|
|
@@ -3,6 +3,7 @@ package com.jzg.organization.service.impl;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.collection.ListUtil;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.excel.EasyExcel;
|
|
|
import com.alibaba.nacos.common.utils.CollectionUtils;
|
|
|
@@ -61,6 +62,7 @@ import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.function.BiConsumer;
|
|
|
import java.util.function.Function;
|
|
|
+import java.util.function.Predicate;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
@@ -178,6 +180,188 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
return page;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 应收数据二次过滤
|
|
|
+ *
|
|
|
+ * @param incomeDataVO 过滤条件
|
|
|
+ * @author lipf
|
|
|
+ * @date 2026/5/12 14:22
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public HttpResult<List<InsPlyIncome>> queryIncomeDatas(IncomeDataVO incomeDataVO) {
|
|
|
+ log.info("应收数据的二次过滤:incomeDataVO=[{}]", JSONUtil.toJsonStr(incomeDataVO));
|
|
|
+ List<String> orderNos = incomeDataVO.getOrderNos();
|
|
|
+ String companyId = incomeDataVO.getCompanyId();
|
|
|
+// if(CollUtil.isEmpty(orderNos)){
|
|
|
+// log.info("应收数据的二次过滤: 订单号不能为空");
|
|
|
+// return HttpResult.error("请勾选要处理的订单信息");
|
|
|
+// }
|
|
|
+// if (StrUtil.isEmpty(companyId)) {
|
|
|
+// log.info("应收数据的二次过滤. 保司不能为空");
|
|
|
+// return HttpResult.error("保司不能为空");
|
|
|
+// }
|
|
|
+// if(!"and".equalsIgnoreCase(incomeDataVO.getLogicJudge()) && "20".equalsIgnoreCase(incomeDataVO.getLogicJudge())){
|
|
|
+// log.info("应收数据的二次过滤. 逻辑条件必须是and或or");
|
|
|
+// return HttpResult.error("逻辑条件必须是and或or");
|
|
|
+// }
|
|
|
+ List<InsPlyIncome> incomes = baseMapper.queryIncomeDatasByOrderIds(orderNos,companyId);
|
|
|
+ log.info("根据订单号和保司id查询出[{}]条记录。 orderNos =[{}],companyId=[{}]",CollUtil.size(incomes), JSONUtil.toJsonStr(orderNos), companyId);
|
|
|
+ List<InsPlyIncome> filterIncomes = new ArrayList<>();
|
|
|
+ if(CollUtil.isEmpty(incomeDataVO.getSearchList())){
|
|
|
+ filterIncomes = incomes;
|
|
|
+ }else{
|
|
|
+ List<IncomeDataVO.SearchVO> searchParams = incomeDataVO.getSearchList();
|
|
|
+ if(CollUtil.isNotEmpty(searchParams)){
|
|
|
+ Map<String, IncomeDataVO.SearchVO> searchVOMap = searchParams.stream()
|
|
|
+ .filter(action -> StrUtil.isNotEmpty(action.getName()))
|
|
|
+ .collect(Collectors.toMap(IncomeDataVO.SearchVO::getName, Function.identity(), (ole_item, new_item) -> ole_item));
|
|
|
+ Set<String> names =searchVOMap.keySet();
|
|
|
+
|
|
|
+ // 保险公司
|
|
|
+ Predicate<InsPlyIncome> companyIdPredicate = insPlyIncome -> {
|
|
|
+ if(!names.contains(IncomeDataVO.SearchVO.companyId)){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ IncomeDataVO.SearchVO searchVO = searchVOMap.get(IncomeDataVO.SearchVO.companyId);
|
|
|
+ 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> companyIds = Arrays.asList(search.split(","));
|
|
|
+ return companyIds.contains(insPlyIncome.getCompanyId());
|
|
|
+ }
|
|
|
+ if("不等于".equalsIgnoreCase(type) || "不包含".equalsIgnoreCase(type)){
|
|
|
+ List<String> companyIds = Arrays.asList(search.split(","));
|
|
|
+ return !companyIds.contains(insPlyIncome.getCompanyId());
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ };
|
|
|
+ // 签单时间
|
|
|
+ Predicate<InsPlyIncome> signDatePredicate = insPlyIncome -> {
|
|
|
+ String signingTime = insPlyIncome.getSigningTime();
|
|
|
+ if(StrUtil.isEmpty(signingTime)){
|
|
|
+ // 签单时间如果为空,说明是数据问题 先返回去,让业务去处理
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if(!names.contains(IncomeDataVO.SearchVO.signDate)){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ IncomeDataVO.SearchVO searchVO = searchVOMap.get(IncomeDataVO.SearchVO.ptlAgreement);
|
|
|
+ String type = searchVO.getType();
|
|
|
+ String search = searchVO.getSearch();
|
|
|
+ if("为空".equals(type)|| "不为空".equals(type)){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ // 如果填写的查询条件,不完善,则该条件不进行过滤
|
|
|
+ if(StrUtil.isEmpty(search)){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if("大于等于".equals(type)){
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return true;
|
|
|
+ };
|
|
|
+ // 出单协议
|
|
|
+ Predicate<InsPlyIncome> ptlAgreementPredicate = insPlyIncome -> {
|
|
|
+ if(!names.contains(IncomeDataVO.SearchVO.ptlAgreement)){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ IncomeDataVO.SearchVO searchVO = searchVOMap.get(IncomeDataVO.SearchVO.ptlAgreement);
|
|
|
+ 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> ptlAgrements = Arrays.asList(search.split(","));
|
|
|
+ return ptlAgrements.contains(insPlyIncome.getAgreementId());
|
|
|
+ }
|
|
|
+ if("不等于".equalsIgnoreCase(type) || "不包含".equalsIgnoreCase(type)){
|
|
|
+ List<String> ptlAgrements = Arrays.asList(search.split(","));
|
|
|
+ return !ptlAgrements.contains(insPlyIncome.getAgreementId());
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ };
|
|
|
+
|
|
|
+ // 订单类型 entryStatus
|
|
|
+ Predicate<InsPlyIncome> orderTypePredicate = insPlyIncome -> {
|
|
|
+ if(!names.contains(IncomeDataVO.SearchVO.companyId)){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ IncomeDataVO.SearchVO searchVO = searchVOMap.get(IncomeDataVO.SearchVO.companyId);
|
|
|
+ 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> entryStatus = Arrays.asList(search.split(","));
|
|
|
+ return entryStatus.contains(insPlyIncome.getEntryStatus());
|
|
|
+ }
|
|
|
+ if("不等于".equalsIgnoreCase(type) || "不包含".equalsIgnoreCase(type)){
|
|
|
+ List<String> entryStatus = Arrays.asList(search.split(","));
|
|
|
+ return !entryStatus.contains(insPlyIncome.getEntryStatus());
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ };
|
|
|
+
|
|
|
+ // 签单年份
|
|
|
+ Predicate<InsPlyIncome> signYearPredicate = insPlyIncome ->{
|
|
|
+ if(!names.contains(IncomeDataVO.SearchVO.companyId)){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ IncomeDataVO.SearchVO searchVO = searchVOMap.get(IncomeDataVO.SearchVO.companyId);
|
|
|
+ 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> signYears = Arrays.asList(search.split(","));
|
|
|
+ return signYears.contains(insPlyIncome.getSignYear());
|
|
|
+ }
|
|
|
+ if("不等于".equalsIgnoreCase(type) || "不包含".equalsIgnoreCase(type)){
|
|
|
+ List<String> signYears = Arrays.asList(search.split(","));
|
|
|
+ return !signYears.contains(insPlyIncome.getSigningTime());
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ };
|
|
|
+ if("and".equalsIgnoreCase(incomeDataVO.getLogicJudge())){
|
|
|
+ Predicate<InsPlyIncome> and = companyIdPredicate.and(signDatePredicate).and(ptlAgreementPredicate).and(orderTypePredicate).and(signYearPredicate);
|
|
|
+ filterIncomes = incomes.stream().filter(and).toList();
|
|
|
+ }else if ("or".equalsIgnoreCase(incomeDataVO.getLogicJudge())){
|
|
|
+ Predicate<InsPlyIncome> or = companyIdPredicate.or(signDatePredicate).or(ptlAgreementPredicate).or(orderTypePredicate).or(signYearPredicate);
|
|
|
+ filterIncomes = incomes.stream().filter(or).toList();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ filterIncomes = this.fillOtherInfo(filterIncomes);
|
|
|
+ return HttpResult.ok(filterIncomes);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 填充必要的字段
|