Browse Source

srm推送预装箱单调整

fenghaifu 4 days ago
parent
commit
1e45b905f1
25 changed files with 674 additions and 41 deletions
  1. 6 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/shippingDetails/entity/VO/RespUpdateVO.java
  2. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/quartz/job/PushShippingDetailsJob.java
  3. 8 6
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/spapl/controller/SyPreAssembledPackingListController.java
  4. 5 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/spapl/entity/SizeTable.java
  5. 3 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/spapl/entity/SyPreAssembledPackingListItem.java
  6. 2 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/spapl/mapper/xml/SyPreAssembledPackingListItemMapper.xml
  7. 7 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/spapl/service/ISyPreAssembledPackingListItemService.java
  8. 3 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/spapl/service/ISyPreAssembledPackingListService.java
  9. 116 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/spapl/service/impl/SyPreAssembledPackingListServiceImpl.java
  10. 67 11
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/splfi/controller/SyPackingListFabricController.java
  11. 11 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/splfi/entity/SyPackingListFabricItem.java
  12. 8 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/splfi/mapper/SyPackingListFabricItemMapper.java
  13. 53 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/splfi/mapper/xml/SyPackingListFabricItemMapper.xml
  14. 7 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/splfi/service/ISyPackingListFabricItemService.java
  15. 3 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/splfi/service/ISyPackingListFabricService.java
  16. 10 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/splfi/service/impl/SyPackingListFabricItemServiceImpl.java
  17. 120 12
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/splfi/service/impl/SyPackingListFabricServiceImpl.java
  18. 60 6
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/splt/controller/SyPackingListTailoringController.java
  19. 13 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/splt/entity/SyPackingListTailoringItem.java
  20. 7 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/splt/mapper/SyPackingListTailoringItemMapper.java
  21. 36 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/splt/mapper/xml/syPackingListTailoringItemMapper.xml
  22. 8 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/splt/service/ISyPackingListTailoringItemService.java
  23. 4 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/splt/service/ISyPackingListTailoringService.java
  24. 10 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/splt/service/impl/SyPackingListTailoringItemServiceImpl.java
  25. 106 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/splt/service/impl/SyPackingListTailoringServiceImpl.java

+ 6 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/shippingDetails/entity/VO/RespUpdateVO.java

@@ -11,4 +11,10 @@ import lombok.Data;
 public class RespUpdateVO {
     private boolean success;
     private String message;
+    private String extraInfo;//其他信息
+
+    public void toError(String message){
+        this.success = false;
+        this.message = message;
+    }
 }

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/quartz/job/PushShippingDetailsJob.java

@@ -79,7 +79,7 @@ public class PushShippingDetailsJob implements Job {
                     log.info("jsonArray\t"+jsonArray);
                     for (int i=0;i<jsonArray.size();i++){
                         JSONObject jsonObject=jsonArray.getJSONObject(i);
-                        String syShippingId=jsonObject.getString("syShippingId");
+                        String syShippingId=jsonObject.getString("extraInfo");
                         boolean success=jsonObject.getBoolean("success");
                         String message= oConvertUtils.getString(jsonObject.getString("message"));
                         String status = success?"1":"2";

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

@@ -2570,6 +2570,9 @@ public class SyPreAssembledPackingListController extends JeecgController<SyPreAs
             syPreAssembledPackingList.setOmpoId(item.getOmpoId());
             syPreAssembledPackingList.setIsExcel(0);
             syPreAssembledPackingList.setIsTc(item.getIsTc());
+            syPreAssembledPackingList.setSalesman(item.getSalesman());
+            syPreAssembledPackingList.setSalesDepartment(item.getSalesDepartment());
+            syPreAssembledPackingList.setSyOrderDataId(item.getSyOrderDataId());
             syPreAssembledPackingList.setTotalPrice(syPreAssembledPackingList.getTotal().multiply(item.getUnitPrice()));
             for (SyPreAssembledPackingListItem syPreAssembledPackingListItem : itemList){
                 SizeTable sizeTable = syPreAssembledPackingListItem.getSizeTables().get(0);
@@ -2579,6 +2582,7 @@ public class SyPreAssembledPackingListController extends JeecgController<SyPreAs
                     respUpdateVO.setMessage("查找出运明细失败");
                     return respUpdateVO;
                 }
+                syPreAssembledPackingListItem.setTotalGrossWeight(syPreAssembledPackingListItem.getGrossWeight());
                 syPreAssembledPackingListItem.setAcSetNo(findExtraInfo.getAcSetNo());
                 syPreAssembledPackingListItem.setGarmentFactory(findExtraInfo.getGarmentFactory());
                 syPreAssembledPackingListItem.setUnitPrice(findExtraInfo.getUnitPrice());
@@ -2592,17 +2596,15 @@ public class SyPreAssembledPackingListController extends JeecgController<SyPreAs
                 syPreAssembledPackingListItem.setSalesman(findExtraInfo.getSalesman());
                 syPreAssembledPackingListItem.setSalesDepartment(findExtraInfo.getSalesDepartment());
                 syPreAssembledPackingListItem.setCustomsDeclarationUnitPrice(findExtraInfo.getCustomsDeclarationUnitPrice());
+                syPreAssembledPackingListItem.setSupplier(findExtraInfo.getSupplier());
             }
-            syPreAssembledPackingList=syPreAssembledPackingListService.saveMain2(syPreAssembledPackingList);
-            respUpdateVO.setMessage(syPreAssembledPackingList.getId());
-            respUpdateVO.setSuccess(true);
+            return syPreAssembledPackingListService.saveSrmBill(syPreAssembledPackingList);
+
         }catch (Exception ex){
-            ex.printStackTrace();
-            log.error("添加失败:" + ex.getMessage());
+            log.error("添加失败:{}" , ex);
             respUpdateVO.setMessage(ex.getMessage());
             return respUpdateVO;
         }
-        return respUpdateVO;
     }
 
 }

+ 5 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/spapl/entity/SizeTable.java

@@ -50,4 +50,9 @@ public class SizeTable {
     @ApiModelProperty(value = "出运明细分组id")
     @TableField(exist = false)
     private java.lang.String groupItemId;
+
+    // 以下对接srm使用
+    // srmid
+    @TableField(exist = false)
+    private String srmId;
 }

+ 3 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/spapl/entity/SyPreAssembledPackingListItem.java

@@ -597,5 +597,7 @@ public class SyPreAssembledPackingListItem implements Serializable {
 	// 是否tc
 	@TableField(exist = false)
 	private String isTc;
-
+	// srm id
+	@TableField(exist = false)
+	private String srmId;
 }

+ 2 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/spapl/mapper/xml/SyPreAssembledPackingListItemMapper.xml

@@ -467,7 +467,8 @@
 		  	  a.customer_name,
 		  	  a.customer_abbreviation,
 		  	  a.elements_id,
-		  	  a.is_tc
+		  	  a.is_tc,
+		  	  c.supplier
 		  FROM
 			  sy_shipping_details_item a
 				  left join sy_order_data b on a.sy_order_data_id=b.id

+ 7 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/spapl/service/ISyPreAssembledPackingListItemService.java

@@ -44,4 +44,11 @@ public interface ISyPreAssembledPackingListItemService extends IService<SyPreAss
 	public List<SizeTable> queryAllSizes(String [] value);
 
 	public List<SizeTable> queryAllSizes2(String [] value);
+
+	/**
+	 * 根据发运明细子表ID获取SRM推送预装箱单时需要的数据
+	 * @param shippingDetailsItemIdList
+	 * @return
+	 */
+	List<SyPreAssembledPackingListItem> getSrmPushExtraList(List<String> shippingDetailsItemIdList);
 }

+ 3 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/spapl/service/ISyPreAssembledPackingListService.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.apache.ibatis.annotations.Param;
 import org.jeecg.modules.documents.letterDeposit.entity.SyLetterDepositItem;
