28169 4 miesięcy temu
rodzic
commit
9cdd7fa8a1

+ 2 - 2
controllers/dialysis_api_controller.go Wyświetl plik

4863
 	}
4863
 	}
4864
 	if adminUserInfo.CurrentOrgId == 10101 || adminUserInfo.CurrentOrgId == 10445 || adminUserInfo.CurrentOrgId == 10345 {
4864
 	if adminUserInfo.CurrentOrgId == 10101 || adminUserInfo.CurrentOrgId == 10445 || adminUserInfo.CurrentOrgId == 10345 {
4865
 
4865
 
4866
-		if xttime <= 1703952000 {
4866
+		if xttime <= 1735574400 {
4867
 			dialysis_count, _ := service.GetDialysisOrderCountOne(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
4867
 			dialysis_count, _ := service.GetDialysisOrderCountOne(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
4868
 			patientInfo.TotalDialysis = dialysis_count
4868
 			patientInfo.TotalDialysis = dialysis_count
4869
 		}
4869
 		}
4870
 
4870
 
4871
-		if xttime >= 1704038400 {
4871
+		if xttime >= 1735660800 {
4872
 			dialysis_count, _ := service.GetDialysisOrderCountTwo(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
4872
 			dialysis_count, _ := service.GetDialysisOrderCountTwo(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
4873
 			patientInfo.TotalDialysis = dialysis_count
4873
 			patientInfo.TotalDialysis = dialysis_count
4874
 		}
4874
 		}

+ 62 - 11
controllers/drug_stock_api_contorller.go Wyświetl plik

3583
 				"max_unit":               drup.MaxUnit,
3583
 				"max_unit":               drup.MaxUnit,
3584
 				"msg":                    2,
3584
 				"msg":                    2,
3585
 			})
3585
 			})
3586
+			tx.Rollback()
3586
 			return
3587
 			return
3587
 		}
3588
 		}
3588
 	}
3589
 	}
3609
 
3610
 
3610
 	}
3611
 	}
3611
 	warehousingOutInfoListThree, _ := service.GetNewDrugWarehouseOutListById(warehouse_out_id, orgId, tx)
3612
 	warehousingOutInfoListThree, _ := service.GetNewDrugWarehouseOutListById(warehouse_out_id, orgId, tx)
3613
+
3614
+	var is_success = 2
3612
 	for _, it := range warehousingOutInfoListThree {
3615
 	for _, it := range warehousingOutInfoListThree {
3616
+
3617
+		var his_count = it.Count
3618
+		var his_count_unit = it.CountUnit
3613
 		medical, _ := service.GetNewBaseDrugMedical(it.DrugId, tx)
3619
 		medical, _ := service.GetNewBaseDrugMedical(it.DrugId, tx)
3614
 		drup, _ := service.FindNewBaseDrugLibRecord(it.OrgId, it.DrugId, tx)
3620
 		drup, _ := service.FindNewBaseDrugLibRecord(it.OrgId, it.DrugId, tx)
3615
 		//出库逻辑
3621
 		//出库逻辑
3637
 		}
3643
 		}
3638
 		//更新基础库库存
3644
 		//更新基础库库存
3639
 		service.UpdateNewBaseDrugSumTwo(it.DrugId, sum_count_one, it.OrgId, tx)
3645
 		service.UpdateNewBaseDrugSumTwo(it.DrugId, sum_count_one, it.OrgId, tx)
3646
+
3647
+		if it.OrgId == 10164 || it.OrgId == 10721 {
3648
+			var now_count int64
3649
+
3650
+			if his_count_unit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
3651
+				now_count = his_count * medical.MinNumber
3652
+			}
3653
+			if his_count_unit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
3654
+				now_count = his_count
3655
+			}
3656
+			if his_count_unit == medical.MaxUnit && medical.MaxUnit == medical.MinUnit {
3657
+				now_count = his_count
3658
+			}
3659
+
3660
+			var flow_count int64
3661
+
3662
+			//查询该药品的出库数量
3663
+			drugflowlist, _ := service.GetDrugOutFlowByWarehouseOut(it.DrugId, it.ID, it.OrgId, tx)
3664
+			if len(drugflowlist) > 0 {
3665
+				for _, items := range drugflowlist {
3666
+
3667
+					if items.MaxUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
3668
+						flow_count = items.Count * medical.MinNumber
3669
+					}
3670
+					if items.MaxUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
3671
+						flow_count = items.Count
3672
+					}
3673
+					if items.MaxUnit == medical.MaxUnit && medical.MaxUnit == medical.MinUnit {
3674
+						flow_count = items.Count
3675
+					}
3676
+				}
3677
+			}
3678
+
3679
+			if now_count != flow_count {
3680
+				is_success = 1
3681
+				tx.Rollback()
3682
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeFlow)
3683
+				return
3684
+			}
3685
+		}
3686
+
3640
 	}
3687
 	}
3641
 
3688
 
