Commit d8a95281 authored by chengwenlong's avatar chengwenlong

用友接口空指针异常处理

parent 387c0206
......@@ -141,18 +141,24 @@ public class WagesServiceImpl implements WagesService {
if(index==-1){
index = sourceOfExpenses.indexOf(")");
}
if(index>=0){
String lbname=sourceOfExpenses.substring(index+1);
String lbname2="项目";
//用友取数
CustomDocRequestModel docRequest = new CustomDocRequestModel();
docRequest.setPageIndex(Long.valueOf(1L));
docRequest.setPageSize(Long.valueOf(500L));
docRequest.setName(lbname);
String codeFromCustomDoc = "";
JSONArray customDoc = getCustomDoc(docRequest);
codeFromCustomDoc = getCodeFromCustomDoc(customDoc, lbname2);
jsonObject1.put("auxiliary_item_b",lbname2+":"+codeFromCustomDoc+"/"+lbname);
if(index>=0) {
String lbname = sourceOfExpenses.substring(index + 1);
String lbname2 = "项目";
//用友接口取数
CustomDocRequestModel docRequest = new CustomDocRequestModel();
docRequest.setPageIndex(Long.valueOf(1L));
docRequest.setPageSize(Long.valueOf(500L));
docRequest.setName(lbname);
String codeFromCustomDoc = "";
JSONArray customDoc = getCustomDoc(docRequest);
//如果用友返回不为空
if (customDoc!=null){
codeFromCustomDoc = getCodeFromCustomDoc(customDoc, lbname2);
if(codeFromCustomDoc!=null){
jsonObject1.put("auxiliary_item_b", lbname2 + ":" + codeFromCustomDoc + "/" + lbname);
}
}
}
}
......@@ -196,8 +202,14 @@ public class WagesServiceImpl implements WagesService {
public JSONArray getCustomDoc(CustomDocRequestModel customDocRequestModel) {
ReturnResult customDocument = VoucherUtils.callVoucherQuery(customDocRequestModel, "/yonbip/digitalModel/customerdoc/list");
JSONObject customDocumentJsonObj = (JSONObject)JSON.toJSON(customDocument.getData().get(0));
return customDocumentJsonObj.getJSONArray("recordList");
if(customDocument!=null){
JSONObject customDocumentJsonObj = (JSONObject)JSON.toJSON(customDocument.getData().get(0));
return customDocumentJsonObj.getJSONArray("recordList");
}
else{
return null;
}
}
private String getCodeFromCustomDoc(JSONArray customDoc, String nameZhCn) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment