Browse Source

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

csx 3 years ago
parent
commit
681498e80c
44 changed files with 8518 additions and 805 deletions
  1. 0 1
      controllers/base_controller.go
  2. 15 1
      controllers/dialysis_api_controller.go
  3. 6 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. 434 0
      controllers/his_deposit_controller.go
  8. 2 2
      controllers/his_project_api_controller.go
  9. 1 1
      controllers/mobile_api_controllers/check_weight_api_controller.go
  10. 240 102
      controllers/mobile_api_controllers/dialysis_api_controller.go
  11. 57 6
      controllers/mobile_api_controllers/patient_api_controller.go
  12. 48 7
      controllers/patient_api_controller.go
  13. 1951 0
      controllers/secondary_order_api_contorller.go
  14. 76 20
      controllers/self_drug_api_congtroller.go
  15. 9 1
      controllers/stock_good_api_controller.go
  16. 712 239
      controllers/stock_in_api_controller.go
  17. 108 19
      controllers/supply_order_api_contorller.go
  18. 9 0
      controllers/verify_login_controller.go
  19. 3 0
      models/dialysis.go
  20. 1 0
      models/dialysis_parameter_models.go
  21. 4 0
      models/drug.go
  22. 17 0
      models/drug_stock.go
  23. 2 0
      models/good_models.go
  24. 97 0
      models/his_deposit_models.go
  25. 2 0
      models/patient_models.go
  26. 199 1
      models/secondary_models.go
  27. 11 0
      models/self_drug_models.go
  28. 157 27
      models/stock_models.go
  29. 2 1
      routers/router.go
  30. 2 2
      service/device_service.go
  31. 7 2
      service/dialysis_service.go
  32. 6 0
      service/doctor_schedule_service.go
  33. 46 17
      service/gobal_config_service.go
  34. 304 0
      service/his_deposit_service.go
  35. 5 1
      service/his_service.go
  36. 1 1
      service/manage_center_service.go
  37. 2 1
      service/mobile_dialysis_service.go
  38. 1 1
      service/patient_service.go
  39. 19 0
      service/role_service.go
  40. 1134 1
      service/secondary_service.go
  41. 19 10
      service/self_drug_service.go
  42. 708 85
      service/stock_service.go
  43. 35 7
      service/supply_service.go
  44. 1361 80
      service/warhouse_service.go

+ 0 - 1
controllers/base_controller.go View File

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
 

+ 15 - 1
controllers/dialysis_api_controller.go View File

3452
 				record.UltrafiltrationRate = ultrafiltration_rate
3452
 				record.UltrafiltrationRate = ultrafiltration_rate
3453
 			}
3453
 			}
3454
 
3454
 
3455
+			if template.TemplateId == 46 { //adminInfo.CurrentOrgId == 9538
3456
+				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60)
3457
+				record.UltrafiltrationRate = ultrafiltration_rate
3458
+			}
3459
+
3460
+			if template.TemplateId == 47 { //adminInfo.CurrentOrgId == 9538
3461
+				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
3462
+				record.UltrafiltrationRate = ultrafiltration_rate
3463
+			}
3464
+
3455
 			// 只针对方济医院
3465
 			// 只针对方济医院
3456
 			if template.TemplateId == 1 && adminInfo.CurrentOrgId != 9849 {
3466
 			if template.TemplateId == 1 && adminInfo.CurrentOrgId != 9849 {
3457
 				value, _ := strconv.ParseFloat(fmt.Sprintf("%.3f", prescription.TargetUltrafiltration/float64(totalMin)*60), 6)
3467
 				value, _ := strconv.ParseFloat(fmt.Sprintf("%.3f", prescription.TargetUltrafiltration/float64(totalMin)*60), 6)
3471
 		}
3481
 		}
3472
 	}
3482
 	}
3473
 
3483
 
3474
-	if template.TemplateId == 6 || template.TemplateId == 20 || template.TemplateId == 22 || template.TemplateId == 32 || template.TemplateId == 34 || template.TemplateId == 41 || template.TemplateId == 43 {
3484
+	if template.TemplateId == 6 || template.TemplateId == 20 || template.TemplateId == 22 || template.TemplateId == 32 || template.TemplateId == 34 || template.TemplateId == 41 || template.TemplateId == 43 || template.TemplateId == 47 {
3475
 		if ultrafiltration_rate > 0 && adminInfo.CurrentOrgId != 9538 {
3485
 		if ultrafiltration_rate > 0 && adminInfo.CurrentOrgId != 9538 {
3476
 			ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
3486
 			ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
3477
 
3487
 
3480
 
3490
 
3481
 	}
3491
 	}
3482
 
3492
 
3493
+	if template.TemplateId == 47 {
3494
+		record.DisplacementQuantity = record.DisplacementQuantity + record.DisplacementQuantity
3495
+	}
3496
+
3483
 	this.ServeSuccessJSON(map[string]interface{}{
3497
 	this.ServeSuccessJSON(map[string]interface{}{
3484
 		"monitor": record,
3498
 		"monitor": record,
3485
 	})
3499
 	})

+ 6 - 1
controllers/dialysis_record_api_controller.go View File

1003
 			tempdispose = "引血" + strconv.FormatInt(blood_drawing, 10) + "ml/min"
1003
 			tempdispose = "引血" + strconv.FormatInt(blood_drawing, 10) + "ml/min"
1004
 		}
1004
 		}
1005
 
1005
 
1006
+		if blood_drawing > 0 && adminUserInfo.CurrentOrgId == 10318 { //adminUserInfo.CurrentOrgId == 9538
1007
+			tempdispose = "引血" + strconv.FormatInt(blood_drawing, 10) + "ml/min"
1008
+		}
1009
+
1006
 		var ultrafiltration_rate float64
1010
 		var ultrafiltration_rate float64
1007
 		_, prescription := service.FindDialysisPrescriptionByReordDate(patientID, schedulestartTime, adminUserInfo.CurrentOrgId)
1011
 		_, prescription := service.FindDialysisPrescriptionByReordDate(patientID, schedulestartTime, adminUserInfo.CurrentOrgId)
1008
 
1012
 
1663
 		tempMinute, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", b), 64)
1667
 		tempMinute, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", b), 64)
1664
 		hour, _ := strconv.ParseInt(fmt.Sprintf("%.0f", a), 10, 64)
1668
 		hour, _ := strconv.ParseInt(fmt.Sprintf("%.0f", a), 10, 64)
1665
 		minute, _ := strconv.ParseInt(fmt.Sprintf("%.0f", tempMinute*60), 10, 64)
1669
 		minute, _ := strconv.ParseInt(fmt.Sprintf("%.0f", tempMinute*60), 10, 64)
1666
-		updateAssessmentErr := service.UpdateAssessmentAfterDate(tempDialysisRecords.PatientId, tempDialysisRecords.UserOrgId, tempDialysisRecords.DialysisDate, hour, minute)
1670
+		monitor, _ := service.GetLastMonitorRecord(tempDialysisRecords.UserOrgId, tempDialysisRecords.PatientId, tempDialysisRecords.DialysisDate)
1671
+		updateAssessmentErr := service.UpdateAssessmentAfterDateOne(tempDialysisRecords.PatientId, tempDialysisRecords.UserOrgId, tempDialysisRecords.DialysisDate, hour, minute, monitor.BreathingRate)
1667
 		if updateAssessmentErr != nil {
1672
 		if updateAssessmentErr != nil {
1668
 			utils.ErrorLog("%v", updateAssessmentErr)
1673
 			utils.ErrorLog("%v", updateAssessmentErr)
1669
 		}
1674
 		}

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


+ 27 - 6
controllers/gobal_config_api_controller.go View File

1607
 
1607
 
1608
 	start_time := c.GetString("start_time")
1608
 	start_time := c.GetString("start_time")
1609
 	end_time := c.GetString("end_time")
1609
 	end_time := c.GetString("end_time")
1610
+	storehouse_id, _ := c.GetInt64("storehouse_id")
1610
 	timeLayout := "2006-01-02"
1611
 	timeLayout := "2006-01-02"
1611
 	loc, _ := time.LoadLocation("Local")
1612
 	loc, _ := time.LoadLocation("Local")
1612
 	var startTime int64
1613
 	var startTime int64
1636
 	page, _ := c.GetInt64("page")
1637
 	page, _ := c.GetInt64("page")
1637
 	limit, _ := c.GetInt64("limit")
1638
 	limit, _ := c.GetInt64("limit")
1638
 
1639
 
1639
-	detail, total, err := service.GetDrugInOrderDetail(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword, page, limit)
1640
+	detail, total, err := service.GetDrugInOrderDetail(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword, page, limit, storehouse_id)
1640
 	var drugType = "药品类型"
1641
 	var drugType = "药品类型"
1641
 	drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
1642
 	drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
1642
 	drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, adminInfo.CurrentOrgId)
1643
 	drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, adminInfo.CurrentOrgId)
1644
+	houseList, _ := service.GetAllStorehouseName(adminInfo.CurrentOrgId)
1643
 	if err != nil {
1645
 	if err != nil {
1644
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1646
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1645
 		return
1647
 		return
1648
 		"detail":         detail,
1650
 		"detail":         detail,
1649
 		"total":          total,
1651
 		"total":          total,
1650
 		"drugTypeParent": drugTypeList,
1652
 		"drugTypeParent": drugTypeList,
1653
+		"houseList":      houseList,
1651
 	})
1654
 	})
1652
 }
1655
 }
1653
 
1656
 
1699
 
1702
 
1700
 	start_time := c.GetString("start_time")
1703
 	start_time := c.GetString("start_time")
1701
 	end_time := c.GetString("end_time")
1704
 	end_time := c.GetString("end_time")
1705
+	storehouse_id, _ := c.GetInt64("storehouse_id")
1702
 	timeLayout := "2006-01-02"
1706
 	timeLayout := "2006-01-02"
1703
 	loc, _ := time.LoadLocation("Local")
1707
 	loc, _ := time.LoadLocation("Local")
1704
 	var startTime int64
1708
 	var startTime int64
1727
 	keyword := c.GetString("keyword")
1731
 	keyword := c.GetString("keyword")
1728
 	limit, _ := c.GetInt64("limit")
1732
 	limit, _ := c.GetInt64("limit")
1729
 	page, _ := c.GetInt64("page")
1733
 	page, _ := c.GetInt64("page")
1730
-	order, total, err := service.GetDrugOutOrder(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword, page, limit)
1734
+	order, total, err := service.GetDrugOutOrder(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword, page, limit, storehouse_id)
1735
+	houseList, _ := service.GetAllStoreHouseList(adminInfo.CurrentOrgId)
1731
 	var drugType = "药品类型"
1736
 	var drugType = "药品类型"
1732
 	drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
1737
 	drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
1733
 	drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, adminInfo.CurrentOrgId)
1738
 	drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, adminInfo.CurrentOrgId)
1739
 		"order":        order,
1744
 		"order":        order,
1740
 		"total":        total,
1745
 		"total":        total,
1741
 		"drugTypeList": drugTypeList,
1746
 		"drugTypeList": drugTypeList,
1747
+		"houseList":    houseList,
1742
 	})
1748
 	})
1743
 }
1749
 }
1744
 
1750
 
1746
 
1752
 
1747
 	start_time := c.GetString("start_time")
1753
 	start_time := c.GetString("start_time")
1748
 	end_time := c.GetString("end_time")
1754
 	end_time := c.GetString("end_time")
1755
+	storehouse_id, _ := c.GetInt64("storehouse_id")
1749
 	timeLayout := "2006-01-02"
1756
 	timeLayout := "2006-01-02"
1750
 	loc, _ := time.LoadLocation("Local")
1757
 	loc, _ := time.LoadLocation("Local")
1751
 	var startTime int64
1758
 	var startTime int64
1774
 	keyword := c.GetString("keyword")
1781
 	keyword := c.GetString("keyword")
1775
 	limit, _ := c.GetInt64("limit")
1782
 	limit, _ := c.GetInt64("limit")
1776
 	page, _ := c.GetInt64("page")
1783
 	page, _ := c.GetInt64("page")
1777
-	orderPrint, _ := service.GetDrugCancelOrderPrint(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword)
1778
-	order, total, err := service.GetDrugCancelOrder(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword, page, limit)
1784
+	orderPrint, _ := service.GetDrugCancelOrderPrint(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword, storehouse_id)
1785
+	order, total, err := service.GetDrugCancelOrder(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword, page, limit, storehouse_id)
1779
 	var drugType = "药品类型"
1786
 	var drugType = "药品类型"
1780
 	drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
1787
 	drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
1781
 	drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, adminInfo.CurrentOrgId)
1788
 	drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, adminInfo.CurrentOrgId)
1789
+	houseList, _ := service.GetAllStoreHouseList(adminInfo.CurrentOrgId)
1782
 	if err != nil {
1790
 	if err != nil {
1783
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1791
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1784
 		return
1792
 		return
1788
 		"total":        total,
1796
 		"total":        total,
1789
 		"orderPrint":   orderPrint,
1797
 		"orderPrint":   orderPrint,
1790
 		"drugTypeList": drugTypeList,
1798
 		"drugTypeList": drugTypeList,
1799
+		"houseList":    houseList,
1791
 	})
1800
 	})
1792
 }
1801
 }
1793
 
1802
 
1925
 	end_time := c.GetString("end_time")
1934
 	end_time := c.GetString("end_time")
1926
 	timeLayout := "2006-01-02"
1935
 	timeLayout := "2006-01-02"
1927
 	loc, _ := time.LoadLocation("Local")
1936
 	loc, _ := time.LoadLocation("Local")
1928
-
1937
+	storehouse_id, _ := c.GetInt64("storehouse_id")
1938
+	drug_id, _ := c.GetInt64("drug_id")
1929
 	var startTime int64
1939
 	var startTime int64
1930
 	if len(start_time) > 0 {
1940
 	if len(start_time) > 0 {
1931
 		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
1941
 		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
1948
 	}
1958
 	}
1949
 	adminUserInfo := c.GetAdminUserInfo()
1959
 	adminUserInfo := c.GetAdminUserInfo()
1950
 
1960
 
1951
-	list, total, err := service.GetAllBaseDurgListCount(page, limit, keyword, drug_type, startTime, endTime, adminUserInfo.CurrentOrgId)
1961
+	list, total, err := service.GetAllBaseDurgListCount(page, limit, keyword, drug_type, startTime, endTime, adminUserInfo.CurrentOrgId, storehouse_id, drug_id)
1952
 
1962
 
1953
 	manufacturerList, _ := service.GetAllManufacturerList(adminUserInfo.CurrentOrgId)
1963
 	manufacturerList, _ := service.GetAllManufacturerList(adminUserInfo.CurrentOrgId)
1964
+
1965
+	houseList, _ := service.GetAllStoreHouseListOne(adminUserInfo.CurrentOrgId)
1966
+
1967
+	medicalList, _ := service.GetAllBaseDrugStockList(adminUserInfo.CurrentOrgId)
1954
 	if err != nil {
1968
 	if err != nil {
1955
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1969
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1956
 		return
1970
 		return
1959
 		"list":             list,
1973
 		"list":             list,
1960
 		"total":            total,
1974
 		"total":            total,
1961
 		"manufacturerList": manufacturerList,
1975
 		"manufacturerList": manufacturerList,
1976
+		"houseList":        houseList,
1977
+		"medicalList":      medicalList,
1962
 	})
1978
 	})
1963
 }
1979
 }
1964
 
1980
 
2068
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
2084
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
2069
 
2085
 
2070
 	drug, _ := service.GetBaseDrugMedical(drug_id)
2086
 	drug, _ := service.GetBaseDrugMedical(drug_id)
2087
+	houseList, _ := service.GetAllStoreHouseList(orgId)
2071
 	if err != nil {
2088
 	if err != nil {
2072
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
2089
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
2073
 		return
2090
 		return
2077
 		"total":            total,
2094
 		"total":            total,
2078
 		"manufacturerList": manufacturerList,
2095
 		"manufacturerList": manufacturerList,
2079
 		"drug":             drug,
2096
 		"drug":             drug,
2097
+		"houseList":        houseList,
2080
 	})
2098
 	})
2081
 }
2099
 }
2082
 
2100
 
2142
 	manufacturerList, err := service.GetAllManufacturerList(orgId)
2160
 	manufacturerList, err := service.GetAllManufacturerList(orgId)
2143
 	drugFlowList, _ := service.GetDrugStockFlowDetail(start_time, orgId)
2161
 	drugFlowList, _ := service.GetDrugStockFlowDetail(start_time, orgId)
2144
 	flowlist, _ := service.GetSingeOrderFlow(id, orgId)
2162
 	flowlist, _ := service.GetSingeOrderFlow(id, orgId)
2163
+
2145
 	if err != nil {
2164
 	if err != nil {
2146
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
2165
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
2147
 		return
2166
 		return
2293
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
2312
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
2294
 	dealerList, _ := service.GetAllDealerList(orgId)
2313
 	dealerList, _ := service.GetAllDealerList(orgId)
2295
 	medical, _ := service.GetBaseDrugMedical(drug_id)
2314
 	medical, _ := service.GetBaseDrugMedical(drug_id)
2315
+	houseList, _ := service.GetAllStoreHouseList(orgId)
2296
 	c.ServeSuccessJSON(map[string]interface{}{
2316
 	c.ServeSuccessJSON(map[string]interface{}{
2297
 		"list":             list,
2317
 		"list":             list,
2298
 		"total":            total,
2318
 		"total":            total,
2299
 		"manufacturerList": manufacturerList,
2319
 		"manufacturerList": manufacturerList,
2300
 		"dealerList":       dealerList,
2320
 		"dealerList":       dealerList,
2301
 		"drug":             medical,
2321
 		"drug":             medical,
2322
+		"houseList":        houseList,
2302
 	})
2323
 	})
2303
 }
2324
 }
2304
 
2325
 

+ 200 - 71
controllers/his_api_controller.go View File

930
 						if len(advices) > 0 {
930
 						if len(advices) > 0 {
931
 							for _, advice := range advices {
931
 							for _, advice := range advices {
932
 								var drug_id int64
932
 								var drug_id int64
933
-								var prescribing_number float64
933
+								//var prescribing_number float64
934
 								var prescribingNumberUnit string
934
 								var prescribingNumberUnit string
935
 								var prescribingNumber string
935
 								var prescribingNumber string
936
+								var prescribing_number_one int64
936
 
937
 
937
 								var adviceId int64
938
 								var adviceId int64
938
 								if advice.(map[string]interface{})["id"] != nil || reflect.TypeOf(advice.(map[string]interface{})["id"]).String() == "float64" {
939
 								if advice.(map[string]interface{})["id"] != nil || reflect.TypeOf(advice.(map[string]interface{})["id"]).String() == "float64" {
940
 								}
941
 								}
941
 								if advice.(map[string]interface{})["prescribing_number"] != nil || reflect.TypeOf(advice.(map[string]interface{})["prescribing_number"]).String() == "string" {
942
 								if advice.(map[string]interface{})["prescribing_number"] != nil || reflect.TypeOf(advice.(map[string]interface{})["prescribing_number"]).String() == "string" {
942
 									prescribing_number_str := advice.(map[string]interface{})["prescribing_number"].(string)
943
 									prescribing_number_str := advice.(map[string]interface{})["prescribing_number"].(string)
943
-									prescribing_number, _ = strconv.ParseFloat(prescribing_number_str, 64)
944
+									//prescribing_number, _ = strconv.ParseFloat(prescribing_number_str, 64)
944
 									prescribingNumber = advice.(map[string]interface{})["prescribing_number"].(string)
945
 									prescribingNumber = advice.(map[string]interface{})["prescribing_number"].(string)
946
+									prescribing_number_one, _ = strconv.ParseInt(prescribing_number_str, 10, 64)
945
 								}
947
 								}
946
 
948
 
947
 								if advice.(map[string]interface{})["prescribing_number_unit"] != nil && reflect.TypeOf(advice.(map[string]interface{})["prescribing_number_unit"]).String() == "string" {
949
 								if advice.(map[string]interface{})["prescribing_number_unit"] != nil && reflect.TypeOf(advice.(map[string]interface{})["prescribing_number_unit"]).String() == "string" {
958
 									return
960
 									return
959
 								}
961
 								}
960
 								//查询药品的所有库存
962
 								//查询药品的所有库存
961
-								list, _ := service.GetDrugWarehouseInfoPrescriptionSeven(drug_id, adminInfo.CurrentOrgId)
962
-								var total_count int64
963
-								for _, it := range list {
964
-									total_count += it.StockMaxNumber*drug.MinNumber + it.StockMinNumber
965
-								}
966
-								totals := strconv.FormatInt(total_count, 10)
963
+								//list, _ := service.GetDrugWarehouseInfoPrescriptionSeven(drug_id, adminInfo.CurrentOrgId)
964
+								//var total_count int64
965
+								//for _, it := range list {
966
+								//	total_count += it.StockMaxNumber*drug.MinNumber + it.StockMinNumber
967
+								//}
968
+								//totals := strconv.FormatInt(total_count, 10)
967
 								//查询该药品是否存在开药记录
969
 								//查询该药品是否存在开药记录
968
 								advicelist, _ := service.GetHisAdviceListByDrugIdEight(drug_id, patient_id, recordDateTime, adviceId)
970
 								advicelist, _ := service.GetHisAdviceListByDrugIdEight(drug_id, patient_id, recordDateTime, adviceId)
969
 
971
 
970
 								//新增处方
972
 								//新增处方
971
 								if advicelist.ID == 0 {
973
 								if advicelist.ID == 0 {
972
-									all_count, _ := strconv.ParseFloat(totals, 64)
974
+									//	all_count, _ := strconv.ParseFloat(totals, 64)
973
 									if prescribingNumberUnit == drug.MinUnit {
975
 									if prescribingNumberUnit == drug.MinUnit {
974
-										if prescribing_number > all_count {
976
+										if prescribing_number_one > drug.SumCount {
975
 											c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
977
 											c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
976
 											return
978
 											return
977
 										}
979
 										}
978
 									} else {
980
 									} else {
979
 										if prescribingNumberUnit == drug.MaxUnit {
981
 										if prescribingNumberUnit == drug.MaxUnit {
980
-											num := prescribing_number * float64(drug.MinNumber)
981
-											if num > all_count {
982
+											num := prescribing_number_one * drug.MinNumber
983
+											if num > drug.SumCount {
982
 												c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
984
 												c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
983
 												return
985
 												return
984
 											}
986
 											}
1013
 									//如果修改的数量大于之前修改的数量
1015
 									//如果修改的数量大于之前修改的数量
1014
 									if (number_count - device_number) > 0 {
1016
 									if (number_count - device_number) > 0 {
1015
 										//如果修改的差数量 大于库存数量
1017
 										//如果修改的差数量 大于库存数量
1016
-										if (number_count - device_number) > total_count {
1018
+										if (number_count - device_number) > drug.SumCount {
1017
 											c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
1019
 											c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
1018
 											return
1020
 											return
1019
 										}
1021
 										}
1028
 										if druginfo.CountUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
1030
 										if druginfo.CountUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
1029
 
1031
 
1030
 											service.ModefyDrugByWarehouseInfo(druginfo.WarehouseInfoId, number_count)
1032
 											service.ModefyDrugByWarehouseInfo(druginfo.WarehouseInfoId, number_count)
1033
+
1034
+											//查询默认仓库
1035
+											houseConfig, _ := service.GetAllStoreHouseConfig(druginfo.OrgId)
1036
+											//查询默认仓库剩余多少库存
1037
+											list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, druginfo.OrgId, drug_id)
1038
+											var sum_count int64
1039
+											var sum_in_count int64
1040
+											for _, it := range list {
1041
+												baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
1042
+												if it.MaxUnit == baseDrug.MaxUnit {
1043
+													it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
1044
+													it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
1045
+
1046
+												}
1047
+												sum_count += it.StockMaxNumber + it.StockMinNumber
1048
+												sum_in_count += it.WarehousingCount
1049
+											}
1050
+											service.UpdateMedicalSumCount(drug_id, sum_count, sum_in_count, druginfo.OrgId)
1031
 										}
1051
 										}
1032
 										if druginfo.CountUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
1052
 										if druginfo.CountUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
1033
 											var stock_max_number int64
1053
 											var stock_max_number int64
1036
 											if number_count >= drug.MinNumber {
1056
 											if number_count >= drug.MinNumber {
1037
 
1057
 
1038
 												stock_max_number = device_number / drug.MinNumber
1058
 												stock_max_number = device_number / drug.MinNumber
1059
+
1039
 												service.ModefyDrugByWarehouseInfo(druginfo.WarehouseInfoId, stock_max_number)
1060
 												service.ModefyDrugByWarehouseInfo(druginfo.WarehouseInfoId, stock_max_number)
1061
+
1040
 												stock_min_number = device_number % drug.MinNumber
1062
 												stock_min_number = device_number % drug.MinNumber
1041
 												service.ModefyDrugByWarehouseInfoOne(druginfo.WarehouseInfoId, stock_min_number)
1063
 												service.ModefyDrugByWarehouseInfoOne(druginfo.WarehouseInfoId, stock_min_number)
1064
+												//查询默认仓库
1065
+												houseConfig, _ := service.GetAllStoreHouseConfig(druginfo.OrgId)
1066
+												//查询默认仓库剩余多少库存
1067
+												list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, druginfo.OrgId, drug_id)
1068
+												var sum_count int64
1069
+												var sum_in_count int64
1070
+												for _, it := range list {
1071
+													baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
1072
+													if it.MaxUnit == baseDrug.MaxUnit {
1073
+														it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
1074
+														it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
1075
+
1076
+													}
1077
+													sum_count += it.StockMaxNumber + it.StockMinNumber
1078
+													sum_in_count += it.WarehousingCount
1079
+												}
1080
+												service.UpdateMedicalSumCount(drug_id, sum_count, sum_in_count, druginfo.OrgId)
1042
 
1081
 
1043
 											} else {
1082
 											} else {
1044
 
1083
 
1045
 												service.ModefyDrugByWarehouseInfoOne(druginfo.WarehouseInfoId, device_number)
1084
 												service.ModefyDrugByWarehouseInfoOne(druginfo.WarehouseInfoId, device_number)
1085
+												//查询默认仓库
1086
+												houseConfig, _ := service.GetAllStoreHouseConfig(druginfo.OrgId)
1087
+												//查询默认仓库剩余多少库存
1088
+												list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, druginfo.OrgId, drug_id)
1089
+												var sum_count int64
1090
+												var sum_in_count int64
1091
+												for _, it := range list {
1092
+													baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
1093
+													if it.MaxUnit == baseDrug.MaxUnit {
1094
+														it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
1095
+														it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
1096
+
1097
+													}
1098
+													sum_count += it.StockMaxNumber + it.StockMinNumber
1099
+													sum_in_count += it.WarehousingCount
1100
+												}
1101
+												service.UpdateMedicalSumCount(drug_id, sum_count, sum_in_count, druginfo.OrgId)
1046
 											}
1102
 											}
1047
 										}
1103
 										}
1048
 
1104
 
1049
 										if druginfo.CountUnit == drug.MaxUnit && druginfo.CountUnit == drug.MinUnit && drug.MaxUnit == drug.MinUnit {
1105
 										if druginfo.CountUnit == drug.MaxUnit && druginfo.CountUnit == drug.MinUnit && drug.MaxUnit == drug.MinUnit {
1050
 											service.ModefyDrugByWarehouseInfo(druginfo.WarehouseInfoId, device_number)
1106
 											service.ModefyDrugByWarehouseInfo(druginfo.WarehouseInfoId, device_number)
1107
+											//查询默认仓库
1108
+											houseConfig, _ := service.GetAllStoreHouseConfig(druginfo.OrgId)
1109
+											//查询默认仓库剩余多少库存
1110
+											list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, druginfo.OrgId, drug_id)
1111
+											var sum_count int64
1112
+											var sum_in_count int64
1113
+											for _, it := range list {
1114
+												baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
1115
+												if it.MaxUnit == baseDrug.MaxUnit {
1116
+													it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
1117
+													it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
1118
+
1119
+												}
1120
+												sum_count += it.StockMaxNumber + it.StockMinNumber
1121
+												sum_in_count += it.WarehousingCount
1122
+											}
1123
+											service.UpdateMedicalSumCount(drug_id, sum_count, sum_in_count, druginfo.OrgId)
1051
 										}
1124
 										}
1052
 										//删除记录
1125
 										//删除记录
1053
 										service.DeleteDrugAutoWarehouseSeven(drug_id, patient_id, recordDateTime, adviceId)
1126
 										service.DeleteDrugAutoWarehouseSeven(drug_id, patient_id, recordDateTime, adviceId)
1077
 
1150
 
1078
 								var project_id int64
1151
 								var project_id int64
1079
 								var project_type int64
1152
 								var project_type int64
1080
-								var totals float64
1153
+								//var totals float64
1081
 								var project_name string
1154
 								var project_name string
1082
 								var parsetotal int64
1155
 								var parsetotal int64
1083
 								var id int64
1156
 								var id int64
1093
 								}
1166
 								}
1094
 								if project.(map[string]interface{})["total"] != nil || reflect.TypeOf(project.(map[string]interface{})["total"]).String() == "string" {
1167
 								if project.(map[string]interface{})["total"] != nil || reflect.TypeOf(project.(map[string]interface{})["total"]).String() == "string" {
1095
 									total, _ := project.(map[string]interface{})["total"].(string)
1168
 									total, _ := project.(map[string]interface{})["total"].(string)
1096
-									totals, _ = strconv.ParseFloat(total, 64)
1169
+									//	totals, _ = strconv.ParseFloat(total, 64)
1097
 									parsetotal, _ = strconv.ParseInt(total, 10, 64)
1170
 									parsetotal, _ = strconv.ParseInt(total, 10, 64)
1098
 								}
1171
 								}
1099
 
1172
 
1112
 
1185
 
1113
 									if len(goodWarehouseInfo) == 0 {
1186
 									if len(goodWarehouseInfo) == 0 {
1114
 										//查询耗材库存
1187
 										//查询耗材库存
1115
-										list, _ := service.GetGoodWarehouseInfoSeven(project_id)
1116
-										var stock_count int64
1117
-										for _, it := range list {
1118
-											stock_count += it.StockCount
1119
-										}
1120
-										stock_counts := strconv.FormatInt(stock_count, 10)
1121
-										stock_total_count, _ := strconv.ParseFloat(stock_counts, 64)
1122
-										if totals > stock_total_count {
1188
+										//list, _ := service.GetGoodWarehouseInfoSeven(project_id)
1189
+										//var stock_count int64
1190
+										//for _, it := range list {
1191
+										//	stock_count += it.StockCount
1192
+										//}
1193
+										//stock_counts := strconv.FormatInt(stock_count, 10)
1194
+										//stock_total_count, _ := strconv.ParseFloat(stock_counts, 64)
1195
+										//if totals > stock_total_count {
1196
+										//	c.ServeDynamicFailJsonSend(project_name + "库存不足")
1197
+										//	return
1198
+										//}
1199
+
1200
+										good, _ := service.GetGoodInformationByGoodId(project_id)
1201
+										if parsetotal > good.SumCount {
1123
 											c.ServeDynamicFailJsonSend(project_name + "库存不足")
1202
 											c.ServeDynamicFailJsonSend(project_name + "库存不足")
1124
 											return
1203
 											return
1125
 										}
1204
 										}
1129
 										for _, item := range goodList {
1208
 										for _, item := range goodList {
1130
 											//回退库存
1209
 											//回退库存
1131
 											service.ModefyWarehouseInfo(item.Count, item.WarehouseInfotId)
1210
 											service.ModefyWarehouseInfo(item.Count, item.WarehouseInfotId)
1211
+											//查询默认仓库
1212
+											houseConfig, _ := service.GetAllStoreHouseConfig(item.GoodId)
1213
+											goodList, _ := service.GetGoodSumCountByStoreId(houseConfig.StorehouseOutInfo, item.ProjectId, item.OrgId)
1214
+											var sum_count int64
1215
+											var sum_in_count int64
1216
+											for _, it := range goodList {
1217
+												sum_count += it.StockCount
1218
+												sum_in_count += it.WarehousingCount
1219
+											}
1220
+											service.UpdateGoodByGoodId(item.GoodId, sum_count, sum_in_count, item.OrgId)
1132
 										}
1221
 										}
1133
 										//删除记录
1222
 										//删除记录
1134
 										service.DeleteAutoWarehouse(patient_id, recordDateTime)
1223
 										service.DeleteAutoWarehouse(patient_id, recordDateTime)
1147
 											for _, item := range goodList {
1236
 											for _, item := range goodList {
1148
 												//回退库存
1237
 												//回退库存
1149
 												service.ModefyWarehouseInfo(item.Count, item.WarehouseInfotId)
1238
 												service.ModefyWarehouseInfo(item.Count, item.WarehouseInfotId)
1239
+												//查询默认仓库
1240
+												houseConfig, _ := service.GetAllStoreHouseConfig(item.GoodId)
1241
+												goodList, _ := service.GetGoodSumCountByStoreId(houseConfig.StorehouseOutInfo, item.ProjectId, item.OrgId)
1242
+												var sum_count int64
1243
+												var sum_in_count int64
1244
+												for _, it := range goodList {
1245
+													sum_count += it.StockCount
1246
+													sum_in_count += it.WarehousingCount
1247
+												}
1248
+												service.UpdateGoodByGoodId(item.GoodId, sum_count, sum_in_count, item.OrgId)
1150
 											}
1249
 											}
1151
 											//删除记录
1250
 											//删除记录
1152
 											service.DeleteAutoWarehouse(patient_id, recordDateTime)
1251
 											service.DeleteAutoWarehouse(patient_id, recordDateTime)
1851
 	_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
1950
 	_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
1852
 
1951
 
1853
 	_, stockConfig := service.FindAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
1952
 	_, stockConfig := service.FindAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
1854
-
1953
+	houseConfig, _ := service.GetAllStoreHouseConfig(c.GetAdminUserInfo().CurrentOrgId)
1855
 	if len(projects) > 0 {
1954
 	if len(projects) > 0 {
1856
 		for _, item := range projects {
1955
 		for _, item := range projects {
1857
 			service.DeletePrintInfo(item.ID) //删除打印信息
1956
 			service.DeletePrintInfo(item.ID) //删除打印信息
1871
 					orderNumber := "CKTKD" + strconv.FormatInt(c.GetAdminUserInfo().CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
1970
 					orderNumber := "CKTKD" + strconv.FormatInt(c.GetAdminUserInfo().CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
1872
 
1971
 
1873
 					cancelStock := models.CancelStock{
1972
 					cancelStock := models.CancelStock{
1874
-						OrderNumber: orderNumber,
1875
-						OperaTime:   operation_time,
1876
-						OrgId:       c.GetAdminUserInfo().CurrentOrgId,
1877
-						Creater:     creater,
1878
-						Ctime:       time.Now().Unix(),
1879
-						Status:      1,
1880
-						ReturnTime:  item.RecordDate,
1881
-						Type:        1,
1973
+						OrderNumber:  orderNumber,
1974
+						OperaTime:    operation_time,
1975
+						OrgId:        c.GetAdminUserInfo().CurrentOrgId,
1976
+						Creater:      creater,
1977
+						Ctime:        time.Now().Unix(),
1978
+						Status:       1,
1979
+						ReturnTime:   item.RecordDate,
1980
+						Type:         1,
1981
+						StorehouseId: houseConfig.StorehouseOutInfo,
1882
 					}
1982
 					}
1883
 					_, msgerrkonde := service.GetCancelStockDetailByOrderNumberOne(item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
1983
 					_, msgerrkonde := service.GetCancelStockDetailByOrderNumberOne(item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
1884
 					if msgerrkonde == gorm.ErrRecordNotFound {
1984
 					if msgerrkonde == gorm.ErrRecordNotFound {
1914
 							WarehouseInfoId: info.WarehouseInfotId,
2014
 							WarehouseInfoId: info.WarehouseInfotId,
1915
 							PatientId:       info.PatientId,
2015
 							PatientId:       info.PatientId,
1916
 							RecordDate:      info.SysRecordTime,
2016
 							RecordDate:      info.SysRecordTime,
2017
+							StorehouseId:    houseConfig.StorehouseOutInfo,
1917
 						}
2018
 						}
1918
 
2019
 
1919
 						service.CreateCancelStockInfoOne(&cancelStockInfo)
2020
 						service.CreateCancelStockInfoOne(&cancelStockInfo)
1950
 							CancelOutDetailId:       cancelInfo.ID,
2051
 							CancelOutDetailId:       cancelInfo.ID,
1951
 							ProductDate:             info.ProductDate,
2052
 							ProductDate:             info.ProductDate,
1952
 							ExpireDate:              info.ExpiryDate,
2053
 							ExpireDate:              info.ExpiryDate,
2054
+							StorehouseId:            houseConfig.StorehouseOutInfo,
1953
 						}
2055
 						}
1954
 						service.CreateStockFlowOne(flow)
2056
 						service.CreateStockFlowOne(flow)
1955
 
2057
 
1967
 						}
2069
 						}
1968
 						//回退库存
2070
 						//回退库存
1969
 						service.UpDateWarehouseInfoByStockDelete(info.WarehouseInfotId, total_count)
2071
 						service.UpDateWarehouseInfoByStockDelete(info.WarehouseInfotId, total_count)
1970
-
2072
+						service.ModifyGoodAddInformation(info.GoodId, total_count, info.OrgId)
1971
 						//查询今日该耗材退库数量
2073
 						//查询今日该耗材退库数量
1972
 						cancelInfoOne, _ := service.GetCancelStockInfoByPatientId(info.PatientId, item.ProjectId, info.SysRecordTime)
2074
 						cancelInfoOne, _ := service.GetCancelStockInfoByPatientId(info.PatientId, item.ProjectId, info.SysRecordTime)
1973
 						var cancel_Count int64
2075
 						var cancel_Count int64
2002
 									Manufacturer:            0,
2104
 									Manufacturer:            0,
2003
 									Type:                    1,
2105
 									Type:                    1,
2004
 									IsSys:                   1,
2106
 									IsSys:                   1,
2107
+									StorehouseId:            houseConfig.StorehouseOutInfo,
2005
 								}
2108
 								}
2006
 								err := service.AddSigleWarehouseOut(&warehouseOut)
2109
 								err := service.AddSigleWarehouseOut(&warehouseOut)
2007
 								if err != nil {
2110
 								if err != nil {
2009
 									return
2112
 									return
2010
 								}
2113
 								}
2011
 								prepare := &models.DialysisBeforePrepare{
2114
 								prepare := &models.DialysisBeforePrepare{
2012
-									UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
2013
-									PatientId:  info.PatientId,
2014
-									RecordDate: info.SysRecordTime,
2015
-									GoodId:     item.ProjectId,
2016
-									GoodTypeId: info.GoodTypeId,
2017
-									Count:      cha_count,
2115
+									UserOrgId:    c.GetAdminUserInfo().CurrentOrgId,
2116
+									PatientId:    info.PatientId,
2117
+									RecordDate:   info.SysRecordTime,
2118
+									GoodId:       item.ProjectId,
2119
+									GoodTypeId:   info.GoodTypeId,
2120
+									Count:        cha_count,
2121
+									StorehouseId: houseConfig.StorehouseOutInfo,
2018
 								}
2122
 								}
2019
 								//出库
2123
 								//出库
2020
 								service.ConsumablesDelivery(c.GetAdminUserInfo().CurrentOrgId, info.PatientId, info.SysRecordTime, prepare, &warehouseOut, cha_count)
2124
 								service.ConsumablesDelivery(c.GetAdminUserInfo().CurrentOrgId, info.PatientId, info.SysRecordTime, prepare, &warehouseOut, cha_count)
2021
 							} else if err == nil {
2125
 							} else if err == nil {
2022
 
2126
 
2023
 								prepare := &models.DialysisBeforePrepare{
2127
 								prepare := &models.DialysisBeforePrepare{
2024
-									UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
2025
-									PatientId:  info.PatientId,
2026
-									RecordDate: info.SysRecordTime,
2027
-									GoodId:     item.ProjectId,
2028
-									GoodTypeId: info.GoodTypeId,
2029
-									Count:      cha_count,
2128
+									UserOrgId:    c.GetAdminUserInfo().CurrentOrgId,
2129
+									PatientId:    info.PatientId,
2130
+									RecordDate:   info.SysRecordTime,
2131
+									GoodId:       item.ProjectId,
2132
+									GoodTypeId:   info.GoodTypeId,
2133
+									Count:        cha_count,
2134
+									StorehouseId: houseConfig.StorehouseOutInfo,
2030
 								}
2135
 								}
2031
 								//出库
2136
 								//出库
2032
 								service.ConsumablesDelivery(c.GetAdminUserInfo().CurrentOrgId, info.PatientId, info.SysRecordTime, prepare, &out, cha_count)
2137
 								service.ConsumablesDelivery(c.GetAdminUserInfo().CurrentOrgId, info.PatientId, info.SysRecordTime, prepare, &out, cha_count)
2076
 						}
2181
 						}
2077
 
2182
 
2078
 						service.UpdateDrugWarehouse(info.WarehouseInfoId, warehouseInfo)
2183
 						service.UpdateDrugWarehouse(info.WarehouseInfoId, warehouseInfo)
2079
-
2184
+						service.ModifyDrugAddInformation(info.DrugId, warehouseInfo.StockMinNumber, warehouseInfo.OrgId)
2080
 						adminUserInfo := c.GetAdminUserInfo()
2185
 						adminUserInfo := c.GetAdminUserInfo()
2081
 						operation_time := time.Now().Unix()
2186
 						operation_time := time.Now().Unix()
2082
 						creater := adminUserInfo.AdminUser.Id
2187
 						creater := adminUserInfo.AdminUser.Id
2099
 							Dealer:       info.Dealer,
2204
 							Dealer:       info.Dealer,
2100
 							Manufacturer: info.Manufacturer,
2205
 							Manufacturer: info.Manufacturer,
2101
 							Type:         1,
2206
 							Type:         1,
2207
+							StorehouseId: houseConfig.DrugStorehouseOut,
2102
 						}
2208
 						}
2103
 						service.AddSigleDrugCancelStock(&cancelStock)
2209
 						service.AddSigleDrugCancelStock(&cancelStock)
2104
 
2210
 
2127
 							ProductDate:      info.ProductDate,
2233
 							ProductDate:      info.ProductDate,
2128
 							ExpiryDate:       info.ExpiryDate,
2234
 							ExpiryDate:       info.ExpiryDate,
2129
 							BatchNumberId:    info.WarehouseInfoId,
2235
 							BatchNumberId:    info.WarehouseInfoId,
2236
+							StorehouseId:     houseConfig.DrugStorehouseOut,
2130
 						}
2237
 						}
2131
 
2238
 
2132
 						flow := models.DrugFlow{
2239
 						flow := models.DrugFlow{
2162
 							MaxUnit:                 info.CountUnit,
2269
 							MaxUnit:                 info.CountUnit,
2163
 							MinUnit:                 "",
2270
 							MinUnit:                 "",
2164
 							AdviceId:                info.AdviceId,
2271
 							AdviceId:                info.AdviceId,
2272
+							StorehouseId:            houseConfig.DrugStorehouseOut,
2165
 						}
2273
 						}
2166
 						service.CreatedCancelStock(cancelStockInfo)
2274
 						service.CreatedCancelStock(cancelStockInfo)
2167
 						service.CreateDrugFlowOne(flow)
2275
 						service.CreateDrugFlowOne(flow)
2178
 						if item.PrescribingNumberUnit == drug.MaxUnit {
2286
 						if item.PrescribingNumberUnit == drug.MaxUnit {
2179
 							warehouseInfo := models.DrugWarehouseInfo{
2287
 							warehouseInfo := models.DrugWarehouseInfo{
2180
 								StockMaxNumber: prescribingNumber,
2288
 								StockMaxNumber: prescribingNumber,
2289
+								StorehouseId:   houseConfig.DrugStorehouseOut,
2181
 							}
2290
 							}
2182
 							service.UpdateDrugWarehouseOne(info.WarehouseInfoId, warehouseInfo)
2291
 							service.UpdateDrugWarehouseOne(info.WarehouseInfoId, warehouseInfo)
2183
-
2292
+							var sum_count int64
2293
+							sum_count = prescribingNumber * drug.MinNumber
2294
+							service.ModifyDrugAddInformation(info.DrugId, sum_count, info.OrgId)
2184
 						}
2295
 						}
2185
 
2296
 
2186
 						adminUserInfo := c.GetAdminUserInfo()
2297
 						adminUserInfo := c.GetAdminUserInfo()
2205
 							Dealer:       info.Dealer,
2316
 							Dealer:       info.Dealer,
2206
 							Manufacturer: info.Manufacturer,
2317
 							Manufacturer: info.Manufacturer,
2207
 							Type:         1,
2318
 							Type:         1,
2319
+							StorehouseId: houseConfig.DrugStorehouseOut,
2208
 						}
2320
 						}
2209
 						service.AddSigleDrugCancelStock(&cancelStock)
2321
 						service.AddSigleDrugCancelStock(&cancelStock)
2210
 
2322
 
2234
 							ProductDate:      info.ProductDate,
2346
 							ProductDate:      info.ProductDate,
2235
 							ExpiryDate:       info.ExpiryDate,
2347
 							ExpiryDate:       info.ExpiryDate,
2236
 							BatchNumberId:    info.WarehouseInfoId,
2348
 							BatchNumberId:    info.WarehouseInfoId,
2349
+							StorehouseId:     houseConfig.DrugStorehouseOut,
2237
 						}
2350
 						}
2238
 
2351
 
2239
 						flow := models.DrugFlow{
2352
 						flow := models.DrugFlow{
2270
 							MaxUnit:                 info.CountUnit,
2383
 							MaxUnit:                 info.CountUnit,
2271
 							MinUnit:                 "",
2384
 							MinUnit:                 "",
2272
 							AdviceId:                info.AdviceId,
2385
 							AdviceId:                info.AdviceId,
2386
+							StorehouseId:            houseConfig.DrugStorehouseOut,
2273
 						}
2387
 						}
2274
 						service.CreatedCancelStock(cancelStockInfo)
2388
 						service.CreatedCancelStock(cancelStockInfo)
2275
 						service.CreateDrugFlowOne(flow)
2389
 						service.CreateDrugFlowOne(flow)
