智慧食堂
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.

355 Zeilen
8.6 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. }, nil)
  77. return
  78. }
  79. func CentralKitchenForSchoolDataStatisticsDelete(c *gin.Context) {
  80. id := c.Param("id")
  81. centralKitchenForSchoolExportRecordsDb := db.CentralKitchenForSchoolExportRecordsDb{}
  82. centralKitchenForSchoolExportRecordsDb.Set()
  83. centralKitchenForSchoolExportRecords, err := centralKitchenForSchoolExportRecordsDb.GetCentralKitchenForSchoolExportRecords(utils.StrToInt(id))
  84. if err != nil {
  85. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  86. return
  87. }
  88. if centralKitchenForSchoolExportRecords == nil {
  89. e.OutErr(c, e.ERR_NO_DATA, "未查询到相关记录")
  90. return
  91. }
  92. _, err = centralKitchenForSchoolExportRecordsDb.CentralKitchenForSchoolExportRecordsDelete(id)
  93. if err != nil {
  94. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  95. return
  96. }
  97. e.OutSuc(c, "success", nil)
  98. return
  99. }
  100. func CentralKitchenForSchoolDataStatisticsExport(c *gin.Context) {
  101. var req md.CentralKitchenForSchoolDataStatisticsExportReq
  102. err := c.ShouldBindJSON(&req)
  103. if err != nil {
  104. err = validate.HandleValidateErr(err)
  105. err1 := err.(e.E)
  106. e.OutErr(c, err1.Code, err1.Error())
  107. return
  108. }
  109. if req.EnterpriseId != 0 {
  110. enterpriseDb := db.EnterpriseDb{}
  111. enterpriseDb.Set()
  112. enterprise, err1 := enterpriseDb.GetEnterprise(req.EnterpriseId)
  113. if err1 != nil {
  114. e.OutErr(c, e.ERR_DB_ORM, err1.Error())
  115. return
  116. }
  117. req.EnterpriseName = enterprise.Name
  118. }
  119. go svc.CentralKitchenForSchoolDataStatisticsExport(req)
  120. e.OutSuc(c, map[string]interface{}{
  121. "msg": "导出成功,请稍后刷新数据列表",
  122. }, nil)
  123. return
  124. }
  125. func CentralKitchenForSchoolDataStatisticsContrast(c *gin.Context) {
  126. var req md.CentralKitchenForSchoolDataStatisticsContrastReq
  127. err := c.ShouldBindJSON(&req)
  128. if err != nil {
  129. err = validate.HandleValidateErr(err)
  130. err1 := err.(e.E)
  131. e.OutErr(c, err1.Code, err1.Error())
  132. return
  133. }
  134. if req.EnterpriseId != 0 {
  135. enterpriseDb := db.EnterpriseDb{}
  136. enterpriseDb.Set()
  137. enterprise, err1 := enterpriseDb.GetEnterprise(req.EnterpriseId)
  138. if err1 != nil {
  139. e.OutErr(c, e.ERR_DB_ORM, err1.Error())
  140. return
  141. }
  142. req.EnterpriseName = enterprise.Name
  143. }
  144. go svc.CentralKitchenForSchoolDataStatisticsContrast(req)
  145. e.OutSuc(c, map[string]interface{}{
  146. "msg": "导出成功,请稍后刷新数据列表",
  147. }, nil)
  148. return
  149. }
  150. func NursingHomeDataStatisticsList(c *gin.Context) {
  151. var req md.NursingHomeExportRecordsListReq
  152. err := c.ShouldBindJSON(&req)
  153. if err != nil {
  154. err = validate.HandleValidateErr(err)
  155. err1 := err.(e.E)
  156. e.OutErr(c, err1.Code, err1.Error())
  157. return
  158. }
  159. if req.Limit == 0 {
  160. req.Limit = 10
  161. }
  162. if req.Page == 0 {
  163. req.Page = 10
  164. }
  165. nursingHomeExportRecordsDb := db.NursingHomeExportRecordsDb{}
  166. nursingHomeExportRecordsDb.Set()
  167. list, total, err := nursingHomeExportRecordsDb.NursingHomeExportRecordsList(req)
  168. if err != nil {
  169. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  170. return
  171. }
  172. e.OutSuc(c, map[string]interface{}{
  173. "list": list,
  174. "total": total,
  175. "kind": []map[string]interface{}{
  176. {
  177. "name": "订单列表",
  178. "value": 1,
  179. },
  180. {
  181. "name": "退款申请表",
  182. "value": 2,
  183. },
  184. {
  185. "name": "预定统计表",
  186. "value": 3,
  187. },
  188. },
  189. }, nil)
  190. return
  191. }
  192. func NursingHomeDataStatisticsDelete(c *gin.Context) {
  193. id := c.Param("id")
  194. nursingHomeExportRecordsDb := db.NursingHomeExportRecordsDb{}
  195. nursingHomeExportRecordsDb.Set()
  196. centralKitchenForSchoolExportRecords, err := nursingHomeExportRecordsDb.GetNursingHomeExportRecords(utils.StrToInt(id))
  197. if err != nil {
  198. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  199. return
  200. }
  201. if centralKitchenForSchoolExportRecords == nil {
  202. e.OutErr(c, e.ERR_NO_DATA, "未查询到相关记录")
  203. return
  204. }
  205. os.RemoveAll("./static" + centralKitchenForSchoolExportRecords.DownloadPath) //移除文件
  206. _, err = nursingHomeExportRecordsDb.NursingHomeExportRecordsDelete(id)
  207. if err != nil {
  208. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  209. return
  210. }
  211. e.OutSuc(c, "success", nil)
  212. return
  213. }
  214. func NursingHomeDataStatisticsExport(c *gin.Context) {
  215. var req md.NursingHomeDataStatisticsExportReq
  216. err := c.ShouldBindJSON(&req)
  217. if err != nil {
  218. err = validate.HandleValidateErr(err)
  219. err1 := err.(e.E)
  220. e.OutErr(c, err1.Code, err1.Error())
  221. return
  222. }
  223. if req.EnterpriseId != 0 {
  224. enterpriseDb := db.EnterpriseDb{}
  225. enterpriseDb.Set()
  226. enterprise, err1 := enterpriseDb.GetEnterprise(req.EnterpriseId)
  227. if err1 != nil {
  228. e.OutErr(c, e.ERR_DB_ORM, err1.Error())
  229. return
  230. }
  231. req.EnterpriseName = enterprise.Name
  232. }
  233. go svc.NursingHomeDataStatisticsExport(req)
  234. e.OutSuc(c, map[string]interface{}{
  235. "msg": "导出成功,请稍后刷新数据列表",
  236. }, nil)
  237. return
  238. }
  239. func SelfSupportForSchoolDataStatisticsList(c *gin.Context) {
  240. var req md.SelfSupportForSchoolExportRecordsListReq
  241. err := c.ShouldBindJSON(&req)
  242. if err != nil {
  243. err = validate.HandleValidateErr(err)
  244. err1 := err.(e.E)
  245. e.OutErr(c, err1.Code, err1.Error())
  246. return
  247. }
  248. if req.Limit == 0 {
  249. req.Limit = 10
  250. }
  251. if req.Page == 0 {
  252. req.Page = 10
  253. }
  254. selfSupportForSchoolExportRecordsDb := db.SelfSupportForSchoolExportRecordsDb{}
  255. selfSupportForSchoolExportRecordsDb.Set()
  256. list, total, err := selfSupportForSchoolExportRecordsDb.SelfSupportForSchoolExportRecordsList(req)
  257. if err != nil {
  258. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  259. return
  260. }
  261. e.OutSuc(c, map[string]interface{}{
  262. "list": list,
  263. "total": total,
  264. "enterprise_kind_list": md.EnterpriseKindForSchool,
  265. "kind": []map[string]interface{}{
  266. {
  267. "name": "教师消费统计表",
  268. "value": 1,
  269. },
  270. {
  271. "name": "商家分餐数据统计表",
  272. "value": 2,
  273. },
  274. {
  275. "name": "就餐数据统计表",
  276. "value": 3,
  277. },
  278. },
  279. }, nil)
  280. return
  281. }
  282. func SelfSupportForSchoolDataStatisticsDelete(c *gin.Context) {
  283. id := c.Param("id")
  284. selfSupportForSchoolExportRecordsDb := db.SelfSupportForSchoolExportRecordsDb{}
  285. selfSupportForSchoolExportRecordsDb.Set()
  286. selfSupportForSchoolExportRecords, err := selfSupportForSchoolExportRecordsDb.GetSelfSupportForSchoolExportRecords(utils.StrToInt(id))
  287. if err != nil {
  288. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  289. return
  290. }
  291. if selfSupportForSchoolExportRecords == nil {
  292. e.OutErr(c, e.ERR_NO_DATA, "未查询到相关记录")
  293. return
  294. }
  295. os.RemoveAll("./static" + selfSupportForSchoolExportRecords.DownloadPath) //移除文件
  296. _, err = selfSupportForSchoolExportRecordsDb.SelfSupportForSchoolExportRecordsDelete(id)
  297. if err != nil {
  298. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  299. return
  300. }
  301. e.OutSuc(c, "success", nil)
  302. return
  303. }
  304. func SelfSupportForSchoolDataStatisticsExport(c *gin.Context) {
  305. var req md.SelfSupportForSchoolDataStatisticsExportReq
  306. err := c.ShouldBindJSON(&req)
  307. if err != nil {
  308. err = validate.HandleValidateErr(err)
  309. err1 := err.(e.E)
  310. e.OutErr(c, err1.Code, err1.Error())
  311. return
  312. }
  313. if req.EnterpriseId != 0 {
  314. enterpriseDb := db.EnterpriseDb{}
  315. enterpriseDb.Set()
  316. enterprise, err1 := enterpriseDb.GetEnterprise(req.EnterpriseId)
  317. if err1 != nil {
  318. e.OutErr(c, e.ERR_DB_ORM, err1.Error())
  319. return
  320. }
  321. req.EnterpriseName = enterprise.Name
  322. }
  323. go svc.SelfSupportForSchoolDataStatisticsExport(req)
  324. e.OutSuc(c, map[string]interface{}{
  325. "msg": "导出成功,请稍后刷新数据列表",
  326. }, nil)
  327. return
  328. }