星空对接接口开发:补充下推逻辑;优化代码路径

This commit is contained in:
16358 2025-06-19 11:22:35 +08:00
parent 4598107db6
commit f07456bfb3
29 changed files with 358 additions and 53 deletions

View File

@ -25,6 +25,7 @@ import java.io.IOException;
/**
* @author 16358
* @date 2025/6/3
* 对外提供接口
*/
@RequestMapping("/openApi")
@RestController

View File

@ -5,9 +5,12 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.ruoyi.bill.domain.PoundBill;
import com.ruoyi.bill.service.IPoundBillService;
import com.ruoyi.system.service.ISysConfigService;
import com.ruoyi.webApi.billHandlerUtil.BillHandler;
import com.ruoyi.webApi.billHandlerUtil.BillHandlers;
import com.ruoyi.webApi.requestbody.DynamicFormRequest;
import com.ruoyi.webApi.saveRequestBody.billHandlerUtil.BillHandler;
import com.ruoyi.webApi.saveRequestBody.billHandlerUtil.BillHandlers;
import com.ruoyi.webApi.pushRequestBody.billHandlerUtil.PushBillHandler;
import com.ruoyi.webApi.pushRequestBody.billHandlerUtil.PushBillHandlers;
import com.ruoyi.webApi.pushRequestBody.requestbody.DynamicFormPushRequest;
import com.ruoyi.webApi.saveRequestBody.requestbody.DynamicFormRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@ -37,12 +40,13 @@ public class ApiPostBack {
private static final ObjectMapper objectMapper = new ObjectMapper();
//单据保存更新
public String makePoundBillFormData(String id) throws IOException {
PoundBill poundBill = poundBillService.selectPoundBillById(id);
if (poundBill == null) throw new RuntimeException("磅单不存在!");
String url = sysConfigService.selectConfigByKey("OA_Url") +
"/k3cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.save.common.kdsvc";
"/k3cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Save.common.kdsvc";
BillHandler handler = BillHandlers.getHandler(poundBill.getSrcblltype());
DynamicFormRequest request = handler.buildRequest(poundBill);
@ -57,6 +61,27 @@ public class ApiPostBack {
return sendPostRequest(url, jsonInputString);
}
//单据下推
public String pushPoundBillFormData(String id) throws IOException {
PoundBill poundBill = poundBillService.selectPoundBillById(id);
if (poundBill == null) throw new RuntimeException("磅单不存在!");
String url = sysConfigService.selectConfigByKey("OA_Url") +
"/k3cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Push.common.kdsvc";
PushBillHandler handler = PushBillHandlers.getHandler(poundBill.getSrcblltype());
DynamicFormPushRequest request = handler.buildRequest(poundBill);
String jsonInputString;
try {
jsonInputString = objectMapper.writeValueAsString(request);
} catch (JsonProcessingException e) {
return "JSON序列化失败" + e.getMessage();
}
return sendPostRequest(url, jsonInputString);
}
private String sendPostRequest(String url, String jsonBody) throws IOException {
StringBuilder errorLog = new StringBuilder();
try {

View File

@ -7,7 +7,7 @@ import java.util.Map;
/**
* @author 16358
* @date 2025/6/5
* 接口接取参数body
* 对外接口接取参数body
*/
public class ApiRequestBody {

View File

@ -28,6 +28,7 @@ import java.util.UUID;
/**
* @author 16358
* @date 2025/6/5
* 拉取星空数据接口
*/
@Component("apiTask")
public class ApiTask {

View File

@ -0,0 +1,12 @@
package com.ruoyi.webApi.pushRequestBody.billHandlerUtil;
import com.ruoyi.bill.domain.PoundBill;
import com.ruoyi.webApi.pushRequestBody.requestbody.DynamicFormPushRequest;
/**
* @author 16358
* @date 2025/6/18
*/
public interface PushBillHandler {
DynamicFormPushRequest buildRequest(PoundBill bill);
}

View File

@ -0,0 +1,51 @@
package com.ruoyi.webApi.pushRequestBody.billHandlerUtil;
import com.ruoyi.webApi.pushRequestBody.billHandlerUtil.impl.PURPushHandler;
import com.ruoyi.webApi.pushRequestBody.billHandlerUtil.impl.SALPushHandler;
import com.ruoyi.webApi.pushRequestBody.billHandlerUtil.impl.SPPushHandler;
import com.ruoyi.webApi.pushRequestBody.billHandlerUtil.impl.STKPushHandler;
public enum PushBillHandlers {
SAL_DELIVERYNOTICE {
@Override
public PushBillHandler getHandler() {
return new SALPushHandler();
}
},
PUR_ReceiveBill {
@Override
public PushBillHandler getHandler() {
return new PURPushHandler();
}
},
STK_TRANSFERAPPLY {
@Override
public PushBillHandler getHandler() {
return new STKPushHandler();
}
},
SP_InStock {
@Override
public PushBillHandler getHandler() {
return new SPPushHandler();
}
};
public abstract PushBillHandler getHandler();
public static PushBillHandler getHandler(String type) {
switch (type) {
case "SAL_DELIVERYNOTICE":
return SAL_DELIVERYNOTICE.getHandler();
case "PUR_ReceiveBill":
return PUR_ReceiveBill.getHandler();
case "STK_TRANSFERAPPLY":
return STK_TRANSFERAPPLY.getHandler();
case "SP_InStock":
return SP_InStock.getHandler();
default:
throw new IllegalArgumentException("不支持的单据类型: " + type);
}
}
}

View File

@ -0,0 +1,21 @@
package com.ruoyi.webApi.pushRequestBody.billHandlerUtil.impl;
import com.ruoyi.bill.domain.PoundBill;
import com.ruoyi.webApi.pushRequestBody.billHandlerUtil.PushBillHandler;
import com.ruoyi.webApi.pushRequestBody.requestbody.DynamicFormPushRequest;
import com.ruoyi.webApi.pushRequestBody.requestbody.PushRequestData;
/**
* @author 16358
* @date 2025/6/18
* 收料通知单
*/
public class PURPushHandler implements PushBillHandler {
@Override
public DynamicFormPushRequest buildRequest(PoundBill bill) {
DynamicFormPushRequest request = new DynamicFormPushRequest("PUR_ReceiveBill");
PushRequestData data = new PushRequestData(bill,"PUR_ReceiveBill-STK_InStock");
request.setData(data);
return request;
}
}

View File

@ -0,0 +1,21 @@
package com.ruoyi.webApi.pushRequestBody.billHandlerUtil.impl;
import com.ruoyi.bill.domain.PoundBill;
import com.ruoyi.webApi.pushRequestBody.billHandlerUtil.PushBillHandler;
import com.ruoyi.webApi.pushRequestBody.requestbody.DynamicFormPushRequest;
import com.ruoyi.webApi.pushRequestBody.requestbody.PushRequestData;
/**
* @author 16358
* @date 2025/6/18
* 发货通知单
*/
public class SALPushHandler implements PushBillHandler {
@Override
public DynamicFormPushRequest buildRequest(PoundBill bill) {
DynamicFormPushRequest request = new DynamicFormPushRequest("SAL_DELIVERYNOTICE");
PushRequestData data = new PushRequestData(bill,"DeliveryNotice-OutStock");
request.setData(data);
return request;
}
}

View File

@ -0,0 +1,22 @@
package com.ruoyi.webApi.pushRequestBody.billHandlerUtil.impl;
import com.ruoyi.bill.domain.PoundBill;
import com.ruoyi.webApi.pushRequestBody.billHandlerUtil.PushBillHandler;
import com.ruoyi.webApi.pushRequestBody.requestbody.DynamicFormPushRequest;
import com.ruoyi.webApi.pushRequestBody.requestbody.PushRequestData;
/**
* @author 16358
* @date 2025/6/18
* 简单生产入库单
* FIXME简单生产入库单未提供下推接口暂时废弃
*/
public class SPPushHandler implements PushBillHandler {
@Override
public DynamicFormPushRequest buildRequest(PoundBill bill) {
DynamicFormPushRequest request = new DynamicFormPushRequest("SP_InStock");
PushRequestData data = new PushRequestData(bill,"!!!!!");
request.setData(data);
return request;
}
}

View File

@ -0,0 +1,21 @@
package com.ruoyi.webApi.pushRequestBody.billHandlerUtil.impl;
import com.ruoyi.bill.domain.PoundBill;
import com.ruoyi.webApi.pushRequestBody.billHandlerUtil.PushBillHandler;
import com.ruoyi.webApi.pushRequestBody.requestbody.DynamicFormPushRequest;
import com.ruoyi.webApi.pushRequestBody.requestbody.PushRequestData;
/**
* @author 16358
* @date 2025/6/18
* 调拨申请单
*/
public class STKPushHandler implements PushBillHandler {
@Override
public DynamicFormPushRequest buildRequest(PoundBill bill) {
DynamicFormPushRequest request = new DynamicFormPushRequest("STK_TRANSFERAPPLY");
PushRequestData data = new PushRequestData(bill,"StkTransferApply-StkTransferDirect");
request.setData(data);
return request;
}
}

View File

@ -0,0 +1,19 @@
package com.ruoyi.webApi.pushRequestBody.requestbody;
import com.fasterxml.jackson.annotation.JsonInclude;
@JsonInclude(JsonInclude.Include.NON_NULL)
public class DynamicFormPushRequest {
private String Formid;
private PushRequestData data;
public DynamicFormPushRequest(String formId) {
this.Formid = formId;
}
// Getters and setters
public String getFormid() { return Formid; }
public void setFormid(String formid) { Formid = formid; }
public PushRequestData getData() { return data; }
public void setData(PushRequestData data) { this.data = data; }
}

View File

@ -0,0 +1,112 @@
package com.ruoyi.webApi.pushRequestBody.requestbody;
import com.ruoyi.bill.domain.PoundBill;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @author 16358
* @date 2025/6/18
*/
public class PushRequestData {
private String Ids = "";
private ArrayList<String> Numbers = new ArrayList<>();
private String EntryIds = "";
private String RuleId;
private String TargetBillTypeId = "";
private int TargetOrgId = 0;
private String TargetFormId = "";
private String IsEnableDefaultRule = "false";
private String IsDraftWhenSaveFail = "false";
private Map<String, Object> CustomParams;
public PushRequestData(PoundBill bill, String ruleId) {
setIds(bill.getFid());
setEntryIds(bill.getFentity_fentryid());
setRuleId(ruleId);
}
public PushRequestData(){};
public String getIds() {
return Ids;
}
public void setIds(String ids) {
Ids = ids;
}
public ArrayList<String> getNumbers() {
return Numbers;
}
public void setNumbers(ArrayList<String> numbers) {
Numbers = numbers;
}
public String getEntryIds() {
return EntryIds;
}
public void setEntryIds(String entryIds) {
EntryIds = entryIds;
}
public String getRuleId() {
return RuleId;
}
public void setRuleId(String ruleId) {
RuleId = ruleId;
}
public String getTargetBillTypeId() {
return TargetBillTypeId;
}
public void setTargetBillTypeId(String targetBillTypeId) {
TargetBillTypeId = targetBillTypeId;
}
public int getTargetOrgId() {
return TargetOrgId;
}
public void setTargetOrgId(int targetOrgId) {
TargetOrgId = targetOrgId;
}
public String getTargetFormId() {
return TargetFormId;
}
public void setTargetFormId(String targetFormId) {
TargetFormId = targetFormId;
}
public String getIsEnableDefaultRule() {
return IsEnableDefaultRule;
}
public void setIsEnableDefaultRule(String isEnableDefaultRule) {
IsEnableDefaultRule = isEnableDefaultRule;
}
public String getIsDraftWhenSaveFail() {
return IsDraftWhenSaveFail;
}
public void setIsDraftWhenSaveFail(String isDraftWhenSaveFail) {
IsDraftWhenSaveFail = isDraftWhenSaveFail;
}
public Map<String, Object> getCustomParams() {
return CustomParams;
}
public void setCustomParams(Map<String, Object> customParams) {
CustomParams = customParams;
}
}

View File

@ -1,7 +1,7 @@
package com.ruoyi.webApi.billHandlerUtil;
package com.ruoyi.webApi.saveRequestBody.billHandlerUtil;
import com.ruoyi.bill.domain.PoundBill;
import com.ruoyi.webApi.requestbody.DynamicFormRequest;
import com.ruoyi.webApi.saveRequestBody.requestbody.DynamicFormRequest;
/**
* @author 16358

View File

@ -1,9 +1,9 @@
package com.ruoyi.webApi.billHandlerUtil;
package com.ruoyi.webApi.saveRequestBody.billHandlerUtil;
import com.ruoyi.webApi.billHandlerUtil.impl.PURHandler;
import com.ruoyi.webApi.billHandlerUtil.impl.SALHandler;
import com.ruoyi.webApi.billHandlerUtil.impl.SPHandler;
import com.ruoyi.webApi.billHandlerUtil.impl.STKHandler;
import com.ruoyi.webApi.saveRequestBody.billHandlerUtil.impl.PURHandler;
import com.ruoyi.webApi.saveRequestBody.billHandlerUtil.impl.SALHandler;
import com.ruoyi.webApi.saveRequestBody.billHandlerUtil.impl.SPHandler;
import com.ruoyi.webApi.saveRequestBody.billHandlerUtil.impl.STKHandler;
public enum BillHandlers {
SAL_DELIVERYNOTICE {

View File

@ -1,10 +1,10 @@
package com.ruoyi.webApi.billHandlerUtil.impl;
package com.ruoyi.webApi.saveRequestBody.billHandlerUtil.impl;
import com.ruoyi.bill.domain.PoundBill;
import com.ruoyi.webApi.billHandlerUtil.BillHandler;
import com.ruoyi.webApi.requestbody.DynamicFormRequest;
import com.ruoyi.webApi.requestbody.RequestData;
import com.ruoyi.webApi.requestbody.model.PURModel;
import com.ruoyi.webApi.saveRequestBody.billHandlerUtil.BillHandler;
import com.ruoyi.webApi.saveRequestBody.requestbody.DynamicFormRequest;
import com.ruoyi.webApi.saveRequestBody.requestbody.RequestData;
import com.ruoyi.webApi.saveRequestBody.requestbody.model.PURModel;
/**
* @author 16358

View File

@ -1,10 +1,10 @@
package com.ruoyi.webApi.billHandlerUtil.impl;
package com.ruoyi.webApi.saveRequestBody.billHandlerUtil.impl;
import com.ruoyi.bill.domain.PoundBill;
import com.ruoyi.webApi.billHandlerUtil.BillHandler;
import com.ruoyi.webApi.requestbody.DynamicFormRequest;
import com.ruoyi.webApi.requestbody.RequestData;
import com.ruoyi.webApi.requestbody.model.SALModel;
import com.ruoyi.webApi.saveRequestBody.billHandlerUtil.BillHandler;
import com.ruoyi.webApi.saveRequestBody.requestbody.DynamicFormRequest;
import com.ruoyi.webApi.saveRequestBody.requestbody.RequestData;
import com.ruoyi.webApi.saveRequestBody.requestbody.model.SALModel;
/**
* @author 16358

View File

@ -1,10 +1,11 @@
package com.ruoyi.webApi.billHandlerUtil.impl;
package com.ruoyi.webApi.saveRequestBody.billHandlerUtil.impl;
import com.ruoyi.bill.domain.PoundBill;
import com.ruoyi.webApi.billHandlerUtil.BillHandler;
import com.ruoyi.webApi.requestbody.DynamicFormRequest;
import com.ruoyi.webApi.requestbody.RequestData;
import com.ruoyi.webApi.requestbody.model.SPModel;
import com.ruoyi.webApi.saveRequestBody.billHandlerUtil.BillHandler;
import com.ruoyi.webApi.saveRequestBody.requestbody.DynamicFormRequest;
import com.ruoyi.webApi.saveRequestBody.requestbody.RequestData;
import com.ruoyi.webApi.saveRequestBody.requestbody.model.PURModel;
import com.ruoyi.webApi.saveRequestBody.requestbody.model.SPModel;
/**
* @author 16358

View File

@ -1,10 +1,10 @@
package com.ruoyi.webApi.billHandlerUtil.impl;
package com.ruoyi.webApi.saveRequestBody.billHandlerUtil.impl;
import com.ruoyi.bill.domain.PoundBill;
import com.ruoyi.webApi.billHandlerUtil.BillHandler;
import com.ruoyi.webApi.requestbody.DynamicFormRequest;
import com.ruoyi.webApi.requestbody.RequestData;
import com.ruoyi.webApi.requestbody.model.STKModel;
import com.ruoyi.webApi.saveRequestBody.billHandlerUtil.BillHandler;
import com.ruoyi.webApi.saveRequestBody.requestbody.DynamicFormRequest;
import com.ruoyi.webApi.saveRequestBody.requestbody.RequestData;
import com.ruoyi.webApi.saveRequestBody.requestbody.model.STKModel;
/**
* @author 16358

View File

@ -1,4 +1,4 @@
package com.ruoyi.webApi.requestbody;
package com.ruoyi.webApi.saveRequestBody.requestbody;
import com.fasterxml.jackson.annotation.JsonInclude;

View File

@ -1,4 +1,4 @@
package com.ruoyi.webApi.requestbody;
package com.ruoyi.webApi.saveRequestBody.requestbody;
import java.util.ArrayList;
import java.util.List;

View File

@ -1,4 +1,4 @@
package com.ruoyi.webApi.requestbody;
package com.ruoyi.webApi.saveRequestBody.requestbody;
/**
* @author 16358

View File

@ -1,4 +1,4 @@
package com.ruoyi.webApi.requestbody.entity;
package com.ruoyi.webApi.saveRequestBody.requestbody.entity;
import java.math.BigDecimal;

View File

@ -1,4 +1,4 @@
package com.ruoyi.webApi.requestbody.entity;
package com.ruoyi.webApi.saveRequestBody.requestbody.entity;
import java.math.BigDecimal;

View File

@ -1,4 +1,4 @@
package com.ruoyi.webApi.requestbody.entity;
package com.ruoyi.webApi.saveRequestBody.requestbody.entity;
import java.math.BigDecimal;

View File

@ -1,4 +1,4 @@
package com.ruoyi.webApi.requestbody.entity;
package com.ruoyi.webApi.saveRequestBody.requestbody.entity;
import java.math.BigDecimal;

View File

@ -1,8 +1,8 @@
package com.ruoyi.webApi.requestbody.model;
package com.ruoyi.webApi.saveRequestBody.requestbody.model;
import com.ruoyi.bill.domain.PoundBill;
import com.ruoyi.webApi.requestbody.entity.PUREntity;
import com.ruoyi.webApi.requestbody.RequestModel;
import com.ruoyi.webApi.saveRequestBody.requestbody.entity.PUREntity;
import com.ruoyi.webApi.saveRequestBody.requestbody.RequestModel;
/**
* @author 16358

View File

@ -1,8 +1,8 @@
package com.ruoyi.webApi.requestbody.model;
package com.ruoyi.webApi.saveRequestBody.requestbody.model;
import com.ruoyi.bill.domain.PoundBill;
import com.ruoyi.webApi.requestbody.entity.SALEntity;
import com.ruoyi.webApi.requestbody.RequestModel;
import com.ruoyi.webApi.saveRequestBody.requestbody.entity.SALEntity;
import com.ruoyi.webApi.saveRequestBody.requestbody.RequestModel;
/**
* @author 16358

View File

@ -1,10 +1,8 @@
package com.ruoyi.webApi.requestbody.model;
package com.ruoyi.webApi.saveRequestBody.requestbody.model;
import com.ruoyi.bill.domain.PoundBill;
import com.ruoyi.webApi.requestbody.entity.SPEntity;
import com.ruoyi.webApi.requestbody.RequestModel;
import com.ruoyi.webApi.requestbody.entity.SPEntity.Ref;
import com.ruoyi.webApi.requestbody.entity.SPEntity.FNumberRef;
import com.ruoyi.webApi.saveRequestBody.requestbody.entity.SPEntity;
import com.ruoyi.webApi.saveRequestBody.requestbody.RequestModel;
/**
* @author 16358

View File

@ -1,8 +1,8 @@
package com.ruoyi.webApi.requestbody.model;
package com.ruoyi.webApi.saveRequestBody.requestbody.model;
import com.ruoyi.bill.domain.PoundBill;
import com.ruoyi.webApi.requestbody.entity.STKEntity;
import com.ruoyi.webApi.requestbody.RequestModel;
import com.ruoyi.webApi.saveRequestBody.requestbody.entity.STKEntity;
import com.ruoyi.webApi.saveRequestBody.requestbody.RequestModel;
/**
* @author 16358