+import org.jeecg.modules.documents.shippingDetails.entity.VO.RespUpdateVO;
 import org.jeecg.modules.documents.shippingDetails.entity.VO.SyShippingDetailsVo;
 import org.jeecg.modules.spapl.entity.SizeTable;
 import org.jeecg.modules.spapl.entity.SyPreAssembledPackingListItem;
@@ -135,4 +136,6 @@ public interface ISyPreAssembledPackingListService extends IService<SyPreAssembl
 	public SyPreAssembledPackingList getPacking(String id);
 
 	public boolean saveList(List<SyPreAssembledPackingList> syPreAssembledPackingLists);
+
+	RespUpdateVO saveSrmBill(SyPreAssembledPackingList syPreAssembledPackingList);
 }

+ 116 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/spapl/service/impl/SyPreAssembledPackingListServiceImpl.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.hibernate.engine.jdbc.Size;
 import org.jeecg.common.exception.JeecgBootException;
+import org.jeecg.common.util.UUIDGenerator;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.modules.documents.letterDeposit.entity.SyLetterDeposit;
 import org.jeecg.modules.documents.letterDeposit.entity.SyLetterDepositItem;
@@ -14,6 +15,7 @@ import org.jeecg.modules.documents.letterDeposit.mapper.SyLetterDepositMapper;
 import org.jeecg.modules.documents.letterDeposit.service.ISyLetterDepositItemService;
 import org.jeecg.modules.documents.shippingDetails.entity.SyShippingDetails;
 import org.jeecg.modules.documents.shippingDetails.entity.SyShippingDetailsItem;
+import org.jeecg.modules.documents.shippingDetails.entity.VO.RespUpdateVO;
 import org.jeecg.modules.documents.shippingDetails.entity.VO.SyShippingDetailsVo;
 import org.jeecg.modules.documents.shippingDetails.mapper.SyShippingDetailsItemMapper;
 import org.jeecg.modules.documents.shippingDetails.mapper.SyShippingDetailsMapper;
@@ -377,7 +379,9 @@ public class SyPreAssembledPackingListServiceImpl extends ServiceImpl<SyPreAssem
 				//box=box.add(boxNumber1);//合计
 				item.setDelFlag("0");//默认为未删除
 				for (SizeTable size : sizes){
-					SyPreAssembledPackingListItem item1=item;
+					SyPreAssembledPackingListItem item1=new SyPreAssembledPackingListItem();
+					item1.setSrmId(size.getSrmId());
+					BeanUtils.copyProperties(item,item1);
 					BigDecimal boxNumber=boxNumber1.multiply(new BigDecimal(size.getProportion()));//获取该尺码件数
 					item1.setTotal(boxNumber);//该尺码件数
 					//item1.setRemainingQuantity(boxNumber);//该尺码的剩余数量
@@ -1493,4 +1497,115 @@ public class SyPreAssembledPackingListServiceImpl extends ServiceImpl<SyPreAssem
 		saveBatch(lists);
 		return bool;
 	}
+
+	/**
+	 * srm推送保存
+	 * @param syPreAssembledPackingList
+	 * @return
+	 */
+	@Override
+	@Transactional
+	public synchronized RespUpdateVO saveSrmBill(SyPreAssembledPackingList syPreAssembledPackingList) {
+		RespUpdateVO respUpdateVO = new RespUpdateVO();
+		respUpdateVO.setSuccess(false);
+		respUpdateVO.setExtraInfo("");
+		List<SyPreAssembledPackingListItem> items=syPreAssembledPackingList.getSyPreAssembledPackingListItemList();
+		SimpleDateFormat sf = new SimpleDateFormat("yyMMddHHmmssSSS");
+		String dateNo ="YCY"+sf.format(System.currentTimeMillis())+String.format("%03d", 1);//+getOne(queryWrapperCount).getId();
+		syPreAssembledPackingList.setDocumentNo(dateNo);//订单号-->单据号
+		syPreAssembledPackingList.setDelFlag("0");//删除状态默认为0
+		syPreAssembledPackingList.setPushStatus("0");//推送状态默认为0
+		if(oConvertUtils.isEmpty(syPreAssembledPackingList.getStatus())||!syPreAssembledPackingList.getStatus().equals("1")){
+			syPreAssembledPackingList.setStatus("0");//单据状态默认为0
+		}
+		if(syPreAssembledPackingList.getSyOrderDataId()==null){
+			SyShippingDetails syShippingDetails=syShippingDetailsMapper.selectById(syPreAssembledPackingList.getSyDeclarationElementsId());
+			if(syShippingDetails!=null&&syShippingDetails.getSyOrderDataId()!=null){
+				syPreAssembledPackingList.setSyOrderDataId(syShippingDetails.getSyOrderDataId());
+			}
+		}
+		syPreAssembledPackingListMapper.insert(syPreAssembledPackingList);//往主表添加数据
+		if(syPreAssembledPackingList.getSyPreAssembledPackingListItemList()!=null){
+			//BigDecimal box=add(syPreAssembledPackingList.getSyPreAssembledPackingListItemList(),syPreAssembledPackingList.getId());
+			Map<String,BigDecimal> maps=new HashMap();
+			for (SyPreAssembledPackingListItem item : items){
+				List<SizeTable> sizes=item.getSizeTables();//获取尺码表信息
+				item.setSyPreAssembledPackingListId(syPreAssembledPackingList.getId());//获取主表id
+				BigDecimal boxNumber1=item.getBoxNumber();//获取箱数
+				item.setActualPackingQty(item.getTotal());//计划装箱数量
+				item.setGroupId(org.jeecg.modules.system.util.oConvertUtils.getId());//分组id
+				//box=box.add(boxNumber1);//合计
+				item.setDelFlag("0");//默认为未删除
+				for (SizeTable size : sizes){
+					SyPreAssembledPackingListItem item1=new SyPreAssembledPackingListItem();
+					BeanUtils.copyProperties(item,item1);
+					BigDecimal boxNumber=boxNumber1.multiply(new BigDecimal(size.getProportion()));//获取该尺码件数
+					item1.setTotal(boxNumber);//该尺码件数
+					//item1.setRemainingQuantity(boxNumber);//该尺码的剩余数量
+					item1.setSize(size.getSize());//获取尺码
+					item1.setActualPackingQty(size.getQuantity());//获取该尺码计划装箱数量 z
+					item1.setTotalPrice(boxNumber.multiply(item1.getUnitPrice()).setScale(2, RoundingMode.HALF_UP));//获取总价		箱数*单价-->件数*单价
+//				item1.setBoxNumber(boxNumber);//获取箱数
+					//boxNumber=boxNumber.divide(item.getPiecesBox(),6,BigDecimal.ROUND_HALF_UP);
+					//item1.setTotalNetWeight(boxNumber.multip1ly(item1.getNetWeight()));//获取总净重		净重*箱数
+					//item1.setTotalGrossWeight(boxNumber.multip1ly(item1.getGrossWeight()));//获取总毛重 	箱数*毛重/箱
+					//item1.setTotalNetWeight(boxNumber.multip1ly(new BigDecimal(size.getProportion())));//获取净净重 不知
+					//BigDecimal volume=boxNumber.multip1ly(item1.getOuterBoxHeight());
+					//volume=volume.multip1ly(item1.getOuterBoxLength());
+					//volume=volume.multip1ly(item1.getOuterBoxWidth());
+					//item1.setTotalVolume(volume.divide(new BigDecimal(1000000)));//获取总体积	长*宽*高*箱数
+
+
+					item1.setSyDeclarationElementsItemId(size.getItemId());//获取到发运明细子表id
+					item1.setSort(size.getNum());//获取序号
+					item1.setId(oConvertUtils.id());//获取到随机id
+					//获取发育明细数据
+					SyShippingDetailsItem syItem=syShippingDetailsItemMapper.selectById(item1.getSyDeclarationElementsItemId());
+					syItem.setIsReference(1);//修改成被参照
+					syShippingDetailsItemMapper.updateById(syItem);
+					syPreAssembledPackingList.setElementsId(syItem.getElementsId());
+					syPreAssembledPackingList.setIsTc(syItem.getIsTc());
+					item1.setPackId(syItem.getPackId());
+					item1.setOmpoIdItem(syItem.getOmpoIdItem());//获取委外/采购订单子表Id
+					item1.setOmpoId(syItem.getOmpoId());//获取委外/采购订单主表Id
+					item1.setOmpoAccount(syItem.getOmpoAccount());//采购委外账套号
+					item1.setOrderNumber(syItem.getOrderNumber());//获取订单号
+					item1.setSpurOrSubOrder(syItem.getPurOrSubOrder());//获取采购委外订货号
+					item1.setSyOrderDataItemId(syItem.getSyOrderDataItemId());//获取到订单子表id
+					item1.setSyOrderDataId(syItem.getSyOrderDataId());//获取到订单子表id
+					item1.setSalesman(syItem.getSalesman());//获取业务员
+					item1.setSalesDepartment(syItem.getSalesDepartment());//获取销售部门
+					item1.setInventoryCode(syItem.getInventoryCode());
+					item1.setInventoryCcode(syItem.getInventoryCcode());
+					item1.setMasterMetering(syItem.getMasterMetering());
+					syPreAssembledPackingListItemMapper.insert(item1);//添加子表数据
+					respUpdateVO.setExtraInfo(respUpdateVO.getExtraInfo()+size.getSrmId()+","+item1.getId()+";");
+
+					//原剩余数量-预装箱单装箱数量=新剩余数量
+					//syItem.setSurplusQuantity(syItem.getSurplusQuantity().subtract(item1.getTotal()));
+					//超发数量
+					//syItem.setExcessQuantity(syItem.getSurplusQuantity().subtract(item1.getTotal()).negate());
+					//syItem.setIsReference(1);//标识已被参照
+					//syShippingDetailsItemMapper.updateById(syItem);//修改发运明细
+					if(item1.getTotal().doubleValue()>0){
+						if(maps.containsKey(item.getSyDeclarationElementsItemId())){
+							maps.put(item1.getSyDeclarationElementsItemId(),maps.get(item1.getSyDeclarationElementsItemId()).add(item1.getTotal()));
+						}else{
+							maps.put(item1.getSyDeclarationElementsItemId(),item1.getTotal());
+						}
+						//updateQuantity(item1.getTotal(),item1.getSyDeclarationElementsItemId());
+					}
+				}
+			}
+			for (String key : maps.keySet()){
+				//updateQuantity(maps.get(key),key);
+			}
+			syPreAssembledPackingListMapper.updateById(syPreAssembledPackingList);
+			respUpdateVO.setMessage(syPreAssembledPackingList.getId());
+			respUpdateVO.setSuccess(true);
+		}else{
+			respUpdateVO.setMessage("子表明细不能为空");
+		}
+		return respUpdateVO;
+	}
 }

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

