Model Validator Table Event
====================
import groovy.sql.Sql
import java.sql.Timestamp
import java.sql.PreparedStatement
import java.sql.ResultSet
import org.compiere.util.Env
import org.compiere.util.DB
// PostgreSQL// A_Ctx A_PO A_Type A_Event
postsql =Sql.newInstance('jdbc:postgresql://127.0.0.1/taya1028','adempiere','adempiere','org.postgresql.Driver' )
def ptable= postsql.dataSet("需求領用") // 製造命令[ 需求領用 ]
def isActive='Y'
def H_ID=1000000
def m_created = new Timestamp(System.currentTimeMillis());
def t_start = System.currentTimeMillis()
def parent_id=((Integer)A_PO.getValue("製造命令_ID")).intValue();
def id=0
def uu=' '
int client=Env.getContextAsInt(A_Ctx, "AD_Client_ID");
int org=Env.getContextAsInt(A_Ctx, "AD_Org_ID");
int uid=Env.getContextAsInt(A_Ctx, "#AD_User_ID");
mssql.eachRow( 'SELECT "品號_id","品名","規格","需領用量","已領用量","未領用量" FROM "需求領用" ' )
{
// select * from adempiere.AD_Sequence WHERE Name='船期與貨況追蹤'--1000346
postsql .query("select adempiere.nextid(1000321, 'N') as id , adempiere.generate_uuid() as uu ")
{ ResultSet rs ->
if (rs.next()){ id = rs.getInt('id')
uu = rs.getString('uu') }
}
println " ${it.品號_id} ${it.品名} "
ptable.add(
"品號_id": it.品號_id, "品名": it.品名, "規格":it.規格, "需領用量":it.需領用量, "已領用量":it.已領用量, "未領用量":it.已領用量
ad_client_id:client, ad_org_id:org, isactive: 'Y', created:m_created , createdby:uid, updated:m_created, updatedby:uid,
"需求用量_id":id, "需求用量_uu":uu, "製造命令_id":record_ID
)
}
def t_end = System.currentTimeMillis()
result="執行完成: " + (t_end - t_start)
沒有留言:
張貼留言