fzzy-igdss-core/src/main/java/com/fzzy/igds/data/SuperInventoryReportData.java
@@ -1,5 +1,6 @@ package com.fzzy.igds.data; import com.ruoyi.common.annotation.Excel; import lombok.Data; import java.io.Serializable; @@ -9,7 +10,6 @@ * * @author sgj * @date 2025/12/19 */ @Data public class SuperInventoryReportData implements Serializable { @@ -19,6 +19,9 @@ /** * 收储公司 */ private String customerId; @Excel(name = "收储公司", sort = 1) private String customerName; /** @@ -26,45 +29,58 @@ */ private String deptId; @Excel(name = "所属库区", sort = 2) private String deptName; /** * 所属仓库 */ private String depotId; @Excel(name = "所属仓库", sort = 3) private String depotName; /** * 期初数量(单位KG) */ @Excel(name = "期初数量(单位KG)", sort = 4) private Double initialWeight = 0.0; /** * 入库数量(单位KG) */ @Excel(name = "入库数量(单位KG)", sort = 5) private Double recordInWeight = 0.0; /** * 倒入数量(单位KG) */ @Excel(name = "倒入数量(单位KG)", sort = 6) private Double changeInWeight = 0.0; /** * 出库数量(单位KG) */ @Excel(name = "出库数量(单位KG)", sort = 7) private Double recordOutWeight = 0.0; /** * 倒出数量(单位KG) */ @Excel(name = "倒出数量(单位KG)", sort = 8) private Double changeOutWeight = 0.0; /** * 损耗数量(单位KG) */ @Excel(name = "损耗数量(单位KG)", sort = 9) private Double lossWeight = 0.0; /** * 期末数量(单位KG) */ @Excel(name = "期末数量(单位KG)", sort = 10) private Double finalWeight = 0.0; } fzzy-igdss-core/src/main/java/com/fzzy/igds/data/SuperInventoryReportParam.java
@@ -14,7 +14,7 @@ public class SuperInventoryReportParam extends IgdsBaseParam { // 收储公司 private String customerName; private String customerId; private String title; fzzy-igdss-core/src/main/java/com/fzzy/igds/service/SuperInventoryReportService.java
@@ -45,10 +45,9 @@ /** * 查询报表数据 * * @param param * @author sgj * @date 2025/12/19 * @param param */ public List<SuperInventoryReportData> listSuperInventoryReportData(SuperInventoryReportParam param) { //1.获取查询得起止时间,如果没有则,默认截止时间为当天,起始时间为30天前 @@ -66,12 +65,26 @@ //默认库区编码 String deptId = ContextUtil.subDeptId(null); param.setCompanyId(companyId); //region 查询条件收储公司和所属库区处理 if (StringUtils.isNotEmpty(param.getDeptId()) && StringUtils.isNotEmpty(param.getCustomerId())) { String substring = param.getDeptId().substring(0, (param.getDeptId().length() - 3)); if (!substring.equals(param.getCustomerId())) { return new ArrayList<SuperInventoryReportData>(); } } if (StringUtils.isEmpty(param.getDeptId())) { param.setDeptId(param.getCustomerId()); } //收储公司,所属库区查询均为空,则查询默认库区 if (StringUtils.isEmpty(param.getCustomerId()) && StringUtils.isEmpty(param.getDeptId())) { param.setDeptId(deptId); } //endregion //region 初始化需要范围的数据 Map<String, SuperInventoryReportData> resultMap = new HashMap<>(); Map<String, SuperInventoryReportData> columsMap = new HashMap<>(); //查询当前用户下属的所有库区 List<Dept> deptList = coreDeptService.getDeptData(); if (null == deptList || deptList.isEmpty()) { @@ -79,10 +92,12 @@ } //预加载所有部门下的仓库信息,减少重复查询 Map<String, Dept> deptCache = new HashMap<>(); Map<String, List<Depot>> deptDepotsMap = new HashMap<>(); Map<String, Company> companyCache = new HashMap<>(); for (Dept dept : deptList) { deptCache.put(dept.getId(), dept); //获取库区下所有仓库 List<Depot> depotList = depotService.getData(companyId, dept.getId(), true); if (null == depotList || depotList.isEmpty()) { @@ -99,27 +114,30 @@ } } //构建结果数据 //构建结果数据映射map for (Map.Entry<String, List<Depot>> entry : deptDepotsMap.entrySet()) { String deptIdKey = entry.getKey(); Company company = companyCache.get(deptIdKey.substring(0, deptIdKey.length() - 3)); Dept dept = deptCache.get(deptIdKey); for (Depot depot : entry.getValue()) { //库区编码+仓库编码组成唯一键 String key = deptIdKey + "_" + depot.getId(); SuperInventoryReportData data = new SuperInventoryReportData(); data.setCustomerName(Optional.ofNullable(company) data.setCustomerId(Optional.ofNullable(company) .map(Company::getId) .orElse("-")); data.setCustomerName(Optional.ofNullable(company) .map(Company::getDwmc) .orElse("-")); data.setDeptId(deptIdKey); data.setDeptName(dept.getKqmc()); data.setDepotId(depot.getId()); resultMap.put(key, data); data.setDepotName(depot.getName()); columsMap.put(key, data); } } //endregion if (resultMap.isEmpty()) { if (columsMap.isEmpty()) { return new ArrayList<>(); } @@ -137,10 +155,11 @@ .collect(Collectors.groupingBy(record -> record.getDeptId() + "_" + record.getDepotId())); //4. 根据库区、仓库为唯一键,组装报表数据 List<SuperInventoryReportData> result = new ArrayList<>(); Date todayZero = DateUtil.getCurZero(new Date()); boolean isEndDateBeforeToday = param.getEnd().before(todayZero); for (SuperInventoryReportData data : resultMap.values()) { for (SuperInventoryReportData data : columsMap.values()) { String dataKey = data.getDeptId() + "_" + data.getDepotId(); //获取库存数据 @@ -227,9 +246,10 @@ data.setChangeOutWeight(sumStockChangeOut); data.setLossWeight(sumLossOver); data.setFinalWeight(finalWeight); result.add(data); } return new ArrayList<>(resultMap.values()); return result; } /** @@ -238,7 +258,9 @@ private List<DepotStore> queryDepotStores(SuperInventoryReportParam param) { QueryWrapper<DepotStore> depotStoreQueryWrapper = new QueryWrapper<>(); depotStoreQueryWrapper.eq("company_id", param.getCompanyId()); depotStoreQueryWrapper.eq("dept_id", param.getDeptId()); if (StringUtils.isNotBlank(param.getDeptId())) { depotStoreQueryWrapper.likeRight("dept_id", param.getDeptId()); } depotStoreQueryWrapper.between("create_time", param.getStart(), param.getEnd()); depotStoreQueryWrapper.orderByAsc("create_time"); return depotStoreMapper.selectList(depotStoreQueryWrapper); @@ -250,7 +272,9 @@ private List<InoutRecord> queryInoutRecords(SuperInventoryReportParam param) { QueryWrapper<InoutRecord> inoutRecordQueryWrapper = new QueryWrapper<>(); inoutRecordQueryWrapper.eq("company_id", param.getCompanyId()); inoutRecordQueryWrapper.eq("dept_id", param.getDeptId()); if (StringUtils.isNotBlank(param.getDeptId())) { inoutRecordQueryWrapper.likeRight("dept_id", param.getDeptId()); } inoutRecordQueryWrapper.between("create_time", param.getStart(), param.getEnd()); inoutRecordQueryWrapper.orderByAsc("create_time"); return inoutRecordMapper.selectList(inoutRecordQueryWrapper); @@ -262,7 +286,9 @@ private List<InoutStockChange> queryInoutStockChanges(SuperInventoryReportParam param) { QueryWrapper<InoutStockChange> inoutStockChangeQueryWrapper = new QueryWrapper<>(); inoutStockChangeQueryWrapper.eq("company_id", param.getCompanyId()); inoutStockChangeQueryWrapper.eq("dept_id", param.getDeptId()); if (StringUtils.isNotBlank(param.getDeptId())) { inoutStockChangeQueryWrapper.likeRight("dept_id", param.getDeptId()); } inoutStockChangeQueryWrapper.between("create_time", param.getStart(), param.getEnd()); inoutStockChangeQueryWrapper.orderByAsc("create_time"); return inoutStockChangeMapper.selectList(inoutStockChangeQueryWrapper); @@ -274,7 +300,9 @@ private List<InoutLossOver> queryInoutLossOvers(SuperInventoryReportParam param) { QueryWrapper<InoutLossOver> inoutLossOverQueryWrapper = new QueryWrapper<>(); inoutLossOverQueryWrapper.eq("company_id", param.getCompanyId()); inoutLossOverQueryWrapper.eq("dept_id", param.getDeptId()); if (StringUtils.isNotBlank(param.getDeptId())) { inoutLossOverQueryWrapper.likeRight("dept_id", param.getDeptId()); } inoutLossOverQueryWrapper.between("create_time", param.getStart(), param.getEnd()); inoutLossOverQueryWrapper.orderByAsc("create_time"); return inoutLossOverMapper.selectList(inoutLossOverQueryWrapper); fzzy-igdss-view/src/main/java/com/fzzy/igds/ReportInDetailPR.java
@@ -77,15 +77,16 @@ //多参数分页查询 com.baomidou.mybatisplus.extension.plugins.pagination.Page<InoutRecord> corePage = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(0, 10000); //收储公司查询处理 if(StringUtils.isEmpty(param.getDeptId())){ param.setDeptId(param.getCompanyId()); } if(StringUtils.isNotEmpty(param.getDeptId()) && StringUtils.isNotEmpty(param.getCompanyId())){ String substring = param.getDeptId().substring(0, (param.getDeptId().length() - 3)); if (!substring.equals(param.getCompanyId())){ return new ArrayList<InoutRecord>(); } } if(StringUtils.isEmpty(param.getDeptId())){ param.setDeptId(param.getCompanyId()); } param.setCompanyId(null); inoutReportService.listPageInout(corePage, param); //获取查询到得list数据 fzzy-igdss-view/src/main/java/com/fzzy/igds/ReportOutDetailPR.java
@@ -77,15 +77,16 @@ //多参数分页查询 com.baomidou.mybatisplus.extension.plugins.pagination.Page<InoutRecord> corePage = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(0, 10000); //收储公司查询处理 if(StringUtils.isEmpty(param.getDeptId())){ param.setDeptId(param.getCompanyId()); } if(StringUtils.isNotEmpty(param.getDeptId()) && StringUtils.isNotEmpty(param.getCompanyId())){ String substring = param.getDeptId().substring(0, (param.getDeptId().length() - 3)); if (!substring.equals(param.getCompanyId())){ return new ArrayList<InoutRecord>(); } } if(StringUtils.isEmpty(param.getDeptId())){ param.setDeptId(param.getCompanyId()); } param.setCompanyId(null); inoutReportService.listPageInout(corePage, param); //获取查询到得list数据 fzzy-igdss-view/src/main/java/com/fzzy/igds/SuperInventoryReport.view.xml
@@ -5,7 +5,7 @@ <Model> <DataType name="dtMain"> <Property name="creationType">com.fzzy.igds.data.SuperInventoryReportData</Property> <PropertyDef name="customerName"> <PropertyDef name="customerId"> <Property name="label">收储公司</Property> <Property name="mapping"> <Property name="mapValues">${dorado.getDataProvider("companyPR#getData").getResult()}</Property> @@ -93,7 +93,7 @@ <Property name="label">截止时间</Property> <Property name="dataType">Date</Property> </PropertyDef> <PropertyDef name="customerName"> <PropertyDef name="customerId"> <Property></Property> <Property name="label">收储公司</Property> <Property name="mapping"> @@ -153,8 +153,8 @@ <Property name="labelWidth">110</Property> <Property name="exClassName">bg-color</Property> <AutoFormElement> <Property name="property">customerName</Property> <Property name="name">customerName</Property> <Property name="property">customerId</Property> <Property name="name">customerId</Property> </AutoFormElement> <AutoFormElement> <Property name="name">deptId</Property> @@ -185,6 +185,14 @@ <Property name="caption">重置</Property> </Button> <Button layoutConstraint="left"> <ClientEvent name="onClick">var data = view.get("#dsQuery.data");
 var param = {
 "deptId":data.get("deptId"),
 "customerId":data.get("customerId"),
 "start":data.get("start"),
 "end":data.get("end")
 }
 window.parent.$.table.exportExcelDorado("./export/superInventoryReport-excel", "库存数据", param);</ClientEvent> <Property name="caption">导出EXCEL</Property> <Property name="exClassName">btn-q2</Property> <Property name="width">140</Property> @@ -244,35 +252,46 @@ <Property name="headerRowHeight">30</Property> <Property name="rowHeight">50</Property> <RowNumColumn/> <DataColumn name="customerName"> <Property name="property">customerName</Property> <DataColumn> <Property name="property">customerId</Property> <Property name="width">326</Property> <Property name="name">customerId</Property> </DataColumn> <DataColumn name="deptId"> <Property name="property">deptId</Property> <Property name="width">250</Property> </DataColumn> <DataColumn name="depotId"> <Property name="property">depotId</Property> <Property name="width">326</Property> </DataColumn> <DataColumn name="initialWeight"> <Property name="property">initialWeight</Property> <Property name="width">100</Property> </DataColumn> <DataColumn name="recordInWeight"> <Property name="property">recordInWeight</Property> <Property name="width">100</Property> </DataColumn> <DataColumn name="changeInWeight"> <Property name="property">changeInWeight</Property> <Property name="width">100</Property> </DataColumn> <DataColumn name="recordOutWeight"> <Property name="property">recordOutWeight</Property> <Property name="width">100</Property> </DataColumn> <DataColumn name="changeOutWeight"> <Property name="property">changeOutWeight</Property> <Property name="width">100</Property> </DataColumn> <DataColumn name="lossWeight"> <Property name="property">lossWeight</Property> <Property name="width">100</Property> </DataColumn> <DataColumn name="finalWeight"> <Property name="property">finalWeight</Property> <Property name="width">100</Property> </DataColumn> </DataGrid> <ToolBar id="tool" layoutConstraint="bottom"> fzzy-igdss-view/src/main/java/com/fzzy/igds/export/ReportController.java
@@ -3,10 +3,15 @@ import com.fzzy.igds.ReportInDetailPR; import com.fzzy.igds.ReportOutDetailPR; import com.fzzy.igds.SuperInventoryReportPR; import com.fzzy.igds.data.InoutParam; import com.fzzy.igds.data.SuperInventoryReportData; import com.fzzy.igds.data.SuperInventoryReportParam; import com.fzzy.igds.domain.Company; import com.fzzy.igds.domain.Depot; import com.fzzy.igds.domain.Dept; import com.fzzy.igds.domain.InoutRecord; import com.fzzy.igds.service.InoutRecordService; import com.fzzy.igds.service.SysDeptService; import com.fzzy.igds.service.*; import com.fzzy.igds.utils.ContextUtil; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.entity.SysDept; @@ -19,7 +24,9 @@ import javax.annotation.Resource; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /** @@ -39,11 +46,26 @@ @Resource private SysDeptService sysDeptService; @Resource private CoreDeptService coreDeptService; @Resource private DepotService depotService; @Resource private CoreCompanyService coreCompanyService; @Autowired private ReportInDetailPR reportInDetailPR; @Autowired private ReportOutDetailPR reportOutDetailPR; @Autowired private SuperInventoryReportPR superInventoryReportPR; @@ -81,4 +103,28 @@ return util.exportExcel(list, sheetName, deptName); } /** * 库存报表导出 * @return */ @RequestMapping("/superInventoryReport-excel") @ResponseBody public AjaxResult superInventoryReport(SuperInventoryReportParam param) { //设置标题 String sheetName = "库存报表数据"; //查询数据 List<SuperInventoryReportData> list = superInventoryReportPR.getReportData(param); //获取分库编码对应的分库名称 String deptName = ""; SysDept subDept = sysDeptService.getCacheDept(null, ContextUtil.subDeptId(null)); if (null != subDept) { deptName = subDept.getDeptName(); } //导出 ExcelUtil<SuperInventoryReportData> util = new ExcelUtil<SuperInventoryReportData>(SuperInventoryReportData.class); return util.exportExcel(list, sheetName, deptName); } }