@@ -34,7 +34,9 @@ import org.jeecg.modules.documents.orderData.mapper.SyOrderDataMapper;
 import org.jeecg.modules.documents.shippingDetails.entity.VO.RespUpdateVO;
 import org.jeecg.modules.documents.shippingDetails.entity.VO.SyShippingDetailsVo;
 import org.jeecg.modules.documents.shippingDetails.mapper.SyShippingDetailsItemMapper;
+import org.jeecg.modules.spapl.entity.SizeTable;
 import org.jeecg.modules.spapl.entity.SyPreAssembledPackingList;
+import org.jeecg.modules.splt.entity.SyPackingListTailoringItem;
 import org.jeecg.modules.splt.service.ISyPackingListTailoringService;
 import org.jeecg.modules.system.controller.CommonController;
 import org.jeecgframework.poi.excel.def.NormalExcelConstants;
@@ -1809,25 +1811,79 @@ public class SyPackingListFabricController implements Job {
 	 public RespUpdateVO srmAdd(@RequestBody SyPackingListFabric syPackingListFabric) {
 		 RespUpdateVO respUpdateVO = new RespUpdateVO();
 		 respUpdateVO.setSuccess(false);
-		 if (!srmAccessToken.equals(syPackingListFabric.getAccessToken())){
+		 if (!srmAccessToken.equals(syPackingListFabric.getAccessToken())) {
 			 respUpdateVO.setMessage("认证失败,请联系管理员");
 			 return respUpdateVO;
 		 }
 
-		 if(oConvertUtils.isEmpty(syPackingListFabric)){
+		 if (oConvertUtils.isEmpty(syPackingListFabric)) {
 			 respUpdateVO.setMessage("请填写信息再提交");
 			 return respUpdateVO;
 		 }
-		 List<String> ids=new ArrayList<>();
-		 for (SyPackingListFabricItem item : syPackingListFabric.getSyPackingListFabricItem()){
-			 ids.add(item.getSyOrderDataId());
-		 }
-		 Map<String,String> maps=orderNumber(ids);
-		 syPackingListFabricService.saveMain(syPackingListFabric,"");
-		 respUpdateVO.setSuccess(true);
-		 respUpdateVO.setMessage(syPackingListFabric.getId());
+		 try {
+			 // 从detail中获取出运明细id
+			 List<SyPackingListFabricItem> itemList = syPackingListFabric.getSyPackingListFabricItem();
+			 List<String> shippingItemIdList = itemList.stream().map(SyPackingListFabricItem::getSyShippingDetailsItemId).distinct().collect(Collectors.toList());
+			 List<SyPackingListFabricItem> srmPushExtraList = syPackingListFabricItemService.getSrmPushExtraList(shippingItemIdList);
+			 if (srmPushExtraList.size() == 0) {
+				 log.error("查找出运单明细失败");
+				 respUpdateVO.setMessage("查找出运单明细失败");
+				 return respUpdateVO;
+			 }
+			 // 赋值
+			 SyPackingListFabricItem item = srmPushExtraList.get(0);
+			 syPackingListFabric.setOrderNumber(item.getOrderNumber());
+			 syPackingListFabric.setCustomer(item.getCustomerName());
+			 syPackingListFabric.setCustomerAbbreviation(item.getCustomerAbbreviation());
+			 syPackingListFabric.setGarmentFactory(item.getGarmentFactory());
+			 syPackingListFabric.setIsU8Data(0);
+			 syPackingListFabric.setAccount(item.getAccount());
+			 BigDecimal remainQuantity = BigDecimal.ZERO;
+			 for (SyPackingListFabricItem fabricItem : itemList) {
+				 SyPackingListFabricItem findExtraInfo = srmPushExtraList.stream().filter(e -> e.getSyShippingDetailsItemId().equals(fabricItem.getSyShippingDetailsItemId())).findFirst().orElse(null);
+				 if (findExtraInfo == null) {
+					 log.error("查找出运明细失败:\t{}", fabricItem);
+					 respUpdateVO.setMessage("查找出运明细失败");
+					 return respUpdateVO;
+				 }
+				 fabricItem.setAccount(findExtraInfo.getAccount());
+				 fabricItem.setSalesman(findExtraInfo.getSalesman());
+				 fabricItem.setSalesDepartment(findExtraInfo.getSalesDepartment());
+				 fabricItem.setPlanLotNumber(findExtraInfo.getOrderNumber().substring(0,findExtraInfo.getOrderNumber().indexOf('-')));
+				 fabricItem.setGarmentFactory(findExtraInfo.getGarmentFactory());
+				 fabricItem.setDeclarationName(findExtraInfo.getDeclarationName());
+				 fabricItem.setDeclarationUnit(findExtraInfo.getDeclarationUnit());
+				 fabricItem.setPrice(findExtraInfo.getPrice());
+				 fabricItem.setSupplierCode(findExtraInfo.getSupplierCode());
+				 fabricItem.setSupplier(findExtraInfo.getSupplier());
+				 fabricItem.setSupplierPrintingPlant(findExtraInfo.getSupplierPrintingPlant());
+				 fabricItem.setSupplierDyeingPlant(findExtraInfo.getSupplierDyeingPlant());
+				 fabricItem.setSupplierCodePrintingPlant(findExtraInfo.getSupplierCodePrintingPlant());
+				 fabricItem.setSupplierCodeDyeingPlant(findExtraInfo.getSupplierCodeDyeingPlant());
+				 fabricItem.setRemainingQuantity(findExtraInfo.getRemainingQuantity());
+				 fabricItem.setOrderNumber(findExtraInfo.getOrderNumber());
+				 fabricItem.setElementsId(findExtraInfo.getElementsId());
+				 fabricItem.setFactoryUnitPrice(findExtraInfo.getFactoryUnitPrice());
+				 fabricItem.setTotalPrice(fabricItem.getPrice().multiply(fabricItem.getActualPackingQty()));
+				 fabricItem.setCustomsDeclarationUnitPrice(findExtraInfo.getCustomsDeclarationUnitPrice());
+				 fabricItem.setOmpoAccount(findExtraInfo.getOmpoAccount());
+				 fabricItem.setOmpoIdItem(findExtraInfo.getOmpoIdItem());
+				 fabricItem.setOmpoId(findExtraInfo.getOmpoId());
+				 fabricItem.setSyOrderDataItemId(findExtraInfo.getSyOrderDataItemId());
+				 fabricItem.setSyOrderDataId(findExtraInfo.getSyOrderDataId());
+				 fabricItem.setIsTc(findExtraInfo.getIsTc());
+				 fabricItem.setMasterMetering(findExtraInfo.getMasterMetering());
+				 fabricItem.setSpecificationAndModel(findExtraInfo.getSpecificationAndModel());
+				 fabricItem.setWidth(findExtraInfo.getWidth());
+				 remainQuantity = remainQuantity.add(fabricItem.getRemainingQuantity());
+			 }
+			 syPackingListFabric.setRemainingQuantity(remainQuantity);
 
-		 return respUpdateVO;
+			 return syPackingListFabricService.saveSrmBill(syPackingListFabric);
+		 } catch (Exception ex) {
+			 respUpdateVO.setMessage(ex.getMessage());
+			 return respUpdateVO;
+		 }
 	 }
 
  }

+ 11 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/splfi/entity/SyPackingListFabricItem.java

@@ -482,4 +482,15 @@ public class SyPackingListFabricItem implements Serializable {
 			meter=netWeight.multiply(num).divide(width1,2,BigDecimal.ROUND_HALF_UP).divide(gramWeight2,2,BigDecimal.ROUND_HALF_UP);//净重*100000/门幅/克重
 		}
 	}
+
+	/** srm 推单用到 **/
+	// 客户全称
+	@TableField(exist = false)
+	private String customerName;
+	// 客户简称
+	@TableField(exist = false)
+	private String customerAbbreviation;
+	// srm id
+	@TableField(exist = false)
+	private String srmId;
 }

