智慧食堂
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 9.4 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
2 months ago
1 year ago
1 year ago
1 year ago
8 months ago
1 year ago
8 months ago
1 year ago
8 months ago
1 year ago
8 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
8 months ago
1 year ago
8 months ago
1 year ago
8 months ago
1 year ago
8 months 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
8 months ago
1 year ago
8 months ago
1 year ago
8 months ago
1 year ago
8 months ago
1 year ago
1 year ago
1 year ago
1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  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. "github.com/gin-gonic/gin"
  9. "os"
  10. )
  11. func CentralKitchenForSchoolDataStatisticsList(c *gin.Context) {
  12. var req md.CentralKitchenForSchoolExportRecordsListReq
  13. err := c.ShouldBindJSON(&req)
  14. if err != nil {
  15. err = validate.HandleValidateErr(err)
  16. err1 := err.(e.E)
  17. e.OutErr(c, err1.Code, err1.Error())
  18. return
  19. }
  20. if req.Limit == 0 {
  21. req.Limit = 10
  22. }
  23. if req.Page == 0 {
  24. req.Page = 10
  25. }
  26. centralKitchenForSchoolExportRecordsDb := db.CentralKitchenForSchoolExportRecordsDb{}
  27. centralKitchenForSchoolExportRecordsDb.Set()
  28. list, total, err := centralKitchenForSchoolExportRecordsDb.CentralKitchenForSchoolExportRecordsList(req)
  29. if err != nil {
  30. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  31. return
  32. }
  33. e.OutSuc(c, map[string]interface{}{
  34. "list": list,
  35. "total": total,
  36. "enterprise_kind_list": md.EnterpriseKindForSchool,
  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. "name": "就餐数据统计表",
  76. "value": 10,
  77. },
  78. {
  79. "name": "教师就餐明细表",
  80. "value": 11,
  81. },
  82. },
  83. }, nil)
  84. return
  85. }
  86. func CentralKitchenForSchoolDataStatisticsDelete(c *gin.Context) {
  87. var req struct {
  88. Ids []int `json:"ids"`
  89. }
  90. err := c.ShouldBindJSON(&req)
  91. if err != nil {
  92. err = validate.HandleValidateErr(err)
  93. err1 := err.(e.E)
  94. e.OutErr(c, err1.Code, err1.Error())
  95. return
  96. }
  97. for _, id := range req.Ids {
  98. centralKitchenForSchoolExportRecordsDb := db.CentralKitchenForSchoolExportRecordsDb{}
  99. centralKitchenForSchoolExportRecordsDb.Set()
  100. centralKitchenForSchoolExportRecords, err0 := centralKitchenForSchoolExportRecordsDb.GetCentralKitchenForSchoolExportRecords(id)
  101. if err0 != nil {
  102. e.OutErr(c, e.ERR_DB_ORM, err0.Error())
  103. return
  104. }
  105. if centralKitchenForSchoolExportRecords == nil {
  106. e.OutErr(c, e.ERR_NO_DATA, "未查询到相关记录")
  107. return
  108. }
  109. _, err1 := centralKitchenForSchoolExportRecordsDb.CentralKitchenForSchoolExportRecordsDelete(id)
  110. if err1 != nil {
  111. e.OutErr(c, e.ERR_DB_ORM, err1.Error())
  112. return
  113. }
  114. }
  115. e.OutSuc(c, "success", nil)
  116. return
  117. }
  118. func CentralKitchenForSchoolDataStatisticsExport(c *gin.Context) {
  119. var req md.CentralKitchenForSchoolDataStatisticsExportReq
  120. err := c.ShouldBindJSON(&req)
  121. if err != nil {
  122. err = validate.HandleValidateErr(err)
  123. err1 := err.(e.E)
  124. e.OutErr(c, err1.Code, err1.Error())
  125. return
  126. }
  127. if req.EnterpriseId != 0 {
  128. enterpriseDb := db.EnterpriseDb{}
  129. enterpriseDb.Set()
  130. enterprise, err1 := enterpriseDb.GetEnterprise(req.EnterpriseId)
  131. if err1 != nil {
  132. e.OutErr(c, e.ERR_DB_ORM, err1.Error())
  133. return
  134. }
  135. req.EnterpriseName = enterprise.Name
  136. }
  137. go svc.CentralKitchenForSchoolDataStatisticsExport(req)
  138. e.OutSuc(c, map[string]interface{}{
  139. "msg": "导出成功,请稍后刷新数据列表",
  140. }, nil)
  141. return
  142. }
  143. func CentralKitchenForSchoolDataStatisticsContrast(c *gin.Context) {
  144. var req md.CentralKitchenForSchoolDataStatisticsContrastReq
  145. err := c.ShouldBindJSON(&req)
  146. if err != nil {
  147. err = validate.HandleValidateErr(err)
  148. err1 := err.(e.E)
  149. e.OutErr(c, err1.Code, err1.Error())
  150. return
  151. }
  152. if req.EnterpriseId != 0 {
  153. enterpriseDb := db.EnterpriseDb{}
  154. enterpriseDb.Set()
  155. enterprise, err1 := enterpriseDb.GetEnterprise(req.EnterpriseId)
  156. if err1 != nil {
  157. e.OutErr(c, e.ERR_DB_ORM, err1.Error())
  158. return
  159. }
  160. req.EnterpriseName = enterprise.Name
  161. }
  162. go svc.CentralKitchenForSchoolDataStatisticsContrast(req)
  163. e.OutSuc(c, map[string]interface{}{
  164. "msg": "导出成功,请稍后刷新数据列表",
  165. }, nil)
  166. return
  167. }
  168. func NursingHomeDataStatisticsList(c *gin.Context) {
  169. var req md.NursingHomeExportRecordsListReq
  170. err := c.ShouldBindJSON(&req)
  171. if err != nil {
  172. err = validate.HandleValidateErr(err)
  173. err1 := err.(e.E)
  174. e.OutErr(c, err1.Code, err1.Error())
  175. return
  176. }
  177. if req.Limit == 0 {
  178. req.Limit = 10
  179. }
  180. if req.Page == 0 {
  181. req.Page = 10
  182. }
  183. nursingHomeExportRecordsDb := db.NursingHomeExportRecordsDb{}
  184. nursingHomeExportRecordsDb.Set()
  185. list, total, err := nursingHomeExportRecordsDb.NursingHomeExportRecordsList(req)
  186. if err != nil {
  187. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  188. return
  189. }
  190. e.OutSuc(c, map[string]interface{}{
  191. "list": list,
  192. "total": total,
  193. "kind": []map[string]interface{}{
  194. {
  195. "name": "订单列表",
  196. "value": 1,
  197. },
  198. {
  199. "name": "退款申请表",
  200. "value": 2,
  201. },
  202. {
  203. "name": "预定统计表",
  204. "value": 3,
  205. },
  206. },
  207. }, nil)
  208. return
  209. }
  210. func NursingHomeDataStatisticsDelete(c *gin.Context) {
  211. var req struct {
  212. Ids []int `json:"ids"`
  213. }
  214. err := c.ShouldBindJSON(&req)
  215. if err != nil {
  216. err = validate.HandleValidateErr(err)
  217. err1 := err.(e.E)
  218. e.OutErr(c, err1.Code, err1.Error())
  219. return
  220. }
  221. for _, id := range req.Ids {
  222. nursingHomeExportRecordsDb := db.NursingHomeExportRecordsDb{}
  223. nursingHomeExportRecordsDb.Set()
  224. centralKitchenForSchoolExportRecords, err1 := nursingHomeExportRecordsDb.GetNursingHomeExportRecords(id)
  225. if err1 != nil {
  226. e.OutErr(c, e.ERR_DB_ORM, err1.Error())
  227. return
  228. }
  229. if centralKitchenForSchoolExportRecords == nil {
  230. e.OutErr(c, e.ERR_NO_DATA, "未查询到相关记录")
  231. return
  232. }
  233. os.RemoveAll("./static" + centralKitchenForSchoolExportRecords.DownloadPath) //移除文件
  234. _, err2 := nursingHomeExportRecordsDb.NursingHomeExportRecordsDelete(id)
  235. if err2 != nil {
  236. e.OutErr(c, e.ERR_DB_ORM, err2.Error())
  237. return
  238. }
  239. }
  240. e.OutSuc(c, "success", nil)
  241. return
  242. }
  243. func NursingHomeDataStatisticsExport(c *gin.Context) {
  244. var req md.NursingHomeDataStatisticsExportReq
  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.EnterpriseId != 0 {
  253. enterpriseDb := db.EnterpriseDb{}
  254. enterpriseDb.Set()
  255. enterprise, err1 := enterpriseDb.GetEnterprise(req.EnterpriseId)
  256. if err1 != nil {
  257. e.OutErr(c, e.ERR_DB_ORM, err1.Error())
  258. return
  259. }
  260. req.EnterpriseName = enterprise.Name
  261. }
  262. go svc.NursingHomeDataStatisticsExport(req)
  263. e.OutSuc(c, map[string]interface{}{
  264. "msg": "导出成功,请稍后刷新数据列表",
  265. }, nil)
  266. return
  267. }
  268. func SelfSupportForSchoolDataStatisticsList(c *gin.Context) {
  269. var req md.SelfSupportForSchoolExportRecordsListReq
  270. err := c.ShouldBindJSON(&req)
  271. if err != nil {
  272. err = validate.HandleValidateErr(err)
  273. err1 := err.(e.E)
  274. e.OutErr(c, err1.Code, err1.Error())
  275. return
  276. }
  277. if req.Limit == 0 {
  278. req.Limit = 10
  279. }
  280. if req.Page == 0 {
  281. req.Page = 10
  282. }
  283. selfSupportForSchoolExportRecordsDb := db.SelfSupportForSchoolExportRecordsDb{}
  284. selfSupportForSchoolExportRecordsDb.Set()
  285. list, total, err := selfSupportForSchoolExportRecordsDb.SelfSupportForSchoolExportRecordsList(req)
  286. if err != nil {
  287. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  288. return
  289. }
  290. e.OutSuc(c, map[string]interface{}{
  291. "list": list,
  292. "total": total,
  293. "enterprise_kind_list": md.EnterpriseKindForSchool,
  294. "kind": []map[string]interface{}{
  295. {
  296. "name": "教师消费统计表",
  297. "value": 1,
  298. },
  299. {
  300. "name": "商家分餐数据统计表",
  301. "value": 2,
  302. },
  303. {
  304. "name": "学校就餐数据统计表",
  305. "value": 3,
  306. },
  307. {
  308. "name": "设备就餐数据统计表",
  309. "value": 4,
  310. },
  311. },
  312. }, nil)
  313. return
  314. }
  315. func SelfSupportForSchoolDataStatisticsDelete(c *gin.Context) {
  316. var req struct {
  317. Ids []int `json:"ids"`
  318. }
  319. err := c.ShouldBindJSON(&req)
  320. if err != nil {
  321. err = validate.HandleValidateErr(err)
  322. err1 := err.(e.E)
  323. e.OutErr(c, err1.Code, err1.Error())
  324. return
  325. }
  326. for _, id := range req.Ids {
  327. selfSupportForSchoolExportRecordsDb := db.SelfSupportForSchoolExportRecordsDb{}
  328. selfSupportForSchoolExportRecordsDb.Set()
  329. selfSupportForSchoolExportRecords, err1 := selfSupportForSchoolExportRecordsDb.GetSelfSupportForSchoolExportRecords(id)
  330. if err1 != nil {
  331. e.OutErr(c, e.ERR_DB_ORM, err1.Error())
  332. return
  333. }
  334. if selfSupportForSchoolExportRecords == nil {
  335. e.OutErr(c, e.ERR_NO_DATA, "未查询到相关记录")
  336. return
  337. }
  338. os.RemoveAll("./static" + selfSupportForSchoolExportRecords.DownloadPath) //移除文件
  339. _, err2 := selfSupportForSchoolExportRecordsDb.SelfSupportForSchoolExportRecordsDelete(id)
  340. if err2 != nil {
  341. e.OutErr(c, e.ERR_DB_ORM, err2.Error())
  342. return
  343. }
  344. }
  345. e.OutSuc(c, "success", nil)
  346. return
  347. }
  348. func SelfSupportForSchoolDataStatisticsExport(c *gin.Context) {
  349. var req md.SelfSupportForSchoolDataStatisticsExportReq
  350. err := c.ShouldBindJSON(&req)
  351. if err != nil {
  352. err = validate.HandleValidateErr(err)
  353. err1 := err.(e.E)
  354. e.OutErr(c, err1.Code, err1.Error())
  355. return
  356. }
  357. if req.EnterpriseId != 0 {
  358. enterpriseDb := db.EnterpriseDb{}
  359. enterpriseDb.Set()
  360. enterprise, err1 := enterpriseDb.GetEnterprise(req.EnterpriseId)
  361. if err1 != nil {
  362. e.OutErr(c, e.ERR_DB_ORM, err1.Error())
  363. return
  364. }
  365. req.EnterpriseName = enterprise.Name
  366. }
  367. go svc.SelfSupportForSchoolDataStatisticsExport(req)
  368. e.OutSuc(c, map[string]interface{}{
  369. "msg": "导出成功,请稍后刷新数据列表",
  370. }, nil)
  371. return
  372. }