Browse Source

面料损耗第六版本

fenghaifu 2 years ago
parent
commit
0a2dcc0a90

+ 3 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/report/entity/FabricPoOrder.java

@@ -66,5 +66,8 @@ public class FabricPoOrder {
     @ApiModelProperty(value = "存货自定义项3")
     private  String cfree3;
 
+    // 采购入库详情
     List<FabricPoOrderIn> fabricPoOrderInList;
+    // 被其他委外订单使用情况
+    List<FabricPoOrderOut> fabricPoOrderOutList;
 }

+ 15 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/report/entity/FabricPoOrderOut.java

@@ -1,6 +1,7 @@
 package org.jeecg.modules.report.entity;
 
 import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
@@ -20,4 +21,18 @@ import lombok.experimental.Accessors;
 @Accessors(chain = true)
 @ApiModel(value="面料损耗-采购订单-出库", description="面料损耗-采购订单-出库")
 public class FabricPoOrderOut {
+	@ApiModelProperty(value = "计划号")
+	String cPlanCode;
+	@ApiModelProperty(value = "委外订单号")
+	String cCode;
+	@ApiModelProperty(value = "使用数量")
+	Double iQuantity;
+	@ApiModelProperty(value = "采购单价")
+	Double iPrice;
+	@ApiModelProperty(value = "物料名称")
+	String cInvName;
+	@ApiModelProperty(value = "物料编码")
+	String cInvCode;
+	@ApiModelProperty(value = "颜色")
+	String cColor;
 }

+ 5 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/report/mapper/FabricLossMapper.java

@@ -59,11 +59,11 @@ public interface FabricLossMapper extends BaseMapper<FabricLoss> {
 
 	//其他入库纱,找委外订单的材料出库单,获取物料号+批号,物料号+批号再其他入库单
 	@DS("multi-three")
-	List<FabricPoOrder> getPurchaseListOtherInList(@Param("code")String code);
+	List<FabricPoOrderOut> getPurchaseListOtherInList(@Param("code")String code);
 
 	//来源余纱,找委外订单的材料出库单,获取物料号+批号。如果物料号+批号在形态转换单中,取转换前物料+批号。判断物料+批号,是否在其他采购入库里
 	@DS("multi-three")
-	List<FabricPoOrder> getPurchaseListOtherPurInList(@Param("code")String code);
+	List<FabricPoOrderOut> getPurchaseListOtherPurInList(@Param("code")String code);
 	// 获取所有委外订单
 	@DS("multi-three")
 	List<FabricOMOrder> getOmOrderListAll(@Param("code")String code);
@@ -103,4 +103,7 @@ public interface FabricLossMapper extends BaseMapper<FabricLoss> {
 	//获取使用其他委外入库物料的金额
 	@DS("multi-three")
 	String getOmOtherToCurMoney(@Param("code")String code);
+	// 获取采购入库物料被其他委外订单使用明细
+	@DS("multi-three")
+	List<FabricPoOrderOut> getPoOrderInToOther(@Param("code")String code);
 }

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

@@ -81,11 +81,11 @@
 		) as t1 group by cVenName,cVenAbbName,cInvCode,cInvName,cColor,cBatch
 	</select>
 	<!-- 其他入库纱,找委外订单的材料出库单,获取物料号+批号,物料号+批号再其他入库单 -->
