1
This commit is contained in:
parent
62d5f56b8e
commit
db2ccb8c3b
@ -2,20 +2,19 @@ package com.gatedge.jindie.controller;
|
|||||||
|
|
||||||
import com.gatedge.jindie.entity.Entity;
|
import com.gatedge.jindie.entity.Entity;
|
||||||
import com.gatedge.jindie.entity.EntityItem;
|
import com.gatedge.jindie.entity.EntityItem;
|
||||||
import com.gatedge.jindie.entity.EntityVO;
|
|
||||||
import com.gatedge.jindie.result.ActionResult;
|
import com.gatedge.jindie.result.ActionResult;
|
||||||
import com.gatedge.jindie.result.ListResult;
|
import com.gatedge.jindie.result.ListResult;
|
||||||
import com.gatedge.jindie.result.ResponseBodyMessage;
|
import com.gatedge.jindie.result.ResponseBodyMessage;
|
||||||
import com.gatedge.jindie.result.ResultBuilder;
|
import com.gatedge.jindie.result.ResultBuilder;
|
||||||
import com.gatedge.jindie.service.SealedQuotationService;
|
import com.gatedge.jindie.service.SealedQuotationService;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import sun.misc.BASE64Encoder;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.Base64;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -31,6 +30,7 @@ import java.util.Map;
|
|||||||
@RequestMapping("/admin/")
|
@RequestMapping("/admin/")
|
||||||
public class SealedQuotationController {
|
public class SealedQuotationController {
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(SealedQuotationController.class);
|
||||||
@Autowired
|
@Autowired
|
||||||
private SealedQuotationService sealedQuotationService;
|
private SealedQuotationService sealedQuotationService;
|
||||||
|
|
||||||
@ -47,7 +47,6 @@ public class SealedQuotationController {
|
|||||||
@PostMapping("queryData")
|
@PostMapping("queryData")
|
||||||
public ListResult queryData(@RequestBody Map<String, String> map) {
|
public ListResult queryData(@RequestBody Map<String, String> map) {
|
||||||
String FBILLNO = map.get("FBILLNO");
|
String FBILLNO = map.get("FBILLNO");
|
||||||
UploadFbillNo = map.get("UploadFbillNo");
|
|
||||||
List<Entity> data = null;
|
List<Entity> data = null;
|
||||||
if (sealedQuotationService.loginChack(map)) {
|
if (sealedQuotationService.loginChack(map)) {
|
||||||
data= sealedQuotationService.queryData(FBILLNO);
|
data= sealedQuotationService.queryData(FBILLNO);
|
||||||
@ -58,7 +57,6 @@ public class SealedQuotationController {
|
|||||||
@PostMapping("queryDataItem")
|
@PostMapping("queryDataItem")
|
||||||
public ListResult queryDataItem(@RequestBody Map<String, String> map) {
|
public ListResult queryDataItem(@RequestBody Map<String, String> map) {
|
||||||
String FBILLNO = map.get("FBILLNO");
|
String FBILLNO = map.get("FBILLNO");
|
||||||
UploadFbillNo = map.get("UploadFbillNo");
|
|
||||||
List<EntityItem> data = null;
|
List<EntityItem> data = null;
|
||||||
if (sealedQuotationService.loginChack(map)) {
|
if (sealedQuotationService.loginChack(map)) {
|
||||||
data= sealedQuotationService.queryDataItem(FBILLNO);
|
data= sealedQuotationService.queryDataItem(FBILLNO);
|
||||||
@ -73,18 +71,31 @@ public class SealedQuotationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/upload")
|
@PostMapping("/upload")
|
||||||
public ResponseBodyMessage upload(@RequestParam("file") MultipartFile file) throws IOException {
|
public ResponseBodyMessage upload(@RequestParam("file") MultipartFile file,
|
||||||
if (!file.isEmpty()) {
|
@RequestParam("FBILLNO1") String Fbillno) throws IOException {
|
||||||
//获取上传文件文件名
|
// 获取文件名
|
||||||
String fileName = file.getOriginalFilename();
|
String fileName = file.getOriginalFilename();
|
||||||
//获取上传文件的Base64
|
// 获取文件内容并转换为 Base64 编码
|
||||||
BASE64Encoder base64Encoder =new BASE64Encoder();
|
String fileBase64 = Base64.getEncoder().encodeToString(file.getBytes());
|
||||||
String fileBase64 = base64Encoder.encode(file.getBytes());
|
|
||||||
String FIDrestful = sealedQuotationService.InterId(UploadFbillNo);
|
System.out.println("文件名为:" + fileName);
|
||||||
responseBodyMessage = sealedQuotationService.uploadFile(FIDrestful,fileName,fileBase64,UploadFbillNo);
|
System.out.println("文件抓取BASE64值:" + fileBase64);
|
||||||
System.out.println("解析JSON数据:"+ responseBodyMessage.getMessage());
|
System.out.println("单据编号 :" + Fbillno);
|
||||||
return responseBodyMessage;
|
|
||||||
}
|
// 调用服务层方法处理文件上传逻辑
|
||||||
return new ResponseBodyMessage(0,"未选择文件,附近上传失败");
|
String FIDrestful = sealedQuotationService.InterId(Fbillno);
|
||||||
|
System.out.println("文件获取FID值:" + FIDrestful);
|
||||||
|
|
||||||
|
// 调用服务层方法上传文件
|
||||||
|
ResponseBodyMessage responseBodyMessage = sealedQuotationService.uploadFile(FIDrestful, fileName, fileBase64, Fbillno);
|
||||||
|
System.out.println("解析JSON数据:" + responseBodyMessage.getMessage());
|
||||||
|
|
||||||
|
return responseBodyMessage;
|
||||||
|
}
|
||||||
|
@GetMapping("/CreateFile")
|
||||||
|
public ListResult CreateFile(@RequestParam String Fbillno) {
|
||||||
|
List<EntityItem> data = null;
|
||||||
|
|
||||||
|
return ResultBuilder.buildEntitySuccess(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,61 @@
|
|||||||
|
package com.gatedge.jindie.entity;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ligoudan
|
||||||
|
* @create 2025-04-09 19:08
|
||||||
|
* 相应JSON的反应实体类
|
||||||
|
*/
|
||||||
|
public class FileEntityItem {
|
||||||
|
@JsonProperty("FATTACHMENTNAME")
|
||||||
|
private String FATTACHMENTNAME;//文件名
|
||||||
|
|
||||||
|
@JsonProperty("FATTACHMENTSIZE")
|
||||||
|
private String FATTACHMENTSIZE;//文件大小
|
||||||
|
|
||||||
|
@JsonProperty("FCREATETIME")
|
||||||
|
private String FCREATETIME;
|
||||||
|
|
||||||
|
@JsonProperty("FID")
|
||||||
|
private String FID;
|
||||||
|
|
||||||
|
public FileEntityItem(String FATTACHMENTNAME, String FATTACHMENTSIZE, String FCREATETIME, String FID) {
|
||||||
|
this.FATTACHMENTNAME = FATTACHMENTNAME;
|
||||||
|
this.FATTACHMENTSIZE = FATTACHMENTSIZE;
|
||||||
|
this.FCREATETIME = FCREATETIME;
|
||||||
|
this.FID = FID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFATTACHMENTNAME() {
|
||||||
|
return FATTACHMENTNAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFATTACHMENTNAME(String FATTACHMENTNAME) {
|
||||||
|
this.FATTACHMENTNAME = FATTACHMENTNAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFATTACHMENTSIZE() {
|
||||||
|
return FATTACHMENTSIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFATTACHMENTSIZE(String FATTACHMENTSIZE) {
|
||||||
|
this.FATTACHMENTSIZE = FATTACHMENTSIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFCREATETIME() {
|
||||||
|
return FCREATETIME;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFCREATETIME(String FCREATETIME) {
|
||||||
|
this.FCREATETIME = FCREATETIME;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFID() {
|
||||||
|
return FID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFID(String FID) {
|
||||||
|
this.FID = FID;
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,7 @@ package com.gatedge.jindie.service;
|
|||||||
import com.gatedge.jindie.entity.Entity;
|
import com.gatedge.jindie.entity.Entity;
|
||||||
import com.gatedge.jindie.entity.EntityItem;
|
import com.gatedge.jindie.entity.EntityItem;
|
||||||
import com.gatedge.jindie.entity.EntityVO;
|
import com.gatedge.jindie.entity.EntityVO;
|
||||||
|
import com.gatedge.jindie.entity.FileEntityItem;
|
||||||
import com.gatedge.jindie.result.ResponseBodyMessage;
|
import com.gatedge.jindie.result.ResponseBodyMessage;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -56,4 +57,7 @@ public interface SealedQuotationService {
|
|||||||
|
|
||||||
//根据获取到的单据内码FID,对单据进行附件上传
|
//根据获取到的单据内码FID,对单据进行附件上传
|
||||||
ResponseBodyMessage uploadFile(String FID, String fileName, String fileBase64, String FBillNo);
|
ResponseBodyMessage uploadFile(String FID, String fileName, String fileBase64, String FBillNo);
|
||||||
|
|
||||||
|
//根据单据编号,查询已经上传的附件
|
||||||
|
List<FileEntityItem> queryFiles(String FBillNo);
|
||||||
}
|
}
|
||||||
|
@ -9,10 +9,12 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||||||
import com.gatedge.jindie.entity.Entity;
|
import com.gatedge.jindie.entity.Entity;
|
||||||
import com.gatedge.jindie.entity.EntityItem;
|
import com.gatedge.jindie.entity.EntityItem;
|
||||||
import com.gatedge.jindie.entity.EntityVO;
|
import com.gatedge.jindie.entity.EntityVO;
|
||||||
|
import com.gatedge.jindie.entity.FileEntityItem;
|
||||||
import com.gatedge.jindie.result.ResponseBodyMessage;
|
import com.gatedge.jindie.result.ResponseBodyMessage;
|
||||||
import com.gatedge.jindie.service.SealedQuotationService;
|
import com.gatedge.jindie.service.SealedQuotationService;
|
||||||
|
|
||||||
import com.jayway.jsonpath.JsonPath;
|
import com.jayway.jsonpath.JsonPath;
|
||||||
|
import javafx.collections.ObservableArray;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpEntity;
|
import org.springframework.http.HttpEntity;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
@ -22,6 +24,8 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@ -48,10 +52,14 @@ public class SealedQuotationServiceImpl implements SealedQuotationService {
|
|||||||
|
|
||||||
private String QUERY_DATA_URL="http://192.168.61.20:18081/K3CLOUD/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.ExecuteBillQuery.common.kdsvc";
|
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";
|
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";
|
private String UploadFile = "http://192.168.61.20:18081/K3Cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Save.common.kdsvc";
|
||||||
//查询单据FID的Url
|
//查询单据FID的Url
|
||||||
private String QueryInterId = "http://192.168.10.105/K3Cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.ExecuteBillQuery.common.kdsvc";
|
private String QueryInterId = "http://192.168.61.20:18081/K3Cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.ExecuteBillQuery.common.kdsvc";
|
||||||
|
//查询单据上传附件
|
||||||
|
private String QueryFilesUrl = "http://192.168.61.20:18081/K3Cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.ExecuteBillQuery.common.kdsvc";
|
||||||
|
//查询单据上传附件的主键
|
||||||
|
private String QueryFiles = "FID,FATTACHMENTNAME,FATTACHMENTSIZE,FCREATETIME";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void login(String FBILLNO, String username, String password) {
|
public void login(String FBILLNO, String username, String password) {
|
||||||
@ -161,7 +169,6 @@ public class SealedQuotationServiceImpl implements SealedQuotationService {
|
|||||||
entityItem.setFSEQ(String.valueOf(FSEQ));
|
entityItem.setFSEQ(String.valueOf(FSEQ));
|
||||||
FSEQ++;
|
FSEQ++;
|
||||||
result.add(entityItem);
|
result.add(entityItem);
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
System.err.println("Invalid JSON array format.");
|
System.err.println("Invalid JSON array format.");
|
||||||
@ -343,19 +350,48 @@ public class SealedQuotationServiceImpl implements SealedQuotationService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseBodyMessage uploadFile(String FID, String fileName, String fileBase64, String FBillNo) {
|
public ResponseBodyMessage uploadFile(String FID, String fileName, String fileBase64, String FBillNo) {
|
||||||
Map<String,Object> data = new HashMap<>();
|
// 创建最外层的Map
|
||||||
Map<String,Object> params = new HashMap<>();
|
Map<String, Object> rootMap = new HashMap<>();
|
||||||
params.put("FileName",fileName);
|
// 创建内部的data Map
|
||||||
params.put("FormId","kafe2f22a0498441f9109c31cf5586da5");
|
Map<String, Object> dataMap = new HashMap<>();
|
||||||
params.put("IsLast",true);
|
// 创建Model Map
|
||||||
params.put("InterId",FID);
|
Map<String, Object> modelMap = new HashMap<>();
|
||||||
params.put("BillNO",FBillNo);
|
// 创建FCreateMen Map
|
||||||
params.put("SendByte",fileBase64);
|
Map<String, Object> createMenMap = new HashMap<>();
|
||||||
data.put("data",params);
|
//获取文件后缀名
|
||||||
|
String extension = getFileExtensionWithDot(fileName);
|
||||||
|
//获取当前时间
|
||||||
|
LocalDateTime currentDateTime = LocalDateTime.now();
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||||
|
String formattedDateTime = currentDateTime.format(formatter);
|
||||||
|
|
||||||
|
|
||||||
|
createMenMap.put("FUserID", "100746");
|
||||||
|
|
||||||
|
// 填充Model Map
|
||||||
|
modelMap.put("FAttachmentName", fileName);//文件名
|
||||||
|
modelMap.put("FBillType", "kafe2f22a0498441f9109c31cf5586da5");//单据类型
|
||||||
|
modelMap.put("FInterID", FID);//单据FID
|
||||||
|
modelMap.put("FBillNo", FBillNo);//单据编号
|
||||||
|
modelMap.put("FAttachment", fileBase64);//文件BASE64
|
||||||
|
modelMap.put("FFILESTORAGE", 0);
|
||||||
|
modelMap.put("FExtName", extension);
|
||||||
|
modelMap.put("FEntryinterId", "-1");//单据头附件
|
||||||
|
modelMap.put("FEntrykey", " ");//单据头附近,要传一个空格
|
||||||
|
modelMap.put("FaliasFileName", fileName);
|
||||||
|
modelMap.put("FCreateMen", createMenMap);
|
||||||
|
modelMap.put("FCreateTime",formattedDateTime);
|
||||||
|
|
||||||
|
// 填充data Map
|
||||||
|
dataMap.put("Model", modelMap);
|
||||||
|
|
||||||
|
// 填充最外层的Map
|
||||||
|
rootMap.put("FormId", "BOS_Attachment");
|
||||||
|
rootMap.put("data", dataMap);
|
||||||
String api = loginAPI(null);
|
String api = loginAPI(null);
|
||||||
loginAPI(api);
|
loginAPI(api);
|
||||||
String Json =API(api,data,UploadFile);
|
String Json =API(api,rootMap,UploadFile);
|
||||||
System.out.println(Json);
|
System.out.println("22上传的:"+Json);
|
||||||
Boolean Success = JsonPath.read(Json,"$.Result.ResponseStatus.IsSuccess");
|
Boolean Success = JsonPath.read(Json,"$.Result.ResponseStatus.IsSuccess");
|
||||||
if(Success){
|
if(Success){
|
||||||
return new ResponseBodyMessage(1,"附件上传成功");
|
return new ResponseBodyMessage(1,"附件上传成功");
|
||||||
@ -364,4 +400,65 @@ public class SealedQuotationServiceImpl implements SealedQuotationService {
|
|||||||
return new ResponseBodyMessage(0,"附件上传失败,失败原因:"+message);
|
return new ResponseBodyMessage(0,"附件上传失败,失败原因:"+message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<FileEntityItem> queryFiles(String FBillNo) {
|
||||||
|
Map<String, Object> data = new HashMap<>();
|
||||||
|
Map<String, Object> params = new HashMap<>();
|
||||||
|
params.put("FormId","BOS_Attachment");
|
||||||
|
params.put("FieldKeys",QueryFiles);
|
||||||
|
params.put("FilterString", "FBILLNO like'%" + FBillNo + "'");
|
||||||
|
params.put("OrderString", "");
|
||||||
|
params.put("TopRowCount", "0");
|
||||||
|
params.put("StartRow", "0");
|
||||||
|
params.put("Limit", "100");
|
||||||
|
String api = loginAPI(null);
|
||||||
|
loginAPI(api);
|
||||||
|
String json = API(api,data,QueryFilesUrl);
|
||||||
|
List<FileEntityItem> result = new ArrayList<>();
|
||||||
|
if (json != null) {
|
||||||
|
//可能返回的是个集合,需要处理一下
|
||||||
|
try {
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
JsonNode jsonArray = objectMapper.readTree(json);
|
||||||
|
if (jsonArray.isArray()) {
|
||||||
|
int FSEQ=1;
|
||||||
|
for (JsonNode jsonItem : jsonArray) {
|
||||||
|
String input = jsonItem.toString();
|
||||||
|
input = input.substring(1, input.length() - 1); // 截取字符串,去掉 "[[" 和 "]]"
|
||||||
|
String[] parts = input.split(",");
|
||||||
|
List<String> list = new ArrayList<>();
|
||||||
|
for (String part : parts) {
|
||||||
|
String cleanedPart = part.replaceAll("[\"\\s+]", ""); // 去掉多余的双引号和空格
|
||||||
|
list.add(cleanedPart);
|
||||||
|
}
|
||||||
|
FileEntityItem entityItem = new FileEntityItem(list.get(3),list.get(2),list.get(1),list.get(0));
|
||||||
|
//entityItem.setFSEQ(String.valueOf(FSEQ));
|
||||||
|
FSEQ++;
|
||||||
|
result.add(entityItem);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
System.err.println("Invalid JSON array format.");
|
||||||
|
}
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取文件后缀名的方法
|
||||||
|
* @param fileName 文件名
|
||||||
|
* @return 文件后缀名,如果没有后缀名返回 null
|
||||||
|
*/
|
||||||
|
public static String getFileExtensionWithDot(String fileName) {
|
||||||
|
int dotIndex = fileName.lastIndexOf(".");
|
||||||
|
if (dotIndex != -1 && dotIndex != 0) {
|
||||||
|
return fileName.substring(dotIndex);
|
||||||
|
} else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user