Browse Source

上次补货时间的bug

wangzhinan 3 years ago
parent
commit
a714b7ce6c

+ 31 - 12
svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/MedicinedeviceService.java

@ -1877,18 +1877,37 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
                    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"));
                    "\t(\n" +
                    "\t\tifnull(\n" +
                    "\t\t\t(\n" +
                    "\t\t\t\tSELECT\n" +
                    "\t\t\t\t\tcount(DISTINCT(id))\n" +
                    "\t\t\t\tFROM\n" +
                    "\t\t\t\t\tt_medicine_drug_inventory_record\n" +
                    "\t\t\t\tWHERE\n" +
                    "\t\t\t\t\tdevice_id = '"+stringObjectMap.get("id").toString()+"'\n" +
                    "\t\t\t),\n" +
                    "\t\t\t0\n" +
                    "\t\t)\n" +
                    "\t)";
            number = jdbcTemplate.queryForObject(tempSql, Integer.class);
            if (number != 0) {
                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"));
            } else {
                stringObjectMap.put("shangyicibuhuoshijian", "");
            }
        }
        result.put("response", ConstantUtils.SUCCESS);