| | |
| | | package com.fzzy.common; |
| | | |
| | | import com.fzzy.common.manager.ExportManager; |
| | | import com.fzzy.igds.ReportInDetailPR; |
| | | import com.fzzy.igds.ReportOutDetailPR; |
| | | import com.fzzy.igds.SuperInventoryReportPR; |
| | | import com.fzzy.igds.data.ExportWordParam; |
| | | import com.fzzy.igds.data.InoutParam; |
| | | import com.fzzy.igds.data.SuperInventoryReportData; |
| | | import com.fzzy.igds.data.SuperInventoryReportParam; |
| | | import com.fzzy.igds.*; |
| | | import com.fzzy.igds.constant.FoodVariety; |
| | | import com.fzzy.igds.data.*; |
| | | 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.SysDeptService; |
| | | import com.fzzy.igds.utils.ContextUtil; |
| | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Optional; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @Description 数据导出入口 |
| | |
| | | @Resource |
| | | private SysDeptService sysDeptService; |
| | | @Resource |
| | | private ReportInDetailPR reportInDetailPR; |
| | | private ReportInoutPR reportInoutPR; |
| | | @Resource |
| | | private ReportOutDetailPR reportOutDetailPR; |
| | | private CompanyPR companyPR; |
| | | @Resource |
| | | private SuperInventoryReportPR superInventoryReportPR; |
| | | private DeptPR deptPR; |
| | | @Resource |
| | | private DepotPR depotPR; |
| | | |
| | | /** |
| | | * 导出word并下载 |
| | |
| | | param.setBizId(bizId); |
| | | param.setEntityName(entityName); |
| | | exportManager.renderWordDownload(param, response); |
| | | } |
| | | |
| | | /** |
| | | * 导出word并下载 |
| | | * |
| | | * @param response |
| | | */ |
| | | @RequestMapping("/download-inout-excel") |
| | | public void downloadInoutExcel(HttpServletResponse response) { |
| | | |
| | | exportManager.downloadInoutExcel(response); |
| | | } |
| | | |
| | | /** |
| | |
| | | @RequestMapping("/inout-excel") |
| | | @ResponseBody |
| | | public AjaxResult inOutExcel(InoutParam param) { |
| | | //设置标题 |
| | | //设置标题 |
| | | String sheetName = "报表数据"; |
| | | //查询数据 |
| | | List<InoutRecord> list = new ArrayList<>(); |
| | | |
| | | if (StringUtils.isNotEmpty(param.getType()) && "IN".equals(param.getType())) { |
| | | sheetName = "入库报表数据"; |
| | | list = reportInDetailPR.listRecord(param); |
| | | } |
| | | |
| | | if (StringUtils.isNotEmpty(param.getType()) && "OUT".equals(param.getType())) { |
| | | sheetName = "出库报表数据"; |
| | | list = reportOutDetailPR.listRecord(param); |
| | | } |
| | | |
| | | //获取分库编码对应的分库名称 |
| | | String deptName = ""; |
| | | SysDept subDept = sysDeptService.getCacheDept(null, ContextUtil.subDeptId(null)); |
| | | if (null != subDept) { |
| | | deptName = subDept.getDeptName(); |
| | | } |
| | | //创建收储公司ID到名称的映射 |
| | | Map<String, String> companyMap = Optional.ofNullable(companyPR.getData()) |
| | | .orElse(new ArrayList<>()) |
| | | .stream() |
| | | .collect(Collectors.toMap(Company::getId, Company::getDwmc, (key1, key2) -> key2)); |
| | | //创建所在库区ID到名称的映射 |
| | | Map<String, String> deptMap = Optional.ofNullable(deptPR.getAllData()) |
| | | .orElse(new ArrayList<>()) |
| | | .stream() |
| | | .collect(Collectors.toMap(Dept::getId, Dept::getKqmc, (key1, key2) -> key2)); |
| | | // 创建仓库ID到名称的映射 |
| | | Map<String, String> depotMap = Optional.ofNullable(depotPR.getData(null)) |
| | | .orElse(new ArrayList<>()) |
| | | .stream() |
| | | .collect(Collectors.toMap(Depot::getId, Depot::getName, (key1, key2) -> key2)); |
| | | |
| | | //导出 |
| | | ExcelUtil<InoutRecord> util = new ExcelUtil<InoutRecord>(InoutRecord.class); |
| | | return util.exportExcel(list, sheetName, deptName); |
| | | //组装实际导出数据 |
| | | if (StringUtils.isNotEmpty(param.getType()) && "IN".equals(param.getType())) { |
| | | sheetName = "入库报表数据"; |
| | | list = reportInoutPR.listRecord(param); |
| | | List<InoutRecordInExport> exportList = new ArrayList<>(); |
| | | InoutRecordInExport export; |
| | | for (InoutRecord record : list) { |
| | | export = new InoutRecordInExport(); |
| | | export.setId(record.getId()); |
| | | export.setPlateNum(record.getPlateNum()); |
| | | // 将仓库ID映射为仓库名称 |
| | | String depotNameValue = depotMap.get(record.getDepotId()); |
| | | export.setDepotId(depotNameValue != null ? depotNameValue : ""); |
| | | //粮食品种映射 |
| | | String foodVarietyNameValue = FoodVariety.getMsg(record.getFoodVariety()); |
| | | export.setFoodVariety(foodVarietyNameValue != null ? foodVarietyNameValue : ""); |
| | | export.setFullWeight(record.getFullWeight()); |
| | | export.setEmptyWeight(record.getEmptyWeight()); |
| | | export.setNetWeight(record.getNetWeight()); |
| | | export.setSettleWeight(record.getSettleWeight()); |
| | | export.setRecordWeight(record.getRecordWeight()); |
| | | export.setCompleteTime(record.getCompleteTime()); |
| | | export.setDeOther(record.getDeOther()); |
| | | export.setUpdateLog(record.getUpdateLog()); |
| | | exportList.add(export); |
| | | } |
| | | ExcelUtil<InoutRecordInExport> util = new ExcelUtil<InoutRecordInExport>(InoutRecordInExport.class); |
| | | return util.exportExcel(exportList, sheetName, deptName); |
| | | } |
| | | |
| | | if (StringUtils.isNotEmpty(param.getType()) && "OUT".equals(param.getType())) { |
| | | sheetName = "出库报表数据"; |
| | | list = reportInoutPR.listRecord(param); |
| | | List<InoutRecordOutExport> exportList = new ArrayList<>(); |
| | | InoutRecordOutExport export; |
| | | for (InoutRecord record : list) { |
| | | export = new InoutRecordOutExport(); |
| | | export.setId(record.getId()); |
| | | export.setPlateNum(record.getPlateNum()); |
| | | // 将仓库ID映射为仓库名称 |
| | | String depotNameValue = depotMap.get(record.getDepotId()); |
| | | export.setDepotId(depotNameValue != null ? depotNameValue : ""); |
| | | //粮食品种映射 |
| | | String foodVarietyNameValue = FoodVariety.getMsg(record.getFoodVariety()); |
| | | export.setFoodVariety(foodVarietyNameValue != null ? foodVarietyNameValue : ""); |
| | | export.setFullWeight(record.getFullWeight()); |
| | | export.setEmptyWeight(record.getEmptyWeight()); |
| | | export.setNetWeight(record.getNetWeight()); |
| | | export.setSettleWeight(record.getSettleWeight()); |
| | | export.setRecordWeight(record.getRecordWeight()); |
| | | export.setCompleteTime(record.getCompleteTime()); |
| | | export.setDeOther(record.getDeOther()); |
| | | export.setUpdateLog(record.getUpdateLog()); |
| | | exportList.add(export); |
| | | } |
| | | ExcelUtil<InoutRecordOutExport> util = new ExcelUtil<InoutRecordOutExport>(InoutRecordOutExport.class); |
| | | return util.exportExcel(exportList, sheetName, deptName); |
| | | } |
| | | |
| | | if (StringUtils.isNotEmpty(param.getType()) && "IN_DETAIL".equals(param.getType())) { |
| | | sheetName = "入库明细报表数据"; |
| | | list = reportInoutPR.listRecord(param); |
| | | List<InoutRecordDetailInExport> exportList = new ArrayList<>(); |
| | | InoutRecordDetailInExport export; |
| | | for (InoutRecord record : list) { |
| | | export = new InoutRecordDetailInExport(); |
| | | //收储公司映射 |
| | | String companyNameValue = companyMap.get(record.getCompanyId()); |
| | | export.setCompanyId(companyNameValue != null ? companyNameValue : ""); |
| | | //库区映射 |
| | | String deptNameValue = deptMap.get(record.getDeptId()); |
| | | export.setDeptId(deptNameValue != null ? deptNameValue : ""); |
| | | export.setId(record.getId()); |
| | | export.setPlateNum(record.getPlateNum()); |
| | | // 将仓库ID映射为仓库名称 |
| | | String depotNameValue = depotMap.get(record.getDepotId()); |
| | | export.setDepotId(depotNameValue != null ? depotNameValue : ""); |
| | | //粮食品种映射 |
| | | String foodVarietyNameValue = FoodVariety.getMsg(record.getFoodVariety()); |
| | | export.setFoodVariety(foodVarietyNameValue != null ? foodVarietyNameValue : ""); |
| | | export.setSettleWeight(record.getSettleWeight()); |
| | | export.setRecordWeight(record.getRecordWeight()); |
| | | export.setCompleteTime(record.getCompleteTime()); |
| | | export.setUpdateLog(record.getUpdateLog()); |
| | | exportList.add(export); |
| | | } |
| | | ExcelUtil<InoutRecordDetailInExport> util = new ExcelUtil<InoutRecordDetailInExport>(InoutRecordDetailInExport.class); |
| | | return util.exportExcel(exportList, sheetName, deptName); |
| | | } |
| | | |
| | | if (StringUtils.isNotEmpty(param.getType()) && "OUT_DETAIL".equals(param.getType())) { |
| | | sheetName = "出库明细报表数据"; |
| | | list = reportInoutPR.listRecord(param); |
| | | List<InoutRecordDetailOutExport> exportList = new ArrayList<>(); |
| | | InoutRecordDetailOutExport export; |
| | | for (InoutRecord record : list) { |
| | | export = new InoutRecordDetailOutExport(); |
| | | //收储公司映射 |
| | | String companyNameValue = companyMap.get(record.getCompanyId()); |
| | | export.setCompanyId(companyNameValue != null ? companyNameValue : ""); |
| | | //库区映射 |
| | | String deptNameValue = deptMap.get(record.getDeptId()); |
| | | export.setDeptId(deptNameValue != null ? deptNameValue : ""); |
| | | export.setId(record.getId()); |
| | | export.setPlateNum(record.getPlateNum()); |
| | | // 将仓库ID映射为仓库名称 |
| | | String depotNameValue = depotMap.get(record.getDepotId()); |
| | | export.setDepotId(depotNameValue != null ? depotNameValue : ""); |
| | | //粮食品种映射 |
| | | String foodVarietyNameValue = FoodVariety.getMsg(record.getFoodVariety()); |
| | | export.setFoodVariety(foodVarietyNameValue != null ? foodVarietyNameValue : ""); |
| | | export.setSettleWeight(record.getSettleWeight()); |
| | | export.setRecordWeight(record.getRecordWeight()); |
| | | export.setCompleteTime(record.getCompleteTime()); |
| | | export.setUpdateLog(record.getUpdateLog()); |
| | | exportList.add(export); |
| | | } |
| | | ExcelUtil<InoutRecordDetailOutExport> util = new ExcelUtil<InoutRecordDetailOutExport>(InoutRecordDetailOutExport.class); |
| | | return util.exportExcel(exportList, sheetName, deptName); |
| | | } |
| | | return AjaxResult.error("参数错误"); |
| | | } |
| | | |
| | | /** |
| | |
| | | //设置标题 |
| | | String sheetName = "库存报表数据"; |
| | | //查询数据 |
| | | List<SuperInventoryReportData> list = superInventoryReportPR.getReportData(param); |
| | | List<SuperInventoryReportData> list = reportInoutPR.getStoreData(param); |
| | | //获取分库编码对应的分库名称 |
| | | String deptName = ""; |
| | | SysDept subDept = sysDeptService.getCacheDept(null, ContextUtil.subDeptId(null)); |