|
@@ -3,12 +3,16 @@ package com.platform.service.preparation.impl;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.platform.common.bean.AbstractPageResultBean;
|
|
|
import com.platform.common.cache.ConfigCache;
|
|
|
+import com.platform.common.cache.DictCache;
|
|
|
+import com.platform.common.constant.CommonConstants;
|
|
|
import com.platform.common.exception.DeniedException;
|
|
|
import com.platform.common.model.UserInfo;
|
|
|
import com.platform.common.util.*;
|
|
|
import com.platform.dao.bean.MyPage;
|
|
|
import com.platform.dao.dto.preparation.PreparationDTO;
|
|
|
+import com.platform.dao.dto.repair.RepairRecordTemplateData;
|
|
|
import com.platform.dao.dto.upms.SysUserDTO;
|
|
|
+import com.platform.dao.entity.customize.CustomFieldTemplateData;
|
|
|
import com.platform.dao.entity.preparation.Preparation;
|
|
|
import com.platform.dao.entity.sb.SbPosition;
|
|
|
import com.platform.dao.entity.upms.SysFile;
|
|
@@ -23,6 +27,10 @@ import com.platform.dao.util.MessageTemplateUtil;
|
|
|
import com.platform.dao.vo.SysUserRoleVO;
|
|
|
import com.platform.dao.vo.SysUserVO;
|
|
|
import com.platform.dao.vo.query.preparation.PreparationVO;
|
|
|
+import com.platform.dao.vo.repair.RepairApplicationFormVO;
|
|
|
+import com.platform.dao.vo.report.AllPreparationReportVO;
|
|
|
+import com.platform.dao.vo.report.PreparationReportByStatusVO;
|
|
|
+import com.platform.dao.vo.report.RepairReport24VO;
|
|
|
import com.platform.service.base.impl.BaseServiceImpl;
|
|
|
import com.platform.service.event.WorkplaceBacklogEvent;
|
|
|
import com.platform.service.preparation.PreparationService;
|
|
@@ -34,6 +42,7 @@ import tk.mybatis.mapper.weekend.Weekend;
|
|
|
import tk.mybatis.mapper.weekend.WeekendCriteria;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
@@ -62,6 +71,175 @@ public class PreparationServiceImpl extends BaseServiceImpl<PreparationMapper, P
|
|
|
@Resource
|
|
|
private SysUserRoleMapper sysUserRoleMapper;
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<PreparationReportByStatusVO> getPreparationReportGroupByStatus(PreparationDTO dto, Integer searchYear, LocalDate startMonth, LocalDate endMonth) {
|
|
|
+ List<Map<String, LocalDateTime>> monthStartAndEndList = new ArrayList<Map<String, LocalDateTime>>();
|
|
|
+ LocalDateTime searchStartTime = null;
|
|
|
+ LocalDateTime searchEndTime = null;
|
|
|
+ if (searchYear != null) {
|
|
|
+ LocalDate localDate = LocalDate.now();
|
|
|
+ int year = localDate.getYear();
|
|
|
+ // 如2021-10-15号码,则month=10,需要计算到11月份,需要加1
|
|
|
+ int month = localDate.getMonthValue();
|
|
|
+ if (searchYear < year) {
|
|
|
+ month = 12;
|
|
|
+ year = searchYear;
|
|
|
+ }
|
|
|
+ monthStartAndEndList = DateUtils.getMonthStartAndEndByYear(year, month);
|
|
|
+ // 当前年份只统计到当前月,历史年份统计全年
|
|
|
+ searchStartTime = DateUtils.getFirstDayOfThisYear(year);
|
|
|
+ searchEndTime = DateUtils.getLastDayOfMonth(year, month);
|
|
|
+ } else {
|
|
|
+ monthStartAndEndList = DateUtils.getMonthStartAndEndByYear(startMonth, endMonth);
|
|
|
+ searchStartTime = DateUtils.getFirstDayOfMonth(startMonth);
|
|
|
+ searchEndTime = DateUtils.getLastDayOfMonth(endMonth);
|
|
|
+ }
|
|
|
+
|
|
|
+ dto.setCreatedTimeEnd(searchStartTime);
|
|
|
+ dto.setCreatedTimeEnd(searchEndTime);
|
|
|
+ List<PreparationVO> list = mapper.selectList(dto);
|
|
|
+ List<PreparationReportByStatusVO> result = new ArrayList<>();
|
|
|
+ Integer draftNum = 0;
|
|
|
+ Integer waiting_allocationNum = 0;
|
|
|
+ Integer allocationedNum = 0;
|
|
|
+ Integer complatedNum = 0;
|
|
|
+ Integer revokedNum = 0;
|
|
|
+ PreparationReportByStatusVO draft = new PreparationReportByStatusVO();
|
|
|
+ PreparationReportByStatusVO waiting = new PreparationReportByStatusVO();
|
|
|
+ PreparationReportByStatusVO allocationed = new PreparationReportByStatusVO();
|
|
|
+ PreparationReportByStatusVO complated = new PreparationReportByStatusVO();
|
|
|
+ PreparationReportByStatusVO revoked = new PreparationReportByStatusVO();
|
|
|
+ List<PreparationVO> draftList = new ArrayList<>();
|
|
|
+ List<PreparationVO> waitingList = new ArrayList<>();
|
|
|
+ List<PreparationVO> allocationedList = new ArrayList<>();
|
|
|
+ List<PreparationVO> complatedList = new ArrayList<>();
|
|
|
+ List<PreparationVO> revokedList = new ArrayList<>();
|
|
|
+ for (PreparationVO vo:list){
|
|
|
+ if (DictCache.getValueByCode("REPAIR_PREPARATION_STATUS","draft").equals(vo.getStatus())){
|
|
|
+ draft.setStatusName("草稿");
|
|
|
+ draftList.add(vo);
|
|
|
+ draft.setStatus(0);
|
|
|
+ draftNum++;
|
|
|
+ }else if (DictCache.getValueByCode("REPAIR_PREPARATION_STATUS","waiting_allocation").equals(vo.getStatus())){
|
|
|
+ draft.setStatusName("待分配");
|
|
|
+ waitingList.add(vo);
|
|
|
+ waiting.setStatus(1);
|
|
|
+ waiting_allocationNum++;
|
|
|
+ }else if (DictCache.getValueByCode("REPAIR_PREPARATION_STATUS","allocationed").equals(vo.getStatus())){
|
|
|
+ allocationed.setStatusName("已分配");
|
|
|
+ allocationedList.add(vo);
|
|
|
+ allocationed.setStatus(2);
|
|
|
+ allocationedNum++;
|
|
|
+ }else if (DictCache.getValueByCode("REPAIR_PREPARATION_STATUS","complated").equals(vo.getStatus())){
|
|
|
+ complated.setStatusName("已完成");
|
|
|
+ complatedList.add(vo);
|
|
|
+ complated.setStatus(3);
|
|
|
+ complatedNum++;
|
|
|
+ }else if (DictCache.getValueByCode("REPAIR_PREPARATION_STATUS","revoked").equals(vo.getStatus())){
|
|
|
+ revoked.setStatusName("已撤销");
|
|
|
+ revokedList.add(vo);
|
|
|
+ revoked.setStatus(4);
|
|
|
+ revokedNum++;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ List<PreparationReportByStatusVO> list1 = new ArrayList<>();
|
|
|
+ if (draftNum!=0){
|
|
|
+ draft.setNum(draftNum);
|
|
|
+ draft.setDetailList(draftList);
|
|
|
+ list1.add(draft);
|
|
|
+ }
|
|
|
+ if (waiting_allocationNum!=0){
|
|
|
+ waiting.setNum(waiting_allocationNum);
|
|
|
+ waiting.setDetailList(waitingList);
|
|
|
+ list1.add(waiting);
|
|
|
+ }
|
|
|
+ if (allocationedNum!=0) {
|
|
|
+ allocationed.setNum(allocationedNum);
|
|
|
+ allocationed.setDetailList(allocationedList);
|
|
|
+ list1.add(allocationed);
|
|
|
+ }
|
|
|
+ if (complatedNum!=0){
|
|
|
+ complated.setNum(complatedNum);
|
|
|
+ complated.setDetailList(complatedList);
|
|
|
+ list1.add(complated);
|
|
|
+ }
|
|
|
+ if (revokedNum!=0){
|
|
|
+ revoked.setNum(revokedNum);
|
|
|
+ revoked.setDetailList(revokedList);
|
|
|
+ list1.add(revoked);
|
|
|
+ }
|
|
|
+ return list1;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<AllPreparationReportVO> getAllPreparationReport(PreparationDTO dto, Integer searchYear, LocalDate startMonth, LocalDate endMonth) {
|
|
|
+ List<Map<String, LocalDateTime>> monthStartAndEndList = new ArrayList<Map<String, LocalDateTime>>();
|
|
|
+ LocalDateTime searchStartTime = null;
|
|
|
+ LocalDateTime searchEndTime = null;
|
|
|
+ if (searchYear != null) {
|
|
|
+ LocalDate localDate = LocalDate.now();
|
|
|
+ int year = localDate.getYear();
|
|
|
+ // 如2021-10-15号码,则month=10,需要计算到11月份,需要加1
|
|
|
+ int month = localDate.getMonthValue();
|
|
|
+ if (searchYear < year) {
|
|
|
+ month = 12;
|
|
|
+ year = searchYear;
|
|
|
+ }
|
|
|
+ monthStartAndEndList = DateUtils.getMonthStartAndEndByYear(year, month);
|
|
|
+ // 当前年份只统计到当前月,历史年份统计全年
|
|
|
+ searchStartTime = DateUtils.getFirstDayOfThisYear(year);
|
|
|
+ searchEndTime = DateUtils.getLastDayOfMonth(year, month);
|
|
|
+ } else {
|
|
|
+ monthStartAndEndList = DateUtils.getMonthStartAndEndByYear(startMonth, endMonth);
|
|
|
+ searchStartTime = DateUtils.getFirstDayOfMonth(startMonth);
|
|
|
+ searchEndTime = DateUtils.getLastDayOfMonth(endMonth);
|
|
|
+ }
|
|
|
+
|
|
|
+ dto.setCreatedTimeEnd(searchStartTime);
|
|
|
+ dto.setCreatedTimeEnd(searchEndTime);
|
|
|
+ List<PreparationVO> list = mapper.selectList(dto);
|
|
|
+ List<AllPreparationReportVO> result = new ArrayList<AllPreparationReportVO>();
|
|
|
+
|
|
|
+ for (Map<String, LocalDateTime> map : monthStartAndEndList) {
|
|
|
+ int i = 0;
|
|
|
+ AllPreparationReportVO vo = new AllPreparationReportVO();
|
|
|
+ List<PreparationVO> detailList = new ArrayList<PreparationVO>();
|
|
|
+ vo.setYear(map.get("searchStartTimeMonth").getYear());
|
|
|
+ vo.setMonth(map.get("searchStartTimeMonth").getMonthValue());
|
|
|
+
|
|
|
+// // 维修描述
|
|
|
+// Weekend<CustomFieldTemplateData> weekend = new Weekend<>(CustomFieldTemplateData.class);
|
|
|
+// WeekendCriteria<CustomFieldTemplateData, Object> weekendCriteria = weekend.weekendCriteria();
|
|
|
+// weekendCriteria = weekendCriteria.andEqualTo(CustomFieldTemplateData::getRemark, CommonConstants.REPAIR_RECORD);
|
|
|
+// weekendCriteria.andLessThan(CustomFieldTemplateData::getCreatedTime,map.get("searchEndTimeMonth"));
|
|
|
+// weekendCriteria.andGreaterThan(CustomFieldTemplateData::getCreatedTime,map.get("searchStartTimeMonth"));
|
|
|
+// List<CustomFieldTemplateData> listCustomer = customFieldTemplateDataMapper.selectByExample(weekend);
|
|
|
+// Map<String,CustomFieldTemplateData> dataMap = new HashMap<>();
|
|
|
+// if(listCustomer != null && listCustomer.size() > 0){
|
|
|
+// listCustomer.forEach(item->{
|
|
|
+// String key = item.getObjId() + "&" + item.getCreatedUserId();
|
|
|
+// CustomFieldTemplateData tempData = dataMap.get(key);
|
|
|
+// if(tempData == null){
|
|
|
+// dataMap.put(key,item);
|
|
|
+// }
|
|
|
+// });
|
|
|
+// }
|
|
|
+ for (PreparationVO preparationVO : list) {
|
|
|
+ if (preparationVO.getApplyTime().isAfter(map.get("searchStartTimeMonth")) && preparationVO.getApplyTime().isBefore(map.get("searchEndTimeMonth"))) {
|
|
|
+ i++;
|
|
|
+ // 维修专业
|
|
|
+
|
|
|
+ detailList.add(preparationVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ vo.setNum(i);
|
|
|
+ vo.setDetailList(detailList);
|
|
|
+ result.add(vo);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public int batchDelete(List<String> ids) {
|
|
|
Weekend<Preparation> weekend = new Weekend<>(Preparation.class);
|