fix:MCP成本计算规则调整
parent
79010a0f36
commit
954be37aa4
|
|
@ -42,6 +42,8 @@ public class ProjectOrderInfoToolProvider extends AbstractMcpToolProvider {
|
|||
private static final String INDUSTRY_TYPE_YYS_DICT_TYPE = "bg_yys";
|
||||
private static final String PROJECT_STAGE_DICT_TYPE = "project_stage";
|
||||
private static final String NOT_DELIVERED_TEXT = "未配货完成";
|
||||
private static final Set<String> SERVICE_MERGE_SOFTWARE_CODES = initCodeSet("0504A14F", "0504A1JX");
|
||||
private static final Set<String> SERVICE_MERGE_SERVICE_CODES = initCodeSet("0202A1NU", "0202A1NS", "0202A1NT");
|
||||
|
||||
@Autowired
|
||||
private IProjectOrderInfoService projectOrderInfoService;
|
||||
|
|
@ -205,6 +207,7 @@ public class ProjectOrderInfoToolProvider extends AbstractMcpToolProvider {
|
|||
orderShipmentMap, Collections.emptyMap(), true, orderInfo.getOrderCode());
|
||||
ProductGroupSummary serviceSummary = appendProductFields(item, "service", serviceList,
|
||||
Collections.emptyMap(), serviceCostMap.getOrDefault(orderInfo.getOrderCode(), Collections.emptyMap()), false, orderInfo.getOrderCode());
|
||||
mergeSpecifiedServiceToSoftware(item, softwareList, serviceList, softwareSummary, serviceSummary, orderInfo.getOrderCode());
|
||||
|
||||
BigDecimal orderAmountWithTax = defaultValue(orderInfo.getShipmentAmount());
|
||||
BigDecimal discountAmountWithTax = softwareSummary.salesWithTax
|
||||
|
|
@ -569,6 +572,89 @@ public class ProjectOrderInfoToolProvider extends AbstractMcpToolProvider {
|
|||
return summary;
|
||||
}
|
||||
|
||||
private void mergeSpecifiedServiceToSoftware(Map<String, Object> item,
|
||||
List<ProjectProductInfo> softwareList,
|
||||
List<ProjectProductInfo> serviceList,
|
||||
ProductGroupSummary softwareSummary,
|
||||
ProductGroupSummary serviceSummary,
|
||||
String orderCode) {
|
||||
int softwareIndex = findFirstProductIndex(softwareList, SERVICE_MERGE_SOFTWARE_CODES);
|
||||
int serviceIndex = findFirstProductIndex(serviceList, SERVICE_MERGE_SERVICE_CODES);
|
||||
if (softwareIndex < 0 || serviceIndex < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
int softwareFieldIndex = softwareIndex + 1;
|
||||
int serviceFieldIndex = serviceIndex + 1;
|
||||
OrderProductBindAmountDto softwareBindAmountDto = projectOrderInfoMapper.selectOrderProductBindAmount(
|
||||
orderCode, softwareList.get(softwareIndex).getProductBomCode());
|
||||
OrderProductBindAmountDto serviceBindAmountDto = projectOrderInfoMapper.selectOrderProductBindAmount(
|
||||
orderCode, serviceList.get(serviceIndex).getProductBomCode());
|
||||
if (!isStocked(item.get("softwareOrderStockingStatus" + softwareFieldIndex))
|
||||
|| !isStocked(item.get("serviceOrderStockingStatus" + serviceFieldIndex))
|
||||
|| softwareBindAmountDto == null
|
||||
|| serviceBindAmountDto == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
BigDecimal serviceSalesWithTax = amountValue(item.get("serviceSalesAmount" + serviceFieldIndex));
|
||||
BigDecimal serviceCostWithTax = defaultValue(serviceBindAmountDto.getCostWithTax());
|
||||
BigDecimal serviceCostWithoutTax = defaultValue(serviceBindAmountDto.getCostWithoutTax());
|
||||
BigDecimal serviceAmountWithoutTax = defaultValue(serviceBindAmountDto.getAmountWithoutTax());
|
||||
BigDecimal serviceGrossProfit = serviceAmountWithoutTax.subtract(serviceCostWithoutTax);
|
||||
|
||||
BigDecimal softwareSalesWithTax = amountValue(item.get("softwareSalesAmount" + softwareFieldIndex)).add(serviceSalesWithTax);
|
||||
BigDecimal softwareCostWithTax = defaultValue(softwareBindAmountDto.getCostWithTax()).add(serviceCostWithTax);
|
||||
BigDecimal softwareCostWithoutTax = defaultValue(softwareBindAmountDto.getCostWithoutTax()).add(serviceCostWithoutTax);
|
||||
BigDecimal softwareAmountWithoutTax = defaultValue(softwareBindAmountDto.getAmountWithoutTax()).add(serviceAmountWithoutTax);
|
||||
BigDecimal softwareGrossProfit = softwareAmountWithoutTax.subtract(softwareCostWithoutTax);
|
||||
|
||||
item.put("softwareSalesAmount" + softwareFieldIndex, softwareSalesWithTax);
|
||||
item.put("softwareCostAmount" + softwareFieldIndex, softwareCostWithTax);
|
||||
item.put("softwareGrossProfit" + softwareFieldIndex, softwareGrossProfit);
|
||||
item.put("softwareGrossProfitRate" + softwareFieldIndex, percentage(softwareGrossProfit, softwareAmountWithoutTax));
|
||||
item.put("serviceSalesAmount" + serviceFieldIndex, BigDecimal.ZERO);
|
||||
item.put("serviceCostAmount" + serviceFieldIndex, BigDecimal.ZERO);
|
||||
item.put("serviceGrossProfit" + serviceFieldIndex, BigDecimal.ZERO);
|
||||
item.put("serviceGrossProfitRate" + serviceFieldIndex, BigDecimal.ZERO);
|
||||
|
||||
softwareSummary.salesWithTax = softwareSummary.salesWithTax.add(serviceSalesWithTax);
|
||||
softwareSummary.salesWithoutTax = softwareSummary.salesWithoutTax.add(serviceAmountWithoutTax);
|
||||
softwareSummary.amountWithoutTax = softwareSummary.amountWithoutTax.add(serviceAmountWithoutTax);
|
||||
softwareSummary.costWithTax = softwareSummary.costWithTax.add(serviceCostWithTax);
|
||||
softwareSummary.costWithoutTax = softwareSummary.costWithoutTax.add(serviceCostWithoutTax);
|
||||
softwareSummary.grossProfit = softwareSummary.grossProfit.add(serviceGrossProfit);
|
||||
softwareSummary.grossProfitRate = percentage(softwareSummary.grossProfit, softwareSummary.amountWithoutTax);
|
||||
|
||||
serviceSummary.salesWithTax = serviceSummary.salesWithTax.subtract(serviceSalesWithTax);
|
||||
serviceSummary.salesWithoutTax = serviceSummary.salesWithoutTax.subtract(serviceAmountWithoutTax);
|
||||
serviceSummary.amountWithoutTax = serviceSummary.amountWithoutTax.subtract(serviceAmountWithoutTax);
|
||||
serviceSummary.costWithTax = serviceSummary.costWithTax.subtract(serviceCostWithTax);
|
||||
serviceSummary.costWithoutTax = serviceSummary.costWithoutTax.subtract(serviceCostWithoutTax);
|
||||
serviceSummary.grossProfit = serviceSummary.grossProfit.subtract(serviceGrossProfit);
|
||||
serviceSummary.grossProfitRate = percentage(serviceSummary.grossProfit, serviceSummary.amountWithoutTax);
|
||||
}
|
||||
|
||||
private int findFirstProductIndex(List<ProjectProductInfo> productInfos, Set<String> productCodes) {
|
||||
if (CollUtil.isEmpty(productInfos)) {
|
||||
return -1;
|
||||
}
|
||||
for (int i = 0; i < productInfos.size(); i++) {
|
||||
if (productCodes.contains(productInfos.get(i).getProductBomCode())) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private boolean isStocked(Object value) {
|
||||
return Boolean.TRUE.equals(value);
|
||||
}
|
||||
|
||||
private BigDecimal amountValue(Object value) {
|
||||
return value instanceof BigDecimal ? (BigDecimal) value : BigDecimal.ZERO;
|
||||
}
|
||||
|
||||
private ProductCostDisplay buildShipmentProductCostDisplay(ProjectProductInfo productInfo, ProductShipmentSummary shipmentSummary) {
|
||||
ProductCostDisplay display = new ProductCostDisplay();
|
||||
BigDecimal requiredQuantity = BigDecimal.valueOf(productInfo.getQuantity() == null ? 0L : productInfo.getQuantity());
|
||||
|
|
@ -698,6 +784,12 @@ public class ProjectOrderInfoToolProvider extends AbstractMcpToolProvider {
|
|||
return value == null ? BigDecimal.ZERO : value;
|
||||
}
|
||||
|
||||
private static Set<String> initCodeSet(String... codes) {
|
||||
Set<String> result = new LinkedHashSet<>();
|
||||
Collections.addAll(result, codes);
|
||||
return Collections.unmodifiableSet(result);
|
||||
}
|
||||
|
||||
private String formatDate(Date value) {
|
||||
return value == null ? "" : DateUtil.format(value, "yyyy-MM-dd");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue