Browse Source

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

wangjun 4 years ago
parent
commit
00cc733c36

+ 18 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java

@ -5971,6 +5971,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                "outpatient.mobile AS \"outpatient_mobile\"," +
                "room.consult_type AS \"consult_type\"," + condition +
                "room.reservation_type AS \"reservation_type\"," +
                "outpatient.patient_name AS \"outPatientName\"," +
                "outpatient.patient AS \"outPatient\"," +
                "outpatient.disease_img AS \"disease_img\"," +
                "outpatient.description AS \"description\"," +
                "outpatient.origin_con_no AS \"origin_con_no\"," +
@ -6019,6 +6021,20 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                String idcard = (String) outpatient.get("idcard");
                String patient_id = (String) outpatient.get("patient_id");
                outpatient.put("age", DateUtil.getAgeForIdcard(idcard));
                int patientAge = 0;
                int patientSex = 3;
                if (null!=outpatient.get("outPatient")){
                    BasePatientDO basePatientDO = basePatientDao.findById(outpatient.get("outPatient").toString());
                    if (null!=basePatientDO){
                        if (StringUtils.isNotBlank(basePatientDO.getIdcard())){
                            patientAge = DateUtil.getAgeForIdcard(basePatientDO.getIdcard());
                            outpatient.put("patientAge", DateUtil.getAgeForIdcard(basePatientDO.getIdcard()));
                            patientSex =basePatientDO.getSex();
                        }
                    }
                }
                outpatient.put("patientAge", patientAge);
                outpatient.put("patientSex", patientSex);
                String group_date = (String) outpatient.get("group_date");
@ -7761,6 +7777,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                            free = res.getString("@total_charge");
                        }
                        ylzPayService.msgPush("01", cardNo, "01", patientDO.getMobile(), "00", userNo, userName, idcard, voucherNo, applyDepaName, applyDoctorName, recipeTime, free, "1");
                    }else {
                        throw new Exception(map.get("mes").toString());
                    }
                    //sendHisDiagnosis(jsonData, outpatientDO, wlyyPrescriptionDO);

+ 1 - 1
business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java

