Compare commits
7 Commits
4cd1dadc75
...
fd6ec2e156
Author | SHA1 | Date |
---|---|---|
|
fd6ec2e156 | |
|
9ef284e9f3 | |
|
f19ee30d0b | |
|
e1faf486ce | |
|
bf4d9f2e19 | |
|
f84c0a37bf | |
|
cbeb66f9dd |
|
@ -1,11 +1,14 @@
|
|||
package com.hzya.frame.plugin.grp.service.impl;
|
||||
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.hzya.frame.grpU8.nxproof.oerdjml.entity.OerDjmlEntity;
|
||||
import com.hzya.frame.grpU8.nxproof.oerdjml.service.IOerDjmlExtService;
|
||||
import com.hzya.frame.grpU8.nxproof.oerdjml.service.IOerDjmlService;
|
||||
import com.hzya.frame.plugin.grp.service.IExpensePluginService;
|
||||
import com.hzya.frame.web.entity.JsonResultEntity;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
|
@ -14,7 +14,7 @@ spring:
|
|||
master:
|
||||
url: jdbc:mysql://ufidahz.com.cn:9014/businesscenter?serverTimezone=UTC&useUnicode=true&characterEncoding=UTF8&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowLoadLocalInfile=false&autoReconnect=true&failOverReadOnly=false&connectTimeout=30000&socketTimeout=30000&autoReconnectForPools=true
|
||||
username: root
|
||||
password: 62e4295b615a30dbf3b8ee96f41c820b
|
||||
password: bd993088e8a7c3dc5f44441617f9b4bf
|
||||
driver-class-name: com.mysql.jdbc.Driver # 3.2.0开始支持SPI可省略此配置
|
||||
savefile:
|
||||
# 文件保存路径
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package com.hzya.frame;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.hzya.frame.grpU8.nxproof.oerdjml.dto.FileInfoDTO;
|
||||
import com.hzya.frame.grpU8.nxproof.oerdjml.service.IOerDjmlExtService;
|
||||
import com.hzya.frame.grpU8.nxproof.oerdjml.service.impl.OerDjmlExtServiceImpl;
|
||||
import com.hzya.frame.plugin.grp.plugin.ExpensePluginInitializer;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
@ -8,6 +11,8 @@ import org.springframework.boot.test.context.SpringBootTest;
|
|||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description
|
||||
|
@ -20,7 +25,8 @@ public class PluginTest {
|
|||
@Resource
|
||||
private ExpensePluginInitializer expensePluginInitializer;
|
||||
|
||||
|
||||
@Resource
|
||||
private OerDjmlExtServiceImpl oerDjmlExtServiceImpl;
|
||||
@Test
|
||||
public void dingTest(){
|
||||
JSONObject jsonObject = JSONObject.parseObject("{\n" +
|
||||
|
@ -39,4 +45,13 @@ public class PluginTest {
|
|||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fileDownloadTest(){
|
||||
List<FileInfoDTO> fileInfoDTOList = oerDjmlExtServiceImpl.fileDownloadV1("3304665242408406647", "8000400011");
|
||||
String djmlStr = JSONObject.toJSONString(fileInfoDTOList);
|
||||
System.out.println(djmlStr);
|
||||
File file = new File(fileInfoDTOList.get(0).getZip_file_path());
|
||||
System.out.println(fileInfoDTOList.size());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,8 +77,7 @@
|
|||
FROM
|
||||
OER_ANNEX
|
||||
<trim prefix="where" prefixOverrides="and">
|
||||
<if test="kjnd != null and kjnd !='' "> KJND = #{kjnd} </if>
|
||||
<if test="gsdm != null and gsdm !='' ">and GSDM = #{gsdm} </if>
|
||||
<if test="gsdm != null and gsdm !='' "> GSDM = #{gsdm} </if>
|
||||
</trim>
|
||||
</select>
|
||||
|
||||
|
|
|
@ -9,7 +9,10 @@ public class FileInfoDTO {
|
|||
private byte[] data;//附件压缩成zip后的数据
|
||||
private String file_name;//附件名字
|
||||
private String file_size;//附件大小
|
||||
|
||||
//压缩后附件路径
|
||||
private String zip_file_path;
|
||||
//原始附件路径
|
||||
private String original_file_path;
|
||||
public byte[] getData() {
|
||||
return data;
|
||||
}
|
||||
|
@ -33,4 +36,20 @@ public class FileInfoDTO {
|
|||
public void setFile_size(String file_size) {
|
||||
this.file_size = file_size;
|
||||
}
|
||||
|
||||
public String getZip_file_path() {
|
||||
return zip_file_path;
|
||||
}
|
||||
|
||||
public void setZip_file_path(String zip_file_path) {
|
||||
this.zip_file_path = zip_file_path;
|
||||
}
|
||||
|
||||
public String getOriginal_file_path() {
|
||||
return original_file_path;
|
||||
}
|
||||
|
||||
public void setOriginal_file_path(String original_file_path) {
|
||||
this.original_file_path = original_file_path;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -528,11 +528,8 @@ GSDM,KJND,mlId
|
|||
<if test="zt != null and zt != ''"> ZT = #{zt},</if>
|
||||
<if test="curshjd != null and curshjd != ''"> curshjd = #{curshjd},</if>
|
||||
<if test="nextshjd != null and nextshjd != ''"> nextshjd = #{nextshjd},</if>
|
||||
ssrid = #{ssrid},
|
||||
ssr = #{ssr},
|
||||
ssrq = #{ssrq},
|
||||
shrid = #{ssrid},
|
||||
shrq = #{shrq}
|
||||
<if test="shrId != null and shrId != ''"> shrid = #{shrId},</if>
|
||||
<if test="shrq != null and shrq != ''"> shrq = #{shrq}</if>
|
||||
</trim>
|
||||
where MLID = #{mlId} and DJBH = #{djbh}
|
||||
</update>
|
||||
|
|
|
@ -177,10 +177,13 @@ public class RestUtil {
|
|||
}
|
||||
}
|
||||
login_name = hashMap.get("loginName");
|
||||
hashMap.put("loginName",login_name);
|
||||
if (StrUtil.isEmpty(login_name)){
|
||||
hashMap.put("loginName","hzya");
|
||||
hashMap.put("loginName","seeyon");
|
||||
}
|
||||
String result = HttpRequest.post(url).body(JSON.toJSONString(hashMap)).execute().body();
|
||||
String params = JSON.toJSONString(hashMap);
|
||||
logger.info("获取token的url:{},请求参数:{}",url,params);
|
||||
String result = HttpRequest.post(url).body(params).execute().body();
|
||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||
if (null != jsonObject) {
|
||||
logger.info("======token:{}======" ,jsonObject.getString("id"));
|
||||
|
|
|
@ -5,6 +5,7 @@ import cn.hutool.core.convert.Convert;
|
|||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
|
@ -17,6 +18,7 @@ import com.hzya.frame.grpU8.nxproof.oerdjml.entity.OerDjmlEntity;
|
|||
import com.hzya.frame.grpU8.nxproof.oerdjml.entity.RestUtil;
|
||||
import com.hzya.frame.grpU8.nxproof.oerdjml.enums.ColEventTypeEnum;
|
||||
import com.hzya.frame.grpU8.nxproof.oerdjml.service.IOerDjmlExtService;
|
||||
import com.hzya.frame.grpU8.nxproof.oerdjml.util.OerDjmlUtil;
|
||||
import com.hzya.frame.grpU8.nxproof.oerdjnr.entity.OerDjnrEntity;
|
||||
import com.hzya.frame.grpU8.nxproof.oeryszb.entity.OerYszbEntity;
|
||||
import com.hzya.frame.sysnew.application.database.entity.SysApplicationDatabaseEntity;
|
||||
|
@ -75,6 +77,7 @@ public class OerDjmlExtServiceImpl implements IOerDjmlExtService {
|
|||
Map<String, String> headers = entity.getHeaders();
|
||||
JSONObject bodyObj = JSONObject.parseObject(bodys);
|
||||
String res = oerValuOf(bodyObj, headers, grpDataSourceCode);
|
||||
logger.info("oerValuOf接收到return");
|
||||
// String formmainTableName = headers.get("formmainTableName");
|
||||
// String forsonTableName = headers.get("forsonTableName");
|
||||
// String djlx = headers.get("djlx");
|
||||
|
@ -108,7 +111,9 @@ public class OerDjmlExtServiceImpl implements IOerDjmlExtService {
|
|||
// }
|
||||
// }
|
||||
if (StrUtil.isNotEmpty(res)){
|
||||
logger.info("参数准备设置到entity.bodys里");
|
||||
entity.setBodys(res);
|
||||
logger.info("设置到entity.bodys里完成,准备return");
|
||||
return entity;
|
||||
}
|
||||
}catch (Exception ex ){
|
||||
|
@ -175,9 +180,11 @@ public class OerDjmlExtServiceImpl implements IOerDjmlExtService {
|
|||
logger.info("准备组装费用报销单参数");
|
||||
//费用报销 expense
|
||||
res = expense(headers,eventType,summaryId,dataSourceCode, formmainData, forsonData);
|
||||
logger.info("oerValuOf方法已经组装好参数,准备return");
|
||||
}else if (DjlxEnum.LABOR.type.equals(djlx)){
|
||||
//劳务费 labor
|
||||
}
|
||||
logger.info("oerValuOf方法return");
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
@ -231,7 +238,7 @@ public class OerDjmlExtServiceImpl implements IOerDjmlExtService {
|
|||
djml.setCurshjd("-9");
|
||||
djml.setNextshjd("999");
|
||||
djml.setFlowcode(flowcode);
|
||||
djml.setJsfs(spliceStr(forsonData0.getString("field0042"),forsonData0.getString("field0043")));//结算方式
|
||||
djml.setJsfs(OerDjmlUtil.spliceStr(forsonData0.getString("field0042"),forsonData0.getString("field0043")));//结算方式
|
||||
djml.setTel("");//电话
|
||||
djml.setSsrq(DateUtil.format(formmainData.getDate("field0039"),"yyyyMMddHHmmssSSS"));//送审日期
|
||||
djml.setSsrid(formmainData.getString("field0037"));//送审人id
|
||||
|
@ -336,8 +343,10 @@ public class OerDjmlExtServiceImpl implements IOerDjmlExtService {
|
|||
djml.setZt("3");
|
||||
djml.setCurshjd("999");
|
||||
djml.setNextshjd("-1");
|
||||
djml.setCrerdm(formmainData.getString("field0037"));//制单人代码
|
||||
djml.setCrermc(formmainData.getString("field0038"));//制单人名称
|
||||
//查询协同附件
|
||||
List<FileInfoDTO> fileInfoList = fileDownload(summaryId, fileApiCode);
|
||||
List<FileInfoDTO> fileInfoList = fileDownloadV1(summaryId, fileApiCode);
|
||||
djml.setFileInfoList(fileInfoList);
|
||||
}
|
||||
String djmlStr = JSONObject.toJSONString(djml);
|
||||
|
@ -399,7 +408,7 @@ public class OerDjmlExtServiceImpl implements IOerDjmlExtService {
|
|||
djml.setCurshjd("-9");
|
||||
djml.setNextshjd("999");
|
||||
djml.setFlowcode(flowcode);
|
||||
djml.setJsfs(spliceStr(forjsonData0.getString("field0086"), forjsonData0.getString("field0042")));
|
||||
djml.setJsfs(OerDjmlUtil.spliceStr(forjsonData0.getString("field0086"), forjsonData0.getString("field0042")));
|
||||
//电话
|
||||
djml.setTel(formmainData.getString("field0005"));
|
||||
djml.setClf_ccr(formmainData.getString("field0089"));
|
||||
|
@ -537,7 +546,7 @@ public class OerDjmlExtServiceImpl implements IOerDjmlExtService {
|
|||
djml.setCurshjd("999");
|
||||
djml.setNextshjd("-1");
|
||||
//查询协同附件
|
||||
List<FileInfoDTO> fileInfoList = fileDownload(summaryId, fileApiCode);
|
||||
List<FileInfoDTO> fileInfoList = fileDownloadV1(summaryId, fileApiCode);
|
||||
djml.setFileInfoList(fileInfoList);
|
||||
}
|
||||
String djmlStr = JSONObject.toJSONString(djml);
|
||||
|
@ -569,46 +578,49 @@ public class OerDjmlExtServiceImpl implements IOerDjmlExtService {
|
|||
}
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* 附件下载并压缩成zip
|
||||
* @param summaryId
|
||||
* @param apiCode
|
||||
* @return
|
||||
*/
|
||||
private List<FileInfoDTO> fileDownload(String summaryId,String apiCode){
|
||||
//这个方法暂时没用
|
||||
public List<FileInfoDTO> fileDownloadDiscard(String summaryId, String apiCode) {
|
||||
try {
|
||||
List<GrpU8CollAttachmentResDTO> colAttachmentList = restUtil.getColAttachments(summaryId, "0", apiCode, null);
|
||||
//下载协同附件
|
||||
if (CollectionUtils.isNotEmpty(colAttachmentList)){
|
||||
// 下载协同附件
|
||||
if (CollectionUtils.isNotEmpty(colAttachmentList)) {
|
||||
String token = restUtil.getToken(null, apiCode);
|
||||
List<FileInfoDTO> fileList = new ArrayList<>();
|
||||
String today = DateUtil.today();
|
||||
String zipPath = DSK + File.separator + today + File.separator + "attachments.zip";
|
||||
|
||||
// 确保目录存在
|
||||
if (!FileUtil.isDirectory(DSK + File.separator + today)) {
|
||||
FileUtil.mkdir(DSK + File.separator + today);
|
||||
}
|
||||
|
||||
// 创建 ZipOutputStream
|
||||
try (ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipPath), Charset.forName("GBK"))) {
|
||||
for (GrpU8CollAttachmentResDTO att : colAttachmentList) {
|
||||
FileInfoDTO fileInfoDTO = new FileInfoDTO();
|
||||
|
||||
String fileName = URLDecoder.decode(att.getFilename(), "UTF-8");
|
||||
byte[] bytes = restUtil.downloadFileBytes(null, apiCode, att.getFileUrl(), fileName,token);
|
||||
if (!FileUtil.isDirectory(DSK+ File.separator+DateUtil.today())){
|
||||
FileUtil.mkdir(DSK+ File.separator+DateUtil.today());
|
||||
}
|
||||
String filePath = DSK+ File.separator+DateUtil.today()+File.separator+att.getFileUrl()+"."+att.getExtension();
|
||||
String fileUrl = att.getFileUrl();
|
||||
byte[] bytes = restUtil.downloadFileBytes(null, apiCode, att.getFileUrl(), fileName, token);
|
||||
String filePath = DSK + File.separator + today + File.separator + att.getFileUrl() + "." + att.getExtension();
|
||||
File file = new File(filePath);
|
||||
|
||||
// 使用 FileOutputStream 写入字节数组到文件
|
||||
try (FileOutputStream fos = new FileOutputStream(file)) {
|
||||
fos.write(bytes);
|
||||
}
|
||||
if (null != file){
|
||||
String zipPath = DSK+File.separator+DateUtil.today()+File.separator+att.getFileUrl()+".zip";
|
||||
ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipPath), Charset.forName("GBK"));
|
||||
writeZipFile(file, zos, fileName);
|
||||
zos.close();
|
||||
// 获取压缩文件的字节数组
|
||||
|
||||
if (null != file) {
|
||||
// 将文件添加到压缩包
|
||||
writeZipFile(file, zos, fileName, fileUrl);
|
||||
|
||||
// 读取压缩文件的字节数组
|
||||
File zipFile = new File(zipPath);
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream((int) zipFile.length());
|
||||
BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(zipFile));
|
||||
try (BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(zipFile))) {
|
||||
int buf_size = 1024;
|
||||
byte[] buffer = new byte[buf_size];
|
||||
int len = 0;
|
||||
int len;
|
||||
while (-1 != (len = bufferedInputStream.read(buffer, 0, buf_size))) {
|
||||
byteArrayOutputStream.write(buffer, 0, len);
|
||||
}
|
||||
|
@ -617,12 +629,71 @@ public class OerDjmlExtServiceImpl implements IOerDjmlExtService {
|
|||
fileInfoDTO.setFile_size(att.getSize());
|
||||
fileInfoDTO.setFile_name(fileName);
|
||||
fileList.add(fileInfoDTO);
|
||||
logger.info("压缩后的文件读取字节数组完成");
|
||||
} catch (Exception e) {
|
||||
logger.error("压缩附件&读取字节数组出错:{}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
logger.info("压缩文件1111111");
|
||||
return fileList;
|
||||
} catch (Exception ex) {
|
||||
logger.error("压缩附件添加到fileList出错:{}", ex);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("下载附件出错:{}", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//从OA下载附件
|
||||
public List<FileInfoDTO> fileDownloadV1(String summaryId, String apiCode) {
|
||||
Assert.notEmpty(summaryId,"summaryId不能为空");
|
||||
Assert.notEmpty(apiCode,"apiCode不能为空");
|
||||
try {
|
||||
//1、查询协同附件
|
||||
List<GrpU8CollAttachmentResDTO> colAttachmentList = restUtil.getColAttachments(summaryId, "0", apiCode, null);
|
||||
//2、下载协同附件
|
||||
if (CollectionUtils.isNotEmpty(colAttachmentList)){
|
||||
//获取OA token
|
||||
String token = restUtil.getToken(null, apiCode);
|
||||
List<FileInfoDTO> fileList = new ArrayList<>();
|
||||
String today = DateUtil.today();
|
||||
String basePath = DSK + File.separator + today + File.separator;
|
||||
// 确保目录存在
|
||||
if (!FileUtil.isDirectory(basePath)) {
|
||||
FileUtil.mkdir(basePath);
|
||||
}
|
||||
for (GrpU8CollAttachmentResDTO att : colAttachmentList) {
|
||||
String fileName = URLDecoder.decode(att.getFilename(), "UTF-8");
|
||||
String fileUrl = att.getFileUrl();
|
||||
byte[] bytes = restUtil.downloadFileBytes(null, apiCode, att.getFileUrl(), fileName, token);
|
||||
String filePath = basePath + att.getFileUrl() + "." + att.getExtension();
|
||||
File file = new File(filePath);
|
||||
// 使用 FileOutputStream 写入字节数组到文件
|
||||
try (FileOutputStream fos = new FileOutputStream(file)) {
|
||||
fos.write(bytes);
|
||||
}
|
||||
//3、把协同附件压缩成.zip
|
||||
if (null != file){
|
||||
String zipPath = basePath + att.getFileUrl() + ".zip";
|
||||
ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipPath), Charset.forName("GBK"));
|
||||
writeZipFile(file, zos, fileName,fileUrl);
|
||||
zos.close();
|
||||
//4、返回.zip附件路径
|
||||
FileInfoDTO fileInfo = new FileInfoDTO();
|
||||
fileInfo.setZip_file_path(zipPath);
|
||||
fileInfo.setOriginal_file_path(filePath);
|
||||
fileInfo.setFile_name(fileName);
|
||||
fileInfo.setFile_size(att.getSize());
|
||||
fileList.add(fileInfo);
|
||||
}
|
||||
}
|
||||
return fileList;
|
||||
}
|
||||
}catch (Exception e){
|
||||
logger.error("下载附件出错:{}",e);
|
||||
}catch(Exception e){
|
||||
logger.error("下载OA附件出错:{}",e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -631,39 +702,29 @@ public class OerDjmlExtServiceImpl implements IOerDjmlExtService {
|
|||
* @param file 要压缩的文件
|
||||
* @param zos 文件压缩流
|
||||
* @param fileName 文件名
|
||||
* @param fileUrl 文件id
|
||||
*/
|
||||
private void writeZipFile(File file, ZipOutputStream zos, String fileName) {
|
||||
private void writeZipFile(File file, ZipOutputStream zos, String fileName, String fileUrl) {
|
||||
if (null != file && null != zos) {
|
||||
try {
|
||||
try (FileInputStream fos = new FileInputStream(file);
|
||||
BufferedInputStream bis = new BufferedInputStream(fos)) {
|
||||
logger.info("=====压缩文件=====");
|
||||
zos.putNextEntry(new ZipEntry(fileName));
|
||||
FileInputStream fos = new FileInputStream(file);
|
||||
BufferedInputStream bis = new BufferedInputStream(fos);
|
||||
zos.putNextEntry(new ZipEntry(fileName ));
|
||||
int len;
|
||||
byte[] buf = new byte[1024];
|
||||
while ((len = bis.read(buf, 0, 1024)) != -1) {
|
||||
zos.write(buf, 0, len);
|
||||
}
|
||||
bis.close();
|
||||
fos.close();
|
||||
logger.info("=====压缩完成=====");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("=====压缩文件出错=====");
|
||||
logger.error("=====压缩文件出错=====:{}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* code和name拼接[]
|
||||
* @param code
|
||||
* @param name
|
||||
* @return 格式:03[公务卡]
|
||||
*/
|
||||
private String spliceStr(String code,String name){
|
||||
String template = "{}[{}]";
|
||||
return StrUtil.format(template,code,name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public enum DjlxEnum {
|
||||
TRAVEL("travel","差旅报销单"),
|
||||
|
|
|
@ -23,6 +23,7 @@ import com.hzya.frame.grpU8.nxproof.oerdjml.entity.GbiZbsyrecAllEntity;
|
|||
import com.hzya.frame.grpU8.nxproof.oerdjml.entity.OerDjmlEntity;
|
||||
import com.hzya.frame.grpU8.nxproof.oerdjml.enums.ColEventTypeEnum;
|
||||
import com.hzya.frame.grpU8.nxproof.oerdjml.service.IOerDjmlService;
|
||||
import com.hzya.frame.grpU8.nxproof.oerdjml.util.OerDjmlUtil;
|
||||
import com.hzya.frame.grpU8.nxproof.oerdjnr.dao.IOerDjnrDao;
|
||||
import com.hzya.frame.grpU8.nxproof.oerdjnr.entity.OerDjnrEntity;
|
||||
import com.hzya.frame.grpU8.nxproof.oeryszb.dao.IOerYszbDao;
|
||||
|
@ -41,6 +42,10 @@ import org.apache.logging.log4j.Logger;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
@ -837,14 +842,16 @@ public class OerDjmlServiceImpl implements IOerDjmlService {
|
|||
delete.setGsdm(oerDjmlAllEntities.get(0).getGsdm());
|
||||
delete.setDataSourceCode(entity.getDataSourceCode());
|
||||
oerAnnexDao.deleteAnnex(delete);
|
||||
int no = 1;
|
||||
int no = 0;
|
||||
for (FileInfoDTO fileInfo : entity.getFileInfoList()) {
|
||||
try {
|
||||
AttachmentFileEntity fileEntity = new AttachmentFileEntity();
|
||||
fileEntity.setDataSourceCode(entity.getDataSourceCode());
|
||||
String fileName = URLDecoder.decode(fileInfo.getFile_name(), "UTF-8");
|
||||
fileEntity.setaTFileName(fileName);
|
||||
fileEntity.setaTFile(fileInfo.getData());
|
||||
fileEntity.setaTFile(file2bytes(fileInfo.getZip_file_path()));
|
||||
fileEntity.setCreateID(OerDjmlUtil.spliceStr(entity.getCrerdm(),entity.getCrermc()));
|
||||
fileEntity.setUpdateID(OerDjmlUtil.spliceStr(entity.getCrerdm(),entity.getCrermc()));
|
||||
saveAttachment(fileEntity);
|
||||
//保存附件关系
|
||||
OerAnnexEntity annexEntity = new OerAnnexEntity();
|
||||
|
@ -870,7 +877,7 @@ public class OerDjmlServiceImpl implements IOerDjmlService {
|
|||
annexEntity.setShowSize(showSize);
|
||||
}
|
||||
|
||||
annexEntity.setFjType("其它");
|
||||
//annexEntity.setFjType("其它");
|
||||
oerAnnexDao.saveData(annexEntity);
|
||||
no++;
|
||||
}catch (Exception e){
|
||||
|
@ -887,6 +894,28 @@ public class OerDjmlServiceImpl implements IOerDjmlService {
|
|||
return BaseResult.getSuccessMessageEntity("处理成功");
|
||||
}
|
||||
|
||||
//附件转成字节数组
|
||||
private byte[] file2bytes(String filePath){
|
||||
if (null != filePath){
|
||||
File zipFile = new File(filePath);
|
||||
if (null != zipFile){
|
||||
try(ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream((int) zipFile.length());
|
||||
BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(zipFile))) {
|
||||
int buf_size = 1024;
|
||||
byte[] buffer = new byte[buf_size];
|
||||
int len;
|
||||
while (-1 != (len = bufferedInputStream.read(buffer, 0, buf_size))) {
|
||||
byteArrayOutputStream.write(buffer, 0, len);
|
||||
}
|
||||
byte[] fileByte = byteArrayOutputStream.toByteArray();
|
||||
return fileByte;
|
||||
}catch (Exception ex){
|
||||
logger.error("附件转成字节数组出错:{}",ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public String queryMaxId(OerAnnexEntity entity) {
|
||||
if (null == entity){
|
||||
entity = new OerAnnexEntity();
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package com.hzya.frame.grpU8.nxproof.oerdjml.util;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
/**
|
||||
* @Description 报销单工具类
|
||||
* @Author xiangerlin
|
||||
* @Date 2025/4/8 18:01
|
||||
**/
|
||||
public class OerDjmlUtil {
|
||||
|
||||
/**
|
||||
* code和name拼接[]
|
||||
* @param code
|
||||
* @param name
|
||||
* @return 格式:03[公务卡]
|
||||
*/
|
||||
public static String spliceStr(String code,String name){
|
||||
String template = "{}[{}]";
|
||||
return StrUtil.format(template,code,name);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue