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