Browse Source

利库调整及财务管理调整

chengqiang 4 năm trước cách đây
mục cha
commit
f8c0b96de6
30 tập tin đã thay đổi với 3310 bổ sung199 xóa
  1. 10 0
      src/main/java/com/jeeplus/modules/sg/balancedlibrary/liKuResourcePool/entity/LiKuResourcePool.java
  2. 3 1
      src/main/java/com/jeeplus/modules/sg/balancedlibrary/liKuResourcePool/mapper/xml/LiKuResourcePoolMapper.xml
  3. 393 0
      src/main/java/com/jeeplus/modules/sg/balancedlibrary/liKuResourcePool/utils/ImportUtil.java
  4. 10 0
      src/main/java/com/jeeplus/modules/sg/balancedlibrary/liKuResourcePool/utils/LiKuUtils.java
  5. 102 27
      src/main/java/com/jeeplus/modules/sg/balancedlibrary/liKuResourcePool/utils/OptimalUtil.java
  6. 42 35
      src/main/java/com/jeeplus/modules/sg/balancedlibrary/liKuResourcePool/web/LiKuResourcePoolController.java
  7. 172 0
      src/main/java/com/jeeplus/modules/sg/balancedlibrary/materialReportDetails/entity/LikuDetail.java
  8. 8 0
      src/main/java/com/jeeplus/modules/sg/balancedlibrary/materialReportDetails/entity/MaterialReportDetails.java
  9. 23 0
      src/main/java/com/jeeplus/modules/sg/balancedlibrary/materialReportDetails/mapper/CompareHistoryMapper.java
  10. 3 0
      src/main/java/com/jeeplus/modules/sg/balancedlibrary/materialReportDetails/mapper/MaterialReportDetailsMapper.java
  11. 37 0
      src/main/java/com/jeeplus/modules/sg/balancedlibrary/materialReportDetails/mapper/xml/CompareHistoryMapper.xml
  12. 64 2
      src/main/java/com/jeeplus/modules/sg/balancedlibrary/materialReportDetails/mapper/xml/MaterialReportDetailsMapper.xml
  13. 48 0
      src/main/java/com/jeeplus/modules/sg/balancedlibrary/materialReportDetails/service/CompareHistoryService.java
  14. 5 0
      src/main/java/com/jeeplus/modules/sg/balancedlibrary/materialReportDetails/service/MaterialReportDetailsService.java
  15. 525 0
      src/main/java/com/jeeplus/modules/sg/balancedlibrary/materialReportDetails/utils/AdjustUtil.java
  16. 226 0
      src/main/java/com/jeeplus/modules/sg/balancedlibrary/materialReportDetails/utils/ExportUtil.java
  17. 13 2
      src/main/java/com/jeeplus/modules/sg/balancedlibrary/materialReportDetails/web/MaterialReportDetailsController.java
  18. 906 0
      src/main/java/com/jeeplus/modules/sg/balancedlibrary/materialReportDetails/web/MaterialReportDetailsControllerTest.java
  19. 2 1
      src/main/java/com/jeeplus/modules/sg/balancedlibrary/replaceMaterial/web/ReplaceMaterialController.java
  20. 6 6
      src/main/java/com/jeeplus/modules/sg/financial/erpcredit/util/ErpInfo.java
  21. 1 1
      src/main/java/com/jeeplus/modules/sg/financial/settlement/mapper/DonorMaterialMapper.java
  22. 1 0
      src/main/java/com/jeeplus/modules/sg/financial/settlement/mapper/xml/DonorMaterialMapper.xml
  23. 2 1
      src/main/java/com/jeeplus/modules/sg/financial/settlement/service/DonorMaterialService.java
  24. BIN
      src/main/resources/freemarker/excelmodel/materialReport.xlsx
  25. 126 0
      src/main/webapp/webpage/modules/sg/balancedlibrary/materialReportDetails/LikuResults.js
  26. 36 0
      src/main/webapp/webpage/modules/sg/balancedlibrary/materialReportDetails/LikuResults.jsp
  27. 114 111
      src/main/webapp/webpage/modules/sg/balancedlibrary/materialReportDetails/MaterialReportDetailsList.js
  28. 395 0
      src/main/webapp/webpage/modules/sg/balancedlibrary/materialReportDetails/MaterialReportDetailsList_1.js
  29. 20 12
      src/main/webapp/webpage/modules/sg/balancedlibrary/materialReportDetails/MaterialReportDetailslList.jsp
  30. 17 0
      src/main/webapp/webpage/modules/sg/financial/settlement/donorMaterialList.js

+ 10 - 0
src/main/java/com/jeeplus/modules/sg/balancedlibrary/liKuResourcePool/entity/LiKuResourcePool.java

@@ -127,6 +127,16 @@ public class LiKuResourcePool extends DataEntity<LiKuResourcePool> {
      */
     private String meterNumber;
 
+    public Double getLengthOfMetre() {
+        return lengthOfMetre;
+    }
+
+    public void setLengthOfMetre(Double lengthOfMetre) {
+        this.lengthOfMetre = lengthOfMetre;
+    }
+
+    private Double lengthOfMetre;//段长资源的长度(以米为单位) ,即lengthOfCable的米单位值
+
     @ExcelField(title = "序号", align = 2, sort = 1)
     public String getSerialNumber() {
         return serialNumber;

+ 3 - 1
src/main/java/com/jeeplus/modules/sg/balancedlibrary/liKuResourcePool/mapper/xml/LiKuResourcePoolMapper.xml

@@ -59,7 +59,9 @@
 		a.isExpansion AS "isExpansion",
 		a.numberOfNiches AS "numberOfNiches",
 		a.remaining AS "remaining",
-		a.segBelongs AS "segBelongs"
+		a.segBelongs AS "segBelongs",
+		a.isSectionLength AS "isSectionLength",
+		a.whereFrom AS "whereFrom"
 	</sql>
 
 	<sql id="leftJoins">

+ 393 - 0
src/main/java/com/jeeplus/modules/sg/balancedlibrary/liKuResourcePool/utils/ImportUtil.java

@@ -0,0 +1,393 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.sg.balancedlibrary.liKuResourcePool.utils;
+
+import com.google.common.collect.Lists;
+import com.jeeplus.common.utils.Reflections;
+import com.jeeplus.common.utils.excel.annotation.ExcelField;
+import com.jeeplus.modules.sys.entity.Area;
+import com.jeeplus.modules.sys.entity.Office;
+import com.jeeplus.modules.sys.entity.User;
+import com.jeeplus.modules.sys.utils.DictUtils;
+import com.jeeplus.modules.sys.utils.UserUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.hssf.usermodel.HSSFDateUtil;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.text.NumberFormat;
+import java.text.SimpleDateFormat;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 导入Excel文件(支持“XLS”和“XLSX”格式)
+ * @author jeeplus
+ * @version 2016-03-10
+ */
+public class ImportUtil {
+
+	private static Logger log = LoggerFactory.getLogger(ImportUtil.class);
+
+	/**
+	 * 工作薄对象
+	 */
+	private Workbook wb;
+
+	/**
+	 * 工作表对象
+	 */
+	private Sheet sheet;
+
+	/**
+	 * 标题行号
+	 */
+	private int headerNum;
+
+	/**
+	 * 构造函数
+	 * @throws InvalidFormatException
+	 * @throws IOException
+	 */
+	public ImportUtil(String fileName, int headerNum)
+			throws InvalidFormatException, IOException {
+		this(new File(fileName), headerNum);
+	}
+
+	/**
+	 * 构造函数
+	 * @param path 导入文件对象,读取第一个工作表
+	 * @param headerNum 标题行号,数据行号=标题行号+1
+	 * @throws InvalidFormatException
+	 * @throws IOException
+	 */
+	public ImportUtil(File file, int headerNum)
+			throws InvalidFormatException, IOException {
+		this(file, headerNum, 0);
+	}
+
+	/**
+	 * 构造函数
+	 * @param path 导入文件
+	 * @param headerNum 标题行号,数据行号=标题行号+1
+	 * @param sheetIndex 工作表编号
+	 * @throws InvalidFormatException
+	 * @throws IOException
+	 */
+	public ImportUtil(String fileName, int headerNum, int sheetIndex)
+			throws InvalidFormatException, IOException {
+		this(new File(fileName), headerNum, sheetIndex);
+	}
+
+	/**
+	 * 构造函数
+	 * @param path 导入文件对象
+	 * @param headerNum 标题行号,数据行号=标题行号+1
+	 * @param sheetIndex 工作表编号
+	 * @throws InvalidFormatException
+	 * @throws IOException
+	 */
+	public ImportUtil(File file, int headerNum, int sheetIndex)
+			throws InvalidFormatException, IOException {
+		this(file.getName(), new FileInputStream(file), headerNum, sheetIndex);
+	}
+
+	/**
+	 * 构造函数
+	 * @param file 导入文件对象
+	 * @param headerNum 标题行号,数据行号=标题行号+1
+	 * @param sheetIndex 工作表编号
+	 * @throws InvalidFormatException
+	 * @throws IOException
+	 */
+	public ImportUtil(MultipartFile multipartFile, int headerNum, int sheetIndex)
+			throws InvalidFormatException, IOException {
+		this(multipartFile.getOriginalFilename(), multipartFile.getInputStream(), headerNum, sheetIndex);
+	}
+
+	/**
+	 * 构造函数
+	 * @param path 导入文件对象
+	 * @param headerNum 标题行号,数据行号=标题行号+1
+	 * @param sheetIndex 工作表编号
+	 * @throws InvalidFormatException
+	 * @throws IOException
+	 */
+	public ImportUtil(String fileName, InputStream is, int headerNum, int sheetIndex)
+			throws InvalidFormatException, IOException {
+		if (StringUtils.isBlank(fileName)){
+			throw new RuntimeException("导入文档为空!");
+		}else if(fileName.toLowerCase().endsWith("xls")){    
+			this.wb = new HSSFWorkbook(is);    
+        }else if(fileName.toLowerCase().endsWith("xlsx")){  
+        	this.wb = new XSSFWorkbook(is);
+        }else{  
+        	throw new RuntimeException("文档格式不正确!");
+        }  
+		if (this.wb.getNumberOfSheets()<sheetIndex){
+			throw new RuntimeException("文档中没有工作表!");
+		}
+		this.sheet = this.wb.getSheetAt(sheetIndex);
+		this.headerNum = headerNum;
+		log.debug("Initialize success.");
+	}
+	
+	/**
+	 * 获取行对象
+	 * @param rownum
+	 * @return
+	 */
+	public Row getRow(int rownum){
+		return this.sheet.getRow(rownum);
+	}
+
+	/**
+	 * 获取数据行号
+	 * @return
+	 */
+	public int getDataRowNum(){
+		return headerNum+1;
+	}
+	
+	/**
+	 * 获取最后一个数据行号
+	 * @return
+	 */
+	public int getLastDataRowNum(){
+//		return this.sheet.getLastRowNum()+headerNum;
+		return this.sheet.getLastRowNum()+1;
+	}
+	
+	/**
+	 * 获取最后一个列号
+	 * @return
+	 */
+	public int getLastCellNum(){
+		return this.getRow(headerNum).getLastCellNum();
+	}
+	
+	/**
+	 * 获取单元格值
+	 * @param row 获取的行
+	 * @param column 获取单元格列号
+	 * @return 单元格值
+	 */
+	public Object getCellValue(Row row, int column) {
+		Object val = "";
+		try {
+			Cell cell = row.getCell(column);
+			if (cell != null) {
+				if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
+					// val = cell.getNumericCellValue();
+					// 当excel 中的数据为数值或日期是需要特殊处理
+					if (HSSFDateUtil.isCellDateFormatted(cell)) {
+						double d = cell.getNumericCellValue();
+						Date date = HSSFDateUtil.getJavaDate(d);
+						SimpleDateFormat dformat = new SimpleDateFormat(
+								"yyyy-MM-dd");
+						val = dformat.format(date);
+					} else {
+						NumberFormat nf = NumberFormat.getInstance();
+						nf.setGroupingUsed(false);// true时的格式:1,234,567,890
+						val = nf.format(cell.getNumericCellValue());// 数值类型的数据为double,所以需要转换一下
+					}
+				} else if (cell.getCellType() == Cell.CELL_TYPE_STRING) {
+					val = cell.getStringCellValue();
+				} else if (cell.getCellType() == Cell.CELL_TYPE_FORMULA) {
+					val = cell.getCellFormula();
+				} else if (cell.getCellType() == Cell.CELL_TYPE_BOOLEAN) {
+					val = cell.getBooleanCellValue();
+				} else if (cell.getCellType() == Cell.CELL_TYPE_ERROR) {
+					val = cell.getErrorCellValue();
+				}
+			}
+		} catch (Exception e) {
+			return val;
+		}
+		return val;
+	}
+	
+	/**
+	 * 获取导入数据列表
+	 * @param cls 导入对象类型
+	 * @param groups 导入分组
+	 */
+	public <E> List<E> getDataList(Class<E> cls, int... groups) throws InstantiationException, IllegalAccessException{
+		List<Object[]> annotationList = Lists.newArrayList();
+		// Get annotation field 
+		Field[] fs = cls.getDeclaredFields();
+		for (Field f : fs){
+			ExcelField ef = f.getAnnotation(ExcelField.class);
+			if (ef != null && (ef.type()==0 || ef.type()==2)){
+				if (groups!=null && groups.length>0){
+					boolean inGroup = false;
+					for (int g : groups){
+						if (inGroup){
+							break;
+						}
+						for (int efg : ef.groups()){
+							if (g == efg){
+								inGroup = true;
+								annotationList.add(new Object[]{ef, f});
+								break;
+							}
+						}
+					}
+				}else{
+					annotationList.add(new Object[]{ef, f});
+				}
+			}
+		}
+		// Get annotation method
+		Method[] ms = cls.getDeclaredMethods();
+		for (Method m : ms){
+			ExcelField ef = m.getAnnotation(ExcelField.class);
+			if (ef != null && (ef.type()==0 || ef.type()==2)){
+				if (groups!=null && groups.length>0){
+					boolean inGroup = false;
+					for (int g : groups){
+						if (inGroup){
+							break;
+						}
+						for (int efg : ef.groups()){
+							if (g == efg){
+								inGroup = true;
+								annotationList.add(new Object[]{ef, m});
+								break;
+							}
+						}
+					}
+				}else{
+					annotationList.add(new Object[]{ef, m});
+				}
+			}
+		}
+		// Field sorting
+		Collections.sort(annotationList, new Comparator<Object[]>() {
+			public int compare(Object[] o1, Object[] o2) {
+				return new Integer(((ExcelField)o1[0]).sort()).compareTo(
+						new Integer(((ExcelField)o2[0]).sort()));
+			};
+		});
+		//log.debug("Import column count:"+annotationList.size());
+		// Get excel data
+		List<E> dataList = Lists.newArrayList();
+		for (int i = this.getDataRowNum(); i < this.getLastDataRowNum(); i++) {
+			E e = (E)cls.newInstance();
+			int column = 0;
+			Row row = this.getRow(i);
+			StringBuilder sb = new StringBuilder();
+			for (Object[] os : annotationList){
+				Object val = this.getCellValue(row, column++);
+				if (val != null){
+					ExcelField ef = (ExcelField)os[0];
+					// If is dict type, get dict value
+					if (StringUtils.isNotBlank(ef.dictType())){
+						val = DictUtils.getDictValue(val.toString(), ef.dictType(), "");
+						//log.debug("Dictionary type value: ["+i+","+colunm+"] " + val);
+					}
+					// Get param type and type cast
+					Class<?> valType = Class.class;
+					if (os[1] instanceof Field){
+						valType = ((Field)os[1]).getType();
+					}else if (os[1] instanceof Method){
+						Method method = ((Method)os[1]);
+						if ("get".equals(method.getName().substring(0, 3))){
+							valType = method.getReturnType();
+						}else if("set".equals(method.getName().substring(0, 3))){
+							valType = ((Method)os[1]).getParameterTypes()[0];
+						}
+					}
+					//log.debug("Import value type: ["+i+","+column+"] " + valType);
+					try {
+						//如果导入的java对象,需要在这里自己进行变换。
+						if (valType == String.class){
+							String s = String.valueOf(val.toString());
+							if(StringUtils.endsWith(s, ".0")){
+								val = StringUtils.substringBefore(s, ".0");
+							}else{
+								val = String.valueOf(val.toString());
+							}
+						}else if (valType == Integer.class){
+							val = Double.valueOf(val.toString()).intValue();
+						}else if (valType == Long.class){
+							val = Double.valueOf(val.toString()).longValue();
+						}else if (valType == Double.class){
+							val = Double.valueOf(val.toString());
+						}else if (valType == Float.class){
+							val = Float.valueOf(val.toString());
+						}else if (valType == Date.class){
+							SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
+							val=sdf.parse(val.toString()); 
+						}else if (valType == User.class){
+							val = UserUtils.getByUserName(val.toString());
+						}else if (valType == Office.class){
+							val = UserUtils.getByOfficeName(val.toString());
+						}else if (valType == Area.class){
+							val = UserUtils.getByAreaName(val.toString());
+						}else{
+							if (ef.fieldType() != Class.class){
+								val = ef.fieldType().getMethod("getValue", String.class).invoke(null, val.toString());
+							}else{
+								val = Class.forName(this.getClass().getName().replaceAll(this.getClass().getSimpleName(), 
+										"fieldtype."+valType.getSimpleName()+"Type")).getMethod("getValue", String.class).invoke(null, val.toString());
+							}
+						}
+					} catch (Exception ex) {
+						log.info("Get cell value ["+i+","+column+"] error: " + ex.toString());
+						val = null;
+					}
+					// set entity value
+					if (os[1] instanceof Field){
+						Reflections.invokeSetter(e, ((Field)os[1]).getName(), val);
+					}else if (os[1] instanceof Method){
+						String mthodName = ((Method)os[1]).getName();
+						if ("get".equals(mthodName.substring(0, 3))){
+							mthodName = "set"+StringUtils.substringAfter(mthodName, "get");
+						}
+						Reflections.invokeMethod(e, mthodName, new Class[] {valType}, new Object[] {val});
+					}
+				}
+				sb.append(val+", ");
+			}
+			dataList.add(e);
+			log.debug("Read success: ["+i+"] "+sb.toString());
+		}
+		return dataList;
+	}
+
+//	/**
+//	 * 导入测试
+//	 */
+//	public static void main(String[] args) throws Throwable {
+//		
+//		ImportExcel ei = new ImportExcel("target/export.xlsx", 1);
+//		
+//		for (int i = ei.getDataRowNum(); i < ei.getLastDataRowNum(); i++) {
+//			Row row = ei.getRow(i);
+//			for (int j = 0; j < ei.getLastCellNum(); j++) {
+//				Object val = ei.getCellValue(row, j);
+//				System.out.print(val+", ");
+//			}
+//			System.out.print("\n");
+//		}
+//		
+//	}
+}

+ 10 - 0
src/main/java/com/jeeplus/modules/sg/balancedlibrary/liKuResourcePool/utils/LiKuUtils.java

@@ -42,6 +42,11 @@ public class LiKuUtils {
     public static final String Kilometer = "千米";
 
 
+    /**
+     * 根据单位判断物资是否为段长
+     * @param unit
+     * @return
+     */
     public static Integer isTheUnitMeter(String unit) {
         if (METER.equals(unit) || Kilometer.equals(unit)) {
             return YES;
@@ -50,6 +55,11 @@ public class LiKuUtils {
         }
     }
 
+    /**
+     * 判断物资或利库所属地区
+     * @param area
+     * @return
+     */
     public static Integer judgmentArea(String area) {
         if (HLA2.equals(area) || area.contains(BB_PLACE)) {
             return BB_FLAG;

+ 102 - 27
src/main/java/com/jeeplus/modules/sg/balancedlibrary/liKuResourcePool/utils/OptimalUtil.java

@@ -1,5 +1,6 @@
 package com.jeeplus.modules.sg.balancedlibrary.liKuResourcePool.utils;
 
+import com.jeeplus.modules.sg.balancedlibrary.liKuResourcePool.entity.LiKuResourcePool;
 import com.jeeplus.modules.sg.balancedlibrary.materialReportDetails.entity.MaterialReportDetails;
 import com.jeeplus.modules.sys.utils.DictUtils;
 
@@ -11,8 +12,12 @@ public class OptimalUtil {
     private boolean getEqual = false;
     //所有可能的元素组合列表
     private List<List<MaterialReportDetails>> result = new ArrayList<>();
+    //由物资上报方开始匹配时所有可能的元素组合列表
+    private List<List<LiKuResourcePool>> resultReverse = new ArrayList<>();
     //最大浪费量
-    private BigDecimal maxiNun = BigDecimal.valueOf(0.0);
+    private BigDecimal maxiNun = new BigDecimal(DictUtils.getDictValue("maxWaste", "maximum_waste", ""));
+    //由物资上报方开始匹配时最大差额
+    private BigDecimal maxiNunReverse = new BigDecimal(DictUtils.getDictValue("maxWasteReverse", "maximum_waste", ""));
 
     /**
      *
@@ -22,36 +27,57 @@ public class OptimalUtil {
      */
     public List<MaterialReportDetails> getOptimal(double total, List<MaterialReportDetails> elements){
         //list降序排列
-        Collections.sort(elements, Comparator.comparing(MaterialReportDetails::getTotal));
+        Collections.sort(elements, Comparator.comparing(MaterialReportDetails::getLengthOfMetre));
         Collections.reverse(elements);
         solve(0,0,new ArrayList<>(),total,elements);
 
         //找到差值最小组合返回
         List<MaterialReportDetails> returnList = new ArrayList<>();
-        BigDecimal max = BigDecimal.valueOf(0.0);
-        for (List<MaterialReportDetails> detailsList :
-                result) {
-            BigDecimal bigAll = BigDecimal.valueOf(0.0);
-            for (MaterialReportDetails details :
-                    detailsList) {
-                bigAll = bigAll.add(BigDecimal.valueOf(details.getTotal()));
+        BigDecimal currMax = BigDecimal.valueOf(0.0);//当前总和最大
+        for (List<MaterialReportDetails> detailsList :result) {
+            BigDecimal listSum = BigDecimal.valueOf(0.0);
+            for (MaterialReportDetails details :detailsList) {
+                listSum = listSum.add(BigDecimal.valueOf(details.getLengthOfMetre()));
             }
-            if (bigAll.compareTo(max) > 0) {
-                max = bigAll;
-                returnList.clear();
-                returnList.addAll(detailsList);
+            if (listSum.compareTo(currMax) > 0) {
+                currMax = listSum;
+                returnList = detailsList;
+//                returnList.clear();
+//                returnList.addAll(detailsList);
             }
         }
 
-/*        for(List<MaterialReportDetails> bigList:result){
-            String str = "";
-            double listNum = 0;
-            for(MaterialReportDetails i:bigList){
-                listNum = listNum + i.getTotal();
-                str = str + i + ",";
+
+        return returnList;
+    }
+
+    /**
+     *
+     * @param total 待比对的值
+     * @param elements  利库所有元素集合
+     * @return
+     */
+    public List<LiKuResourcePool> getOptimalReverse(double total, List<LiKuResourcePool> elements){
+        //list降序排列
+        Collections.sort(elements, Comparator.comparing(LiKuResourcePool::getLengthOfMetre));
+        solveReverse(0,0,new ArrayList<>(),total,elements);
+
+        //找到差值最小组合返回
+        List<LiKuResourcePool> returnList = new ArrayList<>();
+        BigDecimal currMin = BigDecimal.valueOf(total).add(maxiNunReverse);//当前最小值
+        for (List<LiKuResourcePool> poolList : resultReverse) {
+            BigDecimal listSum = BigDecimal.valueOf(0.0);
+            for (LiKuResourcePool pool : poolList) {
+                listSum = listSum.add(BigDecimal.valueOf(pool.getLengthOfMetre()));
+            }
+            if (listSum.compareTo(currMin) < 0) {
+                currMin = listSum;
+                returnList = poolList;
+//                returnList.clear();
+//                returnList.addAll(detailsList);
             }
-            System.out.println(listNum+":"+str);
-        }*/
+        }
+
 
         return returnList;
     }
@@ -66,8 +92,6 @@ public class OptimalUtil {
      */
     public void solve(int index, double sum, List<MaterialReportDetails> curr, double total, List<MaterialReportDetails> elements ){
         //如果找到元素组合的和与待比对值一样,则不往下继续查找
-        String dictValue = DictUtils.getDictValue("maxWaste", "maximum_waste", "");
-        maxiNun = new BigDecimal(dictValue);
         if(getEqual == true){
             return;
         }
@@ -82,21 +106,72 @@ public class OptimalUtil {
             return;
         }
         MaterialReportDetails next = elements.get(index);
+        //处理单位不同,所有都以米作为单位计算
+        Double nextNeed = next.getLengthOfMetre();
+
         index++;
         //如果将当前值加上已有元素组合的值等于待比对值,得到结果
-        if((sum+next.getTotal())==total){
+        if((sum+nextNeed)==total){
             curr.add(next);
             result = new ArrayList<>();
             result.add(curr);
             getEqual = true;
         //如果将当前值加上已有元素组合的值大于待比对值,则不考虑这种组合的后续可能性
-        }else if((sum+next.getTotal()) > total){
+        }else if((sum+nextNeed) > total){
             solve(index,sum,curr,total,elements);
-        }else if((sum+next.getTotal()) < total){
+        }else if((sum+nextNeed) < total){
             List newCurr = new ArrayList(curr);
             newCurr.add(next);
-            solve(index,sum+next.getTotal(),newCurr,total,elements);
+            solve(index,sum+nextNeed,newCurr,total,elements);
             solve(index,sum,curr,total,elements);
         }
     }
+
+    /**
+     *
+     * @param index 当前集合下标
+     * @param sum   当前组合元素和
+     * @param curr  当前组合元素集合
+     * @param total 待比对的值
+     * @param elements 所有元素集合
+     */
+    public void solveReverse(int index, double sum, List<LiKuResourcePool> curr, double total, List<LiKuResourcePool> elements ){
+        //如果找到元素组合的和与待比对值一样,则不往下继续查找
+        if(getEqual == true){
+            return;
+        }
+        //走到这一步,说明总和比total少,不放入
+        if(index == elements.size()){
+            return;
+        }
+        LiKuResourcePool next = elements.get(index);
+        //处理单位不同,所有都以米作为单位计算
+        Double cableLength = next.getLengthOfMetre();
+
+        index++;
+        //如果将当前值加上已有元素组合的值等于待比对值,得到结果
+        if((sum+cableLength)==total){
+            curr.add(next);
+            resultReverse = new ArrayList<>();
+            resultReverse.add(curr);
+            getEqual = true;
+            //如果将当前值加上已有元素组合的值大于待比对值,则不考虑这种组合的后续可能性
+        }else if((sum+cableLength) > total){
+            BigDecimal bigSum = BigDecimal.valueOf(sum);
+            BigDecimal bigLength = BigDecimal.valueOf(cableLength);
+            BigDecimal bigTotal = BigDecimal.valueOf(total);
+            BigDecimal subtract = bigSum.add(bigLength).subtract(bigTotal).setScale(2,BigDecimal.ROUND_HALF_UP);
+            if(subtract.compareTo(maxiNunReverse)<=0){
+                curr.add(next);
+                resultReverse.add(curr);
+            }
+            //由于资源池是由小到大排序,所以后面的一定不会比这条更接近最优解,则下面的代码不需要
+//            solveReverse(index,sum,curr,total,elements);
+        }else if((sum+cableLength) < total){
+            List newCurr = new ArrayList(curr);
+            newCurr.add(next);
+            solveReverse(index,sum+cableLength,newCurr,total,elements);
+            solveReverse(index,sum,curr,total,elements);
+        }
+    }
 }

+ 42 - 35
src/main/java/com/jeeplus/modules/sg/balancedlibrary/liKuResourcePool/web/LiKuResourcePoolController.java

@@ -8,7 +8,7 @@ import com.jeeplus.common.json.AjaxJson;
 import com.jeeplus.common.utils.DateUtils;
 import com.jeeplus.common.utils.StringUtils;
 import com.jeeplus.common.utils.excel.ExportExcel;
-import com.jeeplus.common.utils.excel.ImportExcel;
+import com.jeeplus.modules.sg.balancedlibrary.liKuResourcePool.utils.ImportUtil;
 import com.jeeplus.core.persistence.Page;
 import com.jeeplus.core.web.BaseController;
 import com.jeeplus.modules.sg.balancedlibrary.liKuResourcePool.entity.LiKuResourcePool;
@@ -176,47 +176,54 @@ public class LiKuResourcePoolController extends BaseController {
 		String unit = "";
 		String area = "";
 		try {
-			ImportExcel ei = new ImportExcel(file, 0, 0);
-			List<LiKuResourcePool> list = new ArrayList<>();
-			int lastDataRowNum = ei.getLastDataRowNum();
-			for (int i = 1; i <= lastDataRowNum; i++) {
-				LiKuResourcePool pool = new LiKuResourcePool();
-				Row row = ei.getRow(i);
-				pool.setSerialNumber(String.valueOf(row.getCell(0)));
-				pool.setFactory(String.valueOf(row.getCell(1)));
-				pool.setBatch(String.valueOf(row.getCell(2)));
-				pool.setMaterialCode(String.valueOf(row.getCell(3)));
-				pool.setMaterialDescription(String.valueOf(row.getCell(4)));
-				pool.setUnitOfMeasurement(String.valueOf(row.getCell(5)));
-				pool.setInventoryAmount(Double.valueOf(String.valueOf(row.getCell(6))));
-				pool.setInventoryLocation(String.valueOf(row.getCell(7)));
-				pool.setInvLocation(String.valueOf(row.getCell(8)));
-				pool.setInvLocationDes(String.valueOf(row.getCell(9)));
-				pool.setSupplierName(String.valueOf(row.getCell(10)));
-				pool.setSpecialStock(String.valueOf(row.getCell(11)));
-				pool.setExtendedCoding(String.valueOf(row.getCell(12)));
-				pool.setExtendedDescription(String.valueOf(row.getCell(13)));
-				pool.setMeterNumber(String.valueOf(row.getCell(14)));
-				pool.setRingCage(String.valueOf(row.getCell(15)));
-				pool.setTerminalWarranty(String.valueOf(row.getCell(16)));
-				pool.setSpecialParameters(String.valueOf(row.getCell(17)));
-				pool.setRemarks(String.valueOf(row.getCell(18)));
-				pool.setDaysStorage(Double.valueOf(String.valueOf(row.getCell(19))).intValue());
-				pool.setMonthStorage(Double.valueOf(String.valueOf(row.getCell(20))).intValue());
-				pool.setIsExpansion(String.valueOf(row.getCell(21)));
-				//获取计量单位,判断是否是段长数据
-				unit = pool.getUnitOfMeasurement();
-				pool.setIsSectionLength(LiKuUtils.isTheUnitMeter(unit));
+			ImportUtil ei = new ImportUtil(file,0,0);
+			List<LiKuResourcePool> list = ei.getDataList(LiKuResourcePool.class);
+			for(LiKuResourcePool pool:list){
+				pool.setIsSectionLength(LiKuUtils.isTheUnitMeter(pool.getUnitOfMeasurement()));
 				//获取库存地描述,标记数据所属区域
 				pool.setWhereFrom(LiKuUtils.judgmentArea(pool.getInvLocation()));
 				pool.setRemaining(pool.getInventoryAmount());
 				pool.setNumberOfNiches(0.0);
-				list.add(pool);
 			}
+//			List<LiKuResourcePool> list = new ArrayList<>();
+//			int lastDataRowNum = ei.getLastDataRowNum();
+//			for (int i = 1; i <= lastDataRowNum; i++) {
+//				LiKuResourcePool pool = new LiKuResourcePool();
+//				Row row = ei.getRow(i);
+//				pool.setSerialNumber(String.valueOf(row.getCell(0)));
+//				pool.setFactory(String.valueOf(row.getCell(1)));
+//				pool.setBatch(String.valueOf(row.getCell(2)));
+//				pool.setMaterialCode(row.getCell(3).getStringCellValue());
+//				pool.setMaterialDescription(String.valueOf(row.getCell(4)));
+//				pool.setUnitOfMeasurement(String.valueOf(row.getCell(5)));
+//				pool.setInventoryAmount(Double.valueOf(String.valueOf(row.getCell(6))));
+//				pool.setInventoryLocation(String.valueOf(row.getCell(7)));
+//				pool.setInvLocation(String.valueOf(row.getCell(8)));
+//				pool.setInvLocationDes(String.valueOf(row.getCell(9)));
+//				pool.setSupplierName(String.valueOf(row.getCell(10)));
+//				pool.setSpecialStock(String.valueOf(row.getCell(11)));
+//				pool.setExtendedCoding(String.valueOf(row.getCell(12)));
+//				pool.setExtendedDescription(String.valueOf(row.getCell(13)));
+//				pool.setMeterNumber(String.valueOf(row.getCell(14)));
+//				pool.setRingCage(String.valueOf(row.getCell(15)));
+//				pool.setTerminalWarranty(String.valueOf(row.getCell(16)));
+//				pool.setSpecialParameters(String.valueOf(row.getCell(17)));
+//				pool.setRemarks(String.valueOf(row.getCell(18)));
+//				pool.setDaysStorage(Double.valueOf(String.valueOf(row.getCell(19))).intValue());
+//				pool.setMonthStorage(Double.valueOf(String.valueOf(row.getCell(20))).intValue());
+//				pool.setIsExpansion(String.valueOf(row.getCell(21)));
+//				//获取计量单位,判断是否是段长数据
+//				unit = pool.getUnitOfMeasurement();
+//				pool.setIsSectionLength(LiKuUtils.isTheUnitMeter(unit));
+//				//获取库存地描述,标记数据所属区域
+//				pool.setWhereFrom(LiKuUtils.judgmentArea(pool.getInvLocation()));
+//				pool.setRemaining(pool.getInventoryAmount());
+//				pool.setNumberOfNiches(0.0);
+//				list.add(pool);
+//			}
 			if (list.size() > 0) {
 				List<LiKuResourcePool> insertList = new ArrayList<>();
-				for (LiKuResourcePool pool :
-						list) {
+				for (LiKuResourcePool pool :list) {
 					Integer isSectionLength = pool.getIsSectionLength();
 					if (isSectionLength.compareTo(LiKuUtils.YES) == 0) {
 						String lengthOfCable = pool.getMeterNumber();

+ 172 - 0
src/main/java/com/jeeplus/modules/sg/balancedlibrary/materialReportDetails/entity/LikuDetail.java

@@ -0,0 +1,172 @@
+package com.jeeplus.modules.sg.balancedlibrary.materialReportDetails.entity;
+
+/**
+ * 利库明细
+ */
+public class LikuDetail {
+
+
+
+    private String reportingArea;//上报地区
+    private String nameOfReserve;//物料申请所属项目
+    private String materialCode;//物料编码
+    private String materialName;//物料名称
+    private String extendedCoding;//扩展编码
+    private String extendedDescription;//扩展描述
+    private String unit;//单位
+    private Double total;//总量
+    private String unitWeight;//单重
+    private String totalWeight;//总重
+    private String supplied;//甲乙供
+    private Double numberOfNiches;//利库数量
+    private Double numberOfApplications;//申请数量
+    private String comparisonType;//利库类型
+    private String batch;//利库批次号
+    private String warehouse;//利库仓库
+    private Double numberNiches;//利库明细数量
+    private Integer segBelongs;//利库所属段
+
+    public String getNameOfReserve() {
+        return nameOfReserve;
+    }
+
+    public void setNameOfReserve(String nameOfReserve) {
+        this.nameOfReserve = nameOfReserve;
+    }
+
+    public String getMaterialCode() {
+        return materialCode;
+    }
+
+    public void setMaterialCode(String materialCode) {
+        this.materialCode = materialCode;
+    }
+
+    public String getComparisonType() {
+        return comparisonType;
+    }
+
+    public void setComparisonType(String comparisonType) {
+        this.comparisonType = comparisonType;
+    }
+
+    public String getBatch() {
+        return batch;
+    }
+
+    public void setBatch(String batch) {
+        this.batch = batch;
+    }
+
+    public String getWarehouse() {
+        return warehouse;
+    }
+
+    public void setWarehouse(String warehouse) {
+        this.warehouse = warehouse;
+    }
+
+    public Double getNumberNiches() {
+        return numberNiches;
+    }
+
+    public void setNumberNiches(Double numberNiches) {
+        this.numberNiches = numberNiches;
+    }
+
+    public Integer getSegBelongs() {
+        return segBelongs;
+    }
+
+    public void setSegBelongs(Integer segBelongs) {
+        this.segBelongs = segBelongs;
+    }
+
+    public String getReportingArea() {
+        return reportingArea;
+    }
+
+    public void setReportingArea(String reportingArea) {
+        this.reportingArea = reportingArea;
+    }
+
+    public String getMaterialName() {
+        return materialName;
+    }
+
+    public void setMaterialName(String materialName) {
+        this.materialName = materialName;
+    }
+
+    public String getExtendedCoding() {
+        return extendedCoding;
+    }
+
+    public void setExtendedCoding(String extendedCoding) {
+        this.extendedCoding = extendedCoding;
+    }
+
+    public String getExtendedDescription() {
+        return extendedDescription;
+    }
+
+    public void setExtendedDescription(String extendedDescription) {
+        this.extendedDescription = extendedDescription;
+    }
+
+    public String getUnit() {
+        return unit;
+    }
+
+    public void setUnit(String unit) {
+        this.unit = unit;
+    }
+
+    public Double getTotal() {
+        return total;
+    }
+
+    public void setTotal(Double total) {
+        this.total = total;
+    }
+
+    public String getUnitWeight() {
+        return unitWeight;
+    }
+
+    public void setUnitWeight(String unitWeight) {
+        this.unitWeight = unitWeight;
+    }
+
+    public String getTotalWeight() {
+        return totalWeight;
+    }
+
+    public void setTotalWeight(String totalWeight) {
+        this.totalWeight = totalWeight;
+    }
+
+    public String getSupplied() {
+        return supplied;
+    }
+
+    public void setSupplied(String supplied) {
+        this.supplied = supplied;
+    }
+
+    public Double getNumberOfNiches() {
+        return numberOfNiches;
+    }
+
+    public void setNumberOfNiches(Double numberOfNiches) {
+        this.numberOfNiches = numberOfNiches;
+    }
+
+    public Double getNumberOfApplications() {
+        return numberOfApplications;
+    }
+
+    public void setNumberOfApplications(Double numberOfApplications) {
+        this.numberOfApplications = numberOfApplications;
+    }
+}

+ 8 - 0
src/main/java/com/jeeplus/modules/sg/balancedlibrary/materialReportDetails/entity/MaterialReportDetails.java

@@ -184,7 +184,15 @@ public class MaterialReportDetails extends DataEntity<MaterialReportDetails> {
      * */
     private String numberOfConLocal;
 
+    private Double lengthOfMetre;//段长物资的长度(以米为单位)
 
+    public Double getLengthOfMetre() {
+        return lengthOfMetre;
+    }
+
+    public void setLengthOfMetre(Double lengthOfMetre) {
+        this.lengthOfMetre = lengthOfMetre;
+    }
 
     @ExcelField(title = "上报地区", align = 2, sort = 1)
     public String getReportingArea() {

+ 23 - 0
src/main/java/com/jeeplus/modules/sg/balancedlibrary/materialReportDetails/mapper/CompareHistoryMapper.java

@@ -0,0 +1,23 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.sg.balancedlibrary.materialReportDetails.mapper;
+
+import com.jeeplus.core.persistence.BaseMapper;
+import com.jeeplus.core.persistence.annotation.MyBatisMapper;
+import com.jeeplus.modules.sg.balancedlibrary.materialReportDetails.entity.CompareHistory;
+import com.jeeplus.modules.sg.balancedlibrary.materialReportDetails.entity.MaterialReportDetails;
+
+import java.util.List;
+
+/**
+ * 物资上报明细MAPPER接口
+ * @author enford
+ * @version 1.0
+ */
+@MyBatisMapper
+public interface CompareHistoryMapper extends BaseMapper<CompareHistory> {
+    void insertList(List<CompareHistory> list);
+
+    void delAll();
+}

+ 3 - 0
src/main/java/com/jeeplus/modules/sg/balancedlibrary/materialReportDetails/mapper/MaterialReportDetailsMapper.java

@@ -6,6 +6,7 @@ package com.jeeplus.modules.sg.balancedlibrary.materialReportDetails.mapper;
 import com.jeeplus.core.persistence.BaseMapper;
 import com.jeeplus.core.persistence.annotation.MyBatisMapper;
 import com.jeeplus.modules.sg.balancedlibrary.liKuResourcePool.entity.LiKuResourcePool;
+import com.jeeplus.modules.sg.balancedlibrary.materialReportDetails.entity.LikuDetail;
 import com.jeeplus.modules.sg.balancedlibrary.materialReportDetails.entity.MaterialReportDetails;
 import org.apache.ibatis.annotations.Param;
 
@@ -21,4 +22,6 @@ public interface MaterialReportDetailsMapper extends BaseMapper<MaterialReportDe
     void insertList(List<MaterialReportDetails> list);
 
     void delAll();
+
+    List<LikuDetail>  getLikuDetails(MaterialReportDetails report);
 }

+ 37 - 0
src/main/java/com/jeeplus/modules/sg/balancedlibrary/materialReportDetails/mapper/xml/CompareHistoryMapper.xml

@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.jeeplus.modules.sg.balancedlibrary.materialReportDetails.mapper.CompareHistoryMapper">
+	<sql id="resourceColumns">
+
+	</sql>
+
+	<sql id="leftJoins">
+		LEFT JOIN sys_office office ON office.id = a.office_id
+		LEFT JOIN sys_user tuser ON tuser.id = a.user_id
+	</sql>
+	<delete id="delAll">
+		truncate table bla_compare_history
+	</delete>
+
+
+    <insert id="insertList">
+		insert into bla_compare_history(
+			liku_id,
+			material_id,
+			number_niches,
+			comparison_type
+		)VALUES
+		<foreach collection="list" item="item" index="index" separator=",">
+			(
+			#{item.liKuId},
+			#{item.materialId},
+			#{item.numberNiches},
+			#{item.comparisonType}
+			)
+		</foreach>
+	</insert>
+
+
+
+
+</mapper>

+ 64 - 2
src/main/java/com/jeeplus/modules/sg/balancedlibrary/materialReportDetails/mapper/xml/MaterialReportDetailsMapper.xml

@@ -57,7 +57,7 @@
 	<select id="get" resultType="MaterialReportDetails" >
 		SELECT
 			<include refid="resourceColumns"/>
-		FROM bla_resource_pool a
+		FROM bla_material_report a
 		WHERE a.id = #{id}
 	</select>
 
@@ -67,6 +67,20 @@
 		FROM bla_material_report a
 		<where>
 			a.del_flag = #{DEL_FLAG_NORMAL}
+			<if test="nameOfReserve != null and nameOfReserve != ''">
+				and a.nameOfReserve like concat('%',#{nameOfReserve},'%')
+			</if>
+			<if test="materialCode != null and materialCode != ''">
+				AND a.materialCode like concat('%',#{materialCode},'%')
+			</if>
+			<if test="numberOfNiches != null">
+				<if test="numberOfNiches == 0">
+					AND a.numberOfNiches = 0
+				</if>
+				<if test="numberOfNiches == 1">
+					AND a.numberOfNiches >0
+				</if>
+			</if>
 			${dataScope}
 		</where>
 		<choose>
@@ -74,7 +88,7 @@
 				ORDER BY ${page.orderBy}
 			</when>
 			<otherwise>
-				ORDER BY a.id asc
+				ORDER BY a.reportingArea,a.nameOfReserve,a.materialCode,a.extendedCoding
 			</otherwise>
 		</choose>
 	</select>
@@ -236,4 +250,52 @@
 		select * FROM bla_resource_pool  where ${propertyName} = '${value}'
 	</select>
 
+
+	<select id="getLikuDetails" resultType="com.jeeplus.modules.sg.balancedlibrary.materialReportDetails.entity.LikuDetail" >
+		select
+		r.reportingArea as "reportingArea",
+		r.nameOfReserve as "nameOfReserve",
+		r.materialCode as "materialCode",
+		r.materialName as "materialName",
+		r.extendedCoding as "extendedCoding",
+		r.extendedDescription as "extendedDescription",
+		r.unit as "unit",
+		r.total as "total",
+		r.unitWeight as "unitWeight",
+		r.totalWeight as "totalWeight",
+		r.supplied as "supplied",
+		r.numberOfNiches as "numberOfNiches",
+		r.numberOfApplications as "numberOfApplications",
+		h.comparison_type as "comparisonType",
+		p.batch,
+		CONCAT(p.invLocation,'-',SUBSTRING(p.invLocationDes,1,2)) as "warehouse",
+		h.number_niches as "numberNiches",
+		p.segBelongs
+
+
+		from bla_compare_history h
+		left join bla_material_report r on r.id = h.material_id
+		left join bla_resource_pool p on h.liku_id = p.id
+		where
+			r.id is not null
+			<if test="id != null and id != ''">
+				AND r.id = #{id}
+			</if>
+			<if test="nameOfReserve != null and nameOfReserve != ''">
+				and r.nameOfReserve like concat('%',#{nameOfReserve},'%')
+			</if>
+			<if test="materialCode != null and materialCode != ''">
+				AND r.materialCode like concat('%',#{materialCode},'%')
+			</if>
+			<if test="numberOfNiches != null">
+				<if test="numberOfNiches == 0">
+					AND r.numberOfNiches = 0
+				</if>
+				<if test="numberOfNiches == 1">
+					AND r.numberOfNiches >0
+				</if>
+			</if>
+		order by r.reportingArea,r.nameOfReserve,r.materialCode,r.extendedCoding
+	</select>
+
 </mapper>

+ 48 - 0
src/main/java/com/jeeplus/modules/sg/balancedlibrary/materialReportDetails/service/CompareHistoryService.java

@@ -0,0 +1,48 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.sg.balancedlibrary.materialReportDetails.service;
+
+import com.jeeplus.core.persistence.Page;
+import com.jeeplus.core.service.CrudService;
+import com.jeeplus.modules.sg.balancedlibrary.materialReportDetails.entity.CompareHistory;
+import com.jeeplus.modules.sg.balancedlibrary.materialReportDetails.entity.MaterialReportDetails;
+import com.jeeplus.modules.sg.balancedlibrary.materialReportDetails.mapper.CompareHistoryMapper;
+import com.jeeplus.modules.sg.balancedlibrary.materialReportDetails.mapper.MaterialReportDetailsMapper;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+
+/**
+ * 物资上报明细Service
+ *
+ * @author enford
+ * @version 1.0
+ */
+@Service
+@Transactional(readOnly = true)
+public class CompareHistoryService extends CrudService<CompareHistoryMapper, CompareHistory> {
+
+
+	@Override
+	public List<CompareHistory> findList(CompareHistory entity) {
+		return super.findList(entity);
+	}
+
+	@Override
+	public Page<CompareHistory> findPage(Page<CompareHistory> page, CompareHistory entity) {
+		return super.findPage(page, entity);
+	}
+
+
+	@Transactional(readOnly = false)
+	public void insertList(List<CompareHistory> list) {
+		mapper.insertList(list);
+	}
+
+	@Transactional(readOnly = false)
+	public void delAll() {
+		mapper.delAll();
+	}
+}

+ 5 - 0
src/main/java/com/jeeplus/modules/sg/balancedlibrary/materialReportDetails/service/MaterialReportDetailsService.java

@@ -7,6 +7,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.materialReportDetails.entity.LikuDetail;
 import com.jeeplus.modules.sg.balancedlibrary.materialReportDetails.entity.MaterialReportDetails;
 import com.jeeplus.modules.sg.balancedlibrary.materialReportDetails.mapper.MaterialReportDetailsMapper;
 import org.springframework.stereotype.Service;
@@ -60,4 +61,8 @@ public class MaterialReportDetailsService extends CrudService<MaterialReportDeta
 	public void delAll() {
 		mapper.delAll();
 	}
+
+	public List<LikuDetail> getLikuDetails(MaterialReportDetails report){
+		return mapper.getLikuDetails(report);
+	}
 }

+ 525 - 0
src/main/java/com/jeeplus/modules/sg/balancedlibrary/materialReportDetails/utils/AdjustUtil.java

@@ -0,0 +1,525 @@
+package com.jeeplus.modules.sg.balancedlibrary.materialReportDetails.utils;
+
+import com.jeeplus.modules.sg.balancedlibrary.liKuResourcePool.entity.LiKuResourcePool;
+import com.jeeplus.modules.sg.balancedlibrary.liKuResourcePool.utils.OptimalUtil;
+import com.jeeplus.modules.sg.balancedlibrary.materialReportDetails.entity.CompareHistory;
+import com.jeeplus.modules.sg.balancedlibrary.materialReportDetails.entity.MaterialDetails;
+import com.jeeplus.modules.sg.balancedlibrary.materialReportDetails.entity.MaterialReportDetails;
+import com.jeeplus.modules.sg.balancedlibrary.replaceMaterial.entity.ReplaceMaterial;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+
+import static java.math.BigDecimal.ROUND_HALF_UP;
+
+public class AdjustUtil {
+
+    public static final String LOCAL_ADJUST = "本地利库"; //本地利库
+    public static final String SPAN_ADJUST = "跨区利库";    //跨区利库
+    public static final String REP_LOCAL_ADJUST = "本地以大代小利库"; //本地以大代小利库
+    public static final String REP_SPAN_ADJUST = "跨区以大代小利库"; //跨区以大代小利库
+    public static final String COMBINE_ADJUST = "合并利库"; //合并利库
+    public static final String REP_COMBINE_ADJUST = "以大代小合并利库"; //合并利库
+
+
+    /**
+     * 非段长利库
+     * @param reports
+     * @param pools
+     * @param compareList
+     * @param type
+     */
+    public static void nonSegAdjust(List<MaterialReportDetails> reports, List<LiKuResourcePool> pools, List<CompareHistory> compareList,String type){
+        for (MaterialReportDetails report:reports) {
+            String code = report.getMaterialCode();
+            String exCode = report.getExtendedCoding();
+            BigDecimal applyRemain = BigDecimal.valueOf(report.getNumberOfApplications());//剩余物资需求数量
+            BigDecimal applyTotal = BigDecimal.valueOf(report.getTotal());//总需求数量
+            BigDecimal applyLiku = BigDecimal.valueOf(report.getNumberOfNiches());//利库数量
+            //如果总需求数量等于利库数量则不利库
+            if (applyTotal.compareTo(applyLiku) == 0) {
+                continue;
+            }
+            for (LiKuResourcePool pool:pools) {
+                String poolCode = pool.getMaterialCode();
+                String poExCode = pool.getExtendedCoding();
+                BigDecimal poolRemain = BigDecimal.valueOf(pool.getRemaining());//利库剩余库存数量
+                BigDecimal poolLiku = BigDecimal.valueOf(pool.getNumberOfNiches());//利库数量
+                if (code.equals(poolCode) && exCode.equals(poExCode) && poolRemain.compareTo(BigDecimal.ZERO) != 0) {
+                    BigDecimal likuAmount;//本次利库数量
+                    if(applyRemain.compareTo(poolRemain) >= 0){
+                        likuAmount = poolRemain;
+                    }else {
+                        likuAmount = applyRemain;
+                    }
+                    //修改利库资源池的 剩余库存数量和利库数量
+                    pool.setRemaining(poolRemain.subtract(likuAmount).setScale(2, ROUND_HALF_UP).doubleValue());
+                    pool.setNumberOfNiches(poolLiku.add(likuAmount).setScale(2, ROUND_HALF_UP).doubleValue());
+                    //修改物料申请的 利库数量和剩余申请数量
+                    applyRemain = applyRemain.subtract(likuAmount).setScale(2, ROUND_HALF_UP);
+                    applyLiku = applyLiku.add(likuAmount).setScale(2, ROUND_HALF_UP);
+                    report.setNumberOfNiches(applyLiku.doubleValue());
+                    report.setNumberOfApplications(applyRemain.doubleValue());
+                    //记录利库详细信息
+                    CompareHistory compareHistory = new CompareHistory();
+                    compareHistory.setLiKuId(pool.getId());
+                    compareHistory.setMaterialId(report.getId());
+                    compareHistory.setComparisonType(type);
+                    compareHistory.setNumberNiches(likuAmount.doubleValue());
+
+                    compareList.add(compareHistory);
+                    if (report.getNumberOfNiches().compareTo(report.getTotal()) == 0) {
+                        break;
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * 非段长以大代小利库
+     * @param reports
+     * @param pools
+     * @param compareList
+     * @param type
+     * @param replaceList
+     */
+    public static void nonSegRepAdjust(List<MaterialReportDetails> reports, List<LiKuResourcePool> pools, List<CompareHistory> compareList, String type, List<ReplaceMaterial> replaceList){
+        for (MaterialReportDetails report:reports) {
+            String code = report.getMaterialCode();
+            String exCode = report.getExtendedCoding();
+            BigDecimal applyRemain = BigDecimal.valueOf(report.getNumberOfApplications());//剩余物资需求数量
+            BigDecimal applyTotal = BigDecimal.valueOf(report.getTotal());//总需求数量
+            BigDecimal applyLiku = BigDecimal.valueOf(report.getNumberOfNiches());//利库数量
+            //如果总需求数量等于利库数量则不利库
+            if (applyTotal.compareTo(applyLiku) == 0) {
+                continue;
+            }
+            //查找所有可以替代信息
+            List<ReplaceMaterial> usefulReplaces = new ArrayList<>();
+            for(ReplaceMaterial replace:replaceList){
+                if(code.equals(replace.getMaterialCode())&&exCode.equals(replace.getExtendedCoding())){
+                    usefulReplaces.add(replace);
+                }
+            }
+            //存在对应替换信息时才走后续流程
+            if(usefulReplaces.size()>0){
+                for(ReplaceMaterial replace:usefulReplaces){
+                    String codeRep = replace.getMaterialCodeRep();
+                    String exCodeRep = replace.getExtendedCodingRep();
+
+                    for (LiKuResourcePool pool:pools) {
+                        String poolCode = pool.getMaterialCode();
+                        String poExCode = pool.getExtendedCoding();
+                        BigDecimal poolRemain = BigDecimal.valueOf(pool.getRemaining());//利库剩余库存数量
+                        BigDecimal poolLiku = BigDecimal.valueOf(pool.getNumberOfNiches());//利库数量
+                        if (codeRep.equals(poolCode) && exCodeRep.equals(poExCode) && poolRemain.compareTo(BigDecimal.ZERO) != 0) {
+                            BigDecimal likuAmount;//本次利库数量
+                            if(applyRemain.compareTo(poolRemain) >= 0){
+                                likuAmount = poolRemain;
+                            }else {
+                                likuAmount = applyRemain;
+                            }
+                            //修改利库资源池的 剩余库存数量和利库数量
+                            pool.setRemaining(poolRemain.subtract(likuAmount).setScale(2, ROUND_HALF_UP).doubleValue());
+                            pool.setNumberOfNiches(poolLiku.add(likuAmount).setScale(2, ROUND_HALF_UP).doubleValue());
+                            //修改物料申请的 利库数量和剩余申请数量
+                            applyRemain = applyRemain.subtract(likuAmount).setScale(2, ROUND_HALF_UP);
+                            applyLiku = applyLiku.add(likuAmount).setScale(2, ROUND_HALF_UP);
+                            report.setNumberOfNiches(applyLiku.doubleValue());
+                            report.setNumberOfApplications(applyRemain.doubleValue());
+                            //记录利库详细信息
+                            CompareHistory compareHistory = new CompareHistory();
+                            compareHistory.setLiKuId(pool.getId());
+                            compareHistory.setMaterialId(report.getId());
+                            compareHistory.setComparisonType(type);
+                            compareHistory.setNumberNiches(likuAmount.doubleValue());
+                            compareList.add(compareHistory);
+                            //如果利库完成退出这个替换循环
+                            if (report.getNumberOfNiches().compareTo(report.getTotal()) == 0) {
+                                break;
+                            }
+                        }
+                    }
+                    //如果利库完成退出整个替换循环
+                    if (report.getNumberOfNiches().compareTo(report.getTotal()) == 0) {
+                        break;
+                    }
+
+                }
+            }
+
+        }
+    }
+
+    /**
+     * 段长利库
+     * @param reports
+     * @param pools
+     * @param compareList
+     * @param type
+     */
+    public static void segAdjust(List<MaterialReportDetails> reports, List<LiKuResourcePool> pools, List<CompareHistory> compareList,String type){
+        for (LiKuResourcePool pool:pools) {
+            if (pool.getCompleteLiKu() == 1) {
+                continue;
+            }
+            String poolCode = pool.getMaterialCode();
+            String poExCode = pool.getExtendedCoding();
+
+            //通过物料编码,扩展编码,是否完成利库,获取符合当前利库线段数据的项目集合数据
+            List<MaterialReportDetails> usefulReportList = Calculation(reports, poolCode, poExCode);
+            if(usefulReportList.size()>0){
+                //都是以米计算
+                String unit = pool.getUnitOfMeasurement();
+                Double lengthOfCable = pool.getLengthOfCable();
+                if(unit.contains("千米")){
+                    lengthOfCable = lengthOfCable*1000;
+                }
+                OptimalUtil optimalUtil = new OptimalUtil();
+                //返回最优解
+                List<MaterialReportDetails> bestChose = optimalUtil.getOptimal(lengthOfCable,usefulReportList);
+                //计算最优解
+                if (bestChose.size() > 0) {
+                    BigDecimal totalLiku = BigDecimal.valueOf(0.0);
+                    for (MaterialReportDetails report:bestChose) {
+                        //修改物料的 待申报数量和利库数量
+                        report.setNumberOfApplications(0.0);
+                        report.setNumberOfNiches(report.getTotal());
+                        //新增调整记录
+                        CompareHistory compareHistory = new CompareHistory();
+                        compareHistory.setLiKuId(pool.getId());
+                        compareHistory.setMaterialId(report.getId());
+                        compareHistory.setComparisonType(type);
+                        compareHistory.setNumberNiches(report.getTotal());
+                        compareList.add(compareHistory);
+                        //计算资源池记录利库数量
+                        totalLiku  = totalLiku.add(BigDecimal.valueOf(report.getTotal()));
+                    }
+                    BigDecimal poolLength = BigDecimal.valueOf(pool.getLengthOfCable());
+                    BigDecimal remainLength = poolLength.subtract(totalLiku).setScale(2, ROUND_HALF_UP);
+                    //存在最优解,当前利库信息使用,变更状态
+                    pool.setNumberOfNiches(totalLiku.doubleValue());
+                    pool.setRemaining(remainLength.doubleValue());
+                    pool.setCompleteLiKu(1);
+                }
+            }
+
+        }
+    }
+
+    /**
+     * 以上报物资为主的段长利库
+     * @param reports
+     * @param pools
+     * @param compareList
+     * @param type
+     */
+    public static void segAdjustReverse(List<MaterialReportDetails> reports, List<LiKuResourcePool> pools, List<CompareHistory> compareList,String type){
+        for (MaterialReportDetails report:reports) {
+            Double total = report.getTotal();
+            Double niches = report.getNumberOfNiches();
+            if (niches>=total) {
+                continue;
+            }
+            String code = report.getMaterialCode();
+            String exCode = report.getExtendedCoding();
+
+            //通过物料编码,扩展编码,是否完成利库,获取符合当前利库线段数据的项目集合数据
+            List<LiKuResourcePool> usefulLikuList = CalculationReverse(pools, code, exCode);
+            if(usefulLikuList.size()>0){
+                //都是以米计算
+                String unit = report.getUnit();
+                double totalMetre = total.doubleValue();
+                if(unit.contains("千米")){
+                    totalMetre = totalMetre*1000;
+                }
+                OptimalUtil optimalUtil = new OptimalUtil();
+                //返回最优解
+                List<LiKuResourcePool> bestChose = optimalUtil.getOptimalReverse(totalMetre,usefulLikuList);
+                //计算最优解
+                if (bestChose.size() > 0) {
+                    BigDecimal totalLiku = BigDecimal.valueOf(0.0);
+                    for (LiKuResourcePool pool:bestChose) {
+                        //修改利库的剩余数量、利库数量和利库状态
+                        pool.setRemaining(0.0);
+                        pool.setNumberOfNiches(pool.getLengthOfCable());
+                        pool.setCompleteLiKu(1);
+
+                        report.setNumberOfApplications(0.0);
+                        report.setNumberOfNiches(report.getTotal());
+                        //新增调整记录
+                        CompareHistory compareHistory = new CompareHistory();
+                        compareHistory.setLiKuId(pool.getId());
+                        compareHistory.setMaterialId(report.getId());
+                        compareHistory.setComparisonType(type);
+                        compareHistory.setNumberNiches(pool.getLengthOfCable());
+                        compareList.add(compareHistory);
+                        //计算记录利库总量
+                        totalLiku  = totalLiku.add(BigDecimal.valueOf(pool.getLengthOfCable()));
+                    }
+                    report.setNumberOfApplications(0.0);
+                    //这里利库数量有可能超过总量
+                    report.setNumberOfNiches(totalLiku.doubleValue());
+                }
+            }
+
+        }
+    }
+
+    /**
+     * 段长以大代小利库
+     * @param reports
+     * @param pools
+     * @param compareList
+     * @param type
+     * @param replaceList
+     */
+    public static void segRepAdjust(List<MaterialReportDetails> reports, List<LiKuResourcePool> pools, List<CompareHistory> compareList,String type,List<ReplaceMaterial> replaceList){
+        for (LiKuResourcePool pool:pools) {
+            if (pool.getCompleteLiKu() == 1) {
+                continue;
+            }
+            String poolCode = pool.getMaterialCode();
+            String poExCode = pool.getExtendedCoding();
+            //通过物料编码,扩展编码,是否完成利库,获取符合当前利库线段数据的项目集合数据
+            List<MaterialReportDetails> usefulReportList = CalculationRep(reports, poolCode, poExCode,replaceList);
+            if(usefulReportList.size()>0){
+                //都是以米计算
+                String poolUnit = pool.getUnitOfMeasurement();
+                Double lengthOfCable = pool.getLengthOfCable();
+                if(poolUnit.contains("千米")){
+                    lengthOfCable = lengthOfCable*1000;
+                }
+                OptimalUtil optimalUtil = new OptimalUtil();
+                //返回最优解
+                List<MaterialReportDetails> bestChose = optimalUtil.getOptimal(lengthOfCable,usefulReportList);
+                //计算最优解
+                if (bestChose.size() > 0) {
+                    BigDecimal totalLiku = BigDecimal.valueOf(0.0);
+                    for (MaterialReportDetails report:bestChose) {
+                        //修改物料的 待申报数量和利库数量
+                        report.setNumberOfApplications(0.0);
+                        report.setNumberOfNiches(report.getTotal());
+                        //新增调整记录
+                        CompareHistory compareHistory = new CompareHistory();
+                        compareHistory.setLiKuId(pool.getId());
+                        compareHistory.setMaterialId(report.getId());
+                        compareHistory.setComparisonType(type);
+                        compareHistory.setNumberNiches(report.getTotal());
+                        compareList.add(compareHistory);
+                        //这里处理资源池记录和物资申请记录单位不一致情况
+                        String reportUnit = report.getUnit();
+                        Double poolLiku = report.getTotal();//资源池在该物料身上的利库数量
+                        if(poolUnit.trim().equals("千米")&&reportUnit.trim().equals("米")){
+                            poolLiku = poolLiku/1000;
+                        }
+                        if(poolUnit.trim().equals("米")&&reportUnit.trim().equals("千米")){
+                            poolLiku = poolLiku*1000;
+                        }
+                        //计算资源池记录利库数量
+                        totalLiku  = totalLiku.add(BigDecimal.valueOf(poolLiku));
+                    }
+                    BigDecimal poolLength = BigDecimal.valueOf(pool.getLengthOfCable());
+                    BigDecimal remainLength = poolLength.subtract(totalLiku).setScale(2, ROUND_HALF_UP);
+                    //存在最优解,当前利库信息使用,变更状态
+                    pool.setNumberOfNiches(totalLiku.doubleValue());
+                    pool.setRemaining(remainLength.doubleValue());
+                    pool.setCompleteLiKu(1);
+                }
+            }
+
+        }
+    }
+
+
+    /**
+     * 以上报物资为主的段长以大代小利库
+     * @param reports
+     * @param pools
+     * @param compareList
+     * @param type
+     * @param replaceList
+     */
+    public static void segRepAdjustReverse(List<MaterialReportDetails> reports, List<LiKuResourcePool> pools, List<CompareHistory> compareList,String type,List<ReplaceMaterial> replaceList){
+        for (MaterialReportDetails report:reports) {
+            Double total = report.getTotal();
+            Double niches = report.getNumberOfNiches();
+            if (niches>=total) {
+                continue;
+            }
+            String code = report.getMaterialCode();
+            String exCode = report.getExtendedCoding();
+
+
+            //通过物料编码,扩展编码,是否完成利库,获取符合当前利库线段数据的项目集合数据
+            List<LiKuResourcePool> usefulPoolList = CalculationRepReverse(pools, code, exCode,replaceList);
+            if(usefulPoolList.size()>0){
+                //都是以米计算
+                String unit = report.getUnit();
+                double totalMetre = total.doubleValue();
+                if(unit.contains("千米")){
+                    totalMetre = totalMetre*1000;
+                }
+                OptimalUtil optimalUtil = new OptimalUtil();
+                //返回最优解
+                List<LiKuResourcePool> bestChose = optimalUtil.getOptimalReverse(totalMetre,usefulPoolList);
+                //计算最优解
+                if (bestChose.size() > 0) {
+                    BigDecimal totalLiku = BigDecimal.valueOf(0.0);
+                    for (LiKuResourcePool pool:bestChose) {
+                        pool.setNumberOfNiches(pool.getLengthOfCable());
+                        pool.setRemaining(0.0);
+                        pool.setCompleteLiKu(1);
+                        //新增调整记录
+                        CompareHistory compareHistory = new CompareHistory();
+                        compareHistory.setLiKuId(pool.getId());
+                        compareHistory.setMaterialId(report.getId());
+                        compareHistory.setComparisonType(type);
+                        compareHistory.setNumberNiches(pool.getLengthOfCable());
+                        compareList.add(compareHistory);
+                        //计算资源池记录利库数量(米)
+                        totalLiku  = totalLiku.add(BigDecimal.valueOf(pool.getLengthOfMetre()));
+                    }
+                    report.setNumberOfApplications(0.0);
+                    if(unit.contains("千米")){
+                        report.setNumberOfNiches(totalLiku.doubleValue()/1000);
+                    }else{
+                        report.setNumberOfNiches(totalLiku.doubleValue());
+                    }
+                }
+            }
+
+        }
+    }
+
+
+    /***
+     * 通过项目编码,扩展编码,查询在物资上报中,符合利库数据集合,且这些上报数据都应未利库
+     * */
+    private static List<MaterialReportDetails> Calculation(List<MaterialReportDetails> segmentList, String poolCode, String poExCode) {
+        List<MaterialReportDetails> returnList = new ArrayList<>();
+        for (MaterialReportDetails details:segmentList) {
+            String code = details.getMaterialCode();
+            String exCode = details.getExtendedCoding();
+            //物资需求数量
+            BigDecimal total = BigDecimal.valueOf(details.getTotal());
+            //利库数量
+            BigDecimal numberOfNiches = BigDecimal.valueOf(details.getNumberOfNiches());
+            if (poolCode.equals(code) && poExCode.equals(exCode) && total.compareTo(numberOfNiches) > 0) {
+                //对可用的物资做米和千米的处理
+                String unit = details.getUnit();
+                if(unit.contains("千米")){
+                    details.setLengthOfMetre(details.getTotal()*1000);
+                }else{
+                    details.setLengthOfMetre(details.getTotal());
+                }
+                returnList.add(details);
+            }
+        }
+        return returnList;
+    }
+
+    /***
+     * 以上报物资为主查找利库中可用数据
+     * */
+    private static List<LiKuResourcePool> CalculationReverse(List<LiKuResourcePool> poolList, String code, String exCode) {
+        List<LiKuResourcePool> returnList = new ArrayList<>();
+        for (LiKuResourcePool pool:poolList) {
+            String poolCode = pool.getMaterialCode();
+            String poolExCode = pool.getExtendedCoding();
+            Integer likuStatus = pool.getCompleteLiKu();
+            //利库未完成
+            if (code.equals(poolCode) && exCode.equals(poolExCode) && likuStatus!=1) {
+                //对可用的物资做米和千米的处理
+                String unit = pool.getUnitOfMeasurement();
+                if(unit.contains("千米")){
+                    pool.setLengthOfMetre(pool.getLengthOfCable()*1000);
+                }else{
+                    pool.setLengthOfMetre(pool.getLengthOfCable());
+                }
+                returnList.add(pool);
+            }
+        }
+        return returnList;
+    }
+
+    /***
+     * 通过项目编码,扩展编码,查询在物资上报中,符合利库替换数据集合,计算后续最优解-以大代小
+     * */
+    private static List<MaterialReportDetails> CalculationRep(List<MaterialReportDetails> reportList, String poolCode, String poExCode,List<ReplaceMaterial> replaceList) {
+        List<MaterialReportDetails> returnList = new ArrayList<>();
+
+        //查找所有可以替代信息
+        List<ReplaceMaterial> usefulReplaces = new ArrayList<>();
+        for(ReplaceMaterial replace:replaceList){
+            //不管何时一定是上报物资编码与replace中的编码匹配,利库编码与replace中的替代编码匹配
+            if(poolCode.equals(replace.getMaterialCodeRep())&&poExCode.equals(replace.getExtendedCodingRep())){
+                usefulReplaces.add(replace);
+            }
+        }
+        if(usefulReplaces.size()>0){
+            for(ReplaceMaterial replace:usefulReplaces){
+                String repCode = replace.getMaterialCode();
+                String repExCode = replace.getExtendedCoding();
+                for(MaterialReportDetails report:reportList){
+                    String code = report.getMaterialCode();
+                    String exCode = report.getExtendedCoding();
+                    BigDecimal totalNeed = BigDecimal.valueOf(report.getTotal());//物资需求数量
+                    BigDecimal likuNum = BigDecimal.valueOf(report.getNumberOfNiches());//利库数量
+                    if (repCode.equals(code) && repExCode.equals(exCode) && totalNeed.compareTo(likuNum) > 0) {
+                        //对可用的物资做米和千米的处理
+                        String unit = report.getUnit();
+                        if(unit.contains("千米")){
+                            report.setLengthOfMetre(report.getTotal()*1000);
+                        }else{
+                            report.setLengthOfMetre(report.getTotal());
+                        }
+                        returnList.add(report);
+                    }
+                }
+            }
+        }
+
+        return returnList;
+    }
+
+    /***
+     * 以上报物资为主,在利库资源池中查找可用的替换物资
+     * */
+    private static List<LiKuResourcePool> CalculationRepReverse(List<LiKuResourcePool> poolList, String code, String exCode,List<ReplaceMaterial> replaceList) {
+        List<LiKuResourcePool> returnList = new ArrayList<>();
+
+        //查找所有可以替代信息
+        List<ReplaceMaterial> usefulReplaces = new ArrayList<>();
+        for(ReplaceMaterial replace:replaceList){
+            if(code.equals(replace.getMaterialCode())&&exCode.equals(replace.getExtendedCoding())){
+                usefulReplaces.add(replace);
+            }
+        }
+        if(usefulReplaces.size()>0){
+            for(ReplaceMaterial replace:usefulReplaces){
+                String repCode = replace.getMaterialCodeRep();
+                String repExCode = replace.getExtendedCodingRep();
+                for(LiKuResourcePool pool:poolList){
+                    String poolCode = pool.getMaterialCode();
+                    String poolExCode = pool.getExtendedCoding();
+                    Integer likuStatus = pool.getCompleteLiKu();
+                    if (repCode.equals(poolCode) && repExCode.equals(poolExCode) && likuStatus!=1) {
+                        //对可用的物资做米和千米的处理
+                        String unit = pool.getUnitOfMeasurement();
+                        if(unit.contains("千米")){
+                            pool.setLengthOfMetre(pool.getLengthOfCable()*1000);
+                        }else{
+                            pool.setLengthOfMetre(pool.getLengthOfCable());
+                        }
+                        returnList.add(pool);
+                    }
+                }
+            }
+        }
+
+        return returnList;
+    }
+}

+ 226 - 0
src/main/java/com/jeeplus/modules/sg/balancedlibrary/materialReportDetails/utils/ExportUtil.java

@@ -0,0 +1,226 @@
+package com.jeeplus.modules.sg.balancedlibrary.materialReportDetails.utils;
+
+import com.jeeplus.common.utils.DateUtils;
+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 org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Font;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.xssf.usermodel.XSSFCellStyle;
+import org.apache.poi.xssf.usermodel.XSSFFont;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.*;
+import java.net.URLEncoder;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+
+public class ExportUtil {
+    private XSSFCellStyle style = null;
+
+    private XSSFCellStyle redStyle = null;
+
+    XSSFWorkbook workbook = null;
+
+    public ExportUtil(){
+        try {
+            String path = this.getClass().getResource("/").getPath() + "/freemarker/excelmodel/materialReport.xlsx";
+            File file = new File(path);
+            InputStream inputStream = new FileInputStream(file);// 将excel文件转为输入流
+            workbook = new XSSFWorkbook(inputStream);// 创建个workbook,
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+    }
+
+
+    /**
+     * 导出费用检查管理
+     * @param response
+     */
+    public void exportDetails(HttpServletResponse response, List<MaterialReportDetails> reportList, List<LikuDetail> likuList){
+        OutputStream outputStream = null;
+        try {
+            int rowNum = 2;
+            //处理利库汇总情况
+            Sheet sheet1 = workbook.getSheetAt(0);
+            if(reportList!=null&&reportList.size()>0){
+                for(int i=0;i<reportList.size();i++){
+                    MaterialReportDetails report = reportList.get(i);
+                    //当利库数量不为0时 标红
+                    Double likuAmount = report.getNumberOfNiches();
+                    int color = 0;
+                    if(likuAmount>0) color=1;
+
+                    Row row = sheet1.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); //申请数量
+
+
+                    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(getDouble(report.getNumberOfNiches()));
+                    cell12.setCellValue(getDouble(report.getNumberOfApplications()));
+                }
+            }
+            //利库明细情况
+            Sheet sheet2 = workbook.getSheetAt(1);
+            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()));
+                    }
+                    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()+"段");
+                    }
+
+                }
+            }
+
+            String fileName = "物资上报利库情况表" + DateUtils.getDate("yyyyMMddHHmmss") + ".xlsx";
+            String str = URLEncoder.encode(fileName, "UTF8");
+            response.setHeader("Content-Disposition", "attachment;filename="+str);
+            response.setContentType("application/vnd.ms-excel;charset=UTF-8");
+            outputStream = response.getOutputStream();
+            workbook.write(outputStream);
+            outputStream.flush();
+            outputStream.close();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+
+
+    /**
+     * 创建Cell对象 同时设置style
+     * @param workbook
+     * @param row
+     * @param num
+     * @param color 设置颜色 1:红色
+     * @return
+     */
+    Cell crateCell(XSSFWorkbook workbook,Row row, int num,int color){
+        Cell cell = row.createCell(num);
+        if(style == null){
+            style = workbook.createCellStyle();
+            style.setWrapText(true);
+            style.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);
+            style.setAlignment(XSSFCellStyle.ALIGN_CENTER);
+        }
+        if(redStyle == null){
+            redStyle = workbook.createCellStyle();
+            redStyle.setWrapText(true);
+            redStyle.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);
+            redStyle.setAlignment(XSSFCellStyle.ALIGN_CENTER);
+            XSSFFont font = workbook.createFont();
+            font.setColor(Font.COLOR_RED);
+            redStyle.setFont(font);
+        }
+        if(color==1){
+            cell.setCellStyle(redStyle);
+        }else{
+            cell.setCellStyle(style);
+        }
+        return cell;
+    }
+
+
+
+    Cell crateCellLeft(XSSFWorkbook workbook,Row row, int num){
+        Cell cell = row.createCell(num);
+        if(style == null){
+            style = workbook.createCellStyle();
+            style.setWrapText(true);
+        }
+        cell.setCellStyle(style);
+        return cell;
+    }
+
+    Double getDouble(Double num) {
+        Double returnDouble = 0.0;
+        if (null!=num) {
+            returnDouble = num;
+        }
+        return returnDouble;
+    }
+
+    String getString (String obj) {
+        String returnStr = "";
+        if (null!=obj) {
+            returnStr = obj;
+        }
+        return returnStr;
+    }
+
+}

+ 13 - 2
src/main/java/com/jeeplus/modules/sg/balancedlibrary/materialReportDetails/web/MaterialReportDetailsController.java

@@ -50,8 +50,8 @@ import static java.math.BigDecimal.ROUND_HALF_UP;
  * @author enford
  * @version 1.0
  */
-@Controller
-@RequestMapping(value = "${adminPath}/MaterialReportDetails")
+//@Controller
+//@RequestMapping(value = "${adminPath}/MaterialReportDetails")
 public class MaterialReportDetailsController extends BaseController {
 
     @Autowired
@@ -248,6 +248,7 @@ public class MaterialReportDetailsController extends BaseController {
                 bBSegmentList.sort(Comparator.comparing(MaterialReportDetails::getNameOfReserve));
                 for (MaterialReportDetails material :
                         bBSegmentList) {
+                    //设置初始利库数量为0,初始申请数量为物资的表格数量
                     material.setNumberOfNiches(0.0);
                     material.setNumberOfApplications(material.getTotal());
                 }
@@ -376,6 +377,7 @@ public class MaterialReportDetailsController extends BaseController {
             if (bBPoolList.size() > 0) {
                 for (LiKuResourcePool pool :
                         bBPoolList) {
+                    //设置标识利库中段长状态为 未完成利库 状态,单独设置状态因为无法根据数量判断,段长利库可能有剩余
                     pool.setCompleteLiKu(0);
                 }
                 poolSegSort(bBPoolList);
@@ -420,6 +422,7 @@ public class MaterialReportDetailsController extends BaseController {
                     BigDecimal all = BigDecimal.valueOf(details.getTotal());
                     //利库数量
                     BigDecimal numberOfNiches = BigDecimal.valueOf(details.getNumberOfNiches());
+                    //如果总需求数量等于利库数量则不利库
                     if (all.compareTo(numberOfNiches) == 0) {
                         continue;
                     }
@@ -6066,6 +6069,10 @@ public class MaterialReportDetailsController extends BaseController {
         return returnList;
     }
 
+    /**
+     * 利库非段长排序方法,排序依据 库存日、库存数量、批次号
+     * @param bBNonPoolList
+     */
     private void poolSort(List<LiKuResourcePool> bBNonPoolList) {
         Comparator<LiKuResourcePool> reversed = Comparator.comparing(LiKuResourcePool::getDaysStorage).reversed();
         Comparator<LiKuResourcePool> comparator = Comparator.comparing(LiKuResourcePool::getInventoryAmount).reversed();
@@ -6073,6 +6080,10 @@ public class MaterialReportDetailsController extends BaseController {
         bBNonPoolList.sort(reversed.thenComparing(comparator).thenComparing(poolComparator));
     }
 
+    /**
+     * 利库段长排序方法,排序依据 库存日、库存数量、批次号、具体段长
+     * @param bBNonPoolList
+     */
     private void poolSegSort(List<LiKuResourcePool> bBNonPoolList) {
         Comparator<LiKuResourcePool> reversed = Comparator.comparing(LiKuResourcePool::getDaysStorage).reversed();
         Comparator<LiKuResourcePool> comparator = Comparator.comparing(LiKuResourcePool::getInventoryAmount).reversed();

+ 906 - 0
src/main/java/com/jeeplus/modules/sg/balancedlibrary/materialReportDetails/web/MaterialReportDetailsControllerTest.java

@@ -0,0 +1,906 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.sg.balancedlibrary.materialReportDetails.web;
+
+import com.google.common.collect.Lists;
+import com.jeeplus.common.json.AjaxJson;
+import com.jeeplus.common.utils.DateUtils;
+import com.jeeplus.common.utils.StringUtils;
+import com.jeeplus.common.utils.excel.ExportExcel;
+import com.jeeplus.common.utils.excel.ImportExcel;
+import com.jeeplus.core.persistence.Page;
+import com.jeeplus.core.web.BaseController;
+import com.jeeplus.modules.sg.balancedlibrary.liKuResourcePool.entity.LiKuResourcePool;
+import com.jeeplus.modules.sg.balancedlibrary.liKuResourcePool.service.LiKuResourcePoolService;
+import com.jeeplus.modules.sg.balancedlibrary.liKuResourcePool.utils.LiKuUtils;
+import com.jeeplus.modules.sg.balancedlibrary.liKuResourcePool.utils.OptimalUtil;
+import com.jeeplus.modules.sg.balancedlibrary.materialReportDetails.entity.CompareHistory;
+import com.jeeplus.modules.sg.balancedlibrary.materialReportDetails.entity.LikuDetail;
+import com.jeeplus.modules.sg.balancedlibrary.materialReportDetails.entity.MaterialDetails;
+import com.jeeplus.modules.sg.balancedlibrary.materialReportDetails.entity.MaterialReportDetails;
+import com.jeeplus.modules.sg.balancedlibrary.materialReportDetails.service.CompareHistoryService;
+import com.jeeplus.modules.sg.balancedlibrary.materialReportDetails.service.MaterialReportDetailsService;
+import com.jeeplus.modules.sg.balancedlibrary.materialReportDetails.utils.AdjustUtil;
+import com.jeeplus.modules.sg.balancedlibrary.materialReportDetails.utils.ExportUtil;
+import com.jeeplus.modules.sg.balancedlibrary.replaceMaterial.entity.ReplaceMaterial;
+import com.jeeplus.modules.sg.balancedlibrary.replaceMaterial.service.ReplaceMaterialService;
+import com.jeeplus.modules.sg.managementcenter.materialproject.entity.MaterialProject;
+import org.apache.shiro.authz.annotation.Logical;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import java.math.BigDecimal;
+import java.util.*;
+
+import static java.math.BigDecimal.ROUND_HALF_UP;
+
+/**
+ * 物资上报明细Controller
+ *
+ * @author enford
+ * @version 1.0
+ */
+@Controller
+@RequestMapping(value = "${adminPath}/MaterialReportDetails")
+public class MaterialReportDetailsControllerTest extends BaseController {
+
+    @Autowired
+    private MaterialReportDetailsService service;
+
+    @Autowired
+    private LiKuResourcePoolService poolService;
+
+    @Autowired
+    private ReplaceMaterialService replaceMaterialService;
+
+    @Autowired
+    private CompareHistoryService compareHistoryService;
+
+    @ModelAttribute
+    public MaterialReportDetails get(@RequestParam(required = false) String id) {
+        MaterialReportDetails entity = null;
+        if (StringUtils.isNotBlank(id)) {
+            entity = service.get(id);
+        }
+        if (entity == null) {
+            entity = new MaterialReportDetails();
+        }
+        return entity;
+    }
+
+    /**
+     * 物资上报明细列表页面
+     */
+    @RequiresPermissions("sg:balancedlibrary:MaterialReportDetails:list")
+    @RequestMapping(value = "list")
+    public String list(MaterialReportDetails entity, Model model) {
+        model.addAttribute("entity", entity);
+        return "modules/sg/balancedlibrary/materialReportDetails/MaterialReportDetailslList";
+    }
+
+    /**
+     * 利库明细页面
+     */
+    @RequiresPermissions("sg:balancedlibrary:MaterialReportDetails:list")
+    @RequestMapping(value = "likuResults")
+    public String likuResults(MaterialReportDetails entity, Model model) {
+        model.addAttribute("entity", entity);
+        return "modules/sg/balancedlibrary/materialReportDetails/LikuResults";
+    }
+
+    /**
+     * 利库明细数据
+     */
+    @ResponseBody
+    @RequiresPermissions("sg:balancedlibrary:MaterialReportDetails:list")
+    @RequestMapping(value = "likuResultsData")
+    public Map<String, Object> likuResultsData(MaterialReportDetails entity, HttpServletRequest request, HttpServletResponse response, Model model) {
+        List<LikuDetail> list = service.getLikuDetails(entity);
+        Map<String, Object> map = new HashMap<String, Object>();
+        map.put("rows", list);
+        map.put("total", list.size());
+        return map;
+    }
+
+    /**
+     * 物资上报明细列表数据
+     */
+    @ResponseBody
+    @RequiresPermissions("sg:balancedlibrary:MaterialReportDetails:list")
+    @RequestMapping(value = "data")
+    public Map<String, Object> data(MaterialReportDetails entity, HttpServletRequest request, HttpServletResponse response, Model model) {
+        HttpSession session = request.getSession();
+        session.setAttribute("materialReportDetails", entity);
+        Page<MaterialReportDetails> page = service.findPage(new Page<MaterialReportDetails>(request, response), entity);
+        return getBootstrapData(page);
+    }
+
+    /**
+     * 查看,增加,编辑物资上报明细表单页面
+     */
+    @RequiresPermissions(value = {"sg:balancedlibrary:MaterialReportDetails:view", "sg:balancedlibrary:MaterialReportDetails:add", "sg:balancedlibrary:MaterialReportDetails:edit"}, logical = Logical.OR)
+    @RequestMapping(value = "form")
+    public String form(MaterialReportDetails entity, Model model) {
+        model.addAttribute("entity", entity);
+        return "modules/test/one/dialog/MaterialReportDetailsForm";
+    }
+
+    /**
+     * 保存物资上报明细
+     */
+    @ResponseBody
+    @RequiresPermissions(value = {"sg:balancedlibrary:MaterialReportDetails:add", "sg:balancedlibrary:MaterialReportDetails:edit"}, logical = Logical.OR)
+    @RequestMapping(value = "save")
+    public AjaxJson save(MaterialReportDetails entity, Model model) throws Exception {
+        AjaxJson j = new AjaxJson();
+        /**
+         * 后台hibernate-validation插件校验
+         */
+        String errMsg = beanValidator(entity);
+        if (StringUtils.isNotBlank(errMsg)) {
+            j.setSuccess(false);
+            j.setMsg(errMsg);
+            return j;
+        }
+        //新增或编辑表单保存
+        service.save(entity);
+        j.setSuccess(true);
+        j.setMsg("保存物资上报明细成功");
+        return j;
+    }
+
+    /**
+     * 删除物资上报明细
+     */
+    @ResponseBody
+    @RequiresPermissions("sg:balancedlibrary:MaterialReportDetails:del")
+    @RequestMapping(value = "delete")
+    public AjaxJson delete(MaterialReportDetails entity) {
+        AjaxJson j = new AjaxJson();
+        service.delete(entity);
+        j.setMsg("删除物资上报明细成功");
+        return j;
+    }
+
+    /**
+     * 批量删除物资上报明细
+     */
+    @ResponseBody
+    @RequiresPermissions("sg:balancedlibrary:MaterialReportDetails:del")
+    @RequestMapping(value = "deleteAll")
+    public AjaxJson deleteAll(String ids) {
+        AjaxJson j = new AjaxJson();
+        String idArray[] = ids.split(",");
+        for (String id : idArray) {
+            service.delete(service.get(id));
+        }
+        j.setMsg("删除物资上报明细成功");
+        return j;
+    }
+
+    /**
+     * 导出excel文件
+     */
+    @ResponseBody
+    @RequestMapping(value = "export")
+    public void exportFile(HttpServletRequest request, HttpServletResponse response) {
+        HttpSession session = request.getSession();
+        MaterialReportDetails entity = (MaterialReportDetails) session.getAttribute("materialReportDetails");
+        entity.setPage(null);
+        List<MaterialReportDetails> reportList = service.findList(entity);
+        List<LikuDetail> likuList = service.getLikuDetails(entity);
+        ExportUtil util = new ExportUtil();
+        util.exportDetails(response,reportList,likuList);
+    }
+
+    /**
+     * 物资上报明细-导入Excel数据
+     */
+    @ResponseBody
+    @RequestMapping(value = "import")
+    public AjaxJson importFile(@RequestParam("file") MultipartFile file, HttpServletResponse response, HttpServletRequest request) {
+        AjaxJson j = new AjaxJson();
+        //记录物资上报明细比对利库资源明细详细情况
+        List<CompareHistory> compareHistories = new ArrayList<>();
+        //本部-段长
+        List<MaterialReportDetails> bBSegmentList = new ArrayList<>();
+        //扬中-段长
+        List<MaterialReportDetails> yZSegmentList = new ArrayList<>();
+        //丹阳-段长
+        List<MaterialReportDetails> dYSegmentList = new ArrayList<>();
+        //句容-段长
+        List<MaterialReportDetails> jRSegmentList = new ArrayList<>();
+        //本部-非段长
+        List<MaterialReportDetails> bBNonSegmentList = new ArrayList<>();
+        //扬中-非段长
+        List<MaterialReportDetails> yZNonSegmentList = new ArrayList<>();
+        //丹阳-非段长
+        List<MaterialReportDetails> dYNonSegmentList = new ArrayList<>();
+        //句容-非段长
+        List<MaterialReportDetails> jRNonSegmentList = new ArrayList<>();
+        try {
+            ImportExcel ei = new ImportExcel(file, 1, 0);
+            //物资上报明细数据列表
+            List<MaterialReportDetails> list = ei.getDataList(MaterialReportDetails.class);
+            /*****************************物资上报明细*********************************************/
+            //根据段长非段长、区域 分到不同list,同时设置初始利库数量及申请数量
+            for (MaterialReportDetails details : list) {
+                details.preInsert(); //先给个Id
+                //设置初始利库数量为0,初始申请数量为物资的表格数量
+                details.setNumberOfNiches(0.0);
+                details.setNumberOfApplications(details.getTotal());
+
+                Integer theUnitMeter = LiKuUtils.isTheUnitMeter(details.getUnit());//判断是否段长
+                Integer area = LiKuUtils.judgmentArea(details.getReportingArea());//判断区域
+                if (theUnitMeter.equals(LiKuUtils.YES)) {
+                    if (area.equals(LiKuUtils.BB_FLAG)) {
+                        bBSegmentList.add(details);
+                    } else if (area.equals(LiKuUtils.YZ_FLAG)) {
+                        yZSegmentList.add(details);
+                    } else if (area.equals(LiKuUtils.DY_FLAG)) {
+                        dYSegmentList.add(details);
+                    } else if (area.equals(LiKuUtils.JR_FLAG)) {
+                        jRSegmentList.add(details);
+                    }
+                } else {
+                    if (area.equals(LiKuUtils.BB_FLAG)) {
+                        bBNonSegmentList.add(details);
+                    } else if (area.equals(LiKuUtils.YZ_FLAG)) {
+                        yZNonSegmentList.add(details);
+                    } else if (area.equals(LiKuUtils.DY_FLAG)) {
+                        dYNonSegmentList.add(details);
+                    } else if (area.equals(LiKuUtils.JR_FLAG)) {
+                        jRNonSegmentList.add(details);
+                    }
+                }
+            }
+
+            //同地区上报表中先根据项目名称顺序排序匹配,然后依据表格顺序依次排序匹配
+            //本部段长数据
+            if (bBSegmentList.size() > 0) {
+                bBSegmentList.sort(Comparator.comparing(MaterialReportDetails::getNameOfReserve));
+            }
+            //扬中段长数据
+            if (yZSegmentList.size() > 0) {
+                yZSegmentList.sort(Comparator.comparing(MaterialReportDetails::getNameOfReserve));
+            }
+            //丹阳段长数据
+            if (dYSegmentList.size() > 0) {
+                dYSegmentList.sort(Comparator.comparing(MaterialReportDetails::getNameOfReserve));
+            }
+            //句容段长数据
+            if (jRSegmentList.size() > 0) {
+                jRSegmentList.sort(Comparator.comparing(MaterialReportDetails::getNameOfReserve));
+            }
+
+            //同地区上报表中先根据项目名称顺序排序匹配,然后依据表格顺序依次排序匹配
+            //本部数据-非段长
+            if (bBNonSegmentList.size() > 0) {
+                bBNonSegmentList.sort(Comparator.comparing(MaterialReportDetails::getNameOfReserve));
+            }
+            //扬中数据-非段长
+            if (yZNonSegmentList.size() > 0) {
+                yZNonSegmentList.sort(Comparator.comparing(MaterialReportDetails::getNameOfReserve));
+            }
+            //丹阳数据-非段长
+            if (dYNonSegmentList.size() > 0) {
+                dYNonSegmentList.sort(Comparator.comparing(MaterialReportDetails::getNameOfReserve));
+            }
+            //句容数据-非段长
+            if (jRNonSegmentList.size() > 0) {
+                jRNonSegmentList.sort(Comparator.comparing(MaterialReportDetails::getNameOfReserve));
+            }
+
+            //先根据
+            /*****************************利库资源数据*********************************************/
+            //利库资源池数据,根据本部>扬中>丹阳>句容分组
+            List<LiKuResourcePool> poolList = poolService.findLiKuList(null,null);
+            if(poolList==null||poolList.size()==0){
+                j.setSuccess(false);
+                j.setMsg("请先导入利库资源池!");
+                return j;
+            }
+            //查询出所有本部资源数据-非段长
+            List<LiKuResourcePool> bBNonPoolList = new ArrayList<>();
+            //查询出所有扬中资源数据-非段长
+            List<LiKuResourcePool> yZNonPoolList = new ArrayList<>();
+            //查询出所有丹阳资源数据-非段长
+            List<LiKuResourcePool> dYNonPoolList = new ArrayList<>();
+            //查询出所有句容资源数据-非段长
+            List<LiKuResourcePool> jRNonPoolList = new ArrayList<>();
+
+            //查询出所有本部资源数据-段长
+            List<LiKuResourcePool> bBPoolList = new ArrayList<>();
+            //查询出所有扬中资源数据-段长
+            List<LiKuResourcePool> yZPoolList = new ArrayList<>();
+            //查询出所有丹阳资源数据-段长
+            List<LiKuResourcePool> dYPoolList = new ArrayList<>();
+            //查询出所有句容资源数据-段长
+            List<LiKuResourcePool> jRPoolList = new ArrayList<>();
+            //资源池分类同时每次设置初始利库数和剩余数
+            for(LiKuResourcePool pool:poolList){
+                pool.setNumberOfNiches(0.0);
+                Integer isSectionLength = pool.getIsSectionLength();
+                Integer whereFrom = pool.getWhereFrom();
+                if(isSectionLength.equals(LiKuUtils.NO)){
+                    pool.setRemaining(pool.getInventoryAmount());
+                    if(whereFrom==LiKuUtils.BB_FLAG){
+                        bBNonPoolList.add(pool);
+                    }else if(whereFrom==LiKuUtils.YZ_FLAG){
+                        yZNonPoolList.add(pool);
+                    }else if(whereFrom==LiKuUtils.DY_FLAG){
+                        dYNonPoolList.add(pool);
+                    }else{
+                        jRNonPoolList.add(pool);
+                    }
+                }else{
+                    pool.setRemaining(pool.getLengthOfCable());
+                    if(whereFrom==LiKuUtils.BB_FLAG){
+                        bBPoolList.add(pool);
+                    }else if(whereFrom==LiKuUtils.YZ_FLAG){
+                        yZPoolList.add(pool);
+                    }else if(whereFrom==LiKuUtils.DY_FLAG){
+                        dYPoolList.add(pool);
+                    }else{
+                        jRPoolList.add(pool);
+                    }
+                }
+            }
+
+            //同地区库龄降序>数量大小降序>批次号升序
+            //本部利库资源池数据-非段长
+            if (bBNonPoolList.size() > 0) {
+                poolSort(bBNonPoolList);
+            }
+            //扬中利库资源池数据-非段长
+            if (yZNonPoolList.size() > 0) {
+                poolSort(yZNonPoolList);
+            }
+            //丹阳利库资源池数据-非段长
+            if (dYNonPoolList.size() > 0) {
+                poolSort(dYNonPoolList);
+            }
+            //句容利库资源池数据-非段长
+            if (jRNonPoolList.size() > 0) {
+                poolSort(jRNonPoolList);
+            }
+
+            //本部利库资源池数据-段长
+            if (bBPoolList.size() > 0) {
+                for (LiKuResourcePool pool :
+                        bBPoolList) {
+                    //设置标识利库中段长状态为 未完成利库 状态,单独设置状态因为无法根据数量判断,段长利库可能有剩余
+                    pool.setCompleteLiKu(0);
+                }
+                poolSegSort(bBPoolList);
+            }
+            //扬中利库资源池数据-段长
+            if (yZPoolList.size() > 0) {
+                for (LiKuResourcePool pool :
+                        yZPoolList) {
+                    pool.setCompleteLiKu(0);
+                }
+                poolSegSort(yZPoolList);
+            }
+            //丹阳利库资源池数据-段长
+            if (dYPoolList.size() > 0) {
+                for (LiKuResourcePool pool :
+                        dYPoolList) {
+                    pool.setCompleteLiKu(0);
+                }
+                poolSegSort(dYPoolList);
+            }
+            //句容利库资源池数据-段长
+            if (jRPoolList.size() > 0) {
+                for (LiKuResourcePool pool :
+                        jRPoolList) {
+                    pool.setCompleteLiKu(0);
+                }
+                poolSegSort(jRPoolList);
+            }
+
+            /*****************************************非段长比对*****************************************************/
+            //非段长比对顺序,由物资上报数据比对利库资源池数据
+            //本部-本部
+            if (bBNonSegmentList.size() > 0 && bBNonPoolList.size() > 0) {
+                AdjustUtil.nonSegAdjust(bBNonSegmentList,bBNonPoolList,compareHistories,AdjustUtil.LOCAL_ADJUST);
+            }
+            //扬中-扬中
+            if (yZNonSegmentList.size() > 0 && yZNonPoolList.size() > 0) {
+                AdjustUtil.nonSegAdjust(yZNonSegmentList,yZNonPoolList,compareHistories,AdjustUtil.LOCAL_ADJUST);
+            }
+            //丹阳-丹阳
+            if (dYNonSegmentList.size() > 0 && dYNonPoolList.size() > 0) {
+                AdjustUtil.nonSegAdjust(dYNonSegmentList,dYNonPoolList,compareHistories,AdjustUtil.LOCAL_ADJUST);
+            }
+            //句容-句容
+            if (jRNonSegmentList.size() > 0 && jRNonPoolList.size() > 0) {
+                AdjustUtil.nonSegAdjust(jRNonSegmentList,jRNonPoolList,compareHistories,AdjustUtil.LOCAL_ADJUST);
+            }
+
+            //本部-扬中
+            if (bBNonSegmentList.size() > 0 && yZNonPoolList.size() > 0) {
+                AdjustUtil.nonSegAdjust(bBNonSegmentList,yZNonPoolList,compareHistories,AdjustUtil.SPAN_ADJUST);
+            }
+            //本部-丹阳
+            if (bBNonSegmentList.size() > 0 && dYNonPoolList.size() > 0) {
+                AdjustUtil.nonSegAdjust(bBNonSegmentList,dYNonPoolList,compareHistories,AdjustUtil.SPAN_ADJUST);
+            }
+            //本部-句容
+            if (bBNonSegmentList.size() > 0 && jRNonPoolList.size() > 0) {
+                AdjustUtil.nonSegAdjust(bBNonSegmentList,jRNonPoolList,compareHistories,AdjustUtil.SPAN_ADJUST);
+            }
+
+            //扬中-本部
+            if (yZNonSegmentList.size() > 0 && bBNonPoolList.size() > 0) {
+                AdjustUtil.nonSegAdjust(yZNonSegmentList,bBNonPoolList,compareHistories,AdjustUtil.SPAN_ADJUST);
+            }
+            //杨中-丹阳
+            if (yZNonSegmentList.size() > 0 && dYNonPoolList.size() > 0) {
+                AdjustUtil.nonSegAdjust(yZNonSegmentList,dYNonPoolList,compareHistories,AdjustUtil.SPAN_ADJUST);
+            }
+            //扬中-句容
+            if (yZNonSegmentList.size() > 0 && jRNonPoolList.size() > 0) {
+                AdjustUtil.nonSegAdjust(yZNonSegmentList,jRNonPoolList,compareHistories,AdjustUtil.SPAN_ADJUST);
+            }
+            //丹阳-本部
+            if (dYNonSegmentList.size() > 0 && bBNonPoolList.size() > 0) {
+                AdjustUtil.nonSegAdjust(dYNonSegmentList,bBNonPoolList,compareHistories,AdjustUtil.SPAN_ADJUST);
+            }
+            //丹阳-扬中
+            if (dYNonSegmentList.size() > 0 && yZNonPoolList.size() > 0) {
+                AdjustUtil.nonSegAdjust(dYNonSegmentList,yZNonPoolList,compareHistories,AdjustUtil.SPAN_ADJUST);
+            }
+            //丹阳-句容
+            if (dYNonSegmentList.size() > 0 && jRNonPoolList.size() > 0) {
+                AdjustUtil.nonSegAdjust(dYNonSegmentList,jRNonPoolList,compareHistories,AdjustUtil.SPAN_ADJUST);
+            }
+            //句容-本部
+            if (jRNonSegmentList.size() > 0 && bBNonPoolList.size() > 0) {
+                AdjustUtil.nonSegAdjust(jRNonSegmentList,bBNonPoolList,compareHistories,AdjustUtil.SPAN_ADJUST);
+            }
+            //句容-扬中
+            if (jRNonSegmentList.size() > 0 && yZNonPoolList.size() > 0) {
+                AdjustUtil.nonSegAdjust(jRNonSegmentList,yZNonPoolList,compareHistories,AdjustUtil.SPAN_ADJUST);
+            }
+            //句容-丹阳
+            if (jRNonSegmentList.size() > 0 && dYNonPoolList.size() > 0) {
+                AdjustUtil.nonSegAdjust(jRNonSegmentList,dYNonPoolList,compareHistories,AdjustUtil.SPAN_ADJUST);
+            }
+
+            /*************************************非段长以大代小******************************************************/
+            //查找库中所有的以大代小的数据list
+            List<ReplaceMaterial> replaceList = replaceMaterialService.findAll();
+            if (replaceList.size() > 0) {
+                //本部-本部本地以大代小
+                if (bBNonSegmentList.size() > 0 && bBNonPoolList.size() > 0) {
+                    AdjustUtil.nonSegRepAdjust(bBNonSegmentList,bBNonPoolList,compareHistories,AdjustUtil.REP_LOCAL_ADJUST,replaceList);
+                }
+
+                //扬中-扬中本地以大代小
+                if (yZNonSegmentList.size() > 0 && yZNonPoolList.size() > 0) {
+                    AdjustUtil.nonSegRepAdjust(yZNonSegmentList,yZNonPoolList,compareHistories,AdjustUtil.REP_LOCAL_ADJUST,replaceList);
+                }
+                //丹阳-丹阳本地以大代小
+                if (dYNonSegmentList.size() > 0 && dYNonPoolList.size() > 0) {
+                    AdjustUtil.nonSegRepAdjust(dYNonSegmentList,dYNonPoolList,compareHistories,AdjustUtil.REP_LOCAL_ADJUST,replaceList);
+                }
+                //句容-句容本地以大代小
+                if (jRNonSegmentList.size() > 0 && jRNonPoolList.size() > 0) {
+                    AdjustUtil.nonSegRepAdjust(jRNonSegmentList,jRNonPoolList,compareHistories,AdjustUtil.REP_LOCAL_ADJUST,replaceList);
+                }
+
+
+                //本部-扬中跨域以大代小
+                if (bBNonSegmentList.size() > 0 && yZNonPoolList.size() > 0) {
+                    AdjustUtil.nonSegRepAdjust(bBNonSegmentList,yZNonPoolList,compareHistories,AdjustUtil.REP_SPAN_ADJUST,replaceList);
+                }
+                //本部-丹阳跨域以大代小
+                if (bBNonSegmentList.size() > 0 && dYNonPoolList.size() > 0) {
+                    AdjustUtil.nonSegRepAdjust(bBNonSegmentList,dYNonPoolList,compareHistories,AdjustUtil.REP_SPAN_ADJUST,replaceList);
+                }
+                //本部-句容跨域以大代小
+                if (bBNonSegmentList.size() > 0 && jRNonPoolList.size() > 0) {
+                    AdjustUtil.nonSegRepAdjust(bBNonSegmentList,jRNonPoolList,compareHistories,AdjustUtil.REP_SPAN_ADJUST,replaceList);
+                }
+
+                //扬中-本部跨域以大代小
+                if (yZNonSegmentList.size() > 0 && bBNonPoolList.size() > 0) {
+                    AdjustUtil.nonSegRepAdjust(yZNonSegmentList,bBNonPoolList,compareHistories,AdjustUtil.REP_SPAN_ADJUST,replaceList);
+                }
+                //扬中-丹阳跨域以大代小
+                if (yZNonSegmentList.size() > 0 && dYNonPoolList.size() > 0) {
+                    AdjustUtil.nonSegRepAdjust(yZNonSegmentList,dYNonPoolList,compareHistories,AdjustUtil.REP_SPAN_ADJUST,replaceList);
+                }
+                //扬中-句容跨域以大代小
+                if (yZNonSegmentList.size() > 0 && jRNonPoolList.size() > 0) {
+                    AdjustUtil.nonSegRepAdjust(yZNonSegmentList,jRNonPoolList,compareHistories,AdjustUtil.REP_SPAN_ADJUST,replaceList);
+                }
+
+                //丹阳-本部跨域以大代小
+                if (dYNonSegmentList.size() > 0 && bBNonPoolList.size() > 0) {
+                    AdjustUtil.nonSegRepAdjust(dYNonSegmentList,bBNonPoolList,compareHistories,AdjustUtil.REP_SPAN_ADJUST,replaceList);
+                }
+                //丹阳-扬中跨域以大代小
+                if (dYNonSegmentList.size() > 0 && yZNonPoolList.size() > 0) {
+                    AdjustUtil.nonSegRepAdjust(dYNonSegmentList,yZNonPoolList,compareHistories,AdjustUtil.REP_SPAN_ADJUST,replaceList);
+                }
+                //丹阳-句容跨域以大代小
+                if (dYNonSegmentList.size() > 0 && jRNonPoolList.size() > 0) {
+                    AdjustUtil.nonSegRepAdjust(dYNonSegmentList,jRNonPoolList,compareHistories,AdjustUtil.REP_SPAN_ADJUST,replaceList);
+                }
+
+                //句容-本部跨域以大代小
+                if (jRNonSegmentList.size() > 0 && bBNonPoolList.size() > 0) {
+                    AdjustUtil.nonSegRepAdjust(jRNonSegmentList,bBNonPoolList,compareHistories,AdjustUtil.REP_SPAN_ADJUST,replaceList);
+                }
+
+                //句容-扬中跨域以大代小
+                if (jRNonSegmentList.size() > 0 && yZNonPoolList.size() > 0) {
+                    AdjustUtil.nonSegRepAdjust(jRNonSegmentList,yZNonPoolList,compareHistories,AdjustUtil.REP_SPAN_ADJUST,replaceList);
+                }
+                //句容-丹阳跨域以大代小
+                if (jRNonSegmentList.size() > 0 && dYNonPoolList.size() > 0) {
+                    AdjustUtil.nonSegRepAdjust(jRNonSegmentList,dYNonPoolList,compareHistories,AdjustUtil.REP_SPAN_ADJUST,replaceList);
+                }
+
+            }
+
+            /****************************************段长比对*****************************************************/
+            //本部-本部
+            if (bBPoolList.size() > 0 && bBSegmentList.size() > 0) {
+                AdjustUtil.segAdjustReverse(bBSegmentList,bBPoolList,compareHistories,AdjustUtil.LOCAL_ADJUST);
+                AdjustUtil.segAdjust(bBSegmentList,bBPoolList,compareHistories,AdjustUtil.LOCAL_ADJUST);
+            }
+            //扬中-扬中
+            if (yZPoolList.size() > 0 && yZSegmentList.size() > 0) {
+                AdjustUtil.segAdjustReverse(yZSegmentList,yZPoolList,compareHistories,AdjustUtil.LOCAL_ADJUST);
+                AdjustUtil.segAdjust(yZSegmentList,yZPoolList,compareHistories,AdjustUtil.LOCAL_ADJUST);
+            }
+            //丹阳-丹阳-段长
+            if (dYPoolList.size() > 0 && dYSegmentList.size() > 0) {
+                AdjustUtil.segAdjustReverse(dYSegmentList,dYPoolList,compareHistories,AdjustUtil.LOCAL_ADJUST);
+                AdjustUtil.segAdjust(dYSegmentList,dYPoolList,compareHistories,AdjustUtil.LOCAL_ADJUST);
+            }
+            //句容-句容-段长
+            if (jRPoolList.size() > 0 && jRSegmentList.size() > 0) {
+                AdjustUtil.segAdjustReverse(jRSegmentList,jRPoolList,compareHistories,AdjustUtil.LOCAL_ADJUST);
+                AdjustUtil.segAdjust(jRSegmentList,jRPoolList,compareHistories,AdjustUtil.LOCAL_ADJUST);
+            }
+
+            //本部-扬中-段长
+            if (bBPoolList.size() > 0 && yZSegmentList.size() > 0) {
+                AdjustUtil.segAdjustReverse(yZSegmentList,bBPoolList,compareHistories,AdjustUtil.SPAN_ADJUST);
+                AdjustUtil.segAdjust(yZSegmentList,bBPoolList,compareHistories,AdjustUtil.SPAN_ADJUST);
+            }
+            //本部-丹阳-段长
+            if (bBPoolList.size() > 0 && dYSegmentList.size() > 0) {
+                AdjustUtil.segAdjustReverse(dYSegmentList,bBPoolList,compareHistories,AdjustUtil.SPAN_ADJUST);
+                AdjustUtil.segAdjust(dYSegmentList,bBPoolList,compareHistories,AdjustUtil.SPAN_ADJUST);
+            }
+            //本部-句容-段长
+            if (bBPoolList.size() > 0 && jRSegmentList.size() > 0) {
+                AdjustUtil.segAdjustReverse(jRSegmentList,bBPoolList,compareHistories,AdjustUtil.SPAN_ADJUST);
+                AdjustUtil.segAdjust(jRSegmentList,bBPoolList,compareHistories,AdjustUtil.SPAN_ADJUST);
+            }
+
+            //杨中-本部-段长
+            if (yZPoolList.size() > 0 && bBSegmentList.size() > 0) {
+                AdjustUtil.segAdjustReverse(bBSegmentList,yZPoolList,compareHistories,AdjustUtil.SPAN_ADJUST);
+                AdjustUtil.segAdjust(bBSegmentList,yZPoolList,compareHistories,AdjustUtil.SPAN_ADJUST);
+            }
+            //杨中-丹阳-段长
+            if (yZPoolList.size() > 0 && dYSegmentList.size() > 0) {
+                AdjustUtil.segAdjustReverse(dYSegmentList,yZPoolList,compareHistories,AdjustUtil.SPAN_ADJUST);
+                AdjustUtil.segAdjust(dYSegmentList,yZPoolList,compareHistories,AdjustUtil.SPAN_ADJUST);
+            }
+            //杨中-句容-段长
+            if (yZPoolList.size() > 0 && jRSegmentList.size() > 0) {
+                AdjustUtil.segAdjustReverse(jRSegmentList,yZPoolList,compareHistories,AdjustUtil.SPAN_ADJUST);
+                AdjustUtil.segAdjust(jRSegmentList,yZPoolList,compareHistories,AdjustUtil.SPAN_ADJUST);
+            }
+
+            //丹阳-本部-段长
+            if (dYPoolList.size() > 0 && bBSegmentList.size() > 0) {
+                AdjustUtil.segAdjustReverse(bBSegmentList,dYPoolList,compareHistories,AdjustUtil.SPAN_ADJUST);
+                AdjustUtil.segAdjust(bBSegmentList,dYPoolList,compareHistories,AdjustUtil.SPAN_ADJUST);
+            }
+            //丹阳-扬中-段长
+            if (dYPoolList.size() > 0 && yZSegmentList.size() > 0) {
+                AdjustUtil.segAdjustReverse(yZSegmentList,dYPoolList,compareHistories,AdjustUtil.SPAN_ADJUST);
+                AdjustUtil.segAdjust(yZSegmentList,dYPoolList,compareHistories,AdjustUtil.SPAN_ADJUST);
+            }
+            //丹阳-句容-段长
+            if (dYPoolList.size() > 0 && jRSegmentList.size() > 0) {
+                AdjustUtil.segAdjustReverse(jRSegmentList,dYPoolList,compareHistories,AdjustUtil.SPAN_ADJUST);
+                AdjustUtil.segAdjust(jRSegmentList,dYPoolList,compareHistories,AdjustUtil.SPAN_ADJUST);
+            }
+
+
+            //句容-本部-段长
+            if (jRPoolList.size() > 0 && bBSegmentList.size() > 0) {
+                AdjustUtil.segAdjustReverse(bBSegmentList,jRPoolList,compareHistories,AdjustUtil.SPAN_ADJUST);
+                AdjustUtil.segAdjust(bBSegmentList,jRPoolList,compareHistories,AdjustUtil.SPAN_ADJUST);
+            }
+            //句容-扬中-段长
+            if (jRPoolList.size() > 0 && yZSegmentList.size() > 0) {
+                AdjustUtil.segAdjustReverse(yZSegmentList,jRPoolList,compareHistories,AdjustUtil.SPAN_ADJUST);
+                AdjustUtil.segAdjust(yZSegmentList,jRPoolList,compareHistories,AdjustUtil.SPAN_ADJUST);
+            }
+            //句容-丹阳-段长
+            if (jRPoolList.size() > 0 && dYSegmentList.size() > 0) {
+                AdjustUtil.segAdjustReverse(dYSegmentList,jRPoolList,compareHistories,AdjustUtil.SPAN_ADJUST);
+                AdjustUtil.segAdjust(dYSegmentList,jRPoolList,compareHistories,AdjustUtil.SPAN_ADJUST);
+            }
+
+            /******************************************合并利库************************************/
+            //将4个区域的段长物资数据合并,使用各个区域的
+            List<MaterialReportDetails> fourAreaList = new ArrayList<>();
+            if (bBSegmentList.size() > 0) {
+                fourAreaList.addAll(bBSegmentList);
+            }
+            if (yZSegmentList.size() > 0) {
+                fourAreaList.addAll(yZSegmentList);
+            }
+            if (dYSegmentList.size() > 0) {
+                fourAreaList.addAll(dYSegmentList);
+            }
+            if (jRSegmentList.size() > 0) {
+                fourAreaList.addAll(jRSegmentList);
+            }
+            //将四个区域的段长利库数据合并
+            List<LiKuResourcePool> fourLikuList = new ArrayList<>();
+            if(bBPoolList.size()>0){
+                fourLikuList.addAll(bBPoolList);
+            }
+            if(yZPoolList.size()>0){
+                fourLikuList.addAll(yZPoolList);
+            }
+            if(dYPoolList.size()>0){
+                fourLikuList.addAll(dYPoolList);
+            }
+            if(jRPoolList.size()>0){
+                fourLikuList.addAll(jRPoolList);
+            }
+
+            //本部-所有
+            if (bBSegmentList.size() > 0 && fourLikuList.size() > 0) {
+                AdjustUtil.segAdjustReverse(bBSegmentList,fourLikuList,compareHistories,AdjustUtil.COMBINE_ADJUST);
+            }
+            //杨中-所有
+            if (yZSegmentList.size() > 0 && fourLikuList.size() > 0) {
+                AdjustUtil.segAdjustReverse(yZSegmentList,fourLikuList,compareHistories,AdjustUtil.COMBINE_ADJUST);
+            }
+            //丹阳-所有
+            if (dYSegmentList.size() > 0 && fourLikuList.size() > 0) {
+                AdjustUtil.segAdjustReverse(dYSegmentList,fourLikuList,compareHistories,AdjustUtil.COMBINE_ADJUST);
+            }
+            //句容-所有
+            if (jRSegmentList.size() > 0 && fourLikuList.size() > 0) {
+                AdjustUtil.segAdjustReverse(jRSegmentList,fourLikuList,compareHistories,AdjustUtil.COMBINE_ADJUST);
+            }
+
+            //本部-所有
+            if (bBPoolList.size() > 0 && fourAreaList.size() > 0) {
+                AdjustUtil.segAdjust(fourAreaList,bBPoolList,compareHistories,AdjustUtil.COMBINE_ADJUST);
+            }
+            //杨中-所有
+            if (yZPoolList.size() > 0 && fourAreaList.size() > 0) {
+                AdjustUtil.segAdjust(fourAreaList,yZPoolList,compareHistories,AdjustUtil.COMBINE_ADJUST);
+            }
+            //丹阳-所有
+            if (dYPoolList.size() > 0 && fourAreaList.size() > 0) {
+                AdjustUtil.segAdjust(fourAreaList,dYPoolList,compareHistories,AdjustUtil.COMBINE_ADJUST);
+            }
+            //句容-所有
+            if (jRPoolList.size() > 0 && fourAreaList.size() > 0) {
+                AdjustUtil.segAdjust(fourAreaList,jRPoolList,compareHistories,AdjustUtil.COMBINE_ADJUST);
+            }
+
+            //本部-扬中-丹阳-句容
+            /****************************************段长以大代小********************************************/
+            if (replaceList.size() > 0) {
+                //本部-本部-段长以大代小
+                if (bBPoolList.size() > 0 && bBSegmentList.size() > 0) {
+                    AdjustUtil.segRepAdjustReverse(bBSegmentList,bBPoolList,compareHistories,AdjustUtil.REP_LOCAL_ADJUST,replaceList);
+                    AdjustUtil.segRepAdjust(bBSegmentList,bBPoolList,compareHistories,AdjustUtil.REP_LOCAL_ADJUST,replaceList);
+                }
+                //扬中-扬中-段长以大代小
+                if (yZPoolList.size() > 0 && yZSegmentList.size() > 0) {
+                    AdjustUtil.segRepAdjustReverse(yZSegmentList,yZPoolList,compareHistories,AdjustUtil.REP_LOCAL_ADJUST,replaceList);
+                    AdjustUtil.segRepAdjust(yZSegmentList,yZPoolList,compareHistories,AdjustUtil.REP_LOCAL_ADJUST,replaceList);
+                }
+                //丹阳-丹阳-段长以大代小
+                if (dYPoolList.size() > 0 && dYSegmentList.size() > 0) {
+                    AdjustUtil.segRepAdjustReverse(dYSegmentList,dYPoolList,compareHistories,AdjustUtil.REP_LOCAL_ADJUST,replaceList);
+                    AdjustUtil.segRepAdjust(dYSegmentList,dYPoolList,compareHistories,AdjustUtil.REP_LOCAL_ADJUST,replaceList);
+                }
+                //句容-句容-段长以大代小
+                if (jRPoolList.size() > 0 && jRSegmentList.size() > 0) {
+                    AdjustUtil.segRepAdjustReverse(jRSegmentList,jRPoolList,compareHistories,AdjustUtil.REP_LOCAL_ADJUST,replaceList);
+                    AdjustUtil.segRepAdjust(jRSegmentList,jRPoolList,compareHistories,AdjustUtil.REP_LOCAL_ADJUST,replaceList);
+                }
+
+
+                //本部-扬中-段长以大代小
+                if (bBPoolList.size() > 0 && yZSegmentList.size() > 0) {
+                    AdjustUtil.segRepAdjustReverse(yZSegmentList,bBPoolList,compareHistories,AdjustUtil.REP_SPAN_ADJUST,replaceList);
+                    AdjustUtil.segRepAdjust(yZSegmentList,bBPoolList,compareHistories,AdjustUtil.REP_SPAN_ADJUST,replaceList);
+                }
+                //本部-丹阳-段长以大代小
+                if (bBPoolList.size() > 0 && dYSegmentList.size() > 0) {
+                    AdjustUtil.segRepAdjustReverse(dYSegmentList,bBPoolList,compareHistories,AdjustUtil.REP_SPAN_ADJUST,replaceList);
+                    AdjustUtil.segRepAdjust(dYSegmentList,bBPoolList,compareHistories,AdjustUtil.REP_SPAN_ADJUST,replaceList);
+                }
+                //本部-句容-段长以大代小
+                if (bBPoolList.size() > 0 && jRSegmentList.size() > 0) {
+                    AdjustUtil.segRepAdjustReverse(jRSegmentList,bBPoolList,compareHistories,AdjustUtil.REP_SPAN_ADJUST,replaceList);
+                    AdjustUtil.segRepAdjust(jRSegmentList,bBPoolList,compareHistories,AdjustUtil.REP_SPAN_ADJUST,replaceList);
+                }
+
+                //杨中-本部-段长以大代小
+                if (yZPoolList.size() > 0 && bBSegmentList.size() > 0) {
+                    AdjustUtil.segRepAdjustReverse(bBSegmentList,yZPoolList,compareHistories,AdjustUtil.REP_SPAN_ADJUST,replaceList);
+                    AdjustUtil.segRepAdjust(bBSegmentList,yZPoolList,compareHistories,AdjustUtil.REP_SPAN_ADJUST,replaceList);
+                }
+                //杨中-丹阳-段长以大代小
+                if (yZPoolList.size() > 0 && dYSegmentList.size() > 0) {
+                    AdjustUtil.segRepAdjustReverse(dYSegmentList,yZPoolList,compareHistories,AdjustUtil.REP_SPAN_ADJUST,replaceList);
+                    AdjustUtil.segRepAdjust(dYSegmentList,yZPoolList,compareHistories,AdjustUtil.REP_SPAN_ADJUST,replaceList);
+                }
+                //杨中-句容-段长以大代小
+                if (yZPoolList.size() > 0 && jRSegmentList.size() > 0) {
+                    AdjustUtil.segRepAdjustReverse(jRSegmentList,yZPoolList,compareHistories,AdjustUtil.REP_SPAN_ADJUST,replaceList);
+                    AdjustUtil.segRepAdjust(jRSegmentList,yZPoolList,compareHistories,AdjustUtil.REP_SPAN_ADJUST,replaceList);
+                }
+
+                //丹阳-本部-段长以大代小
+                if (dYPoolList.size() > 0 && bBSegmentList.size() > 0) {
+                    AdjustUtil.segRepAdjustReverse(bBSegmentList,dYPoolList,compareHistories,AdjustUtil.REP_SPAN_ADJUST,replaceList);
+                    AdjustUtil.segRepAdjust(bBSegmentList,dYPoolList,compareHistories,AdjustUtil.REP_SPAN_ADJUST,replaceList);
+                }
+                //丹阳-扬中-段长以大代小
+                if (dYPoolList.size() > 0 && yZSegmentList.size() > 0) {
+                    AdjustUtil.segRepAdjustReverse(yZSegmentList,dYPoolList,compareHistories,AdjustUtil.REP_SPAN_ADJUST,replaceList);
+                    AdjustUtil.segRepAdjust(yZSegmentList,dYPoolList,compareHistories,AdjustUtil.REP_SPAN_ADJUST,replaceList);
+                }
+                //丹阳-句容-段长以大代小
+                if (dYPoolList.size() > 0 && jRSegmentList.size() > 0) {
+                    AdjustUtil.segRepAdjustReverse(jRSegmentList,dYPoolList,compareHistories,AdjustUtil.REP_SPAN_ADJUST,replaceList);
+                    AdjustUtil.segRepAdjust(jRSegmentList,dYPoolList,compareHistories,AdjustUtil.REP_SPAN_ADJUST,replaceList);
+                }
+
+                //句容-本部-段长以大代小
+                if (jRPoolList.size() > 0 && bBSegmentList.size() > 0) {
+                    AdjustUtil.segRepAdjustReverse(bBSegmentList,jRPoolList,compareHistories,AdjustUtil.REP_SPAN_ADJUST,replaceList);
+                    AdjustUtil.segRepAdjust(bBSegmentList,jRPoolList,compareHistories,AdjustUtil.REP_SPAN_ADJUST,replaceList);
+                }
+                //句容-扬中-段长以大代小
+                if (jRPoolList.size() > 0 && yZSegmentList.size() > 0) {
+                    AdjustUtil.segRepAdjustReverse(yZSegmentList,jRPoolList,compareHistories,AdjustUtil.REP_SPAN_ADJUST,replaceList);
+                    AdjustUtil.segRepAdjust(yZSegmentList,jRPoolList,compareHistories,AdjustUtil.REP_SPAN_ADJUST,replaceList);
+                }
+                //句容-丹阳-段长以大代小
+                if (jRPoolList.size() > 0 && yZSegmentList.size() > 0) {
+                    AdjustUtil.segRepAdjustReverse(yZSegmentList,jRPoolList,compareHistories,AdjustUtil.REP_SPAN_ADJUST,replaceList);
+                    AdjustUtil.segRepAdjust(yZSegmentList,jRPoolList,compareHistories,AdjustUtil.REP_SPAN_ADJUST,replaceList);
+                }
+                /******************************************以大代小合并利库************************************/
+                //以大代小合并利库
+
+                //本部-所有
+                if (bBSegmentList.size() > 0 && fourLikuList.size() > 0) {
+                    AdjustUtil.segRepAdjustReverse(bBSegmentList,fourLikuList,compareHistories,AdjustUtil.REP_COMBINE_ADJUST,replaceList);
+                }
+                //杨中-所有
+                if (yZSegmentList.size() > 0 && fourLikuList.size() > 0) {
+                    AdjustUtil.segRepAdjustReverse(yZSegmentList,fourLikuList,compareHistories,AdjustUtil.REP_COMBINE_ADJUST,replaceList);
+                }
+                //丹阳-所有
+                if (dYSegmentList.size() > 0 && fourLikuList.size() > 0) {
+                    AdjustUtil.segRepAdjustReverse(dYSegmentList,fourLikuList,compareHistories,AdjustUtil.REP_COMBINE_ADJUST,replaceList);
+                }
+                //句容-所有
+                if (jRSegmentList.size() > 0 && fourLikuList.size() > 0) {
+                    AdjustUtil.segRepAdjustReverse(jRSegmentList,fourLikuList,compareHistories,AdjustUtil.REP_COMBINE_ADJUST,replaceList);
+                }
+
+                //本部-所有
+                if (bBPoolList.size() > 0 && fourAreaList.size() > 0) {
+                    AdjustUtil.segRepAdjust(fourAreaList,bBPoolList,compareHistories,AdjustUtil.REP_COMBINE_ADJUST,replaceList);
+                }
+                //杨中-所有
+                if (yZPoolList.size() > 0 && fourAreaList.size() > 0) {
+                    AdjustUtil.segRepAdjust(fourAreaList,yZPoolList,compareHistories,AdjustUtil.REP_COMBINE_ADJUST,replaceList);
+                }
+                //丹阳-所有
+                if (dYPoolList.size() > 0 && fourAreaList.size() > 0) {
+                    AdjustUtil.segRepAdjust(fourAreaList,dYPoolList,compareHistories,AdjustUtil.REP_COMBINE_ADJUST,replaceList);
+                }
+                //句容-所有
+                if (jRPoolList.size() > 0 && fourAreaList.size() > 0) {
+                    AdjustUtil.segRepAdjust(fourAreaList,jRPoolList,compareHistories,AdjustUtil.REP_COMBINE_ADJUST,replaceList);
+                }
+
+            }
+
+
+            /*****************************************调整记录保存**************************************************/
+            if (compareHistories.size() > 0) {
+                compareHistoryService.delAll();
+                compareHistoryService.insertList(compareHistories);
+            }
+            /**********************************更新利库资源池,插入申请物资数据**************************************/
+
+            //利库基础数据更新库存
+            poolService.updateAllList(poolList);
+
+            if (list.size() > 0) {
+                service.delAll();
+                service.insertList(list);
+            }
+            j.setSuccess(true);
+            j.setMsg("已成功导入 " + list.size() + " 条物资上报明细记录");
+        } catch (Exception e) {
+            j.setSuccess(false);
+            j.setMsg("导入物资上报明细失败!失败信息:" + e.getMessage());
+        }
+        return j;
+    }
+
+
+
+    /**
+     * 利库非段长排序方法,排序依据 库存日、库存数量、批次号
+     * @param bBNonPoolList
+     */
+    private void poolSort(List<LiKuResourcePool> bBNonPoolList) {
+        Comparator<LiKuResourcePool> reversed = Comparator.comparing(LiKuResourcePool::getDaysStorage).reversed();
+        Comparator<LiKuResourcePool> comparator = Comparator.comparing(LiKuResourcePool::getInventoryAmount).reversed();
+        Comparator<LiKuResourcePool> poolComparator = Comparator.comparing(LiKuResourcePool::getBatch);
+        bBNonPoolList.sort(reversed.thenComparing(comparator).thenComparing(poolComparator));
+    }
+
+    /**
+     * 利库段长排序方法,排序依据 库存日、批次号、具体段长
+     * @param bBNonPoolList
+     */
+    private void poolSegSort(List<LiKuResourcePool> bBNonPoolList) {
+        Comparator<LiKuResourcePool> reversed = Comparator.comparing(LiKuResourcePool::getDaysStorage).reversed();
+        Comparator<LiKuResourcePool> comparator = Comparator.comparing(LiKuResourcePool::getInventoryAmount).reversed();
+        Comparator<LiKuResourcePool> poolComparator = Comparator.comparing(LiKuResourcePool::getBatch);
+        Comparator<LiKuResourcePool> beComparator = Comparator.comparing(LiKuResourcePool::getLengthOfCable);
+        bBNonPoolList.sort(reversed.thenComparing(poolComparator).thenComparing(beComparator));
+    }
+
+    /**
+     * 下载物资上报明细导入模板
+     */
+    @ResponseBody
+    @RequestMapping(value = "import/template")
+    public AjaxJson importFileTemplate(HttpServletResponse response) {
+        AjaxJson j = new AjaxJson();
+        try {
+            String fileName = "利库结果.xlsx";
+            List<MaterialReportDetails> list = Lists.newArrayList();
+            new ExportExcel("物料信息表", MaterialReportDetails.class, 1).setDataList(list).write(response, fileName).dispose();
+            return null;
+        } catch (Exception e) {
+            j.setSuccess(false);
+            j.setMsg("导入模板下载失败!失败信息:" + e.getMessage());
+        }
+        return j;
+    }
+
+}

+ 2 - 1
src/main/java/com/jeeplus/modules/sg/balancedlibrary/replaceMaterial/web/ReplaceMaterialController.java

@@ -185,7 +185,8 @@ public class ReplaceMaterialController extends BaseController {
 		List<ReplaceMaterial> insertList = new ArrayList<>();
 		try {
 			ImportExcel ei = new ImportExcel(file, 0, 0);
-			for (int i = 1; i < ei.getLastDataRowNum(); i++) {
+			int last = ei.getLastDataRowNum();
+			for (int i = 1; i <= ei.getLastDataRowNum(); i++) {
 				Row row = ei.getRow(i);
 				ReplaceMaterial replaceMaterial = new ReplaceMaterial();
 				Cell cell = row.getCell(0);

+ 6 - 6
src/main/java/com/jeeplus/modules/sg/financial/erpcredit/util/ErpInfo.java

@@ -97,7 +97,7 @@ public  class ErpInfo {
         int lastRow = importUtil.getLastDataRowNum();
         List<ErpAccount> list = new ArrayList<ErpAccount>();
         ErpAccount erpAccount = null;
-        for(int i=1; i<lastRow;i++){
+        for(int i=1; i<=lastRow;i++){
             erpAccount = new ErpAccount();
             Row row = importUtil.getRow(i);
             String erpCode = (String) importUtil.getCellValue(row,10);
@@ -385,7 +385,7 @@ public  class ErpInfo {
             }
 
             //成本项目施工费对应供应商
-            List<DictValue> supCost = DictUtils.getDictList("finance_cost_supervisor");
+            List<DictValue> supCost = DictUtils.getDictList("finance_cost_construction");
             for (DictValue a :
                     supCost) {
                 String label = a.getLabel();
@@ -396,16 +396,16 @@ public  class ErpInfo {
             //成本项目设计费对应供应商
             List<DictValue> desCost = DictUtils.getDictList("finance_cost_design");
             for (DictValue a :
-                    supCost) {
+                    desCost) {
                 String label = a.getLabel();
                 if (supplierName.equals(label)) {
                     erpCredit.setOtherDesignFee(DoubleUtil.add(erpCredit.getOtherDesignFee(),lineItemAmount));
                 }
             }
             //成本项目监理费对应供应商
-            List<DictValue> conCOst = DictUtils.getDictList("finance_cost_construction");
+            List<DictValue> conCOst = DictUtils.getDictList("finance_cost_supervisor");
             for (DictValue a :
-                    supCost) {
+                    conCOst) {
                 String label = a.getLabel();
                 if (supplierName.equals(label)) {
                     erpCredit.setOtherSupervisorFee(DoubleUtil.add(erpCredit.getOtherSupervisorFee(),lineItemAmount));
@@ -1019,7 +1019,7 @@ public  class ErpInfo {
 //    }
     /**
      * 获取材料的list集合
-     * @param erpAccounts 导入的表格 bean对象
+     * @param
      * @return 材料 list金额
      */
 //    public static List<ErpCreditMaterial> getListErpCreditChild2(List<ErpAccount> erpAccounts){

+ 1 - 1
src/main/java/com/jeeplus/modules/sg/financial/settlement/mapper/DonorMaterialMapper.java

@@ -99,7 +99,7 @@ public interface DonorMaterialMapper extends BaseMapper<DonorMaterial> {
      * @param code 物料编号
      * @return 判断项目是否存在
      */
-    int findDonor(@Param("projectId") String projectId,@Param("code") String code);
+    int findDonor(@Param("projectId") String projectId,@Param("code") String code,@Param("describe")String describe);
 
     /**
      * 更新项目的erp数量

+ 1 - 0
src/main/java/com/jeeplus/modules/sg/financial/settlement/mapper/xml/DonorMaterialMapper.xml

@@ -261,6 +261,7 @@
 		select count(id) from finance_project_donor_material
 		where material_code = #{code}
 		and project_id = #{projectId}
+		and materail_describe = #{describe}
 	</select>
 
 	<update id="updateErpOne">

+ 2 - 1
src/main/java/com/jeeplus/modules/sg/financial/settlement/service/DonorMaterialService.java

@@ -298,8 +298,9 @@ public class DonorMaterialService extends CrudService<DonorMaterialMapper, Donor
             //通过项目定义号,物料描述更新项目的erp数量
             for (ErpCreditMaterial material : list) {
                 String code = material.getEqmMaterialCode();
+                String describe = material.getEqmMaterialDetails2();
                 //通过设备物料描述,项目定义号,查询物料是否存在,存在更新,不存在插入
-                int donor = donorMaterialMapper.findDonor(projectId, code);
+                int donor = donorMaterialMapper.findDonor(projectId, code,describe);
                 //更新
                 BigDecimal bigDecimal = new BigDecimal( material.getMtlNumbers());
                 BigDecimal bigDecimal1 = bigDecimal.setScale(4, BigDecimal.ROUND_HALF_UP);

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


+ 126 - 0
src/main/webapp/webpage/modules/sg/balancedlibrary/materialReportDetails/LikuResults.js

@@ -0,0 +1,126 @@
+<%@ page contentType="text/html;charset=UTF-8" %>
+<script>
+$(document).ready(function() {
+	$('#leave1Table').bootstrapTable({
+		 
+		  //请求方法
+               method: 'post',
+               //类型json
+               dataType: "json",
+               contentType: "application/x-www-form-urlencoded",
+               //显示检索按钮
+	           showSearch: false,
+               //显示刷新按钮
+               showRefresh: false,
+               //显示切换手机试图按钮
+               showToggle: false,
+               //显示 内容列下拉框
+    	       showColumns: false,
+    	       //显示到处按钮
+    	       showExport: false,
+    	       //显示切换分页按钮
+    	       showPaginationSwitch: false,
+    	       //最低显示2行
+    	       minimumCountColumns: 2,
+               //是否显示行间隔色
+               striped: true,
+               //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)     
+               cache: false,    
+               //是否显示分页(*)  
+               pagination: false,
+                //排序方式 
+               sortOrder: "asc",  
+               //初始化加载第一页,默认第一页
+               pageNumber:1,   
+               //每页的记录行数(*)   
+               pageSize: 10,  
+               //可供选择的每页的行数(*)    
+               pageList: [10, 25, 50, 100],
+               //这个接口需要处理bootstrap table传递的固定参数,并返回特定格式的json数据  
+               url: "${ctx}/MaterialReportDetails/likuResultsData",
+               //默认值为 'limit',传给服务端的参数为:limit, offset, search, sort, order Else
+               //queryParamsType:'',   
+               ////查询参数,每次调用是会带上这个参数,可自定义                         
+               queryParams : function(params) {
+               	var searchParam = $("#searchForm").serializeJSON();
+                   return searchParam;
+               },
+               //分页方式:client客户端分页,server服务端分页(*)
+               sidePagination: "server",
+               contextMenuTrigger:"right",//pc端 按右键弹出菜单
+               contextMenuTriggerMobile:"press",//手机端 弹出菜单,click:单击, press:长按。
+               contextMenu: '#context-menu',
+               onContextMenuItem: function(row, $el){
+                   if($el.data("item") == "edit"){
+                   		edit(row.id);
+                   }else if($el.data("item") == "view"){
+                       view(row.id);
+                   } else if($el.data("item") == "delete"){
+                        jp.confirm('确认要删除该利库资源记录吗?', function(){
+                       	jp.loading();
+                       	jp.get("${ctx}/MaterialReportDetails/delete?id="+row.id, function(data){
+                   	  		if(data.success){
+                   	  			$('#leave1Table').bootstrapTable('refresh');
+                   	  			jp.success(data.msg);
+                   	  		}else{
+                   	  			jp.error(data.msg);
+                   	  		}
+                   	  	})
+
+                   	});
+
+                   }
+               },
+
+               onClickRow: function(row, $el){
+               },
+               	onShowSearch: function () {
+					$("#search-collapse").slideToggle();
+				},
+				columns: [{
+					field: 'nameOfReserve',
+					title: '储备项目名称',
+					sortable: true,
+					sortName: 'nameOfReserve'
+
+				}
+				,{
+					field: 'materialCode',
+					title: '物料编码',
+					sortable: true,
+					sortName: 'materialCode'
+
+				}
+				,{
+					field: 'comparisonType',
+					title: '利库类型',
+					sortable: true,
+					sortName: 'materialName'
+
+				}
+				,{
+					field: 'batch',
+					title: '批次号',
+					sortable: true,
+					sortName: 'batch'
+
+				}
+				,{
+					field: 'warehouse',
+					title: '库存地',
+					sortable: true,
+					sortName: 'warehouse'
+
+				}
+				,{
+					field: 'numberNiches',
+					title: '利库数量',
+					sortable: true,
+					sortName: 'numberNiches'
+
+				}]
+
+		});
+
+});
+</script>

+ 36 - 0
src/main/webapp/webpage/modules/sg/balancedlibrary/materialReportDetails/LikuResults.jsp

@@ -0,0 +1,36 @@
+<%@ page contentType="text/html;charset=UTF-8" %>
+<%@ include file="/webpage/include/taglib.jsp"%>
+<html>
+<head>
+	<title>利库资源池管理</title>
+	<meta http-equiv="Content-type" content="text/html; charset=utf-8">
+	<meta name="decorator" content="ani"/>
+	<%@ include file="/webpage/include/bootstraptable.jsp"%>
+	<%@include file="/webpage/include/treeview.jsp" %>
+	<%@include file="LikuResults.js" %>
+</head>
+<body>
+	<div class="wrapper wrapper-content">
+	<div class="panel panel-primary">
+	<%--<div class="panel-heading">--%>
+		<%--<h3 class="panel-title">利库详情</h3>--%>
+	<%--</div>--%>
+	<div class="panel-body">
+	
+	<!-- 搜索 -->
+	<div id="search-collapse" class="collapse">
+		<div class="accordion-inner">
+			<form:form id="searchForm" modelAttribute="entity" class="form form-horizontal well clearfix">
+				<form:hidden path="id"/>
+			</form:form>
+		</div>
+	</div>
+
+	<!-- 表格 -->
+	<table id="leave1Table"   data-toolbar="#toolbar"></table>
+
+	</div>
+	</div>
+	</div>
+</body>
+</html>

+ 114 - 111
src/main/webapp/webpage/modules/sg/balancedlibrary/materialReportDetails/MaterialReportDetailsList.js

@@ -84,187 +84,186 @@ $(document).ready(function() {
 				   field: 'reportingArea',
 				   title: '上报地区',
 				   sortable: true,
-				   sortName: 'reportingArea'
+				   sortName: 'reportingArea',
+                   formatter:function(value, row , index){
+                       if(row.numberOfNiches > 0){
+                           return "<a style='color:red'>" + value + "</a>";
+                       }else{
+                           return value;
+                       }
+                   }
 
 			   }
 			,{
 		        field: 'nameOfReserve',
 		        title: '储备项目名称',
 		        sortable: true,
-		        sortName: 'nameOfReserve'
+                       formatter:function(value, row , index){
+                           if(row.numberOfNiches > 0){
+                               return "<a style='color:red'>" + value + "</a>";
+                           }else{
+                               return value;
+                           }
+                       },
+                       sortName: 'nameOfReserve'
 
 		    }
 			,{
 		        field: 'materialCode',
 		        title: '物料编码',
 		        sortable: true,
-		        sortName: 'materialCode'
+                       formatter:function(value, row , index){
+                           if(row.numberOfNiches > 0){
+                               return "<a style='color:red'>" + value + "</a>";
+                           }else{
+                               return value;
+                           }
+                       },
+                       sortName: 'materialCode'
 
 		    }
 			,{
 		        field: 'materialName',
 		        title: '物料名称',
 		        sortable: true,
-		        sortName: 'materialName'
+                       formatter:function(value, row , index){
+                           if(row.numberOfNiches > 0){
+                               return "<a style='color:red'>" + value + "</a>";
+                           }else{
+                               return value;
+                           }
+                       },
+                       sortName: 'materialName'
 
 		    }
 			,{
 		        field: 'extendedCoding',
 		        title: '扩展编码',
 		        sortable: true,
-		        sortName: 'extendedCoding'
+                       formatter:function(value, row , index){
+                           if(row.numberOfNiches > 0){
+                               return "<a style='color:red'>" + value + "</a>";
+                           }else{
+                               return value;
+                           }
+                       },
+                       sortName: 'extendedCoding'
 
 		    }
 			,{
 		        field: 'extendedDescription',
 		        title: '扩展描述',
 		        sortable: true,
-		        sortName: 'extendedDescription'
+                       formatter:function(value, row , index){
+                           if(row.numberOfNiches > 0){
+                               return "<a style='color:red'>" + value + "</a>";
+                           }else{
+                               return value;
+                           }
+                       },
+                       sortName: 'extendedDescription'
 
 		    }
 				   ,{
 					   field: 'unit',
 					   title: '单位',
 					   sortable: true,
-					   sortName: 'unit'
+                       formatter:function(value, row , index){
+                           if(row.numberOfNiches > 0){
+                               return "<a style='color:red'>" + value + "</a>";
+                           }else{
+                               return value;
+                           }
+                       },
+                       sortName: 'unit'
 
 				   }
 				   ,{
 					   field: 'total',
 					   title: '总量',
 					   sortable: true,
-					   sortName: 'total'
+                       formatter:function(value, row , index){
+                           if(row.numberOfNiches > 0){
+                               return "<a style='color:red'>" + value + "</a>";
+                           }else{
+                               return value;
+                           }
+                       },
+                       sortName: 'total'
 
 				   }
 				   ,{
 					   field: 'unitWeight',
 					   title: '单重/kg',
 					   sortable: true,
-					   sortName: 'unitWeight'
+                       formatter:function(value, row , index){
+                           if(row.numberOfNiches > 0){
+                               return "<a style='color:red'>" + value + "</a>";
+                           }else{
+                               return value;
+                           }
+                       },
+                       sortName: 'unitWeight'
 
 				   }
 				   ,{
 					   field: 'totalWeight',
 					   title: '总重/吨',
 					   sortable: true,
-					   sortName: 'totalWeight'
+                       formatter:function(value, row , index){
+                           if(row.numberOfNiches > 0){
+                               return "<a style='color:red'>" + value + "</a>";
+                           }else{
+                               return value;
+                           }
+                       },
+                       sortName: 'totalWeight'
 
 				   }
 				   ,{
 					   field: 'supplied',
 					   title: '甲乙供',
 					   sortable: true,
-					   sortName: 'supplied'
+                       formatter:function(value, row , index){
+                           if(row.numberOfNiches > 0){
+                               return "<a style='color:red'>" + value + "</a>";
+                           }else{
+                               return value;
+                           }
+                       },
+                       sortName: 'supplied'
 
 				   }
 				   ,{
 					   field: 'numberOfNiches',
 					   title: '利库数量',
 					   sortable: true,
-					   sortName: 'numberOfNiches'
+					   sortName: 'numberOfNiches',
+                       formatter:function(value, row , index){
+                           if(value != 0){
+                               return "<a href='javascript:likuResults(\"" + row.id + "\")'>" + value + "</a>";
+                           }else{
+                           		return value;
+						   }
+                       }
 
 				   }
 				   ,{
 					   field: 'numberOfApplications',
-					   title: '申请数量',
-					   sortable: true,
-					   sortName: 'numberOfApplications'
-
-				   }
-				   ,{
-					   field: 'localWareBatch',
-					   title: '本地利库批次号',
-					   sortable: true,
-					   sortName: 'localWareBatch'
-
-				   }
-				   ,{
-					   field: 'localWareHouse',
-					   title: '本地利库库存地',
-					   sortable: true,
-					   sortName: 'localWareHouse'
-
-				   }
-				   ,{
-					   field: 'numberOfLocal',
-					   title: '本地利库数量',
-					   sortable: true,
-					   sortName: 'numberOfLocal'
-
-				   }
-				   ,{
-					   field: 'regionalBatch',
-					   title: '跨区利库批次号',
-					   sortable: true,
-					   sortName: 'regionalBatch'
-
-				   }
-				   ,{
-					   field: 'regionalHouse',
-					   title: '跨区利库库存地',
-					   sortable: true,
-					   sortName: 'regionalHouse'
-
-				   }
-				   ,{
-					   field: 'numberOfRegional',
-					   title: '跨区利库数量',
+					   title: '经利库后申报数量',
+					   width: '10%',
 					   sortable: true,
-					   sortName: 'numberOfRegional'
+                       formatter:function(value, row , index){
+                           if(row.numberOfNiches > 0){
+                               return "<a style='color:red'>" + value + "</a>";
+                           }else{
+                               return value;
+                           }
+                       },
+                       sortName: 'numberOfApplications'
 
 				   }
-				   ,{
-					   field: 'localLiKuModel',
-					   title: '本地以大代小利库型号',
-					   sortable: true,
-					   sortName: 'localLiKuModel'
 
-				   }
-				   ,{
-					   field: 'localLiKuBatch',
-					   title: '本地以大代小利库批次号',
-					   sortable: true,
-					   sortName: 'localLiKuBatch'
-
-				   }
-				   ,{
-					   field: 'localLiKuWareHouse',
-					   title: '本地以大代小利库库存地',
-					   sortable: true,
-					   sortName: 'localLiKuWareHouse'
-
-				   }
-				   ,{
-					   field: 'numberOfLocalLiKu',
-					   title: '本地以大代小利库数量',
-					   sortable: true,
-					   sortName: 'numberOfLocalLiKu'
-
-				   },{
-					   field: 'regionLiKuModel',
-					   title: '跨区以大代小利库型号',
-					   sortable: true,
-					   sortName: 'regionLiKuModel'
-
-				   },{
-					   field: 'regionLiKuBatch',
-					   title: '跨区以大代小利库批次号',
-					   sortable: true,
-					   sortName: 'regionLiKuBatch'
-
-				   },{
-					   field: 'regionLiKuWareHouse',
-					   title: '跨区以大代小利库库存地',
-					   sortable: true,
-					   sortName: 'regionLiKuWareHouse'
-
-				   },{
-					   field: 'numberOfRegionalLiKu',
-					   title: '跨区以大代小利库数量',
-					   sortable: true,
-					   sortName: 'numberOfRegionalLiKu'
-
-				   }
 		     ]
 
 		});
@@ -298,7 +297,7 @@ $(document).ready(function() {
 					iframeWin.contentWindow.importExcel('${ctx}/MaterialReportDetails/import', function (data) {
 						if(data.success){
 							jp.success(data.msg);
-							jp.downloadFile('${ctx}/MaterialReportDetails/export','finalAccount');//给个name是为了能够在某些条件下下载两个文件							refresh();
+							// jp.downloadFile('${ctx}/MaterialReportDetails/export','finalAccount');//给个name是为了能够在某些条件下下载两个文件							refresh();
 							refresh();
 						}else{
 							jp.error(data.msg);
@@ -376,8 +375,8 @@ $(document).ready(function() {
 
 
 
-   function edit(id){//没有权限时,不显示确定按钮
-       if(id == undefined){
+  function edit(id){//没有权限时,不显示确定按钮
+  	if(id == undefined){
 	      id = getIdSelections();
 	}
 	jp.openSaveDialog('编辑利库资源', "${ctx}/MaterialReportDetails/form?id=" + id, '800px', '500px');
@@ -387,7 +386,11 @@ $(document).ready(function() {
       if(id == undefined){
              id = getIdSelections();
       }
-        jp.openViewDialog('查看利库资源', "${ctx}/MaterialReportDetails/form?id=" + id, '800px', '500px');
+      jp.openViewDialog('查看利库资源', "${ctx}/MaterialReportDetails/form?id=" + id, '800px', '500px');
+ }
+
+ function likuResults(id){
+     jp.openViewDialog('利库明细', "${ctx}/MaterialReportDetails/likuResults?id=" + id, '1000px', '600px');
  }
 
 

+ 395 - 0
src/main/webapp/webpage/modules/sg/balancedlibrary/materialReportDetails/MaterialReportDetailsList_1.js

@@ -0,0 +1,395 @@
+<%@ page contentType="text/html;charset=UTF-8" %>
+<script>
+$(document).ready(function() {
+	$('#leave1Table').bootstrapTable({
+		 
+		  //请求方法
+               method: 'post',
+               //类型json
+               dataType: "json",
+               contentType: "application/x-www-form-urlencoded",
+               //显示检索按钮
+	           showSearch: true,
+               //显示刷新按钮
+               showRefresh: true,
+               //显示切换手机试图按钮
+               showToggle: true,
+               //显示 内容列下拉框
+    	       showColumns: true,
+    	       //显示到处按钮
+    	       showExport: true,
+    	       //显示切换分页按钮
+    	       showPaginationSwitch: true,
+    	       //最低显示2行
+    	       minimumCountColumns: 2,
+               //是否显示行间隔色
+               striped: true,
+               //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)     
+               cache: false,    
+               //是否显示分页(*)  
+               pagination: true,   
+                //排序方式 
+               sortOrder: "asc",  
+               //初始化加载第一页,默认第一页
+               pageNumber:1,   
+               //每页的记录行数(*)   
+               pageSize: 10,  
+               //可供选择的每页的行数(*)    
+               pageList: [10, 25, 50, 100],
+               //这个接口需要处理bootstrap table传递的固定参数,并返回特定格式的json数据  
+               url: "${ctx}/MaterialReportDetails/data",
+               //默认值为 'limit',传给服务端的参数为:limit, offset, search, sort, order Else
+               //queryParamsType:'',   
+               ////查询参数,每次调用是会带上这个参数,可自定义                         
+               queryParams : function(params) {
+               	var searchParam = $("#searchForm").serializeJSON();
+               	searchParam.pageNo = params.limit === undefined? "1" :params.offset/params.limit+1;
+               	searchParam.pageSize = params.limit === undefined? -1 : params.limit;
+               	searchParam.orderBy = params.sort === undefined? "" : params.sort+ " "+  params.order;
+                   return searchParam;
+               },
+               //分页方式:client客户端分页,server服务端分页(*)
+               sidePagination: "server",
+               contextMenuTrigger:"right",//pc端 按右键弹出菜单
+               contextMenuTriggerMobile:"press",//手机端 弹出菜单,click:单击, press:长按。
+               contextMenu: '#context-menu',
+               onContextMenuItem: function(row, $el){
+                   if($el.data("item") == "edit"){
+                   		edit(row.id);
+                   }else if($el.data("item") == "view"){
+                       view(row.id);
+                   } else if($el.data("item") == "delete"){
+                        jp.confirm('确认要删除该利库资源记录吗?', function(){
+                       	jp.loading();
+                       	jp.get("${ctx}/MaterialReportDetails/delete?id="+row.id, function(data){
+                   	  		if(data.success){
+                   	  			$('#leave1Table').bootstrapTable('refresh');
+                   	  			jp.success(data.msg);
+                   	  		}else{
+                   	  			jp.error(data.msg);
+                   	  		}
+                   	  	})
+
+                   	});
+
+                   }
+               },
+
+               onClickRow: function(row, $el){
+               },
+               	onShowSearch: function () {
+			$("#search-collapse").slideToggle();
+		},
+               columns: [{
+				   field: 'reportingArea',
+				   title: '上报地区',
+				   sortable: true,
+				   sortName: 'reportingArea'
+
+			   }
+			,{
+		        field: 'nameOfReserve',
+		        title: '储备项目名称',
+		        sortable: true,
+		        sortName: 'nameOfReserve'
+
+		    }
+			,{
+		        field: 'materialCode',
+		        title: '物料编码',
+		        sortable: true,
+		        sortName: 'materialCode'
+
+		    }
+			,{
+		        field: 'materialName',
+		        title: '物料名称',
+		        sortable: true,
+		        sortName: 'materialName'
+
+		    }
+			,{
+		        field: 'extendedCoding',
+		        title: '扩展编码',
+		        sortable: true,
+		        sortName: 'extendedCoding'
+
+		    }
+			,{
+		        field: 'extendedDescription',
+		        title: '扩展描述',
+		        sortable: true,
+		        sortName: 'extendedDescription'
+
+		    }
+				   ,{
+					   field: 'unit',
+					   title: '单位',
+					   sortable: true,
+					   sortName: 'unit'
+
+				   }
+				   ,{
+					   field: 'total',
+					   title: '总量',
+					   sortable: true,
+					   sortName: 'total'
+
+				   }
+				   ,{
+					   field: 'unitWeight',
+					   title: '单重/kg',
+					   sortable: true,
+					   sortName: 'unitWeight'
+
+				   }
+				   ,{
+					   field: 'totalWeight',
+					   title: '总重/吨',
+					   sortable: true,
+					   sortName: 'totalWeight'
+
+				   }
+				   ,{
+					   field: 'supplied',
+					   title: '甲乙供',
+					   sortable: true,
+					   sortName: 'supplied'
+
+				   }
+				   ,{
+					   field: 'numberOfNiches',
+					   title: '利库数量',
+					   sortable: true,
+					   sortName: 'numberOfNiches'
+
+				   }
+				   ,{
+					   field: 'numberOfApplications',
+					   title: '申请数量',
+					   sortable: true,
+					   sortName: 'numberOfApplications'
+
+				   }
+				   ,{
+					   field: 'localWareBatch',
+					   title: '本地利库批次号',
+					   sortable: true,
+					   sortName: 'localWareBatch'
+
+				   }
+				   ,{
+					   field: 'localWareHouse',
+					   title: '本地利库库存地',
+					   sortable: true,
+					   sortName: 'localWareHouse'
+
+				   }
+				   ,{
+					   field: 'numberOfLocal',
+					   title: '本地利库数量',
+					   sortable: true,
+					   sortName: 'numberOfLocal'
+
+				   }
+				   ,{
+					   field: 'regionalBatch',
+					   title: '跨区利库批次号',
+					   sortable: true,
+					   sortName: 'regionalBatch'
+
+				   }
+				   ,{
+					   field: 'regionalHouse',
+					   title: '跨区利库库存地',
+					   sortable: true,
+					   sortName: 'regionalHouse'
+
+				   }
+				   ,{
+					   field: 'numberOfRegional',
+					   title: '跨区利库数量',
+					   sortable: true,
+					   sortName: 'numberOfRegional'
+
+				   }
+				   ,{
+					   field: 'localLiKuModel',
+					   title: '本地以大代小利库型号',
+					   sortable: true,
+					   sortName: 'localLiKuModel'
+
+				   }
+				   ,{
+					   field: 'localLiKuBatch',
+					   title: '本地以大代小利库批次号',
+					   sortable: true,
+					   sortName: 'localLiKuBatch'
+
+				   }
+				   ,{
+					   field: 'localLiKuWareHouse',
+					   title: '本地以大代小利库库存地',
+					   sortable: true,
+					   sortName: 'localLiKuWareHouse'
+
+				   }
+				   ,{
+					   field: 'numberOfLocalLiKu',
+					   title: '本地以大代小利库数量',
+					   sortable: true,
+					   sortName: 'numberOfLocalLiKu'
+
+				   },{
+					   field: 'regionLiKuModel',
+					   title: '跨区以大代小利库型号',
+					   sortable: true,
+					   sortName: 'regionLiKuModel'
+
+				   },{
+					   field: 'regionLiKuBatch',
+					   title: '跨区以大代小利库批次号',
+					   sortable: true,
+					   sortName: 'regionLiKuBatch'
+
+				   },{
+					   field: 'regionLiKuWareHouse',
+					   title: '跨区以大代小利库库存地',
+					   sortable: true,
+					   sortName: 'regionLiKuWareHouse'
+
+				   },{
+					   field: 'numberOfRegionalLiKu',
+					   title: '跨区以大代小利库数量',
+					   sortable: true,
+					   sortName: 'numberOfRegionalLiKu'
+
+				   }
+		     ]
+
+		});
+
+
+	  if(navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i)){//如果是移动端
+
+
+		  $('#leave1Table').bootstrapTable("toggleView");
+		}
+
+	  $('#leave1Table').on('check.bs.table uncheck.bs.table load-success.bs.table ' +
+                'check-all.bs.table uncheck-all.bs.table', function () {
+            $('#remove').prop('disabled', ! $('#leave1Table').bootstrapTable('getSelections').length);
+            $('#view,#edit').prop('disabled', $('#leave1Table').bootstrapTable('getSelections').length!=1);
+        });
+
+		$("#btnImport").click(function(){
+			jp.open({
+				type: 2,
+				area: [500, 200],
+				auto: true,
+				title:"导入数据",
+				content: "${ctx}/tag/importExcel" ,
+				btn: ['下载模板','确定', '关闭'],
+				btn1: function(index, layero){
+					jp.downloadFile('${ctx}/MaterialReportDetails/import/template');
+				},
+				btn2: function(index, layero){
+					var iframeWin = layero.find('iframe')[0]; //得到iframe页的窗口对象,执行iframe页的方法:iframeWin.method();
+					iframeWin.contentWindow.importExcel('${ctx}/MaterialReportDetails/import', function (data) {
+						if(data.success){
+							jp.success(data.msg);
+							// jp.downloadFile('${ctx}/MaterialReportDetails/export','finalAccount');//给个name是为了能够在某些条件下下载两个文件							refresh();
+							refresh();
+						}else{
+							jp.error(data.msg);
+						}
+						jp.close(index);
+					});//调用保存事件
+					return false;
+				},
+
+				btn3: function(index){
+					//  jp.close(index);
+				}
+			});
+		});
+
+
+	 $("#export").click(function(){//导出Excel文件
+			jp.downloadFile('${ctx}/MaterialReportDetails/export');
+	  });
+
+
+	  $("#search").click("click", function() {// 绑定查询按扭
+		  $('#leave1Table').bootstrapTable('refresh');
+		});
+
+	 $("#reset").click("click", function() {// 绑定查询按扭
+		  $("#searchForm  input").val("");
+		  $("#searchForm  select").val("");
+		  $("#searchForm  .select-item").html("");
+		  $('#leave1Table').bootstrapTable('refresh');
+		});
+
+		$('#beginBeginDate').datetimepicker({
+			 format: "YYYY-MM-DD HH:mm:ss"
+		});
+		$('#endBeginDate').datetimepicker({
+			 format: "YYYY-MM-DD HH:mm:ss"
+		});
+		$('#endDate').datetimepicker({
+			 format: "YYYY-MM-DD HH:mm:ss"
+		});
+
+	});
+
+  function getIdSelections() {
+        return $.map($("#leave1Table").bootstrapTable('getSelections'), function (row) {
+            return row.id
+        });
+    }
+
+  function deleteAll(){
+
+		jp.confirm('确认要删除该利库资源记录吗?', function(){
+			jp.loading();
+			jp.get("${ctx}/MaterialReportDetails/deleteAll?ids=" + getIdSelections(), function(data){
+         	  		if(data.success){
+         	  			$('#leave1Table').bootstrapTable('refresh');
+         	  			jp.success(data.msg);
+         	  		}else{
+         	  			jp.error(data.msg);
+         	  		}
+         	  	})
+
+		})
+  }
+
+    //刷新列表
+  function refresh(){
+  	$('#leave1Table').bootstrapTable('refresh');
+  }
+
+   function add(){
+	  jp.openSaveDialog('新增利库资源', "${ctx}/MaterialReportDetails/form",'800px', '500px');
+  }
+
+
+
+   function edit(id){//没有权限时,不显示确定按钮
+       if(id == undefined){
+	      id = getIdSelections();
+	}
+	jp.openSaveDialog('编辑利库资源', "${ctx}/MaterialReportDetails/form?id=" + id, '800px', '500px');
+  }
+
+ function view(id){//没有权限时,不显示确定按钮
+      if(id == undefined){
+             id = getIdSelections();
+      }
+        jp.openViewDialog('查看利库资源', "${ctx}/MaterialReportDetails/form?id=" + id, '800px', '500px');
+ }
+
+
+
+</script>

+ 20 - 12
src/main/webapp/webpage/modules/sg/balancedlibrary/materialReportDetails/MaterialReportDetailslList.jsp

@@ -18,13 +18,25 @@
 	<div class="panel-body">
 	
 	<!-- 搜索 -->
-	<%--<div id="search-collapse" class="collapse">
+	<div id="search-collapse" class="collapse">
 		<div class="accordion-inner">
 			<form:form id="searchForm" modelAttribute="entity" class="form form-horizontal well clearfix">
-			 <div class="col-xs-12 col-sm-6 col-md-4">
-				<label class="label-item single-overflow pull-left" title="物料编码:">物料编码:</label>
-				<form:input path="materialCode" htmlEscape="false" maxlength="257"  class=" form-control"/>
-			</div>
+			 	<div class="col-xs-12 col-sm-6 col-md-4">
+					<label class="label-item single-overflow pull-left" title="储备项目名称:">储备项目名称:</label>
+					<form:input path="nameOfReserve" htmlEscape="false" maxlength="257"  class=" form-control"/>
+				</div>
+				<div class="col-xs-12 col-sm-6 col-md-4">
+					<label class="label-item single-overflow pull-left" title="物料编码:">物料编码:</label>
+					<form:input path="materialCode" htmlEscape="false" maxlength="257"  class=" form-control"/>
+				</div>
+				<div class="col-xs-12 col-sm-6 col-md-4">
+					<label class="label-item single-overflow pull-left" title="是否利库:">是否利库:</label>
+					<form:select path="numberOfNiches"  class="form-control m-b">
+						<form:option value="" label=""/>
+						<form:option value="1" label="是"/>
+						<form:option value="0" label="否"/>
+					</form:select>
+				</div>
 		 <div class="col-xs-12 col-sm-6 col-md-4">
 			<div style="margin-top:26px">
 			  <a  id="search" class="btn btn-primary btn-rounded  btn-bordered btn-sm"><i class="fa fa-search"></i> 查询</a>
@@ -33,7 +45,7 @@
 	    </div>	
 	</form:form>
 	</div>
-	</div>--%>
+	</div>
 	
 	<!-- 工具栏 -->
 	<div id="toolbar">
@@ -49,7 +61,7 @@
 			</shiro:hasPermission>
 			<shiro:hasPermission name="sg:balancedlibrary:liKuResourcePool:export">
 				<button id="export" class="btn btn-warning">
-					<i class="fa fa-file-excel-o"></i> 导出
+					<i class="fa fa-file-excel-o"></i> 导出利库情况
 				</button>
 			 </shiro:hasPermission>
 		    </div>
@@ -59,11 +71,7 @@
 
     <!-- context menu -->
     <ul id="context-menu" class="dropdown-menu">
-<%--        <shiro:hasPermission name="sg:balancedlibrary:liKuResourcePool:del">
-        <li data-item="delete"><a>删除</a></li>
-        </shiro:hasPermission>
-        <li data-item="action1"><a>取消</a></li>--%>
-    </ul>  
+    </ul>
 	</div>
 	</div>
 	</div>

+ 17 - 0
src/main/webapp/webpage/modules/sg/financial/settlement/donorMaterialList.js

@@ -100,6 +100,9 @@
             },
             onClickRow: function (row, $el) {
             },
+            onLoadSuccess: function () {  //加载成功时执行
+                getTdValue();
+            },
             onShowSearch: function () {
                 $("#search-collapse").slideToggle();
             },
@@ -243,6 +246,7 @@
         // 绑定查询按扭
         $("#search").click("click", function () {
             $('#dataTable').bootstrapTable('refresh');
+            getTdValue();
         });
 
         // 绑定查询按扭
@@ -251,6 +255,7 @@
             $("#searchForm  select").val("");
             $("#searchForm  .select-item").html("");
             $('#dataTable').bootstrapTable('refresh');
+            getTdValue();
         });
     });
 
@@ -259,6 +264,18 @@ function getIdSelections() {
         return row.projectId
     });
 }
+function getTdValue() {
+    var tableId = document.getElementById("dataTable");
+    if (tableId.rows.length>=2){
+        if (tableId.rows[1].cells[0].innerHTML != '没有找到匹配的记录'){
+            for(var i = 1;i <tableId.rows.length;i++) {
+                if(tableId.rows[i].cells[10].innerHTML!="0"){
+                    tableId.rows[i].cells[10].setAttribute("style","color: red;vertical-align:middle;");
+                }
+            }
+        }
+    }
+}