ソースを参照

11月8日库存管理

XMLWAN 3 年 前
コミット
1dcdc73a93
共有37 個のファイルを変更した7644 個の追加810 個の削除を含む
  1. 0 1
      controllers/base_controller.go
  2. 5 1
      controllers/dialysis_api_controller.go
  3. 5 1
      controllers/dialysis_record_api_controller.go
  4. 478 91
      controllers/drug_stock_api_contorller.go
  5. 27 6
      controllers/gobal_config_api_controller.go
  6. 200 71
      controllers/his_api_controller.go
  7. 1 1
      controllers/mobile_api_controllers/check_weight_api_controller.go
  8. 235 102
      controllers/mobile_api_controllers/dialysis_api_controller.go
  9. 54 3
      controllers/mobile_api_controllers/patient_api_controller.go
  10. 48 7
      controllers/patient_api_controller.go
  11. 2026 0
      controllers/secondary_order_api_contorller.go
  12. 75 19
      controllers/self_drug_api_congtroller.go
  13. 9 1
      controllers/stock_good_api_controller.go
  14. 712 239
      controllers/stock_in_api_controller.go
  15. 91 30
      controllers/supply_order_api_contorller.go
  16. 3 0
      models/dialysis.go
  17. 1 0
      models/dialysis_parameter_models.go
  18. 4 0
      models/drug.go
  19. 17 0
      models/drug_stock.go
  20. 2 0
      models/good_models.go
  21. 2 0
      models/patient_models.go
  22. 199 1
      models/secondary_models.go
  23. 11 0
      models/self_drug_models.go
  24. 157 27
      models/stock_models.go
  25. 2 2
      service/device_service.go
  26. 3 3
      service/dialysis_service.go
  27. 6 0
      service/doctor_schedule_service.go
  28. 46 17
      service/gobal_config_service.go
  29. 6 2
      service/his_service.go
  30. 1 1
      service/manage_center_service.go
  31. 1 1
      service/mobile_dialysis_service.go
  32. 1 1
      service/patient_service.go
  33. 1108 1
      service/secondary_service.go
  34. 17 9
      service/self_drug_service.go
  35. 707 85
      service/stock_service.go
  36. 23 7
      service/supply_service.go
  37. 1361 80
      service/warhouse_service.go

+ 0 - 1
controllers/base_controller.go ファイルの表示

@@ -2,7 +2,6 @@ package controllers
2 2
 
3 3
 import (
4 4
 	"XT_New/service"
5
-
6 5
 	"github.com/astaxie/beego"
7 6
 )
8 7
 

+ 5 - 1
controllers/dialysis_api_controller.go ファイルの表示

@@ -3458,7 +3458,7 @@ func (this *DialysisApiController) GetTodayMonitor() {
3458 3458
 			}
3459 3459
 
3460 3460
 			if template.TemplateId == 47 { //adminInfo.CurrentOrgId == 9538
3461
-				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60)
3461
+				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
3462 3462
 				record.UltrafiltrationRate = ultrafiltration_rate
3463 3463
 			}
3464 3464
 
@@ -3490,6 +3490,10 @@ func (this *DialysisApiController) GetTodayMonitor() {
3490 3490
 
3491 3491
 	}
3492 3492
 
3493
+	if template.TemplateId == 47 {
3494
+		record.DisplacementQuantity = record.DisplacementQuantity + record.DisplacementQuantity
3495
+	}
3496
+
3493 3497
 	this.ServeSuccessJSON(map[string]interface{}{
3494 3498
 		"monitor": record,
3495 3499
 	})

+ 5 - 1
controllers/dialysis_record_api_controller.go ファイルの表示

