|
|
|
@ -24,6 +24,7 @@ import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
|
|
|
|
|
import cn.estsh.impp.framework.boot.auth.AuthUtil;
|
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
@ -33,8 +34,10 @@ import org.springframework.util.CollectionUtils;
|
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.function.Function;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
import java.util.stream.IntStream;
|
|
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -247,6 +250,7 @@ public class MesReworkTaskServiceImpl implements IMesReworkTaskService {
|
|
|
|
|
try {
|
|
|
|
|
//
|
|
|
|
|
List<String> snList = Arrays.asList(requestModel.getSn().split(","));
|
|
|
|
|
snList = snList.stream().distinct().collect(Collectors.toList());
|
|
|
|
|
List<String> idList = Arrays.asList(requestModel.getAssemblyIds().split(","));
|
|
|
|
|
// 判断数量是否一致
|
|
|
|
|
if (snList.size() != idList.size()) MesPcnException.throwFlowException("选中的装配件个数和输入的个数不一致");
|
|
|
|
@ -263,13 +267,25 @@ public class MesReworkTaskServiceImpl implements IMesReworkTaskService {
|
|
|
|
|
}
|
|
|
|
|
Map<Long, String> mapProductionAssemble = mesProductionAssemblies.stream().collect(Collectors.toMap(mesProductionAssembly -> mesProductionAssembly.getId(), mesProductionAssembly -> mesProductionAssembly.getAssemblyPartNo()));
|
|
|
|
|
|
|
|
|
|
List<Integer> snStatusList = Stream.of(MesExtEnumUtil.PRODUCE_SN_STATUS.OFFLINE.getValue(), MesExtEnumUtil.PRODUCE_SN_STATUS.ASSEMBLY_BACK.getValue()).collect(Collectors.toList());
|
|
|
|
|
// 获取替换条码信息列表
|
|
|
|
|
DdlPackBean snDdlPackBean = DdlPackBean.getDdlPackBean();
|
|
|
|
|
DdlPreparedPack.getInPackList(snList, "productSn", snDdlPackBean);
|
|
|
|
|
List<MesProduceSn> mesProduceSns = mesProduceSnRepository.findByHqlWhere(snDdlPackBean);
|
|
|
|
|
DdlPreparedPack.getInPackList(snStatusList, "snStatus", snDdlPackBean);
|
|
|
|
|
|
|
|
|
|
List<MesProduceSn> mesProduceSnList = mesProduceSnRepository.findByHqlWhere(snDdlPackBean);
|
|
|
|
|
if (CollectionUtils.isEmpty(mesProductionAssemblies)) {
|
|
|
|
|
MesPcnException.throwFlowException("零件条码不存在");
|
|
|
|
|
}
|
|
|
|
|
List<MesProduceSn> mesProduceSns = new ArrayList<>();
|
|
|
|
|
Map<String, List<MesProduceSn>> productSnListMap = mesProduceSnList.stream().collect(Collectors.groupingBy(mesProduceSn -> mesProduceSn.getProductSn()));
|
|
|
|
|
Map<String, MesProduceSn> productSnMap = new HashedMap();
|
|
|
|
|
productSnListMap.forEach((k,v) -> {
|
|
|
|
|
MesProduceSn produceSn = v.stream().sorted(Comparator.comparing(MesProduceSn::getCreateDatetime).reversed()).findFirst().get();
|
|
|
|
|
mesProduceSns.add(produceSn);
|
|
|
|
|
productSnMap.put(produceSn.getProductSn(), produceSn);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Map<String, String> mapProduceSn = mesProduceSns.stream().collect(Collectors.toMap(mesProduceSn -> mesProduceSn.getPartNo(), mesProduceSn -> mesProduceSn.getProductSn()));
|
|
|
|
|
|
|
|
|
|
mapProductionAssemble.forEach((k, v) -> {
|
|
|
|
@ -281,9 +297,7 @@ public class MesReworkTaskServiceImpl implements IMesReworkTaskService {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
for (String sn : snList) {
|
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean(requestModel.getOrganizeCode());
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(sn, "productSn", packBean);
|
|
|
|
|
MesProduceSn mesProduceSn = mesProduceSnRepository.getByProperty(packBean);
|
|
|
|
|
MesProduceSn mesProduceSn = productSnMap.get(sn);
|
|
|
|
|
if (mesProduceSn == null) {
|
|
|
|
|
MesPcnException.throwFlowException("条码信息不存在");
|
|
|
|
|
}
|
|
|
|
|