|
@ -4774,6 +4774,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
MediicinecabinetInventory inventory = inventoryDao.findOne(str[i]);
|
|
|
//更新设备缺货状态的该药品的已变动数量
|
|
|
InventoryDO inventoryDO = new InventoryDO();
|
|
|
inventoryDO.setCargoId(inventory.getId());
|
|
|
inventoryDO.setDrugCode(inventory.getDrugCode());
|
|
|
inventoryDO.setOrgCode(inventory.getOrgCode());
|
|
|
inventoryDO.setRatedInventory(inventory.getRatedInventory());
|
|
@ -4890,7 +4891,8 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
// updateDeviceState(inventory.getId(), inventoryDO);
|
|
|
// }
|
|
|
}
|
|
|
|
|
|
//如果正常开启的总计库存为0强制更新设备为缺货状态
|
|
|
setDeviceInventoryStatusByOneInventory(inventoryDO);
|
|
|
mediicinecabinetInventory = inventoryDao.save(inventory);
|
|
|
//重算设备容量
|
|
|
if (cargoCapacityChanged && i == str.length - 1) {
|
|
@ -4921,6 +4923,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
MediicinecabinetInventory inventory = inventoryDao.findOne(id);
|
|
|
//更新设备缺货状态的该药品的已变动数量
|
|
|
InventoryDO inventoryDO = new InventoryDO();
|
|
|
inventoryDO.setCargoId(inventory.getId());
|
|
|
inventoryDO.setDrugCode(inventory.getDrugCode());
|
|
|
inventoryDO.setOrgCode(inventory.getOrgCode());
|
|
|
inventoryDO.setRatedInventory(inventory.getRatedInventory());
|
|
@ -5038,8 +5041,10 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
// updateDeviceState(inventory.getId(), inventoryDO);
|
|
|
// }
|
|
|
}
|
|
|
|
|
|
//如果正常开启的总计库存为0强制更新设备为缺货状态
|
|
|
setDeviceInventoryStatusByOneInventory(inventoryDO);
|
|
|
inventoryDao.save(inventory);
|
|
|
|
|
|
//重算设备容量
|
|
|
if (cargoCapacityChanged) {
|
|
|
Mediicinedevice mediicinedevice = deviceDao.findOne(inventory.getIdDevice());
|
|
@ -5068,6 +5073,37 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* (正常,开启的)库存为零更新设备为缺货状态
|
|
|
* @param inventory
|
|
|
*/
|
|
|
public void setDeviceInventoryStatusByOneInventory(InventoryDO inventory) {
|
|
|
Mediicinedevice device = deviceDao.findOne(inventory.getIdDevice());
|
|
|
if(device == null) return;
|
|
|
//当前设备的库存信息-货道容量、药品数量、货道开关状态1开启,0关闭、货道正常故障状态1故障,0正常
|
|
|
String tempConditionSql = "SELECT\n" +
|
|
|
"\tifnull(t.cargo_capacity, 0) AS cargoCapacity,\n" +
|
|
|
"\tifnull(t.qty, 0) AS qty,\n" +
|
|
|
"\tt.cargo_state AS cargoState,\n" +
|
|
|
"\tt.fault_state AS faultState\n" +
|
|
|
"FROM\n" +
|
|
|
"\tt_mediicinecabinet_inventory t\n" +
|
|
|
"WHERE\n" +
|
|
|
"\tt.id_device = '" + device.getId() + "'\n" +
|
|
|
"\tt.id != '" + inventory.getCargoId() + "'\n" +
|
|
|
"AND (t.state = '1' OR t.state = '21')";
|
|
|
//设备列表
|
|
|
List<Map<String, Object>> list = hibenateUtils.createSQLQuery(tempConditionSql);
|
|
|
int totalDrugNumber = list.stream()
|
|
|
.filter(item -> "1".equals(String.valueOf(item.get("cargoState"))) && "0".equals(String.valueOf(item.get("faultState"))))
|
|
|
.mapToInt(item -> Integer.parseInt(String.valueOf(item.get("qty")))).sum() + inventory.getQty();
|
|
|
if (totalDrugNumber == 0) {
|
|
|
device.setStatus("0");
|
|
|
deviceDao.save(device);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 物联网大屏统计数据
|
|
|
* @return
|