소스 검색

1.平台结算bug修改4.0

wuhp 2 년 전
부모
커밋
8db2a72415

+ 3 - 2
src/main/java/com/ydtech/modules/fnc/controller/InsPlyIncomeController.java

@@ -26,6 +26,7 @@ import java.io.IOException;
 import java.math.BigDecimal;
 import java.time.LocalDate;
 import java.time.Period;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 
@@ -154,9 +155,9 @@ public class InsPlyIncomeController extends BaseController {
     })
     public HttpResult importData(@RequestParam MultipartFile multipartFile) {
 
-        insPlyIncomeService.importData(multipartFile);
+        HashMap<String, Object> result= insPlyIncomeService.importData(multipartFile);
 
-        return HttpResult.ok("导入成功");
+        return HttpResult.ok(result);
     }
     @PostMapping("/bxImportData")
     @ApiOperation(value = "保险手续费导入(excel)")

+ 5 - 1
src/main/java/com/ydtech/modules/fnc/dao/InsPlyIncomeMapper.java

@@ -96,7 +96,7 @@ public interface InsPlyIncomeMapper extends BaseMapper<InsPlyIncome> {
     List<InsPlyIncome> allOtherAmount(HashMap<String, Object> params);
 
 
-    List<InsPlyIncome> findByLicenseno(HashMap<String, Object> params);
+    InsPlyIncome findByLicenseno(HashMap<String, Object> params);
 
     InsPlyIncome bxTotalAmount(HashMap<String, Object> params);
 
@@ -113,4 +113,8 @@ public interface InsPlyIncomeMapper extends BaseMapper<InsPlyIncome> {
     List<HashMap<String,Object>> groupByInvoic(@Param("idArr") String[] idArr);
 
 
+    List<InsPlyIncome> getIncomeIdList(HashMap<String, Object> params);
+
+    List<HashMap<String,Object>> getOtherIds(HashMap<String, Object> params);
+
 }

+ 2 - 0
src/main/java/com/ydtech/modules/fnc/dao/SettlementDocumentaryFeesMapper.java

@@ -24,4 +24,6 @@ public interface SettlementDocumentaryFeesMapper  extends BaseMapper<SettlementD
     List<HashMap<String, Object>> getOtherSettldetail(@Param("invoiceIds") String[] invoiceIds);
 
     void batchByInvoice( HashMap<String,Object> ids);
+
+    List<HashMap<String, Object>> getInvoicIds(HashMap<String, Object> params);
 }

+ 2 - 1
src/main/java/com/ydtech/modules/fnc/service/InsPlyIncomeService.java

@@ -13,6 +13,7 @@ import org.springframework.web.multipart.MultipartFile;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.math.BigDecimal;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 
@@ -46,7 +47,7 @@ public interface InsPlyIncomeService extends IService<InsPlyIncome> {
     HttpResult<List<InsPlyIncome>> nonSettldetail(InsPlyIncomeVo insPlyIncomeVo);
 
 
-    void importData(MultipartFile multipartFile);
+    HashMap<String, Object> importData(MultipartFile multipartFile);
 
     void updateByEntity(InsPlyIncomeVo insPlyIncomeVo);
 

+ 3 - 0
src/main/java/com/ydtech/modules/fnc/service/SettlementDocumentaryFeesService.java

@@ -22,4 +22,7 @@ public interface SettlementDocumentaryFeesService extends IService<SettlementDoc
     List<HashMap<String, Object>> getOtherSettldetail(@Param("incomeIds") String incomeIds);
 
     void batchByInvoice(String ids);
+
+    List<HashMap<String, Object>> getInvoicIds(HashMap<String, Object> params);
+
 }

+ 148 - 26
src/main/java/com/ydtech/modules/fnc/service/impl/InsPlyIncomeServiceImpl.java

@@ -349,7 +349,14 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         insPlyIncome.setJqOtherCostsProportion(insFeeOrderNew.getJqOtherCostsProportion());  //交强跟单费比例
         insPlyIncome.setSyOtherCostsProportion(insFeeOrderNew.getSyOtherCostsProportion());  //商业跟单费比例
         insPlyIncome.setNoOtherCostsProportion(insFeeOrderNew.getNoOtherCostsProportion());  //非车跟单费比例
