|
|
|
@ -89,12 +89,6 @@ public class ErpContractInfoServiceImpl implements IErpContractInfoService {
|
|
|
|
.eq(bo.getContractDeptId() != null, ErpContractInfo::getContractDeptId, bo.getContractDeptId())
|
|
|
|
.eq(bo.getContractDeptId() != null, ErpContractInfo::getContractDeptId, bo.getContractDeptId())
|
|
|
|
.eq(bo.getContractDate() != null, ErpContractInfo::getContractDate, bo.getContractDate())
|
|
|
|
.eq(bo.getContractDate() != null, ErpContractInfo::getContractDate, bo.getContractDate())
|
|
|
|
.eq(bo.getTotalPrice() != null, ErpContractInfo::getTotalPrice, bo.getTotalPrice())
|
|
|
|
.eq(bo.getTotalPrice() != null, ErpContractInfo::getTotalPrice, bo.getTotalPrice())
|
|
|
|
.eq(bo.getACustomerId() != null, ErpContractInfo::getACustomerId, bo.getACustomerId())
|
|
|
|
|
|
|
|
.eq(StringUtils.isNotBlank(bo.getARepresent()), ErpContractInfo::getARepresent, bo.getARepresent())
|
|
|
|
|
|
|
|
.eq(bo.getADate() != null, ErpContractInfo::getADate, bo.getADate())
|
|
|
|
|
|
|
|
.eq(bo.getBCustomerId() != null, ErpContractInfo::getBCustomerId, bo.getBCustomerId())
|
|
|
|
|
|
|
|
.eq(StringUtils.isNotBlank(bo.getBRepresent()), ErpContractInfo::getBRepresent, bo.getBRepresent())
|
|
|
|
|
|
|
|
.eq(bo.getBDate() != null, ErpContractInfo::getBDate, bo.getBDate())
|
|
|
|
|
|
|
|
.eq(StringUtils.isNotBlank(bo.getContractStatus()), ErpContractInfo::getContractStatus, bo.getContractStatus())
|
|
|
|
.eq(StringUtils.isNotBlank(bo.getContractStatus()), ErpContractInfo::getContractStatus, bo.getContractStatus())
|
|
|
|
.eq(StringUtils.isNotBlank(bo.getFlowStatus()), ErpContractInfo::getFlowStatus, bo.getFlowStatus())
|
|
|
|
.eq(StringUtils.isNotBlank(bo.getFlowStatus()), ErpContractInfo::getFlowStatus, bo.getFlowStatus())
|
|
|
|
.eq(bo.getTemplateId() != null, ErpContractInfo::getTemplateId, bo.getTemplateId())
|
|
|
|
.eq(bo.getTemplateId() != null, ErpContractInfo::getTemplateId, bo.getTemplateId())
|
|
|
|
@ -117,13 +111,13 @@ public class ErpContractInfoServiceImpl implements IErpContractInfoService {
|
|
|
|
public Boolean insertByBo(ErpContractInfoBo bo) {
|
|
|
|
public Boolean insertByBo(ErpContractInfoBo bo) {
|
|
|
|
ErpContractInfo add = MapstructUtils.convert(bo, ErpContractInfo.class);
|
|
|
|
ErpContractInfo add = MapstructUtils.convert(bo, ErpContractInfo.class);
|
|
|
|
validEntityBeforeSave(add);
|
|
|
|
validEntityBeforeSave(add);
|
|
|
|
List<ErpContractMaterial> contractMaterielList = bo.getContractMaterielList();
|
|
|
|
List<ErpContractMaterial> contractMaterialList = bo.getContractMaterialList();
|
|
|
|
boolean flag = baseMapper.insert(add) > 0;
|
|
|
|
boolean flag = baseMapper.insert(add) > 0;
|
|
|
|
if (flag) {
|
|
|
|
if (flag && contractMaterialList != null && !contractMaterialList.isEmpty()) {
|
|
|
|
bo.setContractId(add.getContractId());
|
|
|
|
bo.setContractId(add.getContractId());
|
|
|
|
for (ErpContractMaterial erpContractMateriel : contractMaterielList) {
|
|
|
|
for (ErpContractMaterial erpContractMaterial : contractMaterialList) {
|
|
|
|
erpContractMateriel.setContractId(add.getContractId());
|
|
|
|
erpContractMaterial.setContractId(add.getContractId());
|
|
|
|
contractMaterialMapper.insert(erpContractMateriel);
|
|
|
|
contractMaterialMapper.insert(erpContractMaterial);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return flag;
|
|
|
|
return flag;
|
|
|
|
@ -140,22 +134,22 @@ public class ErpContractInfoServiceImpl implements IErpContractInfoService {
|
|
|
|
public Boolean updateByBo(ErpContractInfoBo bo) {
|
|
|
|
public Boolean updateByBo(ErpContractInfoBo bo) {
|
|
|
|
ErpContractInfo update = MapstructUtils.convert(bo, ErpContractInfo.class);
|
|
|
|
ErpContractInfo update = MapstructUtils.convert(bo, ErpContractInfo.class);
|
|
|
|
validEntityBeforeSave(update);
|
|
|
|
validEntityBeforeSave(update);
|
|
|
|
List<ErpContractMaterial> contractMaterielList = bo.getContractMaterielList();
|
|
|
|
List<ErpContractMaterial> contractMaterialList = bo.getContractMaterialList();
|
|
|
|
MPJLambdaWrapper<ErpContractMaterial> lqwRecord = JoinWrappers.lambda(ErpContractMaterial.class);
|
|
|
|
MPJLambdaWrapper<ErpContractMaterial> lqwRecord = JoinWrappers.lambda(ErpContractMaterial.class);
|
|
|
|
lqwRecord.eq(ErpContractMaterial::getContractId, bo.getContractId());
|
|
|
|
lqwRecord.eq(ErpContractMaterial::getContractId, bo.getContractId());
|
|
|
|
List<ErpContractMaterial> contractMaterielOldList = contractMaterialMapper.selectList(lqwRecord);
|
|
|
|
List<ErpContractMaterial> contractMaterialOldList = contractMaterialMapper.selectList(lqwRecord);
|
|
|
|
if (!contractMaterielList.isEmpty()) {
|
|
|
|
if (contractMaterialList != null && !contractMaterialList.isEmpty()) {
|
|
|
|
for (ErpContractMaterial contractMateriel : contractMaterielList) {
|
|
|
|
for (ErpContractMaterial contractMaterial : contractMaterialList) {
|
|
|
|
contractMaterialMapper.insertOrUpdate(contractMateriel);
|
|
|
|
contractMaterialMapper.insertOrUpdate(contractMaterial);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Set<Long> existingContractMaterielIds = contractMaterielList.stream()
|
|
|
|
Set<Long> existingContractMaterialIds = contractMaterialList.stream()
|
|
|
|
.map(ErpContractMaterial::getContractMaterialId)
|
|
|
|
.map(ErpContractMaterial::getContractMaterialId)
|
|
|
|
.collect(Collectors.toSet());
|
|
|
|
.collect(Collectors.toSet());
|
|
|
|
List<ErpContractMaterial> filterContractMaterielIds = contractMaterielOldList.stream()
|
|
|
|
List<ErpContractMaterial> filterContractMaterialIds = contractMaterialOldList.stream()
|
|
|
|
.filter(materiel -> !existingContractMaterielIds.contains(materiel.getContractMaterialId()))
|
|
|
|
.filter(material -> !existingContractMaterialIds.contains(material.getContractMaterialId()))
|
|
|
|
.toList();
|
|
|
|
.toList();
|
|
|
|
for (ErpContractMaterial filterContractMaterielId : filterContractMaterielIds) {
|
|
|
|
for (ErpContractMaterial filterContractMaterialId : filterContractMaterialIds) {
|
|
|
|
contractMaterialMapper.deleteById(filterContractMaterielId.getContractMaterialId());
|
|
|
|
contractMaterialMapper.deleteById(filterContractMaterialId.getContractMaterialId());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return baseMapper.updateById(update) > 0;
|
|
|
|
return baseMapper.updateById(update) > 0;
|
|
|
|
@ -165,9 +159,10 @@ public class ErpContractInfoServiceImpl implements IErpContractInfoService {
|
|
|
|
* 保存前的数据校验
|
|
|
|
* 保存前的数据校验
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private void validEntityBeforeSave(ErpContractInfo entity) {
|
|
|
|
private void validEntityBeforeSave(ErpContractInfo entity) {
|
|
|
|
if (entity.getContractMaterielList() == null || entity.getContractMaterielList().isEmpty()) {
|
|
|
|
// 注释掉物料列表的强制校验,允许空物料列表
|
|
|
|
throw new ServiceException("请填写合同物料!");
|
|
|
|
// if (entity.getContractMaterialList() == null || entity.getContractMaterialList().isEmpty()) {
|
|
|
|
}
|
|
|
|
// throw new ServiceException("请填写合同物料!");
|
|
|
|
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
|