소스 검색

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

chenjiasheng 3 년 전
부모
커밋
702ee7e772

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

@ -191,6 +191,7 @@ public class BaseRequestMapping {
        public static final String getDevicesDeliveryList  = "/getDevicesDeliveryList";
        public static final String getDetialOutOfStock  = "/getDetialOutOfStock";
        public static final String getDevInventory  = "/getDevInventory";
        public static final String getDevInventoryByUserId  = "/getDevInventoryByUserId";
        public static final String countall  = "/countall";
        public static final String countAllDevice  = "/countAllDevice";
        public static final String countOnline  = "/countOnline";

+ 29 - 14
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/a4endpoint/MedicineDeviceEndpoint.java

@ -423,7 +423,7 @@ public class MedicineDeviceEndpoint extends EnvelopRestEndpoint {
                                               @ApiParam(name = "equType", value = "设备类型")
                                               @RequestParam(value = "equType", required = false) String equType,
                                               @ApiParam(name = "userId", value = "用户id", required = true)
                                                   @RequestParam(value = "userId") String userId,
                                               @RequestParam(value = "userId") String userId,
                                               @ApiParam(name = "page", value = "页码", required = true, defaultValue = "1")
                                               @RequestParam(value = "page") int page,
                                               @ApiParam(name = "size", value = "分页大小", required = true, defaultValue = "15")
@ -437,19 +437,19 @@ public class MedicineDeviceEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = BaseRequestMapping.BaseDevice.getInitDeviceByPage)
    @ApiOperation(value = "获取初始化设备分页列表", notes = "获取初始化设备分页列表")
    public PageEnvelop getInitDeviceByPage(@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 = "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 {
                                           @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 = "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.getInitDeviceByPage(content, networkStatus, community,
                saleStatus, equType,
                page, size);
@ -479,6 +479,21 @@ public class MedicineDeviceEndpoint extends EnvelopRestEndpoint {
        return success(jsonObject.getJSONArray("msg"));
    }
    @GetMapping(value = BaseRequestMapping.BaseDevice.getDevInventoryByUserId)
    @ApiOperation(value = "获取设备库存", notes = "获取设备库存")
    public Envelop getDevInventoryByUserId (
            @ApiParam(name = "belongCommunity", value = "社区")
            @RequestParam(value = "belongCommunity", required = false) String belongCommunity,
            @ApiParam(name = "deviceId", value = "所属设备")
            @RequestParam(value = "deviceId", required = false) String deviceId,
            @ApiParam(name = "networkStatus", value = "网络状态")
            @RequestParam(value = "networkStatus", required = false) String networkStatus,
            @ApiParam(name = "userId", value = "用户id", required = true)
            @RequestParam(value = "userId") String userId) throws Exception {
        JSONObject result = deviceService.getDevInventoryByUserId(belongCommunity, deviceId, networkStatus, userId);
        return success(result.getJSONArray("msg"));
    }
    @GetMapping(value = BaseRequestMapping.BaseDevice.getDevicesDeliveryList)
    @ApiOperation(value = "设备投放地址列表", notes = "获取设备投放地址列表")
    public ListEnvelop getDevicesDelivery(

+ 232 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/MedicinedeviceService.java

@ -1645,7 +1645,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
                }
            }
            //模拟补货员未绑定设备
            deviceIds = "";
