|
@@ -14,7 +14,9 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.time.YearMonth;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.stream.Stream;
|
|
@@ -56,6 +58,12 @@ public class WorkManageController {
|
|
|
@Autowired
|
|
|
private RepairProjectService repairProjectService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private DefectManageService defectManageService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PatrolManageService patrolManageService;
|
|
|
+
|
|
|
/**
|
|
|
* 故障列表
|
|
|
* @param request 分页、区域路段筛选、故障类型、设备类型
|
|
@@ -493,4 +501,220 @@ public class WorkManageController {
|
|
|
repairProjectService.updateRepairProjectStatus(repairProjectDTO);
|
|
|
return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 概览数据
|
|
|
+ * @param request 时间筛选
|
|
|
+ * @return 概览数据
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/operationData", method = RequestMethod.POST)
|
|
|
+ public BaseResult<?> operationData(HttpServletRequest request) throws ParseException {
|
|
|
+ Integer version = (Integer) toolUtils.getRequestContent(request, "version", 1);
|
|
|
+ Integer dateType = (Integer) toolUtils.getRequestContent(request, "dateType", 1);
|
|
|
+
|
|
|
+ long l = System.currentTimeMillis();
|
|
|
+ Date date1 = new Date(l);
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTime(date1);
|
|
|
+ int year = calendar.get(Calendar.YEAR); // 获取年份
|
|
|
+ int month = calendar.get(Calendar.MONTH) + 1; // 获取月份
|
|
|
+ long startTime,endTime;
|
|
|
+ String startDate = "";
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ String endDate = simpleDateFormat.format(l);
|
|
|
+ if (dateType == 0) { // 当月
|
|
|
+ if (month < 10) {
|
|
|
+ startDate = year + "-0" + month + "-01";
|
|
|
+ } else {
|
|
|
+ startDate = year + "-" + month + "-01";
|
|
|
+ }
|
|
|
+ } else if (dateType == 1) { // 当年
|
|
|
+ month = 1;
|
|
|
+ startDate = year + "-0" + month + "-01";
|
|
|
+ endDate = simpleDateFormat.format(l);
|
|
|
+ } else if (dateType == 2) { // 全部
|
|
|
+ endDate = simpleDateFormat.format(l);
|
|
|
+ } else if (dateType == 3) { // 具体月份
|
|
|
+ String date = (String) toolUtils.getRequestContent(request, "date", 2);
|
|
|
+ if (date.length() == 0) return toolUtils.response(InterfaceResultEnum.LACK_DATE_ERROR, version);
|
|
|
+ List<String> list = Arrays.asList(date.split("-"));
|
|
|
+ int yearNum = Integer.parseInt(list.get(0));
|
|
|
+ int monthNum = Integer.parseInt(list.get(1));
|
|
|
+ int daysInMonth = YearMonth.of(yearNum, monthNum).lengthOfMonth();
|
|
|
+ if (yearNum == year && monthNum == month) {
|
|
|
+ if (month < 10) {
|
|
|
+ startDate = year + "-" + "0" + month + "-01";
|
|
|
+ } else {
|
|
|
+ startDate = year + "-" + month + "-01";
|
|
|
+ }
|
|
|
+ } else if ((yearNum == year && monthNum > month) || (yearNum > year)) {
|
|
|
+ return toolUtils.response(InterfaceResultEnum.DATE_CHOOSE_ERROR, version);
|
|
|
+ } else {
|
|
|
+ startTime = simpleDateFormat.parse(date + "-01").getTime();
|
|
|
+ endTime = simpleDateFormat.parse(date + "-" + daysInMonth).getTime();
|
|
|
+ startDate = simpleDateFormat.format(startTime);
|
|
|
+ endDate = simpleDateFormat.format(endTime);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ OperationVO operationVO = new OperationVO();
|
|
|
+ operationVO.setStartDate(startDate);
|
|
|
+ operationVO.setEndDate(endDate);
|
|
|
+ operationVO.setSectionList(toolUtils.getSectionList(request));
|
|
|
+ List<Object> dateList = new ArrayList<>();
|
|
|
+ List<Object> alarmList = new ArrayList<>();
|
|
|
+ List<Object> workList = new ArrayList<>();
|
|
|
+ List<Object> defectList = new ArrayList<>();
|
|
|
+ List<Object> patrolList = new ArrayList<>();
|
|
|
+ List<Object> projectList = new ArrayList<>();
|
|
|
+ List<OperationDataDTO> dataList = new ArrayList<>();
|
|
|
+ HashMap<String, Integer> objectObjectHashMap = new HashMap<>();
|
|
|
+ long timeT = l - 29L * 3600 * 1000 * 24;
|
|
|
+ int i = 0;
|
|
|
+
|
|
|
+ while (timeT <= l) {
|
|
|
+ objectObjectHashMap.put(simpleDateFormat.format(new Date(timeT)),i);
|
|
|
+ dateList.add(simpleDateFormat.format(new Date(timeT)));
|
|
|
+ alarmList.add(0);
|
|
|
+ workList.add(0);
|
|
|
+ defectList.add(0);
|
|
|
+ patrolList.add(0);
|
|
|
+ projectList.add(0);
|
|
|
+ dataList.add(new OperationDataDTO(0,0,0,0,0,simpleDateFormat.format(new Date(timeT))));
|
|
|
+ timeT += 3600 * 1000 * 24;
|
|
|
+ i ++;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 故障列表
|
|
|
+ List<AllAlarmInfoLogDTO> alarmCountList = allAlarmInfoLogService.getAllAlarmCountOnMonth(operationVO);
|
|
|
+ for (AllAlarmInfoLogDTO dto : alarmCountList) {
|
|
|
+ Date date = new Date(simpleDateFormat.parse(dto.getUpdateTime()).getTime());
|
|
|
+ String s = simpleDateFormat.format(date);
|
|
|
+ Integer integer = null;
|
|
|
+ if (objectObjectHashMap.containsKey(s)) {
|
|
|
+ integer = objectObjectHashMap.get(s);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (dto.getDayCount() != null && dto.getDayCount() != 0 && integer != null) {
|
|
|
+ alarmList.set(integer, dto.getDayCount());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 工单列表
|
|
|
+ List<WorkManageDTO> workCountList = workManageService.getWorkManageCountOnMonth(operationVO);
|
|
|
+ for (WorkManageDTO dto : workCountList) {
|
|
|
+ Date date = new Date(simpleDateFormat.parse(dto.getCreateTime()).getTime());
|
|
|
+ String s = simpleDateFormat.format(date);
|
|
|
+ Integer integer = null;
|
|
|
+ if (objectObjectHashMap.containsKey(s)) {
|
|
|
+ integer = objectObjectHashMap.get(s);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (dto.getDayCount() != null && dto.getDayCount() != 0 && integer != null) {
|
|
|
+ workList.set(integer, dto.getDayCount());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 缺陷列表
|
|
|
+ List<DefectManageDTO> defectCountList = defectManageService.getDefectManageCountOnMonth(operationVO);
|
|
|
+ for (DefectManageDTO dto : defectCountList) {
|
|
|
+ Date date = new Date(simpleDateFormat.parse(dto.getCreateTime()).getTime());
|
|
|
+ String s = simpleDateFormat.format(date);
|
|
|
+ Integer integer = null;
|
|
|
+ if (objectObjectHashMap.containsKey(s)) {
|
|
|
+ integer = objectObjectHashMap.get(s);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (dto.getDayCount() != null && dto.getDayCount() != 0 && integer != null) {
|
|
|
+ defectList.set(integer, dto.getDayCount());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 巡视列表
|
|
|
+ List<PatrolManageDTO> patrolCountList = patrolManageService.getPatrolManageCountOnMonth(operationVO);
|
|
|
+ for (PatrolManageDTO dto : patrolCountList) {
|
|
|
+ Date date = new Date(simpleDateFormat.parse(dto.getCreateTime()).getTime());
|
|
|
+ String s = simpleDateFormat.format(date);
|
|
|
+ Integer integer = null;
|
|
|
+ if (objectObjectHashMap.containsKey(s)) {
|
|
|
+ integer = objectObjectHashMap.get(s);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (dto.getDayCount() != null && dto.getDayCount() != 0 && integer != null) {
|
|
|
+ patrolList.set(integer, dto.getDayCount());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 维修项目列表
|
|
|
+ List<RepairProjectDTO> repairCountList = repairProjectService.getRepairProjectCountOnMonth(operationVO);
|
|
|
+ for (RepairProjectDTO dto : repairCountList) {
|
|
|
+ Date date = new Date(simpleDateFormat.parse(dto.getCreateTime()).getTime());
|
|
|
+ String s = simpleDateFormat.format(date);
|
|
|
+ Integer integer = null;
|
|
|
+ if (objectObjectHashMap.containsKey(s)) {
|
|
|
+ integer = objectObjectHashMap.get(s);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (dto.getDayCount() != null && dto.getDayCount() != 0 && integer != null) {
|
|
|
+ projectList.set(integer, dto.getDayCount());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 列表数据
|
|
|
+ for (OperationDataDTO dto : dataList) {
|
|
|
+ alarmCountList.forEach(dto1 -> {
|
|
|
+ if (dto1.getUpdateTime().equals(dto.getDate())) {
|
|
|
+ dto.setAlarmCount(dto1.getDayCount());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ for (OperationDataDTO dto : dataList) {
|
|
|
+ workCountList.forEach(dto1 -> {
|
|
|
+ if (dto1.getCreateTime().equals(dto.getDate())) {
|
|
|
+ dto.setWorkCount(dto1.getDayCount());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ for (OperationDataDTO dto : dataList) {
|
|
|
+ defectCountList.forEach(dto1 -> {
|
|
|
+ if (dto1.getCreateTime().equals(dto.getDate())) {
|
|
|
+ dto.setDefectCount(dto1.getDayCount());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ for (OperationDataDTO dto : dataList) {
|
|
|
+ patrolCountList.forEach(dto1 -> {
|
|
|
+ if (dto1.getCreateTime().equals(dto.getDate())) {
|
|
|
+ dto.setPatrolCount(dto1.getDayCount());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ for (OperationDataDTO dto : dataList) {
|
|
|
+ repairCountList.forEach(dto1 -> {
|
|
|
+ if (dto1.getCreateTime().equals(dto.getDate())) {
|
|
|
+ dto.setProjectCount(dto1.getDayCount());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ Integer allAlarmInfoLogCount = allAlarmInfoLogService.getAllAlarmInfoLogCount(operationVO);
|
|
|
+ Integer workManageCount = workManageService.getWorkManageCount(operationVO);
|
|
|
+ Integer defectManageCount = defectManageService.getDefectManageCount(operationVO);
|
|
|
+ Integer patrolManageCount = patrolManageService.getPatrolManageCount1(operationVO);
|
|
|
+ Integer repairProjectCount = repairProjectService.getRepairProjectCount(operationVO);
|
|
|
+ OperationVO vo = new OperationVO();
|
|
|
+ vo.setAlarmCount(allAlarmInfoLogCount);
|
|
|
+ vo.setWorkCount(workManageCount);
|
|
|
+ vo.setDefectCount(defectManageCount);
|
|
|
+ vo.setPatrolCount(patrolManageCount);
|
|
|
+ vo.setProjectCount(repairProjectCount);
|
|
|
+ vo.setAlarmList(alarmList);
|
|
|
+ vo.setWorkList(workList);
|
|
|
+ vo.setDefectList(defectList);
|
|
|
+ vo.setPatrolList(patrolList);
|
|
|
+ vo.setProjectList(projectList);
|
|
|
+ vo.setDateList(dateList);
|
|
|
+ vo.setDataList(dataList);
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,vo);
|
|
|
+ }
|
|
|
}
|