Ver Fonte

面辅料调整,成衣优化查询速度

huxy há 1 ano atrás
pai
commit
d57b92274c

+ 42 - 5
jeecg-boot-module-system/src/main/java/org/jeecg/modules/splfi/controller/SyPackingListFabricController.java

@@ -20,6 +20,7 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
 import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.jeecg.common.exception.JeecgBootException;
 import org.jeecg.common.system.vo.LoginUser;
@@ -771,8 +772,27 @@ public class SyPackingListFabricController implements Job {
 						 }
 					 }
 					 if(cell!=null){
-						 cell.setCellType(CellType.STRING);//获取的都转换成String
-						 itemStrs.add(cell.toString());
+//						 cell.setCellType(CellType.STRING);//获取的都转换成String
+//						 itemStrs.add(cell.toString());
+						 FormulaEvaluator formulaEvaluator = new XSSFFormulaEvaluator((XSSFWorkbook) workbook1);
+						 //获取单元格内容的类型 =R17-Q17*0.35
+						 CellType cellType = cell.getCellType();
+						 //System.out.println("是公式吗\t"+(cellType.equals(CellType.FORMULA)==true?"是":"否"));
+						 //判断是否存储的为公式,此处本可以不加判断
+						 if (cellType.equals(CellType.FORMULA)){
+							// System.out.println("formula cell\t"+cell);
+							 //获取公式,可以理解为已String类型获取cell的值输出
+							 String cellFormula = cell.getCellFormula();
+							 //System.out.println(cellFormula);
+							 //执行公式,此处cell的值就是公式
+							 CellValue evaluate = formulaEvaluator.evaluate(cell);
+							 //System.out.println(evaluate.formatAsString());
+							 itemStrs.add(evaluate.formatAsString());
+						 }else{
+							// System.out.println("string cell\t"+cell);
+							 cell.setCellType(CellType.STRING);//获取的都转换成String
+							 itemStrs.add(cell.toString());
+						 }
 					 }else{
 						 itemStrs.add("");
 					 }
