以操作插件为例
public class DownlaodContract extends AbstractOperationServicePlugIn implements Plugin {
@Override
public void onPreparePropertys(PreparePropertysEventArgs e) {
super.onPreparePropertys(e);
e.getFieldKeys().add("yfsw_htzhuangtai");
}
@Override
public void onAddValidators(AddValidatorsEventArgs e) {
e.addValidator(new AbstractValidator() {
public void validate() {
for (ExtendedDataEntity rowDataEntity : this.getDataEntities()) {
DynamicObject dataEntity = rowDataEntity.getDataEntity();
String zhuangtai = dataEntity.getString("yfsw_htzhuangtai");
if(zhuangtai != "B" || zhuangtai != "C"){
this.addErrorMessage(rowDataEntity,"合同未签署或已作废");
}
}
}
});
}
@Override
public void afterExecuteOperationTransaction(AfterOperationArgs e) {
String privapi_url = "";
String documentId = "";
String url = privapi_url + "/document/download?documentId="+documentId;
super.afterExecuteOperationTransaction(e);
CloseableHttpClient httpClient = HttpClients.createDefault();
StringBuilder entityStringBuilder = null;
try {
HttpGet get = new HttpGet(url);
CloseableHttpResponse httpResponse = null;
httpResponse = httpClient.execute(get);
try {
HttpEntity entity = httpResponse.getEntity();
entityStringBuilder = new StringBuilder();
if (null != entity) {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(httpResponse.getEntity().getContent(), "UTF-8"), 8 * 1024);
String line = null;
while ((line = bufferedReader.readLine()) != null) {
entityStringBuilder.append(line + "/n");
}
}
} finally {
httpResponse.close();
}
} catch (Exception a) {
a.printStackTrace();
} finally {
try {
if (httpClient != null) {
httpClient.close();
}
} catch (IOException a) {
a.printStackTrace();
}
}
}
}
本文链接:https://www.naiteiy.site/index.php/archives/82/