Просмотр исходного кода

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

csx 3 лет назад
Родитель
Сommit
da48e83b09

+ 2 - 2
conf/app.conf Просмотреть файл

@@ -1,6 +1,6 @@
1 1
 appname = 血透
2
-httpport = 9529
3
-runmode = dev
2
+httpport = 9531
3
+runmode = prod
4 4
 
5 5
 #
6 6
 copyrequestbody = true

+ 1 - 1
controllers/device_api_controller.go Просмотреть файл

@@ -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

+ 117 - 32
controllers/drug_stock_api_contorller.go Просмотреть файл

@@ -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,35 +613,46 @@ 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{
602
-						WarehousingOrder: warehousing.WarehousingOrder,
603
-						WarehousingId:    id,
604
-						DrugId:           drug_id,
605
-						Number:           number,
606
-						ProductDate:      productDates,
607
-						ExpireDate:       expiryDates,
608
-						Count:            warehousing_count,
609
-						Price:            last_price,
610
-						Status:           1,
611
-						Ctime:            ctime,
612
-						UserOrgId:        adminUserInfo.CurrentOrgId,
613
-						Manufacturer:     manufacturer,
614
-						Dealer:           dealer,
615
-						BatchNumber:      batch_number,
616
-						MaxUnit:          max_unit,
617
-						MinUnit:          min_unit,
618
-						ConsumableType:   1,
619
-						IsEdit:           1,
620
-						Creator:          adminUserInfo.AdminUser.Id,
621
-						IsSys:            0,
631
+						WarehousingOrder:    warehousing.WarehousingOrder,
632
+						WarehousingId:       warehouse.ID,
633
+						DrugId:              drug_id,
634
+						Number:              number,
635
+						ProductDate:         productDates,
636
+						ExpireDate:          expiryDates,
637
+						Count:               warehousing_count,
638
+						Price:               last_price,
639
+						Status:              1,
640
+						Ctime:               ctime,
641
+						UserOrgId:           adminUserInfo.CurrentOrgId,
642
+						Manufacturer:        manufacturer,
643
+						Dealer:              dealer,
644
+						BatchNumber:         batch_number,
645
+						MaxUnit:             max_unit,
646
+						MinUnit:             min_unit,
647
+						ConsumableType:      1,
648
+						IsEdit:              1,
649
+						Creator:             adminUserInfo.AdminUser.Id,
650
+						IsSys:               0,
651
+						WarehousingDetailId: id,
652
+					}
653
+
654
+					if max_unit == min_unit {
655
+						drugflow.MaxUnit = min_unit
622 656
 					}
623 657
 
624 658
 					drugFlow = append(drugFlow, drugflow)
@@ -658,6 +692,9 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
658 692
 					IsSys:               0,
659 693
 					WarehousingDetailId: info.ID,
660 694
 				}
695
+				if info.MaxUnit == info.MinUnit {
696
+					flows.MaxUnit = info.MinUnit
697
+				}
661 698
 				_, existerrcodes := service.GetDrugFlowIsExist(info.ID, info.DrugId)
662 699
 
663 700
 				if existerrcodes == gorm.ErrRecordNotFound {
@@ -682,7 +719,6 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
682 719
 			//历史入库总数
683 720
 			total = orderInfo.StockMaxNumber * info.MinNumber
684 721
 
685
-			//当前入库总数
686 722
 			allTotal = item.WarehousingCount * info.MinNumber
687 723
 
688 724
 			//如果历史的入库总数 大于当前入库总数 则需要扣减
@@ -719,20 +755,27 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
719 755
 			//比较大小(加)
720 756
 			// 如果当前的入库数量 大于 历史入库数量
721 757
 			if item.WarehousingCount > warehouseInfo.WarehousingCount {
758
+				fmt.Println("大于333333333333333333333333")
722 759
 				total = item.WarehousingCount - warehouseInfo.WarehousingCount
723 760
 				item.StockMaxNumber = warehouseInfo.StockMaxNumber + total
724 761
 				errs = service.UpDateDrugWarehousingInfo(item)
725 762
 				if len(drugFlow) > 0 {
726 763
 					for _, it := range drugFlow {
727 764
 						flow := models.DrugFlow{
728
-							Count:        item.StockMaxNumber,
765
+							Count:        it.Count,
729 766
 							Manufacturer: it.Manufacturer,
730 767
 							Dealer:       it.Dealer,
731 768
 							Number:       it.Number,
732 769
 							BatchNumber:  it.BatchNumber,
733 770
 							Price:        it.Price,
771
+							MaxUnit:      info.MaxUnit,
772
+							ExpireDate:   it.ExpireDate,
734 773
 						}
735
-						parseDateErr := service.UpdateDrugFlow(flow, item.DrugId, warehouseInfo.WarehousingId)
774
+						if info.MaxUnit == info.MinUnit {
775
+							flow.MaxUnit = info.MinUnit
776
+						}
777
+
778
+						parseDateErr := service.UpdateDrugFlowNight(flow, it.DrugId, it.WarehousingDetailId)
736 779
 						fmt.Println(parseDateErr)
737 780
 
738 781
 					}
@@ -747,11 +790,19 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
747 790
 				errs = service.UpDateDrugWarehousingInfo(item)
748 791
 				if len(drugFlow) > 0 {
749 792
 					for _, it := range drugFlow {
750
-						fmt.Println(it)
751 793
 						flow := models.DrugFlow{
752
-							Count: item.StockMaxNumber,
794
+							Count:       it.Count,
795
+							MaxUnit:     it.MaxUnit,
796
+							MinUnit:     it.MinUnit,
797
+							Number:      it.Number,
798
+							BatchNumber: it.BatchNumber,
799
+							Price:       it.Price,
800
+							ExpireDate:  it.ExpireDate,
801
+						}
802
+						if info.MaxUnit == info.MinUnit {
803
+							flow.MaxUnit = info.MinUnit
753 804
 						}
754
-						parseDateErr := service.UpdateDrugFlow(flow, item.DrugId, warehouseInfo.WarehousingId)
805
+						parseDateErr := service.UpdateDrugFlowNight(flow, it.DrugId, it.WarehousingDetailId)
755 806
 						fmt.Println(parseDateErr)
756 807
 					}
757 808
 				}
@@ -770,6 +821,27 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
770 821
 					Manufacturer: item.Manufacturer,
771 822
 					Remark:       item.Remark,
772 823
 					BatchNumber:  item.BatchNumber,
824
+					MaxUnit:      item.MaxUnit,
825
+					MinUnit:      item.MinUnit,
826
+					RetailPrice:  item.RetailPrice,
827
+				}
828
+				if len(drugFlow) > 0 {
829
+					for _, it := range drugFlow {
830
+						flow := models.DrugFlow{
831
+							Count:       it.Count,
832
+							MaxUnit:     it.MaxUnit,
833
+							MinUnit:     it.MinUnit,
834
+							Number:      it.Number,
835
+							BatchNumber: it.BatchNumber,
836
+							Price:       it.Price,
837
+							ExpireDate:  it.ExpireDate,
838
+						}
839
+						if info.MaxUnit == info.MinUnit {
840
+							flow.MaxUnit = info.MinUnit
841
+						}
842
+						parseDateErr := service.UpdateDrugFlowNight(flow, it.DrugId, it.WarehousingDetailId)
843
+						fmt.Println(parseDateErr)
844
+					}
773 845
 				}
774 846
 				errs = service.UpDateDrugWarehousingInfoTwo(item.ID, warehouseinfo)
775 847
 			}
@@ -2408,7 +2480,6 @@ func (c *StockDrugApiController) CreateDrugCancelStock() {
2408 2480
 		infoWareInfo, _ := service.GetDrugWarehouseInfo(item.BatchNumberId)
2409 2481
 		var total_count int64
2410 2482
 		total_count = infoWareInfo.WarehousingCount * medical.MinNumber
2411
-		fmt.Println("当前批次总库存", total_count)
2412 2483
 
2413 2484
 		//查询该批次的出库数量
2414 2485
 		outInfo, _ := service.GetDrugWarehouseOutInfo(item.BatchNumberId, item.DrugId)
@@ -2448,7 +2519,9 @@ func (c *StockDrugApiController) CreateDrugCancelStock() {
2448 2519
 			})
2449 2520
 			return
2450 2521
 		}