+ 8 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/splfi/mapper/SyPackingListFabricItemMapper.java

@@ -8,6 +8,7 @@ import com.baomidou.dynamic.datasource.annotation.DS;
 import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import org.apache.ibatis.annotations.Param;
+import org.jeecg.modules.spapl.entity.SyPreAssembledPackingListItem;
 import org.jeecg.modules.splfi.entity.SyPackingListFabric;
 import org.jeecg.modules.splfi.entity.SyPackingListFabricItem;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
@@ -60,4 +61,11 @@ public interface SyPackingListFabricItemMapper extends BaseMapper<SyPackingListF
 	String getVencode(String name);
 
 	String getItaxRate(String id);
+
+	/**
+	 * 根据发运明细子表ID获取SRM推送装箱单时需要的数据
+	 * @param shippingDetailsItemIdList
+	 * @return
+	 */
+	List<SyPackingListFabricItem> getSrmPushExtraList(@Param("shippingDetailsItemIdList")List<String> shippingDetailsItemIdList);
 }

+ 53 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/splfi/mapper/xml/SyPackingListFabricItemMapper.xml

@@ -324,4 +324,57 @@ SELECT
         select  cast(iTaxRate as decimal(10,3)) iTaxRate   from SO_SODetails where iSOsID=
         (select top 1 iSOsID from OM_MODetails where MODetailsID =#{value} )
     </select>
+
+	<!-- SRM推送时信息查询-->
+	<select id="getSrmPushExtraList" parameterType="java.lang.String" resultType="org.jeecg.modules.splfi.entity.SyPackingListFabricItem">
+		select * from (
+		SELECT
+		a.id as sy_shipping_details_item_id,
+		a.shipping_details_id as sy_shipping_details_id,
+		a.order_number,
+		a.salesman,
+		d.declaration_name,
+		d.declaration_unit,
+		a.material_composition as composition,
+		a.guangpei_gate_width as width,
+		c.unit_price_including_tax as price,
+		a.r_supplier_code as supplier_code_dyeing_plant,
+		a.r_supplier as supplier_dyeing_plant,
+		a.supplier_code as supplier_code_printing_plant,
+		a.supplier as supplier_printing_plant,
+		a.supplier_code,
+		a.supplier,
+		a.specification_and_model,
+		a.master_Metering,
+		a.order_remaining_quantity as remaining_Quantity,
+		a.elements_id,
+		a.sales_department,
+		a.factory_Unit_Price,
+		b.account as account,
+		a.sy_order_data_item_id as isosid,
+		a.inventory_Ccode,
+		a.customs_declaration_unit_price,
+		a.ompo_Account,
+		a.ompo_id,
+		a.ompo_id_item,
+		a.sy_order_data_id,
+		a.sy_order_data_item_id,
+		a.is_tc,
+
+		a.garment_Factory,
+		a.shipping_details_id as sy_declaration_elements_id,
+		a.customer_name,
+		a.customer_abbreviation
+
+		FROM
+		sy_shipping_details_item a
+		left join sy_order_data b on a.sy_order_data_id=b.id
+		left join sy_order_data_item c on a.sy_order_data_item_id=c.id
+		left join sy_declaration_elements d on a.elements_id=d.id
+		) as t1
+		where sy_shipping_details_item_id in
+		<foreach collection="shippingDetailsItemIdList" item="value" index="index" open="(" separator="," close=")">
+			#{value}
+		</foreach>
+	</select>
 </mapper>

+ 7 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/splfi/service/ISyPackingListFabricItemService.java

@@ -18,4 +18,11 @@ public interface ISyPackingListFabricItemService extends IService<SyPackingListF
 	public List<SyPackingListFabricItem> selectByMainId3(String... toArray);
 
 	List<SyPackingListFabricItem> queryByList(String id);
+
+	/**
+	 * 根据发运明细子表ID获取SRM推送装箱单时需要的数据
+	 * @param shippingDetailsItemIdList
+	 * @return
+	 */
+	List<SyPackingListFabricItem> getSrmPushExtraList(List<String> shippingDetailsItemIdList);
 }

+ 3 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/splfi/service/ISyPackingListFabricService.java

@@ -3,11 +3,13 @@ package org.jeecg.modules.splfi.service;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.apache.ibatis.annotations.Param;
+import org.jeecg.modules.documents.shippingDetails.entity.VO.RespUpdateVO;
 import org.jeecg.modules.documents.shippingDetails.entity.VO.SyShippingDetailsVo;
 import org.jeecg.modules.splfi.entity.SyPackingListFabricItem;
 import org.jeecg.modules.splfi.entity.SyPackingListFabric;
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.modules.splfi.vo.SyPackingListFabricPage;
+import org.jeecg.modules.splt.entity.SyPackingListTailoring;
 
 import java.io.Serializable;
 import java.text.ParseException;
@@ -95,4 +97,5 @@ public interface ISyPackingListFabricService extends IService<SyPackingListFabri
 
 	public void  updateQuantitys(Map<String,SyPackingListFabricItem> mapItems,List<String> ids);
 
+	RespUpdateVO saveSrmBill(SyPackingListFabric syPackingListFabric);
 }

+ 10 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/splfi/service/impl/SyPackingListFabricItemServiceImpl.java

@@ -34,4 +34,14 @@ public class SyPackingListFabricItemServiceImpl extends ServiceImpl<SyPackingLis
 	public List<SyPackingListFabricItem> queryByList(String id) {
 		return syPackingListFabricItemMapper.queryByList(id);
 	}
+
+	/**
+	 * 根据发运明细子表ID获取SRM推送装箱单时需要的数据
+	 * @param shippingDetailsItemIdList
+	 * @return
+	 */
+	@Override
+	public List<SyPackingListFabricItem> getSrmPushExtraList(List<String> shippingDetailsItemIdList){
+		return syPackingListFabricItemMapper.getSrmPushExtraList(shippingDetailsItemIdList);
+	}
 }

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

@@ -23,6 +23,7 @@ import org.jeecg.modules.documents.seclarationElements.mapper.SyDeclarationEleme
 import org.jeecg.modules.documents.seclarationElements.mapper.SyDeclarationElementsMapper;
 import org.jeecg.modules.documents.shippingDetails.entity.SyShippingDetails;
 import org.jeecg.modules.documents.shippingDetails.entity.SyShippingDetailsItem;
+import org.jeecg.modules.documents.shippingDetails.entity.VO.RespUpdateVO;
 import org.jeecg.modules.documents.shippingDetails.entity.VO.SyShippingDetailsVo;
 import org.jeecg.modules.documents.shippingDetails.mapper.SyShippingDetailsItemMapper;
 import org.jeecg.modules.documents.shippingDetails.mapper.SyShippingDetailsMapper;
@@ -84,23 +85,23 @@ import java.util.*;
 @Service
 public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFabricMapper, SyPackingListFabric> implements ISyPackingListFabricService, Job {
 
-	@Autowired
+	@Resource
 	private SyPackingListFabricMapper syPackingListFabricMapper;
 	@Autowired
 	private ISyPackingListFabricItemService syPackingListFabricItemService;
-	@Autowired
+	@Resource
 	private SyPackingListFabricItemMapper syPackingListFabricItemMapper;
-	@Autowired
+	@Resource
 	private SyShippingDetailsMapper syShippingDetailsMapper;
-	@Autowired
+	@Resource
 	private SyShippingDetailsItemMapper syShippingDetailsItemMapper;
 	@Autowired
 	private ISyShippingDetailsItemService iSyShippingDetailsItemService;
-	@Autowired
+	@Resource
 	private SyDeclarationElementsMapper syDeclarationElementsMapper;
-	@Autowired
+	@Resource
 	private SyOrderDataMapper syOrderDataMapper;
-	@Autowired
+	@Resource
 	private SyOrderDataItemMapper syOrderDataItemMapper;
 	@Autowired
 	private ISenYuDataSourceOne senYuDataSourceOne;
@@ -110,7 +111,7 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 	private ISenYuDataSourceThree senYuDataSourceThree;
 	@Autowired
 	private IDxpDataPlanService dxpDataPlanService;
-	@Autowired
+	@Resource
 	private SysUserMapper userMapper;//userMapper
 
 	String getUsername(String token){
@@ -1199,10 +1200,10 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 		return strs;
 	}
 
-	@Autowired
+	@Resource
 	private SyPackingListTailoringMapper syPackingListTailoringMapper;//成衣mapper
 
-	@Autowired
+	@Resource
 	private PurchaseWarehousingMapper purchaseWarehousingMapper;//采购入库表
 
 	@Override
@@ -1238,7 +1239,7 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 	}
 
 
-	@Autowired
+	@Resource
 	private SyShippingOrderMapper syShippingOrderMapper;//托书主表
 
 	@Autowired
@@ -2280,7 +2281,7 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 
 	}*/
 
