Selaa lähdekoodia

11月8日库存管理

XMLWAN 2 vuotta sitten
vanhempi
commit
1610085467
1 muutettua tiedostoa jossa 68 lisäystä ja 296 poistoa
  1. 68 296
      controllers/his_api_controller.go

+ 68 - 296
controllers/his_api_controller.go Näytä tiedosto

@@ -930,10 +930,9 @@ func (c *HisApiController) CreateHisPrescription() {
930 930
 						if len(advices) > 0 {
931 931
 							for _, advice := range advices {
932 932
 								var drug_id int64
933
-								//var prescribing_number float64
933
+								var prescribing_number float64
934 934
 								var prescribingNumberUnit string
935 935
 								var prescribingNumber string
936
-								var prescribing_number_one int64
937 936
 
938 937
 								var adviceId int64
939 938
 								if advice.(map[string]interface{})["id"] != nil || reflect.TypeOf(advice.(map[string]interface{})["id"]).String() == "float64" {
@@ -941,9 +940,8 @@ func (c *HisApiController) CreateHisPrescription() {
941 940
 								}
942 941
 								if advice.(map[string]interface{})["prescribing_number"] != nil || reflect.TypeOf(advice.(map[string]interface{})["prescribing_number"]).String() == "string" {
943 942
 									prescribing_number_str := advice.(map[string]interface{})["prescribing_number"].(string)
944
-									//prescribing_number, _ = strconv.ParseFloat(prescribing_number_str, 64)
943
+									prescribing_number, _ = strconv.ParseFloat(prescribing_number_str, 64)
945 944
 									prescribingNumber = advice.(map[string]interface{})["prescribing_number"].(string)
946
-									prescribing_number_one, _ = strconv.ParseInt(prescribing_number_str, 10, 64)
947 945
 								}
948 946
 
949 947
 								if advice.(map[string]interface{})["prescribing_number_unit"] != nil && reflect.TypeOf(advice.(map[string]interface{})["prescribing_number_unit"]).String() == "string" {
@@ -960,27 +958,27 @@ func (c *HisApiController) CreateHisPrescription() {
960 958
 									return
961 959
 								}
962 960
 								//查询药品的所有库存
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)
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)
969 967
 								//查询该药品是否存在开药记录
970 968
 								advicelist, _ := service.GetHisAdviceListByDrugIdEight(drug_id, patient_id, recordDateTime, adviceId)
971 969
 
972 970
 								//新增处方
973 971
 								if advicelist.ID == 0 {
974
-									//	all_count, _ := strconv.ParseFloat(totals, 64)
972
+									all_count, _ := strconv.ParseFloat(totals, 64)
975 973
 									if prescribingNumberUnit == drug.MinUnit {
976
-										if prescribing_number_one > drug.SumCount {
974
+										if prescribing_number > all_count {
977 975
 											c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
978 976
 											return
979 977
 										}
980 978
 									} else {
981 979
 										if prescribingNumberUnit == drug.MaxUnit {
982
-											num := prescribing_number_one * drug.MinNumber
983
-											if num > drug.SumCount {
980
+											num := prescribing_number * float64(drug.MinNumber)
981
+											if num > all_count {
984 982
 												c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
985 983
 												return
986 984
 											}
@@ -1015,7 +1013,7 @@ func (c *HisApiController) CreateHisPrescription() {
1015 1013
 									//如果修改的数量大于之前修改的数量
1016 1014
 									if (number_count - device_number) > 0 {
1017 1015
 										//如果修改的差数量 大于库存数量
1018
-										if (number_count - device_number) > drug.SumCount {
1016
+										if (number_count - device_number) > total_count {
1019 1017
 											c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
1020 1018
 											return
1021 1019
 										}
@@ -1030,24 +1028,6 @@ func (c *HisApiController) CreateHisPrescription() {
1030 1028
 										if druginfo.CountUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
1031 1029
 
1032 1030
 											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)
1051 1031
 										}
1052 1032
 										if druginfo.CountUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
1053 1033
 											var stock_max_number int64
@@ -1056,71 +1036,18 @@ func (c *HisApiController) CreateHisPrescription() {
1056 1036
 											if number_count >= drug.MinNumber {
1057 1037
 
1058 1038
 												stock_max_number = device_number / drug.MinNumber
1059
-
1060 1039
 												service.ModefyDrugByWarehouseInfo(druginfo.WarehouseInfoId, stock_max_number)
1061
-
1062 1040
 												stock_min_number = device_number % drug.MinNumber
1063 1041
 												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)
1081 1042
 
1082 1043
 											} else {
1083 1044
 
1084 1045
 												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)
1102 1046
 											}
1103 1047
 										}
1104 1048
 
1105 1049
 										if druginfo.CountUnit == drug.MaxUnit && druginfo.CountUnit == drug.MinUnit && drug.MaxUnit == drug.MinUnit {
1106 1050
 											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)
1124 1051
 										}
1125 1052
 										//删除记录
1126 1053
 										service.DeleteDrugAutoWarehouseSeven(drug_id, patient_id, recordDateTime, adviceId)
@@ -1150,7 +1077,7 @@ func (c *HisApiController) CreateHisPrescription() {
1150 1077
 
1151 1078
 								var project_id int64
1152 1079
 								var project_type int64
1153
-								//var totals float64
1080
+								var totals float64
1154 1081
 								var project_name string
1155 1082
 								var parsetotal int64
1156 1083
 								var id int64
@@ -1166,7 +1093,7 @@ func (c *HisApiController) CreateHisPrescription() {
1166 1093
 								}
1167 1094
 								if project.(map[string]interface{})["total"] != nil || reflect.TypeOf(project.(map[string]interface{})["total"]).String() == "string" {
1168 1095
 									total, _ := project.(map[string]interface{})["total"].(string)
1169
-									//	totals, _ = strconv.ParseFloat(total, 64)
1096
+									totals, _ = strconv.ParseFloat(total, 64)
1170 1097
 									parsetotal, _ = strconv.ParseInt(total, 10, 64)
1171 1098
 								}
1172 1099
 
@@ -1185,21 +1112,14 @@ func (c *HisApiController) CreateHisPrescription() {
1185 1112
 
1186 1113
 									if len(goodWarehouseInfo) == 0 {
1187 1114
 										//查询耗材库存
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
-										fmt.Println("parsetotal3232323223233232232323233", parsetotal, good.SumCount)
1202
-										if parsetotal > good.SumCount {
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 {
1203 1123
 											c.ServeDynamicFailJsonSend(project_name + "库存不足")
1204 1124
 											return
1205 1125
 										}
@@ -1209,16 +1129,6 @@ func (c *HisApiController) CreateHisPrescription() {
1209 1129
 										for _, item := range goodList {
1210 1130
 											//回退库存
1211 1131
 											service.ModefyWarehouseInfo(item.Count, item.WarehouseInfotId)
1212
-											//查询默认仓库
1213
-											houseConfig, _ := service.GetAllStoreHouseConfig(item.GoodId)
1214
-											goodList, _ := service.GetGoodSumCountByStoreId(houseConfig.StorehouseOutInfo, item.ProjectId, item.OrgId)
1215
-											var sum_count int64
1216
-											var sum_in_count int64
1217
-											for _, it := range goodList {
1218
-												sum_count += it.StockCount
1219
-												sum_in_count += it.WarehousingCount
1220
-											}
1221
-											service.UpdateGoodByGoodId(item.GoodId, sum_count, sum_in_count, item.OrgId)
1222 1132
 										}
1223 1133
 										//删除记录
1224 1134
 										service.DeleteAutoWarehouse(patient_id, recordDateTime)
@@ -1237,16 +1147,6 @@ func (c *HisApiController) CreateHisPrescription() {
1237 1147
 											for _, item := range goodList {
1238 1148
 												//回退库存
1239 1149
 												service.ModefyWarehouseInfo(item.Count, item.WarehouseInfotId)
1240
-												//查询默认仓库
1241
-												houseConfig, _ := service.GetAllStoreHouseConfig(item.GoodId)
1242
-												goodList, _ := service.GetGoodSumCountByStoreId(houseConfig.StorehouseOutInfo, item.ProjectId, item.OrgId)
1243
-												var sum_count int64
1244
-												var sum_in_count int64
1245
-												for _, it := range goodList {
1246
-													sum_count += it.StockCount
1247
-													sum_in_count += it.WarehousingCount
1248
-												}
1249
-												service.UpdateGoodByGoodId(item.GoodId, sum_count, sum_in_count, item.OrgId)
1250 1150
 											}
1251 1151
 											//删除记录
1252 1152
 											service.DeleteAutoWarehouse(patient_id, recordDateTime)
@@ -1951,7 +1851,7 @@ func (c *HisApiController) DeletePrescription() {
1951 1851
 	_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
1952 1852
 
1953 1853
 	_, stockConfig := service.FindAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
1954
-	houseConfig, _ := service.GetAllStoreHouseConfig(c.GetAdminUserInfo().CurrentOrgId)
1854
+
1955 1855
 	if len(projects) > 0 {
1956 1856
 		for _, item := range projects {
1957 1857
 			service.DeletePrintInfo(item.ID) //删除打印信息
@@ -1971,15 +1871,14 @@ func (c *HisApiController) DeletePrescription() {
1971 1871
 					orderNumber := "CKTKD" + strconv.FormatInt(c.GetAdminUserInfo().CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
1972 1872
 
1973 1873
 					cancelStock := models.CancelStock{
1974
-						OrderNumber:  orderNumber,
1975
-						OperaTime:    operation_time,
1976
-						OrgId:        c.GetAdminUserInfo().CurrentOrgId,
1977
-						Creater:      creater,
1978
-						Ctime:        time.Now().Unix(),
1979
-						Status:       1,
1980
-						ReturnTime:   item.RecordDate,
1981
-						Type:         1,
1982
-						StorehouseId: houseConfig.StorehouseOutInfo,
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,
1983 1882
 					}
1984 1883
 					_, msgerrkonde := service.GetCancelStockDetailByOrderNumberOne(item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
1985 1884
 					if msgerrkonde == gorm.ErrRecordNotFound {
@@ -2015,7 +1914,6 @@ func (c *HisApiController) DeletePrescription() {
2015 1914
 							WarehouseInfoId: info.WarehouseInfotId,
2016 1915
 							PatientId:       info.PatientId,
2017 1916
 							RecordDate:      info.SysRecordTime,
2018
-							StorehouseId:    houseConfig.StorehouseOutInfo,
2019 1917
 						}
2020 1918
 
2021 1919
 						service.CreateCancelStockInfoOne(&cancelStockInfo)
@@ -2052,7 +1950,6 @@ func (c *HisApiController) DeletePrescription() {
2052 1950
 							CancelOutDetailId:       cancelInfo.ID,
2053 1951
 							ProductDate:             info.ProductDate,
2054 1952
 							ExpireDate:              info.ExpiryDate,
2055
-							StorehouseId:            houseConfig.StorehouseOutInfo,
2056 1953
 						}
2057 1954
 						service.CreateStockFlowOne(flow)
2058 1955
 
@@ -2070,7 +1967,7 @@ func (c *HisApiController) DeletePrescription() {
2070 1967
 						}
2071 1968
 						//回退库存
2072 1969
 						service.UpDateWarehouseInfoByStockDelete(info.WarehouseInfotId, total_count)
2073
-						service.ModifyGoodAddInformation(info.GoodId, total_count, info.OrgId)
1970
+
2074 1971
 						//查询今日该耗材退库数量
2075 1972
 						cancelInfoOne, _ := service.GetCancelStockInfoByPatientId(info.PatientId, item.ProjectId, info.SysRecordTime)
2076 1973
 						var cancel_Count int64
@@ -2105,7 +2002,6 @@ func (c *HisApiController) DeletePrescription() {
2105 2002
 									Manufacturer:            0,
2106 2003
 									Type:                    1,
2107 2004
 									IsSys:                   1,
2108
-									StorehouseId:            houseConfig.StorehouseOutInfo,
2109 2005
 								}
2110 2006
 								err := service.AddSigleWarehouseOut(&warehouseOut)
2111 2007
 								if err != nil {
@@ -2113,49 +2009,27 @@ func (c *HisApiController) DeletePrescription() {
2113 2009
 									return
2114 2010
 								}
2115 2011
 								prepare := &models.DialysisBeforePrepare{
2116
-									UserOrgId:    c.GetAdminUserInfo().CurrentOrgId,
2117
-									PatientId:    info.PatientId,
2118
-									RecordDate:   info.SysRecordTime,
2119
-									GoodId:       item.ProjectId,
2120
-									GoodTypeId:   info.GoodTypeId,
2121
-									Count:        cha_count,
2122
-									StorehouseId: houseConfig.StorehouseOutInfo,
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,
2123 2018
 								}
2124 2019
 								//出库
2125 2020
 								service.ConsumablesDelivery(c.GetAdminUserInfo().CurrentOrgId, info.PatientId, info.SysRecordTime, prepare, &warehouseOut, cha_count)
2126
-								//查询默认仓库
2127
-								houseConfig, _ := service.GetAllStoreHouseConfig(c.GetAdminUserInfo().CurrentOrgId)
2128
-								goodList, _ := service.GetGoodSumCountByStoreId(houseConfig.StorehouseOutInfo, item.ProjectId, item.UserOrgId)
2129
-								var sum_count int64
2130
-								var sum_in_count int64
2131
-								for _, it := range goodList {
2132
-									sum_count += it.StockCount
2133
-									sum_in_count += it.WarehousingCount
2134
-								}
2135
-								service.UpdateGoodByGoodId(item.ProjectId, sum_count, sum_in_count, item.UserOrgId)
2136 2021
 							} else if err == nil {
2137 2022
 
2138 2023
 								prepare := &models.DialysisBeforePrepare{
2139
-									UserOrgId:    c.GetAdminUserInfo().CurrentOrgId,
2140
-									PatientId:    info.PatientId,
2141
-									RecordDate:   info.SysRecordTime,
2142
-									GoodId:       item.ProjectId,
2143
-									GoodTypeId:   info.GoodTypeId,
2144
-									Count:        cha_count,
2145
-									StorehouseId: houseConfig.StorehouseOutInfo,
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,
2146 2030
 								}
2147 2031
 								//出库
2148 2032
 								service.ConsumablesDelivery(c.GetAdminUserInfo().CurrentOrgId, info.PatientId, info.SysRecordTime, prepare, &out, cha_count)
2149
-								//查询默认仓库
2150
-								houseConfig, _ := service.GetAllStoreHouseConfig(c.GetAdminUserInfo().CurrentOrgId)
2151
-								goodList, _ := service.GetGoodSumCountByStoreId(houseConfig.StorehouseOutInfo, item.ProjectId, item.UserOrgId)
2152
-								var sum_count int64
2153
-								var sum_in_count int64
2154
-								for _, it := range goodList {
2155
-									sum_count += it.StockCount
2156
-									sum_in_count += it.WarehousingCount
2157
-								}
2158
-								service.UpdateGoodByGoodId(item.ProjectId, sum_count, sum_in_count, item.UserOrgId)
2159 2033
 							}
2160 2034
 
2161 2035
 						}
@@ -2225,7 +2099,6 @@ func (c *HisApiController) DeletePrescription() {
2225 2099
 							Dealer:       info.Dealer,
2226 2100
 							Manufacturer: info.Manufacturer,
2227 2101
 							Type:         1,
2228
-							StorehouseId: houseConfig.DrugStorehouseOut,
2229 2102
 						}
2230 2103
 						service.AddSigleDrugCancelStock(&cancelStock)
2231 2104
 
@@ -2254,7 +2127,6 @@ func (c *HisApiController) DeletePrescription() {
2254 2127
 							ProductDate:      info.ProductDate,
2255 2128
 							ExpiryDate:       info.ExpiryDate,
2256 2129
 							BatchNumberId:    info.WarehouseInfoId,
2257
-							StorehouseId:     houseConfig.DrugStorehouseOut,
2258 2130
 						}
2259 2131
 
2260 2132
 						flow := models.DrugFlow{
@@ -2290,7 +2162,6 @@ func (c *HisApiController) DeletePrescription() {
2290 2162
 							MaxUnit:                 info.CountUnit,
2291 2163
 							MinUnit:                 "",
2292 2164
 							AdviceId:                info.AdviceId,
2293
-							StorehouseId:            houseConfig.DrugStorehouseOut,
2294 2165
 						}
2295 2166
 						service.CreatedCancelStock(cancelStockInfo)
2296 2167
 						service.CreateDrugFlowOne(flow)
@@ -2299,24 +2170,6 @@ func (c *HisApiController) DeletePrescription() {
2299 2170
 						service.UpdateDrugFlowSeven(info.PatientId, info.SysRecordTime, info.DrugId, item.ID)
2300 2171
 						//删除流水
2301 2172
 						service.UpdateDrugFlowTens(info.PatientId, info.WarehouseOutOrderNumber, info.DrugId, item.ID)
2302
-
2303
-						//查询默认仓库
2304
-						houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
2305
-						//查询默认仓库剩余多少库存
2306
-						list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
2307
-						var sum_count int64
2308
-						var sum_in_count int64
2309
-						for _, it := range list {
2310
-							baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
2311
-							if it.MaxUnit == baseDrug.MaxUnit {
2312
-								it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
2313
-								it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
2314
-
2315
-							}
2316
-							sum_count += it.StockMaxNumber + it.StockMinNumber
2317
-							sum_in_count += it.WarehousingCount
2318
-						}
2319
-						service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
2320 2173
 					} else {
2321 2174
 						floatPrescrip := strconv.FormatFloat(item.PrescribingNumber, 'f', -1, 32)
2322 2175
 
@@ -2325,7 +2178,6 @@ func (c *HisApiController) DeletePrescription() {
2325 2178
 						if item.PrescribingNumberUnit == drug.MaxUnit {
2326 2179
 							warehouseInfo := models.DrugWarehouseInfo{
2327 2180
 								StockMaxNumber: prescribingNumber,
2328
-								StorehouseId:   houseConfig.DrugStorehouseOut,
2329 2181
 							}
2330 2182
 							service.UpdateDrugWarehouseOne(info.WarehouseInfoId, warehouseInfo)
2331 2183
 
@@ -2353,7 +2205,6 @@ func (c *HisApiController) DeletePrescription() {
2353 2205
 							Dealer:       info.Dealer,
2354 2206
 							Manufacturer: info.Manufacturer,
2355 2207
 							Type:         1,
2356
-							StorehouseId: houseConfig.DrugStorehouseOut,
2357 2208
 						}
2358 2209
 						service.AddSigleDrugCancelStock(&cancelStock)
2359 2210
 
@@ -2383,7 +2234,6 @@ func (c *HisApiController) DeletePrescription() {
2383 2234
 							ProductDate:      info.ProductDate,
2384 2235
 							ExpiryDate:       info.ExpiryDate,
2385 2236
 							BatchNumberId:    info.WarehouseInfoId,
2386
-							StorehouseId:     houseConfig.DrugStorehouseOut,
2387 2237
 						}
2388 2238
 
2389 2239
 						flow := models.DrugFlow{
@@ -2420,7 +2270,6 @@ func (c *HisApiController) DeletePrescription() {
2420 2270
 							MaxUnit:                 info.CountUnit,
2421 2271
 							MinUnit:                 "",
2422 2272
 							AdviceId:                info.AdviceId,
2423
-							StorehouseId:            houseConfig.DrugStorehouseOut,
2424 2273
 						}
2425 2274
 						service.CreatedCancelStock(cancelStockInfo)
2426 2275
 						service.CreateDrugFlowOne(flow)
@@ -2429,23 +2278,6 @@ func (c *HisApiController) DeletePrescription() {
2429 2278
 						//删除流水
2430 2279
 						service.UpdateDrugFlowTens(info.PatientId, info.WarehouseOutOrderNumber, info.DrugId, item.ID)
2431 2280
 
2432
-						//查询默认仓库
2433
-						houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
2434
-						//查询默认仓库剩余多少库存
2435
-						list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
2436
-						var sum_count int64
2437
-						var sum_in_count int64
2438
-						for _, it := range list {
2439
-							baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
2440
-							if it.MaxUnit == baseDrug.MaxUnit {
2441
-								it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
2442
-								it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
2443
-
2444
-							}
2445
-							sum_count += it.StockMaxNumber + it.StockMinNumber
2446
-							sum_in_count += it.WarehousingCount
2447
-						}
2448
-						service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
2449 2281
 					}
2450 2282
 				}
2451 2283
 
@@ -2488,7 +2320,7 @@ func (c *HisApiController) DeleteDoctorAdvice() {
2488 2320
 		if drugStockConfig.IsOpen == 1 {
2489 2321
 			//判断该医嘱是否执行了
2490 2322
 			if advice.ExecutionState == 1 {
2491
-				houseConfig, _ := service.GetAllStoreHouseConfig(advice.UserOrgId)
2323
+
2492 2324
 				//查询该病人该药品是否有库存记录
2493 2325
 				info, errcode := service.GetDrugAutoWarehouseOutSeven(advice.PatientId, advice.AdviceDate, advice.DrugId, advice.ID)
2494 2326
 				if errcode == gorm.ErrRecordNotFound {
@@ -2530,7 +2362,6 @@ func (c *HisApiController) DeleteDoctorAdvice() {
2530 2362
 							Dealer:       info.Dealer,
2531 2363
 							Manufacturer: info.Manufacturer,
2532 2364
 							Type:         1,
2533
-							StorehouseId: houseConfig.DrugStorehouseOut,
2534 2365
 						}
2535 2366
 						service.AddSigleDrugCancelStock(&cancelStock)
2536 2367
 
@@ -2559,7 +2390,6 @@ func (c *HisApiController) DeleteDoctorAdvice() {
2559 2390
 							ProductDate:      info.ProductDate,
2560 2391
 							ExpiryDate:       info.ExpiryDate,
2561 2392
 							BatchNumberId:    info.WarehouseInfoId,
2562
-							StorehouseId:     houseConfig.DrugStorehouseOut,
2563 2393
 						}
2564 2394
 
2565 2395
 						flow := models.DrugFlow{
@@ -2595,7 +2425,6 @@ func (c *HisApiController) DeleteDoctorAdvice() {
2595 2425
 							MaxUnit:                 info.CountUnit,
2596 2426
 							MinUnit:                 "",
2597 2427
 							AdviceId:                info.AdviceId,
2598
-							StorehouseId:            houseConfig.DrugStorehouseOut,
2599 2428
 						}
2600 2429
 						service.CreatedCancelStock(cancelStockInfo)
2601 2430
 						service.CreateDrugFlowOne(flow)
@@ -2604,24 +2433,6 @@ func (c *HisApiController) DeleteDoctorAdvice() {
2604 2433
 						service.UpdateDrugFlowSeven(info.PatientId, info.SysRecordTime, info.DrugId, advice.ID)
2605 2434
 						//删除流水
2606 2435
 						service.UpdateDrugFlowTens(info.PatientId, info.WarehouseOutOrderNumber, info.DrugId, advice.ID)
2607
-
2608
-						//查询默认仓库
2609
-						houseConfig, _ := service.GetAllStoreHouseConfig(info.OrgId)
2610
-						//查询默认仓库剩余多少库存
2611
-						list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, info.OrgId, info.DrugId)
2612
-						var sum_count int64
2613
-						var sum_in_count int64
2614
-						for _, it := range list {
2615
-							baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
2616
-							if it.MaxUnit == baseDrug.MaxUnit {
2617
-								it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
2618
-								it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
2619
-
2620
-							}
2621
-							sum_count += it.StockMaxNumber + it.StockMinNumber
2622
-							sum_in_count += it.WarehousingCount
2623
-						}
2624
-						service.UpdateMedicalSumCount(info.DrugId, sum_count, sum_in_count, info.OrgId)
2625 2436
 					} else {
2626 2437
 
2627 2438
 						floatPrescrip := strconv.FormatFloat(advice.PrescribingNumber, 'f', -1, 32)
@@ -2632,10 +2443,8 @@ func (c *HisApiController) DeleteDoctorAdvice() {
2632 2443
 							warehouseInfo := models.DrugWarehouseInfo{
2633 2444
 								StockMaxNumber: prescribingNumber,
2634 2445
 							}
2635
-							var sum_count int64
2636
-							sum_count = prescribingNumber * drug.MinNumber
2637 2446
 							service.UpdateDrugWarehouseOne(info.WarehouseInfoId, warehouseInfo)
2638
-							service.ModifyDrugAddInformation(info.DrugId, sum_count, info.OrgId)
2447
+
2639 2448
 						}
2640 2449
 
2641 2450
 						adminUserInfo := c.GetAdminUserInfo()
@@ -2660,7 +2469,6 @@ func (c *HisApiController) DeleteDoctorAdvice() {
2660 2469
 							Dealer:       info.Dealer,
2661 2470
 							Manufacturer: info.Manufacturer,
2662 2471
 							Type:         1,
2663
-							StorehouseId: houseConfig.DrugStorehouseOut,
2664 2472
 						}
2665 2473
 						service.AddSigleDrugCancelStock(&cancelStock)
2666 2474
 
@@ -2689,7 +2497,6 @@ func (c *HisApiController) DeleteDoctorAdvice() {
2689 2497
 							ProductDate:      info.ProductDate,
2690 2498
 							ExpiryDate:       info.ExpiryDate,
2691 2499
 							BatchNumberId:    info.WarehouseInfoId,
2692
-							StorehouseId:     houseConfig.DrugStorehouseOut,
2693 2500
 						}
2694 2501
 
2695 2502
 						flow := models.DrugFlow{
@@ -2725,7 +2532,6 @@ func (c *HisApiController) DeleteDoctorAdvice() {
2725 2532
 							MaxUnit:                 info.CountUnit,
2726 2533
 							MinUnit:                 "",
2727 2534
 							AdviceId:                info.AdviceId,
2728
-							StorehouseId:            houseConfig.DrugStorehouseOut,
2729 2535
 						}
2730 2536
 						service.CreatedCancelStock(cancelStockInfo)
2731 2537
 						service.CreateDrugFlowOne(flow)
@@ -2733,23 +2539,7 @@ func (c *HisApiController) DeleteDoctorAdvice() {
2733 2539
 						service.UpdateDrugFlowSeven(info.PatientId, info.SysRecordTime, info.DrugId, advice.ID)
2734 2540
 						//删除流水
2735 2541
 						service.UpdateDrugFlowTens(info.PatientId, info.WarehouseOutOrderNumber, info.DrugId, advice.ID)
2736
-						//查询默认仓库
2737
-						houseConfig, _ := service.GetAllStoreHouseConfig(info.OrgId)
2738
-						//查询默认仓库剩余多少库存
2739
-						list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, info.OrgId, info.DrugId)
2740
-						var sum_count int64
2741
-						var sum_in_count int64
2742
-						for _, it := range list {
2743
-							baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
2744
-							if it.MaxUnit == baseDrug.MaxUnit {
2745
-								it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
2746
-								it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
2747 2542
 
2748
-							}
2749
-							sum_count += it.StockMaxNumber + it.StockMinNumber
2750
-							sum_in_count += it.WarehousingCount
2751
-						}
2752
-						service.UpdateMedicalSumCount(info.DrugId, sum_count, sum_in_count, info.OrgId)
2753 2543
 					}
2754 2544
 				}
2755 2545
 			}
@@ -2786,7 +2576,6 @@ func (c *HisApiController) DeleteProject() {
2786 2576
 		if project.Type == 3 {
2787 2577
 			good, _ := service.FindGoodInfoByIdTwo(project.ProjectId)
2788 2578
 			f_count, _ := strconv.ParseFloat(project.Count, 64)
2789
-			houseConfig, _ := service.GetAllStoreHouseConfig(c.GetAdminUserInfo().CurrentOrgId)
2790 2579
 			good.Total = good.Total + f_count
2791 2580
 			service.UpdateGoodInfo(&good)
2792 2581
 
@@ -2800,15 +2589,14 @@ func (c *HisApiController) DeleteProject() {
2800 2589
 			orderNumber := "CKTKD" + strconv.FormatInt(adminInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
2801 2590
 
2802 2591
 			cancelStock := models.CancelStock{
2803
-				OrderNumber:  orderNumber,
2804
-				OperaTime:    operation_time,
2805
-				OrgId:        adminInfo.CurrentOrgId,
2806
-				Creater:      creater,
2807
-				Ctime:        time.Now().Unix(),
2808
-				Status:       1,
2809
-				ReturnTime:   project.RecordDate,
2810
-				Type:         1,
2811
-				StorehouseId: houseConfig.StorehouseOutInfo,
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,
2812 2600
 			}
2813 2601
 			_, msgerrkonde := service.GetCancelStockDetailByOrderNumberOne(project.RecordDate, adminInfo.CurrentOrgId)
2814 2602
 			if msgerrkonde == gorm.ErrRecordNotFound {
@@ -2845,7 +2633,6 @@ func (c *HisApiController) DeleteProject() {
2845 2633
 					WarehouseInfoId: info.WarehouseInfotId,
2846 2634
 					PatientId:       info.PatientId,
2847 2635
 					RecordDate:      info.SysRecordTime,
2848
-					StorehouseId:    houseConfig.StorehouseOutInfo,
2849 2636
 				}
2850 2637
 
2851 2638
 				service.CreateCancelStockInfoOne(&cancelStockInfo)
@@ -2882,7 +2669,6 @@ func (c *HisApiController) DeleteProject() {
2882 2669
 					CancelOutDetailId:       cancelInfo.ID,
2883 2670
 					ProductDate:             info.ProductDate,
2884 2671
 					ExpireDate:              info.ExpiryDate,
2885
-					StorehouseId:            houseConfig.StorehouseOutInfo,
2886 2672
 				}
2887 2673
 				service.CreateStockFlowOne(flow)
2888 2674
 
@@ -2900,16 +2686,7 @@ func (c *HisApiController) DeleteProject() {
2900 2686
 				}
2901 2687
 				//回退库存
2902 2688
 				service.UpDateWarehouseInfoByStockDelete(info.WarehouseInfotId, total_count)
2903
-				//查询默认仓库
2904
-				houseConfig, _ := service.GetAllStoreHouseConfig(project.UserOrgId)
2905
-				goodList, _ := service.GetGoodSumCountByStoreId(houseConfig.StorehouseOutInfo, project.ProjectId, project.UserOrgId)
2906
-				var sum_count int64
2907
-				var sum_in_count int64
2908
-				for _, it := range goodList {
2909
-					sum_count += it.StockCount
2910
-					sum_in_count += it.WarehousingCount
2911
-				}
2912
-				service.UpdateGoodByGoodId(project.ProjectId, sum_count, sum_in_count, project.UserOrgId)
2689
+
2913 2690
 				//查询今日该耗材退库数量
2914 2691
 				cancelInfoOne, _ := service.GetCancelStockInfoByPatientId(info.PatientId, project.ProjectId, info.SysRecordTime)
2915 2692
 				var cancel_count int64
@@ -2944,7 +2721,6 @@ func (c *HisApiController) DeleteProject() {
2944 2721
 							Manufacturer:            0,
2945 2722
 							Type:                    1,
2946 2723
 							IsSys:                   1,
2947
-							StorehouseId:            houseConfig.StorehouseOutInfo,
2948 2724
 						}
2949 2725
 						err := service.AddSigleWarehouseOut(&warehouseOut)
2950 2726
 						if err != nil {
@@ -2952,25 +2728,23 @@ func (c *HisApiController) DeleteProject() {
2952 2728
 							return
2953 2729
 						}
2954 2730
 						prepare := &models.DialysisBeforePrepare{
2955
-							UserOrgId:    adminInfo.CurrentOrgId,
2956
-							PatientId:    info.PatientId,
2957
-							RecordDate:   info.SysRecordTime,
2958
-							GoodId:       project.ProjectId,
2959
-							GoodTypeId:   info.GoodTypeId,
2960
-							Count:        cha_count,
2961
-							StorehouseId: houseConfig.StorehouseOutInfo,
2731
+							UserOrgId:  adminInfo.CurrentOrgId,
2732
+							PatientId:  info.PatientId,
2733
+							RecordDate: info.SysRecordTime,
2734
+							GoodId:     project.ProjectId,
2735
+							GoodTypeId: info.GoodTypeId,
2736
+							Count:      cha_count,
2962 2737
 						}
2963 2738
 						//出库
2964 2739
 						service.ConsumablesDelivery(adminInfo.CurrentOrgId, info.PatientId, info.SysRecordTime, prepare, &warehouseOut, cha_count)
2965 2740
 					} else if err == nil {
2966 2741
 						prepare := &models.DialysisBeforePrepare{
2967
-							UserOrgId:    adminInfo.CurrentOrgId,
2968
-							PatientId:    info.PatientId,
2969
-							RecordDate:   info.SysRecordTime,
2970
-							GoodId:       project.ProjectId,
2971
-							GoodTypeId:   info.GoodTypeId,
2972
-							Count:        cha_count,
2973
-							StorehouseId: houseConfig.StorehouseOutInfo,
2742
+							UserOrgId:  adminInfo.CurrentOrgId,
2743
+							PatientId:  info.PatientId,
2744
+							RecordDate: info.SysRecordTime,
2745
+							GoodId:     project.ProjectId,
2746
+							GoodTypeId: info.GoodTypeId,
2747
+							Count:      cha_count,
2974 2748
 						}
2975 2749
 						//出库
2976 2750
 						service.ConsumablesDelivery(adminInfo.CurrentOrgId, info.PatientId, info.SysRecordTime, prepare, &out, cha_count)
@@ -5784,7 +5558,6 @@ func (c *HisApiController) GetFaPiaoData() {
5784 5558
 	his, _ := service.GetHisPatientInfoThree(adminUser.CurrentOrgId, number)
5785 5559
 
5786 5560
 	his_hospital_record, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
5787
-	miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
5788 5561
 
5789 5562
 	//prescriptions, _ := service.GetHisPrescriptionThree(adminUser.CurrentOrgId, patient_id, order.Number)
5790 5563
 
@@ -6126,7 +5899,6 @@ func (c *HisApiController) GetFaPiaoData() {
6126 5899
 		"zhenChaCostSelfTotal":        zhenChaCostSelfTotal,
6127 5900
 		"zhenChaCostPartSelfTotal":    zhenChaCostPartSelfTotal,
6128 5901
 		"his_hospital_record":         his_hospital_record,
6129
-		"org_name":                    miConfig.OrgName,
6130 5902
 	})
6131 5903
 
6132 5904
 }