Sfoglia il codice sorgente

单证近期调整调整

huxy 4 mesi fa
parent
commit
d906b1e7f9
35 ha cambiato i file con 1539 aggiunte e 481 eliminazioni
  1. 46 12
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/cost/controller/SyCostAllocationController.java
  2. 16 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/cost/mapper/SyCostAllocationFabricMapper.java
  3. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/cost/mapper/xml/SyCostAllocationAccidentMapper.xml
  4. 334 8
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/cost/mapper/xml/SyCostAllocationFabricMapper.xml
  5. 39 45
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/cost/mapper/xml/SyCostAllocationIngredientMapper.xml
  6. 244 153
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/cost/service/impl/SyCostAllocationServiceImpl.java
  7. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/costLossReview/controller/SyCostLossReviewController.java
  8. 13 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/letterDeposit/controller/SyLetterDepositController.java
  9. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/orderData/service/impl/SyOrderDataServiceImpl.java
  10. 62 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/shippingDetails/controller/SyShippingDetailsController.java
  11. 16 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/shippingDetails/entity/VO/PurchasePreDeliverDetailSizeVo.java
  12. 66 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/shippingDetails/entity/VO/PurchasePreDeliverDetailVo.java
  13. 38 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/shippingDetails/entity/VO/PurchasePreDeliverVo.java
  14. 6 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/shippingDetails/mapper/SyShippingDetailsMapper.java
  15. 50 8
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/shippingDetails/mapper/xml/SyShippingDetailsMapper.xml
  16. 2 3
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/shippingDetails/service/ISyShippingDetailsService.java
  17. 26 7
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/shippingDetails/service/impl/SyShippingDetailsServiceImpl.java
  18. 41 4
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/spapl/controller/SyPreAssembledPackingListController.java
  19. 4 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/spapl/entity/SizeTable.java
  20. 5 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/spapl/entity/SyPreAssembledPackingList.java
  21. 28 81
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/spapl/mapper/xml/SyPreAssembledPackingListItemMapper.xml
  22. 2 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/spapl/mapper/xml/SyPreAssembledPackingListMapper.xml
  23. 2 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/spapl/service/ISyPreAssembledPackingListItemService.java
  24. 5 3
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/spapl/service/ISyPreAssembledPackingListService.java
  25. 61 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/spapl/service/impl/SyPreAssembledPackingListItemServiceImpl.java
  26. 175 4
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/spapl/service/impl/SyPreAssembledPackingListServiceImpl.java
  27. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/splfi/mapper/xml/SyPackingListFabricItemMapper.xml
  28. 84 29
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/splfi/service/impl/SyPackingListFabricServiceImpl.java
  29. 33 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/splt/controller/SyPackingListTailoringController.java
  30. 5 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/splt/entity/SyPackingListTailoringItem.java
  31. 9 3
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/splt/mapper/xml/syPackingListTailoringItemMapper.xml
  32. 7 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/splt/service/ISyPackingListTailoringService.java
  33. 103 107
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/splt/service/impl/SyPackingListTailoringServiceImpl.java
  34. 9 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/SysDictItemController.java
  35. 4 5
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/mapper/xml/SysDictMapper.xml

+ 46 - 12
jeecg-boot-module-system/src/main/java/org/jeecg/modules/cost/controller/SyCostAllocationController.java

