csx před 3 roky
rodič
revize
a6c4b4ccaa

+ 303 - 0
controllers/doctors_api_controller.go Zobrazit soubor

@@ -9,6 +9,7 @@ import (
9 9
 	"github.com/astaxie/beego"
10 10
 	"github.com/jinzhu/gorm"
11 11
 	"strconv"
12
+	"strings"
12 13
 	"time"
13 14
 )
14 15
 
@@ -39,6 +40,17 @@ func DoctorApiRegistRouters() {
39 40
 	beego.Router("/api/patient/updatepasswayassesment", &DoctorsApiController{}, "Get:UpdatePassWayAssesment")
40 41
 	beego.Router("/api/patient/deletepasswayassessment", &DoctorsApiController{}, "Get:DeleteWayAssessment")
41 42
 	beego.Router("/api/patient/getaccesslist", &DoctorsApiController{}, "Get:GetAccessList")
43
+
44
+	//阶段小结路由
45
+	beego.Router("/api/patient/getinspectionmajoritem", &DoctorsApiController{}, "Get:GetInspectionMajorItem")
46
+	beego.Router("/api/patient/getinspectiondetail", &DoctorsApiController{}, "Get:GetInspectionDetailByProject")
47
+	beego.Router("/api/patient/getinspectionitemlist", &DoctorsApiController{}, "Get:GetInspectionItemlist")
48
+	beego.Router("/api/patient/getinitdatelist", &DoctorsApiController{}, "Get:GetInitDateList")
49
+	beego.Router("/api/patient/savecreationinspection", &DoctorsApiController{}, "Get:SaveCreationInspection")
50
+	beego.Router("/api/patient/getemlatesummarylist", &DoctorsApiController{}, "Get:GetTemplateSummaryList")
51
+	beego.Router("/api/patient/gettemplatesummarydetail", &DoctorsApiController{}, "Get:GetTemplateSummaryDetail")
52
+	beego.Router("/api/patient/gettemplatesummaryprintdetail", &DoctorsApiController{}, "Get:GetTemplateSummaryPrintDetail")
53
+	beego.Router("/api/patient/updatetemplatesummary", &DoctorsApiController{}, "Get:UpdateTempalteSummary")
42 54
 }
43 55
 
44 56
 func (c *DoctorsApiController) ScheduleAdvices() {
@@ -661,3 +673,294 @@ func (this *DoctorsApiController) GetAccessList() {
661 673
 		return
662 674
 	}
663 675
 }
676
+
677
+func (this *DoctorsApiController) GetInspectionMajorItem() {
678
+
679
+	other_start_time := this.GetString("other_start_time")
680
+	timeLayout := "2006-01-02"
681
+	loc, _ := time.LoadLocation("Local")
682
+	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", other_start_time+" 23:59:59", loc)
683
+	fmt.Println("startTime2222345555533344334334433433344", startTime.Unix())
684
+	patient_id, _ := this.GetInt64("patient_id")
685
+	adminUserInfo := this.GetAdminUserInfo()
686
+	orgId := adminUserInfo.CurrentOrgId
687
+	list, err := service.GetInspectionMajorItem(startTime.Unix(), orgId, patient_id)
688
+	if err == nil {
689
+		this.ServeSuccessJSON(map[string]interface{}{
690
+			"list": list,
691
+		})
692
+		return
693
+	}
694
+}
695
+
696
+func (this *DoctorsApiController) GetInspectionDetailByProject() {
697
+
698
+	project_id, _ := this.GetInt64("project_id")
699
+	patient_id, _ := this.GetInt64("patient_id")
700
+	inspect_date, _ := this.GetInt64("inspect_date")
701
+	orgId := this.GetAdminUserInfo().CurrentOrgId
702
+	list, err := service.GetInspectionDetailByProject(project_id, patient_id, inspect_date, orgId)
703
+	if err == nil {
704
+		this.ServeSuccessJSON(map[string]interface{}{
705
+			"list": list,
706
+		})
707
+		return
708
+	}
709
+}
710
+
711
+func (this *DoctorsApiController) GetInspectionItemlist() {
712
+	patient_id, _ := this.GetInt64("patient_id")
713
+	ids := this.GetString("ids")
714
+	inspect_date := this.GetString("inspect_date")
715
+	idSplit := strings.Split(ids, ",")
716
+	indateSplit := strings.Split(inspect_date, ",")
717
+	list, err := service.GetInspectionItemlist(patient_id, indateSplit, idSplit)
718
+	if err == nil {
719
+		this.ServeSuccessJSON(map[string]interface{}{
720
+			"list": list,
721
+		})
722
+		return
723
+	}
724
+}
725
+
726
+func (this *DoctorsApiController) GetInitDateList() {
727
+	patient_id, _ := this.GetInt64("patient_id")
728
+
729
+	prescription_list, _ := service.GetDialysisPrescriptionDataList(patient_id)
730
+	befor_list, err := service.GetDialysisBeforInitDateList(patient_id)
731
+	after_list, err := service.GetDialysisAssementAfter(patient_id)
732
+	//统计透析次数
733
+	modelist, err := service.GetDialysisDialysisMode(patient_id)
734
+	orgId := this.GetAdminUserInfo().CurrentOrgId
735
+	docList, _ := service.GetAllDoctorThree(orgId)
736
+	stockType, err := service.GetStockType(orgId)
737
+
738
+	summaryList, err := service.GetTemplateSummary(orgId)
739
+	planList, err := service.GetTemplatePlan(orgId)
740
+	if err == nil {
741
+		this.ServeSuccessJSON(map[string]interface{}{
742
+			"beforlist":         befor_list,
743
+			"prescription_list": prescription_list,
744
+			"after_list":        after_list,
745
+			"modelist":          modelist,
746
+			"docList":           docList,
747
+			"stockType":         stockType,
748
+			"summaryList":       summaryList,
749
+			"planList":          planList,
750
+		})
751
+		return
752
+	}
753
+}
754
+
755
+func (this *DoctorsApiController) SaveCreationInspection() {
756
+
757
+	title := this.GetString("title")
758
+	dry_weight, _ := this.GetFloat("dry_weight")
759
+	fmt.Println("hhhhhhhhhhhhh", dry_weight)
760
+	dialysis_count, _ := this.GetInt64("dialysis_count")
761
+	hd_count, _ := this.GetInt64("hd_count")
762
+	hdf_count, _ := this.GetInt64("hdf_count")
763
+	hp_count, _ := this.GetInt64("hp_count")
764
+	other_count, _ := this.GetInt64("other_count")
765
+	dialzer_apparatus := this.GetString("dialzer_apparatus")
766
+	perfusion_apparatus := this.GetString("perfusion_apparatus")
767
+	anticoagulant, _ := this.GetInt64("anticoagulant")
768
+	fmt.Println(anticoagulant)
769
+	kalium, _ := this.GetFloat("kalium")
770
+	autunite, _ := this.GetFloat("autunite")
771
+	natrium, _ := this.GetFloat("natrium")
772
+	hour, _ := this.GetInt64("hour")
773
+	minute, _ := this.GetInt64("minute")
774
+	befor_weight, _ := this.GetFloat("befor_weight")
775
+	after_weight, _ := this.GetFloat("after_weight")
776
+	befor_pressure := this.GetString("befor_pressure")
777
+	template_summary_content := this.GetString("template_summary_content")
778
+	template_plan_content := this.GetString("template_plan_content")
779
+	template_inspection_content := this.GetString("template_inspection_content")
780
+	fmt.Println("hhhh232233232232332232323", template_inspection_content)
781
+	admin_user_id, _ := this.GetInt64("admin_user_id")
782
+	record_time := this.GetString("record_time")
783
+	timeLayout := "2006-01-02"
784
+	loc, _ := time.LoadLocation("Local")
785
+	recordTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
786
+	after_pressure := this.GetString("after_pressure")
787
+	template_summary_id, _ := this.GetInt64("template_summary_id")
788
+	template_plan_id, _ := this.GetInt64("template_plan_id")
789
+	template_inspection_id, _ := this.GetInt64("template_inspection_id")
790
+	patient_id, _ := this.GetInt64("patient_id")
791
+	fmt.Println("patient_id", patient_id)
792
+	orgId := this.GetAdminUserInfo().CurrentOrgId
793
+	summary := models.XtTemplateSummary{
794
+		StartYear:                 0,
795
+		StartMonth:                0,
796
+		Radio:                     0,
797
+		Quarter:                   0,
798
+		DryWeight:                 dry_weight,
799
+		DialysisCount:             dialysis_count,
800
+		HdCount:                   hd_count,
801
+		HdfCount:                  hdf_count,
802
+		HpCount:                   hp_count,
803
+		OtherCount:                other_count,
804
+		DialzerApparatus:          dialzer_apparatus,
805
+		PerfusionApparatus:        perfusion_apparatus,
806
+		Anticoagulant:             anticoagulant,
807
+		Kalium:                    kalium,
808
+		Autunite:                  autunite,
809
+		Natrium:                   natrium,
810
+		Hour:                      hour,
811
+		Minute:                    minute,
812
+		BeforWeight:               befor_weight,
813
+		AfterWeight:               after_weight,
814
+		BeforPressure:             befor_pressure,
815
+		AfterPressure:             after_pressure,
816
+		TemplateSummaryId:         template_summary_id,
817
+		TemplateSummaryContent:    template_summary_content,
818
+		TemplatePlanId:            template_plan_id,
819
+		TemplatePlanContent:       template_plan_content,
820
+		TemplateInspectionId:      template_inspection_id,
821
+		TemplateInspectionContent: template_inspection_content,
822
+		AdminUserId:               admin_user_id,
823
+		RecordTime:                recordTime.Unix(),
824
+		PatientId:                 patient_id,
825
+		UserOrgId:                 orgId,
826
+		Status:                    1,
827
+		Ctime:                     time.Now().Unix(),
828
+		Mtime:                     0,
829
+		Title:                     title,
830
+	}
831
+
832
+	err := service.CreateSummary(&summary)
833
+	if err == nil {
834
+		this.ServeSuccessJSON(map[string]interface{}{
835
+			"summary": summary,
836
+		})
837
+		return
838
+	}
839
+
840
+}
841
+
842
+func (this *DoctorsApiController) GetTemplateSummaryList() {
843
+	patient_id, _ := this.GetInt64("patient_id")
844
+	orgId := this.GetAdminUserInfo().CurrentOrgId
845
+	list, err := service.GetTemplateSummaryList(patient_id, orgId)
846
+	if err == nil {
847
+		this.ServeSuccessJSON(map[string]interface{}{
848
+			"list": list,
849
+		})
850
+		return
851
+	}
852
+}
853
+
854
+func (this *DoctorsApiController) GetTemplateSummaryDetail() {
855
+
856
+	id, _ := this.GetInt64("id")
857
+	list, err := service.GetTemplateSummaryDetail(id)
858
+	if err == nil {
859
+		this.ServeSuccessJSON(map[string]interface{}{
860
+			"list": list,
861
+		})
862
+		return
863
+	}
864
+}
865
+
866
+func (this *DoctorsApiController) GetTemplateSummaryPrintDetail() {
867
+
868
+	id, _ := this.GetInt64("id")
869
+	list, err := service.GetTemplateSummaryPrintDetail(id)
870
+	orgId := this.GetAdminUserInfo().CurrentOrgId
871
+	doctorList, _ := service.GetAllDoctorThree(orgId)
872
+	if err == nil {
873
+		this.ServeSuccessJSON(map[string]interface{}{
874
+			"list":       list,
875
+			"doctorList": doctorList,
876
+		})
877
+		return
878
+	}
879
+}
880
+
881
+func (this *DoctorsApiController) UpdateTempalteSummary() {
882
+
883
+	id, _ := this.GetInt64("id")
884
+	title := this.GetString("title")
885
+	dry_weight, _ := this.GetFloat("dry_weight")
886
+	fmt.Println("hhhhhhhhhhhhh", dry_weight)
887
+	dialysis_count, _ := this.GetInt64("dialysis_count")
888
+	hd_count, _ := this.GetInt64("hd_count")
889
+	hdf_count, _ := this.GetInt64("hdf_count")
890
+	hp_count, _ := this.GetInt64("hp_count")
891
+	other_count, _ := this.GetInt64("other_count")
892
+	dialzer_apparatus := this.GetString("dialzer_apparatus")
893
+	perfusion_apparatus := this.GetString("perfusion_apparatus")
894
+	anticoagulant, _ := this.GetInt64("anticoagulant")
895
+	fmt.Println(anticoagulant)
896
+	kalium, _ := this.GetFloat("kalium")
897
+	autunite, _ := this.GetFloat("autunite")
898
+	natrium, _ := this.GetFloat("natrium")
899
+	hour, _ := this.GetInt64("hour")
900
+	minute, _ := this.GetInt64("minute")
901
+	befor_weight, _ := this.GetFloat("befor_weight")
902
+	after_weight, _ := this.GetFloat("after_weight")
903
+	befor_pressure := this.GetString("befor_pressure")
904
+	template_summary_content := this.GetString("template_summary_content")
905
+	template_plan_content := this.GetString("template_plan_content")
906
+	template_inspection_content := this.GetString("template_inspection_content")
907
+	fmt.Println("hhhh232233232232332232323", template_inspection_content)
908
+	admin_user_id, _ := this.GetInt64("admin_user_id")
909
+	record_time := this.GetString("record_time")
910
+	timeLayout := "2006-01-02"
911
+	loc, _ := time.LoadLocation("Local")
912
+	recordTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
913
+	after_pressure := this.GetString("after_pressure")
914
+	template_summary_id, _ := this.GetInt64("template_summary_id")
915
+	template_plan_id, _ := this.GetInt64("template_plan_id")
916
+	template_inspection_id, _ := this.GetInt64("template_inspection_id")
917
+	patient_id, _ := this.GetInt64("patient_id")
918
+	fmt.Println("patient_id", patient_id)
919
+	orgId := this.GetAdminUserInfo().CurrentOrgId
920
+	summary := models.XtTemplateSummary{
921
+		ID:                        id,
922
+		StartYear:                 0,
923
+		StartMonth:                0,
924
+		Radio:                     0,
925
+		Quarter:                   0,
926
+		DryWeight:                 dry_weight,
927
+		DialysisCount:             dialysis_count,
928
+		HdCount:                   hd_count,
929
+		HdfCount:                  hdf_count,
930
+		HpCount:                   hp_count,
931
+		OtherCount:                other_count,
932
+		DialzerApparatus:          dialzer_apparatus,
933
+		PerfusionApparatus:        perfusion_apparatus,
934
+		Anticoagulant:             anticoagulant,
935
+		Kalium:                    kalium,
936
+		Autunite:                  autunite,
937
+		Natrium:                   natrium,
938
+		Hour:                      hour,
939
+		Minute:                    minute,
940
+		BeforWeight:               befor_weight,
941
+		AfterWeight:               after_weight,
942
+		BeforPressure:             befor_pressure,
943
+		AfterPressure:             after_pressure,
944
+		TemplateSummaryId:         template_summary_id,
945
+		TemplateSummaryContent:    template_summary_content,
946
+		TemplatePlanId:            template_plan_id,
947
+		TemplatePlanContent:       template_plan_content,
948
+		TemplateInspectionId:      template_inspection_id,
949
+		TemplateInspectionContent: template_inspection_content,
950
+		AdminUserId:               admin_user_id,
951
+		RecordTime:                recordTime.Unix(),
952
+		PatientId:                 patient_id,
953
+		UserOrgId:                 orgId,
954
+		Status:                    1,
955
+		Ctime:                     time.Now().Unix(),
956
+		Mtime:                     0,
957
+		Title:                     title,
958
+	}
959
+	err := service.UpdateTempalteSummary(&summary)
960
+	if err == nil {
961
+		this.ServeSuccessJSON(map[string]interface{}{
962
+			"list": summary,
963
+		})
964
+		return
965
+	}
966
+}

+ 264 - 22
controllers/drug_stock_api_contorller.go Zobrazit soubor

@@ -68,6 +68,8 @@ func DrugStockManagerApiRegistRouters() {
68 68
 
69 69
 	beego.Router("/api/drug/getcanceldrugorderprint", &StockDrugApiController{}, "get:GetCancelDrugOrderPrint")
70 70
 	beego.Router("/api/drug/drugcancelexportlist", &StockDrugApiController{}, "get:GetDrugCancelExportList")
71
+	beego.Router("/api/drug/getdrugwarehouseinfoprint", &StockDrugApiController{}, "get:GetDrugWarehouseInfoPrint")
72
+	beego.Router("/api/drug/getdrugoutorderprint", &StockDrugApiController{}, "get:GetDrugOutOrderPrint")
71 73
 }
72 74
 
73 75
 func (c *StockDrugApiController) CreateDrugWarehouse() {
@@ -263,7 +265,23 @@ func (c *StockDrugApiController) CreateDrugWarehouse() {
263 265
 	errs := service.CreateDrugWarehousingInfo(warehousingInfo)
264 266
 	if errs == nil {
265 267
 		//更改库存
266
-		service.UpdateDrugInfo(warehousingInfo)
268
+		var total float64
269
+		var min_number int64
270
+		for _, item := range warehousingInfo {
271
+			//查询刚入库耗材的库存
272
+			wareseInfo, _ := service.FindDrugWaresingCount(item.DrugId, item.OrgId)
273
+			//更新药品库的总量
274
+			info, _ := service.FindeDrugInfo(item.DrugId)
275
+
276
+			min_number = wareseInfo.StockMaxNumber * info.MinNumber
277
+			str := strconv.FormatInt(min_number, 10)
278
+			minFloat, _ := strconv.ParseFloat(str, 64)
279
+			total = info.Total + minFloat
280
+			lib := models.BaseDrugLib{
281
+				Total: total,
282
+			}
283
+			service.UpdateBaseDrug(&lib, item.DrugId)
284
+		}
267 285
 	}
268 286
 	//创建流水单
269 287
 	service.CreateDrugFlow(drugFlow)
@@ -543,6 +561,7 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
543 561
 						BatchNumber:      batch_number,
544 562
 						MaxUnit:          max_unit,
545 563
 						MinUnit:          min_unit,
564
+						StockMaxNumber:   warehousing_count,
546 565
 					}
547 566
 					warehousingInfo = append(warehousingInfo, warehouseInfo)
548 567
 
@@ -567,7 +586,6 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
567 586
 						Dealer:           dealer,
568 587
 						RetailPrice:      last_price,
569 588
 						RetailTotalPrice: retail_price_total,
570
-						StockMaxNumber:   warehousing_count,
571 589
 						MaxUnit:          max_unit,
572 590
 						MinUnit:          min_unit,
573 591
 						BatchNumber:      batch_number,
@@ -576,7 +594,7 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
576 594
 
577 595
 					drugflow := &models.DrugFlow{
578 596
 						WarehousingOrder: warehousing.WarehousingOrder,
579
-						WarehousingId:    warehousing.ID,
597
+						WarehousingId:    id,
580 598
 						DrugId:           drug_id,
581 599
 						Number:           number,
582 600
 						ProductDate:      productDates,
@@ -638,8 +656,34 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
638 656
 				Total: minNumber,
639 657
 			}
640 658
 			service.UpdateBaseDrug(&lib, item.DrugId)
659
+			warehouseInfo, _ := service.FindeLastWarehouseInfo(item.ID)
660
+			fmt.Println("hhhhh23hh32h232332323223", warehouseInfo)
661
+			var total int64
662
+			//比较大小(加)
663
+			if item.WarehousingCount > warehouseInfo.WarehousingCount {
664
+				total = item.WarehousingCount - warehouseInfo.WarehousingCount
665
+			}
666
+			item.StockMaxNumber = warehouseInfo.StockMaxNumber + total
667
+			if item.WarehousingCount < warehouseInfo.WarehousingCount {
668
+				total = warehouseInfo.WarehousingCount - item.WarehousingCount
669
+			}
670
+			item.StockMaxNumber = warehouseInfo.StockMaxNumber - total
671
+			if item.WarehousingCount == warehouseInfo.StockMaxNumber {
672
+
673
+				item.StockMaxNumber = item.WarehousingCount
674
+			}
641 675
 			errs = service.UpDateDrugWarehousingInfo(item)
642
-			service.CreateDrugFlow(drugFlow)
676
+
677
+		}
678
+	}
679
+
680
+	if len(drugFlow) > 0 {
681
+		for _, item := range drugFlow {
682
+			flow := models.DrugFlow{
683
+				Count: item.Count,
684
+			}
685
+			parseDateErr := service.UpdateDrugFlow(flow, item.DrugId, item.WarehousingId)
686
+			fmt.Println(parseDateErr)
643 687
 		}
644 688
 	}
645 689
 
