소스 검색

默认数据处理

XMLWAN 4 년 전
부모
커밋
303fd8bc33

+ 14 - 0
controllers/gobal_config_api_controller.go 파일 보기

@@ -1025,6 +1025,20 @@ func (this *GobalConfigApiController) ChangeOrg() {
1025 1025
 			}
1026 1026
 		}
1027 1027
 
1028
+		QualityeList, err := service.FindQualityByOrgId(tempOrg.Id)
1029
+		if len(QualityeList) == 0 {
1030
+			err = service.BatchInsertQualityControl(tempOrg.Id)
1031
+		} else {
1032
+			utils.ErrorLog("字段批量插入失败:%v", err)
1033
+		}
1034
+
1035
+		InspectionList, err := service.FindeInspectionByOrgId(tempOrg.Id)
1036
+		if len(InspectionList) == 0 {
1037
+			err = service.BatchInspectionConfiguration(tempOrg.Id)
1038
+		} else {
1039
+			utils.ErrorLog("字段批量插入失败:%v", err)
1040
+		}
1041
+
1028 1042
 		var didRegistedForSCRM bool = false
1029 1043
 		var didRegistedForCDM bool = false
1030 1044
 		var didRegistedForMall bool = false

+ 16 - 0
controllers/mobile_api_controllers/login_api_controller.go 파일 보기

@@ -167,6 +167,22 @@ func (this *LoginAPIController) LoginByPwd() {
167 167
 			}
168 168
 		}
169 169
 
