15928045575 2 سال پیش
والد
کامیت
c5527d7044

+ 50 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/AlarmInfoController.java

@@ -0,0 +1,50 @@
+package com.sckw.slope.detection.controller;
+
+import com.alibaba.fastjson2.JSONObject;
+import com.sckw.core.annotation.Log;
+
+import com.sckw.core.web.response.HttpResult;
+
+import com.sckw.slope.detection.model.param.AlarmInfoAdd;
+import com.sckw.slope.detection.model.param.AlarmInfoQuery;
+
+
+import com.sckw.slope.detection.service.KwsAlarmInfoService;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.validation.Valid;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+
+/**
+ * @author sky
+ * @description 报警信息Controller
+ * @date 2023-10-30 17:10:29
+ */
+@Slf4j
+@RestController
+@RequestMapping("/alarmInfo")
+public class AlarmInfoController {
+
+    @Autowired
+    KwsAlarmInfoService kwsAlarmInfoService;
+
+
+
+    @Log(description = "告警信息查询-分页")
+    @RequestMapping(name = "告警信息查询-分页", value = "/select", method = RequestMethod.POST)
+    public HttpResult select(@Valid @RequestBody AlarmInfoQuery query, HttpServletRequest request) {
+        log.info("告警信息查询-分页 select param {}", JSONObject.toJSONString(query));
+        return HttpResult.ok(kwsAlarmInfoService.select(query, request));
+    }
+
+    @Log(description = "告警信息-修改")
+    @RequestMapping(name = "告警信息-修改", value = "/update", method = RequestMethod.POST)
+    public HttpResult update(@Valid @RequestBody AlarmInfoAdd query, HttpServletRequest request) {
+        log.info("告警信息-修改 select param {}", JSONObject.toJSONString(query));
+        return HttpResult.ok(kwsAlarmInfoService.update(query, request));
+    }
+
+
+}

+ 8 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/dao/mysql/KwsAlarmInfoMapper.java

@@ -3,7 +3,13 @@ package com.sckw.slope.detection.dao.mysql;
 import com.baomidou.dynamic.datasource.annotation.DS;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.sckw.slope.detection.model.dos.mysql.KwsAlarmInfo;
+import com.sckw.slope.detection.model.param.AlarmInfoQuery;
+import com.sckw.slope.detection.model.param.DeviceQuery;
+import com.sckw.slope.detection.model.vo.DeviceVo;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 @Mapper
 @DS("mysql")
@@ -17,4 +23,6 @@ public interface KwsAlarmInfoMapper extends BaseMapper<KwsAlarmInfo> {
     int updateByPrimaryKeySelective(KwsAlarmInfo record);
 
     int updateByPrimaryKey(KwsAlarmInfo record);
+
+    List<DeviceVo> selectByDeviceParam(@Param("query") AlarmInfoQuery query);
 }

+ 30 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/param/AlarmInfoAdd.java

@@ -0,0 +1,30 @@
+package com.sckw.slope.detection.model.param;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author sky
+ * @description 统计查询
+ * @date 2023-11-15 10:11:12
+ */
+@Data
+public class AlarmInfoAdd implements Serializable {
+
+    /**
+     * 矿山ID
+     */
+    private String mountainId;
+
+    /**
+     * 矿山ID
+     */
+    private String companyId;
+
+    /**
+     * [{"level":"1","type":"1","value_desc":"15928045575"}]
+     */
+    private String desc;
+
+}

+ 28 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/param/AlarmInfoQuery.java

@@ -0,0 +1,28 @@
+package com.sckw.slope.detection.model.param;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author sky
+ * @description 统计查询
+ * @date 2023-11-15 10:11:12
+ */
+@Data
+public class AlarmInfoQuery implements Serializable {
+
+    /**
+     * 矿山ID
+     */
+    private String mountainId;
+
+    /**
+     * 矿山ID
+     */
+    private String companyId;
+
+    private int page;
+
+    private int pageSize;
+}

+ 101 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/KwsAlarmInfoService.java

