|
|
@@ -1,10 +1,12 @@
|
|
|
package com.xunmei.core.safetyCheck.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
+import cn.hutool.core.date.DateField;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.xunmei.common.core.constant.SecurityConstants;
|
|
|
@@ -22,6 +24,7 @@ import com.xunmei.core.question.service.IQuestionService;
|
|
|
import com.xunmei.core.safetyCheck.domain.*;
|
|
|
import com.xunmei.core.safetyCheck.dto.register.AppPageDto;
|
|
|
import com.xunmei.core.safetyCheck.dto.register.GrantDto;
|
|
|
+import com.xunmei.core.safetyCheck.enums.SafetyTaskSourceType;
|
|
|
import com.xunmei.core.safetyCheck.mapper.*;
|
|
|
import com.xunmei.core.safetyCheck.service.ICoreSafetyTaskDataNfcService;
|
|
|
import com.xunmei.core.safetyCheck.service.ICoreSafetyTaskDataRemarkimgService;
|
|
|
@@ -37,13 +40,11 @@ import com.xunmei.system.api.RemoteUserService;
|
|
|
import com.xunmei.system.api.domain.SysOrg;
|
|
|
import com.xunmei.system.api.model.LoginUser;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.function.Predicate;
|
|
|
import java.util.stream.Collectors;
|
|
|
@@ -118,6 +119,7 @@ public class SafetyCheckRegisterSericeImpl extends ServiceImpl<CoreSafetyTaskMap
|
|
|
page.getRecords().forEach(vo -> {
|
|
|
List<CoreSafetyTask> v = list.stream()
|
|
|
.filter(i -> ObjectUtil.equal(i.getPlanId(), vo.getPlanId()) && ObjectUtil.equal(vo.getCount(), i.getCount())
|
|
|
+ && ObjectUtil.equal(vo.getTaskName(),i.getTitle())
|
|
|
&& ObjectUtil.equal(i.getPlanStartTime(), vo.getPlanStartTime()) && ObjectUtil.equal(i.getPlanEndTime(), vo.getPlanEndTime()))
|
|
|
.collect(Collectors.toList());
|
|
|
List<Long> roleIds = planToRoles.stream().filter(p -> ObjectUtil.equal(p.getPlanId(), vo.getPlanId()))
|
|
|
@@ -205,40 +207,46 @@ public class SafetyCheckRegisterSericeImpl extends ServiceImpl<CoreSafetyTaskMap
|
|
|
return vo;
|
|
|
}
|
|
|
|
|
|
- private TaskRegisterVo<AppTaskRegisterPointVo> getPointVos(Long id) {
|
|
|
- CoreSafetyTask task = coreSafetyTaskMapper.selectById(id);
|
|
|
+ private TaskRegisterVo<AppTaskRegisterPointVo> getPointVos(Long taskId) {
|
|
|
+ CoreSafetyTask task = coreSafetyTaskMapper.selectById(taskId);
|
|
|
if (ObjectUtil.isNull(task)) {
|
|
|
throw new ServiceException("任务不存在");
|
|
|
}
|
|
|
|
|
|
- CoreSafecheckPlan plan = coreSafecheckPlanMapper.selectById(task.getPlanId());
|
|
|
- if (ObjectUtil.isNull(plan)) {
|
|
|
- throw new ServiceException("计划不存在");
|
|
|
+ CoreSafecheckPlan plan = null;
|
|
|
+ if (ObjectUtil.isNotNull(task.getPlanId())) {
|
|
|
+ plan = coreSafecheckPlanMapper.selectById(task.getPlanId());
|
|
|
}
|
|
|
|
|
|
- List<Long> roleIds = coreSafecheckPlanToRoleMapper.selectList(new LambdaQueryWrapper<CoreSafecheckPlanToRole>()
|
|
|
- .eq(CoreSafecheckPlanToRole::getPlanId, plan.getId())
|
|
|
- .select(CoreSafecheckPlanToRole::getRoleId))
|
|
|
- .stream()
|
|
|
- .map(CoreSafecheckPlanToRole::getRoleId)
|
|
|
- .collect(Collectors.toList());
|
|
|
- RoleConditionEto eto = new RoleConditionEto();
|
|
|
- eto.setIds(roleIds);
|
|
|
- List<IdNameVo> roleNames = remoteRoleService.getNames(eto);
|
|
|
+ /**
|
|
|
+ * 已经完成任务的信息应该从任务信息中获取
|
|
|
+ * 其它状态的任务消息从计划和任务中联合获取
|
|
|
+ */
|
|
|
+ List<IdNameVo> roleNames = getTaskRoles(plan, task);
|
|
|
// 找出检查内容
|
|
|
- List<AppTaskRegisterPointVo> points = baseMapper.selectPoint(plan.getId(), id);
|
|
|
+ List<AppTaskRegisterPointVo> points = new ArrayList<>();
|
|
|
+ List<TaskRegisterNfcVo> nfcs = new ArrayList<>();
|
|
|
+ if (ObjectUtil.equal(task.getStatus(), SafetyCheckTaskStatus.Completed.getValue()) || ObjectUtils.isNull(plan)) {
|
|
|
+ points = baseMapper.selectPoint(null, taskId);
|
|
|
+ nfcs = baseMapper.selectNfcByTask(taskId);
|
|
|
+ } else {
|
|
|
+ points = baseMapper.selectPoint(plan.getId(), taskId);
|
|
|
+ nfcs = baseMapper.selectNfc(plan.getId(), taskId, task.getOrgId());
|
|
|
+ }
|
|
|
+
|
|
|
Map<Long, List<CoreSafetyTaskDataRemarkimg>> taskImgs = new HashMap<>();
|
|
|
- if (ObjectUtil.notEqual(task.getStatus(), SafetyCheckTaskStatus.Waiting.getValue())) {
|
|
|
+ if (ObjectUtil.equal(task.getStatus(), SafetyCheckTaskStatus.UnderWay.getValue()) ||
|
|
|
+ (ObjectUtil.equal(task.getStatus(), SafetyCheckTaskStatus.Completed.getValue()))) {
|
|
|
//已保存未提交的才可能有问题图片
|
|
|
LambdaQueryWrapper<CoreSafetyTaskDataRemarkimg> wrapper = new LambdaQueryWrapper<>();
|
|
|
- wrapper.eq(CoreSafetyTaskDataRemarkimg::getTaskId, id);
|
|
|
+ wrapper.eq(CoreSafetyTaskDataRemarkimg::getTaskId, taskId);
|
|
|
List<CoreSafetyTaskDataRemarkimg> imgs = iCoreSafetyTaskDataRemarkimgService.list(wrapper);
|
|
|
taskImgs = imgs.stream().collect(Collectors.groupingBy(CoreSafetyTaskDataRemarkimg::getTaskDataId));
|
|
|
}
|
|
|
|
|
|
- List<TaskRegisterNfcVo> nfcs = baseMapper.selectNfc(plan.getId(), id, task.getOrgId());
|
|
|
- TaskRegisterVo<AppTaskRegisterPointVo> vo = TaskRegisterVo.of(task, plan.getCheckOrgType().toString(), roleNames);
|
|
|
- vo.setPlanType(plan.getCheckType().intValue());
|
|
|
+
|
|
|
+ TaskRegisterVo<AppTaskRegisterPointVo> vo = TaskRegisterVo.of(task, plan != null ? plan.getCheckOrgType().toString() : "", roleNames);
|
|
|
+// vo.setPlanType(plan.getCheckType().intValue());
|
|
|
Set<Long> usedNfcId = new HashSet<>();
|
|
|
for (AppTaskRegisterPointVo point : points) {
|
|
|
List<CoreSafetyTaskDataRemarkimg> dataImgs = taskImgs.get(point.getPointDataId());
|
|
|
@@ -261,6 +269,29 @@ public class SafetyCheckRegisterSericeImpl extends ServiceImpl<CoreSafetyTaskMap
|
|
|
return vo;
|
|
|
}
|
|
|
|
|
|
+ private List<IdNameVo> getTaskRoles(CoreSafecheckPlan plan, CoreSafetyTask task) {
|
|
|
+ List<Long> roleIds = new ArrayList<>();
|
|
|
+ if (ObjectUtil.equal(task.getSourceType(), SafetyTaskSourceType.TempTask.getCode().longValue())) {
|
|
|
+ roleIds = Arrays.asList(task.getRoleId());
|
|
|
+ } else {
|
|
|
+ if (ObjectUtil.isNull(plan)) {
|
|
|
+ throw new ServiceException("计划不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ roleIds = coreSafecheckPlanToRoleMapper.selectList(new LambdaQueryWrapper<CoreSafecheckPlanToRole>()
|
|
|
+ .eq(CoreSafecheckPlanToRole::getPlanId, plan.getId())
|
|
|
+ .select(CoreSafecheckPlanToRole::getRoleId))
|
|
|
+ .stream()
|
|
|
+ .map(CoreSafecheckPlanToRole::getRoleId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ RoleConditionEto eto = new RoleConditionEto();
|
|
|
+ eto.setIds(roleIds);
|
|
|
+ List<IdNameVo> roleNames = remoteRoleService.getNames(eto);
|
|
|
+
|
|
|
+ return roleNames;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 登记
|
|
|
*
|
|
|
@@ -326,8 +357,8 @@ public class SafetyCheckRegisterSericeImpl extends ServiceImpl<CoreSafetyTaskMap
|
|
|
if (ObjectUtil.isNull(data.getId())) {
|
|
|
data.setId(IDHelper.id());
|
|
|
}
|
|
|
+ data.setPlanEndTime(DateUtil.endOfDay(data.getPlanStartTime()).setField(DateField.MILLISECOND, 0));
|
|
|
data.setPlanStartTime(DateUtil.beginOfDay(data.getPlanStartTime()));
|
|
|
- data.setPlanEndTime(DateUtil.endOfDay(data.getPlanStartTime()));
|
|
|
return webSubmit(data, true);
|
|
|
}
|
|
|
|
|
|
@@ -505,7 +536,8 @@ public class SafetyCheckRegisterSericeImpl extends ServiceImpl<CoreSafetyTaskMap
|
|
|
SysOrg checkOrg = remoteOrgService.selectOrgById(data.getCheckOrgId(), SecurityConstants.INNER);
|
|
|
|
|
|
CoreSafetyTask task = new CoreSafetyTask();
|
|
|
- task.setId(task.getId());
|
|
|
+ task.setId(data.getId());
|
|
|
+ task.setPlanId(-1L);
|
|
|
task.setTitle(data.getTaskName());
|
|
|
task.setCount(1);
|
|
|
task.setExceptionCount(exceptionCount.longValue());
|