修复上料问题

mes-uat-changshu0609^2
jason 3 weeks ago
parent 491aef044b
commit e5c437b997

@ -2,6 +2,7 @@ package cn.estsh.i3plus.ext.mes.pcn.api.base;
import cn.estsh.i3plus.pojo.base.bean.ListPager;
import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.mes.bean.MesContainerPackage;
import cn.estsh.i3plus.pojo.mes.bean.MesContainerSnStation;
import java.util.List;
@ -21,4 +22,5 @@ public interface IMesContainerSnStationService {
void deleteWeaklyByIds(List<Long> idList, String organizeCode, String userName);
void checkStation(String organizeCode, String station);
}

@ -37,6 +37,21 @@ public class MesContainerSnStationController {
@Autowired
private IMesContainerSnService mesContainerSnService;
@GetMapping("/check")
@ApiOperation(value = "查询")
public ResultBean queryCheckStation(String organizeCode, String station) {
try {
ValidatorBean.checkNotNull(organizeCode, "工厂代码不能为空");
ValidatorBean.checkNotNull(station, "站点不能为空");
mesContainerSnStationService.checkStation(organizeCode, station);
return ResultBean.success("校验成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
} catch (ImppBusiException imppException) {
return ResultBean.fail(imppException);
} catch (Exception e) {
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
}
}
@GetMapping("/query")
@ApiOperation(value = "查询")
public ResultBean queryPager(MesContainerSnStation mesContainerSnStation, Pager pager) {

@ -10,14 +10,11 @@ import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.base.common.PagerHelper;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.mes.bean.MesContainerPackageDetail;
import cn.estsh.i3plus.pojo.mes.bean.MesContainerSn;
import cn.estsh.i3plus.pojo.mes.bean.MesContainerSnStation;
import cn.estsh.i3plus.pojo.mes.bean.*;
import cn.estsh.i3plus.pojo.mes.model.report.DataTwoDimensionalModel;
import cn.estsh.i3plus.pojo.mes.model.report.MesCimSeresJisQueueSummaryResponse;
import cn.estsh.i3plus.pojo.mes.repository.MesContainerPackageDetailRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesContainerSnRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesContainerSnStationRepository;
import cn.estsh.i3plus.pojo.mes.repository.*;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@ -47,7 +44,11 @@ public class MesContainerSnStationServiceImpl implements IMesContainerSnStationS
@Autowired
private MesContainerPackageDetailRepository packageDetailRDao;
@Autowired
private MesContainerPackageRepository containerPackageRDao;
@Autowired
private EntityManager entityManager;
@Autowired
private MesStationRepository mesStationRDao;
private void packContainerSnStation(String organizeCode, MesContainerSnStation snStation, Query query) {
query.setParameter("organizeCode", organizeCode)
@ -70,6 +71,7 @@ public class MesContainerSnStationServiceImpl implements IMesContainerSnStationS
if (!StringUtils.isEmpty(mesContainerSnStation.getContainerSn())) {
hql.append(" and mss.top_container_sn=:top_container_sn");
}
hql.append(" group by mss.top_container_sn");
StringBuilder countQueryHql= new StringBuilder();
countQueryHql.append("select count(DISTINCT mss.top_container_sn)");
Query countQuery = entityManager.createNativeQuery(countQueryHql.append(hql).toString());
@ -157,6 +159,14 @@ public class MesContainerSnStationServiceImpl implements IMesContainerSnStationS
@Override
public void doInsert(MesContainerSnStation mesContainerSnStation, String userName) {
final String organizeCode = mesContainerSnStation.getOrganizeCode();
if (!mesStationRDao.isExitByProperty(new String[]{MesConstWords.ORGANIZE_CODE, MesConstWords.IS_VALID, MesConstWords.IS_DELETED, "station"},
new Object[]{organizeCode, CommonEnumUtil.IS_VAILD.VAILD.getValue(), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), mesContainerSnStation.getStation()})) {
throw ImppExceptionBuilder.newInstance()
.setSystemID(CommonEnumUtil.SOFT_TYPE.MES_PCN.getCode())
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
.setErrorDetail("站点【%s】不存在请检测主数据!", mesContainerSnStation.getStation())
.build();
}
String topContainerSn = getTopContainerSn(organizeCode, mesContainerSnStation.getContainerSn());
if (!topContainerSn.equals(mesContainerSnStation.getContainerSn())) {
throw ImppExceptionBuilder.newInstance()
@ -175,6 +185,7 @@ public class MesContainerSnStationServiceImpl implements IMesContainerSnStationS
.setErrorDetail("容器条码【%s】已存在!", mesContainerSnStation.getContainerSn())
.build();
}
checkStationTypeBindContainerSn(organizeCode, mesContainerSnStation.getStation(), mesContainerSnStation.getContainerSn());
List<MesContainerPackageDetail> bottomPackageDetailList = new ArrayList<>();
getBottomPackageDetails(organizeCode, mesContainerSnStation.getContainerSn(), bottomPackageDetailList);
final Set<String> containerSnSet = bottomPackageDetailList.stream().map(MesContainerPackageDetail::getContainerSn).collect(Collectors.toSet());
@ -222,6 +233,52 @@ public class MesContainerSnStationServiceImpl implements IMesContainerSnStationS
}
}
/**
*
* @param organizeCode
* @param station
* @param containerSn
*/
private void checkStationTypeBindContainerSn(String organizeCode, String station, String containerSn) {
MesStation mesStation = mesStationRDao.getByProperty(new String[]{MesConstWords.ORGANIZE_CODE, MesConstWords.IS_VALID, MesConstWords.IS_DELETED, "station"},
new Object[]{organizeCode, CommonEnumUtil.IS_VAILD.VAILD.getValue(), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), station});
if (mesStation == null) {
return;
}
if (mesStation.getStationType() == null) {
throw ImppExceptionBuilder.newInstance()
.setSystemID(CommonEnumUtil.SOFT_TYPE.MES_PCN.getCode())
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
.setErrorDetail("站点【%s】类型不能为空请检查数据!", station)
.build();
}
if (mesStation.getStationType() == MesExtEnumUtil.STATION_TYPE.STATION_TYPE_10.getValue() ||
mesStation.getStationType() == MesExtEnumUtil.STATION_TYPE.STATION_TYPE_20.getValue()) {
// 只能绑定已关箱容器
MesContainerPackage containerPackage = containerPackageRDao.getByProperty(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});
if (containerPackage == null || !Objects.equals(containerPackage.getPackageStatus(), MesExtEnumUtil.CONTAINER_PACKAGE_STATUS.STATUS_20.getValue())) {
throw ImppExceptionBuilder.newInstance()
.setSystemID(CommonEnumUtil.SOFT_TYPE.MES_PCN.getCode())
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
.setErrorDetail("站点[%s]只能绑定已关箱的容器[%s],请检查数据!", station, containerSn)
.build();
}
} else if (mesStation.getStationType() == MesExtEnumUtil.STATION_TYPE.STATION_TYPE_30.getValue() ||
mesStation.getStationType() == MesExtEnumUtil.STATION_TYPE.STATION_TYPE_50.getValue()) {
// 只能绑定未关箱容器
MesContainerPackage containerPackage = containerPackageRDao.getByProperty(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});
if (containerPackage != null && Objects.equals(containerPackage.getPackageStatus(), MesExtEnumUtil.CONTAINER_PACKAGE_STATUS.STATUS_20.getValue())) {
throw ImppExceptionBuilder.newInstance()
.setSystemID(CommonEnumUtil.SOFT_TYPE.MES_PCN.getCode())
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
.setErrorDetail("站点[%s]只能绑定未关箱的容器[%s],请检查数据!", station, containerSn)
.build();
}
}
}
@Override
public void deleteWeaklyByIds(List<Long> idList, String organizeCode, String userName) {
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(organizeCode);
@ -232,4 +289,16 @@ public class MesContainerSnStationServiceImpl implements IMesContainerSnStationS
ddlPackBean);
}
@Override
public void checkStation(String organizeCode, String station) {
if (!mesContainerSnStationRepository.isExitByProperty(new String[]{MesConstWords.ORGANIZE_CODE, MesConstWords.IS_VALID, MesConstWords.IS_DELETED, "station"},
new Object[]{organizeCode, CommonEnumUtil.IS_VAILD.VAILD.getValue(), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), station})) {
throw ImppExceptionBuilder.newInstance()
.setSystemID(CommonEnumUtil.SOFT_TYPE.MES_PCN.getCode())
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
.setErrorDetail("站点【%s】不存在请检查数据!", station)
.build();
}
}
}

@ -57,10 +57,10 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
@Autowired
private SnowflakeIdMaker snowflakeIdMaker;
private MesContainerPackage getContainerPackage(MesContainerSnBindModel model, MesContainerSn containerSn) {
private MesContainerPackage getContainerPackage(MesContainerSnBindModel model, String containerSn) {
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[]{model.getOrganizeCode(), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), containerSn});
return containerPackage;
}
@ -71,12 +71,12 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
return packageDetails;
}
private List<MesContainerPartsModel> getContainerParts(String organizeCode, String containerTypeCode, String containerSn) {
private List<MesContainerPartsModel> getContainerParts(String organizeCode, MesContainerType containerType, String containerSn) {
List<MesContainerPartsModel> result = new ArrayList<>();
Set<String> partNoSet = new HashSet<>();
List<MesContainerSnPart> snPartList = containerSnPartRDao.findByProperty(
new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_VALID, "containerTypeCode", "containerSn"},
new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), containerTypeCode, containerSn});
new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), containerType.getContainerTypeCode(), containerSn});
if (!CollectionUtils.isEmpty(snPartList)) {
for (MesContainerSnPart snPart : snPartList) {
if (StringUtils.isEmpty(snPart.getPartNo())) {
@ -85,6 +85,7 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
partNoSet.add(snPart.getPartNo());
MesContainerPartsModel model = MesContainerPartsModel.builder()
.containerType(containerType.getContainerType())
.partNo(snPart.getPartNo())
.partName(snPart.getPartName())
.matchType(snPart.getMatchType())
@ -97,7 +98,7 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
List<MesContainerTypePart> partList = containerTypePartRDao.findByProperty(
new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_VALID, "containerTypeCode"},
new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), containerTypeCode});
new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), containerType.getContainerTypeCode()});
if (!CollectionUtils.isEmpty(partList)) {
for (MesContainerTypePart partPart : partList) {
if (StringUtils.isEmpty(partPart.getPartNo())) {
@ -108,6 +109,7 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
continue;
}
MesContainerPartsModel model = MesContainerPartsModel.builder()
.containerType(containerType.getContainerType())
.partNo(partPart.getPartNo())
.partName(partPart.getPartName())
.matchType(partPart.getMatchType())
@ -219,7 +221,7 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
model.setBindIsChoosePart(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue());
if (Objects.equals(containerType.getBindIsChoosePart(), CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue())) {
List<MesContainerPartsModel> partsModelList = getContainerParts(model.getOrganizeCode(), containerType.getContainerTypeCode(), containerSn.getContainerSn());
List<MesContainerPartsModel> partsModelList = getContainerParts(model.getOrganizeCode(), containerType, containerSn.getContainerSn());
if (CollectionUtils.isEmpty(partsModelList)) {
MesPcnException.throwMesBusiException("容器条码[%s]或容器类型代码[%s]未维护与容器关系,请检查数据", containerSn.getContainerSn(), containerType.getContainerTypeCode());
}
@ -346,8 +348,14 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
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;
}
MesContainerPackageDetailBinding binding = createContainerPackageDetailBinding(containerPackage, detail, MesExtEnumUtil.CONTAINER_RAW_SN_BINDING_STATUS.UN_BINDING, username);
MesContainerPackageDetailBinding binding = createContainerPackageDetailBinding(detail, MesExtEnumUtil.CONTAINER_RAW_SN_BINDING_STATUS.UN_BINDING, username);
detailBindingRDao.insert(binding);
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(detail.getBarCode(), "containerSn", ddlPackBean);
containerSnStationRDao.updateByProperties(
new String[]{"modifyUser", "modifyDatetime", "isDeleted"},
new Object[]{username, TimeTool.getNowTime(true), CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()},
ddlPackBean);
}
// 容器置为拆箱状态。
containerPackage.setPackageStatus(MesExtEnumUtil.CONTAINER_PACKAGE_STATUS.STATUS_30.getValue());
@ -425,15 +433,27 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
barcode = bottomPackageDetails.get(0).getBarCode();
}
MesContainerPartsModel containerPart = checkProduceSn(model.getOrganizeCode(), containerSn, barcode, model.getPartNo());
MesContainerPartsModel containerPart = null;
Map<String, Object> matchResult = null;
List<MesContainerPartsModel> containerPartsModels = getContainerParts(model.getOrganizeCode(), containerType, containerSn.getContainerSn());
for (MesContainerPartsModel containerPartsModel : containerPartsModels) {
// 调用策略校验条码与容器是否可以绑定
matchResult = ContainerBindManager.INSTANCE.matchNumberRule(model.getOrganizeCode(), barcode, containerPartsModel);
assert matchResult != null;
if (Objects.equals(matchResult.get(MesPcnExtConstWords.RESULT), true)) {
containerPart = containerPartsModel;
break;
}
}
if (containerPart == null) {
MesPcnException.throwMesBusiException("容器条码[%s]或容器类型代码[%s]未维护与零件关系,请检查数据", containerSn.getContainerSn(), containerSn.getContainerTypeCode());
}
if (!StringUtils.isEmpty(model.getPartNo()) && !Objects.equals(model.getPartNo(), containerPart.getPartNo())) {
MesPcnException.throwMesBusiException("条码[%s]的零件号【%s】与选择的零件不匹配请检查数据", model.getBarCode(), model.getPartNo());
}
containerPart.setContainerType(containerType.getContainerType());
containerPart.setContainerPackage(containerPackage);
// 调用策略校验条码与容器是否可以绑定
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);
List<MesContainerPackageDetail> combPackageDetails = new ArrayList<>(oldPackageDetails);
@ -446,12 +466,12 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
}
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()));
Map<String, Object> checkQtyResult = checkQtyService.doCheck(model.getOrganizeCode(), containerPackage, combPackageDetails, containerPartsModels);
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());
MesContainerPackageDetailBinding binding = createContainerPackageDetailBinding(packageDetail, MesExtEnumUtil.CONTAINER_RAW_SN_BINDING_STATUS.BINDING, model.getUserName());
packageDetails.add(packageDetail);
model.setContainerPackage(containerPackage);
@ -485,7 +505,7 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
public MesContainerSnBindModel doClear(MesContainerSnBindModel model) {
//校验容器条码
MesContainerSn containerSn = containerSnService.checkContainerSn(model.getOrganizeCode(), model.getContainerSn());
MesContainerPackage containerPackage = getContainerPackage(model, containerSn);
MesContainerPackage containerPackage = getContainerPackage(model, containerSn.getContainerSn());
if (containerPackage == null) {
MesPcnException.throwMesBusiException("容器条码[%s]未生成容器条码上料主表,请检查数据", containerSn.getContainerSn());
}
@ -504,9 +524,10 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
containerPackageRDao.update(containerPackage);
for (MesContainerPackageDetail packageDetail : packageDetails) {
MesContainerPackageDetailBinding binding = createContainerPackageDetailBinding(containerPackage, packageDetail, MesExtEnumUtil.CONTAINER_RAW_SN_BINDING_STATUS.UN_BINDING, model.getUserName());
MesContainerPackageDetailBinding binding = createContainerPackageDetailBinding(packageDetail, MesExtEnumUtil.CONTAINER_RAW_SN_BINDING_STATUS.UN_BINDING, model.getUserName());
detailBindingRDao.insert(binding);
}
deleteContainerSnStation(containerPackage, model.getUserName());
model.setPackageDetails(new ArrayList<>());
return model;
}
@ -515,16 +536,27 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
public MesContainerSnBindModel doDeleteDetails(MesContainerSnBindModel model) {
//校验容器条码
MesContainerSn containerSn = containerSnService.checkContainerSn(model.getOrganizeCode(), model.getContainerSn());
MesContainerPackage containerPackage = getContainerPackage(model, containerSn);
MesContainerPackage containerPackage = getContainerPackage(model, containerSn.getContainerSn());
if (containerPackage == null) {
MesPcnException.throwMesBusiException("容器条码[%s]未生成容器条码上料主表,请检查数据", containerSn.getContainerSn());
}
List<Long> deleteDetailIds = new ArrayList<>();
for (MesContainerPackageDetail detail : model.getPackageDetails()) {
MesContainerPackageDetailBinding binding = createContainerPackageDetailBinding(containerPackage, detail, MesExtEnumUtil.CONTAINER_RAW_SN_BINDING_STATUS.UN_BINDING, model.getUserName());
MesContainerPackageDetailBinding binding = createContainerPackageDetailBinding(detail, MesExtEnumUtil.CONTAINER_RAW_SN_BINDING_STATUS.UN_BINDING, model.getUserName());
detailBindingRDao.insert(binding);
deleteDetailIds.add(detail.getId());
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(detail.getBarCode(), "containerSn", ddlPackBean);
containerSnStationRDao.updateByProperties(
new String[]{"modifyUser", "modifyDatetime", "isDeleted"},
new Object[]{model.getUserName(), TimeTool.getNowTime(true), CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()},
ddlPackBean);
MesContainerPackage detailPackage = getContainerPackage(model, detail.getBarCode());
if (detailPackage != null) {
deleteContainerSnStation(detailPackage, model.getUserName());
}
}
containerPackageDetailRDao.deleteWeaklyByIds(deleteDetailIds.toArray(new Long[0]), model.getUserName());
@ -540,7 +572,7 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
public MesContainerSnBindModel doClosePackage(MesContainerSnBindModel model) {
//校验容器条码
MesContainerSn containerSn = containerSnService.checkContainerSn(model.getOrganizeCode(), model.getContainerSn());
MesContainerPackage containerPackage = getContainerPackage(model, containerSn);
MesContainerPackage containerPackage = getContainerPackage(model, containerSn.getContainerSn());
if (containerPackage == null) {
MesPcnException.throwMesBusiException("容器条码[%s]未生成容器条码上料主表,请检查数据", containerSn.getContainerSn());
}
@ -551,7 +583,7 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
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) {
MesContainerPackageDetailBinding binding = createContainerPackageDetailBinding(containerPackage, detail, MesExtEnumUtil.CONTAINER_RAW_SN_BINDING_STATUS.CLOSE, model.getUserName());
MesContainerPackageDetailBinding binding = createContainerPackageDetailBinding(detail, MesExtEnumUtil.CONTAINER_RAW_SN_BINDING_STATUS.CLOSE, model.getUserName());
detailBindingRDao.insert(binding);
}
@ -567,7 +599,7 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
public MesContainerSnBindModel doOpenPackage(MesContainerSnBindModel model) {
//校验容器条码
MesContainerSn containerSn = containerSnService.checkContainerSn(model.getOrganizeCode(), model.getContainerSn());
MesContainerPackage containerPackage = getContainerPackage(model, containerSn);
MesContainerPackage containerPackage = getContainerPackage(model, containerSn.getContainerSn());
if (containerPackage == null) {
MesPcnException.throwMesBusiException("容器条码[%s]未生成容器条码上料主表,请检查数据", containerSn.getContainerSn());
}
@ -644,12 +676,12 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
return detail;
}
private MesContainerPackageDetailBinding createContainerPackageDetailBinding(MesContainerPackage containerPackage, MesContainerPackageDetail packageDetail, MesExtEnumUtil.CONTAINER_RAW_SN_BINDING_STATUS snBindingStatus, String userName) {
private MesContainerPackageDetailBinding createContainerPackageDetailBinding(MesContainerPackageDetail packageDetail, MesExtEnumUtil.CONTAINER_RAW_SN_BINDING_STATUS snBindingStatus, String userName) {
MesContainerPackageDetailBinding binding = new MesContainerPackageDetailBinding();
binding.setOrganizeCode(containerPackage.getOrganizeCode());
binding.setPid(containerPackage.getId());
binding.setOrganizeCode(packageDetail.getOrganizeCode());
binding.setPid(packageDetail.getPid());
binding.setSourceId(packageDetail.getId());
binding.setContainerSn(containerPackage.getContainerSn());
binding.setContainerSn(packageDetail.getContainerSn());
binding.setBarCode(packageDetail.getBarCode());
binding.setQty(packageDetail.getQty());
binding.setSnStatus(snBindingStatus.getValue());
@ -657,4 +689,18 @@ public class MesContainerSnBindServiceImpl implements IMesContainerSnBindService
ConvertBean.serviceModelInitialize(binding, userName);
return binding;
}
private void deleteContainerSnStation(MesContainerPackage containerPackage, String userName) {
final String organizeCode = containerPackage.getOrganizeCode();
List<MesContainerPackageDetail> bottomPackageDetailList = new ArrayList<>();
getBottomPackageDetails(organizeCode, containerPackage, bottomPackageDetailList);
final Set<String> containerSnSet = bottomPackageDetailList.stream().map(MesContainerPackageDetail::getContainerSn).collect(Collectors.toSet());
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getInPackList(new ArrayList<>(containerSnSet), "containerSn", ddlPackBean);
containerSnStationRDao.updateByProperties(
new String[]{"modifyUser", "modifyDatetime", "isDeleted"},
new Object[]{userName, TimeTool.getNowTime(true), CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()},
ddlPackBean);
}
}

@ -2,11 +2,8 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.rulematch.containerbi
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesContainerBindDispatchService;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesContainerPartsModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.mes.bean.MesContainerSnPart;
import cn.estsh.i3plus.pojo.mes.bean.MesContainerTypePart;
import cn.estsh.i3plus.pojo.mes.bean.MesRawSnWeightRecord;
import cn.estsh.i3plus.pojo.mes.repository.MesContainerSnPartRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesContainerTypePartRepository;
@ -29,40 +26,6 @@ public class MesAbstractContainerBindDispatchService implements IMesContainerBin
ContainerBindManager.INSTANCE.register(containerType, matchType, this);
}
protected MesContainerPartsModel getContainerParts(String organizeCode, String containerTypeCode, String containerSn, String partNo) {
MesContainerPartsModel model = null;
MesContainerSnPart snPart = containerSnPartRDao.getByProperty(
new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_VALID, "containerTypeCode", "containerSn", "partNo"},
new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), containerTypeCode, containerSn, partNo});
if (snPart == null) {
MesContainerTypePart typePart = containerTypePartRDao.getByProperty(
new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_VALID, "containerTypeCode", "partNo"},
new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), containerTypeCode, partNo});
if (typePart != null) {
model = MesContainerPartsModel.builder()
.partNo(typePart.getPartNo())
.partName(typePart.getPartName())
.matchType(typePart.getMatchType())
.matchRule(typePart.getMatchRule())
.qty(typePart.getQty())
.build();
}
} else {
model = MesContainerPartsModel.builder()
.partNo(snPart.getPartNo())
.partName(snPart.getPartName())
.matchType(snPart.getMatchType())
.matchRule(snPart.getMatchRule())
.qty(snPart.getQty())
.build();
}
if (model == null) {
MesPcnException.throwMesBusiException("容器条码【%s】或容器类型代码【%s】未维护与零件关系请检查数据", containerSn, containerTypeCode, partNo);
}
return model;
}
protected Double getRawSnWeightQty(String organizeCode, String barcode) {
MesRawSnWeightRecord weightRecord = rawSnWeightRecordRDao.getByProperty(
new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_VALID, "barCode"},

@ -0,0 +1,147 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.rulematch.containerbind;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.rulematch.MesNumberRuleMatchRegularExpressionService;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesContainerPartsModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.platform.common.tool.CheckTool;
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.mes.bean.*;
import cn.estsh.i3plus.pojo.mes.repository.MesCustPartInvoicedRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesCustomerPartRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesPackingDefineRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesPartRepository;
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.StringUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/**
*
*/
@Slf4j
@Component
public class MesContainerBindCooperationPackageService extends MesAbstractContainerBindDispatchService {
@Autowired
private MesPartRepository mesPartRDao;
@Autowired
private MesPackingDefineRepository mesPackingDefineRDao;
@Autowired
private MesCustomerPartRepository mesCustomerPartRDao;
@Autowired
private MesCustPartInvoicedRepository partInvoicedRao;
public MesContainerBindCooperationPackageService() {
super(null, MesExtEnumUtil.CONTAINER_PART_MATCH_TYPE.MATCH_TYPE_40);
}
@Override
public Map<String, Object> matchNumberRule(String organizeCode, String barcode, MesContainerPartsModel model) {
Map<String, Object> result = new HashMap<>();
result.put(MesPcnExtConstWords.DATA_TYPE, MesExtEnumUtil.CONTAINER_BARCODE_DATA_TYPE.STATUS_20.getValue());
result.put(MesPcnExtConstWords.RESULT, false);
List<MesPackingDefine> packingDefines = mesPackingDefineRDao.findByProperty(new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_VALID},
new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue()});
for (MesPackingDefine packingDefine : packingDefines) {
Double qty = checkPackingDefine(organizeCode, packingDefine, barcode);
if (qty != null && qty > 0) {
result.put(MesPcnExtConstWords.QTY, qty);
result.put(MesPcnExtConstWords.RESULT, true);
return result;
}
}
return result;
}
private Double checkPackingDefine(String organizeCode, MesPackingDefine packingDefine, String barcode) {
//解析获取信息保存
if (StringUtils.isEmpty(packingDefine.getSplitChar())) {
return null;
}
try {
String[] split = barcode.split("\\" + packingDefine.getSplitChar());
//工厂校验
checkOrganizeCode(organizeCode, packingDefine, split);
//获取物料信息是否存在
getMesPart(organizeCode, packingDefine, split);
//获取数量信息是否存在
return getQty(packingDefine, split);
} catch (Exception ex) {
return null;
}
}
private void checkOrganizeCode(String organizeCode, MesPackingDefine packingDefine, String[] split) {
if (Objects.equals(packingDefine.getCheckOrganizeCode(), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue())) {
return;
}
if (StringUtils.isEmpty(packingDefine.getOrganizeIndex()) || packingDefine.getOrganizeIndex() > split.length
|| StringUtils.isEmpty(split[packingDefine.getOrganizeIndex() - 1])) {
MesPcnException.throwMesBusiException("工厂所在位置不存在,请检查数据!");
}
String splitOrganizeCode = split[packingDefine.getOrganizeIndex() - 1];
if (!Objects.equals(splitOrganizeCode, organizeCode)) {
MesPcnException.throwMesBusiException("箱条码工厂[%s]和当前工厂[%s]不匹配,请检查数据!", splitOrganizeCode, organizeCode);
}
}
private void getMesPart(String organizeCode, MesPackingDefine packingDefine, String[] split) {
if (StringUtils.isEmpty(packingDefine.getPartNoIndex()) || packingDefine.getPartNoIndex() > split.length
|| StringUtils.isEmpty(split[packingDefine.getPartNoIndex() - 1])) {
MesPcnException.throwMesBusiException("物料号所在位置不存在,请检查数据!");
}
String partNo = split[packingDefine.getPartNoIndex() - 1];
if (Objects.equals(packingDefine.getPackBarcodeCustPartNo(), CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue())) {
DdlPackBean invoicePackBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(partNo, MesPcnExtConstWords.CUST_PART_NO, invoicePackBean);
MesCustPartInvoiced invoiced = partInvoicedRao.getByProperty(invoicePackBean);
if (invoiced != null && !StringUtils.isEmpty(invoiced.getPartNo())) {
partNo = invoiced.getPartNo();
} else {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(partNo, MesPcnExtConstWords.CUST_PART_NO, packBean);
MesCustomerPart mesCustomerPart = mesCustomerPartRDao.getByProperty(packBean);
if (mesCustomerPart == null) {
MesPcnException.throwMesBusiException("客户零件号[%s]信息不存在,请检查数据!", partNo);
}
partNo = mesCustomerPart.getErpPartNo();
}
if (StringUtils.isEmpty(partNo)) {
MesPcnException.throwMesBusiException("客户零件号[%s]未绑定物料号数据,请检查数据!", split[packingDefine.getPartNoIndex() - 1]);
}
}
checkPart(organizeCode, partNo);
}
private void checkPart(String organizeCode, String partNo) {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(partNo, MesPcnExtConstWords.PART_NO, packBean);
MesPart mesPart = mesPartRDao.getByProperty(packBean);
if (Objects.isNull(mesPart)) {
MesPcnException.throwMesBusiException("物料[%s]信息不存在,请检查数据!", partNo);
}
}
private Double getQty(MesPackingDefine packingDefine, String[] split) {
if (StringUtils.isEmpty(packingDefine.getQtyIndex()) || packingDefine.getQtyIndex() > split.length
|| StringUtils.isEmpty(split[packingDefine.getQtyIndex() - 1])) {
MesPcnException.throwMesBusiException("数量所在位置不存在,请检查数据!");
}
//校验是否数字
if (!CheckTool.isNumber(split[packingDefine.getQtyIndex() - 1])) {
MesPcnException.throwMesBusiException("数量所在位置不为数字类型,请检查数据!");
}
return Double.parseDouble(split[packingDefine.getQtyIndex() - 1]);
}
}

@ -1,5 +1,6 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.rulematch.containerbind;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.rulematch.MesNumberRuleMatchRegularExpressionService;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesContainerPartsModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
@ -23,6 +24,8 @@ import java.util.Objects;
public class MesContainerBindCooperationPartService extends MesAbstractContainerBindDispatchService {
@Autowired
private MesPartRepository mesPartRDao;
@Autowired
private MesNumberRuleMatchRegularExpressionService matchRegularService;
public MesContainerBindCooperationPartService() {
super(null, MesExtEnumUtil.CONTAINER_PART_MATCH_TYPE.MATCH_TYPE_20);
@ -31,7 +34,13 @@ public class MesContainerBindCooperationPartService extends MesAbstractContainer
@Override
public Map<String, Object> matchNumberRule(String organizeCode, String barcode, MesContainerPartsModel model) {
Map<String, Object> result = new HashMap<>();
result.put(MesPcnExtConstWords.RESULT, true);
result.put(MesPcnExtConstWords.RESULT, false);
result.put(MesPcnExtConstWords.DATA_TYPE, MesExtEnumUtil.CONTAINER_BARCODE_DATA_TYPE.STATUS_10.getValue());
Map<String, Object> matchNumberResult = matchRegularService.matchNumberRule(organizeCode, barcode, "", model.getMatchRule());
if (!Objects.equals(matchNumberResult.get(MesPcnExtConstWords.RESULT), true)) {
return matchNumberResult;
}
MesPart mesPart = mesPartRDao.getByProperty(
new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_VALID, "partNo"},
@ -40,11 +49,11 @@ public class MesContainerBindCooperationPartService extends MesAbstractContainer
MesPcnException.throwMesBusiException("零件号【%s】在物料表不存在, 请检查数据!", model.getPartNo());
}
result.put(MesPcnExtConstWords.DATA_TYPE, MesExtEnumUtil.CONTAINER_BARCODE_DATA_TYPE.STATUS_10.getValue());
if (Objects.equals(model.getContainerType(), MesExtEnumUtil.CONTAINER_TYPE.CONTAINER_TYPE_50.getValue())) {
Double netWeight = getRawSnWeightQty(organizeCode, barcode);
result.put(MesPcnExtConstWords.QTY, netWeight);
}
result.put(MesPcnExtConstWords.RESULT, true);
return result;
}
}