2320
 		if drugStockConfig.IsOpen == 1 {
2434
 		if drugStockConfig.IsOpen == 1 {
2321
 			//判断该医嘱是否执行了
2435
 			//判断该医嘱是否执行了
2322
 			if advice.ExecutionState == 1 {
2436
 			if advice.ExecutionState == 1 {
2323
-
2437
+				houseConfig, _ := service.GetAllStoreHouseConfig(advice.UserOrgId)
2324
 				//查询该病人该药品是否有库存记录
2438
 				//查询该病人该药品是否有库存记录
2325
 				info, errcode := service.GetDrugAutoWarehouseOutSeven(advice.PatientId, advice.AdviceDate, advice.DrugId, advice.ID)
2439
 				info, errcode := service.GetDrugAutoWarehouseOutSeven(advice.PatientId, advice.AdviceDate, advice.DrugId, advice.ID)
2326
 				if errcode == gorm.ErrRecordNotFound {
2440
 				if errcode == gorm.ErrRecordNotFound {
2339
 						}
2453
 						}
2340
 
2454
 
2341
 						service.UpdateDrugWarehouse(info.WarehouseInfoId, warehouseInfo)
2455
 						service.UpdateDrugWarehouse(info.WarehouseInfoId, warehouseInfo)
2342
-
2456
+						service.ModifyDrugAddInformation(info.DrugId, warehouseInfo.StockMinNumber, info.OrgId)
2343
 						adminUserInfo := c.GetAdminUserInfo()
2457
 						adminUserInfo := c.GetAdminUserInfo()
2344
 						operation_time := time.Now().Unix()
2458
 						operation_time := time.Now().Unix()
2345
 						creater := adminUserInfo.AdminUser.Id
2459
 						creater := adminUserInfo.AdminUser.Id
2362
 							Dealer:       info.Dealer,
2476
 							Dealer:       info.Dealer,
2363
 							Manufacturer: info.Manufacturer,
2477
 							Manufacturer: info.Manufacturer,
2364
 							Type:         1,
2478
 							Type:         1,
2479
+							StorehouseId: houseConfig.DrugStorehouseOut,
2365
 						}
2480
 						}
2366
 						service.AddSigleDrugCancelStock(&cancelStock)
2481
 						service.AddSigleDrugCancelStock(&cancelStock)
2367
 
2482
 
2390
 							ProductDate:      info.ProductDate,
2505
 							ProductDate:      info.ProductDate,
2391
 							ExpiryDate:       info.ExpiryDate,
2506
 							ExpiryDate:       info.ExpiryDate,
2392
 							BatchNumberId:    info.WarehouseInfoId,
2507
 							BatchNumberId:    info.WarehouseInfoId,
2508
+							StorehouseId:     houseConfig.DrugStorehouseOut,
2393
 						}
2509
 						}
2394
 
2510
 
2395
 						flow := models.DrugFlow{
2511
 						flow := models.DrugFlow{
2425
 							MaxUnit:                 info.CountUnit,
2541
 							MaxUnit:                 info.CountUnit,
2426
 							MinUnit:                 "",
2542
 							MinUnit:                 "",
2427
 							AdviceId:                info.AdviceId,
2543
 							AdviceId:                info.AdviceId,
2544
+							StorehouseId:            houseConfig.DrugStorehouseOut,
2428
 						}
2545
 						}
2429
 						service.CreatedCancelStock(cancelStockInfo)
2546
 						service.CreatedCancelStock(cancelStockInfo)
2430
 						service.CreateDrugFlowOne(flow)
2547
 						service.CreateDrugFlowOne(flow)
2443
 							warehouseInfo := models.DrugWarehouseInfo{
2560
 							warehouseInfo := models.DrugWarehouseInfo{
2444
 								StockMaxNumber: prescribingNumber,
2561
 								StockMaxNumber: prescribingNumber,
2445
 							}
2562
 							}
2563
+							var sum_count int64
2564
+							sum_count = prescribingNumber * drug.MinNumber
2446
 							service.UpdateDrugWarehouseOne(info.WarehouseInfoId, warehouseInfo)
2565
 							service.UpdateDrugWarehouseOne(info.WarehouseInfoId, warehouseInfo)
2447
-
2566
+							service.ModifyDrugAddInformation(info.DrugId, sum_count, info.OrgId)
2448
 						}
2567
 						}
2449
 
2568
 
2450
 						adminUserInfo := c.GetAdminUserInfo()
2569
 						adminUserInfo := c.GetAdminUserInfo()
2469
 							Dealer:       info.Dealer,
2588
 							Dealer:       info.Dealer,
2470
 							Manufacturer: info.Manufacturer,
2589
 							Manufacturer: info.Manufacturer,
2471
 							Type:         1,
2590
 							Type:         1,
2591
+							StorehouseId: houseConfig.DrugStorehouseOut,
2472
 						}
2592
 						}
2473
 						service.AddSigleDrugCancelStock(&cancelStock)
2593
 						service.AddSigleDrugCancelStock(&cancelStock)
2474
 
2594
 
2497
 							ProductDate:      info.ProductDate,
2617
 							ProductDate:      info.ProductDate,
2498
 							ExpiryDate:       info.ExpiryDate,
2618
 							ExpiryDate:       info.ExpiryDate,
2499
 							BatchNumberId:    info.WarehouseInfoId,
2619
 							BatchNumberId:    info.WarehouseInfoId,
2620
+							StorehouseId:     houseConfig.DrugStorehouseOut,
2500
 						}
2621
 						}
2501
 
2622
 
2502
 						flow := models.DrugFlow{
2623
 						flow := models.DrugFlow{
2532
 							MaxUnit:                 info.CountUnit,
2653
 							MaxUnit:                 info.CountUnit,
2533
 							MinUnit:                 "",
2654
 							MinUnit:                 "",
2534
 							AdviceId:                info.AdviceId,
2655
 							AdviceId:                info.AdviceId,
2656
+							StorehouseId:            houseConfig.DrugStorehouseOut,
2535
 						}
2657
 						}
2536
 						service.CreatedCancelStock(cancelStockInfo)
2658
 						service.CreatedCancelStock(cancelStockInfo)
2537
 						service.CreateDrugFlowOne(flow)
2659
 						service.CreateDrugFlowOne(flow)
2576
 		if project.Type == 3 {
2698
 		if project.Type == 3 {
2577
 			good, _ := service.FindGoodInfoByIdTwo(project.ProjectId)
2699
 			good, _ := service.FindGoodInfoByIdTwo(project.ProjectId)
2578
 			f_count, _ := strconv.ParseFloat(project.Count, 64)
2700
 			f_count, _ := strconv.ParseFloat(project.Count, 64)
2701
+			houseConfig, _ := service.GetAllStoreHouseConfig(c.GetAdminUserInfo().CurrentOrgId)
2579
 			good.Total = good.Total + f_count
2702
 			good.Total = good.Total + f_count
2580
 			service.UpdateGoodInfo(&good)
2703
 			service.UpdateGoodInfo(&good)
2581
 
2704
 
2589
 			orderNumber := "CKTKD" + strconv.FormatInt(adminInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
2712
 			orderNumber := "CKTKD" + strconv.FormatInt(adminInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
2590
 
2713
 
2591
 			cancelStock := models.CancelStock{
2714
 			cancelStock := models.CancelStock{
2592
-				OrderNumber: orderNumber,
2593
-				OperaTime:   operation_time,
2594
-				OrgId:       adminInfo.CurrentOrgId,
2595
-				Creater:     creater,
2596
-				Ctime:       time.Now().Unix(),
2597
-				Status:      1,
2598
-				ReturnTime:  project.RecordDate,
2599
-				Type:        1,
2715
+				OrderNumber:  orderNumber,
2716
+				OperaTime:    operation_time,
2717
+				OrgId:        adminInfo.CurrentOrgId,
2718
+				Creater:      creater,
2719
+				Ctime:        time.Now().Unix(),
2720
+				Status:       1,
2721
+				ReturnTime:   project.RecordDate,
2722
+				Type:         1,
2723
+				StorehouseId: houseConfig.StorehouseOutInfo,
2600
 			}
2724
 			}
2601
 			_, msgerrkonde := service.GetCancelStockDetailByOrderNumberOne(project.RecordDate, adminInfo.CurrentOrgId)
2725
 			_, msgerrkonde := service.GetCancelStockDetailByOrderNumberOne(project.RecordDate, adminInfo.CurrentOrgId)
2602
 			if msgerrkonde == gorm.ErrRecordNotFound {
2726
 			if msgerrkonde == gorm.ErrRecordNotFound {
2633
 					WarehouseInfoId: info.WarehouseInfotId,
2757
 					WarehouseInfoId: info.WarehouseInfotId,
2634
 					PatientId:       info.PatientId,
2758
 					PatientId:       info.PatientId,
2635
 					RecordDate:      info.SysRecordTime,
2759
 					RecordDate:      info.SysRecordTime,
2760
+					StorehouseId:    houseConfig.StorehouseOutInfo,
2636
 				}
2761
 				}
2637
 
2762
 
2638
 				service.CreateCancelStockInfoOne(&cancelStockInfo)
2763
 				service.CreateCancelStockInfoOne(&cancelStockInfo)
2669
 					CancelOutDetailId:       cancelInfo.ID,
2794
 					CancelOutDetailId:       cancelInfo.ID,
2670
 					ProductDate:             info.ProductDate,
2795
 					ProductDate:             info.ProductDate,
2671
 					ExpireDate:              info.ExpiryDate,
2796
 					ExpireDate:              info.ExpiryDate,
2797
+					StorehouseId:            houseConfig.StorehouseOutInfo,
2672
 				}
2798
 				}
2673
 				service.CreateStockFlowOne(flow)
2799
 				service.CreateStockFlowOne(flow)
2674
 
2800
 
2686
 				}
2812
 				}
2687
 				//回退库存
2813
 				//回退库存
2688
 				service.UpDateWarehouseInfoByStockDelete(info.WarehouseInfotId, total_count)
2814
 				service.UpDateWarehouseInfoByStockDelete(info.WarehouseInfotId, total_count)
2689
-
2815
+				service.ModifyGoodAddInformation(info.GoodId, total_count, info.OrgId)
2690
 				//查询今日该耗材退库数量
2816
 				//查询今日该耗材退库数量
2691
 				cancelInfoOne, _ := service.GetCancelStockInfoByPatientId(info.PatientId, project.ProjectId, info.SysRecordTime)
2817
 				cancelInfoOne, _ := service.GetCancelStockInfoByPatientId(info.PatientId, project.ProjectId, info.SysRecordTime)
2692
 				var cancel_count int64
2818
 				var cancel_count int64
2721
 							Manufacturer:            0,
2847
 							Manufacturer:            0,
2722
 							Type:                    1,
2848
 							Type:                    1,
2723
 							IsSys:                   1,
2849
 							IsSys:                   1,
2850
+							StorehouseId:            houseConfig.StorehouseOutInfo,
2724
 						}
2851
 						}
2725
 						err := service.AddSigleWarehouseOut(&warehouseOut)
2852
 						err := service.AddSigleWarehouseOut(&warehouseOut)
2726
 						if err != nil {
2853
 						if err != nil {
2728
 							return
2855
 							return
2729
 						}
2856
 						}
2730
 						prepare := &models.DialysisBeforePrepare{
2857
 						prepare := &models.DialysisBeforePrepare{
2731
-							UserOrgId:  adminInfo.CurrentOrgId,
2732
-							PatientId:  info.PatientId,
2733
-							RecordDate: info.SysRecordTime,
2734
-							GoodId:     project.ProjectId,
2735
-							GoodTypeId: info.GoodTypeId,
2736
-							Count:      cha_count,
2858
+							UserOrgId:    adminInfo.CurrentOrgId,
2859
+							PatientId:    info.PatientId,
2860
+							RecordDate:   info.SysRecordTime,
2861
+							GoodId:       project.ProjectId,
2862
+							GoodTypeId:   info.GoodTypeId,
2863
+							Count:        cha_count,
2864
+							StorehouseId: houseConfig.StorehouseOutInfo,
2737
 						}
2865
 						}
2738
 						//出库
2866
 						//出库
2739
 						service.ConsumablesDelivery(adminInfo.CurrentOrgId, info.PatientId, info.SysRecordTime, prepare, &warehouseOut, cha_count)
2867
 						service.ConsumablesDelivery(adminInfo.CurrentOrgId, info.PatientId, info.SysRecordTime, prepare, &warehouseOut, cha_count)
2740
 					} else if err == nil {
2868
 					} else if err == nil {
2741
 						prepare := &models.DialysisBeforePrepare{
2869
 						prepare := &models.DialysisBeforePrepare{
2742
-							UserOrgId:  adminInfo.CurrentOrgId,
2743
-							PatientId:  info.PatientId,
2744
-							RecordDate: info.SysRecordTime,
2745
-							GoodId:     project.ProjectId,
2746
-							GoodTypeId: info.GoodTypeId,
2747
-							Count:      cha_count,
2870
+							UserOrgId:    adminInfo.CurrentOrgId,
2871
+							PatientId:    info.PatientId,
2872
+							RecordDate:   info.SysRecordTime,
2873
+							GoodId:       project.ProjectId,
2874
+							GoodTypeId:   info.GoodTypeId,
2875
+							Count:        cha_count,
2876
+							StorehouseId: houseConfig.StorehouseOutInfo,
2748
 						}
2877
 						}
2749
 						//出库
2878
 						//出库
2750
 						service.ConsumablesDelivery(adminInfo.CurrentOrgId, info.PatientId, info.SysRecordTime, prepare, &out, cha_count)
2879
 						service.ConsumablesDelivery(adminInfo.CurrentOrgId, info.PatientId, info.SysRecordTime, prepare, &out, cha_count)

+ 434 - 0
controllers/his_deposit_controller.go View File

1
+package controllers
2
+
3
+import (
4
+	"XT_New/enums"
5
+	"XT_New/models"
6
+	"XT_New/service"
7
+	"XT_New/utils"
8
+	"encoding/json"
9
+	"fmt"
10
+	"github.com/astaxie/beego"
11
+	"github.com/shopspring/decimal"
12
+	"strings"
13
+	"time"
14
+)
15
+
16
+type HisDepositApiController struct {
17
+	BaseAuthAPIController
18
+}
19
+
20
+func HisDepositApiRegistRouters() {
21
+	beego.Router("/api/his/ttt", &HisDepositApiController{}, "get:TTT")                         //测试接口
22
+	beego.Router("/api/his/gethisuser", &HisDepositApiController{}, "get:GetHisUser")           //获取病例中心,有效患者名称
23
+	beego.Router("/api/his/adddeposit", &HisDepositApiController{}, "post:AddDeposit")          //新增押金
24
+	beego.Router("/api/his/getdepositcode", &HisDepositApiController{}, "get:GetDepositCode")   //获取新增押金编号
25
+	beego.Router("/api/his/getdeletecode", &HisDepositApiController{}, "get:GetDeleteCode")     //获取退款编号
26
+	beego.Router("/api/his/rechargedetails", &HisDepositApiController{}, "get:RechargeDetails") //充值明细列表
27
+	beego.Router("/api/his/updeposit", &HisDepositApiController{}, "get:UpDeposit")             //审核
28
+	beego.Router("/api/his/deletehistory", &HisDepositApiController{}, "get:DeleteHistory")     //删除
29
+	beego.Router("/api/his/rechargesummary", &HisDepositApiController{}, "get:RechargeSummary") //充值汇总列表
30
+	beego.Router("/api/his/getuserlist", &HisDepositApiController{}, "get:GetUserList")         //获取患者押金列表
31
+	beego.Router("/api/his/depositflow", &HisDepositApiController{}, "get:DepositFlow")         //根据患者id获取押金流水
32
+}
33
+func (this *HisDepositApiController) TTT() {
34
+	id, _ := this.GetInt64("id")
35
+	err := service.DelDecimalHistory(id)
36
+	this.ServeSuccessJSON(map[string]interface{}{
37
+		"list": err,
38
+	})
39
+	return
40
+}
41
+
42
+//获取病例中心,有效患者名称
43
+func (this *HisDepositApiController) GetHisUser() {
44
+	orgid := this.GetAdminUserInfo().CurrentOrgId
45
+	list, err := service.GetHisUser(orgid)
46
+	if err != nil {
47
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
48
+		return
49
+	}
50
+	this.ServeSuccessJSON(map[string]interface{}{
51
+		"list": list,
52
+	})
53
+	return
54
+}
55
+
56
+//新增押金
57
+func (this *HisDepositApiController) AddDeposit() {
58
+	orgid := this.GetAdminUserInfo().CurrentOrgId
59
+	dataBody := make(map[string]interface{}, 0)
60
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
61
+	if err != nil {
62
+		utils.ErrorLog(err.Error())
63
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
64
+		return
65
+	}
66
+	switch {
67
+	case dataBody["code"] == nil:
68
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金编号不能为空")
69
+		return
70
+	case dataBody["his_patient_id"] == nil:
71
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "患者名称不能为空")
72
+		return
73
+	case dataBody["deposit"] == nil:
74
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金金额不能为空")
75
+		return
76
+	case dataBody["trial_status"] == nil:
77
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "审核状态不能为空")
78
+		return
79
+	}
80
+	code := dataBody["code"].(string)                              //押金编号
81
+	his_patient_id := int64(dataBody["his_patient_id"].(float64))  //患者编号
82
+	deposit := decimal.NewFromFloat(dataBody["deposit"].(float64)) //押金金额
83
+	var remarks string
84
+	if dataBody["remarks"] == nil {
85
+		remarks = ""
86
+	} else {
87
+		remarks = dataBody["remarks"].(string) //备注
88
+	}
89
+	trial_status := int64(dataBody["trial_status"].(float64)) //审核状态
90
+	createid := this.GetAdminUserInfo().AdminUser.Id
91
+	pp := this.GetAdminUserInfo()
92
+	fmt.Println(pp)
93
+	err = service.UpDeposit(code, remarks, his_patient_id, orgid, trial_status, createid, deposit)
94
+	if err != nil {
95
+		utils.ErrorLog(err.Error())
96
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
97
+		return
98
+	}
99
+	this.ServeSuccessJSON(map[string]interface{}{
100
+		"list": "添加成功",
101
+	})
102
+	return
103
+}
104
+
105
+//获取新增押金编号
106
+func (this *HisDepositApiController) GetDepositCode() {
107
+	orgid := this.GetAdminUserInfo().CurrentOrgId
108
+	var code string
109
+	for a := true; a == true; {
110
+		code = service.CreateCPCode("CP")
111
+		tmp := service.FindDecimalCode(orgid, code)
112
+		if tmp == false {
113
+			a = false
114
+		}
115
+	}
116
+	this.ServeSuccessJSON(map[string]interface{}{
117
+		"list": code,
118
+	})
119
+	return
120
+}
121
+
122
+//获取退款编号
123
+func (this *HisDepositApiController) GetDeleteCode() {
124
+	orgid := this.GetAdminUserInfo().CurrentOrgId
125
+	var code string
126
+	for a := true; a == true; {
127
+		code = service.CreateCPCode("AF")
128
+		tmp := service.FindDecimalCode(orgid, code)
129
+		if tmp == false {
130
+			a = false
131
+		}
132
+	}
133
+	this.ServeSuccessJSON(map[string]interface{}{
134
+		"list": code,
135
+	})
136
+	return
137
+}
138
+
139
+//充值明细列表
140
+func (this *HisDepositApiController) RechargeDetails() {
141
+	orgid := this.GetAdminUserInfo().CurrentOrgId
142
+	timeLayout := "2006-01-02"
143
+	loc, _ := time.LoadLocation("Local")
144
+	keyword := this.GetString("keyword")
145
+	start_time := this.GetString("start_time")
146
+	end_time := this.GetString("end_time")
147
+	var stime int64 //开始时间
148
+	var etime int64 //结束时间
149
+
150
+	namemap := make(map[int64]string)
151
+	slicekey := make([]int64, 0)
152
+	if len(keyword) > 0 {
153
+		list, _ := service.GetHisUser(orgid)
154
+		for _, v := range list {
155
+			namemap[v.ID] = v.Name
156
+		}
157
+		for k, v := range namemap {
158
+			res := strings.Contains(v, keyword)
159
+			if res == true {
160
+				slicekey = append(slicekey, k)
161
+			}
162
+		}
163
+	}
164
+	if start_time == "" && end_time == "" {
165
+		stime, etime = service.GetMondayOfWeek()
166
+	} else {
167
+		stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
168
+		etmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
169
+		stime = stmp.Unix()
170
+		etime = etmp.Unix()
171
+	}
172
+	list, err := service.DetailsList(orgid, stime, etime, keyword, slicekey)
173
+	if err != nil {
174
+		utils.ErrorLog(err.Error())
175
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
176
+		return
177
+	}
178
+	var sum decimal.Decimal
179
+	for i := 0; i < len(list); i++ {
180
+		if list[i].TrialStatus == 1 {
181
+			sum = sum.Add(list[i].Deposit)
182
+		}
183
+		list[i].Name = service.GetCreateidName(list[i].CreateId)
184
+	}
185
+	this.ServeSuccessJSON(map[string]interface{}{
186
+		"list": list,
187
+		"sum":  sum,
188
+	})
189
+	return
190
+}
191
+
192
+//充值汇总列表
193
+func (this *HisDepositApiController) RechargeSummary() {
194
+	orgid := this.GetAdminUserInfo().CurrentOrgId
195
+	timeLayout := "2006-01-02"
196
+	loc, _ := time.LoadLocation("Local")
197
+	keyword := this.GetString("keyword")
198
+	start_time := this.GetString("start_time")
199
+	end_time := this.GetString("end_time")
200
+	var stime int64 //开始时间
201
+	var etime int64 //结束时间
202
+	namemap := make(map[int64]string)
203
+	slicekey := make([]int64, 0)
204
+	lists, _ := service.GetHisUser(orgid)
205
+	for _, v := range lists {
206
+		namemap[v.ID] = v.Name
207
+	}
208
+	if len(keyword) > 0 {
209
+		for k, v := range namemap {
210
+			res := strings.Contains(v, keyword)
211
+			if res == true {
212
+				slicekey = append(slicekey, k)
213
+			}
214
+		}
215
+	}
216
+	if start_time == "" && end_time == "" {
217
+		stime, etime = service.GetMondayOfWeek()
218
+	} else {
219
+		stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
220
+		etmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
221
+		stime = stmp.Unix()
222
+		etime = etmp.Unix()
223
+	}
224
+	list, err := service.SummaryList(orgid, stime, etime, keyword, slicekey)
225
+	if err != nil {
226
+		utils.ErrorLog(err.Error())
227
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
228
+		return
229
+	}
230
+	//list为详细数据,把list整理合并为maplist输出
231
+	maplist := make(map[int64]models.Summary)
232
+	Finlist := []models.Summary{}
233
+	tmpslice := make([]int64, 0)
234
+	var sum decimal.Decimal
235
+	for i := 0; i < len(list); i++ {
236
+		if list[i].TrialStatus == 1 {
237
+			if k, ok := maplist[list[i].HisPatientId]; ok {
238
+				k.SumDecimal = k.SumDecimal.Add(list[i].Deposit)
239
+				maplist[list[i].HisPatientId] = models.Summary{
240
+					namemap[list[i].HisPatientId],
241
+					k.SumDecimal,
242
+					service.GetUserMoney(list[i].HisPatientId, orgid),
243
+				}
244
+			} else {
245
+				maplist[list[i].HisPatientId] = models.Summary{
246
+					namemap[list[i].HisPatientId],
247
+					list[i].Deposit,
248
+					service.GetUserMoney(list[i].HisPatientId, orgid),
249
+				}
250
+				tmpslice = append(tmpslice, list[i].HisPatientId)
251
+			}
252
+			sum = sum.Add(list[i].Deposit)
253
+		}
254
+	}
255
+	//maplist虽然满足接口要求,但格式不行,整理为Finlist输出
256
+	for i := 0; i < len(tmpslice); i++ {
257
+		Finlist = append(Finlist, maplist[tmpslice[i]])
258
+	}
259
+	this.ServeSuccessJSON(map[string]interface{}{
260
+		"list": Finlist,
261
+		"sum":  sum,
262
+	})
263
+	return
264
+}
265
+
266
+//审核
267
+func (this *HisDepositApiController) UpDeposit() {
268
+	id, _ := this.GetInt64("id", 0)
269
+	if id == 0 {
270
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "id不能为空")
271
+		return
272
+	}
273
+	tmp, err := service.GetDecimalHistoryOne(id)
274
+	if err != nil {
275
+		utils.ErrorLog("无法查询该记录信息", err.Error())
276
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "无法查询该记录信息")
277
+		return
278
+	}
279
+	if tmp.TrialStatus == 0 {
280
+		err = service.UpDecimalHistory(id)
281
+		if err != nil {
282
+			utils.ErrorLog("更新押金历史表出错,原因为:", err.Error())
283
+			this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "系统错误")
284
+			return
285
+		}
286
+	} else {
287
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "当前状态不可审核")
288
+		return
289
+	}
290
+	this.ServeSuccessJSON(map[string]interface{}{
291
+		"list": "审核通过",
292
+	})
293
+	return
294
+}
295
+func (this *HisDepositApiController) DeleteHistory() {
296
+	id, _ := this.GetInt64("id", 0)
297
+	if id == 0 {
298
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "id不能为空")
299
+		return
300
+	}
301
+	tmp, err := service.GetDecimalHistoryOne(id)
302
+	if err != nil {
303
+		utils.ErrorLog("无法查询该记录信息", err.Error())
304
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "无法查询该记录信息")
305
+		return
306
+	}
307
+	if tmp.TrialStatus == 0 {
308
+		err = service.DelDecimalHistory(id)
309
+		if err != nil {
310
+			utils.ErrorLog("删除历史记录出错,原因为:", err.Error())
311
+			this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "系统错误")
312
+			return
313
+		}
314
+	} else {
315
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "已审核的单据不能进行删除操作")
316
+		return
317
+	}
318
+	this.ServeSuccessJSON(map[string]interface{}{
319
+		"list": "删除成功",
320
+	})
321
+	return
322
+}
323
+
324
+//根据id获取押金流水
325
+func (this *HisDepositApiController) DepositFlow() {
326
+	orgid := this.GetAdminUserInfo().CurrentOrgId
327
+	check := map[string][]string{
328
+		"id":             {"must", "int", "id"},
329
+		"deposit_status": {"must", "int", "deposit_status"},
330
+	}
331
+	_, err := checks(this, &check)
332
+	if err != nil {
333
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
334
+		return
335
+	}
336
+	id, _ := this.GetInt64("id") //患者id
337
+	//获取当前患者的姓名
338
+	tmp, _ := service.GetHisUserName(orgid, id)
339
+	name := tmp.Name
340
+	deposit_status, _ := this.GetInt64("deposit_status", 0) //押金类型
341
+	if deposit_status > 3 {
342
+		utils.ErrorLog("押金类型错误,deposit_status:", deposit_status)
343
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金类型错误")
344
+		return
345
+	}
346
+	start_time := this.GetString("start_time", "") //开始时间
347
+	end_time := this.GetString("end_time", "")     //结束时间
348
+	timeLayout := "2006-01-02"
349
+	loc, _ := time.LoadLocation("Local")
350
+	var stime int64 //开始时间
351
+	var etime int64 //结束时间
352
+	if start_time == "" && end_time == "" {
353
+		stime, etime = service.GetMonth()
354
+	} else {
355
+		stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
356
+		etmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
357
+		stime = stmp.Unix()
358
+		etime = etmp.Unix()
359
+	}
360
+	//获取该角色当前时间段的余额
361
+	decimal := service.GetMoneyforTime(id, orgid, etime)
362
+	//获取列表
363
+	deposirhistory, errs := service.GetFlowList(id, orgid, stime, etime, deposit_status)
364
+	if errs != nil {
365
+		utils.ErrorLog("获取列表失败,原因为:", errs.Error())
366
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, errs.Error())
367
+		return
368
+	}
369
+
370
+	this.ServeSuccessJSON(map[string]interface{}{
371
+		"list":    deposirhistory,
372
+		"name":    name,
373
+		"decimal": decimal,
374
+	})
375
+	return
376
+}
377
+
378
+//
379
+func (this *HisDepositApiController) GetUserList() {
380
+	orgid := this.GetAdminUserInfo().CurrentOrgId
381
+	keyword := this.GetString("keyword")
382
+	page, _ := this.GetInt64("page")   //页码
383
+	limit, _ := this.GetInt64("limit") //每一页查出来的条数
384
+	check := map[string][]string{
385
+		"page":  {"must", "string", "page"},
386
+		"limit": {"must", "string", "limit"},
387
+	}
388
+	_, err := checks(this, &check)
389
+	if err != nil {
390
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
391
+		return
392
+	}
393
+	namemap := make(map[int64]string)
394
+	slicekey := make([]int64, 0)
395
+	lists, _ := service.GetHisUser(orgid)
396
+	for _, v := range lists {
397
+		namemap[v.ID] = v.Name
398
+	}
399
+	if len(keyword) > 0 {
400
+		for k, v := range namemap {
401
+			res := strings.Contains(v, keyword)
402
+			if res == true {
403
+				slicekey = append(slicekey, k)
404
+			}
405
+		}
406
+	}
407
+	list, total, errs := service.GetUserList(page, limit, orgid, keyword, slicekey)
408
+	if errs != nil {
409
+		utils.ErrorLog(errs.Error())
410
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
411
+		return
412
+	}
413
+	for i := 0; i < len(list); i++ {
414
+		list[i].HisPatientName = namemap[list[i].HisPatientId]
415
+	}
416
+	this.ServeSuccessJSON(map[string]interface{}{
417
+		"list":  list,
418
+		"total": total,
419
+	})
420
+	return
421
+}
422
+
423
+//判断前端参数是否为空
424
+func checks(this *HisDepositApiController, m *map[string][]string) (map[string]string, error) {
425
+	tmp := make(map[string]string)
426
+	for k, v := range *m {
427
+		t := this.GetString(k)
428
+		if v[0] == "must" && t == "" {
429
+			return nil, fmt.Errorf(v[2] + "不能为空")
430
+		}
431
+		tmp[k] = t
432
+	}
433
+	return tmp, nil
434
+}

