import java.sql.Timestamp
import java.math.BigDecimal
import java.sql.PreparedStatement
import java.sql.ResultSet
import org.compiere.util.DB
import org.compiere.model.MInOut
import org.compiere.model.MInOutLine
import org.compiere.model.MProduct
int v_count = 0
String sql = "SELECT l.ad_client_id, l.ad_org_id, l.jd_ordergenshipmentline_id, l.jd_ordergenshipmentline_uu, l.c_bpartner_id, l.po_reference, l.documentno, l.m_product_id, l.m_product_value, l.m_product_name, l.qtyordered, l.qtydelivered, l.qtyundelivered, l.qtyshipment, l.c_orderline_id, l.c_order_id, o.c_bpartner_location_id, o.m_warehouse_id, o.poreference, o.deliveryrule,o.freightcostrule, o.deliveryviarule, o.priorityrule, o.c_doctype_id, d.m_locator_id, d.c_uom_id, od.c_doctypeshipment_id FROM adempiere.jd_ordergenshipmentline l INNER JOIN adempiere.c_order o ON o.c_order_id=l.c_order_id INNER JOIN adempiere.m_product d ON d.m_product_id=l.m_product_id INNER JOIN adempiere.c_doctype od ON od.c_doctype_id=o.c_doctype_id "
// 請加上條件
// WHERE l.jd_ordergenshipment_id=? "
// A_Ctx A_Trx A_TrxName A_Record_ID A_AD_Client_ID A_AD_User_ID A_AD_PInstance_ID A_Table_ID
//
MInOut shipment = null;
PreparedStatement pstmt = DB.prepareStatement(sql, A_TrxName);
// pstmt.setInt(1, A_Record_ID);
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
if (shipment ==null){
shipment = new MInOut (A_Ctx, 0, A_TrxName);
shipment.setAD_Client_ID (rs.getInt("ad_client_id"));
shipment.setAD_Org_ID (rs.getInt("ad_org_id"));
shipment.setC_DocType_ID(rs.getInt("c_doctypeshipment_id"));
shipment.setDescription('jd_wsgenshipment');
shipment.setC_Order_ID(rs.getInt("c_order_id"));
shipment.setC_BPartner_ID(rs.getInt("c_bpartner_id"));
shipment.setC_BPartner_Location_ID(rs.getInt("c_bpartner_location_id"));
shipment.setM_Warehouse_ID(rs.getInt("m_warehouse_id"));
shipment.setPOReference(rs.getString("poreference"));
shipment.setDeliveryRule(rs.getString("deliveryrule"));
shipment.setFreightCostRule(rs.getString("freightcostrule"));
shipment.setDeliveryViaRule(rs.getString("deliveryviarule"));
shipment.setPriorityRule(rs.getString("priorityrule"));
shipment.save(A_TrxName);
}
sline = new MInOutLine (shipment );
sline.setDescription("jd_wsgenshipment");
sline.setC_OrderLine_ID(rs.getInt("c_orderline_id"));
sline.setM_Locator_ID(rs.getInt("m_locator_id"));
sline.setM_Product_ID(rs.getInt("m_product_id"));
sline.setC_UOM_ID(rs.getInt("c_uom_id"));
sline.setMovementQty(rs.getBigDecimal("qtyshipment"));
sline.setQtyEntered(rs.getBigDecimal("qtyshipment"));
sline.save(A_TrxName);
}
rs.close();
pstmt.close();
result=sql
沒有留言:
張貼留言