fengxiang
2018-06-25 9742e7a70ac6e74d114e68ce1bc8f46670b55453
组织配置单位和页面布局
16 files added
20 files modified
1056 ■■■■ changed files
src/main/java/com/moral/controller/OrganizationLayoutController.java 117 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/controller/OrganizationSensorUnitController.java 56 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/controller/ScreenController.java 39 ●●●● patch | view | raw | blame | history
src/main/java/com/moral/controller/SensorUnitController.java 39 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/entity/Dictionary.java 34 ●●●● patch | view | raw | blame | history
src/main/java/com/moral/entity/DictionaryData.java 62 ●●●● patch | view | raw | blame | history
src/main/java/com/moral/entity/SensorUnit.java 25 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/entity/layout/RealTimeDeviceLayout.java 23 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/entity/layout/RtdLayoutUpload.java 10 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/entity/layout/SensorComb.java 18 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/mapper/DeviceVersionMapper.java 3 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/mapper/DictionaryDataMapper.java 3 ●●●● patch | view | raw | blame | history
src/main/java/com/moral/mapper/DictionaryMapper.java 1 ●●●● patch | view | raw | blame | history
src/main/java/com/moral/mapper/SensorMapper.java 4 ●●●● patch | view | raw | blame | history
src/main/java/com/moral/mapper/SensorUnitMapper.java 7 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/DeviceVersionService.java 4 ●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/DictionaryDataService.java 9 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/MonitorPointService.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/OrganizationLayoutService.java 20 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/OrganizationSensorUnitService.java 14 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/SensorService.java 6 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/SensorUnitService.java 18 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/DeviceVersionServiceImpl.java 14 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/DictionaryDataServiceImpl.java 21 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java 4 ●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/OrganizationLayoutServiceImpl.java 244 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/OrganizationSensorUnitServiceImpl.java 78 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/SensorServiceImpl.java 17 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/SensorUnitServiceImpl.java 90 ●●●●● patch | view | raw | blame | history
src/main/resources/application.yml 6 ●●●● patch | view | raw | blame | history
src/main/resources/mapper/DeviceVersionMapper.xml 17 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/DictionaryDataMapper.xml 11 ●●●● patch | view | raw | blame | history
src/main/resources/mapper/DictionaryMapper.xml 8 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/SensorMapper.xml 28 ●●●●● patch | view | raw | blame | history
src/main/resources/system/sysConfig.properties 2 ●●● patch | view | raw | blame | history
src/main/webapp/js/moralmap.js 2 ●●● patch | view | raw | blame | history
src/main/java/com/moral/controller/OrganizationLayoutController.java
New file
@@ -0,0 +1,117 @@
package com.moral.controller;
import com.moral.common.bean.ResultBean;
import com.moral.entity.DeviceVersion;
import com.moral.entity.Sensor;
import com.moral.entity.layout.RealTimeDeviceLayout;
import com.moral.entity.layout.RtdLayoutUpload;
import com.moral.entity.layout.SensorComb;
import com.moral.service.DeviceVersionService;
import com.moral.service.OrganizationLayoutService;
import com.moral.service.SensorService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@RestController
@RequestMapping("org-layout")
public class OrganizationLayoutController {
    @Resource
    private OrganizationLayoutService organizationLayoutService;
    @Resource
    private SensorService sensorService;
    @Resource
    private DeviceVersionService deviceVersionService;
    @GetMapping("rtd-config")
    public ResultBean<Map<String,Object>> getRealTimeDevicetConfig(Integer orgId){
        Map<String,Object> resultMap = new HashMap();
        resultMap.put("deviceVersions","");
        resultMap.put("sensors","");
        resultMap.put("rtdLayout","");
        // 获取当前组织所含设备版本数组
        List<DeviceVersion> deviceVersionList = deviceVersionService.queryByOrgId(orgId);
        // 获取第一个version 下所有传感器
        if (deviceVersionList!=null && deviceVersionList.size()>0) {
            Integer versionId = deviceVersionList.get(0).getId();
            Integer versionNum = deviceVersionList.get(0).getVersion();
            // 转为 SensorComb 保持对象一致
            List<String> fixedItemKeys =  organizationLayoutService.getFixedItemKeys();
            List<SensorComb> optionalFixedItems = new ArrayList<>();
            List<SensorComb> sensorCombList =  sensorService.queryListByVersionId(versionId)
                    .stream()
                    .filter(item -> {
                        for (String key: fixedItemKeys) {
                            if( key.equals(item.getSensorKey()) ) {
                                SensorComb sensorComb = new SensorComb();
                                sensorComb.setName(item.getDescription());
                                sensorComb.setSensorKey(item.getSensorKey());
                                optionalFixedItems.add(sensorComb);
                                return false;
                            }
                        }
                        return true;
                    })
                    .map(item -> {
                        SensorComb sensorComb = new SensorComb();
                        sensorComb.setName(item.getDescription());
                        sensorComb.setSensorKey(item.getSensorKey());
                        return  sensorComb;
                    }).collect(Collectors.toList());
            RealTimeDeviceLayout realTimeDeviceLayout = organizationLayoutService.queryRealTimeDeviceLayout(orgId,versionNum);
            resultMap.put("deviceVersions",deviceVersionList);
            resultMap.put("sensorCombs",sensorCombList);
            resultMap.put("rtdLayout",realTimeDeviceLayout);
            resultMap.put("optionalFixedItems",optionalFixedItems);
        }
        return new ResultBean<>(resultMap);
    }
    @GetMapping("rtd-act-config")
    public ResultBean<Map<String,Object>> getRealTimeDeviceConfigWithVer(Integer orgId,Integer versionNo){
        Map<String,Object> resultMap = new HashMap();
        resultMap.put("sensors","");
        resultMap.put("rtdLayout","");
            // 转为 SensorComb 保持对象一致
        List<String> fixedItemKeys =  organizationLayoutService.getFixedItemKeys();
        List<SensorComb> optionalFixedItems = new ArrayList<>();
        List<SensorComb> sensorCombList =  sensorService.queryListByVersionNo(versionNo)
                .stream()
                .filter(item -> {
                    for (String key: fixedItemKeys) {
                        if( key.equals(item.getSensorKey()) ) {
                            SensorComb sensorComb = new SensorComb();
                            sensorComb.setName(item.getDescription());
                            sensorComb.setSensorKey(item.getSensorKey());
                            optionalFixedItems.add(sensorComb);
                            return false;
                        }
                    }
                    return true;
                })
                .map(item -> {
                        SensorComb sensorComb = new SensorComb();
                        sensorComb.setName(item.getDescription());
                        sensorComb.setSensorKey(item.getSensorKey());
                        return  sensorComb;
                    }).collect(Collectors.toList());
            RealTimeDeviceLayout realTimeDeviceLayout = organizationLayoutService.queryRealTimeDeviceLayout(orgId,versionNo);
            resultMap.put("sensorCombs",sensorCombList);
            resultMap.put("rtdLayout",realTimeDeviceLayout);
            resultMap.put("optionalFixedItems",optionalFixedItems); // 可显示固定项
        return new ResultBean<>(resultMap);
    }
    @PostMapping("rtd-save")
    public  ResultBean RealTimeDeviceSave(@RequestBody RtdLayoutUpload rtdLayoutUpload) {
        organizationLayoutService.saveRtdLayout(rtdLayoutUpload);
        return ResultBean.success();
    }
    @GetMapping("rtd-remove")
    public  ResultBean RealTimeDeviceRemove(Integer orgId,Integer version) {
        organizationLayoutService.deleteRtdLayout(orgId,version);
        return ResultBean.success();
    }
}
src/main/java/com/moral/controller/OrganizationSensorUnitController.java
New file
@@ -0,0 +1,56 @@
package com.moral.controller;
import com.moral.common.bean.ResultBean;
import com.moral.entity.OrganizationSensorUnit;
import com.moral.entity.SensorUnit;
import com.moral.service.OrganizationSensorUnitService;
import com.moral.service.SensorUnitService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@RestController
@RequestMapping("org-sunit")
public class OrganizationSensorUnitController {
    @Resource
    OrganizationSensorUnitService osuService;
    @Resource
    SensorUnitService sensorUnitService;
    /**
     *  获取组织和单位对应关系实体组
     * @param orgId
     * @return
     */
    @GetMapping("gets-byoid")
    public ResultBean getListByorgId(Integer orgId) {
        Map resultData = new HashMap();
        List<OrganizationSensorUnit> osuList = osuService.queryAllByOrgId(orgId);
        if(osuList!=null && osuList.size()>0) {
            List<Integer> sensorIdList = osuList.stream().map(item -> {
                return item.getSensor().getId();
            }).collect(Collectors.toList());
            Map sensorUnitMap = sensorUnitService.queryGroupSensorBySids(sensorIdList);
            // 只输出有选项的
            List resultOsuList = osuList.stream().filter(item -> {
                    Integer id = item.getSensor().getId();
                    return sensorUnitMap.get(id)!=null;
            }).collect(Collectors.toList());
            resultData.put("osuList",resultOsuList);
            resultData.put("sensorUnitMap",sensorUnitMap);
        }else {
            resultData.put("osuList",new ArrayList<>()); // 组织和待选单位
            resultData.put("sensorUnitMap",new Object()); // 待选单位
        }
        return new ResultBean(resultData);
    }
    @PostMapping("saves")
    public ResultBean saves(@RequestBody List<OrganizationSensorUnit> osuList){
        osuService.addsOrModifys(osuList);
        return  ResultBean.success();
    }
}
src/main/java/com/moral/controller/ScreenController.java
@@ -15,6 +15,8 @@
import com.moral.entity.alarm.AlarmConfig;
import com.moral.entity.alarm.AlarmConfigValue;
import com.moral.entity.charts.DataSortCondition;
import com.moral.entity.layout.RealTimeDeviceLayout;
import com.moral.service.*;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.log4j.Logger;
@@ -45,16 +47,6 @@
import com.moral.common.util.ValidateUtil;
import com.moral.common.xml.Version;
import com.moral.entity.alarm.AlarmSensorLevel;
import com.moral.service.AccountService;
import com.moral.service.AlarmConfigService;
import com.moral.service.AlarmDailyService;
import com.moral.service.AreaService;
import com.moral.service.DeviceService;
import com.moral.service.HistoryMinutelyService;
import com.moral.service.HistoryService;
import com.moral.service.MachineActivateService;
import com.moral.service.MonitorPointService;
import com.moral.service.SensorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
@@ -80,6 +72,8 @@
    SensorService sensorService;
    @Resource
    MonitorPointService monitorPointService;
    @Resource
    DeviceVersionService  deviceVersionService;
    /** The screen service. */
    @Resource
