Forráskód Böngészése

refactor(policyFee): 优化价格策略查询逻辑,移除冗余设备信息查询

- 删除了对ThirdPartyEquipmentInfo的单独查询,简化代码逻辑
- 通过第三方连接器信息(ThirdPartyConnectorInfo)获取connectorId用于价格策略查询
- 引入ThirdPartyConnectorInfoMapper,实现基于站点ID的连接器查询
- 调整代码结构,提升查询效率和代码可读性
- 修正list添加元素顺序,确保逻辑正确
SheepHy 17 órája
szülő
commit
886b006437

+ 8 - 18
src/main/java/com/zsElectric/boot/business/service/impl/PolicyFeeServiceImpl.java

@@ -8,10 +8,8 @@ import com.zsElectric.boot.business.model.dto.AddPolicyFeeDTO;
 import com.zsElectric.boot.business.model.entity.PolicyFee;
 import com.zsElectric.boot.business.model.vo.TimePeriodPriceVO;
 import com.zsElectric.boot.business.service.PolicyFeeService;
-import com.zsElectric.boot.charging.entity.ThirdPartyEquipmentInfo;
-import com.zsElectric.boot.charging.entity.ThirdPartyEquipmentPricePolicy;
-import com.zsElectric.boot.charging.entity.ThirdPartyPolicyInfo;
-import com.zsElectric.boot.charging.entity.ThirdPartyStationInfo;
+import com.zsElectric.boot.charging.entity.*;
+import com.zsElectric.boot.charging.mapper.ThirdPartyConnectorInfoMapper;
 import com.zsElectric.boot.charging.mapper.ThirdPartyEquipmentPricePolicyMapper;
 import com.zsElectric.boot.charging.mapper.ThirdPartyPolicyInfoMapper;
 import com.zsElectric.boot.system.model.entity.DictItem;
@@ -49,8 +47,6 @@ public class PolicyFeeServiceImpl implements PolicyFeeService {
 
     private final PolicyFeeMapper policyFeeMapper;
 
-    private final ThirdPartyEquipmentInfoMapper thirdPartyEquipmentInfoMapper;
-
     private final ThirdPartyPolicyInfoMapper thirdPartyPolicyInfoMapper;
 
     private final ThirdPartyEquipmentPricePolicyMapper thirdPartyEquipmentPricePolicyMapper;
@@ -59,22 +55,16 @@ public class PolicyFeeServiceImpl implements PolicyFeeService {
 
     private final ThirdPartyStationInfoMapper stationInfoMapper;
 
+    private final ThirdPartyConnectorInfoMapper thirdPartyConnectorInfoMapper;
+
     @Override
     public List<TimePeriodPriceVO> getPolicyFee(long stationId, int salesType, Long firmId, Long thirdPartyId) {
         List<TimePeriodPriceVO> timePeriodPriceVOS = new ArrayList<>();
-        
-        // 查询设备信息
-        ThirdPartyEquipmentInfo thirdPartyEquipmentInfo = thirdPartyEquipmentInfoMapper.selectOne(Wrappers.<ThirdPartyEquipmentInfo>lambdaQuery()
-                .eq(ThirdPartyEquipmentInfo::getStationId, stationId)
-                .eq(ThirdPartyEquipmentInfo::getIsDeleted, 0)
-                .last("limit 1"));
-        if (thirdPartyEquipmentInfo == null) {
-            return timePeriodPriceVOS;
-        }
-        
+
         // 查询价格策略
         ThirdPartyEquipmentPricePolicy pricePolicy = thirdPartyEquipmentPricePolicyMapper.selectOne(Wrappers.<ThirdPartyEquipmentPricePolicy>lambdaQuery()
-                .eq(ThirdPartyEquipmentPricePolicy::getConnectorId, thirdPartyEquipmentInfo.getEquipmentId())
+                .eq(ThirdPartyEquipmentPricePolicy::getConnectorId, thirdPartyConnectorInfoMapper.selectOne(Wrappers.<ThirdPartyConnectorInfo>lambdaQuery()
+                        .eq(ThirdPartyConnectorInfo::getStationId,stationInfoMapper.selectById(stationId).getStationId()).last("limit 1")).getConnectorId())
                 .eq(ThirdPartyEquipmentPricePolicy::getIsDeleted, 0)
                 .last("limit 1"));
         if (pricePolicy == null) {
@@ -140,8 +130,8 @@ public class PolicyFeeServiceImpl implements PolicyFeeService {
                                 .add(policyInfo.getServicePrice())
                                 .add(policyFee.getOpFee())
                                 .add(valueAddedFees));
-                timePeriodPriceVOS.add(timePeriodPriceVO);
             }
+            timePeriodPriceVOS.add(timePeriodPriceVO);
         }
         
         return timePeriodPriceVOS;