소스 검색

Merge remote-tracking branch 'origin/test' into test

Qchen 2 년 전
부모
커밋
73f2f2c4d9

+ 16 - 10
src/main/java/com/ydtech/modules/admin/service/impl/SysUserAccountServiceImpl.java

@@ -36,7 +36,6 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
 import java.math.BigDecimal;
-import java.time.LocalDate;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
@@ -371,7 +370,12 @@ public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper,
 
         return sysUserAccount;
     }
-
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/6/11 16:05
+     *  @Description: 注释掉实收的总金额提升查询效率
+     */
     @Override
     public SysUserAccountVo getSysAllAmount(String userId) {
         SysUserAccountVo sysUserAccountVo = new SysUserAccountVo();
@@ -384,16 +388,16 @@ public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper,
         BigDecimal willHalding = BigDecimal.ZERO;        //预收手续费佣金
         BigDecimal willDocumentary = BigDecimal.ZERO;   //预收 非跟单佣金
         BigDecimal willPromotion = BigDecimal.ZERO;   //预收 推广
-        BigDecimal receivedWillHalding = BigDecimal.ZERO;        //实收手续费佣金
-        BigDecimal receivedWillDocumentary = BigDecimal.ZERO;   //实收非跟单佣金
-        BigDecimal receivedWillPromotion = BigDecimal.ZERO;   //实收推广费
+        //BigDecimal receivedWillHalding = BigDecimal.ZERO;        //实收手续费佣金
+       // BigDecimal receivedWillDocumentary = BigDecimal.ZERO;   //实收非跟单佣金
+       // BigDecimal receivedWillPromotion = BigDecimal.ZERO;   //实收推广费
         // 预收手续费佣金
         willPromotion = this.willPromotionAll(willPromotion, userId,"1");
         // 实收手续费佣金
-        receivedWillPromotion = this.willPromotionAll(willPromotion, userId,"2");
+        //receivedWillPromotion = this.willPromotionAll(willPromotion, userId,"2");
         // add by   hxl  修改sql 添加承保状态和不在审核表中的条件   begin ===============
         List<InsFeeOrderNew> willList = insFeeOrderNewService.getByUserIdAndOrderStatusAndNoCheckType(userId,"1");
-        List<InsFeeOrderNew> willListnew = insFeeOrderNewService.getByUserIdAndOrderStatusAndNoCheckType(userId,"2");
+        //List<InsFeeOrderNew> willListnew = insFeeOrderNewService.getByUserIdAndOrderStatusAndNoCheckType(userId,"2");
         if (!CollectionUtils.isEmpty(willList)) {
             for (InsFeeOrderNew item : willList) {
                 if (ObjectUtils.isNotEmpty(item)) {
@@ -403,6 +407,7 @@ public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper,
                 }
             }
         }
+        /**
         if (!CollectionUtils.isEmpty(willListnew)) {
             for (InsFeeOrderNew item : willListnew) {
                 if (ObjectUtils.isNotEmpty(item)) {
@@ -412,14 +417,15 @@ public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper,
                 }
             }
         }
+         **/
         //预收手续费佣金
         sysUserAccountVo.setWillHalding(willPromotion);
         //预收非跟单佣金
         sysUserAccountVo.setWillDocumentary(willDocumentary);
         //实收手续费佣金
-        sysUserAccountVo.setReceivedWillHalding(receivedWillHalding);
+        //sysUserAccountVo.setReceivedWillHalding(receivedWillHalding);
         //实收非跟单佣金
-        sysUserAccountVo.setReceivedWillDocumentary(receivedWillDocumentary);
+        //sysUserAccountVo.setReceivedWillDocumentary(receivedWillDocumentary);
         //提现现中 手续费、非跟单、推广费
         HashMap<String, Object> params = new HashMap<>();
         params.put("auditingStatus", "2");  // 待审核
@@ -435,7 +441,7 @@ public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper,
         //预收手续费佣金
         sysUserAccountVo.setWillPromotion(willPromotion);
         //实收手续费佣金
-        sysUserAccountVo.setReceivedWillPromotion(receivedWillPromotion);
+       // sysUserAccountVo.setReceivedWillPromotion(receivedWillPromotion);
         return sysUserAccountVo;
     }
 

+ 2 - 2
src/main/java/com/ydtech/modules/fee/service/impl/FeeRuleSchemeServiceNewImpl.java

