Browse Source

预警信息

cuimengchao 3 years ago
parent
commit
1d2a99f919

+ 74 - 5
src/main/java/com/yx/face/controller/admin/UserControlEarlyWarningListLogController.java

@@ -1,8 +1,26 @@
 package com.yx.face.controller.admin;
 
 
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
+
+import com.github.pagehelper.PageInfo;
+import com.yx.face.boot.core.BaseController;
+import com.yx.face.boot.restful.RestDTO;
+import com.yx.face.boot.restful.RestResponse;
+import com.yx.face.boot.restful.RestResult;
+import com.yx.face.boot.restful.ServiceException;
+import com.yx.face.model.query.UserEarlyWarningLogQu;
+import com.yx.face.model.vo.UserEarlyWarningLogVO;
+import com.yx.face.service.UserControlEarlyWarningListLogService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
 
 /**
  * <p>
@@ -12,8 +30,59 @@ import org.springframework.web.bind.annotation.RequestMapping;
  * @author wxg
  * @since 2022-01-24
  */
-@Controller
-@RequestMapping("/userControlEarlyWarningListLog")
-public class UserControlEarlyWarningListLogController {
+@Slf4j
+@RequiredArgsConstructor(onConstructor = @__(@Autowired))
+@Api(tags = "B获取预警信息API")
+@RestController
+@RequestMapping("admin/controlEarlyWarningListLog")
+public class UserControlEarlyWarningListLogController extends BaseController {
+
+    private final UserControlEarlyWarningListLogService userControlEarlyWarningListLogService;
+
+
+    @ApiOperation("预警信息")
+    @GetMapping("/getListLog")
+    public RestResult<List<UserEarlyWarningLogVO>> getListLog() {
+        Integer adminId = getUserId();
+        if (adminId == null || adminId <= 0) {
+            throw new ServiceException("无此权限");
+        }
+        List<UserEarlyWarningLogVO> pageList = this.userControlEarlyWarningListLogService.getListLog(adminId);
+        if (pageList != null) {
+            return RestResponse.ok(pageList);
+        }
+        return RestResponse.error("获取常客列表分页失败");
+    }
+
+
+    @ApiOperation("预警确认")
+    @GetMapping("/earlyWarningConfirm")
+    public RestResult<Boolean> earlyWarningConfirm(@ApiParam(name = "id", value = "预警id") @RequestParam("id") Long id) {
+        if (id == null || id <= 0) {
+            throw new ServiceException("id为空");
+        }
+        Integer insert = this.userControlEarlyWarningListLogService.updateEarlyWarningConfirm(id);
+        if (insert == 1) return RestResponse.ok(true);
+        else return RestResponse.error("更新失败");
+    }
+
+
+    @ApiOperation("查询预警列表-分页")
+    @PostMapping("/getListLogPageInfo")
+    public RestResult<PageInfo<UserEarlyWarningLogVO>> getListLogPageInfo(@RequestBody RestDTO<UserEarlyWarningLogQu> dto) {
+        if (dto.getData() == null) {
+            dto.setData(new UserEarlyWarningLogQu());
+        }
+        dto.getData().setAdminId(getUserIdL());
+        PageInfo<UserEarlyWarningLogVO> pageInfo = this.userControlEarlyWarningListLogService.getListLogPageInfo(dto);
+        return RestResponse.ok(pageInfo);
+    }
+
 
+    @ApiOperation("导出Excel")
+    @PostMapping("/getListLogExcel")
+    public void getListLogExcel(@RequestBody UserEarlyWarningLogQu dto, HttpServletResponse response) {
+        dto.setAdminId(getUserIdL());
+        this.userControlEarlyWarningListLogService.getListLogExcel(dto, response);
+    }
 }

+ 14 - 0
src/main/java/com/yx/face/dao/UserControlEarlyWarningListLogDao.java

@@ -1,7 +1,14 @@
 package com.yx.face.dao;
 
 import com.yx.face.boot.component.tk.TKMapper;
+import com.yx.face.model.entity.Admin;
 import com.yx.face.model.entity.UserControlEarlyWarningListLog;
+import com.yx.face.model.excel.UserEarlyWarningLogExcel;
+import com.yx.face.model.vo.UserEarlyWarningLogVO;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.HashMap;
+import java.util.List;
 
 /**
  * <p>
@@ -13,4 +20,11 @@ import com.yx.face.model.entity.UserControlEarlyWarningListLog;
  */
 public interface UserControlEarlyWarningListLogDao extends TKMapper<UserControlEarlyWarningListLog> {
 
+    List<UserEarlyWarningLogVO> getListLog(Admin adminInfo);
+
+    int updateEarlyWarningConfirm(@Param("id") Long id, @Param("status") Integer status);
+
+    List<UserEarlyWarningLogVO> getListLogPageInfo(HashMap<String, Object> map);
+
+    List<UserEarlyWarningLogExcel> getUserEarlyWarningLogExcel(HashMap<String, Object> map);
 }

+ 64 - 0
src/main/java/com/yx/face/model/excel/UserEarlyWarningLogExcel.java

@@ -0,0 +1,64 @@
+package com.yx.face.model.excel;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @description:
+ * @ClassName UserVisitorListVO
+ * @Author cmc
+ * @Date 2021/11/5 14:23
+ */
+@ColumnWidth(22)
+@ApiModel("预警信息 model")
+@Data
+public class UserEarlyWarningLogExcel {
+
+    @ExcelProperty(value = "设备名称", index = 0)
+    @ApiModelProperty(value = "设备sn名称")
+    private String snName;
+
+    @ExcelProperty(value = "预警人现场照片", index = 1)
+    @ApiModelProperty(value = "预警人现场照片")
+    private String photo;
+
+
+    @ExcelProperty(value = "预警人姓名", index = 2)
+    @ApiModelProperty(value = "预警人姓名")
+    private String name;
+
+    @ExcelProperty(value = "预警人身份证号", index = 3)
+    @ApiModelProperty(value = "预警人身份证号")
+    private String idNumber;
+
+    @ExcelProperty(value = "布控人姓名", index = 4)
+    @ApiModelProperty(value = "布控人姓名")
+    private String controlName;
+
+    @ExcelProperty(value = "布控人手机号", index = 5)
+    @ApiModelProperty(value = "布控人手机号")
+    private String controlPhone;
+
+
+    @ExcelProperty(value = "布控人单位", index = 6)
+    @ApiModelProperty(value = "布控人单位")
+    private String controlUnit;
+
+
+    @ExcelProperty(value = "进出闸机时间", index = 7)
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "进出闸机时间")
+    private Date faceTime;
+
+
+    @ExcelProperty(value = "预警是否确认1否2是", index = 8)
+    @ApiModelProperty(value = "预警是否确认1否2是")
+    private Integer status;
+
+}

