Переглянути джерело

Merge branch 'master' of http://124.70.58.209:3000/ytrd-project-management/VehicleMonitor

gao.qiang 1 рік тому
батько
коміт
6673899b6d

+ 15 - 9
business-service/src/main/java/com/ozs/entity/MonitorSystem.java

@@ -37,49 +37,55 @@ public class MonitorSystem extends BaseEntity implements Serializable {
     private String clientId;
 
     /**
-     *监测系统名称
+     * 监测系统名称
      */
     private String monitorSystemName;
 
     /**
-     *系统简介
+     * 系统简介
      */
     private String systemIntroduce;
 
     /**
-     *报警信息内容
+     * 报警信息内容
      */
     private String alarmContent;
 
     /**
-     *报警信息生成机制
+     * 报警信息生成机制
      */
     private String alarmGenerate;
 
     /**
-     *报警解除机制
+     * 报警解除机制
      */
     private String alarmRelease;
 
     /**
-     *报警对应的处理措施
+     * 报警对应的处理措施
      */
     private String treateMeasure;
 
     /**
-     *状态 1在线2离线
+     * 状态 1在线2离线
      */
     private Integer status;
 
     /**
-     *正式环境密钥
+     * 正式环境密钥
      */
     @TableField(exist = false)
     private String clientSecret;
 
     /**
-     *测试环境密钥
+     * 测试环境密钥
      */
     @TableField(exist = false)
     private String testSecret;
+
+    /**
+     * 未解除报警数
+     */
+    @TableField(exist = false)
+    private String countAlarm;
 }

+ 7 - 0
business-service/src/main/java/com/ozs/mapper/MonitorSystemMapper.java

@@ -3,6 +3,9 @@ package com.ozs.mapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.ozs.entity.MonitorSystem;
 
+import java.util.List;
+import java.util.Map;
+
 /**
  * @author wyy
  * @subject
@@ -48,5 +51,9 @@ public interface MonitorSystemMapper extends BaseMapper<MonitorSystem> {
      * @return 结果
      */
     public MonitorSystem checkSystemOnline(Long id);
+
+    Map<String, Object> monitorSystemCount();
+
+    List<MonitorSystem> monitorSystemList();
 }
 

+ 4 - 0
business-service/src/main/java/com/ozs/service/MonitorSystemService.java

@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.ozs.entity.MonitorSystem;
 import com.ozs.entity.vo.MonitorSystemVo;
 
