星空对接接口开发
This commit is contained in:
parent
2c5084700d
commit
221eef78e8
|
@ -147,6 +147,15 @@ public class Poundappli extends BaseEntity
|
||||||
@Excel(name = "最后修改人")
|
@Excel(name = "最后修改人")
|
||||||
private String lstedtopr;
|
private String lstedtopr;
|
||||||
|
|
||||||
|
//星空ID
|
||||||
|
private String fid;
|
||||||
|
|
||||||
|
//星空分录ID
|
||||||
|
private String fentity_fentryid;
|
||||||
|
|
||||||
|
//星空单据类型
|
||||||
|
private String oabilltype;
|
||||||
|
|
||||||
public void setId(String id)
|
public void setId(String id)
|
||||||
{
|
{
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
@ -157,7 +166,31 @@ public class Poundappli extends BaseEntity
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBllstate(String bllstate)
|
public String getFid() {
|
||||||
|
return fid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFid(String fid) {
|
||||||
|
this.fid = fid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFentity_fentryid() {
|
||||||
|
return fentity_fentryid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFentity_fentryid(String fentity_fentryid) {
|
||||||
|
this.fentity_fentryid = fentity_fentryid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOabilltype() {
|
||||||
|
return oabilltype;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOabilltype(String oabilltype) {
|
||||||
|
this.oabilltype = oabilltype;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBllstate(String bllstate)
|
||||||
{
|
{
|
||||||
this.bllstate = bllstate;
|
this.bllstate = bllstate;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,15 +39,6 @@ public class ApiController {
|
||||||
@Resource
|
@Resource
|
||||||
private AuthenticationManager authenticationManager;
|
private AuthenticationManager authenticationManager;
|
||||||
|
|
||||||
//星空 -> 计量平台 : 过磅申请(接收星空 发货通知单,收料通知单)
|
|
||||||
@PostMapping("/poundapplication")
|
|
||||||
public AjaxResult poundapplication(@RequestBody ApiRequestBody data) throws IOException {
|
|
||||||
Object json = data.getData();
|
|
||||||
|
|
||||||
AjaxResult success = AjaxResult.success();
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
//对外提供登录接口
|
//对外提供登录接口
|
||||||
@PostMapping("/getToken")
|
@PostMapping("/getToken")
|
||||||
public AjaxResult getToken(@RequestBody LoginBody loginBody) throws IOException {
|
public AjaxResult getToken(@RequestBody LoginBody loginBody) throws IOException {
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
package com.ruoyi.webApi;
|
package com.ruoyi.webApi;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.ruoyi.common.core.domain.entity.SysDictData;
|
||||||
import com.ruoyi.system.service.ISysConfigService;
|
import com.ruoyi.system.service.ISysConfigService;
|
||||||
|
import com.ruoyi.system.service.ISysDictTypeService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -12,6 +13,7 @@ import java.io.InputStreamReader;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 16358
|
* @author 16358
|
||||||
|
@ -21,6 +23,8 @@ import java.net.URL;
|
||||||
public class ApiTask {
|
public class ApiTask {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysConfigService sysConfigService;
|
private ISysConfigService sysConfigService;
|
||||||
|
@Autowired
|
||||||
|
private ISysDictTypeService dictTypeService;
|
||||||
|
|
||||||
//登录星空接口
|
//登录星空接口
|
||||||
public String OAlogin(){
|
public String OAlogin(){
|
||||||
|
@ -101,4 +105,133 @@ public class ApiTask {
|
||||||
String token = getToken();
|
String token = getToken();
|
||||||
System.out.println(token);
|
System.out.println(token);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//定时任务拉取星空数据(发货通知单,收料通知单,调拨申请单,简单生产入库)
|
||||||
|
public void getOAData(){
|
||||||
|
//获取各个单据的单据id
|
||||||
|
List<SysDictData> oaFormid = dictTypeService.selectDictDataByType("oa_formid");
|
||||||
|
|
||||||
|
//记录错误日志
|
||||||
|
int errorCount = 1;
|
||||||
|
StringBuilder errorLog = new StringBuilder();
|
||||||
|
//循环调用接口 获取数据
|
||||||
|
try {
|
||||||
|
for (SysDictData sysDictData : oaFormid) {
|
||||||
|
String dictValue = sysDictData.getDictValue();
|
||||||
|
String oaData = getOAData(dictValue);
|
||||||
|
System.out.println(oaData);
|
||||||
|
if (oaData != null && !oaData.isEmpty()){
|
||||||
|
if (oaData.contains("ErrorCode")){
|
||||||
|
errorLog.append(errorCount++ + "、"+ "获取"+ sysDictData.getDictLabel() + "数据失败!:" + oaData + "\n");
|
||||||
|
}else{
|
||||||
|
//保存数据
|
||||||
|
switch (dictValue){
|
||||||
|
case "SAL_DELIVERYNOTICE":
|
||||||
|
//保存数据
|
||||||
|
makePoundAppliFormData(dictValue);
|
||||||
|
break;
|
||||||
|
case "PUR_ReceiveBill":
|
||||||
|
//保存数据
|
||||||
|
makePoundAppliFormData(dictValue);
|
||||||
|
break;
|
||||||
|
case "STK_TRANSFERAPPLY":
|
||||||
|
//保存数据
|
||||||
|
makeMainPoundFormData(dictValue);
|
||||||
|
break;
|
||||||
|
case "SP_InStock":
|
||||||
|
//保存数据
|
||||||
|
makeMainPoundFormData(dictValue);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
errorLog.append(errorCount++ + "、"+ "获取数据失败!: 因未知错误导致返回参数为空!" + "\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
errorLog.append(errorCount++ + "、"+ "获取"+ sysDictData.getDictLabel() + "数据失败!: 因未知错误导致返回参数为空!" + "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
errorLog.append(errorCount++ + "、"+ "获取数据失败!: " + e.getMessage() + "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (errorCount > 1){
|
||||||
|
throw new RuntimeException(errorLog.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//调用OA系统接口拉取各个单据的数据
|
||||||
|
public String getOAData(String dictValue){
|
||||||
|
// 目标URL
|
||||||
|
String url = sysConfigService.selectConfigByKey("OA_Url")+"/k3cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.ExecuteBillQuery.common.kdsvc";
|
||||||
|
|
||||||
|
//记录错误日志
|
||||||
|
StringBuilder errorLog = new StringBuilder();
|
||||||
|
try {
|
||||||
|
// 构建请求体,包含参数
|
||||||
|
String jsonInputString = sysConfigService.selectConfigByKey(dictValue+"_raw");
|
||||||
|
// 创建URL对象
|
||||||
|
URL apiUrl = new URL(url);
|
||||||
|
// 打开连接
|
||||||
|
HttpURLConnection connection = (HttpURLConnection) apiUrl.openConnection();
|
||||||
|
|
||||||
|
// 设置请求方法为POST
|
||||||
|
connection.setRequestMethod("POST");
|
||||||
|
|
||||||
|
// 设置请求头
|
||||||
|
// Content-Type 指定发送的数据格式是JSON,并且字符集为UTF-8
|
||||||
|
connection.setRequestProperty("Content-Type", "application/json; utf-8");
|
||||||
|
// Accept 指定期望接收的数据格式是JSON
|
||||||
|
connection.setRequestProperty("Accept", "application/json");
|
||||||
|
// 设置请求头,包含token
|
||||||
|
String token = getToken();
|
||||||
|
if (token != null && !token.isEmpty()) {
|
||||||
|
connection.setRequestProperty("kdservice-sessionid", token);
|
||||||
|
} else {
|
||||||
|
throw new RuntimeException("获取到的Token为空,无法设置请求头。");
|
||||||
|
}
|
||||||
|
// 允许写入请求体
|
||||||
|
connection.setDoOutput(true);
|
||||||
|
|
||||||
|
// 获取输出流,发送请求体数据
|
||||||
|
try (OutputStream os = connection.getOutputStream()) {
|
||||||
|
byte[] input = jsonInputString.getBytes("utf-8");
|
||||||
|
os.write(input, 0, input.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取响应码
|
||||||
|
int responseCode = connection.getResponseCode();
|
||||||
|
|
||||||
|
// 读取响应内容
|
||||||
|
StringBuilder response = new StringBuilder();
|
||||||
|
try (BufferedReader br = new BufferedReader(
|
||||||
|
new InputStreamReader(connection.getInputStream(), "utf-8"))) {
|
||||||
|
String responseLine = null;
|
||||||
|
while ((responseLine = br.readLine()) != null) {
|
||||||
|
response.append(responseLine.trim());
|
||||||
|
}
|
||||||
|
return response.toString();
|
||||||
|
}catch (Exception e) {
|
||||||
|
// throw new RuntimeException("因未知原因导致获取数据失败!");
|
||||||
|
errorLog.append("因未知原因导致获取数据失败!\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
// throw new RuntimeException(e);
|
||||||
|
errorLog.append("获取数据失败!: " + e.getMessage()+ "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return errorLog.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
//保存星空数据为中台<过磅申请>数据
|
||||||
|
public void makePoundAppliFormData(String formid){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//保存星空数据为中台<主榜单>数据
|
||||||
|
public void makeMainPoundFormData(String formid){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -36,11 +36,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<result property="crtopr" column="crtopr" />
|
<result property="crtopr" column="crtopr" />
|
||||||
<result property="lstedtdt" column="lstedtdt" />
|
<result property="lstedtdt" column="lstedtdt" />
|
||||||
<result property="lstedtopr" column="lstedtopr" />
|
<result property="lstedtopr" column="lstedtopr" />
|
||||||
|
<result property="fid" column="fid" />
|
||||||
|
<result property="fentity_fentryid" column="fentity_fentryid" />
|
||||||
|
<result property="oabilltype" column="oabilltype" />
|
||||||
<result property="remark" column="remark" />
|
<result property="remark" column="remark" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectPoundappliVo">
|
<sql id="selectPoundappliVo">
|
||||||
select id, bllstate, usrcode, bsndt, carno, itmname, specification, sendunitid, sendunitname, recentname, trnentname,srcbsndt, srcpunbll, srcwghmqty, srcempmqty, srccleanmqty, srcbsndt, msrunit, msrname, itmno, cardriver, poundid, poundname,srcbilltype, srcbillusrcode, crtorgid, isinuse, crtdt, crtopr, lstedtdt, lstedtopr, remark from t_data_poundappli
|
select id, bllstate, usrcode, bsndt, carno, itmname, specification, sendunitid, sendunitname, recentname, trnentname,srcbsndt, srcpunbll, srcwghmqty, srcempmqty, srccleanmqty, srcbsndt, msrunit, msrname, itmno, cardriver, poundid, poundname,srcbilltype, srcbillusrcode, crtorgid, isinuse, crtdt, crtopr, lstedtdt, lstedtopr, fid, fentity_fentryid, oabilltype, remark from t_data_poundappli
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectPoundappliList" parameterType="Poundappli" resultMap="PoundappliResult">
|
<select id="selectPoundappliList" parameterType="Poundappli" resultMap="PoundappliResult">
|
||||||
|
@ -74,6 +77,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="crtopr != null and crtopr != ''"> and crtopr = #{crtopr}</if>
|
<if test="crtopr != null and crtopr != ''"> and crtopr = #{crtopr}</if>
|
||||||
<if test="lstedtdt != null "> and lstedtdt = #{lstedtdt}</if>
|
<if test="lstedtdt != null "> and lstedtdt = #{lstedtdt}</if>
|
||||||
<if test="lstedtopr != null and lstedtopr != ''"> and lstedtopr = #{lstedtopr}</if>
|
<if test="lstedtopr != null and lstedtopr != ''"> and lstedtopr = #{lstedtopr}</if>
|
||||||
|
<if test="fid != null and fid != ''"> and fid = #{fid}</if>
|
||||||
|
<if test="fentity_fentryid != null and fentity_fentryid != ''"> and fentity_fentryid = #{fentity_fentryid}</if>
|
||||||
|
<if test="oabilltype != null and oabilltype != ''"> and oabilltype = #{oabilltype}</if>
|
||||||
</where>
|
</where>
|
||||||
order by crtdt desc
|
order by crtdt desc
|
||||||
</select>
|
</select>
|
||||||
|
@ -115,6 +121,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="crtopr != null">crtopr,</if>
|
<if test="crtopr != null">crtopr,</if>
|
||||||
<if test="lstedtdt != null">lstedtdt,</if>
|
<if test="lstedtdt != null">lstedtdt,</if>
|
||||||
<if test="lstedtopr != null">lstedtopr,</if>
|
<if test="lstedtopr != null">lstedtopr,</if>
|
||||||
|
<if test="fid != null">fid,</if>
|
||||||
|
<if test="fentity_fentryid != null">fentity_fentryid,</if>
|
||||||
|
<if test="oabilltype != null">oabilltype,</if>
|
||||||
<if test="remark != null">remark,</if>
|
<if test="remark != null">remark,</if>
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
@ -147,6 +156,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="crtopr != null">#{crtopr},</if>
|
<if test="crtopr != null">#{crtopr},</if>
|
||||||
<if test="lstedtdt != null">#{lstedtdt},</if>
|
<if test="lstedtdt != null">#{lstedtdt},</if>
|
||||||
<if test="lstedtopr != null">#{lstedtopr},</if>
|
<if test="lstedtopr != null">#{lstedtopr},</if>
|
||||||
|
<if test="fid != null">#{fid},</if>
|
||||||
|
<if test="fentity_fentryid != null">#{fentity_fentryid},</if>
|
||||||
|
<if test="oabilltype != null">#{oabilltype},</if>
|
||||||
<if test="remark != null">#{remark},</if>
|
<if test="remark != null">#{remark},</if>
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
|
@ -182,6 +194,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="crtopr != null">crtopr = #{crtopr},</if>
|
<if test="crtopr != null">crtopr = #{crtopr},</if>
|
||||||
<if test="lstedtdt != null">lstedtdt = #{lstedtdt},</if>
|
<if test="lstedtdt != null">lstedtdt = #{lstedtdt},</if>
|
||||||
<if test="lstedtopr != null">lstedtopr = #{lstedtopr},</if>
|
<if test="lstedtopr != null">lstedtopr = #{lstedtopr},</if>
|
||||||
|
<if test="fid != null">fid = #{fid},</if>
|
||||||
|
<if test="fentity_fentryid != null">fentity_fentryid = #{fentity_fentryid},</if>
|
||||||
|
<if test="oabilltype != null">oabilltype = #{oabilltype},</if>
|
||||||
<if test="remark != null">remark = #{remark},</if>
|
<if test="remark != null">remark = #{remark},</if>
|
||||||
</trim>
|
</trim>
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class SysConfig extends BaseEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotBlank(message = "参数键值不能为空")
|
@NotBlank(message = "参数键值不能为空")
|
||||||
@Size(min = 0, max = 500, message = "参数键值长度不能超过500个字符")
|
@Size(min = 0, max = 2000, message = "参数键值长度不能超过2000个字符")
|
||||||
public String getConfigValue()
|
public String getConfigValue()
|
||||||
{
|
{
|
||||||
return configValue;
|
return configValue;
|
||||||
|
|
|
@ -148,7 +148,7 @@
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- 添加或修改参数配置对话框 -->
|
<!-- 添加或修改参数配置对话框 -->
|
||||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
<el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
|
||||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||||
<el-form-item label="参数名称" prop="configName">
|
<el-form-item label="参数名称" prop="configName">
|
||||||
<el-input v-model="form.configName" placeholder="请输入参数名称" />
|
<el-input v-model="form.configName" placeholder="请输入参数名称" />
|
||||||
|
@ -157,7 +157,7 @@
|
||||||
<el-input v-model="form.configKey" placeholder="请输入参数键名" />
|
<el-input v-model="form.configKey" placeholder="请输入参数键名" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="参数键值" prop="configValue">
|
<el-form-item label="参数键值" prop="configValue">
|
||||||
<el-input v-model="form.configValue" type="textarea" placeholder="请输入参数键值" />
|
<el-input v-model="form.configValue" type="textarea" :rows="10" placeholder="请输入参数键值" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="系统内置" prop="configType">
|
<el-form-item label="系统内置" prop="configType">
|
||||||
<el-radio-group v-model="form.configType">
|
<el-radio-group v-model="form.configType">
|
||||||
|
|
Loading…
Reference in New Issue