+ 51 - 0
src/main/java/com/yx/face/model/query/UserEarlyWarningLogQu.java

@@ -0,0 +1,51 @@
+package com.yx.face.model.query;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @description:
+ * @ClassName UserVisitorListVO
+ * @Author cmc
+ * @Date 2021/11/5 14:23
+ */
+@ApiModel("预警信息 model")
+@Data
+public class UserEarlyWarningLogQu {
+
+
+    //    @ApiModelProperty(value = "设备sn名称")
+//    private String snName;
+    @ApiModelProperty(value = "开始时间")
+    private String startTime;
+
+    @ApiModelProperty(value = "结束时间")
+    private String endTime;
+
+    @ApiModelProperty(value = "预警人姓名")
+    private String name;
+
+    @ApiModelProperty(value = "预警人身份证号")
+    private String idNumber;
+
+    @ApiModelProperty(value = "预警是否确认1否2是")
+    private Integer status;
+
+
+    @ApiModelProperty(value = "布控人单位")
+    private String controlUnit;
+
+    @ApiModelProperty(value = "布控人手机号")
+    private String controlPhone;
+
+    @ApiModelProperty(value = "布控人姓名")
+    private String controlName;
+
+    @ApiModelProperty(value = "adminId", hidden = true)
+    private Long adminId;
+
+}

+ 50 - 0
src/main/java/com/yx/face/model/vo/UserEarlyWarningLogVO.java

@@ -0,0 +1,50 @@
+package com.yx.face.model.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @description:
+ * @ClassName UserVisitorListVO
+ * @Author cmc
+ * @Date 2021/11/5 14:23
+ */
+@ApiModel("预警信息 model")
+@Data
+public class UserEarlyWarningLogVO {
+
+    @ApiModelProperty(value = "预警id")
+    private Long id;
+
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "进出闸机时间")
+    private Date faceTime;
+
+    @ApiModelProperty(value = "设备sn名称")
+    private String snName;
+
+    @ApiModelProperty(value = "预警人姓名")
+    private String name;
+
+    @ApiModelProperty(value = "预警人身份证号")
+    private String idNumber;
+
+    @ApiModelProperty(value = "预警人现场照片")
+    private String photo;
+
+    @ApiModelProperty(value = "布控人单位")
+    private String controlUnit;
+
+    @ApiModelProperty(value = "布控人手机号")
+    private String controlPhone;
+
+    @ApiModelProperty(value = "布控人姓名")
+    private String controlName;
+    @ApiModelProperty(value = "预警是否确认1否2是")
+    private Integer status;
+
+}

