|
@@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.collection.ListUtil;
|
|
import cn.hutool.core.collection.ListUtil;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
|
+import cn.hutool.core.date.LocalDateTimeUtil;
|
|
|
import cn.hutool.core.lang.tree.Tree;
|
|
import cn.hutool.core.lang.tree.Tree;
|
|
|
import cn.hutool.core.lang.tree.TreeNodeConfig;
|
|
import cn.hutool.core.lang.tree.TreeNodeConfig;
|
|
|
import cn.hutool.core.lang.tree.TreeUtil;
|
|
import cn.hutool.core.lang.tree.TreeUtil;
|
|
@@ -30,6 +31,7 @@ import com.jzg.commons.entity.finance.po.*;
|
|
|
import com.jzg.commons.entity.finance.vo.*;
|
|
import com.jzg.commons.entity.finance.vo.*;
|
|
|
import com.jzg.commons.entity.finance.vo.importimcome.*;
|
|
import com.jzg.commons.entity.finance.vo.importimcome.*;
|
|
|
import com.jzg.commons.entity.orders.po.InsOrderAdjust;
|
|
import com.jzg.commons.entity.orders.po.InsOrderAdjust;
|
|
|
|
|
+import com.jzg.commons.entity.orders.po.InsOrdersPolicy;
|
|
|
import com.jzg.commons.entity.po.EsmInsCompany;
|
|
import com.jzg.commons.entity.po.EsmInsCompany;
|
|
|
import com.jzg.commons.entity.po.InsFeeOrders;
|
|
import com.jzg.commons.entity.po.InsFeeOrders;
|
|
|
import com.jzg.commons.entity.po.PtlAgreement;
|
|
import com.jzg.commons.entity.po.PtlAgreement;
|
|
@@ -53,6 +55,7 @@ import com.jzg.organization.mapper.*;
|
|
|
import com.jzg.organization.service.ReceivableService;
|
|
import com.jzg.organization.service.ReceivableService;
|
|
|
import com.jzg.organization.service.SysUserJzgInfoSalesmanService;
|
|
import com.jzg.organization.service.SysUserJzgInfoSalesmanService;
|
|
|
import com.jzg.organization.service.importincome.ImportIncomeService;
|
|
import com.jzg.organization.service.importincome.ImportIncomeService;
|
|
|
|
|
+import com.jzg.organization.utils.IncomeInvoiceLinkUtil;
|
|
|
import org.apache.ibatis.annotations.Param;
|
|
import org.apache.ibatis.annotations.Param;
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
import org.redisson.api.RBucket;
|
|
import org.redisson.api.RBucket;
|
|
@@ -87,6 +90,7 @@ import java.util.function.BiConsumer;
|
|
|
import java.util.function.Function;
|
|
import java.util.function.Function;
|
|
|
import java.util.function.Predicate;
|
|
import java.util.function.Predicate;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @author tz
|
|
* @author tz
|
|
@@ -868,7 +872,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
|| invoiceType.equals(income.getInvoiceType()))
|
|
|| invoiceType.equals(income.getInvoiceType()))
|
|
|
.collect(Collectors.toCollection(ArrayList::new));
|
|
.collect(Collectors.toCollection(ArrayList::new));
|
|
|
List<InsPlyIncomeDto> copyList = CollUtil.newArrayList();
|
|
List<InsPlyIncomeDto> copyList = CollUtil.newArrayList();
|
|
|
- if (CollUtil.isNotEmpty(incomeDtoList) && InvoiceTypeEnum.FEE_2.getCode().equals(invoiceType)){
|
|
|
|
|
|
|
+ if (CollUtil.isNotEmpty(incomeDtoList) && (StrUtil.isBlank(invoiceType) || InvoiceTypeEnum.FEE_2.getCode().equals(invoiceType))){
|
|
|
// 如果有发票类型为4的,则复制一条4的数据,完全一致,但发票类型为2
|
|
// 如果有发票类型为4的,则复制一条4的数据,完全一致,但发票类型为2
|
|
|
incomeDtoList.stream().filter(item -> InvoiceTypeEnum.FEE_4.getCode().equals(item.getInvoiceType())).forEach(item -> {
|
|
incomeDtoList.stream().filter(item -> InvoiceTypeEnum.FEE_4.getCode().equals(item.getInvoiceType())).forEach(item -> {
|
|
|
InsPlyIncomeDto incomeDto = new InsPlyIncomeDto();
|
|
InsPlyIncomeDto incomeDto = new InsPlyIncomeDto();
|
|
@@ -899,11 +903,14 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
return resultList;
|
|
return resultList;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 如果status = 0或1,则直接返回空的filterIncomeList,如果status = 2,则查询所有ins_ply_follow_invoice_link表,过滤掉disableFlag为1 的,保留为0 的数据
|
|
|
|
|
- List<InsPlyIncomeDto> filterIncomeList = insPlyIncomes.stream()
|
|
|
|
|
- .filter(income -> "0".equals(income.getDisableFlag()))
|
|
|
|
|
- .map(income -> BeanUtil.copyProperties(income, InsPlyIncomeDto.class))
|
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
|
|
|
+ List<InsPlyIncomeDto> filterIncomeList = BeanUtil.copyToList(insPlyIncomes, InsPlyIncomeDto.class);
|
|
|
|
|
+ if ("2".equals(status)){
|
|
|
|
|
+ // 如果status = 0或1,则直接返回空的filterIncomeList,如果status = 2,则查询所有ins_ply_follow_invoice_link表,过滤掉disableFlag为1 的,保留为0 的数据
|
|
|
|
|
+ filterIncomeList = insPlyIncomes.stream()
|
|
|
|
|
+ .filter(income -> "0".equals(income.getDisableFlag()))
|
|
|
|
|
+ .map(income -> BeanUtil.copyProperties(income, InsPlyIncomeDto.class))
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// 5. 将其他费用收入合并进结果集合
|
|
// 5. 将其他费用收入合并进结果集合
|
|
|
mergeOtherCostIncomeToResult(filterIncomeList, resultList, companyMap);
|
|
mergeOtherCostIncomeToResult(filterIncomeList, resultList, companyMap);
|
|
@@ -2637,14 +2644,73 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
errrMsg.append("该批数据的保险机构为空. ");
|
|
errrMsg.append("该批数据的保险机构为空. ");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ errrMsg.append(this.validatePolicy(datas));
|
|
|
|
|
+ errrMsg.append(this.validateProportion(datas));
|
|
|
|
|
+ return errrMsg.toString();
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 校验保单号是否一致
|
|
|
|
|
+ *
|
|
|
|
|
+ * @author lipf
|
|
|
|
|
+ * @date 2026/8/20 10:35
|
|
|
|
|
+ */
|
|
|
|
|
+ private String validatePolicy(List<ImportContentExt> datas) {
|
|
|
|
|
+ StringBuilder errrMsg = new StringBuilder();
|
|
|
|
|
+ for (ImportContentExt data : datas) {
|
|
|
|
|
+ boolean all = false;
|
|
|
|
|
+ boolean jq = false;
|
|
|
|
|
+ boolean sy = false;
|
|
|
|
|
+ boolean jy = false;
|
|
|
|
|
+ InsOrdersPolicy insOrdersPolicy = data.getInsOrdersPolicy();
|
|
|
|
|
+ if(insOrdersPolicy == null){
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ if(!Objects.equals(insOrdersPolicy.getJqPolicyNo(), data.getJqPolicyNo())){
|
|
|
|
|
+ all = true;
|
|
|
|
|
+ jq = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ if(!Objects.equals(insOrdersPolicy.getSyPolicyNo(), data.getSyPolicyNo())){
|
|
|
|
|
+ all = true;
|
|
|
|
|
+ sy = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ if(!Objects.equals(insOrdersPolicy.getJyPolicyNo(), data.getJyPolicyNo())){
|
|
|
|
|
+ all = true;
|
|
|
|
|
+ jy = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ if(all){
|
|
|
|
|
+ errrMsg.append("车牌号为[").append(data.getLicenseNo()).append("]的保单号不一致: ");
|
|
|
|
|
+ if(jq){
|
|
|
|
|
+ errrMsg.append("交强险保单号不一致. 应收数据的交强险保单号是[").append(insOrdersPolicy.getJqPolicyNo()).append("].excel维护的交强险保单号是[").append(data.getJqPolicyNo()).append("].");
|
|
|
|
|
+ }
|
|
|
|
|
+ if(sy){
|
|
|
|
|
+ errrMsg.append("商业险保单号不一致. 应收数据的商业险保单号是[").append(insOrdersPolicy.getSyPolicyNo()).append("].excel维护的商业险保单号是[").append(data.getSyPolicyNo()).append("].");
|
|
|
|
|
+ }
|
|
|
|
|
+ if(jy){
|
|
|
|
|
+ errrMsg.append("驾意险保单号不一致. 应收数据的驾意险保单号是[").append(insOrdersPolicy.getJyPolicyNo()).append("].excel维护的驾意险保单号是[").append(data.getJyPolicyNo()).append("].");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return errrMsg.toString();
|
|
|
|
|
+ }
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 校验应收比例
|
|
|
|
|
+ *
|
|
|
|
|
+ *
|
|
|
|
|
+ * @author lipf
|
|
|
|
|
+ * @date 2026/8/20 10:27
|
|
|
|
|
+ */
|
|
|
|
|
+ private static String validateProportion(List<ImportContentExt> datas) {
|
|
|
|
|
+ StringBuilder errrMsg = new StringBuilder();
|
|
|
for (ImportContentExt data : datas) {
|
|
for (ImportContentExt data : datas) {
|
|
|
boolean all = false;
|
|
boolean all = false;
|
|
|
boolean jq = false;
|
|
boolean jq = false;
|
|
|
boolean sy = false;
|
|
boolean sy = false;
|
|
|
boolean jy = false;
|
|
boolean jy = false;
|
|
|
InsPlyIncome insPlyIncome = data.getInsPlyIncome();
|
|
InsPlyIncome insPlyIncome = data.getInsPlyIncome();
|
|
|
|
|
+ if(insPlyIncome == null){
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
String jqadd = BigDecimalUtil.add(insPlyIncome.getJqSuperviseCostsProportion(), insPlyIncome.getJqOtherCostsProportion());
|
|
String jqadd = BigDecimalUtil.add(insPlyIncome.getJqSuperviseCostsProportion(), insPlyIncome.getJqOtherCostsProportion());
|
|
|
BigDecimal jqsubtract = BigDecimalUtil.subtract(new BigDecimal(jqadd), new BigDecimal(data.getJqInletRatio()));
|
|
BigDecimal jqsubtract = BigDecimalUtil.subtract(new BigDecimal(jqadd), new BigDecimal(data.getJqInletRatio()));
|
|
|
if(BigDecimal.ZERO.compareTo(jqsubtract) != 0){
|
|
if(BigDecimal.ZERO.compareTo(jqsubtract) != 0){
|
|
@@ -5414,11 +5480,42 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
|
|
|
|
|
List<InsPlyIncome> receivableList = baseMapper.getReceivableList(receivableQueryVo);
|
|
List<InsPlyIncome> receivableList = baseMapper.getReceivableList(receivableQueryVo);
|
|
|
receivableList = this.fillOtherInfo(receivableList, null);
|
|
receivableList = this.fillOtherInfo(receivableList, null);
|
|
|
|
|
+ // 类型转换
|
|
|
|
|
+ List<ExportPlatFormReceivableVO> exportPlatFormReceivableVOS = BeanUtil.copyToList(receivableList, ExportPlatFormReceivableVO.class);
|
|
|
|
|
+ // 用ins_ply_income的id关联查到ins_ply_income_invoice_link再关联到ins_ply_income_invoice_settlement,取出结算日期、结算人
|
|
|
|
|
+ if (CollUtil.isNotEmpty(exportPlatFormReceivableVOS)) {
|
|
|
|
|
+ //1.拿到所有incomeId集合
|
|
|
|
|
+ List<Long> incomeIdList = exportPlatFormReceivableVOS.stream()
|
|
|
|
|
+ .map(item -> Long.valueOf(item.getId()))
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, InsPlyIncomeInvoiceSettlement> settlementMap = IncomeInvoiceLinkUtil.querySettlementByIncomeList(incomeIdList, insPlyIncomeInvoiceLinkMapper, insPlyIncomeInvoiceSettlementMapper);
|
|
|
|
|
+ Map<String, List<InsPlyIncomeInvoiceLink>> linkGroupByIncomeId = IncomeInvoiceLinkUtil.queryInvoiceLinkByIncomeId(incomeIdList, insPlyIncomeInvoiceLinkMapper);
|
|
|
|
|
+
|
|
|
|
|
+ //回填vo
|
|
|
|
|
+ for (ExportPlatFormReceivableVO vo : exportPlatFormReceivableVOS) {
|
|
|
|
|
+ List<InsPlyIncomeInvoiceLink> linkList = linkGroupByIncomeId.getOrDefault(vo.getId(), CollUtil.newArrayList());
|
|
|
|
|
+ if (CollUtil.isEmpty(linkList)) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ // 取第一条有结算数据的link,可按业务修改:比如取最新一条
|
|
|
|
|
+ for (InsPlyIncomeInvoiceLink link : linkList) {
|
|
|
|
|
+ InsPlyIncomeInvoiceSettlement settlement = settlementMap.get(link.getInvoiceId());
|
|
|
|
|
+ if (settlement != null) {
|
|
|
|
|
+ //结算日期
|
|
|
|
|
+ vo.setSettlementTime(LocalDateTimeUtil.of(settlement.getReceivePaymentDate()));
|
|
|
|
|
+ //结算人:创建人即为结算操作人
|
|
|
|
|
+ vo.setSettlementPerson(settlement.getCreateBy());
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// 调用动态导出
|
|
// 调用动态导出
|
|
|
return exportBaseService.upLoadFile(
|
|
return exportBaseService.upLoadFile(
|
|
|
- InsPlyIncome.class,
|
|
|
|
|
- receivableList,
|
|
|
|
|
|
|
+ ExportPlatFormReceivableVO.class,
|
|
|
|
|
+ exportPlatFormReceivableVOS,
|
|
|
"平台协议应收-批量导入-导出-" + Instant.now()
|
|
"平台协议应收-批量导入-导出-" + Instant.now()
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|