浏览代码

Merge branch 'dev' of liubing/wlyy2.0 into dev

shikejing 4 年之前
父节点
当前提交
8a1c58f26d

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

@ -447,6 +447,8 @@ public class MonitorPlatformController extends EnvelopRestEndpoint {
            @RequestParam(value = "diseaseCondition",required = false) Integer diseaseCondition,
            @ApiParam(name = "type", value = "1高血压 2糖尿病", defaultValue = "")
            @RequestParam(value = "type",required = false) String type,
            @ApiParam(name="deviceType",value="设备类型 1血糖仪,2血压计 5健康小屋",required = true)
            @RequestParam(value="deviceType",required = true,defaultValue = "1,2,5") String deviceType,
            @ApiParam(name="page",value="第几页(默认第一页)",defaultValue = "1")
            @RequestParam(value="page",required = false) Integer page,
            @ApiParam(name="pageSize",value="每页几行(默认10条记录)",defaultValue = "10")
@ -458,7 +460,7 @@ public class MonitorPlatformController extends EnvelopRestEndpoint {
            if(pageSize==null){
                pageSize = 10;
            }
            return monitorPlatformService.findDeviceLocations(diseaseCondition,page,pageSize,type);
            return monitorPlatformService.findDeviceLocations(diseaseCondition,page,pageSize,type,deviceType);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError("操作失败");

+ 49 - 4
svr/svr-iot/src/main/java/com/yihu/iot/service/equipment/IotEqtDetailService.java

@ -4,19 +4,21 @@ import com.alibaba.fastjson.JSONObject;
import com.yihu.iot.dao.equipment.IotEquipmentDetailDao;
import com.yihu.iot.util.excel.EntityUtils;
import com.yihu.iot.util.excel.HibenateUtils;
import com.yihu.jw.datainput.Data;
import com.yihu.jw.entity.iot.equipment.IotEquipmentDetailDO;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.mysql.query.BaseJpaService;
import iot.device.LocationDataVO;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.data.elasticsearch.core.geo.GeoPoint;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.sql.*;
import java.util.*;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@Service
public class IotEqtDetailService  extends BaseJpaService<IotEquipmentDetailDO, IotEquipmentDetailDao> {
@ -168,4 +170,47 @@ public class IotEqtDetailService  extends BaseJpaService<IotEquipmentDetailDO, I
       return list;
    }
    public List<LocationDataVO> getEquipmentLocation(Integer page, Integer size){
        List<Map<String, Object>> jsonArray = new ArrayList<>();
        List<LocationDataVO> result = new ArrayList<>();
        String sql = "SELECT  " +
                "id AS id,  " +
                "device_code AS deviceSn, " +
                "applicant_name AS name, " +
                "device_name AS equimentName, " +
                "latitude AS lat, " +
                "longitude AS lon, " +
                "create_time AS createTime " +
                "FROM " +
                "iot_equipmet_detail LIMIT "+(page-1)*size+","+size;
        jsonArray = jdbcTemplate.queryForList(sql);
        for (Map<String, Object> jsobj:jsonArray){
            LocationDataVO locationDataVO = new LocationDataVO();
            GeoPoint geoPoint = new GeoPoint(Double.valueOf(jsobj.get("lat").toString()),Double.valueOf(jsobj.get("lon").toString()));
            locationDataVO.setId((String) jsobj.get("id"));
            locationDataVO.setIdCard(null);
            locationDataVO.setCategoryCode("5");
            locationDataVO.setDeviceSn((String) jsobj.get("deviceSn"));
            locationDataVO.setLocation(geoPoint);
            locationDataVO.setDeviceTime(null);
            locationDataVO.setLabel(null);
            locationDataVO.setDiseaseCondition(0);
            locationDataVO.setCreateTime(jsobj.get("createTime").toString());
            locationDataVO.setName((String) jsobj.get("name"));
            locationDataVO.setCode(null);
            locationDataVO.setEquimentName((String) jsobj.get("equimentName"));
            result.add(locationDataVO);
        }
        return result;
    }
    public Integer getEquipmentCount(){
        String sql = "SELECT count(1) totalCount FROM iot_equipmet_detail ";
        Integer totalCount = jdbcTemplate.queryForObject(sql,Integer.class);
        return totalCount;
    }
}

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

@ -70,7 +70,7 @@ public class MonitorPlatformService  {
     * @param diseaseCondition
     * @return
     */
    public MixEnvelop<LocationDataVO, LocationDataVO> findDeviceLocations(Integer diseaseCondition, Integer page, Integer size, String type) throws IOException {
    public MixEnvelop<LocationDataVO, LocationDataVO> findDeviceLocations(Integer diseaseCondition, Integer page, Integer size, String type,String deviceType) throws IOException {
        MixEnvelop<LocationDataVO, LocationDataVO> envelop = new MixEnvelop<>();
        MixEnvelop<LocationDataVO, LocationDataVO> envelopTmp = null;
        JSONArray jsonArray = new JSONArray();
@ -103,6 +103,7 @@ public class MonitorPlatformService  {
            envelop.setTotalCount(total);
            return envelop;
        }else {
            List<LocationDataVO> euipmentList = new ArrayList<>();
            //查找全部
            if(diseaseCondition!=null){
                JSONObject json = new JSONObject();
@ -112,15 +113,40 @@ public class MonitorPlatformService  {
                json.put("value",diseaseCondition);
                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);
            envelop.setTotalCount(iotPatientDeviceService.getESCount(jsonObject.toString()));
            String[] categoryCodes= deviceType.split(",");
            if(categoryCodes.length==1&&"5".equals(deviceType)){
                euipmentList = iotEqtDetailService.getEquipmentLocation(page,size);
                envelop.getDetailModelList().addAll(euipmentList);
                envelop.setTotalCount(iotEqtDetailService.getEquipmentCount());
            }
            else{
                if(deviceType.contains("5")){
                    euipmentList = iotEqtDetailService.getEquipmentLocation(page,size);
                    envelop.getDetailModelList().addAll(euipmentList);
                }
                if(!(deviceType.contains("1")&&deviceType.contains("2"))){
                    for (String categoryCode:categoryCodes){
                        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);
                        }
                    }
                }
                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);
                envelop.setTotalCount(iotPatientDeviceService.getESCount(jsonObject.toString()));
            }
            return envelop;
        }
    }