//            deviceIds = "";
            conditionSql  = "AND ',"+ deviceIds +",' LIKE CONCAT('%,',t.id,',%')\n";
        } else {
@ -2313,6 +2313,237 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
        return result;
    }
    /**
     * 获取设备库存,有携带userId
     * @param belongCommunity
     * @param deviceId
     * @param networkStatus
     * @param userId
     * @return
     * @throws Exception
     */
    public JSONObject getDevInventoryByUserId(String belongCommunity, String deviceId, String networkStatus,String userId) throws Exception {
        JSONObject result = new JSONObject();
        UserDO user = userDao.findOne(userId);
        RoleDO role = roleDao.findOne(user.getRoleId());
        List<Map<String, Object>> deviceList = null;
        //查询控制语句
        String conditionSql = "";
        if ("replenisher".equals(role.getCode())) {
            //补货员所分配的设备
            String deviceIds = "";
            {
                String sql = "SELECT\n" +
                        "\tdevice_id\n" +
                        "FROM\n" +
                        "\tt_mediicine_device_user\n" +
                        "WHERE\n" +
                        "\tuser_id = '" + userId +"'\n" +
                        "AND del = 1";
                //设备列表
                List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql);
                for (Map<String, Object> stringObjectMap : list) {
                    if (stringObjectMap.get("device_id") != null && !StringUtils.isEmpty(stringObjectMap.get("device_id").toString())) {
                        if (StringUtils.isEmpty(deviceIds)) {
                            deviceIds += stringObjectMap.get("device_id").toString();
                        } else {
                            deviceIds += "," +  stringObjectMap.get("device_id").toString();
                        }
                    }
                }
            }
            //模拟补货员未绑定设备
//            deviceIds = "";
            conditionSql  = "AND ',"+ deviceIds +",' LIKE CONCAT('%,',t.id,',%')\n";
        } else {
            String belongCommunitys = "";
            String tempSql = "";
            //获取管理员所在社区id字符串
            {
                //市管理员
                if ("saasAdmin".equals(role.getCode())) {
                    tempSql = "SELECT\n" +
                            "\tid\tas community\n" +
                            "FROM\n" +
                            "\tdm_hospital\n" +
                            "WHERE\n" +
                            "\tdel = 1";
                }
                //区域管理员
                if ("regionAdmin".equals(role.getCode())) {
                    tempSql = "SELECT\n" +
                            "\tdh.id AS community\n" +
                            "FROM\n" +
                            "\twlyy_user_area t\n" +
                            "LEFT JOIN dm_hospital dh ON t.town = dh.town\n" +
                            "WHERE\n" +
                            "\tt.user_id = '" + userId + "'\n" +
                            "AND t.del = 1\n" +
                            "AND dh.del = 1";
                }
                //社区管理员
                if ("communityAdmin".equals(role.getCode())) {
                    tempSql = "SELECT\n" +
                            "t.hospital AS community\n" +
                            "FROM\n" +
                            "wlyy_user_area AS t\n" +
                            "WHERE\n" +
                            "t.user_id = '" + userId + "'\n" +
                            "AND t.del = 1";
                }
                List<Map<String, Object>> list = hibenateUtils.createSQLQuery(tempSql);
                for (Map<String, Object> stringObjectMap : list) {
                    if (stringObjectMap.get("community") != null && !StringUtils.isEmpty(stringObjectMap.get("community").toString())) {
                        if (StringUtils.isEmpty(belongCommunitys)) {
                            belongCommunitys += stringObjectMap.get("community").toString();
                        } else {
                            belongCommunitys += "," +  stringObjectMap.get("community").toString();
                        }
                    }
                }
            }
            if (!StringUtils.isEmpty(belongCommunitys)) {
                conditionSql += "AND ',"+ belongCommunitys +",' 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(networkStatus)) {
            conditionSql += "AND t.network_status = '" + networkStatus +"'\n";
        }
        if (!StringUtils.isEmpty(belongCommunity)) {
            conditionSql += "AND t.belong_community = '" + belongCommunity +"'\n";
        }
        if (!StringUtils.isEmpty(deviceId)) {
            conditionSql += "AND t.id = '" + deviceId +"'\n";
        }
        conditionSql += "AND t.belong_community IS NOT NULL\n";
        sql = sql + conditionSql;
        deviceList = hibenateUtils.createSQLQuery(sql);
        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" +
                    "t.id AS id,\n" +
                    "t.id_device AS idDevice,\n" +
                    "t.num AS num,\n" +
                    "t.sku AS sku,\n" +
                    "t.state AS state,\n" +
                    "t.longtime AS longtime,\n" +
                    "t.drug_id AS drugId,\n" +
                    "t.drug_sku AS drugSku,\n" +
                    "t.drug_code AS drugCode,\n" +
                    "t.org_code AS orgCode,\n" +
                    "t.layer_no AS layerNo,\n" +
                    "t.wayer_no AS wayerNo,\n" +
                    "t.qty AS qty,\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.drug_name AS drugName,\n" +
                    "t.cargo_capacity AS cargoCapacity,\n" +
                    "t.shelf_status AS shelfStatus,\n" +
                    "t.price AS price,\n" +
                    "t.pic AS pic,\n" +
                    "t.equ_num AS equNum,\n" +
                    "t.`merge` AS `merge`" +
                    "FROM\n" +
                    "\tt_mediicinecabinet_inventory t\n" +
                    "WHERE\n" +
                    "\tt.id_device = '" + stringObjectMap.get("id").toString() + "'\n" +
                    "AND t.equ_num = '" + stringObjectMap.get("equNum").toString() + "'\n" +
                    "AND (t.state = '1' OR t.state = '21')";
            List<Map<String, Object>> inventoryList = hibenateUtils.createSQLQuery(sql);
            stringObjectMap.put("children", inventoryList);
        }
        result.put("msg", JavaBeanUtils.getInstance().mapListJson(deviceList));
        return result;
    }
    /**
     * 获取社区投放地址