Explorar el Código

11月8日库存管理

XMLWAN hace 3 años
padre
commit
0849023d8d

+ 1 - 1
controllers/device_api_controller.go Ver fichero

@@ -877,7 +877,7 @@ func (this *DeviceAPIController) ModifyNumber() {
877 877
 	number.ZoneID = zoneID
878 878
 	number.GroupID = groupID
879 879
 	number.Sort = sort
880
-	byName, _ := service.GetDeviceNumberByName(num, adminInfo.CurrentOrgId)
880
+	byName, _ := service.GetDeviceNumberByName(num, zoneID, adminInfo.CurrentOrgId)
881 881
 	if byName.ID > 0 && byName.ID != id {
882 882
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
883 883
 		return

+ 60 - 8
controllers/drug_stock_api_contorller.go Ver fichero

@@ -209,6 +209,13 @@ func (c *StockDrugApiController) CreateDrugWarehouse() {
209 209
 
210 210
 				dealer := int64(items["dealer"].(float64))
211 211
 
212
+				if items["retail_price"] == nil || reflect.TypeOf(items["retail_price"]).String() != "string" {
213
+					utils.ErrorLog("retail_price")
214
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
215
+					return
216
+				}
217
+				retail_price, _ := strconv.ParseFloat(items["retail_price"].(string), 64)
218
+
212 219
 				warehouseInfo := &models.DrugWarehouseInfo{
213 220
 					WarehousingOrder: warehousing.WarehousingOrder,
214 221
 					WarehousingId:    warehousing.ID,
@@ -231,6 +238,13 @@ func (c *StockDrugApiController) CreateDrugWarehouse() {
231 238
 					BatchNumber:      batch_number,
232 239
 					MaxUnit:          max_unit,
233 240
 					MinUnit:          min_unit,
241
+					RetailPrice:      retail_price,
242
+				}
243
+
244
+				if max_unit == min_unit {
245
+					warehouseInfo.StockMaxNumber = 0
246
+					warehouseInfo.StockMinNumber = warehousing_count
247
+					warehouseInfo.MaxUnit = min_unit
234 248
 				}
235 249
 				warehousingInfo = append(warehousingInfo, warehouseInfo)
236 250
 
@@ -257,6 +271,9 @@ func (c *StockDrugApiController) CreateDrugWarehouse() {
257 271
 					IsSys:            0,
258 272
 				}
259 273
 
274
+				if max_unit == min_unit {
275
+					drugflow.MaxUnit = min_unit
276
+				}
260 277
 				drugFlow = append(drugFlow, drugflow)
261 278
 
262 279
 			}
@@ -338,7 +355,6 @@ func (c *StockDrugApiController) GetDrugWarehouseList() {
338 355
 	}
339 356
 
340 357
 	adminUserInfo := c.GetAdminUserInfo()
341
-	fmt.Println("hhh2h3h23h2h32h3h2h32h32h3h2h3", keywords)
342 358
 	//按药品名称搜索
343 359
 	var ids []int64
344 360
 	var idArray []int64
@@ -487,6 +503,8 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
487 503
 
488 504
 				retail_price_total := float64(warehousing_count) * last_price
489 505
 
506
+				retail_price, _ := strconv.ParseFloat(items["retail_price"].(string), 64)
507
+
490 508
 				var productDates int64
491 509
 				var expiryDates int64
492 510
 
@@ -561,13 +579,18 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
561 579
 						Type:             types,
562 580
 						Manufacturer:     manufacturer,
563 581
 						Dealer:           dealer,
564
-						RetailPrice:      last_price,
582
+						RetailPrice:      retail_price,
565 583
 						RetailTotalPrice: retail_price_total,
566 584
 						BatchNumber:      batch_number,
567 585
 						MaxUnit:          max_unit,
568 586
 						MinUnit:          min_unit,
569 587
 						StockMaxNumber:   warehousing_count,
570 588
 					}
589
+					if max_unit == min_unit {
590
+						warehouseInfo.StockMaxNumber = 0
591
+						warehouseInfo.StockMinNumber = warehousing_count
592
+						warehouseInfo.MaxUnit = min_unit
593
+					}
571 594
 					warehousingInfo = append(warehousingInfo, warehouseInfo)
572 595
 
573 596
 				} else {
@@ -590,12 +613,18 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
590 613
 						Type:             types,
591 614
 						Manufacturer:     manufacturer,
592 615
 						Dealer:           dealer,
593
-						RetailPrice:      last_price,
616
+						RetailPrice:      retail_price,
594 617
 						RetailTotalPrice: retail_price_total,
595 618
 						MaxUnit:          max_unit,
596 619
 						MinUnit:          min_unit,
597 620
 						BatchNumber:      batch_number,
598 621
 					}
622
+					if max_unit == min_unit {
623
+						warehouseInfo.StockMaxNumber = 0
624
+						warehouseInfo.StockMinNumber = warehousing_count
625
+						warehouseInfo.MaxUnit = min_unit
626
+					}
627
+
599 628
 					upDateWarehousingInfo = append(upDateWarehousingInfo, warehouseInfo)
600 629
 
601 630
 					drugflow := &models.DrugFlow{
@@ -658,6 +687,9 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
658 687
 					IsSys:               0,
659 688
 					WarehousingDetailId: info.ID,
660 689
 				}
690
+				if info.MaxUnit == info.MinUnit {
691
+					flows.MaxUnit = info.MinUnit
692
+				}
661 693
 				_, existerrcodes := service.GetDrugFlowIsExist(info.ID, info.DrugId)
662 694
 
663 695
 				if existerrcodes == gorm.ErrRecordNotFound {
@@ -682,7 +714,6 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
682 714
 			//历史入库总数
683 715
 			total = orderInfo.StockMaxNumber * info.MinNumber
684 716
 
685
-			//当前入库总数
686 717
 			allTotal = item.WarehousingCount * info.MinNumber
687 718
 
688 719
 			//如果历史的入库总数 大于当前入库总数 则需要扣减
@@ -732,6 +763,9 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
732 763
 							BatchNumber:  it.BatchNumber,
733 764
 							Price:        it.Price,
734 765
 						}
766
+						if info.MaxUnit == info.MinUnit {
767
+							flow.MaxUnit = info.MinUnit
768
+						}
735 769
 						parseDateErr := service.UpdateDrugFlow(flow, item.DrugId, warehouseInfo.WarehousingId)
736 770
 						fmt.Println(parseDateErr)
737 771
 
@@ -749,7 +783,9 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
749 783
 					for _, it := range drugFlow {
750 784
 						fmt.Println(it)
751 785
 						flow := models.DrugFlow{
752
-							Count: item.StockMaxNumber,
786
+							Count:   item.StockMaxNumber,
787
+							MaxUnit: item.MaxUnit,
788
+							MinUnit: item.MinUnit,
753 789
 						}
754 790
 						parseDateErr := service.UpdateDrugFlow(flow, item.DrugId, warehouseInfo.WarehousingId)
755 791
 						fmt.Println(parseDateErr)
@@ -770,6 +806,9 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
770 806
 					Manufacturer: item.Manufacturer,
771 807
 					Remark:       item.Remark,
772 808
 					BatchNumber:  item.BatchNumber,
809
+					MaxUnit:      item.MaxUnit,
810
+					MinUnit:      item.MinUnit,
811
+					RetailPrice:  item.RetailPrice,
773 812
 				}
774 813
 				errs = service.UpDateDrugWarehousingInfoTwo(item.ID, warehouseinfo)
775 814
 			}
@@ -2408,7 +2447,6 @@ func (c *StockDrugApiController) CreateDrugCancelStock() {
2408 2447
 		infoWareInfo, _ := service.GetDrugWarehouseInfo(item.BatchNumberId)
2409 2448
 		var total_count int64
2410 2449
 		total_count = infoWareInfo.WarehousingCount * medical.MinNumber
2411
-		fmt.Println("当前批次总库存", total_count)
2412 2450
 
2413 2451
 		//查询该批次的出库数量
2414 2452
 		outInfo, _ := service.GetDrugWarehouseOutInfo(item.BatchNumberId, item.DrugId)
@@ -2448,7 +2486,9 @@ func (c *StockDrugApiController) CreateDrugCancelStock() {
2448 2486
 			})
2449 2487
 			return
2450 2488
 		}
2451
-
2489
+		fmt.Println("当前退库数", total_count)
2490
+		fmt.Println("当前批次总库存", total_count)
2491
+		fmt.Println("总出库数", out_number)
2452 2492
 		//判断退库数量是否大于总入库数量
2453 2493
 		if total_number > total_count {
2454 2494
 			service.UpdateDrugCancel(item.CancelStockId)
@@ -2614,6 +2654,18 @@ func (this *StockDrugApiController) DeleteDrugCancelStock() {
2614 2654
 	}
2615 2655
 
2616 2656
 	idArray := strings.Split(ids, ",")
2657
+	//获取入库数据
2658
+	list, _ := service.GetDrugWareInfoByCancelId(idArray)
2659
+	for _, item := range list {
2660
+		medical, _ := service.GetBaseDrugMedical(item.DrugId)
2661
+		if item.MaxUnit == medical.MaxUnit {
2662
+			//回退库存
2663
+			service.ModifyDrugWarehouseByInfoId(item.CancelStockId, item.Count)
2664
+		}
2665
+		if item.MaxUnit == medical.MinUnit {
2666
+			service.ModifyDrugWarehouseByStockMin(item.CancelStockId, item.Count)
2667
+		}
2668
+	}
2617 2669
 	err := service.DeleteDrugCancelStock(idArray)
2618 2670
 	if err != nil {
2619 2671
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteFail)
@@ -2625,7 +2677,7 @@ func (this *StockDrugApiController) DeleteDrugCancelStock() {
2625 2677
 }
2626 2678
 func (this *StockDrugApiController) DeleteDrugCancelStockInfo() {
2627 2679
 	id, _ := this.GetInt64("id", 0)
2628
-	fmt.Println(id)
2680
+
2629 2681
 	if id == 0 {
2630 2682
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2631 2683
 		return

+ 7 - 13
controllers/his_api_controller.go Ver fichero

@@ -803,8 +803,6 @@ func (c *HisApiController) CreateHisPrescription() {
803 803
 										number_count = prescribingNumberInt
804 804
 									}
805 805
 
806
-									fmt.Println("以前出库数量23323232322332323223233223232332", device_number)
807
-									fmt.Println("现在出库数量", number_count)
808 806
 									//如果修改的数量大于之前修改的数量
809 807
 									if (number_count - device_number) > 0 {
810 808
 										//如果修改的差数量 大于库存数量
@@ -818,8 +816,7 @@ func (c *HisApiController) CreateHisPrescription() {
818 816
 
819 817
 										// 查询该药品最后一次出库记录
820 818
 										druginfo, _ := service.GetLastDrugWarehouseOutByDrugId(drug_id, patient_id, recordDateTime, adviceId)
821
-										fmt.Println("以前出库数量23323232322332323223233223232332", device_number)
822
-										fmt.Println("现在出库数量", number_count)
819
+
823 820
 										//回退库存
824 821
 										if druginfo.CountUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
825 822
 
@@ -830,14 +827,14 @@ func (c *HisApiController) CreateHisPrescription() {
830 827
 											var stock_min_number int64
831 828
 
832 829
 											if number_count >= drug.MinNumber {
833
-												fmt.Println("尽力啊了吗332323322332233232332233223232323")
830
+
834 831
 												stock_max_number = device_number / drug.MinNumber
835 832
 												service.ModefyDrugByWarehouseInfo(druginfo.WarehouseInfoId, stock_max_number)
836 833
 												stock_min_number = device_number % drug.MinNumber
837 834
 												service.ModefyDrugByWarehouseInfoOne(druginfo.WarehouseInfoId, stock_min_number)
838 835
 
839 836
 											} else {
840
-												fmt.Println("99999999999999999999")
837
+
841 838
 												service.ModefyDrugByWarehouseInfoOne(druginfo.WarehouseInfoId, device_number)
842 839
 											}
843 840
 										}
@@ -897,7 +894,6 @@ func (c *HisApiController) CreateHisPrescription() {
897 894
 									project_name = project.(map[string]interface{})["project_name"].(string)
898 895
 
899 896
 								}
900
-								fmt.Println("id3232322332232323323223322323", id)
901 897
 								if project_type == 3 {
902 898
 
903 899
 									//查找该耗材的出库记录
@@ -922,7 +918,7 @@ func (c *HisApiController) CreateHisPrescription() {
922 918
 										}
923 919
 										//查找今日该患者已经出库的所有耗材
924 920
 										goodList, _ := service.GetAllAutoRecordByPatient(patient_id, recordDateTime)
925
-										fmt.Println("goodList3323223232323232323", goodList)
921
+
926 922
 										for _, item := range goodList {
927 923
 											//回退库存
928 924
 											service.ModefyWarehouseInfo(item.Count, item.WarehouseInfotId)
@@ -933,16 +929,14 @@ func (c *HisApiController) CreateHisPrescription() {
933 929
 									if len(goodWarehouseInfo) > 0 {
934 930
 										//查询该患者耗材的历史数据
935 931
 										ordProject, _ := service.GetHisProjectPrescriptionByPatientIdOne(id)
936
-										fmt.Println("ordOr2323233232323232323223232", ordProject)
932
+
937 933
 										count, _ := strconv.ParseInt(ordProject.Count, 10, 64)
938
-										fmt.Println("id3232322332232323323223322323", id)
939
-										fmt.Println("parsetotal33223232323232323", parsetotal)
940
-										fmt.Println("count2332322332232332", count)
934
+
941 935
 										//数量发生改变
942 936
 										if parsetotal != count {
943 937
 											//查找今日该患者已经出库的所有耗材
944 938
 											goodList, _ := service.GetAllAutoRecordByPatient(patient_id, recordDateTime)
945
-											fmt.Println("goodList3323223232323232323", goodList)
939
+
946 940
 											for _, item := range goodList {
947 941
 												//回退库存
948 942
 												service.ModefyWarehouseInfo(item.Count, item.WarehouseInfotId)

+ 9 - 0
controllers/new_mobile_api_controllers/staff_schedule_api_controller.go Ver fichero

@@ -706,3 +706,12 @@ func (c *StaffScheduleApiController) CreateMobileSchedulePatient() {
706 706
 	return
707 707
 
708 708
 }
709
+
710
+func (c *StaffScheduleApiController) GetSolutionSchedule() {
711
+
712
+	orgId := c.GetMobileAdminUserInfo().Org.Id
713
+	solution, _ := service.GetSolutionSchedule(orgId)
714
+	c.ServeSuccessJSON(map[string]interface{}{
715
+		"solution": solution,
716
+	})
717
+}

+ 1 - 0
controllers/new_mobile_api_controllers/staff_schedule_api_router.go Ver fichero

@@ -25,4 +25,5 @@ func StaffScheduleApiControllersRegisterRouters() {
25 25
 	beego.Router("/m/api/updateschedule", &StaffScheduleApiController{}, "Get:UpdateBloodSchedule")
26 26
 	beego.Router("m/api/schedule/patients", &StaffScheduleApiController{}, "Get:GetSchedulePatient")
27 27
 	beego.Router("/m/api/schedule/create", &StaffScheduleApiController{}, "Post:CreateMobileSchedulePatient")
28
+	beego.Router("m/api/schedule/getsolutionschedule", &StaffScheduleApiController{}, "Get:GetSolutionSchedule")
28 29
 }

+ 1 - 1
controllers/patient_dataconfig_api_controller.go Ver fichero

@@ -86,7 +86,7 @@ func (this *PatientDataConfigAPIController) CreateCourse() {
86 86
 	patientID, _ := this.GetInt64("patient_id")
87 87
 	fmt.Println(patientID)
88 88
 	content := this.GetString("content")
89
-	fmt.Println("content22222222222222222222", content)
89
+
90 90
 	record_time_str := this.GetString("record_time")
91 91
 	title := this.GetString("title")
92 92
 

+ 1 - 11
controllers/print_data_api_controller.go Ver fichero

@@ -44,7 +44,7 @@ func (this *PrintDataAPIController) ScheduleDialysisRecordPrintData() {
44 44
 		}
45 45
 		if this.GetAdminUserInfo().CurrentOrgId == 10101 || this.GetAdminUserInfo().CurrentOrgId == 9671 {
46 46
 			listOne, _ := service.GetDialysisOrderCountEight(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
47
-			fmt.Println("lisntONE2323223323232", listOne.Count)
47
+
48 48
 			item.Patient.TotalDialysis = listOne.Count
49 49
 			item.Count = listOne.Count
50 50
 		}
@@ -129,17 +129,7 @@ func (this *PrintDataAPIController) CourseRecordPrintData() {
129 129
 	adminUserInfo := this.GetAdminUserInfo()
130 130
 	patient_id, _ := this.GetInt64("patient_id")
131 131
 
132
-	//timeLayout := "2006-01-02 15:04:05"
133 132
 	record, err := service.GetPatientCoursesRecords(adminUserInfo.CurrentOrgId, ids_arr)
134
-	//dataTimeStr := time.Unix(record.RecordTime, 0).Format(timeLayout) //设置时间戳 使用模板格式化为日期字符串
135
-	//tempTime := strings.Split(dataTimeStr, " ")
136
-	//
137
-	//recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", tempTime[0])
138
-	//if parseDateErr != nil {
139
-	//	this.ErrorLog("日期(%v)解析错误:%v", tempTime[0], parseDateErr)
140
-	//	//this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
141
-	//	//return
142
-	//}
143 133
 
144 134
 	//patient, _ := service.FindPatientWithDeviceById(adminUserInfo.CurrentOrgId, patient_id)
145 135
 	patient, _ := service.GetPatientDetail(adminUserInfo.CurrentOrgId, patient_id)

+ 2 - 3
controllers/schedule_api_controller.go Ver fichero

@@ -2569,8 +2569,7 @@ func (this *ScheduleApiController) GetPatientScheduleCount() {
2569 2569
 	theEndTime, _ := time.ParseInLocation(timeLayout, weekEndTime, loc)
2570 2570
 	weekStartPoint := theStarTime.Unix()
2571 2571
 	weekEndPoint := theEndTime.Unix()
2572
-	fmt.Println("startTime222222222222222", weekStartPoint)
2573
-	fmt.Println("endtime33333333333333", weekEndPoint)
2572
+
2574 2573
 	list, err := service.GetPatientScheduleCount(orgId, weekStartPoint, weekEndPoint, ids)
2575 2574
 	_, total, _ := service.GetTotalBedNumber(orgId, ids)
2576 2575
 	if err != nil {
@@ -2946,7 +2945,7 @@ func (c *ScheduleApiController) GetSolutionSchedule() {
2946 2945
 
2947 2946
 	orgId := c.GetAdminUserInfo().CurrentOrgId
2948 2947
 	solution, _ := service.GetSolutionSchedule(orgId)
2949
-	fmt.Println("solution33232323223233233323232332323232", solution)
2948
+
2950 2949
 	c.ServeSuccessJSON(map[string]interface{}{
2951 2950
 		"solution": solution,
2952 2951
 	})

+ 45 - 0
models/patient_models.go Ver fichero

@@ -1505,3 +1505,48 @@ type XtHospitalSummary struct {
1505 1505
 func (XtHospitalSummary) TableName() string {
1506 1506
 	return "xt_hospital_summary"
1507 1507
 }
1508
+
1509
+type VmDialysisSolution struct {
1510
+	UserOrgId                  int64                 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1511
+	PatientId                  int64                 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1512
+	DialysisDialyszers         string                `gorm:"column:dialysis_dialyszers" json:"dialysis_dialyszers" form:"dialysis_dialyszers"`
1513
+	DialysisIrrigation         string                `gorm:"column:dialysis_irrigation" json:"dialysis_irrigation" form:"dialysis_irrigation"`
1514
+	DialyzerPerfusionApparatus string                `gorm:"column:dialyzer_perfusion_apparatus" json:"dialyzer_perfusion_apparatus"`
1515
+	ModeName                   string                `gorm:"column:mode_name" json:"mode_name" form:"mode_name"`
1516
+	ModeId                     int64                 `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
1517
+	Anticoagulant              int64                 `gorm:"column:anticoagulant" json:"anticoagulant" form:"anticoagulant"`
1518
+	DialysisSolution           VmDialysisSolutionOne `gorm:"ForeignKey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId" json:"solution"`
1519
+}
1520
+
1521
+func (VmDialysisSolution) TableName() string {
1522
+	return "xt_dialysis_solution"
1523
+}
1524
+
1525
+type VmDialysisSolutionOne struct {
1526
+	UserOrgId                  int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1527
+	PatientId                  int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1528
+	DialysisDialyszers         string `gorm:"column:dialysis_dialyszers" json:"dialysis_dialyszers" form:"dialysis_dialyszers"`
1529
+	DialysisIrrigation         string `gorm:"column:dialysis_irrigation" json:"dialysis_irrigation" form:"dialysis_irrigation"`
1530
+	DialyzerPerfusionApparatus string `gorm:"column:dialyzer_perfusion_apparatus" json:"dialyzer_perfusion_apparatus"`
1531
+	ModeName                   string `gorm:"column:mode_name" json:"mode_name" form:"mode_name"`
1532
+	ModeId                     int64  `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
1533
+}
1534
+
1535
+func (VmDialysisSolutionOne) TableName() string {
1536
+	return "xt_dialysis_solution"
1537
+}
1538
+
1539
+type VmDialysisPrescription struct {
1540
+	UserOrgId                  int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1541
+	PatientId                  int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1542
+	DialysisDialyszers         string `gorm:"column:dialysis_dialyszers" json:"dialysis_dialyszers" form:"dialysis_dialyszers"`
1543
+	DialysisIrrigation         string `gorm:"column:dialysis_irrigation" json:"dialysis_irrigation" form:"dialysis_irrigation"`
1544
+	DialyzerPerfusionApparatus string `gorm:"column:dialyzer_perfusion_apparatus" json:"dialyzer_perfusion_apparatus"`
1545
+	ModeName                   string `gorm:"column:mode_name" json:"mode_name" form:"mode_name"`
1546
+	ModeId                     int64  `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
1547
+	Anticoagulant              int64  `gorm:"column:anticoagulant" json:"anticoagulant" form:"anticoagulant"`
1548
+}
1549
+
1550
+func (VmDialysisPrescription) TableName() string {
1551
+	return "xt_dialysis_prescription"
1552
+}

+ 1 - 0
models/self_drug_models.go Ver fichero

@@ -405,6 +405,7 @@ type XtDrugWarehouseInfo struct {
405 405
 	StockMaxNumber    int64      `gorm:"column:stock_max_number" json:"stock_max_number"`
406 406
 	StockMinNumber    int64      `gorm:"column:stock_min_number" json:"stock_min_number"`
407 407
 	BatchNumber       string     `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
408
+	MinUnit           string     `gorm:"column:min_unit" json:"max_unit" form:"min_unit"`
408 409
 	MaxUnit           string     `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
409 410
 	WarehousingInfoId int64      `gorm:"column:warehousing_info_id" json:"warehousing_info_id" form:"warehousing_info_id"`
410 411
 	XtBaseDrug        XtBaseDrug `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" `

+ 2 - 2
service/device_service.go Ver fichero

@@ -480,9 +480,9 @@ func CreateDeviceNumber(orgID int64, number string, zoneID int64, groupID int64,
480 480
 	return &numberModel, nil
481 481
 }
482 482
 
483
-func GetDeviceNumberByName(num string, orgid int64) (number models.DeviceNumber, err error) {
483
+func GetDeviceNumberByName(num string, zoneId int64, orgid int64) (number models.DeviceNumber, err error) {
484 484
 
485
-	err = XTReadDB().Model(&number).Where("number = ? and org_id = ? and status =1", num, orgid).First(&number).Error
485
+	err = XTReadDB().Model(&number).Where("number = ? and zone_id = ? and org_id = ? and status =1", num, zoneId, orgid).First(&number).Error
486 486
 	return number, err
487 487
 }
488 488
 

+ 12 - 8
service/manage_center_service.go Ver fichero

@@ -222,7 +222,7 @@ func GetBaseDrugLibList(org_id int64, keyword string, page int64, limit int64, i
222 222
 	}
223 223
 
224 224
 	if is_use != 0 {
225
-		if is_use == 1 {
225
+		if is_use == 2 {
226 226
 			db = db.Where("find_in_set('停用',drug_status) = 0")
227 227
 
228 228
 		} else {
@@ -230,14 +230,18 @@ func GetBaseDrugLibList(org_id int64, keyword string, page int64, limit int64, i
230 230
 		}
231 231
 	}
232 232
 
233
-	if is_charge != 0 {
234
-		//db = db.Where("drug_name Like ?", keyword)
235
-		if is_charge == 1 {
236
-			db = db.Where("find_in_set('收费',drug_status) > 0")
233
+	if is_charge == 1 {
234
+		//if is_charge == 1 {
235
+		//	db = db.Where("find_in_set('收费',drug_status) > 0")
236
+		//
237
+		//} else {
238
+		//	db = db.Where("find_in_set('收费',drug_status) = 0")
239
+		//}
240
+		db = db.Where("is_record = ?", is_charge)
241
+	}
237 242
 
238
-		} else {
239
-			db = db.Where("find_in_set('收费',drug_status) = 0")
240
-		}
243
+	if is_charge == 2 {
244
+		db = db.Where("is_record= 0 || is_record = 2")
241 245
 	}
242 246
 
243 247
 	if is_inject != 0 {

+ 2 - 2
service/print_data_service/schedule_dialysis/print_schedule_dialysis_service.go Ver fichero

@@ -50,7 +50,7 @@ func GetSchedules(orgID int64, schIDs []string) ([]*ScheduleVM, error) {
50 50
 		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
51 51
 			return db.Where("user_org_id = ? AND status = 1", orgID).Preload("HisProject").Preload("GoodInfo", "status=1")
52 52
 		}).
53
-		Where("user_org_id = ? AND status = 1 AND id in (?)", orgID, schIDs).Order("schedule_date desc").
53
+		Where("user_org_id = ? AND status = 1 AND id in (?)", orgID, schIDs).Order("schedule_date asc").
54 54
 		Find(&schedules).
55 55
 		Error
56 56
 	if err != nil {
@@ -119,7 +119,7 @@ func GetAllName(orgId int64, appid int64) (list []AdminUserListTwo, err error) {
119 119
 
120 120
 func GetPatientCoursesRecords(orgID int64, id []string) (records []*models.PatientDiseaseCourse, err error) {
121 121
 	db := p_service.XTReadDB()
122
-	err = db.Model(&models.PatientDiseaseCourse{}).Where("org_id = ? and id in(?) and status = 1", orgID, id).Find(&records).Error
122
+	err = db.Model(&models.PatientDiseaseCourse{}).Where("org_id = ? and id in(?) and status = 1", orgID, id).Order("record_time desc").Find(&records).Error
123 123
 	return
124 124
 }
125 125
 

+ 4 - 2
service/schedule_service.go Ver fichero

@@ -1101,8 +1101,10 @@ func GetPatientScheduleTempalate(orgid int64) (models.PatientScheduleTemplateMod
1101 1101
 	return mode, err
1102 1102
 }
1103 1103
 
1104
-func GetSolutionSchedule(orgid int64) (solution []*models.DialysisSolution, err error) {
1104
+func GetSolutionSchedule(orgid int64) (solution []*models.VmDialysisSolution, err error) {
1105 1105
 
1106
-	err = XTReadDB().Where("user_org_id = ? and status = 1", orgid).Group("patient_id,mode_id").Order("created_time desc").Find(&solution).Error
1106
+	err = XTReadDB().Where("user_org_id = ? and status = 1", orgid).Group("patient_id,mode_id").Order("created_time desc").Preload("DialysisSolution", func(db *gorm.DB) *gorm.DB {
1107
+		return db.Where("user_org_id = ? and status = 1", orgid).Order("id asc")
1108
+	}).Find(&solution).Error
1107 1109
 	return solution, err
1108 1110
 }

+ 12 - 0
service/self_drug_service.go Ver fichero

@@ -136,6 +136,18 @@ func GetBaseDrugMedical(id int64) (models.XtBaseDrug, error) {
136 136
 	return drug, err
137 137
 }
138 138
 
139
+func ModifyDrugWarehouseByInfoId(id int64, stock_max_number int64) error {
140
+	info := models.DrugWarehouseInfo{}
141
+	err := XTWriteDB().Model(&info).Where("id = ?", id).UpdateColumn("stock_max_number", gorm.Expr("stock_max_number - ?", stock_max_number)).Error
142
+	return err
143
+}
144
+
145
+func ModifyDrugWarehouseByStockMin(id int64, stock_min_number int64) error {
146
+	info := models.DrugWarehouseInfo{}
147
+	err := XTWriteDB().Model(&info).Where("id = ?", id).UpdateColumn("stock_min_number", gorm.Expr("stock_min_number - ?", stock_min_number)).Error
148
+	return err
149
+}
150
+
139 151
 func GetSelfMedicalByDrugName(drugname string, drug_spec string, patientid int64) (*models.XtSelfMedical, error) {
140 152
 	medical := models.XtSelfMedical{}
141 153
 	err := XTReadDB().Model(&medical).Where("drug_name = ? and drug_spec = ? and patient_id = ? and status = 1", drugname, drug_spec, patientid).Find(&medical).Error

+ 14 - 13
service/stock_service.go Ver fichero

@@ -268,7 +268,7 @@ func FindGoodInfoList(orgId int64, page int64, limit int64, keyword string, is_u
268 268
 		likeKey := "%" + keyword + "%"
269 269
 		db = db.Where("good_code LIKE ? OR good_name LIKE ?", likeKey, likeKey)
270 270
 		if is_use > 0 {
271
-			if is_use == 1 {
271
+			if is_use == 2 {
272 272
 				db = db.Where("find_in_set('停用',good_status) = 0")
273 273
 			} else {
274 274
 				db = db.Where("find_in_set('停用',good_status) > 0")
@@ -296,7 +296,7 @@ func FindGoodInfoList(orgId int64, page int64, limit int64, keyword string, is_u
296 296
 		}
297 297
 	} else {
298 298
 		if is_use > 0 {
299
-			if is_use == 1 {
299
+			if is_use == 2 {
300 300
 				db = db.Where("find_in_set('停用',good_status) = 0")
301 301
 			} else {
302 302
 				db = db.Where("find_in_set('停用',good_status) > 0")
@@ -454,11 +454,11 @@ func CreateDrugWarehousingInfo(warehousingInfo []*models.DrugWarehouseInfo) (err
454 454
 	if len(warehousingInfo) > 0 {
455 455
 		utx := writeDb.Begin()
456 456
 		if len(warehousingInfo) > 0 {
457
-			thisSQL := "INSERT INTO xt_drug_warehouse_info (warehousing_id, drug_id, number, product_date,expiry_date,warehousing_count,price,total_price,dealer,manufacturer,remark,ctime,mtime,status,org_id,warehousing_order,type,retail_price,retail_total_price,stock_max_number,max_unit,min_unit,batch_number) VALUES "
457
+			thisSQL := "INSERT INTO xt_drug_warehouse_info (warehousing_id, drug_id, number, product_date,expiry_date,warehousing_count,price,total_price,dealer,manufacturer,remark,ctime,mtime,status,org_id,warehousing_order,type,retail_price,retail_total_price,stock_max_number,max_unit,min_unit,batch_number,stock_min_number) VALUES "
458 458
 			insertParams := make([]string, 0)
459 459
 			insertData := make([]interface{}, 0)
460 460
 			for _, info := range warehousingInfo {
461
-				insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
461
+				insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
462 462
 				insertData = append(insertData, info.WarehousingId)
463 463
 				insertData = append(insertData, info.DrugId)
464 464
 				insertData = append(insertData, info.Number)
@@ -482,6 +482,7 @@ func CreateDrugWarehousingInfo(warehousingInfo []*models.DrugWarehouseInfo) (err
482 482
 				insertData = append(insertData, info.MaxUnit)
483 483
 				insertData = append(insertData, info.MinUnit)
484 484
 				insertData = append(insertData, info.BatchNumber)
485
+				insertData = append(insertData, info.StockMinNumber)
485 486
 			}
486 487
 			thisSQL += strings.Join(insertParams, ", ")
487 488
 			err = utx.Exec(thisSQL, insertData...).Error
@@ -861,6 +862,8 @@ type VMDrugWarehouseInfo struct {
861 862
 	RetailPrice      float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
862 863
 	RetailTotalPrice float64 `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
863 864
 	BatchNumber      string  `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
865
+	MaxUnit          string  `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
866
+	MinUnit          string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
864 867
 	Drug             *Drug   `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug"`
865 868
 }
866 869
 
@@ -2065,7 +2068,7 @@ func UpDateDrugWarehousingInfo(info *models.DrugWarehouseInfo) (err error) {
2065 2068
 }
2066 2069
 
2067 2070
 func UpDateDrugWarehousingInfoTwo(id int64, info *models.DrugWarehouseInfo) (err error) {
2068
-	err = writeDb.Model(&info).Where("id= ? and status = 1", id).Updates(map[string]interface{}{"number": info.Number, "product_date": info.ProductDate, "expiry_date": info.ExpiryDate, "price": info.Price, "total_price": info.TotalPrice, "dealer": info.Dealer, "manufacturer": info.Manufacturer, "remark": info.Remark, "batch_number": info.BatchNumber}).Error
2071
+	err = writeDb.Model(&info).Where("id= ? and status = 1", id).Updates(map[string]interface{}{"number": info.Number, "product_date": info.ProductDate, "expiry_date": info.ExpiryDate, "price": info.Price, "total_price": info.TotalPrice, "dealer": info.Dealer, "manufacturer": info.Manufacturer, "remark": info.Remark, "batch_number": info.BatchNumber, "max_unit": info.MaxUnit, "min_unit": info.MinUnit, "retail_price": info.RetailPrice}).Error
2069 2072
 	return err
2070 2073
 }
2071 2074
 
@@ -2076,13 +2079,6 @@ func GetDrugWarehouseOrderOne(id int64, drug_id int64) (models.DrugWarehouseInfo
2076 2079
 	return info, err
2077 2080
 }
2078 2081
 
2079
-func GetDrugWarehouseOrder(id int64) (models.DrugWarehouseInfo, error) {
2080
-
2081
-	info := models.DrugWarehouseInfo{}
2082
-	err = XTReadDB().Model(&info).Where("id = ?", id).Find(&info).Error
2083
-	return info, err
2084
-}
2085
-
2086 2082
 func EditWarehousing(warehouse models.Warehousing) {
2087 2083
 	err = readDb.Model(&models.Warehousing{}).Where("warehousing_order = ? AND status = 1", warehouse.WarehousingOrder).Update(map[string]interface{}{"mtime": time.Now().Unix(), "warehousing_time": warehouse.WarehousingTime, "modifier": warehouse.Modifier, "dealer": warehouse.Dealer, "manufacturer": warehouse.Manufacturer}).Error
2088 2084
 
@@ -2431,6 +2427,11 @@ func DeleteCancelStock(ids []string) (err error) {
2431 2427
 	return
2432 2428
 }
2433 2429
 
2430
+func GetDrugWareInfoByCancelId(ids []string) (info []*models.DrugCancelStockInfo, err error) {
2431
+	err = XTReadDB().Where("cancel_stock_id IN(?) and status = 1", ids).Find(&info).Error
2432
+	return info, err
2433
+}
2434
+
2434 2435
 func DeleteDrugCancelStock(ids []string) (err error) {
2435 2436
 	ut := writeDb.Begin()
2436 2437
 	err = ut.Model(&models.DrugCancelStock{}).Where("id IN (?)", ids).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
@@ -4940,7 +4941,7 @@ func UpdateStockFlow(flow models.VmStockFlow, goodid int64, warehousing_id int64
4940 4941
 func UpdateDrugFlow(flow models.DrugFlow, drugid int64, warehousing_id int64) error {
4941 4942
 
4942 4943
 	drugFlow := models.DrugFlow{}
4943
-	err := XTWriteDB().Model(&drugFlow).Where("drug_id = ? and warehousing_id= ? and status = 1", drugid, warehousing_id).Updates(map[string]interface{}{"count": flow.Count}).Error
4944
+	err := XTWriteDB().Model(&drugFlow).Where("drug_id = ? and warehousing_id= ? and status = 1", drugid, warehousing_id).Updates(map[string]interface{}{"count": flow.Count, "max_unit": flow.MaxUnit, "min_unit": flow.MinUnit}).Error
4944 4945
 	return err
4945 4946
 }
4946 4947