@@ -0,0 +1,101 @@
+package com.sckw.slope.detection.service;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import com.sckw.core.model.constant.NumberConstant;
+
+import com.sckw.core.model.page.PageRes;
+
+import com.sckw.core.utils.IdWorker;
+import com.sckw.core.web.response.HttpResult;
+import com.sckw.slope.detection.dao.mysql.*;
+import com.sckw.slope.detection.model.dos.mysql.*;
+import com.sckw.slope.detection.model.dto.HeaderData;
+import com.sckw.slope.detection.model.param.*;
+import com.sckw.slope.detection.model.vo.*;
+
+import jakarta.servlet.http.HttpServletRequest;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
+
+import java.time.LocalDateTime;
+import java.util.*;
+
+/**
+ * @author sky
+ * @description 告警信息service
+ * @date 2023-11-10 15:11:29
+ */
+@Slf4j
+@Service
+public class KwsAlarmInfoService {
+
+    @Autowired
+    CommonService commonService;
+
+    @Autowired
+    KwsAlarmInfoMapper kwsAlarmInfoMapper;
+
+
+    public PageRes select(AlarmInfoQuery query, HttpServletRequest request) {
+        PageHelper.startPage(query.getPage(), query.getPageSize());
+        HeaderData headerData = commonService.getHeaderData(request);
+        query.setMountainId(headerData.getMountainId());
+        List<DeviceVo> list = kwsAlarmInfoMapper.selectByDeviceParam(query);
+        PageInfo<DeviceVo> pageInfo = new PageInfo<>(list);
+        if (CollectionUtils.isEmpty(list)) {
+            return PageRes.build(pageInfo, list);
+        }
+        return PageRes.build(pageInfo, list);
+    }
+    @Transactional
+    public HttpResult update(AlarmInfoAdd infoAdd, HttpServletRequest request) {
+        HeaderData headerData = commonService.getHeaderData(request);
+        LocalDateTime now = LocalDateTime.now();
+        kwsAlarmInfoMapper.update(null, new LambdaUpdateWrapper<KwsAlarmInfo>()
+                .eq(KwsAlarmInfo::getMountainId, headerData.getMountainId())
+                .eq(KwsAlarmInfo::getCompanyId, headerData.getMountainId())
+                .set(KwsAlarmInfo::getUpdateTime, now)
+                .set(KwsAlarmInfo::getDelFlag, NumberConstant.ONE));
+        JSONArray array = JSON.parseArray(infoAdd.getDesc());
+        KwsAlarmInfo alarmInfo = new KwsAlarmInfo();
+        for (Object object : array) {
+            JSONObject obj = (JSONObject) object;
+            KwsAlarmInfo deviceHas = kwsAlarmInfoMapper.selectOne(new LambdaQueryWrapper<KwsAlarmInfo>()
+                    .eq(KwsAlarmInfo::getLevel, obj.get("level"))
+                    .eq(KwsAlarmInfo::getType, obj.get("type"))
+                    .eq(KwsAlarmInfo::getValueDesc, obj.get("value_desc"))
+                    .eq(KwsAlarmInfo::getMountainId, headerData.getMountainId())
+                    .eq(KwsAlarmInfo::getCompanyId, headerData.getMountainId())
+                    .eq(KwsAlarmInfo::getDelFlag, NumberConstant.ZERO)
+            );
+            if(Objects.isNull(deviceHas)){
+                long interId = new IdWorker(NumberConstant.ONE).nextId();
+                alarmInfo.setId(interId);
+                alarmInfo.setMountainId(headerData.getMountainId());
+                alarmInfo.setCompanyId(headerData.getMountainId());
+                alarmInfo.setCreateTime(now);
+                alarmInfo.setLevel(Integer.parseInt(obj.get("level").toString()));
+                alarmInfo.setValueDesc(obj.get("value_desc").toString());
+                alarmInfo.setType(Integer.parseInt(obj.get("type").toString()));
+                alarmInfo.setCreateTime(now);
+                alarmInfo.setUpdateTime(now);
+                kwsAlarmInfoMapper.insert(alarmInfo);
+            }
+
+        }
+        return HttpResult.ok();
+
+
+    }
+
+}

+ 9 - 0
slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsAlarmInfoMapper.xml

@@ -26,6 +26,15 @@
     from kws_alarm_info
     where id = #{id,jdbcType=BIGINT}
   </select>
+
+  <select id="selectByDeviceParam" parameterType="java.lang.Long" resultMap="BaseResultMap">
+    <!--@mbg.generated-->
+    select
+    <include refid="Base_Column_List" />
+    from kws_alarm_info
+    where del_flag=0
+  </select>
+
   <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
     <!--@mbg.generated-->
     delete from kws_alarm_info