修正结算申请查询逻辑
This commit is contained in:
parent
a818ce9d87
commit
339dc16de6
|
|
@ -3,6 +3,10 @@ package com.bonus.common.biz.utils;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author syruan
|
||||
* 线程级全局Map缓存对象
|
||||
*/
|
||||
public class RequestContext {
|
||||
|
||||
// 每个线程独立维护一个 Map
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ import java.util.ArrayList;
|
|||
@Slf4j
|
||||
public class SltAgreementInfoController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
@Resource
|
||||
private ISltAgreementInfoService sltAgreementInfoService;
|
||||
|
||||
@Resource
|
||||
|
|
@ -100,11 +100,17 @@ public class SltAgreementInfoController extends BaseController {
|
|||
public AjaxResult getSltAgreementInfo4Project(SltAgreementInfo bean) {
|
||||
Integer pageIndex = Convert.toInt(ServletUtils.getParameter("pageNum"), 1);
|
||||
Integer pageSize = Convert.toInt(ServletUtils.getParameter("pageSize"), 10);
|
||||
int loginUserHasSettlementPermission = sltAgreementInfoService.checkLoginUserHasSettlementPermission();
|
||||
if (bean != null) {
|
||||
bean.setSettlementType(loginUserHasSettlementPermission);
|
||||
} else {
|
||||
bean = new SltAgreementInfo();
|
||||
bean.setSettlementType(loginUserHasSettlementPermission);
|
||||
}
|
||||
List<SltAgreementInfo> list = sltAgreementInfoService.getSltAgreementInfo4Project(bean);
|
||||
ListPagingUtil paginated = ListPagingUtil.paging(pageIndex, pageSize, list);
|
||||
// 新增外层计算-- 计算当前分页数据的各条目费用
|
||||
if (CollectionUtils.isNotEmpty(paginated.getRows())) {
|
||||
int loginUserHasSettlementPermission = sltAgreementInfoService.checkLoginUserHasSettlementPermission();
|
||||
for (Object row : paginated.getRows()) {
|
||||
if (row instanceof SltAgreementInfo) {
|
||||
((SltAgreementInfo) row).setSettlementType(loginUserHasSettlementPermission);
|
||||
|
|
@ -114,7 +120,9 @@ public class SltAgreementInfoController extends BaseController {
|
|||
sltInfoVo = sltAgreementInfoService.getSltInfo((SltAgreementInfo) row);
|
||||
}
|
||||
if (sltInfoVo != null) {
|
||||
list.get(list.indexOf(row)).setCosts(sltAgreementInfoService.sum(sltInfoVo.getLeaseCost(), sltInfoVo.getRepairCost(), sltInfoVo.getScrapCost(), sltInfoVo.getLoseCost()));
|
||||
list.get(list.indexOf(row)).setCosts(sltAgreementInfoService.sum(sltInfoVo.getLeaseCost(),
|
||||
sltInfoVo.getRepairCost(), sltInfoVo.getScrapCost(), sltInfoVo.getLoseCost())
|
||||
);
|
||||
}
|
||||
}
|
||||
ListPagingUtil resultPaging = ListPagingUtil.paging(pageIndex, pageSize, list);
|
||||
|
|
@ -1286,16 +1294,15 @@ public class SltAgreementInfoController extends BaseController {
|
|||
String unitName = sltAgreementInfo.getUnitName();
|
||||
|
||||
//租赁费用明细
|
||||
BigDecimal totalCostLease = BigDecimal.valueOf(0.00);
|
||||
List<SltAgreementInfo> leaseList = new ArrayList<>();
|
||||
BigDecimal totalCostLease = BigDecimal.ZERO;
|
||||
List<SltAgreementInfo> oneOfListLease = sltAgreementInfoMapper.getLeaseList(sltAgreementInfo);
|
||||
leaseList.addAll(oneOfListLease);
|
||||
List<SltAgreementInfo> leaseList = new ArrayList<>(oneOfListLease);
|
||||
for (SltAgreementInfo bean : leaseList) {
|
||||
if (null == bean.getLeasePrice()) {
|
||||
bean.setLeasePrice(BigDecimal.valueOf(0.00));
|
||||
bean.setLeasePrice(BigDecimal.ZERO);
|
||||
}
|
||||
if (null == bean.getNum()) {
|
||||
bean.setNum(BigDecimal.valueOf(0L));
|
||||
bean.setNum(BigDecimal.ZERO);
|
||||
}
|
||||
if (null == bean.getLeaseDays()) {
|
||||
bean.setLeaseDay(0L);
|
||||
|
|
@ -1304,19 +1311,16 @@ public class SltAgreementInfoController extends BaseController {
|
|||
BigDecimal num = bean.getNum();
|
||||
BigDecimal leaseDays = new BigDecimal(bean.getLeaseDays());
|
||||
BigDecimal costs = leasePrice.multiply(num).multiply(leaseDays);
|
||||
if(costs!=null){
|
||||
totalCostLease = totalCostLease.add(costs);
|
||||
}
|
||||
totalCostLease = totalCostLease.add(costs);
|
||||
bean.setCosts(costs);
|
||||
}
|
||||
List<SltLeaseInfo> lease = Convert.toList(SltLeaseInfo.class, leaseList);
|
||||
|
||||
//丢失费用明细
|
||||
BigDecimal totalCostLose = BigDecimal.valueOf(0.00);
|
||||
List<SltAgreementInfo> loseList = new ArrayList<>();
|
||||
|
||||
List<SltAgreementInfo> oneOfListLose = sltAgreementInfoMapper.getLoseList(sltAgreementInfo);
|
||||
loseList.addAll(oneOfListLose);
|
||||
List<SltAgreementInfo> loseList = new ArrayList<>(oneOfListLose);
|
||||
for (SltAgreementInfo bean : loseList) {
|
||||
if (null == bean.getBuyPrice()) {
|
||||
bean.setBuyPrice(BigDecimal.valueOf(0.00));
|
||||
|
|
@ -1328,16 +1332,14 @@ public class SltAgreementInfoController extends BaseController {
|
|||
BigDecimal num = bean.getNum();
|
||||
// 原价 x 数量
|
||||
BigDecimal costs = buyPrice.multiply(num);
|
||||
if(costs!=null){
|
||||
totalCostLose = totalCostLose.add(costs);
|
||||
}
|
||||
totalCostLose = totalCostLose.add(costs);
|
||||
//计算租赁费用
|
||||
bean.setCosts(costs);
|
||||
}
|
||||
List<SltLeaseInfo> lose = Convert.toList(SltLeaseInfo.class, loseList);
|
||||
|
||||
//维修费用明细
|
||||
BigDecimal totalCostRepair = BigDecimal.valueOf(0.00);
|
||||
BigDecimal totalCostRepair = BigDecimal.ZERO;
|
||||
List<SltAgreementInfo> repairList = new ArrayList<>();
|
||||
List<TmTask> taskListRepair = taskMapper.getTaskIdList(sltAgreementInfo);
|
||||
if (null != taskListRepair && !taskListRepair.isEmpty()) {
|
||||
|
|
@ -1352,7 +1354,7 @@ public class SltAgreementInfoController extends BaseController {
|
|||
List<SltLeaseInfo> repair = Convert.toList(SltLeaseInfo.class, repairList);
|
||||
|
||||
//报废费用明细
|
||||
BigDecimal totalCostScrap = BigDecimal.valueOf(0.00);
|
||||
BigDecimal totalCostScrap = BigDecimal.ZERO;
|
||||
List<SltAgreementInfo> scrapList = new ArrayList<>();
|
||||
List<TmTask> taskListScrap = taskMapper.getTaskIdList(sltAgreementInfo);
|
||||
if (null != taskListScrap && !taskListScrap.isEmpty()) {
|
||||
|
|
|
|||
|
|
@ -1259,6 +1259,7 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
|
|||
// 返回结果
|
||||
return periodCostResultVos;
|
||||
} catch (Exception e) {
|
||||
System.err.println(e.getMessage());
|
||||
log.error("查询区间费用失败:", e);
|
||||
throw new ServiceException("查询区间费用失败:" + e.getMessage());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -217,35 +217,46 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</select>
|
||||
|
||||
<select id="getSltAgreementInfo4Project" resultType="com.bonus.material.settlement.domain.SltAgreementInfo">
|
||||
SELECT bai.agreement_id as agreementId, bai.agreement_code as agreementCode, bai.is_slt as isSlt,
|
||||
bui.unit_id as unitId,bui.unit_name as unitName, bp.pro_id as projectId , bp.pro_name as projectName,
|
||||
saa.remark,bai.protocol, saa.cost as costs,
|
||||
case when (saa.id is null or saa.status = '0') then '0' when saa.status = '1' then '1' when saa.status = '2' then '2' when saa.status = '3' then '3' end as sltStatus
|
||||
FROM bm_agreement_info bai
|
||||
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 slt_agreement_apply saa on saa.agreement_id = bai.agreement_id
|
||||
where bai.status = '1' AND bui.type_id != '1731'
|
||||
<if test="unitIds != null and unitIds.size() > 0">
|
||||
and bui.unit_id in
|
||||
<foreach item="item" index="index" collection="unitIds" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="projectId != null and projectId != ''">
|
||||
and bp.pro_id = #{projectId}
|
||||
</if>
|
||||
<if test="sltStatus != null">
|
||||
and bai.is_slt = #{sltStatus}
|
||||
</if>
|
||||
<if test="sltStatus == null">
|
||||
and bai.is_slt in (0,3)
|
||||
</if>
|
||||
<if test="agreementCode != null">
|
||||
and bai.agreement_code like concat('%',#{agreementCode},'%')
|
||||
</if>
|
||||
GROUP BY bai.agreement_id
|
||||
ORDER BY bai.create_time desc
|
||||
SELECT *
|
||||
FROM (
|
||||
SELECT
|
||||
bai.agreement_id as agreementId, bai.agreement_code as agreementCode, bai.is_slt as isSlt,
|
||||
bui.unit_id as unitId, bui.unit_name as unitName, bp.pro_id as projectId , bp.pro_name as projectName,
|
||||
saa.remark, bai.protocol, saa.cost as costs,
|
||||
case
|
||||
when (saa.id is null or saa.status = '0') then '0'
|
||||
when saa.status = '1' then '1'
|
||||
when saa.status = '2' then '2'
|
||||
when saa.status = '3' then '3'
|
||||
end as sltStatus
|
||||
FROM bm_agreement_info bai
|
||||
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 slt_agreement_apply saa on saa.agreement_id = bai.agreement_id and saa.settlement_type = #{settlementType}
|
||||
WHERE bai.status = '1' AND bui.type_id != '1731'
|
||||
<if test="unitIds != null and unitIds.size() > 0">
|
||||
and bui.unit_id in
|
||||
<foreach item="item" index="index" collection="unitIds" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="projectId != null and projectId != ''">
|
||||
and bp.pro_id = #{projectId}
|
||||
</if>
|
||||
<if test="agreementCode != null">
|
||||
and bai.agreement_code like concat('%',#{agreementCode},'%')
|
||||
</if>
|
||||
GROUP BY bai.agreement_id
|
||||
) t
|
||||
<where>
|
||||
<if test="sltStatus != null">
|
||||
AND t.sltStatus = #{sltStatus}
|
||||
</if>
|
||||
<if test="sltStatus == null">
|
||||
AND (t.sltStatus in ('0','3') or t.sltStatus is null)
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY t.agreementId DESC
|
||||
</select>
|
||||
|
||||
<select id="getSltExam" resultType="com.bonus.material.settlement.domain.SltAgreementApply">
|
||||
|
|
|
|||
Loading…
Reference in New Issue