金蝶提交生效和提交工作流按钮调用接口含多人部分,通过视图找到按钮所用方法就可以在方法里面添加想要的逻辑,完成功能。
/*
*
* 提交生效
*/
protected IObjectPK _submitEffect(Context ctx, CoreBaseInfo model)
throws BOSException, EASBizException {
IObjectPK objectPK = super._submitEffect(ctx, model);
// 金蝶验证通过,调用接口
EmpHireBizBillInfo content = (EmpHireBizBillInfo) model;
EmpHireBizBillEntryCollection entrys = content.getEntrys();
Object[] contentLength = entrys.toArray();
String hrOrgUnitId = entrys.get(0).getHrOrgUnit().getId().toString();
FullOrgUnitInfo fullOrgUnitInfo = FullOrgUnitFactory.
getLocalInstance(ctx).getFullOrgUnitInfo(new ObjectUuidPK(hrOrgUnitId));
if (LongNumberUtil.isSameParentOrg(ctx, fullOrgUnitInfo.getLongNumber())) {
List<Object> list = new ArrayList<Object>();
List<Object> list1 = new ArrayList<Object>();
for (int i = 0; i < contentLength .length; i++) {
// 调动员工
PersonInfo personInfo = PersonFactory.getLocalInstance(ctx)
.getPersonInfo(new ObjectUuidPK(entrys.get(i).getPerson().getId().toString()));
if (personInfo != null) {
Map<String, String> map = new HashMap<String, String>();
// 身份证
map.put("idcard", personInfo.getIdCardNO());
//人员状态
map.put("status", "12");
// 转正日期
map.put("changeDate", entrys.get(i).getBizDate().toString());
list.add(map);
list1.add(personInfo.getName());
}
}
// 调用接口给接口传值
//HjNetUrl.REGULAR接口路径
//调用接口工具类
String postByJson = HttpUtil.postByJson(HjNetUrl.REGULAR, null,
JSONUtils.toJSONString(list));
if (postByJson == null) {
throw new BOSException("异常,接口不通");
}
Map mapJson = JSON.parseObject(postByJson);
Map<String, String> mes = new HashMap<String, String>();
mes.put("name", "员工姓名" + list1 + "转正");
mes.put("message", "(异常)" + mapJson.get("message").toString());
mes.put("code", mapJson.get("code").toString());
mes.put("success", mapJson.get("success").toString());
if (!(mapPostByJson.get("code").toString().equals("200"))) {
throw new BOSException(JSONObject.toJSONString(mes));
}
}
return objectPK;
}
/*
* 设置审批通过
*/
protected void _setAudited(Context ctx, BOSUuid billID)
throws BOSException, EASBizException {
super._setAudited(ctx, billID);
EmpHireBizBillEntryCollection EmpHireBizBill = null;
try {
EmpHireBizBill = EmpHireBizBillEntryFactory.getLocalInstance(ctx)
.getEmpHireBizBillEntryCollection(
"where bill = '" + billID.toString() + "'");
} catch (BOSException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String hrOrgUnitId=EmpHireBizBill.get(0).getHrOrgUnit().getId().toString();
FullOrgUnitInfo fullOrgUnitInfo = FullOrgUnitFactory.
getLocalInstance(ctx).getFullOrgUnitInfo(new ObjectUuidPK(hrOrgUnitId));
if (LongNumberUtil.isSameParentOrg(ctx,fullOrgUnitInfo.getLongNumber() )) {
if (EmpHireBizBill != null) {
List<Object> list = new ArrayList<Object>();
List<Object> list1 = new ArrayList<Object>();
for (int i = 0; i < EmpHireBizBill.size(); i++) {
Map<String, String> map = new HashMap<String, String>();
// 调动员工
PersonInfo personInfo = PersonFactory.getLocalInstance(ctx)
.getPersonInfo(new ObjectUuidPK(EmpHireBizBill.get(i).getPerson().getId().toString()));
// 身份证
map.put("idcard", personInfo.getIdCardNO());
//人员状态
map.put("status", "12");
// 转正日期
map.put("changeDate", EmpHireBizBill.get(i).getBizDate().toString());
list.add(map);
list1.add(personInfo.getName());
}
// 给接口传值
//HjNetUrl.REGULAR接口路径
//调用接口工具类
String postByJson = HttpUtil.postByJson(HjNetUrl.REGULAR, null,
JSONUtils.toJSONString(list));
if (postByJson == null) {
throw new BOSException("异常,接口不通");
}
Map mapJson = JSON.parseObject(postByJson);
Map<String, String> mes = new HashMap<String, String>();
mes
.put("name", "员工姓名" + list1
+ "转正");
mes.put("code", mapJson.get("code").toString());
mes.put("message", "(异常)"
+ mapPostByJson.get("message").toString());
mes.put("success", mapJson.get("success").toString());
if (!(mapJson.get("code").toString().equals("200"))) {
throw new BOSException(mes.get("message"));
}
}
}
}
接口工具类HttpUtil
public class HttpUtil {
private static Logger logger =
Logger.getLogger("com.kingdee.shr.affair.web.handler.util");
public static String postByJson(final String url, final Map<String, String> headers, final String bodyJson) {
final HttpClient httpclient = (HttpClient)new DefaultHttpClient();
try {
final HttpPost httppost = new HttpPost(url);
if (headers != null) {
for (final String key : headers.keySet()) {
httppost.setHeader(key, String.valueOf(headers.get(key)));
}
}
final StringEntity stringEntity = new StringEntity(bodyJson, "Utf-8");
stringEntity.setContentType("application/json");
httppost.setEntity((HttpEntity)stringEntity);
httppost.setHeader("Content-type", "application/json");
RequestConfig requestConfig = RequestConfig.custom()
.setConnectTimeout(10000).setConnectionRequestTimeout(1000)
.setSocketTimeout(5000).build();
httppost.ssetConfig(requestConfig);
final HttpResponse response = httpclient.execute((HttpUriRequest)httppost);
final HttpEntity resEntity = response.getEntity();
final String result = EntityUtils.toString(resEntity);
return result;
}
catch (IOException e) {
logger.error(e.getMessage());
}
finally {
httpclient.getConnectionManager().shutdown();
}
return null;
}
}
本文介绍了如何在金蝶系统中调用接口,特别是提交生效和工作流的接口,通过查看视图方法并添加逻辑来完成功能。使用了HttpUtil作为接口工具类。
1705

被折叠的 条评论
为什么被折叠?



