wuhp 2 жил өмнө
parent
commit
ba5943e420

+ 47 - 10
src/main/java/com/ydtech/modules/fnc/controller/InsPlyIncomeController.java

@@ -22,6 +22,7 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
 import java.io.IOException;
+import java.math.BigDecimal;
 import java.time.LocalDate;
 import java.time.Period;
 import java.util.HashMap;
@@ -146,12 +147,30 @@ public class InsPlyIncomeController extends BaseController {
     @ApiImplicitParams({
             @ApiImplicitParam(name = "file", value = "excel文件", required = true, dataType = "__file")
     })
-    public HttpResult importData(@RequestParam MultipartFile MultipartFile) {
+    public HttpResult importData(@RequestParam MultipartFile multipartFile) {
 
-        insPlyIncomeService.importData(MultipartFile);
+        insPlyIncomeService.importData(multipartFile);
 
         return HttpResult.ok("导入成功");
     }
+    @PostMapping("/bxImportData")
+    @ApiOperation(value = "保险手续费导入(excel)")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "file", value = "excel文件", required = true, dataType = "__file")
+    })
+    public HttpResult bxImportData(@RequestParam MultipartFile multipartFile) {
+        HashMap<String, Object> result= insPlyIncomeService.bxImportData(multipartFile);
+        return HttpResult.ok(result);
+    }
+    @PostMapping("/bxImportNoData")
+    @ApiOperation(value = "保险非车手续费导入(excel)")
+    @ApiImplicitParams({
+    @ApiImplicitParam(name = "file", value = "excel文件", required = true, dataType = "__file")
+    })
+    public HttpResult bxImportNoData(@RequestParam MultipartFile multipartFile) {
+        HashMap<String, Object> result= insPlyIncomeService.bxImportNoData(multipartFile);
+        return HttpResult.ok(result);
+    }
 
 
 
@@ -219,24 +238,42 @@ public class InsPlyIncomeController extends BaseController {
     }
 
 
-    @ApiModelProperty("保险手续费导出")
-    @PostMapping("bxHandlingExcel")
-    public HttpResult bxHandlingexcel(@RequestBody @ApiParam(name = "insPlyIncomeVo") InsPlyIncomeVo  insPlyIncomeVo , HttpServletRequest request, HttpServletResponse response ) throws IOException {
-            return  insPlyIncomeService.bxHandlingexcel(insPlyIncomeVo, request, response);
-
-    }
-
     @ApiModelProperty("平台手续费导出")
     @PostMapping("pinHandlingExcel")
     public HttpResult pinHandlingexcel(@RequestBody @ApiParam(name = "insPlyIncomeVo") InsPlyIncomeVo  insPlyIncomeVo , HttpServletRequest request, HttpServletResponse response ){
+        return insPlyIncomeService.pinHandlingexcel(insPlyIncomeVo, request, response);
+    }
 
-            return insPlyIncomeService.pinHandlingexcel(insPlyIncomeVo, request, response);
+    @ApiModelProperty("保险手续费导出")
+    @PostMapping("bxHandlingExcel")
+    public HttpResult bxHandlingexcel(@RequestBody @ApiParam(name = "insPlyIncomeVo") InsPlyIncomeVo  insPlyIncomeVo , HttpServletRequest request, HttpServletResponse response ) throws IOException {
+            return  insPlyIncomeService.bxHandlingexcel(insPlyIncomeVo, request, response);
     }
     @ApiModelProperty("保险跟单导出")
     @PostMapping("bxOtherExcel")
     public HttpResult bxOtherExcel(@RequestBody @ApiParam(name = "insPlyIncomeVo") InsPlyIncomeVo  insPlyIncomeVo , HttpServletRequest request, HttpServletResponse response ){
             return insPlyIncomeService.bxOtherExcel(insPlyIncomeVo, request, response);
         }
+
+    @ApiModelProperty("保险跟单明细导出")
+    @PostMapping("/bxOtherDetailsExcel")
+    public HttpResult bxOtherDetailsExcel(@RequestBody @ApiParam(name = "insPlyIncomeVo") InsPlyIncomeVo  insPlyIncomeVo , HttpServletRequest request, HttpServletResponse response ){
+            return insPlyIncomeService.bxOtherDetailsExcel(insPlyIncomeVo, request, response);
+        }
+
+    @PostMapping("/invicdetail")
+    @ApiOperation(value = "开票未结算详情查询")
+    public HttpResult<List<HashMap<String,Object>>>   invicdetail (@Valid  @RequestBody InsPlyIncomeVo  insPlyIncomeVo){
+        return  insPlyIncomeService.invicdetail(insPlyIncomeVo);
+    }
+    @ApiModelProperty("保险非车跟单明细导出")
+    @PostMapping("/bxNoOtherDetailsExcel")
+    public HttpResult bxNoOtherDetailsExcel(@RequestBody @ApiParam(name = "insPlyIncomeVo") InsPlyIncomeVo  insPlyIncomeVo , HttpServletRequest request, HttpServletResponse response ){
+        return insPlyIncomeService.bxNoOtherDetailsExcel(insPlyIncomeVo, request, response);
     }
 
 
+
+}
+
+

+ 10 - 0
src/main/java/com/ydtech/modules/fnc/dao/InsPlyIncomeMapper.java

@@ -101,4 +101,14 @@ public interface InsPlyIncomeMapper extends BaseMapper<InsPlyIncome> {
     InsPlyIncome bxTotalAmount(HashMap<String, Object> params);
 
 
+    InsPlyIncome findByBxLicenseno(HashMap<String, Object> params);
+
+    InsPlyIncome getById (@Param("id") String id);
+
+    /**
+     *
+     * @param idArr   开票的id
+     * @return
+     */
+    List<HashMap<String,Object>> groupByInvoic(@Param("idArr") String[] idArr);
 }

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

