|
@ -1816,105 +1816,75 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
//总货道(合并货道的算一道)
|
|
|
jsonObject.put("totalCargo", list.size());
|
|
|
|
|
|
//关闭容量
|
|
|
int outOfStock = totalCapacity - closedCapacity - drugNumber;
|
|
|
jsonObject.put("outOfStock", outOfStock);
|
|
|
//缺货库存----end
|
|
|
// tempSql = "SELECT\n" +
|
|
|
// "\tifnull(sum(t.cargo_capacity), 0) AS closedCapacity\n" +
|
|
|
// "\tCOUNT(DISTINCT(t.id))\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);
|
|
|
//故障容量
|
|
|
// "\tt.id_device = '"+device.getId()+"'\n" +
|
|
|
// "and cast(t.qty AS UNSIGNED) < t.num\n" +
|
|
|
// "AND (t.state = '1'\n" +
|
|
|
// "OR t.state = '21')";
|
|
|
// //预警货道
|
|
|
// int earlyWarningCargo = jdbcTemplate.queryForObject(tempSql, Integer.class);
|
|
|
// jsonObject.put("earlyWarningCargo", earlyWarningCargo);
|
|
|
// tempSql = "SELECT\n" +
|
|
|
// "\tifnull(sum(t.cargo_capacity), 0) AS closedCapacity\n" +
|
|
|
// "\tCOUNT(DISTINCT(t.id))\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);
|
|
|
//既关闭又故障的容量
|
|
|
// "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" +
|
|
|
// "\tifnull(sum(t.cargo_capacity), 0) AS closedCapacity\n" +
|
|
|
// "\tCOUNT(DISTINCT(t.id))\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);
|
|
|
//开启的正常的货道的药品数量
|
|
|
// "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" +
|
|
|
// "\tifnull(sum(t.qty), 0) AS closedCapacity\n" +
|
|
|
// "\tCOUNT(DISTINCT(t.id))\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 = totalCapacity - closedCapacity - drugNumber;
|
|
|
jsonObject.put("outOfStock", outOfStock);
|
|
|
//缺货库存----end
|
|
|
tempSql = "SELECT\n" +
|
|
|
"\tCOUNT(DISTINCT(t.id))\n" +
|
|
|
"FROM\n" +
|
|
|
"\tt_mediicinecabinet_inventory t\n" +
|
|
|
"WHERE\n" +
|
|
|
"\tt.id_device = '"+device.getId()+"'\n" +
|
|
|
"and cast(t.qty AS UNSIGNED) < t.num\n" +
|
|
|
"AND (t.state = '1'\n" +
|
|
|
"OR t.state = '21')";
|
|
|
//预警货道
|
|
|
int earlyWarningCargo = jdbcTemplate.queryForObject(tempSql, Integer.class);
|
|
|
jsonObject.put("earlyWarningCargo", earlyWarningCargo);
|
|
|
tempSql = "SELECT\n" +
|
|
|
"\tCOUNT(DISTINCT(t.id))\n" +
|
|
|
"FROM\n" +
|
|
|
"\tt_mediicinecabinet_inventory t\n" +
|
|
|
"WHERE\n" +
|
|
|
"\tt.id_device = '" + device.getId() + "'\n" +
|
|
|
"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" +
|
|
|
"\tCOUNT(DISTINCT(t.id))\n" +
|
|
|
"FROM\n" +
|
|
|
"\tt_mediicinecabinet_inventory t\n" +
|
|
|
"WHERE\n" +
|
|
|
"\tt.id_device = '" + device.getId() + "'\n" +
|
|
|
"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" +
|
|
|
"\tCOUNT(DISTINCT(t.id))\n" +
|
|
|
"FROM\n" +
|
|
|
"\tt_mediicinecabinet_inventory t\n" +
|
|
|
"WHERE\n" +
|
|
|
"\tt.id_device = '" + device.getId() + "'\n" +
|
|
|
"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);
|
|
|
|
|
|
// "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);
|
|
|
|
|
|
//预警货道 关闭货道 开启货道 故障货道 改为同一条sql查询
|
|
|
tempSql = " SELECT " +
|
|
|
" COUNT(DISTINCT(IF(cast(t.qty AS UNSIGNED) < t.num,t.id,null))) as 'earlyWarningCargo', " +
|
|
|
" COUNT(DISTINCT(IF(t.cargo_state = '0',t.id,null))) as 'closedCargo', " +
|
|
|
" COUNT(DISTINCT(IF(t.cargo_state = '1',t.id,null))) as 'openedCargo', " +
|
|
|
" COUNT(DISTINCT(IF(t.fault_state = '1',t.id,null))) as 'faultCargo' " +
|
|
|
"FROM " +
|
|
|
" t_mediicinecabinet_inventory t " +
|
|
|
"WHERE " +
|
|
|
" t.id_device = '"+device.getId()+"' " +
|
|
|
"AND (t.state = '1' " +
|
|
|
"OR t.state = '21') ";
|
|
|
Map<String,Object> map = jdbcTemplate.queryForMap(tempSql);
|
|
|
jsonObject.putAll(map);
|
|
|
//1补货,2换货,3上架,4下架
|
|
|
jsonObject.put("inventoryList",inventoryRecordDao.findMedicineDrugInventoryRecordsByDeviceIdAndEquNumAndType(device.getId(), device.getEquNum(),"1"));
|
|
|
//该接口日志前端未调用,不返回
|
|
|
// jsonObject.put("inventoryList",inventoryRecordDao.findMedicineDrugInventoryRecordsByDeviceIdAndEquNumAndType(device.getId(), device.getEquNum(),"1"));
|
|
|
result.put("response",ConstantUtils.SUCCESS);
|
|
|
result.put("msg",jsonObject);
|
|
|
return result;
|