|
@@ -309,6 +309,41 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
|
|
|
/*查询U8数据 面料*/
|
|
|
|
|
|
String sqlFabric ="SELECT cInvName as goodsName,sum(yi) as usageQuantity,sum(ying) as planQuantity,sum(gou) as purchaseQuantity," +
|
|
|
+ "processUnit,isnull(sum(gou),0)-isnull(sum(yuu),0) as fabricremainingQuantity,sum(yu) as fabrictransferQuantity FROM ( " +
|
|
|
+ " " +
|
|
|
+ " select sum(r.iQuantity) as yu,r.cBatch ,b.cSource,b.cPOID,sum(b.gou) as gou,sum(b.yi) as yi,sum(b.ying) as ying " +
|
|
|
+ " ,c.cInvName ,v.cVenName as processUnit ,( " +
|
|
|
+ " SELECT sum(r.iQuantity) " +
|
|
|
+ " FROM UFDATA_903_2021.dbo.rdrecords01 rs1 " +
|
|
|
+ " left join UFDATA_903_2021.dbo.rdrecord01 r1 on r1.id=rs1.id " +
|
|
|
+ " where rs1.cBatch = '"+plannum+"' and rs1.cPOID like '"+plannum+"%' and " +
|
|
|
+ " r.cBatch = rs1.cBatch and rs1.cInvCode=r.cInvCode " +
|
|
|
+ " group by rs1.cInvCode, rs1.cBatch ) as yuu " +
|
|
|
+ " FROM UFDATA_903_2021.dbo.rdrecords11 r " +
|
|
|
+ " JOIN ( " +
|
|
|
+ " SELECT od.MODetailsID,od.cInvCode,om.cVenCode " +
|
|
|
+ " FROM UFDATA_903_2021.dbo.OM_MOMain om LEFT JOIN UFDATA_903_2021.dbo.OM_MODetails od ON om.MOID = od.MOID " +
|
|
|
+ " WHERE om.cState = 1 and om.cCode like '"+plannum+"%' " +
|
|
|
+ " ) o ON r.iOMoDID = o.MODetailsID " +
|
|
|
+ " LEFT JOIN ( " +
|
|
|
+ " SELECT r1.id,r1.cSource,rs1.cBatch,rs1.cInvCode ,rs1.cPOID, " +
|
|
|
+ " rs1.iQuantity as gou,isnull(od.iQuantity,0)+isnull(p.iQuantity,0) as ying,isnull(od.iSendQTY,0)+isnull(p.iQuantity,0) as yi " +
|
|
|
+ " FROM UFDATA_903_2021.dbo.rdrecords01 rs1 " +
|
|
|
+ " left join UFDATA_903_2021.dbo.rdrecord01 r1 on r1.id=rs1.id " +
|
|
|
+ " left join UFDATA_903_2021.dbo.PO_Podetails p on p.ID=rs1.iPOsID " +
|
|
|
+ " left join UFDATA_903_2021.dbo.OM_MODetails o on o.MODetailsID =rs1.iOMoDID " +
|
|
|
+ " left join UFDATA_903_2021.dbo.OM_MOMaterials od on od.MoDetailsID=o.MODetailsID " +
|
|
|
+ " where rs1.cBatch = '"+plannum+"' " +
|
|
|
+ " ) b on r.cBatch = b.cBatch and b.cInvCode=r.cInvCode " +
|
|
|
+ " " +
|
|
|
+ " LEFT JOIN (SELECT * FROM UFDATA_903_2021.dbo.Inventory where (cInvCCode like '03%' or cInvCCode like '04%' ) " +
|
|
|
+ " and cInvCCode != '0399' and cInvCCode != '0499') c on c.cInvCode=r.cInvCode " +
|
|
|
+ " LEFT JOIN UFDATA_903_2021.dbo.Vendor v ON o.cVenCode= v.cVenCode " +
|
|
|
+ " GROUP BY c.cInvName,r.cBatch,b.cSource,b.cPOID,v.cVenName ,r.cInvCode " +
|
|
|
+ " " +
|
|
|
+ " ) as ta GROUP BY cInvName,processUnit" +
|
|
|
+ "union all " +
|
|
|
+ "SELECT cInvName as goodsName,sum(yi) as usageQuantity,sum(ying) as planQuantity,sum(gou) as purchaseQuantity," +
|
|
|
"processUnit,isnull(sum(gou),0)-isnull(sum(yuu),0) as fabricremainingQuantity,sum(yu) as fabrictransferQuantity FROM ( " +
|
|
|
" " +
|
|
|
" select sum(r.iQuantity) as yu,r.cBatch ,b.cSource,b.cPOID,sum(b.gou) as gou,sum(b.yi) as yi,sum(b.ying) as ying " +
|
|
@@ -341,7 +376,7 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
|
|
|
" LEFT JOIN Vendor v ON o.cVenCode= v.cVenCode " +
|
|
|
" GROUP BY c.cInvName,r.cBatch,b.cSource,b.cPOID,v.cVenName ,r.cInvCode " +
|
|
|
" " +
|
|
|
- " ) as ta GROUP BY cInvName,processUnit;";
|
|
|
+ " ) as ta GROUP BY cInvName,processUnit" ;
|
|
|
|
|
|
List<Map<String, Object>> list1 = senYuDataSourceOne.queryForList(sqlFabric);
|
|
|
List<JSONObject> jianSon1 = JsonChangeUtils.toJSONObject(list1);
|