fix: bug
This commit is contained in:
@@ -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);
|
||||
}
|
||||
dataListResult.add(map);
|
||||
// if (!archive_file_num.equals(quantity)){
|
||||
// dataListResult.add(map);
|
||||
// }
|
||||
}
|
||||
return dataListResult;
|
||||
}
|
||||
@@ -3470,13 +3551,15 @@ public class FileManageService {
|
||||
|
||||
String[] fileIdArray = md5_code.split(",");
|
||||
for (String fileId : fileIdArray) {
|
||||
String fieldValue = " rec_id=" + myId + ",file_status=1";
|
||||
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);
|
||||
if(StringUtils.isNotEmpty(fileId)){
|
||||
String fieldValue = " rec_id=" + myId + ",file_status=1";
|
||||
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);
|
||||
}
|
||||
}
|
||||
} 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,16 +3910,16 @@ 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","页数和原文数量不匹配!");
|
||||
}
|
||||
return json;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user