+ 2 - 2
controllers/his_project_api_controller.go View File

1061
 	register_type, _ := this.GetInt64("register_type")
1061
 	register_type, _ := this.GetInt64("register_type")
1062
 	limit, _ := this.GetInt64("limit")
1062
 	limit, _ := this.GetInt64("limit")
1063
 	page, _ := this.GetInt64("page")
1063
 	page, _ := this.GetInt64("page")
1064
-	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
1065
-	endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
1064
+	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+":00", loc)
1065
+	endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+":59", loc)
1066
 	adminUserInfo := this.GetAdminUserInfo()
1066
 	adminUserInfo := this.GetAdminUserInfo()
1067
 	orgId := adminUserInfo.CurrentOrgId
1067
 	orgId := adminUserInfo.CurrentOrgId
1068
 	history, total, err := service.GetHisPatientHistory(keyword, startTime.Unix(), endTime.Unix(), register_type, limit, page, orgId)
1068
 	history, total, err := service.GetHisPatientHistory(keyword, startTime.Unix(), endTime.Unix(), register_type, limit, page, orgId)

+ 1 - 1
controllers/mobile_api_controllers/check_weight_api_controller.go View File

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

+ 240 - 102
controllers/mobile_api_controllers/dialysis_api_controller.go View File

2258
 		tempdispose = "引血" + strconv.FormatInt(blood_drawing, 10) + "ml/min"
2258
 		tempdispose = "引血" + strconv.FormatInt(blood_drawing, 10) + "ml/min"
2259
 	}
2259
 	}
2260
 
2260
 
2261
+	if blood_drawing > 0 && adminUserInfo.Org.Id == 10318 {
2262
+		tempdispose = "引血" + strconv.FormatInt(blood_drawing, 10) + "ml/min"
2263
+	}
2264
+
2261
 	var ultrafiltration_rate float64
2265
 	var ultrafiltration_rate float64
2262
 	_, prescription := service.FindDialysisPrescriptionByReordDate(patientID, schedulestartTime, adminUserInfo.Org.Id)
2266
 	_, prescription := service.FindDialysisPrescriptionByReordDate(patientID, schedulestartTime, adminUserInfo.Org.Id)
2263
 	//后期预增脱水量
2267
 	//后期预增脱水量
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
+			}
2905
+
2906
+			if template.TemplateId == 47 {
2907
+				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 60 / float64(totalMin))
2908
+				record.UltrafiltrationRate = ultrafiltration_rate
2909
+			}
2897
 		}
2910
 		}
2898
 	}
2911
 	}
2899
 	// record.UltrafiltrationRate = ultrafiltration_rate
2912
 	// record.UltrafiltrationRate = ultrafiltration_rate
2915
 		}
2928
 		}
2916
 	}
2929
 	}
2917
 
2930
 
2931
+	if template.TemplateId == 47 {
2932
+		record.DisplacementQuantity = record.DisplacementQuantity + record.DisplacementQuantity
2933
+	}
2934
+
2918
 	this.ServeSuccessJSON(map[string]interface{}{
2935
 	this.ServeSuccessJSON(map[string]interface{}{
2919
 		"monitor": record,
2936
 		"monitor": record,
2920
 	})
2937
 	})
3889
 		return
3906
 		return
3890
 	}
3907
 	}
3891
 
3908
 
3909
+	houseConfig, _ := service.GetAllStoreHouseConfig(adminUser.Org.Id)
3910
+
3892
 	var beforePrepares []*models.DialysisBeforePrepareGoods
3911
 	var beforePrepares []*models.DialysisBeforePrepareGoods
3893
 	var newBeforePrepares []*models.NewDialysisBeforePrepareGoods
3912
 	var newBeforePrepares []*models.NewDialysisBeforePrepareGoods
3894
 	var dialysisBefor []*models.DialysisBeforePrepare
3913
 	var dialysisBefor []*models.DialysisBeforePrepare
3924
 				fmt.Println("commdity", commdity_code)
3943
 				fmt.Println("commdity", commdity_code)
3925
 
3944
 
3926
 				prepareGoods := &models.DialysisBeforePrepareGoods{
3945
 				prepareGoods := &models.DialysisBeforePrepareGoods{
3927
-					GoodTypeId: good_type_id,
3928
-					GoodId:     good_id,
3929
-					Count:      count,
3946
+					GoodTypeId:   good_type_id,
3947
+					GoodId:       good_id,
3948
+					Count:        count,
3949
+					StorehouseId: houseConfig.StorehouseOutInfo,
3930
 				}
3950
 				}
3931
 
3951
 
3932
 				beforePrepares = append(beforePrepares, prepareGoods)
3952
 				beforePrepares = append(beforePrepares, prepareGoods)
3933
 
3953
 
3934
 				newPrepareGoods := &models.NewDialysisBeforePrepareGoods{
3954
 				newPrepareGoods := &models.NewDialysisBeforePrepareGoods{
3935
-					GoodTypeId: good_type_id,
3936
-					GoodId:     good_id,
3937
-					Count:      count,
3955
+					GoodTypeId:   good_type_id,
3956
+					GoodId:       good_id,
3957
+					Count:        count,
3958
+					StorehouseId: houseConfig.StorehouseOutInfo,
3938
 				}
3959
 				}
3939
 
3960
 
3940
 				newBeforePrepares = append(newBeforePrepares, newPrepareGoods)
3961
 				newBeforePrepares = append(newBeforePrepares, newPrepareGoods)
3950
 					Ctime:        time.Now().Unix(),
3971
 					Ctime:        time.Now().Unix(),
3951
 					Creater:      adminUser.AdminUser.Id,
3972
 					Creater:      adminUser.AdminUser.Id,
3952
 					CommdityCode: commdity_code,
3973
 					CommdityCode: commdity_code,
3974
+					StorehouseId: houseConfig.StorehouseOutInfo,
3953
 				}
3975
 				}
3954
 
3976
 
3955
 				dialysisBefor = append(dialysisBefor, prepare)
3977
 				dialysisBefor = append(dialysisBefor, prepare)
3959
 
3981
 
3960
 		//查询是否有库存
3982
 		//查询是否有库存
3961
 		for _, item := range dialysisBefor {
3983
 		for _, item := range dialysisBefor {
3962
-			_, err := service.FindFirstWarehousingInfoByStock(item.GoodId, item.GoodTypeId)
3984
+			fmt.Println("houseconfig233232323232232332323223233", houseConfig.StorehouseOutInfo)
3985
+			_, err := service.FindFirstWarehousingInfoByStock(item.GoodId, item.GoodTypeId, houseConfig.StorehouseOutInfo)
3963
 
3986
 
3964
 			if err == gorm.ErrRecordNotFound {
3987
 			if err == gorm.ErrRecordNotFound {
3965
 				goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
3988
 				goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
3997
 					Creater:      item.Creater,
4020
 					Creater:      item.Creater,
3998
 					CommdityCode: item.CommdityCode,
4021
 					CommdityCode: item.CommdityCode,
3999
 					Status:       1,
4022
 					Status:       1,
4023
+					StorehouseId: houseConfig.StorehouseOutInfo,
4000
 				}
4024
 				}
4001
 				//先清除再插入
4025
 				//先清除再插入
4002
 				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)
4003
 				err = service.CreateDialysisBeforePrepareOne(&dialyPrepareOne)
4027
 				err = service.CreateDialysisBeforePrepareOne(&dialyPrepareOne)
4004
-
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)
4005
 			}
4038
 			}
4006
 			if err == nil {
4039
 			if err == nil {
4007
 				c.ServeSuccessJSON(map[string]interface{}{
4040
 				c.ServeSuccessJSON(map[string]interface{}{
4035
 
4068
 
4036
 					for _, it := range list {
4069
 					for _, it := range list {
4037
 						prepare := models.DialysisBeforePrepare{
4070
 						prepare := models.DialysisBeforePrepare{
4038
-							UserOrgId:  it.OrgId,
4039
-							PatientId:  patient_id,
4040
-							RecordDate: it.RecordTime,
4041
-							GoodId:     it.GoodId,
4042
-							GoodTypeId: it.GoodTypeId,
4043
-							Count:      it.Count,
4044
-							Ctime:      time.Now().Unix(),
4045
-							Creater:    adminUser.AdminUser.Id,
4046
-							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,
4047
 						}
4081
 						}
4048
 						//删除准备表数据
4082
 						//删除准备表数据
4049
 						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)
4076
 
4110
 
4077
 						for _, it := range list {
4111
 						for _, it := range list {
4078
 							prepare := models.DialysisBeforePrepare{
4112
 							prepare := models.DialysisBeforePrepare{
4079
-								UserOrgId:  it.OrgId,
4080
-								PatientId:  patient_id,
4081
-								RecordDate: it.RecordTime,
4082
-								GoodId:     it.GoodId,
4083
-								GoodTypeId: it.GoodTypeId,
4084
-								Count:      it.Count,
4085
-								Ctime:      time.Now().Unix(),
4086
-								Creater:    adminUser.AdminUser.Id,
4087
-								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,
4088
 							}
4123
 							}
4089
 							//删除准备表数据
4124
 							//删除准备表数据
4090
 							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)
4091
 
4126
 
4092
 							service.CreateDialysisBeforePrepareOne(&prepare)
4127
 							service.CreateDialysisBeforePrepareOne(&prepare)
4093
-
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)
4094
 						}
4138
 						}
4095
 					}
4139
 					}
4096
 
4140
 
4102
 
4146
 
4103
 						for _, it := range list {
4147
 						for _, it := range list {
4104
 							prepare := models.DialysisBeforePrepare{
4148
 							prepare := models.DialysisBeforePrepare{
4105
-								UserOrgId:  it.OrgId,
4106
-								PatientId:  patient_id,
4107
-								RecordDate: it.RecordTime,
4108
-								GoodId:     it.GoodId,
4109
-								GoodTypeId: it.GoodTypeId,
4110
-								Count:      it.Count,
4111
-								Ctime:      time.Now().Unix(),
4112
-								Creater:    adminUser.AdminUser.Id,
4113
-								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,
4114
 							}
4159
 							}
4115
 							//删除准备表数据
4160
 							//删除准备表数据
4116
 							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)
4117
 
4162
 
4118
 							service.CreateDialysisBeforePrepareOne(&prepare)
4163
 							service.CreateDialysisBeforePrepareOne(&prepare)
4119
-
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)
4120
 						}
4174
 						}
4121
 						if err != nil {
4175
 						if err != nil {
4122
 							goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
4176
 							goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
4184
 	consumables = RemoveRepeatedGood(consumables)
4238
 	consumables = RemoveRepeatedGood(consumables)
4185
 
4239
 
4186
 	if record.IsOpen == 1 {
4240
 	if record.IsOpen == 1 {
4187
-
4241
+		houseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
4188
 		//查询是否有库存
4242
 		//查询是否有库存
4189
 		for _, item := range consumables {
4243
 		for _, item := range consumables {
4190
-			warehouse, _ := service.FindFirstWarehousingInfoByStockTwo(item.GoodId, item.GoodTypeId)
4244
+			warehouse, _ := service.FindFirstWarehousingInfoByStockTwo(item.GoodId, item.GoodTypeId, houseConfig.StorehouseOutInfo)
4191
 
4245
 
4192
 			if item.Count > warehouse.Count {
4246
 			if item.Count > warehouse.Count {
4193
 				goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
4247
 				goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
4225
 				Manufacturer:            0,
4279
 				Manufacturer:            0,
4226
 				Type:                    1,
4280
 				Type:                    1,
4227
 				IsSys:                   1,
4281
 				IsSys:                   1,
4282
+				StorehouseId:            houseConfig.StorehouseOutInfo,
4228
 			}
4283
 			}
4229
 			err := service.AddSigleWarehouseOut(&warehouseOut)
4284
 			err := service.AddSigleWarehouseOut(&warehouseOut)
4230
 			if err != nil {
4285
 			if err != nil {
4243
 				}
4298
 				}
4244
 				for _, item := range list {
4299
 				for _, item := range list {
4245
 					prepare := models.DialysisBeforePrepare{
4300
 					prepare := models.DialysisBeforePrepare{
4246
-						UserOrgId:  adminInfo.Org.Id,
4247
-						PatientId:  patient_id,
4248
-						RecordDate: record_time,
4249
-						GoodId:     item.GoodId,
4250
-						GoodTypeId: item.GoodTypeId,
4251
-						Count:      item.Count,
4252
-						Creater:    adminInfo.AdminUser.Id,
4253
-						Status:     1,
4254
-						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,
4255
 					}
4311
 					}
4256
 					//清空准备表数据
4312
 					//清空准备表数据
4257
 					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)
4258
 					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)
4259
 				}
4325
 				}
4260
 			}
4326
 			}
4261
 			//
4327
 			//
4271
 				}
4337
 				}
4272
 				for _, item := range list {
4338
 				for _, item := range list {
4273
 					prepare := models.DialysisBeforePrepare{
4339
 					prepare := models.DialysisBeforePrepare{
4274
-						UserOrgId:  adminInfo.Org.Id,
4275
-						PatientId:  patient_id,
4276
-						RecordDate: record_time,
4277
-						GoodId:     item.GoodId,
4278
-						GoodTypeId: item.GoodTypeId,
4279
-						Count:      item.Count,
4280
-						Creater:    adminInfo.AdminUser.Id,
4281
-						Status:     1,
4282
-						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,
4283
 					}
4350
 					}
4284
 
4351
 
4285
 					//清空准备表数据
4352
 					//清空准备表数据
4286
 					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)
4287
 					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)
4288
 
4368
 
4289
 				}
4369
 				}
4290
 			}
4370
 			}
4326
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4406
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4327
 		return
4407
 		return
4328
 	}
4408
 	}
4329
-
4409
+	houseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
4330
 	var beforePrepares []*models.DialysisBeforePrepareGoods
4410
 	var beforePrepares []*models.DialysisBeforePrepareGoods
4331
 
4411
 
4332
 	var newBeforePrepares []*models.NewDialysisBeforePrepareGoods
4412
 	var newBeforePrepares []*models.NewDialysisBeforePrepareGoods
4370
 					fmt.Println(commdity_code)
4450
 					fmt.Println(commdity_code)
4371
 
4451
 
4372
 					prepareGoods := &models.DialysisBeforePrepareGoods{
4452
 					prepareGoods := &models.DialysisBeforePrepareGoods{
4373
-						GoodTypeId: good_type_id,
4374
-						GoodId:     good_id,
4375
-						Count:      count,
4453
+						GoodTypeId:   good_type_id,
4454
+						GoodId:       good_id,
4455
+						Count:        count,
4456
+						StorehouseId: houseConfig.StorehouseOutInfo,
4376
 					}
4457
 					}
4377
 
4458
 
4378
 					beforePrepares = append(beforePrepares, prepareGoods)
4459
 					beforePrepares = append(beforePrepares, prepareGoods)
4379
 
4460
 
4380
 					newPrepareGoods := &models.NewDialysisBeforePrepareGoods{
4461
 					newPrepareGoods := &models.NewDialysisBeforePrepareGoods{
4381
-						GoodTypeId: good_type_id,
4382
-						GoodId:     good_id,
4383
-						Count:      count,
4462
+						GoodTypeId:   good_type_id,
4463
+						GoodId:       good_id,
4464
+						Count:        count,
4465
+						StorehouseId: houseConfig.StorehouseOutInfo,
4384
 					}
4466
 					}
4385
 
4467
 
4386
 					newBeforePrepares = append(newBeforePrepares, newPrepareGoods)
4468
 					newBeforePrepares = append(newBeforePrepares, newPrepareGoods)
4399
 					if item.Count < goodInfo.Count {
4481
 					if item.Count < goodInfo.Count {
4400
 						//出库
4482
 						//出库
4401
 						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)
4402
 						break
4493
 						break
4403
 					}
4494
 					}
4404
 
4495
 
4444
 							return
4535
 							return
4445
 						} else {
4536
 						} else {
4446
 							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)
4447
 							break
4547
 							break
4448
 						}
4548
 						}
4449
 					}
4549
 					}
4454
 
4554
 
4455
 				for _, it := range list {
4555
 				for _, it := range list {
4456
 					prepare := models.DialysisBeforePrepare{
4556
 					prepare := models.DialysisBeforePrepare{
4457
-						UserOrgId:  it.OrgId,
4458
-						PatientId:  patient_id,
4459
-						RecordDate: it.RecordTime,
4460
-						GoodId:     it.GoodId,
4461
-						GoodTypeId: it.GoodTypeId,
4462
-						Count:      it.Count,
4463
-						Ctime:      time.Now().Unix(),
4464
-						Creater:    adminInfo.AdminUser.Id,
4465
-						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,
4466
 					}
4567
 					}
4467
 					//删除准备表数据
4568
 					//删除准备表数据
4468
 					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)
4469
 
4570
 
4470
 					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)
