From 339dc16de60fe7c24326980689b6268324edd1f4 Mon Sep 17 00:00:00 2001 From: syruan <15555146157@163.com> Date: Mon, 20 Oct 2025 15:46:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E7=BB=93=E7=AE=97=E7=94=B3?= =?UTF-8?q?=E8=AF=B7=E6=9F=A5=E8=AF=A2=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/biz/utils/RequestContext.java | 4 ++ .../SltAgreementInfoController.java | 38 +++++----- .../impl/SltAgreementInfoServiceImpl.java | 1 + .../settlement/SltAgreementInfoMapper.xml | 69 +++++++++++-------- 4 files changed, 65 insertions(+), 47 deletions(-) diff --git a/bonus-common-biz/src/main/java/com/bonus/common/biz/utils/RequestContext.java b/bonus-common-biz/src/main/java/com/bonus/common/biz/utils/RequestContext.java index 3294c1d2..e08f6197 100644 --- a/bonus-common-biz/src/main/java/com/bonus/common/biz/utils/RequestContext.java +++ b/bonus-common-biz/src/main/java/com/bonus/common/biz/utils/RequestContext.java @@ -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 diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/controller/SltAgreementInfoController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/controller/SltAgreementInfoController.java index ac12d626..dbb3655e 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/controller/SltAgreementInfoController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/controller/SltAgreementInfoController.java @@ -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 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 leaseList = new ArrayList<>(); + BigDecimal totalCostLease = BigDecimal.ZERO; List oneOfListLease = sltAgreementInfoMapper.getLeaseList(sltAgreementInfo); - leaseList.addAll(oneOfListLease); + List 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 lease = Convert.toList(SltLeaseInfo.class, leaseList); //丢失费用明细 BigDecimal totalCostLose = BigDecimal.valueOf(0.00); - List loseList = new ArrayList<>(); List oneOfListLose = sltAgreementInfoMapper.getLoseList(sltAgreementInfo); - loseList.addAll(oneOfListLose); + List 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 lose = Convert.toList(SltLeaseInfo.class, loseList); //维修费用明细 - BigDecimal totalCostRepair = BigDecimal.valueOf(0.00); + BigDecimal totalCostRepair = BigDecimal.ZERO; List repairList = new ArrayList<>(); List taskListRepair = taskMapper.getTaskIdList(sltAgreementInfo); if (null != taskListRepair && !taskListRepair.isEmpty()) { @@ -1352,7 +1354,7 @@ public class SltAgreementInfoController extends BaseController { List repair = Convert.toList(SltLeaseInfo.class, repairList); //报废费用明细 - BigDecimal totalCostScrap = BigDecimal.valueOf(0.00); + BigDecimal totalCostScrap = BigDecimal.ZERO; List scrapList = new ArrayList<>(); List taskListScrap = taskMapper.getTaskIdList(sltAgreementInfo); if (null != taskListScrap && !taskListScrap.isEmpty()) { diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/impl/SltAgreementInfoServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/impl/SltAgreementInfoServiceImpl.java index efae3563..30f9125e 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/impl/SltAgreementInfoServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/impl/SltAgreementInfoServiceImpl.java @@ -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()); } diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/settlement/SltAgreementInfoMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/settlement/SltAgreementInfoMapper.xml index 9981d7b8..67639cd7 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/settlement/SltAgreementInfoMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/settlement/SltAgreementInfoMapper.xml @@ -217,35 +217,46 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"