Browse Source

增加一些设备信息

wangzhinan 3 years ago
parent
commit
639d9c57fb

+ 37 - 29
svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/MedicinedeviceService.java

@ -1258,7 +1258,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
                "FROM\n" +
                "\tt_mediicinecabinet_inventory t\n" +
                "WHERE\n" +
                "\tt.id_device = '\" + device.getId() + \"'\n" +
                "\tt.id_device = '" + device.getId() + "'\n" +
                "and t.cargo_state = '0'\n" +
                "AND (t.state = '1'\n" +
                "OR t.state = '21')";
@ -1823,41 +1823,49 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
            deviceList = hibenateUtils.createSQLQuery(sencodSql);
        }
        for (Map<String, Object> stringObjectMap : deviceList) {
            String tempSql = "SELECT\n" +
                    "\tsum(t.qty)\n" +
            String tempSql = "";
            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" +
                    "\tconcat(IFNULL(t.`id_device`, ''), IFNULL(t.`equ_num`, '')) like '%" + stringObjectMap.get("equNum") +"%'\n" +
                    "AND t.shelf_status = 1";
            //库存
            Integer qty = jdbcTemplate.queryForObject(tempSql, Integer.class);
            qty = qty == null ? 0 : qty;
            stringObjectMap.put("daibuQty", Integer.parseInt(stringObjectMap.get("capacity").toString()) - qty);
                    "\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);
            //未设置商品货道
            tempSql = "SELECT\n" +
                    "\tCOUNT(DISTINCT(id))\n" +
                    "\tcount(DISTINCT(t.id))\n" +
                    "FROM\n" +
                    "\tt_mediicinecabinet_inventory t\n" +
                    "WHERE\n" +
                    "\tconcat(IFNULL(t.`id_device`, ''), IFNULL(t.`equ_num`, '')) like '%" + stringObjectMap.get("equNum") +"%'\n" +
                    "AND t.shelf_status = 0";
            Integer xiajiaQty = jdbcTemplate.queryForObject(tempSql, Integer.class);
            if (xiajiaQty != null) {
                stringObjectMap.put("xiajiaQty", xiajiaQty);
            }
//            tempSql = "select count(distinct(id)) from t_mediicine_stockrecord_detail";
//            tempSql = "SELECT\n" +
//                    "\tcreate_time\n" +
//                    "FROM\n" +
//                    "\tt_mediicine_stockrecord_detail\n" +
//                    "ORDER BY\n" +
//                    "\tcreate_time DESC\n" +
//                    "LIMIT 1";
//            Date buhuoDate = jdbcTemplate.queryForObject(tempSql, Date.class);
//            if (buhuoDate != null) {
//                stringObjectMap.put("buhuoTime", DateUtil.dateToStr(buhuoDate, "yyyy-MM-dd HH:mm:ss" ));
//            }
                    "\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));
            //上一次补货时间
            tempSql = "SELECT\n" +
                    "\tcreate_time\n" +
                    "FROM\n" +
                    "\tt_medicine_drug_inventory_record\n" +
                    "WHERE\n" +
                    "\tdevice_id = '" + stringObjectMap.get("id").toString() + "'\n" +
                    "and type = '1'\n" +
                    "ORDER BY\n" +
                    "\tcreate_time DESC\n" +
                    "LIMIT 1;";
            Date lastBuhuo = jdbcTemplate.queryForObject(tempSql, Date.class);
            stringObjectMap.put("shangyicibuhuoshijian",
                    lastBuhuo== null ? "" : DateUtil.dateToStr(lastBuhuo, "yyyy-MM-dd HH:mm:ss"));
        }
        result.put("response", ConstantUtils.SUCCESS);