zengtx 1 рік тому
батько
коміт
6e47b975b7

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

@@ -29,4 +29,17 @@ public interface SyCostAllocationIngredientMapper extends BaseMapper<SyCostAlloc
 	List<SyTransfer> queryTransferByIngredient(@Param("code") String code, @Param("goodName") String goodName);
 	@DS("multi-three")
 	List<SyRemaining> queryRemainingByIngredient(@Param("code") String code, @Param("goodName") String goodName);
+
+	//查询新增分配表辅料数据
+	@DS("multi-one")
+	void deleteTempTable101();
+	@DS("multi-one")
+	void createTempTable101();
+	@DS("multi-one")
+	void insertDataIntoTempTable101_101(@Param("code") String code);
+	@DS("multi-one")
+	void insertDataIntoTempTable101_102(@Param("code") String code);
+	@DS("multi-one")
+	void insertDataIntoTempTable101_103(@Param("code") String code);
+
 }

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

@@ -16,8 +16,135 @@
 			 sy_cost_allocation_id = #{id} 		
 	</select>
 
+	<update id="deleteTempTable101">
+        DROP TABLE ##fenpeiTable;
+	</update>
+
+	<insert id="createTempTable101">
+
+		 CREATE TABLE ##fenpeiTable (
+            ccode varchar(50),
+            cInvCode varchar(50),
+            goodsName varchar(200),
+            dosage decimal(38),
+            usageQuantity decimal(38),
+            supper varchar(50),
+            rmbAmount decimal(38),
+            usdAmount decimal(38),
+            priceExcludingtax decimal(38),
+            cost decimal(38)
+        )
+	</insert>
+
+	<insert id="insertDataIntoTempTable101_101">
+
+		insert into ##fenpeiTable select t3.ccode as ccode,t3.cInvCode,t3.goodsName,max(t3.dosage) as dosage,sum(t3.usageQuantity) as usageQuantity,max(t3.cVenAbbName) as supper,sum(t3.rmbAmount) as rmbAmount,sum(t3.usdAmount) as usdAmount,sum(t3.priceExcludingtax) as priceExcludingtax,sum(t3.iCost) as cost from (
+
+		select t1.ccode as ccode,t1.cInvCode,t1.goodsName,t1.dosage,t1.usageQuantity,t2.cVenAbbName,t2.rmbAmount,t2.usdAmount,t2.priceExcludingtax,t2.iCost from (select ot.cInvCode,od.isosid,om.ccode,oti.cInvName as goodsName,sum(ot.iUnitQuantity) as dosage,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.Vendor v ON om.cVenCode= v.cVenCode
+		join UFDATA_101_2021.dbo.Inventory oti on oti.cInvCode=ot.cInvCode
+		join UFDATA_101_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
+join UFDATA_103_2021.dbo.cost_allocation_accessories_view vif on om.ccode = vif.cCode and ot.cInvCode = vif.cInvCode
+		WHERE om.iVerifyStateNew = 2  and omi.cInvCcode like '19%'
+		and om.cCode LIKE CONCAT(#{code},'%')
+		and (om.cCloser is null or ( (od.iReceivedQTY is not null or od.iReceivedQTY != 0) and (ot.iSendQTY is not null or ot.iSendQTY !=0) )or om.cCloser='asuser')
+		group by om.ccode,ot.cInvCode,od.isosid,om.ccode,oti.cInvName
+		) as t1,
+		(
+		select max(ven.cVenAbbName) as cVenAbbName,
+		bi.cInvCode,pod.iorderdid,sum(bi.iSum) as rmbAmount,sum(bi.iOriSum) as usdAmount
+		,sum(bi.iMoney) as priceExcludingtax,max(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_101_2021.dbo.PurBillVouchs bi  on bi.iPOsID=pod.ID
+		join UFDATA_101_2021.dbo.PurBillVouch bm  on bm.PBVID=bi.PBVID
+		join UFDATA_101_2021.dbo.Vendor ven on bm.cVenCode = ven.cVenCode
+		join UFDATA_101_2021.dbo.Inventory oti on oti.cInvCode=pod.cInvCode
+		where pom.cVenCode != 'T010001' and pom.cVenCode != 'T020001'
+		GROUP BY bi.cInvCode,pod.iorderdid) as t2 where t1.cInvCode=t2.cInvCode and t1.isosid = t2.iorderdid
+		) t3  GROUP BY t3.ccode,t3.cInvCode,t3.goodsName
+
+	</insert>
+
+	<insert id="insertDataIntoTempTable101_102">
+insert into ##fenpeiTable select t3.ccode,t3.cInvCode,t3.goodsName,max(t3.dosage) as dosage,sum(t3.usageQuantity) as usageQuantity,max(t3.cVenAbbName) as supper,sum(t3.rmbAmount) as rmbAmount,sum(t3.usdAmount) as usdAmount,sum(t3.priceExcludingtax) as priceExcludingtax,sum(t3.iCost) as cost from (
+
+		select t1.ccode,t1.cInvCode,t1.goodsName,t1.dosage,t1.usageQuantity,t2.cVenAbbName,t2.rmbAmount,t2.usdAmount,t2.priceExcludingtax,t2.iCost from (select ot.cInvCode,od.isosid,om.ccode,oti.cInvName as goodsName,sum(ot.iUnitQuantity) as dosage,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.Vendor v ON om.cVenCode= v.cVenCode
+		join UFDATA_101_2021.dbo.Inventory oti on oti.cInvCode=ot.cInvCode
+		join UFDATA_101_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
+join UFDATA_103_2021.dbo.cost_allocation_accessories_view vif on om.ccode = vif.cCode and ot.cInvCode = vif.cInvCode
+		WHERE om.iVerifyStateNew = 2  and omi.cInvCcode like '19%'
+		and om.cCode LIKE CONCAT(#{code},'%')
+		and (om.cCloser is null or ( (od.iReceivedQTY is not null or od.iReceivedQTY != 0) and (ot.iSendQTY is not null or ot.iSendQTY !=0) )or om.cCloser='asuser')
+		group by  om.ccode,ot.cInvCode,od.isosid,om.ccode,oti.cInvName
+		) as t1
+		left join (
+		select max(ven.cVenAbbName) as cVenAbbName,
+		bi.cInvCode,pod.iorderdid,sum(bi.iSum) as rmbAmount,sum(bi.iOriSum) as usdAmount
+		,sum(bi.iMoney) as priceExcludingtax,max(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_103_2021.dbo.HY_DZ_K7_SYNERGISMLOGDID hy on pod.id = hy.predid
+
+		join UFDATA_102_2021.dbo.PO_Podetails pd on pd.iorderdid=hy.did
+		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.PurBillVouch bm  on bm.PBVID=bi.PBVID
+		join UFDATA_102_2021.dbo.Vendor ven on bm.cVenCode = ven.cVenCode
+		join UFDATA_102_2021.dbo.Inventory oti on oti.cInvCode=pd.cInvCode
+		where pm.cVenCode != 'T020001' and pom.cpoid LIKE CONCAT(#{code},'%')
+		GROUP BY bi.cInvCode,pod.iorderdid) as t2 on t1.cInvCode=t2.cInvCode and t2.iorderdid=t1.isosid
+		) t3  GROUP BY t3.ccode,t3.cInvCode,t3.goodsName;
+	</insert>
+
+	<insert id="insertDataIntoTempTable101_103">
+insert into ##fenpeiTable select t3.ccode,t3.cInvCode,t3.goodsName,max(t3.dosage) as dosage,sum(t3.usageQuantity) as usageQuantity,max(t3.cVenAbbName) as supper,sum(t3.rmbAmount) as rmbAmount,sum(t3.usdAmount) as usdAmount,sum(t3.priceExcludingtax) as priceExcludingtax,sum(t3.iCost) as cost from (
+
+		select t1.ccode,t1.cInvCode,t1.goodsName,t1.dosage,t1.usageQuantity,t2.cVenAbbName,t2.rmbAmount,t2.usdAmount,t2.priceExcludingtax,t2.iCost from (select  ot.cInvCode,od.isosid,om.ccode,oti.cInvName as goodsName,sum(ot.iUnitQuantity) as dosage,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.Vendor v ON om.cVenCode= v.cVenCode
+		join UFDATA_101_2021.dbo.Inventory oti on oti.cInvCode=ot.cInvCode
+		join UFDATA_101_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
+join UFDATA_103_2021.dbo.cost_allocation_accessories_view vif on om.ccode = vif.cCode and ot.cInvCode = vif.cInvCode
+		WHERE om.iVerifyStateNew = 2  and omi.cInvCcode like '19%'
+		and om.cCode LIKE CONCAT(#{code},'%')
+		and (om.cCloser is null or ( (od.iReceivedQTY is not null or od.iReceivedQTY != 0) and (ot.iSendQTY is not null or ot.iSendQTY !=0) )or om.cCloser='asuser')
+		group by om.ccode,ot.cInvCode,od.isosid,om.ccode,oti.cInvName
+		) as t1,
+		(
+		select max(ven.cVenAbbName) as cVenAbbName,
+		bi.cInvCode,pod.iorderdid,sum(bi.iSum) as rmbAmount,sum(bi.iOriSum) as usdAmount
+		,sum(bi.iMoney) as priceExcludingtax,max(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_103_2021.dbo.HY_DZ_K7_SYNERGISMLOGDID hy on pod.id = hy.predid
+
+		join UFDATA_103_2021.dbo.OM_MODetails pd on pd.isosid=hy.did
+		join UFDATA_103_2021.dbo.OM_MOMain pm on pd.MOID  = pm.MOID
+		left join UFDATA_103_2021.dbo.PurBillVouchs bi  on bi.iPOsID=pd.MODetailsID
+		left join UFDATA_103_2021.dbo.PurBillVouch bm  on bm.PBVID=bi.PBVID
+		join UFDATA_103_2021.dbo.Vendor ven on bm.cVenCode = ven.cVenCode
+		join UFDATA_103_2021.dbo.Inventory oti on oti.cInvCode=pd.cInvCode
+		where pom.cpoid LIKE CONCAT(#{code},'%')
+		GROUP BY bi.cInvCode,pod.iorderdid) as t2 where t1.cInvCode=t2.cInvCode and t2.iorderdid=t1.isosid
+		) t3  GROUP BY t3.ccode,t3.cInvCode,t3.goodsName;
+
+	</insert>
+
 	<select id="queryByCostIngredient1" resultType="org.jeecg.modules.cost.entity.SyCostAllocationIngredient">
-		select tab.*,isnull(tab1.purchaseQuantity,0) as purchaseQuantity,
+	select tab.*,isnull(tab1.purchaseQuantity,0) as purchaseQuantity,
 		case when isnull(tab2.jian,0)-isnull(tab1.purchaseQuantity,0) <![CDATA[<=]]> 0 then 0
 		else isnull(tab2.jian,0)-isnull(tab1.purchaseQuantity,0) end
 		as ingredientsTransferQuantity,
@@ -53,7 +180,7 @@
 
 		AND omi.cInvCcode LIKE '19%'
 		AND om.cCode LIKE CONCAT(#{code},'%')
-and (om.cCloser is null or ( (od.iReceivedQTY is not null or od.iReceivedQTY != 0) and (ot.iSendQTY is not null or ot.iSendQTY !=0) )or om.cCloser='asuser')
+and (om.cCloser is null or ( (od.iReceivedQTY is not null or od.iReceivedQTY != 0) and (ot.iSendQTY is not null or ot.iSendQTY !=0) ))
 		GROUP BY om.ccode,ot.cInvCode,od.isosid,om.ccode,oti.cInvName ) AS t1
 
 		left join (SELECT ven.cVenAbbName AS cVenAbbName,bi.cInvCode,pod.isosid,SUM ( bi.iSum ) AS rmbAmount,SUM ( bi.iOriSum ) AS usdAmount,
@@ -99,7 +226,7 @@ and (om.cCloser is null or ( (od.iReceivedQTY is not null or od.iReceivedQTY !=
 
 		AND omi.cInvCcode LIKE '19%'
 		AND om.cCode LIKE CONCAT(#{code},'%')
-and (om.cCloser is null or ( (od.iReceivedQTY is not null or od.iReceivedQTY != 0) and (ot.iSendQTY is not null or ot.iSendQTY !=0) )or om.cCloser='asuser')
+and (om.cCloser is null or ( (od.iReceivedQTY is not null or od.iReceivedQTY != 0) and (ot.iSendQTY is not null or ot.iSendQTY !=0) ))
 		GROUP BY om.ccode,ot.cInvCode,om.ccode,oti.cInvName ) AS t1
 
 		left join (
@@ -186,108 +313,9 @@ and (om.cCloser is null or ( (od.iReceivedQTY is not null or od.iReceivedQTY !=
 		from
 		(
 
-		select t4.cInvCode,max(t4.goodsName) as goodsName,max(t4.dosage) as dosage,max(t4.usageQuantity) as usageQuantity,STRING_AGG(t4.supper,',') as supper,sum(t4.rmbAmount) as rmbAmount,sum(t4.usdAmount) as usdAmount,sum(t4.priceExcludingtax) as priceExcludingtax,sum(t4.cost) as cost from (
-		select t3.ccode as ccode,t3.cInvCode,t3.goodsName,max(t3.dosage) as dosage,sum(t3.usageQuantity) as usageQuantity,max(t3.cVenAbbName) as supper,sum(t3.rmbAmount) as rmbAmount,sum(t3.usdAmount) as usdAmount,sum(t3.priceExcludingtax) as priceExcludingtax,sum(t3.iCost) as cost from (
-
-		select t1.ccode as ccode,t1.cInvCode,t1.goodsName,t1.dosage,t1.usageQuantity,t2.cVenAbbName,t2.rmbAmount,t2.usdAmount,t2.priceExcludingtax,t2.iCost from (select ot.cInvCode,od.isosid,om.ccode,oti.cInvName as goodsName,sum(ot.iUnitQuantity) as dosage,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.Vendor v ON om.cVenCode= v.cVenCode
-		join UFDATA_101_2021.dbo.Inventory oti on oti.cInvCode=ot.cInvCode
-		join UFDATA_101_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
-join UFDATA_103_2021.dbo.cost_allocation_accessories_view vif on om.ccode = vif.cCode and ot.cInvCode = vif.cInvCode
-		WHERE om.iVerifyStateNew = 2  and omi.cInvCcode like '19%'
-		and om.cCode LIKE CONCAT(#{code},'%')
-		and (om.cCloser is null or ( (od.iReceivedQTY is not null or od.iReceivedQTY != 0) and (ot.iSendQTY is not null or ot.iSendQTY !=0) )or om.cCloser='asuser')
-		group by om.ccode,ot.cInvCode,od.isosid,om.ccode,oti.cInvName
-		) as t1,
-		(
-		select max(ven.cVenAbbName) as cVenAbbName,
-		bi.cInvCode,pod.iorderdid,sum(bi.iSum) as rmbAmount,sum(bi.iOriSum) as usdAmount
-		,sum(bi.iMoney) as priceExcludingtax,max(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_101_2021.dbo.PurBillVouchs bi  on bi.iPOsID=pod.ID
-		join UFDATA_101_2021.dbo.PurBillVouch bm  on bm.PBVID=bi.PBVID
-		join UFDATA_101_2021.dbo.Vendor ven on bm.cVenCode = ven.cVenCode
-		join UFDATA_101_2021.dbo.Inventory oti on oti.cInvCode=pod.cInvCode
-		where pom.cVenCode != 'T010001' and pom.cVenCode != 'T020001'
-		GROUP BY bi.cInvCode,pod.iorderdid) as t2 where t1.cInvCode=t2.cInvCode and t1.isosid = t2.iorderdid
-		) t3  GROUP BY t3.ccode,t3.cInvCode,t3.goodsName
-
-		union all
-
-		select t3.ccode,t3.cInvCode,t3.goodsName,max(t3.dosage) as dosage,sum(t3.usageQuantity) as usageQuantity,max(t3.cVenAbbName) as supper,sum(t3.rmbAmount) as rmbAmount,sum(t3.usdAmount) as usdAmount,sum(t3.priceExcludingtax) as priceExcludingtax,sum(t3.iCost) as cost from (
-
-		select t1.ccode,t1.cInvCode,t1.goodsName,t1.dosage,t1.usageQuantity,t2.cVenAbbName,t2.rmbAmount,t2.usdAmount,t2.priceExcludingtax,t2.iCost from (select ot.cInvCode,od.isosid,om.ccode,oti.cInvName as goodsName,sum(ot.iUnitQuantity) as dosage,sum(ot.iSendQTY) as usageQuantity
+		select t4.cInvCode,max(t4.goodsName) as goodsName,max(t4.dosage) as dosage,max(t4.usageQuantity) as usageQuantity,STRING_AGG(t4.supper,',') as supper,sum(t4.rmbAmount) as rmbAmount,sum(t4.usdAmount) as usdAmount,sum(t4.priceExcludingtax) as priceExcludingtax,sum(t4.cost) as cost from
+	    ##fenpeiTable t4
 
-		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.Vendor v ON om.cVenCode= v.cVenCode
-		join UFDATA_101_2021.dbo.Inventory oti on oti.cInvCode=ot.cInvCode
-		join UFDATA_101_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
-join UFDATA_103_2021.dbo.cost_allocation_accessories_view vif on om.ccode = vif.cCode and ot.cInvCode = vif.cInvCode
-		WHERE om.iVerifyStateNew = 2  and omi.cInvCcode like '19%'
-		and om.cCode LIKE CONCAT(#{code},'%')
-		and (om.cCloser is null or ( (od.iReceivedQTY is not null or od.iReceivedQTY != 0) and (ot.iSendQTY is not null or ot.iSendQTY !=0) )or om.cCloser='asuser')
-		group by  om.ccode,ot.cInvCode,od.isosid,om.ccode,oti.cInvName
-		) as t1
-		left join (
-		select max(ven.cVenAbbName) as cVenAbbName,
-		bi.cInvCode,pod.iorderdid,sum(bi.iSum) as rmbAmount,sum(bi.iOriSum) as usdAmount
-		,sum(bi.iMoney) as priceExcludingtax,max(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_103_2021.dbo.HY_DZ_K7_SYNERGISMLOGDID hy on pod.id = hy.predid
-
-		join UFDATA_102_2021.dbo.PO_Podetails pd on pd.iorderdid=hy.did
-		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.PurBillVouch bm  on bm.PBVID=bi.PBVID
-		join UFDATA_102_2021.dbo.Vendor ven on bm.cVenCode = ven.cVenCode
-		join UFDATA_102_2021.dbo.Inventory oti on oti.cInvCode=pd.cInvCode
-		where pm.cVenCode != 'T020001' and pom.cpoid LIKE CONCAT(#{code},'%')
-		GROUP BY bi.cInvCode,pod.iorderdid) as t2 on t1.cInvCode=t2.cInvCode and t2.iorderdid=t1.isosid
-		) t3  GROUP BY t3.ccode,t3.cInvCode,t3.goodsName
-
-		union all
-		select t3.ccode,t3.cInvCode,t3.goodsName,max(t3.dosage) as dosage,sum(t3.usageQuantity) as usageQuantity,max(t3.cVenAbbName) as supper,sum(t3.rmbAmount) as rmbAmount,sum(t3.usdAmount) as usdAmount,sum(t3.priceExcludingtax) as priceExcludingtax,sum(t3.iCost) as cost from (
-
-		select t1.ccode,t1.cInvCode,t1.goodsName,t1.dosage,t1.usageQuantity,t2.cVenAbbName,t2.rmbAmount,t2.usdAmount,t2.priceExcludingtax,t2.iCost from (select  ot.cInvCode,od.isosid,om.ccode,oti.cInvName as goodsName,sum(ot.iUnitQuantity) as dosage,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.Vendor v ON om.cVenCode= v.cVenCode
-		join UFDATA_101_2021.dbo.Inventory oti on oti.cInvCode=ot.cInvCode
-		join UFDATA_101_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
-join UFDATA_103_2021.dbo.cost_allocation_accessories_view vif on om.ccode = vif.cCode and ot.cInvCode = vif.cInvCode
-		WHERE om.iVerifyStateNew = 2  and omi.cInvCcode like '19%'
-		and om.cCode LIKE CONCAT(#{code},'%')
-		and (om.cCloser is null or ( (od.iReceivedQTY is not null or od.iReceivedQTY != 0) and (ot.iSendQTY is not null or ot.iSendQTY !=0) )or om.cCloser='asuser')
-		group by om.ccode,ot.cInvCode,od.isosid,om.ccode,oti.cInvName
-		) as t1,
-		(
-		select max(ven.cVenAbbName) as cVenAbbName,
-		bi.cInvCode,pod.iorderdid,sum(bi.iSum) as rmbAmount,sum(bi.iOriSum) as usdAmount
-		,sum(bi.iMoney) as priceExcludingtax,max(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_103_2021.dbo.HY_DZ_K7_SYNERGISMLOGDID hy on pod.id = hy.predid
-
-		join UFDATA_103_2021.dbo.OM_MODetails pd on pd.isosid=hy.did
-		join UFDATA_103_2021.dbo.OM_MOMain pm on pd.MOID  = pm.MOID
-		left join UFDATA_103_2021.dbo.PurBillVouchs bi  on bi.iPOsID=pd.MODetailsID
-		left join UFDATA_103_2021.dbo.PurBillVouch bm  on bm.PBVID=bi.PBVID
-		join UFDATA_103_2021.dbo.Vendor ven on bm.cVenCode = ven.cVenCode
-		join UFDATA_103_2021.dbo.Inventory oti on oti.cInvCode=pd.cInvCode
-		where pom.cpoid LIKE CONCAT(#{code},'%')
-		GROUP BY bi.cInvCode,pod.iorderdid) as t2 where t1.cInvCode=t2.cInvCode and t2.iorderdid=t1.isosid
-		) t3  GROUP BY t3.ccode,t3.cInvCode,t3.goodsName
-		) t4
 		where t4.cInvCode not in(
 		select cInvCode from UFDATA_103_2021.dbo.cost_allocation_fabric_view vif
 		where trim(vif.cCode) like CONCAT(#{code},'%')
@@ -335,6 +363,7 @@ join UFDATA_103_2021.dbo.cost_allocation_accessories_view vif on om.ccode = vif.
 		)
 		GROUP BY i.cInvCode,i.cInvName
 		)tab2 on tab2.cInvName=tab.goodsName and tab2.cInvCode=tab.cInvCode
+
 		
 	</select>
 

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

@@ -384,8 +384,17 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
         }
 
 
-        //查询U8数据 辅料
+        //创建临时表
+        syCostAllocationIngredientMapper.createTempTable101();
+        //插入临时表
+        syCostAllocationIngredientMapper.insertDataIntoTempTable101_101(plannum);
+        syCostAllocationIngredientMapper.insertDataIntoTempTable101_102(plannum);
+        syCostAllocationIngredientMapper.insertDataIntoTempTable101_103(plannum);
+        //查询U8数据 辅料数据关联临时表
         List<SyCostAllocationIngredient> list4 = syCostAllocationIngredientMapper.queryByCostIngredient1(plannum);
+
+        //删除临时表
+        syCostAllocationIngredientMapper.deleteTempTable101();
         for (int i=0;i<list4.size();i++) {
             SyCostAllocationIngredient Ingredient = list4.get(i);
             //若转入数量不为0则给转入数据对象赋值
@@ -535,6 +544,7 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
 
         //清空单号 不让它显示在查询框上
         syCostAllocation.setPlanNum(plannum);
+
         return syCostAllocation;
     }