Selaa lähdekoodia

面辅料超发数量调整

huxy 2 vuotta sitten
vanhempi
commit
a9500c932a

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/spapl/controller/SyPreAssembledPackingListController.java

@@ -194,7 +194,7 @@ public class SyPreAssembledPackingListController extends JeecgController<SyPreAs
             queryWrapper.like("t.documentNo", documentNo);//单据号
         }
         if(oConvertUtils.isNotEmpty(customer)){//客户
-            queryWrapper.like("t.customer",customer);
+            queryWrapper.like("t.customer_Abbreviation",customer);
         }
         if(oConvertUtils.isNotEmpty(distributionPoint)){//分销点
             queryWrapper.like("t.distributionPoint",distributionPoint);

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

@@ -531,7 +531,7 @@ public class SyPackingListFabricController {
 				 MultipartFile file = entity.getValue();// 获取上传文件对象
 				 InputStream inputStream=file.getInputStream();
 				 Workbook workbook=new XSSFWorkbook(inputStream);
-				 Map<String,SyPackingListFabric> maps=refreshSheet(workbook);
+				 Map<String,SyPackingListFabric> maps=refreshSheet2(workbook);
 				 String str=syPackingListFabricService.excelTest(maps);//循环
 				 return Result.OK(str);
 			 } catch (Exception e) {
@@ -603,6 +603,75 @@ public class SyPackingListFabricController {
 		 return maps;
 	 }
 
+
+	 public Map<String,SyPackingListFabric>  refreshSheet2(Workbook workbook1) throws ParseException {
+		 Map<String,SyPackingListFabric> maps=new HashMap<>();
+		 Iterator sheets=workbook1.sheetIterator();
+		 while (sheets.hasNext()){
+			 Sheet sheet=(Sheet) sheets.next();
+			 SyPackingListFabric main =new SyPackingListFabric();
+			 List<SyPackingListFabricItem> items=new ArrayList<>();
+			 List<String> mainStrs=new ArrayList<>();
+			 for (int x=0;x<=sheet.getLastRowNum();x++){
+				 Row row=sheet.getRow(x);
+				 if(x<2) {
+					 mainStrs.add(row.getCell(4)==null?"":row.getCell(4).toString());
+					 mainStrs.add(row.getCell(8)==null?"":row.getCell(8).toString());
+					 mainStrs.add(row.getCell(12)==null?"":row.getCell(12).toString());
+					 mainStrs.add(row.getCell(16)==null?"":row.getCell(16).toString());
+					 mainStrs.add(row.getCell(20)==null?"":row.getCell(16).toString());
+				 }else if(x==2){
+					 main =new SyPackingListFabric(mainStrs.toArray(new String[mainStrs.size()]));
+				 }else if(x>3){
+					 if(oConvertUtils.isEmpty(row.getCell(1))||row.getCell(1).toString().length()<10){//如果这一列为空就退出
+						 break;
+					 }
+					 List<String> itemStrs=new ArrayList<>();
+					 for (int i=0;i<row.getLastCellNum();i++){
+						 Cell cell=row.getCell(i);
+						 if(i<18&&i>14){
+							 if(cell==null||cell.equals("")||cell.toString().length()<1){
+								 throw new JeecgBootException("请填写第"+(x+1)+"行里的"+sheet.getRow(3).getCell(i));
+							 }
+						 }
+						 cell.setCellType(CellType.STRING);//获取的都转换成String
+						 FormulaEvaluator formulaEvaluator = new XSSFFormulaEvaluator((XSSFWorkbook) workbook1);
+						 //获取单元格内容的类型
+						 CellType cellType = cell.getCellType();
+						 //判断是否存储的为公式,此处本可以不加判断
+						 if (cellType.equals(CellType.FORMULA)){
+							 //获取公式,可以理解为已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{
+							 itemStrs.add(cell.toString());
+						 }
+					 }
+					 SyPackingListFabricItem syPackingListFabricItem=new SyPackingListFabricItem(itemStrs.toArray(new String[itemStrs.size()]));
+					 items.add(syPackingListFabricItem);
+				 }
+			 }
+			 for (SyPackingListFabricItem item : items){
+				if(maps.containsKey(item.getPlanLotNumber()+"-"+item.getDeclarationName())){//有这个id
+					SyPackingListFabric main2=maps.get(item.getPlanLotNumber()+"-"+item.getDeclarationName());
+					main2.getSyPackingListFabricItem().add(item);
+					maps.put(item.getPlanLotNumber()+"-"+item.getDeclarationName(),main2);
+				}else{
+					SyPackingListFabric main2 =new SyPackingListFabric();
+					List<SyPackingListFabricItem> items1= new ArrayList<>();
+					items1.add(item);
+					main2.setSyPackingListFabricItem(items1);
+					maps.put(item.getPlanLotNumber()+"-"+item.getDeclarationName(),main2);
+				}
+			 }
+		 }
+		 return maps;
+	 }
+
 	@AutoLog(value = "手动同步辅料数据")
 	@ApiOperation(value="手动同步辅料数据", notes="手动同步辅料数据")
 	@GetMapping(value = "/getU8Data")
@@ -828,6 +897,8 @@ public class SyPackingListFabricController {
 	 @RequestMapping(value = "/deleteFile")
 	 public Result deleteFile(String fileName,String id){
 		 Result result=new Result();
+		 result.setCode(500);
+		 result.setSuccess(false);
 		 if(oConvertUtils.isEmpty(id)){
 			 result.setMessage("id为空");
 			 return result;
@@ -859,6 +930,8 @@ public class SyPackingListFabricController {
 
 				 if (file.exists()) {
 					 if (file.delete()) {
+						 result.setCode(200);
+						 result.setSuccess(true);
 						 result.setMessage("已删除该文件!");
 					 }else{
 						 result.setMessage("文件删除失败!");

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

@@ -142,7 +142,7 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 			entity.setPurOrSubOrder(detailsItem.getPurOrSubOrder());//采购委外订单号
 			entity.setPrice(detailsItem.getSalesUnitPrice());//单价
 			entity.setFactoryUnitPrice(detailsItem.getFactoryUnitPrice());//工厂单价
-
+			updateQuantity(entity.getActualDeclaredQuantity(),entity.getSyShippingDetailsItemId());
 
 
 			if((entity.getInventoryCcode().indexOf("03")!=-1&&!entity.getInventoryCcode().equals("0399")) ||
@@ -170,6 +170,41 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 		return syPackingListFabric;
 	}
 
+	/**
+	 *
+	 * @param quantity 本次数量
+	 * @param syShippingDetailsItemId 出运明细id
+	 * @return
+	 */
+	public int  updateQuantity(BigDecimal quantity,String syShippingDetailsItemId){
+		QueryWrapper queryWrapper=new QueryWrapper();
+		queryWrapper.eq("sy_shipping_details_item_id", syShippingDetailsItemId);//出运明细id
+		queryWrapper.eq("del_flag", "0");//未删除
+		queryWrapper.select("sum(actual_Declared_Quantity) as actualDeclaredQuantity");//获取实际报关数量合计
+		BigDecimal actualDeclaredQuantity=syPackingListFabricItemMapper.selectOne(queryWrapper).getActualDeclaredQuantity();
+		actualDeclaredQuantity.add(quantity);
+
+		QueryWrapper queryWrapper2=new QueryWrapper();
+		queryWrapper2.eq("id", syShippingDetailsItemId);//出运明细id
+		queryWrapper2.eq("del_flag", "0");//未删除
+		queryWrapper2.select("sum(shipment_Quantity) as shipment_Quantity");//获取发货数量
+		BigDecimal shipmentQuantity=syShippingDetailsItemMapper.selectOne(queryWrapper2).getShipmentQuantity();
+
+		BigDecimal remainingQuantity=shipmentQuantity.subtract(actualDeclaredQuantity);//剩余数量
+		BigDecimal excessQuantity=null;//超发数量
+		if(actualDeclaredQuantity.doubleValue()>shipmentQuantity.doubleValue()){
+			excessQuantity=actualDeclaredQuantity.subtract(shipmentQuantity);
+		}
+		if(excessQuantity.doubleValue()<=0){
+			excessQuantity=null;//转为null
+		}
+		UpdateWrapper updateWrapper=new UpdateWrapper();
+		updateWrapper.set("remaining_Quantity",remainingQuantity);
+		updateWrapper.set("excess_Quantity",excessQuantity);
+		updateWrapper.eq("sy_shipping_details_item_id",syShippingDetailsItemId);
+		return syPackingListFabricItemMapper.update(null,updateWrapper);
+	}
+
 	@Override
 	@Transactional
 	public SyPackingListFabric updateMain(SyPackingListFabric syPackingListFabric,List<SyPackingListFabricItem> syPackingListFabricItemList) {
@@ -203,6 +238,7 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 
 			entity.setInventoryQuantity(entity.getActualDeclaredQuantity());//入库数量=实际报关数量
 			if(entity.getIsAdd()>0){//大于1就是新增数据
+				updateQuantity(entity.getActualDeclaredQuantity(),entity.getSyShippingDetailsItemId());
 				//因为云工场得修改时得停止调用前面接口
 				/*SyShippingDetailsItem s1 =syShippingDetailsItemMapper.selectById(entity.getSyShippingDetailsItemId());
 				//剩余数量-这次入库数量=新剩余数量
@@ -224,6 +260,12 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 				entity.setId(null);
 				syPackingListFabricItemMapper.insert(entity);
 			}else{
+				QueryWrapper queryWrapper=new QueryWrapper();
+				queryWrapper.eq("id", entity.getId());//子表id
+				queryWrapper.select("actual_Declared_Quantity as actualDeclaredQuantity");//获取实际报关数量合计
+				BigDecimal actualDeclaredQuantity=syPackingListFabricItemMapper.selectOne(queryWrapper).getActualDeclaredQuantity();
+				actualDeclaredQuantity=actualDeclaredQuantity.subtract(entity.getActualDeclaredQuantity());
+				updateQuantity(actualDeclaredQuantity.negate(),entity.getSyShippingDetailsItemId());
 				syPackingListFabricItemMapper.updateById(entity);
 			}
 		}
@@ -233,6 +275,12 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 	@Override
 	@Transactional
 	public void delMain(String id) {
+		QueryWrapper queryWrapper=new QueryWrapper();
+		queryWrapper.eq("sy_packing_list_fabric_id",id);
+		List<SyPackingListFabricItem> syPackingListFabricItems=syPackingListFabricItemMapper.selectList(queryWrapper);
+		for(SyPackingListFabricItem item : syPackingListFabricItems){
+			updateQuantity(item.getActualDeclaredQuantity().negate(),item.getSyShippingDetailsItemId());
+		}
 		syPackingListFabricItemMapper.deleteByMainId(id);
 		syPackingListFabricMapper.deleteByMainId(id);
 	}
@@ -241,6 +289,12 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 	@Transactional
 	public void delBatchMain(Collection<? extends Serializable> idList) {
 		for(Serializable id:idList) {
+			QueryWrapper queryWrapper=new QueryWrapper();
+			queryWrapper.eq("sy_packing_list_fabric_id",id);
+			List<SyPackingListFabricItem> syPackingListFabricItems=syPackingListFabricItemMapper.selectList(queryWrapper);
+			for(SyPackingListFabricItem item : syPackingListFabricItems){
+				updateQuantity(item.getActualDeclaredQuantity().negate(),item.getSyShippingDetailsItemId());
+			}
 			syPackingListFabricItemMapper.deleteByMainId(id.toString());
 			syPackingListFabricMapper.deleteByMainId(id.toString());
 		}
@@ -480,6 +534,7 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 						s1.setSurplusQuantity(item.getSurplusQuantity().subtract(s1.getActualDeclaredQuantity()).intValue());//剩余数量
 						item.setExcessQuantity(s1.getActualDeclaredQuantity().subtract(item.getSurplusQuantity()));
 						item.setSurplusQuantity(item.getSurplusQuantity().subtract(s1.getActualDeclaredQuantity()));
+						updateQuantity(s1.getActualDeclaredQuantity(),s1.getSyShippingDetailsItemId());
 					}
 					item.setIsReference(2);
 					syShippingDetailsItemMapper.updateById(item);
@@ -590,6 +645,7 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 						syShippingDetailsItem.setSurplusQuantity(syShippingDetailsItem.getSurplusQuantity().subtract(item.getActualDeclaredQuantity()));
 						syShippingDetailsItem.setIsReference(2);//回写
 						syShippingDetailsItemMapper.updateById(syShippingDetailsItem);
+						updateQuantity(item.getActualDeclaredQuantity(),item.getSyShippingDetailsItemId());
 					}
 					syPackingListFabricItemMapper.insert(item);
 				}
@@ -615,6 +671,7 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 
 
 			String ids="";
+			String name="";
 			for (SyPackingListFabricItem item :main.getSyPackingListFabricItem()){
 				SyShippingDetailsItem syShippingDetailsItem=syShippingDetailsItemMapper.selectById(item.getSyShippingDetailsItemId());//获取物料分类和其他数据
 				//物料分类
@@ -650,8 +707,8 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 				}
 				//单位换算
 				total3=total3.add(item.getActualDeclaredQuantity());
+				name=item.getPlanLotNumber()+"-"+item.getDeclarationName();
 				ids+=item.getSyShippingDetailsItemId()+",";//获取出运明细子表id
-
 			}
 			if(!ids.equals("")){
 
@@ -674,7 +731,10 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 					total2=syPackingListFabricItem.getActualDeclaredQuantity();
 				}
 			}
-			strs+="第"+num+"页原单据数量"+total1+",已参照数量"+total2+",本次数量"+total3+";";
+			total1.setScale(2,BigDecimal.ROUND_HALF_UP);
+			total2.setScale(2,BigDecimal.ROUND_HALF_UP);
+			total3.setScale(2,BigDecimal.ROUND_HALF_UP);
+			strs+=name+"的原单据数量"+total1+",已参照数量"+total2+",本次数量"+total3+";";
 			num++;
 		}
 		return strs;
@@ -1572,6 +1632,10 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 								}
 							}
 
+							if(sy1.getActualDeclaredQuantity()!=null){
+								updateQuantity(sy1.getActualDeclaredQuantity(),sy1.getSyShippingDetailsItemId());
+							}
+
 							items.add(sy1);
 							syShippingDetailsItem.setIsPull("2");//拉取成功
 							syShippingDetailsItem.setIsReference(2);//回写