Преглед изворни кода

合并查询数据和相关数据汇总的接口为一个接口,保证数据的一致性

lipf пре 4 месеци
родитељ
комит
c8e9018730

+ 2 - 0
commons/src/main/java/com/jzg/commons/entity/finance/po/InsPlyIncomeOrder.java

@@ -5,6 +5,7 @@ import lombok.Data;
 import java.io.Serial;
 import java.io.Serializable;
 
+
 @Data
 public class InsPlyIncomeOrder implements Serializable {
 
@@ -20,6 +21,7 @@ public class InsPlyIncomeOrder implements Serializable {
      */
     private String orderNo;
 
+
     public InsPlyIncomeOrder(String id, String orderNo) {
         this.id = id;
         this.orderNo = orderNo;

+ 11 - 1
commons/src/main/java/com/jzg/commons/entity/finance/po/InsPlyIncomeVO.java

@@ -21,9 +21,19 @@ public class InsPlyIncomeVO implements Serializable {
      */
     private List<InsPlyIncomeOrder> insPlyIncomeOrders;
 
-    public InsPlyIncomeVO(Page insPlyIncomePage, List<InsPlyIncomeOrder> insPlyIncomeOrders){
+    /**
+     * 应收金额总计
+     */
+    private String allAmount;
+
+    public InsPlyIncomeVO(Page insPlyIncomePage, List<InsPlyIncomeOrder> insPlyIncomeOrders, String allAmount) {
         this.insPlyIncomePage = insPlyIncomePage;
         this.insPlyIncomeOrders = insPlyIncomeOrders;
+        this.allAmount = allAmount;
     }
 
+    public InsPlyIncomeVO(Page insPlyIncomePage, List<InsPlyIncomeOrder> insPlyIncomeOrders) {
+        this.insPlyIncomePage = insPlyIncomePage;
+        this.insPlyIncomeOrders = insPlyIncomeOrders;
+    }
 }

+ 13 - 0
tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/controller/InsFeeOrderController.java

@@ -11,6 +11,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 /**
@@ -60,6 +61,18 @@ public class InsFeeOrderController {
         return insFeeOrdersService.getInsFeeOrderByOrderNo(orderNo);
     }
 
+    /**
+     * 查询指定订单的应收总额
+     *
+     * @param orderNos 订单编号
+     * @author lipf
+     * @date 2026/6/4 10:17
+     */
+    @PostMapping("/insFeeOrder/queryAllTotalReceivablePremiumByOrderNo")
+    BigDecimal queryAllTotalReceivablePremiumByOrderNo(@RequestBody List<String> orderNos){
+        return insFeeOrdersService.queryAllTotalReceivablePremiumByOrderNo(orderNos);
+    }
+
     @Operation(summary = "修改权益可用金额")
     @PostMapping("updateAvailableAmount")
     public HttpResult updateOrders(@RequestBody RightsAmountUpdateDto rightsAmountUpdateDto) {

+ 10 - 0
tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/mapper/InsFeeOrdersMapper.java

@@ -6,6 +6,7 @@ import com.jzg.commons.entity.po.InsFeeOrders;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 @Mapper
@@ -19,4 +20,13 @@ public interface InsFeeOrdersMapper extends BaseMapper<InsFeeOrders> {
     List<InsFeeOrders> getInsFeeOrderAudit(String userId);
 
     List<InsFeeOrders> getInsFeeOrderByOrderNo(String orderNo);
+
+    /**
+     * 查询应收总额
+     *
+     * @author lipf
+     * @date 2026/6/4 10:22
+     */
+    BigDecimal queryAllTotalReceivablePremiumByOrderNo(@Param("orders") List<String> orders);
+
 }

+ 9 - 0
tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/service/InsFeeOrdersService.java

@@ -26,4 +26,13 @@ public interface InsFeeOrdersService extends IService<InsFeeOrders> {
     HttpResult updateAvailableAmount(String orderNo,BigDecimal availableAmount);
 
     CostCalculateRespVO computedCostInfo(PtlAgreementCostRatioVo param);
+
+    /**
+     * 查询指定订单的应收总额
+     *
+     * @param orderNos 订单编号
+     * @author lipf
+     * @date 2026/6/4 10:17
+     */
+    BigDecimal queryAllTotalReceivablePremiumByOrderNo(List<String> orderNos);
 }

+ 25 - 0
tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/service/impl/InsFeeOrdersServiceImpl.java

@@ -1,5 +1,7 @@
 package com.jzg.quotation.summary.service.impl;
 
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.collection.ListUtil;
 import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -394,4 +396,27 @@ public class InsFeeOrdersServiceImpl extends ServiceImpl<InsFeeOrdersMapper, Ins
         wrapper.eq(InsFeeOrders::getOrderNo, orderNo);
         return insFeeOrdersMapper.selectOne(wrapper);
     }
+
+    /**
+     * 查询指定订单的应收总额
+     *
+     * @param orderNos 订单编号
+     * @author lipf
+     * @date 2026/6/4 10:17
+     */
+    @Override
+    public BigDecimal queryAllTotalReceivablePremiumByOrderNo(List<String> orderNos) {
+        if(CollUtil.isEmpty(orderNos)){
+            return BigDecimal.ZERO;
+        }
+        List<List<String>> split = ListUtil.split(orderNos, 3000);
+        BigDecimal initAmout = BigDecimal.ZERO;
+        for (List<String> orders : split) {
+            BigDecimal amount  = insFeeOrdersMapper.queryAllTotalReceivablePremiumByOrderNo(orders);
+            if (amount != null) {
+                initAmout = initAmout.add(amount);
+            }
+        }
+        return initAmout;
+    }
 }

+ 13 - 0
tenant/insurance/quotation-summary/src/main/resources/mapper/InsFeeOrdersMapper.xml

@@ -80,4 +80,17 @@
             </if>
         </where>
     </select>
+
+    <!-- 查询应收订单总额 lipf 2026年6月4日10:22:57 -->
+    <select id="queryAllTotalReceivablePremiumByOrderNo" resultType="java.math.BigDecimal">
+        SELECT
+            sum(COALESCE(ifo.total_receivable_premium, 0))
+        from
+            ins_fee_orders ifo
+        <where>
+            <foreach collection="orders" item="order" open="(" separator="," close=")">
+                #{order}
+            </foreach>
+        </where>
+    </select>
 </mapper>

+ 10 - 0
tenant/organization/src/main/java/com/jzg/organization/client/InsFeeOrdersClient.java

@@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestParam;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 /**
@@ -30,4 +31,13 @@ public interface InsFeeOrdersClient {
     @Operation(summary = "车险报价批量修改联系人等信息")
     HttpResult<String> updateOrdersBatch(@RequestBody BatchModifyVo batchModifyVo);
 
+    /**
+     * 查询指定订单的应收总额
+     *
+     * @param orderNos 订单编号
+     * @author lipf
+     * @date 2026/6/4 10:17
+     */
+    @PostMapping("/insFeeOrder/queryAllTotalReceivablePremiumByOrderNo")
+    BigDecimal queryAllTotalReceivablePremiumByOrderNo(@RequestBody List<String> orderNos);
 }

+ 11 - 1
tenant/organization/src/main/java/com/jzg/organization/controller/ReceivableController.java

@@ -369,11 +369,21 @@ public class ReceivableController {
         }
         Page<InsPlyIncome> data = receivableService.getPlatFormReceivableList(receivableQueryVo);
         List<InsPlyIncomeOrder> receivablePageIds = receivableService.getReceivablePageIds(receivableQueryVo);
-        return HttpResult.ok(new InsPlyIncomeVO(data, receivablePageIds));
+        //满足条件的的总的应收
+        BigDecimal totalReceivablePremium = null;
+        try{
+            List<String> orderNos = receivablePageIds.stream().map(InsPlyIncomeOrder::getOrderNo).distinct().toList();
+            totalReceivablePremium = receivableService.queryAllTotalReceivablePremium(orderNos);
+        }catch (Exception e){
+            log.error("统计总的应收异常",e);
+        }
+        // receivablePageIds.stream().map(InsPlyIncomeOrder::getTotalReceivablePremium).reduce(BigDecimal.ZERO, BigDecimal::add);
+        return HttpResult.ok(new InsPlyIncomeVO(data, receivablePageIds, Objects.toString(totalReceivablePremium,"汇总金额异常")));
     }
 
     @PostMapping("/getPlatFormReceivableTotalAmount")
     @Operation(summary = "获取平台协议总金额")
+    @Deprecated(since = "2026-06-04")
     public HttpResult<BigDecimal> getPlatFormReceivableTotalAmount(@RequestBody ReceivableQueryVo receivableQueryVo){
         if (StrUtil.isBlank(receivableQueryVo.getQueryType())){
             receivableQueryVo.setQueryType("1");

+ 9 - 0
tenant/organization/src/main/java/com/jzg/organization/service/ReceivableService.java

@@ -405,4 +405,13 @@ public interface ReceivableService extends IService<InsPlyIncome> {
      * @return
      */
     boolean deleteSettlementById(String id);
+
+    /**
+     * 查询所有订单的应收总额
+     *
+     * @param orderNos 订单编号
+     * @author lipf
+     * @date 2026/6/4 10:15
+     */
+    BigDecimal queryAllTotalReceivablePremium(List<String> orderNos);
 }

+ 20 - 4
tenant/organization/src/main/java/com/jzg/organization/service/impl/ReceivableServiceImpl.java

@@ -225,7 +225,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
     public List<InsPlyIncomeOrder> getReceivablePageIds(ReceivableQueryVo receivableQueryVo) {
         log.info("获取私有协议手续费应收列表的id集合。receivableQueryVo=[{}]", JSONUtil.toJsonStr(receivableQueryVo));
         // 设置page的searhCount 为false,则不会查询总数,会直接查询具体的值
-        Page<InsPlyIncome> page1 = new Page<>(1, 10000, false);
+        Page<InsPlyIncome> page1 = new Page<>(1, Integer.MAX_VALUE, false);
         Page<InsPlyIncome> page = baseMapper.getReceivablePage(page1, receivableQueryVo);
         List<InsPlyIncomeOrder> res = page.getRecords().stream()
                 .map(action -> new InsPlyIncomeOrder(action.getId(), action.getOrderNo())).toList();
@@ -257,8 +257,13 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
 //            log.info("应收数据的二次过滤. 逻辑条件必须是and或or");
 //            return HttpResult.error("逻辑条件必须是and或or");
 //        }
+
         List<InsPlyIncome> incomes =  baseMapper.queryIncomeDatasByOrderIds(orderNos,companyId);
         log.info("根据订单号和保司id查询出[{}]条记录。 orderNos =[{}],companyId=[{}]",CollUtil.size(incomes), JSONUtil.toJsonStr(orderNos), companyId);
+        // 需要查询未结算的数据 modify by lipf 2026年6月4日11:06:50
+        incomes = incomes.stream().filter(action->{
+            return "0".equals(action.getSettlementStatus());
+        }).toList();
         List<InsPlyIncome> filterIncomes = new ArrayList<>();
         if(CollUtil.isEmpty(incomeDataVO.getSearchList())){
             filterIncomes = incomes;
@@ -563,9 +568,9 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
                 String typeAttrName = Constant.ywyAttrTypeMap.get(typeAttr);
                 insPlyIncome.setTypeAttr(typeAttr);
                 insPlyIncome.setTypeAttrName(typeAttrName);
-                // 费用信息
-                List<InsFeeOrders> insFeeOrderByOrderNo = insFeeOrdersClient.getInsFeeOrderByOrderNo(insPlyIncome.getOrderNo());
-                insPlyIncome.setInsFeeOrders(CollUtil.getFirst(insFeeOrderByOrderNo));
+                // 费用信息, 这里添加费用,性能会很慢
+//                List<InsFeeOrders> insFeeOrderByOrderNo = insFeeOrdersClient.getInsFeeOrderByOrderNo(insPlyIncome.getOrderNo());
+//                insPlyIncome.setInsFeeOrders(CollUtil.getFirst(insFeeOrderByOrderNo));
 
                 String invoiceId = income2InvoceIdMap.get(insPlyIncome.getId());
                 insPlyIncome.setInvoiceStatusName(StrUtil.isEmpty(invoiceId)? "未开票":"已开票");
@@ -1368,6 +1373,17 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
         return insPlyIncomeInvoiceSettlementMapper.deleteById(id) > 0;
     }
 
+    /**
+     * 查询所有订单的应收总额
+     *
+     * @param orderNos 订单编号
+     * @author lipf
+     * @date 2026/6/4 10:15
+     */
+    @Override
+    public BigDecimal queryAllTotalReceivablePremium(List<String> orderNos) {
+        return insFeeOrdersClient.queryAllTotalReceivablePremiumByOrderNo(orderNos);
+    }
 
     @Override
     @Transactional(rollbackFor = Exception.class)

+ 3 - 1
tenant/organization/src/main/resources/mapper/ReceivableMapper.xml

@@ -259,7 +259,9 @@
         LEFT JOIN ins_orders_risk ior2 ON ipi.order_no = ior2.order_no and ior2.risk_code = '0510'
         LEFT JOIN ins_orders_policy iop ON ipi.order_no = iop.order_no
         LEFT JOIN esm_ins_company eic on ipi.company_id = eic.id
-        WHERE 1=1 and ipi.settlement_status = '0' and ipi.is_delete  = 0
+        WHERE 1=1
+        -- and ipi.settlement_status = '0'  -- 已经结算的车辆,在应收订单里面,还需要能查询到
+        and ipi.is_delete  = 0
     </sql>
 
     <!--根据保司id和订单号进行过滤 2026年5月12日15:06:40  lipf  -->