fix: bug
This commit is contained in:
@@ -1,23 +1,30 @@
|
||||
package com.point.strategy.common;
|
||||
|
||||
import com.drew.imaging.ImageMetadataReader;
|
||||
import com.drew.metadata.Directory;
|
||||
import com.drew.metadata.Metadata;
|
||||
import com.drew.metadata.exif.ExifDirectoryBase;
|
||||
import com.itextpdf.text.*;
|
||||
import com.itextpdf.text.Font;
|
||||
import com.itextpdf.text.Image;
|
||||
import com.itextpdf.text.Rectangle;
|
||||
import com.itextpdf.text.pdf.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.util.ResourceUtils;
|
||||
|
||||
import com.itextpdf.text.pdf.PdfCopy;
|
||||
import com.itextpdf.text.pdf.PdfReader;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.imageio.ImageReader;
|
||||
import javax.imageio.stream.FileImageInputStream;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
|
||||
@Slf4j
|
||||
public class PdfFileHelper {
|
||||
/*
|
||||
水印间隔
|
||||
@@ -117,7 +124,7 @@ public class PdfFileHelper {
|
||||
for (int r = 0; r < grid_rows; r++) {
|
||||
for (int j = 0; j < grid_cols; j++) {
|
||||
//画网格矩形
|
||||
content.setColorStroke(BaseColor.RED);
|
||||
content.setColorStroke(BaseColor.BLACK);
|
||||
float x = grid_left + grid_col_width * j;
|
||||
float y = height - grid_top - grid_col_height * (r + 1);
|
||||
content.rectangle(x, y, grid_col_width, grid_col_height);
|
||||
@@ -133,7 +140,7 @@ public class PdfFileHelper {
|
||||
|
||||
//写入文本
|
||||
content.beginText();
|
||||
content.setColorFill(BaseColor.RED);
|
||||
content.setColorFill(BaseColor.BLACK);
|
||||
content.setFontAndSize(font, (int) Math.ceil(font_size * scale * 1.0));
|
||||
content.setTextMatrix(0, 0);
|
||||
//content.ShowTextAligned(Element.ALIGN_LEFT, textContent[r, j], text_left + grid_col_width*j +
|
||||
@@ -238,6 +245,25 @@ public class PdfFileHelper {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取pdf文件总页数
|
||||
* PdfReader
|
||||
*
|
||||
* @param f
|
||||
* @return
|
||||
*/
|
||||
public static int getPdfPageCounOrOther(String f) {
|
||||
try {
|
||||
PdfReader pdfReader = new PdfReader(f);
|
||||
PdfReader.unethicalreading = true;
|
||||
int numberOfPages = pdfReader.getNumberOfPages();
|
||||
pdfReader.close();
|
||||
return numberOfPages;
|
||||
} catch (Exception ex) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pdf文件加水印文字--居中
|
||||
*
|
||||
@@ -350,41 +376,61 @@ public class PdfFileHelper {
|
||||
* 合并Pdf
|
||||
*
|
||||
* @param fileArray pdf图片数组[]{"d:/a/1.pdf","d:/a/2.pdf"}
|
||||
* @param tarFile 生成的目标pdf
|
||||
* @return
|
||||
*/
|
||||
public static boolean mergePdf(String[] fileArray, String tarFile) {
|
||||
//目标文件存在,则先删除
|
||||
File _tarFile = new File(tarFile);
|
||||
if (_tarFile.exists()) {
|
||||
_tarFile.delete();
|
||||
public static boolean mergePdf(String[] fileArray, String targetFile) {
|
||||
if (fileArray == null || fileArray.length == 0) {
|
||||
log.warn("输入的PDF文件数组为空,无需合并。");
|
||||
return true; // 或根据业务需求返回false
|
||||
}
|
||||
Arrays.sort(fileArray);
|
||||
try {
|
||||
Document doc = new Document();
|
||||
PdfCopy pdf = new PdfCopy(doc, new FileOutputStream(tarFile));
|
||||
doc.open();
|
||||
for (int i = 0; i < fileArray.length; i++) {
|
||||
if (fileArray[i] != null) {
|
||||
PdfReader pdfReader = new PdfReader(fileArray[i]);
|
||||
PdfReader.unethicalreading = true;
|
||||
int numberOfPages = pdfReader.getNumberOfPages();
|
||||
for (int page = 0; page < numberOfPages; page++) {
|
||||
PdfImportedPage newPage = pdf.getImportedPage(pdfReader, page + 1);
|
||||
pdf.addPage(newPage);
|
||||
}
|
||||
pdf.freeReader(pdfReader);
|
||||
pdfReader.close();
|
||||
}
|
||||
}
|
||||
doc.close();
|
||||
return true;
|
||||
} catch (Exception ex) {
|
||||
System.out.println("合并Pdf失败:" + ex.getMessage());
|
||||
File target = new File(targetFile);
|
||||
if (target.exists()) {
|
||||
if (!target.delete()) {
|
||||
log.error("无法删除已存在的目标文件: {}", targetFile);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Arrays.sort(fileArray);
|
||||
Document document = null;
|
||||
PdfCopy pdfCopy = null;
|
||||
try {
|
||||
document = new Document();
|
||||
pdfCopy = new PdfCopy(document, new FileOutputStream(targetFile));
|
||||
document.open();
|
||||
|
||||
for (String filePath : fileArray) {
|
||||
if (filePath == null || filePath.trim().isEmpty()) {
|
||||
log.warn("发现一个空的PDF文件路径,已跳过。");
|
||||
continue;
|
||||
}
|
||||
|
||||
PdfReader pdfReader = null;
|
||||
try {
|
||||
pdfReader = new PdfReader(filePath);
|
||||
|
||||
pdfCopy.addDocument(pdfReader);
|
||||
|
||||
} catch(Exception e) {
|
||||
log.error("读取或合并文件 {} 时出错,已跳过此文件。", filePath, e);
|
||||
} finally {
|
||||
if (pdfReader != null) {
|
||||
pdfReader.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} catch (IOException | DocumentException e) {
|
||||
log.error("合并PDF过程中发生严重错误。", e);
|
||||
return false;
|
||||
} finally {
|
||||
// 5. 在最外层的 finally 块中关闭 Document 和 PdfCopy
|
||||
// Document.close() 会自动调用 PdfCopy.close() 和底层的流。
|
||||
// 检查 document 是否为 null 并且已打开,以防在初始化时就发生异常。
|
||||
if (document != null && document.isOpen()) {
|
||||
document.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* @Description 图片转pdf
|
||||
* @Date 13:33 2019/6/10
|
||||
@@ -398,6 +444,8 @@ public class PdfFileHelper {
|
||||
Image png1 = Image.getInstance(source); //通过文件路径获取image
|
||||
// float heigth = png1.getHeight();
|
||||
// float width = png1.getWidth();
|
||||
// 新增:读取图片的EXIF方向信息
|
||||
int orientation = getExifOrientation(source);
|
||||
//new一个pdf文档
|
||||
Document doc = new Document(null, 0, 0, 0, 0);
|
||||
if (img == null) {
|
||||
@@ -411,6 +459,8 @@ public class PdfFileHelper {
|
||||
// int percent = getPercent2(heigth, width);
|
||||
// png1.setAlignment(Image.MIDDLE);
|
||||
// png1.scalePercent(percent+3);// 表示是原来图像的比例;
|
||||
// 新增:根据EXIF方向调整图片
|
||||
adjustImageOrientation(png1, orientation);
|
||||
doc.add(png1);
|
||||
doc.close();
|
||||
File mOutputPdfFile = new File(target); //输出流
|
||||
@@ -426,6 +476,43 @@ public class PdfFileHelper {
|
||||
}
|
||||
|
||||
|
||||
// 新增:获取图片的EXIF方向信息
|
||||
private static int getExifOrientation(String imagePath) {
|
||||
try {
|
||||
File imageFile = new File(imagePath);
|
||||
Metadata metadata = ImageMetadataReader.readMetadata(imageFile);
|
||||
|
||||
// 遍历元数据目录,查找 EXIF 方向标签
|
||||
for (Directory directory : metadata.getDirectories()) {
|
||||
// 使用 ExifDirectoryBase 的常量
|
||||
if (directory.containsTag(ExifDirectoryBase.TAG_ORIENTATION)) {
|
||||
return directory.getInt(ExifDirectoryBase.TAG_ORIENTATION);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.err.println("读取EXIF方向失败: " + e.getMessage());
|
||||
}
|
||||
return 1; // 默认方向:正常
|
||||
}
|
||||
|
||||
// 新增:根据EXIF方向调整图片
|
||||
private static void adjustImageOrientation(Image image, int orientation) throws DocumentException {
|
||||
switch (orientation) {
|
||||
case 1: // 正常
|
||||
break;
|
||||
case 3: // 旋转180度
|
||||
image.setRotationDegrees(180);
|
||||
break;
|
||||
case 6: // 顺时针旋转90度
|
||||
image.setRotationDegrees(90);
|
||||
break;
|
||||
case 8: // 逆时针旋转90度
|
||||
image.setRotationDegrees(270);
|
||||
break;
|
||||
// 其他情况可以根据需要添加
|
||||
}
|
||||
}
|
||||
|
||||
/****
|
||||
* 给PDF文件某些页增加马赛克
|
||||
* @param srcFile 源文件
|
||||
@@ -615,6 +702,23 @@ public class PdfFileHelper {
|
||||
return outputStream;
|
||||
}
|
||||
|
||||
|
||||
public static int getTifPageCount(String filePath) {
|
||||
|
||||
int pageCount = 0;
|
||||
try {
|
||||
File file = new File(filePath);
|
||||
Iterator<ImageReader> readers = ImageIO.getImageReadersByFormatName("TIFF");
|
||||
ImageReader reader = readers.next();
|
||||
reader.setInput(new FileImageInputStream(file));
|
||||
pageCount = reader.getNumImages(true);
|
||||
reader.dispose();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return pageCount;
|
||||
}
|
||||
|
||||
public static void main1(String[] args) {
|
||||
String source = "C:\\Users\\MI\\Desktop\\13\\pdf\\b.pdf";
|
||||
String target = "C:\\Users\\MI\\Desktop\\13\\pdf\\b-" + DateUtil.date2String(new Date(), 3) + ".pdf";
|
||||
@@ -658,14 +762,12 @@ public class PdfFileHelper {
|
||||
setWaterMark(srcFile, tarFile, markStr, fontSize, color, globalOblique);
|
||||
}
|
||||
|
||||
public static void main5(String[] args) {
|
||||
String tarFile = "C:\\Users\\MI\\Desktop\\13\\pdf\\mergePdf-" + DateUtil.date2String(new Date(), 3) + ".pdf";
|
||||
String[] fileArray = {"C:\\Users\\MI\\Desktop\\13\\pdf\\k1.pdf", "C:\\Users\\MI\\Desktop\\13\\pdf\\k2.pdf"};
|
||||
public static void main(String[] args) {
|
||||
String tarFile = "/Users/ab/Desktop/pdf/test.pdf";
|
||||
String[] fileArray = {"/Users/ab/Desktop/pdf/1.pdf", "/Users/ab/Desktop/pdf/2.pdf"};
|
||||
mergePdf(fileArray, tarFile);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
pageNo("C:\\Users\\MI\\Desktop\\13\\pdf\\caiwenhong.pdf","C:\\Users\\MI\\Desktop\\13\\pdf\\caiwenhong-pageNo.pdf");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1032,8 +1032,7 @@ public class DocSimpleController {
|
||||
public AjaxJson selectFileNameAndContentByFileContent(String tableName,String fileContent,int recId) {
|
||||
AjaxJson json = null;
|
||||
try {
|
||||
String tableRealName=tableName+"_file";
|
||||
List list = docSimpleService.selectFileNameAndContentByFileContent(tableRealName, fileContent,recId);
|
||||
List list = docSimpleService.selectFileNameAndContentByFileContent(tableName, fileContent,recId);
|
||||
PageInfo pageInfo = new PageInfo(list);
|
||||
long total = pageInfo.getTotal();
|
||||
json = new AjaxJson();
|
||||
|
||||
@@ -12,27 +12,48 @@ import java.util.Map;
|
||||
@Mapper
|
||||
public interface DocSimpleMapper {
|
||||
List getDocSimpleWithPage(DocSimpleArrange docSimpleArrange);
|
||||
|
||||
//根据id查询
|
||||
DocSimpleArrange getDocSimpleById(@Param("id") Integer id);
|
||||
|
||||
public int saveDocSimple(DocSimpleArrange docSimpleArrange);
|
||||
|
||||
public int deleteDocSimple(Integer id);
|
||||
|
||||
public int deleteDocSimpleCascadeRecycle(Integer recId);
|
||||
|
||||
public int updateDocSimple(DocSimpleArrange docSimpleArrange);
|
||||
|
||||
public int getDocOriginalEntityCount(Integer recId);
|
||||
|
||||
public void saveDocOriginalEntity(DocOriginalEntity docOriginalEntity);
|
||||
|
||||
public void saveDocOriginalJnEntity(DocOriginalEntity docOriginalEntity);
|
||||
|
||||
public List queryDocOriginalEntity(Integer recId);
|
||||
|
||||
public int updateDocOriginalEntity(Integer id);
|
||||
|
||||
public List queryDocOriginalEntityRecycle(Integer recId);
|
||||
|
||||
public void updateDocOriginalEntityRecycle(Integer id);
|
||||
|
||||
public int deleteDocOriginalEntityRecycle(Integer id);
|
||||
|
||||
public void saveBatchDocSimple(Map map);
|
||||
|
||||
DocOriginalEntity queryDocOriginalEntityById(Integer id);
|
||||
|
||||
public List selectObject(HashMap map);
|
||||
|
||||
public List<Map<String, Object>> selectObject3(Map<String, Object> map);
|
||||
|
||||
public List selectObjectLimit(HashMap map);
|
||||
|
||||
public void deleteObject(HashMap map);
|
||||
|
||||
public void saveObject(HashMap map);
|
||||
|
||||
public void updateObject(HashMap map);
|
||||
|
||||
//查询档案原文数量的值
|
||||
@@ -40,5 +61,9 @@ public interface DocSimpleMapper {
|
||||
|
||||
|
||||
//根据原文内容查找原文名称和原文内容全部信息
|
||||
public List<DocOriginalEntity> selectFileNameAndContentByFileContent(Map<String,Object> map);
|
||||
public List<DocOriginalEntity> selectFileNameAndContentByFileContent(Map<String, Object> map);
|
||||
|
||||
public String selectArchiveNo(String tableName, int recId);
|
||||
|
||||
void updateFileName(@Param("tableName") String tableName, @Param("list") List<DocOriginalEntity> collect);
|
||||
}
|
||||
|
||||
@@ -3,12 +3,11 @@ package com.point.strategy.docSimpleArrange.service;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.google.common.cache.Cache;
|
||||
import com.point.strategy.bean.OperLogger;
|
||||
import com.point.strategy.bean.TentityType;
|
||||
import com.point.strategy.bean.TtableDescription;
|
||||
import com.point.strategy.bean.TtableStructDescription;
|
||||
import com.point.strategy.common.*;
|
||||
import com.point.strategy.bean.OperLogger;
|
||||
import com.point.strategy.common.StringUtil;
|
||||
import com.point.strategy.directorySequenceTree.mapper.DirectorySeqMapper;
|
||||
import com.point.strategy.docSimpleArrange.bean.DocOriginalEntity;
|
||||
import com.point.strategy.docSimpleArrange.bean.DocSimpleArrange;
|
||||
@@ -23,29 +22,26 @@ import com.point.strategy.service.TtableStructDescriptionService;
|
||||
import com.point.strategy.user.bean.User;
|
||||
import com.point.strategy.user.bean.UserRole;
|
||||
import com.point.strategy.user.service.UserService;
|
||||
import io.swagger.models.auth.In;
|
||||
import jxl.Cell;
|
||||
import jxl.Sheet;
|
||||
import jxl.Workbook;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import scala.Int;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.sql.Clob;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Component("docSimpleService")
|
||||
@@ -212,54 +208,7 @@ public class DocSimpleService {
|
||||
|
||||
public void saveBatchDocSimple(MultipartFile file) throws Exception {
|
||||
String tableName = "wsda_20190528111300933_temp";
|
||||
String fieldName = "case_no," +
|
||||
" mlh," +
|
||||
" archive_no," +
|
||||
" note ," +
|
||||
" pigeonhole_date," +
|
||||
" archive_ctg_no," +
|
||||
" archive_ctg_no_code," +
|
||||
" retention," +
|
||||
" retention_code," +
|
||||
" filing_year," +
|
||||
" fonds_no," +
|
||||
" fonds_no_code," +
|
||||
" sbt_word," +
|
||||
" doc_no," +
|
||||
" dagdm," +
|
||||
" dagdm_code," +
|
||||
" created_date," +
|
||||
" object_quantity," +
|
||||
" security_class," +
|
||||
" security_class_code," +
|
||||
" quantity," +
|
||||
" piece_no," +
|
||||
" kzbs," +
|
||||
" kzbs_code," +
|
||||
" folder_location," +
|
||||
" damldm," +
|
||||
" damldm_code," +
|
||||
" maintitle," +
|
||||
" responsibleby," +
|
||||
" create_person," +
|
||||
" create_date," +
|
||||
" is_packeep," +
|
||||
" is_packeep_code," +
|
||||
" md5_code," +
|
||||
" md5_check_date," +
|
||||
" batch_id," +
|
||||
" batch_name," +
|
||||
" back_to_update_state," +
|
||||
" is_process," +
|
||||
" testtest_code," +
|
||||
" archive_file_num," +
|
||||
" departname," +
|
||||
" departname_code," +
|
||||
" lb," +
|
||||
" lb_code," +
|
||||
" lm," +
|
||||
" lm_code," +
|
||||
" archive_flag";
|
||||
String fieldName = "case_no," + " mlh," + " archive_no," + " note ," + " pigeonhole_date," + " archive_ctg_no," + " archive_ctg_no_code," + " retention," + " retention_code," + " filing_year," + " fonds_no," + " fonds_no_code," + " sbt_word," + " doc_no," + " dagdm," + " dagdm_code," + " created_date," + " object_quantity," + " security_class," + " security_class_code," + " quantity," + " piece_no," + " kzbs," + " kzbs_code," + " folder_location," + " damldm," + " damldm_code," + " maintitle," + " responsibleby," + " create_person," + " create_date," + " is_packeep," + " is_packeep_code," + " md5_code," + " md5_check_date," + " batch_id," + " batch_name," + " back_to_update_state," + " is_process," + " testtest_code," + " archive_file_num," + " departname," + " departname_code," + " lb," + " lb_code," + " lm," + " lm_code," + " archive_flag";
|
||||
InputStream in = file.getInputStream();
|
||||
Workbook boxExcel = Workbook.getWorkbook(in);
|
||||
Sheet boxSheet = boxExcel.getSheet(0);
|
||||
@@ -697,17 +646,17 @@ public class DocSimpleService {
|
||||
StringBuffer fieldName = new StringBuffer();
|
||||
StringBuffer valueName = new StringBuffer();
|
||||
HashMap fieldValueMap = packSqlObject.getFieldValueMap();
|
||||
if(fieldValueMap.get("archive_no")!=null){
|
||||
if (fieldValueMap.get("archive_no") != null) {
|
||||
String archiveNo1 = fieldValueMap.get("archive_no").toString();
|
||||
HashMap mapThree = new HashMap();
|
||||
StringBuffer conditionSql1 = new StringBuffer();
|
||||
conditionSql1.append("archive_no");
|
||||
conditionSql1.append("=");
|
||||
conditionSql1.append("'"+archiveNo1+"'");
|
||||
conditionSql1.append("'" + archiveNo1 + "'");
|
||||
mapThree.put("tableName", tableName);
|
||||
mapThree.put("conditionSql", conditionSql1.toString());
|
||||
List list = docSimpleMapper.selectObject(mapThree);
|
||||
if (CollectionUtils.isNotEmpty(list)){
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
return json = AjaxJson.returnExceptionInfo(archiveNo1 + "档号重复");
|
||||
}
|
||||
}
|
||||
@@ -753,14 +702,14 @@ public class DocSimpleService {
|
||||
entity.setOperatorChn(user3.getUserChnName());
|
||||
entity.setOperateDate(date);
|
||||
entity.setDescription("操作人[" + user3.getUsername() + "]在时间[" + DateUtil.date2String(date, 1) + "]新增了业务数据");
|
||||
entity.setArgs("表名称为:tableName=" + tableName+",数据为:"+ JSON.toJSONString(fieldValueMap));
|
||||
entity.setArgs("表名称为:tableName=" + tableName + ",数据为:" + JSON.toJSONString(fieldValueMap));
|
||||
operLoggerService.addEntity(entity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
json = AjaxJson.returnExceptionInfo("失败"+e);
|
||||
json = AjaxJson.returnExceptionInfo("失败" + e);
|
||||
}
|
||||
return json;
|
||||
}
|
||||
@@ -805,7 +754,7 @@ public class DocSimpleService {
|
||||
} else if (value.toString().contains("like")) {
|
||||
String str = value.toString();
|
||||
conditionSql.append(" and " + key + " like " + "'" + "%" + str.substring(4, str.length()) + "%" + "'");
|
||||
}else if (value.toString().contains("null")) {
|
||||
} else if (value.toString().contains("null")) {
|
||||
String str = value.toString();
|
||||
conditionSql.append(" and " + key + " is null or " + key + " = ''");
|
||||
} else {
|
||||
@@ -844,8 +793,8 @@ public class DocSimpleService {
|
||||
}
|
||||
// 判断是否需要附加数据权限
|
||||
Object pid = conditionMap.get("pid");
|
||||
if (pid==null && isRankJudgment(tableName1,"level") && ("".equals(funcTypeCode)||"temp".equals(funcTypeCode))){
|
||||
conditionSql.append(" and (level >="+user.getLevel()+" or level is null) ");
|
||||
if (pid == null && isRankJudgment(tableName1, "level") && ("".equals(funcTypeCode) || "temp".equals(funcTypeCode))) {
|
||||
conditionSql.append(" and (level >=" + user.getLevel() + " or level is null) ");
|
||||
}
|
||||
// //添加日志
|
||||
// if (user != null) {
|
||||
@@ -866,12 +815,12 @@ public class DocSimpleService {
|
||||
//map.put("fieldName", fieldName);
|
||||
map.put("conditionSql", conditionSql.toString());
|
||||
// 判断是否根据page_no 排序
|
||||
if (packSqlObject.getOrderBy()!=null && packSqlObject.getOrderBy().contains("page_no")){
|
||||
if (packSqlObject.getOrderBy() != null && packSqlObject.getOrderBy().contains("page_no")) {
|
||||
packSqlObject.setOrderBy("order by file_name asc");
|
||||
}
|
||||
map.put("orderBy", !"".equals(packSqlObject.getOrderBy()) ? packSqlObject.getOrderBy() : "");
|
||||
//将查询的数据加入redis缓存中
|
||||
Cache<Object,Object> fiveSecondCache = guavaLocalCache.getFiveSecondCache();
|
||||
Cache<Object, Object> fiveSecondCache = guavaLocalCache.getFiveSecondCache();
|
||||
fiveSecondCache.cleanUp();
|
||||
fiveSecondCache.put("list", docSimpleMapper.selectObject(map));
|
||||
// fiveSecondCache.invalidate();
|
||||
@@ -882,12 +831,13 @@ public class DocSimpleService {
|
||||
PageHelper.startPage(packSqlObject.getPage(), packSqlObject.getLimit());
|
||||
return docSimpleMapper.selectObject(map);
|
||||
}
|
||||
public boolean isRankJudgment(String table ,String level){
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put("columnName",level);
|
||||
map.put("tableName",table);
|
||||
|
||||
public boolean isRankJudgment(String table, String level) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("columnName", level);
|
||||
map.put("tableName", table);
|
||||
List<TtableStructDescription> ttableStructDescriptions = ttableStructDescriptionService.selectByTableNameAndColumnName(map);
|
||||
if(CollectionUtils.isNotEmpty(ttableStructDescriptions)){
|
||||
if (CollectionUtils.isNotEmpty(ttableStructDescriptions)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -1084,9 +1034,9 @@ public class DocSimpleService {
|
||||
//map.put("fieldName", fieldName);
|
||||
map.put("conditionSql", conditionSql.toString());
|
||||
map.put("orderBy", !"".equals(packSqlObject.getOrderBy()) ? packSqlObject.getOrderBy() : "");
|
||||
int page=packSqlObject.getPage()-1<0?0:packSqlObject.getPage()-1;
|
||||
int limit=packSqlObject.getLimit()-page<=0?1: packSqlObject.getLimit()-page;
|
||||
map.put("limit","limit"+" "+page+","+limit);
|
||||
int page = packSqlObject.getPage() - 1 < 0 ? 0 : packSqlObject.getPage() - 1;
|
||||
int limit = packSqlObject.getLimit() - page <= 0 ? 1 : packSqlObject.getLimit() - page;
|
||||
map.put("limit", "limit" + " " + page + "," + limit);
|
||||
// PageHelper.startPage(packSqlObject.getPage(), packSqlObject.getLimit());
|
||||
return docSimpleMapper.selectObjectLimit(map);
|
||||
}
|
||||
@@ -1141,7 +1091,7 @@ public class DocSimpleService {
|
||||
StringBuffer conditionSql = new StringBuffer();
|
||||
conditionSql.append("1=1");
|
||||
HashMap conditionMap = packSqlObject.getConditionMap();
|
||||
if(conditionMap.isEmpty()){
|
||||
if (conditionMap.isEmpty()) {
|
||||
return json = AjaxJson.returnExceptionInfo("conditionMap为空");
|
||||
}
|
||||
Set set2 = conditionMap.keySet();
|
||||
@@ -1249,7 +1199,7 @@ public class DocSimpleService {
|
||||
StringBuffer conditionSql = new StringBuffer();
|
||||
conditionSql.append("1=1");
|
||||
HashMap conditionMap = packSqlObject.getConditionMap();
|
||||
if(conditionMap.get("ids")==null||"".equals(conditionMap.get("ids"))){
|
||||
if (conditionMap.get("ids") == null || "".equals(conditionMap.get("ids"))) {
|
||||
return json = AjaxJson.returnExceptionInfo("conditionMap.get(\"ids\")为空");
|
||||
}
|
||||
Set set2 = conditionMap.keySet();
|
||||
@@ -1599,11 +1549,26 @@ public class DocSimpleService {
|
||||
|
||||
//根据原文内容查找原文名称和原文内容全部信息
|
||||
public List<DocOriginalEntity> selectFileNameAndContentByFileContent(String tableName, String fileContent, int recId) {
|
||||
/**
|
||||
* 查询文件表
|
||||
*/
|
||||
String fileTable = tableName + "_file";
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("tableName", tableName);
|
||||
map.put("tableName", fileTable);
|
||||
map.put("fileContent", fileContent);
|
||||
map.put("recId", recId);
|
||||
List<DocOriginalEntity> list = docSimpleMapper.selectFileNameAndContentByFileContent(map);
|
||||
long count = list.stream().filter(item -> item.getFileName().contains("null")).count();
|
||||
if (count > 0) {
|
||||
String archiveNo = docSimpleMapper.selectArchiveNo(tableName, recId);
|
||||
List<DocOriginalEntity> collect = list.stream().peek(item -> {
|
||||
if (item.getFileName().contains("null")) {
|
||||
item.setFileName(item.getFileName().replace("null", archiveNo));
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
docSimpleMapper.updateFileName(fileTable,collect);
|
||||
return collect;
|
||||
}
|
||||
return docSimpleMapper.selectFileNameAndContentByFileContent(map);
|
||||
}
|
||||
|
||||
@@ -1812,21 +1777,21 @@ public class DocSimpleService {
|
||||
piece_no = (String) value;
|
||||
Integer i = Integer.parseInt(piece_no);
|
||||
i = i + offset;
|
||||
if (i<=0){
|
||||
return AjaxJson.returnExceptionInfo("档号:"+archive_no+" 格式不对");
|
||||
if (i <= 0) {
|
||||
return AjaxJson.returnExceptionInfo("档号:" + archive_no + " 格式不对");
|
||||
}
|
||||
piece_no = i.toString();
|
||||
} else {
|
||||
Integer folder_no_int = (Integer) value;
|
||||
folder_no_int = folder_no_int + offset;
|
||||
if (folder_no_int<=0){
|
||||
return AjaxJson.returnExceptionInfo("档号:"+archive_no+" 格式不对");
|
||||
if (folder_no_int <= 0) {
|
||||
return AjaxJson.returnExceptionInfo("档号:" + archive_no + " 格式不对");
|
||||
}
|
||||
piece_no = folder_no_int.toString();
|
||||
}
|
||||
//修改后的档号
|
||||
String substring = archive_no.substring(0, archive_no.lastIndexOf('-'));
|
||||
String update_piece_no = maxPieceNoZeroFilling(Integer.parseInt(piece_no),archive_no.substring(archive_no.lastIndexOf('-')).length()-1);
|
||||
String update_piece_no = maxPieceNoZeroFilling(Integer.parseInt(piece_no), archive_no.substring(archive_no.lastIndexOf('-')).length() - 1);
|
||||
|
||||
//最终档号名称
|
||||
String update_archive_no = substring + "-" + update_piece_no;
|
||||
@@ -1862,20 +1827,20 @@ public class DocSimpleService {
|
||||
year_folder_no = (String) value;
|
||||
Integer i = Integer.parseInt(year_folder_no);
|
||||
i = i + offset;
|
||||
if (i<=0){
|
||||
return AjaxJson.returnExceptionInfo("案卷级档号:"+folder_no+" 格式不对");
|
||||
if (i <= 0) {
|
||||
return AjaxJson.returnExceptionInfo("案卷级档号:" + folder_no + " 格式不对");
|
||||
}
|
||||
year_folder_no = i.toString();
|
||||
} else {
|
||||
Integer folder_no_int = (Integer) value;
|
||||
folder_no_int = folder_no_int + offset;
|
||||
if (folder_no_int<=0){
|
||||
return AjaxJson.returnExceptionInfo("案卷级档号:"+folder_no+" 格式不对");
|
||||
if (folder_no_int <= 0) {
|
||||
return AjaxJson.returnExceptionInfo("案卷级档号:" + folder_no + " 格式不对");
|
||||
}
|
||||
year_folder_no = folder_no_int.toString();
|
||||
}
|
||||
String substring = folder_no.substring(0, folder_no.lastIndexOf('-'));
|
||||
String update_year_folder_no = maxPieceNoZeroFilling(Integer.parseInt(year_folder_no),folder_no.substring(folder_no.lastIndexOf('-')).length()-1);
|
||||
String update_year_folder_no = maxPieceNoZeroFilling(Integer.parseInt(year_folder_no), folder_no.substring(folder_no.lastIndexOf('-')).length() - 1);
|
||||
|
||||
//最终案卷机档号
|
||||
String update_archive_no = substring + "-" + update_year_folder_no;
|
||||
@@ -1955,21 +1920,21 @@ public class DocSimpleService {
|
||||
piece_no = (String) value;
|
||||
Integer i = Integer.parseInt(piece_no);
|
||||
i = i + offset;
|
||||
if (i<=0){
|
||||
return AjaxJson.returnExceptionInfo("档号:"+archive_no+" 格式不对");
|
||||
if (i <= 0) {
|
||||
return AjaxJson.returnExceptionInfo("档号:" + archive_no + " 格式不对");
|
||||
}
|
||||
piece_no = i.toString();
|
||||
} else {
|
||||
Integer folder_no_int = (Integer) value;
|
||||
folder_no_int = folder_no_int + offset;
|
||||
if (folder_no_int<=0){
|
||||
return AjaxJson.returnExceptionInfo("档号:"+archive_no+" 格式不对");
|
||||
if (folder_no_int <= 0) {
|
||||
return AjaxJson.returnExceptionInfo("档号:" + archive_no + " 格式不对");
|
||||
}
|
||||
piece_no = folder_no_int.toString();
|
||||
}
|
||||
//修改后的档号
|
||||
String substring = archive_no.substring(0, archive_no.lastIndexOf('-'));
|
||||
String update_piece_no = maxPieceNoZeroFilling(Integer.parseInt(piece_no),archive_no.substring(archive_no.lastIndexOf('-')).length()-1);
|
||||
String update_piece_no = maxPieceNoZeroFilling(Integer.parseInt(piece_no), archive_no.substring(archive_no.lastIndexOf('-')).length() - 1);
|
||||
//最终档号名称
|
||||
String update_archive_no = substring + "-" + update_piece_no;
|
||||
//修改档号
|
||||
@@ -2006,16 +1971,16 @@ public class DocSimpleService {
|
||||
old_item_id = item_id;
|
||||
Integer i = Integer.parseInt(item_id);
|
||||
i = i + offset;
|
||||
if (i<=0){
|
||||
return AjaxJson.returnExceptionInfo("项目号:"+item_id+" 不对");
|
||||
if (i <= 0) {
|
||||
return AjaxJson.returnExceptionInfo("项目号:" + item_id + " 不对");
|
||||
}
|
||||
item_id = i.toString();
|
||||
} else {
|
||||
Integer folder_no_int = (Integer) value;
|
||||
old_item_id = old_item_id;
|
||||
folder_no_int = folder_no_int + offset;
|
||||
if (folder_no_int<=0){
|
||||
return AjaxJson.returnExceptionInfo("项目号:"+item_id+" 不对");
|
||||
if (folder_no_int <= 0) {
|
||||
return AjaxJson.returnExceptionInfo("项目号:" + item_id + " 不对");
|
||||
}
|
||||
item_id = folder_no_int.toString();
|
||||
}
|
||||
@@ -2145,20 +2110,20 @@ public class DocSimpleService {
|
||||
year_folder_no = (String) value;
|
||||
Integer i = Integer.parseInt(year_folder_no);
|
||||
i = i + offset;
|
||||
if (i<=0){
|
||||
return AjaxJson.returnExceptionInfo("案卷级档号:"+folder_no+" 不对");
|
||||
if (i <= 0) {
|
||||
return AjaxJson.returnExceptionInfo("案卷级档号:" + folder_no + " 不对");
|
||||
}
|
||||
year_folder_no = i.toString();
|
||||
} else {
|
||||
Integer folder_no_int = (Integer) value;
|
||||
folder_no_int = folder_no_int + offset;
|
||||
if (folder_no_int<=0){
|
||||
return AjaxJson.returnExceptionInfo("案卷级档号:"+folder_no+" 不对");
|
||||
if (folder_no_int <= 0) {
|
||||
return AjaxJson.returnExceptionInfo("案卷级档号:" + folder_no + " 不对");
|
||||
}
|
||||
year_folder_no = folder_no_int.toString();
|
||||
}
|
||||
String substring = folder_no.substring(0, folder_no.lastIndexOf('-'));
|
||||
String update_year_folder_no = maxPieceNoZeroFilling(Integer.parseInt(year_folder_no),folder_no.substring(folder_no.lastIndexOf('-')).length()-1);
|
||||
String update_year_folder_no = maxPieceNoZeroFilling(Integer.parseInt(year_folder_no), folder_no.substring(folder_no.lastIndexOf('-')).length() - 1);
|
||||
|
||||
//最终案卷机档号
|
||||
String update_archive_no = substring + "-" + update_year_folder_no;
|
||||
@@ -2239,21 +2204,21 @@ public class DocSimpleService {
|
||||
piece_no = (String) value;
|
||||
Integer i = Integer.parseInt(piece_no);
|
||||
i = i + offset;
|
||||
if (i<=0){
|
||||
return AjaxJson.returnExceptionInfo("档号:"+archive_no+" 不对");
|
||||
if (i <= 0) {
|
||||
return AjaxJson.returnExceptionInfo("档号:" + archive_no + " 不对");
|
||||
}
|
||||
piece_no = i.toString();
|
||||
} else {
|
||||
Integer folder_no_int = (Integer) value;
|
||||
folder_no_int = folder_no_int + offset;
|
||||
if (folder_no_int<=0){
|
||||
return AjaxJson.returnExceptionInfo("档号:"+archive_no+" 不对");
|
||||
if (folder_no_int <= 0) {
|
||||
return AjaxJson.returnExceptionInfo("档号:" + archive_no + " 不对");
|
||||
}
|
||||
piece_no = folder_no_int.toString();
|
||||
}
|
||||
//修改后的档号
|
||||
String substring = archive_no.substring(0, archive_no.lastIndexOf('-'));
|
||||
String update_piece_no = maxPieceNoZeroFilling(Integer.parseInt(piece_no),archive_no.substring(archive_no.lastIndexOf('-')).length()-1);
|
||||
String update_piece_no = maxPieceNoZeroFilling(Integer.parseInt(piece_no), archive_no.substring(archive_no.lastIndexOf('-')).length() - 1);
|
||||
//最终档号名称
|
||||
String update_archive_no = substring + "-" + update_piece_no;
|
||||
//修改档号
|
||||
@@ -2281,18 +2246,18 @@ public class DocSimpleService {
|
||||
* @param pieceNo
|
||||
* @return 001, 002, 003
|
||||
*/
|
||||
public String maxPieceNoZeroFilling(Integer pieceNo,Integer len) {
|
||||
public String maxPieceNoZeroFilling(Integer pieceNo, Integer len) {
|
||||
//根据原本的长度来设置件号
|
||||
String result = "";
|
||||
if (len==1){
|
||||
result =""+pieceNo;
|
||||
}else if (len==2){
|
||||
if (pieceNo<10){
|
||||
result="0"+pieceNo;
|
||||
}else {
|
||||
result=""+pieceNo;
|
||||
if (len == 1) {
|
||||
result = "" + pieceNo;
|
||||
} else if (len == 2) {
|
||||
if (pieceNo < 10) {
|
||||
result = "0" + pieceNo;
|
||||
} else {
|
||||
result = "" + pieceNo;
|
||||
}
|
||||
}else if (len==3){
|
||||
} else if (len == 3) {
|
||||
if (pieceNo < 10) {
|
||||
result = "00" + pieceNo;
|
||||
} else if (pieceNo < 100 && pieceNo >= 10) {
|
||||
@@ -2300,25 +2265,25 @@ public class DocSimpleService {
|
||||
} else if (pieceNo < 1000 && pieceNo >= 100) {
|
||||
result = "" + pieceNo;
|
||||
}
|
||||
}else if (len==4){
|
||||
} else if (len == 4) {
|
||||
if (pieceNo < 10) {
|
||||
result = "000" + pieceNo;
|
||||
} else if (pieceNo < 100 && pieceNo >= 10) {
|
||||
result = "00" + pieceNo;
|
||||
} else if (pieceNo < 1000 && pieceNo >= 100) {
|
||||
result = "0" + pieceNo;
|
||||
}else {
|
||||
result =""+pieceNo;
|
||||
} else {
|
||||
result = "" + pieceNo;
|
||||
}
|
||||
}else if (len==5){
|
||||
} else if (len == 5) {
|
||||
if (pieceNo < 10) {
|
||||
result = "0000" + pieceNo;
|
||||
} else if (pieceNo < 100 && pieceNo >= 10) {
|
||||
result = "000" + pieceNo;
|
||||
} else if (pieceNo < 1000 && pieceNo >= 100) {
|
||||
result = "00" + pieceNo;
|
||||
}else if (pieceNo < 10000 && pieceNo >= 1000){
|
||||
result ="0"+pieceNo;
|
||||
} else if (pieceNo < 10000 && pieceNo >= 1000) {
|
||||
result = "0" + pieceNo;
|
||||
}
|
||||
}
|
||||
// if (pieceNo < 10) {
|
||||
@@ -2339,24 +2304,24 @@ public class DocSimpleService {
|
||||
Set<Map.Entry> set = conditionMap.entrySet();
|
||||
//获取redis里面的所有值
|
||||
// List<Object> list = redisUtil.lGet("list", 0, -1);
|
||||
Cache<Object,Object> fiveSecondCache = guavaLocalCache.getFiveSecondCache();
|
||||
Cache<Object, Object> fiveSecondCache = guavaLocalCache.getFiveSecondCache();
|
||||
List<Object> list = (List<Object>) fiveSecondCache.getIfPresent("list");
|
||||
List<Object> resultList = new ArrayList<>();
|
||||
if(conditionMap.isEmpty()){
|
||||
if (conditionMap.isEmpty()) {
|
||||
resultList = list;
|
||||
}else{
|
||||
if(CollectionUtils.isNotEmpty(list)){
|
||||
} else {
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
for (Object o : list) {
|
||||
Map<String,Object> map = (Map<String, Object>) o;
|
||||
Map<String, Object> map = (Map<String, Object>) o;
|
||||
int i = 0;
|
||||
for (Map.Entry entry : set) {
|
||||
String key = entry.getKey().toString();
|
||||
String value = entry.getValue().toString();
|
||||
if(map.get(key).toString().contains(value)){
|
||||
if (map.get(key).toString().contains(value)) {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if(i==set.size()){
|
||||
if (i == set.size()) {
|
||||
resultList.add(map);
|
||||
}
|
||||
}
|
||||
@@ -2365,17 +2330,15 @@ public class DocSimpleService {
|
||||
}
|
||||
|
||||
List list1 = PageUtil.startPage(resultList, packSqlObject.getPage(), packSqlObject.getLimit());
|
||||
json.put("list",list1);
|
||||
json.put("total",resultList.size());
|
||||
json.put("list", list1);
|
||||
json.put("total", resultList.size());
|
||||
return json;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//向上移
|
||||
public AjaxJson moveUp(
|
||||
Integer fileId, String funcTypeCode,String tableName
|
||||
) {
|
||||
public AjaxJson moveUp(Integer fileId, String funcTypeCode, String tableName) {
|
||||
AjaxJson json = null;
|
||||
try {
|
||||
tableName = tableName + "_" + funcTypeCode;
|
||||
@@ -2389,15 +2352,15 @@ public class DocSimpleService {
|
||||
json = AjaxJson.returnExceptionInfo("已是最前了");
|
||||
return json;
|
||||
}
|
||||
Integer recId = (Integer)map.get("rec_id");
|
||||
Integer recId = (Integer) map.get("rec_id");
|
||||
String sql1 = "select * from " + tableName + " where rec_id = " + recId + " and page_no < " + pageNo + " order by page_no desc limit 1";
|
||||
|
||||
|
||||
// ArchiveFile archiveFileUpOne = archiveFileService.getArchiveFileUpOne(parasMap);
|
||||
List<Map<String, Object>> list1 = directorySeqMapper.executeSqlList(sql1);
|
||||
Map<String, Object> map1 = list1.get(0);
|
||||
Integer pageNo1 = (Integer)map1.get("page_no");
|
||||
Integer id = (Integer)map1.get("id");
|
||||
Integer pageNo1 = (Integer) map1.get("page_no");
|
||||
Integer id = (Integer) map1.get("id");
|
||||
//1.把数据库和图片都上移动一格(当前选中的一条图片)
|
||||
if (true) {
|
||||
HashMap maps = new HashMap();
|
||||
@@ -2425,9 +2388,7 @@ public class DocSimpleService {
|
||||
|
||||
|
||||
//向下移
|
||||
public AjaxJson moveDown(
|
||||
Integer fileId, String funcTypeCode,String tableName
|
||||
) {
|
||||
public AjaxJson moveDown(Integer fileId, String funcTypeCode, String tableName) {
|
||||
AjaxJson json = null;
|
||||
try {
|
||||
tableName = tableName + "_" + funcTypeCode;
|
||||
@@ -2437,7 +2398,7 @@ public class DocSimpleService {
|
||||
// ArchiveFile archiveFile = archiveFileService.selectByPrimaryKey(fileId);
|
||||
Map<String, Object> map = list.get(0);
|
||||
Integer pageNo = (Integer) map.get("page_no");
|
||||
Integer recId = (Integer)map.get("rec_id");
|
||||
Integer recId = (Integer) map.get("rec_id");
|
||||
String sql2 = "select count(*) as num from " + tableName + " where rec_id = " + recId;
|
||||
List<Map<String, Object>> list2 = directorySeqMapper.executeSqlList(sql2);
|
||||
Map<String, Object> map2 = list2.get(0);
|
||||
@@ -2453,8 +2414,8 @@ public class DocSimpleService {
|
||||
// ArchiveFile archiveFileUpOne = archiveFileService.getArchiveFileUpOne(parasMap);
|
||||
List<Map<String, Object>> list1 = directorySeqMapper.executeSqlList(sql1);
|
||||
Map<String, Object> map1 = list1.get(0);
|
||||
Integer pageNo1 = (Integer)map1.get("page_no");
|
||||
Integer id = (Integer)map1.get("id");
|
||||
Integer pageNo1 = (Integer) map1.get("page_no");
|
||||
Integer id = (Integer) map1.get("id");
|
||||
//1.把数据库和图片都上移动一格(当前选中的一条图片)
|
||||
if (true) {
|
||||
HashMap maps = new HashMap();
|
||||
@@ -2481,17 +2442,14 @@ public class DocSimpleService {
|
||||
}
|
||||
|
||||
|
||||
|
||||
//重命名
|
||||
public AjaxJson rename(
|
||||
Integer fileId, String funcTypeCode,String tableName,String name
|
||||
) {
|
||||
public AjaxJson rename(Integer fileId, String funcTypeCode, String tableName, String name) {
|
||||
AjaxJson json = null;
|
||||
try {
|
||||
tableName = tableName + "_" + funcTypeCode;
|
||||
HashMap maps = new HashMap();
|
||||
maps.put("tableName", tableName);
|
||||
maps.put("fieldValue", " file_name = " + "'" +name+"'");
|
||||
maps.put("fieldValue", " file_name = " + "'" + name + "'");
|
||||
maps.put("conditionSql", " id = " + fileId);
|
||||
docSimpleMapper.updateObject(maps);
|
||||
|
||||
@@ -2575,7 +2533,7 @@ public class DocSimpleService {
|
||||
if (CollectionUtils.isNotEmpty(archives)) {
|
||||
for (Map<String, Object> archive : archives) {
|
||||
int filingYear = 0;
|
||||
if (archive.get("filing_year") != null&&ToolSelf.isNumeric(archive.get("filing_year").toString())) {
|
||||
if (archive.get("filing_year") != null && ToolSelf.isNumeric(archive.get("filing_year").toString())) {
|
||||
filingYear = Integer.parseInt(archive.get("filing_year").toString());
|
||||
}
|
||||
String retention = "";
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.point.strategy.user.bean.UserRole;
|
||||
import com.point.strategy.user.service.UserService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.http.HttpStatus;
|
||||
@@ -43,6 +44,9 @@ import java.math.BigDecimal;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.sql.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
@@ -60,6 +64,7 @@ import static com.point.strategy.oaDocking.util.FileUtils.unzip;
|
||||
@RestController
|
||||
@RequestMapping("/v/archives")
|
||||
@Api(tags = "OA对接")
|
||||
@Slf4j
|
||||
public class ArchivesUploadController {
|
||||
|
||||
//本地路径
|
||||
@@ -92,21 +97,150 @@ public class ArchivesUploadController {
|
||||
@Autowired
|
||||
private OperLoggerService operLoggerService;
|
||||
|
||||
// ===== 以下为提取的私有工具方法(仅在本类内复用) =====
|
||||
|
||||
/**
|
||||
* 空安全字符串
|
||||
*/
|
||||
private static String nvl(String s) {
|
||||
return s == null ? "" : s;
|
||||
}
|
||||
|
||||
/**
|
||||
* 安全获取文件扩展名(小写,无扩展名返回空串)
|
||||
*/
|
||||
private static String safeExt(String fileName) {
|
||||
if (StringUtils.isBlank(fileName)) return "";
|
||||
int lastSlash = Math.max(fileName.lastIndexOf('/'), fileName.lastIndexOf('\\'));
|
||||
String base = lastSlash >= 0 ? fileName.substring(lastSlash + 1) : fileName;
|
||||
int idx = base.lastIndexOf('.');
|
||||
if (idx <= 0 || idx == base.length() - 1) return "";
|
||||
return base.substring(idx + 1).toLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* 统一构建并确保目录存在
|
||||
*/
|
||||
private Path ensureDir(String... parts) throws IOException {
|
||||
Path p = Paths.get(parts[0], Arrays.copyOfRange(parts, 1, parts.length));
|
||||
Files.createDirectories(p);
|
||||
return p;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将二进制流落盘
|
||||
*/
|
||||
private void writeStreamToFile(InputStream in, Path target) throws IOException {
|
||||
byte[] buffer = new byte[8192];
|
||||
try (InputStream src = in; FileOutputStream out = new FileOutputStream(target.toFile())) {
|
||||
int len;
|
||||
while ((len = src.read(buffer)) != -1) {
|
||||
out.write(buffer, 0, len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 基于中文类型描述推断页码(公文用)
|
||||
*/
|
||||
private int inferPageNo(String fileTypeLabel) {
|
||||
String t = nvl(fileTypeLabel);
|
||||
if (t.contains("正文")) return 1;
|
||||
if (t.contains("处理签")) return 2;
|
||||
if (t.contains("底稿") || t.contains("稿纸")) return 3;
|
||||
if (t.contains("其他")) return 4;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 写入文件表记录(最小侵入,仍复用 DanganguanliService 动态SQL)
|
||||
*/
|
||||
private void insertFileRecord(String fileTableName, int recId, String fileName, String fileNameServer, String filePath, String type, int pageNo, String dir) {
|
||||
String fieldNameFile = "rec_id, file_name, file_name_server, file_path, file_type, page_no, file_des, file_status";
|
||||
String valueNameFile = recId + "," +
|
||||
"'" + fileName + "'," +
|
||||
"'" + fileNameServer + "'," +
|
||||
"'" + filePath + "'," +
|
||||
"'" + type + "'," +
|
||||
pageNo + "," +
|
||||
"'" + dir + "'," +
|
||||
"1";
|
||||
Map<String, Object> mapFile = new HashMap<>();
|
||||
mapFile.put("tableName", fileTableName);
|
||||
mapFile.put("fieldName", fieldNameFile);
|
||||
mapFile.put("valueName", valueNameFile);
|
||||
danganguanliService.saveObject(mapFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* 目标库幂等检查:判断某记录是否已存在
|
||||
*/
|
||||
private boolean existsInTemp(String tempTableName, String whereSql) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("tableName", tempTableName);
|
||||
map.put("conditionSql", whereSql);
|
||||
Integer cnt = danganguanliService.selectObjectCount(map);
|
||||
return cnt != null && cnt > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 目标库查询单条ID(便于复用已有记录追加文件)
|
||||
*/
|
||||
private Integer findSingleId(String tempTableName, String whereSql) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("tableName", tempTableName);
|
||||
map.put("conditionSql", whereSql);
|
||||
List<Map<String, Object>> list = danganguanliService.selectObject(map);
|
||||
if (CollectionUtils.isNotEmpty(list) && list.get(0).get("id") != null) {
|
||||
return Integer.parseInt(String.valueOf(list.get(0).get("id")));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* XML 文本内容转义
|
||||
*/
|
||||
private static String xmlEscape(String s) {
|
||||
if (s == null) return "";
|
||||
return s.replace("&", "&")
|
||||
.replace("<", "<")
|
||||
.replace(">", ">")
|
||||
.replace("\"", """)
|
||||
.replace("'", "'");
|
||||
}
|
||||
|
||||
@RequestMapping(value="/documentDocking" , method= RequestMethod.POST)
|
||||
@ApiOperation(value = "公文系统对接")
|
||||
public AjaxJson documentDocking() {
|
||||
AjaxJson json = new AjaxJson();
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("[DOC] 公文对接开始, archiveXMLGenerate={}, uploadPath={}", archiveXMLGenerate, uploadPath);
|
||||
}
|
||||
//查询公文系统未归档数据 limit 10
|
||||
String sql = " select * from v_ez_zhengshifawen where ARCHIVING_STATUS = 0 ";
|
||||
ResultSet resultSet = null;
|
||||
ResultSet resultSetFile = null;
|
||||
ResultSet resultSetDisposal = null;
|
||||
ResultSet resultSetCount = null;
|
||||
int j = 0;
|
||||
int totalPending = 0;
|
||||
String doc_no = "";
|
||||
try {
|
||||
// 统计待处理条数
|
||||
String countSql = "select count(1) as CNT from v_ez_zhengshifawen where ARCHIVING_STATUS = 0";
|
||||
resultSetCount = YcjSystemIntegration.executeQuery(countSql);
|
||||
if (resultSetCount.next()) {
|
||||
totalPending = resultSetCount.getInt("CNT");
|
||||
}
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("[DOC] 待处理条数 totalPending={}", totalPending);
|
||||
}
|
||||
String tableName = "jhws_2016_20241228144818";
|
||||
String tempTableName = tableName + "_temp";
|
||||
String fileTableName = tableName + "_temp_file";
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("[DOC] 执行源库查询: {}", sql);
|
||||
}
|
||||
resultSet = YcjSystemIntegration.executeQuery(sql);
|
||||
//把数据添加到简化表中
|
||||
String fieldName = "jigouwenti,created_date,filing_year,retention,archive_ctg_code,doc_no,fonds_no,maintitle,responsibleby,archive_flag,batch_id";
|
||||
@@ -123,90 +257,72 @@ public class ArchivesUploadController {
|
||||
if(wenyin_time!=null){
|
||||
created_date = sdf.format(wenyin_time);
|
||||
}
|
||||
String cw_danwei = resultSet.getString("cw_danwei");
|
||||
if(cw_danwei == null){
|
||||
cw_danwei = "";
|
||||
}
|
||||
String zhonglei = resultSet.getString("zhonglei");
|
||||
if(zhonglei == null){
|
||||
zhonglei = "";
|
||||
}
|
||||
String zhusongdangwei = resultSet.getString("zhusongdanwei");
|
||||
if(zhusongdangwei == null){
|
||||
zhusongdangwei = "";
|
||||
}
|
||||
String zhenwen = resultSet.getString("zhenwen");
|
||||
if(zhenwen == null){
|
||||
zhenwen = "";
|
||||
}
|
||||
String zhutici = resultSet.getString("zhutici");
|
||||
if(zhutici == null){
|
||||
zhutici = "";
|
||||
}
|
||||
String chaosongdanwei = resultSet.getString("chaosongdanwei");
|
||||
if(chaosongdanwei == null){
|
||||
chaosongdanwei = "";
|
||||
}
|
||||
String jiaoxiao = resultSet.getString("jiaoxiao");
|
||||
if(jiaoxiao == null){
|
||||
jiaoxiao = "";
|
||||
}
|
||||
String beizhu = resultSet.getString("beizhu");
|
||||
if(beizhu == null){
|
||||
beizhu = "";
|
||||
}
|
||||
String miji = resultSet.getString("miji");
|
||||
if(miji == null){
|
||||
miji = "";
|
||||
}
|
||||
String cw_danwei = nvl(resultSet.getString("cw_danwei"));
|
||||
String zhonglei = nvl(resultSet.getString("zhonglei"));
|
||||
String zhusongdangwei = nvl(resultSet.getString("zhusongdanwei"));
|
||||
String zhenwen = nvl(resultSet.getString("zhenwen"));
|
||||
String zhutici = nvl(resultSet.getString("zhutici"));
|
||||
String chaosongdanwei = nvl(resultSet.getString("chaosongdanwei"));
|
||||
String jiaoxiao = nvl(resultSet.getString("jiaoxiao"));
|
||||
String beizhu = nvl(resultSet.getString("beizhu"));
|
||||
String miji = nvl(resultSet.getString("miji"));
|
||||
int nianhao = resultSet.getInt("nianhao");
|
||||
String filing_year = "";
|
||||
if(nianhao != 0){
|
||||
filing_year = String.valueOf(nianhao);
|
||||
}
|
||||
String retention = resultSet.getString("qixian");
|
||||
if(retention == null){
|
||||
retention = "";
|
||||
}
|
||||
String jigouwenti = resultSet.getString("fenlei");
|
||||
if(jigouwenti == null){
|
||||
jigouwenti = "";
|
||||
}
|
||||
String fonds_no = resultSet.getString("FONDS_NO");
|
||||
if(fonds_no == null){
|
||||
fonds_no = "";
|
||||
}
|
||||
String retention = nvl(resultSet.getString("qixian"));
|
||||
String jigouwenti = nvl(resultSet.getString("fenlei"));
|
||||
String fonds_no = nvl(resultSet.getString("FONDS_NO"));
|
||||
fonds_no = "0240";
|
||||
int indexComment = resultSet.getInt("INDEX_COMMENT");
|
||||
doc_no = resultSet.getString("WENHAO");
|
||||
if(doc_no == null){
|
||||
doc_no = "";
|
||||
}
|
||||
doc_no = nvl(resultSet.getString("WENHAO"));
|
||||
String maintitle = resultSet.getString("BIAOTI");
|
||||
String ARCHIVING_DATE = resultSet.getString("ARCHIVING_DATE");
|
||||
String responsibleby = resultSet.getString("RESPONSIBLEBY");
|
||||
valueName = "'" + jigouwenti + "'," + "'" + created_date + "'," + "'" + filing_year + "'," + "'" + retention + "'," + "'" + archive_ctg_code + "'," + "'" + doc_no + "'," + "'" + fonds_no + "'," + "'" + maintitle + "'," + "'" + responsibleby + "',"+ "'预归档未完成'" + "," + indexComment;
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("[DOC] 处理记录 indexComment={}, doc_no={}, title={}", indexComment, doc_no, maintitle);
|
||||
}
|
||||
|
||||
// 幂等:优先检查是否已存在相同 doc_no + batch_id 记录
|
||||
Integer jhId;
|
||||
String whereSql = " 1=1 and doc_no='" + doc_no + "' and batch_id='" + indexComment + "' ";
|
||||
if (existsInTemp(tempTableName, whereSql)) {
|
||||
jhId = findSingleId(tempTableName, whereSql);
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("[DOC] 命中幂等: 复用已有记录 id={}, where={}", jhId, whereSql);
|
||||
}
|
||||
} else {
|
||||
Map<String, Object> mapTwo = new HashMap<String, Object>();
|
||||
mapTwo.put("tableName", tempTableName);
|
||||
//其实我们知道是哪些字段
|
||||
mapTwo.put("fieldName", fieldName);
|
||||
mapTwo.put("valueName", valueName);
|
||||
danganguanliService.saveObject(mapTwo);
|
||||
int jhId = Integer.parseInt(mapTwo.get("id").toString());
|
||||
jhId = Integer.parseInt(mapTwo.get("id").toString());
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("[DOC] 新增主表记录 id={} (temp={})", jhId, tempTableName);
|
||||
}
|
||||
}
|
||||
|
||||
String filePath = "uploadFile/" + fileTableName + "/" + jhId;
|
||||
String dir = uploadPath + filePath;
|
||||
Path dirPath = ensureDir(uploadPath, filePath);
|
||||
String dir = dirPath.toString();
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("[DOC] 目标目录: {}", dir);
|
||||
}
|
||||
//是否生成归档xml
|
||||
if(archiveXMLGenerate){
|
||||
String head = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
|
||||
String xml = " <目录>" +
|
||||
" <成文单位>" + cw_danwei + "</成文单位>" +
|
||||
" <种类>" + zhonglei + "</种类>" +
|
||||
" <文号>" + doc_no + "</文号>" +
|
||||
" <标题>" + maintitle + "</标题>" +
|
||||
" <主送单位>" + zhusongdangwei + "</主送单位>" +
|
||||
" <正文>" + zhenwen + "</正文>" +
|
||||
" <主题词>" + zhutici + "</主题词>" +
|
||||
" <抄送单位>" + chaosongdanwei + "</抄送单位>" +
|
||||
" <成文单位>" + xmlEscape(cw_danwei) + "</成文单位>" +
|
||||
" <种类>" + xmlEscape(zhonglei) + "</种类>" +
|
||||
" <文号>" + xmlEscape(doc_no) + "</文号>" +
|
||||
" <标题>" + xmlEscape(maintitle) + "</标题>" +
|
||||
" <主送单位>" + xmlEscape(zhusongdangwei) + "</主送单位>" +
|
||||
" <正文>" + xmlEscape(zhenwen) + "</正文>" +
|
||||
" <主题词>" + xmlEscape(zhutici) + "</主题词>" +
|
||||
" <抄送单位>" + xmlEscape(chaosongdanwei) + "</抄送单位>" +
|
||||
" <文印日期>" + created_date + "</文印日期>" +
|
||||
" <份数>" + "</份数>" +
|
||||
" <档案签收>" + "</档案签收>" +
|
||||
@@ -224,9 +340,9 @@ public class ArchivesUploadController {
|
||||
" <文件唯一号>" + "</文件唯一号>" +
|
||||
" <件标示>" + "</件标示>" +
|
||||
" <件内序号>" + "</件内序号>" +
|
||||
" <缴销>" + jiaoxiao + "</缴销>" +
|
||||
" <备注>" + beizhu + "</备注>" +
|
||||
" <密级>" + miji + "</密级>" +
|
||||
" <缴销>" + xmlEscape(jiaoxiao) + "</缴销>" +
|
||||
" <备注>" + xmlEscape(beizhu) + "</备注>" +
|
||||
" <密级>" + xmlEscape(miji) + "</密级>" +
|
||||
" <文件类型>" + "</文件类型>" +
|
||||
" <文件编号>" + "</文件编号>" +
|
||||
" <签发人>" + "</签发人>" +
|
||||
@@ -243,43 +359,24 @@ public class ArchivesUploadController {
|
||||
" <缓急度>" + "</缓急度>" +
|
||||
" <标准文号>" + "</标准文号>" +
|
||||
" <文件分类>" + "</文件分类>" +
|
||||
" <全宗号>" + fonds_no + "</全宗号>" +
|
||||
" <全宗号>" + xmlEscape(fonds_no) + "</全宗号>" +
|
||||
" <归档状态>" + "</归档状态>" +
|
||||
" <归档时间>" + ARCHIVING_DATE + "</归档时间>" +
|
||||
" <责任者>" + responsibleby + "</责任者>" +
|
||||
" <责任者>" + xmlEscape(responsibleby) + "</责任者>" +
|
||||
" </目录>";
|
||||
String content = head + xml;
|
||||
String newContent = FileTool.formatXml(content);
|
||||
FileUtil2.makedir(dir);
|
||||
FileTool.write(newContent, dir + "/" + indexComment + ".xml");
|
||||
FileTool.write(newContent, dirPath.resolve(indexComment + ".xml").toString());
|
||||
String fileName = indexComment + ".xml";
|
||||
String fileNameServer = indexComment + ".xml";
|
||||
String type = "xml";
|
||||
//把文件数据添加到file表中
|
||||
String fieldNameFile =
|
||||
"rec_id, " +
|
||||
"file_name, " +
|
||||
"file_name_server, " +
|
||||
"file_path, " +
|
||||
"file_type," +
|
||||
"page_no," +
|
||||
"file_des," +
|
||||
"file_status";
|
||||
String valueNameFile =
|
||||
"" + jhId + "," +
|
||||
"'" + fileName+ "'," +
|
||||
"'" + fileNameServer+ "'," +
|
||||
"'" + filePath + "'," +
|
||||
"'" + type + "'," +
|
||||
1 + "," +
|
||||
"'" + dir + "'," +
|
||||
"1";
|
||||
Map<String, Object> mapFile = new HashMap<String, Object>();
|
||||
mapFile.put("tableName", fileTableName);
|
||||
//其实我们知道是哪些字段
|
||||
mapFile.put("fieldName", fieldNameFile);
|
||||
mapFile.put("valueName", valueNameFile);
|
||||
danganguanliService.saveObject(mapFile);
|
||||
insertFileRecord(fileTableName, jhId, fileName, fileNameServer, filePath, type, 1, dir);
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("[CONTRACT] 生成XML文件并登记: {}", dirPath.resolve(fileName));
|
||||
}
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("[DOC] 生成XML文件并登记: {}", dirPath.resolve(fileName));
|
||||
}
|
||||
|
||||
}
|
||||
//查询公文文件表
|
||||
@@ -287,77 +384,38 @@ public class ArchivesUploadController {
|
||||
resultSetFile = YcjSystemIntegration.executeQuery(sqlFile);
|
||||
while (resultSetFile.next()) {
|
||||
String fileName = resultSetFile.getString("file_path");
|
||||
// String[] split = file_path.split("/");
|
||||
// String fileName = split[split.length-1];
|
||||
// String[] split = file_path.split("/");
|
||||
// String fileName = split[split.length-1];
|
||||
String file_type = resultSetFile.getString("file_type");
|
||||
InputStream binaryStream = resultSetFile.getBinaryStream("sound_image");
|
||||
String myuuid = StringUtil.generaterUUID();
|
||||
String fileNameServer =myuuid + fileName;
|
||||
File fileOne = new File(dir);
|
||||
if (!fileOne.exists()) {
|
||||
fileOne.mkdirs();
|
||||
}
|
||||
String fileUrl = dir+"/"+fileNameServer;
|
||||
Path target = dirPath.resolve(fileNameServer);
|
||||
if(binaryStream != null){
|
||||
try (FileOutputStream outputStream = new FileOutputStream(fileUrl)) { // 输出到文件
|
||||
byte[] buffer = new byte[1024]; // 缓冲区大小可以根据需要调整
|
||||
int bytesRead;
|
||||
while ((bytesRead = binaryStream.read(buffer)) != -1) {
|
||||
outputStream.write(buffer, 0, bytesRead);
|
||||
try {
|
||||
writeStreamToFile(binaryStream, target);
|
||||
String type = safeExt(fileName);
|
||||
int pageNo = inferPageNo(nvl(file_type));
|
||||
// 避免重复文件记录:以rec_id+file_name去重
|
||||
if (!existsInTemp(fileTableName, " rec_id='" + jhId + "' and file_name='" + fileName + "' ")) {
|
||||
insertFileRecord(fileTableName, jhId, fileName, fileNameServer, filePath, type, pageNo == 0 ? 1 : pageNo, dir);
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("[DOC] 保存附件: fileName={}, serverName={}, type={}, pageNo={}, path={}",
|
||||
fileName, fileNameServer, type, (pageNo == 0 ? 1 : pageNo), target);
|
||||
}
|
||||
int i = 1;
|
||||
String[] strings = fileName.split("\\.");
|
||||
String type = strings[strings.length - 1].toLowerCase();
|
||||
int pageNo = 0;
|
||||
if(file_type.contains("正文")){
|
||||
pageNo = 1;
|
||||
} else if (log.isDebugEnabled()) {
|
||||
log.debug("[DOC] 跳过重复附件登记: rec_id={}, fileName={}", jhId, fileName);
|
||||
}
|
||||
if(file_type.contains("处理签")){
|
||||
pageNo = 2;
|
||||
}
|
||||
if(file_type.contains("底稿")){
|
||||
pageNo = 3;
|
||||
}
|
||||
if(file_type.contains("其他")){
|
||||
pageNo = 4;
|
||||
}
|
||||
//把文件数据添加到file表中
|
||||
String fieldNameFile =
|
||||
"rec_id, " +
|
||||
"file_name, " +
|
||||
"file_name_server, " +
|
||||
"file_path, " +
|
||||
"file_type," +
|
||||
|
||||
"page_no," +
|
||||
"file_des," +
|
||||
"file_status";
|
||||
String valueNameFile =
|
||||
"" + jhId + "," +
|
||||
"'" + fileName+ "'," +
|
||||
"'" + fileNameServer+ "'," +
|
||||
"'" + filePath + "'," +
|
||||
"'" + type + "'," +
|
||||
|
||||
i + "," +
|
||||
"'" + dir + "'," +
|
||||
"1";
|
||||
Map<String, Object> mapFile = new HashMap<String, Object>();
|
||||
mapFile.put("tableName", fileTableName);
|
||||
//其实我们知道是哪些字段
|
||||
mapFile.put("fieldName", fieldNameFile);
|
||||
mapFile.put("valueName", valueNameFile);
|
||||
danganguanliService.saveObject(mapFile);
|
||||
if(type.equalsIgnoreCase("jpg")||type.equalsIgnoreCase("png") || type.equalsIgnoreCase("pdf") ){
|
||||
//生成一份pdf文件,用于归档章的操作
|
||||
String newName_pdf=fileNameServer.replace("."+type,".pdf");
|
||||
PdfFileHelper.image2Pdf(dir+File.separator+fileNameServer,dir+File.separator+newName_pdf);
|
||||
PdfFileHelper.image2Pdf(dirPath.resolve(fileNameServer).toString(),dirPath.resolve(newName_pdf).toString());
|
||||
|
||||
String newName_pdf_original=newName_pdf.replace(".pdf","_original.pdf");
|
||||
FileTool.copyFile(dir+File.separator+newName_pdf,dir+File.separator+newName_pdf_original);
|
||||
FileTool.copyFile(dirPath.resolve(newName_pdf).toString(),dirPath.resolve(newName_pdf_original).toString());
|
||||
}
|
||||
i++;
|
||||
} catch (IOException e) {
|
||||
log.error("[DOC] 保存附件失败 indexComment={}, fileName={}", indexComment, fileName, e);
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
binaryStream.close(); // 关闭流很重要,避免资源泄露
|
||||
@@ -390,12 +448,18 @@ public class ArchivesUploadController {
|
||||
//最后更新归档状态
|
||||
String updateSql = "update v_ez_zhengshifawen set ARCHIVING_STATUS = 1 where index_comment = " + indexComment;
|
||||
YcjSystemIntegration.executeUpdate(updateSql);
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("[DOC] 回写源库归档状态成功 indexComment={}", indexComment);
|
||||
}
|
||||
j++;
|
||||
//添加日志
|
||||
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
User user = null;
|
||||
if (servletRequestAttributes != null) {
|
||||
HttpServletRequest request = servletRequestAttributes.getRequest();
|
||||
UserRole userRole = userService.getUserRole(request);
|
||||
User user= userRole.getUser();
|
||||
if (userRole != null) user = userRole.getUser();
|
||||
}
|
||||
if (user != null) {
|
||||
//记录日志
|
||||
java.util.Date date = new Date();
|
||||
@@ -409,13 +473,18 @@ public class ArchivesUploadController {
|
||||
operLoggerService.addEntity(entity);
|
||||
}
|
||||
}
|
||||
if (log.isInfoEnabled()) log.info("[DOC] 公文对接完成, 待处理条数={}, 成功处理条数={}", totalPending, j);
|
||||
json = AjaxJson.returnInfo("成功接收" + j + "条");
|
||||
} catch (Exception e) {
|
||||
log.error("[DOC] 公文对接失败 doc_no={}", doc_no, e);
|
||||
//添加日志
|
||||
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
User user = null;
|
||||
if (servletRequestAttributes != null) {
|
||||
HttpServletRequest request = servletRequestAttributes.getRequest();
|
||||
UserRole userRole = userService.getUserRole(request);
|
||||
User user= userRole.getUser();
|
||||
if (userRole != null) user = userRole.getUser();
|
||||
}
|
||||
if (user != null) {
|
||||
//记录日志
|
||||
java.util.Date date = new Date();
|
||||
@@ -433,6 +502,7 @@ public class ArchivesUploadController {
|
||||
YcjSystemIntegration.closeResources(null, null, resultSet);
|
||||
YcjSystemIntegration.closeResources(null, null, resultSetFile);
|
||||
YcjSystemIntegration.closeResources(null, null, resultSetDisposal);
|
||||
YcjSystemIntegration.closeResources(null, null, resultSetCount);
|
||||
}
|
||||
|
||||
return json;
|
||||
@@ -443,19 +513,36 @@ public class ArchivesUploadController {
|
||||
@ApiOperation(value = "合同系统对接")
|
||||
public AjaxJson contractDocking() {
|
||||
AjaxJson json = new AjaxJson();
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("[CONTRACT] 合同对接开始, archiveXMLGenerate={}, uploadPath={}", archiveXMLGenerate, uploadPath);
|
||||
}
|
||||
//查询公文系统未归档数据 limit 10
|
||||
String sql = " select * from v_ez_contract where ARCHIVING_STATUS = 0 ";
|
||||
ResultSet resultSet = null;
|
||||
ResultSet resultSetFile = null;
|
||||
ResultSet resultSetDisposal = null;
|
||||
ResultSet resultSetCount = null;
|
||||
int j = 0;
|
||||
int totalPending = 0;
|
||||
String cont_no = "";
|
||||
try {
|
||||
// 统计待处理条数
|
||||
String countSql = "select count(1) as CNT from v_ez_contract where ARCHIVING_STATUS = 0";
|
||||
resultSetCount = YcjSystemIntegration.executeQuery(countSql);
|
||||
if (resultSetCount.next()) {
|
||||
totalPending = resultSetCount.getInt("CNT");
|
||||
}
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("[CONTRACT] 待处理条数 totalPending={}", totalPending);
|
||||
}
|
||||
//鄂州合同档案表
|
||||
String tableName = "ht_table_20250403105425";
|
||||
// String tableName = "ht_table_20250403110716";
|
||||
String tempTableName = tableName + "_temp";
|
||||
String fileTableName = tableName + "_temp_file";
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("[CONTRACT] 执行源库查询: {}", sql);
|
||||
}
|
||||
resultSet = YcjSystemIntegration.executeQuery(sql);
|
||||
//把数据添加到简化表中
|
||||
String fieldName = "cont_no,cont_name,cont_org_name,cont_type,cont_amount_type,cont_amount,cont_amt_description,cont_signing_date,cont_start_date,cont_end_date,cont_cooperate_name,cont_business_license,cont_registration_authority,cont_corp_type,cont_business_range,cont_registered_capital,cont_founted,cont_corp_address,cont_legal_representative,cont_contact_phone,cont_open_bank,cont_bank_amount,fonds_no,retention,archive_ctg_no,created_date,maintitle,responsibleby,archive_flag,batch_id";
|
||||
@@ -597,81 +684,75 @@ public class ArchivesUploadController {
|
||||
responsibleby = "";
|
||||
}
|
||||
valueName = "'" + cont_no + "'," + "'" + cont_name + "'," + "'" + cont_org_name + "'," + "'" + cont_type + "'," + "'" + cont_amount_type + "'," + "'" + cont_amount + "'," + "'" + cont_amt_description + "'," + "'" + cont_signing_date + "'," + "'" + cont_start_date + "'," + "'" + cont_end_date + "'," + "'" + cont_cooperate_name + "'," + "'" + cont_business_license + "'," + "'" + cont_registration_authority + "'," + "'" + cont_corp_type + "'," + "'" + cont_business_range + "'," + "'" + cont_registered_capital + "'," + "'" + cont_founted + "'," + "'" + cont_corp_address + "'," + "'" + cont_legal_representative + "'," + "'" + cont_contact_phone + "'," + "'" + cont_open_bank + "'," + "'" + cont_bank_amount + "'," + "'" + fonds_no + "'," + "'" + retention + "'," + "'" + archive_ctg_no + "'," + "'" + created_date + "'," + "'" + maintitle + "'," + "'" + responsibleby + "',"+ "'预归档未完成'" + "," + indexComment;
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("[CONTRACT] 处理记录 rowId={}, cont_no={}, name={}", indexComment, cont_no, maintitle);
|
||||
}
|
||||
// 幂等:优先检查 cont_no + batch_id
|
||||
Integer jhId;
|
||||
String whereSql = " 1=1 and cont_no='" + cont_no + "' and batch_id='" + indexComment + "' ";
|
||||
if (existsInTemp(tempTableName, whereSql)) {
|
||||
jhId = findSingleId(tempTableName, whereSql);
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("[CONTRACT] 命中幂等: 复用已有记录 id={}, where={}", jhId, whereSql);
|
||||
}
|
||||
} else {
|
||||
Map<String, Object> mapTwo = new HashMap<String, Object>();
|
||||
mapTwo.put("tableName", tempTableName);
|
||||
//其实我们知道是哪些字段
|
||||
mapTwo.put("fieldName", fieldName);
|
||||
mapTwo.put("valueName", valueName);
|
||||
danganguanliService.saveObject(mapTwo);
|
||||
int jhId = Integer.parseInt(mapTwo.get("id").toString());
|
||||
jhId = Integer.parseInt(mapTwo.get("id").toString());
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("[CONTRACT] 新增主表记录 id={} (temp={})", jhId, tempTableName);
|
||||
}
|
||||
}
|
||||
String filePath = "uploadFile/" + fileTableName + "/" + jhId;
|
||||
String dir = uploadPath + filePath;
|
||||
Path dirPath = ensureDir(uploadPath, filePath);
|
||||
String dir = dirPath.toString();
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("[CONTRACT] 目标目录: {}", dir);
|
||||
}
|
||||
//是否生成归档xml
|
||||
if(archiveXMLGenerate){
|
||||
String head = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
|
||||
String xml = " <目录>" +
|
||||
" <自增行号>" + indexComment + "</自增行号>" +
|
||||
" <合同编号>" + cont_no + "</合同编号>" +
|
||||
" <合同名称>" + cont_name + "</合同名称>" +
|
||||
" <甲方>" + cont_org_name + "</甲方>" +
|
||||
" <合同类型>" + cont_type + "</合同类型>" +
|
||||
" <金额类别>" + cont_amount_type + "</金额类别>" +
|
||||
" <合同金额>" + cont_amount + "</合同金额>" +
|
||||
" <合同标的额备注>" + cont_amt_description + "</合同标的额备注>" +
|
||||
" <合同编号>" + xmlEscape(cont_no) + "</合同编号>" +
|
||||
" <合同名称>" + xmlEscape(cont_name) + "</合同名称>" +
|
||||
" <甲方>" + xmlEscape(cont_org_name) + "</甲方>" +
|
||||
" <合同类型>" + xmlEscape(cont_type) + "</合同类型>" +
|
||||
" <金额类别>" + xmlEscape(cont_amount_type) + "</金额类别>" +
|
||||
" <合同金额>" + xmlEscape(cont_amount) + "</合同金额>" +
|
||||
" <合同标的额备注>" + xmlEscape(cont_amt_description) + "</合同标的额备注>" +
|
||||
" <签订日期>" + cont_signing_date + "</签订日期>" +
|
||||
" <合同履约起日期>" + cont_start_date + "</合同履约起日期>" +
|
||||
" <合同履约止日期>" + cont_end_date + "</合同履约止日期>" +
|
||||
" <合作方单位名称>" + cont_cooperate_name + "</合作方单位名称>" +
|
||||
" <营业执照号>" + cont_business_license + "</营业执照号>" +
|
||||
" <登记机关>" + cont_registration_authority + "</登记机关>" +
|
||||
" <企业类型>" + cont_corp_type + "</企业类型>" +
|
||||
" <经营范围>" + cont_business_range + "</经营范围>" +
|
||||
" <注册资金>" + cont_registered_capital + "</注册资金>" +
|
||||
" <成立时间>" + cont_founted + "</成立时间>" +
|
||||
" <企业地址>" + cont_corp_address + "</企业地址>" +
|
||||
" <法人代表>" + cont_legal_representative + "</法人代表>" +
|
||||
" <法人联系电话>" + cont_contact_phone + "</法人联系电话>" +
|
||||
" <企业账号开户银行>" + cont_open_bank + "</企业账号开户银行>" +
|
||||
" <银行账号>" + cont_bank_amount + "</银行账号>" +
|
||||
" <保管期限>" + retention + "</保管期限>" +
|
||||
" <归档分类>" + archive_ctg_no + "</归档分类>" +
|
||||
" <责任者>" + responsibleby + "</责任者>" +
|
||||
" <全宗号>" + fonds_no + "</全宗号>" +
|
||||
" <合作方单位名称>" + xmlEscape(cont_cooperate_name) + "</合作方单位名称>" +
|
||||
" <营业执照号>" + xmlEscape(cont_business_license) + "</营业执照号>" +
|
||||
" <登记机关>" + xmlEscape(cont_registration_authority) + "</登记机关>" +
|
||||
" <企业类型>" + xmlEscape(cont_corp_type) + "</企业类型>" +
|
||||
" <经营范围>" + xmlEscape(cont_business_range) + "</经营范围>" +
|
||||
" <注册资金>" + xmlEscape(cont_registered_capital) + "</注册资金>" +
|
||||
" <成立时间>" + xmlEscape(cont_founted) + "</成立时间>" +
|
||||
" <企业地址>" + xmlEscape(cont_corp_address) + "</企业地址>" +
|
||||
" <法人代表>" + xmlEscape(cont_legal_representative) + "</法人代表>" +
|
||||
" <法人联系电话>" + xmlEscape(cont_contact_phone) + "</法人联系电话>" +
|
||||
" <企业账号开户银行>" + xmlEscape(cont_open_bank) + "</企业账号开户银行>" +
|
||||
" <银行账号>" + xmlEscape(cont_bank_amount) + "</银行账号>" +
|
||||
" <保管期限>" + xmlEscape(retention) + "</保管期限>" +
|
||||
" <归档分类>" + xmlEscape(archive_ctg_no) + "</归档分类>" +
|
||||
" <责任者>" + xmlEscape(responsibleby) + "</责任者>" +
|
||||
" <全宗号>" + xmlEscape(fonds_no) + "</全宗号>" +
|
||||
" <归档状态>" + "已归档" + "</归档状态>" +
|
||||
" <归档时间>" + created_date + "</归档时间>" +
|
||||
" </目录>";
|
||||
String content = head + xml;
|
||||
String newContent = FileTool.formatXml(content);
|
||||
FileUtil2.makedir(dir);
|
||||
FileTool.write(newContent, dir + "/" + indexComment + ".xml");
|
||||
FileTool.write(newContent, dirPath.resolve(indexComment + ".xml").toString());
|
||||
String fileName = indexComment + ".xml";
|
||||
String fileNameServer = indexComment + ".xml";
|
||||
String type = "xml";
|
||||
//把文件数据添加到file表中
|
||||
String fieldNameFile =
|
||||
"rec_id, " +
|
||||
"file_name, " +
|
||||
"file_name_server, " +
|
||||
"file_path, " +
|
||||
"file_type," +
|
||||
"page_no," +
|
||||
"file_des," +
|
||||
"file_status";
|
||||
String valueNameFile =
|
||||
"" + jhId + "," +
|
||||
"'" + fileName+ "'," +
|
||||
"'" + fileNameServer+ "'," +
|
||||
"'" + filePath + "'," +
|
||||
"'" + type + "'," +
|
||||
1 + "," +
|
||||
"'" + dir + "'," +
|
||||
"1";
|
||||
Map<String, Object> mapFile = new HashMap<String, Object>();
|
||||
mapFile.put("tableName", fileTableName);
|
||||
//其实我们知道是哪些字段
|
||||
mapFile.put("fieldName", fieldNameFile);
|
||||
mapFile.put("valueName", valueNameFile);
|
||||
danganguanliService.saveObject(mapFile);
|
||||
insertFileRecord(fileTableName, jhId, fileName, fileNameServer, filePath, type, 1, dir);
|
||||
|
||||
}
|
||||
//查询公文文件表
|
||||
@@ -686,11 +767,7 @@ public class ArchivesUploadController {
|
||||
String fileBase64 = resultSetFile.getString("sound_image");
|
||||
String myuuid = StringUtil.generaterUUID();
|
||||
String fileNameServer =myuuid + fileName;
|
||||
File fileOne = new File(dir);
|
||||
if (!fileOne.exists()) {
|
||||
fileOne.mkdirs();
|
||||
}
|
||||
String fileUrl = dir+"/"+fileNameServer;
|
||||
Path target = dirPath.resolve(fileNameServer);
|
||||
//base64解析
|
||||
// if(StringUtils.isNotEmpty(fileBase64)){
|
||||
// Base64Utils.decode2(fileUrl,fileBase64);
|
||||
@@ -748,53 +825,31 @@ public class ArchivesUploadController {
|
||||
// i++;
|
||||
// }
|
||||
if(binaryStream != null){
|
||||
try (FileOutputStream outputStream = new FileOutputStream(fileUrl)) { // 输出到文件
|
||||
byte[] buffer = new byte[1024]; // 缓冲区大小可以根据需要调整
|
||||
int bytesRead;
|
||||
while ((bytesRead = binaryStream.read(buffer)) != -1) {
|
||||
outputStream.write(buffer, 0, bytesRead);
|
||||
try {
|
||||
writeStreamToFile(binaryStream, target);
|
||||
String type = safeExt(fileName);
|
||||
// 避免重复文件记录:以rec_id+file_name去重
|
||||
if (!existsInTemp(fileTableName, " rec_id='" + jhId + "' and file_name='" + fileName + "' ")) {
|
||||
insertFileRecord(fileTableName, jhId, fileName, fileNameServer, filePath, type, 1, dir);
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("[CONTRACT] 保存附件: fileName={}, serverName={}, type={}, path={}", fileName, fileNameServer, type, target);
|
||||
}
|
||||
} else if (log.isDebugEnabled()) {
|
||||
log.debug("[CONTRACT] 跳过重复附件登记: rec_id={}, fileName={}", jhId, fileName);
|
||||
}
|
||||
int i = 1;
|
||||
String[] strings = fileName.split("\\.");
|
||||
String type = strings[strings.length - 1].toLowerCase();
|
||||
|
||||
//把文件数据添加到file表中
|
||||
String fieldNameFile =
|
||||
"rec_id, " +
|
||||
"file_name, " +
|
||||
"file_name_server, " +
|
||||
"file_path, " +
|
||||
"file_type," +
|
||||
|
||||
"page_no," +
|
||||
"file_des," +
|
||||
"file_status";
|
||||
String valueNameFile =
|
||||
"" + jhId + "," +
|
||||
"'" + fileName+ "'," +
|
||||
"'" + fileNameServer+ "'," +
|
||||
"'" + filePath + "'," +
|
||||
"'" + type + "'," +
|
||||
|
||||
i + "," +
|
||||
"'" + dir + "'," +
|
||||
"1";
|
||||
Map<String, Object> mapFile = new HashMap<String, Object>();
|
||||
mapFile.put("tableName", fileTableName);
|
||||
//其实我们知道是哪些字段
|
||||
mapFile.put("fieldName", fieldNameFile);
|
||||
mapFile.put("valueName", valueNameFile);
|
||||
danganguanliService.saveObject(mapFile);
|
||||
if(type.equalsIgnoreCase("jpg")||type.equalsIgnoreCase("png") || type.equalsIgnoreCase("pdf") ){
|
||||
//生成一份pdf文件,用于归档章的操作
|
||||
String newName_pdf=fileNameServer.replace("."+type,".pdf");
|
||||
PdfFileHelper.image2Pdf(dir+File.separator+fileNameServer,dir+File.separator+newName_pdf);
|
||||
PdfFileHelper.image2Pdf(dirPath.resolve(fileNameServer).toString(),dirPath.resolve(newName_pdf).toString());
|
||||
|
||||
String newName_pdf_original=newName_pdf.replace(".pdf","_original.pdf");
|
||||
FileTool.copyFile(dir+File.separator+newName_pdf,dir+File.separator+newName_pdf_original);
|
||||
FileTool.copyFile(dirPath.resolve(newName_pdf).toString(),dirPath.resolve(newName_pdf_original).toString());
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("[CONTRACT] 生成PDF及原始副本: {}, {}", dirPath.resolve(newName_pdf), dirPath.resolve(newName_pdf_original));
|
||||
}
|
||||
}
|
||||
i++;
|
||||
} catch (IOException e) {
|
||||
log.error("[CONTRACT] 保存附件失败 rowId={}, fileName={}", indexComment, fileName, e);
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
binaryStream.close(); // 关闭流很重要,避免资源泄露
|
||||
@@ -827,13 +882,19 @@ public class ArchivesUploadController {
|
||||
//最后更新归档状态
|
||||
String updateSql = "update v_ez_contract set ARCHIVING_STATUS = 1 where ROW_ID = " + indexComment;
|
||||
YcjSystemIntegration.executeUpdate(updateSql);
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("[CONTRACT] 回写源库归档状态成功 rowId={}", indexComment);
|
||||
}
|
||||
j++;
|
||||
|
||||
//添加日志
|
||||
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
User user = null;
|
||||
if (servletRequestAttributes != null) {
|
||||
HttpServletRequest request = servletRequestAttributes.getRequest();
|
||||
UserRole userRole = userService.getUserRole(request);
|
||||
User user= userRole.getUser();
|
||||
if (userRole != null) user = userRole.getUser();
|
||||
}
|
||||
if (user != null) {
|
||||
//记录日志
|
||||
java.util.Date date = new Date();
|
||||
@@ -847,14 +908,19 @@ public class ArchivesUploadController {
|
||||
operLoggerService.addEntity(entity);
|
||||
}
|
||||
}
|
||||
if (log.isInfoEnabled()) log.info("[CONTRACT] 合同对接完成, 待处理条数={}, 成功处理条数={}", totalPending, j);
|
||||
json = AjaxJson.returnInfo("成功接收"+ j +"条");
|
||||
} catch (Exception e) {
|
||||
log.error("[CONTRACT] 合同对接失败 cont_no={}", cont_no, e);
|
||||
json = AjaxJson.returnExceptionInfo(e.toString());
|
||||
//添加日志
|
||||
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
User user = null;
|
||||
if (servletRequestAttributes != null) {
|
||||
HttpServletRequest request = servletRequestAttributes.getRequest();
|
||||
UserRole userRole = userService.getUserRole(request);
|
||||
User user= userRole.getUser();
|
||||
if (userRole != null) user = userRole.getUser();
|
||||
}
|
||||
if (user != null) {
|
||||
//记录日志
|
||||
java.util.Date date = new Date();
|
||||
@@ -871,6 +937,7 @@ public class ArchivesUploadController {
|
||||
YcjSystemIntegration.closeResources(null, null, resultSet);
|
||||
YcjSystemIntegration.closeResources(null, null, resultSetFile);
|
||||
YcjSystemIntegration.closeResources(null, null, resultSetDisposal);
|
||||
YcjSystemIntegration.closeResources(null, null, resultSetCount);
|
||||
}
|
||||
return json;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.point.strategy.bean.receive.编码;
|
||||
import com.point.strategy.classTree.bean.ClassTree;
|
||||
import com.point.strategy.classTree.mapper.ClassTreeMapper;
|
||||
import com.point.strategy.common.*;
|
||||
import com.point.strategy.dao.TentityStructDescriptionMapper;
|
||||
import com.point.strategy.dao.TtableDescriptionMapper;
|
||||
import com.point.strategy.dao.TtableStructDescriptionMapper;
|
||||
import com.point.strategy.docTraditionArrange.docVolume.mapper.DanganguanliMapper;
|
||||
@@ -21,6 +22,9 @@ import com.point.strategy.fourCheck.service.FourCheckService;
|
||||
import com.point.strategy.user.bean.User;
|
||||
import com.point.strategy.user.bean.UserRole;
|
||||
import com.point.strategy.user.service.UserService;
|
||||
import com.yh.scofd.agent.HTTPAgent;
|
||||
import com.yh.scofd.agent.wrapper.Const;
|
||||
import com.yh.scofd.agent.wrapper.model.ArchiveStamp;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@@ -40,12 +44,14 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
import sun.management.resources.agent;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.awt.*;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
@@ -85,6 +91,12 @@ public class FileManageService {
|
||||
@Value("${img.upload}")
|
||||
private String imgUpload;
|
||||
|
||||
@Value("${youhong.baseUrl}")
|
||||
private String youhongBaseUrl;
|
||||
|
||||
@Value("${youhong.integrate}")
|
||||
private Boolean youhongIntegrate;
|
||||
|
||||
@Transactional
|
||||
public AjaxJson<Object> downloadEEP(String classId, String ids, HttpServletResponse response) {
|
||||
AjaxJson<Object> result = null;
|
||||
@@ -191,8 +203,12 @@ public class FileManageService {
|
||||
String file_name_server = StringUtil.formatMap(tempFile_map, "file_name_server");
|
||||
String file_path = StringUtil.formatMap(tempFile_map, "file_path");
|
||||
String file_des = StringUtil.formatMap(tempFile_map, "file_des");
|
||||
//如果file_des后面有/就不加/没有就加一个
|
||||
if (!file_des.endsWith(File.separator)) {
|
||||
file_des = file_des + File.separator;
|
||||
}
|
||||
//String dir = imgUpload + File.separator + file_path + File.separator + file_name_server;
|
||||
String dir = file_des + File.separator + file_name_server;
|
||||
String dir = file_des + file_name_server;
|
||||
filePaths.add(dir);
|
||||
}
|
||||
//打包成zip文件 并下载
|
||||
@@ -940,6 +956,8 @@ public class FileManageService {
|
||||
String piece_no = StringUtil.formatMap(temp_map, "piece_no");
|
||||
//实体分类号(中文)
|
||||
String archive_ctg_no = StringUtil.formatMap(temp_map, "archive_ctg_no");
|
||||
//机构问题
|
||||
String jigouwenti = StringUtil.formatMap(temp_map, "jigouwenti");
|
||||
if (archive_ctg_no != null && !"".equals(archive_ctg_no)) {
|
||||
archive_ctg_no = archive_ctg_no.substring(archive_ctg_no.indexOf("]") + 1, archive_ctg_no.length());
|
||||
}
|
||||
@@ -963,7 +981,76 @@ public class FileManageService {
|
||||
Map<String, Object> tempFile_map = dataList2.get(0);
|
||||
|
||||
String file_name_server = StringUtil.formatMap(tempFile_map, "file_name_server");
|
||||
String file_name_server_pdf_original = file_name_server.replace(".jpg", "_original.pdf");
|
||||
String file_des = StringUtil.formatMap(tempFile_map, "file_des");
|
||||
String file_name_server_pdf_original = "";
|
||||
if(file_name_server.contains(".jpg")){
|
||||
file_name_server_pdf_original = file_name_server.replace(".jpg", "_original.pdf");
|
||||
}else if(file_name_server.contains(".pdf")){
|
||||
|
||||
file_name_server_pdf_original = file_name_server.replace(".pdf", "_original.pdf");
|
||||
//String newName_pdf_original=file_name_server.replace(".pdf","_original.pdf");
|
||||
//FileTool.copyFile(dir+File.separator+file_name_server,dir+File.separator+newName_pdf_original);
|
||||
String[][] textContent = {{fonds_no, filing_year, piece_no}, {jigouwenti, retention, quantity}};
|
||||
PdfFileHelper.Seal(file_des+File.separator+file_name_server_pdf_original, file_des+File.separator+file_name_server, 1, textContent, "2", 1);
|
||||
return result;
|
||||
}else if(file_name_server.contains(".ofd")){
|
||||
if(youhongIntegrate){
|
||||
String newName_pdf_original=file_name_server.replace(".ofd","_ArchiveSeal.ofd");
|
||||
//FileTool.copyFile(dir+File.separator+file_name_server,dir+File.separator+newName_pdf_original);
|
||||
HTTPAgent agent = new HTTPAgent(youhongBaseUrl,5);
|
||||
ArchiveStamp archiveStamp = new ArchiveStamp(0,255,0,0);
|
||||
archiveStamp.setIndex(new int[]{0});
|
||||
archiveStamp.setxAlign(Const.XAlign.Center);
|
||||
archiveStamp.setyAlign(Const.YAlign.Top);
|
||||
archiveStamp.setPosX(0);
|
||||
archiveStamp.setPosY(10);
|
||||
//档案章线条颜色
|
||||
archiveStamp.setBorderColor("#000000");
|
||||
archiveStamp.setColumnWidth(57.69);
|
||||
archiveStamp.setLineHeight(28.34);
|
||||
archiveStamp.setInnerBorder(4);
|
||||
archiveStamp.setOuterBorder(4);
|
||||
|
||||
//全局字体、颜色、字号设置
|
||||
archiveStamp.setFontSize(17.3);
|
||||
archiveStamp.setFontColor("#FF0000");
|
||||
|
||||
String[] content1 = {fonds_no, filing_year, piece_no};
|
||||
ArchiveStamp.CellStyle[] styles1 = {
|
||||
new ArchiveStamp.CellStyle("Times New Roman",17.3,"#000000"),
|
||||
new ArchiveStamp.CellStyle("Times New Roman",17.3,"#000000"),
|
||||
new ArchiveStamp.CellStyle("Times New Roman",15.33,"#000000")
|
||||
|
||||
};
|
||||
String[] content2 = {jigouwenti, retention, quantity};
|
||||
ArchiveStamp.CellStyle[] styles2 = {
|
||||
new ArchiveStamp.CellStyle("方正小标宋",18.6,"#000000"),
|
||||
new ArchiveStamp.CellStyle("宋体",16.6,"#000000"),
|
||||
new ArchiveStamp.CellStyle("Times New Roman",14,"#000000")
|
||||
|
||||
};
|
||||
archiveStamp.addRow(content1,styles1);
|
||||
archiveStamp.addRow(content2,styles2);
|
||||
// archiveStamp.addRow(fonds_no, filing_year, piece_no);
|
||||
// archiveStamp.addRow(archive_ctg_no, retention, quantity);
|
||||
String result_file_des = file_des + "/result";
|
||||
File fileOne = new File(result_file_des);
|
||||
if (!fileOne.exists()) {
|
||||
fileOne.mkdirs();
|
||||
}
|
||||
agent.officeToOFD(new File(file_des+File.separator+file_name_server),new FileOutputStream(result_file_des+File.separator+newName_pdf_original),null,archiveStamp);
|
||||
//更新文件服务名
|
||||
String fieldValue = " file_name_server='" + newName_pdf_original + "'" + "," + " file_des ='" + result_file_des + "'";
|
||||
String conditionSql = " id='" + fileId + "'";
|
||||
Map<String, Object> map7 = new HashMap<String, Object>();
|
||||
map7.put("tableName", tableName + "_temp_file");
|
||||
map7.put("fieldValue", fieldValue);
|
||||
map7.put("conditionSql", conditionSql);
|
||||
danganguanliMapper.updateObject(map7);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
String file_name_server_pdf = file_name_server.replace(".jpg", ".pdf");
|
||||
|
||||
String source = dir + file_name_server_pdf_original;
|
||||
@@ -979,10 +1066,10 @@ public class FileManageService {
|
||||
target = dir1 + file_name_server_pdf;
|
||||
}
|
||||
String[][] textContent = {{fonds_no, filing_year, piece_no}, {archive_ctg_no, retention, quantity}};
|
||||
PdfFileHelper.Seal(source, target, 1, textContent, "1", 2);
|
||||
PdfFileHelper.Seal(source, target, 1, textContent, "2", 1);
|
||||
//pdf转ofd
|
||||
String newName_ofd = target.replace(".pdf", ".ofd");
|
||||
PdfToOfdUtil.pdfToOfd(target, newName_ofd);
|
||||
// String newName_ofd = target.replace(".pdf", ".ofd");
|
||||
// PdfToOfdUtil.pdfToOfd(target, newName_ofd);
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
@@ -1185,22 +1272,15 @@ public class FileManageService {
|
||||
try {
|
||||
String relative_path = "uploadFile/" + tableName + "_temp_file/" + fondscode + "/" + id;
|
||||
String dir = imgUpload + File.separator + relative_path;
|
||||
// if(archiveNo.contains("·")){
|
||||
// archiveNo = archiveNo.replace("·", ".");
|
||||
// }
|
||||
String dir1 = imgUpload + File.separator + "uploadFile" + File.separator + archiveNo + File.separator;
|
||||
//得到temp_file表数据列表
|
||||
Map<String, Object> parasMap2 = new HashMap<String, Object>();
|
||||
if (type.equals(0)) {
|
||||
parasMap2.put("tableName", tableName + "_temp_file");
|
||||
} else if (type.equals(1)) {
|
||||
parasMap2.put("tableName", tableName + "_file");
|
||||
}
|
||||
|
||||
parasMap2.put("conditionSql", " id in (" + fileIds + " )");
|
||||
List<Map<String, Object>> dataList2 = danganguanliMapper.selectObject(parasMap2);
|
||||
|
||||
//临时文件夹
|
||||
String temp_pdf = tempPath + "/temp_company_img/";
|
||||
FileUtil.makedir(temp_pdf);
|
||||
String[] fileArray = new String[dataList2.size()];
|
||||
@@ -1222,25 +1302,6 @@ public class FileManageService {
|
||||
|
||||
String srcFile2 = tarFile;
|
||||
String tarFile2 = temp_pdf + "setWaterMark-" + DateUtil.date2String(new Date(), 3) + ".pdf";
|
||||
//用户用户名称
|
||||
|
||||
// String markStr =userChnName+ " 禁止传阅 "+"\n";
|
||||
//// int fontSize = 50;
|
||||
//// String color = "RED";
|
||||
//// int globalOblique = 0;
|
||||
//// PdfFileHelper.setWaterMark(srcFile2,
|
||||
//// tarFile2,
|
||||
//// markStr,
|
||||
//// fontSize,0
|
||||
//// color,
|
||||
//// globalOblique);
|
||||
// //水平平铺水印
|
||||
//// PdfFileHelper.waterMark(srcFile2,tarFile2,markStr);
|
||||
// List<String> markList = new ArrayList<>();
|
||||
// markList.add(userChnName);
|
||||
// markList.add("内部资料");
|
||||
// WatermarkMainTest.setWatermark2(tarFile2, srcFile2, markList);
|
||||
//浏览器下载
|
||||
FileUtil.download(srcFile2, response);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -1252,7 +1313,7 @@ public class FileManageService {
|
||||
ImgUtil.pressText(
|
||||
cn.hutool.core.io.FileUtil.file(srcImg), //源图片
|
||||
cn.hutool.core.io.FileUtil.file(destImg), //目标图片
|
||||
"", //水印文字
|
||||
userChnName + "(内部资料)", //水印文字
|
||||
Color.red, //水印文字颜色
|
||||
new Font("黑体", Font.BOLD, 100), //字体
|
||||
0, //x坐标修正值。 默认在中间,偏移量相对于中间偏移
|
||||
@@ -1479,25 +1540,45 @@ public class FileManageService {
|
||||
List<Map<String, Object>> dataFile= danganguanliMapper.selectObject(parasMapFile);
|
||||
int sumFile=0;
|
||||
for (Map<String, Object> map22:dataFile) {
|
||||
|
||||
String file_name_server = StringUtil.formatMap(map22, "file_name_server");
|
||||
file_name_server = file_name_server.replaceAll(".jpg", ".pdf");
|
||||
|
||||
String file_path = StringUtil.formatMap(map22, "file_path");
|
||||
String file_des = StringUtil.formatMap(map22, "file_des");
|
||||
//如果file_des后面有/就不加/没有就加一个
|
||||
if (!file_des.endsWith(File.separator)) {
|
||||
file_des = file_des + File.separator;
|
||||
}
|
||||
//String dir = imgUpload + File.separator + file_path + File.separator + file_name_server;
|
||||
String dir = file_des + File.separator + file_name_server;
|
||||
int count= PdfFileHelper.getPdfPageCoun(dir);
|
||||
int count = 0;
|
||||
String file_type = StringUtil.formatMap(map22, "file_type");
|
||||
if(file_type.equalsIgnoreCase("tif")){
|
||||
file_name_server = file_name_server.replaceAll(".jpg", ".pdf");
|
||||
String dir = file_des + file_name_server;
|
||||
count= PdfFileHelper.getTifPageCount(dir);
|
||||
}else{
|
||||
file_name_server = file_name_server.replaceAll(".jpg", ".pdf");
|
||||
String dir = file_des + file_name_server;
|
||||
count= PdfFileHelper.getPdfPageCoun(dir);
|
||||
}
|
||||
System.out.println(count);
|
||||
sumFile=sumFile+count;
|
||||
}
|
||||
map.put("archive_file_num",sumFile);
|
||||
String archive_file_num=String.valueOf(sumFile);
|
||||
//todo 查询页数兼容yeshu
|
||||
String quantity=StringUtil.formatMap(map,"quantity");
|
||||
String yeshu=StringUtil.formatMap(map,"yeshu");
|
||||
if (!org.springframework.util.StringUtils.isEmpty(yeshu)){
|
||||
map.put("quantity",yeshu);
|
||||
}
|
||||
if (quantity==null || "".equals(quantity)){
|
||||
quantity="0";
|
||||
}
|
||||
if (!archive_file_num.equals(quantity)){
|
||||
dataListResult.add(map);
|
||||
}
|
||||
// if (!archive_file_num.equals(quantity)){
|
||||
// dataListResult.add(map);
|
||||
// }
|
||||
}
|
||||
return dataListResult;
|
||||
}
|
||||
@@ -3470,6 +3551,7 @@ public class FileManageService {
|
||||
|
||||
String[] fileIdArray = md5_code.split(",");
|
||||
for (String fileId : fileIdArray) {
|
||||
if(StringUtils.isNotEmpty(fileId)){
|
||||
String fieldValue = " rec_id=" + myId + ",file_status=1";
|
||||
String conditionSql = " id='" + fileId + "'";
|
||||
Map<String, Object> map7 = new HashMap<String, Object>();
|
||||
@@ -3478,6 +3560,7 @@ public class FileManageService {
|
||||
map7.put("conditionSql", conditionSql);
|
||||
danganguanliMapper.updateObject(map7);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
//要迁移 上级回收站的数据到 上级的临时表中,先要判断 上级的临时表 是否存在
|
||||
@@ -3797,7 +3880,19 @@ public class FileManageService {
|
||||
List<Map<String, Object>> dataList = danganguanliMapper.selectObject(parasMap);
|
||||
Map<String, Object> map0 = dataList.get(0);
|
||||
|
||||
Integer quantity = StringUtil.formatMapToInt(map0, "quantity");
|
||||
// 查找页数字段
|
||||
// todo
|
||||
Integer quantity = 0,quantityFlag=0;
|
||||
TtableDescription ttableDescription = tableDescriptionMapper.selectTtableDescOne(tableName);
|
||||
List<TtableStructDescription> ttableStructDescriptionList = ttableStructDescriptionMapper.selectByTableName(tableName);
|
||||
for (TtableStructDescription ttableStructDescription : ttableStructDescriptionList) {
|
||||
String columnChnName = ttableStructDescription.getColumnChnName();
|
||||
if ("页数".equals(columnChnName)){
|
||||
quantity = StringUtil.formatMapToInt(map0, ttableStructDescription.getColumnName());
|
||||
quantityFlag = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(quantity==null){
|
||||
quantity=0;
|
||||
}
|
||||
@@ -3815,12 +3910,12 @@ public class FileManageService {
|
||||
String file_des = StringUtil.formatMap(map, "file_des");
|
||||
//String dir = imgUpload + File.separator + file_path + File.separator + file_name_server;
|
||||
String dir = file_des + File.separator + file_name_server;
|
||||
int count= PdfFileHelper.getPdfPageCoun(dir);
|
||||
int count= PdfFileHelper.getPdfPageCounOrOther(dir);
|
||||
System.out.println(count);
|
||||
sumFile=sumFile+count;
|
||||
}
|
||||
|
||||
if (quantity!=sumFile){
|
||||
if (quantity!=sumFile && quantityFlag!=0){
|
||||
//json = AjaxJson.returnExceptionInfo("页数和原文数量是否匹配!");
|
||||
json.put("info","页数和原文数量不匹配!");
|
||||
}
|
||||
|
||||
@@ -478,6 +478,19 @@
|
||||
WHERE
|
||||
${conditionSql}
|
||||
</update>
|
||||
<update id="updateFileName">
|
||||
UPDATE ${tableName}
|
||||
SET file_name = CASE
|
||||
<foreach collection="list" item="item" separator="">
|
||||
WHEN id = #{item.id} THEN #{item.fileName}
|
||||
</foreach>
|
||||
ELSE file_name
|
||||
END
|
||||
WHERE id IN
|
||||
<foreach collection="list" item="item" open="(" separator="," close=")">
|
||||
#{item.id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<delete id="deleteDocOriginalEntityRecycle" parameterType="java.lang.Integer">
|
||||
delete from wsjh_20201103104220949_temp_file where 1=1 and id = #{id}
|
||||
@@ -564,5 +577,9 @@
|
||||
</where>
|
||||
order by page_no asc
|
||||
</select>
|
||||
<select id="selectArchiveNo" resultType="java.lang.String">
|
||||
select archive_no from ${tableName} where id = #{recId}
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user