智慧食堂
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

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