|
@ -4424,15 +4424,18 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
// List<Map<String, Object>> collect = inventoryDao.selectsomethingBysomeCondition(inventory.getIdDevice(), "1", "21");
|
|
|
List<Map<String, Object>> collect = hibenateUtils.createSQLQuery(sql);
|
|
|
// //药品变更,true除当前货道还存在该药品
|
|
|
boolean isExit = collect.stream().filter(m -> m.get("drugCode").toString().equals(inventoryDO.getDrugCode())).findAny().isPresent();
|
|
|
if (collect == null || collect.size() == 0 || !isExit) {
|
|
|
Map<String, Object> tempMap = new HashMap<>();
|
|
|
tempMap.put("drugCode", inventoryDO.getDrugCode());
|
|
|
tempMap.put("orgCode", inventoryDO.getOrgCode());
|
|
|
tempMap.put("qty", inventoryDO.getQty());
|
|
|
tempMap.put("ratedInventory", inventoryDO.getRatedInventory());
|
|
|
tempMap.put("drugId", inventoryDO.getDrugId());
|
|
|
collect.add(tempMap);
|
|
|
boolean isExit = false;
|
|
|
if (inventoryDO != null) {
|
|
|
isExit = collect.stream().filter(m -> m.get("drugCode").toString().equals(inventoryDO.getDrugCode())).findAny().isPresent();
|
|
|
if (collect == null || collect.size() == 0 || !isExit) {
|
|
|
Map<String, Object> tempMap = new HashMap<>();
|
|
|
tempMap.put("drugCode", inventoryDO.getDrugCode());
|
|
|
tempMap.put("orgCode", inventoryDO.getOrgCode());
|
|
|
tempMap.put("qty", inventoryDO.getQty());
|
|
|
tempMap.put("ratedInventory", inventoryDO.getRatedInventory());
|
|
|
tempMap.put("drugId", inventoryDO.getDrugId());
|
|
|
collect.add(tempMap);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
@ -4603,6 +4606,8 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
if (id.contains(",")){
|
|
|
String str[] = id.split(",");
|
|
|
MediicinecabinetInventory mediicinecabinetInventory = new MediicinecabinetInventory();
|
|
|
boolean cargoCapacityChanged = false;
|
|
|
int changedCapacity = 0;
|
|
|
for (int i=0;i<str.length;i++){
|
|
|
MediicinecabinetInventory inventory = inventoryDao.findOne(str[i]);
|
|
|
//更新设备缺货状态的该药品的已变动数量
|
|
@ -4610,8 +4615,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
inventoryDO.setDrugCode(inventory.getDrugCode());
|
|
|
inventoryDO.setOrgCode(inventory.getOrgCode());
|
|
|
inventoryDO.setRatedInventory(inventory.getRatedInventory());
|
|
|
boolean cargoCapacityChanged = false;
|
|
|
int changedCapacity = 0;
|
|
|
|
|
|
//库存变动
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(qty)){
|
|
|
if (Integer.parseInt(qty) > 99) {
|
|
@ -4635,7 +4639,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
//提升容量至库存数(修改的库存数大于容量时)
|
|
|
if (Integer.parseInt(qty) > Integer.parseInt(inventory.getCargoCapacity())) {
|
|
|
cargoCapacityChanged = true;
|
|
|
changedCapacity = Integer.parseInt(qty);
|
|
|
changedCapacity += Integer.parseInt(qty);
|
|
|
inventory.setCargoCapacity(qty);
|
|
|
}
|
|
|
inventory.setQty(qty);
|
|
@ -4674,7 +4678,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
throw new Exception("货道容量最多99个,如超过请放置另一格");
|
|
|
}
|
|
|
inventory.setCargoCapacity(cargoCapacity);
|
|
|
changedCapacity = Integer.parseInt(cargoCapacity);
|
|
|
changedCapacity += Integer.parseInt(cargoCapacity);
|
|
|
cargoCapacityChanged = true;
|
|
|
}
|
|
|
//更改货道容量-end
|
|
@ -4718,27 +4722,32 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
//默认false,通过规则判断是否缺货
|
|
|
if (!refreshStatus) {
|
|
|
//更改设备缺货状态
|
|
|
updateDeviceState(inventory.getId(), inventoryDO);
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(status)){
|
|
|
updateDeviceState(inventory.getId(), null);
|
|
|
} else {
|
|
|
updateDeviceState(inventory.getId(), inventoryDO);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
mediicinecabinetInventory = inventoryDao.save(inventory);
|
|
|
//重算设备容量
|
|
|
if (cargoCapacityChanged) {
|
|
|
if (cargoCapacityChanged && i == str.length - 1) {
|
|
|
Mediicinedevice mediicinedevice = deviceDao.findOne(inventory.getIdDevice());
|
|
|
String ids = id.replaceAll(",","','");
|
|
|
String tempSql = "SELECT\n" +
|
|
|
"\tifnull(sum(t.cargo_capacity), 0) as cargoCapacity\n" +
|
|
|
"FROM\n" +
|
|
|
"\tt_mediicinecabinet_inventory t\n" +
|
|
|
"WHERE\n" +
|
|
|
"\tt.id_device = '"+inventory.getIdDevice()+"'\n" +
|
|
|
"AND t.id != '"+inventory.getId()+"'\n" +
|
|
|
"AND t.id not in ('"+ids+"')\n" +
|
|
|
"AND (t.state = '1' OR t.state = '21')";
|
|
|
|
|
|
Map<String,Object> totalMap = jdbcTemplate.queryForMap(tempSql);
|
|
|
Integer noOnlineTotal1 = 0;
|
|
|
if (totalMap!=null){
|
|
|
if (totalMap.get("cargoCapacity") != null) {
|
|
|
noOnlineTotal1 = (int) Double.parseDouble(totalMap.get("cargoCapacity").toString() + changedCapacity);
|
|
|
noOnlineTotal1 = (int) Double.parseDouble(totalMap.get("cargoCapacity").toString() ) + changedCapacity;
|
|
|
}
|
|
|
}
|
|
|
mediicinedevice.setCapacity(String.valueOf(noOnlineTotal1));
|
|
@ -4861,7 +4870,11 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
//默认false,通过规则判断是否缺货
|
|
|
if (!refreshStatus) {
|
|
|
//更改设备缺货状态
|
|
|
updateDeviceState(inventory.getId(), inventoryDO);
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(status)){
|
|
|
updateDeviceState(inventory.getId(), null);
|
|
|
} else {
|
|
|
updateDeviceState(inventory.getId(), inventoryDO);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
inventoryDao.save(inventory);
|