suntianwu il y a 3 ans
Parent
commit
8cbaf50195

+ 64 - 0
src/main/java/com/iden/bms/controller/WarningRuleController.java

@@ -0,0 +1,64 @@
+package com.iden.bms.controller;
+
+
+import com.iden.bms.service.WarningRuleService;
+import com.iden.common.annotation.Permission;
+import com.iden.common.exception.BDException;
+import com.iden.common.logaspect.LogAnnotation;
+import com.iden.common.logaspect.OperateType;
+import com.iden.common.util.Result;
+import com.iden.common.vo.WarningRuleVO;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import javax.servlet.http.HttpServletRequest;
+
+
+/**
+ * @Author: lilt
+ * @Date: 2021/5/26
+ * @Desc:
+ */
+@RestController
+@Api(value = "WarningRuleController", tags = { "预警规则管理" })
+@Slf4j
+@RequestMapping("/bms/warningRule")
+@Permission
+public class WarningRuleController {
+
+    @Autowired
+    private WarningRuleService warningRuleService;
+
+   
+    @PostMapping("/updateWarningRule")
+    @ApiOperation(value = "修改预警规则")
+    @LogAnnotation(
+            type = OperateType.EDIT,
+            moduleName = "修改预警规则",
+            description = "修改预警规则"
+    )
+    public Result<Object> updateWarningRule(HttpServletRequest request,@RequestHeader("token") String token,
+                                 @RequestBody WarningRuleVO vo){
+        try {
+            this.warningRuleService.updateWarningRule(vo);
+            return  Result.success("修改成功!");
+        }catch (BDException e) {
+            log.error("修改预警规则-出现异常",e);
+            return Result.error(e.getMessage());
+        } catch (Exception e) {
+            log.error("预警规则管理: 修改预警规则出现异常",e);
+            return Result.error("修改失败!");
+        }
+    }
+
+    @GetMapping("/getWarningRuleInfo")
+    @ApiOperation(value = "预警规则详情")
+    public Result<WarningRuleVO> getWarningRuleInfo(HttpServletRequest request, @RequestHeader("token") String token){
+        WarningRuleVO orderInfo = this.warningRuleService.getWarningRuleInfo();
+        return  Result.success("查询成功!",orderInfo);
+    }
+
+   
+}

+ 114 - 0
src/main/java/com/iden/bms/service/WarningRuleService.java

@@ -0,0 +1,114 @@
+package com.iden.bms.service;
+
+import cn.hutool.core.bean.BeanUtil;
+
+import cn.hutool.core.collection.CollUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.iden.common.entity.IdenWarningRuleEventComming;
+import com.iden.common.entity.IdenWarningRuleResident;
+import com.iden.common.entity.IdenWarningRuleStranger;
+import com.iden.common.service.IdenWarningRuleEventCommingService;
+import com.iden.common.service.IdenWarningRuleResidentService;
+import com.iden.common.service.IdenWarningRuleStrangerService;
+import com.iden.common.vo.*;
+
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ *
+ * @author makejava
+ * @since 2021-05-21 00:08:38
+ */
+@Service
+public class WarningRuleService {
+
+    @Resource
+    private IdenWarningRuleStrangerService idenWarningRuleStrangerService;
+    @Resource
+    private IdenWarningRuleResidentService idenWarningRuleResidentService;
+    @Resource
+    private IdenWarningRuleEventCommingService idenWarningRuleEventCommingService;
+
+
+    /**
+     * 详情
+     * @return
+     */
+    public WarningRuleVO getWarningRuleInfo(){
+        WarningRuleVO resVO = new WarningRuleVO();
+        QueryWrapper<IdenWarningRuleStranger> queryWrapper = new QueryWrapper<>();
+        queryWrapper.lambda().orderByDesc(IdenWarningRuleStranger::getModifyTime);
+        queryWrapper.last("limit 1");
+        IdenWarningRuleStranger idenWarningRuleStranger = this.idenWarningRuleStrangerService.getOne(queryWrapper);
+        if (idenWarningRuleStranger != null){
+            WarningRuleStrangerVO warningRuleStrangerVO = new WarningRuleStrangerVO();
+            BeanUtil.copyProperties(idenWarningRuleStranger,warningRuleStrangerVO);
+            resVO.setWarningRuleStrangerVO(warningRuleStrangerVO);
+        }
+
+        QueryWrapper<IdenWarningRuleResident> queryWrapper1 = new QueryWrapper<>();
+        queryWrapper1.lambda().orderByDesc(IdenWarningRuleResident::getModifyTime);
+        queryWrapper1.last("limit 1");
+        IdenWarningRuleResident idenWarningRuleResident = this.idenWarningRuleResidentService.getOne(queryWrapper1);
+        if (idenWarningRuleResident != null){
+            WarningRuleResidentVO warningRuleResidentVO = new WarningRuleResidentVO();
+            BeanUtil.copyProperties(idenWarningRuleResident,warningRuleResidentVO);
+            resVO.setWarningRuleResidentVO(warningRuleResidentVO);
+        }
+
+
+        QueryWrapper<IdenWarningRuleEventComming> queryWrapper2 = new QueryWrapper<>();
+        queryWrapper2.lambda().orderByAsc(IdenWarningRuleEventComming::getCreateTime);
+       List<IdenWarningRuleEventComming> idenWarningRuleEventCommings = this.idenWarningRuleEventCommingService.list(queryWrapper2);
+        if (CollUtil.isNotEmpty(idenWarningRuleEventCommings)){
+            List<WarningRuleEventCommingVO> vos = new ArrayList<>();
+            idenWarningRuleEventCommings.forEach(item-> {
+                WarningRuleEventCommingVO warningRuleEventCommingVO = new WarningRuleEventCommingVO();
+                BeanUtil.copyProperties(item,warningRuleEventCommingVO);
+                vos.add(warningRuleEventCommingVO);
+
+            });
+            resVO.setWarningRuleEventCommingVO(vos);
+        }
+
+        return resVO;
+    }
+
+
+    /**
+     * 修改
+     * @param vo
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public void updateWarningRule(WarningRuleVO vo) {
+        WarningRuleStrangerVO warningRuleStrangerVO = vo.getWarningRuleStrangerVO();
+        IdenWarningRuleStranger idenWarningRuleStranger = new IdenWarningRuleStranger();
+        BeanUtil.copyProperties(warningRuleStrangerVO,idenWarningRuleStranger);
+        this.idenWarningRuleStrangerService.updateById(idenWarningRuleStranger);
+
+        WarningRuleResidentVO warningRuleResidentVO = vo.getWarningRuleResidentVO();
+        IdenWarningRuleResident idenWarningRuleResident = new IdenWarningRuleResident();
+        BeanUtil.copyProperties(warningRuleResidentVO,idenWarningRuleResident);
+        this.idenWarningRuleResidentService.updateById(idenWarningRuleResident);
+
+        List<WarningRuleEventCommingVO>  warningRuleEventCommingVOS = vo.getWarningRuleEventCommingVO();
+        if(CollUtil.isNotEmpty(warningRuleEventCommingVOS)){
+            List<IdenWarningRuleEventComming> idenWarningRuleEventCommings = new ArrayList<>();
+            warningRuleEventCommingVOS.forEach(item->{
+                IdenWarningRuleEventComming idenWarningRuleEventComming = new IdenWarningRuleEventComming();
+                BeanUtil.copyProperties(item,idenWarningRuleEventComming);
+                idenWarningRuleEventCommings.add(idenWarningRuleEventComming);
+            });
+            QueryWrapper<IdenWarningRuleEventComming> queryWrapper = new QueryWrapper<>();
+            //删除原来的,添加新的
+            if(this.idenWarningRuleEventCommingService.remove(queryWrapper)){
+                this.idenWarningRuleEventCommingService.saveBatch(idenWarningRuleEventCommings);
+            }
+        }
+    }
+}

+ 1 - 1
src/main/java/com/iden/common/entity/IdenWarningRuleEventComming.java

@@ -18,7 +18,7 @@ import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
 
 /**
- * 昼伏夜出人口识别预警规则表(IdenWarningRuleEventComming)实体类
+ * 昼伏夜出人口识别预警规则表(WarningRuleEventCommingVO)实体类
  *
  * @author makejava
  * @since 2021-12-30 22:29:49

+ 1 - 1
src/main/java/com/iden/common/entity/IdenWarningRuleResident.java

@@ -17,7 +17,7 @@ import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
 
 /**
- * 常住人口识别预警规则表(IdenWarningRuleResident)实体类
+ * 常住人口识别预警规则表(WarningRuleResidentVO)实体类
  *
  * @author makejava
  * @since 2021-12-30 22:29:50

+ 1 - 1
src/main/java/com/iden/common/entity/IdenWarningRuleStranger.java

@@ -17,7 +17,7 @@ import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
 
 /**
- * 陌生人员识别预警规则表(IdenWarningRuleStranger)实体类
+ * 陌生人员识别预警规则表(WarningRuleStrangerVO)实体类
  *
  * @author makejava
  * @since 2021-12-30 22:29:50

+ 1 - 1
src/main/java/com/iden/common/mapper/IdenWarningRuleEventCommingMapper.java

@@ -5,7 +5,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
 
 /**
- * 昼伏夜出人口识别预警规则表(IdenWarningRuleEventComming)表数据库访问层
+ * 昼伏夜出人口识别预警规则表(WarningRuleEventCommingVO)表数据库访问层
  *
  * @author makejava
  * @since 2021-12-30 22:29:49

+ 1 - 1
src/main/java/com/iden/common/mapper/IdenWarningRuleResidentMapper.java

@@ -5,7 +5,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
 
 /**
- * 常住人口识别预警规则表(IdenWarningRuleResident)表数据库访问层
+ * 常住人口识别预警规则表(WarningRuleResidentVO)表数据库访问层
  *
  * @author makejava
  * @since 2021-12-30 22:29:50

+ 1 - 1
src/main/java/com/iden/common/service/IdenWarningRuleEventCommingService.java

@@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.iden.common.entity.IdenWarningRuleEventComming;
 
 /**
- * 昼伏夜出人口识别预警规则表(IdenWarningRuleEventComming)表服务接口
+ * 昼伏夜出人口识别预警规则表(WarningRuleEventCommingVO)表服务接口
  *
  * @author makejava
  * @since 2021-12-30 22:29:49

+ 1 - 1
src/main/java/com/iden/common/service/IdenWarningRuleResidentService.java

@@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.iden.common.entity.IdenWarningRuleResident;
 
 /**
- * 常住人口识别预警规则表(IdenWarningRuleResident)表服务接口
+ * 常住人口识别预警规则表(WarningRuleResidentVO)表服务接口
  *
  * @author makejava
  * @since 2021-12-30 22:29:50

+ 1 - 1
src/main/java/com/iden/common/service/impl/IdenWarningRuleEventCommingServiceImpl.java

@@ -7,7 +7,7 @@ import com.iden.common.service.IdenWarningRuleEventCommingService;
 import org.springframework.stereotype.Service;
 
 /**
- * 昼伏夜出人口识别预警规则表(IdenWarningRuleEventComming)表服务实现类
+ * 昼伏夜出人口识别预警规则表(WarningRuleEventCommingVO)表服务实现类
  *
  * @author makejava
  * @since 2021-12-30 22:29:49

+ 1 - 1
src/main/java/com/iden/common/service/impl/IdenWarningRuleResidentServiceImpl.java

@@ -7,7 +7,7 @@ import com.iden.common.service.IdenWarningRuleResidentService;
 import org.springframework.stereotype.Service;
 
 /**
- * 常住人口识别预警规则表(IdenWarningRuleResident)表服务实现类
+ * 常住人口识别预警规则表(WarningRuleResidentVO)表服务实现类
  *
  * @author makejava
  * @since 2021-12-30 22:29:50

+ 57 - 0
src/main/java/com/iden/common/vo/WarningRuleEventCommingVO.java

@@ -0,0 +1,57 @@
+package com.iden.common.vo;
+
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 昼伏夜出人口识别预警规则表(WarningRuleEventCommingVO)实体类
+ *
+ * @author makejava
+ * @since 2021-12-30 22:29:49
+ */
+
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "昼伏夜出人口识别预警规则表", description = "")
+public class WarningRuleEventCommingVO implements Serializable {
+    private static final long serialVersionUID = -60553155302887995L;
+
+    private Long id;
+
+    @ApiModelProperty("持续多少天")
+    private int continueDays;
+
+    @ApiModelProperty("开始时间(HH:mm:00),精确到分钟")
+    private String startTime;
+
+
+    @ApiModelProperty("结束时间(HH:mm:00),精确到分钟")
+    private String endTime;
+
+
+    @ApiModelProperty("0出现,1不出现")
+    private String status;
+
+
+    @ApiModelProperty("备注")
+    private String remark;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
+    @ApiModelProperty("createTime")
+    private Date createTime;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
+    @ApiModelProperty("modifyTime")
+    private Date modifyTime;
+
+
+}

