Commit d8a95281 authored by chengwenlong's avatar chengwenlong

用友接口空指针异常处理

parent 387c0206
...@@ -141,18 +141,24 @@ public class WagesServiceImpl implements WagesService { ...@@ -141,18 +141,24 @@ public class WagesServiceImpl implements WagesService {
if(index==-1){ if(index==-1){
index = sourceOfExpenses.indexOf(")"); index = sourceOfExpenses.indexOf(")");
} }
if(index>=0){ if(index>=0) {
String lbname=sourceOfExpenses.substring(index+1); String lbname = sourceOfExpenses.substring(index + 1);
String lbname2="项目"; String lbname2 = "项目";
//用友取数 //用友接口取数
CustomDocRequestModel docRequest = new CustomDocRequestModel(); CustomDocRequestModel docRequest = new CustomDocRequestModel();
docRequest.setPageIndex(Long.valueOf(1L)); docRequest.setPageIndex(Long.valueOf(1L));
docRequest.setPageSize(Long.valueOf(500L)); docRequest.setPageSize(Long.valueOf(500L));
docRequest.setName(lbname); docRequest.setName(lbname);
String codeFromCustomDoc = ""; String codeFromCustomDoc = "";
JSONArray customDoc = getCustomDoc(docRequest); JSONArray customDoc = getCustomDoc(docRequest);
//如果用友返回不为空
if (customDoc!=null){
codeFromCustomDoc = getCodeFromCustomDoc(customDoc, lbname2); codeFromCustomDoc = getCodeFromCustomDoc(customDoc, lbname2);
jsonObject1.put("auxiliary_item_b",lbname2+":"+codeFromCustomDoc+"/"+lbname); if(codeFromCustomDoc!=null){
jsonObject1.put("auxiliary_item_b", lbname2 + ":" + codeFromCustomDoc + "/" + lbname);
}
}
} }
} }
...@@ -196,9 +202,15 @@ public class WagesServiceImpl implements WagesService { ...@@ -196,9 +202,15 @@ public class WagesServiceImpl implements WagesService {
public JSONArray getCustomDoc(CustomDocRequestModel customDocRequestModel) { public JSONArray getCustomDoc(CustomDocRequestModel customDocRequestModel) {
ReturnResult customDocument = VoucherUtils.callVoucherQuery(customDocRequestModel, "/yonbip/digitalModel/customerdoc/list"); ReturnResult customDocument = VoucherUtils.callVoucherQuery(customDocRequestModel, "/yonbip/digitalModel/customerdoc/list");
if(customDocument!=null){
JSONObject customDocumentJsonObj = (JSONObject)JSON.toJSON(customDocument.getData().get(0)); JSONObject customDocumentJsonObj = (JSONObject)JSON.toJSON(customDocument.getData().get(0));
return customDocumentJsonObj.getJSONArray("recordList"); return customDocumentJsonObj.getJSONArray("recordList");
} }
else{
return null;
}
}
private String getCodeFromCustomDoc(JSONArray customDoc, String nameZhCn) { private String getCodeFromCustomDoc(JSONArray customDoc, String nameZhCn) {
String code = null; String code = null;
......
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