From 39f9530fd81c481faed2925b57d66347065709f9 Mon Sep 17 00:00:00 2001 From: wujianwei <wjw@11.com> Date: 星期四, 14 八月 2025 14:26:42 +0800 Subject: [PATCH] 新增结算中和已结算无法修改数据 --- service/src/main/java/com/ruoyi/cwgl/service/impl/ExactPricingRuleMatcher.java | 92 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 92 insertions(+), 0 deletions(-) diff --git a/service/src/main/java/com/ruoyi/cwgl/service/impl/ExactPricingRuleMatcher.java b/service/src/main/java/com/ruoyi/cwgl/service/impl/ExactPricingRuleMatcher.java new file mode 100644 index 0000000..39af2e5 --- /dev/null +++ b/service/src/main/java/com/ruoyi/cwgl/service/impl/ExactPricingRuleMatcher.java @@ -0,0 +1,92 @@ +package com.ruoyi.cwgl.service.impl; + +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.cwgl.domain.ReceivableLineTruckPriceRule; + +import java.math.BigDecimal; +import java.util.List; + +/** + * 绮剧‘杩愯垂瑙勫垯鍖归厤鏈嶅姟 + */ +public class ExactPricingRuleMatcher { + + /** + * 鏌ユ壘鍖归厤鐨勮繍璐硅鍒� + * @param rules 鎵�鏈夎繍璐硅鍒欏垪琛� + * @param customerName 瀹㈡埛鍚嶇О + * @param departureLocation 鍑哄彂鍦板畬鏁村湴鍧� + * @param arrivalLocation 鐩殑鍦板畬鏁村湴鍧� + * @param vehicleType 杞﹀瀷 + * @return 鍖归厤鐨勮繍璐硅鍒欙紝娌℃湁鍒欒繑鍥瀗ull + */ + public static ReceivableLineTruckPriceRule findExactMatchingRule( + List<ReceivableLineTruckPriceRule> rules, + String customerName, + String departureLocation, + String arrivalLocation, + String vehicleType) { + + + + for (ReceivableLineTruckPriceRule rule : rules) { + // 瀹㈡埛鍚嶇О蹇呴』瀹屽叏鍖归厤 + if (!isFieldMatch(rule.getCustomerName(), customerName)) { + continue; + } + + // 杞﹀瀷蹇呴』瀹屽叏鍖归厤 + if (!isFieldMatch(rule.getVehicleType(), vehicleType)) { + continue; + } + + // 鍙戣揣鍦板尮閰嶏細瑙勫垯涓殑鍙戣揣甯傚拰鍖哄繀椤婚兘鍖呭惈鍦ㄥ疄闄呭彂璐у湴鍧�涓� + if (!isAddressMatch(rule.getDepartureCity(), rule.getDepartureDistrict(), + departureLocation)) { + continue; + } + + // 鏀惰揣鍦板尮閰嶏細瑙勫垯涓殑鏀惰揣甯傚拰鍖哄繀椤婚兘鍖呭惈鍦ㄥ疄闄呮敹璐у湴鍧�涓� + if (!isAddressMatch(rule.getArrivalCity(), rule.getArrivalDistrict(), + arrivalLocation)) { + continue; + } + + // 鎵�鏈夋潯浠堕兘婊¤冻锛岃繑鍥炲尮閰嶇殑瑙勫垯 + return rule; + } + + return null; + } + + /** + * 鍦板潃鍖归厤閫昏緫 + */ + private static boolean isAddressMatch(String ruleCity, String ruleDistrict, + String location) { + boolean cityFlag = true; + boolean districtFlag = true; + if(StringUtils.isNotEmpty(ruleCity) && !location.contains(ruleCity)){ + cityFlag = false; + } + + if(StringUtils.isNotEmpty(ruleDistrict) && !location.contains(ruleDistrict)){ + districtFlag = false; + } + + + + + return (cityFlag&&districtFlag); + } + + /** + * 鏅�氬瓧娈靛尮閰嶉�昏緫 + */ + private static boolean isFieldMatch(String ruleValue, String actualValue) { + // 濡傛灉瑙勫垯涓畾涔変簡鍊硷紝鍒欏繀椤诲畬鍏ㄥ尮閰� + return ruleValue == null || ruleValue.isEmpty() || ruleValue.equals(actualValue); + } + + +} \ No newline at end of file -- Gitblit v1.8.0