+ 16 - 2
src/main/java/com/yx/face/service/UserControlEarlyWarningListLogService.java

@@ -1,6 +1,12 @@
 package com.yx.face.service;
 
-import com.yx.face.model.entity.UserControlEarlyWarningListLog;
+import com.github.pagehelper.PageInfo;
+import com.yx.face.boot.restful.RestDTO;
+import com.yx.face.model.query.UserEarlyWarningLogQu;
+import com.yx.face.model.vo.UserEarlyWarningLogVO;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
 
 /**
  * <p>
@@ -10,6 +16,14 @@ import com.yx.face.model.entity.UserControlEarlyWarningListLog;
  * @author wxg
  * @since 2022-01-24
  */
-public interface UserControlEarlyWarningListLogService{
+public interface UserControlEarlyWarningListLogService {
+
+    List<UserEarlyWarningLogVO> getListLog(Integer adminId);
+
+
+    Integer updateEarlyWarningConfirm(Long id);
+
+    PageInfo<UserEarlyWarningLogVO> getListLogPageInfo(RestDTO<UserEarlyWarningLogQu> dto);
 
+    void getListLogExcel(UserEarlyWarningLogQu dto, HttpServletResponse response);
 }

+ 92 - 1
src/main/java/com/yx/face/service/impl/UserControlEarlyWarningListLogServiceImpl.java

@@ -1,11 +1,29 @@
 package com.yx.face.service.impl;
 
 
+import cn.hutool.core.io.resource.ClassPathResource;
+import com.alibaba.excel.EasyExcel;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import com.yx.face.boot.restful.RestDTO;
+import com.yx.face.boot.restful.ServiceException;
+import com.yx.face.dao.AdminDao;
 import com.yx.face.dao.UserControlEarlyWarningListLogDao;
-import com.yx.face.model.entity.UserControlEarlyWarningListLog;
+import com.yx.face.model.entity.Admin;
+import com.yx.face.model.excel.UserEarlyWarningLogExcel;
+import com.yx.face.model.query.UserEarlyWarningLogQu;
+import com.yx.face.model.vo.UserEarlyWarningLogVO;
 import com.yx.face.service.UserControlEarlyWarningListLogService;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.util.HashMap;
+import java.util.List;
+
 /**
  * <p>
  * 预警日志 服务实现类
@@ -14,7 +32,80 @@ import org.springframework.stereotype.Service;
  * @author wxg
  * @since 2022-01-24
  */
+@Slf4j
 @Service
 public class UserControlEarlyWarningListLogServiceImpl implements UserControlEarlyWarningListLogService {
 
+    @Resource
+    private UserControlEarlyWarningListLogDao userControlEarlyWarningListLogDao;
+
+    @Resource
+    private AdminDao adminDao;
+
+    /**
+     * @param adminId
+     * @return
+     */
+    @Override
+    public List<UserEarlyWarningLogVO> getListLog(Integer adminId) {
+        Admin adminInfo = adminDao.selectByPrimaryKey(adminId);
+        if (adminInfo == null) {
+            throw new ServiceException("无此权限");
+        }
+        return this.userControlEarlyWarningListLogDao.getListLog(adminInfo);
+    }
+
+    /**
+     * @param id
+     * @return
+     */
+    @Override
+    public Integer updateEarlyWarningConfirm(Long id) {
+        //预警是否缺认1否2是
+        Integer status = 2;
+        // 预警id //
+        return userControlEarlyWarningListLogDao.updateEarlyWarningConfirm(id, status);
+    }
+
+    /**
+     * @param dto
+     * @return
+     */
+    @Override
+    public PageInfo<UserEarlyWarningLogVO> getListLogPageInfo(RestDTO<UserEarlyWarningLogQu> dto) {
+        HashMap<String, Object> map = new HashMap<>(2);
+        UserEarlyWarningLogQu data = dto.getData();
+        if (data.getStatus() == null) {
+            data.setStatus(0);
+        }
+        Admin adminVo = adminDao.selectByPrimaryKey(data.getAdminId());
+        map.put("adminVo", adminVo);
+        map.put("qu", data);
+        PageHelper.startPage(dto.getPageNum(), dto.getPageSize());
+        List<UserEarlyWarningLogVO> listVo = userControlEarlyWarningListLogDao.getListLogPageInfo(map);
+        return new PageInfo<>(listVo);
+    }
+
+    @Override
+    public void getListLogExcel(UserEarlyWarningLogQu dto, HttpServletResponse response) {
+        response.reset();//清缓存
+        HashMap<String, Object> map = new HashMap<>(2);
+        if (dto.getStatus() == null) {
+            dto.setStatus(0);
+        }
+        Admin adminVo = adminDao.selectByPrimaryKey(dto.getAdminId());
+        map.put("adminVo", adminVo);
+        map.put("qu", dto);
+        List<UserEarlyWarningLogExcel> listVo = userControlEarlyWarningListLogDao.getUserEarlyWarningLogExcel(map);
+        response.setContentType("application/vnd.ms-excel");
+        response.setCharacterEncoding("utf-8");
+        try {
+            String fileName = URLEncoder.encode("测试", "UTF-8").replaceAll("\\+", "%20");
+            response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
+            EasyExcel.write(response.getOutputStream(), UserEarlyWarningLogExcel.class).sheet("预警信息").doWrite(listVo);
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new ServiceException(500,"获取数据过程中异常,请重试");
+        }
+    }
 }

+ 175 - 0
src/main/resources/mapper/UserControlEarlyWarningListLogDao.xml

@@ -16,5 +16,180 @@
     <sql id="Base_Column_List">
         id, update_time, create_time, admin_id, status, face_log_id, control_early_warning_id
     </sql>
+    <update id="updateEarlyWarningConfirm">
+        UPDATE user_control_early_warning_list_log SET  status = #{status}  WHERE
+        id = #{id}
+    </update>
+
+    <select id="getListLog" resultType="com.yx.face.model.vo.UserEarlyWarningLogVO">
+        SELECT
+            a.id,
+            b.face_time AS faceTime,
+            c.`name` AS snName,
+            b.`name` AS `name`,
+            b.cardid AS idNumber,
+            b.photo,
+            d.control_unit AS controlUnit,
+            d.control_phone AS controlPhone,
+            d.control_name AS controlName
+        FROM
+            user_control_early_warning_list_log AS a
+                LEFT JOIN face_log AS b ON a.face_log_id = b.id
+                LEFT JOIN face_device AS c ON b.device_sn = c.sn
+                LEFT JOIN user_control_early_warning_list AS d ON a.control_early_warning_id = d.id
+                LEFT JOIN admin e on e.id =a.admin_id
+        <where>
+            and a.`status` = 1
+            <if test="type == 2">
+                and e.province_id = #{provinceId}
+                and e.type =5
+            </if>
+            <if test="type == 3">
+                and e.province_id = #{provinceId}
+                and e.type =5
+                and e.tag_id = #{tagId}
+            </if>
+            <if test="type == 4">
+                and e.city_id = #{cityId}
+                and e.type = 5
+                and e.tag_id = #{tagId}
+            </if>
+            <if test="type == 5">
+                and e.id =#{adminId}
+            </if>
+        </where>
+        ORDER BY a.id DESC
+
+    </select>
+    <select id="getListLogPageInfo" resultType="com.yx.face.model.vo.UserEarlyWarningLogVO">
+        SELECT
+        a.id,
+        b.face_time AS faceTime,
+        c.`name` AS snName,
+        b.`name` AS `name`,
+        b.cardid AS idNumber,
+        b.photo,
+        d.control_unit AS controlUnit,
+        d.control_phone AS controlPhone,
+        d.control_name AS controlName,
+        a.status
+        FROM
+        user_control_early_warning_list_log AS a
+        LEFT JOIN face_log AS b ON a.face_log_id = b.id
+        LEFT JOIN face_device AS c ON b.device_sn = c.sn
+        LEFT JOIN user_control_early_warning_list AS d ON a.control_early_warning_id = d.id
+        LEFT JOIN admin e on e.id =a.admin_id
+        <where>
+            <if test="adminVo.type == 2">
+                and e.province_id = #{adminVo.provinceId}
+                and e.type =5
+            </if>
+            <if test="adminVo.type == 3">
+                and e.province_id = #{adminVo.provinceId}
+                and e.type =5
+                and e.tag_id = #{adminVo.tagId}
+            </if>
+            <if test="adminVo.type == 4">
+                and e.city_id = #{adminVo.cityId}
+                and e.type = 5
+                and e.tag_id = #{adminVo.tagId}
+            </if>
+            <if test="adminVo.type == 5">
+                and e.id =#{adminVo.adminId}
+            </if>
+            <if test="qu.status != 0 ">
+                and a.status =#{qu.status}
+            </if>
+            <if test="qu.name != '' and qu.name != null ">
+                and d.early_warning_name =#{qu.name}
+            </if>
+            <if test="qu.idNumber != '' and qu.idNumber != null ">
+                and d.early_warning_id_number =#{qu.idNumber}
+            </if>
+
+            <if test="qu.controlUnit != null and qu.controlUnit != '' ">
+                and d.control_unit like concat('%',#{qu.controlUnit},'%')
+            </if>
+            <if test="qu.controlPhone != null and qu.controlPhone != '' ">
+                and d.control_phone =#{qu.controlPhone}
+            </if>
+            <if test="qu.controlName != null and qu.controlName != '' ">
+                and d.control_name =#{qu.controlName}
+            </if>
+            <if test="qu.startTime != null and qu.startTime != '' and qu.endTime != null and qu.endTime != '' ">
+                AND  <![CDATA[ b.face_time >= #{qu.startTime}]]>
+                AND  <![CDATA[ b.face_time < #{qu.endTime}]]>
+            </if>
+            <if test="qu.startTime == '' and qu.endTime != null and qu.endTime != '' ">
+                AND  <![CDATA[ b.face_time <= #{qu.endTime}]]>
+            </if>
+        </where>
+        ORDER BY a.id DESC
+    </select>
+    <select id="getUserEarlyWarningLogExcel" resultType="com.yx.face.model.excel.UserEarlyWarningLogExcel">
+        SELECT
+        a.id,
+        b.face_time AS faceTime,
+        c.`name` AS snName,
+        b.`name` AS `name`,
+        b.cardid AS idNumber,
+        b.photo,
+        d.control_unit AS controlUnit,
+        d.control_phone AS controlPhone,
+        d.control_name AS controlName,
+        a.status
+        FROM
+        user_control_early_warning_list_log AS a
+        LEFT JOIN face_log AS b ON a.face_log_id = b.id
+        LEFT JOIN face_device AS c ON b.device_sn = c.sn
+        LEFT JOIN user_control_early_warning_list AS d ON a.control_early_warning_id = d.id
+        LEFT JOIN admin e on e.id =a.admin_id
+        <where>
+            <if test="adminVo.type == 2">
+                and e.province_id = #{adminVo.provinceId}
+                and e.type =5
+            </if>
+            <if test="adminVo.type == 3">
+                and e.province_id = #{adminVo.provinceId}
+                and e.type =5
+                and e.tag_id = #{adminVo.tagId}
+            </if>
+            <if test="adminVo.type == 4">
+                and e.city_id = #{adminVo.cityId}
+                and e.type = 5
+                and e.tag_id = #{adminVo.tagId}
+            </if>
+            <if test="adminVo.type == 5">
+                and e.id =#{adminVo.adminId}
+            </if>
+            <if test="qu.status != 0 ">
+                and a.status =#{qu.status}
+            </if>
+            <if test="qu.name != '' and qu.name != null ">
+                and d.early_warning_name =#{qu.name}
+            </if>
+            <if test="qu.idNumber != '' and qu.idNumber != null ">
+                and d.early_warning_id_number =#{qu.idNumber}
+            </if>
+
+            <if test="qu.controlUnit != null and qu.controlUnit != '' ">
+                and d.control_unit like concat('%',#{qu.controlUnit},'%')
+            </if>
+            <if test="qu.controlPhone != null and qu.controlPhone != '' ">
+                and d.control_phone =#{qu.controlPhone}
+            </if>
+            <if test="qu.controlName != null and qu.controlName != '' ">
+                and d.control_name =#{qu.controlName}
+            </if>
+            <if test="qu.startTime != null and qu.startTime != '' and qu.endTime != null and qu.endTime != '' ">
+                AND  <![CDATA[ b.face_time >= #{qu.startTime}]]>
+                AND  <![CDATA[ b.face_time < #{qu.endTime}]]>
+            </if>
+            <if test="qu.startTime == '' and qu.endTime != null and qu.endTime != '' ">
+                AND  <![CDATA[ b.face_time <= #{qu.endTime}]]>
+            </if>
+        </where>
+        ORDER BY a.id DESC
+    </select>
 
 </mapper>