diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/controller/ComplexQueryController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/controller/ComplexQueryController.java index a67a851c..6ea1a561 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/controller/ComplexQueryController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/controller/ComplexQueryController.java @@ -3,6 +3,7 @@ package com.bonus.material.basic.controller; import cn.hutool.core.convert.Convert; import com.alibaba.nacos.common.utils.CollectionUtils; import com.bonus.common.biz.config.ListPagingUtil; +import com.bonus.common.core.utils.DateUtils; import com.bonus.common.core.utils.ServletUtils; import com.bonus.common.core.utils.bean.BeanUtils; import com.bonus.common.core.utils.poi.ExcelUtil; @@ -16,11 +17,8 @@ import com.bonus.material.basic.domain.*; import com.bonus.material.basic.domain.vo.MaTypeSelectInfo; import com.bonus.material.basic.service.ComplexQueryService; import com.bonus.material.common.annotation.PreventRepeatSubmit; -import com.bonus.material.lease.mapper.LeaseApplyInfoMapper; import com.bonus.material.ma.domain.Type; import com.bonus.material.part.domain.PartInventory; -import com.bonus.material.part.domain.PartTypeCheckInfo; -import com.bonus.material.part.domain.PartTypeQueryDto; import com.bonus.system.api.model.LoginUser; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -507,6 +505,47 @@ public class ComplexQueryController extends BaseController { return AjaxResult.success(getDataTable(pageList)); } + /** + * 导出供应统计报表 + * @param response + * @param bean + */ + @ApiOperation("导出供应统计报表") + @PostMapping("/exportStatisticsList") + public void exportStatisticsList(HttpServletResponse response, ProjUsingRecord bean) + { + String fileName = "供应统计报表"; + if (bean.getStartTime() != null && bean.getEndTime() != null) { + fileName = "供应统计报表"+ "(统计日期" + bean.getStartTime() + "至" + bean.getEndTime() + ")"; + } + List list = complexQueryService.getStatisticsList(bean); + List exportList = new ArrayList<>(); + //将list复制到exportList + for (int i = 0; i < list.size(); i++) { + ProjUsingExport projUsingExport = new ProjUsingExport(); + projUsingExport.setSerialNumber(i + 1); + BeanUtils.copyProperties(list.get(i), projUsingExport); + exportList.add(projUsingExport); + } + ExcelUtil util = new ExcelUtil<>(ProjUsingExport.class); + // 获取当前年月日时分秒导出时间,用括号拼接在后面 + String title = "供应统计报表" + "(" + "导出时间:" + DateUtils.getTime() + ")"; + util.exportExcel(response, exportList, fileName, title); + } + + /** + * 供应统计报表二级页面 + * @param bean + * @return + */ + @ApiOperation(value = "供应统计报表二级页面") + @GetMapping("/getSecondStatisticsList") + public AjaxResult getSecondStatisticsList(ProjUsingRecord bean) { + startPage(); + List pageList = complexQueryService.getSecondStatisticsList(bean); + return AjaxResult.success(getDataTable(pageList)); + } + /** * 施工机具需求、供应分析统计表二级页面---总在用工程明细 * @param bean @@ -522,38 +561,52 @@ public class ComplexQueryController extends BaseController { return AjaxResult.success(getDataTable(pageList)); } - - - @ApiOperation("导出施工机具需求、供应分析统计表") - @PostMapping("/exportStatisticsList") - public void exportStatisticsList(HttpServletResponse response, ProjUsingRecord bean) + /** + * 导出供应统计报表二级页面 + * @param response + * @param bean + */ + @ApiOperation("导出供应统计报表二级页面") + @PostMapping("/exportSecondStatisticsList") + public void exportSecondStatisticsList(HttpServletResponse response, ProjUsingRecord bean) { - List list = complexQueryService.getStatisticsList(bean); - List exportList = new ArrayList<>(); - //将list复制到exportList - for (ProjUsingRecord projUsingRecord : list) { - ProjUsingRecordExport projUsingRecordExport = new ProjUsingRecordExport(); - BeanUtils.copyProperties(projUsingRecord, projUsingRecordExport); - exportList.add(projUsingRecordExport); + String fileName = "供应统计报表二级页面"; + if (bean.getStartTime() != null && bean.getEndTime() != null) { + fileName = "供应统计报表二级页面"+ "(统计日期" + bean.getStartTime() + "至" + bean.getEndTime() + ")"; } + List list = complexQueryService.getSecondStatisticsList(bean); ExcelUtil util = new ExcelUtil<>(ProjUsingRecordExport.class); - util.exportExcel(response, exportList, "施工机具需求、供应分析统计表"); + // 获取当前年月日时分秒导出时间,用括号拼接在后面 + String title = "供应统计报表二级页面" + "(" + "导出时间:" + DateUtils.getTime() + ")"; + util.exportExcel(response, list, fileName, title); } + /** + * 导出总在用工程明细 + * @param response + * @param bean + */ @ApiOperation("导出总在用工程明细") @PostMapping("/exportAllUsDetails") public void exportAllUsDetails(HttpServletResponse response, ProjUsingRecord bean) { + String fileName = "总在用工程明细"; + if (bean.getStartTime() != null && bean.getEndTime() != null) { + fileName = "总在用工程明细"+ "(统计日期" + bean.getStartTime() + "至" + bean.getEndTime() + ")"; + } List list = complexQueryService.getAllUsDetails(bean); List exportList = new ArrayList<>(); //将list复制到exportList - for (ProjUsingRecord projUsingRecord : list) { + for (int i = 0; i < list.size(); i++) { ProjUsingRecordExports projUsingRecordExports = new ProjUsingRecordExports(); - BeanUtils.copyProperties(projUsingRecord, projUsingRecordExports); + projUsingRecordExports.setSerialNumber(i + 1); + BeanUtils.copyProperties(list.get(i), projUsingRecordExports); exportList.add(projUsingRecordExports); } ExcelUtil util = new ExcelUtil<>(ProjUsingRecordExports.class); - util.exportExcel(response, exportList, "总在用工程明细"); + // 获取当前年月日时分秒导出时间,用括号拼接在后面 + String title = "总在用工程明细" + "(" + "导出时间:" + DateUtils.getTime() + ")"; + util.exportExcel(response, exportList, fileName, title); } /** diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/domain/BmUnitType.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/domain/BmUnitType.java index 3d110414..776b787b 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/domain/BmUnitType.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/domain/BmUnitType.java @@ -35,7 +35,7 @@ public class BmUnitType private Long dictCode; /** 单位类型名称 */ - @Excel(name = "单位类型名称") + @Excel(name = "单位类型") private String dictLabel; /** 字典键值 */ @@ -43,7 +43,7 @@ public class BmUnitType private String dictValue; /** 字典排序 */ - @Excel(name = "字典排序") + @Excel(name = "字典排序", cellType = Excel.ColumnType.NUMERIC) private Long dictSort; /** 字典类型 */ diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/domain/ProjUsingExport.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/domain/ProjUsingExport.java new file mode 100644 index 00000000..8204bf6a --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/domain/ProjUsingExport.java @@ -0,0 +1,145 @@ +package com.bonus.material.basic.domain; + +import com.bonus.common.core.annotation.Excel; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.apache.poi.ss.usermodel.HorizontalAlignment; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** +* @description 综合查询--退料查询 +* @author hay +* @date 2024/2/26 14:51 +*/ +@ApiModel(description = "退料查询") +@Data +public class ProjUsingExport implements Serializable { + + private static final long serialVersionUID = 2227217051604273598L; + + @ApiModelProperty(value = "主键id") + private Integer id; + + @ApiModelProperty(value = "序号") + @Excel(name = "序号", isSequence = true, sort = 0, width = 5) + private Integer serialNumber; + + @ApiModelProperty(value = "分公司") + @Excel(name = "分公司") + private String impUnitName; + + @ApiModelProperty(value = "协议号") + private String agreementCode; + + @ApiModelProperty(value = "工程Id") + private Integer proId; + + @ApiModelProperty(value = "工程名称") + @Excel(name = "工程名称") + private String proName; + + @ApiModelProperty(value = "机具类型") + @Excel(name = "机具类型") + private String jijuType; + + @ApiModelProperty(value = "往来单位Id") + private Integer unitId; + + @ApiModelProperty(value = "往来单位") + private String unitName; + + @ApiModelProperty(value = "合同主体") + private String contractPart; + + @ApiModelProperty(value = "物资名称") + private String typeName; + + @ApiModelProperty(value = "规格ID") + private Integer typeId; + + @ApiModelProperty(value = "规格型号") + private String typeModelName; + + @ApiModelProperty(value = "设备编码") + private String maCode; + + @ApiModelProperty(value = "计量单位") + private String unit; + + @ApiModelProperty(value = "领用数量") + private BigDecimal leaseNum; + + @ApiModelProperty(value = "归还数量") + private BigDecimal backNum; + + @ApiModelProperty(value = "需求数量") + @Excel(name = "需求数量", cellType = Excel.ColumnType.NUMERIC, align = HorizontalAlignment.RIGHT) + private String needNum; + + @ApiModelProperty(value = "已供数量") + @Excel(name = "已供数量(累计)", cellType = Excel.ColumnType.NUMERIC, align = HorizontalAlignment.RIGHT) + private String supplyNum; + + @ApiModelProperty(value = "差值") + @Excel(name = "差值(已供G-需求F)", cellType = Excel.ColumnType.NUMERIC, align = HorizontalAlignment.RIGHT) + private String diffNum; + + @ApiModelProperty(value = "在用数量") + private BigDecimal usNum; + + @ApiModelProperty(value = "在库数量") + private BigDecimal storeNum; + + @ApiModelProperty(value = "在修数量") + private BigDecimal repairNum; + + @ApiModelProperty(value = "待入库数量") + private BigDecimal inputNum; + + @ApiModelProperty(value = "总保有量") + private BigDecimal allNum; + + @ApiModelProperty(value = "总在用数量") + private BigDecimal allUsNum; + + + @ApiModelProperty(value = "在用总价值(元)") + private BigDecimal usPrice; + + @ApiModelProperty(value = "投入总价值(元)") + private BigDecimal totalPrice; + + @ApiModelProperty(value = "关键字") + private String keyWord; + + @ApiModelProperty(value="开始时间") + private String startTime; + + @ApiModelProperty(value="结束时间") + private String endTime; + + @ApiModelProperty(value = "数据所属组织") + private Integer companyId; + + @ApiModelProperty(value = "装备管理方式(0编号 1计数)") + private String manageType; + + @ApiModelProperty(value = "是否结算 0否 1是") + private String isSlt; + + @ApiModelProperty(value = "是否结算 0否 1是") + private String isSltName; + + private String externalIds; + @ApiModelProperty(value = "关联外部(第三方)的工程ID") + private String externalId; + + private Long userId; + + @ApiModelProperty(value = "备注") + private String remark; + +} diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/domain/ProjUsingRecordExport.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/domain/ProjUsingRecordExport.java index e144b6a7..c65d3fdb 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/domain/ProjUsingRecordExport.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/domain/ProjUsingRecordExport.java @@ -23,6 +23,10 @@ public class ProjUsingRecordExport implements Serializable { @ApiModelProperty(value = "主键id") private Integer id; + @ApiModelProperty(value = "序号") + @Excel(name = "序号", isSequence = true, sort = 0, width = 5) + private Integer serialNumber; + @ApiModelProperty(value = "协议号") private String agreementCode; @@ -140,7 +144,6 @@ public class ProjUsingRecordExport implements Serializable { private Long userId; @ApiModelProperty(value = "备注") - @Excel(name = "备注") private String remark; } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/domain/ProjUsingRecordExports.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/domain/ProjUsingRecordExports.java index 73f40425..641eb335 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/domain/ProjUsingRecordExports.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/domain/ProjUsingRecordExports.java @@ -22,6 +22,10 @@ public class ProjUsingRecordExports implements Serializable { @ApiModelProperty(value = "主键id") private Integer id; + @ApiModelProperty(value = "序号") + @Excel(name = "序号", isSequence = true, sort = 0, width = 5) + private Integer serialNumber; + @ApiModelProperty(value = "协议号") private String agreementCode; diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/mapper/ComplexQueryMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/mapper/ComplexQueryMapper.java index 08d7bacd..aefa3700 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/mapper/ComplexQueryMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/mapper/ComplexQueryMapper.java @@ -175,14 +175,14 @@ public interface ComplexQueryMapper { * @param item * @return */ - ProjUsingRecord getUsNum(ProjUsingRecord item); + ProjUsingRecord getUsNum(ProjUsingRecordExport item); /** * 根据typeId查询,总库存数量、总在修数量、总待入库数量、总保有量 * @param item * @return */ - RetainedEquipmentInfo selectInventory(ProjUsingRecord item); + RetainedEquipmentInfo selectInventory(ProjUsingRecordExport item); /** * 获取所有在用详情 @@ -248,4 +248,11 @@ public interface ComplexQueryMapper { * @return */ List getPartInventory(RetainedEquipmentInfo bean); + + /** + * 获取二级统计数据 + * @param bean + * @return + */ + List getSecondStatisticsList(ProjUsingRecord bean); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/service/ComplexQueryService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/service/ComplexQueryService.java index 716d5ddb..b352b2c0 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/service/ComplexQueryService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/service/ComplexQueryService.java @@ -161,4 +161,11 @@ public interface ComplexQueryService { * @return */ List getPartInventory(RetainedEquipmentInfo bean); + + /** + * 供应统计报表二级页面 + * @param bean + * @return + */ + List getSecondStatisticsList(ProjUsingRecord bean); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/service/impl/ComplexQueryServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/service/impl/ComplexQueryServiceImpl.java index 67a62ec1..b2cc5c07 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/service/impl/ComplexQueryServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/service/impl/ComplexQueryServiceImpl.java @@ -804,4 +804,57 @@ public class ComplexQueryServiceImpl implements ComplexQueryService { return new ArrayList<>(); } } + + /** + * 供应统计报表二级页面 + * @param bean + * @return + */ + @Override + public List getSecondStatisticsList(ProjUsingRecord bean) { + try { + // 1、查询工程对应的物资名称、型号、需求数量、已供数量 + List list = complexQueryMapper.getSecondStatisticsList(bean); + + // 创建缓存Map,key为typeId,value为对应的库存信息 + Map inventoryCache = new HashMap<>(); + + for (int i = 0; i < list.size(); i++) { + ProjUsingRecordExport item = list.get(i); + item.setSerialNumber(i + 1); + // 3、查询该工程设备的在用数量 + ProjUsingRecord projUsingRecord3 = complexQueryMapper.getUsNum(item); + if (projUsingRecord3 != null && projUsingRecord3.getUsNum() != null) { + item.setUsNum(projUsingRecord3.getUsNum()); + } else { + item.setUsNum(BigDecimal.ZERO); + } + + // 4、根据typeId查询库存信息(使用缓存优化) + Long typeId = Long.valueOf(item.getTypeId()); + + RetainedEquipmentInfo bean1 = inventoryCache.get(typeId); + if (bean1 == null) { + // 如果缓存中没有,则查询数据库并放入缓存 + bean1 = complexQueryMapper.selectInventory(item); + inventoryCache.put(typeId, bean1); + } + + // 设置库存相关信息 + item.setStoreNum(bean1.getStoreNum()); + item.setRepairNum(bean1.getRepairNum()); + item.setAllUsNum(bean1.getUsNum()); + + // 使用三元运算符处理null值 + BigDecimal inputNum = bean1.getInputNum() != null ? bean1.getInputNum() : BigDecimal.ZERO; + BigDecimal repairInputNum = bean1.getRepairInputNum() != null ? bean1.getRepairInputNum() : BigDecimal.ZERO; + item.setInputNum(inputNum.add(repairInputNum)); + item.setAllNum(bean1.getAllNum()); + } + return list; + } catch (Exception e) { + e.printStackTrace(); + return new ArrayList<>(); + } + } } diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/basic/ComplexQueryMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/basic/ComplexQueryMapper.xml index fbe1b77b..9d718b01 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/basic/ComplexQueryMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/basic/ComplexQueryMapper.xml @@ -598,7 +598,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" LEFT JOIN bm_project bp on bai.project_id=bp.pro_id LEFT JOIN sys_dept sd ON sd.dept_id = bp.imp_unit WHERE - sai.lease_id is not null + sai.is_slt = '0' and bp.pro_name is not null and mt.del_flag='0' @@ -609,14 +609,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" mt2.type_name like concat('%', #{keyWord}, '%') or mt.type_name like concat('%', #{keyWord}, '%') or bp.pro_name like concat('%', #{keyWord}, '%') or - mt.unit_name like concat('%', #{keyWord}, '%') + mt.unit_name like concat('%', #{keyWord}, '%') or + sd.dept_name like concat('%', #{keyWord}, '%') ) and bp.pro_name like concat('%', #{proName}, '%') - - and mt2.type_name like concat('%', #{typeName}, '%') + + and mt.jiju_type = #{jijuType} GROUP BY bp.pro_id, mt.type_id @@ -651,6 +652,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" LEFT JOIN sys_dept sd ON sd.dept_id = bp.imp_unit WHERE bp.pro_name is not null + and lai.direct_id is null and mt.del_flag=0 and tt.task_type = '2' and tt.task_status in (3, 4) @@ -662,14 +664,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" mt2.type_name like concat('%', #{keyWord}, '%') or mt.type_name like concat('%', #{keyWord}, '%') or bp.pro_name like concat('%', #{keyWord}, '%') or - mt.unit_name like concat('%', #{keyWord}, '%') + mt.unit_name like concat('%', #{keyWord}, '%') or + sd.dept_name like concat('%', #{keyWord}, '%') ) and bp.pro_name like concat('%', #{proName}, '%') - - and mt2.type_name like concat('%', #{typeName}, '%') + + and mt.jiju_type = #{jijuType} GROUP BY bp.pro_id, mt.type_id @@ -712,14 +715,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" mt2.type_name like concat('%', #{keyWord}, '%') or mt.type_name like concat('%', #{keyWord}, '%') or bp.pro_name like concat('%', #{keyWord}, '%') or - mt.unit_name like concat('%', #{keyWord}, '%') + mt.unit_name like concat('%', #{keyWord}, '%') or + sd.dept_name like concat('%', #{keyWord}, '%') ) and bp.pro_name like concat('%', #{proName}, '%') - - and mt2.type_name like concat('%', #{typeName}, '%') + + and mt.jiju_type = #{jijuType} GROUP BY bp.pro_id, mt.type_id ) combined @@ -1940,4 +1944,162 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + +