123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- package new_mobile_api_controllers
-
- import (
- "Xcx_New/enums"
- "Xcx_New/service/management_service"
- service "Xcx_New/service/print_data_service/schedule_dialysis"
- "Xcx_New/utils"
- "time"
- )
-
- type ManagementAnalyseApiController struct {
- NewMobileBaseAPIAuthController
- }
-
- func (this *ManagementAnalyseApiController) StockRecordPrintData() {
- types, _ := this.GetInt("type", 0)
- start_time := this.GetString("start_time")
- end_time := this.GetString("end_time")
- adminUserInfo := this.GetMobileAdminUserInfo()
-
- 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.Org.Id)
-
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- } else {
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "type": types,
- })
- }
- }
- func (this *ManagementAnalyseApiController) StatisticsPatientChart() {
- start_time := this.GetString("start_time")
- end_time := this.GetString("end_time")
- statistics_type, _ := this.GetInt("type", 0)
-
- adminUserInfo := this.GetMobileAdminUserInfo()
-
- 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()
- }
- data, total_one, _ := management_service.GetPatientChartData(adminUserInfo.Org.Id, startTime, endTime, statistics_type)
- total, _ := management_service.GetLapsetoPatientTotal(adminUserInfo.Org.Id, statistics_type)
-
- total_three, _ := management_service.GetLapsetoPatientTotal(adminUserInfo.Org.Id, 2)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "chart_data": data,
- "total_one": total_one,
- "total": total,
- "total_three": total + total_three,
- })
-
- }
- func (this *ManagementAnalyseApiController) StatisticsPatientTable() {
- start_time := this.GetString("start_time")
- end_time := this.GetString("end_time")
- statistics_type, _ := this.GetInt("type", 0)
- page, _ := this.GetInt64("page", 0)
- limit, _ := this.GetInt64("limit", 0)
-
- if page == 0 {
- page = 1
- }
- if limit == 0 {
- limit = 20
- }
-
- adminUserInfo := this.GetMobileAdminUserInfo()
-
- 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()
- }
- data, total, _ := management_service.GetPatientTableData(adminUserInfo.Org.Id, page, limit, startTime, endTime, statistics_type)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "data": data,
- "total": total,
- })
-
- }
|