常熟站点绑定功能

uat-temp-nht-2506120000-jialiao
jason 4 weeks ago
parent 6fdba66cfb
commit 5b8a5e5d84

@ -213,7 +213,7 @@ public class MesPackageContainerSnServiceImpl implements IMesPackageContainerSnS
.partNo(subPackageDetail.getPartNo())
.build();
Map<String, Object> checkQtyResult = checkQtyService.doCheck(organizeCode, masterContainerPackage, subPackageDetails, containerPart, masterContainerParts);
Map<String, Object> checkQtyResult = checkQtyService.doCheck(organizeCode, masterContainerPackage, subPackageDetails, masterContainerParts);
if (checkQtyResult != null && Objects.equals(checkQtyResult.get(MesPcnExtConstWords.RESULT), false)) {
MesPcnException.throwMesBusiException(checkQtyResult.get(MesPcnExtConstWords.MESSAGE).toString());
}

@ -81,9 +81,12 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
}
private int getContainerPackageDetailCount(MesContainerSnBindModel model, MesContainerSn containerSn) {
return containerPackageDetailRDao.findByPropertyCount(
new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_VALID, "containerSn"},
new Object[]{model.getOrganizeCode(), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), containerSn.getContainerSn()});
List<MesContainerPackageDetail> bottomPackageDetails = new ArrayList<>();
getBottomPackageDetails(model.getOrganizeCode(), containerSn.getContainerSn(), bottomPackageDetails);
return bottomPackageDetails.size();
// return containerPackageDetailRDao.findByPropertyCount(
// new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_VALID, "containerSn"},
// new Object[]{model.getOrganizeCode(), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), containerSn.getContainerSn()});
}
private List<MesContainerPartsModel> getContainerParts(String organizeCode, String containerTypeCode, String containerSn) {
@ -176,8 +179,8 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
continue;
}
Map<String, Object> reulst = matchRegularService.matchNumberRule(organizeCode, barcode, "", snPart.getMatchRule());
if (reulst != null && Objects.equals(reulst.get(MesPcnExtConstWords.RESULT), true)) {
Map<String, Object> result = matchRegularService.matchNumberRule(organizeCode, barcode, "", snPart.getMatchRule());
if (result != null && Objects.equals(result.get(MesPcnExtConstWords.RESULT), true)) {
model = MesContainerPartsModel.builder()
.partNo(snPart.getPartNo())
.partName(snPart.getPartName())
@ -282,27 +285,30 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
return false;
}
private void checkContainerBarcode(String organizeCode, String barcode) {
MesContainerSn containerSn = containerSnService.getContainerSn(organizeCode, barcode);
if (containerSn == null) {
return;
}
private List<MesContainerPackageDetail> checkContainerBarcode(String organizeCode, String barcode, List<MesContainerPackageDetail> oldPackageDetails) {
MesContainerPackage containerPackage = containerPackageRDao.getByProperty(
new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_VALID, "containerSn"},
new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), containerSn.getContainerSn()});
new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), barcode});
if (containerPackage == null || !Objects.equals(containerPackage.getPackageStatus(),MesExtEnumUtil.CONTAINER_PACKAGE_STATUS.STATUS_20.getValue())) {
MesPcnException.throwMesBusiException("容器条码【%s】未关箱不能进行上料操作", containerSn.getContainerSn());
MesPcnException.throwMesBusiException("容器条码【%s】未关箱不能进行上料操作", barcode);
}
MesContainerPackageDetail bindDetail = containerPackageDetailRDao.getByProperty(
new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_VALID, "barCode"},
new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), barcode}
);
if (bindDetail != null) {
MesPcnException.throwMesBusiException("容器条码【%s】被容器【%s】绑定不能进行上料操作", barcode, bindDetail.getContainerSn());
}
String topContainerSn = getTopContainerSn(organizeCode, containerSn.getContainerSn());
List<MesContainerPackageDetail> bottomPackageDetails = new ArrayList<>();
getBottomPackageDetails(organizeCode, topContainerSn, bottomPackageDetails);
getBottomPackageDetails(organizeCode, barcode, bottomPackageDetails);
if (CollectionUtils.isEmpty(bottomPackageDetails)) {
return;
return new ArrayList<>();
}
final Set<String> containerSnSet = bottomPackageDetails.stream().map(MesContainerPackageDetail::getContainerSn).collect(Collectors.toSet());
List<MesContainerPackageDetail> combPackageDetails = new ArrayList<>(oldPackageDetails);
combPackageDetails.addAll(bottomPackageDetails);
final Set<String> containerSnSet = combPackageDetails.stream().map(MesContainerPackageDetail::getContainerSn).collect(Collectors.toSet());
StringBuilder hql = new StringBuilder();
hql.append(" select count(DISTINCT mss.top_container_sn) from mes_container_sn_station mss where mss.organize_code=:organizeCode and mss.is_deleted=:isDeleted and mss.is_valid=:isValid");
if (containerSnSet.size() == 1) {
@ -317,17 +323,19 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
//本次查询满足条件的总数
int count = countQuery.getResultList().size();
if (count > 1) {
MesPcnException.throwMesBusiException("容器条码【%s】在多个站点进行过绑定", containerSn.getContainerSn());
MesPcnException.throwMesBusiException("容器条码【%s】在多个站点进行过绑定", barcode);
}
return bottomPackageDetails;
}
@Override
public MesContainerSnBindModel doScanBarcode(MesContainerSnBindModel model) {
final String organizeCode = model.getOrganizeCode();
//校验容器条码
MesContainerSn containerSn = containerSnService.checkContainerSn(model.getOrganizeCode(), model.getContainerSn());
MesContainerSn containerSn = containerSnService.checkContainerSn(organizeCode, model.getContainerSn());
MesContainerType containerType = containerTypeRDao.getByProperty(
new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_VALID, "containerTypeCode"},
new Object[]{model.getOrganizeCode(), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), containerSn.getContainerTypeCode()});
new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), containerSn.getContainerTypeCode()});
if (containerType == null) {
MesPcnException.throwMesBusiException("容器类型代码【%s】信息不存在请检查容器类型主数据", containerSn.getContainerTypeCode());
}
@ -338,7 +346,7 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
List<MesContainerPackageDetail> packageDetails;
MesContainerPackage containerPackage = containerPackageRDao.getByProperty(
new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_VALID, "containerSn"},
new Object[]{model.getOrganizeCode(), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), containerSn.getContainerSn()});
new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), containerSn.getContainerSn()});
if (containerPackage == null) {
containerPackage = createContainerPackage(model, containerType);
packageDetails = new ArrayList<>();
@ -348,41 +356,67 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
}
packageDetails = containerPackageDetailRDao.findByProperty(
new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_VALID, "containerSn"},
new Object[]{model.getOrganizeCode(), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), containerSn.getContainerSn()});
new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), containerSn.getContainerSn()});
}
for (MesContainerPackageDetail packageDetail : packageDetails) {
if (Objects.equals(packageDetail.getBarCode(), model.getBarCode())) {
MesPcnException.throwMesBusiException("容器条码【%s】与条码【%s】已绑定请检查数据", containerSn.getContainerSn(), model.getBarCode());
}
}
List<MesContainerPackageDetail> oldPackageDetails = new ArrayList<>();
getBottomPackageDetails(organizeCode, containerSn.getContainerSn(), oldPackageDetails);
// 判断扫描的是否为容器条码
List<MesContainerPackageDetail> bottomPackageDetails;
MesContainerSn childContainerSn = containerSnService.getContainerSn(organizeCode, model.getBarCode());
if (childContainerSn != null) {
if (!Objects.equals(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue(), containerType.getIsAllowRecursion())) {
MesPcnException.throwBusiException("扫描的容器条码:%s不允许绑定容器", containerSn.getContainerSn());
}
bottomPackageDetails = checkContainerBarcode(organizeCode, model.getBarCode(), oldPackageDetails);
} else {
bottomPackageDetails = new ArrayList<>();
}
checkContainerBarcode(model.getOrganizeCode(), model.getBarCode());
MesContainerSnBindModel containerResult = packageContainerSnService.packageContain(model.getOrganizeCode(), model.getUserName(), model.getContainerSn(), model.getBarCode());
if (containerResult != null) {
return containerResult;
// MesContainerSnBindModel containerResult = packageContainerSnService.packageContain(organizeCode, model.getUserName(), model.getContainerSn(), model.getBarCode());
// if (containerResult != null) {
// return containerResult;
// }
String barcode = model.getBarCode();
if (!CollectionUtils.isEmpty(bottomPackageDetails)) {
barcode = bottomPackageDetails.get(0).getBarCode();
}
MesContainerPartsModel containerPart = checkProduceSn(model.getOrganizeCode(), containerSn, model.getBarCode(), model.getPartNo());
MesContainerPartsModel containerPart = checkProduceSn(model.getOrganizeCode(), containerSn, barcode, model.getPartNo());
containerPart.setContainerType(containerType.getContainerType());
containerPart.setContainerPackage(containerPackage);
// 调用策略校验条码与容器是否可以绑定
Map<String, Object> matchResult = ContainerBindManager.INSTANCE.matchNumberRule(model.getOrganizeCode(), model.getBarCode(), containerPart);
Map<String, Object> matchResult = ContainerBindManager.INSTANCE.matchNumberRule(model.getOrganizeCode(), barcode, containerPart);
assert matchResult != null;
if (Objects.equals(matchResult.get(MesPcnExtConstWords.RESULT), false)) {
MesPcnException.throwMesBusiException(matchResult.get(MesPcnExtConstWords.MESSAGE).toString());
}
MesContainerPackageDetail packageDetail = createContainerPackageDetail(model, containerPackage, containerPart, matchResult);
packageDetails.add(packageDetail);
List<MesContainerPackageDetail> combPackageDetails = new ArrayList<>(oldPackageDetails);
if (CollectionUtils.isEmpty(bottomPackageDetails)) {
combPackageDetails.add(packageDetail);
} else {
packageDetail.setDataType(MesExtEnumUtil.CONTAINER_BARCODE_DATA_TYPE.STATUS_30.getValue());
packageDetail.setQty((double)bottomPackageDetails.size());
combPackageDetails.addAll(bottomPackageDetails);
}
containerPackage.setQty(combPackageDetails.size());
MesAbstractContainerBindCheckQtyService checkQtyService = ContainerBindManager.INSTANCE.getCheckQtyService(MesExtEnumUtil.CONTAINER_TYPE_MIX_TYPE.getByValue(containerType.getMixType()));
Map<String, Object> checkQtyResult = checkQtyService.doCheck(model.getOrganizeCode(), containerPackage, packageDetails, containerPart, getContainerParts(model.getOrganizeCode(), containerType.getContainerTypeCode(), containerSn.getContainerSn()));
Map<String, Object> checkQtyResult = checkQtyService.doCheck(model.getOrganizeCode(), containerPackage, combPackageDetails, getContainerParts(model.getOrganizeCode(), containerType.getContainerTypeCode(), containerSn.getContainerSn()));
if (checkQtyResult != null && Objects.equals(checkQtyResult.get(MesPcnExtConstWords.RESULT), false)) {
MesPcnException.throwMesBusiException(checkQtyResult.get(MesPcnExtConstWords.MESSAGE).toString());
}
MesContainerPackageDetailBinding binding = createContainerPackageDetailBinding(containerPackage, packageDetail, MesExtEnumUtil.CONTAINER_RAW_SN_BINDING_STATUS.BINDING, model.getUserName());
packageDetails.add(packageDetail);
model.setContainerPackage(containerPackage);
model.setPackageDetails(packageDetails);
model.addPackageDetailBinding(binding);
@ -395,7 +429,6 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
private void saveContainerPackage(MesContainerSnBindModel model) {
MesContainerPackage containerPackage = model.getContainerPackage();
if (containerPackage != null) {
containerPackage.setQty(model.getPackageDetails().size());
containerPackageRDao.save(containerPackage);
}
if (!CollectionUtils.isEmpty(model.getPackageDetails())) {
@ -511,7 +544,7 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
return model;
}
private MesContainerPartsModel checkProduceSn(String organizeCode, MesContainerSn containerSn, String barCode, String partNo) {
private MesContainerPartsModel checkProduceSn(String organizeCode, MesContainerSn containerSn, String barCode, String selectPartNo) {
MesContainerPartsModel model;
MesProduceSn produceSn = produceSnRDao.getByProperty(
new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_VALID, "productSn"},
@ -531,7 +564,7 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
if (model == null) {
MesPcnException.throwMesBusiException("容器条码【%s】或容器类型代码【%s】未维护与零件关系请检查数据", containerSn.getContainerSn(), containerSn.getContainerTypeCode());
}
if (!StringUtils.isEmpty(partNo) && !Objects.equals(partNo, model.getPartNo())) {
if (!StringUtils.isEmpty(selectPartNo) && !Objects.equals(selectPartNo, model.getPartNo())) {
MesPcnException.throwMesBusiException("条码【%s】的零件号【%s】与选择的零件不匹配请检查数据", barCode, produceSn.getPartNo());
}

@ -10,6 +10,7 @@ import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.HashMap;
import java.util.Map;

@ -17,5 +17,5 @@ public class MesAbstractContainerBindCheckQtyService {
}
@ApiOperation(value = "校验数量")
public Map<String, Object> doCheck(String organizeCode, MesContainerPackage containerPackage, List<MesContainerPackageDetail> packageDetails, MesContainerPartsModel matchModel, List<MesContainerPartsModel> containerParts) { return null; }
public Map<String, Object> doCheck(String organizeCode, MesContainerPackage containerPackage, List<MesContainerPackageDetail> packageDetails, List<MesContainerPartsModel> containerParts) { return null; }
}

@ -20,7 +20,7 @@ public class MesContainerBindMixService extends MesAbstractContainerBindCheckQty
}
@Override
public Map<String, Object> doCheck(String organizeCode, MesContainerPackage containerPackage, List<MesContainerPackageDetail> packageDetails, MesContainerPartsModel matchModel, List<MesContainerPartsModel> containerParts) {
public Map<String, Object> doCheck(String organizeCode, MesContainerPackage containerPackage, List<MesContainerPackageDetail> packageDetails, List<MesContainerPartsModel> containerParts) {
Map<String, Object> result = new HashMap<>();
result.put(MesPcnExtConstWords.RESULT, false);
@ -32,14 +32,14 @@ public class MesContainerBindMixService extends MesAbstractContainerBindCheckQty
partNoSet.add(packageDetail.getPartNo());
}
for (MesContainerPartsModel containerPart : containerParts) {
if (!partNoSet.contains(containerPart.getPartNo())) {
if (containerPart.getQty() == null || !partNoSet.contains(containerPart.getPartNo())) {
continue;
}
if (containerPackage.getQty() >= containerPart.getQty()) {
if (containerPackage.getQty() > containerPart.getQty()) {
result.put(MesPcnExtConstWords.MESSAGE, String.format("容器条码【%s】超出了包装规格", containerPackage.getContainerSn()));
return result;
}
if ((containerPackage.getQty() + 1) == containerPart.getQty()) {
if (containerPackage.getQty().equals(containerPart.getQty().intValue())) {
containerPackage.setPackageStatus(MesExtEnumUtil.CONTAINER_PACKAGE_STATUS.STATUS_20.getValue());
}
}

@ -7,11 +7,10 @@ import cn.estsh.i3plus.pojo.mes.bean.MesContainerPackageDetail;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
@Component
@ -21,20 +20,30 @@ public class MesContainerBindNotMixService extends MesAbstractContainerBindCheck
}
@Override
public Map<String, Object> doCheck(String organizeCode, MesContainerPackage containerPackage, List<MesContainerPackageDetail> packageDetails, MesContainerPartsModel matchModel, List<MesContainerPartsModel> containerParts) {
public Map<String, Object> doCheck(String organizeCode, MesContainerPackage containerPackage, List<MesContainerPackageDetail> packageDetails, List<MesContainerPartsModel> containerParts) {
Map<String, Object> result = new HashMap<>();
result.put(MesPcnExtConstWords.RESULT, false);
final Set<String> partNoSet = packageDetails.stream().map(MesContainerPackageDetail::getPartNo).collect(Collectors.toSet());
if (StringUtils.isEmpty(partNoSet)) {
result.put(MesPcnExtConstWords.MESSAGE, "绑定的底层条码中不包含零件信息");
return result;
}
if (partNoSet.size() > 1) {
result.put(MesPcnExtConstWords.MESSAGE, String.format("容器条码【%s】不允许混包", containerPackage.getContainerSn()));
return result;
}
String partNo = partNoSet.iterator().next();
for (MesContainerPartsModel containerPart : containerParts) {
if (!Objects.equals(containerPart.getPartNo(), matchModel.getPartNo())) {
if (containerPart.getQty() == null || !Objects.equals(containerPart.getPartNo(), partNo)) {
continue;
}
if (containerPackage.getQty() >= containerPart.getQty()) {
if (containerPackage.getQty() > containerPart.getQty()) {
result.put(MesPcnExtConstWords.MESSAGE, String.format("容器条码【%s】超出了包装规格", containerPackage.getContainerSn()));
return result;
}
if ((containerPackage.getQty() + 1) == containerPart.getQty()) {
if (containerPackage.getQty().equals(containerPart.getQty().intValue())) {
containerPackage.setPackageStatus(MesExtEnumUtil.CONTAINER_PACKAGE_STATUS.STATUS_20.getValue());
}
}
@ -42,4 +51,13 @@ public class MesContainerBindNotMixService extends MesAbstractContainerBindCheck
result.put(MesPcnExtConstWords.RESULT, true);
return result;
}
private String getPartNo(List<MesContainerPackageDetail> packageDetails) {
for (MesContainerPackageDetail packageDetail : packageDetails) {
if (!StringUtils.isEmpty(packageDetail.getPartNo())) {
return packageDetail.getPartNo();
}
}
return "";
}
}

Loading…
Cancel
Save