+        insPlyIncome.setJqPremium(insFeeOrderNew.getJqPremium());
+        insPlyIncome.setSyPremium(insFeeOrderNew.getSyPremium());
+        insPlyIncome.setNoPremium(insFeeOrderNew.getNoPremium());
+        insPlyIncome.setJqNoTaxPremium(insFeeOrderNew.getJqNoTaxPremium());
+        insPlyIncome.setSyNoTaxPremium(insFeeOrderNew.getSyNoTaxPremium());
+        insPlyIncome.setNoNoTaxPremium(insFeeOrderNew.getNoNoTaxPremium());
         insPlyIncome.setUserId(insFeeOrderNew.getUserId());
+        this.saveRiskCode(order.getProductid(),insPlyIncome);
         insPlyIncome.setInsuredName(order.getInsuredname());
         this.saveByCompanyId(insFeeOrderNew ,insAreaCompany.getCompanyId(),insPlyIncome);
         baseMapper.insert(insPlyIncome);
@@ -370,7 +377,7 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
             if(StringUtils.isNotEmpty(ptlAgreementQueryVo.getInsuranceCompanyId())){
                 String insuranceCompanyId = ptlAgreementQueryVo.getInsuranceCompanyId();
                 EsmInsCompany esmInsCompany = EsmInsCompanyService.getById(insuranceCompanyId);
-                String name = esmInsCompany.getName();   //保险公司名称
+                String name = esmInsCompany.getNamesimple();   //保险公司名称  简称
                 insPlyIncome.setCompanyName(name);
             }
         }
@@ -602,32 +609,66 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         }
     }
 
+    /**
+     *
+     * @param multipartFile
+     * @return totalAmount    总金额
+     *        totalHandingAmount 总手续费金额
+     *        totalOtherAmount   总跟单费金额
+     *        resultHashMap   返回 ids  已经上面的金额
+     *        resultNoSelect  未匹配的车牌号
+     */
+
     @Override