@@ -112,6 +106,8 @@
    @Resource
    private AlarmDailyService alarmDailyService;
    @Resource
    private OrganizationLayoutService orgLayoutService;
    /**
     * Screen login. 大屏登录
     * 
@@ -584,15 +580,22 @@
    })
    @GetMapping("rtm-layout")
    public ResultBean realTimeMonitorLayout(String primaryKey,String type){
        InputStreamReader reader = null;
        Map<String,Object> map = null;
        try {
            reader = new InputStreamReader(resource.getInputStream(),"UTF-8");
            map = new JSONReader(reader).readObject(new TypeReference<Map<String,Object>>() {});
        } catch (IOException e) {
            e.printStackTrace();
        RealTimeDeviceLayout rtdLayout = null;
        if(type != null && type.equals("device")) {
            Device device = deviceService.getDeviceByMac(primaryKey,false);
            if(device!= null
            && device.getOrganizationIds()!=null
            && device.getOrganizationIds().size() >0
            && device.getDeviceVersionId()!=null) {
                 Integer orgId = device.getOrganizationIds().get(0);
                 DeviceVersion deviceVersion = deviceVersionService.queryVersionById(device.getDeviceVersionId());
                 rtdLayout = orgLayoutService.queryRtdLayoutWithUnit(orgId,deviceVersion.getVersion());
            }else {
                return  ResultBean.fail();
        }
        return new ResultBean(map);
        }
        return new ResultBean(rtdLayout);
    }
}
src/main/java/com/moral/controller/SensorUnitController.java
New file
@@ -0,0 +1,39 @@
package com.moral.controller;
import com.moral.common.bean.ResultBean;
import com.moral.entity.SensorUnit;
import com.moral.service.SensorUnitService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@RestController
@RequestMapping("sensor-unit")
@CrossOrigin(origins = "*", maxAge = 3600)
public class SensorUnitController {
    @Resource
    SensorUnitService sensorUnitService;
    @PostMapping("add-or-modify")
    public ResultBean addOrModify(@RequestBody SensorUnit sensorUnit){
        ResultBean resultBean = new ResultBean(ResultBean.SUCCESS);
        if(!sensorUnitService.addOrModify(sensorUnit)){
            resultBean.setCode(ResultBean.FAIL);
        }
        return resultBean;
    }
    /**
     *  获取单位数组
     * @param sensorId
     * @return
     */
    @GetMapping("gets-bysid")
    public ResultBean getListBySensorId(Integer sensorId) {
        return  new ResultBean(sensorUnitService.queryListBySensorId(sensorId));
    }
    @GetMapping("delete")
    public ResultBean delete(Integer id) {
         sensorUnitService.remove(id);
         return  ResultBean.success();
    }
}
src/main/java/com/moral/entity/Dictionary.java
@@ -1,33 +1,17 @@
package com.moral.entity;
public class Dictionary {
    private String dictName;
import lombok.Data;
    private Integer dictValue;
@Data
public class Dictionary {
    private String dictKey;
    private Integer id;
    private String dictName;
    private Integer isDelete;
    public String getDictName() {
        return dictName;
    }
    private String description;
    public void setDictName(String dictName) {
        this.dictName = dictName == null ? null : dictName.trim();
    }
    public Integer getDictValue() {
        return dictValue;
    }
    public void setDictValue(Integer dictValue) {
        this.dictValue = dictValue;
    }
    public Integer getIsDelete() {
        return isDelete;
    }
    public void setIsDelete(Integer isDelete) {
        this.isDelete = isDelete;
    }
}
src/main/java/com/moral/entity/DictionaryData.java
@@ -1,9 +1,14 @@
package com.moral.entity;
import lombok.Data;
@Data
public class DictionaryData {
    private Integer id;
    private Integer dictValue;
    private Integer dictId;
    private String dictDataKey;
    private String dictDataName;
@@ -15,59 +20,6 @@
    private Integer parentId;
    public Integer getId() {
        return id;
    }
    private String description;
    public void setId(Integer id) {
        this.id = id;
    }
    public Integer getDictValue() {
        return dictValue;
    }
    public void setDictValue(Integer dictValue) {
        this.dictValue = dictValue;
    }
    public String getDictDataName() {
        return dictDataName;
    }
    public void setDictDataName(String dictDataName) {
        this.dictDataName = dictDataName == null ? null : dictDataName.trim();
    }
    public Object getDictDataValue() {
        return dictDataValue;
    }
    public void setDictDataValue(Object dictDataValue) {
        this.dictDataValue = dictDataValue;
    }
    public Integer getIsFixed() {
        return isFixed;
    }
    public void setIsFixed(Integer isFixed) {
        this.isFixed = isFixed;
    }
    public Integer getIsDelete() {
        return isDelete;
    }
    public void setIsDelete(Integer isDelete) {
        this.isDelete = isDelete;
    }
    public Integer getParentId() {
        return parentId;
    }
    public void setParentId(Integer parentId) {
        this.parentId = parentId;
    }
}
src/main/java/com/moral/entity/SensorUnit.java
New file
@@ -0,0 +1,25 @@
package com.moral.entity;
import lombok.Data;
import javax.persistence.Id;
import java.util.Date;
@Data
public class SensorUnit {
    @Id
    private Integer id;
    private Integer sensorId;
    private String name;
    private String rules;
    private Boolean isDelete;
    private Date createTime;
    private Date updateTime;
}
src/main/java/com/moral/entity/layout/RealTimeDeviceLayout.java
New file
@@ -0,0 +1,23 @@
package com.moral.entity.layout;
import lombok.Data;
import java.util.Arrays;
import java.util.List;
@Data
public class RealTimeDeviceLayout {
     public static String PageTypePrefix = "real_time_device_";
     public static String ChartSensorKey = "chartSensorKey";
     public static String BottomFixedMonitorItem = "leftBottomFixedMonitorItem";
     public static String DefaultMonitorItems = "defaultMonitorItems";
     public static String CoreMonitorItems = "coreMonitorItems";
     public static String FixedMonitorItems = "fixedMonitorItems";
     Integer id;
     String name;
     String chartSensorKey;
     List<SensorComb> fixedMonitorItems;
     List<SensorComb> defaultMonitorItems;
     List<SensorComb> coreMonitorItems;
}
src/main/java/com/moral/entity/layout/RtdLayoutUpload.java
New file
@@ -0,0 +1,10 @@
package com.moral.entity.layout;
import lombok.Data;
@Data
public class RtdLayoutUpload {
    RealTimeDeviceLayout realTimeDeviceLayout;
    Integer organizationId;
    Integer version;
}
src/main/java/com/moral/entity/layout/SensorComb.java
New file
@@ -0,0 +1,18 @@
package com.moral.entity.layout;
import lombok.Data;
/**
 *  sensor数据组合
 */
@Data
public class SensorComb {
//    Integer Id;
    Integer sensorId;
    Integer index;
    String  sensorKey;
    String  name;
    String  sourceUnit;
    String  targetUnit;
    String  evaluator;
}
src/main/java/com/moral/mapper/DeviceVersionMapper.java
@@ -3,5 +3,8 @@
import com.moral.common.mapper.BaseMapper;
import com.moral.entity.DeviceVersion;
import java.util.List;
public interface DeviceVersionMapper extends BaseMapper<DeviceVersion> {
    public List<DeviceVersion> selectListByOrgId(Integer orgId);
}
src/main/java/com/moral/mapper/DictionaryDataMapper.java
@@ -2,7 +2,8 @@
import com.moral.common.mapper.BaseMapper;
import com.moral.entity.DictionaryData;
import org.apache.ibatis.annotations.Param;
public interface DictionaryDataMapper extends BaseMapper<DictionaryData> {
//    DictionaryData selectByPrimaryKey(Integer id);
    public  Integer selectSupperOrgId();
}
src/main/java/com/moral/mapper/DictionaryMapper.java
@@ -4,5 +4,4 @@
import com.moral.entity.Dictionary;
public interface DictionaryMapper extends BaseMapper<Dictionary> {
//    Dictionary selectByPrimaryKey(String dictName);
}
src/main/java/com/moral/mapper/SensorMapper.java
@@ -9,6 +9,10 @@
public interface SensorMapper extends BaseMapper<Sensor> {
    List<Sensor> selectByVersionId(Integer deviceVersionId);
    List<Sensor> selectByVersionNo(Integer deviceVersionId);
    List<Sensor> selectByOrgId(Integer organizationId);
    List<Map<String, Object>> getSensorsByDeviceVersionId(Integer deviceVersionId);
    
