|
@@ -3,20 +3,24 @@ package com.rongwei.bscommon.sys.service.impl;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.rongwei.bscommon.sys.service.*;
|
|
|
import com.rongwei.bscommon.sys.utils.BusinessFunUtils;
|
|
|
-import com.rongwei.bsentity.domain.ZhcxItpProjectNodeStateDo;
|
|
|
+import com.rongwei.bscommon.sys.utils.ZhcxCommon;
|
|
|
+import com.rongwei.bsentity.domain.*;
|
|
|
import com.rongwei.bscommon.sys.dao.ZhcxItpProjectNodeStateDao;
|
|
|
-import com.rongwei.bscommon.sys.service.ZhcxItpProjectNodeStateService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.rongwei.bsentity.domain.ZhcxOutsideInspectionItpDo;
|
|
|
+import com.rongwei.bsentity.dto.OperDto;
|
|
|
import com.rongwei.bsentity.dto.ZhcxItpProjectNodeStateResultDto;
|
|
|
+import com.rongwei.bsentity.dto.project.node.ProjectNodeStateBo;
|
|
|
+import com.rongwei.bsentity.dto.project.node.RelactionNodeStateBo;
|
|
|
+import com.rongwei.bsentity.dto.project.node.RelactionNodeStateInspectionBo;
|
|
|
+import com.rongwei.bsentity.dto.project.node.RelationInspectionRequest;
|
|
|
+import com.rongwei.rwadmincommon.system.vo.SysUserVo;
|
|
|
import com.rongwei.rwcommon.utils.SecurityUtil;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Collections;
|
|
|
-import java.util.List;
|
|
|
-import java.util.stream.Collectors;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -29,6 +33,27 @@ import java.util.stream.Collectors;
|
|
|
@Service
|
|
|
public class ZhcxItpProjectNodeStateServiceImpl extends ServiceImpl<ZhcxItpProjectNodeStateDao, ZhcxItpProjectNodeStateDo> implements ZhcxItpProjectNodeStateService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ZhcxItpProjectNodeStateOutsideService nodeStateOutsideService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ZhcxItpProjectNodeStateInsideService nodeStateInsideService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ZhcxOutsideInspectionItpService outsideInspectionItpService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ZhcxOutsideInspectionItpSupervisionDispatchService outsideInspectionItpSupervisionDispatchService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ZhcxInsideInspectionService insideInspectionService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ZhcxInsideInspectionDispatchService insideInspectionDispatchService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ZhcxCommon zhcxCommon;
|
|
|
+
|
|
|
/**
|
|
|
* 获取项目各机号报验点状态
|
|
|
*
|
|
@@ -104,6 +129,311 @@ public class ZhcxItpProjectNodeStateServiceImpl extends ServiceImpl<ZhcxItpProje
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 保存报验点状态
|
|
|
+ *
|
|
|
+ * @param nodeStateBo
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void saveNode(ProjectNodeStateBo nodeStateBo) {
|
|
|
+ //添加项目各机号报验点状态
|
|
|
+ if(ObjectUtil.isNotEmpty(nodeStateBo.getInsertList())) {
|
|
|
+ saveBatch(nodeStateBo.getInsertList());
|
|
|
+ }
|
|
|
+ if(ObjectUtil.isNotEmpty(nodeStateBo.getUpdateList())) {
|
|
|
+ updateBatchById(nodeStateBo.getUpdateList());
|
|
|
+ }
|
|
|
+ if(ObjectUtil.isNotEmpty(nodeStateBo.getOutsideStateList())) {
|
|
|
+ nodeStateOutsideService.saveBatch(nodeStateBo.getOutsideStateList());
|
|
|
+ }
|
|
|
+
|
|
|
+ if(ObjectUtil.isNotEmpty(nodeStateBo.getInsideStateList())) {
|
|
|
+ nodeStateInsideService.saveBatch(nodeStateBo.getInsideStateList());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 关联报验单
|
|
|
+ *
|
|
|
+ * @param req
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void relationInspection(RelationInspectionRequest req) {
|
|
|
+ List<RelactionNodeStateBo> stateBoList = null;
|
|
|
+ if("outside".equals(req.getType())) {
|
|
|
+ stateBoList = assembleRelationByOutside(req);
|
|
|
+ } else if("inside".equals(req.getType())) {
|
|
|
+ stateBoList = assembleRelationByInside(req);
|
|
|
+ }
|
|
|
+
|
|
|
+ SysUserVo user = zhcxCommon.getCurrentUser();
|
|
|
+
|
|
|
+ OperDto oper = new OperDto();
|
|
|
+ oper.setOperTime(new Date());
|
|
|
+ oper.setOperUser(user);
|
|
|
+
|
|
|
+ //保存关联关系
|
|
|
+ relationInspection(stateBoList, oper);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 初始化
|
|
|
+ *
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void initRelationInspection() {
|
|
|
+ //外部报验单
|
|
|
+
|
|
|
+ //内部报验单
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存外部报验单
|
|
|
+ */
|
|
|
+ private void saveNodeStatusOutside() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 组装内部报验单参数
|
|
|
+ *
|
|
|
+ * @param req
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<RelactionNodeStateBo> assembleRelationByInside(RelationInspectionRequest req) {
|
|
|
+
|
|
|
+ //外部报验单
|
|
|
+ Collection<ZhcxInsideInspectionDo> insideList = insideInspectionService.listByIds(req.getSideIdList());
|
|
|
+
|
|
|
+ if(ObjectUtil.isEmpty(insideList)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+
|
|
|
+ List<RelactionNodeStateBo> result = new ArrayList<>();
|
|
|
+
|
|
|
+ List<String> machineNoList = new ArrayList<>();
|
|
|
+ machineNoList.addAll(splitMachineNo(req.getMachineNo()));
|
|
|
+
|
|
|
+ //外部报验单
|
|
|
+ for(ZhcxInsideInspectionDo inside : insideList) {
|
|
|
+ String machineNos = getMachinesNoByInside(inside);
|
|
|
+ machineNoList.addAll(splitMachineNo(machineNos));
|
|
|
+
|
|
|
+ machineNoList = new ArrayList<>(new HashSet<>(machineNoList));
|
|
|
+
|
|
|
+ ZhcxInsideInspectionDispatchDo dispatchDo = null;
|
|
|
+ if(!"40".equals(inside.getInspectionstatus())) {
|
|
|
+ LambdaQueryWrapper<ZhcxInsideInspectionDispatchDo> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.eq(ZhcxInsideInspectionDispatchDo::getDeleted, "0")
|
|
|
+ .eq(ZhcxInsideInspectionDispatchDo::getInsideid, inside.getId());
|
|
|
+ dispatchDo = insideInspectionDispatchService.getOne(queryWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ //机号
|
|
|
+ for(String machineNo : machineNoList) {
|
|
|
+ RelactionNodeStateBo nodeStateBo = RelactionNodeStateBo.builder()
|
|
|
+ .machineNo(machineNo)
|
|
|
+ .projectId(inside.getProjectid())
|
|
|
+ .projectCode(inside.getProjectcode())
|
|
|
+ .projectName(inside.getProjectname())
|
|
|
+ .nodeId(req.getNodeId())
|
|
|
+ .inspectionCount(inside.getInspectioncount())
|
|
|
+ .complateTime(inside.getInspectioncomplatetime())
|
|
|
+ .type("inside")
|
|
|
+ .build();
|
|
|
+
|
|
|
+ if("40".equals(inside.getInspectionstatus())) {
|
|
|
+ nodeStateBo.setConclusion("40");
|
|
|
+ } else {
|
|
|
+ nodeStateBo.setConclusion(dispatchDo.getInspectionconclusion());
|
|
|
+ }
|
|
|
+
|
|
|
+ List<RelactionNodeStateInspectionBo> inspectionList = new ArrayList<>(1);
|
|
|
+ inspectionList.add(RelactionNodeStateInspectionBo.builder()
|
|
|
+ .inspectionCode(inside.getInspectioncode())
|
|
|
+ .inspectionId(inside.getId())
|
|
|
+ .launchType(inside.getLaunchtype())
|
|
|
+ .build());
|
|
|
+ nodeStateBo.setInspectionList(inspectionList);
|
|
|
+
|
|
|
+ result.add(nodeStateBo);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 组装外部报验单参数
|
|
|
+ *
|
|
|
+ * @param req
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<RelactionNodeStateBo> assembleRelationByOutside(RelationInspectionRequest req) {
|
|
|
+
|
|
|
+ //外部报验单
|
|
|
+ Collection<ZhcxOutsideInspectionItpDo> outsideList = outsideInspectionItpService.listByIds(req.getSideIdList());
|
|
|
+
|
|
|
+ if(ObjectUtil.isEmpty(outsideList)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+
|
|
|
+ List<RelactionNodeStateBo> result = new ArrayList<>();
|
|
|
+
|
|
|
+ List<String> machineNoList = new ArrayList<>();
|
|
|
+ machineNoList.addAll(splitMachineNo(req.getMachineNo()));
|
|
|
+
|
|
|
+ //外部报验单
|
|
|
+ for(ZhcxOutsideInspectionItpDo outside : outsideList) {
|
|
|
+ String machineNos = getMachinesNoByItp(outside);
|
|
|
+ machineNoList.addAll(splitMachineNo(machineNos));
|
|
|
+
|
|
|
+ ZhcxOutsideInspectionItpSupervisionDispatchDo dispatchDo = null;
|
|
|
+ if(!"40".equals(outside.getInspectionstatus())) {
|
|
|
+ LambdaQueryWrapper<ZhcxOutsideInspectionItpSupervisionDispatchDo> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.eq(ZhcxOutsideInspectionItpSupervisionDispatchDo::getDeleted, "0")
|
|
|
+ .eq(ZhcxOutsideInspectionItpSupervisionDispatchDo::getItpid, outside.getId());
|
|
|
+ dispatchDo = outsideInspectionItpSupervisionDispatchService.getOne(queryWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ //机号
|
|
|
+ for(String machineNo : machineNoList) {
|
|
|
+ RelactionNodeStateBo nodeStateBo = RelactionNodeStateBo.builder()
|
|
|
+ .machineNo(machineNo)
|
|
|
+ .projectId(outside.getProjectid())
|
|
|
+ .projectCode(outside.getProjectcode())
|
|
|
+ .projectName(outside.getProjectname())
|
|
|
+ .nodeId(req.getNodeId())
|
|
|
+ .inspectionCount(outside.getInspectioncount())
|
|
|
+ .complateTime(outside.getInspectioncomplatetime())
|
|
|
+ .type("outside")
|
|
|
+ .build();
|
|
|
+
|
|
|
+ if("40".equals(outside.getInspectionstatus())) {
|
|
|
+ nodeStateBo.setConclusion("40");
|
|
|
+ } else {
|
|
|
+ nodeStateBo.setConclusion(dispatchDo.getInspectionconclusion());
|
|
|
+ }
|
|
|
+
|
|
|
+ List<RelactionNodeStateInspectionBo> inspectionList = new ArrayList<>(1);
|
|
|
+ inspectionList.add(RelactionNodeStateInspectionBo.builder()
|
|
|
+ .inspectionCode(outside.getInspectioncode())
|
|
|
+ .inspectionId(outside.getId())
|
|
|
+ .launchType(outside.getLaunchtype())
|
|
|
+ .build());
|
|
|
+ nodeStateBo.setInspectionList(inspectionList);
|
|
|
+
|
|
|
+ result.add(nodeStateBo);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 关联报验单
|
|
|
+ *
|
|
|
+ * @param list
|
|
|
+ * @param oper
|
|
|
+ */
|
|
|
+ private void relationInspection(List<RelactionNodeStateBo> list, OperDto oper) {
|
|
|
+ if(ObjectUtil.isEmpty(list)) {
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+
|
|
|
+ ProjectNodeStateBo prjNodeState = ProjectNodeStateBo.builder()
|
|
|
+ .insertList(new ArrayList<>())
|
|
|
+ .updateList(new ArrayList<>())
|
|
|
+ .insideStateList(new ArrayList<>())
|
|
|
+ .outsideStateList(new ArrayList<>())
|
|
|
+ .build();
|
|
|
+ for(RelactionNodeStateBo state : list) {
|
|
|
+ LambdaQueryWrapper<ZhcxItpProjectNodeStateDo> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.eq(ZhcxItpProjectNodeStateDo::getPrjid, state.getProjectId())
|
|
|
+ .eq(ZhcxItpProjectNodeStateDo::getMathinecode, state.getMachineNo())
|
|
|
+ .eq(ZhcxItpProjectNodeStateDo::getNodeid, state.getNodeId());
|
|
|
+ List<ZhcxItpProjectNodeStateDo> stateList = list(queryWrapper);
|
|
|
+ ZhcxItpProjectNodeStateDo stateDo = BusinessFunUtils.getPrjNodeState(stateList);
|
|
|
+
|
|
|
+ ZhcxItpProjectNodeStateDo entity = new ZhcxItpProjectNodeStateDo();
|
|
|
+ //内部报验单
|
|
|
+ if("inside".equals(state.getType())) {
|
|
|
+ entity.setIntimes(state.getInspectionCount());
|
|
|
+ entity.setInstate(state.getConclusion());
|
|
|
+
|
|
|
+ if("10".equals(state.getConclusion()) || "30".equals(state.getConclusion())) {
|
|
|
+ entity.setIncompletetime(state.getComplateTime());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //外部
|
|
|
+ else {
|
|
|
+ entity.setOuttimes(state.getInspectionCount());
|
|
|
+ entity.setOutstate(state.getConclusion());
|
|
|
+
|
|
|
+ if("10".equals(state.getConclusion()) || "30".equals(state.getConclusion())) {
|
|
|
+ entity.setOutcompletetime(state.getComplateTime());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(ObjectUtil.isNull(stateDo)) {
|
|
|
+ entity.setId(SecurityUtil.getUUID());
|
|
|
+ entity.setMathinecode(state.getMachineNo());
|
|
|
+ entity.setPrjid(state.getProjectId());
|
|
|
+ entity.setNodeid(state.getNodeId());
|
|
|
+ entity.setDeleted("0");
|
|
|
+ prjNodeState.getInsertList().add(entity);
|
|
|
+ } else {
|
|
|
+ entity.setId(stateDo.getId());
|
|
|
+ prjNodeState.getUpdateList().add(entity);
|
|
|
+ }
|
|
|
+
|
|
|
+ if("inside".equals(state.getType())) {
|
|
|
+ //内部报验报验点明细
|
|
|
+ for(RelactionNodeStateInspectionBo nodeInspection : state.getInspectionList()) {
|
|
|
+ //同一个报验点,只能存一份
|
|
|
+ LambdaQueryWrapper<ZhcxItpProjectNodeStateInsideDo> delWrapper = Wrappers.lambdaQuery();
|
|
|
+ delWrapper.eq(ZhcxItpProjectNodeStateInsideDo::getInsideid, nodeInspection.getInspectionId())
|
|
|
+ .eq(ZhcxItpProjectNodeStateInsideDo::getStateid, entity.getId());
|
|
|
+ nodeStateInsideService.remove(delWrapper);
|
|
|
+
|
|
|
+ ZhcxItpProjectNodeStateInsideDo insideState = new ZhcxItpProjectNodeStateInsideDo();
|
|
|
+ insideState.setId(SecurityUtil.getUUID());
|
|
|
+ insideState.setInspectioncode(nodeInspection.getInspectionCode());
|
|
|
+ insideState.setLaunchtype(nodeInspection.getLaunchType());
|
|
|
+ insideState.setDeleted("0");
|
|
|
+ insideState.setStateid(entity.getId());
|
|
|
+ insideState.setInsideid(nodeInspection.getInspectionId());
|
|
|
+
|
|
|
+ prjNodeState.getInsideStateList().add(insideState);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //外部报验报验点明细
|
|
|
+ for(RelactionNodeStateInspectionBo nodeInspection : state.getInspectionList()) {
|
|
|
+ //同一个报验点,只能存一份
|
|
|
+ LambdaQueryWrapper<ZhcxItpProjectNodeStateOutsideDo> delWrapper = Wrappers.lambdaQuery();
|
|
|
+ delWrapper.eq(ZhcxItpProjectNodeStateOutsideDo::getOutsideid, nodeInspection.getInspectionId())
|
|
|
+ .eq(ZhcxItpProjectNodeStateOutsideDo::getStateid, entity.getId());
|
|
|
+ nodeStateOutsideService.remove(delWrapper);
|
|
|
+
|
|
|
+ ZhcxItpProjectNodeStateOutsideDo outsideState = new ZhcxItpProjectNodeStateOutsideDo();
|
|
|
+ outsideState.setId(SecurityUtil.getUUID());
|
|
|
+ outsideState.setInspectioncode(nodeInspection.getInspectionCode());
|
|
|
+ outsideState.setLaunchtype(nodeInspection.getLaunchType());
|
|
|
+ outsideState.setDeleted("0");
|
|
|
+ outsideState.setStateid(entity.getId());
|
|
|
+ outsideState.setOutsideid(nodeInspection.getInspectionId());
|
|
|
+
|
|
|
+ prjNodeState.getOutsideStateList().add(outsideState);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //持久化
|
|
|
+ saveNode(prjNodeState);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 选择机号
|
|
|
*
|
|
@@ -117,4 +447,32 @@ public class ZhcxItpProjectNodeStateServiceImpl extends ServiceImpl<ZhcxItpProje
|
|
|
|
|
|
return itpDo.getStructuremachineno();
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 选择机号
|
|
|
+ *
|
|
|
+ * @param itpDo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String getMachinesNoByInside(ZhcxInsideInspectionDo itpDo) {
|
|
|
+ if(ObjectUtil.isNotEmpty(itpDo.getMachineno())) {
|
|
|
+ return itpDo.getMachineno();
|
|
|
+ }
|
|
|
+
|
|
|
+ return itpDo.getStructuremachineno();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 拆分机号
|
|
|
+ *
|
|
|
+ * @param machineNo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<String> splitMachineNo(String machineNo) {
|
|
|
+ if(ObjectUtil.isEmpty(machineNo)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+
|
|
|
+ return Arrays.asList(machineNo.split(","));
|
|
|
+ }
|
|
|
}
|