Browse Source

Merge branch 'medicare' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into medicare

wangzhinan 3 years ago
parent
commit
c6eff5411b

+ 1 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/base/BaseRequestMapping.java

@ -201,6 +201,7 @@ public class BaseRequestMapping {
        public static final String getDevicesByReplenishEr  = "/getDevicesByReplenishEr";
        public static final String getDeviceListByUserId  = "/getDeviceListByUserId";
        public static final String getDeviceListWithUserId  = "/getDeviceListWithUserId";
        public static final String getDeviceListByReplenishEr  = "/getDeviceListByReplenishEr";
        public static final String getDeviceInventoryRecordListWithUserId  = "/getDeviceInventoryRecordListWithUserId";
        public static final String getDeviceInventoryRecordListByDeviceId  = "/getDeviceInventoryRecordListByDeviceId";
        public static final String getInitDeviceByPage  = "/getInitDeviceByPage";

+ 25 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/a4endpoint/MedicineDeviceEndpoint.java

@ -531,6 +531,31 @@ public class MedicineDeviceEndpoint extends EnvelopRestEndpoint {
    }
    @GetMapping(value = BaseRequestMapping.BaseDevice.getDeviceListByReplenishEr)
    @ApiOperation(value = "获取设备列表夹带userId", notes = "获取设备列表")
    public PageEnvelop getDeviceListByReplenishEr(@ApiParam(name = "content", value = "搜索内容")
                                               @RequestParam(value = "content", required = false) String content,
                                               @ApiParam(name = "networkStatus", value = "设备网络状态")
                                               @RequestParam(value = "networkStatus", required = false) String networkStatus,
                                               @ApiParam(name = "community", value = "所属社区")
                                               @RequestParam(value = "community", required = false) String community,
                                               @ApiParam(name = "saleStatus", value = "设备销售状态")
                                               @RequestParam(value = "saleStatus", required = false) String saleStatus,
                                               @ApiParam(name = "equType", value = "设备类型")
                                               @RequestParam(value = "equType", required = false) String equType,
                                               @ApiParam(name = "userIds", value = "用户id,多个用英文逗号隔开", required = true)
                                               @RequestParam(value = "userIds") String userIds,
                                               @ApiParam(name = "page", value = "页码", required = true, defaultValue = "1")
                                               @RequestParam(value = "page") int page,
                                               @ApiParam(name = "size", value = "分页大小", required = true, defaultValue = "15")
                                               @RequestParam(value = "size") int size) throws Exception {
        JSONObject result = deviceService.getDeviceListByReplenishEr(content, networkStatus, community,
                saleStatus, equType,
                userIds, page, size);
        return success(result.getJSONArray("msg"), result.getInteger("count"), page, size);
    }
    @GetMapping(value = BaseRequestMapping.BaseDevice.getDeviceInventoryRecordListWithUserId)
    @ApiOperation(value = "获取设备列表and补货记录夹带userId", notes = "获取设备列表and补货记录")
    public PageEnvelop getDeviceInventoryRecordListWithUserId(

+ 13 - 2
svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/MedicineOrderService.java

@ -1607,13 +1607,24 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
        List<Mediicineorder> orders = new ArrayList<>();
        if (!StringUtils.isEmpty(pickUpNum)) {
            mediicineorder = orderDao.findMediicineorderByPickUpNumAndSellStateAndBelongCommunity(pickUpNum, "0",mediicinedevice.getBelongCommunity());
            orders.add(mediicineorder);
            if (mediicineorder == null) {
                //已取药
                mediicineorder = orderDao.findMediicineorderByPickUpNumAndSellStateAndBelongCommunity(pickUpNum, "1",mediicinedevice.getBelongCommunity());
                if (mediicineorder != null) {
                    result.put("msg", "二维码(取药码)已使用");
                    result.put("response", ConstantUtils.FAIL);
                    return result;
                }
            }
            if (mediicineorder != null) {
                orders.add(mediicineorder);
            }
        }
        if (!StringUtils.isEmpty(cardNum)) {
            orders.addAll(orderDao.findMediicineordersBySocialSecurityCardNumAndSellStateAndBelongCommunity(cardNum, "0",mediicinedevice.getBelongCommunity()));
        }
        orders = orders.stream().distinct().collect(Collectors.toList());
        if (orders == null && orders.size() == 0) {
        if (orders == null || orders.size() == 0) {
            result.put("msg", "order doesn't exist");
            result.put("response", ConstantUtils.FAIL);
            return result;

+ 223 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/MedicinedeviceService.java

@ -782,6 +782,16 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
//                        inventory.setNum(copyInventory.getNum());
//                        inventory.setShelfStatus(copyInventory.getShelfStatus());
                        inventory.setState("20");
                        //副货道内容操作-start-------》bug:13570
                        inventory.setQty("0");
                        inventory.setDrugName(null);
                        inventory.setDrugCode(null);
                        inventory.setOrgCode(null);
                        inventory.setPrice(null);
                        //额定库存
                        inventory.setRatedInventory(0);
                        inventory.setShelfStatus("0");
                        //内容操作end
                        inventoryDao.save(inventory);
                    }
                }
@ -2494,6 +2504,219 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
    }
    public JSONObject getDeviceListByReplenishEr(String content,String networkStatus, String community,
                                            String saleStatus,String equType,String userIds, int page, int size) throws Exception {
        JSONObject result = new JSONObject();
        if (StringUtils.isEmpty(userIds)) {
            throw new Exception("未选择补货员");
        }
        String belongCommunitys = "";
        //统计补货员数量
        int length = 0;
        List<String> communityList = new ArrayList<>();
        for (String userId : userIds.split(",")) {
            if (!StringUtils.isEmpty(userId)) {
                length++;
                String sql = "SELECT DISTINCT\n" +
                        "\t(hospital)\n" +
                        "FROM\n" +
                        "\twlyy_user_area\n" +
                        "WHERE\n" +
                        "\tuser_id = '" + userId + "'";
                List<Map<String, Object>> communitys = null;
                communitys = hibenateUtils.createSQLQuery(sql);
                List<String> tempList = new ArrayList<>();
                if (communitys != null) {
                    for (Map<String, Object> stringObjectMap : communitys) {
                        if (stringObjectMap != null && !StringUtils.isEmpty(stringObjectMap.get("hospital") + "")) {
                            if (tempList.indexOf(stringObjectMap.get("hospital") + "") == -1) {
                                tempList.add(stringObjectMap.get("hospital") + "");
                            }
                        }
                    }
                }
                if (communityList.size() == 0) {
                    communityList.addAll(tempList);
                } else {
                    communityList.retainAll(tempList);
                }
            }
        }
        if (communityList.size() == 0) {
            if (length > 1) {
                throw new Exception("补货员之间不存在交叉社区");
            } else {
                throw new Exception("补货员未分配社区");
            }
        }
        String conditionSql = "AND ',"+ String.join(",", communityList) +",' LIKE CONCAT('%,',t.belong_community,',%')\n";
        String sql = "";
        {
            sql += "SELECT\n" +
                    "    t.id AS id,\n" +
                    "    t.belong_community AS belongCommunity,\n" +
                    "    t.community AS community,\n" +
                    "    t.del AS del,\n" +
                    "    t.delivery_address AS deliveryAddress,\n" +
                    "    t.detail_address AS detailAddress,\n" +
                    "    t.equ_area AS equArea,\n" +
                    "    t.equ_class AS equClass,\n" +
                    "    t.equ_info AS equInfo,\n" +
                    "    t.equ_name AS equName,\n" +
                    "    t.equ_num AS equNum,\n" +
                    "    t.equ_type AS equType,\n" +
                    "    t.fbelong_community AS fbelongCommunity,\n" +
                    "    t.machine_code AS machineCode,\n" +
                    "    t.network_status AS networkStatus,\n" +
                    "    t.poweron_test AS poweronTest,\n" +
                    "    t.reg_date AS regDate,\n" +
                    "    t.sale_status AS saleStatus,\n" +
                    "    t.signalintensity AS signalintensity,\n" +
                    "    t.upgr_adesit AS upgrAdesit,\n" +
                    "    t.`status` AS `status`,\n" +
                    "    t.card_status AS cardStatus,\n" +
                    "    t.operator AS operator,\n" +
                    "    t.pack_age AS packAge,\n" +
                    "    t.usage_flow AS usageFlow,\n" +
                    "    t.flow AS flow,\n" +
                    "    t.create_time AS createTime,\n" +
                    "    t.create_user AS createUser,\n" +
                    "    t.create_user_name AS createUserName,\n" +
                    "    t.update_time AS updateTime,\n" +
                    "    t.update_user AS updateUser,\n" +
                    "    t.update_user_name AS updateUserName,\n" +
                    "    t.aisles AS aisles,\n" +
                    "    t.capacity AS capacity,\n" +
                    "    t.ratio AS ratio,\n" +
                    "    t.cargo_capacity AS cargoCapacity,\n" +
                    "    t.layer AS layer,\n" +
                    "    t.wayer AS wayer\n" +
                    "FROM\n" +
                    "    t_mediicine_device AS t\n" +
                    "WHERE 1=1 AND t.del = 1\n";
        }
        if (!StringUtils.isEmpty(content)) {
            conditionSql += "AND CONCAT(IFNULL(t.`equ_num`, ''), IFNULL(t.`equ_name`, '')) like '%" + content +"%'\n";
        }
        if (!StringUtils.isEmpty(networkStatus)) {
            conditionSql += "AND t.network_status = '" + networkStatus +"'\n";
        }
        if (!StringUtils.isEmpty(community)) {
            conditionSql += "AND t.belong_community = '" + community +"'\n";
        }
        if (!StringUtils.isEmpty(saleStatus)) {
            conditionSql += "AND t.sale_status = '" + saleStatus +"'\n";
        }
        if (!StringUtils.isEmpty(equType)) {
            conditionSql += "AND t.equ_type = '" + equType +"'\n";
        }
        conditionSql += "AND t.belong_community IS NOT NULL\n";
        sql = sql + conditionSql;
        List<Map<String, Object>> deviceList = null;
        deviceList = hibenateUtils.createSQLQuery(sql, page, size);
        Map<String, String> equTypeMap = new HashMap<>();
        equTypeMap.put("1", "测试类型1");
        equTypeMap.put("2", "测试类型2");
        equTypeMap.put("3", "测试类型3");
        for (Map<String, Object> stringObjectMap : deviceList) {
            if(!StringUtils.isEmpty(stringObjectMap.get("equType"))){
                stringObjectMap.put("equTypeName", equTypeMap.get(stringObjectMap.get("equType")));
            }
            if(!StringUtils.isEmpty(stringObjectMap.get("networkStatus"))){
                if ("1".equals(stringObjectMap.get("networkStatus").toString())) {
                    stringObjectMap.put("networkStatusName", "在线");
                }
                if ("0".equals(stringObjectMap.get("networkStatus").toString())) {
                    stringObjectMap.put("networkStatusName", "离线");
                }
            }
            if(!StringUtils.isEmpty(stringObjectMap.get("saleStatus"))){
                if ("1".equals(stringObjectMap.get("saleStatus").toString())) {
                    stringObjectMap.put("saleStatusName", "在售");
                }
                if ("2".equals(stringObjectMap.get("saleStatus").toString())) {
                    stringObjectMap.put("saleStatusName", "停售");
                }
                if ("3".equals(stringObjectMap.get("saleStatus").toString())) {
                    stringObjectMap.put("saleStatusName", "故障");
                }
            }
            if(!StringUtils.isEmpty(stringObjectMap.get("cardStatus"))){
                if ("1".equals(stringObjectMap.get("cardStatus").toString())) {
                    stringObjectMap.put("cardStatusName", "正常");
                }
                if ("2".equals(stringObjectMap.get("cardStatus").toString())) {
                    stringObjectMap.put("cardStatusName", "到期");
                }
                if ("3".equals(stringObjectMap.get("cardStatus").toString())) {
                    stringObjectMap.put("cardStatusName", "未知");
                }
            }
            String tempSql = "SELECT\n" +
                    "\tifnull(sum(t.qty), 0) AS qty\n" +
                    "FROM\n" +
                    "\tt_mediicinecabinet_inventory t\n" +
                    "WHERE\n" +
                    "\tt.id_device = '"+ stringObjectMap.get("id") + "" +"'\n" +
                    "AND (t.state = '1' OR t.state = '21')\n" +
                    "AND t.shelf_status = '1'";
            Map<String, Object> tempMap = jdbcTemplate.queryForMap(tempSql);
            int inStock = 0;
            if (tempMap != null) {
                if (tempMap.get("qty") != null) {
                    inStock = (int) Double.parseDouble(tempMap.get("qty") + "");
                }
            }
            //在架库存数
            stringObjectMap.put("shangPinKuCun", inStock);
            //商品庫存
//            Integer inventoryNum = inventoryDao.sumInventoryWithEquNum(stringObjectMap.get("equNum")+"", "1", "21");
            String tempSqlTwo = "SELECT\n" +
                    "\tifnull(\n" +
                    "\t\t(\n" +
                    "\t\t\tSELECT\n" +
                    "\t\t\t\tsum(qty) AS qty\n" +
                    "\t\t\tFROM\n" +
                    "\t\t\t\tt_mediicinecabinet_inventory\n" +
                    "\t\t\tWHERE\n" +
                    "\t\t\t\tequ_num = '"+stringObjectMap.get("equNum")+""+"'\n" +
                    "\t\t\tAND (state = '1' OR state = '21')\n" +
                    "\t\t\tAND drug_code IS NOT NULL\n" +
                    "\t\t\tAND org_code IS NOT NULL\n" +
                    "\t\t),\n" +
                    "\t\t0\n" +
                    "\t) AS qty";
            Map<String, Object> tempMapTwo = jdbcTemplate.queryForMap(tempSqlTwo);
            Integer inventoryNum = 0;
            if (tempMapTwo != null) {
                if (tempMapTwo.get("qty") != null) {
                    inventoryNum = (int) Double.parseDouble(tempMapTwo.get("qty") + "");
                }
            }
            if(inventoryNum == null) inventoryNum = 0;
            stringObjectMap.put("inventoryNum", inventoryNum);
            stringObjectMap.put("warningNum", getEarlyWaringNum(stringObjectMap.get("equNum") + ""));
        }
        String countSql = " select " +
                "     COUNT(DISTINCT (t.id)) as count " +
                "   from " +
                "     t_mediicine_device t " +
                "  where " +
                "  1=1  and t.del = 1  " +
                conditionSql;
        Logger.getAnonymousLogger().info("finalCountSql="+countSql);
        int count = jdbcTemplate.queryForObject(countSql,Integer.class);
        result.put("count", count);
        result.put("msg", JavaBeanUtils.getInstance().mapListJson(deviceList));
        return result;
    }
    public JSONObject getDeviceInventoryRecordListWithUserId(String type,String deviceId, String userId, int page, int size) throws Exception {
        JSONObject result = new JSONObject();