|
@ -722,6 +722,8 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
inventory.setNum("3");
|
|
|
inventory.setLongtime(null);
|
|
|
inventory.setOrgCode(null);
|
|
|
//设备解绑---->货道容量恢复默认值
|
|
|
inventory.setCargoCapacity(5+"");
|
|
|
//额定 库存归0
|
|
|
inventory.setRatedInventory(0);
|
|
|
inventoryDao.save(inventory);
|
|
@ -1607,7 +1609,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
}
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("device",device);
|
|
|
//货道总数----->写死
|
|
|
//货道总数----->行*列计算得出货道总数
|
|
|
String tempSql = "SELECT\n" +
|
|
|
"\tcount(distinct(t.layer_no)) as layerNum\n" +
|
|
|
"FROM\n" +
|
|
@ -1624,7 +1626,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
"AND t.layer_no = '1'";
|
|
|
int wayerNum = jdbcTemplate.queryForObject(tempSql, Integer.class);
|
|
|
jsonObject.put("totalCargo", layerNum * wayerNum);
|
|
|
//设备容量
|
|
|
//设备总货道容量---初始1200
|
|
|
jsonObject.put("deviceCapacity", device.getCapacity());
|
|
|
tempSql = "SELECT\n" +
|
|
|
"\tIFNULL(\n" +
|
|
@ -1644,7 +1646,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
//在架库存数
|
|
|
jsonObject.put("inStock", inStock);
|
|
|
jsonObject.put("inStockRate", new BigDecimal((inStock * 1.0) / Integer.parseInt(device.getCapacity())).setScale(2, BigDecimal.ROUND_HALF_UP));
|
|
|
//缺货库存Out of stock
|
|
|
//缺货库存Out of stock----start
|
|
|
tempSql = "SELECT\n" +
|
|
|
"\tsum(\n" +
|
|
|
"\t\tt.cargo_capacity - cast(t.qty AS UNSIGNED)\n" +
|
|
@ -1654,11 +1656,83 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
"WHERE\n" +
|
|
|
"\tt.id_device = '"+ device.getId() +"'\n" +
|
|
|
"AND (t.state = '1' OR t.state = '21')";
|
|
|
int outOfStock = jdbcTemplate.queryForObject(tempSql, Integer.class);
|
|
|
//缺货库存
|
|
|
jsonObject.put("outOfStock", outOfStock);
|
|
|
// int outOfStock = jdbcTemplate.queryForObject(tempSql, Integer.class);
|
|
|
String sql = "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" +
|
|
|
"AND (t.state = '1' OR t.state = '21')";
|
|
|
//设备列表
|
|
|
List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql);
|
|
|
|
|
|
int closedCapacity = list.stream()
|
|
|
.filter(item -> "0".equals(String.valueOf(item.get("cargoState"))) && "0".equals(String.valueOf(item.get("faultState"))))
|
|
|
.mapToInt(item -> Integer.parseInt(String.valueOf(item.get("cargoCapacity")))).sum();
|
|
|
|
|
|
int faultCapacity = list.stream()
|
|
|
.filter(item -> "1".equals(String.valueOf(item.get("cargoState"))) && "1".equals(String.valueOf(item.get("faultState"))))
|
|
|
.mapToInt(item -> Integer.parseInt(String.valueOf(item.get("cargoCapacity")))).sum();
|
|
|
//closedAndFaultCapacity
|
|
|
int closedAndFaultCapacity = list.stream()
|
|
|
.filter(item -> "0".equals(String.valueOf(item.get("cargoState"))) && "1".equals(String.valueOf(item.get("faultState"))))
|
|
|
.mapToInt(item -> Integer.parseInt(String.valueOf(item.get("cargoCapacity")))).sum();
|
|
|
|
|
|
int drugNumber = 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();
|
|
|
//关闭容量
|
|
|
// tempSql = "SELECT\n" +
|
|
|
// "\tifnull(sum(t.cargo_capacity), 0) AS closedCapacity\n" +
|
|
|
// "FROM\n" +
|
|
|
// "\tt_mediicinecabinet_inventory t\n" +
|
|
|
// "WHERE\n" +
|
|
|
// "\tt.id_device = '" + device.getId() + "'\n" +
|
|
|
// "AND t.cargo_state = '0'\n" +
|
|
|
// "AND t.fault_state = '0'\n" +
|
|
|
// "AND (t.state = '1' OR t.state = '21')";
|
|
|
// int closedCapacity = jdbcTemplate.queryForObject(tempSql, Integer.class);
|
|
|
//故障容量
|
|
|
// tempSql = "SELECT\n" +
|
|
|
// "\tifnull(sum(t.cargo_capacity), 0) AS closedCapacity\n" +
|
|
|
// "FROM\n" +
|
|
|
// "\tt_mediicinecabinet_inventory t\n" +
|
|
|
// "WHERE\n" +
|
|
|
// "\tt.id_device = '" + device.getId() + "'\n" +
|
|
|
// "AND t.cargo_state = '1'\n" +
|
|
|
// "AND t.fault_state = '1'\n" +
|
|
|
// "AND (t.state = '1' OR t.state = '21')";
|
|
|
// int faultCapacity = jdbcTemplate.queryForObject(tempSql, Integer.class);
|
|
|
//既关闭又故障的容量
|
|
|
// tempSql = "SELECT\n" +
|
|
|
// "\tifnull(sum(t.cargo_capacity), 0) AS closedCapacity\n" +
|
|
|
// "FROM\n" +
|
|
|
// "\tt_mediicinecabinet_inventory t\n" +
|
|
|
// "WHERE\n" +
|
|
|
// "\tt.id_device = '" + device.getId() + "'\n" +
|
|
|
// "AND t.cargo_state = '0'\n" +
|
|
|
// "AND t.fault_state = '1'\n" +
|
|
|
// "AND (t.state = '1' OR t.state = '21')";
|
|
|
// int closedAndFaultCapacity = jdbcTemplate.queryForObject(tempSql, Integer.class);
|
|
|
//开启的正常的货道的药品数量
|
|
|
// tempSql = "SELECT\n" +
|
|
|
// "\tifnull(sum(t.qty), 0) AS closedCapacity\n" +
|
|
|
// "FROM\n" +
|
|
|
// "\tt_mediicinecabinet_inventory t\n" +
|
|
|
// "WHERE\n" +
|
|
|
// "\tt.id_device = '" + device.getId() + "'\n" +
|
|
|
// "AND t.cargo_state = '1'\n" +
|
|
|
// "AND t.fault_state = '0'\n" +
|
|
|
// "AND (t.state = '1' OR t.state = '21')";
|
|
|
// int drugNumber = jdbcTemplate.queryForObject(tempSql, Integer.class);
|
|
|
|
|
|
int outOfStock = Integer.parseInt(device.getCapacity()) - closedAndFaultCapacity - faultCapacity - closedCapacity - drugNumber;
|
|
|
jsonObject.put("outOfStock", outOfStock);
|
|
|
//缺货库存----end
|
|
|
tempSql = "SELECT\n" +
|
|
|
"\tCOUNT(DISTINCT(t.id))\n" +
|
|
|
"FROM\n" +
|
|
@ -1680,7 +1754,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
"and t.cargo_state = '0'\n" +
|
|
|
"AND (t.state = '1'\n" +
|
|
|
"OR t.state = '21')";
|
|
|
//关闭货道
|
|
|
//关闭货道----->数量
|
|
|
int closedCargo = jdbcTemplate.queryForObject(tempSql, Integer.class);
|
|
|
jsonObject.put("closedCargo", closedCargo);
|
|
|
tempSql = "SELECT\n" +
|
|
@ -1692,7 +1766,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
"and t.cargo_state = '1'\n" +
|
|
|
"AND (t.state = '1'\n" +
|
|
|
"OR t.state = '21')";
|
|
|
//关闭货道
|
|
|
//故障货道---->数量
|
|
|
int openedCargo = jdbcTemplate.queryForObject(tempSql, Integer.class);
|
|
|
jsonObject.put("openedCargo", openedCargo);
|
|
|
tempSql = "SELECT\n" +
|
|
@ -1704,7 +1778,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
"and t.fault_state = '1'\n" +
|
|
|
"AND (t.state = '1'\n" +
|
|
|
"OR t.state = '21')";
|
|
|
//关闭货道
|
|
|
//故障货道
|
|
|
int faultCargo = jdbcTemplate.queryForObject(tempSql, Integer.class);
|
|
|
jsonObject.put("faultCargo", faultCargo);
|
|
|
|
|
@ -2555,7 +2629,20 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
}
|
|
|
String daibuSql = "";
|
|
|
int daibuNumber;
|
|
|
//待补商品数量
|
|
|
//当前设备的库存信息-货道容量、药品数量、货道开关状态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 = '" + String.valueOf(stringObjectMap.get("id")) + "'\n" +
|
|
|
"AND (t.state = '1' OR t.state = '21')";
|
|
|
//设备列表
|
|
|
List<Map<String, Object>> list = hibenateUtils.createSQLQuery(tempConditionSql);
|
|
|
//待补商品数量(待入库药品数量)
|
|
|
daibuSql = "SELECT\n" +
|
|
|
"\tsum(\n" +
|
|
|
"\t\tt.cargo_capacity - cast(t.qty AS UNSIGNED)\n" +
|
|
@ -2566,7 +2653,18 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
"\tt.id_device = '"+stringObjectMap.get("id").toString()+"'\n" +
|
|
|
"AND (t.state = '1' OR t.state = '21')";
|
|
|
daibuNumber = jdbcTemplate.queryForObject(daibuSql, Integer.class);
|
|
|
stringObjectMap.put("daibushangpinshuliang", daibuNumber);
|
|
|
// stringObjectMap.put("daibushangpinshuliang", daibuNumber);
|
|
|
//newVersion
|
|
|
//所有正常状态货道容量
|
|
|
int normalOpenCargoCapacity = 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("cargoCapacity")))).sum();
|
|
|
int usedCargoCapacity = list.stream()
|
|
|
.filter(item -> "1".equals(String.valueOf(item.get("cargoState"))) &&
|
|
|
"0".equals(String.valueOf(item.get("faultState"))) &&
|
|
|
Integer.parseInt(String.valueOf(item.get("qty"))) > 0)
|
|
|
.mapToInt(item -> Integer.parseInt(String.valueOf(item.get("qty")))).sum();
|
|
|
stringObjectMap.put("daibushangpinshuliang", normalOpenCargoCapacity - usedCargoCapacity);
|
|
|
String tempSql = "SELECT\n" +
|
|
|
"\tifnull(sum(t.qty), 0) AS qty\n" +
|
|
|
"FROM\n" +
|
|
@ -2597,8 +2695,22 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
int number = jdbcTemplate.queryForObject(tempSql, Integer.class);
|
|
|
stringObjectMap.put("weishezhishangpinhuodao", number);
|
|
|
//空置率
|
|
|
// stringObjectMap.put("kongzhilv",
|
|
|
// new BigDecimal((number * 1.0) / Integer.parseInt(stringObjectMap.get("aisles").toString())).setScale(2, BigDecimal.ROUND_HALF_UP));
|
|
|
|
|
|
//newVersion
|
|
|
//正常货道数(正常的、开启的)
|
|
|
int normalCargoNumber = ((int) list.stream()
|
|
|
.filter(item -> "1".equals(String.valueOf(item.get("cargoState"))) && "0".equals(String.valueOf(item.get("faultState")))).count());
|
|
|
//已用货道数
|
|
|
int usedCargoNumber = ((int) list.stream()
|
|
|
.filter(item -> "1".equals(String.valueOf(item.get("cargoState"))) &&
|
|
|
"0".equals(String.valueOf(item.get("faultState"))) &&
|
|
|
Integer.parseInt(String.valueOf(item.get("qty"))) > 0).count());
|
|
|
|
|
|
stringObjectMap.put("kongzhilv",
|
|
|
new BigDecimal((number * 1.0) / Integer.parseInt(stringObjectMap.get("aisles").toString())).setScale(2, BigDecimal.ROUND_HALF_UP));
|
|
|
new BigDecimal(((normalCargoNumber-usedCargoNumber) * 100.0) / normalCargoNumber).setScale(2, BigDecimal.ROUND_HALF_UP));
|
|
|
|
|
|
//商品庫存
|
|
|
// Integer inventoryNum = inventoryDao.sumInventoryWithEquNum(stringObjectMap.get("equNum")+"", "1", "21");
|
|
|
String tempSqlTwo = "SELECT\n" +
|
|
@ -4739,11 +4851,11 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
//默认false,通过规则判断是否缺货
|
|
|
if (!refreshStatus) {
|
|
|
//更改设备缺货状态
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(status)){
|
|
|
updateDeviceState(inventory.getId(), null);
|
|
|
} else {
|
|
|
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);
|
|
@ -4887,11 +4999,11 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
//默认false,通过规则判断是否缺货
|
|
|
if (!refreshStatus) {
|
|
|
//更改设备缺货状态
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(status)){
|
|
|
updateDeviceState(inventory.getId(), null);
|
|
|
} else {
|
|
|
updateDeviceState(inventory.getId(), inventoryDO);
|
|
|
}
|
|
|
// if (org.apache.commons.lang3.StringUtils.isNoneBlank(status)){
|
|
|
// updateDeviceState(inventory.getId(), null);
|
|
|
// } else {
|
|
|
// updateDeviceState(inventory.getId(), inventoryDO);
|
|
|
// }
|
|
|
}
|
|
|
|
|
|
inventoryDao.save(inventory);
|