170
+		//批量插入质控达标统计配置
171
+		QualityeList, err := service.FindQualityByOrgId(org.Id)
172
+		if len(QualityeList) == 0 {
173
+			err = service.BatchInsertQualityControl(org.Id)
174
+		} else {
175
+			utils.ErrorLog("字段批量插入失败:%v", err)
176
+		}
177
+
178
+		//批量插入检验检查统计配置
179
+		InspectionList, err := service.FindeInspectionByOrgId(org.Id)
180
+		if len(InspectionList) == 0 {
181
+			err = service.BatchInspectionConfiguration(org.Id)
182
+		} else {
183
+			utils.ErrorLog("字段批量插入失败:%v", err)
184
+		}
185
+
170 186
 		this.ServeSuccessJSON(map[string]interface{}{
171 187
 			"admin": adminUser,
172 188
 			"user":  appRole,

+ 28 - 1
controllers/new_mobile_api_controllers/common_api_controller.go 파일 보기

@@ -530,7 +530,7 @@ func (this *CommonApiController) GetDialysislist() {
530 530
 	orgId := adminUser.CurrentOrgId
531 531
 
532 532
 	dialysislist, total, err := service.GetDialysisList(statime, entime, page, limit, orgId)
533
-	fmt.Println("err----------------", err)
533
+	fmt.Println("err", err)
534 534
 	if err != nil {
535 535
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
536 536
 		return
@@ -540,3 +540,30 @@ func (this *CommonApiController) GetDialysislist() {
540 540
 		"total":        total,
541 541
 	})
542 542
 }
543
+
544
+func (this *CommonApiController) GetLastSort() {
545
+
546
+	adminUser := this.GetAdminUserInfo()
547
+	orgid := adminUser.CurrentOrgId
548
+	standard, err := service.GetLastSort(orgid)
549
+	if err != nil {
550
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
551
+		return
552
+	}
553
+	this.ServeSuccessJSON(map[string]interface{}{
554
+		"standard": standard,
555
+	})
556
+}
557
+
558
+func (this *CommonApiController) GetLastCheckList() {
559
+	adminUser := this.GetAdminUserInfo()
560
+	orgid := adminUser.CurrentOrgId
561
+	checkList, err := service.GetLastCheckList(orgid)
562
+	if err != nil {
563
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
564
+		return
565
+	}
566
+	this.ServeSuccessJSON(map[string]interface{}{
567
+		"checkList": checkList,
568
+	})
569
+}

+ 2 - 0
controllers/new_mobile_api_controllers/common_api_router.go 파일 보기

@@ -29,4 +29,6 @@ func CommonApiControllersRegisterRouters() {
29 29
 	beego.Router("/com/api/gettotaldialysiscount", &CommonApiController{}, "Get:GetTotalDialysisCount")
30 30
 	beego.Router("/com/api/getcurentorgpatients", &CommonApiController{}, "Get:GetCurentOrgPatients")
31 31
 	beego.Router("/com/api/getdialysislist", &CommonApiController{}, "Get:GetDialysislist")
32
+	beego.Router("/com/api/getlastsort", &CommonApiController{}, "Get:GetLastSort")
33
+	beego.Router("/com/api/getlastchecklist", &CommonApiController{}, "Get:GetLastCheckList")
32 34
 }

+ 16 - 0
controllers/new_mobile_api_controllers/forget_password_controller.go 파일 보기

@@ -179,6 +179,22 @@ func (this *ForgetPwdController) ModifyPassword() {
179 179
 				}
180 180
 			}
181 181
 
182
+			if org.Id > 0 {
183
+				QualityeList, err := service.FindQualityByOrgId(org.Id)
184
+				if len(QualityeList) == 0 {
185
+					err = service.BatchInsertQualityControl(org.Id)
186
+				} else {
187
+					utils.ErrorLog("字段批量插入失败:%v", err)
188
+				}
189
+
190
+				InspectionList, err := service.FindeInspectionByOrgId(org.Id)
191
+				if len(InspectionList) == 0 {
192
+					err = service.BatchInspectionConfiguration(org.Id)
193
+				} else {
194
+					utils.ErrorLog("字段批量插入失败:%v", err)
195
+				}
196
+			}
197
+
182 198
 			this.ServeSuccessJSON(map[string]interface{}{
183 199
 				"admin": adminUser,
184 200
 				"user":  appRole,

+ 33 - 0
controllers/new_mobile_api_controllers/home_api_controller.go 파일 보기

@@ -232,6 +232,23 @@ func (this *HomeController) ChangeOrg() {
232 232
 			} else {
233 233
 				FiledList = make([]*models.FiledConfig, 0)
234 234
 			}
235
+
236
+			if org.Id > 0 {
237
+				QualityeList, err := service.FindQualityByOrgId(org.Id)
238
+				if len(QualityeList) == 0 {
239
+					err = service.BatchInsertQualityControl(org.Id)
240
+				} else {
241
+					utils.ErrorLog("字段批量插入失败:%v", err)
242
+				}
243
+
244
+				InspectionList, err := service.FindeInspectionByOrgId(org.Id)
245
+				if len(InspectionList) == 0 {
246
+					err = service.BatchInspectionConfiguration(org.Id)
247
+				} else {
248
+					utils.ErrorLog("字段批量插入失败:%v", err)
249
+				}
250
+			}
251
+
235 252
 		}
236 253
 		this.ServeSuccessJSON(map[string]interface{}{
237 254
 			"admin": adminUser,
@@ -516,6 +533,22 @@ func (this *HomeController) CreateOrg() {
516 533
 					}
517 534
 				}
518 535
 
536
+				if org.Id > 0 {
537
+					QualityeList, err := service.FindQualityByOrgId(org.Id)
538
+					if len(QualityeList) == 0 {
539
+						err = service.BatchInsertQualityControl(org.Id)
540
+					} else {
541
+						utils.ErrorLog("字段批量插入失败:%v", err)
542
+					}
543
+
544
+					InspectionList, err := service.FindeInspectionByOrgId(org.Id)
545
+					if len(InspectionList) == 0 {
546
+						err = service.BatchInspectionConfiguration(org.Id)
547
+					} else {
548
+						utils.ErrorLog("字段批量插入失败:%v", err)
549
+					}
550
+				}
551
+
519 552
 				this.ServeSuccessJSON(map[string]interface{}{
520 553
 					"admin": adminUser,
521 554
 					"user":  appRole,

+ 16 - 0
controllers/new_mobile_api_controllers/mobile_regist_controller.go 파일 보기

@@ -382,6 +382,22 @@ func (this *MobileRegistController) CreateOrg() {
382 382
 				}
383 383
 			}
384 384
 
385
+			if org.Id > 0 {
386
+				QualityeList, err := service.FindQualityByOrgId(org.Id)
387
+				if len(QualityeList) == 0 {
388
+					err = service.BatchInsertQualityControl(org.Id)
389
+				} else {
390
+					utils.ErrorLog("字段批量插入失败:%v", err)
391
+				}
392
+
393
+				InspectionList, err := service.FindeInspectionByOrgId(org.Id)
394
+				if len(InspectionList) == 0 {
395
+					err = service.BatchInspectionConfiguration(org.Id)
396
+				} else {
397
+					utils.ErrorLog("字段批量插入失败:%v", err)
398
+				}
399
+			}
400
+
385 401
 			this.ServeSuccessJSON(map[string]interface{}{
386 402
 				"admin": adminUser,
387 403
 				"user":  appRole,

+ 16 - 0
controllers/new_mobile_api_controllers/new_login_api_controller.go 파일 보기

@@ -295,6 +295,22 @@ func (this *NewLoginApiController) LoginByCs() {
295 295
 				}
296 296
 			}
297 297
 
298
+			if org.Id > 0 {
299
+				QualityeList, err := service.FindQualityByOrgId(org.Id)
300
+				if len(QualityeList) == 0 {
301
+					err = service.BatchInsertQualityControl(org.Id)
302
+				} else {
303
+					utils.ErrorLog("字段批量插入失败0:%v", err)
304
+				}
305
+
306
+				InspectionList, err := service.FindeInspectionByOrgId(org.Id)
307
+				if len(InspectionList) == 0 {
308
+					err = service.BatchInspectionConfiguration(org.Id)
309
+				} else {
310
+					utils.ErrorLog("字段批量插入失败0:%v", err)
311
+				}
312
+			}
313
+
298 314
 			this.ServeSuccessJSON(map[string]interface{}{
299 315
 				"admin": adminUser,
300 316
 				"user": map[string]interface{}{

+ 14 - 0
controllers/verify_login_controller.go 파일 보기

@@ -166,6 +166,20 @@ func (this *VerifyUserLoginAPIController) VerifyToken() {
166 166
 				}
167 167
 			}
168 168
 
169
+			QualityeList, err := service.FindQualityByOrgId(curOrg.Id)
170
+			if len(QualityeList) == 0 {
171
+				err = service.BatchInsertQualityControl(curOrg.Id)
172
+			} else {
173
+				utils.ErrorLog("字段批量插入失败:%v", err)
174
+			}
175
+
176
+			InspectionList, err := service.FindeInspectionByOrgId(curOrg.Id)
177
+			if len(InspectionList) == 0 {
178
+				err = service.BatchInspectionConfiguration(curOrg.Id)
179
+			} else {
180
+				utils.ErrorLog("字段批量插入失败:%v", err)
181
+			}
182
+
169 183
 			var pruviews []*models.Purview
170 184
 			var curAppUrlfors []string
171 185
 			if len(curAppUrlfors) == 0 {

+ 12 - 0
service/common_service.go 파일 보기

@@ -338,3 +338,15 @@ func GetDialysisList(startime int64, endtime int64, page int64, limit int64, org
338 338
 	err = db.Group("p.patient_id,p.mode_id").Select("p.mode_id,p.patient_id,s.name,s.id_card_no,s.dialysis_no").Joins("left join xt_patients as s on s.id = p.patient_id").Count(&total).Offset(offset).Limit(limit).Scan(&prescription).Error
339 339
 	return prescription, total, err
340 340
 }
341
+
342
+func GetLastSort(orgid int64) (models.XtQualityControlStandard, error) {
343
+	standard := models.XtQualityControlStandard{}
344
+	err := XTReadDB().Model(&standard).Where("user_org_id = ? and status =1", orgid).Last(&standard).Error
345
+	return standard, err
346
+}
347
+
348
+func GetLastCheckList(orgid int64) (models.XtCheckConfiguration, error) {
349
+	configuration := models.XtCheckConfiguration{}
350
+	err := XTReadDB().Model(&configuration).Where("user_org_id = ? and status =1", orgid).Last(&configuration).Error
351
+	return configuration, err
352
+}

+ 24 - 0
service/data.go 파일 보기

@@ -171,11 +171,35 @@ func FindFiledByOrgId(org_id int64) (filedConfig []*models.FiledConfig, err erro
171 171
 	return
172 172
 }
173 173
 
174
+func FindQualityByOrgId(orgid int64) (xtquality []*models.XtQualityControlStandard, err error) {
175
+
176
+	err = readDb.Model(&models.XtQualityControlStandard{}).Where("user_org_id =? and status =1", orgid).Find(&xtquality).Error
177
+	return
178
+}
179
+
180
+func FindeInspectionByOrgId(orgid int64) (xtquality []*models.XtCheckConfiguration, err error) {
181
+
182
+	err = readDb.Model(&models.XtQualityControlStandard{}).Where("user_org_id = ? and status =1", orgid).Find(&xtquality).Error
183
+	return
184
+}
185
+
174 186
 func BatchInsertFiledConfig(org_id int64) (err error) {
175 187
 	err = readDb.Exec("INSERT  INTO sgj_xt.xt_filed_config  ( org_id,  module,  filed_name,  filed_name_cn,  is_show ) SELECT ?,  module,  filed_name,  filed_name_cn,  is_show FROM sgj_xt.xt_filed_config  WHERE org_id = 0 AND is_show = 1", org_id).Error
176 188
 	return
177 189
 }
178 190
 
191
+func BatchInsertQualityControl(org_id int64) (err error) {
192
+
193
+	err = readDb.Exec("INSERT INTO xt_quality_control_standard(user_org_id,inspection_major,inspection_minor,min_range,large_range,sort,created_time,status) SELECT ?,inspection_major,inspection_minor,min_range,large_range,sort,created_time,status FROM xt_quality_control_standard where user_org_id = 0", org_id).Error
194
+	return
195
+}
196
+
197
+func BatchInspectionConfiguration(orgid int64) (err error) {
198
+
199
+	err = readDb.Exec("INSERT INTO xt_check_configuration(user_org_id,inspection_major,inspection_frequency,sort,created_time,status) SELECT ?,inspection_major,inspection_frequency,sort,created_time,status FROM xt_check_configuration where user_org_id = 0", orgid).Error
200
+	return
201
+}
202
+
179 203
 func ShowFiledConfig(org_id int64, isShow int, id int64) (err error) {
180 204
 	err = readDb.Model(&models.FiledConfig{}).Where("org_id = ? AND id = ?", org_id, id).Updates(map[string]interface{}{"ctime": time.Now().Unix(), "mtime": time.Now().Unix(), "is_show": isShow}).Error
181 205
 	return