@@ -797,14 +797,14 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
      * @return
      */
     private boolean checkBoxEqual(PtlAgreementProductCostsAttrLink ptlAgreementProductCostsAttrLink, String value) {
-        if (ptlAgreementProductCostsAttrLink.getMin().contains(value)) {
+        if (ptlAgreementProductCostsAttrLink.getMin().equals(value)) {
             return true;
         }
         return false;
     }
 
     private boolean checkBoxEqual(PtlAgreementUndwrtRulesAttrLink ptlAgreementUndwrtRulesAttrLink, String value) {
-        if (!ptlAgreementUndwrtRulesAttrLink.getMin().contains(value)) {
+        if (!ptlAgreementUndwrtRulesAttrLink.getMin().equals(value)) {
             return true;
         }
         return false;

+ 4 - 1
src/main/java/com/ydtech/modules/fnc/controller/InsPlyIncomeController.java

@@ -202,8 +202,11 @@ public class InsPlyIncomeController extends BaseController {
     public HttpResult<String> bxImportData(@RequestParam MultipartFile multipartFile, @RequestParam("isNotCar") String isNotCar) {
         try {
             List<InsBxPlyIncomeExcelDto> dtoList = ExcelEasypoiUtils.importExcel(multipartFile, InsBxPlyIncomeExcelDto.class, 0, 1, 1);
+            if (CollectionUtils.isEmpty(dtoList)) {
+                return HttpResult.error("导入数据为空");
+            }
             String taskId = String.valueOf(new SnowFlakeUtil().nextId());
-            importAsyncService.importasync(dtoList, isNotCar, taskId);
+                importAsyncService.importasync(dtoList, isNotCar, taskId);
             return HttpResult.ok(taskId);
 
         } catch (IOException e) {

+ 4 - 0
src/main/java/com/ydtech/modules/fnc/entity/InsPlyIncome.java

@@ -333,6 +333,10 @@ public class InsPlyIncome implements Serializable {
     @TableField("settlement_image_id")
     private String settlementImageId;
 
+    @ApiModelProperty("任务id")
+    @TableField("task_id")
+    private String taskId;
+
 
     @ApiModelProperty("总单数")
     @TableField(exist = false)

+ 10 - 66
src/main/java/com/ydtech/modules/fnc/service/impl/ImportAsyncServiceImpl.java

@@ -1,35 +1,21 @@
 package com.ydtech.modules.fnc.service.impl;
 
-import cn.hutool.core.date.DateTime;
-import cn.hutool.core.util.ObjectUtil;
-import com.alibaba.excel.EasyExcel;
-import com.alibaba.excel.ExcelWriter;
-import com.alibaba.excel.write.builder.ExcelWriterBuilder;
-import com.alibaba.excel.write.metadata.WriteSheet;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.ydtech.core.page.HttpResult;
-import com.ydtech.exception.SystemException;
 import com.ydtech.modules.fnc.dao.ImportAsyncMapper;
 import com.ydtech.modules.fnc.dao.InsPlyIncomeMapper;
 import com.ydtech.modules.fnc.entity.ImportResult;
 import com.ydtech.modules.fnc.entity.InsPlyIncome;
 import com.ydtech.modules.fnc.service.ImportAsyncService;
 import com.ydtech.modules.fnc.vo.ImportResultVo;
-import com.ydtech.modules.ins.model.vo.res.BxNoOtherDetailsExcel;
-import com.ydtech.modules.ins.model.vo.res.BxOtherDetailsExcel;
-import com.ydtech.modules.ins.model.vo.res.BxSettlementFeesExcel;
 import com.ydtech.modules.inv.model.dto.*;
 import com.ydtech.modules.inv.utils.EasyExcelUtils;
 import com.ydtech.modules.order.entity.BasePageResult;
-import com.ydtech.modules.order.entity.po.InsUploadFiles;
 import com.ydtech.modules.order.service.InsUploadFilesService;
-import com.ydtech.utils.excel.ExcelEasypoiUtils;
-import org.apache.commons.codec.digest.DigestUtils;
 import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.scheduling.annotation.Async;
@@ -38,18 +24,13 @@ import org.springframework.util.CollectionUtils;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
 import java.io.IOException;
 import java.math.BigDecimal;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
-import java.text.SimpleDateFormat;
-import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.util.ArrayList;
-import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 
@@ -58,6 +39,7 @@ public class ImportAsyncServiceImpl extends ServiceImpl<ImportAsyncMapper, Impor
 
     @Autowired
     private InsPlyIncomeMapper insPlyIncomeMapper;
+
     @Autowired
     private InsUploadFilesService insUploadFilesService;
     @Value("${upload.file.path}")
@@ -72,14 +54,12 @@ public class ImportAsyncServiceImpl extends ServiceImpl<ImportAsyncMapper, Impor
     public void importasync(List<InsBxPlyIncomeExcelDto> dtoList, String isNotCar, String taskId) {
         BigDecimal totalAmount = BigDecimal.ZERO;
         HashMap<String, Object> params = new HashMap<>();
-        StringBuffer strBuilder = new StringBuffer();
         List<InsImportResult> insImportResultsExcel = new ArrayList<>();
         String companyId  ="";
         String partnerCompaniesId  ="";
         String agreementId  ="";
 
         boolean open = true;
-        String ids = "";
         Integer i = 0;
 
         //  创建任务
@@ -175,10 +155,12 @@ public class ImportAsyncServiceImpl extends ServiceImpl<ImportAsyncMapper, Impor
                     agreementId = insPlyIncome.getAgreementId();  //协议id
                 }
                 if (ObjectUtils.isNotEmpty(insPlyIncome)) {  // 比配上汇总金额 未匹配则返回到数据当中
-                    strBuilder.append(insPlyIncome.getId()).append(",");
+
                     if (insPlyIncome.getCommissionFeevalue() != null && insPlyIncome.getCommissionFeevalue().compareTo(BigDecimal.ZERO) != 0) {
                         totalAmount = totalAmount.add(insPlyIncome.getCommissionFeevalue());  //添加总手续费
                     }
+                    insPlyIncome.setTaskId(taskId);
+                    insPlyIncomeMapper.updateById(insPlyIncome);
                 } else {
                     InsImportResult insImportResult = new InsImportResult();
                     if (StringUtils.isNotEmpty(excelItem.getLicenseno())) {
@@ -197,10 +179,6 @@ public class ImportAsyncServiceImpl extends ServiceImpl<ImportAsyncMapper, Impor
                 }
             }
         }
-        if(strBuilder.length() >0){
-            ids = strBuilder.deleteCharAt(strBuilder.length() - 1).toString();
-        }
-
 
         String uploadPath = this.uploadFilePath + "/excel/" + taskId + "/";
         File folder = new File(uploadPath);
@@ -222,7 +200,6 @@ public class ImportAsyncServiceImpl extends ServiceImpl<ImportAsyncMapper, Impor
         endTask.setCompanyId(companyId);
         endTask.setAgreementId(agreementId);
         endTask.setPartnerCompaniesId(partnerCompaniesId);
-        endTask.setIds(ids);
         endTask.setHandStatus("0");
         baseMapper.updateById(endTask);
     }
@@ -257,14 +234,12 @@ public class ImportAsyncServiceImpl extends ServiceImpl<ImportAsyncMapper, Impor
 
         BigDecimal totalAmount = BigDecimal.ZERO;
         HashMap<String, Object> params = new HashMap<>();
-        StringBuffer strBuilder = new StringBuffer();
         List<InsImportResult> insImportResultsExcel = new ArrayList<>();
         String companyId  ="";
         String partnerCompaniesId  ="";
         String agreementId  ="";
 
         boolean open = true;
-        String ids = "";
         Integer i = 0;
 
         //  创建任务
@@ -333,10 +308,11 @@ public class ImportAsyncServiceImpl extends ServiceImpl<ImportAsyncMapper, Impor
                     agreementId = insPlyIncome.getAgreementId();  //协议id
                 }
                 if (ObjectUtils.isNotEmpty(insPlyIncome)) {  // 比配上汇总金额 未匹配则返回到数据当中
-                    strBuilder.append(insPlyIncome.getId()).append(",");
                     if (insPlyIncome.getCommissionFeevalue() != null && insPlyIncome.getCommissionFeevalue().compareTo(BigDecimal.ZERO) != 0) {
                         totalAmount = totalAmount.add(insPlyIncome.getCommissionFeevalue());  //添加总手续费
                     }
+                    insPlyIncome.setTaskId(taskId);
+                    insPlyIncomeMapper.updateById(insPlyIncome);
                 } else {
                     InsImportResult insImportResult = new InsImportResult();
                     if (StringUtils.isNotEmpty(excelItem.getLicenseno())) {
@@ -355,9 +331,6 @@ public class ImportAsyncServiceImpl extends ServiceImpl<ImportAsyncMapper, Impor
                 }
             }
         }
-        if(strBuilder.length() >0){
-            ids = strBuilder.deleteCharAt(strBuilder.length() - 1).toString();
-        }
         String uploadPath = this.uploadFilePath + "/excel/" + taskId + "/";
         Path path = Paths.get(uploadPath);
         if (!Files.exists(path)) {
@@ -382,7 +355,6 @@ public class ImportAsyncServiceImpl extends ServiceImpl<ImportAsyncMapper, Impor
         endTask.setAgreementId(agreementId);
         endTask.setPartnerCompaniesId(partnerCompaniesId);
         endTask.setHandStatus("2");
-        endTask.setIds(ids);
         baseMapper.updateById(endTask);
     }
 
@@ -391,14 +363,12 @@ public class ImportAsyncServiceImpl extends ServiceImpl<ImportAsyncMapper, Impor
 
         BigDecimal totalAmount = BigDecimal.ZERO;
         HashMap<String, Object> params = new HashMap<>();
-        StringBuffer strBuilder = new StringBuffer();
         List<InsImportResult> insImportResultsExcel = new ArrayList<>();
         String companyId  ="";
         String partnerCompaniesId  ="";
         String agreementId  ="";
 
         boolean open = true;
-        String ids = "";
         Integer i = 0;
 
         //  创建任务
@@ -449,10 +419,11 @@ public class ImportAsyncServiceImpl extends ServiceImpl<ImportAsyncMapper, Impor
                     agreementId = insPlyIncome.getAgreementId();  //协议id
                 }
                 if (ObjectUtils.isNotEmpty(insPlyIncome)) {  // 比配上汇总金额 未匹配则返回到数据当中
-                    strBuilder.append(insPlyIncome.getId()).append(",");
                     if (insPlyIncome.getCommissionFeevalue() != null && insPlyIncome.getCommissionFeevalue().compareTo(BigDecimal.ZERO) != 0) {
                         totalAmount = totalAmount.add(insPlyIncome.getCommissionFeevalue());  //添加总手续费
                     }
+                    insPlyIncome.setTaskId(taskId);
+                    insPlyIncomeMapper.updateById(insPlyIncome);
                 } else {
                     InsImportResult insImportResult = new InsImportResult();
                     if (StringUtils.isNotEmpty(excelItem.getLicenseno())) {
@@ -468,9 +439,6 @@ public class ImportAsyncServiceImpl extends ServiceImpl<ImportAsyncMapper, Impor
                 }
             }
         }
-        if(strBuilder.length() >0){
-            ids = strBuilder.deleteCharAt(strBuilder.length() - 1).toString();
-        }
         String uploadPath = this.uploadFilePath + "/excel/" + taskId + "/";
         Path path = Paths.get(uploadPath);
         if (!Files.exists(path)) {
@@ -494,7 +462,6 @@ public class ImportAsyncServiceImpl extends ServiceImpl<ImportAsyncMapper, Impor
         endTask.setCompanyId(companyId);
         endTask.setAgreementId(agreementId);
         endTask.setPartnerCompaniesId(partnerCompaniesId);
-        endTask.setIds(ids);
         endTask.setHandStatus("3");
         baseMapper.updateById(endTask);
 
@@ -504,14 +471,12 @@ public class ImportAsyncServiceImpl extends ServiceImpl<ImportAsyncMapper, Impor
     public void bxImportNoData(List<InsBxNoPlyIncomeExcelDto> dtoList, MultipartFile multipartFile, String taskId) {
         BigDecimal totalAmount = BigDecimal.ZERO;
         HashMap<String, Object> params = new HashMap<>();
-        StringBuffer strBuilder = new StringBuffer();
         List<InsImportResult> insImportResultsExcel = new ArrayList<>();
         String companyId  ="";
         String partnerCompaniesId  ="";
         String agreementId  ="";
 
         boolean open = true;
-        String ids = "";
         Integer i = 0;
 
         //  创建任务
@@ -562,10 +527,11 @@ public class ImportAsyncServiceImpl extends ServiceImpl<ImportAsyncMapper, Impor
                     agreementId = insPlyIncome.getAgreementId();  //协议id
                 }
                 if (ObjectUtils.isNotEmpty(insPlyIncome)) {  // 比配上汇总金额 未匹配则返回到数据当中
-                    strBuilder.append(insPlyIncome.getId()).append(",");
                     if (insPlyIncome.getCommissionFeevalue() != null && insPlyIncome.getCommissionFeevalue().compareTo(BigDecimal.ZERO) != 0) {
                         totalAmount = totalAmount.add(insPlyIncome.getCommissionFeevalue());  //添加总手续费
                     }
+                    insPlyIncome.setTaskId(taskId);
+                    insPlyIncomeMapper.updateById(insPlyIncome);
                 } else {
                     InsImportResult insImportResult = new InsImportResult();
                     if (StringUtils.isNotEmpty(excelItem.getLicenseno())) {
@@ -581,9 +547,6 @@ public class ImportAsyncServiceImpl extends ServiceImpl<ImportAsyncMapper, Impor
                 }
             }
         }
-        if(strBuilder.length() >0){
-            ids = strBuilder.deleteCharAt(strBuilder.length() - 1).toString();
-        }
         String uploadPath = this.uploadFilePath + "/excel/" + taskId + "/";
         Path path = Paths.get(uploadPath);
         if (!Files.exists(path)) {
@@ -607,28 +570,9 @@ public class ImportAsyncServiceImpl extends ServiceImpl<ImportAsyncMapper, Impor
         endTask.setCompanyId(companyId);
         endTask.setAgreementId(agreementId);
         endTask.setPartnerCompaniesId(partnerCompaniesId);
-        endTask.setIds(ids);
         endTask.setHandStatus("3");
         baseMapper.updateById(endTask);
 
 
     }
-    private String getFileFolder(String type, boolean year, boolean month, boolean day) {
-        StringBuilder stringBuilder = new StringBuilder();
-        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
-        String dateString = dateFormat.format(new Date());
-        String[] split = dateString.split("-");
-        stringBuilder.append(type).append("/");
-        if (year) {
-            stringBuilder.append(split[0]).append("/");
-        }
-        if (month) {
-            stringBuilder.append(split[1]).append("/");
-        }
-        if (day) {
-            stringBuilder.append(split[2]).append("/");
-        }
-        return stringBuilder.toString();
-    }
-
 }

+ 85 - 79
src/main/java/com/ydtech/modules/fnc/service/impl/InsPlyIncomeServiceImpl.java

@@ -690,7 +690,6 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         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) {
@@ -709,7 +708,6 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
                 }
                 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());  //总金额
                     }
@@ -723,10 +721,7 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
                     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);
@@ -1453,18 +1448,25 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
     @Override
     @Transactional
     public HttpResult<Object> batchInvoicing(InsPlyIncomeVo insPlyIncomeVo) {
-        ImportResult importResult = importAsyncService.getById(insPlyIncomeVo.getSelectIds().get(0));
-
-        //      开票时生成  记录 用来合计已经开票数据
-        String ids = importResult.getIds();
-        if(StringUtils.isNotEmpty(ids)){
-            String[] split = ids.split(",");
-            for (String id :  split){
-                InsPlyIncome insPlyIncome = baseMapper.selectById(id);
-                insPlyIncome.setInvoicTime(LocalDate.now());  //开票时间
-                insPlyIncome.setInvoicId(insPlyIncomeVo.getInvoicId()); //开票号
-                insPlyIncome.setHandlingFeesStatus("2");   //2为开票
-                baseMapper.updateById(insPlyIncome);
+        ImportResult importResult = importAsyncService.getById(insPlyIncomeVo.getSelectIds().get(0));  // 查询 任务
+        HashMap<String, Object> params = new HashMap<>();
+        if (StringUtils.isNotEmpty(importResult.getId())) {
+            params.put("taskkId", importResult.getId());
+            List<InsPlyIncome> insPlyIncomes = baseMapper.queryNew(params);
+            if (!CollectionUtils.isEmpty(insPlyIncomes)) {
+                if (insPlyIncomeVo != null) { // 确保insPlyIncomeVo不是null
+                    for (InsPlyIncome item : insPlyIncomes) {
+                        item.setInvoicTime(LocalDate.now());
+                        item.setInvoicId(insPlyIncomeVo.getInvoicId());
+                        item.setHandlingFeesStatus("2");
+                        if (StringUtils.isNotEmpty(item.getTaskId())) {
+                            return HttpResult.ok("该单据已经开票 ");
+                        } else {
+                            item.setTaskId(importResult.getId());
+                            baseMapper.updateById(item);
+                        }
+                    }
+                }
             }
         }
         insPlyIncomeVo.setNoInvoicCommissionFeevalue(importResult.getTotalAmount());
@@ -1476,7 +1478,6 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         insPlyIncomeVo.setSettlementAmount(importResult.getTotalAmount());
         insPlyIncomeVo.setContractId(insPlyIncomeVo.getInvoicId());
         insPlyIncomeVo.setCompanyId(importResult.getCompanyId());
-        insPlyIncomeVo.setIds(importResult.getIds());
         this.batchInvoic(insPlyIncomeVo);
         return HttpResult.ok();
     }
@@ -1555,73 +1556,14 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         HashMap<String, Object> params = new HashMap<>();
         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 partnerCompaniesId = (String) idMap.get("partnerCompaniesId");
-            String id =  idMap.get("id").toString(); // 假设id是一个String,而不是List<String>
-            if (partnerCompaniesId != null && id != null) {
-                companyIdToIdsMap.computeIfAbsent(partnerCompaniesId, k -> new ArrayList<>()).add(id); // 将id添加到列表中
-            }
-        }
-
-// 处理invoicIds,填充companyId到setIncomeIds的映射(假设结构相同)
-        for (HashMap<String, Object> idMap : invoicIds) {
-            String partnerCompaniesId = (String) idMap.get("partnerCompaniesId");
-            String setIncomeId =  idMap.get("id").toString(); // 假设这里也是单个id,键名可能不同,例如"setIncomeId"
-            if (partnerCompaniesId != null && setIncomeId != null) {
-                companyIdToSetIncomeIdsMap.computeIfAbsent(partnerCompaniesId, k -> new ArrayList<>()).add(setIncomeId);
-            }
-        }
-        // 遍历result列表,为每个InsPlyIncome对象设置拼接后的ids和incomeIds
-        for (InsPlyIncome resultItem : result) {
-            String partnerCompaniesId = resultItem.getPartnerCompaniesId();
-            List<String> ids = companyIdToIdsMap.getOrDefault(partnerCompaniesId, Collections.emptyList());
-            List<String> setIncomeIds = companyIdToSetIncomeIdsMap.getOrDefault(partnerCompaniesId, 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) {
-                //  通过ids 查出跟单非结算单
-            String ids = insPlyIncomeVo.getIds();
-//        if(StringUtils.isNotEmpty(ids)){
-//            String[] split = ids.split(",");
-//            for (int i =0; i <split.length ; i++) {
-//                String id = split[i];
-//                InsPlyIncome insPlyIncome = baseMapper.selectById(id);
-//                insPlyIncome.setInvoicId(insPlyIncomeVo.getContractId()); // 开票号
-//                insPlyIncome.setContractFileId(insPlyIncomeVo.getContractFileId());
-//                insPlyIncome.setVoucherNumber(insPlyIncomeVo.getVoucherNumber());
-//                insPlyIncome.setSettlementTime(LocalDate.now());
-//                baseMapper.updateById(insPlyIncome);
-//            }
-//        }
+
         SettlementDocumentaryFeesVo settlementDocumentaryFeesVo = new SettlementDocumentaryFeesVo();  // 生成跟单费结算表
         if(StringUtils.isNotEmpty(insPlyIncomeVo.getYear())){
             settlementDocumentaryFeesVo.setTimeFrame(insPlyIncomeVo.getYear());//年度
@@ -1780,9 +1722,73 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         HashMap<String, Object> params = new HashMap<>();
         this.saveParams(insPlyIncomeVo,params);
         List<HashMap<String,Object>>  resultMap=baseMapper.otherTimeDetail(params);
+
+        Set<String> uniqueYears = new HashSet<>();
+
+        for (Map<String, Object> map : resultMap) {
+            // 假设年份是以 "year" 为键的,并且它的值是 String 类型
+            String year = String.valueOf(map.get("year")) ;
+            if (year != null) { // 确保年份不是 null
+                uniqueYears.add(year);
+            }
+        }
+        this.addMonthYear(uniqueYears,resultMap);
+
         return HttpResult.ok(resultMap);
     }
 
+    /**
+     * uniqueYears  年份间隔   resultMap 返回结果
+     * @param uniqueYears
+     * @param resultMap  返回一到十二月数据
+     */
+    private void addMonthYear(Set<String> uniqueYears, List<HashMap<String, Object>> resultMap) {
+        // 存储已存在的年份-月份组合,以便快速查找
+        Set<String> existingYearMonths = new HashSet<>();
+        for (Map<String, Object> entry : resultMap) {
+            String year = String.valueOf(entry.get("year")) ;
+            int month = (Integer) entry.get("monthNumber");
+            existingYearMonths.add(year + "-" + month);
+        }
+
+        // 遍历所有年份和月份,并添加缺失的条目
+        for (String year : uniqueYears) {
+            for (int month = 1; month <= 12; month++) {
+                String yearMonth = year + "-" + month;
+                if (!existingYearMonths.contains(yearMonth)) {
+                    // 创建一个新的条目并添加到resultMap中
+                    HashMap<String, Object> newEntry = new HashMap<>();
+                    newEntry.put("year", year);
+                    newEntry.put("monthNumber", month);
+                    newEntry.put("allTotalOtherFeevalue", 0);
+                    newEntry.put("invoicCommissionFeevalue", 0);
+                    newEntry.put("monthYear", yearMonth);
+                    newEntry.put("noInvoicCommissionFeevalue", 0);
+                    resultMap.add(newEntry);
+                }
+            }
+        }
+        // 使用自定义Comparator对resultMap进行排序
+        Collections.sort(resultMap, new Comparator<HashMap<String, Object>>() {
+            @Override
+            public int compare(HashMap<String, Object> o1, HashMap<String, Object> o2) {
+                // 比较 year
+                String year1 = String.valueOf(o1.get("year")) ;
+                String year2 =String.valueOf(o2.get("year"));
+                int yearComparison = year1.compareTo(year2);
+                if (yearComparison != 0) {
+                    return yearComparison;
+                }
+
+                // 如果 year 相同,则比较 monthNumber
+                Integer monthNum1 = (Integer) o1.get("monthNumber");
+                Integer monthNum2 = (Integer) o2.get("monthNumber");
+                return monthNum1.compareTo(monthNum2);
+            }
+        });
+
+    }
+
     @Override
     public HttpResult<Object> singleInvoic(InsPlyIncomeVo insPlyIncomeVo) {
 

+ 2 - 0
src/main/resources/mapper/modules/fnc/ImportAsyncMapper.xml

@@ -16,6 +16,7 @@
         <result column="agreement_id" property="agreementId"/>
         <result column="ids" property="ids"/>
         <result column="hand_status" property="handStatus"/>
+        <result column="income_id" property="incomeId"/>
     </resultMap>
 
     <select id="queryNew" resultType="com.ydtech.modules.fnc.entity.ImportResult">
@@ -33,6 +34,7 @@
         a.ids as "ids",
         a.hand_status as "handStatus",
         a.hand_status as "handStatus",
+        a.income_id as "incomeId",
         eic.name as "partnerCompaniesName"
         from
         import_task  a

+ 191 - 141
src/main/resources/mapper/modules/fnc/InsPlyIncomeMapper.xml

@@ -76,6 +76,7 @@
         <result column="sy_end_date" property="syEndDate"/>
         <result column="settle_other_status" property="settleOtherStatus"/>
         <result column="settlement_image_id" property="settlementImageId"/>
+        <result column="task_id" property="taskId"/>
 
     </resultMap>
     <sql id="income_com">
@@ -150,6 +151,7 @@
                 a.user_id  as  "userId",
                 a.invoicing_method  as  "invoicingMethod",
                 a.settlement_image_id as "settlementImageId",
+                a.task_id as "taskId",
                 a.create_time  as  "createTime"
     </sql>
 
@@ -1335,7 +1337,6 @@
         </where>
         group  by  a.invoic_id
     </select>
-
     <update id="updateByIds"  parameterType="com.ydtech.modules.fnc.entity.InsPlyIncome">
         update ins_ply_income
             set  handling_fees_status ='1',
@@ -1350,147 +1351,196 @@
             </if>
         </where>
     </update>
-    <select id="otherTimeDetail"  resultType="java.util.HashMap">
-        WITH RECURSIVE months AS (
-        SELECT 1 AS month_num
-        UNION ALL
-        SELECT month_num + 1 FROM months WHERE month_num &lt; 12
-        )
-        SELECT
-        m.month_num AS monthNumber,
-        DATE_FORMAT(STR_TO_DATE(CONCAT(YEAR(CURDATE()), '-', LPAD(m.month_num, 2, '0'), '-01'), '%Y-%m-%d'), '%Y-%m') AS monthYear,
-        COALESCE(other_fees.total_other_feevalue, 0) AS "allTotalOtherFeevalue",
-        COALESCE(settlement_fees.total_settlement_amount, 0) AS "invoicCommissionFeevalue",
-        COALESCE(other_fees.total_other_feevalue, 0) -  COALESCE(settlement_fees.total_settlement_amount, 0) AS "noInvoicCommissionFeevalue"
-        FROM
-        months m
-        LEFT JOIN (
-        SELECT
-        MONTH(a.signdate) AS month_num,
-        SUM(a.other_feevalue) AS total_other_feevalue
-        FROM
-        `ins_ply_income` a
-        INNER JOIN ptl_agreement pa ON a.agreement_id = pa.id
-        <where>
-            1=1
-            <if test="startDate !=null  and  startDate!='' and  endDate !=null and endDate !=''">
-                and DATE_FORMAT( a.signdate, '%Y-%m-%d')  between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
-            </if>
-            <if test="agreementType !=null  and  agreementType  !=''">
-                and pa.agreement_type =#{agreementType}
-            </if>
-
-            <if test="signDateEnd !=null  and  signDateEnd!='' and  signDateStart !=null and signDateStart !=''">
-                and a.signdate   between #{signDateStart} and #{signDateEnd}
-            </if>
-
-            <if test="handlingFeesStatus !=null  and  handlingFeesStatus  !=''">
-                and a.handling_fees_status =#{handlingFeesStatus}
-            </if>
-
-            <if test="dockingPerson !=null  and  dockingPerson  !=''">
-                and  pa.docking_person  =#{dockingPerson}
-            </if>
-
-            <if test="orderno !=null  and  orderno  !=''">
-                and a.orderno =#{orderno}
-            </if>
-            <if test="companyName !=null  and  companyName  !=''">
-                and a.company_id =#{companyName}
-            </if>
-
-            <if test="policyno !=null  and  policyno  !=''">
-                and a.policyno =#{policyno}
-            </if>
-            <if test="documentaryFeesStatus !=null  and  documentaryFeesStatus  !=''">
-                and a.documentary_fees_status =#{documentaryFeesStatus}
-            </if>
-
-            <if test="isNotCar !=null  and  isNotCar  !=''">
-                and a.is_not_car =#{isNotCar}
-            </if>
-
-            <if test="isOther !=null  and  isOther  !=''">
-                and a.is_not_documentary   =#{isOther}
-            </if>
-            <if test="licenseno != null and licenseno != ''">
-                and a.licenseno  =#{licenseno}
-            </if>
-            <if test="syPolicyno != null and syPolicyno != ''">
-                and a.sy_policyno  =#{syPolicyno}
-            </if>
 
-            <if test="noPolicyno != null and noPolicyno != ''">
-                and a.no_policyno =#{noPolicyno}
-            </if>
-            <if test="signdate !=null  and  signdate  !=''">
-                AND  a.signdate =#{signdate}
-            </if>
-            <if test="partnerCompaniesId !=null  and  partnerCompaniesId  !=''">
-                AND a.partner_companies_id =#{partnerCompaniesId}
-            </if>
-
-            <if test="partnerCompaniesName !=null  and  partnerCompaniesName  !=''">
-                AND   a.partner_companies_name =#{partnerCompaniesName}
-            </if>
-
-            <if test="createTime !=null  and  createTime  !=''">
-                AND  a.create_time =#{createTime}
-            </if>
-            <if test="settlementTime !=null  and  settlementTime  !=''">
-                AND a.settlement_time =#{settlementTime}
-            </if>
-
-            <if test="userId !=null  and  userId  !=''">
-                and a.userId   =#{userId}
-            </if>
-            <if test="companyId !=null  and  companyId  !=''">
-                and a.company_id   =#{companyId}
-            </if>
-            <if test="riskcode !=null  and  riskcode  !=''">
-                and a.riskcode   =#{riskcode}
-            </if>
-            <if test="year !=null  and  year  !=''">
-                AND YEAR(a.signdate) =#{year}
-            </if>
-            <if test="yeartsStart !=null and  yeartsStart  !=''   and yeartsEnd  !=null  and  yeartsEnd!=''">
-                and DATE_FORMAT( a.signdate, '%Y')  between #{yeartsStart}   and  #{yeartsEnd}
-            </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="insuredName !=null  and  insuredName !=''">
-                AND  a.insured_name =#{insuredName}
-            </if>
-
-            AND YEAR(a.signdate) = YEAR(CURDATE())
-        </where>
-        GROUP BY
-        MONTH(a.signdate)
-        ) other_fees ON m.month_num = other_fees.month_num
-        LEFT JOIN (
-        SELECT
-        MONTH(signing_time) AS month_num,
-        SUM(settlement_amount) AS total_settlement_amount
-        FROM
-        settlement_documentary_fees
-        WHERE
-        settlement_status = '1'
-        AND handling_fees_status = '1'
-        <if test="isNotCar !=null  and  isNotCar  !=''">
-            and is_not_car =#{isNotCar}
-        </if>
-        <if test="yeartsStart !=null and  yeartsStart  !=''   and yeartsEnd  !=null  and  yeartsEnd!=''">
-            and DATE_FORMAT( signing_time, '%Y')  between #{yeartsStart}   and  #{yeartsEnd}
-        </if>
-        GROUP BY
-        MONTH(signing_time)
-        ) settlement_fees ON m.month_num = settlement_fees.month_num
-        ORDER BY
-        m.month_num;
+  <select id="otherTimeDetail"  resultType="java.util.HashMap">
+      SELECT
+          i.YEAR  as "year",
+          i.monthNumber as "monthNumber",
+          i.allTotalOtherFeevalue as "allTotalOtherFeevalue",
+          IFNULL(s.invoicCommissionFeevalue,0) AS invoicCommissionFeevalue,
+          CONCAT(i.YEAR, '-', LPAD(i.monthNumber, 2, '0')) AS "monthYear",
+          IFNULL(i.allTotalOtherFeevalue ,0) - IFNULL(s.invoicCommissionFeevalue,0)  AS noInvoicCommissionFeevalue
+      FROM (
+               SELECT
+                   YEAR(a.signdate) AS YEAR,
+                   MONTH(a.signdate) AS monthNumber,
+                   SUM(IFNULL(a.other_feevalue, 0)) AS allTotalOtherFeevalue
+
+               FROM ins_ply_income a
+                   LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
+               <where>
+                   YEAR(a.signdate) BETWEEN YEAR(CURDATE()) AND YEAR(CURDATE()) + 1
+                   <if test="startDate !=null  and  startDate!='' and  endDate !=null and endDate !=''">
+                       and DATE_FORMAT( a.signdate, '%Y-%m-%d')  between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
+                   </if>
+                   <if test="agreementType !=null  and  agreementType  !=''">
+                       and pa.agreement_type =#{agreementType}
+                   </if>
+
+                   <if test="signDateEnd !=null  and  signDateEnd!='' and  signDateStart !=null and signDateStart !=''">
+                       and a.signdate   between #{signDateStart} and #{signDateEnd}
+                   </if>
+                   <if test="yeartsStart !=null and  yeartsStart  !=''   and yeartsEnd  !=null  and  yeartsEnd!=''">
+                                   and DATE_FORMAT( a.signdate, '%Y')  between #{yeartsStart}   and  #{yeartsEnd}
+                   </if>
+                   <if test="handlingFeesStatus !=null  and  handlingFeesStatus  !=''">
+                       and a.handling_fees_status =#{handlingFeesStatus}
+                   </if>
+
+                   <if test="dockingPerson !=null  and  dockingPerson  !=''">
+                       and  pa.docking_person  =#{dockingPerson}
+                   </if>
+
+                   <if test="provinceId != null and provinceId != ''">
+                       and a.deptid like "${provinceId}%"
+                   </if>
+
+                   <if test="cityId != null and cityId != ''">
+                       and a.deptid like "${cityId}%"
+                   </if>
+
+                   <if test="countyId != null and countyId != ''">
+                       and a.deptid like "${countyId}%"
+                   </if>
+
+                   <if test="orderno !=null  and  orderno  !=''">
+                       and a.orderno =#{orderno}
+                   </if>
+                   <if test="companyName !=null  and  companyName  !=''">
+                       and a.company_id =#{companyName}
+                   </if>
+
+                   <if test="policyno !=null  and  policyno  !=''">
+                       and a.policyno =#{policyno}
+                   </if>
+                   <if test="documentaryFeesStatus !=null  and  documentaryFeesStatus  !=''">
+                       and a.documentary_fees_status =#{documentaryFeesStatus}
+                   </if>
+
+                   <if test="isNotCar !=null  and  isNotCar  !=''">
+                       and a.is_not_car =#{isNotCar}
+                   </if>
+
+                   <if test="deptId !=null  and  deptId  !=''">
+                       and pa.dept_id =#{deptId}
+                   </if>
+
+
+                   <if test="ids != null and ids != '' and ids.length > 0">
+                       and a.id in
+                       <foreach collection="ids" item="item" open="(" separator="," close=")">
+                           #{item}
+                       </foreach>
+                   </if>
+
+                   <if test="selectIds != null and selectIds != '' and selectIds.size() > 0">
+                       and a.id in
+                       <foreach collection="selectIds" item="item" open="(" separator="," close=")">
+                           #{item}
+                       </foreach>
+                   </if>
+
+                   <if test="partnerCompaniesIdList != null and partnerCompaniesIdList != '' and partnerCompaniesIdList.size() > 0">
+                       and a.partner_companies_id in
+                       <foreach collection="partnerCompaniesIdList" item="item" open="(" separator="," close=")">
+                           #{item}
+                       </foreach>
+                   </if>
+
+                   <if test="isOther !=null  and  isOther  !=''">
+                       and a.is_not_documentary   =#{isOther}
+                   </if>
+                   <if test="licenseno != null and licenseno != ''">
+                       and a.licenseno  =#{licenseno}
+                   </if>
+                   <if test="syPolicyno != null and syPolicyno != ''">
+                       and a.sy_policyno  =#{syPolicyno}
+                   </if>
+
+                   <if test="noPolicyno != null and noPolicyno != ''">
+                       and a.no_policyno =#{noPolicyno}
+                   </if>
+                   <if test="signdate !=null  and  signdate  !=''">
+                       AND  a.signdate =#{signdate}
+                   </if>
+                   <if test="partnerCompaniesId !=null  and  partnerCompaniesId  !=''">
+                       AND a.partner_companies_id =#{partnerCompaniesId}
+                   </if>
+
+                   <if test="partnerCompaniesName !=null  and  partnerCompaniesName  !=''">
+                       AND   a.partner_companies_name =#{partnerCompaniesName}
+                   </if>
+
+                   <if test="createTime !=null  and  createTime  !=''">
+                       AND  a.create_time =#{createTime}
+                   </if>
+                   <if test="settlementTime !=null  and  settlementTime  !=''">
+                       AND a.settlement_time =#{settlementTime}
+                   </if>
+
+                   <if test="userId !=null  and  userId  !=''">
+                       and a.userId   =#{userId}
+                   </if>
+                   <if test="companyId !=null  and  companyId  !=''">
+                       and a.company_id   =#{companyId}
+                   </if>
+                   <if test="riskcode !=null  and  riskcode  !=''">
+                       and a.riskcode   =#{riskcode}
+                   </if>
+                   <if test="year !=null  and  year  !=''">
+                       AND YEAR(a.signdate) =#{year}
+                   </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="insuredName !=null  and  insuredName !=''">
+                       AND  a.insured_name =#{insuredName}
+                   </if>
+                   <if test="jqStartDate  !=null  and  jqStartDate  != ''  and  jqEndDate   != null  and  jqEndDate   !=''">
+                       AND a.jq_end_date BETWEEN #{jqStartDate} AND #{jqEndDate}  AND a.jq_start_date &gt; = #{jqStartDate}
+                   </if>
+                   <if test="syStartDate  !=null  and  syStartDate  != ''  and  syEndDate   != null  and  syEndDate   !=''">
+                       AND a.sy_start_date BETWEEN #{syStartDate} AND #{syEndDate}  AND a.sy_start_date &gt; = #{syStartDate}
+                   </if>
+               </where>
+               GROUP BY YEAR(a.signdate), MONTH(a.signdate)
+           ) i
+               LEFT JOIN (
+          SELECT
+              YEAR(a.signing_time) AS YEAR,
+              MONTH(a.signing_time) AS monthNumber,
+              SUM(CASE WHEN a.settlement_status = '1' THEN IFNULL(a.settlement_amount, 0) ELSE 0 END) AS invoicCommissionFeevalue
+          FROM settlement_documentary_fees a
+          <where>
+              YEAR(a.signing_time) BETWEEN YEAR(CURDATE()) AND YEAR(CURDATE()) + 1
+              <if test="isNotCar !=null  and  isNotCar  !=''">
+                  and a.is_not_car =#{isNotCar}
+              </if>
+              <if test="partnerCompaniesIdList != null and partnerCompaniesIdList != '' and partnerCompaniesIdList.size() > 0">
+                  and a.partner_companies_id in
+                  <foreach collection="partnerCompaniesIdList" item="item" open="(" separator="," close=")">
+                      #{item}
+                  </foreach>
+              </if>
+              <if test="partnerCompaniesId !=null  and  partnerCompaniesId  !=''">
+                  AND a.partner_companies_id =#{partnerCompaniesId}
+              </if>
+              <if test="companyName !=null  and  companyName  !=''">
+                  and a.company_id =#{companyName}
+              </if>
+              <if test="handlingFeesStatus !=null  and  handlingFeesStatus  !=''">
+                  and a.handling_fees_status =#{handlingFeesStatus}
+              </if>
+              <if test="yeartsStart !=null and  yeartsStart  !=''   and yeartsEnd  !=null  and  yeartsEnd!=''">
+                  and DATE_FORMAT( a.signing_time, '%Y')  between #{yeartsStart}   and  #{yeartsEnd}
+              </if>
+          </where>
+          GROUP BY YEAR(a.signing_time), MONTH(a.signing_time)
+      ) s ON i.YEAR = s.YEAR AND i.monthNumber = s.monthNumber
+      ORDER BY i.YEAR, i.monthNumber;
     </select>
 
 </mapper>

+ 63 - 29
src/main/resources/mapper/modules/ins/InsFeeOrderNewMapper.xml

@@ -199,10 +199,11 @@
     <select id="getByUserIdAndOrderStatusAndNoCheck"  resultType="com.ydtech.modules.protocols.entity.po.InsFeeOrderNew">
         select a.*  from
             ins_fee_order_new a  left join ins_area_company ins  on  a.ins_order_no=ins.id
+                                 left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
         WHERE
             a.user_id = #{userId}
           and  ins.orderstatus ='3'
-          and NOT EXISTS (SELECT ins_order_no FROM ins_fee_audit fee where fee.ins_order_no =a.ins_order_no)
+          and iff.auditstatus=0
     </select>
 
     <select id="getSumWillAmount"  resultType="com.ydtech.modules.protocols.entity.po.InsFeeOrderNew">
@@ -220,12 +221,13 @@
         from
         ins_fee_order_new a  left join ins_area_company ins  on  a.ins_order_no=ins.id
         left join  ins_orders o ON o.orderno=ins.orderno
+        left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
         <where>
             <if test="userId !=null  and  userId !=''">
                 a.user_id = #{userId}
             </if>
             and  ins.orderstatus ='3'
-            and NOT EXISTS (SELECT ins_order_no FROM ins_fee_audit fee where fee.ins_order_no =a.ins_order_no)
+            and iff.auditstatus=0
             <if test="timeFiltering!= null  and  timeFiltering  !=''">
                 AND DATE_FORMAT(ins.signing_time, '%Y-%m' ) = #{timeFiltering}
             </if>
@@ -267,8 +269,9 @@
         ins_fee_order_new a
         LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
         left join  ins_orders o ON o.orderno=iac.orderno
+        left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
         <where>
-            NOT EXISTS (SELECT ins_order_no FROM ins_fee_audit fee where fee.ins_order_no =a.ins_order_no)
+            iff.auditstatus=0
             and iac.orderstatus = '3'
             <if test="userId!=null and  userId!= ''">
                 AND a.first_level_user_id = #{userId}
@@ -291,8 +294,9 @@
         ins_fee_order_new a
         LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
         left join  ins_orders o ON o.orderno=iac.orderno
+        left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
         <where>
-            NOT EXISTS (SELECT ins_order_no FROM ins_fee_audit fee where fee.ins_order_no =a.ins_order_no)
+            iff.auditstatus=0
             and iac.orderstatus = '3'
             <if test="userId!=null and  userId!= ''">
                 AND a.three_level_user_id = #{userId}
@@ -315,8 +319,9 @@
         ins_fee_order_new a
         LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
         left join  ins_orders o ON o.orderno=iac.orderno
+        left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
         <where>
-            NOT EXISTS (SELECT ins_order_no FROM ins_fee_audit fee where fee.ins_order_no =a.ins_order_no)
+            iff.auditstatus=0
             and iac.orderstatus = '3'
             <if test="userId!=null and  userId!= ''">
                 AND a.two_level_user_id = #{userId}
@@ -326,17 +331,27 @@
     </select>
     <select id="getByUserIdAndOrderStatusAndNoCheckType"
             resultType="com.ydtech.modules.protocols.entity.po.InsFeeOrderNew">
-        select a.*  from
+        select
+            a.jq_export_supervise_costs_premiums as "jqExportSuperviseCostsPremiums",
+            a.sy_export_supervise_costs_premiums as "syExportSuperviseCostsPremiums",
+            a.no_export_supervise_costs_premiums as "noExportSuperviseCostsPremiums",
+            a.jq_export_other_costs_premiums as "jqExportOtherCostsPremiums",
+            a.sy_export_other_costs_premiums as "syExportOtherCostsPremiums",
+            a.no_export_other_costs_premiums as "noExportOtherCostsPremiums"
+            from
             ins_fee_order_new a  left join ins_area_company ins  on  a.ins_order_no=ins.id
+            left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
         WHERE
             a.user_id = #{userId}
           and  ins.orderstatus ='3'
-          and a.ins_order_no
-          <if test="type=='1'">
-             not
-          </if>
-           in
-           (select ins_order_no from ins_fee_audit)
+            <choose>
+                <when  test='type == "1"'>
+                    and iff.auditstatus=0
+                </when>
+                <otherwise>
+                    and  iff.auditstatus=1
+                </otherwise>
+            </choose>
     </select>
     <select id="getSumWillAmountGeneralizationNew"
             resultType="com.ydtech.modules.protocols.entity.po.InsFeeOrderNew">
@@ -370,11 +385,16 @@
         ins_fee_order_new a
         LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
         left join  ins_orders o ON o.orderno=iac.orderno
+        left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
         <where>
-            <if test='type == "1"'>
-                NOT
-            </if>
-            EXISTS (SELECT ins_order_no FROM ins_fee_audit fee where fee.ins_order_no =a.ins_order_no)
+            <choose>
+                <when  test='type == "1"'>
+                    iff.auditstatus=0
+                </when>
+                <otherwise>
+                    iff.auditstatus=1
+                </otherwise>
+            </choose>
             and iac.orderstatus = '3'
             <if test="userId!=null and  userId!= ''">
                 AND a.first_level_user_id = #{userId}
@@ -407,11 +427,16 @@
         ins_fee_order_new a
         LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
         left join  ins_orders o ON o.orderno=iac.orderno
+        left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
         <where>
-            <if test='type == "1"'>
-                NOT
-            </if>
-            EXISTS (SELECT ins_order_no FROM ins_fee_audit fee where fee.ins_order_no =a.ins_order_no)
+            <choose>
+                <when  test='type == "1"'>
+                    iff.auditstatus=0
+                </when>
+                <otherwise>
+                    iff.auditstatus=1
+                </otherwise>
+            </choose>
             and iac.orderstatus = '3'
             <if test="userId!=null and  userId!= ''">
                 AND a.three_level_user_id = #{userId}
@@ -444,11 +469,16 @@
         ins_fee_order_new a
         LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
         left join  ins_orders o ON o.orderno=iac.orderno
+        left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
         <where>
-            <if test='type == "1"'>
-                NOT
-            </if>
-            EXISTS (SELECT ins_order_no FROM ins_fee_audit fee where fee.ins_order_no =a.ins_order_no)
+            <choose>
+                <when  test='type == "1"'>
+                    iff.auditstatus=0
+                </when>
+                <otherwise>
+                    iff.auditstatus=1
+                </otherwise>
+            </choose>
             and iac.orderstatus = '3'
             <if test="userId!=null and  userId!= ''">
                 AND a.two_level_user_id = #{userId}
@@ -482,16 +512,20 @@
         from
         ins_fee_order_new a  left join ins_area_company ins  on  a.ins_order_no=ins.id
         left join  ins_orders o ON o.orderno=ins.orderno
+        left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
         <where>
             <if test="userId !=null  and  userId !=''">
                 a.user_id = #{userId}
             </if>
             and  ins.orderstatus ='3'
-            and
-            <if test='type == "1"'>
-                NOT
-            </if>
-            EXISTS (SELECT ins_order_no FROM ins_fee_audit fee where fee.ins_order_no =a.ins_order_no)
+            <choose>
+                <when  test='type == "1"'>
+                    and  iff.auditstatus=0
+                </when>
+                <otherwise>
+                    and  iff.auditstatus=1
+                </otherwise>
+            </choose>
             <if test="timeFiltering!= null  and  timeFiltering  !=''">
                 <choose>
                     <when  test='type == "1"'>

+ 37 - 23
src/main/resources/mapper/modules/order/InsAreaCompanyMapper.xml

@@ -310,13 +310,9 @@
         FROM
         ins_fee_order_new a
         LEFT JOIN ins_area_company iac on iac.id=a.ins_order_no
+        left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
         WHERE
-        a.ins_order_no NOT IN (
-        SELECT
-        ins_order_no
-        FROM
-        ins_fee_audit
-        )
+        iff.auditstatus=0
         AND iac.orderstatus =3
         <if test="firstUserId != null and firstUserId != ''">
             AND a.first_level_user_id = #{firstUserId}
@@ -343,8 +339,9 @@
         FROM
         ins_fee_order_new a
         LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
+        left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
         <where>
-            NOT EXISTS ( SELECT ins_order_no FROM ins_fee_audit AS b WHERE b.ins_order_no = a.ins_order_no )
+            iff.auditstatus=0
             and iac.orderstatus = '3'
             <if test="userId!=null and  userId!= ''">
                 AND a.first_level_user_id = #{userId}
@@ -359,8 +356,9 @@
         FROM
         ins_fee_order_new a
         LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
+        left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
         <where>
-            NOT EXISTS ( SELECT ins_order_no FROM ins_fee_audit AS b WHERE b.ins_order_no = a.ins_order_no )
+            iff.auditstatus=0
             and iac.orderstatus = '3'
             <if test="userId!=null and  userId!= ''">
                 AND a.three_level_user_id = #{userId}
@@ -375,8 +373,9 @@
         FROM
         ins_fee_order_new a
         LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
+        left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
         <where>
-            NOT EXISTS ( SELECT ins_order_no FROM ins_fee_audit AS b WHERE b.ins_order_no = a.ins_order_no )
+            iff.auditstatus=0
             and iac.orderstatus = '3'
             <if test="userId!=null and  userId!= ''">
                 AND a.two_level_user_id = #{userId}
@@ -394,8 +393,9 @@
         FROM
         ins_fee_order_new a
         LEFT JOIN ins_area_company iac on iac.id=a.ins_order_no
+        left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
         WHERE
-        NOT EXISTS ( SELECT ins_order_no FROM ins_fee_audit AS b WHERE b.ins_order_no = a.ins_order_no )
+        iff.auditstatus=0
         AND iac.orderstatus =3
         <if test="firstUserId != null and firstUserId != ''">
             AND a.first_level_user_id = #{firstUserId}
@@ -499,12 +499,16 @@
         FROM
         ins_fee_order_new a
         LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
+        left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
         <where>
-            <if test='type == "1"'>
-                NOT
-            </if>
-            EXISTS
-            ( SELECT ins_order_no FROM ins_fee_audit AS b WHERE b.ins_order_no = a.ins_order_no )
+            <choose>
+                <when  test='type == "1"'>
+                    iff.auditstatus=0
+                </when>
+                <otherwise>
+                    iff.auditstatus=1
+                </otherwise>
+            </choose>
             and iac.orderstatus = '3'
             <if test="userId!=null and  userId!= ''">
                 AND a.first_level_user_id = #{userId}
@@ -519,11 +523,16 @@
         FROM
         ins_fee_order_new a
         LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
+        left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
         <where>
-            <if test='type == "1"'>
-                NOT
-            </if>
-            EXISTS ( SELECT ins_order_no FROM ins_fee_audit AS b WHERE b.ins_order_no = a.ins_order_no )
+            <choose>
+                <when  test='type == "1"'>
+                    iff.auditstatus=0
+                </when>
+                <otherwise>
+                    iff.auditstatus=1
+                </otherwise>
+            </choose>
             and iac.orderstatus = '3'
             <if test="userId!=null and  userId!= ''">
                 AND a.three_level_user_id = #{userId}
@@ -538,11 +547,16 @@
         FROM
         ins_fee_order_new a
         LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
+        left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
         <where>
-            <if test='type == "1"'>
-                NOT
-            </if>
-            EXISTS ( SELECT ins_order_no FROM ins_fee_audit AS b WHERE b.ins_order_no = a.ins_order_no )
+            <choose>
+                <when  test='type == "1"'>
+                    iff.auditstatus=0
+                </when>
+                <otherwise>
+                    iff.auditstatus=1
+                </otherwise>
+            </choose>
             and iac.orderstatus = '3'
             <if test="userId!=null and  userId!= ''">
                 AND a.two_level_user_id = #{userId}

+ 1 - 1
src/main/resources/mapper/modules/protocol/PtlAgreementMapper.xml

@@ -133,6 +133,6 @@
                   and   a.partner_companies_id =#{partnerCompaniesId}
             </if>
         </where>
-
+        limit  1
     </select>
 </mapper>