|
|
|
@ -9,9 +9,13 @@ import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesPartProdGroup;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesPartProdGroupDetail;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesPartProduceType;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.MesCustPartInvoicedRepository;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.MesCustomerPartRepository;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.MesPartProdGroupRepository;
|
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
|
|
|
|
|
import cn.estsh.impp.framework.boot.util.ValidatorBean;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
@ -20,7 +24,14 @@ import java.util.List;
|
|
|
|
|
@Slf4j
|
|
|
|
|
public class MesPartProdGroupDetailService extends BaseMesService<MesPartProdGroupDetail> implements IMesPartProdGroupDetailService {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private MesPartProdGroupRepository partProdGroupRao;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private MesCustPartInvoicedRepository mesCustPartInvoicedRao;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private MesCustomerPartRepository customerPartRao;
|
|
|
|
|
|
|
|
|
|
protected void setPackQueryBean(MesPartProdGroupDetail bean, DdlPackBean packBean) {
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(bean.getPartProdGroupCode(), "partProdGroupCode", packBean);
|
|
|
|
@ -40,6 +51,16 @@ public class MesPartProdGroupDetailService extends BaseMesService<MesPartProdGro
|
|
|
|
|
ValidatorBean.checkNotNull(item.getPartNo(), "零件号不能为空");
|
|
|
|
|
ValidatorBean.checkNotNull(item.getCustPartNo(), "客户零件号不能为空");
|
|
|
|
|
|
|
|
|
|
boolean check = check(item.getOrganizeCode(), item.getCustPartNo(), item.getPartProdGroupCode());
|
|
|
|
|
if (!check){
|
|
|
|
|
throw ImppExceptionBuilder.newInstance()
|
|
|
|
|
.setSystemID(CommonEnumUtil.SOFT_TYPE.MES.getCode())
|
|
|
|
|
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
|
|
|
|
|
.setErrorDetail("待开票表及客户零件表不存在客户零件号【%s】,请检查数据",
|
|
|
|
|
item.getCustPartNo())
|
|
|
|
|
.build();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DdlPackBean custBean = DdlPackBean.getDdlPackBean(item.getOrganizeCode());
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(item.getPartProdGroupCode(), "partProdGroupCode", custBean);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(item.getCustPartNo(), "custPartNo", custBean);
|
|
|
|
@ -53,6 +74,29 @@ public class MesPartProdGroupDetailService extends BaseMesService<MesPartProdGro
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean check(String organizeCode,String custPartNo,String partProdGroupCode){
|
|
|
|
|
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(organizeCode);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(partProdGroupCode,"partProdGroupCode", ddlPackBean);
|
|
|
|
|
List<MesPartProdGroup> mesPartProdGroupList = partProdGroupRao.findByHqlTopWhere(ddlPackBean, 1);
|
|
|
|
|
if (mesPartProdGroupList == null || mesPartProdGroupList.isEmpty()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
String custCode = mesPartProdGroupList.get(0).getCustCode();
|
|
|
|
|
DdlPackBean ddlPackBean1 = DdlPackBean.getDdlPackBean(organizeCode);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(custCode,"custCode",ddlPackBean1);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(custPartNo,"custPartNo",ddlPackBean1);
|
|
|
|
|
|
|
|
|
|
int count = mesCustPartInvoicedRao.findByHqlWhereCount(ddlPackBean1);
|
|
|
|
|
if (count > 0) {
|
|
|
|
|
return true;
|
|
|
|
|
}else {
|
|
|
|
|
DdlPackBean custPackBean = DdlPackBean.getDdlPackBean(organizeCode);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(custCode,"custCode",custPackBean);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(custPartNo,"custPartNo",custPackBean);
|
|
|
|
|
int count1 = customerPartRao.findByHqlWhereCount(custPackBean);
|
|
|
|
|
return count1 > 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public void validateImport(List<MesPartProdGroupDetail> beanList) {
|
|
|
|
|
|
|
|
|
|