4471
 
4582
 
4472
 					if err != nil {
4583
 					if err != nil {
4473
 						goodObj, _ := service.GetGoodInformationByGoodId(it.GoodId)
4584
 						goodObj, _ := service.GetGoodInformationByGoodId(it.GoodId)
4543
 				goodUser, _ := service.GetLastDialysisGoods(item.PatientId, adminUser.Org.Id, date.Unix())
4654
 				goodUser, _ := service.GetLastDialysisGoods(item.PatientId, adminUser.Org.Id, date.Unix())
4544
 
4655
 
4545
 				lastGoodUserDetial, _ := service.GetLastDialysisBeforePrepare(item.PatientId, adminUser.Org.Id, date.Unix())
4656
 				lastGoodUserDetial, _ := service.GetLastDialysisBeforePrepare(item.PatientId, adminUser.Org.Id, date.Unix())
4546
-				fmt.Println("GOOD333232323223322332232332232323322323", lastGoodUserDetial)
4547
 				item.LastAutomaticReduceDetail = goodUser
4657
 				item.LastAutomaticReduceDetail = goodUser
4548
 				item.LastDialysisBeforePrepare = lastGoodUserDetial
4658
 				item.LastDialysisBeforePrepare = lastGoodUserDetial
4549
 				item.Project = project
4659
 				item.Project = project
4684
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4794
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4685
 		return
4795
 		return
4686
 	}
4796
 	}
4797
+	houseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
4687
 
4798
 
4688
 	var beforePrepares []*models.DialysisBeforePrepareGoods
4799
 	var beforePrepares []*models.DialysisBeforePrepareGoods
4689
 
4800
 
4725
 				}
4836
 				}
4726
 				project_id := int64(items["project_id"].(float64))
4837
 				project_id := int64(items["project_id"].(float64))
4727
 				prepare := &models.DialysisBeforePrepareGoods{
4838
 				prepare := &models.DialysisBeforePrepareGoods{
4728
-					GoodId:     good_id,
4729
-					GoodTypeId: good_type_id,
4730
-					Count:      count,
4731
-					ProjectId:  project_id,
4839
+					GoodId:       good_id,
4840
+					GoodTypeId:   good_type_id,
4841
+					Count:        count,
4842
+					ProjectId:    project_id,
4843
+					StorehouseId: houseConfig.StorehouseOutInfo,
4732
 				}
4844
 				}
4733
 				beforePrepares = append(beforePrepares, prepare)
4845
 				beforePrepares = append(beforePrepares, prepare)
4734
 
4846
 
4735
 				newPrepare := &models.NewDialysisBeforePrepareGoods{
4847
 				newPrepare := &models.NewDialysisBeforePrepareGoods{
4736
-					GoodId:     good_id,
4737
-					GoodTypeId: good_type_id,
4738
-					Count:      count,
4739
-					ProjectId:  project_id,
4848
+					GoodId:       good_id,
4849
+					GoodTypeId:   good_type_id,
4850
+					Count:        count,
4851
+					ProjectId:    project_id,
4852
+					StorehouseId: houseConfig.StorehouseOutInfo,
4740
 				}
4853
 				}
4741
 				newBeforePrepares = append(newBeforePrepares, newPrepare)
4854
 				newBeforePrepares = append(newBeforePrepares, newPrepare)
4742
 			}
4855
 			}
4745
 	fmt.Println("前端数据9999999999999", beforePrepares)
4858
 	fmt.Println("前端数据9999999999999", beforePrepares)
4746
 	//查询是否有库存
4859
 	//查询是否有库存
4747
 	for _, item := range beforePrepares {
4860
 	for _, item := range beforePrepares {
4748
-		warehouse, _ := service.FindFirstWarehousingInfoByStockTwo(item.GoodId, item.GoodTypeId)
4861
+		storeConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
4862
+		warehouse, _ := service.FindFirstWarehousingInfoByStockTwo(item.GoodId, item.GoodTypeId, storeConfig.StorehouseOutInfo)
4749
 
4863
 
4750
 		if item.Count > warehouse.Count {
4864
 		if item.Count > warehouse.Count {
4751
 			goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
4865
 			goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
4772
 
4886
 
4773
 	for _, item := range list {
4887
 	for _, item := range list {
4774
 		prepare := models.DialysisBeforePrepare{
4888
 		prepare := models.DialysisBeforePrepare{
4775
-			UserOrgId:  item.OrgId,
4776
-			PatientId:  item.PatientId,
4777
-			RecordDate: item.RecordTime,
4778
-			GoodId:     item.GoodId,
4779
-			GoodTypeId: item.GoodTypeId,
4780
-			Count:      item.Count,
4781
-			Creater:    adminInfo.AdminUser.Id,
4782
-			Status:     1,
4783
-			Ctime:      time.Now().Unix(),
4784
-			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,
4785
 		}
4900
 		}
4786
 		//清空准备表的数据
4901
 		//清空准备表的数据
4787
 		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)
4788
 		//插入准备表数据
4903
 		//插入准备表数据
4789
 		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
+
4790
 	}
4917
 	}
4791
 
4918
 
4792
 	//更新自动出库的地方
4919
 	//更新自动出库的地方
5156
 
5283
 
5157
 	delete_count = warehouseOutInfos.Count - count
5284
 	delete_count = warehouseOutInfos.Count - count
5158
 
5285
 
5286
+	houseConfig, _ := service.GetAllStoreHouseConfig(orgID)
5159
 	fmt.Println("delete_count2323232", delete_count)
5287
 	fmt.Println("delete_count2323232", delete_count)
5160
 	// 在出库记录表里记录退库详情
5288
 	// 在出库记录表里记录退库详情
5161
 	warehouseOutInfo := &models.WarehouseOutInfo{
5289
 	warehouseOutInfo := &models.WarehouseOutInfo{
5171
 		GoodId:                  good_yc.GoodId,
5299
 		GoodId:                  good_yc.GoodId,
5172
 		PatientId:               good_yc.PatientId,
5300
 		PatientId:               good_yc.PatientId,
5173
 		ConsumableType:          2,
5301
 		ConsumableType:          2,
5302
+		StorehouseId:            houseConfig.StorehouseOutInfo,
5174
 	}
5303
 	}
5175
 	warehouseOutInfo.Count = count
5304
 	warehouseOutInfo.Count = count
5176
 
5305
 
5186
 	//查找当天是否存在出库记录
5315
 	//查找当天是否存在出库记录
5187
 
5316
 
5188
 	_, errcod := service.GetWarehouseOutInfoIsExistOne(good_yc.GoodId, good_yc.PatientId, record_time)
5317
 	_, errcod := service.GetWarehouseOutInfoIsExistOne(good_yc.GoodId, good_yc.PatientId, record_time)
5189
-	fmt.Println("errcode2323223255556652324242424242424242424242424242242", errcod)
5318
+
5190
 	if errcod == gorm.ErrRecordNotFound {
5319
 	if errcod == gorm.ErrRecordNotFound {
5191
 		errOne := service.AddSigleWarehouseOutInfo(warehouseOutInfo)
5320
 		errOne := service.AddSigleWarehouseOutInfo(warehouseOutInfo)
5192
 		//插入详情明细表
5321
 		//插入详情明细表
5213
 			IsSys:                   1,
5342
 			IsSys:                   1,
5214
 			UpdateCreator:           creater,
5343
 			UpdateCreator:           creater,
5215
 			PatientId:               patient_id,
5344
 			PatientId:               patient_id,
5345
+			StorehouseId:            houseConfig.StorehouseOutInfo,
5216
 		}
5346
 		}
5217
 		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)
5218
 		if errflow == gorm.ErrRecordNotFound {
5348
 		if errflow == gorm.ErrRecordNotFound {
5219
 			//创建流水表
5349
 			//创建流水表
5220
 			err := service.CreateStockFlowOne(stockFlow)
5350
 			err := service.CreateStockFlowOne(stockFlow)
5221
-			fmt.Println("h2h3h2323342i24i242i4u2i4242u42424", err)
5351
+			fmt.Println("err", err)
5222
 		} else if errflow == nil {
5352
 		} else if errflow == nil {
5223
 			//插入详情明细表
5353
 			//插入详情明细表
5224
 			stockFlow := models.VmStockFlow{
5354
 			stockFlow := models.VmStockFlow{
5246
 				IsSys:                   1,
5376
 				IsSys:                   1,
5247
 				UpdateCreator:           creater,
5377
 				UpdateCreator:           creater,
5248
 				PatientId:               patient_id,
5378
 				PatientId:               patient_id,
5379
+				StorehouseId:            houseConfig.StorehouseOutInfo,
5249
 			}
5380
 			}
5250
 
5381
 
5251
 			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)
5282
 			UpdateCreator:           creater,
5413
 			UpdateCreator:           creater,
5283
 			PatientId:               patient_id,
5414
 			PatientId:               patient_id,
5284
 			ReturnCount:             delete_count,
5415
 			ReturnCount:             delete_count,
5416
+			StorehouseId:            houseConfig.StorehouseOutInfo,
5285
 		}
5417
 		}
5286
 		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)
5287
 		if errflows == gorm.ErrRecordNotFound {
5419
 		if errflows == gorm.ErrRecordNotFound {
5314
 				UpdateCreator:           creater,
5446
 				UpdateCreator:           creater,
5315
 				PatientId:               patient_id,
5447
 				PatientId:               patient_id,
5316
 				ReturnCount:             delete_count,
5448
 				ReturnCount:             delete_count,
5449
+				StorehouseId:            houseConfig.StorehouseOutInfo,
5317
 			}
5450
 			}
5318
 			//service.UpdatedStockFlow(stockFlow)
5451
 			//service.UpdatedStockFlow(stockFlow)
5319
 			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)
5334
 		GoodId:                  good_yc.GoodId,
5467
 		GoodId:                  good_yc.GoodId,
5335
 		GoodTypeId:              good_yc.GoodTypeId,
5468
 		GoodTypeId:              good_yc.GoodTypeId,
5336
 		Count:                   count,
5469
 		Count:                   count,
5470
+		StorehouseId:            houseConfig.StorehouseOutInfo,
5337
 	}
5471
 	}
5338
 	//查询当天耗材是否已经存在数据
5472
 	//查询当天耗材是否已经存在数据
5339
 	_, 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)
5350
 	// 删除出库完成后,要增加对应批次的库存数量
5484
 	// 删除出库完成后,要增加对应批次的库存数量
5351
 	fmt.Println("deletecount2323232323232323232323232323", delete_count)
5485
 	fmt.Println("deletecount2323232323232323232323232323", delete_count)
5352
 	errThree := service.UpDateWarehouseInfoByStockDelete(warehouseOutInfos.WarehouseInfotId, delete_count)
5486
 	errThree := service.UpDateWarehouseInfoByStockDelete(warehouseOutInfos.WarehouseInfotId, delete_count)
5487
+	service.ModifyGoodAddInformation(good_yc.GoodId, delete_count, good_yc.OrgId)
5353
 	errOne := service.UpDateWarehouStockFlowByStockDelete(warehouseOutInfos.WarehouseInfotId, record_time, good_yc.GoodId, delete_count, good_yc.PatientId)
5488
 	errOne := service.UpDateWarehouStockFlowByStockDelete(warehouseOutInfos.WarehouseInfotId, record_time, good_yc.GoodId, delete_count, good_yc.PatientId)
5354
 	fmt.Println("erron2332323232323232232323", errOne)
5489
 	fmt.Println("erron2332323232323232232323", errOne)
5355
 	if errThree != nil {
5490
 	if errThree != nil {
5406
 
5541
 
5407
 	if len(goods) > 0 {
5542
 	if len(goods) > 0 {
5408
 		out, err := service.FindStockOutByIsSys(orgID, 1, record_time)
5543
 		out, err := service.FindStockOutByIsSys(orgID, 1, record_time)
5544
+		houseConfig, _ := service.GetAllStoreHouseConfig(orgID)
5409
 		if err == gorm.ErrRecordNotFound {
5545
 		if err == gorm.ErrRecordNotFound {
5410
 			//没有记录,则创建出库单
5546
 			//没有记录,则创建出库单
5411
 			timeStr := time.Now().Format("2006-01-02")
5547
 			timeStr := time.Now().Format("2006-01-02")
5428
 				Manufacturer:            0,
5564
 				Manufacturer:            0,
5429
 				Type:                    1,
5565
 				Type:                    1,
5430
 				IsSys:                   1,
5566
 				IsSys:                   1,
5567
+				StorehouseId:            houseConfig.StorehouseOutInfo,
5431
 			}
5568
 			}
5432
 			err := service.AddSigleWarehouseOut(&warehouseOut)
5569
 			err := service.AddSigleWarehouseOut(&warehouseOut)
5433
 			if err != nil {
5570
 			if err != nil {
5446
 				}
5583
 				}
5447
 			}
5584
 			}
5448
 			prepare := models.DialysisBeforePrepare{
5585
 			prepare := models.DialysisBeforePrepare{
5449
-				GoodTypeId: item.GoodTypeId,
5450
-				GoodId:     item.GoodId,
5451
-				Count:      item.Count,
5586
+				GoodTypeId:   item.GoodTypeId,
5587
+				GoodId:       item.GoodId,
5588
+				Count:        item.Count,
5589
+				StorehouseId: houseConfig.StorehouseOutInfo,
5452
 			}
5590
 			}
5453
-			fmt.Println("到这里了吗34344343434334343434", newCount)
5591
+
5454
 			service.ConsumablesDelivery(orgID, patient_id, record_time, &prepare, &out, newCount)
5592
 			service.ConsumablesDelivery(orgID, patient_id, record_time, &prepare, &out, newCount)
5455
 		}
5593
 		}
5456
 
5594
 
5499
 			SysRecordTime:           record_time,
5637
 			SysRecordTime:           record_time,
5500
 			GoodTypeId:              good_yc.GoodTypeId,
5638
 			GoodTypeId:              good_yc.GoodTypeId,
5501
 			GoodId:                  good_yc.GoodId,
5639
 			GoodId:                  good_yc.GoodId,
5640
+			StorehouseId:            warehouseOut.StorehouseId,
5502
 		}
5641
 		}
5503
 		warehouseOutInfo.Count = delete_count
5642
 		warehouseOutInfo.Count = delete_count
5504
 		stockInInfo, _ := service.FindLastStockInInfoRecord(good_yc.GoodId, orgID)
5643
 		stockInInfo, _ := service.FindLastStockInInfoRecord(good_yc.GoodId, orgID)
5510
 		}
5649
 		}
5511
 
5650
 
5512
 		// 删除出库完成后,要增加对应批次的库存数量
5651
 		// 删除出库完成后,要增加对应批次的库存数量
5513
-		fmt.Println("时间人秘股呢换药2232323223323223322323232323232323232323232323", delete_count)
5514
 
5652
 
5515
 		// 删除出库完成后,要改变流水库存
5653
 		// 删除出库完成后,要改变流水库存
5516
 		errOne = service.UpDateWarehouStockFlowByStockDelete(ware.WarehouseInfotId, record_time, good_yc.GoodId, delete_count, good_yc.PatientId)
5654
 		errOne = service.UpDateWarehouStockFlowByStockDelete(ware.WarehouseInfotId, record_time, good_yc.GoodId, delete_count, good_yc.PatientId)
5517
 
5655
 
5518
 		fmt.Println("erron2332323232323232232323", errOne)
5656
 		fmt.Println("erron2332323232323232232323", errOne)
5519
 		errThree := service.UpDateWarehouseInfoByStockDelete(ware.WarehouseInfotId, delete_count)
5657
 		errThree := service.UpDateWarehouseInfoByStockDelete(ware.WarehouseInfotId, delete_count)
5520
-
5658
+		service.ModifyGoodAddInformation(good_yc.GoodId, delete_count, good_yc.OrgId)
5521
 		if errThree != nil {
5659
 		if errThree != nil {
5522
 			return errThree
5660
 			return errThree
5523
 		}
5661
 		}

+ 57 - 6
controllers/mobile_api_controllers/patient_api_controller.go View File

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 {
1069
 						total = list.Count*medical.MinNumber + list.StockMinNumber
1104
 						total = list.Count*medical.MinNumber + list.StockMinNumber
1070
 						prescribing_number_total = count * medical.MinNumber
1105
 						prescribing_number_total = count * medical.MinNumber
1071
 					}
1106
 					}
1072
-					fmt.Println("医嘱开的数量", total)
1107
+					//fmt.Println("医嘱开的数量", total)
1073
 					if medical.MinUnit == advice.PrescribingNumberUnit {
1108
 					if medical.MinUnit == advice.PrescribingNumberUnit {
1074
 						prescribingNumber_temp := strconv.FormatFloat(math.Abs(advice.PrescribingNumber), 'f', 0, 64)
1109
 						prescribingNumber_temp := strconv.FormatFloat(math.Abs(advice.PrescribingNumber), 'f', 0, 64)
1075
 						count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
1110
 						count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
1077
 						prescribing_number_total = count
1112
 						prescribing_number_total = count
1078
 					}
1113
 					}
1079
 
1114
 
1080
-					fmt.Println("数量一", prescribing_number_total)
1081
-					fmt.Println("数量二", total)
1115
+					//fmt.Println("数量一", prescribing_number_total)
1116
+					//fmt.Println("数量二", total)
1082
 
1117
 
1083
 					if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
1118
 					if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
1084
 						c.ServeSuccessJSON(map[string]interface{}{
1119
 						c.ServeSuccessJSON(map[string]interface{}{
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 View File

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
 }

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


+ 76 - 20
controllers/self_drug_api_congtroller.go View File

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)
2485
 
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)
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)
2597
 func (this *SelfDrugApiController) GetDamageByDrugId() {
2653
 func (this *SelfDrugApiController) GetDamageByDrugId() {
2598
 
2654
 
2599
 	drug_id, _ := this.GetInt64("drug_id")
2655
 	drug_id, _ := this.GetInt64("drug_id")
2600
-	warehousing_order := this.GetString("warehousing_order")
2656
+	warehousing_order := this.GetString("warehouseing_order")
2601
 	drug_type, _ := this.GetInt64("type")
2657
 	drug_type, _ := this.GetInt64("type")
2602
 	list, err := service.GetDamageByDrugId(drug_id, warehousing_order, drug_type)
2658
 	list, err := service.GetDamageByDrugId(drug_id, warehousing_order, drug_type)
2603
 	if err != nil {
2659
 	if err != nil {

+ 9 - 1
controllers/stock_good_api_controller.go View File

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)

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


+ 108 - 19
controllers/supply_order_api_contorller.go View File

2083
 	purcaseOrder, _ := service.GetAllPurcaseOrderById(id, orgId)
2083
 	purcaseOrder, _ := service.GetAllPurcaseOrderById(id, orgId)
2084
 	//获取购货单的数据
2084
 	//获取购货单的数据
2085
 	goodOrder, err := service.GetAllGoodOrderByIdSix(id, orgId)
2085
 	goodOrder, err := service.GetAllGoodOrderByIdSix(id, orgId)
2086
-	fmt.Println("2323232332232323232332", goodOrder)
2086
+
2087
 	drugList, err := service.GetSupplyDrugList(orgId)
2087
 	drugList, err := service.GetSupplyDrugList(orgId)
2088
 
2088
 
2089
 	if err == nil {
2089
 	if err == nil {
2196
 	//获取购货单的数据
2196
 	//获取购货单的数据
2197
 	goodOrder, _ := service.GetAllGoodOrderByIdTwo(id, orgId)
2197
 	goodOrder, _ := service.GetAllGoodOrderByIdTwo(id, orgId)
2198
 
2198
 
2199
+	houseConfig, _ := service.GetAllStoreHouseConfig(orgId)
2199
 	//查询该购货单是否审核成功
2200
 	//查询该购货单是否审核成功
2200
 	detail, _ := service.GetGoodOrderDetail(id, orgId)
2201
 	detail, _ := service.GetGoodOrderDetail(id, orgId)
2201
 	var warehousingInfo []*models.WarehousingInfo
2202
 	var warehousingInfo []*models.WarehousingInfo
2228
 						WarehousingTime:   record_date,
2229
 						WarehousingTime:   record_date,
2229
 						Type:              1,
2230
 						Type:              1,
2230
 						SupplyWarehouseId: id,
2231
 						SupplyWarehouseId: id,
2232
+						StorehouseId:      houseConfig.DrugStorehouseInfo,
2231
 					}
2233
 					}
2232
 					//查询今日是否存在入库单号
2234
 					//查询今日是否存在入库单号
2233
-					_, errcode := service.GetSingleDrugWarehouseOrder(record_date, orgId)
2234
-					if errcode == gorm.ErrRecordNotFound {
2235
-						service.AddSigleDrugWarehouse(&warehousing)
2236
-					}
2235
+					//_, errcode := service.GetSingleDrugWarehouseOrder(record_date, orgId)
2236
+					//if errcode == gorm.ErrRecordNotFound {
2237
+					service.AddSigleDrugWarehouse(&warehousing)
2238
+					//}
2237
 					drugWarehouseInfo, _ := service.GetLastDrugWarehouse(orgId)
2239
 					drugWarehouseInfo, _ := service.GetLastDrugWarehouse(orgId)
2238
 
2240
 
2239
 					warehouseInfoDetailOne := &models.DrugWarehouseInfo{
2241
 					warehouseInfoDetailOne := &models.DrugWarehouseInfo{
2261
 						RetailPrice:               item.MinPrice,
2263
 						RetailPrice:               item.MinPrice,
2262
 						SupplyWarehouseId:         id,
2264
 						SupplyWarehouseId:         id,
2263
 						SupplyWarehouseDetailInfo: item.ID,
2265
 						SupplyWarehouseDetailInfo: item.ID,
2266
+						StorehouseId:              houseConfig.DrugStorehouseInfo,
2264
 					}
2267
 					}
2265
 					if medical.MaxUnit == medical.MinUnit {
2268
 					if medical.MaxUnit == medical.MinUnit {
2266
 						warehouseInfoDetailOne.StockMaxNumber = item.Count
2269
 						warehouseInfoDetailOne.StockMaxNumber = item.Count
2297
 						IsSys:                     0,
2300
 						IsSys:                     0,
2298
 						SupplyWarehouseId:         id,
2301
 						SupplyWarehouseId:         id,
2299
 						SupplyWarehouseDetailInfo: item.ID,
2302
 						SupplyWarehouseDetailInfo: item.ID,
2303
+						StorehouseId:              houseConfig.DrugStorehouseInfo,
2300
 					}
2304
 					}
2301
 
2305
 
2302
 					if medical.MaxUnit == medical.MinUnit {
2306
 					if medical.MaxUnit == medical.MinUnit {
2329
 						WarehousingTime:   record_date,
2333
 						WarehousingTime:   record_date,
2330
 						Type:              1,
2334
 						Type:              1,
2331
 						SupplyWarehouseId: id,
2335
 						SupplyWarehouseId: id,
2336
+						StorehouseId:      houseConfig.StorehouseInfo,
2332
 					}
2337
 					}
2333
 					//查询是否存在入库单
2338
 					//查询是否存在入库单
2334
-					_, errcose := service.GetSindleWarehouse(record_date, orgId)
2335
-					if errcose == gorm.ErrRecordNotFound {
2336
-						service.AddSigleWarehouse(&warehousing)
2337
-					}
2339
+					//_, errcose := service.GetSindleWarehouse(record_date, orgId)
2340
+					//if errcose == gorm.ErrRecordNotFound {
2341
+					service.AddSigleWarehouse(&warehousing)
2342
+					//}
2338
 					info, _ := service.GetLastWarehouseInfoByInfo(orgId)
2343
 					info, _ := service.GetLastWarehouseInfoByInfo(orgId)
2339
 
2344
 
2340
 					//入库单表格
2345
 					//入库单表格
2361
 						PackingPrice:              item.MinPrice,
2366
 						PackingPrice:              item.MinPrice,
2362
 						SupplyWarehouseId:         id,
2367
 						SupplyWarehouseId:         id,
2363
 						SupplyWarehouseDetailInfo: item.ID,
2368
 						SupplyWarehouseDetailInfo: item.ID,
2369
+						StorehouseId:              houseConfig.StorehouseInfo,
2364
 					}
2370
 					}
2365
 					warehousingInfo = append(warehousingInfo, warehouseInfo)
2371
 					warehousingInfo = append(warehousingInfo, warehouseInfo)
2366
 				}
