|
@ -2346,34 +2346,68 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
}
|
|
|
for (Map<String, Object> stringObjectMap : deviceList) {
|
|
|
String tempSql = "";
|
|
|
int number;
|
|
|
//待补商品数量
|
|
|
tempSql = "SELECT\n" +
|
|
|
"\tsum(\n" +
|
|
|
"\t\tt.cargo_capacity - cast(t.qty AS UNSIGNED)\n" +
|
|
|
"\t)\n" +
|
|
|
//当前设备的库存信息-货道容量、药品数量、货道开关状态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 = '"+stringObjectMap.get("id").toString()+"'\n" +
|
|
|
"\tt.id_device = '" + String.valueOf(stringObjectMap.get("id")) + "'\n" +
|
|
|
"AND (t.state = '1' OR t.state = '21')";
|
|
|
number = jdbcTemplate.queryForObject(tempSql, Integer.class);
|
|
|
stringObjectMap.put("daibushangpinshuliang", number);
|
|
|
//设备列表
|
|
|
List<Map<String, Object>> list = hibenateUtils.createSQLQuery(tempConditionSql);
|
|
|
//待补商品数量
|
|
|
// int number;
|
|
|
// tempSql = "SELECT\n" +
|
|
|
// "\tsum(\n" +
|
|
|
// "\t\tt.cargo_capacity - cast(t.qty AS UNSIGNED)\n" +
|
|
|
// "\t)\n" +
|
|
|
// "FROM\n" +
|
|
|
// "\tt_mediicinecabinet_inventory t\n" +
|
|
|
// "WHERE\n" +
|
|
|
// "\tt.id_device = '"+stringObjectMap.get("id").toString()+"'\n" +
|
|
|
// "AND (t.state = '1' OR t.state = '21')";
|
|
|
// number = jdbcTemplate.queryForObject(tempSql, Integer.class);
|
|
|
// stringObjectMap.put("daibushangpinshuliang", number);
|
|
|
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);
|
|
|
|
|
|
//未设置商品货道
|
|
|
tempSql = "SELECT\n" +
|
|
|
"\tcount(DISTINCT(t.id))\n" +
|
|
|
"FROM\n" +
|
|
|
"\tt_mediicinecabinet_inventory t\n" +
|
|
|
"WHERE\n" +
|
|
|
"\tt.id_device = '" + stringObjectMap.get("id").toString() + "'\n" +
|
|
|
"AND t.org_code IS NULL\n" +
|
|
|
"AND t.drug_code IS NULL\n" +
|
|
|
"AND (t.state = '1' OR t.state = '21')";
|
|
|
number = jdbcTemplate.queryForObject(tempSql, Integer.class);
|
|
|
stringObjectMap.put("weishezhishangpinhuodao", number);
|
|
|
//空置率
|
|
|
// tempSql = "SELECT\n" +
|
|
|
// "\tcount(DISTINCT(t.id))\n" +
|
|
|
// "FROM\n" +
|
|
|
// "\tt_mediicinecabinet_inventory t\n" +
|
|
|
// "WHERE\n" +
|
|
|
// "\tt.id_device = '" + stringObjectMap.get("id").toString() + "'\n" +
|
|
|
// "AND t.org_code IS NULL\n" +
|
|
|
// "AND t.drug_code IS NULL\n" +
|
|
|
// "AND (t.state = '1' OR t.state = '21')";
|
|
|
// 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) * 1.0) / normalCargoNumber).setScale(2, BigDecimal.ROUND_HALF_UP));
|
|
|
//上一次补货时间
|
|
|
tempSql = "SELECT\n" +
|
|
|
"\t(\n" +
|
|
@ -2390,7 +2424,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
"\t\t\t0\n" +
|
|
|
"\t\t)\n" +
|
|
|
"\t)";
|
|
|
number = jdbcTemplate.queryForObject(tempSql, Integer.class);
|
|
|
int number = jdbcTemplate.queryForObject(tempSql, Integer.class);
|
|
|
if (number != 0) {
|
|
|
tempSql = "SELECT\n" +
|
|
|
"\tcreate_time\n" +
|
|
@ -2628,7 +2662,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
}
|
|
|
}
|
|
|
String daibuSql = "";
|
|
|
int daibuNumber;
|
|
|
// int daibuNumber;
|
|
|
//当前设备的库存信息-货道容量、药品数量、货道开关状态1开启,0关闭、货道正常故障状态1故障,0正常
|
|
|
String tempConditionSql = "SELECT\n" +
|
|
|
"\tifnull(t.cargo_capacity, 0) AS cargoCapacity,\n" +
|
|
@ -2643,16 +2677,16 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
//设备列表
|
|
|
List<Map<String, Object>> list = hibenateUtils.createSQLQuery(tempConditionSql);
|
|
|
//待补商品数量(待入库药品数量)
|
|
|
daibuSql = "SELECT\n" +
|
|
|
"\tsum(\n" +
|
|
|
"\t\tt.cargo_capacity - cast(t.qty AS UNSIGNED)\n" +
|
|
|
"\t)\n" +
|
|
|
"FROM\n" +
|
|
|
"\tt_mediicinecabinet_inventory t\n" +
|
|
|
"WHERE\n" +
|
|
|
"\tt.id_device = '"+stringObjectMap.get("id").toString()+"'\n" +
|
|
|
"AND (t.state = '1' OR t.state = '21')";
|
|
|
daibuNumber = jdbcTemplate.queryForObject(daibuSql, Integer.class);
|
|
|
// daibuSql = "SELECT\n" +
|
|
|
// "\tsum(\n" +
|
|
|
// "\t\tt.cargo_capacity - cast(t.qty AS UNSIGNED)\n" +
|
|
|
// "\t)\n" +
|
|
|
// "FROM\n" +
|
|
|
// "\tt_mediicinecabinet_inventory t\n" +
|
|
|
// "WHERE\n" +
|
|
|
// "\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);
|
|
|
//newVersion
|
|
|
//所有正常状态货道容量
|
|
@ -2697,7 +2731,6 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
//空置率
|
|
|
// 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()
|
|
@ -2709,7 +2742,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
Integer.parseInt(String.valueOf(item.get("qty"))) > 0).count());
|
|
|
|
|
|
stringObjectMap.put("kongzhilv",
|
|
|
new BigDecimal(((normalCargoNumber-usedCargoNumber) * 100.0) / normalCargoNumber).setScale(2, BigDecimal.ROUND_HALF_UP));
|
|
|
new BigDecimal(((normalCargoNumber-usedCargoNumber) * 1.0) / normalCargoNumber).setScale(2, BigDecimal.ROUND_HALF_UP));
|
|
|
|
|
|
//商品庫存
|
|
|
// Integer inventoryNum = inventoryDao.sumInventoryWithEquNum(stringObjectMap.get("equNum")+"", "1", "21");
|