package com.fzzy.igds; import com.bstek.dorado.annotation.DataProvider; import com.fzzy.igds.constant.Constant; import com.fzzy.igds.data.InoutParam; import com.fzzy.igds.data.SuperInventoryReportData; import com.fzzy.igds.data.SuperInventoryReportParam; import com.fzzy.igds.domain.InoutRecord; import com.fzzy.igds.service.InoutRecordService; import com.fzzy.igds.service.SuperInventoryReportService; import com.fzzy.igds.service.SysDeptService; import com.fzzy.igds.utils.ContextUtil; import com.fzzy.igds.utils.DateUtil; import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.common.utils.StringUtils; import org.apache.commons.lang3.time.DateFormatUtils; import org.springframework.stereotype.Component; import javax.annotation.Resource; import java.util.*; /** * @Description 出入库相关报表 * @Author CZT * @Date 2025/12/29 10:32 */ @Component public class ReportInoutPR { @Resource private InoutRecordService inoutReportService; @Resource private SysDeptService sysDeptService; @Resource private SuperInventoryReportService superInventoryReportService; /** * reportInoutPR#getQueryInout * * @param * @return */ @DataProvider public Map getQueryInout(InoutParam param) { Map result = new HashMap(); //获取参数中报表类型 String type = param.getType(); //获取参数中分库编码 String deptId = param.getDeptId(); result.put("deptId", deptId); //获取分库编码对应的分库名称 String deptName = ""; SysDept subDept = sysDeptService.getCacheDept(null, ContextUtil.subDeptId(null)); if (null != subDept) { deptName = subDept.getDeptName(); } String title = "汇总表"; if ("IN".equals(type)) { title= deptName + "入库明细汇总"; } if ("OUT".equals(type)) { title= deptName + "出库明细汇总"; } if ("STORE".equals(type)) { title= deptName + "库存汇总表"; } result.put("end", new Date()); Date start = DateUtil.getNewByDay(new Date(), -30); result.put("start", start); result.put("timeDesc", DateFormatUtils.format(start, "yyyy-MM-dd") + " 至 " + DateFormatUtils.format(new Date(), "yyyy-MM-dd")); result.put("createUser", ContextUtil.getLoginUserName()); result.put("createTime", new Date()); result.put("title", title); result.put("type", type); return result; } /** * reportInoutPR#getQuery 根据报表类型,获取默认查询信息,比如表头信息等 * * @param * @return */ @DataProvider public Map getQueryStore(SuperInventoryReportParam param) { Map result = new HashMap(); //获取参数中分库编码 String deptId = param.getDeptId(); result.put("deptId", deptId); //获取分库编码对应的分库名称 String deptName = ""; SysDept subDept = sysDeptService.getCacheDept(null, ContextUtil.subDeptId(null)); if (null != subDept) { deptName = subDept.getDeptName(); } String title = deptName + "库存汇总表"; result.put("end", new Date()); Date start = DateUtil.getNewByDay(new Date(), -30); result.put("start", start); result.put("timeDesc", DateFormatUtils.format(start, "yyyy-MM-dd") + " 至 " + DateFormatUtils.format(new Date(), "yyyy-MM-dd")); result.put("createUser", ContextUtil.getLoginUserName()); result.put("createTime", new Date()); result.put("title", title); return result; } /** * 出入库汇总表 * reportInoutPR#listRecord 报表数据,只获取已经完成的,并且非异常数据和删除数据 * * @param param * @return */ @DataProvider public List listRecord(InoutParam param) { if (null == param) { param = new InoutParam(); } //查询入库数据 param.setProgress(Constant.PROGRESS_RECORD); param.setRecordStatus(Constant.RECORD_STATUS_NORMAL); //多参数分页查询 com.baomidou.mybatisplus.extension.plugins.pagination.Page corePage = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(0, 10000); //收储公司查询处理 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(); } } if(StringUtils.isEmpty(param.getDeptId())){ param.setDeptId(param.getCompanyId()); } param.setCompanyId(null); inoutReportService.listPageInout(corePage, param); //获取查询到得list数据 List result = corePage.getRecords(); if (null == result || result.isEmpty()) { return result; } // 添加统计信息 double emptyWeightSum = 0.0, fullWeightSum = 0.0, deCheck = 0.0, addCheck = 0.0, deWetSum = 0.0, deImpuritySum = 0.0, deHandleSum = 0.0, deOtherSum = 0.0, deSumSum = 0.0, netWeightSum = 0.0, settleWeightSum = 0.0; int index = 1; List list = new ArrayList<>(); for (InoutRecord record : result) { if(StringUtils.isNotBlank(record.getDeptId())){ record.setCompanyId(record.getDeptId().substring(0,(record.getDeptId().length()-3))); } list.add(record); record.setRemarks(String.valueOf(index)); emptyWeightSum += record.getEmptyWeight(); fullWeightSum += record.getFullWeight(); deOtherSum += record.getDeOther(); netWeightSum += record.getNetWeight(); settleWeightSum += record.getSettleWeight(); index++; } InoutRecord sum = new InoutRecord(); sum.setId("合计"); sum.setEmptyWeight(emptyWeightSum); sum.setFullWeight(fullWeightSum); sum.setDeOther(deOtherSum); sum.setNetWeight(netWeightSum); sum.setSettleWeight(settleWeightSum); if (sum.getNoticeId() == null) sum.setNoticeId(""); if (sum.getDepotId() == null) sum.setDepotId(""); if (sum.getProgress() == null) sum.setProgress(""); if (sum.getUserName() == null) sum.setUserName(""); if (sum.getPlateNum() == null) sum.setPlateNum(""); if (sum.getFoodVariety() == null) sum.setFoodVariety(""); list.add(sum); return list; } /** * reportInoutPR#getStoreData * * @param param */ @DataProvider public List getStoreData(SuperInventoryReportParam param) { if (null == param) { param = new SuperInventoryReportParam(); } return superInventoryReportService.listSuperInventoryReportData(param); } }