|
|
@@ -19,24 +19,17 @@ import com.jzg.commons.entity.finance.dto.*;
|
|
|
import com.jzg.commons.entity.finance.po.*;
|
|
|
import com.jzg.commons.entity.finance.vo.*;
|
|
|
import com.jzg.commons.entity.orders.po.InsOrderAdjust;
|
|
|
-import com.jzg.commons.entity.orders.po.InsOrders;
|
|
|
import com.jzg.commons.entity.po.EsmInsCompany;
|
|
|
import com.jzg.commons.entity.po.InsFeeOrders;
|
|
|
import com.jzg.commons.entity.po.PtlAgreement;
|
|
|
import com.jzg.commons.entity.po.SysUploadFiles;
|
|
|
import com.jzg.commons.exception.ServiceException;
|
|
|
import com.jzg.commons.exception.SystemException;
|
|
|
-import com.jzg.commons.util.AssertionUtils;
|
|
|
-import com.jzg.commons.util.EasyExcelUtils;
|
|
|
-import com.jzg.commons.util.MinioUtils;
|
|
|
-import com.jzg.commons.util.ServletUtils;
|
|
|
+import com.jzg.commons.util.*;
|
|
|
import com.jzg.commons.util.idgen.IdGenerate;
|
|
|
import com.jzg.organization.client.EsmInsCompanyClient;
|
|
|
import com.jzg.organization.client.InsFeeOrdersClient;
|
|
|
-import com.jzg.organization.excel.listener.JyExcelListener;
|
|
|
-import com.jzg.organization.excel.listener.OtherExcelListener;
|
|
|
-import com.jzg.organization.excel.listener.ReceivbleExcelListener;
|
|
|
-import com.jzg.organization.excel.listener.SuperviseExcelListener;
|
|
|
+import com.jzg.organization.excel.listener.*;
|
|
|
import com.jzg.organization.mapper.*;
|
|
|
import com.jzg.organization.service.ReceivableService;
|
|
|
import com.jzg.organization.service.SysUserJzgInfoSalesmanService;
|
|
|
@@ -167,9 +160,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
// if (count > 0){
|
|
|
// return false;
|
|
|
// }
|
|
|
- auditedOrder.forEach(item -> {
|
|
|
- item.setId(IdGenerate.nextId());
|
|
|
- });
|
|
|
+ auditedOrder.forEach(item -> item.setId(IdGenerate.nextId()));
|
|
|
return saveBatch(auditedOrder);
|
|
|
}
|
|
|
|
|
|
@@ -178,10 +169,26 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
return baseMapper.getReceivableCompany(invoicingVo);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 查询应收订单关联的所有对接人信息
|
|
|
+ *
|
|
|
+ * @param invoicingVo 包含应收订单编号级的对象
|
|
|
+ * @return HttpResult<List<ContractVO>> 应收订单关联的对接人信息
|
|
|
+ * @author lipf
|
|
|
+ * @date 2026/5/30 10:09
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public HttpResult<List<ContractVO>> queryReceivableContact(InvoicingVo invoicingVo) {
|
|
|
+ List<InsPlyIncome> insPlyIncomes = baseMapper.queryIncomeByIds(invoicingVo);
|
|
|
+ List<ContractVO> contractVOS = insPlyIncomes.stream().map(action -> new ContractVO(action.getContactPerson(), action.getContactPersonPhone())).distinct().toList();
|
|
|
+ log.info("根据订单编号查询得到的对接人信息[{}]个", CollUtil.size(contractVOS));
|
|
|
+ return HttpResult.ok(contractVOS);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取私有协议手续费列表
|
|
|
*
|
|
|
- * @param receivableQueryVo
|
|
|
+ * @param receivableQueryVo 列表查询条件
|
|
|
* @return Page<InsPlyIncome>
|
|
|
*/
|
|
|
@Override
|
|
|
@@ -209,7 +216,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
Page<InsPlyIncome> page = baseMapper.getReceivablePage(page1, receivableQueryVo);
|
|
|
List<InsPlyIncomeOrder> res = page.getRecords().stream()
|
|
|
.map(action -> new InsPlyIncomeOrder(action.getId(), action.getOrderNo())).toList();
|
|
|
- log.info("获取私有协议手续费应收列表的id集合。receivableQueryVo=[{}]. ids.size=[{}]", JSONUtil.toJsonStr(receivableQueryVo), CollUtil.size(res));
|
|
|
+ log.info("获取私有/平台协议手续费应收列表的id集合。receivableQueryVo=[{}]. ids.size=[{}]", JSONUtil.toJsonStr(receivableQueryVo), CollUtil.size(res));
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
@@ -250,6 +257,23 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
.collect(Collectors.toMap(IncomeDataVO.SearchVO::getName, Function.identity(), (ole_item, new_item) -> ole_item));
|
|
|
Set<String> names =searchVOMap.keySet();
|
|
|
|
|
|
+ Predicate<InsPlyIncome> contactPredicate = insPlyIncome -> {
|
|
|
+ if(!names.contains(IncomeDataVO.SearchVO.contactPerson)){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ IncomeDataVO.SearchVO searchVO = searchVOMap.get(IncomeDataVO.SearchVO.contactPerson);
|
|
|
+ String type = searchVO.getType();
|
|
|
+ String search = searchVO.getSearch();
|
|
|
+ if(StrUtil.isEmpty(search)){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if("等于".equals(type)){
|
|
|
+ return search.equals(insPlyIncome.getContactPersonPhone());
|
|
|
+ }else if("不等于".equals(type)){
|
|
|
+ return !search.equals(insPlyIncome.getContactPersonPhone());
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ };
|
|
|
// 保险公司
|
|
|
Predicate<InsPlyIncome> companyIdPredicate = insPlyIncome -> {
|
|
|
if(!names.contains(IncomeDataVO.SearchVO.companyId)){
|
|
|
@@ -378,7 +402,6 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
if("为空".equals(type)|| "不为空".equals(type)){
|
|
|
return true;
|
|
|
}
|
|
|
- // 如果填写的查询条件,不完善,则该条件不进行过滤
|
|
|
if(StrUtil.isEmpty(search)){
|
|
|
return true;
|
|
|
}
|
|
|
@@ -388,15 +411,98 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
}
|
|
|
if("不等于".equalsIgnoreCase(type) || "不包含".equalsIgnoreCase(type)){
|
|
|
List<String> signYears = Arrays.asList(search.split(","));
|
|
|
- return !signYears.contains(insPlyIncome.getSigningTime());
|
|
|
+ return !signYears.contains(insPlyIncome.getSignYear()); // 修复这里
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ };
|
|
|
+
|
|
|
+ // 车牌号 licenseNo
|
|
|
+ Predicate<InsPlyIncome> licenseNoPredicate = insPlyIncome -> {
|
|
|
+ if(!names.contains(IncomeDataVO.SearchVO.licenseNo)){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ IncomeDataVO.SearchVO searchVO = searchVOMap.get(IncomeDataVO.SearchVO.licenseNo);
|
|
|
+ String type = searchVO.getType();
|
|
|
+ String search = searchVO.getSearch();
|
|
|
+ if("为空".equals(type)|| "不为空".equals(type)){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if(StrUtil.isEmpty(search)){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if("等于".equalsIgnoreCase(type) || "包含".equalsIgnoreCase(type)){
|
|
|
+ List<String> licenseNos = Arrays.asList(search.split(","));
|
|
|
+ return licenseNos.contains(insPlyIncome.getLicenseNo());
|
|
|
+ }
|
|
|
+ if("不等于".equalsIgnoreCase(type) || "不包含".equalsIgnoreCase(type)){
|
|
|
+ List<String> licenseNos = Arrays.asList(search.split(","));
|
|
|
+ return !licenseNos.contains(insPlyIncome.getLicenseNo());
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
+ // 交强险保单号 jqPolicyNo
|
|
|
+ Predicate<InsPlyIncome> jqPolicyNoPredicate = insPlyIncome -> {
|
|
|
+ if(!names.contains(IncomeDataVO.SearchVO.jqPolicyNo)){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ IncomeDataVO.SearchVO searchVO = searchVOMap.get(IncomeDataVO.SearchVO.jqPolicyNo);
|
|
|
+ String type = searchVO.getType();
|
|
|
+ String search = searchVO.getSearch();
|
|
|
+ if("为空".equals(type)|| "不为空".equals(type)){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if(StrUtil.isEmpty(search)){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if("等于".equalsIgnoreCase(type) || "包含".equalsIgnoreCase(type)){
|
|
|
+ List<String> jqPolicyNos = Arrays.asList(search.split(","));
|
|
|
+ return jqPolicyNos.contains(insPlyIncome.getJqPolicyNo());
|
|
|
+ }
|
|
|
+ if("不等于".equalsIgnoreCase(type) || "不包含".equalsIgnoreCase(type)){
|
|
|
+ List<String> jqPolicyNos = Arrays.asList(search.split(","));
|
|
|
+ return !jqPolicyNos.contains(insPlyIncome.getJqPolicyNo());
|
|
|
}
|
|
|
return true;
|
|
|
};
|
|
|
+
|
|
|
+
|
|
|
+ // 商业险保单号 syPolicyNo
|
|
|
+ Predicate<InsPlyIncome> syPolicyNoPredicate = insPlyIncome -> {
|
|
|
+ if(!names.contains(IncomeDataVO.SearchVO.syPolicyNo)){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ IncomeDataVO.SearchVO searchVO = searchVOMap.get(IncomeDataVO.SearchVO.syPolicyNo);
|
|
|
+ String type = searchVO.getType();
|
|
|
+ String search = searchVO.getSearch();
|
|
|
+ if("为空".equals(type)|| "不为空".equals(type)){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if(StrUtil.isEmpty(search)){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if("等于".equalsIgnoreCase(type) || "包含".equalsIgnoreCase(type)){
|
|
|
+ List<String> syPolicyNos = Arrays.asList(search.split(","));
|
|
|
+ return syPolicyNos.contains(insPlyIncome.getSyPolicyNo());
|
|
|
+ }
|
|
|
+ if("不等于".equalsIgnoreCase(type) || "不包含".equalsIgnoreCase(type)){
|
|
|
+ List<String> syPolicyNos = Arrays.asList(search.split(","));
|
|
|
+ return !syPolicyNos.contains(insPlyIncome.getSyPolicyNo());
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
if("and".equalsIgnoreCase(incomeDataVO.getLogicJudge())){
|
|
|
- Predicate<InsPlyIncome> and = companyIdPredicate.and(signDatePredicate).and(ptlAgreementPredicate).and(orderTypePredicate).and(signYearPredicate);
|
|
|
+ Predicate<InsPlyIncome> and = companyIdPredicate.and(signDatePredicate).
|
|
|
+ and(ptlAgreementPredicate).and(orderTypePredicate).and(signYearPredicate).and(licenseNoPredicate)
|
|
|
+ .and(contactPredicate).and(jqPolicyNoPredicate).and(syPolicyNoPredicate);
|
|
|
filterIncomes = incomes.stream().filter(and).toList();
|
|
|
}else if ("or".equalsIgnoreCase(incomeDataVO.getLogicJudge())){
|
|
|
- Predicate<InsPlyIncome> or = companyIdPredicate.or(signDatePredicate).or(ptlAgreementPredicate).or(orderTypePredicate).or(signYearPredicate);
|
|
|
+ Predicate<InsPlyIncome> or = companyIdPredicate.or(signDatePredicate).
|
|
|
+ or(ptlAgreementPredicate).or(orderTypePredicate).or(signYearPredicate).or(licenseNoPredicate)
|
|
|
+ .or(contactPredicate).or(jqPolicyNoPredicate).or(syPolicyNoPredicate);
|
|
|
filterIncomes = incomes.stream().filter(or).toList();
|
|
|
}
|
|
|
}
|
|
|
@@ -409,6 +515,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
@Override
|
|
|
public Boolean deleteInvoiceById(String id) {
|
|
|
log.info("私有协议-开票记录-删除: id=[{}]",id);
|
|
|
+ insPlyIncomeInvoiceLinkMapper.deleteByInvoiceId(id);
|
|
|
return insPlyIncomeInvoiceMapper.deleteById(id) > 0;
|
|
|
}
|
|
|
|
|
|
@@ -464,7 +571,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
/**
|
|
|
* 查询订单绑定的发票信息
|
|
|
*
|
|
|
- * @param invoicingVo
|
|
|
+ * @param invoicingVo 应收订单的序号集
|
|
|
* @return List<String> 订单绑定的发票号
|
|
|
* @author lipf
|
|
|
* @date 2026/5/21 11:59
|
|
|
@@ -622,25 +729,25 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
|
|
|
// 私有手续费 应收金额
|
|
|
// 交强的总手续费(jq_commission_premium) + 商业的总手续费(sy_commission_premium)
|
|
|
- if (invoiceType.equals("1")) {
|
|
|
- return jqCommissionPremium.add(syCommissionPremium);
|
|
|
- } else if (invoiceType.equals("2")) {
|
|
|
- // 交强的总跟单费(jq_follow_premium) + 商业的总跟单费(sy_follow_premium)
|
|
|
- return jqFollowPremium.add(syFollowPremium);
|
|
|
- } else if (invoiceType.equals("3")) {
|
|
|
- // 驾意险的总手续费(jy_commission_premium)
|
|
|
- return jyCommissionPremium;
|
|
|
- } else if (invoiceType.equals("4")) {
|
|
|
- // 驾意险的总跟单费(jy_follow_premium)
|
|
|
- return jyFollowPremium;
|
|
|
- } else if (invoiceType.equals("5")) {
|
|
|
- // 交强的总手续费(jq_commission_premium) + 商业的总手续费(sy_commission_premium) + 交强的总跟单费(jq_follow_premium) + 商业的总跟单费(sy_follow_premium)
|
|
|
- return jqCommissionPremium.add(syCommissionPremium).add(jqFollowPremium).add(syFollowPremium);
|
|
|
- } else if (invoiceType.equals("6")) {
|
|
|
- // 驾意险的总手续费(jy_commission_premium) + 驾意险的总跟单费(jy_follow_premium)
|
|
|
- return jyCommissionPremium.add(jyFollowPremium);
|
|
|
- }
|
|
|
- return null;
|
|
|
+ return switch (invoiceType) {
|
|
|
+ case "1" -> jqCommissionPremium.add(syCommissionPremium);
|
|
|
+ case "2" ->
|
|
|
+ // 交强的总跟单费(jq_follow_premium) + 商业的总跟单费(sy_follow_premium)
|
|
|
+ jqFollowPremium.add(syFollowPremium);
|
|
|
+ case "3" ->
|
|
|
+ // 驾意险的总手续费(jy_commission_premium)
|
|
|
+ jyCommissionPremium;
|
|
|
+ case "4" ->
|
|
|
+ // 驾意险的总跟单费(jy_follow_premium)
|
|
|
+ jyFollowPremium;
|
|
|
+ case "5" ->
|
|
|
+ // 交强的总手续费(jq_commission_premium) + 商业的总手续费(sy_commission_premium) + 交强的总跟单费(jq_follow_premium) + 商业的总跟单费(sy_follow_premium)
|
|
|
+ jqCommissionPremium.add(syCommissionPremium).add(jqFollowPremium).add(syFollowPremium);
|
|
|
+ case "6" ->
|
|
|
+ // 驾意险的总手续费(jy_commission_premium) + 驾意险的总跟单费(jy_follow_premium)
|
|
|
+ jyCommissionPremium.add(jyFollowPremium);
|
|
|
+ default -> null;
|
|
|
+ };
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -674,7 +781,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
invoice.setReceivableSupervisePremium(invoicingVo.getReceivableSupervisePremium());
|
|
|
invoice.setTaxPoint(invoicingVo.getTaxPoint());
|
|
|
insPlyIncomeInvoiceMapper.insert(invoice);
|
|
|
- List<InsPlyIncomeInvoiceLink> invoicingLinkList = new ArrayList<InsPlyIncomeInvoiceLink>();
|
|
|
+ List<InsPlyIncomeInvoiceLink> invoicingLinkList = new ArrayList<>();
|
|
|
invoicingVo.getIncomeIds().forEach(incomeId -> {
|
|
|
InsPlyIncomeInvoiceLink link = new InsPlyIncomeInvoiceLink();
|
|
|
link.setId(IdGenerate.nextId());
|
|
|
@@ -728,42 +835,29 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
if (CollectionUtils.isEmpty(invoiceIds)) {
|
|
|
return false;
|
|
|
}
|
|
|
- long result = 0;
|
|
|
+ long result;
|
|
|
final String number = "1";
|
|
|
- switch (invoiceType) {
|
|
|
- case number:
|
|
|
- result = baseMapper.update(new LambdaUpdateWrapper<InsPlyIncome>()
|
|
|
- .in(InsPlyIncome::getId, invoiceIds)
|
|
|
- .set(InsPlyIncome::getSuperviseSettlement, number));
|
|
|
- break;
|
|
|
- case "2":
|
|
|
- result = baseMapper.update(new LambdaUpdateWrapper<InsPlyIncome>()
|
|
|
- .in(InsPlyIncome::getId, invoiceIds)
|
|
|
- .set(InsPlyIncome::getOtherSettlement, number));
|
|
|
- break;
|
|
|
- case "3":
|
|
|
- result = baseMapper.update(new LambdaUpdateWrapper<InsPlyIncome>()
|
|
|
- .in(InsPlyIncome::getId, invoiceIds)
|
|
|
- .set(InsPlyIncome::getJySuperviseSettlement, number));
|
|
|
- break;
|
|
|
- case "4":
|
|
|
- result = baseMapper.update(new LambdaUpdateWrapper<InsPlyIncome>()
|
|
|
- .in(InsPlyIncome::getId, invoiceIds)
|
|
|
- .set(InsPlyIncome::getJyOtherSettlement, number));
|
|
|
- break;
|
|
|
- case "5":
|
|
|
- result = baseMapper.update(new LambdaUpdateWrapper<InsPlyIncome>()
|
|
|
- .in(InsPlyIncome::getId, invoiceIds)
|
|
|
- .set(InsPlyIncome::getPlatformSuperviseSettlement, number).set(InsPlyIncome::getSettlementStatus, number));
|
|
|
- break;
|
|
|
- case "6":
|
|
|
- result = baseMapper.update(new LambdaUpdateWrapper<InsPlyIncome>()
|
|
|
- .in(InsPlyIncome::getId, invoiceIds)
|
|
|
- .set(InsPlyIncome::getPlatformOtherSettlement, number).set(InsPlyIncome::getSettlementStatus, number));
|
|
|
- break;
|
|
|
- default:
|
|
|
- result = 0;
|
|
|
- }
|
|
|
+ result = switch (invoiceType) {
|
|
|
+ case number -> baseMapper.update(new LambdaUpdateWrapper<InsPlyIncome>()
|
|
|
+ .in(InsPlyIncome::getId, invoiceIds)
|
|
|
+ .set(InsPlyIncome::getSuperviseSettlement, number));
|
|
|
+ case "2" -> baseMapper.update(new LambdaUpdateWrapper<InsPlyIncome>()
|
|
|
+ .in(InsPlyIncome::getId, invoiceIds)
|
|
|
+ .set(InsPlyIncome::getOtherSettlement, number));
|
|
|
+ case "3" -> baseMapper.update(new LambdaUpdateWrapper<InsPlyIncome>()
|
|
|
+ .in(InsPlyIncome::getId, invoiceIds)
|
|
|
+ .set(InsPlyIncome::getJySuperviseSettlement, number));
|
|
|
+ case "4" -> baseMapper.update(new LambdaUpdateWrapper<InsPlyIncome>()
|
|
|
+ .in(InsPlyIncome::getId, invoiceIds)
|
|
|
+ .set(InsPlyIncome::getJyOtherSettlement, number));
|
|
|
+ case "5" -> baseMapper.update(new LambdaUpdateWrapper<InsPlyIncome>()
|
|
|
+ .in(InsPlyIncome::getId, invoiceIds)
|
|
|
+ .set(InsPlyIncome::getPlatformSuperviseSettlement, number).set(InsPlyIncome::getSettlementStatus, number));
|
|
|
+ case "6" -> baseMapper.update(new LambdaUpdateWrapper<InsPlyIncome>()
|
|
|
+ .in(InsPlyIncome::getId, invoiceIds)
|
|
|
+ .set(InsPlyIncome::getPlatformOtherSettlement, number).set(InsPlyIncome::getSettlementStatus, number));
|
|
|
+ default -> 0;
|
|
|
+ };
|
|
|
return result > 0;
|
|
|
}
|
|
|
|
|
|
@@ -821,7 +915,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
invoice.setReceivableSupervisePremium(invoicingVo.getReceivablePremium());
|
|
|
invoice.setTaxPoint(invoicingVo.getTaxPoint());
|
|
|
|
|
|
- List<InsPlyIncomeInvoiceLink> invoicingLinkList = new ArrayList();
|
|
|
+ List<InsPlyIncomeInvoiceLink> invoicingLinkList = new ArrayList<>();
|
|
|
|
|
|
invoicingVo.getIncomeIds().forEach(incomeId -> {
|
|
|
InsPlyIncomeInvoiceLink link = new InsPlyIncomeInvoiceLink();
|
|
|
@@ -867,8 +961,8 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
insPlyIncomeInvoiceSettlementFileMapper.insert(files);
|
|
|
}
|
|
|
|
|
|
- // 判断是否已经结算完成
|
|
|
- if (surplusPremium.compareTo(settlementVo.getActualReceivedAmount()) == 0) {
|
|
|
+ // 判断是否已经结算完成, 考虑回款差额
|
|
|
+ if (surplusPremium.compareTo(settlementVo.getActualReceivedAmount().add(platformSettlementVo.getSettlementVo().getPaymentDifference())) == 0) {
|
|
|
log.info("序号为[{}]的发票已经结算完成",invoice.getId());
|
|
|
// 更新发票状态
|
|
|
invoice.setStatus("1");
|
|
|
@@ -1016,6 +1110,186 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
return importExcelResultVo;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 导出应收开票模板
|
|
|
+ * @return String 导出时的提示信息
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public String exportAccountsReceivableInvoiceTemplate() {
|
|
|
+ List<InvoiceReceivableExportExcelVo> emptyList = ListUtil.empty();
|
|
|
+
|
|
|
+ // 调用动态导出
|
|
|
+ return exportBaseService.upLoadFile(
|
|
|
+ InvoiceReceivableExportExcelVo.class,
|
|
|
+ emptyList,
|
|
|
+ "应收开票-导出模板-" + Instant.now()
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ImportUpdateExcelResultVo importAccountsReceivableInvoice(MultipartFile file) {
|
|
|
+ String userName = baseController.getUserName();
|
|
|
+ log.info("用户[{}]导入平台协议文件",userName);
|
|
|
+ ImportUpdateExcelResultVo importExcelResultVo = new ImportUpdateExcelResultVo();
|
|
|
+ List<InvoiceReceivableExportExcelVo> receivableExportExcelVos = importInvoiceReceivableExcel(file);
|
|
|
+ if (CollUtil.isEmpty(receivableExportExcelVos)){
|
|
|
+ throw new SystemException("数据不能为空,导入失败");
|
|
|
+ }
|
|
|
+ AssertionUtils.isEmpty(receivableExportExcelVos, "数据处理失败,导入失败");
|
|
|
+ // 获取保司名称
|
|
|
+ HttpResult<List<EsmInsCompany>> listHttpResult = esmInsCompanyClient.liveCompanyList();
|
|
|
+ AssertionUtils.isFail(listHttpResult.getCode() != 200, listHttpResult.getMsg());
|
|
|
+
|
|
|
+ int failedNumber = 0;
|
|
|
+ List<InvoiceReceivableExportExcelVo> failedExcel = new ArrayList<>();
|
|
|
+ // 只存储需要【修改】的数据
|
|
|
+ List<InsPlyIncome> updateExcel = new ArrayList<>();
|
|
|
+ List<InsPlyIncome> insertExcel = new ArrayList<>();
|
|
|
+ // 存储导入成功的订单号
|
|
|
+ List<String> successOrderNoList = new ArrayList<>();
|
|
|
+
|
|
|
+ // 校验Excel内部保单号重复
|
|
|
+ Set<String> existPolicyNoSet = new HashSet<>();
|
|
|
+ Set<String> repeatPolicyNoSet = new HashSet<>();
|
|
|
+ Set<String> existCompanyIdSet = new HashSet<>();
|
|
|
+
|
|
|
+ for (InvoiceReceivableExportExcelVo vo : receivableExportExcelVos) {
|
|
|
+ String policyNo = vo.getJqPolicyNo();
|
|
|
+ if (existPolicyNoSet.contains(policyNo)) {
|
|
|
+ repeatPolicyNoSet.add(policyNo);
|
|
|
+ } else {
|
|
|
+ existPolicyNoSet.add(policyNo);
|
|
|
+ }
|
|
|
+ existCompanyIdSet.add(vo.getCompanyId());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 导入只能一个保司
|
|
|
+ if (existCompanyIdSet.size() > 1) {
|
|
|
+ throw new SystemException("导入数据不能包含多个保险公司");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 处理数据
|
|
|
+ for (InvoiceReceivableExportExcelVo vo : receivableExportExcelVos) {
|
|
|
+ // 1. 空数据校验
|
|
|
+ ImportResultVo resultVo = vo.checkEmpty();
|
|
|
+ if (!resultVo.isSuccess()) {
|
|
|
+ failedNumber++;
|
|
|
+ vo.setErrorMessage(resultVo.getMessage());
|
|
|
+ failedExcel.add(vo);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. Excel内部保单号重复
|
|
|
+ if (repeatPolicyNoSet.contains(vo.getJqPolicyNo())) {
|
|
|
+ failedNumber++;
|
|
|
+ vo.setErrorMessage("保单号重复");
|
|
|
+ failedExcel.add(vo);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询数据库中是否已存在该协议
|
|
|
+ PtlAgreement ptlAgreement = ptlAgreementMapper.selectOne(new LambdaQueryWrapper<PtlAgreement>()
|
|
|
+ .eq(PtlAgreement::getAgreementCode, vo.getAgreementCode())
|
|
|
+ .eq(PtlAgreement::getAgreementType, vo.getAgreementType()));
|
|
|
+
|
|
|
+ // 数据库不存在 → 直接失败
|
|
|
+ if (Objects.isNull(ptlAgreement)) {
|
|
|
+ failedNumber++;
|
|
|
+ vo.setErrorMessage("协议编码在协议中不存在");
|
|
|
+ failedExcel.add(vo);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询数据库中是否已存在该保单号
|
|
|
+ InsPlyIncome existIncome = baseMapper.selectOne(new LambdaQueryWrapper<InsPlyIncome>()
|
|
|
+ .eq(InsPlyIncome::getJqPolicyNo, vo.getJqPolicyNo()));
|
|
|
+
|
|
|
+ // 封装修改数据
|
|
|
+ InsPlyIncome insPlyIncome = new InsPlyIncome();
|
|
|
+ insPlyIncome.setId(IdGenerate.nextId());
|
|
|
+ insPlyIncome.setLicenseNo(vo.getLicenseNo());
|
|
|
+ insPlyIncome.setJqPolicyNo(vo.getJqPolicyNo());
|
|
|
+ insPlyIncome.setJqSuperviseCostsProportion(vo.getJqSuperviseCostsProportion());
|
|
|
+ insPlyIncome.setJqOtherCostsProportion(vo.getJqOtherCostsProportion());
|
|
|
+ insPlyIncome.setSyPolicyNo(vo.getSyPolicyNo());
|
|
|
+ insPlyIncome.setSySuperviseCostsProportion(vo.getSySuperviseCostsProportion());
|
|
|
+ insPlyIncome.setSyOtherCostsProportion(vo.getSyOtherCostsProportion());
|
|
|
+ insPlyIncome.setJyPolicyNo(vo.getJyPolicyNo());
|
|
|
+ insPlyIncome.setJySuperviseCostsProportion(vo.getJySuperviseCostsProportion());
|
|
|
+ insPlyIncome.setJyOtherCostsProportion(vo.getJyOtherCostsProportion());
|
|
|
+ // 签单时间
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ insPlyIncome.setSigningTime(LocalDateTime.parse(vo.getSigningTime(), formatter));
|
|
|
+ // 协议编号
|
|
|
+ insPlyIncome.setAgreementId(ptlAgreement.getId());
|
|
|
+ insPlyIncome.setAgreementName(ptlAgreement.getAgreementName());
|
|
|
+ insPlyIncome.setAgreementType(ptlAgreement.getAgreementType().toString());
|
|
|
+ // 险种编号
|
|
|
+ insPlyIncome.setProductId(vo.getProductId());
|
|
|
+ // 险种名称
|
|
|
+ insPlyIncome.setProductName(vo.getProductName());
|
|
|
+ // 被保险人姓名
|
|
|
+ insPlyIncome.setInsuredPerson(vo.getInsuredPerson());
|
|
|
+
|
|
|
+ // 数据库不存在 → 直接失败
|
|
|
+ if (Objects.isNull(existIncome)) {
|
|
|
+ // 加入修改列表
|
|
|
+ // 机构id
|
|
|
+ insPlyIncome.setDeptId(baseController.getUserDeptId());
|
|
|
+ insPlyIncome.setCompanyId(vo.getCompanyId());
|
|
|
+ insPlyIncome.setOrderNo(vo.getOrderNo());
|
|
|
+ insertExcel.add(insPlyIncome);
|
|
|
+ // 新增成功,记录订单号
|
|
|
+ successOrderNoList.add(vo.getOrderNo());
|
|
|
+ }else{
|
|
|
+ // 数据库已存在 → 继续后续校验
|
|
|
+ // 判断已开票 / 已结算
|
|
|
+ String settlementFlag = "1";
|
|
|
+ if (settlementFlag.equals(existIncome.getSuperviseSettlement()) || settlementFlag.equals(existIncome.getOtherSettlement())
|
|
|
+ || settlementFlag.equals(existIncome.getJySuperviseSettlement()) || settlementFlag.equals(existIncome.getJyOtherSettlement())
|
|
|
+ || settlementFlag.equals(existIncome.getPlatformSuperviseSettlement()) || settlementFlag.equals(existIncome.getPlatformOtherSettlement())) {
|
|
|
+ failedNumber++;
|
|
|
+ vo.setErrorMessage("应收数据已结算");
|
|
|
+ failedExcel.add(vo);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ insPlyIncome.setId(existIncome.getId());
|
|
|
+ // 加入修改列表
|
|
|
+ updateExcel.add(insPlyIncome);
|
|
|
+ // 更新成功,记录订单号
|
|
|
+ successOrderNoList.add(vo.getOrderNo());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 执行批量更新
|
|
|
+ if (CollUtil.isNotEmpty(updateExcel)) {
|
|
|
+ baseMapper.updateById(updateExcel);
|
|
|
+ }else{
|
|
|
+ baseMapper.insert(insertExcel);
|
|
|
+ }
|
|
|
+
|
|
|
+ // ===================== 生成失败数据下载链接 =====================
|
|
|
+ String failFileUrl = "";
|
|
|
+ if (CollUtil.isNotEmpty(failedExcel)) {
|
|
|
+ failFileUrl = exportBaseService.upLoadFile(
|
|
|
+ InvoiceReceivableExportExcelVo.class,
|
|
|
+ failedExcel,
|
|
|
+ "平台协议应收-导入失败-" + Instant.now()
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ // 返回结果
|
|
|
+ importExcelResultVo.setFailedData(failedExcel);
|
|
|
+ importExcelResultVo.setFailFileUrl(failFileUrl);
|
|
|
+ importExcelResultVo.setSuccessNumber(CollUtil.isNotEmpty(updateExcel) ? updateExcel.size() : insertExcel.size());
|
|
|
+ importExcelResultVo.setFailedNumber(failedNumber);
|
|
|
+ // 导出成功的orderNos
|
|
|
+ importExcelResultVo.setOrderNos(successOrderNoList);
|
|
|
+
|
|
|
+ return importExcelResultVo;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@@ -1067,9 +1341,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
List<String> incomeIds = new ArrayList<>();
|
|
|
insPlyIncomeInvoiceLinkMapper.selectList(new LambdaQueryWrapper<InsPlyIncomeInvoiceLink>()
|
|
|
.eq(InsPlyIncomeInvoiceLink::getInvoiceId, settlementVo.getInvoicingId()))
|
|
|
- .forEach(item -> {
|
|
|
- incomeIds.add(item.getIncomeId());
|
|
|
- });
|
|
|
+ .forEach(item -> incomeIds.add(item.getIncomeId()));
|
|
|
// 判断是需要更新哪个字段
|
|
|
this.updateIncomeSettlementStatus(insPlyIncomeInvoice.getInvoiceType(), incomeIds);
|
|
|
}else{
|
|
|
@@ -1097,8 +1369,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
EasyExcel.read(inputStream, SuperviseExcelVo.class, listener)
|
|
|
.sheet()
|
|
|
.doRead();
|
|
|
- List<SuperviseExcelVo> dataList = listener.getDataList();
|
|
|
- return dataList;
|
|
|
+ return listener.getDataList();
|
|
|
} catch (Exception e) {
|
|
|
log.error("导入excel异常。",e);
|
|
|
return null;
|
|
|
@@ -1112,10 +1383,9 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
EasyExcel.read(inputStream, OtherExcelVo.class, listener)
|
|
|
.sheet()
|
|
|
.doRead();
|
|
|
- List<OtherExcelVo> dataList = listener.getDataList();
|
|
|
- return dataList;
|
|
|
+ return listener.getDataList();
|
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
+ log.error("importOtherExcel异常",e);
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
@@ -1127,10 +1397,22 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
EasyExcel.read(inputStream, ReceivableExportExcelVo.class, listener)
|
|
|
.sheet()
|
|
|
.doRead();
|
|
|
- List<ReceivableExportExcelVo> dataList = listener.getDataList();
|
|
|
- return dataList;
|
|
|
+ return listener.getDataList();
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.info("importReceivableExcel异常",e);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<InvoiceReceivableExportExcelVo> importInvoiceReceivableExcel(MultipartFile file) {
|
|
|
+ InvoiceReceivbleExcelListener listener = new InvoiceReceivbleExcelListener();
|
|
|
+ try (InputStream inputStream = file.getInputStream()) {
|
|
|
+ EasyExcel.read(inputStream, InvoiceReceivableExportExcelVo.class, listener)
|
|
|
+ .sheet()
|
|
|
+ .doRead();
|
|
|
+ return listener.getDataList();
|
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
+ log.error("importInvoiceReceivableExcel异常",e);
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
@@ -1142,10 +1424,9 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
EasyExcel.read(inputStream, OtherExcelVo.class, listener)
|
|
|
.sheet()
|
|
|
.doRead();
|
|
|
- List<JyExcelVo> dataList = listener.getDataList();
|
|
|
- return dataList;
|
|
|
+ return listener.getDataList();
|
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
+ log.info("importJyExcel异常",e);
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
@@ -1576,14 +1857,14 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
}
|
|
|
insOrders.add(insPlyIncomeSource.getOrderNo());
|
|
|
if (Objects.nonNull(batchModifyVo.getJqSuperviseCostsProportion()) && batchModifyVo.getJqSuperviseCostsProportion().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- BigDecimal superviseReceivablePremium = calcReceivableAmount(new BigDecimal(Objects.toString(insPlyIncomeSource.getJqPremium(),"0") ), batchModifyVo.getJqSuperviseCostsProportion());
|
|
|
+ BigDecimal superviseReceivablePremium = BigDecimalUtil.multiply(new BigDecimal(Objects.toString(insPlyIncomeSource.getJqPremium(),"0") ), batchModifyVo.getJqSuperviseCostsProportion());
|
|
|
baseMapper.update(null, new LambdaUpdateWrapper<InsPlyIncome>()
|
|
|
.set(InsPlyIncome::getJqSuperviseCostsProportion, batchModifyVo.getJqSuperviseCostsProportion())
|
|
|
.set(InsPlyIncome::getJqSuperviseCostsPremiums, superviseReceivablePremium)
|
|
|
.in(InsPlyIncome::getId, batchModifyVo.getIncomeIds()));
|
|
|
}
|
|
|
if (Objects.nonNull(batchModifyVo.getSySuperviseCostsProportion()) && batchModifyVo.getSySuperviseCostsProportion().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- BigDecimal otherReceivablePremium = calcReceivableAmount(new BigDecimal(Objects.toString(insPlyIncomeSource.getSyPremium(),"0")), batchModifyVo.getSySuperviseCostsProportion());
|
|
|
+ BigDecimal otherReceivablePremium = BigDecimalUtil.multiply(new BigDecimal(Objects.toString(insPlyIncomeSource.getSyPremium(),"0")), batchModifyVo.getSySuperviseCostsProportion());
|
|
|
baseMapper.update(null, new LambdaUpdateWrapper<InsPlyIncome>()
|
|
|
.set(InsPlyIncome::getSySuperviseCostsProportion, batchModifyVo.getSySuperviseCostsProportion())
|
|
|
.set(InsPlyIncome::getSySuperviseCostsPremiums, otherReceivablePremium)
|
|
|
@@ -1613,13 +1894,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public BigDecimal calcReceivableAmount(BigDecimal premium, BigDecimal ratio) {
|
|
|
- if(premium==null||ratio==null) {
|
|
|
- return BigDecimal.ZERO;
|
|
|
- }
|
|
|
- return premium.multiply(ratio);
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public Page<InsPlyIncome> getPlatFormReceivableList(ReceivableQueryVo receivableQueryVo) {
|
|
|
@@ -1680,8 +1955,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
|
|
|
@Override
|
|
|
public List<InsPlyIncomeInvoiceSettlement> getInvoiceRecordDetail(String id) {
|
|
|
- List<InsPlyIncomeInvoiceSettlement> insPlyIncomeInvoiceSettlements = insPlyIncomeInvoiceSettlementMapper.selectList(new LambdaQueryWrapper<InsPlyIncomeInvoiceSettlement>().eq(InsPlyIncomeInvoiceSettlement::getInvoiceId, id));
|
|
|
- return insPlyIncomeInvoiceSettlements;
|
|
|
+ return insPlyIncomeInvoiceSettlementMapper.selectList(new LambdaQueryWrapper<InsPlyIncomeInvoiceSettlement>().eq(InsPlyIncomeInvoiceSettlement::getInvoiceId, id));
|
|
|
}
|
|
|
|
|
|
private void verifyUploadPath() throws IOException {
|
|
|
@@ -1695,8 +1969,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
/**
|
|
|
* 导出应收手续费数据 (车险)
|
|
|
*
|
|
|
- * @param receivableQueryVo
|
|
|
- * @return
|
|
|
+ * @param receivableQueryVo 导出数据的筛选条件
|
|
|
*/
|
|
|
@Override
|
|
|
public void exportSuperviseExcel(ReceivableQueryVo receivableQueryVo) {
|
|
|
@@ -1754,8 +2027,8 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
/**
|
|
|
* 应收手续费结算记录
|
|
|
*
|
|
|
- * @param settlementQueryVo
|
|
|
- * @return
|
|
|
+ * @param settlementQueryVo 查询条件
|
|
|
+ * @return Page<ExportSuperviseSettlementExcelDto>
|
|
|
*/
|
|
|
@Override
|
|
|
public Page<ExportSuperviseSettlementExcelDto> superviseSettlementExcel(Page page, SettlementQueryVo settlementQueryVo) {
|
|
|
@@ -1771,8 +2044,8 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
/**
|
|
|
* 平台协议结算记录
|
|
|
*
|
|
|
- * @param settlementQueryVo
|
|
|
- * @return
|
|
|
+ * @param settlementQueryVo 查询条件
|
|
|
+ * @return Page<ExportSuperviseSettlementExcelDto>
|
|
|
*/
|
|
|
@Override
|
|
|
public Page<ExportSuperviseSettlementExcelDto> platformSettlementExcel(Page page, SettlementQueryVo settlementQueryVo) {
|