XMLWAN 4 years ago
parent
commit
b132c490c6

+ 4 - 4
controllers/base_api_controller.go View File

@@ -81,7 +81,7 @@ func (this *BaseAuthAPIController) Prepare() {
81 81
 		userAdmin.ModifyTime = 1530786071
82 82
 		var subscibe models.ServeSubscibe
83 83
 		subscibe.ID = 1
84
-		subscibe.OrgId = 9538
84
+		subscibe.OrgId = 7957
85 85
 		subscibe.PeriodStart = 1538035409
86 86
 		subscibe.PeriodEnd = 1569571409
87 87
 		subscibe.State = 1
@@ -91,7 +91,7 @@ func (this *BaseAuthAPIController) Prepare() {
91 91
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
92 92
 		subscibes[4] = &subscibe
93 93
 		var adminUserInfo service.AdminUserInfo
94
-		adminUserInfo.CurrentOrgId = 9538
94
+		adminUserInfo.CurrentOrgId = 7957
95 95
 		adminUserInfo.CurrentAppId = 18
96 96
 		adminUserInfo.AdminUser = &userAdmin
97 97
 		adminUserInfo.Subscibes = subscibes
@@ -326,7 +326,7 @@ func (this *BaseServeAPIController) Prepare() {
326 326
 		userAdmin.ModifyTime = 1530786071
327 327
 		var subscibe models.ServeSubscibe
328 328
 		subscibe.ID = 1
329
-		subscibe.OrgId = 9538
329
+		subscibe.OrgId = 7957
330 330
 		subscibe.PeriodStart = 1538035409
331 331
 		subscibe.PeriodEnd = 1569571409
332 332
 		subscibe.State = 1
@@ -336,7 +336,7 @@ func (this *BaseServeAPIController) Prepare() {
336 336
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
337 337
 		subscibes[4] = &subscibe
338 338
 		var adminUserInfo service.AdminUserInfo
339
-		adminUserInfo.CurrentOrgId = 9538
339
+		adminUserInfo.CurrentOrgId = 7957
340 340
 		adminUserInfo.CurrentAppId = 18
341 341
 		adminUserInfo.AdminUser = &userAdmin
342 342
 		adminUserInfo.Subscibes = subscibes

+ 169 - 68
controllers/new_mobile_api_controllers/common_api_controller.go View File

@@ -21,7 +21,6 @@ func (this *CommonApiController) GetInspectionMajor() {
21 21
 	adminInfo := this.GetAdminUserInfo()
22 22
 	orgid := adminInfo.CurrentOrgId
23 23
 	major, err := service.GetInspectionMajor(orgid)
24
-
25 24
 	if len(major) == 0 {
26 25
 		major, _ := service.GetInspectionMajor(0)
27 26
 		if err != nil {
@@ -106,32 +105,67 @@ func (this *CommonApiController) SaveConfiguration() {
106 105
 	if rangvalue == "0" {
107 106
 		rangvalue = ""
108 107
 	}
109
-	_, errcode := service.GetConfigurationById(inspectionmajor, inspectionMinor, orgid)
110
-	if errcode == gorm.ErrRecordNotFound {
111
-		standard := models.XtQualityControlStandard{
112
-			InspectionMajor: inspectionmajor,
113
-			InspectionMinor: inspectionMinor,
114
-			MinRange:        minrange,
115
-			LargeRange:      largerange,
116
-			Sort:            sorts,
117
-			UserOrgId:       orgid,
118
-			Status:          1,
119
-			RangeType:       checktype,
120
-			RangeValue:      rangvalue,
121
-			CreatedTime:     time.Now().Unix(),
108
+	// 参与集成的机构根据小项id获取item_id
109
+	itemid, err := service.GetItemid(inspectionMinor)
110
+	//查询小项是否有值
111
+	fmt.Println("小项id", itemid.ItemId)
112
+	major, err := service.GetInspectionMajor(orgid)
113
+	if len(major) == 0 {
114
+		_, errcode := service.GetConfigurationById(inspectionmajor, inspectionMinor, orgid)
115
+		if errcode == gorm.ErrRecordNotFound {
116
+			standard := models.XtQualityControlStandard{
117
+				InspectionMajor: inspectionmajor,
118
+				InspectionMinor: inspectionMinor,
119
+				MinRange:        minrange,
120
+				LargeRange:      largerange,
121
+				Sort:            sorts,
122
+				UserOrgId:       orgid,
123
+				Status:          1,
124
+				RangeType:       checktype,
125
+				RangeValue:      rangvalue,
126
+				CreatedTime:     time.Now().Unix(),
127
+			}
128
+			fmt.Println(standard)
129
+			err = service.SaveInspection(&standard)
130
+			if err != nil {
131
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
132
+				return
133
+			}
134
+			this.ServeSuccessJSON(map[string]interface{}{
135
+				"standard": standard,
136
+			})
137
+		} else if errcode == nil {
138
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
139
+			return
122 140
 		}
123
-		fmt.Println(standard)
124
-		err = service.SaveInspection(&standard)
125
-		if err != nil {
126
-			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
141
+	} else {
142
+		_, errcode := service.GetConfigurationById(inspectionmajor, inspectionMinor, orgid)
143
+		if errcode == gorm.ErrRecordNotFound {
144
+			standard := models.XtQualityControlStandard{
145
+				InspectionMajor: inspectionmajor,
146
+				InspectionMinor: itemid.ItemId,
147
+				MinRange:        minrange,
148
+				LargeRange:      largerange,
149
+				Sort:            sorts,
150
+				UserOrgId:       orgid,
151
+				Status:          1,
152
+				RangeType:       checktype,
153
+				RangeValue:      rangvalue,
154
+				CreatedTime:     time.Now().Unix(),
155
+			}
156
+			fmt.Println(standard)
157
+			err = service.SaveInspection(&standard)
158
+			if err != nil {
159
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
160
+				return
161
+			}
162
+			this.ServeSuccessJSON(map[string]interface{}{
163
+				"standard": standard,
164
+			})
165
+		} else if errcode == nil {
166
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
127 167
 			return
128 168
 		}
129
-		this.ServeSuccessJSON(map[string]interface{}{
130
-			"standard": standard,
131
-		})
132
-	} else if errcode == nil {
133
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
134
-		return
135 169
 	}
136 170
 
137 171
 }
@@ -141,28 +175,59 @@ func (this *CommonApiController) GetConfigurationlist() {
141 175
 	page, _ := this.GetInt64("page")
142 176
 	adminUser := this.GetAdminUserInfo()
143 177
 	orgid := adminUser.CurrentOrgId
144
-	configurationlist, total, err := service.GetConfigurationlist(orgid, limit, page)
145
-	if err != nil {
146
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
147
-		return
178
+	major, _ := service.GetInspectionMajor(orgid)
179
+	if len(major) == 0 {
180
+		configurationlist, total, err := service.GetConfigurationlist(orgid, limit, page)
181
+		if err != nil {
182
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
183
+			return
184
+		}
185
+		this.ServeSuccessJSON(map[string]interface{}{
186
+			"configurationlist": configurationlist,
187
+			"total":             total,
188
+		})
189
+	} else {
190
+		configurationlist, total, err := service.GetConfigurationListTwo(orgid, limit, page)
191
+		if err != nil {
192
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
193
+			return
194
+		}
195
+		this.ServeSuccessJSON(map[string]interface{}{
196
+			"configurationlist": configurationlist,
197
+			"total":             total,
198
+		})
148 199
 	}
149
-	this.ServeSuccessJSON(map[string]interface{}{
150
-		"configurationlist": configurationlist,
151
-		"total":             total,
152
-	})
200
+
153 201
 }
154 202
 
155 203
 func (this *CommonApiController) GetConfigurationDetail() {
156 204
 	id, _ := this.GetInt64("id")
157 205
 	//fmt.Println("id是", id)
206
+	orgId := this.GetAdminUserInfo().CurrentOrgId
158 207
 	detail, err := service.GetConfigurationDetail(id)
159
-	if err != nil {
160
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
161
-		return
208
+	major, err := service.GetInspectionMajor(orgId)
209
+	var vid = 0
210
+	if len(major) == 0 {
211
+		if err != nil {
212
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
213
+			return
214
+		}
215
+		this.ServeSuccessJSON(map[string]interface{}{
216
+			"configurationdetail": detail,
217
+			"vid":                 vid,
218
+		})
219
+	} else {
220
+		itemId, err := service.GetIdByItemId(detail.InspectionMinor, orgId)
221
+		if err != nil {
222
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
223
+			return
224
+		}
225
+		this.ServeSuccessJSON(map[string]interface{}{
226
+			"configurationdetail": detail,
227
+			"vid":                 itemId.ID,
228
+		})
162 229
 	}
163
-	this.ServeSuccessJSON(map[string]interface{}{
164
-		"configurationdetail": detail,
165
-	})
230
+
166 231
 }
167 232
 
168 233
 func (this *CommonApiController) GetAllInspectionminor() {
@@ -223,27 +288,54 @@ func (this *CommonApiController) UpdateConfiguration() {
223 288
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
224 289
 		return
225 290
 	}
226
-	standard := models.XtQualityControlStandard{
227
-		InspectionMajor: inspectionmajor,
228
-		InspectionMinor: inspectionMinor,
229
-		MinRange:        minrange,
230
-		LargeRange:      largerange,
231
-		Sort:            sort,
232
-		RangeValue:      rangvalue,
233
-		RangeType:       rangtype,
234
-		Status:          1,
235
-		UserOrgId:       orgId,
236
-		CreatedTime:     time.Now().Unix(),
237
-		UpdatedTime:     time.Now().Unix(),
238
-	}
239
-	err = service.UpdarteConfiguration(&standard, id)
240
-	if err != nil {
241
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
242
-		return
291
+
292
+	major, err := service.GetInspectionMajor(orgId)
293
+	if len(major) == 0 {
294
+		standard := models.XtQualityControlStandard{
295
+			InspectionMajor: inspectionmajor,
296
+			InspectionMinor: inspectionMinor,
297
+			MinRange:        minrange,
298
+			LargeRange:      largerange,
299
+			Sort:            sort,
300
+			RangeValue:      rangvalue,
301
+			RangeType:       rangtype,
302
+			Status:          1,
303
+			UserOrgId:       orgId,
304
+			CreatedTime:     time.Now().Unix(),
305
+			UpdatedTime:     time.Now().Unix(),
306
+		}
307
+		err = service.UpdarteConfiguration(&standard, id)
308
+		if err != nil {
309
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
310
+			return
311
+		}
312
+		this.ServeSuccessJSON(map[string]interface{}{
313
+			"standard": standard,
314
+		})
315
+	} else {
316
+		itemid, _ := service.GetItemid(inspectionMinor)
317
+		standard := models.XtQualityControlStandard{
318
+			InspectionMajor: inspectionmajor,
319
+			InspectionMinor: itemid.ItemId,
320
+			MinRange:        minrange,
321
+			LargeRange:      largerange,
322
+			Sort:            sort,
323
+			RangeValue:      rangvalue,
324
+			RangeType:       rangtype,
325
+			Status:          1,
326
+			UserOrgId:       orgId,
327
+			CreatedTime:     time.Now().Unix(),
328
+			UpdatedTime:     time.Now().Unix(),
329
+		}
330
+		err = service.UpdarteConfiguration(&standard, id)
331
+		if err != nil {
332
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
333
+			return
334
+		}
335
+		this.ServeSuccessJSON(map[string]interface{}{
336
+			"standard": standard,
337
+		})
243 338
 	}
244
-	this.ServeSuccessJSON(map[string]interface{}{
245
-		"standard": standard,
246
-	})
247 339
 
248 340
 }
249 341
 
@@ -1299,9 +1391,9 @@ func (this *CommonApiController) GetPatientscontrol() {
1299 1391
 	limit, _ := this.GetInt64("limit")
1300 1392
 	fmt.Println("limit", limit)
1301 1393
 	patients, total, err := service.GetPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix, page, limit)
1302
-	//统计非传染病类型
1394
+
1303 1395
 	control, err := service.GetLastPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
1304
-	//统计传染病类型
1396
+
1305 1397
 	infectiousControl, err := service.GetInfectiousControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
1306 1398
 
1307 1399
 	if err != nil {
@@ -1334,20 +1426,29 @@ func (this *CommonApiController) GetCartogramList() {
1334 1426
 	endtimeStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endtimeStr)
1335 1427
 	endtimeStrsUnix := endtimeStrs.Unix()
1336 1428
 	fmt.Println("结束时间搓", endtimeStrsUnix)
1337
-	limit, _ := this.GetInt64("limit")
1338
-	page, _ := this.GetInt64("page")
1339
-	cartogramlist, err := service.GetLastPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
1340
-	infectiouscontrol, err := service.GetInfectiousPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
1341
-	_, total, err := service.GetPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix, page, limit)
1429
+	//limit, _ := this.GetInt64("limit")
1430
+	//page, _ := this.GetInt64("page")
1431
+
1432
+	//统计总共
1433
+	_, total, err := service.GetTotalPatientsControl(orgid, startimeStrUnix, endtimeStrsUnix)
1434
+	fmt.Println("total=================", total)
1435
+	//统计rangetype= 1
1436
+	_, standtotal, err := service.GetStandControl(orgid, startimeStrUnix, endtimeStrsUnix)
1437
+	fmt.Println(standtotal)
1438
+	_, standtotalOne, err := service.GetStandControlOne(orgid, startimeStrUnix, endtimeStrsUnix)
1439
+	fmt.Println(standtotalOne)
1440
+	//cartogramlist, err := service.GetLastPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
1441
+	//infectiouscontrol, err := service.GetInfectiousPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
1442
+	//_, total, err := service.GetPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix, page, limit)
1342 1443
 	if err != nil {
1343 1444
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1344 1445
 		return
1345 1446
 	}
1346 1447
 
1347 1448
 	this.ServeSuccessJSON(map[string]interface{}{
1348
-		"cartogramlist":     cartogramlist,
1349
-		"total":             total,
1350
-		"infectiouscontrol": infectiouscontrol,
1449
+		"total":         total,
1450
+		"standtotal":    standtotal,
1451
+		"standtotalOne": standtotalOne,
1351 1452
 	})
1352 1453
 }
1353 1454
 

+ 16 - 8
controllers/new_mobile_api_controllers/new_common_api_controller.go View File

@@ -859,20 +859,28 @@ func (this *NewCommonApiController) GetMobileCartogramlist() {
859 859
 	endtimeStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endtimeStr)
860 860
 	endtimeStrsUnix := endtimeStrs.Unix()
861 861
 	fmt.Println("结束时间搓", endtimeStrsUnix)
862
-	limit, _ := this.GetInt64("limit")
863
-	page, _ := this.GetInt64("page")
864
-	cartogramlist, err := service.GetLastPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
865
-	_, total, err := service.GetPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix, page, limit)
866
-	infectiouscontrol, err := service.GetInfectiousPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
862
+	//统计总共
863
+	_, total, err := service.GetTotalPatientsControl(orgid, startimeStrUnix, endtimeStrsUnix)
864
+	fmt.Println("total=================", total)
865
+	//统计rangetype= 1
866
+	_, standtotal, err := service.GetStandControl(orgid, startimeStrUnix, endtimeStrsUnix)
867
+	fmt.Println(standtotal)
868
+	_, standtotalOne, err := service.GetStandControlOne(orgid, startimeStrUnix, endtimeStrsUnix)
869
+	fmt.Println(standtotalOne)
870
+	//limit, _ := this.GetInt64("limit")
871
+	//page, _ := this.GetInt64("page")
872
+	//cartogramlist, err := service.GetLastPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
873
+	//_, total, err := service.GetPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix, page, limit)
874
+	//infectiouscontrol, err := service.GetInfectiousPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
867 875
 	if err != nil {
868 876
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
869 877
 		return
870 878
 	}
871 879
 
872 880
 	this.ServeSuccessJSON(map[string]interface{}{
873
-		"cartogramlist":     cartogramlist,
874
-		"total":             total,
875
-		"infectiouscontrol": infectiouscontrol,
881
+		"total":         total,
882
+		"standtotal":    standtotal,
883
+		"standtotalOne": standtotalOne,
876 884
 	})
877 885
 }
878 886
 

+ 77 - 0
service/common_service.go View File

@@ -26,6 +26,12 @@ func GetInspectionRange(id int64) (models.XtInspectionReference, error) {
26 26
 	return reference, err
27 27
 }
28 28
 
29
+func GetItemid(id int64) (models.XtInspectionReference, error) {
30
+	reference := models.XtInspectionReference{}
31
+	err = XTReadDB().Model(&reference).Where("id = ? and status = 1", id).Find(&reference).Error
32
+	return reference, err
33
+}
34
+
29 35
 func GetConfigurationById(major int64, moni int64, orgid int64) (*models.XtQualityControlStandard, error) {
30 36
 	standard := models.XtQualityControlStandard{}
31 37
 	err := XTReadDB().Model(&standard).Where("inspection_major = ? and inspection_minor = ? and user_org_id = ? and status = 1", major, moni, orgid).Find(&standard).Error
@@ -64,12 +70,31 @@ func GetConfigurationlist(orgid int64, limit int64, page int64) (standard []*mod
64 70
 	return standard, total, err
65 71
 }
66 72
 
73
+func GetConfigurationListTwo(orgid int64, limit int64, page int64) (standard []*models.QualityControlStandard, total int64, err error) {
74
+	db := XTReadDB().Table("xt_quality_control_standard as x").Where("x.status =1")
75
+	if orgid > 0 {
76
+		db = db.Where("x.user_org_id = ?", orgid)
77
+	}
78
+	table := XTReadDB().Table("xt_inspection_reference as s")
79
+	fmt.Println(table)
80
+	offset := (page - 1) * limit
81
+	err = db.Order("x.sort asc,x.created_time desc").Group("x.id").Select("x.id,x.inspection_major,x.inspection_minor,x.min_range,x.large_range,x.sort,x.user_org_id,x.range_value,x.range_type,s.unit,s.project_name,s.item_name").Count(&total).
82
+		Joins("left join xt_inspection_reference as s on s.item_id = x.inspection_minor").Offset(offset).Limit(limit).Scan(&standard).Error
83
+	return standard, total, err
84
+}
85
+
67 86
 func GetConfigurationDetail(id int64) (models.XtQualityControlStandard, error) {
68 87
 	standard := models.XtQualityControlStandard{}
69 88
 	err := XTReadDB().Model(&standard).Where("id=? and status = 1", id).Find(&standard).Error
70 89
 	return standard, err
71 90
 }
72 91
 
92
+func GetIdByItemId(itemid int64, orgid int64) (models.XtInspectionReference, error) {
93
+	reference := models.XtInspectionReference{}
94
+	err := XTReadDB().Model(&reference).Where("item_id = ? and org_id = ?", itemid, orgid).Find(&reference).Error
95
+	return reference, err
96
+}
97
+
73 98
 func GetAllInspectionMinor(orgid int64) (standard []*models.XtInspectionReference, err error) {
74 99
 
75 100
 	err = XTReadDB().Model(&standard).Where("org_id = ? and status = 1", orgid).Find(&standard).Error
@@ -2385,6 +2410,58 @@ func GetLastPatientsControl(orgid int64, lapstor int64, startime int64, endtime
2385 2410
 	return inspection, err
2386 2411
 }
2387 2412
 
2413
+func GetTotalPatientsControl(orgid int64, startime int64, endtime int64) (inspection []*models.PatientInspectionCount, total int64, err error) {
2414
+	db := readDb.Table("xt_inspection as x").Where("x.status = 1")
2415
+	table := readDb.Table("xt_quality_control_standard as s")
2416
+	fmt.Println(table)
2417
+	if orgid > 0 {
2418
+		db = db.Where("x.org_id = ? and x.inspect_value <> ''", orgid)
2419
+	}
2420
+	if startime > 0 {
2421
+		db = db.Where("x.inspect_date >=?", startime)
2422
+	}
2423
+	if endtime > 0 {
2424
+		db = db.Where("x.inspect_date <=?", endtime)
2425
+	}
2426
+	err = db.Select("x.id").Joins("RIGHT JOIN xt_quality_control_standard as s on x.project_id = s.inspection_major and x.item_id = s.inspection_minor and x.org_id = s.user_org_id ").Where("s.status = 1").Count(&total).Scan(&inspection).Error
2427
+	return inspection, total, err
2428
+}
2429
+func GetStandControl(orgid int64, startime int64, endtime int64) (inspection []*models.PatientInspectionCount, total int64, err error) {
2430
+	db := readDb.Table("xt_inspection as x").Where("x.status = 1")
2431
+	table := readDb.Table("xt_quality_control_standard as s")
2432
+	fmt.Println(table)
2433
+	if orgid > 0 {
2434
+		db = db.Where("x.org_id = ? and x.inspect_value+0 <> 0 and x.inspect_type = 1 ", orgid)
2435
+	}
2436
+	if startime > 0 {
2437
+		db = db.Where("x.inspect_date >=?", startime)
2438
+	}
2439
+	if endtime > 0 {
2440
+		db = db.Where("x.inspect_date <=?", endtime)
2441
+	}
2442
+	db = db.Where("s.status = 1")
2443
+	err = db.Select("x.id").Joins("RIGHT JOIN xt_quality_control_standard as s on x.project_id = s.inspection_major and x.item_id = s.inspection_minor and x.org_id = s.user_org_id ").Where("x.inspect_value+0 >= s.min_range + 0 and x.inspect_value+0 <= s.large_range + 0 ").Count(&total).Scan(&inspection).Error
2444
+	return inspection, total, err
2445
+}
2446
+
2447
+func GetStandControlOne(orgid int64, startime int64, endtime int64) (inspection []*models.PatientInspectionCount, total int64, err error) {
2448
+	db := readDb.Table("xt_inspection as x").Where("x.status = 1")
2449
+	table := readDb.Table("xt_quality_control_standard as s")
2450
+	fmt.Println(table)
2451
+	if orgid > 0 {
2452
+		db = db.Where("x.org_id = ? and x.inspect_value <> '' and x.inspect_type = 2 ", orgid)
2453
+	}
2454
+	if startime > 0 {
2455
+		db = db.Where("x.inspect_date >=?", startime)
2456
+	}
2457
+	if endtime > 0 {
2458
+		db = db.Where("x.inspect_date <=?", endtime)
2459
+	}
2460
+	db = db.Where("s.status = 1")
2461
+	err = db.Select("x.id").Joins("RIGHT JOIN xt_quality_control_standard as s on x.project_id = s.inspection_major and x.item_id = s.inspection_minor and x.org_id = s.user_org_id ").Where("x.inspect_value = s.range_value").Count(&total).Scan(&inspection).Error
2462
+	return inspection, total, err
2463
+}
2464
+
2388 2465
 func GetInfectiousPatientsControl(orgid int64, lapstor int64, startime int64, endtime int64) (inspection []*models.PatientInspectionCount, err error) {
2389 2466
 	db := readDb.Table("xt_inspection as x").Where("x.status =1")
2390 2467
 	table := readDb.Table("xt_patients as s")