|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402 |
- package hdl
-
- import (
- "applet/app/admin/lib/validate"
- "applet/app/admin/md"
- "applet/app/admin/svc"
- "applet/app/db"
- "applet/app/e"
- "github.com/gin-gonic/gin"
- "os"
- )
-
- func CentralKitchenForSchoolDataStatisticsList(c *gin.Context) {
- var req md.CentralKitchenForSchoolExportRecordsListReq
- err := c.ShouldBindJSON(&req)
- if err != nil {
- err = validate.HandleValidateErr(err)
- err1 := err.(e.E)
- e.OutErr(c, err1.Code, err1.Error())
- return
- }
- if req.Limit == 0 {
- req.Limit = 10
- }
- if req.Page == 0 {
- req.Page = 10
- }
- centralKitchenForSchoolExportRecordsDb := db.CentralKitchenForSchoolExportRecordsDb{}
- centralKitchenForSchoolExportRecordsDb.Set()
- list, total, err := centralKitchenForSchoolExportRecordsDb.CentralKitchenForSchoolExportRecordsList(req)
- if err != nil {
- e.OutErr(c, e.ERR_DB_ORM, err.Error())
- return
- }
-
- e.OutSuc(c, map[string]interface{}{
- "list": list,
- "total": total,
- "enterprise_kind_list": md.EnterpriseKindForSchool,
- "kind": []map[string]interface{}{
- {
- "name": "订单列表",
- "value": 1,
- },
- {
- "name": "退款申请表",
- "value": 2,
- },
- {
- "name": "学校预定统计表",
- "value": 3,
- },
- {
- "name": "班级明细表",
- "value": 4,
- },
- {
- "name": "退款明细表",
- "value": 5,
- },
- {
- "name": "收款统计表",
- "value": 6,
- },
- {
- "name": "班级收款明细表",
- "value": 7,
- },
- {
- "name": "学校预定数量统计表",
- "value": 8,
- },
- {
- "name": "数据对比",
- "value": 9,
- },
- {
- "name": "就餐数据统计表",
- "value": 10,
- },
- {
- "name": "教师就餐明细表",
- "value": 11,
- },
- },
- }, nil)
- return
- }
-
- func CentralKitchenForSchoolDataStatisticsDelete(c *gin.Context) {
- var req struct {
- Ids []int `json:"ids"`
- }
- err := c.ShouldBindJSON(&req)
- if err != nil {
- err = validate.HandleValidateErr(err)
- err1 := err.(e.E)
- e.OutErr(c, err1.Code, err1.Error())
- return
- }
-
- for _, id := range req.Ids {
- centralKitchenForSchoolExportRecordsDb := db.CentralKitchenForSchoolExportRecordsDb{}
- centralKitchenForSchoolExportRecordsDb.Set()
- centralKitchenForSchoolExportRecords, err0 := centralKitchenForSchoolExportRecordsDb.GetCentralKitchenForSchoolExportRecords(id)
- if err0 != nil {
- e.OutErr(c, e.ERR_DB_ORM, err0.Error())
- return
- }
- if centralKitchenForSchoolExportRecords == nil {
- e.OutErr(c, e.ERR_NO_DATA, "未查询到相关记录")
- return
- }
- _, err1 := centralKitchenForSchoolExportRecordsDb.CentralKitchenForSchoolExportRecordsDelete(id)
- if err1 != nil {
- e.OutErr(c, e.ERR_DB_ORM, err1.Error())
- return
- }
- }
- e.OutSuc(c, "success", nil)
- return
- }
-
- func CentralKitchenForSchoolDataStatisticsExport(c *gin.Context) {
- var req md.CentralKitchenForSchoolDataStatisticsExportReq
- err := c.ShouldBindJSON(&req)
- if err != nil {
- err = validate.HandleValidateErr(err)
- err1 := err.(e.E)
- e.OutErr(c, err1.Code, err1.Error())
- return
- }
- if req.EnterpriseId != 0 {
- enterpriseDb := db.EnterpriseDb{}
- enterpriseDb.Set()
- enterprise, err1 := enterpriseDb.GetEnterprise(req.EnterpriseId)
- if err1 != nil {
- e.OutErr(c, e.ERR_DB_ORM, err1.Error())
- return
- }
- req.EnterpriseName = enterprise.Name
- }
-
- go svc.CentralKitchenForSchoolDataStatisticsExport(req)
-
- e.OutSuc(c, map[string]interface{}{
- "msg": "导出成功,请稍后刷新数据列表",
- }, nil)
- return
- }
-
- func CentralKitchenForSchoolDataStatisticsContrast(c *gin.Context) {
- var req md.CentralKitchenForSchoolDataStatisticsContrastReq
- err := c.ShouldBindJSON(&req)
- if err != nil {
- err = validate.HandleValidateErr(err)
- err1 := err.(e.E)
- e.OutErr(c, err1.Code, err1.Error())
- return
- }
- if req.EnterpriseId != 0 {
- enterpriseDb := db.EnterpriseDb{}
- enterpriseDb.Set()
- enterprise, err1 := enterpriseDb.GetEnterprise(req.EnterpriseId)
- if err1 != nil {
- e.OutErr(c, e.ERR_DB_ORM, err1.Error())
- return
- }
- req.EnterpriseName = enterprise.Name
- }
-
- go svc.CentralKitchenForSchoolDataStatisticsContrast(req)
-
- e.OutSuc(c, map[string]interface{}{
- "msg": "导出成功,请稍后刷新数据列表",
- }, nil)
- return
- }
-
- func NursingHomeDataStatisticsList(c *gin.Context) {
- var req md.NursingHomeExportRecordsListReq
- err := c.ShouldBindJSON(&req)
- if err != nil {
- err = validate.HandleValidateErr(err)
- err1 := err.(e.E)
- e.OutErr(c, err1.Code, err1.Error())
- return
- }
- if req.Limit == 0 {
- req.Limit = 10
- }
- if req.Page == 0 {
- req.Page = 10
- }
-
- nursingHomeExportRecordsDb := db.NursingHomeExportRecordsDb{}
- nursingHomeExportRecordsDb.Set()
- list, total, err := nursingHomeExportRecordsDb.NursingHomeExportRecordsList(req)
- if err != nil {
- e.OutErr(c, e.ERR_DB_ORM, err.Error())
- return
- }
-
- e.OutSuc(c, map[string]interface{}{
- "list": list,
- "total": total,
- "kind": []map[string]interface{}{
- {
- "name": "订单列表",
- "value": 1,
- },
- {
- "name": "退款申请表",
- "value": 2,
- },
- {
- "name": "预定统计表",
- "value": 3,
- },
- },
- }, nil)
- return
- }
-
- func NursingHomeDataStatisticsDelete(c *gin.Context) {
- var req struct {
- Ids []int `json:"ids"`
- }
- err := c.ShouldBindJSON(&req)
- if err != nil {
- err = validate.HandleValidateErr(err)
- err1 := err.(e.E)
- e.OutErr(c, err1.Code, err1.Error())
- return
- }
- for _, id := range req.Ids {
- nursingHomeExportRecordsDb := db.NursingHomeExportRecordsDb{}
- nursingHomeExportRecordsDb.Set()
- centralKitchenForSchoolExportRecords, err1 := nursingHomeExportRecordsDb.GetNursingHomeExportRecords(id)
- if err1 != nil {
- e.OutErr(c, e.ERR_DB_ORM, err1.Error())
- return
- }
- if centralKitchenForSchoolExportRecords == nil {
- e.OutErr(c, e.ERR_NO_DATA, "未查询到相关记录")
- return
- }
- os.RemoveAll("./static" + centralKitchenForSchoolExportRecords.DownloadPath) //移除文件
- _, err2 := nursingHomeExportRecordsDb.NursingHomeExportRecordsDelete(id)
- if err2 != nil {
- e.OutErr(c, e.ERR_DB_ORM, err2.Error())
- return
- }
- }
-
- e.OutSuc(c, "success", nil)
- return
- }
-
- func NursingHomeDataStatisticsExport(c *gin.Context) {
- var req md.NursingHomeDataStatisticsExportReq
- err := c.ShouldBindJSON(&req)
- if err != nil {
- err = validate.HandleValidateErr(err)
- err1 := err.(e.E)
- e.OutErr(c, err1.Code, err1.Error())
- return
- }
-
- if req.EnterpriseId != 0 {
- enterpriseDb := db.EnterpriseDb{}
- enterpriseDb.Set()
- enterprise, err1 := enterpriseDb.GetEnterprise(req.EnterpriseId)
- if err1 != nil {
- e.OutErr(c, e.ERR_DB_ORM, err1.Error())
- return
- }
- req.EnterpriseName = enterprise.Name
- }
-
- go svc.NursingHomeDataStatisticsExport(req)
-
- e.OutSuc(c, map[string]interface{}{
- "msg": "导出成功,请稍后刷新数据列表",
- }, nil)
- return
- }
-
- func SelfSupportForSchoolDataStatisticsList(c *gin.Context) {
- var req md.SelfSupportForSchoolExportRecordsListReq
- err := c.ShouldBindJSON(&req)
- if err != nil {
- err = validate.HandleValidateErr(err)
- err1 := err.(e.E)
- e.OutErr(c, err1.Code, err1.Error())
- return
- }
- if req.Limit == 0 {
- req.Limit = 10
- }
- if req.Page == 0 {
- req.Page = 10
- }
-
- selfSupportForSchoolExportRecordsDb := db.SelfSupportForSchoolExportRecordsDb{}
- selfSupportForSchoolExportRecordsDb.Set()
- list, total, err := selfSupportForSchoolExportRecordsDb.SelfSupportForSchoolExportRecordsList(req)
- if err != nil {
- e.OutErr(c, e.ERR_DB_ORM, err.Error())
- return
- }
-
- e.OutSuc(c, map[string]interface{}{
- "list": list,
- "total": total,
- "enterprise_kind_list": md.EnterpriseKindForSchool,
- "kind": []map[string]interface{}{
- {
- "name": "教师消费统计表",
- "value": 1,
- },
- {
- "name": "商家分餐数据统计表",
- "value": 2,
- },
- {
- "name": "学校就餐数据统计表",
- "value": 3,
- },
- {
- "name": "设备就餐数据统计表",
- "value": 4,
- },
- },
- }, nil)
- return
- }
-
- func SelfSupportForSchoolDataStatisticsDelete(c *gin.Context) {
- var req struct {
- Ids []int `json:"ids"`
- }
- err := c.ShouldBindJSON(&req)
- if err != nil {
- err = validate.HandleValidateErr(err)
- err1 := err.(e.E)
- e.OutErr(c, err1.Code, err1.Error())
- return
- }
-
- for _, id := range req.Ids {
- selfSupportForSchoolExportRecordsDb := db.SelfSupportForSchoolExportRecordsDb{}
- selfSupportForSchoolExportRecordsDb.Set()
- selfSupportForSchoolExportRecords, err1 := selfSupportForSchoolExportRecordsDb.GetSelfSupportForSchoolExportRecords(id)
- if err1 != nil {
- e.OutErr(c, e.ERR_DB_ORM, err1.Error())
- return
- }
- if selfSupportForSchoolExportRecords == nil {
- e.OutErr(c, e.ERR_NO_DATA, "未查询到相关记录")
- return
- }
- os.RemoveAll("./static" + selfSupportForSchoolExportRecords.DownloadPath) //移除文件
- _, err2 := selfSupportForSchoolExportRecordsDb.SelfSupportForSchoolExportRecordsDelete(id)
- if err2 != nil {
- e.OutErr(c, e.ERR_DB_ORM, err2.Error())
- return
- }
- }
-
- e.OutSuc(c, "success", nil)
- return
- }
-
- func SelfSupportForSchoolDataStatisticsExport(c *gin.Context) {
- var req md.SelfSupportForSchoolDataStatisticsExportReq
- err := c.ShouldBindJSON(&req)
- if err != nil {
- err = validate.HandleValidateErr(err)
- err1 := err.(e.E)
- e.OutErr(c, err1.Code, err1.Error())
- return
- }
-
- if req.EnterpriseId != 0 {
- enterpriseDb := db.EnterpriseDb{}
- enterpriseDb.Set()
- enterprise, err1 := enterpriseDb.GetEnterprise(req.EnterpriseId)
- if err1 != nil {
- e.OutErr(c, e.ERR_DB_ORM, err1.Error())
- return
- }
- req.EnterpriseName = enterprise.Name
- }
-
- go svc.SelfSupportForSchoolDataStatisticsExport(req)
-
- e.OutSuc(c, map[string]interface{}{
- "msg": "导出成功,请稍后刷新数据列表",
- }, nil)
- return
- }
|