|
|
@@ -0,0 +1,631 @@
|
|
|
+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;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+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;
|
|
|
+
|
|
|
+@Service
|
|
|
+public class ImportAsyncServiceImpl extends ServiceImpl<ImportAsyncMapper, ImportResult> implements ImportAsyncService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private InsPlyIncomeMapper insPlyIncomeMapper;
|
|
|
+ @Autowired
|
|
|
+ private InsUploadFilesService insUploadFilesService;
|
|
|
+ @Value("${upload.file.path}")
|
|
|
+ private String uploadFilePath;
|
|
|
+ @Value("${upload.file.path}")
|
|
|
+ private String uploadPath;
|
|
|
+ @Value("${upload.file.url}")
|
|
|
+ private String uploadUrl;
|
|
|
+
|
|
|
+ @Async
|
|
|
+ @Override
|
|
|
+ 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;
|
|
|
+
|
|
|
+ // 创建任务
|
|
|
+ ImportResult importResult = new ImportResult();
|
|
|
+ importResult.setId(taskId);
|
|
|
+ importResult.setStatus("ready");
|
|
|
+ importResult.setCreateTime(LocalDateTime.now());
|
|
|
+ importResult.setCreatedAt(LocalDateTime.now());
|
|
|
+ baseMapper.insert(importResult);
|
|
|
+
|
|
|
+ if (!CollectionUtils.isEmpty(dtoList)) {
|
|
|
+ for (InsBxPlyIncomeExcelDto excelItem : dtoList) {
|
|
|
+ String reason = "";
|
|
|
+ i = i + 1;
|
|
|
+ params.clear();
|
|
|
+ if (StringUtils.isNotEmpty(excelItem.getLicenseno())) {
|
|
|
+ String licenseno = excelItem.getLicenseno();//车牌号
|
|
|
+ params.put("licenseno", licenseno);
|
|
|
+ InsPlyIncome byBxLicenseno = insPlyIncomeMapper.findByBxLicenseno(params);
|
|
|
+ if (ObjectUtils.isEmpty(byBxLicenseno)) {
|
|
|
+ reason = "该数据车牌号有问题";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(excelItem.getPolicyno())) {
|
|
|
+ String policyno = excelItem.getPolicyno(); //交强保单号
|
|
|
+ params.put("policyno", policyno);
|
|
|
+ InsPlyIncome byBxLicenseno = insPlyIncomeMapper.findByBxLicenseno(params);
|
|
|
+ if (ObjectUtils.isEmpty(byBxLicenseno)) {
|
|
|
+ reason = "该数据交强保单号有问题";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(excelItem.getSyPolicyno())) {
|
|
|
+ String syPolicyno = excelItem.getSyPolicyno(); //商业保单号
|
|
|
+ params.put("syPolicyno", syPolicyno);
|
|
|
+ InsPlyIncome byBxLicenseno = insPlyIncomeMapper.findByBxLicenseno(params);
|
|
|
+ if (ObjectUtils.isEmpty(byBxLicenseno)) {
|
|
|
+ reason = "该数据商业保单号有问题";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (excelItem.getJqSuperviseCostsPremiums() != null && excelItem.getJqSuperviseCostsPremiums().compareTo(BigDecimal.ZERO) != 0) {
|
|
|
+ params.put("jqSuperviseCostsPremiums", excelItem.getJqSuperviseCostsPremiums());
|
|
|
+ InsPlyIncome byBxLicenseno = insPlyIncomeMapper.findByBxLicenseno(params);
|
|
|
+ if (ObjectUtils.isEmpty(byBxLicenseno)) {
|
|
|
+ reason = "该数据交强手续费金额有问题";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (excelItem.getJqSuperviseCostsProportion() != null && excelItem.getJqSuperviseCostsProportion().compareTo(BigDecimal.ZERO) != 0) {
|
|
|
+ params.put("jqSuperviseCostsProportion", excelItem.getJqSuperviseCostsProportion());
|
|
|
+ InsPlyIncome byBxLicenseno = insPlyIncomeMapper.findByBxLicenseno(params);
|
|
|
+ if (ObjectUtils.isEmpty(byBxLicenseno)) {
|
|
|
+ reason = "该数据交强手续费比例有问题";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (excelItem.getSySuperviseCostsProportion() != null && excelItem.getSySuperviseCostsProportion().compareTo(BigDecimal.ZERO) != 0) {
|
|
|
+ params.put("sySuperviseCostsProportion", excelItem.getSySuperviseCostsProportion());
|
|
|
+ InsPlyIncome byBxLicenseno = insPlyIncomeMapper.findByBxLicenseno(params);
|
|
|
+ if (ObjectUtils.isEmpty(byBxLicenseno)) {
|
|
|
+ reason = "该数据商业手续费比例有问题";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (excelItem.getSySuperviseCostsPremiums() != null && excelItem.getSySuperviseCostsPremiums().compareTo(BigDecimal.ZERO) != 0) {
|
|
|
+ params.put("sySuperviseCostsPremiums", excelItem.getSySuperviseCostsPremiums());
|
|
|
+ InsPlyIncome byBxLicenseno = insPlyIncomeMapper.findByBxLicenseno(params);
|
|
|
+ if (ObjectUtils.isEmpty(byBxLicenseno)) {
|
|
|
+ reason = "该数据商业手续费金额有问题";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (excelItem.getJqPremium() != null && excelItem.getJqPremium().compareTo(BigDecimal.ZERO) != 0) {
|
|
|
+ params.put("jqPremium", excelItem.getJqPremium());
|
|
|
+ InsPlyIncome byBxLicenseno = insPlyIncomeMapper.findByBxLicenseno(params);
|
|
|
+ if (ObjectUtils.isEmpty(byBxLicenseno)) {
|
|
|
+ reason = "该数据交强保费有问题";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (excelItem.getSyPremium() != null && excelItem.getSyPremium().compareTo(BigDecimal.ZERO) != 0) {
|
|
|
+ params.put("syPremium", excelItem.getSyPremium());
|
|
|
+ InsPlyIncome byBxLicenseno = insPlyIncomeMapper.findByBxLicenseno(params);
|
|
|
+ if (ObjectUtils.isEmpty(byBxLicenseno)) {
|
|
|
+ reason = "该数据商业保费有问题";
|
|
|
+ }
|
|
|
+ }
|
|
|
+// 只查手续费
|
|
|
+ params.put("isOther", "0");
|
|
|
+ params.put("isNotCar", isNotCar);
|
|
|
+ InsPlyIncome insPlyIncome = insPlyIncomeMapper.findByBxLicenseno(params);
|
|
|
+ if (ObjectUtils.isNotEmpty(insPlyIncome) && open) {
|
|
|
+ open = false;
|
|
|
+ companyId = insPlyIncome.getCompanyId(); // 保险公司id
|
|
|
+ partnerCompaniesId = insPlyIncome.getPartnerCompaniesId(); //合作公司id
|
|
|
+ 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()); //添加总手续费
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ InsImportResult insImportResult = new InsImportResult();
|
|
|
+ if (StringUtils.isNotEmpty(excelItem.getLicenseno())) {
|
|
|
+ insImportResult.setLicenseno(excelItem.getLicenseno());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(excelItem.getPolicyno())) {
|
|
|
+ insImportResult.setPolicyno(excelItem.getPolicyno());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(excelItem.getSyPolicyno())) {
|
|
|
+ insImportResult.setSyPolicyno(excelItem.getSyPolicyno());
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotEmpty(reason)){
|
|
|
+ insImportResult.setReason(reason);
|
|
|
+ }
|
|
|
+ insImportResultsExcel.add(insImportResult);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(strBuilder.length() >0){
|
|
|
+ ids = strBuilder.deleteCharAt(strBuilder.length() - 1).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ String uploadPath = this.uploadFilePath + "/excel/" + taskId + "/";
|
|
|
+ File folder = new File(uploadPath);
|
|
|
+ // 路劲不存在创建目录
|
|
|
+ if (!folder.isDirectory()) {
|
|
|
+ folder.mkdirs();
|
|
|
+ }
|
|
|
+
|
|
|
+ String fileName = EasyExcelUtils.downExcel(uploadPath, "保险跟单明细导出", InsImportResult.class, insImportResultsExcel);
|
|
|
+
|
|
|
+ ImportResult endTask = new ImportResult();
|
|
|
+ endTask.setTotalAmount(totalAmount);
|
|
|
+ endTask.setId(taskId);
|
|
|
+ endTask.setCompletedAt(LocalDateTime.now());
|
|
|
+ endTask.setStatus("complete");
|
|
|
+ if(!CollectionUtils.isEmpty(insImportResultsExcel)){
|
|
|
+ endTask.setUploadUrl("upload/excel/" + taskId + "/" + fileName);
|
|
|
+ }
|
|
|
+ endTask.setCompanyId(companyId);
|
|
|
+ endTask.setAgreementId(agreementId);
|
|
|
+ endTask.setPartnerCompaniesId(partnerCompaniesId);
|
|
|
+ endTask.setIds(ids);
|
|
|
+ endTask.setHandStatus("0");
|
|
|
+ baseMapper.updateById(endTask);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HttpResult<BasePageResult<ImportResult>> selectAll(ImportResultVo importResultVo) {
|
|
|
+ try{
|
|
|
+ HashMap<String, Object> params = new HashMap<>();
|
|
|
+ PageInfo<List<InsPlyIncome>> pageHelper = null;
|
|
|
+ PageHelper.startPage(importResultVo.getPageNum(),importResultVo.getPageSize());
|
|
|
+ params.put("pageNum",importResultVo.getPageNum());
|
|
|
+ params.put("pageSize",importResultVo.getPageSize());
|
|
|
+ if(StringUtils.isNotEmpty(importResultVo.getHandStatus())){
|
|
|
+ params.put("handStatus",importResultVo.getHandStatus());
|
|
|
+ }
|
|
|
+ List<ImportResult> list= this.baseMapper.queryNew(params);
|
|
|
+
|
|
|
+ pageHelper=new PageInfo(list);
|
|
|
+ BasePageResult<ImportResult> pageResult=new BasePageResult<ImportResult>(importResultVo.getPageNum(), importResultVo.getPageSize(), pageHelper.getTotal(), pageHelper.getPages(), list);
|
|
|
+ return HttpResult.ok(pageResult);
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ return HttpResult.error("查询异常");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void bxOtherImportData(List<InsBxOtherExcelDto> 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;
|
|
|
+
|
|
|
+ // 创建任务
|
|
|
+ ImportResult importResult = new ImportResult();
|
|
|
+ importResult.setId(taskId);
|
|
|
+ importResult.setStatus("ready");
|
|
|
+ importResult.setCreateTime(LocalDateTime.now());
|
|
|
+ importResult.setCreatedAt(LocalDateTime.now());
|
|
|
+ baseMapper.insert(importResult);
|
|
|
+
|
|
|
+ if (!CollectionUtils.isEmpty(dtoList)) {
|
|
|
+ for (InsBxOtherExcelDto excelItem : dtoList) {
|
|
|
+ String reason = "";
|
|
|
+ i = i + 1;
|
|
|
+ params.clear();
|
|
|
+ if (StringUtils.isNotEmpty(excelItem.getLicenseno())) {
|
|
|
+ String licenseno = excelItem.getLicenseno();//车牌号
|
|
|
+ params.put("licenseno", licenseno);
|
|
|
+ InsPlyIncome byBxLicenseno = insPlyIncomeMapper.findByBxLicenseno(params);
|
|
|
+ if (ObjectUtils.isEmpty(byBxLicenseno)) {
|
|
|
+ reason = "该数据车牌号有问题";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(excelItem.getPolicyno())) {
|
|
|
+ String policyno = excelItem.getPolicyno(); //交强保单号
|
|
|
+ params.put("policyno", policyno);
|
|
|
+ InsPlyIncome byBxLicenseno = insPlyIncomeMapper.findByBxLicenseno(params);
|
|
|
+ if (ObjectUtils.isEmpty(byBxLicenseno)) {
|
|
|
+ reason = "该数据交强保单号有问题";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(excelItem.getSyPolicyno())) {
|
|
|
+ String syPolicyno = excelItem.getSyPolicyno(); //商业保单号
|
|
|
+ params.put("syPolicyno", syPolicyno);
|
|
|
+ InsPlyIncome byBxLicenseno = insPlyIncomeMapper.findByBxLicenseno(params);
|
|
|
+ if (ObjectUtils.isEmpty(byBxLicenseno)) {
|
|
|
+ reason = "该数据商业保单号有问题";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (excelItem.getJqOtherCostsProportion()!=null && excelItem.getJqOtherCostsProportion().compareTo(BigDecimal.ZERO) != 0) {
|
|
|
+ BigDecimal jqOtherCostsProportion = excelItem.getJqOtherCostsProportion();//商业保单号
|
|
|
+ params.put("jqOtherCostsProportion", jqOtherCostsProportion);
|
|
|
+ InsPlyIncome byBxLicenseno = insPlyIncomeMapper.findByBxLicenseno(params);
|
|
|
+ if (ObjectUtils.isEmpty(byBxLicenseno)) {
|
|
|
+ reason = "该数据交强跟单比例有问题";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (excelItem.getSyOtherCostsProportion()!=null && excelItem.getSyOtherCostsProportion().compareTo(BigDecimal.ZERO) != 0) {
|
|
|
+ BigDecimal syOtherCostsProportion = excelItem.getSyOtherCostsProportion();//商业保单号
|
|
|
+ params.put("syOtherCostsProportion", syOtherCostsProportion);
|
|
|
+ InsPlyIncome byBxLicenseno = insPlyIncomeMapper.findByBxLicenseno(params);
|
|
|
+ if (ObjectUtils.isEmpty(byBxLicenseno)) {
|
|
|
+ reason = "该数据商业跟单比例有问题";
|
|
|
+ }
|
|
|
+ }
|
|
|
+// 只查手续费
|
|
|
+ params.put("isOther", "1");
|
|
|
+ params.put("isNotCar", isNotCar);
|
|
|
+ InsPlyIncome insPlyIncome = insPlyIncomeMapper.findByBxLicenseno(params);
|
|
|
+ if (ObjectUtils.isNotEmpty(insPlyIncome) && open) {
|
|
|
+ open = false;
|
|
|
+ companyId = insPlyIncome.getCompanyId(); // 保险公司id
|
|
|
+ partnerCompaniesId = insPlyIncome.getPartnerCompaniesId(); //合作公司id
|
|
|
+ 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()); //添加总手续费
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ InsImportResult insImportResult = new InsImportResult();
|
|
|
+ if (StringUtils.isNotEmpty(excelItem.getLicenseno())) {
|
|
|
+ insImportResult.setLicenseno(excelItem.getLicenseno());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(excelItem.getPolicyno())) {
|
|
|
+ insImportResult.setPolicyno(excelItem.getPolicyno());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(excelItem.getSyPolicyno())) {
|
|
|
+ insImportResult.setSyPolicyno(excelItem.getSyPolicyno());
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotEmpty(reason)){
|
|
|
+ insImportResult.setReason(reason);
|
|
|
+ }
|
|
|
+ insImportResultsExcel.add(insImportResult);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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)) {
|
|
|
+ try {
|
|
|
+ Files.createDirectories(path);
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String fileName = EasyExcelUtils.downExcel(uploadPath, "保险对账问题文件", InsImportResult.class, insImportResultsExcel);
|
|
|
+ String url=uploadUrl + "excel/" + fileName;
|
|
|
+
|
|
|
+ ImportResult endTask = new ImportResult();
|
|
|
+ endTask.setTotalAmount(totalAmount);
|
|
|
+ endTask.setId(taskId);
|
|
|
+ endTask.setCompletedAt(LocalDateTime.now());
|
|
|
+ endTask.setStatus("complete");
|
|
|
+ if(!CollectionUtils.isEmpty(insImportResultsExcel)){
|
|
|
+ endTask.setUploadUrl("upload/excel/" + taskId + "/" + fileName);
|
|
|
+ }
|
|
|
+ endTask.setCompanyId(companyId);
|
|
|
+ endTask.setAgreementId(agreementId);
|
|
|
+ endTask.setPartnerCompaniesId(partnerCompaniesId);
|
|
|
+ endTask.setHandStatus("2");
|
|
|
+ endTask.setIds(ids);
|
|
|
+ baseMapper.updateById(endTask);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void bxNoOtherImportData(List<InsNoBxOtherExcelDto> 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;
|
|
|
+
|
|
|
+ // 创建任务
|
|
|
+ ImportResult importResult = new ImportResult();
|
|
|
+ importResult.setId(taskId);
|
|
|
+ importResult.setStatus("ready");
|
|
|
+ importResult.setCreateTime(LocalDateTime.now());
|
|
|
+ importResult.setCreatedAt(LocalDateTime.now());
|
|
|
+ baseMapper.insert(importResult);
|
|
|
+
|
|
|
+ if (!CollectionUtils.isEmpty(dtoList)) {
|
|
|
+ for (InsNoBxOtherExcelDto excelItem : dtoList) {
|
|
|
+ String reason = "";
|
|
|
+ i = i + 1;
|
|
|
+ params.clear();
|
|
|
+ if (StringUtils.isNotEmpty(excelItem.getLicenseno())) {
|
|
|
+ String licenseno = excelItem.getLicenseno();//车牌号
|
|
|
+ params.put("licenseno", licenseno);
|
|
|
+ InsPlyIncome byBxLicenseno = insPlyIncomeMapper.findByBxLicenseno(params);
|
|
|
+ if (ObjectUtils.isEmpty(byBxLicenseno)) {
|
|
|
+ reason = "该数据车牌号有问题";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(excelItem.getNoPolicyno())) {
|
|
|
+ String noPolicyno = excelItem.getNoPolicyno(); //交强保单号
|
|
|
+ params.put("noPolicyno", noPolicyno);
|
|
|
+ InsPlyIncome byBxLicenseno = insPlyIncomeMapper.findByBxLicenseno(params);
|
|
|
+ if (ObjectUtils.isEmpty(byBxLicenseno)) {
|
|
|
+ reason = "该数据非车保单号有问题";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (excelItem.getNoOtherCostsProportion()!=null && excelItem.getNoOtherCostsProportion().compareTo(BigDecimal.ZERO) != 0) {
|
|
|
+ BigDecimal noOtherCostsProportion = excelItem.getNoOtherCostsProportion();//商业保单号
|
|
|
+ params.put("noOtherCostsProportion", noOtherCostsProportion);
|
|
|
+ InsPlyIncome byBxLicenseno = insPlyIncomeMapper.findByBxLicenseno(params);
|
|
|
+ if (ObjectUtils.isEmpty(byBxLicenseno)) {
|
|
|
+ reason = "该数据非车跟单比例有问题";
|
|
|
+ }
|
|
|
+ }
|
|
|
+// 只查手续费
|
|
|
+ params.put("isOther", "1");
|
|
|
+ params.put("isNotCar", isNotCar);
|
|
|
+ InsPlyIncome insPlyIncome = insPlyIncomeMapper.findByBxLicenseno(params);
|
|
|
+ if (ObjectUtils.isNotEmpty(insPlyIncome) && open) {
|
|
|
+ open = false;
|
|
|
+ companyId = insPlyIncome.getCompanyId(); // 保险公司id
|
|
|
+ partnerCompaniesId = insPlyIncome.getPartnerCompaniesId(); //合作公司id
|
|
|
+ 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()); //添加总手续费
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ InsImportResult insImportResult = new InsImportResult();
|
|
|
+ if (StringUtils.isNotEmpty(excelItem.getLicenseno())) {
|
|
|
+ insImportResult.setLicenseno(excelItem.getLicenseno());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(excelItem.getNoPolicyno())) {
|
|
|
+ insImportResult.setPolicyno(excelItem.getNoPolicyno());
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotEmpty(reason)){
|
|
|
+ insImportResult.setReason(reason);
|
|
|
+ }
|
|
|
+ insImportResultsExcel.add(insImportResult);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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)) {
|
|
|
+ try {
|
|
|
+ Files.createDirectories(path);
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String fileName = EasyExcelUtils.downExcel(uploadPath, "保险对账问题文件", InsImportResult.class, insImportResultsExcel);
|
|
|
+ String url=uploadUrl + "excel/" + fileName;
|
|
|
+
|
|
|
+ ImportResult endTask = new ImportResult();
|
|
|
+ endTask.setTotalAmount(totalAmount);
|
|
|
+ endTask.setId(taskId);
|
|
|
+ endTask.setCompletedAt(LocalDateTime.now());
|
|
|
+ endTask.setStatus("complete");
|
|
|
+ if(!CollectionUtils.isEmpty(insImportResultsExcel)){
|
|
|
+ endTask.setUploadUrl("upload/excel/" + taskId + "/" + fileName);
|
|
|
+ }
|
|
|
+ endTask.setCompanyId(companyId);
|
|
|
+ endTask.setAgreementId(agreementId);
|
|
|
+ endTask.setPartnerCompaniesId(partnerCompaniesId);
|
|
|
+ endTask.setIds(ids);
|
|
|
+ endTask.setHandStatus("3");
|
|
|
+ baseMapper.updateById(endTask);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ 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;
|
|
|
+
|
|
|
+ // 创建任务
|
|
|
+ ImportResult importResult = new ImportResult();
|
|
|
+ importResult.setId(taskId);
|
|
|
+ importResult.setStatus("ready");
|
|
|
+ importResult.setCreateTime(LocalDateTime.now());
|
|
|
+ importResult.setCreatedAt(LocalDateTime.now());
|
|
|
+ baseMapper.insert(importResult);
|
|
|
+
|
|
|
+ if (!CollectionUtils.isEmpty(dtoList)) {
|
|
|
+ for (InsBxNoPlyIncomeExcelDto excelItem : dtoList) {
|
|
|
+ String reason = "";
|
|
|
+ i = i + 1;
|
|
|
+ params.clear();
|
|
|
+ if (StringUtils.isNotEmpty(excelItem.getLicenseno())) {
|
|
|
+ String licenseno = excelItem.getLicenseno();//车牌号
|
|
|
+ params.put("licenseno", licenseno);
|
|
|
+ InsPlyIncome byBxLicenseno = insPlyIncomeMapper.findByBxLicenseno(params);
|
|
|
+ if (ObjectUtils.isEmpty(byBxLicenseno)) {
|
|
|
+ reason = "该数据车牌号有问题";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(excelItem.getNoPolicyno())) {
|
|
|
+ String noPolicyno = excelItem.getNoPolicyno(); //交强保单号
|
|
|
+ params.put("noPolicyno", noPolicyno);
|
|
|
+ InsPlyIncome byBxLicenseno = insPlyIncomeMapper.findByBxLicenseno(params);
|
|
|
+ if (ObjectUtils.isEmpty(byBxLicenseno)) {
|
|
|
+ reason = "该数据非车保单号有问题";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (excelItem.getNoSuperviseCostsProportion()!=null && excelItem.getNoSuperviseCostsProportion().compareTo(BigDecimal.ZERO) != 0) {
|
|
|
+ BigDecimal noSuperviseCostsProportion = excelItem.getNoSuperviseCostsProportion();//商业保单号
|
|
|
+ params.put("noSuperviseCostsProportion", noSuperviseCostsProportion);
|
|
|
+ InsPlyIncome byBxLicenseno = insPlyIncomeMapper.findByBxLicenseno(params);
|
|
|
+ if (ObjectUtils.isEmpty(byBxLicenseno)) {
|
|
|
+ reason = "该数据非车手续费比例有问题";
|
|
|
+ }
|
|
|
+ }
|
|
|
+// 只查手续费
|
|
|
+ params.put("isOther", "1");
|
|
|
+ params.put("isNotCar", "1");
|
|
|
+ InsPlyIncome insPlyIncome = insPlyIncomeMapper.findByBxLicenseno(params);
|
|
|
+ if (ObjectUtils.isNotEmpty(insPlyIncome) && open) {
|
|
|
+ open = false;
|
|
|
+ companyId = insPlyIncome.getCompanyId(); // 保险公司id
|
|
|
+ partnerCompaniesId = insPlyIncome.getPartnerCompaniesId(); //合作公司id
|
|
|
+ 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()); //添加总手续费
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ InsImportResult insImportResult = new InsImportResult();
|
|
|
+ if (StringUtils.isNotEmpty(excelItem.getLicenseno())) {
|
|
|
+ insImportResult.setLicenseno(excelItem.getLicenseno());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(excelItem.getNoPolicyno())) {
|
|
|
+ insImportResult.setPolicyno(excelItem.getNoPolicyno());
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotEmpty(reason)){
|
|
|
+ insImportResult.setReason(reason);
|
|
|
+ }
|
|
|
+ insImportResultsExcel.add(insImportResult);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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)) {
|
|
|
+ try {
|
|
|
+ Files.createDirectories(path);
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String fileName = EasyExcelUtils.downExcel(uploadPath, "保险对账问题文件", InsImportResult.class, insImportResultsExcel);
|
|
|
+ String url=uploadUrl + "excel/" + fileName;
|
|
|
+
|
|
|
+ ImportResult endTask = new ImportResult();
|
|
|
+ endTask.setTotalAmount(totalAmount);
|
|
|
+ endTask.setId(taskId);
|
|
|
+ endTask.setCompletedAt(LocalDateTime.now());
|
|
|
+ endTask.setStatus("complete");
|
|
|
+ if(!CollectionUtils.isEmpty(insImportResultsExcel)){
|
|
|
+ endTask.setUploadUrl("upload/excel/" + taskId + "/" + fileName);
|
|
|
+ }
|
|
|
+ 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();
|
|
|
+ }
|
|
|
+
|
|
|
+}
|