2372
 				}
2370
 
2376
 
2371
 	for _, item := range warehousingInfo {
2377
 	for _, item := range warehousingInfo {
2372
 		service.CreatedWarehouseingDetail(item)
2378
 		service.CreatedWarehouseingDetail(item)
2379
+		//查询该机构默认仓库
2380
+		storeConfig, _ := service.GetAllStoreHouseConfig(item.OrgId)
2381
+		//查询剩余库存
2382
+		goodList, _ := service.GetGoodSumCountByStoreId(storeConfig.StorehouseOutInfo, item.GoodId, item.OrgId)
2383
+		var sum_count int64
2384
+		var sum_in_count int64
2385
+		for _, item := range goodList {
2386
+			sum_count += item.StockCount
2387
+			sum_in_count += item.WarehousingCount
2388
+		}
2389
+		service.UpdateGoodByGoodId(item.GoodId, sum_count, sum_in_count, item.OrgId)
2390
+
2373
 		warehousinginfo, _ := service.GetLastWarehousingInfo(item.GoodId)
2391
 		warehousinginfo, _ := service.GetLastWarehousingInfo(item.GoodId)
2374
 		flow := models.VmStockFlow{
2392
 		flow := models.VmStockFlow{
2375
 			WarehousingOrder:          item.WarehousingOrder,
2393
 			WarehousingOrder:          item.WarehousingOrder,
2393
 			WarehousingDetailId:       warehousinginfo.ID,
2411
 			WarehousingDetailId:       warehousinginfo.ID,
2394
 			SupplyWarehouseId:         id,
2412
 			SupplyWarehouseId:         id,
2395
 			SupplyWarehouseDetailInfo: item.ID,
2413
 			SupplyWarehouseDetailInfo: item.ID,
2414
+			StorehouseId:              houseConfig.StorehouseInfo,
2396
 		}
2415
 		}
2397
 		service.CreateStockFlowOne(flow)
2416
 		service.CreateStockFlowOne(flow)
2398
 	}
2417
 	}
2400
 	errs := service.CreateDrugWarehousingInfoSix(warehouseInfoDetail)
2419
 	errs := service.CreateDrugWarehousingInfoSix(warehouseInfoDetail)
2401
 
2420
 
2402
 	//改变入库状态
2421
 	//改变入库状态
2422
+	for _, items := range warehouseInfoDetail {
2423
+
2424
+		//查询默认仓库
2425
+		houseConfig, _ := service.GetAllStoreHouseConfig(items.OrgId)
2426
+		//查询默认仓库剩余多少库存
2427
+		list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, items.OrgId, items.DrugId)
2428
+		var sum_count int64
2429
+		var sum_in_count int64
2430
+		for _, it := range list {
2431
+			baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
2432
+			if it.MaxUnit == baseDrug.MaxUnit {
2433
+				it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
2434
+				it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
2435
+			}
2436
+			sum_count += it.StockMaxNumber + it.StockMinNumber
2437
+			sum_in_count += it.WarehousingCount
2438
+		}
2439
+		service.UpdateMedicalSumCount(items.DrugId, sum_count, sum_in_count, items.OrgId)
2403
 
2440
 
2441
+	}
2404
 	fmt.Println(errs)
2442
 	fmt.Println(errs)
2405
 	for _, items := range drugFlow {
2443
 	for _, items := range drugFlow {
2406
 		drugWarehouseInfo, _ := service.GetLastDrugWarehouseInfo(items.DrugId)
2444
 		drugWarehouseInfo, _ := service.GetLastDrugWarehouseInfo(items.DrugId)
3117
 			}
3155
 			}
3118
 		}
3156
 		}
