|
|
|
|
@ -59,6 +59,8 @@ import org.springblade.desk.order.pojo.entity.MoldDemand; |
|
|
|
|
import org.springblade.desk.order.pojo.entity.YieldOrder; |
|
|
|
|
import org.springblade.desk.order.service.IMoldDemandService; |
|
|
|
|
import org.springblade.desk.order.service.IYieldOrderService; |
|
|
|
|
import org.springblade.desk.produce.pojo.entity.WorkPlan; |
|
|
|
|
import org.springblade.desk.produce.service.IPdaSaveService; |
|
|
|
|
import org.springblade.desk.produce.service.IWorkOrderService; |
|
|
|
|
import org.springblade.desk.produce.service.IWorkPlanService; |
|
|
|
|
import org.springblade.desk.quality.pojo.dto.PpmReportDetailDTO; |
|
|
|
|
@ -80,6 +82,7 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
|
import java.sql.Connection; |
|
|
|
|
import java.sql.SQLException; |
|
|
|
|
import java.time.LocalDate; |
|
|
|
|
@ -191,6 +194,10 @@ public class DsTaskingServiceImpl extends BaseServiceImpl<DsTaskingMapper, DsTas |
|
|
|
|
@Autowired |
|
|
|
|
IDsDispatchPointerService dsDispatchPointerService; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
@Lazy |
|
|
|
|
IPdaSaveService pdaSaveService; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public IPage<DsTaskingVO> selectAssignList(IPage<DsTaskingVO> page, DsTaskingVO dsTasking) { |
|
|
|
|
List<DsTaskingVO> dsTaskingVOS = baseMapper.selectDsTaskingPage(page, dsTasking); |
|
|
|
|
@ -1040,69 +1047,149 @@ public class DsTaskingServiceImpl extends BaseServiceImpl<DsTaskingMapper, DsTas |
|
|
|
|
// 构建工序树
|
|
|
|
|
List<ProcessTreeVO> processTree = reworkBuildProcessTree(reworkProcessEntityList, processProjectEntityList, |
|
|
|
|
processMeasuringToolEntityList, processMoldToolEntityList); |
|
|
|
|
|
|
|
|
|
craftTree.setProcessList(processTree); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
result.getCraftList().add(craftTree); |
|
|
|
|
|
|
|
|
|
}else{ |
|
|
|
|
// 没有返工工艺信息的情况
|
|
|
|
|
// 创建新的工艺实体并设置返工订单号
|
|
|
|
|
craft = new DsCraftEntity(); |
|
|
|
|
craft.setReworkOrder(dsTaskingEntity.getReworkOrder()); |
|
|
|
|
craft.setPartId(partEntity.getId()); |
|
|
|
|
craft.setPartCode(partEntity.getPartCode()); |
|
|
|
|
craft.setPartVersions(dsTaskingEntity.getBatchNo()); |
|
|
|
|
// 创建工艺节点并设置craftInfo
|
|
|
|
|
craftTree.setCraftInfo(JSONObject.from(craft)); |
|
|
|
|
craftTree.setProcessList(new ArrayList<>()); |
|
|
|
|
result.getCraftList().add(craftTree); |
|
|
|
|
|
|
|
|
|
// 查询零件工艺信息
|
|
|
|
|
List<DsCraftVO> dsCraftVOList = craftService.selectDsCraftByPartId(partEntity.getId(), "2"); |
|
|
|
|
if(CollectionUtils.isEmpty(dsCraftVOList)){ |
|
|
|
|
throw new ServiceException("零件工艺信息有误 请检查该零件是否有工艺信息"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// // 查询零件工艺信息
|
|
|
|
|
// List<DsCraftVO> dsCraftVOList = craftService.selectDsCraftByPartId(partEntity.getId(), "2");
|
|
|
|
|
// if(CollectionUtils.isEmpty(dsCraftVOList)){
|
|
|
|
|
// throw new ServiceException("零件工艺信息有误 请检查该零件是否有工艺信息");
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// if (!CollectionUtils.isEmpty(dsCraftVOList)) {
|
|
|
|
|
// for (DsCraftVO craftVO : dsCraftVOList) {
|
|
|
|
|
// // 每次循环创建新的craftTree对象
|
|
|
|
|
// CraftTreeVO craftTree1 = new CraftTreeVO();
|
|
|
|
|
//
|
|
|
|
|
// craftVO.setReworkOrder(dsTaskingEntity.getReworkOrder());
|
|
|
|
|
// craftVO.setPartId(partEntity.getId());
|
|
|
|
|
// craftVO.setPartVersions(dsTaskingEntity.getVersion());
|
|
|
|
|
//
|
|
|
|
|
// craftTree1.setCraftInfo(JSONObject.from(craftVO));
|
|
|
|
|
//
|
|
|
|
|
// // 查询工序信息
|
|
|
|
|
// List<DsProcessEntity> processEntities = processService.selectDsProcessByCraftId(craftVO.getId());
|
|
|
|
|
//
|
|
|
|
|
// if (!CollectionUtils.isEmpty(processEntities)) {
|
|
|
|
|
// List<Long> processIds = processEntities.stream()
|
|
|
|
|
// .map(DsProcessEntity::getId)
|
|
|
|
|
// .collect(Collectors.toList());
|
|
|
|
|
//
|
|
|
|
|
// // 批量查询关联数据
|
|
|
|
|
// List<DsProcessProjectEntity> processProjectEntityList = processProjectService.selectDsProcessProjectByProcessIds(processIds);
|
|
|
|
|
// List<DsProcessMeasuringToolEntity> processMeasuringToolEntityList = processMeasuringToolService.selectDsProcessMeasuringToolByProcessIds(processIds);
|
|
|
|
|
// List<DsProcessMoldToolEntity> processMoldToolEntityList = processMoldToolService.selectDsProcessMoldToolByProcessIds(processIds);
|
|
|
|
|
//
|
|
|
|
|
// // 构建工序树
|
|
|
|
|
// List<ProcessTreeVO> processTree = buildProcessTree(processEntities, processProjectEntityList,
|
|
|
|
|
// processMeasuringToolEntityList, processMoldToolEntityList);
|
|
|
|
|
// craftTree1.setProcessList(processTree);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// result.getCraftList().add(craftTree1);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
if (!CollectionUtils.isEmpty(dsCraftVOList)) { |
|
|
|
|
for (DsCraftVO craftVO : dsCraftVOList) { |
|
|
|
|
// 查询工序信息
|
|
|
|
|
List<DsProcessEntity> processEntities = processService.selectDsProcessByCraftId(craftVO.getId()); |
|
|
|
|
// 每次循环创建新的craftTree对象
|
|
|
|
|
CraftTreeVO craftTree1 = new CraftTreeVO(); |
|
|
|
|
craftVO.setReworkOrder(dsTaskingEntity.getReworkOrder()); |
|
|
|
|
craftVO.setPartId(partEntity.getId()); |
|
|
|
|
craftVO.setPartVersions(dsTaskingEntity.getBatchNo()); |
|
|
|
|
craftVO.setId(null); |
|
|
|
|
craftTree1.setCraftInfo(JSONObject.from(craftVO)); |
|
|
|
|
|
|
|
|
|
if (!CollectionUtils.isEmpty(processEntities)) { |
|
|
|
|
// 关键:将正常工序列表转换为返工工序列表
|
|
|
|
|
List<PrReworkProcessEntity> reworkProcessEntityList = convertToReworkProcessList(processEntities, dsTaskingEntity); |
|
|
|
|
|
|
|
|
|
List<Long> processIds = processEntities.stream() |
|
|
|
|
.map(DsProcessEntity::getId) |
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
// 批量查询关联数据
|
|
|
|
|
List<DsProcessProjectEntity> processProjectEntityList = processProjectService.selectDsProcessProjectByProcessIds(processIds); |
|
|
|
|
List<DsProcessMeasuringToolEntity> processMeasuringToolEntityList = processMeasuringToolService.selectDsProcessMeasuringToolByProcessIds(processIds); |
|
|
|
|
List<DsProcessMoldToolEntity> processMoldToolEntityList = processMoldToolService.selectDsProcessMoldToolByProcessIds(processIds); |
|
|
|
|
|
|
|
|
|
// 构建工序树
|
|
|
|
|
List<ProcessTreeVO> processTree = reworkBuildProcessTree(reworkProcessEntityList, processProjectEntityList, |
|
|
|
|
processMeasuringToolEntityList, processMoldToolEntityList); |
|
|
|
|
|
|
|
|
|
clearAllIds(processTree); |
|
|
|
|
craftTree1.setProcessList(processTree); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
result.getCraftList().add(craftTree1); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 清空工序树中所有ID |
|
|
|
|
*/ |
|
|
|
|
private void clearAllIds(List<ProcessTreeVO> processTree) { |
|
|
|
|
if (CollectionUtils.isEmpty(processTree)) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for (ProcessTreeVO node : processTree) { |
|
|
|
|
// 清空工序信息中的id
|
|
|
|
|
if (node.getProcessInfo() instanceof JSONObject) { |
|
|
|
|
((JSONObject) node.getProcessInfo()).remove("id"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 清空工装模具列表中的id
|
|
|
|
|
if (!CollectionUtils.isEmpty(node.getMoldToolList())) { |
|
|
|
|
for (Object obj : node.getMoldToolList()) { |
|
|
|
|
if (obj instanceof JSONObject) { |
|
|
|
|
((JSONObject) obj).remove("id"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 清空尺寸量具列表中的id
|
|
|
|
|
if (!CollectionUtils.isEmpty(node.getMeasuringToolList())) { |
|
|
|
|
for (Object obj : node.getMeasuringToolList()) { |
|
|
|
|
if (obj instanceof JSONObject) { |
|
|
|
|
((JSONObject) obj).remove("id"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 清空工序项目列表中的id
|
|
|
|
|
if (!CollectionUtils.isEmpty(node.getProjectList())) { |
|
|
|
|
for (Object obj : node.getProjectList()) { |
|
|
|
|
if (obj instanceof JSONObject) { |
|
|
|
|
((JSONObject) obj).remove("id"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 将正常工序列表转换为返工工序列表 |
|
|
|
|
*/ |
|
|
|
|
private List<PrReworkProcessEntity> convertToReworkProcessList(List<DsProcessEntity> processEntities, DsTaskingEntity dsTaskingEntity) { |
|
|
|
|
List<WorkPlan> originalOrderProcess = pdaSaveService.getOriginalOrderProcess(dsTaskingEntity.getPartCode(), dsTaskingEntity.getBatchNo()); |
|
|
|
|
// 转换为Map便于快速查找
|
|
|
|
|
Map<Long, WorkPlan> workPlanMap = new HashMap<>(); |
|
|
|
|
if (!CollectionUtils.isEmpty(originalOrderProcess)) { |
|
|
|
|
for (WorkPlan workPlan : originalOrderProcess) { |
|
|
|
|
if (workPlan != null && workPlan.getPpsId() != null) { |
|
|
|
|
workPlanMap.put(workPlan.getPpsId(), workPlan); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
List<PrReworkProcessEntity> reworkList = new ArrayList<>(); |
|
|
|
|
for (DsProcessEntity process : processEntities) { |
|
|
|
|
PrReworkProcessEntity reworkProcess = new PrReworkProcessEntity(); |
|
|
|
|
// 设置返工特有的属性
|
|
|
|
|
reworkProcess.setId(process.getId()); |
|
|
|
|
reworkProcess.setReworkCode(dsTaskingEntity.getReworkOrder()); |
|
|
|
|
reworkProcess.setPartCode(dsTaskingEntity.getPartCode()); |
|
|
|
|
reworkProcess.setBatchNo(dsTaskingEntity.getBatchNo()); |
|
|
|
|
reworkProcess.setProcessNo(process.getProcessNo()); |
|
|
|
|
reworkProcess.setPpsName(process.getProcessName()); |
|
|
|
|
reworkProcess.setPpsId(process.getPpsId()); |
|
|
|
|
reworkProcess.setCaId(process.getCaId()); |
|
|
|
|
reworkProcess.setMakeMemo(process.getProDes()); |
|
|
|
|
reworkProcess.setHourQuota(BigDecimal.valueOf(process.getProHours())); |
|
|
|
|
reworkProcess.setCruxProcess(process.getIsMain()); |
|
|
|
|
reworkProcess.setTrialNo(process.getTrialNo()); |
|
|
|
|
reworkProcess.setCraftName(process.getCraftName()); |
|
|
|
|
|
|
|
|
|
// 匹配ppsId并赋值(不为空才赋值)
|
|
|
|
|
if (process.getPpsId() != null && workPlanMap.containsKey(process.getPpsId())) { |
|
|
|
|
WorkPlan workPlan = workPlanMap.get(process.getPpsId()); |
|
|
|
|
Optional.ofNullable(workPlan.getOcId()).ifPresent(reworkProcess::setOcId); |
|
|
|
|
Optional.ofNullable(workPlan.getMakeTeam()).ifPresent(reworkProcess::setMakeTeam); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
reworkList.add(reworkProcess); |
|
|
|
|
} |
|
|
|
|
return reworkList; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public boolean authorizedAccomplish(DsCraftEntity craft, List<DsProcessVO> processList, List<Long> processDeleteIds, List<Long> projectIds) { |
|
|
|
|
|
|
|
|
|
|