3926 lines
215 KiB
Java
3926 lines
215 KiB
Java
package com.point.strategy.service;
|
||
|
||
import cn.hutool.core.img.ImgUtil;
|
||
import com.alibaba.fastjson.JSON;
|
||
import com.alibaba.fastjson.JSONObject;
|
||
import com.point.strategy.bean.*;
|
||
import com.point.strategy.bean.receive.文件实体;
|
||
import com.point.strategy.bean.receive.文档;
|
||
import com.point.strategy.bean.receive.电子文件封装包;
|
||
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;
|
||
import com.point.strategy.fond.bean.Fond;
|
||
import com.point.strategy.fond.mapper.FondMapper;
|
||
import com.point.strategy.fond.service.FondService;
|
||
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;
|
||
import org.apache.poi.hssf.usermodel.HSSFCell;
|
||
import org.apache.poi.hssf.usermodel.HSSFRow;
|
||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||
import org.dom4j.Document;
|
||
import org.dom4j.Element;
|
||
import org.dom4j.io.SAXReader;
|
||
import org.slf4j.Logger;
|
||
import org.slf4j.LoggerFactory;
|
||
import org.springframework.beans.factory.annotation.Autowired;
|
||
import org.springframework.beans.factory.annotation.Value;
|
||
import org.springframework.stereotype.Service;
|
||
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.*;
|
||
import java.util.stream.Collectors;
|
||
|
||
@Service
|
||
public class FileManageService {
|
||
|
||
private static final Logger logger = LoggerFactory.getLogger(FileManageService.class);
|
||
@Autowired
|
||
private DanganguanliMapper danganguanliMapper;
|
||
@Autowired
|
||
private CommonService commonService;
|
||
@Autowired
|
||
private TtableStructDescriptionMapper ttableStructDescriptionMapper;
|
||
@Autowired
|
||
private TtableDescriptionMapper tableDescriptionMapper;
|
||
@Autowired
|
||
private UserService userService;
|
||
@Autowired
|
||
private OperLoggerService operLoggerService;
|
||
@Autowired
|
||
private FourCheckService fourCheckService;
|
||
@Autowired
|
||
private FondMapper fondMapper;
|
||
@Autowired
|
||
private FondService fondService;
|
||
@Autowired
|
||
private ClassTreeMapper classTreeMapper;
|
||
@Autowired
|
||
private EepLogService eepLogService;
|
||
|
||
|
||
@Value("${temp.path}")
|
||
private String tempPath;
|
||
|
||
@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;
|
||
try {
|
||
result = new AjaxJson<>();
|
||
String content = formatContentEEP(classId, ids);
|
||
String fileName = "SZ154-2021-W01-Y-0009.eep";
|
||
String path = tempPath + "/dc/";
|
||
FileUtil.makedir(path);
|
||
path = path + fileName;
|
||
FileUtils.writeStringToFile(new File(path), content, "UTF-8");
|
||
DownLoadFile.download(path, response);
|
||
//删除临时文件
|
||
FileUtil.delAllFile(path);
|
||
} catch (Exception e) {
|
||
result = AjaxJson.returnExceptionInfo("下载eep失败:" + e);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
public void transferEEP(JSONObject jsonObject, HttpServletResponse response, HttpServletRequest request) {
|
||
AjaxJson<Object> result = null;
|
||
try {
|
||
result = new AjaxJson<>();
|
||
Integer classId = jsonObject.getInteger("classId");
|
||
String ids = jsonObject.getString("ids");
|
||
String path = jsonObject.getString("path");
|
||
String checkLink = jsonObject.getString("checkLink");
|
||
String entityId = jsonObject.getString("entityId");
|
||
String fondscode = jsonObject.getString("fondscode");
|
||
String transferTo = jsonObject.getString("transferTo");
|
||
List<TtableDescription> tableDescriptionList = commonService.selectTtableDesByClassId(classId);
|
||
if (tableDescriptionList.size() == 1) { //1层
|
||
String tableName = tableDescriptionList.get(0).getTableName();
|
||
String content = formatContentEEP(tableName, ids);
|
||
content = FileTool.formatXml(content);
|
||
String datetime = DateUtil.date2String(new Date(), 3);
|
||
String fileName = datetime + ".eep";
|
||
FileUtil.makedir(path);
|
||
String wholePath = path + "/" + fileName;
|
||
FileUtils.writeStringToFile(new File(wholePath), content, "UTF-8");
|
||
|
||
Map<String, Object> params = new HashMap<>();
|
||
params.put("checkLink", checkLink);
|
||
params.put("classId", classId);
|
||
params.put("entityId", entityId);
|
||
params.put("fondscode", fondscode);
|
||
params.put("pathName", path);
|
||
String fileName11 = fourCheckService.check(params);
|
||
List<String> list = new ArrayList<>();
|
||
list.add(wholePath);
|
||
list.add(path + File.separator + fileName11 + ".pdf");
|
||
String temp = tempPath + File.separator + "eep";
|
||
//创建文件夹
|
||
File file = new File(temp);
|
||
if (!file.exists() && !file.isDirectory()) {
|
||
file.mkdirs();
|
||
}
|
||
DownloadZip.downloadFilesZip(request, response, list, temp, "eepDown.zip");
|
||
//删除临时文件
|
||
FileUtil.delAllFile(tempPath);
|
||
//添加eep包下载日志
|
||
EepLog eepLog = new EepLog();
|
||
String fondsNameByFondsCode = fondMapper.getFondsNameByFondsCode(fondscode);
|
||
ClassTree classTree = classTreeMapper.selectClassOneById(classId);
|
||
String className = classTree.getClassName();
|
||
eepLog.setTableChnName(fondsNameByFondsCode + className + System.currentTimeMillis());
|
||
eepLog.setClassId(classId);
|
||
eepLog.setCreateDate(new Date());
|
||
eepLog.setEepPath(wholePath);
|
||
eepLog.setTableChnName(transferTo);
|
||
eepLogService.addEntity(eepLog);
|
||
}
|
||
} catch (Exception e) {
|
||
result = AjaxJson.returnExceptionInfo("移交eep失败:" + e);
|
||
}
|
||
}
|
||
|
||
|
||
public void batchDownload(String tableName,
|
||
String ids,
|
||
Integer userId,
|
||
String archiveNo,
|
||
Integer type,
|
||
HttpServletRequest request,
|
||
HttpServletResponse response) {
|
||
try {
|
||
String zipBasePath = tempPath + "\\temp2\\bb\\";
|
||
FileUtil.makedir(zipBasePath);
|
||
List<String> filePaths = new ArrayList<String>();
|
||
String zipName = "批量下载" + DateUtil.date2String(new Date(), 3) + ".zip";
|
||
//得到temp_file表数据列表
|
||
String myTableName = "";
|
||
if (type == 0) {
|
||
myTableName = tableName + "_temp_file";
|
||
} else if (type == 1) {
|
||
myTableName = tableName + "_file";
|
||
}
|
||
Map<String, Object> parasMap2 = new HashMap<String, Object>();
|
||
parasMap2.put("tableName", myTableName);
|
||
parasMap2.put("conditionSql", " id in ( " + ids + ")");
|
||
List<Map<String, Object>> dataList2 = danganguanliMapper.selectObject(parasMap2);
|
||
for (Map<String, Object> tempFile_map : dataList2) {
|
||
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_name_server;
|
||
filePaths.add(dir);
|
||
}
|
||
//打包成zip文件 并下载
|
||
DownloadZip.downloadFilesZip(request, response, filePaths, zipBasePath, zipName);
|
||
//删除临时文件夹目录
|
||
FileUtil.delAllFile(zipBasePath);
|
||
|
||
//添加日志
|
||
// TtableDescription ttableDescription = tableDescriptionMapper.selectTtableDescOne(tableName);
|
||
User user = userService.selectByPrimaryKey(userId);
|
||
if (user != null) {
|
||
//记录日志
|
||
Date date = new Date();
|
||
OperLogger entity = new OperLogger();
|
||
entity.setLogType("1");
|
||
entity.setOperator(user.getUsername());
|
||
entity.setOperatorChn(user.getUserChnName());
|
||
entity.setOperateDate(date);
|
||
entity.setDescription("批量下载了档号为:'" + archiveNo + "' 的原文");
|
||
entity.setArgs("批量下载了档号为:'" + archiveNo + "' 的原文");
|
||
operLoggerService.addEntity(entity);
|
||
}
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
|
||
|
||
public void batchDownloadTwo(String tableName,
|
||
String ids,
|
||
HttpServletRequest request,
|
||
HttpServletResponse response) {
|
||
try {
|
||
//批量下载档案复制
|
||
String zipBasePath = tempPath + "\\temp2\\bb\\";
|
||
FileUtil.makedir(zipBasePath);
|
||
List<String> filePaths = new ArrayList<String>();
|
||
String zipName = "批量下载" + DateUtil.date2String(new Date(), 3) + ".zip";
|
||
//得到temp_file表数据列表
|
||
String myTableName = tableName + "_file";
|
||
Map<String, Object> parasMap2 = new HashMap<String, Object>();
|
||
parasMap2.put("tableName", myTableName);
|
||
parasMap2.put("conditionSql", " id in ( " + ids + ")");
|
||
List<Map<String, Object>> dataList2 = danganguanliMapper.selectObject(parasMap2);
|
||
for (Map<String, Object> tempFile_map : dataList2) {
|
||
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");
|
||
//String dir = imgUpload + File.separator + file_path + File.separator + file_name_server;
|
||
String dir = file_des + File.separator + file_name_server;
|
||
filePaths.add(dir + file_name_server);
|
||
}
|
||
//打包成zip文件 并下载
|
||
DownloadZip.downloadFilesZip(request, response, filePaths, zipBasePath, zipName);
|
||
//删除临时文件夹目录
|
||
FileUtil.delAllFile(zipBasePath);
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
|
||
public void batchDownloadWatermarking(String tableName,
|
||
String ids,
|
||
Integer userId,
|
||
String archiveNo,
|
||
Integer type,
|
||
HttpServletRequest request,
|
||
HttpServletResponse response) {
|
||
try {
|
||
String zipBasePath = tempPath + "\\temp2\\bb\\";
|
||
String zipFilePath = tempPath + "\\temp2\\cc\\";
|
||
FileUtil.makedir(zipBasePath);
|
||
FileUtil.makedir(zipFilePath);
|
||
List<String> filePaths = new ArrayList<String>();
|
||
String zipName = "批量下载" + DateUtil.date2String(new Date(), 3) + ".zip";
|
||
//得到temp_file表数据列表
|
||
String myTableName = "";
|
||
if (type == 0) {
|
||
myTableName = tableName + "_temp_file";
|
||
} else if (type == 1) {
|
||
myTableName = tableName + "_file";
|
||
}
|
||
Map<String, Object> parasMap2 = new HashMap<String, Object>();
|
||
parasMap2.put("tableName", myTableName);
|
||
parasMap2.put("conditionSql", " id in ( " + ids + ")");
|
||
List<Map<String, Object>> dataList2 = danganguanliMapper.selectObject(parasMap2);
|
||
for (Map<String, Object> tempFile_map : dataList2) {
|
||
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");
|
||
//String dir = imgUpload + File.separator + file_path + File.separator;
|
||
String dir = file_des + File.separator;
|
||
filePaths.add(dir + file_name_server);
|
||
}
|
||
//打包成zip文件 并下载
|
||
//获取用户信息
|
||
UserRole userRole = userService.getUserRole(request);
|
||
DownloadZip.downloadFilesWatermarkingZip(request, response, filePaths, zipBasePath, zipName, userRole, zipFilePath);
|
||
//删除临时文件夹目录
|
||
FileUtil.delAllFile(zipBasePath);
|
||
|
||
//添加日志
|
||
// TtableDescription ttableDescription = tableDescriptionMapper.selectTtableDescOne(tableName);
|
||
User user = userService.selectByPrimaryKey(userId);
|
||
if (user != null) {
|
||
//记录日志
|
||
Date date = new Date();
|
||
OperLogger entity = new OperLogger();
|
||
entity.setLogType("1");
|
||
entity.setOperator(user.getUsername());
|
||
entity.setOperatorChn(user.getUserChnName());
|
||
entity.setOperateDate(date);
|
||
entity.setDescription("批量下载了档号为:'" + archiveNo + "' 的原文");
|
||
entity.setArgs("批量下载了档号为:'" + archiveNo + "' 的原文");
|
||
operLoggerService.addEntity(entity);
|
||
}
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
|
||
|
||
private String formatContentEEP(String tableName, String ids) {
|
||
String result = "";
|
||
List<Map<String, Object>> mapList = getTableDataList(tableName, ids);
|
||
String datetime = DateUtil.date2String(new Date(), 1);
|
||
String entity = formatContentEntity(mapList, tableName);
|
||
result = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||
"<电子文件封装包>" +
|
||
" <封装包格式描述>本EEP 根据中华人民共和国档案行业标准DA/T 48-2009《基于XML 的电子文件封装规范》生成</封装包格式描述>" +
|
||
" <版本>2009</版本>" +
|
||
" <被签名对象 eep版本=\"2009\">" +
|
||
" <封装包类型>原始型</封装包类型>" +
|
||
" <封装包类型描述>本封装包包含电子文件数据及其元数据,原始封装,未经修改</封装包类型描述>" +
|
||
" <封装包创建时间>" + datetime + "</封装包创建时间>" +
|
||
" <封装包创建单位>湖北典策档案科技发展有限公司/153-1234-2345 158-3456-4567/湖北典策档案科技发展有限公司(湖北省武汉市武昌区洪山路87号)</封装包创建单位>" +
|
||
" <封装内容>" +
|
||
" <文件实体块>"
|
||
+ entity +
|
||
// " <文件实体关系>" +
|
||
// " <文件标识符/>" +
|
||
// " <被关联文件标识符/>" +
|
||
// " <关系类型/>" +
|
||
// " <关系/>" +
|
||
// " <关系描述/>" +
|
||
// " </文件实体关系>" +
|
||
" </文件实体块>" +
|
||
" <业务实体块>" +
|
||
" <业务实体>" +
|
||
" <业务标识符/>" +
|
||
" <机构人员标识符/>" +
|
||
" <文件标识符/>" +
|
||
" <业务状态/>" +
|
||
" <业务行为>数据封包</业务行为>" +
|
||
" <行为时间>" + datetime + "</行为时间>" +
|
||
" <行为依据>依据中华人民共和国档案行业标准DA/T 48-2009《基于XML 的电子文件封装规范》生成</行为依据>" +
|
||
" <行为描述>数据封包</行为描述>" +
|
||
" </业务实体>" +
|
||
" </业务实体块>" +
|
||
" <机构人员实体块>" +
|
||
" <机构人员实体>" +
|
||
" <机构人员标识符/>" +
|
||
" <机构人员类型/>" +
|
||
" <机构人员名称/>" +
|
||
" <组织机构代码/>" +
|
||
" <个人职位/>" +
|
||
" </机构人员实体>" +
|
||
" <机构人员实体关系>" +
|
||
" <机构人员标识符/>" +
|
||
" <被关联机构人员标识符/>" +
|
||
" <关系类型/>" +
|
||
" <关系/>" +
|
||
" <关系描述/>" +
|
||
" </机构人员实体关系>" +
|
||
" </机构人员实体块>" +
|
||
" </封装内容>" +
|
||
" </被签名对象>" +
|
||
" <电子签名块>" +
|
||
" <电子签名>" +
|
||
" <签名标识符/>" +
|
||
" <签名规则>签名算法:MD5withRSA编码规则:UTF-8</签名规则>" +
|
||
" <签名时间>" + datetime + "</签名时间>" +
|
||
" <签名人>系统管理员</签名人>" +
|
||
" <签名结果>57O757uf566h55CG5ZGY</签名结果>" +
|
||
" <证书块>" +
|
||
" <证书/>" +
|
||
" <证书引用/>" +
|
||
" </证书块>" +
|
||
" <签名算法标识/>" +
|
||
" </电子签名>" +
|
||
" </电子签名块>" +
|
||
" <锁定签名>" +
|
||
" <被锁定签名标识符/>" +
|
||
" <签名规则>签名算法:MD5withRSA编码规则:UTF-8</签名规则>" +
|
||
" <签名时间>" + datetime + "</签名时间>" +
|
||
" <签名人>系统管理员</签名人>" +
|
||
" <签名结果>5rmW5YyX5qGj5qGI5oqA5pyv56CU56m26Zmi5pyJ6ZmQ5YWs5Y+4LzE1My03NzA4LTg1MzkgMTU4 LTcxODEtNTkyNi/muZbljJfnnIHmoaPmoYjppobmoaPmoYjkv53miqTkuK3lv4PvvIjmuZbljJfn nIHmrabmsYnluILmrabmmIzljLrmtKrlsbHot684N+WPtyk=</签名结果>" +
|
||
" <证书块>" +
|
||
" <证书/>" +
|
||
" <证书引用/>" +
|
||
" </证书块>" +
|
||
" <签名算法标识/>" +
|
||
" </锁定签名>" +
|
||
"</电子文件封装包>";
|
||
return result;
|
||
}
|
||
|
||
private String formatContentEntity(List<Map<String, Object>> mapList, String tableName) {
|
||
String result = "";
|
||
for (Map<String, Object> map : mapList) {
|
||
String uuid = StringUtil.generaterUUID();
|
||
String id = StringUtil.formatMap(map, "id");
|
||
String fonds_no = StringUtil.formatMap(map, "fonds_no");
|
||
String filing_year = StringUtil.formatMap(map, "filing_year");
|
||
String retention = StringUtil.formatMap(map, "retention");
|
||
String maintitle = StringUtil.formatMap(map, "maintitle");
|
||
String security_class = StringUtil.formatMap(map, "security_class");
|
||
String archive_no = StringUtil.formatMap(map, "archive_no");
|
||
String created_date = StringUtil.formatMap(map, "created_date");
|
||
String responsibleby = StringUtil.formatMap(map, "responsibleby");
|
||
String mlh = StringUtil.formatMap(map, "mlh");
|
||
String piece_no = StringUtil.formatMap(map, "piece_no");
|
||
String year_folder_no = StringUtil.formatMap(map, "year_folder_no");
|
||
String quantity = StringUtil.formatMap(map, "quantity");
|
||
String archive_ctg_no = StringUtil.formatMap(map, "archive_ctg_no");
|
||
|
||
|
||
String fondsname = fondMapper.getFondsNameByFondsCode(fonds_no);
|
||
String entity = "<文件实体>" +
|
||
" <聚合层次/>" +
|
||
" <来源>" +
|
||
" <档案馆名称></档案馆名称>" +
|
||
" <档案馆代码></档案馆代码>" +
|
||
" <全宗名称>" + fondsname + "</全宗名称>" +
|
||
" <立档单位名称>" + fondsname + "</立档单位名称>" +
|
||
" </来源>" +
|
||
" <电子文件号>" + uuid + "</电子文件号>" +
|
||
" <档号>" +
|
||
" <档号>" + archive_no + "</档号>" +
|
||
" <全宗号>" + fonds_no + "</全宗号>" +
|
||
" <目录号>" + mlh + "</目录号>" +
|
||
" <年度>" + filing_year + "</年度>" +
|
||
" <保管期限>" + retention + "</保管期限>" +
|
||
" <机构或问题></机构或问题>" +
|
||
" <类别号></类别号>" +
|
||
" <室编案卷号>" + year_folder_no + "</室编案卷号>" +
|
||
" <馆编案卷号/>" +
|
||
" <室编件号>" + piece_no + "</室编件号>" +
|
||
" <页数>" + quantity + "</页数>" +
|
||
" </档号>" +
|
||
" <内容描述>" +
|
||
" <题名>" + maintitle + "</题名>" +
|
||
" <并列题名/>" +
|
||
" <副题名/>" +
|
||
" <说明题名文字/>" +
|
||
" <主题词 主题词表名称=\"\"/>" +
|
||
" <人名/>" +
|
||
" <摘要/>" +
|
||
" <分类号>" + archive_ctg_no + "</分类号>" +
|
||
" <文件编号/>" +
|
||
" <责任者>" + responsibleby + "</责任者>" +
|
||
" <日期>" + created_date + "</日期>" +
|
||
" <文种/>" +
|
||
" <紧急程度></紧急程度>" +
|
||
" <主送/>" +
|
||
" <抄送/>" +
|
||
" <密级>" + security_class + "</密级>" +
|
||
" <保密期限/>" +
|
||
" </内容描述>" +
|
||
" <形式特征>" +
|
||
" <文件组合类型/>" +
|
||
" <页数></页数>" +
|
||
" <语种/>" +
|
||
" <稿本/>" +
|
||
" <件数/>" +
|
||
" </形式特征>" +
|
||
" <存储位置>" +
|
||
" <当前位置/>" +
|
||
" <脱机载体编号/>" +
|
||
" <脱机载体存址/>" +
|
||
" <缩微号/>" +
|
||
" </存储位置>" +
|
||
" <权限管理>" +
|
||
" <知识产权说明/>" +
|
||
" <授权>" +
|
||
" <授权行为/>" +
|
||
" <授权对象/>" +
|
||
" </授权>" +
|
||
" <控制标识/>" +
|
||
" </权限管理>" +
|
||
" <信息系统描述/>" +
|
||
" <附注/>" +
|
||
" <文件数据>" + wendang(tableName, id) + "</文件数据>" +
|
||
" <修改封装内容/>" +
|
||
" </文件实体>";
|
||
result = result + entity;
|
||
}
|
||
return result;
|
||
}
|
||
|
||
|
||
private String wendang(String tableName, String recId) {
|
||
String result = "";
|
||
List<Map<String, Object>> mapList = getTableDataFileList(tableName, recId);
|
||
for (Map<String, Object> map : mapList) {
|
||
String file_name_server = StringUtil.formatMap(map, "file_name_server");
|
||
String file_name = StringUtil.formatMap(map, "file_name");
|
||
String file_path = StringUtil.formatMap(map, "file_path");
|
||
String file_type = StringUtil.formatMap(map, "file_type");
|
||
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;
|
||
String kk = file_name_server.replaceAll(".jpg", "");
|
||
String encodeStr = Base64Utils.encode2(dir);
|
||
String wendangXml = " <文档>" +
|
||
" <文档标识符>修改0-文档0</文档标识符>" +
|
||
" <文档序号>0</文档序号>" +
|
||
" <文档数据 文档数据ID=\"修改0-文档0-文档数据0\">" +
|
||
" <编码 编码ID=\"修改0-文档0-文档数据0-编码0\">" +
|
||
" <电子属性>" +
|
||
" <格式信息>" + file_type + "</格式信息>" +
|
||
" <计算机文件名>" + file_name_server + "</计算机文件名>" +
|
||
" <计算机文件大小>406.57</计算机文件大小>" +
|
||
" </电子属性>" +
|
||
" <编码描述>本封装包中</编码描述>" +
|
||
" <反编码关键字>base64</反编码关键字>" +
|
||
" <编码数据>" + encodeStr + "</编码数据>" +
|
||
" </编码>" +
|
||
" </文档数据>" +
|
||
" </文档>";
|
||
result = result + wendangXml;
|
||
}
|
||
return result;
|
||
}
|
||
|
||
private List<Map<String, Object>> getTableDataFileList(String tableName, String recId) {
|
||
List<Map<String, Object>> mapList = null;
|
||
//得到源头表数据列表
|
||
Map<String, Object> parasMap = new HashMap<String, Object>();
|
||
parasMap.put("tableName", tableName + "_file");
|
||
parasMap.put("conditionSql", " 1=1 and rec_id=" + recId + " and file_status=1");
|
||
mapList = danganguanliMapper.selectObject(parasMap);
|
||
return mapList;
|
||
}
|
||
|
||
private List<Map<String, Object>> getTableDataList(String tableName, String ids) {
|
||
List<Map<String, Object>> mapList = null;
|
||
//得到源头表数据列表
|
||
Map<String, Object> parasMap = new HashMap<String, Object>();
|
||
parasMap.put("tableName", tableName);
|
||
parasMap.put("conditionSql", " 1=1 and id in (" + ids + ") ");
|
||
mapList = danganguanliMapper.selectObject(parasMap);
|
||
return mapList;
|
||
}
|
||
|
||
|
||
private Map<String, Object> getTableData(Integer classId, Integer id) {
|
||
Map<String, Object> map = null;
|
||
//获取文件的对象信息
|
||
List<Map<String, Object>> sourceMapList = danganguanliMapper.selectTabByClassId(classId);
|
||
//先假定只有一条,文书简化类
|
||
Map<String, Object> sourceMap = sourceMapList.get(0);
|
||
//表名称为:
|
||
String source_table_name = sourceMap.get("TABLE_NAME").toString();
|
||
//得到源头表数据列表
|
||
Map<String, Object> parasMap = new HashMap<String, Object>();
|
||
parasMap.put("tableName", source_table_name + "_temp");
|
||
parasMap.put("conditionSql", " 1=1 and id= " + id);
|
||
List<Map<String, Object>> dataList = danganguanliMapper.selectObject(parasMap);
|
||
map = dataList.get(0);
|
||
return map;
|
||
}
|
||
|
||
|
||
@Transactional
|
||
public AjaxJson<Object> transfer(String outPath,
|
||
Integer classId,
|
||
String ids,
|
||
HttpServletRequest request1,
|
||
HttpServletResponse response) {
|
||
AjaxJson<Object> result = null;
|
||
try {
|
||
result = new AjaxJson<>();
|
||
List<TtableDescription> tableDescriptionList = commonService.selectTtableDesByClassId(classId);
|
||
if (tableDescriptionList.size() == 1) { //1层
|
||
String tableName = tableDescriptionList.get(0).getTableName();
|
||
//得到主表数据列表
|
||
Map<String, Object> parasMap = new HashMap<String, Object>();
|
||
parasMap.put("tableName", tableName);
|
||
parasMap.put("conditionSql", " id in ( " + ids + " )");
|
||
List<Map<String, Object>> dataList = danganguanliMapper.selectObject(parasMap);
|
||
String path = outPath + File.separator + "Disk1" + File.separator;
|
||
String fileName2 = "文件目录.xml";
|
||
FileUtil.makedir(path);
|
||
FileUtils.writeStringToFile(new File(path + fileName2), getContentFileDirectory(dataList, tableName), "UTF-8");
|
||
|
||
for (Map<String, Object> map0 : dataList) {
|
||
String id = StringUtil.formatMap(map0, "id");
|
||
String path_dianziquanwen = path + StringUtil.formatMap(map0, "archive_no") + File.separator;
|
||
FileUtil.makedir(path_dianziquanwen);
|
||
//得到主表--原文图片数据列表
|
||
Map<String, Object> parasMapFile = new HashMap<String, Object>();
|
||
parasMapFile.put("tableName", tableName + "_file");
|
||
parasMapFile.put("conditionSql", " rec_id in ( " + id + " ) and file_status=1 ");
|
||
List<Map<String, Object>> dataFileList = danganguanliMapper.selectObject(parasMapFile);
|
||
for (Map<String, Object> map : dataFileList) {
|
||
String file_name_server = StringUtil.formatMap(map, "file_name_server");
|
||
String newName_pdf = file_name_server.replace(".jpg", ".pdf");
|
||
String newName = file_name_server.replace(".jpg", "");
|
||
String file_path = StringUtil.formatMap(map, "file_path");
|
||
String file_des = StringUtil.formatMap(map, "file_des");
|
||
//String dir = imgUpload + file_path + File.separator;
|
||
String dir = file_des + File.separator;
|
||
// if (file_name_server.contains(".jpg")){
|
||
// JSONArray a = new JSONArray();
|
||
// PDFFileToImage.pdf2Image(a, new File(dir+newName_pdf), path_dianziquanwen, newName, "jpg");
|
||
// }else{
|
||
// FileTool.copyTo(dir + file_name_server, path_dianziquanwen + file_name_server);
|
||
// }
|
||
FileTool.copyTo(dir + file_name_server, path_dianziquanwen + file_name_server);
|
||
}
|
||
}
|
||
} else if (tableDescriptionList.size() == 2) { //第二层
|
||
String tableName1 = tableDescriptionList.get(0).getTableName();
|
||
String tableName2 = tableDescriptionList.get(1).getTableName();
|
||
|
||
//得到主表表数据列表(第一层)
|
||
Map<String, Object> parasMap = new HashMap<String, Object>();
|
||
parasMap.put("tableName", tableName1);
|
||
parasMap.put("conditionSql", " id in ( " + ids + ")");
|
||
List<Map<String, Object>> dataList = danganguanliMapper.selectObject(parasMap);
|
||
|
||
//得到主表表数据列表(第二层)
|
||
Map<String, Object> parasMap2 = new HashMap<String, Object>();
|
||
parasMap2.put("tableName", tableName2);
|
||
parasMap2.put("conditionSql", " pid in ( " + ids + ")");
|
||
List<Map<String, Object>> dataList2 = danganguanliMapper.selectObject(parasMap2);
|
||
|
||
String path = outPath + File.separator + "Disk1" + File.separator;
|
||
String fileName1 = "案卷目录.xml";
|
||
String fileName2 = "文件目录.xml";
|
||
FileUtil.makedir(path);
|
||
FileUtils.writeStringToFile(new File(path + fileName1), getContentFileDirectoryChuangtong(dataList, tableName1), "UTF-8");
|
||
FileUtils.writeStringToFile(new File(path + fileName2), getContentFileDirectory(dataList2, tableName2), "UTF-8");
|
||
for (Map<String, Object> map5 : dataList) {
|
||
String id = StringUtil.formatMap(map5, "id");
|
||
String folder_no = StringUtil.formatMap(map5, "folder_no");
|
||
//下面是原文图片(案卷)
|
||
//得到主表数据列表
|
||
Map<String, Object> parasMapFile = new HashMap<String, Object>();
|
||
parasMapFile.put("tableName", tableName1 + "_file");
|
||
parasMapFile.put("conditionSql", " file_status=1 and rec_id= " + id);
|
||
List<Map<String, Object>> dataFileList = danganguanliMapper.selectObject(parasMapFile);
|
||
for (Map<String, Object> map : dataFileList) {
|
||
String file_name_server = StringUtil.formatMap(map, "file_name_server");
|
||
String newName_pdf = file_name_server.replace(".jpg", ".pdf");
|
||
String newName = file_name_server.replace(".jpg", "");
|
||
String file_path = StringUtil.formatMap(map, "file_path");
|
||
String file_des = StringUtil.formatMap(map, "file_des");
|
||
//String dir = imgUpload + file_path + File.separator;
|
||
String dir = file_des + File.separator;
|
||
String path1 = outPath + File.separator + "Disk1" + File.separator + "案卷目录" + File.separator + folder_no + File.separator;
|
||
FileUtil.makedir(path1);
|
||
// if (file_name_server.contains(".jpg")){
|
||
// JSONArray a = new JSONArray();
|
||
// PDFFileToImage.pdf2Image(a, new File(dir+newName_pdf), path1, newName, "jpg");
|
||
// }else{
|
||
// FileTool.copyTo(dir + file_name_server, path1 + file_name_server);
|
||
// }
|
||
FileTool.copyTo(dir + file_name_server, path1 + file_name_server);
|
||
}
|
||
|
||
//下面是原文图片(卷内)
|
||
//得到主表数据列表
|
||
Map<String, Object> parasMapFile2 = new HashMap<String, Object>();
|
||
parasMapFile2.put("tableName", tableName2);
|
||
parasMapFile2.put("conditionSql", " pid= " + id);
|
||
List<Map<String, Object>> dataFileList2 = danganguanliMapper.selectObject(parasMapFile2);
|
||
for (Map<String, Object> map1 : dataFileList2) {
|
||
String myid = StringUtil.formatMap(map1, "id");
|
||
String archive_no = StringUtil.formatMap(map1, "archive_no");
|
||
//卷内-原文
|
||
Map<String, Object> parasMapFile3 = new HashMap<String, Object>();
|
||
parasMapFile3.put("tableName", tableName2 + "_file");
|
||
parasMapFile3.put("conditionSql", " file_status=1 and rec_id= " + myid);
|
||
List<Map<String, Object>> dataFileList3 = danganguanliMapper.selectObject(parasMapFile3);
|
||
String path2 = outPath + File.separator + "Disk1" + File.separator + "文件目录" + File.separator + archive_no + File.separator;
|
||
FileUtil.makedir(path2);
|
||
for (Map<String, Object> map2 : dataFileList3) {
|
||
String file_name_server2 = StringUtil.formatMap(map2, "file_name_server");
|
||
String newName_pdf = file_name_server2.replace(".jpg", ".pdf");
|
||
String newName = file_name_server2.replace(".jpg", "");
|
||
String file_path2 = StringUtil.formatMap(map2, "file_path");
|
||
String file_des = StringUtil.formatMap(map2, "file_des");
|
||
// imgUpload
|
||
//String dir2 = imgUpload + file_path2 + File.separator;
|
||
String dir2 = file_des + File.separator;
|
||
// if (file_name_server2.contains(".jpg")){
|
||
// JSONArray a = new JSONArray();
|
||
// PDFFileToImage.pdf2Image(a, new File(dir2+newName_pdf), path2, newName, "jpg");
|
||
// }else{
|
||
// FileTool.copyTo(dir2 + file_name_server2, path2 + file_name_server2);
|
||
// }
|
||
FileTool.copyTo(dir2 + file_name_server2, path2 + file_name_server2);
|
||
}
|
||
}
|
||
}
|
||
} else if (tableDescriptionList.size() == 3) { //第三层
|
||
String tableName1 = tableDescriptionList.get(0).getTableName();
|
||
String tableName2 = tableDescriptionList.get(1).getTableName();
|
||
String tableName3 = tableDescriptionList.get(2).getTableName();
|
||
|
||
//得到主表表数据列表(第一层)-项目
|
||
Map<String, Object> parasMap = new HashMap<String, Object>();
|
||
parasMap.put("tableName", tableName1);
|
||
parasMap.put("conditionSql", " id in ( " + ids + ")");
|
||
List<Map<String, Object>> dataList = danganguanliMapper.selectObject(parasMap);
|
||
|
||
//得到主表表数据列表(第二层)-案卷
|
||
Map<String, Object> parasMap2 = new HashMap<String, Object>();
|
||
parasMap2.put("tableName", tableName2);
|
||
parasMap2.put("conditionSql", " pid in ( " + ids + ")");
|
||
List<Map<String, Object>> dataList2 = danganguanliMapper.selectObject(parasMap2);
|
||
|
||
String ids222 = "";
|
||
for (Map<String, Object> map22 : dataList2) {
|
||
String id = StringUtil.formatMap(map22, "id");
|
||
ids222 = ids222 + id + ",";
|
||
}
|
||
ids222 = ids222.substring(0, ids222.length() - 1);
|
||
|
||
//得到主表表数据列表(第三层)-卷内
|
||
Map<String, Object> parasMap3 = new HashMap<String, Object>();
|
||
parasMap3.put("tableName", tableName3);
|
||
parasMap3.put("conditionSql", " pid in ( " + ids222 + ")");
|
||
List<Map<String, Object>> dataList3 = danganguanliMapper.selectObject(parasMap3);
|
||
|
||
String path = outPath + File.separator + "Disk1" + File.separator;
|
||
String fileName1 = "项目目录.xml";
|
||
String fileName2 = "案卷目录.xml";
|
||
String fileName3 = "文件目录.xml";
|
||
FileUtil.makedir(path);
|
||
FileUtils.writeStringToFile(new File(path + fileName1), getContentFileDirectoryXiangmu(dataList, tableName1), "UTF-8");
|
||
FileUtils.writeStringToFile(new File(path + fileName2), getContentFileDirectoryChuangtong(dataList2, tableName2), "UTF-8");
|
||
FileUtils.writeStringToFile(new File(path + fileName3), getContentFileDirectory(dataList3, tableName3), "UTF-8");
|
||
|
||
// for (Map<String, Object> map:dataList) {
|
||
// String id = StringUtil.formatMap(map, "id");
|
||
// String item_id = StringUtil.formatMap(map, "item_id");
|
||
// String fonds_no = StringUtil.formatMap(map, "fonds_no");
|
||
// String bianhao=fonds_no+"_"+item_id;
|
||
// //项目-原文
|
||
// Map<String, Object> parasMapFile30 = new HashMap<String, Object>();
|
||
// parasMapFile30.put("tableName", tableName1 + "_file");
|
||
// parasMapFile30.put("conditionSql", " file_status=1 and rec_id= " + id);
|
||
// List<Map<String, Object>> dataFileList1 = danganguanliMapper.selectObject(parasMapFile30);
|
||
// String path2 = outPath + File.separator + "Disk1" + File.separator + "项目目录" + File.separator + bianhao + File.separator;
|
||
// FileUtil.makedir(path2);
|
||
// for (Map<String, Object> map2 : dataFileList1) {
|
||
// String file_name_server2 = StringUtil.formatMap(map2, "file_name_server");
|
||
// String newName_pdf = file_name_server2.replace(".jpg", ".pdf");
|
||
// String newName = file_name_server2.replace(".jpg", "");
|
||
// String file_path2 = StringUtil.formatMap(map2, "file_path");
|
||
// // imgUpload
|
||
// String dir2 = imgUpload + file_path2 + File.separator;
|
||
// FileTool.copyTo(dir2 + file_name_server2, path2 + file_name_server2);
|
||
// }
|
||
// }
|
||
|
||
for (Map<String, Object> map5 : dataList2) {
|
||
String id = StringUtil.formatMap(map5, "id");
|
||
// String folder_no = StringUtil.formatMap(map5, "folder_no");
|
||
// //下面是原文图片(案卷)
|
||
// //得到主表数据列表
|
||
// Map<String, Object> parasMapFile22 = new HashMap<String, Object>();
|
||
// parasMapFile22.put("tableName", tableName2 + "_file");
|
||
// parasMapFile22.put("conditionSql", " file_status=1 and rec_id= " + id);
|
||
// List<Map<String, Object>> dataFileList = danganguanliMapper.selectObject(parasMapFile22);
|
||
// for (Map<String, Object> map : dataFileList) {
|
||
// String file_name_server = StringUtil.formatMap(map, "file_name_server");
|
||
// String newName_pdf = file_name_server.replace(".jpg", ".pdf");
|
||
// String newName = file_name_server.replace(".jpg", "");
|
||
// String file_path = StringUtil.formatMap(map, "file_path");
|
||
// String dir = imgUpload + file_path + File.separator;
|
||
// String path1 = outPath + File.separator + "Disk1" + File.separator + "案卷目录" + File.separator + folder_no + File.separator;
|
||
// FileUtil.makedir(path1);
|
||
// FileTool.copyTo(dir + file_name_server, path1 + file_name_server);
|
||
// }
|
||
|
||
//下面是原文图片(卷内)
|
||
//得到主表数据列表
|
||
Map<String, Object> parasMapFile23 = new HashMap<String, Object>();
|
||
parasMapFile23.put("tableName", tableName3);
|
||
parasMapFile23.put("conditionSql", " pid= " + id);
|
||
List<Map<String, Object>> dataFileList2 = danganguanliMapper.selectObject(parasMapFile23);
|
||
for (Map<String, Object> map1 : dataFileList2) {
|
||
String myid = StringUtil.formatMap(map1, "id");
|
||
String archive_no = StringUtil.formatMap(map1, "archive_no");
|
||
//卷内-原文
|
||
Map<String, Object> parasMapFile33 = new HashMap<String, Object>();
|
||
parasMapFile33.put("tableName", tableName3 + "_file");
|
||
parasMapFile33.put("conditionSql", " file_status=1 and rec_id= " + myid);
|
||
List<Map<String, Object>> dataFileList3 = danganguanliMapper.selectObject(parasMapFile33);
|
||
String path2 = outPath + File.separator + "Disk1" + File.separator + "文件目录" + File.separator + archive_no + File.separator;
|
||
FileUtil.makedir(path2);
|
||
for (Map<String, Object> map2 : dataFileList3) {
|
||
String file_name_server2 = StringUtil.formatMap(map2, "file_name_server");
|
||
String newName_pdf = file_name_server2.replace(".jpg", ".pdf");
|
||
String newName = file_name_server2.replace(".jpg", "");
|
||
String file_path2 = StringUtil.formatMap(map2, "file_path");
|
||
String file_des = StringUtil.formatMap(map2, "file_des");
|
||
// imgUpload
|
||
//String dir2 = imgUpload + file_path2 + File.separator;
|
||
String dir2 = file_des + File.separator;
|
||
FileTool.copyTo(dir2 + file_name_server2, path2 + file_name_server2);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
} catch (Exception e) {
|
||
result = AjaxJson.returnExceptionInfo("移交失败:" + e);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
//*******************start***********************简化
|
||
|
||
/**
|
||
* 文件目录
|
||
*
|
||
* @param dataList
|
||
* @return
|
||
*/
|
||
private String getContentFileDirectory(List<Map<String, Object>> dataList, String tableName) {
|
||
String result = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
|
||
"\n" +
|
||
"<文件目录>\n" + getContent(dataList, tableName) + "</文件目录>\n";
|
||
return result;
|
||
}
|
||
|
||
|
||
private String getContent(List<Map<String, Object>> dataList, String tableName) {
|
||
String result = "";
|
||
for (Map<String, Object> map : dataList) {
|
||
String ziduanbiaoqianContent = ziduanbiaoqian(tableName, map);
|
||
String content = "<文件>\n" +
|
||
ziduanbiaoqianContent
|
||
+ " </文件>\n";
|
||
result = result + content;
|
||
}
|
||
return result;
|
||
}
|
||
|
||
|
||
//字段标签
|
||
private String ziduanbiaoqian(String tableName, Map<String, Object> map) {
|
||
String result = "";
|
||
List<TtableStructDescription> structDescriptionList = commonService.selectTableStructDesByTableName(tableName);
|
||
for (TtableStructDescription ttableStructDescription : structDescriptionList) {
|
||
result = result + " <" + ttableStructDescription.getColumnChnName() + ">" + StringUtil.formatMap(map, ttableStructDescription.getColumnName()) + "</" + ttableStructDescription.getColumnChnName() + ">\n";
|
||
}
|
||
return result;
|
||
}
|
||
|
||
//*******************end***********************简化
|
||
|
||
//------案卷目录-------------start---------传统
|
||
|
||
private String getContentFileDirectoryChuangtong(List<Map<String, Object>> dataList, String tableName) {
|
||
String result = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
|
||
"\n" +
|
||
"<档案目录>\n" + getContentChuangtong(dataList, tableName) + "</档案目录>\n";
|
||
return result;
|
||
}
|
||
|
||
private String getContentChuangtong(List<Map<String, Object>> dataList, String tableName) {
|
||
String result = "";
|
||
for (Map<String, Object> map : dataList) {
|
||
String ziduanbiaoqianContent = ziduanbiaoqian(tableName, map);
|
||
String content = "<档案>\n" +
|
||
ziduanbiaoqianContent
|
||
+ " </档案>\n";
|
||
result = result + content;
|
||
}
|
||
return result;
|
||
}
|
||
|
||
//------案卷目录-------------end---------传统
|
||
|
||
//=======================start=======================项目目录
|
||
|
||
|
||
private String getContentFileDirectoryXiangmu(List<Map<String, Object>> dataList, String tableName) {
|
||
String result = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
|
||
"\n" +
|
||
"<项目目录>\n" + getContentXiangmu(dataList, tableName) + "</项目目录>\n";
|
||
return result;
|
||
}
|
||
|
||
private String getContentXiangmu(List<Map<String, Object>> dataList, String tableName) {
|
||
String result = "";
|
||
for (Map<String, Object> map : dataList) {
|
||
String ziduanbiaoqianContent = ziduanbiaoqian(tableName, map);
|
||
String content = "<项目>\n" +
|
||
ziduanbiaoqianContent
|
||
+ " </项目>\n";
|
||
result = result + content;
|
||
}
|
||
return result;
|
||
}
|
||
|
||
//=======================end=======================项目目录
|
||
|
||
|
||
//==================================================================
|
||
|
||
|
||
/**
|
||
* 归档章
|
||
*
|
||
* @param id
|
||
* @return
|
||
*/
|
||
@Transactional
|
||
public AjaxJson<Object> archiveSeal(Integer id,
|
||
String tableName,
|
||
Integer fileId,
|
||
String archiveNo,
|
||
HttpServletRequest request) {
|
||
AjaxJson<Object> result = null;
|
||
try {
|
||
result = new AjaxJson<>();
|
||
//得到temp表数据列表
|
||
Map<String, Object> parasMap = new HashMap<String, Object>();
|
||
parasMap.put("tableName", tableName + "_temp");
|
||
parasMap.put("conditionSql", " 1=1 and id= " + id);
|
||
List<Map<String, Object>> dataList = danganguanliMapper.selectObject(parasMap);
|
||
Map<String, Object> temp_map = dataList.get(0);
|
||
//全宗号+归档年度+件号+实体分类号(中文)+保管期限(中文)+页数(图片总数)
|
||
//全宗号
|
||
String fonds_no = StringUtil.formatMap(temp_map, "fonds_no");
|
||
//归档年度
|
||
String filing_year = StringUtil.formatMap(temp_map, "filing_year");
|
||
//件号
|
||
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());
|
||
}
|
||
//保管期限(中文)
|
||
String retention = StringUtil.formatMap(temp_map, "retention");
|
||
//页数(图片总数)
|
||
String quantity = StringUtil.formatMap(temp_map, "quantity");
|
||
|
||
//request.getRealPath("/uploadFile/")
|
||
String dir = imgUpload + File.separator + "uploadFile" + File.separator + tableName + "_temp_file" + File.separator + fonds_no + File.separator + id + File.separator;
|
||
|
||
// 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>();
|
||
parasMap2.put("tableName", tableName + "_temp_file");
|
||
parasMap2.put("conditionSql", " 1=1 and id= " + fileId);
|
||
List<Map<String, Object>> dataList2 = danganguanliMapper.selectObject(parasMap2);
|
||
Map<String, Object> tempFile_map = dataList2.get(0);
|
||
|
||
String file_name_server = StringUtil.formatMap(tempFile_map, "file_name_server");
|
||
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;
|
||
String target = dir + file_name_server_pdf;
|
||
|
||
//判断此文件是否存在
|
||
File file = new File(source);
|
||
File file1 = new File(target);
|
||
if (!file.exists()) {
|
||
source = dir1 + file_name_server_pdf_original;
|
||
}
|
||
if (!file1.exists()) {
|
||
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, "2", 1);
|
||
//pdf转ofd
|
||
// String newName_ofd = target.replace(".pdf", ".ofd");
|
||
// PdfToOfdUtil.pdfToOfd(target, newName_ofd);
|
||
|
||
|
||
} catch (Exception e) {
|
||
result = AjaxJson.returnExceptionInfo("归档章失败:" + e);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 撤回归档章
|
||
*/
|
||
@Transactional
|
||
public AjaxJson<Object> withdrawArchiveSeal(String path, String fileNameServer) {
|
||
try {
|
||
if (StringUtils.isEmpty(path) || StringUtils.isEmpty(fileNameServer)) {
|
||
return AjaxJson.returnExceptionInfo("缺少必填项");
|
||
}
|
||
//源文件名称
|
||
String sourceFile = fileNameServer.replace(fileNameServer.substring(fileNameServer.lastIndexOf("."), fileNameServer.length()), "_original.pdf");
|
||
// 归档章文件名称
|
||
String targetFile = fileNameServer.replace(fileNameServer.substring(fileNameServer.lastIndexOf("."), fileNameServer.length()), ".pdf");
|
||
//原文件路径
|
||
String source = imgUpload + path + "/" + sourceFile;
|
||
//归公章路径
|
||
String targe = imgUpload + path + "/" + targetFile;
|
||
//判断此文件是否存在
|
||
File file = new File(source);
|
||
if (!file.exists()) {
|
||
return AjaxJson.returnExceptionInfo("该文件不支持撤回归档章操作");
|
||
}
|
||
//替换归公章文件
|
||
FileUtil2.copyFile(source, targe);
|
||
} catch (Exception e) {
|
||
return AjaxJson.returnExceptionInfo("撤回归档章异常" + e);
|
||
}
|
||
return new AjaxJson<>();
|
||
}
|
||
|
||
/**
|
||
* 合并文件-pdf
|
||
* 1、第一张要有规党章,
|
||
* 2、加编号,规则为:奇数页号码在右上角,偶数页号码在左上角
|
||
*
|
||
* @param fondscode
|
||
* @param fileIds
|
||
* @return
|
||
*/
|
||
@Transactional
|
||
public AjaxJson<Object> mergeFile(String fondscode,
|
||
Integer id,
|
||
String fileIds,
|
||
String tableName,
|
||
String archiveNo,
|
||
HttpServletRequest request) {
|
||
AjaxJson<Object> result = null;
|
||
try {
|
||
result = new AjaxJson<>();
|
||
//判断已经合并pdf成功了,就不能再合并了
|
||
Map<String, Object> parasMap5 = new HashMap<String, Object>();
|
||
parasMap5.put("tableName", tableName + "_temp_file");
|
||
parasMap5.put("conditionSql", " rec_id =" + id + " and file_status=1 and file_type='pdf' ");
|
||
List<Map<String, Object>> dataList5 = danganguanliMapper.selectObject(parasMap5);
|
||
if (dataList5 != null && dataList5.size() > 0) {
|
||
result = AjaxJson.returnExceptionInfo("合并文件pdf已存在!");
|
||
return result;
|
||
}
|
||
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>();
|
||
parasMap2.put("tableName", tableName + "_temp_file");
|
||
if (fileIds != null && !"".equals(fileIds)) {
|
||
parasMap2.put("conditionSql", " id in (" + fileIds + " )");
|
||
} else {
|
||
parasMap2.put("conditionSql", " file_status=1 and rec_id= " + id);
|
||
}
|
||
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()];
|
||
int i = 0;
|
||
for (Map<String, Object> tempFile_map : dataList2) {
|
||
String file_name_server = StringUtil.formatMap(tempFile_map, "file_name_server");
|
||
String file_name_server_pdf = file_name_server.replace(".jpg", "_original.pdf");
|
||
String srcpdfPath = dir + File.separator + file_name_server_pdf;
|
||
//判断是否存在
|
||
File file = new File(srcpdfPath);
|
||
if (!file.exists()) {
|
||
srcpdfPath = dir1 + file_name_server_pdf;
|
||
fileArray[i] = srcpdfPath;
|
||
i++;
|
||
} else {
|
||
fileArray[i] = srcpdfPath;
|
||
i++;
|
||
}
|
||
|
||
}
|
||
String tarFile = temp_pdf + StringUtil.generaterUUID() + ".pdf";
|
||
PdfFileHelper.mergePdf(fileArray, tarFile);
|
||
|
||
//要加编号
|
||
String tarFile2 = temp_pdf + StringUtil.generaterUUID() + ".pdf";
|
||
PdfFileHelper.pageNo(tarFile, tarFile2);
|
||
|
||
//加归档章
|
||
//得到temp表数据列表
|
||
Map<String, Object> parasMap = new HashMap<String, Object>();
|
||
parasMap.put("tableName", tableName + "_temp");
|
||
parasMap.put("conditionSql", " 1=1 and id= " + id);
|
||
List<Map<String, Object>> dataList = danganguanliMapper.selectObject(parasMap);
|
||
Map<String, Object> temp_map = dataList.get(0);
|
||
//全宗号+归档年度+件号+实体分类号(中文)+保管期限(中文)+页数(图片总数)
|
||
//全宗号
|
||
String fonds_no = StringUtil.formatMap(temp_map, "fonds_no");
|
||
//归档年度
|
||
String filing_year = StringUtil.formatMap(temp_map, "filing_year");
|
||
//件号
|
||
String piece_no = StringUtil.formatMap(temp_map, "piece_no");
|
||
//实体分类号(中文)
|
||
String archive_ctg_no = StringUtil.formatMap(temp_map, "archive_ctg_no");
|
||
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());
|
||
}
|
||
//保管期限(中文)
|
||
String retention = StringUtil.formatMap(temp_map, "retention");
|
||
//页数(图片总数)
|
||
String quantity = StringUtil.formatMap(temp_map, "quantity");
|
||
|
||
String myuuid = StringUtil.generaterUUID();
|
||
FileUtil2.makedir(dir + File.separator);
|
||
String target = dir + File.separator + myuuid + ".pdf";
|
||
String[][] textContent = {{fonds_no, filing_year, piece_no}, {archive_ctg_no, retention, quantity}};
|
||
PdfFileHelper.Seal(tarFile2, target, 1, textContent, "1", 2);
|
||
//pdf转ofd
|
||
String newName_ofd = target.replace(".pdf", ".ofd");
|
||
PdfToOfdUtil.pdfToOfd(target, newName_ofd);
|
||
|
||
//最后把合并的pdf文件添加到temp_file中
|
||
String fieldName =
|
||
"rec_id, " +
|
||
"file_name, " +
|
||
"file_name_server, " +
|
||
"file_path, " +
|
||
"file_type," +
|
||
"page_no," +
|
||
"file_status";
|
||
String valueName =
|
||
"" + id + "," +
|
||
"'合并文件.pdf'," +
|
||
"'" + myuuid + ".pdf'," +
|
||
"'" + relative_path + "'," +
|
||
"'pdf'," +
|
||
"-1," +
|
||
"1";
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
map.put("tableName", tableName + "_temp_file");
|
||
map.put("fieldName", fieldName);
|
||
map.put("valueName", valueName);
|
||
danganguanliMapper.saveObject(map);
|
||
|
||
//最后temp表archive_file_num字段要加1
|
||
String fieldValue = " archive_file_num=archive_file_num+1 ";
|
||
String conditionSql = " id='" + id + "'";
|
||
Map<String, Object> map7 = new HashMap<String, Object>();
|
||
map7.put("tableName", tableName + "_temp");
|
||
map7.put("fieldValue", fieldValue);
|
||
map7.put("conditionSql", conditionSql);
|
||
danganguanliMapper.updateObject(map7);
|
||
} catch (Exception e) {
|
||
result = AjaxJson.returnExceptionInfo("合并文件失败:" + e);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 合并下载
|
||
* 1、每页上必须有水印,
|
||
* 2、图片有规党章就有,没有就没有
|
||
*
|
||
* @param fondscode
|
||
* @param id
|
||
* @param tableName
|
||
* @return
|
||
*/
|
||
public void mergeDownload(String fondscode,
|
||
Integer id,
|
||
String fileIds,
|
||
String tableName,
|
||
String archiveNo,
|
||
HttpServletRequest request,
|
||
HttpServletResponse response,
|
||
Integer type) {
|
||
try {
|
||
String relative_path = "uploadFile/" + tableName + "_temp_file/" + fondscode + "/" + id;
|
||
String dir = imgUpload + File.separator + relative_path;
|
||
String dir1 = imgUpload + File.separator + "uploadFile" + File.separator + archiveNo + File.separator;
|
||
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()];
|
||
UserRole userRole = userService.getUserRole(request);
|
||
String userChnName = userRole.getUser().getUserChnName();
|
||
int i = 0;
|
||
for (Map<String, Object> tempFile_map : dataList2) {
|
||
String file_name_server = StringUtil.formatMap(tempFile_map, "file_name_server");
|
||
String file_des = StringUtil.formatMap(tempFile_map, "file_des");
|
||
String srcImg = file_des + File.separator + file_name_server;
|
||
|
||
String srcpdfPath = destFilePdf(srcImg, userChnName);
|
||
|
||
fileArray[i] = srcpdfPath;
|
||
i++;
|
||
}
|
||
String tarFile = temp_pdf + StringUtil.generaterUUID() + ".pdf";
|
||
PdfFileHelper.mergePdf(fileArray, tarFile);
|
||
|
||
String srcFile2 = tarFile;
|
||
String tarFile2 = temp_pdf + "setWaterMark-" + DateUtil.date2String(new Date(), 3) + ".pdf";
|
||
FileUtil.download(srcFile2, response);
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
|
||
private String destFilePdf(String srcImg, String userChnName) {
|
||
String destImg = srcImg.replaceAll(".jpg", "_waterMark.jpg");
|
||
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坐标修正值。 默认在中间,偏移量相对于中间偏移
|
||
0, //y坐标修正值。 默认在中间,偏移量相对于中间偏移
|
||
0.3f//透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字
|
||
);
|
||
String fromPath = destImg;
|
||
String toSource = destImg.replaceAll(".jpg", ".pdf");
|
||
Img2pdf.jpg2pdfSortedByFilename(fromPath, toSource);
|
||
return toSource;
|
||
}
|
||
|
||
|
||
public void downloadExcel(String ids, String mapOne, String tableName, String funcTypeCode, HttpServletResponse response) {
|
||
try {
|
||
Map<String, Object> mapTwo = JSON.parseObject(mapOne);
|
||
response.setHeader("Pragma", "No-cache");
|
||
response.setHeader("Cache-Control", "no-cache");
|
||
response.setDateHeader("Expires", 0);
|
||
response.reset();
|
||
response.setContentType("application/x-msdownload; charset=utf-8");
|
||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
||
String fileName = new String("导出excel".getBytes("utf-8"), "ISO-8859-1") + sdf.format(new Date()) + ".xls";
|
||
response.setHeader("Content-disposition", "attachment; filename=" + fileName);
|
||
|
||
List<TtableStructDescription> ttableStructDescriptionList = commonService.selectTableStructDesByTableName(tableName);
|
||
|
||
String[] columnsTitle = new String[ttableStructDescriptionList.size()];
|
||
String fieldName = "";
|
||
int j = 0;
|
||
for (TtableStructDescription tableStructDescription : ttableStructDescriptionList) {
|
||
columnsTitle[j] = tableStructDescription.getColumnChnName();
|
||
fieldName = fieldName + "" + tableStructDescription.getColumnName() + ",";
|
||
j++;
|
||
}
|
||
|
||
fieldName = fieldName.substring(0, fieldName.length() - 1);
|
||
|
||
String cols[] = fieldName.split(",");
|
||
HSSFWorkbook wb = new HSSFWorkbook();
|
||
HSSFSheet sheet = wb.createSheet("文书传统整理");
|
||
HSSFRow row = sheet.createRow(0);
|
||
for (int i = 0; i < cols.length; i++) {
|
||
HSSFCell cell = row.createCell(i);
|
||
sheet.setColumnWidth(i, 4000);
|
||
cell.setCellValue(columnsTitle[i]);
|
||
}
|
||
Map<String, Object> parasMap2 = new HashMap<String, Object>();
|
||
if (funcTypeCode == null || "".equals(funcTypeCode)) {
|
||
parasMap2.put("tableName", tableName);
|
||
} else {
|
||
parasMap2.put("tableName", tableName + "_" + funcTypeCode);
|
||
}
|
||
if (StringUtils.isEmpty(ids)) {
|
||
if (mapTwo == null || mapTwo.size() == 0) {
|
||
parasMap2.put("conditionSql", "archive_flag = '已组卷'");
|
||
} else {
|
||
StringBuffer conditionSql = new StringBuffer();
|
||
conditionSql.append("1=1");
|
||
Set<Map.Entry<String, Object>> entries = mapTwo.entrySet();
|
||
for (Map.Entry<String, Object> entry : entries) {
|
||
conditionSql.append(" and " + entry.getKey());
|
||
conditionSql.append("=");
|
||
conditionSql.append("'" + entry.getValue() + "'");
|
||
parasMap2.put("conditionSql", conditionSql);
|
||
}
|
||
}
|
||
} else {
|
||
parasMap2.put("conditionSql", " id in ( " + ids + " )");
|
||
}
|
||
|
||
List<Map<String, Object>> dataList = danganguanliMapper.selectObject(parasMap2);
|
||
for (int i = 0; i < dataList.size(); i++) {
|
||
HSSFRow rowi = sheet.createRow(i + 1);
|
||
Map<String, Object> map = dataList.get(i);
|
||
int num = 0;
|
||
for (String key : cols) {
|
||
rowi.createCell(num).setCellValue(StringUtil.formatMap(map, key));
|
||
num++;
|
||
}
|
||
}
|
||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||
wb.write(bos);
|
||
response.setHeader("Content-Length", bos.toByteArray().length + "");
|
||
bos.writeTo(response.getOutputStream());
|
||
response.flushBuffer();
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
|
||
public void downloadExcel(String ids, String mapOne, String tableName, String funcTypeCode, HttpServletRequest request, HttpServletResponse response) {
|
||
try {
|
||
Map<String, Object> mapTwo = JSON.parseObject(mapOne);
|
||
response.setHeader("Pragma", "No-cache");
|
||
response.setHeader("Cache-Control", "no-cache");
|
||
response.setDateHeader("Expires", 0);
|
||
response.reset();
|
||
response.setContentType("application/x-msdownload; charset=utf-8");
|
||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
||
String fileName = new String("导出excel".getBytes("utf-8"), "ISO-8859-1") + sdf.format(new Date()) + ".xls";
|
||
response.setHeader("Content-disposition", "attachment; filename=" + fileName);
|
||
|
||
List<TtableStructDescription> ttableStructDescriptionList = commonService.selectTableStructDesByTableName(tableName);
|
||
|
||
String[] columnsTitle = new String[ttableStructDescriptionList.size()];
|
||
String fieldName = "";
|
||
int j = 0;
|
||
for (TtableStructDescription tableStructDescription : ttableStructDescriptionList) {
|
||
columnsTitle[j] = tableStructDescription.getColumnChnName();
|
||
fieldName = fieldName + "" + tableStructDescription.getColumnName() + ",";
|
||
j++;
|
||
}
|
||
|
||
fieldName = fieldName.substring(0, fieldName.length() - 1);
|
||
|
||
String cols[] = fieldName.split(",");
|
||
HSSFWorkbook wb = new HSSFWorkbook();
|
||
HSSFSheet sheet = wb.createSheet("文书传统整理");
|
||
HSSFRow row = sheet.createRow(0);
|
||
for (int i = 0; i < cols.length; i++) {
|
||
HSSFCell cell = row.createCell(i);
|
||
sheet.setColumnWidth(i, 4000);
|
||
cell.setCellValue(columnsTitle[i]);
|
||
}
|
||
Map<String, Object> parasMap2 = new HashMap<String, Object>();
|
||
if (funcTypeCode == null || "".equals(funcTypeCode)) {
|
||
parasMap2.put("tableName", tableName);
|
||
} else {
|
||
parasMap2.put("tableName", tableName + "_" + funcTypeCode);
|
||
}
|
||
//需要判断全宗号和用户管理员权限
|
||
UserRole userRole = userService.getUserRole(request);
|
||
User user = userRole.getUser();
|
||
if (StringUtils.isEmpty(ids)) {
|
||
if (mapTwo == null || mapTwo.size() == 0) {
|
||
StringBuffer conditionSql = new StringBuffer();
|
||
conditionSql.append(" archive_flag = '已组卷' ");
|
||
//获取用户关联的全宗号
|
||
if (!"admin".equals(user.getUsername())) {
|
||
// Integer id = user.getId();
|
||
List<Fond> fondByUser = fondService.getFondByUser(user.getId());
|
||
if (CollectionUtils.isEmpty(fondByUser)) {
|
||
conditionSql.append(" and " + " fonds_no =" + " xxx");
|
||
} else {
|
||
List<String> collect = fondByUser.stream().map(item -> {
|
||
return "'" + item.getFondscode() + "'";
|
||
}).collect(Collectors.toList());
|
||
String fonds = StringUtils.join(collect.toArray(), ",");
|
||
conditionSql.append(" and " + " fonds_no in ( " + fonds + ")");
|
||
}
|
||
}
|
||
parasMap2.put("conditionSql", conditionSql);
|
||
} else {
|
||
StringBuffer conditionSql = new StringBuffer();
|
||
conditionSql.append("1=1");
|
||
Set<Map.Entry<String, Object>> entries = mapTwo.entrySet();
|
||
for (Map.Entry<String, Object> entry : entries) {
|
||
conditionSql.append(" and " + entry.getKey());
|
||
conditionSql.append("=");
|
||
conditionSql.append("'" + entry.getValue() + "'");
|
||
}
|
||
//获取用户关联的全宗号
|
||
if (!"admin".equals(user.getUsername())) {
|
||
// Integer id = user.getId();
|
||
List<Fond> fondByUser = fondService.getFondByUser(user.getId());
|
||
if (CollectionUtils.isEmpty(fondByUser)) {
|
||
conditionSql.append(" and " + " fonds_no =" + " xxx");
|
||
} else {
|
||
List<String> collect = fondByUser.stream().map(item -> {
|
||
return "'" + item.getFondscode() + "'";
|
||
}).collect(Collectors.toList());
|
||
|
||
String fonds = StringUtils.join(collect.toArray(), ",");
|
||
conditionSql.append(" and " + " fonds_no in ( " + fonds + ")");
|
||
}
|
||
}
|
||
parasMap2.put("conditionSql", conditionSql);
|
||
}
|
||
} else {
|
||
parasMap2.put("conditionSql", " id in ( " + ids + " )");
|
||
}
|
||
|
||
List<Map<String, Object>> dataList = danganguanliMapper.selectObject(parasMap2);
|
||
for (int i = 0; i < dataList.size(); i++) {
|
||
HSSFRow rowi = sheet.createRow(i + 1);
|
||
Map<String, Object> map = dataList.get(i);
|
||
int num = 0;
|
||
for (String key : cols) {
|
||
rowi.createCell(num).setCellValue(StringUtil.formatMap(map, key));
|
||
num++;
|
||
}
|
||
}
|
||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||
wb.write(bos);
|
||
response.setHeader("Content-Length", bos.toByteArray().length + "");
|
||
bos.writeTo(response.getOutputStream());
|
||
response.flushBuffer();
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
|
||
|
||
private List<Map<String, Object>> formatDataList(List<Map<String, Object>> dataList,String funcTypeCode,String tableName){
|
||
List<Map<String, Object>> dataListResult =new ArrayList<>();
|
||
for (Map<String, Object> map:dataList) {
|
||
|
||
String tableNameTiaoMu="";
|
||
String tableNameYuanwen="";
|
||
if (funcTypeCode==null ||"".equals(funcTypeCode)){
|
||
tableNameTiaoMu=tableName;
|
||
tableNameYuanwen=tableName + "_file";
|
||
}else {
|
||
tableNameTiaoMu=tableName + "_" + funcTypeCode;
|
||
tableNameYuanwen=tableName + "_" + funcTypeCode + "_file";
|
||
}
|
||
|
||
String zhujianId=StringUtil.formatMap(map, "id");
|
||
//得到主表--原文图片数据列表
|
||
Map<String, Object> parasMapFile = new HashMap<String, Object>();
|
||
parasMapFile.put("tableName", tableNameYuanwen);
|
||
parasMapFile.put("conditionSql", " rec_id in ( " + zhujianId + " ) and file_status=1 ");
|
||
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");
|
||
|
||
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;
|
||
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";
|
||
}
|
||
dataListResult.add(map);
|
||
// if (!archive_file_num.equals(quantity)){
|
||
// dataListResult.add(map);
|
||
// }
|
||
}
|
||
return dataListResult;
|
||
}
|
||
|
||
public void downloadExcel2(String ids,
|
||
String mapOne,
|
||
String tableName,
|
||
String funcTypeCode,
|
||
String downloadInfo,
|
||
HttpServletRequest request,
|
||
HttpServletResponse response) {
|
||
try {
|
||
Map<String, Object> mapTwo = JSON.parseObject(mapOne);
|
||
JSONObject downloadInfoObj = JSON.parseObject(downloadInfo);
|
||
Integer level=downloadInfoObj.getInteger("level");
|
||
Integer sign=downloadInfoObj.getInteger("sign");
|
||
response.setHeader("Pragma", "No-cache");
|
||
response.setHeader("Cache-Control", "no-cache");
|
||
response.setDateHeader("Expires", 0);
|
||
response.reset();
|
||
response.setContentType("application/x-msdownload; charset=utf-8");
|
||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
||
String fileName = new String("导出excel".getBytes("utf-8"), "ISO-8859-1") + sdf.format(new Date()) + ".xls";
|
||
response.setHeader("Content-disposition", "attachment; filename=" + fileName);
|
||
|
||
//List<TtableStructDescription> ttableStructDescriptionList = commonService.selectTableStructDesByTableName(tableName);
|
||
String cols1 = "";
|
||
if (level == 1) {
|
||
cols1 = "archive_no";
|
||
} else {
|
||
if (sign == 1) {
|
||
cols1 = "folder_no";
|
||
} else if (sign == 2) {
|
||
cols1 = "archive_no";
|
||
}
|
||
}
|
||
String[] columnsTitle = {"档号","原文数量","条目页数"};
|
||
String cols[] = {cols1,"archive_file_num","quantity"};
|
||
HSSFWorkbook wb = new HSSFWorkbook();
|
||
HSSFSheet sheet = wb.createSheet("文书传统整理");
|
||
HSSFRow row = sheet.createRow(0);
|
||
for (int i = 0; i < cols.length; i++) {
|
||
HSSFCell cell = row.createCell(i);
|
||
sheet.setColumnWidth(i, 4000);
|
||
cell.setCellValue(columnsTitle[i]);
|
||
}
|
||
Map<String, Object> parasMap2 = new HashMap<String, Object>();
|
||
if (funcTypeCode == null || "".equals(funcTypeCode)) {
|
||
parasMap2.put("tableName", tableName);
|
||
} else {
|
||
parasMap2.put("tableName", tableName + "_" + funcTypeCode);
|
||
}
|
||
//需要判断全宗号和用户管理员权限
|
||
UserRole userRole = userService.getUserRole(request);
|
||
User user = userRole.getUser();
|
||
if (StringUtils.isEmpty(ids)) {
|
||
if (mapTwo == null || mapTwo.size() == 0) {
|
||
StringBuffer conditionSql = new StringBuffer();
|
||
conditionSql.append(" archive_flag = '已组卷' ");
|
||
//获取用户关联的全宗号
|
||
if (!"admin".equals(user.getUsername())) {
|
||
// Integer id = user.getId();
|
||
List<Fond> fondByUser = fondService.getFondByUser(user.getId());
|
||
if (CollectionUtils.isEmpty(fondByUser)) {
|
||
conditionSql.append(" and " + " fonds_no =" + " xxx");
|
||
} else {
|
||
List<String> collect = fondByUser.stream().map(item -> {
|
||
return "'" + item.getFondscode() + "'";
|
||
}).collect(Collectors.toList());
|
||
String fonds = StringUtils.join(collect.toArray(), ",");
|
||
conditionSql.append(" and " + " fonds_no in ( " + fonds + ")");
|
||
}
|
||
}
|
||
parasMap2.put("conditionSql", conditionSql);
|
||
} else {
|
||
StringBuffer conditionSql = new StringBuffer();
|
||
conditionSql.append("1=1");
|
||
Set<Map.Entry<String, Object>> entries = mapTwo.entrySet();
|
||
for (Map.Entry<String, Object> entry : entries) {
|
||
conditionSql.append(" and " + entry.getKey());
|
||
conditionSql.append("=");
|
||
conditionSql.append("'" + entry.getValue() + "'");
|
||
}
|
||
//获取用户关联的全宗号
|
||
if (!"admin".equals(user.getUsername())) {
|
||
// Integer id = user.getId();
|
||
List<Fond> fondByUser = fondService.getFondByUser(user.getId());
|
||
if (CollectionUtils.isEmpty(fondByUser)) {
|
||
conditionSql.append(" and " + " fonds_no =" + " xxx");
|
||
} else {
|
||
List<String> collect = fondByUser.stream().map(item -> {
|
||
return "'" + item.getFondscode() + "'";
|
||
}).collect(Collectors.toList());
|
||
|
||
String fonds = StringUtils.join(collect.toArray(), ",");
|
||
conditionSql.append(" and " + " fonds_no in ( " + fonds + ")");
|
||
}
|
||
}
|
||
parasMap2.put("conditionSql", conditionSql);
|
||
}
|
||
} else {
|
||
parasMap2.put("conditionSql", " id in ( " + ids + " )");
|
||
}
|
||
List<Map<String, Object>> dataList = danganguanliMapper.selectObject(parasMap2);
|
||
dataList=formatDataList(dataList,funcTypeCode,tableName);
|
||
for (int i = 0; i < dataList.size(); i++) {
|
||
HSSFRow rowi = sheet.createRow(i + 1);
|
||
Map<String, Object> map = dataList.get(i);
|
||
int num = 0;
|
||
for (String key : cols) {
|
||
String cellValue="";
|
||
String val=StringUtil.formatMap(map, key);
|
||
if (val!=null&&!"".equals(val)){
|
||
cellValue=val;
|
||
}else{
|
||
cellValue="0";
|
||
}
|
||
rowi.createCell(num).setCellValue(cellValue);
|
||
num++;
|
||
}
|
||
}
|
||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||
wb.write(bos);
|
||
response.setHeader("Content-Length", bos.toByteArray().length + "");
|
||
bos.writeTo(response.getOutputStream());
|
||
response.flushBuffer();
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
|
||
|
||
|
||
@Transactional
|
||
public AjaxJson<Object> contrastField(String filePath, Integer classId, HttpServletResponse response) {
|
||
AjaxJson<Object> result = null;
|
||
try {
|
||
|
||
List<TtableDescription> list = commonService.selectTtableDesByClassId(classId);
|
||
if (list != null && list.size() == 1) {
|
||
String tableName1 = list.get(0).getTableName();
|
||
List<TtableStructDescription> tableStructDescriptionList = ttableStructDescriptionMapper.selectByTableName(tableName1);
|
||
List<String> stringList = readXML(filePath + "/文件目录.xml");
|
||
for (TtableStructDescription tableStructDes : tableStructDescriptionList) {
|
||
for (String str : stringList) {
|
||
if (tableStructDes.getColumnChnName().equals(str)) {
|
||
tableStructDes.setMyNote(str);
|
||
break;
|
||
} else {
|
||
tableStructDes.setMyNote("");
|
||
}
|
||
}
|
||
}
|
||
result = new AjaxJson<>();
|
||
result.put("list1", tableStructDescriptionList);
|
||
} else if (list != null && list.size() == 2) {
|
||
String tableName1 = list.get(0).getTableName();
|
||
String tableName2 = list.get(1).getTableName();
|
||
List<TtableStructDescription> tableStructDescriptionList1 = ttableStructDescriptionMapper.selectByTableName(tableName1);
|
||
List<TtableStructDescription> tableStructDescriptionList2 = ttableStructDescriptionMapper.selectByTableName(tableName2);
|
||
|
||
List<String> stringList1 = readXML(filePath + "/案卷目录.xml");
|
||
List<String> stringList2 = readXML(filePath + "/文件目录.xml");
|
||
for (TtableStructDescription tableStructDes : tableStructDescriptionList1) {
|
||
for (String str : stringList1) {
|
||
if (tableStructDes.getColumnChnName().equals(str)) {
|
||
tableStructDes.setMyNote(str);
|
||
break;
|
||
} else {
|
||
tableStructDes.setMyNote("");
|
||
}
|
||
}
|
||
}
|
||
for (TtableStructDescription tableStructDes : tableStructDescriptionList2) {
|
||
for (String str : stringList2) {
|
||
if (tableStructDes.getColumnChnName().equals(str)) {
|
||
tableStructDes.setMyNote(str);
|
||
break;
|
||
} else {
|
||
tableStructDes.setMyNote("");
|
||
}
|
||
}
|
||
}
|
||
result = new AjaxJson<>();
|
||
result.put("list1", tableStructDescriptionList1);
|
||
result.put("list2", tableStructDescriptionList2);
|
||
} else if (list != null && list.size() == 3) {
|
||
String tableName1 = list.get(0).getTableName();
|
||
String tableName2 = list.get(1).getTableName();
|
||
String tableName3 = list.get(2).getTableName();
|
||
List<TtableStructDescription> tableStructDescriptionList1 = ttableStructDescriptionMapper.selectByTableName(tableName1);
|
||
List<TtableStructDescription> tableStructDescriptionList2 = ttableStructDescriptionMapper.selectByTableName(tableName2);
|
||
List<TtableStructDescription> tableStructDescriptionList3 = ttableStructDescriptionMapper.selectByTableName(tableName3);
|
||
|
||
List<String> stringList1 = readXML(filePath + "/项目目录.xml");
|
||
List<String> stringList2 = readXML(filePath + "/案卷目录.xml");
|
||
List<String> stringList3 = readXML(filePath + "/文件目录.xml");
|
||
|
||
for (TtableStructDescription tableStructDes : tableStructDescriptionList1) {
|
||
for (String str : stringList1) {
|
||
if (tableStructDes.getColumnChnName().equals(str)) {
|
||
tableStructDes.setMyNote(str);
|
||
break;
|
||
} else {
|
||
tableStructDes.setMyNote("");
|
||
}
|
||
}
|
||
}
|
||
for (TtableStructDescription tableStructDes : tableStructDescriptionList2) {
|
||
for (String str : stringList2) {
|
||
if (tableStructDes.getColumnChnName().equals(str)) {
|
||
tableStructDes.setMyNote(str);
|
||
break;
|
||
} else {
|
||
tableStructDes.setMyNote("");
|
||
}
|
||
}
|
||
}
|
||
|
||
for (TtableStructDescription tableStructDes : tableStructDescriptionList3) {
|
||
for (String str : stringList3) {
|
||
if (tableStructDes.getColumnChnName().equals(str)) {
|
||
tableStructDes.setMyNote(str);
|
||
break;
|
||
} else {
|
||
tableStructDes.setMyNote("");
|
||
}
|
||
}
|
||
}
|
||
|
||
result = new AjaxJson<>();
|
||
result.put("list1", tableStructDescriptionList1);
|
||
result.put("list2", tableStructDescriptionList2);
|
||
result.put("list3", tableStructDescriptionList3);
|
||
}
|
||
} catch (Exception e) {
|
||
result = AjaxJson.returnExceptionInfo("对比字段失败:" + e);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
@Transactional
|
||
public AjaxJson<Object> receiveXmlList(String filePath, Integer classId) {
|
||
AjaxJson<Object> result = null;
|
||
try {
|
||
List<TtableDescription> list = commonService.selectTtableDesByClassId(classId);
|
||
if (list != null && list.size() == 1) {
|
||
List<String> stringList = readXML(filePath + "/文件目录.xml");
|
||
result = new AjaxJson<>();
|
||
result.put("list1", stringList);
|
||
} else if (list != null && list.size() == 2) {
|
||
List<String> stringList1 = readXML(filePath + "/案卷目录.xml");
|
||
List<String> stringList2 = readXML(filePath + "/文件目录.xml");
|
||
result = new AjaxJson<>();
|
||
result.put("list1", stringList1);
|
||
result.put("list2", stringList2);
|
||
} else if (list != null && list.size() == 3) {
|
||
List<String> stringList1 = readXML(filePath + "/项目目录.xml");
|
||
List<String> stringList2 = readXML(filePath + "/案卷目录.xml");
|
||
List<String> stringList3 = readXML(filePath + "/文件目录.xml");
|
||
result = new AjaxJson<>();
|
||
result.put("list1", stringList1);
|
||
result.put("list2", stringList2);
|
||
result.put("list3", stringList3);
|
||
}
|
||
} catch (Exception e) {
|
||
result = AjaxJson.returnExceptionInfo("接收-xml标签列表:" + e);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 格式如下
|
||
* <?xml version="1.0" encoding="utf-8"?>
|
||
* <文件目录>
|
||
* <文件>
|
||
* <题名>1111111</题名>
|
||
* <全宗号>001</全宗号>
|
||
* </文件>
|
||
* ……
|
||
* </文件目录>
|
||
* 我只要第3级
|
||
*
|
||
* @param xmlFilePath
|
||
*/
|
||
private List<String> readXML(String xmlFilePath) {
|
||
List<String> stringList = new ArrayList<>();
|
||
SAXReader reader = new SAXReader();
|
||
//创建读取对象
|
||
Document doc;
|
||
try {
|
||
doc = reader.read(new File(xmlFilePath));
|
||
//从test.xml文件中取得节点操作对象
|
||
Element root = doc.getRootElement();
|
||
Element levelOneChildItem = (Element) root.elements().get(0);
|
||
List levelOneChildList2 = levelOneChildItem.elements();
|
||
for (int j = 0; j < levelOneChildList2.size(); j++) {
|
||
Element levelOneChildItem2 = (Element) levelOneChildList2.get(j);
|
||
// System.out.println("Child item3: " + levelOneChildItem2.getName() + " = " + levelOneChildItem2.getText());
|
||
stringList.add(levelOneChildItem2.getName());
|
||
}
|
||
//输出节点内容
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
}
|
||
return stringList;
|
||
}
|
||
|
||
|
||
private List<Map<String, Object>> dynamicReadXML(String filePath) {
|
||
List<Map<String, Object>> mapList = new ArrayList<>();
|
||
SAXReader reader = new SAXReader();
|
||
//创建读取对象
|
||
Document doc;
|
||
try {
|
||
doc = reader.read(new File(filePath));
|
||
//从test.xml文件中取得节点操作对象
|
||
Element root = doc.getRootElement();
|
||
//取得节点对象
|
||
|
||
List attrList = root.attributes();
|
||
// for(int i=0;i<attrList.size();i++){
|
||
// Attribute item=(Attribute) attrList.get(i);
|
||
// System.out.println("Root item attribute: " + item.getName() + " = " + item.getValue());
|
||
// }
|
||
// System.out.println("Root item:" + root.getName() + " = " + root.getText().trim());
|
||
|
||
List levelOneChildList = root.elements();
|
||
for (int i = 0; i < levelOneChildList.size(); i++) {
|
||
Element levelOneChildItem = (Element) levelOneChildList.get(i);
|
||
// System.out.println("Child item2: " + levelOneChildItem.getName() + " = " + levelOneChildItem.getText());
|
||
List levelOneChildList2 = levelOneChildItem.elements();
|
||
|
||
Map<String, Object> map = new HashMap<>();
|
||
|
||
for (int j = 0; j < levelOneChildList2.size(); j++) {
|
||
Element levelOneChildItem2 = (Element) levelOneChildList2.get(j);
|
||
// System.out.println("Child item3: " + levelOneChildItem2.getName() + " = " + levelOneChildItem2.getText());
|
||
map.put(levelOneChildItem2.getName(), levelOneChildItem2.getText());
|
||
}
|
||
mapList.add(map);
|
||
}
|
||
//输出节点内容
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
|
||
}
|
||
return mapList;
|
||
}
|
||
|
||
|
||
/**
|
||
* @param request
|
||
* @param response
|
||
* @return
|
||
*/
|
||
//@Transactional
|
||
public AjaxJson<Object> receive(ReceiveDto receiveDto,
|
||
HttpServletRequest request,
|
||
HttpServletResponse response) {
|
||
AjaxJson<Object> result = null;
|
||
try {
|
||
result = new AjaxJson<>();
|
||
String filePath = receiveDto.getFilePath();
|
||
Integer classId = receiveDto.getClassId();
|
||
|
||
List<TtableDescription> list0 = commonService.selectTtableDesByClassId(classId);
|
||
if (list0 != null && list0.size() == 1) { //第一层
|
||
//格式为:接收字段名-门类字段名-字段中文名
|
||
List<String> stringList = receiveDto.getStringList1();
|
||
String tableName = list0.get(0).getTableName();
|
||
|
||
List<String> list = new ArrayList<>();
|
||
//递归获取该路径下的所有文件,文件夹,并输出
|
||
FileTool.getFiles(filePath, list);
|
||
|
||
List<String> listXML = new ArrayList<>();
|
||
for (String str : list) {
|
||
System.out.println(str);
|
||
if (str.contains("文件目录.xml")) {
|
||
listXML.add(str);
|
||
}
|
||
}
|
||
|
||
//解析xml
|
||
for (String str : listXML) {
|
||
//获取文件内容
|
||
List<Map<String, Object>> dataList = dynamicReadXML(str);
|
||
//把数据添加到表中
|
||
for (Map<String, Object> jianhuaMap : dataList) {
|
||
String fieldName = "";
|
||
String valueName = "";
|
||
for (String ziduan : stringList) {
|
||
String[] arrays = ziduan.split("-");
|
||
String a = arrays[0]; //接收字段名
|
||
String b = arrays[1]; //门类字段名
|
||
String c = arrays[2]; //字段中文名(没用到)
|
||
String val = StringUtil.formatMap(jianhuaMap, a);
|
||
fieldName = fieldName + b + ",";
|
||
if (val != null && !"".equals(val)) {
|
||
valueName = valueName + "'" + val + "',";
|
||
} else {
|
||
valueName = valueName + "null,";
|
||
}
|
||
}
|
||
String archive_no = StringUtil.formatMap(jianhuaMap, "档号");
|
||
List<String> listJPG = FileTool.getFileList(filePath + "/" + archive_no);
|
||
fieldName = fieldName + "archive_file_num,archive_flag";
|
||
valueName = valueName + listJPG.size() + ",'已组卷'";
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
map.put("tableName", tableName + "_temp");
|
||
map.put("fieldName", fieldName);
|
||
map.put("valueName", valueName);
|
||
danganguanliMapper.saveObject(map);
|
||
int id = Integer.parseInt(map.get("id").toString());
|
||
//得到主表数据列表
|
||
Map<String, Object> parasMap2 = new HashMap<String, Object>();
|
||
parasMap2.put("tableName", tableName + "_temp");
|
||
parasMap2.put("conditionSql", " id =" + id);
|
||
List<Map<String, Object>> dataList2 = danganguanliMapper.selectObject(parasMap2);
|
||
Map<String, Object> map2 = dataList2.get(0);
|
||
String fonds_no = StringUtil.formatMap(map2, "fonds_no");
|
||
|
||
for (String strJpgPaht : listJPG) {
|
||
String myuuid = StringUtil.generaterUUID();
|
||
String relative_path = "uploadFile/" + tableName + "_temp_file/" + fonds_no + "/" + id;
|
||
String dir = imgUpload + relative_path;
|
||
//原文图片也要添加到表中
|
||
//把数据添加到表中
|
||
String fieldNameFile =
|
||
"rec_id, " +
|
||
"file_name, " +
|
||
"file_name_server, " +
|
||
"file_path, " +
|
||
"file_type," +
|
||
"page_no," +
|
||
"file_des," +
|
||
"file_status";
|
||
String valueNameFile =
|
||
"" + id + "," +
|
||
"'" + myuuid + ".jpg'," +
|
||
"'" + myuuid + ".jpg'," +
|
||
"'" + relative_path + "'," +
|
||
"'jpg'," +
|
||
"-1," +
|
||
"'" + dir + "'," +
|
||
"1";
|
||
Map<String, Object> mapFile = new HashMap<String, Object>();
|
||
mapFile.put("tableName", tableName + "_temp_file");
|
||
//其实我们知道是哪些字段
|
||
mapFile.put("fieldName", fieldNameFile);
|
||
mapFile.put("valueName", valueNameFile);
|
||
danganguanliMapper.saveObject(mapFile);
|
||
//原文也要复制到项目中图片库中
|
||
FileUtil.makedir(dir);
|
||
FileTool.copyTo(strJpgPaht,
|
||
dir + "/" + myuuid + ".jpg");
|
||
//要生成pdf文件
|
||
PdfFileHelper.image2Pdf(dir + "/" + myuuid + ".jpg",
|
||
dir + "/" + myuuid + ".pdf");
|
||
//要生成pdf文件-要保留原始pdf一份
|
||
FileTool.copyTo(dir + "/" + myuuid + ".pdf",
|
||
dir + "/" + myuuid + "_original.pdf");
|
||
}
|
||
}
|
||
}
|
||
} else if (list0 != null && list0.size() == 2) { //第二层
|
||
//格式为:接收字段名-门类字段名-字段中文名
|
||
List<String> stringList = receiveDto.getStringList1();
|
||
List<String> stringList2 = receiveDto.getStringList2();
|
||
String tableName = list0.get(0).getTableName();
|
||
String tableName2 = list0.get(1).getTableName();
|
||
|
||
List<String> list = new ArrayList<>();
|
||
//递归获取该路径下的所有文件,文件夹,并输出
|
||
FileTool.getFiles(filePath, list);
|
||
|
||
List<String> listXML = new ArrayList<>();
|
||
List<String> listXML2 = new ArrayList<>();
|
||
for (String str : list) {
|
||
System.out.println(str);
|
||
if (str.contains("案卷目录.xml")) {
|
||
listXML.add(str);
|
||
} else if (str.contains("文件目录.xml")) {
|
||
listXML2.add(str);
|
||
}
|
||
}
|
||
|
||
//解析xml
|
||
for (String str : listXML) { //案卷目录
|
||
//获取文件内容
|
||
List<Map<String, Object>> dataList = dynamicReadXML(str);
|
||
//把数据添加到表中
|
||
for (Map<String, Object> anjuanMap : dataList) {
|
||
String fieldName = "";
|
||
String valueName = "";
|
||
for (String ziduan : stringList) {
|
||
String[] arrays = ziduan.split("-");
|
||
String a = arrays[0]; //接收字段名
|
||
String b = arrays[1]; //门类字段名
|
||
String c = arrays[2]; //字段中文名(没用到)
|
||
String val = StringUtil.formatMap(anjuanMap, a);
|
||
fieldName = fieldName + b + ",";
|
||
valueName = valueName + "'" + val + "',";
|
||
}
|
||
String folder_no = StringUtil.formatMap(anjuanMap, "案卷级档号");
|
||
List<String> jpg_anjaun = FileTool.getFileList(filePath + "/案卷目录/" + folder_no);
|
||
fieldName = fieldName + "archive_file_num,archive_flag";
|
||
valueName = valueName + jpg_anjaun.size() + ",'已组卷'";
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
map.put("tableName", tableName + "_temp");
|
||
map.put("fieldName", fieldName);
|
||
map.put("valueName", valueName);
|
||
danganguanliMapper.saveObject(map);
|
||
int id = (Integer) map.get("id");
|
||
//得到主表数据列表
|
||
Map<String, Object> parasMap2 = new HashMap<String, Object>();
|
||
parasMap2.put("tableName", tableName + "_temp");
|
||
parasMap2.put("conditionSql", " id =" + id);
|
||
List<Map<String, Object>> dataList2 = danganguanliMapper.selectObject(parasMap2);
|
||
Map<String, Object> map2 = dataList2.get(0);
|
||
String fonds_no = StringUtil.formatMap(map2, "fonds_no");
|
||
|
||
for (String strJpgPaht : jpg_anjaun) {
|
||
String myuuid = StringUtil.generaterUUID();
|
||
String relative_path = "uploadFile/" + tableName + "_temp_file/" + fonds_no + "/" + id;
|
||
String dir = imgUpload + relative_path;
|
||
//原文图片也要添加到表中
|
||
//把数据添加到表中
|
||
String fieldNameFile =
|
||
"rec_id, " +
|
||
"file_name, " +
|
||
"file_name_server, " +
|
||
"file_path, " +
|
||
"file_type," +
|
||
"page_no," +
|
||
"file_des," +
|
||
"file_status";
|
||
String valueNameFile =
|
||
"" + id + "," +
|
||
"'" + myuuid + ".jpg'," +
|
||
"'" + myuuid + ".jpg'," +
|
||
"'" + relative_path + "'," +
|
||
"'jpg'," +
|
||
"-1," +
|
||
"'" + dir + "'," +
|
||
"1";
|
||
Map<String, Object> mapFile = new HashMap<String, Object>();
|
||
mapFile.put("tableName", tableName + "_temp_file");
|
||
mapFile.put("fieldName", fieldNameFile);
|
||
mapFile.put("valueName", valueNameFile);
|
||
danganguanliMapper.saveObject(mapFile);
|
||
//原文也要复制到项目中图片库中
|
||
FileUtil.makedir(dir);
|
||
FileTool.copyTo(strJpgPaht,
|
||
dir + "/" + myuuid + ".jpg");
|
||
//要生成pdf文件
|
||
PdfFileHelper.image2Pdf(dir + "/" + myuuid + ".jpg",
|
||
dir + "/" + myuuid + ".pdf");
|
||
//要生成pdf文件-要保留原始pdf一份
|
||
FileTool.copyTo(dir + "/" + myuuid + ".pdf",
|
||
dir + "/" + myuuid + "_original.pdf");
|
||
}
|
||
}
|
||
}
|
||
//解析xml
|
||
for (String str : listXML2) {
|
||
//获取文件内容
|
||
List<Map<String, Object>> dataList = dynamicReadXML(str);
|
||
//把数据添加到表中
|
||
for (Map<String, Object> juanneiMap : dataList) {
|
||
String fieldName = "";
|
||
String valueName = "";
|
||
for (String ziduan : stringList2) {
|
||
String[] arrays = ziduan.split("-");
|
||
String a = arrays[0]; //接收字段名
|
||
String b = arrays[1]; //门类字段名
|
||
String c = arrays[2]; //字段中文名(没用到)
|
||
String val = StringUtil.formatMap(juanneiMap, a);
|
||
fieldName = fieldName + b + ",";
|
||
if (val != null && !"".equals(val)) {
|
||
valueName = valueName + "'" + val + "',";
|
||
} else {
|
||
valueName = valueName + "null,";
|
||
}
|
||
}
|
||
String folder_no = StringUtil.formatMap(juanneiMap, "案卷级档号");
|
||
String archive_no = StringUtil.formatMap(juanneiMap, "文件级档号");
|
||
Map<String, Object> parasMap6 = new HashMap<String, Object>();
|
||
parasMap6.put("tableName", tableName + "_temp");
|
||
parasMap6.put("conditionSql", " folder_no ='" + folder_no + "'");
|
||
List<Map<String, Object>> dataList6 = danganguanliMapper.selectObject(parasMap6);
|
||
Map<String, Object> map6 = dataList6.get(0);
|
||
String id6 = StringUtil.formatMap(map6, "id");
|
||
|
||
List<String> jpg_juannei = FileTool.getFileList(filePath + "/文件目录/" + archive_no);
|
||
|
||
fieldName = fieldName + "archive_file_num,pid,archive_flag";
|
||
valueName = valueName + jpg_juannei.size() + "," + id6 + ",'已组卷'";
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
map.put("tableName", tableName2 + "_temp");
|
||
map.put("fieldName", fieldName);
|
||
map.put("valueName", valueName);
|
||
danganguanliMapper.saveObject(map);
|
||
int id = Integer.parseInt(map.get("id").toString());
|
||
//得到主表数据列表
|
||
Map<String, Object> parasMap2 = new HashMap<String, Object>();
|
||
parasMap2.put("tableName", tableName2 + "_temp");
|
||
parasMap2.put("conditionSql", " id =" + id);
|
||
List<Map<String, Object>> dataList2 = danganguanliMapper.selectObject(parasMap2);
|
||
Map<String, Object> map2 = dataList2.get(0);
|
||
String fonds_no = StringUtil.formatMap(map2, "fonds_no");
|
||
|
||
for (String strJpgPaht : jpg_juannei) {
|
||
String myuuid = StringUtil.generaterUUID();
|
||
String relative_path = "uploadFile/" + tableName2 + "_temp_file/" + fonds_no + "/" + id;
|
||
String dir = imgUpload + relative_path;
|
||
//原文图片也要添加到表中
|
||
//把数据添加到表中
|
||
String fieldNameFile =
|
||
"rec_id, " +
|
||
"file_name, " +
|
||
"file_name_server, " +
|
||
"file_path, " +
|
||
"file_type," +
|
||
"page_no," +
|
||
"file_des," +
|
||
"file_status";
|
||
String valueNameFile =
|
||
"" + id + "," +
|
||
"'" + myuuid + ".jpg'," +
|
||
"'" + myuuid + ".jpg'," +
|
||
"'" + relative_path + "'," +
|
||
"'jpg'," +
|
||
"-1," +
|
||
"'" + dir + "'," +
|
||
"1";
|
||
Map<String, Object> mapFile = new HashMap<String, Object>();
|
||
mapFile.put("tableName", tableName2 + "_temp_file");
|
||
mapFile.put("fieldName", fieldNameFile);
|
||
mapFile.put("valueName", valueNameFile);
|
||
danganguanliMapper.saveObject(mapFile);
|
||
//原文也要复制到项目中图片库中
|
||
FileUtil.makedir(dir);
|
||
FileTool.copyTo(strJpgPaht,
|
||
dir + "/" + myuuid + ".jpg");
|
||
//要生成pdf文件
|
||
PdfFileHelper.image2Pdf(dir + "/" + myuuid + ".jpg",
|
||
dir + "/" + myuuid + ".pdf");
|
||
//要生成pdf文件-要保留原始pdf一份
|
||
FileTool.copyTo(dir + "/" + myuuid + ".pdf",
|
||
dir + "/" + myuuid + "_original.pdf");
|
||
}
|
||
}
|
||
}
|
||
} else if (list0 != null && list0.size() == 3) { //第三层
|
||
//格式为:接收字段名-门类字段名-字段中文名
|
||
List<String> stringList = receiveDto.getStringList1();
|
||
List<String> stringList2 = receiveDto.getStringList2();
|
||
List<String> stringList3 = receiveDto.getStringList3();
|
||
|
||
String tableName = list0.get(0).getTableName();
|
||
String tableName2 = list0.get(1).getTableName();
|
||
String tableName3 = list0.get(2).getTableName();
|
||
|
||
List<String> list = new ArrayList<>();
|
||
//递归获取该路径下的所有文件,文件夹,并输出
|
||
FileTool.getFiles(filePath, list);
|
||
|
||
List<String> listXML = new ArrayList<>();
|
||
List<String> listXML2 = new ArrayList<>();
|
||
List<String> listXML3 = new ArrayList<>();
|
||
for (String str : list) {
|
||
System.out.println(str);
|
||
if (str.contains("项目目录.xml")) {
|
||
listXML.add(str);
|
||
} else if (str.contains("案卷目录.xml")) {
|
||
listXML2.add(str);
|
||
} else if (str.contains("文件目录.xml")) {
|
||
listXML3.add(str);
|
||
}
|
||
}
|
||
|
||
//解析xml
|
||
for (String str : listXML) { //案卷目录
|
||
//获取文件内容
|
||
List<Map<String, Object>> dataList = dynamicReadXML(str);
|
||
//把数据添加到表中
|
||
for (Map<String, Object> anjuanMap : dataList) {
|
||
String fieldName = "";
|
||
String valueName = "";
|
||
for (String ziduan : stringList) {
|
||
String[] arrays = ziduan.split("-");
|
||
String a = arrays[0]; //接收字段名
|
||
String b = arrays[1]; //门类字段名
|
||
String c = arrays[2]; //字段中文名(没用到)
|
||
String val = StringUtil.formatMap(anjuanMap, a);
|
||
fieldName = fieldName + b + ",";
|
||
valueName = valueName + "'" + val + "',";
|
||
}
|
||
String quanzonghao = StringUtil.formatMap(anjuanMap, "全宗号");
|
||
String xiangmuhao = StringUtil.formatMap(anjuanMap, "项目号");
|
||
String bianma = quanzonghao + "_" + xiangmuhao;
|
||
// List<String> jpg_anjaun = FileTool.getFileList(filePath + "/项目目录/" + bianma);
|
||
fieldName = fieldName + "archive_file_num,archive_flag";
|
||
valueName = valueName + 0 + ",'已组卷'";
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
map.put("tableName", tableName + "_temp");
|
||
map.put("fieldName", fieldName);
|
||
map.put("valueName", valueName);
|
||
danganguanliMapper.saveObject(map);
|
||
// int id = Integer.parseInt(map.get("id").toString()) ;
|
||
// //得到主表数据列表
|
||
// Map<String, Object> parasMap2 = new HashMap<String, Object>();
|
||
// parasMap2.put("tableName", tableName + "_temp");
|
||
// parasMap2.put("conditionSql", " id =" + id);
|
||
// List<Map<String, Object>> dataList2 = danganguanliMapper.selectObject(parasMap2);
|
||
// Map<String, Object> map2 = dataList2.get(0);
|
||
// String fonds_no = StringUtil.formatMap(map2, "fonds_no");
|
||
|
||
// for (String strJpgPaht : jpg_anjaun) {
|
||
// String myuuid = StringUtil.generaterUUID();
|
||
// String relative_path = "uploadFile/" + tableName + "_temp_file/" + fonds_no + "/" + id;
|
||
// String dir = imgUpload + relative_path;
|
||
// //原文图片也要添加到表中
|
||
// //把数据添加到表中
|
||
// String fieldNameFile =
|
||
// "rec_id, " +
|
||
// "file_name, " +
|
||
// "file_name_server, " +
|
||
// "file_path, " +
|
||
// "file_type," +
|
||
// "page_no," +
|
||
// "file_des," +
|
||
// "file_status";
|
||
// String valueNameFile =
|
||
// "" + id + "," +
|
||
// "'" + myuuid + ".jpg'," +
|
||
// "'" + myuuid + ".jpg'," +
|
||
// "'" + relative_path + "'," +
|
||
// "'jpg'," +
|
||
// "-1," +
|
||
// "'" + dir + "'," +
|
||
// "1";
|
||
// Map<String, Object> mapFile = new HashMap<String, Object>();
|
||
// mapFile.put("tableName", tableName + "_temp_file");
|
||
// mapFile.put("fieldName", fieldNameFile);
|
||
// mapFile.put("valueName", valueNameFile);
|
||
// danganguanliMapper.saveObject(mapFile);
|
||
// //原文也要复制到项目中图片库中
|
||
// FileUtil.makedir(dir);
|
||
// FileTool.copyTo(strJpgPaht,
|
||
// dir + "/" + myuuid + ".jpg");
|
||
// //要生成pdf文件
|
||
// PdfFileHelper.image2Pdf(dir + "/" + myuuid + ".jpg",
|
||
// dir + "/" + myuuid + ".pdf");
|
||
// //要生成pdf文件-要保留原始pdf一份
|
||
// FileTool.copyTo(dir + "/" + myuuid + ".pdf",
|
||
// dir + "/" + myuuid + "_original.pdf");
|
||
// }
|
||
}
|
||
}
|
||
//解析xml
|
||
for (String str : listXML2) {
|
||
//获取文件内容
|
||
List<Map<String, Object>> dataList = dynamicReadXML(str);
|
||
//把数据添加到表中
|
||
for (Map<String, Object> juanneiMap : dataList) {
|
||
String fieldName = "";
|
||
String valueName = "";
|
||
for (String ziduan : stringList2) {
|
||
String[] arrays = ziduan.split("-");
|
||
String a = arrays[0]; //接收字段名
|
||
String b = arrays[1]; //门类字段名
|
||
String c = arrays[2]; //字段中文名(没用到)
|
||
String val = StringUtil.formatMap(juanneiMap, a);
|
||
fieldName = fieldName + b + ",";
|
||
if (val != null && !"".equals(val)) {
|
||
valueName = valueName + "'" + val + "',";
|
||
} else {
|
||
valueName = valueName + "null,";
|
||
}
|
||
}
|
||
String fonds_no22 = StringUtil.formatMap(juanneiMap, "全宗号");
|
||
String item_id = StringUtil.formatMap(juanneiMap, "项目号");
|
||
String archive_no = StringUtil.formatMap(juanneiMap, "案卷级档号");
|
||
Map<String, Object> parasMap6 = new HashMap<String, Object>();
|
||
parasMap6.put("tableName", tableName + "_temp");
|
||
parasMap6.put("conditionSql", " fonds_no='" + fonds_no22 + "' and item_id ='" + item_id + "'");
|
||
List<Map<String, Object>> dataList6 = danganguanliMapper.selectObject(parasMap6);
|
||
Map<String, Object> map6 = dataList6.get(0);
|
||
String id6 = StringUtil.formatMap(map6, "id");
|
||
// List<String> jpg_juannei = FileTool.getFileList(filePath + "/案卷目录/" + archive_no);
|
||
fieldName = fieldName + "archive_file_num,pid,archive_flag";
|
||
valueName = valueName + 0 + "," + id6 + ",'已组卷'";
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
map.put("tableName", tableName2 + "_temp");
|
||
map.put("fieldName", fieldName);
|
||
map.put("valueName", valueName);
|
||
danganguanliMapper.saveObject(map);
|
||
// int id = Integer.parseInt(map.get("id").toString()) ;
|
||
// //得到主表数据列表
|
||
// Map<String, Object> parasMap2 = new HashMap<String, Object>();
|
||
// parasMap2.put("tableName", tableName2 + "_temp");
|
||
// parasMap2.put("conditionSql", " id =" + id);
|
||
// List<Map<String, Object>> dataList2 = danganguanliMapper.selectObject(parasMap2);
|
||
// Map<String, Object> map2 = dataList2.get(0);
|
||
// String fonds_no = StringUtil.formatMap(map2, "fonds_no");
|
||
|
||
// for (String strJpgPaht : jpg_juannei) {
|
||
// String myuuid = StringUtil.generaterUUID();
|
||
// String relative_path = "uploadFile/" + tableName2 + "_temp_file/" + fonds_no + "/" + id;
|
||
// String dir = imgUpload + relative_path;
|
||
// //原文图片也要添加到表中
|
||
// //把数据添加到表中
|
||
// String fieldNameFile =
|
||
// "rec_id, " +
|
||
// "file_name, " +
|
||
// "file_name_server, " +
|
||
// "file_path, " +
|
||
// "file_type," +
|
||
// "page_no," +
|
||
// "file_des," +
|
||
// "file_status";
|
||
// String valueNameFile =
|
||
// "" + id + "," +
|
||
// "'" + myuuid + ".jpg'," +
|
||
// "'" + myuuid + ".jpg'," +
|
||
// "'" + relative_path + "'," +
|
||
// "'jpg'," +
|
||
// "-1," +
|
||
// "'" + dir + "'," +
|
||
// "1";
|
||
// Map<String, Object> mapFile = new HashMap<String, Object>();
|
||
// mapFile.put("tableName", tableName2 + "_temp_file");
|
||
// mapFile.put("fieldName", fieldNameFile);
|
||
// mapFile.put("valueName", valueNameFile);
|
||
// danganguanliMapper.saveObject(mapFile);
|
||
// //原文也要复制到项目中图片库中
|
||
// FileUtil.makedir(dir);
|
||
// FileTool.copyTo(strJpgPaht,
|
||
// dir + "/" + myuuid + ".jpg");
|
||
// //要生成pdf文件
|
||
// PdfFileHelper.image2Pdf(dir + "/" + myuuid + ".jpg",
|
||
// dir + "/" + myuuid + ".pdf");
|
||
// //要生成pdf文件-要保留原始pdf一份
|
||
// FileTool.copyTo(dir + "/" + myuuid + ".pdf",
|
||
// dir + "/" + myuuid + "_original.pdf");
|
||
// }
|
||
}
|
||
}
|
||
|
||
//解析xml
|
||
for (String str : listXML3) {
|
||
//获取文件内容
|
||
List<Map<String, Object>> dataList = dynamicReadXML(str);
|
||
//把数据添加到表中
|
||
for (Map<String, Object> juanneiMap : dataList) {
|
||
String fieldName = "";
|
||
String valueName = "";
|
||
for (String ziduan : stringList3) {
|
||
String[] arrays = ziduan.split("-");
|
||
String a = arrays[0]; //接收字段名
|
||
String b = arrays[1]; //门类字段名
|
||
String c = arrays[2]; //字段中文名(没用到)
|
||
String val = StringUtil.formatMap(juanneiMap, a);
|
||
fieldName = fieldName + b + ",";
|
||
if (val != null && !"".equals(val)) {
|
||
valueName = valueName + "'" + val + "',";
|
||
} else {
|
||
valueName = valueName + "null,";
|
||
}
|
||
}
|
||
String folder_no = StringUtil.formatMap(juanneiMap, "案卷级档号");
|
||
String archive_no = StringUtil.formatMap(juanneiMap, "档号");
|
||
Map<String, Object> parasMap6 = new HashMap<String, Object>();
|
||
parasMap6.put("tableName", tableName2 + "_temp");
|
||
parasMap6.put("conditionSql", " folder_no ='" + folder_no + "'");
|
||
List<Map<String, Object>> dataList6 = danganguanliMapper.selectObject(parasMap6);
|
||
Map<String, Object> map6 = dataList6.get(0);
|
||
String id6 = StringUtil.formatMap(map6, "id");
|
||
|
||
List<String> jpg_juannei = FileTool.getFileList(filePath + "/文件目录/" + archive_no);
|
||
|
||
fieldName = fieldName + "archive_file_num,pid,archive_flag";
|
||
valueName = valueName + jpg_juannei.size() + "," + id6 + ",'已组卷'";
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
map.put("tableName", tableName3 + "_temp");
|
||
map.put("fieldName", fieldName);
|
||
map.put("valueName", valueName);
|
||
danganguanliMapper.saveObject(map);
|
||
int id = Integer.parseInt(map.get("id").toString());
|
||
//得到主表数据列表
|
||
Map<String, Object> parasMap2 = new HashMap<String, Object>();
|
||
parasMap2.put("tableName", tableName3 + "_temp");
|
||
parasMap2.put("conditionSql", " id =" + id);
|
||
List<Map<String, Object>> dataList2 = danganguanliMapper.selectObject(parasMap2);
|
||
Map<String, Object> map2 = dataList2.get(0);
|
||
String fonds_no = StringUtil.formatMap(map2, "fonds_no");
|
||
|
||
for (String strJpgPaht : jpg_juannei) {
|
||
String myuuid = StringUtil.generaterUUID();
|
||
String relative_path = "uploadFile/" + tableName2 + "_temp_file/" + fonds_no + "/" + id;
|
||
String dir = imgUpload + relative_path;
|
||
//原文图片也要添加到表中
|
||
//把数据添加到表中
|
||
String fieldNameFile =
|
||
"rec_id, " +
|
||
"file_name, " +
|
||
"file_name_server, " +
|
||
"file_path, " +
|
||
"file_type," +
|
||
"page_no," +
|
||
"file_des," +
|
||
"file_status";
|
||
String valueNameFile =
|
||
"" + id + "," +
|
||
"'" + myuuid + ".jpg'," +
|
||
"'" + myuuid + ".jpg'," +
|
||
"'" + relative_path + "'," +
|
||
"'jpg'," +
|
||
"-1," +
|
||
"'" + dir + "'," +
|
||
"1";
|
||
Map<String, Object> mapFile = new HashMap<String, Object>();
|
||
mapFile.put("tableName", tableName3 + "_temp_file");
|
||
mapFile.put("fieldName", fieldNameFile);
|
||
mapFile.put("valueName", valueNameFile);
|
||
danganguanliMapper.saveObject(mapFile);
|
||
//原文也要复制到项目中图片库中
|
||
FileUtil.makedir(dir);
|
||
FileTool.copyTo(strJpgPaht,
|
||
dir + "/" + myuuid + ".jpg");
|
||
//要生成pdf文件
|
||
PdfFileHelper.image2Pdf(dir + "/" + myuuid + ".jpg",
|
||
dir + "/" + myuuid + ".pdf");
|
||
//要生成pdf文件-要保留原始pdf一份
|
||
FileTool.copyTo(dir + "/" + myuuid + ".pdf",
|
||
dir + "/" + myuuid + "_original.pdf");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
} catch (Exception e) {
|
||
result = AjaxJson.returnExceptionInfo("接收失败:" + e);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
|
||
public AjaxJson<Object> receiveEEP(@RequestBody JSONObject jsonObject,
|
||
HttpServletRequest request,
|
||
HttpServletResponse response) {
|
||
AjaxJson<Object> result = null;
|
||
try {
|
||
result = new AjaxJson<>();
|
||
Integer classId = jsonObject.getInteger("classId");
|
||
String path = jsonObject.getString("path");
|
||
String absolutePath = getAbsolutePath(path);
|
||
List<TtableDescription> list0 = commonService.selectTtableDesByClassId(classId);
|
||
if (list0 != null && list0.size() == 1) { //第一层
|
||
String tableName = list0.get(0).getTableName();
|
||
// String tableName2 = list0.get(1).getTableName();
|
||
// String tableName3 = list0.get(2).getTableName();
|
||
String xmlStr = FileTool.getContent(new File(absolutePath));
|
||
Map<String, Class> clazzMap2 = new HashMap<String, Class>();
|
||
clazzMap2.put("电子文件封装包", 电子文件封装包.class);
|
||
// clazzMap2.put("被签名对象", 被签名对象.class);
|
||
// clazzMap2.put("封装内容", 封装内容.class);
|
||
clazzMap2.put("文件实体", 文件实体.class);
|
||
// clazzMap2.put("来源", 来源.class);
|
||
// clazzMap2.put("档号", 档号.class);
|
||
// clazzMap2.put("内容描述", 内容描述.class);
|
||
clazzMap2.put("文档", 文档.class);
|
||
// clazzMap2.put("编码", 编码.class);
|
||
// clazzMap2.put("电子属性", 电子属性.class);
|
||
电子文件封装包 data1 = (电子文件封装包) XMLBeanUtils.xml2Bean(clazzMap2, xmlStr);
|
||
|
||
List<文件实体> 文件实体列表 = data1.get被签名对象().get封装内容().get文件实体块();
|
||
for (文件实体 文件实体对象 : 文件实体列表) {
|
||
String archive_no = 文件实体对象.get档号().get档号();
|
||
Map<String, Object> map0 = new HashMap<String, Object>();
|
||
map0.put("tableName", tableName + "_temp");
|
||
map0.put("conditionSql", "archive_no='" + archive_no + "'");
|
||
List<Map<String, Object>> mapList0 = danganguanliMapper.selectObject(map0);
|
||
if (mapList0 != null && mapList0.size() > 0) {
|
||
result = AjaxJson.returnExceptionInfo("接收eep包失败:档号[" + archive_no + "]已存在");
|
||
return result;
|
||
}
|
||
|
||
Map<String, Object> fieldValueMap = getFieldValue(文件实体对象);
|
||
String fieldName = StringUtil.formatMap(fieldValueMap, "field");
|
||
String valueName = StringUtil.formatMap(fieldValueMap, "value");
|
||
|
||
fieldName = fieldName + "archive_file_num,archive_flag";
|
||
valueName = valueName + 文件实体对象.get文件数据().size() + ",'已组卷'";
|
||
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
map.put("tableName", tableName + "_temp");
|
||
map.put("fieldName", fieldName);
|
||
map.put("valueName", valueName);
|
||
danganguanliMapper.saveObject(map);
|
||
int id = Integer.parseInt(map.get("id").toString());
|
||
//得到主表数据列表
|
||
Map<String, Object> parasMap2 = new HashMap<String, Object>();
|
||
parasMap2.put("tableName", tableName + "_temp");
|
||
parasMap2.put("conditionSql", " id =" + id);
|
||
List<Map<String, Object>> dataList2 = danganguanliMapper.selectObject(parasMap2);
|
||
Map<String, Object> map2 = dataList2.get(0);
|
||
String fonds_no = StringUtil.formatMap(map2, "fonds_no");
|
||
|
||
List<文档> 文档列表 = 文件实体对象.get文件数据();
|
||
for (文档 文档对象 : 文档列表) {
|
||
编码 编码对象 = 文档对象.get文档数据().get编码();
|
||
String 编码数据Base64 = 编码对象.get编码数据();
|
||
|
||
String myuuid = StringUtil.generaterUUID();
|
||
String relative_path = "/uploadFile/" + tableName + "_temp_file/" + fonds_no + "/" + id;
|
||
String dir = imgUpload + relative_path;
|
||
FileUtil.makedir(dir);
|
||
String strJpgPaht = dir + "/" + myuuid + ".jpg";
|
||
Base64Utils.decode2(strJpgPaht, 编码数据Base64);
|
||
//原文图片也要添加到表中
|
||
//把数据添加到表中
|
||
String fieldNameFile =
|
||
"rec_id, " +
|
||
"file_name, " +
|
||
"file_name_server, " +
|
||
"file_path, " +
|
||
"file_type," +
|
||
"page_no," +
|
||
"file_des," +
|
||
"file_status";
|
||
String valueNameFile =
|
||
"" + id + "," +
|
||
"'" + myuuid + ".jpg'," +
|
||
"'" + myuuid + ".jpg'," +
|
||
"'" + relative_path + "'," +
|
||
"'jpg'," +
|
||
"-1," +
|
||
"'" + dir + "'," +
|
||
"1";
|
||
Map<String, Object> mapFile = new HashMap<String, Object>();
|
||
mapFile.put("tableName", tableName + "_temp_file");
|
||
//其实我们知道是哪些字段
|
||
mapFile.put("fieldName", fieldNameFile);
|
||
mapFile.put("valueName", valueNameFile);
|
||
danganguanliMapper.saveObject(mapFile);
|
||
//原文也要复制到项目中图片库中
|
||
FileUtil.makedir(dir);
|
||
|
||
//要生成pdf文件
|
||
PdfFileHelper.image2Pdf(dir + "/" + myuuid + ".jpg",
|
||
dir + "/" + myuuid + ".pdf");
|
||
//要生成pdf文件-要保留原始pdf一份
|
||
FileTool.copyTo(dir + "/" + myuuid + ".pdf",
|
||
dir + "/" + myuuid + "_original.pdf");
|
||
}
|
||
}
|
||
}
|
||
|
||
if (true) {
|
||
ClassTree classTree = classTreeMapper.selectClassOneById(classId);
|
||
UserRole userRole = userService.getUserRole(request);
|
||
User user = userRole.getUser();
|
||
if (user != null) {
|
||
//记录日志
|
||
Date date = new Date();
|
||
OperLogger entity = new OperLogger();
|
||
entity.setLogType("接收数据");
|
||
entity.setOperator(user.getUsername());
|
||
entity.setOperatorChn(user.getUserChnName());
|
||
entity.setOperateDate(date);
|
||
entity.setDescription("操作人[" + user.getUsername() + "]在时间[" + DateUtil.date2String(date, 1) + "]接收数据");
|
||
entity.setArgs("数据:门类名称=" + classTree.getClassName());
|
||
operLoggerService.addEntity(entity);
|
||
}
|
||
}
|
||
|
||
|
||
} catch (Exception e) {
|
||
result = AjaxJson.returnExceptionInfo("接收eep包失败:" + e);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
|
||
private String getAbsolutePath(String path) {
|
||
String result = "";
|
||
File file = new File(path);
|
||
File[] fs = file.listFiles();
|
||
if (null != fs && fs.length > 1) {
|
||
for (int i = 0; i < fs.length; i++) {
|
||
String name1 = fs[i].getName();
|
||
if (name1.contains("eep")) {
|
||
result = fs[i].getAbsolutePath();
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
|
||
|
||
private Map<String, Object> getFieldValue(文件实体 文件实体对象) {
|
||
Map<String, Object> fieldValueMap = new HashMap<>();
|
||
// fieldValueMap.put("fonds_name",文件实体对象.get来源().get全宗名称());
|
||
fieldValueMap.put("fonds_no", 文件实体对象.get档号().get全宗号());
|
||
fieldValueMap.put("filing_year", 文件实体对象.get档号().get年度());
|
||
fieldValueMap.put("retention", 文件实体对象.get档号().get保管期限());
|
||
fieldValueMap.put("piece_no", 文件实体对象.get档号().get室编件号());
|
||
fieldValueMap.put("archive_no", 文件实体对象.get档号().get档号());
|
||
fieldValueMap.put("maintitle", 文件实体对象.get内容描述().get题名());
|
||
fieldValueMap.put("archive_ctg_no", 文件实体对象.get内容描述().get分类号());
|
||
fieldValueMap.put("created_date", 文件实体对象.get内容描述().get日期());
|
||
fieldValueMap.put("security_class", 文件实体对象.get内容描述().get密级());
|
||
fieldValueMap.put("responsibleby", 文件实体对象.get内容描述().get责任者());
|
||
fieldValueMap.put("quantity", 文件实体对象.get档号().get页数());
|
||
|
||
String field = "";
|
||
String value = "";
|
||
for (Map.Entry<String, Object> entry : fieldValueMap.entrySet()) {
|
||
field = field + entry.getKey() + ",";
|
||
if (entry.getValue() != null && !"".equals(entry.getValue())) {
|
||
value = value + "'" + entry.getValue() + "',";
|
||
} else {
|
||
value = value + "null,";
|
||
}
|
||
}
|
||
Map<String, Object> resultMap = new HashMap<>();
|
||
resultMap.put("field", field);
|
||
resultMap.put("value", value);
|
||
return resultMap;
|
||
}
|
||
|
||
|
||
@Transactional
|
||
public AjaxJson<Object> deleteData(DeleteDto deleteDto) {
|
||
AjaxJson<Object> result = null;
|
||
try {
|
||
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||
HttpServletRequest request = servletRequestAttributes.getRequest();
|
||
Integer classId = deleteDto.getClassId();
|
||
String oneIds = deleteDto.getOneIds();
|
||
String twoIds = deleteDto.getTwoIds();
|
||
String threeIds = deleteDto.getThreeIds();
|
||
|
||
List<TtableDescription> tableDescriptionList = commonService.selectTtableDesByClassId(classId);
|
||
if (tableDescriptionList.size() == 1) { //1层
|
||
String tb1 = tableDescriptionList.get(0).getTableName();
|
||
|
||
Map<String, Object> parasMap1 = new HashMap<String, Object>();
|
||
parasMap1.put("tableName", tb1 + "_temp");
|
||
parasMap1.put("conditionSql", " 1=1 and id in (" + oneIds + ") ");
|
||
List<Map<String, Object>> dataList2 = danganguanliMapper.selectObject(parasMap1);
|
||
|
||
for (Map<String, Object> map01 : dataList2) {
|
||
String id = StringUtil.formatMap(map01, "id");
|
||
//得到临时原文数据列表
|
||
Map<String, Object> parasMap2 = new HashMap<String, Object>();
|
||
parasMap2.put("tableName", tb1 + "_temp_file");
|
||
parasMap2.put("conditionSql", " 1=1 and file_status=1 and rec_id=" + id);
|
||
List<Map<String, Object>> dataFileList2 = danganguanliMapper.selectObject(parasMap2);
|
||
|
||
String fileIds = "";
|
||
for (Map<String, Object> mapFile : dataFileList2) {
|
||
String fileId = StringUtil.formatMap(mapFile, "id");
|
||
fileIds = fileIds + fileId + ",";
|
||
|
||
String fieldValue = " file_status=2";
|
||
String conditionSql = " id='" + fileId + "'";
|
||
Map<String, Object> map7 = new HashMap<String, Object>();
|
||
map7.put("tableName", tb1 + "_temp_file");
|
||
map7.put("fieldValue", fieldValue);
|
||
map7.put("conditionSql", conditionSql);
|
||
danganguanliMapper.updateObject(map7);
|
||
}
|
||
if (!"".equals(fileIds)) {
|
||
fileIds = fileIds.substring(0, fileIds.length() - 1);
|
||
}
|
||
|
||
String fieldName = "";
|
||
String valueName = "";
|
||
for (Map.Entry<String, Object> entry : map01.entrySet()) {
|
||
String k = entry.getKey();
|
||
String v = entry.getValue() != null ? String.valueOf(entry.getValue()) : "";
|
||
if (!"id".equals(k)) {
|
||
if (v != null && !"".equals(v)) {
|
||
fieldName = fieldName + k + ",";
|
||
valueName = valueName + "'" + v + "',";
|
||
}
|
||
}
|
||
}
|
||
|
||
fieldName = fieldName + "md5_code";
|
||
valueName = valueName + "'" + fileIds + "'";
|
||
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
map.put("tableName", tb1 + "_temp_trash");
|
||
map.put("fieldName", fieldName);
|
||
map.put("valueName", valueName);
|
||
danganguanliMapper.saveObject(map);
|
||
|
||
//添加日志
|
||
UserRole userRole = userService.getUserRole(request);
|
||
User user = userRole.getUser();
|
||
if (user != null) {
|
||
String archiveNo = StringUtil.formatMap(map01, "archive_no");
|
||
//记录日志
|
||
Date date = new Date();
|
||
OperLogger entity = new OperLogger();
|
||
entity.setLogType("1");
|
||
entity.setOperator(user.getUsername());
|
||
entity.setOperatorChn(user.getUserChnName());
|
||
entity.setOperateDate(date);
|
||
entity.setDescription("删除了档号为" + archiveNo);
|
||
entity.setArgs("数据:档号为" + archiveNo);
|
||
operLoggerService.addEntity(entity);
|
||
}
|
||
}
|
||
|
||
String conditionSql2 = " id in (" + oneIds + ") ";
|
||
Map<String, Object> map_temp_file_del = new HashMap<String, Object>();
|
||
map_temp_file_del.put("tableName", tb1 + "_temp");
|
||
map_temp_file_del.put("conditionSql", conditionSql2);
|
||
danganguanliMapper.deleteObject(map_temp_file_del);
|
||
|
||
|
||
} else if (tableDescriptionList.size() == 2) { //2层
|
||
String tb1 = tableDescriptionList.get(0).getTableName();
|
||
String tb2 = tableDescriptionList.get(1).getTableName();
|
||
|
||
if (!"".equals(twoIds) && twoIds != null) { //只删除卷内的数据
|
||
Map<String, Object> parasMap1 = new HashMap<String, Object>();
|
||
parasMap1.put("tableName", tb2 + "_temp");
|
||
parasMap1.put("conditionSql", " 1=1 and id in (" + twoIds + ") ");
|
||
List<Map<String, Object>> dataList2 = danganguanliMapper.selectObject(parasMap1);
|
||
|
||
for (Map<String, Object> map01 : dataList2) {
|
||
String id = StringUtil.formatMap(map01, "id");
|
||
//得到临时原文数据列表
|
||
Map<String, Object> parasMap2 = new HashMap<String, Object>();
|
||
parasMap2.put("tableName", tb2 + "_temp_file");
|
||
parasMap2.put("conditionSql", " 1=1 and file_status=1 and rec_id=" + id);
|
||
List<Map<String, Object>> dataFileList2 = danganguanliMapper.selectObject(parasMap2);
|
||
|
||
String fileIds = "";
|
||
for (Map<String, Object> mapFile : dataFileList2) {
|
||
String fileId = StringUtil.formatMap(mapFile, "id");
|
||
fileIds = fileIds + fileId + ",";
|
||
|
||
String fieldValue = " file_status=2";
|
||
String conditionSql = " id='" + fileId + "'";
|
||
Map<String, Object> map7 = new HashMap<String, Object>();
|
||
map7.put("tableName", tb2 + "_temp_file");
|
||
map7.put("fieldValue", fieldValue);
|
||
map7.put("conditionSql", conditionSql);
|
||
danganguanliMapper.updateObject(map7);
|
||
}
|
||
if (!"".equals(fileIds)) {
|
||
fileIds = fileIds.substring(0, fileIds.length() - 1);
|
||
}
|
||
|
||
String fieldName = "";
|
||
String valueName = "";
|
||
for (Map.Entry<String, Object> entry : map01.entrySet()) {
|
||
String k = entry.getKey();
|
||
String v = entry.getValue() != null ? String.valueOf(entry.getValue()) : "";
|
||
if (!"id".equals(k)) {
|
||
if (v != null && !"".equals(v)) {
|
||
fieldName = fieldName + k + ",";
|
||
valueName = valueName + "'" + v + "',";
|
||
}
|
||
}
|
||
}
|
||
|
||
fieldName = fieldName + "md5_code";
|
||
valueName = valueName + "'" + fileIds + "'";
|
||
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
map.put("tableName", tb2 + "_temp_trash");
|
||
map.put("fieldName", fieldName);
|
||
map.put("valueName", valueName);
|
||
danganguanliMapper.saveObject(map);
|
||
//添加日志
|
||
UserRole userRole = userService.getUserRole(request);
|
||
User user = userRole.getUser();
|
||
if (user != null) {
|
||
String archiveNo = StringUtil.formatMap(map01, "archive_no");
|
||
//记录日志
|
||
Date date = new Date();
|
||
OperLogger entity = new OperLogger();
|
||
entity.setLogType("1");
|
||
entity.setOperator(user.getUsername());
|
||
entity.setOperatorChn(user.getUserChnName());
|
||
entity.setOperateDate(date);
|
||
entity.setDescription("删除了档号为" + archiveNo);
|
||
entity.setArgs("数据:档号为" + archiveNo);
|
||
operLoggerService.addEntity(entity);
|
||
}
|
||
}
|
||
|
||
String conditionSql2 = " id in (" + twoIds + ") ";
|
||
Map<String, Object> map_temp_file_del = new HashMap<String, Object>();
|
||
map_temp_file_del.put("tableName", tb2 + "_temp");
|
||
map_temp_file_del.put("conditionSql", conditionSql2);
|
||
danganguanliMapper.deleteObject(map_temp_file_del);
|
||
|
||
|
||
} else if (!"".equals(oneIds) && oneIds != null) { //删除案卷和卷内的数据
|
||
Map<String, Object> parasMap1 = new HashMap<String, Object>();
|
||
parasMap1.put("tableName", tb1 + "_temp");
|
||
parasMap1.put("conditionSql", " 1=1 and id in (" + oneIds + ") ");
|
||
List<Map<String, Object>> dataList2 = danganguanliMapper.selectObject(parasMap1);
|
||
|
||
for (Map<String, Object> map01 : dataList2) {
|
||
String id = StringUtil.formatMap(map01, "id");
|
||
//得到临时原文数据列表
|
||
Map<String, Object> parasMap2 = new HashMap<String, Object>();
|
||
parasMap2.put("tableName", tb1 + "_temp_file");
|
||
parasMap2.put("conditionSql", " 1=1 and file_status=1 and rec_id=" + id);
|
||
List<Map<String, Object>> dataFileList2 = danganguanliMapper.selectObject(parasMap2);
|
||
|
||
String fileIds = "";
|
||
for (Map<String, Object> mapFile : dataFileList2) {
|
||
String fileId = StringUtil.formatMap(mapFile, "id");
|
||
fileIds = fileIds + fileId + ",";
|
||
|
||
String fieldValue = " file_status=2";
|
||
String conditionSql = " id='" + fileId + "'";
|
||
Map<String, Object> map7 = new HashMap<String, Object>();
|
||
map7.put("tableName", tb1 + "_temp_file");
|
||
map7.put("fieldValue", fieldValue);
|
||
map7.put("conditionSql", conditionSql);
|
||
danganguanliMapper.updateObject(map7);
|
||
}
|
||
if (!"".equals(fileIds)) {
|
||
fileIds = fileIds.substring(0, fileIds.length() - 1);
|
||
}
|
||
|
||
String fieldName = "";
|
||
String valueName = "";
|
||
for (Map.Entry<String, Object> entry : map01.entrySet()) {
|
||
String k = entry.getKey();
|
||
String v = entry.getValue() != null ? String.valueOf(entry.getValue()) : "";
|
||
if (!"id".equals(k)) {
|
||
if (v != null && !"".equals(v)) {
|
||
fieldName = fieldName + k + ",";
|
||
valueName = valueName + "'" + v + "',";
|
||
}
|
||
}
|
||
}
|
||
|
||
fieldName = fieldName + "md5_code,batch_name,batch_id";
|
||
valueName = valueName + "'" + fileIds + "','" + tb1 + "','" + tb2 + "'";
|
||
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
map.put("tableName", tb1 + "_temp_trash");
|
||
map.put("fieldName", fieldName);
|
||
map.put("valueName", valueName);
|
||
danganguanliMapper.saveObject(map);
|
||
|
||
//第二层卷内也要删除
|
||
Map<String, Object> parasMap21 = new HashMap<String, Object>();
|
||
parasMap21.put("tableName", tb2 + "_temp");
|
||
parasMap21.put("conditionSql", " 1=1 and pid in (" + oneIds + ") ");
|
||
List<Map<String, Object>> dataList22 = danganguanliMapper.selectObject(parasMap21);
|
||
for (Map<String, Object> map23 : dataList22) {
|
||
String juanneiId = StringUtil.formatMap(map23, "id");
|
||
|
||
Map<String, Object> parasMap24 = new HashMap<String, Object>();
|
||
parasMap24.put("tableName", tb2 + "_temp_file");
|
||
parasMap24.put("conditionSql", " 1=1 and file_status=1 and rec_id=" + juanneiId);
|
||
List<Map<String, Object>> dataFileList25 = danganguanliMapper.selectObject(parasMap24);
|
||
|
||
String juanneiFileIds = "";
|
||
for (Map<String, Object> mapFile : dataFileList25) {
|
||
String fileId = StringUtil.formatMap(mapFile, "id");
|
||
juanneiFileIds = juanneiFileIds + fileId + ",";
|
||
|
||
String fieldValue = " file_status=2";
|
||
String conditionSql = " id='" + fileId + "'";
|
||
Map<String, Object> map7 = new HashMap<String, Object>();
|
||
map7.put("tableName", tb2 + "_temp_file");
|
||
map7.put("fieldValue", fieldValue);
|
||
map7.put("conditionSql", conditionSql);
|
||
danganguanliMapper.updateObject(map7);
|
||
}
|
||
if (!"".equals(juanneiFileIds)) {
|
||
juanneiFileIds = juanneiFileIds.substring(0, juanneiFileIds.length() - 1);
|
||
}
|
||
|
||
String fieldName27 = "";
|
||
String valueName28 = "";
|
||
for (Map.Entry<String, Object> entry : map23.entrySet()) {
|
||
String k = entry.getKey();
|
||
String v = entry.getValue() != null ? String.valueOf(entry.getValue()) : "";
|
||
if (!"id".equals(k)) {
|
||
if (v != null && !"".equals(v)) {
|
||
fieldName27 = fieldName27 + k + ",";
|
||
valueName28 = valueName28 + "'" + v + "',";
|
||
}
|
||
}
|
||
}
|
||
|
||
fieldName27 = fieldName27 + "md5_code,batch_name,batch_id";
|
||
valueName28 = valueName28 + "'" + juanneiFileIds + "','" + tb1 + "','" + tb2 + "'";
|
||
|
||
Map<String, Object> map29 = new HashMap<String, Object>();
|
||
map29.put("tableName", tb2 + "_temp_trash");
|
||
map29.put("fieldName", fieldName27);
|
||
map29.put("valueName", valueName28);
|
||
danganguanliMapper.saveObject(map29);
|
||
//添加日志
|
||
UserRole userRole = userService.getUserRole(request);
|
||
User user = userRole.getUser();
|
||
if (user != null) {
|
||
String archiveNo = StringUtil.formatMap(map23, "archive_no");
|
||
//记录日志
|
||
Date date = new Date();
|
||
OperLogger entity = new OperLogger();
|
||
entity.setLogType("1");
|
||
entity.setOperator(user.getUsername());
|
||
entity.setOperatorChn(user.getUserChnName());
|
||
entity.setOperateDate(date);
|
||
entity.setDescription("删除了档号为" + archiveNo);
|
||
entity.setArgs("数据:档号为" + archiveNo);
|
||
operLoggerService.addEntity(entity);
|
||
}
|
||
}
|
||
|
||
String conditionSql2 = " pid in (" + oneIds + ") ";
|
||
Map<String, Object> map_temp_file_del = new HashMap<String, Object>();
|
||
map_temp_file_del.put("tableName", tb2 + "_temp");
|
||
map_temp_file_del.put("conditionSql", conditionSql2);
|
||
danganguanliMapper.deleteObject(map_temp_file_del);
|
||
//添加日志
|
||
UserRole userRole = userService.getUserRole(request);
|
||
User user = userRole.getUser();
|
||
if (user != null) {
|
||
String archiveNo = StringUtil.formatMap(map01, "folder_no");
|
||
//记录日志
|
||
Date date = new Date();
|
||
OperLogger entity = new OperLogger();
|
||
entity.setLogType("1");
|
||
entity.setOperator(user.getUsername());
|
||
entity.setOperatorChn(user.getUserChnName());
|
||
entity.setOperateDate(date);
|
||
entity.setDescription("删除了案卷级档号为" + archiveNo);
|
||
entity.setArgs("数据:案卷级档号为" + archiveNo);
|
||
operLoggerService.addEntity(entity);
|
||
}
|
||
}
|
||
|
||
String conditionSql2 = " id in (" + oneIds + ") ";
|
||
Map<String, Object> map_temp_file_del = new HashMap<String, Object>();
|
||
map_temp_file_del.put("tableName", tb1 + "_temp");
|
||
map_temp_file_del.put("conditionSql", conditionSql2);
|
||
danganguanliMapper.deleteObject(map_temp_file_del);
|
||
}
|
||
} else if (tableDescriptionList.size() == 3) { //3层
|
||
String tb1 = tableDescriptionList.get(0).getTableName();
|
||
String tb2 = tableDescriptionList.get(1).getTableName();
|
||
String tb3 = tableDescriptionList.get(2).getTableName();
|
||
|
||
if (!"".equals(threeIds) && threeIds != null) { //只删除第三层
|
||
Map<String, Object> parasMap1 = new HashMap<String, Object>();
|
||
parasMap1.put("tableName", tb3 + "_temp");
|
||
parasMap1.put("conditionSql", " 1=1 and id in (" + threeIds + ") ");
|
||
List<Map<String, Object>> dataList2 = danganguanliMapper.selectObject(parasMap1);
|
||
|
||
for (Map<String, Object> map01 : dataList2) {
|
||
String id = StringUtil.formatMap(map01, "id");
|
||
//得到临时原文数据列表
|
||
Map<String, Object> parasMap2 = new HashMap<String, Object>();
|
||
parasMap2.put("tableName", tb3 + "_temp_file");
|
||
parasMap2.put("conditionSql", " 1=1 and file_status=1 and rec_id=" + id);
|
||
List<Map<String, Object>> dataFileList2 = danganguanliMapper.selectObject(parasMap2);
|
||
|
||
String fileIds = "";
|
||
for (Map<String, Object> mapFile : dataFileList2) {
|
||
String fileId = StringUtil.formatMap(mapFile, "id");
|
||
fileIds = fileIds + fileId + ",";
|
||
|
||
String fieldValue = " file_status=2";
|
||
String conditionSql = " id='" + fileId + "'";
|
||
Map<String, Object> map7 = new HashMap<String, Object>();
|
||
map7.put("tableName", tb3 + "_temp_file");
|
||
map7.put("fieldValue", fieldValue);
|
||
map7.put("conditionSql", conditionSql);
|
||
danganguanliMapper.updateObject(map7);
|
||
}
|
||
if (!"".equals(fileIds)) {
|
||
fileIds = fileIds.substring(0, fileIds.length() - 1);
|
||
}
|
||
|
||
String fieldName = "";
|
||
String valueName = "";
|
||
for (Map.Entry<String, Object> entry : map01.entrySet()) {
|
||
String k = entry.getKey();
|
||
String v = entry.getValue() != null ? String.valueOf(entry.getValue()) : "";
|
||
if (!"id".equals(k)) {
|
||
if (v != null && !"".equals(v)) {
|
||
fieldName = fieldName + k + ",";
|
||
valueName = valueName + "'" + v + "',";
|
||
}
|
||
}
|
||
}
|
||
|
||
fieldName = fieldName + "md5_code";
|
||
valueName = valueName + "'" + fileIds + "'";
|
||
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
map.put("tableName", tb3 + "_temp_trash");
|
||
map.put("fieldName", fieldName);
|
||
map.put("valueName", valueName);
|
||
danganguanliMapper.saveObject(map);
|
||
//添加日志
|
||
UserRole userRole = userService.getUserRole(request);
|
||
User user = userRole.getUser();
|
||
if (user != null) {
|
||
String archiveNo = StringUtil.formatMap(map01, "archive_no");
|
||
//记录日志
|
||
Date date = new Date();
|
||
OperLogger entity = new OperLogger();
|
||
entity.setLogType("1");
|
||
entity.setOperator(user.getUsername());
|
||
entity.setOperatorChn(user.getUserChnName());
|
||
entity.setOperateDate(date);
|
||
entity.setDescription("删除了档号为" + archiveNo);
|
||
entity.setArgs("数据:档号为" + archiveNo);
|
||
operLoggerService.addEntity(entity);
|
||
}
|
||
}
|
||
|
||
String conditionSql2 = " id in (" + threeIds + ") ";
|
||
Map<String, Object> map_temp_file_del = new HashMap<String, Object>();
|
||
map_temp_file_del.put("tableName", tb3 + "_temp");
|
||
map_temp_file_del.put("conditionSql", conditionSql2);
|
||
danganguanliMapper.deleteObject(map_temp_file_del);
|
||
|
||
|
||
} else if (!"".equals(twoIds) && twoIds != null) { //删除第二层和第三层
|
||
Map<String, Object> parasMap1 = new HashMap<String, Object>();
|
||
parasMap1.put("tableName", tb2 + "_temp");
|
||
parasMap1.put("conditionSql", " 1=1 and id in (" + twoIds + ") ");
|
||
List<Map<String, Object>> dataList2 = danganguanliMapper.selectObject(parasMap1);
|
||
|
||
for (Map<String, Object> map01 : dataList2) {
|
||
String id = StringUtil.formatMap(map01, "id");
|
||
//得到临时原文数据列表
|
||
Map<String, Object> parasMap2 = new HashMap<String, Object>();
|
||
parasMap2.put("tableName", tb2 + "_temp_file");
|
||
parasMap2.put("conditionSql", " 1=1 and file_status=1 and rec_id=" + id);
|
||
List<Map<String, Object>> dataFileList2 = danganguanliMapper.selectObject(parasMap2);
|
||
|
||
String fileIds = "";
|
||
for (Map<String, Object> mapFile : dataFileList2) {
|
||
String fileId = StringUtil.formatMap(mapFile, "id");
|
||
fileIds = fileIds + fileId + ",";
|
||
|
||
String fieldValue = " file_status=2";
|
||
String conditionSql = " id='" + fileId + "'";
|
||
Map<String, Object> map7 = new HashMap<String, Object>();
|
||
map7.put("tableName", tb2 + "_temp_file");
|
||
map7.put("fieldValue", fieldValue);
|
||
map7.put("conditionSql", conditionSql);
|
||
danganguanliMapper.updateObject(map7);
|
||
}
|
||
if (!"".equals(fileIds)) {
|
||
fileIds = fileIds.substring(0, fileIds.length() - 1);
|
||
}
|
||
|
||
String fieldName = "";
|
||
String valueName = "";
|
||
for (Map.Entry<String, Object> entry : map01.entrySet()) {
|
||
String k = entry.getKey();
|
||
String v = entry.getValue() != null ? String.valueOf(entry.getValue()) : "";
|
||
if (!"id".equals(k)) {
|
||
if (v != null && !"".equals(v)) {
|
||
fieldName = fieldName + k + ",";
|
||
valueName = valueName + "'" + v + "',";
|
||
}
|
||
}
|
||
}
|
||
|
||
fieldName = fieldName + "md5_code,batch_name,batch_id";
|
||
valueName = valueName + "'" + fileIds + "','" + tb2 + "','" + tb3 + "'";
|
||
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
map.put("tableName", tb2 + "_temp_trash");
|
||
map.put("fieldName", fieldName);
|
||
map.put("valueName", valueName);
|
||
danganguanliMapper.saveObject(map);
|
||
|
||
//第三层卷内也要删除
|
||
Map<String, Object> parasMap21 = new HashMap<String, Object>();
|
||
parasMap21.put("tableName", tb3 + "_temp");
|
||
parasMap21.put("conditionSql", " 1=1 and pid in (" + twoIds + ") ");
|
||
List<Map<String, Object>> dataList22 = danganguanliMapper.selectObject(parasMap21);
|
||
for (Map<String, Object> map23 : dataList22) {
|
||
String juanneiId = StringUtil.formatMap(map23, "id");
|
||
|
||
Map<String, Object> parasMap24 = new HashMap<String, Object>();
|
||
parasMap24.put("tableName", tb3 + "_temp_file");
|
||
parasMap24.put("conditionSql", " 1=1 and file_status=1 and rec_id=" + juanneiId);
|
||
List<Map<String, Object>> dataFileList25 = danganguanliMapper.selectObject(parasMap24);
|
||
|
||
String juanneiFileIds = "";
|
||
for (Map<String, Object> mapFile : dataFileList25) {
|
||
String fileId = StringUtil.formatMap(mapFile, "id");
|
||
juanneiFileIds = juanneiFileIds + fileId + ",";
|
||
|
||
String fieldValue = " file_status=2";
|
||
String conditionSql = " id='" + fileId + "'";
|
||
Map<String, Object> map7 = new HashMap<String, Object>();
|
||
map7.put("tableName", tb3 + "_temp_file");
|
||
map7.put("fieldValue", fieldValue);
|
||
map7.put("conditionSql", conditionSql);
|
||
danganguanliMapper.updateObject(map7);
|
||
}
|
||
if (!"".equals(juanneiFileIds)) {
|
||
juanneiFileIds = juanneiFileIds.substring(0, juanneiFileIds.length() - 1);
|
||
}
|
||
|
||
String fieldName27 = "";
|
||
String valueName28 = "";
|
||
for (Map.Entry<String, Object> entry : map23.entrySet()) {
|
||
String k = entry.getKey();
|
||
String v = entry.getValue() != null ? String.valueOf(entry.getValue()) : "";
|
||
if (!"id".equals(k)) {
|
||
if (v != null && !"".equals(v)) {
|
||
fieldName27 = fieldName27 + k + ",";
|
||
valueName28 = valueName28 + "'" + v + "',";
|
||
}
|
||
}
|
||
}
|
||
|
||
fieldName27 = fieldName27 + "md5_code,batch_name,batch_id";
|
||
valueName28 = valueName28 + "'" + juanneiFileIds + "','" + tb1 + "','" + tb2 + "'";
|
||
|
||
Map<String, Object> map29 = new HashMap<String, Object>();
|
||
map29.put("tableName", tb3 + "_temp_trash");
|
||
map29.put("fieldName", fieldName27);
|
||
map29.put("valueName", valueName28);
|
||
danganguanliMapper.saveObject(map29);
|
||
//添加日志
|
||
UserRole userRole = userService.getUserRole(request);
|
||
User user = userRole.getUser();
|
||
if (user != null) {
|
||
String archiveNo = StringUtil.formatMap(map01, "archive_no");
|
||
//记录日志
|
||
Date date = new Date();
|
||
OperLogger entity = new OperLogger();
|
||
entity.setLogType("1");
|
||
entity.setOperator(user.getUsername());
|
||
entity.setOperatorChn(user.getUserChnName());
|
||
entity.setOperateDate(date);
|
||
entity.setDescription("删除了档号为" + archiveNo);
|
||
entity.setArgs("数据:档号为" + archiveNo);
|
||
operLoggerService.addEntity(entity);
|
||
}
|
||
}
|
||
|
||
String conditionSql2 = " pid in (" + twoIds + ") ";
|
||
Map<String, Object> map_temp_file_del = new HashMap<String, Object>();
|
||
map_temp_file_del.put("tableName", tb3 + "_temp");
|
||
map_temp_file_del.put("conditionSql", conditionSql2);
|
||
danganguanliMapper.deleteObject(map_temp_file_del);
|
||
//添加日志
|
||
UserRole userRole = userService.getUserRole(request);
|
||
User user = userRole.getUser();
|
||
if (user != null) {
|
||
String archiveNo = StringUtil.formatMap(map01, "folder_no");
|
||
//记录日志
|
||
Date date = new Date();
|
||
OperLogger entity = new OperLogger();
|
||
entity.setLogType("1");
|
||
entity.setOperator(user.getUsername());
|
||
entity.setOperatorChn(user.getUserChnName());
|
||
entity.setOperateDate(date);
|
||
entity.setDescription("删除了案卷级档号为" + archiveNo);
|
||
entity.setArgs("数据:案卷级档号档号为" + archiveNo);
|
||
operLoggerService.addEntity(entity);
|
||
}
|
||
}
|
||
|
||
String conditionSql2 = " id in (" + twoIds + ") ";
|
||
Map<String, Object> map_temp_file_del = new HashMap<String, Object>();
|
||
map_temp_file_del.put("tableName", tb2 + "_temp");
|
||
map_temp_file_del.put("conditionSql", conditionSql2);
|
||
danganguanliMapper.deleteObject(map_temp_file_del);
|
||
} else if (!"".equals(oneIds) && oneIds != null) { //删除第一二三层
|
||
Map<String, Object> parasMap1 = new HashMap<String, Object>();
|
||
parasMap1.put("tableName", tb1 + "_temp");
|
||
parasMap1.put("conditionSql", " 1=1 and id in (" + oneIds + ") ");
|
||
List<Map<String, Object>> dataList2 = danganguanliMapper.selectObject(parasMap1);
|
||
|
||
for (Map<String, Object> map01 : dataList2) {
|
||
String id = StringUtil.formatMap(map01, "id");
|
||
//得到临时原文数据列表
|
||
Map<String, Object> parasMap2 = new HashMap<String, Object>();
|
||
parasMap2.put("tableName", tb1 + "_temp_file");
|
||
parasMap2.put("conditionSql", " 1=1 and file_status=1 and rec_id=" + id);
|
||
List<Map<String, Object>> dataFileList2 = danganguanliMapper.selectObject(parasMap2);
|
||
|
||
String fileIds = "";
|
||
for (Map<String, Object> mapFile : dataFileList2) {
|
||
String fileId = StringUtil.formatMap(mapFile, "id");
|
||
fileIds = fileIds + fileId + ",";
|
||
|
||
String fieldValue = " file_status=2";
|
||
String conditionSql = " id='" + fileId + "'";
|
||
Map<String, Object> map7 = new HashMap<String, Object>();
|
||
map7.put("tableName", tb1 + "_temp_file");
|
||
map7.put("fieldValue", fieldValue);
|
||
map7.put("conditionSql", conditionSql);
|
||
danganguanliMapper.updateObject(map7);
|
||
}
|
||
if (!"".equals(fileIds)) {
|
||
fileIds = fileIds.substring(0, fileIds.length() - 1);
|
||
}
|
||
|
||
String fieldName = "";
|
||
String valueName = "";
|
||
for (Map.Entry<String, Object> entry : map01.entrySet()) {
|
||
String k = entry.getKey();
|
||
String v = entry.getValue() != null ? String.valueOf(entry.getValue()) : "";
|
||
if (!"id".equals(k)) {
|
||
if (v != null && !"".equals(v)) {
|
||
fieldName = fieldName + k + ",";
|
||
valueName = valueName + "'" + v + "',";
|
||
}
|
||
}
|
||
}
|
||
|
||
fieldName = fieldName + "md5_code,batch_name,batch_id";
|
||
valueName = valueName + "'" + fileIds + "','" + tb1 + "','" + tb2 + "'";
|
||
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
map.put("tableName", tb1 + "_temp_trash");
|
||
map.put("fieldName", fieldName);
|
||
map.put("valueName", valueName);
|
||
danganguanliMapper.saveObject(map);
|
||
|
||
//第二层要删除
|
||
Map<String, Object> parasMap21 = new HashMap<String, Object>();
|
||
parasMap21.put("tableName", tb2 + "_temp");
|
||
parasMap21.put("conditionSql", " 1=1 and pid in (" + oneIds + ") ");
|
||
List<Map<String, Object>> dataList22 = danganguanliMapper.selectObject(parasMap21);
|
||
String juanneiIdIds = "";
|
||
for (Map<String, Object> map23 : dataList22) {
|
||
String juanneiId = StringUtil.formatMap(map23, "id");
|
||
juanneiIdIds = juanneiIdIds + juanneiId + ",";
|
||
if (!"".equals(juanneiIdIds)) {
|
||
juanneiIdIds = juanneiIdIds.substring(0, juanneiIdIds.length() - 1);
|
||
}
|
||
|
||
Map<String, Object> parasMap24 = new HashMap<String, Object>();
|
||
parasMap24.put("tableName", tb2 + "_temp_file");
|
||
parasMap24.put("conditionSql", " 1=1 and file_status=1 and rec_id=" + juanneiId);
|
||
List<Map<String, Object>> dataFileList25 = danganguanliMapper.selectObject(parasMap24);
|
||
|
||
String juanneiFileIds = "";
|
||
for (Map<String, Object> mapFile : dataFileList25) {
|
||
String fileId = StringUtil.formatMap(mapFile, "id");
|
||
juanneiFileIds = juanneiFileIds + fileId + ",";
|
||
|
||
String fieldValue = " file_status=2";
|
||
String conditionSql = " id='" + fileId + "'";
|
||
Map<String, Object> map7 = new HashMap<String, Object>();
|
||
map7.put("tableName", tb2 + "_temp_file");
|
||
map7.put("fieldValue", fieldValue);
|
||
map7.put("conditionSql", conditionSql);
|
||
danganguanliMapper.updateObject(map7);
|
||
}
|
||
if (!"".equals(juanneiFileIds)) {
|
||
juanneiFileIds = juanneiFileIds.substring(0, juanneiFileIds.length() - 1);
|
||
}
|
||
|
||
String fieldName27 = "";
|
||
String valueName28 = "";
|
||
for (Map.Entry<String, Object> entry : map23.entrySet()) {
|
||
String k = entry.getKey();
|
||
String v = entry.getValue() != null ? String.valueOf(entry.getValue()) : "";
|
||
if (!"id".equals(k)) {
|
||
if (v != null && !"".equals(v)) {
|
||
fieldName27 = fieldName27 + k + ",";
|
||
valueName28 = valueName28 + "'" + v + "',";
|
||
}
|
||
}
|
||
}
|
||
|
||
fieldName27 = fieldName27 + "md5_code,batch_name,batch_id";
|
||
valueName28 = valueName28 + "'" + juanneiFileIds + "','" + tb1 + "','" + tb2 + "'";
|
||
|
||
Map<String, Object> map29 = new HashMap<String, Object>();
|
||
map29.put("tableName", tb2 + "_temp_trash");
|
||
map29.put("fieldName", fieldName27);
|
||
map29.put("valueName", valueName28);
|
||
danganguanliMapper.saveObject(map29);
|
||
}
|
||
|
||
String conditionSql2 = " pid in (" + oneIds + ") ";
|
||
Map<String, Object> map_temp_file_del = new HashMap<String, Object>();
|
||
map_temp_file_del.put("tableName", tb2 + "_temp");
|
||
map_temp_file_del.put("conditionSql", conditionSql2);
|
||
danganguanliMapper.deleteObject(map_temp_file_del);
|
||
|
||
|
||
//删除第三层
|
||
if (StringUtils.isEmpty(juanneiIdIds)) {
|
||
juanneiIdIds = "''";
|
||
}
|
||
Map<String, Object> parasMap3 = new HashMap<String, Object>();
|
||
parasMap3.put("tableName", tb3 + "_temp");
|
||
parasMap3.put("conditionSql", " 1=1 and pid in (" + juanneiIdIds + ") ");
|
||
List<Map<String, Object>> dataList3 = danganguanliMapper.selectObject(parasMap3);
|
||
for (Map<String, Object> map23 : dataList3) {
|
||
String juanneiId = StringUtil.formatMap(map23, "id");
|
||
|
||
Map<String, Object> parasMap24 = new HashMap<String, Object>();
|
||
parasMap24.put("tableName", tb3 + "_temp_file");
|
||
parasMap24.put("conditionSql", " 1=1 and file_status=1 and rec_id=" + juanneiId);
|
||
List<Map<String, Object>> dataFileList25 = danganguanliMapper.selectObject(parasMap24);
|
||
|
||
String juanneiFileIds = "";
|
||
for (Map<String, Object> mapFile : dataFileList25) {
|
||
String fileId = StringUtil.formatMap(mapFile, "id");
|
||
juanneiFileIds = juanneiFileIds + fileId + ",";
|
||
|
||
String fieldValue = " file_status=2";
|
||
String conditionSql = " id='" + fileId + "'";
|
||
Map<String, Object> map7 = new HashMap<String, Object>();
|
||
map7.put("tableName", tb3 + "_temp_file");
|
||
map7.put("fieldValue", fieldValue);
|
||
map7.put("conditionSql", conditionSql);
|
||
danganguanliMapper.updateObject(map7);
|
||
}
|
||
if (!"".equals(juanneiFileIds)) {
|
||
juanneiFileIds = juanneiFileIds.substring(0, juanneiFileIds.length() - 1);
|
||
}
|
||
|
||
String fieldName27 = "";
|
||
String valueName28 = "";
|
||
for (Map.Entry<String, Object> entry : map23.entrySet()) {
|
||
String k = entry.getKey();
|
||
String v = entry.getValue() != null ? String.valueOf(entry.getValue()) : "";
|
||
if (!"id".equals(k)) {
|
||
if (v != null && !"".equals(v)) {
|
||
fieldName27 = fieldName27 + k + ",";
|
||
valueName28 = valueName28 + "'" + v + "',";
|
||
}
|
||
}
|
||
}
|
||
|
||
fieldName27 = fieldName27 + "md5_code,batch_name,batch_id";
|
||
valueName28 = valueName28 + "'" + juanneiFileIds + "','" + tb1 + "','" + tb2 + "'";
|
||
|
||
Map<String, Object> map29 = new HashMap<String, Object>();
|
||
map29.put("tableName", tb3 + "_temp_trash");
|
||
map29.put("fieldName", fieldName27);
|
||
map29.put("valueName", valueName28);
|
||
danganguanliMapper.saveObject(map29);
|
||
}
|
||
|
||
String conditionSql3 = " pid in (" + juanneiIdIds + ") ";
|
||
Map<String, Object> map_temp_file_de3 = new HashMap<String, Object>();
|
||
map_temp_file_de3.put("tableName", tb3 + "_temp");
|
||
map_temp_file_de3.put("conditionSql", conditionSql3);
|
||
danganguanliMapper.deleteObject(map_temp_file_de3);
|
||
//添加日志
|
||
UserRole userRole = userService.getUserRole(request);
|
||
User user = userRole.getUser();
|
||
if (user != null) {
|
||
String archiveNo = StringUtil.formatMap(map01, "item_id");
|
||
//记录日志
|
||
Date date = new Date();
|
||
OperLogger entity = new OperLogger();
|
||
entity.setLogType("1");
|
||
entity.setOperator(user.getUsername());
|
||
entity.setOperatorChn(user.getUserChnName());
|
||
entity.setOperateDate(date);
|
||
entity.setDescription("删除了项目号为" + archiveNo);
|
||
entity.setArgs("数据:项目号为" + archiveNo);
|
||
operLoggerService.addEntity(entity);
|
||
}
|
||
|
||
}
|
||
|
||
String conditionSql2 = " id in (" + oneIds + ") ";
|
||
Map<String, Object> map_temp_file_del = new HashMap<String, Object>();
|
||
map_temp_file_del.put("tableName", tb1 + "_temp");
|
||
map_temp_file_del.put("conditionSql", conditionSql2);
|
||
danganguanliMapper.deleteObject(map_temp_file_del);
|
||
}
|
||
}
|
||
|
||
} catch (Exception e) {
|
||
result = AjaxJson.returnExceptionInfo("删除失败:" + e);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
|
||
/**
|
||
* @param entityId
|
||
* @param ids
|
||
* @return
|
||
*/
|
||
@Transactional
|
||
public AjaxJson<Object> recoveryData(Integer entityId, String ids) {
|
||
AjaxJson<Object> result = null;
|
||
try {
|
||
result = new AjaxJson<>();
|
||
//为了得到表名称
|
||
TtableDescription tableDescription = tableDescriptionMapper.selectTtableDescription(entityId);
|
||
String tableName = tableDescription.getTableName();
|
||
//得到要恢复的数据列表
|
||
Map<String, Object> parasMap1 = new HashMap<String, Object>();
|
||
parasMap1.put("tableName", tableName + "_temp_trash");
|
||
parasMap1.put("conditionSql", " 1=1 and id in (" + ids + ") ");
|
||
List<Map<String, Object>> dataList2 = danganguanliMapper.selectObject(parasMap1);
|
||
for (Map<String, Object> map01 : dataList2) {
|
||
String folder_no = StringUtil.formatMap(map01, "folder_no");
|
||
//
|
||
String md5_code = StringUtil.formatMap(map01, "md5_code");
|
||
//案卷表的名字
|
||
String parentTableName = StringUtil.formatMap(map01, "batch_name");
|
||
|
||
if (parentTableName == null || "".equals(parentTableName)) {
|
||
String fieldName = "";
|
||
String valueName = "";
|
||
for (Map.Entry<String, Object> entry : map01.entrySet()) {
|
||
String k = entry.getKey();
|
||
String v = entry.getValue() != null ? String.valueOf(entry.getValue()) : "";
|
||
if (!"id".equals(k)) {
|
||
if ("md5_code".equals(k)) {
|
||
if (v != null && !"".equals(v)) {
|
||
fieldName = fieldName + "md5_code" + ",";
|
||
valueName = valueName + "'',";
|
||
}
|
||
} else if ("batch_name".equals(k)) {
|
||
if (v != null && !"".equals(v)) {
|
||
fieldName = fieldName + "batch_name" + ",";
|
||
valueName = valueName + "'',";
|
||
}
|
||
} else if ("batch_id".equals(k)) {
|
||
if (v != null && !"".equals(v)) {
|
||
fieldName = fieldName + "batch_id" + ",";
|
||
valueName = valueName + "'',";
|
||
}
|
||
} else {
|
||
if (v != null && !"".equals(v)) {
|
||
fieldName = fieldName + k + ",";
|
||
valueName = valueName + "'" + v + "',";
|
||
}
|
||
}
|
||
}
|
||
}
|
||
fieldName = fieldName.substring(0, fieldName.length() - 1);
|
||
valueName = valueName.substring(0, valueName.length() - 1);
|
||
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
map.put("tableName", tableName + "_temp");
|
||
map.put("fieldName", fieldName);
|
||
map.put("valueName", valueName);
|
||
danganguanliMapper.saveObject(map);
|
||
String myId = StringUtil.formatMap(map, "id");
|
||
|
||
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>();
|
||
map7.put("tableName", tableName + "_temp_file");
|
||
map7.put("fieldValue", fieldValue);
|
||
map7.put("conditionSql", conditionSql);
|
||
danganguanliMapper.updateObject(map7);
|
||
}
|
||
}
|
||
} else {
|
||
|
||
//要迁移 上级回收站的数据到 上级的临时表中,先要判断 上级的临时表 是否存在
|
||
Map<String, Object> parasMap51 = new HashMap<String, Object>();
|
||
parasMap51.put("tableName", parentTableName + "_temp");
|
||
parasMap51.put("conditionSql", " 1=1 and folder_no in ('" + folder_no + "') ");
|
||
List<Map<String, Object>> dataList52 = danganguanliMapper.selectObject(parasMap51);
|
||
int id56 = 0;
|
||
if (dataList52 == null || dataList52.size() == 0) { //该数据的上级不存在
|
||
//把回收站父级的数据迁移到 temp表父级的数据里面
|
||
//1、在回收站中 查询到父级垃圾数据
|
||
Map<String, Object> parasMap53 = new HashMap<String, Object>();
|
||
parasMap53.put("tableName", parentTableName + "_temp_trash");
|
||
parasMap53.put("conditionSql", " 1=1 and folder_no in ('" + folder_no + "') ");
|
||
List<Map<String, Object>> dataList54 = danganguanliMapper.selectObject(parasMap53);
|
||
if (dataList54 == null || dataList54.size() == 0) { //说明回收站和 temp未入库中都没有数据
|
||
result = AjaxJson.returnExceptionInfo("上级档案数据被彻底删除了,该条数据不能恢复!");
|
||
return result;
|
||
}
|
||
//请注意 父亲只有一个
|
||
Map<String, Object> map55 = dataList54.get(0);
|
||
String parent_md5_code = StringUtil.formatMap(map55, "md5_code");
|
||
String fieldName = "";
|
||
String valueName = "";
|
||
for (Map.Entry<String, Object> entry : map55.entrySet()) {
|
||
String k = entry.getKey();
|
||
String v = entry.getValue() != null ? String.valueOf(entry.getValue()) : "";
|
||
if (!"id".equals(k)) {
|
||
if ("md5_code".equals(k)) {
|
||
if (v != null && !"".equals(v)) {
|
||
fieldName = fieldName + "md5_code" + ",";
|
||
valueName = valueName + "'',";
|
||
}
|
||
} else if ("batch_name".equals(k)) {
|
||
if (v != null && !"".equals(v)) {
|
||
fieldName = fieldName + "batch_name" + ",";
|
||
valueName = valueName + "'',";
|
||
}
|
||
} else if ("batch_id".equals(k)) {
|
||
if (v != null && !"".equals(v)) {
|
||
fieldName = fieldName + "batch_id" + ",";
|
||
valueName = valueName + "'',";
|
||
}
|
||
} else {
|
||
if (v != null && !"".equals(v)) {
|
||
fieldName = fieldName + k + ",";
|
||
valueName = valueName + "'" + v + "',";
|
||
}
|
||
}
|
||
}
|
||
}
|
||
fieldName = fieldName.substring(0, fieldName.length() - 1);
|
||
valueName = valueName.substring(0, valueName.length() - 1);
|
||
|
||
Map<String, Object> map56 = new HashMap<String, Object>();
|
||
map56.put("tableName", parentTableName + "_temp");
|
||
map56.put("fieldName", fieldName);
|
||
map56.put("valueName", valueName);
|
||
danganguanliMapper.saveObject(map56);
|
||
id56 = Integer.parseInt(map56.get("id").toString());
|
||
|
||
String[] fileIdArray56 = parent_md5_code.split(",");
|
||
for (String fileId56 : fileIdArray56) {
|
||
String fieldValue = " rec_id=" + id56 + ",file_status=1";
|
||
String conditionSql = " id='" + fileId56 + "'";
|
||
Map<String, Object> map7 = new HashMap<String, Object>();
|
||
map7.put("tableName", parentTableName + "_temp_file");
|
||
map7.put("fieldValue", fieldValue);
|
||
map7.put("conditionSql", conditionSql);
|
||
danganguanliMapper.updateObject(map7);
|
||
}
|
||
|
||
//迁移成功后要删除上级父亲
|
||
String conditionSql2 = " 1=1 and folder_no in ('" + folder_no + "') ";
|
||
Map<String, Object> map_temp_file_del = new HashMap<String, Object>();
|
||
map_temp_file_del.put("tableName", parentTableName + "_temp_trash");
|
||
map_temp_file_del.put("conditionSql", conditionSql2);
|
||
danganguanliMapper.deleteObject(map_temp_file_del);
|
||
} else { //说明上级临时表中存在 数据
|
||
Map<String, Object> map55 = dataList52.get(0);
|
||
id56 = Integer.parseInt(StringUtil.formatMap(map55, "id"));
|
||
}
|
||
|
||
//2、把自己也从 回收站 迁移到 temp表里面
|
||
String fieldName57 = "";
|
||
String valueName57 = "";
|
||
for (Map.Entry<String, Object> entry : map01.entrySet()) {
|
||
String k = entry.getKey();
|
||
String v = entry.getValue() != null ? String.valueOf(entry.getValue()) : "";
|
||
if (!"id".equals(k)) {
|
||
if ("md5_code".equals(k)) {
|
||
if (v != null && !"".equals(v)) {
|
||
fieldName57 = fieldName57 + "md5_code" + ",";
|
||
valueName57 = valueName57 + "'',";
|
||
}
|
||
} else if ("batch_name".equals(k)) {
|
||
if (v != null && !"".equals(v)) {
|
||
fieldName57 = fieldName57 + "batch_name" + ",";
|
||
valueName57 = valueName57 + "'',";
|
||
}
|
||
} else if ("batch_id".equals(k)) {
|
||
if (v != null && !"".equals(v)) {
|
||
fieldName57 = fieldName57 + "batch_id" + ",";
|
||
valueName57 = valueName57 + "'',";
|
||
}
|
||
} else if ("pid".equals(k)) {
|
||
if (v != null && !"".equals(v)) {
|
||
fieldName57 = fieldName57 + "pid" + ",";
|
||
valueName57 = valueName57 + "'" + id56 + "',";
|
||
}
|
||
} else {
|
||
if (v != null && !"".equals(v)) {
|
||
fieldName57 = fieldName57 + k + ",";
|
||
valueName57 = valueName57 + "'" + v + "',";
|
||
}
|
||
}
|
||
}
|
||
}
|
||
fieldName57 = fieldName57.substring(0, fieldName57.length() - 1);
|
||
valueName57 = valueName57.substring(0, valueName57.length() - 1);
|
||
|
||
Map<String, Object> map57 = new HashMap<String, Object>();
|
||
map57.put("tableName", tableName + "_temp");
|
||
map57.put("fieldName", fieldName57);
|
||
map57.put("valueName", valueName57);
|
||
danganguanliMapper.saveObject(map57);
|
||
int id57 = Integer.parseInt(map57.get("id").toString());
|
||
|
||
String[] fileIdArray58 = md5_code.split(",");
|
||
for (String fileId : fileIdArray58) {
|
||
String fieldValue = " rec_id=" + id57 + ",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);
|
||
}
|
||
}
|
||
}
|
||
String conditionSql2 = " id in (" + ids + ") ";
|
||
Map<String, Object> map_temp_file_del = new HashMap<String, Object>();
|
||
map_temp_file_del.put("tableName", tableName + "_temp_trash");
|
||
map_temp_file_del.put("conditionSql", conditionSql2);
|
||
danganguanliMapper.deleteObject(map_temp_file_del);
|
||
} catch (Exception e) {
|
||
result = AjaxJson.returnExceptionInfo("恢复失败:" + e);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
|
||
@Transactional
|
||
public AjaxJson<Object> realDeleteData(Integer entityId, String ids, HttpServletRequest request) {
|
||
AjaxJson<Object> result = null;
|
||
try {
|
||
result = new AjaxJson<>();
|
||
//为了得到表名称
|
||
TtableDescription tableDescription = tableDescriptionMapper.selectTtableDescription(entityId);
|
||
String tableName = tableDescription.getTableName();
|
||
//得到要恢复的数据列表
|
||
Map<String, Object> parasMap1 = new HashMap<String, Object>();
|
||
parasMap1.put("tableName", tableName + "_temp_trash");
|
||
parasMap1.put("conditionSql", " 1=1 and id in (" + ids + ") ");
|
||
List<Map<String, Object>> dataList2 = danganguanliMapper.selectObject(parasMap1);
|
||
for (Map<String, Object> map01 : dataList2) {
|
||
//简化-文件级档号
|
||
String archive_no = StringUtil.formatMap(map01, "archive_no");
|
||
//传统-案卷级档号
|
||
String folder_no = StringUtil.formatMap(map01, "folder_no");
|
||
// 原文 temp_file表的id字段,多个用 逗号隔开,如1,2,3
|
||
String md5_code = StringUtil.formatMap(map01, "md5_code");
|
||
String fileids = md5_code;
|
||
//案卷表的名字
|
||
String parentTableName = StringUtil.formatMap(map01, "batch_name");
|
||
if (archive_no != null && !"".equals(archive_no)) { //说明是简化,只有一层
|
||
//查询得到 原文数据
|
||
if (fileids != null && !"".equals(fileids)) {
|
||
Map<String, Object> parasMap11 = new HashMap<String, Object>();
|
||
parasMap11.put("tableName", tableName + "_temp_file");
|
||
parasMap11.put("conditionSql", " 1=1 and id in (" + fileids + ") ");
|
||
List<Map<String, Object>> dataListFileJPG11 = danganguanliMapper.selectObject(parasMap11);
|
||
//要彻底删除原文数据库数据
|
||
String conditionSql2 = " id in (" + fileids + ") ";
|
||
Map<String, Object> map_temp_file_del = new HashMap<String, Object>();
|
||
map_temp_file_del.put("tableName", tableName + "_temp_file");
|
||
map_temp_file_del.put("conditionSql", conditionSql2);
|
||
danganguanliMapper.deleteObject(map_temp_file_del);
|
||
//要彻底删除原文图片文件
|
||
for (Map<String, Object> mapFile12 : dataListFileJPG11) {
|
||
String file_path = StringUtil.formatMap(mapFile12, "file_path");
|
||
String file_name_server = StringUtil.formatMap(mapFile12, "file_name_server");
|
||
String file_name_pdf = file_name_server.replaceAll(".jpg", ".pdf");
|
||
String file_name_original_pdf = file_name_pdf.replaceAll(".pdf", "_original.pdf");
|
||
String whole_file_path = request.getRealPath("/") + file_path + "/";
|
||
String jpg = whole_file_path + file_name_server;
|
||
String pdf = whole_file_path + file_name_pdf;
|
||
String original_pdf = whole_file_path + file_name_original_pdf;
|
||
FileUtil.deleteFile(jpg);
|
||
FileUtil.deleteFile(pdf);
|
||
FileUtil.deleteFile(original_pdf);
|
||
}
|
||
}
|
||
} else { //说明是传统,则有2层
|
||
//说明是父级,要删除父级案卷和子级、卷内和子级
|
||
//删除案卷的原文和图片
|
||
//查询得到 原文数据
|
||
if (fileids != null && !"".equals(fileids)) {
|
||
Map<String, Object> parasMap11 = new HashMap<String, Object>();
|
||
parasMap11.put("tableName", tableName + "_temp_file");
|
||
parasMap11.put("conditionSql", " 1=1 and id in (" + fileids + ") ");
|
||
List<Map<String, Object>> dataListFileJPG11 = danganguanliMapper.selectObject(parasMap11);
|
||
//要彻底删除原文数据库数据
|
||
String conditionSql2 = " id in (" + fileids + ") ";
|
||
Map<String, Object> map_temp_file_del = new HashMap<String, Object>();
|
||
map_temp_file_del.put("tableName", tableName + "_temp_file");
|
||
map_temp_file_del.put("conditionSql", conditionSql2);
|
||
danganguanliMapper.deleteObject(map_temp_file_del);
|
||
//要彻底删除原文图片文件
|
||
for (Map<String, Object> mapFile12 : dataListFileJPG11) {
|
||
String file_path = StringUtil.formatMap(mapFile12, "file_path");
|
||
String file_name_server = StringUtil.formatMap(mapFile12, "file_name_server");
|
||
String file_name_pdf = file_name_server.replaceAll(".jpg", ".pdf");
|
||
String file_name_original_pdf = file_name_pdf.replaceAll(".pdf", "_original.pdf");
|
||
String whole_file_path = request.getRealPath("/") + file_path + "/";
|
||
String jpg = whole_file_path + file_name_server;
|
||
String pdf = whole_file_path + file_name_pdf;
|
||
String original_pdf = whole_file_path + file_name_original_pdf;
|
||
FileUtil.deleteFile(jpg);
|
||
FileUtil.deleteFile(pdf);
|
||
FileUtil.deleteFile(original_pdf);
|
||
}
|
||
}
|
||
|
||
//得到 卷内的表名字
|
||
String batch_id = StringUtil.formatMap(map01, "batch_id");
|
||
String juanneiTable = batch_id;
|
||
|
||
//接着删除 卷内和原文图片
|
||
Map<String, Object> parasMap53 = new HashMap<String, Object>();
|
||
parasMap53.put("tableName", juanneiTable + "_temp_trash");
|
||
parasMap53.put("conditionSql", " 1=1 and folder_no in ('" + folder_no + "') ");
|
||
List<Map<String, Object>> dataList20 = danganguanliMapper.selectObject(parasMap53);
|
||
|
||
String conditionSql21 = " folder_no in ('" + folder_no + "') ";
|
||
Map<String, Object> map_temp_file_del21 = new HashMap<String, Object>();
|
||
map_temp_file_del21.put("tableName", juanneiTable + "_temp_trash");
|
||
map_temp_file_del21.put("conditionSql", conditionSql21);
|
||
danganguanliMapper.deleteObject(map_temp_file_del21);
|
||
//删除原文
|
||
for (Map<String, Object> map22 : dataList20) {
|
||
// 原文 temp_file表的id字段,多个用 逗号隔开,如1,2,3
|
||
String md5_code23 = StringUtil.formatMap(map22, "md5_code");
|
||
String fileids23 = md5_code23;
|
||
if (fileids23 != null && !"".equals(fileids23)) {
|
||
//查询得到 原文数据
|
||
Map<String, Object> parasMap23 = new HashMap<String, Object>();
|
||
parasMap23.put("tableName", tableName + "_temp_file");
|
||
parasMap23.put("conditionSql", " 1=1 and id in (" + fileids23 + ") ");
|
||
List<Map<String, Object>> dataListFileJPG23 = danganguanliMapper.selectObject(parasMap23);
|
||
//要彻底删除原文数据库数据
|
||
String conditionSql23 = " id in (" + fileids23 + ") ";
|
||
Map<String, Object> map_temp_file_del23 = new HashMap<String, Object>();
|
||
map_temp_file_del23.put("tableName", juanneiTable + "_temp_file");
|
||
map_temp_file_del23.put("conditionSql", conditionSql23);
|
||
danganguanliMapper.deleteObject(map_temp_file_del23);
|
||
//要彻底删除原文图片文件
|
||
for (Map<String, Object> mapFile123 : dataListFileJPG23) {
|
||
String file_path = StringUtil.formatMap(mapFile123, "file_path");
|
||
String file_name_server = StringUtil.formatMap(mapFile123, "file_name_server");
|
||
String file_name_pdf = file_name_server.replaceAll(".jpg", ".pdf");
|
||
String file_name_original_pdf = file_name_pdf.replaceAll(".pdf", "_original.pdf");
|
||
String whole_file_path = request.getRealPath("/") + file_path + "/";
|
||
String jpg = whole_file_path + file_name_server;
|
||
String pdf = whole_file_path + file_name_pdf;
|
||
String original_pdf = whole_file_path + file_name_original_pdf;
|
||
FileUtil.deleteFile(jpg);
|
||
FileUtil.deleteFile(pdf);
|
||
FileUtil.deleteFile(original_pdf);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
String conditionSql2 = " id in (" + ids + ") ";
|
||
Map<String, Object> map_temp_file_del = new HashMap<String, Object>();
|
||
map_temp_file_del.put("tableName", tableName + "_temp_trash");
|
||
map_temp_file_del.put("conditionSql", conditionSql2);
|
||
danganguanliMapper.deleteObject(map_temp_file_del);
|
||
} catch (Exception e) {
|
||
result = AjaxJson.returnExceptionInfo("正式删除数据失败:" + e);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
|
||
//检查原文图片数量
|
||
public AjaxJson checkFileImgNum(JSONObject jsonObject) {
|
||
AjaxJson<Object> json = new AjaxJson<>();
|
||
Integer zhujianId = jsonObject.getInteger("id");
|
||
String tableName = jsonObject.getString("tableName");
|
||
String funcTypeCode = jsonObject.getString("funcTypeCode");
|
||
String tableNameTiaoMu="";
|
||
String tableNameYuanwen="";
|
||
if (funcTypeCode==null ||"".equals(funcTypeCode)){
|
||
tableNameTiaoMu=tableName;
|
||
tableNameYuanwen=tableName + "_file";
|
||
}else {
|
||
tableNameTiaoMu=tableName + "_" + funcTypeCode;
|
||
tableNameYuanwen=tableName + "_" + funcTypeCode + "_file";
|
||
}
|
||
|
||
//得到主表数据列表
|
||
Map<String, Object> parasMap = new HashMap<String, Object>();
|
||
parasMap.put("tableName", tableNameTiaoMu);
|
||
parasMap.put("conditionSql", " id in ( " + zhujianId + " )");
|
||
List<Map<String, Object>> dataList = danganguanliMapper.selectObject(parasMap);
|
||
Map<String, Object> map0 = dataList.get(0);
|
||
|
||
// 查找页数字段
|
||
// 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;
|
||
}
|
||
|
||
//得到主表--原文图片数据列表
|
||
Map<String, Object> parasMapFile = new HashMap<String, Object>();
|
||
parasMapFile.put("tableName", tableNameYuanwen);
|
||
parasMapFile.put("conditionSql", " rec_id in ( " + zhujianId + " ) and file_status=1 ");
|
||
List<Map<String, Object>> dataFile= danganguanliMapper.selectObject(parasMapFile);
|
||
int sumFile=0;
|
||
for (Map<String, Object> map:dataFile) {
|
||
String file_name_server = StringUtil.formatMap(map, "file_name_server");
|
||
file_name_server = file_name_server.replaceAll(".jpg", ".pdf");
|
||
String file_path = StringUtil.formatMap(map, "file_path");
|
||
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.getPdfPageCounOrOther(dir);
|
||
System.out.println(count);
|
||
sumFile=sumFile+count;
|
||
}
|
||
|
||
if (quantity!=sumFile && quantityFlag!=0){
|
||
//json = AjaxJson.returnExceptionInfo("页数和原文数量是否匹配!");
|
||
json.put("info","页数和原文数量不匹配!");
|
||
}
|
||
return json;
|
||
}
|
||
|
||
}
|