|
@@ -1,12 +1,13 @@
|
|
|
package com.jeeplus.modules.sg.balancedlibrary.materialReportDetails.utils;
|
|
|
|
|
|
import com.jeeplus.common.utils.DateUtils;
|
|
|
+import com.jeeplus.modules.sg.balancedlibrary.liKuResourcePool.entity.LiKuResourcePool;
|
|
|
+import com.jeeplus.modules.sg.balancedlibrary.materialQuota.entity.MaterialQuota;
|
|
|
import com.jeeplus.modules.sg.balancedlibrary.materialReportDetails.entity.LikuDetail;
|
|
|
import com.jeeplus.modules.sg.balancedlibrary.materialReportDetails.entity.MaterialReportDetails;
|
|
|
-import com.jeeplus.modules.sg.financial.settlement.entity.CostCheck;
|
|
|
-import com.jeeplus.modules.sg.financial.settlement.entity.ProjectBudget;
|
|
|
-import com.jeeplus.modules.sg.financial.settlement.util.MyExportUtil;
|
|
|
-import org.apache.poi.hssf.usermodel.HSSFFont;
|
|
|
+import com.jeeplus.modules.sg.balancedlibrary.preferredMaterials.entity.PreferredMaterials;
|
|
|
+import com.jeeplus.modules.sg.balancedlibrary.standardMaterials.entity.StandardMaterials;
|
|
|
+import com.jeeplus.modules.sg.balancedlibrary.transitMaterialGoods.entity.TransitMaterialGoods;
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFFont;
|
|
@@ -14,10 +15,12 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.*;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.net.URLEncoder;
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
-import java.util.Date;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
public class ExportUtil {
|
|
|
private XSSFCellStyle style = null;
|
|
@@ -28,7 +31,7 @@ public class ExportUtil {
|
|
|
|
|
|
public ExportUtil(){
|
|
|
try {
|
|
|
- String path = this.getClass().getResource("/").getPath() + "/freemarker/excelmodel/materialReport.xlsx";
|
|
|
+ String path = this.getClass().getResource("/").getPath() + "/freemarker/excelmodel/materialReport02.xlsx";
|
|
|
File file = new File(path);
|
|
|
InputStream inputStream = new FileInputStream(file);// 将excel文件转为输入流
|
|
|
workbook = new XSSFWorkbook(inputStream);// 创建个workbook,
|
|
@@ -43,11 +46,109 @@ public class ExportUtil {
|
|
|
* 导出费用检查管理
|
|
|
* @param response
|
|
|
*/
|
|
|
- public void exportDetails(HttpServletResponse response, List<MaterialReportDetails> reportList, List<LikuDetail> likuList){
|
|
|
+ public void exportDetails(HttpServletResponse response, List<MaterialReportDetails> reportList, List<LikuDetail> likuList,
|
|
|
+ List<StandardMaterials> standardList,List<String> preferredCodes,
|
|
|
+ List<MaterialQuota> quotaList,List<TransitMaterialGoods> goodsList,
|
|
|
+ Map<String, String> reportPersonMap,List<PreferredMaterials> materialsList,
|
|
|
+ List<LiKuResourcePool> poolList){
|
|
|
OutputStream outputStream = null;
|
|
|
+
|
|
|
+ //利库map 批次
|
|
|
+ Map<String,LiKuResourcePool> likuMap = new HashMap();
|
|
|
+ for (LiKuResourcePool pool : poolList){
|
|
|
+ likuMap.put(pool.getBatch(),pool);
|
|
|
+ }
|
|
|
+
|
|
|
+ //标准物资map
|
|
|
+ Map<String,StandardMaterials> stanMater = new HashMap();
|
|
|
+ for (StandardMaterials materials : standardList){
|
|
|
+ stanMater.put(materials.getMaterialCode(),materials);
|
|
|
+ }
|
|
|
+ //优选物料map
|
|
|
+ Map<String,PreferredMaterials> preferMap = new HashMap();
|
|
|
+ for (PreferredMaterials materials : materialsList){
|
|
|
+ preferMap.put(materials.getMaterialCode(),materials);
|
|
|
+ }
|
|
|
+ //采购标准标识
|
|
|
+ /*Map<String,StandardMaterials> standardMap = new HashMap<>();
|
|
|
+ for(StandardMaterials standard:standardList){
|
|
|
+ standardMap.put(standard.getMaterialCode(),standard);
|
|
|
+ }*/
|
|
|
+ //物资数量校验
|
|
|
+ Map<String,MaterialQuota> quotaMap = new HashMap<>();
|
|
|
+ for(MaterialQuota quota:quotaList){
|
|
|
+ quotaMap.put(quota.getMaterialCode(),quota);
|
|
|
+ }
|
|
|
+ //在途物资统计校验
|
|
|
+ //在途物资统计表 key=统计物料编码-部门 去重汇总统计
|
|
|
+ Map<String, BigDecimal> onPassageMaterialsMap = new HashMap<>();
|
|
|
+ //项目物资需求表 key=统计物料编码-部门 去重汇总统计
|
|
|
+ Map<String, BigDecimal> materialInformationMap = new HashMap<>();
|
|
|
+ //在途物资统计表与项目物资需求表比较 在途物资统计表J列>=项目物资需求表H列 标识
|
|
|
+ List<String> flagList = new ArrayList<>();
|
|
|
+
|
|
|
+ //在途物资统计表 去重汇总统计
|
|
|
+ goodsList.forEach(opm -> {
|
|
|
+ if (com.jeeplus.common.utils.StringUtils.isBlank(opm.getContractCount())) {
|
|
|
+ opm.setContractCount("0");
|
|
|
+ }
|
|
|
+ //根据提报人 找到对应部门
|
|
|
+ String reportPersonOfDepartment = reportPersonMap.get(opm.getPlanner());
|
|
|
+ //如果没有部门 表示空部门 物料编码-部门
|
|
|
+ String key = "";
|
|
|
+ if (reportPersonOfDepartment == null) {
|
|
|
+ key = opm.getMaterialCode() + "-";
|
|
|
+ } else {
|
|
|
+ key = opm.getMaterialCode() + "-" + reportPersonOfDepartment;
|
|
|
+ }
|
|
|
+ if (onPassageMaterialsMap.containsKey(key)) {
|
|
|
+ onPassageMaterialsMap.put(key, new BigDecimal(opm.getContractCount()).add(onPassageMaterialsMap.get(key)));
|
|
|
+ } else {
|
|
|
+ if (com.jeeplus.common.utils.StringUtils.isNotBlank(opm.getMaterialCode())) {
|
|
|
+ onPassageMaterialsMap.put(key, new BigDecimal(opm.getContractCount()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ //项目物资需求表 去重汇总统计
|
|
|
+ reportList.forEach(m -> {
|
|
|
+ if (com.jeeplus.common.utils.StringUtils.isBlank(m.getTotal().toString())) {
|
|
|
+ m.setTotal(0.0);
|
|
|
+ }
|
|
|
+ //物料编码-部门
|
|
|
+ if (m.getReportDepartment() == null){
|
|
|
+ m.setReportDepartment("");
|
|
|
+ }
|
|
|
+ String key = m.getMaterialCode() + "-" + m.getReportDepartment();
|
|
|
+// likuCMap.put(key,m);
|
|
|
+ if (materialInformationMap.containsKey(key)) {
|
|
|
+ materialInformationMap.put(key, new BigDecimal(m.getTotal()).add(materialInformationMap.get(key)));
|
|
|
+ } else {
|
|
|
+ if (com.jeeplus.common.utils.StringUtils.isNotBlank(m.getMaterialCode())) {
|
|
|
+ materialInformationMap.put(key, new BigDecimal(m.getTotal()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ //两表比较 添加标识
|
|
|
+ materialInformationMap.forEach((k, v) -> {
|
|
|
+ if (onPassageMaterialsMap.containsKey(k)) {
|
|
|
+ if (onPassageMaterialsMap.get(k).compareTo(v) >= 0) {
|
|
|
+ flagList.add(k);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ Map<String,String> test = new HashMap<>();
|
|
|
+ //根据标识在原表中追加备注
|
|
|
+ reportList.forEach(l -> {
|
|
|
+ String key = l.getMaterialCode() + "-" + l.getReportDepartment();
|
|
|
+ if (flagList.contains(key)) {
|
|
|
+ l.setRemarkText("在途已有" + onPassageMaterialsMap.get(key) + "单位,请核实本次需求");
|
|
|
+ test.put(l.getMaterialCode(),l.getRemarkText());
|
|
|
+ }
|
|
|
+ });
|
|
|
try {
|
|
|
int rowNum = 2;
|
|
|
- //处理利库汇总情况
|
|
|
+ /*//处理利库汇总情况
|
|
|
Sheet sheet1 = workbook.getSheetAt(0);
|
|
|
if(reportList!=null&&reportList.size()>0){
|
|
|
for(int i=0;i<reportList.size();i++){
|
|
@@ -90,16 +191,18 @@ public class ExportUtil {
|
|
|
cell14.setCellValue(getDouble(report.getNumberOfApplications()));
|
|
|
|
|
|
}
|
|
|
- }
|
|
|
+ }*/
|
|
|
+ //隐藏利库汇总情况sheet
|
|
|
+ workbook.setSheetHidden(workbook.getSheetIndex("利库汇总情况"),1);
|
|
|
//利库明细情况
|
|
|
Sheet sheet2 = workbook.getSheetAt(1);
|
|
|
if(reportList!=null&&reportList.size()>0){
|
|
|
for(int i=0;i<reportList.size();i++){
|
|
|
MaterialReportDetails report = reportList.get(i);
|
|
|
//当利库数量不为0时 标红
|
|
|
- Double likuAmount = report.getNumberOfNiches();
|
|
|
+// Double likuAmount = report.getNumberOfNiches();
|
|
|
int color = 0;
|
|
|
- if(likuAmount>0) color=1;
|
|
|
+// if(likuAmount>0) color=1;
|
|
|
|
|
|
Row row = sheet2.createRow(rowNum+i);
|
|
|
Cell cell0 = crateCell(workbook,row,0,color); //上报地区
|
|
@@ -116,114 +219,247 @@ public class ExportUtil {
|
|
|
Cell cell11 = crateCell(workbook,row,11,color);//提报人
|
|
|
Cell cell12 = crateCell(workbook,row,12,color);//提报部门
|
|
|
Cell cell13 = crateCell(workbook,row,13,color); //备注
|
|
|
- Cell cell14 = crateCell(workbook,row,14,color); //利库数量
|
|
|
- Cell cell15 = crateCell(workbook,row,15,color); //利库金额
|
|
|
- Cell cell16 = crateCell(workbook,row,16,color); //申请数量
|
|
|
- Cell cell17 = crateCell(workbook,row,17,color); //本地利库批次号
|
|
|
- Cell cell18 = crateCell(workbook,row,18,color); //本地利库库存地
|
|
|
- Cell cell19 = crateCell(workbook,row,19,color); //本地利库数量
|
|
|
- Cell cell20 = crateCell(workbook,row,20,color); //跨区利库批次号
|
|
|
- Cell cell21 = crateCell(workbook,row,21,color); //跨区利库库存地
|
|
|
- Cell cell22 = crateCell(workbook,row,22,color); //跨区利库数量
|
|
|
- Cell cell23 = crateCell(workbook,row,23,color); //本地替代利库利库扩展编码
|
|
|
- Cell cell24 = crateCell(workbook,row,24,color); //本地替代利库利库扩展描述
|
|
|
- Cell cell25 = crateCell(workbook,row,25,color); //本地替代利库利库批次号
|
|
|
- Cell cell26 = crateCell(workbook,row,26,color); //本地替代利库利库库存地
|
|
|
- Cell cell27 = crateCell(workbook,row,27,color); //本地替代利库利库数量
|
|
|
- Cell cell28 = crateCell(workbook,row,28,color); //跨区替代利库利库扩展编码
|
|
|
- Cell cell29 = crateCell(workbook,row,29,color); //跨区替代利库利库扩展描述
|
|
|
- Cell cell30 = crateCell(workbook,row,30,color); //跨区替代利库利库批次号
|
|
|
- Cell cell31 = crateCell(workbook,row,31,color); //跨区替代利库利库库存地
|
|
|
- Cell cell32 = crateCell(workbook,row,32,color); //跨区替代利库利库数量
|
|
|
+ Cell cell14 = crateCell(workbook,row,14,color); //标准物料 从bla_standard_materials表中获取 该表中物料编码字段唯一
|
|
|
+ Cell cell15 = crateCell(workbook,row,15,color); //大类 从bla_standard_materials表中获取
|
|
|
+ Cell cell16 = crateCell(workbook,row,16,color); //中类 从bla_standard_materials表中获取
|
|
|
+ Cell cell17 = crateCell(workbook,row,17,color); //小类 从bla_standard_materials表中获取
|
|
|
+ Cell cell18 = crateCell(workbook,row,18,color); //小类是否在清单内 从bla_preferred_materials表中获取区域字段 该表中物料编码字段唯一
|
|
|
+ Cell cell19 = crateCell(workbook,row,19,color); //优选标识 从bla_preferred_materials表中获取三级清单物料字段
|
|
|
+ Cell cell20 = crateCell(workbook,row,20,color); //在途说明 通过数据操作获取
|
|
|
+ Cell cell21 = crateCell(workbook,row,21,color); //审核说明 通过数据操作获取
|
|
|
+ Cell cell22 = crateCell(workbook,row,22,color); //意见反馈 空着
|
|
|
+ Cell cell23 = crateCell(workbook,row,23,color); //库存计划编制人 从bla_resource_pool 表中获取计划编制人字段
|
|
|
+ Cell cell24 = crateCell(workbook,row,24,color); //库存批次 由本地利库批次号、跨区利库批次号、本地替代利库利库批次号、跨区替代利库利库批次号拼接组成
|
|
|
+ Cell cell25 = crateCell(workbook,row,25,color); //库存数量 从bla_resource_pool 表中获取库存数量字段
|
|
|
+ Cell cell26 = crateCell(workbook,row,26,color); //库存地点 由本地利库库存地、跨区利库库存地、本地替代利库利库库存地、跨区替代利库利库库存地根据规则拼接
|
|
|
+ Cell cell27 = crateCell(workbook,row,27,color); //利库数量
|
|
|
+ Cell cell28 = crateCell(workbook,row,28,color); //申报数量
|
|
|
+ Cell cell29 = crateCell(workbook,row,29,color); //本地利库批次号
|
|
|
+ Cell cell30 = crateCell(workbook,row,30,color); //本地利库库存地
|
|
|
+ Cell cell31 = crateCell(workbook,row,31,color); //本地利库数量
|
|
|
+ Cell cell32 = crateCell(workbook,row,32,color); //跨区利库批次号
|
|
|
+ Cell cell33 = crateCell(workbook,row,33,color); //跨区利库库存地
|
|
|
+ Cell cell34 = crateCell(workbook,row,34,color); //跨区利库数量
|
|
|
+ Cell cell35 = crateCell(workbook,row,35,color); //本地替代利库利库扩展编码
|
|
|
+ Cell cell36 = crateCell(workbook,row,36,color); //本地替代利库利库扩展描述
|
|
|
+ Cell cell37 = crateCell(workbook,row,37,color); //本地替代利库利库批次号
|
|
|
+ Cell cell38 = crateCell(workbook,row,38,color); //本地替代利库利库库存地
|
|
|
+ Cell cell39 = crateCell(workbook,row,39,color); //本地替代利库利库数量
|
|
|
+ Cell cell40 = crateCell(workbook,row,40,color); //跨区替代利库利库扩展编码
|
|
|
+ Cell cell41 = crateCell(workbook,row,41,color); //跨区替代利库利库扩展描述
|
|
|
+ Cell cell42 = crateCell(workbook,row,42,color); //跨区替代利库利库批次号
|
|
|
+ Cell cell43 = crateCell(workbook,row,43,color); //跨区替代利库利库库存地
|
|
|
+ Cell cell44 = crateCell(workbook,row,44,color); //跨区替代利库利库数量
|
|
|
|
|
|
|
|
|
- cell0.setCellValue(getString(report.getReportingArea()));
|
|
|
- cell1.setCellValue(getString(report.getNameOfReserve()));
|
|
|
- cell2.setCellValue(getString(report.getMaterialCode()));
|
|
|
- cell3.setCellValue(getString(report.getMaterialName()));
|
|
|
- cell4.setCellValue(getString(report.getExtendedCoding()));
|
|
|
- cell5.setCellValue(getString(report.getExtendedDescription()));
|
|
|
- cell6.setCellValue(getString(report.getUnit()));
|
|
|
- cell7.setCellValue(getDouble(report.getTotal()));
|
|
|
- cell8.setCellValue(getString(report.getUnitWeight()));
|
|
|
- cell9.setCellValue(getString(report.getTotalWeight()));
|
|
|
- cell10.setCellValue(getString(report.getSupplied()));
|
|
|
+ cell0.setCellValue(getString(report.getReportingArea()));//上报地区
|
|
|
+ cell1.setCellValue(getString(report.getNameOfReserve()));//储备项目名称
|
|
|
+ cell2.setCellValue(getString(report.getMaterialCode()));//物料编码
|
|
|
+ cell3.setCellValue(getString(report.getMaterialName()));//物料名称
|
|
|
+ cell4.setCellValue(getString(report.getExtendedCoding()));//扩展编码
|
|
|
+ cell5.setCellValue(getString(report.getExtendedDescription()));//扩展描述
|
|
|
+ cell6.setCellValue(getString(report.getUnit()));//单位
|
|
|
+ cell7.setCellValue(getDouble(report.getTotal()));//总量
|
|
|
+ cell8.setCellValue(getString(report.getUnitWeight()));//单重
|
|
|
+ cell9.setCellValue(getString(report.getTotalWeight()));//总重
|
|
|
+ cell10.setCellValue(getString(report.getSupplied()));//甲乙供
|
|
|
cell11.setCellValue(getString(report.getReportPerson()));//提报人
|
|
|
cell12.setCellValue(getString(report.getReportDepartment()));//提报部门
|
|
|
cell13.setCellValue(getString(report.getRemark()));//备注
|
|
|
- cell14.setCellValue(getDouble(report.getNumberOfNiches()));
|
|
|
- cell15.setCellValue(getString(report.getLiKuAmount()));//利库金额
|
|
|
- cell16.setCellValue(getDouble(report.getNumberOfApplications()));
|
|
|
- cell17.setCellValue(getString(report.getLocalWareBatch()));
|
|
|
- cell18.setCellValue(getString(report.getLocalWareHouse()));
|
|
|
- cell19.setCellValue(getString(report.getNumberOfLocal()));
|
|
|
- cell20.setCellValue(getString(report.getRegionalBatch()));
|
|
|
- cell21.setCellValue(getString(report.getRegionalHouse()));
|
|
|
- cell22.setCellValue(getString(report.getNumberOfRegional()));
|
|
|
- cell23.setCellValue(getString(report.getLocalReplacementExtendedCoding()));
|
|
|
- cell24.setCellValue(getString(report.getLocalReplacementExtendedDescription()));
|
|
|
- cell25.setCellValue(getString(report.getLocalReplacementBatch()));
|
|
|
- cell26.setCellValue(getString(report.getLocalReplacementHouse()));
|
|
|
- cell27.setCellValue(getString(report.getLocalReplacementNumber()));
|
|
|
- cell28.setCellValue(getString(report.getRegionalReplacementExtendedCoding()));
|
|
|
- cell29.setCellValue(getString(report.getRegionalReplacementExtendedDescription()));
|
|
|
- cell30.setCellValue(getString(report.getRegionalReplacementBatch()));
|
|
|
- cell31.setCellValue(getString(report.getRegionalReplacementHouse()));
|
|
|
- cell32.setCellValue(getString(report.getRegionalReplacementNumber()));
|
|
|
+ //标准物料、大类、中类、小类
|
|
|
+ cell14.setCellValue(stanMater.get(report.getMaterialCode()).getPurchaseStandardId());
|
|
|
+ cell15.setCellValue(stanMater.get(report.getMaterialCode()).getBigCategoryDescript());
|
|
|
+ cell16.setCellValue(stanMater.get(report.getMaterialCode()).getMiddleCategoryDescript());
|
|
|
+ cell17.setCellValue(stanMater.get(report.getMaterialCode()).getSmallCategoryDescript());
|
|
|
+ //小类是否在清单内(区域)、优选标识
|
|
|
+ PreferredMaterials materials = preferMap.get(report.getMaterialCode());
|
|
|
+ if (materials != null){
|
|
|
+ cell18.setCellValue(preferMap.get(report.getMaterialCode()).getArea());
|
|
|
+ }
|
|
|
+ if (preferredCodes.contains(report.getMaterialCode())){
|
|
|
+ cell19.setCellValue("优选");
|
|
|
+ }else {
|
|
|
+ cell19.setCellValue("非优选");
|
|
|
+ }
|
|
|
+// cell19.setCellValue(preferMap.get(report.getMaterialCode()).getThirdClassList());
|
|
|
+ //在途说明、审核说明、意见反馈
|
|
|
+ cell20.setCellValue(test.get(report.getMaterialCode()));
|
|
|
+ MaterialQuota quota = quotaMap.get(report.getMaterialCode());
|
|
|
+ if(quota!=null){
|
|
|
+ Double quotaNum = quota.getQuota();
|
|
|
+ if(quotaNum!=null){
|
|
|
+ if(report.getTotal()!=null&& report.getTotal()>quotaNum){
|
|
|
+ cell21.setCellValue("超限额");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ cell22.setCellValue("");
|
|
|
+
|
|
|
+ //库存批次 由本地利库批次号、跨区利库批次号、本地替代利库利库批次号、跨区替代利库利库批次号拼接组成
|
|
|
+ String pc = changeVal02(report.getLocalWareBatch())
|
|
|
+ + changeVal02(report.getRegionalBatch())
|
|
|
+ + changeVal02(report.getLocalReplacementBatch())
|
|
|
+ + changeVal02(report.getRegionalReplacementBatch());
|
|
|
+ cell24.setCellValue(pc);
|
|
|
+ //库存计划编制人
|
|
|
+ LiKuResourcePool liKuResourcePool = likuMap.get(pc);
|
|
|
+ if (liKuResourcePool != null){
|
|
|
+ cell23.setCellValue(liKuResourcePool.getPlanner());
|
|
|
+ }
|
|
|
+ //库存数量
|
|
|
+ if (liKuResourcePool != null){
|
|
|
+ cell25.setCellValue(liKuResourcePool.getInventoryAmount());
|
|
|
+ }
|
|
|
+ //库存地点 由本地利库库存地、跨区利库库存地、本地替代利库利库库存地、跨区替代利库利库库存地根据规则拼接
|
|
|
+ String area = changeVal(report.getLocalWareHouse()) + "-" + changeVal(report.getRegionalHouse()) + "-" +
|
|
|
+ changeVal(report.getLocalReplacementHouse()) + "-" + changeVal(report.getRegionalReplacementHouse());
|
|
|
+ cell26.setCellValue(area);
|
|
|
+
|
|
|
+ cell27.setCellValue(getDouble(report.getNumberOfNiches()));//利库数量
|
|
|
+ cell28.setCellValue(getDouble(report.getNumberOfApplications()));//申报数量
|
|
|
+ cell29.setCellValue(getString(report.getLocalWareBatch()));
|
|
|
+ cell30.setCellValue(getString(report.getLocalWareHouse()));
|
|
|
+ cell31.setCellValue(getString(report.getNumberOfLocal()));
|
|
|
+ cell32.setCellValue(getString(report.getRegionalBatch()));
|
|
|
+ cell33.setCellValue(getString(report.getRegionalHouse()));
|
|
|
+ cell34.setCellValue(getString(report.getNumberOfRegional()));
|
|
|
+ cell35.setCellValue(getString(report.getLocalReplacementExtendedCoding()));
|
|
|
+ cell36.setCellValue(getString(report.getLocalReplacementExtendedDescription()));
|
|
|
+ cell37.setCellValue(getString(report.getLocalReplacementBatch()));
|
|
|
+ cell38.setCellValue(getString(report.getLocalReplacementHouse()));
|
|
|
+ cell39.setCellValue(getString(report.getLocalReplacementNumber()));
|
|
|
+ cell40.setCellValue(getString(report.getRegionalReplacementExtendedCoding()));
|
|
|
+ cell41.setCellValue(getString(report.getRegionalReplacementExtendedDescription()));
|
|
|
+ cell42.setCellValue(getString(report.getRegionalReplacementBatch()));
|
|
|
+ cell43.setCellValue(getString(report.getRegionalReplacementHouse()));
|
|
|
+ cell44.setCellValue(getString(report.getRegionalReplacementNumber()));
|
|
|
}
|
|
|
}
|
|
|
- /*if(likuList!=null&&likuList.size()>0){
|
|
|
- for(int i=0;i<likuList.size();i++){
|
|
|
- LikuDetail liku = likuList.get(i);
|
|
|
- int color = 0;
|
|
|
- Row row = sheet2.createRow(rowNum+i);
|
|
|
- Cell cell0 = crateCell(workbook,row,0,color); //上报地区
|
|
|
- Cell cell1 = crateCell(workbook,row,1,color); //储备项目名称
|
|
|
- Cell cell2 = crateCell(workbook,row,2,color); //物料编码
|
|
|
- Cell cell3 = crateCell(workbook,row,3,color); //物料名称
|
|
|
- Cell cell4 = crateCell(workbook,row,4,color); //扩展编码
|
|
|
- Cell cell5 = crateCell(workbook,row,5,color); //扩展描述
|
|
|
- Cell cell6 = crateCell(workbook,row,6,color); //单位
|
|
|
- Cell cell7 = crateCell(workbook,row,7,color); //总量
|
|
|
- Cell cell8 = crateCell(workbook,row,8,color); //单重
|
|
|
- Cell cell9 = crateCell(workbook,row,9,color); //总重
|
|
|
- Cell cell10 = crateCell(workbook,row,10,color); //甲乙供
|
|
|
- Cell cell11 = crateCell(workbook,row,11,color); //利库数量
|
|
|
- Cell cell12 = crateCell(workbook,row,12,color); //申请数量
|
|
|
- Cell cell13 = crateCell(workbook,row,13,color); //利库类型
|
|
|
- Cell cell14 = crateCell(workbook,row,14,color); //利库批次号
|
|
|
- Cell cell15 = crateCell(workbook,row,15,color); //利库库存地
|
|
|
- Cell cell16 = crateCell(workbook,row,16,color); //利库明细数量
|
|
|
-
|
|
|
-
|
|
|
- cell0.setCellValue(getString(liku.getReportingArea()));
|
|
|
- cell1.setCellValue(getString(liku.getNameOfReserve()));
|
|
|
- cell2.setCellValue(getString(liku.getMaterialCode()));
|
|
|
- cell3.setCellValue(getString(liku.getMaterialName()));
|
|
|
- cell4.setCellValue(getString(liku.getExtendedCoding()));
|
|
|
- cell5.setCellValue(getString(liku.getExtendedDescription()));
|
|
|
- cell6.setCellValue(getString(liku.getUnit()));
|
|
|
- cell7.setCellValue(getDouble(liku.getTotal()));
|
|
|
- cell8.setCellValue(getString(liku.getUnitWeight()));
|
|
|
- cell9.setCellValue(getString(liku.getTotalWeight()));
|
|
|
- cell10.setCellValue(getString(liku.getSupplied()));
|
|
|
- //当利库数量=利库明细数量 表明这条记录只有一个利库明细数据
|
|
|
- if(liku.getNumberOfNiches().equals(liku.getNumberNiches())){
|
|
|
- cell11.setCellValue(getDouble(liku.getNumberOfNiches()));
|
|
|
- cell12.setCellValue(getDouble(liku.getNumberOfApplications()));
|
|
|
+ //创建一个新的sheet
|
|
|
+ /*//表头
|
|
|
+ String []title = {"上报地区","储备项目名称","物料编码","物料名称","扩展编码","扩展描述","单位","总量",
|
|
|
+ "单重/kg","总重/吨","甲乙供","提报人","提报部门","备注","采购标准标识","三级清单物料",
|
|
|
+ "物资数量校验","在途物资统计校验"};
|
|
|
+ //获取数据
|
|
|
+ //采购标准标识
|
|
|
+ Map<String,StandardMaterials> standardMap = new HashMap<>();
|
|
|
+ for(StandardMaterials standard:standardList){
|
|
|
+ standardMap.put(standard.getMaterialCode(),standard);
|
|
|
+ }
|
|
|
+ //三级清单物料
|
|
|
+ Map<String,MaterialQuota> quotaMap = new HashMap<>();
|
|
|
+ for(MaterialQuota quota:quotaList){
|
|
|
+ quotaMap.put(quota.getMaterialCode(),quota);
|
|
|
+ }
|
|
|
+ //在途物资统计校验
|
|
|
+ //在途物资统计表 key=统计物料编码-部门 去重汇总统计
|
|
|
+ Map<String, BigDecimal> onPassageMaterialsMap = new HashMap<>();
|
|
|
+ //项目物资需求表 key=统计物料编码-部门 去重汇总统计
|
|
|
+ Map<String, BigDecimal> materialInformationMap = new HashMap<>();
|
|
|
+ //在途物资统计表与项目物资需求表比较 在途物资统计表J列>=项目物资需求表H列 标识
|
|
|
+ List<String> flagList = new ArrayList<>();
|
|
|
+ //在途物资统计表 去重汇总统计
|
|
|
+ goodsList.forEach(opm -> {
|
|
|
+ if (com.jeeplus.common.utils.StringUtils.isBlank(opm.getContractCount())) {
|
|
|
+ opm.setContractCount("0");
|
|
|
+ }
|
|
|
+ //根据提报人 找到对应部门
|
|
|
+ String reportPersonOfDepartment = reportPersonMap.get(opm.getPlanner());
|
|
|
+ //如果没有部门 表示空部门 物料编码-部门
|
|
|
+ String key = "";
|
|
|
+ if (reportPersonOfDepartment == null) {
|
|
|
+ key = opm.getMaterialCode() + "-";
|
|
|
+ } else {
|
|
|
+ key = opm.getMaterialCode() + "-" + reportPersonOfDepartment;
|
|
|
+ }
|
|
|
+ if (onPassageMaterialsMap.containsKey(key)) {
|
|
|
+ onPassageMaterialsMap.put(key, new BigDecimal(opm.getContractCount()).add(onPassageMaterialsMap.get(key)));
|
|
|
+ } else {
|
|
|
+ if (com.jeeplus.common.utils.StringUtils.isNotBlank(opm.getMaterialCode())) {
|
|
|
+ onPassageMaterialsMap.put(key, new BigDecimal(opm.getContractCount()));
|
|
|
}
|
|
|
- cell13.setCellValue(getString(liku.getComparisonType()));
|
|
|
- cell14.setCellValue(getString(liku.getBatch()));
|
|
|
- cell15.setCellValue(getString(liku.getWarehouse()));
|
|
|
- //段长类要加第几段
|
|
|
- if(liku.getSegBelongs() == null){
|
|
|
- cell16.setCellValue(getDouble(liku.getNumberNiches()));
|
|
|
- }else{
|
|
|
- cell16.setCellValue(liku.getNumberNiches()+" 第"+liku.getSegBelongs()+"段");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ //项目物资需求表 去重汇总统计
|
|
|
+ reportList.forEach(m -> {
|
|
|
+ if (com.jeeplus.common.utils.StringUtils.isBlank(m.getTotal().toString())) {
|
|
|
+ m.setTotal(0.0);
|
|
|
+ }
|
|
|
+ //物料编码-部门
|
|
|
+ if (m.getReportDepartment() == null){
|
|
|
+ m.setReportDepartment("");
|
|
|
+ }
|
|
|
+ String key = m.getMaterialCode() + "-" + m.getReportDepartment();
|
|
|
+ if (materialInformationMap.containsKey(key)) {
|
|
|
+ materialInformationMap.put(key, new BigDecimal(m.getTotal()).add(materialInformationMap.get(key)));
|
|
|
+ } else {
|
|
|
+ if (com.jeeplus.common.utils.StringUtils.isNotBlank(m.getMaterialCode())) {
|
|
|
+ materialInformationMap.put(key, new BigDecimal(m.getTotal()));
|
|
|
}
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
+ //两表比较 添加标识
|
|
|
+ materialInformationMap.forEach((k, v) -> {
|
|
|
+ if (onPassageMaterialsMap.containsKey(k)) {
|
|
|
+ if (onPassageMaterialsMap.get(k).compareTo(v) >= 0) {
|
|
|
+ flagList.add(k);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ Map<String,String> test = new HashMap<>();
|
|
|
+ //根据标识在原表中追加备注
|
|
|
+ reportList.forEach(l -> {
|
|
|
+ String key = l.getMaterialCode() + "-" + l.getReportDepartment();
|
|
|
+ if (flagList.contains(key)) {
|
|
|
+ l.setRemarkText("在途已有" + onPassageMaterialsMap.get(key) + "单位,请核实本次需求");
|
|
|
+ test.put(l.getMaterialCode(),l.getRemarkText());
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ //赋值操作
|
|
|
+ String [][] content = new String[reportList.size()][18];
|
|
|
+ for (int i=0;i<reportList.size();i++){
|
|
|
+ content[i] = new String[title.length];
|
|
|
+ MaterialReportDetails mater = reportList.get(i);
|
|
|
+ content[i][0] = mater.getReportingArea();
|
|
|
+ content[i][1] = mater.getNameOfReserve();
|
|
|
+ content[i][2] = mater.getMaterialCode();
|
|
|
+ content[i][3] = mater.getMaterialName();
|
|
|
+ content[i][4] = mater.getExtendedCoding();
|
|
|
+ content[i][5] = mater.getExtendedDescription();
|
|
|
+ content[i][6] = mater.getUnit();
|
|
|
+ content[i][7] = mater.getTotal().toString();
|
|
|
+ content[i][8] = mater.getUnitWeight();
|
|
|
+ content[i][9] = mater.getTotalWeight();
|
|
|
+ content[i][10] = mater.getSupplied();
|
|
|
+ content[i][11] = mater.getReportPerson();
|
|
|
+ content[i][12] = mater.getReportDepartment();
|
|
|
+ content[i][13] = mater.getRemark();
|
|
|
+ content[i][14] = standardMap.get(mater.getMaterialCode()).getPurchaseStandardId();//采购标准标识
|
|
|
+ if (preferredCodes.contains(mater.getMaterialCode())){
|
|
|
+ content[i][15] = "优选";//三级清单物料
|
|
|
+ }else {
|
|
|
+ content[i][15] = "非优选";//三级清单物料
|
|
|
+ }
|
|
|
+ MaterialQuota quota = quotaMap.get(mater.getMaterialCode());
|
|
|
+ if(quota!=null){
|
|
|
+ Double quotaNum = quota.getQuota();
|
|
|
+ if(quotaNum!=null){
|
|
|
+ if(mater.getTotal()!=null&& mater.getTotal()>quotaNum){
|
|
|
+ content[i][16] = "超限额";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (test.get(mater.getMaterialCode()) != null){
|
|
|
+ content[i][17] = test.get(mater.getMaterialCode());
|
|
|
}
|
|
|
- }*/
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ CreateSheetUtil util = new CreateSheetUtil();
|
|
|
+ util.createSheet("export",title,content,workbook,reportList,standardList,preferredCodes,quotaList,goodsList,reportPersonMap);
|
|
|
+*/
|
|
|
|
|
|
String fileName = "物资上报利库情况表" + DateUtils.getDate("yyyyMMddHHmmss") + ".xlsx";
|
|
|
String str = URLEncoder.encode(fileName, "UTF8");
|
|
@@ -320,4 +556,34 @@ public class ExportUtil {
|
|
|
return returnStr;
|
|
|
}
|
|
|
|
|
|
+ public static String changeVal(String val){
|
|
|
+ if (val != null){
|
|
|
+ switch (val){
|
|
|
+ case "HLA2":
|
|
|
+ val="镇江";
|
|
|
+ break;
|
|
|
+ case "HLB1":
|
|
|
+ val="丹阳";
|
|
|
+ break;
|
|
|
+ case "HLC1":
|
|
|
+ val="句容";
|
|
|
+ break;
|
|
|
+ case "HLD1":
|
|
|
+ val="扬中";
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return val;
|
|
|
+ }else {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String changeVal02(String val){
|
|
|
+ if (val==null){
|
|
|
+ val="";
|
|
|
+ }
|
|
|
+ return val;
|
|
|
+ }
|
|
|
}
|