-	@Autowired
+	@Resource
 	private DxpDataPlanMapper dxpDataPlanMapper;
 
 	/**
@@ -2946,4 +2947,111 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 		}
 		return ids;
 	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public RespUpdateVO saveSrmBill(SyPackingListFabric syPackingListFabric){
+		RespUpdateVO respUpdateVO = new RespUpdateVO();
+		respUpdateVO.setSuccess(false);
+		respUpdateVO.setExtraInfo("");
+		try {
+			SimpleDateFormat sf = new SimpleDateFormat("yyMMddHHmmssSSS");
+			String dateNo = "ML" + sf.format(System.currentTimeMillis()) + String.format("%03d", 1);//获取单据号
+			syPackingListFabric.setDelFlag("0");
+			syPackingListFabric.setStatus("0");
+			syPackingListFabric.setDocumentNo(dateNo);//单据号
+			syPackingListFabric.setDataSource("参照出运明细");//参照
+//			String username = "admin";
+//			if (oConvertUtils.isNotEmpty(token)) {
+//				username = getUsername(token);
+//			}
+//			syPackingListFabric.setPreparedBy(username);//将admin设置为制单人
+//			syPackingListFabric.setCreateBy(username);//将admin设置为制单人
+//			if (username != null && username.equals("周泽济")) {
+//				syPackingListFabric.setPushState("4");
+//			}
+			syPackingListFabricMapper.insert(syPackingListFabric);
+			Map<String, String> mapId = new HashMap<String, String>();//key为发运明细子表id,value为分组id
+			BigDecimal total = new BigDecimal("0");//合计数量,初始为0
+			List<String> itemIds = new ArrayList<>();
+			for (SyPackingListFabricItem entity : syPackingListFabric.getSyPackingListFabricItem()) {
+				itemIds.add(entity.getSyShippingDetailsItemId());
+				//entity.setRemainingQuantity(entity.getInventoryQuantity());//入库数量
+				total = total.add(entity.getInventoryQuantity());//循环添加每条数据的入库数量
+				String key = entity.getSyShippingDetailsItemId();//获取发运明细子表id
+				if (!mapId.containsKey(key)) {//如果这个发运明细id没有分组id,就生成一个新的分组id
+					mapId.put(key, oConvertUtils.getId());
+				}
+				entity.setGroupId(mapId.get(key));//分组id
+				entity.setSyPackingListFabricId(syPackingListFabric.getId());//外键设置
+				entity.setDelFlag("0");//新增数据设置成未删除
+				//获取该发运明细子表数据,回写剩余数量
+				SyShippingDetailsItem detailsItem = syShippingDetailsItemMapper.selectById(entity.getSyShippingDetailsItemId());
+				//detailsItem.setIsReference(1);//修改成已被参照
+				//剩余数量-这次入库数量=新剩余数量
+				//detailsItem.setOrderRemainingQuantity(detailsItem.getOrderRemainingQuantity().subtract(entity.getInventoryQuantity()));
+				//此次入库数量-剩余数量=超发数量
+				//detailsItem.setExcessQuantity(entity.getInventoryQuantity().subtract(detailsItem.getOrderRemainingQuantity()));
+				detailsItem.setIsReference(2);//面辅料回写
+				entity.setSalesman(detailsItem.getSalesman());//获取业务员
+				entity.setIsTc(detailsItem.getIsTc());
+				entity.setSalesDepartment(detailsItem.getSalesDepartment());//获取业务部门
+				entity.setPreDeliveryDate(detailsItem.getPreDeliveryDate());//hod
+				entity.setOrderNumber(detailsItem.getOrderNumber());//获取订单号
+				entity.setSmallPo(detailsItem.getSmallPo());//小po
+				entity.setOmpoAccount(detailsItem.getOmpoAccount());
+				entity.setAccount(detailsItem.getAccount());
+				entity.setOmpoIdItem(detailsItem.getOmpoIdItem());
+				entity.setElementsId(detailsItem.getElementsId());
+				entity.setSyOrderDataItemId(detailsItem.getSyOrderDataItemId());
+				entity.setSyOrderDataId(detailsItem.getSyOrderDataId());
+				entity.setOmpoId(detailsItem.getOmpoId());
+				entity.setInventoryQuantity(entity.getActualDeclaredQuantity());//入库数量=实际报关数量
+				entity.setDistributionPoint(detailsItem.getDistributionPoint());//分销点
+				entity.setPurOrSubOrder(detailsItem.getPurOrSubOrder());//采购委外订单号
+				entity.setPrice(detailsItem.getSalesUnitPrice());//单价
+				entity.setFactoryUnitPrice(detailsItem.getFactoryUnitPrice());//工厂单价
+
+				if (entity.getMasterMetering() == null) {
+					throw new JeecgBootException("未获取到销售订单的单位");
+				}
+//			if(entity.getMasterMetering().equals("KG")){
+//				updateQuantity(entity.getNetWeight(),entity.getSyShippingDetailsItemId(),entity.getMasterMetering());
+//			}else{
+//				updateQuantity(entity.getActualDeclaredQuantity(),entity.getSyShippingDetailsItemId(),entity.getMasterMetering());
+//			}
+
+
+				if ((entity.getInventoryCcode().substring(0, 2).equals("03") && !entity.getInventoryCcode().equals("0399")) ||
+						(entity.getInventoryCcode().substring(0, 2).equals("02") && !entity.getInventoryCcode().equals("0299")) ||
+						(entity.getInventoryCcode().substring(0, 2).equals("04") && !entity.getInventoryCcode().equals("0499"))) {
+					if (entity.getMeter() != null) {//前端计算米数
+						entity.setActualDeclaredQuantity(entity.getMeter());//修改报关数量
+					}
+				}
+				if (entity.getMasterMetering() != null && entity.getMasterMetering().equals("KG")) {//计算总价
+					if (entity.getNetWeight() != null) {
+						setNetWeight(entity);//净重保留两位小数
+						entity.setTotalPrice(entity.getNetWeight().multiply(entity.getPrice()).setScale(2, RoundingMode.HALF_UP));//净重*单价
+					}
+				} else {
+					if (entity.getActualDeclaredQuantity() != null) {
+						entity.setTotalPrice(entity.getActualDeclaredQuantity().multiply(entity.getPrice()).setScale(2, RoundingMode.HALF_UP));//实际报关数量*单价
+					}
+				}
+				syShippingDetailsItemMapper.updateById(detailsItem);
+				syPackingListFabricItemMapper.insert(entity);
+				respUpdateVO.setExtraInfo(respUpdateVO.getExtraInfo() + entity.getSrmId() + "," + entity.getId() + ";");
+			}
+			syPackingListFabric.setQuantity(total);//给数量附上初始值
+			syPackingListFabric.setRemainingQuantity(total);//给剩余数量附上初始值
+			syPackingListFabricMapper.updateById(syPackingListFabric);//重新修改数据
+			updateQuantitys(null, itemIds);
+			respUpdateVO.setMessage(syPackingListFabric.getId());
+			respUpdateVO.setSuccess(true);
+		}catch (Exception ex){
+			respUpdateVO.setMessage(ex.getMessage());
+		}
+		return respUpdateVO;
+	}
 }

+ 60 - 6
jeecg-boot-module-system/src/main/java/org/jeecg/modules/splt/controller/SyPackingListTailoringController.java

@@ -2245,19 +2245,73 @@ public class SyPackingListTailoringController implements Job {
 	 public RespUpdateVO srmAdd(@RequestBody SyPackingListTailoring syPackingListTailoring) {
 		 RespUpdateVO respUpdateVO = new RespUpdateVO();
 		 respUpdateVO.setSuccess(false);
-		 if (!srmAccessToken.equals(syPackingListTailoring.getAccessToken())){
+		 log.info("SRM推送\t{}", syPackingListTailoring);
+		 if (!srmAccessToken.equals(syPackingListTailoring.getAccessToken())) {
 			 respUpdateVO.setMessage("认证失败,请联系管理员");
 			 return respUpdateVO;
 		 }
 
-		 if(oConvertUtils.isEmpty(syPackingListTailoring)){
+		 if (oConvertUtils.isEmpty(syPackingListTailoring)) {
 			 respUpdateVO.setMessage("对象为空");
 			 return respUpdateVO;
 		 }
-		 syPackingListTailoringService.saveMain2(syPackingListTailoring);
-		 respUpdateVO.setSuccess(true);
-		 respUpdateVO.setMessage(syPackingListTailoring.getId());
-		 return respUpdateVO;
+		 try {
+			 // 从size中获取出运明细id
+			 List<String> prePackingIdList = new ArrayList<>();
+			 List<SyPackingListTailoringItem> itemList = syPackingListTailoring.getSyPackingListTailoringItemList();
+			 itemList.forEach(item -> {
+				 item.getSizeTables().forEach(s -> {
+					 prePackingIdList.add(s.getItemId());
+				 });
+			 });
+			 List<SyPackingListTailoringItem> srmPushExtraList = syPackingListTailoringItemService.getSrmPushExtraList(prePackingIdList);
+			 if (srmPushExtraList.size() == 0) {
+				 log.error("查找预装箱单明细失败");
+				 respUpdateVO.setMessage("查找预装箱单明细失败");
+				 return respUpdateVO;
+			 }
+			 // 赋值
+			 SyPackingListTailoringItem item = srmPushExtraList.get(0);
+			 syPackingListTailoring.setOrderNumber(item.getOrderNumber());
+			 syPackingListTailoring.setCustomer(item.getCustomerName());
+			 syPackingListTailoring.setCustomerAbbreviation(item.getCustomerAbbreviation());
+			 syPackingListTailoring.setGarmentFactory(item.getGarmentFactory());
+			 syPackingListTailoring.setElementsId(item.getElementsId());
+			 syPackingListTailoring.setOmpoId(item.getOmpoId());
+			 syPackingListTailoring.setIsTc(item.getIsTc());
+			 syPackingListTailoring.setSalesman(item.getSalesman());
+			 syPackingListTailoring.setSalesDepartment(item.getSalesDepartment());
+			 syPackingListTailoring.setSyOrderDataId(item.getSyOrderDataId());
+			 syPackingListTailoring.setTotalPrice(syPackingListTailoring.getTotal().multiply(item.getUnitPrice()));
+			 for (SyPackingListTailoringItem tailoringItem : itemList) {
+				 SizeTable sizeTable = tailoringItem.getSizeTables().get(0);
+				 SyPackingListTailoringItem findExtraInfo = srmPushExtraList.stream().filter(e -> e.getSyPreAssembledPackingListItemId().equals(sizeTable.getItemId())).findFirst().orElse(null);
+				 if (srmPushExtraList.size() == 0) {
+					 log.error("查找出运明细失败:\t{}", sizeTable);
+					 respUpdateVO.setMessage("查找出运明细失败");
+					 return respUpdateVO;
+				 }
+				 tailoringItem.setAcSetNo(findExtraInfo.getAcSetNo());
+				 tailoringItem.setGarmentFactory(findExtraInfo.getGarmentFactory());
+				 tailoringItem.setUnitPrice(findExtraInfo.getUnitPrice());
+				 tailoringItem.setTotalPrice(findExtraInfo.getUnitPrice().multiply(tailoringItem.getTotal()));
+				 tailoringItem.setWithCode(findExtraInfo.getWithCode());
+				 tailoringItem.setSyOrderDataItemId(findExtraInfo.getSyOrderDataItemId());
+				 tailoringItem.setSyOrderDataId(findExtraInfo.getSyOrderDataId());
+				 tailoringItem.setOmpoIdItem(findExtraInfo.getOmpoIdItem());
+				 tailoringItem.setOmpoId(findExtraInfo.getOmpoId());
+				 tailoringItem.setOrderNumber(findExtraInfo.getOrderNumber());
+				 tailoringItem.setSalesman(findExtraInfo.getSalesman());
+				 tailoringItem.setSalesDepartment(findExtraInfo.getSalesDepartment());
+				 tailoringItem.setCustomsDeclarationUnitPrice(findExtraInfo.getCustomsDeclarationUnitPrice());
+				 tailoringItem.setSupplier(findExtraInfo.getSupplier());
+			 }
+			 return syPackingListTailoringService.saveSrmBill(syPackingListTailoring);
+
+		 }catch (Exception ex){
+			 respUpdateVO.setMessage(ex.getMessage());
+			 return respUpdateVO;
+		 }
 	 }
 
 }

+ 13 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/splt/entity/SyPackingListTailoringItem.java

@@ -458,4 +458,17 @@ public class SyPackingListTailoringItem implements Serializable {
 				//netWeightToo+","+
 				remarks;
 	}
+	/** 以下单证推送用 **/
+	// 客户全称
+	@TableField(exist = false)
+	private String customerName;
+	// 客户简称
+	@TableField(exist = false)
+	private String customerAbbreviation;
+	// 客户代码
+	@TableField(exist = false)
+	private String customerCode;
+	// srm id
+	@TableField(exist = false)
+	private String srmId;
 }

