Pārlūkot izejas kodu

11月8日库存管理

XMLWAN 3 gadus atpakaļ
vecāks
revīzija
1dcdc73a93
37 mainītis faili ar 7644 papildinājumiem un 810 dzēšanām
  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 Parādīt failu

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

+ 5 - 1
controllers/dialysis_api_controller.go Parādīt failu

3458
 			}
3458
 			}
3459
 
3459
 
3460
 			if template.TemplateId == 47 { //adminInfo.CurrentOrgId == 9538
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
 				record.UltrafiltrationRate = ultrafiltration_rate
3462
 				record.UltrafiltrationRate = ultrafiltration_rate
3463
 			}
3463
 			}
3464
 
3464
 
3490
 
3490
 
3491
 	}
3491
 	}
3492
 
3492
 
3493
+	if template.TemplateId == 47 {
3494
+		record.DisplacementQuantity = record.DisplacementQuantity + record.DisplacementQuantity
3495
+	}
3496
+
3493
 	this.ServeSuccessJSON(map[string]interface{}{
3497
 	this.ServeSuccessJSON(map[string]interface{}{
3494
 		"monitor": record,
3498
 		"monitor": record,
3495
 	})
3499
 	})

+ 5 - 1
controllers/dialysis_record_api_controller.go Parādīt failu

999
 
999
 
1000
 		var tempdispose string
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
 			tempdispose = "引血" + strconv.FormatInt(blood_drawing, 10) + "ml/min"
1007
 			tempdispose = "引血" + strconv.FormatInt(blood_drawing, 10) + "ml/min"
1004
 		}
1008
 		}
1005
 
1009
 

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 478 - 91
controllers/drug_stock_api_contorller.go


+ 27 - 6
controllers/gobal_config_api_controller.go Parādīt failu

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

+ 200 - 71
controllers/his_api_controller.go Parādīt failu

720
 						if len(advices) > 0 {
720
 						if len(advices) > 0 {
721
 							for _, advice := range advices {
721
 							for _, advice := range advices {
722
 								var drug_id int64
722
 								var drug_id int64
723
-								var prescribing_number float64
723
+								//var prescribing_number float64
724
 								var prescribingNumberUnit string
724
 								var prescribingNumberUnit string
725
 								var prescribingNumber string
725
 								var prescribingNumber string
726
+								var prescribing_number_one int64
726
 
727
 
727
 								var adviceId int64
728
 								var adviceId int64
728
 								if advice.(map[string]interface{})["id"] != nil || reflect.TypeOf(advice.(map[string]interface{})["id"]).String() == "float64" {
729
 								if advice.(map[string]interface{})["id"] != nil || reflect.TypeOf(advice.(map[string]interface{})["id"]).String() == "float64" {
730
 								}
731
 								}
731
 								if advice.(map[string]interface{})["prescribing_number"] != nil || reflect.TypeOf(advice.(map[string]interface{})["prescribing_number"]).String() == "string" {
732
 								if advice.(map[string]interface{})["prescribing_number"] != nil || reflect.TypeOf(advice.(map[string]interface{})["prescribing_number"]).String() == "string" {
732
 									prescribing_number_str := advice.(map[string]interface{})["prescribing_number"].(string)
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
 									prescribingNumber = advice.(map[string]interface{})["prescribing_number"].(string)
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
 								if advice.(map[string]interface{})["prescribing_number_unit"] != nil && reflect.TypeOf(advice.(map[string]interface{})["prescribing_number_unit"]).String() == "string" {
739
 								if advice.(map[string]interface{})["prescribing_number_unit"] != nil && reflect.TypeOf(advice.(map[string]interface{})["prescribing_number_unit"]).String() == "string" {
748
 									return
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
 								advicelist, _ := service.GetHisAdviceListByDrugIdEight(drug_id, patient_id, recordDateTime, adviceId)
760
 								advicelist, _ := service.GetHisAdviceListByDrugIdEight(drug_id, patient_id, recordDateTime, adviceId)
759
 
761
 
760
 								//新增处方
762
 								//新增处方
761
 								if advicelist.ID == 0 {
763
 								if advicelist.ID == 0 {
762
-									all_count, _ := strconv.ParseFloat(totals, 64)
764
+									//	all_count, _ := strconv.ParseFloat(totals, 64)
763
 									if prescribingNumberUnit == drug.MinUnit {
765
 									if prescribingNumberUnit == drug.MinUnit {
764
-										if prescribing_number > all_count {
766
+										if prescribing_number_one > drug.SumCount {
765
 											c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
767
 											c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
766
 											return
768
 											return
767
 										}
769
 										}
768
 									} else {
770
 									} else {
769
 										if prescribingNumberUnit == drug.MaxUnit {
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
 												c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
774
 												c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
773
 												return
775
 												return
774
 											}
776
 											}
803
 									//如果修改的数量大于之前修改的数量
805
 									//如果修改的数量大于之前修改的数量
804
 									if (number_count - device_number) > 0 {
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
 											c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
809
 											c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
808
 											return
810
 											return
809
 										}
811
 										}
818
 										if druginfo.CountUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
820
 										if druginfo.CountUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
819
 
821
 
820
 											service.ModefyDrugByWarehouseInfo(druginfo.WarehouseInfoId, number_count)
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
 										if druginfo.CountUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
842
 										if druginfo.CountUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
823
 											var stock_max_number int64
843
 											var stock_max_number int64
826
 											if number_count >= drug.MinNumber {
846
 											if number_count >= drug.MinNumber {
827
 
847
 
828
 												stock_max_number = device_number / drug.MinNumber
848
 												stock_max_number = device_number / drug.MinNumber
849
+
829
 												service.ModefyDrugByWarehouseInfo(druginfo.WarehouseInfoId, stock_max_number)
850
 												service.ModefyDrugByWarehouseInfo(druginfo.WarehouseInfoId, stock_max_number)
851
+
830
 												stock_min_number = device_number % drug.MinNumber
852
 												stock_min_number = device_number % drug.MinNumber
831
 												service.ModefyDrugByWarehouseInfoOne(druginfo.WarehouseInfoId, stock_min_number)
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
 											} else {
872
 											} else {
834
 
873
 
835
 												service.ModefyDrugByWarehouseInfoOne(druginfo.WarehouseInfoId, device_number)
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
 										if druginfo.CountUnit == drug.MaxUnit && druginfo.CountUnit == drug.MinUnit && drug.MaxUnit == drug.MinUnit {
895
 										if druginfo.CountUnit == drug.MaxUnit && druginfo.CountUnit == drug.MinUnit && drug.MaxUnit == drug.MinUnit {
840
 											service.ModefyDrugByWarehouseInfo(druginfo.WarehouseInfoId, device_number)
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
 										service.DeleteDrugAutoWarehouseSeven(drug_id, patient_id, recordDateTime, adviceId)
916
 										service.DeleteDrugAutoWarehouseSeven(drug_id, patient_id, recordDateTime, adviceId)
867
 
940
 
868
 								var project_id int64
941
 								var project_id int64
869
 								var project_type int64
942
 								var project_type int64
870
-								var totals float64
943
+								//var totals float64
871
 								var project_name string
944
 								var project_name string
872
 								var parsetotal int64
945
 								var parsetotal int64
873
 								var id int64
946
 								var id int64
883
 								}
956
 								}
884
 								if project.(map[string]interface{})["total"] != nil || reflect.TypeOf(project.(map[string]interface{})["total"]).String() == "string" {
957
 								if project.(map[string]interface{})["total"] != nil || reflect.TypeOf(project.(map[string]interface{})["total"]).String() == "string" {
885
 									total, _ := project.(map[string]interface{})["total"].(string)
958
 									total, _ := project.(map[string]interface{})["total"].(string)
886
-									totals, _ = strconv.ParseFloat(total, 64)
959
+									//	totals, _ = strconv.ParseFloat(total, 64)
887
 									parsetotal, _ = strconv.ParseInt(total, 10, 64)
960
 									parsetotal, _ = strconv.ParseInt(total, 10, 64)
888
 								}
961
 								}
889
 
962
 
902
 
975
 
903
 									if len(goodWarehouseInfo) == 0 {
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
 											c.ServeDynamicFailJsonSend(project_name + "库存不足")
992
 											c.ServeDynamicFailJsonSend(project_name + "库存不足")
914
 											return
993
 											return
915
 										}
994
 										}
919
 										for _, item := range goodList {
998
 										for _, item := range goodList {
920
 											//回退库存
999
 											//回退库存
921
 											service.ModefyWarehouseInfo(item.Count, item.WarehouseInfotId)
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
 										service.DeleteAutoWarehouse(patient_id, recordDateTime)
1013
 										service.DeleteAutoWarehouse(patient_id, recordDateTime)
937
 											for _, item := range goodList {
1026
 											for _, item := range goodList {
938
 												//回退库存
1027
 												//回退库存
939
 												service.ModefyWarehouseInfo(item.Count, item.WarehouseInfotId)
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
 											service.DeleteAutoWarehouse(patient_id, recordDateTime)
1041
 											service.DeleteAutoWarehouse(patient_id, recordDateTime)
1641
 	_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
1740
 	_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
1642
 
1741
 
1643
 	_, stockConfig := service.FindAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
1742
 	_, stockConfig := service.FindAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
1644
-
1743
+	houseConfig, _ := service.GetAllStoreHouseConfig(c.GetAdminUserInfo().CurrentOrgId)
1645
 	if len(projects) > 0 {
1744
 	if len(projects) > 0 {
1646
 		for _, item := range projects {
1745
 		for _, item := range projects {
1647
 			service.DeletePrintInfo(item.ID) //删除打印信息
1746
 			service.DeletePrintInfo(item.ID) //删除打印信息
1661
 					orderNumber := "CKTKD" + strconv.FormatInt(c.GetAdminUserInfo().CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
1760
 					orderNumber := "CKTKD" + strconv.FormatInt(c.GetAdminUserInfo().CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
1662
 
1761
 
1663
 					cancelStock := models.CancelStock{
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
 					_, msgerrkonde := service.GetCancelStockDetailByOrderNumberOne(item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
1773
 					_, msgerrkonde := service.GetCancelStockDetailByOrderNumberOne(item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
1674
 					if msgerrkonde == gorm.ErrRecordNotFound {
1774
 					if msgerrkonde == gorm.ErrRecordNotFound {
1704
 							WarehouseInfoId: info.WarehouseInfotId,
1804
 							WarehouseInfoId: info.WarehouseInfotId,
1705
 							PatientId:       info.PatientId,
1805
 							PatientId:       info.PatientId,
1706
 							RecordDate:      info.SysRecordTime,
1806
 							RecordDate:      info.SysRecordTime,
1807
+							StorehouseId:    houseConfig.StorehouseOutInfo,
1707
 						}
1808
 						}
1708
 
1809
 
1709
 						service.CreateCancelStockInfoOne(&cancelStockInfo)
1810
 						service.CreateCancelStockInfoOne(&cancelStockInfo)
1740
 							CancelOutDetailId:       cancelInfo.ID,
1841
 							CancelOutDetailId:       cancelInfo.ID,
1741
 							ProductDate:             info.ProductDate,
1842
 							ProductDate:             info.ProductDate,
1742
 							ExpireDate:              info.ExpiryDate,
1843
 							ExpireDate:              info.ExpiryDate,
1844
+							StorehouseId:            houseConfig.StorehouseOutInfo,
1743
 						}
1845
 						}
1744
 						service.CreateStockFlowOne(flow)
1846
 						service.CreateStockFlowOne(flow)
1745
 
1847
 
1757
 						}
1859
 						}
1758
 						//回退库存
1860
 						//回退库存
1759
 						service.UpDateWarehouseInfoByStockDelete(info.WarehouseInfotId, total_count)
1861
 						service.UpDateWarehouseInfoByStockDelete(info.WarehouseInfotId, total_count)
1760
-
1862
+						service.ModifyGoodAddInformation(info.GoodId, total_count, info.OrgId)
1761
 						//查询今日该耗材退库数量
1863
 						//查询今日该耗材退库数量
1762
 						cancelInfoOne, _ := service.GetCancelStockInfoByPatientId(info.PatientId, item.ProjectId, info.SysRecordTime)
1864
 						cancelInfoOne, _ := service.GetCancelStockInfoByPatientId(info.PatientId, item.ProjectId, info.SysRecordTime)
1763
 						var cancel_Count int64
1865
 						var cancel_Count int64
1792
 									Manufacturer:            0,
1894
 									Manufacturer:            0,
1793
 									Type:                    1,
1895
 									Type:                    1,
1794
 									IsSys:                   1,
1896
 									IsSys:                   1,
1897
+									StorehouseId:            houseConfig.StorehouseOutInfo,
1795
 								}
1898
 								}
1796
 								err := service.AddSigleWarehouseOut(&warehouseOut)
1899
 								err := service.AddSigleWarehouseOut(&warehouseOut)
1797
 								if err != nil {
1900
 								if err != nil {
1799
 									return
1902
 									return
1800
 								}
1903
 								}
1801
 								prepare := &models.DialysisBeforePrepare{
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
 								service.ConsumablesDelivery(c.GetAdminUserInfo().CurrentOrgId, info.PatientId, info.SysRecordTime, prepare, &warehouseOut, cha_count)
1914
 								service.ConsumablesDelivery(c.GetAdminUserInfo().CurrentOrgId, info.PatientId, info.SysRecordTime, prepare, &warehouseOut, cha_count)
1811
 							} else if err == nil {
1915
 							} else if err == nil {
1812
 
1916
 
1813
 								prepare := &models.DialysisBeforePrepare{
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
 								service.ConsumablesDelivery(c.GetAdminUserInfo().CurrentOrgId, info.PatientId, info.SysRecordTime, prepare, &out, cha_count)
1927
 								service.ConsumablesDelivery(c.GetAdminUserInfo().CurrentOrgId, info.PatientId, info.SysRecordTime, prepare, &out, cha_count)
1866
 						}
1971
 						}
1867
 
1972
 
1868
 						service.UpdateDrugWarehouse(info.WarehouseInfoId, warehouseInfo)
1973
 						service.UpdateDrugWarehouse(info.WarehouseInfoId, warehouseInfo)
1869
-
1974
+						service.ModifyDrugAddInformation(info.DrugId, warehouseInfo.StockMinNumber, warehouseInfo.OrgId)
1870
 						adminUserInfo := c.GetAdminUserInfo()
1975
 						adminUserInfo := c.GetAdminUserInfo()
1871
 						operation_time := time.Now().Unix()
1976
 						operation_time := time.Now().Unix()
1872
 						creater := adminUserInfo.AdminUser.Id
1977
 						creater := adminUserInfo.AdminUser.Id
1889
 							Dealer:       info.Dealer,
1994
 							Dealer:       info.Dealer,
1890
 							Manufacturer: info.Manufacturer,
1995
 							Manufacturer: info.Manufacturer,
1891
 							Type:         1,
1996
 							Type:         1,
1997
+							StorehouseId: houseConfig.DrugStorehouseOut,
1892
 						}
1998
 						}
1893
 						service.AddSigleDrugCancelStock(&cancelStock)
1999
 						service.AddSigleDrugCancelStock(&cancelStock)
1894
 
2000
 
1917
 							ProductDate:      info.ProductDate,
2023
 							ProductDate:      info.ProductDate,
1918
 							ExpiryDate:       info.ExpiryDate,
2024
 							ExpiryDate:       info.ExpiryDate,
1919
 							BatchNumberId:    info.WarehouseInfoId,
2025
 							BatchNumberId:    info.WarehouseInfoId,
2026
+							StorehouseId:     houseConfig.DrugStorehouseOut,
1920
 						}
2027
 						}
1921
 
2028
 
1922
 						flow := models.DrugFlow{
2029
 						flow := models.DrugFlow{
1952
 							MaxUnit:                 info.CountUnit,
2059
 							MaxUnit:                 info.CountUnit,
1953
 							MinUnit:                 "",
2060
 							MinUnit:                 "",
1954
 							AdviceId:                info.AdviceId,
2061
 							AdviceId:                info.AdviceId,
2062
+							StorehouseId:            houseConfig.DrugStorehouseOut,
1955
 						}
2063
 						}
1956
 						service.CreatedCancelStock(cancelStockInfo)
2064
 						service.CreatedCancelStock(cancelStockInfo)
1957
 						service.CreateDrugFlowOne(flow)
2065
 						service.CreateDrugFlowOne(flow)
1968
 						if item.PrescribingNumberUnit == drug.MaxUnit {
2076
 						if item.PrescribingNumberUnit == drug.MaxUnit {
1969
 							warehouseInfo := models.DrugWarehouseInfo{
2077
 							warehouseInfo := models.DrugWarehouseInfo{
1970
 								StockMaxNumber: prescribingNumber,
2078
 								StockMaxNumber: prescribingNumber,
2079
+								StorehouseId:   houseConfig.DrugStorehouseOut,
1971
 							}
2080
 							}
1972
 							service.UpdateDrugWarehouseOne(info.WarehouseInfoId, warehouseInfo)
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
 						adminUserInfo := c.GetAdminUserInfo()
2087
 						adminUserInfo := c.GetAdminUserInfo()
1995
 							Dealer:       info.Dealer,
2106
 							Dealer:       info.Dealer,
1996
 							Manufacturer: info.Manufacturer,
2107
 							Manufacturer: info.Manufacturer,
1997
 							Type:         1,
2108
 							Type:         1,
2109
+							StorehouseId: houseConfig.DrugStorehouseOut,
1998
 						}
2110
 						}
1999
 						service.AddSigleDrugCancelStock(&cancelStock)
2111
 						service.AddSigleDrugCancelStock(&cancelStock)
2000
 
2112
 
2024
 							ProductDate:      info.ProductDate,
2136
 							ProductDate:      info.ProductDate,
2025
 							ExpiryDate:       info.ExpiryDate,
2137
 							ExpiryDate:       info.ExpiryDate,
2026
 							BatchNumberId:    info.WarehouseInfoId,
2138
 							BatchNumberId:    info.WarehouseInfoId,
2139
+							StorehouseId:     houseConfig.DrugStorehouseOut,
2027
 						}
2140
 						}
2028
 
2141
 
2029
 						flow := models.DrugFlow{
2142
 						flow := models.DrugFlow{
2060
 							MaxUnit:                 info.CountUnit,
2173
 							MaxUnit:                 info.CountUnit,
2061
 							MinUnit:                 "",
2174
 							MinUnit:                 "",
2062
 							AdviceId:                info.AdviceId,
2175
 							AdviceId:                info.AdviceId,
2176
+							StorehouseId:            houseConfig.DrugStorehouseOut,
2063
 						}
2177
 						}
2064
 						service.CreatedCancelStock(cancelStockInfo)
2178
 						service.CreatedCancelStock(cancelStockInfo)
2065
 						service.CreateDrugFlowOne(flow)
2179
 						service.CreateDrugFlowOne(flow)
2110
 		if drugStockConfig.IsOpen == 1 {
2224
 		if drugStockConfig.IsOpen == 1 {
2111
 			//判断该医嘱是否执行了
2225
 			//判断该医嘱是否执行了
2112
 			if advice.ExecutionState == 1 {
2226
 			if advice.ExecutionState == 1 {
2113
-
2227
+				houseConfig, _ := service.GetAllStoreHouseConfig(advice.UserOrgId)
2114
 				//查询该病人该药品是否有库存记录
2228
 				//查询该病人该药品是否有库存记录
2115
 				info, errcode := service.GetDrugAutoWarehouseOutSeven(advice.PatientId, advice.AdviceDate, advice.DrugId, advice.ID)
2229
 				info, errcode := service.GetDrugAutoWarehouseOutSeven(advice.PatientId, advice.AdviceDate, advice.DrugId, advice.ID)
2116
 				if errcode == gorm.ErrRecordNotFound {
2230
 				if errcode == gorm.ErrRecordNotFound {
2129
 						}
2243
 						}
2130
 
2244
 
2131
 						service.UpdateDrugWarehouse(info.WarehouseInfoId, warehouseInfo)
2245
 						service.UpdateDrugWarehouse(info.WarehouseInfoId, warehouseInfo)
2132
-
2246
+						service.ModifyDrugAddInformation(info.DrugId, warehouseInfo.StockMinNumber, info.OrgId)
2133
 						adminUserInfo := c.GetAdminUserInfo()
2247
 						adminUserInfo := c.GetAdminUserInfo()
2134
 						operation_time := time.Now().Unix()
2248
 						operation_time := time.Now().Unix()
2135
 						creater := adminUserInfo.AdminUser.Id
2249
 						creater := adminUserInfo.AdminUser.Id
2152
 							Dealer:       info.Dealer,
2266
 							Dealer:       info.Dealer,
2153
 							Manufacturer: info.Manufacturer,
2267
 							Manufacturer: info.Manufacturer,
2154
 							Type:         1,
2268
 							Type:         1,
2269
+							StorehouseId: houseConfig.DrugStorehouseOut,
2155
 						}
2270
 						}
2156
 						service.AddSigleDrugCancelStock(&cancelStock)
2271
 						service.AddSigleDrugCancelStock(&cancelStock)
2157
 
2272
 
2180
 							ProductDate:      info.ProductDate,
2295
 							ProductDate:      info.ProductDate,
2181
 							ExpiryDate:       info.ExpiryDate,
2296
 							ExpiryDate:       info.ExpiryDate,
2182
 							BatchNumberId:    info.WarehouseInfoId,
2297
 							BatchNumberId:    info.WarehouseInfoId,
2298
+							StorehouseId:     houseConfig.DrugStorehouseOut,
2183
 						}
2299
 						}
2184
 
2300
 
2185
 						flow := models.DrugFlow{
2301
 						flow := models.DrugFlow{
2215
 							MaxUnit:                 info.CountUnit,
2331
 							MaxUnit:                 info.CountUnit,
2216
 							MinUnit:                 "",
2332
 							MinUnit:                 "",
2217
 							AdviceId:                info.AdviceId,
2333
 							AdviceId:                info.AdviceId,
2334
+							StorehouseId:            houseConfig.DrugStorehouseOut,
2218
 						}
2335
 						}
2219
 						service.CreatedCancelStock(cancelStockInfo)
2336
 						service.CreatedCancelStock(cancelStockInfo)
2220
 						service.CreateDrugFlowOne(flow)
2337
 						service.CreateDrugFlowOne(flow)
2233
 							warehouseInfo := models.DrugWarehouseInfo{
2350
 							warehouseInfo := models.DrugWarehouseInfo{
2234
 								StockMaxNumber: prescribingNumber,
2351
 								StockMaxNumber: prescribingNumber,
2235
 							}
2352
 							}
2353
+							var sum_count int64
2354
+							sum_count = prescribingNumber * drug.MinNumber
2236
 							service.UpdateDrugWarehouseOne(info.WarehouseInfoId, warehouseInfo)
2355
 							service.UpdateDrugWarehouseOne(info.WarehouseInfoId, warehouseInfo)
2237
-
2356
+							service.ModifyDrugAddInformation(info.DrugId, sum_count, info.OrgId)
2238
 						}
2357
 						}
2239
 
2358
 
2240
 						adminUserInfo := c.GetAdminUserInfo()
2359
 						adminUserInfo := c.GetAdminUserInfo()
2259
 							Dealer:       info.Dealer,
2378
 							Dealer:       info.Dealer,
2260
 							Manufacturer: info.Manufacturer,
2379
 							Manufacturer: info.Manufacturer,
2261
 							Type:         1,
2380
 							Type:         1,
2381
+							StorehouseId: houseConfig.DrugStorehouseOut,
2262
 						}
2382
 						}
2263
 						service.AddSigleDrugCancelStock(&cancelStock)
2383
 						service.AddSigleDrugCancelStock(&cancelStock)
2264
 
2384
 
2287
 							ProductDate:      info.ProductDate,
2407
 							ProductDate:      info.ProductDate,
2288
 							ExpiryDate:       info.ExpiryDate,
2408
 							ExpiryDate:       info.ExpiryDate,
2289
 							BatchNumberId:    info.WarehouseInfoId,
2409
 							BatchNumberId:    info.WarehouseInfoId,
2410
+							StorehouseId:     houseConfig.DrugStorehouseOut,
2290
 						}
2411
 						}
2291
 
2412
 
2292
 						flow := models.DrugFlow{
2413
 						flow := models.DrugFlow{
2322
 							MaxUnit:                 info.CountUnit,
2443
 							MaxUnit:                 info.CountUnit,
2323
 							MinUnit:                 "",
2444
 							MinUnit:                 "",
2324
 							AdviceId:                info.AdviceId,
2445
 							AdviceId:                info.AdviceId,
2446
+							StorehouseId:            houseConfig.DrugStorehouseOut,
2325
 						}
2447
 						}
2326
 						service.CreatedCancelStock(cancelStockInfo)
2448
 						service.CreatedCancelStock(cancelStockInfo)
2327
 						service.CreateDrugFlowOne(flow)
2449
 						service.CreateDrugFlowOne(flow)
2366
 		if project.Type == 3 {
2488
 		if project.Type == 3 {
2367
 			good, _ := service.FindGoodInfoByIdTwo(project.ProjectId)
2489
 			good, _ := service.FindGoodInfoByIdTwo(project.ProjectId)
2368
 			f_count, _ := strconv.ParseFloat(project.Count, 64)
2490
 			f_count, _ := strconv.ParseFloat(project.Count, 64)
2491
+			houseConfig, _ := service.GetAllStoreHouseConfig(c.GetAdminUserInfo().CurrentOrgId)
2369
 			good.Total = good.Total + f_count
2492
 			good.Total = good.Total + f_count
2370
 			service.UpdateGoodInfo(&good)
2493
 			service.UpdateGoodInfo(&good)
2371
 
2494
 
2379
 			orderNumber := "CKTKD" + strconv.FormatInt(adminInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
2502
 			orderNumber := "CKTKD" + strconv.FormatInt(adminInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
2380
 
2503
 
2381
 			cancelStock := models.CancelStock{
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
 			_, msgerrkonde := service.GetCancelStockDetailByOrderNumberOne(project.RecordDate, adminInfo.CurrentOrgId)
2515
 			_, msgerrkonde := service.GetCancelStockDetailByOrderNumberOne(project.RecordDate, adminInfo.CurrentOrgId)
2392
 			if msgerrkonde == gorm.ErrRecordNotFound {
2516
 			if msgerrkonde == gorm.ErrRecordNotFound {
2423
 					WarehouseInfoId: info.WarehouseInfotId,
2547
 					WarehouseInfoId: info.WarehouseInfotId,
2424
 					PatientId:       info.PatientId,
2548
 					PatientId:       info.PatientId,
2425
 					RecordDate:      info.SysRecordTime,
2549
 					RecordDate:      info.SysRecordTime,
2550
+					StorehouseId:    houseConfig.StorehouseOutInfo,
2426
 				}
2551
 				}
2427
 
2552
 
2428
 				service.CreateCancelStockInfoOne(&cancelStockInfo)
2553
 				service.CreateCancelStockInfoOne(&cancelStockInfo)
2459
 					CancelOutDetailId:       cancelInfo.ID,
2584
 					CancelOutDetailId:       cancelInfo.ID,
2460
 					ProductDate:             info.ProductDate,
2585
 					ProductDate:             info.ProductDate,
2461
 					ExpireDate:              info.ExpiryDate,
2586
 					ExpireDate:              info.ExpiryDate,
2587
+					StorehouseId:            houseConfig.StorehouseOutInfo,
2462
 				}
2588
 				}
2463
 				service.CreateStockFlowOne(flow)
2589
 				service.CreateStockFlowOne(flow)
2464
 
2590
 
2476
 				}
2602
 				}
2477
 				//回退库存
2603
 				//回退库存
2478
 				service.UpDateWarehouseInfoByStockDelete(info.WarehouseInfotId, total_count)
2604
 				service.UpDateWarehouseInfoByStockDelete(info.WarehouseInfotId, total_count)
2479
-
2605
+				service.ModifyGoodAddInformation(info.GoodId, total_count, info.OrgId)
2480
 				//查询今日该耗材退库数量
2606
 				//查询今日该耗材退库数量
2481
 				cancelInfoOne, _ := service.GetCancelStockInfoByPatientId(info.PatientId, project.ProjectId, info.SysRecordTime)
2607
 				cancelInfoOne, _ := service.GetCancelStockInfoByPatientId(info.PatientId, project.ProjectId, info.SysRecordTime)
2482
 				var cancel_count int64
2608
 				var cancel_count int64
2511
 							Manufacturer:            0,
2637
 							Manufacturer:            0,
2512
 							Type:                    1,
2638
 							Type:                    1,
2513
 							IsSys:                   1,
2639
 							IsSys:                   1,
2640
+							StorehouseId:            houseConfig.StorehouseOutInfo,
2514
 						}
2641
 						}
2515
 						err := service.AddSigleWarehouseOut(&warehouseOut)
2642
 						err := service.AddSigleWarehouseOut(&warehouseOut)
2516
 						if err != nil {
2643
 						if err != nil {
2518
 							return
2645
 							return
2519
 						}
2646
 						}
2520
 						prepare := &models.DialysisBeforePrepare{
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
 						service.ConsumablesDelivery(adminInfo.CurrentOrgId, info.PatientId, info.SysRecordTime, prepare, &warehouseOut, cha_count)
2657
 						service.ConsumablesDelivery(adminInfo.CurrentOrgId, info.PatientId, info.SysRecordTime, prepare, &warehouseOut, cha_count)
2530
 					} else if err == nil {
2658
 					} else if err == nil {
2531
 						prepare := &models.DialysisBeforePrepare{
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
 						service.ConsumablesDelivery(adminInfo.CurrentOrgId, info.PatientId, info.SysRecordTime, prepare, &out, cha_count)
2669
 						service.ConsumablesDelivery(adminInfo.CurrentOrgId, info.PatientId, info.SysRecordTime, prepare, &out, cha_count)

+ 1 - 1
controllers/mobile_api_controllers/check_weight_api_controller.go Parādīt failu

264
 
264
 
265
 	template, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
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
 		dewater_amount = dewater_amount * 1000
268
 		dewater_amount = dewater_amount * 1000
269
 	}
269
 	}
270
 
270
 

+ 235 - 102
controllers/mobile_api_controllers/dialysis_api_controller.go Parādīt failu

2254
 
2254
 
2255
 	var tempdispose string
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
 		tempdispose = "引血" + strconv.FormatInt(blood_drawing, 10) + "ml/min"
2262
 		tempdispose = "引血" + strconv.FormatInt(blood_drawing, 10) + "ml/min"
2259
 	}
2263
 	}
2260
 
2264
 
2885
 				record.UltrafiltrationRate = ultrafiltration_rate
2889
 				record.UltrafiltrationRate = ultrafiltration_rate
2886
 			}
2890
 			}
2887
 
2891
 
2888
-			if template.TemplateId == 41 {
2892
+			if template.TemplateId == 41 || template.TemplateId == 47 {
2889
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 60 / float64(totalMin) * 1000)
2893
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 60 / float64(totalMin) * 1000)
2890
 				record.UltrafiltrationRate = ultrafiltration_rate
2894
 				record.UltrafiltrationRate = ultrafiltration_rate
2891
 			}
2895
 			}
2894
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 60 / float64(totalMin))
2898
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 60 / float64(totalMin))
2895
 				record.UltrafiltrationRate = ultrafiltration_rate
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
 			if template.TemplateId == 47 {
2906
 			if template.TemplateId == 47 {
2899
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 60 / float64(totalMin))
2907
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 60 / float64(totalMin))
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
 		if ultrafiltration_rate > 0 && adminInfo.Org.Id != 9538 {
2924
 		if ultrafiltration_rate > 0 && adminInfo.Org.Id != 9538 {
2917
 			ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
2925
 			ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
2918
 			record.UltrafiltrationVolume = ultrafiltration_volume
2926
 			record.UltrafiltrationVolume = ultrafiltration_volume
2920
 		}
2928
 		}
2921
 	}
2929
 	}
2922
 
2930
 
2931
+	if template.TemplateId == 47 {
2932
+		record.DisplacementQuantity = record.DisplacementQuantity + record.DisplacementQuantity
2933
+	}
2934
+
2923
 	this.ServeSuccessJSON(map[string]interface{}{
2935
 	this.ServeSuccessJSON(map[string]interface{}{
2924
 		"monitor": record,
2936
 		"monitor": record,
2925
 	})
2937
 	})
3894
 		return
3906
 		return
3895
 	}
3907
 	}
3896
 
3908
 
3909
+	houseConfig, _ := service.GetAllStoreHouseConfig(adminUser.Org.Id)
3910
+
3897
 	var beforePrepares []*models.DialysisBeforePrepareGoods
3911
 	var beforePrepares []*models.DialysisBeforePrepareGoods
3898
 	var newBeforePrepares []*models.NewDialysisBeforePrepareGoods
3912
 	var newBeforePrepares []*models.NewDialysisBeforePrepareGoods
3899
 	var dialysisBefor []*models.DialysisBeforePrepare
3913
 	var dialysisBefor []*models.DialysisBeforePrepare
3929
 				fmt.Println("commdity", commdity_code)
3943
 				fmt.Println("commdity", commdity_code)
3930
 
3944
 
3931
 				prepareGoods := &models.DialysisBeforePrepareGoods{
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
 				beforePrepares = append(beforePrepares, prepareGoods)
3952
 				beforePrepares = append(beforePrepares, prepareGoods)
3938
 
3953
 
3939
 				newPrepareGoods := &models.NewDialysisBeforePrepareGoods{
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
 				newBeforePrepares = append(newBeforePrepares, newPrepareGoods)
3961
 				newBeforePrepares = append(newBeforePrepares, newPrepareGoods)
3955
 					Ctime:        time.Now().Unix(),
3971
 					Ctime:        time.Now().Unix(),
3956
 					Creater:      adminUser.AdminUser.Id,
3972
 					Creater:      adminUser.AdminUser.Id,
3957
 					CommdityCode: commdity_code,
3973
 					CommdityCode: commdity_code,
3974
+					StorehouseId: houseConfig.StorehouseOutInfo,
3958
 				}
3975
 				}
3959
 
3976
 
3960
 				dialysisBefor = append(dialysisBefor, prepare)
3977
 				dialysisBefor = append(dialysisBefor, prepare)
3964
 
3981
 
3965
 		//查询是否有库存
3982
 		//查询是否有库存
