From 9742e7a70ac6e74d114e68ce1bc8f46670b55453 Mon Sep 17 00:00:00 2001
From: fengxiang <110431245@qq.com>
Date: Mon, 25 Jun 2018 16:39:48 +0800
Subject: [PATCH] 组织配置单位和页面布局
---
src/main/java/com/moral/controller/OrganizationLayoutController.java | 117 ++++++
src/main/java/com/moral/controller/SensorUnitController.java | 39 ++
src/main/java/com/moral/service/DeviceVersionService.java | 4
src/main/java/com/moral/service/impl/DictionaryDataServiceImpl.java | 21 +
src/main/resources/mapper/DictionaryDataMapper.xml | 11
src/main/java/com/moral/mapper/DictionaryDataMapper.java | 3
src/main/java/com/moral/service/impl/SensorUnitServiceImpl.java | 90 +++++
src/main/java/com/moral/service/impl/DeviceVersionServiceImpl.java | 14
src/main/webapp/js/moralmap.js | 2
src/main/java/com/moral/service/SensorService.java | 6
src/main/java/com/moral/entity/layout/RtdLayoutUpload.java | 10
src/main/java/com/moral/mapper/SensorUnitMapper.java | 7
src/main/java/com/moral/service/impl/SensorServiceImpl.java | 17
src/main/resources/mapper/DeviceVersionMapper.xml | 17
src/main/java/com/moral/service/impl/OrganizationLayoutServiceImpl.java | 244 +++++++++++++
src/main/resources/mapper/SensorMapper.xml | 28 +
src/main/java/com/moral/entity/Dictionary.java | 34 -
src/main/java/com/moral/service/MonitorPointService.java | 2
src/main/java/com/moral/controller/ScreenController.java | 39 +-
src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java | 4
src/main/java/com/moral/mapper/DeviceVersionMapper.java | 3
src/main/java/com/moral/service/OrganizationSensorUnitService.java | 14
src/main/java/com/moral/entity/DictionaryData.java | 62 ---
src/main/java/com/moral/service/impl/OrganizationSensorUnitServiceImpl.java | 78 ++++
src/main/java/com/moral/service/DictionaryDataService.java | 9
src/main/java/com/moral/mapper/SensorMapper.java | 4
src/main/java/com/moral/controller/OrganizationSensorUnitController.java | 56 +++
src/main/java/com/moral/entity/layout/SensorComb.java | 18 +
src/main/java/com/moral/service/SensorUnitService.java | 18 +
src/main/resources/mapper/DictionaryMapper.xml | 8
src/main/java/com/moral/service/OrganizationLayoutService.java | 20 +
src/main/resources/system/sysConfig.properties | 2
src/main/java/com/moral/entity/layout/RealTimeDeviceLayout.java | 23 +
src/main/java/com/moral/mapper/DictionaryMapper.java | 1
src/main/java/com/moral/entity/SensorUnit.java | 25 +
src/main/resources/application.yml | 6
36 files changed, 945 insertions(+), 111 deletions(-)
diff --git a/src/main/java/com/moral/controller/OrganizationLayoutController.java b/src/main/java/com/moral/controller/OrganizationLayoutController.java
new file mode 100644
index 0000000..8482391
--- /dev/null
+++ b/src/main/java/com/moral/controller/OrganizationLayoutController.java
@@ -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();
+ }
+}
diff --git a/src/main/java/com/moral/controller/OrganizationSensorUnitController.java b/src/main/java/com/moral/controller/OrganizationSensorUnitController.java
new file mode 100644
index 0000000..5158d46
--- /dev/null
+++ b/src/main/java/com/moral/controller/OrganizationSensorUnitController.java
@@ -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();
+ }
+}
diff --git a/src/main/java/com/moral/controller/ScreenController.java b/src/main/java/com/moral/controller/ScreenController.java
index 66467dd..10915d3 100644
--- a/src/main/java/com/moral/controller/ScreenController.java
+++ b/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);
}
}
diff --git a/src/main/java/com/moral/controller/SensorUnitController.java b/src/main/java/com/moral/controller/SensorUnitController.java
new file mode 100644
index 0000000..cd1a430
--- /dev/null
+++ b/src/main/java/com/moral/controller/SensorUnitController.java
@@ -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();
+ }
+}
diff --git a/src/main/java/com/moral/entity/Dictionary.java b/src/main/java/com/moral/entity/Dictionary.java
index be69fe8..e09ee42 100644
--- a/src/main/java/com/moral/entity/Dictionary.java
+++ b/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;
- }
}
\ No newline at end of file
diff --git a/src/main/java/com/moral/entity/DictionaryData.java b/src/main/java/com/moral/entity/DictionaryData.java
index 05fdaf4..36893dd 100644
--- a/src/main/java/com/moral/entity/DictionaryData.java
+++ b/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;
- }
}
\ No newline at end of file
diff --git a/src/main/java/com/moral/entity/SensorUnit.java b/src/main/java/com/moral/entity/SensorUnit.java
new file mode 100644
index 0000000..16b9fff
--- /dev/null
+++ b/src/main/java/com/moral/entity/SensorUnit.java
@@ -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;
+
+}
\ No newline at end of file
diff --git a/src/main/java/com/moral/entity/layout/RealTimeDeviceLayout.java b/src/main/java/com/moral/entity/layout/RealTimeDeviceLayout.java
new file mode 100644
index 0000000..9b9b96c
--- /dev/null
+++ b/src/main/java/com/moral/entity/layout/RealTimeDeviceLayout.java
@@ -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;
+
+}
diff --git a/src/main/java/com/moral/entity/layout/RtdLayoutUpload.java b/src/main/java/com/moral/entity/layout/RtdLayoutUpload.java
new file mode 100644
index 0000000..0fe814a
--- /dev/null
+++ b/src/main/java/com/moral/entity/layout/RtdLayoutUpload.java
@@ -0,0 +1,10 @@
+package com.moral.entity.layout;
+
+import lombok.Data;
+
+@Data
+public class RtdLayoutUpload {
+ RealTimeDeviceLayout realTimeDeviceLayout;
+ Integer organizationId;
+ Integer version;
+}
diff --git a/src/main/java/com/moral/entity/layout/SensorComb.java b/src/main/java/com/moral/entity/layout/SensorComb.java
new file mode 100644
index 0000000..7c4e7ae
--- /dev/null
+++ b/src/main/java/com/moral/entity/layout/SensorComb.java
@@ -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;
+}
diff --git a/src/main/java/com/moral/mapper/DeviceVersionMapper.java b/src/main/java/com/moral/mapper/DeviceVersionMapper.java
index 62d949e..3629c23 100644
--- a/src/main/java/com/moral/mapper/DeviceVersionMapper.java
+++ b/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);
}
\ No newline at end of file
diff --git a/src/main/java/com/moral/mapper/DictionaryDataMapper.java b/src/main/java/com/moral/mapper/DictionaryDataMapper.java
index 038a4be..0bb1798 100644
--- a/src/main/java/com/moral/mapper/DictionaryDataMapper.java
+++ b/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();
}
\ No newline at end of file
diff --git a/src/main/java/com/moral/mapper/DictionaryMapper.java b/src/main/java/com/moral/mapper/DictionaryMapper.java
index 6ae4aa0..5be2ddd 100644
--- a/src/main/java/com/moral/mapper/DictionaryMapper.java
+++ b/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);
}
\ No newline at end of file
diff --git a/src/main/java/com/moral/mapper/SensorMapper.java b/src/main/java/com/moral/mapper/SensorMapper.java
index c0cd5e8..c7f4ded 100644
--- a/src/main/java/com/moral/mapper/SensorMapper.java
+++ b/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);
diff --git a/src/main/java/com/moral/mapper/SensorUnitMapper.java b/src/main/java/com/moral/mapper/SensorUnitMapper.java
new file mode 100644
index 0000000..85cb886
--- /dev/null
+++ b/src/main/java/com/moral/mapper/SensorUnitMapper.java
@@ -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> {
+}
\ No newline at end of file
diff --git a/src/main/java/com/moral/service/DeviceVersionService.java b/src/main/java/com/moral/service/DeviceVersionService.java
index 44cf766..af8d202 100644
--- a/src/main/java/com/moral/service/DeviceVersionService.java
+++ b/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);
}
diff --git a/src/main/java/com/moral/service/DictionaryDataService.java b/src/main/java/com/moral/service/DictionaryDataService.java
new file mode 100644
index 0000000..d4e72bb
--- /dev/null
+++ b/src/main/java/com/moral/service/DictionaryDataService.java
@@ -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);
+}
diff --git a/src/main/java/com/moral/service/MonitorPointService.java b/src/main/java/com/moral/service/MonitorPointService.java
index 452a257..4328dc4 100644
--- a/src/main/java/com/moral/service/MonitorPointService.java
+++ b/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);
}
diff --git a/src/main/java/com/moral/service/OrganizationLayoutService.java b/src/main/java/com/moral/service/OrganizationLayoutService.java
new file mode 100644
index 0000000..9f15695
--- /dev/null
+++ b/src/main/java/com/moral/service/OrganizationLayoutService.java
@@ -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);
+}
diff --git a/src/main/java/com/moral/service/OrganizationSensorUnitService.java b/src/main/java/com/moral/service/OrganizationSensorUnitService.java
new file mode 100644
index 0000000..e44a885
--- /dev/null
+++ b/src/main/java/com/moral/service/OrganizationSensorUnitService.java
@@ -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);
+}
diff --git a/src/main/java/com/moral/service/SensorService.java b/src/main/java/com/moral/service/SensorService.java
index 5d7bf3d..dd0f733 100644
--- a/src/main/java/com/moral/service/SensorService.java
+++ b/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();
}
diff --git a/src/main/java/com/moral/service/SensorUnitService.java b/src/main/java/com/moral/service/SensorUnitService.java
new file mode 100644
index 0000000..94703af
--- /dev/null
+++ b/src/main/java/com/moral/service/SensorUnitService.java
@@ -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);
+}
diff --git a/src/main/java/com/moral/service/impl/DeviceVersionServiceImpl.java b/src/main/java/com/moral/service/impl/DeviceVersionServiceImpl.java
index 9f15f47..2083175 100644
--- a/src/main/java/com/moral/service/impl/DeviceVersionServiceImpl.java
+++ b/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);
+ }
+
}
diff --git a/src/main/java/com/moral/service/impl/DictionaryDataServiceImpl.java b/src/main/java/com/moral/service/impl/DictionaryDataServiceImpl.java
new file mode 100644
index 0000000..38d4d52
--- /dev/null
+++ b/src/main/java/com/moral/service/impl/DictionaryDataServiceImpl.java
@@ -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);
+ }
+}
diff --git a/src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java b/src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java
index 200db4e..ed3b52e 100644
--- a/src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java
+++ b/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);
+ }
}
diff --git a/src/main/java/com/moral/service/impl/OrganizationLayoutServiceImpl.java b/src/main/java/com/moral/service/impl/OrganizationLayoutServiceImpl.java
new file mode 100644
index 0000000..304ff2c
--- /dev/null
+++ b/src/main/java/com/moral/service/impl/OrganizationLayoutServiceImpl.java
@@ -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());
+ }
+ }
+ }
+ });
+ }
+}
diff --git a/src/main/java/com/moral/service/impl/OrganizationSensorUnitServiceImpl.java b/src/main/java/com/moral/service/impl/OrganizationSensorUnitServiceImpl.java
new file mode 100644
index 0000000..39000d9
--- /dev/null
+++ b/src/main/java/com/moral/service/impl/OrganizationSensorUnitServiceImpl.java
@@ -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);
+ }
+ }
+ );
+ }
+}
diff --git a/src/main/java/com/moral/service/impl/SensorServiceImpl.java b/src/main/java/com/moral/service/impl/SensorServiceImpl.java
index 727f319..c088849 100644
--- a/src/main/java/com/moral/service/impl/SensorServiceImpl.java
+++ b/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();
diff --git a/src/main/java/com/moral/service/impl/SensorUnitServiceImpl.java b/src/main/java/com/moral/service/impl/SensorUnitServiceImpl.java
new file mode 100644
index 0000000..527b123
--- /dev/null
+++ b/src/main/java/com/moral/service/impl/SensorUnitServiceImpl.java
@@ -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;
+ }
+}
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index 0580053..b5a49fb 100644
--- a/src/main/resources/application.yml
+++ b/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
diff --git a/src/main/resources/mapper/DeviceVersionMapper.xml b/src/main/resources/mapper/DeviceVersionMapper.xml
index ef1aac2..ad7b3db 100644
--- a/src/main/resources/mapper/DeviceVersionMapper.xml
+++ b/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>
\ No newline at end of file
diff --git a/src/main/resources/mapper/DictionaryDataMapper.xml b/src/main/resources/mapper/DictionaryDataMapper.xml
index 5d502f6..67efb58 100644
--- a/src/main/resources/mapper/DictionaryDataMapper.xml
+++ b/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>
\ No newline at end of file
diff --git a/src/main/resources/mapper/DictionaryMapper.xml b/src/main/resources/mapper/DictionaryMapper.xml
index f81c477..3127ca3 100644
--- a/src/main/resources/mapper/DictionaryMapper.xml
+++ b/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>
\ No newline at end of file
diff --git a/src/main/resources/mapper/SensorMapper.xml b/src/main/resources/mapper/SensorMapper.xml
index 88cb11d..84e8794 100644
--- a/src/main/resources/mapper/SensorMapper.xml
+++ b/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>
\ No newline at end of file
diff --git a/src/main/resources/system/sysConfig.properties b/src/main/resources/system/sysConfig.properties
index d7432f1..0f6e6b7 100644
--- a/src/main/resources/system/sysConfig.properties
+++ b/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
\ No newline at end of file
+specialOrgIds=5
\ No newline at end of file
diff --git a/src/main/webapp/js/moralmap.js b/src/main/webapp/js/moralmap.js
index 975ed08..276078c 100644
--- a/src/main/webapp/js/moralmap.js
+++ b/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;
--
Gitblit v1.8.0