+ 43 - 0
src/main/java/com/iden/common/vo/WarningRuleResidentVO.java

@@ -0,0 +1,43 @@
+package com.iden.common.vo;
+
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 常住人口识别预警规则表(WarningRuleResidentVO)实体类
+ *
+ * @author makejava
+ * @since 2021-12-30 22:29:50
+ */
+
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "常住人口识别预警规则表", description = "")
+public class WarningRuleResidentVO implements Serializable {
+    private static final long serialVersionUID = 309294589618110577L;
+
+    private Long id;
+
+
+    @ApiModelProperty("连续X天内未被抓拍到人脸的常住人口")
+    private Integer continueDisappearDays;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
+    @ApiModelProperty("createTime")
+    private Date createTime;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
+    @ApiModelProperty("modifyTime")
+    private Date modifyTime;
+
+
+}

+ 53 - 0
src/main/java/com/iden/common/vo/WarningRuleStrangerVO.java

@@ -0,0 +1,53 @@
+package com.iden.common.vo;
+
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 陌生人员识别预警规则表(WarningRuleStrangerVO)实体类
+ *
+ * @author makejava
+ * @since 2021-12-30 22:29:50
+ */
+
+@Data
+@EqualsAndHashCode(callSuper = false)
+@ApiModel(value = "陌生人员识别预警规则表", description = "")
+public class WarningRuleStrangerVO implements Serializable {
+    private static final long serialVersionUID = -19599267894769977L;
+
+    private Long id;
+
+
+    @ApiModelProperty("陌生人1月内出现频次小于等于X次")
+    private Integer strangerFrequency;
+
+
+    @ApiModelProperty("X天内,未连续出现")
+    private Integer strangerDays;
+
+
+    @ApiModelProperty("1月内出现频次大于X次")
+    private Integer noRegisterFrequency;
+
+
+    @ApiModelProperty("X天内,连续出现")
+    private Integer noRegisterDays;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
+    @ApiModelProperty("createTime")
+    private Date createTime;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
+    @ApiModelProperty("modifyTime")
+    private Date modifyTime;
+
+
+}

+ 34 - 0
src/main/java/com/iden/common/vo/WarningRuleVO.java

@@ -0,0 +1,34 @@
+package com.iden.common.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ *
+ * @author makejava
+ * @since 2021-12-22 17:23:46
+ */
+
+@Data
+@ApiModel(value = "预警规则", description = "")
+public class WarningRuleVO implements Serializable {
+    private static final long serialVersionUID = -91650038520335504L;
+
+
+    @ApiModelProperty("陌生人预警规则")
+    private WarningRuleStrangerVO warningRuleStrangerVO;
+
+
+    @ApiModelProperty("常住人口识别预警规则")
+    private WarningRuleResidentVO warningRuleResidentVO;
+
+
+    @ApiModelProperty("昼伏夜出人口识别预警规则")
+    private List<WarningRuleEventCommingVO> warningRuleEventCommingVO;
+
+
+}