From 1fd5b4d93d5c0c3b680a4af7e7dce3119c3b1667 Mon Sep 17 00:00:00 2001
From: 16358 <1635849544@qq.com>
Date: Tue, 17 Jun 2025 17:33:30 +0800
Subject: [PATCH] =?UTF-8?q?=E6=98=9F=E7=A9=BA=E5=AF=B9=E6=8E=A5=E6=8E=A5?=
=?UTF-8?q?=E5=8F=A3=E5=BC=80=E5=8F=91?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../java/com/ruoyi/bill/domain/PoundBill.java | 57 ++++-
.../com/ruoyi/bill/domain/Poundappli.java | 24 +-
.../java/com/ruoyi/bill/domain/Poundmst.java | 22 ++
.../java/com/ruoyi/webApi/ApiPostBack.java | 233 ++++++++++++++++++
.../main/java/com/ruoyi/webApi/ApiTask.java | 10 +-
.../measurement/bill/PoundBillMapper.xml | 29 ++-
.../measurement/bill/PoundappliMapper.xml | 12 +-
.../measurement/bill/PoundmstMapper.xml | 10 +-
8 files changed, 384 insertions(+), 13 deletions(-)
create mode 100644 measurement/src/main/java/com/ruoyi/webApi/ApiPostBack.java
diff --git a/measurement/src/main/java/com/ruoyi/bill/domain/PoundBill.java b/measurement/src/main/java/com/ruoyi/bill/domain/PoundBill.java
index 2630fb2..594bc17 100644
--- a/measurement/src/main/java/com/ruoyi/bill/domain/PoundBill.java
+++ b/measurement/src/main/java/com/ruoyi/bill/domain/PoundBill.java
@@ -285,6 +285,37 @@ public class PoundBill extends BaseEntity
@Excel(name = "最后修改人")
private String lstedtopr;
+ //打印次数
+ private Long printcount;
+
+ //星空ID
+ private String fid;
+
+ //星空分录ID
+ private String fentity_fentryid;
+
+ //直供商id
+ private String zgsId;
+
+ //直供商名称
+ private String zgsName;
+
+ public String getZgsId() {
+ return zgsId;
+ }
+
+ public void setZgsId(String zgsId) {
+ this.zgsId = zgsId;
+ }
+
+ public String getZgsName() {
+ return zgsName;
+ }
+
+ public void setZgsName(String zgsName) {
+ this.zgsName = zgsName;
+ }
+
public void setId(String id)
{
this.id = id;
@@ -295,7 +326,31 @@ public class PoundBill extends BaseEntity
return id;
}
- public void setBillstate(String billstate)
+ 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 Long getPrintcount() {
+ return printcount;
+ }
+
+ public void setPrintcount(Long printcount) {
+ this.printcount = printcount;
+ }
+
+ public void setBillstate(String billstate)
{
this.billstate = billstate;
}
diff --git a/measurement/src/main/java/com/ruoyi/bill/domain/Poundappli.java b/measurement/src/main/java/com/ruoyi/bill/domain/Poundappli.java
index 321f272..05368ee 100644
--- a/measurement/src/main/java/com/ruoyi/bill/domain/Poundappli.java
+++ b/measurement/src/main/java/com/ruoyi/bill/domain/Poundappli.java
@@ -156,7 +156,29 @@ public class Poundappli extends BaseEntity
//星空单据类型
private String oabilltype;
- public void setId(String id)
+ //直供商id
+ private String zgsId;
+
+ //直供商名称
+ private String zgsName;
+
+ public String getZgsId() {
+ return zgsId;
+ }
+
+ public void setZgsId(String zgsId) {
+ this.zgsId = zgsId;
+ }
+
+ public String getZgsName() {
+ return zgsName;
+ }
+
+ public void setZgsName(String zgsName) {
+ this.zgsName = zgsName;
+ }
+
+ public void setId(String id)
{
this.id = id;
}
diff --git a/measurement/src/main/java/com/ruoyi/bill/domain/Poundmst.java b/measurement/src/main/java/com/ruoyi/bill/domain/Poundmst.java
index ac11396..1f2e2e5 100644
--- a/measurement/src/main/java/com/ruoyi/bill/domain/Poundmst.java
+++ b/measurement/src/main/java/com/ruoyi/bill/domain/Poundmst.java
@@ -210,6 +210,28 @@ public class Poundmst extends BaseEntity
@Excel(name = "生产车间编号")
private String sccjNum;
+ //直供商id
+ private String zgsId;
+
+ //直供商名称
+ private String zgsName;
+
+ public String getZgsId() {
+ return zgsId;
+ }
+
+ public void setZgsId(String zgsId) {
+ this.zgsId = zgsId;
+ }
+
+ public String getZgsName() {
+ return zgsName;
+ }
+
+ public void setZgsName(String zgsName) {
+ this.zgsName = zgsName;
+ }
+
public void setId(String id)
{
this.id = id;
diff --git a/measurement/src/main/java/com/ruoyi/webApi/ApiPostBack.java b/measurement/src/main/java/com/ruoyi/webApi/ApiPostBack.java
new file mode 100644
index 0000000..df33e1f
--- /dev/null
+++ b/measurement/src/main/java/com/ruoyi/webApi/ApiPostBack.java
@@ -0,0 +1,233 @@
+package com.ruoyi.webApi;
+
+import com.ruoyi.bill.domain.PoundBill;
+import com.ruoyi.bill.domain.Poundappli;
+import com.ruoyi.bill.service.IPoundBillService;
+import com.ruoyi.bill.service.IPoundappliService;
+import com.ruoyi.system.service.ISysConfigService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+/**
+ * 各个单据回传星空接口(单据更新,单据下推)
+ * @author 16358
+ * @date 2025/6/16
+ */
+@Component("apiPostBack")
+public class ApiPostBack {
+ @Autowired
+ private ISysConfigService sysConfigService;
+
+ private ApiTask apiTask;
+
+ private IPoundBillService poundBillService;
+
+ /**
+ * 磅单信息对象更新回星空
+ * @return 回传成功报文/错误日志信息
+ */
+
+ public String makePoundBillFormData(String id){
+
+ PoundBill poundBill = poundBillService.selectPoundBillById(id);
+ if(poundBill == null) throw new RuntimeException("磅单不存在!");
+ // 目标URL
+ String url = sysConfigService.selectConfigByKey("OA_Url")+"/k3cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.save.common.kdsvc";
+
+ String jsonInputString = "";
+ String oabilltype = poundBill.getSrcblltype();
+ if("SAL_DELIVERYNOTICE".equals(oabilltype)){
+ //发货通知单
+ jsonInputString = "{\n" +
+ " \"Formid\": \"SAL_DELIVERYNOTICE\",\n" +
+ " \"data\": {\n" +
+ " \"NeedUpDateFields\": [],\n" +
+ " \"NeedReturnFields\": [],\n" +
+ " \"IsDeleteEntry\": \"true\",\n" +
+ " \"IsAutoAdjustField\": \"true\",\n" +
+ " \"Model\": {\n" +
+ " \"FID\": \""+poundBill.getFid()+"\",\n" +
+ " \"F_GMSHDW\": \""+poundBill.getRecunitid()+"\",\n" +
+ " \"F_CYDW\": \""+poundBill.getTrnunitid()+"\",\n" +
+ " \"F_BDMC\":\""+poundBill.getPoundname()+" \",\n" +
+ " \"FEntity\": [\n" +
+ " {\n" +
+ " \"FEntryID\": "+poundBill.getFentity_fentryid()+",\n" +
+ " \"F_JLHCSL\": \""+poundBill.getNetmqty()+"\",\n" +
+ " \"F_YMZ\": \""+poundBill.getSrcwghmqty()+"\",\n" +
+ " \"F_YPZ\": \""+poundBill.getSrcempmqty()+"\",\n" +
+ " \"F_JS\": \""+poundBill.getNetmqty()+"\"\n" +
+ " }\n" +
+ " ]\n" +
+ " }\n" +
+ " }\n" +
+ "}";
+ }else if("PUR_ReceiveBill".equals(oabilltype)){
+ //收料通知单
+ jsonInputString = "{\n" +
+ " \"Formid\": \"PUR_ReceiveBill\",\n" +
+ " \"data\": {\n" +
+ " \"NeedUpDateFields\": [],\n" +
+ " \"NeedReturnFields\": [],\n" +
+ " \"IsDeleteEntry\": \"true\",\n" +
+ " \"IsAutoAdjustField\": \"true\",\n" +
+ " \"Model\": {\n" +
+ " \"FID\": \""+poundBill.getFid()+"\",\n" +
+ " \"F_GMSHDW\": \""+poundBill.getRecunitid()+"\",\n" +
+ " \"F_CYDW\": \""+poundBill.getTrnunitid()+"\",\n" +
+ " \"F_BDMC\":\""+poundBill.getPoundname()+" \",\n" +
+ " \"FDetailEntity\": [\n" +
+ " {\n" +
+ " \"FEntryID\": "+poundBill.getFentity_fentryid()+",\n" +
+ " \"F_JLHCSL\": \""+poundBill.getNetmqty()+"\",\n" +
+ " \"F_YMZ\": \""+poundBill.getSrcwghmqty()+"\",\n" +
+ " \"F_YPZ\": \""+poundBill.getSrcempmqty()+"\",\n" +
+ " \"F_JS\": \""+poundBill.getNetmqty()+"\"\n" +
+ " }\n" +
+ " ]\n" +
+ " }\n" +
+ " }\n" +
+ "}";
+ }else if("STK_TRANSFERAPPLY".equals(oabilltype)){
+ //调拨申请单
+ jsonInputString = "{\n" +
+ " \"Formid\": \"STK_TRANSFERAPPLY\",\n" +
+ " \"data\": {\n" +
+ " \"NeedUpDateFields\": [],\n" +
+ " \"NeedReturnFields\": [],\n" +
+ " \"IsDeleteEntry\": \"true\",\n" +
+ " \"IsAutoAdjustField\": \"true\",\n" +
+ " \"Model\": {\n" +
+ " \"FID\": \""+poundBill.getFid()+"\",\n" +
+ " \"F_DYCS\": "+poundBill.getPrintcount()+", \n" +
+ " \"F_CYDW\": \""+poundBill.getTrnunitid()+"\", \n" +
+ " \"F_FHDW\": \""+poundBill.getSendunitid()+"\", \n" +
+ " \"F_SHDW\": \""+poundBill.getRecunitid()+"\", \n" +
+ " \"F_ZGS\": "+poundBill.getZgsId()+", \n" +
+ " \"FEntity\": [\n" +
+ " {\n" +
+ " \"FEntryID\": "+poundBill.getFentity_fentryid()+",\n" +
+ " \"F_JLHCSL\": \""+poundBill.getNetmqty()+"\" \n" +
+ " }\n" +
+ " ]\n" +
+ " }\n" +
+ " }\n" +
+ "}";
+ }else if("SP_InStock".equals(oabilltype)){
+ //简单生产入库单
+ jsonInputString = "{\n" +
+ " \"Formid\": \"SP_InStock\",\n" +
+ " \"data\": {\n" +
+ " \"NeedUpDateFields\": [],\n" +
+ " \"NeedReturnFields\": [],\n" +
+ " \"IsDeleteEntry\": \"true\",\n" +
+ " \"IsAutoAdjustField\": \"true\",\n" +
+ " \"Model\": {\n" +
+ " \"FID\": \""+poundBill.getFid()+"\",\n" +
+ " \"F_YWBD\": \""+poundBill.getPoundid()+"\",\n" +
+ " \"F_SJYWBD\": \""+poundBill.getPoundid()+"\",\n" +
+ " \"F_ZGS\": "+poundBill.getZgsId()+", \n" +
+ " \"F_FHDW\": \""+poundBill.getSendunitid()+"\", \n" +
+ " \"F_SHDW\": \""+poundBill.getRecunitid()+"\", \n" +
+ " \"FEntity\": [\n" +
+ " {\n" +
+ " \"FEntryID\": "+poundBill.getFentity_fentryid()+",\n" +
+ " \"FMaterialId\": {\n" +
+ " \"FNumber\": \"\"\n" +
+ " },\n" +
+ " \"FInStockType\": \"1\",\n" +
+ " \"FMustQty\": "+poundBill.getNetmqty()+",\n" +
+ " \"FRealQty\": "+poundBill.getNetmqty()+",\n" +
+ " \"FStockId\": {\n" +
+ " \"FNumber\": \"\"\n" +
+ " },\n" +
+ " \"FWorkShopId1\": {\n" +
+ " \"FNumber\": \"\"\n" +
+ " },\n" +
+ " \"FShiftGroupId\": {\n" +
+ " \"FNumber\": \"\"\n" +
+ " },\n" +
+ " \"F_CZ\": 0,\n" +
+ " \"FMemo\": \""+poundBill.getRemark()+"\",\n" +
+ " \"F_LC\": \""+poundBill.getBoilerno()+"\",\n" +
+ " \"F_GH\": 0,\n" +
+ " \"F_GANGH\": \""+poundBill.getSteeno()+"\",\n" +
+ " \"F_ZKS\": 0,\n" +
+ " \"F_KH\": 0,\n" +
+ " \"F_PJZL\": 0,\n" +
+ " \"F_XCLX\": \""+poundBill.getLinetype()+"\",\n" +
+ " \"F_PH\": \""+poundBill.getBatno()+"\"\n" +
+ " }\n" +
+ " ]\n" +
+ " }\n" +
+ " }\n" +
+ "}";
+ }else {
+ throw new RuntimeException("单据类型错误!");
+ }
+
+ //记录错误日志
+ StringBuilder errorLog = new StringBuilder();
+ try {
+ // 创建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 = apiTask.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();
+ }
+
+}
\ No newline at end of file
diff --git a/measurement/src/main/java/com/ruoyi/webApi/ApiTask.java b/measurement/src/main/java/com/ruoyi/webApi/ApiTask.java
index 5a8677c..dec9dc9 100644
--- a/measurement/src/main/java/com/ruoyi/webApi/ApiTask.java
+++ b/measurement/src/main/java/com/ruoyi/webApi/ApiTask.java
@@ -287,11 +287,7 @@ public class ApiTask {
poundappli.setFentity_fentryid(fentryid);
poundappli.setSrcbillusrcode(sourceBillNo);
poundappli.setOabilltype(formid);//星空单据类型
- if("SAL_DELIVERYNOTICE".equals(formid)){
- poundappli.setSrcbilltype("发货通知单");//来源单据类型
- }else {
- poundappli.setSrcbilltype("收料通知单");//来源单据类型
- }
+ poundappli.setSrcbilltype(formid);//来源单据类型
poundappliService.insertPoundappliDpi(poundappli);
}
@@ -338,7 +334,7 @@ public class ApiTask {
poundmst.setSccjNum(sccjNumber);
poundmst.setBbno(bbno);
poundmst.setOabilltype(formid);//星空单据类型
- poundmst.setSrcbllknd("简单生产入库单");//来源单据类型
+ poundmst.setSrcbllknd(formid);//来源单据类型
poundmstService.insertPoundmstDpi(poundmst);
}
@@ -371,7 +367,7 @@ public class ApiTask {
poundmst.setQty(qty);
poundmst.setFentity_fentryid(fentryid);
poundmst.setOabilltype(formid);//星空单据类型
- poundmst.setSrcbllknd("调拨申请单");//来源单据类型
+ poundmst.setSrcbllknd(formid);//来源单据类型
poundmstService.insertPoundmstDpi(poundmst);
}
diff --git a/measurement/src/main/resources/mapper/measurement/bill/PoundBillMapper.xml b/measurement/src/main/resources/mapper/measurement/bill/PoundBillMapper.xml
index 64dd1f0..72a608d 100644
--- a/measurement/src/main/resources/mapper/measurement/bill/PoundBillMapper.xml
+++ b/measurement/src/main/resources/mapper/measurement/bill/PoundBillMapper.xml
@@ -67,6 +67,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+
+
+
+
+
@@ -75,7 +80,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- select id, billstate, usrcode, carno, wghmqty, empmqty, netmqty, wghdt, empdt, srcpunmqty, srcwghmqty, srcempmqty, srcnetmqty, itmname, wghdtoprname, empdtoprname, specification, msrname, poundid, poundname, empsysid, empusrcode, wghsysid, wghusrcode, recunitid, recunitname, sendunitid, sendunitname, trnunitid, trnunitname, bsnunitid, bsnunitname, bsndptid, bsndptname, wghtype, scltype, cardriver, srcblltype, pondsrc, wetusrcode, srcbllusrcode, remark, boilerno,agnstatus,agngrossmqty,agntaremqty,agnnetmqty,ductmqty,ductmqtypre, steeno, unitlen, indexid, carnolz, steeltype, linetype, batno, lzno, lqty, bdcode, crtorgid, isinuse, crtdt, crtopr, lstedtdt, lstedtopr from t_data_poundbill
+ select id, billstate, usrcode, carno, wghmqty, empmqty, netmqty, wghdt, empdt, srcpunmqty, srcwghmqty, srcempmqty, srcnetmqty, itmname, wghdtoprname, empdtoprname, specification, msrname, poundid, poundname, empsysid, empusrcode, wghsysid, wghusrcode, recunitid, recunitname, sendunitid, sendunitname, trnunitid, trnunitname, bsnunitid, bsnunitname, bsndptid, bsndptname, wghtype, scltype, cardriver, srcblltype, pondsrc, wetusrcode, srcbllusrcode, remark, boilerno,agnstatus,agngrossmqty,agntaremqty,agnnetmqty,ductmqty,ductmqtypre, steeno, unitlen, indexid, carnolz, steeltype, linetype, batno, lzno, lqty, bdcode, crtorgid, printcount, zgsId, zgsName, fid, fentity_fentryid, isinuse, crtdt, crtopr, lstedtdt, lstedtopr from t_data_poundbill