费用未结算报表增加批量查询,优化执行速度
This commit is contained in:
parent
6a2d78c315
commit
0c0bf6426c
|
|
@ -6,13 +6,16 @@ import java.math.RoundingMode;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.bonus.common.biz.config.ListPagingUtil;
|
import com.bonus.common.biz.config.ListPagingUtil;
|
||||||
import com.bonus.common.biz.config.PoiOutPage;
|
import com.bonus.common.biz.config.PoiOutPage;
|
||||||
|
import com.bonus.common.core.exception.ServiceException;
|
||||||
import com.bonus.common.core.utils.ServletUtils;
|
import com.bonus.common.core.utils.ServletUtils;
|
||||||
import com.bonus.common.log.enums.OperaType;
|
import com.bonus.common.log.enums.OperaType;
|
||||||
import com.bonus.common.security.utils.SecurityUtils;
|
import com.bonus.common.security.utils.SecurityUtils;
|
||||||
|
|
@ -1445,32 +1448,42 @@ public class SltAgreementInfoController extends BaseController {
|
||||||
// ----------- 定义返回集合 ------------
|
// ----------- 定义返回集合 ------------
|
||||||
List<SltInfoVo> resultList = new ArrayList<>();
|
List<SltInfoVo> resultList = new ArrayList<>();
|
||||||
|
|
||||||
// ----------- 查询列表 ---------------
|
try {
|
||||||
List<SltAgreementInfo> list = sltAgreementInfoService.getSltReportList(query);
|
// ----------- 查询列表 ---------------
|
||||||
|
List<SltAgreementInfo> list = sltAgreementInfoService.getSltReportList(query);
|
||||||
|
|
||||||
// ----------- 遍历列表,设置默认值 ---------------
|
// ----------- 遍历列表,设置默认值 ---------------
|
||||||
Byte settlementType = sltAgreementInfoService.checkLoginUserHasSettlementPermission();
|
Byte settlementType = sltAgreementInfoService.checkLoginUserHasSettlementPermission();
|
||||||
// 设置结算权限,控制展示
|
// 设置结算权限,控制展示
|
||||||
list.forEach(info -> info.setSettlementType(settlementType));
|
list.forEach(info -> info.setSettlementType(settlementType));
|
||||||
|
|
||||||
List<SltInfoVo> dataList = new ArrayList<>();
|
List<SltInfoVo> dataList = new ArrayList<>();
|
||||||
SltInfoVo bean = new SltInfoVo();
|
SltInfoVo bean = new SltInfoVo();
|
||||||
for (SltAgreementInfo info : list) {
|
|
||||||
SltInfoVo vo = sltAgreementInfoService.getSltInfo(info);
|
// 把每个对象的agreementId设置成集合,避免重复查询
|
||||||
if (vo == null) { continue; }
|
list.forEach(info -> {
|
||||||
vo.setAgreementId(info.getAgreementId());
|
info.setAgreementIds(list.stream().map(SltAgreementInfo::getAgreementId).collect(Collectors.toList()));
|
||||||
vo.setAgreementCode(info.getAgreementCode());
|
SltInfoVo vo = sltAgreementInfoService.getSltInfoReportBatch(info);
|
||||||
dataList.add(vo);
|
if (vo != null && !ObjectUtil.isEmpty(vo)) {
|
||||||
|
vo.setAgreementId(info.getAgreementId());
|
||||||
|
vo.setAgreementCode(info.getAgreementCode());
|
||||||
|
dataList.add(vo);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 移除领、修、丢、废4项都没有明细的结算信息
|
||||||
|
dataList.removeIf(vo -> CollectionUtils.isEmpty(vo.getLeaseList())
|
||||||
|
&& CollectionUtils.isEmpty(vo.getRepairList())
|
||||||
|
&& CollectionUtils.isEmpty(vo.getScrapList())
|
||||||
|
&& CollectionUtils.isEmpty(vo.getLoseList())
|
||||||
|
);
|
||||||
|
|
||||||
|
return getDataTable(dataList);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} finally {
|
||||||
|
sltAgreementInfoService.clearCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 移除领、修、丢、废4项都没有明细的结算信息
|
|
||||||
dataList.removeIf(vo -> CollectionUtils.isEmpty(vo.getLeaseList())
|
|
||||||
&& CollectionUtils.isEmpty(vo.getRepairList())
|
|
||||||
&& CollectionUtils.isEmpty(vo.getScrapList())
|
|
||||||
&& CollectionUtils.isEmpty(vo.getLoseList())
|
|
||||||
);
|
|
||||||
|
|
||||||
return getDataTable(dataList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,11 @@ public class SltAgreementInfo extends BaseEntity {
|
||||||
@ApiModelProperty(value = "协议id")
|
@ApiModelProperty(value = "协议id")
|
||||||
private Long agreementId;
|
private Long agreementId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 协议id集合,用作查询一次性查多个协议的数据
|
||||||
|
*/
|
||||||
|
private List<Long> agreementIds;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 协议编号
|
* 协议编号
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,8 @@ public class SltAgreementReduce extends BaseEntity {
|
||||||
@ApiModelProperty(value = "协议id")
|
@ApiModelProperty(value = "协议id")
|
||||||
private Long agreementId;
|
private Long agreementId;
|
||||||
|
|
||||||
|
private List<Long> agreementIds;
|
||||||
|
|
||||||
/** 结算单号(例如:JM202402-1) */
|
/** 结算单号(例如:JM202402-1) */
|
||||||
@Excel(name = "减免单号", readConverterExp = "例=如:JM202402-1")
|
@Excel(name = "减免单号", readConverterExp = "例=如:JM202402-1")
|
||||||
private String code;
|
private String code;
|
||||||
|
|
|
||||||
|
|
@ -91,14 +91,30 @@ public interface SltAgreementInfoMapper {
|
||||||
|
|
||||||
int insSltInfo(@Param("record") LeaseOutDetails record, @Param("agreementId")String agreementId, @Param("ma") Type ma);
|
int insSltInfo(@Param("record") LeaseOutDetails record, @Param("agreementId")String agreementId, @Param("ma") Type ma);
|
||||||
|
|
||||||
|
// 查询一个协议号的领料详情
|
||||||
List<SltAgreementInfo> getLeaseList(SltAgreementInfo bean);
|
List<SltAgreementInfo> getLeaseList(SltAgreementInfo bean);
|
||||||
|
|
||||||
|
// 查询多个协议号的领料详情
|
||||||
|
List<SltAgreementInfo> getLeaseListBatch(SltAgreementInfo bean);
|
||||||
|
|
||||||
|
// 查询一个协议号的维修详情(根据taskIds)
|
||||||
List<SltAgreementInfo> getRepairDetailsList(@Param("info") SltAgreementInfo info, @Param("taskList") List<TmTask> taskList);
|
List<SltAgreementInfo> getRepairDetailsList(@Param("info") SltAgreementInfo info, @Param("taskList") List<TmTask> taskList);
|
||||||
|
|
||||||
|
// 查询多个协议号的维修详情
|
||||||
|
List<SltAgreementInfo> getRepairDetailsListBatch(@Param("info") SltAgreementInfo info, @Param("taskList") List<TmTask> taskList);
|
||||||
|
|
||||||
|
// 查询一个协议号的报废详情(根据taskIds)
|
||||||
List<SltAgreementInfo> getScrapDetailsList(@Param("info") SltAgreementInfo info, @Param("taskList") List<TmTask> taskList);
|
List<SltAgreementInfo> getScrapDetailsList(@Param("info") SltAgreementInfo info, @Param("taskList") List<TmTask> taskList);
|
||||||
|
|
||||||
|
// 查询多个协议号的报废详情
|
||||||
|
List<SltAgreementInfo> getScrapDetailsListBatch(@Param("info") SltAgreementInfo info);
|
||||||
|
|
||||||
|
// 获取一个协议号的丢失详情
|
||||||
List<SltAgreementInfo> getLoseList(SltAgreementInfo bean);
|
List<SltAgreementInfo> getLoseList(SltAgreementInfo bean);
|
||||||
|
|
||||||
|
// 获取多个协议号的丢失详情
|
||||||
|
List<SltAgreementInfo> getLoseListBatch(SltAgreementInfo bean);
|
||||||
|
|
||||||
int updateRelation(SltAgreementApply apply);
|
int updateRelation(SltAgreementApply apply);
|
||||||
|
|
||||||
int updateApply(SltAgreementApply apply);
|
int updateApply(SltAgreementApply apply);
|
||||||
|
|
|
||||||
|
|
@ -34,11 +34,14 @@ public interface SltAgreementReduceMapper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据协议Id查询减免明细
|
* 根据协议Id查询减免明细
|
||||||
* @param bean
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
List<SltAgreementReduce> getReductionList(SltAgreementReduce bean);
|
List<SltAgreementReduce> getReductionList(SltAgreementReduce bean);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量查询减免明细
|
||||||
|
*/
|
||||||
|
List<SltAgreementReduce> getReductionListBatch(SltAgreementReduce bean);
|
||||||
|
|
||||||
List<SltAgreementReduce> selectAuditReduceList(SltAgreementReduce sltAgreement);
|
List<SltAgreementReduce> selectAuditReduceList(SltAgreementReduce sltAgreement);
|
||||||
|
|
||||||
void deleteReduceDetail(Long id);
|
void deleteReduceDetail(Long id);
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,13 @@ public interface ISltAgreementInfoService {
|
||||||
|
|
||||||
public SltInfoVo getSltInfo(SltAgreementInfo info);
|
public SltInfoVo getSltInfo(SltAgreementInfo info);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量查询结算信息列表 -- 未结算报表专用
|
||||||
|
*/
|
||||||
|
SltInfoVo getSltInfoReportBatch(SltAgreementInfo list);
|
||||||
|
|
||||||
|
void clearCache();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查登陆用户是否有结算权限
|
* 检查登陆用户是否有结算权限
|
||||||
* @return 管理的结算类型码
|
* @return 管理的结算类型码
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,12 @@ package com.bonus.material.settlement.service.impl;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.regex.Pattern;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import com.bonus.common.biz.constant.GlobalConstants;
|
import com.bonus.common.biz.constant.GlobalConstants;
|
||||||
import com.bonus.common.biz.domain.ProjectTreeBuild;
|
import com.bonus.common.biz.domain.ProjectTreeBuild;
|
||||||
import com.bonus.common.biz.domain.ProjectTreeNode;
|
import com.bonus.common.biz.domain.ProjectTreeNode;
|
||||||
import com.bonus.common.biz.enums.TmTaskTypeEnum;
|
|
||||||
import com.bonus.common.core.exception.ServiceException;
|
import com.bonus.common.core.exception.ServiceException;
|
||||||
import com.bonus.common.core.utils.DateUtils;
|
import com.bonus.common.core.utils.DateUtils;
|
||||||
import com.bonus.common.core.web.domain.AjaxResult;
|
import com.bonus.common.core.web.domain.AjaxResult;
|
||||||
|
|
@ -21,7 +20,6 @@ import com.bonus.material.basic.mapper.BmAgreementInfoMapper;
|
||||||
import com.bonus.material.basic.mapper.BmConfigMapper;
|
import com.bonus.material.basic.mapper.BmConfigMapper;
|
||||||
import com.bonus.material.common.domain.dto.SelectDto;
|
import com.bonus.material.common.domain.dto.SelectDto;
|
||||||
import com.bonus.material.common.domain.vo.AgreementVo;
|
import com.bonus.material.common.domain.vo.AgreementVo;
|
||||||
import com.bonus.material.countersign.domain.SignConfigVo;
|
|
||||||
import com.bonus.material.settlement.domain.SltAgreementApply;
|
import com.bonus.material.settlement.domain.SltAgreementApply;
|
||||||
import com.bonus.material.settlement.domain.SltAgreementReduce;
|
import com.bonus.material.settlement.domain.SltAgreementReduce;
|
||||||
import com.bonus.material.settlement.domain.SltAgreementRelation;
|
import com.bonus.material.settlement.domain.SltAgreementRelation;
|
||||||
|
|
@ -76,6 +74,17 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
|
||||||
@Resource
|
@Resource
|
||||||
private SltAgreementReduceMapper sltAgreementRecudceMapper;
|
private SltAgreementReduceMapper sltAgreementRecudceMapper;
|
||||||
|
|
||||||
|
// 定义线程级缓存
|
||||||
|
private static final ThreadLocal<List<SltAgreementInfo>> leaseListCache = new ThreadLocal<>();
|
||||||
|
// 丢失结算列表缓存
|
||||||
|
private static final ThreadLocal<List<SltAgreementInfo>> lostListCache = new ThreadLocal<>();
|
||||||
|
// 费用减免列表缓存
|
||||||
|
private static final ThreadLocal<List<SltAgreementReduce>> reductionListCache = new ThreadLocal<>();
|
||||||
|
// 维修结算列表缓存
|
||||||
|
private static final ThreadLocal<List<SltAgreementInfo>> repairListCache = new ThreadLocal<>();
|
||||||
|
// 报废结算列表缓存
|
||||||
|
private static final ThreadLocal<List<SltAgreementInfo>> scrapListCache = new ThreadLocal<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询结算信息
|
* 查询结算信息
|
||||||
*
|
*
|
||||||
|
|
@ -87,6 +96,16 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
|
||||||
return sltAgreementInfoMapper.selectSltAgreementInfoById(id);
|
return sltAgreementInfoMapper.selectSltAgreementInfoById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 暴露 public 方法给外层清理缓存、防止内存泄漏
|
||||||
|
@Override
|
||||||
|
public void clearCache() {
|
||||||
|
leaseListCache.remove();
|
||||||
|
lostListCache.remove();
|
||||||
|
reductionListCache.remove();
|
||||||
|
repairListCache.remove();
|
||||||
|
scrapListCache.remove();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询结算信息列表
|
* 查询结算信息列表
|
||||||
*
|
*
|
||||||
|
|
@ -182,11 +201,130 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
|
||||||
return sltInfoVo;
|
return sltInfoVo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量查询结算信息列表 -- 未结算报表专用
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public SltInfoVo getSltInfoReportBatch(SltAgreementInfo info) {
|
||||||
|
SltInfoVo sltInfoVo = new SltInfoVo();
|
||||||
|
sltInfoVo.setUnitName(info.getUnitName());
|
||||||
|
sltInfoVo.setProjectName(info.getProjectName());
|
||||||
|
BigDecimal leaseCost = BigDecimal.ZERO, repairCost= BigDecimal.ZERO ;
|
||||||
|
BigDecimal scrapCost= BigDecimal.ZERO, loseCost= BigDecimal.ZERO, reducCost= BigDecimal.ZERO;
|
||||||
|
|
||||||
|
if (leaseListCache.get() == null) {
|
||||||
|
// 调用一次性批量租赁费用查询
|
||||||
|
leaseListCache.set(sltAgreementInfoMapper.getLeaseListBatch(info));
|
||||||
|
}
|
||||||
|
if (lostListCache.get() == null) {
|
||||||
|
// 调用一次性批量丢失费用查询
|
||||||
|
lostListCache.set(sltAgreementInfoMapper.getLoseListBatch(info));
|
||||||
|
}
|
||||||
|
if (reductionListCache.get() == null) {
|
||||||
|
// 调用一次性批量减免费用查询
|
||||||
|
SltAgreementReduce bean =new SltAgreementReduce();
|
||||||
|
bean.setAgreementIds(info.getAgreementIds());
|
||||||
|
reductionListCache.set(sltAgreementRecudceMapper.getReductionListBatch(bean));
|
||||||
|
}
|
||||||
|
if (repairListCache.get() == null) {
|
||||||
|
// 调用一次性批量维修费用查询
|
||||||
|
repairListCache.set(sltAgreementInfoMapper.getRepairDetailsListBatch(info, null));
|
||||||
|
}
|
||||||
|
if (scrapListCache.get() == null) {
|
||||||
|
// 调用一次性批量报废费用查询
|
||||||
|
scrapListCache.set(sltAgreementInfoMapper.getScrapDetailsListBatch(info));
|
||||||
|
}
|
||||||
|
// 查询租赁费用列表
|
||||||
|
List<SltAgreementInfo> leaseList = getLeaseBtachList(info);
|
||||||
|
//维修费用列表
|
||||||
|
List<SltAgreementInfo> repairList = getRepairListBatch(info);
|
||||||
|
//报废费用列表
|
||||||
|
List<SltAgreementInfo> scrapList = getScrapListBatch(info);
|
||||||
|
//丢失费用列表
|
||||||
|
List<SltAgreementInfo> loseList = getLoseListBatch(info);
|
||||||
|
//费用减免列表
|
||||||
|
List<SltAgreementReduce> reductionList = getReductionListBatch(info);
|
||||||
|
|
||||||
|
if (CollectionUtils.isEmpty(leaseList) && CollectionUtils.isEmpty(repairList)
|
||||||
|
&& CollectionUtils.isEmpty(scrapList) && CollectionUtils.isEmpty(loseList)
|
||||||
|
&& CollectionUtils.isEmpty(reductionList))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
sltInfoVo.setLeaseList(leaseList);
|
||||||
|
sltInfoVo.setRepairList(repairList);
|
||||||
|
sltInfoVo.setScrapList(scrapList);
|
||||||
|
sltInfoVo.setLoseList(loseList);
|
||||||
|
sltInfoVo.setReductionList(reductionList);
|
||||||
|
for (SltAgreementInfo lease : leaseList) {
|
||||||
|
if (lease.getCosts() != null) {
|
||||||
|
leaseCost = leaseCost.add(lease.getCosts());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (SltAgreementInfo repair : repairList) {
|
||||||
|
if(repair.getCosts() != null && (repair.getPartType().equals("收费"))) {
|
||||||
|
repairCost = repairCost.add(repair.getCosts());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (SltAgreementInfo scrap : scrapList) {
|
||||||
|
if(scrap.getCosts() != null && (scrap.getPartType().equals("收费"))) {
|
||||||
|
scrapCost = scrapCost.add(scrap.getCosts());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (SltAgreementInfo lose : loseList) {
|
||||||
|
if(lose.getCosts()!=null){
|
||||||
|
loseCost = loseCost.add(lose.getCosts());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (SltAgreementReduce reduction : reductionList) {
|
||||||
|
if(reduction.getLeaseMoney()!=null){
|
||||||
|
reducCost = reducCost.add(reduction.getLeaseMoney());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sltInfoVo.setLeaseCost(leaseCost);
|
||||||
|
sltInfoVo.setRepairCost(repairCost);
|
||||||
|
sltInfoVo.setScrapCost(scrapCost);
|
||||||
|
sltInfoVo.setLoseCost(loseCost);
|
||||||
|
sltInfoVo.setReductionCost(reducCost);
|
||||||
|
List<SltAgreementRelation> relations = getRelations(leaseList, repairList, scrapList, loseList, info);
|
||||||
|
sltInfoVo.setRelations(relations);
|
||||||
|
return sltInfoVo;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SltAgreementApply> getSltExam(SltAgreementInfo bean) {
|
public List<SltAgreementApply> getSltExam(SltAgreementInfo bean) {
|
||||||
return sltAgreementInfoMapper.getSltExam(bean);
|
return sltAgreementInfoMapper.getSltExam(bean);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量分批查询工具
|
||||||
|
*
|
||||||
|
* @param ids 待查询的id集合
|
||||||
|
* @param batchSize 每次查询的最大数量
|
||||||
|
* @param queryFunc 查询函数,比如 service::queryByIds
|
||||||
|
* @return 合并后的结果集合
|
||||||
|
* @param <T> id类型
|
||||||
|
* @param <R> 返回结果类型
|
||||||
|
*/
|
||||||
|
public static <T, R> List<R> batchQuery(List<T> ids, int batchSize, Function<List<T>, List<R>> queryFunc) {
|
||||||
|
if (ids == null || ids.isEmpty()) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<R> result = new ArrayList<>();
|
||||||
|
int total = ids.size();
|
||||||
|
for (int i = 0; i < total; i += batchSize) {
|
||||||
|
int end = Math.min(i + batchSize, total);
|
||||||
|
List<T> subList = ids.subList(i, end);
|
||||||
|
List<R> batchResult = queryFunc.apply(subList);
|
||||||
|
if (batchResult != null && !batchResult.isEmpty()) {
|
||||||
|
result.addAll(batchResult);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增结算信息
|
* 新增结算信息
|
||||||
*
|
*
|
||||||
|
|
@ -241,6 +379,9 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
|
||||||
return sltAgreementInfoMapper.deleteSltAgreementInfoById(id);
|
return sltAgreementInfoMapper.deleteSltAgreementInfoById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取单个协议的领料明细
|
||||||
|
*/
|
||||||
public List<SltAgreementInfo> getLeaseList(SltAgreementInfo info) {
|
public List<SltAgreementInfo> getLeaseList(SltAgreementInfo info) {
|
||||||
List<SltAgreementInfo> oneOfList = sltAgreementInfoMapper.getLeaseList(info);
|
List<SltAgreementInfo> oneOfList = sltAgreementInfoMapper.getLeaseList(info);
|
||||||
List<SltAgreementInfo> leaseList = new ArrayList<>(oneOfList);
|
List<SltAgreementInfo> leaseList = new ArrayList<>(oneOfList);
|
||||||
|
|
@ -266,6 +407,36 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
|
||||||
return leaseList;
|
return leaseList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取多个协议的领料明细
|
||||||
|
*/
|
||||||
|
public List<SltAgreementInfo> getLeaseBtachList(SltAgreementInfo info) {
|
||||||
|
// 领料就不要每次都执行
|
||||||
|
List<SltAgreementInfo> leaseList = leaseListCache.get()
|
||||||
|
.stream()
|
||||||
|
.filter(bean -> bean.getAgreementId().equals(info.getAgreementId())).collect(Collectors.toList());
|
||||||
|
|
||||||
|
for (SltAgreementInfo bean : leaseList) {
|
||||||
|
if (null == bean.getLeasePrice()) {
|
||||||
|
bean.setLeasePrice(BigDecimal.ZERO);
|
||||||
|
} else {
|
||||||
|
bean.setLeasePrice(bean.getLeasePrice().setScale(2, RoundingMode.HALF_UP));
|
||||||
|
}
|
||||||
|
if (null == bean.getNum()) {
|
||||||
|
bean.setNum(BigDecimal.ZERO);
|
||||||
|
}
|
||||||
|
if (null == bean.getLeaseDays()) {
|
||||||
|
bean.setLeaseDay(0L);
|
||||||
|
}
|
||||||
|
BigDecimal leasePrice = bean.getLeasePrice();
|
||||||
|
BigDecimal num = bean.getNum();
|
||||||
|
BigDecimal leaseDays = new BigDecimal(bean.getLeaseDays());
|
||||||
|
BigDecimal costs = leasePrice.multiply(num).multiply(leaseDays).setScale(GlobalConstants.INT_2, RoundingMode.HALF_UP);
|
||||||
|
bean.setCosts(costs);
|
||||||
|
}
|
||||||
|
return leaseList;
|
||||||
|
}
|
||||||
|
|
||||||
public List<SltAgreementInfo> getRepairList(SltAgreementInfo info) {
|
public List<SltAgreementInfo> getRepairList(SltAgreementInfo info) {
|
||||||
List<SltAgreementInfo> repairList = new ArrayList<>();
|
List<SltAgreementInfo> repairList = new ArrayList<>();
|
||||||
List<TmTask> taskList = taskMapper.getTaskIdList(info);
|
List<TmTask> taskList = taskMapper.getTaskIdList(info);
|
||||||
|
|
@ -276,6 +447,13 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
|
||||||
return repairList;
|
return repairList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<SltAgreementInfo> getRepairListBatch(SltAgreementInfo info) {
|
||||||
|
return repairListCache.get()
|
||||||
|
.stream()
|
||||||
|
.filter(bean -> bean.getAgreementId().equals(info.getAgreementId()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
public List<SltAgreementInfo> getScrapList(SltAgreementInfo info) {
|
public List<SltAgreementInfo> getScrapList(SltAgreementInfo info) {
|
||||||
List<SltAgreementInfo> scrapList = new ArrayList<>();
|
List<SltAgreementInfo> scrapList = new ArrayList<>();
|
||||||
List<TmTask> taskList = taskMapper.getTaskIdList(info);
|
List<TmTask> taskList = taskMapper.getTaskIdList(info);
|
||||||
|
|
@ -286,6 +464,16 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
|
||||||
return scrapList;
|
return scrapList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取多个协议的报废明细
|
||||||
|
*/
|
||||||
|
public List<SltAgreementInfo> getScrapListBatch(SltAgreementInfo info) {
|
||||||
|
return scrapListCache.get()
|
||||||
|
.stream()
|
||||||
|
.filter(bean -> bean.getAgreementId().equals(info.getAgreementId()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
public List<SltAgreementInfo> getLoseList(SltAgreementInfo info) {
|
public List<SltAgreementInfo> getLoseList(SltAgreementInfo info) {
|
||||||
List<SltAgreementInfo> oneOfList = sltAgreementInfoMapper.getLoseList(info);
|
List<SltAgreementInfo> oneOfList = sltAgreementInfoMapper.getLoseList(info);
|
||||||
List<SltAgreementInfo> loseList = new ArrayList<>(oneOfList);
|
List<SltAgreementInfo> loseList = new ArrayList<>(oneOfList);
|
||||||
|
|
@ -307,17 +495,47 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
|
||||||
return loseList;
|
return loseList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<SltAgreementInfo> getLoseListBatch(SltAgreementInfo info) {
|
||||||
|
List<SltAgreementInfo> loseList = lostListCache.get()
|
||||||
|
.stream()
|
||||||
|
.filter(bean -> bean.getAgreementId().equals(info.getAgreementId()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
for (SltAgreementInfo bean : loseList) {
|
||||||
|
if (null == bean.getBuyPrice()) {
|
||||||
|
bean.setBuyPrice(BigDecimal.ZERO);
|
||||||
|
}
|
||||||
|
if (null == bean.getNum()) {
|
||||||
|
bean.setNum(BigDecimal.ZERO);
|
||||||
|
}
|
||||||
|
BigDecimal buyPrice = bean.getBuyPrice();
|
||||||
|
BigDecimal num = bean.getNum();
|
||||||
|
// 原价 x 数量
|
||||||
|
BigDecimal costs = buyPrice.multiply(num);
|
||||||
|
//计算租赁费用
|
||||||
|
bean.setCosts(costs);
|
||||||
|
}
|
||||||
|
return loseList;
|
||||||
|
}
|
||||||
|
|
||||||
private List<SltAgreementReduce> getReductionList(SltAgreementInfo info) {
|
private List<SltAgreementReduce> getReductionList(SltAgreementInfo info) {
|
||||||
SltAgreementReduce bean =new SltAgreementReduce();
|
SltAgreementReduce bean =new SltAgreementReduce();
|
||||||
bean.setAgreementId(info.getAgreementId());
|
bean.setAgreementId(info.getAgreementId());
|
||||||
return sltAgreementRecudceMapper.getReductionList(bean);
|
return sltAgreementRecudceMapper.getReductionList(bean);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<SltAgreementReduce> getReductionListBatch(SltAgreementInfo info) {
|
||||||
|
return reductionListCache.get()
|
||||||
|
.stream()
|
||||||
|
.filter(bean -> bean.getAgreementId().equals(info.getAgreementId()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
private List<SltAgreementRelation> getRelations(List<SltAgreementInfo> leaseList, List<SltAgreementInfo> repairList,
|
private List<SltAgreementRelation> getRelations(List<SltAgreementInfo> leaseList, List<SltAgreementInfo> repairList,
|
||||||
List<SltAgreementInfo> scrapList, List<SltAgreementInfo> loseList,
|
List<SltAgreementInfo> scrapList, List<SltAgreementInfo> loseList,
|
||||||
SltAgreementInfo sltInfo) {
|
SltAgreementInfo sltInfo)
|
||||||
|
{
|
||||||
List<SltAgreementRelation> relations = new ArrayList<>();
|
List<SltAgreementRelation> relations = new ArrayList<>();
|
||||||
// for (SltAgreementInfo info : list) {
|
|
||||||
SltAgreementRelation relation = new SltAgreementRelation();
|
SltAgreementRelation relation = new SltAgreementRelation();
|
||||||
BigDecimal loseCost = BigDecimal.ZERO;
|
BigDecimal loseCost = BigDecimal.ZERO;
|
||||||
BigDecimal leaseCost = BigDecimal.ZERO;
|
BigDecimal leaseCost = BigDecimal.ZERO;
|
||||||
|
|
@ -360,7 +578,6 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
|
||||||
relation.setScrapCost(scrapCost);
|
relation.setScrapCost(scrapCost);
|
||||||
relation.setLoseCost(loseCost);
|
relation.setLoseCost(loseCost);
|
||||||
relations.add(relation);
|
relations.add(relation);
|
||||||
// }
|
|
||||||
return relations;
|
return relations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -811,6 +811,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="projectId != null and projectId != ''">
|
<if test="projectId != null and projectId != ''">
|
||||||
and bp.pro_id = #{projectId}
|
and bp.pro_id = #{projectId}
|
||||||
</if>
|
</if>
|
||||||
|
<if test="agreementCode != null and agreementCode != ''">
|
||||||
|
and bai.agreement_code = #{agreementCode}
|
||||||
|
</if>
|
||||||
<if test="startTime != null and endTime != null">
|
<if test="startTime != null and endTime != null">
|
||||||
and saa.create_time between #{startTime} and #{endTime}
|
and saa.create_time between #{startTime} and #{endTime}
|
||||||
</if>
|
</if>
|
||||||
|
|
@ -855,4 +858,185 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
GROUP BY bai.agreement_id
|
GROUP BY bai.agreement_id
|
||||||
ORDER BY bai.create_time desc
|
ORDER BY bai.create_time desc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getLeaseListBatch" resultType="com.bonus.material.settlement.domain.SltAgreementInfo">
|
||||||
|
SELECT
|
||||||
|
res.agreementId,
|
||||||
|
res.unitName,
|
||||||
|
res.projectName,
|
||||||
|
res.companyId,
|
||||||
|
res.typeId,
|
||||||
|
res.typeName,
|
||||||
|
res.modelName,
|
||||||
|
res.mtUnitName,
|
||||||
|
res.leasePrice,
|
||||||
|
SUM(res.num) as num,
|
||||||
|
res.startTime,
|
||||||
|
res.endTime,
|
||||||
|
res.leaseDays
|
||||||
|
FROM
|
||||||
|
(
|
||||||
|
select sai.id,
|
||||||
|
sai.agreement_id as agreementId,
|
||||||
|
bui.unit_name as unitName,
|
||||||
|
bp.pro_name as projectName,
|
||||||
|
sai.company_id as companyId,
|
||||||
|
sai.type_id as typeId,
|
||||||
|
mt1.type_name as typeName,
|
||||||
|
mt.type_name as modelName,
|
||||||
|
mt.unit_name as mtUnitName,
|
||||||
|
sai.lease_price as leasePrice,
|
||||||
|
sai.num as num,
|
||||||
|
DATE(sai.start_time) as startTime,
|
||||||
|
DATE(sai.end_time) as endTime,
|
||||||
|
DATEDIFF(IF(sai.end_time is null,CURDATE(),sai.end_time), sai.start_time) + 1 as leaseDays
|
||||||
|
from
|
||||||
|
slt_agreement_info sai
|
||||||
|
LEFT JOIN bm_agreement_info bai on sai.agreement_id = bai.agreement_id
|
||||||
|
LEFT JOIN bm_project bp ON bp.pro_id = bai.project_id
|
||||||
|
LEFT JOIN bm_unit bui ON bui.unit_id = bai.unit_id
|
||||||
|
left join ma_type mt on sai.type_id = mt.type_id
|
||||||
|
left join ma_type mt1 on mt.parent_id = mt1.type_id
|
||||||
|
<where>
|
||||||
|
<if test="agreementIds != null and agreementIds.size > 0">
|
||||||
|
and sai.agreement_id in
|
||||||
|
<foreach collection="agreementIds" index="index" item="item" open="(" separator="," close=")">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test="settlementType != null and settlementType != 0">
|
||||||
|
and mt.jiju_type = #{settlementType}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
) res
|
||||||
|
GROUP BY res.agreementId,res.typeId,res.startTime,res.endTime
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getLoseListBatch" resultType="com.bonus.material.settlement.domain.SltAgreementInfo">
|
||||||
|
SELECT
|
||||||
|
res.agreementId,
|
||||||
|
res.unitName,
|
||||||
|
res.projectName,
|
||||||
|
res.companyId,
|
||||||
|
res.typeId,
|
||||||
|
res.typeName,
|
||||||
|
res.modelName,
|
||||||
|
res.mtUnitName,
|
||||||
|
res.buyPrice,
|
||||||
|
SUM(res.num) as num,
|
||||||
|
res.startTime,
|
||||||
|
res.endTime,
|
||||||
|
res.leaseDays
|
||||||
|
FROM
|
||||||
|
(
|
||||||
|
select sai.id,
|
||||||
|
sai.agreement_id as agreementId,
|
||||||
|
bui.unit_name as unitName,
|
||||||
|
bp.pro_name as projectName,
|
||||||
|
sai.company_id as companyId,
|
||||||
|
sai.type_id as typeId,
|
||||||
|
sai.ma_id as maId,
|
||||||
|
mt1.type_name as typeName,
|
||||||
|
mt.type_name as modelName,
|
||||||
|
mt.unit_name as mtUnitName,
|
||||||
|
mt.buy_price as buyPrice,
|
||||||
|
sai.num as num,
|
||||||
|
sai.start_time as startTime,
|
||||||
|
sai.end_time as endTime,
|
||||||
|
DATEDIFF(sai.end_time, sai.start_time) + 1 as leaseDays
|
||||||
|
from
|
||||||
|
slt_agreement_info sai
|
||||||
|
LEFT JOIN bm_agreement_info bai on sai.agreement_id = bai.agreement_id
|
||||||
|
LEFT JOIN bm_project bp ON bp.pro_id = bai.project_id
|
||||||
|
LEFT JOIN bm_unit bui ON bui.unit_id = bai.unit_id
|
||||||
|
left join ma_type mt on sai.type_id = mt.type_id
|
||||||
|
left join ma_type mt1 on mt.parent_id = mt1.type_id
|
||||||
|
where
|
||||||
|
sai.agreement_id in
|
||||||
|
<foreach item="item" index="index" collection="agreementIds" open="(" separator="," close=")">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
and sai.end_time is null
|
||||||
|
<if test="settlementType != null and settlementType != 0">
|
||||||
|
and mt.jiju_type = #{settlementType}
|
||||||
|
</if>
|
||||||
|
) res
|
||||||
|
GROUP BY res.typeId
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getRepairDetailsListBatch" resultType="com.bonus.material.settlement.domain.SltAgreementInfo">
|
||||||
|
select
|
||||||
|
tta.agreement_id as agreementId,
|
||||||
|
bui.unit_name as unitName,
|
||||||
|
bp.pro_name as projectName,
|
||||||
|
rc.id as costId,
|
||||||
|
rc.type_id as typeId,
|
||||||
|
rc.ma_id as maId,
|
||||||
|
mt1.type_name as typeName,
|
||||||
|
mt.type_name as modelName,
|
||||||
|
mt.unit_name as mtUnitName,
|
||||||
|
rc.repair_num as num,
|
||||||
|
rc.costs as costs,
|
||||||
|
case rc.part_type when '0' then '不收费' when '1' then '收费' else '' end as partType,
|
||||||
|
case rc.repair_type when '1' then '内部维修' when '2' then '返厂维修' else '' end as repairType,
|
||||||
|
rc.company_id as companyId,
|
||||||
|
case rc.status when '0' then '未审核' when '1' then '已审核' when '2' then '已驳回' else '' end as repairStatus
|
||||||
|
from repair_cost rc
|
||||||
|
left join tm_task_agreement tta on rc.task_id = tta.task_id
|
||||||
|
left join tm_task tt on rc.task_id = tt.task_id
|
||||||
|
left join bm_agreement_info bai on tta.agreement_id = bai.agreement_id
|
||||||
|
left join bm_project bp ON bp.pro_id = bai.project_id
|
||||||
|
left join bm_unit bui ON bui.unit_id = bai.unit_id
|
||||||
|
left join ma_type mt on rc.type_id = mt.type_id
|
||||||
|
left join ma_type mt1 on mt.parent_id = mt1.type_id
|
||||||
|
where rc.status in ('0','1')
|
||||||
|
and rc.repair_type in ('1','2')
|
||||||
|
<if test="info.settlementType != null and info.settlementType != 0">
|
||||||
|
and mt.jiju_type = #{info.settlementType}
|
||||||
|
</if>
|
||||||
|
<if test="info.agreementIds != null and info.agreementIds.size > 0">
|
||||||
|
and tta.agreement_id in
|
||||||
|
<foreach item="aid" collection="info.agreementIds" open="(" separator="," close=")">
|
||||||
|
#{aid}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getScrapDetailsListBatch" resultType="com.bonus.material.settlement.domain.SltAgreementInfo">
|
||||||
|
select
|
||||||
|
tta.agreement_id as agreementId,
|
||||||
|
bui.unit_name as unitName,
|
||||||
|
bp.pro_name as projectName,
|
||||||
|
rc.id as costId,
|
||||||
|
rc.type_id as typeId,
|
||||||
|
rc.ma_id as maId,
|
||||||
|
mt1.type_name as typeName,
|
||||||
|
mt.type_name as modelName,
|
||||||
|
mt.unit_name as mtUnitName,
|
||||||
|
rc.repair_num as num,
|
||||||
|
rc.costs as costs,
|
||||||
|
case rc.part_type when '0' then '不收费' when '1' then '收费' else '' end as partType,
|
||||||
|
case rc.repair_type when '1' then '内部维修' when '2' then '返厂维修' when '3' then '其他维修' else '' end as repairType,
|
||||||
|
rc.company_id as companyId,
|
||||||
|
case rc.status when '0' then '未审核' when '1' then '已审核' when '2' then '已驳回' else '' end as repairStatus
|
||||||
|
from repair_cost rc
|
||||||
|
LEFT JOIN tm_task_agreement tta on rc.task_id = tta.task_id
|
||||||
|
LEFT JOIN tm_task tt on rc.task_id = tt.task_id
|
||||||
|
LEFT JOIN bm_agreement_info bai on tta.agreement_id = bai.agreement_id
|
||||||
|
LEFT JOIN bm_project bp ON bp.pro_id = bai.project_id
|
||||||
|
LEFT JOIN bm_unit bui ON bui.unit_id = bai.unit_id
|
||||||
|
LEFT JOIN ma_type mt on rc.type_id = mt.type_id
|
||||||
|
LEFT JOIN ma_type mt1 on mt.parent_id = mt1.type_id
|
||||||
|
where rc.status in ('0','1')
|
||||||
|
and rc.repair_type = '3'
|
||||||
|
<if test="info.settlementType != null and info.settlementType != 0">
|
||||||
|
and mt.jiju_type = #{info.settlementType}
|
||||||
|
</if>
|
||||||
|
<if test="info.agreementIds != null and info.agreementIds.size > 0">
|
||||||
|
and tta.agreement_id in
|
||||||
|
<foreach item="aid" collection="info.agreementIds" open="(" separator="," close=")">
|
||||||
|
#{aid}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
|
|
@ -305,5 +305,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
WHERE sra.agreement_id = #{agreementId}
|
WHERE sra.agreement_id = #{agreementId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getReductionListBatch" resultType="com.bonus.material.settlement.domain.SltAgreementReduce">
|
||||||
|
SELECT mt2.type_name as maName,
|
||||||
|
mt.type_name as maModel,
|
||||||
|
mt.unit_name as maUnit,
|
||||||
|
srd.lease_price as leasePrice,
|
||||||
|
srd.reduce_num as reduceNum,
|
||||||
|
srd.start_time as startTime,
|
||||||
|
srd.end_time as endTime,
|
||||||
|
srd.days as days,
|
||||||
|
srd.lease_money as leaseMoney,
|
||||||
|
sra.remark
|
||||||
|
FROM slt_reduce_apply sra
|
||||||
|
LEFT JOIN slt_reduce_details srd on sra.id = srd.apply_id
|
||||||
|
LEFT JOIN ma_type mt on mt.type_id = srd.type_id
|
||||||
|
LEFT JOIN ma_type mt2 on mt2.type_id = mt.parent_id
|
||||||
|
<where>
|
||||||
|
<if test="agreementIds != null and agreementIds.size > 0">
|
||||||
|
sra.agreement_id in
|
||||||
|
<foreach item="item" index="index" collection="agreementIds" open="(" separator="," close=")">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue