|
|
@ -1,12 +1,24 @@
|
|
|
|
package cn.estsh.i3plus.ext.mes.apiservice.serviceimpl.busi;
|
|
|
|
package cn.estsh.i3plus.ext.mes.apiservice.serviceimpl.busi;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.api.busi.IMesSpotCheckOrderPartService;
|
|
|
|
import cn.estsh.i3plus.ext.mes.api.busi.IMesSpotCheckOrderPartService;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.apiservice.config.AuthUtilExt;
|
|
|
|
import cn.estsh.i3plus.ext.mes.apiservice.serviceimpl.base.BaseMesService;
|
|
|
|
import cn.estsh.i3plus.ext.mes.apiservice.serviceimpl.base.BaseMesService;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.platform.common.exception.ImppExceptionEnum;
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
|
|
|
|
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.base.tool.DdlPreparedPack;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesSpotCheckOrderPart;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesSpotCheckOrderPart;
|
|
|
|
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
|
|
|
|
|
|
|
|
import cn.estsh.impp.framework.boot.util.ValidatorBean;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
@Service
|
|
|
|
@Slf4j
|
|
|
|
@Slf4j
|
|
|
@ -15,4 +27,54 @@ public class MesSpotCheckOrderPartService extends BaseMesService<MesSpotCheckOrd
|
|
|
|
protected void setPackQueryBean(MesSpotCheckOrderPart bean, DdlPackBean packBean) {
|
|
|
|
protected void setPackQueryBean(MesSpotCheckOrderPart bean, DdlPackBean packBean) {
|
|
|
|
DdlPreparedPack.getNumEqualPack(bean.getSpotCheckOrderId(), "spotCheckOrderId", packBean);
|
|
|
|
DdlPreparedPack.getNumEqualPack(bean.getSpotCheckOrderId(), "spotCheckOrderId", packBean);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void validateImport(List<MesSpotCheckOrderPart> beanList) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 数据校验
|
|
|
|
|
|
|
|
ValidatorBean.checkNotNull(beanList.get(0).getSpotCheckOrderId(), "点检单不能为空");
|
|
|
|
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean(AuthUtilExt.getOrganizeCode());
|
|
|
|
|
|
|
|
DdlPreparedPack.getNumEqualPack(beanList.get(0).getSpotCheckOrderId(), "spotCheckOrderId", packBean);
|
|
|
|
|
|
|
|
List<MesSpotCheckOrderPart> orderPartList = baseRDao.findByHqlWhere(packBean);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, List<MesSpotCheckOrderPart>> orderPartMap = orderPartList.stream().collect(Collectors.groupingBy(k -> k.getPartNo()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<String> partNoList = new ArrayList<>();
|
|
|
|
|
|
|
|
List<String> repeatPartNoList = new ArrayList<>();
|
|
|
|
|
|
|
|
Map<String, String> importMap = new HashMap<>();
|
|
|
|
|
|
|
|
for (MesSpotCheckOrderPart bean : beanList) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 数据校验
|
|
|
|
|
|
|
|
ValidatorBean.checkNotNull(bean.getSpotCheckOrderId(), "点检单不能为空");
|
|
|
|
|
|
|
|
ValidatorBean.checkNotNull(bean.getPartNo(), "零件号不能为空");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (orderPartMap.containsKey(bean.getPartNo())) {
|
|
|
|
|
|
|
|
partNoList.add(bean.getPartNo());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (importMap.containsKey(bean.getPartNo())) {
|
|
|
|
|
|
|
|
repeatPartNoList.add(bean.getPartNo());
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
importMap.put(bean.getPartNo(), bean.getPartNo());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!CollectionUtils.isEmpty(partNoList)) {
|
|
|
|
|
|
|
|
throw ImppExceptionBuilder.newInstance()
|
|
|
|
|
|
|
|
.setSystemID(CommonEnumUtil.SOFT_TYPE.MES.getCode())
|
|
|
|
|
|
|
|
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
|
|
|
|
|
|
|
|
.setErrorDetail("点检单【%s】零件号【%s】已经存在,请检查数据", beanList.get(0).getSpotCheckOrderId(), partNoList)
|
|
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!CollectionUtils.isEmpty(repeatPartNoList)) {
|
|
|
|
|
|
|
|
throw ImppExceptionBuilder.newInstance()
|
|
|
|
|
|
|
|
.setSystemID(CommonEnumUtil.SOFT_TYPE.MES.getCode())
|
|
|
|
|
|
|
|
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
|
|
|
|
|
|
|
|
.setErrorDetail("添加零件号中【%s】零件号重复,请检查数据", repeatPartNoList)
|
|
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|