2451
-
2522
+		fmt.Println("当前退库数", total_count)
2523
+		fmt.Println("当前批次总库存", total_count)
2524
+		fmt.Println("总出库数", out_number)
2452 2525
 		//判断退库数量是否大于总入库数量
2453 2526
 		if total_number > total_count {
2454 2527
 			service.UpdateDrugCancel(item.CancelStockId)
@@ -2614,6 +2687,18 @@ func (this *StockDrugApiController) DeleteDrugCancelStock() {
2614 2687
 	}
2615 2688
 
2616 2689
 	idArray := strings.Split(ids, ",")
2690
+	//获取入库数据
2691
+	list, _ := service.GetDrugWareInfoByCancelId(idArray)
2692
+	for _, item := range list {
2693
+		medical, _ := service.GetBaseDrugMedical(item.DrugId)
2694
+		if item.MaxUnit == medical.MaxUnit {
2695
+			//回退库存
2696
+			service.ModifyDrugWarehouseByInfoId(item.CancelStockId, item.Count)
2697
+		}
2698
+		if item.MaxUnit == medical.MinUnit {
2699
+			service.ModifyDrugWarehouseByStockMin(item.CancelStockId, item.Count)
2700
+		}
2701
+	}
2617 2702
 	err := service.DeleteDrugCancelStock(idArray)
2618 2703
 	if err != nil {
2619 2704
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteFail)
@@ -2625,7 +2710,7 @@ func (this *StockDrugApiController) DeleteDrugCancelStock() {
2625 2710
 }
2626 2711
 func (this *StockDrugApiController) DeleteDrugCancelStockInfo() {
2627 2712
 	id, _ := this.GetInt64("id", 0)
2628
-	fmt.Println(id)
2713
+
2629 2714
 	if id == 0 {
2630 2715
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2631 2716
 		return

+ 20 - 9
controllers/his_api_controller.go Просмотреть файл

@@ -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
 										}
@@ -905,6 +902,7 @@ func (c *HisApiController) CreateHisPrescription() {
905 902
 									//for _, it := range goodWarehouseInfo {
906 903
 									//	total_count += it.Count
907 904
 									//}
905
+
908 906
 									if len(goodWarehouseInfo) == 0 {
909 907
 										//查询耗材库存
910 908
 										list, _ := service.GetGoodWarehouseInfoSeven(project_id)
@@ -918,18 +916,27 @@ func (c *HisApiController) CreateHisPrescription() {
918 916
 											c.ServeDynamicFailJsonSend(project_name + "库存不足")
919 917
 											return
920 918
 										}
919
+										//查找今日该患者已经出库的所有耗材
920
+										goodList, _ := service.GetAllAutoRecordByPatient(patient_id, recordDateTime)
921
+
922
+										for _, item := range goodList {
923
+											//回退库存
924
+											service.ModefyWarehouseInfo(item.Count, item.WarehouseInfotId)
925
+										}
926
+										//删除记录
927
+										service.DeleteAutoWarehouse(patient_id, recordDateTime)
921 928
 									}
922 929
 									if len(goodWarehouseInfo) > 0 {
923 930
 										//查询该患者耗材的历史数据
924 931
 										ordProject, _ := service.GetHisProjectPrescriptionByPatientIdOne(id)
932
+
925 933
 										count, _ := strconv.ParseInt(ordProject.Count, 10, 64)
926
-										fmt.Println("parsetotal33223232323232323", parsetotal)
927
-										fmt.Println("count2332322332232332", count)
934
+
928 935
 										//数量发生改变
929 936
 										if parsetotal != count {
930 937
 											//查找今日该患者已经出库的所有耗材
931 938
 											goodList, _ := service.GetAllAutoRecordByPatient(patient_id, recordDateTime)
932
-											fmt.Println("goodList3323223232323232323", goodList)
939
+
933 940
 											for _, item := range goodList {
934 941
 												//回退库存
935 942
 												service.ModefyWarehouseInfo(item.Count, item.WarehouseInfotId)
@@ -2355,6 +2362,10 @@ func (c *HisApiController) DeleteProject() {
2355 2362
 	service.CreateHisLabelRecord(&label)
2356 2363
 
2357 2364
 	if stockConfig.IsOpen == 1 {
2365
+		if project.Type == 2 {
2366
+			err := service.DelelteProject(id, c.GetAdminUserInfo().CurrentOrgId)
2367
+			fmt.Println(err)
2368
+		}
2358 2369
 		if project.Type == 3 {
2359 2370
 			good, _ := service.FindGoodInfoByIdTwo(project.ProjectId)
2360 2371
 			f_count, _ := strconv.ParseFloat(project.Count, 64)

+ 22 - 7
controllers/new_mobile_api_controllers/staff_schedule_api_controller.go Просмотреть файл

@@ -309,13 +309,11 @@ func (this *StaffScheduleApiController) GetPatientScheduleList() {
309 309
 func (this *StaffScheduleApiController) DeleteSchedule() {
310 310
 	id, _ := this.GetInt64("id")
311 311
 	fmt.Println("id", id)
312
-	err := service.DeleteSchedule(id)
312
+
313 313
 	org_id := this.GetMobileAdminUserInfo().Org.Id
314
-	schedule, _ := service.GetSchedule(org_id, id)
315
-	if schedule == nil {
316
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeScheduleNotExist)
317
-		return
318
-	}
314
+	err := service.DeleteSchedule(id)
315
+	schedule, _ := service.GetScheduleNight(org_id, id)
316
+
319 317
 	redis := service.RedisClient()
320 318
 
321 319
 	//处方
@@ -339,9 +337,10 @@ func (this *StaffScheduleApiController) DeleteSchedule() {
339 337
 
340 338
 	keySeven := strconv.FormatInt(org_id, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":dialysis_orders_list_all"
341 339
 	redis.Set(keySeven, "", time.Second)
342
-	fmt.Println(err)
340
+
343 341
 	defer redis.Close()
344 342
 	fmt.Println(err)
343
+
345 344
 	returnData := make(map[string]interface{}, 0)
346 345
 	returnData["msg"] = "ok"
347 346
 	this.ServeSuccessJSON(returnData)
@@ -706,3 +705,19 @@ func (c *StaffScheduleApiController) CreateMobileSchedulePatient() {
706 705
 	return
707 706
 
708 707
 }
708
+
709
+func (c *StaffScheduleApiController) GetSolutionSchedule() {
710
+
711
+	orgId := c.GetMobileAdminUserInfo().Org.Id
712
+	scheduleDate := c.GetString("start_time")
713
+	zoneid, _ := c.GetInt64("zoneid")
714
+	classtype, _ := c.GetInt64("classtype")
715
+	timeLayout := "2006-01-02"
716
+	loc, _ := time.LoadLocation("Local")
717
+	theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", scheduleDate+" 00:00:00", loc)
718
+	fmt.Println("时间错2332233323223", theTime.Unix())
719
+	schedule, _ := service.GetSolutionScheduleBySchedule(orgId, zoneid, classtype, theTime.Unix())
720
+	c.ServeSuccessJSON(map[string]interface{}{
721
+		"schedule": schedule,
722
+	})
723
+}

+ 1 - 0
controllers/new_mobile_api_controllers/staff_schedule_api_router.go Просмотреть файл

@@ -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 Просмотреть файл

@@ -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
 

+ 6 - 11
controllers/print_data_api_controller.go Просмотреть файл

@@ -39,10 +39,15 @@ func (this *PrintDataAPIController) ScheduleDialysisRecordPrintData() {
39 39
 	schedules, getScheduleErr := service.GetSchedules(adminUserInfo.CurrentOrgId, idStrs)
40 40
 	for _, item := range schedules {
41 41
 		list, _ := service.GetDialysisOrderCountSeven(item.PatientID, item.ScheduleDate)
42
-		if this.GetAdminUserInfo().CurrentOrgId != 10101 {
42
+		if this.GetAdminUserInfo().CurrentOrgId != 10101 && this.GetAdminUserInfo().CurrentOrgId != 9671 {
43 43
 			item.Count = list.Count
44 44
 		}
45
+		if this.GetAdminUserInfo().CurrentOrgId == 10101 || this.GetAdminUserInfo().CurrentOrgId == 9671 {
46
+			listOne, _ := service.GetDialysisOrderCountEight(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
45 47
 
48
+			item.Patient.TotalDialysis = listOne.Count
49
+			item.Count = listOne.Count
50
+		}
46 51
 	}
47 52
 	if getScheduleErr != nil {
48 53
 		this.ErrorLog("获取打印透析记录失败:%v", getScheduleErr)
@@ -124,17 +129,7 @@ func (this *PrintDataAPIController) CourseRecordPrintData() {
124 129
 	adminUserInfo := this.GetAdminUserInfo()
125 130
 	patient_id, _ := this.GetInt64("patient_id")
126 131
 
127
-	//timeLayout := "2006-01-02 15:04:05"
128 132
 	record, err := service.GetPatientCoursesRecords(adminUserInfo.CurrentOrgId, ids_arr)
129
-	//dataTimeStr := time.Unix(record.RecordTime, 0).Format(timeLayout) //设置时间戳 使用模板格式化为日期字符串
130
-	//tempTime := strings.Split(dataTimeStr, " ")
131
-	//
132
-	//recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", tempTime[0])
133
-	//if parseDateErr != nil {
134
-	//	this.ErrorLog("日期(%v)解析错误:%v", tempTime[0], parseDateErr)
135
-	//	//this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
136
-	//	//return
137
-	//}
138 133
 
139 134
 	//patient, _ := service.FindPatientWithDeviceById(adminUserInfo.CurrentOrgId, patient_id)
140 135
 	patient, _ := service.GetPatientDetail(adminUserInfo.CurrentOrgId, patient_id)

+ 2 - 3
controllers/schedule_api_controller.go Просмотреть файл

@@ -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
 	})

+ 159 - 81
controllers/stock_in_api_controller.go Просмотреть файл

@@ -303,14 +303,32 @@ func (c *StockManagerApiController) CreateWarehouse() {
303 303
 		}
304 304
 	}
305 305
 
306
-	//入库单创建成功
307
-	errs := service.CreateWarehousingInfo(warehousingInfo)
308
-	for _, its := range stockFlow {
309
-		warehousinginfo, _ := service.GetLastWarehousingInfo(its.GoodId)
310
-		its.WarehousingDetailId = warehousinginfo.ID
306
+	for _, item := range warehousingInfo {
307
+		service.CreatedWarehouseingDetail(item)
308
+		warehousinginfo, _ := service.GetLastWarehousingInfo(item.GoodId)
309
+		flow := models.VmStockFlow{
310
+			WarehousingOrder:    item.WarehousingOrder,
311
+			WarehousingId:       item.WarehousingId,
312
+			GoodId:              item.GoodId,
313
+			Number:              item.Number,
314
+			ProductDate:         item.ProductDate,
315
+			ExpireDate:          item.ExpiryDate,
316
+			Count:               item.StockCount,
317
+			Price:               item.Price,
318
+			Status:              1,
319
+			Ctime:               ctime,
320
+			UserOrgId:           item.OrgId,
321
+			Manufacturer:        item.Manufacturer,
322
+			Dealer:              item.Dealer,
323
+			LicenseNumber:       item.LicenseNumber,
324
+			IsEdit:              1,
325
+			Creator:             adminUserInfo.AdminUser.Id,
326
+			SystemTime:          operation_time,
327
+			ConsumableType:      1,
328
+			WarehousingDetailId: warehousinginfo.ID,
329
+		}
330
+		service.CreateStockFlowOne(flow)
311 331
 	}
312
-	//创建入库单流水
313
-	service.CreateStockFlow(stockFlow)
314 332
 
315 333
 	info, _ := service.FindLastWarehousingInfo(warehousing.WarehousingOrder)
316 334
 
@@ -328,12 +346,6 @@ func (c *StockManagerApiController) CreateWarehouse() {
328 346
 		fmt.Println(parseDateErr)
329 347
 	}
330 348
 
331
-	if errs != nil {
332
-		utils.ErrorLog(errs.Error())
333
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockInFail)
334
-		return
335
-	}
336
-
337 349
 	c.ServeSuccessJSON(map[string]interface{}{
338 350
 		"msg":               "入库成功",
339 351
 		"warehousing_order": warehousing_order,
@@ -695,17 +707,18 @@ func (c *StockManagerApiController) EditWarehouse() {
695 707
 
696 708
 				service.UpdateWarehouseInfoByGoodId(goodinfo, item.ID)
697 709
 
698
-				flowStock := models.VmStockFlow{
699
-					Count:         item.WarehousingCount,
700
-					Number:        item.Number,
701
-					ProductDate:   item.ProductDate,
702
-					ExpireDate:    item.ExpiryDate,
703
-					Price:         item.Price,
704
-					Manufacturer:  item.Manufacturer,
705
-					Dealer:        item.Dealer,
706
-					LicenseNumber: info.LicenseNumber,
707
-				}
708
-				service.UpdatedStockFlowByGoodIdOne(item.WarehousingId, item.GoodId, flowStock)
710
+				//flowStock := models.VmStockFlow{
711
+				//	Count:         item.WarehousingCount,
712
+				//	Number:        item.Number,
713
+				//	ProductDate:   item.ProductDate,
714
+				//	ExpireDate:    item.ExpiryDate,
715
+				//	Price:         item.Price,
716
+				//	Manufacturer:  item.Manufacturer,
717
+				//	Dealer:        item.Dealer,
718
+				//	LicenseNumber: info.LicenseNumber,
719
+				//}
720
+				//fmt.Println("大于233232322323233232232323233232233223")
721
+				//service.UpdatedStockFlowByGoodIdOne(item.WarehousingId, item.GoodId, flowStock)
709 722
 				//改变库存
710 723
 				good, _ := service.GetLastInfoMationById(info.GoodId)
711 724
 				warhouseCount := strconv.FormatInt(total, 10)
@@ -758,9 +771,16 @@ func (c *StockManagerApiController) EditWarehouse() {
758 771
 	if len(stockFlow) > 0 {
759 772
 		for _, item := range stockFlow {
760 773
 			flow := models.VmStockFlow{
761
-				Count: item.Count,
762
-			}
763
-			parseDateErr := service.UpdateStockFlow(flow, item.GoodId, item.WarehousingId)
774
+				Count:         item.Count,
775
+				Number:        item.Number,
776
+				ProductDate:   item.ProductDate,
777
+				ExpireDate:    item.ExpireDate,
778
+				Price:         item.Price,
779
+				Manufacturer:  item.Manufacturer,
780
+				Dealer:        item.Dealer,
781
+				LicenseNumber: item.LicenseNumber,
782
+			}
783
+			parseDateErr := service.UpdatedStockFlowByGoodIdOne(item.WarehousingId, item.GoodId, flow)
764 784
 			fmt.Println(parseDateErr)
765 785
 		}
766 786
 	}
@@ -2034,7 +2054,7 @@ func (c *StockManagerApiController) CreateCancelStock() {
2034 2054
 	}
2035 2055
 
2036 2056
 	var cancelStockInfos []*models.CancelStockInfo
2037
-	var stockFLow []*models.VmStockFlow
2057
+	//var stockFLow []*models.VmStockFlow
2038 2058
 	if dataBody["cancelStock"] != nil && reflect.TypeOf(dataBody["cancelStock"]).String() == "[]interface {}" {
2039 2059
 		thisStockIn, _ := dataBody["cancelStock"].([]interface{})
2040 2060
 		if len(thisStockIn) > 0 {
@@ -2131,48 +2151,48 @@ func (c *StockManagerApiController) CreateCancelStock() {
2131 2151
 				}
2132 2152
 				cancelStockInfos = append(cancelStockInfos, cancelStockInfo)
2133 2153
 
2134
-				list, _ := service.GetAllManufacturerList(adminUserInfo.CurrentOrgId)
2135
-
2136
-				var manufacturer_id int64
2137
-
2138
-				for _, items := range list {
2139
-					if manufacturer == items.ManufacturerName {
2140
-						manufacturer_id = items.ID
2141
-					}
2142
-				}
2143
-
2144
-				flow := &models.VmStockFlow{
2145
-					WarehousingId:           0,
2146
-					GoodId:                  good_id,
2147
-					Number:                  number,
2148
-					LicenseNumber:           "",
2149
-					Count:                   count,
2150
-					UserOrgId:               adminUserInfo.CurrentOrgId,
2151
-					PatientId:               0,
2152
-					SystemTime:              time.Now().Unix(),
2153
-					ConsumableType:          4,
2154
-					IsSys:                   0,
2155
-					WarehousingOrder:        "",
2156
-					WarehouseOutId:          0,
2157
-					WarehouseOutOrderNumber: "",
2158
-					IsEdit:                  0,
2159
-					CancelStockId:           cancelStock.ID,
2160
-					CancelOrderNumber:       cancelStock.OrderNumber,
2161
-					Manufacturer:            manufacturer_id,
2162
-					Dealer:                  0,
2163
-					Creator:                 adminUserInfo.AdminUser.Id,
2164
-					UpdateCreator:           0,
2165
-					Status:                  1,
2166
-					Ctime:                   time.Now().Unix(),
2167
-					Mtime:                   0,
2168
-					Price:                   price,
2169
-					WarehousingDetailId:     0,
2170
-					WarehouseOutDetailId:    0,
2171
-					CancelOutDetailId:       0,
2172
-					ProductDate:             productDates,
2173
-					ExpireDate:              expiryDates,
2174
-				}
2175
-				stockFLow = append(stockFLow, flow)
2154
+				//list, _ := service.GetAllManufacturerList(adminUserInfo.CurrentOrgId)
2155
+				//
2156
+				//var manufacturer_id int64
2157
+
2158
+				//for _, items := range list {
2159
+				//	if manufacturer == items.ManufacturerName {
2160
+				//		manufacturer_id = items.ID
2161
+				//	}
2162
+				//}
2163
+
2164
+				//flow := &models.VmStockFlow{
2165
+				//	WarehousingId:           0,
2166
+				//	GoodId:                  good_id,
2167
+				//	Number:                  number,
2168
+				//	LicenseNumber:           "",
2169
+				//	Count:                   count,
2170
+				//	UserOrgId:               adminUserInfo.CurrentOrgId,
2171
+				//	PatientId:               0,
2172
+				//	SystemTime:              time.Now().Unix(),
2173
+				//	ConsumableType:          4,
2174
+				//	IsSys:                   0,
2175
+				//	WarehousingOrder:        "",
2176
+				//	WarehouseOutId:          0,
2177
+				//	WarehouseOutOrderNumber: "",
2178
+				//	IsEdit:                  0,
2179
+				//	CancelStockId:           cancelStock.ID,
2180
+				//	CancelOrderNumber:       cancelStock.OrderNumber,
2181
+				//	Manufacturer:            manufacturer_id,
2182
+				//	Dealer:                  0,
2183
+				//	Creator:                 adminUserInfo.AdminUser.Id,
2184
+				//	UpdateCreator:           0,
2185
+				//	Status:                  1,
2186
+				//	Ctime:                   time.Now().Unix(),
2187
+				//	Mtime:                   0,
2188
+				//	Price:                   price,
2189
+				//	WarehousingDetailId:     0,
2190
+				//	WarehouseOutDetailId:    0,
2191
+				//	CancelOutDetailId:       0,
2192
+				//	ProductDate:             productDates,
2193
+				//	ExpireDate:              expiryDates,
2194
+				//}
2195
+				//stockFLow = append(stockFLow, flow)
2176 2196
 			}
2177 2197
 		}
2178 2198
 	}
@@ -2208,17 +2228,50 @@ func (c *StockManagerApiController) CreateCancelStock() {
2208 2228
 
2209 2229
 			item.CancelStockId = listcancel.ID
2210 2230
 			errs := service.CreateCancelStockInfoOne(item)
2231
+			list, _ := service.GetAllManufacturerList(adminUserInfo.CurrentOrgId)
2211 2232
 
2212
-			if len(stockFLow) > 0 {
2213
-
2214
-				for _, items := range stockFLow {
2215
-					cancelStockInfo, _ := service.GetLastCancelStockInfoByGoodId(item.GoodId)
2216
-					items.CancelStockId = listcancel.ID
2217
-					items.CancelOutDetailId = cancelStockInfo.ID
2233
+			var manufacturer_id int64
2218 2234
 
2235
+			for _, items := range list {
2236
+				if item.Manufacturer == items.ManufacturerName {
2237
+					manufacturer_id = items.ID
2219 2238
 				}
2220
-				service.CreateStockFlow(stockFLow)
2221 2239
 			}
2240
+			flow := models.VmStockFlow{
2241
+				WarehousingId:           0,
2242
+				GoodId:                  item.GoodId,
2243
+				Number:                  item.Number,
2244
+				LicenseNumber:           "",
2245
+				Count:                   item.Count,
2246
+				UserOrgId:               adminUserInfo.CurrentOrgId,
2247
+				PatientId:               0,
2248
+				SystemTime:              time.Now().Unix(),
2249
+				ConsumableType:          4,
2250
+				IsSys:                   0,
2251
+				WarehousingOrder:        "",
2252
+				WarehouseOutId:          0,
2253
+				WarehouseOutOrderNumber: "",
2254
+				IsEdit:                  0,
2255
+				CancelStockId:           cancelStock.ID,
2256
+				CancelOrderNumber:       cancelStock.OrderNumber,
2257
+				Manufacturer:            manufacturer_id,
2258
+				Dealer:                  0,
2259
+				Creator:                 adminUserInfo.AdminUser.Id,
2260
+				UpdateCreator:           0,
2261
+				Status:                  1,
2262
+				Ctime:                   time.Now().Unix(),
2263
+				Mtime:                   0,
2264
+				Price:                   item.Price,
2265
+				WarehousingDetailId:     0,
2266
+				WarehouseOutDetailId:    0,
2267
+				CancelOutDetailId:       0,
2268
+				ProductDate:             item.ProductDate,
2269
+				ExpireDate:              item.ExpiryDate,
2270
+			}
2271
+			cancelStockInfo, _ := service.GetLastCancelStockInfoByGoodId(item.GoodId)
2272
+			flow.CancelStockId = cancelStockInfo.CancelStockId
2273
+			flow.CancelOutDetailId = cancelStockInfo.ID
2274
+			service.CreateStockFlowOne(flow)
2222 2275
 			if errs != nil {
2223 2276
 				utils.ErrorLog(errs.Error())
2224 2277
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCancelStockFail)
@@ -2315,7 +2368,21 @@ func (this *StockManagerApiController) DeleteCancelStock() {
2315 2368
 	}
2316 2369
 
2317 2370
 	idArray := strings.Split(ids, ",")
2371
+	//获取
2372
+	list, _ := service.GetCancelWarehosueInfo(idArray)
2373
+	for _, item := range list {
2374
+		info, _ := service.GetCancelStockById(item.WarehouseInfoId)
2375
+		warehousingInfo := models.WarehousingInfo{
2376
+			StockCount: info.Count,
2377
+		}
2378
+		//扣减库存
2379
+		service.ModefyWarehouseInfoNight(warehousingInfo, info.WarehouseInfoId)
2380
+		//删除流水
2381
+		service.UpdatedStockFlowByCancelId(info.ID, info.GoodId)
2382
+	}
2383
+	//获取
2318 2384
 	err := service.DeleteCancelStock(idArray)
2385
+
2319 2386
 	if err != nil {
2320 2387
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteFail)
2321 2388
 	} else {
@@ -2332,8 +2399,19 @@ func (this *StockManagerApiController) DeleteCancelStockInfo() {
2332 2399
 		return
2333 2400
 	}
2334 2401
 
2402
+	//改变库存
2403
+	info, _ := service.GetCancelStockById(id)
2404
+
2405
+	warehousingInfo := models.WarehousingInfo{
2406
+		StockCount: info.Count,
2407
+	}
2408
+	//扣减库存
2409
+	service.ModefyWarehouseInfoNight(warehousingInfo, info.WarehouseInfoId)
2410
+	//删除详情
2335 2411
 	err := service.UpDateCancleStockStatus(id)
2336
-	service.UpdatedStockFlowByCancelId(id)
2412
+	//删除流水
2413
+	err = service.UpdatedStockFlowByCancelId(id, info.GoodId)
2414
+
2337 2415
 	if err != nil {
2338 2416
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteFail)
2339 2417
 	} else {
@@ -2637,7 +2715,6 @@ func (c *StockManagerApiController) EditCancelStock() {
2637 2715
 
2638 2716
 		if len(stockFlow) > 0 {
2639 2717
 			for _, itemcancel := range stockFlow {
2640
-				fmt.Println("hhh233232323323233223323232我的时间")
2641 2718
 				//查询是否存在
2642 2719
 				stockInfo, errcode := service.IsExsitStockFlow(itemcancel.GoodId, itemcancel.CancelOrderNumber)
2643 2720
 				if errcode == gorm.ErrRecordNotFound {
@@ -2668,8 +2745,6 @@ func (c *StockManagerApiController) EditCancelStock() {
2668 2745
 			for _, it := range list {
2669 2746
 				all_total += it.Count
2670 2747
 			}
2671
-			fmt.Println("最后一次出库233223323233223", info.Count)
2672
-			fmt.Println("当前出库23323223232323323", item.Count)
2673 2748
 
2674 2749
 			//比较退库库数量和最后一次退库库数据大小
2675 2750
 			//退库(加)
@@ -2709,6 +2784,7 @@ func (c *StockManagerApiController) EditCancelStock() {
2709 2784
 			}
2710 2785
 			if item.Count == info.Count {
2711 2786
 				errs = service.UpDateCancelStockInfo(item)
2787
+
2712 2788
 			}
2713 2789
 		}
2714 2790
 	}
@@ -2727,6 +2803,8 @@ func (c *StockManagerApiController) EditCancelStock() {
2727 2803
 					Price:         itemcancel.Price,
2728 2804
 					LicenseNumber: itemcancel.LicenseNumber,
2729 2805
 					Number:        itemcancel.Number,
2806
+					ExpireDate:    itemcancel.ExpireDate,
2807
+					ProductDate:   itemcancel.ProductDate,
2730 2808
 				}
2731 2809
 				service.UpdateStockFlowThree(stockInfo.ID, flow)
2732 2810
 			}

+ 61 - 0
models/patient_models.go Просмотреть файл

@@ -1505,3 +1505,64 @@ 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
+}
1553
+
1554
+type XtScheduleList struct {
1555
+	UserOrgId        int64              `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1556
+	PartitionId      int64              `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
1557
+	BedId            int64              `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
1558
+	PatientId        int64              `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1559
+	ScheduleDate     int64              `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
1560
+	ScheduleType     int64              `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
1561
+	ScheduleWeek     int64              `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
1562
+	ModeId           int64              `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
1563
+	DialysisSolution VmDialysisSolution `gorm:"ForeignKey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId" json:"vmsolution"`
1564
+}
1565
+
1566
+func (XtScheduleList) TableName() string {
1567
+	return "xt_schedule"
1568
+}

+ 1 - 0
models/self_drug_models.go Просмотреть файл

@@ -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 Просмотреть файл

@@ -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 Просмотреть файл

@@ -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 {

+ 20 - 9
service/print_data_service/schedule_dialysis/print_schedule_dialysis_service.go Просмотреть файл

@@ -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 {
@@ -63,10 +63,10 @@ func GetSchedules(orgID int64, schIDs []string) ([]*ScheduleVM, error) {
63 63
 			item.Patient.TotalDialysis = dialysis_count
64 64
 
65 65
 		}
66
-		if orgID == 10101 {
67
-			dialysis_count, _ := GetDialysisOrderCountOne(orgID, item.PatientID, item.ScheduleDate)
68
-			item.Patient.TotalDialysis = dialysis_count
69
-		}
66
+		//if orgID == 10101 {
67
+		//	dialysis_count, _ := GetDialysisOrderCountOne(orgID, item.PatientID, item.ScheduleDate)
68
+		//	item.Patient.TotalDialysis = dialysis_count
69
+		//}
70 70
 	}
71 71
 	return schedules, nil
72 72
 }
@@ -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 asc").Find(&records).Error
123 123
 	return
124 124
 }
125 125
 
@@ -211,9 +211,20 @@ func GetDialysisOrderCountSeven(patient_id int64, recordDate int64) (models.VmDi
211 211
 	return order, err
212 212
 }
213 213
 
214
-func GetDialysisOrderCountOne(orgID int64, patient_id int64, recordDate int64) (count int64, err error) {
215
-	err = p_service.XTReadDB().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
216
-	return
214
+//func GetDialysisOrderCountOne(orgID int64, patient_id int64, recordDate int64) (count int64, err error) {
215
+//	err = p_service.XTReadDB().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
216
+//	return
217
+//}
218
+
219
+//func GetDialysisOrderCountOne(orgID int64, patient_id int64, recordDate int64) (count int64, err error) {
220
+//	err = p_service.XTReadDB().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
221
+//	return
222
+//}
223
+
224
+func GetDialysisOrderCountEight(orgID int64, patient_id int64, recordDate int64) (models.VmDialysisOrder, error) {
225
+	order := models.VmDialysisOrder{}
226
+	err := p_service.XTReadDB().Raw("SELECT Count(id) as count,Max(dialysis_date) as dialysis_date  from xt_dialysis_order where dialysis_date>=1640966400 and dialysis_date <= ? AND status = 1 AND stage = 2 AND patient_id = ? and user_org_id = ?", recordDate, patient_id, orgID).Scan(&order).Error
227
+	return order, err
217 228
 }
218 229
 
219 230
 func GetOutStockTotalCountTwo(startime int64, endtime int64, orgid int64) (autoMatic []*models.NewXtAutomaticReduceDetail, err error) {

+ 37 - 2
service/schedule_service.go Просмотреть файл

@@ -242,6 +242,16 @@ func GetSchedule(orgID, id int64) (*models.Schedule, error) {
242 242
 	return &schedule, nil
243 243
 }
244 244
 
245
+func GetScheduleNight(orgID, id int64) (*models.Schedule, error) {
246
+	var schedule models.Schedule
247
+	var err error
248
+	err = readDb.Model(&models.Schedule{}).Where("id = ? and user_org_id=?", id, orgID).First(&schedule).Error
249
+	if err != nil {
250
+		return nil, err
251
+	}
252
+	return &schedule, nil
253
+}
254
+
245 255
 func UpdateSchedule(m *models.Schedule) error {
246 256
 	utx := XTWriteDB().Begin()
247 257
 	err := utx.Save(&m).Error
@@ -1101,8 +1111,33 @@ func GetPatientScheduleTempalate(orgid int64) (models.PatientScheduleTemplateMod
1101 1111
 	return mode, err
1102 1112
 }
1103 1113
 
1104
-func GetSolutionSchedule(orgid int64) (solution []*models.DialysisSolution, err error) {
1114
+func GetSolutionSchedule(orgid int64) (solution []*models.VmDialysisSolution, err error) {
1105 1115
 
1106
-	err = XTReadDB().Where("user_org_id = ? and status = 1", orgid).Group("patient_id,mode_id").Order("created_time desc").Find(&solution).Error
1116
+	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 {
1117
+		return db.Where("user_org_id = ? and status = 1", orgid).Order("id asc")
1118
+	}).Find(&solution).Error
1107 1119
 	return solution, err
1108 1120
 }
1121
+
1122
+func GetSolutionScheduleBySchedule(orgid int64, zonid int64, classtype int64, schedule_date int64) (schedule []*models.XtScheduleList, err error) {
1123
+
1124
+	db := XTReadDB().Model(&schedule).Where("status = 1")
1125
+	if orgid > 0 {
1126
+		db = db.Where("user_org_id =?", orgid)
1127
+	}
1128
+	if zonid > 0 {
1129
+		db = db.Where("partition_id = ?", zonid)
1130
+	}
1131
+	if classtype > 0 {
1132
+		db = db.Where("schedule_type = ?", classtype)
1133
+	}
1134
+	if schedule_date > 0 {
1135
+		db = db.Where("schedule_date = ?", schedule_date)
1136
+	}
1137
+	err = db.Preload("DialysisSolution", func(db *gorm.DB) *gorm.DB {
1138
+		return db.Where("user_org_id = ? and status = 1", orgid).Group("patient_id,mode_id").Order("created_time asc").Preload("DialysisSolution", func(db *gorm.DB) *gorm.DB {
1139
+			return db.Where("user_org_id = ? and status = 1", orgid).Order("id asc")
1140
+		})
1141
+	}).Find(&schedule).Error
1142
+	return schedule, err
1143
+}

+ 12 - 0
service/self_drug_service.go Просмотреть файл

@@ -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

+ 42 - 23
service/stock_service.go Просмотреть файл

@@ -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
@@ -658,12 +659,6 @@ func UpdateDrugFlowTens(patientid int64, warehouse_out_number string, drug_id in
658 659
 	return flow, err
659 660
 }
660 661
 
661
-func UpdateDrugFlowTen(patientid int64, warehouse_out_number string, drug_id int64) (models.DrugFlow, error) {
662
-	flow := models.DrugFlow{}
663
-	err := XTWriteDB().Model(&flow).Where("patient_id =? and warehouse_out_order_number = ? and drug_id = ? and status = 1", patientid, warehouse_out_number, drug_id).Updates(map[string]interface{}{"status": 0}).Error
664
-	return flow, err
665
-}
666
-
667 662
 func CreateDrugFlowTwo(flow *models.DrugFlow) error {
668 663
 
669 664
 	err := XTWriteDB().Create(&flow).Error
@@ -682,6 +677,12 @@ func GetLastWarehousingInfo(goodid int64) (models.WarehousingInfo, error) {
682 677
 	return info, err
683 678
 }
684 679
 
680
+func CreatedWarehouseingDetail(info *models.WarehousingInfo) error {
681
+
682
+	err := XTWriteDB().Create(&info).Error
683
+	return err
684
+}
685
+
685 686
 func FindFirstWarehousingInfoByStock(good_id int64, good_type_id int64) (info models.WarehousingInfo, err error) {
686 687
 	err = readDb.Model(&models.WarehousingInfo{}).Where("good_id = ? AND good_type_id = ? AND status = 1 and stock_count > 0", good_id, good_type_id).Order("ctime").First(&info).Error
687 688
 	return info, err
@@ -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
 
@@ -2410,6 +2406,12 @@ func FindAllDrugCancelList(orgId int64, page int64, limit int64, startTime int64
2410 2406
 	return
2411 2407
 }
2412 2408
 
2409
+func GetCancelWarehosueInfo(ids []string) (info []*models.CancelStockInfo, err error) {
2410
+
2411
+	err = XTReadDB().Where("id IN(?) and status = 1", ids).Find(&info).Error
2412
+	return info, err
2413
+}
2414
+
2413 2415
 func DeleteCancelStock(ids []string) (err error) {
2414 2416
 	ut := writeDb.Begin()
2415 2417
 	err = ut.Model(&models.CancelStock{}).Where("id IN (?)", ids).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
@@ -2431,6 +2433,11 @@ func DeleteCancelStock(ids []string) (err error) {
2431 2433
 	return
2432 2434
 }
2433 2435
 
2436
+func GetDrugWareInfoByCancelId(ids []string) (info []*models.DrugCancelStockInfo, err error) {
2437
+	err = XTReadDB().Where("cancel_stock_id IN(?) and status = 1", ids).Find(&info).Error
2438
+	return info, err
2439
+}
2440
+
2434 2441
 func DeleteDrugCancelStock(ids []string) (err error) {
2435 2442
 	ut := writeDb.Begin()
2436 2443
 	err = ut.Model(&models.DrugCancelStock{}).Where("id IN (?)", ids).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
@@ -2457,9 +2464,21 @@ func UpDateCancleStockStatus(id int64) (err error) {
2457 2464
 	return
2458 2465
 }
2459 2466
 
2460
-func UpdatedStockFlowByCancelId(id int64) (err error) {
2467
+func GetCancelStockById(id int64) (models.CancelStockInfo, error) {
2468
+	info := models.CancelStockInfo{}
2469
+	err := XTReadDB().Model(&info).Where("id = ? and status = 1", id).Find(&info).Error
2470
+	return info, err
2471
+}
2472
+
2473
+func ModefyWarehouseInfoNight(info models.WarehousingInfo, id int64) error {
2474
+
2475
+	err := XTWriteDB().Model(&info).Where("id = ? and status = 1", id).UpdateColumn("stock_count", gorm.Expr("stock_count - ?", info.StockCount)).Error
2476
+	return err
2477
+}
2478
+
2479
+func UpdatedStockFlowByCancelId(id int64, good_id int64) (err error) {
2461 2480
 
2462
-	err = XTWriteDB().Model(&models.CancelStockInfo{}).Where("cancel_out_detail_id = ? and status = 0", id).Updates(map[string]interface{}{"status": 0}).Error
2481
+	err = XTWriteDB().Model(&models.VmStockFlow{}).Where("cancel_out_detail_id = ? and status = 1 and good_id = ?", id, good_id).Updates(map[string]interface{}{"status": 0}).Error
2463 2482
 	return
2464 2483
 }
2465 2484
 
@@ -4940,14 +4959,14 @@ func UpdateStockFlow(flow models.VmStockFlow, goodid int64, warehousing_id int64
4940 4959
 func UpdateDrugFlow(flow models.DrugFlow, drugid int64, warehousing_id int64) error {
4941 4960
 
4942 4961
 	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
4962
+	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, "price": flow.Price, "expire_date": flow.ExpireDate}).Error
4944 4963
 	return err
4945 4964
 }
4946 4965
 
4947 4966
 func UpdateDrugFlowNight(flow models.DrugFlow, drugid int64, warehousing_id int64) error {
4948 4967
 
4949 4968
 	drugFlow := models.DrugFlow{}
4950
-	err := XTWriteDB().Model(&drugFlow).Where("drug_id = ? and warehousing_id= ? and status = 1", drugid, warehousing_id).Updates(map[string]interface{}{"count": flow.Count, "manufacturer": flow.Manufacturer, "dealer": flow.Dealer, "number": flow.Number, "batch_number": flow.BatchNumber, "price": flow.Price}).Error
4969
+	err := XTWriteDB().Model(&drugFlow).Where("drug_id = ? and warehousing_detail_id= ? and status = 1", drugid, warehousing_id).Updates(map[string]interface{}{"count": flow.Count, "max_unit": flow.MaxUnit, "min_unit": flow.MinUnit, "price": flow.Price, "expire_date": flow.ExpireDate}).Error
4951 4970
 	return err
4952 4971
 }
4953 4972
 
@@ -5543,7 +5562,7 @@ func UpdateStockFlowTwo(id int64, flow models.VmStockFlow) error {
5543 5562
 
5544 5563
 func UpdateStockFlowThree(id int64, flow models.VmStockFlow) error {
5545 5564
 
5546
-	err := XTWriteDB().Model(&flow).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"count": flow.Count, "manufacturer": flow.Count, "dealer": flow.Dealer, "number": flow.Number, "license_number": flow.LicenseNumber, "price": flow.Price}).Error
5565
+	err := XTWriteDB().Model(&flow).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"count": flow.Count, "manufacturer": flow.Count, "dealer": flow.Dealer, "number": flow.Number, "license_number": flow.LicenseNumber, "price": flow.Price, "product_date": flow.ProductDate, "expire_date": flow.ExpireDate}).Error
5547 5566
 	return err
5548 5567
 }
5549 5568