手册排序优化

This commit is contained in:
zhal 2023-07-07 15:24:22 +08:00
parent be4a711ac6
commit 84d9ffb931
3 changed files with 1736 additions and 1716 deletions

View File

@ -1,15 +1,16 @@
package com.actionsoft.apps.coe.pal.pal.output.util;
import java.awt.*;
import java.io.*;
import java.sql.Timestamp;
import java.util.*;
import java.util.List;
import java.util.stream.Stream;
import com.actionsoft.apps.coe.pal.constant.CoEConstant;
import com.actionsoft.apps.coe.pal.pal.method.cache.PALMethodCache;
import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodAttributeModel;
import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodModel;
import com.actionsoft.apps.coe.pal.pal.repository.PALRepositoryQueryAPIManager;
import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache;
import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.cache.DesignerShapeRelationCache;
import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.dao.DesignerShapeRelationDao;
import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.model.DesignerShapeRelationModel;
import com.actionsoft.apps.coe.pal.pal.repository.designer.util.CoeDesignerUtil;
import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel;
import com.actionsoft.apps.coe.pal.pal.repository.upfile.constant.CoeFileConstant;
import com.actionsoft.apps.coe.pal.pal.repository.upfile.dao.UpFileDao;
import com.actionsoft.apps.coe.pal.pal.repository.upfile.model.UpfileModel;
@ -23,37 +24,23 @@ import com.actionsoft.bpms.server.fs.DCContext;
import com.actionsoft.bpms.server.fs.dc.DCProfileManager;
import com.actionsoft.bpms.util.UtilFile;
import com.actionsoft.bpms.util.UtilString;
import com.actionsoft.apps.coe.pal.pal.method.cache.PALMethodCache;
import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodAttributeModel;
import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodModel;
import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache;
import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.dao.DesignerShapeRelationDao;
import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.model.DesignerShapeRelationModel;
import com.actionsoft.apps.coe.pal.pal.repository.designer.util.CoeDesignerUtil;
import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel;
import com.actionsoft.sdk.local.SDK;
import com.alibaba.fastjson.JSON;
import com.google.gson.JsonObject;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.sini.com.spire.doc.*;
import com.sini.com.spire.doc.documents.*;
import com.sini.com.spire.doc.fields.DocPicture;
import com.sini.com.spire.doc.fields.TextRange;
import com.sini.com.spire.doc.formatting.CharacterFormat;
import com.sini.com.spire.doc.formatting.ParagraphFormat;
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import org.docx4j.wml.P;
import org.pptx4j.pml.Presentation;
import org.xlsx4j.sml.Col;
import java.awt.*;
import java.io.*;
import java.util.List;
import java.util.*;
public class OutputWordUtil {
@ -206,7 +193,7 @@ public class OutputWordUtil {
}
try {
if (t!= null && out != null) {
if (t != null && out != null) {
t.process(dataMap, out);
out.flush();
out.close();
@ -219,8 +206,6 @@ public class OutputWordUtil {
}
/**
* 生成word文件
*
@ -229,7 +214,7 @@ public class OutputWordUtil {
* @param tempName
* @param docName
*/
public static void createZdDoc2(JSONObject dataMap, String tempPath, String tempName, String docName,JSONObject wizardJsonData,String repositoryId) throws FileNotFoundException {
public static void createZdDoc2(JSONObject dataMap, String tempPath, String tempName, String docName, JSONObject wizardJsonData, String repositoryId) throws FileNotFoundException {
Configuration configuration = new Configuration();
configuration.setDefaultEncoding("UTF-8");
@ -257,7 +242,7 @@ public class OutputWordUtil {
try {
if (t!= null && out != null) {
if (t != null && out != null) {
t.process(dataMap, out);
out.flush();
out.close();
@ -269,12 +254,6 @@ public class OutputWordUtil {
}
//***********************************************************使用spire 生成模板后复制文件****************************************************/
List<Map<String, Object>> repositoryFileElements = CoeDesignerUtil.getShapeMessageJson4(repositoryId); //流程文件内容
if (wizardJsonData.getBoolean("orderNuberFirst")) { // 根据页面选择进行排序
@ -290,14 +269,14 @@ public class OutputWordUtil {
String type = shape.get("type").toString();
if ("regulation".equals(type)) {
controlShapeId = shape.get("id").toString();
}else if("I/O_L4".equals(type)) {
} else if ("I/O_L4".equals(type)) {
controlShapeId = shape.get("id").toString();
}
}
}
UserContext userContext=DispatcherRequest.getUserContext();
UserContext userContext = DispatcherRequest.getUserContext();
Map<String, String> result = new HashMap<>();
result.put("listDef", "");
@ -332,7 +311,7 @@ public class OutputWordUtil {
Document document = new Document(outFile.getPath());
//将另一个文档插入当前文档
document.insertTextFromFile(path+fileName, FileFormat.Docx_2013);
document.insertTextFromFile(path + fileName, FileFormat.Docx_2013);
// document.insertTextFromFile("/Users/sunlh/Downloads/手册格式问题测试文档(3)new.docx", FileFormat.Docx_2013);
//保存结果文档
document.saveToFile(outFile.getPath(), FileFormat.Docx_2013);
@ -343,7 +322,7 @@ public class OutputWordUtil {
/****************************插入支持文件、相关文件、附则等信息********************************************************/
Document doc=new Document(outFile.getPath());
Document doc = new Document(outFile.getPath());
//获取最后一节
Section section = doc.getLastSection();
@ -352,7 +331,7 @@ public class OutputWordUtil {
JSONArray relevant_flies = new JSONArray(); //组织职责Table
List<DesignerShapeRelationModel> relationList2 = DesignerShapeRelationCache.getListByAttrId(repositoryModel.getId(), "", "related_files");
int count = 0;
if(relationList2.size()>0) {
if (relationList2.size() > 0) {
for (DesignerShapeRelationModel relation : relationList2) {
String relationFileId = relation.getRelationFileId();// 支持或相关文件的ID
PALRepositoryModel model = PALRepositoryCache.getCache().get(relationFileId);
@ -397,7 +376,7 @@ public class OutputWordUtil {
strArray[0] = jsonObject.getString("desc").toString();
strArray[1] = jsonObject.getString("name").toString();
list.add(strArray);
strArray2[i]=strArray;
strArray2[i] = strArray;
}
String[][] data = strArray2;
@ -438,7 +417,7 @@ public class OutputWordUtil {
JSONArray supportfiles = new JSONArray(); //组织职责Table
List<DesignerShapeRelationModel> relationList = DesignerShapeRelationCache.getListByAttrId(repositoryModel.getId(), "", "support_files");
int index = 0;
if(relationList.size()>0){
if (relationList.size() > 0) {
for (DesignerShapeRelationModel relation : relationList) {
String relationFileId = relation.getRelationFileId();// 支持或相关文件的ID
PALRepositoryModel model = PALRepositoryCache.getCache().get(relationFileId);
@ -453,14 +432,14 @@ public class OutputWordUtil {
}
CharacterFormat format2=new CharacterFormat();
CharacterFormat format2 = new CharacterFormat();
//创建字体格式
format2.setFontName("宋体");
//添加段落设置一级序列
Paragraph paragraph2 = section.addParagraph();
ParagraphFormat paragraphFormat2 = paragraph2.getFormat();
paragraphFormat2.setHorizontalAlignment(HorizontalAlignment.Left);
TextRange tr2=paragraph2.appendText("支持文件");
TextRange tr2 = paragraph2.appendText("支持文件");
tr2.getCharacterFormat().setBold(true);
tr2.getCharacterFormat().setFontName("宋体");
paragraph2.applyStyle(BuiltinStyle.Heading_1); //应用标题1样式
@ -476,7 +455,7 @@ public class OutputWordUtil {
strArray[0] = jsonObject.getString("desc").toString();
strArray[1] = jsonObject.getString("name").toString();
list.add(strArray);
strArray2[i]=strArray;
strArray2[i] = strArray;
}
String[][] data = strArray2;
@ -538,7 +517,7 @@ public class OutputWordUtil {
tr5.getCharacterFormat().setFontName("宋体");*/
CharacterFormat format4=new CharacterFormat();
CharacterFormat format4 = new CharacterFormat();
//创建字体格式
format4.setFontName("宋体");
//添加段落
@ -547,7 +526,8 @@ public class OutputWordUtil {
ParagraphFormat paragraphFormat4 = paragraph4.getFormat();
paragraphFormat4.setHorizontalAlignment(HorizontalAlignment.Left);
TextRange tr4 = paragraph4.appendText("附件");;
TextRange tr4 = paragraph4.appendText("附件");
;
tr4.getCharacterFormat().setBold(true);
tr4.getCharacterFormat().setFontName("宋体");
@ -557,8 +537,9 @@ public class OutputWordUtil {
//查询模型文件属性上传附件信息
List<UpfileModel> search2 = upFileDao.searchByRepositoryId(repositoryModel.getId(),"f");
List<UpfileModel> search2 = upFileDao.searchByRepositoryIdGroupByFilename(repositoryModel.getId(), "f");
System.out.println("search2==================" + search2.toString());
DCContext dcContextModel = null;
@ -566,11 +547,11 @@ public class OutputWordUtil {
Collections.sort(search2, new Comparator<UpfileModel>() {
@Override
public int compare(UpfileModel o1, UpfileModel o2) {
String p1=o1.getFileName();
String p2=o2.getFileName();
if(p1.substring(0,2).equals("附件") && p2.substring(0,2).equals("附件")){
return Integer.parseInt(p1.substring(2,p1.indexOf(""))) - Integer.parseInt(p2.substring(2,p2.indexOf("")));
}else{
String p1 = o1.getFileName();
String p2 = o2.getFileName();
if ((p1.substring(0, 2).equals("附件") && p2.substring(0, 2).equals("附件") && p1.indexOf("") != -1 && p2.indexOf("") != -1)) {
return Integer.parseInt(p1.substring(2, p1.indexOf(""))) - Integer.parseInt(p2.substring(2, p2.indexOf("")));
} else {
return 0;
}
@ -603,51 +584,59 @@ public class OutputWordUtil {
if (suffix.equals(".doc") || suffix.equals(".docx")) {
pic1.loadImage("../doccenter/com.awspaas.user.apps.coe.pal.output.zd/filepic/word.png");
paragraph5.appendText(dcContextModel.getFileName());
if(suffix.equals(".doc")){
if (suffix.equals(".doc")) {
paragraph5.appendOleObject(stream1, pic1, "doc");
}else if(suffix.equals(".docx")){
} else if (suffix.equals(".docx")) {
paragraph5.appendOleObject(stream1, pic1, "docx");
}
}else if(suffix.equals(".pdf")){
} else if (suffix.equals(".pdf")) {
pic1.loadImage("../doccenter/com.awspaas.user.apps.coe.pal.output.zd/filepic/pdf.png");
paragraph5.appendText(dcContextModel.getFileName());
paragraph5.appendOleObject(stream1, pic1, "pdf");
}else if(suffix.equals(".xls") || suffix.equals(".xlsx")){
} else if (suffix.equals(".xls") || suffix.equals(".xlsx")) {
pic1.loadImage("../doccenter/com.awspaas.user.apps.coe.pal.output.zd/filepic/xls.png");
paragraph5.appendText(dcContextModel.getFileName());
if(suffix.equals(".xls")){
if (suffix.equals(".xls")) {
paragraph5.appendOleObject(stream1, pic1, "xls");
}else if(suffix.equals(".xlsx")){
} else if (suffix.equals(".xlsx")) {
paragraph5.appendOleObject(stream1, pic1, "xlsx");
}
}else if(suffix.equals(".png") || suffix.equals(".jgp")){
} else if (suffix.equals(".png") || suffix.equals(".jgp")) {
pic1.loadImage("../doccenter/com.awspaas.user.apps.coe.pal.output.zd/filepic/png.png");
paragraph5.appendText(dcContextModel.getFileName());
if(suffix.equals(".png")){
if (suffix.equals(".png")) {
paragraph5.appendOleObject(stream1, pic1, "png");
}else if(suffix.equals(".jpg")){
} else if (suffix.equals(".jpg")) {
paragraph5.appendOleObject(stream1, pic1, "jpg");
}
}else if(suffix.equals(".zip") || suffix.equals(".rar")){
} else if (suffix.equals(".zip") || suffix.equals(".rar")) {
pic1.loadImage("../doccenter/com.awspaas.user.apps.coe.pal.output.zd/filepic/zip.png");
paragraph5.appendText(dcContextModel.getFileName());
if(suffix.equals(".zip")){
if (suffix.equals(".zip")) {
paragraph5.appendOleObject(stream1, pic1, "zip");
}else if(suffix.equals(".rar")){
} else if (suffix.equals(".rar")) {
paragraph5.appendOleObject(stream1, pic1, "rar");
}
}else if(suffix.equals(".mp3") || suffix.equals(".mp4")){
} else if (suffix.equals(".mp3") || suffix.equals(".mp4")) {
pic1.loadImage("../doccenter/com.awspaas.user.apps.coe.pal.output.zd/filepic/mp3.png");
paragraph5.appendText(dcContextModel.getFileName());
if(suffix.equals(".mp3")){
if (suffix.equals(".mp3")) {
paragraph5.appendOleObject(stream1, pic1, "mp3");
}else if(suffix.equals(".mp4")){
} else if (suffix.equals(".mp4")) {
paragraph5.appendOleObject(stream1, pic1, "mp4");
}
}else if(suffix.equals(".txt")){
} else if (suffix.equals(".txt")) {
pic1.loadImage("../doccenter/com.awspaas.user.apps.coe.pal.output.zd/filepic/txt.png");
paragraph5.appendText(dcContextModel.getFileName());
paragraph5.appendOleObject(stream1, pic1, "txt");
} else if (suffix.equals(".ppt") || suffix.equals(".pptx")) {
pic1.loadImage("../doccenter/com.awspaas.user.apps.coe.pal.output.zd/filepic/ppt.png");
paragraph5.appendText(dcContextModel.getFileName());
if (suffix.equals(".ppt")) {
paragraph5.appendOleObject(stream1, pic1, "ppt");
} else if (suffix.equals(".pptx")) {
paragraph5.appendOleObject(stream1, pic1, "pptx");
}
}
@ -660,8 +649,6 @@ public class OutputWordUtil {
}
/**
* 生成word文件
*
@ -670,7 +657,7 @@ public class OutputWordUtil {
* @param tempName
* @param docName
*/
public static void createBdDoc2(JSONObject dataMap, String tempPath, String tempName, String docName,String repositoryId) throws FileNotFoundException {
public static void createBdDoc2(JSONObject dataMap, String tempPath, String tempName, String docName, String repositoryId) throws FileNotFoundException {
Configuration configuration = new Configuration();
configuration.setDefaultEncoding("UTF-8");
@ -697,7 +684,7 @@ public class OutputWordUtil {
}
try {
if (t!= null && out != null) {
if (t != null && out != null) {
t.process(dataMap, out);
out.flush();
out.close();
@ -709,12 +696,12 @@ public class OutputWordUtil {
}
/**************************************************插入文件对象**********************************************************************/
Document doc=new Document(outFile.getPath());
Document doc = new Document(outFile.getPath());
//获取最后一节
Section section = doc.getLastSection();
CharacterFormat format4=new CharacterFormat();
CharacterFormat format4 = new CharacterFormat();
//创建字体格式
format4.setFontName("宋体");
//添加段落
@ -737,11 +724,11 @@ public class OutputWordUtil {
UpFileDao upFileDao = new UpFileDao();
//查询模型文件属性上传附件信息
List<UpfileModel> search = upFileDao.searchByRepositoryId(repositoryModel.getId(),"s");
List<UpfileModel> search = upFileDao.searchByRepositoryId(repositoryModel.getId(), "s");
DCContext dcContextModel = null;
UserContext userContext=DispatcherRequest.getUserContext();
UserContext userContext = DispatcherRequest.getUserContext();
if (search != null && search.size() > 0) {
// 复制附件
for (UpfileModel upfileModel : search) {
@ -753,7 +740,6 @@ public class OutputWordUtil {
String fileName = dcContextModel.getFileName();
//添加段落
Paragraph paragraph5 = section.addParagraph();
@ -771,51 +757,59 @@ public class OutputWordUtil {
if (suffix.equals(".doc") || suffix.equals(".docx")) {
pic1.loadImage("../doccenter/com.awspaas.user.apps.coe.pal.output.zd/filepic/word.png");
paragraph5.appendText(dcContextModel.getFileName());
if(suffix.equals(".doc")){
if (suffix.equals(".doc")) {
paragraph5.appendOleObject(stream1, pic1, "doc");
}else if(suffix.equals(".docx")){
} else if (suffix.equals(".docx")) {
paragraph5.appendOleObject(stream1, pic1, "docx");
}
}else if(suffix.equals(".pdf")){
} else if (suffix.equals(".pdf")) {
pic1.loadImage("../doccenter/com.awspaas.user.apps.coe.pal.output.zd/filepic/pdf.png");
paragraph5.appendText(dcContextModel.getFileName());
paragraph5.appendOleObject(stream1, pic1, "pdf");
}else if(suffix.equals(".xls") || suffix.equals(".xlsx")){
} else if (suffix.equals(".xls") || suffix.equals(".xlsx")) {
pic1.loadImage("../doccenter/com.awspaas.user.apps.coe.pal.output.zd/filepic/xls.png");
paragraph5.appendText(dcContextModel.getFileName());
if(suffix.equals(".xls")){
if (suffix.equals(".xls")) {
paragraph5.appendOleObject(stream1, pic1, "xls");
}else if(suffix.equals(".xlsx")){
} else if (suffix.equals(".xlsx")) {
paragraph5.appendOleObject(stream1, pic1, "xlsx");
}
}else if(suffix.equals(".png") || suffix.equals(".jgp")){
} else if (suffix.equals(".png") || suffix.equals(".jgp")) {
pic1.loadImage("../doccenter/com.awspaas.user.apps.coe.pal.output.zd/filepic/png.png");
paragraph5.appendText(dcContextModel.getFileName());
if(suffix.equals(".png")){
if (suffix.equals(".png")) {
paragraph5.appendOleObject(stream1, pic1, "png");
}else if(suffix.equals(".jpg")){
} else if (suffix.equals(".jpg")) {
paragraph5.appendOleObject(stream1, pic1, "jpg");
}
}else if(suffix.equals(".zip") || suffix.equals(".rar")){
} else if (suffix.equals(".zip") || suffix.equals(".rar")) {
pic1.loadImage("../doccenter/com.awspaas.user.apps.coe.pal.output.zd/filepic/zip.png");
paragraph5.appendText(dcContextModel.getFileName());
if(suffix.equals(".zip")){
if (suffix.equals(".zip")) {
paragraph5.appendOleObject(stream1, pic1, "zip");
}else if(suffix.equals(".rar")){
} else if (suffix.equals(".rar")) {
paragraph5.appendOleObject(stream1, pic1, "rar");
}
}else if(suffix.equals(".mp3") || suffix.equals(".mp4")){
} else if (suffix.equals(".mp3") || suffix.equals(".mp4")) {
pic1.loadImage("../doccenter/com.awspaas.user.apps.coe.pal.output.zd/filepic/mp3.png");
paragraph5.appendText(dcContextModel.getFileName());
if(suffix.equals(".mp3")){
if (suffix.equals(".mp3")) {
paragraph5.appendOleObject(stream1, pic1, "mp3");
}else if(suffix.equals(".mp4")){
} else if (suffix.equals(".mp4")) {
paragraph5.appendOleObject(stream1, pic1, "mp4");
}
}else if(suffix.equals(".txt")){
} else if (suffix.equals(".txt")) {
pic1.loadImage("../doccenter/com.awspaas.user.apps.coe.pal.output.zd/filepic/txt.png");
paragraph5.appendText(dcContextModel.getFileName());
paragraph5.appendOleObject(stream1, pic1, "txt");
} else if (suffix.equals(".ppt") || suffix.equals(".pptx")) {
pic1.loadImage("../doccenter/com.awspaas.user.apps.coe.pal.output.zd/filepic/ppt.png");
paragraph5.appendText(dcContextModel.getFileName());
if (suffix.equals(".ppt")) {
paragraph5.appendOleObject(stream1, pic1, "ppt");
} else if (suffix.equals(".pptx")) {
paragraph5.appendOleObject(stream1, pic1, "pptx");
}
}
@ -828,8 +822,6 @@ public class OutputWordUtil {
}
/**
* 将文件的扩展属性设置默认值为空字符串防止没有设置扩展属性而使得导出文件出错
*
@ -859,6 +851,7 @@ public class OutputWordUtil {
/**
* 将文件的扩展属性设置默认值为空字符串防止没有设置扩展属性而使得导出文件出错
* com.alibaba.fastjson
*
* @param methodScope
* @param dataMap
*/
@ -922,6 +915,7 @@ public class OutputWordUtil {
/**
* 将文件中图形元素的扩展属性默认值设为空字符串防止没有设置扩展属性而使得导出文件出错
*
* @param repositoryId
* @param _tr
*/
@ -983,7 +977,7 @@ public class OutputWordUtil {
public static String set2string(Set<String> set) {
StringBuilder result = new StringBuilder();
if (set.size() > 0) {
for (Iterator<String> it = set.iterator(); it.hasNext();) {
for (Iterator<String> it = set.iterator(); it.hasNext(); ) {
result.append(it.next());
result.append(",");
}
@ -1044,7 +1038,7 @@ public class OutputWordUtil {
JSONArray dataAttributesJsonArray = dataAttributes.getJSONArray("attributesJsonArray");
for (int i = 0; i < dataAttributesJsonArray.size(); i++) {
JSONObject dataAttribute = dataAttributesJsonArray.getJSONObject(i);
if(dataAttribute == null || "null".equals(dataAttribute.toString())) {
if (dataAttribute == null || "null".equals(dataAttribute.toString())) {
continue; //跳过dataAttributesJsonArray中的空
}
if (dataAttribute.containsKey("key") && dataAttribute.containsKey("value")) {
@ -1084,6 +1078,7 @@ public class OutputWordUtil {
/**
* 如果图形元素属性中有关联的图形获取关联的流程文件的数据Table
* com.alibaba.fastjson
*
* @param repositoryId
* @param table
* @param relationShapeIds
@ -1092,7 +1087,7 @@ public class OutputWordUtil {
public static void setTableValue2(String repositoryId, JSONArray table, String relationShapeIds) {
// 记录关联属性的流程节点防止多次查询重复文件信息耗费时间
Set<String> relationFileIds = new HashSet<>();
List<Map<String, Object>> relationFileElements2 = new ArrayList<Map<String,Object>>();
List<Map<String, Object>> relationFileElements2 = new ArrayList<Map<String, Object>>();
relationShapeIds = relationShapeIds.replace("[", "").replace("]", "").replace("\"", "");
if (!"".equals(relationShapeIds)) {
@ -1224,7 +1219,7 @@ public class OutputWordUtil {
JSONArray dataAttributesJsonArray = dataAttributes.getJSONArray("attributesJsonArray");
for (int i = 0; i < dataAttributesJsonArray.size(); i++) {
JSONObject dataAttribute = dataAttributesJsonArray.getJSONObject(i);
if(dataAttribute == null || "null".equals(dataAttribute.toString())) {
if (dataAttribute == null || "null".equals(dataAttribute.toString())) {
continue;
}
if (dataAttribute.containsKey("key") && dataAttribute.containsKey("value")) {
@ -1347,6 +1342,7 @@ public class OutputWordUtil {
/**
* 获取图形实例的关联Model Map<shapeId, shapeName>
*
* @param fileId
* @param shapeId
* @return
@ -1406,10 +1402,11 @@ public class OutputWordUtil {
/**
* 查询横版特殊信息
*
* <p>
* 查询部门岗位角色
*
* <p>
* 部门岗位角色的区分依据在相应的流程源文件需要查找源文件
*
* @param _tr
* @param dataAttribute
* @param shapeModelMap
@ -1431,7 +1428,7 @@ public class OutputWordUtil {
}
List<DesignerShapeRelationModel> relationModels = dao.query(null, shapeId, key, null, str);
if (relationModels != null && relationModels.size() > 0) {
for(DesignerShapeRelationModel model : relationModels) {
for (DesignerShapeRelationModel model : relationModels) {
String relationFileId = model.getRelationFileId();
boolean flag = false;
if (relationFileIds.contains(relationFileId)) {// 包含该关联文件内容不再查询
@ -1454,10 +1451,10 @@ public class OutputWordUtil {
String type = element.get("type").toString();
if ("organization".equals(type)) {
sbOrg.append(",");
sbOrg.append(element.get("text").toString().replace("\n",""));
sbOrg.append(element.get("text").toString().replace("\n", ""));
} else if ("position".equals(type) || "role".equals(type)) {
sbRole.append(",");
sbRole.append(element.get("text").toString().replace("\n",""));
sbRole.append(element.get("text").toString().replace("\n", ""));
}
}
}
@ -1481,6 +1478,7 @@ public class OutputWordUtil {
/**
* 将图形元素关联属性的id替换为name
* com.alibaba.fastjson
*
* @param key
* @param dataAttribute 图形元素所有关联属性
* @param shapeRelationModelMap<id, name>
@ -1562,6 +1560,7 @@ public class OutputWordUtil {
/**
* 导出word时对特殊字符转义防止office解析特殊字符打不开
* 特殊字符"&" "<" ">"
*
* @param str
*/
public static String specialCharTransfer(String str) {
@ -1595,12 +1594,12 @@ public class OutputWordUtil {
}
if (json.containsKey("attributes")) {
if (json.get("attributes") instanceof JSONObject) {// netJson
JSONObject dataJson = (JSONObject)json.get("attributes");
JSONObject dataJson = (JSONObject) json.get("attributes");
if (dataJson.containsKey("privateAttributeContent") && dataJson.get("privateAttributeContent").getClass().getName().contains("JSONObject")) {
return dataJson.getJSONObject("privateAttributeContent").getString("number");
}
}
if(json.get("attributes") instanceof JSONObject) {// fastJson
if (json.get("attributes") instanceof JSONObject) {// fastJson
JSONObject dataJson = (JSONObject) json.get("attributes");
if (dataJson.containsKey("privateAttributeContent") && dataJson.get("privateAttributeContent").getClass().getName().contains("JSONObject")) {
return dataJson.getJSONObject("privateAttributeContent").getString("number");
@ -1614,7 +1613,7 @@ public class OutputWordUtil {
return obj.getString("value");
}
//加入活动序号排序处理
if (obj.getString("key")!= null && obj.getString("key").contains("number")) {
if (obj.getString("key") != null && obj.getString("key").contains("number")) {
return obj.getString("value");
}
}

View File

@ -1,5 +1,11 @@
package com.actionsoft.apps.coe.pal.pal.repository.upfile.dao;
import com.actionsoft.apps.coe.pal.pal.repository.upfile.model.UpfileModel;
import com.actionsoft.bpms.commons.database.RowMapper;
import com.actionsoft.bpms.util.DBSql;
import com.actionsoft.bpms.util.UtilString;
import com.actionsoft.exception.AWSDataAccessException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@ -9,20 +15,9 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.actionsoft.apps.coe.pal.constant.CoEConstant;
import com.actionsoft.apps.coe.pal.pal.repository.dao.PALRepository;
import com.actionsoft.apps.coe.pal.pal.repository.model.impl.PALRepositoryModelImpl;
import com.actionsoft.bpms.commons.database.RowMapper;
import com.actionsoft.bpms.util.DBSql;
import com.actionsoft.bpms.util.UtilString;
import com.actionsoft.apps.coe.pal.pal.repository.upfile.model.UpfileModel;
import com.actionsoft.exception.AWSDataAccessException;
import com.actionsoft.sdk.local.SDK;
/**
* @author 作者 renmm
* @version 创建时间2014-4-8
*
*/
public class UpFileDao {
/**
@ -42,8 +37,8 @@ public class UpFileDao {
paraMap.put(UpfileModel.FIELD_TYPE, model.getType());
paraMap.put(UpfileModel.FIELD_CREATEUSER, model.getCreateUser());
paraMap.put(UpfileModel.FIELD_CREATETIME, model.getCreateTime());
if (model.getSecurityLevel()!=null){
paraMap.put(UpfileModel.FIELD_SECURITY_LEVEL,model.getSecurityLevel());
if (model.getSecurityLevel() != null) {
paraMap.put(UpfileModel.FIELD_SECURITY_LEVEL, model.getSecurityLevel());
}
String sql = DBSql.getInsertStatement(UpfileModel.DATABASE_ENTITY, paraMap);
result = DBSql.update(sql.toString(), paraMap);
@ -52,40 +47,42 @@ public class UpFileDao {
/**
* 按条件进行更新
*
* @param model
* @return
*/
public int update(UpfileModel model){
public int update(UpfileModel model) {
List<Object> args = new ArrayList<>();
StringBuffer sql = new StringBuffer("update " +UpfileModel.DATABASE_ENTITY+" set ");
if (null != model.getPl_uuid()){
StringBuffer sql = new StringBuffer("update " + UpfileModel.DATABASE_ENTITY + " set ");
if (null != model.getPl_uuid()) {
sql.append(UpfileModel.FIELD_PL_UUID + "=?,");
args.add(model.getPl_uuid());
}
if (null != model.getShape_uuid()){
if (null != model.getShape_uuid()) {
sql.append(UpfileModel.FIELD_SHAPE_UUID + "=?,");
args.add(model.getShape_uuid());
}
if (null != model.getFileName()){
sql.append(UpfileModel.FIELD_FILENAME +"=?,");
if (null != model.getFileName()) {
sql.append(UpfileModel.FIELD_FILENAME + "=?,");
args.add(model.getFileName());
}
if (null != model.getSecurityLevel()){
if (null != model.getSecurityLevel()) {
sql.append(UpfileModel.FIELD_SECURITY_LEVEL + "=?,");
args.add(model.getSecurityLevel());
}
int index = sql.lastIndexOf(",");
sql.setCharAt(index,' ');
sql.append("where "+UpfileModel.FIELD_UUID+"=?");
sql.setCharAt(index, ' ');
sql.append("where " + UpfileModel.FIELD_UUID + "=?");
args.add(model.getUuid());
return DBSql.update(sql.toString(), args.toArray());
}
public boolean batchInsert(List<UpfileModel> list) {
Connection conn = DBSql.open();
PreparedStatement prest = null;
try {
conn.setAutoCommit(false);
String sql = "insert into " + UpfileModel.DATABASE_ENTITY + "(" + UpfileModel.FIELD_UUID + "," + UpfileModel.FIELD_PL_UUID + "," + UpfileModel.FIELD_SHAPE_UUID + "," + UpfileModel.FIELD_TYPE + "," + UpfileModel.FIELD_FILENAME + "," + UpfileModel.FIELD_DOWNLOAD + "," + UpfileModel.FIELD_CREATEUSER + "," + UpfileModel.FIELD_CREATETIME +","+UpfileModel.FIELD_SECURITY_LEVEL+")" + " VALUES(?,?,?,?,?,?,?,?,?)";
String sql = "insert into " + UpfileModel.DATABASE_ENTITY + "(" + UpfileModel.FIELD_UUID + "," + UpfileModel.FIELD_PL_UUID + "," + UpfileModel.FIELD_SHAPE_UUID + "," + UpfileModel.FIELD_TYPE + "," + UpfileModel.FIELD_FILENAME + "," + UpfileModel.FIELD_DOWNLOAD + "," + UpfileModel.FIELD_CREATEUSER + "," + UpfileModel.FIELD_CREATETIME + "," + UpfileModel.FIELD_SECURITY_LEVEL + ")" + " VALUES(?,?,?,?,?,?,?,?,?)";
prest = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
for (int i = 0; i < list.size(); i++) {
UpfileModel model = list.get(i);
@ -97,10 +94,10 @@ public class UpFileDao {
prest.setInt(6, model.getDownload());
prest.setString(7, model.getCreateUser());
prest.setTimestamp(8, model.getCreateTime());
if (null != model.getSecurityLevel()){
prest.setInt(9,model.getSecurityLevel());
}else {
prest.setInt(9,-1);
if (null != model.getSecurityLevel()) {
prest.setInt(9, model.getSecurityLevel());
} else {
prest.setInt(9, -1);
}
prest.addBatch();
}
@ -131,6 +128,19 @@ public class UpFileDao {
return new ArrayList<UpfileModel>();
}
public List<UpfileModel> searchBGroup(String sqlWhere) {
StringBuffer sql = new StringBuffer();
sql.append("select ID,SHAPEID,FILETYPE,DOWNLOAD,PALREPOSITORYID,FILENAME from ").append(UpfileModel.DATABASE_ENTITY).append(" where 1 = 1 ").append(sqlWhere);
try {
return DBSql.query(sql.toString(), new UpfileModelMapper());
} catch (AWSDataAccessException e) {
e.printStackTrace();
}
return new ArrayList<UpfileModel>();
}
private class UpfileModelMapper implements RowMapper<UpfileModel> {
public UpfileModel mapRow(ResultSet rs, int arg1) throws SQLException {
UpfileModel model = new UpfileModel();
@ -205,8 +215,19 @@ public class UpFileDao {
return search(sqlWhere.toString());
}
public List<UpfileModel> searchByRepositoryIdGroupByFilename(String repositoryId, String type) {
StringBuffer sqlWhere = new StringBuffer();
if (!UtilString.isEmpty(type)) {
sqlWhere.append(" and PALREPOSITORYID ='").append(repositoryId).append("' and FILETYPE='").append(type).append("'").append("GROUP BY ID,SHAPEID,FILETYPE,DOWNLOAD,PALREPOSITORYID,FILENAME");
}
System.out.println("sqlWhere=============" + sqlWhere);
return searchBGroup(sqlWhere.toString());
}
/**
* 按照条件查询
*
* @param repositoryId
* @param shapeId
* @param type f,s
@ -245,10 +266,10 @@ public class UpFileDao {
public List<UpfileModel> getRelationUpfile(String uuid, String shapeId, String type) {
String sql = "SELECT f.* FROM APP_ACT_COE_PAL_UPFILE f, APP_ACT_COE_PAL_SHAPE_RLAT r WHERE r.FILEID=? AND f.PALREPOSITORYID = r.RELATIONFILEID AND f.SHAPEID = r.RELATIONSHAPEID";
if (type.equals("file")) {
return DBSql.query(sql, new UpfileModelMapper(), new Object[] { uuid });
return DBSql.query(sql, new UpfileModelMapper(), new Object[]{uuid});
} else {
sql += " AND r.SHAPEID=?";
return DBSql.query(sql, new UpfileModelMapper(), new Object[] { uuid, shapeId });
return DBSql.query(sql, new UpfileModelMapper(), new Object[]{uuid, shapeId});
}
}
}