Merge remote-tracking branch 'origin/master'

This commit is contained in:
hongchao 2025-11-21 15:08:37 +08:00
commit 5232ed983d
9 changed files with 468 additions and 34 deletions

View File

@ -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<ProjUsingRecord> list = complexQueryService.getStatisticsList(bean);
List<ProjUsingExport> 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<ProjUsingExport> 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<ProjUsingRecordExport> 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<ProjUsingRecord> list = complexQueryService.getStatisticsList(bean);
List<ProjUsingRecordExport> 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<ProjUsingRecordExport> list = complexQueryService.getSecondStatisticsList(bean);
ExcelUtil<ProjUsingRecordExport> 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<ProjUsingRecord> list = complexQueryService.getAllUsDetails(bean);
List<ProjUsingRecordExports> 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<ProjUsingRecordExports> util = new ExcelUtil<>(ProjUsingRecordExports.class);
util.exportExcel(response, exportList, "总在用工程明细");
// 获取当前年月日时分秒导出时间用括号拼接在后面
String title = "总在用工程明细" + "" + "导出时间:" + DateUtils.getTime() + "";
util.exportExcel(response, exportList, fileName, title);
}
/**

View File

@ -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;
/** 字典类型 */

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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<PartInventory> getPartInventory(RetainedEquipmentInfo bean);
/**
* 获取二级统计数据
* @param bean
* @return
*/
List<ProjUsingRecordExport> getSecondStatisticsList(ProjUsingRecord bean);
}

View File

@ -161,4 +161,11 @@ public interface ComplexQueryService {
* @return
*/
List<PartInventory> getPartInventory(RetainedEquipmentInfo bean);
/**
* 供应统计报表二级页面
* @param bean
* @return
*/
List<ProjUsingRecordExport> getSecondStatisticsList(ProjUsingRecord bean);
}

View File

@ -804,4 +804,57 @@ public class ComplexQueryServiceImpl implements ComplexQueryService {
return new ArrayList<>();
}
}
/**
* 供应统计报表二级页面
* @param bean
* @return
*/
@Override
public List<ProjUsingRecordExport> getSecondStatisticsList(ProjUsingRecord bean) {
try {
// 1查询工程对应的物资名称型号需求数量已供数量
List<ProjUsingRecordExport> list = complexQueryMapper.getSecondStatisticsList(bean);
// 创建缓存Mapkey为typeIdvalue为对应的库存信息
Map<Long, RetainedEquipmentInfo> 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<>();
}
}
}

View File

