From c1e28938c9ce3d837257cec865ed3471fe5246d2 Mon Sep 17 00:00:00 2001 From: hongchao <3228015117@qq.com> Date: Fri, 23 May 2025 14:24:33 +0800 Subject: [PATCH] =?UTF-8?q?bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sgzb/base/api/domain/LeaseOutDetails.java | 2 + .../base/api/domain/SltAgreementInfo.java | 2 + .../controller/LeaseOutDetailsController.java | 5 +- .../app/service/LeaseOutDetailsService.java | 3 +- .../impl/LeaseOutDetailsServiceImpl.java | 53 +++++++++- .../controller/RepairTestInputController.java | 4 +- .../SltAgreementInfoController.java | 46 +++++---- .../mapper/SltAgreementInfoMapper.java | 4 + .../remind/service/CalcMonthlyServiceImp.java | 11 ++- .../impl/SltAgreementInfoServiceImpl.java | 33 ++++++- .../mapper/app/BackReceiveMapper.xml | 2 - .../resources/mapper/app/TmTaskMapper.xml | 6 +- .../mapper/material/BackRecordMapper.xml | 9 +- .../mapper/material/CalMonthlyMapper.xml | 6 +- .../mapper/material/LeaseRecordMapper.xml | 9 +- .../material/PurchaseCheckDetailsMapper.xml | 2 +- .../material/SltAgreementInfoMapper.xml | 98 +++++++++++++++++++ 17 files changed, 246 insertions(+), 49 deletions(-) diff --git a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/LeaseOutDetails.java b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/LeaseOutDetails.java index 593da76..7c72b95 100644 --- a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/LeaseOutDetails.java +++ b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/LeaseOutDetails.java @@ -191,4 +191,6 @@ public class LeaseOutDetails implements Serializable { private int preStoreNum; /** 操作后库存 */ private int postStoreNum; + + private String token; } diff --git a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementInfo.java b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementInfo.java index 99fbfb4..c2e29a7 100644 --- a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementInfo.java +++ b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementInfo.java @@ -235,4 +235,6 @@ public class SltAgreementInfo { @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private String endTimeTemp; + private int manageType; + } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/controller/LeaseOutDetailsController.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/controller/LeaseOutDetailsController.java index 3560169..84d10c8 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/controller/LeaseOutDetailsController.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/controller/LeaseOutDetailsController.java @@ -17,6 +17,7 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; import java.util.List; /** @@ -163,11 +164,11 @@ public class LeaseOutDetailsController extends BaseController { @Log(title = "领料出库", businessType = BusinessType.MATERIAL) //@PreventRepeatSubmit @PostMapping("/submitOutRfid") - public AjaxResult submitOutRfid(@RequestBody List recordList) { + public AjaxResult submitOutRfid(@RequestBody List recordList, HttpServletRequest request) { if (CollUtil.isEmpty(recordList)) { return AjaxResult.error("请选择要出库的机具"); } else { - return leaseOutDetailsService.submitOutRfid(recordList); + return leaseOutDetailsService.submitOutRfid(recordList,request); } } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/service/LeaseOutDetailsService.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/service/LeaseOutDetailsService.java index 6b63020..bd5dce1 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/service/LeaseOutDetailsService.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/service/LeaseOutDetailsService.java @@ -6,6 +6,7 @@ import com.bonus.sgzb.base.api.domain.LeaseOutDetails; import com.bonus.sgzb.base.api.domain.MaMachine; import com.bonus.sgzb.common.core.web.domain.AjaxResult; +import javax.servlet.http.HttpServletRequest; import java.util.List; /** @@ -74,7 +75,7 @@ public interface LeaseOutDetailsService { */ List proUseRecord(LeaseApplyDetails bean); - AjaxResult submitOutRfid(List recordList); + AjaxResult submitOutRfid(List recordList, HttpServletRequest request); List getDetailsByApplyId(TmTask id); diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/service/impl/LeaseOutDetailsServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/service/impl/LeaseOutDetailsServiceImpl.java index cae7538..870d324 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/service/impl/LeaseOutDetailsServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/service/impl/LeaseOutDetailsServiceImpl.java @@ -24,8 +24,12 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; import java.math.BigDecimal; import java.util.*; @@ -131,13 +135,60 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService { @Override @Transactional - public AjaxResult submitOutRfid(List recordList) { + public AjaxResult submitOutRfid(List recordList,HttpServletRequest request) { + HttpSession session = request.getSession(); + // 从请求头获取 token + String headerToken = request.getHeader("X-Submit-Token"); + + if (headerToken == null || headerToken.isEmpty()) { + return AjaxResult.error("缺少提交令牌"); + } + + // 获取存储所有 token 处理状态的 Map + Map tokenProcessedMap = (Map) session.getAttribute("X-Submit-Token-Processed-Map"); + if (tokenProcessedMap == null) { + tokenProcessedMap = new HashMap<>(); + session.setAttribute("X-Submit-Token-Processed-Map", tokenProcessedMap); + } + + // 检查当前 token 是否已经处理过 + if (tokenProcessedMap.getOrDefault(headerToken, false)) { + return AjaxResult.error("请不要重复提交"); + } + + // 从 session 中获取 token + String sessionToken = (String) session.getAttribute("X-Submit-Token-" + headerToken); + if (sessionToken == null) { + // 首次请求,将请求头中的 token 存入 session + session.setAttribute("X-Submit-Token-" + headerToken, headerToken); + sessionToken = headerToken; + } else if (!sessionToken.equals(headerToken)) { + // token 不匹配,判定为重复提交 + return AjaxResult.error("提交令牌不匹配,请不要重复提交"); + } + + if (recordList.isEmpty() || recordList.get(0).getToken() == null) { + return AjaxResult.error("请求参数中缺少提交令牌"); + } + + // 获取传参中的 token + String paramToken = recordList.get(0).getToken(); + + // 比较 session 中的 token 和传参中的 token + if (!sessionToken.equals(paramToken)) { + return AjaxResult.error("提交令牌不匹配,请不要重复提交"); + } + for (LeaseOutDetails bean : recordList) { AjaxResult ajaxResult = submitOut(bean); if (ajaxResult.isError()) { return ajaxResult; } } + // 处理完成后移除 session 中的 token + session.removeAttribute("X-Submit-Token-" + headerToken); + // 标记当前 token 已处理 + tokenProcessedMap.put(headerToken, true); return AjaxResult.success(); } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/RepairTestInputController.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/RepairTestInputController.java index 35286d2..16d0c75 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/RepairTestInputController.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/RepairTestInputController.java @@ -34,7 +34,7 @@ public class RepairTestInputController extends BaseController { @ApiOperation(value = "获取修试后入库列表") @GetMapping("getRepairedList") - @RequiresPermissions("warehousing:repair:list") + @RequiresPermissions("warehousing:repair:view") public TableDataInfo getRepairedList(RepairTestInputDto dto){ startPage(); List list = service.getRepairedList(dto); @@ -43,7 +43,7 @@ public class RepairTestInputController extends BaseController { @ApiOperation(value = "获取修试后入库列表") @PostMapping("getAppRepairedList") - @RequiresPermissions("warehousing:repair:list") + @RequiresPermissions("warehousing:repair:view") public AjaxResult getAppRepairedList(@Validated @RequestBody RepairTestInputDto dto){ List list = service.getRepairedList(dto); return AjaxResult.success(list); diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/SltAgreementInfoController.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/SltAgreementInfoController.java index 7e69195..8fab3ef 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/SltAgreementInfoController.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/SltAgreementInfoController.java @@ -107,9 +107,15 @@ public class SltAgreementInfoController extends BaseController { */ // @RequiresPermissions("month:record:query") @ApiOperation(value = "根据协议获取月结算清单") - @PostMapping("/getSltInfoMonth") - public AjaxResult getSltInfoMonth(@RequestBody List list) { - return AjaxResult.success(sltAgreementInfoService.getSltInfoMonth(list)); + @GetMapping("/getSltInfoMonth") + public AjaxResult getSltInfoMonth(AgreementInfo info) { + List list = new ArrayList<>(); + list.add(info); + List result = sltAgreementInfoService.getSltInfoMonth(list); + if (!result.isEmpty() && result.get(0) instanceof AjaxResult) { + return (AjaxResult) result.get(0); + } + return AjaxResult.success(result); } // @RequiresPermissions("cost:settlement:export") @@ -920,21 +926,21 @@ public class SltAgreementInfoController extends BaseController { // 关闭写入器 excelWriter.finish(); } -// @GetMapping("/taskCycle") -// public void taskCycle() { -// System.out.println("===springMVC定时器启动===="); -// try { -// -//// if (com.bonus.sgzb.common.core.utils.StringUtils.isEmpty(settlementJobDay)) { -//// calcMonthlyService.calcMonthInfo(1); -//// } else { -//// int calDay = Integer.parseInt(settlementJobDay); -// calcMonthlyService.calcMonthInfo(30); -//// } -// -// } catch (Exception e) { -// e.printStackTrace(); -// } -// System.out.println("===springMVC定时器结束===="); -// } + @GetMapping("/taskCycle") + public void taskCycle() { + System.out.println("===springMVC定时器启动===="); + try { + +// if (com.bonus.sgzb.common.core.utils.StringUtils.isEmpty(settlementJobDay)) { +// calcMonthlyService.calcMonthInfo(1); +// } else { +// int calDay = Integer.parseInt(settlementJobDay); + calcMonthlyService.calcMonthInfo(30); +// } + + } catch (Exception e) { + e.printStackTrace(); + } + System.out.println("===springMVC定时器结束===="); + } } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/SltAgreementInfoMapper.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/SltAgreementInfoMapper.java index d611939..bbfcd49 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/SltAgreementInfoMapper.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/SltAgreementInfoMapper.java @@ -70,6 +70,10 @@ public interface SltAgreementInfoMapper { List getLeaseListMonthNotNull(AgreementInfo bean); + List getLeaseListMonthOne(AgreementInfo bean); + + List getLeaseListMonthTwo(AgreementInfo bean); + List getPreScrapDetailsList(@Param("taskList") List taskList); int updateOutSourceCosts(SltAgreementInfo sltAgreementInfo); diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/remind/service/CalcMonthlyServiceImp.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/remind/service/CalcMonthlyServiceImp.java index 3bb21cf..c0c151b 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/remind/service/CalcMonthlyServiceImp.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/remind/service/CalcMonthlyServiceImp.java @@ -88,9 +88,16 @@ public class CalcMonthlyServiceImp implements CalcMonthlyService { calMonthlyMapper.insertCalcRecord(record); String taskId = record.getId(); for (AgreementInfo bean : list) { + + if (StringUtils.isNotBlank(bean.getStartTime()) && StringUtils.isNotBlank(bean.getEndTime())) { - List monthList = sltAgreementInfoMapper.getLeaseListMonthNotNull(bean); - monthList.stream().filter(Objects::nonNull); + List monthOneList = sltAgreementInfoMapper.getLeaseListMonthOne(bean); + List monthTwoList = sltAgreementInfoMapper.getLeaseListMonthTwo(bean); + monthOneList.stream().filter(Objects::nonNull); + monthTwoList.stream().filter(Objects::nonNull); + List monthList = new ArrayList<>(); + monthList.addAll(monthOneList); + monthList.addAll(monthTwoList); for (SltAgreementInfo sltAgreementInfo : monthList) { ProjectMonthCosts projectMonthCosts = new ProjectMonthCosts(); diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/SltAgreementInfoServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/SltAgreementInfoServiceImpl.java index be8bd07..b877fa1 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/SltAgreementInfoServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/SltAgreementInfoServiceImpl.java @@ -509,9 +509,11 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { //租赁费用列表 for (AgreementInfo agreementInfo : list) { // 如果选择了最新月份则需要查数据 - if (StringUtils.isNotBlank(agreementInfo.getStartTime()) && StringUtils.isNotBlank(agreementInfo.getEndTime()) && DateTimeHelper.getNowMonth().equals(DateTimeHelper.getNowMonth(DateTimeHelper.parse(agreementInfo.getEndTime(), "yyyy-MM")))) { - List listMonth = getLeaseListMonth(agreementInfo, num); - leaseListMonth.addAll(listMonth); + if (StringUtils.isNotBlank(agreementInfo.getStartTime()) && StringUtils.isNotBlank(agreementInfo.getEndTime()) + && DateTimeHelper.getNowMonth().compareTo(DateTimeHelper.getNowMonth(DateTimeHelper.parse(agreementInfo.getStartTime(), "yyyy-MM"))) <= 0) { +// List listMonth = getLeaseListMonth(agreementInfo, num); +// leaseListMonth.addAll(listMonth); + return Collections.singletonList(new AjaxResult(500, "当前月暂未结算")); } else { // 如果不传日期或传以往日期 则查定时任务记录的数据 List listMonth = getLeaseJobListMonth(agreementInfo); @@ -533,7 +535,30 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { monthCost.setCodeNum(num++); for (String id : monthCost.getIds().split(",")) { monthCost.setId(Long.parseLong(id)); - monthDetails.addAll(calMonthlyMapper.getMonthDetails(monthCost)); + List details = calMonthlyMapper.getMonthDetails(monthCost); + // 合并相同typeId、manageType=0、startTime和endTime相同的数据 + Map mergedMap = new HashMap<>(); + for (SltAgreementInfo detail : details) { + String key = detail.getTypeId() + "_" + detail.getStartTime() + "_" + detail.getEndTime(); + + if (detail.getManageType() == 0 && mergedMap.containsKey(key)) { + SltAgreementInfo mergedDetail = mergedMap.get(key); + // 数量相加 + mergedDetail.setNum(mergedDetail.getNum() + detail.getNum()); + // 费用相加 + mergedDetail.setCosts(mergedDetail.getCosts().add(detail.getCosts())); + // 实际费用相加 + mergedDetail.setRealCosts(mergedDetail.getRealCosts().add(detail.getRealCosts())); + // 备注相加 + if (detail.getRemark() != null && !detail.getRemark().isEmpty()) { + mergedDetail.setRemark(mergedDetail.getRemark() + "、" + detail.getRemark()); + } + } else { + mergedMap.put(key, detail); + } + } + monthDetails.addAll(new ArrayList<>(mergedMap.values())); +// monthDetails.addAll(calMonthlyMapper.getMonthDetails(monthCost)); } monthCost.setNode(monthDetails); } diff --git a/sgzb-modules/sgzb-material/src/main/resources/mapper/app/BackReceiveMapper.xml b/sgzb-modules/sgzb-material/src/main/resources/mapper/app/BackReceiveMapper.xml index 18fae20..3cef240 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/mapper/app/BackReceiveMapper.xml +++ b/sgzb-modules/sgzb-material/src/main/resources/mapper/app/BackReceiveMapper.xml @@ -758,7 +758,6 @@ IFNULL(aa.back_num,0) as in_completed_back_num, IFNULL(bb.finished_back_num, 0) as finished_back_num, mt.manage_type as manageType, - mtk.user_id, CONCAT('NSJJ',mt.`code`,mt.model_code) as `code`, bad.remark as remark FROM @@ -769,7 +768,6 @@ group by agreement_id,type_id) sai on tta.agreement_id=sai.agreement_id and sai.type_id=bad.type_id LEFT JOIN ma_type mt on mt.type_id=bad.type_id LEFT JOIN ma_type mt2 ON mt2.type_id=mt.parent_id - LEFT JOIN ma_type_keeper mtk on mt.type_id=mtk.type_id LEFT JOIN ( SELECT type_id as typeId, diff --git a/sgzb-modules/sgzb-material/src/main/resources/mapper/app/TmTaskMapper.xml b/sgzb-modules/sgzb-material/src/main/resources/mapper/app/TmTaskMapper.xml index fe35a25..6eb1e3f 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/mapper/app/TmTaskMapper.xml +++ b/sgzb-modules/sgzb-material/src/main/resources/mapper/app/TmTaskMapper.xml @@ -1312,11 +1312,9 @@ LEFT JOIN bm_project_lot bpl ON bpl.lot_id = bai.project_id LEFT JOIN bm_unit_info bui ON bui.unit_id = bai.unit_id LEFT JOIN lease_apply_details lad on lai.id = lad.parennt_id - LEFT JOIN ma_type_keeper mtk on lad.type_id = mtk.type_id + WHERE tt.task_status in(33,34,35) - - and mtk.user_id = #{userId} - + and tt.code like concat('%', #{code}, '%') diff --git a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/BackRecordMapper.xml b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/BackRecordMapper.xml index 3386991..75e7bf7 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/BackRecordMapper.xml +++ b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/BackRecordMapper.xml @@ -117,12 +117,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" LEFT JOIN ma_type mt ON mt.type_id = bcd.type_id LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id LEFT JOIN ma_machine mm ON mm.ma_id = bcd.ma_id --- LEFT JOIN sys_user su ON su.user_id = baif.back_person where 1 = 1 - and (baif.`code` like concat('%',#{keyWord},'%') or - mm.ma_code like concat('%',#{keyWord},'%') or - su.nick_name like concat('%',#{keyWord},'%')) + and (baif.`code` like concat('%',#{keyWord,jdbcType=VARCHAR},'%') or + mm.ma_code like concat('%',#{keyWord,jdbcType=VARCHAR},'%') or + mt.unit_name like concat('%',#{keyWord,jdbcType=VARCHAR},'%') or + mt2.type_name like concat('%',#{keyWord,jdbcType=VARCHAR},'%') or + mt.type_name like concat('%',#{keyWord,jdbcType=VARCHAR},'%')) and mt2.type_name like concat('%',#{typeName},'%') diff --git a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/CalMonthlyMapper.xml b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/CalMonthlyMapper.xml index 6a49406..73bac60 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/CalMonthlyMapper.xml +++ b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/CalMonthlyMapper.xml @@ -43,7 +43,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" LEFT JOIN bm_unit_info bui ON bui.unit_id = bai.unit_id WHERE 1=1 - and spm.month = #{endTime} + and spm.month = DATE_FORMAT(#{endTime}, '%Y-%m') AND pmc.agreement_id = #{agreementId} @@ -53,6 +53,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + +