智慧食堂
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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  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. e.OutSuc(c, map[string]interface{}{
  115. "msg": "导出成功,请稍后刷新数据列表",
  116. }, nil)
  117. return
  118. }
  119. func NursingHomeDataStatisticsList(c *gin.Context) {
  120. var req md.NursingHomeExportRecordsListReq
  121. err := c.ShouldBindJSON(&req)
  122. if err != nil {
  123. err = validate.HandleValidateErr(err)
  124. err1 := err.(e.E)
  125. e.OutErr(c, err1.Code, err1.Error())
  126. return
  127. }
  128. if req.Limit == 0 {
  129. req.Limit = 10
  130. }
  131. if req.Page == 0 {
  132. req.Page = 10
  133. }
  134. nursingHomeExportRecordsDb := db.NursingHomeExportRecordsDb{}
  135. nursingHomeExportRecordsDb.Set()
  136. list, total, err := nursingHomeExportRecordsDb.NursingHomeExportRecordsList(req)
  137. if err != nil {
  138. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  139. return
  140. }
  141. e.OutSuc(c, map[string]interface{}{
  142. "list": list,
  143. "total": total,
  144. "kind": []map[string]interface{}{
  145. {
  146. "name": "订单列表",
  147. "value": 1,
  148. },
  149. {
  150. "name": "退款申请表",
  151. "value": 2,
  152. },
  153. {
  154. "name": "预定统计表",
  155. "value": 3,
  156. },
  157. },
  158. }, nil)
  159. return
  160. }
  161. func NursingHomeDataStatisticsDelete(c *gin.Context) {
  162. id := c.Param("id")
  163. nursingHomeExportRecordsDb := db.NursingHomeExportRecordsDb{}
  164. nursingHomeExportRecordsDb.Set()
  165. centralKitchenForSchoolExportRecords, err := nursingHomeExportRecordsDb.GetNursingHomeExportRecords(utils.StrToInt(id))
  166. if err != nil {
  167. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  168. return
  169. }
  170. if centralKitchenForSchoolExportRecords == nil {
  171. e.OutErr(c, e.ERR_NO_DATA, "未查询到相关记录")
  172. return
  173. }
  174. os.RemoveAll("./static" + centralKitchenForSchoolExportRecords.DownloadPath) //移除文件
  175. _, err = nursingHomeExportRecordsDb.NursingHomeExportRecordsDelete(id)
  176. if err != nil {
  177. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  178. return
  179. }
  180. e.OutSuc(c, "success", nil)
  181. return
  182. }
  183. func NursingHomeDataStatisticsExport(c *gin.Context) {
  184. var req md.NursingHomeDataStatisticsExportReq
  185. err := c.ShouldBindJSON(&req)
  186. if err != nil {
  187. err = validate.HandleValidateErr(err)
  188. err1 := err.(e.E)
  189. e.OutErr(c, err1.Code, err1.Error())
  190. return
  191. }
  192. if req.EnterpriseId != 0 {
  193. enterpriseDb := db.EnterpriseDb{}
  194. enterpriseDb.Set()
  195. enterprise, err1 := enterpriseDb.GetEnterprise(req.EnterpriseId)
  196. if err1 != nil {
  197. e.OutErr(c, e.ERR_DB_ORM, err1.Error())
  198. return
  199. }
  200. req.EnterpriseName = enterprise.Name
  201. }
  202. go svc.NursingHomeDataStatisticsExport(req)
  203. e.OutSuc(c, map[string]interface{}{
  204. "msg": "导出成功,请稍后刷新数据列表",
  205. }, nil)
  206. return
  207. }
  208. func SelfSupportForSchoolDataStatisticsList(c *gin.Context) {
  209. var req md.SelfSupportForSchoolExportRecordsListReq
  210. err := c.ShouldBindJSON(&req)
  211. if err != nil {
  212. err = validate.HandleValidateErr(err)
  213. err1 := err.(e.E)
  214. e.OutErr(c, err1.Code, err1.Error())
  215. return
  216. }
  217. if req.Limit == 0 {
  218. req.Limit = 10
  219. }
  220. if req.Page == 0 {
  221. req.Page = 10
  222. }
  223. selfSupportForSchoolExportRecordsDb := db.SelfSupportForSchoolExportRecordsDb{}
  224. selfSupportForSchoolExportRecordsDb.Set()
  225. list, total, err := selfSupportForSchoolExportRecordsDb.SelfSupportForSchoolExportRecordsList(req)
  226. if err != nil {
  227. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  228. return
  229. }
  230. e.OutSuc(c, map[string]interface{}{
  231. "list": list,
  232. "total": total,
  233. "kind": []map[string]interface{}{
  234. {
  235. "name": "学生列表",
  236. "value": 1,
  237. },
  238. {
  239. "name": "老师列表",
  240. "value": 2,
  241. },
  242. {
  243. "name": "消费明细表",
  244. "value": 3,
  245. },
  246. },
  247. }, nil)
  248. return
  249. }
  250. func SelfSupportForSchoolDataStatisticsDelete(c *gin.Context) {
  251. id := c.Param("id")
  252. selfSupportForSchoolExportRecordsDb := db.SelfSupportForSchoolExportRecordsDb{}
  253. selfSupportForSchoolExportRecordsDb.Set()
  254. selfSupportForSchoolExportRecords, err := selfSupportForSchoolExportRecordsDb.GetSelfSupportForSchoolExportRecords(utils.StrToInt(id))
  255. if err != nil {
  256. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  257. return
  258. }
  259. if selfSupportForSchoolExportRecords == nil {
  260. e.OutErr(c, e.ERR_NO_DATA, "未查询到相关记录")
  261. return
  262. }
  263. os.RemoveAll("./static" + selfSupportForSchoolExportRecords.DownloadPath) //移除文件
  264. _, err = selfSupportForSchoolExportRecordsDb.SelfSupportForSchoolExportRecordsDelete(id)
  265. if err != nil {
  266. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  267. return
  268. }
  269. e.OutSuc(c, "success", nil)
  270. return
  271. }
  272. func SelfSupportForSchoolDataStatisticsExport(c *gin.Context) {
  273. var req md.SelfSupportForSchoolDataStatisticsExportReq
  274. err := c.ShouldBindJSON(&req)
  275. if err != nil {
  276. err = validate.HandleValidateErr(err)
  277. err1 := err.(e.E)
  278. e.OutErr(c, err1.Code, err1.Error())
  279. return
  280. }
  281. if req.EnterpriseId != 0 {
  282. enterpriseDb := db.EnterpriseDb{}
  283. enterpriseDb.Set()
  284. enterprise, err1 := enterpriseDb.GetEnterprise(req.EnterpriseId)
  285. if err1 != nil {
  286. e.OutErr(c, e.ERR_DB_ORM, err1.Error())
  287. return
  288. }
  289. req.EnterpriseName = enterprise.Name
  290. }
  291. go svc.SelfSupportForSchoolDataStatisticsExport(req)
  292. e.OutSuc(c, map[string]interface{}{
  293. "msg": "导出成功,请稍后刷新数据列表",
  294. }, nil)
  295. return
  296. }