+import java.util.Map;
+
 /**
  * @author wyy
  * @subject
@@ -68,4 +70,6 @@ public interface MonitorSystemService extends IService<MonitorSystem> {
     IPage<MonitorSystemVo> pageList(MonitorSystemVo monitorSystemVo);
 
     MonitorSystem selectByClientId(String clientId);
+
+    Map<String, Object> monitorSystem();
 }

+ 11 - 2
business-service/src/main/java/com/ozs/service/impl/MonitorSystemServiceImpl.java

@@ -20,6 +20,7 @@ import org.springframework.util.CollectionUtils;
 import org.springframework.util.ObjectUtils;
 
 import java.util.List;
+import java.util.Map;
 import java.util.Objects;
 import java.util.stream.Collectors;
 
@@ -135,9 +136,9 @@ public class MonitorSystemServiceImpl extends ServiceImpl<MonitorSystemMapper, M
         if (!CollectionUtils.isEmpty(list) && Objects.nonNull(list.get(0))) {
             list.forEach(l -> {
                 if (l.getEnv().equals(1)) {//测试环境
-                    monitor.setTestSecret(l.getClientSecret());
+                    monitor.setTestSecret(SM4Utils.decryptData_ECB(l.getClientSecret(),KEY));
                 } else if (l.getEnv().equals(2)) {//正式环境
-                    monitor.setClientSecret(l.getClientSecret());
+                    monitor.setClientSecret(SM4Utils.decryptData_ECB(l.getClientSecret(),KEY));
                 }
             });
         }
@@ -174,4 +175,12 @@ public class MonitorSystemServiceImpl extends ServiceImpl<MonitorSystemMapper, M
         MonitorSystem monitorSystem = monitorSystemMapper.selectOne(wrapper);
         return monitorSystem;
     }
+
+    @Override
+    public Map<String, Object> monitorSystem() {
+        Map<String, Object> mapCount = monitorSystemMapper.monitorSystemCount();
+        List<MonitorSystem> monitorSystemList = monitorSystemMapper.monitorSystemList();
+        mapCount.put("monitorSystemList", monitorSystemList);
+        return mapCount;
+    }
 }

+ 15 - 0
business-service/src/main/resources/mapper/MonitorSystemMapper.xml

@@ -65,4 +65,19 @@
         <include refid="selectMonitorSystemVo"/>
         where id = #{id}
     </select>
+
+    <select id="monitorSystemCount"  resultType="java.util.Map">
+        select count(id) AS countAllMonitor,
+               SUM(CASE status WHEN '0' THEN 1 ELSE 0 end) AS offlineMonitor,
+               SUM(CASE status WHEN '1' THEN 1 ELSE 0 end) AS onlineMonitor
+        from monitor_system
+    </select>
+
+    <select id="monitorSystemList" resultType="com.ozs.entity.MonitorSystem">
+        SELECT a.*, b.countAlarm, b.SOURCE FROM (
+            SELECT * FROM monitor_system
+        ) a LEFT JOIN (
+            SELECT count(id) countAlarm, SOURCE FROM msg_alarm where IS_RELEASE = 2 GROUP BY SOURCE
+        ) b ON a.CLIENT_ID = b.SOURCE
+    </select>
 </mapper>

+ 3 - 1
vehicle-admin/src/main/java/com/ozs/web/controller/accountmanagment/MsgAlarmController.java

@@ -177,7 +177,9 @@ public class MsgAlarmController extends BaseController {
                 }
                 if(!ObjectUtils.isEmpty(o.getSource())){
                     MonitorSystem monitorSystem = monitorSystemService.selectByClientId(o.getSource());
-                    o.setSourceName(monitorSystem.getMonitorSystemName());
+                    if(!ObjectUtils.isEmpty(monitorSystem)){
+                        o.setSourceName(monitorSystem.getMonitorSystemName());
+                    }
                 }
                 String mils = AppendUtils.stringAppend(o.getAlarmMile());
                 o.setAlarmMiles(mils);

+ 34 - 12
vehicle-admin/src/main/java/com/ozs/web/controller/system/MonitorSystemController.java

@@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.*;
 
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
 import java.util.UUID;
 
 /**
@@ -31,56 +32,74 @@ public class MonitorSystemController extends BaseController {
     @Autowired
     private MonitorSystemService monitorSystemService;
 
+    /**
+     * 首页-监测系统信息
+     *
+     * @param
+     * @return
+     */
+    @Log(title = "首页-监测系统信息", businessType = BusinessType.SELECT)
+    @PostMapping("/monitorSystem")
+    @ApiOperation(value = "首页-监测系统信息")
+    public AjaxResult monitorSystem() {
+        Map<String, Object> monitorSystem = monitorSystemService.monitorSystem();
+        return AjaxResult.success(monitorSystem);
+    }
+
     /**
      * 分页查询
+     *
      * @param
      * @return
      */
     @Log(title = "监测系统-分页查询", businessType = BusinessType.SELECT)
     @PostMapping("/pageList")
     @ApiOperation(value = "监测系统分页查询")
