print_data_api_controller.go 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535
  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. if item.ScheduleDate < 1740931200 {
  200. startTime = 1740326400
  201. endTime = 1740844800
  202. }
  203. scheduleDialyCount, _ := service.GetPatientScheduleDialyCount(item.PatientID, startTime, endTime, adminUserInfo.CurrentOrgId)
  204. dialysis_count := len(scheduleDialyCount)
  205. var dialysis_count_str = "一周" + strconv.Itoa(dialysis_count) + "次"
  206. if adminUserInfo.CurrentOrgId == 10742 {
  207. assessmentBeforeDislysisVM.DialysisCount = dialysis_count_str
  208. }
  209. item.AssessmentBeforeDislysis = assessmentBeforeDislysisVM
  210. list, _ := service.GetDialysisOrderCountSeven(item.PatientID, item.ScheduleDate)
  211. if this.GetAdminUserInfo().CurrentOrgId != 10101 && this.GetAdminUserInfo().CurrentOrgId != 9671 && this.GetAdminUserInfo().CurrentOrgId != 10345 {
  212. if this.GetAdminUserInfo().CurrentOrgId == 10445 {
  213. if item.ScheduleDate >= 1640966400 && item.ScheduleDate <= 1672416000 {
  214. listOne, _ := service.GetDialysisOrderCountNewTen(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
  215. item.Patient.TotalDialysis = listOne.Count
  216. item.Count = listOne.Count
  217. }
  218. if item.ScheduleDate >= 1672502400 && item.ScheduleDate <= 1703952000 {
  219. listOne, _ := service.GetDialysisOrderCountTwenty(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
  220. item.Patient.TotalDialysis = listOne.Count
  221. item.Count = listOne.Count
  222. }
  223. if item.ScheduleDate >= 1704038400 && item.ScheduleDate <= 1735574400 {
  224. listOne, _ := service.GetDialysisOrderCountEight(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
  225. item.Patient.TotalDialysis = listOne.Count
  226. item.Count = listOne.Count
  227. }
  228. if item.ScheduleDate >= 1735660800 {
  229. listOne, _ := service.GetDialysisOrderCountNight(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
  230. item.Patient.TotalDialysis = listOne.Count
  231. item.Count = listOne.Count
  232. }
  233. }
  234. if this.GetAdminUserInfo().CurrentOrgId != 10445 {
  235. item.Count = list.Count
  236. }
  237. }
  238. lastSchedule, _ := service.FindLastSchedule(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
  239. item.Schedule = &lastSchedule
  240. if this.GetAdminUserInfo().CurrentOrgId == 10101 || this.GetAdminUserInfo().CurrentOrgId == 9671 || this.GetAdminUserInfo().CurrentOrgId == 10345 {
  241. if item.ScheduleDate <= 1640966400 {
  242. listOne, _ := service.GetDialysisOrderCountEight(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
  243. item.Patient.TotalDialysis = listOne.Count
  244. item.Count = listOne.Count
  245. }
  246. if item.ScheduleDate >= 1672502400 {
  247. listOne, _ := service.GetDialysisOrderCountNight(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
  248. item.Patient.TotalDialysis = listOne.Count
  249. item.Count = listOne.Count
  250. }
  251. }
  252. //上次透后体重
  253. lastAfterWeight, _ := service.GetBatchLastAfterWeight(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
  254. item.LastAfterWeight = lastAfterWeight
  255. }
  256. if getScheduleErr != nil {
  257. this.ErrorLog("获取打印透析记录失败:%v", getScheduleErr)
  258. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  259. return
  260. }
  261. medicalStaffs, getMedicalStaffErr := service.GetMedicalStaffs(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
  262. if getMedicalStaffErr != nil {
  263. this.ErrorLog("获取医护人员失败:%v", getMedicalStaffErr)
  264. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  265. return
  266. }
  267. adminUser, _ := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
  268. name, getScheduleErr := service.GetAllName(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
  269. templateInfo, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
  270. numberList, _ := service.GetAllBedNumberList(adminUserInfo.CurrentOrgId)
  271. this.ServeSuccessJSON(map[string]interface{}{
  272. "schedules": schedules,
  273. "medical_staffs": medicalStaffs,
  274. "users": adminUser,
  275. "templateInfo": templateInfo,
  276. "name": name,
  277. "numberList": numberList,
  278. })
  279. }
  280. }
  281. func (this *PrintDataAPIController) StockRecordPrintData() {
  282. types, _ := this.GetInt("type", 0)
  283. start_time := this.GetString("start_time")
  284. end_time := this.GetString("end_time")
  285. adminUserInfo := this.GetAdminUserInfo()
  286. timeLayout := "2006-01-02"
  287. loc, _ := time.LoadLocation("Local")
  288. var startTime int64
  289. if len(start_time) > 0 {
  290. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  291. if err != nil {
  292. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  293. return
  294. }
  295. startTime = theTime.Unix()
  296. }
  297. var endTime int64
  298. if len(end_time) > 0 {
  299. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  300. if err != nil {
  301. utils.ErrorLog(err.Error())
  302. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  303. return
  304. }
  305. endTime = theTime.Unix()
  306. }
  307. list, err := service.FindPrintStockGoodInfoByType(types, startTime, endTime, adminUserInfo.CurrentOrgId)
  308. stockTotal, err := service.GetOutStockTotalCountTwo(startTime, endTime, adminUserInfo.CurrentOrgId)
  309. info, err := service.GetCoutWareseOutInfo(startTime, endTime, adminUserInfo.CurrentOrgId)
  310. infomationList, err := service.GetGoodInfomationList(adminUserInfo.CurrentOrgId)
  311. if err != nil {
  312. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  313. } else {
  314. this.ServeSuccessJSON(map[string]interface{}{
  315. "list": list,
  316. "type": types,
  317. "stockTotal": stockTotal,
  318. "info": info,
  319. "orgid": adminUserInfo.CurrentOrgId,
  320. "infomationList": infomationList,
  321. })
  322. }
  323. }
  324. func (this *PrintDataAPIController) CourseRecordPrintData() {
  325. ids_str := this.GetString("ids")
  326. ids_arr := strings.Split(ids_str, ",")
  327. adminUserInfo := this.GetAdminUserInfo()
  328. patient_id, _ := this.GetInt64("patient_id")
  329. record, err := service.GetPatientCoursesRecords(adminUserInfo.CurrentOrgId, ids_arr)
  330. //patient, _ := service.FindPatientWithDeviceById(adminUserInfo.CurrentOrgId, patient_id)
  331. patient, _ := service.GetPatientDetail(adminUserInfo.CurrentOrgId, patient_id)
  332. adminUser, _ := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
  333. operators, err := service.GetAdminUserEsTwo(adminUserInfo.CurrentOrgId)
  334. if err != nil {
  335. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  336. return
  337. } else {
  338. this.ServeSuccessJSON(map[string]interface{}{
  339. "record": record,
  340. "patient": patient,
  341. "adminUser": adminUser,
  342. "operators": operators,
  343. })
  344. }
  345. }
  346. func (this *PrintDataAPIController) GetLastAfterWeight() {
  347. id, _ := this.GetInt64("id")
  348. fmt.Print("id", id)
  349. assmentdate, _ := this.GetInt64("assmentdate")
  350. adminUserInfo := this.GetAdminUserInfo()
  351. org_id := adminUserInfo.CurrentOrgId
  352. weight, err := service.GetLastAfterWeight(org_id, id, assmentdate)
  353. //fmt.Print("errr-------------",err)
  354. if err != nil {
  355. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  356. return
  357. }
  358. this.ServeSuccessJSON(map[string]interface{}{
  359. "weight": weight,
  360. })
  361. }
  362. func (this *PrintDataAPIController) GetGoodDetailPrintList() {
  363. types, _ := this.GetInt("type", 0)
  364. start_time := this.GetString("start_time")
  365. end_time := this.GetString("end_time")
  366. storehouse_id, _ := this.GetInt64("storehouse_id")
  367. good_id, _ := this.GetInt64("good_id")
  368. adminUserInfo := this.GetAdminUserInfo()
  369. order_way, _ := this.GetInt64("order_way")
  370. timeLayout := "2006-01-02"
  371. loc, _ := time.LoadLocation("Local")
  372. var startTime int64
  373. if len(start_time) > 0 {
  374. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  375. if err != nil {
  376. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  377. return
  378. }
  379. startTime = theTime.Unix()
  380. }
  381. var endTime int64
  382. if len(end_time) > 0 {
  383. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  384. if err != nil {
  385. utils.ErrorLog(err.Error())
  386. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  387. return
  388. }
  389. endTime = theTime.Unix()
  390. }
  391. limit, _ := this.GetInt64("limit")
  392. page, _ := this.GetInt64("page")
  393. //入库详情
  394. if types == 1 {
  395. list, err := service.GetWarehouseInfoGoodDetailPrintList(adminUserInfo.CurrentOrgId, startTime, endTime, limit, page, storehouse_id, good_id)
  396. if err != nil {
  397. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  398. return
  399. }
  400. this.ServeSuccessJSON(map[string]interface{}{
  401. "list": list,
  402. })
  403. }
  404. //出库详情
  405. if types == 2 {
  406. //list, err := service.GetWarehouseOutInfoGoodDetailPrintList(adminUserInfo.CurrentOrgId, startTime, endTime, limit, page)
  407. list, _ := service.GetWarehouseOutInfoPrintList(adminUserInfo.CurrentOrgId, startTime, endTime, good_id, order_way)
  408. stockTotal, err := service.GetOutStockTotalCountThree(startTime, endTime, adminUserInfo.CurrentOrgId, good_id)
  409. if err != nil {
  410. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  411. return
  412. }
  413. this.ServeSuccessJSON(map[string]interface{}{
  414. "list": list,
  415. "stockTotal": stockTotal,
  416. })
  417. }
  418. //退库详情
  419. if types == 4 {
  420. list, _ := service.GetWarehouseCancelPrintList(adminUserInfo.CurrentOrgId, startTime, endTime)
  421. this.ServeSuccessJSON(map[string]interface{}{
  422. "list": list,
  423. })
  424. }
  425. }