@@ -376,6 +376,13 @@ public class InsPlyIncome implements Serializable {
     @TableField(exist = false)
     private String invoicIds;
 
+    @ApiModelProperty("协议名称")
+    @TableField(exist = false)
+    private String agreementName;
+    @ApiModelProperty("用户名称")
+    @TableField(exist = false)
+    private String userName;
+
 
     public InsPlyIncome(String orderno, String policyno, String syPolicyno, String noPolicyno, String settleno, String deptId, String deptName, String riskcode, LocalDateTime payDate, LocalDateTime signDate, String companyId, String companyName, String agreementId, String licenseno, BigDecimal taxamount, BigDecimal noTaxPremium, BigDecimal commissionFeerate, BigDecimal otherFeerate, BigDecimal commissionFeevalue, BigDecimal otherFeevalue, BigDecimal allFeeValue, BigDecimal finalFeeValue, BigDecimal doingFeeValue, LocalDate createTime, String voucherNumber, String contractId, String contractFileId, String handlingFeesStatus, String documentaryFeesStatus, String isNotCar, String isNotDocumentary) {
         this.orderno = orderno;

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

@@ -12,6 +12,7 @@ import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import java.math.BigDecimal;
 import java.util.HashMap;
 import java.util.List;
 
@@ -45,7 +46,7 @@ public interface InsPlyIncomeService extends IService<InsPlyIncome> {
     HttpResult<List<InsPlyIncome>> nonSettldetail(InsPlyIncomeVo insPlyIncomeVo);
 
 
-    void importData(MultipartFile MultipartFile);
+    void importData(MultipartFile multipartFile);
 
     void updateByEntity(InsPlyIncomeVo insPlyIncomeVo);
 
@@ -81,4 +82,26 @@ public interface InsPlyIncomeService extends IService<InsPlyIncome> {
     HttpResult bxOtherExcel(InsPlyIncomeVo insPlyIncomeVo, HttpServletRequest request, HttpServletResponse response);
 
     InsPlyIncome bxTotalAmount(InsPlyIncomeVo insPlyIncomeVo);
+
+    HashMap<String, Object> bxImportData(MultipartFile multipartFile);
+
+    HashMap<String, Object> bxImportNoData(MultipartFile multipartFile);
+
+    /**
+     *
+     * @param insPlyIncomeVo 参数对象
+     * @param request
+     * @param response
+     * @return
+     */
+    HttpResult bxOtherDetailsExcel(InsPlyIncomeVo insPlyIncomeVo, HttpServletRequest request, HttpServletResponse response);
+
+    /**
+     *
+     * @param insPlyIncomeVo  传参字段
+     * @return  开票未结算金额  开票号   ids  开票时间
+     */
+    HttpResult<List<HashMap<String,Object>>> invicdetail(InsPlyIncomeVo insPlyIncomeVo);
+
+    HttpResult bxNoOtherDetailsExcel(InsPlyIncomeVo insPlyIncomeVo, HttpServletRequest request, HttpServletResponse response);
 }

+ 223 - 33
src/main/java/com/ydtech/modules/fnc/service/impl/InsPlyIncomeServiceImpl.java

@@ -3,6 +3,7 @@ package com.ydtech.modules.fnc.service.impl;
 import cn.afterturn.easypoi.excel.entity.ExportParams;
 import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.text.StrBuilder;
 import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fasterxml.jackson.core.JsonProcessingException;
@@ -10,6 +11,7 @@ import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import com.ydtech.constants.enums.dict.agreement.ProductsType;
 import com.ydtech.core.page.HttpResult;
 import com.ydtech.exception.SystemException;
 import com.ydtech.modules.esm.model.EsmInsCompany;
@@ -25,11 +27,10 @@ import com.ydtech.modules.fnc.service.SettlementDocumentaryFeesService;
 import com.ydtech.modules.fnc.service.SettlementDocumentaryLogService;
 import com.ydtech.modules.fnc.vo.InsPlyIncomeVo;
 import com.ydtech.modules.fnc.vo.SettlementDocumentaryFeesVo;
-import com.ydtech.modules.ins.model.vo.res.BxOtherExcel;
-import com.ydtech.modules.ins.model.vo.res.BxSettlementFeesExcel;
-import com.ydtech.modules.ins.model.vo.res.InsCmainNocarDetailResVo;
-import com.ydtech.modules.ins.model.vo.res.SettlementFeesExcel;
+import com.ydtech.modules.ins.model.vo.res.*;
 import com.ydtech.modules.inv.model.InvChannelsExternalBillsDetails;
+import com.ydtech.modules.inv.model.dto.InsBxNoPlyIncomeExcelDto;
+import com.ydtech.modules.inv.model.dto.InsBxPlyIncomeExcelDto;
 import com.ydtech.modules.inv.model.dto.InsPlyIncomeExcelDto;
 import com.ydtech.modules.inv.model.dto.InvChannelExcelDto;
 import com.ydtech.modules.inv.model.excel.InvDisburseExcel;
@@ -142,16 +143,16 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
             if ("1".equals(agreeType)) {
                 this.savePinTai(order,insFeeOrderNew,insAreaCompany);  //手续费不分非车不非车 跟单也不分
             }else {  // 保险  逻辑: 手续费生成一条  跟单费生成一条   非车手续费一条  非车跟单费一条
-                if (insFeeOrderNew.getJqSuperviseCostsPremiums() != null || insFeeOrderNew.getSySuperviseCostsPremiums() != null) { //手续费
+                if (((insFeeOrderNew.getJqSuperviseCostsPremiums() != null && insFeeOrderNew.getJqSuperviseCostsPremiums().compareTo(BigDecimal.ZERO) != 0)) || (insFeeOrderNew.getSySuperviseCostsPremiums() != null && insFeeOrderNew.getSySuperviseCostsPremiums().compareTo(BigDecimal.ZERO) != 0)) { //手续费
                     this.saveInsuranceProcedures(order,insFeeOrderNew,insAreaCompany);
                 }
-                if(insFeeOrderNew.getJqOtherCostsPremiums()!=null ){   //跟单费
+                if(insFeeOrderNew.getJqOtherCostsPremiums()!=null &&   insFeeOrderNew.getJqOtherCostsPremiums().compareTo(BigDecimal.ZERO) != 0){   //跟单费
                     this.saveOtherAmount(order,insFeeOrderNew,insAreaCompany);
                 }
-                if(insFeeOrderNew.getNoSuperviseCostsPremiums()  !=null){  // 非车手续费
+                if(insFeeOrderNew.getNoSuperviseCostsPremiums()  !=null &&   insFeeOrderNew.getNoSuperviseCostsPremiums().compareTo(BigDecimal.ZERO) != 0) {  // 非车手续费
                     this.saveNoSupervise(order,insFeeOrderNew,insAreaCompany);
                 }
-                if(insFeeOrderNew.getNoOtherCostsPremiums() !=null){  // 非车跟单费
+                if(insFeeOrderNew.getNoOtherCostsPremiums() !=null &&     insFeeOrderNew.getNoOtherCostsPremiums().compareTo(BigDecimal.ZERO) != 0){  // 非车跟单费
                     this.saveNoOtherAmount(order,insFeeOrderNew,insAreaCompany);
                 }
             }
@@ -168,7 +169,7 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         insPlyIncome.setOtherFeevalue(insFeeOrderNew.getNoOtherCostsPremiums());  //非车跟单费
         insPlyIncome.setOtherFeerate(insFeeOrderNew.getNoOtherCostsProportion()); //非车跟单费用比例
         insPlyIncome.setDeptId(insFeeOrderNew.getDeptId());
-        insPlyIncome.setRiskcode(order.getProductid());
+        this.saveRiskCode(order.getProductid(),insPlyIncome);
         insPlyIncome.setPayDate(insAreaCompany.getPayDate());
         insPlyIncome.setSignDate(insAreaCompany.getSigningTime());
         insPlyIncome.setCompanyId(insAreaCompany.getCompanyId());
@@ -196,8 +197,9 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         if(StringUtils.isNotEmpty(noPolicyno)){
             insPlyIncome.setNoPolicyno(noPolicyno); // 非车保单号
         }
+
         insPlyIncome.setDeptId(insFeeOrderNew.getDeptId());
-        insPlyIncome.setRiskcode(order.getProductid());
+        this.saveRiskCode(order.getProductid(),insPlyIncome);
         insPlyIncome.setPayDate(insAreaCompany.getPayDate());
         insPlyIncome.setSignDate(insAreaCompany.getSigningTime());
         insPlyIncome.setCompanyId(insAreaCompany.getCompanyId());
@@ -218,6 +220,26 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         baseMapper.insert(insPlyIncome);
     }
 
+    private void saveRiskCode(String productid,InsPlyIncome insPlyIncome) {
+        if(ProductsType.PT_0330.getCode().equals(productid)){
+            insPlyIncome.setRiskcode(ProductsType.PT_0330.getDesc());
+        }
+        if(ProductsType.PT_034001.getCode().equals(productid)){
+            insPlyIncome.setRiskcode(ProductsType.PT_034001.getDesc());
+        }
+
+        if(ProductsType.PT_034002.getCode().equals(productid)){
+            insPlyIncome.setRiskcode(ProductsType.PT_034002.getDesc());
+        }
+        if(ProductsType.PT_0330034002.getCode().equals(productid)){
+            insPlyIncome.setRiskcode(ProductsType.PT_0330034002.getDesc());
+        }
+        if(ProductsType.PT_0330034001.getCode().equals(productid)){
+            insPlyIncome.setRiskcode(ProductsType.PT_0330034001.getDesc());
+        }
+
+    }
+
     private void saveOtherAmount(InsOrders order, InsFeeOrderNew insFeeOrderNew, InsAreaCompany insAreaCompany) {
         BigDecimal otherAmount = this.calculateTotal(insFeeOrderNew.getJqOtherCostsPremiums(), insFeeOrderNew.getSyOtherCostsPremiums(),null);
         BigDecimal otherProportion = this.calculateTotal(insFeeOrderNew.getSyOtherCostsProportion(), insFeeOrderNew.getJqOtherCostsProportion(),null);
@@ -227,7 +249,7 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
 
         InsPlyIncome insPlyIncome = new InsPlyIncome(insFeeOrderNew.getId(),insAreaCompany.getJqpolicyno(),insAreaCompany.getSypolicyno(),null,null,insFeeOrderNew.getDeptId(),null,order.getProductid(),insAreaCompany.getPayDate(),insAreaCompany.getSigningTime(),insAreaCompany.getCompanyId(),null,insFeeOrderNew.getAgreementId(),order.getLicenseno(),insAreaCompany.getTaxamount(),
                 allNoTaxPremium,null,otherProportion,null,otherAmount,otherAmount,null,null,LocalDate.now(),null,null,null,"0","0","0","1");
-
+        this.saveRiskCode(order.getProductid(),insPlyIncome);
         insPlyIncome.setTaxPremium(allPremium);
         insPlyIncome.setJqPremium(insFeeOrderNew.getJqPremium());
         insPlyIncome.setSyPremium(insFeeOrderNew.getSyPremium());
@@ -259,10 +281,10 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         insPlyIncome.setJqSuperviseCostsPremiums(insFeeOrderNew.getJqSuperviseCostsPremiums());
         insPlyIncome.setSySuperviseCostsProportion(insFeeOrderNew.getSySuperviseCostsProportion());
         insPlyIncome.setSySuperviseCostsPremiums(insFeeOrderNew.getSySuperviseCostsPremiums());
+        this.saveRiskCode(order.getProductid(),insPlyIncome);
         insPlyIncome.setTaxPremium(allTaxPremium);
         insPlyIncome.setUserId(insFeeOrderNew.getUserId());
         this.saveByCompanyId(insFeeOrderNew ,insAreaCompany.getCompanyId(),insPlyIncome);
-
         baseMapper.insert(insPlyIncome);
     }
 
@@ -341,9 +363,9 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
                 insPlyIncome.setPartnerCompaniesName(name);
                 insPlyIncome.setPartnerCompaniesId(ptlAgreementQueryVo.getPartnerCompaniesId());
             }
-            if(StringUtils.isNotEmpty(ptlAgreementQueryVo.getAssociationCompaniesId())){
-                String associationCompaniesId = ptlAgreementQueryVo.getAssociationCompaniesId();
-                EsmInsCompany esmInsCompany = EsmInsCompanyService.getById(associationCompaniesId);
+            if(StringUtils.isNotEmpty(ptlAgreementQueryVo.getInsuranceCompanyId())){
+                String insuranceCompanyId = ptlAgreementQueryVo.getInsuranceCompanyId();
+                EsmInsCompany esmInsCompany = EsmInsCompanyService.getById(insuranceCompanyId);
                 String name = esmInsCompany.getName();   //保险公司名称
                 insPlyIncome.setCompanyName(name);
             }
@@ -470,7 +492,7 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
             params.put("agreementType",insPlyIncomeVo.getAgreementType());
         }
         if(StringUtils.isNotEmpty(insPlyIncomeVo.getLicenseno())){
-            params.put("licenseno", insPlyIncomeVo.getLicenseno().split(","));
+            params.put("licenseno", insPlyIncomeVo.getLicenseno());
         }
         if(StringUtils.isNotEmpty(insPlyIncomeVo.getUserId())){
             params.put("userId",insPlyIncomeVo.getUserId());
@@ -518,6 +540,9 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         if(StringUtils.isNotEmpty(insPlyIncomeVo.getSignDateStart())){
             params.put("signDateStart",insPlyIncomeVo.getSignDateStart());
         }
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getCompanyName())){
+            params.put("companyName",insPlyIncomeVo.getCompanyName());
+        }
         return params;
     }
 
@@ -557,13 +582,13 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
     @Override
     public HttpResult<List<InsPlyIncome>> nonSettldetail(InsPlyIncomeVo insPlyIncomeVo) {
         try {
-            String ids = insPlyIncomeVo.getIncomeIds();
+            String ids = insPlyIncomeVo.getIds();
             ArrayList<InsPlyIncome> resultList = new ArrayList<>();
             if (ObjectUtils.isNotEmpty(ids)) {
                 String[] split = ids.split(",");
                     for (int i =0; i <split.length ; i++) {
                     String id = split[i];
-                    resultList.add(baseMapper.selectById(id));
+                    resultList.add(this.baseMapper.getById(id));
                 }
             }
             return HttpResult.ok(resultList);
@@ -574,11 +599,11 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
     }
 
     @Override
-    public void importData(MultipartFile MultipartFile) {
+    public void importData(MultipartFile multipartFile) {
         List<InsPlyIncome> list = null;
         HashMap<String, Object> params = new HashMap<>();
         try {
-            List<InsPlyIncomeExcelDto> dtoList = ExcelEasypoiUtils.importExcel(MultipartFile, InsPlyIncomeExcelDto.class, 0, 1, 1);
+            List<InsPlyIncomeExcelDto> dtoList = ExcelEasypoiUtils.importExcel(multipartFile, InsPlyIncomeExcelDto.class, 0, 1, 1);
             for (InsPlyIncomeExcelDto excelItem : dtoList) {
                 params.clear();
                 String licenseno = excelItem.getLicenseno();//车牌号
@@ -604,6 +629,167 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         }
     }
 
+
+    @Override
+    public HashMap<String, Object> bxImportData(MultipartFile multipartFile) {
+        BigDecimal totalAmount=BigDecimal.ZERO;
+        HashMap<String, Object> params = new HashMap<>();
+        HashMap<String, Object> resultMap = new HashMap<>();
+        StringBuffer strBuilder = new StringBuffer();
+        String ids="";
+        try {
+            List<InsBxPlyIncomeExcelDto> dtoList = ExcelEasypoiUtils.importExcel(multipartFile, InsBxPlyIncomeExcelDto.class, 0, 1, 1);
+            for (InsBxPlyIncomeExcelDto excelItem : dtoList) {
+                params.clear();
+                if(StringUtils.isNotEmpty(excelItem.getLicenseno())){
+                    String licenseno = excelItem.getLicenseno();//车牌号
+                    params.put("licenseno",licenseno);
+                }
+                if(StringUtils.isNotEmpty(excelItem.getPolicyno())){
+                    String policyno = excelItem.getPolicyno(); //交强保单号
+                    params.put("policyno",policyno);
+                }
+
+                if(StringUtils.isNotEmpty(excelItem.getSyPolicyno())){
+                    String syPolicyno = excelItem.getSyPolicyno(); //商业保单号
+                    params.put("syPolicyno",syPolicyno);
+                }
+//                只查手续费
+                params.put("isOther","0");
+                params.put("isNotCar","0");
+                InsPlyIncome insPlyIncome = baseMapper.findByBxLicenseno(params);
+                strBuilder.append(insPlyIncome.getId()).append(",");
+                if(  insPlyIncome.getCommissionFeevalue()!=null && insPlyIncome.getCommissionFeevalue().compareTo(BigDecimal.ZERO)!=0){
+                    totalAmount = totalAmount.add(insPlyIncome.getCommissionFeevalue());  //添加总手续费
+                }
+            }
+            if(strBuilder.length() >0){
+                 ids = strBuilder.deleteCharAt(strBuilder.length() - 1).toString();
+            }
+            resultMap.put("ids",ids);
+            resultMap.put("totalAmount",totalAmount);
+            return resultMap;
+        } catch (IOException e) {
+            throw new SystemException("导入失败!");
+        }
+
+    }
+
+    @Override
+    public HashMap<String, Object> bxImportNoData(MultipartFile multipartFile) {
+        BigDecimal totalAmount=BigDecimal.ZERO;
+        HashMap<String, Object> params = new HashMap<>();
+        HashMap<String, Object> resultMap = new HashMap<>();
+        StringBuffer strBuilder = new StringBuffer();
+        String ids="";
+        try {
+            List<InsBxNoPlyIncomeExcelDto> dtoList = ExcelEasypoiUtils.importExcel(multipartFile, InsBxNoPlyIncomeExcelDto.class, 0, 1, 1);
+            for (InsBxNoPlyIncomeExcelDto excelItem : dtoList) {
+                params.clear();
+                if(StringUtils.isNotEmpty(excelItem.getLicenseno())){
+                    String licenseno = excelItem.getLicenseno();//车牌号
+                    params.put("licenseno",licenseno);
+                }
+                if(StringUtils.isNotEmpty(excelItem.getNoPolicyno())){
+                    String policyno = excelItem.getNoPolicyno(); //非车保单号
+                    params.put("policyno",policyno);
+                }
+//                只查手续费
+                params.put("isOther","1");
+                InsPlyIncome insPlyIncome = baseMapper.findByBxLicenseno(params);
+                strBuilder.append(insPlyIncome.getId()).append(",");
+                totalAmount = totalAmount.add(insPlyIncome.getCommissionFeevalue());  //添加总手续费
+            }
+            if(strBuilder.length() >0){
+                ids = strBuilder.deleteCharAt(strBuilder.length() - 1).toString();
+            }
+            resultMap.put("ids",ids);
+            resultMap.put("totalAmount",totalAmount);
+            return resultMap;
+        } catch (IOException e) {
+            throw new SystemException("导入失败!");
+        }
+    }
+
+    @Override
+    public HttpResult bxOtherDetailsExcel(InsPlyIncomeVo insPlyIncomeVo, HttpServletRequest request, HttpServletResponse response) {
+        HashMap<String, Object> params = new HashMap<>();
+        params =this.saveParams(insPlyIncomeVo,params);
+        List<InsPlyIncome> insPlyIncomes = baseMapper.queryNew(params);
+
+        ExportParams exportParams = new ExportParams("保险跟单明细导出", null, ExcelType.HSSF);
+        exportParams.setStyle(ExcelStyleUtil.class);
+        List<BxOtherDetailsExcel> resultList = new ArrayList<>();
+        for (InsPlyIncome item :insPlyIncomes){
+            BxOtherDetailsExcel bxOtherDetailsExcel = new BxOtherDetailsExcel();
+            BeanUtils.copyProperties(item, bxOtherDetailsExcel);
+            resultList.add(bxOtherDetailsExcel);
+        }
+        String uploadPath = this.uploadPath + "/excel/";
+        Path path = Paths.get(uploadPath);
+        if (!Files.exists(path)) {
+            try {
+                Files.createDirectories(path);
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        String fileName = EasyExcelUtils.downExcel(uploadPath, "保险跟单明细导出", BxOtherDetailsExcel.class, resultList);
+        return HttpResult.ok("",uploadUrl + "excel/" + fileName);
+    }
+
+    /**
+     *
+     * @param insPlyIncomeVo  传参字段
+     * ids  通过ids中的id进行开票分组
+     *
+     * @return
+     */
+    @Override
+    public HttpResult<List<HashMap<String,Object>>> invicdetail(InsPlyIncomeVo insPlyIncomeVo) {
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getIds())){
+            String ids = insPlyIncomeVo.getIds();
+            String[] idArr = ids.split(",");
+            List<HashMap<String,Object>>  result= this.baseMapper.groupByInvoic(idArr);
+            return HttpResult.ok(result);
+        }
+      return HttpResult.ok();
+    }
+
+    /***
+     *
+     * @param insPlyIncomeVo
+     * @param request
+     * @param response
+     * @return   保险非车跟单明细导出
+     */
+    @Override
+    public HttpResult bxNoOtherDetailsExcel(InsPlyIncomeVo insPlyIncomeVo, HttpServletRequest request, HttpServletResponse response) {
+        HashMap<String, Object> params = new HashMap<>();
+        params =this.saveParams(insPlyIncomeVo,params);
+        List<InsPlyIncome> insPlyIncomes = baseMapper.queryNew(params);
+
+        ExportParams exportParams = new ExportParams("保险非车跟单明细导出", null, ExcelType.HSSF);
+        exportParams.setStyle(ExcelStyleUtil.class);
+        List<BxNoOtherDetailsExcel> resultList = new ArrayList<>();
+        for (InsPlyIncome item :insPlyIncomes){
+            BxNoOtherDetailsExcel bxNoOtherDetailsExcel = new BxNoOtherDetailsExcel();
+            BeanUtils.copyProperties(item, bxNoOtherDetailsExcel);
+            resultList.add(bxNoOtherDetailsExcel);
+        }
+        String uploadPath = this.uploadPath + "/excel/";
+        Path path = Paths.get(uploadPath);
+        if (!Files.exists(path)) {
+            try {
+                Files.createDirectories(path);
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        String fileName = EasyExcelUtils.downExcel(uploadPath, "保险非车跟单明细导出", BxNoOtherDetailsExcel.class, resultList);
+        return HttpResult.ok("",uploadUrl + "excel/" + fileName);
+    }
+
     @Override
     @Transactional
     public void updateByEntity(InsPlyIncomeVo insPlyIncomeVo) {
@@ -707,6 +893,7 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
     public void uodateBalance(InsPlyIncomeVo insPlyIncomeVo) {
         InsPlyIncome insPlyIncome = new InsPlyIncome();
         insPlyIncomeVo.setHandlingFeesStatus("1");
+        insPlyIncomeVo.setSettlementTime(LocalDate.now());
         BeanUtils.copyProperties(insPlyIncomeVo, insPlyIncome);
         baseMapper.uopdateByOrderno(insPlyIncome);
 
@@ -802,14 +989,16 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
     @Transactional
     public HttpResult<Object> batchInvoicing(InsPlyIncomeVo insPlyIncomeVo) {
 //      开票时生成  记录 用来合计已经开票数据
-        HashMap<String, Object> params = new HashMap<>();
-        params = this.saveParams(insPlyIncomeVo, params);
-        List<InsPlyIncome> list= this.baseMapper.queryNew(params);
-        for (InsPlyIncome item :  list){
-            item.setHandlingFeesStatus("2");  //已开票
-            item.setInvoicTime(LocalDate.now());
-            item.setInvoicAmount(item.getCommissionFeevalue());
-            baseMapper.updateById(item);
+        String ids = insPlyIncomeVo.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);
+            }
         }
         return HttpResult.ok();
     }
@@ -911,7 +1100,7 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         params =this.saveParams(insPlyIncomeVo,params);
         List<InsPlyIncome> insPlyIncomes = baseMapper.queryNew(params);
 
-        ExportParams exportParams = new ExportParams("保险手续费导出", null, ExcelType.HSSF);
+        ExportParams exportParams = new ExportParams("平台手续费", null, ExcelType.HSSF);
         exportParams.setStyle(ExcelStyleUtil.class);
         List<SettlementFeesExcel> resultList = new ArrayList<>();
         for (InsPlyIncome item :insPlyIncomes){
@@ -928,9 +1117,8 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
                 e.printStackTrace();
             }
         }
-        String fileName = EasyExcelUtils.downExcel(uploadPath, "保险手续费导出", SettlementFeesExcel.class, resultList);
+        String fileName = EasyExcelUtils.downExcel(uploadPath, "平台手续费导出", SettlementFeesExcel.class, resultList);
         return HttpResult.ok("",uploadUrl + "excel/" + fileName);
-
     }
 
     @Override
@@ -939,11 +1127,12 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         params =this.saveParams(insPlyIncomeVo,params);
         List<InsPlyIncome> insPlyIncomes = baseMapper.queryNew(params);
 
-        ExportParams exportParams = new ExportParams("平台手续费", null, ExcelType.HSSF);
+        ExportParams exportParams = new ExportParams("保险手续费", null, ExcelType.HSSF);
         exportParams.setStyle(ExcelStyleUtil.class);
         List<BxSettlementFeesExcel> resultList = new ArrayList<>();
         for (InsPlyIncome item :insPlyIncomes){
             BxSettlementFeesExcel bxSettlementFeesExcel = new BxSettlementFeesExcel();
+            LocalDateTime signDate = item.getSignDate();
             BeanUtils.copyProperties(item, bxSettlementFeesExcel);
             resultList.add(bxSettlementFeesExcel);
         }
@@ -956,7 +1145,7 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
                 e.printStackTrace();
             }
         }
-        String fileName = EasyExcelUtils.downExcel(uploadPath, "平台手续费导出", BxSettlementFeesExcel.class, resultList);
+        String fileName = EasyExcelUtils.downExcel(uploadPath, "保险手续费导出", BxSettlementFeesExcel.class, resultList);
         return HttpResult.ok("",uploadUrl + "excel/" + fileName);
     }
 
@@ -1000,4 +1189,5 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
     }
 
 
+
 }

+ 6 - 0
src/main/java/com/ydtech/modules/fnc/vo/InsPlyIncomeVo.java

@@ -241,4 +241,10 @@ public class InsPlyIncomeVo implements Serializable {
     @ApiModelProperty("已经开票未结算ids")
     private String invoicIds;
 
+    @ApiModelProperty("已经开票未结算ids")
+    private String invoicId;
+
+    @ApiModelProperty("保险公司名称")
+    private String companyName;
+
 }

+ 39 - 0
src/main/java/com/ydtech/modules/ins/model/vo/res/BxNoOtherDetailsExcel.java

@@ -0,0 +1,39 @@
+package com.ydtech.modules.ins.model.vo.res;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+public class BxNoOtherDetailsExcel {
+    @ApiModelProperty("子订单号")
+    @ExcelProperty( "子订单号")
+    private String orderno;
+
+    @ApiModelProperty("保险公司名称")
+    @ExcelProperty( "保险公司名称")
+    private String companyName;
+
+    @ApiModelProperty("合作公司名称")
+    @ExcelProperty( "合作公司名称")
+    private String partnerCompaniesName;
+
+    @ApiModelProperty("非车保单号")
+    @ExcelProperty( "非车保单号")
+    private String noPolicyno;
+
+    @ApiModelProperty("非车险不含税保费")
+    @ExcelProperty( "非车险不含税保费")
+    private BigDecimal noNoTaxPremium;
+
+    @ApiModelProperty("跟单金额")
+    @ExcelProperty( "跟单金额")
+    private BigDecimal otherFeevalue;
+
+    @ApiModelProperty("跟单费比例")
+    @ExcelProperty( "跟单费比例")
+    private BigDecimal otherFeerate;
+}

+ 71 - 0
src/main/java/com/ydtech/modules/ins/model/vo/res/BxOtherDetailsExcel.java

@@ -0,0 +1,71 @@
+package com.ydtech.modules.ins.model.vo.res;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+public class BxOtherDetailsExcel {
+
+    @ApiModelProperty("子订单号")
+    @ExcelProperty( "子订单号")
+    private String orderno;
+
+    @ApiModelProperty("保险公司名称")
+    @ExcelProperty( "保险公司名称")
+    private String companyName;
+
+    @ApiModelProperty("合作公司名称")
+    @ExcelProperty( "合作公司名称")
+    private String partnerCompaniesName;
+
+    @ApiModelProperty("交强保单号")
+    @ExcelProperty( "交强保单号")
+    private String policyno;
+
+    @ApiModelProperty("商业保单号")
+    @ExcelProperty( "商业保单号")
+    private String syPolicyno;
+
+    @ApiModelProperty("交强保费")
+    @ExcelProperty( "交强保费")
+    private BigDecimal jqPremium;
+
+    @ApiModelProperty("商业保费")
+    @ExcelProperty( "商业保费")
+    private BigDecimal syPremium;
+
+    @ApiModelProperty("交强不含税保费")
+    @ExcelProperty( "交强不含税保费")
+    private BigDecimal jqNoTaxPremium;
+
+    @ApiModelProperty("商业不含税保费")
+    @ExcelProperty( "商业不含税保费")
+    private BigDecimal syNoTaxPremium;
+
+    @ApiModelProperty("跟单费金额")
+    @ExcelProperty( "跟单费金额")
+    private BigDecimal otherFeevalue;
+
+    @ApiModelProperty("跟单费比例")
+    @ExcelProperty( "跟单费比例")
+    private BigDecimal otherFeerate;
+
+    @ApiModelProperty("交强跟单比例")
+    @ExcelProperty( "交强跟单比例")
+    private BigDecimal jqOtherCostsProportion;
+
+    @ApiModelProperty("商业跟单比例")
+    @ExcelProperty( "商业跟单比例")
+    private BigDecimal syOtherCostsProportion;
+
+    @ApiModelProperty("交强跟单金额")
+    @ExcelProperty( "交强跟单金额")
+    private BigDecimal jqOtherCostsPremium;
+
+    @ApiModelProperty("商业跟单金额")
+    @ExcelProperty( "商业跟单金额")
+    private BigDecimal syOtherCostsPremium;
+}

+ 4 - 3
src/main/java/com/ydtech/modules/ins/model/vo/res/BxSettlementFeesExcel.java

@@ -16,6 +16,7 @@ import java.io.Serializable;
 import java.math.BigDecimal;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
+import java.util.Date;
 
 @Data
 public class BxSettlementFeesExcel implements Serializable {
@@ -26,7 +27,7 @@ public class BxSettlementFeesExcel implements Serializable {
     @ApiModelProperty("签单日期")
     @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
     @ExcelProperty( "签单日期")
-    private LocalDate signDate;
+    private Date signDate;
 
 
     @ApiModelProperty("车牌号")
@@ -105,13 +106,13 @@ public class BxSettlementFeesExcel implements Serializable {
     @ExcelProperty( "创建日期")
     @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
     @ApiModelProperty(value = "创建日期")
-    private LocalDate createTime;
+    private Date createTime;
 
 
     @ExcelProperty( "结算日期")
     @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
     @ApiModelProperty(value = "结算日期")
-    private LocalDate settlementTime;
+    private Date settlementTime;
 
 
     @ApiModelProperty("结算人")

+ 18 - 0
src/main/java/com/ydtech/modules/inv/model/dto/InsBxNoPlyIncomeExcelDto.java

@@ -0,0 +1,18 @@
+package com.ydtech.modules.inv.model.dto;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import lombok.Data;
+
+@Data
+public class InsBxNoPlyIncomeExcelDto {
+    /**
+     * 车牌号
+     */
+    @Excel(name = "车牌号")
+    private String licenseno;
+    /**
+     * 非车保单号
+     */
+    @Excel(name = "非车保单号")
+    private String noPolicyno;
+}

+ 25 - 0
src/main/java/com/ydtech/modules/inv/model/dto/InsBxPlyIncomeExcelDto.java

@@ -0,0 +1,25 @@
+package com.ydtech.modules.inv.model.dto;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import lombok.Data;
+
+@Data
+public class InsBxPlyIncomeExcelDto {
+    /**
+     * 车牌号
+     */
+    @Excel(name = "车牌号")
+    private String licenseno;
+    /**
+     * 交强保单号
+     */
+    @Excel(name = "交强保单号")
+    private String policyno;
+
+    /**
+     * 商业保单号
+     */
+    @Excel(name = "商业保单号")
+    private String syPolicyno;
+
+}

+ 84 - 18
src/main/resources/mapper/modules/fnc/InsPlyIncomeMapper.xml

@@ -106,6 +106,7 @@
                 a.sy_supervise_costs_proportion  as  "sySuperviseCostsProportion",
                 a.no_supervise_costs_premiums  as  "noSuperviseCostsPremiums",
                 a.no_supervise_costs_proportion  as  "noSuperviseCostsProportion",
+                a.partner_companies_id  as  "partnerCompaniesId",
                 a.jq_premium  as  "jqPremium",
                 a.sy_premium  as  "syPremium",
                 a.no_premium  as  "noPremium",
@@ -125,6 +126,8 @@
                 a.jq_other_costs_premium  as  "jqOtherCostsPremium",
                 a.sy_other_costs_premium  as  "syOtherCostsPremium",
                 a.no_other_costs_premium  as  "noOtherCostsPremium",
+                a.partner_companies_name  as  "partnerCompaniesName",
+                a.company_name  as  "companyName",
                 a.receivable_amount  as  "receivableAmount",
                 a.invoic_time  as  "invoicTime",
                 a.user_id  as  "userId",
@@ -133,9 +136,12 @@
 
     <select id="queryNew"  resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
             select
+                pa.agreement_name  as "agreementName",
+                su.name  as "userName",
                 <include refid="income_com"/>
                 from  ins_ply_income a
                 LEFT  JOIN  ptl_agreement  pa  on  a.agreement_id  = pa.id
+                LEFT  JOIN  sys_user   su  on su.id=a.user_id
             <where>
                 <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')
@@ -155,6 +161,9 @@
                 <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}
@@ -170,11 +179,9 @@
                 <if test="isOther !=null  and  isOther  !=''">
                     and a.is_not_documentary   =#{isOther}
                 </if>
-                <if test="licenseno != null and licenseno != ''  and licenseno.length > 0">
-                    and a.licenseno in
-                    <foreach collection="licenseno" item="item" open="(" separator="," close=")">
-                        #{item}
-                    </foreach>
+                <if test="licenseno != null and licenseno != ''">
+                    and a.licenseno  =#{licenseno}
+
                 </if>
 
                 <if test="policyno != null and policyno != ''  and policyno.length > 0">
@@ -348,6 +355,36 @@
             <if test="noPolicyno !=null  and  noPolicyno !=''">
                AND a.no_policyno=#{noPolicyno}
             </if>
+            <if test="isOther !=null  and  isOther  !=''">
+                and a.is_not_documentary   =#{isOther}
+            </if>
+        </where>
+    </select>
+
+    <select id="findByBxLicenseno" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
+       select
+        <include refid="income_com"/>
+        from  ins_ply_income a
+        <where>
+            1=1
+            <if test="licenseno !=null  and  licenseno !=''">
+                AND  a.licenseno=#{licenseno}
+            </if>
+            <if test="policyno !=null  and  policyno !=''">
+              AND  a.policyno=#{policyno}
+            </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="isOther !=null  and  isOther  !=''">
+                and a.is_not_documentary   =#{isOther}
+            </if>
+            <if test="isNotCar !=null  and  isNotCar  !=''">
+                and a.is_not_car =#{isNotCar}
+            </if>
         </where>
     </select>
 
@@ -475,7 +512,9 @@
                 <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="signDateEnd !=null  and  signDateEnd!='' and  signDateStart !=null and signDateStart !=''">
                     and a.signdate   between #{signDateStart} and #{signDateEnd}
                 </if>
@@ -498,11 +537,8 @@
                 <if test="isOther !=null  and  isOther  !=''">
                     and a.is_not_documentary   =#{isOther}
                 </if>
-                <if test="licenseno != null and licenseno != ''  and licenseno.length > 0">
-                    and a.licenseno in
-                    <foreach collection="licenseno" item="item" open="(" separator="," close=")">
-                        #{item}
-                    </foreach>
+                <if test="licenseno != null and licenseno != ''  ">
+                    and a.licenseno  =#{licenseno}
                 </if>
 
                 <if test="policyno != null and policyno != ''  and policyno.length > 0">
@@ -701,14 +737,14 @@
         select
         a.agreement_id AS "agreementId",
         MAX(a.partner_companies_name) AS "partnerCompaniesName",
-        MAX(ec.name) AS "companyName",
+        MAX( a.company_name ) AS "companyName",
         SUM(a.commission_feevalue) AS "commissionFeevalue",
         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",
-        GROUP_CONCAT(a.id) AS "ids"
+        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"
         from  ins_ply_income a
-        LEFT JOIN   esm_ins_company  ec  on ec.id= a.company_id
         LEFT JOIN   ptl_agreement  pa  on pa.id= a.agreement_id
         <where>
             1=1
@@ -740,21 +776,20 @@
     <select id="allOtherAmount" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
         SELECT
             a.company_id AS "companyId",
-            MAX( b.name ) AS "companyName",
+            MAX( a.company_name ) AS "companyName",
             MAX( a.partner_companies_name) as "partnerCompaniesName",
             IF(MAX( c.unsettledAmount ) IS NULL , sum( a.other_feevalue ),  MAX( c.unsettledAmount ) ) AS "noInvoicCommissionFeevalue",
             IF(MAX(c.invoicIds) IS NULL ,  GROUP_CONCAT(a.id),MAX(c.invoicIds) ) as  "incomeIds",
-            MAX(c.settleMentAmount) -MAX( f.settleMentAmount )  AS "invoicCommissionFeevalue",
+            MAX(COALESCE(c.settleMentAmount, 0) - COALESCE(f.settleMentAmount, 0)) AS "invoicCommissionFeevalue",
             MAX(f.settleMentAmount) as "settleMentAmount",
             GROUP_CONCAT(a.id) as "ids",
             IF(MAX( f.unSettledAmount ) is null ,MAX( c.settleMentAmount ) ,MAX( f.unSettledAmount )) AS "unSettledAmount",
             sum( a.other_feevalue ) AS "otherFeevalue"
         FROM
             ins_ply_income a
-                left join esm_ins_company b ON a.company_id = b.id
                 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 WHERE a.settlement_status = '1' GROUP BY company_id ) c ON c.companyId = a.company_id
-                LEFT JOIN ( SELECT a.company_id AS "companyId", MIN( unsettled_amount ) AS "unSettledAmount",sum( settlement_amount ) AS "settleMentAmount" FROM settlement_documentary_fees a WHERE a.settlement_status = '2' GROUP BY company_id ) f ON f.companyId = a.company_id
+                LEFT JOIN ( SELECT a.company_id AS "companyId", MIN( a.unsettled_amount ) AS "unSettledAmount",sum( settlement_amount ) AS "settleMentAmount" FROM settlement_documentary_fees a WHERE a.settlement_status = '2' GROUP BY company_id ) f ON f.companyId = a.company_id
        <where>
            1=1
            <if test="agreementType !=null  and agreementType!='' ">
@@ -783,5 +818,36 @@
             a.company_id
     </select>
 
+    <select id="getById" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
+        select
+        pa.agreement_name  as "agreementName",
+        su.name  as "userName",
+        <include refid="income_com"/>
+        from  ins_ply_income a
+        LEFT  JOIN  ptl_agreement  pa  on  a.agreement_id  = pa.id
+        LEFT  JOIN  sys_user   su  on su.id=a.user_id
+        <where>
+            <if test="id !=null and id !=''">
+                a.id=#{id}
+            </if>
+        </where>
+    </select>
+    <select id="groupByInvoic" resultType="java.util.HashMap">
+        select
+        sum(a.commission_feevalue) as "invoicCommissionFeevalue",
+        MAX(invoic_id) as "invoicId",
+        MAX(invoic_time) as "invoicTime",
+        GROUP_CONCAT(a.id) as  "ids"
+        from  ins_ply_income a
+        LEFT  JOIN  ptl_agreement  pa  on  a.agreement_id  = pa.id
+        LEFT  JOIN  sys_user   su  on su.id=a.user_id
+        <where>
+            a.id IN
+            <foreach item="item" index="index" collection="idArr" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </where>
+        group  by  a.invoic_id
+    </select>
 
 </mapper>

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

@@ -105,8 +105,7 @@
     </select>
     <select id="getByAgreementIdNew" resultType="com.ydtech.modules.protocol.entity.po.PtlAgreement">
         select
-            partner_companies_id  as  "partnercompaniesId",
-            association_companies_id  as  "associationCompaniesId"
+           *
         from  ptl_agreement
         <where>
             <if test="agreementId!=null  and  agreementId !=''">

BIN
src/main/resources/template/SettlementTemplate.xlsx