@ -908,7 +908,7 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
    /**
     *
     * 中山医院统一支付
     * 易联众统一支付
     *
     * @param relationCode
     * @param relationName

+ 10 - 3
business/base-service/src/main/java/com/yihu/jw/wlyy/service/WlyyBusinessService.java

@ -300,19 +300,26 @@ public class WlyyBusinessService {
                        patientMedicareCardDO.setDel("1");
                        patientMedicareCardDO.setRemark(cardTypeName);
                        patientMedicareCardDao.save(patientMedicareCardDO);
                    }else {
                        if (patientMedicareCardDO.getType().equalsIgnoreCase("A_01")){
                            patientCardNo = patientMedicareCardDO.getCode();
                        }
                    }
                }
            }else {
                //TODO
            }
            if (!StringUtils.isNoneBlank(patientCardNo)){
                return "社保卡不能为空!";
            }
            //查询i健康信息,没有就注册;
            Map<String,String> patientSccParams = new HashMap<>();
            patientSccParams.put("scc",patientCardNo);
            patientSccParams.put("ssc",patientCardNo);
            patientSccParams.put("name",basePatientDO.getName());
            patientSccParams.put("idCard",basePatientDO.getIdcard());
            patientSccParams.put("sex",basePatientDO.getSex().toString());
            patientSccParams.put("phone",basePatientDO.getPhone());
            patientSccParams.put("birthday",basePatientDO.getBirthday().toString());
            patientSccParams.put("phone",basePatientDO.getMobile());
            patientSccParams.put("birthday",DateUtil.dateToStrShort(basePatientDO.getBirthday()));
            JSONObject object = wlyyHttpService.sendWlyyMes("wlyyFindAccountBySsc", null, patientSccParams);

+ 3 - 1
gateway/ag-basic/src/main/java/com/yihu/jw/gateway/filter/PostFilter.java

@ -63,8 +63,10 @@ public class PostFilter extends ZuulFilter {
            url.contains("/open/noLogin/getSFExpressInfoNew")||
            url.contains("/open/noLogin/sfroutepushservice")||
            url.contains("/open/noLogin/ylzSettleRecord")||
                url.contains("/weixin"))){
                url.contains("/weixin")||url.contains("/oauth/getSsoPublicKey"))){
            RequestContext.getCurrentContext().setResponseBody(object.toJSONString());
        }else {
            RequestContext.getCurrentContext().setResponseBody(body);
        }
        logger.info(ctx.getResponseBody()+"");
        } catch (Exception e) {

+ 59 - 3
svr/svr-iot/src/main/java/com/yihu/iot/controller/monitorPlatform/MonitorPlatformController.java

@ -206,7 +206,9 @@ public class MonitorPlatformController extends EnvelopRestEndpoint {
            @ApiParam(name="area",value="地区",defaultValue = "")
            @RequestParam(value="area",required = false) String area,
            @ApiParam(name="hospital",value="机构",defaultValue = "")
            @RequestParam(value="hospital",required = false) String hospital){
            @RequestParam(value="hospital",required = false) String hospital,
            @ApiParam(name="deviceName",value = "设备名称(品牌)",required = false)
            @RequestParam(value = "deviceName",required = false,defaultValue = "")String deviceName){
        try {
            if(page==null){
                page = 1;
@ -215,7 +217,7 @@ public class MonitorPlatformController extends EnvelopRestEndpoint {
                pageSize = 20;
            }
            return MixEnvelop.getSuccess("查询成功",monitorPlatformService.warningInformationAlarm_new(page,pageSize,startTime,endTime,deviceType,area,hospital));
            return MixEnvelop.getSuccess("查询成功",monitorPlatformService.warningInformationAlarm_new(page,pageSize,startTime,endTime,deviceType,area,hospital,deviceName));
        }catch (Exception e){
            e.printStackTrace();
            return MixEnvelop.getError("查询失败");
@ -353,6 +355,27 @@ public class MonitorPlatformController extends EnvelopRestEndpoint {
        }
    }
    @RequestMapping(value="getTotalRange",method = RequestMethod.GET)
    @ApiOperation("96使用率,86绑定率,88指导率,慢病患者设备使用率,慢病患者设备覆盖率整合")
    public MixEnvelop getTotalRange(@ApiParam(name="startTime",value="开始时间yyyy-MM-dd",defaultValue = "")
                                        @RequestParam(value="startTime",required = false) String startTime,
                                    @ApiParam(name="endTime",value="结束时间",defaultValue = "")
                                        @RequestParam(value="endTime",required = false) String endTime,
                                    @ApiParam(name="deviceType",value="设备类型",defaultValue = "")
                                        @RequestParam(value="deviceType",required = false) String deviceType,
                                    @ApiParam(name="area",value="地区",defaultValue = "")
                                        @RequestParam(value="area",required = false) String area,
                                    @ApiParam(name="hospital",value="机构",defaultValue = "")
                                        @RequestParam(value="hospital",required = false) String hospital){
        try {
            return MixEnvelop.getSuccess("查询成功",monitorPlatformService.getTotalRange(startTime,endTime,deviceType,area,hospital));
        }catch (Exception e){
            e.printStackTrace();
            return MixEnvelop.getError("查询失败");
        }
    }
    @RequestMapping(value = "/diseaseUseRange",method = RequestMethod.GET)
    @ApiOperation("慢病患者设备使用率")
    public MixEnvelop diseaseUseRange(
@ -449,6 +472,8 @@ public class MonitorPlatformController extends EnvelopRestEndpoint {
            @RequestParam(value = "type",required = false) String type,
            @ApiParam(name="deviceType",value="设备类型 对应设备字典库的DEVICE_TYPE值",required = true)
            @RequestParam(value="deviceType",required = true) String deviceType,
            @ApiParam(name="deviceName",value = "设备名称(品牌)",required = false)
            @RequestParam(value = "deviceName",required = false,defaultValue = " ")String deviceName,
            @ApiParam(name="page",value="第几页(默认第一页)",defaultValue = "1")
            @RequestParam(value="page",required = false) Integer page,
            @ApiParam(name="pageSize",value="每页几行(默认10条记录)",defaultValue = "10")
@ -460,7 +485,7 @@ public class MonitorPlatformController extends EnvelopRestEndpoint {
            if(pageSize==null){
                pageSize = 10;
            }
            return monitorPlatformService.findDeviceLocations(diseaseCondition,page,pageSize,type,deviceType);
            return monitorPlatformService.findDeviceLocations(diseaseCondition,page,pageSize,type,deviceType,deviceName);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError("操作失败");
@ -814,4 +839,35 @@ public class MonitorPlatformController extends EnvelopRestEndpoint {
        }
    }
    @RequestMapping(value = "/getSearchTags",method = RequestMethod.GET)
    @ApiOperation("快速搜索标签")
    public Envelop getSearchTags(){
        try {
            return success(monitorPlatformService.getSearchTags());
        }
        catch (Exception e){
            e.printStackTrace();
            return MixEnvelop.getError("查询失败");
        }
    }
    @RequestMapping(value="getDeviceTotalCount",method = RequestMethod.GET)
    @ApiOperation("获取设备使用量、库存量、总备案")
    public Envelop getDeviceTotalCount(@ApiParam(name="startTime",value="开始时间yyyy-MM-dd",defaultValue = "")
                                           @RequestParam(value="startTime",required = false) String startTime,
                                       @ApiParam(name="endTime",value="结束时间",defaultValue = "")
                                       @RequestParam(value="endTime",required = false) String endTime,
                                       @ApiParam(name="deviceType",value="设备类型",defaultValue = "")
                                           @RequestParam(value="deviceType",required = false) String deviceType,
                                       @ApiParam(name="area",value="地区",defaultValue = "")
                                           @RequestParam(value="area",required = false) String area){
        try {
            return success(monitorPlatformService.getDeviceTotalCount(startTime, endTime, deviceType, area));
        }
        catch (Exception e){
            e.printStackTrace();
            return MixEnvelop.getError("查询失败");
        }
    }
}

+ 28 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/common/ElasticSearchQueryGenerator.java

@ -4,8 +4,10 @@ package com.yihu.iot.service.common;
import com.alibaba.druid.sql.ast.SQLExpr;
import com.alibaba.druid.sql.ast.expr.SQLQueryExpr;
import com.alibaba.druid.sql.parser.SQLExprParser;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.JsonArray;
import com.yihu.elasticsearch.ElasticSearchPool;
import com.yihu.iot.datainput.enums.DataTypeEnum;
import com.yihu.iot.datainput.service.DataStandardConvertService;
@ -427,6 +429,32 @@ public class ElasticSearchQueryGenerator {
                if("null".equals(andOr)) {
                    boolQueryBuilder.must(matchQueryBuilder);
                }
            }
            else if(condition.equals("in")) {
                List<String> list= (List<String>) JSONArray.parse(JSON.toJSONString(param.get("value")));
                String[] tmpString = list.toArray(new String[]{});
                if (tmpString.length>1000){
                    int tmp = list.size()/1000;
                    for (int i=0;i<=tmp;i++){
                        String[] sunString = new String[]{};
                        if (i==tmp){
                            sunString = list.subList(i * 1000, list.size()).toArray(new String[]{});
                        }
                        else{
                            sunString = list.subList(i * 1000, (i + 1) * 1000).toArray(new String[]{});
                        }
                        TermsQueryBuilder termsQueryBuilder = QueryBuilders.termsQuery(field,sunString);
                        boolQueryBuilder.should(termsQueryBuilder);
                    }
                }
                else{
                    TermsQueryBuilder termsQueryBuilder = QueryBuilders.termsQuery(field,tmpString);
                    if("and".equals(andOr)) {
                        boolQueryBuilder.must(termsQueryBuilder);
                    }else if("or".equals(andOr)) {
                        boolQueryBuilder.should(termsQueryBuilder);
                    }
                }
            }else if(condition.equals("=")) {
                MatchQueryBuilder matchQueryBuilder = QueryBuilders.matchQuery(field, value);
                if("and".equals(andOr)) {

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

@ -1164,13 +1164,13 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
        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\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";
        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\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));

+ 4 - 3
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotPatientDeviceService.java

@ -13,6 +13,7 @@ import com.yihu.iot.service.common.MyJdbcTemplate;
import com.yihu.iot.service.common.OrgUserService;
import com.yihu.iot.service.dict.IotSystemDictService;
import com.yihu.iot.service.useragent.UserAgent;
import com.yihu.iot.util.conceal.ConcealUtil;
import com.yihu.iot.util.excel.HibenateUtils;
import com.yihu.jw.device.LocationDataDO;
import com.yihu.jw.entity.iot.device.IotDeviceDO;
@ -306,13 +307,13 @@ public class IotPatientDeviceService extends BaseJpaService<IotPatientDeviceDO,
                if (StringUtils.isNotEmpty(idCard)){
                    sql = sql +" and t.idcard = '"+idCard+"'";
                    nameList = jdbcTempalte.queryForList(sql);
                }if (StringUtils.isNotEmpty(snCoed)){
                }if (StringUtils.isNoneBlank(snCoed)){
                    sqlEqt = sqlEqt +" and t.device_code = '"+snCoed+"'";
                    deviceList = jdbcTempalte.queryForList(sqlEqt);
                }
                if(nameList.size()>0){
                    String code = null==nameList.get(0).get("code")?"":nameList.get(0).get("code").toString();
                    String name = null==nameList.get(0).get("name")?"":nameList.get(0).get("name").toString();
                    String name = null==nameList.get(0).get("name")?"": ConcealUtil.nameOrAddrConceal(nameList.get(0).get("name").toString());
                    locationDataVO.setCode(code);
                    locationDataVO.setName(name);
                }
@ -401,7 +402,7 @@ public class IotPatientDeviceService extends BaseJpaService<IotPatientDeviceDO,
        int count = 0;
        SearchSourceBuilder queryStr = elasticSearchQueryGenerator.getQueryBuilder("",jsonData);
        io.searchbox.core.SearchResult result = elasticSearchHelper.search(ConstantUtils.deviceLocationIndex,ConstantUtils.deviceLocationType,queryStr.toString());
        count = result.getTotal();
        count += result.getTotal();
        return count;
    }

+ 2 - 1
svr/svr-iot/src/main/java/com/yihu/iot/service/equipment/IotEqtDetailService.java

@ -2,6 +2,7 @@ package com.yihu.iot.service.equipment;
import com.alibaba.fastjson.JSONObject;
import com.yihu.iot.dao.equipment.IotEquipmentDetailDao;
import com.yihu.iot.util.conceal.ConcealUtil;
import com.yihu.iot.util.excel.EntityUtils;
import com.yihu.iot.util.excel.HibenateUtils;
import com.yihu.jw.datainput.Data;
@ -199,7 +200,7 @@ public class IotEqtDetailService  extends BaseJpaService<IotEquipmentDetailDO, I
            locationDataVO.setLabel(null);
            locationDataVO.setDiseaseCondition(5);
            locationDataVO.setCreateTime(jsobj.get("createTime").toString());
            locationDataVO.setName((String) jsobj.get("name"));
            locationDataVO.setName(ConcealUtil.nameOrAddrConceal(jsobj.get("name").toString()));
            locationDataVO.setCode(null);
            locationDataVO.setEquimentName((String) jsobj.get("equimentName"));
            result.add(locationDataVO);

+ 187 - 52
svr/svr-iot/src/main/java/com/yihu/iot/service/monitorPlatform/MonitorPlatformService.java

@ -11,6 +11,7 @@ import com.yihu.iot.service.device.IotPatientDeviceService;
import com.yihu.iot.service.equipment.IotEqtDetailService;
import com.yihu.iot.service.label.FigureLabelSerachService;
import com.yihu.iot.service.platform.IotInterfaceLogService;
import com.yihu.iot.util.conceal.ConcealUtil;
import com.yihu.iot.util.excel.HibenateUtils;
import com.yihu.jw.entity.iot.dict.IotSystemDictDO;
import com.yihu.jw.entity.iot.equipment.IotEquipmentDetailDO;
@ -79,10 +80,9 @@ public class MonitorPlatformService  {
     * @param diseaseCondition
     * @return
     */
    public MixEnvelop<LocationDataVO, LocationDataVO> findDeviceLocations(Integer diseaseCondition, Integer page, Integer size, String type,String deviceType) throws IOException {
    public MixEnvelop<LocationDataVO, LocationDataVO> findDeviceLocations(Integer diseaseCondition, Integer page, Integer size, String type,String deviceType,String deviceName) throws IOException {
        MixEnvelop<LocationDataVO, LocationDataVO> envelop = new MixEnvelop<>();
        MixEnvelop<LocationDataVO, LocationDataVO> envelopTmp = null;
        JSONArray jsonArray = new JSONArray();
        Integer total = 0;
        if(org.apache.commons.lang.StringUtils.isNotBlank(type)){
            String re = searchpatientdevicesn(type, page, size);
@ -115,49 +115,79 @@ public class MonitorPlatformService  {
            List<LocationDataVO> euipmentList = new ArrayList<>();
            int totalEqCount=0;
            int totalCount=0;
            //查找全部
            if(diseaseCondition!=null){
                JSONObject json = new JSONObject();
                json.put("andOr","and");
                json.put("field","diseaseCondition");
                json.put("condition","=");
                json.put("value",diseaseCondition);
                jsonArray.add(json);
            }
            //小屋总数
            if(deviceType.contains("5")){
               totalEqCount = iotEqtDetailService.getEquipmentCount();
                if (org.apache.commons.lang3.StringUtils.isBlank(deviceName)||(org.apache.commons.lang3.StringUtils.isNoneBlank(deviceName) &&deviceName.contains("健康小屋"))){
                    totalEqCount = iotEqtDetailService.getEquipmentCount();
                }
            }
            String[] categoryCodes= deviceType.split(",");
            if(categoryCodes.length==1&&"5".equals(deviceType)){
                euipmentList = iotEqtDetailService.getEquipmentLocation(page,size);
                envelop.getDetailModelList().addAll(euipmentList);
                if (org.apache.commons.lang3.StringUtils.isBlank(deviceName)||(org.apache.commons.lang3.StringUtils.isNoneBlank(deviceName) &&deviceName.contains("健康小屋"))){
                    euipmentList = iotEqtDetailService.getEquipmentLocation(page,size);
                    envelop.getDetailModelList().addAll(euipmentList);
                }
            }
            else{
                if(deviceType.contains("5")){
                    euipmentList = iotEqtDetailService.getEquipmentLocation(page,size);
                    envelop.getDetailModelList().addAll(euipmentList);
                    if (org.apache.commons.lang3.StringUtils.isBlank(deviceName)||(org.apache.commons.lang3.StringUtils.isNoneBlank(deviceName) &&deviceName.contains("健康小屋"))){
                        euipmentList = iotEqtDetailService.getEquipmentLocation(page,size);
                        envelop.getDetailModelList().addAll(euipmentList);
                    }
                }
                for (String categoryCode:categoryCodes){
                    JSONObject json = new JSONObject();
                    JSONArray jsonArray = new JSONArray();
                    if(diseaseCondition!=null){
                        json.put("andOr","and");
                        json.put("field","diseaseCondition");
                        json.put("condition","=");
                        json.put("value",diseaseCondition);
                        jsonArray.add(json);
                    }
                     if(!"5".equals(categoryCode)){
                         JSONObject json = new JSONObject();
                         json.put("andOr","and");
                         json.put("field","categoryCode");
                         json.put("condition","=");
                         json.put("value",Integer.parseInt(categoryCode));
                         jsonArray.add(json);
                         json = new JSONObject();
                         List<String> listTmp = new ArrayList<>();
                         if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceName)){
                             String[] deviceNames = deviceName.split(",");
                             for (String tmp :deviceNames){
                                 String sql="select DISTINCT device_code from device.wlyy_devices wd INNER JOIN wlyy.wlyy_patient_device pd on pd.device_sn = wd.device_code  where wd.device_name like '%"+tmp+"%'";
                                 List<String> tmpList = jdbcTemplate.queryForList(sql,String.class);
                                 listTmp.addAll(tmpList);
                             }
                             if (listTmp.size()!=0){
                                 json.put("andOr","and");
                                 json.put("field","deviceSn");
                                 json.put("condition","in");
                                 json.put("value",listTmp);
                                 jsonArray.add(json);
                             }
                         }
                         else{
                             String sql="select DISTINCT device_code from device.wlyy_devices wd INNER JOIN wlyy.wlyy_patient_device pd on pd.device_sn = wd.device_code  ";
                             if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)){
                                 sql+="and pd.category_code in ('"+deviceType.replace(",","','")+"') ";
                             }
                             List<String> tmpList = jdbcTemplate.queryForList(sql,String.class);
                             json.put("andOr","and");
                             json.put("field","deviceSn");
                             json.put("condition","in");
                             json.put("value",tmpList);
                             jsonArray.add(json);
                         }
                         JSONObject jsonObject = new JSONObject();
                         jsonObject.put("filter",jsonArray);
                         jsonObject.put("page",page);
                         jsonObject.put("size",size);
                         List<LocationDataVO> locationDataVOList = iotPatientDeviceService.findDeviceLocationsByIdCard(jsonObject.toString());
                         List<LocationDataVO> list2 = iotPatientDeviceService.addNameAndCodeToList(locationDataVOList);
                         //figureLabelSerachService.getFigureLabelByList(locationDataVOList);
                         envelop.getDetailModelList().addAll(list2);
                         totalCount += iotPatientDeviceService.getESCount(jsonObject.toString());
                         jsonArray.remove(json);
                         if (jsonArray.size()!=0){
                             List<LocationDataVO> locationDataVOList = iotPatientDeviceService.findDeviceLocationsByIdCard(jsonObject.toString());
                             List<LocationDataVO> list2 = iotPatientDeviceService.addNameAndCodeToList(locationDataVOList);
                             //figureLabelSerachService.getFigureLabelByList(locationDataVOList);
                             envelop.getDetailModelList().addAll(list2);
                           totalCount += iotPatientDeviceService.getESCount(jsonObject.toString());
                         }
                     }
                     break;
                }
            }
            envelop.setTotalCount(totalCount>totalEqCount?totalCount:totalEqCount);