@ -33,10 +33,13 @@ public class MesContainerBindPackageSnService extends MesAbstractContainerBindDi
@Override
public Map<String, Object> matchNumberRule(String organizeCode, String barcode, MesContainerPartsModel model) {
Map<String, Object> result = new HashMap<>();
result.put(MesPcnExtConstWords.RESULT, true);
result.put(MesPcnExtConstWords.RESULT, false);
result.put(MesPcnExtConstWords.DATA_TYPE, MesExtEnumUtil.CONTAINER_BARCODE_DATA_TYPE.STATUS_20.getValue());
String[] splitBarcode = barcode.split("\\|");
if (splitBarcode.length < 8) {
MesPcnException.throwMesBusiException("自制件箱码【%s】格式不对, 请检查数据!", barcode);
result.put(MesPcnExtConstWords.MESSAGE, String.format("自制件箱码【%s】格式不对, 请检查数据!", barcode));
return result;
}
String barOrganizeCode = splitBarcode[2];
if (!Objects.equals(barOrganizeCode, organizeCode)) {
@ -69,7 +72,7 @@ public class MesContainerBindPackageSnService extends MesAbstractContainerBindDi
} catch (NumberFormatException e) {
MesPcnException.throwMesBusiException("自制件箱码【%s】的数量【%s】格式错误, 请检查数据!", barcode, barQty);
}
result.put(MesPcnExtConstWords.DATA_TYPE, MesExtEnumUtil.CONTAINER_BARCODE_DATA_TYPE.STATUS_20.getValue());
result.put(MesPcnExtConstWords.RESULT, true);
return result;
}