@@ -847,14 +867,31 @@ public class SyPackingListFabricController implements Job {
 							 }
 						 }
 						 if(cell!=null){
-							 cell.setCellType(CellType.STRING);//获取的都转换成String
-							 itemStrs.add(cell.toString());
+							 FormulaEvaluator formulaEvaluator = new XSSFFormulaEvaluator((XSSFWorkbook) workbook1);
+							 //获取单元格内容的类型 =R17-Q17*0.35
+							 CellType cellType = cell.getCellType();
+							 //System.out.println("是公式吗\t"+(cellType.equals(CellType.FORMULA)==true?"是":"否"));
+							 //判断是否存储的为公式,此处本可以不加判断
+							 if (cellType.equals(CellType.FORMULA)){
+								 //System.out.println("formula cell\t"+cell);
+								 //获取公式,可以理解为已String类型获取cell的值输出
+								 String cellFormula = cell.getCellFormula();
+								 //System.out.println(cellFormula);
+								 //执行公式,此处cell的值就是公式
+								 CellValue evaluate = formulaEvaluator.evaluate(cell);
+								 //System.out.println(evaluate.formatAsString());
+								 itemStrs.add(evaluate.formatAsString());
+							 }else{
+								 //System.out.println("string cell\t"+cell);
+								 cell.setCellType(CellType.STRING);//获取的都转换成String
+								 itemStrs.add(cell.toString());
+							 }
 						 }else{
 							 itemStrs.add("");
 						 }
 
 						 /*FormulaEvaluator formulaEvaluator = new XSSFFormulaEvaluator((XSSFWorkbook) workbook1);
-						 //获取单元格内容的类型
+						 //获取单元格内容的类型 =R17-Q17*0.35
 						 CellType cellType = cell.getCellType();
 						 //判断是否存储的为公式,此处本可以不加判断
 						 if (cellType.equals(CellType.FORMULA)){

+ 12 - 12
jeecg-boot-module-system/src/main/java/org/jeecg/modules/splfi/service/impl/SyPackingListFabricServiceImpl.java

@@ -1388,18 +1388,18 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 				for (SyPackingListFabricItem item : main.getSyPackingListFabricItem()){
 					//System.out.println("inventoryCcode\t"+item.getInventoryCcode());
 					if(item.getInventoryCcode().indexOf("04")!=-1||item.getInventoryCcode().indexOf("03")!=-1){
-						booleanMap.put(item.getInventoryCode()+item.getPlanLotNumber()+item.getColour()+item.getWidth(),false);//存货编码+计划单号+颜色+门幅
-						if(bigDecimalMap.containsKey(item.getInventoryCode()+item.getPlanLotNumber()+item.getColour()+item.getWidth())){//再次
+						booleanMap.put(item.getInventoryCode()+item.getPlanLotNumber()+item.getColour()+item.getWidth()+item.getSyOrderDataItemId(),false);//存货编码+计划单号+颜色+门幅
+						if(bigDecimalMap.containsKey(item.getInventoryCode()+item.getPlanLotNumber()+item.getColour()+item.getWidth()+item.getSyOrderDataItemId())){//再次
 							if(item.getMasterMetering().equals("KG")){
-								bigDecimalMap.put(item.getInventoryCode()+item.getPlanLotNumber()+item.getColour()+item.getWidth(),bigDecimalMap.get(item.getInventoryCode()+item.getPlanLotNumber()+item.getColour()+item.getWidth()).add(item.getNetWeight()));
+								bigDecimalMap.put(item.getInventoryCode()+item.getPlanLotNumber()+item.getColour()+item.getWidth()+item.getSyOrderDataItemId(),bigDecimalMap.get(item.getInventoryCode()+item.getPlanLotNumber()+item.getColour()+item.getWidth()+item.getSyOrderDataItemId()).add(item.getNetWeight()));
 							}else{
-								bigDecimalMap.put(item.getInventoryCode()+item.getPlanLotNumber()+item.getColour()+item.getWidth(),item.getActualDeclaredQuantity().add(item.getActualDeclaredQuantity()));
+								bigDecimalMap.put(item.getInventoryCode()+item.getPlanLotNumber()+item.getColour()+item.getWidth()+item.getSyOrderDataItemId(),item.getActualDeclaredQuantity().add(item.getActualDeclaredQuantity()));
 							}
 						}else{//初次
 							if(item.getMasterMetering().equals("KG")){
-								bigDecimalMap.put(item.getInventoryCode()+item.getPlanLotNumber()+item.getColour()+item.getWidth(),item.getNetWeight());
+								bigDecimalMap.put(item.getInventoryCode()+item.getPlanLotNumber()+item.getColour()+item.getWidth()+item.getSyOrderDataItemId(),item.getNetWeight());
 							}else{
-								bigDecimalMap.put(item.getInventoryCode()+item.getPlanLotNumber()+item.getColour()+item.getWidth(),item.getActualDeclaredQuantity());
+								bigDecimalMap.put(item.getInventoryCode()+item.getPlanLotNumber()+item.getColour()+item.getWidth()+item.getSyOrderDataItemId(),item.getActualDeclaredQuantity());
 							}
 						}
 					}
@@ -1407,12 +1407,12 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 				}
 			}
 			for (SyPackingListFabricItem item : main.getSyPackingListFabricItem()){
-				if(mapt.get("account").equals("101")&&booleanMap.containsKey(item.getInventoryCode()+item.getPlanLotNumber()+item.getColour()+item.getWidth())){
-					System.out.println("inventoryCode\t"+item.getInventoryCode()+item.getPlanLotNumber()+item.getColour()+item.getWidth());
-					if(booleanMap.get(item.getInventoryCode()+item.getPlanLotNumber()+item.getColour()+item.getWidth())){//为true就退出循环
+				if(mapt.get("account").equals("101")&&booleanMap.containsKey(item.getInventoryCode()+item.getPlanLotNumber()+item.getColour()+item.getWidth()+item.getSyOrderDataItemId())){
+					System.out.println("inventoryCode\t"+item.getInventoryCode()+item.getPlanLotNumber()+item.getColour()+item.getWidth()+item.getSyOrderDataItemId());
+					if(booleanMap.get(item.getInventoryCode()+item.getPlanLotNumber()+item.getColour()+item.getWidth()+item.getSyOrderDataItemId())){//为true就退出循环
 						continue;
 					}else{
-						booleanMap.put(item.getInventoryCode()+item.getPlanLotNumber()+item.getColour()+item.getWidth(),true);
+						booleanMap.put(item.getInventoryCode()+item.getPlanLotNumber()+item.getColour()+item.getWidth()+item.getSyOrderDataItemId(),true);
 					}
 				}
 				JSONObject mapItem=new JSONObject();
@@ -1711,8 +1711,8 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 				}
 
 				if(mapt.get("account").equals("101")&&(item.getInventoryCcode().indexOf("04")!=-1||item.getInventoryCcode().indexOf("03")!=-1)){
-					mapItem.put("IQUANTITY",bigDecimalMap.get(item.getInventoryCode()+item.getPlanLotNumber()+item.getColour()+item.getWidth()));//入库单数量
-					mapItem5.put("IQUANTITY",bigDecimalMap.get(item.getInventoryCode()+item.getPlanLotNumber()+item.getColour()+item.getWidth()));//采购单数量
+					mapItem.put("IQUANTITY",bigDecimalMap.get(item.getInventoryCode()+item.getPlanLotNumber()+item.getColour()+item.getWidth()+item.getSyOrderDataItemId()));//入库单数量
+					mapItem5.put("IQUANTITY",bigDecimalMap.get(item.getInventoryCode()+item.getPlanLotNumber()+item.getColour()+item.getWidth()+item.getSyOrderDataItemId()));//采购单数量
 				}
 				//mapItem.put("INUM",orderDataItem.get("inum"));//明细ID(采购订单行ID/委外订单行ID)
 				//mapItem.put("cBatch","x");//批号

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/splt/mapper/xml/syPackingListTailoringMapper.xml

@@ -141,7 +141,7 @@
          b.small_Po,
          b.factory_Unit_Price
          FROM sy_packing_list_tailoring a
-         LEFT JOIN sy_packing_list_tailoring_item b
+         inner JOIN sy_packing_list_tailoring_item b
          ON a.id=b.sy_packing_list_tailoring_id and b.del_flag=0
          ${ew.customSqlSegment}
          GROUP BY a.id