Kaynağa Gözat

报警设置接口

zhj 2 yıl önce
ebeveyn
işleme
e8b19afcee

+ 164 - 7
src/main/java/com/welampiot/controller/AlarmController.java

@@ -5,9 +5,7 @@ import com.welampiot.common.InterfaceResultEnum;
 import com.welampiot.dto.*;
 import com.welampiot.service.*;
 import com.welampiot.utils.ToolUtils;
-import com.welampiot.vo.AlarmRepairInfoVO;
-import com.welampiot.vo.AllAlarmInfoLogVO;
-import com.welampiot.vo.RepairPersonnelDetailsVO;
+import com.welampiot.vo.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.CrossOrigin;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -17,10 +15,7 @@ import org.springframework.web.bind.annotation.RestController;
 import javax.servlet.http.HttpServletRequest;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
@@ -58,6 +53,14 @@ public class AlarmController {
     private RepairInfoService repairInfoService;
     @Autowired
     private RepairPersonnelService repairPersonnelService;
+    @Autowired
+    private UserService userService;
+    @Autowired
+    private GlobalLocationService globalLocationService;
+    @Autowired
+    private SectionService sectionService;
+    @Autowired
+    private SendStatusService sendStatusService;
 
     /**
      * 获取告警列表
@@ -339,4 +342,158 @@ public class AlarmController {
         allAlarmInfoLogService.deleteAlarmData(id);
         return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
     }
+
+    /**
+     * 区域路段侧边栏列表
+     * @param request 故障id
+     * @return 区域路段侧边栏列表
+     */
+    @RequestMapping(value = "/alarmNav", method = RequestMethod.POST)
+    public BaseResult<?> alarmNav(HttpServletRequest request) {
+        Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
+        String username = (String) toolUtils.getRequestContent(request,"username",2);
+        if (username.length() == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
+        UserDTO userDTO = userService.getPrivilegeList(username);
+        if (userDTO == null) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL,version);
+        GlobalLocationVO globalLocationVO = new GlobalLocationVO();
+        globalLocationVO.setList(new ArrayList<>());
+        if (userDTO.getZoneList() == null || userDTO.getZoneList().isEmpty()) {
+            return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,globalLocationVO);
+        }
+
+        List<String> zones = Arrays.asList(userDTO.getZoneList().split(","));
+        List<SectionDTO> list2;
+        List<GlobalLocationDTO> areaList = globalLocationService.getGlobalList(4, version);
+        List<SectionDTO> sectionList = sectionService.getListByIdList(zones);
+        List<GlobalLocationDTO> countryOfSectionList = globalLocationService.getCountryOfSectionList(1, version);
+        List<GlobalLocationDTO> provinceOfSectionList = globalLocationService.getCountryOfSectionList(2, version);
+        List<GlobalLocationDTO> cityOfSectionList = globalLocationService.getCountryOfSectionList(3, version);
+        areaList = Stream.of(areaList, countryOfSectionList, provinceOfSectionList, cityOfSectionList)
+                .flatMap(Collection::stream)
+                .collect(Collectors.toList());
+
+        List<GlobalLocationDTO> newAreaList = new ArrayList<>();
+        for (GlobalLocationDTO g : areaList) {
+            list2 = new ArrayList<>();
+            boolean isFlag = false;
+            for (SectionDTO s : sectionList) {
+                if (Objects.equals(g.getId(),s.getPid())) {
+                    list2.add(s);
+                    isFlag = true;
+                }
+            }
+            if (isFlag) {
+                GlobalLocationDTO dto = new GlobalLocationDTO();
+                dto.setId(g.getId());
+                dto.setPid(g.getPid());
+                dto.setName(g.getName());
+                dto.setSectionList(list2);
+                newAreaList.add(dto);
+            }
+        }
+
+        globalLocationVO.setList(newAreaList);
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,globalLocationVO);
+    }
+
+    /**
+     * 推送人员列表
+     * @param request 路段id,用户名
+     * @return 推送人员列表
+     */
+    @RequestMapping(value = "/sendUserList", method = RequestMethod.POST)
+    public BaseResult<?> sendUserList(HttpServletRequest request) {
+        Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
+        Integer sectionId = (Integer) toolUtils.getRequestContent(request,"sectionId",1);
+        int page = request.getParameter("page") == null ? 1 : Integer.parseInt(request.getParameter("page"));
+        int count = request.getParameter("count") == null ? 16 : Integer.parseInt(request.getParameter("count"));
+        SendStatusVO sendStatusVO = new SendStatusVO();
+        sendStatusVO.setPage(count * (page - 1));
+        sendStatusVO.setCount(count);
+        sendStatusVO.setSectionList(toolUtils.getSectionList(request));
+        sendStatusVO.setSectionId(sectionId);
+        List<SendStatusDTO> sendPersonList = sendStatusService.getSendPersonList(sendStatusVO);
+        SendStatusVO vo = new SendStatusVO();
+        vo.setList(sendPersonList);
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,vo);
+    }
+
+    /**
+     * 删除推送人员
+     * @param request 路段id,推送人员id
+     * @return 删除推送人员
+     */
+    @RequestMapping(value = "/delSendUser", method = RequestMethod.POST)
+    public BaseResult<?> delSendUser(HttpServletRequest request) {
+        Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
+        Integer sectionId = (Integer) toolUtils.getRequestContent(request,"sectionId",1);
+        Integer id = (Integer) toolUtils.getRequestContent(request,"id",1);
+        if (id == 0 || sectionId == 0)
+            return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
+        sendStatusService.deleteSendStatusData(sectionId,id);
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
+    }
+
+    /**
+     * 添加推送人员
+     * @param request 路段id,推送人员id
+     * @return 添加推送人员
+     */
+    @RequestMapping(value = "/addSendUser", method = RequestMethod.POST)
+    public BaseResult<?> addSendUser(HttpServletRequest request) {
+        Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
+        Integer sectionId = (Integer) toolUtils.getRequestContent(request,"sectionId",1);
+        Integer id = (Integer) toolUtils.getRequestContent(request,"id",1);
+        if (id == 0 || sectionId == 0)
+            return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
+        SendStatusDTO sendStatusDTO = new SendStatusDTO();
+        sendStatusDTO.setSectionId(sectionId);
+        sendStatusDTO.setRepairUserid(id);
+        sendStatusService.addSendStatusData(sendStatusDTO);
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
+    }
+
+    /**
+     * 修改推送人员状态
+     * @param request 路段id,推送人员id
+     * @return 修改推送人员状态
+     */
+    @RequestMapping(value = "/setSendUserStatus", method = RequestMethod.POST)
+    public BaseResult<?> setSendUserStatus(HttpServletRequest request) {
+        Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
+        Integer sectionId = (Integer) toolUtils.getRequestContent(request,"sectionId",1);
+        Integer id = (Integer) toolUtils.getRequestContent(request,"id",1);
+        Integer isPhone = (Integer) toolUtils.getRequestContent(request,"isPhone",1);
+        Integer isEmail = (Integer) toolUtils.getRequestContent(request,"isEmail",1);
+        if (id == 0 || sectionId == 0)
+            return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
+        SendStatusDTO sendStatusDTO = new SendStatusDTO();
+        sendStatusDTO.setSectionId(sectionId);
+        sendStatusDTO.setRepairUserid(id);
+        sendStatusDTO.setIsPhone(isPhone);
+        sendStatusDTO.setIsEmail(isEmail);
+        sendStatusService.updateSendStatusData(sendStatusDTO);
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
+    }
+
+    /**
+     * 开启关闭推送
+     * @param request 路段id,推送人员id,推送状态
+     * @return 开启关闭推送
+     */
+    @RequestMapping(value = "/openCloseStatus", method = RequestMethod.POST)
+    public BaseResult<?> openCloseStatus(HttpServletRequest request) {
+        Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
+        Integer sectionId = (Integer) toolUtils.getRequestContent(request,"sectionId",1);
+        Integer id = (Integer) toolUtils.getRequestContent(request,"id",1);
+        Integer status = (Integer) toolUtils.getRequestContent(request,"status",1);
+        if (id == 0 || sectionId == 0)
+            return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
+        SendStatusDTO sendStatusDTO = new SendStatusDTO();
+        sendStatusDTO.setSectionId(sectionId);
+        sendStatusDTO.setRepairUserid(id);
+        sendStatusDTO.setStatus(status);
+        sendStatusService.updateCloseStatus(sendStatusDTO);
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
+    }
 }

