智慧食堂
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

hdl_data_statistics.go 7.6 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  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. "name": "消费明细表",
  245. "value": 3,
  246. },
  247. },
  248. }, nil)
  249. return
  250. }
  251. func SelfSupportForSchoolDataStatisticsDelete(c *gin.Context) {
  252. id := c.Param("id")
  253. selfSupportForSchoolExportRecordsDb := db.SelfSupportForSchoolExportRecordsDb{}
  254. selfSupportForSchoolExportRecordsDb.Set()
  255. selfSupportForSchoolExportRecords, err := selfSupportForSchoolExportRecordsDb.GetSelfSupportForSchoolExportRecords(utils.StrToInt(id))
  256. if err != nil {
  257. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  258. return
  259. }
  260. if selfSupportForSchoolExportRecords == nil {
  261. e.OutErr(c, e.ERR_NO_DATA, "未查询到相关记录")
  262. return
  263. }
  264. os.RemoveAll("./static" + selfSupportForSchoolExportRecords.DownloadPath) //移除文件
  265. _, err = selfSupportForSchoolExportRecordsDb.SelfSupportForSchoolExportRecordsDelete(id)
  266. if err != nil {
  267. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  268. return
  269. }
  270. e.OutSuc(c, "success", nil)
  271. return
  272. }
  273. func SelfSupportForSchoolDataStatisticsExport(c *gin.Context) {
  274. var req md.SelfSupportForSchoolDataStatisticsExportReq
  275. err := c.ShouldBindJSON(&req)
  276. if err != nil {
  277. err = validate.HandleValidateErr(err)
  278. err1 := err.(e.E)
  279. e.OutErr(c, err1.Code, err1.Error())
  280. return
  281. }
  282. if req.EnterpriseId != 0 {
  283. enterpriseDb := db.EnterpriseDb{}
  284. enterpriseDb.Set()
  285. enterprise, err1 := enterpriseDb.GetEnterprise(req.EnterpriseId)
  286. if err1 != nil {
  287. e.OutErr(c, e.ERR_DB_ORM, err1.Error())
  288. return
  289. }
  290. req.EnterpriseName = enterprise.Name
  291. }
  292. go svc.SelfSupportForSchoolDataStatisticsExport(req)
  293. e.OutSuc(c, map[string]interface{}{
  294. "msg": "导出成功,请稍后刷新数据列表",
  295. }, nil)
  296. return
  297. }