@@ -57,6 +57,7 @@ import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.*;
+import java.math.BigDecimal;
 import java.util.*;
 
 /**
@@ -137,11 +138,30 @@ public class SyCostAllocationController {
             if(list.size()>0){
                 syCostAllocation = JSON.parseObject(JSON.toJSONString(list.get(0).getCostInfo()), SyCostAllocation.class);
                 syCostAllocation.setAttachs(list.get(0).getAttachs());
-
                 if (org.jeecg.modules.system.util.oConvertUtils.isNotEmpty(syCostAllocation.getGarmentContractno())) {
                     accessorItemList = fabricLossMapper.getSoAccList(Arrays.asList(syCostAllocation.getGarmentContractno().split(",")));
                     accessorItemList.forEach(e -> e.setFileurl("/report/FabricLoss/getFile?fileId=" + e.getCFileId() + "&filename=" + e.getFilename()));
                 }
+                //面料集合
+                JSONArray fabrics2 = syCostAllocation.getProcessUnitList().get(0).getJSONArray("syCostAllocationFabricList");
+                for (int i=0;i<fabrics2.size();i++){
+                    JSONObject fabric1=fabrics2.getJSONObject(i);
+                    if (fabric1.get("fabricremainingQuantity")==null||new BigDecimal(fabric1.get("fabricremainingQuantity").toString()).compareTo(new BigDecimal("0"))==0){//余下数量
+                        fabric1.put("remainingQuantitycost",null);//余下成本
+                    }
+                    if (fabric1.get("fabrictransferQuantity")==null||new BigDecimal(fabric1.get("fabrictransferQuantity").toString()).compareTo(new BigDecimal("0"))==0){//转入数量
+                        fabric1.put("transferCost",null);//余下成本
+                    }
+                }
+                //辅料集合
+                JSONArray ingredients1 = syCostAllocation.getProcessUnitList().get(0).getJSONArray("syCostAllocationIngredientList");
+                for (int i=0;i<ingredients1.size();i++){
+                    JSONObject ingredient=ingredients1.getJSONObject(i);
+                    if(ingredient.get("ingredientsTransferQuantity")==null||ingredient.get("ingredientsTransferQuantity").equals("") ||
+                        new BigDecimal(ingredient.get("ingredientsTransferQuantity").toString()).compareTo(new BigDecimal("0"))==0){//转入数量
+                        ingredient.put("transferCost",null);//余下成本
+                    }
+                }
                 syCostAllocation.setAccessorItemList(accessorItemList);
                 Result.OK(syCostAllocation);
             }else {
@@ -168,7 +188,7 @@ public class SyCostAllocationController {
                 }
                 syCostAllocation2.setAccessorItemList(accessorItemList);
                 List<SyCostAllocationFabric> fabrics1 = (List<SyCostAllocationFabric>) syCostAllocation.getProcessUnitList().get(0).get("syCostAllocationFabricList");
-                List<SyCostAllocationIngredient> ingredients1=(List<SyCostAllocationIngredient>)  syCostAllocation.getProcessUnitList().get(0).get("syCostAllocationIngredientList");
+                List<SyCostAllocationIngredient> ingredients1 = (List<SyCostAllocationIngredient>) syCostAllocation.getProcessUnitList().get(0).get("syCostAllocationIngredientList");
                 JSONArray fabrics2 = syCostAllocation2.getProcessUnitList().get(0).getJSONArray("syCostAllocationFabricList");
                 JSONArray ingredients2=syCostAllocation2.getProcessUnitList().get(0).getJSONArray("syCostAllocationIngredientList");
 //                List<SyCostAllocationFabric> fabrics2 = JSONArray.parseArray(syCostAllocation2.getProcessUnitList().get(0).getJSONArray("syCostAllocationFabricList").toJSONString(), SyCostAllocationFabric.class);
@@ -176,24 +196,34 @@ public class SyCostAllocationController {
                 for (int i=0;i<fabrics2.size();i++){
                     SyCostAllocationFabric fabric2=JSONObject.parseObject(String.valueOf(fabrics2.getJSONObject(i)),SyCostAllocationFabric.class);
                     for (SyCostAllocationFabric fabric1 :fabrics1){
-//                        System.out.println("fabric1\t"+fabric1);
-//                        System.out.println("fabric2\t"+fabric2);
                         if (fabric2.getGoodsName().equals(fabric1.getGoodsName())
                                 &&fabric2.getUsageQuantity().doubleValue()==fabric1.getUsageQuantity().doubleValue()
                                 &&fabric2.getRemarks()!=null){
                             fabric1.setRemarks(fabric2.getRemarks());
-                            for(SyCostAllocationFabric pilosity2 : fabric2.getPilosityFewerList()){
-                                for (SyCostAllocationFabric pilosity1 : fabric1.getPilosityFewerList()){
-                                    if (pilosity1.getGoodsName()!=null  &&pilosity2.getGoodsName()!=null
-                                        &&pilosity2.getGoodsName().equals(pilosity1.getGoodsName())
-                                        &&pilosity1.getPlanQuantity()!=null &&pilosity2.getPlanQuantity()!=null
-                                        &&pilosity2.getPlanQuantity().doubleValue()==pilosity1.getPlanQuantity().doubleValue()
-                                        &&pilosity2.getRemarks()!=null){
-                                        pilosity1.setRemarks(pilosity2.getRemarks());
+                            if (fabric2.getPilosityFewerList()!=null){
+                                for(SyCostAllocationFabric pilosity2 : fabric2.getPilosityFewerList()){
+                                    if (fabric1.getPilosityFewerList()!=null){
+                                        for (SyCostAllocationFabric pilosity1 : fabric1.getPilosityFewerList()){
+                                            if (pilosity1.getGoodsName()!=null  &&pilosity2.getGoodsName()!=null
+                                                    &&pilosity2.getGoodsName().equals(pilosity1.getGoodsName())
+                                                    &&pilosity1.getPlanQuantity()!=null &&pilosity2.getPlanQuantity()!=null
+                                                    &&pilosity2.getPlanQuantity().doubleValue()==pilosity1.getPlanQuantity().doubleValue()
+                                                    &&pilosity2.getRemarks()!=null){
+                                                pilosity1.setRemarks(pilosity2.getRemarks());
+                                            }
+                                        }
                                     }
                                 }
                             }
                         }
+//                        System.out.println("ML余下数量\t"+fabric1.getFabricremainingQuantity()+"\t余下成本\t"+fabric1.getRemainingQuantitycost());
+                        if (fabric1.getFabricremainingQuantity()==null||fabric1.getFabricremainingQuantity().compareTo(new BigDecimal("0"))==0){//余下数量
+                            fabric1.setRemainingQuantitycost(null);//余下成本
+                        }
+//                        System.out.println("ML转入数量\t"+fabric1.getFabrictransferQuantity()+"\t转入成本\t"+fabric1.getTransferCost());
+                        if (fabric1.getFabrictransferQuantity()==null||fabric1.getFabrictransferQuantity().compareTo(new BigDecimal("0"))==0){//转入数量
+                            fabric1.setTransferCost(null);//转入成本
+                        }
                     }
                 }
                 for (int i=0;i<ingredients2.size();i++){
@@ -207,6 +237,10 @@ public class SyCostAllocationController {
                                 &&fabric2.getSupper().equals(fabric1.getSupper())&&fabric2.getRemarks()!=null){
                             fabric1.setRemarks(fabric2.getRemarks());
                         }
+//                        System.out.println("FL转入数量\t"+fabric1.getIngredientsTransferQuantity()+"\t转入成本\t"+fabric1.getTransferCost());
+                        if(fabric1.getIngredientsTransferQuantity()==null||fabric1.getIngredientsTransferQuantity().compareTo(new BigDecimal("0"))==0){//转入数量
+                            fabric1.setTransferCost(null);//转入成本
+                        }
                     }
                 }
             }

+ 16 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/cost/mapper/SyCostAllocationFabricMapper.java

@@ -37,12 +37,28 @@ public interface SyCostAllocationFabricMapper extends BaseMapper<SyCostAllocatio
 	@DS("multi-three")
 	List<SyTransfer> queryTransferByFabric2(@Param("code") String code,@Param("goodName") String goodName);
 	@DS("multi-three")
+	List<SyTransfer> queryTransferByFabric3(@Param("code") String code);
+	@DS("multi-three")
+	List<SyTransfer> queryTransferByFabric4(@Param("code") String code);
+	@DS("multi-three")
 	List<SyRemaining> queryRemainingByFabric(@Param("code") String code, @Param("goodName") String goodName);
 	@DS("multi-three")
 	List<SyRemaining> queryRemainingByFabric2(@Param("code") String code, @Param("goodName") String goodName);
+	@DS("multi-three")
+	List<SyRemaining> queryRemainingByFabric3(@Param("code") String code, @Param("goodName") String goodName);
+	@DS("multi-three")
+	List<SyRemaining> queryRemainingByFabric4(@Param("code") String code);
 
 	//面料sheet多发少发链接
 	@DS("multi-three")
 	List<SyCostAllocationFabric> querypilosityFewer(@Param("code") String code,@Param("goodName") String goodName);
 
+	//面料sheet多发少发链接
+	@DS("multi-three")
+	List<SyCostAllocationFabric> querypilosityFewer2(@Param("code") String code);
+
+	//面料sheet多发少发链接
+	@DS("multi-three")
+	List<SyCostAllocationFabric> querypilosityFewer3(@Param("code") String code);
+
 }

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

@@ -19,7 +19,7 @@
 	<select id="queryByCostAccident" resultType="org.jeecg.modules.cost.entity.SyCostAllocationAccident">
 		select
 			it.id as id,its.u8_invoice as accidentNum,its.money_type,it.accident_number,its.accident_type,it.accident_theme,
-				case when its.money_type='美元' and its.accident_type != '公司承担' then ifnull(sum(its.practical_sum),0) end as amount,
+			case when its.money_type='美元' and its.accident_type != '公司承担' then ifnull(sum(its.practical_sum),0) end as amount,
 			case when its.money_type='人民币' and its.accident_type != '公司承担' then ifnull(sum(its.practical_sum),0) end as amountrmb,
 			case when its.money_type='美元' and its.accident_type = '公司承担' then ifnull(sum(its.practical_sum),0) end as pkorgAmount,
 			case when its.money_type='人民币' and its.accident_type = '公司承担' then ifnull(sum(its.practical_sum),0) end as pkorgAmountrmb,

+ 334 - 8
jeecg-boot-module-system/src/main/java/org/jeecg/modules/cost/mapper/xml/SyCostAllocationFabricMapper.xml

@@ -251,7 +251,6 @@
 		else tab2.jian-isnull(tab1.purchaseQuantity,0) end as number
 		from
 		(
-
 		select i.cInvName,sum(rs.iQuantity) as purchaseQuantity,rs.cBatch,rs.cFree1 from UFDATA_103_2021.dbo.rdrecords01 rs
 		join UFDATA_103_2021.dbo.Inventory i on rs.cInvCode=i.cInvCode
 		where cPOID in (
@@ -293,17 +292,18 @@
 		and (tab1.cfree1=tab2.cfree1 or tab1.cfree1 is null and tab2.cfree1 is null )
 		where tab2.jian-isnull(tab1.purchaseQuantity,0) > 0 and tab2.cinvName = #{goodName}
 		and tab2.cBatch not  like CONCAT('%',#{code},'%')
+
     </select>
 
 
-	<select id="queryTransferByFabric2" resultType="org.jeecg.modules.cost.entity.SyTransfer">
+    <select id="queryTransferByFabric2" resultType="org.jeecg.modules.cost.entity.SyTransfer">
 
-		select
-		tab2.cinvName as goodsName,tab2.cFree1 as color,tab2.cBatch as planCode,
-		case when tab2.jian <![CDATA[<=]]> 0 then 0
-		else tab2.jian end as number
-		<!--case when tab2.jian-isnull(tab1.purchaseQuantity,0) <![CDATA[<=]]> 0 then 0
-		else tab2.jian-isnull(tab1.purchaseQuantity,0) end as number -->
+        select
+        tab2.cinvName as goodsName,tab2.cFree1 as color,tab2.cBatch as planCode,
+        case when tab2.jian <![CDATA[<=]]> 0 then 0
+        else tab2.jian end as number
+        <!--case when tab2.jian-isnull(tab1.purchaseQuantity,0) <![CDATA[<=]]> 0 then 0
+        else tab2.jian-isnull(tab1.purchaseQuantity,0) end as number -->
 		from
 		(
 		select i.cInvName,sum(rs.iQuantity) as purchaseQuantity,rs.cBatch,rs.cFree1 from UFDATA_101_2021.dbo.rdrecords01 rs
@@ -404,6 +404,108 @@
 	</select>
 
 
+	<select id="queryTransferByFabric3" resultType="org.jeecg.modules.cost.entity.SyTransfer">
+
+		select
+		tab2.cinvName as goodsName,tab2.cFree1 as color,tab2.cBatch as planCode,
+		case when tab2.jian-isnull(tab1.purchaseQuantity,0) <![CDATA[<=]]> 0 then 0
+		else tab2.jian-isnull(tab1.purchaseQuantity,0) end as number
+		from
+		(
+		select i.cInvName,sum(rs.iQuantity) as purchaseQuantity,rs.cBatch,rs.cFree1 from UFDATA_101_2021.dbo.rdrecords01 rs
+		join UFDATA_101_2021.dbo.Inventory i on rs.cInvCode=i.cInvCode
+		where cPOID in (
+		select distinct om.cPOID
+		from UFDATA_101_2021.dbo.PO_POmain om
+		join UFDATA_101_2021.dbo.PO_PODetails od on om.poid=od.poid
+		join UFDATA_101_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
+		WHERE om.cVerifier is not null  and (om.cCloser is null or om.cCloser!='asuser')
+		and om.cPOID like CONCAT('%',#{code},'%')
+		)
+		GROUP BY i.cInvName,rs.cBatch,rs.cFree1
+		union all
+		select i.cInvName,sum(rs.iQuantity) as purchaseQuantity,rs.cBatch,rs.cFree1 from UFDATA_101_2021.dbo.rdrecords01 rs
+		join UFDATA_101_2021.dbo.Inventory i on rs.cInvCode=i.cInvCode
+		where cPOID in (
+		select distinct om.cCode
+		from UFDATA_101_2021.dbo.om_momain om
+		join UFDATA_101_2021.dbo.OM_MODetails od on om.moid=od.moid
+		join UFDATA_101_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
+		WHERE om.cVerifier is not null  and omi.cInvCcode like '19%'
+		and om.cCode like CONCAT('%',#{code},'%')
+		)
+		GROUP BY i.cInvName,rs.cBatch,rs.cFree1
+		)tab1
+		right join
+		(
+		select i.cInvName,sum(rs.iQuantity) as jian,rs.cBatch,rs.cFree1 from UFDATA_101_2021.dbo.rdrecords11 rs
+		join UFDATA_101_2021.dbo.Inventory i on rs.cInvCode=i.cInvCode
+		where comcode in (
+		select distinct om.ccode
+		from UFDATA_101_2021.dbo.om_momain om
+		join UFDATA_101_2021.dbo.OM_MODetails od on om.moid=od.moid
+		join UFDATA_101_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
+		WHERE om.iVerifyStateNew = 2
+		and omi.cInvCcode like '19%' and om.cCode like CONCAT('%',#{code},'%')
+		)
+		GROUP BY i.cInvName,rs.cBatch,rs.cFree1
+		)tab2 on tab2.cInvName=tab1.cInvName and tab2.cBatch=tab1.cBatch
+		and (tab1.cfree1=tab2.cfree1 or tab1.cfree1 is null and tab2.cfree1 is null )
+		where tab2.jian-isnull(tab1.purchaseQuantity,0) > 0
+		and tab2.cBatch not  like CONCAT('%',#{code},'%')
+
+		union all
+
+		select
+		tab2.cinvName as goodsName,tab2.cFree1 as color,tab2.cBatch as planCode,
+		case when tab2.jian-isnull(tab1.purchaseQuantity,0) <![CDATA[<=]]> 0 then 0
+		else tab2.jian-isnull(tab1.purchaseQuantity,0) end as number
+		from
+		(
+		select i.cInvName,sum(rs.iQuantity) as purchaseQuantity,rs.cBatch,rs.cFree1 from UFDATA_103_2021.dbo.rdrecords01 rs
+		join UFDATA_103_2021.dbo.Inventory i on rs.cInvCode=i.cInvCode
+		where cPOID in (
+		select distinct om.cPOID
+		from UFDATA_103_2021.dbo.PO_POmain om
+		join UFDATA_103_2021.dbo.PO_PODetails od on om.poid=od.poid
+		join UFDATA_103_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
+		WHERE om.cVerifier is not null and (om.cCloser is null or om.cCloser!='asuser')
+		and om.cPOID like CONCAT('%',#{code},'%')
+		)
+		GROUP BY i.cInvName,rs.cBatch,rs.cFree1
+		union all
+		select i.cInvName,sum(rs.iQuantity) as purchaseQuantity,rs.cBatch,rs.cFree1 from UFDATA_103_2021.dbo.rdrecords01 rs
+		join UFDATA_103_2021.dbo.Inventory i on rs.cInvCode=i.cInvCode
+		where cPOID in (
+		select distinct om.cCode
+		from UFDATA_103_2021.dbo.om_momain om
+		join UFDATA_103_2021.dbo.OM_MODetails od on om.moid=od.moid
+		join UFDATA_103_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
+		WHERE om.cVerifier is not null  and omi.cInvCcode like '19%'
+		and om.cCode like CONCAT('%',#{code},'%')
+		)
+		GROUP BY i.cInvName,rs.cBatch,rs.cFree1
+		)tab1
+		right join
+		(
+		select i.cInvName,sum(rs.iQuantity) as jian,rs.cBatch,rs.cFree1 from UFDATA_103_2021.dbo.rdrecords11 rs
+		join UFDATA_103_2021.dbo.Inventory i on rs.cInvCode=i.cInvCode
+		where comcode in (
+		select distinct om.ccode
+		from UFDATA_103_2021.dbo.om_momain om
+		join UFDATA_103_2021.dbo.OM_MODetails od on om.moid=od.moid
+		join UFDATA_103_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
+		WHERE om.iVerifyStateNew = 2
+		and omi.cInvCcode like '19%' and om.cCode like CONCAT('%',#{code},'%')
+		)
+		GROUP BY i.cInvName,rs.cBatch,rs.cFree1
+		)tab2 on tab2.cInvName=tab1.cInvName and tab2.cBatch=tab1.cBatch
+		and (tab1.cfree1=tab2.cfree1 or tab1.cfree1 is null and tab2.cfree1 is null )
+		where tab2.jian-isnull(tab1.purchaseQuantity,0) > 0
+		and tab2.cBatch not  like CONCAT('%',#{code},'%')
+
+    </select>
+
 <!--<select id="queryTransferByFabric3" resultType="org.jeecg.modules.cost.entity.SyTransfer">
 
 
@@ -630,6 +732,84 @@
 		GROUP BY oti.cInvName,ot.cFree1
 	</select>
 
+	<!--	面料余下数量链接方法-->
+	<select id="queryRemainingByFabric3" resultType="org.jeecg.modules.cost.entity.SyRemaining">
+		select cinvname as goodsName,cfree1 as color,
+		出库计划单号 as planCode,出库数量 as number
+		from TimeberwordFunction.dbo.invoke103
+		left join Inventory
+		on Inventory.cInvCode=invoke103.cinvcode
+		where 入库计划单号=#{code}
+		and cinvname=#{goodName}
+		and 出库计划单号!=#{code}
+	</select>
+
+	<!--	面料余下数量链接方法-->
+<!--	<select id="queryRemainingByFabric4" resultType="org.jeecg.modules.cost.entity.SyRemaining">
+		select cinvname as goodsName,a.*
+		from (SELECT cinvcode,cfree1 as color,
+		出库计划单号 planCode,
+		本款入库数量-总出库数量 number
+		FROM TimeberwordFunction.DBO.invoke101_v1
+		union all
+		SELECT cinvcode,cfree1 as color,
+		出库计划单号 planCode,
+		本款入库数量-总出库数量 number
+		FROM TimeberwordFunction.DBO.invoke103_v1 ) a
+		inner join Inventory b
+		on a.cInvCode=b.cinvcode
+		WHERE planCode like CONCAT('%',#{code},'%')
+		and number>0;
+	</select>-->
+
+
+	<select id="queryTransferByFabric4" resultType="org.jeecg.modules.cost.entity.SyTransfer">
+		SELECT cinvname AS goodsName, a.* FROM (
+		SELECT cinvcode as cinvcode, cfree1 AS color,
+		转入计划单号 planCode,出库计划单号 planCode2,
+		转入数量 number
+		FROM TimeberwordFunction.DBO.invoke101_v1 UNION ALL
+		SELECT cinvcode as cinvcode, cfree1 AS color,
+		转入计划单号 planCode,出库计划单号 planCode2,
+		转入数量 number
+		FROM TimeberwordFunction.DBO.invoke103_v1) a
+		INNER JOIN Inventory b ON a.cinvcode = b.cinvcode
+		WHERE planCode2 LIKE CONCAT('%', #{code}, '%')
+		AND number > 0;
+	</select>
+
+	<!--	面料余下数量链接方法-->
+	<select id="queryRemainingByFabric4停用" resultType="org.jeecg.modules.cost.entity.SyRemaining">
+		SELECT cinvname AS goodsName, a.* FROM (
+		SELECT icinvcode as cinvcode, cfree1 AS color,
+		转入计划单号 planCode2,出库计划单号 planCode,
+		转入数量 number
+		FROM TimeberwordFunction.DBO.invoke101_v1 UNION ALL
+		SELECT icinvcode as cinvcode, cfree1 AS color,
+		转入计划单号 planCode2,出库计划单号 planCode,
+		转入数量 number
+		FROM TimeberwordFunction.DBO.invoke103_v1) a
+		INNER JOIN Inventory b ON a.cinvcode = b.cinvcode
+		WHERE planCode2 LIKE CONCAT('%', #{code}, '%')
+		AND number > 0;
+	</select>
+
+	<!--	面料余下数量链接方法-->
+	<select id="queryRemainingByFabric4" resultType="org.jeecg.modules.cost.entity.SyRemaining">
+		SELECT cinvname AS goodsName, a.* FROM (
+		SELECT icinvcode as cinvcode,
+		cfree1 AS color,转入计划单号 planCode2,
+		出库计划单号 planCode,本款余数 number
+		FROM TimeberwordFunction.DBO.invoke101_v1 UNION ALL
+		SELECT icinvcode as cinvcode,
+		cfree1 AS color,转入计划单号 planCode2,
+		出库计划单号 planCode,本款余数 number
+		FROM TimeberwordFunction.DBO.invoke103_v1) a
+		INNER JOIN Inventory b ON a.cinvcode = b.cinvcode
+		WHERE planCode2 LIKE CONCAT('%', #{code}, '%')
+		AND number > 0;
+	</select>
+
 	<!--	面料余下数量链接方法-->
 	<select id="queryRemainingByFabric" resultType="org.jeecg.modules.cost.entity.SyRemaining">
 		select a.cfree1 color,a.cInvName goodsName,a.comcode planCode,purchaseQuantity2-purchaseQuantity1 as number
@@ -733,4 +913,150 @@
 		)tab1 on tab1.cInvName=tab.cInvName and tab1.color = tab.color
 
 	</select>
+
+
+
+	<!--	多发少发链接-->
+	<select id="querypilosityFewer2" parameterType="java.lang.String" resultType="org.jeecg.modules.cost.entity.SyCostAllocationFabric">
+		 select  tab.planQuantity as planQuantity,tab.color, tab.goodsName,
+		isnull(tab1.purchaseQuantity,0) as purchaseQuantity,
+		(isnull(tab.usageQuantity,0) - tab.planQuantity) as pilosityFewer
+		from(
+		select ot.cFree1 as color,oti.cInvName as cInvName,
+		max(oti.cInvName)/*+ ' '+ ot.cFree1*/ as goodsName,
+		sum(ot.iQuantity) as planQuantity,sum(ot.iSendQTY) as usageQuantity
+		from UFDATA_101_2021.dbo.om_momain om
+		join UFDATA_101_2021.dbo.OM_MODetails od on om.moid=od.moid
+		join UFDATA_101_2021.dbo.OM_MOMaterials ot on ot.MoDetailsID=od.MODetailsID
+		join UFDATA_101_2021.dbo.Inventory oti on oti.cInvCode=ot.cInvCode
+		join UFDATA_101_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
+		WHERE om.iVerifyStateNew = 2  and omi.cInvCcode like '19%' and om.cCode like CONCAT('%',#{code},'%')
+		AND ( ((isnull(iReceivedQTY, 0) + isnull(freceivedqty, 0) != 0 )
+		OR (isnull(iReceivedQTY, 0) + isnull(freceivedqty, 0) = 0 ))
+		AND (isnull(cbCloser, 'asuser') = 'asuser'))
+
+		GROUP BY ot.cFree1,oti.cInvName
+		) tab
+		left join
+	    (select rs.cFree1 as color,i.cInvName as cInvName,sum(rs.iQuantity) as purchaseQuantity,max(rs.cBatch) as cBatch
+		from UFDATA_101_2021.dbo.rdrecords01 rs
+		join UFDATA_101_2021.dbo.Inventory i on rs.cInvCode=i.cInvCode
+		where iordercode in (
+		select distinct od.csocode
+		from UFDATA_101_2021.dbo.PO_POmain om
+		join UFDATA_101_2021.dbo.PO_PODetails od on om.poid=od.poid
+		join UFDATA_101_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
+		WHERE om.cVerifier is not null
+		 and om.cPOID like CONCAT('%',#{code},'%')
+		)and rs.cBatch like CONCAT('%',#{code},'%')
+		GROUP BY rs.cFree1,i.cInvName
+		)tab1 on tab1.cInvName=tab.cInvName and tab1.color = tab.color
+
+		union all
+
+		select
+		tab.planQuantity as planQuantity,tab.color, tab.goodsName,isnull(tab1.purchaseQuantity,0) as purchaseQuantity,(isnull(tab.usageQuantity,0) - tab.planQuantity) as pilosityFewer
+		from
+		(select ot.cFree1 as color,oti.cInvName as cInvName,max(oti.cInvName)/*+ ' '+ ot.cFree1*/ as goodsName,
+		sum(ot.iQuantity) as planQuantity,sum(ot.iSendQTY) as usageQuantity
+		from UFDATA_103_2021.dbo.om_momain om
+		join UFDATA_103_2021.dbo.OM_MODetails od on om.moid=od.moid
+		join UFDATA_103_2021.dbo.OM_MOMaterials ot on ot.MoDetailsID=od.MODetailsID
+		join UFDATA_103_2021.dbo.Inventory oti on oti.cInvCode=ot.cInvCode
+		join UFDATA_103_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
+		WHERE om.iVerifyStateNew = 2  and omi.cInvCcode like '19%' and om.cCode like CONCAT('%',#{code},'%')
+		AND ( ((isnull(iReceivedQTY, 0) + isnull(freceivedqty, 0) != 0 )
+		OR (isnull(iReceivedQTY, 0) + isnull(freceivedqty, 0) = 0 ))
+		AND (isnull(cbCloser, 'asuser') = 'asuser'))
+		GROUP BY ot.cFree1,oti.cInvName
+		) tab
+		left join
+	 	(select rs.cFree1 as color,i.cInvName as cInvName,sum(rs.iQuantity) as purchaseQuantity,max(rs.cBatch) as cBatch
+		from UFDATA_101_2021.dbo.rdrecords01 rs
+		join UFDATA_103_2021.dbo.Inventory i on rs.cInvCode=i.cInvCode
+		where iordercode in (
+		select distinct od.csocode
+		from UFDATA_101_2021.dbo.PO_POmain om
+		join UFDATA_103_2021.dbo.PO_PODetails od on om.poid=od.poid
+		join UFDATA_103_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
+		WHERE om.cVerifier is not null
+		 and om.cPOID like CONCAT('%',#{code},'%')
+		)and rs.cBatch like CONCAT('%',#{code},'%')
+		GROUP BY rs.cFree1,i.cInvName
+		)tab1 on tab1.cInvName=tab.cInvName and tab1.color = tab.color
+	</select>
+
+
+	<!--	多发少发链接-->
+	<select id="querypilosityFewer3" parameterType="java.lang.String" resultType="org.jeecg.modules.cost.entity.SyCostAllocationFabric">
+		select  tab.planQuantity as planQuantity,tab.color, tab.goodsName,
+		isnull(tab1.purchaseQuantity,0) as purchaseQuantity,
+		(isnull(tab1.purchaseQuantity,0) - tab.planQuantity) as pilosityFewer
+		from(
+		select ot.cFree1 as color,oti.cInvName as cInvName,
+		max(oti.cInvName)/*+ ' '+ ot.cFree1*/ as goodsName,
+		sum(ot.iQuantity) as planQuantity,sum(ot.iSendQTY) as usageQuantity
+		from UFDATA_101_2021.dbo.om_momain om
+		join UFDATA_101_2021.dbo.OM_MODetails od on om.moid=od.moid
+		join UFDATA_101_2021.dbo.OM_MOMaterials ot on ot.MoDetailsID=od.MODetailsID
+		join UFDATA_101_2021.dbo.Inventory oti on oti.cInvCode=ot.cInvCode
+		join UFDATA_101_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
+		WHERE om.iVerifyStateNew = 2  and omi.cInvCcode like '19%' and om.cCode like CONCAT('%',#{code},'%')
+		AND ( ((isnull(iReceivedQTY, 0) + isnull(freceivedqty, 0) != 0 )
+		OR (isnull(iReceivedQTY, 0) + isnull(freceivedqty, 0) = 0 ))
+		AND (isnull(cbCloser, 'asuser') = 'asuser'))
+
+		GROUP BY ot.cFree1,oti.cInvName
+		) tab
+		left join
+	    (select rs.cFree1 as color,i.cInvName as cInvName,sum(rs.iQuantity) as purchaseQuantity,max(rs.cBatch) as cBatch
+		from UFDATA_101_2021.dbo.rdrecords01 rs
+		join UFDATA_101_2021.dbo.Inventory i on rs.cInvCode=i.cInvCode
+		where iordercode in (
+		select distinct od.csocode
+		from UFDATA_101_2021.dbo.PO_POmain om
+		join UFDATA_101_2021.dbo.PO_PODetails od on om.poid=od.poid
+		join UFDATA_101_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
+		WHERE om.cVerifier is not null
+		 and om.cPOID like CONCAT('%',#{code},'%')
+		)and rs.cBatch like CONCAT('%',#{code},'%')
+		GROUP BY rs.cFree1,i.cInvName
+		)tab1 on tab1.cInvName=tab.cInvName and tab1.color = tab.color
+
+		union all
+
+		select
+		tab.planQuantity as planQuantity,tab.color, tab.goodsName,
+		isnull(tab1.purchaseQuantity,0) as purchaseQuantity,
+		(isnull(tab1.purchaseQuantity,0) - tab.planQuantity) as pilosityFewer
+		from
+		(select ot.cFree1 as color,oti.cInvName as cInvName,max(oti.cInvName)/*+ ' '+ ot.cFree1*/ as goodsName,
+		sum(ot.iQuantity) as planQuantity,sum(ot.iSendQTY) as usageQuantity
+		from UFDATA_103_2021.dbo.om_momain om
+		join UFDATA_103_2021.dbo.OM_MODetails od on om.moid=od.moid
+		join UFDATA_103_2021.dbo.OM_MOMaterials ot on ot.MoDetailsID=od.MODetailsID
+		join UFDATA_103_2021.dbo.Inventory oti on oti.cInvCode=ot.cInvCode
+		join UFDATA_103_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
+		WHERE om.iVerifyStateNew = 2  and omi.cInvCcode like '19%' and om.cCode like CONCAT('%',#{code},'%')
+		AND ( ((isnull(iReceivedQTY, 0) + isnull(freceivedqty, 0) != 0 )
+		OR (isnull(iReceivedQTY, 0) + isnull(freceivedqty, 0) = 0 ))
+		AND (isnull(cbCloser, 'asuser') = 'asuser'))
+		GROUP BY ot.cFree1,oti.cInvName
+		) tab
+		left join
+	 	(select rs.cFree1 as color,i.cInvName as cInvName,sum(rs.iQuantity) as purchaseQuantity,max(rs.cBatch) as cBatch
+		from UFDATA_101_2021.dbo.rdrecords01 rs
+		join UFDATA_103_2021.dbo.Inventory i on rs.cInvCode=i.cInvCode
+		where iordercode in (
+		select distinct od.csocode
+		from UFDATA_101_2021.dbo.PO_POmain om
+		join UFDATA_103_2021.dbo.PO_PODetails od on om.poid=od.poid
+		join UFDATA_103_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
+		WHERE om.cVerifier is not null
+		 and om.cPOID like CONCAT('%',#{code},'%')
+		)and rs.cBatch like CONCAT('%',#{code},'%')
+		GROUP BY rs.cFree1,i.cInvName
+		)tab1 on tab1.cInvName=tab.cInvName and tab1.color = tab.color
+	</select>
+
 </mapper>

+ 39 - 45
jeecg-boot-module-system/src/main/java/org/jeecg/modules/cost/mapper/xml/SyCostAllocationIngredientMapper.xml

@@ -738,60 +738,54 @@ SELECT   	case when (a.iQuantityIn-b.usageQuantity)/a.iQuantityIn   <![CDATA[<=]
     </select>
 
 	<select id="queryRemainingByIngredient" resultType="org.jeecg.modules.cost.entity.SyRemaining">
-		select oti.cInvName as goodsName,max(om.cCode) as planCode,sum(ot.iSendQTY) as number ,
-								max(pb.iCost) as unitCost,sum(ot.iSendQTY)*max(pb.iCost) as cost
+		select  oti.cInvName as goodsName,max(om.cCode) as planCode,sum(ot.iSendQTY) as number ,
+				max(pb.iCost) as unitCost,sum(ot.iSendQTY)*max(pb.iCost) as cost
 				from UFDATA_101_2021.dbo.om_momain om
 				join UFDATA_101_2021.dbo.OM_MODetails od on om.moid=od.moid
 				join UFDATA_101_2021.dbo.OM_MOMaterials ot on ot.MoDetailsID=od.MODetailsID
 				join UFDATA_101_2021.dbo.Inventory oti on oti.cInvCode=ot.cInvCode
 				join UFDATA_101_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
 				left join (
-						SELECT p.cInvCode,p.iorderdid,sum(bi.iCost) as iCost
-						from UFDATA_101_2021.dbo.PO_Podetails p
-						join UFDATA_101_2021.dbo.PO_Pomain pm on p.POID  = pm.POID
-						join UFDATA_101_2021.dbo.PurBillVouchs bi  on bi.iPOsID=p.ID
-					  where pm.cVenCode != 'T010001'
-						GROUP BY p.cInvCode,p.iorderdid
-
-						union all
-
-					 select
-						pod.cInvCode,pod.iorderdid,sum(bi.iCost) as iCost
-						 from UFDATA_101_2021.dbo.PO_Pomain pom
-						 join UFDATA_101_2021.dbo.PO_Podetails pod on pod.POID  = pom.POID
-						 join UFDATA_102_2021.dbo.SO_SODetails sd on sd.cSOCode=pom.cpoid and sd.irowno=pod.ivouchrowno
-						 join UFDATA_102_2021.dbo.PO_Podetails pd on pd.iorderdid=sd.isosid
-						 join UFDATA_102_2021.dbo.PO_Pomain pm on pd.POID  = pm.POID
-						 join UFDATA_102_2021.dbo.PurBillVouchs bi  on bi.iPOsID=pd.ID
-						 join UFDATA_102_2021.dbo.Inventory oti on oti.cInvCode=pd.cInvCode
-						 where pm.cVenCode != 'T010001' and pom.cVenCode = 'T010001'
-						 GROUP BY pod.cInvCode,pod.iorderdid
+					 SELECT p.cInvCode,p.iorderdid,sum(bi.iCost) as iCost
+					 from UFDATA_101_2021.dbo.PO_Podetails p
+					 join UFDATA_101_2021.dbo.PO_Pomain pm on p.POID  = pm.POID
+					 join UFDATA_101_2021.dbo.PurBillVouchs bi  on bi.iPOsID=p.ID
+					 where pm.cVenCode != 'T010001'
+					 GROUP BY p.cInvCode,p.iorderdid
+					 union all
+					 select pod.cInvCode,pod.iorderdid,sum(bi.iCost) as iCost
+					 from UFDATA_101_2021.dbo.PO_Pomain pom
+					 join UFDATA_101_2021.dbo.PO_Podetails pod on pod.POID  = pom.POID
+					 join UFDATA_102_2021.dbo.SO_SODetails sd on sd.cSOCode=pom.cpoid and sd.irowno=pod.ivouchrowno
+					 join UFDATA_102_2021.dbo.PO_Podetails pd on pd.iorderdid=sd.isosid
+					 join UFDATA_102_2021.dbo.PO_Pomain pm on pd.POID  = pm.POID
+					 join UFDATA_102_2021.dbo.PurBillVouchs bi  on bi.iPOsID=pd.ID
+					 join UFDATA_102_2021.dbo.Inventory oti on oti.cInvCode=pd.cInvCode
+					 where pm.cVenCode != 'T010001' and pom.cVenCode = 'T010001'
+					 GROUP BY pod.cInvCode,pod.iorderdid
 				 ) pb on pb.cInvCode=ot.cInvCode and pb.iorderdid=od.isosid
 		WHERE om.iVerifyStateNew = 2  and omi.cInvCcode like '19%'
-					and om.cCode LIKE CONCAT('%',#{code},'%') and (oti.cInvCcode like '05%' or oti.cInvCcode like '06%'
-					or oti.cInvCcode like '07%' or oti.cInvCCode = '0399' or oti.cInvCCode = '0499')
-
+		and om.cCode LIKE CONCAT('%',#{code},'%') and (oti.cInvCcode like '05%' or oti.cInvCcode like '06%'
+		or oti.cInvCcode like '07%' or oti.cInvCCode = '0399' or oti.cInvCCode = '0499')
 		GROUP BY oti.cInvName
-
 		union all
-
-		select oti.cInvName as goodsName,max(om.cCode) as planCode,sum(ot.iSendQTY) as number ,
-								max(pb.iCost) as unitCost,sum(ot.iSendQTY)*max(pb.iCost) as cost
-		from UFDATA_103_2021.dbo.om_momain om
-		join UFDATA_103_2021.dbo.OM_MODetails od on om.moid=od.moid
-		join UFDATA_103_2021.dbo.OM_MOMaterials ot on ot.MoDetailsID=od.MODetailsID
-		join UFDATA_103_2021.dbo.Inventory oti on oti.cInvCode=ot.cInvCode
-		join UFDATA_103_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
-		left join (
-				SELECT p.cInvCode,p.iorderdid,max(bi.iCost) as iCost
-				from UFDATA_103_2021.dbo.PO_Podetails p
-				join UFDATA_103_2021.dbo.PurBillVouchs bi  on bi.iPOsID=p.ID
-				GROUP BY p.cInvCode,p.iorderdid
-		 ) pb on pb.cInvCode=ot.cInvCode and pb.iorderdid=od.isosid
-		WHERE om.iVerifyStateNew = 2  and omi.cInvCcode like '19%'
-					and om.cCode LIKE CONCAT('%',#{code},'%') and (oti.cInvCcode like '05%' or oti.cInvCcode like '06%'
-					or oti.cInvCcode like '07%' or oti.cInvCCode = '0399' or oti.cInvCCode = '0499')
-
-		GROUP BY oti.cInvName
+		select  oti.cInvName as goodsName,max(om.cCode) as planCode,
+			    sum(ot.iSendQTY) as number,max(pb.iCost) as unitCost,
+			    sum(ot.iSendQTY)*max(pb.iCost) as cost
+				from UFDATA_103_2021.dbo.om_momain om
+				join UFDATA_103_2021.dbo.OM_MODetails od on om.moid=od.moid
+				join UFDATA_103_2021.dbo.OM_MOMaterials ot on ot.MoDetailsID=od.MODetailsID
+				join UFDATA_103_2021.dbo.Inventory oti on oti.cInvCode=ot.cInvCode
+				join UFDATA_103_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
+				left join (
+					 SELECT p.cInvCode,p.iorderdid,max(bi.iCost) as iCost
+					 from UFDATA_103_2021.dbo.PO_Podetails p
+					 join UFDATA_103_2021.dbo.PurBillVouchs bi  on bi.iPOsID=p.ID
+					 GROUP BY p.cInvCode,p.iorderdid
+				) pb on pb.cInvCode=ot.cInvCode and pb.iorderdid=od.isosid
+				WHERE om.iVerifyStateNew = 2  and omi.cInvCcode like '19%'
+				and om.cCode LIKE CONCAT('%',#{code},'%') and (oti.cInvCcode like '05%' or oti.cInvCcode like '06%'
+				or oti.cInvCcode like '07%' or oti.cInvCCode = '0399' or oti.cInvCCode = '0499')
+				GROUP BY oti.cInvName
     </select>
 </mapper>

+ 244 - 153
jeecg-boot-module-system/src/main/java/org/jeecg/modules/cost/service/impl/SyCostAllocationServiceImpl.java

@@ -213,9 +213,11 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
 
         //查询单证面损数据   面料(不)含税成本
         SyFabricLossReport syLossReport1 = null;
+//        System.out.println("面损plan_code\t"+plannum+"\t面损长度\t"+plannum.length());
         QueryWrapper<SyFabricLossReport> queryLossWrapper = new QueryWrapper<>();
         queryLossWrapper.eq("plan_code", plannum);
         List<SyFabricLossReport> syLossReportList = syFabricLossReportService.list(queryLossWrapper);
+//        System.out.println("面损syLossReportList\t"+syLossReportList.size());
         if (syLossReportList.size()>0){
             syLossReport1 = syLossReportList.get(0);
         }
@@ -226,9 +228,11 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
             fabricLoss1 = JSON.parseObject(JSON.toJSONString(syLossReport1.getContent()), FabricLoss.class);
 
             BigDecimal fabariccostIncludestax=new BigDecimal("0");
-            for (FabricCostInvoice fabricCostInvoice : fabricLoss1.getFabricCostInvoiceList()){
-                if (fabricCostInvoice.getIMoney()!=null){
-                    fabariccostIncludestax=fabariccostIncludestax.add(new BigDecimal(fabricCostInvoice.getIMoney())).setScale(2, RoundingMode.HALF_UP) ;
+            if (fabricLoss1.getFabricCostInvoiceList()!=null){
+                for (FabricCostInvoice fabricCostInvoice : fabricLoss1.getFabricCostInvoiceList()){
+                    if (fabricCostInvoice.getIMoney()!=null){
+                        fabariccostIncludestax=fabariccostIncludestax.add(new BigDecimal(fabricCostInvoice.getIMoney())).setScale(2, RoundingMode.HALF_UP) ;
+                    }
                 }
             }
 //            syCostAllocation.setFabriccostIncludestax(new BigDecimal(fabricLoss1.getActualMoney()));// 实际总金额
@@ -259,9 +263,68 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
 
         int planQuantity=syCostAllocation.getPlanQuantity().intValue();
 
+        long startTime2 = System.currentTimeMillis();
         /*查询U8数据 面料*/
         List<SyCostAllocationFabric> list3 = syCostAllocationFabricMapper.queryByCostFabric3(plannum,planQuantity);
 
+        //获取所有转入数据
+//        List<SyTransfer> transferlists  = syCostAllocationFabricMapper.queryTransferByFabric3(plannum);
+
+        //获取所有转入数据
+        List<SyTransfer> transferlists  = syCostAllocationFabricMapper.queryTransferByFabric4(plannum);
+
+        Map<String,List<SyTransfer>> syTransferMaps=new HashMap<>();
+
+        long startTime1 = System.currentTimeMillis();
+        //获取所有余下数量
+        List<SyRemaining> syRemainings=syCostAllocationFabricMapper.queryRemainingByFabric4(plannum);
+
+        //面料余下数量
+        Map<String,List<SyRemaining>> syRemainingMaps=new HashMap<>();
+
+        //多发少发链接结合赋值
+        List<SyCostAllocationFabric> pilosityFeweLists = syCostAllocationFabricMapper.querypilosityFewer2(plannum);
+
+        System.out.println("多发少发链接结合赋值\t"+pilosityFeweLists);
+        Map<String,List<SyCostAllocationFabric>> syFabricMaps=new HashMap<>();
+
+        for (SyTransfer transfer : transferlists){
+            if (syTransferMaps.containsKey(transfer.getGoodsName())){
+                List<SyTransfer> transferlist=syTransferMaps.get(transfer.getGoodsName());
+                transferlist.add(transfer);
+            }else{
+                List<SyTransfer> transferlist=new ArrayList<>();
+                transferlist.add(transfer);
+                syTransferMaps.put(transfer.getGoodsName(),transferlist);
+            }
+        }
+
+        for (SyRemaining syRemaining :syRemainings){
+            if (syRemainingMaps.containsKey(syRemaining.getGoodsName())){
+                List<SyRemaining> remaininglist=syRemainingMaps.get(syRemaining.getGoodsName());
+                remaininglist.add(syRemaining);
+            }else{
+                List<SyRemaining> remaininglist=new ArrayList<>();
+                remaininglist.add(syRemaining);
+                syRemainingMaps.put(syRemaining.getGoodsName(),remaininglist);
+            }
+        }
+
+        for (SyCostAllocationFabric syCostAllocationFabric : pilosityFeweLists){
+            if (syFabricMaps.containsKey(syCostAllocationFabric.getGoodsName())){
+                List<SyCostAllocationFabric> syCostAllocationFabrics=syFabricMaps.get(syCostAllocationFabric.getGoodsName());
+                syCostAllocationFabrics.add(syCostAllocationFabric);
+            }else{
+                List<SyCostAllocationFabric> syCostAllocationFabrics=new ArrayList<>();
+                syCostAllocationFabrics.add(syCostAllocationFabric);
+                syFabricMaps.put(syCostAllocationFabric.getGoodsName(),syCostAllocationFabrics);
+            }
+        }
+        //查询单证面损数据
+        SyFabricLossReport syFabricLossReport = null;
+        QueryWrapper<SyFabricLossReport> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("plan_code", syCostAllocation.getPlanNum());
+        List<SyFabricLossReport> syFabricLossReportList = syFabricLossReportService.list(queryWrapper);
         for (int i=0;i<list3.size();i++) {
 
             SyCostAllocationFabric Fabric = list3.get(i);
@@ -283,19 +346,17 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
             }
             //转入数量、余下数量
             if(0!=Fabric.getFabrictransferQuantity().compareTo(BigDecimal.ZERO) || 0!=Fabric.getFabricremainingQuantity().compareTo(BigDecimal.ZERO)){
-                List<SyTransfer> transferlist  = syCostAllocationFabricMapper.queryTransferByFabric(plannum,Fabric.getGoodsName());
+//                List<SyTransfer> transferlist  = syCostAllocationFabricMapper.queryTransferByFabric(plannum,Fabric.getGoodsName());
+                List<SyTransfer> transferlist  = syTransferMaps.get(Fabric.getGoodsName());
+                if (transferlist==null || transferlist.size()==0){
+                    transferlist=new ArrayList<>();
+                }
                 BigDecimal cost = new BigDecimal(BigInteger.ZERO);
                 BigDecimal quantity = new BigDecimal(BigInteger.ZERO);
                 for (SyTransfer syTransfer:transferlist) {
-                    //查询单证面损数据
-                    SyFabricLossReport syFabricLossReport = null;
-                    QueryWrapper<SyFabricLossReport> queryWrapper = new QueryWrapper<>();
-                    queryWrapper.eq("plan_code", syTransfer.getPlanCode());
-                    List<SyFabricLossReport> syFabricLossReportList = syFabricLossReportService.list(queryWrapper);
                     if (syFabricLossReportList.size()>0){
                         syFabricLossReport = syFabricLossReportList.get(0);
                     }
-
                     FabricLoss fabricLoss = null;
                     if (syFabricLossReport != null){
                         fabricLoss = JSON.parseObject(JSON.toJSONString(syFabricLossReport.getContent()), FabricLoss.class);
@@ -315,7 +376,7 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
                     quantity=quantity.add(new BigDecimal(syTransfer.getNumber()));
                 }
                 Fabric.setSyTransfers(transferlist);
-                Fabric.setFabrictransferQuantity(quantity);
+//                Fabric.setFabrictransferQuantity(quantity);//转入数量
                 Fabric.setTransferCost(cost);
             }
 
@@ -327,22 +388,19 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
             }
             Fabric.setRemainingQuantitycost(new BigDecimal("0"));
             if(Fabric.getFabricremainingQuantity().compareTo(BigDecimal.ZERO) != 0 ){
-                long startTime = System.currentTimeMillis();
-                List<SyRemaining> syRemaining  = syCostAllocationFabricMapper.queryRemainingByFabric(plannum,Fabric.getGoodsName());
-                long endTime2 = System.currentTimeMillis();
+//                List<SyRemaining> syRemaining  = syCostAllocationFabricMapper.queryRemainingByFabric(plannum,Fabric.getGoodsName());
+//                if (syRemaining.size()==0){
+//                    syRemaining=syCostAllocationFabricMapper.queryRemainingByFabric3(plannum,Fabric.getGoodsName());
+//                }
+                List<SyRemaining> syRemaining=syRemainingMaps.get(Fabric.getGoodsName());
                 BigDecimal cost = new BigDecimal(BigInteger.ZERO);
+                if (syRemaining==null || syRemaining.size()==0){
+                    syRemaining=new ArrayList<>();
+                }
                 for (SyRemaining syRemain:syRemaining) {
-//                    syRemain.setNumber(Fabric.getFabricremainingQuantity().toString());
-                    //查询单证面损数据
-                    SyFabricLossReport syFabricLossReport = null;
-                    QueryWrapper<SyFabricLossReport> queryWrapper = new QueryWrapper<>();
-//                    queryWrapper.eq("plan_code", syRemain.getPlanCode());
-                    queryWrapper.eq("plan_code", plannum);
-                    List<SyFabricLossReport> syFabricLossReportList = syFabricLossReportService.list(queryWrapper);
                     if (syFabricLossReportList.size()>0){
                         syFabricLossReport = syFabricLossReportList.get(0);
                     }
-
                     FabricLoss fabricLoss = null;
                     if (syFabricLossReport != null){
                         fabricLoss = JSON.parseObject(JSON.toJSONString(syFabricLossReport.getContent()), FabricLoss.class);
@@ -365,24 +423,28 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
 //                    syCostAllocation.setFabriccostIncludestax(syCostAllocation.getFabriccostIncludestax().subtract(cost).setScale(2, RoundingMode.HALF_UP));
 //                    syCostAllocation.setFabriccostIncludestaxUsd(syCostAllocation.getFabriccostIncludestaxUsd().subtract(costUsd).setScale(2, RoundingMode.HALF_UP));
                 }
-
                 Fabric.setSyRemaining(syRemaining);
             }
 
-            //多发少发链接结合赋值
-            List<SyCostAllocationFabric> pilosityFeweList = syCostAllocationFabricMapper.querypilosityFewer(plannum,Fabric.getGoodsName());
+            //多发少发链接结合赋值 syFabricMaps
+//            List<SyCostAllocationFabric> pilosityFeweList = syCostAllocationFabricMapper.querypilosityFewer(plannum,Fabric.getGoodsName());
+            List<SyCostAllocationFabric> pilosityFeweList = syFabricMaps.get(Fabric.getGoodsName());
+            System.out.println("多发少发链接\t"+pilosityFeweList);
             Fabric.setPilosityFewerList(pilosityFeweList);
 
-            //多发少发 = 使用数量-计划数量
+            //多发少发 = 使用数量-计划数量------>购入数量-计划数量
             if(oConvertUtils.isEmpty(Fabric.getUsageQuantity())){
                 Fabric.setUsageQuantity(BigDecimal.ZERO);
             }
             Fabric.setPilosityFewer(Fabric.getUsageQuantity().subtract(Fabric.getPlanQuantity()));
 
-
             //单耗件= 计划数量/表头计划数量
             Fabric.setUnitConsumption(Fabric.getPlanQuantity().divide(syCostAllocation.getPlanQuantity(),4,BigDecimal.ROUND_HALF_UP));
 
+//            转入成本
+//            Fabric.setTransferCost();
+//            余下数量的成本
+//            Fabric.setRemainingQuantitycost();
         }
 
         //如果没有面损表信息,查询所有采购发票
@@ -419,13 +481,13 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
                             BigDecimal num2 = money2.multiply(li.getUsageQuantity());
                             includestaxTotal = includestaxTotal.add(num2);
                             //(发票金额/发票数量)*使用数量
-                            System.out.println("面料含税成本\t"+usageQuantityTotal+"\t面料不含税成本\t"+notincludestaxTotal+"\t发票数量\t"+str.getInvoiceQuantity()+"\t使用数量\t"+li.getUsageQuantity());
+//                            System.out.println("面料含税成本\t"+usageQuantityTotal+"\t面料不含税成本\t"+notincludestaxTotal+"\t发票数量\t"+str.getInvoiceQuantity()+"\t使用数量\t"+li.getUsageQuantity());
                         }
                     }
                 }
 
                 syCostAllocation.setFabriccostIncludestax(usageQuantityTotal.setScale(2,BigDecimal.ROUND_HALF_UP));
-                System.out.println("实际总金额2\t"+usageQuantityTotal);
+//                System.out.println("实际总金额2\t"+usageQuantityTotal);
                 syCostAllocation.setFabriccostNotincludestax(notincludestaxTotal);
                 syCostAllocation.setFabriccostIncludestaxUsd(includestaxTotal);
             }else{
@@ -436,149 +498,178 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
 
         }
 
-        //查询U8数据 辅料数据关联临时表 syTransfers
+        long startTime3 = System.currentTimeMillis();
+        //查询U8数据 辅料数据关联临时表 syTransfers ingredientsTransferQuantity
         List<SyCostAllocationIngredient> list4 = syCostAllocationIngredientMapper.queryByCostIngredient4(plannum,syCostAllocation.getExchangeRate());
-        HashMap<String,List<SyCostAllocationIngredient>> stringListHashMap=new HashMap();//物料名称+物料编码
-        HashMap<String,List<SyCostAllocationIngredient>> stringListHashMap2=new HashMap();//物料名称+物料编码+供应商
-        List<SyCostAllocationIngredient> ingredients4=new ArrayList<>();//重新赋值
-        HashMap<String,BigDecimal> stringBigDecimalHashMap=new HashMap();//获取转入数量 syf107
         for (SyCostAllocationIngredient ingredient : list4){
-            if (stringListHashMap.containsKey(ingredient.getGoodsName()+ingredient.getGoodsCode())){
-                List<SyCostAllocationIngredient> ingredients=stringListHashMap.get(ingredient.getGoodsName()+ingredient.getGoodsCode());
-                ingredients.add(ingredient);
-                BigDecimal transferQuantity=new BigDecimal("0");//转入数量
-                for (SyCostAllocationIngredient ingredient1 : ingredients){
-                    transferQuantity=transferQuantity.add(ingredient1.getIngredientsTransferQuantity());//转入数量
-                }
-                BigDecimal usageQuantity=new BigDecimal("0");//使用数量
-                BigDecimal purchaseQuantity=new BigDecimal("0");//购入数量
-                for (SyCostAllocationIngredient ingredient1 : ingredients){
-                    if (usageQuantity.compareTo(ingredient1.getUsageQuantity())!=0){
-                        usageQuantity=usageQuantity.add(ingredient1.getUsageQuantity());//转入数量
-                    }
-                    purchaseQuantity=purchaseQuantity.add(ingredient1.getPurchaseQuantity());
-                }
-                stringBigDecimalHashMap.put(ingredient.getGoodsName()+ingredient.getGoodsCode()+"ingredientsTransferQuantity",transferQuantity);
-                stringBigDecimalHashMap.put(ingredient.getGoodsName()+ingredient.getGoodsCode()+"usageQuantity",usageQuantity);
-                stringBigDecimalHashMap.put(ingredient.getGoodsName()+ingredient.getGoodsCode()+"purchaseQuantity",purchaseQuantity);
-                stringListHashMap.put(ingredient.getGoodsName()+ingredient.getGoodsCode(),ingredients);
-            }else{
-                List<SyCostAllocationIngredient> ingredients=new ArrayList<>();
-                ingredients.add(ingredient);
-                stringListHashMap.put(ingredient.getGoodsName()+ingredient.getGoodsCode(),ingredients);
+            if (ingredient.getUsageQuantity()!=null&&ingredient.getPurchaseQuantity()!=null && ingredient.getUsageQuantity().compareTo(ingredient.getPurchaseQuantity())>0){
+                BigDecimal transferQuantity=ingredient.getUsageQuantity().subtract(ingredient.getPurchaseQuantity());
+//                ingredient.setIngredientsTransferQuantity(transferQuantity);
             }
-
-            if (stringListHashMap2.containsKey(ingredient.getGoodsName()+ingredient.getGoodsCode()+ingredient.getSupper())){
-                List<SyCostAllocationIngredient> ingredients=stringListHashMap2.get(ingredient.getGoodsName()+ingredient.getGoodsCode()+ingredient.getSupper());
-                ingredients.add(ingredient);
-                stringListHashMap2.put(ingredient.getGoodsName()+ingredient.getGoodsCode()+ingredient.getSupper(),ingredients);
-            }else{
-                List<SyCostAllocationIngredient> ingredients=new ArrayList<>();
-                ingredients.add(ingredient);
-                stringListHashMap2.put(ingredient.getGoodsName()+ingredient.getGoodsCode()+ingredient.getSupper(),ingredients);
-            }
-        }
-        for (List<SyCostAllocationIngredient> syCostAllocationIngredients : stringListHashMap.values()){
-            if (syCostAllocationIngredients.size()>1){//解决转入数量和使用数量问题
-                for (SyCostAllocationIngredient ingredient : syCostAllocationIngredients){
-                    BigDecimal transferQuantity=stringBigDecimalHashMap.get(ingredient.getGoodsName()+ingredient.getGoodsCode()+"ingredientsTransferQuantity");
-                    BigDecimal usageQuantity=stringBigDecimalHashMap.get(ingredient.getGoodsName()+ingredient.getGoodsCode()+"usageQuantity");
-                    BigDecimal purchaseQuantity=stringBigDecimalHashMap.get(ingredient.getGoodsName()+ingredient.getGoodsCode()+"purchaseQuantity");
-                    if (ingredient.getUsageQuantity().equals(transferQuantity)){
-                        ingredient.setIngredientsTransferQuantity(ingredient.getUsageQuantity().subtract(transferQuantity));
-//                        ingredient.setUsageQuantity(ingredient.getUsageQuantity().subtract(usageQuantity));
-                    }
-                    if (usageQuantity.compareTo(purchaseQuantity)==0){
-                        ingredient.setUsageQuantity(ingredient.getPurchaseQuantity());
-//                        ingredient.setUsageQuantity(ingredient.getUsageQuantity().subtract(usageQuantity));
-                    }
-                }
+            if (ingredient.getUsageQuantity()!=null&&ingredient.getPurchaseQuantity()!=null && ingredient.getUsageQuantity().compareTo(ingredient.getPurchaseQuantity())<0){
+                BigDecimal remainingQuantity=ingredient.getPurchaseQuantity().subtract(ingredient.getUsageQuantity());
+//                ingredient.setIngredientsRemainingQuantity(transferQuantity);
             }
         }
-        for (List<SyCostAllocationIngredient> syCostAllocationIngredients : stringListHashMap2.values()){
-            SyCostAllocationIngredient allocationIngredient1=new SyCostAllocationIngredient();
-            if (syCostAllocationIngredients.size()>1){
-                int num=0;
-                for (SyCostAllocationIngredient ingredient : syCostAllocationIngredients){
-                   if (num==0){
-                       allocationIngredient1=ingredient;
-                   }else{
-                       //转入数量
-                       allocationIngredient1.setIngredientsTransferQuantity(allocationIngredient1.getIngredientsTransferQuantity().add(ingredient.getIngredientsTransferQuantity()));
-                       //转入成本
-//                       allocationIngredient1.setTransferCost(allocationIngredient1.getTransferCost().add(ingredient.getTransferCost()));
-                       //使用数量
-//                       allocationIngredient1.setUsageQuantity(allocationIngredient1.getUsageQuantity().add(ingredient.getUsageQuantity()));
-                       //购入数量
-                       BigDecimal PurchaseQuantity=(allocationIngredient1.getPurchaseQuantity().add(ingredient.getPurchaseQuantity()));
-                       allocationIngredient1.setPurchaseQuantity(PurchaseQuantity);
-                       //余下数量
-                       BigDecimal ingredientsRemainingQuantity=allocationIngredient1.getPurchaseQuantity().subtract(ingredient.getUsageQuantity());
-                       if (ingredientsRemainingQuantity.doubleValue()>BigDecimal.ZERO.doubleValue()){
-                           allocationIngredient1.setIngredientsRemainingQuantity(ingredientsRemainingQuantity);
-                       }else{
-                           allocationIngredient1.setIngredientsRemainingQuantity(BigDecimal.ZERO);
-//                           allocationIngredient1.setTransferCost(BigDecimal.ZERO);
-                       }
-//                       allocationIngredient1.setIngredientsRemainingQuantity(allocationIngredient1.getPurchaseQuantity().subtract(ingredient.getUsageQuantity()));
-                       //转入数量
-                       BigDecimal ingredientsTransferQuantity=allocationIngredient1.getUsageQuantity().subtract(allocationIngredient1.getPurchaseQuantity());
-                       if (ingredientsTransferQuantity.doubleValue()>BigDecimal.ZERO.doubleValue()){
-                           allocationIngredient1.setIngredientsTransferQuantity(ingredientsTransferQuantity);
-                       }else{
-                           allocationIngredient1.setIngredientsTransferQuantity(BigDecimal.ZERO);
-                       }
-//                       allocationIngredient1.setIngredientsTransferQuantity(allocationIngredient1.getUsageQuantity().subtract(allocationIngredient1.getPurchaseQuantity()));
-                       //损耗
-                       allocationIngredient1.setLoss((allocationIngredient1.getPurchaseQuantity().subtract(allocationIngredient1.getUsageQuantity())).divide(allocationIngredient1.getPurchaseQuantity(),4));
-                       //人民币金额
-                       allocationIngredient1.setRmbAmount(allocationIngredient1.getRmbAmount().add(ingredient.getRmbAmount()));
-                       //美元金额
-                       allocationIngredient1.setUsdAmount(allocationIngredient1.getUsdAmount().add(ingredient.getUsdAmount()));
-                       //不含税金额
-                       allocationIngredient1.setPriceExcludingtax(allocationIngredient1.getPriceExcludingtax().add(ingredient.getPriceExcludingtax()));
-                       //用量
-                   }
-                   num++;
-                }
-            }else{
-                allocationIngredient1=syCostAllocationIngredients.get(0);
-            }
-            ingredients4.add(allocationIngredient1);
-        }
-        list4=ingredients4;
-
-        List<SyRemaining> remaininglists  = syCostAllocationIngredientMapper.queryRemainingByIngredient(plannum);
-        Map<String,List<SyRemaining>> remainingMaps=new HashMap<>();
-        for (SyRemaining syRemaining : remaininglists){
-            if (remainingMaps.containsKey(syRemaining.getGoodsName())){
-                List<SyRemaining> remaininglist=remainingMaps.get(syRemaining.getGoodsName());
-                remaininglist.add(syRemaining);
+//        HashMap<String,List<SyCostAllocationIngredient>> stringListHashMap=new HashMap();//物料名称+物料编码
+//        HashMap<String,List<SyCostAllocationIngredient>> stringListHashMap2=new HashMap();//物料名称+物料编码+供应商
+//        List<SyCostAllocationIngredient> ingredients4=new ArrayList<>();//重新赋值
+//        HashMap<String,BigDecimal> stringBigDecimalHashMap=new HashMap();//获取转入数量 syf107
+//        for (SyCostAllocationIngredient ingredient : list4){
+//            if (stringListHashMap.containsKey(ingredient.getGoodsName()+ingredient.getGoodsCode())){
+//                List<SyCostAllocationIngredient> ingredients=stringListHashMap.get(ingredient.getGoodsName()+ingredient.getGoodsCode());
+//                ingredients.add(ingredient);
+//                BigDecimal transferQuantity=new BigDecimal("0");//转入数量
+//                for (SyCostAllocationIngredient ingredient1 : ingredients){
+//                    transferQuantity=transferQuantity.add(ingredient1.getIngredientsTransferQuantity());//转入数量
+//                }
+//                BigDecimal usageQuantity=new BigDecimal("0");//使用数量
+//                BigDecimal purchaseQuantity=new BigDecimal("0");//购入数量
+//                for (SyCostAllocationIngredient ingredient1 : ingredients){
+//                    if (usageQuantity.compareTo(ingredient1.getUsageQuantity())!=0){
+//                        usageQuantity=usageQuantity.add(ingredient1.getUsageQuantity());//转入数量
+//                    }
+//                    purchaseQuantity=purchaseQuantity.add(ingredient1.getPurchaseQuantity());
+//                }
+//                stringBigDecimalHashMap.put(ingredient.getGoodsName()+ingredient.getGoodsCode()+"ingredientsTransferQuantity",transferQuantity);
+//                stringBigDecimalHashMap.put(ingredient.getGoodsName()+ingredient.getGoodsCode()+"usageQuantity",usageQuantity);
+//                stringBigDecimalHashMap.put(ingredient.getGoodsName()+ingredient.getGoodsCode()+"purchaseQuantity",purchaseQuantity);
+//                stringListHashMap.put(ingredient.getGoodsName()+ingredient.getGoodsCode(),ingredients);
+//            }else{
+//                List<SyCostAllocationIngredient> ingredients=new ArrayList<>();
+//                ingredients.add(ingredient);
+//                stringListHashMap.put(ingredient.getGoodsName()+ingredient.getGoodsCode(),ingredients);
+//            }
+//
+//            if (stringListHashMap2.containsKey(ingredient.getGoodsName()+ingredient.getGoodsCode()+ingredient.getSupper())){
+//                List<SyCostAllocationIngredient> ingredients=stringListHashMap2.get(ingredient.getGoodsName()+ingredient.getGoodsCode()+ingredient.getSupper());
+//                ingredients.add(ingredient);
+//                stringListHashMap2.put(ingredient.getGoodsName()+ingredient.getGoodsCode()+ingredient.getSupper(),ingredients);
+//            }else{
+//                List<SyCostAllocationIngredient> ingredients=new ArrayList<>();
+//                ingredients.add(ingredient);
+//                stringListHashMap2.put(ingredient.getGoodsName()+ingredient.getGoodsCode()+ingredient.getSupper(),ingredients);
+//            }
+//        }
+//        for (List<SyCostAllocationIngredient> syCostAllocationIngredients : stringListHashMap.values()){
+//            if (syCostAllocationIngredients.size()>1){//解决转入数量和使用数量问题
+//                for (SyCostAllocationIngredient ingredient : syCostAllocationIngredients){
+//                    BigDecimal transferQuantity=stringBigDecimalHashMap.get(ingredient.getGoodsName()+ingredient.getGoodsCode()+"ingredientsTransferQuantity");
+//                    BigDecimal usageQuantity=stringBigDecimalHashMap.get(ingredient.getGoodsName()+ingredient.getGoodsCode()+"usageQuantity");
+//                    BigDecimal purchaseQuantity=stringBigDecimalHashMap.get(ingredient.getGoodsName()+ingredient.getGoodsCode()+"purchaseQuantity");
+//                    if (ingredient.getUsageQuantity().equals(transferQuantity)){
+//                        ingredient.setIngredientsTransferQuantity(ingredient.getUsageQuantity().subtract(transferQuantity));
+////                        ingredient.setUsageQuantity(ingredient.getUsageQuantity().subtract(usageQuantity));
+//                    }
+//                    if (usageQuantity.compareTo(purchaseQuantity)==0){
+//                        ingredient.setUsageQuantity(ingredient.getPurchaseQuantity());
+////                        ingredient.setUsageQuantity(ingredient.getUsageQuantity().subtract(usageQuantity));
+//                    }
+//                }
+//            }
+//        }
+//        for (List<SyCostAllocationIngredient> syCostAllocationIngredients : stringListHashMap2.values()){
+//            SyCostAllocationIngredient allocationIngredient1=new SyCostAllocationIngredient();
+//            if (syCostAllocationIngredients.size()>1){
+//                int num=0;
+//                for (SyCostAllocationIngredient ingredient : syCostAllocationIngredients){
+//                   if (num==0){
+//                       allocationIngredient1=ingredient;
+//                   }else{
+//                       //转入数量
+//                       allocationIngredient1.setIngredientsTransferQuantity(allocationIngredient1.getIngredientsTransferQuantity().add(ingredient.getIngredientsTransferQuantity()));
+//                       //转入成本
+////                       allocationIngredient1.setTransferCost(allocationIngredient1.getTransferCost().add(ingredient.getTransferCost()));
+//                       //使用数量
+////                       allocationIngredient1.setUsageQuantity(allocationIngredient1.getUsageQuantity().add(ingredient.getUsageQuantity()));
+//                       //购入数量
+//                       BigDecimal PurchaseQuantity=(allocationIngredient1.getPurchaseQuantity().add(ingredient.getPurchaseQuantity()));
+//                       allocationIngredient1.setPurchaseQuantity(PurchaseQuantity);
+//                       //余下数量
+//                       BigDecimal ingredientsRemainingQuantity=allocationIngredient1.getPurchaseQuantity().subtract(ingredient.getUsageQuantity());
+//                       if (ingredientsRemainingQuantity.doubleValue()>BigDecimal.ZERO.doubleValue()){
+//                           allocationIngredient1.setIngredientsRemainingQuantity(ingredientsRemainingQuantity);
+//                       }else{
+//                           allocationIngredient1.setIngredientsRemainingQuantity(BigDecimal.ZERO);
+////                           allocationIngredient1.setTransferCost(BigDecimal.ZERO);
+//                       }
+////                       allocationIngredient1.setIngredientsRemainingQuantity(allocationIngredient1.getPurchaseQuantity().subtract(ingredient.getUsageQuantity()));
+//                       //转入数量
+//                       BigDecimal ingredientsTransferQuantity=allocationIngredient1.getUsageQuantity().subtract(allocationIngredient1.getPurchaseQuantity());
+//                       if (ingredientsTransferQuantity.doubleValue()>BigDecimal.ZERO.doubleValue()){
+//                           allocationIngredient1.setIngredientsTransferQuantity(ingredientsTransferQuantity);
+//                       }else{
+//                           allocationIngredient1.setIngredientsTransferQuantity(BigDecimal.ZERO);
+//                       }
+////                       allocationIngredient1.setIngredientsTransferQuantity(allocationIngredient1.getUsageQuantity().subtract(allocationIngredient1.getPurchaseQuantity()));
+//                       //损耗
+//                       allocationIngredient1.setLoss((allocationIngredient1.getPurchaseQuantity().subtract(allocationIngredient1.getUsageQuantity())).divide(allocationIngredient1.getPurchaseQuantity(),4));
+//                       //人民币金额
+//                       allocationIngredient1.setRmbAmount(allocationIngredient1.getRmbAmount().add(ingredient.getRmbAmount()));
+//                       //美元金额
+//                       allocationIngredient1.setUsdAmount(allocationIngredient1.getUsdAmount().add(ingredient.getUsdAmount()));
+//                       //不含税金额
+//                       allocationIngredient1.setPriceExcludingtax(allocationIngredient1.getPriceExcludingtax().add(ingredient.getPriceExcludingtax()));
+//                       //用量
+//                   }
+//                   num++;
+//                }
+//            }else{
+//                allocationIngredient1=syCostAllocationIngredients.get(0);
+//            }
+//            ingredients4.add(allocationIngredient1);
+//        }
+//        list4=ingredients4;//辅料合计
+
+//        List<SyRemaining> remaininglists  = syCostAllocationIngredientMapper.queryRemainingByIngredient(plannum);
+//        Map<String,List<SyRemaining>> remainingMaps=new HashMap<>();
+//        for (SyRemaining syRemaining : remaininglists){
+//            if (remainingMaps.containsKey(syRemaining.getGoodsName())){
+//                List<SyRemaining> remaininglist=remainingMaps.get(syRemaining.getGoodsName());
+//                remaininglist.add(syRemaining);
+////                remainingMaps.put(syRemaining.getGoodsName(),remaininglist);
+//            }else{
+//                List<SyRemaining> remaininglist=new ArrayList<>();
+//                remaininglist.add(syRemaining);
 //                remainingMaps.put(syRemaining.getGoodsName(),remaininglist);
-            }else{
-                List<SyRemaining> remaininglist=new ArrayList<>();
-                remaininglist.add(syRemaining);
-                remainingMaps.put(syRemaining.getGoodsName(),remaininglist);
-            }
-        }
+//            }
+//        }
 
         for (int i=0;i<list4.size();i++) {
             SyCostAllocationIngredient Ingredient = list4.get(i);
             //若转入数量不为0则给转入数据对象赋值  List<SyTransfer>
-//            System.out.println("辅料转入数量\t"+Ingredient.getIngredientsTransferQuantity());
+//            System.out.println("货物名称\t"+Ingredient.getGoodsName()+"\t辅料转入数量\t"+Ingredient.getIngredientsTransferQuantity());
 //            System.out.println("辅料判断\t"+(0!=Ingredient.getIngredientsTransferQuantity().compareTo(BigDecimal.ZERO)));
             if(0!=Ingredient.getIngredientsTransferQuantity().compareTo(BigDecimal.ZERO)){
+                long startTime5 = System.currentTimeMillis();
                 List<SyTransfer> transferlist  = syCostAllocationFabricMapper.queryTransferByFabric2(plannum,Ingredient.getGoodsName());
 //                syCostAllocationIngredientMapper.queryTransferByIngredient(plannum,Ingredient.getGoodsName());
 //                Ingredient.setSyTransfers(transferlist);
                 Ingredient.setSyTransfers(transferlist);
             }
+//            System.out.println("辅料人名币金额\t"+Ingredient.getRmbAmount()+"\t购入数量\t"+Ingredient.getPurchaseQuantity());
+            BigDecimal unitCost=new BigDecimal("0");
+            if (Ingredient.getPurchaseQuantity().compareTo(new BigDecimal("0"))>0){
+                unitCost=Ingredient.getRmbAmount().divide(Ingredient.getPurchaseQuantity(),4,BigDecimal.ROUND_HALF_UP);
+            }
             //若剩余数量不为0则给转入数据对象赋值
             if(Ingredient.getIngredientsRemainingQuantity()!=null){
                 if(Ingredient.getIngredientsRemainingQuantity().compareTo(BigDecimal.ZERO)>0){
-//                    List<SyRemaining> remaininglist  = syCostAllocationIngredientMapper.queryRemainingByIngredient(plannum,Ingredient.getGoodsName());
-//                    Ingredient.setSyRemaining(remaininglist);
-                    Ingredient.setSyRemaining(remainingMaps.get(Ingredient.getGoodsName()));
+//                  List<SyRemaining> remaininglist  = syCostAllocationIngredientMapper.queryRemainingByIngredient(plannum,Ingredient.getGoodsName());
+//                  Ingredient.setSyRemaining(remaininglist);
+//                  Ingredient.setSyRemaining(remainingMaps.get(Ingredient.getGoodsName()));
+                    List<SyRemaining> syRemainings1=syRemainingMaps.get(Ingredient.getGoodsName());
+                    if (syRemainings1==null || syRemainings1.size()==0){
+                        syRemainings1=new ArrayList<>();
+                    }
+                    for (SyRemaining remaining : syRemainings1){
+//                        System.out.println("辅料数量\t"+remaining.getNumber());
+                        BigDecimal number=new BigDecimal(remaining.getNumber());
+                        BigDecimal cost=unitCost.multiply(number).setScale(2,BigDecimal.ROUND_HALF_UP);
+                        remaining.setUnitCost(unitCost);//总成本
+                        remaining.setCost(cost);//总成本
+                    }
+                    Ingredient.setSyRemaining(syRemainings1);
                 }
             }
 
@@ -596,7 +687,7 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
                     syCostAllocation.setExcipiencostIncludestaxUsd(BigDecimal.ZERO);
                 }
                 //人民币金额 RmbAmount+ 辅料含税成本 ExcipiencostIncludestax
-//                System.out.println("getRmbAmount\t"+Ingredient.getRmbAmount()+"getExcipiencostIncludestax\t"+syCostAllocation.getExcipiencostIncludestax());
+                //System.out.println("getRmbAmount\t"+Ingredient.getRmbAmount()+"getExcipiencostIncludestax\t"+syCostAllocation.getExcipiencostIncludestax());
                 syCostAllocation.setExcipiencostIncludestax(Ingredient.getRmbAmount().add(syCostAllocation.getExcipiencostIncludestax()));
                 syCostAllocation.setExcipiencostIncludestaxUsd(Ingredient.getUsdAmount().add(syCostAllocation.getExcipiencostIncludestaxUsd()));
 

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/costLossReview/controller/SyCostLossReviewController.java

@@ -90,6 +90,7 @@ public class SyCostLossReviewController extends JeecgController<SyOrderData, ISy
                                   HttpServletRequest req) {
        Page page = new Page(pageNo, pageSize,false);
        Result<IPage<SyCostLossReview>> result = new Result<IPage<SyCostLossReview>>();
+       long startTime = System.currentTimeMillis();
        IPage<SyCostLossReview> nullList = new Page<>();
        List<String> sumList = new ArrayList<>();
        if(syCostLossReview.getPlanNo()=="" || syCostLossReview.getPlanNo()==null){
@@ -207,7 +208,6 @@ public class SyCostLossReviewController extends JeecgController<SyOrderData, ISy
                pageList.setTotal(syCostLossReviewMapper.querylistCount(syCostLossReview, sumList, new ArrayList<>()));
            }
 
-       long startTime = System.currentTimeMillis();
        //赋值制单人
        List<SyCostLossReview> listPlanNo = syCostLossReviewService.queryMakerByplanNo();
        Map<String, String> nameByCode = listPlanNo.stream()

+ 13 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/letterDeposit/controller/SyLetterDepositController.java

@@ -245,6 +245,19 @@ public class SyLetterDepositController extends JeecgController<SyLetterDeposit,
 				result.setMessage("编辑失败,该单据已提交,不能修改!");
 				return result;
 			}
+
+
+			//判断预托书号是否唯一
+			String depositaryReceiptNo = syLetterDeposit.getDepositaryReceiptNo();
+			QueryWrapper<SyLetterDeposit> queryWrapper2 = new QueryWrapper();
+			queryWrapper2.eq("depositary_receipt_no",depositaryReceiptNo).eq("del_flag",0).ne("id",syLetterDeposit.getId());
+			List<SyLetterDeposit> list2 = syLetterDepositService.list(queryWrapper2);
+			if(list2.size()>0){
+				result.setSuccess(false);
+				result.setMessage("预托书号已存在,请重新维护!");
+				return result;
+			}
+
 			//查询预托书子表
 			QueryWrapper<SyLetterDepositItem> queryWrapper = new QueryWrapper<>();
 			queryWrapper.eq("sy_letter_deposit_id",syLetterDeposit.getId()).eq("del_flag",0);

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/orderData/service/impl/SyOrderDataServiceImpl.java

@@ -136,7 +136,7 @@ public class SyOrderDataServiceImpl extends ServiceImpl<SyOrderDataMapper, SyOrd
                         " LEFT JOIN Person  pe ON s.cPersonCode = pe.cPersonCode" +
                         " left join Vendor v on s.cDefine12=v.cVenName" +
                         " where s.iStatus = 1 AND s.cdefine15 !='2' "+ //AND (s.cdefine15 is null or  s.cdefine15 !='1')
-                        " and s.cSOCode = '"+parameter+"' order by s.dDate desc ";
+                        " and s.cSOCode = '"+parameter+"' order by s.dDate desc";
 
                 List<Map<String, Object>> list = new ArrayList<>();
                 if(account.equals("101")){

+ 62 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/shippingDetails/controller/SyShippingDetailsController.java

@@ -1269,6 +1269,68 @@ public class SyShippingDetailsController extends JeecgController<SyShippingDetai
   }
 
 
+
+	 /**
+	  *预约发货单接口
+	  * @param ids
+	  * @return
+	  */
+	 @AutoLog(value = "预约发货单接口")
+	 @ApiOperation(value="预约发货单接口", notes="预约发货单接口")
+	 @GetMapping(value = "/pushPreDeliverVo")
+	 public Result<JSONObject> pushPreDeliverVo(String[] ids){
+
+		 Result<JSONObject> pushvo = new Result<>();
+		 JSONObject result = new JSONObject();
+		 List<PurchasePreDeliverVo> list = new ArrayList<>();
+
+		 try {
+			 if(oConvertUtils.isEmpty(ids)){
+				 System.out.println("ID为空!");
+			 }
+			 //查询IP及账套信息、时间戳
+			 QueryWrapper<DxpDataPlan> queryWrapper = new QueryWrapper<>();
+			 queryWrapper.eq("code", "senYu_Srm_Yfh");
+			 Page<DxpDataPlan> page = new Page<DxpDataPlan>(1, 100);
+			 IPage<DxpDataPlan> pageList = iDxpDataPlanService.page(page, queryWrapper);
+			 List<DxpDataPlan> resultList = pageList.getRecords();
+
+			 List<String> arrIds=Arrays.asList(ids);
+			 //查询明细
+			 PurchasePreDeliverVo purchasePreDeliverVo =  syShippingDetailsService.getPurchasePreDeliverVo(arrIds);
+			 List<PurchasePreDeliverDetailVo> purchasePreDeliverDetailVos =  syShippingDetailsService.getPurchasePreDeliverDetailVo(arrIds);
+			 purchasePreDeliverVo.setPurchasePreDeliverDetailList(purchasePreDeliverDetailVos);
+			 list.add(purchasePreDeliverVo);
+
+//			 //转JSON
+			 Gson userGson = new GsonBuilder().create();
+			 result.put("payload", userGson.toJson(JSONObject.toJSON(list)));
+			 log.info("JSON数据:" + result);
+			 pushvo.setResult(result);
+			 //拼接url
+			 String url = "http://localhost:8005/erp/purchase/purchasePreDeliver/dzSaveBath";
+			 //调用doPost
+			 InterfaceConnUtils interfaceConnUtils = new InterfaceConnUtils();
+			 //处理返回信息
+			 JSONObject informationJson = interfaceConnUtils.doPostToBasicAuth(result, url);
+			 System.out.println("处理返回信息informationJson\t"+informationJson);
+			 //获取返回信息
+			 String message = informationJson.getString("message");
+//			 //获取是否成功
+//			 String code = jsonArray.getString("code");
+//			 //获取返回消息
+//			 String message = jsonArray.getString("message");
+
+			 log.info("返回信息jsonArray\t"+message);
+
+		 }catch (Exception ex){
+
+			 ex.printStackTrace();
+			 log.error("推送失败:" + ex.getMessage());
+		 }
+		 return  pushvo;
+	 }
+
 	 /**
 	  * 查询报关要素
 	  * @param

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

@@ -0,0 +1,16 @@
+package org.jeecg.modules.documents.shippingDetails.entity.VO;
+
+public class PurchasePreDeliverDetailSizeVo {
+    /**id*/
+    private String id;
+    /**发货单子表ID*/
+    private String deliverDetailId;
+    /**出运明细子表id*/
+    private String syShippingDetailsId;
+    /**尺码*/
+    private String size;
+    /**发货数量*/
+    private java.math.BigDecimal quantity;
+    /**委外订单子表id*/
+    private String purchaseId;
+}

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

@@ -0,0 +1,66 @@
+package org.jeecg.modules.documents.shippingDetails.entity.VO;
+
+import lombok.Data;
+
+import java.util.Date;
+import java.util.List;
+
+@Data
+public class PurchasePreDeliverDetailVo {
+    /**主键*/
+    private String id;
+    /**出运明细子表id*/
+    private String syShippingDetailsId;
+    /**出运明细分组id*/
+    private String syShippingDetailGroupId;
+    /**预发货主表id*/
+    private String purchasePreDeliverId;
+    /**订单编号*/
+    private String orderCode;
+    /**款号*/
+    private String styleNo;
+    /**存货编码*/
+    private String invCode;
+    /**存货名称*/
+    private String invName;
+    /**规格型号*/
+    private String invSpec;
+    /**成品门幅*/
+    private String tailoringGateWidth;
+    /**尺码*/
+    private String size;
+    /**数量*/
+    private java.math.BigDecimal quantity;
+    /**配码规格*/
+    private String codingRules;
+    /**克重/工艺*/
+    private String weight;
+    /**毛门幅CM*/
+    private String guangpeiGateWidth;
+    /**小PO*/
+    private String smallPo;
+    /**分销点*/
+    private String distributionPoint;
+    /**PACK ID*/
+    private String packId;
+    /**成分*/
+    private String composition;
+    /**箱数*/
+    private Integer boxNumber;
+    /**下游供应商*/
+    private String downSupplier;
+    /**上游供应商*/
+    private String upSupplier;
+    /**计划到货日期*/
+    private String arriveDate;
+    /**委外订单子表id*/
+    private String purchaseId;
+    /** 颜色 **/
+    private String color;
+    /**发货数量*/
+    private java.math.BigDecimal deliveryQuantity;
+    //提交状态
+    private String submitStatus;
+    //明细对象
+    private List<PurchasePreDeliverDetailSizeVo> purchasePreDeliverDetailSizeList;
+}

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

@@ -0,0 +1,38 @@
+package org.jeecg.modules.documents.shippingDetails.entity.VO;
+
+import lombok.Data;
+
+import java.util.Date;
+import java.util.List;
+
+@Data
+public class PurchasePreDeliverVo {
+    /**主键*/
+    private String id;
+    /**出运明细主键id*/
+    private String syShippingId;
+    /**组织*/
+    private String sysOrgCode;
+    /**业务类型*/
+    private String businessType;
+    /**发货方*/
+    private String consigner;
+    /**接收方*/
+    private String acceptor;
+    /**单据日期*/
+    private String vbilldate;
+    /**发货日期*/
+    private String sendDate;
+    /**订单号*/
+    private String orderCode;
+    /**来源系统(u8账套)*/
+    private String sourceSystem;
+    /**业务类型*/
+    private String orderType;
+    /**预发货数量*/
+    private java.math.BigDecimal quantity;
+    /**外销发票号*/
+    private String exportInvoiceCode;
+    //明细对象
+    private List<PurchasePreDeliverDetailVo> purchasePreDeliverDetailList;
+}

+ 6 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/shippingDetails/mapper/SyShippingDetailsMapper.java

@@ -73,4 +73,10 @@ public interface SyShippingDetailsMapper extends BaseMapper<SyShippingDetails> {
 
     //查询报关要素子表
     public List<SyDeclarationElementsItem> querysyDeclarationElementsItemList(@Param("id") String id);
+
+    public PurchasePreDeliverVo getPurchasePreDeliverVo(@Param("id") List<String> id);
+
+    public List<PurchasePreDeliverDetailVo> getPurchasePreDeliverDetailVo(@Param("id") List<String> shippingDetailsId);
+
+    List<PurchasePreDeliverDetailSizeVo> getPurchasePreDeliverDetailSizeVo(String shippingDetailsId);
 }

+ 50 - 8
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/shippingDetails/mapper/xml/SyShippingDetailsMapper.xml

@@ -64,7 +64,6 @@ a.end_customer) as endCustomer,
         AND b.inventory_ccode not like '19%'
     </select>
 
-
 <select id="queryShippingDetails" resultType="org.jeecg.modules.documents.shippingDetails.entity.VO.SyShippingDetailsVo">
     select /*e.declaration_name as declarationName,e.hs_code as hsCode,e.english_product_name as englishProductName,*/a.create_time as createTime,b.is_reference as isReference,
     a.id as id,GROUP_CONCAT(b.id) as itemIds,a.document_no as documentNo,a.document_date as documentDate,b.order_number as orderNumber,a.push_state,b.submit_status as submitStatus,
@@ -119,7 +118,6 @@ GROUP BY b.group_id
 
 </select>
 
-
     <select id="queryShippingDetailsGarment" resultType="org.jeecg.modules.documents.shippingDetails.entity.VO.SyShippingDetailsVo">
     select e.declaration_name as declarationName,e.hs_code as hsCode,e.english_product_name as englishProductName,a.create_time as createTime,b.is_reference as isReference,a.id as id,GROUP_CONCAT(b.id) as itemIds,a.document_no as documentNo,a.document_date as documentDate,b.order_number as orderNumber,a.push_state,b.submit_status as submitStatus,
     b.customer_abbreviation as customerAbbreviation,b.sales_department as salesDepartment,b.salesman as salesman,a.customer as customer,b.specification_and_model as specificationAndModel,
@@ -180,7 +178,6 @@ GROUP BY b.group_id order by a.create_time desc
         where id = #{shippingDetailsId}
     </update>
 
-
     <select id="pushSyShipping" resultType="org.jeecg.modules.documents.shippingDetails.entity.VO.PushShippingVO">
       select
       a.document_no as attributeString1,a.id as attributeString2,
@@ -211,7 +208,6 @@ GROUP BY b.group_id order by a.create_time desc
         where b.del_flag = 0 and b.shipping_details_id = #{shippingDetailsId}
     </select>
 
-
     <select id="displayDetails" resultType="org.jeecg.modules.documents.shippingDetails.entity.VO.OrderDataVo">
            select b.sy_order_data_id as syOrderDataId,b.id as syOrderDataItemId ,a.order_number as orderNumber,b.item_number as itemNumber,b.small_po as smallPo,b.pk_org as pkOrg,a.order_date as orderDate,b.inventory_name as inventoryName,
          b.colour as colour,b.size as size,b.coding_rules as codingRules,b.quantity as quantity,a.business_type_value as businessTypeText,a.customer_order_number as customerOrderNumber,
@@ -238,7 +234,6 @@ GROUP BY b.group_id order by a.create_time desc
 
     </select>
 
-
     <select id="exCelQuery" resultType="org.jeecg.modules.documents.shippingDetails.entity.VO.SyShippingDetailsVo">
           select t.* from(select a.id as id,a.document_no as documentNo,a.document_date as documentDate,b.order_number as orderNumber,a.push_state,a.state,
     b.customer_abbreviation as customerAbbreviation,b.sales_department as salesDepartment,b.salesman as salesman,a.customer as customer,
@@ -259,7 +254,6 @@ where a.del_flag = 0  order by a.document_no desc) as t
 ${ew.customSqlSegment}
     </select>
 
-
     <update id="updateElenmentId">
         update sy_shipping_details_item b
         left  join sy_shipping_details a
@@ -301,7 +295,6 @@ ${ew.customSqlSegment}
 
     </update>
 
-
     <select id="queryAllsyShippingDeial" resultType="org.jeecg.modules.documents.shippingDetails.entity.VO.SyShippingDetailsVo">
 
         select b.id as itemIds from sy_shipping_details a
@@ -333,7 +326,6 @@ ${ew.customSqlSegment}
         and a.del_flag = '0' and b.del_flag = '0' and b.inventory_ccode NOT LIKE '19%'
     </select>
 
-
     <update id="singleRowdelect">
 
         update sy_shipping_details_item
@@ -348,4 +340,54 @@ ${ew.customSqlSegment}
         WHERE sy_declaration_elements_id = #{id} AND del_flag = 0 ORDER BY CAST(sort AS SIGNED) ASC
 
     </select>
+
+    <select id="getPurchasePreDeliverVo" resultType="org.jeecg.modules.documents.shippingDetails.entity.VO.PurchasePreDeliverVo">
+        select
+        -- 	'businessType', 'consigner', 'acceptor','orderType',
+            a.id 'syShippingId',b.account 'sysOrgCode',
+            sum(shipment_quantity) 'quantity',a.document_date 'vbilldate',
+            b.pre_delivery_date 'sendDate',order_number 'orderCode'
+        from sy_shipping_details a
+        left join sy_shipping_details_item b
+        on a.id=b.shipping_details_id
+        where b.id in
+        <foreach collection="id" item="item"  open="(" separator="," close=")">
+            #{item}
+        </foreach>
+    </select>
+
+    <select id="getPurchasePreDeliverDetailVo" resultType="org.jeecg.modules.documents.shippingDetails.entity.VO.PurchasePreDeliverDetailVo">
+        select
+        -- 'purchasePreDeliverId','downSupplier','upSupplier', 'tailoring_Gate_Width', b.size 'size',
+        b.group_Id 'syShippingDetailGroupId',b.order_Number 'orderCode',
+        b.item_number 'styleNo',b.inventory_code 'invCode',b.colour 'color',
+        b.inventory_name 'invName',b.specification_and_model 'invSpec',
+        sum(b.shipment_quantity) 'quantity',b.coding_rules 'codingRules',
+        b.submit_status 'submitStatus',b.weight 'weight',
+        b.guangpei_gate_width 'guangpeiGateWidth',b.small_Po 'smallPo',
+        b.distribution_Point 'distributionPoint',b.pack_id 'packId',
+        b.material_composition 'composition',b.box_number 'boxNumber',
+        b.d_arrive_date 'arriveDate',sum(b.shipment_quantity) 'deliveryQuantity'
+        from sy_shipping_details a
+        left join sy_shipping_details_item b
+        on a.id=b.shipping_details_id
+        where b.id in
+        <foreach collection="id" item="item"  open="(" separator="," close=")">
+            #{item}
+        </foreach>
+        group by b.group_Id
+        order by size+0
+    </select>
+
+    <select id="getPurchasePreDeliverDetailSizeVo" resultType="org.jeecg.modules.documents.shippingDetails.entity.VO.PurchasePreDeliverDetailVo">
+        select b.size 'size',c.num,
+               b.id 'syShippingDetailsId',
+               b.ompo_Id_Item 'purchaseId',
+               b.shipment_quantity 'quantity'
+        from sy_shipping_details a
+        left join sy_shipping_details_item b on a.id=b.shipping_details_id
+		LEFT JOIN sizetable c ON b.`size`=c.`size`
+        where b.group_Id = #{value}
+        order by c.num
+    </select>
 </mapper>

+ 2 - 3
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/shippingDetails/service/ISyShippingDetailsService.java

@@ -2,9 +2,6 @@ package org.jeecg.modules.documents.shippingDetails.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.orderData.entity.SyOrderData;
-import org.jeecg.modules.documents.seclarationElements.entity.SyDeclarationElements;
 import org.jeecg.modules.documents.shippingDetails.entity.SyShippingDetails;
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.modules.documents.shippingDetails.entity.VO.*;
@@ -64,5 +61,7 @@ public interface ISyShippingDetailsService extends IService<SyShippingDetails> {
     //发运明细修改单行删除、
     public int singleRowdelect(String id);
 
+    public List<PurchasePreDeliverDetailVo> getPurchasePreDeliverDetailVo(List<String> id);
 
+    public PurchasePreDeliverVo getPurchasePreDeliverVo(List<String> id);
 }

+ 26 - 7
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/shippingDetails/service/impl/SyShippingDetailsServiceImpl.java

@@ -5,21 +5,15 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.jeecg.common.exception.JeecgBootException;
 import org.jeecg.common.util.oConvertUtils;
-import org.jeecg.modules.documents.orderData.entity.SyOrderData;
 import org.jeecg.modules.documents.orderData.entity.SyOrderDataItem;
-import org.jeecg.modules.documents.orderData.entity.SyOrderDataVO;
 import org.jeecg.modules.documents.orderData.service.impl.SyOrderDataItemServiceImpl;
 import org.jeecg.modules.documents.seclarationElements.entity.SyDeclarationElements;
 import org.jeecg.modules.documents.seclarationElements.service.ISyDeclarationElementsService;
 import org.jeecg.modules.documents.shippingDetails.entity.SyShippingDetails;
 import org.jeecg.modules.documents.shippingDetails.entity.SyShippingDetailsItem;
-import org.jeecg.modules.documents.shippingDetails.entity.VO.OrderDataVo;
-import org.jeecg.modules.documents.shippingDetails.entity.VO.PushShippingDeialVo;
-import org.jeecg.modules.documents.shippingDetails.entity.VO.PushShippingVO;
-import org.jeecg.modules.documents.shippingDetails.entity.VO.SyShippingDetailsVo;
+import org.jeecg.modules.documents.shippingDetails.entity.VO.*;
 import org.jeecg.modules.documents.shippingDetails.mapper.SyShippingDetailsMapper;
 import org.jeecg.modules.documents.shippingDetails.service.ISyShippingDetailsService;
-import org.jeecg.modules.system.util.InterfaceConnUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -365,6 +359,17 @@ public class SyShippingDetailsServiceImpl extends ServiceImpl<SyShippingDetailsM
         return syShippingDetailsMapper.pushSyShipping(id);
     }
 
+    /**
+     * 发运明细推送(查询主表)
+     * @param id
+     * @return
+     */
+    @Override
+    public PurchasePreDeliverVo getPurchasePreDeliverVo(List<String> id) {
+
+        return syShippingDetailsMapper.getPurchasePreDeliverVo(id);
+    }
+
     /**
      * 发运明细推送(查询子表)
      * @param shippingDetailsId
@@ -375,6 +380,20 @@ public class SyShippingDetailsServiceImpl extends ServiceImpl<SyShippingDetailsM
         return syShippingDetailsMapper.pushSyShippingDeial(shippingDetailsId);
     }
 
+    /**
+     * 发运明细推送(查询子表)
+     * @param shippingDetailsId
+     * @return
+     */
+    @Override
+    public List<PurchasePreDeliverDetailVo> getPurchasePreDeliverDetailVo(List<String> shippingDetailsId) {
+        List<PurchasePreDeliverDetailVo> deliverDetailVos=syShippingDetailsMapper.getPurchasePreDeliverDetailVo(shippingDetailsId);
+        deliverDetailVos.forEach(p->{
+            List<PurchasePreDeliverDetailSizeVo> deliverDetailSizeVos=syShippingDetailsMapper.getPurchasePreDeliverDetailSizeVo(p.getSyShippingDetailGroupId());
+            p.setPurchasePreDeliverDetailSizeList(deliverDetailSizeVos);
+        });
+        return deliverDetailVos;
+    }
 
     /**
      * 额外维护款号、物料成分、是否做TC证书

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

@@ -15,6 +15,8 @@ import javax.servlet.http.HttpServletResponse;
 
 import cn.afterturn.easypoi.excel.ExcelExportUtil;
 import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.google.gson.Gson;
@@ -39,6 +41,7 @@ import org.jeecg.modules.openApi.service.IDxpDataPlanService;
 import org.jeecg.modules.spapl.entity.SizeTable;
 import org.jeecg.modules.spapl.vo.PackingHeaderVo;
 import org.jeecg.modules.spapl.vo.SyPreAssembledPackingListVo;
+import org.jeecg.modules.splt.entity.SyPackingListTailoring;
 import org.jeecg.modules.system.util.InterfaceConnUtils;
 
 import org.jeecg.common.api.vo.Result;
@@ -491,6 +494,39 @@ public class SyPreAssembledPackingListController extends JeecgController<SyPreAs
 
     }
 
+
+    @PostMapping(value = "/saveBath")
+    @AutoLog(value = "测试接收功能")
+    @ApiOperation(value="测试接收功能", notes="测试接收功能")
+    public Result saveBath(@RequestBody String str){
+        str= JSON.parse(str).toString();
+        JSONArray json=JSONObject.parseArray(str);
+        Result result=new Result();
+        try {
+            if(json!=null&&json.size()>0) {
+                //账套
+                for (int i = 0; i < json.size(); i++) {
+                    //获取对象
+                    JSONObject jsonObject = json.getJSONObject(i);
+                    //获取json名
+                    String spapl = jsonObject.get("spapl").toString();
+                    //转list
+                    List<SyPreAssembledPackingList> syPreAssembledPackingLists=JSONObject.parseArray(spapl,SyPreAssembledPackingList.class);
+                    //生成数据
+                    boolean bool= syPreAssembledPackingListService.saveList(syPreAssembledPackingLists);
+                }
+                result.setSuccess(true);
+                result.setMessage("操作成功");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.error500("操作失败:"+e.getMessage());
+        }
+        return result;
+    }
+
+
     /**
      * 推送测试
      * @param ids
@@ -820,7 +856,7 @@ public class SyPreAssembledPackingListController extends JeecgController<SyPreAs
         QueryWrapper<SyPreAssembledPackingList> queryWrapper = new QueryWrapper<SyPreAssembledPackingList>();
         queryWrapper.eq("id",id).eq("del_flag",0);//预装箱单主表id
         SyPreAssembledPackingList preAssembledPackingList=syPreAssembledPackingListService.queryById(queryWrapper);//已筛选删除状态
-        List<SyPreAssembledPackingListItem> spaplItems = syPreAssembledPackingListItemService.selectByMainId(id);//已筛选删除状态
+        List<SyPreAssembledPackingListItem> spaplItems = syPreAssembledPackingListItemService.selectByMainId2(id,preAssembledPackingList.getSizeTables());//已筛选删除状态
         //List<String> strings=new ArrayList<>();
         if(spaplItems.size()>0){
             preAssembledPackingList.setSyPreAssembledPackingListItemList(spaplItems);
@@ -1687,13 +1723,14 @@ public class SyPreAssembledPackingListController extends JeecgController<SyPreAs
                 if((5+list.getSizeTables().size())-6>0){
                     CellRangeAddress region2 = new CellRangeAddress( mainLength+1, mainLength+1,6, 5+list.getSizeTables().size());
                     sheet.addMergedRegion(region2);
+//                    CellRangeAddress region3 = new CellRangeAddress( mainLength+1, mainLength+1,35, 37);
+//                    sheet.addMergedRegion(region3);
                 }
                 row = sheet.createRow(mainLength+1);
                 for (int i=0;i<x;i++){
                     Cell cell = row.createCell(i);//横向
                     cell.setCellStyle(cellStyle);
                     if(i>=6&&i<6+list.getSizeTables().size()){
-                        //row.createCell(6).setCellValue("size");
                         Cell cell2= row.createCell(6);
                         cell2.setCellStyle(cellStyle2);
                         cell2.setCellValue("size");
@@ -1702,8 +1739,8 @@ public class SyPreAssembledPackingListController extends JeecgController<SyPreAs
                         cell.setCellValue(args2[i]);
                         cell.setCellStyle(cellStyle);
                     }
-                    else if(i>=5+list.getSizeTables().size()&&i<9+list.getSizeTables().size()){
-                        //System.out.println("i\t"+i);
+                    else if(i>=5+list.getSizeTables().size()&&i<14+list.getSizeTables().size()){
+//                        System.out.println(args2[i-list.getSizeTables().size()]+"\t"+(i-list.getSizeTables().size())+"\t"+i);
                         cell.setCellValue(args2[i-list.getSizeTables().size()]);
                         cell.setCellStyle(cellStyle);
                     }

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

@@ -46,4 +46,8 @@ public class SizeTable {
     @ApiModelProperty(value = "分组名称")
     @TableField(exist = false)
     private java.lang.String groupName;
+
+    @ApiModelProperty(value = "出运明细分组id")
+    @TableField(exist = false)
+    private java.lang.String groupItemId;
 }

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

@@ -297,7 +297,11 @@ public class SyPreAssembledPackingList implements Serializable {
 				"PORT:"+ ","+
 				distributionPoint+ ","+
 				"CLASSES:"+ ","+
-				inventoryCurrencyName;
+				inventoryCurrencyName+ ","+
+				"佣金:"+ ","+
+				ymoney+ ","+
+				"采购委外订单号:"+ ","+
+				spurOrSubOrder;
 	}
 
 	/*public String toString1(){

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

@@ -19,6 +19,8 @@
 			id,
 			sy_pre_assembled_packing_list_id,
 			sy_declaration_elements_id,
+			(select group_id from sy_shipping_details_item
+			where id=sy_declaration_elements_item_id) as groupItemId,
 			sy_order_data_id,
 			item_Code,
 			ac_set_no,
@@ -176,6 +178,8 @@
 		sizetable.num,
 		id as itemId,
 		sy_order_data_item_id,
+		(select group_id from sy_shipping_details_item
+		where id=sy_declaration_elements_item_id) as groupItemId,
 		total quantity,
 		total/box_number proportion,
 		group_id
@@ -407,87 +411,30 @@
 	</select>
 
 	<select id="insertBatch"   resultType="int">
-		  	insert into sy_pre_assembled_packing_list_item( id,
-			sy_pre_assembled_packing_list_id,
-			sy_declaration_elements_id,
-			sy_declaration_elements_item_id,
-			ac_set_no,
-			garment_factory,
-			hod,
-			style_no,
-			po_no,
-			item_code,
-			distribution_point,
-			prepack_sku,
-			size,
-			starting_box_number,
-			end_case_number,
-			colour,
-			pieces_box,
-			box_number,
-			total,
-			net_weight,
-			total_net_weight,
-			gross_weight,
-			total_gross_weight,
-			outer_box_length,
-			outer_box_width,
-			outer_box_height,
-			total_volume,
-			net_weight_too,
-			unit_price,
-			total_price,
-			sort,
-			create_by,
-			create_time,
-			update_by,
-			update_time,
-			pk_org,
-			del_flag,
-			memo,
-			with_code,
-			small_po,
-			inventory_name,
-			factory_unit_price,
-			master_Metering,
-			group_id,
-			inventory_Code,
-			plan_Quantity,
-			actual_Packing_Qty,
-			spur_or_sub_order,
-			sy_order_data_id,
-			sy_order_data_item_id,
-			inventory_ccode,
-			supplier_Code,
-			supplier,
-			ompo_Account,
-			ompo_Id,
-			ompo_Id_Item,
-			ymoney,
-			plan_Size,
-			order_Number,
-			remaining_Quantity,
-			salesman,
-			sales_Department,
-			customs_declaration_unit_price,
-			pack_id,
-			total_Pack,
-			pack_box,
-			packs)
-			VALUES
-			<foreach collection="list" item="entity" index="index" separator="," >
-				(#{entity.id}, #{entity.syPreAssembledPackingListId}, #{entity.syDeclarationElementsId}, #{entity.syDeclarationElementsItemId}, #{entity.acSetNo},
-				#{entity.garmentFactory}, #{entity.hod}, #{entity.styleNo}, #{entity.poNo}, #{entity.itemCode}, #{entity.distributionPoint}, #{entity.prepackSku},
-				#{entity.size}, #{entity.startingBoxNumber}, #{entity.endCaseNumber}, #{entity.colour}, #{entity.piecesBox}, #{entity.boxNumber}, #{entity.total},
-				#{entity.netWeight}, #{entity.totalNetWeight}, #{entity.grossWeight}, #{entity.totalGrossWeight}, #{entity.outerBoxLength}, #{entity.outerBoxWidth},
-				#{entity.outerBoxHeight}, #{entity.totalVolume}, #{entity.netWeightToo}, #{entity.unitPrice}, #{entity.totalPrice}, #{entity.sort}, #{entity.createBy},
-				#{entity.createTime}, #{entity.updateBy}, #{entity.updateTime}, #{entity.pkOrg}, #{entity.delFlag}, #{entity.memo}, #{entity.withCode}, #{entity.smallPo},
-				#{entity.inventoryName}, #{entity.factoryUnitPrice}, #{entity.masterMetering}, #{entity.groupId}, #{entity.inventoryCode}, #{entity.planQuantity},
-				#{entity.actualPackingQty}, #{entity.spurOrSubOrder}, #{entity.syOrderDataId}, #{entity.syOrderDataItemId}, #{entity.inventoryCcode}, #{entity.supplierCode},
-				#{entity.supplier}, #{entity.ompoAccount}, #{entity.ompoId}, #{entity.ompoIdItem}, #{entity.ymoney}, #{entity.planSize}, #{entity.orderNumber}, #{entity.remainingQuantity},
-				 #{entity.salesman}, #{entity.salesDepartment}, #{entity.customsDeclarationUnitPrice}, #{entity.packId}, #{entity.totalPack}, #{entity.packBox}, #{entity.packs})
-			</foreach>
-
+		insert into sy_pre_assembled_packing_list_item( id,sy_pre_assembled_packing_list_id,
+		sy_declaration_elements_id,sy_declaration_elements_item_id,ac_set_no,garment_factory,
+		hod,style_no,po_no,item_code,distribution_point,prepack_sku,size,starting_box_number,
+		end_case_number,colour,pieces_box,box_number,total,net_weight,total_net_weight,gross_weight,
+		total_gross_weight,outer_box_length,outer_box_width,outer_box_height,total_volume,
+		net_weight_too,unit_price,total_price,sort,create_by,create_time,update_by,update_time,
+		pk_org,del_flag,memo,with_code,small_po,inventory_name,factory_unit_price,master_Metering,
+		group_id,inventory_Code,plan_Quantity,actual_Packing_Qty,spur_or_sub_order,sy_order_data_id,
+		sy_order_data_item_id,inventory_ccode,supplier_Code,supplier,ompo_Account,ompo_Id,ompo_Id_Item,
+		ymoney,plan_Size,order_Number,remaining_Quantity,salesman,sales_Department,
+		customs_declaration_unit_price,pack_id,total_Pack,pack_box,packs)
+		VALUES
+		<foreach collection="list" item="entity" index="index" separator="," >
+			(#{entity.id}, #{entity.syPreAssembledPackingListId}, #{entity.syDeclarationElementsId}, #{entity.syDeclarationElementsItemId}, #{entity.acSetNo},
+			#{entity.garmentFactory}, #{entity.hod}, #{entity.styleNo}, #{entity.poNo}, #{entity.itemCode}, #{entity.distributionPoint}, #{entity.prepackSku},
+			#{entity.size}, #{entity.startingBoxNumber}, #{entity.endCaseNumber}, #{entity.colour}, #{entity.piecesBox}, #{entity.boxNumber}, #{entity.total},
+			#{entity.netWeight}, #{entity.totalNetWeight}, #{entity.grossWeight}, #{entity.totalGrossWeight}, #{entity.outerBoxLength}, #{entity.outerBoxWidth},
+			#{entity.outerBoxHeight}, #{entity.totalVolume}, #{entity.netWeightToo}, #{entity.unitPrice}, #{entity.totalPrice}, #{entity.sort}, #{entity.createBy},
+			#{entity.createTime}, #{entity.updateBy}, #{entity.updateTime}, #{entity.pkOrg}, #{entity.delFlag}, #{entity.memo}, #{entity.withCode}, #{entity.smallPo},
+			#{entity.inventoryName}, #{entity.factoryUnitPrice}, #{entity.masterMetering}, #{entity.groupId}, #{entity.inventoryCode}, #{entity.planQuantity},
+			#{entity.actualPackingQty}, #{entity.spurOrSubOrder}, #{entity.syOrderDataId}, #{entity.syOrderDataItemId}, #{entity.inventoryCcode}, #{entity.supplierCode},
+			#{entity.supplier}, #{entity.ompoAccount}, #{entity.ompoId}, #{entity.ompoIdItem}, #{entity.ymoney}, #{entity.planSize}, #{entity.orderNumber}, #{entity.remainingQuantity},
+			 #{entity.salesman}, #{entity.salesDepartment}, #{entity.customsDeclarationUnitPrice}, #{entity.packId}, #{entity.totalPack}, #{entity.packBox}, #{entity.packs})
+		</foreach>
 	</select>
 
 

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

@@ -396,7 +396,8 @@
         b.distribution_Point,
         SUBSTRING(b.hod,1,10)  hod,
         b.supplier,
-        b.ymoney,
+        b.spur_Or_Sub_Order spurOrSubOrder,
+        d.ymoney,
         b.Unit_Price  price,
         d.material_Composition,
         declaration_name productName,

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

@@ -20,6 +20,8 @@ public interface ISyPreAssembledPackingListItemService extends IService<SyPreAss
 
 	public List<SyPreAssembledPackingListItem> selectByMainId(String mainId);
 
+	public List<SyPreAssembledPackingListItem> selectByMainId2(String mainId,List<SizeTable> sizeMs);
+
 	/**
 	 * str为尺码范围和数量比例
 	 * @param str

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

@@ -128,9 +128,11 @@ public interface ISyPreAssembledPackingListService extends IService<SyPreAssembl
 
 	public String[] getExcelId();
 
-	List<SyPreAssembledPackingList>  queryById2( Map<String, List<String>> ids, List<String> allIds);
+	public List<SyPreAssembledPackingList>  queryById2( Map<String, List<String>> ids, List<String> allIds);
 
-	List<SyPreAssembledPackingList> selectPage3(QueryWrapper<SyPreAssembledPackingListVo> queryWrapper);
+	public List<SyPreAssembledPackingList> selectPage3(QueryWrapper<SyPreAssembledPackingListVo> queryWrapper);
 
-	SyPreAssembledPackingList getPacking(String id);
+	public SyPreAssembledPackingList getPacking(String id);
+
+	public boolean saveList(List<SyPreAssembledPackingList> syPreAssembledPackingLists);
 }

+ 61 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/spapl/service/impl/SyPreAssembledPackingListItemServiceImpl.java

@@ -54,6 +54,67 @@ public class SyPreAssembledPackingListItemServiceImpl extends ServiceImpl<SyPreA
 		return list;
 	}
 
+	@Override
+	public List<SyPreAssembledPackingListItem> selectByMainId2(String mainId,List<SizeTable> sizeMs) {
+		List<SyPreAssembledPackingListItem> list= syPreAssembledPackingListItemMapper.selectByMainId(mainId);
+		List<SizeTable> sizes=syPreAssembledPackingListItemMapper.queryAllSizes(mainId);
+		Map<String,List<SizeTable>> mapItemSizes=new HashMap<>();//子表尺码
+		for (SizeTable size : sizes){//子表尺码
+			if(mapItemSizes.containsKey(size.getGroupId())){//有
+				mapItemSizes.get(size.getGroupId()).add(size);
+			}else{
+				List<SizeTable> items=new ArrayList<>();
+				items.add(size);
+				mapItemSizes.put(size.getGroupId(),items);
+			}
+		}
+//		int num=1;
+		for (String keyset : mapItemSizes.keySet()){
+			List<SizeTable> sizeTables=mapItemSizes.get(keyset);
+			for (SizeTable sizeTable1 : sizeMs){
+				boolean bool=true;
+				for (SizeTable sizeTable2 : sizeTables){
+					if (sizeTable2.getSize().equals(sizeTable1.getSize())){
+						bool=false;
+					}
+				}
+				if (bool==true){
+					SizeTable sizeTable2=sizeTables.get(0);
+					SizeTable sizeTable3=new SizeTable();
+
+					sizeTable3.setNum(sizeTable1.getNum());
+					sizeTable3.setSize(sizeTable1.getSize());
+					sizeTable3.setAlias(sizeTable1.getAlias());
+					sizeTable3.setProportion(sizeTable1.getProportion());
+					sizeTable3.setItemId(sizeTable1.getItemId());
+					sizeTable3.setQuantity(sizeTable1.getQuantity());
+
+					sizeTable3.setGroupId(sizeTable2.getGroupId());
+					sizeTable3.setGroupItemId(sizeTable2.getGroupItemId());
+
+//					System.out.println("groupItemIdNum"+num+"\t"+sizeTable2.getGroupId());
+					sizeTables.add(sizeTable3);
+				}
+			}
+//			System.out.println("-------------------------------------------------");
+//			num++;
+		}
+//		System.out.println("mapItemSizes\n"+mapItemSizes);
+		for(SyPreAssembledPackingListItem spapl_item : list){
+			spapl_item.setSizeTables(mapItemSizes.get(spapl_item.getGroupId()));
+//			System.out.println("mapItem\n"+mapItemSizes.get(spapl_item.getGroupId()));
+			//sizes=sort(sizes);
+			/*String planSize="";
+			for (SizeTable size : sizes){
+				planSize=planSize+size.getSize()+":"+size.getQuantity().intValue()+"+";
+			}
+			planSize=planSize.substring(0,planSize.length()-1);
+			spapl_item.setPlanSize(planSize);*/
+			//spapl_item.setSizeTables(sizes);
+		}
+		return list;
+	}
+
 	@Override
 	public List<SizeTable> selectSize(String str, BigDecimal orderNum){
 		List<SizeTable> sizes=null;

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

@@ -164,8 +164,8 @@ public class SyPreAssembledPackingListServiceImpl extends ServiceImpl<SyPreAssem
 				 }
 				 //box=box.add(boxNumber1);//合计
 				 item.setDelFlag("0");
-				 System.out.println("尺码组长度\t"+sizes.size());
-				 System.out.println("尺码组\t"+sizes);
+//				 System.out.println("尺码组长度\t"+sizes.size());
+//				 System.out.println("尺码组M\n"+sizes);
 				 for (SizeTable size : sizes){
 					 if(size.getProportion()==null){
 						 size.setProportion(0);
@@ -174,6 +174,7 @@ public class SyPreAssembledPackingListServiceImpl extends ServiceImpl<SyPreAssem
 					 item1.setSize(size.getSize());//获取尺码信息
 					 BigDecimal boxNumber=boxNumber1.multiply(new BigDecimal(size.getProportion()));//获取该尺码件数
 					 item1.setTotal(boxNumber);//该尺码件数
+					 size.setNum(boxNumber.intValue());
 					 item1.setTotalPrice(boxNumber.multiply(item1.getUnitPrice()).setScale(2, RoundingMode.HALF_UP));//获取总价		箱数*单价-->件数*单价
 					 item1.setId(size.getItemId());//从尺码表中获取到id
 					 if(size.getProportion()==0){
@@ -208,9 +209,35 @@ public class SyPreAssembledPackingListServiceImpl extends ServiceImpl<SyPreAssem
 //						 System.out.println("修改");
 						 //syPreAssembledPackingListItemMapper.updateById(item1);//如果没修改成功就是新增数据
 					 }
+//					 System.out.println("getIsAdd\n"+item.getIsAdd()+"\tgetItemId\t"+size.getItemId()+"\tgetProportion\t"+size.getProportion());
+					 if (item.getIsAdd()==0&&size.getItemId()==null&&size.getProportion()>0){
+//						String syDeclarationElementsItemId=syPreAssembledPackingListItemMapper.selectById(item1.getId()).getSyDeclarationElementsItemId();
+//						item1.setSyDeclarationElementsItemId(syDeclarationElementsItemId);
+					 	QueryWrapper queryWrapper=new QueryWrapper();
+					 	queryWrapper.eq("size",size.getSize());
+					 	queryWrapper.eq("del_flag","0");
+					 	queryWrapper.eq("group_id",size.getGroupItemId());
+						SyShippingDetailsItem syItem=syShippingDetailsItemMapper.selectOne(queryWrapper);
+						if(syItem!=null){
+							 //获取委外/采购订单子表Id
+							 item1.setOmpoId(syItem.getOmpoId());
+							 item1.setSyDeclarationElementsItemId(syItem.getId());
+							 item1.setOmpoIdItem(syItem.getOmpoIdItem());
+							 item1.setOmpoAccount(syItem.getOmpoAccount());
+							 item1.setSyOrderDataId(syItem.getSyOrderDataId());
+							 item1.setSyOrderDataItemId(syItem.getSyOrderDataItemId());
+							 item1.setOrderNumber(syItem.getOrderNumber());//获取订单号
+							 item1.setSupplierCode(syItem.getSupplierCode());
+							 item1.setSupplier(syItem.getSupplier());
+							 //获取订单子表id
+							 //item1.setSyOrderDataItemId(syItem.getSyOrderDataItemId());
+						 }
+						 item1.setSyPreAssembledPackingListId(pid);
+						 item1.setId(oConvertUtils.id());//获取到随机id
+						 syPreAssembledPackingListItemMapper.insert(item1);
+					 }
 				 }
-			 }
-			 else{
+			 }else{
 				 System.out.println("删除了");
 			 	syPreAssembledPackingListItemMapper.deleteByGroupId(item2.getGroupId());
 			 }
@@ -907,6 +934,9 @@ public class SyPreAssembledPackingListServiceImpl extends ServiceImpl<SyPreAssem
 						syPreAssembledPackingList.setOrderNumber(syItem.getOrderNumber());
 						syPreAssembledPackingList.setItemNumber(syItem.getItemNumber());
 						syPreAssembledPackingList.setSpurOrSubOrder(syItem.getPurOrSubOrder());
+
+						syPreAssembledPackingList.setCustomer(syItem.getCustomerName());
+						syPreAssembledPackingList.setSyOrderDataId(syItem.getSyOrderDataId());
 						//原剩余数量-预装箱单装箱数量=新剩余数量
 						/*syItem.setSurplusQuantity(syItem.getSurplusQuantity().subtract(item1.getTotal()));
 						//超发数量
@@ -1322,4 +1352,145 @@ public class SyPreAssembledPackingListServiceImpl extends ServiceImpl<SyPreAssem
 //		}
 		return packingList;
 	}
+
+	@Override
+	public boolean saveList(List<SyPreAssembledPackingList> items1) {
+		boolean bool=false;
+		List<SyPreAssembledPackingList> lists=new ArrayList<>();
+		List<SyPreAssembledPackingListItem> listItems=new ArrayList<>();
+		List<String> documentNos=getDateNos(items1.size());
+		List<String> ids=new ArrayList<>();
+		for (SyPreAssembledPackingList item : items1){
+			ids.add(item.getSyDeclarationElementsId());//获取出运明细主表id
+		}
+		QueryWrapper queryWrapper=new QueryWrapper();
+		queryWrapper.in("shipping_Details_Id",ids);
+		queryWrapper.in("del_flag",0);
+		List<SyShippingDetailsItem> syItems=syShippingDetailsItemMapper.selectList(queryWrapper);//获取数据
+		Map<String,SyShippingDetailsItem> mapItems=new HashMap<>();
+		Map<String,SyShippingDetailsItem> map=new HashMap<>();
+		for (SyShippingDetailsItem detailsItem : syItems){
+			if(detailsItem.getCodingRules()==null||detailsItem.getCodingRules().length()<1){
+				map.put(detailsItem.getGroupId()+"默认配码规格"+detailsItem.getSize(),detailsItem);
+			}else{
+				map.put(detailsItem.getGroupId()+detailsItem.getCodingRules()+detailsItem.getSize(),detailsItem);
+			}
+		}
+		for (SyShippingDetailsItem item : syItems){
+			mapItems.put(item.getId(),item);
+		}
+		Date day=new Date();
+		try {
+			String time= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(System.currentTimeMillis());
+			day =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(time);//获取制单日期
+		}catch (Exception e){
+
+		}
+		System.out.println(day);
+		int num=0;
+		try{
+			for(SyPreAssembledPackingList syPreAssembledPackingList : items1){
+				syPreAssembledPackingList.setDocumentNo(documentNos.get(num));//订单号-->单据号
+				num++;
+				syPreAssembledPackingList.setDelFlag("0");//删除状态默认为0
+				syPreAssembledPackingList.setPushStatus("0");//推送状态默认为0
+				syPreAssembledPackingList.setStatus("0");//单据状态默认为0
+				syPreAssembledPackingList.setTotal(new BigDecimal("0"));
+				syPreAssembledPackingList.setTotalBoxes(new BigDecimal("0"));
+				syPreAssembledPackingList.setTotalNetWeight(new BigDecimal("0"));
+				syPreAssembledPackingList.setTotalGrossWeight(new BigDecimal("0"));
+				syPreAssembledPackingList.setTotalVolume(new BigDecimal("0"));
+				syPreAssembledPackingList.setTotalPrice(new BigDecimal("0"));
+				syPreAssembledPackingList.setId(oConvertUtils.id());
+				List<SyPreAssembledPackingListItem> items=syPreAssembledPackingList.getSyPreAssembledPackingListItemList();
+				for (SyPreAssembledPackingListItem item : items){
+					syPreAssembledPackingList.setTotalBoxes(syPreAssembledPackingList.getTotalBoxes().add(item.getBoxNumber()));
+					syPreAssembledPackingList.setTotalNetWeight(syPreAssembledPackingList.getTotalNetWeight().add(item.getTotalNetWeight()));
+					syPreAssembledPackingList.setTotalGrossWeight(syPreAssembledPackingList.getTotalGrossWeight().add(item.getTotalGrossWeight()));
+					syPreAssembledPackingList.setTotalVolume(syPreAssembledPackingList.getTotalVolume().add(item.getTotalVolume()));
+					List<SizeTable> sizes=item.getSizeTables();//获取尺码表信息
+					item.setSyPreAssembledPackingListId(syPreAssembledPackingList.getId());//获取主表id
+					syPreAssembledPackingList.setIsExcel(1);//设置成1
+					BigDecimal boxNumber1=item.getBoxNumber();//获取箱数
+					item.setActualPackingQty(item.getTotal());//计划装箱数量
+					item.setGroupId(org.jeecg.modules.system.util.oConvertUtils.getId());//分组id
+					item.setDelFlag("0");//默认为未删除er
+					for (SizeTable size : sizes){
+						if(size.getProportion()==null||size.getProportion()==0){
+							continue;
+						}
+						String str=item.getGroupItemId()+item.getWithCode()+size.getSize();
+						SyShippingDetailsItem syItem=map.get(str);
+						if(syItem==null){
+							continue;
+						}
+						syItem.setIsReference(1);//修改成被参照
+						syShippingDetailsItemMapper.updateById(syItem);
+						SyPreAssembledPackingListItem item1=item;//itemid
+						item1.setSize(size.getSize());//获取尺码信息
+						BigDecimal boxNumber=boxNumber1.multiply(new BigDecimal(size.getProportion()));//获取该尺码件数
+						item1.setTotal(boxNumber);//该尺码件数
+						syPreAssembledPackingList.setTotal(syPreAssembledPackingList.getTotal().add(boxNumber));
+						item1.setActualPackingQty(size.getQuantity());//获取该尺码计划装箱数量
+						item1.setSyDeclarationElementsItemId(syItem.getId());//获取到发运明细子表id
+						item1.setSort(size.getNum());//获取序号
+						item.setCustomsDeclarationUnitPrice(syItem.getCustomsDeclarationUnitPrice());//报关单价
+						item1.setId(oConvertUtils.id());//获取到随机iddistributionPoint
+						//获取发育明细数据
+						item1.setPackId(syItem.getPackId());
+						item1.setUnitPrice(syItem.getSalesUnitPrice());//获取销售单价
+						item1.setFactoryUnitPrice(new BigDecimal(syItem.getFactoryUnitPrice()==null?"0":syItem.getFactoryUnitPrice()));//工厂单价
+						item1.setInventoryName(syItem.getInventoryName());//存货名称
+						item1.setAcSetNo(syItem.getAccount());//获取账套号
+						item1.setHod(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(syItem.getPreDeliveryDate()));//预发货日期
+						item1.setTotalPrice(item1.getTotal().multiply(item1.getUnitPrice()).setScale(2, RoundingMode.HALF_UP));//获取总价		箱数*单价-->件数*单价
+						item1.setOrderNumber(syItem.getOrderNumber());//获取订单号
+						item1.setSpurOrSubOrder(syItem.getPurOrSubOrder());//获取采购委外订货号
+						item1.setSyOrderDataItemId(syItem.getSyOrderDataItemId());//获取到订单子表id
+						syPreAssembledPackingList.setElementsId(syItem.getElementsId());//申报要素id
+						syPreAssembledPackingList.setIsTc(syItem.getIsTc());
+						item1.setSalesman(syItem.getSalesman());//获取业务员
+						item1.setSalesDepartment(syItem.getSalesDepartment());//获取销售部门
+						item1.setInventoryCode(syItem.getInventoryCode());
+						item1.setInventoryCcode(syItem.getInventoryCcode());
+						item1.setCreateTime(day);
+						item1.setSyOrderDataId(syItem.getSyOrderDataId());
+						item1.setSyOrderDataItemId(syItem.getSyOrderDataItemId());
+						item1.setOrderNumber(syItem.getOrderNumber()); //销售订单号
+						item1.setOmpoId(syItem.getOmpoId());//采购委外订单id
+						item1.setOmpoAccount(syItem.getOmpoAccount());//采购委外账套号
+						item1.setOmpoIdItem(syItem.getOmpoIdItem());//采购委外订单子表id
+						item1.setSupplierCode(syItem.getSupplierCode());
+						item1.setSupplier(syItem.getSupplier());
+						syPreAssembledPackingList.setOrderNumber(syItem.getOrderNumber());
+						syPreAssembledPackingList.setItemNumber(syItem.getItemNumber());
+						syPreAssembledPackingList.setSpurOrSubOrder(syItem.getPurOrSubOrder());
+						syPreAssembledPackingList.setCustomer(syItem.getCustomerName());
+						syPreAssembledPackingList.setSyOrderDataId(syItem.getSyOrderDataId());
+						syPreAssembledPackingList.setTotalPrice(syPreAssembledPackingList.getTotalPrice().add(item1.getTotalPrice()));//获取总价
+						if(size.getProportion()==0){
+							item1.setTotal(null);//该尺码件数
+						}
+						SyPreAssembledPackingListItem item2=new SyPreAssembledPackingListItem();
+						BeanUtils.copyProperties(item1,item2);
+						listItems.add(item2);
+					}
+				}
+				SyShippingDetails syShippingDetails=syShippingDetailsMapper.selectById(syPreAssembledPackingList.getSyDeclarationElementsId());
+				if(syShippingDetails!=null){
+					syPreAssembledPackingList.setCustomer(syShippingDetails.getCustomer());
+					syPreAssembledPackingList.setSyOrderDataId(syShippingDetails.getSyOrderDataId());
+				}
+				lists.add(syPreAssembledPackingList);
+			}
+			bool=true;
+		}catch (Exception e){
+			e.printStackTrace();
+			e.getMessage();
+			bool=false;
+		}
+		syPreAssembledPackingListItemMapper.insertBatch(listItems);
+		saveBatch(lists);
+		return bool;
+	}
 }

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

@@ -216,7 +216,7 @@
 	</select>
 
 	<!--<select id="getu8Data"  resultMap="genderIsosid">-->
-	<select id="getu8Data"  resultMap="genderIsosid">
+	<select id="getu8Data" resultMap="genderIsosid">
 		SELECT DISTINCT
 			left(sy_order_data_id,13) AS isosid
 			FROM `sy_shipping_details_item`

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

@@ -87,6 +87,8 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 	@Autowired
 	private SyPackingListFabricMapper syPackingListFabricMapper;
 	@Autowired
+	private ISyPackingListFabricItemService syPackingListFabricItemService;
+	@Autowired
 	private SyPackingListFabricItemMapper syPackingListFabricItemMapper;
 	@Autowired
 	private SyShippingDetailsMapper syShippingDetailsMapper;
@@ -448,8 +450,8 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 		return syPackingListFabric;
 	}
 
-	@Autowired
-	private ISyPackingListFabricItemService syPackingListFabricItemService;
+//	@Autowired
+//	private ISyPackingListFabricItemService syPackingListFabricItemService;
 
 	/**
 	 * 删除 将del_flag改为1
@@ -903,16 +905,39 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 		try{
 			List<String> itemIds=new ArrayList<>();
 			List<String> documentNos=getDateNos(maps.size());
+			List<SyPackingListFabricItem> fabricItems=new ArrayList<>();
+			List<String> detailsId=new ArrayList<>();
+			List<String> detailsId2=new ArrayList<>();
+			List<String> orderdatasId=new ArrayList<>();
+
+			for (String str : maps.keySet()){
+				SyPackingListFabric syPackingListFabric =maps.get(str);
+				for (SyPackingListFabricItem fabricItem : syPackingListFabric.getSyPackingListFabricItem()){
+					detailsId.add(fabricItem.getSyShippingDetailsItemId());
+				}
+			}
+
+			Map<String,SyShippingDetailsItem> detailsItemMap=new HashMap<>();
+			List<SyShippingDetailsItem> detailsItems=syShippingDetailsItemMapper.selectBatchIds(detailsId);//itemid
+			for (SyShippingDetailsItem detailsItem : detailsItems){
+				detailsItemMap.put(detailsItem.getId(),detailsItem);
+				orderdatasId.add(detailsItem.getSyOrderDataItemId());
+			}
+			Map<String,SyOrderDataItem> orderDataItemMap=new HashMap<>();
+			List<SyOrderDataItem> orderDataItems=syOrderDataItemMapper.selectBatchIds(orderdatasId);//orderItemId
+			for (SyOrderDataItem dataItem : orderDataItems){
+				orderDataItemMap.put(dataItem.getId(),dataItem);
+			}
 			int num=0;
 			for (String str : maps.keySet()){
 				//SimpleDateFormat sf = new SimpleDateFormat("yyMMddHHmmssSSS"); totalPrice
 				//String dateNo ="ML"+sf.format(System.currentTimeMillis());//获取单据号
 				SyPackingListFabric syPackingListFabric =maps.get(str);
-				List<String> ids=new ArrayList<>();
-				for (SyPackingListFabricItem item : syPackingListFabric.getSyPackingListFabricItem()){
-					ids.add(item.getSyOrderDataId());
-				}
-				Map<String,String> maps2=orderNumber(ids);
+//				List<String> ids=new ArrayList<>();
+//				for (SyShippingDetailsItem detailsItem : detailsItems){
+//					ids.add(detailsItem.getSyOrderDataId());
+//				}
+//				Map<String,String> maps2=orderNumber(ids);
 //				if(maps2.size()==2){
 //					throw new JeecgBootException("手工匹配订单不能跟普通销售订单混合在一起,手工匹配订单是:"+maps.get("手工同步订单"));
 //				}
@@ -920,6 +945,7 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 				syPackingListFabric.setDocumentNo(documentNos.get(num));//单据号
 				num++;
 				syPackingListFabric.setStatus("0");//状态
+				syPackingListFabric.setMemo("新增测试数据");//备注
 				syPackingListFabric.setDataSource("excel导入");//excel导入
 				String username=getUsername(token);
 				syPackingListFabric.setPreparedBy(username);//将admin设置为制单人
@@ -933,8 +959,10 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 				List<SyPackingListFabricItem> items=syPackingListFabric.getSyPackingListFabricItem();
 				for(SyPackingListFabricItem item :items){
 					item.setDelFlag("0");//是否删除
+					item.setMemo("新增测试数据");
 					item.setSyPackingListFabricId(syPackingListFabric.getId());
-					SyShippingDetailsItem syShippingDetailsItem=syShippingDetailsItemMapper.selectById(item.getSyShippingDetailsItemId());//itemid
+//					SyShippingDetailsItem syShippingDetailsItem=syShippingDetailsItemMapper.selectById(item.getSyShippingDetailsItemId());//itemid
+					SyShippingDetailsItem syShippingDetailsItem=detailsItemMap.get(item.getSyShippingDetailsItemId());//出运明细记录
 					if(syShippingDetailsItem==null){
 						//System.out.println("ids\t"+item.getSyShippingDetailsItemId());
 						throw new JeecgBootException("出运明细未找到对应数据");
@@ -957,9 +985,9 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 					item.setSyOrderDataId(syShippingDetailsItem.getSyOrderDataId());//销售订单子表id
 					item.setGroupId(oConvertUtils.getId());
 //					SyOrderDataItem dataItem=syOrderDataItemMapper.selectById(syShippingDetailsItem.getSyOrderDataItemId());
-//					item.setMasterMetering(dataItem.getMasterMetering());//计量单位
-					item.setMasterMetering(getMasterMetering(syShippingDetailsItem.getSyOrderDataItemId()));//计量单位
-					//item.setMasterMetering(getMasterMetering(item.getSyOrderDataItemId()));
+					SyOrderDataItem dataItem=orderDataItemMap.get(syShippingDetailsItem.getSyOrderDataItemId());//销售订单子表
+					item.setMasterMetering(dataItem.getMasterMetering());//计量单位
+//					item.setMasterMetering(getMasterMetering(syShippingDetailsItem.getSyOrderDataItemId()));//计量单位
 					item.setPurOrSubOrder(syShippingDetailsItem.getPurOrSubOrder());//委外采购订单
 					item.setManualYarnUnitPrice(syShippingDetailsItem.getManualYarnUnitPrice());//手册纱单价
 					item.setManualYarnFlag(syShippingDetailsItem.getManualYarnFlag());//手册纱单价
@@ -1009,8 +1037,9 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 						//item.setRemainingQuantity(syShippingDetailsItem.getOrderRemainingQuantity().subtract(item.getActualDeclaredQuantity()));//剩余数量
 						/*syShippingDetailsItem.setExcessQuantity(item.getActualDeclaredQuantity().subtract(syShippingDetailsItem.getOrderRemainingQuantity()));
 						syShippingDetailsItem.setOrderRemainingQuantity(syShippingDetailsItem.getOrderRemainingQuantity().subtract(item.getActualDeclaredQuantity()));*/
-						syShippingDetailsItem.setIsReference(2);//回写
-						syShippingDetailsItemMapper.updateById(syShippingDetailsItem);
+//						syShippingDetailsItem.setIsReference(2);//回写
+						detailsId2.add(syShippingDetailsItem.getId());
+//						syShippingDetailsItemMapper.updateById(syShippingDetailsItem);
 					}
 //					if(item.getMasterMetering().equals("KG")){
 //						updateQuantity(item.getNetWeight(),item.getSyShippingDetailsItemId(),item.getMasterMetering());
@@ -1018,10 +1047,18 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 //						updateQuantity(item.getActualDeclaredQuantity(),item.getSyShippingDetailsItemId(),item.getMasterMetering());
 //					}
 					itemIds.add(item.getSyShippingDetailsItemId());
-					syPackingListFabricItemMapper.insert(item);
+//					syPackingListFabricItemMapper.insert(item);
+					fabricItems.add(item);
 				}
 				syPackingListFabricMapper.updateById(syPackingListFabric);
 			}
+			UpdateWrapper updateWrapper=new UpdateWrapper();
+			updateWrapper.set("is_reference","2");
+			updateWrapper.eq("id",detailsId2);
+			syShippingDetailsItemMapper.update(null,updateWrapper);
+			syPackingListFabricItemService.saveBatch(fabricItems);//新增子表数据
+			iSyShippingDetailsItemService.saveOrUpdateBatch(detailsItems);//批量修改
+			System.out.println("开始回写数量_____________________________");
 			updateQuantitys(null,itemIds);
 			bool=true;
 		}catch (Exception e){
@@ -1056,12 +1093,30 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 			String ids="";
 			String name="";
 			int num=5;
+			List<String> detailIds=new ArrayList<>();//出运明细子表id
+			List<String> orderIds=new ArrayList<>();//订单子表id
+			for (SyPackingListFabricItem item :main.getSyPackingListFabricItem()){
+				detailIds.add(item.getSyShippingDetailsItemId());
+			}
+			List<SyShippingDetailsItem> detailsItems=syShippingDetailsItemMapper.selectBatchIds(detailIds);//获取物料分类和其他数据
+			Map<String,SyShippingDetailsItem> detailsItemMap=new HashMap<>();
+			for (SyShippingDetailsItem detailsItem : detailsItems){
+				detailsItemMap.put(detailsItem.getId(),detailsItem);
+				orderIds.add(detailsItem.getSyOrderDataItemId());
+			}
+			List<SyOrderDataItem> orderDataItemss=syOrderDataItemMapper.selectBatchIds(orderIds);
+			Map<String,SyOrderDataItem> orderDataItemMap=new HashMap<>();
+			for (SyOrderDataItem orderDataItem : orderDataItemss){
+				orderDataItemMap.put(orderDataItem.getId(),orderDataItem);
+			}
+
 			for (SyPackingListFabricItem item :main.getSyPackingListFabricItem()){
 				setNetWeight(item);//净重保留两位小数
-				SyShippingDetailsItem syShippingDetailsItem=syShippingDetailsItemMapper.selectById(item.getSyShippingDetailsItemId());//获取物料分类和其他数据
 				//物料分类
+				SyShippingDetailsItem syShippingDetailsItem=detailsItemMap.get(item.getSyShippingDetailsItemId());
 				if(syShippingDetailsItem!=null){//不为null
-					SyOrderDataItem dataItem=syOrderDataItemMapper.selectById(syShippingDetailsItem.getSyOrderDataItemId());
+//					SyOrderDataItem dataItem=syOrderDataItemMapper.selectById(syShippingDetailsItem.getSyOrderDataItemId());
+					SyOrderDataItem dataItem=orderDataItemMap.get(syShippingDetailsItem.getSyOrderDataItemId());
 					if(dataItem!=null&&dataItem.getMasterMetering().equals("KG")){
 						if(dataItem.getMasterMetering().equals("KG")){
 							total3=total3.add(item.getNetWeight());
@@ -1069,7 +1124,7 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 							total3=total3.add(item.getActualDeclaredQuantity());
 						}
 					}else{
-						//System.out.println("净重\t"+item.getNetWeight());
+//						System.out.println("净重\t"+item.getNetWeight());
 //						throw new JeecgBootException("第"+item.getNum()+"行找不到订单数据,获取不到单位");
 					}
 					item.setInventoryCcode(syShippingDetailsItem.getInventoryCcode());//物料分类
@@ -1619,7 +1674,7 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 				mapItem4.put("CDEFINE33",item.getDeclarationName());//报关品名
 				mapItem6.put("CDEFINE31",item.getDeclarationName());//货物名称
 
-				Order orderIrowno=new Order();
+				Order  orderIrowno=new Order();
 				//System.out.println("新的逻辑id\t"+orderDataItem.get("iSOsID"));
 				//if(item.getSyOrderDataItemId()!=null){//销售发货单 ---查询销售订单子表数据  顺序---5
 				String orderDataId="";
@@ -2236,6 +2291,9 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 		String massage="";
 		int num=0;
 		int num1=0;
+		List<String> itemIds=new ArrayList<>();//出运明细子表id
+		List<SyPackingListFabric> fabrics=new ArrayList<>();//面辅料主表集合
+		List<SyPackingListFabricItem> fabricItems=new ArrayList<>();//面辅料子表集合
 		DxpDataPlan dxpDataPlan=dxpDataPlanMapper.selectById("0012");
 		SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 		Date datetome = sf.parse(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS").format(System.currentTimeMillis()));
@@ -2247,7 +2305,7 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 		}else{
 			long time=(datetome.getTime()-datetome2.getTime())/1000;
 			//System.out.println("time\t"+time);
-			if(time>240){
+			if(time>1200){
 				dxpDataPlan.setItemUrl("f");
 				dxpDataPlanMapper.updateById(dxpDataPlan);
 			}
@@ -2319,6 +2377,7 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 			if (listMain.size() == 0) {
 				continue;//退出本次循环
 			}
+//			System.out.println("销售出库主表SQL\t"+sql);
 			List<JSONObject> jsonObjects = JsonChangeUtils.toJSONObject(listMain);
 			////System.out.println("主表长度\t"+jsonObjects.size());
 			for (JSONObject json : jsonObjects) {//主表
@@ -2400,6 +2459,7 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 					} else {
 						list = senYuDataSourceTwo.queryForList(sql2);//102
 					}
+//					System.out.println("销售出库子表SQL2\t"+sql2);
 					List<JSONObject> jianSon = JsonChangeUtils.toJSONObject(list);
 					List<SyPackingListFabricItem> items=new ArrayList<>();
 					////System.out.println("获取子表长度\t"+jianSon.size());
@@ -2548,18 +2608,13 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 					}
 					if(items.size()>0){
 						sy.setSyPackingListFabricItem(items);
-						List<String> itemIds=new ArrayList<>();
 						for (SyPackingListFabricItem item : sy.getSyPackingListFabricItem()){
-							SyPackingListFabricItem item1=syPackingListFabricItemMapper.selectById(item.getId());
-							if(item1==null){
-								syPackingListFabricItemMapper.insert(item);//插入新数据
-							}
+							syPackingListFabricItemMapper.insert(item);//插入新数据
 							itemIds.add(item.getSyShippingDetailsItemId());
+							fabricItems.add(item);
 						}
-						SyPackingListFabric syPackingListFabric=syPackingListFabricMapper.selectById(sy.getId());
-						if(syPackingListFabric==null){
-							syPackingListFabricMapper.insert(sy);//添加数据
-						}
+						syPackingListFabricMapper.insert(sy);//添加数据
+						fabrics.add(sy);
 						updateQuantitys(null,itemIds);
 						num++;
 					}else{
@@ -2574,7 +2629,7 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 		}
 		long endTime2 = System.currentTimeMillis();
 		//System.out.println("面辅料自动拉取耗费时间:" + (endTime2 - startTime) + "ms");
-		log.warn("面辅料自动拉取耗费时间:" + (endTime2 - startTime) + "ms");
+		log.debug("面辅料自动拉取耗费时间:" + (endTime2 - startTime) + "ms");
 		dxpDataPlan.setItemUrl("f");
 		dxpDataPlanMapper.updateById(dxpDataPlan);
 		return "成功添加了"+num+"条数据!";

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

@@ -551,7 +551,7 @@ public class SyPackingListTailoringController implements Job {
 			result.setSuccess(false);
 			return result;
 		}
-		SyPackingListTailoring syPackingListTailoring = syPackingListTailoringService.queryId(id);
+		SyPackingListTailoring syPackingListTailoring = syPackingListTailoringService.queryId2(id);
 		if(syPackingListTailoring==null){
 			result.setSuccess(false);
 			result.setMessage("未找到该id");
@@ -1258,7 +1258,6 @@ public class SyPackingListTailoringController implements Job {
 					 JSONObject jsonObject = json.getJSONObject(i);
 					 //获取json名
 					 String spapl = jsonObject.get("splt").toString();
-					 //System.out.println("spapl\t"+spapl);
 					 //转list
 					 List<SyPackingListTailoring> syPackingListTailorings=JSONObject.parseArray(spapl,SyPackingListTailoring.class);
 					//生成数据
@@ -1468,6 +1467,21 @@ public class SyPackingListTailoringController implements Job {
 					 if(venCode!=null){
 						 map.put("vencode",venCode);//委外采购账套号
 					 }*/
+					 List<DictModel> dictModels=sysDictService.queryDictItemsByCode("Related_units");
+					 Map<String,List<String>> maps=new HashMap();
+					 for (DictModel model : dictModels){
+						 String account= model.getValue().split("-")[0];
+						 String ccuscode= model.getValue().split("-")[1];
+						 if (maps.containsKey(account)){
+							 List<String> customers=maps.get(account);
+							 customers.add(ccuscode);
+						 }else{
+							 List<String> customers=new ArrayList<>();
+							 customers.add(ccuscode);
+							 maps.put(account,customers);
+						 }
+					 }
+					 map.put("maps",maps);
 					 map.put("customerCode","one");//客户编码
 					 map.put("CVENCODE","one");//供应商编码
 					 map.put("orderNumber","one");//销售订单号2
@@ -2112,6 +2126,23 @@ public class SyPackingListTailoringController implements Job {
 				 Map<String,Object> maps=new HashMap<>();
 				 maps.put("account",key);//账套号
 				 maps.put("account1",key);//账套号
+
+				 List<DictModel> dictModels=sysDictService.queryDictItemsByCode("Related_units");
+				 Map<String,List<String>> mapd=new HashMap();
+				 for (DictModel model : dictModels){
+					 String account= model.getValue().split("-")[0];
+					 String ccuscode= model.getValue().split("-")[1];
+					 if (mapd.containsKey(account)){
+						 List<String> customers=mapd.get(account);
+						 customers.add(ccuscode);
+					 }else{
+						 List<String> customers=new ArrayList<>();
+						 customers.add(ccuscode);
+						 mapd.put(account,customers);
+					 }
+				 }
+				 maps.put("maps",mapd);
+
 				 for (int i=0;i<3;i++){
 			 	 /*if(maps.get("account").equals("103")){
 					message+=syPackingListTailoringService.pushInvoice3(listTailorings, maps);

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

@@ -224,6 +224,11 @@ public class SyPackingListTailoringItem implements Serializable {
 	@Excel(name = "分组id", width = 15)
 	@ApiModelProperty(value = "分组id")
 	private String groupId;
+	/**预装箱单分组id*/
+	@Excel(name = "预装箱单分组id", width = 15)
+	@ApiModelProperty(value = "预装箱单分组id")
+	@TableField(exist = false)
+	private String groupItemId;
 	/**二维表格*/
 	@TableField(exist = false)
 	@ApiModelProperty(value = "二维表格")

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

@@ -177,7 +177,7 @@
 		inventory_name,
 		spur_or_sub_order,
 		factory_unit_price,/*成衣工厂*/
-		order_Number/*销售订单号号*/
+		order_Number,/*销售订单号号*/
 		master_Metering,/*计量单位*/
 		inventory_Code,/*存货编码*/
 		inventory_Ccode,/*区分成衣跟面辅料*/
@@ -191,6 +191,8 @@
 		remarks,/*备注*/
 		total_Pack,
 		pack_Box,
+		(select group_id from sy_pre_assembled_packing_list_item
+		where id= max(sy_Pre_Assembled_Packing_List_Item_Id)) groupItemId,
 		packs,
 		group_id
 	FROM  sy_packing_list_tailoring_item
@@ -265,6 +267,7 @@
 			LEFT JOIN sizetable ON sy_packing_list_tailoring_item.`size`=sizetable.`size`
 		WHERE group_id=#{group_id} AND
 		sy_packing_list_tailoring_id=#{id}
+		and sy_packing_list_tailoring_item.del_flag=0
 		ORDER BY num
 	</select>
 
@@ -273,19 +276,22 @@
 		 FROM sy_packing_list_tailoring_item
 		 LEFT JOIN sizetable ON sy_packing_list_tailoring_item.`size`=sizetable.`size`
 		 WHERE sy_packing_list_tailoring_id =#{value}
+		 and sy_packing_list_tailoring_item.del_flag=0
 		 ORDER BY num
 	</select>
 
 	<select id="sizeAlls" resultType="org.jeecg.modules.spapl.entity.SizeTable">
 		SELECT sy_packing_list_tailoring_item.size,alias,total quantity,box_Number,total/box_Number proportion,
-		id itemId,num,group_id,sy_packing_list_tailoring_id id
+		id itemId,num,group_id,sy_packing_list_tailoring_id id,(select group_id from sy_pre_assembled_packing_list_item
+		where id=sy_Pre_Assembled_Packing_List_Item_Id and sy_Pre_Assembled_Packing_List_Item_Id is not null ) groupItemId
 		FROM sy_packing_list_tailoring_item
 		LEFT JOIN sizetable ON sy_packing_list_tailoring_item.`size`=sizetable.`size`
 		 WHERE sy_packing_list_tailoring_id in
 		<foreach collection="list" item="value" index="index" open="(" separator="," close=")">
 			#{value}
 		</foreach>
-		 ORDER BY num
+		 and sy_packing_list_tailoring_item.del_flag=0
+		ORDER BY num
 	</select>
 
 	<select id="getList" parameterType="java.lang.String" resultType="org.jeecg.modules.splt.entity.SyPackingListTailoringItem">

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

@@ -75,6 +75,13 @@ public interface ISyPackingListTailoringService extends IService<SyPackingListTa
 	 */
 	public SyPackingListTailoring queryId(String id);
 
+	/**
+	 * 根据装箱单主表id获取数据
+	 * @param id
+	 * @return
+	 */
+	public SyPackingListTailoring queryId2(String id);
+
 	/**
 	 * 将数据汇总
 	 * @param page

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

@@ -98,6 +98,9 @@ public class SyPackingListTailoringServiceImpl extends ServiceImpl<SyPackingList
 			for (SizeTable size : sizes){
 				if(size.getProportion()==null){
 					size.setProportion(0);
+					item.setDelFlag("1");
+				}else{
+					item.setDelFlag("0");
 				}
 				SyPackingListTailoringItem item1=item;
 				item1.setSize(size.getSize());//获取尺码信息
@@ -126,6 +129,29 @@ public class SyPackingListTailoringServiceImpl extends ServiceImpl<SyPackingList
 					BeanUtils.copyProperties(item1,item3);
 					items3.add(item3);
 				}
+				if (item.getIsAdd()==0&&size.getItemId()==null&&size.getProportion()>0){
+					System.out.println("size尺码\t"+size);
+					System.out.println("getProportion\t"+size.getProportion()+"\tboxNumber\t"+boxNumber);
+					QueryWrapper queryWrapper=new QueryWrapper();
+					queryWrapper.eq("sy_Pre_Assembled_Packing_List_Id",item.getSyPreAssembledPackingListId());
+					queryWrapper.eq("size",size.getSize());
+					queryWrapper.eq("del_flag","0");
+					queryWrapper.eq("group_id",item.getGroupItemId());
+					SyPreAssembledPackingListItem splt=syPreAssembledPackingListItemMapper.selectOne(queryWrapper);
+					System.out.println("splt\t"+splt);
+//					//获取预装箱单子表id
+					if (splt!=null){
+						item1.setSyPreAssembledPackingListItemId(splt.getId());
+					}else{
+						item1.setMemo("无对应预装箱单");
+						item1.setSyPreAssembledPackingListItemId(null);
+					}
+					item1.setSyPackingListTailoringId(pid);
+					item1.setId(oConvertUtils.id());//获取到随机id
+					//SyPreAssembledPackingListItem syPreAssembledPackingListItem=syPreAssembledPackingListItemMapper.selectById(item1.getSyPreAssembledPackingListItemId());
+					item1.setOmpoIdItem(item1.getOmpoIdItem());
+					syPackingListTailoringItemMapper.insert(item1);
+				}
 			}
 		}
 		for (String key : mapBools.keySet()){
@@ -628,6 +654,65 @@ public class SyPackingListTailoringServiceImpl extends ServiceImpl<SyPackingList
 		return syPackingListTailoring;
 	}
 
+	/**
+	 * 根据装箱单id获取数据
+	 * @param id
+	 * @return
+	 */
+	@Override
+	public SyPackingListTailoring queryId2(String id) {
+		SyPackingListTailoring syPackingListTailoring=syPackingListTailoringMapper.getMainId(id);
+		List<SyPackingListTailoringItem> items=syPackingListTailoringItemMapper.queryId(id);
+		List<SizeTable> size=syPackingListTailoringItemMapper.sizes(syPackingListTailoring.getId());
+		List<SizeTable> sizes=syPackingListTailoringItemMapper.sizeAlls(syPackingListTailoring.getId());
+		Map<String,List<SizeTable>> mapItems=new HashMap<>();
+		for (SizeTable sizeTable : sizes){
+			if(mapItems.containsKey(sizeTable.getGroupId())){
+				mapItems.get(sizeTable.getGroupId()).add(sizeTable);
+			}else{
+				List<SizeTable> sizeTables=new ArrayList<>();
+				sizeTables.add(sizeTable);
+				mapItems.put(sizeTable.getGroupId(),sizeTables);
+			}
+		}
+
+		for (String keyset : mapItems.keySet()){
+			List<SizeTable> sizeTables=mapItems.get(keyset);
+			for (SizeTable sizeTable1 : size){
+				boolean bool=true;
+				for (SizeTable sizeTable2 : sizeTables){
+					if (sizeTable2.getSize().equals(sizeTable1.getSize())){
+						bool=false;
+					}
+				}
+				if (bool==true){
+
+					SizeTable sizeTable2=sizeTables.get(0);
+					SizeTable sizeTable3=new SizeTable();
+
+					sizeTable3.setNum(sizeTable1.getNum());
+					sizeTable3.setSize(sizeTable1.getSize());
+					sizeTable3.setAlias(sizeTable1.getAlias());
+					sizeTable3.setProportion(sizeTable1.getProportion());
+					sizeTable3.setItemId(sizeTable1.getItemId());
+					sizeTable3.setQuantity(sizeTable1.getQuantity());
+
+					sizeTable3.setGroupId(sizeTable2.getGroupId());
+					sizeTable3.setGroupItemId(sizeTable2.getGroupItemId());
+
+					sizeTables.add(sizeTable3);
+				}
+			}
+		}
+		syPackingListTailoring.setSizeTables(size);//获取id
+		for (SyPackingListTailoringItem item : items){
+			//item.setSizeTables(syPackingListTailoringItemMapper.size(item.getGroupId(),item.getSyPackingListTailoringId()));
+			item.setSizeTables(mapItems.get(item.getGroupId()));
+//			System.out.println("groupItemId\t"+item.getGroupItemId());
+		}
+		syPackingListTailoring.setSyPackingListTailoringItemList(items);
+		return syPackingListTailoring;
+	}
 	@Override
 	public IPage<SyPackingListTailoringVo> selectList(IPage<SyPackingListTailoringVo> page, QueryWrapper<SyPackingListTailoringVo> queryWrapper) {
 
@@ -1523,17 +1608,10 @@ public class SyPackingListTailoringServiceImpl extends ServiceImpl<SyPackingList
 					}else{
 
 					}
-					Map<String,Object> ivouchrownos=new HashMap<>();
 					//String params1="UFDATA_103_2021";//当前数据库
 					String params3= (String) map.get("cOrderCode");//销售订单号
 					String params5=mapSort.get(item.getId());//当前数据库行号
-//					if (mapt.get("account").equals("102")&&mapt.get("account1").equals("102")){
-//						ivouchrownos =syPackingListTailoringMapper.getAccount2(params3,params5);
-//					}else{
-						ivouchrownos =syPackingListTailoringMapper.getIvouchrowno(params1,params2,params3,params4,params5);
-//					}
-					//orderIrowno.setIrowno(ivouchrowno);//获取行号
-					//System.out.println("销售订单子表的行号\t"+ivouchrownos);
+					Map<String,Object> ivouchrownos =syPackingListTailoringMapper.getIvouchrowno(params1,params2,params3,params4,params5);
 					if(ivouchrownos==null||ivouchrownos.get("iorderdid")==null){
 						return "推送失败:未找到上游订单数据";
 					}
@@ -2074,28 +2152,20 @@ public class SyPackingListTailoringServiceImpl extends ServiceImpl<SyPackingList
 	 * @return
 	 */
 	public String pushInvoices(List<SyPackingListTailoring> listTailorings,Map<String,Object> maps) {
-		long startTime = System.currentTimeMillis();
-		String message="";
 		List<String> codes=getList(listTailorings,maps.get("account").toString());//获取出库单号
-		//System.out.println(maps.get("account")+"账套成衣查看入库单号\t"+codes);
 		if(codes.size()==0){
 			return "无可推送数据!";
 		}
 		String account=maps.get("account").toString();
-
-		//Map<String,List<String>> customers=getSuppliers(codes,listTailorings);//key:供应商编码,value:出库单id
 		Map<String,List<String>> customers=getSuppliers(listTailorings);//key:供应商编码,value:出库单单据号
-		//System.out.println(account+"采购customers\t"+customers);
 		if(account.equals("102")){
 			customers=getSuppliers2(codes,listTailorings);//key:供应商编码,value:出库单id
-//			customers=getSuppliers2(listTailorings);//key:供应商编码,value:出库单id
 		}
 		Map<String,List<SyPackingListTailoringItem>> listTailoringItemMaps=getListTailoringItemMaps(customers,listTailorings);//key:供应商编码,value:对应子表
 		Map<String,List<SyPackingListTailoring>> listTailoringMaps=getListTailoringMaps(customers,listTailorings);//key:供应商编码,value:对应主表
 		Map<String,List<SyPackingListTailoring>> codeMaps=new HashMap<>();//key:传入销售发-票单id,value:主表数据
 		JSONArray jsonArrays1=new JSONArray();
 		String code=redisUtil.get("pushsno002").toString();//发-票号
-
 		for (String customer : customers.keySet()){
 			SyPackingListTailoring syPackingListTailoring=listTailoringMaps.get(customer).get(0);
 			Map<String, Object> orderData=null;
@@ -2114,28 +2184,14 @@ public class SyPackingListTailoringServiceImpl extends ServiceImpl<SyPackingList
 					throw new JeecgBootException(account+"查询不到对应的采购订单");
 				}
 			}
-			//System.out.println("orderData\t"+orderData);
-
 			String orderNumber=listTailorings.get(0).getShippingOrderNumber().substring(0,syPackingListTailoring.getShippingOrderNumber().indexOf("-"));
-			//List<SyPackingListFabricItem> listFabricItems=syPackingListFabric.getSyPackingListFabricItem();//需要进行分组
 			List<SyPackingListTailoringItem> listTailoringItems=listTailoringItemMaps.get(customer);
-			////System.out.println("codes.size\t"+codes.size());
-			//System.out.println("codes\t"+codes);
 			List<Map<String,Object>> invoices=getInvoices1(customers.get(customer));
 			JSONObject  jsonObject1=new JSONObject();
 			code=org.jeecg.modules.system.util.oConvertUtils.addOne(code);
 			code=orderNumber+code.substring(code.indexOf("0"));
 			redisUtil.set("pushsno002", code);//采购委外发-票单
 			codeMaps.put(code,listTailoringMaps.get(customer));
-//			String istc=syPackingListTailoring.getIsTc();
-//			if (istc!=null&&istc.equals("1")){
-//				if(syPackingListTailoring.getMemo()!=null){
-//					syPackingListTailoring.setMemo(syPackingListTailoring.getMemo()+"TC证书");
-//				}else{
-//					syPackingListTailoring.setMemo("TC证书");
-//				}
-//			}
-			//jsonObject1.put("CMEMO",syPackingListTailoring.getMemo());//备注
 			jsonObject1.put("CVOUCHCODE",code);//发-票号
 			jsonObject1.put("CMAKER","进出口平台管理员");//制单人
 			jsonObject1.put("CHANDLER","进出口平台管理员");//审核人
@@ -2143,7 +2199,6 @@ public class SyPackingListTailoringServiceImpl extends ServiceImpl<SyPackingList
 			jsonObject1.put("CTYPE","专用");//发-票类型
 
 			jsonObject1.put("CGLTYPE","入库单");//上游单据
-			//System.out.println("syPackingListTailoring.getLatestDateOfShipment2()\t"+syPackingListTailoring.getLatestDateOfShipment2());
 			jsonObject1.put("DDATE",syPackingListTailoring.getTheFinalShippingDate().substring(0,10));//装运期限
 			jsonObject1.put("CDEFINE4",syPackingListTailoring.getTheFinalShippingDate().substring(0,10));//最终船期
 			jsonObject1.put("CDEFINE6",syPackingListTailoring.getTheFinalShippingDate2().substring(0,10));//合同日期
@@ -2191,11 +2246,7 @@ public class SyPackingListTailoringServiceImpl extends ServiceImpl<SyPackingList
 				jsonObject.put("POAUTOIDCOL","Autoid");//对应类型
 				String istc2=item.getIsTc();
 				if (istc2!=null&&istc2.equals("1")){
-//					if(item.getMemo()!=null){
-//						item.setMemo(item.getMemo()+"TC证书");
-//					}else{
-						item.setMemo("TC证书");
-//					}
+					item.setMemo("TC证书");
 				}
 				jsonObject.put("CBMEMO",item.getMemo());//备注
 				for (Map<String,Object> map : invoices){
@@ -2229,33 +2280,17 @@ public class SyPackingListTailoringServiceImpl extends ServiceImpl<SyPackingList
 				jsonObject.put("CDEFINE33",item.getDeclarationName());//存货名称
 				jsonArrays.add(jsonObject);
 			}
-//			//System.out.println("dzMoney\t"+dzMoney+"\tu8Money\t"+u8Money);
 			dzMoney=dzMoney.setScale(2, RoundingMode.HALF_UP);
-//			//System.out.println("dzMoney\t"+dzMoney+"\tu8Money\t"+u8Money);
-//			//System.out.println("dzMoney.compareTo(u8Money)t"+dzMoney.compareTo(u8Money));
 			if(dzMoney.compareTo(u8Money)!=0){
 				BigDecimal dividePrice =dzMoney.subtract(u8Money);
-//				//System.out.println("IORIMONEY\t"+jsonArrays.getJSONObject(jsonArrays.size()-1).get("IORIMONEY").toString());
 				BigDecimal ioriMoney=new BigDecimal(jsonArrays.getJSONObject(jsonArrays.size()-1).get("IORIMONEY").toString());
 				jsonArrays.getJSONObject(jsonArrays.size()-1).put("IORIMONEY",ioriMoney.add(dividePrice));
-//				//System.out.println("IORIMONEY\t"+jsonArrays.getJSONObject(jsonArrays.size()-1).get("IORIMONEY").toString());
 			}
 //			jsonObject.put("IORIMONEY",item.getUnitPrice());//金额
 			jsonObject1.put("DETAILList",jsonArrays);
 			jsonArrays1.add(jsonObject1);
-			//Map<String,List<String>> maps=new HashMap<>();//key:客户编码-字符,value:主表id-数组 用于区分维度完成分组条件
-			//System.out.println("jsonObject\n"+jsonObject1);
-			////System.out.println("jsonArrays.size\t"+jsonArrays.size());
-			////System.out.println("listFabrics.size\t"+listFabrics.size());
-			////System.out.println("listFabricItems.size\t"+listFabricItems.size());
-			long endTime = System.currentTimeMillis();
-			//System.out.println("互相插入数据时用的时间:" + (endTime - startTime) + "ms");
-		}
-		//System.out.println("jsonArrays1\n"+jsonArrays1);
+		}
 		text(jsonArrays1,"测试合并推送成衣采购发票");
-//		if(true){
-//			return "推送成功";
-//		}
 		JSONArray resturnJsonArrays = InterfaceConnUtils.doPost(jsonArrays1,"purinvoice_import");//采购发-票单
 		Map<String,String> codeMaps2 =new HashMap<>();
 		if(maps.get("account1").equals("101")||account.equals("103")){//账套只有101或者账套是103的为委外发-票
@@ -2265,24 +2300,20 @@ public class SyPackingListTailoringServiceImpl extends ServiceImpl<SyPackingList
 		}
 		for (String code1 : codeMaps.keySet()){
 			List<SyPackingListTailoring> listTailoringList=codeMaps.get(code1);
-			//List<String> ids=new ArrayList<>();
 			for (SyPackingListTailoring tailoring : listTailoringList){
 				tailoring.setRdrecord32Code(null);
-				//ids.add(fabric.getId());
 				if (codeMaps2.get(code1).indexOf("失败")>-1){
 					if(tailoring.getSaleInvoiceError()==null){
 						tailoring.setSaleInvoiceError(codeMaps2.get(code1));
 					}else{
 						tailoring.setSaleInvoiceError(tailoring.getSaleInvoiceError()+";"+codeMaps2.get(code1));
 					}
-					//tailoring.setSaleInvoiceError(codeMaps2.get(code1));
 				}else{
 					if(tailoring.getSaleInvoiceCode()==null){
 						tailoring.setSaleInvoiceCode(codeMaps2.get(code1));
 					}else{
 						tailoring.setSaleInvoiceCode(tailoring.getSaleInvoiceCode()+";"+codeMaps2.get(code1));
 					}
-					//tailoring.setSaleInvoiceError("");
 				}
 			}
 		}
@@ -2305,48 +2336,32 @@ public class SyPackingListTailoringServiceImpl extends ServiceImpl<SyPackingList
 	 * @return
 	 */
 	public String pushInvoices2(List<SyPackingListTailoring> listTailorings,Map<String,Object> maps) {
-		long startTime = System.currentTimeMillis();
-		String message="";
 		List<String> codes=getList2(listTailorings,maps.get("account").toString());//获取出库单号
-		//System.out.println(maps.get("account")+"账套成衣查看出库单号\t"+codes);
 		if(codes.size()==0){
 			return "无可推送数据!";
 		}
 		String account=maps.get("account").toString();
 		Map<String,List<String>> customers=getCustomers(codes,listTailorings);//key:供应商编码,value:出库单id
-		//System.out.println(account+"销售customers\t"+customers);
 		Map<String,List<SyPackingListTailoringItem>> listTailoringItemMaps=getListTailoringItemMaps(customers,listTailorings);//key:供应商编码,value:子表数据
 		Map<String,List<SyPackingListTailoring>> listTailoringMaps=getListTailoringMaps(customers,listTailorings);//key:供应商编码,value:主表数据
 		Map<String,List<SyPackingListTailoring>> codeMaps=new HashMap<>();//key:传入销售发-票单id,value:主表数据
 		JSONArray jsonArrays1=new JSONArray();
-		String code=redisUtil.get("pushsno005").toString();//发-票号
+		String code=redisUtil.get("pushsno005").toString();//发票号
 		for (String customer : customers.keySet()){
 			SyPackingListTailoring syPackingListTailoring=listTailoringMaps.get(customer).get(0);
 			List<SyPackingListTailoringItem> listFabricItems=listTailoringItemMaps.get(customer);
-			//System.out.println("codes\t"+codes);
 			List<Map<String,Object>> invoices=getInvoices(customers.get(customer));
 			JSONObject  jsonObject1=new JSONObject();
-
-//			String istc=syPackingListTailoring.getIsTc();
-//			if (istc!=null&&istc.equals("1")){
-//				if(syPackingListTailoring.getMemo()!=null){
-//					syPackingListTailoring.setMemo(syPackingListTailoring.getMemo()+"TC证书");
-//				}else{
-//					syPackingListTailoring.setMemo("TC证书");
-//				}
-//			}
-			//jsonObject1.put("CMEMO",syPackingListTailoring.getMemo());//备注
-
 			code=org.jeecg.modules.system.util.oConvertUtils.addOne(code);
 			String orderNumber=listTailorings.get(0).getShippingOrderNumber().substring(0,syPackingListTailoring.getShippingOrderNumber().indexOf("-"));
 			code=orderNumber+code.substring(code.indexOf("0"));
 			redisUtil.set("pushsno005", code);//采购委外入库单
 			codeMaps.put(code,listTailoringMaps.get(customer));
-			jsonObject1.put("CVOUCHCODE",code);//发-票号
+			jsonObject1.put("CVOUCHCODE",code);//发票号
 			jsonObject1.put("CMAKER","进出口平台管理员");//制单人
 			jsonObject1.put("CVERIFIER","进出口平台管理员");//审核人
 			jsonObject1.put("CACCID",account);//账套号
-			jsonObject1.put("CTYPE","普通");//发-票类型
+			jsonObject1.put("CTYPE","普通");//发票类型
 			jsonObject1.put("CGLTYPE","销售出库单");//上游单据
 			jsonObject1.put("CDEFINE13",syPackingListTailoring.getShippingOrderNumber().replace("&","(-)"));// 客户名称
 			jsonObject1.put("CDEFINE11",syPackingListTailoring.getEndCustomer().replace("&","(-)"));//最终客户
@@ -2357,19 +2372,23 @@ public class SyPackingListTailoringServiceImpl extends ServiceImpl<SyPackingList
 				throw new JeecgBootException(account+"查询不到对应的销售订单");
 			}
 			//System.out.println("成衣销售order\t"+order);
-			if(order.get("cCusCode").equals("T020001")&&!account.equals("101")){
-				//maps.put("account","101");//账套号
-			}else if(order.get("cCusCode").equals("0001")&&!account.equals("102")){
+//			if(order.get("cCusCode").equals("T020001")&&!account.equals("101")){
+//				//maps.put("account","101");//账套号
+//			}else if(order.get("cCusCode").equals("0001")&&!account.equals("102")){
+//				jsonObject1.put("CTYPE","专用");//发-票类型(普通,专用)
+//				//maps.put("account","102");//账套号
+//			}else{
+//				//maps.put("account","104");//账套号
+//			}
+			HashMap map1=(HashMap) maps.get("maps");
+			List<String> account2=(ArrayList)map1.get("102");
+			if(account2.contains(order.get("cCusCode"))&&!account.equals("102")){
 				jsonObject1.put("CTYPE","专用");//发-票类型(普通,专用)
-				//maps.put("account","102");//账套号
-			}else{
-				//maps.put("account","104");//账套号
 			}
 			jsonObject1.put("DDATE",syPackingListTailoring.getTheFinalShippingDate().substring(0,10));//日期
 			jsonObject1.put("CDEFINE4",syPackingListTailoring.getTheFinalShippingDate());//最终船期
 			jsonObject1.put("CDEFINE6",syPackingListTailoring.getTheFinalShippingDate2());//合同日期
 			jsonObject1.put("CDEFINE10",syPackingListTailoring.getShippingOrderNumber().replace("&","(-)"));//托书号
-			//System.out.println("syPackingListFabric.getSupplierCode()\t"+syPackingListTailoring.getSupplierCode());
 			if(syPackingListTailoring.getSupplierCode()!=null){
 				String	venName=syPackingListTailoringMapper.getCvenName2(syPackingListTailoring.getSupplier());
 				//jsonObject1.put("CDEFINE12",venName);//供应商全称
@@ -2405,32 +2424,17 @@ public class SyPackingListTailoringServiceImpl extends ServiceImpl<SyPackingList
 			List<Object> autoIds=new ArrayList<>();
 			//String iTaxRate=syPackingListTailoringItemMapper.getItaxRate(syPackingListTailoring.getRdrecord32Code());
 			for (SyPackingListTailoringItem item : listFabricItems){
-//				//System.out.println("total\t"+item.getTotal());
-//				//System.out.println("size\t"+item.getSize());
-//				//System.out.println("inventoryCode\t"+item.getInventoryCode());
-
-
 				JSONObject  jsonObject=new JSONObject();
 				jsonObject.put("IQUANTITY",item.getTotal());//净重
 				jsonObject.put("size",item.getSize());
 				jsonObject.put("CINVCODE",item.getInventoryCode());//存货编码
 				jsonObject.put("DISAUTOIDCOL","AUTOID");//对应类型
-//				//System.out.println("IQUANTITY\t"+jsonObject.get("IQUANTITY"));
-//				//System.out.println("cFree2\t"+jsonObject.get("cFree2"));
 				String istc2=item.getIsTc();
 				if (istc2!=null&&istc2.equals("1")){
-//					if(item.getMemo()!=null){
-//						item.setMemo(item.getMemo()+"TC证书");
-//					}else{
-						item.setMemo("TC证书");
-					//}
+					item.setMemo("TC证书");
 				}
 				jsonObject.put("CBMEMO",item.getMemo());//备注
 				for (Map<String,Object> map : invoices){
-
-//					//System.out.println("map.get(\"iQuantity\").toString()\t"+map.get("iQuantity").toString());
-//					//System.out.println("map.get(\"cInvCode\")\t"+map.get("cInvCode"));
-//					//System.out.println("map.get(\"AutoID\")\t"+map.get("AutoID"));
 					if(Double.parseDouble(map.get("iQuantity").toString())==Double.parseDouble(jsonObject.get("IQUANTITY").toString())&&
 							map.get("cInvCode").toString().equalsIgnoreCase(item.getInventoryCode()) &&map.get("cFree2").equals(item.getSize())
 							&&!autoIds.contains(map.get("AutoID"))){
@@ -2452,20 +2456,13 @@ public class SyPackingListTailoringServiceImpl extends ServiceImpl<SyPackingList
 				jsonObject.put("CDEFINE23",item.getDeclarationUnit());//报关单位
 				jsonObject.put("CDEFINE31",item.getDeclarationName());//存货名称
 				jsonObject.put("ITAXRATE",order.get("iTaxRate"));//税率
-				//if(iTaxRate!=null){
-				//}
 				jsonObject.put("CWHCODE",syPackingListFabricItemMapper.getVencode(item.getSupplier()));//获取仓库编码
 				jsonArrays.add(jsonObject);
 			}
 			jsonObject1.put("DETAILList",jsonArrays);
 			jsonArrays1.add(jsonObject1);
-			//Map<String,List<String>> maps=new HashMap<>();//key:客户编码-字符,value:主表id-数组 用于区分维度完成分组条件
-//			//System.out.println("jsonObject\n"+jsonArrays.get(0));
-			long endTime = System.currentTimeMillis();
-			//System.out.println("互相插入数据时用的时间:" + (endTime - startTime) + "ms");
 		}
 		text(jsonArrays1,"测试合并推送成衣销售发票");
-		////System.out.println("jsonArrays1\t"+jsonArrays1);
 		JSONArray resturnJsonArrays = InterfaceConnUtils.doPost(jsonArrays1,"saleinvoice_import");//销售发-票单
 		Map<String,String> codeMaps2 = result(resturnJsonArrays,"销售发票",account);
 		for (String code1 : codeMaps.keySet()){
@@ -2487,7 +2484,6 @@ public class SyPackingListTailoringServiceImpl extends ServiceImpl<SyPackingList
 					}else{
 						tailoring.setSaleInvoiceCode(tailoring.getSaleInvoiceCode()+";"+codeMaps2.get(code1));
 					}
-					//	tailoring.setSaleInvoiceError("");
 				}
 			}
 		}

+ 9 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/SysDictItemController.java

@@ -58,7 +58,15 @@ public class SysDictItemController {
 	public Result<IPage<SysDictItem>> queryPageList(SysDictItem sysDictItem,@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
 									  @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,HttpServletRequest req) {
 		Result<IPage<SysDictItem>> result = new Result<IPage<SysDictItem>>();
-		QueryWrapper<SysDictItem> queryWrapper = QueryGenerator.initQueryWrapper(sysDictItem, req.getParameterMap());
+//		QueryWrapper<SysDictItem> queryWrapper = QueryGenerator.initQueryWrapper(sysDictItem, req.getParameterMap());
+		QueryWrapper queryWrapper = new QueryWrapper();
+		queryWrapper.eq("dict_id",sysDictItem.getDictId());
+		if (oConvertUtils.isNotEmpty(sysDictItem.getItemText())){
+			queryWrapper.like("item_text",sysDictItem.getItemText());
+		}
+		if (oConvertUtils.isNotEmpty(sysDictItem.getStatus())){
+			queryWrapper.eq("status",sysDictItem.getStatus());
+		}
 		queryWrapper.orderByAsc("sort_order");
 		Page<SysDictItem> page = new Page<SysDictItem>(pageNo, pageSize);
 		IPage<SysDictItem> pageList = sysDictItemService.page(page, queryWrapper);

+ 4 - 5
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/mapper/xml/SysDictMapper.xml

@@ -43,13 +43,12 @@
 
 	<!-- 通过字典code获取字典数据,可批量查询 -->
 	<select id="queryManyDictByKeys" parameterType="String"  resultType="org.jeecg.common.system.vo.DictModelMany">
-		SELECT
-			dict.dict_code,
+		SELECT dict.dict_code,
 			item.item_text AS "text",
 			item.item_value AS "value"
-		FROM
-			sys_dict_item item
-		INNER JOIN sys_dict dict ON dict.id = item.dict_id
+		FROM sys_dict_item item
+		INNER JOIN sys_dict dict
+		ON dict.id = item.dict_id
 		WHERE dict.dict_code IN (
 			<foreach item="dictCode" collection="dictCodeList" separator=",">
 				#{dictCode}