智慧食堂
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

359 Zeilen
8.7 KiB

  1. package hdl
  2. import (
  3. "applet/app/admin/lib/validate"
  4. "applet/app/admin/md"
  5. "applet/app/admin/svc"
  6. "applet/app/db"
  7. "applet/app/e"
  8. "applet/app/utils"
  9. "github.com/gin-gonic/gin"
  10. "os"
  11. )
  12. func CentralKitchenForSchoolDataStatisticsList(c *gin.Context) {
  13. var req md.CentralKitchenForSchoolExportRecordsListReq
  14. err := c.ShouldBindJSON(&req)
  15. if err != nil {
  16. err = validate.HandleValidateErr(err)
  17. err1 := err.(e.E)
  18. e.OutErr(c, err1.Code, err1.Error())
  19. return
  20. }
  21. if req.Limit == 0 {
  22. req.Limit = 10
  23. }
  24. if req.Page == 0 {
  25. req.Page = 10
  26. }
  27. centralKitchenForSchoolExportRecordsDb := db.CentralKitchenForSchoolExportRecordsDb{}
  28. centralKitchenForSchoolExportRecordsDb.Set()
  29. list, total, err := centralKitchenForSchoolExportRecordsDb.CentralKitchenForSchoolExportRecordsList(req)
  30. if err != nil {
  31. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  32. return
  33. }
  34. e.OutSuc(c, map[string]interface{}{
  35. "list": list,
  36. "total": total,
  37. "enterprise_kind_list": md.EnterpriseKindForSchool,
  38. "kind": []map[string]interface{}{
  39. {
  40. "name": "订单列表",
  41. "value": 1,
  42. },
  43. {
  44. "name": "退款申请表",
  45. "value": 2,
  46. },
  47. {
  48. "name": "学校预定统计表",
  49. "value": 3,
  50. },
  51. {
  52. "name": "班级明细表",
  53. "value": 4,
  54. },
  55. {
  56. "name": "退款明细表",
  57. "value": 5,
  58. },
  59. {
  60. "name": "收款统计表",
  61. "value": 6,
  62. },
  63. {
  64. "name": "班级收款明细表",
  65. "value": 7,
  66. },
  67. {
  68. "name": "学校预定数量统计表",
  69. "value": 8,
  70. },
  71. {
  72. "name": "数据对比",
  73. "value": 9,
  74. },
  75. {
  76. "name": "就餐数据统计表",
  77. "value": 10,
  78. },
  79. },
  80. }, nil)
  81. return
  82. }
  83. func CentralKitchenForSchoolDataStatisticsDelete(c *gin.Context) {
  84. id := c.Param("id")
  85. centralKitchenForSchoolExportRecordsDb := db.CentralKitchenForSchoolExportRecordsDb{}
  86. centralKitchenForSchoolExportRecordsDb.Set()
  87. centralKitchenForSchoolExportRecords, err := centralKitchenForSchoolExportRecordsDb.GetCentralKitchenForSchoolExportRecords(utils.StrToInt(id))
  88. if err != nil {
  89. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  90. return
  91. }
  92. if centralKitchenForSchoolExportRecords == nil {
  93. e.OutErr(c, e.ERR_NO_DATA, "未查询到相关记录")
  94. return
  95. }
  96. _, err = centralKitchenForSchoolExportRecordsDb.CentralKitchenForSchoolExportRecordsDelete(id)
  97. if err != nil {
  98. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  99. return
  100. }
  101. e.OutSuc(c, "success", nil)
  102. return
  103. }
  104. func CentralKitchenForSchoolDataStatisticsExport(c *gin.Context) {
  105. var req md.CentralKitchenForSchoolDataStatisticsExportReq
  106. err := c.ShouldBindJSON(&req)
  107. if err != nil {
  108. err = validate.HandleValidateErr(err)
  109. err1 := err.(e.E)
  110. e.OutErr(c, err1.Code, err1.Error())
  111. return
  112. }
  113. if req.EnterpriseId != 0 {
  114. enterpriseDb := db.EnterpriseDb{}
  115. enterpriseDb.Set()
  116. enterprise, err1 := enterpriseDb.GetEnterprise(req.EnterpriseId)
  117. if err1 != nil {
  118. e.OutErr(c, e.ERR_DB_ORM, err1.Error())
  119. return
  120. }
  121. req.EnterpriseName = enterprise.Name
  122. }
  123. go svc.CentralKitchenForSchoolDataStatisticsExport(req)
  124. e.OutSuc(c, map[string]interface{}{
  125. "msg": "导出成功,请稍后刷新数据列表",
  126. }, nil)
  127. return
  128. }
  129. func CentralKitchenForSchoolDataStatisticsContrast(c *gin.Context) {
  130. var req md.CentralKitchenForSchoolDataStatisticsContrastReq
  131. err := c.ShouldBindJSON(&req)
  132. if err != nil {
  133. err = validate.HandleValidateErr(err)
  134. err1 := err.(e.E)
  135. e.OutErr(c, err1.Code, err1.Error())
  136. return
  137. }
  138. if req.EnterpriseId != 0 {
  139. enterpriseDb := db.EnterpriseDb{}
  140. enterpriseDb.Set()
  141. enterprise, err1 := enterpriseDb.GetEnterprise(req.EnterpriseId)
  142. if err1 != nil {
  143. e.OutErr(c, e.ERR_DB_ORM, err1.Error())
  144. return
  145. }
  146. req.EnterpriseName = enterprise.Name
  147. }
  148. go svc.CentralKitchenForSchoolDataStatisticsContrast(req)
  149. e.OutSuc(c, map[string]interface{}{
  150. "msg": "导出成功,请稍后刷新数据列表",
  151. }, nil)
  152. return
  153. }
  154. func NursingHomeDataStatisticsList(c *gin.Context) {
  155. var req md.NursingHomeExportRecordsListReq
  156. err := c.ShouldBindJSON(&req)
  157. if err != nil {
  158. err = validate.HandleValidateErr(err)
  159. err1 := err.(e.E)
  160. e.OutErr(c, err1.Code, err1.Error())
  161. return
  162. }
  163. if req.Limit == 0 {
  164. req.Limit = 10
  165. }
  166. if req.Page == 0 {
  167. req.Page = 10
  168. }
  169. nursingHomeExportRecordsDb := db.NursingHomeExportRecordsDb{}
  170. nursingHomeExportRecordsDb.Set()
  171. list, total, err := nursingHomeExportRecordsDb.NursingHomeExportRecordsList(req)
  172. if err != nil {
  173. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  174. return
  175. }
  176. e.OutSuc(c, map[string]interface{}{
  177. "list": list,
  178. "total": total,
  179. "kind": []map[string]interface{}{
  180. {
  181. "name": "订单列表",
  182. "value": 1,
  183. },
  184. {
  185. "name": "退款申请表",
  186. "value": 2,
  187. },
  188. {
  189. "name": "预定统计表",
  190. "value": 3,
  191. },
  192. },
  193. }, nil)
  194. return
  195. }
  196. func NursingHomeDataStatisticsDelete(c *gin.Context) {
  197. id := c.Param("id")
  198. nursingHomeExportRecordsDb := db.NursingHomeExportRecordsDb{}
  199. nursingHomeExportRecordsDb.Set()
  200. centralKitchenForSchoolExportRecords, err := nursingHomeExportRecordsDb.GetNursingHomeExportRecords(utils.StrToInt(id))
  201. if err != nil {
  202. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  203. return
  204. }
  205. if centralKitchenForSchoolExportRecords == nil {
  206. e.OutErr(c, e.ERR_NO_DATA, "未查询到相关记录")
  207. return
  208. }
  209. os.RemoveAll("./static" + centralKitchenForSchoolExportRecords.DownloadPath) //移除文件
  210. _, err = nursingHomeExportRecordsDb.NursingHomeExportRecordsDelete(id)
  211. if err != nil {
  212. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  213. return
  214. }
  215. e.OutSuc(c, "success", nil)
  216. return
  217. }
  218. func NursingHomeDataStatisticsExport(c *gin.Context) {
  219. var req md.NursingHomeDataStatisticsExportReq
  220. err := c.ShouldBindJSON(&req)
  221. if err != nil {
  222. err = validate.HandleValidateErr(err)
  223. err1 := err.(e.E)
  224. e.OutErr(c, err1.Code, err1.Error())
  225. return
  226. }
  227. if req.EnterpriseId != 0 {
  228. enterpriseDb := db.EnterpriseDb{}
  229. enterpriseDb.Set()
  230. enterprise, err1 := enterpriseDb.GetEnterprise(req.EnterpriseId)
  231. if err1 != nil {
  232. e.OutErr(c, e.ERR_DB_ORM, err1.Error())
  233. return
  234. }
  235. req.EnterpriseName = enterprise.Name
  236. }
  237. go svc.NursingHomeDataStatisticsExport(req)
  238. e.OutSuc(c, map[string]interface{}{
  239. "msg": "导出成功,请稍后刷新数据列表",
  240. }, nil)
  241. return
  242. }
  243. func SelfSupportForSchoolDataStatisticsList(c *gin.Context) {
  244. var req md.SelfSupportForSchoolExportRecordsListReq
  245. err := c.ShouldBindJSON(&req)
  246. if err != nil {
  247. err = validate.HandleValidateErr(err)
  248. err1 := err.(e.E)
  249. e.OutErr(c, err1.Code, err1.Error())
  250. return
  251. }
  252. if req.Limit == 0 {
  253. req.Limit = 10
  254. }
  255. if req.Page == 0 {
  256. req.Page = 10
  257. }
  258. selfSupportForSchoolExportRecordsDb := db.SelfSupportForSchoolExportRecordsDb{}
  259. selfSupportForSchoolExportRecordsDb.Set()
  260. list, total, err := selfSupportForSchoolExportRecordsDb.SelfSupportForSchoolExportRecordsList(req)
  261. if err != nil {
  262. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  263. return
  264. }
  265. e.OutSuc(c, map[string]interface{}{
  266. "list": list,
  267. "total": total,
  268. "enterprise_kind_list": md.EnterpriseKindForSchool,
  269. "kind": []map[string]interface{}{
  270. {
  271. "name": "教师消费统计表",
  272. "value": 1,
  273. },
  274. {
  275. "name": "商家分餐数据统计表",
  276. "value": 2,
  277. },
  278. {
  279. "name": "就餐数据统计表",
  280. "value": 3,
  281. },
  282. },
  283. }, nil)
  284. return
  285. }
  286. func SelfSupportForSchoolDataStatisticsDelete(c *gin.Context) {
  287. id := c.Param("id")
  288. selfSupportForSchoolExportRecordsDb := db.SelfSupportForSchoolExportRecordsDb{}
  289. selfSupportForSchoolExportRecordsDb.Set()
  290. selfSupportForSchoolExportRecords, err := selfSupportForSchoolExportRecordsDb.GetSelfSupportForSchoolExportRecords(utils.StrToInt(id))
  291. if err != nil {
  292. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  293. return
  294. }
  295. if selfSupportForSchoolExportRecords == nil {
  296. e.OutErr(c, e.ERR_NO_DATA, "未查询到相关记录")
  297. return
  298. }
  299. os.RemoveAll("./static" + selfSupportForSchoolExportRecords.DownloadPath) //移除文件
  300. _, err = selfSupportForSchoolExportRecordsDb.SelfSupportForSchoolExportRecordsDelete(id)
  301. if err != nil {
  302. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  303. return
  304. }
  305. e.OutSuc(c, "success", nil)
  306. return
  307. }
  308. func SelfSupportForSchoolDataStatisticsExport(c *gin.Context) {
  309. var req md.SelfSupportForSchoolDataStatisticsExportReq
  310. err := c.ShouldBindJSON(&req)
  311. if err != nil {
  312. err = validate.HandleValidateErr(err)
  313. err1 := err.(e.E)
  314. e.OutErr(c, err1.Code, err1.Error())
  315. return
  316. }
  317. if req.EnterpriseId != 0 {
  318. enterpriseDb := db.EnterpriseDb{}
  319. enterpriseDb.Set()
  320. enterprise, err1 := enterpriseDb.GetEnterprise(req.EnterpriseId)
  321. if err1 != nil {
  322. e.OutErr(c, e.ERR_DB_ORM, err1.Error())
  323. return
  324. }
  325. req.EnterpriseName = enterprise.Name
  326. }
  327. go svc.SelfSupportForSchoolDataStatisticsExport(req)
  328. e.OutSuc(c, map[string]interface{}{
  329. "msg": "导出成功,请稍后刷新数据列表",
  330. }, nil)
  331. return
  332. }