3119
 		if it.IsSource == 2 {
3157
 		if it.IsSource == 2 {
3120
-			fmt.Println("hh23323233232232332232323232332", it.WarehouseOutId)
3158
+
3121
 			out, _ := service.GetGoodWarehouseInfoByWarehousingId(it.ProjectId, id, orgId)
3159
 			out, _ := service.GetGoodWarehouseInfoByWarehousingId(it.ProjectId, id, orgId)
3122
 			if out.ID > 0 {
3160
 			if out.ID > 0 {
3123
 				this.ServeSuccessJSON(map[string]interface{}{
3161
 				this.ServeSuccessJSON(map[string]interface{}{
3166
 		if len(goodList) == 0 {
3204
 		if len(goodList) == 0 {
3167
 			service.UpdateGoodWarehousing(id, orgId)
3205
 			service.UpdateGoodWarehousing(id, orgId)
3168
 		}
3206
 		}
3207
+
3208
+		// 查询入库单
3209
+		drugInfo, _ := service.GetDrugSupplyWarehouseIdSeven(id, orgId)
3210
+		for _, item := range drugInfo {
3211
+
3212
+			//查询默认仓库
3213
+			houseConfig, _ := service.GetAllStoreHouseConfig(item.OrgId)
3214
+			//查询默认仓库剩余多少库存
3215
+			list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.OrgId, item.DrugId)
3216
+			var sum_count int64
3217
+			var sum_in_count int64
3218
+			for _, it := range list {
3219
+				baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
3220
+				if it.MaxUnit == baseDrug.MaxUnit {
3221
+					it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
3222
+					it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
3223
+
3224
+				}
3225
+				sum_count += it.StockMaxNumber + it.StockMinNumber
3226
+				sum_in_count += it.WarehousingCount
3227
+			}
3228
+			service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.OrgId)
3229
+		}
3230
+
3169
 		//删除药品入库单
3231
 		//删除药品入库单
3170
 		service.UpdateDrugSupplyWarehousingInfo(id, orgId)
3232
 		service.UpdateDrugSupplyWarehousingInfo(id, orgId)
3233
+
3171
 		//删除入库流水
3234
 		//删除入库流水
3172
 		service.UpdateDrugSupplyFlow(id, orgId)
3235
 		service.UpdateDrugSupplyFlow(id, orgId)
3173
 
3236
 
3237
+		//查寻入库单
3238
+		info, _ := service.GetSupplySupplyWarehouseIdSeven(id, orgId)
3239
+		for _, item := range info {
3240
+			//扣减库存
3241
+			//查询该机构默认仓库
3242
+			storeConfig, _ := service.GetAllStoreHouseConfig(item.OrgId)
3243
+			//查询剩余库存
3244
+			goodList, _ := service.GetGoodSumCountByStoreId(storeConfig.StorehouseOutInfo, item.GoodId, item.OrgId)
3245
+			var sum_count int64
3246
+			var sum_in_count int64
3247
+			for _, item := range goodList {
3248
+				sum_count += item.StockCount
3249
+				sum_in_count += item.WarehousingCount
3250
+			}
3251
+			service.UpdateGoodByGoodId(item.GoodId, sum_count, sum_in_count, item.OrgId)
3252
+		}
3253
+
3174
 		//删除耗材入库单
3254
 		//删除耗材入库单
3175
 		service.UpdateGoodSupplyWarehousingInfo(id, orgId)
3255
 		service.UpdateGoodSupplyWarehousingInfo(id, orgId)
3176
 
3256
 
3177
 		//删除耗材入库流水
3257
 		//删除耗材入库流水
3178
 		service.UpdateGoodSupplyFlow(id, orgId)
3258
 		service.UpdateGoodSupplyFlow(id, orgId)
3259
+
3179
 		if err == nil {
3260
 		if err == nil {
3180
 			this.ServeSuccessJSON(map[string]interface{}{
3261
 			this.ServeSuccessJSON(map[string]interface{}{
3181
 				"cancelList":   cancelList,
3262
 				"cancelList":   cancelList,
3290
 	orgId := this.GetAdminUserInfo().CurrentOrgId
3371
 	orgId := this.GetAdminUserInfo().CurrentOrgId
3291
 	record_date := recordDate.Unix()
3372
 	record_date := recordDate.Unix()
3292
 	checker := this.GetAdminUserInfo().AdminUser.Id
3373
 	checker := this.GetAdminUserInfo().AdminUser.Id
3293
-
3374
+	houseConfig, _ := service.GetAllStoreHouseConfig(this.GetAdminUserInfo().CurrentOrgId)
3294
 	//获取退库单详情
3375
 	//获取退库单详情
3295
 	list, _ := service.GetSupplyCancelOrderDetail(id, orgId)
3376
 	list, _ := service.GetSupplyCancelOrderDetail(id, orgId)
3296
 	for _, item := range list {
3377
 	for _, item := range list {
3297
-		fmt.Println("itme.233232323232323232323232323232232332", item.Type)
3378
+
3298
 		var total_count int64
3379
 		var total_count int64
3299
 		var prescribing_number_total int64
3380
 		var prescribing_number_total int64
3300
 		//药品
3381
 		//药品
3301
 		if item.IsSource == 1 {
3382
 		if item.IsSource == 1 {
3302
 
3383
 
3303
 			//获取药品库存
3384
 			//获取药品库存
3304
-			info, _ := service.GetDrugTotalCountTwenTy(item.ProjectId, item.SupplyWarehouseDetailInfo, item.Type)
3385
+			info, _ := service.GetDrugTotalCountTwenTy(item.ProjectId, item.SupplyWarehouseDetailInfo, item.Type, houseConfig.DrugStorehouseOut)
3305
 
3386
 
3306
 			for _, it := range info {
3387
 			for _, it := range info {
3307
 
3388
 
3324
 				prescribing_number_total = item.SupplyCount
3405
 				prescribing_number_total = item.SupplyCount
3325
 			}
3406
 			}
3326
 
3407
 
3327
-			fmt.Println("hhhhhadf dafsdfsdfddddfdf", prescribing_number_total)
3328
 			//判断单位
3408
 			//判断单位
3329
 			if total_count == 0 {
3409
 			if total_count == 0 {
3330
 				goodObj, _ := service.GetDrugByGoodId(item.ProjectId)
3410
 				goodObj, _ := service.GetDrugByGoodId(item.ProjectId)
3382
 				Type:                    1,
3462
 				Type:                    1,
3383
 				SupplyCancelOutId:       id,
3463
 				SupplyCancelOutId:       id,
3384
 				SupplyWarehouseId:       warehouse_out_id,
3464
 				SupplyWarehouseId:       warehouse_out_id,
3465
+				StorehouseId:            houseConfig.DrugStorehouseOut,
3385
 			}
3466
 			}
3386
 			// 查询今日是否存在出库单
3467
 			// 查询今日是否存在出库单
3387
 			_, errcodes := service.GetDrugWarehouseOutById(orgId, record_date)
3468
 			_, errcodes := service.GetDrugWarehouseOutById(orgId, record_date)
3417
 				SupplyWarehouseId:       warehouse_out_id,
3498
 				SupplyWarehouseId:       warehouse_out_id,
3418
 				SysRecordTime:           record_date,
3499
 				SysRecordTime:           record_date,
3419
 				IsSource:                item.Type,
3500
 				IsSource:                item.Type,
3501
+				StorehouseId:            houseConfig.DrugStorehouseOut,
3420
 			}
3502
 			}
3421
 
3503
 
3422
 			drup, _ := service.FindBaseDrugLibRecord(orgId, item.ProjectId)
3504
 			drup, _ := service.FindBaseDrugLibRecord(orgId, item.ProjectId)
3435
 		//耗材
3517
 		//耗材
3436
 		if item.IsSource == 2 {
3518
 		if item.IsSource == 2 {
3437
 			// 查询该耗材是否有库存
3519
 			// 查询该耗材是否有库存
3438
-			warehouseOne, _ := service.FindWarehousingInfoTwenTy(item.ProjectId, item.SupplyWarehouseDetailInfo, item.Type)
3520
+			warehouseOne, _ := service.FindWarehousingInfoTwenTy(item.ProjectId, item.SupplyWarehouseDetailInfo, item.Type, houseConfig.StorehouseOutInfo)
3439
 
3521
 
3440
 			// 如果出库数量大于该批次剩余库存数量
3522
 			// 如果出库数量大于该批次剩余库存数量
3441
 			if item.SupplyCount > warehouseOne.StockCount {
3523
 			if item.SupplyCount > warehouseOne.StockCount {
3478
 				SupplyCancelOutId:       id,
3560
 				SupplyCancelOutId:       id,
3479
 				SupplyWarehouseId:       warehouse_out_id,
3561
 				SupplyWarehouseId:       warehouse_out_id,
3480
 				IsSys:                   0,
3562
 				IsSys:                   0,
3563
+				StorehouseId:            houseConfig.StorehouseOutInfo,
3481
 			}
3564
 			}
3482
 			//查询是否生成出库单
3565
 			//查询是否生成出库单
3483
 			_, errcodes := service.FindStockOutByIsSys(orgId, 0, record_date)
3566
 			_, errcodes := service.FindStockOutByIsSys(orgId, 0, record_date)
3485
 				service.AddSigleWarehouseOut(&warehouseOut)
3568
 				service.AddSigleWarehouseOut(&warehouseOut)
3486
 			}
3569
 			}
3487
 			outWarehouse, _ := service.GetlastWarehouseOutById(orgId, record_date)
3570
 			outWarehouse, _ := service.GetlastWarehouseOutById(orgId, record_date)
3488
-			fmt.Println("232332322332232323", outWarehouse)
3571
+
3489
 			goodObj, _ := service.GetGoodInformationByGoodId(item.ProjectId)
3572
 			goodObj, _ := service.GetGoodInformationByGoodId(item.ProjectId)
3490
 			info := &models.WarehouseOutInfo{
3573
 			info := &models.WarehouseOutInfo{
3491
 				WarehouseOutOrderNumber: outWarehouse.WarehouseOutOrderNumber,
3574
 				WarehouseOutOrderNumber: outWarehouse.WarehouseOutOrderNumber,
3510
 				OrgId:                   orgId,
3593
 				OrgId:                   orgId,
3511
 				SupplyWarehouseId:       warehouse_out_id,
3594
 				SupplyWarehouseId:       warehouse_out_id,
3512
 				IsSource:                item.Type,
3595
 				IsSource:                item.Type,
3596
+				StorehouseId:            houseConfig.StorehouseOutInfo,
3513
 			}
3597
 			}
3514
 			//出库逻辑
3598
 			//出库逻辑
3515
 			parseDateErr := service.ConsumablesDeliveryNight(orgId, record_date, info, &warehouseOut, item.SupplyCount, creater, warehouse_out_id, id)
3599
 			parseDateErr := service.ConsumablesDeliveryNight(orgId, record_date, info, &warehouseOut, item.SupplyCount, creater, warehouse_out_id, id)
3527
 		CheckTime: record_date,
3611
 		CheckTime: record_date,
3528
 	}
3612
 	}
3529
 	err := service.CheckReturnOrder(id, orgId, cancel)
3613
 	err := service.CheckReturnOrder(id, orgId, cancel)
3530
-	fmt.Println("3232233232322332232323232323322332232323232323")
3614
+
3531
 	if err == nil {
3615
 	if err == nil {
3532
 		this.ServeSuccessJSON(map[string]interface{}{
3616
 		this.ServeSuccessJSON(map[string]interface{}{
3533
 			"msg":        "1",
3617
 			"msg":        "1",
3601
 func (this *SupplyOrderApiController) ModefyReturnOrder() {
3685
 func (this *SupplyOrderApiController) ModefyReturnOrder() {
3602
 	id, _ := this.GetInt64("id")
3686
 	id, _ := this.GetInt64("id")
3603
 	err := service.ModefyReturnOrder(id)
3687
 	err := service.ModefyReturnOrder(id)
3604
-
3605
 	//获取退库单据日期
3688
 	//获取退库单据日期
3606
 	cancel, _ := service.GetReturnOrderById(id)
3689
 	cancel, _ := service.GetReturnOrderById(id)
3607
 	orgId := this.GetAdminUserInfo().CurrentOrgId
3690
 	orgId := this.GetAdminUserInfo().CurrentOrgId
3619
 					drugInfo := models.DrugWarehouseInfo{
3702
 					drugInfo := models.DrugWarehouseInfo{
3620
 						StockMaxNumber: item.SupplyCount,
3703
 						StockMaxNumber: item.SupplyCount,
3621
 					}
3704
 					}
3705
+
3622
 					service.UpdateDrugWasehousring(item.ProjectId, item.SupplyWarehouseDetailInfo, drugInfo)
3706
 					service.UpdateDrugWasehousring(item.ProjectId, item.SupplyWarehouseDetailInfo, drugInfo)
3707
+					var sum_count int64
3708
+					sum_count = item.SupplyCount * base.MinNumber
3709
+					service.ModifyDrugAddInformation(item.ProjectId, sum_count, orgId)
3623
 				}
3710
 				}
3624
 
3711
 
3625
 				if item.SupplyType == base.MinUnit && base.MaxUnit != base.MinUnit {
3712
 				if item.SupplyType == base.MinUnit && base.MaxUnit != base.MinUnit {
3627
 						StockMinNumber: item.SupplyCount,
3714
 						StockMinNumber: item.SupplyCount,
3628
 					}
3715
 					}
3629
 					service.UpdateDrugWasehousringOne(item.ProjectId, item.SupplyWarehouseDetailInfo, drugInfo)
3716
 					service.UpdateDrugWasehousringOne(item.ProjectId, item.SupplyWarehouseDetailInfo, drugInfo)
3717
+					service.ModifyDrugAddInformation(item.ProjectId, item.SupplyCount, orgId)
3630
 				}
3718
 				}
3631
 
3719
 
3632
 				//删除流水
3720
 				//删除流水
3641
 			}
3729
 			}
3642
 			//耗材
3730
 			//耗材
3643
 			if item.IsSource == 2 {
3731
 			if item.IsSource == 2 {
3644
-				fmt.Println("item2332322323232332", item.SupplyCount)
3732
+
3645
 				//退库
3733
 				//退库
3646
 				info := models.WarehousingInfo{
3734
 				info := models.WarehousingInfo{
3647
 					StockCount: item.SupplyCount,
3735
 					StockCount: item.SupplyCount,
3649
 
3737
 
3650
 				//更改库存
3738
 				//更改库存
3651
 				err := service.UpdateWarehousingInfoById(item.ProjectId, item.SupplyWarehouseDetailInfo, info)
3739
 				err := service.UpdateWarehousingInfoById(item.ProjectId, item.SupplyWarehouseDetailInfo, info)
3740
+				service.ModifyGoodAddInformation(item.ProjectId, item.SupplyCount, item.UserOrgId)
3652
 				fmt.Println(err)
3741
 				fmt.Println(err)
3653
 				//删除出库记录
3742
 				//删除出库记录
3654
 				service.DeleteGoodWarehouseOut(item.ProjectId, item.WarehouseCancelId, orgId)
3743
 				service.DeleteGoodWarehouseOut(item.ProjectId, item.WarehouseCancelId, orgId)

+ 9 - 0
controllers/verify_login_controller.go View File

301
 			}
301
 			}
302
 
302
 
303
 			subscibe, _ := service.GetOrgSubscibe(adminUserInfo.CurrentOrgId)
303
 			subscibe, _ := service.GetOrgSubscibe(adminUserInfo.CurrentOrgId)
304
+			//判断该机构是否需要生成默认仓库
305
+			orgid := adminUserInfo.CurrentOrgId
306
+			boolean := service.IsStorehouse(orgid)
307
+			if boolean == false {
308
+				err = service.GetDefaultStorehouse(orgid)
309
+				if err != nil {
310
+					utils.ErrorLog("创建默认仓库失败,原因为:", err)
311
+				}
312
+			}
304
 
313
 
305
 			this.SetSession("admin_user_info", adminUserInfo)
314
 			this.SetSession("admin_user_info", adminUserInfo)
306
 
315
 

+ 3 - 0
models/dialysis.go View File

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 View File

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 View File

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 View File

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 View File

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 {

+ 97 - 0
models/his_deposit_models.go View File

1
+package models
2
+
3
+import "github.com/shopspring/decimal"
4
+
5
+type Deposit struct {
6
+	ID           int64           `gorm:"column:id" json:"id" form:"id"`
7
+	UserOrgId    int64           `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`          //机构id
8
+	HisPatientId int64           `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"` //his病人id
9
+	Ctime        int64           `gorm:"column:ctime" json:"ctime" form:"ctime"`
10
+	Mtime        int64           `gorm:"column:mtime" json:"mtime" form:"mtime"`
11
+	Status       int64           `gorm:"column:status" json:"status" form:"status"`
12
+	Deposit      decimal.Decimal `gorm:"column:deposit" json:"deposit" form:"deposit"` //押金
13
+}
14
+
15
+func (Deposit) TableName() string {
16
+	return "sgj_xt.his_deposit"
17
+}
18
+
19
+type DepositHistory struct {
20
+	ID             int64           `gorm:"column:id" json:"id" form:"id"`
21
+	UserOrgId      int64           `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`          //机构id
22
+	HisPatientId   int64           `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"` //his病人id
23
+	DepositCode    string          `gorm:"column:deposit_code" json:"deposit_code" form:"deposit_code"`
24
+	Deposit        decimal.Decimal `gorm:"column:deposit" json:"deposit" form:"deposit"`                         //本次操作金额
25
+	SurplusDeposit decimal.Decimal `gorm:"column:surplus_deposit" json:"surplus_deposit" form:"surplus_deposit"` //剩余金额
26
+	DepositStatus  int64           `gorm:"column:deposit_status" json:"deposit_status" form:"deposit_status"`    //1:充值,2:扣费,3:退费
27
+	Status         int64           `gorm:"column:status" json:"status" form:"status"`
28
+	CreateId       int64           `gorm:"column:create_id" json:"create_id" form:"create_id"`
29
+	Ctime          int64           `gorm:"column:ctime" json:"ctime" form:"ctime"`
30
+	Mtime          int64           `gorm:"column:mtime" json:"mtime" form:"mtime"`
31
+	TrialStatus    int64           `gorm:"column:trial_status" json:"trial_status" form:"trial_status"` //审核状态0:未审核 ,1:已审核
32
+	Remarks        string          `gorm:"column:remarks" json:"remarks" form:"remarks"`                //备注
33
+}
34
+
35
+func (DepositHistory) TableName() string {
36
+	return "sgj_xt.his_deposit_history"
37
+}
38
+
39
+type GetHisName struct {
40
+	ID   int64  `gorm:"column:id" json:"id" form:"id"`
41
+	Name string `gorm:"column:name" json:"name" form:"name"`
42
+}
43
+
44
+func (GetHisName) TableName() string {
45
+	return "sgj_xt.xt_patients"
46
+}
47
+
48
+type DepositHistoryname struct {
49
+	ID             int64           `gorm:"column:id" json:"id" form:"id"`
50
+	UserOrgId      int64           `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`          //机构id
51
+	HisPatientId   int64           `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"` //his病人id
52
+	DepositCode    string          `gorm:"column:deposit_code" json:"deposit_code" form:"deposit_code"`
53
+	Deposit        decimal.Decimal `gorm:"column:deposit" json:"deposit" form:"deposit"`                         //本次操作金额
54
+	SurplusDeposit decimal.Decimal `gorm:"column:surplus_deposit" json:"surplus_deposit" form:"surplus_deposit"` //剩余金额
55
+	DepositStatus  int64           `gorm:"column:deposit_status" json:"deposit_status" form:"deposit_status"`    //1:充值,2:扣费,3:退费
56
+	Status         int64           `gorm:"column:status" json:"status" form:"status"`
57
+	CreateId       int64           `gorm:"column:create_id" json:"create_id" form:"create_id"`
58
+	Ctime          int64           `gorm:"column:ctime" json:"ctime" form:"ctime"`
59
+	Mtime          int64           `gorm:"column:mtime" json:"mtime" form:"mtime"`
60
+	TrialStatus    int64           `gorm:"column:trial_status" json:"trial_status" form:"trial_status"` //审核状态0:未审核 ,1:已审核
61
+	Remarks        string          `gorm:"column:remarks" json:"remarks" form:"remarks"`                //备注
62
+	Name           string          ` json:"name" `
63
+}
64
+
65
+func (DepositHistoryname) TableName() string {
66
+	return "sgj_xt.his_deposit_history"
67
+}
68
+
69
+type CreateUser struct {
70
+	ID   int64  `gorm:"column:id" json:"id" form:"id"`
71
+	Name string `gorm:"column:name" json:"name" form:"name"`
72
+}
73
+
74
+func (CreateUser) TableName() string {
75
+	return "sgj_users.sgj_user_admin"
76
+}
77
+
78
+type Summary struct {
79
+	HisName    string          `json:"his_name"`    //患者姓名
80
+	SumDecimal decimal.Decimal `json:"sum_decimal"` //充值金额
81
+	Decimal    decimal.Decimal `json:"decimal"`     //押金余额
82
+}
83
+
84
+type Deposit1 struct {
85
+	ID             int64           `gorm:"column:id" json:"id" form:"id"`
86
+	UserOrgId      int64           `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`          //机构id
87
+	HisPatientId   int64           `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"` //his病人id
88
+	HisPatientName string          `json:"his_patient_name"`
89
+	Ctime          int64           `gorm:"column:ctime" json:"ctime" form:"ctime"`
90
+	Mtime          int64           `gorm:"column:mtime" json:"mtime" form:"mtime"`
91
+	Status         int64           `gorm:"column:status" json:"status" form:"status"`
92
+	Deposit        decimal.Decimal `gorm:"column:deposit" json:"deposit" form:"deposit"` //押金
93
+}
94
+
95
+func (Deposit1) TableName() string {
96
+	return "sgj_xt.his_deposit"
97
+}

+ 2 - 0
models/patient_models.go View File

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
 	ZbPatientId              string  `gorm:"column:zb_patient_id" json:"zb_patient_id" form:"zb_patient_id"`
192
 	ZbPatientId              string  `gorm:"column:zb_patient_id" json:"zb_patient_id" form:"zb_patient_id"`
743
 	SchRemark                    string  `gorm:"column:sch_remark" json:"sch_remark" form:"sch_remark"`
744
 	SchRemark                    string  `gorm:"column:sch_remark" json:"sch_remark" form:"sch_remark"`
744
 	OutReason                    string  `gorm:"column:out_reason" json:"out_reason" form:"out_reason"`
745
 	OutReason                    string  `gorm:"column:out_reason" json:"out_reason" form:"out_reason"`
745
 	DeathTime                    int64   `gorm:"column:death_time" json:"death_time" form:"death_time"`
746
 	DeathTime                    int64   `gorm:"column:death_time" json:"death_time" form:"death_time"`
747
+	TrobleShoot                  int64   `gorm:"column:troble_shoot" json:"troble_shoot" form:"troble_shoot"`
746
 }
748
 }
747
 
749
 
748
 func (XtPatientsNew) TableName() string {
750
 func (XtPatientsNew) TableName() string {

+ 199 - 1
models/secondary_models.go View File

1
 package models
1
 package models
2
 
2
 
3
-func main() {
3
+//仓库配置
4
+type StorehouseConfig struct {
5
+	ID                 int64 `gorm:"column:id" json:"id" form:"id"`
6
+	UserOrgId          int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`                         //机构id
7
+	StorehouseInfo     int64 `gorm:"column:storehouse_info" json:"storehouse_info" form:"storehouse_info"`             //耗材 自动入库 的仓库id
8
+	StorehouseOutInfo  int64 `gorm:"column:storehouse_out_info" json:"storehouse_out_info" form:"storehouse_out_info"` //耗材 自动出库 的仓库id
9
+	DrugStorehouseInfo int64 `gorm:"drug_storehouse_info" json:"drug_storehouse_info" form:"drug_storehouse_info"`     //药品 自动入库 的仓库id
10
+	DrugStorehouseOut  int64 `gorm:"drug_storehouse_out" json:"drug_storehouse_out" form:"drug_storehouse_out"`        //药品 自动出库 的仓库id
11
+	Status             int64 `gorm:"status" json:"status" form:"status"`
12
+	Ctime              int64 `gorm:"ctime" json:"ctime" form:"ctime"`
13
+	Mtime              int64 `gorm:"mtime" json:"mtime" form:"mtime"`
14
+}
15
+
16
+func (StorehouseConfig) TableName() string {
17
+	return "xt_storehouse_config"
18
+}
19
+
20
+type App_Role_byli struct {
21
+	Id          int64  `gorm:"PRIMARY_KEY;AUTO_INCREMENT" json:"id"`
22
+	OrgId       int64  `gorm:"column:org_id" json:"org_id"`
23
+	AdminUserId int64  `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
24
+	UserName    string `gorm:"column:user_name" json:"user_name"` // 用户名称
25
+}
26
+
27
+func (App_Role_byli) TableName() string {
28
+	return "sgj_users.sgj_user_admin_role"
29
+}
30
+
31
+type UserOrg struct {
32
+	Id      int64 `gorm:"PRIMARY_KEY;AUTO_INCREMENT" json:"id"`
33
+	Creator int64 `gorm:"column:creator" json:"creator"`
34
+}
35
+
36
+func (UserOrg) TableName() string {
37
+	return "sgj_users.sgj_user_org"
38
+}
39
+
40
+//分页
41
+type Storehouselist struct {
42
+	ID                  int64  `gorm:"column:id" json:"id" form:"id"`
43
+	StorehouseCode      string `gorm:"column:storehouse_code" json:"storehouse_code" form:"storehouse_code"`                 //仓库编号
44
+	StorehouseName      string `gorm:"column:storehouse_name" json:"storehouse_name" form:"storehouse_name"`                 //仓库名称
45
+	StorehouseAddress   string `gorm:"column:storehouse_address" json:"storehouse_address" form:"storehouse_address"`        //仓库地址
46
+	StorehouseStatus    int64  `gorm:"column:storehouse_status" json:"storehouse_status" form:"storehouse_status"`           //仓库状态
47
+	Status              int64  `gorm:"column:status" json:"status" form:"status"`                                            //数据状态
48
+	StorehouseAdminId   int64  `gorm:"column:storehouse_admin_id" json:"storehouse_admin_id" form:"storehouse_admin_id"`     //仓库管理员id
49
+	StorehouseAdminName string `gorm:"column:storehouse_admin_name" json:"storehouse_admin_name" form:"storehouse_admin_id"` //仓库管理员名字
50
+	UserOrgId           int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
51
+	Ctime               int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
52
+	Mtime               int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
53
+}
54
+
55
+type RolePurviews struct {
56
+	Id         int64 `gorm:"PRIMARY_KEY;AUTO_INCREMENT"`
57
+	RoleId     int64
58
+	OrgId      int64
59
+	AppId      int64
60
+	PurviewIds string `gorm:"column:purview_ids"`
61
+	Status     int8   // 状态 0.无效 1.有效 2.禁用
62
+	CreateTime int64  `gorm:"column:ctime"` // 创建时间
63
+	ModifyTime int64  `gorm:"column:mtime"` // 修改时间
64
+	Role       Role   `gorm:"ForeignKey:RoleId;AssociationForeignKey:ID" json:"role_info"`
65
+}
66
+
67
+func (RolePurviews) TableName() string {
68
+	return "sgj_users.sgj_user_role_purview"
69
+}
70
+
71
+type XtStorehouse struct {
72
+	ID                  int64  `gorm:"column:id" json:"id" form:"id"`
73
+	StorehouseCode      string `gorm:"column:storehouse_code" json:"storehouse_code" form:"storehouse_code"`
74
+	StorehouseName      string `gorm:"column:storehouse_name" json:"storehouse_name" form:"storehouse_name"`
75
+	StorehouseAddress   string `gorm:"column:storehouse_address" json:"storehouse_address" form:"storehouse_address"`
76
+	StorehouseStatus    int64  `gorm:"column:storehouse_status" json:"storehouse_status" form:"storehouse_status"`
77
+	Status              int64  `gorm:"column:status" json:"status" form:"status"`
78
+	StorehouseAdminId   int64  `gorm:"column:storehouse_admin_id" json:"storehouse_admin_id" form:"storehouse_admin_id"`
79
+	StorehouseAdminName string `gorm:"column:storehouse_admin_name" json:"storehouse_admin_name" form:"storehouse_admin_name"`
80
+	UserOrgId           int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
81
+	Ctime               int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
82
+	Mtime               int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
83
+}
84
+
85
+func (XtStorehouse) TableName() string {
86
+	return "xt_storehouse"
87
+}
88
+
89
+type VmStorehouseName struct {
90
+	ID               int64  `gorm:"column:id" json:"id" form:"id"`
91
+	StorehouseName   string `gorm:"column:storehouse_name" json:"storehouse_name" form:"storehouse_name"`
92
+	StorehouseId     int64  `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
93
+	StockMaxNumber   int64  `gorm:"column:stock_max_number" json:"stock_max_number" form:"stock_max_number"`
94
+	StockMinNumber   int64  `gorm:"column:stock_min_number" json:"stock_min_number" form:"stock_min_number"`
95
+	WarehousingCount int64  `gorm:"column:warehousing_count" json:"warehousing_count" form:"warehousing_count"`
96
+}
97
+
98
+type VmStorehouseNameOne struct {
99
+	ID               int64  `gorm:"column:id" json:"id" form:"id"`
100
+	StorehouseName   string `gorm:"column:storehouse_name" json:"storehouse_name" form:"storehouse_name"`
101
+	StorehouseId     int64  `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
102
+	StockCount       int64  `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
103
+	WarehousingCount int64  `gorm:"column:warehousing_count" json:"warehousing_count" form:"warehousing_count"`
104
+}
105
+
106
+type XtStorehouseConfig struct {
107
+	ID                 int64 `gorm:"column:id" json:"id" form:"id"`
108
+	UserOrgId          int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
109
+	StorehouseInfo     int64 `gorm:"column:storehouse_info" json:"storehouse_info" form:"storehouse_info"`
110
+	StorehouseOutInfo  int64 `gorm:"column:storehouse_out_info" json:"storehouse_out_info" form:"storehouse_out_info"`
111
+	DrugStorehouseInfo int64 `gorm:"column:drug_storehouse_info" json:"drug_storehouse_info" form:"drug_storehouse_info"`
112
+	DrugStorehouseOut  int64 `gorm:"column:drug_storehouse_out" json:"drug_storehouse_out" form:"drug_storehouse_out"`
113
+	Status             int64 `gorm:"column:status" json:"status" form:"status"`
114
+	Ctime              int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
115
+	Mtime              int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
116
+}
117
+
118
+func (XtStorehouseConfig) TableName() string {
119
+	return "xt_storehouse_config"
120
+}
121
+
122
+//二级仓库
123
+type Storehouse struct {
124
+	ID                int64  `gorm:"column:id" json:"id" form:"id"`
125
+	StorehouseCode    string `gorm:"column:storehouse_code" json:"storehouse_code" form:"storehouse_code"`             //仓库编号
126
+	StorehouseName    string `gorm:"column:storehouse_name" json:"storehouse_name" form:"storehouse_name"`             //仓库名称
127
+	StorehouseAddress string `gorm:"column:storehouse_address" json:"storehouse_address" form:"storehouse_address"`    //仓库地址
128
+	StorehouseStatus  int64  `gorm:"column:storehouse_status" json:"storehouse_status" form:"storehouse_status"`       //仓库状态
129
+	Status            int64  `gorm:"column:status" json:"status" form:"status"`                                        //数据状态
130
+	StorehouseAdminId int64  `gorm:"column:storehouse_admin_id" json:"storehouse_admin_id" form:"storehouse_admin_id"` //仓库管理员id
131
+	UserOrgId         int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
132
+	Ctime             int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
133
+	Mtime             int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
134
+}
135
+
136
+func (Storehouse) TableName() string {
137
+	return "xt_storehouse"
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 View File

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 View File

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 - 1
routers/router.go View File

10
 
10
 
11
 func init() {
11
 func init() {
12
 	beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
12
 	beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
13
-		// AllowAllOrigins:  true,
13
+		//AllowAllOrigins:  true,
14
 		AllowOrigins: []string{"https://xt.kuyicloud.com", "http://localhost:9528", "http://localhost:9529", "http://localhost:9531", "http://xt.test.shengws.com", "http://new_mobile.test.sgjyun.com", "https://xt.test.shengws.com", "http://xt.test.sgjyun.com", "https://xt.test.sgjyun.com", "http://localhost:8081", "http://localhost:8082", "https://pad.kuyicloud.com", "http://pad.kuyicloud.com", "http://pad.test.sgjyun.com", "https://pad.test.sgjyun.com", "http://admin.xt.test.sgjyun.com", "http://admin.xt.kuyicloud.com", "http://mobile.sgjyun.com", "http://mobile.kuyicloud.com"},
14
 		AllowOrigins: []string{"https://xt.kuyicloud.com", "http://localhost:9528", "http://localhost:9529", "http://localhost:9531", "http://xt.test.shengws.com", "http://new_mobile.test.sgjyun.com", "https://xt.test.shengws.com", "http://xt.test.sgjyun.com", "https://xt.test.sgjyun.com", "http://localhost:8081", "http://localhost:8082", "https://pad.kuyicloud.com", "http://pad.kuyicloud.com", "http://pad.test.sgjyun.com", "https://pad.test.sgjyun.com", "http://admin.xt.test.sgjyun.com", "http://admin.xt.kuyicloud.com", "http://mobile.sgjyun.com", "http://mobile.kuyicloud.com"},
15
 		//AllowOrigins:     []string{"https://xt.kuyicloud.com", "http://localhost:9528", "http://xt.test.shengws.com","https://xt.test.shengws.com", "http://xt.test.sgjyun.com","https://xt.test.sgjyun.com", "http://localhost:8081", "http://localhost:8082", "https://pad.kuyicloud.com", "http://pad.kuyicloud.com", "http://pad.test.sgjyun.com","https://pad.test.sgjyun.com", "http://admin.xt.test.sgjyun.com", "http://admin.xt.kuyicloud.com","http://mobile.sgjyun.com","http://mobile.kuyicloud.com"},
15
 		//AllowOrigins:     []string{"https://xt.kuyicloud.com", "http://localhost:9528", "http://xt.test.shengws.com","https://xt.test.shengws.com", "http://xt.test.sgjyun.com","https://xt.test.sgjyun.com", "http://localhost:8081", "http://localhost:8082", "https://pad.kuyicloud.com", "http://pad.kuyicloud.com", "http://pad.test.sgjyun.com","https://pad.test.sgjyun.com", "http://admin.xt.test.sgjyun.com", "http://admin.xt.kuyicloud.com","http://mobile.sgjyun.com","http://mobile.kuyicloud.com"},
16
 		AllowMethods:     []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
16
 		AllowMethods:     []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
80
 
80
 
81
 	controllers.SupplyOrderApiRegistRouters()
81
 	controllers.SupplyOrderApiRegistRouters()
82
 	controllers.SecondaryOrderApiRegistRouters()
82
 	controllers.SecondaryOrderApiRegistRouters()
83
+	controllers.HisDepositApiRegistRouters()
83
 }
84
 }

+ 2 - 2
service/device_service.go View File

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

+ 7 - 2
service/dialysis_service.go View File

706
 		Preload("AssessmentBeforeDislysis", "status = 1 AND  user_org_id = ?", orgID).
706
 		Preload("AssessmentBeforeDislysis", "status = 1 AND  user_org_id = ?", orgID).
707
 		Preload("AssessmentAfterDislysis", "status = 1 AND  user_org_id = ?", orgID).
707
 		Preload("AssessmentAfterDislysis", "status = 1 AND  user_org_id = ?", orgID).
708
 		Preload("MonitoringRecord", func(db *gorm.DB) *gorm.DB {
708
 		Preload("MonitoringRecord", func(db *gorm.DB) *gorm.DB {
709
-			return db.Where("status = 1 AND user_org_id = ?", orgID).Order("operate_time asc")
709
+			return db.Where("status = 1 AND user_org_id = ? ", orgID).Order("operate_time asc")
710
 		}).
710
 		}).
711
 		Preload("DialysisOrder", "status = 1 AND user_org_id = ?", orgID).
711
 		Preload("DialysisOrder", "status = 1 AND user_org_id = ?", orgID).
712
 		Preload("MonitorPatients", "status = 1 AND user_org_id = ?", orgID)
712
 		Preload("MonitorPatients", "status = 1 AND user_org_id = ?", orgID)
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).
1238
 	err = writeDb.Model(&models.AssessmentAfterDislysis{}).Where("status =1 AND user_org_id = ? AND patient_id = ? AND assessment_date = ?", org_id, patient_id, date).Updates(map[string]interface{}{"actual_treatment_hour": actual_treatment_hour, "actual_treatment_minute": actual_treatment_minute}).Error
1238
 	err = writeDb.Model(&models.AssessmentAfterDislysis{}).Where("status =1 AND user_org_id = ? AND patient_id = ? AND assessment_date = ?", org_id, patient_id, date).Updates(map[string]interface{}{"actual_treatment_hour": actual_treatment_hour, "actual_treatment_minute": actual_treatment_minute}).Error
1239
 	return
1239
 	return
1240
 }
1240
 }
1241
+func UpdateAssessmentAfterDateOne(patient_id int64, org_id int64, date int64, actual_treatment_hour int64, actual_treatment_minute int64, BreathingRate float64) (err error) {
1242
+	err = writeDb.Model(&models.AssessmentAfterDislysis{}).Where("status =1 AND user_org_id = ? AND patient_id = ? AND assessment_date = ?", org_id, patient_id, date).Updates(map[string]interface{}{"actual_treatment_hour": actual_treatment_hour, "actual_treatment_minute": actual_treatment_minute, "breathing_rate": BreathingRate}).Error
1243
+	return
1244
+}
1241
 
1245
 
1242
 func CreateDialysisBeforePrepare(beforePrepares []*models.DialysisBeforePrepare) (err error) {
1246
 func CreateDialysisBeforePrepare(beforePrepares []*models.DialysisBeforePrepare) (err error) {
1243
 	if len(beforePrepares) > 0 {
1247
 	if len(beforePrepares) > 0 {
1351
 func GetGoodInfoMation(orgid int64) (goodinfo []*models.GoodInfo, err error) {
1355
 func GetGoodInfoMation(orgid int64) (goodinfo []*models.GoodInfo, err error) {
1352
 
1356
 
1353
 	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
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
1354
 	return goodinfo, err
1359
 	return goodinfo, err
1355
 }
1360
 }
1356
 
1361
 

+ 6 - 0
service/doctor_schedule_service.go View File

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 View File

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
 

+ 304 - 0
service/his_deposit_service.go View File

1
+package service
2
+
3
+import (
4
+	"XT_New/models"
5
+	"XT_New/utils"
6
+	"fmt"
7
+	"github.com/shopspring/decimal"
8
+	"math/rand"
9
+	"strconv"
10
+	"time"
11
+)
12
+
13
+//生成编号?+yymmdd+随机数(4位)
14
+//新增参数为CP
15
+//退款参数为AF
16
+func CreateCPCode(str string) string {
17
+	s := fmt.Sprintf("%04v", rand.New(rand.NewSource(time.Now().UnixNano())).Int63n(10000))
18
+	t := time.Now().Format("20060102")
19
+	code := str + t + s
20
+	return code
21
+}
22
+
23
+//获取his中的有效患者
24
+func GetHisUser(orgid int64) (hisname []models.GetHisName, err error) {
25
+	err = XTReadDB().Model(&models.GetHisName{}).Where("status = 1 and user_org_id = ?", orgid).Find(&hisname).Error
26
+	return
27
+}
28
+
29
+//获取his中的有效患者
30
+func GetHisUserName(orgid, id int64) (hisname models.GetHisName, err error) {
31
+	err = XTReadDB().Model(&models.GetHisName{}).Where("status = 1 and user_org_id = ? and id = ?", orgid, id).Find(&hisname).Error
32
+	return
33
+}
34
+
35
+//添加押金(开始)调用接口前记得判断审核状态,确认通过审核后在调用
36
+func UpDeposit(code, remarks string, his_patient_id, orgid, trial_status, createid int64, deposit decimal.Decimal) (err error) {
37
+	//查押金表是否存在记录
38
+	tmp, tmpdeposit := IsHisPatientId(his_patient_id, orgid)
39
+	if tmp == 0 {
40
+		//需要生成一条数据
41
+		de := models.Deposit{
42
+			UserOrgId:    orgid,
43
+			HisPatientId: his_patient_id,
44
+			Ctime:        time.Now().Unix(),
45
+			Status:       1,
46
+		}
47
+		i, d, err := AddDeposit(de)
48
+		if err != nil || i == 0 {
49
+			utils.ErrorLog("添加用户押金记录失败: %v", err.Error())
50
+			return err
51
+		}
52
+		tmp = i
53
+		tmpdeposit = d
54
+	}
55
+	if trial_status == 1 {
56
+		de := models.Deposit{
57
+			ID:      tmp,
58
+			Mtime:   time.Now().Unix(),
59
+			Deposit: deposit.Add(tmpdeposit),
60
+		}
61
+		err = UpdateDeposit(de)
62
+		if err != nil {
63
+			utils.ErrorLog("添加用户押金失败: %v", err.Error())
64
+			return
65
+		}
66
+	}
67
+	dehistory := models.DepositHistory{
68
+		UserOrgId:      orgid,
69
+		HisPatientId:   his_patient_id,
70
+		DepositCode:    code,
71
+		Deposit:        deposit,                 //本次操作的押金
72
+		SurplusDeposit: tmpdeposit.Add(deposit), //剩余金额
73
+		DepositStatus:  1,
74
+		Status:         1,
75
+		CreateId:       createid,
76
+		Ctime:          time.Now().Unix(),
77
+		Mtime:          time.Now().Unix(),
78
+		TrialStatus:    trial_status,
79
+		Remarks:        remarks,
80
+	}
81
+	err = AddDepositHistory(dehistory)
82
+	if err != nil {
83
+		utils.ErrorLog("添加用户押金历史记录失败: %v", err.Error())
84
+	}
85
+	return
86
+}
87
+
88
+//添加押金记录
89
+func AddDepositHistory(dh models.DepositHistory) error {
90
+	err := XTWriteDB().Create(&dh).Error
91
+	return err
92
+}
93
+
94
+//押金中添加一条记录,并返回该数据的id和押金余额(当没有该用户记录时调用)
95
+func AddDeposit(de models.Deposit) (int64, decimal.Decimal, error) {
96
+	var tmp models.Deposit
97
+	err := XTWriteDB().Create(&de).Find(&tmp).Error
98
+	if err != nil {
99
+		return 0, decimal.NewFromFloat(0.00), err
100
+	}
101
+	return tmp.ID, tmp.Deposit, err
102
+}
103
+
104
+//更改押金记录
105
+func UpdateDeposit(de models.Deposit) (err error) {
106
+	err = XTWriteDB().Model(&models.Deposit{}).Where("id = ? and status = 1", de.ID).Updates(map[string]interface{}{
107
+		"mtime":   de.Mtime,
108
+		"deposit": de.Deposit,
109
+	}).Error
110
+	return
111
+}
112
+
113
+//判断押金表是否存在当前的患者的一条有效数据,如果有返回id和押金余额,没有返回0
114
+func IsHisPatientId(his_patient_id, orgid int64) (int64, decimal.Decimal) {
115
+	var tmp []models.Deposit
116
+	XTReadDB().Model(&models.Deposit{}).Where("user_org_id = ? and his_patient_id = ? and status = 1", orgid, his_patient_id).Find(&tmp)
117
+	if len(tmp) != 1 {
118
+		return 0, decimal.NewFromFloat(0.00)
119
+	}
120
+	return tmp[0].ID, tmp[0].Deposit
121
+}
122
+
123
+//查询押金编号是否重复
124
+func FindDecimalCode(orgid int64, code string) bool {
125
+	var total int
126
+	XTReadDB().Model(&models.DepositHistory{}).Where("user_org_id = ? and deposit_code = ? and status = 1", orgid, code).Count(&total)
127
+	if total > 0 {
128
+		return true
129
+	} else {
130
+		return false
131
+	}
132
+}
133
+
134
+//充值明细列表
135
+func DetailsList(orgid, stime, etime int64, keyword string, slicekey []int64) (deposithistory []models.DepositHistoryname, err error) {
136
+	db := XTReadDB().Model(&models.DepositHistory{}).Where("status = 1 and user_org_id = ? and deposit_status = 1 ", orgid).Where("ctime >= ? and ctime <= ?", stime, etime)
137
+	if len(keyword) > 0 {
138
+		var tmp string = "deposit_code like ?"
139
+		if len(slicekey) > 0 {
140
+			for i := 0; i < len(slicekey); i++ {
141
+				tmp = tmp + " or his_patient_id = " + strconv.FormatInt(slicekey[i], 10)
142
+			}
143
+		}
144
+		keyword = "%" + keyword + "%"
145
+		db = db.Where(tmp, keyword)
146
+	}
147
+	err = db.Order("ctime desc").Find(&deposithistory).Error
148
+	return
149
+}
150
+
151
+//充值汇总列表
152
+func SummaryList(orgid, stime, etime int64, keyword string, slicekey []int64) (deposithistory []models.DepositHistory, err error) {
153
+	db := XTReadDB().Model(&models.DepositHistory{}).Where("status = 1 and trial_status = 1 and user_org_id = ? and deposit_status = 1 ", orgid).Where("ctime >= ? and ctime <= ?", stime, etime)
154
+	if len(slicekey) > 0 {
155
+		tmp := ""
156
+		for i := 0; i < len(slicekey); i++ {
157
+			tmp = tmp + " his_patient_id = " + strconv.FormatInt(slicekey[i], 10)
158
+			if i < len(slicekey)-1 {
159
+				tmp = tmp + " or "
160
+			}
161
+		}
162
+		db = db.Where(tmp)
163
+	} else {
164
+		if len(keyword) > 0 {
165
+			return
166
+		}
167
+	}
168
+	err = db.Order("ctime desc").Find(&deposithistory).Error
169
+	return
170
+}
171
+
172
+//获取本周周一和周日的起止时间戳
173
+func GetMondayOfWeek() (int64, int64) {
174
+	t := time.Now()
175
+	dayObj := GetZeroTime(t)
176
+	var dayStr string
177
+	loc, _ := time.LoadLocation("Local")
178
+	if t.Weekday() == time.Monday {
179
+		dayStr = dayObj.Format("2006-01-02")
180
+	} else {
181
+		offset := int(time.Monday - t.Weekday())
182
+		if offset > 0 {
183
+			offset = -6
184
+		}
185
+		dayStr = dayObj.AddDate(0, 0, offset).Format("2006-01-02")
186
+	}
187
+	dayStr = dayStr + " 00:00:00"
188
+	stime, _ := time.ParseInLocation("2006-01-02 15:04:05", dayStr, loc)
189
+	return stime.Unix(), stime.Unix() + 604799
190
+}
191
+
192
+//获取本月的起止时间戳
193
+func GetMonth() (int64, int64) {
194
+	timeNow := time.Now()
195
+	timeToday := time.Date(timeNow.Year(), timeNow.Month(), timeNow.Day(), 0, 0, 0, 0, timeNow.Location()) // 获取当天0点时间 time类型
196
+	timeMonthStartUnix1 := timeToday.AddDate(0, 0, -timeToday.Day()+1).Unix()                              // 获取本月第一天0点 时间戳类型
197
+	timeMonthEndUnix1 := timeToday.AddDate(0, 1, -timeToday.Day()+1).Unix() - 1                            // 获取下个月第一天/ 本月最后一天24点 时间戳类型
198
+	return timeMonthStartUnix1, timeMonthEndUnix1
199
+}
200
+func GetCreateidName(id int64) string {
201
+	var tmp models.CreateUser
202
+	XTReadDB().Select("name").Where("id = ?", id).Find(&tmp)
203
+	return tmp.Name
204
+}
205
+
206
+//审核通过
207
+func UpDecimalHistory(id int64) (err error) {
208
+	//开事务
209
+	tx := XTWriteDB().Begin()
210
+	defer func() {
211
+		if err != nil {
212
+			utils.ErrorLog("事务失败,原因为", err)
213
+			tx.Rollback()
214
+		} else {
215
+			tx.Commit()
216
+		}
217
+	}()
218
+	//改状态
219
+	err = tx.Model(models.DepositHistory{}).Where("id = ?", id).Updates(map[string]interface{}{
220
+		"trial_status": 1,
221
+		"mtime":        time.Now().Unix(),
222
+	}).Error
223
+	if err != nil {
224
+		return
225
+	}
226
+	//查记录x2
227
+	var history models.DepositHistory
228
+	var detmp models.Deposit
229
+	err = tx.Model(&models.DepositHistory{}).Where("id = ?", id).Find(&history).Error
230
+	if err != nil {
231
+		return
232
+	}
233
+	err = tx.Model(&models.Deposit{}).Where("user_org_id = ? and his_patient_id = ? and status = 1 ", history.UserOrgId, history.HisPatientId).Find(&detmp).Error
234
+	if err != nil {
235
+		return
236
+	}
237
+	//相加
238
+	err = tx.Model(&models.Deposit{}).Where("id = ? and status = 1", detmp.ID).Updates(map[string]interface{}{
239
+		"mtime":   time.Now().Unix(),
240
+		"deposit": detmp.Deposit.Add(history.Deposit),
241
+	}).Error
242
+
243
+	return
244
+}
245
+
246
+//删除本次记录
247
+func DelDecimalHistory(id int64) (err error) {
248
+	err = XTWriteDB().Model(models.DepositHistory{}).Where("id = ?", id).Updates(map[string]interface{}{
249
+		"status": 0,
250
+		"mtime":  time.Now().Unix(),
251
+	}).Error
252
+	return
253
+}
254
+
255
+//根据id获取一条押金历史记录
256
+func GetDecimalHistoryOne(id int64) (history models.DepositHistory, err error) {
257
+	err = XTReadDB().Model(&models.DepositHistory{}).Where("id = ?", id).Find(&history).Error
258
+	return
259
+}
260
+
261
+//根据患者id获取该患者当前剩余的押金
262
+func GetUserMoney(id, orgid int64) decimal.Decimal {
263
+	tmp := models.Deposit{}
264
+	XTReadDB().Model(&models.Deposit{}).Where("his_patient_id = ? and user_org_id = ? and status = 1", id, orgid).Find(&tmp)
265
+	return tmp.Deposit
266
+}
267
+
268
+//查询时间段内患者的余额
269
+func GetMoneyforTime(id, orgid, etime int64) decimal.Decimal {
270
+	tmp := models.DepositHistory{}
271
+	XTReadDB().Model(&models.DepositHistory{}).Where("his_patient_id = ? and user_org_id = ? and status = 1 and mtime <= ?", id, orgid, etime).Order("mtime").Find(&tmp)
272
+	return tmp.SurplusDeposit
273
+}
274
+
275
+//押金流水
276
+func GetFlowList(id, orgid, stime, etime, deposit_status int64) (deposit []models.DepositHistory, err error) {
277
+	s := "status = 1 and trial_status = 1 and user_org_id = ? and his_patient_id = ? and mtime >= ? and mtime <= ?"
278
+	if deposit_status != 0 {
279
+		s = s + " and deposit_status = " + string(deposit_status)
280
+	}
281
+	err = XTReadDB().Model(&models.DepositHistory{}).Where(s, orgid, id, stime, etime).Order("mtime desc").Find(&deposit).Error
282
+	return
283
+}
284
+
285
+func GetUserList(page, limit, orgid int64, keyword string, slicekey []int64) (m []models.Deposit1, total int64, err error) {
286
+	db := XTReadDB().Model(&models.Deposit{}).Where("status = 1 and user_org_id = ? ", orgid)
287
+	offset := (page - 1) * limit
288
+	if len(slicekey) > 0 {
289
+		tmp := ""
290
+		for i := 0; i < len(slicekey); i++ {
291
+			tmp = tmp + " his_patient_id = " + strconv.FormatInt(slicekey[i], 10)
292
+			if i < len(slicekey)-1 {
293
+				tmp = tmp + " or "
294
+			}
295
+		}
296
+		db = db.Where(tmp)
297
+	} else {
298
+		if len(keyword) > 0 {
299
+			return
300
+		}
301
+	}
302
+	err = db.Count(&total).Offset(offset).Order("mtime desc").Find(&m).Error
303
+	return
304
+}

+ 5 - 1
service/his_service.go View File

734
 	DrugDay                     string  `gorm:"column:drug_day" json:"drug_day" form:"drug_day"`
734
 	DrugDay                     string  `gorm:"column:drug_day" json:"drug_day" form:"drug_day"`
735
 	Total                       float64 `gorm:"column:total" json:"total" form:"total"`
735
 	Total                       float64 `gorm:"column:total" json:"total" form:"total"`
736
 	PrescribingNumberUnit       string  `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
736
 	PrescribingNumberUnit       string  `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
737
-
737
+	BatchRetaiPrice             float64 `gorm:"column:batch_retai_price" json:"batch_retai_price" form:"batch_retai_price"`
738
+	SumCount                    int64   `gorm:"column:sum_count" json:"sum_count" form:"sum_count"`
739
+	SumInCount                  int64   `gorm:"column:sum_in_count" json:"sum_in_count" form:"sum_in_count"`
738
 	//MedicineInsurancePercentage []*MedicineInsurancePercentage `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"monitoring_record"`
740
 	//MedicineInsurancePercentage []*MedicineInsurancePercentage `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"monitoring_record"`
739
 	OtherDrugWarehouseInfo []*OtherDrugWarehouseInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"stock_in"`
741
 	OtherDrugWarehouseInfo []*OtherDrugWarehouseInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"stock_in"`
740
 	VMDrugSalesReturnInfo  []*VMDrugSalesReturnInfo  `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"sales_return"`
742
 	VMDrugSalesReturnInfo  []*VMDrugSalesReturnInfo  `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"sales_return"`
750
 	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 {
752
 	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 {
751
 		return db.Where("(status = 1 and stock_max_number > 0)  or  (status = 1  AND stock_min_number >0)")
753
 		return db.Where("(status = 1 and stock_max_number > 0)  or  (status = 1  AND stock_min_number >0)")
752
 	}).Find(&list).Error
754
 	}).Find(&list).Error
755
+
756
+	//err = readDb.Model(&BaseDrugLib{}).Where("org_id = ?  AND status = 1 AND  find_in_set('停用',drug_status) = 0", org_id).Find(&list).Error
753
 	return
757
 	return
754
 }
758
 }
755
 
759
 

+ 1 - 1
service/manage_center_service.go View File

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
 

+ 2 - 1
service/mobile_dialysis_service.go View File

164
 	Name               string `gorm:"column:name" json:"name" form:"name"`
164
 	Name               string `gorm:"column:name" json:"name" form:"name"`
165
 	IdCardNo           string `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
165
 	IdCardNo           string `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
166
 	UserSysBeforeCount int64  `gorm:"column:user_sys_before_count" json:"user_sys_before_count" form:"user_sys_before_count"`
166
 	UserSysBeforeCount int64  `gorm:"column:user_sys_before_count" json:"user_sys_before_count" form:"user_sys_before_count"`
167
+	TrobleShoot        int64  `gorm:"column:troble_shoot" json:"troble_shoot" form:"troble_shoot"`
167
 }
168
 }
168
 
169
 
169
 func (MSchedualPatientVMList) TableName() string {
170
 func (MSchedualPatientVMList) TableName() string {
2770
 
2771
 
2771
 	err = readDb.Model(&AutomaticReduceDetail{}).Where("patient_id = ? AND org_id = ? AND status=1 AND record_time < ? AND count > 0", patient_id, orgID, record_time).Select("record_time").Group("record_time").Order("record_time asc").Scan(&Id).Error
2772
 	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 {
2773
 	if len(Id) > 0 {
2773
-		fmt.Println("ids232323223322233233233322332", Id)
2774
+
2774
 		err = readDb.Model(&AutomaticReduceDetail{}).Where("patient_id = ? AND org_id = ? AND status=1 AND record_time = ? AND count > 0", patient_id, orgID, Id[len(Id)-1].RecordTime).Preload("VMGoodInfo", "status = 1 AND org_id = ? ", orgID).Preload("GoodsType", "status = 1 AND (org_id = ? OR org_id = 0)  ", orgID).Find(&goodUser).Error
2775
 		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
 	}
2776
 	}
2776
 	return
2777
 	return

+ 1 - 1
service/patient_service.go View File

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
 

+ 19 - 0
service/role_service.go View File

485
 	return purviewVMs, nil
485
 	return purviewVMs, nil
486
 }
486
 }
487
 
487
 
488
+//用来处理树形结构
489
+func Totree(map1 map[int64]int64, map2 map[int64]*PurviewTreeViewModel, tmp int64) []*PurviewTreeViewModel {
490
+	var j int //用来计数
491
+	var tmp_purview []*PurviewTreeViewModel
492
+	for k, v := range map1 {
493
+		if v == tmp {
494
+			tmp_purview = append(tmp_purview, map2[k])
495
+			delete(map1, k)
496
+			for k1, v1 := range tmp_purview {
497
+				if k1 == j {
498
+					v1.Childs = Totree(map1, map2, k)
499
+				}
500
+			}
501
+			j++
502
+		}
503
+	}
504
+	return tmp_purview
505
+}
506
+
488
 func GetAllGeneralFuncPurviewVMsProcessed() ([]*PurviewTreeViewModel, error) {
507
 func GetAllGeneralFuncPurviewVMsProcessed() ([]*PurviewTreeViewModel, error) {
489
 	var originPurviews []*models.SgjUserOperatePurview
508
 	var originPurviews []*models.SgjUserOperatePurview
490
 	getPurviewErr := readUserDb.Model(models.SgjUserOperatePurview{}).Where(" status = 1").Order("number asc").Find(&originPurviews).Error
509
 	getPurviewErr := readUserDb.Model(models.SgjUserOperatePurview{}).Where(" status = 1").Order("number asc").Find(&originPurviews).Error

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


+ 19 - 10
service/self_drug_service.go View File

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
 
1000
 	if endtime > 0 {
1006
 	if endtime > 0 {
1001
 		db = db.Where("x.start_time<=?", endtime)
1007
 		db = db.Where("x.start_time<=?", endtime)
1002
 	}
1008
 	}
1003
-	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.min_count,x.min_unit,t.dose,t.dose_unit,t.max_unit,t.min_unit").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).Order("x.ctime desc").Scan(&list).Error
1009
+	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.min_count,x.min_unit,t.dose,t.dose_unit,t.max_unit,t.min_unit").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).Order("x.id desc").Offset(offset).Limit(limit).Order("x.ctime desc").Scan(&list).Error
1004
 	return list, total, err
1010
 	return list, total, err
1005
 }
1011
 }
1006
 
1012
 
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
1114
+	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).Order("x.ctime desc").Offset(offset).Limit(limit).Scan(&list).Error
1106
 	return list, total, err
1115
 	return list, total, err
1107
 }
1116
 }
1108
 
1117
 

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


+ 35 - 7
service/supply_service.go View File

760
 	return err
760
 	return err
761
 }
761
 }
762
 
762
 
763
+func GetSupplySupplyWarehouseId(id int64, orgid int64) (models.WarehousingInfo, error) {
764
+	info := models.WarehousingInfo{}
765
+	err := XTReadDB().Where("supply_warehouse_id = ? and org_id = ? and status = 1", id, orgid).Find(&info).Error
766
+	return info, err
767
+}
768
+
769
+func GetSupplySupplyWarehouseIdSeven(id int64, orgid int64) (info []*models.WarehousingInfo, err error) {
770
+
771
+	err = XTReadDB().Where("supply_warehouse_id = ? and org_id = ? and status = 1", id, orgid).Find(&info).Error
772
+	return info, err
773
+}
774
+
775
+func GetDrugSupplyWarehouseId(id int64, orgid int64) (models.DrugWarehouseInfo, error) {
776
+	info := models.DrugWarehouseInfo{}
777
+	err := XTReadDB().Where("supply_warehouse_id = ? and org_id = ? and status = 1", id, orgid).Find(&info).Error
778
+	return info, err
779
+}
780
+
781
+func GetDrugSupplyWarehouseIdSeven(id int64, orgid int64) (info []*models.DrugWarehouseInfo, err error) {
782
+
783
+	err = XTReadDB().Where("supply_warehouse_id = ? and org_id = ? and status = 1", id, orgid).Find(&info).Error
784
+	return info, err
785
+}
786
+
763
 func UpdateDrugSupplyWarehousingInfo(id int64, orgid int64) error {
787
 func UpdateDrugSupplyWarehousingInfo(id int64, orgid int64) error {
764
 
788
 
765
 	err := XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("supply_warehouse_id = ? and org_id = ? and status = 1", id, orgid).Updates(map[string]interface{}{"status": 0}).Error
789
 	err := XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("supply_warehouse_id = ? and org_id = ? and status = 1", id, orgid).Updates(map[string]interface{}{"status": 0}).Error
843
 	if len(drugflow) > 0 {
867
 	if len(drugflow) > 0 {
844
 		utx := writeDb.Begin()
868
 		utx := writeDb.Begin()
845
 		if len(drugflow) > 0 {
869
 		if len(drugflow) > 0 {
846
-			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 "
870
+			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 "
847
 			insertParams := make([]string, 0)
871
 			insertParams := make([]string, 0)
848
 			insertData := make([]interface{}, 0)
872
 			insertData := make([]interface{}, 0)
849
 			for _, info := range drugflow {
873
 			for _, info := range drugflow {
850
 
874
 
851
-				insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
875
+				insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
852
 				insertData = append(insertData, info.WarehousingId)
876
 				insertData = append(insertData, info.WarehousingId)
853
 				insertData = append(insertData, info.DrugId)
877
 				insertData = append(insertData, info.DrugId)
854
 				insertData = append(insertData, info.Number)
878
 				insertData = append(insertData, info.Number)
883
 				insertData = append(insertData, info.MinUnit)
907
 				insertData = append(insertData, info.MinUnit)
884
 				insertData = append(insertData, info.SupplyWarehouseId)
908
 				insertData = append(insertData, info.SupplyWarehouseId)
885
 				insertData = append(insertData, info.SupplyWarehouseDetailInfo)
909
 				insertData = append(insertData, info.SupplyWarehouseDetailInfo)
910
+				insertData = append(insertData, info.StorehouseId)
886
 			}
911
 			}
887
 			thisSQL += strings.Join(insertParams, ", ")
912
 			thisSQL += strings.Join(insertParams, ", ")
888
 			err = utx.Exec(thisSQL, insertData...).Error
913
 			err = utx.Exec(thisSQL, insertData...).Error
1028
 	return err
1053
 	return err
1029
 }
1054
 }
1030
 
1055
 
1031
-func FindWarehousingInfoTwenTy(goodId int64, supply_warehouse_detail_info int64, source int64) (models.WarehousingInfo, error) {
1032
-	fmt.Println("source232232332232323232323", source)
1056
+func FindWarehousingInfoTwenTy(goodId int64, supply_warehouse_detail_info int64, source int64, storehouse_id int64) (models.WarehousingInfo, error) {
1057
+
1033
 	info := models.WarehousingInfo{}
1058
 	info := models.WarehousingInfo{}
1034
 	var err error
1059
 	var err error
1035
 	if source == 1 {
1060
 	if source == 1 {
1036
-		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
1061
+		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
1037
 
1062
 
1038
 	}
1063
 	}
1039
 	if source == 2 {
1064
 	if source == 2 {
1040
-		err = XTReadDB().Select(" good_id,sum(stock_count) as stock_count").Where("good_id = ? and status = 1", goodId).Find(&info).Error
1065
+		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
1041
 
1066
 
1042
 	}
1067
 	}
1043
 	return info, err
1068
 	return info, err
1044
 }
1069
 }
1045
 
1070
 
1046
-func GetDrugTotalCountTwenTy(drugid int64, supply_warehouse_detail_info int64, source int64) (list []*models.VmDrugWarehouseInfo, err error) {
1071
+func GetDrugTotalCountTwenTy(drugid int64, supply_warehouse_detail_info int64, source int64, storehouse_id int64) (list []*models.VmDrugWarehouseInfo, err error) {
1047
 
1072
 
1048
 	if source == 1 {
1073
 	if source == 1 {
1049
 		db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1")
1074
 		db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1")
1055
 		if supply_warehouse_detail_info > 0 {
1080
 		if supply_warehouse_detail_info > 0 {
1056
 			db = db.Where("x.supply_warehouse_detail_info = ?", supply_warehouse_detail_info)
1081
 			db = db.Where("x.supply_warehouse_detail_info = ?", supply_warehouse_detail_info)
1057
 		}
1082
 		}
1083
+		if storehouse_id > 0 {
1084
+			db = db.Where("x.storehouse_id= ?", storehouse_id)
1085
+		}
1058
 		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
1086
 		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
1059
 	}
1087
 	}
1060
 
1088
 

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