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

项目维修管理:添加编辑维修项目、项目维修列表、维修标记完成

zhj 2 роки тому
батько
коміт
87b501a4eb

+ 3 - 1
src/main/java/com/welampiot/common/InterfaceResultEnum.java

@@ -103,7 +103,7 @@ public enum InterfaceResultEnum {
     LACK_LOCATION("0296","位置信息不能为空","The location information cannot be empty","Информация о местоположении не может быть пустой"),
     LACK_OPEN_TIME_ERROR("0297","发生时间不能为空","The occurrence time cannot be empty","Время не может быть пустым"),
     LACK_LEVEL_ERROR("0298","请选择严重程度","Please select Severity","Пожалуйста, выберите степень серьезности"),
-    LACK_SCRIPT_ERROR("0299","请填写工单描述","Please fill in the description of the work order","Пожалуйста, заполните список работников"),
+    LACK_SCRIPT_ERROR("0299","请填写描述","Please fill in the description of the work order","Пожалуйста, заполните список работников"),
     LACK_PATROL_TIME_ERROR("0300","巡视计划时间不能为空","Patrol plan time can't be empty","Время обхода не должно быть пустым"),
     LACK_PATROL_SPOT_NAME_ERROR("0301","巡视点名称不能为空","The patrol point name cannot be empty","Название места обхода не может быть пустым"),
     TIME_EXCEPTION_ERROR("0302","开始时间不能大于结束时间","The start time cannot be later than the end time","Время начала не может быть больше времени конца"),
@@ -114,6 +114,8 @@ public enum InterfaceResultEnum {
     LACK_PATROL_START_TIME_ERROR("0307","巡视计划开始时间不能为空","The start time of the inspection schedule cannot be empty","Время начала обхода не должно быть пустым"),
     LACK_PATROL_END_TIME_ERROR("0308","巡视计划结束时间不能为空","The tour schedule end time cannot be empty","Время окончания обхода не должно быть пустым"),
     PATROL_TASK_SPOT_DISTANCE_ERROR("0309","距离太远,打卡失败","The distance is so far that the punch card fails","Слишком далеко, чтобы пробить пропуск"),
+    LACK_WORK_ID_ERROR("0310","维修人员id不能为空","The maintenance personnel id cannot be empty","Техподдержка не должна быть пуста"),
+    LACK_COM_TIME_ERROR("0311","目标完成时间不能为空","The target completion time cannot be empty","Время достижения цели не должно быть пустым"),
     ;
     private String code;
     private String msgCn;

+ 100 - 4
src/main/java/com/welampiot/controller/WorkManageController.java

@@ -2,10 +2,7 @@ package com.welampiot.controller;
 
 import com.welampiot.common.BaseResult;
 import com.welampiot.common.InterfaceResultEnum;
-import com.welampiot.dto.AllAlarmInfoLogDTO;
-import com.welampiot.dto.WorkManageDTO;
-import com.welampiot.dto.WorkManageDescDTO;
-import com.welampiot.dto.WorkManageFileDTO;
+import com.welampiot.dto.*;
 import com.welampiot.service.*;
 import com.welampiot.utils.ToolUtils;
 import com.welampiot.vo.*;
@@ -56,6 +53,9 @@ public class WorkManageController {
     @Autowired
     private UserService userService;
 
+    @Autowired
+    private RepairProjectService repairProjectService;
+
     /**
      * 故障列表
      * @param request 分页、区域路段筛选、故障类型、设备类型
@@ -397,4 +397,100 @@ public class WorkManageController {
         workManageDescService.addWorkManageDescData(workManageDescDTO);
         return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
     }
+
+    /**
+     * 添加编辑维修项目
+     * @param request 维修项目属性
+     * @return 更新维修项目数据
+     */
+    @RequestMapping(value = "/saveRepairProject", method = RequestMethod.POST)
+    public BaseResult<?> saveRepairProject(HttpServletRequest request) {
+        Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
+        Integer id = (Integer) toolUtils.getRequestContent(request,"id",1);
+        Integer sectionId = (Integer) toolUtils.getRequestContent(request,"sectionId",1);
+        Integer workId = (Integer) toolUtils.getRequestContent(request,"workId",1);
+        Integer type = (Integer) toolUtils.getRequestContent(request,"type",1);
+        String comTime = (String) toolUtils.getRequestContent(request,"comTime",2);
+        String desc = (String) toolUtils.getRequestContent(request,"desc",2);
+        String username = (String) toolUtils.getRequestContent(request,"username",2);
+
+        if (sectionId == 0) return toolUtils.response(InterfaceResultEnum.LACK_SECTION_ERROR,version);
+        if (workId == 0) return toolUtils.response(InterfaceResultEnum.LACK_WORK_ID_ERROR,version);
+        if (desc.length() == 0) return toolUtils.response(InterfaceResultEnum.LACK_SCRIPT_ERROR,version);
+        if (comTime.length() == 0) return toolUtils.response(InterfaceResultEnum.LACK_COM_TIME_ERROR,version);
+        RepairProjectDTO repairProjectDTO = new RepairProjectDTO();
+        repairProjectDTO.setSectionId(sectionId);
+        repairProjectDTO.setWorkId(workId);
+        repairProjectDTO.setType(type);
+        repairProjectDTO.setComTime(comTime);
+        repairProjectDTO.setDesc(desc);
+        if (id == 0) { // 添加
+            long l = System.currentTimeMillis();
+            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            String format = simpleDateFormat.format(l);
+            Integer userid = repairPersonnelService.getUserIdByUsername(username);
+            repairProjectDTO.setUserid(userid);
+            repairProjectDTO.setCreateTime(format);
+            repairProjectService.addRepairProjectData(repairProjectDTO);
+        } else { // 编辑
+            repairProjectDTO.setId(id);
+            repairProjectService.updateRepairProjectData(repairProjectDTO);
+        }
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
+    }
+
+    /**
+     * 项目维修列表
+     * @param request 分页、关键字搜索、区域路段筛选
+     * @return 项目维修列表
+     */
+    @RequestMapping(value = "/repairProjectList", method = RequestMethod.POST)
+    public BaseResult<?> repairProjectList(HttpServletRequest request) {
+        Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
+        Integer areaId = (Integer) toolUtils.getRequestContent(request,"areaId",1);
+        Integer sectionId = (Integer) toolUtils.getRequestContent(request,"sectionId",1);
+        Integer provinceId = (Integer) toolUtils.getRequestContent(request,"provinceId",1);
+        Integer cityId = (Integer) toolUtils.getRequestContent(request,"cityId",1);
+        Integer type = (Integer) toolUtils.getRequestContent(request,"type",1);
+        String keyword = (String) toolUtils.getRequestContent(request,"keyword",2);
+        int page = request.getParameter("page") == null ? 1 : Integer.parseInt(request.getParameter("page"));
+        int count = request.getParameter("count") == null ? 16 : Integer.parseInt(request.getParameter("count"));
+
+        RepairProjectVO vo = new RepairProjectVO();
+        vo.setPage(count * (page - 1));
+        vo.setCount(count);
+        vo.setSectionId(sectionId);
+        vo.setAreaId(areaId);
+        vo.setCityId(cityId);
+        vo.setProvinceId(provinceId);
+        vo.setKeyword(keyword);
+        vo.setType(type);
+        vo.setSectionList(toolUtils.getSectionList(request));
+        List<RepairProjectDTO> repairProjectList = repairProjectService.getRepairProjectList(vo);
+        RepairProjectVO repairProjectVO = new RepairProjectVO();
+        repairProjectVO.setList(repairProjectList);
+        repairProjectVO.setTotal(repairProjectService.getRepairProjectTotal(vo));
+        repairProjectVO.setTotal1(repairProjectService.getRepairProjectTotal(vo));
+        repairProjectVO.setTotal2(repairProjectService.getRepairProjectTotal2(vo));
+        repairProjectVO.setTotal3(repairProjectService.getRepairProjectTotal3(vo));
+        repairProjectVO.setTotal4(repairProjectService.getRepairProjectTotal4(vo));
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,repairProjectVO);
+    }
+
+    /**
+     * 维修标记完成
+     * @param request 维修项目id
+     * @return 修改维修项目状态为完成
+     */
+    @RequestMapping(value = "/setRepairProjectStatus", method = RequestMethod.POST)
+    public BaseResult<?> setRepairProjectStatus(HttpServletRequest request) {
+        Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
+        Integer id = (Integer) toolUtils.getRequestContent(request,"id",1);
+        if (id == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
+        RepairProjectDTO repairProjectDTO = new RepairProjectDTO();
+        repairProjectDTO.setId(id);
+        repairProjectDTO.setStatus(2);
+        repairProjectService.updateRepairProjectStatus(repairProjectDTO);
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
+    }
 }

+ 33 - 0
src/main/java/com/welampiot/dao/RepairProjectDao.java

@@ -0,0 +1,33 @@
+package com.welampiot.dao;
+
+import com.welampiot.dto.RepairProjectDTO;
+import com.welampiot.vo.RepairProjectVO;
+
+import java.util.List;
+
+/**
+ * ClassName: RepairProjectDao
+ * Package: com.welampiot.dao
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/7/3 - 16:42
+ * @Version: v1.0
+ */
+public interface RepairProjectDao {
+    void addRepairProjectData(RepairProjectDTO dto);
+
+    void updateRepairProjectData(RepairProjectDTO dto);
+
+    List<RepairProjectDTO> getRepairProjectList(RepairProjectVO vo);
+
+    Integer getRepairProjectTotal(RepairProjectVO vo);
+
+    Integer getRepairProjectTotal2(RepairProjectVO vo);
+
+    Integer getRepairProjectTotal3(RepairProjectVO vo);
+
+    Integer getRepairProjectTotal4(RepairProjectVO vo);
+
+    void updateRepairProjectStatus(RepairProjectDTO dto);
+}

+ 41 - 0
src/main/java/com/welampiot/dto/RepairProjectDTO.java

@@ -0,0 +1,41 @@
+package com.welampiot.dto;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * ClassName: RepairProjectDTO
+ * Package: com.welampiot.dto
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/7/3 - 16:29
+ * @Version: v1.0
+ */
+@Data
+public class RepairProjectDTO implements Serializable {
+    private Integer id;
+
+    private Integer userid;
+
+    private Integer workId;
+
+    private Integer type; // 维修类型(0 中小修,1 大修,2 改造)
+
+    private String comTime; // 完成目标时间
+
+    private String desc; // 描述
+
+    private Integer status; // 状态(0 正常,1 预期,2 完成)
+
+    private String createTime; // 创建时间
+
+    private String number; // 维修编号
+
+    private String workName; // 巡视人名称
+
+    private Integer sectionId; // 路段id
+
+    private static final long serialVersionUID = 1L;
+}

+ 33 - 0
src/main/java/com/welampiot/service/RepairProjectService.java

@@ -0,0 +1,33 @@
+package com.welampiot.service;
+
+import com.welampiot.dto.RepairProjectDTO;
+import com.welampiot.vo.RepairProjectVO;
+
+import java.util.List;
+
+/**
+ * ClassName: RepairProjectService
+ * Package: com.welampiot.service
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/7/3 - 16:43
+ * @Version: v1.0
+ */
+public interface RepairProjectService {
+    void addRepairProjectData(RepairProjectDTO dto);
+
+    void updateRepairProjectData(RepairProjectDTO dto);
+
+    List<RepairProjectDTO> getRepairProjectList(RepairProjectVO vo);
+
+    Integer getRepairProjectTotal(RepairProjectVO vo);
+
+    Integer getRepairProjectTotal2(RepairProjectVO vo);
+
+    Integer getRepairProjectTotal3(RepairProjectVO vo);
+
+    Integer getRepairProjectTotal4(RepairProjectVO vo);
+
+    void updateRepairProjectStatus(RepairProjectDTO dto);
+}

+ 65 - 0
src/main/java/com/welampiot/service/impl/RepairProjectServiceImpl.java

@@ -0,0 +1,65 @@
+package com.welampiot.service.impl;
+
+import com.welampiot.dao.RepairProjectDao;
+import com.welampiot.dto.RepairProjectDTO;
+import com.welampiot.service.RepairProjectService;
+import com.welampiot.vo.RepairProjectVO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * ClassName: RepairProjectServiceImpl
+ * Package: com.welampiot.service.impl
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/7/3 - 16:43
+ * @Version: v1.0
+ */
+@Service
+public class RepairProjectServiceImpl implements RepairProjectService {
+    @Autowired
+    private RepairProjectDao repairProjectDao;
+
+    @Override
+    public void addRepairProjectData(RepairProjectDTO dto) {
+        repairProjectDao.addRepairProjectData(dto);
+    }
+
+    @Override
+    public void updateRepairProjectData(RepairProjectDTO dto) {
+        repairProjectDao.updateRepairProjectData(dto);
+    }
+
+    @Override
+    public List<RepairProjectDTO> getRepairProjectList(RepairProjectVO vo) {
+        return repairProjectDao.getRepairProjectList(vo);
+    }
+
+    @Override
+    public Integer getRepairProjectTotal(RepairProjectVO vo) {
+        return repairProjectDao.getRepairProjectTotal(vo);
+    }
+
+    @Override
+    public Integer getRepairProjectTotal2(RepairProjectVO vo) {
+        return repairProjectDao.getRepairProjectTotal2(vo);
+    }
+
+    @Override
+    public Integer getRepairProjectTotal3(RepairProjectVO vo) {
+        return repairProjectDao.getRepairProjectTotal3(vo);
+    }
+
+    @Override
+    public Integer getRepairProjectTotal4(RepairProjectVO vo) {
+        return repairProjectDao.getRepairProjectTotal4(vo);
+    }
+
+    @Override
+    public void updateRepairProjectStatus(RepairProjectDTO dto) {
+        repairProjectDao.updateRepairProjectStatus(dto);
+    }
+}

+ 45 - 0
src/main/java/com/welampiot/vo/RepairProjectVO.java

@@ -0,0 +1,45 @@
+package com.welampiot.vo;
+
+import com.welampiot.dto.RepairProjectDTO;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * ClassName: RepairProjectVO
+ * Package: com.welampiot.vo
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/7/3 - 17:58
+ * @Version: v1.0
+ */
+@Data
+public class RepairProjectVO implements Serializable {
+    private Integer page;
+
+    private Integer count;
+
+    private Integer areaId;
+
+    private Integer sectionId;
+
+    private Integer cityId;
+
+    private Integer provinceId;
+
+    private String keyword;
+
+    private Integer type;
+
+    private Integer total;
+    private Integer total1;
+    private Integer total2;
+    private Integer total3;
+    private Integer total4;
+
+    private List<RepairProjectDTO> list;
+
+    private List<Integer> sectionList;
+}

+ 120 - 0
src/main/resources/mapper/RepairProjectMapper.xml

@@ -0,0 +1,120 @@
+<?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.RepairProjectDao">
+
+    <insert id="addRepairProjectData" parameterType="RepairProjectDTO" useGeneratedKeys="true" keyProperty="id">
+        insert into repair_project(sectionId,work_id,com_time,type,`desc`,user_id,create_time)
+        values (#{sectionId},#{workId},#{comTime},#{type},#{desc},#{userid},#{createTime})
+    </insert>
+
+    <update id="updateRepairProjectData" parameterType="RepairProjectDTO">
+        update repair_project r
+        set
+            r.sectionId = #{sectionId},
+            r.work_id = #{workId},
+            r.com_time = #{comTime},
+            r.type = #{type},
+            r.`desc` = #{desc}
+        where r.id = #{id}
+    </update>
+
+    <select id="getRepairProjectList" resultType="RepairProjectDTO">
+        select r.id,r.number,r.type,r.com_time comTime,r.work_name workName,r.`desc`,r.status
+        from repair_project r
+        left join section s on r.sectionId = s.id
+        left join global_location gl on s.pid = gl.id
+        left join global_location gl1 on gl.pid = gl1.id
+        left join global_location gl2 on gl1.pid = gl2.id
+        where 1=1
+        <if test="sectionList != null and !sectionList.isEmpty()">
+            and r.sectionId in
+            <foreach collection="sectionList" item="item" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        <choose>
+            <when test="type == 0">
+                and r.type = 0
+            </when>
+            <when test="type == 1">
+                and r.type = 1
+            </when>
+            <when test="type == 2">
+                and r.type = 2
+            </when>
+        </choose>
+        <if test="keyword != null and keyword != ''">
+            and r.number like '%${keyword}%'
+        </if>
+        <if test="areaId != null and areaId != 0">
+            and gl.id = #{areaId}
+        </if>
+        <if test="sectionId != null and sectionId != 0">
+            and r.sectionId = #{sectionId}
+        </if>
+        <if test="cityId != null and cityId != 0">
+            and gl1.id = #{cityId}
+        </if>
+        <if test="provinceId != null and provinceId != 0">
+            and gl2.id = #{provinceId}
+        </if>
+        <if test="page >= 0 and count > 0">
+            limit #{page},#{count}
+        </if>
+    </select>
+
+    <select id="getRepairProjectTotal" resultType="Integer">
+        select count(r.id)
+        from repair_project r
+        <if test="sectionList != null and !sectionList.isEmpty()">
+            where r.sectionId in
+            <foreach collection="sectionList" item="item" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+    </select>
+
+    <select id="getRepairProjectTotal2" resultType="Integer">
+        select count(r.id)
+        from repair_project r
+        where r.type = 0
+        <if test="sectionList != null and !sectionList.isEmpty()">
+            and r.sectionId in
+            <foreach collection="sectionList" item="item" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+    </select>
+
+    <select id="getRepairProjectTotal3" resultType="Integer">
+        select count(r.id)
+        from repair_project r
+        where r.type = 1
+        <if test="sectionList != null and !sectionList.isEmpty()">
+            and r.sectionId in
+            <foreach collection="sectionList" item="item" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+    </select>
+
+    <select id="getRepairProjectTotal4" resultType="Integer">
+        select count(r.id)
+        from repair_project r
+        where r.type = 2
+        <if test="sectionList != null and !sectionList.isEmpty()">
+            and r.sectionId in
+            <foreach collection="sectionList" item="item" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+    </select>
+
+    <update id="updateRepairProjectStatus" parameterType="RepairProjectDTO">
+        update repair_project r
+        set
+            r.status = #{status}
+        where r.id = #{id}
+    </update>
+
+</mapper>