parent
86d4bf5d53
commit
47cd2a538d
|
@ -0,0 +1,9 @@
|
||||||
|
package com.hzya.frame.grpU8.nxproof.attachment;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description
|
||||||
|
* @Author xiangerlin
|
||||||
|
* @Date 2024/8/16 11:07
|
||||||
|
**/
|
||||||
|
public class Test {
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.hzya.frame.grpU8.nxproof.attachment.dao;/*
|
||||||
|
* @Description 附件
|
||||||
|
* @Author xiangerlin
|
||||||
|
@Date 2022-10-26 11:17
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import com.hzya.frame.basedao.dao.IBaseDao;
|
||||||
|
import com.hzya.frame.grpU8.nxproof.attachment.entity.AttachmentFileEntity;
|
||||||
|
|
||||||
|
public interface IAttachmentFileDao extends IBaseDao<AttachmentFileEntity, String> {
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.hzya.frame.grpU8.nxproof.attachment.dao.impl;/*
|
||||||
|
* @Description 附件
|
||||||
|
* @Author xiangerlin
|
||||||
|
@Date 2022-10-26 11:18
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import com.hzya.frame.basedao.dao.MybatisGenericDao;
|
||||||
|
import com.hzya.frame.grpU8.nxproof.attachment.dao.IAttachmentFileDao;
|
||||||
|
import com.hzya.frame.grpU8.nxproof.attachment.entity.AttachmentFileEntity;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public class AttachmentFileDaoImpl extends MybatisGenericDao<AttachmentFileEntity, String> implements IAttachmentFileDao {
|
||||||
|
}
|
|
@ -0,0 +1,120 @@
|
||||||
|
package com.hzya.frame.grpU8.nxproof.attachment.entity;/*
|
||||||
|
* @Description 附件表
|
||||||
|
* @Author xiangerlin
|
||||||
|
@Date 2022-10-26 10:40
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import com.hzya.frame.web.entity.BaseEntity;
|
||||||
|
|
||||||
|
public class AttachmentFileEntity extends BaseEntity {
|
||||||
|
|
||||||
|
private String aTGuid;//主键id
|
||||||
|
private String createDate;//创建日期
|
||||||
|
private String createID;//创建人id
|
||||||
|
private String updateDate;//更新日期
|
||||||
|
private String updateID;//更新人id
|
||||||
|
private String deleteDate;//删除日期
|
||||||
|
private String deleteID;//删除人
|
||||||
|
private String aTFileName;//附件名
|
||||||
|
private String aTExtName;//附件后缀名
|
||||||
|
private byte[] aTFile;//附件 二进制文件
|
||||||
|
private String relationApp;//固定传 OER
|
||||||
|
private String isDELETE;//删除标记 0是未删除
|
||||||
|
|
||||||
|
public String getaTGuid() {
|
||||||
|
return aTGuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setaTGuid(String aTGuid) {
|
||||||
|
this.aTGuid = aTGuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCreateDate() {
|
||||||
|
return createDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreateDate(String createDate) {
|
||||||
|
this.createDate = createDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCreateID() {
|
||||||
|
return createID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreateID(String createID) {
|
||||||
|
this.createID = createID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUpdateDate() {
|
||||||
|
return updateDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUpdateDate(String updateDate) {
|
||||||
|
this.updateDate = updateDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUpdateID() {
|
||||||
|
return updateID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUpdateID(String updateID) {
|
||||||
|
this.updateID = updateID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDeleteDate() {
|
||||||
|
return deleteDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeleteDate(String deleteDate) {
|
||||||
|
this.deleteDate = deleteDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDeleteID() {
|
||||||
|
return deleteID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeleteID(String deleteID) {
|
||||||
|
this.deleteID = deleteID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getaTFileName() {
|
||||||
|
return aTFileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setaTFileName(String aTFileName) {
|
||||||
|
this.aTFileName = aTFileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getaTExtName() {
|
||||||
|
return aTExtName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setaTExtName(String aTExtName) {
|
||||||
|
this.aTExtName = aTExtName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] getaTFile() {
|
||||||
|
return aTFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setaTFile(byte[] aTFile) {
|
||||||
|
this.aTFile = aTFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRelationApp() {
|
||||||
|
return relationApp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRelationApp(String relationApp) {
|
||||||
|
this.relationApp = relationApp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIsDELETE() {
|
||||||
|
return isDELETE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsDELETE(String isDELETE) {
|
||||||
|
this.isDELETE = isDELETE;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,86 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.hzya.frame.grpU8.nxproof.attachment.entity.AttachmentFileEntity">
|
||||||
|
<resultMap id="get-AttachmentFileEntity-result" type="com.hzya.frame.grpU8.nxproof.attachment.entity.AttachmentFileEntity">
|
||||||
|
|
||||||
|
<result property="aTGuid" column="aTGuid" />
|
||||||
|
<result property="createDate" column="createDate" />
|
||||||
|
<result property="createID" column="createID" />
|
||||||
|
<result property="updateDate" column="updateDate" />
|
||||||
|
<result property="updateID" column="updateID" />
|
||||||
|
<result property="deleteDate" column="deleteDate" />
|
||||||
|
<result property="deleteID" column="deleteID" />
|
||||||
|
<result property="aTFileName" column="aTFileName" />
|
||||||
|
<result property="aTExtName" column="aTExtName" />
|
||||||
|
<result column="aTFile" property="aTFile" jdbcType="BLOB" typeHandler="org.apache.ibatis.type.BlobTypeHandler" />
|
||||||
|
<result property="relationApp" column="relationApp" />
|
||||||
|
<result property="isDELETE" column="isDELETE" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
|
||||||
|
<sql id="AttachmentFileEntity_Base_Column_List">
|
||||||
|
ATGuid,
|
||||||
|
CreateDate,
|
||||||
|
CreateID,
|
||||||
|
UpdateDate,
|
||||||
|
UpdateID,
|
||||||
|
DeleteDate,
|
||||||
|
DeleteID,
|
||||||
|
ATFileName,
|
||||||
|
ATExtName,
|
||||||
|
ATFile,
|
||||||
|
RelationApp,
|
||||||
|
ISDELETE
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 查询 采用==查询 -->
|
||||||
|
<select id="AttachmentFileEntity_list_base" resultMap="get-AttachmentFileEntity-result" parameterType="com.hzya.frame.grpU8.nxproof.attachment.entity.AttachmentFileEntity">
|
||||||
|
select
|
||||||
|
<include refid="AttachmentFileEntity_Base_Column_List" />
|
||||||
|
FROM
|
||||||
|
AT_AttachmentFile
|
||||||
|
<trim prefix="where" prefixOverrides="and">
|
||||||
|
<if test="aTGuid != null and aTGuid !='' "> aTGuid = #{aTGuid} </if>
|
||||||
|
<if test="aTFileName != null and aTFileName !='' ">and aTFileName = #{aTFileName} </if>
|
||||||
|
</trim>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<insert id="AttachmentFileEntity_insert" parameterType="com.hzya.frame.grpU8.nxproof.attachment.entity.AttachmentFileEntity">
|
||||||
|
insert into AT_AttachmentFile(
|
||||||
|
<trim suffix="" suffixOverrides=",">
|
||||||
|
<if test="aTGuid != null and aTGuid !='' ">aTGuid,</if>
|
||||||
|
<if test="createDate != null and createDate !='' "> createDate, </if>
|
||||||
|
<if test="createID != null and createID !='' "> createID, </if>
|
||||||
|
<if test="updateDate != null and updateDate !='' "> updateDate ,</if>
|
||||||
|
<if test="updateID != null and updateID !='' ">updateID,</if>
|
||||||
|
<if test="deleteDate != null and deleteDate !='' ">deleteDate,</if>
|
||||||
|
<if test="deleteID != null and deleteID !='' ">deleteID,</if>
|
||||||
|
<if test="aTFileName != null and aTFileName !='' ">aTFileName,</if>
|
||||||
|
<if test="aTExtName != null and aTExtName !='' ">aTExtName,</if>
|
||||||
|
<if test="aTFile != null and aTFile !='' ">aTFile,</if>
|
||||||
|
relationApp,
|
||||||
|
isDELETE
|
||||||
|
</trim>
|
||||||
|
)values
|
||||||
|
(
|
||||||
|
<trim suffix="" suffixOverrides=",">
|
||||||
|
<if test="aTGuid != null and aTGuid !='' ">#{aTGuid},</if>
|
||||||
|
<if test="createDate != null and createDate !='' "> #{createDate}, </if>
|
||||||
|
<if test="createID != null and createID !='' "> #{createID}, </if>
|
||||||
|
<if test="updateDate != null and updateDate !='' "> #{updateDate} ,</if>
|
||||||
|
<if test="updateID != null and updateID !='' ">#{updateID},</if>
|
||||||
|
<if test="deleteDate != null and deleteDate !='' ">#{deleteDate},</if>
|
||||||
|
<if test="deleteID != null and deleteID !='' ">#{deleteID},</if>
|
||||||
|
<if test="aTFileName != null and aTFileName !='' ">#{aTFileName},</if>
|
||||||
|
<if test="aTExtName != null and aTExtName !='' ">#{aTExtName},</if>
|
||||||
|
<if test="aTFile != null and aTFile !='' ">#{aTFile,typeHandler=org.apache.ibatis.type.BlobTypeHandler},</if>
|
||||||
|
'OER',
|
||||||
|
0
|
||||||
|
|
||||||
|
</trim>
|
||||||
|
)
|
||||||
|
</insert>
|
||||||
|
</mapper>
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.hzya.frame.grpU8.nxproof.attachment.service;/*
|
||||||
|
* @Description
|
||||||
|
* @Author xiangerlin
|
||||||
|
@Date 2022-10-26 11:19
|
||||||
|
*/
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.hzya.frame.grpU8.nxproof.attachment.entity.AttachmentFileEntity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface IAttachmentFileService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存附件
|
||||||
|
* @param entity
|
||||||
|
*/
|
||||||
|
void saveAttachment(AttachmentFileEntity entity);
|
||||||
|
|
||||||
|
List<AttachmentFileEntity> queryFile(AttachmentFileEntity entity)throws Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调用http接口查询单据附件
|
||||||
|
* @param billCode
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
List<JSONObject> queryFileByCode(String billCode)throws Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 附件上传
|
||||||
|
* @param fileList
|
||||||
|
* @param mlid
|
||||||
|
* @param kjnd
|
||||||
|
*/
|
||||||
|
void uploadAttachment(List<JSONObject> fileList,String mlid,String kjnd);
|
||||||
|
}
|
|
@ -0,0 +1,231 @@
|
||||||
|
package com.hzya.frame.grpU8.nxproof.attachment.service.impl;/*
|
||||||
|
* @Description
|
||||||
|
* @Author xiangerlin
|
||||||
|
@Date 2022-10-26 11:20
|
||||||
|
*/
|
||||||
|
|
||||||
|
import cn.hutool.core.convert.Convert;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.http.HttpRequest;
|
||||||
|
import cn.hutool.http.HttpUtil;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.hzya.frame.basedao.service.impl.BaseService;
|
||||||
|
import com.hzya.frame.grpU8.nxproof.attachment.dao.IAttachmentFileDao;
|
||||||
|
import com.hzya.frame.grpU8.nxproof.attachment.entity.AttachmentFileEntity;
|
||||||
|
import com.hzya.frame.grpU8.nxproof.attachment.service.IAttachmentFileService;
|
||||||
|
import com.hzya.frame.grpU8.nxproof.oerannex.service.IOerAnnexService;
|
||||||
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.net.URLDecoder;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.zip.ZipEntry;
|
||||||
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class AttachmentFileServiceImpl extends BaseService<AttachmentFileEntity,String> implements IAttachmentFileService {
|
||||||
|
|
||||||
|
Logger logger = LogManager.getLogger(getClass());
|
||||||
|
|
||||||
|
protected IAttachmentFileDao attachmentFileDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public void setBillLogDao(IAttachmentFileDao dao) {
|
||||||
|
this.attachmentFileDao = dao;
|
||||||
|
this.dao=dao;
|
||||||
|
}
|
||||||
|
@Autowired
|
||||||
|
private IOerAnnexService oerAnnexService;
|
||||||
|
@Autowired
|
||||||
|
private IAttachmentFileService attachmentFileService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存附件
|
||||||
|
* @param entity
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void saveAttachment(AttachmentFileEntity entity) {
|
||||||
|
entity.setaTGuid("A1:"+IdUtil.fastUUID());
|
||||||
|
String date = DateUtil.format(new Date(), "yyyyMMdd HH:mm:ss");
|
||||||
|
entity.setCreateDate(date);
|
||||||
|
entity.setUpdateDate(date);
|
||||||
|
String fileName = entity.getaTFileName();
|
||||||
|
if (StrUtil.isNotEmpty(fileName)){
|
||||||
|
int index = fileName.lastIndexOf(".");
|
||||||
|
if (index > 0){
|
||||||
|
String suffix = fileName.substring(index);
|
||||||
|
entity.setaTExtName(suffix);
|
||||||
|
String prefix = fileName.substring(0,index);
|
||||||
|
entity.setaTFileName(prefix);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
attachmentFileDao.save("AttachmentFileEntity_insert",entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AttachmentFileEntity> queryFile(AttachmentFileEntity entity) throws Exception {
|
||||||
|
entity.setAcc_name(Constant.CONFIGMAP.get("file_acc_name"));
|
||||||
|
List<AttachmentFileEntity> list = attachmentFileDao.query(entity);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调用http接口查询单据附件
|
||||||
|
*
|
||||||
|
* @param billCode 单据号
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<JSONObject> queryFileByCode(String billCode) throws Exception {
|
||||||
|
List<JSONObject> list = new ArrayList<>();
|
||||||
|
if (StrUtil.isNotEmpty(billCode)){
|
||||||
|
JSONObject params = new JSONObject();
|
||||||
|
params.put("billNo",billCode);
|
||||||
|
String res = HttpRequest.post(Constant.CONFIGMAP.get("grp_file_download_url")+"/grp/af/findFilesBB").body(params.toString()).execute().body();
|
||||||
|
logger.info("根据单号:{},查询到到附件列表为:{}",billCode,res);
|
||||||
|
if (StrUtil.isNotEmpty(res)){
|
||||||
|
JSONObject resJson = JSONObject.parseObject(res);
|
||||||
|
int pageCount = resJson.getIntValue("pageCount");
|
||||||
|
boolean success = resJson.getBoolean("success");
|
||||||
|
if (success){
|
||||||
|
String dataStr = resJson.getString("data");
|
||||||
|
list = JSONObject.parseArray(dataStr,JSONObject.class);
|
||||||
|
if (null != list && list.size() >0){
|
||||||
|
for (JSONObject jsonObject : list) {
|
||||||
|
String fileName = jsonObject.getString("fileName");
|
||||||
|
if (StrUtil.isNotEmpty(fileName)){
|
||||||
|
// 使用indexOf找到"."的位置
|
||||||
|
int dotIndex = fileName.lastIndexOf('.');
|
||||||
|
// 确保找到了".",防止indexOf返回-1的情况
|
||||||
|
if (dotIndex != -1){
|
||||||
|
String ext_name = fileName.substring(dotIndex);
|
||||||
|
jsonObject.put("Ext",ext_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 附件上传
|
||||||
|
*
|
||||||
|
* @param fileList
|
||||||
|
* @param mlid
|
||||||
|
* @param kjnd
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void uploadAttachment(List<JSONObject> fileList, String mlid, String kjnd) {
|
||||||
|
if (CollectionUtils.isNotEmpty(fileList) && StrUtil.isNotEmpty(mlid) && StrUtil.isNotEmpty(kjnd)){
|
||||||
|
try {
|
||||||
|
//附件下载
|
||||||
|
List<FileInfoDTO> fileInfoList = fileDownload(fileList);
|
||||||
|
//附件保存到grp库里
|
||||||
|
if (CollectionUtils.isNotEmpty(fileInfoList)){
|
||||||
|
//保存前先删一下历史附件
|
||||||
|
OerAnnexEntity delete = new OerAnnexEntity();
|
||||||
|
delete.setGsdm(Constant.CONFIGMAP.get("gsdm"));
|
||||||
|
delete.setKjnd(kjnd);
|
||||||
|
delete.setMlid(mlid);
|
||||||
|
//oerAnnexService.deleteAnnex(delete);
|
||||||
|
int no = 1;
|
||||||
|
for (FileInfoDTO fileInfo : fileInfoList) {
|
||||||
|
try {
|
||||||
|
AttachmentFileEntity fileEntity = new AttachmentFileEntity();
|
||||||
|
String fileName = URLDecoder.decode(fileInfo.getFile_name(), "UTF-8");
|
||||||
|
fileEntity.setaTFileName(fileName);
|
||||||
|
fileEntity.setaTFile(fileInfo.getData());
|
||||||
|
attachmentFileService.saveAttachment(fileEntity);
|
||||||
|
//保存附件关系
|
||||||
|
OerAnnexEntity annexEntity = new OerAnnexEntity();
|
||||||
|
annexEntity.setMlid(mlid);
|
||||||
|
annexEntity.setKjnd(kjnd);
|
||||||
|
annexEntity.setAnnexName(fileName);
|
||||||
|
annexEntity.setAnnexSize(Convert.toLong(fileInfo.getFile_size()));
|
||||||
|
annexEntity.setOnlyid(fileEntity.getaTGuid());
|
||||||
|
annexEntity.setXh(String.valueOf(no));
|
||||||
|
oerAnnexService.saveAnnex(annexEntity);
|
||||||
|
no++;
|
||||||
|
}catch (Exception e){
|
||||||
|
logger.error("保存附件到grp出错:{}",e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
logger.error("保存附件到grp出错:{}",e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<FileInfoDTO> fileDownload(List<JSONObject> fileList){
|
||||||
|
String dir = Constant.CONFIGMAP.get("file_dest_temp");
|
||||||
|
List<FileInfoDTO> files = new ArrayList<>();
|
||||||
|
//1、下载附件
|
||||||
|
for (JSONObject fileObj : fileList) {
|
||||||
|
try {
|
||||||
|
FileInfoDTO fileInfoDTO = new FileInfoDTO();
|
||||||
|
String url = fileObj.getString("url");
|
||||||
|
String fileName = URLDecoder.decode(fileObj.getString("fileName"));
|
||||||
|
File file = HttpUtil.downloadFileFromUrl(url, dir);
|
||||||
|
if (null != file){
|
||||||
|
String zipPath = dir + File.separator + fileName.split("\\.")[0] + ".zip";
|
||||||
|
ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipPath), Charset.forName("GBK"));
|
||||||
|
writeZipFile(file, zos,fileName);
|
||||||
|
zos.close();
|
||||||
|
// 获取压缩文件的字节数组
|
||||||
|
File zipFile = new File(zipPath);
|
||||||
|
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 = 0;
|
||||||
|
while (-1 != (len = bufferedInputStream.read(buffer, 0, buf_size))) {
|
||||||
|
byteArrayOutputStream.write(buffer, 0, len);
|
||||||
|
}
|
||||||
|
byte[] fileByte = byteArrayOutputStream.toByteArray();
|
||||||
|
fileInfoDTO.setData(fileByte);
|
||||||
|
fileInfoDTO.setFile_size(fileObj.getString("size"));
|
||||||
|
fileInfoDTO.setFile_name(fileName);
|
||||||
|
files.add(fileInfoDTO);
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
logger.error("上传附件出错:{}",e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return files;
|
||||||
|
}
|
||||||
|
private void writeZipFile(File file,ZipOutputStream zos,String fileName){
|
||||||
|
if (null != file && null !=zos){
|
||||||
|
try {
|
||||||
|
logger.info("=====压缩文件=====");
|
||||||
|
zos.putNextEntry(new ZipEntry(fileName));
|
||||||
|
FileInputStream fos = new FileInputStream(file);
|
||||||
|
BufferedInputStream bis = new BufferedInputStream(fos);
|
||||||
|
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("=====压缩文件出错=====");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package com.hzya.frame.grpU8.nxproof.oerannex;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description
|
||||||
|
* @Author xiangerlin
|
||||||
|
* @Date 2024/8/16 10:40
|
||||||
|
**/
|
||||||
|
public class Test {
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.hzya.frame.grpU8.nxproof.oerannex.dao;/*
|
||||||
|
* @Description 附件关系表
|
||||||
|
* @Author xiangerlin
|
||||||
|
@Date 2022-10-26 10:04
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import com.hzya.frame.basedao.dao.IBaseDao;
|
||||||
|
import com.hzya.frame.grpU8.nxproof.oerannex.entity.OerAnnexEntity;
|
||||||
|
|
||||||
|
public interface IOerAnnexDao extends IBaseDao<OerAnnexEntity, String> {
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.hzya.frame.grpU8.nxproof.oerannex.dao.impl;/*
|
||||||
|
* @Description 附件关系表
|
||||||
|
* @Author xiangerlin
|
||||||
|
@Date 2022-10-26 10:05
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import com.hzya.frame.basedao.dao.MybatisGenericDao;
|
||||||
|
import com.hzya.frame.grpU8.nxproof.oerannex.dao.IOerAnnexDao;
|
||||||
|
import com.hzya.frame.grpU8.nxproof.oerannex.entity.OerAnnexEntity;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public class OerAnnexDaoImpl extends MybatisGenericDao<OerAnnexEntity, String> implements IOerAnnexDao {
|
||||||
|
}
|
|
@ -0,0 +1,149 @@
|
||||||
|
package com.hzya.frame.grpU8.nxproof.oerannex.entity;
|
||||||
|
|
||||||
|
import com.hzya.frame.web.entity.BaseEntity;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @Description 附件关系表
|
||||||
|
* @Author xiangerlin
|
||||||
|
@Date 2022-10-26 8:44
|
||||||
|
*/
|
||||||
|
public class OerAnnexEntity extends BaseEntity {
|
||||||
|
|
||||||
|
private String annexid; //主键id
|
||||||
|
private String mlid;//报销单id
|
||||||
|
private String gsdm;//公司代码 默认001
|
||||||
|
private String kjnd;//会计年度
|
||||||
|
private String bnxid;// 不知道是什么 填0
|
||||||
|
private String xh;//序号
|
||||||
|
private String onlyid;// AT_AttachmentFile 表的主键ATGuid
|
||||||
|
private String annexName;//附件名
|
||||||
|
private Long annexSize;//附件大小
|
||||||
|
private String showSize;//附件大小显示值
|
||||||
|
private String ole;// 不知道是什么,填空
|
||||||
|
private String fjType;//附件类型, 数据库中只有 其他、其他其他(&Z)、合同3种类型
|
||||||
|
private String fpid;//不知道是什么 填空
|
||||||
|
|
||||||
|
private String maxAnnexid;//最大id
|
||||||
|
|
||||||
|
private String aTextName;//后缀名
|
||||||
|
|
||||||
|
public String getAnnexid() {
|
||||||
|
return annexid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAnnexid(String annexid) {
|
||||||
|
this.annexid = annexid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMlid() {
|
||||||
|
return mlid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMlid(String mlid) {
|
||||||
|
this.mlid = mlid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGsdm() {
|
||||||
|
return gsdm;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGsdm(String gsdm) {
|
||||||
|
this.gsdm = gsdm;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getKjnd() {
|
||||||
|
return kjnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKjnd(String kjnd) {
|
||||||
|
this.kjnd = kjnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBnxid() {
|
||||||
|
return bnxid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBnxid(String bnxid) {
|
||||||
|
this.bnxid = bnxid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getXh() {
|
||||||
|
return xh;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setXh(String xh) {
|
||||||
|
this.xh = xh;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOnlyid() {
|
||||||
|
return onlyid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOnlyid(String onlyid) {
|
||||||
|
this.onlyid = onlyid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAnnexName() {
|
||||||
|
return annexName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAnnexName(String annexName) {
|
||||||
|
this.annexName = annexName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getAnnexSize() {
|
||||||
|
return annexSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAnnexSize(Long annexSize) {
|
||||||
|
this.annexSize = annexSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getShowSize() {
|
||||||
|
return showSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShowSize(String showSize) {
|
||||||
|
this.showSize = showSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOle() {
|
||||||
|
return ole;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOle(String ole) {
|
||||||
|
this.ole = ole;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFjType() {
|
||||||
|
return fjType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFjType(String fjType) {
|
||||||
|
this.fjType = fjType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFpid() {
|
||||||
|
return fpid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFpid(String fpid) {
|
||||||
|
this.fpid = fpid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMaxAnnexid() {
|
||||||
|
return maxAnnexid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxAnnexid(String maxAnnexid) {
|
||||||
|
this.maxAnnexid = maxAnnexid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getaTextName() {
|
||||||
|
return aTextName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setaTextName(String aTextName) {
|
||||||
|
this.aTextName = aTextName;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,125 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.hzya.frame.grpU8.nxproof.oerannex.entity.OerAnnexEntity">
|
||||||
|
<resultMap id="get-OerAnnexEntity-result" type="com.hzya.frame.grpU8.nxproof.oerannex.entity.OerAnnexEntity">
|
||||||
|
<result property="annexid" column="annexid" />
|
||||||
|
<result property="mlid" column="mlid" />
|
||||||
|
<result property="gsdm" column="gsdm" />
|
||||||
|
<result property="kjnd" column="kjnd" />
|
||||||
|
<result property="bnxid" column="bnxid" />
|
||||||
|
<result property="xh" column="xh" />
|
||||||
|
<result property="onlyid" column="onlyid" />
|
||||||
|
<result property="annexName" column="annexName" />
|
||||||
|
<result property="annexSize" column="annexSize" />
|
||||||
|
<result property="showSize" column="showSize" />
|
||||||
|
<result property="ole" column="ole" />
|
||||||
|
<result property="fjType" column="fjType" />
|
||||||
|
<result property="fpid" column="fpid" />
|
||||||
|
<result property="maxAnnexid" column="maxAnnexid" />
|
||||||
|
<result property="aTextName" column="aTextName" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="OerAnnexEntity_Base_Column_List">
|
||||||
|
AnnexID,
|
||||||
|
MLID,
|
||||||
|
GSDM,
|
||||||
|
KJND,
|
||||||
|
BNXID,
|
||||||
|
XH,
|
||||||
|
OnlyID,
|
||||||
|
AnnexName,
|
||||||
|
AnnexSize,
|
||||||
|
ShowSize,
|
||||||
|
OLE,
|
||||||
|
FJType,
|
||||||
|
FPID
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 查询 采用==查询 -->
|
||||||
|
<select id="OerAnnexEntity_list_base" resultMap="get-OerAnnexEntity-result" parameterType="com.hzya.frame.grpU8.nxproof.oerannex.entity.OerAnnexEntity">
|
||||||
|
select
|
||||||
|
<include refid="OerAnnexEntity_Base_Column_List" />
|
||||||
|
FROM
|
||||||
|
OER_ANNEX
|
||||||
|
<trim prefix="where" prefixOverrides="and">
|
||||||
|
<if test="mlid != null and mlid !='' "> MLID = #{mlid} </if>
|
||||||
|
<if test="kjnd != null and kjnd !='' ">and KJND = #{kjnd} </if>
|
||||||
|
<if test="gsdm != null and gsdm !='' ">and gsdm = #{gsdm} </if>
|
||||||
|
</trim>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 查询 采用==查询 联查附件表 -->
|
||||||
|
<select id="OerAnnexEntity_list_base_join_attachment" resultMap="get-OerAnnexEntity-result" parameterType="com.hzya.frame.grpU8.nxproof.oerannex.entity.OerAnnexEntity">
|
||||||
|
select
|
||||||
|
OER_ANNEX.AnnexID,
|
||||||
|
OER_ANNEX.mlid,
|
||||||
|
OER_ANNEX.OnlyID,
|
||||||
|
OER_ANNEX.AnnexName,
|
||||||
|
OER_ANNEX.AnnexSize,
|
||||||
|
AT_AttachmentFile.AtextName
|
||||||
|
FROM
|
||||||
|
OER_ANNEX
|
||||||
|
LEFT JOIN AT_AttachmentFile ON AT_AttachmentFile.ATGuid = OER_ANNEX.OnlyID
|
||||||
|
<trim prefix="where" prefixOverrides="and">
|
||||||
|
<if test="mlid != null and mlid !='' "> MLID = #{mlid} </if>
|
||||||
|
<if test="kjnd != null and kjnd !='' ">and KJND = #{kjnd} </if>
|
||||||
|
<if test="gsdm != null and gsdm !='' ">and gsdm = #{gsdm} </if>
|
||||||
|
</trim>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!--查询最大id-->
|
||||||
|
<select id="OerAnnexEntity_max_id" resultMap="get-OerAnnexEntity-result" parameterType="com.hzya.frame.grpU8.nxproof.oerannex.entity.OerAnnexEntity">
|
||||||
|
SELECT
|
||||||
|
MAX(AnnexID) as maxAnnexid
|
||||||
|
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>
|
||||||
|
</trim>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="OerAnnexEntity_insert" parameterType="com.hzya.frame.grpU8.nxproof.oerannex.entity.OerAnnexEntity">
|
||||||
|
insert into OER_ANNEX(
|
||||||
|
<trim suffix="" suffixOverrides=",">
|
||||||
|
<if test="annexid != null and annexid !='' ">AnnexID,</if>
|
||||||
|
<if test="mlid != null and mlid !='' "> MLID, </if>
|
||||||
|
<if test="gsdm != null and gsdm !='' "> gsdm, </if>
|
||||||
|
<if test="kjnd != null and kjnd !='' "> kjnd ,</if>
|
||||||
|
<if test="xh != null and xh !='' ">xh,</if>
|
||||||
|
<if test="onlyid != null and onlyid !='' ">onlyid,</if>
|
||||||
|
<if test="annexName != null and annexName !='' ">annexName,</if>
|
||||||
|
<if test="annexSize != null and annexSize !='' ">annexSize,</if>
|
||||||
|
<if test="showSize != null and showSize !='' ">showSize,</if>
|
||||||
|
<if test="fjType != null and fjType !='' ">fjType,</if>
|
||||||
|
bnxid,
|
||||||
|
ole,
|
||||||
|
fpid
|
||||||
|
</trim>
|
||||||
|
)values
|
||||||
|
(
|
||||||
|
<trim suffix="" suffixOverrides=",">
|
||||||
|
<if test="annexid != null and annexid !='' ">#{annexid},</if>
|
||||||
|
<if test="mlid != null and mlid !='' "> #{mlid}, </if>
|
||||||
|
<if test="gsdm != null and gsdm !='' "> #{gsdm}, </if>
|
||||||
|
<if test="kjnd != null and kjnd !='' "> #{kjnd} ,</if>
|
||||||
|
<if test="xh != null and xh !='' ">#{xh},</if>
|
||||||
|
<if test="onlyid != null and onlyid !='' ">#{onlyid},</if>
|
||||||
|
<if test="annexName != null and annexName !='' ">#{annexName},</if>
|
||||||
|
<if test="annexSize != null and annexSize !='' ">#{annexSize},</if>
|
||||||
|
<if test="showSize != null and showSize !='' ">#{showSize},</if>
|
||||||
|
<if test="fjType != null and fjType !='' ">#{fjType},</if>
|
||||||
|
0,
|
||||||
|
null,
|
||||||
|
''
|
||||||
|
</trim>
|
||||||
|
)
|
||||||
|
</insert>
|
||||||
|
<!-- 删除附件 -->
|
||||||
|
<delete id="OerAnnexEntity_delete" parameterType="com.hzya.frame.grpU8.nxproof.oerannex.entity.OerAnnexEntity">
|
||||||
|
delete from OER_ANNEX where mlid = #{mlid} and kjnd = #{kjnd} and gsdm = #{gsdm}
|
||||||
|
</delete>
|
||||||
|
</mapper>
|
|
@ -0,0 +1,51 @@
|
||||||
|
package com.hzya.frame.grpU8.nxproof.oerannex.service;
|
||||||
|
/*
|
||||||
|
* @Description 附件关系表
|
||||||
|
* @Author xiangerlin
|
||||||
|
@Date 2022-10-26 10:06
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import com.hzya.frame.grpU8.nxproof.oerannex.entity.OerAnnexEntity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface IOerAnnexService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询附件关系
|
||||||
|
* @param entity
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
List<OerAnnexEntity> queryAnnex(OerAnnexEntity entity)throws Exception;
|
||||||
|
/**
|
||||||
|
* 查询最大id
|
||||||
|
* @param entity
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
String queryMaxId(OerAnnexEntity entity)throws Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存附件关系
|
||||||
|
* @param entity
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
void saveAnnex(OerAnnexEntity entity)throws Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除附件关系
|
||||||
|
* @param entity
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
void deleteAnnex(OerAnnexEntity entity)throws Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询附件关系,联查附件对象表
|
||||||
|
* @param mlid
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
List<OerAnnexEntity> queryAnnexAndFile(String mlid)throws Exception;
|
||||||
|
}
|
|
@ -0,0 +1,132 @@
|
||||||
|
package com.hzya.frame.grpU8.nxproof.oerannex.service.impl;/*
|
||||||
|
* @Description 附件关系表
|
||||||
|
* @Author xiangerlin
|
||||||
|
@Date 2022-10-26 10:07
|
||||||
|
*/
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.hzya.frame.basedao.service.impl.BaseService;
|
||||||
|
import com.hzya.frame.grpU8.nxproof.oerannex.dao.IOerAnnexDao;
|
||||||
|
import com.hzya.frame.grpU8.nxproof.oerannex.entity.OerAnnexEntity;
|
||||||
|
import com.hzya.frame.grpU8.nxproof.oerannex.service.IOerAnnexService;
|
||||||
|
import com.hzya.frame.web.exception.BaseSystemException;
|
||||||
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class OerAnnexServiceImpl extends BaseService<OerAnnexEntity,String> implements IOerAnnexService {
|
||||||
|
|
||||||
|
Logger logger = LogManager.getLogger(getClass());
|
||||||
|
|
||||||
|
protected IOerAnnexDao oerAnnexDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public void setBillLogDao(IOerAnnexDao dao) {
|
||||||
|
this.oerAnnexDao = dao;
|
||||||
|
this.dao=dao;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询附件关系
|
||||||
|
*
|
||||||
|
* @param entity
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<OerAnnexEntity> queryAnnex(OerAnnexEntity entity) throws Exception {
|
||||||
|
List<OerAnnexEntity> annexList = oerAnnexDao.query(entity);
|
||||||
|
return annexList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除附件关系
|
||||||
|
*
|
||||||
|
* @param entity
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void deleteAnnex(OerAnnexEntity entity) throws Exception {
|
||||||
|
if (null != entity && StrUtil.isNotEmpty(entity.getMlid()) && StrUtil.isNotEmpty(entity.getKjnd())){
|
||||||
|
oerAnnexDao.delete("OerAnnexEntity_delete",entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询最大id
|
||||||
|
* @param entity
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String queryMaxId(OerAnnexEntity entity) throws Exception {
|
||||||
|
if (null == entity){
|
||||||
|
entity = new OerAnnexEntity();
|
||||||
|
}
|
||||||
|
if (StrUtil.isEmpty(entity.getKjnd())){
|
||||||
|
entity.setKjnd(String.valueOf(DateUtil.year(new Date())));
|
||||||
|
}
|
||||||
|
OerAnnexEntity max = oerAnnexDao.query(entity,"OerAnnexEntity_max_id");
|
||||||
|
if (null != max){
|
||||||
|
Long max_value = Long.valueOf(max.getMaxAnnexid());
|
||||||
|
return String.valueOf(max_value+1);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存附件关系
|
||||||
|
* @param entity
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void saveAnnex(OerAnnexEntity entity) throws Exception {
|
||||||
|
if (null == entity){
|
||||||
|
throw new BaseSystemException("参数不能为空");
|
||||||
|
}
|
||||||
|
//entity.setAcc_name(Constant.CONFIGMAP.get("file_acc_name"));
|
||||||
|
entity.setAnnexid(queryMaxId(entity));
|
||||||
|
if (null != entity.getAnnexSize()){
|
||||||
|
int fileSize = entity.getAnnexSize().intValue();
|
||||||
|
String showSize = "";
|
||||||
|
if (fileSize < 1000) {
|
||||||
|
showSize = fileSize + "b";
|
||||||
|
} else if (1000 < fileSize && fileSize < 1000000) {
|
||||||
|
showSize = (fileSize / 1000) + " KB";
|
||||||
|
} else {
|
||||||
|
showSize = (fileSize / 1000000) + " MB";
|
||||||
|
}
|
||||||
|
entity.setShowSize(showSize);
|
||||||
|
}
|
||||||
|
/* if (!entity.getAnnexName().contains("合同")) {
|
||||||
|
entity.setFjType("其它");
|
||||||
|
}else {
|
||||||
|
entity.setFjType("合同");
|
||||||
|
}*/
|
||||||
|
entity.setFjType("其它");
|
||||||
|
oerAnnexDao.save(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询附件关系,联查附件对象表
|
||||||
|
*
|
||||||
|
* @param mlid
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<OerAnnexEntity> queryAnnexAndFile(String mlid) throws Exception {
|
||||||
|
OerAnnexEntity entity = new OerAnnexEntity();
|
||||||
|
entity.setMlid(mlid);
|
||||||
|
List<OerAnnexEntity> oerAnnexList = oerAnnexDao.queryList(entity, "OerAnnexEntity_list_base_join_attachment");
|
||||||
|
return oerAnnexList;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
package com.hzya.frame.grpU8.nxproof.oerdjml.dto;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description 附件对象
|
||||||
|
* @Author xiangerlin
|
||||||
|
* @Date 2024/8/16 10:28
|
||||||
|
**/
|
||||||
|
public class FileInfoDTO {
|
||||||
|
private byte[] data;//附件压缩成zip后的数据
|
||||||
|
private String file_name;//附件名字
|
||||||
|
private String file_size;//附件大小
|
||||||
|
|
||||||
|
public byte[] getData() {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setData(byte[] data) {
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFile_name() {
|
||||||
|
return file_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFile_name(String file_name) {
|
||||||
|
this.file_name = file_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFile_size() {
|
||||||
|
return file_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFile_size(String file_size) {
|
||||||
|
this.file_size = file_size;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
package com.hzya.frame.grpU8.nxproof.oerdjml.entity;
|
package com.hzya.frame.grpU8.nxproof.oerdjml.entity;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
import com.hzya.frame.grpU8.nxproof.gbizbsyrec.entity.GbiZbsyrecEntity;
|
import com.hzya.frame.grpU8.nxproof.gbizbsyrec.entity.GbiZbsyrecEntity;
|
||||||
import com.hzya.frame.grpU8.nxproof.oerdjjsfs.entity.OerDjjsfsEntity;
|
import com.hzya.frame.grpU8.nxproof.oerdjjsfs.entity.OerDjjsfsEntity;
|
||||||
import com.hzya.frame.grpU8.nxproof.oerdjnr.entity.OerDjnrEntity;
|
import com.hzya.frame.grpU8.nxproof.oerdjnr.entity.OerDjnrEntity;
|
||||||
|
@ -73,10 +74,14 @@ public class OerDjmlEntity extends BaseEntity {
|
||||||
private String ssrid;
|
private String ssrid;
|
||||||
//送审人
|
//送审人
|
||||||
private String ssr;
|
private String ssr;
|
||||||
private List<GbiZbsyrecEntity> gbiZbsyrecEntitylist;
|
@JSONField(ordinal = 9996)
|
||||||
private List<OerDjnrEntity> oerDjnrEntityList;
|
private List<OerDjnrEntity> oerDjnrEntityList;
|
||||||
|
@JSONField(ordinal = 9997)
|
||||||
private List<OerYszbEntity> oerYszbEntityList;
|
private List<OerYszbEntity> oerYszbEntityList;
|
||||||
|
@JSONField(ordinal = 9998)
|
||||||
private List<OerDjjsfsEntity> oerDjjsfsEntityList;
|
private List<OerDjjsfsEntity> oerDjjsfsEntityList;
|
||||||
|
@JSONField(ordinal = 9999)
|
||||||
|
private List<GbiZbsyrecEntity> gbiZbsyrecEntitylist;
|
||||||
|
|
||||||
public String getMlId() {
|
public String getMlId() {
|
||||||
return mlId;
|
return mlId;
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.hzya.frame.grpU8.nxproof.oerdjml.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
|
import cn.hutool.core.date.DateTime;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
|
@ -9,9 +10,11 @@ import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.hzya.frame.grpU8.nxproof.gbizbsyrec.dao.IGbiZbsyrecDao;
|
import com.hzya.frame.grpU8.nxproof.gbizbsyrec.dao.IGbiZbsyrecDao;
|
||||||
import com.hzya.frame.grpU8.nxproof.gbizbsyrec.entity.GbiZbsyrecEntity;
|
import com.hzya.frame.grpU8.nxproof.gbizbsyrec.entity.GbiZbsyrecEntity;
|
||||||
|
import com.hzya.frame.grpU8.nxproof.oerannex.entity.OerAnnexEntity;
|
||||||
import com.hzya.frame.grpU8.nxproof.oerdjjsfs.dao.IOerDjjsfsDao;
|
import com.hzya.frame.grpU8.nxproof.oerdjjsfs.dao.IOerDjjsfsDao;
|
||||||
import com.hzya.frame.grpU8.nxproof.oerdjjsfs.entity.OerDjjsfsEntity;
|
import com.hzya.frame.grpU8.nxproof.oerdjjsfs.entity.OerDjjsfsEntity;
|
||||||
import com.hzya.frame.grpU8.nxproof.oerdjml.dao.IOerDjmlDao;
|
import com.hzya.frame.grpU8.nxproof.oerdjml.dao.IOerDjmlDao;
|
||||||
|
import com.hzya.frame.grpU8.nxproof.oerdjml.dto.FileInfoDTO;
|
||||||
import com.hzya.frame.grpU8.nxproof.oerdjml.entity.GbiZbsyrecAllEntity;
|
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.entity.OerDjmlEntity;
|
||||||
import com.hzya.frame.grpU8.nxproof.oerdjml.service.IOerDjmlService;
|
import com.hzya.frame.grpU8.nxproof.oerdjml.service.IOerDjmlService;
|
||||||
|
@ -24,19 +27,28 @@ import com.hzya.frame.grpU8.nxproof.pubauditlog.entity.PubAuditLogEntity;
|
||||||
import com.hzya.frame.grpU8.nxproof.pubobjflow.dao.IPubObjFlowDao;
|
import com.hzya.frame.grpU8.nxproof.pubobjflow.dao.IPubObjFlowDao;
|
||||||
import com.hzya.frame.grpU8.nxproof.pubobjflow.entity.PubObjFlowEntity;
|
import com.hzya.frame.grpU8.nxproof.pubobjflow.entity.PubObjFlowEntity;
|
||||||
import com.hzya.frame.mdm.entity.MdmDto;
|
import com.hzya.frame.mdm.entity.MdmDto;
|
||||||
|
import com.hzya.frame.seeyon.entity.CollAttachmentResDTO;
|
||||||
import com.hzya.frame.seeyon.enums.ColEventTypeEnum;
|
import com.hzya.frame.seeyon.enums.ColEventTypeEnum;
|
||||||
|
import com.hzya.frame.seeyon.util.RestUtil;
|
||||||
import com.hzya.frame.sysnew.application.entity.SysExtensionApiEntity;
|
import com.hzya.frame.sysnew.application.entity.SysExtensionApiEntity;
|
||||||
import com.hzya.frame.web.entity.BaseResult;
|
import com.hzya.frame.web.entity.BaseResult;
|
||||||
import com.hzya.frame.web.exception.BaseSystemException;
|
import com.hzya.frame.web.exception.BaseSystemException;
|
||||||
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.net.URLDecoder;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.zip.ZipEntry;
|
||||||
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author:hecan
|
* @Author:hecan
|
||||||
|
@ -63,7 +75,10 @@ public class OerDjmlServiceImpl implements IOerDjmlService {
|
||||||
private IPubAuditLogDao iPubAuditLogDao;
|
private IPubAuditLogDao iPubAuditLogDao;
|
||||||
@Autowired
|
@Autowired
|
||||||
private IPubObjFlowDao iPubObjFlowDao;
|
private IPubObjFlowDao iPubObjFlowDao;
|
||||||
|
@Autowired
|
||||||
|
private RestUtil restUtil;
|
||||||
|
@Value("${savefile.path}")
|
||||||
|
public String DSK;
|
||||||
@Override
|
@Override
|
||||||
public String saveExpenseDocuments(JSONObject jsonObject) {
|
public String saveExpenseDocuments(JSONObject jsonObject) {
|
||||||
|
|
||||||
|
@ -816,6 +831,7 @@ public class OerDjmlServiceImpl implements IOerDjmlService {
|
||||||
String forsonTableName = headers.get("forsonTableName");
|
String forsonTableName = headers.get("forsonTableName");
|
||||||
String djlxid = headers.get("djlxid");
|
String djlxid = headers.get("djlxid");
|
||||||
String flowcode = headers.get("flowcode");
|
String flowcode = headers.get("flowcode");
|
||||||
|
String fileApiCode = headers.get("file_api_code");
|
||||||
JSONObject bodyObj = JSONObject.parseObject(bodys);
|
JSONObject bodyObj = JSONObject.parseObject(bodys);
|
||||||
JSONObject seeyonData = bodyObj.getJSONObject("businessDataStr");
|
JSONObject seeyonData = bodyObj.getJSONObject("businessDataStr");
|
||||||
if (null != seeyonData){
|
if (null != seeyonData){
|
||||||
|
@ -830,6 +846,7 @@ public class OerDjmlServiceImpl implements IOerDjmlService {
|
||||||
JSONObject forjsonData0 = forsonData.getJSONObject(0);
|
JSONObject forjsonData0 = forsonData.getJSONObject(0);
|
||||||
OerDjmlEntity djml = new OerDjmlEntity();
|
OerDjmlEntity djml = new OerDjmlEntity();
|
||||||
djml.setDjbh(formmainData.getString("field0001"));
|
djml.setDjbh(formmainData.getString("field0001"));
|
||||||
|
djml.setLclb(eventType);
|
||||||
//流程发起
|
//流程发起
|
||||||
if (ColEventTypeEnum.ONSTART.getType().equals(eventType)){
|
if (ColEventTypeEnum.ONSTART.getType().equals(eventType)){
|
||||||
djml.setGsdm(forjsonData0.getString("field0084"));
|
djml.setGsdm(forjsonData0.getString("field0084"));
|
||||||
|
@ -838,8 +855,8 @@ public class OerDjmlServiceImpl implements IOerDjmlService {
|
||||||
djml.setZt("2");
|
djml.setZt("2");
|
||||||
djml.setCrerdm(formmainData.getString("field0107"));
|
djml.setCrerdm(formmainData.getString("field0107"));
|
||||||
djml.setCrermc("");
|
djml.setCrermc("");
|
||||||
djml.setCrerdate(formmainData.getString("startDate"));
|
djml.setCrerdate(timestampConvert(formmainData.getString("start_date")));
|
||||||
djml.setDjdate(formmainData.getString("field0002"));
|
djml.setDjdate((formmainData.getString("field0002")));
|
||||||
djml.setJe(formmainData.getString("field0080"));
|
djml.setJe(formmainData.getString("field0080"));
|
||||||
djml.setJedx( Convert.numberToChinese(Double.valueOf(formmainData.getString("field0080")),true));
|
djml.setJedx( Convert.numberToChinese(Double.valueOf(formmainData.getString("field0080")),true));
|
||||||
djml.setYjje("0.00");
|
djml.setYjje("0.00");
|
||||||
|
@ -970,17 +987,61 @@ public class OerDjmlServiceImpl implements IOerDjmlService {
|
||||||
logger.info("报销单结算方式:{}",JSONObject.toJSONString(jsfsList));
|
logger.info("报销单结算方式:{}",JSONObject.toJSONString(jsfsList));
|
||||||
logger.info("报销单预算指标:{}",JSONObject.toJSONString(yszbList));
|
logger.info("报销单预算指标:{}",JSONObject.toJSONString(yszbList));
|
||||||
djml.setOerDjnrEntityList(djnrList);
|
djml.setOerDjnrEntityList(djnrList);
|
||||||
|
djml.setOerDjjsfsEntityList(jsfsList);
|
||||||
djml.setOerYszbEntityList(yszbList);
|
djml.setOerYszbEntityList(yszbList);
|
||||||
String djmlStr = JSONObject.toJSONString(djml);
|
}else if (ColEventTypeEnum.ONSTOP.getType().equals(eventType)){
|
||||||
JSONObject param = new JSONObject(new LinkedHashMap<>());
|
//流程终止 修改状态,释放指标
|
||||||
param = JSONObject.parseObject(djmlStr);
|
djml.setZt("0");
|
||||||
param.put("lclb",eventType);
|
}else if (ColEventTypeEnum.ONCANCEL.getType().equals(eventType)){
|
||||||
param.put("oerDjnrEntityList",djnrList);
|
//流程撤销 修改状态,释放指标
|
||||||
param.put("oerYszbEntityList",yszbList);
|
djml.setZt("1");
|
||||||
param.put("oerDjjsfsEntityList",jsfsList);
|
}else if (ColEventTypeEnum.ONPROCESSFINISHED.getType().equals(eventType)){
|
||||||
//param.put("gbiZbsyrecEntitylist",null);
|
//流程处理事件
|
||||||
logger.info("差旅报销单报文:{}",param.toString());
|
djml.setZt("3");
|
||||||
|
djml.setCurshjd("999");
|
||||||
|
djml.setNextshjd("-1");
|
||||||
|
//查询协同附件
|
||||||
|
List<CollAttachmentResDTO> colAttachmentList = restUtil.getColAttachments(bodyObj.getString("summaryId"), "0", "fileApiCode", "hzya");
|
||||||
|
//下载协同附件
|
||||||
|
if (CollectionUtils.isNotEmpty(colAttachmentList)){
|
||||||
|
List<FileInfoDTO> fileList = new ArrayList<>();
|
||||||
|
for (CollAttachmentResDTO att : colAttachmentList) {
|
||||||
|
FileInfoDTO fileInfoDTO = new FileInfoDTO();
|
||||||
|
|
||||||
|
String fileName = URLDecoder.decode(att.getFilename(), "UTF-8");
|
||||||
|
byte[] bytes = restUtil.downloadFileBytes("hzya", fileApiCode, att.getFileUrl(), fileName);
|
||||||
|
String filePath = DSK+File.separator+DateUtil.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.getSubReference()+".zip";
|
||||||
|
ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipPath), Charset.forName("GBK"));
|
||||||
|
writeZipFile(file, zos, fileName);
|
||||||
|
zos.close();
|
||||||
|
// 获取压缩文件的字节数组
|
||||||
|
File zipFile = new File(zipPath);
|
||||||
|
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 = 0;
|
||||||
|
while (-1 != (len = bufferedInputStream.read(buffer, 0, buf_size))) {
|
||||||
|
byteArrayOutputStream.write(buffer, 0, len);
|
||||||
|
}
|
||||||
|
byte[] fileByte = byteArrayOutputStream.toByteArray();
|
||||||
|
fileInfoDTO.setData(fileByte);
|
||||||
|
fileInfoDTO.setFile_size(att.getSize());
|
||||||
|
fileInfoDTO.setFile_name(fileName);
|
||||||
|
fileList.add(fileInfoDTO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
String djmlStr = JSONObject.toJSONString(djml);
|
||||||
|
logger.info("差旅报销单报文:{}",djmlStr);
|
||||||
}
|
}
|
||||||
}catch (Exception ex ){
|
}catch (Exception ex ){
|
||||||
logger.error("保存报销单之前组装参数出错",ex);
|
logger.error("保存报销单之前组装参数出错",ex);
|
||||||
|
@ -988,6 +1049,45 @@ public class OerDjmlServiceImpl implements IOerDjmlService {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String timestampConvert(String timestamp){
|
||||||
|
if (StrUtil.isNotEmpty(timestamp)){
|
||||||
|
try {
|
||||||
|
DateTime date = DateUtil.date(Long.valueOf(timestamp));
|
||||||
|
String formattedDate = DateUtil.format(date, "yyyyMMdd");
|
||||||
|
return formattedDate;
|
||||||
|
}catch (Exception e){
|
||||||
|
logger.error("日期转换出错:{}",e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 把文件压缩成zip
|
||||||
|
* @param file 要压缩的文件
|
||||||
|
* @param zos 文件压缩流
|
||||||
|
* @param fileName 文件名
|
||||||
|
*/
|
||||||
|
private void writeZipFile(File file, ZipOutputStream zos, String fileName) {
|
||||||
|
if (null != file && null != zos) {
|
||||||
|
try {
|
||||||
|
logger.info("=====压缩文件=====");
|
||||||
|
zos.putNextEntry(new ZipEntry(fileName));
|
||||||
|
FileInputStream fos = new FileInputStream(file);
|
||||||
|
BufferedInputStream bis = new BufferedInputStream(fos);
|
||||||
|
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("=====压缩文件出错=====");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue