Browse Source

Merge branch 'xt_statistics_branch' of http://git.shengws.com/csx/XT_New into xt_statistics_branch

csx 4 years ago
parent
commit
903d98770c

+ 21 - 15
controllers/inspection_api_controller.go View File

@@ -124,10 +124,10 @@ func (c *InspectionApiController) CreatePatientInspection() {
124 124
 		return
125 125
 	}
126 126
 
127
-	timeLayout := "2006-01-02 15:04:05"
127
+	timeLayout := "2006-01-02 15:04"
128 128
 	loc, _ := time.LoadLocation("Local")
129 129
 
130
-	theTime, err := time.ParseInLocation(timeLayout, from.InspectDate+" 00:00:00", loc)
130
+	theTime, err := time.ParseInLocation(timeLayout, from.InspectDate, loc)
131 131
 	if err != nil {
132 132
 		utils.ErrorLog(err.Error())
133 133
 		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "检验日期不正确")
@@ -226,13 +226,11 @@ func (c *InspectionApiController) CreatePatientInspection() {
226 226
 }
227 227
 
228 228
 func (c *InspectionApiController) EditPatientInspection() {
229
-	fmt.Println("触发了没有---------------------------------------")
230 229
 	patient, _ := c.GetInt64("patient", 0)
231 230
 	remind_cycle, _ := c.GetInt64("remind_cycle", 0)
232
-	dates := c.GetString("dates")
233
-	projectid := c.GetString("projectid")
234
-	fmt.Println("日期---", dates)
235
-	fmt.Println("projectid", projectid)
231
+	// dates := c.GetString("dates")
232
+	// projectid := c.GetString("projectid")
233
+
236 234
 	if patient <= 0 {
237 235
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
238 236
 		return
@@ -253,23 +251,31 @@ func (c *InspectionApiController) EditPatientInspection() {
253 251
 		return
254 252
 	}
255 253
 
256
-	timeLayout := "2006-01-02 15:04:05"
254
+	timeLayout := "2006-01-02 15:04"
257 255
 	loc, _ := time.LoadLocation("Local")
258 256
 
259
-	theTime, err := time.ParseInLocation(timeLayout, from.InspectDate+" 00:00:00", loc)
257
+	theTime, err := time.ParseInLocation(timeLayout, from.InspectDate, loc)
260 258
 	if err != nil {
261 259
 		utils.ErrorLog(err.Error())
262 260
 		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "检验日期不正确")
263 261
 		return
264 262
 	}
265 263
 
264
+	oldTime, olderr := time.ParseInLocation(timeLayout, from.OldInspectDate, loc)
265
+	if olderr != nil {
266
+		utils.ErrorLog(olderr.Error())
267
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "检验日期不正确")
268
+		return
269
+	}
270
+
266 271
 	if len(from.FormItem) == 0 {
267 272
 		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "未填写项目")
268 273
 		return
269 274
 	}
270 275
 
271 276
 	date := theTime.Unix()
272
-	insp, err := service.GetPatientInspectionByDate(adminUserInfo.CurrentOrgId, patient, date, from.ProjectId)
277
+	oldDate := oldTime.Unix()
278
+	insp, err := service.GetPatientInspectionByDate(adminUserInfo.CurrentOrgId, patient, oldDate, from.ProjectId)
273 279
 	if err != nil {
274 280
 		utils.ErrorLog("%v", err)
275 281
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -306,10 +312,10 @@ func (c *InspectionApiController) EditPatientInspection() {
306 312
 			inspection.CreatedTime = time.Now().Unix()
307 313
 			inspection.UpdatedTime = time.Now().Unix()
308 314
 			addinsp = append(addinsp, inspection)
309
-		} else if _, exi := inspMap[item.ID]; exi {
310
-			fmt.Println("2222222222")
315
+		} else {
311 316
 			inspection := *inspMap[item.ID]
312 317
 			inspection.InspectValue = item.Value
318
+			inspection.InspectDate = date
313 319
 			inspection.UpdatedTime = time.Now().Unix()
314 320
 			editinsp = append(editinsp, inspection)
315 321
 			noMap = append(noMap, item.ID)
@@ -373,15 +379,15 @@ func (c *InspectionApiController) DeletePatientInspection() {
373 379
 	patient, _ := c.GetInt64("patient", 0)
374 380
 	ProjectId, _ := c.GetInt64("project_id", 0)
375 381
 	InspectDate := c.GetString("date")
376
-	if patient <= 0 || ProjectId <= 0 || len(InspectDate) != 10 {
382
+	if patient <= 0 || ProjectId <= 0 || len(InspectDate) < 10 {
377 383
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
378 384
 		return
379 385
 	}
380 386
 
381
-	timeLayout := "2006-01-02 15:04:05"
387
+	timeLayout := "2006-01-02 15:04"
382 388
 	loc, _ := time.LoadLocation("Local")
383 389
 
384
-	theTime, err := time.ParseInLocation(timeLayout, InspectDate+" 00:00:00", loc)
390
+	theTime, err := time.ParseInLocation(timeLayout, InspectDate, loc)
385 391
 	if err != nil {
386 392
 		utils.ErrorLog(err.Error())
387 393
 		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "检验日期不正确")

+ 126 - 0
controllers/new_mobile_api_controllers/common_api_controller.go View File

@@ -1012,6 +1012,9 @@ func (this *CommonApiController) GetMonthProjectList() {
1012 1012
 
1013 1013
 	febStart := this.GetString("febStart")
1014 1014
 	fmt.Println("二月始", febStart)
1015
+	febStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", febStart)
1016
+	febStartStrStrUnix := febStartStr.Unix()
1017
+	fmt.Println("二月使", febStartStrStrUnix)
1015 1018
 	febEnd := this.GetString("febEnd")
1016 1019
 	fmt.Println("二月末", febEnd)
1017 1020
 	febEndStr := febEnd + " 23:59:59"
@@ -1021,6 +1024,9 @@ func (this *CommonApiController) GetMonthProjectList() {
1021 1024
 
1022 1025
 	marchStart := this.GetString("marchStart")
1023 1026
 	fmt.Println("三月始", marchStart)
1027
+	marchStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", marchStart)
1028
+	marchStartStrUnix := marchStartStr.Unix()
1029
+	fmt.Println("三月使", marchStartStrUnix)
1024 1030
 	marchEnd := this.GetString("marchEnd")
1025 1031
 	fmt.Println("三月末", febEnd)
1026 1032
 	marchEndStr := marchEnd + " 23:59:59"
@@ -1028,4 +1034,124 @@ func (this *CommonApiController) GetMonthProjectList() {
1028 1034
 	marchEndStrUnix := marchEndStrs.Unix()
1029 1035
 	fmt.Println("三月末", marchEndStrUnix)
1030 1036
 
1037
+	aprStart := this.GetString("aprStart")
1038
+	fmt.Println("四月始", aprStart)
1039
+	aprStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", aprStart)
1040
+	aprStartStrUnix := aprStartStr.Unix()
1041
+	fmt.Println("四月使", aprStartStrUnix)
1042
+	aprEnd := this.GetString("aprEnd")
1043
+	fmt.Println("四月末", aprEnd)
1044
+	aprEndStr := aprEnd + " 23:59:59"
1045
+	aprEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", aprEndStr)
1046
+	aprEndStrsUnix := aprEndStrs.Unix()
1047
+	fmt.Println("四月末", aprEndStrsUnix)
1048
+
1049
+	mayStart := this.GetString("mayStart")
1050
+	fmt.Println("五月始", mayStart)
1051
+	mayStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", mayStart)
1052
+	mayStartStrUnix := mayStartStr.Unix()
1053
+	fmt.Println("五月使", mayStartStrUnix)
1054
+	mayEnd := this.GetString("mayEnd")
1055
+	fmt.Println("五月末", mayEnd)
1056
+	mayEndStr := mayEnd + " 23:59:59"
1057
+	mayEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", mayEndStr)
1058
+	mayEndStrsUnix := mayEndStrs.Unix()
1059
+	fmt.Println("五月末", mayEndStrsUnix)
1060
+
1061
+	junStart := this.GetString("junStart")
1062
+	fmt.Println("六月始", mayStart)
1063
+	junStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", junStart)
1064
+	junStartStrUnix := junStartStr.Unix()
1065
+	fmt.Println("六月使", junStartStrUnix)
1066
+	junEnd := this.GetString("junEnd")
1067
+	fmt.Println("六月末", junEnd)
1068
+	junEndStr := junEnd + " 23:59:59"
1069
+	junEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", junEndStr)
1070
+	junEndStrsUnix := junEndStrs.Unix()
1071
+	fmt.Println("六月末", junEndStrsUnix)
1072
+
1073
+	julStart := this.GetString("julStart")
1074
+	fmt.Println("七月始", julStart)
1075
+	julStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", julStart)
1076
+	julStartStrUnix := julStartStr.Unix()
1077
+	fmt.Println("七月使", julStartStrUnix)
1078
+	julEnd := this.GetString("julEnd")
1079
+	fmt.Println("七月末", julEnd)
1080
+	julEndStr := julEnd + " 23:59:59"
1081
+	julEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", julEndStr)
1082
+	julEndStrsUnix := julEndStrs.Unix()
1083
+	fmt.Println("七月末", julEndStrsUnix)
1084
+
1085
+	augStart := this.GetString("augStart")
1086
+	fmt.Println("八月始", augStart)
1087
+	augStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", augStart)
1088
+	augStartStrUnix := augStartStr.Unix()
1089
+	fmt.Println("八月使", augStartStrUnix)
1090
+	augEnd := this.GetString("augEnd")
1091
+	fmt.Println("八月末", augEnd)
1092
+	augEndStr := augEnd + " 23:59:59"
1093
+	augEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", augEndStr)
1094
+	augEndStrsUnix := augEndStrs.Unix()
1095
+	fmt.Println("八月末", augEndStrsUnix)
1096
+
1097
+	sepStart := this.GetString("sepStart")
1098
+	fmt.Println("九月始", sepStart)
1099
+	sepStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", sepStart)
1100
+	sepStartStrUnix := sepStartStr.Unix()
1101
+	fmt.Println("九月使", sepStartStrUnix)
1102
+	sepEnd := this.GetString("sepEnd")
1103
+	fmt.Println("九月末", sepEnd)
1104
+	sepEndStr := sepEnd + " 23:59:59"
1105
+	sepEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", sepEndStr)
1106
+	sepEndStrsUnix := sepEndStrs.Unix()
1107
+	fmt.Println("九月末", sepEndStrsUnix)
1108
+
1109
+	octStart := this.GetString("octStart")
1110
+	fmt.Println("10月始", octStart)
1111
+	octStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", octStart)
1112
+	octStartStrUnix := octStartStr.Unix()
1113
+	fmt.Println("10月使", octStartStrUnix)
1114
+	octEnd := this.GetString("octEnd")
1115
+	fmt.Println("10月末", octEnd)
1116
+	octEndStr := octEnd + " 23:59:59"
1117
+	octEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", octEndStr)
1118
+	octEndStrsUnix := octEndStrs.Unix()
1119
+	fmt.Println("10月末", octEndStrsUnix)
1120
+
1121
+	novStart := this.GetString("novStart")
1122
+	fmt.Println("11月始", novStart)
1123
+	novStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", novStart)
1124
+	novStartStrUnix := novStartStr.Unix()
1125
+	fmt.Println("11月使", novStartStrUnix)
1126
+	novEnd := this.GetString("novEnd")
1127
+	fmt.Println("11月末", novEnd)
1128
+	novEndStr := novEnd + " 23:59:59"
1129
+	novEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", novEndStr)
1130
+	novEndStrsUnix := novEndStrs.Unix()
1131
+	fmt.Println("10月末", novEndStrsUnix)
1132
+
1133
+	decStart := this.GetString("decStart")
1134
+	fmt.Println("12月始", novStart)
1135
+	decStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", decStart)
1136
+	decStartStrUnix := decStartStr.Unix()
1137
+	fmt.Println("12月使", decStartStrUnix)
1138
+	decEnd := this.GetString("decEnd")
1139
+	fmt.Println("12月末", novEnd)
1140
+	decEndStr := decEnd + " 23:59:59"
1141
+	decEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", decEndStr)
1142
+	decEndStrsUnix := decEndStrs.Unix()
1143
+	fmt.Println("12月末", decEndStrsUnix)
1144
+	//统计总共
1145
+	monthlist, err := service.GetMonthProjectList(orgid, lapseto, modetype, januaryStartStrUnix, januaryEndStrUnix, febStartStrStrUnix, febEndStrUnix, marchStartStrUnix, marchEndStrUnix, aprStartStrUnix, aprEndStrsUnix, mayStartStrUnix, mayEndStrsUnix, junStartStrUnix, junEndStrsUnix, julStartStrUnix, julEndStrsUnix, augStartStrUnix, augEndStrsUnix, sepStartStrUnix, sepEndStrsUnix, octStartStrUnix, octEndStrsUnix, novStartStrUnix, novEndStrsUnix, decStartStrUnix, decEndStrsUnix)
1146
+	//统计不合格
1147
+	monthNolist, err := service.GetMonthProjectListTwo(orgid, lapseto, modetype, januaryStartStrUnix, januaryEndStrUnix, febStartStrStrUnix, febEndStrUnix, marchStartStrUnix, marchEndStrUnix, aprStartStrUnix, aprEndStrsUnix, mayStartStrUnix, mayEndStrsUnix, junStartStrUnix, junEndStrsUnix, julStartStrUnix, julEndStrsUnix, augStartStrUnix, augEndStrsUnix, sepStartStrUnix, sepEndStrsUnix, octStartStrUnix, octEndStrsUnix, novStartStrUnix, novEndStrsUnix, decStartStrUnix, decEndStrsUnix)
1148
+	if err != nil {
1149
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1150
+		return
1151
+	}
1152
+
1153
+	this.ServeSuccessJSON(map[string]interface{}{
1154
+		"monthlist":   monthlist,
1155
+		"monthNolist": monthNolist,
1156
+	})
1031 1157
 }

+ 125 - 0
controllers/new_mobile_api_controllers/new_common_api_controller.go View File

@@ -370,3 +370,128 @@ func (this *NewCommonApiController) GetSeachPatientDetail() {
370 370
 		"PatientsInfo": PatientsInfo,
371 371
 	})
372 372
 }
373
+
374
+func (this *NewCommonApiController) GetMobileNormdata() {
375
+
376
+	adminInfo := this.GetMobileAdminUserInfo()
377
+	orgid := adminInfo.Org.Id
378
+	//获取系统数据
379
+	normdata, err := service.GetNormDataByOrgId(orgid)
380
+	if len(normdata) == 0 {
381
+		normdata, err := service.GetNormData(0)
382
+		if err != nil {
383
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
384
+			return
385
+		}
386
+		this.ServeSuccessJSON(map[string]interface{}{
387
+			"normdata": normdata,
388
+		})
389
+	}
390
+	if err != nil {
391
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
392
+		return
393
+	}
394
+	this.ServeSuccessJSON(map[string]interface{}{
395
+		"normdata": normdata,
396
+	})
397
+}
398
+
399
+func (this *NewCommonApiController) GetMobileProjectlsit() {
400
+
401
+	adminInfo := this.GetMobileAdminUserInfo()
402
+	orgid := adminInfo.Org.Id
403
+	fmt.Println("orgid", orgid)
404
+	lapseto, _ := this.GetInt64("lapseto")
405
+	fmt.Println("专柜", lapseto)
406
+	itemtype, _ := this.GetInt64("itemtype")
407
+	fmt.Println("itemtype", itemtype)
408
+	modetype, _ := this.GetInt64("modeltype")
409
+	fmt.Println(modetype)
410
+
411
+	firstQuarterStart := this.GetString("first_quarter_start")
412
+	firstQuarterStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", firstQuarterStart)
413
+	firstQuarterStartUnix := firstQuarterStartStr.Unix()
414
+	fmt.Println("第一季度开始时间", firstQuarterStartUnix)
415
+	fisrtQuarterEnd := this.GetString("first_qurter_end")
416
+	fisrtQuarterEndStr := fisrtQuarterEnd + " 23:59:59"
417
+	fisrtQuarterEnds, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", fisrtQuarterEndStr)
418
+	fisrtQuarterEndStrUnix := fisrtQuarterEnds.Unix()
419
+	fmt.Println("第一季度结束时间", fisrtQuarterEndStrUnix)
420
+
421
+	secondeQuarterStart := this.GetString("second_qurter_start")
422
+	secondeQuarterStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", secondeQuarterStart)
423
+	secondeQuarterStartUnix := secondeQuarterStartStr.Unix()
424
+	fmt.Println("第二季度开始时间", secondeQuarterStartUnix)
425
+	secondQuarterEnd := this.GetString("second_qurter_end")
426
+	secondQuarterEndStr := secondQuarterEnd + " 23:59:59"
427
+	secondQuarterEnds, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", secondQuarterEndStr)
428
+	secondQuarterEndStrUnix := secondQuarterEnds.Unix()
429
+	fmt.Println("第二季度结束时间", secondQuarterEndStrUnix)
430
+
431
+	threeQuarterStart := this.GetString("three_qurter_start")
432
+	threeQuarterStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", threeQuarterStart)
433
+	threeQuarterStartUnix := threeQuarterStartStr.Unix()
434
+	fmt.Println("第三季度开始时间", threeQuarterStartUnix)
435
+	threeQuarterEnd := this.GetString("three_qurter_end")
436
+	threeQuarterEndStr := threeQuarterEnd + " 23:59:59"
437
+	threeQuarterEnds, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", threeQuarterEndStr)
438
+	threeQuarterEndStrUnix := threeQuarterEnds.Unix()
439
+	fmt.Println("第三季度结束时间", threeQuarterEndStrUnix)
440
+
441
+	fourQuarterStart := this.GetString("four_qurter_start")
442
+	fourQuarterStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", fourQuarterStart)
443
+	fourQuarterStartUnix := fourQuarterStartStr.Unix()
444
+	fmt.Println("第四季度开始时间", fourQuarterStartUnix)
445
+	fourQuarterEnd := this.GetString("four_qurter_end")
446
+	fourQuarterEndStr := fourQuarterEnd + " 23:59:59"
447
+	fourQuarterEnds, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", fourQuarterEndStr)
448
+	fourQuarterEndStrUnix := fourQuarterEnds.Unix()
449
+	fmt.Println("第四季度结束时间", fourQuarterEndStrUnix)
450
+
451
+	//按季度统计
452
+	if itemtype == 1 {
453
+		//统计总共
454
+		list, err := service.GetProjectList(orgid, lapseto, modetype, firstQuarterStartUnix, fourQuarterEndStrUnix, firstQuarterStartUnix, fisrtQuarterEndStrUnix, secondeQuarterStartUnix, secondQuarterEndStrUnix, threeQuarterStartUnix, threeQuarterEndStrUnix, fourQuarterStartUnix, fourQuarterEndStrUnix)
455
+		//统计达标个数
456
+		standList, err := service.GetProjectStandList(orgid, lapseto, modetype, firstQuarterStartUnix, fourQuarterEndStrUnix, firstQuarterStartUnix, fisrtQuarterEndStrUnix, secondeQuarterStartUnix, secondQuarterEndStrUnix, threeQuarterStartUnix, threeQuarterEndStrUnix, fourQuarterStartUnix, fourQuarterEndStrUnix)
457
+		if err != nil {
458
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
459
+			return
460
+		}
461
+
462
+		this.ServeSuccessJSON(map[string]interface{}{
463
+			"list":      list,
464
+			"standList": standList,
465
+		})
466
+	}
467
+}
468
+
469
+func (this *NewCommonApiController) GetMobileFirstQuarter() {
470
+
471
+	adminUser := this.GetMobileAdminUserInfo()
472
+	orgid := adminUser.Org.Id
473
+	lapseto, _ := this.GetInt64("lapseto")
474
+	fmt.Println("转归", lapseto)
475
+	startime := this.GetString("startime")
476
+	fmt.Println("startime", startime)
477
+	startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
478
+	fmt.Println("parseDateErr", parseDateErr)
479
+	statime := startDate.Unix()
480
+	fmt.Println("开始时间", statime)
481
+	endtime := this.GetString("endtime")
482
+	fmt.Println("endtime", endtime)
483
+	endTimeYMDHmsStr := endtime + " 23:59:59"
484
+	endDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
485
+	entime := endDate.Unix()
486
+	fmt.Println("结束日期", entime)
487
+	//group, parseDateErr := service.GetItemNameGroup(orgid, statime, entime)
488
+	//quarter, err := service.GetFirstQuarter(orgid, statime, entime)
489
+	count, err := service.GetQuarterTotalCount(orgid, statime, entime, lapseto)
490
+	if err != nil {
491
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
492
+		return
493
+	}
494
+	this.ServeSuccessJSON(map[string]interface{}{
495
+		"count": count,
496
+	})
497
+}

+ 3 - 0
controllers/new_mobile_api_controllers/new_common_api_router.go View File

@@ -18,4 +18,7 @@ func NewCommonApiControllersRegisterRouters() {
18 18
 	beego.Router("/m/api/getmobileInspectionList", &NewCommonApiController{}, "Get:GetMobileInspectionList")
19 19
 	beego.Router("/m/api/getpatientinspectiondetail", &NewCommonApiController{}, "Get:GetPatientInspectionDetail")
20 20
 	beego.Router("m/api/getseachpatientdetail", &NewCommonApiController{}, "Get:GetSeachPatientDetail")
21
+	beego.Router("m/api/getmobilenormdata", &NewCommonApiController{}, "Get:GetMobileNormdata")
22
+	beego.Router("m/api/getmobileprojectlist", &NewCommonApiController{}, "Get:GetMobileProjectlsit")
23
+	beego.Router("/m/api/getmobilefirstquarter", &NewCommonApiController{}, "Get:GetMobileFirstQuarter")
21 24
 }

+ 5 - 5
models/common_models.go View File

@@ -290,11 +290,11 @@ type DialysisTotalDataStruct struct {
290 290
 	ModeID string `json:"mode_id"`
291 291
 }
292 292
 
293
-type UserInspectionProjectCount struct {
294
-	PatientId int64
295
-	Count     int64
296
-	ProjectId int64
297
-}
293
+//type UserInspectionProjectCount struct {
294
+//  PatientId int64
295
+//  Count     int64
296
+//  ProjectId int64
297
+//}
298 298
 
299 299
 type InspectionReferenceMaps struct {
300 300
 	ProjectName        string               `gorm:"-" json:"project_name" form:"project_name"`

+ 11 - 4
models/inspection_models.go View File

@@ -77,6 +77,12 @@ type UserInspectionProjectCounts struct {
77 77
 	Sort                int64
78 78
 }
79 79
 
80
+type UserInspectionProjectCount struct {
81
+	PatientId int64
82
+	Count     int64
83
+	ProjectId int64
84
+}
85
+
80 86
 type UserDoctorAdvicesCount struct {
81 87
 	PatientId int64
82 88
 	Count     int64
@@ -91,10 +97,11 @@ type InspectionReferenceMap struct {
91 97
 }
92 98
 
93 99
 type InepectionForm struct {
94
-	Method      string `json:"method"`
95
-	ProjectId   int64  `json:"project_id"`
96
-	InspectDate string `json:"inspect_date"`
97
-	FormItem    []struct {
100
+	Method         string `json:"method"`
101
+	ProjectId      int64  `json:"project_id"`
102
+	InspectDate    string `json:"inspect_date"`
103
+	OldInspectDate string `json:"old_inspect_date"`
104
+	FormItem       []struct {
98 105
 		ID          int64  `json:"id"`
99 106
 		ProjectId   int64  `json:"project_id"`
100 107
 		ProjectName string `json:"project_name"`

+ 441 - 0
service/common_service.go View File

@@ -1080,3 +1080,444 @@ func GetProjectStandList(orgid int64, lapseto int64, modetype int64, startime in
1080 1080
 	}
1081 1081
 	return
1082 1082
 }
1083
+
1084
+func GetMonthProjectList(orgid int64, lapseto int64, modetype int64, januaryStartStrUnix int64, januaryEndStrUnix int64, febStartStrStrUnix int64, febEndStrUnix int64, marchStartStrUnix int64, marchEndStrUnix int64, aprStartStrUnix int64, aprEndStrsUnix int64, mayStartStrUnix int64, mayEndStrsUnix int64, junStartStrUnix int64, junEndStrsUnix int64, julStartStrUnix int64, julEndStrsUnix int64, augStartStrUnix int64, augEndStrsUnix int64, sepStartStrUnix int64, sepEndStrsUnix int64, octStartStrUnix int64, octEndStrsUnix int64, novStartStrUnix int64, novEndStrsUnix int64, decStartStrUnix int64, decEndStrsUnix int64) (inspection []*models.ProjectCountOne, err error) {
1085
+
1086
+	if lapseto == 0 {
1087
+
1088
+		d := XTReadDB().Table("xt_patients as s")
1089
+		fmt.Println("d", d)
1090
+		db := readDb.Table("xt_inspection as x ").Where("x.status=1")
1091
+
1092
+		countSQL := "SELECT nnd AS 'total',COUNT(*) AS 'count' FROM(" +
1093
+			"SELECT " +
1094
+			"CASE " +
1095
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? THEN '一月'" +
1096
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? THEN '二月'" +
1097
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? THEN '三月'" +
1098
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? THEN '四月'" +
1099
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? THEN '五月'" +
1100
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? THEN '六月'" +
1101
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? THEN '七月'" +
1102
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? THEN '八月'" +
1103
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? THEN '九月'" +
1104
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? THEN '十月'" +
1105
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? THEN '十一月'" +
1106
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? THEN '十二月'" +
1107
+			" ELSE '其他'" +
1108
+			"END AS nnd FROM xt_inspection as x left join xt_patients as s on s.id = x.patient_id  WHERE x.status=1 and (s.lapseto = 1 or s.lapseto = 2)"
1109
+		countParams := make([]interface{}, 0)
1110
+		countParams = append(countParams, januaryStartStrUnix)
1111
+		countParams = append(countParams, januaryEndStrUnix)
1112
+		countParams = append(countParams, febStartStrStrUnix)
1113
+		countParams = append(countParams, febEndStrUnix)
1114
+		countParams = append(countParams, marchStartStrUnix)
1115
+		countParams = append(countParams, marchEndStrUnix)
1116
+		countParams = append(countParams, aprStartStrUnix)
1117
+		countParams = append(countParams, aprEndStrsUnix)
1118
+		countParams = append(countParams, mayStartStrUnix)
1119
+		countParams = append(countParams, mayEndStrsUnix)
1120
+		countParams = append(countParams, junStartStrUnix)
1121
+		countParams = append(countParams, junEndStrsUnix)
1122
+		countParams = append(countParams, julStartStrUnix)
1123
+		countParams = append(countParams, julEndStrsUnix)
1124
+		countParams = append(countParams, augStartStrUnix)
1125
+		countParams = append(countParams, augEndStrsUnix)
1126
+		countParams = append(countParams, sepStartStrUnix)
1127
+		countParams = append(countParams, sepEndStrsUnix)
1128
+		countParams = append(countParams, octStartStrUnix)
1129
+		countParams = append(countParams, octEndStrsUnix)
1130
+		countParams = append(countParams, novStartStrUnix)
1131
+		countParams = append(countParams, novEndStrsUnix)
1132
+		countParams = append(countParams, decStartStrUnix)
1133
+		countParams = append(countParams, decEndStrsUnix)
1134
+		if orgid > 0 {
1135
+			db = db.Where("x.org_id=?", orgid)
1136
+			countSQL += " AND x.org_id=?"
1137
+			countParams = append(countParams, orgid)
1138
+		}
1139
+		if modetype > 0 {
1140
+			db = db.Where("x.item_id = ?", modetype)
1141
+			countSQL += " AND x.item_id=?"
1142
+			countParams = append(countParams, modetype)
1143
+		}
1144
+		if januaryStartStrUnix > 0 {
1145
+			db = db.Where("x.inspect_date >= ?", januaryStartStrUnix)
1146
+			countSQL += " AND x.inspect_date >=?"
1147
+			countParams = append(countParams, januaryStartStrUnix)
1148
+		}
1149
+		if decEndStrsUnix > 0 {
1150
+			db = db.Where("x.inspect_date <= ?", decEndStrsUnix)
1151
+			countSQL += " AND x.inspect_date <=?"
1152
+			countParams = append(countParams, decEndStrsUnix)
1153
+		}
1154
+		countSQL += ")a GROUP BY nnd"
1155
+		err = readDb.Raw(countSQL, countParams...).Scan(&inspection).Error
1156
+	}
1157
+
1158
+	if lapseto == 1 {
1159
+
1160
+		d := XTReadDB().Table("xt_patients as s")
1161
+		fmt.Println("d", d)
1162
+		db := readDb.Table("xt_inspection as x ").Where("x.status=1")
1163
+
1164
+		countSQL := "SELECT nnd AS 'total',COUNT(*) AS 'count' FROM(" +
1165
+			"SELECT " +
1166
+			"CASE " +
1167
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? THEN '一月'" +
1168
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? THEN '二月'" +
1169
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? THEN '三月'" +
1170
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? THEN '四月'" +
1171
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? THEN '五月'" +
1172
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? THEN '六月'" +
1173
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? THEN '七月'" +
1174
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? THEN '八月'" +
1175
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? THEN '九月'" +
1176
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? THEN '十月'" +
1177
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? THEN '十一月'" +
1178
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? THEN '十二月'" +
1179
+			" ELSE '其他'" +
1180
+			"END AS nnd FROM xt_inspection as x left join xt_patients as s on s.id = x.patient_id  WHERE x.status=1 and (s.lapseto = 1)"
1181
+		countParams := make([]interface{}, 0)
1182
+		countParams = append(countParams, januaryStartStrUnix)
1183
+		countParams = append(countParams, januaryEndStrUnix)
1184
+		countParams = append(countParams, febStartStrStrUnix)
1185
+		countParams = append(countParams, febEndStrUnix)
1186
+		countParams = append(countParams, marchStartStrUnix)
1187
+		countParams = append(countParams, marchEndStrUnix)
1188
+		countParams = append(countParams, aprStartStrUnix)
1189
+		countParams = append(countParams, aprEndStrsUnix)
1190
+		countParams = append(countParams, mayStartStrUnix)
1191
+		countParams = append(countParams, mayEndStrsUnix)
1192
+		countParams = append(countParams, junStartStrUnix)
1193
+		countParams = append(countParams, junEndStrsUnix)
1194
+		countParams = append(countParams, julStartStrUnix)
1195
+		countParams = append(countParams, julEndStrsUnix)
1196
+		countParams = append(countParams, augStartStrUnix)
1197
+		countParams = append(countParams, augEndStrsUnix)
1198
+		countParams = append(countParams, sepStartStrUnix)
1199
+		countParams = append(countParams, sepEndStrsUnix)
1200
+		countParams = append(countParams, octStartStrUnix)
1201
+		countParams = append(countParams, octEndStrsUnix)
1202
+		countParams = append(countParams, novStartStrUnix)
1203
+		countParams = append(countParams, novEndStrsUnix)
1204
+		countParams = append(countParams, decStartStrUnix)
1205
+		countParams = append(countParams, decEndStrsUnix)
1206
+		if orgid > 0 {
1207
+			db = db.Where("x.org_id=?", orgid)
1208
+			countSQL += " AND x.org_id=?"
1209
+			countParams = append(countParams, orgid)
1210
+		}
1211
+		if modetype > 0 {
1212
+			db = db.Where("x.item_id = ?", modetype)
1213
+			countSQL += " AND x.item_id=?"
1214
+			countParams = append(countParams, modetype)
1215
+		}
1216
+		if januaryStartStrUnix > 0 {
1217
+			db = db.Where("x.inspect_date >= ?", januaryStartStrUnix)
1218
+			countSQL += " AND x.inspect_date >=?"
1219
+			countParams = append(countParams, januaryStartStrUnix)
1220
+		}
1221
+		if decEndStrsUnix > 0 {
1222
+			db = db.Where("x.inspect_date <= ?", decEndStrsUnix)
1223
+			countSQL += " AND x.inspect_date <=?"
1224
+			countParams = append(countParams, decEndStrsUnix)
1225
+		}
1226
+		countSQL += ")a GROUP BY nnd"
1227
+		err = readDb.Raw(countSQL, countParams...).Scan(&inspection).Error
1228
+	}
1229
+
1230
+	if lapseto == 2 {
1231
+		d := XTReadDB().Table("xt_patients as s")
1232
+		fmt.Println("d", d)
1233
+		db := readDb.Table("xt_inspection as x ").Where("x.status=1")
1234
+
1235
+		countSQL := "SELECT nnd AS 'total',COUNT(*) AS 'count' FROM(" +
1236
+			"SELECT " +
1237
+			"CASE " +
1238
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? THEN '一月'" +
1239
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? THEN '二月'" +
1240
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? THEN '三月'" +
1241
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? THEN '四月'" +
1242
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? THEN '五月'" +
1243
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? THEN '六月'" +
1244
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? THEN '七月'" +
1245
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? THEN '八月'" +
1246
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? THEN '九月'" +
1247
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? THEN '十月'" +
1248
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? THEN '十一月'" +
1249
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? THEN '十二月'" +
1250
+			" ELSE '其他'" +
1251
+			"END AS nnd FROM xt_inspection as x left join xt_patients as s on s.id = x.patient_id  WHERE x.status=1 and (s.lapseto = 2)"
1252
+		countParams := make([]interface{}, 0)
1253
+		countParams = append(countParams, januaryStartStrUnix)
1254
+		countParams = append(countParams, januaryEndStrUnix)
1255
+		countParams = append(countParams, febStartStrStrUnix)
1256
+		countParams = append(countParams, febEndStrUnix)
1257
+		countParams = append(countParams, marchStartStrUnix)
1258
+		countParams = append(countParams, marchEndStrUnix)
1259
+		countParams = append(countParams, aprStartStrUnix)
1260
+		countParams = append(countParams, aprEndStrsUnix)
1261
+		countParams = append(countParams, mayStartStrUnix)
1262
+		countParams = append(countParams, mayEndStrsUnix)
1263
+		countParams = append(countParams, junStartStrUnix)
1264
+		countParams = append(countParams, junEndStrsUnix)
1265
+		countParams = append(countParams, julStartStrUnix)
1266
+		countParams = append(countParams, julEndStrsUnix)
1267
+		countParams = append(countParams, augStartStrUnix)
1268
+		countParams = append(countParams, augEndStrsUnix)
1269
+		countParams = append(countParams, sepStartStrUnix)
1270
+		countParams = append(countParams, sepEndStrsUnix)
1271
+		countParams = append(countParams, octStartStrUnix)
1272
+		countParams = append(countParams, octEndStrsUnix)
1273
+		countParams = append(countParams, novStartStrUnix)
1274
+		countParams = append(countParams, novEndStrsUnix)
1275
+		countParams = append(countParams, decStartStrUnix)
1276
+		countParams = append(countParams, decEndStrsUnix)
1277
+		if orgid > 0 {
1278
+			db = db.Where("x.org_id=?", orgid)
1279
+			countSQL += " AND x.org_id=?"
1280
+			countParams = append(countParams, orgid)
1281
+		}
1282
+		if modetype > 0 {
1283
+			db = db.Where("x.item_id = ?", modetype)
1284
+			countSQL += " AND x.item_id=?"
1285
+			countParams = append(countParams, modetype)
1286
+		}
1287
+		if januaryStartStrUnix > 0 {
1288
+			db = db.Where("x.inspect_date >= ?", januaryStartStrUnix)
1289
+			countSQL += " AND x.inspect_date >=?"
1290
+			countParams = append(countParams, januaryStartStrUnix)
1291
+		}
1292
+		if decEndStrsUnix > 0 {
1293
+			db = db.Where("x.inspect_date <= ?", decEndStrsUnix)
1294
+			countSQL += " AND x.inspect_date <=?"
1295
+			countParams = append(countParams, decEndStrsUnix)
1296
+		}
1297
+		countSQL += ")a GROUP BY nnd"
1298
+		err = readDb.Raw(countSQL, countParams...).Scan(&inspection).Error
1299
+	}
1300
+	return
1301
+}
1302
+
1303
+func GetMonthProjectListTwo(orgid int64, lapseto int64, modetype int64, januaryStartStrUnix int64, januaryEndStrUnix int64, febStartStrStrUnix int64, febEndStrUnix int64, marchStartStrUnix int64, marchEndStrUnix int64, aprStartStrUnix int64, aprEndStrsUnix int64, mayStartStrUnix int64, mayEndStrsUnix int64, junStartStrUnix int64, junEndStrsUnix int64, julStartStrUnix int64, julEndStrsUnix int64, augStartStrUnix int64, augEndStrsUnix int64, sepStartStrUnix int64, sepEndStrsUnix int64, octStartStrUnix int64, octEndStrsUnix int64, novStartStrUnix int64, novEndStrsUnix int64, decStartStrUnix int64, decEndStrsUnix int64) (inspection []*models.ProjectCount, err error) {
1304
+
1305
+	if lapseto == 0 {
1306
+		d := XTReadDB().Table("xt_patients as s")
1307
+		fmt.Println("d", d)
1308
+		db := readDb.Table("xt_inspection as x ").Where("x.status=1")
1309
+		table := XTReadDB().Table("xt_inspection_reference as r")
1310
+		fmt.Println(table)
1311
+		countSQL := "SELECT nnd AS 'total',COUNT(*) AS 'count' FROM(" +
1312
+			"SELECT " +
1313
+			"CASE " +
1314
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0  THEN '一月'" +
1315
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0  THEN '二月'" +
1316
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0  THEN '三月'" +
1317
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0  THEN '四月'" +
1318
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0  THEN '五月'" +
1319
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0  THEN '六月'" +
1320
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0  THEN '七月'" +
1321
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0  THEN '八月'" +
1322
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0  THEN '九月'" +
1323
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0  THEN '十月'" +
1324
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0  THEN '十一月'" +
1325
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0  THEN '十二月'" +
1326
+			" ELSE '其他'" +
1327
+			"END AS nnd FROM xt_inspection as x left join xt_inspection_reference as  r on r.id = x.item_id left join xt_patients as s on s.id = x.patient_id  WHERE x.status=1 and (s.lapseto = 1 or s.lapseto = 2) and (x.inspect_value + 0 >= r.range_min + 0 AND x.inspect_value + 0 <= r.range_max + 0)"
1328
+		countParams := make([]interface{}, 0)
1329
+		countParams = append(countParams, januaryStartStrUnix)
1330
+		countParams = append(countParams, januaryEndStrUnix)
1331
+		countParams = append(countParams, febStartStrStrUnix)
1332
+		countParams = append(countParams, febEndStrUnix)
1333
+		countParams = append(countParams, marchStartStrUnix)
1334
+		countParams = append(countParams, marchEndStrUnix)
1335
+		countParams = append(countParams, aprStartStrUnix)
1336
+		countParams = append(countParams, aprEndStrsUnix)
1337
+		countParams = append(countParams, mayStartStrUnix)
1338
+		countParams = append(countParams, mayEndStrsUnix)
1339
+		countParams = append(countParams, junStartStrUnix)
1340
+		countParams = append(countParams, junEndStrsUnix)
1341
+		countParams = append(countParams, julStartStrUnix)
1342
+		countParams = append(countParams, julEndStrsUnix)
1343
+		countParams = append(countParams, augStartStrUnix)
1344
+		countParams = append(countParams, augEndStrsUnix)
1345
+		countParams = append(countParams, sepStartStrUnix)
1346
+		countParams = append(countParams, sepEndStrsUnix)
1347
+		countParams = append(countParams, octStartStrUnix)
1348
+		countParams = append(countParams, octEndStrsUnix)
1349
+		countParams = append(countParams, novStartStrUnix)
1350
+		countParams = append(countParams, novEndStrsUnix)
1351
+		countParams = append(countParams, decStartStrUnix)
1352
+		countParams = append(countParams, decEndStrsUnix)
1353
+		if orgid > 0 {
1354
+			db = db.Where("x.org_id=?", orgid)
1355
+			countSQL += " AND x.org_id=?"
1356
+			countParams = append(countParams, orgid)
1357
+		}
1358
+		if modetype > 0 {
1359
+			db = db.Where("x.item_id = ?", modetype)
1360
+			countSQL += " AND x.item_id=?"
1361
+			countParams = append(countParams, modetype)
1362
+		}
1363
+		if januaryStartStrUnix > 0 {
1364
+			db = db.Where("x.inspect_date >= ?", januaryStartStrUnix)
1365
+			countSQL += " AND x.inspect_date >=?"
1366
+			countParams = append(countParams, januaryStartStrUnix)
1367
+		}
1368
+		if decEndStrsUnix > 0 {
1369
+			db = db.Where("x.inspect_date <= ?", decEndStrsUnix)
1370
+			countSQL += " AND x.inspect_date <=?"
1371
+			countParams = append(countParams, decEndStrsUnix)
1372
+		}
1373
+		countSQL += ")a GROUP BY nnd"
1374
+		err = readDb.Raw(countSQL, countParams...).Scan(&inspection).Error
1375
+	}
1376
+
1377
+	if lapseto == 1 {
1378
+
1379
+		d := XTReadDB().Table("xt_patients as s")
1380
+		fmt.Println("d", d)
1381
+		db := readDb.Table("xt_inspection as x ").Where("x.status=1")
1382
+		table := XTReadDB().Table("xt_inspection_reference as r")
1383
+		fmt.Println(table)
1384
+		countSQL := "SELECT nnd AS 'total',COUNT(*) AS 'count' FROM(" +
1385
+			"SELECT " +
1386
+			"CASE " +
1387
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0  THEN '一月'" +
1388
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0  THEN '二月'" +
1389
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0  THEN '三月'" +
1390
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0  THEN '四月'" +
1391
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0  THEN '五月'" +
1392
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0  THEN '六月'" +
1393
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0  THEN '七月'" +
1394
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0  THEN '八月'" +
1395
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0  THEN '九月'" +
1396
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0  THEN '十月'" +
1397
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0  THEN '十一月'" +
1398
+			" WHEN x.inspect_date>=? AND  x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0  THEN '十二月'" +
1399
+			" ELSE '其他'" +
1400
+			"END AS nnd FROM xt_inspection as x left join xt_inspection_reference as  r on r.id = x.item_id left join xt_patients as s on s.id = x.patient_id  WHERE x.status=1 and (s.lapseto = 1) and (x.inspect_value + 0 >= r.range_min + 0 AND x.inspect_value + 0 <= r.range_max + 0)"
1401
+		countParams := make([]interface{}, 0)
1402
+		countParams = append(countParams, januaryStartStrUnix)
1403
+		countParams = append(countParams, januaryEndStrUnix)
1404
+		countParams = append(countParams, febStartStrStrUnix)
1405
+		countParams = append(countParams, febEndStrUnix)
1406
+		countParams = append(countParams, marchStartStrUnix)
1407
+		countParams = append(countParams, marchEndStrUnix)
1408
+		countParams = append(countParams, aprStartStrUnix)
1409
+		countParams = append(countParams, aprEndStrsUnix)
1410
+		countParams = append(countParams, mayStartStrUnix)
1411
+		countParams = append(countParams, mayEndStrsUnix)
1412
+		countParams = append(countParams, junStartStrUnix)
1413
+		countParams = append(countParams, junEndStrsUnix)
1414
+		countParams = append(countParams, julStartStrUnix)
1415
+		countParams = append(countParams, julEndStrsUnix)
1416
+		countParams = append(countParams, augStartStrUnix)
1417
+		countParams = append(countParams, augEndStrsUnix)
1418
+		countParams = append(countParams, sepStartStrUnix)
1419
+		countParams = append(countParams, sepEndStrsUnix)
1420
+		countParams = append(countParams, octStartStrUnix)
1421
+		countParams = append(countParams, octEndStrsUnix)
1422
+		countParams = append(countParams, novStartStrUnix)
1423
+		countParams = append(countParams, novEndStrsUnix)
1424
+		countParams = append(countParams, decStartStrUnix)
1425
+		countParams = append(countParams, decEndStrsUnix)
1426
+		if orgid > 0 {
1427
+			db = db.Where("x.org_id=?", orgid)
1428
+			countSQL += " AND x.org_id=?"
1429
+			countParams = append(countParams, orgid)
1430
+		}
1431
+		if modetype > 0 {
1432
+			db = db.Where("x.item_id = ?", modetype)
1433
+			countSQL += " AND x.item_id=?"
1434
+			countParams = append(countParams, modetype)
1435
+		}
1436
+		if januaryStartStrUnix > 0 {
1437
+			db = db.Where("x.inspect_date >= ?", januaryStartStrUnix)
1438
+			countSQL += " AND x.inspect_date >=?"
1439
+			countParams = append(countParams, januaryStartStrUnix)
1440
+		}
1441
+		if decEndStrsUnix > 0 {
1442
+			db = db.Where("x.inspect_date <= ?", decEndStrsUnix)
1443
+			countSQL += " AND x.inspect_date <=?"
1444
+			countParams = append(countParams, decEndStrsUnix)
1445
+		}
1446
+		countSQL += ")a GROUP BY nnd"
1447
+		err = readDb.Raw(countSQL, countParams...).Scan(&inspection).Error
1448
+
1449
+		if lapseto == 2 {
1450
+
1451
+			d := XTReadDB().Table("xt_patients as s")
1452
+			fmt.Println("d", d)
1453
+			db := readDb.Table("xt_inspection as x ").Where("x.status=1")
1454
+			table := XTReadDB().Table("xt_inspection_reference as r")
1455
+			fmt.Println(table)
1456
+			countSQL := "SELECT nnd AS 'total',COUNT(*) AS 'count' FROM(" +
1457
+				"SELECT " +
1458
+				"CASE " +
1459
+				" WHEN x.inspect_date>=? AND  x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0  THEN '一月'" +
1460
+				" WHEN x.inspect_date>=? AND  x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0  THEN '二月'" +
1461
+				" WHEN x.inspect_date>=? AND  x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0  THEN '三月'" +
1462
+				" WHEN x.inspect_date>=? AND  x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0  THEN '四月'" +
1463
+				" WHEN x.inspect_date>=? AND  x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0  THEN '五月'" +
1464
+				" WHEN x.inspect_date>=? AND  x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0  THEN '六月'" +
1465
+				" WHEN x.inspect_date>=? AND  x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0  THEN '七月'" +
1466
+				" WHEN x.inspect_date>=? AND  x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0  THEN '八月'" +
1467
+				" WHEN x.inspect_date>=? AND  x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0  THEN '九月'" +
1468
+				" WHEN x.inspect_date>=? AND  x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0  THEN '十月'" +
1469
+				" WHEN x.inspect_date>=? AND  x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0  THEN '十一月'" +
1470
+				" WHEN x.inspect_date>=? AND  x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0  THEN '十二月'" +
1471
+				" ELSE '其他'" +
1472
+				"END AS nnd FROM xt_inspection as x left join xt_inspection_reference as  r on r.id = x.item_id left join xt_patients as s on s.id = x.patient_id  WHERE x.status=1 and (s.lapseto = 2) and (x.inspect_value + 0 >= r.range_min + 0 AND x.inspect_value + 0 <= r.range_max + 0)"
1473
+			countParams := make([]interface{}, 0)
1474
+			countParams = append(countParams, januaryStartStrUnix)
1475
+			countParams = append(countParams, januaryEndStrUnix)
1476
+			countParams = append(countParams, febStartStrStrUnix)
1477
+			countParams = append(countParams, febEndStrUnix)
1478
+			countParams = append(countParams, marchStartStrUnix)
1479
+			countParams = append(countParams, marchEndStrUnix)
1480
+			countParams = append(countParams, aprStartStrUnix)
1481
+			countParams = append(countParams, aprEndStrsUnix)
1482
+			countParams = append(countParams, mayStartStrUnix)
1483
+			countParams = append(countParams, mayEndStrsUnix)
1484
+			countParams = append(countParams, junStartStrUnix)
1485
+			countParams = append(countParams, junEndStrsUnix)
1486
+			countParams = append(countParams, julStartStrUnix)
1487
+			countParams = append(countParams, julEndStrsUnix)
1488
+			countParams = append(countParams, augStartStrUnix)
1489
+			countParams = append(countParams, augEndStrsUnix)
1490
+			countParams = append(countParams, sepStartStrUnix)
1491
+			countParams = append(countParams, sepEndStrsUnix)
1492
+			countParams = append(countParams, octStartStrUnix)
1493
+			countParams = append(countParams, octEndStrsUnix)
1494
+			countParams = append(countParams, novStartStrUnix)
1495
+			countParams = append(countParams, novEndStrsUnix)
1496
+			countParams = append(countParams, decStartStrUnix)
1497
+			countParams = append(countParams, decEndStrsUnix)
1498
+			if orgid > 0 {
1499
+				db = db.Where("x.org_id=?", orgid)
1500
+				countSQL += " AND x.org_id=?"
1501
+				countParams = append(countParams, orgid)
1502
+			}
1503
+			if modetype > 0 {
1504
+				db = db.Where("x.item_id = ?", modetype)
1505
+				countSQL += " AND x.item_id=?"
1506
+				countParams = append(countParams, modetype)
1507
+			}
1508
+			if januaryStartStrUnix > 0 {
1509
+				db = db.Where("x.inspect_date >= ?", januaryStartStrUnix)
1510
+				countSQL += " AND x.inspect_date >=?"
1511
+				countParams = append(countParams, januaryStartStrUnix)
1512
+			}
1513
+			if decEndStrsUnix > 0 {
1514
+				db = db.Where("x.inspect_date <= ?", decEndStrsUnix)
1515
+				countSQL += " AND x.inspect_date <=?"
1516
+				countParams = append(countParams, decEndStrsUnix)
1517
+			}
1518
+			countSQL += ")a GROUP BY nnd"
1519
+			err = readDb.Raw(countSQL, countParams...).Scan(&inspection).Error
1520
+		}
1521
+	}
1522
+	return
1523
+}