print_data_api_controller.go 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  1. package controllers
  2. import (
  3. "fmt"
  4. "strconv"
  5. "strings"
  6. "time"
  7. "XT_New/enums"
  8. service "XT_New/service/print_data_service/schedule_dialysis"
  9. "XT_New/utils"
  10. "github.com/astaxie/beego"
  11. )
  12. func PrintDataAPIControllerRegistRouters() {
  13. beego.Router("/api/print/schedule/dialysis", &PrintDataAPIController{}, "get:ScheduleDialysisRecordPrintData")
  14. beego.Router("/api/print/stock", &PrintDataAPIController{}, "get:StockRecordPrintData")
  15. beego.Router("/api/print/course", &PrintDataAPIController{}, "get:CourseRecordPrintData")
  16. beego.Router("/api/print/getlastafterweight", &PrintDataAPIController{}, "get:GetLastAfterWeight")
  17. beego.Router("/api/stock/getgooddetailprintlist", &PrintDataAPIController{}, "get:GetGoodDetailPrintList")
  18. }
  19. type PrintDataAPIController struct {
  20. BaseAuthAPIController
  21. }
  22. // /api/print/schedule/dialysis [get]
  23. // @param ids:string 排班 id,以逗号隔开 ("1,2,3")
  24. func (this *PrintDataAPIController) ScheduleDialysisRecordPrintData() {
  25. schIDStr := this.GetString("ids")
  26. if len(schIDStr) == 0 {
  27. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28. return
  29. }
  30. idStrs := strings.Split(schIDStr, ",")
  31. adminUserInfo := this.GetAdminUserInfo()
  32. if this.GetAdminUserInfo().CurrentOrgId == 10016 || this.GetAdminUserInfo().CurrentOrgId == 9882 || this.GetAdminUserInfo().CurrentOrgId == 10138 || this.GetAdminUserInfo().CurrentOrgId == 10278 || this.GetAdminUserInfo().CurrentOrgId == 9841 || this.GetAdminUserInfo().CurrentOrgId == 9845 || this.GetAdminUserInfo().CurrentOrgId == 10081 || this.GetAdminUserInfo().CurrentOrgId == 10215 || this.GetAdminUserInfo().CurrentOrgId == 10121 || this.GetAdminUserInfo().CurrentOrgId == 10234 || this.GetAdminUserInfo().CurrentOrgId == 10188 || this.GetAdminUserInfo().CurrentOrgId == 10217 || this.GetAdminUserInfo().CurrentOrgId == 10340 || this.GetAdminUserInfo().CurrentOrgId == 9905 || this.GetAdminUserInfo().CurrentOrgId == 10346 || this.GetAdminUserInfo().CurrentOrgId == 10441 || this.GetAdminUserInfo().CurrentOrgId == 9970 || this.GetAdminUserInfo().CurrentOrgId == 10101 || this.GetAdminUserInfo().CurrentOrgId == 10495 || this.GetAdminUserInfo().CurrentOrgId == 10013 || this.GetAdminUserInfo().CurrentOrgId == 10014 || this.GetAdminUserInfo().CurrentOrgId == 10307 {
  33. schedules, getScheduleErr := service.GetSchedulesSeven(adminUserInfo.CurrentOrgId, idStrs)
  34. for _, item := range schedules {
  35. //获取透析上机
  36. order, _ := service.GetBatchDialysisOrder(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
  37. item.DialysisOrder = order
  38. //获取透析处方
  39. prescription, _ := service.GetBatchPrescription(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
  40. item.Prescription = prescription
  41. //接诊评估
  42. receiveTreatmentAsses, _ := service.GetBatchReceiveTreatmentAsses(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
  43. if receiveTreatmentAsses.Condition == 1 {
  44. if len(receiveTreatmentAsses.AdmissionNumber) == 0 || receiveTreatmentAsses.AdmissionNumber == "" {
  45. lastAcceptTreatment, _ := service.GetLastAcceptTreatment(adminUserInfo.CurrentOrgId, item.PatientID)
  46. receiveTreatmentAsses.AdmissionNumber = lastAcceptTreatment.AdmissionNumber
  47. receiveTreatmentAsses.HisDepartment = lastAcceptTreatment.HisDepartment
  48. receiveTreatmentAsses.HisBed = lastAcceptTreatment.HisBed
  49. }
  50. }
  51. item.ReceiveAssessment = receiveTreatmentAsses
  52. //透前评估
  53. assessmentBeforeDislysisVM, _ := service.GetBatchAssessmentBeforeDislysisVM(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
  54. now := time.Now()
  55. // 计算当前是周几,周一为第1天,周日为第0天
  56. weekday := now.Weekday()
  57. // 计算当前日期是周几,并计算出周一的日期
  58. // 通过减去当前是周几的偏移量再加1来实现(因为Weekday()返回的是从周日开始的索引,而我们想要从周一开始)
  59. mondayone := now.AddDate(0, 0, -(int(weekday)+6)%7) // 或者使用 monday := now.Add(-time.Hour * 24 * (int(weekday)+6)%7)
  60. // 设置开始时间为周一的00:00:00
  61. startOfTheWeek := time.Date(mondayone.Year(), mondayone.Month(), mondayone.Day(), 0, 0, 0, 0, mondayone.Location())
  62. // 设置结束时间为周日的23:59:59(周一的日期基础上加6天)
  63. endOfTheWeek := startOfTheWeek.AddDate(0, 0, 6).Add(24*time.Hour - time.Second) // 或者使用 endOfTheWeek := monday.AddDate(0, 0, 7).Add(-time.Second)
  64. var start_time = startOfTheWeek.Format("2006-01-02")
  65. var end_time = endOfTheWeek.Format("2006-01-02")
  66. timeLayout := "2006-01-02"
  67. loc, _ := time.LoadLocation("Local")
  68. var startTime int64
  69. if len(start_time) > 0 {
  70. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  71. if err != nil {
  72. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  73. return
  74. }
  75. startTime = theTime.Unix()
  76. }
  77. var endTime int64
  78. if len(end_time) > 0 {
  79. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  80. if err != nil {
  81. utils.ErrorLog(err.Error())
  82. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  83. return
  84. }
  85. endTime = theTime.Unix()
  86. }
  87. scheduleDialyCount, _ := service.GetPatientScheduleDialyCount(item.PatientID, startTime, endTime, adminUserInfo.CurrentOrgId)
  88. dialysis_count := len(scheduleDialyCount)
  89. var dialysis_count_str = "一周" + strconv.Itoa(dialysis_count) + "次"
  90. if adminUserInfo.CurrentOrgId == 10742 {
  91. assessmentBeforeDislysisVM.DialysisCount = dialysis_count_str
  92. }
  93. item.AssessmentBeforeDislysis = assessmentBeforeDislysisVM
  94. //透后评估
  95. assessmentAfterDislysisVM, _ := service.GetBatchAssessmentAfterDislysisVM(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
  96. item.AssessmentAfterDislysis = assessmentAfterDislysisVM
  97. //上次透后体重
  98. lastAfterWeight, _ := service.GetBatchLastAfterWeight(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
  99. item.LastAfterWeight = lastAfterWeight
  100. //透析监测
  101. monitor, _ := service.GetBatchMonitor(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
  102. item.MonitoringRecords = monitor
  103. //透析医嘱
  104. advice, _ := service.GetBatchDoctorAdvice(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
  105. item.Advices = advice
  106. //获取His医嘱
  107. doctorAdvice, _ := service.GetHisBatchDoctorAdvice(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
  108. item.HisAdvices = doctorAdvice
  109. //获取项目
  110. project, _ := service.GetHisBatchProject(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
  111. item.HisPrescriptionProject = project
  112. //双人核对
  113. dobuleCheck, _ := service.GetBatchDobuleCheck(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
  114. item.DoubleCheck = dobuleCheck
  115. //透析小结
  116. summerVM, _ := service.GetBatchSummerVM(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
  117. item.Summer = summerVM
  118. list, _ := service.GetDialysisOrderCountSeven(item.PatientID, item.ScheduleDate)
  119. if this.GetAdminUserInfo().CurrentOrgId != 10101 && this.GetAdminUserInfo().CurrentOrgId != 9671 && this.GetAdminUserInfo().CurrentOrgId != 10345 && this.GetAdminUserInfo().CurrentOrgId != 9970 && this.GetAdminUserInfo().CurrentOrgId != 10495 {
  120. item.Count = list.Count
  121. }
  122. lastSchedule, _ := service.FindLastSchedule(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
  123. item.Schedule = &lastSchedule
  124. if this.GetAdminUserInfo().CurrentOrgId == 10101 || this.GetAdminUserInfo().CurrentOrgId == 9671 || this.GetAdminUserInfo().CurrentOrgId == 10345 || this.GetAdminUserInfo().CurrentOrgId == 9970 || this.GetAdminUserInfo().CurrentOrgId == 10495 || this.GetAdminUserInfo().CurrentOrgId == 10013 || this.GetAdminUserInfo().CurrentOrgId == 10014 {
  125. if item.ScheduleDate <= 1735574400 {
  126. listOne, _ := service.GetDialysisOrderCountEight(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
  127. item.Patient.TotalDialysis = listOne.Count
  128. item.Count = listOne.Count
  129. }
  130. if item.ScheduleDate >= 1735660800 {
  131. listOne, _ := service.GetDialysisOrderCountNight(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
  132. item.Patient.TotalDialysis = listOne.Count
  133. item.Count = listOne.Count
  134. }
  135. }
  136. }
  137. if getScheduleErr != nil {
  138. this.ErrorLog("获取打印透析记录失败:%v", getScheduleErr)
  139. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  140. return
  141. }
  142. medicalStaffs, getMedicalStaffErr := service.GetMedicalStaffs(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
  143. if getMedicalStaffErr != nil {
  144. this.ErrorLog("获取医护人员失败:%v", getMedicalStaffErr)
  145. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  146. return
  147. }
  148. adminUser, _ := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
  149. name, getScheduleErr := service.GetAllName(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
  150. templateInfo, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
  151. numberList, _ := service.GetAllBedNumberList(adminUserInfo.CurrentOrgId)
  152. this.ServeSuccessJSON(map[string]interface{}{
  153. "schedules": schedules,
  154. "medical_staffs": medicalStaffs,
  155. "users": adminUser,
  156. "templateInfo": templateInfo,
  157. "name": name,
  158. "numberList": numberList,
  159. })
  160. }
  161. if this.GetAdminUserInfo().CurrentOrgId != 10016 && this.GetAdminUserInfo().CurrentOrgId != 9882 && this.GetAdminUserInfo().CurrentOrgId != 10138 && this.GetAdminUserInfo().CurrentOrgId != 10278 && this.GetAdminUserInfo().CurrentOrgId != 9841 && this.GetAdminUserInfo().CurrentOrgId != 9845 && this.GetAdminUserInfo().CurrentOrgId != 10081 && this.GetAdminUserInfo().CurrentOrgId != 10215 && this.GetAdminUserInfo().CurrentOrgId != 10121 && this.GetAdminUserInfo().CurrentOrgId != 10234 && this.GetAdminUserInfo().CurrentOrgId != 10188 && this.GetAdminUserInfo().CurrentOrgId != 10217 && this.GetAdminUserInfo().CurrentOrgId != 10340 && this.GetAdminUserInfo().CurrentOrgId != 9905 && this.GetAdminUserInfo().CurrentOrgId != 10346 && this.GetAdminUserInfo().CurrentOrgId != 10441 && this.GetAdminUserInfo().CurrentOrgId != 9970 && this.GetAdminUserInfo().CurrentOrgId != 10101 && this.GetAdminUserInfo().CurrentOrgId != 10495 && this.GetAdminUserInfo().CurrentOrgId != 10013 && this.GetAdminUserInfo().CurrentOrgId != 10014 && this.GetAdminUserInfo().CurrentOrgId != 10307 {
  162. schedules, getScheduleErr := service.GetSchedules(adminUserInfo.CurrentOrgId, idStrs)
  163. for _, item := range schedules {
  164. //透前评估
  165. assessmentBeforeDislysisVM, _ := service.GetBatchAssessmentBeforeDislysisVM(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
  166. now := time.Now()
  167. // 计算当前是周几,周一为第1天,周日为第0天
  168. weekday := now.Weekday()
  169. // 计算当前日期是周几,并计算出周一的日期
  170. // 通过减去当前是周几的偏移量再加1来实现(因为Weekday()返回的是从周日开始的索引,而我们想要从周一开始)
  171. mondayone := now.AddDate(0, 0, -(int(weekday)+6)%7) // 或者使用 monday := now.Add(-time.Hour * 24 * (int(weekday)+6)%7)
  172. // 设置开始时间为周一的00:00:00
  173. startOfTheWeek := time.Date(mondayone.Year(), mondayone.Month(), mondayone.Day(), 0, 0, 0, 0, mondayone.Location())
  174. // 设置结束时间为周日的23:59:59(周一的日期基础上加6天)
  175. endOfTheWeek := startOfTheWeek.AddDate(0, 0, 6).Add(24*time.Hour - time.Second) // 或者使用 endOfTheWeek := monday.AddDate(0, 0, 7).Add(-time.Second)
  176. var start_time = startOfTheWeek.Format("2006-01-02")
  177. var end_time = endOfTheWeek.Format("2006-01-02")
  178. timeLayout := "2006-01-02"
  179. loc, _ := time.LoadLocation("Local")
  180. var startTime int64
  181. if len(start_time) > 0 {
  182. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  183. if err != nil {
  184. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  185. return
  186. }
  187. startTime = theTime.Unix()
  188. }
  189. var endTime int64
  190. if len(end_time) > 0 {
  191. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  192. if err != nil {
  193. utils.ErrorLog(err.Error())
  194. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  195. return
  196. }
  197. endTime = theTime.Unix()
  198. }
  199. scheduleDialyCount, _ := service.GetPatientScheduleDialyCount(item.PatientID, startTime, endTime, adminUserInfo.CurrentOrgId)
  200. fmt.Println("scheduleDialyCount------------------", scheduleDialyCount)
  201. dialysis_count := len(scheduleDialyCount)
  202. var dialysis_count_str = "一周" + strconv.Itoa(dialysis_count) + "次"
  203. if adminUserInfo.CurrentOrgId == 10742 {
  204. assessmentBeforeDislysisVM.DialysisCount = dialysis_count_str
  205. }
  206. item.AssessmentBeforeDislysis = assessmentBeforeDislysisVM
  207. list, _ := service.GetDialysisOrderCountSeven(item.PatientID, item.ScheduleDate)
  208. if this.GetAdminUserInfo().CurrentOrgId != 10101 && this.GetAdminUserInfo().CurrentOrgId != 9671 && this.GetAdminUserInfo().CurrentOrgId != 10345 {
  209. if this.GetAdminUserInfo().CurrentOrgId == 10445 {
  210. if item.ScheduleDate >= 1640966400 && item.ScheduleDate <= 1672416000 {
  211. listOne, _ := service.GetDialysisOrderCountNewTen(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
  212. item.Patient.TotalDialysis = listOne.Count
  213. item.Count = listOne.Count
  214. }
  215. if item.ScheduleDate >= 1672502400 && item.ScheduleDate <= 1703952000 {
  216. listOne, _ := service.GetDialysisOrderCountTwenty(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
  217. item.Patient.TotalDialysis = listOne.Count
  218. item.Count = listOne.Count
  219. }
  220. if item.ScheduleDate >= 1704038400 && item.ScheduleDate <= 1735574400 {
  221. listOne, _ := service.GetDialysisOrderCountEight(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
  222. item.Patient.TotalDialysis = listOne.Count
  223. item.Count = listOne.Count
  224. }
  225. if item.ScheduleDate >= 1735660800 {
  226. listOne, _ := service.GetDialysisOrderCountNight(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
  227. item.Patient.TotalDialysis = listOne.Count
  228. item.Count = listOne.Count
  229. }
  230. }
  231. if this.GetAdminUserInfo().CurrentOrgId != 10445 {
  232. item.Count = list.Count
  233. }
  234. }
  235. lastSchedule, _ := service.FindLastSchedule(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
  236. item.Schedule = &lastSchedule
  237. if this.GetAdminUserInfo().CurrentOrgId == 10101 || this.GetAdminUserInfo().CurrentOrgId == 9671 || this.GetAdminUserInfo().CurrentOrgId == 10345 {
  238. if item.ScheduleDate <= 1640966400 {
  239. listOne, _ := service.GetDialysisOrderCountEight(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
  240. item.Patient.TotalDialysis = listOne.Count
  241. item.Count = listOne.Count
  242. }
  243. if item.ScheduleDate >= 1672502400 {
  244. listOne, _ := service.GetDialysisOrderCountNight(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
  245. item.Patient.TotalDialysis = listOne.Count
  246. item.Count = listOne.Count
  247. }
  248. }
  249. //上次透后体重
  250. lastAfterWeight, _ := service.GetBatchLastAfterWeight(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
  251. item.LastAfterWeight = lastAfterWeight
  252. }
  253. if getScheduleErr != nil {
  254. this.ErrorLog("获取打印透析记录失败:%v", getScheduleErr)
  255. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  256. return
  257. }
  258. medicalStaffs, getMedicalStaffErr := service.GetMedicalStaffs(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
  259. if getMedicalStaffErr != nil {
  260. this.ErrorLog("获取医护人员失败:%v", getMedicalStaffErr)
  261. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  262. return
  263. }
  264. adminUser, _ := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
  265. name, getScheduleErr := service.GetAllName(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
  266. templateInfo, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
  267. numberList, _ := service.GetAllBedNumberList(adminUserInfo.CurrentOrgId)
  268. this.ServeSuccessJSON(map[string]interface{}{
  269. "schedules": schedules,
  270. "medical_staffs": medicalStaffs,
  271. "users": adminUser,
  272. "templateInfo": templateInfo,
  273. "name": name,
  274. "numberList": numberList,
  275. })
  276. }
  277. }
  278. func (this *PrintDataAPIController) StockRecordPrintData() {
  279. types, _ := this.GetInt("type", 0)
  280. start_time := this.GetString("start_time")
  281. end_time := this.GetString("end_time")
  282. adminUserInfo := this.GetAdminUserInfo()
  283. timeLayout := "2006-01-02"
  284. loc, _ := time.LoadLocation("Local")
  285. var startTime int64
  286. if len(start_time) > 0 {
  287. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  288. if err != nil {
  289. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  290. return
  291. }
  292. startTime = theTime.Unix()
  293. }
  294. var endTime int64
  295. if len(end_time) > 0 {
  296. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  297. if err != nil {
  298. utils.ErrorLog(err.Error())
  299. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  300. return
  301. }
  302. endTime = theTime.Unix()
  303. }
  304. list, err := service.FindPrintStockGoodInfoByType(types, startTime, endTime, adminUserInfo.CurrentOrgId)
  305. stockTotal, err := service.GetOutStockTotalCountTwo(startTime, endTime, adminUserInfo.CurrentOrgId)
  306. info, err := service.GetCoutWareseOutInfo(startTime, endTime, adminUserInfo.CurrentOrgId)
  307. infomationList, err := service.GetGoodInfomationList(adminUserInfo.CurrentOrgId)
  308. if err != nil {
  309. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  310. } else {
  311. this.ServeSuccessJSON(map[string]interface{}{
  312. "list": list,
  313. "type": types,
  314. "stockTotal": stockTotal,
  315. "info": info,
  316. "orgid": adminUserInfo.CurrentOrgId,
  317. "infomationList": infomationList,
  318. })
  319. }
  320. }
  321. func (this *PrintDataAPIController) CourseRecordPrintData() {
  322. ids_str := this.GetString("ids")
  323. ids_arr := strings.Split(ids_str, ",")
  324. adminUserInfo := this.GetAdminUserInfo()
  325. patient_id, _ := this.GetInt64("patient_id")
  326. record, err := service.GetPatientCoursesRecords(adminUserInfo.CurrentOrgId, ids_arr)
  327. //patient, _ := service.FindPatientWithDeviceById(adminUserInfo.CurrentOrgId, patient_id)
  328. patient, _ := service.GetPatientDetail(adminUserInfo.CurrentOrgId, patient_id)
  329. adminUser, _ := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
  330. operators, err := service.GetAdminUserEsTwo(adminUserInfo.CurrentOrgId)
  331. if err != nil {
  332. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  333. return
  334. } else {
  335. this.ServeSuccessJSON(map[string]interface{}{
  336. "record": record,
  337. "patient": patient,
  338. "adminUser": adminUser,
  339. "operators": operators,
  340. })
  341. }
  342. }
  343. func (this *PrintDataAPIController) GetLastAfterWeight() {
  344. id, _ := this.GetInt64("id")
  345. fmt.Print("id", id)
  346. assmentdate, _ := this.GetInt64("assmentdate")
  347. adminUserInfo := this.GetAdminUserInfo()
  348. org_id := adminUserInfo.CurrentOrgId
  349. weight, err := service.GetLastAfterWeight(org_id, id, assmentdate)
  350. //fmt.Print("errr-------------",err)
  351. if err != nil {
  352. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  353. return
  354. }
  355. this.ServeSuccessJSON(map[string]interface{}{
  356. "weight": weight,
  357. })
  358. }
  359. func (this *PrintDataAPIController) GetGoodDetailPrintList() {
  360. types, _ := this.GetInt("type", 0)
  361. start_time := this.GetString("start_time")
  362. end_time := this.GetString("end_time")
  363. storehouse_id, _ := this.GetInt64("storehouse_id")
  364. good_id, _ := this.GetInt64("good_id")
  365. adminUserInfo := this.GetAdminUserInfo()
  366. order_way, _ := this.GetInt64("order_way")
  367. timeLayout := "2006-01-02"
  368. loc, _ := time.LoadLocation("Local")
  369. var startTime int64
  370. if len(start_time) > 0 {
  371. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  372. if err != nil {
  373. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  374. return
  375. }
  376. startTime = theTime.Unix()
  377. }
  378. var endTime int64
  379. if len(end_time) > 0 {
  380. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  381. if err != nil {
  382. utils.ErrorLog(err.Error())
  383. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  384. return
  385. }
  386. endTime = theTime.Unix()
  387. }
  388. limit, _ := this.GetInt64("limit")
  389. page, _ := this.GetInt64("page")
  390. //入库详情
  391. if types == 1 {
  392. list, err := service.GetWarehouseInfoGoodDetailPrintList(adminUserInfo.CurrentOrgId, startTime, endTime, limit, page, storehouse_id, good_id)
  393. if err != nil {
  394. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  395. return
  396. }
  397. this.ServeSuccessJSON(map[string]interface{}{
  398. "list": list,
  399. })
  400. }
  401. //出库详情
  402. if types == 2 {
  403. //list, err := service.GetWarehouseOutInfoGoodDetailPrintList(adminUserInfo.CurrentOrgId, startTime, endTime, limit, page)
  404. list, _ := service.GetWarehouseOutInfoPrintList(adminUserInfo.CurrentOrgId, startTime, endTime, good_id, order_way)
  405. stockTotal, err := service.GetOutStockTotalCountThree(startTime, endTime, adminUserInfo.CurrentOrgId, good_id)
  406. if err != nil {
  407. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  408. return
  409. }
  410. this.ServeSuccessJSON(map[string]interface{}{
  411. "list": list,
  412. "stockTotal": stockTotal,
  413. })
  414. }
  415. //退库详情
  416. if types == 4 {
  417. list, _ := service.GetWarehouseCancelPrintList(adminUserInfo.CurrentOrgId, startTime, endTime)
  418. this.ServeSuccessJSON(map[string]interface{}{
  419. "list": list,
  420. })
  421. }
  422. }