@ -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'
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
@ -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}, '%')
)
</if>
<if test="proName != null and proName != ''">
and bp.pro_name like concat('%', #{proName}, '%')
</if>
<if test="typeName != null and typeName != ''">
and mt2.type_name like concat('%', #{typeName}, '%')
<if test="jijuType != null and jijuType != ''">
and mt.jiju_type = #{jijuType}
</if>
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}, '%')
)
</if>
<if test="proName != null and proName != ''">
and bp.pro_name like concat('%', #{proName}, '%')
</if>
<if test="typeName != null and typeName != ''">
and mt2.type_name like concat('%', #{typeName}, '%')
<if test="jijuType != null and jijuType != ''">
and mt.jiju_type = #{jijuType}
</if>
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}, '%')
)
</if>
<if test="proName != null and proName != ''">
and bp.pro_name like concat('%', #{proName}, '%')
</if>
<if test="typeName != null and typeName != ''">
and mt2.type_name like concat('%', #{typeName}, '%')
<if test="jijuType != null and jijuType != ''">
and mt.jiju_type = #{jijuType}
</if>
GROUP BY bp.pro_id, mt.type_id
) combined
@ -1940,4 +1944,162 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
</select>
<select id="getSecondStatisticsList" resultType="com.bonus.material.basic.domain.ProjUsingRecordExport">
SELECT
typeId,
proId,
proName,
typeName,
modelName as typeModelName,
unit,
SUM(needNum) as needNum,
SUM(outNum) as supplyNum,
SUM(outNum) - SUM(needNum) as diffNum
FROM (
-- 语句一的结果作为outNum
SELECT
mt.type_id as typeId,
bp.pro_id as proId,
sd.dept_name AS impUnitName,
bp.pro_name as proName,
mt2.type_name as typeName,
mt.type_name as modelName,
mt.unit_name as unit,
SUM(sai.num) as outNum,
0 as needNum
FROM
slt_agreement_info sai
LEFT JOIN ma_type mt on mt.type_id = sai.type_id
LEFT JOIN ma_type mt2 on mt2.type_id = mt.parent_id
LEFT JOIN bm_agreement_info bai on sai.agreement_id=bai.agreement_id
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.is_slt = '0'
and bp.pro_name is not null
and mt.del_flag='0'
<if test="keyWord != null and keyWord != ''">
and (
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}, '%')
)
</if>
<if test="proId != null">
and bp.pro_id = #{proId}
</if>
<if test="jijuType != null and jijuType != ''">
and mt.jiju_type = #{jijuType}
</if>
<if test="proName != null and proName != ''">
and bp.pro_name like concat('%', #{proName}, '%')
</if>
<if test="typeName != null and typeName != ''">
and mt2.type_name like concat('%', #{typeName}, '%')
</if>
GROUP BY bp.pro_id, mt.type_id
UNION ALL
-- 语句二的结果作为needNum
SELECT
mt.type_id as typeId,
bp.pro_id as proId,
sd.dept_name AS impUnitName,
bp.pro_name as proName,
mt2.type_name as typeName,
mt.type_name as modelName,
mt.unit_name as unit,
0 as outNum,
SUM(lad.pre_num) as needNum
FROM
lease_apply_details lad
LEFT JOIN lease_apply_info lai on lad.parent_id=lai.id
LEFT JOIN tm_task tt on lai.task_id = tt.task_id
LEFT JOIN tm_task_agreement tta on tt.task_id = tta.task_id
LEFT JOIN bm_agreement_info bai on tta.agreement_id = bai.agreement_id
LEFT JOIN ma_type mt on mt.type_id=lad.type_id
LEFT JOIN ma_type mt2 on mt2.type_id=mt.parent_id
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
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)
<if test="proId != null">
and bp.pro_id = #{proId}
</if>
<if test="jijuType != null and jijuType != ''">
and mt.jiju_type = #{jijuType}
</if>
<if test="keyWord != null and keyWord != ''">
and (
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}, '%')
)
</if>
<if test="proName != null and proName != ''">
and bp.pro_name like concat('%', #{proName}, '%')
</if>
<if test="typeName != null and typeName != ''">
and mt2.type_name like concat('%', #{typeName}, '%')
</if>
GROUP BY bp.pro_id, mt.type_id
UNION ALL
-- 语句三的结果作为needNum
SELECT
mt.type_id as typeId,
bp.pro_id as proId,
sd.dept_name AS impUnitName,
bp.pro_name as proName,
mt2.type_name as typeName,
mt.type_name as modelName,
mt.unit_name as unit,
0 as outNum,
SUM(lpd.num) as needNum
FROM
lease_publish_details lpd
LEFT JOIN lease_apply_info lai on lpd.parent_id=lai.id
LEFT JOIN tm_task tt on lai.task_id = tt.task_id
LEFT JOIN ma_type mt on mt.type_id=lpd.type_id
LEFT JOIN ma_type mt2 on mt2.type_id=mt.parent_id
LEFT JOIN bm_project bp on lai.project_id=bp.pro_id
LEFT JOIN sys_dept sd ON sd.dept_id = bp.imp_unit
WHERE
bp.pro_name is not null
and mt.del_flag='0'
and tt.task_type = '19'
<if test="proId != null">
and bp.pro_id = #{proId}
</if>
<if test="jijuType != null and jijuType != ''">
and mt.jiju_type = #{jijuType}
</if>
<if test="keyWord != null and keyWord != ''">
and (
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}, '%')
)
</if>
<if test="proName != null and proName != ''">
and bp.pro_name like concat('%', #{proName}, '%')
</if>
<if test="typeName != null and typeName != ''">
and mt2.type_name like concat('%', #{typeName}, '%')
</if>
GROUP BY bp.pro_id, mt.type_id
) combined
GROUP BY proId,typeId
ORDER BY proId
</select>
</mapper>