wushilong 3 lat temu
rodzic
commit
1c7ab72cfa

+ 22 - 9
svr/svr-iot/src/main/java/com/yihu/iot/controller/monitorPlatform/MonitorPlatformController.java

@ -803,8 +803,8 @@ public class MonitorPlatformController extends EnvelopRestEndpoint {
    @GetMapping(value = "/getEquipmentStatistics")
    @ApiOperation("设备库存、使用数、总备案、失联率、物联率")
    public Envelop getEquipmentStatistics(@RequestParam(value = "deviceType", required = true, defaultValue = "1,2,5")
                                          @ApiParam(name = "deviceType", value = "设备类型,1血糖仪,2血压计,5健康小屋", required = true) String deviceType,
    public Envelop getEquipmentStatistics(@RequestParam(value = "deviceType", required = true, defaultValue = "1,2,5,22")
                                          @ApiParam(name = "deviceType", value = "设备类型,1血糖仪,2血压计,5健康小屋,22智慧药房", required = true) String deviceType,
                                          @RequestParam(value = "deviceName", required = false, defaultValue = "")
                                          @ApiParam(name = "deviceName", value = "设备名称(品牌)", required = false) String deviceName,
                                          @RequestParam(value = "showLevel", defaultValue = "0")
@ -1078,28 +1078,41 @@ public class MonitorPlatformController extends EnvelopRestEndpoint {
    @ApiOperation("获取药柜数量")
    @RequestMapping(value = "getMedicinecabinetCount", method = {RequestMethod.GET})
    public ObjEnvelop getMedicinecabinetCount() {
        Map<String, String> map = monitorPlatformService.getMedicinecabinetCount();
        Map<String, Object> map = monitorPlatformService.getMedicinecabinetCount();
        return ObjEnvelop.getSuccess("查询成功", map);
    }
    @ApiOperation("获取药柜详细信息")
    @RequestMapping(value = "getMedicineCabinetDetails", method = {RequestMethod.GET})
    @RequestMapping(value = "getMedicineCabinetDetails", method = {RequestMethod.POST})
    public ObjEnvelop getMedicineCabinetDetails(@ApiParam(name = "deviceid", defaultValue = "设备id")
                               @RequestParam(value = "deviceid", required = true) String deviceid,
                               @ApiParam(name = "day", defaultValue = "天数")
                               @RequestParam(value = "day", required = true) String day) {
                                                @RequestParam(value = "deviceid", required = true) String deviceid) {
        try {
            /*808080eb7da2717d017da2cdc43e003e*/
            Map<String, List<Map>> getadddd = monitorPlatformService.getadddd(deviceid, day);
            Map<String, List<Map>> getadddd = monitorPlatformService.getadddd(deviceid, "365");
            return ObjEnvelop.getSuccess("成功", getadddd, 200);
        } catch (Exception e) {
            return ObjEnvelop.getError("失败" + e.getMessage());
        }
    }
    @ApiOperation("获取药柜详细曲线信息")
    @RequestMapping(value = "getCabinetCurve", method = {RequestMethod.POST})
    public ObjEnvelop getCabinetCurve(@ApiParam(name = "deviceid", defaultValue = "设备id")
                                      @RequestParam(value = "deviceid", required = true) String deviceid,
                                      @ApiParam(name = "day", defaultValue = "天数")
                                      @RequestParam(value = "day", required = false) String day) {
        try {
            Map<String, List<Map>> cabinetCurve = monitorPlatformService.getCabinetCurve(deviceid, day);
            return ObjEnvelop.getSuccess("成功",cabinetCurve,200);
        } catch (Exception e) {
            return ObjEnvelop.getError("失败" + e.getMessage());
        }
    }
    @ApiOperation("获取药柜地标")
    @RequestMapping(value = "getLongitudeAndLatitude", method = {RequestMethod.GET})
    public ObjEnvelop getLongitudeAndLatitude(){
    public ObjEnvelop getLongitudeAndLatitude() {
        try {
            List<Map<String, Object>> longitudeAndLatitude = monitorPlatformService.getLongitudeAndLatitude();
            return ObjEnvelop.getSuccess("成功", longitudeAndLatitude, 200);

+ 83 - 43
svr/svr-iot/src/main/java/com/yihu/iot/service/monitorPlatform/MonitorPlatformService.java

@ -1341,30 +1341,52 @@ public class MonitorPlatformService {
                Integer lostContact = jdbcTemplate.queryForObject(sql.toString(), Integer.class);
                result.put("lostContact", lostContact);
            }
            //deviceType包含小屋且设备名称为空||deviceType包含小屋且设备名称为健康小屋。
            if ((deviceType.contains("5") && org.apache.commons.lang3.StringUtils.isBlank(deviceName)) || (deviceType.contains("5") && org.apache.commons.lang3.StringUtils.isNoneBlank(deviceName) && deviceName.contains("健康小屋"))) {
            if ((deviceType.contains("5") && org.apache.commons.lang3.StringUtils.isBlank(deviceName))
                    || (deviceType.contains("5") && org.apache.commons.lang3.StringUtils.isNoneBlank(deviceName) && deviceName.contains("健康小屋"))
                    || (deviceType.contains("22") && org.apache.commons.lang3.StringUtils.isBlank(deviceName))
                    || (deviceType.contains("22") && org.apache.commons.lang3.StringUtils.isNoneBlank(deviceName) && deviceName.contains("智慧药房"))
            ) {
                String sql = "select COUNT(*) from xmiot.iot_equipmet_detail";
                /*取到智慧药柜*/
                Map<String, Object> medicinecabinetCount = getMedicinecabinetCount();
                //智慧药柜
                int ygtotal = Integer.parseInt(medicinecabinetCount.get("total").toString());
                int ygusing = Integer.parseInt(medicinecabinetCount.get("using").toString());
                int ygstock = Integer.parseInt(medicinecabinetCount.get("stock").toString());
                Integer count = jdbcTemplate.queryForObject(sql, Integer.class);
                JSONObject tmp = new JSONObject();
                tmp.put("using", count);
                tmp.put("total", count);
                tmp.put("using", count + ygusing);
                tmp.put("total", count + ygtotal);
                tmp.put("type", "5");
                tmp.put("stock", 0);
                tmp.put("stock", 0 + ygstock);
                if ("0".equals(showLevel)) {
                    tmp.put("device_name", "组合一体机");
                    tmp.put("Subdivision", true);
                } else {
                    tmp.put("device_name", "健康小屋");
                    tmp.put("Subdivision", false);
                    //智慧药柜
                    medicinecabinetCount.put("Subdivision", false);
                    medicinecabinetCount.put("showLevel", 1);
                    result.getJSONArray("deviceInfo").add(medicinecabinetCount);
                    result.put("grantCount", result.getInteger("grantCount") + count);
                }
                tmp.put("showLevel", Integer.parseInt(showLevel));
                result.getJSONArray("deviceInfo").add(tmp);
                result.put("grantCount", result.getInteger("grantCount") + count);
                //统计健康小屋数据/ 小屋全部统计为正常使用
                sql = "select count(*) from xmiot.iot_equipmet_detail where device_code in (select DISTINCT sn device_model from xmiot.wlyy_iot_m)";
                count = jdbcTemplate.queryForObject(sql, Integer.class);
                result.put("iotCount", result.getInteger("iotCount") + count);//小屋物联
            }
            arrTmp = result.getJSONArray("deviceInfo");
            for (int i = 0; i < arrTmp.size(); i++) {
                JSONObject tmp = arrTmp.getJSONObject(i);
@ -1625,6 +1647,8 @@ public class MonitorPlatformService {
                sql.append("and belong_are_code='" + area + "' ");
            }
            Integer tmp = jdbcTemplate.queryForObject(sql.toString(), Integer.class);
            totalAll += tmp;
            grant += tmp;
        }
@ -1776,7 +1800,7 @@ public class MonitorPlatformService {
    }
    /*获取药柜所有设备信息  地址  编号  名字*/
    public List<Map<String,String>> getMedicinecabinet() {
    public List<Map<String, String>> getMedicinecabinet() {
        JSONArray resultArr = new JSONArray();
        List<Map<String, String>> list = new ArrayList<>();
        try {
@ -1790,13 +1814,19 @@ public class MonitorPlatformService {
                resultMap.put("equName", equName);
                /*获取设备地址*/
                String deliveryAddress = jsonObject.getString("deliveryAddress");
                resultMap.put("deliveryAddress;", deliveryAddress);
                resultMap.put("deliveryAddress", deliveryAddress);
                /*获取设备编号*/
                String equNum = jsonObject.getString("equNum");
                resultMap.put("equNum", equNum);
                /*获取设备编号*/
                String id = jsonObject.getString("id");
                resultMap.put("id", id);
                /*投放经度*/
                String lng = jsonObject.getString("lng");
                resultMap.put("lng", lng);
                /*投放纬度*/
                String lat = jsonObject.getString("lat");
                resultMap.put("lat", lat);
                list.add(resultMap);
            }
            return list;
@ -1806,8 +1836,8 @@ public class MonitorPlatformService {
        }
    }
    /*总数*/
    public Map<String, String> getMedicinecabinetCount() {
    /*药柜总数*/
    public Map<String, Object> getMedicinecabinetCount() {
        Map resultMap = new HashMap<>();
        JSONObject jsonObject = getUrl("/open/noLogin/getDeviceList", null);
@ -1819,44 +1849,25 @@ public class MonitorPlatformService {
        String usedTotal = jsonObject.get("usedTotal").toString();
        resultMap.put("total", total);
        resultMap.put("notUsedTotal", notUsedTotal);
        resultMap.put("usedTotal", usedTotal);
        resultMap.put("stock", notUsedTotal);
        resultMap.put("using", usedTotal);
        resultMap.put("device_name", "智慧药柜");
        return resultMap;
    }
    /*获取药柜详细信息*/
    public Map<String, List<Map>> getadddd(String deviceid, String day) throws Exception {
    public Map<String, List<Map>> getadddd(String deviceId, String day) throws Exception {
        //返回参数
        Map<String, List<Map>> resoultMap = new HashMap<>();
        //参数加密
        Map parameterMap = new HashMap<String, String>();
        parameterMap.put("deviceId", deviceid);
        parameterMap.put("deviceId", deviceId);
        parameterMap.put("day", day);
        String content = com.alibaba.fastjson.JSONObject.toJSONString(parameterMap);
        String params = AesEncryptUtils.agEncrypt(content);
        JSONObject jsonObject = getUrl("/open/noLogin/getDeviceInfo", params);
        //医保曲线
        JSONArray yibaoArray = jsonObject.getJSONArray("yibaoList");
        /*for (int i = 0; i < yibaoList.size(); i++) {
            Map listMap = new HashMap<>();
            JSONObject yibaoListJSONObject = yibaoList.getJSONObject(i);
            String date = yibaoListJSONObject.getString("date");
            String avg = yibaoListJSONObject.getString("avg");
            String count = yibaoListJSONObject.getString("count");
            listMap.put("date",date);
            listMap.put("avg",avg);
            listMap.put("count",count);
            yibaoListMap.add(listMap);
        }
        */
        List<Map> yibaoList = JSONObject.parseArray(yibaoArray.toJSONString(), Map.class);
        //扫码曲线获取
        JSONArray saomaArray = jsonObject.getJSONArray("saomaList");
        List<Map> saomaList = JSONObject.parseArray(yibaoArray.toJSONString(), Map.class);
        //取药列表获取
        List<Map> mediicineorderListMap = new ArrayList<>();
        JSONArray mediicineorderList = jsonObject.getJSONArray("mediicineorderList");
@ -1880,7 +1891,7 @@ public class MonitorPlatformService {
        //设备名称
        deviceListMapObject.put("equName", deviceObject.getString("equName"));
        //设备地址
        deviceListMapObject.put("detailAddress", deviceObject.getString("detailAddress"));
        deviceListMapObject.put("deliveryAddress", deviceObject.getString("deliveryAddress"));
        //设备编号
        deviceListMapObject.put("equNum", deviceObject.getString("equNum"));
        //湿度
@ -1895,21 +1906,49 @@ public class MonitorPlatformService {
        List<Map> shippingTypeList = JSONObject.parseArray(shippingTypeArray.toJSONString(), Map.class);
        //医保曲线存放
        resoultMap.put("yibaoList", yibaoList);
        //扫码曲线存放
        resoultMap.put("saomaListMap", saomaList);
        //取药列表存放
        resoultMap.put("mediicineorderListMap", mediicineorderListMap);
        resoultMap.put("mediicineorderList", mediicineorderListMap);
        //设备信息存放
        resoultMap.put("deviceList", deviceListMap);
        //取药方式存放
        resoultMap.put("shippingTypeListMap", shippingTypeList);
        resoultMap.put("shippingTypeTotal", shippingTypeList);
        return resoultMap;
    }
    /*获取药柜曲线图信息*/
    public Map<String, List<Map>> getCabinetCurve(String deviceId, String day) throws Exception {
        if ("".equals(day) || day == null) {
            day = "365";
        }
        //返回参数
        Map<String, List<Map>> resoultMap = new HashMap<>();
        //参数加密
        Map parameterMap = new HashMap<String, String>();
        parameterMap.put("deviceId", deviceId);
        parameterMap.put("day", day);
        String content = com.alibaba.fastjson.JSONObject.toJSONString(parameterMap);
        String params = AesEncryptUtils.agEncrypt(content);
        JSONObject jsonObject = getUrl("/open/noLogin/getDeviceInfo", params);
        //医保曲线
        JSONArray yibaoArray = jsonObject.getJSONArray("yibaoList");
        List<Map> yibaoList = JSONObject.parseArray(yibaoArray.toJSONString(), Map.class);
        //扫码曲线获取
        JSONArray saomaArray = jsonObject.getJSONArray("saomaList");
        List<Map> saomaList = JSONObject.parseArray(yibaoArray.toJSONString(), Map.class);
        //医保曲线存放
        resoultMap.put("yibaoList", yibaoList);
        //扫码曲线存放
        resoultMap.put("saomaList", saomaList);
        return resoultMap;
    }
    /*药柜地标*/
    public List<Map<String,Object>> getLongitudeAndLatitude(){
    public List<Map<String, Object>> getLongitudeAndLatitude() {
        JSONArray resultArr = new JSONArray();
        List<Map<String, Object>> list = new ArrayList<>();
        try {
@ -1924,6 +1963,9 @@ public class MonitorPlatformService {
                /*投放纬度*/
                String lat = jsonObject.getString("lat");
                resultMap.put("lat;", lat);
                /*id*/
                String id = jsonObject.getString("id");
                resultMap.put("id;", id);
                list.add(resultMap);
            }
            return list;
@ -1934,8 +1976,6 @@ public class MonitorPlatformService {
    }
    /*请求接口*/
    public JSONObject getUrl(String url, String parame) {
        JSONObject resultObj = new JSONObject();