-    public void importData(MultipartFile multipartFile) {
-        List<InsPlyIncome> list = null;
+    public HashMap<String, Object> importData(MultipartFile multipartFile) {
+        BigDecimal totalAmount=BigDecimal.ZERO;
+        BigDecimal totalHandingAmount=BigDecimal.ZERO;
+        BigDecimal totalOtherAmount=BigDecimal.ZERO;
         HashMap<String, Object> params = new HashMap<>();
+        HashMap<String, Object> resultHashMap = new HashMap<>();
+        ArrayList<HashMap<String,Object>> resultNoSelect = new ArrayList<>();
+        StringBuffer strBuilder = new StringBuffer();
         try {
             List<InsPlyIncomeExcelDto> dtoList = ExcelEasypoiUtils.importExcel(multipartFile, InsPlyIncomeExcelDto.class, 0, 1, 1);
             for (InsPlyIncomeExcelDto excelItem : dtoList) {
                 params.clear();
-                String licenseno = excelItem.getLicenseno();//车牌号
-                params.put("licenseno",licenseno);
-                String policyno = excelItem.getPolicyno(); //交强保单号
-                params.put("policyno",policyno);
-                String syPolicyno = excelItem.getSyPolicyno(); //商业保单号
-                params.put("syPolicyno",syPolicyno);
-                String noPolicyno = excelItem.getNoPolicyno(); //非车保单号
-                params.put("noPolicyno",noPolicyno);
-                if(ObjectUtils.isNotEmpty(licenseno)){
-                    List<InsPlyIncome> insPlyIncome=baseMapper.findByLicenseno(params);
-                    for (InsPlyIncome item : insPlyIncome) {
-                        if(ObjectUtils.isNotEmpty(item)){
-                            item.setHandlingFeesStatus("1"); //已结算
-                            baseMapper.updateById(item);
-                        }
+                if(StringUtils.isNotEmpty(excelItem.getLicenseno())){
+                    params.put("licenseno",excelItem.getLicenseno());//车牌号
+                }
+                if(StringUtils.isNotEmpty(excelItem.getPolicyno())){
+                    params.put("policyno",excelItem.getPolicyno()); //交强保单号
+                }
+                if(StringUtils.isNotEmpty(excelItem.getSyPolicyno())){
+                    params.put("syPolicyno", excelItem.getSyPolicyno());//商业保单号
+                }
+                if(StringUtils.isNotEmpty(excelItem.getNoPolicyno())){
+                    params.put("noPolicyno",excelItem.getNoPolicyno());   //非车保单号
+                }
+                InsPlyIncome insPlyIncome=baseMapper.findByLicenseno(params);
+                if(ObjectUtils.isNotEmpty(insPlyIncome)){
+                    strBuilder.append(insPlyIncome.getId()).append(",");
+                    if(insPlyIncome.getAllFeeValue()!=null && insPlyIncome.getAllFeeValue().compareTo(BigDecimal.ZERO)!=0){
+                        totalAmount = totalAmount.add(insPlyIncome.getAllFeeValue());  //总金额
+                    }
+                    if(insPlyIncome.getCommissionFeevalue()!=null && insPlyIncome.getCommissionFeevalue().compareTo(BigDecimal.ZERO)!=0){
+                        totalHandingAmount=totalHandingAmount.add(insPlyIncome.getCommissionFeevalue());  //总手续费
+                    }
+                    if(insPlyIncome.getOtherFeevalue()!=null && insPlyIncome.getOtherFeevalue().compareTo(BigDecimal.ZERO)!=0){
+                        totalOtherAmount=totalOtherAmount.add(insPlyIncome.getOtherFeevalue());   //总跟单费
                     }
+                }else {
+                    resultNoSelect.add(params);  // 添加未匹配的车牌号
                 }
             }
+            if(strBuilder.length() >0){
+              String  ids = strBuilder.deleteCharAt(strBuilder.length() - 1).toString();
+                resultHashMap.put("ids",ids);
+            }
+            resultHashMap.put("totalAmount",totalAmount);
+            resultHashMap.put("totalHandingAmount",totalHandingAmount);
+            resultHashMap.put("totalOtherAmount",totalOtherAmount);
+            resultHashMap.put("resultList",resultNoSelect);
+            return resultHashMap;
         } catch (IOException e) {
             throw new SystemException("导入失败!");
         }
@@ -889,7 +930,7 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         }
 
         if(insPlyIncomeVo.getNoSuperviseCostsProportion().compareTo(BigDecimal.ZERO) != 0){
-            BigDecimal  nohandingFee = noNoTaxPremium.multiply(insPlyIncomeVo.getSySuperviseCostsProportion().divide(new BigDecimal(100)));
+            BigDecimal  nohandingFee = noNoTaxPremium.multiply(insPlyIncomeVo.getNoSuperviseCostsProportion().divide(new BigDecimal(100)));
             insPlyIncome.setNoSuperviseCostsPremiums(nohandingFee);
         }
 
@@ -900,7 +941,7 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
 
         if(insPlyIncomeVo.getSyOtherCostsProportion().compareTo(BigDecimal.ZERO) != 0){
             BigDecimal syother = syNoTaxPremium.multiply(insPlyIncomeVo.getSyOtherCostsProportion().divide(new BigDecimal(100)));//交强跟单费  按照思路  交强不含税保费* 交强跟单比例 = 交强跟单金额
-            insPlyIncome.setJqOtherCostsPremium(syother);
+            insPlyIncome.setSyOtherCostsPremium(syother);
         }
 
         if(insPlyIncomeVo.getNoOtherCostsProportion().compareTo(BigDecimal.ZERO) != 0){
@@ -925,7 +966,7 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
                 insPlyIncome.setCommissionFeevalue(this.calculateTotal(insPlyIncome.getJqSuperviseCostsPremiums(),insPlyIncome.getSySuperviseCostsPremiums(),null)); // 手续费
                 insPlyIncome.setCommissionFeerate(this.calculateTotal(insPlyIncome.getJqSuperviseCostsProportion(),insPlyIncome.getSySuperviseCostsProportion(),null));//手续费比例
                 insPlyIncome.setAllFeeValue(this.calculateTotal(insPlyIncome.getCommissionFeevalue(),null,null));//总金额
-            }else { //保险跟单费  交强跟单+商业跟单
+            }else if ("1".equals(insPlyIncomeVo.getIsNotDocumentary()) && "0".equals(insPlyIncomeVo.getIsNotCar())){ //保险跟单费  交强跟单+商业跟单
                 insPlyIncome.setOtherFeevalue(this.calculateTotal(insPlyIncome.getJqOtherCostsPremium(),insPlyIncome.getSyOtherCostsPremium(),null));
                 insPlyIncome.setOtherFeerate(this.calculateTotal(insPlyIncome.getJqOtherCostsProportion(),insPlyIncome.getSyOtherCostsProportion(),null));
                 insPlyIncome.setAllFeeValue(this.calculateTotal(insPlyIncome.getOtherFeevalue(),null,null));//总金额
@@ -935,9 +976,7 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
                 insPlyIncome.setCommissionFeevalue(this.calculateTotal(insPlyIncome.getNoSuperviseCostsPremiums(),null,null));  // 非车手续费
                 insPlyIncome.setCommissionFeerate(this.calculateTotal(insPlyIncome.getNoSuperviseCostsProportion(),null,null));  //非车比例
                 insPlyIncome.setAllFeeValue(this.calculateTotal(insPlyIncome.getCommissionFeevalue(),null,null));//总金额
-
-
-            }else {   //非车跟单
+            }else if ("1".equals(insPlyIncomeVo.getIsNotDocumentary()) && "1".equals(insPlyIncomeVo.getIsNotCar())){   //非车跟单
                 insPlyIncome.setOtherFeevalue(this.calculateTotal(insPlyIncome.getNoOtherCostsPremium(),null,null));  //非车跟单金额
                 insPlyIncome.setOtherFeerate(this.calculateTotal(insPlyIncome.getNoOtherCostsProportion(),null,null)); // 非车跟单比例
                 insPlyIncome.setAllFeeValue(this.calculateTotal(insPlyIncome.getOtherFeevalue(),null,null));//总金额
@@ -1106,6 +1145,11 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         return  HttpResult.ok();
     }
 
+    /**
+     *
+     * @param insPlyIncomeVo
+     * @return
+     */
 
     @Override
     public List<InsPlyIncome> totalBxAmount(InsPlyIncomeVo insPlyIncomeVo) {
@@ -1113,9 +1157,35 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         params=this.saveParams(insPlyIncomeVo,params);
         params.remove("handlingFeesStatus");
         List<InsPlyIncome>  resultList  =  baseMapper.totalBxAmount(params);
+//      数据库数据太多是 用sql拼接id会丢失 所以只能逻辑拼接
+        List<InsPlyIncome> idList=baseMapper.getIncomeIdList(params);
+        if(!CollectionUtils.isEmpty(idList) && !ObjectUtils.isNotEmpty(resultList)){
+            this.splicingIds(idList,resultList);
+        }
         return resultList;
     }
 
+    /**
+     *
+     * @param idList    要开票的数据集合
+     * @param resultList   总返回数据
+     */
+
+    private void splicingIds(List<InsPlyIncome> idList, List<InsPlyIncome> resultList) {
+        // 使用Map来存储agreementId到其id列表的映射
+        Map<String, List<String>> idMap = new HashMap<>();
+        for (InsPlyIncome idItem : idList) {
+            String agreementId = idItem.getAgreementId();
+            idMap.computeIfAbsent(agreementId, k -> new ArrayList<>()).add(idItem.getId());
+        }
+
+        for (InsPlyIncome resultItem : resultList) {
+            List<String> ids = idMap.getOrDefault(resultItem.getAgreementId(), Collections.emptyList());
+            String idsString = String.join(",", ids);
+            resultItem.setIds(idsString);
+        }
+    }
+
     @Override
     @Transactional
     public HttpResult<Object> batchInvoicing(InsPlyIncomeVo insPlyIncomeVo) {
@@ -1177,14 +1247,66 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         return HttpResult.ok(insPlyIncome);
     }
 
+    /**
+     *
+     * @param insPlyIncomeVo
+     * @return
+     */
     @Override
     public HttpResult<List<InsPlyIncome>> allOtherAmount(InsPlyIncomeVo insPlyIncomeVo) {
         HashMap<String, Object> params = new HashMap<>();
-        params=this.saveParams(insPlyIncomeVo,params);
-        List<InsPlyIncome> result= baseMapper.allOtherAmount(params);
+        params = this.saveParams(insPlyIncomeVo, params);
+        List<InsPlyIncome> result = baseMapper.allOtherAmount(params);
+        List<HashMap<String, Object>> otherIds = baseMapper.getOtherIds(params);
+        List<HashMap<String, Object>> invoicIds = settlementDocumentaryFeesService.getInvoicIds(params);
+        this.splicingOtherIds(result,otherIds,invoicIds);
         return HttpResult.ok(result);
     }
 
+    /**
+     *
+     * @param result  返回的数据
+     * @param otherIds ins_ply_income  跟单费
+     * @param invoicIds  settlement_documentary_fees  开票ids
+     */
+    private void splicingOtherIds(List<InsPlyIncome> result, List<HashMap<String, Object>> otherIds, List<HashMap<String, Object>> invoicIds) {
+        // 创建两个映射来分别存储companyId到ids和setIncomeIds的映射
+        Map<String, List<String>> companyIdToIdsMap = new HashMap<>();
+        Map<String, List<String>> companyIdToSetIncomeIdsMap = new HashMap<>();
+
+// 处理otherIds,填充companyId到ids的映射
+        for (HashMap<String, Object> idMap : otherIds) {
+            String companyId = (String) idMap.get("companyId");
+            String id =  idMap.get("id").toString(); // 假设id是一个String,而不是List<String>
+            if (companyId != null && id != null) {
+                companyIdToIdsMap.computeIfAbsent(companyId, k -> new ArrayList<>()).add(id); // 将id添加到列表中
+            }
+        }
+
+// 处理invoicIds,填充companyId到setIncomeIds的映射(假设结构相同)
+        for (HashMap<String, Object> idMap : invoicIds) {
+            String companyId = (String) idMap.get("companyId");
+            String setIncomeId =  idMap.get("id").toString(); // 假设这里也是单个id,键名可能不同,例如"setIncomeId"
+            if (companyId != null && setIncomeId != null) {
+                companyIdToSetIncomeIdsMap.computeIfAbsent(companyId, k -> new ArrayList<>()).add(setIncomeId);
+            }
+        }
+        // 遍历result列表,为每个InsPlyIncome对象设置拼接后的ids和incomeIds
+        for (InsPlyIncome resultItem : result) {
+            String companyId = resultItem.getCompanyId();
+            List<String> ids = companyIdToIdsMap.getOrDefault(companyId, Collections.emptyList());
+            List<String> setIncomeIds = companyIdToSetIncomeIdsMap.getOrDefault(companyId, Collections.emptyList());
+
+            // 合并ids和setIncomeIds(如果需要,可以先去重),但在此处我们直接拼接
+            String idsString = String.join(",", ids);
+            String incomeIdsString = String.join(",", setIncomeIds);
+
+            // 设置拼接后的ids和incomeIds到InsPlyIncome对象中
+            resultItem.setIds(idsString);
+            resultItem.setIncomeIds(incomeIdsString); // 假设InsPlyIncome有这个方法
+        }
+    }
+
     @Override
     @Transactional
     public HttpResult<Object> batchInvoic(InsPlyIncomeVo insPlyIncomeVo) {

+ 5 - 0
src/main/java/com/ydtech/modules/fnc/service/impl/SettlementDocumentaryFeesServiceImpl.java

@@ -126,6 +126,11 @@ public class SettlementDocumentaryFeesServiceImpl extends ServiceImpl<Settlement
         baseMapper.batchByInvoice(params);
     }
 
+    @Override
+    public List<HashMap<String, Object>> getInvoicIds(HashMap<String, Object> params) {
+        return  baseMapper.getInvoicIds(params);
+    }
+
     private int compareAmount(BigDecimal settlementAmount, BigDecimal settlementAmount1) {
 
         return settlementAmount.compareTo(settlementAmount1);

+ 71 - 9
src/main/resources/mapper/modules/fnc/InsPlyIncomeMapper.xml

@@ -714,8 +714,7 @@
         SUM(CASE WHEN a.handling_fees_status = '2' THEN a.commission_feevalue ELSE 0 END) AS "invoicCommissionFeevalue",
         SUM( CASE WHEN a.handling_fees_status = '0' THEN a.commission_feevalue ELSE 0 END ) AS "noInvoicCommissionFeevalue",
         SUM(CASE WHEN a.handling_fees_status = '1' THEN a.commission_feevalue ELSE 0 END) AS "readyCommissionFeevalue",
-        SUM(a.commission_feevalue - CASE WHEN a.handling_fees_status = '1' THEN a.commission_feevalue ELSE 0 END) as "unSettledAmount",
-        GROUP_CONCAT(CASE WHEN a.handling_fees_status = '2' THEN a.id ELSE NULL END) AS "ids"
+        SUM(a.commission_feevalue - CASE WHEN a.handling_fees_status = '1' THEN a.commission_feevalue ELSE 0 END) as "unSettledAmount"
         from  ins_ply_income a
         LEFT JOIN   ptl_agreement  pa  on pa.id= a.agreement_id
         <where>
@@ -745,20 +744,50 @@
         GROUP BY  a.agreement_id
     </select>
 
+    <select id="getIncomeIdList" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
+        select
+            a.agreement_id AS "agreementId",
+            a.id  as "id"
+        from  ins_ply_income a
+        LEFT JOIN   ptl_agreement  pa  on pa.id= a.agreement_id
+        <where>
+            1=1
+            and a.handling_fees_status ='2'
+            <if test="agreementType !=null  and agreementType!='' ">
+                AND pa.agreement_type =#{agreementType}
+            </if>
+            <if test="year !=null  and  year  !=''">
+                AND YEAR(a.signdate) =#{year}
+            </if>
+            <if test="isOther !=null  and  isOther  !=''">
+                and a.is_not_documentary   =#{isOther}
+            </if>
+            <if test="isNotCar !=null  and  isNotCar  !=''">
+                and a.is_not_car =#{isNotCar}
+            </if>
+            <if test="month !=null  and  month !=''">
+                AND month(a.signdate) =#{month}
+            </if>
+            <if test="day !=null  and  day !=''">
+                AND day(a.signdate) =#{day}
+            </if>
+        </where>
+
+
+    </select>
+
     <select id="allOtherAmount" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
         SELECT
         a.company_id AS "companyId",
         MAX( a.company_name ) AS "companyName",
         MAX( a.partner_companies_name ) AS "partnerCompaniesName",
-        MAX( c.invoicIds ) AS "incomeIds",
-        GROUP_CONCAT( a.id ) AS "ids",
-        max(c.settleMentAmount) as  "invoicCommissionFeevalue",
-        sum( a.other_feevalue )-max(c.settleMentAmount)  as "noInvoicCommissionFeevalue",
-        max(f.settleMentAmount) as  "settleMentAmount",
-        MAX(COALESCE(c.settleMentAmount, 0) - COALESCE(f.settleMentAmount, 0)) AS "unSettledAmount",
+        IFNULL ( max(c.settleMentAmount),0.00) as  "invoicCommissionFeevalue",
+        sum(COALESCE( a.other_feevalue,0.00) )-COALESCE(max(c.settleMentAmount),0.00)  as "noInvoicCommissionFeevalue",
+        IFNULL(max(f.settleMentAmount) , 0.00)  as  "settleMentAmount",
+        MAX(COALESCE(c.settleMentAmount, 0.00) - COALESCE(f.settleMentAmount, 0)) AS "unSettledAmount",
         sum( a.other_feevalue ) AS "otherFeevalue"
         FROM
-            ins_ply_income a
+        ins_ply_income a
         LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
         LEFT JOIN ( SELECT a.company_id AS "companyId", MIN( a.unsettled_amount ) AS "unsettledAmount" ,sum(
         settlement_amount ) AS "settleMentAmount", GROUP_CONCAT(a.id) as "invoicIds" FROM settlement_documentary_fees a
@@ -803,6 +832,39 @@
         GROUP BY
             a.company_id
     </select>
+    <select id="getOtherIds" resultType="java.util.HashMap">
+        SELECT
+        a.id  as "id",
+        a.company_id AS "companyId"
+        FROM
+        ins_ply_income a
+        LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
+       <where>
+           1=1
+           <if test="agreementType !=null  and agreementType!='' ">
+               AND pa.agreement_type =#{agreementType}
+           </if>
+           <if test="year !=null  and  year  !=''">
+               AND YEAR(a.signdate) =#{year}
+           </if>
+           <if test="isOther !=null  and  isOther  !=''">
+               and a.is_not_documentary   =#{isOther}
+           </if>
+           <if test="isNotCar !=null  and  isNotCar  !=''">
+               and a.is_not_car =#{isNotCar}
+           </if>
+           <if test="month !=null  and  month !=''">
+               AND month(a.signdate) =#{month}
+           </if>
+           <if test="day !=null  and  day !=''">
+               AND day(a.signdate) =#{day}
+           </if>
+           <if test="documentaryFeesStatus != null  and documentaryFeesStatus != '' ">
+               AND   a.documentary_fees_status = #{documentaryFeesStatus}
+           </if>
+       </where>
+    </select>
+
 
     <select id="getById" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
         select

+ 14 - 0
src/main/resources/mapper/modules/fnc/SettlementDocumentaryFeesMapper.xml

@@ -77,6 +77,20 @@
     </update>
 
 
+    <select id="getInvoicIds" resultType="java.util.HashMap">
+        SELECT
+            a.id  as "id",
+            a.company_id    AS "companyId"
+        FROM settlement_documentary_fees a
+        <where>
+            a.settlement_status = '1'
+            <if test="isNotCar !=null  and  isNotCar  !=''">
+                and a.is_not_car =#{isNotCar}
+            </if>
+        </where>
+    </select>
+
+