+ 7 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/splt/mapper/SyPackingListTailoringItemMapper.java

@@ -49,4 +49,11 @@ public interface SyPackingListTailoringItemMapper extends BaseMapper<SyPackingLi
 	String getiTaxPrice(String id);
 
 	String getiTaxPrice2(String id);
+
+	/**
+	 * 根据预发货单子表ID获取SRM推送装箱单时需要的数据
+	 * @param prePackingIdList
+	 * @return
+	 */
+	List<SyPackingListTailoringItem> getSrmPushExtraList(@Param("prePackingIdList")List<String> prePackingIdList);
 }

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

@@ -383,6 +383,41 @@
         on OM_MODetails.MODetailsID  =rdrecords01.iOMoDID
         where rdrecords01.autoid=#{value }
     </select>
-
+	<!-- SRM推送时信息查询-->
+	<select id="getSrmPushExtraList" parameterType="java.lang.String" resultType="org.jeecg.modules.splt.entity.SyPackingListTailoringItem">
+		select * from (
+		SELECT
+		a.id as sy_Pre_Assembled_Packing_List_Item_Id,
+		a.sy_Pre_Assembled_Packing_List_Id,
+		b.account as ac_set_no,
+		b.garment_Factory as garment_factory,
+		c.unit_price_including_tax as unit_price,
+		c.coding_rules as with_code,
+		a.sy_order_data_id,
+		a.sy_order_data_item_id,
+		c.ompo_id,
+		c.ompo_id_item,
+		a.ymoney,
+		a.order_number,
+		a.sales_department,
+		a.salesman,
+		a.customs_declaration_unit_price,
+		d.elements_id,
+		d.is_tc,
+		c.supplier,
+		b.customer_name,
+		b.customer_abbreviation,
+		b.customer_code
+		FROM
+		sy_pre_assembled_packing_list_item a
+		inner join sy_pre_assembled_packing_list d on a.sy_Pre_Assembled_Packing_List_Id=d.id
+		left join sy_order_data b on a.sy_order_data_id=b.id
+		left join sy_order_data_item c on a.sy_order_data_item_id=c.id
+		) as t1
+		where sy_Pre_Assembled_Packing_List_Item_Id in
+		<foreach collection="prePackingIdList" item="value" index="index" open="(" separator="," close=")">
+			#{value}
+		</foreach>
+	</select>
 
 </mapper>

+ 8 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/splt/service/ISyPackingListTailoringItemService.java

@@ -1,5 +1,6 @@
 package org.jeecg.modules.splt.service;
 
+import org.apache.ibatis.annotations.Param;
 import org.jeecg.modules.splt.entity.SyPackingListTailoringItem;
 import com.baomidou.mybatisplus.extension.service.IService;
 import java.util.List;
@@ -13,4 +14,11 @@ import java.util.List;
 public interface ISyPackingListTailoringItemService extends IService<SyPackingListTailoringItem> {
 
 	public List<SyPackingListTailoringItem> selectByMainId(String mainId);
+
+	/**
+	 * 根据预发货单子表ID获取SRM推送装箱单时需要的数据
+	 * @param prePackingIdList
+	 * @return
+	 */
+	List<SyPackingListTailoringItem> getSrmPushExtraList(List<String> prePackingIdList);
 }

+ 4 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/splt/service/ISyPackingListTailoringService.java

@@ -5,7 +5,9 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.apache.ibatis.annotations.Param;
 import org.jeecg.common.system.vo.DictModel;
+import org.jeecg.modules.documents.shippingDetails.entity.VO.RespUpdateVO;
 import org.jeecg.modules.documents.syShippingOrder.entity.SyShippingOrderItem;
+import org.jeecg.modules.spapl.entity.SyPreAssembledPackingList;
 import org.jeecg.modules.splfi.entity.SyPackingListFabric;
 import org.jeecg.modules.splt.entity.SyPackingListTailoringItem;
 import org.jeecg.modules.splt.entity.SyPackingListTailoring;
@@ -152,4 +154,6 @@ public interface ISyPackingListTailoringService extends IService<SyPackingListTa
 	List<String> getRedisSno(int max);
 
 	void updateTimeStatus();
+
+	RespUpdateVO saveSrmBill(SyPackingListTailoring syPackingListTailoring);
 }

+ 10 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/splt/service/impl/SyPackingListTailoringItemServiceImpl.java

@@ -33,4 +33,14 @@ public class SyPackingListTailoringItemServiceImpl extends ServiceImpl<SyPacking
 		}
 		return items;
 	}
+
+	/**
+	 * 根据预发货单子表ID获取SRM推送装箱单时需要的数据
+	 * @param prePackingIdList
+	 * @return
+	 */
+	@Override
+	public List<SyPackingListTailoringItem> getSrmPushExtraList(List<String> prePackingIdList){
+		return syPackingListTailoringItemMapper.getSrmPushExtraList(prePackingIdList);
+	}
 }

+ 106 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/splt/service/impl/SyPackingListTailoringServiceImpl.java

@@ -12,10 +12,12 @@ import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.exception.JeecgBootException;
 import org.jeecg.common.system.vo.DictModel;
 import org.jeecg.common.util.RedisUtil;
+import org.jeecg.common.util.UUIDGenerator;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.config.InterfaceConnUtils;
 import org.jeecg.modules.documents.letterDeposit.entity.SyLetterDeposit;
 import org.jeecg.modules.documents.shippingDetails.entity.SyShippingDetailsItem;
+import org.jeecg.modules.documents.shippingDetails.entity.VO.RespUpdateVO;
 import org.jeecg.modules.documents.syShippingOrder.entity.SyShippingOrderItem;
 import org.jeecg.modules.documents.syShippingOrder.mapper.SyShippingOrderItemMapper;
 import org.jeecg.modules.documents.syShippingOrder.mapper.SyShippingOrderMapper;
@@ -38,12 +40,14 @@ import org.jeecg.modules.splt.service.ISyPackingListTailoringService;
 import org.jeecg.modules.splt.vo.SyPackingListTailoringVo;
 import org.jeecg.modules.system.service.impl.SysDictServiceImpl;
 import org.springframework.beans.BeanUtils;
+import org.springframework.context.annotation.Bean;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.interceptor.TransactionAspectSupport;
 
+import javax.annotation.Resource;
 import java.io.FileWriter;
 import java.io.Serializable;
 import java.math.BigDecimal;
@@ -1187,7 +1191,7 @@ public class SyPackingListTailoringServiceImpl extends ServiceImpl<SyPackingList
 		return strs;
 	}
 
