LAPTOP-KB9HII50\70708 1 éve
szülő
commit
3a3167c9e0

+ 3 - 3
svr/svr-iot/src/main/java/com/yihu/iot/controller/product/IotProductController.java

@ -1,13 +1,13 @@
package com.yihu.iot.controller.product;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yihu.iot.service.device.IotDeviceInventoryWarningService;
import com.yihu.iot.service.dict.IotSystemDictService;
import com.yihu.iot.service.product.IotProductBaseInfoPropertyService;
import com.yihu.iot.service.product.IotProductBaseInfoService;
import com.yihu.jw.entity.iot.device.IotDeviceInventoryWarningDO;
import com.yihu.jw.entity.iot.product.IotProductBaseInfoDO;
import com.yihu.jw.entity.util.AesEncryptUtils;
import com.yihu.jw.restmodel.iot.device.IotDeviceInventoryWarningVO;
import com.yihu.jw.restmodel.iot.product.IotMaintenanceUnitVO;
import com.yihu.jw.restmodel.iot.product.IotProductBaseInfoPropertyVO;
@ -146,9 +146,9 @@ public class IotProductController extends EnvelopRestEndpoint {
    @PostMapping(value = IotRequestMapping.Product.addProduct)
    @ApiOperation(value = "创建产品", notes = "创建产品")
    public MixEnvelop<IotProductVO, IotProductVO> addProduct(@ApiParam(name = "jsonData", value = "json", defaultValue = "")
                                            @RequestParam(value = "jsonData", required = false)String jsonData) {
    public MixEnvelop<IotProductVO, IotProductVO> addProduct(String jsonData) {
        try {
            JSONObject jsonObject = JSON.parseObject(jsonData);
            IotProductVO iotProductVO = toEntity(jsonData, IotProductVO.class);
           return iotProductBaseInfoService.addProduct(iotProductVO);

+ 36 - 0
svr/svr-iot/src/main/java/com/yihu/iot/controller/third/ThirdDataInputController.java

@ -7,9 +7,11 @@ import com.yihu.iot.datainput.service.DataInputService;
import com.yihu.iot.datainput.service.DataSearchService;
import com.yihu.iot.datainput.util.ConstantUtils;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.iot.DataRequestMapping;
import com.yihu.jw.rm.iot.IotRequestMapping;
import com.yihu.jw.util.entity.ServiceException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -29,6 +31,40 @@ public class ThirdDataInputController {
    @Autowired
    private DataSearchService dataSearchService;
    /**************************社区数据删除**********************************************/
    @PostMapping(value = "deviceRegistration")
    @ApiOperation(value = "设备注册", notes = "设备注册")
    public Envelop deviceRegistration(@ApiParam(name = "jsonData", value = "", defaultValue = "")
                                      @RequestBody String jsonData){
        try{
            dataInputService.deviceRegistration(jsonData);
            return Envelop.getSuccess("设备注册成功");
        } catch (ServiceException e){
            return Envelop.getError(e.getMessage());
        } catch (Exception e){
            e.printStackTrace();
            return Envelop.getError("设备注册失败");
        }
    }
    @PostMapping(value = "uploadDeviceData")
    @ApiOperation(value = "设备注册", notes = "设备注册")
    public Envelop uploadDeviceData(@ApiParam(name = "jsonData", value = "", defaultValue = "")
                                    @RequestBody String jsonData){
        try{
            return Envelop.getSuccess(dataInputService.uploadDeviceData(jsonData));
        } catch (ServiceException e){
            return Envelop.getError(e.getMessage());
        } catch (Exception e){
            e.printStackTrace();
            return Envelop.getError("设备注册失败");
        }
    }
    /************************************************************************/
    @PostMapping(value = IotRequestMapping.ThirdOpen.registedevice)
    @ApiOperation(value = "设备注册绑定", notes = "设备注册并绑定用户")
    public MixEnvelop registedevice(@ApiParam(name = "jsonData", value = "", defaultValue = "") @RequestParam String jsonData){

+ 12 - 0
svr/svr-iot/src/main/java/com/yihu/iot/dao/device/IotDeviceUploadRecordDao.java

@ -0,0 +1,12 @@
package com.yihu.iot.dao.device;
import com.yihu.jw.entity.iot.device.IotDeviceUploadRecordDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by yeshijie on 2023/7/7.
 */
public interface IotDeviceUploadRecordDao  extends PagingAndSortingRepository<IotDeviceUploadRecordDO, Long>,
        JpaSpecificationExecutor<IotDeviceUploadRecordDO> {
}

+ 85 - 1
svr/svr-iot/src/main/java/com/yihu/iot/datainput/service/DataInputService.java

@ -3,6 +3,8 @@ package com.yihu.iot.datainput.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.elasticsearch.ElasticSearchHelper;
import com.yihu.iot.dao.device.IotDeviceDao;
import com.yihu.iot.dao.device.IotDeviceUploadRecordDao;
import com.yihu.iot.datainput.enums.DataOperationTypeEnum;
import com.yihu.iot.datainput.util.ConstantUtils;
import com.yihu.iot.datainput.util.RowKeyUtils;
@ -11,7 +13,9 @@ import com.yihu.iot.service.device.IotDeviceService;
import com.yihu.jw.datainput.DataBodySignsDO;
import com.yihu.jw.datainput.WeRunDataDO;
import com.yihu.jw.entity.iot.device.IotDeviceDO;
import com.yihu.jw.entity.iot.device.IotDeviceUploadRecordDO;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.entity.ServiceException;
import com.yihu.jw.util.http.HttpClientUtil;
import io.searchbox.client.JestResult;
import org.apache.commons.lang.StringUtils;
@ -46,7 +50,8 @@ public class DataInputService {
    @Autowired
    private IotDeviceService iotDeviceService;
    @Autowired
    private IotDeviceDao iotDeviceDao;
    @Autowired
    private DataProcessLogService dataProcessLogService;
    @Autowired
@ -57,12 +62,91 @@ public class DataInputService {
    private String profiles;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private IotDeviceUploadRecordDao iotDeviceUploadRecordDao;
//    @Autowired
//    private HBaseHelper hBaseHelper;
//    @Autowired
//    private HBaseAdmin hBaseAdmin;
    //设备注册
    public String deviceRegistration(String json) throws ServiceException {
        JSONObject jsonObject = JSONObject.parseObject(json);
        String deviceSn = jsonObject.getString("deviceSn");//设备唯一码
        String name = jsonObject.getString("name");//设备名称
        String hospital = jsonObject.getString("hospital");//设备归属机构编码
        String hospitalName = jsonObject.getString("hospitalName");//设备归属机构名称
        String categoryCode = jsonObject.getString("categoryCode");//设备类型编码
        String categoryName = jsonObject.getString("categoryName");//设备类型名称
        if(StringUtils.isBlank(deviceSn)){
            throw new ServiceException("设备唯一码不能为空");
        }
        if(StringUtils.isBlank(name)){
            throw new ServiceException("设备名称不能为空");
        }
        if(StringUtils.isBlank(hospital)){
            throw new ServiceException("设备归属机构编码不能为空");
        }
        if(StringUtils.isBlank(hospitalName)){
            throw new ServiceException("设备归属机构名称不能为空");
        }
        if(StringUtils.isBlank(categoryCode)){
            throw new ServiceException("设备类型编码不能为空");
        }
        if(StringUtils.isBlank(categoryName)){
            throw new ServiceException("设备类型名称不能为空");
        }
        String result = "";
        try {
            int count = iotDeviceService.countByDeviceSn(deviceSn);
            if(count > 0){
                throw new ServiceException("设备唯一码已存在,请检查是否已经上传过,或者换一个编码");
            }
            IotDeviceDO iotDeviceDO = new IotDeviceDO();
            iotDeviceDO.setDeviceSn(deviceSn);
            iotDeviceDO.setCategoryCode(categoryCode);
            iotDeviceDO.setCategoryName(categoryName);
            iotDeviceDO.setDel(1);
            iotDeviceDO.setStatus("1");
            iotDeviceDO.setCreateTime(new Date());
            iotDeviceDO.setDeviceSource("4");
            iotDeviceDO.setHospital(hospital);
            iotDeviceDO.setHospitalName(hospitalName);
            iotDeviceDao.save(iotDeviceDO);
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }
    /**
     * 上传设备数据
     */
    public String uploadDeviceData(String json){
        JSONObject jsonObject = JSONObject.parseObject(json);
        String deviceSn = jsonObject.getString("deviceSn");
        String hospital = jsonObject.getString("hospital");
        String categoryCode = jsonObject.getString("categoryCode");
        try {
            IotDeviceUploadRecordDO recordDO = new IotDeviceUploadRecordDO();
            recordDO.setDeviceSn(deviceSn);
            recordDO.setHospital(hospital);
            recordDO.setJsonData(jsonObject.getJSONArray("data").toJSONString());
            recordDO.setCategoryCode(categoryCode);
            recordDO.setStatus(0);
            recordDO.setCreateTime(new Date());
            iotDeviceUploadRecordDao.save(recordDO);
        }catch (Exception e){
            e.printStackTrace();
            logger.error("上传设备数据失败");
            //保存日志
            return "fail";
        }
        return "success";
    }
    /**
     * 居民设备注册及绑定
     */

+ 2 - 0
svr/svr-iot/src/main/java/com/yihu/iot/interceptor/XssHttpServletRequestWrapper.java

@ -100,7 +100,9 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
        value = value.replaceAll("'", "& #39;");
        value = value.replaceAll("eval\\((.*)\\)", "");
        value = value.replaceAll("[\\\"\\\'][\\s]*javascript:(.*)[\\\"\\\']", "\"\"");
        value = value.replaceAll("description", "descr_Ption");//解决description 被转成 deion
        value = value.replaceAll("script", "");
        value = value.replaceAll("descr_Ption", "description");
        value = cleanSqlKeyWords(value);
        return value;
    }

+ 113 - 17
svr/svr-iot/src/main/java/com/yihu/iot/service/monitorPlatform/MonitorPlatformService.java

@ -1082,25 +1082,121 @@ public class MonitorPlatformService {
     * @param hospital
     * @return
     */
    public JSONArray warningInformationAlarm_new(Integer page, Integer pageSize, String startTime, String endTime,
                                                 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);
        params.put("pageSize", pageSize);
        params.put("startTime", startTime);
        params.put("endTime", endTime);
        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) {
            return json.getJSONArray("data");
//    public JSONArray warningInformationAlarm_new(Integer page, Integer pageSize, String startTime, String endTime,
//                                                 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);
//        params.put("pageSize", pageSize);
//        params.put("startTime", startTime);
//        params.put("endTime", endTime);
//        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) {
//            return json.getJSONArray("data");
//        }
//
//        return new JSONArray();
//    }
    public List<com.alibaba.fastjson.JSONObject> warningInformationAlarm_new(Integer page,Integer pageSize,String startTime,String endTime,
                                                                             String deviceType,String area,String hospital,String deviceName){
        List<com.alibaba.fastjson.JSONObject> list = new ArrayList<>();
        StringBuffer tz_type = new StringBuffer("''");
        if (org.apache.commons.lang3.StringUtils.isBlank(deviceType)){
            tz_type.append(",'1','2'");
        }
        else{
            if (deviceType.contains("1")){
                tz_type.append(",'1'");
            }
            if (deviceType.contains("2")) {
                tz_type.append(",'2'");
            }
        }
        if (tz_type.toString().contains("1")||tz_type.toString().contains("2")){
            StringBuffer sql = new StringBuffer("select  A.*,d.name from ( SELECT  m.sender,m.sender_name,m.create_time,m.value1,m.value2,m.tz_type,p.address," +
                    "p.photo,m.receiver  ");
            sql.append("from wlyy.wlyy_message m INNER JOIN wlyy.wlyy_patient p on m.sender=p.code ");
            if(!StringUtils.isEmpty(area)||!StringUtils.isEmpty(hospital)){
                sql.append("INNER join wlyy.wlyy_sign_family f on f.`status`>0 and f.patient = m.sender ");
            }
            if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceName)){
                sql.append("INNER JOIN wlyy.wlyy_patient_device pd on  pd.`user` = p.`code` ");
            }
            sql.append("WHERE m.type = 2 " );
            if(org.apache.commons.lang3.StringUtils.isNoneBlank(startTime)){
                sql.append("and m.create_time >= '"+startTime+"' ");
            }
            if(org.apache.commons.lang3.StringUtils.isNoneBlank(endTime)){
                sql.append("and m.create_time <= '"+endTime+"' ");
            }
            if(org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)){
                sql.append("and m.tz_type in ("+tz_type+") ");
            }
            if(org.apache.commons.lang3.StringUtils.isNoneBlank(area)){
                sql.append("and f.hospital like '"+area+"%' ");
            }
            if(org.apache.commons.lang3.StringUtils.isNoneBlank(hospital)){
                sql.append("and f.hospital = '"+hospital+"' ");
            }
            if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceName)){
                sql.append("and pd.device_name in ('").append(deviceName.replace(",","','")).append("')  ");
            }
            sql.append("ORDER BY m.id desc LIMIT ?,? ) A INNER JOIN wlyy.wlyy_doctor d on d.code = A.receiver ");
            List<com.alibaba.fastjson.JSONObject> tmp = myJdbcTemplate.queryJson(sql.toString(),new Object[]{(page-1)*pageSize,pageSize});
            list.addAll(tmp);
        }
        list.forEach(json->{
            json.put("value2Name",getTypeName(json.getString("tz_type"),String.valueOf(json.getIntValue("value2"))));
            //姓名脱敏
            json.put("sender_name",null==json.getString("sender_name")?"": ConcealUtil.nameOrAddrConceal(json.getString("sender_name").toString()) );
            json.put("name",null==json.getString("name")?"": ConcealUtil.nameOrAddrConceal(json.getString("name").toString()) );
            //地址脱敏
            json.put("address",null==json.getString("address")?"": ConcealUtil.nameOrAddrConceal(json.getString("address").toString()) );
        });
        return new JSONArray();
        return list;
    }
    private String getTypeName(String type,String value){
        String name = "";
        //1早餐前、2早餐后、3午餐前、4午餐后、5晚餐前 6晚餐后 7睡前)
        if ("1".equals(type)){
            switch (value){
                case "1":
                    name = "早餐前";
                    break;
                case "2":
                    name = "早餐后";
                    break;
                case "3":
                    name = "午餐前";
                    break;
                case "4":
                    name = "午餐后";
                    break;
                case "5":
                    name = "晚餐前";
                    break;
                case "6":
                    name = "晚餐后";
                    break;
                default:
                    name = "睡前";
                    break;
            }
        }else if("3".equals(type)){
            name = "收缩压";
        }else {
            name = "舒张压";
        }
        return name;
    }
    /**

+ 4 - 1
svr/svr-iot/src/main/java/com/yihu/iot/service/product/IotProductBaseInfoService.java

@ -10,7 +10,6 @@ import com.yihu.jw.entity.iot.product.*;
import com.yihu.jw.restmodel.iot.product.*;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.iot.IotRequestMapping;
import com.yihu.jw.util.common.StringUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang.StringUtils;
@ -69,6 +68,7 @@ public class IotProductBaseInfoService extends BaseJpaService<IotProductBaseInfo
        translateDictForOne(baseInfoVO);
        IotProductExtendInfoVO extendInfoVO = convertToModel(extendInfoDO,IotProductExtendInfoVO.class);
        extendInfoVO.setRatifyDate(DateUtil.dateToStrShort(extendInfoDO.getRatifyDate()));
        List<IotProductAttachmentVO> attachmentVOList =
                convertToModels(attachmentDOList,new ArrayList<>(attachmentDOList.size()),IotProductAttachmentVO.class);
        List<IotProductMeasuredDataVO> measuredDataVOList =
@ -259,6 +259,9 @@ public class IotProductBaseInfoService extends BaseJpaService<IotProductBaseInfo
        baseInfoDO.setStartTime(DateUtil.strToDate(baseInfoVO.getStartTime()));
        baseInfoDO.setEndTime(DateUtil.strToDate(baseInfoVO.getEndTime()));
        IotProductExtendInfoDO extendInfoDO = convertToModel(extendInfoVO,IotProductExtendInfoDO.class);
        if(StringUtils.isNotBlank(extendInfoVO.getRatifyDate())){
            extendInfoDO.setRatifyDate(DateUtil.strToDate(extendInfoVO.getRatifyDate()));
        }
        List<IotProductAttachmentDO> attachmentDOList =
                convertToModels(attachmentVOList,new ArrayList<>(attachmentVOList.size()),IotProductAttachmentDO.class);
        List<IotProductMeasuredDataDO> measuredDataDOList =

+ 1 - 1
svr/svr-iot/src/main/resources/bootstrap.yml

@ -1,6 +1,6 @@
spring:
  application:
    name:  svr-iot
    name:  svr-iot--
  cloud:
    config:
      failFast: true