|
|
|
@ -4,8 +4,11 @@ package com.hw.jindie.service.impl;
|
|
|
|
|
import com.alibaba.fastjson2.JSONArray;
|
|
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
|
|
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
|
|
|
|
import com.hw.common.core.constant.SecurityConstants;
|
|
|
|
|
import com.hw.common.core.utils.StringUtils;
|
|
|
|
|
import com.hw.jindie.config.KingdeeConfig;
|
|
|
|
|
import com.hw.system.api.RemoteLogService;
|
|
|
|
|
import com.hw.system.api.domain.SysOperLog;
|
|
|
|
|
import com.kingdee.bos.webapi.entity.RepoRet;
|
|
|
|
|
import com.kingdee.bos.webapi.entity.RepoStatus;
|
|
|
|
|
import com.kingdee.bos.webapi.sdk.K3CloudApi;
|
|
|
|
@ -13,8 +16,11 @@ import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -24,6 +30,8 @@ import java.util.ArrayList;
|
|
|
|
|
*/
|
|
|
|
|
@Service
|
|
|
|
|
public class KingdeeErpService {
|
|
|
|
|
@Resource
|
|
|
|
|
private RemoteLogService remoteLogService;
|
|
|
|
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(KingdeeErpService.class);
|
|
|
|
|
|
|
|
|
@ -115,6 +123,8 @@ public class KingdeeErpService {
|
|
|
|
|
RepoRet repoRet = gson.fromJson(resultJson, RepoRet.class);
|
|
|
|
|
logger.info("singleSavePurchaseRequisition接口调用成功|请求参数:" + saveParams + "|返回结果:" + resultJson);
|
|
|
|
|
RepoStatus responseStatus = repoRet.getResult().getResponseStatus();
|
|
|
|
|
List<SysOperLog> sysOperLogList = new ArrayList<>();
|
|
|
|
|
Date currentDate = new Date();
|
|
|
|
|
if (responseStatus.isIsSuccess()) {
|
|
|
|
|
JSONObject json = new JSONObject();
|
|
|
|
|
json.put("formId", KingdeeConfig.PUR_Requisition);
|
|
|
|
@ -125,12 +135,28 @@ public class KingdeeErpService {
|
|
|
|
|
if (!commitRepoRet.getResult().getResponseStatus().isIsSuccess()) {
|
|
|
|
|
logger.error("singleSavePurchaseRequisitionCommitException|请求参数:" + json.toJSONString() + "|返回结果:" + commitRepoRet);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SysOperLog sysOperLogCommit = this.getSysOperLog("原材料入库申请单提交", 1, "com.hw.jindie.controller.KingdeeErpSyncController.syncPurchaseReceiveBillFromErp",
|
|
|
|
|
"POST", "syncPurchaseReceiveBillFromErp", "PUR_ReceiveBill(" + json.toString() + ")", commitRepoRet.toString(), currentDate, 1L);
|
|
|
|
|
sysOperLogList.add(sysOperLogCommit);
|
|
|
|
|
|
|
|
|
|
//采购申请单审核
|
|
|
|
|
String auditResult = this.genericAuditInterface(json);
|
|
|
|
|
RepoRet auditRepoRet = gson.fromJson(auditResult, RepoRet.class);
|
|
|
|
|
if (!auditRepoRet.getResult().getResponseStatus().isIsSuccess()) {
|
|
|
|
|
logger.error("singleSavePurchaseRequisitionAuditException|请求参数:" + json.toJSONString() + "|返回结果:" + commitRepoRet);
|
|
|
|
|
logger.error("singleSavePurchaseRequisitionAuditException|请求参数:" + json.toJSONString() + "|返回结果:" + auditRepoRet);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SysOperLog sysOperLogAudit = this.getSysOperLog("原材料入库申请单审核", 1, "com.hw.jindie.controller.KingdeeErpSyncController.syncPurchaseReceiveBillFromErp",
|
|
|
|
|
"POST", "syncPurchaseReceiveBillFromErp", "PUR_ReceiveBill(" + json.toString() + ")", commitRepoRet.toString(), currentDate, 1L);
|
|
|
|
|
sysOperLogList.add(sysOperLogAudit);
|
|
|
|
|
|
|
|
|
|
if (!sysOperLogList.isEmpty()) {
|
|
|
|
|
for (SysOperLog sysOperLog : sysOperLogList) {
|
|
|
|
|
remoteLogService.saveLog(sysOperLog, SecurityConstants.INNER);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return gson.toJson(responseStatus);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
@ -265,27 +291,51 @@ public class KingdeeErpService {
|
|
|
|
|
String saveParams = data.toJSONString();
|
|
|
|
|
String resultJson = client.save(formId, saveParams);
|
|
|
|
|
|
|
|
|
|
List<SysOperLog> sysOperLogList = new ArrayList<>();
|
|
|
|
|
Date currentDate = new Date();
|
|
|
|
|
//用于记录结果
|
|
|
|
|
Gson gson = new Gson();
|
|
|
|
|
//对返回结果进行解析和校验
|
|
|
|
|
RepoRet repoRet = gson.fromJson(resultJson, RepoRet.class);
|
|
|
|
|
logger.info("savePurchaseStorage接口调用成功|请求参数:" + saveParams + "|返回结果:" + resultJson);
|
|
|
|
|
RepoStatus responseStatus = repoRet.getResult().getResponseStatus();
|
|
|
|
|
|
|
|
|
|
if (responseStatus.isIsSuccess()) {
|
|
|
|
|
Long beginTimeL = System.currentTimeMillis();
|
|
|
|
|
JSONObject json = new JSONObject();
|
|
|
|
|
json.put("formId", KingdeeConfig.STK_InStock);
|
|
|
|
|
json.put("Ids", repoRet.getResult().getId());
|
|
|
|
|
//采购入库单提交
|
|
|
|
|
String commitResult = this.genericCommitInterface(json);
|
|
|
|
|
RepoRet commitRepoRet = gson.fromJson(commitResult, RepoRet.class);
|
|
|
|
|
String commitResultStr = "成功";
|
|
|
|
|
if (!commitRepoRet.getResult().getResponseStatus().isIsSuccess()) {
|
|
|
|
|
commitResultStr = "失败";
|
|
|
|
|
logger.error("savePurchaseStorage|请求参数:" + json.toJSONString() + "|返回结果:" + commitRepoRet);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SysOperLog sysOperLogCommit = this.getSysOperLog("原材料入库申请单提交", 1, "com.hw.jindie.controller.KingdeeErpSyncController.savePurchaseStorage",
|
|
|
|
|
"POST", "syncPurchaseReceiveBillFromErp", formId+"(" + json.toString() + ")", commitResultStr, currentDate, System.currentTimeMillis()-beginTimeL);
|
|
|
|
|
sysOperLogList.add(sysOperLogCommit);
|
|
|
|
|
|
|
|
|
|
beginTimeL = System.currentTimeMillis();
|
|
|
|
|
//采购入库单审核
|
|
|
|
|
String auditResult = this.genericAuditInterface(json);
|
|
|
|
|
RepoRet auditRepoRet = gson.fromJson(auditResult, RepoRet.class);
|
|
|
|
|
String auditResultStr = "成功";
|
|
|
|
|
if (!auditRepoRet.getResult().getResponseStatus().isIsSuccess()) {
|
|
|
|
|
logger.error("savePurchaseStorage|请求参数:" + json.toJSONString() + "|返回结果:" + commitRepoRet);
|
|
|
|
|
auditResultStr = "失败";
|
|
|
|
|
logger.error("savePurchaseStorage|请求参数:" + json.toJSONString() + "|返回结果:" + auditRepoRet);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SysOperLog sysOperLogAudit = this.getSysOperLog("原材料入库申请单审核", 1, "com.hw.jindie.controller.KingdeeErpSyncController.savePurchaseStorage",
|
|
|
|
|
"POST", "syncPurchaseReceiveBillFromErp", formId+"(" + json.toString() + ")", auditResultStr, currentDate, System.currentTimeMillis()-beginTimeL);
|
|
|
|
|
sysOperLogList.add(sysOperLogAudit);
|
|
|
|
|
|
|
|
|
|
if (!sysOperLogList.isEmpty()) {
|
|
|
|
|
for (SysOperLog sysOperLog : sysOperLogList) {
|
|
|
|
|
remoteLogService.saveLog(sysOperLog, SecurityConstants.INNER);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return gson.toJson(responseStatus);
|
|
|
|
@ -459,6 +509,9 @@ public class KingdeeErpService {
|
|
|
|
|
String saveParams = data.toJSONString();
|
|
|
|
|
String resultJson = client.save(formId, saveParams);
|
|
|
|
|
|
|
|
|
|
List<SysOperLog> sysOperLogList = new ArrayList<>();
|
|
|
|
|
Date currentDate = new Date();
|
|
|
|
|
|
|
|
|
|
//用于记录结果
|
|
|
|
|
Gson gson = new Gson();
|
|
|
|
|
//对返回结果进行解析和校验
|
|
|
|
@ -466,21 +519,44 @@ public class KingdeeErpService {
|
|
|
|
|
logger.info("saveOtherOutStorage接口调用成功|请求参数:" + saveParams + "|返回结果:" + resultJson);
|
|
|
|
|
RepoStatus responseStatus = repoRet.getResult().getResponseStatus();
|
|
|
|
|
if (responseStatus.isIsSuccess()) {
|
|
|
|
|
Long beginTimeL = System.currentTimeMillis();
|
|
|
|
|
JSONObject json = new JSONObject();
|
|
|
|
|
json.put("formId", KingdeeConfig.STK_MisDelivery);
|
|
|
|
|
json.put("Ids", repoRet.getResult().getId());
|
|
|
|
|
//其他出库单提交
|
|
|
|
|
String commitResult = this.genericCommitInterface(json);
|
|
|
|
|
RepoRet commitRepoRet = gson.fromJson(commitResult, RepoRet.class);
|
|
|
|
|
String commitResultStr = "成功";
|
|
|
|
|
if (!commitRepoRet.getResult().getResponseStatus().isIsSuccess()) {
|
|
|
|
|
commitResultStr = "失败";
|
|
|
|
|
logger.error("saveOtherOutStorage|请求参数:" + json.toJSONString() + "|返回结果:" + commitRepoRet);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SysOperLog sysOperLogCommit = this.getSysOperLog("其他出库单提交", 1, "com.hw.jindie.controller.KingdeeErpSyncController.saveOtherOutStorage",
|
|
|
|
|
"POST", "saveOtherOutStorage", formId+"(" + json.toString() + ")", commitResultStr, currentDate, System.currentTimeMillis()-beginTimeL);
|
|
|
|
|
sysOperLogList.add(sysOperLogCommit);
|
|
|
|
|
|
|
|
|
|
beginTimeL = System.currentTimeMillis();
|
|
|
|
|
//其他出库单审核
|
|
|
|
|
String auditResult = this.genericAuditInterface(json);
|
|
|
|
|
RepoRet auditRepoRet = gson.fromJson(auditResult, RepoRet.class);
|
|
|
|
|
String auditResultStr = "成功";
|
|
|
|
|
if (!auditRepoRet.getResult().getResponseStatus().isIsSuccess()) {
|
|
|
|
|
auditResultStr = "失败";
|
|
|
|
|
logger.error("saveOtherOutStorage|请求参数:" + json.toJSONString() + "|返回结果:" + commitRepoRet);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SysOperLog sysOperLogAudit = this.getSysOperLog("其他出库单审核", 1, "com.hw.jindie.controller.KingdeeErpSyncController.saveOtherOutStorage",
|
|
|
|
|
"POST", "saveOtherOutStorage", formId+"(" + json.toString() + ")", auditResultStr, currentDate, System.currentTimeMillis()-beginTimeL);
|
|
|
|
|
sysOperLogList.add(sysOperLogAudit);
|
|
|
|
|
|
|
|
|
|
if (!sysOperLogList.isEmpty()) {
|
|
|
|
|
for (SysOperLog sysOperLog : sysOperLogList) {
|
|
|
|
|
remoteLogService.saveLog(sysOperLog, SecurityConstants.INNER);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return gson.toJson(responseStatus);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
@ -552,6 +628,9 @@ public class KingdeeErpService {
|
|
|
|
|
String saveParams = data.toJSONString();
|
|
|
|
|
String resultJson = client.save(formId, saveParams);
|
|
|
|
|
|
|
|
|
|
List<SysOperLog> sysOperLogList = new ArrayList<>();
|
|
|
|
|
Date currentDate = new Date();
|
|
|
|
|
|
|
|
|
|
//用于记录结果
|
|
|
|
|
Gson gson = new Gson();
|
|
|
|
|
//对返回结果进行解析和校验
|
|
|
|
@ -559,21 +638,43 @@ public class KingdeeErpService {
|
|
|
|
|
logger.info("saveOtherInStorage接口调用成功|请求参数:" + saveParams + "|返回结果:" + resultJson);
|
|
|
|
|
RepoStatus responseStatus = repoRet.getResult().getResponseStatus();
|
|
|
|
|
if (responseStatus.isIsSuccess()) {
|
|
|
|
|
Long beginTimeL = System.currentTimeMillis();
|
|
|
|
|
JSONObject json = new JSONObject();
|
|
|
|
|
json.put("formId", KingdeeConfig.STK_MISCELLANEOUS);
|
|
|
|
|
json.put("Ids", repoRet.getResult().getId());
|
|
|
|
|
//其他入库单提交
|
|
|
|
|
String commitResult = this.genericCommitInterface(json);
|
|
|
|
|
RepoRet commitRepoRet = gson.fromJson(commitResult, RepoRet.class);
|
|
|
|
|
String commitResultStr = "成功";
|
|
|
|
|
if (!commitRepoRet.getResult().getResponseStatus().isIsSuccess()){
|
|
|
|
|
commitResultStr = "失败";
|
|
|
|
|
logger.error("saveOtherInStorage|请求参数:" + json.toJSONString() + "|返回结果:" + commitRepoRet);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SysOperLog sysOperLogCommit = this.getSysOperLog("其他入库单提交", 1, "com.hw.jindie.controller.KingdeeErpSyncController.saveOtherInStorage",
|
|
|
|
|
"POST", "saveOtherInStorage", formId+"(" + json.toString() + ")", commitResultStr, currentDate, System.currentTimeMillis()-beginTimeL);
|
|
|
|
|
sysOperLogList.add(sysOperLogCommit);
|
|
|
|
|
|
|
|
|
|
beginTimeL = System.currentTimeMillis();
|
|
|
|
|
//其他入库单审核
|
|
|
|
|
String auditResult = this.genericAuditInterface(json);
|
|
|
|
|
RepoRet auditRepoRet = gson.fromJson(auditResult, RepoRet.class);
|
|
|
|
|
String auditResultStr = "成功";
|
|
|
|
|
if (!auditRepoRet.getResult().getResponseStatus().isIsSuccess()){
|
|
|
|
|
auditResultStr = "失败";
|
|
|
|
|
logger.error("saveOtherInStorage|请求参数:" + json.toJSONString() + "|返回结果:" + commitRepoRet);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SysOperLog sysOperLogAudit = this.getSysOperLog("其他入库单审核", 1, "com.hw.jindie.controller.KingdeeErpSyncController.saveOtherInStorage",
|
|
|
|
|
"POST", "saveOtherInStorage", formId+"(" + json.toString() + ")", auditResultStr, currentDate, System.currentTimeMillis()-beginTimeL);
|
|
|
|
|
sysOperLogList.add(sysOperLogAudit);
|
|
|
|
|
|
|
|
|
|
if (!sysOperLogList.isEmpty()) {
|
|
|
|
|
for (SysOperLog sysOperLog : sysOperLogList) {
|
|
|
|
|
remoteLogService.saveLog(sysOperLog, SecurityConstants.INNER);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return gson.toJson(responseStatus);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
@ -583,4 +684,24 @@ public class KingdeeErpService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private SysOperLog getSysOperLog(String logTitle, Integer businessType, String method, String requestMethod, String operUrl,
|
|
|
|
|
String operParam, String jsonResult, Date operTime, Long costTime) throws Exception {
|
|
|
|
|
SysOperLog sysOperLog = new SysOperLog();
|
|
|
|
|
sysOperLog.setTitle(logTitle);
|
|
|
|
|
sysOperLog.setBusinessType(businessType);
|
|
|
|
|
sysOperLog.setMethod(method);
|
|
|
|
|
sysOperLog.setRequestMethod(requestMethod);
|
|
|
|
|
sysOperLog.setOperatorType(0);
|
|
|
|
|
sysOperLog.setOperIp("127.0.0.1");
|
|
|
|
|
sysOperLog.setOperName("定时任务");
|
|
|
|
|
sysOperLog.setOperUrl(operUrl);
|
|
|
|
|
sysOperLog.setOperParam(operParam);
|
|
|
|
|
sysOperLog.setJsonResult(jsonResult);
|
|
|
|
|
sysOperLog.setStatus(0);
|
|
|
|
|
sysOperLog.setOperTime(operTime);
|
|
|
|
|
sysOperLog.setCostTime(costTime);
|
|
|
|
|
|
|
|
|
|
return sysOperLog;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|