chenyuesheng 3 роки тому
батько
коміт
0d9d24adaf

+ 9 - 7
src/main/java/com/jeeplus/modules/sg/balancedlibrary/liKuResourcePool/utils/OptimalUtil.java

@@ -27,8 +27,8 @@ public class OptimalUtil {
      */
     public List<MaterialReportDetails> getOptimal(double total, List<MaterialReportDetails> elements){
         //list降序排列
-        Collections.sort(elements, Comparator.comparing(MaterialReportDetails::getLengthOfMetre));
-        Collections.reverse(elements);
+        //Collections.sort(elements, Comparator.comparing(MaterialReportDetails::getLengthOfMetre));
+        //Collections.reverse(elements);
         solve(0,0,new ArrayList<>(),total,elements);
 
         //找到差值最小组合返回
@@ -37,7 +37,7 @@ public class OptimalUtil {
         for (List<MaterialReportDetails> detailsList :result) {
             BigDecimal listSum = BigDecimal.valueOf(0.0);
             for (MaterialReportDetails details :detailsList) {
-                listSum = listSum.add(BigDecimal.valueOf(details.getLengthOfMetre()));
+                listSum = listSum.add(BigDecimal.valueOf(details.getTotal()));
             }
             if (listSum.compareTo(currMax) > 0) {
                 currMax = listSum;
@@ -59,7 +59,7 @@ public class OptimalUtil {
      */
     public List<LiKuResourcePool> getOptimalReverse(double total, List<LiKuResourcePool> elements){
         //list降序排列
-        Collections.sort(elements, Comparator.comparing(LiKuResourcePool::getLengthOfMetre));
+        //Collections.sort(elements, Comparator.comparing(LiKuResourcePool::getLengthOfMetre));
         solveReverse(0,0,new ArrayList<>(),total,elements);
 
         //找到差值最小组合返回
@@ -68,7 +68,7 @@ public class OptimalUtil {
         for (List<LiKuResourcePool> poolList : resultReverse) {
             BigDecimal listSum = BigDecimal.valueOf(0.0);
             for (LiKuResourcePool pool : poolList) {
-                listSum = listSum.add(new BigDecimal(pool.getLengthOfMetre()));
+                listSum = listSum.add(new BigDecimal(pool.getLengthOfCable()));
             }
             if (listSum.compareTo(currMin) < 0) {
                 currMin = listSum;
@@ -107,7 +107,8 @@ public class OptimalUtil {
         }
         MaterialReportDetails next = elements.get(index);
         //处理单位不同,所有都以米作为单位计算
-        Double nextNeed = next.getLengthOfMetre();
+        //Double nextNeed = next.getLengthOfMetre();
+        Double nextNeed = next.getTotal();
 
         index++;
         //如果将当前值加上已有元素组合的值等于待比对值,得到结果
@@ -146,7 +147,8 @@ public class OptimalUtil {
         }
         LiKuResourcePool next = elements.get(index);
         //处理单位不同,所有都以米作为单位计算
-        Double cableLength = Double.valueOf(next.getLengthOfMetre());
+        //Double cableLength = Double.valueOf(next.getLengthOfMetre());
+        Double cableLength = Double.valueOf(next.getRemaining());
 
         index++;
         //如果将当前值加上已有元素组合的值等于待比对值,得到结果

+ 6 - 5
src/main/java/com/jeeplus/modules/sg/balancedlibrary/liKuResourcePool/web/LiKuResourcePoolController.java

@@ -191,7 +191,7 @@ public class LiKuResourcePoolController extends BaseController {
 					Integer isSectionLength = pool.getIsSectionLength();
 					if (isSectionLength.compareTo(LiKuUtils.YES) == 0) {
 						String lengthOfCable = pool.getLengthOfCable();
-						/*if (null != lengthOfCable && !"".equals(lengthOfCable)) {
+						if (null != lengthOfCable && !"".equals(lengthOfCable)) {
 							String[] split = lengthOfCable.split(";");
 							for (int i = 0; i < split.length; i++) {
 								LiKuResourcePool liKu = new LiKuResourcePool();
@@ -202,7 +202,7 @@ public class LiKuResourcePoolController extends BaseController {
 								liKu.setMaterialCode(pool.getMaterialCode());
 								liKu.setMaterialDescription(pool.getMaterialDescription());
 								liKu.setUnitOfMeasurement(pool.getUnitOfMeasurement());
-								liKu.setInventoryAmount(pool.getInventoryAmount());
+								liKu.setInventoryAmount(split[i]);
 								liKu.setInventoryLocation(pool.getInventoryLocation());
 								liKu.setInvLocation(pool.getInvLocation());
 								liKu.setInvLocationDes(pool.getInvLocationDes());
@@ -224,11 +224,12 @@ public class LiKuResourcePoolController extends BaseController {
 								liKu.setSegBelongs(i + 1);
 								insertList.add(liKu);
 							}
-						} else {*/
-							/*pool.setSegBelongs(1);*/
+						} else {
+							pool.setSegBelongs(1);
 							pool.setRemaining(pool.getInventoryAmount());
+							pool.setLengthOfCable(pool.getInventoryAmount());
 							insertList.add(pool);
-						/*}*/
+						}
 					}else {
 						insertList.add(pool);
 					}

+ 226 - 68
src/main/java/com/jeeplus/modules/sg/balancedlibrary/materialReportDetails/service/MaterialReportDetailsService.java

@@ -13,6 +13,7 @@ import com.jeeplus.core.persistence.Page;
 import com.jeeplus.core.service.CrudService;
 import com.jeeplus.modules.sg.balancedlibrary.liKuResourcePool.entity.LiKuResourcePool;
 import com.jeeplus.modules.sg.balancedlibrary.liKuResourcePool.mapper.LiKuResourcePoolMapper;
+import com.jeeplus.modules.sg.balancedlibrary.liKuResourcePool.utils.OptimalUtil;
 import com.jeeplus.modules.sg.balancedlibrary.materialReportDetails.constant.AreaCodeFlagEnum;
 import com.jeeplus.modules.sg.balancedlibrary.materialReportDetails.constant.AreaTypeFlagEnum;
 import com.jeeplus.modules.sg.balancedlibrary.materialReportDetails.constant.MaterialsUnitFlagEnum;
@@ -27,6 +28,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
@@ -99,7 +101,6 @@ public class MaterialReportDetailsService extends CrudService<MaterialReportDeta
         List<LiKuResourcePool> liKuPoolList = liKuResourcePoolMapper.findLiKuList(null, null);
         //如果利库资源池为空时 则直接返回结果提示
         if (liKuPoolList == null || liKuPoolList.size() == 0) {
-            j.setSuccess(false);
             j.setMsg("请先导入利库资源池!");
             return j;
         }
@@ -128,7 +129,7 @@ public class MaterialReportDetailsService extends CrudService<MaterialReportDeta
 
             //添加标识 分组 段长数据 非段长数据 单位转换
             if (liKuResourcePool.getUnitOfMeasurement().equals(MaterialsUnitFlagEnum.M.getUnit()) || liKuResourcePool.getUnitOfMeasurement().equals(MaterialsUnitFlagEnum.KM.getUnit())) {
-                if (StringUtils.isNotBlank(liKuResourcePool.getLengthOfCable())) {
+                /*if (StringUtils.isNotBlank(liKuResourcePool.getLengthOfCable())) {
                     String[] split = liKuResourcePool.getLengthOfCable().split(";");
                     for (int i = 0; i < split.length; i++) {
                         //拆分成新的对象添加集合中 拆分段长为剩余
@@ -147,16 +148,15 @@ public class MaterialReportDetailsService extends CrudService<MaterialReportDeta
                         }
 
                         liKuIsSegmentPoolList.add(ResourcePool);
-                    }
-                } else {
-                    if (liKuResourcePool.getUnitOfMeasurement().equals(MaterialsUnitFlagEnum.KM.getUnit())) {
-                        liKuResourcePool.setUnitOfMeasurement(MaterialsUnitFlagEnum.M.getUnit());
-                        liKuResourcePool.setInventoryAmount(new BigDecimal(liKuResourcePool.getInventoryAmount()).multiply(new BigDecimal(1000)).toString());
-                        liKuResourcePool.setLengthOfCable(liKuResourcePool.getInventoryAmount());
-                        liKuResourcePool.setRemaining(liKuResourcePool.getInventoryAmount());
-                    }
-                    liKuIsSegmentPoolList.add(liKuResourcePool);
+
+                } else {}*/
+                if (liKuResourcePool.getUnitOfMeasurement().equals(MaterialsUnitFlagEnum.KM.getUnit())) {
+                    liKuResourcePool.setInventoryAmount(new BigDecimal(liKuResourcePool.getInventoryAmount()).multiply(new BigDecimal(1000)).toString());
+                    liKuResourcePool.setLengthOfCable(liKuResourcePool.getInventoryAmount());
+                    liKuResourcePool.setRemaining(liKuResourcePool.getInventoryAmount());
                 }
+                liKuIsSegmentPoolList.add(liKuResourcePool);
+                /*}*/
             } else {
                 liKuIsNotSegmentPoolList.add(liKuResourcePool);
             }
@@ -184,36 +184,41 @@ public class MaterialReportDetailsService extends CrudService<MaterialReportDeta
             l.setNumberOfNiches(0.0);
             //初始化申请数量
             l.setNumberOfApplications(l.getTotal());
-            if(l.getReportingArea().equals(AreaCodeFlagEnum.HLA2.getArea())){
+            if (l.getReportingArea().equals(AreaCodeFlagEnum.HLA2.getArea())) {
                 l.setAreaCodeFlagEnum(AreaCodeFlagEnum.HLA2);
-            }else if(l.getReportingArea().equals(AreaCodeFlagEnum.HLD1.getArea())){
+            } else if (l.getReportingArea().equals(AreaCodeFlagEnum.HLD1.getArea())) {
                 l.setAreaCodeFlagEnum(AreaCodeFlagEnum.HLD1);
-            }else if(l.getReportingArea().equals(AreaCodeFlagEnum.HLB1.getArea())){
+            } else if (l.getReportingArea().equals(AreaCodeFlagEnum.HLB1.getArea())) {
                 l.setAreaCodeFlagEnum(AreaCodeFlagEnum.HLB1);
-            }else if(l.getReportingArea().equals(AreaCodeFlagEnum.HLC1.getArea())){
+            } else if (l.getReportingArea().equals(AreaCodeFlagEnum.HLC1.getArea())) {
                 l.setAreaCodeFlagEnum(AreaCodeFlagEnum.HLC1);
-            }else{
+            } else {
                 l.setAreaCodeFlagEnum(AreaCodeFlagEnum.NO_PLACE);
             }
 
             //单位转换为米
             if (l.getUnit().equals(MaterialsUnitFlagEnum.KM.getUnit())) {
                 l.setTotal((BigDecimal.valueOf(l.getTotal()).multiply(new BigDecimal(1000))).doubleValue());
-                l.setUnit(MaterialsUnitFlagEnum.M.getUnit());
                 l.setNumberOfApplications(l.getTotal());
             }
-            if (l.getUnit().equals(MaterialsUnitFlagEnum.M.getUnit())) {
+            if (l.getUnit().equals(MaterialsUnitFlagEnum.M.getUnit()) || l.getUnit().equals(MaterialsUnitFlagEnum.KM.getUnit())) {
                 materialIsSegmentList.add(l);
             } else {
                 materialIsNotSegmentList.add(l);
             }
         });
+        //排序
+        List<MaterialReportDetails> materialIsSegmentSortList = getSortMaterialReport(materialIsSegmentList);
+        List<MaterialReportDetails> materialIsNotSegmentSortList = getSortMaterialReport(materialIsNotSegmentList);
 
+        /*materialIsNotSegmentSortList.forEach(m->{
+            System.out.println(m.getAreaCodeFlagEnum().getArea() + "-----" + m.getTotal() +"-------"+ m.getExtendedCoding());
+        });*/
 
         /********************************************物资利库比较***************************************************/
 
         //非段长物资比较 本地库 物资匹配利库
-        materialIsNotSegmentList.forEach(l -> {
+        materialIsNotSegmentSortList.forEach(l -> {
             //优先匹配最佳
             /*liKuIsNotSegmentPoolSortList.stream().filter(liKu -> liKu.getLiKuFlag().getArea().equals(l.getReportingArea())
                     && Double.valueOf(liKu.getRemaining()).compareTo(l.getTotal()) >= 0
@@ -231,7 +236,7 @@ public class MaterialReportDetailsService extends CrudService<MaterialReportDeta
             }
         });
         //非段长物资比较 跨区库
-        materialIsNotSegmentList.forEach(l -> {
+        materialIsNotSegmentSortList.forEach(l -> {
             //需求数量与利库数量不同 去其他地区找
             /*if (l.getTotal().compareTo(l.getNumberOfNiches()) != 0) {
                 //优先匹配最佳
@@ -252,7 +257,7 @@ public class MaterialReportDetailsService extends CrudService<MaterialReportDeta
             }
         });
         //非段长物资替代 本地库
-        materialIsNotSegmentList.forEach(l -> {
+        materialIsNotSegmentSortList.forEach(l -> {
             //如果本地库 区域库依旧没找到 则启用代替
             /*if (l.getTotal().compareTo(l.getNumberOfNiches()) != 0) {
                 //过滤出 本地库物料编码相同 最优选择
@@ -265,13 +270,13 @@ public class MaterialReportDetailsService extends CrudService<MaterialReportDeta
             if (l.getTotal().compareTo(l.getNumberOfNiches()) != 0) {
                 liKuIsNotSegmentPoolSortList.stream().filter(liKu -> liKu.getLiKuFlag().getArea().equals(l.getReportingArea())
                         && l.getMaterialCode().equals(liKu.getMaterialCode())
-                        && !l.getExtendedCoding() .equals(liKu.getExtendedCoding()) ).forEach(liKuResourcePool -> {
+                        && !l.getExtendedCoding().equals(liKu.getExtendedCoding())).forEach(liKuResourcePool -> {
                     liKuCompareMaterial(l, liKuResourcePool, AreaTypeFlagEnum.LOCAL, AreaTypeFlagEnum.LOCAL_REPLACEMENT, MaterialsUnitFlagEnum.IS_SEGMENT);
                 });
             }
         });
         //非段长物资代替 库区库
-        materialIsNotSegmentList.forEach(l -> {
+        materialIsNotSegmentSortList.forEach(l -> {
             //如果本地库 区域库依旧没找到 则启用代替
             /*if (l.getTotal().compareTo(l.getNumberOfNiches()) != 0) {
                 //过滤出 本地库物料编码相同 最优选择
@@ -284,27 +289,41 @@ public class MaterialReportDetailsService extends CrudService<MaterialReportDeta
             if (l.getTotal().compareTo(l.getNumberOfNiches()) != 0) {
                 liKuIsNotSegmentPoolSortList.stream().filter(liKu -> !liKu.getLiKuFlag().getArea().equals(l.getReportingArea())
                         && l.getMaterialCode().equals(liKu.getMaterialCode())
-                        && !l.getExtendedCoding() .equals(liKu.getExtendedCoding())).forEach(liKuResourcePool -> {
+                        && !l.getExtendedCoding().equals(liKu.getExtendedCoding())).forEach(liKuResourcePool -> {
                     liKuCompareMaterial(l, liKuResourcePool, AreaTypeFlagEnum.SPAN, AreaTypeFlagEnum.SPAN_REPLACEMENT, MaterialsUnitFlagEnum.IS_SEGMENT);
                 });
             }
         });
 
-
-        //段长物资比较 本地库 利库匹配物资
+        /***********************************************本地库 段长匹配**********************************************************/
+        //段长物资 本地库比较 最优 上报物资匹配利库池
+        materialIsSegmentSortList.forEach(m -> {
+            //过滤 本地库 物料编码 扩展编码
+            List<LiKuResourcePool> collect = liKuIsSegmentPoolSortList.stream().filter(liKu ->
+                    liKu.getLiKuFlag().getArea().equals(m.getReportingArea())
+                            && m.getMaterialCode().equals(liKu.getMaterialCode())
+                            && m.getExtendedCoding().equals(liKu.getExtendedCoding())
+            ).collect(Collectors.toList());
+            OptimalUtil optimalUtil = new OptimalUtil();
+            //返回最优解
+            optimalUtil.getOptimalReverse(m.getTotal(), collect).forEach(l -> {
+                liKuCompareMaterial(m, l, AreaTypeFlagEnum.LOCAL, null, MaterialsUnitFlagEnum.IS_NOT_SEGMENT);
+            });
+        });
+        //段长物资 本地库比较 最优 利库池匹配上报物资
         liKuIsSegmentPoolSortList.forEach(l -> {
-            //最优选择 过滤本地库  物料编码  扩展编码 段长大于上报物资
-            materialIsSegmentList.stream().filter(material -> material.getReportingArea().equals(l.getLiKuFlag().getArea())
+            List<MaterialReportDetails> collect = materialIsSegmentSortList.stream().filter(material -> material.getReportingArea().equals(l.getLiKuFlag().getArea())
                     && material.getMaterialCode().equals(l.getMaterialCode())
-                    && material.getExtendedCoding().equals(l.getExtendedCoding())
-                    && new BigDecimal(l.getLengthOfCable()).compareTo(BigDecimal.valueOf(material.getTotal())) == 0).forEach(materialReportDetails -> {
-                        if (new BigDecimal(l.getRemaining()).compareTo(BigDecimal.ZERO) > 0) {
-                            liKuCompareMaterial(materialReportDetails, l, AreaTypeFlagEnum.LOCAL, null, MaterialsUnitFlagEnum.IS_NOT_SEGMENT);
-                        }
-                    }
-            );
+                    && material.getExtendedCoding().equals(l.getExtendedCoding())).collect(Collectors.toList());
+            OptimalUtil optimalUtil = new OptimalUtil();
+            optimalUtil.getOptimal(Double.parseDouble(l.getLengthOfCable()), collect).forEach(m -> {
+                liKuCompareMaterial(m, l, AreaTypeFlagEnum.LOCAL, null, MaterialsUnitFlagEnum.IS_NOT_SEGMENT);
+            });
+        });
+        //段长物资比较 本地库 利库匹配物资
+        liKuIsSegmentPoolSortList.forEach(l -> {
             if (new BigDecimal(l.getRemaining()).compareTo(BigDecimal.ZERO) > 0) {
-                materialIsSegmentList.stream().filter(material -> material.getReportingArea().equals(l.getLiKuFlag().getArea())
+                materialIsSegmentSortList.stream().filter(material -> material.getReportingArea().equals(l.getLiKuFlag().getArea())
                         && material.getMaterialCode().equals(l.getMaterialCode())
                         && material.getExtendedCoding().equals(l.getExtendedCoding())
                         && new BigDecimal(l.getLengthOfCable()).compareTo(BigDecimal.valueOf(material.getTotal())) > 0).forEach(materialReportDetails -> {
@@ -315,10 +334,131 @@ public class MaterialReportDetailsService extends CrudService<MaterialReportDeta
                 );
             }
         });
-        //段长物资比较 跨区库
+
+        /***********************************************************跨区库 段长匹配***********************************************************************/
+        //段长物资 跨区库比较 最优 上报物资匹配利库池
+        materialIsSegmentSortList.forEach(m -> {
+            //过滤 跨区库 物料编码 扩展编码
+            List<LiKuResourcePool> collect = liKuIsSegmentPoolSortList.stream().filter(liKu ->
+                    !liKu.getLiKuFlag().getArea().equals(m.getReportingArea())
+                            && m.getMaterialCode().equals(liKu.getMaterialCode())
+                            && m.getExtendedCoding().equals(liKu.getExtendedCoding())
+            ).collect(Collectors.toList());
+            OptimalUtil optimalUtil = new OptimalUtil();
+            //返回最优解
+            optimalUtil.getOptimalReverse(m.getTotal(), collect).forEach(l -> {
+                liKuCompareMaterial(m, l, AreaTypeFlagEnum.SPAN, null, MaterialsUnitFlagEnum.IS_NOT_SEGMENT);
+            });
+        });
+        //段长物资 跨区库比较 最优 利库池匹配上报物资
+        liKuIsSegmentPoolSortList.forEach(l -> {
+            List<MaterialReportDetails> collect = materialIsSegmentSortList.stream().filter(material ->
+                    !material.getReportingArea().equals(l.getLiKuFlag().getArea())
+                    && material.getMaterialCode().equals(l.getMaterialCode())
+                    && material.getExtendedCoding().equals(l.getExtendedCoding())).collect(Collectors.toList());
+            OptimalUtil optimalUtil = new OptimalUtil();
+            optimalUtil.getOptimal(Double.parseDouble(l.getLengthOfCable()), collect).forEach(m -> {
+                liKuCompareMaterial(m, l, AreaTypeFlagEnum.SPAN, null, MaterialsUnitFlagEnum.IS_NOT_SEGMENT);
+            });
+        });
+        //段长物资比较 跨区库 利库匹配物资
+        liKuIsSegmentPoolSortList.forEach(l -> {
+            if (new BigDecimal(l.getRemaining()).compareTo(BigDecimal.ZERO) > 0) {
+                materialIsSegmentSortList.stream().filter(material -> !material.getReportingArea().equals(l.getLiKuFlag().getArea())
+                        && material.getMaterialCode().equals(l.getMaterialCode())
+                        && material.getExtendedCoding().equals(l.getExtendedCoding())
+                        && new BigDecimal(l.getLengthOfCable()).compareTo(BigDecimal.valueOf(material.getTotal())) > 0).forEach(materialReportDetails -> {
+                            if (new BigDecimal(l.getRemaining()).compareTo(BigDecimal.valueOf(materialReportDetails.getTotal())) >= 0) {
+                                liKuCompareMaterial(materialReportDetails, l, AreaTypeFlagEnum.SPAN, null, MaterialsUnitFlagEnum.IS_NOT_SEGMENT);
+                            }
+                        }
+                );
+            }
+        });
+        /*************************************************************本地库-代替 段长*******************************************************************/
+        //段长物资 本地库比较 最优 上报物资匹配利库池 替代
+        materialIsSegmentSortList.forEach(m -> {
+            //过滤 本地库 物料编码 扩展编码
+            List<LiKuResourcePool> collect = liKuIsSegmentPoolSortList.stream().filter(liKu ->
+                    liKu.getLiKuFlag().getArea().equals(m.getReportingArea())
+                            && m.getMaterialCode().equals(liKu.getMaterialCode())
+                            && !m.getExtendedCoding().equals(liKu.getExtendedCoding())
+            ).collect(Collectors.toList());
+            OptimalUtil optimalUtil = new OptimalUtil();
+            //返回最优解
+            optimalUtil.getOptimalReverse(m.getTotal(), collect).forEach(l -> {
+                liKuCompareMaterial(m, l, AreaTypeFlagEnum.LOCAL,  AreaTypeFlagEnum.LOCAL_REPLACEMENT, MaterialsUnitFlagEnum.IS_NOT_SEGMENT);
+            });
+        });
+        //段长物资 本地库比较 最优 利库池匹配上报物资
+        liKuIsSegmentPoolSortList.forEach(l -> {
+            List<MaterialReportDetails> collect = materialIsSegmentSortList.stream().filter(material -> material.getReportingArea().equals(l.getLiKuFlag().getArea())
+                    && material.getMaterialCode().equals(l.getMaterialCode())
+                    && !material.getExtendedCoding().equals(l.getExtendedCoding())).collect(Collectors.toList());
+            OptimalUtil optimalUtil = new OptimalUtil();
+            optimalUtil.getOptimal(Double.parseDouble(l.getLengthOfCable()), collect).forEach(m -> {
+                liKuCompareMaterial(m, l, AreaTypeFlagEnum.LOCAL,  AreaTypeFlagEnum.LOCAL_REPLACEMENT, MaterialsUnitFlagEnum.IS_NOT_SEGMENT);
+            });
+        });
+        //段长物资比较 本地库 利库匹配物资
+        liKuIsSegmentPoolSortList.forEach(l -> {
+            if (new BigDecimal(l.getRemaining()).compareTo(BigDecimal.ZERO) > 0) {
+                materialIsSegmentSortList.stream().filter(material -> material.getReportingArea().equals(l.getLiKuFlag().getArea())
+                        && material.getMaterialCode().equals(l.getMaterialCode())
+                        && !material.getExtendedCoding().equals(l.getExtendedCoding())
+                        && new BigDecimal(l.getLengthOfCable()).compareTo(BigDecimal.valueOf(material.getTotal())) > 0).forEach(materialReportDetails -> {
+                            if (new BigDecimal(l.getRemaining()).compareTo(BigDecimal.valueOf(materialReportDetails.getTotal())) >= 0) {
+                                liKuCompareMaterial(materialReportDetails, l, AreaTypeFlagEnum.LOCAL,  AreaTypeFlagEnum.LOCAL_REPLACEMENT, MaterialsUnitFlagEnum.IS_NOT_SEGMENT);
+                            }
+                        }
+                );
+            }
+        });
+        /*****************************************************跨区库 段长 替代 ****************************************************************/
+
+        //段长物资 跨区库比较 最优 上报物资匹配利库池
+        materialIsSegmentSortList.forEach(m -> {
+            //过滤 跨区库 物料编码 扩展编码
+            List<LiKuResourcePool> collect = liKuIsSegmentPoolSortList.stream().filter(liKu ->
+                    !liKu.getLiKuFlag().getArea().equals(m.getReportingArea())
+                            && m.getMaterialCode().equals(liKu.getMaterialCode())
+                            && !m.getExtendedCoding().equals(liKu.getExtendedCoding())
+            ).collect(Collectors.toList());
+            OptimalUtil optimalUtil = new OptimalUtil();
+            //返回最优解
+            optimalUtil.getOptimalReverse(m.getTotal(), collect).forEach(l -> {
+                liKuCompareMaterial(m, l, AreaTypeFlagEnum.SPAN, AreaTypeFlagEnum.SPAN_REPLACEMENT, MaterialsUnitFlagEnum.IS_NOT_SEGMENT);
+            });
+        });
+        //段长物资 跨区库比较 最优 利库池匹配上报物资
+        liKuIsSegmentPoolSortList.forEach(l -> {
+            List<MaterialReportDetails> collect = materialIsSegmentSortList.stream().filter(material ->
+                    !material.getReportingArea().equals(l.getLiKuFlag().getArea())
+                            && material.getMaterialCode().equals(l.getMaterialCode())
+                            && !material.getExtendedCoding().equals(l.getExtendedCoding())).collect(Collectors.toList());
+            OptimalUtil optimalUtil = new OptimalUtil();
+            optimalUtil.getOptimal(Double.parseDouble(l.getLengthOfCable()), collect).forEach(m -> {
+                liKuCompareMaterial(m, l, AreaTypeFlagEnum.SPAN, AreaTypeFlagEnum.SPAN_REPLACEMENT, MaterialsUnitFlagEnum.IS_NOT_SEGMENT);
+            });
+        });
+        //段长物资比较 跨区库 利库匹配物资
         liKuIsSegmentPoolSortList.forEach(l -> {
+            if (new BigDecimal(l.getRemaining()).compareTo(BigDecimal.ZERO) > 0) {
+                materialIsSegmentSortList.stream().filter(material -> !material.getReportingArea().equals(l.getLiKuFlag().getArea())
+                        && material.getMaterialCode().equals(l.getMaterialCode())
+                        && !material.getExtendedCoding().equals(l.getExtendedCoding())
+                        && new BigDecimal(l.getLengthOfCable()).compareTo(BigDecimal.valueOf(material.getTotal())) > 0).forEach(materialReportDetails -> {
+                            if (new BigDecimal(l.getRemaining()).compareTo(BigDecimal.valueOf(materialReportDetails.getTotal())) >= 0) {
+                                liKuCompareMaterial(materialReportDetails, l, AreaTypeFlagEnum.SPAN, AreaTypeFlagEnum.SPAN_REPLACEMENT, MaterialsUnitFlagEnum.IS_NOT_SEGMENT);
+                            }
+                        }
+                );
+            }
+        });
+        //段长物资比较 跨区库
+        /*liKuIsSegmentPoolSortList.forEach(l -> {
             //最优选择 过滤本地库  物料编码  扩展编码 段长大于上报物资
-            materialIsSegmentList.stream().filter(material -> !material.getReportingArea().equals(l.getLiKuFlag().getArea())
+            materialIsSegmentSortList.stream().filter(material -> !material.getReportingArea().equals(l.getLiKuFlag().getArea())
                     && material.getMaterialCode().equals(l.getMaterialCode())
                     && material.getExtendedCoding().equals(l.getExtendedCoding())
                     && new BigDecimal(l.getLengthOfCable()).compareTo(BigDecimal.valueOf(material.getTotal())) == 0).forEach(materialReportDetails -> {
@@ -328,7 +468,7 @@ public class MaterialReportDetailsService extends CrudService<MaterialReportDeta
                     }
             );
             if (new BigDecimal(l.getRemaining()).compareTo(BigDecimal.ZERO) > 0) {
-                materialIsSegmentList.stream().filter(material -> !material.getReportingArea().equals(l.getLiKuFlag().getArea())
+                materialIsSegmentSortList.stream().filter(material -> !material.getReportingArea().equals(l.getLiKuFlag().getArea())
                         && material.getMaterialCode().equals(l.getMaterialCode())
                         && material.getExtendedCoding().equals(l.getExtendedCoding())
                         && new BigDecimal(l.getLengthOfCable()).compareTo(BigDecimal.valueOf(material.getTotal())) > 0).forEach(materialReportDetails -> {
@@ -342,7 +482,7 @@ public class MaterialReportDetailsService extends CrudService<MaterialReportDeta
         //段长物资替换 本地库
         liKuIsSegmentPoolSortList.forEach(l -> {
             //最优选择 过滤本地库  物料编码  扩展编码 段长大于上报物资
-            materialIsSegmentList.stream().filter(material -> material.getReportingArea().equals(l.getLiKuFlag().getArea())
+            materialIsSegmentSortList.stream().filter(material -> material.getReportingArea().equals(l.getLiKuFlag().getArea())
                     && material.getMaterialCode().equals(l.getMaterialCode())
                     && new BigDecimal(l.getLengthOfCable()).compareTo(BigDecimal.valueOf(material.getTotal())) == 0).forEach(materialReportDetails -> {
                         if (new BigDecimal(l.getRemaining()).compareTo(BigDecimal.ZERO) > 0) {
@@ -351,7 +491,7 @@ public class MaterialReportDetailsService extends CrudService<MaterialReportDeta
                     }
             );
             if (new BigDecimal(l.getRemaining()).compareTo(BigDecimal.ZERO) > 0) {
-                materialIsSegmentList.stream().filter(material -> material.getReportingArea().equals(l.getLiKuFlag().getArea())
+                materialIsSegmentSortList.stream().filter(material -> material.getReportingArea().equals(l.getLiKuFlag().getArea())
                         && material.getMaterialCode().equals(l.getMaterialCode())
                         && new BigDecimal(l.getLengthOfCable()).compareTo(BigDecimal.valueOf(material.getTotal())) > 0).forEach(materialReportDetails -> {
                             if (new BigDecimal(l.getRemaining()).compareTo(BigDecimal.valueOf(materialReportDetails.getTotal())) >= 0) {
@@ -364,33 +504,32 @@ public class MaterialReportDetailsService extends CrudService<MaterialReportDeta
         //段长物资替换 跨区库
         liKuIsSegmentPoolSortList.forEach(l -> {
             //最优选择 过滤本地库  物料编码  扩展编码 段长大于上报物资
-            materialIsSegmentList.stream().filter(material -> !material.getReportingArea().equals(l.getLiKuFlag().getArea())
+            materialIsSegmentSortList.stream().filter(material -> !material.getReportingArea().equals(l.getLiKuFlag().getArea())
                     && material.getMaterialCode().equals(l.getMaterialCode())
                     && new BigDecimal(l.getLengthOfCable()).compareTo(BigDecimal.valueOf(material.getTotal())) == 0
-                    && !l.getExtendedCoding() .equals(material.getExtendedCoding())).forEach(materialReportDetails -> {
+                    && !l.getExtendedCoding().equals(material.getExtendedCoding())).forEach(materialReportDetails -> {
                         if (new BigDecimal(l.getRemaining()).compareTo(BigDecimal.ZERO) > 0) {
                             liKuCompareMaterial(materialReportDetails, l, AreaTypeFlagEnum.SPAN, AreaTypeFlagEnum.SPAN_REPLACEMENT, MaterialsUnitFlagEnum.IS_NOT_SEGMENT);
                         }
                     }
             );
             if (new BigDecimal(l.getRemaining()).compareTo(BigDecimal.ZERO) > 0) {
-                materialIsSegmentList.stream().filter(material -> !material.getReportingArea().equals(l.getLiKuFlag().getArea())
+                materialIsSegmentSortList.stream().filter(material -> !material.getReportingArea().equals(l.getLiKuFlag().getArea())
                         && material.getMaterialCode().equals(l.getMaterialCode())
                         && new BigDecimal(l.getLengthOfCable()).compareTo(BigDecimal.valueOf(material.getTotal())) > 0
-                        && !l.getExtendedCoding() .equals(material.getExtendedCoding())).forEach(materialReportDetails -> {
+                        && !l.getExtendedCoding().equals(material.getExtendedCoding())).forEach(materialReportDetails -> {
                             if (new BigDecimal(l.getRemaining()).compareTo(BigDecimal.valueOf(materialReportDetails.getTotal())) >= 0) {
                                 liKuCompareMaterial(materialReportDetails, l, AreaTypeFlagEnum.SPAN, AreaTypeFlagEnum.SPAN_REPLACEMENT, MaterialsUnitFlagEnum.IS_NOT_SEGMENT);
                             }
                         }
                 );
             }
-        });
+        });*/
 
         //段长非段长合并 排序 处理拆分段长
-        List<LiKuResourcePool> tempList = new ArrayList<>();
+        /*List<LiKuResourcePool> tempList = new ArrayList<>();
         liKuIsSegmentPoolSortList.stream().map(m -> {
             m.setLengthOfCable(m.getRemaining() + ";");
-
             return m;
         }).forEach(l -> {
             if (tempList.size() != 0) {
@@ -410,7 +549,6 @@ public class MaterialReportDetailsService extends CrudService<MaterialReportDeta
                         //修改 利库数量
                         temp.setNumberOfNiches((new BigDecimal(temp.getNumberOfNiches()).add(new BigDecimal(l.getNumberOfNiches()))).toString());
                         flag = false;
-
                         break;
                     }
                 }
@@ -420,10 +558,18 @@ public class MaterialReportDetailsService extends CrudService<MaterialReportDeta
             } else {
                 tempList.add(l);
             }
-        });
+        });*/
+
         //利库合并 并排序
-        List<LiKuResourcePool> sortLiKuPoolList = getSortLiKuPool(Stream.concat(liKuIsNotSegmentPoolSortList.stream(), tempList.stream()).map(m -> {
-            m.setLengthOfCable(interceptString(m.getLengthOfCable()));
+        List<LiKuResourcePool> sortLiKuPoolList = getSortLiKuPool(Stream.concat(liKuIsNotSegmentPoolSortList.stream(), liKuIsSegmentPoolSortList.stream()).map(m -> {
+            if (m.getUnitOfMeasurement().equals(MaterialsUnitFlagEnum.KM.getUnit())) {
+                if (StringUtils.isNotBlank(m.getNumberOfNiches())) {
+                    m.setNumberOfNiches(new BigDecimal(m.getNumberOfNiches()).divide(new BigDecimal(1000)).toString());
+                }
+                if (StringUtils.isNotBlank(m.getRemaining())) {
+                    m.setRemaining(new BigDecimal(m.getRemaining()).divide(new BigDecimal(1000)).toString());
+                }
+            }
             return m;
         }).collect(Collectors.toList()));
         //上报资源合并
@@ -448,17 +594,26 @@ public class MaterialReportDetailsService extends CrudService<MaterialReportDeta
             m.setRegionalReplacementBatch(interceptString(m.getRegionalReplacementBatch()));
             m.setRegionalReplacementHouse(interceptString(m.getRegionalReplacementHouse()));
             m.setRegionalReplacementNumber(interceptString(m.getRegionalReplacementNumber()));
-
+            if (m.getUnit().equals(MaterialsUnitFlagEnum.KM.getUnit())) {
+                BigDecimal convert = new BigDecimal(1000);
+                if (m.getTotal() != null) {
+                    m.setTotal(BigDecimal.valueOf(m.getTotal()).divide(convert).doubleValue());
+                }
+                if (m.getNumberOfNiches() != null) {
+                    m.setNumberOfNiches(BigDecimal.valueOf(m.getNumberOfNiches()).divide(convert).doubleValue());
+                }
+                if (m.getNumberOfApplications() != null) {
+                    m.setNumberOfApplications(BigDecimal.valueOf(m.getNumberOfApplications()).divide(convert).doubleValue());
+                }
+            }
             return m;
         }).collect(Collectors.toList());
 
         /***************************************存储数据库************************************************/
         //清除利库池
-        liKuResourcePoolMapper.clearLiKuResource();
         materialReportDetailsMapper.delAll();
 
-        sortLiKuPoolList.forEach(DataEntity::preInsert);
-        liKuResourcePoolMapper.insertList(sortLiKuPoolList);
+        liKuResourcePoolMapper.updateAllList(sortLiKuPoolList);
 
         materialResultList.forEach(DataEntity::preInsert);
         materialReportDetailsMapper.insertList(materialResultList);
@@ -522,7 +677,9 @@ public class MaterialReportDetailsService extends CrudService<MaterialReportDeta
         /*} else {
             materialReportDetails.setNumberOfNiches(material_liKuCount.add(temp).doubleValue());
         }*/
-
+        if (materialReportDetails.getUnit().equals(MaterialsUnitFlagEnum.KM.getUnit())) {
+            temp = temp.divide(new BigDecimal(1000));
+        }
         //如果代替标识为空则
         if (replacement == null) {
             //传递标识,根据标识来判断本地/跨库 所有结束后统一处理多余,
@@ -530,12 +687,12 @@ public class MaterialReportDetailsService extends CrudService<MaterialReportDeta
                 //拼接本地库批次号
                 materialReportDetails.setLocalWareBatch(materialReportDetails.getLocalWareBatch() + liKuResourcePool.getBatch() + ",");
                 materialReportDetails.setLocalWareHouse(materialReportDetails.getLocalWareHouse() + liKuResourcePool.getInvLocation() + ",");
-                materialReportDetails.setNumberOfLocal(materialReportDetails.getNumberOfLocal() + temp + ",");
+                materialReportDetails.setNumberOfLocal(materialReportDetails.getNumberOfLocal() + temp.setScale(2, BigDecimal.ROUND_HALF_UP) + ",");
             } else {
                 //拼接跨区批次号
                 materialReportDetails.setRegionalBatch(materialReportDetails.getRegionalBatch() + liKuResourcePool.getBatch() + ",");
                 materialReportDetails.setRegionalHouse(materialReportDetails.getRegionalHouse() + liKuResourcePool.getInvLocation() + ",");
-                materialReportDetails.setNumberOfRegional(materialReportDetails.getNumberOfRegional() + temp + ",");
+                materialReportDetails.setNumberOfRegional(materialReportDetails.getNumberOfRegional() + temp.setScale(2, BigDecimal.ROUND_HALF_UP) + ",");
             }
         } else {
             //区分本地利库与跨区利库替换
@@ -544,16 +701,15 @@ public class MaterialReportDetailsService extends CrudService<MaterialReportDeta
                 materialReportDetails.setLocalReplacementExtendedDescription(materialReportDetails.getLocalReplacementExtendedDescription() + liKuResourcePool.getExtendedDescription() + ",");
                 materialReportDetails.setLocalReplacementBatch(materialReportDetails.getLocalReplacementBatch() + liKuResourcePool.getBatch() + ",");
                 materialReportDetails.setLocalReplacementHouse(materialReportDetails.getLocalReplacementHouse() + liKuResourcePool.getInvLocation() + ",");
-                materialReportDetails.setLocalReplacementNumber(materialReportDetails.getLocalReplacementNumber() + temp + ",");
+                materialReportDetails.setLocalReplacementNumber(materialReportDetails.getLocalReplacementNumber() + temp.setScale(2, BigDecimal.ROUND_HALF_UP) + ",");
             } else {
                 materialReportDetails.setRegionalReplacementExtendedCoding(materialReportDetails.getRegionalReplacementExtendedCoding() + liKuResourcePool.getExtendedCoding() + ",");
                 materialReportDetails.setRegionalReplacementExtendedDescription(materialReportDetails.getRegionalReplacementExtendedDescription() + liKuResourcePool.getExtendedDescription() + ",");
                 materialReportDetails.setRegionalReplacementBatch(materialReportDetails.getRegionalReplacementBatch() + liKuResourcePool.getBatch() + ",");
                 materialReportDetails.setRegionalReplacementHouse(materialReportDetails.getRegionalReplacementHouse() + liKuResourcePool.getInvLocation() + ",");
-                materialReportDetails.setRegionalReplacementNumber(materialReportDetails.getRegionalReplacementNumber() + temp + ",");
+                materialReportDetails.setRegionalReplacementNumber(materialReportDetails.getRegionalReplacementNumber() + temp.setScale(2, BigDecimal.ROUND_HALF_UP) + ",");
             }
         }
-
     }
 
     /**
@@ -595,21 +751,23 @@ public class MaterialReportDetailsService extends CrudService<MaterialReportDeta
 
     /**
      * 上报资源排序 地区-》需求数量-》扩展编码
+     *
      * @param materialReportDetailsList
      * @return
      */
-    private List<MaterialReportDetails> getSortMaterialReport(List<MaterialReportDetails> materialReportDetailsList){
-        return materialReportDetailsList.stream().sorted((material1,material2)->{
-            if(material1.getAreaCodeFlagEnum()==material2.getAreaCodeFlagEnum()){
-                if(material1.getTotal().compareTo(material2.getTotal())==0){
+    private List<MaterialReportDetails> getSortMaterialReport(List<MaterialReportDetails> materialReportDetailsList) {
+        return materialReportDetailsList.stream().sorted((material1, material2) -> {
+            if (material1.getAreaCodeFlagEnum() == material2.getAreaCodeFlagEnum()) {
+                if (material1.getTotal().compareTo(material2.getTotal()) == 0) {
                     return new BigDecimal(material1.getExtendedCoding()).compareTo(new BigDecimal(material2.getExtendedCoding()));
-                }else{
+                } else {
                     return material2.getTotal().compareTo(material1.getTotal());
                 }
-            }else{
+            } else {
                 return material1.getAreaCodeFlagEnum().getNum() - material2.getAreaCodeFlagEnum().getNum();
             }
         }).collect(Collectors.toList());
     }
 
+
 }

+ 42 - 6
src/main/java/com/jeeplus/modules/sg/balancedlibrary/materialReportDetails/utils/ExportUtil.java

@@ -69,8 +69,26 @@ public class ExportUtil {
                     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 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); //跨区替代利库利库数量
 
 
                     cell0.setCellValue(getString(report.getReportingArea()));
@@ -84,11 +102,29 @@ public class ExportUtil {
                     cell8.setCellValue(getString(report.getUnitWeight()));
                     cell9.setCellValue(getString(report.getTotalWeight()));
                     cell10.setCellValue(getString(report.getSupplied()));
-                    cell11.setCellValue(getDouble(report.getNumberOfNiches()));
-                    cell12.setCellValue(getDouble(report.getNumberOfApplications()));
+                    cell11.setCellValue(getString(report.getReportPerson()));//提报人
+                    cell12.setCellValue(getString(report.getReportDepartment()));//提报部门
+                    cell13.setCellValue(getDouble(report.getNumberOfNiches()));
+                    cell14.setCellValue(getDouble(report.getNumberOfApplications()));
+                    cell15.setCellValue(getString(report.getLocalWareBatch()));
+                    cell16.setCellValue(getString(report.getLocalWareHouse()));
+                    cell17.setCellValue(getString(report.getNumberOfLocal()));
+                    cell18.setCellValue(getString(report.getRegionalBatch()));
+                    cell19.setCellValue(getString(report.getRegionalHouse()));
+                    cell20.setCellValue(getString(report.getNumberOfRegional()));
+                    cell21.setCellValue(getString(report.getLocalReplacementExtendedCoding()));
+                    cell22.setCellValue(getString(report.getLocalReplacementExtendedDescription()));
+                    cell23.setCellValue(getString(report.getLocalReplacementBatch()));
+                    cell24.setCellValue(getString(report.getLocalReplacementHouse()));
+                    cell25.setCellValue(getString(report.getLocalReplacementNumber()));
+                    cell26.setCellValue(getString(report.getRegionalReplacementExtendedCoding()));
+                    cell27.setCellValue(getString(report.getRegionalReplacementExtendedDescription()));
+                    cell28.setCellValue(getString(report.getRegionalReplacementBatch()));
+                    cell29.setCellValue(getString(report.getRegionalReplacementHouse()));
+                    cell30.setCellValue(getString(report.getRegionalReplacementNumber()));
                 }
             }
-            //利库明细情况
+            /*//利库明细情况
             Sheet sheet2 = workbook.getSheetAt(1);
             if(likuList!=null&&likuList.size()>0){
                 for(int i=0;i<likuList.size();i++){
@@ -142,7 +178,7 @@ public class ExportUtil {
                     }
 
                 }
-            }
+            }*/
 
             String fileName = "物资上报利库情况表" + DateUtils.getDate("yyyyMMddHHmmss") + ".xlsx";
             String str = URLEncoder.encode(fileName, "UTF8");

+ 4 - 5
src/main/java/com/jeeplus/modules/sg/balancedlibrary/materialReportDetails/web/MaterialReportDetailsControllerTest.java

@@ -243,8 +243,8 @@ public class MaterialReportDetailsControllerTest extends BaseController {
             if(!j.isSuccess()){
                 return j;
             }
-            String fileName = "项目物资需求表" + DateUtils.getDate("yyyyMMddHHmmss") + ".xlsx";
-            new ExportExcel("", MaterialReportDetails.class).setDataList(list).write(response, fileName).dispose();
+            /*String fileName = "项目物资需求表" + DateUtils.getDate("yyyyMMddHHmmss") + ".xlsx";
+            new ExportExcel("", MaterialReportDetails.class).setDataList(list).write(response, fileName).dispose();*/
 
             //利库基础数据更新库存
             //poolService.updateAllList(poolList);
@@ -255,7 +255,6 @@ public class MaterialReportDetailsControllerTest extends BaseController {
             }
             */
         } catch (Exception e) {
-            j.setSuccess(false);
             j.setMsg("导入物资上报明细失败!失败信息:" + e.getMessage());
             e.printStackTrace();
         }
@@ -615,9 +614,9 @@ public class MaterialReportDetailsControllerTest extends BaseController {
 
             }
 
-            *//****************************************段长比对*****************************************************//*
+            /****************************************段长比对*****************************************************/
             //本部-本部
-            if (bBPoolList.size() > 0 && bBSegmentList.size() > 0) {
+            /*if (bBPoolList.size() > 0 && bBSegmentList.size() > 0) {
                 AdjustUtil.segAdjustReverse(bBSegmentList,bBPoolList,compareHistories,AdjustUtil.LOCAL_ADJUST);
                 AdjustUtil.segAdjust(bBSegmentList,bBPoolList,compareHistories,AdjustUtil.LOCAL_ADJUST);
             }

BIN
src/main/resources/freemarker/excelmodel/materialReport.xlsx


+ 241 - 0
src/main/webapp/webpage/modules/sg/balancedlibrary/materialReportDetails/MaterialReportDetailsList.js

@@ -264,6 +264,247 @@ $(document).ready(function() {
 
 				   }
 
+
+				   ,{
+					   field: 'localWareBatch',
+					   title: '本地利库批次号',
+					   width: '10%',
+					   sortable: true,
+					   formatter:function(value, row , index){
+						   if(row.numberOfNiches > 0&&value){
+							   return "<a style='color:red'>" + value + "</a>";
+						   }else{
+							   return value;
+						   }
+					   },
+					   sortName: 'localWareBatch'
+
+				   }
+				   ,{
+					   field: 'localWareHouse',
+					   title: '本地利库库存地',
+					   width: '10%',
+					   sortable: true,
+					   formatter:function(value, row , index){
+						   if(row.numberOfNiches > 0&&value){
+							   return "<a style='color:red'>" + value + "</a>";
+						   }else{
+							   return value;
+						   }
+					   },
+					   sortName: 'localWareHouse'
+
+				   }
+				   ,{
+					   field: 'numberOfLocal',
+					   title: '本地利库数量',
+					   width: '10%',
+					   sortable: true,
+					   formatter:function(value, row , index){
+						   if(row.numberOfNiches > 0&&value){
+							   return "<a style='color:red'>" + value + "</a>";
+						   }else{
+							   return value;
+						   }
+					   },
+					   sortName: 'numberOfLocal'
+
+				   }
+				   ,{
+					   field: 'regionalBatch',
+					   title: '跨区利库批次号',
+					   width: '10%',
+					   sortable: true,
+					   formatter:function(value, row , index){
+						   if(row.numberOfNiches > 0&&value){
+							   return "<a style='color:red'>" + value + "</a>";
+						   }else{
+							   return value;
+						   }
+					   },
+					   sortName: 'regionalBatch'
+
+				   }
+				   ,{
+					   field: 'regionalHouse',
+					   title: '跨区利库库存地',
+					   width: '10%',
+					   sortable: true,
+					   formatter:function(value, row , index){
+						   if(row.numberOfNiches > 0&&value){
+							   return "<a style='color:red'>" + value + "</a>";
+						   }else{
+							   return value;
+						   }
+					   },
+					   sortName: 'regionalHouse'
+
+				   }
+				   ,{
+					   field: 'numberOfRegional',
+					   title: '跨区利库数量',
+					   width: '10%',
+					   sortable: true,
+					   formatter:function(value, row , index){
+						   if(row.numberOfNiches > 0&&value){
+							   return "<a style='color:red'>" + value + "</a>";
+						   }else{
+							   return value;
+						   }
+					   },
+					   sortName: 'numberOfRegional'
+
+				   }
+				   ,{
+					   field: 'localReplacementExtendedCoding',
+					   title: '本地替代利库利库扩展编码',
+					   width: '10%',
+					   sortable: true,
+					   formatter:function(value, row , index){
+						   if(row.numberOfNiches > 0&&value){
+							   return "<a style='color:red'>" + value + "</a>";
+						   }else{
+							   return value;
+						   }
+					   },
+					   sortName: 'localReplacementExtendedCoding'
+
+				   }
+				   ,{
+					   field: 'localReplacementExtendedDescription',
+					   title: '本地替代利库利库扩展描述',
+					   width: '10%',
+					   sortable: true,
+					   formatter:function(value, row , index){
+						   if(row.numberOfNiches > 0&&value){
+							   return "<a style='color:red'>" + value + "</a>";
+						   }else{
+							   return value;
+						   }
+					   },
+					   sortName: 'localReplacementExtendedDescription'
+
+				   }
+				   ,{
+					   field: 'localReplacementBatch',
+					   title: '本地替代利库利库批次号',
+					   width: '10%',
+					   sortable: true,
+					   formatter:function(value, row , index){
+						   if(row.numberOfNiches > 0&&value){
+							   return "<a style='color:red'>" + value + "</a>";
+						   }else{
+							   return value;
+						   }
+					   },
+					   sortName: 'localReplacementBatch'
+
+				   }
+				   ,{
+					   field: 'localReplacementHouse',
+					   title: '本地替代利库利库库存地',
+					   width: '10%',
+					   sortable: true,
+					   formatter:function(value, row , index){
+						   if(row.numberOfNiches > 0&&value){
+							   return "<a style='color:red'>" + value + "</a>";
+						   }else{
+							   return value;
+						   }
+					   },
+					   sortName: 'localReplacementHouse'
+
+				   }
+				   ,{
+					   field: 'localReplacementNumber',
+					   title: '本地替代利库利库数量',
+					   width: '10%',
+					   sortable: true,
+					   formatter:function(value, row , index){
+						   if(row.numberOfNiches > 0&&value){
+							   return "<a style='color:red'>" + value + "</a>";
+						   }else{
+							   return value;
+						   }
+					   },
+					   sortName: 'localReplacementNumber'
+
+				   }
+				   ,{
+					   field: 'regionalReplacementExtendedCoding',
+					   title: '跨区替代利库利库扩展编码',
+					   width: '10%',
+					   sortable: true,
+					   formatter:function(value, row , index){
+						   if(row.numberOfNiches > 0&&value){
+							   return "<a style='color:red'>" + value + "</a>";
+						   }else{
+							   return value;
+						   }
+					   },
+					   sortName: 'regionalReplacementExtendedCoding'
+
+				   }
+				   ,{
+					   field: 'regionalReplacementExtendedDescription',
+					   title: '跨区替代利库利库扩展描述',
+					   width: '10%',
+					   sortable: true,
+					   formatter:function(value, row , index){
+						   if(row.numberOfNiches > 0&&value){
+							   return "<a style='color:red'>" + value + "</a>";
+						   }else{
+							   return value;
+						   }
+					   },
+					   sortName: 'regionalReplacementExtendedDescription'
+
+				   }
+				   ,{
+					   field: 'regionalReplacementBatch',
+					   title: '跨区替代利库利库批次号',
+					   width: '10%',
+					   sortable: true,
+					   formatter:function(value, row , index){
+						   if(row.numberOfNiches > 0&&value){
+							   return "<a style='color:red'>" + value + "</a>";
+						   }else{
+							   return value;
+						   }
+					   },
+					   sortName: 'regionalReplacementBatch'
+
+				   }
+				   ,{
+					   field: 'regionalReplacementHouse',
+					   title: '跨区替代利库利库库存地',
+					   width: '10%',
+					   sortable: true,
+					   formatter:function(value, row , index){
+						   if(row.numberOfNiches > 0&&value){
+							   return "<a style='color:red'>" + value + "</a>";
+						   }else{
+							   return value;
+						   }
+					   },
+					   sortName: 'regionalReplacementHouse'
+
+				   }
+				   ,{
+					   field: 'regionalReplacementNumber',
+					   title: '跨区替代利库利库数量',
+					   width: '10%',
+					   sortable: true,
+					   formatter:function(value, row , index){
+						   if(row.numberOfNiches > 0&&value){
+							   return "<a style='color:red'>" + value + "</a>";
+						   }else{
+							   return value;
+						   }
+					   },
+					   sortName: 'regionalReplacementNumber'
+
+				   }
 		     ]
 
 		});