-	@Autowired
+	@Resource
 	private PurchaseWarehousingMapper purchaseWarehousingMapper;//采购入库表
 
 	@DS("multi-one")
@@ -2793,4 +2797,105 @@ public class SyPackingListTailoringServiceImpl extends ServiceImpl<SyPackingList
 		}
 		return ids;
 	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public RespUpdateVO saveSrmBill(SyPackingListTailoring syPackingListTailoring){
+		RespUpdateVO respUpdateVO = new RespUpdateVO();
+		respUpdateVO.setSuccess(false);
+		respUpdateVO.setExtraInfo("");
+		try {
+			List<SyPackingListTailoringItem> items = syPackingListTailoring.getSyPackingListTailoringItemList();
+			//SyPackingListTailoring.setDocumentNo(oConvertUtils.id());//随机单据号
+			syPackingListTailoring.setDelFlag("0");//删除状态默认为0
+			syPackingListTailoring.setPushState("0");//推送状态默认为0
+			syPackingListTailoring.setStatus("0");//单据状态默认为0
+			syPackingListTailoring.setDocumentNo(randomStr());//单据号
+			syPackingListTailoringMapper.insert(syPackingListTailoring);//往主表添加数据
+			UpdateWrapper updateWrapper = new UpdateWrapper();
+			updateWrapper.set("is_Reference", "2");//已被预装箱单参照,装箱单不能取消提交
+			updateWrapper.eq("id", syPackingListTailoring.getSyPreAssembledPackingListId());//预装箱单主表id做为修改条件
+			syPreAssembledPackingListMapper.update(null, updateWrapper);//修改
+			SyPreAssembledPackingList syPreAssembledPackingList = syPreAssembledPackingListMapper.selectById(syPackingListTailoring.getSyPreAssembledPackingListId());//获取订单数据id
+			if (syPreAssembledPackingList != null && syPreAssembledPackingList.getSyOrderDataId() != null) {
+				syPackingListTailoring.setSyOrderDataId(syPackingListTailoring.getSyOrderDataId());
+
+			}
+			if (syPackingListTailoring.getSyPackingListTailoringItemList() != null) {
+				syPackingListTailoring.setTotalBoxes(new BigDecimal("0"));//总箱数
+				syPackingListTailoring.setTotal(new BigDecimal("0"));//总件数
+				syPackingListTailoring.setTotalGrossWeight(new BigDecimal("0"));//总毛重
+				syPackingListTailoring.setTotalNetWeight(new BigDecimal("0"));//总净重
+				syPackingListTailoring.setTotalPrice(new BigDecimal("0"));//总价
+				syPackingListTailoring.setTotalVolume(new BigDecimal("0"));//总体积
+				for (SyPackingListTailoringItem item : items) {
+					List<SizeTable> sizes = item.getSizeTables();//获取尺码表信息
+					item.setSyPackingListTailoringId(syPackingListTailoring.getId());//获取主表id
+					item.setElementsId(syPackingListTailoring.getElementsId());//申报要素id
+					syPackingListTailoring.setTotalBoxes(syPackingListTailoring.getTotalBoxes().add(item.getBoxNumber()));//总箱数
+					syPackingListTailoring.setTotal(syPackingListTailoring.getTotal().add(item.getTotal()));//总件数
+					syPackingListTailoring.setTotalGrossWeight(syPackingListTailoring.getTotalGrossWeight().add(item.getTotalGrossWeight()));//总毛重
+					syPackingListTailoring.setTotalNetWeight(syPackingListTailoring.getTotalNetWeight().add(item.getTotalNetWeight()));//总净重
+					syPackingListTailoring.setTotalPrice(syPackingListTailoring.getTotalPrice().add(item.getTotalPrice()));//总价
+					syPackingListTailoring.setTotalVolume(syPackingListTailoring.getTotalVolume().add(item.getTotalVolume()));//总体积
+					BigDecimal boxNumber1 = item.getBoxNumber();//获取箱数
+					item.setGroupId(oConvertUtils.id());//分组随机id
+					item.setDelFlag("0");//默认为未删除
+					for (SizeTable size : sizes) {
+						if (size.getProportion() == null) {
+							size.setProportion(0);
+						}
+						SyPackingListTailoringItem item1 = new SyPackingListTailoringItem();
+						BeanUtils.copyProperties(item, item1);
+						item1.setSize(size.getSize());//获取尺码信息
+						BigDecimal boxNumber = boxNumber1.multiply(new BigDecimal(size.getProportion()));//获取该尺码件数
+						item1.setTotal(boxNumber);//该尺码件数
+
+						item1.setActualPackingQty(boxNumber);
+						item1.setPlanQuantity(size.getQuantity());//计划装箱数量
+						item1.setSize(size.getSize());//获取尺码
+						item1.setTotalPrice(boxNumber.multiply(item1.getUnitPrice()).setScale(2, RoundingMode.HALF_UP));//获取总价		箱数*单价-->件数*单价
+						item1.setSyPreAssembledPackingListItemId(size.getItemId());//获取到预装箱单子表id
+						item1.setSort(size.getNum());//获取序号
+						item1.setId(oConvertUtils.id());//获取到随机id
+						SyPreAssembledPackingListItem syPreItem = syPreAssembledPackingListItemMapper.selectById(item1.getSyPreAssembledPackingListItemId());//获取预装箱单数据
+//					syPreItem.setRemainingQuantity(syPreItem.getRemainingQuantity().subtract(boxNumber));//新剩余数量=原剩余数量-装箱单新增数量
+//					syPreItem.setExcessQuantity(syPreItem.getRemainingQuantity().subtract(boxNumber).negate());
+						item1.setSalesman(syPreItem.getSalesman());//获取业务员
+						if (item1.getFactoryUnitPrice() != null) {
+							item1.setFactoryUnitPrice(syPreItem.getFactoryUnitPrice());//工厂单价
+						}
+						item1.setPackId(syPreItem.getPackId());//packid
+						item1.setCustomsDeclarationUnitPrice(syPreItem.getCustomsDeclarationUnitPrice());//报关单价
+						item1.setSalesDepartment(syPreItem.getSalesDepartment());//获取业务部门
+						item1.setSyOrderDataId(syPreItem.getSyOrderDataId());//订单数据主表id
+						item1.setSyOrderDataItemId(syPreItem.getSyOrderDataItemId());//订单数据子表id
+						item1.setOrderNumber(syPreItem.getOrderNumber());//销售订单号
+						item1.setSpurOrSubOrder(syPreItem.getSpurOrSubOrder());//获取采购委外订单号
+						item1.setOmpoId(syPreItem.getOmpoId());//获取采购委外主表id
+						item1.setMasterMetering(item1.getMasterMetering());
+						item1.setOmpoIdItem(syPreItem.getOmpoIdItem());//获取采购委外子表id
+						item1.setOmpoAccount(syPreItem.getOmpoAccount());//委外采购账套号
+						item1.setSupplier(syPreItem.getSupplier());
+						item1.setSupplierCode(syPreItem.getSupplierCode());
+						if (size.getProportion() == 0) {
+							item1.setTotal(null);//该尺码件数
+						}
+						syPreAssembledPackingListItemMapper.updateById(syPreItem);//修改剩余数量
+						syPackingListTailoringItemMapper.insert(item1);//添加子表数据
+						respUpdateVO.setExtraInfo(respUpdateVO.getExtraInfo() + size.getSrmId() + "," + item1.getId() + ";");
+
+					}
+				}
+				syPackingListTailoringMapper.updateById(syPackingListTailoring);
+				respUpdateVO.setMessage(syPreAssembledPackingList.getId());
+				respUpdateVO.setSuccess(true);
+			} else {
+				respUpdateVO.setMessage("子表明细不能为空");
+			}
+		}catch (Exception ex){
+			respUpdateVO.setMessage(ex.getMessage());
+		}
+		return respUpdateVO;
+	}
 }