@@ -999,7 +999,11 @@ func (this *DialysisRecordAPIController) StartDialysis() {
999 999
 
1000 1000
 		var tempdispose string
1001 1001
 		// 只针对中能建
1002
-		if blood_drawing > 0 { //adminUserInfo.CurrentOrgId == 9538
1002
+		if blood_drawing > 0 && adminUserInfo.CurrentOrgId == 9538 { //adminUserInfo.CurrentOrgId == 9538
1003
+			tempdispose = "引血" + strconv.FormatInt(blood_drawing, 10) + "ml/min"
1004
+		}
1005
+
1006
+		if blood_drawing > 0 && adminUserInfo.CurrentOrgId == 10318 { //adminUserInfo.CurrentOrgId == 9538
1003 1007
 			tempdispose = "引血" + strconv.FormatInt(blood_drawing, 10) + "ml/min"
1004 1008
 		}
1005 1009
 

File diff suppressed because it is too large
+ 478 - 91
controllers/drug_stock_api_contorller.go


+ 27 - 6
controllers/gobal_config_api_controller.go ファイルの表示

@@ -1602,6 +1602,7 @@ func (c *GobalConfigApiController) GetDrugInDetail() {
1602 1602
 
1603 1603
 	start_time := c.GetString("start_time")
1604 1604
 	end_time := c.GetString("end_time")
1605
+	storehouse_id, _ := c.GetInt64("storehouse_id")
1605 1606
 	timeLayout := "2006-01-02"
1606 1607
 	loc, _ := time.LoadLocation("Local")
1607 1608
 	var startTime int64
@@ -1631,10 +1632,11 @@ func (c *GobalConfigApiController) GetDrugInDetail() {
1631 1632
 	page, _ := c.GetInt64("page")
1632 1633
 	limit, _ := c.GetInt64("limit")
1633 1634
 
1634
-	detail, total, err := service.GetDrugInOrderDetail(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword, page, limit)
1635
+	detail, total, err := service.GetDrugInOrderDetail(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword, page, limit, storehouse_id)
1635 1636
 	var drugType = "药品类型"
1636 1637
 	drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
1637 1638
 	drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, adminInfo.CurrentOrgId)
1639
+	houseList, _ := service.GetAllStorehouseName(adminInfo.CurrentOrgId)
1638 1640
 	if err != nil {
1639 1641
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1640 1642
 		return
@@ -1643,6 +1645,7 @@ func (c *GobalConfigApiController) GetDrugInDetail() {
1643 1645
 		"detail":         detail,
1644 1646
 		"total":          total,
1645 1647
 		"drugTypeParent": drugTypeList,
1648
+		"houseList":      houseList,
1646 1649
 	})
1647 1650
 }
1648 1651
 
@@ -1694,6 +1697,7 @@ func (c *GobalConfigApiController) GetDrugOutDetail() {
1694 1697
 
1695 1698
 	start_time := c.GetString("start_time")
1696 1699
 	end_time := c.GetString("end_time")
1700
+	storehouse_id, _ := c.GetInt64("storehouse_id")
1697 1701
 	timeLayout := "2006-01-02"
1698 1702
 	loc, _ := time.LoadLocation("Local")
1699 1703
 	var startTime int64
@@ -1722,7 +1726,8 @@ func (c *GobalConfigApiController) GetDrugOutDetail() {
1722 1726
 	keyword := c.GetString("keyword")
1723 1727
 	limit, _ := c.GetInt64("limit")
1724 1728
 	page, _ := c.GetInt64("page")
1725
-	order, total, err := service.GetDrugOutOrder(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword, page, limit)
1729
+	order, total, err := service.GetDrugOutOrder(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword, page, limit, storehouse_id)
1730
+	houseList, _ := service.GetAllStoreHouseList(adminInfo.CurrentOrgId)
1726 1731
 	var drugType = "药品类型"
1727 1732
 	drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
1728 1733
 	drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, adminInfo.CurrentOrgId)
@@ -1734,6 +1739,7 @@ func (c *GobalConfigApiController) GetDrugOutDetail() {
1734 1739
 		"order":        order,
1735 1740
 		"total":        total,
1736 1741
 		"drugTypeList": drugTypeList,
1742
+		"houseList":    houseList,
1737 1743
 	})
1738 1744
 }
1739 1745
 
@@ -1741,6 +1747,7 @@ func (c *GobalConfigApiController) GetDrugCancelDetail() {
1741 1747
 
1742 1748
 	start_time := c.GetString("start_time")
1743 1749
 	end_time := c.GetString("end_time")
1750
+	storehouse_id, _ := c.GetInt64("storehouse_id")
1744 1751
 	timeLayout := "2006-01-02"
1745 1752
 	loc, _ := time.LoadLocation("Local")
1746 1753
 	var startTime int64
@@ -1769,11 +1776,12 @@ func (c *GobalConfigApiController) GetDrugCancelDetail() {
1769 1776
 	keyword := c.GetString("keyword")
1770 1777
 	limit, _ := c.GetInt64("limit")
1771 1778
 	page, _ := c.GetInt64("page")
1772
-	orderPrint, _ := service.GetDrugCancelOrderPrint(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword)
1773
-	order, total, err := service.GetDrugCancelOrder(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword, page, limit)
1779
+	orderPrint, _ := service.GetDrugCancelOrderPrint(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword, storehouse_id)
1780
+	order, total, err := service.GetDrugCancelOrder(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword, page, limit, storehouse_id)
1774 1781
 	var drugType = "药品类型"
1775 1782
 	drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
1776 1783
 	drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, adminInfo.CurrentOrgId)
1784
+	houseList, _ := service.GetAllStoreHouseList(adminInfo.CurrentOrgId)
1777 1785
 	if err != nil {
1778 1786
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1779 1787
 		return
@@ -1783,6 +1791,7 @@ func (c *GobalConfigApiController) GetDrugCancelDetail() {
1783 1791
 		"total":        total,
1784 1792
 		"orderPrint":   orderPrint,
1785 1793
 		"drugTypeList": drugTypeList,
1794
+		"houseList":    houseList,
1786 1795
 	})
1787 1796
 }
1788 1797
 
@@ -1920,7 +1929,8 @@ func (c *GobalConfigApiController) GetDrugStockList() {
1920 1929
 	end_time := c.GetString("end_time")
1921 1930
 	timeLayout := "2006-01-02"
1922 1931
 	loc, _ := time.LoadLocation("Local")
1923
-
1932
+	storehouse_id, _ := c.GetInt64("storehouse_id")
1933
+	drug_id, _ := c.GetInt64("drug_id")
1924 1934
 	var startTime int64
1925 1935
 	if len(start_time) > 0 {
1926 1936
 		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
@@ -1943,9 +1953,13 @@ func (c *GobalConfigApiController) GetDrugStockList() {
1943 1953
 	}
1944 1954
 	adminUserInfo := c.GetAdminUserInfo()
1945 1955
 
1946
-	list, total, err := service.GetAllBaseDurgListCount(page, limit, keyword, drug_type, startTime, endTime, adminUserInfo.CurrentOrgId)
1956
+	list, total, err := service.GetAllBaseDurgListCount(page, limit, keyword, drug_type, startTime, endTime, adminUserInfo.CurrentOrgId, storehouse_id, drug_id)
1947 1957
 
1948 1958
 	manufacturerList, _ := service.GetAllManufacturerList(adminUserInfo.CurrentOrgId)
1959
+
1960
+	houseList, _ := service.GetAllStoreHouseListOne(adminUserInfo.CurrentOrgId)
1961
+
1962
+	medicalList, _ := service.GetAllBaseDrugStockList(adminUserInfo.CurrentOrgId)
1949 1963
 	if err != nil {
1950 1964
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1951 1965
 		return
@@ -1954,6 +1968,8 @@ func (c *GobalConfigApiController) GetDrugStockList() {
1954 1968
 		"list":             list,
1955 1969
 		"total":            total,
1956 1970
 		"manufacturerList": manufacturerList,
1971
+		"houseList":        houseList,
1972
+		"medicalList":      medicalList,
1957 1973
 	})
1958 1974
 }
1959 1975
 
@@ -2063,6 +2079,7 @@ func (c *GobalConfigApiController) GetBatchOrderDetail() {
2063 2079
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
2064 2080
 
2065 2081
 	drug, _ := service.GetBaseDrugMedical(drug_id)
2082
+	houseList, _ := service.GetAllStoreHouseList(orgId)
2066 2083
 	if err != nil {
2067 2084
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
2068 2085
 		return
@@ -2072,6 +2089,7 @@ func (c *GobalConfigApiController) GetBatchOrderDetail() {
2072 2089
 		"total":            total,
2073 2090
 		"manufacturerList": manufacturerList,
2074 2091
 		"drug":             drug,
2092
+		"houseList":        houseList,
2075 2093
 	})
2076 2094
 }
2077 2095
 
@@ -2137,6 +2155,7 @@ func (c *GobalConfigApiController) GetSingleOrderDetail() {
2137 2155
 	manufacturerList, err := service.GetAllManufacturerList(orgId)
2138 2156
 	drugFlowList, _ := service.GetDrugStockFlowDetail(start_time, orgId)
2139 2157
 	flowlist, _ := service.GetSingeOrderFlow(id, orgId)
2158
+
2140 2159
 	if err != nil {
2141 2160
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
2142 2161
 		return
@@ -2288,12 +2307,14 @@ func (c *GobalConfigApiController) GetDrugFlow() {
2288 2307
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
2289 2308
 	dealerList, _ := service.GetAllDealerList(orgId)
2290 2309
 	medical, _ := service.GetBaseDrugMedical(drug_id)
2310
+	houseList, _ := service.GetAllStoreHouseList(orgId)
2291 2311
 	c.ServeSuccessJSON(map[string]interface{}{
2292 2312
 		"list":             list,
2293 2313
 		"total":            total,
2294 2314
 		"manufacturerList": manufacturerList,
2295 2315
 		"dealerList":       dealerList,
2296 2316
 		"drug":             medical,
2317
+		"houseList":        houseList,
2297 2318
 	})
2298 2319
 }
2299 2320
 

+ 200 - 71
controllers/his_api_controller.go ファイルの表示

@@ -720,9 +720,10 @@ func (c *HisApiController) CreateHisPrescription() {
720 720
 						if len(advices) > 0 {
721 721
 							for _, advice := range advices {
722 722
 								var drug_id int64
723
-								var prescribing_number float64
723
+								//var prescribing_number float64
724 724
 								var prescribingNumberUnit string
725 725
 								var prescribingNumber string
726
+								var prescribing_number_one int64
726 727
 
727 728
 								var adviceId int64
728 729
 								if advice.(map[string]interface{})["id"] != nil || reflect.TypeOf(advice.(map[string]interface{})["id"]).String() == "float64" {
@@ -730,8 +731,9 @@ func (c *HisApiController) CreateHisPrescription() {
730 731
 								}
731 732
 								if advice.(map[string]interface{})["prescribing_number"] != nil || reflect.TypeOf(advice.(map[string]interface{})["prescribing_number"]).String() == "string" {
732 733
 									prescribing_number_str := advice.(map[string]interface{})["prescribing_number"].(string)
733
-									prescribing_number, _ = strconv.ParseFloat(prescribing_number_str, 64)
734
+									//prescribing_number, _ = strconv.ParseFloat(prescribing_number_str, 64)
734 735
 									prescribingNumber = advice.(map[string]interface{})["prescribing_number"].(string)
736
+									prescribing_number_one, _ = strconv.ParseInt(prescribing_number_str, 10, 64)
735 737
 								}
736 738
 
737 739
 								if advice.(map[string]interface{})["prescribing_number_unit"] != nil && reflect.TypeOf(advice.(map[string]interface{})["prescribing_number_unit"]).String() == "string" {
@@ -748,27 +750,27 @@ func (c *HisApiController) CreateHisPrescription() {
748 750
 									return
749 751
 								}
750 752
 								//查询药品的所有库存
751
-								list, _ := service.GetDrugWarehouseInfoPrescriptionSeven(drug_id, adminInfo.CurrentOrgId)
752
-								var total_count int64
753
-								for _, it := range list {
754
-									total_count += it.StockMaxNumber*drug.MinNumber + it.StockMinNumber
755
-								}
756
-								totals := strconv.FormatInt(total_count, 10)
753
+								//list, _ := service.GetDrugWarehouseInfoPrescriptionSeven(drug_id, adminInfo.CurrentOrgId)
754
+								//var total_count int64
755
+								//for _, it := range list {
756
+								//	total_count += it.StockMaxNumber*drug.MinNumber + it.StockMinNumber
757
+								//}
758
+								//totals := strconv.FormatInt(total_count, 10)
757 759
 								//查询该药品是否存在开药记录
758 760
 								advicelist, _ := service.GetHisAdviceListByDrugIdEight(drug_id, patient_id, recordDateTime, adviceId)
759 761
 
760 762
 								//新增处方
761 763
 								if advicelist.ID == 0 {
762
-									all_count, _ := strconv.ParseFloat(totals, 64)
764
+									//	all_count, _ := strconv.ParseFloat(totals, 64)
763 765
 									if prescribingNumberUnit == drug.MinUnit {
764
-										if prescribing_number > all_count {
766
+										if prescribing_number_one > drug.SumCount {
765 767
 											c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
766 768
 											return
767 769
 										}
768 770
 									} else {
769 771
 										if prescribingNumberUnit == drug.MaxUnit {
770
-											num := prescribing_number * float64(drug.MinNumber)
771
-											if num > all_count {
772
+											num := prescribing_number_one * drug.MinNumber
773
+											if num > drug.SumCount {
772 774
 												c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
773 775
 												return
774 776
 											}
@@ -803,7 +805,7 @@ func (c *HisApiController) CreateHisPrescription() {
803 805
 									//如果修改的数量大于之前修改的数量
804 806
 									if (number_count - device_number) > 0 {
805 807
 										//如果修改的差数量 大于库存数量
806
-										if (number_count - device_number) > total_count {
808
+										if (number_count - device_number) > drug.SumCount {
807 809
 											c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
808 810
 											return
809 811
 										}
@@ -818,6 +820,24 @@ func (c *HisApiController) CreateHisPrescription() {
818 820
 										if druginfo.CountUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
819 821
 
820 822
 											service.ModefyDrugByWarehouseInfo(druginfo.WarehouseInfoId, number_count)
823
+
824
+											//查询默认仓库
825
+											houseConfig, _ := service.GetAllStoreHouseConfig(druginfo.OrgId)
826
+											//查询默认仓库剩余多少库存
827
+											list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, druginfo.OrgId, drug_id)
828
+											var sum_count int64
829
+											var sum_in_count int64
830
+											for _, it := range list {
831
+												baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
832
+												if it.MaxUnit == baseDrug.MaxUnit {
833
+													it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
834
+													it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
835
+
836
+												}
837
+												sum_count += it.StockMaxNumber + it.StockMinNumber
838
+												sum_in_count += it.WarehousingCount
839
+											}
840
+											service.UpdateMedicalSumCount(drug_id, sum_count, sum_in_count, druginfo.OrgId)
821 841
 										}
822 842
 										if druginfo.CountUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
823 843
 											var stock_max_number int64
@@ -826,18 +846,71 @@ func (c *HisApiController) CreateHisPrescription() {
826 846
 											if number_count >= drug.MinNumber {
827 847
 
828 848
 												stock_max_number = device_number / drug.MinNumber
849
+
829 850
 												service.ModefyDrugByWarehouseInfo(druginfo.WarehouseInfoId, stock_max_number)
851
+
830 852
 												stock_min_number = device_number % drug.MinNumber
831 853
 												service.ModefyDrugByWarehouseInfoOne(druginfo.WarehouseInfoId, stock_min_number)
854
+												//查询默认仓库
855
+												houseConfig, _ := service.GetAllStoreHouseConfig(druginfo.OrgId)
856
+												//查询默认仓库剩余多少库存
857
+												list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, druginfo.OrgId, drug_id)
858
+												var sum_count int64
859
+												var sum_in_count int64
860
+												for _, it := range list {
861
+													baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
862
+													if it.MaxUnit == baseDrug.MaxUnit {
863
+														it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
864
+														it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
865
+
866
+													}
867
+													sum_count += it.StockMaxNumber + it.StockMinNumber
868
+													sum_in_count += it.WarehousingCount
869
+												}
870
+												service.UpdateMedicalSumCount(drug_id, sum_count, sum_in_count, druginfo.OrgId)
832 871
 
833 872
 											} else {
834 873
 
835 874
 												service.ModefyDrugByWarehouseInfoOne(druginfo.WarehouseInfoId, device_number)
875
+												//查询默认仓库
876
+												houseConfig, _ := service.GetAllStoreHouseConfig(druginfo.OrgId)
877
+												//查询默认仓库剩余多少库存
878
+												list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, druginfo.OrgId, drug_id)
879
+												var sum_count int64
880
+												var sum_in_count int64
881
+												for _, it := range list {
882
+													baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
883
+													if it.MaxUnit == baseDrug.MaxUnit {
884
+														it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
885
+														it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
886
+
887
+													}
888
+													sum_count += it.StockMaxNumber + it.StockMinNumber
889
+													sum_in_count += it.WarehousingCount
890
+												}
891
+												service.UpdateMedicalSumCount(drug_id, sum_count, sum_in_count, druginfo.OrgId)
836 892
 											}
837 893
 										}
838 894
 
839 895
 										if druginfo.CountUnit == drug.MaxUnit && druginfo.CountUnit == drug.MinUnit && drug.MaxUnit == drug.MinUnit {
840 896
 											service.ModefyDrugByWarehouseInfo(druginfo.WarehouseInfoId, device_number)
897
+											//查询默认仓库
898
+											houseConfig, _ := service.GetAllStoreHouseConfig(druginfo.OrgId)
899
+											//查询默认仓库剩余多少库存
900
+											list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, druginfo.OrgId, drug_id)
901
+											var sum_count int64
902
+											var sum_in_count int64
903
+											for _, it := range list {
904
+												baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
905
+												if it.MaxUnit == baseDrug.MaxUnit {
906
+													it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
907
+													it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
908
+
909
+												}
910
+												sum_count += it.StockMaxNumber + it.StockMinNumber
911
+												sum_in_count += it.WarehousingCount
912
+											}
913
+											service.UpdateMedicalSumCount(drug_id, sum_count, sum_in_count, druginfo.OrgId)
841 914
 										}
842 915
 										//删除记录
843 916
 										service.DeleteDrugAutoWarehouseSeven(drug_id, patient_id, recordDateTime, adviceId)
@@ -867,7 +940,7 @@ func (c *HisApiController) CreateHisPrescription() {
867 940
 
868 941
 								var project_id int64
869 942
 								var project_type int64
870
-								var totals float64
943
+								//var totals float64
871 944
 								var project_name string
872 945
 								var parsetotal int64
873 946
 								var id int64
@@ -883,7 +956,7 @@ func (c *HisApiController) CreateHisPrescription() {
883 956
 								}
884 957
 								if project.(map[string]interface{})["total"] != nil || reflect.TypeOf(project.(map[string]interface{})["total"]).String() == "string" {
885 958
 									total, _ := project.(map[string]interface{})["total"].(string)
886
-									totals, _ = strconv.ParseFloat(total, 64)
959
+									//	totals, _ = strconv.ParseFloat(total, 64)
887 960
 									parsetotal, _ = strconv.ParseInt(total, 10, 64)
888 961
 								}
889 962
 
@@ -902,14 +975,20 @@ func (c *HisApiController) CreateHisPrescription() {
902 975
 
903 976
 									if len(goodWarehouseInfo) == 0 {
904 977
 										//查询耗材库存
905
-										list, _ := service.GetGoodWarehouseInfoSeven(project_id)
906
-										var stock_count int64
907
-										for _, it := range list {
908
-											stock_count += it.StockCount
909
-										}
910
-										stock_counts := strconv.FormatInt(stock_count, 10)
911
-										stock_total_count, _ := strconv.ParseFloat(stock_counts, 64)
912
-										if totals > stock_total_count {
978
+										//list, _ := service.GetGoodWarehouseInfoSeven(project_id)
979
+										//var stock_count int64
980
+										//for _, it := range list {
981
+										//	stock_count += it.StockCount
982
+										//}
983
+										//stock_counts := strconv.FormatInt(stock_count, 10)
984
+										//stock_total_count, _ := strconv.ParseFloat(stock_counts, 64)
985
+										//if totals > stock_total_count {
986
+										//	c.ServeDynamicFailJsonSend(project_name + "库存不足")
987
+										//	return
988
+										//}
989
+
990
+										good, _ := service.GetGoodInformationByGoodId(project_id)
991
+										if parsetotal > good.SumCount {
913 992
 											c.ServeDynamicFailJsonSend(project_name + "库存不足")
914 993
 											return
915 994
 										}
@@ -919,6 +998,16 @@ func (c *HisApiController) CreateHisPrescription() {
919 998
 										for _, item := range goodList {
920 999
 											//回退库存
921 1000
 											service.ModefyWarehouseInfo(item.Count, item.WarehouseInfotId)
1001
+											//查询默认仓库
1002
+											houseConfig, _ := service.GetAllStoreHouseConfig(item.GoodId)
1003
+											goodList, _ := service.GetGoodSumCountByStoreId(houseConfig.StorehouseOutInfo, item.ProjectId, item.OrgId)
1004
+											var sum_count int64
1005
+											var sum_in_count int64
1006
+											for _, it := range goodList {
1007
+												sum_count += it.StockCount
1008
+												sum_in_count += it.WarehousingCount
1009
+											}
1010
+											service.UpdateGoodByGoodId(item.GoodId, sum_count, sum_in_count, item.OrgId)
922 1011
 										}
923 1012
 										//删除记录
924 1013
 										service.DeleteAutoWarehouse(patient_id, recordDateTime)
@@ -937,6 +1026,16 @@ func (c *HisApiController) CreateHisPrescription() {
937 1026
 											for _, item := range goodList {
938 1027
 												//回退库存
939 1028
 												service.ModefyWarehouseInfo(item.Count, item.WarehouseInfotId)
1029
+												//查询默认仓库
1030
+												houseConfig, _ := service.GetAllStoreHouseConfig(item.GoodId)
1031
+												goodList, _ := service.GetGoodSumCountByStoreId(houseConfig.StorehouseOutInfo, item.ProjectId, item.OrgId)
1032
+												var sum_count int64
1033
+												var sum_in_count int64
1034
+												for _, it := range goodList {
1035
+													sum_count += it.StockCount
1036
+													sum_in_count += it.WarehousingCount
1037
+												}
1038
+												service.UpdateGoodByGoodId(item.GoodId, sum_count, sum_in_count, item.OrgId)
940 1039
 											}
941 1040
 											//删除记录
942 1041
 											service.DeleteAutoWarehouse(patient_id, recordDateTime)
@@ -1641,7 +1740,7 @@ func (c *HisApiController) DeletePrescription() {
1641 1740
 	_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
1642 1741
 
1643 1742
 	_, stockConfig := service.FindAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
1644
-
1743
+	houseConfig, _ := service.GetAllStoreHouseConfig(c.GetAdminUserInfo().CurrentOrgId)
1645 1744
 	if len(projects) > 0 {
1646 1745
 		for _, item := range projects {
1647 1746
 			service.DeletePrintInfo(item.ID) //删除打印信息
@@ -1661,14 +1760,15 @@ func (c *HisApiController) DeletePrescription() {
1661 1760
 					orderNumber := "CKTKD" + strconv.FormatInt(c.GetAdminUserInfo().CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
1662 1761
 
1663 1762
 					cancelStock := models.CancelStock{
1664
-						OrderNumber: orderNumber,
1665
-						OperaTime:   operation_time,
1666
-						OrgId:       c.GetAdminUserInfo().CurrentOrgId,
1667
-						Creater:     creater,
1668
-						Ctime:       time.Now().Unix(),
1669
-						Status:      1,
1670
-						ReturnTime:  item.RecordDate,
1671
-						Type:        1,
1763
+						OrderNumber:  orderNumber,
1764
+						OperaTime:    operation_time,
1765
+						OrgId:        c.GetAdminUserInfo().CurrentOrgId,
1766
+						Creater:      creater,
1767
+						Ctime:        time.Now().Unix(),
1768
+						Status:       1,
1769
+						ReturnTime:   item.RecordDate,
1770
+						Type:         1,
1771
+						StorehouseId: houseConfig.StorehouseOutInfo,
1672 1772
 					}
1673 1773
 					_, msgerrkonde := service.GetCancelStockDetailByOrderNumberOne(item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
1674 1774
 					if msgerrkonde == gorm.ErrRecordNotFound {
@@ -1704,6 +1804,7 @@ func (c *HisApiController) DeletePrescription() {
1704 1804
 							WarehouseInfoId: info.WarehouseInfotId,
1705 1805
 							PatientId:       info.PatientId,
1706 1806
 							RecordDate:      info.SysRecordTime,
1807
+							StorehouseId:    houseConfig.StorehouseOutInfo,
1707 1808
 						}
1708 1809
 
1709 1810
 						service.CreateCancelStockInfoOne(&cancelStockInfo)
@@ -1740,6 +1841,7 @@ func (c *HisApiController) DeletePrescription() {
1740 1841
 							CancelOutDetailId:       cancelInfo.ID,
1741 1842
 							ProductDate:             info.ProductDate,
1742 1843
 							ExpireDate:              info.ExpiryDate,
1844
+							StorehouseId:            houseConfig.StorehouseOutInfo,
1743 1845
 						}
1744 1846
 						service.CreateStockFlowOne(flow)
1745 1847
 
@@ -1757,7 +1859,7 @@ func (c *HisApiController) DeletePrescription() {
1757 1859
 						}
1758 1860
 						//回退库存
1759 1861
 						service.UpDateWarehouseInfoByStockDelete(info.WarehouseInfotId, total_count)
1760
-
1862
+						service.ModifyGoodAddInformation(info.GoodId, total_count, info.OrgId)
1761 1863
 						//查询今日该耗材退库数量
1762 1864
 						cancelInfoOne, _ := service.GetCancelStockInfoByPatientId(info.PatientId, item.ProjectId, info.SysRecordTime)
1763 1865
 						var cancel_Count int64
@@ -1792,6 +1894,7 @@ func (c *HisApiController) DeletePrescription() {
1792 1894
 									Manufacturer:            0,
1793 1895
 									Type:                    1,
1794 1896
 									IsSys:                   1,
1897
+									StorehouseId:            houseConfig.StorehouseOutInfo,
1795 1898
 								}
1796 1899
 								err := service.AddSigleWarehouseOut(&warehouseOut)
1797 1900
 								if err != nil {
@@ -1799,24 +1902,26 @@ func (c *HisApiController) DeletePrescription() {
1799 1902
 									return
1800 1903
 								}
1801 1904
 								prepare := &models.DialysisBeforePrepare{
1802
-									UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
1803
-									PatientId:  info.PatientId,
1804
-									RecordDate: info.SysRecordTime,
1805
-									GoodId:     item.ProjectId,
1806
-									GoodTypeId: info.GoodTypeId,
1807
-									Count:      cha_count,
1905
+									UserOrgId:    c.GetAdminUserInfo().CurrentOrgId,
1906
+									PatientId:    info.PatientId,
1907
+									RecordDate:   info.SysRecordTime,
1908
+									GoodId:       item.ProjectId,
1909
+									GoodTypeId:   info.GoodTypeId,
1910
+									Count:        cha_count,
1911
+									StorehouseId: houseConfig.StorehouseOutInfo,
1808 1912
 								}
1809 1913
 								//出库
1810 1914
 								service.ConsumablesDelivery(c.GetAdminUserInfo().CurrentOrgId, info.PatientId, info.SysRecordTime, prepare, &warehouseOut, cha_count)
1811 1915
 							} else if err == nil {
1812 1916
 
1813 1917
 								prepare := &models.DialysisBeforePrepare{
1814
-									UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
1815
-									PatientId:  info.PatientId,
1816
-									RecordDate: info.SysRecordTime,
1817
-									GoodId:     item.ProjectId,
1818
-									GoodTypeId: info.GoodTypeId,
1819
-									Count:      cha_count,
1918
+									UserOrgId:    c.GetAdminUserInfo().CurrentOrgId,
1919
+									PatientId:    info.PatientId,
1920
+									RecordDate:   info.SysRecordTime,
1921
+									GoodId:       item.ProjectId,
1922
+									GoodTypeId:   info.GoodTypeId,
1923
+									Count:        cha_count,
1924
+									StorehouseId: houseConfig.StorehouseOutInfo,
1820 1925
 								}
1821 1926
 								//出库
1822 1927
 								service.ConsumablesDelivery(c.GetAdminUserInfo().CurrentOrgId, info.PatientId, info.SysRecordTime, prepare, &out, cha_count)
@@ -1866,7 +1971,7 @@ func (c *HisApiController) DeletePrescription() {
1866 1971
 						}
1867 1972
 
1868 1973
 						service.UpdateDrugWarehouse(info.WarehouseInfoId, warehouseInfo)
1869
-
1974
+						service.ModifyDrugAddInformation(info.DrugId, warehouseInfo.StockMinNumber, warehouseInfo.OrgId)
1870 1975
 						adminUserInfo := c.GetAdminUserInfo()
1871 1976
 						operation_time := time.Now().Unix()
1872 1977
 						creater := adminUserInfo.AdminUser.Id
@@ -1889,6 +1994,7 @@ func (c *HisApiController) DeletePrescription() {
1889 1994
 							Dealer:       info.Dealer,
1890 1995
 							Manufacturer: info.Manufacturer,
1891 1996
 							Type:         1,
1997
+							StorehouseId: houseConfig.DrugStorehouseOut,
1892 1998
 						}
1893 1999
 						service.AddSigleDrugCancelStock(&cancelStock)
1894 2000
 
@@ -1917,6 +2023,7 @@ func (c *HisApiController) DeletePrescription() {
1917 2023
 							ProductDate:      info.ProductDate,
1918 2024
 							ExpiryDate:       info.ExpiryDate,
1919 2025
 							BatchNumberId:    info.WarehouseInfoId,
2026
+							StorehouseId:     houseConfig.DrugStorehouseOut,
1920 2027
 						}
1921 2028
 
1922 2029
 						flow := models.DrugFlow{
@@ -1952,6 +2059,7 @@ func (c *HisApiController) DeletePrescription() {
1952 2059
 							MaxUnit:                 info.CountUnit,
1953 2060
 							MinUnit:                 "",
1954 2061
 							AdviceId:                info.AdviceId,
2062
+							StorehouseId:            houseConfig.DrugStorehouseOut,
1955 2063
 						}
1956 2064
 						service.CreatedCancelStock(cancelStockInfo)
1957 2065
 						service.CreateDrugFlowOne(flow)
@@ -1968,9 +2076,12 @@ func (c *HisApiController) DeletePrescription() {
1968 2076
 						if item.PrescribingNumberUnit == drug.MaxUnit {
1969 2077
 							warehouseInfo := models.DrugWarehouseInfo{
1970 2078
 								StockMaxNumber: prescribingNumber,
2079
+								StorehouseId:   houseConfig.DrugStorehouseOut,
1971 2080
 							}
1972 2081
 							service.UpdateDrugWarehouseOne(info.WarehouseInfoId, warehouseInfo)
1973
-
2082
+							var sum_count int64
2083
+							sum_count = prescribingNumber * drug.MinNumber
2084
+							service.ModifyDrugAddInformation(info.DrugId, sum_count, info.OrgId)
1974 2085
 						}
1975 2086
 
1976 2087
 						adminUserInfo := c.GetAdminUserInfo()
@@ -1995,6 +2106,7 @@ func (c *HisApiController) DeletePrescription() {
1995 2106
 							Dealer:       info.Dealer,
1996 2107
 							Manufacturer: info.Manufacturer,
1997 2108
 							Type:         1,
2109
+							StorehouseId: houseConfig.DrugStorehouseOut,
1998 2110
 						}
1999 2111
 						service.AddSigleDrugCancelStock(&cancelStock)
2000 2112
 
@@ -2024,6 +2136,7 @@ func (c *HisApiController) DeletePrescription() {
2024 2136
 							ProductDate:      info.ProductDate,
2025 2137
 							ExpiryDate:       info.ExpiryDate,
2026 2138
 							BatchNumberId:    info.WarehouseInfoId,
2139
+							StorehouseId:     houseConfig.DrugStorehouseOut,
2027 2140
 						}
2028 2141
 
2029 2142
 						flow := models.DrugFlow{
@@ -2060,6 +2173,7 @@ func (c *HisApiController) DeletePrescription() {
2060 2173
 							MaxUnit:                 info.CountUnit,
2061 2174
 							MinUnit:                 "",
2062 2175
 							AdviceId:                info.AdviceId,
2176
+							StorehouseId:            houseConfig.DrugStorehouseOut,
2063 2177
 						}
2064 2178
 						service.CreatedCancelStock(cancelStockInfo)
2065 2179
 						service.CreateDrugFlowOne(flow)
@@ -2110,7 +2224,7 @@ func (c *HisApiController) DeleteDoctorAdvice() {
2110 2224
 		if drugStockConfig.IsOpen == 1 {
2111 2225
 			//判断该医嘱是否执行了
2112 2226
 			if advice.ExecutionState == 1 {
2113
-
2227
+				houseConfig, _ := service.GetAllStoreHouseConfig(advice.UserOrgId)
2114 2228
 				//查询该病人该药品是否有库存记录
2115 2229
 				info, errcode := service.GetDrugAutoWarehouseOutSeven(advice.PatientId, advice.AdviceDate, advice.DrugId, advice.ID)
2116 2230
 				if errcode == gorm.ErrRecordNotFound {
@@ -2129,7 +2243,7 @@ func (c *HisApiController) DeleteDoctorAdvice() {
2129 2243
 						}
2130 2244
 
2131 2245
 						service.UpdateDrugWarehouse(info.WarehouseInfoId, warehouseInfo)
2132
-
2246
+						service.ModifyDrugAddInformation(info.DrugId, warehouseInfo.StockMinNumber, info.OrgId)
2133 2247
 						adminUserInfo := c.GetAdminUserInfo()
2134 2248
 						operation_time := time.Now().Unix()
2135 2249
 						creater := adminUserInfo.AdminUser.Id
@@ -2152,6 +2266,7 @@ func (c *HisApiController) DeleteDoctorAdvice() {
2152 2266
 							Dealer:       info.Dealer,
2153 2267
 							Manufacturer: info.Manufacturer,
2154 2268
 							Type:         1,
2269
+							StorehouseId: houseConfig.DrugStorehouseOut,
2155 2270
 						}
2156 2271
 						service.AddSigleDrugCancelStock(&cancelStock)
2157 2272
 
@@ -2180,6 +2295,7 @@ func (c *HisApiController) DeleteDoctorAdvice() {
2180 2295
 							ProductDate:      info.ProductDate,
2181 2296
 							ExpiryDate:       info.ExpiryDate,
2182 2297
 							BatchNumberId:    info.WarehouseInfoId,
2298
+							StorehouseId:     houseConfig.DrugStorehouseOut,
2183 2299
 						}
2184 2300
 
2185 2301
 						flow := models.DrugFlow{
@@ -2215,6 +2331,7 @@ func (c *HisApiController) DeleteDoctorAdvice() {
2215 2331
 							MaxUnit:                 info.CountUnit,
2216 2332
 							MinUnit:                 "",
2217 2333
 							AdviceId:                info.AdviceId,
2334
+							StorehouseId:            houseConfig.DrugStorehouseOut,
2218 2335
 						}
2219 2336
 						service.CreatedCancelStock(cancelStockInfo)
2220 2337
 						service.CreateDrugFlowOne(flow)
@@ -2233,8 +2350,10 @@ func (c *HisApiController) DeleteDoctorAdvice() {
2233 2350
 							warehouseInfo := models.DrugWarehouseInfo{
2234 2351
 								StockMaxNumber: prescribingNumber,
2235 2352
 							}
2353
+							var sum_count int64
2354
+							sum_count = prescribingNumber * drug.MinNumber
2236 2355
 							service.UpdateDrugWarehouseOne(info.WarehouseInfoId, warehouseInfo)
2237
-
2356
+							service.ModifyDrugAddInformation(info.DrugId, sum_count, info.OrgId)
2238 2357
 						}
2239 2358
 
2240 2359
 						adminUserInfo := c.GetAdminUserInfo()
@@ -2259,6 +2378,7 @@ func (c *HisApiController) DeleteDoctorAdvice() {
2259 2378
 							Dealer:       info.Dealer,
2260 2379
 							Manufacturer: info.Manufacturer,
2261 2380
 							Type:         1,
2381
+							StorehouseId: houseConfig.DrugStorehouseOut,
2262 2382
 						}
2263 2383
 						service.AddSigleDrugCancelStock(&cancelStock)
2264 2384
 
@@ -2287,6 +2407,7 @@ func (c *HisApiController) DeleteDoctorAdvice() {
2287 2407
 							ProductDate:      info.ProductDate,
2288 2408
 							ExpiryDate:       info.ExpiryDate,
2289 2409
 							BatchNumberId:    info.WarehouseInfoId,
2410
+							StorehouseId:     houseConfig.DrugStorehouseOut,
2290 2411
 						}
2291 2412
 
2292 2413
 						flow := models.DrugFlow{
@@ -2322,6 +2443,7 @@ func (c *HisApiController) DeleteDoctorAdvice() {
2322 2443
 							MaxUnit:                 info.CountUnit,
2323 2444
 							MinUnit:                 "",
2324 2445
 							AdviceId:                info.AdviceId,
2446
+							StorehouseId:            houseConfig.DrugStorehouseOut,
2325 2447
 						}
2326 2448
 						service.CreatedCancelStock(cancelStockInfo)
2327 2449
 						service.CreateDrugFlowOne(flow)
@@ -2366,6 +2488,7 @@ func (c *HisApiController) DeleteProject() {
2366 2488
 		if project.Type == 3 {
2367 2489
 			good, _ := service.FindGoodInfoByIdTwo(project.ProjectId)
2368 2490
 			f_count, _ := strconv.ParseFloat(project.Count, 64)
2491
+			houseConfig, _ := service.GetAllStoreHouseConfig(c.GetAdminUserInfo().CurrentOrgId)
2369 2492
 			good.Total = good.Total + f_count
2370 2493
 			service.UpdateGoodInfo(&good)
2371 2494
 
@@ -2379,14 +2502,15 @@ func (c *HisApiController) DeleteProject() {
2379 2502
 			orderNumber := "CKTKD" + strconv.FormatInt(adminInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
2380 2503
 
2381 2504
 			cancelStock := models.CancelStock{
2382
-				OrderNumber: orderNumber,
2383
-				OperaTime:   operation_time,
2384
-				OrgId:       adminInfo.CurrentOrgId,
2385
-				Creater:     creater,
2386
-				Ctime:       time.Now().Unix(),
2387
-				Status:      1,
2388
-				ReturnTime:  project.RecordDate,
2389
-				Type:        1,
2505
+				OrderNumber:  orderNumber,
2506
+				OperaTime:    operation_time,
2507
+				OrgId:        adminInfo.CurrentOrgId,
2508
+				Creater:      creater,
2509
+				Ctime:        time.Now().Unix(),
2510
+				Status:       1,
2511
+				ReturnTime:   project.RecordDate,
2512
+				Type:         1,
2513
+				StorehouseId: houseConfig.StorehouseOutInfo,
2390 2514
 			}
2391 2515
 			_, msgerrkonde := service.GetCancelStockDetailByOrderNumberOne(project.RecordDate, adminInfo.CurrentOrgId)
2392 2516
 			if msgerrkonde == gorm.ErrRecordNotFound {
@@ -2423,6 +2547,7 @@ func (c *HisApiController) DeleteProject() {
2423 2547
 					WarehouseInfoId: info.WarehouseInfotId,
2424 2548
 					PatientId:       info.PatientId,
2425 2549
 					RecordDate:      info.SysRecordTime,
2550
+					StorehouseId:    houseConfig.StorehouseOutInfo,
2426 2551
 				}
2427 2552
 
2428 2553
 				service.CreateCancelStockInfoOne(&cancelStockInfo)
@@ -2459,6 +2584,7 @@ func (c *HisApiController) DeleteProject() {
2459 2584
 					CancelOutDetailId:       cancelInfo.ID,
2460 2585
 					ProductDate:             info.ProductDate,
2461 2586
 					ExpireDate:              info.ExpiryDate,
2587
+					StorehouseId:            houseConfig.StorehouseOutInfo,
2462 2588
 				}
2463 2589
 				service.CreateStockFlowOne(flow)
2464 2590
 
@@ -2476,7 +2602,7 @@ func (c *HisApiController) DeleteProject() {
2476 2602
 				}
2477 2603
 				//回退库存
2478 2604
 				service.UpDateWarehouseInfoByStockDelete(info.WarehouseInfotId, total_count)
2479
-
2605
+				service.ModifyGoodAddInformation(info.GoodId, total_count, info.OrgId)
2480 2606
 				//查询今日该耗材退库数量
2481 2607
 				cancelInfoOne, _ := service.GetCancelStockInfoByPatientId(info.PatientId, project.ProjectId, info.SysRecordTime)
2482 2608
 				var cancel_count int64
@@ -2511,6 +2637,7 @@ func (c *HisApiController) DeleteProject() {
2511 2637
 							Manufacturer:            0,
2512 2638
 							Type:                    1,
2513 2639
 							IsSys:                   1,
2640
+							StorehouseId:            houseConfig.StorehouseOutInfo,
2514 2641
 						}
2515 2642
 						err := service.AddSigleWarehouseOut(&warehouseOut)
2516 2643
 						if err != nil {
@@ -2518,23 +2645,25 @@ func (c *HisApiController) DeleteProject() {
2518 2645
 							return
2519 2646
 						}
2520 2647
 						prepare := &models.DialysisBeforePrepare{
2521
-							UserOrgId:  adminInfo.CurrentOrgId,
2522
-							PatientId:  info.PatientId,
2523
-							RecordDate: info.SysRecordTime,
2524
-							GoodId:     project.ProjectId,
2525
-							GoodTypeId: info.GoodTypeId,
2526
-							Count:      cha_count,
2648
+							UserOrgId:    adminInfo.CurrentOrgId,
2649
+							PatientId:    info.PatientId,
2650
+							RecordDate:   info.SysRecordTime,
2651
+							GoodId:       project.ProjectId,
2652
+							GoodTypeId:   info.GoodTypeId,
2653
+							Count:        cha_count,
2654
+							StorehouseId: houseConfig.StorehouseOutInfo,
2527 2655
 						}
2528 2656
 						//出库
2529 2657
 						service.ConsumablesDelivery(adminInfo.CurrentOrgId, info.PatientId, info.SysRecordTime, prepare, &warehouseOut, cha_count)
2530 2658
 					} else if err == nil {
2531 2659
 						prepare := &models.DialysisBeforePrepare{
2532
-							UserOrgId:  adminInfo.CurrentOrgId,
2533
-							PatientId:  info.PatientId,
2534
-							RecordDate: info.SysRecordTime,
2535
-							GoodId:     project.ProjectId,
2536
-							GoodTypeId: info.GoodTypeId,
2537
-							Count:      cha_count,
2660
+							UserOrgId:    adminInfo.CurrentOrgId,
2661
+							PatientId:    info.PatientId,
2662
+							RecordDate:   info.SysRecordTime,
2663
+							GoodId:       project.ProjectId,
2664
+							GoodTypeId:   info.GoodTypeId,
2665
+							Count:        cha_count,
2666
+							StorehouseId: houseConfig.StorehouseOutInfo,
2538 2667
 						}
2539 2668
 						//出库
2540 2669
 						service.ConsumablesDelivery(adminInfo.CurrentOrgId, info.PatientId, info.SysRecordTime, prepare, &out, cha_count)

+ 1 - 1
controllers/mobile_api_controllers/check_weight_api_controller.go ファイルの表示

@@ -264,7 +264,7 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
264 264
 
265 265
 	template, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
266 266
 
267
-	if template.TemplateId == 22 || template.TemplateId == 17 || template.TemplateId == 21 || template.TemplateId == 26 || template.TemplateId == 27 || template.TemplateId == 34 || template.TemplateId == 30 || template.TemplateId == 32 || template.TemplateId == 36 || template.TemplateId == 40 || template.TemplateId == 38 || template.TemplateId == 43 || template.TemplateId == 46 || template.TemplateId == 47 {
267
+	if template.TemplateId == 22 || template.TemplateId == 17 || template.TemplateId == 21 || template.TemplateId == 26 || template.TemplateId == 27 || template.TemplateId == 34 || template.TemplateId == 30 || template.TemplateId == 32 || template.TemplateId == 36 || template.TemplateId == 40 || template.TemplateId == 38 || template.TemplateId == 43 || template.TemplateId == 46 {
268 268
 		dewater_amount = dewater_amount * 1000
269 269
 	}
270 270
 

+ 235 - 102
controllers/mobile_api_controllers/dialysis_api_controller.go ファイルの表示

@@ -2254,7 +2254,11 @@ func (this *DialysisAPIController) StartDialysis() {
2254 2254
 
2255 2255
 	var tempdispose string
2256 2256
 	// 只针对中能建
2257
-	if blood_drawing > 0 {
2257
+	if blood_drawing > 0 && adminUserInfo.Org.Id == 9538 {
2258
+		tempdispose = "引血" + strconv.FormatInt(blood_drawing, 10) + "ml/min"
2259
+	}
2260
+
2261
+	if blood_drawing > 0 && adminUserInfo.Org.Id == 10318 {
2258 2262
 		tempdispose = "引血" + strconv.FormatInt(blood_drawing, 10) + "ml/min"
2259 2263
 	}
2260 2264
 
@@ -2885,7 +2889,7 @@ func (this *DialysisAPIController) GetLastMonitorRecordTody() {
2885 2889
 				record.UltrafiltrationRate = ultrafiltration_rate
2886 2890
 			}
2887 2891
 
2888
-			if template.TemplateId == 41 {
2892
+			if template.TemplateId == 41 || template.TemplateId == 47 {
2889 2893
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 60 / float64(totalMin) * 1000)
2890 2894
 				record.UltrafiltrationRate = ultrafiltration_rate
2891 2895
 			}
@@ -2894,6 +2898,10 @@ func (this *DialysisAPIController) GetLastMonitorRecordTody() {
2894 2898
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 60 / float64(totalMin))
2895 2899
 				record.UltrafiltrationRate = ultrafiltration_rate
2896 2900
 			}
2901
+			if template.TemplateId == 46 {
2902
+				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 60 / float64(totalMin))
2903
+				record.UltrafiltrationRate = ultrafiltration_rate
2904
+			}
2897 2905
 
2898 2906
 			if template.TemplateId == 47 {
2899 2907
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 60 / float64(totalMin))
@@ -2912,7 +2920,7 @@ func (this *DialysisAPIController) GetLastMonitorRecordTody() {
2912 2920
 		}
2913 2921
 	}
2914 2922
 
2915
-	if template.TemplateId == 6 || template.TemplateId == 20 || template.TemplateId == 22 || template.TemplateId == 32 || template.TemplateId == 34 || template.TemplateId == 36 || template.TemplateId == 41 || template.TemplateId == 43 || template.TemplateId == 47 { //adminInfo.Org.Id == 9538
2923
+	if template.TemplateId == 6 || template.TemplateId == 20 || template.TemplateId == 22 || template.TemplateId == 32 || template.TemplateId == 34 || template.TemplateId == 36 || template.TemplateId == 41 || template.TemplateId == 43 { //adminInfo.Org.Id == 9538
2916 2924
 		if ultrafiltration_rate > 0 && adminInfo.Org.Id != 9538 {
2917 2925
 			ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
2918 2926
 			record.UltrafiltrationVolume = ultrafiltration_volume
@@ -2920,6 +2928,10 @@ func (this *DialysisAPIController) GetLastMonitorRecordTody() {
2920 2928
 		}
2921 2929
 	}
2922 2930
 
2931
+	if template.TemplateId == 47 {
2932
+		record.DisplacementQuantity = record.DisplacementQuantity + record.DisplacementQuantity
2933
+	}
2934
+
2923 2935
 	this.ServeSuccessJSON(map[string]interface{}{
2924 2936
 		"monitor": record,
2925 2937
 	})
@@ -3894,6 +3906,8 @@ func (c *DialysisAPIController) CreateConsumables() {
3894 3906
 		return
3895 3907
 	}
3896 3908
 
3909
+	houseConfig, _ := service.GetAllStoreHouseConfig(adminUser.Org.Id)
3910
+
3897 3911
 	var beforePrepares []*models.DialysisBeforePrepareGoods
3898 3912
 	var newBeforePrepares []*models.NewDialysisBeforePrepareGoods
3899 3913
 	var dialysisBefor []*models.DialysisBeforePrepare
@@ -3929,17 +3943,19 @@ func (c *DialysisAPIController) CreateConsumables() {
3929 3943
 				fmt.Println("commdity", commdity_code)
3930 3944
 
3931 3945
 				prepareGoods := &models.DialysisBeforePrepareGoods{
3932
-					GoodTypeId: good_type_id,
3933
-					GoodId:     good_id,
3934
-					Count:      count,
3946
+					GoodTypeId:   good_type_id,
3947
+					GoodId:       good_id,
3948
+					Count:        count,
3949
+					StorehouseId: houseConfig.StorehouseOutInfo,
3935 3950
 				}
3936 3951
 
3937 3952
 				beforePrepares = append(beforePrepares, prepareGoods)
3938 3953
 
3939 3954
 				newPrepareGoods := &models.NewDialysisBeforePrepareGoods{
3940
-					GoodTypeId: good_type_id,
3941
-					GoodId:     good_id,
3942
-					Count:      count,
3955
+					GoodTypeId:   good_type_id,
3956
+					GoodId:       good_id,
3957
+					Count:        count,
3958
+					StorehouseId: houseConfig.StorehouseOutInfo,
3943 3959
 				}
3944 3960
 
3945 3961
 				newBeforePrepares = append(newBeforePrepares, newPrepareGoods)
@@ -3955,6 +3971,7 @@ func (c *DialysisAPIController) CreateConsumables() {
3955 3971
 					Ctime:        time.Now().Unix(),
3956 3972
 					Creater:      adminUser.AdminUser.Id,
3957 3973
 					CommdityCode: commdity_code,
3974
+					StorehouseId: houseConfig.StorehouseOutInfo,
3958 3975
 				}
3959 3976
 
3960 3977
 				dialysisBefor = append(dialysisBefor, prepare)
@@ -3964,7 +3981,8 @@ func (c *DialysisAPIController) CreateConsumables() {
3964 3981
 
3965 3982
 		//查询是否有库存
3966 3983
 		for _, item := range dialysisBefor {
3967
-			_, err := service.FindFirstWarehousingInfoByStock(item.GoodId, item.GoodTypeId)
3984
+			fmt.Println("houseconfig233232323232232332323223233", houseConfig.StorehouseOutInfo)
3985
+			_, err := service.FindFirstWarehousingInfoByStock(item.GoodId, item.GoodTypeId, houseConfig.StorehouseOutInfo)
3968 3986
 
3969 3987
 			if err == gorm.ErrRecordNotFound {
3970 3988
 				goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
@@ -4002,11 +4020,21 @@ func (c *DialysisAPIController) CreateConsumables() {
4002 4020
 					Creater:      item.Creater,
4003 4021
 					CommdityCode: item.CommdityCode,
4004 4022
 					Status:       1,
4023
+					StorehouseId: houseConfig.StorehouseOutInfo,
4005 4024
 				}
4006 4025
 				//先清除再插入
4007 4026
 				service.DeleteDialysisBefor(adminUser.Org.Id, patient_id, record_time, item.GoodId, item.GoodTypeId)
4008 4027
 				err = service.CreateDialysisBeforePrepareOne(&dialyPrepareOne)
4009
-
4028
+				//查询默认仓库
4029
+				houseConfig, _ := service.GetAllStoreHouseConfig(adminUser.Org.Id)
4030
+				goodList, _ := service.GetGoodSumCountByStoreId(houseConfig.StorehouseOutInfo, item.GoodId, adminUser.Org.Id)
4031
+				var sum_count int64
4032
+				var sum_in_count int64
4033
+				for _, it := range goodList {
4034
+					sum_count += it.StockCount
4035
+					sum_in_count += it.WarehousingCount
4036
+				}
4037
+				service.UpdateGoodByGoodId(item.GoodId, sum_count, sum_in_count, adminUser.Org.Id)
4010 4038
 			}
4011 4039
 			if err == nil {
4012 4040
 				c.ServeSuccessJSON(map[string]interface{}{
@@ -4040,15 +4068,16 @@ func (c *DialysisAPIController) CreateConsumables() {
4040 4068
 
4041 4069
 					for _, it := range list {
4042 4070
 						prepare := models.DialysisBeforePrepare{
4043
-							UserOrgId:  it.OrgId,
4044
-							PatientId:  patient_id,
4045
-							RecordDate: it.RecordTime,
4046
-							GoodId:     it.GoodId,
4047
-							GoodTypeId: it.GoodTypeId,
4048
-							Count:      it.Count,
4049
-							Ctime:      time.Now().Unix(),
4050
-							Creater:    adminUser.AdminUser.Id,
4051
-							Status:     1,
4071
+							UserOrgId:    it.OrgId,
4072
+							PatientId:    patient_id,
4073
+							RecordDate:   it.RecordTime,
4074
+							GoodId:       it.GoodId,
4075
+							GoodTypeId:   it.GoodTypeId,
4076
+							Count:        it.Count,
4077
+							Ctime:        time.Now().Unix(),
4078
+							Creater:      adminUser.AdminUser.Id,
4079
+							Status:       1,
4080
+							StorehouseId: houseConfig.StorehouseOutInfo,
4052 4081
 						}
4053 4082
 						//删除准备表数据
4054 4083
 						service.DeleteDialysisBefor(adminUser.Org.Id, patient_id, record_time, item.GoodId, item.GoodTypeId)
@@ -4081,21 +4110,31 @@ func (c *DialysisAPIController) CreateConsumables() {
4081 4110
 
4082 4111
 						for _, it := range list {
4083 4112
 							prepare := models.DialysisBeforePrepare{
4084
-								UserOrgId:  it.OrgId,
4085
-								PatientId:  patient_id,
4086
-								RecordDate: it.RecordTime,
4087
-								GoodId:     it.GoodId,
4088
-								GoodTypeId: it.GoodTypeId,
4089
-								Count:      it.Count,
4090
-								Ctime:      time.Now().Unix(),
4091
-								Creater:    adminUser.AdminUser.Id,
4092
-								Status:     1,
4113
+								UserOrgId:    it.OrgId,
4114
+								PatientId:    patient_id,
4115
+								RecordDate:   it.RecordTime,
4116
+								GoodId:       it.GoodId,
4117
+								GoodTypeId:   it.GoodTypeId,
4118
+								Count:        it.Count,
4119
+								Ctime:        time.Now().Unix(),
4120
+								Creater:      adminUser.AdminUser.Id,
4121
+								Status:       1,
4122
+								StorehouseId: houseConfig.StorehouseOutInfo,
4093 4123
 							}
4094 4124
 							//删除准备表数据
4095 4125
 							service.DeleteDialysisBefor(adminUser.Org.Id, patient_id, record_time, item.GoodId, item.GoodTypeId)
4096 4126
 
4097 4127
 							service.CreateDialysisBeforePrepareOne(&prepare)
4098
-
4128
+							//查询默认仓库
4129
+							houseConfig, _ := service.GetAllStoreHouseConfig(adminUser.Org.Id)
4130
+							goodList, _ := service.GetGoodSumCountByStoreId(houseConfig.StorehouseOutInfo, item.GoodId, adminUser.Org.Id)
4131
+							var sum_count int64
4132
+							var sum_in_count int64
4133
+							for _, it := range goodList {
4134
+								sum_count += it.StockCount
4135
+								sum_in_count += it.WarehousingCount
4136
+							}
4137
+							service.UpdateGoodByGoodId(item.GoodId, sum_count, sum_in_count, adminUser.Org.Id)
4099 4138
 						}
4100 4139
 					}
4101 4140
 
@@ -4107,21 +4146,31 @@ func (c *DialysisAPIController) CreateConsumables() {
4107 4146
 
4108 4147
 						for _, it := range list {
4109 4148
 							prepare := models.DialysisBeforePrepare{
4110
-								UserOrgId:  it.OrgId,
4111
-								PatientId:  patient_id,
4112
-								RecordDate: it.RecordTime,
4113
-								GoodId:     it.GoodId,
4114
-								GoodTypeId: it.GoodTypeId,
4115
-								Count:      it.Count,
4116
-								Ctime:      time.Now().Unix(),
4117
-								Creater:    adminUser.AdminUser.Id,
4118
-								Status:     1,
4149
+								UserOrgId:    it.OrgId,
4150
+								PatientId:    patient_id,
4151
+								RecordDate:   it.RecordTime,
4152
+								GoodId:       it.GoodId,
4153
+								GoodTypeId:   it.GoodTypeId,
4154
+								Count:        it.Count,
4155
+								Ctime:        time.Now().Unix(),
4156
+								Creater:      adminUser.AdminUser.Id,
4157
+								Status:       1,
4158
+								StorehouseId: houseConfig.StorehouseOutInfo,
4119 4159
 							}
4120 4160
 							//删除准备表数据
4121 4161
 							service.DeleteDialysisBefor(adminUser.Org.Id, patient_id, record_time, item.GoodId, item.GoodTypeId)
4122 4162
 
4123 4163
 							service.CreateDialysisBeforePrepareOne(&prepare)
4124
-
4164
+							//查询默认仓库
4165
+							houseConfig, _ := service.GetAllStoreHouseConfig(adminUser.Org.Id)
4166
+							goodList, _ := service.GetGoodSumCountByStoreId(houseConfig.StorehouseInfo, item.GoodId, adminUser.Org.Id)
4167
+							var sum_count int64
4168
+							var sum_in_count int64
4169
+							for _, it := range goodList {
4170
+								sum_count += it.StockCount
4171
+								sum_in_count += it.WarehousingCount
4172
+							}
4173
+							service.UpdateGoodByGoodId(item.GoodId, sum_count, sum_in_count, adminUser.Org.Id)
4125 4174
 						}
4126 4175
 						if err != nil {
4127 4176
 							goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
@@ -4189,10 +4238,10 @@ func (c *DialysisAPIController) CreateStockOutInfo() {
4189 4238
 	consumables = RemoveRepeatedGood(consumables)
4190 4239
 
4191 4240
 	if record.IsOpen == 1 {
4192
-
4241
+		houseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
4193 4242
 		//查询是否有库存
4194 4243
 		for _, item := range consumables {
4195
-			warehouse, _ := service.FindFirstWarehousingInfoByStockTwo(item.GoodId, item.GoodTypeId)
4244
+			warehouse, _ := service.FindFirstWarehousingInfoByStockTwo(item.GoodId, item.GoodTypeId, houseConfig.StorehouseOutInfo)
4196 4245
 
4197 4246
 			if item.Count > warehouse.Count {
4198 4247
 				goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
@@ -4230,6 +4279,7 @@ func (c *DialysisAPIController) CreateStockOutInfo() {
4230 4279
 				Manufacturer:            0,
4231 4280
 				Type:                    1,
4232 4281
 				IsSys:                   1,
4282
+				StorehouseId:            houseConfig.StorehouseOutInfo,
4233 4283
 			}
4234 4284
 			err := service.AddSigleWarehouseOut(&warehouseOut)
4235 4285
 			if err != nil {
@@ -4248,19 +4298,30 @@ func (c *DialysisAPIController) CreateStockOutInfo() {
4248 4298
 				}
4249 4299
 				for _, item := range list {
4250 4300
 					prepare := models.DialysisBeforePrepare{
4251
-						UserOrgId:  adminInfo.Org.Id,
4252
-						PatientId:  patient_id,
4253
-						RecordDate: record_time,
4254
-						GoodId:     item.GoodId,
4255
-						GoodTypeId: item.GoodTypeId,
4256
-						Count:      item.Count,
4257
-						Creater:    adminInfo.AdminUser.Id,
4258
-						Status:     1,
4259
-						Ctime:      time.Now().Unix(),
4301
+						UserOrgId:    adminInfo.Org.Id,
4302
+						PatientId:    patient_id,
4303
+						RecordDate:   record_time,
4304
+						GoodId:       item.GoodId,
4305
+						GoodTypeId:   item.GoodTypeId,
4306
+						Count:        item.Count,
4307
+						Creater:      adminInfo.AdminUser.Id,
4308
+						Status:       1,
4309
+						Ctime:        time.Now().Unix(),
4310
+						StorehouseId: houseConfig.StorehouseOutInfo,
4260 4311
 					}
4261 4312
 					//清空准备表数据
4262 4313
 					service.DeleteDialysisBefor(adminInfo.Org.Id, patient_id, record_time, item.GoodId, item.GoodTypeId)
4263 4314
 					service.CreateDialysisBeforePrepareOne(&prepare)
4315
+					//查询默认仓库
4316
+					houseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
4317
+					goodList, _ := service.GetGoodSumCountByStoreId(houseConfig.StorehouseInfo, item.GoodId, adminInfo.Org.Id)
4318
+					var sum_count int64
4319
+					var sum_in_count int64
4320
+					for _, it := range goodList {
4321
+						sum_count += it.StockCount
4322
+						sum_in_count += it.WarehousingCount
4323
+					}
4324
+					service.UpdateGoodByGoodId(item.GoodId, sum_count, sum_in_count, adminInfo.Org.Id)
4264 4325
 				}
4265 4326
 			}
4266 4327
 			//
@@ -4276,20 +4337,34 @@ func (c *DialysisAPIController) CreateStockOutInfo() {
4276 4337
 				}
4277 4338
 				for _, item := range list {
4278 4339
 					prepare := models.DialysisBeforePrepare{
4279
-						UserOrgId:  adminInfo.Org.Id,
4280
-						PatientId:  patient_id,
4281
-						RecordDate: record_time,
4282
-						GoodId:     item.GoodId,
4283
-						GoodTypeId: item.GoodTypeId,
4284
-						Count:      item.Count,
4285
-						Creater:    adminInfo.AdminUser.Id,
4286
-						Status:     1,
4287
-						Ctime:      time.Now().Unix(),
4340
+						UserOrgId:    adminInfo.Org.Id,
4341
+						PatientId:    patient_id,
4342
+						RecordDate:   record_time,
4343
+						GoodId:       item.GoodId,
4344
+						GoodTypeId:   item.GoodTypeId,
4345
+						Count:        item.Count,
4346
+						Creater:      adminInfo.AdminUser.Id,
4347
+						Status:       1,
4348
+						Ctime:        time.Now().Unix(),
4349
+						StorehouseId: houseConfig.StorehouseOutInfo,
4288 4350
 					}
4289 4351
 
4290 4352
 					//清空准备表数据
4291 4353
 					err = service.DeleteDialysisBefor(adminInfo.Org.Id, patient_id, record_time, item.GoodId, item.GoodTypeId)
4292 4354
 					service.CreateDialysisBeforePrepareOne(&prepare)
4355
+					//清空准备表数据
4356
+					service.DeleteDialysisBefor(adminInfo.Org.Id, patient_id, record_time, item.GoodId, item.GoodTypeId)
4357
+					service.CreateDialysisBeforePrepareOne(&prepare)
4358
+					//查询默认仓库
4359
+					houseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
4360
+					goodList, _ := service.GetGoodSumCountByStoreId(houseConfig.StorehouseInfo, item.GoodId, adminInfo.Org.Id)
4361
+					var sum_count int64
4362
+					var sum_in_count int64
4363
+					for _, it := range goodList {
4364
+						sum_count += it.StockCount
4365
+						sum_in_count += it.WarehousingCount
4366
+					}
4367
+					service.UpdateGoodByGoodId(item.GoodId, sum_count, sum_in_count, adminInfo.Org.Id)
4293 4368
 
4294 4369
 				}
4295 4370
 			}
@@ -4331,7 +4406,7 @@ func (c *DialysisAPIController) EditConsumables() {
4331 4406
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4332 4407
 		return
4333 4408
 	}
4334
-
4409
+	houseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
4335 4410
 	var beforePrepares []*models.DialysisBeforePrepareGoods
4336 4411
 
4337 4412
 	var newBeforePrepares []*models.NewDialysisBeforePrepareGoods
@@ -4375,17 +4450,19 @@ func (c *DialysisAPIController) EditConsumables() {
4375 4450
 					fmt.Println(commdity_code)
4376 4451
 
4377 4452
 					prepareGoods := &models.DialysisBeforePrepareGoods{
4378
-						GoodTypeId: good_type_id,
4379
-						GoodId:     good_id,
4380
-						Count:      count,
4453
+						GoodTypeId:   good_type_id,
4454
+						GoodId:       good_id,
4455
+						Count:        count,
4456
+						StorehouseId: houseConfig.StorehouseOutInfo,
4381 4457
 					}
4382 4458
 
4383 4459
 					beforePrepares = append(beforePrepares, prepareGoods)
4384 4460
 
4385 4461
 					newPrepareGoods := &models.NewDialysisBeforePrepareGoods{
4386
-						GoodTypeId: good_type_id,
4387
-						GoodId:     good_id,
4388
-						Count:      count,
4462
+						GoodTypeId:   good_type_id,
4463
+						GoodId:       good_id,
4464
+						Count:        count,
4465
+						StorehouseId: houseConfig.StorehouseOutInfo,
4389 4466
 					}
4390 4467
 
4391 4468
 					newBeforePrepares = append(newBeforePrepares, newPrepareGoods)
@@ -4404,6 +4481,15 @@ func (c *DialysisAPIController) EditConsumables() {
4404 4481
 					if item.Count < goodInfo.Count {
4405 4482
 						//出库
4406 4483
 						err = ConsumablesDeliveryTotalSeven(adminInfo.Org.Id, patient_id, record_time, beforePrepares, adminInfo.AdminUser.Id, item.Count)
4484
+						houseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
4485
+						goodList, _ := service.GetGoodSumCountByStoreId(houseConfig.StorehouseOutInfo, item.GoodId, adminInfo.Org.Id)
4486
+						var sum_count int64
4487
+						var sum_in_count int64
4488
+						for _, it := range goodList {
4489
+							sum_count += it.StockCount
4490
+							sum_in_count += it.WarehousingCount
4491
+						}
4492
+						service.UpdateGoodByGoodId(item.GoodId, sum_count, sum_in_count, adminInfo.Org.Id)
4407 4493
 						break
4408 4494
 					}
4409 4495
 
@@ -4449,6 +4535,15 @@ func (c *DialysisAPIController) EditConsumables() {
4449 4535
 							return
4450 4536
 						} else {
4451 4537
 							err = ConsumablesDeliveryTotalSix(adminInfo.Org.Id, patient_id, record_time, beforePrepares, newBeforePrepares, adminInfo.AdminUser.Id)
4538
+							houseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
4539
+							goodList, _ := service.GetGoodSumCountByStoreId(houseConfig.StorehouseOutInfo, item.GoodId, adminInfo.Org.Id)
4540
+							var sum_count int64
4541
+							var sum_in_count int64
4542
+							for _, it := range goodList {
4543
+								sum_count += it.StockCount
4544
+								sum_in_count += it.WarehousingCount
4545
+							}
4546
+							service.UpdateGoodByGoodId(item.GoodId, sum_count, sum_in_count, adminInfo.Org.Id)
4452 4547
 							break
4453 4548
 						}
4454 4549
 					}
@@ -4459,20 +4554,31 @@ func (c *DialysisAPIController) EditConsumables() {
4459 4554
 
4460 4555
 				for _, it := range list {
4461 4556
 					prepare := models.DialysisBeforePrepare{
4462
-						UserOrgId:  it.OrgId,
4463
-						PatientId:  patient_id,
4464
-						RecordDate: it.RecordTime,
4465
-						GoodId:     it.GoodId,
4466
-						GoodTypeId: it.GoodTypeId,
4467
-						Count:      it.Count,
4468
-						Ctime:      time.Now().Unix(),
4469
-						Creater:    adminInfo.AdminUser.Id,
4470
-						Status:     1,
4557
+						UserOrgId:    it.OrgId,
4558
+						PatientId:    patient_id,
4559
+						RecordDate:   it.RecordTime,
4560
+						GoodId:       it.GoodId,
4561
+						GoodTypeId:   it.GoodTypeId,
4562
+						Count:        it.Count,
4563
+						Ctime:        time.Now().Unix(),
4564
+						Creater:      adminInfo.AdminUser.Id,
4565
+						Status:       1,
4566
+						StorehouseId: houseConfig.StorehouseOutInfo,
4471 4567
 					}
4472 4568
 					//删除准备表数据
4473 4569
 					service.DeleteDialysisBefor(adminInfo.Org.Id, patient_id, record_time, it.GoodId, it.GoodTypeId)
4474 4570
 
4475 4571
 					service.CreateDialysisBeforePrepareOne(&prepare)
4572
+					//查询默认仓库
4573
+					houseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
4574
+					goodList, _ := service.GetGoodSumCountByStoreId(houseConfig.StorehouseOutInfo, it.GoodId, adminInfo.Org.Id)
4575
+					var sum_count int64
4576
+					var sum_in_count int64
4577
+					for _, it := range goodList {
4578
+						sum_count += it.StockCount
4579
+						sum_in_count += it.WarehousingCount
4580
+					}
4581
+					service.UpdateGoodByGoodId(it.GoodId, sum_count, sum_in_count, adminInfo.Org.Id)
4476 4582
 
4477 4583
 					if err != nil {
4478 4584
 						goodObj, _ := service.GetGoodInformationByGoodId(it.GoodId)
@@ -4548,7 +4654,6 @@ func (c *DialysisAPIController) GetDialysisGoods() {
4548 4654
 				goodUser, _ := service.GetLastDialysisGoods(item.PatientId, adminUser.Org.Id, date.Unix())
4549 4655
 
4550 4656
 				lastGoodUserDetial, _ := service.GetLastDialysisBeforePrepare(item.PatientId, adminUser.Org.Id, date.Unix())
4551
-				fmt.Println("GOOD333232323223322332232332232323322323", lastGoodUserDetial)
4552 4657
 				item.LastAutomaticReduceDetail = goodUser
4553 4658
 				item.LastDialysisBeforePrepare = lastGoodUserDetial
4554 4659
 				item.Project = project
@@ -4689,6 +4794,7 @@ func (c *DialysisAPIController) CreateOtherStockOutInfo() {
4689 4794
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4690 4795
 		return
4691 4796
 	}
4797
+	houseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
4692 4798
 
4693 4799
 	var beforePrepares []*models.DialysisBeforePrepareGoods
4694 4800
 
@@ -4730,18 +4836,20 @@ func (c *DialysisAPIController) CreateOtherStockOutInfo() {
4730 4836
 				}
4731 4837
 				project_id := int64(items["project_id"].(float64))
4732 4838
 				prepare := &models.DialysisBeforePrepareGoods{
4733
-					GoodId:     good_id,
4734
-					GoodTypeId: good_type_id,
4735
-					Count:      count,
4736
-					ProjectId:  project_id,
4839
+					GoodId:       good_id,
4840
+					GoodTypeId:   good_type_id,
4841
+					Count:        count,
4842
+					ProjectId:    project_id,
4843
+					StorehouseId: houseConfig.StorehouseOutInfo,
4737 4844
 				}
4738 4845
 				beforePrepares = append(beforePrepares, prepare)
4739 4846
 
4740 4847
 				newPrepare := &models.NewDialysisBeforePrepareGoods{
4741
-					GoodId:     good_id,
4742
-					GoodTypeId: good_type_id,
4743
-					Count:      count,
4744
-					ProjectId:  project_id,
4848
+					GoodId:       good_id,
4849
+					GoodTypeId:   good_type_id,
4850
+					Count:        count,
4851
+					ProjectId:    project_id,
4852
+					StorehouseId: houseConfig.StorehouseOutInfo,
4745 4853
 				}
4746 4854
 				newBeforePrepares = append(newBeforePrepares, newPrepare)
4747 4855
 			}
@@ -4750,7 +4858,8 @@ func (c *DialysisAPIController) CreateOtherStockOutInfo() {
4750 4858
 	fmt.Println("前端数据9999999999999", beforePrepares)
4751 4859
 	//查询是否有库存
4752 4860
 	for _, item := range beforePrepares {
4753
-		warehouse, _ := service.FindFirstWarehousingInfoByStockTwo(item.GoodId, item.GoodTypeId)
4861
+		storeConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
4862
+		warehouse, _ := service.FindFirstWarehousingInfoByStockTwo(item.GoodId, item.GoodTypeId, storeConfig.StorehouseOutInfo)
4754 4863
 
4755 4864
 		if item.Count > warehouse.Count {
4756 4865
 			goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
@@ -4777,21 +4886,34 @@ func (c *DialysisAPIController) CreateOtherStockOutInfo() {
4777 4886
 
4778 4887
 	for _, item := range list {
4779 4888
 		prepare := models.DialysisBeforePrepare{
4780
-			UserOrgId:  item.OrgId,
4781
-			PatientId:  item.PatientId,
4782
-			RecordDate: item.RecordTime,
4783
-			GoodId:     item.GoodId,
4784
-			GoodTypeId: item.GoodTypeId,
4785
-			Count:      item.Count,
4786
-			Creater:    adminInfo.AdminUser.Id,
4787
-			Status:     1,
4788
-			Ctime:      time.Now().Unix(),
4789
-			ProjectId:  item.ProjectId,
4889
+			UserOrgId:    item.OrgId,
4890
+			PatientId:    item.PatientId,
4891
+			RecordDate:   item.RecordTime,
4892
+			GoodId:       item.GoodId,
4893
+			GoodTypeId:   item.GoodTypeId,
4894
+			Count:        item.Count,
4895
+			Creater:      adminInfo.AdminUser.Id,
4896
+			Status:       1,
4897
+			Ctime:        time.Now().Unix(),
4898
+			ProjectId:    item.ProjectId,
4899
+			StorehouseId: houseConfig.StorehouseOutInfo,
4790 4900
 		}
4791 4901
 		//清空准备表的数据
4792 4902
 		err = service.DeleteDialysisBefor(adminInfo.Org.Id, patient_id, record_time, item.GoodId, item.GoodTypeId)
4793 4903
 		//插入准备表数据
4794 4904
 		service.CreateDialysisBeforePrepareOne(&prepare)
4905
+
4906
+		//查询默认仓库
4907
+		houseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
4908
+		goodList, _ := service.GetGoodSumCountByStoreId(houseConfig.StorehouseInfo, item.ProjectId, adminInfo.Org.Id)
4909
+		var sum_count int64
4910
+		var sum_in_count int64
4911
+		for _, it := range goodList {
4912
+			sum_count += it.StockCount
4913
+			sum_in_count += it.WarehousingCount
4914
+		}
4915
+		service.UpdateGoodByGoodId(item.ProjectId, sum_count, sum_in_count, adminInfo.Org.Id)
4916
+
4795 4917
 	}
4796 4918
 
4797 4919
 	//更新自动出库的地方
@@ -5161,6 +5283,7 @@ func ConsumablesDeliveryDeleteFour(orgID int64, record_time int64, good_yc *mode
5161 5283
 
5162 5284
 	delete_count = warehouseOutInfos.Count - count
5163 5285
 
5286
+	houseConfig, _ := service.GetAllStoreHouseConfig(orgID)
5164 5287
 	fmt.Println("delete_count2323232", delete_count)
5165 5288
 	// 在出库记录表里记录退库详情
5166 5289
 	warehouseOutInfo := &models.WarehouseOutInfo{
@@ -5176,6 +5299,7 @@ func ConsumablesDeliveryDeleteFour(orgID int64, record_time int64, good_yc *mode
5176 5299
 		GoodId:                  good_yc.GoodId,
5177 5300
 		PatientId:               good_yc.PatientId,
5178 5301
 		ConsumableType:          2,
5302
+		StorehouseId:            houseConfig.StorehouseOutInfo,
5179 5303
 	}
5180 5304
 	warehouseOutInfo.Count = count
5181 5305
 
@@ -5191,7 +5315,7 @@ func ConsumablesDeliveryDeleteFour(orgID int64, record_time int64, good_yc *mode
5191 5315
 	//查找当天是否存在出库记录
5192 5316
 
5193 5317
 	_, errcod := service.GetWarehouseOutInfoIsExistOne(good_yc.GoodId, good_yc.PatientId, record_time)
5194
-	fmt.Println("errcode2323223255556652324242424242424242424242424242242", errcod)
5318
+
5195 5319
 	if errcod == gorm.ErrRecordNotFound {
5196 5320
 		errOne := service.AddSigleWarehouseOutInfo(warehouseOutInfo)
5197 5321
 		//插入详情明细表
@@ -5218,12 +5342,13 @@ func ConsumablesDeliveryDeleteFour(orgID int64, record_time int64, good_yc *mode
5218 5342
 			IsSys:                   1,
5219 5343
 			UpdateCreator:           creater,
5220 5344
 			PatientId:               patient_id,
5345
+			StorehouseId:            houseConfig.StorehouseOutInfo,
5221 5346
 		}
5222 5347
 		exsit, errflow := service.GetStockFlowIsExsit(warehouseOutInfos.WarehouseInfotId, patient_id, record_time, good_yc.GoodId)
5223 5348
 		if errflow == gorm.ErrRecordNotFound {
5224 5349
 			//创建流水表
5225 5350
 			err := service.CreateStockFlowOne(stockFlow)
5226
-			fmt.Println("h2h3h2323342i24i242i4u2i4242u42424", err)
5351
+			fmt.Println("err", err)
5227 5352
 		} else if errflow == nil {
5228 5353
 			//插入详情明细表
5229 5354
 			stockFlow := models.VmStockFlow{
@@ -5251,6 +5376,7 @@ func ConsumablesDeliveryDeleteFour(orgID int64, record_time int64, good_yc *mode
5251 5376
 				IsSys:                   1,
5252 5377
 				UpdateCreator:           creater,
5253 5378
 				PatientId:               patient_id,
5379
+				StorehouseId:            houseConfig.StorehouseOutInfo,
5254 5380
 			}
5255 5381
 
5256 5382
 			service.UpdatedStockFlowOne(stockFlow, warehouseOut.ID, patient_id, record_time, good_yc.GoodId)
@@ -5287,6 +5413,7 @@ func ConsumablesDeliveryDeleteFour(orgID int64, record_time int64, good_yc *mode
5287 5413
 			UpdateCreator:           creater,
5288 5414
 			PatientId:               patient_id,
5289 5415
 			ReturnCount:             delete_count,
5416
+			StorehouseId:            houseConfig.StorehouseOutInfo,
5290 5417
 		}
5291 5418
 		exsit, errflows := service.GetStockFlowIsExsit(warehouseOutInfos.WarehouseInfotId, patient_id, record_time, good_yc.GoodId)
5292 5419
 		if errflows == gorm.ErrRecordNotFound {
@@ -5319,6 +5446,7 @@ func ConsumablesDeliveryDeleteFour(orgID int64, record_time int64, good_yc *mode
5319 5446
 				UpdateCreator:           creater,
5320 5447
 				PatientId:               patient_id,
5321 5448
 				ReturnCount:             delete_count,
5449
+				StorehouseId:            houseConfig.StorehouseOutInfo,
5322 5450
 			}
5323 5451
 			//service.UpdatedStockFlow(stockFlow)
5324 5452
 			service.UpdatedStockFlowOne(stockFlow, warehouseOut.ID, patient_id, record_time, good_yc.GoodId)
@@ -5339,6 +5467,7 @@ func ConsumablesDeliveryDeleteFour(orgID int64, record_time int64, good_yc *mode
5339 5467
 		GoodId:                  good_yc.GoodId,
5340 5468
 		GoodTypeId:              good_yc.GoodTypeId,
5341 5469
 		Count:                   count,
5470
+		StorehouseId:            houseConfig.StorehouseOutInfo,
5342 5471
 	}
5343 5472
 	//查询当天耗材是否已经存在数据
5344 5473
 	_, errcode := service.GetAutoMaticReduceDetail(orgID, patient_id, record_time, good_yc.GoodId, good_yc.GoodTypeId)
@@ -5412,6 +5541,7 @@ func ConsumablesDeliveryTotalSix(orgID int64, patient_id int64, record_time int6
5412 5541
 
5413 5542
 	if len(goods) > 0 {
5414 5543
 		out, err := service.FindStockOutByIsSys(orgID, 1, record_time)
5544
+		houseConfig, _ := service.GetAllStoreHouseConfig(orgID)
5415 5545
 		if err == gorm.ErrRecordNotFound {
5416 5546
 			//没有记录,则创建出库单
5417 5547
 			timeStr := time.Now().Format("2006-01-02")
@@ -5434,6 +5564,7 @@ func ConsumablesDeliveryTotalSix(orgID int64, patient_id int64, record_time int6
5434 5564
 				Manufacturer:            0,
5435 5565
 				Type:                    1,
5436 5566
 				IsSys:                   1,
5567
+				StorehouseId:            houseConfig.StorehouseOutInfo,
5437 5568
 			}
5438 5569
 			err := service.AddSigleWarehouseOut(&warehouseOut)
5439 5570
 			if err != nil {
@@ -5452,11 +5583,12 @@ func ConsumablesDeliveryTotalSix(orgID int64, patient_id int64, record_time int6
5452 5583
 				}
5453 5584
 			}
5454 5585
 			prepare := models.DialysisBeforePrepare{
5455
-				GoodTypeId: item.GoodTypeId,
5456
-				GoodId:     item.GoodId,
5457
-				Count:      item.Count,
5586
+				GoodTypeId:   item.GoodTypeId,
5587
+				GoodId:       item.GoodId,
5588
+				Count:        item.Count,
5589
+				StorehouseId: houseConfig.StorehouseOutInfo,
5458 5590
 			}
5459
-			fmt.Println("到这里了吗34344343434334343434", newCount)
5591
+
5460 5592
 			service.ConsumablesDelivery(orgID, patient_id, record_time, &prepare, &out, newCount)
5461 5593
 		}
5462 5594
 
@@ -5505,6 +5637,7 @@ func ConsumablesDeliveryDeleteThree(orgID int64, record_time int64, good_yc *mod
5505 5637
 			SysRecordTime:           record_time,
5506 5638
 			GoodTypeId:              good_yc.GoodTypeId,
5507 5639
 			GoodId:                  good_yc.GoodId,
5640
+			StorehouseId:            warehouseOut.StorehouseId,
5508 5641
 		}
5509 5642
 		warehouseOutInfo.Count = delete_count
5510 5643
 		stockInInfo, _ := service.FindLastStockInInfoRecord(good_yc.GoodId, orgID)

+ 54 - 3
controllers/mobile_api_controllers/patient_api_controller.go ファイルの表示

@@ -701,8 +701,9 @@ func (c *PatientApiController) ExecDoctorAdvice() {
701 701
 					var prescribing_number_total int64
702 702
 					for _, item := range advices {
703 703
 						if item.Way == 1 {
704
+							houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
704 705
 							//查询该药品的剩余库存
705
-							list, _ := service.GetDrugTotalCount(item.DrugId, item.UserOrgId)
706
+							list, _ := service.GetDrugTotalCount(item.DrugId, item.UserOrgId, houseConfig.DrugStorehouseOut)
706 707
 
707 708
 							//查询改药品信息
708 709
 							medical, _ := service.GetBaseDrugMedical(item.DrugId)
@@ -743,6 +744,22 @@ func (c *PatientApiController) ExecDoctorAdvice() {
743 744
 							if prescribing_number_total <= total {
744 745
 								if medical.IsUse == 2 {
745 746
 									service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
747
+									//查询默认仓库
748
+									houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
749
+									//查询默认仓库剩余多少库存
750
+									list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
751
+									var sum_count int64
752
+									var sum_in_count int64
753
+									for _, it := range list {
754
+										baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
755
+										if it.MaxUnit == baseDrug.MaxUnit {
756
+											it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
757
+											it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
758
+										}
759
+										sum_count += it.StockMaxNumber + it.StockMinNumber
760
+										sum_in_count += it.WarehousingCount
761
+									}
762
+									service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
746 763
 								}
747 764
 							}
748 765
 
@@ -772,8 +789,9 @@ func (c *PatientApiController) ExecDoctorAdvice() {
772 789
 					for _, item := range advices {
773 790
 
774 791
 						if item.Way == 1 {
792
+							houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
775 793
 							//查询该药品的剩余库存
776
-							list, _ := service.GetDrugTotalCount(item.DrugId, item.UserOrgId)
794
+							list, _ := service.GetDrugTotalCount(item.DrugId, item.UserOrgId, houseConfig.DrugStorehouseOut)
777 795
 
778 796
 							//查询改药品信息
779 797
 							medical, _ := service.GetBaseDrugMedical(item.DrugId)
@@ -818,6 +836,22 @@ func (c *PatientApiController) ExecDoctorAdvice() {
818 836
 							if prescribing_number_total <= total {
819 837
 								if medical.IsUse == 2 {
820 838
 									service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
839
+									//查询默认仓库
840
+									houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
841
+									//查询默认仓库剩余多少库存
842
+									list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
843
+									var sum_count int64
844
+									var sum_in_count int64
845
+									for _, it := range list {
846
+										baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
847
+										if it.MaxUnit == baseDrug.MaxUnit {
848
+											it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
849
+											it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
850
+										}
851
+										sum_count += it.StockMaxNumber + it.StockMinNumber
852
+										sum_in_count += it.WarehousingCount
853
+									}
854
+									service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
821 855
 									c.ServeSuccessJSON(map[string]interface{}{
822 856
 										"msg":    "1",
823 857
 										"advice": advice,
@@ -1059,7 +1093,8 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1059 1093
 					var total int64
1060 1094
 					var prescribing_number_total int64
1061 1095
 					//查询该药品是否有库存
1062
-					list, _ := service.GetDrugTotalCount(advice.DrugId, advice.UserOrgId)
1096
+					houseConfig, _ := service.GetAllStoreHouseConfig(advice.UserOrgId)
1097
+					list, _ := service.GetDrugTotalCount(advice.DrugId, advice.UserOrgId, houseConfig.DrugStorehouseOut)
1063 1098
 
1064 1099
 					//判断单位是否相等
1065 1100
 					if medical.MaxUnit == advice.PrescribingNumberUnit {
@@ -1099,6 +1134,22 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1099 1134
 					if prescribing_number_total <= total {
1100 1135
 						if medical.IsUse == 2 {
1101 1136
 							service.HisDrugsDelivery(adminInfo.Org.Id, creater, &advice)
1137
+							//查询默认仓库
1138
+							houseConfig, _ := service.GetAllStoreHouseConfig(medical.OrgId)
1139
+							//查询默认仓库剩余多少库存
1140
+							list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, medical.OrgId, medical.ID)
1141
+							var sum_count int64
1142
+							var sum_in_count int64
1143
+							for _, it := range list {
1144
+								baseDrug, _ := service.GetBaseDrugMedical(medical.ID)
1145
+								if it.MaxUnit == baseDrug.MaxUnit {
1146
+									it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
1147
+									it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
1148
+								}
1149
+								sum_count += it.StockMaxNumber + it.StockMinNumber
1150
+								sum_in_count += it.WarehousingCount
1151
+							}
1152
+							service.UpdateMedicalSumCount(medical.ID, sum_count, sum_in_count, medical.OrgId)
1102 1153
 						}
1103 1154
 					}
1104 1155
 				}

+ 48 - 7
controllers/patient_api_controller.go ファイルの表示

@@ -348,6 +348,7 @@ func (c *PatientApiController) CreatePatient() {
348 348
 		MemberTreatement:             0,
349 349
 		EquitmentId:                  "",
350 350
 		UserSysBeforeCount:           patient.UserSysBeforeCount,
351
+		TrobleShoot:                  patient.TrobleShoot,
351 352
 	}
352 353
 
353 354
 	err = service.CreatePatientsNew(&patientsNew)
@@ -562,6 +563,7 @@ func (c *PatientApiController) EditPatient() {
562 563
 		UpdatedTime:               time.Now().Unix(),
563 564
 		BloodPatients:             1,
564 565
 		Lapseto:                   patient.Lapseto,
566
+		TrobleShoot:               patient.TrobleShoot,
565 567
 	}
566 568
 	//	//更新病人ID获取新表病人ID
567 569
 	err = service.UpdatepatientTwo(&patientsNew, id)
@@ -1726,9 +1728,9 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1726 1728
 			var prescribing_number_total int64
1727 1729
 			advices, _ := service.GetExecutionDoctors(adminUserInfo.CurrentOrgId, patient, id)
1728 1730
 			for _, item := range advices {
1729
-
1731
+				houseConfig, _ := service.GetAllStoreHouseConfig(adminUserInfo.CurrentOrgId)
1730 1732
 				//查询该药品是否有库存
1731
-				list, _ := service.GetDrugTotalCount(item.DrugId, item.UserOrgId)
1733
+				list, _ := service.GetDrugTotalCountTwenty(item.DrugId, item.UserOrgId, houseConfig.DrugStorehouseOut)
1732 1734
 
1733 1735
 				//查询改药品信息
1734 1736
 				medical, _ := service.GetBaseDrugMedical(item.DrugId)
@@ -1747,9 +1749,6 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1747 1749
 					prescribing_number_total = count
1748 1750
 				}
1749 1751
 
1750
-				fmt.Println("数量一", prescribing_number_total)
1751
-				fmt.Println("数量二", total)
1752
-
1753 1752
 				if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
1754 1753
 					c.ServeSuccessJSON(map[string]interface{}{
1755 1754
 						"msg":    "3",
@@ -1767,6 +1766,22 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1767 1766
 				if prescribing_number_total <= total {
1768 1767
 					if medical.IsUse == 2 {
1769 1768
 						service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
1769
+						//查询默认仓库
1770
+						houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
1771
+						//查询默认仓库剩余多少库存
1772
+						list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
1773
+						var sum_count int64
1774
+						var sum_in_count int64
1775
+						for _, it := range list {
1776
+							baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
1777
+							if it.MaxUnit == baseDrug.MaxUnit {
1778
+								it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
1779
+								it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
1780
+							}
1781
+							sum_count += it.StockMaxNumber + it.StockMinNumber
1782
+							sum_in_count += it.WarehousingCount
1783
+						}
1784
+						service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
1770 1785
 						break
1771 1786
 						c.ServeSuccessJSON(map[string]interface{}{
1772 1787
 							"msg":    "1",
@@ -1990,8 +2005,12 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1990 2005
 
1991 2006
 				var total int64
1992 2007
 				var prescribing_number_total int64
1993
-				//查询该药品是否有库存
1994
-				list, _ := service.GetDrugTotalCount(advice.DrugId, advice.UserOrgId)
2008
+
2009
+				//查询默认出库仓库
2010
+				houseConfig, _ := service.GetAllStoreHouseConfig(advice.UserOrgId)
2011
+
2012
+				//查询该药品在默认仓库是否有库存
2013
+				list, _ := service.GetDrugTotalCountTwenty(advice.DrugId, advice.UserOrgId, houseConfig.DrugStorehouseOut)
1995 2014
 
1996 2015
 				//判断单位是否相等
1997 2016
 				if medical.MaxUnit == advice.PrescribingNumberUnit {
@@ -2028,6 +2047,23 @@ func (c *PatientApiController) ExecDoctorAdvice() {
2028 2047
 				if prescribing_number_total <= total {
2029 2048
 					if medical.IsUse == 2 {
2030 2049
 						service.HisDrugsDelivery(adminUserInfo.CurrentOrgId, item.ExecutionStaff, item)
2050
+
2051
+						//查询默认仓库
2052
+						houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
2053
+						//查询默认仓库剩余多少库存
2054
+						list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
2055
+						var sum_count int64
2056
+						var sum_in_count int64
2057
+						for _, it := range list {
2058
+							baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
2059
+							if it.MaxUnit == baseDrug.MaxUnit {
2060
+								it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
2061
+								it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
2062
+							}
2063
+							sum_count += it.StockMaxNumber + it.StockMinNumber
2064
+							sum_in_count += it.WarehousingCount
2065
+						}
2066
+						service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
2031 2067
 						break
2032 2068
 						c.ServeSuccessJSON(map[string]interface{}{
2033 2069
 							"msg":    "1",
@@ -4076,6 +4112,11 @@ func patientFormData(patient *models.Patients, data []byte, method string) (cont
4076 4112
 		patient.ContactName = contact_name
4077 4113
 	}
4078 4114
 
4115
+	if patientBody["troble_shoot"] != nil && reflect.TypeOf(patientBody["troble_shoot"]).String() == "float64" {
4116
+		troble_shoot := int64(patientBody["troble_shoot"].(float64))
4117
+		patient.TrobleShoot = troble_shoot
4118
+	}
4119
+
4079 4120
 	return
4080 4121
 
4081 4122
 }

File diff suppressed because it is too large
+ 2026 - 0
controllers/secondary_order_api_contorller.go


+ 75 - 19
controllers/self_drug_api_congtroller.go ファイルの表示

@@ -950,8 +950,9 @@ func (this *SelfDrugApiController) GetSelfStockQuery() {
950 950
 func (this *SelfDrugApiController) PostSearchDrugWarehouseList() {
951 951
 
952 952
 	keyword := this.GetString("keyword")
953
+	storehouse_id, _ := this.GetInt64("storehouse_id")
953 954
 	orgId := this.GetAdminUserInfo().CurrentOrgId
954
-	list, err := service.PostSearchDrugWarehouseList(keyword, orgId)
955
+	list, err := service.PostSearchDrugWarehouseList(keyword, orgId, storehouse_id)
955 956
 	manufacturerList, err := service.GetAllManufacturerList(orgId)
956 957
 	dealerList, err := service.GetAllDealerList(orgId)
957 958
 	if err != nil {
@@ -1433,6 +1434,7 @@ func (this *SelfDrugApiController) GetDrugDamageList() {
1433 1434
 
1434 1435
 	start_time := this.GetString("start_time")
1435 1436
 	end_time := this.GetString("end_time")
1437
+	storehouse_id, _ := this.GetInt64("storehouse_id")
1436 1438
 	var startTime int64
1437 1439
 	if len(start_time) > 0 {
1438 1440
 		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
@@ -1456,10 +1458,12 @@ func (this *SelfDrugApiController) GetDrugDamageList() {
1456 1458
 	limit, _ := this.GetInt64("limit")
1457 1459
 	page, _ := this.GetInt64("page")
1458 1460
 
1459
-	list, total, err := service.GetDrugDamageList(startTime, endTime, orgId, keyword, limit, page)
1461
+	list, total, err := service.GetDrugDamageList(startTime, endTime, orgId, keyword, limit, page, storehouse_id)
1460 1462
 
1461 1463
 	damagelist, _ := service.GetDrugDamageByOrgId(orgId)
1462 1464
 	doctorList, err := service.GetAllDoctorThree(orgId)
1465
+
1466
+	houseList, _ := service.GetAllStoreHouseList(orgId)
1463 1467
 	if err != nil {
1464 1468
 		this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
1465 1469
 		return
@@ -1470,6 +1474,7 @@ func (this *SelfDrugApiController) GetDrugDamageList() {
1470 1474
 		"list":       list,
1471 1475
 		"damagelist": damagelist,
1472 1476
 		"doctorList": doctorList,
1477
+		"houseList":  houseList,
1473 1478
 	})
1474 1479
 }
1475 1480
 
@@ -1735,7 +1740,8 @@ func (this *SelfDrugApiController) GetDrugDamagePrint() {
1735 1740
 func (this *SelfDrugApiController) GetWarehoseInfoById() {
1736 1741
 
1737 1742
 	id, _ := this.GetInt64("id")
1738
-	list, _ := service.GetWarehoseInfoById(id)
1743
+	storehouse_id, _ := this.GetInt64("storehouse_id")
1744
+	list, _ := service.GetWarehoseInfoById(id, storehouse_id)
1739 1745
 
1740 1746
 	this.ServeSuccessJSON(map[string]interface{}{
1741 1747
 		"list": list,
@@ -1975,17 +1981,21 @@ func (this *SelfDrugApiController) GetDrugInventoryList() {
1975 1981
 	limit, _ := this.GetInt64("limit")
1976 1982
 	page, _ := this.GetInt64("page")
1977 1983
 	list, total, err := service.GetDrugInventoryList(keyword, page, limit, orgId, startTime, endTime)
1978
-	fmt.Println("list23232323223", list)
1984
+
1979 1985
 	doctorList, _ := service.GetAllDoctorThree(orgId)
1986
+	houseList, _ := service.GetAllStoreHouseList(orgId)
1987
+	houseConfig, _ := service.GetAllStoreHouseConfig(orgId)
1980 1988
 	if err != nil {
1981 1989
 		this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
1982 1990
 		return
1983 1991
 	}
1984 1992
 
1985 1993
 	this.ServeSuccessJSON(map[string]interface{}{
1986
-		"total":      total,
1987
-		"list":       list,
1988
-		"doctorList": doctorList,
1994
+		"total":       total,
1995
+		"list":        list,
1996
+		"doctorList":  doctorList,
1997
+		"houseList":   houseList,
1998
+		"houseConfig": houseConfig,
1989 1999
 	})
1990 2000
 }
1991 2001
 
@@ -2342,9 +2352,11 @@ func (this *SelfDrugApiController) GetDrugInventoryDetailList() {
2342 2352
 	keyword := this.GetString("keyword")
2343 2353
 	limit, _ := this.GetInt64("limit")
2344 2354
 	page, _ := this.GetInt64("page")
2355
+	storehouse_id, _ := this.GetInt64("storehouse_id")
2345 2356
 	orgId := this.GetAdminUserInfo().CurrentOrgId
2346
-	list, total, err := service.GetDrugInventoryDetailList(keyword, page, limit, orgId)
2347
-	fmt.Println("list23232323223", list)
2357
+	list, total, err := service.GetDrugInventoryDetailList(keyword, page, limit, orgId, storehouse_id)
2358
+
2359
+	houseList, _ := service.GetAllStoreHouseList(orgId)
2348 2360
 	doctorList, _ := service.GetAllDoctorThree(orgId)
2349 2361
 	if err != nil {
2350 2362
 		this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
@@ -2355,6 +2367,7 @@ func (this *SelfDrugApiController) GetDrugInventoryDetailList() {
2355 2367
 		"total":      total,
2356 2368
 		"list":       list,
2357 2369
 		"doctorList": doctorList,
2370
+		"houseList":  houseList,
2358 2371
 	})
2359 2372
 }
2360 2373
 
@@ -2472,6 +2485,8 @@ func (this *SelfDrugApiController) SaveInventoryList() {
2472 2485
 			expiry_date := int64(items["expiry_date"].(float64))
2473 2486
 
2474 2487
 			manufacturer := int64(items["manufacturer"].(float64))
2488
+
2489
+			storehouse_id := int64(items["storehouse_id"].(float64))
2475 2490
 			timeLayout := "2006-01-02"
2476 2491
 			loc, _ := time.LoadLocation("Local")
2477 2492
 			timeNow := time.Now().Format("2006-01-02")
@@ -2480,29 +2495,68 @@ func (this *SelfDrugApiController) SaveInventoryList() {
2480 2495
 			var consumable_count int64
2481 2496
 			var ord_total int64
2482 2497
 			var new_total int64
2498
+			var total int64
2483 2499
 			ord_total = stock_max_number*min_number + stock_min_number
2484 2500
 			new_total = last_stock_max_number*min_number + last_stock_min_number
2501
+			medical, _ := service.GetBaseDrugMedical(drug_id)
2502
+
2503
+			//改变库存
2504
+			info := models.DrugWarehouseInfo{
2505
+				DrugId:           drug_id,
2506
+				StockMaxNumber:   last_stock_max_number,
2507
+				StockMinNumber:   last_stock_min_number,
2508
+				WarehousingCount: last_stock_max_number,
2509
+				MaxUnit:          max_unit,
2510
+				MinUnit:          min_unit,
2511
+			}
2512
+			drugInfo, _ := service.GetCurrentWarehosueInfoOne(id)
2485 2513
 
2514
+			if drugInfo.MaxUnit == medical.MaxUnit {
2515
+				total = drugInfo.WarehousingCount * medical.MinNumber
2516
+			}
2517
+			if drugInfo.MaxUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
2518
+				total = drugInfo.WarehousingCount
2519
+			}
2520
+			//如果库存数据大于盘点数据,则减去数量
2486 2521
 			if ord_total > new_total {
2487 2522
 				consumable_type = 11
2488 2523
 				consumable_count = ord_total - new_total
2524
+
2525
+				err = service.ModifyDrugWarehouseInfo(&info, id)
2526
+
2489 2527
 			}
2490
-			if ord_total < new_total {
2528
+			//如果库存数据小于盘点数据,则增加数量
2529
+			if ord_total < new_total && new_total <= total {
2491 2530
 				consumable_type = 10
2492 2531
 				consumable_count = new_total - ord_total
2532
+				err = service.ModifyDrugWarehouseInfo(&info, id)
2533
+
2493 2534
 			}
2494
-			fmt.Println("ord_total", ord_total)
2495
-			fmt.Println("new_total23323232323223", new_total)
2496
-			fmt.Println("consumable_count", consumable_count)
2497 2535
 
2498
-			//改变库存
2499
-			info := models.DrugWarehouseInfo{
2500
-				DrugId:         drug_id,
2501
-				StockMaxNumber: last_stock_max_number,
2502
-				StockMinNumber: last_stock_min_number,
2536
+			if ord_total < new_total && new_total > total {
2537
+				consumable_type = 10
2538
+				consumable_count = new_total - ord_total
2539
+				err = service.ModifyDrugWarehouseInfoSix(&info, id)
2540
+
2541
+			}
2542
+
2543
+			//查询默认仓库
2544
+			houseConfig, _ := service.GetAllStoreHouseConfig(drugInfo.OrgId)
2545
+			//查询默认仓库剩余多少库存
2546
+			list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, drugInfo.OrgId, drugInfo.DrugId)
2547
+			var sum_count int64
2548
+			var sum_in_count int64
2549
+			for _, it := range list {
2550
+				baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
2551
+				if it.MaxUnit == baseDrug.MaxUnit {
2552
+					it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
2553
+					it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
2554
+				}
2555
+				sum_count += it.StockMaxNumber + it.StockMinNumber
2556
+				sum_in_count += it.WarehousingCount
2503 2557
 			}
2558
+			service.UpdateMedicalSumCount(drugInfo.DrugId, sum_count, sum_in_count, drugInfo.OrgId)
2504 2559
 
2505
-			err = service.ModifyDrugWarehouseInfo(&info, id)
2506 2560
 			inventory := models.XtDrugInventory{
2507 2561
 				DrugName:           drug_name,
2508 2562
 				SpecificationName:  specification_name,
@@ -2542,6 +2596,7 @@ func (this *SelfDrugApiController) SaveInventoryList() {
2542 2596
 				LastStockMinNumber: last_stock_min_number,
2543 2597
 				InventoryType:      consumable_type,
2544 2598
 				Type:               type_id,
2599
+				StorehouseId:       storehouse_id,
2545 2600
 			}
2546 2601
 
2547 2602
 			err = service.CreateDrugInventory(inventory)
@@ -2578,6 +2633,7 @@ func (this *SelfDrugApiController) SaveInventoryList() {
2578 2633
 				ProductDate:             0,
2579 2634
 				MaxUnit:                 min_unit,
2580 2635
 				MinUnit:                 min_unit,
2636
+				StorehouseId:            storehouse_id,
2581 2637
 			}
2582 2638
 			if ord_total != new_total {
2583 2639
 				service.CreateDrugFlowOne(flow)

+ 9 - 1
controllers/stock_good_api_controller.go ファイルの表示

@@ -174,9 +174,17 @@ func (c *StockGoodApiController) GetGoodType() {
174 174
 func (c *StockGoodApiController) GetAllGoodType() {
175 175
 	adminUserInfo := c.GetAdminUserInfo()
176 176
 	goodTypes, err := service.FindAllGoodType(adminUserInfo.CurrentOrgId)
177
+	houseList, _ := service.GetAllStoreHouseListTwo(adminUserInfo.CurrentOrgId)
178
+	storehouselist, _ := service.GetAllStoreHouseList(adminUserInfo.CurrentOrgId)
179
+	goodInfo, _ := service.FindAllGoodInfo(adminUserInfo.CurrentOrgId)
180
+	manufacturerList, _ := service.GetAllManufacturerList(adminUserInfo.CurrentOrgId)
177 181
 	if err == nil {
178 182
 		c.ServeSuccessJSON(map[string]interface{}{
179
-			"goodType": goodTypes,
183
+			"goodType":         goodTypes,
184
+			"houseList":        houseList,
185
+			"goodInfo":         goodInfo,
186
+			"manufacturerList": manufacturerList,
187
+			"storehouseList":   storehouselist,
180 188
 		})
181 189
 	} else {
182 190
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)

File diff suppressed because it is too large
+ 712 - 239
controllers/stock_in_api_controller.go


+ 91 - 30
controllers/supply_order_api_contorller.go ファイルの表示

@@ -2082,7 +2082,7 @@ func (this *SupplyOrderApiController) GetAllOrderCountList() {
2082 2082
 	purcaseOrder, _ := service.GetAllPurcaseOrderById(id, orgId)
2083 2083
 	//获取购货单的数据
2084 2084
 	goodOrder, err := service.GetAllGoodOrderByIdSix(id, orgId)
2085
-	fmt.Println("2323232332232323232332", goodOrder)
2085
+
2086 2086
 	drugList, err := service.GetSupplyDrugList(orgId)
2087 2087
 
2088 2088
 	if err == nil {
@@ -2195,6 +2195,7 @@ func (this *SupplyOrderApiController) GetGoodOrderCountList() {
2195 2195
 	//获取购货单的数据
2196 2196
 	goodOrder, _ := service.GetAllGoodOrderByIdTwo(id, orgId)
2197 2197
 
2198
+	houseConfig, _ := service.GetAllStoreHouseConfig(orgId)
2198 2199
 	//查询该购货单是否审核成功
2199 2200
 	detail, _ := service.GetGoodOrderDetail(id, orgId)
2200 2201
 	var warehousingInfo []*models.WarehousingInfo
@@ -2227,6 +2228,7 @@ func (this *SupplyOrderApiController) GetGoodOrderCountList() {
2227 2228
 						WarehousingTime:   record_date,
2228 2229
 						Type:              1,
2229 2230
 						SupplyWarehouseId: id,
2231
+						StorehouseId:      houseConfig.DrugStorehouseInfo,
2230 2232
 					}
2231 2233
 					//查询今日是否存在入库单号
2232 2234
 					//_, errcode := service.GetSingleDrugWarehouseOrder(record_date, orgId)
@@ -2260,6 +2262,7 @@ func (this *SupplyOrderApiController) GetGoodOrderCountList() {
2260 2262
 						RetailPrice:               item.MinPrice,
2261 2263
 						SupplyWarehouseId:         id,
2262 2264
 						SupplyWarehouseDetailInfo: item.ID,
2265
+						StorehouseId:              houseConfig.DrugStorehouseInfo,
2263 2266
 					}
2264 2267
 					if medical.MaxUnit == medical.MinUnit {
2265 2268
 						warehouseInfoDetailOne.StockMaxNumber = item.Count
@@ -2296,6 +2299,7 @@ func (this *SupplyOrderApiController) GetGoodOrderCountList() {
2296 2299
 						IsSys:                     0,
2297 2300
 						SupplyWarehouseId:         id,
2298 2301
 						SupplyWarehouseDetailInfo: item.ID,
2302
+						StorehouseId:              houseConfig.DrugStorehouseInfo,
2299 2303
 					}
2300 2304
 
2301 2305
 					if medical.MaxUnit == medical.MinUnit {
@@ -2328,6 +2332,7 @@ func (this *SupplyOrderApiController) GetGoodOrderCountList() {
2328 2332
 						WarehousingTime:   record_date,
2329 2333
 						Type:              1,
2330 2334
 						SupplyWarehouseId: id,
2335
+						StorehouseId:      houseConfig.StorehouseInfo,
2331 2336
 					}
2332 2337
 					//查询是否存在入库单
2333 2338
 					//_, errcose := service.GetSindleWarehouse(record_date, orgId)
@@ -2360,6 +2365,7 @@ func (this *SupplyOrderApiController) GetGoodOrderCountList() {
2360 2365
 						PackingPrice:              item.MinPrice,
2361 2366
 						SupplyWarehouseId:         id,
2362 2367
 						SupplyWarehouseDetailInfo: item.ID,
2368
+						StorehouseId:              houseConfig.StorehouseInfo,
2363 2369
 					}
2364 2370
 					warehousingInfo = append(warehousingInfo, warehouseInfo)
2365 2371
 				}
@@ -2369,7 +2375,18 @@ func (this *SupplyOrderApiController) GetGoodOrderCountList() {
2369 2375
 
2370 2376
 	for _, item := range warehousingInfo {
2371 2377
 		service.CreatedWarehouseingDetail(item)
2372
-		service.ModifyGoodAddInformation(item.GoodId, item.StockCount, item.OrgId)
2378
+		//查询该机构默认仓库
2379
+		storeConfig, _ := service.GetAllStoreHouseConfig(item.OrgId)
2380
+		//查询剩余库存
2381
+		goodList, _ := service.GetGoodSumCountByStoreId(storeConfig.StorehouseOutInfo, item.GoodId, item.OrgId)
2382
+		var sum_count int64
2383
+		var sum_in_count int64
2384
+		for _, item := range goodList {
2385
+			sum_count += item.StockCount
2386
+			sum_in_count += item.WarehousingCount
2387
+		}
2388
+		service.UpdateGoodByGoodId(item.GoodId, sum_count, sum_in_count, item.OrgId)
2389
+
2373 2390
 		warehousinginfo, _ := service.GetLastWarehousingInfo(item.GoodId)
2374 2391
 		flow := models.VmStockFlow{
2375 2392
 			WarehousingOrder:          item.WarehousingOrder,
@@ -2393,22 +2410,33 @@ func (this *SupplyOrderApiController) GetGoodOrderCountList() {
2393 2410
 			WarehousingDetailId:       warehousinginfo.ID,
2394 2411
 			SupplyWarehouseId:         id,
2395 2412
 			SupplyWarehouseDetailInfo: item.ID,
2413
+			StorehouseId:              houseConfig.StorehouseInfo,
2396 2414
 		}
2397 2415
 		service.CreateStockFlowOne(flow)
2398 2416
 	}
2399 2417
 	//创建入库单
2400 2418
 	errs := service.CreateDrugWarehousingInfoSix(warehouseInfoDetail)
2419
+
2401 2420
 	//改变入库状态
2402 2421
 	for _, items := range warehouseInfoDetail {
2403
-		medical, _ := service.GetBaseDrugMedical(items.DrugId)
2404
-		if items.MaxUnit == medical.MaxUnit {
2405
-			var sum_count int64
2406
-			sum_count = items.WarehousingCount * medical.MinNumber
2407
-			service.ModifyDrugAddInformation(items.DrugId, sum_count, items.OrgId)
2408
-		}
2409
-		if items.MaxUnit == medical.MinUnit {
2410
-			service.ModifyDrugAddInformation(items.DrugId, items.WarehousingCount, items.OrgId)
2422
+
2423
+		//查询默认仓库
2424
+		houseConfig, _ := service.GetAllStoreHouseConfig(items.OrgId)
2425
+		//查询默认仓库剩余多少库存
2426
+		list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, items.OrgId, items.DrugId)
2427
+		var sum_count int64
2428
+		var sum_in_count int64
2429
+		for _, it := range list {
2430
+			baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
2431
+			if it.MaxUnit == baseDrug.MaxUnit {
2432
+				it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
2433
+				it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
2434
+			}
2435
+			sum_count += it.StockMaxNumber + it.StockMinNumber
2436
+			sum_in_count += it.WarehousingCount
2411 2437
 		}
2438
+		service.UpdateMedicalSumCount(items.DrugId, sum_count, sum_in_count, items.OrgId)
2439
+
2412 2440
 	}
2413 2441
 	fmt.Println(errs)
2414 2442
 	for _, items := range drugFlow {
@@ -3177,16 +3205,28 @@ func (this *SupplyOrderApiController) ModefyGoodOrder() {
3177 3205
 		}
3178 3206
 
3179 3207
 		// 查询入库单
3180
-		drugInfo, _ := service.GetDrugSupplyWarehouseId(id, orgId)
3181
-		if drugInfo.StockMaxNumber > 0 {
3182
-			medical, _ := service.GetBaseDrugMedical(drugInfo.DrugId)
3183
-			var stock_count int64
3184
-			stock_count = drugInfo.StockMaxNumber * medical.MinNumber
3185
-			service.ModifyDrugReduceInformation(drugInfo.DrugId, stock_count, drugInfo.OrgId)
3186
-		}
3187
-		if drugInfo.StockMinNumber > 0 {
3188
-			service.ModifyDrugReduceInformation(drugInfo.DrugId, drugInfo.StockMinNumber, drugInfo.OrgId)
3208
+		drugInfo, _ := service.GetDrugSupplyWarehouseIdSeven(id, orgId)
3209
+		for _, item := range drugInfo {
3210
+
3211
+			//查询默认仓库
3212
+			houseConfig, _ := service.GetAllStoreHouseConfig(item.OrgId)
3213
+			//查询默认仓库剩余多少库存
3214
+			list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.OrgId, item.DrugId)
3215
+			var sum_count int64
3216
+			var sum_in_count int64
3217
+			for _, it := range list {
3218
+				baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
3219
+				if it.MaxUnit == baseDrug.MaxUnit {
3220
+					it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
3221
+					it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
3222
+
3223
+				}
3224
+				sum_count += it.StockMaxNumber + it.StockMinNumber
3225
+				sum_in_count += it.WarehousingCount
3226
+			}
3227
+			service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.OrgId)
3189 3228
 		}
3229
+
3190 3230
 		//删除药品入库单
3191 3231
 		service.UpdateDrugSupplyWarehousingInfo(id, orgId)
3192 3232
 
@@ -3194,9 +3234,22 @@ func (this *SupplyOrderApiController) ModefyGoodOrder() {
3194 3234
 		service.UpdateDrugSupplyFlow(id, orgId)
3195 3235
 
3196 3236
 		//查寻入库单
3197
-		info, _ := service.GetSupplySupplyWarehouseId(id, orgId)
3198
-		//扣减库存
3199
-		service.ModifyGoodReduceInformation(info.GoodId, info.StockCount, info.OrgId)
3237
+		info, _ := service.GetSupplySupplyWarehouseIdSeven(id, orgId)
3238
+		for _, item := range info {
3239
+			//扣减库存
3240
+			//查询该机构默认仓库
3241
+			storeConfig, _ := service.GetAllStoreHouseConfig(item.OrgId)
3242
+			//查询剩余库存
3243
+			goodList, _ := service.GetGoodSumCountByStoreId(storeConfig.StorehouseOutInfo, item.GoodId, item.OrgId)
3244
+			var sum_count int64
3245
+			var sum_in_count int64
3246
+			for _, item := range goodList {
3247
+				sum_count += item.StockCount
3248
+				sum_in_count += item.WarehousingCount
3249
+			}
3250
+			service.UpdateGoodByGoodId(item.GoodId, sum_count, sum_in_count, item.OrgId)
3251
+		}
3252
+
3200 3253
 		//删除耗材入库单
3201 3254
 		service.UpdateGoodSupplyWarehousingInfo(id, orgId)
3202 3255
 
@@ -3317,7 +3370,7 @@ func (this *SupplyOrderApiController) CheckReturnOrder() {
3317 3370
 	orgId := this.GetAdminUserInfo().CurrentOrgId
3318 3371
 	record_date := recordDate.Unix()
3319 3372
 	checker := this.GetAdminUserInfo().AdminUser.Id
3320
-
3373
+	houseConfig, _ := service.GetAllStoreHouseConfig(this.GetAdminUserInfo().CurrentOrgId)
3321 3374
 	//获取退库单详情
3322 3375
 	list, _ := service.GetSupplyCancelOrderDetail(id, orgId)
3323 3376
 	for _, item := range list {
@@ -3328,7 +3381,7 @@ func (this *SupplyOrderApiController) CheckReturnOrder() {
3328 3381
 		if item.IsSource == 1 {
3329 3382
 
3330 3383
 			//获取药品库存
3331
-			info, _ := service.GetDrugTotalCountTwenTy(item.ProjectId, item.SupplyWarehouseDetailInfo, item.Type)
3384
+			info, _ := service.GetDrugTotalCountTwenTy(item.ProjectId, item.SupplyWarehouseDetailInfo, item.Type, houseConfig.DrugStorehouseOut)
3332 3385
 
3333 3386
 			for _, it := range info {
3334 3387
 
@@ -3351,7 +3404,6 @@ func (this *SupplyOrderApiController) CheckReturnOrder() {
3351 3404
 				prescribing_number_total = item.SupplyCount
3352 3405
 			}
3353 3406
 
3354
-			fmt.Println("hhhhhadf dafsdfsdfddddfdf", prescribing_number_total)
3355 3407
 			//判断单位
3356 3408
 			if total_count == 0 {
3357 3409
 				goodObj, _ := service.GetDrugByGoodId(item.ProjectId)
@@ -3409,6 +3461,7 @@ func (this *SupplyOrderApiController) CheckReturnOrder() {
3409 3461
 				Type:                    1,
3410 3462
 				SupplyCancelOutId:       id,
3411 3463
 				SupplyWarehouseId:       warehouse_out_id,
3464
+				StorehouseId:            houseConfig.DrugStorehouseOut,
3412 3465
 			}
3413 3466
 			// 查询今日是否存在出库单
3414 3467
 			_, errcodes := service.GetDrugWarehouseOutById(orgId, record_date)
@@ -3444,6 +3497,7 @@ func (this *SupplyOrderApiController) CheckReturnOrder() {
3444 3497
 				SupplyWarehouseId:       warehouse_out_id,
3445 3498
 				SysRecordTime:           record_date,
3446 3499
 				IsSource:                item.Type,
3500
+				StorehouseId:            houseConfig.DrugStorehouseOut,
3447 3501
 			}
3448 3502
 
3449 3503
 			drup, _ := service.FindBaseDrugLibRecord(orgId, item.ProjectId)
@@ -3462,7 +3516,7 @@ func (this *SupplyOrderApiController) CheckReturnOrder() {
3462 3516
 		//耗材
3463 3517
 		if item.IsSource == 2 {
3464 3518
 			// 查询该耗材是否有库存
3465
-			warehouseOne, _ := service.FindWarehousingInfoTwenTy(item.ProjectId, item.SupplyWarehouseDetailInfo, item.Type)
3519
+			warehouseOne, _ := service.FindWarehousingInfoTwenTy(item.ProjectId, item.SupplyWarehouseDetailInfo, item.Type, houseConfig.StorehouseOutInfo)
3466 3520
 
3467 3521
 			// 如果出库数量大于该批次剩余库存数量
3468 3522
 			if item.SupplyCount > warehouseOne.StockCount {
@@ -3505,6 +3559,7 @@ func (this *SupplyOrderApiController) CheckReturnOrder() {
3505 3559
 				SupplyCancelOutId:       id,
3506 3560
 				SupplyWarehouseId:       warehouse_out_id,
3507 3561
 				IsSys:                   0,
3562
+				StorehouseId:            houseConfig.StorehouseOutInfo,
3508 3563
 			}
3509 3564
 			//查询是否生成出库单
3510 3565
 			_, errcodes := service.FindStockOutByIsSys(orgId, 0, record_date)
@@ -3512,7 +3567,7 @@ func (this *SupplyOrderApiController) CheckReturnOrder() {
3512 3567
 				service.AddSigleWarehouseOut(&warehouseOut)
3513 3568
 			}
3514 3569
 			outWarehouse, _ := service.GetlastWarehouseOutById(orgId, record_date)
3515
-			fmt.Println("232332322332232323", outWarehouse)
3570
+
3516 3571
 			goodObj, _ := service.GetGoodInformationByGoodId(item.ProjectId)
3517 3572
 			info := &models.WarehouseOutInfo{
3518 3573
 				WarehouseOutOrderNumber: outWarehouse.WarehouseOutOrderNumber,
@@ -3537,6 +3592,7 @@ func (this *SupplyOrderApiController) CheckReturnOrder() {
3537 3592
 				OrgId:                   orgId,
3538 3593
 				SupplyWarehouseId:       warehouse_out_id,
3539 3594
 				IsSource:                item.Type,
3595
+				StorehouseId:            houseConfig.StorehouseOutInfo,
3540 3596
 			}
3541 3597
 			//出库逻辑
3542 3598
 			parseDateErr := service.ConsumablesDeliveryNight(orgId, record_date, info, &warehouseOut, item.SupplyCount, creater, warehouse_out_id, id)
@@ -3554,7 +3610,7 @@ func (this *SupplyOrderApiController) CheckReturnOrder() {
3554 3610
 		CheckTime: record_date,
3555 3611
 	}
3556 3612
 	err := service.CheckReturnOrder(id, orgId, cancel)
3557
-	fmt.Println("3232233232322332232323232323322332232323232323")
3613
+
3558 3614
 	if err == nil {
3559 3615
 		this.ServeSuccessJSON(map[string]interface{}{
3560 3616
 			"msg":        "1",
@@ -3628,7 +3684,6 @@ func (this *SupplyOrderApiController) DeleteReturnOrderById() {
3628 3684
 func (this *SupplyOrderApiController) ModefyReturnOrder() {
3629 3685
 	id, _ := this.GetInt64("id")
3630 3686
 	err := service.ModefyReturnOrder(id)
3631
-
3632 3687
 	//获取退库单据日期
3633 3688
 	cancel, _ := service.GetReturnOrderById(id)
3634 3689
 	orgId := this.GetAdminUserInfo().CurrentOrgId
@@ -3646,7 +3701,11 @@ func (this *SupplyOrderApiController) ModefyReturnOrder() {
3646 3701
 					drugInfo := models.DrugWarehouseInfo{
3647 3702
 						StockMaxNumber: item.SupplyCount,
3648 3703
 					}
3704
+
3649 3705
 					service.UpdateDrugWasehousring(item.ProjectId, item.SupplyWarehouseDetailInfo, drugInfo)
3706
+					var sum_count int64
3707
+					sum_count = item.SupplyCount * base.MinNumber
3708
+					service.ModifyDrugAddInformation(item.ProjectId, sum_count, orgId)
3650 3709
 				}
3651 3710
 
3652 3711
 				if item.SupplyType == base.MinUnit && base.MaxUnit != base.MinUnit {
@@ -3654,6 +3713,7 @@ func (this *SupplyOrderApiController) ModefyReturnOrder() {
3654 3713
 						StockMinNumber: item.SupplyCount,
3655 3714
 					}
3656 3715
 					service.UpdateDrugWasehousringOne(item.ProjectId, item.SupplyWarehouseDetailInfo, drugInfo)
3716
+					service.ModifyDrugAddInformation(item.ProjectId, item.SupplyCount, orgId)
3657 3717
 				}
3658 3718
 
3659 3719
 				//删除流水
@@ -3668,7 +3728,7 @@ func (this *SupplyOrderApiController) ModefyReturnOrder() {
3668 3728
 			}
3669 3729
 			//耗材
3670 3730
 			if item.IsSource == 2 {
3671
-				fmt.Println("item2332322323232332", item.SupplyCount)
3731
+
3672 3732
 				//退库
3673 3733
 				info := models.WarehousingInfo{
3674 3734
 					StockCount: item.SupplyCount,
@@ -3676,6 +3736,7 @@ func (this *SupplyOrderApiController) ModefyReturnOrder() {
3676 3736
 
3677 3737
 				//更改库存
3678 3738
 				err := service.UpdateWarehousingInfoById(item.ProjectId, item.SupplyWarehouseDetailInfo, info)
3739
+				service.ModifyGoodAddInformation(item.ProjectId, item.SupplyCount, item.UserOrgId)
3679 3740
 				fmt.Println(err)
3680 3741
 				//删除出库记录
3681 3742
 				service.DeleteGoodWarehouseOut(item.ProjectId, item.WarehouseCancelId, orgId)

+ 3 - 0
models/dialysis.go ファイルの表示

@@ -1048,6 +1048,7 @@ type DialysisBeforePrepare struct {
1048 1048
 	NewCount     int64                    `gorm:"column:new_count" json:"new_count" form:"new_count"`
1049 1049
 	Children     []*DialysisBeforePrepare `gorm:"column:children" json:"children" form:"children"`
1050 1050
 	ProjectId    int64                    `gorm:"column:project_id" json:"project_id" form:"project_id"`
1051
+	StorehouseId int64                    `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
1051 1052
 }
1052 1053
 
1053 1054
 func (DialysisBeforePrepare) TableName() string {
@@ -1061,6 +1062,7 @@ type DialysisBeforePrepareGoods struct {
1061 1062
 	TypeName          string `gorm:"column:type_name" json:"type_name" form:"type_name"`
1062 1063
 	SpecificationName string `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
1063 1064
 	ProjectId         int64  `gorm:"column:project_id" json:"project_id" form:"project_id"`
1065
+	StorehouseId      int64  `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
1064 1066
 }
1065 1067
 
1066 1068
 type NewDialysisBeforePrepareGoods struct {
@@ -1071,6 +1073,7 @@ type NewDialysisBeforePrepareGoods struct {
1071 1073
 	SpecificationName string `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
1072 1074
 	NewCount          int64  `gorm:"column:new_count" json:"new_count" form:"new_count"`
1073 1075
 	ProjectId         int64  `gorm:"column:project_id" json:"project_id" form:"project_id"`
1076
+	StorehouseId      int64  `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
1074 1077
 }
1075 1078
 
1076 1079
 type QueueCallConfig struct {

+ 1 - 0
models/dialysis_parameter_models.go ファイルの表示

@@ -96,6 +96,7 @@ type BloodAutomaticReduceDetail struct {
96 96
 	GoodTypeId              int64  `gorm:"column:good_type_id" json:"good_type_id" form:"good_type_id"`
97 97
 	Count                   int64  `gorm:"column:count" json:"count" form:"count"`
98 98
 	ProjectId               int64  `gorm:"column:project_id" json:"project_id" form:"project_id"`
99
+	StorehouseId            int64  `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
99 100
 }
100 101
 
101 102
 func (BloodAutomaticReduceDetail) TableName() string {

+ 4 - 0
models/drug.go ファイルの表示

@@ -72,6 +72,9 @@ type BaseDrugLib struct {
72 72
 	PrescribingNumberUnit string                 `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
73 73
 	DrugWarehouseInfo     []*XtDrugWarehouseInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_warehouse_info"`
74 74
 	IsUse                 int64                  `gorm:"column:is_user" json:"is_user" form:"is_user"`
75
+	BatchRetaiPrice       float64                `gorm:"column:batch_retai_price" json:"batch_retai_price" form:"batch_retai_price"`
76
+	SumCount              int64                  `gorm:"column:sum_count" json:"sum_count" form:"sum_count"`
77
+	SumInCount            int64                  `gorm:"column:sum_in_count" json:"sum_in_count" form:"sum_in_count"`
75 78
 }
76 79
 
77 80
 func (BaseDrugLib) TableName() string {
@@ -84,6 +87,7 @@ type BaseDrugLibSeven struct {
84 87
 	MaxUnit   string `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
85 88
 	MinNumber int64  `gorm:"column:min_number" json:"min_number" form:"min_number"`
86 89
 	MinUnit   string `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
90
+	SumCount  int64  `gorm:"column:sum_count" json:"sum_count" form:"sum_count"`
87 91
 }
88 92
 
89 93
 func (BaseDrugLibSeven) TableName() string {

+ 17 - 0
models/drug_stock.go ファイルの表示

@@ -15,6 +15,9 @@ type DrugWarehouse struct {
15 15
 	Manufacturer      int64  `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
16 16
 	Type              int64  `gorm:"column:type" json:"type" form:"type"`
17 17
 	SupplyWarehouseId int64  `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
18
+	StorehouseId      int64  `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
19
+	SecondWarehouseId int64  `gorm:"column:second_warehouse_id" json:"second_warehouse_id" form:"second_warehouse_id"`
20
+	IsSys             int64  `gorm:"column:is_sys" json:"is_sys" form:"is_sys"`
18 21
 }
19 22
 
20 23
 func (DrugWarehouse) TableName() string {
@@ -81,6 +84,8 @@ type DrugWarehouseInfo struct {
81 84
 	WarehousingInfoId         int64   `gorm:"column:warehousing_info_id" json:"warehousing_info_id" form:"warehousing_info_id"`
82 85
 	SupplyWarehouseId         int64   `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
83 86
 	SupplyWarehouseDetailInfo int64   `gorm:"column:supply_warehouse_detail_info" json:"supply_warehouse_detail_info" form:"supply_warehouse_detail_info"`
87
+	StorehouseId              int64   `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
88
+	SecondWarehouseInfoId     int64   `gorm:"column:second_warehouse_info_id" json:"second_warehouse_info_id" form:"second_warehouse_info_id"`
84 89
 }
85 90
 
86 91
 func (DrugWarehouseInfo) TableName() string {
@@ -116,6 +121,8 @@ type DrugWarehouseOut struct {
116 121
 	Dealers                 *Dealer       `gorm:"ForeignKey:Dealer;AssociationForeignKey:ID" json:"dealers"`
117 122
 	SupplyCancelOutId       int64         `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
118 123
 	SupplyWarehouseId       int64         `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
124
+	StorehouseId            int64         `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
125
+	SecondWarehouseId       int64         `gorm:"column:second_warehouse_id" json:"second_warehouse_id" form:"second_warehouse_id"`
119 126
 }
120 127
 
121 128
 func (DrugWarehouseOut) TableName() string {
@@ -155,6 +162,9 @@ type DrugWarehouseOutInfo struct {
155 162
 	SupplyCancelOutId       int64   `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
156 163
 	SupplyWarehouseId       int64   `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
157 164
 	IsSource                int64   `gorm:"column:is_source" json:"is_source" form:"is_source"`
165
+	StorehouseId            int64   `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
166
+	SecondWarehouseInfoId   int64   `gorm:"column:second_warehouse_info_id" json:"second_warehouse_info_id" form:"second_warehouse_info_id"`
167
+	AdminUserId             int64   `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
158 168
 }
159 169
 
160 170
 func (DrugWarehouseOutInfo) TableName() string {
@@ -226,6 +236,7 @@ type DrugCancelStock struct {
226 236
 	Manufacturers       *Manufacturer          `gorm:"ForeignKey:Manufacturer;AssociationForeignKey:ID" json:"manufacturers"`
227 237
 	Dealers             *Dealer                `gorm:"ForeignKey:Dealer;AssociationForeignKey:ID" json:"dealers"`
228 238
 	DrugCancelStockInfo []*DrugCancelStockInfo `gorm:"ForeignKey:CancelStockId;AssociationForeignKey:ID" json:"drugCancelStockInfo"`
239
+	StorehouseId        int64                  `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
229 240
 }
230 241
 
231 242
 func (DrugCancelStock) TableName() string {
@@ -258,6 +269,7 @@ type DrugCancelStockInfo struct {
258 269
 	MaxUnit          string      `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
259 270
 	BaseDrugLib      BaseDrugLib `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" `
260 271
 	BatchNumberId    int64       `gorm:"column:batch_number_id" json:"batch_number_id" form:"batch_number_id"`
272
+	StorehouseId     int64       `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
261 273
 }
262 274
 
263 275
 func (DrugCancelStockInfo) TableName() string {
@@ -279,6 +291,7 @@ type DrugAutomaticReduceDetail struct {
279 291
 	CountUnit               string `gorm:"column:count_unit" json:"count_unit" form:"count_unit"`
280 292
 	WarehouseInfoId         int64  `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
281 293
 	AdviceId                int64  `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
294
+	StorehouseId            int64  `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
282 295
 }
283 296
 
284 297
 func (DrugAutomaticReduceDetail) TableName() string {
@@ -306,6 +319,7 @@ type VmDrugWarehouseInfo struct {
306 319
 	MinNumber                 int64  `gorm:"column:min_number" json:"min_number" form:"min_number"`
307 320
 	SupplyWarehouseId         int64  `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
308 321
 	SupplyWarehouseDetailInfo int64  `gorm:"column:supply_warehouse_detail_info" json:"supply_warehouse_detail_info" form:"supply_warehouse_detail_info"`
322
+	StorehouseId              int64  `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
309 323
 }
310 324
 
311 325
 type StDrugWarehouseOutInfo struct {
@@ -393,6 +407,9 @@ type DrugFlow struct {
393 407
 	SupplyWarehouseId         int64                `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
394 408
 	SupplyCancelOutId         int64                `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
395 409
 	SupplyWarehouseDetailInfo int64                `gorm:"column:supply_warehouse_detail_info" json:"supply_warehouse_detail_info" form:"supply_warehouse_detail_info"`
410
+	StorehouseId              int64                `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
411
+	SecondWarehouseInfoId     int64                `gorm:"column:second_warehouse_info_id" json:"second_warehouse_info_id" form:"second_warehouse_info_id"`
412
+	AdminUserId               int64                `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
396 413
 }
397 414
 
398 415
 func (DrugFlow) TableName() string {

+ 2 - 0
models/good_models.go ファイルの表示

@@ -88,6 +88,8 @@ type GoodInfo struct {
88 88
 	IsWarehouse                 int64                `gorm:"column:is_warehouse" json:"is_warehouse" form:"is_warehouse"`
89 89
 	SumCount                    int64                `gorm:"column:sum_count" json:"sum_count" form:"sum_count"`
90 90
 	BatchRetaiPrice             float64              `gorm:"column:batch_retai_price" json:"batch_retai_price" form:"batch_retai_price"`
91
+	SumInCount                  int64                `gorm:"column:sum_in_count" json:"sum_in_count" form:"sum_in_count"`
92
+	WarehousingInfo             []*WarehousingInfo   `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"warehouse_info"`
91 93
 }
92 94
 
93 95
 func (GoodInfo) TableName() string {

+ 2 - 0
models/patient_models.go ファイルの表示

@@ -186,6 +186,7 @@ type Patients struct {
186 186
 	SchRemark                string  `gorm:"column:sch_remark" json:"sch_remark" form:"sch_remark"`
187 187
 	OutReason                string  `gorm:"column:out_reason" json:"out_reason" form:"out_reason"`
188 188
 	DeathTime                int64   `gorm:"column:death_time" json:"death_time" form:"death_time"`
189
+	TrobleShoot              int64   `gorm:"column:troble_shoot" json:"troble_shoot" form:"troble_shoot"`
189 190
 	ContagionIds             []int64 `gorm:"-"`
190 191
 	DryWeight                float64 `gorm:"-"`
191 192
 }
@@ -741,6 +742,7 @@ type XtPatientsNew struct {
741 742
 	SchRemark                    string  `gorm:"column:sch_remark" json:"sch_remark" form:"sch_remark"`
742 743
 	OutReason                    string  `gorm:"column:out_reason" json:"out_reason" form:"out_reason"`
743 744
 	DeathTime                    int64   `gorm:"column:death_time" json:"death_time" form:"death_time"`
745
+	TrobleShoot                  int64   `gorm:"column:troble_shoot" json:"troble_shoot" form:"troble_shoot"`
744 746
 }
745 747
 
746 748
 func (XtPatientsNew) TableName() string {

+ 199 - 1
models/secondary_models.go ファイルの表示

@@ -1,5 +1,203 @@
1 1
 package models
2 2
 
3
-func main() {
3
+//二级仓库
4
+type Storehouse struct {
5
+	ID                int64  `gorm:"column:id" json:"id" form:"id"`
6
+	StorehouseCode    string `gorm:"column:storehouse_code" json:"storehouse_code" form:"storehouse_code"`             //仓库编号
7
+	StorehouseName    string `gorm:"column:storehouse_name" json:"storehouse_name" form:"storehouse_name"`             //仓库名称
8
+	StorehouseAddress string `gorm:"column:storehouse_address" json:"storehouse_address" form:"storehouse_address"`    //仓库地址
9
+	StorehouseStatus  int64  `gorm:"column:storehouse_status" json:"storehouse_status" form:"storehouse_status"`       //仓库状态
10
+	Status            int64  `gorm:"column:status" json:"status" form:"status"`                                        //数据状态
11
+	StorehouseAdminId int64  `gorm:"column:storehouse_admin_id" json:"storehouse_admin_id" form:"storehouse_admin_id"` //仓库管理员id
12
+	UserOrgId         int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
13
+	Ctime             int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
14
+	Mtime             int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
15
+}
16
+
17
+func (Storehouse) TableName() string {
18
+	return "xt_storehouse"
19
+}
20
+
21
+//仓库配置
22
+type StorehouseConfig struct {
23
+	ID                 int64 `gorm:"column:id" json:"id" form:"id"`
24
+	UserOrgId          int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`                         //机构id
25
+	StorehouseInfo     int64 `gorm:"column:storehouse_info" json:"storehouse_info" form:"storehouse_info"`             //耗材 自动入库 的仓库id
26
+	StorehouseOutInfo  int64 `gorm:"column:storehouse_out_info" json:"storehouse_out_info" form:"storehouse_out_info"` //耗材 自动出库 的仓库id
27
+	DrugStorehouseInfo int64 `gorm:"drug_storehouse_info" json:"drug_storehouse_info" form:"drug_storehouse_info"`     //药品 自动入库 的仓库id
28
+	DrugStorehouseOut  int64 `gorm:"drug_storehouse_out" json:"drug_storehouse_out" form:"drug_storehouse_out"`        //药品 自动出库 的仓库id
29
+	Status             int64 `gorm:"status" json:"status" form:"status"`
30
+	Ctime              int64 `gorm:"ctime" json:"ctime" form:"ctime"`
31
+	Mtime              int64 `gorm:"mtime" json:"mtime" form:"mtime"`
32
+}
33
+
34
+func (StorehouseConfig) TableName() string {
35
+	return "xt_storehouse_config"
36
+}
37
+
38
+type App_Role_byli struct {
39
+	Id          int64  `gorm:"PRIMARY_KEY;AUTO_INCREMENT" json:"id"`
40
+	OrgId       int64  `gorm:"column:org_id" json:"org_id"`
41
+	AdminUserId int64  `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
42
+	UserName    string `gorm:"column:user_name" json:"user_name"` // 用户名称
43
+}
44
+
45
+func (App_Role_byli) TableName() string {
46
+	return "sgj_users.sgj_user_admin_role"
47
+}
48
+
49
+type UserOrg struct {
50
+	Id      int64 `gorm:"PRIMARY_KEY;AUTO_INCREMENT" json:"id"`
51
+	Creator int64 `gorm:"column:creator" json:"creator"`
52
+}
53
+
54
+func (UserOrg) TableName() string {
55
+	return "sgj_users.sgj_user_org"
56
+}
57
+
58
+//分页
59
+type Storehouselist struct {
60
+	ID                  int64  `gorm:"column:id" json:"id" form:"id"`
61
+	StorehouseCode      string `gorm:"column:storehouse_code" json:"storehouse_code" form:"storehouse_code"`                 //仓库编号
62
+	StorehouseName      string `gorm:"column:storehouse_name" json:"storehouse_name" form:"storehouse_name"`                 //仓库名称
63
+	StorehouseAddress   string `gorm:"column:storehouse_address" json:"storehouse_address" form:"storehouse_address"`        //仓库地址
64
+	StorehouseStatus    int64  `gorm:"column:storehouse_status" json:"storehouse_status" form:"storehouse_status"`           //仓库状态
65
+	Status              int64  `gorm:"column:status" json:"status" form:"status"`                                            //数据状态
66
+	StorehouseAdminId   int64  `gorm:"column:storehouse_admin_id" json:"storehouse_admin_id" form:"storehouse_admin_id"`     //仓库管理员id
67
+	StorehouseAdminName string `gorm:"column:storehouse_admin_name" json:"storehouse_admin_name" form:"storehouse_admin_id"` //仓库管理员名字
68
+	UserOrgId           int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
69
+	Ctime               int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
70
+	Mtime               int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
71
+}
72
+
73
+type RolePurviews struct {
74
+	Id         int64 `gorm:"PRIMARY_KEY;AUTO_INCREMENT"`
75
+	RoleId     int64
76
+	OrgId      int64
77
+	AppId      int64
78
+	PurviewIds string `gorm:"column:purview_ids"`
79
+	Status     int8   // 状态 0.无效 1.有效 2.禁用
80
+	CreateTime int64  `gorm:"column:ctime"` // 创建时间
81
+	ModifyTime int64  `gorm:"column:mtime"` // 修改时间
82
+	Role       Role   `gorm:"ForeignKey:RoleId;AssociationForeignKey:ID" json:"role_info"`
83
+}
84
+
85
+func (RolePurviews) TableName() string {
86
+	return "sgj_users.sgj_user_role_purview"
87
+}
88
+
89
+type XtStorehouse struct {
90
+	ID                  int64  `gorm:"column:id" json:"id" form:"id"`
91
+	StorehouseCode      string `gorm:"column:storehouse_code" json:"storehouse_code" form:"storehouse_code"`
92
+	StorehouseName      string `gorm:"column:storehouse_name" json:"storehouse_name" form:"storehouse_name"`
93
+	StorehouseAddress   string `gorm:"column:storehouse_address" json:"storehouse_address" form:"storehouse_address"`
94
+	StorehouseStatus    int64  `gorm:"column:storehouse_status" json:"storehouse_status" form:"storehouse_status"`
95
+	Status              int64  `gorm:"column:status" json:"status" form:"status"`
96
+	StorehouseAdminId   int64  `gorm:"column:storehouse_admin_id" json:"storehouse_admin_id" form:"storehouse_admin_id"`
97
+	StorehouseAdminName string `gorm:"column:storehouse_admin_name" json:"storehouse_admin_name" form:"storehouse_admin_name"`
98
+	UserOrgId           int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
99
+	Ctime               int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
100
+	Mtime               int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
101
+}
102
+
103
+func (XtStorehouse) TableName() string {
104
+	return "xt_storehouse"
105
+}
106
+
107
+type VmStorehouseName struct {
108
+	ID               int64  `gorm:"column:id" json:"id" form:"id"`
109
+	StorehouseName   string `gorm:"column:storehouse_name" json:"storehouse_name" form:"storehouse_name"`
110
+	StorehouseId     int64  `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
111
+	StockMaxNumber   int64  `gorm:"column:stock_max_number" json:"stock_max_number" form:"stock_max_number"`
112
+	StockMinNumber   int64  `gorm:"column:stock_min_number" json:"stock_min_number" form:"stock_min_number"`
113
+	WarehousingCount int64  `gorm:"column:warehousing_count" json:"warehousing_count" form:"warehousing_count"`
114
+}
115
+
116
+type VmStorehouseNameOne struct {
117
+	ID               int64  `gorm:"column:id" json:"id" form:"id"`
118
+	StorehouseName   string `gorm:"column:storehouse_name" json:"storehouse_name" form:"storehouse_name"`
119
+	StorehouseId     int64  `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
120
+	StockCount       int64  `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
121
+	WarehousingCount int64  `gorm:"column:warehousing_count" json:"warehousing_count" form:"warehousing_count"`
122
+}
123
+
124
+type XtStorehouseConfig struct {
125
+	ID                 int64 `gorm:"column:id" json:"id" form:"id"`
126
+	UserOrgId          int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
127
+	StorehouseInfo     int64 `gorm:"column:storehouse_info" json:"storehouse_info" form:"storehouse_info"`
128
+	StorehouseOutInfo  int64 `gorm:"column:storehouse_out_info" json:"storehouse_out_info" form:"storehouse_out_info"`
129
+	DrugStorehouseInfo int64 `gorm:"column:drug_storehouse_info" json:"drug_storehouse_info" form:"drug_storehouse_info"`
130
+	DrugStorehouseOut  int64 `gorm:"column:drug_storehouse_out" json:"drug_storehouse_out" form:"drug_storehouse_out"`
131
+	Status             int64 `gorm:"column:status" json:"status" form:"status"`
132
+	Ctime              int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
133
+	Mtime              int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
134
+}
135
+
136
+func (XtStorehouseConfig) TableName() string {
137
+	return "xt_storehouse_config"
138
+}
139
+
140
+type XtSecondWarehouse struct {
141
+	ID                int64  `gorm:"column:id" json:"id" form:"id"`
142
+	SecondOrderNumber string `gorm:"column:second_order_number" json:"second_order_number" form:"second_order_number"`
143
+	Creater           int64  `gorm:"column:creater" json:"creater" form:"creater"`
144
+	RecordDate        int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
145
+	Checker           int64  `gorm:"column:checker" json:"checker" form:"checker"`
146
+	IsCheck           int64  `gorm:"column:is_check" json:"is_check" form:"is_check"`
147
+	UserOrgId         int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
148
+	Status            int64  `gorm:"column:status" json:"status" form:"status"`
149
+	Ctime             int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
150
+	Mtime             int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
151
+	CheckTime         int64  `gorm:"column:check_time" json:"check_time" form:"check_time"`
152
+	StorehouseInId    int64  `gorm:"column:storehouse_in_id" json:"storehouse_in_id" form:"storehouse_in_id"`
153
+	StorehouseOutId   int64  `gorm:"column:storehouse_out_id" json:"storehouse_out_id" form:"storehouse_out_id"`
154
+}
155
+
156
+func (XtSecondWarehouse) TableName() string {
157
+	return "xt_second_warehouse"
158
+}
159
+
160
+type XtSecondWarehouseInfo struct {
161
+	ID                      int64   `gorm:"column:id" json:"id" form:"id"`
162
+	ProjectName             string  `gorm:"column:project_name" json:"project_name" form:"project_name"`
163
+	SecondSpecificationName string  `gorm:"column:second_specification_name" json:"second_specification_name" form:"second_specification_name"`
164
+	ProjectType             string  `gorm:"column:project_type" json:"project_type" form:"project_type"`
165
+	SencondUnit             string  `gorm:"column:sencond_unit" json:"sencond_unit" form:"sencond_unit"`
166
+	Count                   int64   `gorm:"column:count" json:"count" form:"count"`
167
+	SecondTotal             string  `gorm:"column:second_total" json:"second_total" form:"second_total"`
168
+	SecondOrderNumber       string  `gorm:"column:second_order_number" json:"second_order_number" form:"second_order_number"`
169
+	RecordDate              int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
170
+	StorehouseInId          int64   `gorm:"column:storehouse_in_id" json:"storehouse_in_id" form:"storehouse_in_id"`
171
+	StorehouseOutId         int64   `gorm:"column:storehouse_out_id" json:"storehouse_out_id" form:"storehouse_out_id"`
172
+	Creater                 int64   `gorm:"column:creater" json:"creater" form:"creater"`
173
+	ProjectId               int64   `gorm:"column:project_id" json:"project_id" form:"project_id"`
174
+	Remake                  string  `gorm:"column:remake" json:"remake" form:"remake"`
175
+	UserOrgId               int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
176
+	Status                  int64   `gorm:"column:status" json:"status" form:"status"`
177
+	Ctime                   int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
178
+	Mtime                   int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
179
+	MinPrice                float64 `gorm:"column:min_price" json:"min_price" form:"min_price"`
180
+	IsSource                int64   `gorm:"column:is_source" json:"is_source" form:"is_source"`
181
+	WarehouseId             int64   `gorm:"column:warehouse_id" json:"warehouse_id" form:"warehouse_id"`
182
+}
183
+
184
+func (XtSecondWarehouseInfo) TableName() string {
185
+	return "xt_second_warehouse_info"
186
+}
4 187
 
188
+type VmSecondWarehouse struct {
189
+	ID                  int64  `gorm:"column:id" json:"id" form:"id"`
190
+	SecondOrderNumber   string `gorm:"column:second_order_number" json:"second_order_number" form:"second_order_number"`
191
+	Creater             int64  `gorm:"column:creater" json:"creater" form:"creater"`
192
+	RecordDate          int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
193
+	Checker             int64  `gorm:"column:checker" json:"checker" form:"checker"`
194
+	IsCheck             int64  `gorm:"column:is_check" json:"is_check" form:"is_check"`
195
+	UserOrgId           int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
196
+	Status              int64  `gorm:"column:status" json:"status" form:"status"`
197
+	Ctime               int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
198
+	Mtime               int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
199
+	CheckTime           int64  `gorm:"column:check_time" json:"check_time" form:"check_time"`
200
+	StorehouseInId      int64  `gorm:"column:storehouse_in_id" json:"storehouse_in_id" form:"storehouse_in_id"`
201
+	StorehouseOutId     int64  `gorm:"column:storehouse_out_id" json:"storehouse_out_id" form:"storehouse_out_id"`
202
+	StorehouseAdminName string `gorm:"column:storehouse_admin_name" json:"storehouse_admin_name" form:"storehouse_admin_name"`
5 203
 }

+ 11 - 0
models/self_drug_models.go ファイルの表示

@@ -357,6 +357,7 @@ type XtDrugWarehouseOutInfo struct {
357 357
 	Number                  string     `gorm:"column:number" json:"number" form:"number"`
358 358
 	BatchNumber             string     `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
359 359
 	XtBaseDrug              XtBaseDrug `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" `
360
+	StorehouseId            int64      `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
360 361
 }
361 362
 
362 363
 func (XtDrugWarehouseOutInfo) TableName() string {
@@ -414,6 +415,7 @@ type XtDrugWarehouseInfo struct {
414 415
 	XtBaseDrug                XtBaseDrug `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" `
415 416
 	SupplyWarehouseId         int64      `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
416 417
 	SupplyWarehouseDetailInfo int64      `gorm:"column:supply_warehouse_detail_info" json:"supply_warehouse_detail_info" form:"supply_warehouse_detail_info"`
418
+	StorehouseId              int64      `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
417 419
 }
418 420
 
419 421
 func (XtDrugWarehouseInfo) TableName() string {
@@ -480,6 +482,8 @@ type BloodDrugWarehouseInfo struct {
480 482
 	WarehouseingUnit string  `gorm:"column:warehouseing_unit" json:"warehouseing_unit" form:"warehouseing_unit"`
481 483
 	LastPrice        float64 `gorm:"column:last_price" json:"last_price" form:"last_price"`
482 484
 	DrugOriginPlace  string  `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
485
+	StorehouseId     int64   `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
486
+	CountUnit        string  `json:"count_unit"`
483 487
 }
484 488
 
485 489
 type BloodDrugCancelStockInfo struct {
@@ -512,6 +516,7 @@ type BloodDrugCancelStockInfo struct {
512 516
 	Dose             float64 `json:"dose"`
513 517
 	DoseUnit         string  `json:"dose_unit"`
514 518
 	Unit             string  `json:"unit"`
519
+	StorehouseId     int64   `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
515 520
 }
516 521
 
517 522
 type BloodDrugSalesReturnInfo struct {
@@ -547,6 +552,7 @@ type BloodDrugWarehouseOutInfo struct {
547 552
 	DrugId                  int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
548 553
 	WarehousingOutTarget    int64   `gorm:"column:warehousing_out_target" json:"warehousing_out_target" form:"warehousing_out_target"`
549 554
 	Count                   int64   `gorm:"column:count" json:"count" form:"count"`
555
+	CountUnit               string  `gorm:"column:count_unit" json:"count_unit" form:"count_unit"`
550 556
 	Price                   float64 `gorm:"column:price" json:"price" form:"price"`
551 557
 	TotalPrice              float64 `gorm:"column:total_price" json:"total_price" form:"total_price"`
552 558
 	ProductDate             int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
@@ -575,6 +581,7 @@ type BloodDrugWarehouseOutInfo struct {
575 581
 	Dose                    float64 `json:"dose"`
576 582
 	DoseUnit                string  `json:"dose_unit"`
577 583
 	LastPrice               float64 `json:"last_price"`
584
+	StorehouseId            int64   `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
578 585
 }
579 586
 
580 587
 type XtMonitorConfig struct {
@@ -679,6 +686,8 @@ type VmDrugWarehouseOutInfo struct {
679 686
 	Number                  string  `gorm:"column:number" json:"number" form:"number"`
680 687
 	WarehouseInfoId         int64   `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
681 688
 	MedicalInsuranceNumber  string  `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
689
+	StorehouseId            int64   `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
690
+	AdminUserId             int64   `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
682 691
 }
683 692
 
684 693
 type XtDrugAdjustPrice struct {
@@ -859,6 +868,7 @@ type XtDrugInventory struct {
859 868
 	LastStockMinNumber int64   `gorm:"column:last_stock_min_number" json:"last_stock_min_number" form:"last_stock_min_number"`
860 869
 	InventoryType      int64   `gorm:"column:inventory_type" json:"inventory_type" form:"inventory_type"`
861 870
 	Type               int64   `gorm:"column:type" json:"type" form:"type"`
871
+	StorehouseId       int64   `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
862 872
 }
863 873
 
864 874
 func (XtDrugInventory) TableName() string {
@@ -907,6 +917,7 @@ type VmDrugInventory struct {
907 917
 	StockMinNumber     int64              `gorm:"column:stock_min_number" json:"stock_min_number" form:"stock_min_number"`
908 918
 	WarehouseInfoId    int64              `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
909 919
 	Children           []*XtDrugInventory `gorm:"column:children" json:"children" form:"children"`
920
+	StorehouseId       int64              `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
910 921
 }
911 922
 
912 923
 type SgjDrugWarehouseOutInfo struct {

+ 157 - 27
models/stock_models.go ファイルの表示

@@ -65,6 +65,9 @@ type Warehousing struct {
65 65
 	Dealers           Dealer       `gorm:"ForeignKey:ID;AssociationForeignKey:Dealer" json:"Dealer"`
66 66
 	Type              int64        `gorm:"column:type" json:"type"`
67 67
 	SupplyWarehouseId int64        `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
68
+	StorehouseId      int64        `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
69
+	IsSys             int64        `gorm:"column:is_sys" json:"is_sys" form:"is_sys"`
70
+	SecondWarehouseId int64        `gorm:"column:second_warehouse_id" json:"second_warehouse_id" form:"second_warehouse_id"`
68 71
 }
69 72
 
70 73
 func (Warehousing) TableName() string {
@@ -72,33 +75,35 @@ func (Warehousing) TableName() string {
72 75
 }
73 76
 
74 77
 type StWarehousingInfo struct {
75
-	ID                int64   `gorm:"column:id" json:"id"`
76
-	WarehousingId     int64   `gorm:"column:warehousing_id" json:"warehousing_id"`
77
-	GoodId            int64   `gorm:"column:good_id" json:"good_id"`
78
-	GoodTypeId        int64   `gorm:"column:good_type_id" json:"good_type_id"`
79
-	Number            string  `gorm:"column:number" json:"number"`
80
-	ProductDate       int64   `gorm:"column:product_date" json:"product_date"`
81
-	ExpiryDate        int64   `gorm:"column:expiry_date" json:"expiry_date"`
82
-	WarehousingCount  int64   `gorm:"column:warehousing_count" json:"warehousing_count"`
83
-	WarehousingUnit   string  `gorm:"column:warehousing_unit" json:"warehousing_unit"`
84
-	Price             float64 `gorm:"column:price" json:"price"`
85
-	TotalPrice        float64 `gorm:"column:total_price" json:"total_price"`
86
-	Dealer            int64   `gorm:"column:dealer" json:"dealer"`
87
-	Manufacturer      int64   `gorm:"column:manufacturer" json:"manufacturer"`
88
-	Remark            string  `gorm:"column:remark" json:"remark"`
89
-	Ctime             int64   `gorm:"column:ctime" json:"ctime"`
90
-	Mtime             int64   `gorm:"column:mtime" json:"mtime"`
91
-	Status            int64   `gorm:"column:status" json:"status"`
92
-	OrgId             int64   `gorm:"column:org_id" json:"org_id"`
93
-	IsReturn          int64   `gorm:"column:is_return" json:"is_return"`
94
-	StockCount        int64   `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
95
-	WarehousingOrder  string  `gorm:"column:warehousing_order" json:"warehousing_order"`
96
-	Type              int64   `gorm:"column:type" json:"type"`
97
-	GoodName          string  `json:"good_name"`
98
-	PackingUnit       string  `json:"packing_unit"`
99
-	TotalCount        int64   `json:"total_count"`
100
-	SpecificationName string  `json:"specification_name"`
101
-	LicenseNumber     string  `gorm:"column:license_number" json:"license_number" form:"license_number"`
78
+	ID                    int64   `gorm:"column:id" json:"id"`
79
+	WarehousingId         int64   `gorm:"column:warehousing_id" json:"warehousing_id"`
80
+	GoodId                int64   `gorm:"column:good_id" json:"good_id"`
81
+	GoodTypeId            int64   `gorm:"column:good_type_id" json:"good_type_id"`
82
+	Number                string  `gorm:"column:number" json:"number"`
83
+	ProductDate           int64   `gorm:"column:product_date" json:"product_date"`
84
+	ExpiryDate            int64   `gorm:"column:expiry_date" json:"expiry_date"`
85
+	WarehousingCount      int64   `gorm:"column:warehousing_count" json:"warehousing_count"`
86
+	WarehousingUnit       string  `gorm:"column:warehousing_unit" json:"warehousing_unit"`
87
+	Price                 float64 `gorm:"column:price" json:"price"`
88
+	TotalPrice            float64 `gorm:"column:total_price" json:"total_price"`
89
+	Dealer                int64   `gorm:"column:dealer" json:"dealer"`
90
+	Manufacturer          int64   `gorm:"column:manufacturer" json:"manufacturer"`
91
+	Remark                string  `gorm:"column:remark" json:"remark"`
92
+	Ctime                 int64   `gorm:"column:ctime" json:"ctime"`
93
+	Mtime                 int64   `gorm:"column:mtime" json:"mtime"`
94
+	Status                int64   `gorm:"column:status" json:"status"`
95
+	OrgId                 int64   `gorm:"column:org_id" json:"org_id"`
96
+	IsReturn              int64   `gorm:"column:is_return" json:"is_return"`
97
+	StockCount            int64   `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
98
+	WarehousingOrder      string  `gorm:"column:warehousing_order" json:"warehousing_order"`
99
+	Type                  int64   `gorm:"column:type" json:"type"`
100
+	GoodName              string  `json:"good_name"`
101
+	PackingUnit           string  `json:"packing_unit"`
102
+	TotalCount            int64   `json:"total_count"`
103
+	SpecificationName     string  `json:"specification_name"`
104
+	LicenseNumber         string  `gorm:"column:license_number" json:"license_number" form:"license_number"`
105
+	StorehouseId          int64   `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
106
+	SecondWarehouseInfoId int64   `gorm:"column:second_warehouse_info_id" json:"second_warehouse_info_id" form:"second_warehouse_info_id"`
102 107
 }
103 108
 
104 109
 func (StWarehousingInfo) TableName() string {
@@ -135,6 +140,8 @@ type WarehousingInfo struct {
135 140
 	PackingPrice              float64     `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
136 141
 	SupplyWarehouseId         int64       `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
137 142
 	SupplyWarehouseDetailInfo int64       `gorm:"column:supply_warehouse_detail_info" json:"supply_warehouse_detail_info" form:"supply_warehouse_detail_info"`
143
+	StorehouseId              int64       `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
144
+	SecondWarehouseInfoId     int64       `gorm:"column:second_warehouse_info_id" json:"second_warehouse_info_id" form:"second_warehouse_info_id"`
138 145
 }
139 146
 
140 147
 func (WarehousingInfo) TableName() string {
@@ -181,6 +188,7 @@ type VmWarehousingInfo struct {
181 188
 	PackingUnit       string      `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
182 189
 	Count             int64       `gorm:json:"count"`
183 190
 	PackingPrice      float64     `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
191
+	StorehouseId      int64       `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
184 192
 }
185 193
 
186 194
 type WarehouseOut struct {
@@ -203,6 +211,8 @@ type WarehouseOut struct {
203 211
 	IsSys                   int64        `gorm:"column:is_sys" json:"is_sys"`
204 212
 	SupplyCancelOutId       int64        `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
205 213
 	SupplyWarehouseId       int64        `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
214
+	StorehouseId            int64        `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
215
+	SecondWarehouseId       int64        `gorm:"column:second_warehouse_id" json:"second_warehouse_id" form:"second_warehouse_id"`
206 216
 }
207 217
 
208 218
 func (WarehouseOut) TableName() string {
@@ -243,6 +253,9 @@ type WarehouseOutInfo struct {
243 253
 	SupplyCancelOutId       int64        `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
244 254
 	SupplyWarehouseId       int64        `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
245 255
 	IsSource                int64        `gorm:"column:is_source" json:"is_source" form:"is_source"`
256
+	StorehouseId            int64        `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
257
+	SecondWarehouseInfoId   int64        `gorm:"column:second_warehouse_info_id" json:"second_warehouse_info_id" form:"second_warehouse_info_id"`
258
+	AdminUserId             int64        `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
246 259
 }
247 260
 
248 261
 func (WarehouseOutInfo) TableName() string {
@@ -259,6 +272,7 @@ type WarehouseOutInfoNight struct {
259 272
 	WarehouseInfotId int64 `gorm:"column:warehouse_info_id" json:"warehouse_info_id"`
260 273
 	IsSys            int64 `gorm:"column:is_sys" json:"is_sys"`
261 274
 	Status           int64 `gorm:"column:status" json:"status"`
275
+	OrgId            int64 `gorm:"column:org_id" json:"org_id"`
262 276
 }
263 277
 
264 278
 func (WarehouseOutInfoNight) TableName() string {
@@ -341,6 +355,7 @@ type CancelStock struct {
341 355
 	Manufacturer      int64                `gorm:"column:manufacturer" json:"manufacturer"`
342 356
 	Type              int64                `gorm:"column:type" json:"type"`
343 357
 	XtCancelStockInfo []*XtCancelStockInfo `gorm:"ForeignKey:CancelStockId;AssociationForeignKey:ID" json:"XtCancelStockInfo"`
358
+	StorehouseId      int64                `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
344 359
 }
345 360
 
346 361
 func (CancelStock) TableName() string {
@@ -409,6 +424,7 @@ type AutomaticReduceDetail struct {
409 424
 	Type                    int64               `gorm:"column:type" json:"type"`
410 425
 	WarehouseOutInfo        []*WarehouseOutInfo `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"warehouseOutInfo"`
411 426
 	ProjectId               int64               `gorm:"column:project_id" json:"project_id" form:"project_id"`
427
+	StorehouseId            int64               `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
412 428
 }
413 429
 
414 430
 func (AutomaticReduceDetail) TableName() string {
@@ -487,6 +503,8 @@ type WarehouseOutInfoOne struct {
487 503
 	SocialSecurityDirectoryCode string  `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
488 504
 	SupplyCancelOutId           int64   `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
489 505
 	SupplyWarehouseId           int64   `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
506
+	StorehouseId                int64   `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
507
+	AdminUserId                 int64   `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
490 508
 }
491 509
 
492 510
 type WarehouseOutInfoTwo struct {
@@ -596,6 +614,9 @@ type VmStockFlow struct {
596 614
 	SupplyWarehouseId         int64   `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
597 615
 	SupplyCancelOutId         int64   `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
598 616
 	SupplyWarehouseDetailInfo int64   `gorm:"column:supply_warehouse_detail_info" json:"supply_warehouse_detail_info" form:"supply_warehouse_detail_info"`
617
+	StorehouseId              int64   `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
618
+	SecondWarehouseInfoId     int64   `gorm:"column:second_warehouse_info_id" json:"second_warehouse_info_id" form:"second_warehouse_info_id"`
619
+	AdminUserId               int64   `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
599 620
 }
600 621
 
601 622
 func (VmStockFlow) TableName() string {
@@ -629,6 +650,7 @@ type CancelStockInfo struct {
629 650
 	WarehousingInfo []*WarehousingInfo `gorm:"ForeignKey:GoodId;AssociationForeignKey:GoodId" json:"xt_warehouse_info"`
630 651
 	PatientId       int64              `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
631 652
 	RecordDate      int64              `gorm:"column:record_date" json:"record_date" form:"record_date"`
653
+	StorehouseId    int64              `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
632 654
 }
633 655
 
634 656
 func (CancelStockInfo) TableName() string {
@@ -705,6 +727,7 @@ type VmBaseDrug struct {
705 727
 	Total                       float64                   `gorm:"column:total" json:"total" form:"total"`
706 728
 	PrescribingNumberUnit       string                    `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
707 729
 	DrugWarehouseInfo           []*VsDrugWarehouseInfo    `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_warehouse_info"`
730
+	DrugWarehouse               []*DrugWarehouseInfo      `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_warehouse"`
708 731
 	DrugCancelStockInfo         []*VsDrugCancelStockInfo  `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_cancel_stock_info"`
709 732
 	DrugWarehouseOutInfo        []*VsDrugWarehouseOutInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_warehouse_out"`
710 733
 }
@@ -741,6 +764,7 @@ type VsDrugWarehouseInfo struct {
741 764
 	RetailPrice      float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
742 765
 	RetailTotalPrice float64 `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
743 766
 	BatchNumber      string  `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
767
+	StorehouseId     int64   `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
744 768
 }
745 769
 
746 770
 func (VsDrugWarehouseInfo) TableName() string {
@@ -858,6 +882,7 @@ type BloodWarehouseInfo struct {
858 882
 	SpecificationName string  `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
859 883
 	PackingUnit       string  `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
860 884
 	BuyPrice          float64 `gorm:"column:buy_price" json:"buy_price" form:"buy_price"`
885
+	StorehouseId      int64   `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
861 886
 }
862 887
 
863 888
 type XtStockAdjustPrice struct {
@@ -1048,6 +1073,7 @@ type XtStockInventory struct {
1048 1073
 	InventoryType     int64   `gorm:"column:inventory_type" json:"inventory_type" form:"inventory_type"`
1049 1074
 	LastStockCount    int64   `gorm:"column:last_stock_count" json:"last_stock_count" form:"last_stock_count"`
1050 1075
 	StockCount        int64   `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
1076
+	StorehouseId      int64   `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
1051 1077
 }
1052 1078
 
1053 1079
 func (XtStockInventory) TableName() string {
@@ -1088,6 +1114,7 @@ type VmStockInventory struct {
1088 1114
 	InventoryType     int64   `gorm:"column:inventory_type" json:"inventory_type" form:"inventory_type"`
1089 1115
 	LastStockCount    int64   `gorm:"column:last_stock_count" json:"last_stock_count" form:"last_stock_count"`
1090 1116
 	StockCount        int64   `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
1117
+	StorehouseId      int64   `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
1091 1118
 }
1092 1119
 
1093 1120
 type XtStockCorrectRecord struct {
@@ -1202,3 +1229,106 @@ type PatientWarehouseInfo struct {
1202 1229
 func (PatientWarehouseInfo) TableName() string {
1203 1230
 	return "xt_warehouse_info"
1204 1231
 }
1232
+
1233
+type BloodHisDoctorAdviceInfo struct {
1234
+	ID                    int64                       `gorm:"column:id" json:"id" form:"id"`
1235
+	UserOrgId             int64                       `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1236
+	PatientId             int64                       `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1237
+	HisPatientId          int64                       `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
1238
+	AdviceType            int64                       `gorm:"column:advice_type" json:"advice_type" form:"advice_type"`
1239
+	AdviceDate            int64                       `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
1240
+	StartTime             int64                       `gorm:"column:start_time" json:"start_time" form:"start_time"`
1241
+	AdviceName            string                      `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
1242
+	AdviceDesc            string                      `gorm:"column:advice_desc" json:"advice_desc" form:"advice_desc"`
1243
+	ReminderDate          int64                       `gorm:"column:reminder_date" json:"reminder_date" form:"reminder_date"`
1244
+	SingleDose            float64                     `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
1245
+	SingleDoseUnit        string                      `gorm:"column:single_dose_unit" json:"single_dose_unit" form:"single_dose_unit"`
1246
+	PrescribingNumber     float64                     `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
1247
+	PrescribingNumberUnit string                      `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
1248
+	DeliveryWay           string                      `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
1249
+	ExecutionFrequency    string                      `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
1250
+	AdviceDoctor          int64                       `gorm:"column:advice_doctor" json:"advice_doctor" form:"advice_doctor"`
1251
+	Status                int64                       `gorm:"column:status" json:"status" form:"status"`
1252
+	CreatedTime           int64                       `gorm:"column:created_time" json:"created_time" form:"created_time"`
1253
+	UpdatedTime           int64                       `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
1254
+	AdviceAffirm          string                      `gorm:"column:advice_affirm" json:"advice_affirm" form:"advice_affirm"`
1255
+	Remark                string                      `gorm:"column:remark" json:"remark" form:"remark"`
1256
+	StopTime              int64                       `gorm:"column:stop_time" json:"stop_time" form:"stop_time"`
1257
+	StopReason            string                      `gorm:"column:stop_reason" json:"stop_reason" form:"stop_reason"`
1258
+	StopDoctor            int64                       `gorm:"column:stop_doctor" json:"stop_doctor" form:"stop_doctor"`
1259
+	StopState             int64                       `gorm:"column:stop_state" json:"stop_state" form:"stop_state"`
1260
+	ParentId              int64                       `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
1261
+	ExecutionTime         int64                       `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
1262
+	ExecutionStaff        int64                       `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
1263
+	ExecutionState        int64                       `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
1264
+	Checker               int64                       `gorm:"column:checker" json:"checker" form:"checker"`
1265
+	RecordDate            int64                       `gorm:"column:record_date" json:"record_date" form:"record_date"`
1266
+	DialysisOrderId       int64                       `gorm:"column:dialysis_order_id" json:"dialysis_order_id" form:"dialysis_order_id"`
1267
+	CheckTime             int64                       `gorm:"column:check_time" json:"check_time" form:"check_time"`
1268
+	CheckState            int64                       `gorm:"column:check_state" json:"check_state" form:"check_state"`
1269
+	DrugSpec              float64                     `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
1270
+	DrugSpecUnit          string                      `gorm:"column:drug_spec_unit" json:"drug_spec_unit" form:"drug_spec_unit"`
1271
+	Groupno               int64                       `gorm:"column:groupno" json:"groupno" form:"groupno"`
1272
+	RemindType            int64                       `gorm:"column:remind_type" json:"remind_type" form:"remind_type"`
1273
+	FrequencyType         int64                       `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
1274
+	DayCount              int64                       `gorm:"column:day_count" json:"day_count" form:"day_count"`
1275
+	WeekDay               string                      `gorm:"column:week_day" json:"week_day" form:"week_day"`
1276
+	TemplateId            string                      `gorm:"column:template_id" json:"template_id" form:"template_id"`
1277
+	Modifier              int64                       `gorm:"column:modifier" json:"modifier" form:"modifier"`
1278
+	DrugId                int64                       `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
1279
+	Price                 float64                     `gorm:"column:price" json:"price" form:"price"`
1280
+	PrescriptionId        int64                       `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
1281
+	MedListCodg           string                      `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
1282
+	FeedetlSn             string                      `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
1283
+	Day                   int64                       `gorm:"column:day" json:"day" form:"day"`
1284
+	ChildDoctorAdvice     []*BloodHisDoctorAdviceInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:DrugId" json:"child"`
1285
+	Diagnosis             int64                       `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
1286
+	Way                   int64                       `gorm:"column:way" json:"way" form:"way"`
1287
+	HospApprFlag          int64                       `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
1288
+	LmtUsedFlag           int64                       `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
1289
+}
1290
+
1291
+func (BloodHisDoctorAdviceInfo) TableName() string {
1292
+	return "his_doctor_advice_info"
1293
+}
1294
+
1295
+type BloodHisPrescriptionProject struct {
1296
+	ID                 int64                          `gorm:"column:id" json:"id" form:"id"`
1297
+	ProjectId          int64                          `gorm:"column:project_id" json:"project_id" form:"project_id"`
1298
+	Price              float64                        `gorm:"column:price" json:"price" form:"price"`
1299
+	UserOrgId          int64                          `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1300
+	Status             int64                          `gorm:"column:status" json:"status" form:"status"`
1301
+	Ctime              int64                          `gorm:"column:ctime" json:"ctime" form:"ctime"`
1302
+	Mtime              int64                          `gorm:"column:mtime" json:"mtime" form:"mtime"`
1303
+	PatientId          int64                          `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1304
+	HisPatientId       int64                          `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
1305
+	RecordDate         int64                          `gorm:"column:record_date" json:"record_date" form:"record_date"`
1306
+	PrescriptionId     int64                          `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
1307
+	Count              string                         `gorm:"column:count" json:"count" form:"count"`
1308
+	FeedetlSn          string                         `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
1309
+	MedListCodg        string                         `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
1310
+	SingleDose         string                         `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
1311
+	DeliveryWay        string                         `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
1312
+	ExecutionFrequency string                         `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
1313
+	Day                string                         `gorm:"column:day" json:"day" form:"day"`
1314
+	Remark             string                         `gorm:"column:remark" json:"remark" form:"remark"`
1315
+	Unit               string                         `gorm:"column:unit" json:"unit" form:"unit"`
1316
+	Type               int64                          `gorm:"column:type" json:"type" form:"type"`
1317
+	Doctor             int64                          `gorm:"column:doctor" json:"doctor" form:"doctor"`
1318
+	ExecutionTime      int64                          `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
1319
+	ExecutionStaff     int64                          `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
1320
+	ExecutionState     int64                          `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
1321
+	CheckTime          int64                          `gorm:"column:check_time" json:"check_time" form:"check_time"`
1322
+	CheckState         int64                          `gorm:"column:check_state" json:"check_state" form:"check_state"`
1323
+	Checker            int64                          `gorm:"column:checker" json:"checker" form:"checker"`
1324
+	StartTime          int64                          `gorm:"column:start_time" json:"start_time" form:"start_time"`
1325
+	TeamId             int64                          `gorm:"column:team_id" json:"team_id" form:"team_id"`
1326
+	FrequencyType      int64                          `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
1327
+	DayCount           int64                          `gorm:"column:day_count" json:"day_count" form:"day_count"`
1328
+	WeekDay            string                         `gorm:"column:week_day" json:"week_day" form:"week_day"`
1329
+	ChildDoctorAdvice  []*BloodHisPrescriptionProject `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ProjectId" json:"child"`
1330
+}
1331
+
1332
+func (BloodHisPrescriptionProject) TableName() string {
1333
+	return "his_prescription_project"
1334
+}

+ 2 - 2
service/device_service.go ファイルの表示

@@ -437,7 +437,7 @@ func GetAllDeviceNumbers(orgID int64, record_date int64, schedule_type int64) ([
437 437
 
438 438
 func GetDeviceNumberByID(orgID int64, numberID int64) (*models.DeviceNumber, error) {
439 439
 	var number models.DeviceNumber
440
-	err := readDb.Model(&models.DeviceNumber{}).Where("org_id = ? AND id = ?", orgID, numberID).First(&number).Error
440
+	err := readDb.Model(&models.DeviceNumber{}).Where("org_id = ? AND id = ? ", orgID, numberID).First(&number).Error
441 441
 	if err != nil {
442 442
 		if err == gorm.ErrRecordNotFound {
443 443
 			return nil, nil
@@ -495,7 +495,7 @@ func UpdateDeviceNumber(number *models.DeviceNumber) error {
495 495
 		tx.Rollback()
496 496
 		return updateNumberErr
497 497
 	}
498
-	updateDeviceErr := tx.Model(&models.Device{}).Where("org_id = ? AND device_number_id = ?", number.OrgID, number.ID).Updates(map[string]interface{}{"device_number": number.Number, "sort": number.Sort}).Error
498
+	updateDeviceErr := tx.Model(&models.Device{}).Where("org_id = ? AND device_number_id = ?", number.OrgID, number.ID).Updates(map[string]interface{}{"device_number": number.Number}).Error
499 499
 	if updateDeviceErr != nil {
500 500
 		tx.Rollback()
501 501
 		return updateDeviceErr

+ 3 - 3
service/dialysis_service.go ファイルの表示

@@ -760,7 +760,7 @@ func GetDialysisWatchByKeyword(orgID int64, keyword string, schedulType int64, p
760 760
 
761 761
 	db := readDb.
762 762
 		Model(&models.DialysisSchedule{}).
763
-		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
763
+		Preload("DeviceNumber", "org_id = ?", orgID).
764 764
 		// Preload("DeviceZone", "status = 1 AND org_id = ?", orgID).
765 765
 		Preload("TreatmentMode", "status = 1").
766 766
 		Preload("Prescription", "status = 1 AND user_org_id = ?", orgID).
@@ -1354,8 +1354,8 @@ func SaveHisDoctorAdvice(advice *models.HisDoctorAdviceInfo) (err error) {
1354 1354
 
1355 1355
 func GetGoodInfoMation(orgid int64) (goodinfo []*models.GoodInfo, err error) {
1356 1356
 
1357
-	//	err = XTReadDB().Model(&goodinfo).Where("org_id = ? and status = 1 AND  find_in_set('停用',good_status) = 0", orgid).Preload("GoodSotckInfo", "stock_count > 0 and status = 1").Find(&goodinfo).Error
1358
-	err = XTReadDB().Model(&goodinfo).Where("org_id = ? and status = 1 AND  find_in_set('停用',good_status) = 0", orgid).Find(&goodinfo).Error
1357
+	err = XTReadDB().Model(&goodinfo).Where("org_id = ? and status = 1 AND  find_in_set('停用',good_status) = 0", orgid).Preload("GoodSotckInfo", "stock_count > 0 and status = 1").Find(&goodinfo).Error
1358
+	//err = XTReadDB().Model(&goodinfo).Where("org_id = ? and status = 1 AND  find_in_set('停用',good_status) = 0", orgid).Find(&goodinfo).Error
1359 1359
 	return goodinfo, err
1360 1360
 }
1361 1361
 

+ 6 - 0
service/doctor_schedule_service.go ファイルの表示

@@ -92,6 +92,12 @@ func GetAllDoctorList(orgid int64, appid int64) (role []*models.XTSgjUserAdminRo
92 92
 	return role, err
93 93
 }
94 94
 
95
+func GetAllDoctorListSix(orgid int64, appid int64) (role []*models.XTSgjUserAdminRole, err error) {
96
+
97
+	err = UserReadDB().Model(&role).Where("org_id =? and app_id = ? and status = 1", orgid, appid).Order("sort desc").Find(&role).Error
98
+	return role, err
99
+}
100
+
95 101
 func GetAllNurseList(orgid int64, appid int64) (role []*models.XTSgjUserAdminRole, err error) {
96 102
 
97 103
 	err = UserReadDB().Model(&role).Where("org_id = ? and app_id = ? and user_type =3 and status =1", orgid, appid).Order("sort desc").Find(&role).Error

+ 46 - 17
service/gobal_config_service.go ファイルの表示

@@ -273,7 +273,7 @@ func GetExportHisOrderList(user_org_id int64, start_time int64, end_time int64,
273 273
 	return
274 274
 }
275 275
 
276
-func GetDrugInOrderDetail(startime int64, endtime int64, orgid int64, orderType int64, manufacturerId int64, keyword string, page int64, limit int64) (drugInfo []*models.BloodDrugWarehouseInfo, total int64, err error) {
276
+func GetDrugInOrderDetail(startime int64, endtime int64, orgid int64, orderType int64, manufacturerId int64, keyword string, page int64, limit int64, storehouse_id int64) (drugInfo []*models.BloodDrugWarehouseInfo, total int64, err error) {
277 277
 
278 278
 	likeKey := "%" + keyword + "%"
279 279
 	offset := (page - 1) * limit
@@ -293,8 +293,9 @@ func GetDrugInOrderDetail(startime int64, endtime int64, orgid int64, orderType
293 293
 	if orgid > 0 {
294 294
 		db = db.Where("x.org_id =?", orgid)
295 295
 	}
296
-	if orderType > 0 {
297
-		db = db.Where("x.type = ?", orderType)
296
+
297
+	if storehouse_id > 0 {
298
+		db = db.Where("x.storehouse_id = ?", storehouse_id)
298 299
 	}
299 300
 
300 301
 	if len(keyword) > 0 {
@@ -304,9 +305,9 @@ func GetDrugInOrderDetail(startime int64, endtime int64, orgid int64, orderType
304 305
 	}
305 306
 
306 307
 	if manufacturerId > 0 {
307
-		err = db.Select("x.id,x.warehousing_id,x.drug_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.price,x.total_price,x.dealer,t.manufacturer,x.remark,x.ctime,x.org_id,x.is_return,x.warehousing_order,x.type,x.retail_price,x.retail_total_price,t.drug_type,t.drug_name,t.drug_spec,t.min_unit,t.dose,t.dose_unit,t.max_unit,t.min_number,s.creater").Joins("left join xt_base_drug as t on t.id = x.drug_id and t.org_id = ? and t.status =1", orgid).Where("t.manufacturer = ?", manufacturerId).Joins("left join xt_drug_warehouse as s on s.id = x.warehousing_id and s.org_id = ? and s.status =1", orgid).Order("x.ctime desc").Count(&total).Offset(offset).Limit(limit).Scan(&drugInfo).Error
308
+		err = db.Select("x.id,x.warehousing_id,x.drug_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.price,x.total_price,x.dealer,t.manufacturer,x.remark,x.ctime,x.org_id,x.is_return,x.warehousing_order,x.type,x.retail_price,x.retail_total_price,x.storehouse_id,x.max_unit as count_unit,t.drug_type,t.drug_name,t.drug_spec,t.min_unit,t.dose,t.dose_unit,t.max_unit,t.min_number,s.creater").Joins("left join xt_base_drug as t on t.id = x.drug_id and t.org_id = ? and t.status =1", orgid).Where("t.manufacturer = ?", manufacturerId).Joins("left join xt_drug_warehouse as s on s.id = x.warehousing_id and s.org_id = ? and s.status =1", orgid).Order("x.id desc").Count(&total).Offset(offset).Limit(limit).Scan(&drugInfo).Error
308 309
 	} else {
309
-		err = db.Select("x.id,x.warehousing_id,x.drug_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.price,x.total_price,x.dealer,t.manufacturer,x.remark,x.ctime,x.org_id,x.is_return,x.warehousing_order,x.type,x.retail_price,x.retail_total_price,t.drug_type,t.drug_name,t.drug_spec,t.min_unit,t.dose,t.dose_unit,t.max_unit,t.min_number,s.creater").Joins("left join xt_base_drug as t on t.id = x.drug_id and t.org_id = ? and t.status =1", orgid).Joins("left join xt_drug_warehouse as s on s.id = x.warehousing_id and s.org_id = ? and s.status =1", orgid).Order("x.ctime desc").Count(&total).Offset(offset).Limit(limit).Scan(&drugInfo).Error
310
+		err = db.Select("x.id,x.warehousing_id,x.drug_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.price,x.total_price,x.dealer,t.manufacturer,x.remark,x.ctime,x.org_id,x.is_return,x.warehousing_order,x.type,x.retail_price,x.retail_total_price,x.storehouse_id,x.max_unit as count_unit,t.drug_type,t.drug_name,t.drug_spec,t.min_unit,t.dose,t.dose_unit,t.max_unit,t.min_number,s.creater").Joins("left join xt_base_drug as t on t.id = x.drug_id and t.org_id = ? and t.status =1", orgid).Joins("left join xt_drug_warehouse as s on s.id = x.warehousing_id and s.org_id = ? and s.status =1", orgid).Order("x.id desc").Count(&total).Offset(offset).Limit(limit).Scan(&drugInfo).Error
310 311
 	}
311 312
 
312 313
 	return drugInfo, total, err
@@ -347,7 +348,7 @@ func GetDrugReturnOrder(startime int64, endtime int64, orgid int64, orderType in
347 348
 	return returninfo, total, err
348 349
 }
349 350
 
350
-func GetDrugOutOrder(startime int64, endtime int64, orgid int64, orderType int64, manufacturerId int64, keyword string, page int64, limit int64) (outinfo []*models.BloodDrugWarehouseOutInfo, total int64, err error) {
351
+func GetDrugOutOrder(startime int64, endtime int64, orgid int64, orderType int64, manufacturerId int64, keyword string, page int64, limit int64, storehouse_id int64) (outinfo []*models.BloodDrugWarehouseOutInfo, total int64, err error) {
351 352
 
352 353
 	likeKey := "%" + keyword + "%"
353 354
 	offset := (page - 1) * limit
@@ -369,21 +370,25 @@ func GetDrugOutOrder(startime int64, endtime int64, orgid int64, orderType int64
369 370
 		db = db.Where("x.type = ?", orderType)
370 371
 	}
371 372
 
373
+	if storehouse_id > 0 {
374
+		db = db.Where("x.storehouse_id = ?", storehouse_id)
375
+	}
376
+
372 377
 	if len(keyword) > 0 {
373 378
 		db = db.Joins("left join sgj_xt.xt_drug_warehouse_out as o on o.id = x.warehouse_out_id  left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = o.creater").Group("x.id")
374 379
 		db = db.Where("x.warehouse_out_order_number like ? or b.drug_name like ?  or r.user_name like ?", likeKey, likeKey, likeKey)
375 380
 	}
376 381
 
377 382
 	if manufacturerId > 0 {
378
-		err = db.Select("x.id,x.warehouse_out_id,x.drug_id,x.warehousing_out_target,x.count,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.remark,x.is_cancel,x.warehouse_out_order_number,x.type,x.dealer,x.manufacturer,x.is_sys,x.sys_record_time,x.retail_price,x.retail_total_price,b.drug_name,b.drug_spec,b.drug_type,b.min_unit,b.max_unit,b.min_number,b.dose,b.dose_unit,b.last_price,t.creater").Joins("left join xt_base_drug as b on b.id = x.drug_id and b.org_id = ? and b.status =1", orgid).Joins("left join xt_drug_warehouse_out as t on t.id = x.warehouse_out_id and t.org_id = ? and t.status  =1", orgid).Where("t.manufacturer = ?", manufacturerId).Order("x.ctime desc").Count(&total).Offset(offset).Limit(limit).Scan(&outinfo).Error
383
+		err = db.Select("x.id,x.warehouse_out_id,x.drug_id,x.warehousing_out_target,x.count,x.count_unit,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.remark,x.is_cancel,x.warehouse_out_order_number,x.type,x.dealer,x.manufacturer,x.is_sys,x.sys_record_time,x.retail_price,x.retail_total_price,x.storehouse_id,b.drug_name,b.drug_spec,b.drug_type,b.min_unit,b.max_unit,b.min_number,b.dose,b.dose_unit,b.last_price,t.creater").Joins("left join xt_base_drug as b on b.id = x.drug_id and b.org_id = ? and b.status =1", orgid).Joins("left join xt_drug_warehouse_out as t on t.id = x.warehouse_out_id and t.org_id = ? and t.status  =1", orgid).Where("t.manufacturer = ?", manufacturerId).Order("x.ctime desc").Count(&total).Offset(offset).Limit(limit).Scan(&outinfo).Error
379 384
 	} else {
380
-		err = db.Select("x.id,x.warehouse_out_id,x.drug_id,x.warehousing_out_target,x.count,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.remark,x.is_cancel,x.warehouse_out_order_number,x.type,x.dealer,x.manufacturer,x.is_sys,x.sys_record_time,x.retail_price,x.retail_total_price,b.drug_name,b.drug_spec,b.drug_type,b.min_unit,b.max_unit,b.min_number,b.dose,b.dose_unit,b.last_price,t.creater").Joins("left join xt_base_drug as b on b.id = x.drug_id and b.org_id = ? and b.status =1", orgid).Joins("left join xt_drug_warehouse_out as t on t.id = x.warehouse_out_id and t.org_id = ? and t.status  =1", orgid).Order("x.ctime desc").Count(&total).Offset(offset).Limit(limit).Scan(&outinfo).Error
385
+		err = db.Select("x.id,x.warehouse_out_id,x.drug_id,x.warehousing_out_target,x.count,x.count_unit,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.remark,x.is_cancel,x.warehouse_out_order_number,x.type,x.dealer,x.manufacturer,x.is_sys,x.sys_record_time,x.retail_price,x.retail_total_price,x.storehouse_id,b.drug_name,b.drug_spec,b.drug_type,b.min_unit,b.max_unit,b.min_number,b.dose,b.dose_unit,b.last_price,t.creater").Joins("left join xt_base_drug as b on b.id = x.drug_id and b.org_id = ? and b.status =1", orgid).Joins("left join xt_drug_warehouse_out as t on t.id = x.warehouse_out_id and t.org_id = ? and t.status  =1", orgid).Order("x.ctime desc").Count(&total).Offset(offset).Limit(limit).Scan(&outinfo).Error
381 386
 	}
382 387
 
383 388
 	return outinfo, total, err
384 389
 }
385 390
 
386
-func GetDrugCancelOrderPrint(startime int64, endtime int64, orgid int64, orderType int64, manufacturerId int64, keyword string) (info []*models.BloodDrugCancelStockInfo, err error) {
391
+func GetDrugCancelOrderPrint(startime int64, endtime int64, orgid int64, orderType int64, manufacturerId int64, keyword string, storehouse_id int64) (info []*models.BloodDrugCancelStockInfo, err error) {
387 392
 	likeKey := "%" + keyword + "%"
388 393
 	db := XTReadDB().Table("xt_drug_cancel_stock_info as x").Where("x.status =1")
389 394
 	dbOne := XTReadDB().Table("xt_base_drug as s").Where("s.status =1")
@@ -404,17 +409,20 @@ func GetDrugCancelOrderPrint(startime int64, endtime int64, orgid int64, orderTy
404 409
 	if len(keyword) > 0 {
405 410
 		db = db.Where("x.order_number like ? or s.drug_spec like ? or t.creater like ?", likeKey, likeKey, likeKey)
406 411
 	}
412
+	if storehouse_id > 0 {
413
+		db = db.Where("x.storehouse_id = ?", storehouse_id)
414
+	}
407 415
 
408 416
 	if manufacturerId > 0 {
409
-		err = db.Select("x.id,x.max_unit as unit,x.drug_id,x.cancel_stock_id,x.count,x.price,x.total,x.product_date,x.expiry_date,x.ctime,x.org_id,x.order_number,x.type,x.dealer,x.manufacturer,x.retail_price,x.retail_total_price,x.number,s.drug_name,s.drug_type,s.drug_spec,s.min_unit,t.creater,s.dose,s.dose_unit,s.min_number,s.max_unit").Joins("left join xt_base_drug as s on s.id = x.drug_id and s.org_id = ? and s.status = 1", orgid).Joins("left join xt_drug_cancel_stock as t on t.id = x.cancel_stock_id and t.org_id = ? and t.status =1", orgid).Where("t.manufacturer = ?", manufacturerId).Order("x.ctime desc").Group("x.drug_id").Scan(&info).Error
417
+		err = db.Select("x.id,x.max_unit as unit,x.drug_id,x.cancel_stock_id,x.count,x.price,x.total,x.product_date,x.expiry_date,x.ctime,x.org_id,x.order_number,x.type,x.dealer,x.manufacturer,x.retail_price,x.retail_total_price,x.number,x.storehouse_id,s.drug_name,s.drug_type,s.drug_spec,s.min_unit,t.creater,s.dose,s.dose_unit,s.min_number,s.max_unit").Joins("left join xt_base_drug as s on s.id = x.drug_id and s.org_id = ? and s.status = 1", orgid).Joins("left join xt_drug_cancel_stock as t on t.id = x.cancel_stock_id and t.org_id = ? and t.status =1", orgid).Where("t.manufacturer = ?", manufacturerId).Order("x.ctime desc").Group("x.drug_id").Scan(&info).Error
410 418
 	} else {
411
-		err = db.Select("x.id,x.max_unit as unit,x.drug_id,x.cancel_stock_id,x.count,x.price,x.total,x.product_date,x.expiry_date,x.ctime,x.org_id,x.order_number,x.type,x.dealer,x.manufacturer,x.retail_price,x.retail_total_price,x.number,s.drug_name,s.drug_type,s.drug_spec,s.min_unit,t.creater,s.dose,s.dose_unit,s.min_number,s.max_unit").Joins("left join xt_base_drug as s on s.id = x.drug_id and s.org_id = ? and s.status = 1", orgid).Joins("left join xt_drug_cancel_stock as t on t.id = x.cancel_stock_id and t.org_id = ? and t.status =1", orgid).Order("x.ctime desc").Group("x.drug_id").Scan(&info).Error
419
+		err = db.Select("x.id,x.max_unit as unit,x.drug_id,x.cancel_stock_id,x.count,x.price,x.total,x.product_date,x.expiry_date,x.ctime,x.org_id,x.order_number,x.type,x.dealer,x.manufacturer,x.retail_price,x.retail_total_price,x.number,x.storehouse_id,s.drug_name,s.drug_type,s.drug_spec,s.min_unit,t.creater,s.dose,s.dose_unit,s.min_number,s.max_unit").Joins("left join xt_base_drug as s on s.id = x.drug_id and s.org_id = ? and s.status = 1", orgid).Joins("left join xt_drug_cancel_stock as t on t.id = x.cancel_stock_id and t.org_id = ? and t.status =1", orgid).Order("x.ctime desc").Group("x.drug_id").Scan(&info).Error
412 420
 	}
413 421
 
414 422
 	return info, err
415 423
 }
416 424
 
417
-func GetDrugCancelOrder(startime int64, endtime int64, orgid int64, orderType int64, manufacturerId int64, keyword string, page int64, limit int64) (cancel []*models.BloodDrugCancelStockInfo, total int64, err error) {
425
+func GetDrugCancelOrder(startime int64, endtime int64, orgid int64, orderType int64, manufacturerId int64, keyword string, page int64, limit int64, storehouse_id int64) (cancel []*models.BloodDrugCancelStockInfo, total int64, err error) {
418 426
 
419 427
 	likeKey := "%" + keyword + "%"
420 428
 	offset := (page - 1) * limit
@@ -434,6 +442,9 @@ func GetDrugCancelOrder(startime int64, endtime int64, orgid int64, orderType in
434 442
 	if orderType > 0 {
435 443
 		db = db.Where("x.type = ? ", orderType)
436 444
 	}
445
+	if storehouse_id > 0 {
446
+		db = db.Where("x.storehouse_id = ?", storehouse_id)
447
+	}
437 448
 	if len(keyword) > 0 {
438 449
 		db = db.Joins("left join sgj_xt.xt_drug_cancel_stock as o on o.id = x.cancel_stock_id  left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = o.creater").Group("o.id")
439 450
 
@@ -441,9 +452,9 @@ func GetDrugCancelOrder(startime int64, endtime int64, orgid int64, orderType in
441 452
 	}
442 453
 
443 454
 	if manufacturerId > 0 {
444
-		err = db.Select("x.id,x.max_unit as unit,x.drug_id,x.cancel_stock_id,x.count,x.price,x.total,x.product_date,x.expiry_date,x.ctime,x.org_id,x.order_number,x.type,x.dealer,x.manufacturer,x.retail_price,x.retail_total_price,x.number,s.drug_name,s.drug_type,s.drug_spec,s.min_unit,t.creater,s.dose,s.dose_unit,s.min_number,s.max_unit").Joins("left join xt_base_drug as s on s.id = x.drug_id and s.org_id = ? and s.status = 1", orgid).Joins("left join xt_drug_cancel_stock as t on t.id = x.cancel_stock_id and t.org_id = ? and t.status =1", orgid).Where("t.manufacturer = ?", manufacturerId).Order("x.ctime desc").Count(&total).Offset(offset).Limit(limit).Scan(&cancel).Error
455
+		err = db.Select("x.id,x.max_unit as unit,x.drug_id,x.cancel_stock_id,x.count,x.price,x.total,x.product_date,x.expiry_date,x.ctime,x.org_id,x.order_number,x.type,x.dealer,x.manufacturer,x.retail_price,x.retail_total_price,x.number,x.storehouse_id,s.drug_name,s.drug_type,s.drug_spec,s.min_unit,t.creater,s.dose,s.dose_unit,s.min_number,s.max_unit").Joins("left join xt_base_drug as s on s.id = x.drug_id and s.org_id = ? and s.status = 1", orgid).Joins("left join xt_drug_cancel_stock as t on t.id = x.cancel_stock_id and t.org_id = ? and t.status =1", orgid).Where("t.manufacturer = ?", manufacturerId).Order("x.ctime desc").Count(&total).Offset(offset).Limit(limit).Scan(&cancel).Error
445 456
 	} else {
446
-		err = db.Select("x.id,x.max_unit as unit,x.drug_id,x.cancel_stock_id,x.count,x.price,x.total,x.product_date,x.expiry_date,x.ctime,x.org_id,x.order_number,x.type,x.dealer,x.manufacturer,x.retail_price,x.retail_total_price,x.number,s.drug_name,s.drug_type,s.drug_spec,s.min_unit,t.creater,s.dose,s.dose_unit,s.min_number,s.max_unit").Joins("left join xt_base_drug as s on s.id = x.drug_id and s.org_id = ? and s.status = 1", orgid).Joins("left join xt_drug_cancel_stock as t on t.id = x.cancel_stock_id and t.org_id = ? and t.status =1", orgid).Order("x.ctime desc").Count(&total).Offset(offset).Limit(limit).Scan(&cancel).Error
457
+		err = db.Select("x.id,x.max_unit as unit,x.drug_id,x.cancel_stock_id,x.count,x.price,x.total,x.product_date,x.expiry_date,x.ctime,x.org_id,x.order_number,x.type,x.dealer,x.manufacturer,x.retail_price,x.retail_total_price,x.number,x.storehouse_id,s.drug_name,s.drug_type,s.drug_spec,s.min_unit,t.creater,s.dose,s.dose_unit,s.min_number,s.max_unit").Joins("left join xt_base_drug as s on s.id = x.drug_id and s.org_id = ? and s.status = 1", orgid).Joins("left join xt_drug_cancel_stock as t on t.id = x.cancel_stock_id and t.org_id = ? and t.status =1", orgid).Order("x.ctime desc").Count(&total).Offset(offset).Limit(limit).Scan(&cancel).Error
447 458
 	}
448 459
 
449 460
 	return cancel, total, err
@@ -613,7 +624,7 @@ func GetDrugStockList(page int64, limit int64, keyword string, drugcategory int6
613 624
 	return list, total, err
614 625
 }
615 626
 
616
-func GetAllBaseDurgListCount(page int64, limit int64, keyword string, drugcategory int64, startime int64, endtime int64, orgid int64) (drug []*models.VmBaseDrug, total int64, err error) {
627
+func GetAllBaseDurgListCount(page int64, limit int64, keyword string, drugcategory int64, startime int64, endtime int64, orgid int64, storehouse_id int64, drug_id int64) (drug []*models.VmBaseDrug, total int64, err error) {
617 628
 
618 629
 	offset := (page - 1) * limit
619 630
 	db := XTReadDB().Table("xt_base_drug").Where("status = 1")
@@ -629,6 +640,10 @@ func GetAllBaseDurgListCount(page int64, limit int64, keyword string, drugcatego
629 640
 		db = db.Where("drug_name like ?", likeKey)
630 641
 	}
631 642
 
643
+	if drug_id > 0 {
644
+		db = db.Where("id = ?", drug_id)
645
+	}
646
+
632 647
 	err = db.Count(&total).Offset(offset).Limit(limit).Order("ctime desc").Preload("DrugWarehouseInfo", func(db *gorm.DB) *gorm.DB {
633 648
 		if startime > 0 {
634 649
 			db = db.Where("ctime>=?", startime)
@@ -636,6 +651,9 @@ func GetAllBaseDurgListCount(page int64, limit int64, keyword string, drugcatego
636 651
 		if endtime > 0 {
637 652
 			db = db.Where("ctime<=?", endtime)
638 653
 		}
654
+		if storehouse_id > 0 {
655
+			db = db.Where("storehouse_id = ?", storehouse_id)
656
+		}
639 657
 		return db.Where("status = 1")
640 658
 	}).Preload("DrugCancelStockInfo", func(db *gorm.DB) *gorm.DB {
641 659
 		if startime > 0 {
@@ -645,6 +663,17 @@ func GetAllBaseDurgListCount(page int64, limit int64, keyword string, drugcatego
645 663
 			db = db.Where("ctime<=?", endtime)
646 664
 		}
647 665
 		return db.Where("status = 1")
666
+	}).Preload("DrugWarehouse", func(db *gorm.DB) *gorm.DB {
667
+		if startime > 0 {
668
+			db = db.Where("ctime>=?", startime)
669
+		}
670
+		if endtime > 0 {
671
+			db = db.Where("ctime<=?", endtime)
672
+		}
673
+		if storehouse_id > 0 {
674
+			db = db.Where("storehouse_id = ?", storehouse_id)
675
+		}
676
+		return db.Group("drug_id,storehouse_id").Where("status = 1")
648 677
 	}).Preload("DrugWarehouseOutInfo", func(db *gorm.DB) *gorm.DB {
649 678
 		if startime > 0 {
650 679
 			db = db.Where("ctime>=?", startime)
@@ -715,7 +744,7 @@ func GetDrugStockOutFlow(drugid int64, startime int64, endtime int64, page int64
715 744
 
716 745
 func GetBatchOrderDetail(drugid int64, orgid int64, page int64, limit int64) (drug []*models.DrugWarehouseInfo, total int64, err error) {
717 746
 	offset := (page - 1) * limit
718
-	err = XTReadDB().Model(&drug).Where("drug_id = ? and org_id = ? and status = 1", drugid, orgid).Count(&total).Offset(offset).Limit(limit).Find(&drug).Error
747
+	err = XTReadDB().Model(&drug).Where("drug_id = ? and org_id = ? and status = 1", drugid, orgid).Count(&total).Offset(offset).Limit(limit).Order("id desc").Find(&drug).Error
719 748
 	return drug, total, err
720 749
 }
721 750
 
@@ -830,7 +859,7 @@ func GetSingleOrderDetail(id int64, orgid int64) (info []*models.VmDrugWarehouse
830 859
 		db = db.Where("x.warehouse_out_id = ?", id)
831 860
 	}
832 861
 
833
-	err = db.Select("x.id,x.warehouse_out_id,x.drug_id,sum(x.count) as count,x.count_unit,x.price,x.product_date,x.expiry_date,x.remark,x.is_cancel,x.warehouse_out_order_number,x.type,x.dealer,t.manufacturer,x.is_sys,x.sys_record_time,x.retail_price as total_price,x.retail_total_price,t.drug_name,t.drug_type,t.max_unit,t.min_unit,t.min_number,x.number,x.batch_number,t.dose,t.dose_unit,t.last_price,t.min_price,t.medical_insurance_number,t.retail_price ,x.warehouse_info_id").Joins("left join xt_base_drug as t on t.id = x.drug_id").Group("x.drug_id").Scan(&info).Error
862
+	err = db.Select("x.id,x.warehouse_out_id,x.drug_id,sum(x.count) as count,x.count_unit,x.price,x.product_date,x.expiry_date,x.remark,x.is_cancel,x.warehouse_out_order_number,x.type,x.dealer,t.manufacturer,x.is_sys,x.sys_record_time,x.retail_price as total_price,x.retail_total_price,x.storehouse_id,t.drug_name,t.drug_type,t.max_unit,t.min_unit,t.min_number,x.number,x.batch_number,x.admin_user_id,t.dose,t.dose_unit,t.last_price,t.min_price,t.medical_insurance_number,t.retail_price ,x.warehouse_info_id").Joins("left join xt_base_drug as t on t.id = x.drug_id").Group("x.drug_id").Scan(&info).Error
834 863
 	return info, err
835 864
 }
836 865
 

+ 6 - 2
service/his_service.go ファイルの表示

@@ -285,7 +285,7 @@ func GetNewScheduleHisPatientList(org_id int64, keywords string, record_date int
285 285
 }
286 286
 
287 287
 func GetAllBaseDrugStockList(org_id int64) (drugs []*models.BaseDrugLib, err error) {
288
-	err = readDb.Model(&models.BaseDrugLib{}).Where("user_org_id = ? AND status = 1", org_id).Find(&drugs).Error
288
+	err = readDb.Model(&models.BaseDrugLib{}).Where("org_id = ? AND status = 1", org_id).Find(&drugs).Error
289 289
 	return
290 290
 }
291 291
 
@@ -711,7 +711,9 @@ type BaseDrugLib struct {
711 711
 	DrugDay                     string  `gorm:"column:drug_day" json:"drug_day" form:"drug_day"`
712 712
 	Total                       float64 `gorm:"column:total" json:"total" form:"total"`
713 713
 	PrescribingNumberUnit       string  `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
714
-
714
+	BatchRetaiPrice             float64 `gorm:"column:batch_retai_price" json:"batch_retai_price" form:"batch_retai_price"`
715
+	SumCount                    int64   `gorm:"column:sum_count" json:"sum_count" form:"sum_count"`
716
+	SumInCount                  int64   `gorm:"column:sum_in_count" json:"sum_in_count" form:"sum_in_count"`
715 717
 	//MedicineInsurancePercentage []*MedicineInsurancePercentage `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"monitoring_record"`
716 718
 	OtherDrugWarehouseInfo []*OtherDrugWarehouseInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"stock_in"`
717 719
 	VMDrugSalesReturnInfo  []*VMDrugSalesReturnInfo  `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"sales_return"`
@@ -727,6 +729,8 @@ func GetAllDrugLibList(org_id int64) (list []*BaseDrugLib, err error) {
727 729
 	err = readDb.Model(&BaseDrugLib{}).Where("org_id = ?  AND status = 1 AND  find_in_set('停用',drug_status) = 0", org_id).Preload("OtherDrugWarehouseInfo", func(db *gorm.DB) *gorm.DB {
728 730
 		return db.Where("(status = 1 and stock_max_number > 0)  or  (status = 1  AND stock_min_number >0)")
729 731
 	}).Find(&list).Error
732
+
733
+	//err = readDb.Model(&BaseDrugLib{}).Where("org_id = ?  AND status = 1 AND  find_in_set('停用',drug_status) = 0", org_id).Find(&list).Error
730 734
 	return
731 735
 }
732 736
 

+ 1 - 1
service/manage_center_service.go ファイルの表示

@@ -174,7 +174,7 @@ func FindBaseDrugLibRecord(org_id int64, id int64) (lib models.BaseDrugLib, err
174 174
 }
175 175
 
176 176
 func FindBaseDrugLibRecordSeven(org_id int64, id int64) (lib models.BaseDrugLibSeven, err error) {
177
-	err = readDb.Select("id,drug_name,max_unit,min_number,min_unit").Where("org_id = ? AND id = ? AND status = 1", org_id, id).First(&lib).Error
177
+	err = readDb.Select("id,drug_name,max_unit,min_number,min_unit,sum_count").Where("org_id = ? AND id = ? AND status = 1", org_id, id).First(&lib).Error
178 178
 	return
179 179
 }
180 180
 

+ 1 - 1
service/mobile_dialysis_service.go ファイルの表示

@@ -2770,7 +2770,7 @@ func GetLastDialysisGoods(patient_id int64, orgID int64, record_time int64) (goo
2770 2770
 
2771 2771
 	err = readDb.Model(&AutomaticReduceDetail{}).Where("patient_id = ? AND org_id = ? AND status=1 AND record_time < ? AND count > 0", patient_id, orgID, record_time).Select("record_time").Group("record_time").Order("record_time asc").Scan(&Id).Error
2772 2772
 	if len(Id) > 0 {
2773
-		fmt.Println("ids232323223322233233233322332", Id)
2773
+
2774 2774
 		err = readDb.Model(&AutomaticReduceDetail{}).Where("patient_id = ? AND org_id = ? AND status=1 AND record_time = ? AND count > 0", patient_id, orgID, Id[len(Id)-1].RecordTime).Preload("VMGoodInfo", "status = 1 AND org_id = ? ", orgID).Preload("GoodsType", "status = 1 AND (org_id = ? OR org_id = 0)  ", orgID).Find(&goodUser).Error
2775 2775
 	}
2776 2776
 	return

+ 1 - 1
service/patient_service.go ファイルの表示

@@ -822,7 +822,7 @@ func UpdatePatientLapseto(patientid int64, lapseto models.PatientLapseto) error
822 822
 func UpdatepatientTwo(patientsNew *models.XtPatientsNew, id int64) error {
823 823
 
824 824
 	err := XTWriteDB().Model(&patientsNew).Where("blood_id = ?", id).Update(map[string]interface{}{"user_org_id": patientsNew.UserOrgId, "user_id": patientsNew.UserId, "avatar": patientsNew.Avatar, "patient_type": patientsNew.Avatar, "dialysis_no": patientsNew.DialysisNo, "admission_number": patientsNew.AdmissionNumber, "source": patientsNew.Source, "lapseto": patientsNew.Lapseto, "partition_id": patientsNew.PartitionId, "bed_id": patientsNew.BedId, "name": patientsNew.Name, "alias": patientsNew.Alias, "gender": patientsNew.Gender, "marital_status": patientsNew.MaritalStatus, "id_card_no": patientsNew.IdCardNo, "birthday": patientsNew.Birthday, "reimbursement_way_id": patientsNew.ReimbursementWayId, "health_care_type": patientsNew.HealthCareType, "health_care_no": patientsNew.HealthCareType, "health_care_due_date": patientsNew.HealthCareType, "height": patientsNew.Height, "blood_type": patientsNew.BloodType, "rh": patientsNew.Rh, "health_care_due_alert_date": patientsNew.HealthCareDueAlertDate, "education_level": patientsNew.EducationLevel, "profession": patientsNew.Profession, "phone": patientsNew.Phone, "home_telephone": patientsNew.HomeTelephone, "relative_phone": patientsNew.RelativePhone, "relative_relations": patientsNew.RelativeRelations, "home_address": patientsNew.HomeAddress, "work_unit": patientsNew.WorkUnit, "unit_address": patientsNew.UnitAddress, "children": patientsNew.Children, "receiving_date": patientsNew.ReceivingDate, "is_hospital_first_dialysis": patientsNew.IsHospitalFirstDialysis, "first_dialysis_date": patientsNew.FirstDialysisDate, "first_dialysis_hospital": patientsNew.FirstDialysisHospital, "predialysis_condition": patientsNew.PredialysisCondition, "pre_hospital_dialysis_frequency": patientsNew.PreHospitalDialysisFrequency, "pre_hospital_dialysis_times": patientsNew.PreHospitalDialysisFrequency, "hospital_first_dialysis_date": patientsNew.HospitalFirstDialysisDate, "induction_period": patientsNew.InductionPeriod, "initial_dialysis": patientsNew.InitialDialysis, "total_dialysis": patientsNew.TotalDialysis, "attending_doctor_id": patientsNew.AttendingDoctorId, "head_nurse_id": patientsNew.HeadNurseId, "evaluate": patientsNew.Evaluate, "diagnose": patientsNew.Diagnose, "remark": patientsNew.Remark, "registrars_id": patientsNew.RegistrarsId, "registrars": patientsNew.Registrars, "qr_code": patientsNew.QrCode, "binding_state": patientsNew.BindingState, "patient_complains": patientsNew.PatientComplains, "present_history": patientsNew.PresentHistory, "past_history": patientsNew.PastHistory, "temperature": patientsNew.Temperature,
825
-		"pulse": patientsNew.Pulse, "respiratory": patientsNew.Respiratory, "sbp": patientsNew.Sbp, "dbp": patientsNew.Dbp, "nation": patientsNew.Nation, "native_place": patientsNew.NativePlace, "age": patientsNew.Age, "infectious_next_record_time": patientsNew.InfectiousNextRecordTime, "is_infectious": patientsNew.IsInfectious, "remind_cycle": patientsNew.RemindCycle, "response_result": patientsNew.ResponseResult, "is_open_remind": patientsNew.IsOpenRemind, "first_treatment_date": patientsNew.FirstTreatmentDate, "dialysis_age": patientsNew.DialysisAge, "expense_kind": patientsNew.ExpenseKind, "tell_phone": patientsNew.ExpenseKind, "contact_name": patientsNew.ContactName, "blood_patients": patientsNew.BloodPatients, "slow_patients": patientsNew.SlowPatients, "member_patients": patientsNew.MemberPatients, "ecommer_patients": patientsNew.EcommerPatients}).Error
825
+		"pulse": patientsNew.Pulse, "respiratory": patientsNew.Respiratory, "sbp": patientsNew.Sbp, "dbp": patientsNew.Dbp, "nation": patientsNew.Nation, "native_place": patientsNew.NativePlace, "age": patientsNew.Age, "infectious_next_record_time": patientsNew.InfectiousNextRecordTime, "is_infectious": patientsNew.IsInfectious, "remind_cycle": patientsNew.RemindCycle, "response_result": patientsNew.ResponseResult, "is_open_remind": patientsNew.IsOpenRemind, "first_treatment_date": patientsNew.FirstTreatmentDate, "dialysis_age": patientsNew.DialysisAge, "expense_kind": patientsNew.ExpenseKind, "tell_phone": patientsNew.ExpenseKind, "contact_name": patientsNew.ContactName, "blood_patients": patientsNew.BloodPatients, "slow_patients": patientsNew.SlowPatients, "member_patients": patientsNew.MemberPatients, "ecommer_patients": patientsNew.EcommerPatients, "troble_shoot": patientsNew.TrobleShoot}).Error
826 826
 	return err
827 827
 }
828 828
 

File diff suppressed because it is too large
+ 1108 - 1
service/secondary_service.go


+ 17 - 9
service/self_drug_service.go ファイルの表示

@@ -821,7 +821,7 @@ func GetLastDrugWarehouseOutInfo(drugid int64, warehouseOutId int64, orgid int64
821 821
 	return info, err
822 822
 }
823 823
 
824
-func PostSearchDrugWarehouseList(keyword string, orgid int64) (info []*models.BloodDrugWarehouseInfo, err error) {
824
+func PostSearchDrugWarehouseList(keyword string, orgid int64, storehouse_id int64) (info []*models.BloodDrugWarehouseInfo, err error) {
825 825
 	db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1")
826 826
 	table := XTReadDB().Table("xt_base_drug as t").Where("t.status")
827 827
 	fmt.Println(table)
@@ -829,7 +829,10 @@ func PostSearchDrugWarehouseList(keyword string, orgid int64) (info []*models.Bl
829 829
 	if orgid > 0 {
830 830
 		db = db.Where("x.org_id = ?", orgid)
831 831
 	}
832
-	err = db.Group("x.drug_id").Select("x.id,x.warehousing_id,x.drug_id,t.number,x.product_date,x.expiry_date,x.warehousing_count,x.price,x.total_price,x.dealer,x.remark,x.warehousing_order,x.warehouseing_unit,x.stock_max_number,x.stock_min_number,x.batch_number,t.drug_origin_place,t.drug_name,t.min_unit,x.manufacturer,t.retail_price,t.max_unit,t.min_number,t.dose,t.dose_unit,t.last_price,t.drug_origin_place").Joins("left join xt_base_drug as t on t.id = x.drug_id").Where("t.drug_name like ? and t.org_id = ?", likeKey, orgid).Order("x.ctime desc").Scan(&info).Error
832
+	if storehouse_id > 0 {
833
+		db = db.Where("x.storehouse_id = ?", storehouse_id)
834
+	}
835
+	err = db.Group("x.drug_id").Select("x.id,x.warehousing_id,x.drug_id,t.number,x.product_date,x.expiry_date,x.warehousing_count,x.price,x.total_price,x.dealer,x.remark,x.warehousing_order,x.warehouseing_unit,x.stock_max_number,x.stock_min_number,x.batch_number,x.storehouse_id,t.drug_origin_place,t.drug_name,t.min_unit,x.manufacturer,t.retail_price,t.max_unit,t.min_number,t.dose,t.dose_unit,t.last_price,t.drug_origin_place").Joins("left join xt_base_drug as t on t.id = x.drug_id").Where("t.drug_name like ? and t.org_id = ?", likeKey, orgid).Order("x.ctime desc").Scan(&info).Error
833 836
 	return info, err
834 837
 
835 838
 }
@@ -888,7 +891,7 @@ func CreateDrugDamage(damage models.XtDrugDamage) error {
888 891
 	return err
889 892
 }
890 893
 
891
-func GetDrugDamageList(startime int64, endtime int64, orgId int64, keyword string, limit int64, page int64) (adjust []*models.VmDrugInventory, total int64, err error) {
894
+func GetDrugDamageList(startime int64, endtime int64, orgId int64, keyword string, limit int64, page int64, storehouse_id int64) (adjust []*models.VmDrugInventory, total int64, err error) {
892 895
 	likeKey := "%" + keyword + "%"
893 896
 	offset := (page - 1) * limit
894 897
 	db := XTReadDB().Table("xt_drug_inventory as x").Where("x.status = 1 and type = 4")
@@ -910,7 +913,10 @@ func GetDrugDamageList(startime int64, endtime int64, orgId int64, keyword strin
910 913
 	if endtime > 0 {
911 914
 		db = db.Where("x.ctime <=?", endtime)
912 915
 	}
913
-	err = db.Group("x.drug_id").Select("x.id,x.drug_name,x.specification_name,x.warehousing_unit,x.count,x.last_price,x.retail_price,x.new_price,x.manufacturer,x.dealer,x.remark,x.drug_id,x.warehousing_order,x.start_time,x.creater,x.checker,x.checker_status,x.checker_time,x.number,x.drug_origin_place,x.warehouse_info_id,x.batch_number,x.stock_max_number,x.stock_min_number,t.min_number,t.max_unit,t.min_unit,t.min_price").Joins("left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.creater").Joins("left join xt_base_drug as t on t.id =x.drug_id").Count(&total).Offset(offset).Limit(limit).Scan(&adjust).Error
916
+	if storehouse_id > 0 {
917
+		db = db.Where("x.storehouse_id = ?", storehouse_id)
918
+	}
919
+	err = db.Group("x.drug_id").Select("x.id,x.drug_name,x.specification_name,x.warehousing_unit,x.count,x.last_price,x.retail_price,x.new_price,x.manufacturer,x.dealer,x.remark,x.drug_id,x.warehousing_order,x.start_time,x.creater,x.checker,x.checker_status,x.checker_time,x.number,x.drug_origin_place,x.warehouse_info_id,x.batch_number,x.stock_max_number,x.stock_min_number,x.storehouse_id,t.min_number,t.max_unit,t.min_unit,t.min_price").Joins("left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.creater").Joins("left join xt_base_drug as t on t.id =x.drug_id").Count(&total).Offset(offset).Limit(limit).Scan(&adjust).Error
914 920
 	return adjust, total, err
915 921
 }
916 922
 
@@ -968,9 +974,9 @@ func GetDrugDamagePrint(ids []string) (damage []*models.XtDrugDamage, err error)
968 974
 	return damage, err
969 975
 }
970 976
 
971
-func GetWarehoseInfoById(id int64) (info []*models.XtDrugWarehouseInfo, err error) {
977
+func GetWarehoseInfoById(id int64, storehouse_id int64) (info []*models.XtDrugWarehouseInfo, err error) {
972 978
 
973
-	err = XTReadDB().Model(&info).Where("drug_id=? and status = 1", id).Preload("XtBaseDrug", "status= 1").Find(&info).Error
979
+	err = XTReadDB().Model(&info).Where("drug_id=? and status = 1 and storehouse_id = ?", id, storehouse_id).Preload("XtBaseDrug", "status= 1").Find(&info).Error
974 980
 	return info, err
975 981
 }
976 982
 
@@ -1088,8 +1094,7 @@ func GetDrugInventoryPrintList(ids []string) (info []*models.XtDrugInventory, er
1088 1094
 	return info, err
1089 1095
 }
1090 1096
 
1091
-func GetDrugInventoryDetailList(keyword string, page int64, limit int64, orgid int64) (list []*models.VmDrugInventory, total int64, err error) {
1092
-	fmt.Println("startdate", limit, page)
1097
+func GetDrugInventoryDetailList(keyword string, page int64, limit int64, orgid int64, storehouse_id int64) (list []*models.VmDrugInventory, total int64, err error) {
1093 1098
 	likeKey := "%" + keyword + "%"
1094 1099
 	offset := (page - 1) * limit
1095 1100
 	db := XTReadDB().Table("xt_drug_inventory as x").Where("x.status = 1")
@@ -1102,7 +1107,10 @@ func GetDrugInventoryDetailList(keyword string, page int64, limit int64, orgid i
1102 1107
 	if orgid > 0 {
1103 1108
 		db = db.Where("x.user_org_id = ?", orgid)
1104 1109
 	}
1105
-	err = db.Select("x.id,x.drug_name,x.specification_name,x.warehousing_unit,x.count,x.last_price,x.retail_price,x.manufacturer,x.dealer,x.remark,x.drug_id,x.warehousing_order,x.number,x.batch_number,x.start_time,x.creater,x.checker,x.checker_status,x.checker_time,x.total,x.drug_origin_place,x.expiry_date,x.product_date,x.min_count,t.dose,t.dose_unit,t.max_unit,x.min_unit,x.stock_max_number,x.stock_min_number,x.last_stock_max_number,x.last_stock_min_number,x.inventory_type").Joins("left join sgj_users.sgj_user_admin_role as r on r.id = x.creater").Joins("left join xt_base_drug as t on t.id =x.drug_id").Count(&total).Offset(offset).Limit(limit).Scan(&list).Error
1110
+	if storehouse_id > 0 {
1111
+		db = db.Where("x.storehouse_id = ?", storehouse_id)
1112
+	}
1113
+	err = db.Select("x.id,x.drug_name,x.specification_name,x.warehousing_unit,x.count,x.last_price,x.retail_price,x.manufacturer,x.dealer,x.remark,x.drug_id,x.warehousing_order,x.number,x.batch_number,x.start_time,x.creater,x.checker,x.checker_status,x.checker_time,x.total,x.drug_origin_place,x.expiry_date,x.product_date,x.min_count,x.storehouse_id,t.dose,t.dose_unit,t.max_unit,x.min_unit,x.stock_max_number,x.stock_min_number,x.last_stock_max_number,x.last_stock_min_number,x.inventory_type").Joins("left join sgj_users.sgj_user_admin_role as r on r.id = x.creater").Joins("left join xt_base_drug as t on t.id =x.drug_id").Count(&total).Offset(offset).Limit(limit).Scan(&list).Error
1106 1114
 	return list, total, err
1107 1115
 }
1108 1116
 

File diff suppressed because it is too large
+ 707 - 85
service/stock_service.go


+ 23 - 7
service/supply_service.go ファイルの表示

@@ -764,12 +764,24 @@ func GetSupplySupplyWarehouseId(id int64, orgid int64) (models.WarehousingInfo,
764 764
 	return info, err
765 765
 }
766 766
 
767
+func GetSupplySupplyWarehouseIdSeven(id int64, orgid int64) (info []*models.WarehousingInfo, err error) {
768
+
769
+	err = XTReadDB().Where("supply_warehouse_id = ? and org_id = ? and status = 1", id, orgid).Find(&info).Error
770
+	return info, err
771
+}
772
+
767 773
 func GetDrugSupplyWarehouseId(id int64, orgid int64) (models.DrugWarehouseInfo, error) {
768 774
 	info := models.DrugWarehouseInfo{}
769 775
 	err := XTReadDB().Where("supply_warehouse_id = ? and org_id = ? and status = 1", id, orgid).Find(&info).Error
770 776
 	return info, err
771 777
 }
772 778
 
779
+func GetDrugSupplyWarehouseIdSeven(id int64, orgid int64) (info []*models.DrugWarehouseInfo, err error) {
780
+
781
+	err = XTReadDB().Where("supply_warehouse_id = ? and org_id = ? and status = 1", id, orgid).Find(&info).Error
782
+	return info, err
783
+}
784
+
773 785
 func UpdateDrugSupplyWarehousingInfo(id int64, orgid int64) error {
774 786
 
775 787
 	err := XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("supply_warehouse_id = ? and org_id = ? and status = 1", id, orgid).Updates(map[string]interface{}{"status": 0}).Error
@@ -853,12 +865,12 @@ func CreateDrugFlowSix(drugflow []*models.DrugFlow) (err error) {
853 865
 	if len(drugflow) > 0 {
854 866
 		utx := writeDb.Begin()
855 867
 		if len(drugflow) > 0 {
856
-			thisSQL := "INSERT INTO xt_drug_flow (warehousing_id, drug_id, number,batch_number,count,user_org_id,patient_id,system_time,consumable_type,is_sys,warehousing_order,warehouse_out_id,warehouse_out_order_number,is_edit,cancel_stock_id,cancel_order_number,manufacturer,dealer,creator,update_creator,status,ctime,mtime,price,warehousing_detail_id,warehouse_out_detail_id,cancel_out_detail_id,expire_date,product_date,max_unit,min_unit,supply_warehouse_id,supply_warehouse_detail_info) VALUES "
868
+			thisSQL := "INSERT INTO xt_drug_flow (warehousing_id, drug_id, number,batch_number,count,user_org_id,patient_id,system_time,consumable_type,is_sys,warehousing_order,warehouse_out_id,warehouse_out_order_number,is_edit,cancel_stock_id,cancel_order_number,manufacturer,dealer,creator,update_creator,status,ctime,mtime,price,warehousing_detail_id,warehouse_out_detail_id,cancel_out_detail_id,expire_date,product_date,max_unit,min_unit,supply_warehouse_id,supply_warehouse_detail_info,storehouse_id) VALUES "
857 869
 			insertParams := make([]string, 0)
858 870
 			insertData := make([]interface{}, 0)
859 871
 			for _, info := range drugflow {
860 872
 
861
-				insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
873
+				insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
862 874
 				insertData = append(insertData, info.WarehousingId)
863 875
 				insertData = append(insertData, info.DrugId)
864 876
 				insertData = append(insertData, info.Number)
@@ -893,6 +905,7 @@ func CreateDrugFlowSix(drugflow []*models.DrugFlow) (err error) {
893 905
 				insertData = append(insertData, info.MinUnit)
894 906
 				insertData = append(insertData, info.SupplyWarehouseId)
895 907
 				insertData = append(insertData, info.SupplyWarehouseDetailInfo)
908
+				insertData = append(insertData, info.StorehouseId)
896 909
 			}
897 910
 			thisSQL += strings.Join(insertParams, ", ")
898 911
 			err = utx.Exec(thisSQL, insertData...).Error
@@ -1038,22 +1051,22 @@ func ModfySupplyWarehouseOut(warehousing_id int64, orgid int64) error {
1038 1051
 	return err
1039 1052
 }
1040 1053
 
1041
-func FindWarehousingInfoTwenTy(goodId int64, supply_warehouse_detail_info int64, source int64) (models.WarehousingInfo, error) {
1042
-	fmt.Println("source232232332232323232323", source)
1054
+func FindWarehousingInfoTwenTy(goodId int64, supply_warehouse_detail_info int64, source int64, storehouse_id int64) (models.WarehousingInfo, error) {
1055
+
1043 1056
 	info := models.WarehousingInfo{}
1044 1057
 	var err error
1045 1058
 	if source == 1 {
1046
-		err = XTReadDB().Select(" good_id,sum(stock_count) as stock_count").Where("good_id = ? and status = 1 and supply_warehouse_detail_info =?", goodId, supply_warehouse_detail_info).Find(&info).Error
1059
+		err = XTReadDB().Select(" good_id,sum(stock_count) as stock_count").Where("good_id = ? and status = 1 and supply_warehouse_detail_info =? and storehouse_id = ?", goodId, supply_warehouse_detail_info, storehouse_id).Find(&info).Error
1047 1060
 
1048 1061
 	}
1049 1062
 	if source == 2 {
1050
-		err = XTReadDB().Select(" good_id,sum(stock_count) as stock_count").Where("good_id = ? and status = 1", goodId).Find(&info).Error
1063
+		err = XTReadDB().Select(" good_id,sum(stock_count) as stock_count").Where("good_id = ? and status = 1 and storehouse_id = ?", goodId, storehouse_id).Find(&info).Error
1051 1064
 
1052 1065
 	}
1053 1066
 	return info, err
1054 1067
 }
1055 1068
 
1056
-func GetDrugTotalCountTwenTy(drugid int64, supply_warehouse_detail_info int64, source int64) (list []*models.VmDrugWarehouseInfo, err error) {
1069
+func GetDrugTotalCountTwenTy(drugid int64, supply_warehouse_detail_info int64, source int64, storehouse_id int64) (list []*models.VmDrugWarehouseInfo, err error) {
1057 1070
 
1058 1071
 	if source == 1 {
1059 1072
 		db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1")
@@ -1065,6 +1078,9 @@ func GetDrugTotalCountTwenTy(drugid int64, supply_warehouse_detail_info int64, s
1065 1078
 		if supply_warehouse_detail_info > 0 {
1066 1079
 			db = db.Where("x.supply_warehouse_detail_info = ?", supply_warehouse_detail_info)
1067 1080
 		}
1081
+		if storehouse_id > 0 {
1082
+			db = db.Where("x.storehouse_id= ?", storehouse_id)
1083
+		}
1068 1084
 		err = db.Select("x.drug_id,x.stock_max_number,x.stock_min_number,d.min_number,d.max_unit,d.min_unit,x.max_unit as count_unit,x.supply_warehouse_detail_info").Joins("left join xt_base_drug as d on d.id = x.drug_id").Scan(&list).Error
1069 1085
 	}
1070 1086
 

File diff suppressed because it is too large
+ 1361 - 80
service/warhouse_service.go