|
@@ -0,0 +1,274 @@
|
|
|
+package com.welampiot.controller;
|
|
|
+
|
|
|
+import com.welampiot.common.BaseResult;
|
|
|
+import com.welampiot.common.InterfaceResultEnum;
|
|
|
+import com.welampiot.dto.DefectManageDTO;
|
|
|
+import com.welampiot.dto.DefectManageDescDTO;
|
|
|
+import com.welampiot.dto.DefectManageFileDTO;
|
|
|
+import com.welampiot.service.*;
|
|
|
+import com.welampiot.utils.ToolUtils;
|
|
|
+import com.welampiot.vo.DefectManageInfoVO;
|
|
|
+import com.welampiot.vo.DefectManageVO;
|
|
|
+import com.welampiot.vo.RepairPersonnelDetailsVO;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.CrossOrigin;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * ClassName: DefectManageController
|
|
|
+ * Package: com.welampiot.controller
|
|
|
+ * Description:
|
|
|
+ *
|
|
|
+ * @Author: zhj_Start
|
|
|
+ * @Create: 2023/6/29 - 10:02
|
|
|
+ * @Version: v1.0
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@CrossOrigin
|
|
|
+@RequestMapping("/defectManage")
|
|
|
+public class DefectManageController {
|
|
|
+ @Autowired
|
|
|
+ private DefectManageService defectManageService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ToolUtils toolUtils;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private RepairPersonnelService repairPersonnelService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UserService userService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private DefectManageFileService defectManageFileService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private DefectManageDescService defectManageDescService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加编辑缺陷
|
|
|
+ * @param request 要添加编辑的缺陷属性
|
|
|
+ * @return 更新缺陷数据
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/saveDefectManage", method = RequestMethod.POST)
|
|
|
+ public BaseResult<?> saveDefectManage(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 devType = (Integer) toolUtils.getRequestContent(request,"devType",1);
|
|
|
+ Integer level = (Integer) toolUtils.getRequestContent(request,"level",1);
|
|
|
+ String openTime = (String) toolUtils.getRequestContent(request,"openTime",2);
|
|
|
+ String location = (String) toolUtils.getRequestContent(request,"location",2);
|
|
|
+ String devName = (String) toolUtils.getRequestContent(request,"devName",2);
|
|
|
+ String script = (String) toolUtils.getRequestContent(request,"script",2);
|
|
|
+ String longitude = (String) toolUtils.getRequestContent(request,"longitude",2);
|
|
|
+ String latitude = (String) toolUtils.getRequestContent(request,"latitude",2);
|
|
|
+ String username = (String) toolUtils.getRequestContent(request,"username",2);
|
|
|
+
|
|
|
+ if (sectionId == 0)
|
|
|
+ return toolUtils.response(InterfaceResultEnum.LACK_SECTION_ERROR,version);
|
|
|
+ if (String.valueOf(devType).length() == 0)
|
|
|
+ return toolUtils.response(InterfaceResultEnum.LACK_LOOP_DEV_TYPE_ERROR,version);
|
|
|
+ if (String.valueOf(level).length() == 0)
|
|
|
+ return toolUtils.response(InterfaceResultEnum.LACK_LEVEL_ERROR,version);
|
|
|
+ if (openTime.length() == 0)
|
|
|
+ return toolUtils.response(InterfaceResultEnum.LACK_OPEN_TIME_ERROR,version);
|
|
|
+ if (location.length() == 0)
|
|
|
+ return toolUtils.response(InterfaceResultEnum.LACK_LOCATION_ERROR,version);
|
|
|
+ if (devName.length() == 0)
|
|
|
+ return toolUtils.response(InterfaceResultEnum.LACK_DEV_NAME_ERROR,version);
|
|
|
+ if (script.length() == 0)
|
|
|
+ return toolUtils.response(InterfaceResultEnum.LACK_SCRIPT_ERROR,version);
|
|
|
+ if (longitude.length() == 0 || latitude.length() == 0)
|
|
|
+ return toolUtils.response(InterfaceResultEnum.LACK_LOCATION_ERROR,version);
|
|
|
+ DefectManageDTO defectManageDTO = new DefectManageDTO();
|
|
|
+ defectManageDTO.setSectionId(sectionId);
|
|
|
+ defectManageDTO.setDevType(devType);
|
|
|
+ defectManageDTO.setLevel(level);
|
|
|
+ defectManageDTO.setOpenTime(openTime);
|
|
|
+ defectManageDTO.setLocation(location);
|
|
|
+ defectManageDTO.setDevName(devName);
|
|
|
+ defectManageDTO.setScript(script);
|
|
|
+ defectManageDTO.setLongitude(longitude);
|
|
|
+ defectManageDTO.setLatitude(latitude);
|
|
|
+ if (id == 0) { // 添加
|
|
|
+ long l = System.currentTimeMillis();
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ defectManageDTO.setCreateTime(simpleDateFormat.format(l));
|
|
|
+ Integer userId = repairPersonnelService.getUserIdByUsername(username);
|
|
|
+ defectManageDTO.setUserid(userId);
|
|
|
+ defectManageService.addDefectManage(defectManageDTO);
|
|
|
+ Integer userid = defectManageService.getUseridById(id);
|
|
|
+ String name = userService.getNameByUserid(userid);
|
|
|
+ DefectManageDescDTO defectManageDescDTO = new DefectManageDescDTO();
|
|
|
+ defectManageDescDTO.setDefectManageId(id);
|
|
|
+ defectManageDescDTO.setCreateTime(simpleDateFormat.format(l));
|
|
|
+ defectManageDescDTO.setDescribe(name + " 创建缺陷");
|
|
|
+ defectManageDescService.addDefectManageDescData(defectManageDescDTO);
|
|
|
+ } else { // 编辑
|
|
|
+ defectManageDTO.setId(id);
|
|
|
+ defectManageService.updateDefectManage(defectManageDTO);
|
|
|
+ Integer fileId = (Integer) toolUtils.getRequestContent(request,"fileId",1);
|
|
|
+ String name = (String) toolUtils.getRequestContent(request,"name",2);
|
|
|
+ String url = (String) toolUtils.getRequestContent(request,"url",2);
|
|
|
+ if (fileId == 0 || name.length() == 0 || url.length() == 0)
|
|
|
+ return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
+ DefectManageFileDTO defectManageFileDTO = new DefectManageFileDTO();
|
|
|
+ defectManageFileDTO.setId(fileId);
|
|
|
+ defectManageFileDTO.setDefectManageId(id);
|
|
|
+ defectManageFileDTO.setName(name);
|
|
|
+ defectManageFileDTO.setUrl(url);
|
|
|
+ defectManageFileService.updateDefectManageFile(defectManageFileDTO);
|
|
|
+ }
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 派发缺陷
|
|
|
+ * @param request 缺陷id,维修人员id
|
|
|
+ * @return 派发缺陷
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/distributeWork", method = RequestMethod.POST)
|
|
|
+ public BaseResult<?> distributeWork(HttpServletRequest request) {
|
|
|
+ Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
|
|
|
+ Integer id = (Integer) toolUtils.getRequestContent(request,"id",1);
|
|
|
+ Integer workId = (Integer) toolUtils.getRequestContent(request,"workId",1);
|
|
|
+ if (id == 0 || workId == 0)
|
|
|
+ return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
+ // 更新工单状态status为1(处理中)
|
|
|
+ DefectManageDTO defectManageDTO = new DefectManageDTO();
|
|
|
+ defectManageDTO.setId(id);
|
|
|
+ defectManageDTO.setStatus(1);
|
|
|
+ defectManageService.updateDefectManageStatus(defectManageDTO);
|
|
|
+ Integer userid = defectManageService.getUseridById(id);
|
|
|
+ //记录工单的描述信息
|
|
|
+ long l = System.currentTimeMillis();
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ String format = simpleDateFormat.format(l);
|
|
|
+ String name = userService.getNameByUserid(userid);
|
|
|
+ RepairPersonnelDetailsVO detailsVO = repairPersonnelService.getDetailsByRepairPersonnelDTO(workId);
|
|
|
+ if (detailsVO == null) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL,version);
|
|
|
+ DefectManageDescDTO defectManageDescDTO = new DefectManageDescDTO();
|
|
|
+ defectManageDescDTO.setDefectManageId(id);
|
|
|
+ defectManageDescDTO.setDescribe(name + " 派发缺陷-> " + detailsVO.getName());
|
|
|
+ defectManageDescDTO.setCreateTime(format);
|
|
|
+ defectManageDescService.addDefectManageDescData(defectManageDescDTO);
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置缺陷状态
|
|
|
+ * @param request 缺陷id,缺陷状态
|
|
|
+ * @return 修改缺陷状态,记录缺陷信息
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/setDefectManageStatus", method = RequestMethod.POST)
|
|
|
+ public BaseResult<?> setDefectManageStatus(HttpServletRequest request) {
|
|
|
+ Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
|
|
|
+ Integer id = (Integer) toolUtils.getRequestContent(request,"id",1);
|
|
|
+ Integer status = (Integer) toolUtils.getRequestContent(request,"status",1);
|
|
|
+ if (id == 0 || status == 0)
|
|
|
+ return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
+ // 更新工单状态
|
|
|
+ DefectManageDTO defectManageDTO = new DefectManageDTO();
|
|
|
+ defectManageDTO.setId(id);
|
|
|
+ defectManageDTO.setStatus(status);
|
|
|
+ defectManageService.updateDefectManageStatus(defectManageDTO);
|
|
|
+ Integer userid = defectManageService.getUseridById(id);
|
|
|
+ //记录工单的描述信息
|
|
|
+ long l = System.currentTimeMillis();
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ String format = simpleDateFormat.format(l);
|
|
|
+ String name = userService.getNameByUserid(userid);
|
|
|
+ DefectManageDescDTO defectManageDescDTO = new DefectManageDescDTO();
|
|
|
+ defectManageDescDTO.setDefectManageId(id);
|
|
|
+ if (status == 4) {
|
|
|
+ defectManageDescDTO.setDescribe(name + " 归档");
|
|
|
+ } else if (status == 3) {
|
|
|
+ defectManageDescDTO.setDescribe(name + " 复核通过,已经结案");
|
|
|
+ } else if (status == 2) {
|
|
|
+ defectManageDescDTO.setDescribe(name + " 标记处理,进入复核状态");
|
|
|
+ } else if (status == 1) {
|
|
|
+ defectManageDescDTO.setDescribe(name + " 复核不通过,重新进入未处理");
|
|
|
+ }
|
|
|
+ defectManageDescDTO.setCreateTime(format);
|
|
|
+ defectManageDescService.addDefectManageDescData(defectManageDescDTO);
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 缺陷列表
|
|
|
+ * @param request 分页、关键字搜索、区域路段筛选
|
|
|
+ * @return 缺陷列表
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/defectManageList", method = RequestMethod.POST)
|
|
|
+ public BaseResult<?> defectManageList(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 status = (Integer) toolUtils.getRequestContent(request,"status",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"));
|
|
|
+
|
|
|
+ DefectManageVO vo = new DefectManageVO();
|
|
|
+ vo.setPage(count * (page - 1));
|
|
|
+ vo.setCount(count);
|
|
|
+ vo.setSectionId(sectionId);
|
|
|
+ vo.setAreaId(areaId);
|
|
|
+ vo.setCityId(cityId);
|
|
|
+ vo.setProvinceId(provinceId);
|
|
|
+ vo.setKeyword(keyword);
|
|
|
+ vo.setStatus(status);
|
|
|
+ vo.setSectionList(toolUtils.getSectionList(request));
|
|
|
+ List<DefectManageDTO> defectManageList = defectManageService.getDefectManageListByVO(vo);
|
|
|
+ List<DefectManageDTO> list = new ArrayList<>();
|
|
|
+ defectManageList.forEach(defectManageDTO -> {
|
|
|
+ if (defectManageDTO.getId() != null) {
|
|
|
+ List<DefectManageFileDTO> fileList = defectManageFileService.getDefectManageFileListById(defectManageDTO.getId());
|
|
|
+ defectManageDTO.setFileList(fileList);
|
|
|
+ }
|
|
|
+ list.add(defectManageDTO);
|
|
|
+ });
|
|
|
+ DefectManageVO defectManageVO = new DefectManageVO();
|
|
|
+ defectManageVO.setList(list);
|
|
|
+ defectManageVO.setTotal(defectManageService.getDefectManageTotal(vo));
|
|
|
+ defectManageVO.setTotal1(defectManageService.getDefectManageTotal(vo));
|
|
|
+ defectManageVO.setTotal2(defectManageService.getDefectManageTotal2(vo));
|
|
|
+ defectManageVO.setTotal3(defectManageService.getDefectManageTotal3(vo));
|
|
|
+ defectManageVO.setTotal4(defectManageService.getDefectManageTotal4(vo));
|
|
|
+ defectManageVO.setTotal5(defectManageService.getDefectManageTotal5(vo));
|
|
|
+ defectManageVO.setTotal6(defectManageService.getDefectManageTotal6(vo));
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,defectManageVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 缺陷详情
|
|
|
+ * @param request 缺陷id
|
|
|
+ * @return 缺陷详情
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/defectManageInfo", method = RequestMethod.POST)
|
|
|
+ public BaseResult<?> defectManageInfo(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);
|
|
|
+ DefectManageDTO defectManageDTO = defectManageService.getDefectManageInfoById(id);
|
|
|
+ if (defectManageDTO == null) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL,version);
|
|
|
+ DefectManageInfoVO defectManageInfoVO = new DefectManageInfoVO();
|
|
|
+ BeanUtils.copyProperties(defectManageDTO,defectManageInfoVO);
|
|
|
+ List<DefectManageFileDTO> fileList = defectManageFileService.getDefectManageFileListById(defectManageDTO.getId());
|
|
|
+ List<DefectManageDescDTO> descList = defectManageDescService.getDefectManageDescDetails(defectManageDTO.getId());
|
|
|
+ defectManageInfoVO.setFileList(fileList);
|
|
|
+ defectManageInfoVO.setHistory(descList);
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,defectManageInfoVO);
|
|
|
+ }
|
|
|
+}
|