|
@@ -254,8 +254,42 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
|
|
|
List<SyCostAllocationFabric> list3 = new ArrayList<>();
|
|
|
for (int i=0;i<jianSon1.size();i++) {
|
|
|
SyCostAllocationFabric Fabric = JSONObject.toJavaObject(jianSon1.get(i), SyCostAllocationFabric.class);
|
|
|
+ /*
|
|
|
+ 1.转入:从材料出库起手,找到委外订单下使用的出库,然后关联采购排除不是自己买的;
|
|
|
+ -- 1.委外订单关联材料出库单,根据计划号查出所有材料出库;
|
|
|
+ -- 2.根据第一步查出的所有材料出库批次号+物料,查出所有的采购入库;
|
|
|
+ -- 3.根据第二步找到所有的采购订单
|
|
|
+ -- 4.根据第三步的采购订单用计划号not like ,找出所有不是本次采购的采购订单
|
|
|
+ 2.余下:从采购起手,找到所有的采购入库,然后关联材料出库,排除掉自己使用的 就是余下的
|
|
|
+ * */
|
|
|
/*余下*/
|
|
|
- String sqlRemaining = " SELECT v.cVenName,c.cInvName,rs1.cPOID,rs1.cfree1, " +
|
|
|
+ String sqlRemaining =" 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 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 and rs1.cPOID 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 " +
|
|
|
+ " JOIN ( " +
|
|
|
+ " SELECT od.MODetailsID " +
|
|
|
+ " FROM OM_MOMain om LEFT JOIN OM_MODetails od ON om.MOID = od.MOID " +
|
|
|
+ " WHERE om.cState = 1 and om.cCode not like '"+plannum+"%' " +
|
|
|
+ " group by MODetailsID " +
|
|
|
+ " ) o ON r.iOMoDID = o.MODetailsID " +
|
|
|
+ " group by b.cVenName,b.cInvName,b.cPOID,b.cfree1";
|
|
|
+/* " SELECT v.cVenName,c.cInvName,rs1.cPOID,rs1.cfree1, " +
|
|
|
" isnull(sum(od.iSendQTY),0)+isnull(sum(p.iQuantity),0) as yi " +
|
|
|
" FROM rdrecords01 rs1 " +
|
|
|
" left join rdrecord01 r1 on r1.id=rs1.id " +
|
|
@@ -266,9 +300,35 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
|
|
|
" LEFT JOIN Vendor v ON r1.cVenCode= v.cVenCode " +
|
|
|
" where rs1.cBatch != ' "+plannum+"' and rs1.cPOID like ' "+plannum+"%' and v.cVenName='"+Fabric.getProcessUnit()+
|
|
|
"' and c.cInvName='"+Fabric.getGoodsName()+"' " +
|
|
|
- " group BY v.cVenName,c.cInvName,rs1.cPOID,rs1.cfree1";
|
|
|
+ " group BY v.cVenName,c.cInvName,rs1.cPOID,rs1.cfree1";*/
|
|
|
/*转入*/
|
|
|
- String sqlTransfer = " SELECT v.cVenName,c.cInvName,rs1.cPOID,rs1.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.cState = 1 and om.cCode like 'SYA520R%' " +
|
|
|
+ " 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";
|
|
|
+ /*" SELECT v.cVenName,c.cInvName,rs1.cPOID,rs1.cfree1, " +
|
|
|
" isnull(sum(od.iSendQTY),0)+isnull(sum(p.iQuantity),0) as yi " +
|
|
|
" FROM rdrecords01 rs1 " +
|
|
|
" left join rdrecord01 r1 on r1.id=rs1.id " +
|
|
@@ -279,7 +339,7 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
|
|
|
" LEFT JOIN Vendor v ON r1.cVenCode= v.cVenCode " +
|
|
|
" where rs1.cBatch = ' "+plannum+"' and 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";
|
|
|
+ " group BY v.cVenName,c.cInvName,rs1.cPOID,rs1.cfree1";*/
|
|
|
List<Map<String, Object>> remainingList = senYuDataSourceOne.queryForList(sqlRemaining);
|
|
|
if(remainingList.size()>0){
|
|
|
List<JSONObject> remainingJson = JsonChangeUtils.toJSONObject(remainingList);
|
|
@@ -364,7 +424,33 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
|
|
|
for (int i=0;i<jianSon2.size();i++) {
|
|
|
SyCostAllocationIngredient Ingredient = JSONObject.toJavaObject(jianSon2.get(i), SyCostAllocationIngredient.class);
|
|
|
/*余下*/
|
|
|
- String sqlRemaining = " SELECT v.cVenName,c.cInvName,rs1.cPOID,rs1.cfree1, " +
|
|
|
+ String sqlRemaining =" 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 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 and rs1.cPOID like '"+plannum+"%' and v.cVenName='"+Ingredient.getProcessUnit()+
|
|
|
+ "' and c.cInvName='"+Ingredient.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 " +
|
|
|
+ " JOIN ( " +
|
|
|
+ " SELECT od.MODetailsID " +
|
|
|
+ " FROM OM_MOMain om LEFT JOIN OM_MODetails od ON om.MOID = od.MOID " +
|
|
|
+ " WHERE om.cState = 1 and om.cCode not like '"+plannum+"%' " +
|
|
|
+ " group by MODetailsID " +
|
|
|
+ " ) o ON r.iOMoDID = o.MODetailsID " +
|
|
|
+ " group by b.cVenName,b.cInvName,b.cPOID,b.cfree1";
|
|
|
+ /*" SELECT v.cVenName,c.cInvName,rs1.cPOID,rs1.cfree1, " +
|
|
|
" isnull(sum(od.iSendQTY),0)+isnull(sum(p.iQuantity),0) as yi " +
|
|
|
" FROM rdrecords01 rs1 " +
|
|
|
" left join rdrecord01 r1 on r1.id=rs1.id " +
|
|
@@ -375,9 +461,35 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
|
|
|
" LEFT JOIN Vendor v ON r1.cVenCode= v.cVenCode " +
|
|
|
" where rs1.cBatch != ' "+plannum+"' and rs1.cPOID like ' "+plannum+"%' and v.cVenName='"+Ingredient.getProcessUnit()+
|
|
|
"' and c.cInvName='"+Ingredient.getGoodsName()+"' " +
|
|
|
- " group BY v.cVenName,c.cInvName,rs1.cPOID,rs1.cfree1";
|
|
|
+ " group BY v.cVenName,c.cInvName,rs1.cPOID,rs1.cfree1";*/
|
|
|
/*转入*/
|
|
|
- String sqlTransfer = " SELECT v.cVenName,c.cInvName,rs1.cPOID,rs1.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.cState = 1 and om.cCode like 'SYA520R%' " +
|
|
|
+ " 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='"+Ingredient.getProcessUnit()+
|
|
|
+ "' and c.cInvName='"+Ingredient.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";
|
|
|
+ /* " SELECT v.cVenName,c.cInvName,rs1.cPOID,rs1.cfree1, " +
|
|
|
" isnull(sum(od.iSendQTY),0)+isnull(sum(p.iQuantity),0) as yi " +
|
|
|
" FROM rdrecords01 rs1 " +
|
|
|
" left join rdrecord01 r1 on r1.id=rs1.id " +
|
|
@@ -388,7 +500,7 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
|
|
|
" LEFT JOIN Vendor v ON r1.cVenCode= v.cVenCode " +
|
|
|
" where rs1.cBatch = ' "+plannum+"' and rs1.cPOID not like ' "+plannum+"%' and v.cVenName='"+Ingredient.getProcessUnit()+
|
|
|
"' and c.cInvName='"+Ingredient.getGoodsName()+"' " +
|
|
|
- " group BY v.cVenName,c.cInvName,rs1.cPOID,rs1.cfree1";
|
|
|
+ " group BY v.cVenName,c.cInvName,rs1.cPOID,rs1.cfree1";*/
|
|
|
List<Map<String, Object>> remainingList = senYuDataSourceOne.queryForList(sqlRemaining);
|
|
|
if(remainingList.size()>0){
|
|
|
List<JSONObject> remainingJson = JsonChangeUtils.toJSONObject(remainingList);
|