-	<select id="getPurchaseListOtherInList" resultType="org.jeecg.modules.report.entity.FabricPoOrder">
-
+	<select id="getPurchaseListOtherInList" resultType="org.jeecg.modules.report.entity.FabricPoOrderOut">
+		select cCode,sum(iQuantity*iPrice)/sum(iQuantity) as iPrice, sum(iQuantity) as iQuantity from
+		(
 		SELECT
-			'其他入库的纱' as cInvName,
-			isnull(sum(a.iQuantity),0) as iQuantityOut
+			a.comcode as cCode,isnull(a.iSQuantity,a.iquantity) as iQuantity,a.iUnitCost as iPrice
 		FROM
 			rdrecords11 a
 			INNER JOIN OM_MODetails b ON a.iOMoDID = b.MODetailsID
@@ -98,77 +98,50 @@
 			or d.cInvCCode LIKE '04%')
 			AND c.cCode LIKE CONCAT(#{code},'%')
 			AND a.cInvCode + isnull( a.cFree1, '' ) + isnull( a.cBatch, '' ) 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 = '其他入库'
+				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.FabricPoOrder">
+	<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
-			'来源余纱' as cInvName,isnull(sum(h.iQuantity),0)  as iQuantityOut
+			a.comcode as cCode,isnull(a.iSQuantity,a.iquantity) as iQuantity,a.iUnitCost as iPrice
 		FROM
-			rdrecords11 h
-		WHERE
-			comcode IN (
-		SELECT DISTINCT
-			a.cCode
-		FROM
-			om_momain a
-			INNER JOIN OM_MODetails b ON a.moid = b.moid
-			INNER JOIN Inventory c ON b.cinvcode = c.cinvcode
+			rdrecords11 a
+			INNER JOIN Inventory d ON a.cinvcode = d.cinvcode
 		WHERE
-			(c.cInvCCode LIKE '01%'
-			or c.cInvCCode LIKE '02%'
-			or c.cInvCCode LIKE '03%'
-			or c.cInvCCode LIKE '04%')
-			AND a.cCode LIKE CONCAT(#{code},'%')
-			)
-			AND cInvCode + isnull( cBatch, '' ) IN ( SELECT cinvcode + isnull( cavbatch, '' ) FROM AssemVouchs WHERE bavtype = '转换后' )
-			and cInvCode + isnull( cBatch, '' ) IN (
-				select u.cInvCode+ isnull( u.cBatch, '' )  from rdrecords01 u inner join PO_Podetails v on u.iposid=v.id
-				inner join PO_Pomain w on w.POID  =v.POID where w.cPOID not like CONCAT(#{code},'%')
-				and u.cInvCode + isnull( u.cBatch, '' ) in (
-					select m.cInvCode + isnull( m.cavbatch, '' ) from AssemVouchs m where m.cavcode + CONVERT ( VARCHAR ( 10 ), m.igroupno ) in (
-							select cavcode + CONVERT ( VARCHAR ( 10 ), igroupno )
-							FROM
-								AssemVouchs where cinvcode + isnull( cavbatch, '' )=h.cInvCode + isnull( h.cBatch, '' ) and  bavtype = '转换后'
-					) and bavtype = '转换前'
-				)
-			)
-		) union all
-		(
-			SELECT
-				'来源余纱' as cInvName,isnull(sum(iQuantity),0)  as iQuantityIn
-			FROM
-				rdrecords11
-			WHERE
-				comcode IN (
-			SELECT DISTINCT
-				a.cCode
-			FROM
-				om_momain a
-				INNER JOIN OM_MODetails b ON a.moid = b.moid
-				INNER JOIN Inventory c ON b.cinvcode = c.cinvcode
-			WHERE
-				(c.cInvCCode LIKE '01%'
-				or c.cInvCCode LIKE '02%'
-				or c.cInvCCode LIKE '03%'
-				or c.cInvCCode LIKE '04%')
-				AND a.cCode LIKE CONCAT(#{code},'%')
+			(d.cInvCCode LIKE '01%'
+			or d.cInvCCode LIKE '02%'
+			or d.cInvCCode LIKE '03%'
+			or d.cInvCCode LIKE '04%')
+			and a.comcode 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 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='普通采购'
 				)
-				AND cInvCode + isnull( cBatch, '' ) NOT IN ( SELECT cinvcode + isnull( cavbatch, '' ) FROM AssemVouchs WHERE bavtype = '转换后' )
-				and cInvCode + isnull( cBatch, '' ) in (
-					select u.cInvCode + isnull( u.cBatch, '' ) from rdrecords01 u inner join PO_Podetails v on u.iposid=v.id
-					inner join PO_Pomain w on w.POID  =v.POID where w.cPOID not like CONCAT(#{code},'%')
+				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='普通采购')
 				)
-		)
+			)
+		) as t1 group by cCode
 	</select>
 	<!--获取所有委外订单 cComUnitCode : 计量单位,02(PCS)根,04(M)米-->
 	<select id="getOmOrderListAll" resultType="org.jeecg.modules.report.entity.FabricOMOrder">
@@ -396,4 +369,30 @@
 				)
 			)
 	</select>