+ 1 - 1
src/main/java/com/welampiot/controller/UserController.java

@@ -1025,7 +1025,7 @@ public class UserController {
         List<String> zones = Arrays.asList(userDTO.getZoneList().split(","));
         List<GlobalLocationDTO> list1;
         List<SectionDTO> list2;
-        List<GlobalLocationDTO> oneCountryList = globalLocationService.getCountryOfSectionList(version);
+        List<GlobalLocationDTO> oneCountryList = globalLocationService.getCountryOfSectionList(1,version);
         List<GlobalLocationDTO> provinceList = globalLocationService.getGlobalList(2, version);
         List<GlobalLocationDTO> cityList = globalLocationService.getGlobalList(3, version);
         List<GlobalLocationDTO> areaList = globalLocationService.getGlobalList(4, version);

+ 1 - 1
src/main/java/com/welampiot/dao/GlobalLocationDao.java

@@ -39,5 +39,5 @@ public interface GlobalLocationDao {
 
     List<GlobalLocationDTO> getOnlyOneLevelList(@Param("level") Integer level,@Param("version") Integer version);
 
-    List<GlobalLocationDTO> getCountryOfSectionList(@Param("version") Integer version);
+    List<GlobalLocationDTO> getCountryOfSectionList(@Param("level") Integer level,@Param("version") Integer version);
 }

+ 28 - 0
src/main/java/com/welampiot/dao/SendStatusDao.java

@@ -0,0 +1,28 @@
+package com.welampiot.dao;
+
+import com.welampiot.dto.SendStatusDTO;
+import com.welampiot.vo.SendStatusVO;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * ClassName: SendStatusDao
+ * Package: com.welampiot.dao
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/7/14 - 15:11
+ * @Version: v1.0
+ */
+public interface SendStatusDao {
+    List<SendStatusDTO> getSendPersonList(SendStatusVO vo);
+
+    void deleteSendStatusData(@Param("sectionId") Integer sectionId, @Param("id") Integer id);
+
+    void addSendStatusData(SendStatusDTO dto);
+
+    void updateSendStatusData(SendStatusDTO dto);
+
+    void updateCloseStatus(SendStatusDTO dto);
+}

+ 43 - 0
src/main/java/com/welampiot/dto/SendStatusDTO.java

@@ -0,0 +1,43 @@
+package com.welampiot.dto;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * ClassName: SendStatusDTO
+ * Package: com.welampiot.dto
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/7/14 - 14:48
+ * @Version: v1.0
+ */
+@Data
+public class SendStatusDTO implements Serializable {
+    private Integer id;
+
+    private Integer sectionId;
+
+    private Integer repairUserid; // 推送人员id
+
+    private Integer isPhone; // 是否开启短信推送
+
+    private Integer isEmail; // 是否开启邮件推送
+
+    private Integer status; // 是否开启推送(0 未开启,1 开启)
+
+    private Integer type; // 语言版本信息(0 中文,1 英文,2 俄语)
+
+    private String name;
+
+    private String company;
+
+    private String department;
+
+    private String number;
+
+    private String phone;
+
+    private String email;
+}

+ 1 - 1
src/main/java/com/welampiot/service/GlobalLocationService.java

@@ -32,5 +32,5 @@ public interface GlobalLocationService {
     List<GlobalLocationDTO> getAreaListByPid(Integer pid, Integer version);
     List<GlobalLocationDTO> getCityListByPid(Integer pid, Integer version);
     List<GlobalLocationDTO> getOnlyOneLevelList(Integer level, Integer version);
-    List<GlobalLocationDTO> getCountryOfSectionList(Integer version);
+    List<GlobalLocationDTO> getCountryOfSectionList(Integer level, Integer version);
 }

+ 27 - 0
src/main/java/com/welampiot/service/SendStatusService.java

@@ -0,0 +1,27 @@
+package com.welampiot.service;
+
+import com.welampiot.dto.SendStatusDTO;
+import com.welampiot.vo.SendStatusVO;
+
+import java.util.List;
+
+/**
+ * ClassName: SendStatusService
+ * Package: com.welampiot.service
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/7/14 - 15:12
+ * @Version: v1.0
+ */
+public interface SendStatusService {
+    List<SendStatusDTO> getSendPersonList(SendStatusVO vo);
+
+    void deleteSendStatusData(Integer sectionId, Integer id);
+
+    void addSendStatusData(SendStatusDTO dto);
+
+    void updateSendStatusData(SendStatusDTO dto);
+
+    void updateCloseStatus(SendStatusDTO dto);
+}

+ 2 - 2
src/main/java/com/welampiot/service/impl/GlobalLocationServiceImpl.java

@@ -197,7 +197,7 @@ public class GlobalLocationServiceImpl implements GlobalLocationService {
     }
 
     @Override
-    public List<GlobalLocationDTO> getCountryOfSectionList(Integer version) {
-        return globalLocationDao.getCountryOfSectionList(version);
+    public List<GlobalLocationDTO> getCountryOfSectionList(Integer level, Integer version) {
+        return globalLocationDao.getCountryOfSectionList(level,version);
     }
 }

+ 50 - 0
src/main/java/com/welampiot/service/impl/SendStatusServiceImpl.java

@@ -0,0 +1,50 @@
+package com.welampiot.service.impl;
+
+import com.welampiot.dao.SendStatusDao;
+import com.welampiot.dto.SendStatusDTO;
+import com.welampiot.service.SendStatusService;
+import com.welampiot.vo.SendStatusVO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * ClassName: SendStatusServiceImpl
+ * Package: com.welampiot.service.impl
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/7/14 - 15:12
+ * @Version: v1.0
+ */
+@Service
+public class SendStatusServiceImpl implements SendStatusService {
+    @Autowired
+    private SendStatusDao sendStatusDao;
+
+    @Override
+    public List<SendStatusDTO> getSendPersonList(SendStatusVO vo) {
+        return sendStatusDao.getSendPersonList(vo);
+    }
+
+    @Override
+    public void deleteSendStatusData(Integer sectionId, Integer id) {
+        sendStatusDao.deleteSendStatusData(sectionId,id);
+    }
+
+    @Override
+    public void addSendStatusData(SendStatusDTO dto) {
+        sendStatusDao.addSendStatusData(dto);
+    }
+
+    @Override
+    public void updateSendStatusData(SendStatusDTO dto) {
+        sendStatusDao.updateSendStatusData(dto);
+    }
+
+    @Override
+    public void updateCloseStatus(SendStatusDTO dto) {
+        sendStatusDao.updateCloseStatus(dto);
+    }
+}

+ 29 - 0
src/main/java/com/welampiot/vo/SendStatusVO.java

@@ -0,0 +1,29 @@
+package com.welampiot.vo;
+
+import com.welampiot.dto.SendStatusDTO;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * ClassName: SendStatusVO
+ * Package: com.welampiot.vo
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/7/14 - 15:06
+ * @Version: v1.0
+ */
+@Data
+public class SendStatusVO implements Serializable {
+    private Integer page;
+
+    private Integer count;
+
+    private Integer sectionId;
+
+    private List sectionList;
+
+    private List<SendStatusDTO> list;
+}

+ 1 - 1
src/main/resources/mapper/GlobalLocationMapper.xml

@@ -238,7 +238,7 @@
         FROM section s
         LEFT JOIN global_location g
         ON g.id = s.pid
-        WHERE g.level = 1
+        WHERE g.level = #{level}
     </select>
     
 </mapper>

+ 60 - 0
src/main/resources/mapper/SendStatusMapper.xml

@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.welampiot.dao.SendStatusDao">
+
+    <select id="getSendPersonList" resultType="SendStatusDTO">
+        select
+            s.isEmail,
+            s.isPhone,
+            s.status,
+            s.repairUserId as id,
+            r.number,
+            r.company,
+            r.section as department,
+            r.phone,
+            r.email,
+            r.name
+        from send_status s
+        left join repair_personnel r on s.repairUserId = r.id
+        where 1=1
+        <if test="sectionList != null and !sectionList.isEmpty()">
+            and s.sectionId in
+            <foreach collection="sectionList" item="item" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="sectionId != null and sectionId != 0">
+            and s.sectionId = #{sectionId}
+        </if>
+        <if test="page >= 0 and count > 0">
+            limit #{page},#{count}
+        </if>
+    </select>
+
+    <delete id="deleteSendStatusData">
+        delete
+        from send_status
+        where sectionId = #{sectionId} and repairUserId = #{id};
+    </delete>
+
+    <insert id="addSendStatusData" keyProperty="id" useGeneratedKeys="true" parameterType="SendStatusDTO">
+        insert into send_status(sectionId,repairUserId)
+        values (#{sectionId},#{repairUserid})
+    </insert>
+
+    <update id="updateSendStatusData" parameterType="SendStatusDTO">
+        update send_status s
+        set
+            s.isPhone = #{isPhone},
+            s.isEmail = #{isEmail}
+        where s.repairUserId = #{repairUserid} and s.sectionId = #{sectionId}
+    </update>
+
+    <update id="updateCloseStatus" parameterType="SendStatusDTO">
+        update send_status s
+        set
+            s.status = #{status}
+        where s.repairUserId = #{repairUserid} and s.sectionId = #{sectionId}
+    </update>
+
+</mapper>

+ 1 - 1
src/main/resources/mapper/UserMapper.xml

@@ -340,7 +340,7 @@
     </update>
 
     <select id="getPrivilegeList" resultType="UserDTO">
-        select u.privilege_list as privilegeList
+        select u.privilege_list as privilegeList,u.zone_list as zoneList
         from user u
         where u.username = #{username}
     </select>