-    public AjaxResult pageList(@RequestBody MonitorSystemVo monitorSystemVo){
-        IPage<MonitorSystemVo> page =  monitorSystemService.pageList(monitorSystemVo);
+    public AjaxResult pageList(@RequestBody MonitorSystemVo monitorSystemVo) {
+        IPage<MonitorSystemVo> page = monitorSystemService.pageList(monitorSystemVo);
         return AjaxResult.success(page);
     }
 
     /**
      * 监测系统名称查询
+     *
      * @param
      * @return
      */
     @Log(title = "监测系统-监测系统名称查询", businessType = BusinessType.SELECT)
     @GetMapping("/list")
     @ApiOperation(value = "监测系统-监测系统名称查询")
-    public AjaxResult list(){
+    public AjaxResult list() {
         LambdaQueryWrapper<MonitorSystem> wrapper = new LambdaQueryWrapper<MonitorSystem>();
-        wrapper.eq(MonitorSystem::getStatus,1);
+        wrapper.eq(MonitorSystem::getStatus, 1);
         List<MonitorSystem> list = monitorSystemService.list(wrapper);
         return AjaxResult.success(list);
     }
 
     /**
      * 详情查看
+     *
      * @param
      * @return
      */
     @Log(title = "监测系统-详情查看", businessType = BusinessType.SELECT)
     @GetMapping("/{id}")
     @ApiOperation(value = "监测系统-详情查看")
-    public AjaxResult detail(@PathVariable Long id){
+    public AjaxResult detail(@PathVariable Long id) {
         MonitorSystem monitorSystem = monitorSystemService.getMonitorSystem(id);
         return AjaxResult.success(monitorSystem);
     }
 
     /**
      * 新增
+     *
      * @param
      * @return
      */
     @Log(title = "监测系统-新增", businessType = BusinessType.INSERT)
     @PostMapping("/add")
     @ApiOperation(value = "监测系统-新增")
-    public AjaxResult add(@RequestBody MonitorSystem monitorSystem){
+    public AjaxResult add(@RequestBody MonitorSystem monitorSystem) {
         if (UserConstants.NOT_UNIQUE.equals(monitorSystemService.checkClientIdUnique(monitorSystem))) {
             return error("监测系统新增'" + monitorSystem.getClientId() + "'失败,客户端编码已存在");
         }
@@ -90,26 +109,28 @@ public class MonitorSystemController extends BaseController {
 
     /**
      * 删除
+     *
      * @param
      * @return
      */
     @Log(title = "监测系统-删除", businessType = BusinessType.DELETE)
     @DeleteMapping("/{ids}")
     @ApiOperation(value = "监测系统-删除")
-    public AjaxResult delete(@PathVariable Long[] ids){
-         monitorSystemService.deleteByIds(ids);
-         return AjaxResult.success();
+    public AjaxResult delete(@PathVariable Long[] ids) {
+        monitorSystemService.deleteByIds(ids);
+        return AjaxResult.success();
     }
 
     /**
      * 修改
+     *
      * @param
      * @return
      */
     @Log(title = "监测系统-修改", businessType = BusinessType.UPDATE)
     @PutMapping
     @ApiOperation(value = "监测系统-修改")
-    public AjaxResult update(@RequestBody MonitorSystem monitorSystem){
+    public AjaxResult update(@RequestBody MonitorSystem monitorSystem) {
         if (UserConstants.EXCEPTION.equals(monitorSystemService.checkSystemOnline(monitorSystem))) {
             return error("监测系统修改'" + monitorSystem.getClientId() + "'失败,该系统正在使用中,无法修改");
         }
@@ -120,15 +141,16 @@ public class MonitorSystemController extends BaseController {
 
     /**
      * 生成密钥
+     *
      * @param
      * @return
      */
     @Log(title = "监测系统-生成密钥", businessType = BusinessType.SELECT)
     @GetMapping("/getSecret")
     @ApiOperation(value = "监测系统-生成密钥")
-    public AjaxResult getSecret(){
+    public AjaxResult getSecret() {
         UUID id = UUID.randomUUID();
         String[] idd = id.toString().split("-");
-        return AjaxResult.success(idd[0]+idd[1]+idd[2]);
+        return AjaxResult.success(idd[0] + idd[1] + idd[2]);
     }
 }