|
|
|
@ -2,8 +2,10 @@ package com.hnac.hzims.operational.maintenance.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
|
import com.google.common.collect.Lists; |
|
|
|
|
import com.hnac.hzims.operational.defect.constants.DefectConstant; |
|
|
|
|
import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity; |
|
|
|
@ -22,6 +24,9 @@ import com.hnac.hzims.operational.maintenance.vo.OperMaintenanceTaskVO;
|
|
|
|
|
import com.hnac.hzims.operational.maintenance.wrapper.OperMaintenanceTaskWrapper; |
|
|
|
|
import com.hnac.hzims.safeproduct.Constants; |
|
|
|
|
import com.hnac.hzims.safeproduct.feign.IDangerSourceClient; |
|
|
|
|
import com.hnac.hzims.ticket.areamonthly.vo.AreaMonthlyVo; |
|
|
|
|
import com.hnac.hzims.ticket.areamonthly.vo.MaintenanceTaskVo; |
|
|
|
|
import com.hnac.hzims.ticket.areamonthly.vo.MaintenanceTaskWithAreaVo; |
|
|
|
|
import com.hnac.hzims.vo.SafeCheckStatisticVO; |
|
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
@ -41,6 +46,7 @@ import org.springblade.system.cache.DictCache;
|
|
|
|
|
import org.springblade.system.user.cache.UserCache; |
|
|
|
|
import org.springblade.system.user.entity.User; |
|
|
|
|
import org.springblade.system.user.feign.IUserClient; |
|
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
@ -62,267 +68,323 @@ import java.util.stream.Collectors;
|
|
|
|
|
@RequiredArgsConstructor |
|
|
|
|
@Slf4j |
|
|
|
|
public class OperMaintenanceTaskServiceImpl extends BaseServiceImpl<OperMaintenanceTaskMapper, OperMaintenanceTaskEntity> implements IOperMaintenanceTaskService { |
|
|
|
|
private final IDangerSourceClient dangerSourceClient; |
|
|
|
|
private final OperMaintenanceTaskMapper operMaintenanceTaskMapper; |
|
|
|
|
private final OperPhenomenonMapper operPhenomenonMapper; |
|
|
|
|
private final IFlowClient flowClient; |
|
|
|
|
private final IUserClient userClient; |
|
|
|
|
private final IDangerSourceClient dangerSourceClient; |
|
|
|
|
private final OperMaintenanceTaskMapper operMaintenanceTaskMapper; |
|
|
|
|
private final OperPhenomenonMapper operPhenomenonMapper; |
|
|
|
|
private final IFlowClient flowClient; |
|
|
|
|
private final IUserClient userClient; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public R doSave(OperMaintenanceTaskDTO req) { |
|
|
|
|
req.setTaskCode(this.genTaskCode(RandomUtils.nextInt(0, 999))); |
|
|
|
|
//保存时推送消息
|
|
|
|
|
return R.status(super.save(req)); |
|
|
|
|
} |
|
|
|
|
@Override |
|
|
|
|
public R doSave(OperMaintenanceTaskDTO req) { |
|
|
|
|
req.setTaskCode(this.genTaskCode(RandomUtils.nextInt(0, 999))); |
|
|
|
|
//保存时推送消息
|
|
|
|
|
return R.status(super.save(req)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public R<OperMaintenanceTaskEntity> detail(Long id) { |
|
|
|
|
OperMaintenanceTaskVO detail = OperMaintenanceTaskWrapper.build().entityVO(super.getById(id)); |
|
|
|
|
detail.setDangerSources(dangerSourceClient.details(detail.getSafo().split(","))); |
|
|
|
|
return R.data(detail); |
|
|
|
|
} |
|
|
|
|
@Override |
|
|
|
|
public R<OperMaintenanceTaskEntity> detail(Long id) { |
|
|
|
|
OperMaintenanceTaskVO detail = OperMaintenanceTaskWrapper.build().entityVO(super.getById(id)); |
|
|
|
|
detail.setDangerSources(dangerSourceClient.details(detail.getSafo().split(","))); |
|
|
|
|
return R.data(detail); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public R<IPage<OperMaintenanceTaskVO>> list(OperMaintenanceTaskDTO req, Query query) { |
|
|
|
|
Wrapper<OperMaintenanceTaskEntity> queryWrapper = new LambdaQueryWrapper<OperMaintenanceTaskEntity>() {{ |
|
|
|
|
orderByDesc(OperMaintenanceTaskEntity::getDisposeTime); |
|
|
|
|
if(StringUtil.isNotBlank(req.getTaskIds())){ |
|
|
|
|
in(OperMaintenanceTaskEntity::getId, Lists.newArrayList(req.getTaskIds().split(","))); |
|
|
|
|
} |
|
|
|
|
if (req.getRefLibraryId() != null) { |
|
|
|
|
eq(OperMaintenanceTaskEntity::getRefLibraryId, req.getRefLibraryId()); |
|
|
|
|
} |
|
|
|
|
if (StringUtils.isNotBlank(req.getProcessInstanceId())) { |
|
|
|
|
eq(OperMaintenanceTaskEntity::getProcessInstanceId, req.getProcessInstanceId()); |
|
|
|
|
} |
|
|
|
|
if (req.getDisposer() != null) { |
|
|
|
|
like(OperMaintenanceTaskEntity::getDisposer, req.getDisposer()); |
|
|
|
|
} |
|
|
|
|
if (StringUtils.isNotBlank(req.getContent())) { |
|
|
|
|
like(OperMaintenanceTaskEntity::getContent, req.getContent()); |
|
|
|
|
} |
|
|
|
|
if (req.getStatus() != null) { |
|
|
|
|
eq(OperMaintenanceTaskEntity::getStatus, req.getStatus()); |
|
|
|
|
} |
|
|
|
|
if (req.getTitle() != null) { |
|
|
|
|
like(OperMaintenanceTaskEntity::getTitle, req.getTitle()); |
|
|
|
|
} |
|
|
|
|
if (req.getTaskType() != null) { |
|
|
|
|
eq(OperMaintenanceTaskEntity::getTaskType, req.getTaskType()); |
|
|
|
|
} |
|
|
|
|
if (req.getExcludeNullTicket() != null && req.getExcludeNullTicket() == 1) { |
|
|
|
|
isNull(OperMaintenanceTaskEntity::getTicketId); |
|
|
|
|
} |
|
|
|
|
if (!StringUtil.isEmpty(req.getStartTime())) { |
|
|
|
|
gt(OperMaintenanceTaskEntity::getDisposeTime,req.getStartTime()); |
|
|
|
|
} |
|
|
|
|
if (!StringUtil.isEmpty(req.getEndTime())) { |
|
|
|
|
lt(OperMaintenanceTaskEntity::getDisposeTime,req.getEndTime()); |
|
|
|
|
} |
|
|
|
|
if(!CollectionUtils.isEmpty(req.getDeptIds())){ |
|
|
|
|
in(OperMaintenanceTaskEntity::getCreateDept,req.getDeptIds()); |
|
|
|
|
} |
|
|
|
|
}}; |
|
|
|
|
@Override |
|
|
|
|
public R<IPage<OperMaintenanceTaskVO>> list(OperMaintenanceTaskDTO req, Query query) { |
|
|
|
|
Wrapper<OperMaintenanceTaskEntity> queryWrapper = new LambdaQueryWrapper<OperMaintenanceTaskEntity>() {{ |
|
|
|
|
orderByDesc(OperMaintenanceTaskEntity::getDisposeTime); |
|
|
|
|
if (StringUtil.isNotBlank(req.getTaskIds())) { |
|
|
|
|
in(OperMaintenanceTaskEntity::getId, Lists.newArrayList(req.getTaskIds().split(","))); |
|
|
|
|
} |
|
|
|
|
if (req.getRefLibraryId() != null) { |
|
|
|
|
eq(OperMaintenanceTaskEntity::getRefLibraryId, req.getRefLibraryId()); |
|
|
|
|
} |
|
|
|
|
if (StringUtils.isNotBlank(req.getProcessInstanceId())) { |
|
|
|
|
eq(OperMaintenanceTaskEntity::getProcessInstanceId, req.getProcessInstanceId()); |
|
|
|
|
} |
|
|
|
|
if (req.getDisposer() != null) { |
|
|
|
|
like(OperMaintenanceTaskEntity::getDisposer, req.getDisposer()); |
|
|
|
|
} |
|
|
|
|
if (StringUtils.isNotBlank(req.getContent())) { |
|
|
|
|
like(OperMaintenanceTaskEntity::getContent, req.getContent()); |
|
|
|
|
} |
|
|
|
|
if (req.getStatus() != null) { |
|
|
|
|
eq(OperMaintenanceTaskEntity::getStatus, req.getStatus()); |
|
|
|
|
} |
|
|
|
|
if (req.getTitle() != null) { |
|
|
|
|
like(OperMaintenanceTaskEntity::getTitle, req.getTitle()); |
|
|
|
|
} |
|
|
|
|
if (req.getTaskType() != null) { |
|
|
|
|
eq(OperMaintenanceTaskEntity::getTaskType, req.getTaskType()); |
|
|
|
|
} |
|
|
|
|
if (req.getExcludeNullTicket() != null && req.getExcludeNullTicket() == 1) { |
|
|
|
|
isNull(OperMaintenanceTaskEntity::getTicketId); |
|
|
|
|
} |
|
|
|
|
if (!StringUtil.isEmpty(req.getStartTime())) { |
|
|
|
|
gt(OperMaintenanceTaskEntity::getDisposeTime, req.getStartTime()); |
|
|
|
|
} |
|
|
|
|
if (!StringUtil.isEmpty(req.getEndTime())) { |
|
|
|
|
lt(OperMaintenanceTaskEntity::getDisposeTime, req.getEndTime()); |
|
|
|
|
} |
|
|
|
|
if (!CollectionUtils.isEmpty(req.getDeptIds())) { |
|
|
|
|
in(OperMaintenanceTaskEntity::getCreateDept, req.getDeptIds()); |
|
|
|
|
} |
|
|
|
|
}}; |
|
|
|
|
|
|
|
|
|
IPage pages = super.page(Condition.getPage(query), queryWrapper); |
|
|
|
|
pages.setRecords(OperMaintenanceTaskWrapper.build().listVO(pages.getRecords())); |
|
|
|
|
return R.data(pages); |
|
|
|
|
} |
|
|
|
|
IPage pages = super.page(Condition.getPage(query), queryWrapper); |
|
|
|
|
pages.setRecords(OperMaintenanceTaskWrapper.build().listVO(pages.getRecords())); |
|
|
|
|
return R.data(pages); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public String genTaskCode(Integer num) { |
|
|
|
|
return DateUtil.format(DateUtil.now(), DateUtil.PATTERN_DATETIME_MINI) + new DecimalFormat("000").format(num); |
|
|
|
|
} |
|
|
|
|
@Override |
|
|
|
|
public String genTaskCode(Integer num) { |
|
|
|
|
return DateUtil.format(DateUtil.now(), DateUtil.PATTERN_DATETIME_MINI) + new DecimalFormat("000").format(num); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<OperMaintenanceTaskEntity> getByEmCode(String emCode, List<String> list) { |
|
|
|
|
return this.baseMapper.selectByEmCode(emCode,list); |
|
|
|
|
} |
|
|
|
|
@Override |
|
|
|
|
public List<OperMaintenanceTaskEntity> getByEmCode(String emCode, List<String> list) { |
|
|
|
|
return this.baseMapper.selectByEmCode(emCode, list); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<MaintenanceReportVO> getMaintenanceStatisticsByDisposer(LocalDate startDate, LocalDate endDate, List<Long> deptIdList) { |
|
|
|
|
List<MaintenanceReportVO> maintenanceReportVOList = new ArrayList<>(); |
|
|
|
|
//查询当月日常维护任务
|
|
|
|
|
List<OperMaintenanceTaskEntity> operMaintenanceTaskEntityList = this.baseMapper.selectList(new LambdaQueryWrapper<OperMaintenanceTaskEntity>(){{ |
|
|
|
|
ge(OperMaintenanceTaskEntity::getDisposeTime,startDate); |
|
|
|
|
le(OperMaintenanceTaskEntity::getDisposeTime,endDate); |
|
|
|
|
in(OperMaintenanceTaskEntity::getCreateDept,deptIdList); |
|
|
|
|
}}); |
|
|
|
|
//按执行人组合
|
|
|
|
|
if(CollectionUtil.isNotEmpty(operMaintenanceTaskEntityList)){ |
|
|
|
|
Map<String,List<OperMaintenanceTaskEntity>> map = operMaintenanceTaskEntityList.stream().filter(o->StringUtils.isNotBlank(o.getDisposer())).collect(Collectors.groupingBy(OperMaintenanceTaskEntity::getDisposer)); |
|
|
|
|
map.forEach((k,v)->{ |
|
|
|
|
MaintenanceReportVO maintenanceReportVO = new MaintenanceReportVO(); |
|
|
|
|
//获取执行人名字
|
|
|
|
|
List<Long> userIdList = Arrays.asList(k.split(",")).stream().map(o->Long.parseLong(o)).collect(Collectors.toList()); |
|
|
|
|
String userName = userIdList.stream().map(userId -> { |
|
|
|
|
User user = UserCache.getUser(userId); |
|
|
|
|
return Optional.ofNullable(user).map(User::getName).orElse(""); |
|
|
|
|
}).collect(Collectors.joining(",")); |
|
|
|
|
maintenanceReportVO.setOperMaintenanceTaskEntityList(v); |
|
|
|
|
maintenanceReportVO.setUserName(userName); |
|
|
|
|
//已完成任务
|
|
|
|
|
List<OperMaintenanceTaskEntity> finishTask = v.stream().filter(o-> MaintenanceConstant.TASK_STATUS_5 == o.getStatus()).collect(Collectors.toList()); |
|
|
|
|
Map<String,List<OperMaintenanceTaskEntity>> finishTaskGroupByType = finishTask.stream().collect(Collectors.groupingBy(OperMaintenanceTaskEntity::getTypeCode)); |
|
|
|
|
AtomicReference<String> finishSituation = new AtomicReference<>(""); |
|
|
|
|
finishTaskGroupByType.forEach((TypeCode,TypeList)->{ |
|
|
|
|
try{ |
|
|
|
|
finishSituation.set(finishSituation.get().concat(DictCache.getValue(DictConstant.MAINTENANCE_TYPE_CODE, TypeCode)).concat(":").concat(TypeList.size() + "").concat("\r\n")); |
|
|
|
|
} |
|
|
|
|
catch(NullPointerException e){ |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
maintenanceReportVO.setCompleteNum(finishTask.size()); |
|
|
|
|
maintenanceReportVO.setCompleteSituation(finishSituation.get()); |
|
|
|
|
//未完成任务
|
|
|
|
|
List<OperMaintenanceTaskEntity> immatureTask = v.stream().filter(o-> MaintenanceConstant.TASK_STATUS_5 != o.getStatus()).collect(Collectors.toList()); |
|
|
|
|
Map<String,List<OperMaintenanceTaskEntity>> immatureTaskTaskGroupByType = immatureTask.stream().collect(Collectors.groupingBy(OperMaintenanceTaskEntity::getTypeCode)); |
|
|
|
|
AtomicReference<String> immatureTaskSituation = new AtomicReference<>(""); |
|
|
|
|
immatureTaskTaskGroupByType.forEach((TypeCode,TypeList)->{ |
|
|
|
|
immatureTaskSituation.set(immatureTaskSituation.get().concat(DictCache.getValue(DictConstant.MAINTENANCE_TYPE_CODE, TypeCode)).concat(":").concat(TypeList.size() + "").concat("\r\n")); |
|
|
|
|
}); |
|
|
|
|
maintenanceReportVO.setIncompleteNum(immatureTask.size()); |
|
|
|
|
maintenanceReportVO.setIncompleteSituation(immatureTaskSituation.get()); |
|
|
|
|
@Override |
|
|
|
|
public List<MaintenanceReportVO> getMaintenanceStatisticsByDisposer(LocalDate startDate, LocalDate endDate, List<Long> deptIdList) { |
|
|
|
|
List<MaintenanceReportVO> maintenanceReportVOList = new ArrayList<>(); |
|
|
|
|
//查询当月日常维护任务
|
|
|
|
|
List<OperMaintenanceTaskEntity> operMaintenanceTaskEntityList = this.baseMapper.selectList(new LambdaQueryWrapper<OperMaintenanceTaskEntity>() {{ |
|
|
|
|
ge(OperMaintenanceTaskEntity::getDisposeTime, startDate); |
|
|
|
|
le(OperMaintenanceTaskEntity::getDisposeTime, endDate); |
|
|
|
|
in(OperMaintenanceTaskEntity::getCreateDept, deptIdList); |
|
|
|
|
}}); |
|
|
|
|
//按执行人组合
|
|
|
|
|
if (CollectionUtil.isNotEmpty(operMaintenanceTaskEntityList)) { |
|
|
|
|
Map<String, List<OperMaintenanceTaskEntity>> map = operMaintenanceTaskEntityList.stream().filter(o -> StringUtils.isNotBlank(o.getDisposer())).collect(Collectors.groupingBy(OperMaintenanceTaskEntity::getDisposer)); |
|
|
|
|
map.forEach((k, v) -> { |
|
|
|
|
MaintenanceReportVO maintenanceReportVO = new MaintenanceReportVO(); |
|
|
|
|
//获取执行人名字
|
|
|
|
|
List<Long> userIdList = Arrays.asList(k.split(",")).stream().map(o -> Long.parseLong(o)).collect(Collectors.toList()); |
|
|
|
|
String userName = userIdList.stream().map(userId -> { |
|
|
|
|
User user = UserCache.getUser(userId); |
|
|
|
|
return Optional.ofNullable(user).map(User::getName).orElse(""); |
|
|
|
|
}).collect(Collectors.joining(",")); |
|
|
|
|
maintenanceReportVO.setOperMaintenanceTaskEntityList(v); |
|
|
|
|
maintenanceReportVO.setUserName(userName); |
|
|
|
|
//已完成任务
|
|
|
|
|
List<OperMaintenanceTaskEntity> finishTask = v.stream().filter(o -> MaintenanceConstant.TASK_STATUS_5 == o.getStatus()).collect(Collectors.toList()); |
|
|
|
|
Map<String, List<OperMaintenanceTaskEntity>> finishTaskGroupByType = finishTask.stream().collect(Collectors.groupingBy(OperMaintenanceTaskEntity::getTypeCode)); |
|
|
|
|
AtomicReference<String> finishSituation = new AtomicReference<>(""); |
|
|
|
|
finishTaskGroupByType.forEach((TypeCode, TypeList) -> { |
|
|
|
|
try { |
|
|
|
|
finishSituation.set(finishSituation.get().concat(DictCache.getValue(DictConstant.MAINTENANCE_TYPE_CODE, TypeCode)).concat(":").concat(TypeList.size() + "").concat("\r\n")); |
|
|
|
|
} catch (NullPointerException e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
maintenanceReportVO.setCompleteNum(finishTask.size()); |
|
|
|
|
maintenanceReportVO.setCompleteSituation(finishSituation.get()); |
|
|
|
|
//未完成任务
|
|
|
|
|
List<OperMaintenanceTaskEntity> immatureTask = v.stream().filter(o -> MaintenanceConstant.TASK_STATUS_5 != o.getStatus()).collect(Collectors.toList()); |
|
|
|
|
Map<String, List<OperMaintenanceTaskEntity>> immatureTaskTaskGroupByType = immatureTask.stream().collect(Collectors.groupingBy(OperMaintenanceTaskEntity::getTypeCode)); |
|
|
|
|
AtomicReference<String> immatureTaskSituation = new AtomicReference<>(""); |
|
|
|
|
immatureTaskTaskGroupByType.forEach((TypeCode, TypeList) -> { |
|
|
|
|
immatureTaskSituation.set(immatureTaskSituation.get().concat(DictCache.getValue(DictConstant.MAINTENANCE_TYPE_CODE, TypeCode)).concat(":").concat(TypeList.size() + "").concat("\r\n")); |
|
|
|
|
}); |
|
|
|
|
maintenanceReportVO.setIncompleteNum(immatureTask.size()); |
|
|
|
|
maintenanceReportVO.setIncompleteSituation(immatureTaskSituation.get()); |
|
|
|
|
|
|
|
|
|
//获取问题数量
|
|
|
|
|
List<OperPhenomenonEntity> operPhenomenonEntityList = operPhenomenonMapper.selectList(new LambdaQueryWrapper<OperPhenomenonEntity>(){{ |
|
|
|
|
in(OperPhenomenonEntity::getFinder,userIdList); |
|
|
|
|
eq(OperPhenomenonEntity::getSourceCode, DefectConstant.DefectSourceEnum.RCWH.getStatus()); |
|
|
|
|
ge(OperPhenomenonEntity::getFindTime,startDate); |
|
|
|
|
le(OperPhenomenonEntity::getFindTime,endDate); |
|
|
|
|
in(OperPhenomenonEntity::getCreateDept,deptIdList); |
|
|
|
|
}}); |
|
|
|
|
maintenanceReportVO.setFindProblemNum(operPhenomenonEntityList.size()); |
|
|
|
|
//获取工时
|
|
|
|
|
int actHoursSum = v.stream().collect(Collectors.summingInt(OperMaintenanceTaskEntity::getHours)); |
|
|
|
|
maintenanceReportVO.setHours(actHoursSum); |
|
|
|
|
//合计
|
|
|
|
|
maintenanceReportVO.setCount(v.size()); |
|
|
|
|
maintenanceReportVOList.add(maintenanceReportVO); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
return maintenanceReportVOList; |
|
|
|
|
} |
|
|
|
|
//获取问题数量
|
|
|
|
|
List<OperPhenomenonEntity> operPhenomenonEntityList = operPhenomenonMapper.selectList(new LambdaQueryWrapper<OperPhenomenonEntity>() {{ |
|
|
|
|
in(OperPhenomenonEntity::getFinder, userIdList); |
|
|
|
|
eq(OperPhenomenonEntity::getSourceCode, DefectConstant.DefectSourceEnum.RCWH.getStatus()); |
|
|
|
|
ge(OperPhenomenonEntity::getFindTime, startDate); |
|
|
|
|
le(OperPhenomenonEntity::getFindTime, endDate); |
|
|
|
|
in(OperPhenomenonEntity::getCreateDept, deptIdList); |
|
|
|
|
}}); |
|
|
|
|
maintenanceReportVO.setFindProblemNum(operPhenomenonEntityList.size()); |
|
|
|
|
//获取工时
|
|
|
|
|
int actHoursSum = v.stream().collect(Collectors.summingInt(OperMaintenanceTaskEntity::getHours)); |
|
|
|
|
maintenanceReportVO.setHours(actHoursSum); |
|
|
|
|
//合计
|
|
|
|
|
maintenanceReportVO.setCount(v.size()); |
|
|
|
|
maintenanceReportVOList.add(maintenanceReportVO); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
return maintenanceReportVOList; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<MaintenanceReportVO> getMaintenanceStatisticsByDisposer(Map<String,Object> params) { |
|
|
|
|
LocalDate startDate = LocalDate.parse(params.get("startDate").toString(), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); |
|
|
|
|
LocalDate endDate = LocalDate.parse(params.get("endDate").toString(), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); |
|
|
|
|
List<Long> deptIdList = (List<Long>) params.get("deptId"); |
|
|
|
|
return getMaintenanceStatisticsByDisposer(startDate,endDate,deptIdList); |
|
|
|
|
} |
|
|
|
|
@Override |
|
|
|
|
public List<MaintenanceReportVO> getMaintenanceStatisticsByDisposer(Map<String, Object> params) { |
|
|
|
|
LocalDate startDate = LocalDate.parse(params.get("startDate").toString(), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); |
|
|
|
|
LocalDate endDate = LocalDate.parse(params.get("endDate").toString(), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); |
|
|
|
|
List<Long> deptIdList = (List<Long>) params.get("deptId"); |
|
|
|
|
return getMaintenanceStatisticsByDisposer(startDate, endDate, deptIdList); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<Map<String, Object>> getMaintenanceConclusion(Map<String, Object> params) { |
|
|
|
|
return operMaintenanceTaskMapper.getMaintenanceConclusion(params); |
|
|
|
|
} |
|
|
|
|
@Override |
|
|
|
|
public List<Map<String, Object>> getMaintenanceConclusion(Map<String, Object> params) { |
|
|
|
|
return operMaintenanceTaskMapper.getMaintenanceConclusion(params); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<OperMaintenanceTaskEntity> getMaintenanceTask(String startTime, String endTime, List<Long> list) { |
|
|
|
|
return this.baseMapper.selectMaintenanceTask(startTime,endTime,list); |
|
|
|
|
} |
|
|
|
|
@Override |
|
|
|
|
public List<OperMaintenanceTaskEntity> getMaintenanceTask(String startTime, String endTime, List<Long> list) { |
|
|
|
|
return this.baseMapper.selectMaintenanceTask(startTime, endTime, list); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@Transactional |
|
|
|
|
public R completeTask(OperMaintenanceTaskDTO req, ComleteTask completeTask) { |
|
|
|
|
/**如果当前流程为待确认、归档,则从相应角色内获取人员列表完成工作流任务**/ |
|
|
|
|
if(req.getStatus() == MaintenanceConstant.TASK_STATUS_3 || req.getStatus() == MaintenanceConstant.TASK_STATUS_4){ |
|
|
|
|
R<List<User>> userListR = userClient.relationUserListByRoleAlias(AuthUtil.getTenantId(),req.getCreateDept(),MaintenanceConstant.GROUP_LEADER); |
|
|
|
|
if(!userListR.isSuccess() || CollectionUtil.isEmpty(userListR.getData())){ |
|
|
|
|
throw new ServiceException("获取"+MaintenanceConstant.GROUP_LEADER+"角色下的用户为空或失败"); |
|
|
|
|
} |
|
|
|
|
String leaders = userListR.getData().stream().map(user->"taskUser_".concat(user.getId().toString())).collect(Collectors.joining(",")); |
|
|
|
|
log.info("获取角色下的人员为:{}",leaders); |
|
|
|
|
if(CollectionUtil.isEmpty(completeTask.getVariables())){ |
|
|
|
|
completeTask.setVariables(new HashMap<>()); |
|
|
|
|
} |
|
|
|
|
completeTask.getVariables().put(MaintenanceConstant.GROUP_LEADER,leaders); |
|
|
|
|
} |
|
|
|
|
R completeR = flowClient.completeTask(completeTask); |
|
|
|
|
if(!completeR.isSuccess()){ |
|
|
|
|
throw new ServiceException(completeR.getMsg()); |
|
|
|
|
} |
|
|
|
|
return R.status(this.updateById(req)); |
|
|
|
|
} |
|
|
|
|
@Override |
|
|
|
|
@Transactional |
|
|
|
|
public R completeTask(OperMaintenanceTaskDTO req, ComleteTask completeTask) { |
|
|
|
|
/**如果当前流程为待确认、归档,则从相应角色内获取人员列表完成工作流任务**/ |
|
|
|
|
if (req.getStatus() == MaintenanceConstant.TASK_STATUS_3 || req.getStatus() == MaintenanceConstant.TASK_STATUS_4) { |
|
|
|
|
R<List<User>> userListR = userClient.relationUserListByRoleAlias(AuthUtil.getTenantId(), req.getCreateDept(), MaintenanceConstant.GROUP_LEADER); |
|
|
|
|
if (!userListR.isSuccess() || CollectionUtil.isEmpty(userListR.getData())) { |
|
|
|
|
throw new ServiceException("获取" + MaintenanceConstant.GROUP_LEADER + "角色下的用户为空或失败"); |
|
|
|
|
} |
|
|
|
|
String leaders = userListR.getData().stream().map(user -> "taskUser_".concat(user.getId().toString())).collect(Collectors.joining(",")); |
|
|
|
|
log.info("获取角色下的人员为:{}", leaders); |
|
|
|
|
if (CollectionUtil.isEmpty(completeTask.getVariables())) { |
|
|
|
|
completeTask.setVariables(new HashMap<>()); |
|
|
|
|
} |
|
|
|
|
completeTask.getVariables().put(MaintenanceConstant.GROUP_LEADER, leaders); |
|
|
|
|
} |
|
|
|
|
R completeR = flowClient.completeTask(completeTask); |
|
|
|
|
if (!completeR.isSuccess()) { |
|
|
|
|
throw new ServiceException(completeR.getMsg()); |
|
|
|
|
} |
|
|
|
|
return R.status(this.updateById(req)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@Transactional |
|
|
|
|
public R deleteTaskBatch(List<Long> taskIdList) { |
|
|
|
|
taskIdList.forEach(taskId->{ |
|
|
|
|
/**删除工作流任务**/ |
|
|
|
|
EndVo endVo = new EndVo(); |
|
|
|
|
if(Func.isEmpty(taskId)){ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
OperMaintenanceTaskEntity taskEntity = this.getById(taskId); |
|
|
|
|
if(ObjectUtil.isEmpty(taskEntity) || ObjectUtil.isEmpty(taskEntity.getProcessInstanceId())){ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
R r = flowClient.delProcessInstanceById(taskEntity.getProcessInstanceId(),"删除日常维护任务"); |
|
|
|
|
if(!r.isSuccess()){ |
|
|
|
|
throw new ServiceException(r.getMsg()); |
|
|
|
|
} |
|
|
|
|
/**删除任务**/ |
|
|
|
|
this.removeById(taskId); |
|
|
|
|
}); |
|
|
|
|
return R.success("删除成功!"); |
|
|
|
|
} |
|
|
|
|
@Override |
|
|
|
|
@Transactional |
|
|
|
|
public R deleteTaskBatch(List<Long> taskIdList) { |
|
|
|
|
taskIdList.forEach(taskId -> { |
|
|
|
|
/**删除工作流任务**/ |
|
|
|
|
EndVo endVo = new EndVo(); |
|
|
|
|
if (Func.isEmpty(taskId)) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
OperMaintenanceTaskEntity taskEntity = this.getById(taskId); |
|
|
|
|
if (ObjectUtil.isEmpty(taskEntity) || ObjectUtil.isEmpty(taskEntity.getProcessInstanceId())) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
R r = flowClient.delProcessInstanceById(taskEntity.getProcessInstanceId(), "删除日常维护任务"); |
|
|
|
|
if (!r.isSuccess()) { |
|
|
|
|
throw new ServiceException(r.getMsg()); |
|
|
|
|
} |
|
|
|
|
/**删除任务**/ |
|
|
|
|
this.removeById(taskId); |
|
|
|
|
}); |
|
|
|
|
return R.success("删除成功!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 获取当班定期工作 |
|
|
|
|
* @param start |
|
|
|
|
* @param end |
|
|
|
|
* @param list |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public RegularWorkVO getDutyRegularWork(String start, String end, List<Long> list) { |
|
|
|
|
RegularWorkVO regularWorkVO = new RegularWorkVO(); |
|
|
|
|
// 查询定期工作任务
|
|
|
|
|
List<OperMaintenanceTaskEntity> regularWorkList = this.list(new LambdaQueryWrapper<OperMaintenanceTaskEntity>(){{ |
|
|
|
|
ge(OperMaintenanceTaskEntity::getDisposeTime,start) |
|
|
|
|
.le(OperMaintenanceTaskEntity::getDisposeTime,end) |
|
|
|
|
.eq(OperMaintenanceTaskEntity::getTypeCode,"05") |
|
|
|
|
.in(OperMaintenanceTaskEntity::getCreateDept,list); |
|
|
|
|
}}); |
|
|
|
|
if(CollectionUtil.isEmpty(regularWorkList)){ |
|
|
|
|
regularWorkVO.setRegularWorkSum(0); |
|
|
|
|
regularWorkVO.setRegularWork(0); |
|
|
|
|
return regularWorkVO; |
|
|
|
|
} |
|
|
|
|
regularWorkVO.setMainTaskIds(regularWorkList.stream().map(OperMaintenanceTaskEntity::getId).map(id->id.toString()).collect(Collectors.joining(","))); |
|
|
|
|
regularWorkVO.setRegularWorkSum(regularWorkList.size()); |
|
|
|
|
// 定期工作任务完成数量
|
|
|
|
|
List<OperMaintenanceTaskEntity> regularWorkFinishList = regularWorkList.stream().filter(o -> MaintenanceConstant.TASK_STATUS_5 == o.getStatus()).collect(Collectors.toList()); |
|
|
|
|
if(CollectionUtil.isEmpty(regularWorkFinishList)){ |
|
|
|
|
regularWorkVO.setRegularWork(0); |
|
|
|
|
return regularWorkVO; |
|
|
|
|
} |
|
|
|
|
regularWorkVO.setRegularWork(regularWorkFinishList.size()); |
|
|
|
|
return regularWorkVO; |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* 获取当班定期工作 |
|
|
|
|
* |
|
|
|
|
* @param start |
|
|
|
|
* @param end |
|
|
|
|
* @param list |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public RegularWorkVO getDutyRegularWork(String start, String end, List<Long> list) { |
|
|
|
|
RegularWorkVO regularWorkVO = new RegularWorkVO(); |
|
|
|
|
// 查询定期工作任务
|
|
|
|
|
List<OperMaintenanceTaskEntity> regularWorkList = this.list(new LambdaQueryWrapper<OperMaintenanceTaskEntity>() {{ |
|
|
|
|
ge(OperMaintenanceTaskEntity::getDisposeTime, start) |
|
|
|
|
.le(OperMaintenanceTaskEntity::getDisposeTime, end) |
|
|
|
|
.eq(OperMaintenanceTaskEntity::getTypeCode, "05") |
|
|
|
|
.in(OperMaintenanceTaskEntity::getCreateDept, list); |
|
|
|
|
}}); |
|
|
|
|
if (CollectionUtil.isEmpty(regularWorkList)) { |
|
|
|
|
regularWorkVO.setRegularWorkSum(0); |
|
|
|
|
regularWorkVO.setRegularWork(0); |
|
|
|
|
return regularWorkVO; |
|
|
|
|
} |
|
|
|
|
regularWorkVO.setMainTaskIds(regularWorkList.stream().map(OperMaintenanceTaskEntity::getId).map(id -> id.toString()).collect(Collectors.joining(","))); |
|
|
|
|
regularWorkVO.setRegularWorkSum(regularWorkList.size()); |
|
|
|
|
// 定期工作任务完成数量
|
|
|
|
|
List<OperMaintenanceTaskEntity> regularWorkFinishList = regularWorkList.stream().filter(o -> MaintenanceConstant.TASK_STATUS_5 == o.getStatus()).collect(Collectors.toList()); |
|
|
|
|
if (CollectionUtil.isEmpty(regularWorkFinishList)) { |
|
|
|
|
regularWorkVO.setRegularWork(0); |
|
|
|
|
return regularWorkVO; |
|
|
|
|
} |
|
|
|
|
regularWorkVO.setRegularWork(regularWorkFinishList.size()); |
|
|
|
|
return regularWorkVO; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 获取安全检查日常维护任务 |
|
|
|
|
* @param startDate 开始时间 |
|
|
|
|
* @param endDate 结束时间 |
|
|
|
|
* @param dept 机构ID |
|
|
|
|
* @return SafeCheckStatisticVO对象 |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public SafeCheckStatisticVO getMaintenanceTaskCheck(String startDate, String endDate, Long dept) { |
|
|
|
|
//获取已完成任务
|
|
|
|
|
List<OperMaintenanceTaskEntity> taskEntityList = this.list(Wrappers.<OperMaintenanceTaskEntity>lambdaQuery() |
|
|
|
|
.eq(OperMaintenanceTaskEntity::getStatus,MaintenanceConstant.TASK_STATUS_5) |
|
|
|
|
.eq(OperMaintenanceTaskEntity::getCreateDept,dept) |
|
|
|
|
.ge(OperMaintenanceTaskEntity::getDisposeTime,startDate) |
|
|
|
|
.le(OperMaintenanceTaskEntity::getDisposeTime,endDate) |
|
|
|
|
); |
|
|
|
|
SafeCheckStatisticVO vo = new SafeCheckStatisticVO(); |
|
|
|
|
vo.setProjectType(Constants.SafeCheckProjectEnum.MAINTENANCE_TASK.getType()); |
|
|
|
|
vo.setProjectTypeName(Constants.SafeCheckProjectEnum.MAINTENANCE_TASK.getName()); |
|
|
|
|
vo.setTotal(taskEntityList.size()); |
|
|
|
|
return vo; |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* 获取安全检查日常维护任务 |
|
|
|
|
* |
|
|
|
|
* @param startDate 开始时间 |
|
|
|
|
* @param endDate 结束时间 |
|
|
|
|
* @param dept 机构ID |
|
|
|
|
* @return SafeCheckStatisticVO对象 |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public SafeCheckStatisticVO getMaintenanceTaskCheck(String startDate, String endDate, Long dept) { |
|
|
|
|
//获取已完成任务
|
|
|
|
|
List<OperMaintenanceTaskEntity> taskEntityList = this.list(Wrappers.<OperMaintenanceTaskEntity>lambdaQuery() |
|
|
|
|
.eq(OperMaintenanceTaskEntity::getStatus, MaintenanceConstant.TASK_STATUS_5) |
|
|
|
|
.eq(OperMaintenanceTaskEntity::getCreateDept, dept) |
|
|
|
|
.ge(OperMaintenanceTaskEntity::getDisposeTime, startDate) |
|
|
|
|
.le(OperMaintenanceTaskEntity::getDisposeTime, endDate) |
|
|
|
|
); |
|
|
|
|
SafeCheckStatisticVO vo = new SafeCheckStatisticVO(); |
|
|
|
|
vo.setProjectType(Constants.SafeCheckProjectEnum.MAINTENANCE_TASK.getType()); |
|
|
|
|
vo.setProjectTypeName(Constants.SafeCheckProjectEnum.MAINTENANCE_TASK.getName()); |
|
|
|
|
vo.setTotal(taskEntityList.size()); |
|
|
|
|
return vo; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 根据区域和月份分页查询日志维护列表 |
|
|
|
|
* |
|
|
|
|
* @param pageParam |
|
|
|
|
* @param areaMonthlyVo |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public IPage<MaintenanceTaskVo> queryLogMaintenancePageList(Page<OperMaintenanceTaskEntity> pageParam, MaintenanceTaskWithAreaVo areaMonthlyVo) { |
|
|
|
|
//1.根据区域查询
|
|
|
|
|
QueryWrapper<OperMaintenanceTaskEntity> queryWrapper = new QueryWrapper<>(); |
|
|
|
|
//维护内容
|
|
|
|
|
queryWrapper.lambda().like(StringUtils.isNotBlank(areaMonthlyVo.getContent()), |
|
|
|
|
OperMaintenanceTaskEntity::getContent, areaMonthlyVo.getContent()); |
|
|
|
|
//执行状态
|
|
|
|
|
queryWrapper.lambda().eq(areaMonthlyVo.getStatus() != null, OperMaintenanceTaskEntity::getStatus, |
|
|
|
|
areaMonthlyVo.getStatus()); |
|
|
|
|
//项目名称
|
|
|
|
|
queryWrapper.lambda().like(areaMonthlyVo.getTitle() != null, OperMaintenanceTaskEntity::getTitle, |
|
|
|
|
areaMonthlyVo.getTitle()); |
|
|
|
|
//任务类型
|
|
|
|
|
queryWrapper.lambda().eq(areaMonthlyVo.getTaskType() != null, OperMaintenanceTaskEntity::getTaskType, |
|
|
|
|
areaMonthlyVo.getTaskType()); |
|
|
|
|
|
|
|
|
|
//区域编号必传
|
|
|
|
|
queryWrapper.eq("CREATE_DEPT", areaMonthlyVo.getAreaId()); |
|
|
|
|
queryWrapper.eq(areaMonthlyVo.getYearMonth() != null, "date_format(create_time,'%Y-%m')", areaMonthlyVo.getYearMonth()); |
|
|
|
|
Page<OperMaintenanceTaskEntity> operMaintenanceTaskEntityPage = baseMapper.selectPage(pageParam, queryWrapper); |
|
|
|
|
//数据转换
|
|
|
|
|
if (CollectionUtil.isNotEmpty(operMaintenanceTaskEntityPage.getRecords())) { |
|
|
|
|
List<MaintenanceTaskVo> maintenanceTaskVos = operMaintenanceTaskEntityPage.getRecords().stream().map(operMaintenanceTaskEntity -> { |
|
|
|
|
MaintenanceTaskVo vo = new MaintenanceTaskVo(); |
|
|
|
|
BeanUtils.copyProperties(operMaintenanceTaskEntity, vo); |
|
|
|
|
vo.setTypeCodeValue(DictCache.getValue(DictConstant.MAINTENANCE_TYPE_CODE, vo.getTypeCode())); |
|
|
|
|
vo.setStatusValue(DictCache.getValue(DictConstant.MAINTENANCE_TASK_STATUS, vo.getStatus())); |
|
|
|
|
String disposerName = Optional.ofNullable(operMaintenanceTaskEntity.getDisposer()).map(s -> { |
|
|
|
|
List<String> disposerList = Arrays.stream(s.split(",")).collect(Collectors.toList()); |
|
|
|
|
return disposerList.stream().map(d -> { |
|
|
|
|
User user = UserCache.getUser(Long.parseLong(d)); |
|
|
|
|
return Optional.ofNullable(user).map(User::getName).orElse(""); |
|
|
|
|
}).collect(Collectors.joining(",")); |
|
|
|
|
}).orElse(""); |
|
|
|
|
vo.setDisposerName(disposerName); |
|
|
|
|
return vo; |
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
IPage<MaintenanceTaskVo> taskVos = new Page<>(); |
|
|
|
|
taskVos.setRecords(maintenanceTaskVos); |
|
|
|
|
taskVos.setTotal(operMaintenanceTaskEntityPage.getTotal()); |
|
|
|
|
taskVos.setPages(operMaintenanceTaskEntityPage.getPages()); |
|
|
|
|
taskVos.setSize(operMaintenanceTaskEntityPage.getSize()); |
|
|
|
|
return taskVos; |
|
|
|
|
} |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|