This commit is contained in:
李狗蛋
2025-04-07 21:48:14 +08:00
parent a96448fce7
commit 62d5f56b8e
17 changed files with 13984 additions and 5455 deletions

View File

@@ -8,6 +8,7 @@ public class GatedgeApplication {
public static void main(String[] args) {
SpringApplication.run(GatedgeApplication.class, args);
System.out.println("服务启动成功");
}
}

View File

@@ -5,11 +5,15 @@ import com.gatedge.jindie.entity.EntityItem;
import com.gatedge.jindie.entity.EntityVO;
import com.gatedge.jindie.result.ActionResult;
import com.gatedge.jindie.result.ListResult;
import com.gatedge.jindie.result.ResponseBodyMessage;
import com.gatedge.jindie.result.ResultBuilder;
import com.gatedge.jindie.service.SealedQuotationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import sun.misc.BASE64Encoder;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -30,6 +34,10 @@ public class SealedQuotationController {
@Autowired
private SealedQuotationService sealedQuotationService;
private ResponseBodyMessage responseBodyMessage;
//记录单据编号,用于上传到单据附件管理
private String UploadFbillNo;
@GetMapping("login")
public ActionResult login(@RequestParam("FBILLNO") String FBILLNO, @RequestParam("Username") String username, @RequestParam("Password") String password) {
sealedQuotationService.login(FBILLNO, username, password);
@@ -39,6 +47,7 @@ public class SealedQuotationController {
@PostMapping("queryData")
public ListResult queryData(@RequestBody Map<String, String> map) {
String FBILLNO = map.get("FBILLNO");
UploadFbillNo = map.get("UploadFbillNo");
List<Entity> data = null;
if (sealedQuotationService.loginChack(map)) {
data= sealedQuotationService.queryData(FBILLNO);
@@ -49,6 +58,7 @@ public class SealedQuotationController {
@PostMapping("queryDataItem")
public ListResult queryDataItem(@RequestBody Map<String, String> map) {
String FBILLNO = map.get("FBILLNO");
UploadFbillNo = map.get("UploadFbillNo");
List<EntityItem> data = null;
if (sealedQuotationService.loginChack(map)) {
data= sealedQuotationService.queryDataItem(FBILLNO);
@@ -61,4 +71,20 @@ public class SealedQuotationController {
Map<String, Object> map = sealedQuotationService.saveData(params);
return ResultBuilder.buildEntitySuccess(map);
}
@PostMapping("/upload")
public ResponseBodyMessage upload(@RequestParam("file") MultipartFile file) throws IOException {
if (!file.isEmpty()) {
//获取上传文件文件名
String fileName = file.getOriginalFilename();
//获取上传文件的Base64
BASE64Encoder base64Encoder =new BASE64Encoder();
String fileBase64 = base64Encoder.encode(file.getBytes());
String FIDrestful = sealedQuotationService.InterId(UploadFbillNo);
responseBodyMessage = sealedQuotationService.uploadFile(FIDrestful,fileName,fileBase64,UploadFbillNo);
System.out.println("解析JSON数据"+ responseBodyMessage.getMessage());
return responseBodyMessage;
}
return new ResponseBodyMessage(0,"未选择文件,附近上传失败");
}
}

View File

@@ -0,0 +1,32 @@
package com.gatedge.jindie.result;
/**
* @author 李天华
* @create 2024-12-24 9:43
* 文件上传的返回JSON实体类
*/
public class ResponseBodyMessage {
private int status; //状态码
private String message;
public ResponseBodyMessage(int status, String message) {
this.status = status;
this.message = message;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}

View File

@@ -3,6 +3,7 @@ package com.gatedge.jindie.service;
import com.gatedge.jindie.entity.Entity;
import com.gatedge.jindie.entity.EntityItem;
import com.gatedge.jindie.entity.EntityVO;
import com.gatedge.jindie.result.ResponseBodyMessage;
import java.util.List;
import java.util.Map;
@@ -49,4 +50,10 @@ public interface SealedQuotationService {
Boolean loginChack(Map<String, String> params);
//获取单据内码
String InterId(String FBillNo);
//根据获取到的单据内码FID对单据进行附件上传
ResponseBodyMessage uploadFile(String FID, String fileName, String fileBase64, String FBillNo);
}

View File

@@ -9,8 +9,10 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.gatedge.jindie.entity.Entity;
import com.gatedge.jindie.entity.EntityItem;
import com.gatedge.jindie.entity.EntityVO;
import com.gatedge.jindie.result.ResponseBodyMessage;
import com.gatedge.jindie.service.SealedQuotationService;
import com.jayway.jsonpath.JsonPath;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
@@ -41,10 +43,15 @@ public class SealedQuotationServiceImpl implements SealedQuotationService {
//主表
private String Primary_Meter="Fid,FBILLNO,FProjectName,FSrcBillNo,FSupplierId.FNumber,FSupplierName,FOpenDate,FPriceStatus,FQuoteDate,FExpiryDate,FContact,FPhone,FMail,FCurrId.FName,FIsIncludedTax,FDATE,FBuyer.FName,FCheckerId,FDocumentStatus";
private String Detailed_List="FEntity_FEntryID, FMATERIALID.FNumber,FMaterialId.FName, FUnitID.FName,FQty, FPrice, FTaxRate, FTaxPrice,FNote,FPayConditionId.FName";
//查询表单的FID
private String UploadPrimary_Meter = "FID";
private String QUERY_DATA_URL="http://192.168.61.20:18081/K3CLOUD/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.ExecuteBillQuery.common.kdsvc";
private String SAVA_DATA_URL="http://192.168.61.20:18081/k3cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Save.common.kdsvc";
//上传文件的Url
private String UploadFile = "http://192.168.10.105/K3Cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.AttachmentUpLoad.common.kdsvc";
//查询单据FID的Url
private String QueryInterId = "http://192.168.10.105/K3Cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.ExecuteBillQuery.common.kdsvc";
@Override
public void login(String FBILLNO, String username, String password) {
@@ -315,4 +322,46 @@ public class SealedQuotationServiceImpl implements SealedQuotationService {
return false;
}
}
@Override
public String InterId(String FBillNo) {
Map<String, Object> data = new HashMap<>();
Map<String, Object> params = new HashMap<>();
params.put("FormId","kafe2f22a0498441f9109c31cf5586da5");
params.put("FieldKeys",UploadPrimary_Meter);
params.put("FilterString", "FBILLNO like'%" + FBillNo + "'");
data.put("data", params);
String api = loginAPI(null);
loginAPI(api);
String input = API(api,data,QueryInterId);
if (input != null) {
//截取字符串,去掉[[]]
input = input.substring(2, input.length() - 2);
}
return input;
}
@Override
public ResponseBodyMessage uploadFile(String FID, String fileName, String fileBase64, String FBillNo) {
Map<String,Object> data = new HashMap<>();
Map<String,Object> params = new HashMap<>();
params.put("FileName",fileName);
params.put("FormId","kafe2f22a0498441f9109c31cf5586da5");
params.put("IsLast",true);
params.put("InterId",FID);
params.put("BillNO",FBillNo);
params.put("SendByte",fileBase64);
data.put("data",params);
String api = loginAPI(null);
loginAPI(api);
String Json =API(api,data,UploadFile);
System.out.println(Json);
Boolean Success = JsonPath.read(Json,"$.Result.ResponseStatus.IsSuccess");
if(Success){
return new ResponseBodyMessage(1,"附件上传成功");
}else {
String message = JsonPath.read(Json,"$.Result.ResponseStatus.Errors[0].Message");
return new ResponseBodyMessage(0,"附件上传失败,失败原因:"+message);
}
}
}

View File

@@ -1,3 +1,7 @@
server:
port: 10002
spring:
servlet:
multipart:
max-file-size: 100MB
max-request-size: 100MB