数据服务脚本 Java Script
支持的接口
通过状态接口可以进行单据的审核(audit),撤销审核(unaudit),关闭(close),打开(open),锁定(lock),解锁(unlock),单据转换(get)等操作。
public interface IEntityStatusOperator {
Object status(ASRequest aRequest, String asOperation, Long aRecId) throws ASException ;
}
数据服务支持新增的函数
public Object status(ASRequest aRequest,String asAction, String asOperation, Long aRecId) throws ASException {
获得或修改字段的状态,主数据集中存在的字段
public interface IFieldValue {
int setFieldValue(ASRequest aRequest, Long aRecId, String asFieldCode, Object aValue) throws ASException;
Object getFieldValue(ASRequest aRequest, Long aRecId, String asFieldCode) throws ASException;
}
脚本路径
private static final String SCRIPT_DEL_BEF ="SCRIPT/DEL/BEF";
private static final String SCRIPT_DEL_AFT = "SCRIPT/DEL/AFT";
private static final String SCRIPT_AUDIT_BEF = "SCRIPT/AUDIT/BEF";
private static final String SCRIPT_AUDIT_AFT = "SCRIPT/AUDIT/AFT";
private static final String SCRIPT_UNAUDIT_BEF = "SCRIPT/UNAUDIT/BEF";
private static final String SCRIPT_UNAUDIT_AFT = "SCRIPT/UNAUDIT/AFT";
private static final String SCRIPT_LOCK_BEF = "SCRIPT/LOCK/BEF";
private static final String SCRIPT_LOCK_AFT= "SCRIPT/LOCK/AFT";
private static final String SCRIPT_UNLOCK_BEF = "SCRIPT/UNLOCK/BEF";
private static final String SCRIPT_UNLOCK_AFT = "SCRIPT/UNLOCK/AFT";
private static final String SCRIPT_CLOSE_BEF = "SCRIPT/CLOSE/BEF";
private static final String SCRIPT_CLOSE_AFT = "SCRIPT/CLOSE/AFT";
private static final String SCRIPT_OPEN_BEF = "SCRIPT/OPEN/BEF";
private static final String SCRIPT_OPEN_AFT = "SCRIPT/OPEN/AFT";
- 脚本举例
//更新该记录对应的字段中指向的其他记录的状态
public Object tryRefStatus(ASRequest aRequest,Long aRecId,String asDomainPath,String asField,String asOperation) throws ASException
审核时,循环执行存储过程
int i,l = param.idList.size();
var lp = new List();
for(i=0;i<l;i++) {
lp.clear();
lp.add(param.idList.get(i));
request.db().callProcedure("",lp);
}
<SCRIPT>
<DEL>
<BEF>
script.returnValue = -1;
script.message = '数据查询' + request.info().operation + request.db().getValue('select count(*) from t_cgdd where cgddid in ( ' + param.idSQLStr() + ') ',null)
</BEF>
<AFT>
script.returnValue = -1;
script.message = '后数据查询' + request.info().operation + request.db().getValue('select count(*) from t_cgdd where cgddid in ( ' + param.idSQLStr() + ') ',null)
</AFT>
</DEL>
<AUDIT>
<BEF>
script.returnValue = -1;
script.message = '数据查询' + request.info().operation + request.db().getValue('select count(*) from t_cgdd where cgddid in ( ' + param.idSQLStr() + ') ',null)
</BEF>
<AFT>
script.returnValue = -1;
script.message = '后数据查询' + request.info().operation + request.db().getValue('select count(*) from t_cgdd where cgddid in ( ' + param.idSQLStr() + ') ',null)
</AFT>
</AUDIT>
<UNAUDIT>
<BEF>
script.returnValue = -1;
script.message = '数据查询' + request.info().operation + request.db().getValue('select count(*) from t_cgdd where cgddid in ( ' + param.idSQLStr() + ') ',null)
</BEF>
<AFT>
script.returnValue = -1;
script.message = '后数据查询' + request.info().operation + request.db().getValue('select count(*) from t_cgdd where cgddid in ( ' + param.idSQLStr() + ') ',null)
</AFT>
</UNAUDIT>
<CLOSE>
<BEF>
script.returnValue = -1;
script.message = '数据查询' + request.info().operation + request.db().getValue('select count(*) from t_cgdd where cgddid in ( ' + param.idSQLStr() + ') ',null)
</BEF>
<AFT>
script.returnValue = -1;
script.message = '后数据查询' + request.info().operation + request.db().getValue('select count(*) from t_cgdd where cgddid in ( ' + param.idSQLStr() + ') ',null)
</AFT>
</CLOSE>
<OPEN>
<BEF>
script.returnValue = -1;
script.message = '数据查询' + request.info().operation + request.db().getValue('select count(*) from t_cgdd where cgddid in ( ' + param.idSQLStr() + ') ',null)
</BEF>
<AFT>
script.returnValue = -1;
script.message = '后数据查询' + request.info().operation + request.db().getValue('select count(*) from t_cgdd where cgddid in ( ' + param.idSQLStr() + ') ',null)
</AFT>
</OPEN>
<LOCK>
<BEF>
script.returnValue = -1;
script.message = '数据查询' + request.info().operation + request.db().getValue('select count(*) from t_cgdd where cgddid in ( ' + param.idSQLStr() + ') ',null)
</BEF>
<AFT>
script.returnValue = -1;
script.message = '后数据查询' + request.info().operation + request.db().getValue('select count(*) from t_cgdd where cgddid in ( ' + param.idSQLStr() + ') ',null)
</AFT>
</LOCK>
<UNLOCK>
<BEF>
script.returnValue = -1;
script.message = '数据查询' + request.info().operation + request.db().getValue('select count(*) from t_cgdd where cgddid in ( ' + param.idSQLStr() + ') ',null)
</BEF>
<AFT>
script.returnValue = -1;
script.message = '后数据查询' + request.info().operation + request.db().getValue('select count(*) from t_cgdd where cgddid in ( ' + param.idSQLStr() + ') ',null)
</AFT>
</UNLOCK>
</SCRIPT>
调用举例:
system.service(“.CGDD.DATA”).status(request,”lock”,flow.tranid);//锁定采购订单
system.service(“.CGDD.DATA”). setFieldValue (request, flow.tranid,
”tranmemo”,flow. shortmemo);//将流程的备注信息更新到单据。
数据服务可以触发事件,可以在工作流中使用
system.service(“.CGDD.DATA”).triggerEntityEvent(request,String asType,Long lRecId)
asType事件类型, lRecId 业务id
system.service('.CLAZDJ.DATA').status(request,'unlock',flow.tranid); 设置单据的状态
system.service('.CLAZDJ.DATA').setFieldValue(request,flow.tranid,'sfkaz','否'); 更新字段值
system.service('.CLAZDJ.DATA').setFieldValue(request,flow.tranid,'tranmemo',event.eventParam('comcontent')); 将点评内容更新到字段中
Created with the Personal Edition of HelpNDoc: Full-featured EPub generator