3642
 	out := models.DrugWarehouseOut{
3689
 	out := models.DrugWarehouseOut{
3645
 	//更新审核状态
3692
 	//更新审核状态
3646
 	service.UpdateNewCheckDrugOut(out, warehouse_out_id, tx)
3693
 	service.UpdateNewCheckDrugOut(out, warehouse_out_id, tx)
3647
 
3694
 
3648
-	tx.Commit()
3695
+	//查询
3696
+	if is_success != 1 {
3697
+		tx.Commit()
3698
+		c.ServeSuccessJSON(map[string]interface{}{
3699
+			"warehousingOutInfoList": warehousingOutInfoList,
3700
+			"drug_name":              "",
3701
+			"dose":                   "",
3702
+			"dose_unit":              "",
3703
+			"min_number":             "",
3704
+			"min_unit":               "",
3705
+			"max_unit":               "",
3706
+			"msg":                    1,
3707
+		})
3708
+		return
3709
+	}
3649
 
3710
 
3650
-	c.ServeSuccessJSON(map[string]interface{}{
3651
-		"warehousingOutInfoList": warehousingOutInfoList,
3652
-		"drug_name":              "",
3653
-		"dose":                   "",
3654
-		"dose_unit":              "",
3655
-		"min_number":             "",
3656
-		"min_unit":               "",
3657
-		"max_unit":               "",
3658
-		"msg":                    1,
3659
-	})
3660
 }
3711
 }
3661
 
3712
 
3662
 func (c *StockDrugApiController) ToReturnCheck() {
3713
 func (c *StockDrugApiController) ToReturnCheck() {

+ 12 - 2
controllers/mobile_api_controllers/dialysis_api_controller.go Wyświetl plik

3900
 		if prescription.TargetUltrafiltration > 0 && prescription.DialysisDurationHour > 0 {
3900
 		if prescription.TargetUltrafiltration > 0 && prescription.DialysisDurationHour > 0 {
3901
 
3901
 
3902
 			totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
3902
 			totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
3903
-			if (template.TemplateId == 6 || template.TemplateId == 32 || template.TemplateId == 65 || adminUserInfo.Org.Id == 10375 || adminUserInfo.Org.Id == 10599 || adminUserInfo.Org.Id == 10742 || adminUserInfo.Org.Id == 10740 || adminUserInfo.Org.Id == 10745) && adminUserInfo.Org.Id != 9671 { //adminUserInfo.Org.Id == 9538
3903
+			if (template.TemplateId == 6 || template.TemplateId == 32 || template.TemplateId == 65 || adminUserInfo.Org.Id == 10375 || adminUserInfo.Org.Id == 10599) && adminUserInfo.Org.Id != 9671 { //adminUserInfo.Org.Id == 9538
3904
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
3904
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
3905
 			}
3905
 			}
3906
 
3906
 
3907
+			if adminUserInfo.Org.Id == 10742 || adminUserInfo.Org.Id == 10740 || adminUserInfo.Org.Id == 10745 {
3908
+				ultrafiltration_rate = math.Floor(prescription.PrescriptionWater / float64(totalMin) * 60 * 1000)
3909
+			}
3910
+
3907
 			if adminUserInfo.Org.Id == 10597 || adminUserInfo.Org.Id == 10679 { //adminUserInfo.Org.Id == 9538
3911
 			if adminUserInfo.Org.Id == 10597 || adminUserInfo.Org.Id == 10679 { //adminUserInfo.Org.Id == 9538
3908
 				ultrafiltration_rate = math.Floor(prescription.PrescriptionWater / float64(totalMin) * 60 * 1000)
3912
 				ultrafiltration_rate = math.Floor(prescription.PrescriptionWater / float64(totalMin) * 60 * 1000)
3909
 			}
3913
 			}
5182
 		if prescription.TargetUltrafiltration > 0 && prescription.DialysisDurationHour > 0 {
5186
 		if prescription.TargetUltrafiltration > 0 && prescription.DialysisDurationHour > 0 {
5183
 
5187
 
5184
 			totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
5188
 			totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
5185
-			if (template.TemplateId == 6 || template.TemplateId == 65 || adminInfo.Org.Id == 10375 || adminInfo.Org.Id == 10599 || adminInfo.Org.Id == 10742 || adminInfo.Org.Id == 10740 || adminInfo.Org.Id == 10745) && adminInfo.Org.Id != 9538 {
5189
+			if (template.TemplateId == 6 || template.TemplateId == 65 || adminInfo.Org.Id == 10375 || adminInfo.Org.Id == 10599) && adminInfo.Org.Id != 9538 {
5186
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
5190
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
5187
 				record.UltrafiltrationRate = ultrafiltration_rate
5191
 				record.UltrafiltrationRate = ultrafiltration_rate
5188
 
5192
 
5189
 			}
5193
 			}
5190
 
5194
 
5195
+			//重庆塘坝卫生院
5196
+			if adminInfo.Org.Id == 10742 || adminInfo.Org.Id == 10740 || adminInfo.Org.Id == 10745 {
5197
+				ultrafiltration_rate = math.Floor(prescription.PrescriptionWater / float64(totalMin) * 60 * 1000)
5198
+				record.UltrafiltrationRate = ultrafiltration_rate
5199
+			}
5200
+
5191
 			if adminInfo.Org.Id == 10597 || adminInfo.Org.Id == 10679 {
5201
 			if adminInfo.Org.Id == 10597 || adminInfo.Org.Id == 10679 {
5192
 				ultrafiltration_rate = math.Floor(prescription.PrescriptionWater / float64(totalMin) * 60 * 1000)
5202
 				ultrafiltration_rate = math.Floor(prescription.PrescriptionWater / float64(totalMin) * 60 * 1000)
5193
 				record.UltrafiltrationRate = ultrafiltration_rate
5203
 				record.UltrafiltrationRate = ultrafiltration_rate

+ 27 - 0
controllers/pharmacy_controller.go Wyświetl plik

50
 
50
 
51
 	beego.Router("/api/pharmacy/changeZeroFlag", &PharmacyController{}, "Get:ChangeZeroFlag")
51
 	beego.Router("/api/pharmacy/changeZeroFlag", &PharmacyController{}, "Get:ChangeZeroFlag")
52
 
52
 
53
+	beego.Router("/api/pharmacy/getdrugtocalcount", &PharmacyController{}, "Get:GetDrugTocalCount")
54
+
53
 }
55
 }
54
 
56
 
55
 // 测试
57
 // 测试
1446
 	})
1448
 	})
1447
 
1449
 
1448
 }
1450
 }