@ -32,13 +32,15 @@ public class MesContainerBindProductSnService extends MesAbstractContainerBindDi
@Override
public Map<String, Object> matchNumberRule(String organizeCode, String barcode, MesContainerPartsModel model) {
Map<String, Object> result = new HashMap<>();
result.put(MesPcnExtConstWords.RESULT, true);
result.put(MesPcnExtConstWords.RESULT, false);
result.put(MesPcnExtConstWords.DATA_TYPE, MesExtEnumUtil.CONTAINER_BARCODE_DATA_TYPE.STATUS_10.getValue());
MesProduceSn produceSn = produceSnRDao.getByProperty(
new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_VALID, "productSn"},
new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), barcode});
if (produceSn == null) {
MesPcnException.throwMesBusiException("扫描条码【%s】在条码表不存在, 请检查数据!", barcode);
result.put(MesPcnExtConstWords.MESSAGE, String.format("扫描条码【%s】在条码表不存在, 请检查数据!", barcode));
return result;
}
if (!Objects.equals(produceSn.getSnStatus(), MesExtEnumUtil.PRODUCE_SN_STATUS.CREATE.getValue()) &&
@ -51,11 +53,11 @@ public class MesContainerBindProductSnService extends MesAbstractContainerBindDi
MesPcnException.throwMesBusiException("扫描条码【%s】的质量状态必须为“合格”或“可疑转正常”, 请检查数据!", barcode);
}
result.put(MesPcnExtConstWords.DATA_TYPE, MesExtEnumUtil.CONTAINER_BARCODE_DATA_TYPE.STATUS_10.getValue());
if (Objects.equals(model.getContainerType(), MesExtEnumUtil.CONTAINER_TYPE.CONTAINER_TYPE_50.getValue())) {
Double netWeight = getRawSnWeightQty(organizeCode, barcode);
result.put(MesPcnExtConstWords.QTY, netWeight);
}
result.put(MesPcnExtConstWords.RESULT, true);
return result;
}
}

Loading…
Cancel
Save