Browse Source

1. 应收表导出

785834757 8 months ago
parent
commit
94d7944dbb

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

@@ -10,6 +10,8 @@ import com.ydtech.modules.fnc.dto.InsuranceHandlingSettlementMonthDto;
 import com.ydtech.modules.fnc.dto.PlatformSettlementRecordDto;
 import com.ydtech.modules.fnc.entity.InsPlyIncome;
 import com.ydtech.modules.fnc.vo.*;
+import com.ydtech.modules.order.entity.vo.AuditExportQueryVo;
+import com.ydtech.modules.order.entity.vo.ReceivableExportVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
@@ -237,4 +239,6 @@ public interface InsPlyIncomeMapper extends BaseMapper<InsPlyIncome> {
      *  @Description:  查询签单日期为空的结算日期
      */
     List<InsPlyIncome> findListByDate(@Param("benginDate") String benginDate, @Param("endDate") String endDate);
+
+    List<ReceivableExportVo> getReceivableExportList(@Param("params")AuditExportQueryVo auditExportQueryVo);
 }

+ 18 - 0
src/main/java/com/ydtech/modules/order/controller/ExcelExportController.java

@@ -90,4 +90,22 @@ public class ExcelExportController extends BaseController {
         }
     }
 
+    @PostMapping("/receivableExcelExport")
+    @ApiOperation("应收模版导出")
+    public HttpResult<Object> receivableExcelExport(@RequestBody AuditExportQueryVo auditExportQueryVo){
+        List<ReceivableExportVo> receivableExportList = excelExportService.getReceivableExportList(auditExportQueryVo);
+        ExcelUtils<ReceivableExportVo> excelUtils = new ExcelUtils<>(ReceivableExportVo.class);
+        //读取模版文件
+//        String templatePath = ResourceLoader.class.getClassLoader().getResource("template/finance_audit_detail.xlsx").getPath();
+        String fileName = "应收" + System.currentTimeMillis() + ".xlsx";
+        String saveFilePath = uploadPath+"//" + EXCEL_PATH + fileName;
+        String resultPath = UPLOAD_PATH + fileName;
+        String sheetName = "应收表";
+        if(excelUtils.writeExcel(saveFilePath,sheetName, receivableExportList)){
+            return HttpResult.ok(resultPath);
+        }else{
+            return HttpResult.error("导出应收表失败");
+        }
+    }
+
 }

+ 5 - 0
src/main/java/com/ydtech/modules/order/service/ExcelExportService.java

@@ -28,4 +28,9 @@ public interface ExcelExportService {
      * @return
      */
     List<AuditExportVo>  getAuditExportList(AuditExportQueryVo auditExportQueryVo);
+
+    /**
+     * 获取应收数据列表
+     */
+    List<ReceivableExportVo> getReceivableExportList(AuditExportQueryVo auditExportQueryVo);
 }

+ 31 - 0
src/main/java/com/ydtech/modules/order/service/impl/ExcelExportServiceImpl.java

@@ -1,8 +1,11 @@
 package com.ydtech.modules.order.service.impl;
 
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.ydtech.constants.enums.dict.BusinessPropertyEnum;
 import com.ydtech.constants.enums.dict.BusinessSegmentsSZEnum;
 import com.ydtech.exception.SystemException;
+import com.ydtech.modules.fnc.dao.InsPlyIncomeMapper;
 import com.ydtech.modules.order.dao.InsOrdersMapper;
 import com.ydtech.modules.order.entity.vo.*;
 import com.ydtech.modules.order.service.ExcelExportService;