@@ -1152,11 +1196,13 @@ func (c *StockDrugApiController) CreateDrugWarehouseOut() {
1152 1196
 				remark := items["remark"].(string)
1153 1197
 				max_unit := items["max_unit"].(string)
1154 1198
 				dealer := int64(items["dealer"].(float64))
1155
-				fmt.Println("dealer2222222222222222222", dealer)
1199
+
1156 1200
 				manufacturer := int64(items["manufacturer"].(float64))
1157
-				fmt.Println("manufacturer22222222222222", manufacturer)
1201
+
1158 1202
 				number := items["number"].(string)
1159 1203
 				batch_number := items["batch_number"].(string)
1204
+
1205
+				warehouse_info_id := int64(items["warehouse_info_id"].(float64))
1160 1206
 				var productDates int64
1161 1207
 				var expiryDates int64
1162 1208
 				if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "string" {
@@ -1209,6 +1255,7 @@ func (c *StockDrugApiController) CreateDrugWarehouseOut() {
1209 1255
 					Number:                  number,
1210 1256
 					BatchNumber:             batch_number,
1211 1257
 					IsSys:                   0,
1258
+					WarehouseInfoId:         warehouse_info_id,
1212 1259
 				}
1213 1260
 				warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1214 1261
 
@@ -1242,17 +1289,26 @@ func (c *StockDrugApiController) CreateDrugWarehouseOut() {
1242 1289
 	//调用出库逻辑
1243 1290
 	for _, item := range warehousingOutInfo {
1244 1291
 		//获取药品库存
1245
-		info, _ := service.GetDrugTotalCount(item.DrugId, item.OrgId)
1292
+		info, _ := service.GetDrugTotalCountOne(item.DrugId, item.OrgId, item.WarehouseInfoId)
1246 1293
 		//查询改药品信息
1247 1294
 		medical, _ := service.GetBaseDrugMedical(item.DrugId)
1295
+		total_count = info.StockMaxNumber*medical.MinNumber + info.StockMinNumber
1296
+		//for _, it := range info{
1297
+		//  if medical.MaxUnit == it.MaxUnit{
1298
+		//    it.Count = it.StockMaxNumber * medical.MinNumber
1299
+		//  }
1300
+		//  if medical.MinUnit == it.MinUnit{
1301
+		//    it.Count = it.StockMinNumber
1302
+		//  }
1303
+		//  total_count += it.Count
1304
+		//}
1305
+		fmt.Println("总库存23232323232232332232332223", total_count)
1248 1306
 		//判断单位是否相等
1249 1307
 		if medical.MaxUnit == item.CountUnit {
1250 1308
 			//转化为最小单位
1251
-			total_count = info.Count * medical.MinNumber
1252 1309
 			prescribing_number_total = item.Count * medical.MinNumber
1253 1310
 		}
1254 1311
 		if medical.MinUnit == item.CountUnit {
1255
-			total_count = info.Count
1256 1312
 			prescribing_number_total = item.Count
1257 1313
 		}
1258 1314
 
@@ -1521,7 +1577,7 @@ func (c *StockDrugApiController) EditDrugWarehouseOut() {
1521 1577
 				batch_number := items["batch_number"].(string)
1522 1578
 				number := items["number"].(string)
1523 1579
 				max_unit := items["count_unit"].(string)
1524
-
1580
+				warehouse_info_id := int64(items["warehouse_info_id"].(float64))
1525 1581
 				var productDates int64
1526 1582
 				var expiryDates int64
1527 1583
 				if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "string" {
@@ -1551,8 +1607,7 @@ func (c *StockDrugApiController) EditDrugWarehouseOut() {
1551 1607
 					}
1552 1608
 
1553 1609
 				}
1554
-				fmt.Println("生产日期22222222222222222222222222", expiryDates)
1555
-				fmt.Println("生产日期22222222222222222222222222", productDates)
1610
+
1556 1611
 				if id == 0 {
1557 1612
 					warehouseOutInfo := &models.DrugWarehouseOutInfo{
1558 1613
 						WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
@@ -1577,6 +1632,7 @@ func (c *StockDrugApiController) EditDrugWarehouseOut() {
1577 1632
 						ProductDate:             productDates,
1578 1633
 						ExpiryDate:              expiryDates,
1579 1634
 						CountUnit:               count_unit,
1635
+						WarehouseInfoId:         warehouse_info_id,
1580 1636
 					}
1581 1637
 					warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1582 1638
 
@@ -1601,7 +1657,7 @@ func (c *StockDrugApiController) EditDrugWarehouseOut() {
1601 1657
 						Creator:                 adminUserInfo.AdminUser.Id,
1602 1658
 						IsSys:                   0,
1603 1659
 						WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1604
-						WarehouseOutId:          warehouseOut.ID,
1660
+						WarehouseOutId:          id,
1605 1661
 					}
1606 1662
 
1607 1663
 					drugFlow = append(drugFlow, drugflow)
@@ -1646,6 +1702,7 @@ func (c *StockDrugApiController) EditDrugWarehouseOut() {
1646 1702
 						ProductDate:             productDates,
1647 1703
 						ExpiryDate:              expiryDates,
1648 1704
 						CountUnit:               count_unit,
1705
+						WarehouseInfoId:         warehouse_info_id,
1649 1706
 					}
1650 1707
 					upDateWarehouseOutInfos = append(upDateWarehouseOutInfos, warehouseOutInfo)
1651 1708
 
@@ -2147,6 +2204,8 @@ func (c *StockDrugApiController) CreateDrugCancelStock() {
2147 2204
 	//扣减库存逻辑
2148 2205
 	for _, item := range cancelStockInfos {
2149 2206
 		var total_number int64
2207
+		var out_number int64
2208
+		var can_number int64
2150 2209
 		medical, _ := service.GetBaseDrugMedical(item.DrugId)
2151 2210
 		//将当前退库数转为最小单位
2152 2211
 		if item.MaxUnit == medical.MaxUnit {
@@ -2163,15 +2222,62 @@ func (c *StockDrugApiController) CreateDrugCancelStock() {
2163 2222
 		total_count = infoWareInfo.StockMaxNumber*medical.MinNumber + infoWareInfo.StockMinNumber
2164 2223
 		fmt.Println("当前批次总库存", total_count)
2165 2224
 
2225
+		//查询该批次的出库数量
2226
+		outInfo, _ := service.GetDrugWarehouseOutInfo(item.BatchNumberId, item.DrugId)
2227
+		//查询该批次总的退库数量
2228
+
2229
+		canInfo, _ := service.GetCancelDrugStockOutInfo(item.BatchNumberId, item.DrugId)
2230
+		for _, item := range canInfo {
2231
+			if item.MaxUnit == medical.MaxUnit {
2232
+				item.Count = item.Count * medical.MinNumber
2233
+			}
2234
+			if item.MaxUnit == medical.MinUnit {
2235
+				item.Count = item.Count
2236
+			}
2237
+		}
2238
+		for _, item := range canInfo {
2239
+			can_number += item.Count
2240
+		}
2241
+
2242
+		for _, item := range outInfo {
2243
+			if item.CountUnit == medical.MaxUnit {
2244
+				item.Count = item.Count * medical.MinNumber
2245
+			}
2246
+			if item.CountUnit == medical.MinUnit {
2247
+				item.Count = item.Count
2248
+			}
2249
+		}
2250
+		for _, item := range outInfo {
2251
+			out_number += item.Count
2252
+		}
2253
+		fmt.Println("出库数量23232232323222332", out_number)
2254
+		if out_number == 0 {
2255
+			c.ServeSuccessJSON(map[string]interface{}{
2256
+				"msg": "2",
2257
+			})
2258
+			return
2259
+		}
2166 2260
 		//判断退库数量是否大于总入库数量
2167
-		if total_number > total_count {
2261
+		if total_number > out_number {
2262
+			service.UpdateDrugCancel(item.CancelStockId)
2263
+			c.ServeSuccessJSON(map[string]interface{}{
2264
+				"msg": "4",
2265
+			})
2266
+			return
2267
+		}
2268
+
2269
+		//判断总退库数量是否大于出库数量
2270
+		fmt.Println("hhhhhhhhhhh", can_number+total_number)
2271
+		if can_number+total_number > out_number {
2272
+			service.UpdateDrugCancel(item.CancelStockId)
2168 2273
 			c.ServeSuccessJSON(map[string]interface{}{
2169 2274
 				"msg": "2",
2170 2275
 			})
2171 2276
 			return
2172 2277
 		}
2278
+
2173 2279
 		//正常退库
2174
-		if total_number <= total_count {
2280
+		if total_number <= out_number {
2175 2281
 			//创建退库详情
2176 2282
 			errs := service.CreateDrugCancelStockInfo(cancelStockInfos)
2177 2283
 			//创建库存明细
@@ -2558,6 +2664,8 @@ func (c *StockDrugApiController) EditDrugCancelStock() {
2558 2664
 			infoWareInfo, _ := service.GetDrugWarehouseInfo(item.BatchNumberId)
2559 2665
 			fmt.Println("hhh2h3h2hh3233", item.MaxUnit, medical.MaxUnit)
2560 2666
 			var total_count int64
2667
+			var cancel_count int64
2668
+			var out_count int64
2561 2669
 			total_count = infoWareInfo.StockMaxNumber*medical.MinNumber + infoWareInfo.StockMinNumber
2562 2670
 			//转化为最小单位
2563 2671
 			var total_number int64
@@ -2567,13 +2675,46 @@ func (c *StockDrugApiController) EditDrugCancelStock() {
2567 2675
 			if item.MaxUnit == medical.MinUnit {
2568 2676
 				total_number = item.Count
2569 2677
 			}
2570
-			//if item.MaxUnit == medical.MaxUnit {
2571
-			//	total_count = infoWareInfo.WarehousingCount
2572
-			//}
2573
-			////转化为最小库存
2574
-			//if item.MaxUnit == medical.MinUnit {
2575
-			//	total_count = infoWareInfo.WarehousingCount * medical.MinNumber
2576
-			//}
2678
+
2679
+			//统计该批次的总出库数
2680
+			outInfo, _ := service.GetDrugWarehouseOutInfo(item.BatchNumberId, item.DrugId)
2681
+			for _, item := range outInfo {
2682
+				if item.CountUnit == medical.MaxUnit {
2683
+					item.Count = item.Count * medical.MinNumber
2684
+				}
2685
+				if item.CountUnit == medical.MinUnit {
2686
+					item.Count = item.Count
2687
+				}
2688
+			}
2689
+
2690
+			for _, item := range outInfo {
2691
+				out_count += item.Count
2692
+			}
2693
+			fmt.Println("out_count232233332232323223", out_count)
2694
+
2695
+			//判断退库数量是否大于出库数量
2696
+			cancelInfo, _ := service.GetCancelDrugStockOutInfo(item.BatchNumberId, item.DrugId)
2697
+			for _, item := range cancelInfo {
2698
+				if item.MaxUnit == medical.MaxUnit {
2699
+					item.Count = item.Count * medical.MinNumber
2700
+				}
2701
+				if item.MaxUnit == medical.MinUnit {
2702
+					item.Count = item.Count
2703
+				}
2704
+			}
2705
+
2706
+			for _, item := range cancelInfo {
2707
+				cancel_count += item.Count
2708
+			}
2709
+			fmt.Println("cancel_count", cancel_count)
2710
+			fmt.Println("hhhhhh23h2h332322323232", total_number+cancel_count)
2711
+			if total_number+cancel_count > out_count {
2712
+				c.ServeSuccessJSON(map[string]interface{}{
2713
+					"msg": "4",
2714
+				})
2715
+				return
2716
+			}
2717
+
2577 2718
 			//判断退库数量是否大于总入库数量
2578 2719
 			if total_number > total_count {
2579 2720
 				c.ServeSuccessJSON(map[string]interface{}{
@@ -2655,12 +2796,29 @@ func (c *StockDrugApiController) EditDrugCancelStock() {
2655 2796
 
2656 2797
 	if len(upDateCancelStockInfos) > 0 {
2657 2798
 		var total int64
2799
+		var out_count int64
2658 2800
 		for _, item := range upDateCancelStockInfos {
2659 2801
 			errs = service.UpDateDrugCancelStockInfo(item)
2660 2802
 			//查询该批次最后一条退库记录
2661 2803
 			info, _ := service.GetLastCancelStockInfo(id)
2662 2804
 			//查询该药品的信息
2663 2805
 			medical, _ := service.GetBaseDrugMedical(item.DrugId)
2806
+			//统计该批次的总出库数
2807
+			outInfo, _ := service.GetDrugWarehouseOutInfo(item.BatchNumberId, item.DrugId)
2808
+			for _, item := range outInfo {
2809
+				if item.CountUnit == medical.MaxUnit {
2810
+					item.Count = item.Count * medical.MinNumber
2811
+				}
2812
+				if item.CountUnit == medical.MinUnit {
2813
+					item.Count = item.Count
2814
+				}
2815
+			}
2816
+
2817
+			for _, item := range outInfo {
2818
+				out_count += item.Count
2819
+			}
2820
+
2821
+			fmt.Println("out_count232233332232323223", out_count)
2664 2822
 
2665 2823
 			if item.MaxUnit == medical.MaxUnit {
2666 2824
 				item.Count = item.Count * medical.MinNumber
@@ -2805,3 +2963,87 @@ func (this *StockDrugApiController) GetDrugCancelExportList() {
2805 2963
 		"list": list,
2806 2964
 	})
2807 2965
 }
2966
+
2967
+func (c *StockDrugApiController) GetDrugWarehouseInfoPrint() {
2968
+
2969
+	start_time := c.GetString("start_time")
2970
+	end_time := c.GetString("end_time")
2971
+	order_type, _ := c.GetInt64("order_type")
2972
+	timeLayout := "2006-01-02"
2973
+	loc, _ := time.LoadLocation("Local")
2974
+
2975
+	var startTime int64
2976
+	if len(start_time) > 0 {
2977
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
2978
+		if err != nil {
2979
+			fmt.Println(err)
2980
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2981
+			return
2982
+		}
2983
+		startTime = theTime.Unix()
2984
+	}
2985
+	var endTime int64
2986
+	if len(end_time) > 0 {
2987
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
2988
+		if err != nil {
2989
+			utils.ErrorLog(err.Error())
2990
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2991
+			return
2992
+		}
2993
+		endTime = theTime.Unix()
2994
+	}
2995
+	adminUserInfo := c.GetAdminUserInfo()
2996
+	orgId := adminUserInfo.CurrentOrgId
2997
+	if order_type == 1 {
2998
+		list, err := service.GetDrugWarehouseInfoPrint(startTime, endTime, orgId)
2999
+		if err == nil {
3000
+			c.ServeSuccessJSON(map[string]interface{}{
3001
+				"list": list,
3002
+			})
3003
+			return
3004
+		}
3005
+	}
3006
+}
3007
+
3008
+func (c *StockDrugApiController) GetDrugOutOrderPrint() {
3009
+
3010
+	start_time := c.GetString("start_time")
3011
+	end_time := c.GetString("end_time")
3012
+	order_type, _ := c.GetInt64("order_type")
3013
+	timeLayout := "2006-01-02"
3014
+	loc, _ := time.LoadLocation("Local")
3015
+
3016
+	var startTime int64
3017
+	if len(start_time) > 0 {
3018
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
3019
+		if err != nil {
3020
+			fmt.Println(err)
3021
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3022
+			return
3023
+		}
3024
+		startTime = theTime.Unix()
3025
+	}
3026
+	var endTime int64
3027
+	if len(end_time) > 0 {
3028
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
3029
+		if err != nil {
3030
+			utils.ErrorLog(err.Error())
3031
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3032
+			return
3033
+		}
3034
+		endTime = theTime.Unix()
3035
+	}
3036
+	adminUserInfo := c.GetAdminUserInfo()
3037
+	orgId := adminUserInfo.CurrentOrgId
3038
+	if order_type == 2 {
3039
+		//list, err := service.GetDrugOutOrderPrint(startTime, endTime, orgId)
3040
+		list, err := service.GetDrugOutOrderPrintList(startTime, endTime, orgId)
3041
+		if err == nil {
3042
+			c.ServeSuccessJSON(map[string]interface{}{
3043
+				"list": list,
3044
+			})
3045
+			return
3046
+		}
3047
+	}
3048
+
3049
+}

+ 13 - 6
controllers/gobal_config_api_controller.go Zobrazit soubor

@@ -1851,7 +1851,10 @@ func (c *GobalConfigApiController) GetDrugStockList() {
1851 1851
 	adminUserInfo := c.GetAdminUserInfo()
1852 1852
 
1853 1853
 	//查询入库数量
1854
-	list, total, err := service.GetDrugStockList(page, limit, keyword, drug_type, startTime, endTime, adminUserInfo.CurrentOrgId)
1854
+	//list, total, err := service.GetDrugStockList(page, limit, keyword, drug_type, startTime, endTime, adminUserInfo.CurrentOrgId)
1855
+
1856
+	list, total, err := service.GetAllBaseDurgListCount(page, limit, keyword, drug_type, startTime, endTime, adminUserInfo.CurrentOrgId)
1857
+	fmt.Println("total232323232323232232323", total)
1855 1858
 	manufacturerList, _ := service.GetAllManufacturerList(adminUserInfo.CurrentOrgId)
1856 1859
 	if err != nil {
1857 1860
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
@@ -2007,18 +2010,19 @@ func (c *GobalConfigApiController) GetDrugCountList() {
2007 2010
 	orgId := c.GetAdminUserInfo().CurrentOrgId
2008 2011
 	list, err := service.GetDrugCountList(startTime, endTime, orgId)
2009 2012
 	countList, err := service.GetMinCountList(startTime, endTime, orgId)
2010
-	outCountList, _ := service.GetOutDrugCountList(startTime, endTime, orgId)
2011
-	auCountList, err := service.GetAutoDrugCountList(startTime, endTime, orgId)
2013
+	//outCountList, _ := service.GetOutDrugCountList(startTime, endTime, orgId)
2014
+	//auCountList, err := service.GetAutoDrugCountList(startTime, endTime, orgId)
2012 2015
 	info, _ := service.GetDrugWarehouOrderInfo(startTime, endTime, orgId)
2013 2016
 	cancelCountList, _ := service.GetCancelDrugCountList(startTime, endTime, orgId)
2017
+	//service.GetAllCountList(startTime,endTime,orgId)
2014 2018
 	if err != nil {
2015 2019
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
2016 2020
 		return
2017 2021
 	}
2018 2022
 	c.ServeSuccessJSON(map[string]interface{}{
2019
-		"countList":       list,
2020
-		"outCountList":    outCountList,
2021
-		"auCountList":     auCountList,
2023
+		"countList": list,
2024
+		//"outCountList":    outCountList,
2025
+		//"auCountList":     auCountList,
2022 2026
 		"minCount":        countList,
2023 2027
 		"info":            info,
2024 2028
 		"cancelCountList": cancelCountList,
@@ -2028,11 +2032,13 @@ func (c *GobalConfigApiController) GetDrugCountList() {
2028 2032
 func (c *GobalConfigApiController) GetSingleOrderDetail() {
2029 2033
 
2030 2034
 	id, _ := c.GetInt64("id")
2035
+	start_time, _ := c.GetInt64("start_time")
2031 2036
 	orgId := c.GetAdminUserInfo().CurrentOrgId
2032 2037
 	list, err := service.GetSingleOrderDetail(id, orgId)
2033 2038
 	outList, err := service.GetAllSingleDrugDetail(id, orgId)
2034 2039
 	dealerList, err := service.GetAllDealerList(orgId)
2035 2040
 	manufacturerList, err := service.GetAllManufacturerList(orgId)
2041
+	drugFlowList, _ := service.GetDrugStockFlowDetail(start_time, orgId)
2036 2042
 	if err != nil {
2037 2043
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
2038 2044
 		return
@@ -2042,6 +2048,7 @@ func (c *GobalConfigApiController) GetSingleOrderDetail() {
2042 2048
 		"dealerList":       dealerList,
2043 2049
 		"manufacturerList": manufacturerList,
2044 2050
 		"outList":          outList,
2051
+		"drugFlowList":     drugFlowList,
2045 2052
 	})
2046 2053
 }
2047 2054
 

+ 75 - 6
controllers/mobile_api_controllers/dialysis_api_controller.go Zobrazit soubor

@@ -3904,7 +3904,7 @@ func (c *DialysisAPIController) EditConsumables() {
3904 3904
 					if err != nil {
3905 3905
 						goodObj, _ := service.GetGoodInformationByGoodId(it.GoodId)
3906 3906
 						c.ServeSuccessJSON(map[string]interface{}{
3907
-							"message":            "1",
3907
+							"message":            "2",
3908 3908
 							"good_name":          goodObj.GoodName,
3909 3909
 							"specification_name": goodObj.SpecificationName,
3910 3910
 						})
@@ -4629,9 +4629,43 @@ func ConsumablesDeliveryDeleteFour(orgID int64, record_time int64, good_yc *mode
4629 4629
 			UpdateCreator:           creater,
4630 4630
 			PatientId:               patient_id,
4631 4631
 		}
4632
-		//创建流水表
4633
-		err := service.CreateStockFlowOne(stockFlow)
4634
-		fmt.Println("h2h3h2323342i24i242i4u2i4242u42424", err)
4632
+		exsit, errflow := service.GetStockFlowIsExsit(warehouseOutInfos.WarehouseInfotId, patient_id, record_time, good_yc.GoodId)
4633
+		if errflow == gorm.ErrRecordNotFound {
4634
+			//创建流水表
4635
+			err := service.CreateStockFlowOne(stockFlow)
4636
+			fmt.Println("h2h3h2323342i24i242i4u2i4242u42424", err)
4637
+		} else if errflow == nil {
4638
+			//插入详情明细表
4639
+			stockFlow := models.VmStockFlow{
4640
+				ID:                      exsit.ID,
4641
+				WarehousingId:           warehouseOutInfos.WarehouseInfotId,
4642
+				WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
4643
+				WarehouseOutId:          warehouseOut.ID,
4644
+				GoodId:                  good_yc.GoodId,
4645
+				Number:                  warehouseOutInfos.Number,
4646
+				ProductDate:             stockInInfo.ProductDate,
4647
+				ExpireDate:              stockInInfo.ExpiryDate,
4648
+				Count:                   exsit.Count - delete_count,
4649
+				Price:                   stockInInfo.Price,
4650
+				Status:                  1,
4651
+				Ctime:                   time.Now().Unix(),
4652
+				UserOrgId:               good_yc.OrgId,
4653
+				Manufacturer:            stockInInfo.Manufacturer,
4654
+				Dealer:                  stockInInfo.Dealer,
4655
+				LicenseNumber:           stockInInfo.LicenseNumber,
4656
+				IsEdit:                  2,
4657
+				Creator:                 creater,
4658
+				SystemTime:              record_time,
4659
+				ConsumableType:          3,
4660
+				WarehousingDetailId:     0,
4661
+				IsSys:                   1,
4662
+				UpdateCreator:           creater,
4663
+				PatientId:               patient_id,
4664
+			}
4665
+
4666
+			service.UpdatedStockFlow(stockFlow)
4667
+		}
4668
+
4635 4669
 		if errOne != nil {
4636 4670
 			return errOne
4637 4671
 		}
@@ -4639,6 +4673,7 @@ func ConsumablesDeliveryDeleteFour(orgID int64, record_time int64, good_yc *mode
4639 4673
 		service.UpdatedWarehouseOutInfo(warehouseOutInfo, good_yc.GoodId, good_yc.PatientId, record_time)
4640 4674
 		//插入详情明细表
4641 4675
 		stockFlow := models.VmStockFlow{
4676
+			WarehousingId:           warehouseOutInfos.WarehouseInfotId,
4642 4677
 			WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
4643 4678
 			WarehouseOutId:          warehouseOut.ID,
4644 4679
 			GoodId:                  good_yc.GoodId,
@@ -4661,9 +4696,43 @@ func ConsumablesDeliveryDeleteFour(orgID int64, record_time int64, good_yc *mode
4661 4696
 			IsSys:                   1,
4662 4697
 			UpdateCreator:           creater,
4663 4698
 			PatientId:               patient_id,
4699
+			ReturnCount:             delete_count,
4664 4700
 		}
4665
-		//创建流水表
4666
-		service.CreateStockFlowOne(stockFlow)
4701
+		exsit, errflows := service.GetStockFlowIsExsit(warehouseOutInfos.WarehouseInfotId, patient_id, record_time, good_yc.GoodId)
4702
+		if errflows == gorm.ErrRecordNotFound {
4703
+			//创建流水表
4704
+			service.CreateStockFlowOne(stockFlow)
4705
+		} else if errflows == nil {
4706
+			stockFlow := models.VmStockFlow{
4707
+				WarehousingId:           warehouseOutInfos.WarehouseInfotId,
4708
+				ID:                      exsit.ID,
4709
+				WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
4710
+				WarehouseOutId:          warehouseOut.ID,
4711
+				GoodId:                  good_yc.GoodId,
4712
+				Number:                  warehouseOutInfos.Number,
4713
+				ProductDate:             stockInInfo.ProductDate,
4714
+				ExpireDate:              stockInInfo.ExpiryDate,
4715
+				Count:                   exsit.Count - delete_count,
4716
+				Price:                   stockInInfo.Price,
4717
+				Status:                  1,
4718
+				Ctime:                   time.Now().Unix(),
4719
+				UserOrgId:               good_yc.OrgId,
4720
+				Manufacturer:            stockInInfo.Manufacturer,
4721
+				Dealer:                  stockInInfo.Dealer,
4722
+				LicenseNumber:           stockInInfo.LicenseNumber,
4723
+				IsEdit:                  2,
4724
+				Creator:                 creater,
4725
+				SystemTime:              record_time,
4726
+				ConsumableType:          3,
4727
+				WarehousingDetailId:     0,
4728
+				IsSys:                   1,
4729
+				UpdateCreator:           creater,
4730
+				PatientId:               patient_id,
4731
+				ReturnCount:             delete_count,
4732
+			}
4733
+			service.UpdatedStockFlow(stockFlow)
4734
+		}
4735
+
4667 4736
 	}
4668 4737
 
4669 4738
 	//更改自动出库的表格

+ 31 - 0
controllers/new_mobile_api_controllers/staff_schedule_api_controller.go Zobrazit soubor

@@ -3,8 +3,10 @@ package new_mobile_api_controllers
3 3
 import (
4 4
 	"XT_New/controllers/mobile_api_controllers"
5 5
 	"XT_New/enums"
6
+	"XT_New/models"
6 7
 	"XT_New/service"
7 8
 	"fmt"
9
+	"strings"
8 10
 	"time"
9 11
 )
10 12
 
@@ -320,3 +322,32 @@ func (this *StaffScheduleApiController) SearchPatient() {
320 322
 		"schedule": schedule,
321 323
 	})
322 324
 }
325
+
326
+func (this *StaffScheduleApiController) UpdatePatientScheduleById() {
327
+
328
+	ids := this.GetString("ids")
329
+	idSplit := strings.Split(ids, ",")
330
+	var err error
331
+	//查询患者信息
332
+	list, _ := service.GetStaffScheduleById(idSplit)
333
+	if len(list) > 0 {
334
+		for index, _ := range list {
335
+			fmt.Println("index2322332", index)
336
+			schedule := models.XtSchedule{
337
+				PatientId: list[0].PatientId,
338
+				ModeId:    list[0].ModeId,
339
+			}
340
+			xtSchedule := models.WeekSchedule{
341
+				PatientId: list[1].PatientId,
342
+				ModeId:    list[1].ModeId,
343
+			}
344
+			err = service.UpdateStaffSchedule(list[1].ID, schedule)
345
+			fmt.Println("errrrrrrr2323323232323", err)
346
+			service.UpdateStaffScheduleOne(list[0].ID, xtSchedule)
347
+		}
348
+	}
349
+	fmt.Println(err)
350
+	this.ServeSuccessJSON(map[string]interface{}{
351
+		"msg": "切换成功",
352
+	})
353
+}

+ 1 - 0
controllers/new_mobile_api_controllers/staff_schedule_api_router.go Zobrazit soubor

@@ -19,4 +19,5 @@ func StaffScheduleApiControllersRegisterRouters() {
19 19
 	beego.Router("/m/api/getpatientschedulelist", &StaffScheduleApiController{}, "Get:GetPatientScheduleList")
20 20
 	beego.Router("/m/api/deleteSchedule", &StaffScheduleApiController{}, "Get:DeleteSchedule")
21 21
 	beego.Router("/m/api/ssearchpatient", &StaffScheduleApiController{}, "Get:SearchPatient")
22
+	beego.Router("/m/api/updatepatientschedule", &StaffScheduleApiController{}, "Get:UpdatePatientScheduleById")
22 23
 }

+ 13 - 0
controllers/print_data_api_controller.go Zobrazit soubor

@@ -17,6 +17,7 @@ func PrintDataAPIControllerRegistRouters() {
17 17
 	beego.Router("/api/print/course", &PrintDataAPIController{}, "get:CourseRecordPrintData")
18 18
 	beego.Router("/api/print/getlastafterweight", &PrintDataAPIController{}, "get:GetLastAfterWeight")
19 19
 	beego.Router("/api/stock/getgooddetailprintlist", &PrintDataAPIController{}, "get:GetGoodDetailPrintList")
20
+
20 21
 }
21 22
 
22 23
 type PrintDataAPIController struct {
@@ -204,4 +205,16 @@ func (this *PrintDataAPIController) GetGoodDetailPrintList() {
204 205
 		})
205 206
 	}
206 207
 
208
+	//出库详情
209
+	if types == 2 {
210
+		list, err := service.GetWarehouseOutInfoGoodDetailPrintList(adminUserInfo.CurrentOrgId, startTime, endTime, limit, page)
211
+		if err != nil {
212
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
213
+			return
214
+		}
215
+		this.ServeSuccessJSON(map[string]interface{}{
216
+			"list": list,
217
+		})
218
+	}
219
+
207 220
 }

+ 241 - 8
controllers/stock_in_api_controller.go Zobrazit soubor

@@ -99,6 +99,10 @@ func StockManagerApiRegistRouters() {
99 99
 
100 100
 	beego.Router("/api/cancel/getcancelexportlist", &StockManagerApiController{}, "Get:GetCancelExportList")
101 101
 
102
+	//耗材调价
103
+	beego.Router("/api/stock/postsearchgoodwarehouselist", &StockManagerApiController{}, "Get:GetSearchGoodWarehouseList")
104
+	beego.Router("/api/stock/saveadjustprice", &StockManagerApiController{}, "Post:SaveAdjuestPrice")
105
+	beego.Router("/api/stock/getallstockprice", &StockManagerApiController{}, "Get:GetAllStockPrice")
102 106
 }
103 107
 
104 108
 func (c *StockManagerApiController) CreateWarehouse() {
@@ -278,6 +282,20 @@ func (c *StockManagerApiController) CreateWarehouse() {
278 282
 
279 283
 	info, _ := service.FindLastWarehousingInfo(warehousing.WarehousingOrder)
280 284
 
285
+	for _, item := range warehousingInfo {
286
+		goodInfo, _ := service.GetGoodInformationByGoodId(item.GoodId)
287
+		str := strconv.FormatInt(item.WarehousingCount, 10)
288
+		minFloat, _ := strconv.ParseFloat(str, 64)
289
+
290
+		good := models.GoodInfo{
291
+			Total: minFloat + goodInfo.Total,
292
+		}
293
+		//更该库存
294
+		parseDateErr := service.UpdateGoodInfoList(good, goodInfo.ID)
295
+		break
296
+		fmt.Println(parseDateErr)
297
+	}
298
+
281 299
 	if errs != nil {
282 300
 		utils.ErrorLog(errs.Error())
283 301
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockInFail)
@@ -554,6 +572,7 @@ func (c *StockManagerApiController) EditWarehouse() {
554 572
 					stockFlow = append(stockFlow, flow)
555 573
 
556 574
 				} else {
575
+					fmt.Println("id23233232323232323232323223", id)
557 576
 					warehouseInfo := &models.WarehousingInfo{
558 577
 						ID:               id,
559 578
 						WarehousingOrder: warehouse.WarehousingOrder,
@@ -573,14 +592,13 @@ func (c *StockManagerApiController) EditWarehouse() {
573 592
 						Type:             types,
574 593
 						Manufacturer:     manufacturer,
575 594
 						Dealer:           dealer,
576
-						StockCount:       warehousing_count,
577 595
 						LicenseNumber:    license_number,
578 596
 					}
579 597
 					upDateWarehousingInfo = append(upDateWarehousingInfo, warehouseInfo)
580 598
 
581 599
 					flow := &models.VmStockFlow{
582 600
 						WarehousingOrder:    warehousing.WarehousingOrder,
583
-						WarehousingId:       warehousing.ID,
601
+						WarehousingId:       id,
584 602
 						GoodId:              good_id,
585 603
 						Number:              number,
586 604
 						ProductDate:         productDates,
@@ -614,20 +632,31 @@ func (c *StockManagerApiController) EditWarehouse() {
614 632
 	if len(upDateWarehousingInfo) > 0 {
615 633
 
616 634
 		for _, item := range upDateWarehousingInfo {
635
+
617 636
 			var total int64
618 637
 			var all_total int64
619 638
 			//获取该批次该型号的库存
620
-			info, _ := service.GetLastWarehousingById(item.WarehousingId, item.GoodId)
621
-
639
+			info, _ := service.GetLastWarehousingByIdOne(item.ID, item.GoodId)
640
+			fmt.Println("oooooooooo", info.WarehousingCount)
622 641
 			//判断 该批次的入库数量
623 642
 			total = item.WarehousingCount - info.WarehousingCount
624
-
643
+			fmt.Println("total232323322332232332", total)
625 644
 			all_total = info.StockCount + total
626 645
 
627 646
 			item.StockCount = all_total
647
+			fmt.Println("hhhhhhhhhhhhh", item.StockCount)
648
+
628 649
 			errs = service.UpDateWarehousingInfo(item)
650
+		}
651
+	}
629 652
 
630
-			service.CreateStockFlow(stockFlow)
653
+	if len(stockFlow) > 0 {
654
+		for _, item := range stockFlow {
655
+			flow := models.VmStockFlow{
656
+				Count: item.Count,
657
+			}
658
+			parseDateErr := service.UpdateStockFlow(flow, item.GoodId, item.WarehousingId)
659
+			fmt.Println(parseDateErr)
631 660
 		}
632 661
 	}
633 662
 
@@ -1929,7 +1958,9 @@ func (c *StockManagerApiController) CreateCancelStock() {
1929 1958
 
1930 1959
 		//统计该耗材的出库数量
1931 1960
 		info, _ := service.GetWarehoureOrderInfoCount(item.GoodId, item.OrgId)
1961
+		fmt.Println("2333223323322332233223322323", item.Count, info.Count)
1932 1962
 		if item.Count > info.Count {
1963
+			service.UpdateCancelInfo(item.CancelStockId)
1933 1964
 			c.ServeSuccessJSON(map[string]interface{}{
1934 1965
 				"msg": "2",
1935 1966
 			})
@@ -1958,6 +1989,14 @@ func (c *StockManagerApiController) CreateCancelStock() {
1958 1989
 				return
1959 1990
 			}
1960 1991
 
1992
+			//查询该批次的剩余库存
1993
+			wareouseinfo, _ := service.GetWarehouseInfoById(item.WarehouseInfoId)
1994
+			if (wareouseinfo.StockCount + item.Count) > wareouseinfo.WarehousingCount {
1995
+				c.ServeSuccessJSON(map[string]interface{}{
1996
+					"msg": "5",
1997
+				})
1998
+				return
1999
+			}
1961 2000
 			//更改入库数量
1962 2001
 			errs = service.UpdateWareInfoById(item.WarehouseInfoId, item.Count)
1963 2002
 
@@ -2365,6 +2404,13 @@ func (c *StockManagerApiController) EditCancelStock() {
2365 2404
 				errs = service.UpDateCancelStockInfo(item)
2366 2405
 
2367 2406
 				service.CreateStockFlow(stockFlow)
2407
+				warehouseinfo, _ := service.GetWarehouseInfoById(item.WarehouseInfoId)
2408
+				if (warehouseinfo.StockCount + total) > warehouseinfo.StockCount {
2409
+					c.ServeSuccessJSON(map[string]interface{}{
2410
+						"msg": "5",
2411
+					})
2412
+					return
2413
+				}
2368 2414
 				parseDateErr := service.UpdateWareInfoById(item.WarehouseInfoId, total)
2369 2415
 				if parseDateErr != nil {
2370 2416
 					utils.ErrorLog(errs.Error())
@@ -2386,6 +2432,7 @@ func (c *StockManagerApiController) EditCancelStock() {
2386 2432
 				}
2387 2433
 				if item.Count <= infolist.WarehousingCount {
2388 2434
 					var total_count = info.Count - item.Count
2435
+
2389 2436
 					parseDateErr := service.UpdateWareInfoById(item.WarehouseInfoId, total_count)
2390 2437
 					if parseDateErr != nil {
2391 2438
 						utils.ErrorLog(errs.Error())
@@ -4281,7 +4328,8 @@ func (this *StockManagerApiController) GetAllStockList() {
4281 4328
 	adminUserInfo := this.GetAdminUserInfo()
4282 4329
 	orgId := adminUserInfo.CurrentOrgId
4283 4330
 
4284
-	list, total, _ := service.GetAllStockList(page, limit, startTime, endTime, types, keywords, orgId)
4331
+	list, total, _ := service.GetAllGoodInfoStockList(page, limit, startTime, endTime, types, keywords, orgId)
4332
+	fmt.Println("耗材总计23323232232323232323", total)
4285 4333
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
4286 4334
 	this.ServeSuccessJSON(map[string]interface{}{
4287 4335
 		"list":             list,
@@ -4440,7 +4488,7 @@ func (this *StockManagerApiController) GetOrderDetailById() {
4440 4488
 	//手动出库
4441 4489
 	info, _ := service.GetWarehouseOutInfoById(id, good_id)
4442 4490
 
4443
-	stockFlowList, err := service.GetStockFlowBatchNumber(id, good_id)
4491
+	stockFlowList, err := service.GetStockFlowBatchNumberOne(id, good_id)
4444 4492
 	if err == nil {
4445 4493
 		this.ServeSuccessJSON(map[string]interface{}{
4446 4494
 			"list":          userDetails,
@@ -4652,3 +4700,188 @@ func (this *StockManagerApiController) GetCancelExportList() {
4652 4700
 		"list": list,
4653 4701
 	})
4654 4702
 }
4703
+
4704
+func (this *StockManagerApiController) GetSearchGoodWarehouseList() {
4705
+
4706
+	keyword := this.GetString("keyword")
4707
+	orgId := this.GetAdminUserInfo().CurrentOrgId
4708
+	list, _ := service.GetSearchGoodWarehouseList(keyword, orgId)
4709
+	manufacturerList, _ := service.GetAllManufacturerList(orgId)
4710
+	dealerList, _ := service.GetAllDealerList(orgId)
4711
+	this.ServeSuccessJSON(map[string]interface{}{
4712
+		"list":             list,
4713
+		"manufacturerList": manufacturerList,
4714
+		"dealerList":       dealerList,
4715
+	})
4716
+}
4717
+
4718
+func (this *StockManagerApiController) SaveAdjuestPrice() {
4719
+	timeLayout := "2006-01-02"
4720
+	loc, _ := time.LoadLocation("Local")
4721
+	dataBody := make(map[string]interface{}, 0)
4722
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
4723
+	if err != nil {
4724
+		utils.ErrorLog(err.Error())
4725
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4726
+		return
4727
+	}
4728
+	tableData, _ := dataBody["tableData"].([]interface{})
4729
+	if len(tableData) > 0 {
4730
+		for _, item := range tableData {
4731
+			items := item.(map[string]interface{})
4732
+
4733
+			if items["good_name"] == nil || reflect.TypeOf(items["good_name"]).String() != "string" {
4734
+				utils.ErrorLog("good_name")
4735
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4736
+				return
4737
+			}
4738
+			good_name := items["good_name"].(string)
4739
+
4740
+			if items["good_name"] == nil || reflect.TypeOf(items["good_name"]).String() != "string" {
4741
+				utils.ErrorLog("good_name")
4742
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4743
+				return
4744
+			}
4745
+
4746
+			if items["packing_price"] == nil || reflect.TypeOf(items["packing_price"]).String() != "string" {
4747
+				utils.ErrorLog("packing_price")
4748
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4749
+				return
4750
+			}
4751
+			packing_price, _ := strconv.ParseFloat(items["packing_price"].(string), 64)
4752
+
4753
+			if items["warehousing_order"] == nil || reflect.TypeOf(items["warehousing_order"]).String() != "string" {
4754
+				utils.ErrorLog("warehousing_order")
4755
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4756
+				return
4757
+			}
4758
+			warehousing_order := items["warehousing_order"].(string)
4759
+
4760
+			if items["license_number"] == nil || reflect.TypeOf(items["license_number"]).String() != "string" {
4761
+				utils.ErrorLog("license_number")
4762
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4763
+				return
4764
+			}
4765
+			license_number := items["license_number"].(string)
4766
+
4767
+			if items["dealer"] == nil || reflect.TypeOf(items["dealer"]).String() != "string" {
4768
+				utils.ErrorLog("dealer")
4769
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4770
+				return
4771
+			}
4772
+			dealer := items["dealer"].(string)
4773
+
4774
+			if items["manufacturer"] == nil || reflect.TypeOf(items["manufacturer"]).String() != "string" {
4775
+				utils.ErrorLog("manufacturer")
4776
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4777
+				return
4778
+			}
4779
+			manufacturer := items["manufacturer"].(string)
4780
+
4781
+			if items["specification_name"] == nil || reflect.TypeOf(items["specification_name"]).String() != "string" {
4782
+				utils.ErrorLog("specification_name")
4783
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4784
+				return
4785
+			}
4786
+			specification_name := items["specification_name"].(string)
4787
+
4788
+			if items["remark"] == nil || reflect.TypeOf(items["remark"]).String() != "string" {
4789
+				utils.ErrorLog("remark")
4790
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4791
+				return
4792
+			}
4793
+			remark := items["remark"].(string)
4794
+
4795
+			if items["warehousing_unit"] == nil || reflect.TypeOf(items["warehousing_unit"]).String() != "string" {
4796
+				utils.ErrorLog("warehousing_unit")
4797
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4798
+				return
4799
+			}
4800
+			warehousing_unit := items["warehousing_unit"].(string)
4801
+
4802
+			if items["buy_price"] == nil || reflect.TypeOf(items["buy_price"]).String() != "string" {
4803
+				utils.ErrorLog("buy_price")
4804
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4805
+				return
4806
+			}
4807
+			buy_price, _ := strconv.ParseFloat(items["buy_price"].(string), 64)
4808
+
4809
+			if items["count"] == nil || reflect.TypeOf(items["count"]).String() != "float64" {
4810
+				utils.ErrorLog("count")
4811
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4812
+				return
4813
+			}
4814
+			count := int64(items["count"].(float64))
4815
+
4816
+			if items["new_price"] == nil || reflect.TypeOf(items["new_price"]).String() != "string" {
4817
+				utils.ErrorLog("new_price")
4818
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4819
+				return
4820
+			}
4821
+			new_price, _ := strconv.ParseFloat(items["new_price"].(string), 64)
4822
+
4823
+			if items["good_id"] == nil || reflect.TypeOf(items["good_id"]).String() != "float64" {
4824
+				utils.ErrorLog("good_id")
4825
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4826
+				return
4827
+			}
4828
+			good_id := int64(items["good_id"].(float64))
4829
+
4830
+			if items["start_time"] == nil || reflect.TypeOf(items["start_time"]).String() != "string" {
4831
+				utils.ErrorLog("start_time")
4832
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4833
+				return
4834
+			}
4835
+			var startTime int64
4836
+			start_time := items["start_time"].(string)
4837
+			if len(start_time) > 0 {
4838
+				theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
4839
+				if err != nil {
4840
+					fmt.Println(err)
4841
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4842
+					return
4843
+				}
4844
+				startTime = theTime.Unix()
4845
+			}
4846
+			orgId := this.GetAdminUserInfo().CurrentOrgId
4847
+			adjustprice := models.XtStockAdjustPrice{
4848
+				GoodName:          good_name,
4849
+				SpecificationName: specification_name,
4850
+				WarehousingUnit:   warehousing_unit,
4851
+				Count:             count,
4852
+				BuyPrice:          buy_price,
4853
+				PackingPrice:      packing_price,
4854
+				NewPrice:          new_price,
4855
+				Manufacturer:      manufacturer,
4856
+				Dealer:            dealer,
4857
+				Remark:            remark,
4858
+				GoodId:            good_id,
4859
+				UserOrgId:         orgId,
4860
+				Ctime:             time.Now().Unix(),
4861
+				Mtime:             0,
4862
+				Status:            1,
4863
+				WarehousingOrder:  warehousing_order,
4864
+				LicenseNumber:     license_number,
4865
+				StartTime:         startTime,
4866
+				Creater:           this.GetAdminUserInfo().AdminUser.Id,
4867
+				CheckerStatus:     2,
4868
+			}
4869
+
4870
+			service.CreateAdjustPrice(&adjustprice)
4871
+		}
4872
+	}
4873
+
4874
+	this.ServeSuccessJSON(map[string]interface{}{
4875
+		"msg": "保存成功!",
4876
+	})
4877
+}
4878
+
4879
+func (this *StockManagerApiController) GetAllStockPrice() {
4880
+
4881
+	orgId := this.GetAdminUserInfo().CurrentOrgId
4882
+
4883
+	list, _ := service.GetAllStockPrice(orgId)
4884
+	this.ServeSuccessJSON(map[string]interface{}{
4885
+		"list": list,
4886
+	})
4887
+}

+ 1 - 0
models/drug_stock.go Zobrazit soubor

@@ -279,6 +279,7 @@ type VmDrugWarehouseInfo struct {
279 279
 	Count          int64  `gorm:"column:count" json:"count" form:"count"`
280 280
 	MaxUnit        string `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
281 281
 	MinUnit        string `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
282
+	CountUnit      string `gorm:"column:count_unit" json:"count_unit" form:"count_unit"`
282 283
 	StockMinNumber int64  `gorm:"column:stock_min_number" json:"stock_min_number" form:"stock_min_number"`
283 284
 	StockMaxNumber int64  `gorm:"column:stock_max_number" json:"stock_max_number" form:"stock_max_number"`
284 285
 }

+ 2 - 1
models/good_models.go Zobrazit soubor

@@ -77,7 +77,8 @@ type GoodInfo struct {
77 77
 	DefaultCountUnit            string               `gorm:"column:default_count_unit" json:"default_count_unit" form:"default_count_unit"`
78 78
 	MinUnit                     string               `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
79 79
 	Total                       float64              `gorm:"column:total" json:"total" form:"total"`
80
-	StWarehousingInfo           []*StWarehousingInfo `gorm:"ForeignKey:good_id;AssociationForeignKey:ID" json:"xt_warehouse_info"`
80
+	StWarehousingInfo           []*StWarehousingInfo `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"xt_warehouse_info"`
81
+	CancelStockInfo             []*CancelStockInfo   `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"cancel_stock_info"`
81 82
 }
82 83
 
83 84
 func (GoodInfo) TableName() string {

+ 176 - 0
models/patient_models.go Zobrazit soubor

@@ -799,6 +799,26 @@ func (XtInspectionReference) TableName() string {
799 799
 	return "xt_inspection_reference"
800 800
 }
801 801
 
802
+type VmXtInspection struct {
803
+	ID           int64  `gorm:"column:id" json:"id" form:"id"`
804
+	PatientId    int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
805
+	OrgId        int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
806
+	ProjectId    int64  `gorm:"column:project_id" json:"project_id" form:"project_id"`
807
+	ItemId       int64  `gorm:"column:item_id" json:"item_id" form:"item_id"`
808
+	ItemName     string `gorm:"column:item_name" json:"item_name" form:"item_name"`
809
+	ProjectName  string `gorm:"column:project_name" json:"project_name" form:"project_name"`
810
+	InspectType  int64  `gorm:"column:inspect_type" json:"inspect_type" form:"inspect_type"`
811
+	InspectValue string `gorm:"column:inspect_value" json:"inspect_value" form:"inspect_value"`
812
+	InspectDate  int64  `gorm:"column:inspect_date" json:"inspect_date" form:"inspect_date"`
813
+	Status       int64  `gorm:"column:status" json:"status" form:"status"`
814
+	CreatedTime  int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
815
+	UpdatedTime  int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
816
+	RangeType    int64  `gorm:"column:range_type" json:"range_type" form:"range_type"`
817
+	RangeMin     string `gorm:"column:range_min" json:"range_min" form:"range_min"`
818
+	RangeMax     string `gorm:"column:range_max" json:"range_max" form:"range_max"`
819
+	RangeValue   string `gorm:"column:range_value" json:"range_value" form:"range_value"`
820
+}
821
+
802 822
 type XtInspection struct {
803 823
 	ID           int64  `gorm:"column:id" json:"id" form:"id"`
804 824
 	PatientId    int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
@@ -820,6 +840,26 @@ func (XtInspection) TableName() string {
820 840
 	return "xt_inspection"
821 841
 }
822 842
 
843
+type VmInspection struct {
844
+	ID           int64  `gorm:"column:id" json:"id" form:"id"`
845
+	PatientId    int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
846
+	OrgId        int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
847
+	ProjectId    int64  `gorm:"column:project_id" json:"project_id" form:"project_id"`
848
+	ItemId       int64  `gorm:"column:item_id" json:"item_id" form:"item_id"`
849
+	ItemName     string `gorm:"column:item_name" json:"item_name" form:"item_name"`
850
+	ProjectName  string `gorm:"column:project_name" json:"project_name" form:"project_name"`
851
+	InspectType  int64  `gorm:"column:inspect_type" json:"inspect_type" form:"inspect_type"`
852
+	InspectValue string `gorm:"column:inspect_value" json:"inspect_value" form:"inspect_value"`
853
+	InspectDate  int64  `gorm:"column:inspect_date" json:"inspect_date" form:"inspect_date"`
854
+	Status       int64  `gorm:"column:status" json:"status" form:"status"`
855
+	CreatedTime  int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
856
+	UpdatedTime  int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
857
+	RangeMin     string `gorm:"column:range_min" json:"range_min" form:"range_min"`
858
+	RangeMax     string `gorm:"column:range_max" json:"range_max" form:"range_max"`
859
+	RangeValue   string `gorm:"column:range_value" json:"range_value" form:"range_value"`
860
+	Unit         string `gorm:"column:unit" json:"unit" form:"unit"`
861
+}
862
+
823 863
 type BloodXtPatients struct {
824 864
 	ID         int64  `gorm:"column:id" json:"id" form:"id"`
825 865
 	UserOrgId  int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
@@ -1016,3 +1056,139 @@ type ExportLog struct {
1016 1056
 func (ExportLog) TableName() string {
1017 1057
 	return "xt_export_log"
1018 1058
 }
1059
+
1060
+type XtTemplateSummary struct {
1061
+	ID                        int64      `gorm:"column:id" json:"id" form:"id"`
1062
+	StartYear                 int64      `gorm:"column:start_year" json:"start_year" form:"start_year"`
1063
+	StartMonth                int64      `gorm:"column:start_month" json:"start_month" form:"start_month"`
1064
+	Radio                     int64      `gorm:"column:radio" json:"radio" form:"radio"`
1065
+	Quarter                   int64      `gorm:"column:quarter" json:"quarter" form:"quarter"`
1066
+	DryWeight                 float64    `gorm:"column:dry_weight" json:"dry_weight" form:"dry_weight"`
1067
+	DialysisCount             int64      `gorm:"column:dialysis_count" json:"dialysis_count" form:"dialysis_count"`
1068
+	HdCount                   int64      `gorm:"column:hd_count" json:"hd_count" form:"hd_count"`
1069
+	HdfCount                  int64      `gorm:"column:hdf_count" json:"hdf_count" form:"hdf_count"`
1070
+	HpCount                   int64      `gorm:"column:hp_count" json:"hp_count" form:"hp_count"`
1071
+	OtherCount                int64      `gorm:"column:other_count" json:"other_count" form:"other_count"`
1072
+	DialzerApparatus          string     `gorm:"column:dialzer_apparatus" json:"dialzer_apparatus" form:"dialzer_apparatus"`
1073
+	PerfusionApparatus        string     `gorm:"column:perfusion_apparatus" json:"perfusion_apparatus" form:"perfusion_apparatus"`
1074
+	Anticoagulant             int64      `gorm:"column:anticoagulant" json:"anticoagulant" form:"anticoagulant"`
1075
+	Kalium                    float64    `gorm:"column:kalium" json:"kalium" form:"kalium"`
1076
+	Autunite                  float64    `gorm:"column:autunite" json:"autunite" form:"autunite"`
1077
+	Natrium                   float64    `gorm:"column:natrium" json:"natrium" form:"natrium"`
1078
+	Hour                      int64      `gorm:"column:hour" json:"hour" form:"hour"`
1079
+	Minute                    int64      `gorm:"column:minute" json:"minute" form:"minute"`
1080
+	BeforWeight               float64    `gorm:"column:befor_weight" json:"befor_weight" form:"befor_weight"`
1081
+	AfterWeight               float64    `gorm:"column:after_weight" json:"after_weight" form:"after_weight"`
1082
+	BeforPressure             string     `gorm:"column:befor_pressure" json:"befor_pressure" form:"befor_pressure"`
1083
+	AfterPressure             string     `gorm:"column:after_pressure" json:"after_pressure" form:"after_pressure"`
1084
+	TemplateSummaryId         int64      `gorm:"column:template_summary_id" json:"template_summary_id" form:"template_summary_id"`
1085
+	TemplateSummaryContent    string     `gorm:"column:template_summary_content" json:"template_summary_content" form:"template_summary_content"`
1086
+	TemplatePlanId            int64      `gorm:"column:template_plan_id" json:"template_plan_id" form:"template_plan_id"`
1087
+	TemplatePlanContent       string     `gorm:"column:template_plan_content" json:"template_plan_content" form:"template_plan_content"`
1088
+	TemplateInspectionId      int64      `gorm:"column:template_inspection_id" json:"template_inspection_id" form:"template_inspection_id"`
1089
+	TemplateInspectionContent string     `gorm:"column:template_inspection_content" json:"template_inspection_content" form:"template_inspection_content"`
1090
+	AdminUserId               int64      `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
1091
+	RecordTime                int64      `gorm:"column:record_time" json:"record_time" form:"record_time"`
1092
+	PatientId                 int64      `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1093
+	UserOrgId                 int64      `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1094
+	Status                    int64      `gorm:"column:status" json:"status" form:"status"`
1095
+	Ctime                     int64      `gorm:"column:ctime" json:"ctime" form:"ctime"`
1096
+	Mtime                     int64      `gorm:"column:mtime" json:"mtime" form:"mtime"`
1097
+	Title                     string     `gorm:"column:title" json:"title" form:"title"`
1098
+	Patients                  VmPatients `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
1099
+}
1100
+
1101
+func (XtTemplateSummary) TableName() string {
1102
+	return "xt_template_summary"
1103
+}
1104
+
1105
+type VmPatients struct {
1106
+	ID                           int64   `gorm:"column:id" json:"id" form:"id"`
1107
+	UserOrgId                    int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1108
+	UserId                       int64   `gorm:"column:user_id" json:"user_id" form:"user_id"`
1109
+	Avatar                       string  `gorm:"column:avatar" json:"avatar" form:"avatar"`
1110
+	PatientType                  int64   `gorm:"column:patient_type" json:"patient_type" form:"patient_type"`
1111
+	DialysisNo                   string  `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
1112
+	AdmissionNumber              string  `gorm:"column:admission_number" json:"admission_number" form:"admission_number"`
1113
+	Source                       int64   `gorm:"column:source" json:"source" form:"source"`
1114
+	Lapseto                      int64   `gorm:"column:lapseto" json:"lapseto" form:"lapseto"`
1115
+	PartitionId                  int64   `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
1116
+	BedId                        int64   `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
1117
+	Name                         string  `gorm:"column:name" json:"name" form:"name"`
1118
+	Alias                        string  `gorm:"column:alias" json:"alias" form:"alias"`
1119
+	Gender                       int64   `gorm:"column:gender" json:"gender" form:"gender"`
1120
+	MaritalStatus                int64   `gorm:"column:marital_status" json:"marital_status" form:"marital_status"`
1121
+	IdCardNo                     string  `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
1122
+	Birthday                     int64   `gorm:"column:birthday" json:"birthday" form:"birthday"`
1123
+	ReimbursementWayId           int64   `gorm:"column:reimbursement_way_id" json:"reimbursement_way_id" form:"reimbursement_way_id"`
1124
+	HealthCareType               int64   `gorm:"column:health_care_type" json:"health_care_type" form:"health_care_type"`
1125
+	HealthCareNo                 string  `gorm:"column:health_care_no" json:"health_care_no" form:"health_care_no"`
1126
+	HealthCareDueDate            int64   `gorm:"column:health_care_due_date" json:"health_care_due_date" form:"health_care_due_date"`
1127
+	Height                       int64   `gorm:"column:height" json:"height" form:"height"`
1128
+	BloodType                    int64   `gorm:"column:blood_type" json:"blood_type" form:"blood_type"`
1129
+	Rh                           int64   `gorm:"column:rh" json:"rh" form:"rh"`
1130
+	HealthCareDueAlertDate       int64   `gorm:"column:health_care_due_alert_date" json:"health_care_due_alert_date" form:"health_care_due_alert_date"`
1131
+	EducationLevel               int64   `gorm:"column:education_level" json:"education_level" form:"education_level"`
1132
+	Profession                   int64   `gorm:"column:profession" json:"profession" form:"profession"`
1133
+	Phone                        string  `gorm:"column:phone" json:"phone" form:"phone"`
1134
+	HomeTelephone                string  `gorm:"column:home_telephone" json:"home_telephone" form:"home_telephone"`
1135
+	RelativePhone                string  `gorm:"column:relative_phone" json:"relative_phone" form:"relative_phone"`
1136
+	RelativeRelations            string  `gorm:"column:relative_relations" json:"relative_relations" form:"relative_relations"`
1137
+	HomeAddress                  string  `gorm:"column:home_address" json:"home_address" form:"home_address"`
1138
+	WorkUnit                     string  `gorm:"column:work_unit" json:"work_unit" form:"work_unit"`
1139
+	UnitAddress                  string  `gorm:"column:unit_address" json:"unit_address" form:"unit_address"`
1140
+	Children                     int64   `gorm:"column:children" json:"children" form:"children"`
1141
+	ReceivingDate                int64   `gorm:"column:receiving_date" json:"receiving_date" form:"receiving_date"`
1142
+	IsHospitalFirstDialysis      int64   `gorm:"column:is_hospital_first_dialysis" json:"is_hospital_first_dialysis" form:"is_hospital_first_dialysis"`
1143
+	FirstDialysisDate            int64   `gorm:"column:first_dialysis_date" json:"first_dialysis_date" form:"first_dialysis_date"`
1144
+	FirstDialysisHospital        string  `gorm:"column:first_dialysis_hospital" json:"first_dialysis_hospital" form:"first_dialysis_hospital"`
1145
+	PredialysisCondition         string  `gorm:"column:predialysis_condition" json:"predialysis_condition" form:"predialysis_condition"`
1146
+	PreHospitalDialysisFrequency string  `gorm:"column:pre_hospital_dialysis_frequency" json:"pre_hospital_dialysis_frequency" form:"pre_hospital_dialysis_frequency"`
1147
+	PreHospitalDialysisTimes     int64   `gorm:"column:pre_hospital_dialysis_times" json:"pre_hospital_dialysis_times" form:"pre_hospital_dialysis_times"`
1148
+	HospitalFirstDialysisDate    int64   `gorm:"column:hospital_first_dialysis_date" json:"hospital_first_dialysis_date" form:"hospital_first_dialysis_date"`
1149
+	InductionPeriod              int64   `gorm:"column:induction_period" json:"induction_period" form:"induction_period"`
1150
+	InitialDialysis              int64   `gorm:"column:initial_dialysis" json:"initial_dialysis" form:"initial_dialysis"`
1151
+	TotalDialysis                int64   `gorm:"column:total_dialysis" json:"total_dialysis" form:"total_dialysis"`
1152
+	AttendingDoctorId            int64   `gorm:"column:attending_doctor_id" json:"attending_doctor_id" form:"attending_doctor_id"`
1153
+	HeadNurseId                  int64   `gorm:"column:head_nurse_id" json:"head_nurse_id" form:"head_nurse_id"`
1154
+	Evaluate                     string  `gorm:"column:evaluate" json:"evaluate" form:"evaluate"`
1155
+	Diagnose                     string  `gorm:"column:diagnose" json:"diagnose" form:"diagnose"`
1156
+	Remark                       string  `gorm:"column:remark" json:"remark" form:"remark"`
1157
+	RegistrarsId                 int64   `gorm:"column:registrars_id" json:"registrars_id" form:"registrars_id"`
1158
+	Registrars                   string  `gorm:"column:registrars" json:"registrars" form:"registrars"`
1159
+	QrCode                       string  `gorm:"column:qr_code" json:"qr_code" form:"qr_code"`
1160
+	BindingState                 int64   `gorm:"column:binding_state" json:"binding_state" form:"binding_state"`
1161
+	PatientComplains             string  `gorm:"column:patient_complains" json:"patient_complains" form:"patient_complains"`
1162
+	PresentHistory               string  `gorm:"column:present_history" json:"present_history" form:"present_history"`
1163
+	PastHistory                  string  `gorm:"column:past_history" json:"past_history" form:"past_history"`
1164
+	Temperature                  float64 `gorm:"column:temperature" json:"temperature" form:"temperature"`
1165
+	Pulse                        int64   `gorm:"column:pulse" json:"pulse" form:"pulse"`
1166
+	Respiratory                  int64   `gorm:"column:respiratory" json:"respiratory" form:"respiratory"`
1167
+	Sbp                          int64   `gorm:"column:sbp" json:"sbp" form:"sbp"`
1168
+	Dbp                          int64   `gorm:"column:dbp" json:"dbp" form:"dbp"`
1169
+	Status                       int64   `gorm:"column:status" json:"status" form:"status"`
1170
+	CreatedTime                  int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
1171
+	UpdatedTime                  int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
1172
+	Nation                       string  `gorm:"column:nation" json:"nation" form:"nation"`
1173
+	NativePlace                  string  `gorm:"column:native_place" json:"native_place" form:"native_place"`
1174
+	Age                          int64   `gorm:"column:age" json:"age" form:"age"`
1175
+	InfectiousNextRecordTime     int64   `gorm:"column:infectious_next_record_time" json:"infectious_next_record_time" form:"infectious_next_record_time"`
1176
+	IsInfectious                 int64   `gorm:"column:is_infectious" json:"is_infectious" form:"is_infectious"`
1177
+	IsOpenRemind                 int64   `gorm:"column:is_open_remind" json:"is_open_remind" form:"is_open_remind"`
1178
+	RemindCycle                  int64   `gorm:"column:remind_cycle" json:"remind_cycle" form:"remind_cycle"`
1179
+	ResponseResult               string  `gorm:"column:response_result" json:"response_result" form:"response_result"`
1180
+	FirstTreatmentDate           int64   `gorm:"column:first_treatment_date" json:"first_treatment_date" form:"first_treatment_date"`
1181
+	DialysisAge                  int64   `gorm:"column:dialysis_age" json:"dialysis_age" form:"dialysis_age"`
1182
+	ExpenseKind                  int64   `gorm:"column:expense_kind" json:"expense_kind" form:"expense_kind"`
1183
+	TellPhone                    string  `gorm:"column:tell_phone" json:"tell_phone" form:"tell_phone"`
1184
+	ContactName                  string  `gorm:"column:contact_name" json:"contact_name" form:"contact_name"`
1185
+	UserSysBeforeCount           int64   `gorm:"column:user_sys_before_count" json:"user_sys_before_count" form:"user_sys_before_count"`
1186
+	IsExcelExport                int64   `gorm:"column:is_excel_export" json:"is_excel_export" form:"is_excel_export"`
1187
+	SchRemark                    string  `gorm:"column:sch_remark" json:"sch_remark" form:"sch_remark"`
1188
+	OutReason                    string  `gorm:"column:out_reason" json:"out_reason" form:"out_reason"`
1189
+	DeathTime                    int64   `gorm:"column:death_time" json:"death_time" form:"death_time"`
1190
+}
1191
+
1192
+func (VmPatients) TableName() string {
1193
+	return "xt_patients"
1194
+}

+ 29 - 0
models/schedule_models.go Zobrazit soubor

@@ -170,3 +170,32 @@ type XtDataPrint struct {
170 170
 func (XtDataPrint) TableName() string {
171 171
 	return "xt_data_print"
172 172
 }
173
+
174
+type VmSchedulesRemind struct {
175
+	ID           int64 `gorm:"column:id" json:"id" form:"id"`
176
+	UserOrgId    int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
177
+	PartitionId  int64 `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
178
+	BedId        int64 `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
179
+	PatientId    int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
180
+	ScheduleDate int64 `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
181
+	ScheduleType int64 `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
182
+	ScheduleWeek int64 `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
183
+	ModeId       int64 `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
184
+	Status       int64 `gorm:"column:status" json:"status" form:"status"`
185
+	CreatedTime  int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
186
+	UpdatedTime  int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
187
+	IsExport     int64 `gorm:"column:is_export" json:"is_export" form:"is_export"`
188
+
189
+	DeviceZone           DeviceZone             `json:"zone" gorm:"foreignkey:ID;AssociationForeignKey:PartitionId;"`
190
+	DeviceNumber         DeviceNumber           `json:"number" gorm:"foreignkey:ID;AssociationForeignKey:BedId;"`
191
+	DialysisOrder        DialysisOrder          `json:"order" gorm:"foreignkey:DialysisDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
192
+	XtPatients           XtPatients             `json:"patient" gorm:"foreignkey:ID;AssociationForeignKey:PatientId;"`
193
+	DoctorAdvice         []*DoctorAdvice        `json:"doctoradvice" gorm:"foreignkey:AdviceDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
194
+	DialysisPrescription DialysisPrescription   `json:"prescription" gorm:"foreignkey:RecordDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
195
+	HisDoctorAdviceInfo  []*HisDoctorAdviceInfo `json:"hisdoctoradviceinfo" gorm:"foreignkey:AdviceDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
196
+	DialysisSolution     DialysisSolution       `json:"dialysissolution" gorm:"foreignkey:RecordDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
197
+}
198
+
199
+func (VmSchedulesRemind) TableName() string {
200
+	return "xt_schedule"
201
+}

+ 71 - 64
models/self_drug_models.go Zobrazit soubor

@@ -68,6 +68,10 @@ type XtBaseDrug struct {
68 68
 	Total                  float64 `gorm:"column:total" json:"total" form:"total"`
69 69
 	PrescribingNumberUnit  string  `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
70 70
 	MinNumber              int64   `gorm:"column:min_number" json:"min_number" form:"min_number"`
71
+	Dose                   float64 `gorm:"column:dose" json:"dose" form:"dose"`
72
+	DoseUnit               string  `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
73
+	DrugDay                string  `gorm:"column:drug_day" json:"drug_day" form:"drug_day"`
74
+	MinPrice               float64 `gorm:"column:min_price" json:"min_price" form:"min_price"`
71 75
 }
72 76
 
73 77
 func (XtBaseDrug) TableName() string {
@@ -322,33 +326,34 @@ func (XtDrugWarehouseOut) TableName() string {
322 326
 }
323 327
 
324 328
 type XtDrugWarehouseOutInfo struct {
325
-	ID                      int64   `gorm:"column:id" json:"id" form:"id"`
326
-	WarehouseOutId          int64   `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
327
-	DrugId                  int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
328
-	WarehousingOutTarget    int64   `gorm:"column:warehousing_out_target" json:"warehousing_out_target" form:"warehousing_out_target"`
329
-	Count                   int64   `gorm:"column:count" json:"count" form:"count"`
330
-	Price                   float64 `gorm:"column:price" json:"price" form:"price"`
331
-	TotalPrice              float64 `gorm:"column:total_price" json:"total_price" form:"total_price"`
332
-	ProductDate             int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
333
-	ExpiryDate              int64   `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
334
-	Mtime                   int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
335
-	Ctime                   int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
336
-	Status                  int64   `gorm:"column:status" json:"status" form:"status"`
337
-	OrgId                   int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
338
-	Remark                  string  `gorm:"column:remark" json:"remark" form:"remark"`
339
-	IsCancel                int64   `gorm:"column:is_cancel" json:"is_cancel" form:"is_cancel"`
340
-	WarehouseOutOrderNumber string  `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number" form:"warehouse_out_order_number"`
341
-	Type                    int64   `gorm:"column:type" json:"type" form:"type"`
342
-	Dealer                  int64   `gorm:"column:dealer" json:"dealer" form:"dealer"`
343
-	Manufacturer            int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
344
-	IsSys                   int64   `gorm:"column:is_sys" json:"is_sys" form:"is_sys"`
345
-	SysRecordTime           int64   `gorm:"column:sys_record_time" json:"sys_record_time" form:"sys_record_time"`
346
-	RetailPrice             float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
347
-	RetailTotalPrice        float64 `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
348
-	CountUnit               string  `gorm:"column:count_unit" json:"count_unit" form:"count_unit"`
349
-	WarehouseInfoId         int64   `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
350
-	Number                  string  `gorm:"column:number" json:"number" form:"number"`
351
-	BatchNumber             string  `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
329
+	ID                      int64      `gorm:"column:id" json:"id" form:"id"`
330
+	WarehouseOutId          int64      `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
331
+	DrugId                  int64      `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
332
+	WarehousingOutTarget    int64      `gorm:"column:warehousing_out_target" json:"warehousing_out_target" form:"warehousing_out_target"`
333
+	Count                   int64      `gorm:"column:count" json:"count" form:"count"`
334
+	Price                   float64    `gorm:"column:price" json:"price" form:"price"`
335
+	TotalPrice              float64    `gorm:"column:total_price" json:"total_price" form:"total_price"`
336
+	ProductDate             int64      `gorm:"column:product_date" json:"product_date" form:"product_date"`
337
+	ExpiryDate              int64      `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
338
+	Mtime                   int64      `gorm:"column:mtime" json:"mtime" form:"mtime"`
339
+	Ctime                   int64      `gorm:"column:ctime" json:"ctime" form:"ctime"`
340
+	Status                  int64      `gorm:"column:status" json:"status" form:"status"`
341
+	OrgId                   int64      `gorm:"column:org_id" json:"org_id" form:"org_id"`
342
+	Remark                  string     `gorm:"column:remark" json:"remark" form:"remark"`
343
+	IsCancel                int64      `gorm:"column:is_cancel" json:"is_cancel" form:"is_cancel"`
344
+	WarehouseOutOrderNumber string     `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number" form:"warehouse_out_order_number"`
345
+	Type                    int64      `gorm:"column:type" json:"type" form:"type"`
346
+	Dealer                  int64      `gorm:"column:dealer" json:"dealer" form:"dealer"`
347
+	Manufacturer            int64      `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
348
+	IsSys                   int64      `gorm:"column:is_sys" json:"is_sys" form:"is_sys"`
349
+	SysRecordTime           int64      `gorm:"column:sys_record_time" json:"sys_record_time" form:"sys_record_time"`
350
+	RetailPrice             float64    `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
351
+	RetailTotalPrice        float64    `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
352
+	CountUnit               string     `gorm:"column:count_unit" json:"count_unit" form:"count_unit"`
353
+	WarehouseInfoId         int64      `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
354
+	Number                  string     `gorm:"column:number" json:"number" form:"number"`
355
+	BatchNumber             string     `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
356
+	XtBaseDrug              XtBaseDrug `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" `
352 357
 }
353 358
 
354 359
 func (XtDrugWarehouseOutInfo) TableName() string {
@@ -356,18 +361,19 @@ func (XtDrugWarehouseOutInfo) TableName() string {
356 361
 }
357 362
 
358 363
 type XtDrugAutomaticReduceDetail struct {
359
-	ID                      int64  `gorm:"column:id" json:"id" form:"id"`
360
-	WarehouseOutId          int64  `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
361
-	WarehouseOutOrderNumber string `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number" form:"warehouse_out_order_number"`
362
-	PatientId               int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
363
-	Ctime                   int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
364
-	Mtime                   int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
365
-	Status                  int64  `gorm:"column:status" json:"status" form:"status"`
366
-	RecordTime              int64  `gorm:"column:record_time" json:"record_time" form:"record_time"`
367
-	OrgId                   int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
368
-	GoodId                  int64  `gorm:"column:good_id" json:"good_id" form:"good_id"`
369
-	GoodTypeId              int64  `gorm:"column:good_type_id" json:"good_type_id" form:"good_type_id"`
370
-	Count                   int64  `gorm:"column:count" json:"count" form:"count"`
364
+	ID                      int64      `gorm:"column:id" json:"id" form:"id"`
365
+	WarehouseOutId          int64      `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
366
+	WarehouseOutOrderNumber string     `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number" form:"warehouse_out_order_number"`
367
+	PatientId               int64      `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
368
+	Ctime                   int64      `gorm:"column:ctime" json:"ctime" form:"ctime"`
369
+	Mtime                   int64      `gorm:"column:mtime" json:"mtime" form:"mtime"`
370
+	Status                  int64      `gorm:"column:status" json:"status" form:"status"`
371
+	RecordTime              int64      `gorm:"column:record_time" json:"record_time" form:"record_time"`
372
+	OrgId                   int64      `gorm:"column:org_id" json:"org_id" form:"org_id"`
373
+	DrugId                  int64      `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
374
+	Count                   int64      `gorm:"column:count" json:"count" form:"count"`
375
+	CountUnit               string     `gorm:"column:count_unit" json:"count_unit" form:"count_unit"`
376
+	XtBaseDrug              XtBaseDrug `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" `
371 377
 }
372 378
 
373 379
 func (XtDrugAutomaticReduceDetail) TableName() string {
@@ -375,31 +381,32 @@ func (XtDrugAutomaticReduceDetail) TableName() string {
375 381
 }
376 382
 
377 383
 type XtDrugWarehouseInfo struct {
378
-	ID               int64   `gorm:"column:id" json:"id" form:"id"`
379
-	WarehousingId    int64   `gorm:"column:warehousing_id" json:"warehousing_id" form:"warehousing_id"`
380
-	DrugId           int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
381
-	Number           string  `gorm:"column:number" json:"number" form:"number"`
382
-	ProductDate      int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
383
-	ExpiryDate       int64   `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
384
-	WarehousingCount int64   `gorm:"column:warehousing_count" json:"warehousing_count" form:"warehousing_count"`
385
-	Price            float64 `gorm:"column:price" json:"price" form:"price"`
386
-	TotalPrice       float64 `gorm:"column:total_price" json:"total_price" form:"total_price"`
387
-	Dealer           int64   `gorm:"column:dealer" json:"dealer" form:"dealer"`
388
-	Manufacturer     int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
389
-	Remark           string  `gorm:"column:remark" json:"remark" form:"remark"`
390
-	Ctime            int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
391
-	Mtime            int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
392
-	Status           int64   `gorm:"column:status" json:"status" form:"status"`
393
-	OrgId            int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
394
-	IsReturn         int64   `gorm:"column:is_return" json:"is_return" form:"is_return"`
395
-	WarehousingOrder string  `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
396
-	Type             int64   `gorm:"column:type" json:"type" form:"type"`
397
-	RetailPrice      float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
398
-	RetailTotalPrice float64 `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
399
-	StockMaxNumber   int64   `gorm:"column:stock_max_number" json:"stock_max_number"`
400
-	StockMinNumber   int64   `gorm:"column:stock_min_number" json:"stock_min_number"`
401
-	BatchNumber      string  `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
402
-	MaxUnit          string  `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
384
+	ID               int64      `gorm:"column:id" json:"id" form:"id"`
385
+	WarehousingId    int64      `gorm:"column:warehousing_id" json:"warehousing_id" form:"warehousing_id"`
386
+	DrugId           int64      `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
387
+	Number           string     `gorm:"column:number" json:"number" form:"number"`
388
+	ProductDate      int64      `gorm:"column:product_date" json:"product_date" form:"product_date"`
389
+	ExpiryDate       int64      `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
390
+	WarehousingCount int64      `gorm:"column:warehousing_count" json:"warehousing_count" form:"warehousing_count"`
391
+	Price            float64    `gorm:"column:price" json:"price" form:"price"`
392
+	TotalPrice       float64    `gorm:"column:total_price" json:"total_price" form:"total_price"`
393
+	Dealer           int64      `gorm:"column:dealer" json:"dealer" form:"dealer"`
394
+	Manufacturer     int64      `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
395
+	Remark           string     `gorm:"column:remark" json:"remark" form:"remark"`
396
+	Ctime            int64      `gorm:"column:ctime" json:"ctime" form:"ctime"`
397
+	Mtime            int64      `gorm:"column:mtime" json:"mtime" form:"mtime"`
398
+	Status           int64      `gorm:"column:status" json:"status" form:"status"`
399
+	OrgId            int64      `gorm:"column:org_id" json:"org_id" form:"org_id"`
400
+	IsReturn         int64      `gorm:"column:is_return" json:"is_return" form:"is_return"`
401
+	WarehousingOrder string     `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
402
+	Type             int64      `gorm:"column:type" json:"type" form:"type"`
403
+	RetailPrice      float64    `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
404
+	RetailTotalPrice float64    `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
405
+	StockMaxNumber   int64      `gorm:"column:stock_max_number" json:"stock_max_number"`
406
+	StockMinNumber   int64      `gorm:"column:stock_min_number" json:"stock_min_number"`
407
+	BatchNumber      string     `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
408
+	MaxUnit          string     `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
409
+	XtBaseDrug       XtBaseDrug `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" `
403 410
 }
404 411
 
405 412
 func (XtDrugWarehouseInfo) TableName() string {

+ 275 - 0
models/stock_models.go Zobrazit soubor

@@ -368,6 +368,27 @@ func (AutomaticReduceDetail) TableName() string {
368 368
 	return "xt_automatic_reduce_detail"
369 369
 }
370 370
 
371
+type SgjAutomaticReduceDetail struct {
372
+	ID                      int64   `gorm:"column:id" json:"id"`
373
+	WarehouseOutId          int64   `gorm:"column:warehouse_out_id" json:"warehouse_out_id"`
374
+	WarehouseOutOrderNumber string  `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number"`
375
+	PatientId               int64   `gorm:"column:patient_id" json:"patient_id"`
376
+	Ctime                   int64   `gorm:"column:ctime" json:"ctime"`
377
+	Mtime                   int64   `gorm:"column:mtime" json:"mtime"`
378
+	Status                  int64   `gorm:"column:status" json:"status"`
379
+	RecordTime              int64   `gorm:"column:record_time" json:"record_time"`
380
+	OrgId                   int64   `gorm:"column:org_id" json:"org_id"`
381
+	GoodId                  int64   `gorm:"column:good_id" json:"good_id"`
382
+	GoodTypeId              int64   `gorm:"column:good_type_id" json:"good_type_id"`
383
+	Count                   int64   `gorm:"column:count" json:"count"`
384
+	Type                    int64   `gorm:"column:type" json:"type"`
385
+	GoodName                string  `gorm:"column:good_name" json:"good_name"`
386
+	SpecificationName       string  `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
387
+	PackingUnit             string  `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
388
+	RetailPrice             float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
389
+	PackingPrice            float64 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
390
+}
391
+
371 392
 type VmWarehouseOutInfo struct {
372 393
 	GoodId int64   `gorm:"column:good_id" json:"good_id"`
373 394
 	Count  int64   `gorm:"column:count" json:"count"`
@@ -520,6 +541,7 @@ type VmStockFlow struct {
520 541
 	CancelOutDetailId       int64   `gorm:"column:cancel_out_detail_id" json:"cancel_out_detail_id" form:"cancel_out_detail_id"`
521 542
 	ProductDate             int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
522 543
 	ExpireDate              int64   `gorm:"column:expire_date" json:"expire_date" form:"expire_date"`
544
+	ReturnCount             int64   `gorm:"column:return_count" json:"return_count" form:"return_count"`
523 545
 }
524 546
 
525 547
 func (VmStockFlow) TableName() string {
@@ -555,3 +577,256 @@ type CancelStockInfo struct {
555 577
 func (CancelStockInfo) TableName() string {
556 578
 	return "xt_cancel_stock_info"
557 579
 }
580
+
581
+type VmBaseDrug struct {
582
+	ID                          int64                     `gorm:"column:id" json:"id" form:"id"`
583
+	DrugName                    string                    `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
584
+	Pinyin                      string                    `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
585
+	Wubi                        string                    `gorm:"column:wubi" json:"wubi" form:"wubi"`
586
+	DrugAlias                   string                    `gorm:"column:drug_alias" json:"drug_alias" form:"drug_alias"`
587
+	DrugAliasPinyin             string                    `gorm:"column:drug_alias_pinyin" json:"drug_alias_pinyin" form:"drug_alias_pinyin"`
588
+	DrugAliasWubi               string                    `gorm:"column:drug_alias_wubi" json:"drug_alias_wubi" form:"drug_alias_wubi"`
589
+	DrugCategory                int64                     `gorm:"column:drug_category" json:"drug_category" form:"drug_category"`
590
+	DrugSpec                    string                    `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
591
+	DrugType                    int64                     `gorm:"column:drug_type" json:"drug_type" form:"drug_type"`
592
+	DrugStockLimit              string                    `gorm:"column:drug_stock_limit" json:"drug_stock_limit" form:"drug_stock_limit"`
593
+	DrugOriginPlace             string                    `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
594
+	DrugDosageForm              int64                     `gorm:"column:drug_dosage_form" json:"drug_dosage_form" form:"drug_dosage_form"`
595
+	MedicalInsuranceLevel       int64                     `gorm:"column:medical_insurance_level" json:"medical_insurance_level" form:"medical_insurance_level"`
596
+	MaxUnit                     string                    `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
597
+	MinNumber                   int64                     `gorm:"column:min_number" json:"min_number" form:"min_number"`
598
+	MinUnit                     string                    `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
599
+	Dose                        float64                   `gorm:"column:dose" json:"dose" form:"dose"`
600
+	DoseUnit                    string                    `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
601
+	UnitMatrixing               string                    `gorm:"column:unit_matrixing" json:"unit_matrixing" form:"unit_matrixing"`
602
+	RetailPrice                 float64                   `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
603
+	MinPrice                    float64                   `gorm:"column:min_price" json:"min_price" form:"min_price"`
604
+	LastPrice                   float64                   `gorm:"column:last_price" json:"last_price" form:"last_price"`
605
+	DrugControl                 int64                     `gorm:"column:drug_control" json:"drug_control" form:"drug_control"`
606
+	Number                      string                    `gorm:"column:number" json:"number" form:"number"`
607
+	DrugClassify                string                    `gorm:"column:drug_classify" json:"drug_classify" form:"drug_classify"`
608
+	DrugDose                    float64                   `gorm:"column:drug_dose" json:"drug_dose" form:"drug_dose"`
609
+	DrugDoseUnit                int64                     `gorm:"column:drug_dose_unit" json:"drug_dose_unit" form:"drug_dose_unit"`
610
+	MedicalInsuranceNumber      string                    `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
611
+	Manufacturer                int64                     `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
612
+	PharmacologyCategory        int64                     `gorm:"column:pharmacology_category" json:"pharmacology_category" form:"pharmacology_category"`
613
+	StatisticsCategory          int64                     `gorm:"column:statistics_category" json:"statistics_category" form:"statistics_category"`
614
+	Code                        string                    `gorm:"column:code" json:"code" form:"code"`
615
+	IsSpecialDiseases           int64                     `gorm:"column:is_special_diseases" json:"is_special_diseases" form:"is_special_diseases"`
616
+	IsRecord                    int64                     `gorm:"column:is_record" json:"is_record" form:"is_record"`
617
+	Agent                       string                    `gorm:"column:agent" json:"agent" form:"agent"`
618
+	DrugStatus                  string                    `gorm:"column:drug_status" json:"drug_status" form:"drug_status"`
619
+	LimitRemark                 string                    `gorm:"column:limit_remark" json:"limit_remark" form:"limit_remark"`
620
+	DeliveryWay                 string                    `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
621
+	ExecutionFrequency          string                    `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
622
+	SingleDose                  float64                   `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
623
+	PrescribingNumber           float64                   `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
624
+	Label                       int64                     `gorm:"column:label" json:"label" form:"label"`
625
+	Sort                        int64                     `gorm:"column:sort" json:"sort" form:"sort"`
626
+	IsUseDoctorAdvice           int64                     `gorm:"column:is_use_doctor_advice" json:"is_use_doctor_advice" form:"is_use_doctor_advice"`
627
+	IsDefault                   int64                     `gorm:"column:is_default" json:"is_default" form:"is_default"`
628
+	IsChargePredict             int64                     `gorm:"column:is_charge_predict" json:"is_charge_predict" form:"is_charge_predict"`
629
+	IsStatisticsWork            int64                     `gorm:"column:is_statistics_work" json:"is_statistics_work" form:"is_statistics_work"`
630
+	IsChargeUse                 int64                     `gorm:"column:is_charge_use" json:"is_charge_use" form:"is_charge_use"`
631
+	Status                      int64                     `gorm:"column:status" json:"status" form:"status"`
632
+	Ctime                       int64                     `gorm:"column:ctime" json:"ctime" form:"ctime"`
633
+	Mtime                       int64                     `gorm:"column:mtime" json:"mtime" form:"mtime"`
634
+	OrgId                       int64                     `gorm:"column:org_id" json:"org_id" form:"org_id"`
635
+	DrugCode                    string                    `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
636
+	Dealer                      int64                     `gorm:"column:dealer" json:"dealer" form:"dealer"`
637
+	PrescriptionMark            int64                     `gorm:"column:prescription_mark" json:"prescription_mark" form:"prescription_mark"`
638
+	RecordDate                  int64                     `gorm:"column:record_date" json:"record_date" form:"record_date"`
639
+	DrugRemark                  string                    `gorm:"column:drug_remark" json:"drug_remark" form:"drug_remark"`
640
+	SocialSecurityDirectoryCode string                    `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
641
+	DoseCode                    string                    `gorm:"column:dose_code" json:"dose_code" form:"dose_code"`
642
+	IsMark                      int64                     `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
643
+	HospApprFlag                int64                     `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
644
+	LmtUsedFlag                 int64                     `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
645
+	DrugDay                     string                    `gorm:"column:drug_day" json:"drug_day" form:"drug_day"`
646
+	Total                       float64                   `gorm:"column:total" json:"total" form:"total"`
647
+	PrescribingNumberUnit       string                    `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
648
+	DrugWarehouseInfo           []*VsDrugWarehouseInfo    `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_warehouse_info"`
649
+	DrugCancelStockInfo         []*VsDrugCancelStockInfo  `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_cancel_stock_info"`
650
+	DrugWarehouseOutInfo        []*VsDrugWarehouseOutInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_warehouse_out"`
651
+}
652
+
653
+func (VmBaseDrug) TableName() string {
654
+	return "xt_base_drug"
655
+}
656
+
657
+type VsDrugWarehouseInfo struct {
658
+	ID               int64   `gorm:"column:id" json:"id" form:"id"`
659
+	WarehousingId    int64   `gorm:"column:warehousing_id" json:"warehousing_id" form:"warehousing_id"`
660
+	DrugId           int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
661
+	Number           string  `gorm:"column:number" json:"number" form:"number"`
662
+	ProductDate      int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
663
+	ExpiryDate       int64   `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
664
+	WarehousingCount int64   `gorm:"column:warehousing_count" json:"warehousing_count" form:"warehousing_count"`
665
+	WarehouseingUnit string  `gorm:"column:warehouseing_unit" json:"warehouseing_unit" form:"warehouseing_unit"`
666
+	MaxUnit          string  `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
667
+	MinUnit          string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
668
+	StockMaxNumber   int64   `gorm:"column:stock_max_number" json:"stock_max_number" form:"stock_max_number"`
669
+	StockMinNumber   int64   `gorm:"column:stock_min_number" json:"stock_min_number" form:"stock_min_number"`
670
+	Price            float64 `gorm:"column:price" json:"price" form:"price"`
671
+	TotalPrice       float64 `gorm:"column:total_price" json:"total_price" form:"total_price"`
672
+	Dealer           int64   `gorm:"column:dealer" json:"dealer" form:"dealer"`
673
+	Manufacturer     int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
674
+	Remark           string  `gorm:"column:remark" json:"remark" form:"remark"`
675
+	Ctime            int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
676
+	Mtime            int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
677
+	Status           int64   `gorm:"column:status" json:"status" form:"status"`
678
+	OrgId            int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
679
+	IsReturn         int64   `gorm:"column:is_return" json:"is_return" form:"is_return"`
680
+	WarehousingOrder string  `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
681
+	Type             int64   `gorm:"column:type" json:"type" form:"type"`
682
+	RetailPrice      float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
683
+	RetailTotalPrice float64 `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
684
+	BatchNumber      string  `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
685
+}
686
+
687
+func (VsDrugWarehouseInfo) TableName() string {
688
+	return "xt_drug_warehouse_info"
689
+}
690
+
691
+type VsDrugCancelStockInfo struct {
692
+	ID               int64       `gorm:"column:id" json:"id" form:"id"`
693
+	DrugId           int64       `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
694
+	CancelStockId    int64       `gorm:"column:cancel_stock_id" json:"cancel_stock_id" form:"cancel_stock_id"`
695
+	Count            int64       `gorm:"column:count" json:"count" form:"count"`
696
+	Price            float64     `gorm:"column:price" json:"price" form:"price"`
697
+	Total            float64     `gorm:"column:total" json:"total" form:"total"`
698
+	ProductDate      int64       `gorm:"column:product_date" json:"product_date" form:"product_date"`
699
+	ExpiryDate       int64       `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
700
+	Ctime            int64       `gorm:"column:ctime" json:"ctime" form:"ctime"`
701
+	Mtime            int64       `gorm:"column:mtime" json:"mtime" form:"mtime"`
702
+	Status           int64       `gorm:"column:status" json:"status" form:"status"`
703
+	OrgId            int64       `gorm:"column:org_id" json:"org_id" form:"org_id"`
704
+	OrderNumber      string      `gorm:"column:order_number" json:"order_number" form:"order_number"`
705
+	Type             int64       `gorm:"column:type" json:"type" form:"type"`
706
+	Dealer           string      `gorm:"column:dealer" json:"dealer" form:"dealer"`
707
+	Manufacturer     string      `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
708
+	RetailPrice      float64     `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
709
+	RetailTotalPrice float64     `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
710
+	Number           string      `gorm:"column:number" json:"number" form:"number"`
711
+	RegisterAccount  string      `gorm:"column:register_account" json:"register_account" form:"register_account"`
712
+	Remark           string      `gorm:"column:remark" json:"remark" form:"remark"`
713
+	BatchNumber      string      `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
714
+	MaxUnit          string      `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
715
+	BaseDrugLib      BaseDrugLib `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" `
716
+}
717
+
718
+func (VsDrugCancelStockInfo) TableName() string {
719
+	return "xt_drug_cancel_stock_info"
720
+}
721
+
722
+type VsDrugWarehouseOutInfo struct {
723
+	ID                      int64   `gorm:"column:id" json:"id" form:"id"`
724
+	WarehouseOutId          int64   `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
725
+	DrugId                  int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
726
+	WarehousingOutTarget    int64   `gorm:"column:warehousing_out_target" json:"warehousing_out_target" form:"warehousing_out_target"`
727
+	Count                   int64   `gorm:"column:count" json:"count" form:"count"`
728
+	Price                   float64 `gorm:"column:price" json:"price" form:"price"`
729
+	TotalPrice              float64 `gorm:"column:total_price" json:"total_price" form:"total_price"`
730
+	ProductDate             int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
731
+	ExpiryDate              int64   `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
732
+	Mtime                   int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
733
+	Ctime                   int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
734
+	Status                  int64   `gorm:"column:status" json:"status" form:"status"`
735
+	OrgId                   int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
736
+	Remark                  string  `gorm:"column:remark" json:"remark" form:"remark"`
737
+	IsCancel                int64   `gorm:"column:is_cancel" json:"is_cancel" form:"is_cancel"`
738
+	WarehouseOutOrderNumber string  `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number" form:"warehouse_out_order_number"`
739
+	Type                    int64   `gorm:"column:type" json:"type" form:"type"`
740
+	Dealer                  int64   `gorm:"column:dealer" json:"dealer" form:"dealer"`
741
+	Manufacturer            int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
742
+	IsSys                   int64   `gorm:"column:is_sys" json:"is_sys" form:"is_sys"`
743
+	SysRecordTime           int64   `gorm:"column:sys_record_time" json:"sys_record_time" form:"sys_record_time"`
744
+	RetailPrice             float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
745
+	RetailTotalPrice        float64 `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
746
+	CountUnit               string  `gorm:"column:count_unit" json:"count_unit" form:"count_unit"`
747
+}
748
+
749
+func (VsDrugWarehouseOutInfo) TableName() string {
750
+	return "xt_drug_warehouse_out_info"
751
+}
752
+
753
+type VmStockFlowOne struct {
754
+	ID                      int64   `gorm:"column:id" json:"id" form:"id"`
755
+	WarehousingId           int64   `gorm:"column:warehousing_id" json:"warehousing_id" form:"warehousing_id"`
756
+	GoodId                  int64   `gorm:"column:good_id" json:"good_id" form:"good_id"`
757
+	Number                  string  `gorm:"column:number" json:"number" form:"number"`
758
+	Count                   int64   `gorm:"column:count" json:"count" form:"count"`
759
+	PatientId               int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
760
+	SystemTime              int64   `gorm:"column:system_time" json:"system_time" form:"system_time"`
761
+	IsSys                   int64   `gorm:"column:is_sys" json:"is_sys" form:"is_sys"`
762
+	WarehousingOrder        string  `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
763
+	WarehouseOutId          int64   `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
764
+	WarehouseOutOrderNumber string  `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number" form:"warehouse_out_order_number"`
765
+	Price                   float64 `gorm:"column:price" json:"price" form:"price"`
766
+	ProductDate             int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
767
+	ExpireDate              int64   `gorm:"column:expire_date" json:"expire_date" form:"expire_date"`
768
+	PackingUnit             string  `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
769
+	Ctime                   int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
770
+	Name                    string  `gorm:"column:name" json:"name" form:"name"`
771
+}
772
+
773
+type BloodWarehouseInfo struct {
774
+	ID                int64   `gorm:"column:id" json:"id" form:"id"`
775
+	WarehousingId     int64   `gorm:"column:warehousing_id" json:"warehousing_id" form:"warehousing_id"`
776
+	GoodId            int64   `gorm:"column:good_id" json:"good_id" form:"good_id"`
777
+	GoodTypeId        int64   `gorm:"column:good_type_id" json:"good_type_id" form:"good_type_id"`
778
+	Number            string  `gorm:"column:number" json:"number" form:"number"`
779
+	ProductDate       int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
780
+	ExpiryDate        int64   `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
781
+	WarehousingCount  int64   `gorm:"column:warehousing_count" json:"warehousing_count" form:"warehousing_count"`
782
+	WarehousingUnit   string  `gorm:"column:warehousing_unit" json:"warehousing_unit" form:"warehousing_unit"`
783
+	StockCount        int64   `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
784
+	Price             float64 `gorm:"column:price" json:"price" form:"price"`
785
+	TotalPrice        float64 `gorm:"column:total_price" json:"total_price" form:"total_price"`
786
+	Dealer            int64   `gorm:"column:dealer" json:"dealer" form:"dealer"`
787
+	Manufacturer      int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
788
+	Remark            string  `gorm:"column:remark" json:"remark" form:"remark"`
789
+	Ctime             int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
790
+	Mtime             int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
791
+	Status            int64   `gorm:"column:status" json:"status" form:"status"`
792
+	OrgId             int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
793
+	IsReturn          int64   `gorm:"column:is_return" json:"is_return" form:"is_return"`
794
+	WarehousingOrder  string  `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
795
+	Type              int64   `gorm:"column:type" json:"type" form:"type"`
796
+	LicenseNumber     string  `gorm:"column:license_number" json:"license_number" form:"license_number"`
797
+	GoodName          string  `gorm:"column:good_name" json:"good_name" form:"good_name"`
798
+	PackingPrice      float64 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
799
+	SpecificationName string  `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
800
+	PackingUnit       string  `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
801
+	BuyPrice          float64 `gorm:"column:buy_price" json:"buy_price" form:"buy_price"`
802
+}
803
+
804
+type XtStockAdjustPrice struct {
805
+	ID                int64   `gorm:"column:id" json:"id" form:"id"`
806
+	GoodName          string  `gorm:"column:good_name" json:"good_name" form:"good_name"`
807
+	SpecificationName string  `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
808
+	WarehousingUnit   string  `gorm:"column:warehousing_unit" json:"warehousing_unit" form:"warehousing_unit"`
809
+	Count             int64   `gorm:"column:count" json:"count" form:"count"`
810
+	BuyPrice          float64 `gorm:"column:buy_price" json:"buy_price" form:"buy_price"`
811
+	PackingPrice      float64 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
812
+	NewPrice          float64 `gorm:"column:new_price" json:"new_price" form:"new_price"`
813
+	Manufacturer      string  `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
814
+	Dealer            string  `gorm:"column:dealer" json:"dealer" form:"dealer"`
815
+	Remark            string  `gorm:"column:remark" json:"remark" form:"remark"`
816
+	GoodId            int64   `gorm:"column:good_id" json:"good_id" form:"good_id"`
817
+	UserOrgId         int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
818
+	Ctime             int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
819
+	Mtime             int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
820
+	Status            int64   `gorm:"column:status" json:"status" form:"status"`
821
+	WarehousingOrder  string  `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
822
+	LicenseNumber     string  `gorm:"column:license_number" json:"license_number" form:"license_number"`
823
+	StartTime         int64   `gorm:"column:start_time" json:"start_time" form:"start_time"`
824
+	Creater           int64   `gorm:"column:creater" json:"creater" form:"creater"`
825
+	Checker           int64   `gorm:"column:checker" json:"checker" form:"checker"`
826
+	CheckerStatus     int64   `gorm:"column:checker_status" json:"checker_status" form:"checker_status"`
827
+	CheckerTime       int64   `gorm:"column:checker_time" json:"checker_time" form:"checker_time"`
828
+}
829
+
830
+func (XtStockAdjustPrice) TableName() string {
831
+	return "xt_stock_adjust_price"
832
+}

+ 1 - 1
service/device_service.go Zobrazit soubor

@@ -387,7 +387,7 @@ type DeviceNumberViewModel struct {
387 387
 
388 388
 func GetAllValidDeviceNumbers(orgID int64) ([]*DeviceNumberViewModel, error) {
389 389
 	var vms []*DeviceNumberViewModel = make([]*DeviceNumberViewModel, 0)
390
-	rows, err := readDb.Raw("SELECT n.*, z.name as zone_name, g.name as group_name FROM xt_device_number as n join xt_device_zone as z on z.id = n.zone_id AND z.status = 1 join xt_device_group as g on g.id = n.group_id WHERE (n.org_id = ? AND n.status = 1)", orgID).Rows()
390
+	rows, err := readDb.Raw("SELECT n.*, z.name as zone_name, g.name as group_name FROM xt_device_number  as n join xt_device_zone as z on z.id = n.zone_id AND z.status = 1 join xt_device_group as g on g.id = n.group_id WHERE (n.org_id = ? AND n.status = 1) order by sort ", orgID).Rows()
391 391
 	defer rows.Close()
392 392
 	if err != nil {
393 393
 		return nil, err

+ 22 - 2
service/doctor_schedule_service.go Zobrazit soubor

@@ -591,8 +591,9 @@ func GetPatientSchedule(startime int64, zoneid int64, classtype int64, orgid int
591 591
 	if classtype > 0 {
592 592
 		db = db.Where("s.schedule_type = ?", classtype)
593 593
 	}
594
-	err = db.Preload("DeviceZone", " status= 1").Preload("DeviceNumber", "status= 1").
595
-		Preload("DialysisOrder", "status =1").Joins("JOIN xt_patients as p ON p.id = s.patient_id and p.lapseto = 1 and p.user_org_id =?", orgid).Where("s.user_org_id = ? and s.schedule_date = ? and s.status =1", orgid, startime).
594
+	err = db.Preload("DeviceZone", " status= 1").Preload("DeviceNumber", func(db *gorm.DB) *gorm.DB {
595
+		return XTReadDB().Model(&models.DeviceNumber{}).Where("status = 1 AND org_id = ?", orgid).Order("sort asc")
596
+	}).Preload("DialysisOrder", "status =1").Joins("JOIN xt_patients as p ON p.id = s.patient_id and p.lapseto = 1 and p.user_org_id =?", orgid).Where("s.user_org_id = ? and s.schedule_date = ? and s.status =1", orgid, startime).
596 597
 		Select("s.id, s.user_org_id, s.partition_id, s.bed_id, s.patient_id, s.schedule_date, s.schedule_type, s.schedule_week, s.mode_id,p.name as patient").Find(&schedule).Error
597 598
 	return schedule, err
598 599
 }
@@ -615,3 +616,22 @@ func GetSearchPatient(keywords string, orgid int64, startime int64) (schedule []
615 616
 		Select("s.id, s.user_org_id, s.partition_id, s.bed_id, s.patient_id, s.schedule_date, s.schedule_type, s.schedule_week, s.mode_id,p.name as patient").Find(&schedule).Error
616 617
 	return schedule, err
617 618
 }
619
+
620
+func GetStaffScheduleById(ids []string) (schedule []*models.XtSchedule, err error) {
621
+
622
+	err = XTReadDB().Where("id in(?)", ids).Find(&schedule).Error
623
+	return schedule, err
624
+
625
+}
626
+
627
+func UpdateStaffSchedule(nextid int64, schedule models.XtSchedule) error {
628
+
629
+	err := XTWriteDB().Model(&schedule).Where("id = ?", nextid).Updates(map[string]interface{}{"patient_id": schedule.PatientId, "mode_id": schedule.ModeId}).Error
630
+	return err
631
+}
632
+
633
+func UpdateStaffScheduleOne(nextid int64, schedule models.WeekSchedule) error {
634
+
635
+	err := XTWriteDB().Model(&schedule).Where("id = ?", nextid).Updates(map[string]interface{}{"patient_id": schedule.PatientId, "mode_id": schedule.ModeId}).Error
636
+	return err
637
+}

+ 67 - 0
service/drug_stock_service.go Zobrazit soubor

@@ -193,3 +193,70 @@ func GetDrugCancelExportList(orderid []string, orgid int64) (info []*models.Drug
193 193
 	err = db.Find(&info).Error
194 194
 	return info, err
195 195
 }
196
+
197
+func GetDrugWarehouseInfoPrint(startime int64, endtime int64, orgid int64) (info []*models.XtDrugWarehouseInfo, err error) {
198
+
199
+	db := XTReadDB().Table("xt_drug_warehouse_info").Where("status = 1")
200
+	if startime > 0 {
201
+		db = db.Where("ctime >=?", startime)
202
+	}
203
+	if endtime > 0 {
204
+		db = db.Where("ctime<=?", endtime)
205
+	}
206
+	if orgid > 0 {
207
+		db = db.Where("org_id = ?", orgid)
208
+	}
209
+	err = db.Preload("XtBaseDrug", "status = 1 and org_id = ?", orgid).Group("drug_id").Find(&info).Error
210
+
211
+	//err = db.Select("x.id,x.warehousing_id,x.drug_id,x.number,x.product_date,x.expiry_date,sum(x.warehousing_count) as warehousing_count,x.price,x.total_price,x.dealer,x.manufacturer,x.remark,x.is_return,x.warehousing_order,x.type,x.retail_price,x.retail_total_price,x.warehouseing_unit,x.max_unit,x.min_unit,x.stock_max_number,x.stock_min_number,x.batch_number").Group("x.drug_id").Find(&DrugWarehouseInfo{}).Error
212
+	return info, err
213
+}
214
+
215
+//func GetDrugWarehouseInfoList(startime int64,endtime int64,orgid int64)(info []*models.BloodAutomaticReduceDetail,err error)  {
216
+//
217
+//
218
+//  db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1")
219
+//  if startime > 0 {
220
+//    db = db.Where("x.ctime >=?", startime)
221
+//  }
222
+//  if endtime>0{
223
+//    db = db.Where("x.ctime<=?", endtime)
224
+//  }
225
+//  if orgid > 0{
226
+//    db = db.Where("x.org_id = ?", orgid)
227
+//  }
228
+//
229
+//
230
+//}
231
+
232
+func GetDrugOutOrderPrint(startime int64, endtime int64, orgid int64) (info []*models.XtDrugWarehouseOutInfo, err error) {
233
+
234
+	db := XTReadDB().Table("xt_drug_warehouse_out_info").Where("status = 1")
235
+	if startime > 0 {
236
+		db = db.Where("ctime >=?", startime)
237
+	}
238
+	if endtime > 0 {
239
+		db = db.Where("ctime<=?", endtime)
240
+	}
241
+	if orgid > 0 {
242
+		db = db.Where("org_id = ?", orgid)
243
+	}
244
+	err = db.Preload("XtBaseDrug", "status = 1 and org_id = ?", orgid).Group("drug_id").Find(&info).Error
245
+	return info, err
246
+}
247
+
248
+func GetDrugOutOrderPrintList(startime int64, endtime int64, orgid int64) (list []*models.XtDrugAutomaticReduceDetail, err error) {
249
+
250
+	db := XTReadDB().Table("xt_drug_automatic_reduce_detail").Where("status = 1")
251
+	if startime > 0 {
252
+		db = db.Where("ctime >=?", startime)
253
+	}
254
+	if endtime > 0 {
255
+		db = db.Where("ctime<=?", endtime)
256
+	}
257
+	if orgid > 0 {
258
+		db = db.Where("org_id = ?", orgid)
259
+	}
260
+	err = db.Preload("XtBaseDrug", "status = 1 and org_id = ?", orgid).Find(&list).Error
261
+	return list, err
262
+}

+ 45 - 4
service/gobal_config_service.go Zobrazit soubor

@@ -499,7 +499,6 @@ func GetDrugWarehuseOrderInfo(orgid int64) (drug []*models.DrugWarehouseInfo, er
499 499
 func GetDrugStockList(page int64, limit int64, keyword string, drugcategory int64, startime int64, endtime int64, orgid int64) (list []*models.StDrugWarehouseInfo, total int64, err error) {
500 500
 	offset := (page - 1) * limit
501 501
 	db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1")
502
-
503 502
 	likeKey := "%" + keyword + "%"
504 503
 	if orgid > 0 {
505 504
 		db = db.Where("x.org_id = ?", orgid)
@@ -537,6 +536,26 @@ func GetDrugStockList(page int64, limit int64, keyword string, drugcategory int6
537 536
 	return list, total, err
538 537
 }
539 538
 
539
+func GetAllBaseDurgListCount(page int64, limit int64, keyword string, drugcategory int64, startime int64, endtime int64, orgid int64) (drug []*models.VmBaseDrug, total int64, err error) {
540
+
541
+	offset := (page - 1) * limit
542
+	db := XTReadDB().Table("xt_base_drug").Where("status = 1")
543
+	likeKey := "%" + keyword + "%"
544
+	if orgid > 0 {
545
+		db = db.Where("org_id = ?", orgid)
546
+	}
547
+	if drugcategory > 0 {
548
+		db = db.Where("drug_type = ?", drugcategory)
549
+	}
550
+
551
+	if len(keyword) > 0 {
552
+		db = db.Where("drug_name like ?", likeKey)
553
+	}
554
+
555
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("ctime desc").Preload("DrugWarehouseInfo", "status=1 and org_id = ? and ctime >=? and ctime<=?", orgid, startime, endtime).Preload("DrugCancelStockInfo", "status=1 and org_id = ? and ctime >=? and ctime<=?", orgid, startime, endtime).Preload("DrugWarehouseOutInfo", "status=1 and org_id = ? and ctime >=? and ctime<=?", orgid, startime, endtime).Find(&drug).Error
556
+	return drug, total, err
557
+}
558
+
540 559
 func GetDrugStockFlow(drugid int64, startime int64, endtime int64, page int64, limit int64, orgid int64) (list []*models.StDrugWarehouseInfo, total int64, err error) {
541 560
 
542 561
 	db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1")
@@ -643,7 +662,7 @@ func GetOutDrugCountList(startime int64, endtime int64, orgid int64) (info []*mo
643 662
 	if orgid > 0 {
644 663
 		db = db.Where("x.org_id = ?", orgid)
645 664
 	}
646
-	err = db.Select("sum(x.count) as count,x.drug_id").Group("x.drug_id").Scan(&info).Error
665
+	err = db.Select("x.count,x.drug_id,x.count_unit").Find(&info).Error
647 666
 	return info, err
648 667
 }
649 668
 
@@ -659,7 +678,7 @@ func GetAutoDrugCountList(startime int64, endtime int64, orgid int64) (info []*m
659 678
 	if orgid > 0 {
660 679
 		db = db.Where("x.org_id = ?", orgid)
661 680
 	}
662
-	err = db.Select("sum(x.count) as count,x.drug_id").Group("x.drug_id").Scan(&info).Error
681
+	err = db.Select("x.count,x.drug_id,x.count_unit").Find(&info).Error
663 682
 	return info, err
664 683
 
665 684
 }
@@ -681,6 +700,22 @@ func GetCancelDrugCountList(startime int64, endtime int64, orgid int64) (info []
681 700
 	return info, err
682 701
 }
683 702
 
703
+func GetAllCountList(startime int64, endtime int64, orgid int64) (info []*models.DrugWarehouseInfo, err error) {
704
+	db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1")
705
+
706
+	if startime > 0 {
707
+		db = db.Where("x.ctime >=?", startime)
708
+	}
709
+	if endtime > 0 {
710
+		db = db.Where("x.ctime<=?", endtime)
711
+	}
712
+	if orgid > 0 {
713
+		db = db.Where("x.org_id = ?", orgid)
714
+	}
715
+	err = db.Find(&info).Error
716
+	return info, err
717
+}
718
+
684 719
 func GetSingleOrderDetail(id int64, orgid int64) (info []*models.VmDrugWarehouseOutInfo, err error) {
685 720
 
686 721
 	db := XTReadDB().Table("xt_drug_warehouse_out_info as x").Where("x.status = 1")
@@ -697,6 +732,12 @@ func GetSingleOrderDetail(id int64, orgid int64) (info []*models.VmDrugWarehouse
697 732
 	return info, err
698 733
 }
699 734
 
735
+func GetDrugStockFlowDetail(id int64, orgid int64) (drugflow []*models.XtDrugAutomaticReduceDetail, err error) {
736
+
737
+	err = XTReadDB().Where("record_time = ? and org_id = ? and status = 1", id, orgid).Find(&drugflow).Error
738
+	return drugflow, err
739
+}
740
+
700 741
 func GetAllSingleDrugDetail(id int64, orgid int64) (outInfo []*models.VmDrugWarehouseOutInfo, err error) {
701 742
 
702 743
 	db := XTReadDB().Table("xt_drug_warehouse_out_info as x").Where("x.status = 1")
@@ -734,6 +775,6 @@ func FindeDrugWarehouserInfo(ware_out_id int64, drug_id int64, orgid int64) (out
734 775
 
735 776
 func GetDrugFlowBatch(ware_out_id int64, drug_id int64, orgid int64) (flow []*models.DrugFlow, err error) {
736 777
 
737
-	err = XTReadDB().Where("warehouse_out_id = ? and drug_id = ? and user_org_id = ? and status = 1", ware_out_id, drug_id, orgid).Group("number").Find(&flow).Error
778
+	err = XTReadDB().Where("warehouse_out_id = ? and drug_id = ? and user_org_id = ? and status = 1", ware_out_id, drug_id, orgid).Find(&flow).Error
738 779
 	return flow, err
739 780
 }

+ 1 - 1
service/mobile_dialysis_service.go Zobrazit soubor

@@ -521,7 +521,7 @@ func MobileGetDoctorAdvicesByGroups(orgID int64, patientID int64, recordDate int
521 521
 
522 522
 	err := readDb.
523 523
 		Model(&models.DoctorAdvice{}).
524
-		Where("patient_id = ? and user_org_id = ? and status = 1 and record_date = ? and advice_type = 2", patientID, orgID, recordDate).
524
+		Where("patient_id = ? and user_org_id = ? and status = 1 and record_date = ? and (advice_type = 2 || advice_type = 3)", patientID, orgID, recordDate).
525 525
 		Select("id, user_org_id, patient_id, advice_type, advice_date, record_date, start_time, advice_name,advice_desc, reminder_date, drug_spec, drug_spec_unit, single_dose, single_dose_unit, prescribing_number, prescribing_number_unit, delivery_way, execution_frequency, advice_doctor, status, created_time,updated_time, advice_affirm, remark, stop_time, stop_reason, stop_doctor, stop_state, parent_id, execution_time, execution_staff, execution_state, checker, check_state, check_time, groupno,way,drug_id,drug_name_id, IF(parent_id > 0, parent_id, id) as advice_order").
526 526
 		Order("start_time asc, groupno desc, advice_order desc, id asc").
527 527
 		Scan(&records).Error

+ 144 - 0
service/patientmanage_service.go Zobrazit soubor

@@ -1621,3 +1621,147 @@ func GetTotalBedNumber(orgid int64, ids []string) (list []*models.XtDeviceNumber
1621 1621
 	err = db.Count(&total).Find(&list).Error
1622 1622
 	return list, total, err
1623 1623
 }
1624
+
1625
+func GetInspectionMajorItem(startime int64, orgid int64, patientid int64) (inspection []*models.XtInspection, err error) {
1626
+
1627
+	db := XTReadDB().Table("xt_inspection as x").Where("x.status = 1")
1628
+	if startime > 0 {
1629
+		db = db.Where("x.inspect_date<=?", startime)
1630
+	}
1631
+	if orgid > 0 {
1632
+		db = db.Where("x.org_id = ?", orgid)
1633
+	}
1634
+	if patientid > 0 {
1635
+		db = db.Where("x.patient_id = ?", patientid)
1636
+	}
1637
+	err = db.Group("x.project_id").Find(&inspection).Error
1638
+	return inspection, err
1639
+}
1640
+
1641
+func GetInspectionDetailByProject(project_id int64, patientid int64, inspect_date int64, orgid int64) (inspection []*models.VmInspection, err error) {
1642
+
1643
+	db := XTReadDB().Table("xt_inspection as x").Where("x.status = 1")
1644
+	table := XTReadDB().Table("xt_inspection_reference as t").Where("t.status = 1")
1645
+	fmt.Println(table)
1646
+	if inspect_date > 0 {
1647
+		db = db.Where("x.inspect_date=?", inspect_date)
1648
+	}
1649
+	if orgid > 0 {
1650
+		db = db.Where("x.org_id = ?", orgid)
1651
+	}
1652
+	if patientid > 0 {
1653
+		db = db.Where("x.patient_id = ?", patientid)
1654
+	}
1655
+	if project_id > 0 {
1656
+		db = db.Where("x.project_id = ?", project_id)
1657
+	}
1658
+	err = db.Select("x.id,x.patient_id,x.org_id,x.project_id,x.item_id,x.item_name,x.project_name,x.inspect_type,x.inspect_value,x.inspect_date,t.range_max,t.range_min,t.range_value,t.unit").Joins("left join xt_inspection_reference as t on t.id = x.item_id").Scan(&inspection).Error
1659
+	return inspection, err
1660
+}
1661
+
1662
+func GetInspectionItemlist(patientid int64, inspect_date []string, projectid []string) (inspection []*models.VmInspection, err error) {
1663
+
1664
+	db := XTReadDB().Table("xt_inspection as x").Where("x.status = 1")
1665
+	table := XTReadDB().Table("xt_inspection_reference as s").Where("s.status = 1")
1666
+	fmt.Println(table)
1667
+	if patientid > 0 {
1668
+		db = db.Where("x.patient_id = ?", patientid)
1669
+	}
1670
+	if len(inspect_date) > 0 {
1671
+		db = db.Where("x.inspect_date in(?)", inspect_date)
1672
+	}
1673
+
1674
+	if len(projectid) > 0 {
1675
+		db = db.Where("x.project_id in(?)", projectid)
1676
+	}
1677
+
1678
+	err = db.Select("x.id,x.patient_id,x.org_id,x.project_id,x.item_id,x.item_name,x.project_name,x.inspect_type,x.inspect_value,x.inspect_date,t.range_max,t.range_min,t.range_value,t.unit").Joins("left join xt_inspection_reference as t on t.id = x.item_id").Scan(&inspection).Error
1679
+	return inspection, err
1680
+}
1681
+
1682
+func GetDialysisBeforInitDateList(patient_id int64) (models.PredialysisEvaluation, error) {
1683
+	befor := models.PredialysisEvaluation{}
1684
+	db := XTReadDB().Model(&befor).Where("status = 1")
1685
+	if patient_id > 0 {
1686
+		db = db.Where("patient_id = ? and assessment_date>=1627747200 and assessment_date<=1630339200 ", patient_id)
1687
+	}
1688
+
1689
+	err = db.Last(&befor).Error
1690
+	return befor, err
1691
+}
1692
+
1693
+func GetDialysisPrescriptionDataList(patient_id int64) (models.DialysisPrescription, error) {
1694
+
1695
+	prescription := models.DialysisPrescription{}
1696
+	db := XTReadDB().Model(&prescription).Where("status = 1")
1697
+	if patient_id > 0 {
1698
+		db = db.Where("patient_id = ? and record_date>=1627747200 and record_date<=1630339200", patient_id)
1699
+	}
1700
+	err = db.Last(&prescription).Error
1701
+	return prescription, err
1702
+}
1703
+
1704
+func GetDialysisAssementAfter(patient_id int64) (models.AssessmentAfterDislysis, error) {
1705
+
1706
+	after := models.AssessmentAfterDislysis{}
1707
+	db := XTReadDB().Model(&after).Where("status = 1")
1708
+	if patient_id > 0 {
1709
+		db = db.Where("patient_id = ? and assessment_date>=1627747200 and assessment_date<=1630339200", patient_id)
1710
+	}
1711
+	err = db.Last(&after).Error
1712
+	return after, err
1713
+}
1714
+
1715
+func GetDialysisDialysisMode(patient_id int64) (counts []*models.PatientPrescriptionCountStruct, err error) {
1716
+
1717
+	db := readDb.Table("xt_dialysis_order as o").Where("o.status = 1")
1718
+	table := readDb.Table("xt_schedule as s").Where("s.status = 1")
1719
+	fmt.Println(table)
1720
+	p := readDb.Table("xt_patients as p").Where("p.status = 1")
1721
+	fmt.Println(p)
1722
+	//if starttime > 0 {
1723
+	//  db = db.Where("o.dialysis_date >=?", starttime)
1724
+	//}
1725
+	//if endtime > 0 {
1726
+	//  db = db.Where("o.dialysis_date<=?", endtime)
1727
+	//}
1728
+	//if orgid > 0 {
1729
+	//  db = db.Where("o.user_org_id = ?", orgid)
1730
+	//}
1731
+	if patient_id > 0 {
1732
+		db = db.Where("o.patient_id = ?", patient_id)
1733
+	}
1734
+	err = db.Where("o.dialysis_date >=1627747200 and o.dialysis_date<=1630339200").Select("s.mode_id,count(s.mode_id) as count").Joins("left join xt_schedule as s on s.patient_id = o.patient_id and s.schedule_date = o.dialysis_date and s.status= 1").Joins("left join xt_patients as  p on o.patient_id = p.id").Group("s.mode_id").Scan(&counts).Error
1735
+	return counts, err
1736
+}
1737
+
1738
+func CreateSummary(summary *models.XtTemplateSummary) error {
1739
+
1740
+	err = XTWriteDB().Create(&summary).Error
1741
+	return err
1742
+}
1743
+
1744
+func UpdateTempalteSummary(summary *models.XtTemplateSummary) error {
1745
+
1746
+	err = XTWriteDB().Save(&summary).Error
1747
+	return err
1748
+}
1749
+
1750
+func GetTemplateSummaryList(patientid int64, orgid int64) (summary []*models.XtTemplateSummary, err error) {
1751
+
1752
+	err = XTReadDB().Where("patient_id = ? and user_org_id = ? and status = 1", patientid, orgid).Find(&summary).Error
1753
+	return summary, err
1754
+}
1755
+
1756
+func GetTemplateSummaryDetail(id int64) (models.XtTemplateSummary, error) {
1757
+	summary := models.XtTemplateSummary{}
1758
+	err := XTReadDB().Model(&summary).Where("id=?", id).Find(&summary).Error
1759
+	return summary, err
1760
+}
1761
+
1762
+func GetTemplateSummaryPrintDetail(id int64) (models.XtTemplateSummary, error) {
1763
+
1764
+	summary := models.XtTemplateSummary{}
1765
+	err := XTReadDB().Model(&summary).Where("id=? and status = 1", id).Preload("Patients", "status = 1").Find(&summary).Error
1766
+	return summary, err
1767
+}

+ 21 - 2
service/print_data_service/schedule_dialysis/print_schedule_dialysis_service.go Zobrazit soubor

@@ -216,7 +216,7 @@ func GetGoodInfomationList(orgid int64) (goodInfo []*models.GoodInfo, err error)
216 216
 }
217 217
 
218 218
 func GetWarehouseInfoGoodDetailPrintList(orgid int64, startime int64, endtime int64, limit int64, page int64) (info []*models.VmWarehousingInfo, err error) {
219
-	offset := (page - 1) * limit
219
+	//offset := (page - 1) * limit
220 220
 	db := p_service.XTReadDB().Table("xt_warehouse_info as x").Where("x.status = 1")
221 221
 	table := p_service.XTReadDB().Table("xt_good_information as t").Where("t.status = 1")
222 222
 	fmt.Println(table)
@@ -231,6 +231,25 @@ func GetWarehouseInfoGoodDetailPrintList(orgid int64, startime int64, endtime in
231 231
 		db = db.Where("x.ctime<=?", endtime)
232 232
 	}
233 233
 
234
-	err = db.Select("x.id,x.warehousing_id,x.good_id,x.good_type_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.warehousing_unit,x.stock_count,x.price,x.total_price,x.dealer,x.manufacturer,x.remark,x.is_return,x.warehousing_order,x.type,x.license_number,t.good_name,t.specification_name,t.min_number,t.packing_unit").Joins("left join xt_good_information as t on t.id = x.good_id").Offset(offset).Limit(limit).Scan(&info).Error
234
+	err = db.Select("x.id,x.warehousing_id,x.good_id,x.good_type_id,x.number,x.product_date,x.expiry_date,sum(x.warehousing_count) as warehousing_count,x.warehousing_unit,x.stock_count,x.price,x.total_price,x.dealer,x.manufacturer,x.remark,x.is_return,x.warehousing_order,x.type,x.license_number,t.good_name,t.specification_name,t.min_number,t.packing_unit").Joins("left join xt_good_information as t on t.id = x.good_id").Group("x.good_id").Scan(&info).Error
235 235
 	return info, err
236 236
 }
237
+
238
+func GetWarehouseOutInfoGoodDetailPrintList(orgid int64, startime int64, endtime int64, limit int64, page int64) (auto []*models.SgjAutomaticReduceDetail, err error) {
239
+
240
+	db := p_service.XTReadDB().Table("xt_automatic_reduce_detail as x").Where("x.status = 1")
241
+	table := p_service.XTReadDB().Table("xt_good_information as t").Where("t.status = 1")
242
+	fmt.Println(table)
243
+	if orgid > 0 {
244
+		db = db.Where("x.org_id = ?", orgid)
245
+	}
246
+	if startime > 0 {
247
+		db = db.Where("x.ctime >= ?", startime)
248
+	}
249
+	if endtime > 0 {
250
+		db = db.Where("x.ctime<=?", endtime)
251
+	}
252
+	err = db.Select("x.patient_id,x.record_time,x.good_id,sum(x.count) as count,t.good_name,t.specification_name,t.packing_unit,t.retail_price,t.packing_price").Joins("left join xt_good_information as t on t.id = x.good_id").Group("x.good_id").Scan(&auto).Error
253
+	return auto, err
254
+
255
+}

+ 4 - 2
service/schedule_service.go Zobrazit soubor

@@ -564,7 +564,7 @@ func GetWeekDaySchedule(orgID int64, scheduleDate int64, scheduleDates *time.Tim
564 564
 	return
565 565
 }
566 566
 
567
-func GetWeekDayScheduleById(orgid int64, scheduleDate int64, scheduleType int64) (list []*models.VmSchedules, err error) {
567
+func GetWeekDayScheduleById(orgid int64, scheduleDate int64, scheduleType int64) (list []*models.VmSchedulesRemind, err error) {
568 568
 
569 569
 	db := XTReadDB().Table("xt_schedule as x").Where("x.status = 1")
570 570
 	if orgid > 0 {
@@ -579,7 +579,9 @@ func GetWeekDayScheduleById(orgid int64, scheduleDate int64, scheduleType int64)
579 579
 
580 580
 	err = db.Select("x.id,x.user_org_id,x.partition_id,x.bed_id,x.patient_id,x.schedule_date,x.schedule_type,x.schedule_week,x.mode_id,x.is_export").Preload("XtPatients", "status = 1").Preload("DeviceZone", "status = 1").Preload("DeviceNumber", "status = 1").Preload("DialysisOrder", "status = 1").Preload("DoctorAdvice", func(db *gorm.DB) *gorm.DB {
581 581
 		return db.Where("status =1 and parent_id = 0").Preload("ChildDoctorAdvice", "status = 1")
582
-	}).Preload("HisDoctorAdviceInfo", "status = 1").Preload("DialysisPrescription", "status = 1").Preload("DialysisSolution", "status = 1 and user_org_id = ?", orgid).Find(&list).Error
582
+	}).Preload("HisDoctorAdviceInfo", "status = 1").Preload("DialysisPrescription", "status = 1").Preload("DialysisSolution", func(db *gorm.DB) *gorm.DB {
583
+		return db.Where("status =1").Order("id asc")
584
+	}).Find(&list).Error
583 585
 
584 586
 	return list, err
585 587
 }

+ 192 - 2
service/stock_service.go Zobrazit soubor

@@ -488,8 +488,8 @@ func UpdateDrugInfo(warehousingInfo []*models.DrugWarehouseInfo) (err error) {
488 488
 func FindDrugWaresingCount(drug_id int64, orgid int64) (models.XtDrugWarehouseInfo, error) {
489 489
 
490 490
 	info := models.XtDrugWarehouseInfo{}
491
-	db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1")
492
-	err = db.Select("x.stock_max_number,x.drug_id").Where("x.drug_id = ? and x.org_id = ? and x.status =1", drug_id, orgid).Last(&info).Error
491
+	db := XTReadDB().Table("xt_drug_warehouse_info").Where("status = 1")
492
+	err = db.Select("stock_max_number,drug_id").Where("drug_id = ? and org_id = ? and status =1", drug_id, orgid).Last(&info).Error
493 493
 	return info, err
494 494
 }
495 495
 
@@ -505,6 +505,11 @@ func UpdateBaseDrug(lib *models.BaseDrugLib, id int64) error {
505 505
 	err := XTWriteDB().Model(&lib).Where("id = ?", id).Updates(map[string]interface{}{"total": lib.Total}).Error
506 506
 	return err
507 507
 }
508
+func FindeLastWarehouseInfo(id int64) (models.DrugWarehouseInfo, error) {
509
+	info := models.DrugWarehouseInfo{}
510
+	err := XTReadDB().Model(&info).Where("id=? and status = 1", id).Find(&info).Error
511
+	return info, err
512
+}
508 513
 
509 514
 func CreateDrugFlow(drugflow []*models.DrugFlow) (err error) {
510 515
 	if len(drugflow) > 0 {
@@ -1397,6 +1402,7 @@ type DrugWarehouseOutInfo struct {
1397 1402
 	Number                  string  `gorm:"column:number" json:"number" form:"number"`
1398 1403
 	BatchNumber             string  `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
1399 1404
 	Drug                    *Drug   `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug"`
1405
+	WarehouseInfoId         int64   `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
1400 1406
 }
1401 1407
 
1402 1408
 func (DrugWarehouseOutInfo) TableName() string {
@@ -1799,6 +1805,13 @@ func GetLastWarehousingById(warehousing_id int64, orgid int64) (models.Warehousi
1799 1805
 	return info, err
1800 1806
 }
1801 1807
 
1808
+func GetLastWarehousingByIdOne(warehousing_id int64, orgid int64) (models.WarehousingInfo, error) {
1809
+
1810
+	info := models.WarehousingInfo{}
1811
+	err = XTReadDB().Model(&info).Where("id = ? and good_id = ? and status = 1", warehousing_id, orgid).Find(&info).Error
1812
+	return info, err
1813
+}
1814
+
1802 1815
 func UpDateWarehousingInfo(info *models.WarehousingInfo) (err error) {
1803 1816
 	err = writeDb.Save(&info).Error
1804 1817
 	return err
@@ -3168,6 +3181,26 @@ func GetAllStockList(page int64, limit int64, startime int64, endtime int64, goo
3168 3181
 	return info, total, err
3169 3182
 }
3170 3183
 
3184
+func GetAllGoodInfoStockList(page int64, limit int64, startime int64, endtime int64, good_type int64, keyword string, orgid int64) (info []*models.GoodInfo, total int64, err error) {
3185
+
3186
+	offset := (page - 1) * limit
3187
+	db := XTReadDB().Table("xt_good_information as x").Where("x.status= 1")
3188
+
3189
+	likeKey := "%" + keyword + "%"
3190
+	if len(likeKey) > 0 {
3191
+		db = db.Where("x.good_name like ?", likeKey)
3192
+	}
3193
+	if orgid > 0 {
3194
+		db = db.Where("x.org_id = ?", orgid)
3195
+	}
3196
+	if good_type > 0 {
3197
+		db = db.Where("x.good_type_id = ?", good_type)
3198
+	}
3199
+
3200
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("x.ctime desc").Preload("StWarehousingInfo", "status= 1 and org_id =? and ctime>=? and ctime<=?", orgid, startime, endtime).Preload("CancelStockInfo", "status= 1 and org_id =? and ctime>=? and ctime<=?", orgid, startime, endtime).Find(&info).Error
3201
+	return info, total, err
3202
+}
3203
+
3171 3204
 func GetStockListById(good_id int64, orgid int64, limit int64, page int64, startime int64, endtime int64) (info []*models.VmWarehousingInfo, total int64, err error) {
3172 3205
 
3173 3206
 	offset := (page - 1) * limit
@@ -3343,6 +3376,11 @@ func GetGoodInformationByGoodId(good_id int64) (models.GoodInfo, error) {
3343 3376
 	err := XTReadDB().Where("id = ? and status = 1", good_id).Find(&info).Error
3344 3377
 	return info, err
3345 3378
 }
3379
+func UpdateGoodInfoList(info models.GoodInfo, id int64) error {
3380
+
3381
+	err := XTWriteDB().Model(&info).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"total": info.Total}).Error
3382
+	return err
3383
+}
3346 3384
 
3347 3385
 func GetExprotStockList(orgid int64, orderid []string, startime int64, endtime int64) (info []*models.StWarehousingInfo, err error) {
3348 3386
 
@@ -3514,6 +3552,35 @@ func GetDrugTotalCount(drugid int64, orgid int64) (info models.VmDrugWarehouseIn
3514 3552
 	return info, err
3515 3553
 }
3516 3554
 
3555
+func GetDrugTotalCountSwx(id int64, orgid int64) (info models.VmDrugWarehouseInfo, err error) {
3556
+
3557
+	db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1")
3558
+	if id > 0 {
3559
+		db = db.Where("x.id = ?", id)
3560
+	}
3561
+	if orgid > 0 {
3562
+		db = db.Where("x.org_id = ?", orgid)
3563
+	}
3564
+	err = db.Select("x.drug_id,sum(x.stock_max_number) as count,sum(x.stock_min_number) as stock_min_number,x.max_unit,x.min_unit").Find(&info).Error
3565
+	return info, err
3566
+}
3567
+
3568
+func GetDrugTotalCountOne(drugid int64, orgid int64, id int64) (models.VmDrugWarehouseInfo, error) {
3569
+	info := models.VmDrugWarehouseInfo{}
3570
+	db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1")
3571
+	if id == 0 {
3572
+		db = db.Where("id = ?", id)
3573
+	}
3574
+	if drugid > 0 {
3575
+		db = db.Where("x.drug_id = ?", drugid)
3576
+	}
3577
+	if orgid > 0 {
3578
+		db = db.Where("x.org_id = ?", orgid)
3579
+	}
3580
+	err = db.Select("x.drug_id,x.stock_max_number,x.stock_min_number,x.max_unit,x.min_unit").Find(&info).Error
3581
+	return info, err
3582
+}
3583
+
3517 3584
 func GetDrugByGoodId(drugid int64) (models.BaseDrugLib, error) {
3518 3585
 
3519 3586
 	lib := models.BaseDrugLib{}
@@ -3668,6 +3735,12 @@ func GetWarehoureOrderInfoCount(goodid int64, orgid int64) (info models.Warehous
3668 3735
 	return info, err
3669 3736
 }
3670 3737
 
3738
+func UpdateCancelInfo(id int64) (models.CancelStock, error) {
3739
+	stock := models.CancelStock{}
3740
+	err := XTWriteDB().Model(&stock).Where("id=? and status = 1", id).Updates(map[string]interface{}{"status": 0}).Error
3741
+	return stock, err
3742
+}
3743
+
3671 3744
 func GetStockBatchNumber(id int64, orgid int64) (info []*models.WarehousingInfo, err error) {
3672 3745
 
3673 3746
 	err = XTReadDB().Model(&info).Where("good_id = ? and org_id = ? and status = 1 and number <> ''", id, orgid).Group("number").Find(&info).Error
@@ -3686,6 +3759,25 @@ func GetStockFlowBatchNumber(id int64, goodid int64) (stock []*models.VmStockFlo
3686 3759
 	return stock, err
3687 3760
 }
3688 3761
 
3762
+func GetStockFlowBatchNumberOne(id int64, goodid int64) (stock []*models.VmStockFlowOne, err error) {
3763
+
3764
+	db := XTReadDB().Table("xt_stock_flow as x").Where("x.status = 1")
3765
+	table := XTReadDB().Table("xt_patients as t").Where("t.status = 1")
3766
+	fmt.Println(table)
3767
+	tableone := XTReadDB().Table("xt_good_information as o").Where("o.status = 1")
3768
+	fmt.Println(tableone)
3769
+	if id > 0 {
3770
+		db = db.Where("x.warehouse_out_id = ?", id)
3771
+	}
3772
+	if goodid > 0 {
3773
+		db = db.Where("x.good_id = ?", goodid)
3774
+	}
3775
+
3776
+	err = db.Select("x.id,x.warehousing_id,x.good_id,x.number,x.count,x.patient_id,x.system_time,x.is_sys,x.warehousing_order,x.warehouse_out_id,x.warehouse_out_order_number,x.price,x.product_date,x.expire_date,x.ctime,o.packing_unit,t.name").Joins("left join xt_patients as t on t.id = x.patient_id").Joins("left join xt_good_information as o on o.id = x.good_id").Scan(&stock).Error
3777
+	//err = XTReadDB().Model(&stock).Where("warehouse_out_id = ? and good_id = ? and status = 1", id, goodid).Find(&stock).Error
3778
+	return stock, err
3779
+}
3780
+
3689 3781
 func GetDrugBatchNumber(drug_id int64, orgid int64) (info []*models.DrugWarehouseInfo, err error) {
3690 3782
 
3691 3783
 	err = XTReadDB().Model(&info).Where("drug_id = ? and org_id = ? and status = 1 and batch_number <>''", drug_id, orgid).Find(&info).Error
@@ -3814,6 +3906,25 @@ func CreateStockFlowOne(flow models.VmStockFlow) error {
3814 3906
 	return err
3815 3907
 }
3816 3908
 
3909
+func UpdatedStockFlow(flow models.VmStockFlow) error {
3910
+	err := XTWriteDB().Save(&flow).Error
3911
+	return err
3912
+}
3913
+
3914
+func GetStockFlowIsExsit(warehousing_id int64, patient_id int64, record_time int64, good_id int64) (*models.VmStockFlow, error) {
3915
+
3916
+	stock := models.VmStockFlow{}
3917
+	var err error
3918
+	err = XTReadDB().Model(&stock).Where("warehousing_id = ? and patient_id = ? and system_time = ? and good_id = ? and status = 1", warehousing_id, patient_id, record_time, good_id).Find(&stock).Error
3919
+	if err == gorm.ErrRecordNotFound {
3920
+		return nil, err
3921
+	}
3922
+	if err != nil {
3923
+		return nil, err
3924
+	}
3925
+	return &stock, nil
3926
+}
3927
+
3817 3928
 func GetWarehouseOutInfoIsExist(id int64) (*models.WarehouseOutInfo, error) {
3818 3929
 
3819 3930
 	info := models.WarehouseOutInfo{}
@@ -4119,3 +4230,82 @@ func GetLastCancelInfo(id int64, goodid int64) (models.CancelStockInfo, error) {
4119 4230
 	err := XTReadDB().Model(&info).Where("warehouse_info_id  = ? and good_id = ? and status = 1", id, goodid).Find(&info).Error
4120 4231
 	return info, err
4121 4232
 }
4233
+
4234
+func UpdateStockFlow(flow models.VmStockFlow, goodid int64, warehousing_id int64) error {
4235
+
4236
+	err := XTWriteDB().Model(&flow).Where("good_id = ? and warehousing_id= ? and status = 1", goodid, warehousing_id).Updates(map[string]interface{}{"count": flow.Count}).Error
4237
+	return err
4238
+}
4239
+
4240
+func UpdateDrugFlow(flow models.DrugFlow, drugid int64, warehousing_id int64) error {
4241
+
4242
+	drugFlow := models.DrugFlow{}
4243
+	err := XTWriteDB().Model(&drugFlow).Where("drug_id = ? and warehousing_id= ? and status = 1", drugid, warehousing_id).Updates(map[string]interface{}{"count": flow.Count}).Error
4244
+	return err
4245
+}
4246
+
4247
+func UpdateDrugCancel(id int64) (models.DrugCancelStock, error) {
4248
+
4249
+	stock := models.DrugCancelStock{}
4250
+
4251
+	err := XTWriteDB().Model(&stock).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"status": 0}).Error
4252
+	return stock, err
4253
+}
4254
+
4255
+func GetDrugWarehouseOutInfo(warehouse_info_id int64, drug_id int64) (info []*models.DrugWarehouseOutInfo, err error) {
4256
+
4257
+	db := XTReadDB().Model(&info)
4258
+	if warehouse_info_id > 0 {
4259
+		db = db.Where("warehouse_info_id = ?", warehouse_info_id)
4260
+	}
4261
+	if drug_id > 0 {
4262
+		db = db.Where("drug_id = ? and status =1", drug_id)
4263
+	}
4264
+
4265
+	err = db.Find(&info).Error
4266
+	return info, err
4267
+}
4268
+
4269
+func GetCancelDrugStockOutInfo(warehouse_info_id int64, drug_id int64) (info []*models.DrugCancelStockInfo, err error) {
4270
+
4271
+	err = XTReadDB().Model(&info).Where("batch_number_id =? and drug_id = ? and status = 1", warehouse_info_id, drug_id).Find(&info).Error
4272
+	return info, err
4273
+}
4274
+
4275
+func GetTemplateSummary(orgid int64) (config []*models.Dataconfig, err error) {
4276
+
4277
+	err = XTReadDB().Model(&config).Where("module='template_summary' and parent_id=? and org_id in (?)", 0, orgid).Find(&config).Error
4278
+	return config, err
4279
+
4280
+}
4281
+
4282
+func GetTemplatePlan(orgid int64) (config []*models.Dataconfig, err error) {
4283
+
4284
+	err = XTReadDB().Model(&config).Where("module='template_plan' and parent_id=? and org_id in (?)", 0, orgid).Find(&config).Error
4285
+	return config, err
4286
+}
4287
+
4288
+func GetSearchGoodWarehouseList(keyword string, orgid int64) (info []*models.BloodWarehouseInfo, err error) {
4289
+
4290
+	db := XTReadDB().Table("xt_warehouse_info as x").Where("x.status = 1")
4291
+	table := XTReadDB().Table("xt_goood_information as t").Where("t.status")
4292
+	fmt.Println(table)
4293
+	likeKey := "%" + keyword + "%"
4294
+	if orgid > 0 {
4295
+		db = db.Where("x.org_id = ?", orgid)
4296
+	}
4297
+	err = db.Select("x.id,x.warehousing_id,x.good_id,x.good_type_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.price,x.total_price,x.dealer,x.remark,x.warehousing_order,x.warehousing_unit,x.stock_count,x.license_number,x.warehousing_unit,t.good_name,t.specification_name,x.manufacturer,t.packing_price,t.id as good_id,t.packing_unit,t.buy_price").Joins("left join xt_good_information as t on t.id = x.good_id").Where("t.good_name like ? and t.org_id = ?", likeKey, orgid).Order("x.ctime desc").Scan(&info).Error
4298
+	return info, err
4299
+}
4300
+
4301
+func CreateAdjustPrice(adjustPrice *models.XtStockAdjustPrice) error {
4302
+
4303
+	err := XTWriteDB().Create(&adjustPrice).Error
4304
+	return err
4305
+}
4306
+
4307
+func GetAllStockPrice(orgid int64) (list []*models.XtStockAdjustPrice, err error) {
4308
+
4309
+	err = XTReadDB().Model(&list).Where("user_org_id = ? and status = 1", orgid).Find(&list).Error
4310
+	return list, err
4311
+}

+ 5 - 0
service/user_service.go Zobrazit soubor

@@ -107,6 +107,11 @@ func GetAllDoctor(orgid int64, appid int64) (appRole []*models.App_Role, err err
107 107
 	return appRole, err
108 108
 }
109 109
 
110
+func GetAllDoctorThree(orgid int64) (appRole []*models.App_Role, err error) {
111
+	err = UserReadDB().Where("org_id = ? AND status = ? AND  (user_type = ? OR user_type = ?) ", orgid, 1, 2, 1).Find(&appRole).Error
112
+	return appRole, err
113
+}
114
+
110 115
 func QueryDryWeight(orgid int64, patientid int64) (*models.SgjPatientDryweight, error) {
111 116
 	var dryweight models.SgjPatientDryweight
112 117
 	var err error

+ 234 - 51
service/warhouse_service.go Zobrazit soubor

@@ -141,6 +141,7 @@ func DrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *model
141 141
 			ExpiryDate:              warehouse.ExpiryDate,
142 142
 			PatientId:               advice.PatientId,
143 143
 			Count:                   count,
144
+			WarehouseInfoId:         warehouse.ID,
144 145
 		}
145 146
 
146 147
 		fmt.Println("单据号2232322323232323232323232323232323", warehouseout.WarehouseOutOrderNumber)
@@ -181,8 +182,8 @@ func DrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *model
181 182
 			UpdatedDrugWarehouseOutInfo(warehouseOutInfo, advice.DrugId, advice.PatientId, advice.RecordDate, advice.UserOrgId)
182 183
 		}
183 184
 		details := &models.DrugAutomaticReduceDetail{
184
-			WarehouseOutId:          warehouseOutInfo.ID,
185
-			WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
185
+			WarehouseOutId:          warehouseout.ID,
186
+			WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
186 187
 			PatientId:               advice.PatientId,
187 188
 			Ctime:                   time.Now().Unix(),
188 189
 			Mtime:                   time.Now().Unix(),
@@ -202,24 +203,27 @@ func DrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *model
202 203
 		// 判断处方里药品单位是拆零单位还是包装单位,	如果是拆零单位,则根据规格,将拆零数量转为包装数量
203 204
 		var maxNumber int64 = 0
204 205
 		var minNumber int64 = 0
205
-		if advice.PrescribingNumberUnit == drup.MinUnit {
206
+		fmt.Println("单位1111111111", advice.PrescribingNumberUnit)
207
+		fmt.Println("单位222222222222222", drup.MaxUnit)
208
+		if advice.PrescribingNumberUnit == drup.MaxUnit {
206 209
 			maxNumber = count / drup.MinNumber
207 210
 			minNumber = count % drup.MinNumber
208 211
 		} else {
209
-			maxNumber = count
212
+			minNumber = count
210 213
 		}
211
-
214
+		fmt.Println("maxNumber0000000000000", maxNumber)
215
+		fmt.Println("minNumber999999999999999", minNumber)
212 216
 		if warehouse.StockMaxNumber < maxNumber {
213
-			fmt.Println("尽量323223232")
217
+
214 218
 			return errors.New("库存数量不足")
215 219
 		}
216 220
 
217 221
 		warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
218 222
 		warehouse.Mtime = time.Now().Unix()
219
-
220 223
 		if warehouse.StockMinNumber < minNumber {
221 224
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - 1
222 225
 			warehouse.StockMinNumber = warehouse.StockMinNumber + drup.MinNumber - minNumber
226
+
223 227
 		} else {
224 228
 			warehouse.StockMinNumber = warehouse.StockMinNumber - minNumber
225 229
 		}
@@ -227,6 +231,7 @@ func DrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *model
227 231
 		if warehouse.StockMaxNumber < 0 {
228 232
 			return errors.New("库存数量不足")
229 233
 		}
234
+
230 235
 		errThree := UpDateDrugWarehouseInfoByStock(&warehouse)
231 236
 		if errThree != nil {
232 237
 			return errThree
@@ -256,38 +261,71 @@ func DrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *model
256 261
 			ExpiryDate:              warehouse.ExpiryDate,
257 262
 			PatientId:               advice.PatientId,
258 263
 			Count:                   count,
264
+			WarehouseInfoId:         warehouse.ID,
259 265
 		}
260
-
261
-		errOne := AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
262
-		if errOne != nil {
263
-			return errOne
264
-		} else {
265
-			details := &models.DrugAutomaticReduceDetail{
266
-				WarehouseOutId:          warehouseOutInfo.ID,
267
-				WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
268
-				PatientId:               advice.PatientId,
269
-				Ctime:                   time.Now().Unix(),
270
-				Mtime:                   time.Now().Unix(),
271
-				Status:                  1,
272
-				RecordTime:              advice.RecordDate,
273
-				OrgId:                   orgID,
274
-				DrugId:                  advice.DrugId,
275
-				Count:                   count,
276
-				CountUnit:               advice.PrescribingNumberUnit,
277
-			}
278
-			errTwo := AddSigleDrugAutoReduceRecordInfo(details)
279
-			if errTwo != nil {
280
-				return errTwo
266
+		//查询是否存在数据
267
+		_, errcodes := GetDrugWarehouseOutInfoIsExit(advice.DrugId, advice.PatientId, advice.RecordDate)
268
+		if errcodes == gorm.ErrRecordNotFound {
269
+			errOne := AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
270
+			if errOne != nil {
271
+				return errOne
281 272
 			}
273
+		} else if errcodes == nil {
274
+			UpdatedDrugWarehouseOutInfo(warehouseOutInfo, advice.DrugId, advice.PatientId, advice.RecordDate, advice.UserOrgId)
282 275
 		}
276
+
277
+		details := &models.DrugAutomaticReduceDetail{
278
+			WarehouseOutId:          warehouseout.ID,
279
+			WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
280
+			PatientId:               advice.PatientId,
281
+			Ctime:                   time.Now().Unix(),
282
+			Mtime:                   time.Now().Unix(),
283
+			Status:                  1,
284
+			RecordTime:              advice.RecordDate,
285
+			OrgId:                   orgID,
286
+			DrugId:                  advice.DrugId,
287
+			Count:                   stock_number,
288
+			CountUnit:               advice.PrescribingNumberUnit,
289
+		}
290
+		errTwo := AddSigleDrugAutoReduceRecordInfo(details)
291
+		if errTwo != nil {
292
+			return errTwo
293
+		}
294
+
283 295
 		// 出库完成后,要将该批次库存清零
284 296
 		warehouse.StockMaxNumber = 0
285 297
 		warehouse.StockMinNumber = 0
286 298
 		warehouse.Mtime = time.Now().Unix()
287 299
 		errThree := UpDateDrugWarehouseInfoByStock(&warehouse)
300
+
288 301
 		if errThree != nil {
289 302
 			return errThree
290 303
 		}
304
+
305
+		drugflow := models.DrugFlow{
306
+			WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
307
+			WarehouseOutId:          warehouseout.ID,
308
+			DrugId:                  advice.DrugId,
309
+			Number:                  warehouse.Number,
310
+			ProductDate:             warehouse.ProductDate,
311
+			ExpireDate:              warehouse.ExpiryDate,
312
+			Count:                   stock_number,
313
+			Price:                   baseInfo.RetailPrice,
314
+			Status:                  1,
315
+			Ctime:                   time.Now().Unix(),
316
+			UserOrgId:               orgID,
317
+			Manufacturer:            warehouse.Manufacturer,
318
+			Dealer:                  warehouse.Dealer,
319
+			BatchNumber:             warehouse.BatchNumber,
320
+			MaxUnit:                 advice.PrescribingNumberUnit,
321
+			ConsumableType:          3,
322
+			IsEdit:                  1,
323
+			Creator:                 advice.ExecutionStaff,
324
+			IsSys:                   1,
325
+			PatientId:               advice.PatientId,
326
+		}
327
+
328
+		CreateDrugFlowOne(drugflow)
291 329
 		// 清零完该库存后,还有剩余出库未出完,进行对应的递归操作
292 330
 		prescribingNumber_two_temp := deliver_number - stock_number
293 331
 		overPlusNumber := float64(prescribingNumber_two_temp)
@@ -419,6 +457,7 @@ func HisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
419 457
 			ProductDate:             warehouse.ProductDate,
420 458
 			ExpiryDate:              warehouse.ExpiryDate,
421 459
 			PatientId:               advice.PatientId,
460
+			WarehouseInfoId:         warehouse.ID,
422 461
 		}
423 462
 
424 463
 		warehouseOutInfo.Count = count
@@ -461,8 +500,8 @@ func HisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
461 500
 		}
462 501
 
463 502
 		details := &models.DrugAutomaticReduceDetail{
464
-			WarehouseOutId:          warehouseOutInfo.ID,
465
-			WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
503
+			WarehouseOutId:          warehouseout.ID,
504
+			WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
466 505
 			PatientId:               advice.PatientId,
467 506
 			Ctime:                   time.Now().Unix(),
468 507
 			Mtime:                   time.Now().Unix(),
@@ -535,6 +574,7 @@ func HisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
535 574
 			ProductDate:             warehouse.ProductDate,
536 575
 			ExpiryDate:              warehouse.ExpiryDate,
537 576
 			PatientId:               advice.PatientId,
577
+			WarehouseInfoId:         warehouse.ID,
538 578
 		}
539 579
 
540 580
 		warehouseOutInfo.Count = count
@@ -548,7 +588,7 @@ func HisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
548 588
 			Number:                  warehouse.Number,
549 589
 			ProductDate:             warehouse.ProductDate,
550 590
 			ExpireDate:              warehouse.ExpiryDate,
551
-			Count:                   count,
591
+			Count:                   stock_number,
552 592
 			Price:                   baseInfo.RetailPrice,
553 593
 			Status:                  1,
554 594
 			Ctime:                   time.Now().Unix(),
@@ -577,8 +617,8 @@ func HisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
577 617
 			UpdatedDrugWarehouseOutInfo(warehouseOutInfo, advice.DrugId, advice.PatientId, advice.RecordDate, advice.UserOrgId)
578 618
 		}
579 619
 		details := &models.DrugAutomaticReduceDetail{
580
-			WarehouseOutId:          warehouseOutInfo.ID,
581
-			WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
620
+			WarehouseOutId:          warehouseout.ID,
621
+			WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
582 622
 			PatientId:               advice.PatientId,
583 623
 			Ctime:                   time.Now().Unix(),
584 624
 			Mtime:                   time.Now().Unix(),
@@ -668,6 +708,7 @@ func AutoDrugDeliverInfo(orgID int64, prescribingNumber int64, warehouseout *mod
668 708
 			Count:                   advice.Count,
669 709
 			RetailPrice:             advice.RetailPrice,
670 710
 			Price:                   advice.Price,
711
+			WarehouseInfoId:         advice.WarehouseInfoId,
671 712
 		}
672 713
 
673 714
 		warehouseOutInfo.Count = prescribingNumber
@@ -872,6 +913,7 @@ func ConsumablesDeliveryTotal(orgID int64, patient_id int64, record_time int64,
872 913
 func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods *models.DialysisBeforePrepare, warehouseOut *models.WarehouseOut, count int64) (err error) {
873 914
 
874 915
 	fmt.Println("count23232323232323232323232323", count)
916
+	fmt.Println("hhhh2h3h3h2h23h32hh23h32h23", goods.Count)
875 917
 	// 判断处方里药品单位是拆零单位还是包装单位,	如果是包装单位,则根据规格,将包装数量转为拆零数量
876 918
 	var deliver_number int64 = 0
877 919
 	var stock_number int64 = 0
@@ -885,8 +927,6 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
885 927
 	warehouse, err := FindFirstWarehousingInfoByStock(goods.GoodId, goods.GoodTypeId)
886 928
 	if err != nil {
887 929
 
888
-		fmt.Println("进来232323232323234343434343434343434343", warehouse.StockCount)
889
-
890 930
 		return errors.New("库存数量不足")
891 931
 	}
892 932
 
@@ -949,6 +989,9 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
949 989
 
950 990
 		if errcode == gorm.ErrRecordNotFound {
951 991
 			errTwo := CreateAutoReduceRecord(&details)
992
+			if errTwo != nil {
993
+				return errTwo
994
+			}
952 995
 			//插入库存流水表
953 996
 			flow := models.VmStockFlow{
954 997
 				WarehouseOutId:          warehouseOut.ID,
@@ -974,14 +1017,49 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
974 1017
 				IsSys:                   1,
975 1018
 				PatientId:               patient_id,
976 1019
 			}
977
-			CreateStockFlowOne(flow)
978
-			if errTwo != nil {
979
-				return errTwo
1020
+			//查询流水是否存在
1021
+			exsit, errflow := GetStockFlowIsExsit(warehouseOut.ID, patient_id, record_time, goods.GoodId)
1022
+
1023
+			fmt.Println("什么数据233232323", errflow)
1024
+			if errflow == gorm.ErrRecordNotFound {
1025
+				errThre := CreateStockFlowOne(flow)
1026
+				if errThre != nil {
1027
+					return errThre
1028
+				}
1029
+			} else if errflow == nil {
1030
+				flow := models.VmStockFlow{
1031
+					ID:                      exsit.ID,
1032
+					WarehouseOutId:          warehouseOut.ID,
1033
+					WarehousingId:           warehouse.ID,
1034
+					GoodId:                  goods.GoodId,
1035
+					Number:                  warehouse.Number,
1036
+					ProductDate:             warehouse.ProductDate,
1037
+					ExpireDate:              warehouse.ExpiryDate,
1038
+					Count:                   exsit.Count + goods.Count,
1039
+					Price:                   info.PackingPrice,
1040
+					Status:                  1,
1041
+					Ctime:                   time.Now().Unix(),
1042
+					UserOrgId:               orgID,
1043
+					Manufacturer:            info.Manufacturer,
1044
+					Dealer:                  info.Dealer,
1045
+					LicenseNumber:           warehouse.LicenseNumber,
1046
+					IsEdit:                  2,
1047
+					Creator:                 warehouseOut.Creater,
1048
+					SystemTime:              record_time,
1049
+					ConsumableType:          3,
1050
+					WarehouseOutDetailId:    warehouseOutInfo.ID,
1051
+					WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1052
+					IsSys:                   1,
1053
+					PatientId:               patient_id,
1054
+					ReturnCount:             exsit.Count + (exsit.Count + deliver_number),
1055
+				}
1056
+				errFour := UpdatedStockFlow(flow)
1057
+				if errFour != nil {
1058
+					return errFour
1059
+				}
980 1060
 			}
1061
+
981 1062
 		} else if errcode == nil {
982
-			DeleteAutoRedeceDetailTwo(orgID, patient_id, record_time, goods.GoodId, goods.GoodTypeId)
983
-			CreateAutoReduceRecord(&details)
984
-			//插入库存流水表
985 1063
 			flow := models.VmStockFlow{
986 1064
 				WarehouseOutId:          warehouseOut.ID,
987 1065
 				WarehousingId:           warehouse.ID,
@@ -1006,7 +1084,45 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
1006 1084
 				IsSys:                   1,
1007 1085
 				PatientId:               patient_id,
1008 1086
 			}
1009
-			CreateStockFlowOne(flow)
1087
+			//查询流水是否存在
1088
+			exsit, errflow := GetStockFlowIsExsit(warehouseOut.ID, patient_id, record_time, goods.GoodId)
1089
+
1090
+			if errflow == gorm.ErrRecordNotFound {
1091
+				CreateStockFlowOne(flow)
1092
+				DeleteAutoRedeceDetailTwo(orgID, patient_id, record_time, goods.GoodId, goods.GoodTypeId)
1093
+				CreateAutoReduceRecord(&details)
1094
+			} else if errflow == nil {
1095
+				flow := models.VmStockFlow{
1096
+					ID:                      exsit.ID,
1097
+					WarehouseOutId:          warehouseOut.ID,
1098
+					WarehousingId:           warehouse.ID,
1099
+					GoodId:                  goods.GoodId,
1100
+					Number:                  warehouse.Number,
1101
+					ProductDate:             warehouse.ProductDate,
1102
+					ExpireDate:              warehouse.ExpiryDate,
1103
+					Count:                   exsit.Count + goods.Count,
1104
+					Price:                   info.PackingPrice,
1105
+					Status:                  1,
1106
+					Ctime:                   time.Now().Unix(),
1107
+					UserOrgId:               orgID,
1108
+					Manufacturer:            info.Manufacturer,
1109
+					Dealer:                  info.Dealer,
1110
+					LicenseNumber:           warehouse.LicenseNumber,
1111
+					IsEdit:                  2,
1112
+					Creator:                 warehouseOut.Creater,
1113
+					SystemTime:              record_time,
1114
+					ConsumableType:          3,
1115
+					WarehouseOutDetailId:    warehouseOutInfo.ID,
1116
+					WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1117
+					IsSys:                   1,
1118
+					PatientId:               patient_id,
1119
+					ReturnCount:             exsit.Count + (exsit.Count + deliver_number),
1120
+				}
1121
+				UpdatedStockFlow(flow)
1122
+				DeleteAutoRedeceDetailTwo(orgID, patient_id, record_time, goods.GoodId, goods.GoodTypeId)
1123
+				CreateAutoReduceRecord(&details)
1124
+			}
1125
+
1010 1126
 		}
1011 1127
 
1012 1128
 		maxNumber = goods.Count
@@ -1029,7 +1145,7 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
1029 1145
 
1030 1146
 		return nil
1031 1147
 	} else {
1032
-
1148
+		fmt.Println("不进来22323232323232323232233223323223322323")
1033 1149
 		// 当刚批次的库存数量小于出库数量的话,则先把该批次出库完后,再进行递归出库
1034 1150
 		warehouseOutInfo := &models.WarehouseOutInfo{
1035 1151
 			WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
@@ -1056,7 +1172,7 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
1056 1172
 		warehouseOutInfo.Count = stock_number
1057 1173
 
1058 1174
 		_, errcodes := GetWarehouseOutInfoIsExistOne(goods.GoodId, goods.PatientId, record_time)
1059
-
1175
+		fmt.Println("hhhhh2h323233223232323", errcodes)
1060 1176
 		if errcodes == gorm.ErrRecordNotFound {
1061 1177
 			errOne := AddSigleWarehouseOutInfo(warehouseOutInfo)
1062 1178
 
@@ -1072,7 +1188,7 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
1072 1188
 				ProductDate:             warehouse.ProductDate,
1073 1189
 				ExpireDate:              warehouse.ExpiryDate,
1074 1190
 				Count:                   stock_number,
1075
-				Price:                   warehouse.Price,
1191
+				Price:                   info.PackingPrice,
1076 1192
 				Status:                  1,
1077 1193
 				Ctime:                   time.Now().Unix(),
1078 1194
 				UserOrgId:               orgID,
@@ -1088,11 +1204,46 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
1088 1204
 				IsSys:                   1,
1089 1205
 				PatientId:               patient_id,
1090 1206
 			}
1091
-			CreateStockFlowOne(flow)
1207
+			//查询流水是否存在
1208
+			exsit, errflows := GetStockFlowIsExsit(warehouse.ID, patient_id, record_time, goods.GoodId)
1209
+
1210
+			if errflows == gorm.ErrRecordNotFound {
1211
+				CreateStockFlowOne(flow)
1212
+			} else if errflows == nil {
1213
+				flow := models.VmStockFlow{
1214
+					ID:                      exsit.ID,
1215
+					WarehouseOutId:          warehouseOut.ID,
1216
+					WarehousingId:           warehouse.ID,
1217
+					GoodId:                  goods.GoodId,
1218
+					Number:                  warehouse.Number,
1219
+					ProductDate:             warehouse.ProductDate,
1220
+					ExpireDate:              warehouse.ExpiryDate,
1221
+					Count:                   exsit.Count + goods.Count,
1222
+					Price:                   info.PackingPrice,
1223
+					Status:                  1,
1224
+					Ctime:                   time.Now().Unix(),
1225
+					UserOrgId:               orgID,
1226
+					Manufacturer:            info.Manufacturer,
1227
+					Dealer:                  info.Dealer,
1228
+					LicenseNumber:           warehouse.LicenseNumber,
1229
+					IsEdit:                  2,
1230
+					Creator:                 warehouseOut.Creater,
1231
+					SystemTime:              record_time,
1232
+					ConsumableType:          3,
1233
+					WarehouseOutDetailId:    warehouseOutInfo.ID,
1234
+					WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1235
+					IsSys:                   1,
1236
+					PatientId:               patient_id,
1237
+					ReturnCount:             exsit.Count + (exsit.Count + deliver_number),
1238
+				}
1239
+				UpdatedStockFlow(flow)
1240
+			}
1241
+
1092 1242
 		} else if errcodes == nil {
1243
+			fmt.Println("尽力3323232322323232323232323232323")
1093 1244
 			goods.Count = deliver_number - stock_number
1094
-			//更新数量为  刚批次剩余数量  + 还有未出的数量
1095
-			warehouseOutInfo.Count = goods.Count + stock_number
1245
+			//更新数量为  批次剩余数量  + 还有未出的数量
1246
+			warehouseOutInfo.Count = stock_number
1096 1247
 			UpdatedWarehouseOutInfo(warehouseOutInfo, goods.GoodId, goods.PatientId, record_time)
1097 1248
 			//插入库存流水表
1098 1249
 			flow := models.VmStockFlow{
@@ -1102,8 +1253,8 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
1102 1253
 				Number:                  warehouse.Number,
1103 1254
 				ProductDate:             warehouse.ProductDate,
1104 1255
 				ExpireDate:              warehouse.ExpiryDate,
1105
-				Count:                   goods.Count + stock_number,
1106
-				Price:                   warehouse.Price,
1256
+				Count:                   stock_number,
1257
+				Price:                   info.PackingPrice,
1107 1258
 				Status:                  1,
1108 1259
 				Ctime:                   time.Now().Unix(),
1109 1260
 				UserOrgId:               orgID,
@@ -1119,7 +1270,39 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
1119 1270
 				IsSys:                   1,
1120 1271
 				PatientId:               patient_id,
1121 1272
 			}
1122
-			CreateStockFlowOne(flow)
1273
+			//查询流水是否存在
1274
+			exsit, errflows := GetStockFlowIsExsit(warehouse.ID, patient_id, record_time, goods.GoodId)
1275
+			if errflows == gorm.ErrRecordNotFound {
1276
+				CreateStockFlowOne(flow)
1277
+			} else if errflows == nil {
1278
+				fmt.Println("尽力3323232322323232323232323232323", exsit.Count+goods.Count)
1279
+				flow := models.VmStockFlow{
1280
+					ID:                      exsit.ID,
1281
+					WarehouseOutId:          warehouseOut.ID,
1282
+					WarehousingId:           warehouse.ID,
1283
+					GoodId:                  goods.GoodId,
1284
+					Number:                  warehouse.Number,
1285
+					ProductDate:             warehouse.ProductDate,
1286
+					ExpireDate:              warehouse.ExpiryDate,
1287
+					Count:                   exsit.Count + goods.Count,
1288
+					Price:                   info.PackingPrice,
1289
+					Status:                  1,
1290
+					Ctime:                   time.Now().Unix(),
1291
+					UserOrgId:               orgID,
1292
+					Manufacturer:            info.Manufacturer,
1293
+					Dealer:                  info.Dealer,
1294
+					LicenseNumber:           warehouse.LicenseNumber,
1295
+					IsEdit:                  2,
1296
+					Creator:                 warehouseOut.Creater,
1297
+					SystemTime:              record_time,
1298
+					ConsumableType:          3,
1299
+					WarehouseOutDetailId:    warehouseOutInfo.ID,
1300
+					WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1301
+					IsSys:                   1,
1302
+					PatientId:               patient_id,
1303
+				}
1304
+				UpdatedStockFlow(flow)
1305
+			}
1123 1306
 		}
1124 1307
 
1125 1308
 		// 出库完成后,要将该批次库存清零