|
|
|
|
@ -1,20 +1,25 @@ |
|
|
|
|
package org.springblade.desk.oem.service.impl; |
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
|
import jakarta.annotation.Resource; |
|
|
|
|
import org.springblade.core.mp.support.Query; |
|
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
|
import org.springblade.desk.dashboard.utils.DateUtils; |
|
|
|
|
import org.springblade.desk.oem.mapper.PlatingTypeRulesMapper; |
|
|
|
|
import org.springblade.desk.oem.pojo.entity.OemStatementEntity; |
|
|
|
|
import org.springblade.desk.oem.pojo.entity.PlatingTypeRulesEntity; |
|
|
|
|
import org.springblade.desk.oem.pojo.excel.OemStatementExcel; |
|
|
|
|
import org.springblade.desk.oem.pojo.request.PriceSheetQuery; |
|
|
|
|
import org.springblade.desk.oem.pojo.request.StatementQuery; |
|
|
|
|
import org.springblade.desk.oem.pojo.vo.OemStatementVO; |
|
|
|
|
import org.springblade.desk.oem.mapper.OemStatementMapper; |
|
|
|
|
import org.springblade.desk.oem.pojo.vo.PriceSheetVO; |
|
|
|
|
import org.springblade.desk.oem.pojo.vo.StatementVO; |
|
|
|
|
import org.springblade.desk.oem.service.IOemStatementService; |
|
|
|
|
import org.springblade.desk.util.PriceMatcher; |
|
|
|
|
import org.springblade.erpdata.feign.IErpDataOemClient; |
|
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
@ -22,8 +27,7 @@ import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
|
import java.time.LocalDate; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -38,6 +42,9 @@ public class OemStatementServiceImpl extends BaseServiceImpl<OemStatementMapper, |
|
|
|
|
@Resource |
|
|
|
|
private IErpDataOemClient erpDataOemClient; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private PlatingTypeRulesMapper platingTypeRulesMapper; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public IPage<StatementVO> selectOemStatementPage(IPage<StatementVO> page, StatementQuery mesOemStatement) { |
|
|
|
|
return page.setRecords(baseMapper.selectOemStatementPage(page, mesOemStatement)); |
|
|
|
|
@ -55,31 +62,660 @@ public class OemStatementServiceImpl extends BaseServiceImpl<OemStatementMapper, |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public R oemSettleAccounts(List<StatementVO> statementVOS, BigDecimal price, LocalDate putStoreDate) { |
|
|
|
|
//以外协厂商分组的Map<厂家代码, 待结算工序结算单列表>
|
|
|
|
|
Map<String, List<StatementVO>> oemAndStatementMap = statementVOS.stream().collect(Collectors.groupingBy(StatementVO::getOemCode)); |
|
|
|
|
//1.以外协厂商分组的Map<厂家名称, 待结算工序结算单列表>
|
|
|
|
|
Map<String, List<StatementVO>> oemAndStatementMap = statementVOS.stream().collect(Collectors.groupingBy(StatementVO::getOcName)); |
|
|
|
|
for (Map.Entry<String, List<StatementVO>> listEntry : oemAndStatementMap.entrySet()) { |
|
|
|
|
//外协厂商下全部需要结算的结算单
|
|
|
|
|
List<StatementVO> statementVOList = listEntry.getValue(); |
|
|
|
|
|
|
|
|
|
//以外协代码,日期查出的全部报价单
|
|
|
|
|
String oemCode = listEntry.getKey(); |
|
|
|
|
PriceSheetQuery query = new PriceSheetQuery(); |
|
|
|
|
query.setOcCode(oemCode); |
|
|
|
|
query.setInDateStart(putStoreDate); |
|
|
|
|
query.setInDateEnd(putStoreDate); |
|
|
|
|
R<Page<PriceSheetVO>> pageR = erpDataOemClient.priceSheetData(query, new Query() {{ |
|
|
|
|
setSize(99999); |
|
|
|
|
}}); |
|
|
|
|
//外协厂商下规定日期内的全部报价单
|
|
|
|
|
List<PriceSheetVO> priceSheetVOList = null; |
|
|
|
|
if (pageR != null && pageR.getData() != null && pageR.getData().getRecords() != null && pageR.getData().getRecords().size() > 0) { |
|
|
|
|
priceSheetVOList = pageR.getData().getRecords(); |
|
|
|
|
//2.以外协名称,日期查出的全部报价单
|
|
|
|
|
String oemName = listEntry.getKey(); |
|
|
|
|
List<PriceSheetVO> priceSheetAllList = getPriceSheets(oemName, putStoreDate); |
|
|
|
|
if (priceSheetAllList.isEmpty()) { |
|
|
|
|
//【结算异常】
|
|
|
|
|
statementVOList.forEach(statementVO -> { |
|
|
|
|
statementVO.setRosStatus(StatementVO.ERR_SETTLEMENT); |
|
|
|
|
statementVO.setMemo(String.format("外协厂商【%s】匹配无报价记录", oemName)); |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
//工序分组Map<工序, 报价列表>
|
|
|
|
|
Map<String, List<PriceSheetVO>> priceSheetMap = priceSheetAllList.stream().collect(Collectors.groupingBy(PriceSheetVO::getGxinfo)); |
|
|
|
|
/*statementVOList.forEach(statementVO -> { |
|
|
|
|
List<PriceSheetVO> matchedPriceSheets = MatchTheQuotations(statementVO, priceSheetMap); |
|
|
|
|
if (matchedPriceSheets.isEmpty()) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
statementVO.setPriceSheetList(matchedPriceSheets); |
|
|
|
|
});*/ |
|
|
|
|
//3.为每个结算单匹配报价集合
|
|
|
|
|
statementVOList.forEach(statementVO -> { |
|
|
|
|
List<PriceSheetVO> matchedPriceSheets = MatchTheQuotations(statementVO, priceSheetMap); |
|
|
|
|
if (matchedPriceSheets.isEmpty()) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
statementVO.setPriceSheetList(matchedPriceSheets); |
|
|
|
|
//4.匹配规则,过滤出唯一报价
|
|
|
|
|
//①.匹配车间订单号
|
|
|
|
|
if (ruleWoNo(statementVO)) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
//②.匹配物料名称和质量等级
|
|
|
|
|
if (rulePartNameAndProdIdent(statementVO)) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
//③.匹配金价银价
|
|
|
|
|
if (ruleGoldAndSilverPrices(statementVO, price)) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
//④.涂色标、涂色带、涂箭头
|
|
|
|
|
if (ruleColor(statementVO)) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
//⑤.物料号匹配
|
|
|
|
|
if (ruleGoods(statementVO)) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
//⑥.阶梯价匹配
|
|
|
|
|
if (ruleTieredPricing(statementVO)) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
statementVOList.forEach(statementVO -> { |
|
|
|
|
//保存
|
|
|
|
|
List<OemStatementEntity> saves = statementVOList.stream() |
|
|
|
|
.map(statementVO -> { |
|
|
|
|
OemStatementEntity entity = new OemStatementEntity(); |
|
|
|
|
BeanUtils.copyProperties(statementVO, entity); |
|
|
|
|
entity.setUpdateTime(new Date()); |
|
|
|
|
return entity; |
|
|
|
|
}) |
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
baseMapper.insertOrUpdate(saves); |
|
|
|
|
} |
|
|
|
|
return R.success("操作完成"); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 获取报价单列表 |
|
|
|
|
*/ |
|
|
|
|
private List<PriceSheetVO> getPriceSheets(String oemName, LocalDate putStoreDate) { |
|
|
|
|
PriceSheetQuery query = new PriceSheetQuery(); |
|
|
|
|
query.setOcName(oemName); |
|
|
|
|
query.setInDateStart(putStoreDate); |
|
|
|
|
query.setInDateEnd(putStoreDate); |
|
|
|
|
|
|
|
|
|
// R<Page<PriceSheetVO>> pageR = erpDataOemClient.priceSheetData(query, new Query() {{
|
|
|
|
|
// setSize(99999);
|
|
|
|
|
// }});
|
|
|
|
|
|
|
|
|
|
// if (pageR != null && pageR.getData() != null) {
|
|
|
|
|
// return pageR.getData().getRecords();
|
|
|
|
|
// }
|
|
|
|
|
return Collections.emptyList(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 为结算单匹配报价集合 |
|
|
|
|
* |
|
|
|
|
* @param statementVO 外协厂家下镀后入库的外协工序结算单 |
|
|
|
|
* @param priceSheetMap 外协厂家下有效期内的全部工序报价 |
|
|
|
|
*/ |
|
|
|
|
private List<PriceSheetVO> MatchTheQuotations(StatementVO statementVO, Map<String, List<PriceSheetVO>> priceSheetMap) { |
|
|
|
|
String psName = statementVO.getPsName(); |
|
|
|
|
if (!priceSheetMap.containsKey(psName)) { |
|
|
|
|
//【结算异常】
|
|
|
|
|
statementVO.setRosStatus(StatementVO.ERR_SETTLEMENT); |
|
|
|
|
statementVO.setMemo(String.format("外协厂商【%s】,工序内容【%s】匹配无报价记录", statementVO.getOcName(), psName)); |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
//获得外协厂商该工序下报价单列表
|
|
|
|
|
return priceSheetMap.get(psName); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 规则:匹配车间订单号 |
|
|
|
|
* |
|
|
|
|
* @param statementVO |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private boolean ruleWoNo(StatementVO statementVO) { |
|
|
|
|
List<PriceSheetVO> priceSheetList = statementVO.getPriceSheetList(); |
|
|
|
|
//取出匹配车间订单号的报价和无车间订单号的报价
|
|
|
|
|
Map<String, List<PriceSheetVO>> woNoPriceSheetMap = priceSheetList.stream() |
|
|
|
|
.collect(Collectors.groupingBy( |
|
|
|
|
priceSheet -> { |
|
|
|
|
String wono = priceSheet.getWono(); |
|
|
|
|
return wono == null || wono.trim().isEmpty() ? "EMPTY_WONO" : wono; |
|
|
|
|
}, |
|
|
|
|
Collectors.toList() |
|
|
|
|
)); |
|
|
|
|
//匹配车间订单号报价
|
|
|
|
|
if (woNoPriceSheetMap.containsKey(statementVO.getWoCode())) { |
|
|
|
|
List<PriceSheetVO> woNoPriceSheetList = woNoPriceSheetMap.get(statementVO.getWoCode()); |
|
|
|
|
//多条【结算异常】
|
|
|
|
|
if (woNoPriceSheetList.size() > 1) { |
|
|
|
|
statementVO.setRosStatus(StatementVO.ERR_SETTLEMENT); |
|
|
|
|
statementVO.setMemo(String.format("外协厂商【%s】,工序内容【%s】,工作订单号【%s】匹配多条报价记录", statementVO.getOcName(), statementVO.getPartName(), statementVO.getWoCode())); |
|
|
|
|
//结算异常:多条报价记录结算结果
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
PriceSheetVO priceSheet = woNoPriceSheetList.get(0); |
|
|
|
|
//唯一使用此报价单**结算**
|
|
|
|
|
BigDecimal unitPrice = new BigDecimal(priceSheet.getPrice()); |
|
|
|
|
BigDecimal qty = new BigDecimal(statementVO.getMakeQty()); |
|
|
|
|
statementVO.setRosStatus(StatementVO.IN_SETTLEMENT); |
|
|
|
|
statementVO.setUnitPrice(unitPrice); |
|
|
|
|
statementVO.setUnit(priceSheet.getPrtum()); |
|
|
|
|
statementVO.setTotalPrice(unitPrice.multiply(qty)); |
|
|
|
|
statementVO.setMemo("结算中"); |
|
|
|
|
statementVO.setQuotation(priceSheet.getSeqid()); |
|
|
|
|
//使用此报价
|
|
|
|
|
return true; |
|
|
|
|
} else { |
|
|
|
|
//筛选出无车间订单号报价单列表
|
|
|
|
|
priceSheetList = woNoPriceSheetMap.get("EMPTY_WONO"); |
|
|
|
|
if (priceSheetList.size() < 1) { |
|
|
|
|
statementVO.setRosStatus(StatementVO.ERR_SETTLEMENT); |
|
|
|
|
statementVO.setMemo(String.format("外协厂商【%s】,工序内容【%s】匹配无报价记录", statementVO.getOcName(), statementVO.getPartName())); |
|
|
|
|
//结算异常:无报价记录结算结果
|
|
|
|
|
return true; |
|
|
|
|
} else { |
|
|
|
|
statementVO.setPriceSheetList(priceSheetList); |
|
|
|
|
//结束当前规则匹配,进入下一规则匹配
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 规则:匹配物料名称和质量等级 |
|
|
|
|
* |
|
|
|
|
* @param statementVO |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private boolean rulePartNameAndProdIdent(StatementVO statementVO) { |
|
|
|
|
List<PriceSheetVO> priceSheetList = statementVO.getPriceSheetList(); |
|
|
|
|
//报价单判断同时满足物料名称和质量等级 || 为空
|
|
|
|
|
priceSheetList = priceSheetList.stream() |
|
|
|
|
.filter(priceSheet -> matchesCondition1(priceSheet, statementVO)) |
|
|
|
|
.filter(priceSheet -> matchesCondition2(priceSheet, statementVO)) |
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
//无报价单【结算异常】
|
|
|
|
|
if (priceSheetList.size() < 1) { |
|
|
|
|
//结算异常:无报价记录结算结果
|
|
|
|
|
statementVO.setRosStatus(StatementVO.ERR_SETTLEMENT); |
|
|
|
|
statementVO.setMemo(String.format("外协厂商【%s】,工序内容【%s】,物料名【%s】,质量等级【%s】匹配无报价记录", statementVO.getOcName(), statementVO.getPartName(), statementVO.getPartName(), statementVO.getProdIdent())); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
//保存结果,结束当前规则匹配,进入下一规则匹配
|
|
|
|
|
statementVO.setPriceSheetList(priceSheetList); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 规则:金价银价 |
|
|
|
|
* |
|
|
|
|
* @param statementVO |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private boolean ruleGoldAndSilverPrices(StatementVO statementVO, BigDecimal price) { |
|
|
|
|
List<PriceSheetVO> priceSheetList = statementVO.getPriceSheetList(); |
|
|
|
|
String plateGoodsCode = statementVO.getPlateGoodsCode(); |
|
|
|
|
//判断传入参数的当前金价银价 > 0 && 零件镀层物料编码不为空,则需匹配规则
|
|
|
|
|
if (price.compareTo(BigDecimal.ZERO) > 0 && StringUtils.isEmpty(plateGoodsCode)) { |
|
|
|
|
//取出所有备注
|
|
|
|
|
Map<String, List<PriceSheetVO>> remarkPriceSheetMap = priceSheetList.stream() |
|
|
|
|
.filter(priceSheet -> { |
|
|
|
|
String remark = priceSheet.getRemark(); |
|
|
|
|
return remark != null && !remark.trim().isEmpty(); |
|
|
|
|
}) |
|
|
|
|
.collect(Collectors.groupingBy( |
|
|
|
|
PriceSheetVO::getRemark, |
|
|
|
|
Collectors.toList() |
|
|
|
|
)); |
|
|
|
|
Set<String> remarksByPrice = PriceMatcher.findRemarksByPriceStream(remarkPriceSheetMap.keySet(), price); |
|
|
|
|
if (remarksByPrice.size() < 1) { |
|
|
|
|
//结算异常:无报价记录结算结果
|
|
|
|
|
statementVO.setRosStatus(StatementVO.ERR_SETTLEMENT); |
|
|
|
|
statementVO.setMemo(String.format("外协厂商【%s】,工序内容【%s】,金价银价【%s】匹配无报价记录", statementVO.getOcName(), statementVO.getPartName(), price)); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
//保存结果,结束当前规则匹配,进入下一规则匹配
|
|
|
|
|
List<PriceSheetVO> priceSheetVOList = remarkPriceSheetMap.entrySet().stream() |
|
|
|
|
.filter(entry -> remarksByPrice.contains(entry.getKey())) // 过滤key在keys中的条目
|
|
|
|
|
.flatMap(entry -> entry.getValue().stream()) // 将List<PriceSheetVO>扁平化为PriceSheetVO流
|
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
statementVO.setPriceSheetList(priceSheetVOList); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
//结束当前规则匹配,进入下一规则匹配
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 涂色标、涂色带、涂箭头匹配规则 |
|
|
|
|
* |
|
|
|
|
* @param statementVO |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private boolean ruleColor(StatementVO statementVO) { |
|
|
|
|
List<PriceSheetVO> priceSheetList = statementVO.getPriceSheetList(); |
|
|
|
|
//结算单色标色带箭头数量>0,需要匹配报价里色标色带箭头
|
|
|
|
|
//如果结算单没有数量,直接返回false进入下个规则
|
|
|
|
|
if (!hasColorCount(statementVO)) { |
|
|
|
|
//结束当前规则匹配,进入下一规则匹配
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
//涂色标、涂色带、涂箭头的报价集合
|
|
|
|
|
Map<String, List<PriceSheetVO>> prtnoPriceSheetMap = priceSheetList.stream() |
|
|
|
|
.filter(priceSheet -> { |
|
|
|
|
String prtno = priceSheet.getPrtno(); |
|
|
|
|
return prtno != null && !prtno.trim().isEmpty() && ("涂色标".equals(prtno) || "涂色带".equals(prtno) || "涂箭头".equals(prtno)); |
|
|
|
|
}) |
|
|
|
|
.collect(Collectors.groupingBy( |
|
|
|
|
PriceSheetVO::getPrtno, |
|
|
|
|
Collectors.toList() |
|
|
|
|
)); |
|
|
|
|
// 如果没有任何报价记录
|
|
|
|
|
if (prtnoPriceSheetMap.isEmpty()) { |
|
|
|
|
//结算异常:无报价记录结算结果
|
|
|
|
|
statementVO.setRosStatus(StatementVO.ERR_SETTLEMENT); |
|
|
|
|
statementVO.setMemo(String.format("外协厂商【%s】,工序内容【%s】涂色标、涂色带、涂箭头匹配无报价记录", statementVO.getOcName(), statementVO.getPartName())); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
//总价
|
|
|
|
|
BigDecimal totalPrice = BigDecimal.ZERO; |
|
|
|
|
//涂箭头
|
|
|
|
|
Integer tjtNum = StringUtils.isNotEmpty(statementVO.getTjtNum()) ? Integer.valueOf(statementVO.getTjtNum()) : 0; |
|
|
|
|
//涂色标
|
|
|
|
|
Integer tsbNum = StringUtils.isNotEmpty(statementVO.getTsbNum()) ? Integer.valueOf(statementVO.getTsbNum()) : 0; |
|
|
|
|
//涂色带
|
|
|
|
|
Integer tsdNum = StringUtils.isNotEmpty(statementVO.getTsdNum()) ? Integer.valueOf(statementVO.getTsdNum()) : 0; |
|
|
|
|
//报价单号
|
|
|
|
|
String quotation = ""; |
|
|
|
|
if (tjtNum > 0 && prtnoPriceSheetMap.containsKey("涂箭头")) { |
|
|
|
|
List<PriceSheetVO> tjtPriceSheetList = prtnoPriceSheetMap.get("涂箭头"); |
|
|
|
|
if (tjtPriceSheetList.size() > 1) { |
|
|
|
|
//结算异常:多条报价记录结算结果
|
|
|
|
|
statementVO.setRosStatus(StatementVO.ERR_SETTLEMENT); |
|
|
|
|
statementVO.setMemo(String.format("外协厂商【%s】,工序内容【%s】,涂箭头数量【%s】匹配多条报价记录", statementVO.getOcName(), statementVO.getPartName(), tjtNum)); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
//唯一使用此报价单**结算**
|
|
|
|
|
BigDecimal unitPrice = new BigDecimal(tjtPriceSheetList.get(0).getPrice()); |
|
|
|
|
BigDecimal itemTotalPrice = unitPrice.multiply(BigDecimal.valueOf(tjtNum)); |
|
|
|
|
totalPrice = totalPrice.add(itemTotalPrice); |
|
|
|
|
quotation = tjtPriceSheetList.get(0).getSeqid(); |
|
|
|
|
} |
|
|
|
|
if (tsdNum > 0 && prtnoPriceSheetMap.containsKey("涂色带")) { |
|
|
|
|
List<PriceSheetVO> tsdPriceSheetList = prtnoPriceSheetMap.get("涂色带"); |
|
|
|
|
if (tsdPriceSheetList.size() > 1) { |
|
|
|
|
//结算异常:多条报价记录结算结果
|
|
|
|
|
statementVO.setRosStatus(StatementVO.ERR_SETTLEMENT); |
|
|
|
|
statementVO.setMemo(String.format("外协厂商【%s】,工序内容【%s】,涂色带数量【%s】匹配多条报价记录", statementVO.getOcName(), statementVO.getPartName(), tsdNum)); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
//唯一使用此报价单**结算**
|
|
|
|
|
BigDecimal unitPrice = new BigDecimal(tsdPriceSheetList.get(0).getPrice()); |
|
|
|
|
BigDecimal itemTotalPrice = unitPrice.multiply(BigDecimal.valueOf(tsdNum)); |
|
|
|
|
totalPrice = totalPrice.add(itemTotalPrice); |
|
|
|
|
quotation = tsdPriceSheetList.get(0).getSeqid(); |
|
|
|
|
} |
|
|
|
|
if (tsbNum > 0 && prtnoPriceSheetMap.containsKey("涂色标")) { |
|
|
|
|
List<PriceSheetVO> tsbPriceSheetList = prtnoPriceSheetMap.get("涂色标"); |
|
|
|
|
if (tsbPriceSheetList.size() > 1) { |
|
|
|
|
//结算异常:多条报价记录结算结果
|
|
|
|
|
statementVO.setRosStatus(StatementVO.ERR_SETTLEMENT); |
|
|
|
|
statementVO.setMemo(String.format("外协厂商【%s】,工序内容【%s】,涂色标数量【%s】匹配多条报价记录", statementVO.getOcName(), statementVO.getPartName(), tsbNum)); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
//唯一使用此报价单**结算**
|
|
|
|
|
BigDecimal unitPrice = new BigDecimal(tsbPriceSheetList.get(0).getPrice()); |
|
|
|
|
BigDecimal itemTotalPrice = unitPrice.multiply(BigDecimal.valueOf(tsbNum)); |
|
|
|
|
totalPrice = totalPrice.add(itemTotalPrice); |
|
|
|
|
quotation = tsbPriceSheetList.get(0).getSeqid(); |
|
|
|
|
} |
|
|
|
|
//如总价大于0,则报价成功
|
|
|
|
|
if (totalPrice.compareTo(BigDecimal.ZERO) > 0) { |
|
|
|
|
statementVO.setRosStatus(StatementVO.IN_SETTLEMENT); |
|
|
|
|
statementVO.setTotalPrice(totalPrice); |
|
|
|
|
statementVO.setMemo("结算中"); |
|
|
|
|
statementVO.setQuotation(quotation); |
|
|
|
|
return true; |
|
|
|
|
} else { |
|
|
|
|
//结算异常:多条报价记录结算结果
|
|
|
|
|
statementVO.setRosStatus(StatementVO.ERR_SETTLEMENT); |
|
|
|
|
statementVO.setMemo(String.format("外协厂商【%s】,工序内容【%s】涂色标、涂色带、涂箭头匹配无报价记录", statementVO.getOcName(), statementVO.getPartName())); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 规则:物料号匹配 |
|
|
|
|
* |
|
|
|
|
* @param statementVO |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private boolean ruleGoods(StatementVO statementVO) { |
|
|
|
|
List<PriceSheetVO> priceSheetList = statementVO.getPriceSheetList(); |
|
|
|
|
//1.结算单的镀种、零件号、镀层厚度,三个维度分别匹配报价的物料号,匹配出单一维度的报价
|
|
|
|
|
StatementVO statementPlate = BeanUtil.copyProperties(statementVO, StatementVO.class); |
|
|
|
|
StatementVO statementPartCode = BeanUtil.copyProperties(statementVO, StatementVO.class); |
|
|
|
|
StatementVO statementPlateThickness = BeanUtil.copyProperties(statementVO, StatementVO.class); |
|
|
|
|
//2.统计结果为 true 的规则数量
|
|
|
|
|
int trueCount = 0; |
|
|
|
|
if (rulePlate(statementPlate)) { |
|
|
|
|
statementVO.setPriceSheetList(statementPlate.getPriceSheetList()); |
|
|
|
|
trueCount++; |
|
|
|
|
} |
|
|
|
|
if (rulePartCode(statementPartCode)) { |
|
|
|
|
statementVO.setPriceSheetList(statementPartCode.getPriceSheetList()); |
|
|
|
|
trueCount++; |
|
|
|
|
} |
|
|
|
|
if (rulePlateThickness(statementPlateThickness)) { |
|
|
|
|
statementVO.setPriceSheetList(statementPlateThickness.getPriceSheetList()); |
|
|
|
|
trueCount++; |
|
|
|
|
} |
|
|
|
|
if (trueCount == 1) { |
|
|
|
|
//保存结果,结束当前规则匹配,进入下一规则匹配
|
|
|
|
|
return false; |
|
|
|
|
} else if (trueCount > 1) { |
|
|
|
|
//结算异常:多条报价记录结算结果
|
|
|
|
|
statementVO.setRosStatus(StatementVO.ERR_SETTLEMENT); |
|
|
|
|
statementVO.setMemo(String.format("外协厂商【%s】,工序内容【%s】,物料号匹配多条报价记录", statementVO.getOcName(), statementVO.getPartName())); |
|
|
|
|
return true; |
|
|
|
|
} else { |
|
|
|
|
//结算异常:无报价记录结算结果
|
|
|
|
|
statementVO.setRosStatus(StatementVO.ERR_SETTLEMENT); |
|
|
|
|
statementVO.setMemo(String.format("外协厂商【%s】,工序内容【%s】,物料号匹配无报价记录", statementVO.getOcName(), statementVO.getPartName())); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
/** |
|
|
|
|
* 规则:镀种匹配 |
|
|
|
|
* |
|
|
|
|
* @param statementVO |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private boolean rulePlate(StatementVO statementVO) { |
|
|
|
|
List<PriceSheetVO> priceSheetList = statementVO.getPriceSheetList(); |
|
|
|
|
//结算单的镀种维度匹配报价的物料号
|
|
|
|
|
String plate = statementVO.getPlate(); |
|
|
|
|
if (StringUtils.isEmpty(plate)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
Map<String, List<PriceSheetVO>> map = priceSheetList.stream().collect(Collectors.groupingBy(PriceSheetVO::getPrtno)); |
|
|
|
|
//1.精确匹配,完整的镀种
|
|
|
|
|
if (map.containsKey(plate)) { |
|
|
|
|
statementVO.setPriceSheetList(map.get(plate)); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
return null; |
|
|
|
|
//2.使用模糊查询。根据订单中的镀种,到镀种映射表中查询对应的代码,再根据代码查找报价,适用于:Ap.Ni15、Ap.Ni20有同一个报价Ap.Ni%Cu%Xn%
|
|
|
|
|
LambdaQueryWrapper<PlatingTypeRulesEntity> queryWrapper = new LambdaQueryWrapper(); |
|
|
|
|
queryWrapper.eq(PlatingTypeRulesEntity::getOrderPlat, plate) |
|
|
|
|
.orderByDesc(PlatingTypeRulesEntity::getCreateTime) // 按创建时间降序
|
|
|
|
|
.last("AND ROWNUM = 1"); // 只取第一条
|
|
|
|
|
PlatingTypeRulesEntity platingTypeRulesEntity = platingTypeRulesMapper.selectOne(queryWrapper); |
|
|
|
|
if (platingTypeRulesEntity == null || StringUtils.isBlank(platingTypeRulesEntity.getQuotationPlat())) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
if (map.containsKey(platingTypeRulesEntity.getQuotationPlat())) { |
|
|
|
|
statementVO.setPriceSheetList(map.get(plate)); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 规则:零件号匹配 |
|
|
|
|
* |
|
|
|
|
* @param statementVO |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private boolean rulePartCode(StatementVO statementVO) { |
|
|
|
|
List<PriceSheetVO> priceSheetList = statementVO.getPriceSheetList(); |
|
|
|
|
//结算单的零件号维度匹配报价的物料号
|
|
|
|
|
String partCode = statementVO.getPartCode(); |
|
|
|
|
if (StringUtils.isEmpty(partCode)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
Map<String, List<PriceSheetVO>> map = priceSheetList.stream().collect(Collectors.groupingBy(PriceSheetVO::getPrtno)); |
|
|
|
|
//1.精确匹配,完整的零件号
|
|
|
|
|
if (map.containsKey(partCode)) { |
|
|
|
|
statementVO.setPriceSheetList(map.get(partCode)); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
//2.模糊查询报价单中为一类零件号, 如81E6-%螺母
|
|
|
|
|
Map<String, List<PriceSheetVO>> newMap = map.entrySet().stream() |
|
|
|
|
.filter(entry -> entry.getKey().contains("-%")) |
|
|
|
|
.collect(Collectors.toMap( |
|
|
|
|
entry -> entry.getKey().split("%")[0], // 只保留%之前的部分
|
|
|
|
|
Map.Entry::getValue |
|
|
|
|
)); |
|
|
|
|
List<PriceSheetVO> priceSheetVOList = newMap.entrySet().stream() |
|
|
|
|
.filter(entry -> partCode.startsWith(entry.getKey())) |
|
|
|
|
.flatMap(entry -> entry.getValue().stream()) // 将 List<T> 扁平化为 Stream<T>
|
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
//匹配成功,保存报价集合
|
|
|
|
|
if (null != priceSheetVOList && !priceSheetVOList.isEmpty()) { |
|
|
|
|
statementVO.setPriceSheetList(priceSheetVOList); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 规则:镀层厚度匹配 |
|
|
|
|
* |
|
|
|
|
* @param statementVO |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private boolean rulePlateThickness(StatementVO statementVO) { |
|
|
|
|
List<PriceSheetVO> priceSheetList = statementVO.getPriceSheetList(); |
|
|
|
|
//结算单的镀层厚度维度分匹配报价的物料号,
|
|
|
|
|
String plateThickness = statementVO.getPlateThickness(); |
|
|
|
|
if (StringUtils.isEmpty(plateThickness)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
Map<String, List<PriceSheetVO>> map = priceSheetList.stream().collect(Collectors.groupingBy(PriceSheetVO::getPrtno)); |
|
|
|
|
//镀层厚度值相等,保存报价集合
|
|
|
|
|
if (map.containsKey(plateThickness)) { |
|
|
|
|
statementVO.setPriceSheetList(map.get(plateThickness)); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 规则:阶梯价匹配 |
|
|
|
|
* |
|
|
|
|
* @param statementVO |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private boolean ruleTieredPricing(StatementVO statementVO) { |
|
|
|
|
List<PriceSheetVO> priceSheetList = statementVO.getPriceSheetList(); |
|
|
|
|
//如果无报价,结算异常:无报价记录结算结果
|
|
|
|
|
if (null == priceSheetList || priceSheetList.isEmpty()) { |
|
|
|
|
statementVO.setRosStatus(StatementVO.ERR_SETTLEMENT); |
|
|
|
|
statementVO.setMemo(String.format("外协厂商【%s】,工序内容【%s】,阶梯价匹配无报价记录", statementVO.getOcName(), statementVO.getPartName())); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
//如果只剩唯一报价,则直接使用
|
|
|
|
|
if (priceSheetList.size() == 1) { |
|
|
|
|
//唯一使用此报价单**结算**
|
|
|
|
|
PriceSheetVO priceSheet = priceSheetList.get(0); |
|
|
|
|
BigDecimal unitPrice = new BigDecimal(priceSheet.getPrice()); |
|
|
|
|
BigDecimal qty = new BigDecimal(statementVO.getMakeQty()); |
|
|
|
|
statementVO.setRosStatus(StatementVO.IN_SETTLEMENT); |
|
|
|
|
statementVO.setUnitPrice(unitPrice); |
|
|
|
|
statementVO.setUnit(priceSheet.getPrtum()); |
|
|
|
|
statementVO.setTotalPrice(unitPrice.multiply(qty)); |
|
|
|
|
statementVO.setMemo("结算中"); |
|
|
|
|
statementVO.setQuotation(priceSheet.getSeqid()); |
|
|
|
|
//使用此报价
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
//匹配阶梯价
|
|
|
|
|
//1.只允许有一种阶梯价
|
|
|
|
|
Map<String, List<PriceSheetVO>> StairPriceSheetMap = priceSheetList.stream().filter(priceSheet -> { |
|
|
|
|
String stairflag = priceSheet.getStairflag(); |
|
|
|
|
return stairflag != null && !stairflag.trim().isEmpty(); |
|
|
|
|
}).collect(Collectors.groupingBy(PriceSheetVO::getStairflag)); |
|
|
|
|
if (StairPriceSheetMap.keySet().size() > 1) { |
|
|
|
|
statementVO.setRosStatus(StatementVO.ERR_SETTLEMENT); |
|
|
|
|
statementVO.setMemo(String.format("外协厂商【%s】,工序内容【%s】,阶梯价类型【%s】匹配多条报价记录", statementVO.getOcName(), statementVO.getPartName(), String.join(", ", StairPriceSheetMap.keySet()))); |
|
|
|
|
return true; |
|
|
|
|
} else if (StairPriceSheetMap.keySet().size() < 1) { |
|
|
|
|
statementVO.setRosStatus(StatementVO.ERR_SETTLEMENT); |
|
|
|
|
statementVO.setMemo(String.format("外协厂商【%s】,工序内容【%s】,阶梯价匹配无报价记录", statementVO.getOcName(), statementVO.getPartName())); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
if (StairPriceSheetMap.keySet().contains("非阶梯价")) { |
|
|
|
|
//2.如果阶梯价是非阶梯价,判断报价是否唯一
|
|
|
|
|
List<PriceSheetVO> priceSheetVOS = StairPriceSheetMap.get("非阶梯价"); |
|
|
|
|
if (null == priceSheetVOS || priceSheetVOS.isEmpty()) { |
|
|
|
|
statementVO.setRosStatus(StatementVO.ERR_SETTLEMENT); |
|
|
|
|
statementVO.setMemo(String.format("外协厂商【%s】,工序内容【%s】,阶梯价【】匹配无报价记录", statementVO.getOcName(), statementVO.getPartName(), "非阶梯价")); |
|
|
|
|
return true; |
|
|
|
|
} else if (null != priceSheetVOS && priceSheetVOS.size() > 1) { |
|
|
|
|
statementVO.setRosStatus(StatementVO.ERR_SETTLEMENT); |
|
|
|
|
statementVO.setMemo(String.format("外协厂商【%s】,工序内容【%s】,阶梯价【】匹配多条报价记录", statementVO.getOcName(), statementVO.getPartName(), "非阶梯价")); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
//唯一使用此报价单**结算**
|
|
|
|
|
PriceSheetVO priceSheet = priceSheetVOS.get(0); |
|
|
|
|
BigDecimal unitPrice = new BigDecimal(priceSheet.getPrice()); |
|
|
|
|
BigDecimal qty = new BigDecimal(statementVO.getMakeQty()); |
|
|
|
|
statementVO.setRosStatus(StatementVO.IN_SETTLEMENT); |
|
|
|
|
statementVO.setUnitPrice(unitPrice); |
|
|
|
|
statementVO.setUnit(priceSheet.getPrtum()); |
|
|
|
|
statementVO.setTotalPrice(unitPrice.multiply(qty)); |
|
|
|
|
statementVO.setMemo("结算中"); |
|
|
|
|
statementVO.setQuotation(priceSheet.getSeqid()); |
|
|
|
|
return true; |
|
|
|
|
} else if (StairPriceSheetMap.keySet().contains("单批阶梯价(按单件面积)")) { |
|
|
|
|
//3.如果阶梯价是按单件面积,判断报价是否唯一
|
|
|
|
|
List<PriceSheetVO> priceSheetVOS = StairPriceSheetMap.get("单批阶梯价(按单件面积)"); |
|
|
|
|
//获取结算单的单件面积,匹配报价里的阶梯上下限
|
|
|
|
|
String ypArea = statementVO.getYpArea(); |
|
|
|
|
if (ypArea != null && ypArea.endsWith(".")) { |
|
|
|
|
ypArea = ypArea.substring(0, ypArea.length() - 1); |
|
|
|
|
} |
|
|
|
|
double ypAreaValue = Double.parseDouble(ypArea); |
|
|
|
|
if (null != priceSheetVOS && priceSheetVOS.size() > 1) { |
|
|
|
|
List<PriceSheetVO> priceSheetVOList = priceSheetVOS.stream() |
|
|
|
|
.filter(vo -> { |
|
|
|
|
double lower = Double.parseDouble(vo.getLower()); |
|
|
|
|
double upper = Double.parseDouble(vo.getUpper()); |
|
|
|
|
return ypAreaValue >= lower && ypAreaValue <= upper; |
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
if (null != priceSheetVOList && priceSheetVOList.size() > 1) { |
|
|
|
|
statementVO.setRosStatus(StatementVO.ERR_SETTLEMENT); |
|
|
|
|
statementVO.setMemo(String.format("外协厂商【%s】,工序内容【%s】,阶梯价【】匹配多条报价记录", statementVO.getOcName(), statementVO.getPartName(), "单批阶梯价(按单件面积)")); |
|
|
|
|
return true; |
|
|
|
|
} else if (null != priceSheetVOList && priceSheetVOList.size() == 1) { |
|
|
|
|
//唯一使用此报价单**结算**
|
|
|
|
|
PriceSheetVO priceSheet = priceSheetVOList.get(0); |
|
|
|
|
BigDecimal unitPrice = new BigDecimal(priceSheet.getPrice()); |
|
|
|
|
BigDecimal qty = new BigDecimal(statementVO.getMakeQty()); |
|
|
|
|
statementVO.setRosStatus(StatementVO.IN_SETTLEMENT); |
|
|
|
|
statementVO.setUnitPrice(unitPrice); |
|
|
|
|
statementVO.setUnit(priceSheet.getPrtum()); |
|
|
|
|
statementVO.setTotalPrice(unitPrice.multiply(qty)); |
|
|
|
|
statementVO.setMemo("结算中"); |
|
|
|
|
statementVO.setQuotation(priceSheet.getSeqid()); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
statementVO.setRosStatus(StatementVO.ERR_SETTLEMENT); |
|
|
|
|
statementVO.setMemo(String.format("外协厂商【%s】,工序内容【%s】,阶梯价【】匹配无报价记录", statementVO.getOcName(), statementVO.getPartName(), "单批阶梯价(按单件面积)")); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} else if (StairPriceSheetMap.keySet().contains("单批阶梯价(按单批面积)")) { |
|
|
|
|
//4.如果阶梯价是按单批面积,判断报价是否唯一
|
|
|
|
|
List<PriceSheetVO> priceSheetVOS = StairPriceSheetMap.get("单批阶梯价(按单批面积)"); |
|
|
|
|
//获取结算单的单件面积,匹配报价里的阶梯上下限
|
|
|
|
|
String totalArea = statementVO.getTotalArea(); |
|
|
|
|
if (totalArea != null && totalArea.endsWith(".")) { |
|
|
|
|
totalArea = totalArea.substring(0, totalArea.length() - 1); |
|
|
|
|
} |
|
|
|
|
double totalAreaValue = Double.parseDouble(totalArea); |
|
|
|
|
if (null != priceSheetVOS && priceSheetVOS.size() > 1) { |
|
|
|
|
List<PriceSheetVO> priceSheetVOList = priceSheetVOS.stream() |
|
|
|
|
.filter(vo -> { |
|
|
|
|
double lower = Double.parseDouble(vo.getLower()); |
|
|
|
|
double upper = Double.parseDouble(vo.getUpper()); |
|
|
|
|
return totalAreaValue >= lower && totalAreaValue <= upper; |
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
if (null != priceSheetVOList && priceSheetVOList.size() > 1) { |
|
|
|
|
statementVO.setRosStatus(StatementVO.ERR_SETTLEMENT); |
|
|
|
|
statementVO.setMemo(String.format("外协厂商【%s】,工序内容【%s】,阶梯价【】匹配多条报价记录", statementVO.getOcName(), statementVO.getPartName(), "单批阶梯价(按单批面积)")); |
|
|
|
|
return true; |
|
|
|
|
} else if (null != priceSheetVOList && priceSheetVOList.size() == 1) { |
|
|
|
|
//唯一使用此报价单**结算**
|
|
|
|
|
PriceSheetVO priceSheet = priceSheetVOList.get(0); |
|
|
|
|
BigDecimal unitPrice = new BigDecimal(priceSheet.getPrice()); |
|
|
|
|
BigDecimal qty = new BigDecimal(statementVO.getMakeQty()); |
|
|
|
|
statementVO.setRosStatus(StatementVO.IN_SETTLEMENT); |
|
|
|
|
statementVO.setUnitPrice(unitPrice); |
|
|
|
|
statementVO.setUnit(priceSheet.getPrtum()); |
|
|
|
|
statementVO.setTotalPrice(unitPrice.multiply(qty)); |
|
|
|
|
statementVO.setMemo("结算中"); |
|
|
|
|
statementVO.setQuotation(priceSheet.getSeqid()); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
statementVO.setRosStatus(StatementVO.ERR_SETTLEMENT); |
|
|
|
|
statementVO.setMemo(String.format("外协厂商【%s】,工序内容【%s】,阶梯价【】匹配无报价记录", statementVO.getOcName(), statementVO.getPartName(), "单批阶梯价(按单批面积)")); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} else { |
|
|
|
|
//todo:qyl 5.其他阶梯价类型暂不处理,找客户确认
|
|
|
|
|
statementVO.setRosStatus(StatementVO.ERR_SETTLEMENT); |
|
|
|
|
statementVO.setMemo(String.format("外协厂商【%s】,工序内容【%s】,阶梯价匹配无报价记录", statementVO.getOcName(), statementVO.getPartName())); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 检查是否有涂色相关的数量 |
|
|
|
|
*/ |
|
|
|
|
private boolean hasColorCount(StatementVO statementVO) { |
|
|
|
|
return StringUtils.isNotEmpty(statementVO.getTjtNum()) |
|
|
|
|
|| StringUtils.isNotEmpty(statementVO.getTsbNum()) |
|
|
|
|
|| StringUtils.isNotEmpty(statementVO.getTsdNum()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 条件1: prtdesc 匹配 |
|
|
|
|
*/ |
|
|
|
|
private boolean matchesCondition1(PriceSheetVO priceSheet, StatementVO statementVO) { |
|
|
|
|
String prtdesc = priceSheet.getPrtdesc(); |
|
|
|
|
String partName = statementVO.getPartName(); |
|
|
|
|
|
|
|
|
|
// 条件: prtdesc 为空 或 与 partName 相等
|
|
|
|
|
return StringUtils.isBlank(prtdesc) || partName.equals(prtdesc); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 条件2: prtlotno 匹配 |
|
|
|
|
*/ |
|
|
|
|
private boolean matchesCondition2(PriceSheetVO priceSheet, StatementVO statementVO) { |
|
|
|
|
String prtlotno = priceSheet.getPrtlotno(); |
|
|
|
|
String prodIdent = statementVO.getProdIdent(); |
|
|
|
|
|
|
|
|
|
// 如果 prtlotno 是 "/",条件满足
|
|
|
|
|
if ("/".equals(prtlotno)) { |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 按"和"分割,检查前缀
|
|
|
|
|
String[] prefixes = prtlotno.split("和"); |
|
|
|
|
|
|
|
|
|
return Arrays.stream(prefixes) |
|
|
|
|
.map(String::trim) // 去除空格
|
|
|
|
|
.anyMatch(prodIdent::startsWith); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|