|
|
|
@ -50,6 +50,8 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
|
|
|
|
|
@Autowired
|
|
|
|
|
private MesNumberRuleMatchRegularExpressionService matchRegularService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private MesContainerSnStationRepository containerSnStationRDao;
|
|
|
|
|
@Autowired
|
|
|
|
|
private EntityManager entityManager;
|
|
|
|
|
|
|
|
|
|
private MesContainerPackage getContainerPackage(MesContainerSnBindModel model, MesContainerSn containerSn) {
|
|
|
|
@ -66,15 +68,6 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
|
|
|
|
|
return packageDetails;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private int getContainerPackageDetailCount(MesContainerSnBindModel model, MesContainerSn containerSn) {
|
|
|
|
|
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) {
|
|
|
|
|
List<MesContainerPartsModel> result = new ArrayList<>();
|
|
|
|
|
Set<String> partNoSet = new HashSet<>();
|
|
|
|
@ -256,14 +249,20 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
|
|
|
|
|
return containerSn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Boolean getBottomPackageDetails(String organizeCode, String containerSn, List<MesContainerPackageDetail> bottomPackageDetails) {
|
|
|
|
|
List<MesContainerPackageDetail> packageDetailList = containerPackageDetailRDao.findByProperty(new String[]{MesConstWords.ORGANIZE_CODE, MesConstWords.IS_VALID, MesConstWords.IS_DELETED, "containerSn"},
|
|
|
|
|
new Object[]{organizeCode, CommonEnumUtil.IS_VAILD.VAILD.getValue(), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), containerSn});
|
|
|
|
|
private Boolean getBottomPackageDetails(String organizeCode, MesContainerPackage containerPackage, List<MesContainerPackageDetail> bottomPackageDetails) {
|
|
|
|
|
if (containerPackage == null) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
List<MesContainerPackageDetail> packageDetailList = containerPackageDetailRDao.findByProperty(new String[]{MesConstWords.ORGANIZE_CODE, MesConstWords.IS_VALID, MesConstWords.IS_DELETED, "pid"},
|
|
|
|
|
new Object[]{organizeCode, CommonEnumUtil.IS_VAILD.VAILD.getValue(), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), containerPackage.getId()});
|
|
|
|
|
if (CollectionUtils.isEmpty(packageDetailList)) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
for (MesContainerPackageDetail packageDetail : packageDetailList) {
|
|
|
|
|
if (getBottomPackageDetails(organizeCode, packageDetail.getBarCode(), bottomPackageDetails)) {
|
|
|
|
|
MesContainerPackage childContainerPackage = 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(), packageDetail.getBarCode()});
|
|
|
|
|
if (childContainerPackage == null || getBottomPackageDetails(organizeCode, childContainerPackage, bottomPackageDetails)) {
|
|
|
|
|
bottomPackageDetails.add(packageDetail);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -271,6 +270,11 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 校验扫描的条码是否可以进行上料操作
|
|
|
|
|
* @param organizeCode 工厂代码
|
|
|
|
|
* @param barcode 扫描的条码(零件条码/容器条码)
|
|
|
|
|
*/
|
|
|
|
|
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"},
|
|
|
|
@ -278,16 +282,9 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
|
|
|
|
|
if (containerPackage == null || !Objects.equals(containerPackage.getPackageStatus(),MesExtEnumUtil.CONTAINER_PACKAGE_STATUS.STATUS_20.getValue())) {
|
|
|
|
|
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());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<MesContainerPackageDetail> bottomPackageDetails = new ArrayList<>();
|
|
|
|
|
getBottomPackageDetails(organizeCode, barcode, bottomPackageDetails);
|
|
|
|
|
getBottomPackageDetails(organizeCode, containerPackage, bottomPackageDetails);
|
|
|
|
|
if (CollectionUtils.isEmpty(bottomPackageDetails)) {
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
}
|
|
|
|
@ -314,8 +311,54 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
|
|
|
|
|
return bottomPackageDetails;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 判断扫描的容器下所有零件是否为扣减完成,表示该容器为空箱,需要将该容器条码与其他容器的绑定关系解除
|
|
|
|
|
* 同时记录解绑记录。
|
|
|
|
|
* @param organizeCode 工厂代码
|
|
|
|
|
* @param containerSn 扫描的容器条码
|
|
|
|
|
* @param bStep 是否为工步上料
|
|
|
|
|
* @param username 用户名
|
|
|
|
|
*/
|
|
|
|
|
private void autoOpenContainerSn(String organizeCode, String containerSn, boolean bStep, String username) {
|
|
|
|
|
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});
|
|
|
|
|
if (containerPackage == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<MesContainerPackageDetail> bottomPackageDetails = new ArrayList<>();
|
|
|
|
|
getBottomPackageDetails(organizeCode, containerPackage, bottomPackageDetails);
|
|
|
|
|
boolean isAllDeduction = true;
|
|
|
|
|
for (MesContainerPackageDetail packageDetail : bottomPackageDetails) {
|
|
|
|
|
if (!Objects.equals(packageDetail.getSnStatus(), MesExtEnumUtil.CONTAINER_BARCODE_STATUS.STATUS_20.getValue())) {
|
|
|
|
|
isAllDeduction = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (isAllDeduction) {
|
|
|
|
|
MesContainerPackageDetail detail = 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(), containerPackage.getContainerSn()});
|
|
|
|
|
if (detail != null) {
|
|
|
|
|
MesContainerPackageDetailBinding binding = createContainerPackageDetailBinding(containerPackage, detail, MesExtEnumUtil.CONTAINER_RAW_SN_BINDING_STATUS.UN_BINDING, username);
|
|
|
|
|
detailBindingRDao.insert(binding);
|
|
|
|
|
containerPackageDetailRDao.deleteWeaklyById(detail.getId(), username);
|
|
|
|
|
}
|
|
|
|
|
containerPackageRDao.deleteWeaklyById(containerPackage.getId(), username);
|
|
|
|
|
// 非工步上料,需要将容器与站点解绑!
|
|
|
|
|
if (!bStep) {
|
|
|
|
|
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(organizeCode);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(containerSn, "containerSn", ddlPackBean);
|
|
|
|
|
containerSnStationRDao.updateByProperties(
|
|
|
|
|
new String[]{"modifyUser", "modifyDatetime", "isDeleted"},
|
|
|
|
|
new Object[]{username, TimeTool.getNowTime(true), CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()},
|
|
|
|
|
ddlPackBean);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public MesContainerSnBindModel doScanBarcode(MesContainerSnBindModel model) {
|
|
|
|
|
public MesContainerSnBindModel doScanBarcode(MesContainerSnBindModel model, boolean bStep) {
|
|
|
|
|
final String organizeCode = model.getOrganizeCode();
|
|
|
|
|
//校验容器条码
|
|
|
|
|
MesContainerSn containerSn = containerSnService.checkContainerSn(organizeCode, model.getContainerSn());
|
|
|
|
@ -328,6 +371,7 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
|
|
|
|
|
if (containerType.getMixType() == null) {
|
|
|
|
|
MesPcnException.throwMesBusiException("容器类型代码【%s】未配置混包类型,请检查容器类型主数据", containerSn.getContainerTypeCode());
|
|
|
|
|
}
|
|
|
|
|
autoOpenContainerSn(organizeCode, containerSn.getContainerSn(), bStep, model.getUserName());
|
|
|
|
|
|
|
|
|
|
List<MesContainerPackageDetail> packageDetails;
|
|
|
|
|
MesContainerPackage containerPackage = containerPackageRDao.getByProperty(
|
|
|
|
@ -341,22 +385,16 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
|
|
|
|
|
MesPcnException.throwMesBusiException("容器条码【%s】已关箱,不能再进行上料", containerSn.getContainerSn());
|
|
|
|
|
}
|
|
|
|
|
packageDetails = containerPackageDetailRDao.findByProperty(
|
|
|
|
|
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 String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_VALID, "pid"},
|
|
|
|
|
new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), containerPackage.getId()});
|
|
|
|
|
}
|
|
|
|
|
MesContainerPackageDetail barcodePackageDetail = 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(), model.getBarCode()});
|
|
|
|
|
if (barcodePackageDetail != null) {
|
|
|
|
|
MesPcnException.throwMesBusiException("条码【%s】已被容器【%s】绑定,请检查数据!", model.getBarCode(), barcodePackageDetail.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);
|
|
|
|
|
getBottomPackageDetails(organizeCode, containerPackage, oldPackageDetails);
|
|
|
|
|
|
|
|
|
|
// 判断扫描的是否为容器条码
|
|
|
|
|
List<MesContainerPackageDetail> bottomPackageDetails;
|
|
|
|
@ -397,7 +435,6 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
|
|
|
|
|
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, combPackageDetails, getContainerParts(model.getOrganizeCode(), containerType.getContainerTypeCode(), containerSn.getContainerSn()));
|
|
|
|
|
if (checkQtyResult != null && Objects.equals(checkQtyResult.get(MesPcnExtConstWords.RESULT), false)) {
|
|
|
|
@ -452,7 +489,6 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
|
|
|
|
|
containerPackageDetailRDao.updateByProperties(new String[]{"modifyUser", "modifyDatetime", "isDeleted"},
|
|
|
|
|
new Object[]{model.getUserName(), TimeTool.getNowTime(true), CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()}, ddlPackBean);
|
|
|
|
|
|
|
|
|
|
containerPackage.setQty(0);
|
|
|
|
|
containerPackage.setPackageStatus(MesExtEnumUtil.CONTAINER_PACKAGE_STATUS.STATUS_30.getValue());
|
|
|
|
|
ConvertBean.serviceModelUpdate(containerPackage, model.getUserName());
|
|
|
|
|
containerPackageRDao.update(containerPackage);
|
|
|
|
@ -482,7 +518,6 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
|
|
|
|
|
}
|
|
|
|
|
containerPackageDetailRDao.deleteWeaklyByIds(deleteDetailIds.toArray(new Long[0]), model.getUserName());
|
|
|
|
|
|
|
|
|
|
containerPackage.setQty(getContainerPackageDetailCount(model, containerSn));
|
|
|
|
|
containerPackage.setPackageStatus(MesExtEnumUtil.CONTAINER_PACKAGE_STATUS.STATUS_30.getValue());
|
|
|
|
|
ConvertBean.serviceModelUpdate(containerPackage, model.getUserName());
|
|
|
|
|
containerPackageRDao.update(containerPackage);
|
|
|
|
@ -571,7 +606,6 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
|
|
|
|
|
containerPackage.setOrganizeCode(model.getOrganizeCode());
|
|
|
|
|
containerPackage.setContainerSn(model.getContainerSn());
|
|
|
|
|
containerPackage.setPackageStatus(MesExtEnumUtil.CONTAINER_PACKAGE_STATUS.STATUS_10.getValue());
|
|
|
|
|
containerPackage.setQty(0);
|
|
|
|
|
ConvertBean.serviceModelInitialize(containerPackage, model.getUserName());
|
|
|
|
|
return containerPackage;
|
|
|
|
|
}
|
|
|
|
|