zengtx 1 rok pred
rodič
commit
ff726405f3

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

@@ -24,23 +24,10 @@ public interface SyCostAllocationIngredientMapper extends BaseMapper<SyCostAlloc
 	@DS("multi-three")
 	List<SyCostAllocationIngredient> queryByCostIngredient(String code);
 	@DS("multi-three")
-	List<SyCostAllocationIngredient> queryByCostIngredient1(@Param("table") String table,@Param("code") String code);
+	List<SyCostAllocationIngredient> queryByCostIngredient1(@Param("code") String code);
 	@DS("multi-three")
 	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(@Param("table") String table);
-	//创建临时表
-	@DS("multi-one")
-	void createTempTable101(@Param("table") String table);
-	@DS("multi-one")
-	void insertDataIntoTempTable101_101(@Param("table") String table,@Param("code") String code);
-	@DS("multi-one")
-	void insertDataIntoTempTable101_102(@Param("table") String table,@Param("code") String code);
-	@DS("multi-one")
-	void insertDataIntoTempTable101_103(@Param("table") String table,@Param("code") String code);
-
 }

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

@@ -23,11 +23,11 @@
 		sp.cMaker as preparedBy,
 		ex.cExpName as expenseItem,
 		v.cVenName as processUnit,
-			case when sps.cExpCode='00011' and sp.Cexch_Name='美元' then  sps.iMoney*sp.iexchrate end as shuiemoney,
+			case when sps.cExpCode='00011' and sp.Cexch_Name='美元' then  sps.iMoney*sp.iexchrate
+					when sps.cExpCode='00011' and sp.Cexch_Name='人民币' then sps.iMoney end as shuiemoney,
 		case when sps.cExpCode!='00011' and sp.Cexch_Name='美元' then sps.iMoney*sp.iexchrate
 				 when sps.cExpCode!='00011' and sp.Cexch_Name='人民币' then sps.iMoney end as disbursedLocalmoney,
-		case when sps.cExpCode!='00011' and sp.Cexch_Name ='美元' then sps.iMoney
-	  when sps.cExpCode = '00011' and sp.Cexch_Name ='美元' then sps.iMoney	end as disbursedOriginalmoney
+		case when sps.cExpCode!='00011' and sp.Cexch_Name ='美元' then sps.iMoney end as disbursedOriginalmoney
 		FROM
 		UFDATA_101_2021.dbo.SalePayVouch sp
 		INNER JOIN UFDATA_101_2021.dbo.SalePayVouchs sps ON sp.id = sps.id
@@ -50,11 +50,11 @@
 				 sp.cMaker as preparedBy,
 				 ex.cExpName as expenseItem,
 				 v.cVenName as processUnit,
-					case when sps.cExpCode='00011' and sp.Cexch_Name='美元' then  sps.iMoney*sp.iexchrate end as shuiemoney,
+				case when sps.cExpCode='00011' and sp.Cexch_Name='美元' then  sps.iMoney*sp.iexchrate
+					when sps.cExpCode='00011' and sp.Cexch_Name='人民币' then sps.iMoney end as shuiemoney,
 		case when sps.cExpCode!='00011' and sp.Cexch_Name='美元' then sps.iMoney*sp.iexchrate
 				 when sps.cExpCode!='00011' and sp.Cexch_Name='人民币' then sps.iMoney end as disbursedLocalmoney,
-		case when sps.cExpCode!='00011' and sp.Cexch_Name ='美元' then sps.iMoney
-	  when sps.cExpCode = '00011' and sp.Cexch_Name ='美元' then sps.iMoney	end as disbursedOriginalmoney
+		case when sps.cExpCode!='00011' and sp.Cexch_Name ='美元' then sps.iMoney end as disbursedOriginalmoney
 			 FROM
 				 UFDATA_102_2021.dbo.SalePayVouch sp
 				 INNER JOIN UFDATA_102_2021.dbo.SalePayVouchs sps ON sp.id = sps.id
@@ -77,11 +77,11 @@
 				 sp.cMaker as preparedBy,
 				 ex.cExpName as expenseItem,
 				 v.cVenName as processUnit,
-					case when sps.cExpCode='00011' and sp.Cexch_Name='美元' then  sps.iMoney*sp.iexchrate end as shuiemoney,
+				case when sps.cExpCode='00011' and sp.Cexch_Name='美元' then  sps.iMoney*sp.iexchrate
+					when sps.cExpCode='00011' and sp.Cexch_Name='人民币' then sps.iMoney end as shuiemoney,
 		case when sps.cExpCode!='00011' and sp.Cexch_Name='美元' then sps.iMoney*sp.iexchrate
 				 when sps.cExpCode!='00011' and sp.Cexch_Name='人民币' then sps.iMoney end as disbursedLocalmoney,
