Prechádzať zdrojové kódy

面料损耗第七版本

fenghaifu 2 rokov pred
rodič
commit
eca8e13697

+ 41 - 10
jeecg-boot-module-system/src/main/java/org/jeecg/modules/report/mapper/xml/FabricLossMapper.xml

@@ -97,7 +97,7 @@
 			or d.cInvCCode LIKE '03%'
 			or d.cInvCCode LIKE '04%')
 			AND c.cCode LIKE CONCAT(#{code},'%')
-			AND a.cInvCode + isnull( a.cFree1, '' ) + isnull( a.cBatch, '' ) IN (
+			AND (a.cInvCode + isnull( a.cFree1, '' ) + isnull( a.cBatch, '' ) IN (
 				SELECT
 					b.cInvCode + isnull( b.cFree1, '' ) + isnull( b.cBatch, '' )
 				FROM
@@ -105,15 +105,27 @@
 					INNER JOIN rdrecord08 a ON a.id = b.ID
 				WHERE
 					a.cbustype = '其他入库'
+			) or a.cInvCode + isnull( a.cFree1, '' ) + isnull( a.cBatch, '' ) IN (
+				select cInvCode2+isnull(cColor2,'')+isnull(cAVBatch2,'') from VIEW_FabricLoss_AssemVouchs where
+				cInvCode+isnull(cColor,'')+isnull(cAVBatch,'') in (
+				select b.cInvCode + isnull( b.cFree1, '' ) + isnull( b.cBatch, '' )
+				FROM
+					RdRecords08 b
+					INNER JOIN rdrecord08 a ON a.id = b.ID
+				WHERE
+					a.cbustype = '其他入库'
+				)
+			)
 			)
 		) as t1 group by cCode
 	</select>
 	<!-- 来源余纱,找委外订单的材料出库单,获取物料号+批号。如果物料号+批号在形态转换单中,取转换前物料+批号。判断物料+批号,是否在其他采购入库里 -->
 	<select id="getPurchaseListOtherPurInList" resultType="org.jeecg.modules.report.entity.FabricPoOrderOut">
-		select cCode,sum(iQuantity*iPrice)/sum(iQuantity) as iPrice, sum(iQuantity) as iQuantity from
+		select cCode,sum(iPrice)/count(iPrice) as iPrice, sum(iQuantity) as iQuantity from
 		(
 		SELECT
-			a.comcode as cCode,isnull(a.iSQuantity,a.iquantity) as iQuantity,a.iUnitCost as iPrice
+			a.comcode as cCode,case when a.iSQuantity is null or a.iSQuantity=0 then a.iquantity else a.iSQuantity end as iQuantity,
+			a.iUnitCost as iPrice
 		FROM
 			rdrecords11 a
 			INNER JOIN Inventory d ON a.cinvcode = d.cinvcode
@@ -127,18 +139,18 @@
 				a.cInvCode+isnull(a.cFree1,'')+isnull(a.cbatch,'') in (
 				select b.cinvcode+isnull(b.cfree1,'')+isnull(b.cbatch,'') from RdRecords01 b
 				inner join RdRecord01 a on a.id=b.id
-				inner join OM_MODetails  c on b.iOMoDID=c.MODetailsID
-				inner join om_momain d on c.MOID =d.MOID
-				where d.ccode not like CONCAT(#{code},'%') and a.cbustype='普通采购'
+				inner join PO_Podetails  c on b.iPOsID =c.ID
+				inner join PO_Pomain d on c.POID  =d.POID
+				where d.cPOID  not like CONCAT(#{code},'%') and a.cbustype='普通采购'
 				)
 				or a.cInvCode+isnull(a.cFree1,'')+isnull(a.cbatch,'') in (
 					select cInvCode2+isnull(cColor2,'')+isnull(cAVBatch2,'') from VIEW_FabricLoss_AssemVouchs where
 						cInvCode+isnull(cColor,'')+isnull(cAVBatch,'') in (
 						select b.cinvcode+isnull(b.cfree1,'')+isnull(b.cbatch,'') from RdRecords01 b
 						inner join RdRecord01 a on a.id=b.id
-						inner join OM_MODetails  c on b.iOMoDID=c.MODetailsID
-						inner join om_momain d on c.MOID =d.MOID
-						where d.ccode not like CONCAT(#{code},'%') and a.cbustype='普通采购')
+						inner join PO_Podetails  c on b.iPOsID =c.ID
+						inner join PO_Pomain d on c.POID  =d.POID
+						where d.cPOID not like CONCAT(#{code},'%') and a.cbustype='普通采购')
 				)
 			)
 		) as t1 group by cCode
@@ -208,7 +220,8 @@
 			b.cInvCode,
 			isnull( a.iSQuantity, a.iQuantity ) AS iQuantity,
 			a.autoid,
-			a.iPrice
+			a.iPrice,
+			a.cBatch
 		FROM
 			rdrecords11 a
 			INNER JOIN Inventory b ON a.cInvCode = b.cInvCode
@@ -218,6 +231,24 @@
 		WHERE
 			b.cInvCCode NOT LIKE '19%'
 			AND e.cCode LIKE CONCAT(#{code},'%')
+			and (
+				a.cInvCode+isnull(a.cFree1,'')+isnull(a.cbatch,'') in (
+				select b.cinvcode+isnull(b.cfree1,'')+isnull(b.cbatch,'') from RdRecords01 b
+				inner join RdRecord01 a on a.id=b.id
+				inner join PO_Podetails  c on b.iPOsID =c.ID
+				inner join PO_Pomain d on c.POID  =d.POID
+				where d.cPOID  like CONCAT(#{code},'%') and a.cbustype='普通采购'
+				)
+				or a.cInvCode+isnull(a.cFree1,'')+isnull(a.cbatch,'') in (
+					select cInvCode2+isnull(cColor2,'')+isnull(cAVBatch2,'') from VIEW_FabricLoss_AssemVouchs where
+						cInvCode+isnull(cColor,'')+isnull(cAVBatch,'') in (
+						select b.cinvcode+isnull(b.cfree1,'')+isnull(b.cbatch,'') from RdRecords01 b
+						inner join RdRecord01 a on a.id=b.id
+						inner join PO_Podetails  c on b.iPOsID =c.ID
+						inner join PO_Pomain d on c.POID  =d.POID
+						where d.cPOID like CONCAT(#{code},'%') and a.cbustype='普通采购')
+				)
+			)
 
 	</select>
 	<!--获取本次采购入库的形态转换-->

+ 7 - 4
jeecg-boot-module-system/src/main/java/org/jeecg/modules/report/service/impl/FabricLossServiceImpl.java

@@ -136,17 +136,20 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
 				// 获取采购形态转换物料
 				List<Map<String, Object>> tmpAssemVouchList = fabricAssemVouchList.stream().filter(e->
 						oConvertUtils.getString(e.get("cInvCode")).equals(fabricPoOrder.getCInvCode()) &&
-						oConvertUtils.getString(e.get("cColor")).equals(fabricPoOrder.getCColor())).collect(Collectors.toList());
+						oConvertUtils.getString(e.get("cColor")).equals(fabricPoOrder.getCColor())&&
+								oConvertUtils.getString(e.get("cAVBatch")).equals(fabricPoOrder.getCBatch())).collect(Collectors.toList());
 				// 未形态转换物料
 				List<Map<String, Object>> tmpOmOutList1 = fabricOmOutList.stream().filter(e->
 						oConvertUtils.getString(e.get("cInvCode")).equals(fabricPoOrder.getCInvCode()) &&
-						oConvertUtils.getString(e.get("cColor")).equals(fabricPoOrder.getCColor())).collect(Collectors.toList());
+						oConvertUtils.getString(e.get("cColor")).equals(fabricPoOrder.getCColor()) &&
+						oConvertUtils.getString(e.get("cBatch")).equals(fabricPoOrder.getCBatch())).collect(Collectors.toList());
 
 				// 形态转换物料
 				List<Map<String, Object>> tmpOmOutList2 = fabricOmOutList.stream().filter(out->{
 				return tmpAssemVouchList.stream().filter(e ->
 						oConvertUtils.getString(e.get("cInvCode2")).equals(oConvertUtils.getString(out.get("cInvCode"))) &&
-						oConvertUtils.getString(e.get("cColor2")).equals(oConvertUtils.getString(out.get("cColor")))
+						oConvertUtils.getString(e.get("cColor2")).equals(oConvertUtils.getString(out.get("cColor"))) &&
+								oConvertUtils.getString(e.get("cAVBatch2")).equals(oConvertUtils.getString(out.get("cBatch")))
 				).count() > 0;
 				}).collect(Collectors.toList());
 
@@ -238,7 +241,7 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
 			fabricPoOrderList.add(fabricPoOrderQtrk);
 			if (fabricPoOrderTempList.size()>0){
 				for (FabricPoOrderOut item : fabricPoOrderTempList){
-					fabricPoOrderQtrk.setIQuantityIn(item.getIQuantity()+fabricPoOrderLyys.getIQuantityIn());
+					fabricPoOrderQtrk.setIQuantityIn(item.getIQuantity()+fabricPoOrderQtrk.getIQuantityIn());
 					String cCode = item.getCCode();
 					int index1 = cCode.indexOf("SY");
 					if (index1 == -1) {