Browse Source

面损表销售出库查询优化

fenghaifu 11 months ago
parent
commit
9ded08e0f5

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

@@ -141,7 +141,7 @@ public interface FabricLossMapper extends BaseMapper<FabricLoss> {
 	List<FabricMoOrderRK> getOmInDetailListByDetailId(@Param("detailIdList")List<Integer> detailIdList);
 	// 获取销售出库数量
 	@DS("multi-three")
-	List<FabricMoOrderCK> getSaleOutList(@Param("code")String code);
+	List<FabricMoOrderCK> getSaleOutList(@Param("code")String code,@Param("detailIdList")List<Integer> detailIdList);
 
 	// 获取本次采购入库的形态转换
 	@DS("multi-three")
@@ -158,4 +158,8 @@ public interface FabricLossMapper extends BaseMapper<FabricLoss> {
 	@DS("multi-three")
 	@InterceptorIgnore(tenantLine = "1")
 	List<FabricInvInType> getInTypeByInvId(@Param("invIdList")List<String> invIdList);
+
+	//获取计划关联的销售订单子表id,给查询销售出库用
+	@DS("multi-three")
+	List<Map<String,Object>> getSaleOrderDetailIdList(@Param("code")String code);
 }

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

@@ -637,8 +637,17 @@
 		inner join so_somain e on e.id=d.id
 		INNER JOIN Inventory b ON c.cinvcode = b.cinvcode
 		where
-			d.id in (
-			select distinct e.id
+			d.id in
+		<foreach  item="item" collection="detailIdList" index="index"  open="(" separator="," close=")">
+			#{item}
+		</foreach>
+			 or trim(e.cSOCode) like '${code}%'
+		) as t1 where (cInvCCode like '01%' or cInvCCode like '02%' or cInvCCode like '03%' or cInvCCode like '04%')
+	</select>
+	<!-- 获取计划关联的销售订单子表id,给查询销售出库用 -->
+	<select id="getSaleOrderDetailIdList" resultType="map">
+
+			select distinct e.id as id
 					from om_momain a
 					inner join OM_MODetails b on a.moid=b.moid
 					inner join rdrecords32 c on c.iorderdid  =b.isosid and b.cinvcode=c.cinvcode
@@ -646,9 +655,9 @@
 					inner join SO_SODetails e on e.iSOsID=c.isodid
 					where trim(a.ccode) like '${code}%'  and a.ccode not like '%样%' and
 						(d.cInvCCode like '01%' or d.cInvCCode like '02%' or d.cInvCCode like '03%' or d.cInvCCode like '04%')
-			) or trim(e.cSOCode) like '${code}%'
-		) as t1 where (cInvCCode like '01%' or cInvCCode like '02%' or cInvCCode like '03%' or cInvCCode like '04%')
+
 	</select>
+
 	<!--获取本次采购入库的形态转换-->
 	<select id="getPoAssemVouchList" resultType="map">
 

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

@@ -1928,7 +1928,16 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
 		if (oConvertUtils.listIsNotEmpty(outList1)){
 			otherOutList.addAll(outList1);
 		}
-		outList1 = fabricLossMapper.getSaleOutList(code);// 销售出库
+		List<Map<String,Object>> saleorderDetailTable = fabricLossMapper.getSaleOrderDetailIdList(code);
+		List<Integer> saleorderDetailIdList = new ArrayList<>();
+		saleorderDetailTable.forEach(e->{
+			saleorderDetailIdList.add(oConvertUtils.getInt(e.get("id"), 0));
+		});
+		outList1 = new ArrayList<>();
+		if (saleorderDetailIdList.size()>0){
+			outList1 = fabricLossMapper.getSaleOutList(code, saleorderDetailIdList);// 销售出库
+		}
+
 		if (oConvertUtils.listIsNotEmpty(outList1)){
 			otherOutList.addAll(outList1);
 		}