智慧食堂
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

hdl_data_statistics.go 8.4 KiB

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