Bladeren bron

私有协议订单功能开发

lipf 5 maanden geleden
bovenliggende
commit
2513ced662

+ 7 - 1
commons/src/main/java/com/jzg/commons/entity/finance/po/InsPlyIncome.java

@@ -44,6 +44,10 @@ public class InsPlyIncome  extends BaseModel {
     @TableField(exist = false)
     private String signingTime;
 
+    @Schema(description = "签单年份")
+    @TableField(exist = false)
+    private String signYear;
+
     @Schema(description = "保司ID")
     private String companyId;
 
@@ -189,5 +193,7 @@ public class InsPlyIncome  extends BaseModel {
     @Schema(description = "订单类型")
     private String orderType;
 
-
+    @TableField(exist = false)
+    @Schema(description = "订单类型(code)")
+    private String entryStatus;
 }

+ 73 - 0
commons/src/main/java/com/jzg/commons/entity/finance/vo/IncomeDataVO.java

@@ -0,0 +1,73 @@
+package com.jzg.commons.entity.finance.vo;
+
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ *
+ * @author lipf
+ * @date 2026/5/12 14:16
+ */
+@Data
+public class IncomeDataVO implements Serializable {
+    @Serial
+    private static final long serialVersionUID = -3396833203930686221L;
+
+    /**
+     * 订单号
+     */
+    private List<String> orderNos;
+
+    /**
+     * 保险公司的id
+     */
+    private String companyId;
+
+    /**
+     * 具体的查询条件
+     */
+    private List<SearchVO> searchList;
+
+    /**
+     * 逻辑判断
+     * and 并且
+     * or 或者
+     */
+    private String logicJudge;
+
+
+    @Data
+    public static class SearchVO implements Serializable {
+        @Serial
+        private static final long serialVersionUID = 6474246099964388105L;
+
+        public static final String companyId = "companyId";
+        public static final String signDate = "signDate";
+        public static final String ptlAgreement = "ptlAgreement";
+        public static final String orderType = "orderType";
+        public static final String signYear = "signYear";
+
+        /**
+         * 查询条件
+         * companyId: 表示保险公司(序号)
+         * signDate: 表示签单日期(yyyy-mm-dd)
+         * ptlAgreement: 表示出单协议
+         * orderType: 表示订单类型 (车险订单,补录订单, 代客录单), 传对应的字典码即可
+         * signYear: 表示签单年份
+         */
+        private String name;
+        /**
+         * 查询条件的操作符号
+         */
+        private String type;
+
+        /**
+         * 条件值1
+         */
+        private String search;
+
+    }
+}

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

@@ -79,6 +79,18 @@ public class ReceivableController {
         return HttpResult.ok(receivableService.getReceivablePage(receivableQueryVo));
     }
 
+    /**
+     *
+     * @author lipf
+     * @date 2026/5/12 14:15
+     */
+    @Operation(summary = "应收数据二次过滤")
+    //@PostMapping("/income/queryIncomeDatas")
+    @PostMapping("getSelectedReceivableList")
+    public HttpResult<List<InsPlyIncome>> queryIncomeDatas(@RequestBody IncomeDataVO incomeDataVO){
+        return receivableService.queryIncomeDatas(incomeDataVO);
+    }
+
     @PostMapping("getOtherReceivableList")
     @Operation(summary = "获取私有协议跟单费列表")
     public HttpResult getOtherReceivableList(@RequestBody ReceivableQueryVo receivableQueryVo){
@@ -103,7 +115,7 @@ public class ReceivableController {
         return HttpResult.ok(receivableService.getReceivablePage(receivableQueryVo));
     }
 
-    @PostMapping("getSelectedReceivableList")
+    //@PostMapping("getSelectedReceivableList")
     @Operation(summary = "获取选中应收列表")
     public HttpResult getSelectedReceivableList(@RequestBody ReceivableQueryVo receivableQueryVo){
         return HttpResult.ok(receivableService.getReceivableList(receivableQueryVo));

+ 8 - 2
tenant/organization/src/main/java/com/jzg/organization/mapper/ReceivableMapper.java

@@ -3,7 +3,6 @@ package com.jzg.organization.mapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.jzg.commons.entity.finance.dto.*;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.jzg.commons.entity.finance.po.InsPlyIncome;
 import com.jzg.commons.entity.finance.vo.InvoiceRecordQueryVo;
 import com.jzg.commons.entity.finance.vo.InvoiceRecordResult;
@@ -15,7 +14,6 @@ import com.jzg.commons.entity.po.EsmInsCompany;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
-import java.math.BigDecimal;
 import java.util.List;
 
 @Mapper
@@ -46,6 +44,14 @@ public interface ReceivableMapper extends BaseMapper<InsPlyIncome> {
      */
     Page<InsPlyIncome> getReceivablePage(Page page,@Param("receivableQueryVo") ReceivableQueryVo receivableQueryVo);
 
+    /**
+     *
+     * @author lipf
+     * @date 2026/5/12 14:50
+     */
+    List<InsPlyIncome> queryIncomeDatasByOrderIds(@Param("orderNos") List<String> orderNos,
+                                                  @Param("companyId") String companyId);
+
     List<InsPlyIncome> getReceivableList(@Param("receivableQueryVo") ReceivableQueryVo receivableQueryVo);
 
     /**

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

@@ -2,6 +2,7 @@ package com.jzg.organization.service;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.jzg.commons.core.page.HttpResult;
 import com.jzg.commons.entity.finance.dto.*;
 import com.jzg.commons.entity.finance.po.InsPlyIncome;
 import com.jzg.commons.entity.finance.po.InsPlyIncomeInvoiceSettlement;
@@ -283,4 +284,12 @@ public interface ReceivableService extends IService<InsPlyIncome> {
      */
     void restockInsPlyIncome(InsOrderAdjust insOrderAdjust);
 
+    /**
+     * 应收数据二次过滤
+     *
+     * @param incomeDataVO 过滤条件
+     * @author lipf
+     * @date 2026/5/12 14:22
+     */
+    HttpResult<List<InsPlyIncome>> queryIncomeDatas(IncomeDataVO incomeDataVO);
 }

+ 184 - 0
tenant/organization/src/main/java/com/jzg/organization/service/impl/ReceivableServiceImpl.java

@@ -3,6 +3,7 @@ package com.jzg.organization.service.impl;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.collection.ListUtil;
 import cn.hutool.core.date.DateTime;
+import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONUtil;
 import com.alibaba.excel.EasyExcel;
 import com.alibaba.nacos.common.utils.CollectionUtils;
@@ -61,6 +62,7 @@ import java.util.*;
 import java.util.concurrent.TimeUnit;
 import java.util.function.BiConsumer;
 import java.util.function.Function;
+import java.util.function.Predicate;
 import java.util.stream.Collectors;
 
 /**
@@ -178,6 +180,188 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
         return page;
     }
 
+    /**
+     * 应收数据二次过滤
+     *
+     * @param incomeDataVO 过滤条件
+     * @author lipf
+     * @date 2026/5/12 14:22
+     */
+    @Override
+    public HttpResult<List<InsPlyIncome>> queryIncomeDatas(IncomeDataVO incomeDataVO) {
+        log.info("应收数据的二次过滤:incomeDataVO=[{}]", JSONUtil.toJsonStr(incomeDataVO));
+        List<String> orderNos = incomeDataVO.getOrderNos();
+        String companyId = incomeDataVO.getCompanyId();
+//        if(CollUtil.isEmpty(orderNos)){
+//            log.info("应收数据的二次过滤: 订单号不能为空");
+//            return HttpResult.error("请勾选要处理的订单信息");
+//        }
+//        if (StrUtil.isEmpty(companyId)) {
+//            log.info("应收数据的二次过滤. 保司不能为空");
+//            return HttpResult.error("保司不能为空");
+//        }
+//        if(!"and".equalsIgnoreCase(incomeDataVO.getLogicJudge()) && "20".equalsIgnoreCase(incomeDataVO.getLogicJudge())){
+//            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);
+        List<InsPlyIncome> filterIncomes = new ArrayList<>();
+        if(CollUtil.isEmpty(incomeDataVO.getSearchList())){
+            filterIncomes = incomes;
+        }else{
+            List<IncomeDataVO.SearchVO> searchParams = incomeDataVO.getSearchList();
+            if(CollUtil.isNotEmpty(searchParams)){
+                Map<String, IncomeDataVO.SearchVO> searchVOMap = searchParams.stream()
+                        .filter(action -> StrUtil.isNotEmpty(action.getName()))
+                        .collect(Collectors.toMap(IncomeDataVO.SearchVO::getName, Function.identity(), (ole_item, new_item) -> ole_item));
+                Set<String> names =searchVOMap.keySet();
+
+                // 保险公司
+                Predicate<InsPlyIncome> companyIdPredicate = insPlyIncome -> {
+                    if(!names.contains(IncomeDataVO.SearchVO.companyId)){
+                        return true;
+                    }
+                    IncomeDataVO.SearchVO searchVO = searchVOMap.get(IncomeDataVO.SearchVO.companyId);
+                    String type = searchVO.getType();
+                    String search = searchVO.getSearch();
+                    if("为空".equals(type)|| "不为空".equals(type)){
+                        return true;
+                    }
+                    // 如果填写的查询条件,不完善,则该条件不进行过滤
+                    if(StrUtil.isEmpty(search)){
+                        return true;
+                    }
+                    if("等于".equalsIgnoreCase(type) || "包含".equalsIgnoreCase(type)){
+                        List<String> companyIds = Arrays.asList(search.split(","));
+                        return companyIds.contains(insPlyIncome.getCompanyId());
+                    }
+                    if("不等于".equalsIgnoreCase(type) || "不包含".equalsIgnoreCase(type)){
+                        List<String> companyIds = Arrays.asList(search.split(","));
+                        return !companyIds.contains(insPlyIncome.getCompanyId());
+                    }
+                    return true;
+                };
+                // 签单时间
+                Predicate<InsPlyIncome> signDatePredicate = insPlyIncome -> {
+                    String signingTime = insPlyIncome.getSigningTime();
+                    if(StrUtil.isEmpty(signingTime)){
+                        // 签单时间如果为空,说明是数据问题 先返回去,让业务去处理
+                        return true;
+                    }
+                    if(!names.contains(IncomeDataVO.SearchVO.signDate)){
+                        return true;
+                    }
+                    IncomeDataVO.SearchVO searchVO = searchVOMap.get(IncomeDataVO.SearchVO.ptlAgreement);
+                    String type = searchVO.getType();
+                    String search = searchVO.getSearch();
+                    if("为空".equals(type)|| "不为空".equals(type)){
+                        return true;
+                    }
+                    // 如果填写的查询条件,不完善,则该条件不进行过滤
+                    if(StrUtil.isEmpty(search)){
+                        return true;
+                    }
+
+                    if("大于等于".equals(type)){
+
+                    }
+
+
+                    return true;
+                };
+                // 出单协议
+                Predicate<InsPlyIncome> ptlAgreementPredicate = insPlyIncome -> {
+                    if(!names.contains(IncomeDataVO.SearchVO.ptlAgreement)){
+                        return true;
+                    }
+                    IncomeDataVO.SearchVO searchVO = searchVOMap.get(IncomeDataVO.SearchVO.ptlAgreement);
+                    String type = searchVO.getType();
+                    String search = searchVO.getSearch();
+                    if("为空".equals(type)|| "不为空".equals(type)){
+                        return true;
+                    }
+                    // 如果填写的查询条件,不完善,则该条件不进行过滤
+                    if(StrUtil.isEmpty(search)){
+                        return true;
+                    }
+                    if("等于".equalsIgnoreCase(type) || "包含".equalsIgnoreCase(type)){
+                        List<String> ptlAgrements = Arrays.asList(search.split(","));
+                        return ptlAgrements.contains(insPlyIncome.getAgreementId());
+                    }
+                    if("不等于".equalsIgnoreCase(type) || "不包含".equalsIgnoreCase(type)){
+                        List<String> ptlAgrements = Arrays.asList(search.split(","));
+                        return !ptlAgrements.contains(insPlyIncome.getAgreementId());
+                    }
+                    return true;
+                };
+
+                // 订单类型 entryStatus
+                Predicate<InsPlyIncome> orderTypePredicate = insPlyIncome -> {
+                    if(!names.contains(IncomeDataVO.SearchVO.companyId)){
+                        return true;
+                    }
+                    IncomeDataVO.SearchVO searchVO = searchVOMap.get(IncomeDataVO.SearchVO.companyId);
+                    String type = searchVO.getType();
+                    String search = searchVO.getSearch();
+                    if("为空".equals(type)|| "不为空".equals(type)){
+                        return true;
+                    }
+                    // 如果填写的查询条件,不完善,则该条件不进行过滤
+                    if(StrUtil.isEmpty(search)){
+                        return true;
+                    }
+                    if("等于".equalsIgnoreCase(type) || "包含".equalsIgnoreCase(type)){
+                        List<String> entryStatus = Arrays.asList(search.split(","));
+                        return entryStatus.contains(insPlyIncome.getEntryStatus());
+                    }
+                    if("不等于".equalsIgnoreCase(type) || "不包含".equalsIgnoreCase(type)){
+                        List<String> entryStatus = Arrays.asList(search.split(","));
+                        return !entryStatus.contains(insPlyIncome.getEntryStatus());
+                    }
+                    return true;
+                };
+
+                // 签单年份
+                Predicate<InsPlyIncome> signYearPredicate = insPlyIncome ->{
+                    if(!names.contains(IncomeDataVO.SearchVO.companyId)){
+                        return true;
+                    }
+                    IncomeDataVO.SearchVO searchVO = searchVOMap.get(IncomeDataVO.SearchVO.companyId);
+                    String type = searchVO.getType();
+                    String search = searchVO.getSearch();
+                    if("为空".equals(type)|| "不为空".equals(type)){
+                        return true;
+                    }
+                    // 如果填写的查询条件,不完善,则该条件不进行过滤
+                    if(StrUtil.isEmpty(search)){
+                        return true;
+                    }
+                    if("等于".equalsIgnoreCase(type) || "包含".equalsIgnoreCase(type)){
+                        List<String> signYears = Arrays.asList(search.split(","));
+                        return signYears.contains(insPlyIncome.getSignYear());
+                    }
+                    if("不等于".equalsIgnoreCase(type) || "不包含".equalsIgnoreCase(type)){
+                        List<String> signYears = Arrays.asList(search.split(","));
+                        return !signYears.contains(insPlyIncome.getSigningTime());
+                    }
+                    return true;
+                };
+                if("and".equalsIgnoreCase(incomeDataVO.getLogicJudge())){
+                    Predicate<InsPlyIncome> and = companyIdPredicate.and(signDatePredicate).and(ptlAgreementPredicate).and(orderTypePredicate).and(signYearPredicate);
+                    filterIncomes = incomes.stream().filter(and).toList();
+                }else if ("or".equalsIgnoreCase(incomeDataVO.getLogicJudge())){
+                    Predicate<InsPlyIncome> or = companyIdPredicate.or(signDatePredicate).or(ptlAgreementPredicate).or(orderTypePredicate).or(signYearPredicate);
+                    filterIncomes = incomes.stream().filter(or).toList();
+                }
+            }
+        }
+
+        filterIncomes = this.fillOtherInfo(filterIncomes);
+        return HttpResult.ok(filterIncomes);
+    }
+
+
 
     /**
      * 填充必要的字段

+ 68 - 49
tenant/organization/src/main/resources/mapper/ReceivableMapper.xml

@@ -197,59 +197,78 @@
         </if>
     </select>
 
-    <select id="getReceivablePage" resultType="com.jzg.commons.entity.finance.po.InsPlyIncome">
+    <sql id="query">
         SELECT
-            io.signing_time,
-            ipi.id,
-            io.id as 'orderNo',
-            io.company_name,
-            ipi.dept_name,
-            ipi.agreement_name,
-            io.product_name,
-            CASE io.entry_status
-            WHEN 1 THEN '车险出单'
-            WHEN 2 THEN '代客录单'
-            WHEN 3 THEN '补录订单'
-            ELSE '未知状态'
-            END AS order_type,
-            ipi.license_no,
-            (ipi.jq_receivable_premium + ipi.sy_receivable_premium + ipi.jy_receivable_premium) as receivableAmount,  -- 总应收金额
-            (ipi.jq_supervise_costs_premiums + ipi.sy_supervise_costs_premiums + ipi.jy_supervise_costs_premiums) as superviseCostsPremiums, -- 总应收手续费
-            (ipi.jq_other_costs_premiums + ipi.sy_other_costs_premiums + ipi.jy_other_costs_premiums) as otherCostsPremiums,  -- 总应收跟单费
-            io.product_name,
-            iocui.name AS insuredPerson,
-            ipi.jq_premium,
-            ipi.sy_premium,
-            ipi.jy_premium,
-            ipi.tax_premium,
-            ipi.jq_supervise_costs_proportion,
-            ipi.sy_supervise_costs_proportion,
-            ipi.jy_supervise_costs_proportion,
-            ipi.jq_other_costs_proportion,
-            ipi.sy_other_costs_proportion,
-            ipi.jy_other_costs_proportion,
-            ipi.business_source,
-            ipi.settlement_status,
-            ipi.add_type,
-            ior1.start_date as jq_start_date,
-            ior2.start_date as sy_start_date,
-            io.product_name AS productName,
-            iop.jq_policy_no, -- 交强保单号
-            iop.sy_policy_no, -- 商业保单号
-            iop.jy_policy_no, -- 非车险保单号
-            io.company_name,
-            io.create_time,
-            io.docking_person
-
+        io.signing_time,
+        year(io.signing_time) as sign_year,
+        ipi.id,
+        io.id as 'orderNo',
+        io.company_name,
+        ipi.dept_name,
+        ipi.agreement_name,
+        io.product_name,
+        CASE io.entry_status
+        WHEN 1 THEN '车险出单'
+        WHEN 2 THEN '代客录单'
+        WHEN 3 THEN '补录订单'
+        ELSE '未知状态'
+        END AS order_type,
+        ipi.license_no,
+        (ipi.jq_receivable_premium + ipi.sy_receivable_premium + ipi.jy_receivable_premium) as receivableAmount,  -- 总应收金额
+        (ipi.jq_supervise_costs_premiums + ipi.sy_supervise_costs_premiums + ipi.jy_supervise_costs_premiums) as superviseCostsPremiums, -- 总应收手续费
+        (ipi.jq_other_costs_premiums + ipi.sy_other_costs_premiums + ipi.jy_other_costs_premiums) as otherCostsPremiums,  -- 总应收跟单费
+        io.product_name,
+        iocui.name AS insuredPerson,
+        ipi.jq_premium,
+        ipi.sy_premium,
+        ipi.jy_premium,
+        ipi.tax_premium,
+        ipi.jq_supervise_costs_proportion,
+        ipi.sy_supervise_costs_proportion,
+        ipi.jy_supervise_costs_proportion,
+        ipi.jq_other_costs_proportion,
+        ipi.sy_other_costs_proportion,
+        ipi.jy_other_costs_proportion,
+        ipi.business_source,
+        ipi.settlement_status,
+        ipi.add_type,
+        ior1.start_date as jq_start_date,
+        ior2.start_date as sy_start_date,
+        io.product_name AS productName,
+        iop.jq_policy_no, -- 交强保单号
+        iop.sy_policy_no, -- 商业保单号
+        iop.jy_policy_no, -- 非车险保单号
+        io.company_name,
+        io.company_id,
+        io.create_time,
+        io.docking_person
         FROM
-            ins_ply_income ipi
-            LEFT JOIN ins_orders io ON ipi.order_no = io.id
-            LEFT JOIN ins_orders_car_user_info iocui ON ipi.order_no = iocui.order_no and iocui.policy_person_type = '3'
-            LEFT JOIN ins_orders_risk ior1 ON ipi.order_no = ior1.order_no and ior1.risk_code = '0507'
-            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
+        ins_ply_income ipi
+        LEFT JOIN ins_orders io ON ipi.order_no = io.id
+        LEFT JOIN ins_orders_car_user_info iocui ON ipi.order_no = iocui.order_no and iocui.policy_person_type = '3'
+        LEFT JOIN ins_orders_risk ior1 ON ipi.order_no = ior1.order_no and ior1.risk_code = '0507'
+        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
         WHERE 1=1
         AND NOT EXISTS ( SELECT 1 FROM ins_ply_income_invoice_link ipil WHERE ipil.income_id = ipi.id )
+    </sql>
+
+    <!--根据保司id和订单号进行过滤 2026年5月12日15:06:40  lipf  -->
+    <select id="queryIncomeDatasByOrderIds" resultType="com.jzg.commons.entity.finance.po.InsPlyIncome">
+        <include refid="query"/>
+        <if test="companyId != null and companyId != ''">
+            and io.company_id = #{companyId}
+        </if>
+        <if test="orderNos != null and orderNos.size() > 0">
+            and io.id in
+            <foreach collection="orderNos" item="id" open="(" separator="," close=")">
+                #{id}
+            </foreach>
+        </if>
+    </select>
+    
+    <select id="getReceivablePage" resultType="com.jzg.commons.entity.finance.po.InsPlyIncome">
+        <include refid="query"/>
         <if test = "receivableQueryVo.agreementType != null and receivableQueryVo.agreementType == 1">
             AND ipi.agreement_type = #{receivableQueryVo.agreementType}
         </if>