|
@@ -1,28 +1,27 @@
|
|
|
package fi.er.webService;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import kd.bos.context.RequestContext;
|
|
|
import kd.bos.dataentity.OperateOption;
|
|
|
import kd.bos.dataentity.entity.DynamicObject;
|
|
|
-import kd.bos.dataentity.entity.DynamicObjectCollection;
|
|
|
import kd.bos.entity.operate.result.OperationResult;
|
|
|
+import kd.bos.logging.Log;
|
|
|
+import kd.bos.logging.LogFactory;
|
|
|
import kd.bos.openapi.common.custom.annotation.ApiController;
|
|
|
import kd.bos.openapi.common.custom.annotation.ApiMapping;
|
|
|
import kd.bos.openapi.common.custom.annotation.ApiParam;
|
|
|
import kd.bos.openapi.common.custom.annotation.ApiPostMapping;
|
|
|
-import kd.bos.orm.query.QCP;
|
|
|
+import kd.bos.openapi.common.result.CustomApiResult;
|
|
|
import kd.bos.orm.query.QFilter;
|
|
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|
|
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
|
|
-import kd.bos.util.StringUtils;
|
|
|
+import nckd.jimin.jyyy.fi.common.NstcApiReturnModel;
|
|
|
import java.io.Serializable;
|
|
|
-import java.math.BigDecimal;
|
|
|
-import java.math.RoundingMode;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* @author zf
|
|
@@ -32,6 +31,8 @@ import java.util.Map;
|
|
|
@ApiMapping(value = "saveBankApi")
|
|
|
public class SaveBankApi implements Serializable {
|
|
|
protected static final Long DEFAULT_ORG_ID = 100000L;
|
|
|
+ private static final Log logger = LogFactory.getLog(SaveAccountApi.class);
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* @description 行名行号同步接口
|
|
@@ -39,7 +40,7 @@ public class SaveBankApi implements Serializable {
|
|
|
* @return CustomApiResult
|
|
|
*/
|
|
|
@ApiPostMapping(value = "/save", desc = "同步行名行号")
|
|
|
- public CustomApiResultForMy<List<BankSynReturnModel>> saveBank (@ApiParam(value = "九恒星行名行号") JSONArray data) {
|
|
|
+ public CustomApiResult<JSONObject> saveBank (@ApiParam(value = "九恒星行名行号") JSONArray data) {
|
|
|
StringBuilder resultString = new StringBuilder();
|
|
|
List<BankSynReturnModel> returnList = new ArrayList<>();
|
|
|
Boolean result = true;
|
|
@@ -51,18 +52,48 @@ public class SaveBankApi implements Serializable {
|
|
|
RequestContext rc = RequestContext.get();
|
|
|
DynamicObject user = BusinessDataServiceHelper.loadSingleFromCache(rc.getCurrUserId(), "bos_user");
|
|
|
|
|
|
+ JSONArray dataArray = new JSONArray();
|
|
|
+
|
|
|
+ if(data == null || data.size() == 0){
|
|
|
+ return returnResult("500", "E", "接口调用失败,data无实际数据", null);
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONObject dataJSON = data.getJSONObject(0);
|
|
|
+ if(dataJSON.get("param0") == null){
|
|
|
+ return returnResult("500", "E", "接口调用失败,param0无实际数据", null);
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONArray paramArray = dataJSON.getJSONArray("param0");
|
|
|
+ if(paramArray == null || paramArray.size() == 0){
|
|
|
+ return returnResult("500", "E", "接口调用失败,param0无实际数据", null);
|
|
|
+ }
|
|
|
+
|
|
|
//循环传入的数据
|
|
|
- for (int i = 0; i < data.size(); i++) {
|
|
|
- JSONObject eobject = data.getJSONObject(i);
|
|
|
- BankSynReturnModel contractSynReturnModel = syncBank(eobject,defaultgj,user);
|
|
|
- if ("500".equals(contractSynReturnModel.getCode())){
|
|
|
- result = false;
|
|
|
+ for (int i = 0; i < paramArray.size(); i++) {
|
|
|
+ JSONObject eobject = paramArray.getJSONObject(i);
|
|
|
+
|
|
|
+ try {
|
|
|
+ NstcApiReturnModel contractSynReturnModel = syncBank(eobject, defaultgj, user);
|
|
|
+ if ("500".equals(contractSynReturnModel.getCode())) {
|
|
|
+ result = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ dataArray.add(JSONObject.parseObject(JSON.toJSONString(contractSynReturnModel)));
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error("保存银行账号失败:{}", e.getMessage());
|
|
|
+
|
|
|
+ NstcApiReturnModel returnModel = new NstcApiReturnModel();
|
|
|
+
|
|
|
+ returnModel.setNumber(eobject.get("number")+"");
|
|
|
+ returnModel.setName(eobject.get("name")+"");
|
|
|
+ returnModel.setCode("500");
|
|
|
+ returnModel.setMessage("保存银行账号失败: " + e.getMessage());
|
|
|
+
|
|
|
+ dataArray.add(JSONObject.parseObject(JSON.toJSONString(returnModel)));
|
|
|
}
|
|
|
- returnList.add(contractSynReturnModel);
|
|
|
}
|
|
|
- return result == true
|
|
|
- ? CustomApiResultForMy.success2(returnList)
|
|
|
- : CustomApiResultForMy.fail(returnList);
|
|
|
+
|
|
|
+ return returnResult("200", "S", "接口调用成功,同步结果请查看responseData参数", dataArray);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -70,8 +101,8 @@ public class SaveBankApi implements Serializable {
|
|
|
* @description 保存行名行号
|
|
|
* @param jsonObject
|
|
|
*/
|
|
|
- private BankSynReturnModel syncBank(JSONObject jsonObject,DynamicObject defaultgj ,DynamicObject user) {
|
|
|
- BankSynReturnModel contractSynReturnModel = new BankSynReturnModel();
|
|
|
+ private NstcApiReturnModel syncBank(JSONObject jsonObject,DynamicObject defaultgj ,DynamicObject user) {
|
|
|
+ NstcApiReturnModel contractSynReturnModel = new NstcApiReturnModel();
|
|
|
String number = jsonObject.get("number")+"";
|
|
|
String name = jsonObject.get("name")+"";
|
|
|
if ("".equals(number)||"".equals(name)) {
|
|
@@ -132,4 +163,27 @@ public class SaveBankApi implements Serializable {
|
|
|
return contractSynReturnModel;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 自定义返回data对象
|
|
|
+ * @param code 编码
|
|
|
+ * @param message 错误信息
|
|
|
+ * @return CustomApiResult 返回
|
|
|
+ */
|
|
|
+ public CustomApiResult<JSONObject> returnResult(String code, String status, String message, JSONArray dataArrary){
|
|
|
+ JSONObject reslutData = new JSONObject();
|
|
|
+
|
|
|
+ JSONArray responseData = new JSONArray();
|
|
|
+ JSONObject dataJSON = new JSONObject();
|
|
|
+ dataJSON.put("data", dataArrary);
|
|
|
+
|
|
|
+ responseData.add(dataJSON);
|
|
|
+
|
|
|
+ reslutData.put("code", code);
|
|
|
+ reslutData.put("status", status);
|
|
|
+ reslutData.put("message", message);
|
|
|
+ reslutData.put("responseData", responseData);
|
|
|
+
|
|
|
+ return CustomApiResult.success(reslutData);
|
|
|
+ }
|
|
|
}
|