-		case when sps.cExpCode!='00011' and sp.Cexch_Name ='美元' then sps.iMoney
-	  when sps.cExpCode = '00011' and sp.Cexch_Name ='美元' then sps.iMoney	end as disbursedOriginalmoney
+		case when sps.cExpCode!='00011' and sp.Cexch_Name ='美元' then sps.iMoney end as disbursedOriginalmoney
 			 FROM
 				 UFDATA_103_2021.dbo.SalePayVouch sp
 				 INNER JOIN UFDATA_103_2021.dbo.SalePayVouchs sps ON sp.id = sps.id

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

@@ -16,135 +16,9 @@
 			 sy_cost_allocation_id = #{id} 		
 	</select>
 
-	<update id="deleteTempTable101">
-        DROP TABLE ${table};
-	</update>
-
-	<insert id="createTempTable101">
-
-		 CREATE TABLE ${table}(
-            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 ${table} 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 ${table} 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 ${table} 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,
@@ -167,21 +41,19 @@ join UFDATA_103_2021.dbo.cost_allocation_accessories_view vif on om.ccode = vif.
 		FROM
 		(
 		SELECT ot.cInvCode,od.isosid,om.ccode,oti.cInvName AS goodsName,SUM (ot.iUnitQuantity) AS dosage,SUM (ot.iSendQTY) AS usageQuantity
-		FROM
-		UFDATA_103_2021.dbo.om_momain om
+		FROM UFDATA_103_2021.dbo.cost_allocation_accessories_view vif
+		join UFDATA_103_2021.dbo.om_momain om on om.ccode = vif.cCode
 		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.OM_MOMaterials ot ON ot.MoDetailsID= od.MODetailsID and ot.cInvCode = vif.cInvCode
 		JOIN UFDATA_103_2021.dbo.Vendor v ON om.cVenCode= v.cVenCode
 		JOIN UFDATA_103_2021.dbo.Inventory oti ON oti.cInvCode= ot.cInvCode
 		JOIN UFDATA_103_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) ))
-		GROUP BY om.ccode,ot.cInvCode,od.isosid,om.ccode,oti.cInvName ) AS t1
+	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,
 		SUM ( bi.iMoney ) AS priceExcludingtax,sum ( bi.iCost*bi.iPBVQuantity) AS totalCost ,sum ( bi.iPBVQuantity) AS totalSum
@@ -212,22 +84,19 @@ and (om.cCloser is null or ( (od.iReceivedQTY is not null or od.iReceivedQTY !=
 		SELECT t1.ccode,t1.cInvCode,t1.goodsName,t1.dosage,t1.usageQuantity,t2.cVenAbbName,t2.rmbAmount,t2.usdAmount,t2.priceExcludingtax,t2.totalCost,t2.totalSum
 		FROM
 		(
-		SELECT ot.cInvCode,om.ccode,oti.cInvName AS goodsName,max (ot.iUnitQuantity) AS dosage,SUM (ot.iSendQTY) AS usageQuantity
-		FROM
-		UFDATA_103_2021.dbo.om_momain om
+		SELECT ot.cInvCode,od.isosid,om.ccode,oti.cInvName AS goodsName,SUM (ot.iUnitQuantity) AS dosage,SUM (ot.iSendQTY) AS usageQuantity
+		FROM UFDATA_103_2021.dbo.cost_allocation_accessories_view vif
+		join UFDATA_103_2021.dbo.om_momain om on om.ccode = vif.cCode
 		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.OM_MOMaterials ot ON ot.MoDetailsID= od.MODetailsID and ot.cInvCode = vif.cInvCode
 		JOIN UFDATA_103_2021.dbo.Vendor v ON om.cVenCode= v.cVenCode
 		JOIN UFDATA_103_2021.dbo.Inventory oti ON oti.cInvCode= ot.cInvCode
 		JOIN UFDATA_103_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) ))
-		GROUP BY om.ccode,ot.cInvCode,om.ccode,oti.cInvName ) AS t1
+	GROUP BY om.ccode,ot.cInvCode,od.isosid,om.ccode,oti.cInvName) AS t1
 
 		left join (
 		SELECT oti.cinvName,ven.cVenAbbName AS cVenAbbName,bi.cInvCode,SUM ( bi.iSum ) AS rmbAmount,SUM ( bi.iOriSum ) AS usdAmount,
@@ -313,9 +182,105 @@ 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
-	    ${table} t4
+		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_103_2021.dbo.cost_allocation_accessories_view vif
+		join UFDATA_101_2021.dbo.om_momain om on om.ccode = vif.cCode
+		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 and ot.cInvCode = vif.cInvCode
+		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
+		WHERE om.iVerifyStateNew = 2  and omi.cInvCcode like '19%'
+		and om.cCode LIKE CONCAT(#{code},'%')
+		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
+
+		from UFDATA_103_2021.dbo.cost_allocation_accessories_view vif
+		join UFDATA_101_2021.dbo.om_momain om on om.ccode = vif.cCode
+		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 and ot.cInvCode = vif.cInvCode
+		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
+		WHERE om.iVerifyStateNew = 2  and omi.cInvCcode like '19%'
+		and om.cCode LIKE CONCAT(#{code},'%')
+		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_103_2021.dbo.cost_allocation_accessories_view vif
+		join UFDATA_101_2021.dbo.om_momain om on om.ccode = vif.cCode
+		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 and ot.cInvCode = vif.cInvCode
+		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
+		WHERE om.iVerifyStateNew = 2  and omi.cInvCcode like '19%'
+		and om.cCode LIKE CONCAT(#{code},'%')
+		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},'%')
@@ -432,9 +397,12 @@ and (om.cCloser is null or ( (od.iReceivedQTY is not null or od.iReceivedQTY !=
 						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_103_2021.dbo.OM_MOMaterials ot ON ot.MoDetailsID= od.MODetailsID
 						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 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 (i.cInvCcode like '05%' or i.cInvCcode like '06%' or i.cInvCcode like '07%'
 						or i.cInvCCode = '0399' or i.cInvCCode = '0499' or i.cInvCCode = '0299')
 				GROUP BY i.cInvName,rs.cBatch

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

@@ -33,7 +33,7 @@ left join UFDATA_101_2021.dbo.OM_MODetails ommos on ommos.MODetailsID=pbvs.iPOsI
 left join UFDATA_101_2021.dbo.om_momain ommo on ommo.moid=ommos.moid
 left join UFDATA_101_2021.dbo.SO_SODetails sd on sd.iSOsID = ommos.isosid
 	left join UFDATA_101_2021.dbo.Inventory inv on pbvs.cInvCode = inv.cInvCode
-group by pbv.cDefine10,pbvs.cInvCode,pbvs.cFree1,pbvs.cFree2,pbv.cBusType,inv.cInvCCode,ommo.ccode,ommo.cVenCode
+group by pbv.cDefine10,pbvs.cInvCode,pbvs.cFree1,pbvs.cFree2,pbv.cBusType,inv.cInvCCode,ommo.ccode,ommo.cVenCode,pbvs.cDefine28
 having ommo.ccode like CONCAT(#{code},'%') AND pbv.cBusType='委外加工' and inv.cInvCCode like '19%') as pbv
 left join
 -- 根据外销发票号 加物料编码以及自由项组合计算 销售发票合计数量

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

@@ -383,18 +383,9 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
 
         }
 
-
-        //创建临时表
-        syCostAllocationIngredientMapper.createTempTable101("##"+plannum);
-        //插入临时表
-        syCostAllocationIngredientMapper.insertDataIntoTempTable101_101("##"+plannum,plannum);
-        syCostAllocationIngredientMapper.insertDataIntoTempTable101_102("##"+plannum,plannum);
-        syCostAllocationIngredientMapper.insertDataIntoTempTable101_103("##"+plannum,plannum);
         //查询U8数据 辅料数据关联临时表
-        List<SyCostAllocationIngredient> list4 = syCostAllocationIngredientMapper.queryByCostIngredient1("##"+plannum,plannum);
+        List<SyCostAllocationIngredient> list4 = syCostAllocationIngredientMapper.queryByCostIngredient1(plannum);
 
-        //删除临时表
-        syCostAllocationIngredientMapper.deleteTempTable101("##"+plannum);
         for (int i=0;i<list4.size();i++) {
             SyCostAllocationIngredient Ingredient = list4.get(i);
             //若转入数量不为0则给转入数据对象赋值

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

@@ -237,7 +237,7 @@ public class SyOrderDataServiceImpl extends ServiceImpl<SyOrderDataMapper, SyOrd
                                 "left join UFDATA_101_2021.dbo.SO_SODetails_extradefine sosose101 on sosose101.iSOsID=popos101.iorderdid " +
                                 "left join UFDATA_102_2021.dbo.Inventory inv102 on inv102.cInvCode=sosos102.cInvCode  " +
                                 "where soso102.cCusCode='T020001' and left(inv102.cInvCCode,2)='19'  " +
-                                "and soso102.cSOCode='"+sy.getOrderNumber()+"' and sosos102.AutoID =" + sy2.getId();
+                                "and soso102.cSOCode='"+sy.getOrderNumber()+"' and sosose101.cbdefine2 is not null and sosos102.AutoID =" + sy2.getId();
                         List<Map<String, Object>> ymoneyList = new ArrayList<>();
 
                         if (sy.getAccount().equals("101")) {

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

@@ -234,7 +234,7 @@ public class AddOrderJob implements Job,ApplicationContextAware {
                                 "left join UFDATA_101_2021.dbo.SO_SODetails_extradefine sosose901 on sosose901.iSOsID=popos901.iorderdid " +
                                 "left join UFDATA_102_2021.dbo.Inventory inv902 on inv902.cInvCode=sosos902.cInvCode  " +
                                 "where soso902.cCusCode='T020001' and left(inv902.cInvCCode,2)='19'  " +
-                                "and soso902.cSOCode='"+sy.getOrderNumber()+"' and sosos902.AutoID =" + sy2.getId();
+                                "and soso902.cSOCode='"+sy.getOrderNumber()+"' and sosose901.cbdefine2 is not null and sosos902.AutoID =" + sy2.getId();
                         List<Map<String, Object>> ymoneyList = new ArrayList<>();
 
                         if (sy.getAccount().equals("101")) {