Преглед на файлове

成本报表 面料转入

liuchaohui преди 2 години
родител
ревизия
696e39cc6c

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

@@ -3,8 +3,10 @@ package org.jeecg.modules.cost.mapper;
 import java.util.List;
 
 import com.baomidou.dynamic.datasource.annotation.DS;
+import org.apache.ibatis.annotations.Param;
 import org.jeecg.modules.cost.entity.SyCostAllocationFabric;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.cost.entity.SyTransfer;
 
 /**
  * @Description: 成本分配子表_面料
@@ -20,4 +22,6 @@ public interface SyCostAllocationFabricMapper extends BaseMapper<SyCostAllocatio
 
 	@DS("multi-three")
 	List<SyCostAllocationFabric> queryByCostFabric(String mainId);
+	@DS("multi-three")
+	List<SyTransfer> queryTransferByFabric(@Param("code") String code,@Param("goodName") String goodName);
 }

+ 72 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/cost/mapper/xml/SyCostAllocationFabricMapper.xml

@@ -109,4 +109,76 @@
 				GROUP BY i.cInvName,rs.cBatch
 		)tab2 on tab2.cInvName=tab.goodsName
 	</select>
+
+	<select id="queryTransferByFabric" resultType="org.jeecg.modules.cost.entity.SyTransfer">
+        select tab1.cInvName as goodsName,tab1.cFree1 as color,tab1.cCode as planCode,
+				tab1.purchaseQuantity-tab2.jian as number
+		from
+		(
+				select i.cInvName,sum(rs.iQuantity) as purchaseQuantity,rs.cBatch,rs.cFree1,(
+						select distinct om.cCode
+						from UFDATA_901_2021.dbo.om_momain om
+						join UFDATA_901_2021.dbo.OM_MODetails od on om.moid=od.moid
+						join UFDATA_901_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
+						WHERE om.iVerifyStateNew = 2 and (om.cCloser is null or om.cCloser='asuser')
+									and omi.cInvCcode like '19%' and od.csocode=rs.iordercode
+				) as ccode
+				from UFDATA_901_2021.dbo.rdrecords01 rs
+				join UFDATA_901_2021.dbo.Inventory i on rs.cInvCode=i.cInvCode
+				where (i.cInvCcode like '03%' or i.cInvCcode like '04%') and i.cInvCCode != '0399' and i.cInvCCode != '0499'
+				GROUP BY i.cInvName,rs.cBatch,rs.cFree1,rs.iordercode
+		)tab1
+		 join
+		(
+				select i.cInvName,sum(rs.iQuantity) as jian,rs.cBatch,rs.cFree1 from UFDATA_901_2021.dbo.rdrecords11 rs
+				join UFDATA_901_2021.dbo.Inventory i on rs.cInvCode=i.cInvCode
+				where iordercode in (
+						select distinct od.csocode
+						from UFDATA_901_2021.dbo.om_momain om
+						join UFDATA_901_2021.dbo.OM_MODetails od on om.moid=od.moid
+						join UFDATA_901_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
+						WHERE om.iVerifyStateNew = 2 and (om.cCloser is null or om.cCloser='asuser')
+									and omi.cInvCcode like '19%' and om.cCode like CONCAT(#{code},'%')
+				) and (i.cInvCcode like '03%' or i.cInvCcode like '04%') and i.cInvCCode != '0399' and i.cInvCCode != '0499'
+				and i.cInvName = #{goodName}
+				GROUP BY i.cInvName,rs.cBatch,rs.cFree1
+		)tab2 on tab2.cInvName=tab1.cInvName and tab1.cBatch=tab2.cBatch and tab1.cFree1=tab2.cFree1
+		where tab1.purchaseQuantity-tab2.jian>0
+
+		union all
+
+		select tab1.cInvName as goodsName,tab1.cFree1 as color,tab1.cCode as planCode,
+				tab1.purchaseQuantity-tab2.jian as number
+		from
+		(
+				select i.cInvName,sum(rs.iQuantity) as purchaseQuantity,rs.cBatch,rs.cFree1,(
+						select distinct om.cCode
+						from UFDATA_903_2021.dbo.om_momain om
+						join UFDATA_903_2021.dbo.OM_MODetails od on om.moid=od.moid
+						join UFDATA_903_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
+						WHERE om.iVerifyStateNew = 2 and (om.cCloser is null or om.cCloser='asuser')
+									and omi.cInvCcode like '19%' and od.csocode=rs.iordercode
+				) as ccode
+				from UFDATA_903_2021.dbo.rdrecords01 rs
+				join UFDATA_903_2021.dbo.Inventory i on rs.cInvCode=i.cInvCode
+				where (i.cInvCcode like '03%' or i.cInvCcode like '04%') and i.cInvCCode != '0399' and i.cInvCCode != '0499'
+				GROUP BY i.cInvName,rs.cBatch,rs.cFree1,rs.iordercode
+		)tab1
+		 join
+		(
+				select i.cInvName,sum(rs.iQuantity) as jian,rs.cBatch,rs.cFree1 from UFDATA_903_2021.dbo.rdrecords11 rs
+				join UFDATA_903_2021.dbo.Inventory i on rs.cInvCode=i.cInvCode
+				where iordercode in (
+						select distinct od.csocode
+						from UFDATA_903_2021.dbo.om_momain om
+						join UFDATA_903_2021.dbo.OM_MODetails od on om.moid=od.moid
+						join UFDATA_903_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
+						WHERE om.iVerifyStateNew = 2 and (om.cCloser is null or om.cCloser='asuser')
+									and omi.cInvCcode like '19%' and om.cCode like CONCAT(#{code},'%')
+				) and (i.cInvCcode like '03%' or i.cInvCcode like '04%') and i.cInvCCode != '0399' and i.cInvCCode != '0499'
+				and i.cInvName = #{goodName}
+				GROUP BY i.cInvName,rs.cBatch,rs.cFree1
+		)tab2 on tab2.cInvName=tab1.cInvName and tab1.cBatch=tab2.cBatch and tab1.cFree1=tab2.cFree1
+		where tab1.purchaseQuantity-tab2.jian>0
+    </select>
 </mapper>

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

@@ -235,35 +235,13 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
                                     "       group by MODetailsID " +
                                     "       ) o ON r.iOMoDID  = o.MODetailsID   " +
                                     "           group by b.cVenName,b.cInvName,b.cPOID,b.cfree1";
-            /*转入*/
-            String sqlTransfer = "     select b.cInvName as goodsName,b.cPOID as planCode,b.cfree1 as color,max(b.yi ) as number " +
-                                    "     FROM ( " +
-                                    "      select cBatch,cInvCode,iOMoDID from rdrecords11 where  cBatch is not null  " +
-                                    "      group by cBatch,cInvCode,iOMoDID  " +
-                                    "     ) r    " +
-                                    "    JOIN (    " +
-                                    "     SELECT od.MODetailsID     " +
-                                    "     FROM OM_MOMain om LEFT JOIN OM_MODetails od ON om.MOID = od.MOID     " +
-                                    "     WHERE om.iVerifyStateNew = 2 and om.cCode like '"+plannum+"%'    " +
-                                    "     group by MODetailsID " +
-                                    "         ) o ON r.iOMoDID  = o.MODetailsID   " +
-                                    "         JOIN (    " +
-                                    "         SELECT v.cVenName as cVenName,c.cInvName,rs1.cPOID,rs1.cfree1,rs1.cInvCode,rs1.cBatch, " +
-                                    "               sum(isnull(od.iSendQTY,0)+isnull(p.iQuantity,0)) as yi " +
-                                    "         FROM rdrecords01 rs1    " +
-                                    "     left join rdrecord01 r1 on r1.id=rs1.id   " +
-                                    "     left join PO_Podetails p on p.ID=rs1.iPOsID   " +
-                                    "     left join OM_MODetails o on o.MODetailsID =rs1.iOMoDID   " +
-                                    "     left join OM_MOMaterials od on od.MoDetailsID=o.MODetailsID   " +
-                                    "     LEFT JOIN Inventory  c on c.cInvCode=rs1.cInvCode   " +
-                                    "     LEFT JOIN Vendor v ON r1.cVenCode= v.cVenCode  " +
-                                    "          where rs1.cPOID not like '"+plannum+"%'"+// and v.cVenName='"+Fabric.getProcessUnit()+
-                                    " and c.cInvName='"+Fabric.getGoodsName()+"' " +
-                                    "     group BY v.cVenName,c.cInvName,rs1.cPOID,rs1.cfree1,rs1.cInvCode,rs1.cBatch " +
-                                    "        ) b on r.cBatch = b.cBatch and b.cInvCode=r.cInvCode  " +
-                                    "    group by b.cVenName,b.cInvName,b.cPOID,b.cfree1";
+
             List<Map<String, Object>> remainingList  = senYuDataSourceOne.queryForList(sqlRemaining);
-            List<Map<String, Object>> transferlist  = senYuDataSourceOne.queryForList(sqlTransfer);
+            //若转入数量不为0则给转入数据对象赋值
+            if(!Fabric.getFabrictransferQuantity().equals(0)){
+                List<SyTransfer> transferlist  = syCostAllocationFabricMapper.queryTransferByFabric(plannum,Fabric.getGoodsName());
+                Fabric.setSyTransfers(transferlist);
+            }
         }