@@ -13,6 +16,7 @@ import org.springframework.stereotype.Service;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.util.List;
+import java.util.Objects;
 
 @Service
 public class ExcelExportServiceImpl implements ExcelExportService {
@@ -20,6 +24,9 @@ public class ExcelExportServiceImpl implements ExcelExportService {
     @Autowired
     private InsOrdersMapper insOrdersMapper;
 
+    @Autowired
+    private InsPlyIncomeMapper insPlyIncomeMapper;
+
     /**
      * 获取车险业务明细
      * @param userId
@@ -106,4 +113,28 @@ public class ExcelExportServiceImpl implements ExcelExportService {
         return auditExportList;
     }
 
+    @Override
+    public List<ReceivableExportVo> getReceivableExportList(AuditExportQueryVo auditExportQueryVo) {
+        if(auditExportQueryVo.getSignStartDate() == null || auditExportQueryVo.getSignEndDate() == null) {
+            LocalDateTime now = LocalDateTime.now();
+            LocalDateTime halfYearAgo = now.minusMonths(6);
+            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        }
+        List<ReceivableExportVo> receivableExportList = insPlyIncomeMapper.getReceivableExportList(auditExportQueryVo);
+        receivableExportList.forEach(item->{
+            JSONArray crossInsrances = JSONArray.parseArray(item.getCrossInsurance());
+            if(Objects.nonNull(item.getCrossInsurance())){
+                crossInsrances = JSONArray.parseArray(item.getCrossInsurance());
+            }
+//            JSONArray crossInsruance = item.getCrossInsurance();
+            if (Objects.nonNull(crossInsrances)){
+                if(crossInsrances.size()>0){
+                    JSONObject cross = crossInsrances.getJSONObject(0);
+                    item.setJypolicyno(cross.getString("application"));
+                }
+            }
+        });
+        return receivableExportList;
+    }
+
 }

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

@@ -3609,4 +3609,75 @@
         AND iac.createtime <![CDATA[ <= ]]> #{endDate}
         and ipi.id IS NOT NULL
     </select>
+
+    <select id="getReceivableExportList" resultType="com.ydtech.modules.order.entity.vo.ReceivableExportVo">
+        SELECT
+            iac.id,
+            io.userid,
+            io.licenseno,
+            io.ins_company,
+            io.product,
+            iac.jqpolicyno,
+            iac.sypolicyno,
+            iac.cross_insurance,
+            iac.jqpremium,
+            iac.sypremium,
+            iac.jypremium,
+            iac.taxamount,
+            iac.agreement_id,
+            iac.docking_person,
+            su.name as operator_name,
+            (ifon.jq_costs_export_proportion + ifon.jq_export_other_costs_proportion) as jq_export_proportion,
+            (ifon.sy_costs_export_proportion + ifon.sy_export_other_costs_proportion) as sy_export_proportion,
+            (ifon.no_costs_export_proportion + ifon.no_export_other_costs_proportion) as jy_export_proportion,
+            (ifon.jq_export_supervise_costs_premiums + ifon.sy_export_supervise_costs_premiums + ifon.no_export_supervise_costs_premiums +
+             ifon.jq_export_other_costs_premiums + ifon.sy_export_other_costs_premiums + ifon.no_export_other_costs_premiums) as settlement,
+            ifon.jq_supervise_costs_proportion,
+            ifon.jq_other_costs_proportion,
+            ifon.jq_supervise_costs_premiums,
+            ifon.jq_other_costs_premiums,
+            ifon.sy_supervise_costs_proportion,
+            ifon.sy_other_costs_proportion,
+            ifon.sy_supervise_costs_premiums,
+            ifon.sy_other_costs_premiums,
+            ifon.no_supervise_costs_proportion,
+            ifon.no_other_costs_proportion,
+            ifon.no_supervise_costs_premiums,
+            ifon.no_other_costs_premiums,
+            case
+                WHEN io.entry_status = 3 THEN '是'
+                ELSE '否'
+            END as is_external,
+            ipi.partner_companies_name,
+            ipi.insured_name,
+            iac.signing_time,
+            ipi.receivable_amount as receivable,
+            case
+                WHEN pa.agreement_type = 2 THEN '保险公司'
+                ELSE '平台公司'
+            END as agreement_type
+
+
+        FROM
+            ins_orders io
+                left join ins_area_company iac ON
+                io.orderno =  iac.orderno
+                left join sys_user su ON
+                io.operatorid = su.id
+                left join ins_fee_order_new ifon on
+                ifon.ins_order_no = iac.id
+                left join ins_ply_income ipi on
+                ipi.orderno = iac.id
+                left join ptl_agreement pa on
+                iac.agreement_id = pa.id
+                left join ins_fee_audit ifa on ifa.ins_order_no = iac.id
+        WHERE
+            io.orderstatus = 3
+          and
+            iac.orderstatus = 3
+            and
+            ifa.auditstatus = 1
+          AND iac.createtime BETWEEN #{params.signStartDate}
+            AND #{params.signEndDate};
+    </select>
 </mapper>