+	<!--获取采购入库物料被其他委外订单使用明细 -->
+	<select id="getPoOrderInToOther" resultType="org.jeecg.modules.report.entity.FabricPoOrderOut">
+		select cCode,cInvCode,cColor,sum(iQuantity*iPrice)/sum(iQuantity) as iPrice, sum(iQuantity) as iQuantity from
+		(
+		select cInvCode,isnull(cFree1,'') as cColor,comcode as cCode,isnull(iSQuantity,iquantity) as iQuantity,iUnitCost as iPrice
+		from rdrecords11 where
+		comcode not like CONCAT(#{code},'%')
+		and (cInvCode+isnull(cFree1,'')+isnull(cbatch,'') in (
+			select b.cinvcode+isnull(b.cfree1,'')+isnull(b.cbatch,'') from RdRecords01 b
+			inner join OM_MODetails  c on b.iOMoDID=c.MODetailsID
+			inner join om_momain d on c.MOID =d.MOID
+			where d.ccode like CONCAT(#{code},'%')
+		)
+		or cInvCode+isnull(cFree1,'')+isnull(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 OM_MODetails  c on b.iOMoDID=c.MODetailsID
+				inner join om_momain d on c.MOID =d.MOID
+				where d.ccode like CONCAT(#{code},'%')
+		)
+		)
+		)
+		) as t1
+		group by cCode,cInvCode,cColor
+	</select>
 </mapper>

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

@@ -129,6 +129,8 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
 				bNum = new BigDecimal(fabricPoOrderIn.getIQuantity()-fabricPoOrderIn.getIQuantitySettle());
 				fabricPoOrderIn.setIQuantityNSettle(bNum.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue());
 			}
+			// 采购入库被其他委外订单使用的信息
+			List<FabricPoOrderOut> fabricPoOrderOutList = fabricLossMapper.getPoOrderInToOther(code);
 			// 采购订单设置分配数量、委外供应商、余纱、采购损耗
 			for (FabricPoOrder fabricPoOrder : fabricPoOrderList){
 				// 获取采购形态转换物料
@@ -183,21 +185,73 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
 						e.getCInvCode().equals(fabricPoOrder.getCInvCode()) &&
 						oConvertUtils.getString(e.getCColor()).equals(oConvertUtils.getString(fabricPoOrder.getCColor()))).collect(Collectors.toList());
 				fabricPoOrder.setFabricPoOrderInList(tmpFabricPoOrderInList);
+				// 设置被其他委外订单使用信息
+				List<FabricPoOrderOut> findFabricPoOrderOutList = fabricPoOrderOutList.stream().filter(e->
+						oConvertUtils.getString(e.getCInvCode()).equals(oConvertUtils.getString(fabricPoOrder.getCInvCode())) &&
+						oConvertUtils.getString(e.getCColor()).equals(oConvertUtils.getString(fabricPoOrder.getCColor()))).collect(Collectors.toList());
+				// 设置计划号
+				for (FabricPoOrderOut item : findFabricPoOrderOutList){
+					String cCode = item.getCCode();
+					int index1 = cCode.indexOf("SY");
+					if (index1 == -1) {
+						continue;
+					}
+					int index2 = cCode.indexOf("-", index1);
+					if (index2 == -1) {
+						index2 = cCode.length();
+					}
+					item.setCPlanCode(cCode.substring(index1,index2-1));
+				}
+				
+				fabricPoOrder.setFabricPoOrderOutList(findFabricPoOrderOutList);
 			}
 			// 采购入库-来源余纱
