智慧食堂
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

hdl_data_statistics.go 8.7 KiB

1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  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. "name": "设备就餐数据统计表",
  284. "value": 4,
  285. },
  286. },
  287. }, nil)
  288. return
  289. }
  290. func SelfSupportForSchoolDataStatisticsDelete(c *gin.Context) {
  291. id := c.Param("id")
  292. selfSupportForSchoolExportRecordsDb := db.SelfSupportForSchoolExportRecordsDb{}
  293. selfSupportForSchoolExportRecordsDb.Set()
  294. selfSupportForSchoolExportRecords, err := selfSupportForSchoolExportRecordsDb.GetSelfSupportForSchoolExportRecords(utils.StrToInt(id))
  295. if err != nil {
  296. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  297. return
  298. }
  299. if selfSupportForSchoolExportRecords == nil {
  300. e.OutErr(c, e.ERR_NO_DATA, "未查询到相关记录")
  301. return
  302. }
  303. os.RemoveAll("./static" + selfSupportForSchoolExportRecords.DownloadPath) //移除文件
  304. _, err = selfSupportForSchoolExportRecordsDb.SelfSupportForSchoolExportRecordsDelete(id)
  305. if err != nil {
  306. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  307. return
  308. }
  309. e.OutSuc(c, "success", nil)
  310. return
  311. }
  312. func SelfSupportForSchoolDataStatisticsExport(c *gin.Context) {
  313. var req md.SelfSupportForSchoolDataStatisticsExportReq
  314. err := c.ShouldBindJSON(&req)
  315. if err != nil {
  316. err = validate.HandleValidateErr(err)
  317. err1 := err.(e.E)
  318. e.OutErr(c, err1.Code, err1.Error())
  319. return
  320. }
  321. if req.EnterpriseId != 0 {
  322. enterpriseDb := db.EnterpriseDb{}
  323. enterpriseDb.Set()
  324. enterprise, err1 := enterpriseDb.GetEnterprise(req.EnterpriseId)
  325. if err1 != nil {
  326. e.OutErr(c, e.ERR_DB_ORM, err1.Error())
  327. return
  328. }
  329. req.EnterpriseName = enterprise.Name
  330. }
  331. go svc.SelfSupportForSchoolDataStatisticsExport(req)
  332. e.OutSuc(c, map[string]interface{}{
  333. "msg": "导出成功,请稍后刷新数据列表",
  334. }, nil)
  335. return
  336. }