|
@@ -26,10 +26,8 @@ import javax.validation.Valid;
|
|
|
import java.io.Serializable;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.ParseException;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* SRM系统调用,付款同步接口
|
|
@@ -55,7 +53,7 @@ public class SRMSynPayApiPlugin implements Serializable {
|
|
|
@Valid @ApiParam(value = "付款申请") JSONArray bizAccountOutBills,
|
|
|
@Valid @ApiParam(value = "预付款") JSONArray dailyLoanBills) {
|
|
|
if(bizAccountOutBills == null && dailyLoanBills == null){
|
|
|
- return returnResult("E", "失败,bizAccountOutBills、dailyLoanBills参数不能同时为空", null);
|
|
|
+ return returnResult("1", "失败,bizAccountOutBills、dailyLoanBills参数不能同时为空", null);
|
|
|
}
|
|
|
int bizAcctOutBillSize = 0;
|
|
|
int dailyLoanBillSize = 0;
|
|
@@ -69,7 +67,7 @@ public class SRMSynPayApiPlugin implements Serializable {
|
|
|
}
|
|
|
|
|
|
if(bizAcctOutBillSize > 0 && dailyLoanBillSize > 0){
|
|
|
- return returnResult("100", "失败,bizAccountOutBills、dailyLoanBills参数不能同时存在", null);
|
|
|
+ return returnResult("1", "失败,bizAccountOutBills、dailyLoanBills参数不能同时存在", null);
|
|
|
}
|
|
|
|
|
|
JSONArray responseData = new JSONArray();
|
|
@@ -79,21 +77,37 @@ public class SRMSynPayApiPlugin implements Serializable {
|
|
|
responseData = synDailyLoanBill(dailyLoanBills);
|
|
|
}
|
|
|
|
|
|
- String code = "0";
|
|
|
- String msg = "同步成功";
|
|
|
- if(responseData.size() > 0){
|
|
|
+ String code = "";
|
|
|
+ String msg = "";
|
|
|
+
|
|
|
+ int sucCount = 0;
|
|
|
+ int failCount = 0;
|
|
|
+ String sucBillNo = "";
|
|
|
+ String failBillNo = "";
|
|
|
+
|
|
|
+ if(responseData == null){
|
|
|
+ code = "1";
|
|
|
+ msg = "失败";
|
|
|
+ } else if(responseData.size() > 0){
|
|
|
for(int i = 0; i < responseData.size(); i++){
|
|
|
JSONObject response = responseData.getJSONObject(i);
|
|
|
|
|
|
String srmBillNo = response.getString("SRMBillNo");
|
|
|
String status = response.getString("status");
|
|
|
- String message = response.getString("status");
|
|
|
+ String message = response.getString("message");
|
|
|
|
|
|
- if(!"0".equals(status)){
|
|
|
+ if("0".equals(status)){
|
|
|
+ sucCount++;
|
|
|
+ sucBillNo = (sucBillNo.length() > 0 ? "," : "") + srmBillNo;
|
|
|
+ } else {
|
|
|
code = "1";
|
|
|
- msg = "同步失败";
|
|
|
+
|
|
|
+ failCount++;
|
|
|
+ failBillNo = (failBillNo.length() > 0 ? "," : "") + srmBillNo;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ msg = String.format("成功%s条,失败%s条。成功SRMBillNo,%s,失败SRMBillNo,%s", sucCount, failCount, sucBillNo, failBillNo);
|
|
|
}
|
|
|
|
|
|
return returnResult(code, msg, responseData);
|
|
@@ -159,17 +173,44 @@ public class SRMSynPayApiPlugin implements Serializable {
|
|
|
String biller = inputData.getString("biller");//制单人工号
|
|
|
String applier = inputData.getString("applier");//经办人工号
|
|
|
|
|
|
- if(StringUtils.isEmpty(srmBillNo) || StringUtils.isEmpty(srmUrl) || StringUtils.isEmpty(cause)
|
|
|
- || StringUtils.isEmpty(orgUnit) || StringUtils.isEmpty(position) || StringUtils.isEmpty(biller) || StringUtils.isEmpty(applier)){
|
|
|
- returnMessage = "请检查以下参数 SRM单号、srmUrl、事由、申请部门、申请人职位、制单人、经办人 是否为空!";
|
|
|
- return buildReturnData(code, srmBillNo, returnMessage, null, null, null);
|
|
|
- } else if("XM".equals(billType)){
|
|
|
+ if(StringUtils.isEmpty(srmBillNo)){
|
|
|
+ returnMessage = ("".equals(returnMessage) ? "" : ",") + "SRM单号 不能为空";
|
|
|
+ }
|
|
|
+
|
|
|
+ if(StringUtils.isEmpty(srmUrl)){
|
|
|
+ returnMessage = ("".equals(returnMessage) ? "" : ",") + "srmUrl 不能为空";
|
|
|
+ }
|
|
|
+
|
|
|
+ if(StringUtils.isEmpty(cause)){
|
|
|
+ returnMessage = ("".equals(returnMessage) ? "" : ",") + "事由 不能为空";
|
|
|
+ }
|
|
|
+
|
|
|
+ if(StringUtils.isEmpty(orgUnit)){
|
|
|
+ returnMessage = ("".equals(returnMessage) ? "" : ",") + "申请部门 不能为空";
|
|
|
+ }
|
|
|
+
|
|
|
+ if(StringUtils.isEmpty(position)){
|
|
|
+ returnMessage = ("".equals(returnMessage) ? "" : ",") + "申请人职位 不能为空";
|
|
|
+ }
|
|
|
+
|
|
|
+ if(StringUtils.isEmpty(biller)){
|
|
|
+ returnMessage = ("".equals(returnMessage) ? "" : ",") + "制单人 不能为空";
|
|
|
+ }
|
|
|
+
|
|
|
+ if( StringUtils.isEmpty(applier)){
|
|
|
+ returnMessage = ("".equals(returnMessage) ? "" : ",") + "经办人 不能为空";
|
|
|
+ }
|
|
|
+
|
|
|
+ if("XM".equals(billType)){
|
|
|
if(StringUtils.isEmpty(project)){
|
|
|
- returnMessage = "项目类付款,请检查以下参数 项目编码、合同编码 是否为空!";
|
|
|
- return buildReturnData(code, srmBillNo, returnMessage, null, null, null);
|
|
|
+ returnMessage = ("".equals(returnMessage) ? "" : ",") + "项目类付款 项目编码 不能为空";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if(!StringUtils.isEmpty(returnMessage)){
|
|
|
+ return buildReturnData(code, srmBillNo, returnMessage, null, null, null);
|
|
|
+ }
|
|
|
+
|
|
|
//根据srm单据编号,校验在星瀚中是否已存在单据
|
|
|
String xhBillNO = queryBillInfoBySRMBillNo(ENTITY_PUBLICPAY, srmBillNo);
|
|
|
if(!StringUtils.isEmpty(xhBillNO)){
|
|
@@ -714,9 +755,35 @@ public class SRMSynPayApiPlugin implements Serializable {
|
|
|
String position = inputData.getString("position");//职位
|
|
|
String biller = inputData.getString("biller");//制单人工号
|
|
|
|
|
|
- if(StringUtils.isEmpty(srmBillNo) || StringUtils.isEmpty(srmUrl) || StringUtils.isEmpty(cause)
|
|
|
- || StringUtils.isEmpty(orgUnit) || StringUtils.isEmpty(position) || StringUtils.isEmpty(biller) || StringUtils.isEmpty(applier)){
|
|
|
- returnMessage = "请检查以下参数 SRM单号、srmUrl、合同编码、事由、申请部门、申请人职位、制单人、经办人 是否为空!";
|
|
|
+ if(StringUtils.isEmpty(srmBillNo)){
|
|
|
+ returnMessage = ("".equals(returnMessage) ? "" : ",") + "SRM单号 不能为空";
|
|
|
+ }
|
|
|
+
|
|
|
+ if(StringUtils.isEmpty(srmUrl)){
|
|
|
+ returnMessage = ("".equals(returnMessage) ? "" : ",") + "srmUrl 不能为空";
|
|
|
+ }
|
|
|
+
|
|
|
+ if(StringUtils.isEmpty(cause)){
|
|
|
+ returnMessage = ("".equals(returnMessage) ? "" : ",") + "事由 不能为空";
|
|
|
+ }
|
|
|
+
|
|
|
+ if(StringUtils.isEmpty(orgUnit)){
|
|
|
+ returnMessage = ("".equals(returnMessage) ? "" : ",") + "申请部门 不能为空";
|
|
|
+ }
|
|
|
+
|
|
|
+ if(StringUtils.isEmpty(position)){
|
|
|
+ returnMessage = ("".equals(returnMessage) ? "" : ",") + "申请人职位 不能为空";
|
|
|
+ }
|
|
|
+
|
|
|
+ if(StringUtils.isEmpty(biller)){
|
|
|
+ returnMessage = ("".equals(returnMessage) ? "" : ",") + "制单人 不能为空";
|
|
|
+ }
|
|
|
+
|
|
|
+ if( StringUtils.isEmpty(applier)){
|
|
|
+ returnMessage = ("".equals(returnMessage) ? "" : ",") + "经办人 不能为空";
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!StringUtils.isEmpty(returnMessage)){
|
|
|
return buildReturnData(code, srmBillNo, returnMessage, null, null, null);
|
|
|
}
|
|
|
|
|
@@ -814,6 +881,9 @@ public class SRMSynPayApiPlugin implements Serializable {
|
|
|
dailyLoanBill.set("ispush", "false");//合同下推生成
|
|
|
dailyLoanBill.set("nckd_srmstatus", "1");//srm状态,1:SRM已推送;2:已退回SRM;3:已反写SRM;4:反写SRM失败
|
|
|
// dailyLoanBill.set("repaymentdate", repaymentDate);//预计冲销日期
|
|
|
+ dailyLoanBill.set("nckd_duigong", "01");//是否对公业务
|
|
|
+ dailyLoanBill.set("nckd_payviewtypemul", getDefaultMultViewType());//多选页面类型
|
|
|
+
|
|
|
|
|
|
BigDecimal totalReimburseAmount = BigDecimal.ZERO;//报销金额合计
|
|
|
|
|
@@ -1084,14 +1154,15 @@ public class SRMSynPayApiPlugin implements Serializable {
|
|
|
* @return CustomApiResult 返回
|
|
|
*/
|
|
|
public CustomApiResult<JSONObject> returnResult(String code, String message, JSONArray responseData){
|
|
|
- JSONObject reslutData = new JSONObject();
|
|
|
+ JSONObject resultData = new JSONObject();
|
|
|
|
|
|
- reslutData.put("message", message);
|
|
|
- reslutData.put("code", code);
|
|
|
+ resultData.put("msg", message);
|
|
|
+ resultData.put("code", code);
|
|
|
+ resultData.put("successFlag", ("0".equals(code) ? true : false));
|
|
|
|
|
|
- reslutData.put("data", responseData);
|
|
|
+ resultData.put("data", responseData);
|
|
|
|
|
|
- return CustomApiResult.success(reslutData);
|
|
|
+ return CustomApiResult.success(resultData);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1111,4 +1182,25 @@ public class SRMSynPayApiPlugin implements Serializable {
|
|
|
}
|
|
|
return billNO;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 默认多选页面类型
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Object[] getDefaultMultViewType(){
|
|
|
+ String[] typeStrings = new String[]{"1008", "1009"};
|
|
|
+
|
|
|
+ QFilter qFilter = new QFilter("number", QCP.in, typeStrings);
|
|
|
+ DynamicObject[] viewTypeCols = BusinessDataServiceHelper.load("nckd_payviewtype", "id, number, name", qFilter.toArray());
|
|
|
+ if(viewTypeCols != null && viewTypeCols.length > 0){
|
|
|
+ List<Long> idList = Arrays.stream(viewTypeCols)
|
|
|
+ .map(type -> type.getLong("id"))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ Object[] basedataIds = idList.toArray();
|
|
|
+ return basedataIds;
|
|
|
+ }
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|