    List<Sensor> getSensorsByCriteria(Map<String, Object> parameters);
src/main/java/com/moral/mapper/SensorUnitMapper.java
New file
@@ -0,0 +1,7 @@
package com.moral.mapper;
import com.moral.common.mapper.BaseMapper;
import com.moral.entity.SensorUnit;
public interface SensorUnitMapper extends BaseMapper<SensorUnit> {
}
src/main/java/com/moral/service/DeviceVersionService.java
@@ -15,4 +15,8 @@
    void versionSensorConfig(Integer deviceVersionId, Integer[] sensorIds);
    List<Integer> getSensorIds(int deviceVersionId);
    List<DeviceVersion> queryByOrgId(Integer organizationId);
    DeviceVersion queryVersionById(Integer versionId);
}
src/main/java/com/moral/service/DictionaryDataService.java
New file
@@ -0,0 +1,9 @@
package com.moral.service;
import com.moral.entity.DictionaryData;
import java.util.List;
public interface DictionaryDataService {
    List<DictionaryData> queryByKey(String dictDataKey);
}
src/main/java/com/moral/service/MonitorPointService.java
@@ -28,4 +28,6 @@
    List<MonitorPoint> getMonitorPointsByRegion(Map<String, Object> parameters);
    List<Integer> queryVersionsById(Integer id);
    MonitorPoint queryMonitorPointById(Integer mpointId);
}
src/main/java/com/moral/service/OrganizationLayoutService.java
New file
@@ -0,0 +1,20 @@
package com.moral.service;
import com.moral.entity.layout.RealTimeDeviceLayout;
import com.moral.entity.layout.RtdLayoutUpload;
import org.springframework.data.annotation.Transient;
import java.util.List;
public interface OrganizationLayoutService {
    List<String> getFixedItemKeys();
    RealTimeDeviceLayout queryRealTimeDeviceLayout(Integer orgId, Integer version);
    @Transient
    void  saveRtdLayout(RtdLayoutUpload rtdUpload);
    void  deleteRtdLayout(Integer orgId, Integer version);
    RealTimeDeviceLayout queryRtdLayoutWithUnit(Integer orgId, Integer versionNo);
}
src/main/java/com/moral/service/OrganizationSensorUnitService.java
New file
@@ -0,0 +1,14 @@
package com.moral.service;
import com.moral.entity.OrganizationSensorUnit;
import org.springframework.data.annotation.Transient;
import java.util.List;
public interface OrganizationSensorUnitService {
    List<OrganizationSensorUnit> queryAllByOrgId(Integer organizationId);
    List<OrganizationSensorUnit> queryByOrgId(Integer organizationId);
    @Transient
    void addsOrModifys(List<OrganizationSensorUnit> osuList);
}
src/main/java/com/moral/service/SensorService.java
@@ -14,8 +14,14 @@
    PageBean queryByVersionId(Integer deviceVersionId);
    List<Sensor> queryListByVersionId(Integer deviceVersionId);
    List<Sensor> queryListByVersionNo(Integer versionNo);
    public void addOrModify(Sensor sensor);
    public void deleteByIds(Integer... ids);
    List<Sensor> queryByOrgId(Integer organizationId);
    public List<Sensor> getAllSensors();
}
src/main/java/com/moral/service/SensorUnitService.java
New file
@@ -0,0 +1,18 @@
package com.moral.service;
import com.moral.entity.SensorUnit;
import java.util.List;
import java.util.Map;
public interface SensorUnitService {
     public boolean addOrModify(SensorUnit sensorUnit);
    List<SensorUnit> queryListBySensorId(int sensorId);
    List<SensorUnit> queryListBySensorId(int sensorId, Boolean isDelete);
    void remove(Integer id);
    Map<Integer,List<SensorUnit>> queryGroupSensorBySids(List<Integer> sensorIds);
}
src/main/java/com/moral/service/impl/DeviceVersionServiceImpl.java
@@ -4,6 +4,7 @@
import com.moral.common.util.MyBatisBaseMapUtil;
import com.moral.entity.DeviceVersion;
import com.moral.entity.DeviceVersionSensor;
import com.moral.entity.Sensor;
import com.moral.mapper.DeviceVersionMapper;
import com.moral.mapper.DeviceVersionSensorMapper;
import com.moral.service.DeviceVersionService;
@@ -66,6 +67,9 @@
                  deviceVersionSensorMapper.insertList(deviceVersionSensorList);
            }
      }
      public List<DeviceVersion> getVersionsByOrgId(int organizationId){
            return null;
      }
      @Override
      public List<Integer> getSensorIds(int deviceVersionId){
            DeviceVersionSensor deviceVersionSensor = new DeviceVersionSensor();
@@ -77,4 +81,14 @@
            }
            return sensorIds;
      }
      @Override
      public  List<DeviceVersion> queryByOrgId(Integer organizationId){
            return  this.deviceVersionMapper.selectListByOrgId(organizationId);
      }
      @Override
      public DeviceVersion queryVersionById(Integer versionId) {
            return deviceVersionMapper.selectByPrimaryKey(versionId);
      }
}
src/main/java/com/moral/service/impl/DictionaryDataServiceImpl.java
New file
@@ -0,0 +1,21 @@
package com.moral.service.impl;
import com.moral.entity.DictionaryData;
import com.moral.mapper.DictionaryDataMapper;
import com.moral.service.DictionaryDataService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service
public class DictionaryDataServiceImpl implements DictionaryDataService{
    @Resource
    DictionaryDataMapper dataMapper;
    @Override
    public List<DictionaryData> queryByKey(String dictDataKey) {
        DictionaryData query = new DictionaryData();
        query.setDictDataKey(dictDataKey);
        return  dataMapper.select(query);
    }
}
src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java
@@ -226,4 +226,8 @@
    public List<Integer> queryVersionsById(Integer id){
        return  monitorPointMapper.selectVersionsById(id);
    }
    @Override
    public MonitorPoint queryMonitorPointById(Integer mpointId) {
        return  this.monitorPointMapper.selectByPrimaryKey(mpointId);
    }
}
src/main/java/com/moral/service/impl/OrganizationLayoutServiceImpl.java
New file
@@ -0,0 +1,244 @@
package com.moral.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.moral.entity.*;
import com.moral.entity.layout.RealTimeDeviceLayout;
import com.moral.entity.layout.RtdLayoutUpload;
import com.moral.entity.layout.SensorComb;
import com.moral.mapper.DictionaryDataMapper;
import com.moral.mapper.OrganizationLayoutMapper;
import com.moral.mapper.OrganizationSensorUnitMapper;
import com.moral.mapper.SensorMapper;
import com.moral.service.OrganizationLayoutService;
import org.springframework.data.annotation.Transient;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;
import javax.annotation.Resource;
import javax.naming.Name;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class OrganizationLayoutServiceImpl implements OrganizationLayoutService{
    @Resource
    SensorMapper sensorMapper;
    @Resource
    OrganizationLayoutMapper orgLayoutMapper;
    @Resource
    OrganizationSensorUnitMapper orgUnitMapper;
    private static String pageLayoutFixedItems = "page_layout_fixed_items";
    @Resource
    DictionaryDataMapper dataMapper;
    private DictionaryData queryDictionaryData(String dictDataKey) {
        DictionaryData query = new DictionaryData();
        query.setDictDataKey(dictDataKey);
        List<DictionaryData> dataList = dataMapper.select(query);
        List<String> fixedItemKeys = new ArrayList<>();
        if(dataList.size()>0) {
            return  dataList.get(0);
        }
        return  null;
    }
    @Override
    public List<String> getFixedItemKeys() {
        DictionaryData dictionaryData = queryDictionaryData(pageLayoutFixedItems);
        List<String> fixedItemKeys = new ArrayList<>();
            if(dictionaryData!=null && dictionaryData.getDictDataValue()!=null ) {
                List<String> keyList  = JSON.parseObject(dictionaryData.getDictDataValue().toString(),
                        new TypeReference<List<String>>(){});
                if(keyList!=null) {
                    fixedItemKeys.addAll(keyList);
                }
            }
        return fixedItemKeys;
    }
    public Integer queryPageConfigCountByOrgId(Integer orgId,String pageType) {
        OrganizationLayout query = new OrganizationLayout();
        query.setOrganizationId(orgId);
        query.setPageType(pageType);
        return  orgLayoutMapper.selectCount(query);
    }
    @Override
    public RealTimeDeviceLayout queryRealTimeDeviceLayout(Integer orgId,Integer version){
        String pageType = getPageType(version);
        if(queryPageConfigCountByOrgId(orgId,pageType) > 0) {
            RealTimeDeviceLayout rtdLayout = new RealTimeDeviceLayout();
            Example example = new Example(OrganizationLayout.class);
            // 升序排序
            example.orderBy("pagePositionIndex").asc();
            // 查询图表key
            example.or().andEqualTo("pageType",pageType)
                    .andEqualTo("organizationId",orgId)
                    .andEqualTo("pagePosition",RealTimeDeviceLayout.ChartSensorKey);
           List<OrganizationLayout> ChartSensorKeys = orgLayoutMapper.selectByExample(example);
           if(ChartSensorKeys.size()>0) {
               rtdLayout.setChartSensorKey(ChartSensorKeys.get(0).getPagePositionValue());
           }
           // 查询默认区
            example.clear();
            example.or().andEqualTo("pageType",pageType)
                    .andEqualTo("organizationId",orgId)
                    .andEqualTo("pagePosition",RealTimeDeviceLayout.DefaultMonitorItems);
            List<OrganizationLayout> defaultMonitorItems = orgLayoutMapper.selectByExample(example);
            List<SensorComb> defaultSensorCombList = defaultMonitorItems.stream().map(
                    item-> {
                        SensorComb sensorComb = new SensorComb();
                        sensorComb.setSensorKey(item.getPagePositionValue());
                        sensorComb.setIndex(item.getPagePositionIndex());
                        return  sensorComb;
                    }
            ).collect(Collectors.toList());
            rtdLayout.setDefaultMonitorItems(defaultSensorCombList);
            // 查询核心区
            example.clear();
            example.or().andEqualTo("pageType",pageType)
                    .andEqualTo("organizationId",orgId)
                    .andEqualTo("pagePosition",RealTimeDeviceLayout.CoreMonitorItems);
            List<OrganizationLayout> coreMonitorItems = orgLayoutMapper.selectByExample(example);
            List<SensorComb> coreSensorCombList = coreMonitorItems.stream().map(
                    item-> {
                        SensorComb sensorComb = new SensorComb();
                        sensorComb.setSensorKey(item.getPagePositionValue());
                        sensorComb.setIndex(item.getPagePositionIndex());
                        return  sensorComb;
                    }
            ).collect(Collectors.toList());
            rtdLayout.setCoreMonitorItems(coreSensorCombList);
            // 查询固定区
            example.clear();
            example.or().andEqualTo("pageType",pageType)
                    .andEqualTo("organizationId",orgId)
                    .andEqualTo("pagePosition",RealTimeDeviceLayout.FixedMonitorItems);
            List<OrganizationLayout> fixedMonitorItems = orgLayoutMapper.selectByExample(example);
            List<SensorComb> fixedSensorCombList = fixedMonitorItems.stream().map(
                    item-> {
                        SensorComb sensorComb = new SensorComb();
                        sensorComb.setSensorKey(item.getPagePositionValue());
                        sensorComb.setIndex(item.getPagePositionIndex());
                        return  sensorComb;
                    }
            ).collect(Collectors.toList());
            rtdLayout.setFixedMonitorItems(fixedSensorCombList);
            this.loadSensorToComb(rtdLayout);
            return  rtdLayout;
        }
        return  null;
    }
    private void loadSensorToComb(RealTimeDeviceLayout rtdLayout) {
        List<SensorComb> allSensorCombList = new ArrayList<>();
        allSensorCombList.addAll(rtdLayout.getCoreMonitorItems());
        allSensorCombList.addAll(rtdLayout.getDefaultMonitorItems());
        allSensorCombList.addAll(rtdLayout.getFixedMonitorItems());
        List<String> sensorKeyList = allSensorCombList.stream().map(
                item -> {
                    return item.getSensorKey();
                }
        ).collect(Collectors.toList());
        Example example = new Example(Sensor.class);
        example.or().andIn("sensorKey",sensorKeyList);
        List<Sensor> sensorList = sensorMapper.selectByExample(example);
        for (SensorComb sensorComb: allSensorCombList) {
              for (Sensor sensor :sensorList) {
                  if(sensor.getSensorKey()!=null
                          &&sensor.getSensorKey().equals(sensorComb.getSensorKey())){
                      sensorComb.setName(sensor.getDescription());
                      sensorComb.setSensorId(sensor.getId());
                      sensorComb.setSourceUnit(sensor.getUnit());
                      sensorComb.setTargetUnit(sensor.getUnit());
                  }
              }
        }
    }
    public static  String getPageType(Integer version) {
      return  RealTimeDeviceLayout.PageTypePrefix + version.toString();
    }
    @Transient
    @Override
    public void  saveRtdLayout(RtdLayoutUpload rtdUpload) {
        String pageType = getPageType(rtdUpload.getVersion());
        Integer orgId = rtdUpload.getOrganizationId();
        RealTimeDeviceLayout rtdLayout = rtdUpload.getRealTimeDeviceLayout();
        // 清空旧数据
        this.deleteRtdLayout(orgId,rtdUpload.getVersion());
        OrganizationLayout orgLayout = new OrganizationLayout();
        orgLayout.setOrganizationId(orgId);
        orgLayout.setPageType(pageType);
        //  储存chartSensorKey
        orgLayout.setPagePosition(RealTimeDeviceLayout.ChartSensorKey);
        orgLayout.setPagePositionIndex(0);
        orgLayout.setPagePositionValue(rtdLayout.getChartSensorKey());
        orgLayoutMapper.insert(orgLayout);
        // 储存核心区
        List<SensorComb> coreSensorList = rtdLayout.getCoreMonitorItems();
        orgLayout.setPagePosition(RealTimeDeviceLayout.CoreMonitorItems);
        if( coreSensorList !=null ) {
            for(int index=0;index< coreSensorList.size();index++) {
                orgLayout.setPagePositionIndex(index);
                orgLayout.setPagePositionValue(coreSensorList.get(index).getSensorKey());
                orgLayoutMapper.insert(orgLayout);
            }
        }
        // 储存核心区
        List<SensorComb> defaultSensorList = rtdLayout.getDefaultMonitorItems();
        orgLayout.setPagePosition(RealTimeDeviceLayout.DefaultMonitorItems);
        if ( defaultSensorList != null ){
            for(int index=0;index< defaultSensorList.size();index++) {
                orgLayout.setPagePositionIndex(index);
                orgLayout.setPagePositionValue(defaultSensorList.get(index).getSensorKey());
                orgLayoutMapper.insert(orgLayout);
            }
        }
        // 储存固定区
        List<SensorComb> fixedSensorList = rtdLayout.getFixedMonitorItems();
        orgLayout.setPagePosition(RealTimeDeviceLayout.FixedMonitorItems);
        if( fixedSensorList != null ) {
            for(int index=0;index< fixedSensorList.size();index++) {
                orgLayout.setPagePositionIndex(index);
                orgLayout.setPagePositionValue(fixedSensorList.get(index).getSensorKey());
                orgLayoutMapper.insert(orgLayout);
            }
        }
    }
    @Override
    public  void  deleteRtdLayout(Integer orgId, Integer version) {
        // 清空旧数据
        OrganizationLayout query = new OrganizationLayout();
        query.setOrganizationId(orgId);
        query.setPageType(getPageType(version));
        orgLayoutMapper.delete(query);
    }
    @Override
    public  RealTimeDeviceLayout queryRtdLayoutWithUnit(Integer orgId, Integer versionNo) {
        String pageType = getPageType(versionNo);
        if(queryPageConfigCountByOrgId(orgId,pageType) == 0 ){
            orgId = dataMapper.selectSupperOrgId();
        }
        RealTimeDeviceLayout rtdLayout = queryRealTimeDeviceLayout(orgId,versionNo);
        loadUnitToComb(orgId,rtdLayout);
        return  rtdLayout;
    }
    // 装载单位信息到布局配置
    private void loadUnitToComb(Integer orgId,RealTimeDeviceLayout rtdLayout) {
        List<SensorComb> allList = new ArrayList<>();
        allList.addAll(rtdLayout.getCoreMonitorItems());
        allList.addAll(rtdLayout.getDefaultMonitorItems());
        allList.addAll(rtdLayout.getFixedMonitorItems());
        List<OrganizationSensorUnit> orgUnitList = orgUnitMapper.selectByOrgId(orgId);
        allList.forEach(item -> {
              for(OrganizationSensorUnit orgUnit: orgUnitList) {
                  SensorUnit sensorUnit = orgUnit.getSensorUnit();
                  if( sensorUnit!=null && sensorUnit.getSensorId() !=null) {
                        if(sensorUnit.getSensorId() == item.getSensorId()) {
                            item.setTargetUnit(sensorUnit.getName());
                            item.setEvaluator(sensorUnit.getRules());
                        }
                  }
              }
        });
    }
}
src/main/java/com/moral/service/impl/OrganizationSensorUnitServiceImpl.java
New file
@@ -0,0 +1,78 @@
package com.moral.service.impl;
import com.moral.entity.OrganizationSensorUnit;
import com.moral.entity.Sensor;
import com.moral.entity.SensorUnit;
import com.moral.mapper.OrganizationSensorUnitMapper;
import com.moral.mapper.SensorMapper;
import com.moral.service.OrganizationSensorUnitService;
import org.springframework.data.annotation.Transient;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Service
public class OrganizationSensorUnitServiceImpl implements OrganizationSensorUnitService{
    @Resource
    OrganizationSensorUnitMapper osuMapper;
    @Resource
    SensorMapper sensorMapper;
    /**
     * 获取所有传感器单位对应关系
     * @param organizationId
     * @return
     */
    @Override
    public List<OrganizationSensorUnit> queryAllByOrgId(Integer organizationId) {
            // 获取当前组织下所有传感器
            List<Sensor> sensorList = sensorMapper.selectByOrgId(organizationId);
            // 获取单位组织对应关系拉出单位数据
            List<OrganizationSensorUnit> organizationSensorUnits = osuMapper.selectByOrgId(organizationId);
            List<OrganizationSensorUnit> returnList = new ArrayList<>();
            for (int index=0;index<sensorList.size();index++){
                 Sensor sensor = sensorList.get(index);
                 OrganizationSensorUnit osuOutEntity = null;
                 for (int num =0; num< organizationSensorUnits.size();num++) {
                    OrganizationSensorUnit osuTemp = organizationSensorUnits.get(num);
                    SensorUnit sensorUnit = osuTemp.getSensorUnit();
                    if(sensorUnit!=null&&sensor.getId() == sensorUnit.getSensorId() ){
                        osuOutEntity = osuTemp;
                        break;
                    }
                 }
                 if(osuOutEntity==null) {osuOutEntity = new OrganizationSensorUnit();}
                 osuOutEntity.setOrganizationId(organizationId);
                 osuOutEntity.setSensor(sensor);
                returnList.add(osuOutEntity);
            }
            return  returnList;
    }
    @Override
    public List<OrganizationSensorUnit> queryByOrgId(Integer organizationId) {
        return osuMapper.selectByOrgId(organizationId);
    }
    @Override
    @Transient
    public void addsOrModifys(List<OrganizationSensorUnit> osuList) {
        osuList.forEach(
                item -> {
                    if(item.getId() != null) {
                        if(item.getSensorUnitId() == null) {
                            osuMapper.deleteByPrimaryKey(item);
                        }else {
                            osuMapper.updateByPrimaryKeySelective(item);
                        }
                    }else{
                        item.setCreateTime(new Date());
                        osuMapper.insertSelective(item);
                    }
                }
        );
    }
}
src/main/java/com/moral/service/impl/SensorServiceImpl.java
@@ -35,6 +35,14 @@
        List<Sensor> sensorList = sensorMapper.selectByVersionId(deviceVersionId);
        return  new PageBean(sensorList);
    }
    @Override
    public List<Sensor> queryListByVersionId(Integer deviceVersionId){
        return sensorMapper.selectByVersionId(deviceVersionId);
    }
    @Override
    public List<Sensor> queryListByVersionNo(Integer versionNo){
        return sensorMapper.selectByVersionNo(versionNo);
    }
    public void addOrModify(Sensor sensor){
        try{
            if(sensor.getId()==null){
@@ -62,6 +70,15 @@
        }
    }
    /**
     * 获取当前组织下所有传感器并集
     * @param organizationId
     * @return
     */
    @Override
    public List<Sensor> queryByOrgId(Integer organizationId) {
        return sensorMapper.selectByOrgId(organizationId);
    }
    @Override
    public List<Sensor> getAllSensors() {
        return sensorMapper.selectAll();
src/main/java/com/moral/service/impl/SensorUnitServiceImpl.java
New file
@@ -0,0 +1,90 @@
package com.moral.service.impl;
import com.moral.entity.SensorUnit;
import com.moral.mapper.SensorUnitMapper;
import com.moral.service.SensorService;
import com.moral.service.SensorUnitService;
import org.apache.log4j.Logger;
import org.springframework.data.annotation.Transient;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class SensorUnitServiceImpl implements SensorUnitService{
    private static Logger log = Logger.getLogger(SensorService.class);
    @Resource
    private SensorUnitMapper sensorUnitMapper;
    @Override
    public boolean addOrModify(SensorUnit sensorUnit) {
        try {
            if(sensorUnit.getId()!=null) {
                sensorUnit.setUpdateTime(new Date());
                sensorUnitMapper.updateByPrimaryKeySelective(sensorUnit);
            }else{
                sensorUnit.setIsDelete(false);
                sensorUnit.setCreateTime(new Date());
                sensorUnitMapper.insertSelective(sensorUnit);
            }
            return true;
        } catch (Exception ex) {
            ex.printStackTrace();
            log.error(ex.getMessage());
        }
        return false;
    }
    @Override
    public List<SensorUnit> queryListBySensorId(int sensorId) {
        return queryListBySensorId(sensorId,false);
    }
    /**
     * 根据传感器id 获取 所属传感器数组
     * @param sensorId
     * @return
     */
    @Override
    public List<SensorUnit> queryListBySensorId(int sensorId, Boolean isDelete) {
        SensorUnit sensorUnitQuery = new SensorUnit();
        sensorUnitQuery.setSensorId(sensorId);
        sensorUnitQuery.setIsDelete(isDelete);
        return  sensorUnitMapper.select(sensorUnitQuery);
    }
    /**
     * 根据传感器单位实体id 删除
     * @param id
     */
    @Override
    public void remove(Integer id) {
         SensorUnit sensorUnit = new SensorUnit();
         sensorUnit.setId(id);
         sensorUnit.setIsDelete(true);
         sensorUnit.setUpdateTime(new Date());
         sensorUnitMapper.updateByPrimaryKeySelective(sensorUnit);
    }
    /**
     * 获取传感器单位数组分组
     * @param sensorIds
     * @return
     */
    @Override
    public Map<Integer,List<SensorUnit>> queryGroupSensorBySids(List<Integer> sensorIds){
        SensorUnit sensorUnitQuery = new SensorUnit();
        Map<Integer,List<SensorUnit>> resultList = new HashMap<>();
        for(Integer sensorId: sensorIds) {
            sensorUnitQuery.setSensorId(sensorId);
            List<SensorUnit> sensorUnitList = sensorUnitMapper.select(sensorUnitQuery);
            if(sensorUnitList!=null&&sensorUnitList.size()>0){
                resultList.put(sensorId,sensorUnitList);
            }
        }
        return  resultList;
    }
}
src/main/resources/application.yml
@@ -52,10 +52,10 @@
  redis:
    host: 47.96.19.115
    host: 47.100.8.247
    port: 6379
    password: redis_pass
    database: 0
    password:
    database: 1
    timeout: 0
    pool:
      max-active: 8
src/main/resources/mapper/DeviceVersionMapper.xml
@@ -8,4 +8,21 @@
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="description" jdbcType="VARCHAR" property="description" />
  </resultMap>
  <select id="selectListByOrgId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
          SELECT
              *
          FROM
              device_version dvn
          WHERE
              dvn.id IN (
          SELECT DISTINCT
              dev.device_version_id
          FROM
              device dev
          WHERE
              dev.monitor_point_id IN
                ( SELECT id FROM monitor_point mpt WHERE mpt.organization_id = #{orgId,jdbcType=INTEGER} )
              )
          order by dvn.create_time desc
  </select>
</mapper>
src/main/resources/mapper/DictionaryDataMapper.xml
@@ -3,14 +3,21 @@
<mapper namespace="com.moral.mapper.DictionaryDataMapper" >
  <resultMap id="BaseResultMap" type="com.moral.entity.DictionaryData" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="dict_value" property="dictValue" jdbcType="INTEGER" />
    <result column="dict_id" property="dictId" jdbcType="INTEGER" />
    <result column="dict_data_key" property="dictDataKey" jdbcType="VARCHAR" />
    <result column="dict_data_name" property="dictDataName" jdbcType="VARCHAR" />
    <result column="dict_data_value" property="dictDataValue" jdbcType="OTHER" />
    <result column="is_fixed" property="isFixed" jdbcType="INTEGER" />
    <result column="is_delete" property="isDelete" jdbcType="INTEGER" />
    <result column="parent_id" property="parentId" jdbcType="INTEGER" />
    <result column="description" property="description" jdbcType="VARCHAR" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, dict_value, dict_data_name, dict_data_value, is_fixed, is_delete, parent_id
    id, dict_id, dict_data_key, dict_data_name, dict_data_value, is_fixed, is_delete,
    parent_id, description
  </sql>
  <select id="selectSupperOrgId" parameterType="java.lang.String" resultType="java.lang.Integer">
    select dict_data_value from dictionary_data
    where dict_data_key = 'auth_config_super_org'
  </select>
</mapper>
src/main/resources/mapper/DictionaryMapper.xml
@@ -2,11 +2,13 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.moral.mapper.DictionaryMapper" >
  <resultMap id="BaseResultMap" type="com.moral.entity.Dictionary" >
    <id column="dict_name" property="dictName" jdbcType="VARCHAR" />
    <result column="dict_value" property="dictValue" jdbcType="INTEGER" />
    <id column="dict_key" property="dictKey" jdbcType="VARCHAR" />
    <result column="id" property="id" jdbcType="INTEGER" />
    <result column="dict_name" property="dictName" jdbcType="VARCHAR" />
    <result column="is_delete" property="isDelete" jdbcType="INTEGER" />
    <result column="description" property="description" jdbcType="VARCHAR" />
  </resultMap>
  <sql id="Base_Column_List" >
    dict_name, dict_value, is_delete
    dict_key, id, dict_name, is_delete, description
  </sql>
</mapper>
src/main/resources/mapper/SensorMapper.xml
@@ -23,6 +23,21 @@
       where sen.id = dvs.sensor_id and dvs.device_version_id = #{deviceVersionId,jdbcType=INTEGER}
    )
  </select>
  <select id="selectByVersionNo" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select
    <include refid="Base_Column_List" />
    from sensor sen
    where EXISTS
    (  select id
       from device_version_sensor dvs
       where sen.id = dvs.sensor_id
       and dvs.device_version_id in
          (
              select dev.id from device_version dev
                where dev.version = #{versionNo,jdbcType=INTEGER}
          )
    )
  </select>
  
      <select id="getSensorsByDeviceVersionId" resultType="java.util.Map">
        SELECT
@@ -66,5 +81,16 @@
            AND d.profession_id = #{professionId}
            </if>
    </select>
    <select id="selectByOrgId" resultMap="BaseResultMap">
          select * from sensor sen where sen.id in
            (
               select DISTINCT sensor_id from device_version_sensor dvs
                 where dvs.device_version_id in (
                        select DISTINCT device_version_id from device dev where
                        EXISTS (select * from monitor_point mpt where
                         mpt.organization_id = #{organizationId,jdbcType=INTEGER} and mpt.id = dev.monitor_point_id
                        )
                 )
            ) order by sen.id asc
    </select>
</mapper>
src/main/resources/system/sysConfig.properties
@@ -28,4 +28,4 @@
orgId=5
password=123456
noFilters=/**/*.css,/**/*.json,/alarm/**,/screen/**,/**/*.jsp,/**/*.js,/**/*.gif,/**/*.png,/**/*.ico,/**/*.html,/**/*.map,/machineactivate/**,/device/**,/sensor/**,/mobile/**,/page/**,/swagger*/**,/v2/**,/webjars/**
specialOrgIds=-1,5
specialOrgIds=5
src/main/webapp/js/moralmap.js
@@ -436,7 +436,7 @@
                                state = stateObj["state"];
                                stateName = stateObj["stateName"];
                                var name = e['name'];
                                if(moralMap.getUtf8Length(name) > 24) {
                                if(moralMap.getUtf8Length(name) > 22) {
                                    var stop1 = 0;
                                    for(var stop1_i = 0, len = 0; stop1_i < name.length; stop1_i++) {
                                        len += ((name.charCodeAt(stop1_i) & 0xff00) != 0) ? 2 : 1;