From 3fdb25babed7f879a2daf6aeaa52ed4ba4bfe18c Mon Sep 17 00:00:00 2001 From: mashuai Date: Mon, 3 Nov 2025 14:18:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MaterialLeaseInfoController.java | 29 +++- .../clz/domain/lease/LeaseDetailsInfo.java | 161 ++++++++++++++++++ .../clz/domain/lease/LeaseOutDetailsInfo.java | 11 +- .../clz/service/MaterialLeaseInfoService.java | 6 + .../impl/MaterialLeaseInfoServiceImpl.java | 85 +++++++-- 5 files changed, 274 insertions(+), 18 deletions(-) create mode 100644 bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/lease/LeaseDetailsInfo.java diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/controller/MaterialLeaseInfoController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/controller/MaterialLeaseInfoController.java index c5c49496..a6c7fe54 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/controller/MaterialLeaseInfoController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/controller/MaterialLeaseInfoController.java @@ -188,9 +188,36 @@ public class MaterialLeaseInfoController extends BaseController { @ApiOperation(value = "导出工器具领料出库详情") @PostMapping("/exportOutDetails") public void exportOutDetails(HttpServletResponse response, MaterialLeaseApplyInfo leaseApplyInfo) { + String fileName = "材料站出库详情"; List list = materialLeaseInfoService.exportOutDetails(leaseApplyInfo); + // 根据list集合数,去填充序号 + for (int i = 0; i < list.size(); i++) { + list.get(i).setSerialNumber(i + 1); + } ExcelUtil util = new ExcelUtil<>(LeaseOutDetailsInfo.class); - util.exportExcel(response, list, "工器具领料出库详情数据"); + // 获取当前年月日时分秒导出时间,用括号拼接在后面 + String title = "材料站出库详情" + "(" + "导出时间:" + DateUtils.getTime() + ")"; + util.exportExcel(response, list, fileName, title); + } + + /** + * 工器具领料申请详情 + * @param response + * @param leaseApplyInfo + */ + @ApiOperation(value = "导出工器具领料申请详情") + @PostMapping("/exportDetails") + public void exportDetails(HttpServletResponse response, MaterialLeaseApplyInfo leaseApplyInfo) { + String fileName = "班组领料申请详情"; + List list = materialLeaseInfoService.exportDetails(leaseApplyInfo); + // 根据list集合数,去填充序号 + for (int i = 0; i < list.size(); i++) { + list.get(i).setSerialNumber(i + 1); + } + ExcelUtil util = new ExcelUtil<>(LeaseDetailsInfo.class); + // 获取当前年月日时分秒导出时间,用括号拼接在后面 + String title = "班组领料申请详情" + "(" + "导出时间:" + DateUtils.getTime() + ")"; + util.exportExcel(response, list, fileName, title); } /** diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/lease/LeaseDetailsInfo.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/lease/LeaseDetailsInfo.java new file mode 100644 index 00000000..b5ccfdb3 --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/lease/LeaseDetailsInfo.java @@ -0,0 +1,161 @@ +package com.bonus.material.clz.domain.lease; + +import com.bonus.common.core.annotation.Excel; +import com.bonus.material.back.domain.vo.MaCodeVo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.ToString; +import org.apache.poi.ss.usermodel.HorizontalAlignment; + +import java.math.BigDecimal; +import java.util.List; + +/** + * 领料任务详细对象 lease_apply_details + * + * @author xsheng + * @date 2024-10-16 + */ +@Data +@ToString +public class LeaseDetailsInfo { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "序号") + @Excel(name = "序号", isSequence = true, sort = 0, width = 5) + private Integer serialNumber; + + /** ID */ + private Long id; + + /** 任务ID */ + @ApiModelProperty(value = "任务ID") + private Long parentId; + + @ApiModelProperty(value = "机具ID") + private Long maId; + + /** 物资类型 */ + @ApiModelProperty(value = "物资类型名称") + @Excel(name = "类型名称") + private String maTypeName; + + /** 物资类型ids */ + @ApiModelProperty(value = "物资类型ids") + private int[] maTypeIds; + + private String maTypeIdsStr; + + private int isManual; + + /** 规格型号id */ + @ApiModelProperty(value = "规格型号id") + private Long typeId; + + @ApiModelProperty(value = "规格型号id") + private Long newTypeId; + + @ApiModelProperty(value = "三级id") + private Long thirdTypeId; + + @ApiModelProperty(value = "规格型号id") + private Long taskId; + + /** 规格型号 */ + @ApiModelProperty(value = "规格型号名称") + @Excel(name = "规格型号") + private String typeName; + + @ApiModelProperty(value = "机具编码") + private String maCode; + + /** 计量单位 */ + @ApiModelProperty(value = "计量单位") + @Excel(name = "计量单位") + private String unitName; + + /** 计量单位数值 */ + @ApiModelProperty(value = "计量单位数值") + private String unitValue; + + /** 库存数量 */ + @ApiModelProperty(value = "库存数量") + @Excel(name = "当前库存", cellType = Excel.ColumnType.NUMERIC, align = HorizontalAlignment.RIGHT) + private BigDecimal storageNum; + + /** 预领料数 */ + @Excel(name = "预领数量", cellType = Excel.ColumnType.NUMERIC, align = HorizontalAlignment.RIGHT) + @ApiModelProperty(value = "预领料数") + private BigDecimal preNum; + + @ApiModelProperty(value = "已发布数量") + private BigDecimal publishNum; + + @ApiModelProperty(value = "待发布数量") + private BigDecimal pendingNum; + + @ApiModelProperty(value = "本次发布数量") + private BigDecimal num; + + /** 审批数量 */ + @ApiModelProperty(value = "审批数量") + private BigDecimal auditNum; + + /** + * 此数量是剩余需要出库的数量(preNum - alNum) + */ + @ApiModelProperty(value = "剩余最大出库数量") + private BigDecimal outNum; + + /** 已领数量 */ + @ApiModelProperty(value = "已领数量") + private BigDecimal alNum; + + @ApiModelProperty(name = "装备管理方式") + private String manageType; + + /** 备注 */ + @ApiModelProperty(value = "备注") + @Excel(name = "备注") + private String remark; + + /** 状态(0待审批,1进行中,2已出库) */ + private String status; + + /** 数据所属组织 */ + @ApiModelProperty(value = "数据所属组织") + private Long companyId; + + private String keyword; + + @ApiModelProperty(value = "用户ID") + private Long userId; + + @ApiModelProperty(value = "编码类型集合") + private List maCodeVoList; + + @ApiModelProperty(value = "往来单位id") + private Long unitId; + + @ApiModelProperty(value = "工程id") + private Long projectId; + + @ApiModelProperty(value = "领料人") + private String leasePerson; + + @ApiModelProperty(value = "联系方式") + private String phone; + + @ApiModelProperty(value = "任务当月序号 例如:1 插入及查询时请携带任务类型") + private Integer monthOrder; + + @ApiModelProperty(value = "发布批次") + private String publishTask; + + @ApiModelProperty(value = "领料单位") + private String leaseUnit; + + @ApiModelProperty(value = "租赁工程") + private String leaseProject; +} diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/lease/LeaseOutDetailsInfo.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/lease/LeaseOutDetailsInfo.java index d4940439..5def3887 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/lease/LeaseOutDetailsInfo.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/lease/LeaseOutDetailsInfo.java @@ -5,6 +5,7 @@ import com.bonus.material.back.domain.vo.MaCodeVo; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.ToString; +import org.apache.poi.ss.usermodel.HorizontalAlignment; import java.math.BigDecimal; import java.util.List; @@ -21,6 +22,10 @@ public class LeaseOutDetailsInfo { private static final long serialVersionUID = 1L; + @ApiModelProperty(value = "序号") + @Excel(name = "序号", isSequence = true, sort = 0, width = 5) + private Integer serialNumber; + /** ID */ private Long id; @@ -76,11 +81,11 @@ public class LeaseOutDetailsInfo { /** 库存数量 */ @ApiModelProperty(value = "库存数量") - @Excel(name = "当前库存") + @Excel(name = "当前库存", cellType = Excel.ColumnType.NUMERIC, align = HorizontalAlignment.RIGHT) private BigDecimal storageNum; /** 预领料数 */ - @Excel(name = "预领数量") + @Excel(name = "预领数量", cellType = Excel.ColumnType.NUMERIC, align = HorizontalAlignment.RIGHT) @ApiModelProperty(value = "预领料数") private BigDecimal preNum; @@ -101,7 +106,7 @@ public class LeaseOutDetailsInfo { * 此数量是剩余需要出库的数量(preNum - alNum) */ @ApiModelProperty(value = "剩余最大出库数量") - @Excel(name = "出库数量") + @Excel(name = "出库数量", cellType = Excel.ColumnType.NUMERIC, align = HorizontalAlignment.RIGHT) private BigDecimal outNum; /** 已领数量 */ diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/MaterialLeaseInfoService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/MaterialLeaseInfoService.java index 45a05e7d..cd6bae3b 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/MaterialLeaseInfoService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/MaterialLeaseInfoService.java @@ -181,4 +181,10 @@ public interface MaterialLeaseInfoService { */ void queryQrCode(MaterialLeaseApplyDetails bean, HttpServletResponse response); + /** + * 工器具领料申请详情 + * @param leaseApplyInfo + * @return + */ + List exportDetails(MaterialLeaseApplyInfo leaseApplyInfo); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialLeaseInfoServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialLeaseInfoServiceImpl.java index 110008e1..b369bccf 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialLeaseInfoServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialLeaseInfoServiceImpl.java @@ -631,6 +631,47 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService { } } + /** + * 导出设备出库信息 + * @param leaseApplyInfo + * @return + */ + @Override + public List exportDetails(MaterialLeaseApplyInfo leaseApplyInfo) { + List leaseOutDetails = new ArrayList<>(); + Optional optionalInfo = Optional.ofNullable(materialLeaseInfoMapper.selectLeaseApplyInfoById(leaseApplyInfo)); + optionalInfo.ifPresent(info -> { + // 获取工器具领料出库详情 + List details = materialLeaseInfoMapper.getOutDetailsById(leaseApplyInfo); + if (!CollectionUtils.isEmpty(details)) { + // 步骤4.1: 收集所有typeId,进行批量查询 + List typeIds = details.stream() + .map(MaterialLeaseApplyDetails::getTypeId) + .filter(Objects::nonNull) + .distinct() + .collect(Collectors.toList()); + SelectDto selectDto = new SelectDto(); + selectDto.setProId(info.getProId()); + List agreementList = mapper.getAgreementInfoBy(selectDto); + Map storageNumMap = preCalculateStorageNums(info, agreementList, typeIds); + for (MaterialLeaseApplyDetails detail : details) { + // 直接从预计算的Map中获取库存数据,避免复杂的嵌套循环 + BigDecimal storageNum = storageNumMap.getOrDefault(detail.getTypeId(), BigDecimal.ZERO); + LeaseDetailsInfo lease = new LeaseDetailsInfo(); + lease.setMaTypeName(detail.getMaTypeName() == null ? "" : detail.getMaTypeName()); + lease.setTypeName(detail.getTypeName() == null ? "" : detail.getTypeName()); + lease.setUnitName(detail.getUnitName() == null ? "" : detail.getUnitName()); + lease.setPreNum(detail.getPreNum()); + lease.setStorageNum(storageNum); + lease.setManageType("0".equals(detail.getManageType()) ? "数量管理" : "编码管理"); + lease.setRemark(detail.getRemark() == null ? "" : detail.getRemark()); + leaseOutDetails.add(lease); + } + } + }); + return leaseOutDetails; + } + /** 简单的文件名清洗(避免非法字符) */ private String sanitizeFileName(String name) { if (name == null) { @@ -1143,21 +1184,37 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService { @Override public List exportOutDetails(MaterialLeaseApplyInfo leaseApplyInfo) { List leaseOutDetails = new ArrayList<>(); - List details = materialLeaseInfoMapper.getOutDetailsById(leaseApplyInfo); - if (!CollectionUtils.isEmpty(details)) { - for (MaterialLeaseApplyDetails detail : details) { - LeaseOutDetailsInfo lease = new LeaseOutDetailsInfo(); - lease.setMaTypeName(detail.getMaTypeName() == null ? "" : detail.getMaTypeName()); - lease.setTypeName(detail.getTypeName() == null ? "" : detail.getTypeName()); - lease.setUnitName(detail.getUnitName() == null ? "" : detail.getUnitName()); - lease.setPreNum(detail.getPreNum()); - lease.setStorageNum(detail.getStorageNum()); - lease.setOutNum(detail.getOutNum()); - lease.setManageType("0".equals(detail.getManageType()) ? "数量管理" : "编码管理"); - lease.setRemark(detail.getRemark() == null ? "" : detail.getRemark()); - leaseOutDetails.add(lease); + Optional optionalInfo = Optional.ofNullable(materialLeaseInfoMapper.selectLeaseApplyInfoById(leaseApplyInfo)); + optionalInfo.ifPresent(info -> { + // 获取工器具领料出库详情 + List details = materialLeaseInfoMapper.getOutDetailsById(leaseApplyInfo); + if (!CollectionUtils.isEmpty(details)) { + // 步骤4.1: 收集所有typeId,进行批量查询 + List typeIds = details.stream() + .map(MaterialLeaseApplyDetails::getTypeId) + .filter(Objects::nonNull) + .distinct() + .collect(Collectors.toList()); + SelectDto selectDto = new SelectDto(); + selectDto.setProId(info.getProId()); + List agreementList = mapper.getAgreementInfoBy(selectDto); + Map storageNumMap = preCalculateStorageNums(info, agreementList, typeIds); + for (MaterialLeaseApplyDetails detail : details) { + // 直接从预计算的Map中获取库存数据,避免复杂的嵌套循环 + BigDecimal storageNum = storageNumMap.getOrDefault(detail.getTypeId(), BigDecimal.ZERO); + LeaseOutDetailsInfo lease = new LeaseOutDetailsInfo(); + lease.setMaTypeName(detail.getMaTypeName() == null ? "" : detail.getMaTypeName()); + lease.setTypeName(detail.getTypeName() == null ? "" : detail.getTypeName()); + lease.setUnitName(detail.getUnitName() == null ? "" : detail.getUnitName()); + lease.setPreNum(detail.getPreNum()); + lease.setStorageNum(storageNum); + lease.setOutNum(detail.getOutNum()); + lease.setManageType("0".equals(detail.getManageType()) ? "数量管理" : "编码管理"); + lease.setRemark(detail.getRemark() == null ? "" : detail.getRemark()); + leaseOutDetails.add(lease); + } } - } + }); return leaseOutDetails; }