|
|
@ -14,6 +14,7 @@ import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
|
|
|
import cn.estsh.i3plus.platform.common.tool.TimeTool;
|
|
|
|
import cn.estsh.i3plus.platform.common.tool.TimeTool;
|
|
|
|
import cn.estsh.i3plus.platform.common.util.MesConstWords;
|
|
|
|
import cn.estsh.i3plus.platform.common.util.MesConstWords;
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.codemaker.SnowflakeIdMaker;
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
|
|
|
|
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.*;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.*;
|
|
|
@ -53,6 +54,8 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
|
|
|
|
private MesContainerSnStationRepository containerSnStationRDao;
|
|
|
|
private MesContainerSnStationRepository containerSnStationRDao;
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private EntityManager entityManager;
|
|
|
|
private EntityManager entityManager;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private SnowflakeIdMaker snowflakeIdMaker;
|
|
|
|
|
|
|
|
|
|
|
|
private MesContainerPackage getContainerPackage(MesContainerSnBindModel model, MesContainerSn containerSn) {
|
|
|
|
private MesContainerPackage getContainerPackage(MesContainerSnBindModel model, MesContainerSn containerSn) {
|
|
|
|
MesContainerPackage containerPackage = containerPackageRDao.getByProperty(
|
|
|
|
MesContainerPackage containerPackage = containerPackageRDao.getByProperty(
|
|
|
@ -319,31 +322,37 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
|
|
|
|
* @param bStep 是否为工步上料
|
|
|
|
* @param bStep 是否为工步上料
|
|
|
|
* @param username 用户名
|
|
|
|
* @param username 用户名
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private void autoOpenContainerSn(String organizeCode, String containerSn, boolean bStep, String username) {
|
|
|
|
private MesContainerPackage autoOpenContainerSn(String organizeCode, String containerSn, boolean bStep, String username) {
|
|
|
|
MesContainerPackage containerPackage = containerPackageRDao.getByProperty(
|
|
|
|
MesContainerPackage containerPackage = containerPackageRDao.getByProperty(
|
|
|
|
new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_VALID, "containerSn"},
|
|
|
|
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});
|
|
|
|
new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), containerSn});
|
|
|
|
if (containerPackage == null) {
|
|
|
|
if (containerPackage == null) {
|
|
|
|
return;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<MesContainerPackageDetail> bottomPackageDetails = new ArrayList<>();
|
|
|
|
List<MesContainerPackageDetail> bottomPackageDetails = new ArrayList<>();
|
|
|
|
getBottomPackageDetails(organizeCode, containerPackage, bottomPackageDetails);
|
|
|
|
getBottomPackageDetails(organizeCode, containerPackage, bottomPackageDetails);
|
|
|
|
boolean isAllDeduction = true;
|
|
|
|
List<MesContainerPackageDetail> deductionDetails = new ArrayList<>();
|
|
|
|
for (MesContainerPackageDetail packageDetail : bottomPackageDetails) {
|
|
|
|
for (MesContainerPackageDetail packageDetail : bottomPackageDetails) {
|
|
|
|
if (!Objects.equals(packageDetail.getSnStatus(), MesExtEnumUtil.CONTAINER_BARCODE_STATUS.STATUS_20.getValue())) {
|
|
|
|
if (Objects.equals(packageDetail.getSnStatus(), MesExtEnumUtil.CONTAINER_BARCODE_STATUS.STATUS_20.getValue())) {
|
|
|
|
isAllDeduction = false;
|
|
|
|
deductionDetails.add(packageDetail);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!deductionDetails.isEmpty()) {
|
|
|
|
|
|
|
|
// 扣减完成的条码与容器进行解绑
|
|
|
|
|
|
|
|
for (MesContainerPackageDetail detail : deductionDetails) {
|
|
|
|
|
|
|
|
if (detailBindingRDao.isExitByProperty(new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_VALID, "pid", "barCode", "snStatus"},
|
|
|
|
|
|
|
|
new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), containerPackage.getId(), detail.getBarCode(), MesExtEnumUtil.CONTAINER_RAW_SN_BINDING_STATUS.UN_BINDING.getValue()})) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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);
|
|
|
|
MesContainerPackageDetailBinding binding = createContainerPackageDetailBinding(containerPackage, detail, MesExtEnumUtil.CONTAINER_RAW_SN_BINDING_STATUS.UN_BINDING, username);
|
|
|
|
detailBindingRDao.insert(binding);
|
|
|
|
detailBindingRDao.insert(binding);
|
|
|
|
containerPackageDetailRDao.deleteWeaklyById(detail.getId(), username);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 容器置为拆箱状态。
|
|
|
|
|
|
|
|
containerPackage.setPackageStatus(MesExtEnumUtil.CONTAINER_PACKAGE_STATUS.STATUS_30.getValue());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 全部扣减完成
|
|
|
|
|
|
|
|
if (!deductionDetails.isEmpty() && deductionDetails.size() == bottomPackageDetails.size()) {
|
|
|
|
containerPackageRDao.deleteWeaklyById(containerPackage.getId(), username);
|
|
|
|
containerPackageRDao.deleteWeaklyById(containerPackage.getId(), username);
|
|
|
|
// 非工步上料,需要将容器与站点解绑!
|
|
|
|
// 非工步上料,需要将容器与站点解绑!
|
|
|
|
if (!bStep) {
|
|
|
|
if (!bStep) {
|
|
|
@ -354,7 +363,9 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
|
|
|
|
new Object[]{username, TimeTool.getNowTime(true), CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()},
|
|
|
|
new Object[]{username, TimeTool.getNowTime(true), CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()},
|
|
|
|
ddlPackBean);
|
|
|
|
ddlPackBean);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return containerPackage;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -371,12 +382,9 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
|
|
|
|
if (containerType.getMixType() == null) {
|
|
|
|
if (containerType.getMixType() == null) {
|
|
|
|
MesPcnException.throwMesBusiException("容器类型代码【%s】未配置混包类型,请检查容器类型主数据", containerSn.getContainerTypeCode());
|
|
|
|
MesPcnException.throwMesBusiException("容器类型代码【%s】未配置混包类型,请检查容器类型主数据", containerSn.getContainerTypeCode());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
autoOpenContainerSn(organizeCode, containerSn.getContainerSn(), bStep, model.getUserName());
|
|
|
|
MesContainerPackage containerPackage = autoOpenContainerSn(organizeCode, containerSn.getContainerSn(), bStep, model.getUserName());
|
|
|
|
|
|
|
|
|
|
|
|
List<MesContainerPackageDetail> packageDetails;
|
|
|
|
List<MesContainerPackageDetail> packageDetails;
|
|
|
|
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()});
|
|
|
|
|
|
|
|
if (containerPackage == null) {
|
|
|
|
if (containerPackage == null) {
|
|
|
|
containerPackage = createContainerPackage(model, containerType);
|
|
|
|
containerPackage = createContainerPackage(model, containerType);
|
|
|
|
packageDetails = new ArrayList<>();
|
|
|
|
packageDetails = new ArrayList<>();
|
|
|
@ -406,7 +414,7 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
|
|
|
|
bottomPackageDetails = checkContainerBarcode(organizeCode, model.getBarCode(), oldPackageDetails);
|
|
|
|
bottomPackageDetails = checkContainerBarcode(organizeCode, model.getBarCode(), oldPackageDetails);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (Objects.equals(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue(), containerType.getIsAllowRecursion())) {
|
|
|
|
if (Objects.equals(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue(), containerType.getIsAllowRecursion())) {
|
|
|
|
MesPcnException.throwBusiException("容器条码【%s】不能零件条码,请重新扫描!", containerSn.getContainerSn());
|
|
|
|
MesPcnException.throwBusiException("容器条码【%s】不能扫描原料条码,请重新扫描!", containerSn.getContainerSn());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bottomPackageDetails = new ArrayList<>();
|
|
|
|
bottomPackageDetails = new ArrayList<>();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -459,11 +467,11 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
|
|
|
|
containerPackageRDao.save(containerPackage);
|
|
|
|
containerPackageRDao.save(containerPackage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!CollectionUtils.isEmpty(model.getPackageDetails())) {
|
|
|
|
if (!CollectionUtils.isEmpty(model.getPackageDetails())) {
|
|
|
|
if (containerPackage != null) {
|
|
|
|
// if (containerPackage != null) {
|
|
|
|
for (MesContainerPackageDetail packageDetail : model.getPackageDetails()) {
|
|
|
|
// for (MesContainerPackageDetail packageDetail : model.getPackageDetails()) {
|
|
|
|
packageDetail.setPid(containerPackage.getId());
|
|
|
|
// packageDetail.setPid(containerPackage.getId());
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
containerPackageDetailRDao.saveAll(model.getPackageDetails());
|
|
|
|
containerPackageDetailRDao.saveAll(model.getPackageDetails());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!CollectionUtils.isEmpty(model.getBindingList())) {
|
|
|
|
if (!CollectionUtils.isEmpty(model.getBindingList())) {
|
|
|
@ -537,7 +545,9 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
|
|
|
|
if (Objects.equals(containerPackage.getPackageStatus(), MesExtEnumUtil.CONTAINER_PACKAGE_STATUS.STATUS_20.getValue())) {
|
|
|
|
if (Objects.equals(containerPackage.getPackageStatus(), MesExtEnumUtil.CONTAINER_PACKAGE_STATUS.STATUS_20.getValue())) {
|
|
|
|
MesPcnException.throwMesBusiException("容器条码【%s】已关箱,请务重复操作!", containerSn.getContainerSn());
|
|
|
|
MesPcnException.throwMesBusiException("容器条码【%s】已关箱,请务重复操作!", containerSn.getContainerSn());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
List<MesContainerPackageDetail> packageDetails = getContainerPackageDetail(model, containerSn);
|
|
|
|
List<MesContainerPackageDetail> packageDetails = containerPackageDetailRDao.findByProperty(
|
|
|
|
|
|
|
|
new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_VALID, "pid"},
|
|
|
|
|
|
|
|
new Object[]{model.getOrganizeCode(), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), containerPackage.getId()});
|
|
|
|
for (MesContainerPackageDetail detail : packageDetails) {
|
|
|
|
for (MesContainerPackageDetail detail : packageDetails) {
|
|
|
|
MesContainerPackageDetailBinding binding = createContainerPackageDetailBinding(containerPackage, detail, MesExtEnumUtil.CONTAINER_RAW_SN_BINDING_STATUS.CLOSE, model.getUserName());
|
|
|
|
MesContainerPackageDetailBinding binding = createContainerPackageDetailBinding(containerPackage, detail, MesExtEnumUtil.CONTAINER_RAW_SN_BINDING_STATUS.CLOSE, model.getUserName());
|
|
|
|
detailBindingRDao.insert(binding);
|
|
|
|
detailBindingRDao.insert(binding);
|
|
|
@ -607,6 +617,7 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
|
|
|
|
containerPackage.setContainerSn(model.getContainerSn());
|
|
|
|
containerPackage.setContainerSn(model.getContainerSn());
|
|
|
|
containerPackage.setPackageStatus(MesExtEnumUtil.CONTAINER_PACKAGE_STATUS.STATUS_10.getValue());
|
|
|
|
containerPackage.setPackageStatus(MesExtEnumUtil.CONTAINER_PACKAGE_STATUS.STATUS_10.getValue());
|
|
|
|
ConvertBean.serviceModelInitialize(containerPackage, model.getUserName());
|
|
|
|
ConvertBean.serviceModelInitialize(containerPackage, model.getUserName());
|
|
|
|
|
|
|
|
containerPackageRDao.insert(containerPackage);
|
|
|
|
return containerPackage;
|
|
|
|
return containerPackage;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|