123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
- package controllers
-
- import (
- "Xcx_New/enums"
- service "Xcx_New/service/print_data_service/schedule_dialysis"
- "Xcx_New/utils"
- "fmt"
- "strings"
- "time"
-
- "github.com/astaxie/beego"
- )
-
- func PrintDataAPIControllerRegistRouters() {
- beego.Router("/api/print/schedule/dialysis", &PrintDataAPIController{}, "get:ScheduleDialysisRecordPrintData")
- beego.Router("/api/print/stock", &PrintDataAPIController{}, "get:StockRecordPrintData")
- beego.Router("/api/print/course", &PrintDataAPIController{}, "get:CourseRecordPrintData")
- beego.Router("/api/print/getlastafterweight", &PrintDataAPIController{}, "get:GetLastAfterWeight")
- beego.Router("/api/stock/getgooddetailprintlist", &PrintDataAPIController{}, "get:GetGoodDetailPrintList")
-
- }
-
- type PrintDataAPIController struct {
- BaseAuthAPIController
- }
-
- // /api/print/schedule/dialysis [get]
- // @param ids:string 排班 id,以逗号隔开 ("1,2,3")
- func (this *PrintDataAPIController) ScheduleDialysisRecordPrintData() {
- schIDStr := this.GetString("ids")
-
- if len(schIDStr) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- idStrs := strings.Split(schIDStr, ",")
- adminUserInfo := this.GetAdminUserInfo()
- schedules, getScheduleErr := service.GetSchedules(adminUserInfo.CurrentOrgId, idStrs)
-
- if getScheduleErr != nil {
- this.ErrorLog("获取打印透析记录失败:%v", getScheduleErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- medicalStaffs, getMedicalStaffErr := service.GetMedicalStaffs(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
- if getMedicalStaffErr != nil {
- this.ErrorLog("获取医护人员失败:%v", getMedicalStaffErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- adminUser, _ := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
- name, getScheduleErr := service.GetAllName(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
- templateInfo, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "schedules": schedules,
- "medical_staffs": medicalStaffs,
- "users": adminUser,
- "templateInfo": templateInfo,
- "name": name,
- })
- }
-
- func (this *PrintDataAPIController) StockRecordPrintData() {
- types, _ := this.GetInt("type", 0)
- start_time := this.GetString("start_time")
- end_time := this.GetString("end_time")
- adminUserInfo := this.GetAdminUserInfo()
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var startTime int64
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime = theTime.Unix()
- }
- var endTime int64
- if len(end_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
-
- list, err := service.FindPrintStockGoodInfoByType(types, startTime, endTime, adminUserInfo.CurrentOrgId)
- stockTotal, err := service.GetOutStockTotalCountTwo(startTime, endTime, adminUserInfo.CurrentOrgId)
-
- info, err := service.GetCoutWareseOutInfo(startTime, endTime, adminUserInfo.CurrentOrgId)
-
- infomationList, err := service.GetGoodInfomationList(adminUserInfo.CurrentOrgId)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- } else {
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "type": types,
- "stockTotal": stockTotal,
- "info": info,
- "orgid": adminUserInfo.CurrentOrgId,
- "infomationList": infomationList,
- })
- }
- }
-
- func (this *PrintDataAPIController) CourseRecordPrintData() {
- id, _ := this.GetInt64("id", 0)
- adminUserInfo := this.GetAdminUserInfo()
-
- if id == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- timeLayout := "2006-01-02 15:04:05"
- record, err := service.GetPatientCoursesRecords(adminUserInfo.CurrentOrgId, id)
- dataTimeStr := time.Unix(record.RecordTime, 0).Format(timeLayout) //设置时间戳 使用模板格式化为日期字符串
- tempTime := strings.Split(dataTimeStr, " ")
-
- recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", tempTime[0])
- if parseDateErr != nil {
- this.ErrorLog("日期(%v)解析错误:%v", tempTime[0], parseDateErr)
- //this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- //return
- }
-
- patient, _ := service.FindPatientWithDeviceById(adminUserInfo.CurrentOrgId, record.PatientID, recordDate.Unix())
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- } else {
- this.ServeSuccessJSON(map[string]interface{}{
- "record": record,
- "patient": patient,
- })
- }
- }
-
- func (this *PrintDataAPIController) GetLastAfterWeight() {
- id, _ := this.GetInt64("id")
- fmt.Print("id", id)
- assmentdate, _ := this.GetInt64("assmentdate")
-
- adminUserInfo := this.GetAdminUserInfo()
- org_id := adminUserInfo.CurrentOrgId
- weight, err := service.GetLastAfterWeight(org_id, id, assmentdate)
- //fmt.Print("errr-------------",err)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "weight": weight,
- })
- }
-
- func (this *PrintDataAPIController) GetGoodDetailPrintList() {
-
- types, _ := this.GetInt("type", 0)
- start_time := this.GetString("start_time")
- end_time := this.GetString("end_time")
- adminUserInfo := this.GetAdminUserInfo()
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var startTime int64
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime = theTime.Unix()
- }
- var endTime int64
- if len(end_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
- limit, _ := this.GetInt64("limit")
- page, _ := this.GetInt64("page")
-
- //入库详情
- if types == 1 {
- list, err := service.GetWarehouseInfoGoodDetailPrintList(adminUserInfo.CurrentOrgId, startTime, endTime, limit, page)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
- }
-
- //出库详情
- if types == 2 {
- list, err := service.GetWarehouseOutInfoGoodDetailPrintList(adminUserInfo.CurrentOrgId, startTime, endTime, limit, page)
- stockTotal, err := service.GetOutStockTotalCountTwo(startTime, endTime, adminUserInfo.CurrentOrgId)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "stockTotal": stockTotal,
- })
- }
-
- }
|