3966
 		for _, item := range dialysisBefor {
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
 			if err == gorm.ErrRecordNotFound {
3987
 			if err == gorm.ErrRecordNotFound {
3970
 				goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
3988
 				goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
4002
 					Creater:      item.Creater,
4020
 					Creater:      item.Creater,
4003
 					CommdityCode: item.CommdityCode,
4021
 					CommdityCode: item.CommdityCode,
4004
 					Status:       1,
4022
 					Status:       1,
4023
+					StorehouseId: houseConfig.StorehouseOutInfo,
4005
 				}
4024
 				}
4006
 				//先清除再插入
4025
 				//先清除再插入
4007
 				service.DeleteDialysisBefor(adminUser.Org.Id, patient_id, record_time, item.GoodId, item.GoodTypeId)
4026
 				service.DeleteDialysisBefor(adminUser.Org.Id, patient_id, record_time, item.GoodId, item.GoodTypeId)
4008
 				err = service.CreateDialysisBeforePrepareOne(&dialyPrepareOne)
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
 			if err == nil {
4039
 			if err == nil {
4012
 				c.ServeSuccessJSON(map[string]interface{}{
4040
 				c.ServeSuccessJSON(map[string]interface{}{
4040
 
4068
 
4041
 					for _, it := range list {
4069
 					for _, it := range list {
4042
 						prepare := models.DialysisBeforePrepare{
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
 						service.DeleteDialysisBefor(adminUser.Org.Id, patient_id, record_time, item.GoodId, item.GoodTypeId)
4083
 						service.DeleteDialysisBefor(adminUser.Org.Id, patient_id, record_time, item.GoodId, item.GoodTypeId)
4081
 
4110
 
4082
 						for _, it := range list {
4111
 						for _, it := range list {
4083
 							prepare := models.DialysisBeforePrepare{
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
 							service.DeleteDialysisBefor(adminUser.Org.Id, patient_id, record_time, item.GoodId, item.GoodTypeId)
4125
 							service.DeleteDialysisBefor(adminUser.Org.Id, patient_id, record_time, item.GoodId, item.GoodTypeId)
4096
 
4126
 
4097
 							service.CreateDialysisBeforePrepareOne(&prepare)
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
 
4146
 
4108
 						for _, it := range list {
4147
 						for _, it := range list {
4109
 							prepare := models.DialysisBeforePrepare{
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
 							service.DeleteDialysisBefor(adminUser.Org.Id, patient_id, record_time, item.GoodId, item.GoodTypeId)
4161
 							service.DeleteDialysisBefor(adminUser.Org.Id, patient_id, record_time, item.GoodId, item.GoodTypeId)
4122
 
4162
 
4123
 							service.CreateDialysisBeforePrepareOne(&prepare)
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
 						if err != nil {
4175
 						if err != nil {
4127
 							goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
4176
 							goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
4189
 	consumables = RemoveRepeatedGood(consumables)
4238
 	consumables = RemoveRepeatedGood(consumables)
4190
 
4239
 
4191
 	if record.IsOpen == 1 {
4240
 	if record.IsOpen == 1 {
4192
-
4241
+		houseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
4193
 		//查询是否有库存
4242
 		//查询是否有库存
4194
 		for _, item := range consumables {
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
 			if item.Count > warehouse.Count {
4246
 			if item.Count > warehouse.Count {
4198
 				goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
4247
 				goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
4230
 				Manufacturer:            0,
4279
 				Manufacturer:            0,
4231
 				Type:                    1,
4280
 				Type:                    1,
4232
 				IsSys:                   1,
4281
 				IsSys:                   1,
4282
+				StorehouseId:            houseConfig.StorehouseOutInfo,
4233
 			}
4283
 			}
4234
 			err := service.AddSigleWarehouseOut(&warehouseOut)
4284
 			err := service.AddSigleWarehouseOut(&warehouseOut)
4235
 			if err != nil {
4285
 			if err != nil {
4248
 				}
4298
 				}
4249
 				for _, item := range list {
4299
 				for _, item := range list {
4250
 					prepare := models.DialysisBeforePrepare{
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
 					service.DeleteDialysisBefor(adminInfo.Org.Id, patient_id, record_time, item.GoodId, item.GoodTypeId)
4313
 					service.DeleteDialysisBefor(adminInfo.Org.Id, patient_id, record_time, item.GoodId, item.GoodTypeId)
4263
 					service.CreateDialysisBeforePrepareOne(&prepare)
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
 				}
4337
 				}
4277
 				for _, item := range list {
4338
 				for _, item := range list {
4278
 					prepare := models.DialysisBeforePrepare{
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
 					err = service.DeleteDialysisBefor(adminInfo.Org.Id, patient_id, record_time, item.GoodId, item.GoodTypeId)
4353
 					err = service.DeleteDialysisBefor(adminInfo.Org.Id, patient_id, record_time, item.GoodId, item.GoodTypeId)
4292
 					service.CreateDialysisBeforePrepareOne(&prepare)
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
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4406
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4332
 		return
4407
 		return
4333
 	}
4408
 	}
4334
-
4409
+	houseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
4335
 	var beforePrepares []*models.DialysisBeforePrepareGoods
4410
 	var beforePrepares []*models.DialysisBeforePrepareGoods
4336
 
4411
 
4337
 	var newBeforePrepares []*models.NewDialysisBeforePrepareGoods
4412
 	var newBeforePrepares []*models.NewDialysisBeforePrepareGoods
4375
 					fmt.Println(commdity_code)
4450
 					fmt.Println(commdity_code)
4376
 
4451
 
4377
 					prepareGoods := &models.DialysisBeforePrepareGoods{
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
 					beforePrepares = append(beforePrepares, prepareGoods)
4459
 					beforePrepares = append(beforePrepares, prepareGoods)
4384
 
4460
 
4385
 					newPrepareGoods := &models.NewDialysisBeforePrepareGoods{
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
 					newBeforePrepares = append(newBeforePrepares, newPrepareGoods)
4468
 					newBeforePrepares = append(newBeforePrepares, newPrepareGoods)
4404
 					if item.Count < goodInfo.Count {
4481
 					if item.Count < goodInfo.Count {
4405
 						//出库
4482
 						//出库
4406
 						err = ConsumablesDeliveryTotalSeven(adminInfo.Org.Id, patient_id, record_time, beforePrepares, adminInfo.AdminUser.Id, item.Count)
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
 						break
4493
 						break
4408
 					}
4494
 					}
4409
 
4495
 
4449
 							return
4535
 							return
4450
 						} else {
4536
 						} else {
4451
 							err = ConsumablesDeliveryTotalSix(adminInfo.Org.Id, patient_id, record_time, beforePrepares, newBeforePrepares, adminInfo.AdminUser.Id)
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
 							break
4547
 							break
4453
 						}
4548
 						}
4454
 					}
4549
 					}
4459
 
4554
 
4460
 				for _, it := range list {
4555
 				for _, it := range list {
4461
 					prepare := models.DialysisBeforePrepare{
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
 					service.DeleteDialysisBefor(adminInfo.Org.Id, patient_id, record_time, it.GoodId, it.GoodTypeId)
4569
 					service.DeleteDialysisBefor(adminInfo.Org.Id, patient_id, record_time, it.GoodId, it.GoodTypeId)
4474
 
4570
 
4475
 					service.CreateDialysisBeforePrepareOne(&prepare)
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
 					if err != nil {
4583
 					if err != nil {
4478
 						goodObj, _ := service.GetGoodInformationByGoodId(it.GoodId)
4584
 						goodObj, _ := service.GetGoodInformationByGoodId(it.GoodId)
4548
 				goodUser, _ := service.GetLastDialysisGoods(item.PatientId, adminUser.Org.Id, date.Unix())
4654
 				goodUser, _ := service.GetLastDialysisGoods(item.PatientId, adminUser.Org.Id, date.Unix())
4549
 
4655
 
4550
 				lastGoodUserDetial, _ := service.GetLastDialysisBeforePrepare(item.PatientId, adminUser.Org.Id, date.Unix())
4656
 				lastGoodUserDetial, _ := service.GetLastDialysisBeforePrepare(item.PatientId, adminUser.Org.Id, date.Unix())
4551
-				fmt.Println("GOOD333232323223322332232332232323322323", lastGoodUserDetial)
4552
 				item.LastAutomaticReduceDetail = goodUser
4657
 				item.LastAutomaticReduceDetail = goodUser
4553
 				item.LastDialysisBeforePrepare = lastGoodUserDetial
4658
 				item.LastDialysisBeforePrepare = lastGoodUserDetial
4554
 				item.Project = project
4659
 				item.Project = project
4689
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4794
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4690
 		return
4795
 		return
4691
 	}
4796
 	}
4797
+	houseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
4692
 
4798
 
4693
 	var beforePrepares []*models.DialysisBeforePrepareGoods
4799
 	var beforePrepares []*models.DialysisBeforePrepareGoods
4694
 
4800
 
4730
 				}
4836
 				}
4731
 				project_id := int64(items["project_id"].(float64))
4837
 				project_id := int64(items["project_id"].(float64))
4732
 				prepare := &models.DialysisBeforePrepareGoods{
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
 				beforePrepares = append(beforePrepares, prepare)
4845
 				beforePrepares = append(beforePrepares, prepare)
4739
 
4846
 
4740
 				newPrepare := &models.NewDialysisBeforePrepareGoods{
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
 				newBeforePrepares = append(newBeforePrepares, newPrepare)
4854
 				newBeforePrepares = append(newBeforePrepares, newPrepare)
4747
 			}
4855
 			}
4750
 	fmt.Println("前端数据9999999999999", beforePrepares)
4858
 	fmt.Println("前端数据9999999999999", beforePrepares)
4751
 	//查询是否有库存
4859
 	//查询是否有库存
4752
 	for _, item := range beforePrepares {
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
 		if item.Count > warehouse.Count {
4864
 		if item.Count > warehouse.Count {
4756
 			goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
4865
 			goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
4777
 
4886
 
4778
 	for _, item := range list {
4887
 	for _, item := range list {
4779
 		prepare := models.DialysisBeforePrepare{
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
 		err = service.DeleteDialysisBefor(adminInfo.Org.Id, patient_id, record_time, item.GoodId, item.GoodTypeId)
4902
 		err = service.DeleteDialysisBefor(adminInfo.Org.Id, patient_id, record_time, item.GoodId, item.GoodTypeId)
4793
 		//插入准备表数据
4903
 		//插入准备表数据
4794
 		service.CreateDialysisBeforePrepareOne(&prepare)
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
 
5283
 
5162
 	delete_count = warehouseOutInfos.Count - count
5284
 	delete_count = warehouseOutInfos.Count - count
5163
 
5285
 
5286
+	houseConfig, _ := service.GetAllStoreHouseConfig(orgID)
5164
 	fmt.Println("delete_count2323232", delete_count)
5287
 	fmt.Println("delete_count2323232", delete_count)
5165
 	// 在出库记录表里记录退库详情
5288
 	// 在出库记录表里记录退库详情
5166
 	warehouseOutInfo := &models.WarehouseOutInfo{
5289
 	warehouseOutInfo := &models.WarehouseOutInfo{
5176
 		GoodId:                  good_yc.GoodId,
5299
 		GoodId:                  good_yc.GoodId,
5177
 		PatientId:               good_yc.PatientId,
5300
 		PatientId:               good_yc.PatientId,
5178
 		ConsumableType:          2,
5301
 		ConsumableType:          2,
5302
+		StorehouseId:            houseConfig.StorehouseOutInfo,
5179
 	}
5303
 	}
5180
 	warehouseOutInfo.Count = count
5304
 	warehouseOutInfo.Count = count
5181
 
5305
 
5191
 	//查找当天是否存在出库记录
5315
 	//查找当天是否存在出库记录
5192
 
5316
 
5193
 	_, errcod := service.GetWarehouseOutInfoIsExistOne(good_yc.GoodId, good_yc.PatientId, record_time)
5317
 	_, errcod := service.GetWarehouseOutInfoIsExistOne(good_yc.GoodId, good_yc.PatientId, record_time)
5194
-	fmt.Println("errcode2323223255556652324242424242424242424242424242242", errcod)
5318
+
5195
 	if errcod == gorm.ErrRecordNotFound {
5319
 	if errcod == gorm.ErrRecordNotFound {
5196
 		errOne := service.AddSigleWarehouseOutInfo(warehouseOutInfo)
5320
 		errOne := service.AddSigleWarehouseOutInfo(warehouseOutInfo)
5197
 		//插入详情明细表
5321
 		//插入详情明细表
5218
 			IsSys:                   1,
5342
 			IsSys:                   1,
5219
 			UpdateCreator:           creater,
5343
 			UpdateCreator:           creater,
5220
 			PatientId:               patient_id,
5344
 			PatientId:               patient_id,
5345
+			StorehouseId:            houseConfig.StorehouseOutInfo,
5221
 		}
5346
 		}
5222
 		exsit, errflow := service.GetStockFlowIsExsit(warehouseOutInfos.WarehouseInfotId, patient_id, record_time, good_yc.GoodId)
5347
 		exsit, errflow := service.GetStockFlowIsExsit(warehouseOutInfos.WarehouseInfotId, patient_id, record_time, good_yc.GoodId)
5223
 		if errflow == gorm.ErrRecordNotFound {
5348
 		if errflow == gorm.ErrRecordNotFound {
5224
 			//创建流水表
5349
 			//创建流水表
5225
 			err := service.CreateStockFlowOne(stockFlow)
5350
 			err := service.CreateStockFlowOne(stockFlow)
5226
-			fmt.Println("h2h3h2323342i24i242i4u2i4242u42424", err)
5351
+			fmt.Println("err", err)
5227
 		} else if errflow == nil {
5352
 		} else if errflow == nil {
5228
 			//插入详情明细表
5353
 			//插入详情明细表
5229
 			stockFlow := models.VmStockFlow{
5354
 			stockFlow := models.VmStockFlow{
5251
 				IsSys:                   1,
5376
 				IsSys:                   1,
5252
 				UpdateCreator:           creater,
5377
 				UpdateCreator:           creater,
5253
 				PatientId:               patient_id,
5378
 				PatientId:               patient_id,
5379
+				StorehouseId:            houseConfig.StorehouseOutInfo,
5254
 			}
5380
 			}
5255
 
5381
 
5256
 			service.UpdatedStockFlowOne(stockFlow, warehouseOut.ID, patient_id, record_time, good_yc.GoodId)
5382
 			service.UpdatedStockFlowOne(stockFlow, warehouseOut.ID, patient_id, record_time, good_yc.GoodId)
5287
 			UpdateCreator:           creater,
5413
 			UpdateCreator:           creater,
5288
 			PatientId:               patient_id,
5414
 			PatientId:               patient_id,
5289
 			ReturnCount:             delete_count,
5415
 			ReturnCount:             delete_count,
5416
+			StorehouseId:            houseConfig.StorehouseOutInfo,
5290
 		}
5417
 		}
5291
 		exsit, errflows := service.GetStockFlowIsExsit(warehouseOutInfos.WarehouseInfotId, patient_id, record_time, good_yc.GoodId)
5418
 		exsit, errflows := service.GetStockFlowIsExsit(warehouseOutInfos.WarehouseInfotId, patient_id, record_time, good_yc.GoodId)
5292
 		if errflows == gorm.ErrRecordNotFound {
5419
 		if errflows == gorm.ErrRecordNotFound {
5319
 				UpdateCreator:           creater,
5446
 				UpdateCreator:           creater,
5320
 				PatientId:               patient_id,
5447
 				PatientId:               patient_id,
5321
 				ReturnCount:             delete_count,
5448
 				ReturnCount:             delete_count,
5449
+				StorehouseId:            houseConfig.StorehouseOutInfo,
5322
 			}
5450
 			}
5323
 			//service.UpdatedStockFlow(stockFlow)
5451
 			//service.UpdatedStockFlow(stockFlow)
5324
 			service.UpdatedStockFlowOne(stockFlow, warehouseOut.ID, patient_id, record_time, good_yc.GoodId)
5452
 			service.UpdatedStockFlowOne(stockFlow, warehouseOut.ID, patient_id, record_time, good_yc.GoodId)
5339
 		GoodId:                  good_yc.GoodId,
5467
 		GoodId:                  good_yc.GoodId,
5340
 		GoodTypeId:              good_yc.GoodTypeId,
5468
 		GoodTypeId:              good_yc.GoodTypeId,
5341
 		Count:                   count,
5469
 		Count:                   count,
5470
+		StorehouseId:            houseConfig.StorehouseOutInfo,
5342
 	}
5471
 	}
5343
 	//查询当天耗材是否已经存在数据
5472
 	//查询当天耗材是否已经存在数据
5344
 	_, errcode := service.GetAutoMaticReduceDetail(orgID, patient_id, record_time, good_yc.GoodId, good_yc.GoodTypeId)
5473
 	_, errcode := service.GetAutoMaticReduceDetail(orgID, patient_id, record_time, good_yc.GoodId, good_yc.GoodTypeId)
5412
 
5541
 
5413
 	if len(goods) > 0 {
5542
 	if len(goods) > 0 {
5414
 		out, err := service.FindStockOutByIsSys(orgID, 1, record_time)
5543
 		out, err := service.FindStockOutByIsSys(orgID, 1, record_time)
5544
+		houseConfig, _ := service.GetAllStoreHouseConfig(orgID)
5415
 		if err == gorm.ErrRecordNotFound {
5545
 		if err == gorm.ErrRecordNotFound {
5416
 			//没有记录,则创建出库单
5546
 			//没有记录,则创建出库单
5417
 			timeStr := time.Now().Format("2006-01-02")
5547
 			timeStr := time.Now().Format("2006-01-02")
5434
 				Manufacturer:            0,
5564
 				Manufacturer:            0,
5435
 				Type:                    1,
5565
 				Type:                    1,
5436
 				IsSys:                   1,
5566
 				IsSys:                   1,
5567
+				StorehouseId:            houseConfig.StorehouseOutInfo,
5437
 			}
5568
 			}
5438
 			err := service.AddSigleWarehouseOut(&warehouseOut)
5569
 			err := service.AddSigleWarehouseOut(&warehouseOut)
5439
 			if err != nil {
5570
 			if err != nil {
5452
 				}
5583
 				}
5453
 			}
5584
 			}
5454
 			prepare := models.DialysisBeforePrepare{
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
 			service.ConsumablesDelivery(orgID, patient_id, record_time, &prepare, &out, newCount)
5592
 			service.ConsumablesDelivery(orgID, patient_id, record_time, &prepare, &out, newCount)
5461
 		}
5593
 		}
5462
 
5594
 
5505
 			SysRecordTime:           record_time,
5637
 			SysRecordTime:           record_time,
5506
 			GoodTypeId:              good_yc.GoodTypeId,
5638
 			GoodTypeId:              good_yc.GoodTypeId,
5507
 			GoodId:                  good_yc.GoodId,
5639
 			GoodId:                  good_yc.GoodId,
5640
+			StorehouseId:            warehouseOut.StorehouseId,
5508
 		}
5641
 		}
5509
 		warehouseOutInfo.Count = delete_count
5642
 		warehouseOutInfo.Count = delete_count
5510
 		stockInInfo, _ := service.FindLastStockInInfoRecord(good_yc.GoodId, orgID)
5643
 		stockInInfo, _ := service.FindLastStockInInfoRecord(good_yc.GoodId, orgID)

+ 54 - 3
controllers/mobile_api_controllers/patient_api_controller.go Parādīt failu

701
 					var prescribing_number_total int64
701
 					var prescribing_number_total int64
702
 					for _, item := range advices {
702
 					for _, item := range advices {
703
 						if item.Way == 1 {
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
 							medical, _ := service.GetBaseDrugMedical(item.DrugId)
709
 							medical, _ := service.GetBaseDrugMedical(item.DrugId)
743
 							if prescribing_number_total <= total {
744
 							if prescribing_number_total <= total {
744
 								if medical.IsUse == 2 {
745
 								if medical.IsUse == 2 {
745
 									service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
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
 					for _, item := range advices {
789
 					for _, item := range advices {
773
 
790
 
774
 						if item.Way == 1 {
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
 							medical, _ := service.GetBaseDrugMedical(item.DrugId)
797
 							medical, _ := service.GetBaseDrugMedical(item.DrugId)
818
 							if prescribing_number_total <= total {
836
 							if prescribing_number_total <= total {
819
 								if medical.IsUse == 2 {
837
 								if medical.IsUse == 2 {
820
 									service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
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
 									c.ServeSuccessJSON(map[string]interface{}{
855
 									c.ServeSuccessJSON(map[string]interface{}{
822
 										"msg":    "1",
856
 										"msg":    "1",
823
 										"advice": advice,
857
 										"advice": advice,
1059
 					var total int64
1093
 					var total int64
1060
 					var prescribing_number_total int64
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
 					if medical.MaxUnit == advice.PrescribingNumberUnit {
1100
 					if medical.MaxUnit == advice.PrescribingNumberUnit {
1099
 					if prescribing_number_total <= total {
1134
 					if prescribing_number_total <= total {
1100
 						if medical.IsUse == 2 {
1135
 						if medical.IsUse == 2 {
1101
 							service.HisDrugsDelivery(adminInfo.Org.Id, creater, &advice)
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 Parādīt failu

348
 		MemberTreatement:             0,
348
 		MemberTreatement:             0,
349
 		EquitmentId:                  "",
349
 		EquitmentId:                  "",
350
 		UserSysBeforeCount:           patient.UserSysBeforeCount,
350
 		UserSysBeforeCount:           patient.UserSysBeforeCount,
351
+		TrobleShoot:                  patient.TrobleShoot,
351
 	}
352
 	}
352
 
353
 
353
 	err = service.CreatePatientsNew(&patientsNew)
354
 	err = service.CreatePatientsNew(&patientsNew)
562
 		UpdatedTime:               time.Now().Unix(),
563
 		UpdatedTime:               time.Now().Unix(),
563
 		BloodPatients:             1,
564
 		BloodPatients:             1,
564
 		Lapseto:                   patient.Lapseto,
565
 		Lapseto:                   patient.Lapseto,
566
+		TrobleShoot:               patient.TrobleShoot,
565
 	}
567
 	}
566
 	//	//更新病人ID获取新表病人ID
568
 	//	//更新病人ID获取新表病人ID
567
 	err = service.UpdatepatientTwo(&patientsNew, id)
569
 	err = service.UpdatepatientTwo(&patientsNew, id)
1726
 			var prescribing_number_total int64
1728
 			var prescribing_number_total int64
1727
 			advices, _ := service.GetExecutionDoctors(adminUserInfo.CurrentOrgId, patient, id)
1729
 			advices, _ := service.GetExecutionDoctors(adminUserInfo.CurrentOrgId, patient, id)
1728
 			for _, item := range advices {
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
 				medical, _ := service.GetBaseDrugMedical(item.DrugId)
1736
 				medical, _ := service.GetBaseDrugMedical(item.DrugId)
1747
 					prescribing_number_total = count
1749
 					prescribing_number_total = count
1748
 				}
1750
 				}
1749
 
1751
 
1750
-				fmt.Println("数量一", prescribing_number_total)
1751
-				fmt.Println("数量二", total)
1752
-
1753
 				if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
1752
 				if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
1754
 					c.ServeSuccessJSON(map[string]interface{}{
1753
 					c.ServeSuccessJSON(map[string]interface{}{
1755
 						"msg":    "3",
1754
 						"msg":    "3",
1767
 				if prescribing_number_total <= total {
1766
 				if prescribing_number_total <= total {
1768
 					if medical.IsUse == 2 {
1767
 					if medical.IsUse == 2 {
1769
 						service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
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
 						break
1785
 						break
1771
 						c.ServeSuccessJSON(map[string]interface{}{
1786
 						c.ServeSuccessJSON(map[string]interface{}{
1772
 							"msg":    "1",
1787
 							"msg":    "1",
1990
 
2005
 
1991
 				var total int64
2006
 				var total int64
1992
 				var prescribing_number_total int64
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
 				if medical.MaxUnit == advice.PrescribingNumberUnit {
2016
 				if medical.MaxUnit == advice.PrescribingNumberUnit {
2028
 				if prescribing_number_total <= total {
2047
 				if prescribing_number_total <= total {
2029
 					if medical.IsUse == 2 {
2048
 					if medical.IsUse == 2 {
2030
 						service.HisDrugsDelivery(adminUserInfo.CurrentOrgId, item.ExecutionStaff, item)
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
 						break
2067
 						break
2032
 						c.ServeSuccessJSON(map[string]interface{}{
2068
 						c.ServeSuccessJSON(map[string]interface{}{
2033
 							"msg":    "1",
2069
 							"msg":    "1",
4076
 		patient.ContactName = contact_name
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
 	return
4120
 	return
4080
 
4121
 
4081
 }
4122
 }

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 2026 - 0
controllers/secondary_order_api_contorller.go


+ 75 - 19
controllers/self_drug_api_congtroller.go Parādīt failu

950
 func (this *SelfDrugApiController) PostSearchDrugWarehouseList() {
950
 func (this *SelfDrugApiController) PostSearchDrugWarehouseList() {
951
 
951
 
952
 	keyword := this.GetString("keyword")
952
 	keyword := this.GetString("keyword")
953
+	storehouse_id, _ := this.GetInt64("storehouse_id")
953
 	orgId := this.GetAdminUserInfo().CurrentOrgId
954
 	orgId := this.GetAdminUserInfo().CurrentOrgId
954
-	list, err := service.PostSearchDrugWarehouseList(keyword, orgId)
955
+	list, err := service.PostSearchDrugWarehouseList(keyword, orgId, storehouse_id)
955
 	manufacturerList, err := service.GetAllManufacturerList(orgId)
956
 	manufacturerList, err := service.GetAllManufacturerList(orgId)
956
 	dealerList, err := service.GetAllDealerList(orgId)
957
 	dealerList, err := service.GetAllDealerList(orgId)
957
 	if err != nil {
958
 	if err != nil {
1433
 
1434
 
1434
 	start_time := this.GetString("start_time")
1435
 	start_time := this.GetString("start_time")
1435
 	end_time := this.GetString("end_time")
1436
 	end_time := this.GetString("end_time")
1437
+	storehouse_id, _ := this.GetInt64("storehouse_id")
1436
 	var startTime int64
1438
 	var startTime int64
1437
 	if len(start_time) > 0 {
1439
 	if len(start_time) > 0 {
1438
 		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
1440
 		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
1456
 	limit, _ := this.GetInt64("limit")
1458
 	limit, _ := this.GetInt64("limit")
1457
 	page, _ := this.GetInt64("page")
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
 	damagelist, _ := service.GetDrugDamageByOrgId(orgId)
1463
 	damagelist, _ := service.GetDrugDamageByOrgId(orgId)
1462
 	doctorList, err := service.GetAllDoctorThree(orgId)
1464
 	doctorList, err := service.GetAllDoctorThree(orgId)
1465
+
1466
+	houseList, _ := service.GetAllStoreHouseList(orgId)
1463
 	if err != nil {
1467
 	if err != nil {
1464
 		this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
1468
 		this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
1465
 		return
1469
 		return
1470
 		"list":       list,
1474
 		"list":       list,
1471
 		"damagelist": damagelist,
1475
 		"damagelist": damagelist,
1472
 		"doctorList": doctorList,
1476
 		"doctorList": doctorList,
1477
+		"houseList":  houseList,
1473
 	})
1478
 	})
1474
 }
1479
 }
1475
 
1480
 
1735
 func (this *SelfDrugApiController) GetWarehoseInfoById() {
1740
 func (this *SelfDrugApiController) GetWarehoseInfoById() {
1736
 
1741
 
1737
 	id, _ := this.GetInt64("id")
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
 	this.ServeSuccessJSON(map[string]interface{}{
1746
 	this.ServeSuccessJSON(map[string]interface{}{
1741
 		"list": list,
1747
 		"list": list,
1975
 	limit, _ := this.GetInt64("limit")
1981
 	limit, _ := this.GetInt64("limit")
1976
 	page, _ := this.GetInt64("page")
1982
 	page, _ := this.GetInt64("page")
1977
 	list, total, err := service.GetDrugInventoryList(keyword, page, limit, orgId, startTime, endTime)
1983
 	list, total, err := service.GetDrugInventoryList(keyword, page, limit, orgId, startTime, endTime)
1978
-	fmt.Println("list23232323223", list)
1984
+
1979
 	doctorList, _ := service.GetAllDoctorThree(orgId)
1985
 	doctorList, _ := service.GetAllDoctorThree(orgId)
1986
+	houseList, _ := service.GetAllStoreHouseList(orgId)
1987
+	houseConfig, _ := service.GetAllStoreHouseConfig(orgId)
1980
 	if err != nil {
1988
 	if err != nil {
1981
 		this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
1989
 		this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
1982
 		return
1990
 		return
1983
 	}
1991
 	}
1984
 
1992
 
1985
 	this.ServeSuccessJSON(map[string]interface{}{
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
 	keyword := this.GetString("keyword")
2352
 	keyword := this.GetString("keyword")
2343
 	limit, _ := this.GetInt64("limit")
2353
 	limit, _ := this.GetInt64("limit")
2344
 	page, _ := this.GetInt64("page")
2354
 	page, _ := this.GetInt64("page")
2355
+	storehouse_id, _ := this.GetInt64("storehouse_id")
2345
 	orgId := this.GetAdminUserInfo().CurrentOrgId
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
 	doctorList, _ := service.GetAllDoctorThree(orgId)
2360
 	doctorList, _ := service.GetAllDoctorThree(orgId)
2349
 	if err != nil {
2361
 	if err != nil {
2350
 		this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
2362
 		this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
2355
 		"total":      total,
2367
 		"total":      total,
2356
 		"list":       list,
2368
 		"list":       list,
2357
 		"doctorList": doctorList,
2369
 		"doctorList": doctorList,
2370
+		"houseList":  houseList,
2358
 	})
2371
 	})
2359
 }
2372
 }
2360
 
2373
 
2472
 			expiry_date := int64(items["expiry_date"].(float64))
2485
 			expiry_date := int64(items["expiry_date"].(float64))
2473
 
2486
 
2474
 			manufacturer := int64(items["manufacturer"].(float64))
2487
 			manufacturer := int64(items["manufacturer"].(float64))
2488
+
2489
+			storehouse_id := int64(items["storehouse_id"].(float64))
2475
 			timeLayout := "2006-01-02"
2490
 			timeLayout := "2006-01-02"
2476
 			loc, _ := time.LoadLocation("Local")
2491
 			loc, _ := time.LoadLocation("Local")
2477
 			timeNow := time.Now().Format("2006-01-02")
2492
 			timeNow := time.Now().Format("2006-01-02")
2480
 			var consumable_count int64
2495
 			var consumable_count int64
2481
 			var ord_total int64
2496
 			var ord_total int64
2482
 			var new_total int64
2497
 			var new_total int64
2498
+			var total int64
2483
 			ord_total = stock_max_number*min_number + stock_min_number
2499
 			ord_total = stock_max_number*min_number + stock_min_number
2484
 			new_total = last_stock_max_number*min_number + last_stock_min_number
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
 			if ord_total > new_total {
2521
 			if ord_total > new_total {
2487
 				consumable_type = 11
2522
 				consumable_type = 11
2488
 				consumable_count = ord_total - new_total
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
 				consumable_type = 10
2530
 				consumable_type = 10
2492
 				consumable_count = new_total - ord_total
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
 			inventory := models.XtDrugInventory{
2560
 			inventory := models.XtDrugInventory{
2507
 				DrugName:           drug_name,
2561
 				DrugName:           drug_name,
2508
 				SpecificationName:  specification_name,
2562
 				SpecificationName:  specification_name,
2542
 				LastStockMinNumber: last_stock_min_number,
2596
 				LastStockMinNumber: last_stock_min_number,
2543
 				InventoryType:      consumable_type,
2597
 				InventoryType:      consumable_type,
2544
 				Type:               type_id,
2598
 				Type:               type_id,
2599
+				StorehouseId:       storehouse_id,
2545
 			}
2600
 			}
2546
 
2601
 
2547
 			err = service.CreateDrugInventory(inventory)
2602
 			err = service.CreateDrugInventory(inventory)
2578
 				ProductDate:             0,
2633
 				ProductDate:             0,
2579
 				MaxUnit:                 min_unit,
2634
 				MaxUnit:                 min_unit,
2580
 				MinUnit:                 min_unit,
2635
 				MinUnit:                 min_unit,
2636
+				StorehouseId:            storehouse_id,
2581
 			}
2637
 			}
2582
 			if ord_total != new_total {
2638
 			if ord_total != new_total {
2583
 				service.CreateDrugFlowOne(flow)
2639
 				service.CreateDrugFlowOne(flow)

+ 9 - 1
controllers/stock_good_api_controller.go Parādīt failu

174
 func (c *StockGoodApiController) GetAllGoodType() {
174
 func (c *StockGoodApiController) GetAllGoodType() {
175
 	adminUserInfo := c.GetAdminUserInfo()
175
 	adminUserInfo := c.GetAdminUserInfo()
176
 	goodTypes, err := service.FindAllGoodType(adminUserInfo.CurrentOrgId)
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
 	if err == nil {
181
 	if err == nil {
178
 		c.ServeSuccessJSON(map[string]interface{}{
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
 	} else {
189
 	} else {
182
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
190
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 712 - 239
controllers/stock_in_api_controller.go


+ 91 - 30
controllers/supply_order_api_contorller.go Parādīt failu

2082
 	purcaseOrder, _ := service.GetAllPurcaseOrderById(id, orgId)
2082
 	purcaseOrder, _ := service.GetAllPurcaseOrderById(id, orgId)
2083
 	//获取购货单的数据
2083
 	//获取购货单的数据
2084
 	goodOrder, err := service.GetAllGoodOrderByIdSix(id, orgId)
2084
 	goodOrder, err := service.GetAllGoodOrderByIdSix(id, orgId)
2085
-	fmt.Println("2323232332232323232332", goodOrder)
2085
+
2086
 	drugList, err := service.GetSupplyDrugList(orgId)
2086
 	drugList, err := service.GetSupplyDrugList(orgId)
2087
 
2087
 
2088
 	if err == nil {
2088
 	if err == nil {
2195
 	//获取购货单的数据
2195
 	//获取购货单的数据
2196
 	goodOrder, _ := service.GetAllGoodOrderByIdTwo(id, orgId)
2196
 	goodOrder, _ := service.GetAllGoodOrderByIdTwo(id, orgId)
2197
 
2197
 
2198
+	houseConfig, _ := service.GetAllStoreHouseConfig(orgId)
2198
 	//查询该购货单是否审核成功
2199
 	//查询该购货单是否审核成功
2199
 	detail, _ := service.GetGoodOrderDetail(id, orgId)
2200
 	detail, _ := service.GetGoodOrderDetail(id, orgId)
2200
 	var warehousingInfo []*models.WarehousingInfo
2201
 	var warehousingInfo []*models.WarehousingInfo
2227
 						WarehousingTime:   record_date,
2228
 						WarehousingTime:   record_date,
2228
 						Type:              1,
2229
 						Type:              1,
2229
 						SupplyWarehouseId: id,
2230
 						SupplyWarehouseId: id,
2231
+						StorehouseId:      houseConfig.DrugStorehouseInfo,
2230
 					}
2232
 					}
2231
 					//查询今日是否存在入库单号
2233
 					//查询今日是否存在入库单号
2232
 					//_, errcode := service.GetSingleDrugWarehouseOrder(record_date, orgId)
2234
 					//_, errcode := service.GetSingleDrugWarehouseOrder(record_date, orgId)
2260
 						RetailPrice:               item.MinPrice,
2262
 						RetailPrice:               item.MinPrice,
2261
 						SupplyWarehouseId:         id,
2263
 						SupplyWarehouseId:         id,
2262
 						SupplyWarehouseDetailInfo: item.ID,
2264
 						SupplyWarehouseDetailInfo: item.ID,
2265
+						StorehouseId:              houseConfig.DrugStorehouseInfo,
2263
 					}
2266
 					}
2264
 					if medical.MaxUnit == medical.MinUnit {
2267
 					if medical.MaxUnit == medical.MinUnit {
2265
 						warehouseInfoDetailOne.StockMaxNumber = item.Count
2268
 						warehouseInfoDetailOne.StockMaxNumber = item.Count
2296
 						IsSys:                     0,
2299
 						IsSys:                     0,
2297
 						SupplyWarehouseId:         id,
2300
 						SupplyWarehouseId:         id,
2298
 						SupplyWarehouseDetailInfo: item.ID,
2301
 						SupplyWarehouseDetailInfo: item.ID,
2302
+						StorehouseId:              houseConfig.DrugStorehouseInfo,
2299
 					}
2303
 					}
2300
 
2304
 
2301
 					if medical.MaxUnit == medical.MinUnit {
2305
 					if medical.MaxUnit == medical.MinUnit {
2328
 						WarehousingTime:   record_date,
2332
 						WarehousingTime:   record_date,
2329
 						Type:              1,
2333
 						Type:              1,
2330
 						SupplyWarehouseId: id,
2334
 						SupplyWarehouseId: id,
2335
+						StorehouseId:      houseConfig.StorehouseInfo,
2331
 					}
2336
 					}
2332
 					//查询是否存在入库单
2337
 					//查询是否存在入库单
2333
 					//_, errcose := service.GetSindleWarehouse(record_date, orgId)
2338
 					//_, errcose := service.GetSindleWarehouse(record_date, orgId)
2360
 						PackingPrice:              item.MinPrice,
2365
 						PackingPrice:              item.MinPrice,
2361
 						SupplyWarehouseId:         id,
2366
 						SupplyWarehouseId:         id,
2362
 						SupplyWarehouseDetailInfo: item.ID,
2367
 						SupplyWarehouseDetailInfo: item.ID,
2368
+						StorehouseId:              houseConfig.StorehouseInfo,
2363
 					}
2369
 					}
2364
 					warehousingInfo = append(warehousingInfo, warehouseInfo)
2370
 					warehousingInfo = append(warehousingInfo, warehouseInfo)
2365
 				}
2371
 				}
2369
 
2375
 
2370
 	for _, item := range warehousingInfo {
2376
 	for _, item := range warehousingInfo {
2371
 		service.CreatedWarehouseingDetail(item)
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
 		warehousinginfo, _ := service.GetLastWarehousingInfo(item.GoodId)
2390
 		warehousinginfo, _ := service.GetLastWarehousingInfo(item.GoodId)
2374
 		flow := models.VmStockFlow{
2391
 		flow := models.VmStockFlow{
2375
 			WarehousingOrder:          item.WarehousingOrder,
2392
 			WarehousingOrder:          item.WarehousingOrder,
2393
 			WarehousingDetailId:       warehousinginfo.ID,
2410
 			WarehousingDetailId:       warehousinginfo.ID,
2394
 			SupplyWarehouseId:         id,
2411
 			SupplyWarehouseId:         id,
2395
 			SupplyWarehouseDetailInfo: item.ID,
2412
 			SupplyWarehouseDetailInfo: item.ID,
2413
+			StorehouseId:              houseConfig.StorehouseInfo,
2396
 		}
2414
 		}
2397
 		service.CreateStockFlowOne(flow)
2415
 		service.CreateStockFlowOne(flow)
2398
 	}
2416
 	}
2399
 	//创建入库单
2417
 	//创建入库单
2400
 	errs := service.CreateDrugWarehousingInfoSix(warehouseInfoDetail)
2418
 	errs := service.CreateDrugWarehousingInfoSix(warehouseInfoDetail)
2419
+
2401
 	//改变入库状态
2420
 	//改变入库状态
2402
 	for _, items := range warehouseInfoDetail {
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
 	fmt.Println(errs)
2441
 	fmt.Println(errs)
2414
 	for _, items := range drugFlow {
2442
 	for _, items := range drugFlow {
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
 		service.UpdateDrugSupplyWarehousingInfo(id, orgId)
3231
 		service.UpdateDrugSupplyWarehousingInfo(id, orgId)
3192
 
3232
 
3194
 		service.UpdateDrugSupplyFlow(id, orgId)
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
 		service.UpdateGoodSupplyWarehousingInfo(id, orgId)
3254
 		service.UpdateGoodSupplyWarehousingInfo(id, orgId)
3202
 
3255
 
3317
 	orgId := this.GetAdminUserInfo().CurrentOrgId
3370
 	orgId := this.GetAdminUserInfo().CurrentOrgId
3318
 	record_date := recordDate.Unix()
3371
 	record_date := recordDate.Unix()
3319
 	checker := this.GetAdminUserInfo().AdminUser.Id
3372
 	checker := this.GetAdminUserInfo().AdminUser.Id
3320
-
3373
+	houseConfig, _ := service.GetAllStoreHouseConfig(this.GetAdminUserInfo().CurrentOrgId)
3321
 	//获取退库单详情
3374
 	//获取退库单详情
3322
 	list, _ := service.GetSupplyCancelOrderDetail(id, orgId)
3375
 	list, _ := service.GetSupplyCancelOrderDetail(id, orgId)
3323
 	for _, item := range list {
3376
 	for _, item := range list {
3328
 		if item.IsSource == 1 {
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
 			for _, it := range info {
3386
 			for _, it := range info {
3334
 
3387
 
3351
 				prescribing_number_total = item.SupplyCount
3404
 				prescribing_number_total = item.SupplyCount
3352
 			}
3405
 			}
3353
 
3406
 
3354
-			fmt.Println("hhhhhadf dafsdfsdfddddfdf", prescribing_number_total)
3355
 			//判断单位
3407
 			//判断单位
3356
 			if total_count == 0 {
3408
 			if total_count == 0 {
3357
 				goodObj, _ := service.GetDrugByGoodId(item.ProjectId)
3409
 				goodObj, _ := service.GetDrugByGoodId(item.ProjectId)
3409
 				Type:                    1,
3461
 				Type:                    1,
3410
 				SupplyCancelOutId:       id,
3462
 				SupplyCancelOutId:       id,
3411
 				SupplyWarehouseId:       warehouse_out_id,
3463
 				SupplyWarehouseId:       warehouse_out_id,
3464
+				StorehouseId:            houseConfig.DrugStorehouseOut,
3412
 			}
3465
 			}
3413
 			// 查询今日是否存在出库单
3466
 			// 查询今日是否存在出库单
3414
 			_, errcodes := service.GetDrugWarehouseOutById(orgId, record_date)
3467
 			_, errcodes := service.GetDrugWarehouseOutById(orgId, record_date)
3444
 				SupplyWarehouseId:       warehouse_out_id,
3497
 				SupplyWarehouseId:       warehouse_out_id,
3445
 				SysRecordTime:           record_date,
3498
 				SysRecordTime:           record_date,
3446
 				IsSource:                item.Type,
3499
 				IsSource:                item.Type,
3500
+				StorehouseId:            houseConfig.DrugStorehouseOut,
3447
 			}
3501
 			}
3448
 
3502
 
3449
 			drup, _ := service.FindBaseDrugLibRecord(orgId, item.ProjectId)
3503
 			drup, _ := service.FindBaseDrugLibRecord(orgId, item.ProjectId)
3462
 		//耗材
3516
 		//耗材
3463
 		if item.IsSource == 2 {
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
 			if item.SupplyCount > warehouseOne.StockCount {
3522
 			if item.SupplyCount > warehouseOne.StockCount {
3505
 				SupplyCancelOutId:       id,
3559
 				SupplyCancelOutId:       id,
3506
 				SupplyWarehouseId:       warehouse_out_id,
3560
 				SupplyWarehouseId:       warehouse_out_id,
3507
 				IsSys:                   0,
3561
 				IsSys:                   0,
3562
+				StorehouseId:            houseConfig.StorehouseOutInfo,
3508
 			}
3563
 			}
3509
 			//查询是否生成出库单
3564
 			//查询是否生成出库单
3510
 			_, errcodes := service.FindStockOutByIsSys(orgId, 0, record_date)
3565
 			_, errcodes := service.FindStockOutByIsSys(orgId, 0, record_date)
3512
 				service.AddSigleWarehouseOut(&warehouseOut)
3567
 				service.AddSigleWarehouseOut(&warehouseOut)
3513
 			}
3568
 			}
3514
 			outWarehouse, _ := service.GetlastWarehouseOutById(orgId, record_date)
3569
 			outWarehouse, _ := service.GetlastWarehouseOutById(orgId, record_date)
3515
-			fmt.Println("232332322332232323", outWarehouse)
3570
+
3516
 			goodObj, _ := service.GetGoodInformationByGoodId(item.ProjectId)
3571
 			goodObj, _ := service.GetGoodInformationByGoodId(item.ProjectId)
3517
 			info := &models.WarehouseOutInfo{
3572
 			info := &models.WarehouseOutInfo{
3518
 				WarehouseOutOrderNumber: outWarehouse.WarehouseOutOrderNumber,
3573
 				WarehouseOutOrderNumber: outWarehouse.WarehouseOutOrderNumber,
3537
 				OrgId:                   orgId,
3592
 				OrgId:                   orgId,
3538
 				SupplyWarehouseId:       warehouse_out_id,
3593
 				SupplyWarehouseId:       warehouse_out_id,
3539
 				IsSource:                item.Type,
3594
 				IsSource:                item.Type,
3595
+				StorehouseId:            houseConfig.StorehouseOutInfo,
3540
 			}
3596
 			}
3541
 			//出库逻辑
3597
 			//出库逻辑
3542
 			parseDateErr := service.ConsumablesDeliveryNight(orgId, record_date, info, &warehouseOut, item.SupplyCount, creater, warehouse_out_id, id)
3598
 			parseDateErr := service.ConsumablesDeliveryNight(orgId, record_date, info, &warehouseOut, item.SupplyCount, creater, warehouse_out_id, id)
3554
 		CheckTime: record_date,
3610
 		CheckTime: record_date,
3555
 	}
3611
 	}
3556
 	err := service.CheckReturnOrder(id, orgId, cancel)
3612
 	err := service.CheckReturnOrder(id, orgId, cancel)
3557
-	fmt.Println("3232233232322332232323232323322332232323232323")
3613
+
3558
 	if err == nil {
3614
 	if err == nil {
3559
 		this.ServeSuccessJSON(map[string]interface{}{
3615
 		this.ServeSuccessJSON(map[string]interface{}{
3560
 			"msg":        "1",
3616
 			"msg":        "1",
3628
 func (this *SupplyOrderApiController) ModefyReturnOrder() {
3684
 func (this *SupplyOrderApiController) ModefyReturnOrder() {
3629
 	id, _ := this.GetInt64("id")
3685
 	id, _ := this.GetInt64("id")
3630
 	err := service.ModefyReturnOrder(id)
3686
 	err := service.ModefyReturnOrder(id)
3631
-
3632
 	//获取退库单据日期
3687
 	//获取退库单据日期
3633
 	cancel, _ := service.GetReturnOrderById(id)
3688
 	cancel, _ := service.GetReturnOrderById(id)
3634
 	orgId := this.GetAdminUserInfo().CurrentOrgId
3689
 	orgId := this.GetAdminUserInfo().CurrentOrgId
3646
 					drugInfo := models.DrugWarehouseInfo{
3701
 					drugInfo := models.DrugWarehouseInfo{
3647
 						StockMaxNumber: item.SupplyCount,
3702
 						StockMaxNumber: item.SupplyCount,
3648
 					}
3703
 					}
3704
+
3649
 					service.UpdateDrugWasehousring(item.ProjectId, item.SupplyWarehouseDetailInfo, drugInfo)
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
 				if item.SupplyType == base.MinUnit && base.MaxUnit != base.MinUnit {
3711
 				if item.SupplyType == base.MinUnit && base.MaxUnit != base.MinUnit {
3654
 						StockMinNumber: item.SupplyCount,
3713
 						StockMinNumber: item.SupplyCount,
3655
 					}
3714
 					}
3656
 					service.UpdateDrugWasehousringOne(item.ProjectId, item.SupplyWarehouseDetailInfo, drugInfo)
3715
 					service.UpdateDrugWasehousringOne(item.ProjectId, item.SupplyWarehouseDetailInfo, drugInfo)
3716
+					service.ModifyDrugAddInformation(item.ProjectId, item.SupplyCount, orgId)
3657
 				}
3717
 				}
3658
 
3718
 
3659
 				//删除流水
3719
 				//删除流水
3668
 			}
3728
 			}
3669
 			//耗材
3729
 			//耗材
3670
 			if item.IsSource == 2 {
3730
 			if item.IsSource == 2 {
3671
-				fmt.Println("item2332322323232332", item.SupplyCount)
3731
+
3672
 				//退库
3732
 				//退库
3673
 				info := models.WarehousingInfo{
3733
 				info := models.WarehousingInfo{
3674
 					StockCount: item.SupplyCount,
3734
 					StockCount: item.SupplyCount,
3676
 
3736
 
3677
 				//更改库存
3737
 				//更改库存
3678
 				err := service.UpdateWarehousingInfoById(item.ProjectId, item.SupplyWarehouseDetailInfo, info)
3738
 				err := service.UpdateWarehousingInfoById(item.ProjectId, item.SupplyWarehouseDetailInfo, info)
3739
+				service.ModifyGoodAddInformation(item.ProjectId, item.SupplyCount, item.UserOrgId)
3679
 				fmt.Println(err)
3740
 				fmt.Println(err)
3680
 				//删除出库记录
3741
 				//删除出库记录
3681
 				service.DeleteGoodWarehouseOut(item.ProjectId, item.WarehouseCancelId, orgId)
3742
 				service.DeleteGoodWarehouseOut(item.ProjectId, item.WarehouseCancelId, orgId)

+ 3 - 0
models/dialysis.go Parādīt failu

1048
 	NewCount     int64                    `gorm:"column:new_count" json:"new_count" form:"new_count"`
1048
 	NewCount     int64                    `gorm:"column:new_count" json:"new_count" form:"new_count"`
1049
 	Children     []*DialysisBeforePrepare `gorm:"column:children" json:"children" form:"children"`
1049
 	Children     []*DialysisBeforePrepare `gorm:"column:children" json:"children" form:"children"`
1050
 	ProjectId    int64                    `gorm:"column:project_id" json:"project_id" form:"project_id"`
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
 func (DialysisBeforePrepare) TableName() string {
1054
 func (DialysisBeforePrepare) TableName() string {
1061
 	TypeName          string `gorm:"column:type_name" json:"type_name" form:"type_name"`
1062
 	TypeName          string `gorm:"column:type_name" json:"type_name" form:"type_name"`
1062
 	SpecificationName string `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
1063
 	SpecificationName string `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
1063
 	ProjectId         int64  `gorm:"column:project_id" json:"project_id" form:"project_id"`
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
 type NewDialysisBeforePrepareGoods struct {
1068
 type NewDialysisBeforePrepareGoods struct {
1071
 	SpecificationName string `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
1073
 	SpecificationName string `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
1072
 	NewCount          int64  `gorm:"column:new_count" json:"new_count" form:"new_count"`
1074
 	NewCount          int64  `gorm:"column:new_count" json:"new_count" form:"new_count"`
1073
 	ProjectId         int64  `gorm:"column:project_id" json:"project_id" form:"project_id"`
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
 type QueueCallConfig struct {
1079
 type QueueCallConfig struct {

+ 1 - 0
models/dialysis_parameter_models.go Parādīt failu

96
 	GoodTypeId              int64  `gorm:"column:good_type_id" json:"good_type_id" form:"good_type_id"`
96
 	GoodTypeId              int64  `gorm:"column:good_type_id" json:"good_type_id" form:"good_type_id"`
97
 	Count                   int64  `gorm:"column:count" json:"count" form:"count"`
97
 	Count                   int64  `gorm:"column:count" json:"count" form:"count"`
98
 	ProjectId               int64  `gorm:"column:project_id" json:"project_id" form:"project_id"`
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
 func (BloodAutomaticReduceDetail) TableName() string {
102
 func (BloodAutomaticReduceDetail) TableName() string {

+ 4 - 0
models/drug.go Parādīt failu

72
 	PrescribingNumberUnit string                 `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
72
 	PrescribingNumberUnit string                 `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
73
 	DrugWarehouseInfo     []*XtDrugWarehouseInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_warehouse_info"`
73
 	DrugWarehouseInfo     []*XtDrugWarehouseInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_warehouse_info"`
74
 	IsUse                 int64                  `gorm:"column:is_user" json:"is_user" form:"is_user"`
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
 func (BaseDrugLib) TableName() string {
80
 func (BaseDrugLib) TableName() string {
84
 	MaxUnit   string `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
87
 	MaxUnit   string `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
85
 	MinNumber int64  `gorm:"column:min_number" json:"min_number" form:"min_number"`
88
 	MinNumber int64  `gorm:"column:min_number" json:"min_number" form:"min_number"`
86
 	MinUnit   string `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
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
 func (BaseDrugLibSeven) TableName() string {
93
 func (BaseDrugLibSeven) TableName() string {

+ 17 - 0
models/drug_stock.go Parādīt failu

15
 	Manufacturer      int64  `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
15
 	Manufacturer      int64  `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
16
 	Type              int64  `gorm:"column:type" json:"type" form:"type"`
16
 	Type              int64  `gorm:"column:type" json:"type" form:"type"`
17
 	SupplyWarehouseId int64  `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
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
 func (DrugWarehouse) TableName() string {
23
 func (DrugWarehouse) TableName() string {
81
 	WarehousingInfoId         int64   `gorm:"column:warehousing_info_id" json:"warehousing_info_id" form:"warehousing_info_id"`
84
 	WarehousingInfoId         int64   `gorm:"column:warehousing_info_id" json:"warehousing_info_id" form:"warehousing_info_id"`
82
 	SupplyWarehouseId         int64   `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
85
 	SupplyWarehouseId         int64   `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
83
 	SupplyWarehouseDetailInfo int64   `gorm:"column:supply_warehouse_detail_info" json:"supply_warehouse_detail_info" form:"supply_warehouse_detail_info"`
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
 func (DrugWarehouseInfo) TableName() string {
91
 func (DrugWarehouseInfo) TableName() string {
116
 	Dealers                 *Dealer       `gorm:"ForeignKey:Dealer;AssociationForeignKey:ID" json:"dealers"`
121
 	Dealers                 *Dealer       `gorm:"ForeignKey:Dealer;AssociationForeignKey:ID" json:"dealers"`
117
 	SupplyCancelOutId       int64         `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
122
 	SupplyCancelOutId       int64         `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
118
 	SupplyWarehouseId       int64         `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
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
 func (DrugWarehouseOut) TableName() string {
128
 func (DrugWarehouseOut) TableName() string {
155
 	SupplyCancelOutId       int64   `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
162
 	SupplyCancelOutId       int64   `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
156
 	SupplyWarehouseId       int64   `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
163
 	SupplyWarehouseId       int64   `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
157
 	IsSource                int64   `gorm:"column:is_source" json:"is_source" form:"is_source"`
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
 func (DrugWarehouseOutInfo) TableName() string {
170
 func (DrugWarehouseOutInfo) TableName() string {
226
 	Manufacturers       *Manufacturer          `gorm:"ForeignKey:Manufacturer;AssociationForeignKey:ID" json:"manufacturers"`
236
 	Manufacturers       *Manufacturer          `gorm:"ForeignKey:Manufacturer;AssociationForeignKey:ID" json:"manufacturers"`
227
 	Dealers             *Dealer                `gorm:"ForeignKey:Dealer;AssociationForeignKey:ID" json:"dealers"`
237
 	Dealers             *Dealer                `gorm:"ForeignKey:Dealer;AssociationForeignKey:ID" json:"dealers"`
228
 	DrugCancelStockInfo []*DrugCancelStockInfo `gorm:"ForeignKey:CancelStockId;AssociationForeignKey:ID" json:"drugCancelStockInfo"`
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
 func (DrugCancelStock) TableName() string {
242
 func (DrugCancelStock) TableName() string {
258
 	MaxUnit          string      `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
269
 	MaxUnit          string      `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
259
 	BaseDrugLib      BaseDrugLib `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" `
270
 	BaseDrugLib      BaseDrugLib `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" `
260
 	BatchNumberId    int64       `gorm:"column:batch_number_id" json:"batch_number_id" form:"batch_number_id"`
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
 func (DrugCancelStockInfo) TableName() string {
275
 func (DrugCancelStockInfo) TableName() string {
279
 	CountUnit               string `gorm:"column:count_unit" json:"count_unit" form:"count_unit"`
291
 	CountUnit               string `gorm:"column:count_unit" json:"count_unit" form:"count_unit"`
280
 	WarehouseInfoId         int64  `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
292
 	WarehouseInfoId         int64  `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
281
 	AdviceId                int64  `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
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
 func (DrugAutomaticReduceDetail) TableName() string {
297
 func (DrugAutomaticReduceDetail) TableName() string {
306
 	MinNumber                 int64  `gorm:"column:min_number" json:"min_number" form:"min_number"`
319
 	MinNumber                 int64  `gorm:"column:min_number" json:"min_number" form:"min_number"`
307
 	SupplyWarehouseId         int64  `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
320
 	SupplyWarehouseId         int64  `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
308
 	SupplyWarehouseDetailInfo int64  `gorm:"column:supply_warehouse_detail_info" json:"supply_warehouse_detail_info" form:"supply_warehouse_detail_info"`
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
 type StDrugWarehouseOutInfo struct {
325
 type StDrugWarehouseOutInfo struct {
393
 	SupplyWarehouseId         int64                `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
407
 	SupplyWarehouseId         int64                `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
394
 	SupplyCancelOutId         int64                `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
408
 	SupplyCancelOutId         int64                `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
395
 	SupplyWarehouseDetailInfo int64                `gorm:"column:supply_warehouse_detail_info" json:"supply_warehouse_detail_info" form:"supply_warehouse_detail_info"`
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
 func (DrugFlow) TableName() string {
415
 func (DrugFlow) TableName() string {

+ 2 - 0
models/good_models.go Parādīt failu

88
 	IsWarehouse                 int64                `gorm:"column:is_warehouse" json:"is_warehouse" form:"is_warehouse"`
88
 	IsWarehouse                 int64                `gorm:"column:is_warehouse" json:"is_warehouse" form:"is_warehouse"`
89
 	SumCount                    int64                `gorm:"column:sum_count" json:"sum_count" form:"sum_count"`
89
 	SumCount                    int64                `gorm:"column:sum_count" json:"sum_count" form:"sum_count"`
90
 	BatchRetaiPrice             float64              `gorm:"column:batch_retai_price" json:"batch_retai_price" form:"batch_retai_price"`
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
 func (GoodInfo) TableName() string {
95
 func (GoodInfo) TableName() string {

+ 2 - 0
models/patient_models.go Parādīt failu

186
 	SchRemark                string  `gorm:"column:sch_remark" json:"sch_remark" form:"sch_remark"`
186
 	SchRemark                string  `gorm:"column:sch_remark" json:"sch_remark" form:"sch_remark"`
187
 	OutReason                string  `gorm:"column:out_reason" json:"out_reason" form:"out_reason"`
187
 	OutReason                string  `gorm:"column:out_reason" json:"out_reason" form:"out_reason"`
188
 	DeathTime                int64   `gorm:"column:death_time" json:"death_time" form:"death_time"`
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
 	ContagionIds             []int64 `gorm:"-"`
190
 	ContagionIds             []int64 `gorm:"-"`
190
 	DryWeight                float64 `gorm:"-"`
191
 	DryWeight                float64 `gorm:"-"`
191
 }
192
 }
741
 	SchRemark                    string  `gorm:"column:sch_remark" json:"sch_remark" form:"sch_remark"`
742
 	SchRemark                    string  `gorm:"column:sch_remark" json:"sch_remark" form:"sch_remark"`
742
 	OutReason                    string  `gorm:"column:out_reason" json:"out_reason" form:"out_reason"`
743
 	OutReason                    string  `gorm:"column:out_reason" json:"out_reason" form:"out_reason"`
743
 	DeathTime                    int64   `gorm:"column:death_time" json:"death_time" form:"death_time"`
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
 func (XtPatientsNew) TableName() string {
748
 func (XtPatientsNew) TableName() string {

+ 199 - 1
models/secondary_models.go Parādīt failu

1
 package models
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 Parādīt failu

357
 	Number                  string     `gorm:"column:number" json:"number" form:"number"`
357
 	Number                  string     `gorm:"column:number" json:"number" form:"number"`
358
 	BatchNumber             string     `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
358
 	BatchNumber             string     `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
359
 	XtBaseDrug              XtBaseDrug `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" `
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
 func (XtDrugWarehouseOutInfo) TableName() string {
363
 func (XtDrugWarehouseOutInfo) TableName() string {
414
 	XtBaseDrug                XtBaseDrug `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" `
415
 	XtBaseDrug                XtBaseDrug `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" `
415
 	SupplyWarehouseId         int64      `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
416
 	SupplyWarehouseId         int64      `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
416
 	SupplyWarehouseDetailInfo int64      `gorm:"column:supply_warehouse_detail_info" json:"supply_warehouse_detail_info" form:"supply_warehouse_detail_info"`
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
 func (XtDrugWarehouseInfo) TableName() string {
421
 func (XtDrugWarehouseInfo) TableName() string {
480
 	WarehouseingUnit string  `gorm:"column:warehouseing_unit" json:"warehouseing_unit" form:"warehouseing_unit"`
482
 	WarehouseingUnit string  `gorm:"column:warehouseing_unit" json:"warehouseing_unit" form:"warehouseing_unit"`
481
 	LastPrice        float64 `gorm:"column:last_price" json:"last_price" form:"last_price"`
483
 	LastPrice        float64 `gorm:"column:last_price" json:"last_price" form:"last_price"`
482
 	DrugOriginPlace  string  `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
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
 type BloodDrugCancelStockInfo struct {
489
 type BloodDrugCancelStockInfo struct {
512
 	Dose             float64 `json:"dose"`
516
 	Dose             float64 `json:"dose"`
513
 	DoseUnit         string  `json:"dose_unit"`
517
 	DoseUnit         string  `json:"dose_unit"`
514
 	Unit             string  `json:"unit"`
518
 	Unit             string  `json:"unit"`
519
+	StorehouseId     int64   `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
515
 }
520
 }
516
 
521
 
517
 type BloodDrugSalesReturnInfo struct {
522
 type BloodDrugSalesReturnInfo struct {
547
 	DrugId                  int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
552
 	DrugId                  int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
548
 	WarehousingOutTarget    int64   `gorm:"column:warehousing_out_target" json:"warehousing_out_target" form:"warehousing_out_target"`
553
 	WarehousingOutTarget    int64   `gorm:"column:warehousing_out_target" json:"warehousing_out_target" form:"warehousing_out_target"`
549
 	Count                   int64   `gorm:"column:count" json:"count" form:"count"`
554
 	Count                   int64   `gorm:"column:count" json:"count" form:"count"`
555
+	CountUnit               string  `gorm:"column:count_unit" json:"count_unit" form:"count_unit"`
550
 	Price                   float64 `gorm:"column:price" json:"price" form:"price"`
556
 	Price                   float64 `gorm:"column:price" json:"price" form:"price"`
551
 	TotalPrice              float64 `gorm:"column:total_price" json:"total_price" form:"total_price"`
557
 	TotalPrice              float64 `gorm:"column:total_price" json:"total_price" form:"total_price"`
552
 	ProductDate             int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
558
 	ProductDate             int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
575
 	Dose                    float64 `json:"dose"`
581
 	Dose                    float64 `json:"dose"`
576
 	DoseUnit                string  `json:"dose_unit"`
582
 	DoseUnit                string  `json:"dose_unit"`
577
 	LastPrice               float64 `json:"last_price"`
583
 	LastPrice               float64 `json:"last_price"`
584
+	StorehouseId            int64   `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
578
 }
585
 }
579
 
586
 
580
 type XtMonitorConfig struct {
587
 type XtMonitorConfig struct {
679
 	Number                  string  `gorm:"column:number" json:"number" form:"number"`
686
 	Number                  string  `gorm:"column:number" json:"number" form:"number"`
680
 	WarehouseInfoId         int64   `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
687
 	WarehouseInfoId         int64   `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
681
 	MedicalInsuranceNumber  string  `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
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
 type XtDrugAdjustPrice struct {
693
 type XtDrugAdjustPrice struct {
859
 	LastStockMinNumber int64   `gorm:"column:last_stock_min_number" json:"last_stock_min_number" form:"last_stock_min_number"`
868
 	LastStockMinNumber int64   `gorm:"column:last_stock_min_number" json:"last_stock_min_number" form:"last_stock_min_number"`
860
 	InventoryType      int64   `gorm:"column:inventory_type" json:"inventory_type" form:"inventory_type"`
869
 	InventoryType      int64   `gorm:"column:inventory_type" json:"inventory_type" form:"inventory_type"`
861
 	Type               int64   `gorm:"column:type" json:"type" form:"type"`
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
 func (XtDrugInventory) TableName() string {
874
 func (XtDrugInventory) TableName() string {
907
 	StockMinNumber     int64              `gorm:"column:stock_min_number" json:"stock_min_number" form:"stock_min_number"`
917
 	StockMinNumber     int64              `gorm:"column:stock_min_number" json:"stock_min_number" form:"stock_min_number"`
908
 	WarehouseInfoId    int64              `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
918
 	WarehouseInfoId    int64              `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
909
 	Children           []*XtDrugInventory `gorm:"column:children" json:"children" form:"children"`
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
 type SgjDrugWarehouseOutInfo struct {
923
 type SgjDrugWarehouseOutInfo struct {

+ 157 - 27
models/stock_models.go Parādīt failu

65
 	Dealers           Dealer       `gorm:"ForeignKey:ID;AssociationForeignKey:Dealer" json:"Dealer"`
65
 	Dealers           Dealer       `gorm:"ForeignKey:ID;AssociationForeignKey:Dealer" json:"Dealer"`
66
 	Type              int64        `gorm:"column:type" json:"type"`
66
 	Type              int64        `gorm:"column:type" json:"type"`
67
 	SupplyWarehouseId int64        `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
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
 func (Warehousing) TableName() string {
73
 func (Warehousing) TableName() string {
72
 }
75
 }
73
 
76
 
74
 type StWarehousingInfo struct {
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
 func (StWarehousingInfo) TableName() string {
109
 func (StWarehousingInfo) TableName() string {
135
 	PackingPrice              float64     `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
140
 	PackingPrice              float64     `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
136
 	SupplyWarehouseId         int64       `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
141
 	SupplyWarehouseId         int64       `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
137
 	SupplyWarehouseDetailInfo int64       `gorm:"column:supply_warehouse_detail_info" json:"supply_warehouse_detail_info" form:"supply_warehouse_detail_info"`
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
 func (WarehousingInfo) TableName() string {
147
 func (WarehousingInfo) TableName() string {
181
 	PackingUnit       string      `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
188
 	PackingUnit       string      `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
182
 	Count             int64       `gorm:json:"count"`
189
 	Count             int64       `gorm:json:"count"`
183
 	PackingPrice      float64     `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
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
 type WarehouseOut struct {
194
 type WarehouseOut struct {
203
 	IsSys                   int64        `gorm:"column:is_sys" json:"is_sys"`
211
 	IsSys                   int64        `gorm:"column:is_sys" json:"is_sys"`
204
 	SupplyCancelOutId       int64        `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
212
 	SupplyCancelOutId       int64        `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
205
 	SupplyWarehouseId       int64        `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
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
 func (WarehouseOut) TableName() string {
218
 func (WarehouseOut) TableName() string {
243
 	SupplyCancelOutId       int64        `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
253
 	SupplyCancelOutId       int64        `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
244
 	SupplyWarehouseId       int64        `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
254
 	SupplyWarehouseId       int64        `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
245
 	IsSource                int64        `gorm:"column:is_source" json:"is_source" form:"is_source"`
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
 func (WarehouseOutInfo) TableName() string {
261
 func (WarehouseOutInfo) TableName() string {
259
 	WarehouseInfotId int64 `gorm:"column:warehouse_info_id" json:"warehouse_info_id"`
272
 	WarehouseInfotId int64 `gorm:"column:warehouse_info_id" json:"warehouse_info_id"`
260
 	IsSys            int64 `gorm:"column:is_sys" json:"is_sys"`
273
 	IsSys            int64 `gorm:"column:is_sys" json:"is_sys"`
261
 	Status           int64 `gorm:"column:status" json:"status"`
274
 	Status           int64 `gorm:"column:status" json:"status"`
275
+	OrgId            int64 `gorm:"column:org_id" json:"org_id"`
262
 }
276
 }
263
 
277
 
264
 func (WarehouseOutInfoNight) TableName() string {
278
 func (WarehouseOutInfoNight) TableName() string {
341
 	Manufacturer      int64                `gorm:"column:manufacturer" json:"manufacturer"`
355
 	Manufacturer      int64                `gorm:"column:manufacturer" json:"manufacturer"`
342
 	Type              int64                `gorm:"column:type" json:"type"`
356
 	Type              int64                `gorm:"column:type" json:"type"`
343
 	XtCancelStockInfo []*XtCancelStockInfo `gorm:"ForeignKey:CancelStockId;AssociationForeignKey:ID" json:"XtCancelStockInfo"`
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
 func (CancelStock) TableName() string {
361
 func (CancelStock) TableName() string {
409
 	Type                    int64               `gorm:"column:type" json:"type"`
424
 	Type                    int64               `gorm:"column:type" json:"type"`
410
 	WarehouseOutInfo        []*WarehouseOutInfo `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"warehouseOutInfo"`
425
 	WarehouseOutInfo        []*WarehouseOutInfo `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"warehouseOutInfo"`
411
 	ProjectId               int64               `gorm:"column:project_id" json:"project_id" form:"project_id"`
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
 func (AutomaticReduceDetail) TableName() string {
430
 func (AutomaticReduceDetail) TableName() string {
487
 	SocialSecurityDirectoryCode string  `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
503
 	SocialSecurityDirectoryCode string  `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
488
 	SupplyCancelOutId           int64   `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
504
 	SupplyCancelOutId           int64   `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
489
 	SupplyWarehouseId           int64   `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
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
 type WarehouseOutInfoTwo struct {
510
 type WarehouseOutInfoTwo struct {
596
 	SupplyWarehouseId         int64   `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
614
 	SupplyWarehouseId         int64   `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
597
 	SupplyCancelOutId         int64   `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
615
 	SupplyCancelOutId         int64   `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
598
 	SupplyWarehouseDetailInfo int64   `gorm:"column:supply_warehouse_detail_info" json:"supply_warehouse_detail_info" form:"supply_warehouse_detail_info"`
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
 func (VmStockFlow) TableName() string {
622
 func (VmStockFlow) TableName() string {
629
 	WarehousingInfo []*WarehousingInfo `gorm:"ForeignKey:GoodId;AssociationForeignKey:GoodId" json:"xt_warehouse_info"`
650
 	WarehousingInfo []*WarehousingInfo `gorm:"ForeignKey:GoodId;AssociationForeignKey:GoodId" json:"xt_warehouse_info"`
630
 	PatientId       int64              `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
651
 	PatientId       int64              `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
631
 	RecordDate      int64              `gorm:"column:record_date" json:"record_date" form:"record_date"`
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
 func (CancelStockInfo) TableName() string {
656
 func (CancelStockInfo) TableName() string {
705
 	Total                       float64                   `gorm:"column:total" json:"total" form:"total"`
727
 	Total                       float64                   `gorm:"column:total" json:"total" form:"total"`
706
 	PrescribingNumberUnit       string                    `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
728
 	PrescribingNumberUnit       string                    `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
707
 	DrugWarehouseInfo           []*VsDrugWarehouseInfo    `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_warehouse_info"`
729
 	DrugWarehouseInfo           []*VsDrugWarehouseInfo    `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_warehouse_info"`
730
+	DrugWarehouse               []*DrugWarehouseInfo      `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_warehouse"`
708
 	DrugCancelStockInfo         []*VsDrugCancelStockInfo  `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_cancel_stock_info"`
731
 	DrugCancelStockInfo         []*VsDrugCancelStockInfo  `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_cancel_stock_info"`
709
 	DrugWarehouseOutInfo        []*VsDrugWarehouseOutInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_warehouse_out"`
732
 	DrugWarehouseOutInfo        []*VsDrugWarehouseOutInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_warehouse_out"`
710
 }
733
 }
741
 	RetailPrice      float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
764
 	RetailPrice      float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
742
 	RetailTotalPrice float64 `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
765
 	RetailTotalPrice float64 `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
743
 	BatchNumber      string  `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
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
 func (VsDrugWarehouseInfo) TableName() string {
770
 func (VsDrugWarehouseInfo) TableName() string {
858
 	SpecificationName string  `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
882
 	SpecificationName string  `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
859
 	PackingUnit       string  `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
883
 	PackingUnit       string  `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
860
 	BuyPrice          float64 `gorm:"column:buy_price" json:"buy_price" form:"buy_price"`
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
 type XtStockAdjustPrice struct {
888
 type XtStockAdjustPrice struct {
1048
 	InventoryType     int64   `gorm:"column:inventory_type" json:"inventory_type" form:"inventory_type"`
1073
 	InventoryType     int64   `gorm:"column:inventory_type" json:"inventory_type" form:"inventory_type"`
1049
 	LastStockCount    int64   `gorm:"column:last_stock_count" json:"last_stock_count" form:"last_stock_count"`
1074
 	LastStockCount    int64   `gorm:"column:last_stock_count" json:"last_stock_count" form:"last_stock_count"`
1050
 	StockCount        int64   `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
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
 func (XtStockInventory) TableName() string {
1079
 func (XtStockInventory) TableName() string {
1088
 	InventoryType     int64   `gorm:"column:inventory_type" json:"inventory_type" form:"inventory_type"`
1114
 	InventoryType     int64   `gorm:"column:inventory_type" json:"inventory_type" form:"inventory_type"`
1089
 	LastStockCount    int64   `gorm:"column:last_stock_count" json:"last_stock_count" form:"last_stock_count"`
1115
 	LastStockCount    int64   `gorm:"column:last_stock_count" json:"last_stock_count" form:"last_stock_count"`
1090
 	StockCount        int64   `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
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
 type XtStockCorrectRecord struct {
1120
 type XtStockCorrectRecord struct {
1202
 func (PatientWarehouseInfo) TableName() string {
1229
 func (PatientWarehouseInfo) TableName() string {
1203
 	return "xt_warehouse_info"
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 Parādīt failu

437
 
437
 
438
 func GetDeviceNumberByID(orgID int64, numberID int64) (*models.DeviceNumber, error) {
438
 func GetDeviceNumberByID(orgID int64, numberID int64) (*models.DeviceNumber, error) {
439
 	var number models.DeviceNumber
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
 	if err != nil {
441
 	if err != nil {
442
 		if err == gorm.ErrRecordNotFound {
442
 		if err == gorm.ErrRecordNotFound {
443
 			return nil, nil
443
 			return nil, nil
495
 		tx.Rollback()
495
 		tx.Rollback()
496
 		return updateNumberErr
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
 	if updateDeviceErr != nil {
499
 	if updateDeviceErr != nil {
500
 		tx.Rollback()
500
 		tx.Rollback()
501
 		return updateDeviceErr
501
 		return updateDeviceErr

+ 3 - 3
service/dialysis_service.go Parādīt failu

760
 
760
 
761
 	db := readDb.
761
 	db := readDb.
762
 		Model(&models.DialysisSchedule{}).
762
 		Model(&models.DialysisSchedule{}).
763
-		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
763
+		Preload("DeviceNumber", "org_id = ?", orgID).
764
 		// Preload("DeviceZone", "status = 1 AND org_id = ?", orgID).
764
 		// Preload("DeviceZone", "status = 1 AND org_id = ?", orgID).
765
 		Preload("TreatmentMode", "status = 1").
765
 		Preload("TreatmentMode", "status = 1").
766
 		Preload("Prescription", "status = 1 AND user_org_id = ?", orgID).
766
 		Preload("Prescription", "status = 1 AND user_org_id = ?", orgID).
1354
 
1354
 
1355
 func GetGoodInfoMation(orgid int64) (goodinfo []*models.GoodInfo, err error) {
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
 	return goodinfo, err
1359
 	return goodinfo, err
1360
 }
1360
 }
1361
 
1361
 

+ 6 - 0
service/doctor_schedule_service.go Parādīt failu

92
 	return role, err
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
 func GetAllNurseList(orgid int64, appid int64) (role []*models.XTSgjUserAdminRole, err error) {
101
 func GetAllNurseList(orgid int64, appid int64) (role []*models.XTSgjUserAdminRole, err error) {
96
 
102
 
97
 	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
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 Parādīt failu

273
 	return
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
 	likeKey := "%" + keyword + "%"
278
 	likeKey := "%" + keyword + "%"
279
 	offset := (page - 1) * limit
279
 	offset := (page - 1) * limit
293
 	if orgid > 0 {
293
 	if orgid > 0 {
294
 		db = db.Where("x.org_id =?", orgid)
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
 	if len(keyword) > 0 {
301
 	if len(keyword) > 0 {
304
 	}
305
 	}
305
 
306
 
306
 	if manufacturerId > 0 {
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
 	} else {
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
 	return drugInfo, total, err
313
 	return drugInfo, total, err
347
 	return returninfo, total, err
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
 	likeKey := "%" + keyword + "%"
353
 	likeKey := "%" + keyword + "%"
353
 	offset := (page - 1) * limit
354
 	offset := (page - 1) * limit
369
 		db = db.Where("x.type = ?", orderType)
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
 	if len(keyword) > 0 {
377
 	if len(keyword) > 0 {
373
 		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")
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
 		db = db.Where("x.warehouse_out_order_number like ? or b.drug_name like ?  or r.user_name like ?", likeKey, likeKey, likeKey)
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
 	if manufacturerId > 0 {
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
 	} else {
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
 	return outinfo, total, err
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
 	likeKey := "%" + keyword + "%"
392
 	likeKey := "%" + keyword + "%"
388
 	db := XTReadDB().Table("xt_drug_cancel_stock_info as x").Where("x.status =1")
393
 	db := XTReadDB().Table("xt_drug_cancel_stock_info as x").Where("x.status =1")
389
 	dbOne := XTReadDB().Table("xt_base_drug as s").Where("s.status =1")
394
 	dbOne := XTReadDB().Table("xt_base_drug as s").Where("s.status =1")
404
 	if len(keyword) > 0 {
409
 	if len(keyword) > 0 {
405
 		db = db.Where("x.order_number like ? or s.drug_spec like ? or t.creater like ?", likeKey, likeKey, likeKey)
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
 	if manufacturerId > 0 {
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
 	} else {
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
 	return info, err
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
 	likeKey := "%" + keyword + "%"
427
 	likeKey := "%" + keyword + "%"
420
 	offset := (page - 1) * limit
428
 	offset := (page - 1) * limit
434
 	if orderType > 0 {
442
 	if orderType > 0 {
435
 		db = db.Where("x.type = ? ", orderType)
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
 	if len(keyword) > 0 {
448
 	if len(keyword) > 0 {
438
 		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")
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
 	}
452
 	}
442
 
453
 
443
 	if manufacturerId > 0 {
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
 	} else {
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
 	return cancel, total, err
460
 	return cancel, total, err
613
 	return list, total, err
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
 	offset := (page - 1) * limit
629
 	offset := (page - 1) * limit
619
 	db := XTReadDB().Table("xt_base_drug").Where("status = 1")
630
 	db := XTReadDB().Table("xt_base_drug").Where("status = 1")
629
 		db = db.Where("drug_name like ?", likeKey)
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
 	err = db.Count(&total).Offset(offset).Limit(limit).Order("ctime desc").Preload("DrugWarehouseInfo", func(db *gorm.DB) *gorm.DB {
647
 	err = db.Count(&total).Offset(offset).Limit(limit).Order("ctime desc").Preload("DrugWarehouseInfo", func(db *gorm.DB) *gorm.DB {
633
 		if startime > 0 {
648
 		if startime > 0 {
634
 			db = db.Where("ctime>=?", startime)
649
 			db = db.Where("ctime>=?", startime)
636
 		if endtime > 0 {
651
 		if endtime > 0 {
637
 			db = db.Where("ctime<=?", endtime)
652
 			db = db.Where("ctime<=?", endtime)
638
 		}
653
 		}
654
+		if storehouse_id > 0 {
655
+			db = db.Where("storehouse_id = ?", storehouse_id)
656
+		}
639
 		return db.Where("status = 1")
657
 		return db.Where("status = 1")
640
 	}).Preload("DrugCancelStockInfo", func(db *gorm.DB) *gorm.DB {
658
 	}).Preload("DrugCancelStockInfo", func(db *gorm.DB) *gorm.DB {
641
 		if startime > 0 {
659
 		if startime > 0 {
645
 			db = db.Where("ctime<=?", endtime)
663
 			db = db.Where("ctime<=?", endtime)
646
 		}
664
 		}
647
 		return db.Where("status = 1")
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
 	}).Preload("DrugWarehouseOutInfo", func(db *gorm.DB) *gorm.DB {
677
 	}).Preload("DrugWarehouseOutInfo", func(db *gorm.DB) *gorm.DB {
649
 		if startime > 0 {
678
 		if startime > 0 {
650
 			db = db.Where("ctime>=?", startime)
679
 			db = db.Where("ctime>=?", startime)
715
 
744
 
716
 func GetBatchOrderDetail(drugid int64, orgid int64, page int64, limit int64) (drug []*models.DrugWarehouseInfo, total int64, err error) {
745
 func GetBatchOrderDetail(drugid int64, orgid int64, page int64, limit int64) (drug []*models.DrugWarehouseInfo, total int64, err error) {
717
 	offset := (page - 1) * limit
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
 	return drug, total, err
748
 	return drug, total, err
720
 }
749
 }
721
 
750
 
830
 		db = db.Where("x.warehouse_out_id = ?", id)
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
 	return info, err
863
 	return info, err
835
 }
864
 }
836
 
865
 

+ 6 - 2
service/his_service.go Parādīt failu

285
 }
285
 }
286
 
286
 
287
 func GetAllBaseDrugStockList(org_id int64) (drugs []*models.BaseDrugLib, err error) {
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
 	return
289
 	return
290
 }
290
 }
291
 
291
 
711
 	DrugDay                     string  `gorm:"column:drug_day" json:"drug_day" form:"drug_day"`
711
 	DrugDay                     string  `gorm:"column:drug_day" json:"drug_day" form:"drug_day"`
712
 	Total                       float64 `gorm:"column:total" json:"total" form:"total"`
712
 	Total                       float64 `gorm:"column:total" json:"total" form:"total"`
713
 	PrescribingNumberUnit       string  `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
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
 	//MedicineInsurancePercentage []*MedicineInsurancePercentage `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"monitoring_record"`
717
 	//MedicineInsurancePercentage []*MedicineInsurancePercentage `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"monitoring_record"`
716
 	OtherDrugWarehouseInfo []*OtherDrugWarehouseInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"stock_in"`
718
 	OtherDrugWarehouseInfo []*OtherDrugWarehouseInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"stock_in"`
717
 	VMDrugSalesReturnInfo  []*VMDrugSalesReturnInfo  `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"sales_return"`
719
 	VMDrugSalesReturnInfo  []*VMDrugSalesReturnInfo  `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"sales_return"`
727
 	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 {
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
 		return db.Where("(status = 1 and stock_max_number > 0)  or  (status = 1  AND stock_min_number >0)")
730
 		return db.Where("(status = 1 and stock_max_number > 0)  or  (status = 1  AND stock_min_number >0)")
729
 	}).Find(&list).Error
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
 	return
734
 	return
731
 }
735
 }
732
 
736
 

+ 1 - 1
service/manage_center_service.go Parādīt failu

174
 }
174
 }
175
 
175
 
176
 func FindBaseDrugLibRecordSeven(org_id int64, id int64) (lib models.BaseDrugLibSeven, err error) {
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
 	return
178
 	return
179
 }
179
 }
180
 
180
 

+ 1 - 1
service/mobile_dialysis_service.go Parādīt failu

2770
 
2770
 
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
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
 	if len(Id) > 0 {
2772
 	if len(Id) > 0 {
2773
-		fmt.Println("ids232323223322233233233322332", Id)
2773
+
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
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
 	return
2776
 	return

+ 1 - 1
service/patient_service.go Parādīt failu

822
 func UpdatepatientTwo(patientsNew *models.XtPatientsNew, id int64) error {
822
 func UpdatepatientTwo(patientsNew *models.XtPatientsNew, id int64) error {
823
 
823
 
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,
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
 	return err
826
 	return err
827
 }
827
 }
828
 
828
 

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 1108 - 1
service/secondary_service.go


+ 17 - 9
service/self_drug_service.go Parādīt failu

821
 	return info, err
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
 	db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1")
825
 	db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1")
826
 	table := XTReadDB().Table("xt_base_drug as t").Where("t.status")
826
 	table := XTReadDB().Table("xt_base_drug as t").Where("t.status")
827
 	fmt.Println(table)
827
 	fmt.Println(table)
829
 	if orgid > 0 {
829
 	if orgid > 0 {
830
 		db = db.Where("x.org_id = ?", orgid)
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
 	return info, err
836
 	return info, err
834
 
837
 
835
 }
838
 }
888
 	return err
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
 	likeKey := "%" + keyword + "%"
895
 	likeKey := "%" + keyword + "%"
893
 	offset := (page - 1) * limit
896
 	offset := (page - 1) * limit
894
 	db := XTReadDB().Table("xt_drug_inventory as x").Where("x.status = 1 and type = 4")
897
 	db := XTReadDB().Table("xt_drug_inventory as x").Where("x.status = 1 and type = 4")
910
 	if endtime > 0 {
913
 	if endtime > 0 {
911
 		db = db.Where("x.ctime <=?", endtime)
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
 	return adjust, total, err
920
 	return adjust, total, err
915
 }
921
 }
916
 
922
 
968
 	return damage, err
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
 	return info, err
980
 	return info, err
975
 }
981
 }
976
 
982
 
1088
 	return info, err
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
 	likeKey := "%" + keyword + "%"
1098
 	likeKey := "%" + keyword + "%"
1094
 	offset := (page - 1) * limit
1099
 	offset := (page - 1) * limit
1095
 	db := XTReadDB().Table("xt_drug_inventory as x").Where("x.status = 1")
1100
 	db := XTReadDB().Table("xt_drug_inventory as x").Where("x.status = 1")
1102
 	if orgid > 0 {
1107
 	if orgid > 0 {
1103
 		db = db.Where("x.user_org_id = ?", orgid)
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
 	return list, total, err
1114
 	return list, total, err
1107
 }
1115
 }
1108
 
1116
 

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 707 - 85
service/stock_service.go


+ 23 - 7
service/supply_service.go Parādīt failu

764
 	return info, err
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
 func GetDrugSupplyWarehouseId(id int64, orgid int64) (models.DrugWarehouseInfo, error) {
773
 func GetDrugSupplyWarehouseId(id int64, orgid int64) (models.DrugWarehouseInfo, error) {
768
 	info := models.DrugWarehouseInfo{}
774
 	info := models.DrugWarehouseInfo{}
769
 	err := XTReadDB().Where("supply_warehouse_id = ? and org_id = ? and status = 1", id, orgid).Find(&info).Error
775
 	err := XTReadDB().Where("supply_warehouse_id = ? and org_id = ? and status = 1", id, orgid).Find(&info).Error
770
 	return info, err
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
 func UpdateDrugSupplyWarehousingInfo(id int64, orgid int64) error {
785
 func UpdateDrugSupplyWarehousingInfo(id int64, orgid int64) error {
774
 
786
 
775
 	err := XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("supply_warehouse_id = ? and org_id = ? and status = 1", id, orgid).Updates(map[string]interface{}{"status": 0}).Error
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
 	if len(drugflow) > 0 {
865
 	if len(drugflow) > 0 {
854
 		utx := writeDb.Begin()
866
 		utx := writeDb.Begin()
855
 		if len(drugflow) > 0 {
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
 			insertParams := make([]string, 0)
869
 			insertParams := make([]string, 0)
858
 			insertData := make([]interface{}, 0)
870
 			insertData := make([]interface{}, 0)
859
 			for _, info := range drugflow {
871
 			for _, info := range drugflow {
860
 
872
 
861
-				insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
873
+				insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
862
 				insertData = append(insertData, info.WarehousingId)
874
 				insertData = append(insertData, info.WarehousingId)
863
 				insertData = append(insertData, info.DrugId)
875
 				insertData = append(insertData, info.DrugId)
864
 				insertData = append(insertData, info.Number)
876
 				insertData = append(insertData, info.Number)
893
 				insertData = append(insertData, info.MinUnit)
905
 				insertData = append(insertData, info.MinUnit)
894
 				insertData = append(insertData, info.SupplyWarehouseId)
906
 				insertData = append(insertData, info.SupplyWarehouseId)
895
 				insertData = append(insertData, info.SupplyWarehouseDetailInfo)
907
 				insertData = append(insertData, info.SupplyWarehouseDetailInfo)
908
+				insertData = append(insertData, info.StorehouseId)
896
 			}
909
 			}
897
 			thisSQL += strings.Join(insertParams, ", ")
910
 			thisSQL += strings.Join(insertParams, ", ")
898
 			err = utx.Exec(thisSQL, insertData...).Error
911
 			err = utx.Exec(thisSQL, insertData...).Error
1038
 	return err
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
 	info := models.WarehousingInfo{}
1056
 	info := models.WarehousingInfo{}
1044
 	var err error
1057
 	var err error
1045
 	if source == 1 {
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
 	if source == 2 {
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
 	return info, err
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
 	if source == 1 {
1071
 	if source == 1 {
1059
 		db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1")
1072
 		db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1")
1065
 		if supply_warehouse_detail_info > 0 {
1078
 		if supply_warehouse_detail_info > 0 {
1066
 			db = db.Where("x.supply_warehouse_detail_info = ?", supply_warehouse_detail_info)
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
 		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
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
 

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 1361 - 80
service/warhouse_service.go