|
|
|
@ -1,9 +1,11 @@ |
|
|
|
package org.springblade.desk.dashboard.service.impl; |
|
|
|
package org.springblade.desk.dashboard.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springblade.core.log.exception.ServiceException; |
|
|
|
import org.springblade.core.log.exception.ServiceException; |
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
import org.springblade.core.secure.utils.AuthUtil; |
|
|
|
import org.springblade.core.secure.utils.AuthUtil; |
|
|
|
@ -13,6 +15,7 @@ import org.springblade.desk.dashboard.constant.TaskingConstant; |
|
|
|
import org.springblade.desk.dashboard.excel.DsPartExcel; |
|
|
|
import org.springblade.desk.dashboard.excel.DsPartExcel; |
|
|
|
import org.springblade.desk.dashboard.mapper.DsPartMapper; |
|
|
|
import org.springblade.desk.dashboard.mapper.DsPartMapper; |
|
|
|
import org.springblade.desk.dashboard.pojo.entity.*; |
|
|
|
import org.springblade.desk.dashboard.pojo.entity.*; |
|
|
|
|
|
|
|
import org.springblade.desk.dashboard.pojo.enums.PartCraftStatusEnum; |
|
|
|
import org.springblade.desk.dashboard.pojo.vo.*; |
|
|
|
import org.springblade.desk.dashboard.pojo.vo.*; |
|
|
|
import org.springblade.desk.dashboard.service.*; |
|
|
|
import org.springblade.desk.dashboard.service.*; |
|
|
|
import org.springblade.desk.dashboard.utils.DateUtils; |
|
|
|
import org.springblade.desk.dashboard.utils.DateUtils; |
|
|
|
@ -40,6 +43,7 @@ import java.util.stream.Collectors; |
|
|
|
* @author BladeX |
|
|
|
* @author BladeX |
|
|
|
* @since 2025-11-12 |
|
|
|
* @since 2025-11-12 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
@Slf4j |
|
|
|
@Service |
|
|
|
@Service |
|
|
|
public class DsPartServiceImpl extends BaseServiceImpl<DsPartMapper, DsPartEntity> implements IDsPartService { |
|
|
|
public class DsPartServiceImpl extends BaseServiceImpl<DsPartMapper, DsPartEntity> implements IDsPartService { |
|
|
|
|
|
|
|
|
|
|
|
@ -85,6 +89,9 @@ public class DsPartServiceImpl extends BaseServiceImpl<DsPartMapper, DsPartEntit |
|
|
|
return erpDataPartClient; |
|
|
|
return erpDataPartClient; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
|
|
IPrReworkProcessService prReworkProcessService; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public IPage<DsPartVO> selectDsPartPage(IPage<DsPartVO> page, DsPartVO dsPart) { |
|
|
|
public IPage<DsPartVO> selectDsPartPage(IPage<DsPartVO> page, DsPartVO dsPart) { |
|
|
|
|
|
|
|
|
|
|
|
@ -574,7 +581,144 @@ public class DsPartServiceImpl extends BaseServiceImpl<DsPartMapper, DsPartEntit |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean selectPartCraft(String partCode, String roamNo, String rank, String partVersion) { |
|
|
|
public PartCraftVO selectPartCraft(String partCode, String roamNo, String rank, String partVersion) { |
|
|
|
return false; |
|
|
|
if (StringUtils.isEmpty(partCode)) { |
|
|
|
|
|
|
|
return PartCraftVO.build(PartCraftStatusEnum.PART_NOT_EXIST.getCode()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 1. 查询零件信息 - 先判空再使用
|
|
|
|
|
|
|
|
DsPartEntity partEntity = selectDsPartByPatCodeAndVersion(partCode, partVersion); |
|
|
|
|
|
|
|
if (Objects.isNull(partEntity)) { |
|
|
|
|
|
|
|
return PartCraftVO.build(PartCraftStatusEnum.PART_NOT_EXIST.getCode()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 查询零件版本
|
|
|
|
|
|
|
|
DsPartVersionEntity partVersionEntity = partVersionService.selectByPartId(partEntity.getId()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 2. 判断零件状态
|
|
|
|
|
|
|
|
// todo 判断零件状态维护中 返回“零件工艺维护中”
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 3. 检查工艺是否过期
|
|
|
|
|
|
|
|
Date nextDue = partEntity.getNextDue(); |
|
|
|
|
|
|
|
if (nextDue != null && nextDue.before(new Date())) { |
|
|
|
|
|
|
|
return PartCraftVO.build(PartCraftStatusEnum.PART_EXPIRED.getCode()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 4. 查询所有工艺
|
|
|
|
|
|
|
|
List<DsCraftEntity> dsCraftList = craftService.selectDsCraftByPartIdAndRoamNo(partEntity.getId(), roamNo); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 5. 如果没有工艺,创建维护任务并返回null
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(dsCraftList)) { |
|
|
|
|
|
|
|
createMaintainTask(partEntity, partVersionEntity); |
|
|
|
|
|
|
|
return PartCraftVO.build(PartCraftStatusEnum.NO_CRAFT_INFO.getCode()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 6. 按优先级查询工艺
|
|
|
|
|
|
|
|
DsCraftEntity craftByRank = selectCraftByPriority(dsCraftList, rank); |
|
|
|
|
|
|
|
if (craftByRank == null) { |
|
|
|
|
|
|
|
return PartCraftVO.build(PartCraftStatusEnum.NO_CRAFT_RANK_INFO.getCode()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 7. 查询工序
|
|
|
|
|
|
|
|
List<DsProcessEntity> processEntities = processService.selectDsProcessByCraftId(craftByRank.getId()); |
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(processEntities)) { |
|
|
|
|
|
|
|
return PartCraftVO.build(PartCraftStatusEnum.NO_PROCEDURE_INFO.getCode()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 8. 返回工艺
|
|
|
|
|
|
|
|
return PartCraftVO.build(PartCraftStatusEnum.SUCCESS.getCode(),craftByRank); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public List<PrReworkProcessEntity> selectReworkPartCraft(String partCode, String reworkOrder,String batchNo,String reworkNo) { |
|
|
|
|
|
|
|
if (StringUtils.isEmpty(partCode) || StringUtils.isEmpty(reworkOrder) || StringUtils.isEmpty(batchNo) || StringUtils.isEmpty(reworkNo) ) { |
|
|
|
|
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 1.查询返工工艺
|
|
|
|
|
|
|
|
DsCraftEntity craftEntity = craftService.getReworkCraft(reworkOrder); |
|
|
|
|
|
|
|
if (Objects.isNull(craftEntity)) { |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 2.查询返工工序
|
|
|
|
|
|
|
|
List<PrReworkProcessEntity> reworkProcessEntityList = prReworkProcessService.selectPrReworkProcess(reworkOrder, partCode, batchNo,reworkNo); |
|
|
|
|
|
|
|
if(CollectionUtils.isEmpty(reworkProcessEntityList)){ |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return reworkProcessEntityList; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public DsPartVersionEntity getNewPartVersion(String partCode) { |
|
|
|
|
|
|
|
if (StringUtils.isEmpty(partCode)) { |
|
|
|
|
|
|
|
List<DsPartVersionEntity> partVersionEntityList = partVersionService.selectByPartCode(partCode); |
|
|
|
|
|
|
|
Optional<DsPartVersionEntity> maxEntity = partVersionEntityList.stream() |
|
|
|
|
|
|
|
.filter(entity -> entity.getPartVersion() != null) |
|
|
|
|
|
|
|
.max(Comparator.comparing(DsPartVersionEntity::getPartVersion)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (maxEntity.isPresent()) { |
|
|
|
|
|
|
|
return maxEntity.get(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 创建维护任务 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private void createMaintainTask(DsPartEntity partEntity, DsPartVersionEntity partVersionEntity) { |
|
|
|
|
|
|
|
DsTaskingEntity dsTaskingEntity = new DsTaskingEntity(); |
|
|
|
|
|
|
|
dsTaskingEntity.setPartCode(partEntity.getPartCode()); |
|
|
|
|
|
|
|
dsTaskingEntity.setPartName(partEntity.getPartName()); |
|
|
|
|
|
|
|
dsTaskingEntity.setTaskStatus(TaskingConstant.TASK_STATUS_WAIT); |
|
|
|
|
|
|
|
dsTaskingEntity.setTaskType(TaskingConstant.MAINTAIN_TASK); |
|
|
|
|
|
|
|
if (partVersionEntity != null) { |
|
|
|
|
|
|
|
dsTaskingEntity.setVersion(partVersionEntity.getPartVersion()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
boolean taskingSave = taskingService.save(dsTaskingEntity); |
|
|
|
|
|
|
|
if (!taskingSave) { |
|
|
|
|
|
|
|
log.error("创建维护任务失败,零件编码:{}", partEntity.getPartCode()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 根据优先级选择工艺 |
|
|
|
|
|
|
|
* 优先级规则:指定级别 > 未指定时按 2级→1级→3级 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private DsCraftEntity selectCraftByPriority(List<DsCraftEntity> craftList, String rank) { |
|
|
|
|
|
|
|
if (!StringUtils.isEmpty(rank)) { |
|
|
|
|
|
|
|
// 指定了工艺级别,直接返回对应级别工艺
|
|
|
|
|
|
|
|
return getCraftByRank(craftList, rank); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 未指定级别,按 2级→1级→3级 优先级查询
|
|
|
|
|
|
|
|
String[] priorityRanks = {"2", "1", "3"}; |
|
|
|
|
|
|
|
for (String priorityRank : priorityRanks) { |
|
|
|
|
|
|
|
DsCraftEntity craft = getCraftByRank(craftList, priorityRank); |
|
|
|
|
|
|
|
if (craft != null) { |
|
|
|
|
|
|
|
return craft; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 从工艺列表中筛选指定级别的工艺 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private DsCraftEntity getCraftByRank(List<DsCraftEntity> craftList, String rank) { |
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(craftList) || StringUtils.isEmpty(rank)) { |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return craftList.stream() |
|
|
|
|
|
|
|
.filter(craft -> rank.equals(craft.getRank())) |
|
|
|
|
|
|
|
.findFirst() |
|
|
|
|
|
|
|
.orElse(null); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|