From 8a86d6428206e7243f6eaf6475da369a80b7f39b Mon Sep 17 00:00:00 2001 From: hongchao <3228015117@qq.com> Date: Sun, 14 Sep 2025 11:24:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9D=90=E6=96=99=E7=AB=99=E9=A2=86=E6=96=99?= =?UTF-8?q?=E5=8D=95=E8=AF=A6=E6=83=85=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/LeaseApplyInfoController.java | 12 + .../lease/service/ILeaseApplyInfoService.java | 10 + .../impl/LeaseApplyInfoServiceImpl.java | 245 ++++++++++++++++++ .../material/clz/MaterialLeaseInfoMapper.xml | 2 +- 4 files changed, 268 insertions(+), 1 deletion(-) diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/controller/LeaseApplyInfoController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/controller/LeaseApplyInfoController.java index b8ba1fe2..99578d34 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/controller/LeaseApplyInfoController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/controller/LeaseApplyInfoController.java @@ -181,6 +181,18 @@ public class LeaseApplyInfoController extends BaseController { return success(leaseApplyInfoService.selectLeaseApplyInfoById(id, keyWord, publishTask)); } + /** + * 获取材料站领料任务详细信息 + */ + @ApiOperation(value = "获取材料站领料任务详细信息") + //@RequiresPermissions("lease:info:query") + @GetMapping(value = "/getClz/{id}") + public AjaxResult getClzInfo(@NotNull(message = "领料任务ID不能为空") @PathVariable("id") Long id, + @RequestParam(value = "keyWord", required = false) String keyWord, + @RequestParam(value = "publishTask", required = false) String publishTask) { + return success(leaseApplyInfoService.selectClzLeaseApplyInfoById(id, keyWord, publishTask)); + } + /** * 获取领料出库详细信息 * @param bean diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/ILeaseApplyInfoService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/ILeaseApplyInfoService.java index bf9e1d38..bcabeb37 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/ILeaseApplyInfoService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/ILeaseApplyInfoService.java @@ -32,6 +32,16 @@ public interface ILeaseApplyInfoService { */ LeaseApplyRequestVo selectLeaseApplyInfoById(Long id, String keyword, String publishTask); + /** + * 查询领料任务 + * + * @param id 领料任务主键 + * @param keyword keyword 关键字 + * @param publishTask 发布批次 + * @return 领料任务 + */ + LeaseApplyRequestVo selectClzLeaseApplyInfoById(Long id, String keyword, String publishTask); + /** * 查询领料任务列表 * diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseApplyInfoServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseApplyInfoServiceImpl.java index c0bdf6ab..99d376cb 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseApplyInfoServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseApplyInfoServiceImpl.java @@ -336,6 +336,251 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService { } } + + /** + * 查询领料任务 + * + * @param id 领料任务主键 + * @return 领料任务 + */ + @Override + public LeaseApplyRequestVo selectClzLeaseApplyInfoById(Long id, String keyword, String publishTask) { + // 性能监控开始 + long startTime = System.currentTimeMillis(); + Map stepTimes = new LinkedHashMap<>(); + Set userRoles = SecurityUtils.getLoginUser().getRoles(); + + log.info("=== selectLeaseApplyInfoById开始执行,id: {}, keyword: {}, publishTask: {}", id, keyword, publishTask); + + try { + // 步骤1: 初始化查询对象和获取用户信息 + long step1Start = System.currentTimeMillis(); + LeaseApplyInfo leaseApplyInfo = new LeaseApplyInfo(); + leaseApplyInfo.setId(id); + Long userId = SecurityUtils.getLoginUser().getUserid(); + stepTimes.put("初始化和获取用户信息", System.currentTimeMillis() - step1Start); + + // 步骤2: 查询用户绑定的物资类型 + long step2Start = System.currentTimeMillis(); + //List typeIdList = leaseApplyInfoMapper.selectTypeIdList(userId); + stepTimes.put("查询用户绑定物资类型", System.currentTimeMillis() - step2Start); + + // 步骤3: 设置查询参数 + long step3Start = System.currentTimeMillis(); + + if (StringUtils.isNotBlank(keyword)) { + leaseApplyInfo.setKeyWord(keyword); + } + if (StringUtils.isNotBlank(publishTask)) { + leaseApplyInfo.setPublishTask(publishTask); + } + stepTimes.put("设置查询参数", System.currentTimeMillis() - step3Start); + + // 步骤4: 查询主要的申请信息 + long step4Start = System.currentTimeMillis(); + Optional optionalInfo = Optional.ofNullable(leaseApplyInfoMapper.selectLeaseApplyInfoById(leaseApplyInfo)); + stepTimes.put("查询主要申请信息", System.currentTimeMillis() - step4Start); + LeaseApplyRequestVo leaseApplyRequestVo = new LeaseApplyRequestVo(); + + // 步骤5: 查询领用出库数据(可选) + if (StringUtils.isNotBlank(publishTask)) { + long step5Start = System.currentTimeMillis(); + leaseApplyInfo.setPublishTask(publishTask); + List leaseApplyOutList = leaseApplyInfoMapper.selectPublishList(leaseApplyInfo); + if (!CollectionUtils.isEmpty(leaseApplyOutList)) { + LeaseApplyInfo applyInfo = leaseApplyOutList.get(0); + if (applyInfo.getPreCountNum().compareTo(applyInfo.getAlNum()) == 0) { + applyInfo.setTaskStatus(LeaseTaskStatusEnum.LEASE_TASK_FINISHED.getStatus()); + applyInfo.setTaskStatusName(LeaseTaskStatusEnum.LEASE_TASK_FINISHED.getStatusName()); + } else { + applyInfo.setTaskStatus(LeaseTaskStatusEnum.LEASE_TASK_IN_PROGRESS.getStatus()); + applyInfo.setTaskStatusName(LeaseTaskStatusEnum.LEASE_TASK_IN_PROGRESS.getStatusName()); + } + optionalInfo = Optional.of(leaseApplyOutList.get(0)); + } + stepTimes.put("查询领用出库数据", System.currentTimeMillis() - step5Start); + } else { + stepTimes.put("查询领用出库数据", 0L); // 跳过此步骤 + } + optionalInfo.ifPresent(info -> { + // 步骤6: 查询附件信息 + long step6Start = System.currentTimeMillis(); + BmFileInfo bmFileInfo = new BmFileInfo(); + bmFileInfo.setModelId(id); + bmFileInfo.setTaskType(2); + bmFileInfo.setFileType(5L); + List bmFileInfoList = bmFileInfoMapper.selectBmFileInfoList(bmFileInfo); + if (!CollectionUtils.isEmpty(bmFileInfoList)) { + info.setBmFileInfos(bmFileInfoList); + } + stepTimes.put("查询附件信息", System.currentTimeMillis() - step6Start); + + // 步骤7: 设置审批人签名和发料单位 + long step7Start = System.currentTimeMillis(); + /** 设置审批人签名url 防止代码冲突 **/ + String directAuditUrl = leaseApplyInfoMapper.getDirectAuditUrl(info); + info.setDirectAuditSignUrl(directAuditUrl); + /** 设置审批人签名url 防止代码冲突 **/ + + /** 设置发料单位 防止代码冲突 **/ + if(info.getDirectAuditBy() != null){ + String sendUnit = leaseApplyInfoMapper.getSendUnit(info); + info.setSendUnit(sendUnit); + } + // 电子签名进行base64拼接 + if (StringUtils.isNotBlank(info.getLeaseSignUrl())) { + if (!info.getLeaseSignUrl().startsWith("http")) { + info.setLeaseSignUrl("data:image/png;base64," + info.getLeaseSignUrl()); + } + } + /** 设置发料单位 防止代码冲突 **/ + stepTimes.put("设置签名和单位信息", System.currentTimeMillis() - step7Start); + + leaseApplyRequestVo.setLeaseApplyInfo(info); + // 步骤8: 获取领料单详情 + long step8Start = System.currentTimeMillis(); + List details; + + details = leaseApplyDetailsMapper.selectLeaseApplyDetailsList(new LeaseApplyDetails(info.getId(), keyword, null, null)); + + stepTimes.put("获取领料单详情", System.currentTimeMillis() - step8Start); + + // 步骤81: 获取领料单详情 + long step81Start = System.currentTimeMillis(); + // 走单独的领用详情查询 + if (StringUtils.isNotBlank(publishTask)) { + // 根据领用批次查询领用详情 + details = leaseApplyDetailsMapper.getDetailsPublish(leaseApplyInfo); + if (!CollectionUtils.isEmpty(details)) { + for (LeaseApplyDetails detail : details) { + // 根据parent_id和type_id查询出库数量 + BigDecimal outNum = leaseApplyDetailsMapper.getOutNum(detail); + detail.setAlNum(outNum); + detail.setOutNum(detail.getPreNum().subtract(outNum)); + if (detail.getPreNum().compareTo(detail.getAlNum()) == 0) { + detail.setStatus("2"); + } else { + detail.setStatus("1"); + } + } + } + } + if (details.size()>0){ + for (LeaseApplyDetails detail : details){ + //查询类型的库存和总待出库数量 + LeaseApplyDetails pendingOutNum = mapper.selectPendingOutNum(detail); + detail.setPendingOutNum(pendingOutNum.getPendingOutNum()); + detail.setStorageNum(pendingOutNum.getStorageNum()); + } + } + stepTimes.put("领用发布查询", System.currentTimeMillis() - step81Start); + + if (!CollectionUtils.isEmpty(details)) { + leaseApplyRequestVo.setLeaseApplyDetailsList(details); + + // 步骤9: 获取编码详情(批量优化) + long step9Start = System.currentTimeMillis(); + + // 收集所有typeId + List typeIds = details.stream() + .map(LeaseApplyDetails::getTypeId) + .filter(Objects::nonNull) + .distinct() + .collect(Collectors.toList()); + + if (!CollectionUtils.isEmpty(typeIds)) { + // 一次性批量查询所有编码详情 + List allMaCodeList = leaseApplyDetailsMapper.getCodeListBatch(id, typeIds); + + // 按typeId分组 + Map> maCodeMap = allMaCodeList.stream() + .filter(maCode -> maCode.getTypeId() != null) + .collect(Collectors.groupingBy(MaCodeVo::getTypeId)); + + // 分配给对应的detail + for (LeaseApplyDetails detail : details) { + if (detail.getTypeId() != null) { + List maCodeVoList = maCodeMap.get(detail.getTypeId().toString()); + if (!CollectionUtils.isEmpty(maCodeVoList)) { + detail.setMaCodeVoList(maCodeVoList); + } + } + } + } + + stepTimes.put("获取编码详情(批量优化)", System.currentTimeMillis() - step9Start); + + // 步骤10: 处理审批签名 + long step10Start = System.currentTimeMillis(); + // 提取details中的signType和signUrl,单独作为一个集合,并去重 + List approveSignList = details.stream() + .filter(detail -> detail.getSignUrl() != null) + .map(detail -> new LeaseOutSign(detail.getSignType(), detail.getSignUrl())) + .distinct() // 去重操作 + .collect(Collectors.toList()); + if (!CollectionUtils.isEmpty(approveSignList)) { + for (LeaseOutSign leaseOutSign : approveSignList) { + if (StringUtils.isNotBlank(leaseOutSign.getOutSignUrl())) { + if (!leaseOutSign.getOutSignUrl().startsWith("http")) { + leaseOutSign.setOutSignUrl("data:image/png;base64," + leaseOutSign.getOutSignUrl()); + } + } + } + leaseApplyRequestVo.setApproveSignList(approveSignList); + } + stepTimes.put("处理审批签名", System.currentTimeMillis() - step10Start); + } else { + stepTimes.put("获取编码详情", 0L); + stepTimes.put("处理审批签名", 0L); + } + // 步骤11: 查询出库库管员电子签名详情 + long step11Start = System.currentTimeMillis(); + List outSignList = leaseApplyInfoMapper.selectLeaseApplyOutList(id); + if (!CollectionUtils.isEmpty(outSignList)) { + for (LeaseOutSign applyInfo : outSignList) { + if (StringUtils.isNotBlank(applyInfo.getOutSignUrl())) { + if (!applyInfo.getOutSignUrl().startsWith("http")) { + applyInfo.setOutSignUrl("data:image/png;base64," + applyInfo.getOutSignUrl()); + } + } + } + leaseApplyRequestVo.setKgSignList(outSignList); + } + stepTimes.put("查询库管员签名", System.currentTimeMillis() - step11Start); + + // 步骤12: 查询领料人电子签名详情 + long step12Start = System.currentTimeMillis(); + List signList = leaseApplyInfoMapper.selectOutList(id, null); + if (!CollectionUtils.isEmpty(signList)) { + for (LeaseOutSign applyInfo : signList) { + if (StringUtils.isNotBlank(applyInfo.getOutSignUrl())) { + if (!applyInfo.getOutSignUrl().startsWith("http")) { + applyInfo.setOutSignUrl("data:image/png;base64," + applyInfo.getOutSignUrl()); + } + } + } + leaseApplyRequestVo.setOutSignList(signList); + } + stepTimes.put("查询领料人签名", System.currentTimeMillis() - step12Start); + + }); + + // 性能分析总结 + long totalTime = System.currentTimeMillis() - startTime; + DateTimeHelper.logPerformanceAnalysis("selectLeaseApplyInfoById", totalTime, stepTimes); + + return leaseApplyRequestVo; + } catch (Exception e) { + // 记录异常日志和性能数据 + long totalTime = System.currentTimeMillis() - startTime; + log.error("selectLeaseApplyInfoById执行异常,耗时: {}ms, id: {}, 错误: {}", totalTime, id, e.getMessage()); + DateTimeHelper.logPerformanceAnalysis("selectLeaseApplyInfoById(异常)", totalTime, stepTimes); + + System.err.println("Error occurred while selecting lease apply info by ID: " + id + e.getMessage()); + throw new RuntimeException("查询失败,请联系管理员"); + } + } + @Override public List selectLeaseApplyInfoByIdTwo(LeaseApplyInfo bean) { try { diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/MaterialLeaseInfoMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/MaterialLeaseInfoMapper.xml index 4ae83f67..b6d3b49c 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/MaterialLeaseInfoMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/MaterialLeaseInfoMapper.xml @@ -1074,7 +1074,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" SELECT sd.dept_name as impUnitName, lai.id AS id, - lai.code AS code, + lpd.code AS code, lai.create_by AS createBy, lai.create_time AS createTime, sd.dept_name AS impUnitName,