-			List<FabricPoOrder> fabricPoOrderTempList = fabricLossMapper.getPurchaseListOtherPurInList(code);
+			List<FabricPoOrderOut> fabricPoOrderTempList = fabricLossMapper.getPurchaseListOtherPurInList(code);
+			FabricPoOrder fabricPoOrderLyys = new FabricPoOrder();
+			fabricPoOrderLyys.setCInvName("来源余纱");
+			fabricPoOrderLyys.setIQuantityIn(0.0);
+			fabricPoOrderLyys.setFabricPoOrderOutList(fabricPoOrderTempList);
+			fabricPoOrderList.add(fabricPoOrderLyys);
 			if (fabricPoOrderTempList.size()>0){
-				FabricPoOrder fabricPoOrderFirst = fabricPoOrderTempList.get(0);
-				for (int i=1; i<fabricPoOrderTempList.size(); i++){
-					BigDecimal bdVal = new BigDecimal(fabricPoOrderFirst.getIQuantityOut()+fabricPoOrderTempList.get(i).getIQuantityOut());
-					fabricPoOrderFirst.setIQuantityOut(bdVal.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue());
+				for (FabricPoOrderOut item : fabricPoOrderTempList){
+					fabricPoOrderLyys.setIQuantityIn(item.getIQuantity()+fabricPoOrderLyys.getIQuantityIn());
+					String cCode = item.getCCode();
+					int index1 = cCode.indexOf("SY");
+					if (index1 == -1) {
+						continue;
+					}
+					int index2 = cCode.indexOf("-", index1);
+					if (index2 == -1) {
+						index2 = cCode.length();
+					}
+					item.setCPlanCode(cCode.substring(index1,index2-1));
 				}
-				fabricPoOrderList.add(fabricPoOrderFirst);
+				BigDecimal bdVal = new BigDecimal(fabricPoOrderLyys.getIQuantityIn());
+				fabricPoOrderLyys.setIQuantityIn(bdVal.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue());
 			}
 			// 采购入库-其他入库的纱
 			fabricPoOrderTempList = fabricLossMapper.getPurchaseListOtherInList(code);
+			FabricPoOrder fabricPoOrderQtrk = new FabricPoOrder();
+			fabricPoOrderQtrk.setCInvName("其他入库的纱");
+			fabricPoOrderQtrk.setIQuantityIn(0.0);
+			fabricPoOrderQtrk.setFabricPoOrderOutList(fabricPoOrderTempList);
+			fabricPoOrderList.add(fabricPoOrderQtrk);
 			if (fabricPoOrderTempList.size()>0){
-				fabricPoOrderList.add(fabricPoOrderTempList.get(0));
+				for (FabricPoOrderOut item : fabricPoOrderTempList){
+					fabricPoOrderQtrk.setIQuantityIn(item.getIQuantity()+fabricPoOrderLyys.getIQuantityIn());
+					String cCode = item.getCCode();
+					int index1 = cCode.indexOf("SY");
+					if (index1 == -1) {
+						continue;
+					}
+					int index2 = cCode.indexOf("-", index1);
+					if (index2 == -1) {
+						index2 = cCode.length();
+					}
+					item.setCPlanCode(cCode.substring(index1,index2-1));
+				}
+				BigDecimal bdVal = new BigDecimal(fabricPoOrderQtrk.getIQuantityIn());
+				fabricPoOrderQtrk.setIQuantityIn(bdVal.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue());
 			}
 			ret.setFabricPoOrderList(fabricPoOrderList);
 			// 委外订单所有