@ -798,6 +828,20 @@ public class MonitorPlatformService  {
        return new JSONObject();
    }
    public JSONObject getTotalRange(String startTime, String endTime,
                                  String deviceType, String area, String hospital){
        JSONObject result = new JSONObject();
        result.put("grant",totalRange(startTime,endTime,deviceType,area,hospital,"85"));
        result.put("binding",totalRange(startTime,endTime,deviceType,area,hospital,"86"));
        result.put("guide",totalRange(startTime,endTime,deviceType,area,hospital,"88"));
        result.put("malfunction",totalRange(startTime,endTime,deviceType,area,hospital,"0"));
        result.put("diseaseUsing",diseaseUseRange(startTime,endTime,deviceType,area,hospital));
        result.put("diseaseCover",diseaseRange(startTime,endTime,deviceType,area,hospital));
        return result;
    }
    /**
     * 慢病患者设备使用率
     * @param startTime
@ -890,7 +934,7 @@ public class MonitorPlatformService  {
     * @return
     */
    public JSONArray warningInformationAlarm_new(Integer page,Integer pageSize,String startTime,String endTime,
                                                 String deviceType,String area,String hospital){
                                                 String deviceType,String area,String hospital,String deviceName){
        String url = "/wlyygc/iot_monitoring/warningInformationAlarm_new";
        Map<String, Object> params = new HashMap<>();
        params.put("page",page);
@ -900,6 +944,7 @@ public class MonitorPlatformService  {
        params.put("deviceType",deviceType);
        params.put("area",area);
        params.put("hospital",hospital);
        params.put("deviceName",deviceName);
        String response = sendGet(url,params);
        JSONObject json = JSONObject.parseObject(response);
        if(json.getInteger("status")==200){
@ -941,17 +986,35 @@ public class MonitorPlatformService  {
     * @return
     */
    public JSONArray datafiltering(String name){
        String url = "/wlyygc/iot_monitoring/datafiltering";
        Map<String, Object> params = new HashMap<>();
        params.put("name",name);
        String response = sendGet(url,params);
        JSONObject json = JSONObject.parseObject(response);
        if(json.getInteger("status")==200){
            JSONArray jsonArray = json.getJSONArray("data");
        StringBuffer sql = new StringBuffer("SELECT d.category_code as categoryCode,d.id,d.device_sn deviceSn,p.code,p.name,d.device_name deviceName ");
        sql.append("from wlyy.wlyy_patient_device d,wlyy.wlyy_patient p  ");
        sql.append("WHERE d.`user` = p.`code`   ");
        if(org.apache.commons.lang3.StringUtils.isNotBlank(name)){
            sql.append("and (d.device_sn like '%"+name+"%' or p.`name` = '"+name+"') ");
        }
        List<JSONObject> jsonArray = myJdbcTemplate.queryJson(sql.toString(),new Object[]{});
        if(jsonArray.size()==0){
            sql= new StringBuffer(" select '5' as categoryCode, id,device_code as deviceSn,null as code,null as name,'健康小屋' as deviceName from xmiot.iot_equipmet_detail where device_code like '%"+name+"%'");
            jsonArray = myJdbcTemplate.queryJson(sql.toString(),new Object[]{});
        }
        for (int i=0;i<jsonArray.size();i++){
            com.alibaba.fastjson.JSONObject jsonObj= jsonArray.get(i);
            if (org.apache.commons.lang3.StringUtils.isNoneBlank(jsonObj.getString("name"))){
                jsonObj.put("name", ConcealUtil.nameOrAddrConceal(jsonObj.getString("name")));
            }
        }
//        String url = "/wlyygc/iot_monitoring/datafiltering";
//        Map<String, Object> params = new HashMap<>();
//        params.put("name",name);
//        String response = sendGet(url,params);
//        JSONObject json = JSONObject.parseObject(response);
//        if(json.getInteger("status")==200){
//            JSONArray jsonArray = json.getJSONArray("data");
            for(int i=0;i<jsonArray.size();i++){
                JSONObject data = jsonArray.getJSONObject(i);
                JSONObject data = jsonArray.get(i);
                String deviceSn = data.getString("deviceSn");
                JSONArray jsonArray1 = new JSONArray();
                JSONObject json1 = new JSONObject();
                json1.put("andOr","and");
@ -977,10 +1040,9 @@ public class MonitorPlatformService  {
                }
            }
            return jsonArray;
        }
        return new JSONArray();
            JSONArray result = new JSONArray();
            result.addAll(jsonArray);
            return result;
    }
@ -1118,7 +1180,7 @@ public class MonitorPlatformService  {
                StringBuffer sql = new StringBuffer("SELECT a.category_code type,a.device_name,a.c as 'using',b.c-a.c as 'stock',b.c as 'total' from ( ");
                StringBuffer sqlCondition = new StringBuffer();
                if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceName)){
                    sqlCondition.append("and d.device_name='"+deviceName+"' ");
                    sqlCondition.append("and d.device_name in ('").append(deviceName.replace(",","','")).append("') ");
                }
                sql.append("SELECT d.category_code,d.device_name, COUNT(*) c from wlyy.wlyy_patient_device d,wlyy.wlyy_sign_family f WHERE f.`status`>0 and f.patient = d.`user` "+sqlCondition+" ");
                if ("0".equals(showLevel)){//组合一体机(5健康小屋,取自物联网),单体征测量仪(2血压计、1血糖仪)
@ -1206,7 +1268,7 @@ public class MonitorPlatformService  {
                result.put("lostContact",lostContact);
            }
            //deviceType包含小屋且设备名称为空||deviceType包含小屋且设备名称为健康小屋。
          if ((deviceType.contains("5")&&org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType))||(deviceType.contains("5")&&org.apache.commons.lang3.StringUtils.isNoneBlank(deviceName)&&"健康小屋".equals(deviceName))){
          if ((deviceType.contains("5")&&org.apache.commons.lang3.StringUtils.isBlank(deviceName))||(deviceType.contains("5")&&org.apache.commons.lang3.StringUtils.isNoneBlank(deviceName)&&deviceName.contains("健康小屋"))){
                String sql = "select COUNT(*) from xmiot.iot_equipmet_detail";
                Integer count = jdbcTemplate.queryForObject(sql,Integer.class);
                JSONObject tmp = new JSONObject();
@ -1249,9 +1311,9 @@ public class MonitorPlatformService  {
    public String getRange(int first, int second, int i) {
        if (second == 0 && first > 0) {
            return "100%";
            return "100";
        } else if (second == 0 && first == 0) {
            return "0.00%";
            return "0.00";
        }
        float size = (float) (first * 100) / second;
        DecimalFormat df = new DecimalFormat("0.00");//格式化小数,不足的补0
@ -1300,7 +1362,7 @@ public class MonitorPlatformService  {
        }
        //失联
        if("2".equals(quotaCode)){
            sql = new StringBuffer("SELECT count(*) from wlyy.wlyy_patient_device d,wlyy.wlyy_sign_family f");
            sql = new StringBuffer("SELECT count(*) from wlyy.wlyy_patient_device d,wlyy.wlyy_sign_family f ");
            sqlCondition = new StringBuffer(" where 1=1 ");
            if (org.apache.commons.lang3.StringUtils.isNoneBlank(area)){
                sql.append("LEFT JOIN wlyy.dm_hospital dh on f.hospital = dh.`code` ");
@ -1311,14 +1373,18 @@ public class MonitorPlatformService  {
            }
            sqlCondition.append("and f.`status`>0 and f.patient = d.`user` ");
            sqlCondition.append("  and d.category_code in ('").append(deviceType.replace(",","','")).append("') ");
            sqlCondition.append("and d.device_sn not in (select device_sn from ( select device_sn,MAX(record_date) record_date from device.wlyy_patient_health_index where device_sn<>'' GROUP BY device_sn)a ");
            sqlCondition.append("where TIMESTAMPDIFF(DAY,record_date,NOW()) <= 7)");
            sqlCondition.append("and d.device_sn not in (select DISTINCT device_sn from device.wlyy_patient_health_index where device_sn<>''  ");
            if (org.apache.commons.lang3.StringUtils.isNoneBlank(startTime)&&org.apache.commons.lang3.StringUtils.isNoneBlank(endTime)){
                sqlCondition.append("and record_date >='"+startTime+" 00:00:00' and record_date<='"+endTime+" 23:59:59'  ");
            }
            sqlCondition.append(")");
            sql.append(sqlCondition);
            total=jdbcTemplate.queryForObject(sql.toString(),Integer.class);
        }
        Integer count =0;
        if ((org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)&&deviceType.contains("5"))||org.apache.commons.lang3.StringUtils.isBlank(deviceType)){
            String sqll = "select COUNT(*) from xmiot.iot_equipmet_detail";
            Integer count = jdbcTemplate.queryForObject(sqll,Integer.class);
             count = jdbcTemplate.queryForObject(sqll,Integer.class);
            result.put("totalAll",grantCount+count);
            count =0;
            if("1".equals(quotaCode)){//小屋物联率
@ -1339,6 +1405,9 @@ public class MonitorPlatformService  {
            }
            result.put("total",total+count);//互联设备\失联设备数量
        }
        else{
            result.put("total",total+count);//互联设备\失联设备数量
        }
        DecimalFormat df = new DecimalFormat("0.00");
        if (result.getInteger("totalAll") > 0) {
            result.put("totalRange", df.format(result.getDouble("total") > 0.0 ? ((result.getDouble("total")) / (result.getInteger("totalAll") * 1.0000) * 100) : 0.0) );
@ -1377,7 +1446,6 @@ public class MonitorPlatformService  {
        }
    }
    public JSONObject getDeviceData(){
        JSONObject object = new JSONObject();
        //血糖仪数量
@ -1413,4 +1481,71 @@ public class MonitorPlatformService  {
        object.put("medicalAbnormalSignData",gg);
        return object;
    }
    public JSONArray getSearchTags(){
        String sql = "select id,`value` from xmiot.iot_system_dict where dict_name='DEVICE' and (value='组合一体机' or value ='单体征测量仪') and del=1;";
        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 parent_code='"+map.get("id").toString()+"'";
            StringBuffer buffer = new StringBuffer();
            List<Map<String,Object>> reList = jdbcTemplate.queryForList(sql);
            for (Map<String,Object> reMap:reList){
                JSONObject tmp = new JSONObject();
                tmp.put("name",reMap.get("value").toString());
                tmp.put("code",reMap.get("code").toString());
                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);
            }
        }
        return  result;
    }
    public JSONObject getDeviceTotalCount(String startTime,String endTime,String deviceType,String area){
        Integer totalAll=0;
        Integer grant=0;
        if (deviceType.contains("5")){
            StringBuffer sql = new StringBuffer("select count(*) from xmiot.iot_equipmet_detail where 1=1 ");
            if(org.apache.commons.lang3.StringUtils.isNoneBlank(area)){
                sql.append("and belong_are_code='"+area+"' ");
            }
            Integer tmp = jdbcTemplate.queryForObject(sql.toString(),Integer.class);
            totalAll +=tmp;
            grant +=tmp;
        }
        String allCountSql = "SELECT COUNT(*) FROM device.wlyy_devices d ";
        int i = 0;
        if(org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)&&deviceType.contains("1")){
            allCountSql+= " where device_name like '%血糖仪%' ";
            i = 1;
        }
        if(org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)&&deviceType.contains("2")){
            if(i==1){
                allCountSql+= " or device_name like '%血压计%'";
            }else{
                allCountSql+= " where device_name like '%血压计%' ";
            }
        }
        Integer allCount = jdbcTemplate.queryForObject(allCountSql, Integer.class);
        totalAll+=allCount;
        StringBuffer sql = new StringBuffer("SELECT COUNT(*) from wlyy.wlyy_patient_device d,wlyy.wlyy_sign_family f  WHERE 1=1 and f.`status`>0 and f.patient = d.`user` ");
        sql.append("and d.category_code in ('").append(deviceType.replace(",","','")).append("') ");
        Integer count = jdbcTemplate.queryForObject(sql.toString(),Integer.class);
        grant +=count;
        JSONObject result = new JSONObject();
        result.put("totalAll",totalAll);
        result.put("using",grant);
        result.put("stock",totalAll-grant);
        return result;
    }
}

+ 4 - 4
svr/svr-iot/src/main/java/com/yihu/iot/service/platform/IotInterfaceLogService.java

@ -217,10 +217,10 @@ public class IotInterfaceLogService extends BaseJpaService<IotInterfaceLogDO, Io
        List<IotInterfaceLogVO> list = new ArrayList<>();
        listSql.forEach(one->{
            IotInterfaceLogVO iotInterfaceLogVO = new IotInterfaceLogVO();
            iotInterfaceLogVO.setAppName(one.get("app_name").toString());
            iotInterfaceLogVO.setInterfaceName(one.get("interface_name").toString());
            iotInterfaceLogVO.setWorkType(one.get("work_type").toString());
            iotInterfaceLogVO.setCount(one.get("count").toString());
            iotInterfaceLogVO.setAppName(one.get("app_name")==null?"":one.get("app_name").toString());
            iotInterfaceLogVO.setInterfaceName(one.get("interface_name")==null?"":one.get("interface_name").toString());
            iotInterfaceLogVO.setWorkType(one.get("work_type")==null?"":one.get("work_type").toString());
            iotInterfaceLogVO.setCount(one.get("count")==null?"":one.get("count").toString());
            DecimalFormat df = new DecimalFormat("0.00");
            iotInterfaceLogVO.setFailureRate( df.format(Double.parseDouble(one.get("count").toString()) > 0.0 ? ((Double.parseDouble(one.get("COALESCE(c.fali,0)").toString())) / (Double.parseDouble(one.get("count").toString()) * 1.0000) * 100) : 0.0) );
            list.add(iotInterfaceLogVO);

+ 143 - 0
svr/svr-iot/src/main/java/com/yihu/iot/util/conceal/ConcealUtil.java

@ -0,0 +1,143 @@
package com.yihu.iot.util.conceal;
/**
 * 数据脱敏工具
 * Created by zdm on 2019/4/2.
 */
public class ConcealUtil {
    private static final int SIZE = 6;
    private static final String SYMBOL = "*";
    /**
     * 电话号码脱敏,达到保密效果
     *
     * @param userName 用户名
     * @return 替换后的用户名
     */
    public static String phoneConceal(String userName) {
        String userNameAfterReplaced = "";
        if (userName == null) {
            userName = "";
        }
        int nameLength = userName.length();
        if (nameLength <= 1) {
            userNameAfterReplaced = "*";
        } else if (nameLength == 2) {
            userNameAfterReplaced = replaceAction(userName, "(?<=\\d{0})\\d(?=\\d{1})");
        } else if (nameLength >= 3 && nameLength <= 6) {
            userNameAfterReplaced = replaceAction(userName, "(?<=\\d{1})\\d(?=\\d{1})");
        } else if (nameLength >= 7 && nameLength <= 10) {
            userNameAfterReplaced = replaceAction(userName, "(?<=\\d{3})\\d(?=\\d{3})");
        } else if (nameLength >= 11) {
            userNameAfterReplaced = replaceAction(userName, "(?<=\\d{3})\\d(?=\\d{4})");
        }
        return userNameAfterReplaced;
    }
    /**
     * 实际替换动作
     *
     * @param username username
     * @param regular  正则
     * @return
     */
    private static String replaceAction(String username, String regular) {
        return username.replaceAll(regular, "*");
    }
    /**
     * 身份证号替换,保留前四位和后四位
     * <p>
     * 如果身份证号为空 或者 null ,返回null ;否则,返回替换后的字符串;
     *
     * @param idCard 身份证号
     * @return
     */
    public static String idCardConceal(String idCard) {
        if (idCard.isEmpty() || idCard == null) {
            return null;
        } else {
            return replaceAction(idCard, "(?<=\\d{6})\\d(?=\\d{4})");
        }
    }
    /**
     * 银行卡替换,保留后四位
     * <p>
     * 如果银行卡号为空 或者 null ,返回null ;否则,返回替换后的字符串;
     *
     * @param bankCard 银行卡号
     * @return
     */
    public static String bankCardConceal(String bankCard) {
        if (bankCard.isEmpty() || bankCard == null) {
            return null;
        } else {
            return replaceAction(bankCard, "(?<=\\d{0})\\d(?=\\d{4})");
        }
    }
    /**
     * 姓名及地址脱敏
     * @param value
     * @return
     */
    public static String nameOrAddrConceal(String value) {
        if (null == value || "".equals(value)) {
            return value;
        }
        int len = value.length();
        int pamaone = len / 2;
        int pamatwo = pamaone - 1;
        int pamathree = len % 2;
        StringBuilder stringBuilder = new StringBuilder();
        if (len <= 2) {
            if (pamathree == 1) {
                return SYMBOL;
            }
            stringBuilder.append(value.charAt(0));
            stringBuilder.append(SYMBOL);
        } else {
            if (pamatwo <= 0) {
                stringBuilder.append(value.substring(0, 1));
                stringBuilder.append(SYMBOL);
                stringBuilder.append(value.substring(len - 1, len));
            } else if (pamatwo >= SIZE / 2 && SIZE + 1 != len) {
                int pamafive = (len - SIZE) / 2;
                stringBuilder.append(value.substring(0, pamafive));
                for (int i = 0; i < SIZE; i++) {
                    stringBuilder.append(SYMBOL);
                }
                if ((pamathree == 0 && SIZE / 2 == 0) || (pamathree != 0 && SIZE % 2 != 0)) {
                    stringBuilder.append(value.substring(len - pamafive, len));
                } else {
                    stringBuilder.append(value.substring(len - (pamafive + 1), len));
                }
            } else {
                int pamafour = len - 2;
                stringBuilder.append(value.substring(0, 1));
                for (int i = 0; i < pamafour; i++) {
                    stringBuilder.append(SYMBOL);
                }
                stringBuilder.append(value.substring(len - 1, len));
            }
        }
        return stringBuilder.toString();
    }
/*    public static void main(String[] args) throws IOException {
        String strName= nameOrAddrConceal("张三");
        System.out.println(strName);
        String addr= nameOrAddrConceal("厦门市");
        System.out.println(addr);
        String idcard= idCardConceal("350825199012033283");
        System.out.println(idcard);
        String phone= phoneConceal("17689202624");
        System.out.println(phone);
    }*/
}