1451
+
1452
+func (this *PharmacyController) GetDrugTocalCount() {
1453
+
1454
+	timeLayout := "2006-01-02"
1455
+	loc, _ := time.LoadLocation("Local")
1456
+	drug_id, _ := this.GetInt64("drug_id")
1457
+	start_time := this.GetString("start_time")
1458
+	var startTime int64
1459
+	if len(start_time) > 0 {
1460
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
1461
+		if err != nil {
1462
+			fmt.Println(err)
1463
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1464
+			return
1465
+		}
1466
+		startTime = theTime.Unix()
1467
+	}
1468
+	orgId := this.GetAdminUserInfo().CurrentOrgId
1469
+
1470
+	adviceList, _ := service.GetDrugTocalCountByDrugId(drug_id, startTime, orgId)
1471
+
1472
+	this.ServeSuccessJSON(map[string]interface{}{
1473
+		"adviceList": adviceList,
1474
+	})
1475
+}

+ 2 - 2
controllers/print_data_api_controller.go Wyświetl plik

107
 
107
 
108
 			if this.GetAdminUserInfo().CurrentOrgId == 10101 || this.GetAdminUserInfo().CurrentOrgId == 9671 || this.GetAdminUserInfo().CurrentOrgId == 10345 || this.GetAdminUserInfo().CurrentOrgId == 9970 || this.GetAdminUserInfo().CurrentOrgId == 10495 || this.GetAdminUserInfo().CurrentOrgId == 10013 || this.GetAdminUserInfo().CurrentOrgId == 10014 {
108
 			if this.GetAdminUserInfo().CurrentOrgId == 10101 || this.GetAdminUserInfo().CurrentOrgId == 9671 || this.GetAdminUserInfo().CurrentOrgId == 10345 || this.GetAdminUserInfo().CurrentOrgId == 9970 || this.GetAdminUserInfo().CurrentOrgId == 10495 || this.GetAdminUserInfo().CurrentOrgId == 10013 || this.GetAdminUserInfo().CurrentOrgId == 10014 {
109
 
109
 
110
-				if item.ScheduleDate <= 1703952000 {
110
+				if item.ScheduleDate <= 1735574400 {
111
 					listOne, _ := service.GetDialysisOrderCountEight(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
111
 					listOne, _ := service.GetDialysisOrderCountEight(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
112
 
112
 
113
 					item.Patient.TotalDialysis = listOne.Count
113
 					item.Patient.TotalDialysis = listOne.Count
114
 					item.Count = listOne.Count
114
 					item.Count = listOne.Count
115
 				}
115
 				}
116
 
116
 
117
-				if item.ScheduleDate >= 1704038400 {
117
+				if item.ScheduleDate >= 1735660800 {
118
 
118
 
119
 					listOne, _ := service.GetDialysisOrderCountNight(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
119
 					listOne, _ := service.GetDialysisOrderCountNight(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
120
 
120
 

+ 27 - 2
controllers/stock_in_api_controller.go Wyświetl plik

7304
 
7304
 
7305
 	////出库逻辑
7305
 	////出库逻辑
7306
 	for _, item := range warehousingOutInfo {
7306
 	for _, item := range warehousingOutInfo {
7307
+
7307
 		// 查询该耗材是否有库存
7308
 		// 查询该耗材是否有库存
7308
 		warehouseOne, _ := service.FindNewWarehousingInfoTen(item.GoodId, item.StorehouseId, tx)
7309
 		warehouseOne, _ := service.FindNewWarehousingInfoTen(item.GoodId, item.StorehouseId, tx)
7309
 
7310
 
7323
 		}
7324
 		}
7324
 
7325
 
7325
 	}
7326
 	}
7327
+	var is_scucess = 2
7328
+
7326
 	for _, item := range warehousingOutInfo {
7329
 	for _, item := range warehousingOutInfo {
7327
 
7330
 
7328
 		creater := this.GetAdminUserInfo().AdminUser.Id
7331
 		creater := this.GetAdminUserInfo().AdminUser.Id
7329
 
7332
 
7333
+		var now_count = item.Count
7334
+
7330
 		//出库
7335
 		//出库
7331
 		err := service.ConsumablesNewDeliveryThirty(orgId, item.SysRecordTime, item, &warehouseOut, item.Count, creater, tx)
7336
 		err := service.ConsumablesNewDeliveryThirty(orgId, item.SysRecordTime, item, &warehouseOut, item.Count, creater, tx)
7332
 
7337
 
7353
 		//基础库扣减库存
7358
 		//基础库扣减库存
7354
 		service.UpdateNewGoodInfoReduceSumCount(item.GoodId, total_count, orgId, tx)
7359
 		service.UpdateNewGoodInfoReduceSumCount(item.GoodId, total_count, orgId, tx)
7355
 
7360
 
7361
+		var flow_count int64
7362
+		flowList, _ := service.GetGoodFlowByWarehouseOutId(item.GoodId, item.OrgId, item.ID, tx)
7363
+		if len(flowList) > 0 {
7364
+			for _, items := range flowList {
7365
+				flow_count += items.Count
7366
+			}
7367
+		}
7368
+
7369
+		if now_count != flow_count {
7370
+			is_scucess = 1
7371
+			tx.Rollback()
7372
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeFlow)
7373
+			return
7374
+
7375
+		}
7376
+
7356
 	}
7377
 	}
7357
 
7378
 
7358
 	//审核单据
7379
 	//审核单据
7359
 	err := service.UpdatedNewWarehouseOut(id, tx)
7380
 	err := service.UpdatedNewWarehouseOut(id, tx)
7360
 
7381
 
7361
-	tx.Commit()
7382
+	if is_scucess != 1 {
7383
+		tx.Commit()
7384
+	}
7385
+
7362
 	if err == nil {
7386
 	if err == nil {
7363
 		this.ServeSuccessJSON(map[string]interface{}{
7387
 		this.ServeSuccessJSON(map[string]interface{}{
7364
 			"msg":                "2",
7388
 			"msg":                "2",
7366
 			"specification_name": "",
7390
 			"specification_name": "",
7367
 			"storehose_name":     "",
7391
 			"storehose_name":     "",
7368
 		})
7392
 		})
7393
+		return
7369
 	}
7394
 	}
7370
 
7395
 
7371
 }
7396
 }
7492
 				Dealer:                  item.Dealer,
7517
 				Dealer:                  item.Dealer,
7493
 				Creator:                 Creator,
7518
 				Creator:                 Creator,
7494
 				UpdateCreator:           0,
7519
 				UpdateCreator:           0,
7495
-				Status:                  1,
7496
 				Ctime:                   item.Ctime,
7520
 				Ctime:                   item.Ctime,
7521
+				Status:                  1,
7497
 				Mtime:                   0,
7522
 				Mtime:                   0,
7498
 				Price:                   item.PackingPrice,
7523
 				Price:                   item.PackingPrice,
7499
 				WarehousingDetailId:     item.ID,
7524
 				WarehousingDetailId:     item.ID,

+ 3 - 0
enums/error_code.go Wyświetl plik

287
 	ErrorTimeCodeParamWrong = 600000012
287
 	ErrorTimeCodeParamWrong = 600000012
288
 
288
 
289
 	ErrorCodeAuthWrong = 600000013
289
 	ErrorCodeAuthWrong = 600000013
290
+
291
+	ErrorCodeFlow = 600000014
290
 )
292
 )
291
 
293
 
292
 var ErrCodeMsgs = map[int]string{
294
 var ErrCodeMsgs = map[int]string{
552
 
554
 
553
 	ErrorTimeCodeParamWrong: "时间跨度不能超过一个月",
555
 	ErrorTimeCodeParamWrong: "时间跨度不能超过一个月",
554
 	ErrorCodeAuthWrong:      "尚未实名认证,请先认证",
556
 	ErrorCodeAuthWrong:      "尚未实名认证,请先认证",
557
+	ErrorCodeFlow:           "网络错误,数据异常,审核失败",
555
 }
558
 }
556
 
559
 
557
 type SGJError struct {
560
 type SGJError struct {

+ 1 - 0
models/schedule_models.go Wyświetl plik

477
 	SchedualPatient            *NewMSchedualPatientVMList `gorm:"ForeignKey:PatientId" json:"patient"`
477
 	SchedualPatient            *NewMSchedualPatientVMList `gorm:"ForeignKey:PatientId" json:"patient"`
478
 	HisPrescriptionTemplateSix HisPrescriptionTemplateSix `gorm:"ForeignKey:PatientId,Mode;AssociationForeignKey:PatientId,ModeId" json:"his_prescription_template"`
478
 	HisPrescriptionTemplateSix HisPrescriptionTemplateSix `gorm:"ForeignKey:PatientId,Mode;AssociationForeignKey:PatientId,ModeId" json:"his_prescription_template"`
479
 	HisPrescriptionProject     []*HisPrescriptionProject  `gorm:"ForeignKey:PatientId,schedule_date;AssociationForeignKey:PatientId,RecordDate" json:"his_prescription_project"`
479
 	HisPrescriptionProject     []*HisPrescriptionProject  `gorm:"ForeignKey:PatientId,schedule_date;AssociationForeignKey:PatientId,RecordDate" json:"his_prescription_project"`
480
+	DialysisSolution           DialysisSolution           `gorm:"ForeignKey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId" json:"dialysis_solution"`
480
 }
481
 }
481
 
482
 
482
 func (VmBloodScheduleTwo) TableName() string {
483
 func (VmBloodScheduleTwo) TableName() string {

+ 2 - 2
service/dialysis_solution_service.go Wyświetl plik

425
 				return db.Where("user_org_id = ? and status = 1 and record_date = ? and type =3", orgID, scheduleDate).Preload("GoodInfo", func(db *gorm.DB) *gorm.DB {
425
 				return db.Where("user_org_id = ? and status = 1 and record_date = ? and type =3", orgID, scheduleDate).Preload("GoodInfo", func(db *gorm.DB) *gorm.DB {
426
 					return db.Where("org_id = ? and status = 1", orgID)
426
 					return db.Where("org_id = ? and status = 1", orgID)
427
 				})
427
 				})
428
-			}).Preload("HisPrescriptionTemplateSix", func(db *gorm.DB) *gorm.DB {
428
+			}).Preload("DialysisSolution", "status =1 and user_org_id = ? and solution_status=1").Preload("HisPrescriptionTemplateSix", func(db *gorm.DB) *gorm.DB {
429
 			return db.Where("user_org_id = ? and status = 1", orgID).Preload("HisPrescriptionInfoTemplateSix", func(db *gorm.DB) *gorm.DB {
429
 			return db.Where("user_org_id = ? and status = 1", orgID).Preload("HisPrescriptionInfoTemplateSix", func(db *gorm.DB) *gorm.DB {
430
 				return db.Where("user_org_id = ? and status = 1 and type = 2", orgID).Preload("HisPrescriptionProjectTemplateSeven", func(db *gorm.DB) *gorm.DB {
430
 				return db.Where("user_org_id = ? and status = 1 and type = 2", orgID).Preload("HisPrescriptionProjectTemplateSeven", func(db *gorm.DB) *gorm.DB {
431
 					return db.Where("user_org_id = ? and status = 1 and type = 3 and (frequency_type =1 or (frequency_type =2 and day_count >0) or (frequency_type =3 and week_day<>''))", orgID).Preload("GoodInfo", "org_id =? and status = 1", orgID)
431
 					return db.Where("user_org_id = ? and status = 1 and type = 3 and (frequency_type =1 or (frequency_type =2 and day_count >0) or (frequency_type =3 and week_day<>''))", orgID).Preload("GoodInfo", "org_id =? and status = 1", orgID)
443
 				return db.Where("user_org_id = ? and status = 1 and record_date = ? and type =3", orgID, scheduleDate).Preload("GoodInfo", func(db *gorm.DB) *gorm.DB {
443
 				return db.Where("user_org_id = ? and status = 1 and record_date = ? and type =3", orgID, scheduleDate).Preload("GoodInfo", func(db *gorm.DB) *gorm.DB {
444
 					return db.Where("org_id = ? and status = 1", orgID)
444
 					return db.Where("org_id = ? and status = 1", orgID)
445
 				})
445
 				})
446
-			}).Preload("HisPrescriptionTemplateSix", func(db *gorm.DB) *gorm.DB {
446
+			}).Preload("DialysisSolution", "status =1 and user_org_id = ? and solution_status=1", orgID).Preload("HisPrescriptionTemplateSix", func(db *gorm.DB) *gorm.DB {
447
 			return db.Where("user_org_id = ? and status = 1", orgID).Preload("HisPrescriptionInfoTemplateSix", func(db *gorm.DB) *gorm.DB {
447
 			return db.Where("user_org_id = ? and status = 1", orgID).Preload("HisPrescriptionInfoTemplateSix", func(db *gorm.DB) *gorm.DB {
448
 				return db.Where("user_org_id = ? and status = 1 and type = 2", orgID).Preload("HisPrescriptionProjectTemplateSeven", func(db *gorm.DB) *gorm.DB {
448
 				return db.Where("user_org_id = ? and status = 1 and type = 2", orgID).Preload("HisPrescriptionProjectTemplateSeven", func(db *gorm.DB) *gorm.DB {
449
 					return db.Where("user_org_id = ? and status = 1 and type = 3 and (frequency_type =1 or (frequency_type =2 and day_count >0) or (frequency_type =3 and week_day<>''))", orgID).Preload("GoodInfo", "org_id =? and status = 1", orgID)
449
 					return db.Where("user_org_id = ? and status = 1 and type = 3 and (frequency_type =1 or (frequency_type =2 and day_count >0) or (frequency_type =3 and week_day<>''))", orgID).Preload("GoodInfo", "org_id =? and status = 1", orgID)

+ 1 - 1
service/gobal_config_service.go Wyświetl plik

665
 	if orgid > 0 {
665
 	if orgid > 0 {
666
 		db = db.Where("x.org_id =?", orgid)
666
 		db = db.Where("x.org_id =?", orgid)
667
 	}
667
 	}
668
-	err = db.Select("x.id,x.drug_name,p.manufacturer_name,x.dose,x.dose_unit,x.min_number,x.max_unit,x.min_unit").Joins("left join xt_manufacturer as p on p.id =x.manufacturer").Scan(&drug).Error
668
+	err = db.Select("x.id,x.drug_name,p.manufacturer_name,x.dose,x.dose_unit,x.min_number,x.max_unit,x.min_unit,x.scan_code,x.drug_identification_code").Joins("left join xt_manufacturer as p on p.id =x.manufacturer").Scan(&drug).Error
669
 	return drug, err
669
 	return drug, err
670
 }
670
 }
671
 
671
 

+ 2 - 2
service/mobile_dialysis_service.go Wyświetl plik

2889
 }
2889
 }
2890
 
2890
 
2891
 func GetDialysisOrderCountOne(orgID int64, patient_id int64, recordDate int64) (count int64, err error) {
2891
 func GetDialysisOrderCountOne(orgID int64, patient_id int64, recordDate int64) (count int64, err error) {
2892
-	err = readDb.Model(&models.DialysisOrder{}).Where("dialysis_date>=1640966400 and  dialysis_date <= ? AND status = 1 AND stage = 2 AND user_org_id = ? AND patient_id = ?", recordDate, orgID, patient_id).Count(&count).Error
2892
+	err = readDb.Model(&models.DialysisOrder{}).Where("dialysis_date>=1704038400 and  dialysis_date <= ? AND status = 1 AND stage = 2 AND user_org_id = ? AND patient_id = ?", recordDate, orgID, patient_id).Count(&count).Error
2893
 	return
2893
 	return
2894
 }
2894
 }
2895
 
2895
 
2896
 func GetDialysisOrderCountTwo(orgID int64, patient_id int64, recordDate int64) (count int64, err error) {
2896
 func GetDialysisOrderCountTwo(orgID int64, patient_id int64, recordDate int64) (count int64, err error) {
2897
-	err = readDb.Model(&models.DialysisOrder{}).Where("dialysis_date>=1704038400 and  dialysis_date <= ? AND status = 1 AND stage = 2 AND user_org_id = ? AND patient_id = ?", recordDate, orgID, patient_id).Count(&count).Error
2897
+	err = readDb.Model(&models.DialysisOrder{}).Where("dialysis_date>=1735660800 and  dialysis_date <= ? AND status = 1 AND stage = 2 AND user_org_id = ? AND patient_id = ?", recordDate, orgID, patient_id).Count(&count).Error
2898
 	return
2898
 	return
2899
 }
2899
 }
2900
 
2900
 

+ 1 - 1
service/patientmanage_service.go Wyświetl plik

951
 
951
 
952
 func UpdatedPatient(patients models.Patients, id int64) error {
952
 func UpdatedPatient(patients models.Patients, id int64) error {
953
 
953
 
954
-	err := XTWriteDB().Model(&patients).Where("id=?", id).Update(map[string]interface{}{"name": patients.Name, "gender": patients.Gender, "birthday": patients.Birthday, "age": patients.Age, "phone": patients.Phone, "lapseto": patients.Lapseto, "admission_number": patients.AdmissionNumber, "first_dialysis_date": patients.FirstDialysisDate, "diagnose": patients.Diagnose, "source": patients.Source, "dialysis_no": patients.DialysisNo, "avatar": patients.Avatar, "id_card_no": patients.IdCardNo, "is_infectious": patients.IsInfectious, "out_reason": patients.OutReason, "death_time": patients.DeathTime, "relative_phone": patients.RelativePhone, "sch_remark": patients.SchRemark, "treatment_plan": patients.TreatmentPlan, "patient_type": patients.PatientType}).Error
954
+	err := XTWriteDB().Model(&patients).Where("id=?", id).Update(map[string]interface{}{"name": patients.Name, "gender": patients.Gender, "birthday": patients.Birthday, "age": patients.Age, "phone": patients.Phone, "lapseto": patients.Lapseto, "admission_number": patients.AdmissionNumber, "first_dialysis_date": patients.FirstDialysisDate, "diagnose": patients.Diagnose, "source": patients.Source, "dialysis_no": patients.DialysisNo, "avatar": patients.Avatar, "id_card_no": patients.IdCardNo, "is_infectious": patients.IsInfectious, "out_reason": patients.OutReason, "death_time": patients.DeathTime, "relative_phone": patients.RelativePhone, "sch_remark": patients.SchRemark, "treatment_plan": patients.TreatmentPlan, "patient_type": patients.PatientType, "updated_time": time.Now().Unix()}).Error
955
 
955
 
956
 	return err
956
 	return err
957
 }
957
 }

+ 8 - 1
service/pharmacy_service.go Wyświetl plik

2466
 
2466
 
2467
 	err := XTWriteDB().Model(&adviceInfo).Where("id = ? and user_org_id = ? and status =1", id, user_org_id).Updates(map[string]interface{}{"drug_code": drug_code}).Error
2467
 	err := XTWriteDB().Model(&adviceInfo).Where("id = ? and user_org_id = ? and status =1", id, user_org_id).Updates(map[string]interface{}{"drug_code": drug_code}).Error
2468
 
2468
 
2469
-	fmt.Println("eeeeeeeeeeeeeeeeeeeeeeeeeeeeee", err)
2469
+	fmt.Println("", err)
2470
 	return adviceInfo, err
2470
 	return adviceInfo, err
2471
 }
2471
 }
2472
 
2472
 
2560
 
2560
 
2561
 	return
2561
 	return
2562
 }
2562
 }
2563
+
2564
+func GetDrugTocalCountByDrugId(drug_id int64, advice_date int64, user_org_id int64) (advice []*models.HisDoctorAdviceInfo, err error) {
2565
+
2566
+	err = XTReadDB().Where("drug_id = ? and advice_date>=? and user_org_id = ? and status=1 and drug_code!=''", drug_id, advice_date, user_org_id).Find(&advice).Error
2567
+
2568
+	return advice, err
2569
+}

+ 2 - 2
service/print_data_service/schedule_dialysis/print_schedule_dialysis_service.go Wyświetl plik

236
 
236
 
237
 func GetDialysisOrderCountEight(orgID int64, patient_id int64, recordDate int64) (models.VmDialysisOrder, error) {
237
 func GetDialysisOrderCountEight(orgID int64, patient_id int64, recordDate int64) (models.VmDialysisOrder, error) {
238
 	order := models.VmDialysisOrder{}
238
 	order := models.VmDialysisOrder{}
239
-	err := p_service.XTReadDB().Raw("SELECT Count(id) as count,Max(dialysis_date) as dialysis_date  from xt_dialysis_order where dialysis_date>=1672502400 and dialysis_date <= ? AND status = 1 AND stage = 2 AND patient_id = ? and user_org_id = ?", recordDate, patient_id, orgID).Scan(&order).Error
239
+	err := p_service.XTReadDB().Raw("SELECT Count(id) as count,Max(dialysis_date) as dialysis_date  from xt_dialysis_order where dialysis_date>=1704038400 and dialysis_date <= ? AND status = 1 AND stage = 2 AND patient_id = ? and user_org_id = ?", recordDate, patient_id, orgID).Scan(&order).Error
240
 	return order, err
240
 	return order, err
241
 }
241
 }
242
 
242
 
243
 func GetDialysisOrderCountNight(orgID int64, patient_id int64, recordDate int64) (models.VmDialysisOrder, error) {
243
 func GetDialysisOrderCountNight(orgID int64, patient_id int64, recordDate int64) (models.VmDialysisOrder, error) {
244
 	order := models.VmDialysisOrder{}
244
 	order := models.VmDialysisOrder{}
245
-	err := p_service.XTReadDB().Raw("SELECT Count(id) as count,Max(dialysis_date) as dialysis_date  from xt_dialysis_order where dialysis_date>=1704038400 and dialysis_date <= ? AND status = 1 AND stage = 2 AND patient_id = ? and user_org_id = ?", recordDate, patient_id, orgID).Scan(&order).Error
245
+	err := p_service.XTReadDB().Raw("SELECT Count(id) as count,Max(dialysis_date) as dialysis_date  from xt_dialysis_order where dialysis_date>=1735660800 and dialysis_date <= ? AND status = 1 AND stage = 2 AND patient_id = ? and user_org_id = ?", recordDate, patient_id, orgID).Scan(&order).Error
246
 	return order, err
246
 	return order, err
247
 }
247
 }
248
 
248
 

+ 40 - 1
service/stock_service.go Wyświetl plik

1872
 	return drugWarehouseOut, err
1872
 	return drugWarehouseOut, err
1873
 }
1873
 }
1874
 
1874
 
1875
+func GetNewDrugWarehouseOutIsExitOne(org_id int64, is_sys int, record_time int64, warehousing_out_order string, tx *gorm.DB, id int64) (models.DrugWarehouseOut, error) {
1876
+
1877
+	drugWarehouseOut := models.DrugWarehouseOut{}
1878
+	err := tx.Where("is_sys = ? AND status = 1 AND org_id = ? AND id = ?", is_sys, org_id, id).Find(&drugWarehouseOut).Error
1879
+	if err != gorm.ErrRecordNotFound {
1880
+		if err != nil {
1881
+			tx.Rollback()
1882
+			return drugWarehouseOut, err
1883
+		}
1884
+	}
1885
+
1886
+	return drugWarehouseOut, err
1887
+}
1888
+
1875
 func AddSigleDrugWarehouseOut(warehouseOut *models.DrugWarehouseOut) error {
1889
 func AddSigleDrugWarehouseOut(warehouseOut *models.DrugWarehouseOut) error {
1876
 	err := writeDb.Create(&warehouseOut).Error
1890
 	err := writeDb.Create(&warehouseOut).Error
1877
 	return err
1891
 	return err
9108
 		tx.Rollback()
9122
 		tx.Rollback()
9109
 		return err
9123
 		return err
9110
 	}
9124
 	}
9111
-	tx.Commit()
9112
 	return err
9125
 	return err
9113
 }
9126
 }
9114
 
9127
 
9320
 
9333
 
9321
 }
9334
 }
9322
 
9335
 
9336
+func GetGoodFlowByWarehouseOutId(good_id int64, user_org_id int64, id int64, tx *gorm.DB) (flow []*models.VmStockFlow, err error) {
9337
+
9338
+	err = tx.Where("good_id = ? and user_org_id = ? and warehouse_out_detail_id = ? and status=1", good_id, user_org_id, id).Find(&flow).Error
9339
+
9340
+	if err != gorm.ErrRecordNotFound {
9341
+		if err != nil {
9342
+			tx.Rollback()
9343
+			return flow, err
9344
+		}
9345
+	}
9346
+	return
9347
+}
9348
+
9323
 func UpdateGoodInfoAddSumCount(goodid int64, sum_count int64, orgid int64, sum_in_count int64) error {
9349
 func UpdateGoodInfoAddSumCount(goodid int64, sum_count int64, orgid int64, sum_in_count int64) error {
9324
 
9350
 
9325
 	err := XTWriteDB().Model(&models.GoodInfo{}).Where("id = ? and org_id = ? and status = 1", goodid, orgid).Update(map[string]interface{}{"sum_count": sum_count}).Error
9351
 	err := XTWriteDB().Model(&models.GoodInfo{}).Where("id = ? and org_id = ? and status = 1", goodid, orgid).Update(map[string]interface{}{"sum_count": sum_count}).Error
10887
 
10913
 
10888
 	return outinfo, err
10914
 	return outinfo, err
10889
 }
10915
 }
10916
+
10917
+func GetNewGoodWarehouseOutInfo(good_id int64, user_org_id int64, warehouse_out_id int64, tx *gorm.DB) (info []*models.WarehouseOutInfo, err error) {
10918
+
10919
+	err = tx.Where("good_id = ? and org_id = ? and warehouse_out_id = ? and status= 1", good_id, user_org_id, warehouse_out_id).Find(&info).Error
10920
+
10921
+	if err != gorm.ErrRecordNotFound {
10922
+		if err != nil {
10923
+			tx.Rollback()
10924
+			return info, err
10925
+		}
10926
+	}
10927
+	return info, err
10928
+}

+ 12 - 9
service/warhouse_service.go Wyświetl plik

6133
 	return err
6133
 	return err
6134
 }
6134
 }
6135
 
6135
 
6136
+func GetDrugOutFlowByWarehouseOut(drug_id int64, warehouse_out_detail_id int64, org_id int64, tx *gorm.DB) (flow []*models.DrugFlow, err error) {
6137
+
6138
+	err = tx.Where("drug_id = ? and warehouse_out_detail_id = ? and user_org_id = ? and status=1", drug_id, warehouse_out_detail_id, org_id).Find(&flow).Error
6139
+	if err != gorm.ErrRecordNotFound {
6140
+		if err != nil {
6141
+			tx.Rollback()
6142
+			return flow, err
6143
+		}
6144
+	}
6145
+	return flow, err
6146
+}
6147
+
6136
 func UpdateNewGoodWarehouseOutById(id int64, warehouse_info_id int64, org_id int64, over_count int64, tx *gorm.DB) error {
6148
 func UpdateNewGoodWarehouseOutById(id int64, warehouse_info_id int64, org_id int64, over_count int64, tx *gorm.DB) error {
6137
 
6149
 
6138
 	err := tx.Model(models.WarehouseOutInfo{}).Where("id = ?  and org_id = ? and status = 1", id, org_id).Update(map[string]interface{}{"warehouse_info_id": warehouse_info_id, "over_count": over_count}).Error
6150
 	err := tx.Model(models.WarehouseOutInfo{}).Where("id = ?  and org_id = ? and status = 1", id, org_id).Update(map[string]interface{}{"warehouse_info_id": warehouse_info_id, "over_count": over_count}).Error
10904
 		//更新出库数量
10916
 		//更新出库数量
10905
 		ModifyNewGoodSumCount(goods.StorehouseId, goods.Count, goods.OrgId, goods.GoodId, tx)
10917
 		ModifyNewGoodSumCount(goods.StorehouseId, goods.Count, goods.OrgId, goods.GoodId, tx)
10906
 
10918
 
10907
-		fmt.Println("warehouse.StockCount----------------", warehouse.StockCount)
10908
-		fmt.Println("warehouse.StockCount----------------", maxNumber)
10909
-		//if warehouse.StockCount < maxNumber {
10910
-		//	tx.Rollback()
10911
-		//	return errors.New("库存数量不足")
10912
-		//
10913
-		//}
10914
-
10915
 		return nil
10919
 		return nil
10916
 	} else {
10920
 	} else {
10917
 		// 出库完成后,要将该批次库存清零
10921
 		// 出库完成后,要将该批次库存清零
10978
 
10982
 
10979
 		goods.Count = deliver_number - stock_number
10983
 		goods.Count = deliver_number - stock_number
10980
 
10984
 
10981
-		fmt.Println("hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", goods.Count)
10982
 		ConsumablesNewDeliveryThirty(orgID, record_time, goods, warehouseOut, count, creator, tx)
10985
 		ConsumablesNewDeliveryThirty(orgID, record_time, goods, warehouseOut, count, creator, tx)
10983
 	}
10986
 	}
10984
 	return nil
10987
 	return nil