wangzhinan 3 years ago
parent
commit
638758c580

+ 49 - 3
svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/MedicinedeviceService.java

@ -1560,6 +1560,12 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
    }
    /**
     * 通过设备id获取设备信息
     * @param deviceId
     * @return
     * @throws Exception
     */
    public JSONObject getOneDeviceInfo(String deviceId) throws Exception{
        JSONObject result = new JSONObject();
        if(StringUtils.isEmpty(deviceId)){
@ -1575,10 +1581,26 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
        }
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("device",device);
        jsonObject.put("totalCargo", device.getAisles());   //货道合并/解离
        //货道总数----->写死
        String tempSql = "SELECT\n" +
                "\tcount(distinct(t.layer_no)) as layerNum\n" +
                "FROM\n" +
                "\tt_mediicinecabinet_inventory t\n" +
                "WHERE\n" +
                "\tt.id_device = '"+device.getId()+"'";
        int layerNum = jdbcTemplate.queryForObject(tempSql, Integer.class);
        tempSql = "SELECT\n" +
                "\tcount(distinct(t.wayer_no)) as wayerNum\n" +
                "FROM\n" +
                "\tt_mediicinecabinet_inventory t\n" +
                "WHERE\n" +
                "\tt.id_device = '"+device.getId()+"'\n" +
                "AND t.layer_no = '1'";
        int wayerNum = jdbcTemplate.queryForObject(tempSql, Integer.class);
        jsonObject.put("totalCargo", layerNum * wayerNum);
        //设备容量
        jsonObject.put("deviceCapacity", device.getCapacity());
        String tempSql = "SELECT\n" +
        tempSql = "SELECT\n" +
                "\tIFNULL(\n" +
                "\t\t(\n" +
                "\t\t\tSELECT\n" +
@ -1607,7 +1629,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
                "\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);
@ -1635,6 +1657,30 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
        //关闭货道
        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);
        //1补货,2换货,3上架,4下架
        jsonObject.put("inventoryList",inventoryRecordDao.findMedicineDrugInventoryRecordsByDeviceIdAndEquNumAndType(device.getId(), device.getEquNum(),"1"));