Browse Source

物联网url修改

D 2 years ago
parent
commit
3e3a4d3e9f

+ 5 - 0
common/common-entity/sql/2023.sql

@ -0,0 +1,5 @@
-- 数据库 device
ALTER TABLE wlyy_patient_device_location ADD city varchar(20) COMMENT '城市' ;
ALTER TABLE wlyy_patient_device_location ADD city_name varchar(20) COMMENT '城市名称' ;
ALTER TABLE wlyy_patient_device_location ADD town varchar(20) COMMENT '地区' ;
ALTER TABLE wlyy_patient_device_location ADD town_name varchar(20) COMMENT '地区名称' ;

+ 1 - 1
common/common-request-mapping/src/main/java/com/yihu/jw/rm/iot/IotRequestMapping.java

@ -27,7 +27,7 @@ public class IotRequestMapping {
        public static final String workType = api_iot_common + "/workType";
        public static final String hospital = api_iot_common + "/hospital";
        public static final String interfaceAudit = api_iot_common + "/interfaceAudit";
        public static final String monitorPlatform = api_iot_common + "/open/monitorPlatform";//免登录加上open
        public static final String monitorPlatform = api_iot_common + "/monitorPlatform";//免登录加上open
        public static final String sim = api_iot_common + "/sim";
        public static final String openThird = api_iot_common + "/open/gc"; //第三方调用 需要accesstoken
        public static final String getHospital = "/getHospital";

+ 6 - 0
svr/svr-iot/pom.xml

@ -142,6 +142,12 @@
            <version>2.4.6</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>cn.hutool</groupId>
            <artifactId>hutool-all</artifactId>
            <version>5.8.16</version>
        </dependency>
    </dependencies>
    <build>

+ 32 - 2
svr/svr-iot/src/main/java/com/yihu/iot/controller/monitorPlatform/MonitorPlatformController.java

@ -472,6 +472,29 @@ public class MonitorPlatformController extends EnvelopRestEndpoint {
        }
    }
    @ApiOperation("同步设备的街道数据")
    @GetMapping(value = "findLocationByAddress")
    public MixEnvelop findLocationByAddress(){
        try {
            monitorPlatformService.findLocationByAddress();
            return MixEnvelop.getSuccess("同步成功!!");
        }catch (Exception e){
            e.printStackTrace();
            return MixEnvelop.getError("查询失败!");
        }
    }
    @ApiOperation("获取街道数据")
    @GetMapping(value = "getTown")
    public MixEnvelop getTown(){
        try {
            return MixEnvelop.getSuccess("查询成功!!", monitorPlatformService.getTown());
        }catch (Exception e){
            e.printStackTrace();
            return MixEnvelop.getError("查询失败!");
        }
    }
    @GetMapping(value = IotRequestMapping.PatientDevice.findLocationByIdCard)
    @ApiOperation(value = "根据idCard查询设备地址", notes = "根据idCard查询设备地址")
    public MixEnvelop<LocationDataVO, LocationDataVO> findDeviceLocationsByIdCard(
@ -486,7 +509,10 @@ public class MonitorPlatformController extends EnvelopRestEndpoint {
            @ApiParam(name = "page", value = "第几页(默认第一页)", defaultValue = "1")
            @RequestParam(value = "page", required = false) Integer page,
            @ApiParam(name = "pageSize", value = "每页几行(默认10条记录)", defaultValue = "10")
            @RequestParam(value = "pageSize", required = false) Integer pageSize) {
            @RequestParam(value = "pageSize", required = false) Integer pageSize,
            @ApiParam(name = "town", value = "地区")
            @RequestParam(value = "town", required = false) String town
    ) {
        try {
            if (page == null) {
                page = 1;
@ -494,7 +520,11 @@ public class MonitorPlatformController extends EnvelopRestEndpoint {
            if (pageSize == null) {
                pageSize = 10;
            }
            return monitorPlatformService.findDeviceLocations(diseaseCondition, page, pageSize, type, deviceType, monitorPlatformService.getDeviceNameByRequestParam(deviceName));
            return monitorPlatformService.findDeviceLocations(
                    diseaseCondition, page, pageSize, type, deviceType,
                    monitorPlatformService.getDeviceNameByRequestParam(deviceName),
                    town
            );
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError("操作失败");

+ 5 - 15
svr/svr-iot/src/main/java/com/yihu/iot/service/company/IotCompanyService.java

@ -1063,8 +1063,6 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
        companyDO.setAuditMessage(msg);
        companyDO.setAuditName(uname);
        iotCompanyDao.save(companyDO);
        return MixEnvelop.getSuccess("审核操作成功");
    }
@ -1181,22 +1179,14 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
    public JSONObject getAppService(){
        JSONObject object = new JSONObject();
        String str = "SELECT SUM(b.count) count,b.app_name appName\n" +
                "FROM (SELECT COUNT(id) fali,app_name,interface_name FROM xmiot.iot_interface_log  WHERE state=0 GROUP BY app_name,interface_name) c\n" +
                "RIGHT JOIN (SELECT count(id) count,app_name,interface_name,work_type FROM xmiot.iot_interface_log WHERE app_name IS NOT NULL and app_id<>'2c9a80ed72393a3301724abe57ec0032' \n" +
                "GROUP BY app_name,interface_name) b ON c.app_name=b.app_name AND c.interface_name=b.interface_name\n" +
        String str = "SELECT SUM(b.count) count,b.app_name appName FROM " +
                "(SELECT COUNT(id) count,app_name,interface_name FROM xmiot.iot_interface_log " +
                " WHERE state=0 OR (app_name IS NOT NULL and app_id<>'2c9a80ed72393a3301724abe57ec0032' AND app_id <> 'b5125656570011ec8771005056ab2351') " +
                "GROUP BY app_name,interface_name) b\n" +
                "GROUP BY b.app_name ORDER BY count DESC";
        String str1 = "SELECT SUM(b.count) count,b.app_name appName\n" +
                "FROM (SELECT COUNT(id) fali,app_name,interface_name FROM xmiot.iot_interface_log  WHERE state=0 GROUP BY app_name,interface_name) c\n" +
                "RIGHT JOIN (SELECT count(id) count,app_name,interface_name,work_type FROM xmiot.iot_interface_log WHERE app_name IS NOT NULL and app_id<>'2c9a80ed72393a3301724abe57ec0032' \n" +
                "GROUP BY app_name,interface_name) b ON c.app_name=b.app_name AND c.interface_name=b.interface_name\n" +
                "GROUP BY b.app_name ORDER BY count DESC limit 0,3";
        List<AppServiceCount> counts = jdbcTemplate.query(str,new BeanPropertyRowMapper<>(AppServiceCount.class));
        List<AppServiceCount> counts1 = jdbcTemplate.query(str1,new BeanPropertyRowMapper<>(AppServiceCount.class));
        object.put("appcount",counts.size());
        object.put("sortList",counts1);
        object.put("sortList",counts.subList(0,3));
        object.put("medicalcount",40);//目前暂无医疗机构接入,默认0家。
        return object;
    }

+ 96 - 36
svr/svr-iot/src/main/java/com/yihu/iot/service/monitorPlatform/MonitorPlatformService.java

@ -39,6 +39,8 @@ import java.io.IOException;
import java.text.DecimalFormat;
import java.util.*;
import static cn.hutool.core.util.ObjectUtil.hasEmpty;
/**
 * Created by yeshijie on 2020/5/11.
 */
@ -86,7 +88,7 @@ public class MonitorPlatformService {
     * @param diseaseCondition
     * @return
     */
    public MixEnvelop<LocationDataVO, LocationDataVO> findDeviceLocations(Integer diseaseCondition, Integer page, Integer size, String type, String deviceType, String deviceName) throws IOException {
    public MixEnvelop<LocationDataVO, LocationDataVO> findDeviceLocations(Integer diseaseCondition, Integer page, Integer size, String type, String deviceType, String deviceName, String town) throws IOException {
        MixEnvelop<LocationDataVO, LocationDataVO> envelop = new MixEnvelop<>();
        MixEnvelop<LocationDataVO, LocationDataVO> envelopTmp = null;
        Integer total = 0;
@ -96,7 +98,11 @@ public class MonitorPlatformService {
            JSONArray list = json.getJSONArray("list");
            for (int i = 0; i < list.size(); i++) {
                String sql = "select id, idcard idCard,category_code categoryCode,device_sn deviceSn,location,device_time deviceTime,disease_condition diseaseCondition,\n" +
                        "create_time createTime,device_name equimentName from device.wlyy_patient_device_location where del=0 and  device_sn='" + list.getString(i) + "'";
                             "create_time createTime,device_name equimentName from device.wlyy_patient_device_location where del=0 and  device_sn='" + list.getString(i) + "'";
                //判断地区是否等于null
                if (!hasEmpty(town)){
                    sql += "and town ='" + town + "'";
                }
                List<Map<String, Object>> result = jdbcTemplate.queryForList(sql.toString());
                List<LocationDataVO> locationDataVOList = new ArrayList<>();
                result.forEach(map -> {
@ -145,6 +151,10 @@ public class MonitorPlatformService {
                        "from device.wlyy_patient_device_location  ");
                StringBuffer sqlCounts = new StringBuffer("select count(*) from device.wlyy_patient_device_location ");
                StringBuffer sqlCondition = new StringBuffer("where del=0 ");
                //如果地区不为空 则增加地区
                if (!hasEmpty(town)){
                    sqlCondition.append("and town = '" + town + "'" );
                }
                if (diseaseCondition != null) {
                    sqlCondition.append(" and disease_condition =" + diseaseCondition);
                }
@ -1198,7 +1208,7 @@ public class MonitorPlatformService {
     */
    public JSONObject getBrandsAndManufacturer() {
        try {
            String sql = "select count(DISTINCT A.device_name) as total,A.device_name,A.manufacturer from (\n" +
            String sql = "select count(DISTINCT A.device_name) as total,A.device_name, IF(A.manufacturer = '健康之路', '福建健康之路信息技术有限公司',  A.manufacturer) manufacturer from (\n" +
                    "select pd.device_name,wd.manufacturer from wlyy.wlyy_patient_device pd,device.wlyy_devices wd\n" +
                    "where pd.device_sn = wd.device_code and pd.del=0 \n" +
                    "and wd.manufacturer_code is not null and wd.manufacturer_code <>'' and pd.device_name<>'血压计-null' and pd.device_name<>'血糖仪-自助体检一体机'  \n" +
@ -1364,24 +1374,24 @@ public class MonitorPlatformService {
                    Integer usingTmp = 0;
                    Integer totalTmp = 0;
                    Integer stockTmp = 0;
                    if (deviceTypeTmp.contains("5")&&deviceName.contains("健康小屋")){
                        if (org.apache.commons.lang3.StringUtils.isBlank(typeTmp)){
                            typeTmp+="5";
                        }else {
                            typeTmp+=",5";
                    if (deviceTypeTmp.contains("5") && deviceName.contains("健康小屋")) {
                        if (org.apache.commons.lang3.StringUtils.isBlank(typeTmp)) {
                            typeTmp += "5";
                        } else {
                            typeTmp += ",5";
                        }
                        usingTmp +=count;
                        totalTmp +=count;
                        usingTmp += count;
                        totalTmp += count;
                    }
                    if (deviceTypeTmp.contains("22")&&deviceName.contains("智慧药房")){
                        if (org.apache.commons.lang3.StringUtils.isBlank(typeTmp)){
                            typeTmp+="22";
                        }else {
                            typeTmp+=",22";
                    if (deviceTypeTmp.contains("22") && deviceName.contains("智慧药房")) {
                        if (org.apache.commons.lang3.StringUtils.isBlank(typeTmp)) {
                            typeTmp += "22";
                        } else {
                            typeTmp += ",22";
                        }
                        usingTmp +=ygusing;
                        totalTmp +=ygtotal;
                        stockTmp +=ygstock;
                        usingTmp += ygusing;
                        totalTmp += ygtotal;
                        stockTmp += ygstock;
                    }
                    tmp.put("device_name", "组合一体机");
@ -1396,7 +1406,7 @@ public class MonitorPlatformService {
                    /*string用,分割*/
                    String[] arrays = deviceType.split(",");
                    for (String string : arrays) {
                        if ("5".equals(string)&&deviceName.contains("健康小屋")) {
                        if ("5".equals(string) && deviceName.contains("健康小屋")) {
                            /*健康小屋*/
                            tmp.put("device_name", "健康小屋");
                            tmp.put("Subdivision", false);
@ -1407,7 +1417,7 @@ public class MonitorPlatformService {
                            tmp.put("showLevel", Integer.parseInt(showLevel));
                            result.getJSONArray("deviceInfo").add(tmp);
                        }
                        if ("22".equals(string)&&deviceName.contains("智慧药房")) {
                        if ("22".equals(string) && deviceName.contains("智慧药房")) {
                            //智慧药房
                            medicinecabinetCount.put("Subdivision", false);
                            medicinecabinetCount.put("showLevel", Integer.parseInt(showLevel));
@ -1416,15 +1426,15 @@ public class MonitorPlatformService {
                        }
                    }
                }
                if (deviceTypeTmp.contains("5")&&deviceName.contains("健康小屋")){
                    result.put("grantCount", result.getInteger("grantCount") +count);
                if (deviceTypeTmp.contains("5") && deviceName.contains("健康小屋")) {
                    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);//小屋物联
                }
                if (deviceTypeTmp.contains("22")&&deviceName.contains("智慧药房")){
                    result.put("grantCount", result.getInteger("grantCount") +ygtotal);
                if (deviceTypeTmp.contains("22") && deviceName.contains("智慧药房")) {
                    result.put("grantCount", result.getInteger("grantCount") + ygtotal);
                }
            }
@ -1663,7 +1673,7 @@ public class MonitorPlatformService {
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        JSONArray result = new JSONArray();
        for (Map<String, Object> map : list) {
            sql = "select `code`,`value` from xmiot.iot_system_dict where dict_name='DEVICE_TYPE' and del=1 and code!=10 and code!=11  and parent_code='" + map.get("id").toString() + "'";
            sql = "select `code`,`value` from xmiot.iot_system_dict where dict_name='DEVICE_TYPE' AND del=1 AND code!=10 AND code!=11  AND parent_code='" + map.get("id").toString() + "'";
            StringBuffer buffer = new StringBuffer();
            List<Map<String, Object>> reList = jdbcTemplate.queryForList(sql);
            for (Map<String, Object> reMap : reList) {
@ -1673,13 +1683,14 @@ public class MonitorPlatformService {
                buffer.append("," + reMap.get("code").toString());
                result.add(tmp);
            }
            if (org.apache.commons.lang3.StringUtils.isNoneBlank(buffer.toString())) {
                buffer.deleteCharAt(0);
                JSONObject tmp = new JSONObject();
                tmp.put("name", map.get("value").toString());
                tmp.put("code", buffer.toString());
                result.add(tmp);
            }
            //组合一体机 单体征测量仪 数据
//            if (org.apache.commons.lang3.StringUtils.isNoneBlank(buffer.toString())) {
//                buffer.deleteCharAt(0);
//                JSONObject tmp = new JSONObject();
//                tmp.put("name", map.get("value").toString());
//                tmp.put("code", buffer.toString());
//                result.add(tmp);
//            }
        }
        return result;
    }
@ -1729,13 +1740,13 @@ public class MonitorPlatformService {
        if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)) {
            String deviceTypes[] = deviceType.split(",");
            boolean flag = false;
            for(String type : deviceTypes){
                if("1".equals(type)||"2".equals(type)){
            for (String type : deviceTypes) {
                if ("1".equals(type) || "2".equals(type)) {
                    flag = true;
                    break;
                }
            }
            if(flag){
            if (flag) {
                Integer allCount = jdbcTemplate.queryForObject(allCountSql, Integer.class);//单体征总数
                totalAll += allCount;
@ -2038,7 +2049,7 @@ public class MonitorPlatformService {
    }
    /*取药信息*/
    public JSONObject getBuyDrugMessage(String deviceid, String startTime,String endTime) throws Exception {
    public JSONObject getBuyDrugMessage(String deviceid, String startTime, String endTime) throws Exception {
        Map parameterMap = new HashMap<String, String>();
        parameterMap.put("deviceId", deviceid);
        parameterMap.put("startTime", startTime);
@ -2097,5 +2108,54 @@ public class MonitorPlatformService {
        }
    }
    /**
     * 同步病人地址
     *
     * @author cx
     * @date 2023/4/11 16:44
     */
    public void findLocationByAddress() {
        String sql = "SELECT DISTINCT * FROM (" +
                     "SELECT l.patient, h.city, h.city_name, h.town, h.town_name FROM wlyy.wlyy_sign_family f\n" +
                     "INNER JOIN device.wlyy_patient_device_location l \n" +
                     "ON l.patient = f.patient\n" +
                     "INNER JOIN wlyy.dm_hospital h ON h.`code` = f.hospital) sf ";
        List<Map<String, Object>> result = jdbcTemplate.queryForList(sql.toString());
        int num = 0;
        for (Map map: result){
            String patient = (String)map.get("patient");
            //判断 病人不为空
            String town =  (String)map.get("town");
            String townName =  (String)map.get("town_name");
            String update = "UPDATE device.wlyy_patient_device_location " +
                    "SET city = '350200' , city_name = '"+"厦门市"+"',town = '" + town + "' , town_name =  '" + townName + "' " +
                    "WHERE patient = '" + patient + "' ";
            jdbcTemplate.update(update.toString());
//            System.out.println("添加成功!!!!" + num);
            if (num % 300 == 0){
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            num++;
        }
    }
    /**
     * 通过区名称查询 list
     *
     *
     * @return String
     * @author cx
     * @date 2023/4/13 11:07
     */
    public List<Map<String, Object>> getTown() {
        String sql = " SELECT town_name, town FROM wlyy.dm_hospital WHERE city = 350200 GROUP BY town_name ";
        return  jdbcTemplate.queryForList(sql.toString());
    }
}