|
@@ -39,7 +39,11 @@ func PharmacyApiRegistRouters() {
|
39
|
39
|
beego.Router("/api/pharmacy/getgoodinventorybygoodid", &PharmacyController{}, "Get:GetGoodInventoryByGoodId")
|
40
|
40
|
beego.Router("/api/pharmacy/updateInventoryWarehouseInfo", &PharmacyController{}, "Get:UpdateInventoryWarehouseInfo")
|
41
|
41
|
|
42
|
|
- beego.Router("/api/pharmacy/getdruginventoryList", &PharmacyController{}, "Get:GetDrugInventoryList")
|
|
42
|
+ beego.Router("/api/pharmacy/getdrugnewinventoryList", &PharmacyController{}, "Get:GetDrugInventoryList")
|
|
43
|
+
|
|
44
|
+ beego.Router("/api/pharmacy/getdruginventorybydrugid", &PharmacyController{}, "Get:GetDrugInventoryByDrugId")
|
|
45
|
+
|
|
46
|
+ beego.Router("/api/pharmacy/updatedruginventorywarehouseinfo", &PharmacyController{}, "Get:UpdateDrugInventoryWarehouseInfo")
|
43
|
47
|
}
|
44
|
48
|
|
45
|
49
|
// 测试
|
|
@@ -1082,10 +1086,270 @@ func (this *PharmacyController) UpdateInventoryWarehouseInfo() {
|
1082
|
1086
|
|
1083
|
1087
|
func (this *PharmacyController) GetDrugInventoryList() {
|
1084
|
1088
|
|
|
1089
|
+ keywords := this.GetString("keywords")
|
|
1090
|
+ orgId := this.GetAdminUserInfo().CurrentOrgId
|
|
1091
|
+ drugList, _ := service.GetDrugNewInventoryList(orgId, keywords)
|
|
1092
|
+ manufacturerList, _ := service.GetAllManufacturerList(orgId)
|
|
1093
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
1094
|
+ "drugList": drugList,
|
|
1095
|
+ "manufacturerList": manufacturerList,
|
|
1096
|
+ })
|
|
1097
|
+}
|
|
1098
|
+
|
|
1099
|
+func (this *PharmacyController) GetDrugInventoryByDrugId() {
|
|
1100
|
+
|
1085
|
1101
|
orgId := this.GetAdminUserInfo().CurrentOrgId
|
1086
|
|
- drugList, _ := service.GetDrugNewInventoryList(orgId)
|
|
1102
|
+
|
|
1103
|
+ id, _ := this.GetInt64("id")
|
|
1104
|
+
|
|
1105
|
+ infoList, _ := service.GetDrugInvetoryByDrugId(orgId, id)
|
|
1106
|
+
|
|
1107
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
1108
|
+ "infoList": infoList,
|
|
1109
|
+ })
|
|
1110
|
+}
|
|
1111
|
+
|
|
1112
|
+func (this *PharmacyController) UpdateDrugInventoryWarehouseInfo() {
|
|
1113
|
+
|
|
1114
|
+ id, _ := this.GetInt64("id")
|
|
1115
|
+ stock_max_number, _ := this.GetInt64("stock_max_number")
|
|
1116
|
+ stock_min_number, _ := this.GetInt64("stock_min_number")
|
|
1117
|
+ last_stock_max_number, _ := this.GetInt64("last_stock_max_number")
|
|
1118
|
+ last_stock_min_number, _ := this.GetInt64("last_stock_min_number")
|
|
1119
|
+
|
|
1120
|
+ drug_id, _ := this.GetInt64("drug_id")
|
|
1121
|
+ storehouse_id, _ := this.GetInt64("storehouse_id")
|
|
1122
|
+ is_type, _ := this.GetInt64("is_type")
|
|
1123
|
+
|
|
1124
|
+ specification_name := this.GetString("specification_name")
|
|
1125
|
+ orgId := this.GetAdminUserInfo().CurrentOrgId
|
|
1126
|
+
|
|
1127
|
+ base, _ := service.GetBasedrugByIdOne(drug_id, orgId)
|
|
1128
|
+
|
|
1129
|
+ var ord_total int64
|
|
1130
|
+ var new_total int64
|
|
1131
|
+ var consumable_count int64
|
|
1132
|
+
|
|
1133
|
+ ord_total = stock_max_number*base.MinNumber + stock_min_number
|
|
1134
|
+ new_total = last_stock_max_number*base.MinNumber + last_stock_min_number
|
|
1135
|
+
|
|
1136
|
+ //更新入库单
|
|
1137
|
+ service.UpdateNewDrugWarehouseInfoById(id, last_stock_max_number, last_stock_min_number)
|
|
1138
|
+
|
|
1139
|
+ //查询默认仓库
|
|
1140
|
+ houseConfig, _ := service.GetAllStoreHouseConfig(orgId)
|
|
1141
|
+ //查询默认仓库剩余多少库存
|
|
1142
|
+ list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, orgId, drug_id)
|
|
1143
|
+ var sum_count int64
|
|
1144
|
+ for _, it := range list {
|
|
1145
|
+ baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
|
|
1146
|
+ if it.MaxUnit == baseDrug.MaxUnit {
|
|
1147
|
+ it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
|
|
1148
|
+ it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
|
|
1149
|
+ }
|
|
1150
|
+ sum_count += it.StockMaxNumber + it.StockMinNumber
|
|
1151
|
+
|
|
1152
|
+ }
|
|
1153
|
+ //更新剩余库存
|
|
1154
|
+ service.UpdateMedicalSumCountOne(drug_id, sum_count, orgId)
|
|
1155
|
+
|
|
1156
|
+ //更新剩余库存
|
|
1157
|
+ service.UpdateDrugStockCount(drug_id, orgId, houseConfig.DrugStorehouseOut, sum_count)
|
|
1158
|
+
|
|
1159
|
+ drugWarehouseInfoOne, _ := service.GetDrugWarehouseInfoOne(id)
|
|
1160
|
+
|
|
1161
|
+ manufacturer, _ := service.GetManufactureById(drugWarehouseInfoOne.Manufacturer)
|
|
1162
|
+
|
|
1163
|
+ recordDateStr := time.Now().Format("2006-01-02")
|
|
1164
|
+
|
|
1165
|
+ recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
|
|
1166
|
+
|
|
1167
|
+ fmt.Println("ord_total-----------------------------", ord_total)
|
|
1168
|
+ fmt.Println("new_total-----------------------------", new_total)
|
|
1169
|
+ //盘亏
|
|
1170
|
+ if ord_total > new_total {
|
|
1171
|
+
|
|
1172
|
+ consumable_count = ord_total - new_total
|
|
1173
|
+
|
|
1174
|
+ inventory := models.XtDrugInventory{
|
|
1175
|
+ DrugName: base.DrugName,
|
|
1176
|
+ SpecificationName: specification_name,
|
|
1177
|
+ WarehousingUnit: drugWarehouseInfoOne.MaxUnit,
|
|
1178
|
+ Count: consumable_count,
|
|
1179
|
+ LastPrice: drugWarehouseInfoOne.Price,
|
|
1180
|
+ RetailPrice: drugWarehouseInfoOne.RetailPrice,
|
|
1181
|
+ NewPrice: 0,
|
|
1182
|
+ Manufacturer: manufacturer.ManufacturerName,
|
|
1183
|
+ Dealer: "",
|
|
1184
|
+ Remark: "",
|
|
1185
|
+ DrugId: drug_id,
|
|
1186
|
+ UserOrgId: orgId,
|
|
1187
|
+ Ctime: time.Now().Unix(),
|
|
1188
|
+ Mtime: 0,
|
|
1189
|
+ Status: 1,
|
|
1190
|
+ WarehousingOrder: drugWarehouseInfoOne.WarehousingOrder,
|
|
1191
|
+ LicenseNumber: "",
|
|
1192
|
+ StartTime: recordDate.Unix(),
|
|
1193
|
+ Creater: this.GetAdminUserInfo().AdminUser.Id,
|
|
1194
|
+ Checker: 0,
|
|
1195
|
+ CheckerStatus: 0,
|
|
1196
|
+ CheckerTime: 0,
|
|
1197
|
+ ExpiryDate: drugWarehouseInfoOne.ExpiryDate,
|
|
1198
|
+ ProductDate: drugWarehouseInfoOne.ProductDate,
|
|
1199
|
+ Number: "",
|
|
1200
|
+ BatchNumber: drugWarehouseInfoOne.BatchNumber,
|
|
1201
|
+ Total: "",
|
|
1202
|
+ DrugOriginPlace: "",
|
|
1203
|
+ WarehouseInfoId: id,
|
|
1204
|
+ ProofCount: 0,
|
|
1205
|
+ StockMaxNumber: stock_max_number,
|
|
1206
|
+ StockMinNumber: stock_min_number,
|
|
1207
|
+ MinCount: 0,
|
|
1208
|
+ MinUnit: drugWarehouseInfoOne.MinUnit,
|
|
1209
|
+ LastStockMaxNumber: last_stock_max_number,
|
|
1210
|
+ LastStockMinNumber: last_stock_min_number,
|
|
1211
|
+ InventoryType: 11,
|
|
1212
|
+ Type: is_type,
|
|
1213
|
+ StorehouseId: storehouse_id,
|
|
1214
|
+ RecordDate: recordDate.Unix(),
|
|
1215
|
+ }
|
|
1216
|
+
|
|
1217
|
+ service.CreateDrugInventory(inventory)
|
|
1218
|
+
|
|
1219
|
+ flow := models.DrugFlow{
|
|
1220
|
+ WarehousingId: id,
|
|
1221
|
+ DrugId: drug_id,
|
|
1222
|
+ Number: "",
|
|
1223
|
+ BatchNumber: drugWarehouseInfoOne.BatchNumber,
|
|
1224
|
+ Count: consumable_count,
|
|
1225
|
+ UserOrgId: orgId,
|
|
1226
|
+ PatientId: 0,
|
|
1227
|
+ SystemTime: recordDate.Unix(),
|
|
1228
|
+ ConsumableType: 11,
|
|
1229
|
+ IsSys: 1,
|
|
1230
|
+ WarehousingOrder: drugWarehouseInfoOne.WarehousingOrder,
|
|
1231
|
+ WarehouseOutId: 0,
|
|
1232
|
+ WarehouseOutOrderNumber: "",
|
|
1233
|
+ IsEdit: 0,
|
|
1234
|
+ CancelStockId: 0,
|
|
1235
|
+ CancelOrderNumber: "",
|
|
1236
|
+ Manufacturer: manufacturer.ID,
|
|
1237
|
+ Dealer: 0,
|
|
1238
|
+ Creator: this.GetAdminUserInfo().AdminUser.Id,
|
|
1239
|
+ UpdateCreator: 0,
|
|
1240
|
+ Status: 1,
|
|
1241
|
+ Ctime: time.Now().Unix(),
|
|
1242
|
+ Mtime: 0,
|
|
1243
|
+ Price: drugWarehouseInfoOne.Price,
|
|
1244
|
+ WarehousingDetailId: id,
|
|
1245
|
+ WarehouseOutDetailId: 0,
|
|
1246
|
+ CancelOutDetailId: 0,
|
|
1247
|
+ ExpireDate: drugWarehouseInfoOne.ExpiryDate,
|
|
1248
|
+ ProductDate: 0,
|
|
1249
|
+ MaxUnit: drugWarehouseInfoOne.MaxUnit,
|
|
1250
|
+ MinUnit: drugWarehouseInfoOne.MinUnit,
|
|
1251
|
+ StorehouseId: storehouse_id,
|
|
1252
|
+ OverCount: sum_count,
|
|
1253
|
+ }
|
|
1254
|
+ service.CreateDrugFlowOne(flow)
|
|
1255
|
+
|
|
1256
|
+ //添加出库数据
|
|
1257
|
+ service.AddDrugWarehouseOut(drug_id, consumable_count, storehouse_id, orgId)
|
|
1258
|
+
|
|
1259
|
+ }
|
|
1260
|
+
|
|
1261
|
+ //盘盈
|
|
1262
|
+ if ord_total < new_total {
|
|
1263
|
+
|
|
1264
|
+ consumable_count = new_total - ord_total
|
|
1265
|
+
|
|
1266
|
+ inventory := models.XtDrugInventory{
|
|
1267
|
+ DrugName: base.DrugName,
|
|
1268
|
+ SpecificationName: specification_name,
|
|
1269
|
+ WarehousingUnit: drugWarehouseInfoOne.MaxUnit,
|
|
1270
|
+ Count: consumable_count,
|
|
1271
|
+ LastPrice: drugWarehouseInfoOne.Price,
|
|
1272
|
+ RetailPrice: drugWarehouseInfoOne.RetailPrice,
|
|
1273
|
+ NewPrice: 0,
|
|
1274
|
+ Manufacturer: manufacturer.ManufacturerName,
|
|
1275
|
+ Dealer: "",
|
|
1276
|
+ Remark: "",
|
|
1277
|
+ DrugId: drug_id,
|
|
1278
|
+ UserOrgId: orgId,
|
|
1279
|
+ Ctime: time.Now().Unix(),
|
|
1280
|
+ Mtime: 0,
|
|
1281
|
+ Status: 1,
|
|
1282
|
+ WarehousingOrder: drugWarehouseInfoOne.WarehousingOrder,
|
|
1283
|
+ LicenseNumber: "",
|
|
1284
|
+ StartTime: recordDate.Unix(),
|
|
1285
|
+ Creater: this.GetAdminUserInfo().AdminUser.Id,
|
|
1286
|
+ Checker: 0,
|
|
1287
|
+ CheckerStatus: 0,
|
|
1288
|
+ CheckerTime: 0,
|
|
1289
|
+ ExpiryDate: drugWarehouseInfoOne.ExpiryDate,
|
|
1290
|
+ ProductDate: drugWarehouseInfoOne.ProductDate,
|
|
1291
|
+ Number: "",
|
|
1292
|
+ BatchNumber: drugWarehouseInfoOne.BatchNumber,
|
|
1293
|
+ Total: "",
|
|
1294
|
+ DrugOriginPlace: "",
|
|
1295
|
+ WarehouseInfoId: id,
|
|
1296
|
+ ProofCount: 0,
|
|
1297
|
+ StockMaxNumber: stock_max_number,
|
|
1298
|
+ StockMinNumber: stock_min_number,
|
|
1299
|
+ MinCount: 0,
|
|
1300
|
+ MinUnit: drugWarehouseInfoOne.MinUnit,
|
|
1301
|
+ LastStockMaxNumber: last_stock_max_number,
|
|
1302
|
+ LastStockMinNumber: last_stock_min_number,
|
|
1303
|
+ InventoryType: 10,
|
|
1304
|
+ Type: is_type,
|
|
1305
|
+ StorehouseId: storehouse_id,
|
|
1306
|
+ RecordDate: recordDate.Unix(),
|
|
1307
|
+ }
|
|
1308
|
+
|
|
1309
|
+ service.CreateDrugInventory(inventory)
|
|
1310
|
+
|
|
1311
|
+ flow := models.DrugFlow{
|
|
1312
|
+ WarehousingId: id,
|
|
1313
|
+ DrugId: drug_id,
|
|
1314
|
+ Number: "",
|
|
1315
|
+ BatchNumber: drugWarehouseInfoOne.BatchNumber,
|
|
1316
|
+ Count: consumable_count,
|
|
1317
|
+ UserOrgId: orgId,
|
|
1318
|
+ PatientId: 0,
|
|
1319
|
+ SystemTime: recordDate.Unix(),
|
|
1320
|
+ ConsumableType: 10,
|
|
1321
|
+ IsSys: 1,
|
|
1322
|
+ WarehousingOrder: drugWarehouseInfoOne.WarehousingOrder,
|
|
1323
|
+ WarehouseOutId: 0,
|
|
1324
|
+ WarehouseOutOrderNumber: "",
|
|
1325
|
+ IsEdit: 0,
|
|
1326
|
+ CancelStockId: 0,
|
|
1327
|
+ CancelOrderNumber: "",
|
|
1328
|
+ Manufacturer: manufacturer.ID,
|
|
1329
|
+ Dealer: 0,
|
|
1330
|
+ Creator: this.GetAdminUserInfo().AdminUser.Id,
|
|
1331
|
+ UpdateCreator: 0,
|
|
1332
|
+ Status: 1,
|
|
1333
|
+ Ctime: time.Now().Unix(),
|
|
1334
|
+ Mtime: 0,
|
|
1335
|
+ Price: drugWarehouseInfoOne.Price,
|
|
1336
|
+ WarehousingDetailId: id,
|
|
1337
|
+ WarehouseOutDetailId: 0,
|
|
1338
|
+ CancelOutDetailId: 0,
|
|
1339
|
+ ExpireDate: drugWarehouseInfoOne.ExpiryDate,
|
|
1340
|
+ ProductDate: 0,
|
|
1341
|
+ MaxUnit: drugWarehouseInfoOne.MaxUnit,
|
|
1342
|
+ MinUnit: drugWarehouseInfoOne.MinUnit,
|
|
1343
|
+ StorehouseId: storehouse_id,
|
|
1344
|
+ OverCount: sum_count,
|
|
1345
|
+ }
|
|
1346
|
+ service.CreateDrugFlowOne(flow)
|
|
1347
|
+
|
|
1348
|
+ //减少出库数据
|
|
1349
|
+ service.ReduceDrugWarehouseOut(drug_id, consumable_count, storehouse_id, orgId)
|
|
1350
|
+ }
|
1087
|
1351
|
|
1088
|
1352
|
this.ServeSuccessJSON(map[string]interface{}{
|
1089
|
|
- "drugList": drugList,
|
|
1353
|
+ "msg": "msg",
|
1090
|
1354
|
})
|
1091
|
1355
|
}
|