|
|
|
@ -39,6 +39,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
import rx.internal.util.LinkedArrayList;
|
|
|
|
|
|
|
|
|
|
import javax.persistence.EntityManager;
|
|
|
|
|
import java.util.*;
|
|
|
|
@ -122,9 +123,11 @@ public class MesPackageNoGenerateStepService extends BaseStepService implements
|
|
|
|
|
List<Integer> foreignKeyList = prodRuleContextList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getIsPackage()) && o.getIsPackage().compareTo(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) == 0)).map(MesProdRuleContext::getForeignKey).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
//搜集数据关联键集合对应的[合格状态]的产出条码,根据零件号分组
|
|
|
|
|
Map<String, List<String>> productSnMap2Part = productionPsOutContextList.stream()
|
|
|
|
|
/**Map<String, List<String>> productSnMap2Part = productionPsOutContextList.stream()
|
|
|
|
|
.filter(o -> (null != o && o.getQcStatus().compareTo(MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue()) == 0 && foreignKeyList.contains(o.getForeignKey())))
|
|
|
|
|
.collect(Collectors.groupingBy(MesProductionPsOutContext::getPartNo, Collectors.mapping(MesProductionPsOutContext::getProductSn, Collectors.toList())));
|
|
|
|
|
.collect(Collectors.groupingBy(MesProductionPsOutContext::getPartNo, Collectors.mapping(MesProductionPsOutContext::getProductSn, Collectors.toList())));**/
|
|
|
|
|
Map<String, LinkedList<String>> productSnMap2Part = new HashMap<>();
|
|
|
|
|
productionPsOutContextList.forEach(o -> productSnMap2Part.computeIfAbsent(o.getPartNo(), k -> new LinkedList<>()).addAll(generateVirtualPs(o.getQty(), o.getProductSn())));
|
|
|
|
|
|
|
|
|
|
//获取包装规则信息
|
|
|
|
|
Map<String, MesPackageRuleContext> packageRuleContextMap = productionProcessContextStepService.getPackageRuleContext(reqBean);
|
|
|
|
@ -134,7 +137,7 @@ public class MesPackageNoGenerateStepService extends BaseStepService implements
|
|
|
|
|
Map<String, String> packageDataContextMap = productionCustomContextStepService.getPackageDataContext(reqBean);
|
|
|
|
|
|
|
|
|
|
//不同的零件号分别打包处理
|
|
|
|
|
for (Map.Entry<String, List<String>> entry : productSnMap2Part.entrySet()) {
|
|
|
|
|
for (Map.Entry<String, LinkedList<String>> entry : productSnMap2Part.entrySet()) {
|
|
|
|
|
|
|
|
|
|
if (null == entry) continue;
|
|
|
|
|
|
|
|
|
@ -297,7 +300,7 @@ public class MesPackageNoGenerateStepService extends BaseStepService implements
|
|
|
|
|
//生成包装及明细, 根据标包数量判断是否执行打印 [递归]
|
|
|
|
|
@Override
|
|
|
|
|
public List<MesPackageDataContext> doHandlePackagePrint(StationRequestBean reqBean, StepResult stepResult, MesPackageRuleContext packageRuleContext,
|
|
|
|
|
List<MesPackageDataContext> packageDataContextList, List<String> productSnList, Boolean isAsyn) {
|
|
|
|
|
List<MesPackageDataContext> packageDataContextList, LinkedList<String> productSnList, Boolean isAsyn) {
|
|
|
|
|
|
|
|
|
|
//缓存的包装条码明细数量
|
|
|
|
|
Integer cachedQty = CollectionUtils.isEmpty(packageDataContextList) ? MesPcnExtConstWords.ZERO : packageDataContextList.size();
|
|
|
|
@ -307,9 +310,9 @@ public class MesPackageNoGenerateStepService extends BaseStepService implements
|
|
|
|
|
if (needQty < 0) needQty = MesPcnExtConstWords.ZERO;
|
|
|
|
|
|
|
|
|
|
//当前满足标包的差额条码
|
|
|
|
|
List<String> productSnList2Cur = null;
|
|
|
|
|
LinkedList<String> productSnList2Cur = null;
|
|
|
|
|
//除去当前满足标包的差额条码后的剩余条码
|
|
|
|
|
List<String> productSnList2Remain = null;
|
|
|
|
|
LinkedList<String> productSnList2Remain = null;
|
|
|
|
|
|
|
|
|
|
//当前零件剩余未打包条码 如果小于等于 当前满足标包的差额数量, 则直接将 未打包条码赋给当前满足标包的差额条码, 否则 截取条码
|
|
|
|
|
if (productSnList.size() <= needQty) {
|
|
|
|
@ -320,8 +323,8 @@ public class MesPackageNoGenerateStepService extends BaseStepService implements
|
|
|
|
|
productSnList2Remain = productSnList;
|
|
|
|
|
} else {
|
|
|
|
|
//根据需要的个数进行截取条码
|
|
|
|
|
productSnList2Cur = productSnList.subList(0, needQty);
|
|
|
|
|
productSnList2Remain = productSnList.subList(needQty, productSnList.size());
|
|
|
|
|
productSnList2Cur = (LinkedList<String>) productSnList.subList(0, needQty);
|
|
|
|
|
productSnList2Remain = (LinkedList<String>) productSnList.subList(needQty, productSnList.size());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -454,46 +457,49 @@ public class MesPackageNoGenerateStepService extends BaseStepService implements
|
|
|
|
|
|
|
|
|
|
//判断统计方式,是否生成包装明细信息, 返回当前未满包的包装条码明细数据
|
|
|
|
|
private List<MesPackageDataContext> insertPackageDetailAndBackUnSealedResultList(StationRequestBean reqBean, MesPackageRuleContext packageRuleContext,
|
|
|
|
|
MesPackage packageDb, List<String> productSnList2Cur, Boolean isSealed) {
|
|
|
|
|
MesPackage packageDb, LinkedList<String> productSnList2Cur, Boolean isSealed) {
|
|
|
|
|
//当前未满包的包装条码明细数据
|
|
|
|
|
List<MesPackageDataContext> resultList = null;
|
|
|
|
|
if (CollectionUtils.isEmpty(productSnList2Cur)) return resultList;
|
|
|
|
|
//包装条码明细ID
|
|
|
|
|
Long detailId = null;
|
|
|
|
|
//遍历当前满足标包的差额条码
|
|
|
|
|
for (String productSn : productSnList2Cur) {
|
|
|
|
|
if (StringUtils.isEmpty(productSn)) continue;
|
|
|
|
|
//遍历当前满足标包的差额条码, 这边根据条码分组(因为可能存在重复条码[适配弹框输入的工单数量])
|
|
|
|
|
Map<String, Integer> productSnMap = productSnList2Cur.stream().collect(Collectors.groupingBy(o -> o, Collectors.summingInt(o -> 1)));
|
|
|
|
|
for (Map.Entry<String, Integer> entry : productSnMap.entrySet()) {
|
|
|
|
|
if (null == entry) continue;
|
|
|
|
|
//判断统计方式,是否生成包装明细信息
|
|
|
|
|
if (packageRuleContext.getGenerateType().compareTo(MesExtEnumUtil.PACKING_RULE_GENERATE_TYPE.PACKAGE_DETAIL.getValue()) == 0) {
|
|
|
|
|
detailId = insertMesPackageDetail(reqBean, packageDb, productSn);
|
|
|
|
|
detailId = insertMesPackageDetail(reqBean, packageDb, entry.getKey(), entry.getValue());
|
|
|
|
|
}
|
|
|
|
|
//判断不满包则 赋值给 当前未满包的包装条码明细数据resultList
|
|
|
|
|
if (!isSealed) {
|
|
|
|
|
if (CollectionUtils.isEmpty(resultList)) resultList = new ArrayList<>();
|
|
|
|
|
for (Integer i = 0; i < entry.getValue(); i++) {
|
|
|
|
|
MesPackageDataContext packageDataContext = new MesPackageDataContext();
|
|
|
|
|
BeanUtils.copyProperties(packageRuleContext, packageDataContext);
|
|
|
|
|
packageDataContext.setPackageId(packageDb.getId());
|
|
|
|
|
packageDataContext.setDetailId(detailId);
|
|
|
|
|
packageDataContext.setPackageNo(packageDb.getPackageNo());
|
|
|
|
|
packageDataContext.setQty(new Double(1));
|
|
|
|
|
packageDataContext.setSerialNumber(productSn);
|
|
|
|
|
packageDataContext.setSerialNumber(entry.getKey());
|
|
|
|
|
packageDataContext.setCreateDatetime(packageDb.getCreateDatetime());
|
|
|
|
|
packageDataContext.setModifyDatetime(TimeTool.getNowTime(true));
|
|
|
|
|
resultList.add(packageDataContext);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return resultList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//生成包装明细信息
|
|
|
|
|
private Long insertMesPackageDetail(StationRequestBean reqBean, MesPackage packageDb, String productSn) {
|
|
|
|
|
private Long insertMesPackageDetail(StationRequestBean reqBean, MesPackage packageDb, String productSn, Integer qty) {
|
|
|
|
|
MesPackageDetail packageDetailDb = new MesPackageDetail();
|
|
|
|
|
packageDetailDb.setPackageNo(packageDb.getPackageNo());
|
|
|
|
|
packageDetailDb.setPartNo(packageDb.getPartNo());
|
|
|
|
|
packageDetailDb.setPartName(packageDb.getPartName());
|
|
|
|
|
packageDetailDb.setSerialNumber(productSn);
|
|
|
|
|
packageDetailDb.setProductSn(productSn);
|
|
|
|
|
packageDetailDb.setQty(new Double(1));
|
|
|
|
|
packageDetailDb.setQty(new Double(qty));
|
|
|
|
|
packageDetailDb.setQcStatus(MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue());
|
|
|
|
|
packageDetailDb.setFid(UUID.randomUUID().toString());
|
|
|
|
|
packageDetailDb.setOrganizeCode(reqBean.getOrganizeCode());
|
|
|
|
@ -698,12 +704,21 @@ public class MesPackageNoGenerateStepService extends BaseStepService implements
|
|
|
|
|
|
|
|
|
|
//生成虚拟条码,零件打包不写包装明细数据, 只是为了适配工步中的方法去递归生成包装条码
|
|
|
|
|
@Override
|
|
|
|
|
public List<String> generateVirtualPs(Double qty) {
|
|
|
|
|
List<String> virtualPsList = new ArrayList<>();
|
|
|
|
|
public LinkedList<String> generateVirtualPs(Double qty) {
|
|
|
|
|
LinkedList<String> virtualPsList = new LinkedList<>();
|
|
|
|
|
for (int i = 0; i < qty.intValue(); i ++) {
|
|
|
|
|
virtualPsList.add(String.valueOf(i));
|
|
|
|
|
}
|
|
|
|
|
return virtualPsList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public LinkedList<String> generateVirtualPs(Double qty, String productSn) {
|
|
|
|
|
LinkedList<String> virtualPsList = new LinkedList<>();
|
|
|
|
|
for (int i = 0; i < qty.intValue(); i ++) {
|
|
|
|
|
virtualPsList.add(productSn);
|
|
|
|
|
}
|
|
|
|
|
return virtualPsList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|