制度手册创建修订记录内容

This commit is contained in:
zhal 2023-08-01 18:57:00 +08:00
parent 926a1dce1c
commit b002f69150
5 changed files with 246 additions and 14 deletions

View File

@ -3725,6 +3725,22 @@ public class CoEPALController {
}
/**
* 重新生成手册(文件状态批量修改)
*
* @param me
* @param plId
* @return
*/
@Mapping("com.actionsoft.apps.coe.pal.publisher_publish_Refresh_ManualBychangeFile")
public String RefreshManualChangeFile(UserContext me, String plIds) {
DesignerRelationShapeWeb web = new DesignerRelationShapeWeb(me);
return web.RefreshManualChangeFile(me,plIds);
}
/**
* 判断表单模型是否存在excel文件
*

View File

@ -23,12 +23,14 @@ import com.actionsoft.bpms.server.DispatcherRequest;
import com.actionsoft.bpms.server.UserContext;
import com.actionsoft.bpms.server.fs.DCContext;
import com.actionsoft.bpms.server.fs.dc.DCProfileManager;
import com.actionsoft.bpms.util.UtilDate;
import com.actionsoft.bpms.util.UtilFile;
import com.actionsoft.bpms.util.UtilString;
import com.actionsoft.sdk.local.SDK;
import com.actionsoft.sdk.local.api.AppAPI;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.awspaas.apps.coe.pal.output.zd.report1.Report1Gener;
import com.sini.com.spire.doc.*;
import com.sini.com.spire.doc.collections.SectionCollection;
import com.sini.com.spire.doc.documents.*;
@ -43,6 +45,7 @@ import org.apache.commons.lang.StringUtils;
import java.awt.*;
import java.io.*;
import java.sql.Timestamp;
import java.util.List;
import java.util.*;
@ -369,6 +372,100 @@ public class OutputWordUtil {
//创建 Document 类的对象并从磁盘加载 Word 文档
Document document = new Document(outFile.getPath());
float rowSpacing = 10f; // 行间距值单位为磅
JSONArray versionHistoryTable = getVersionHistoryTable(repositoryModel);
int index = 0;
if (versionHistoryTable.getJSONObject(0).size() > 0) {
//获取最后一节
Section section = document.getLastSection();
CharacterFormat format2 = new CharacterFormat();
//创建字体格式
format2.setFontName("宋体");
//添加段落设置一级序列
Paragraph paragraph2 = section.addParagraph();
ParagraphFormat paragraphFormat2 = paragraph2.getFormat();
paragraphFormat2.setHorizontalAlignment(Left);
TextRange tr2 = paragraph2.appendText("修订记录");
tr2.getCharacterFormat().setBold(true);
tr2.getCharacterFormat().setFontName("宋体");
tr2.getCharacterFormat().setFontSize(12);
paragraph2.applyStyle(BuiltinStyle.Body_Text); //应用标题1样式
//定义表格数据
String[] header = {"版本", "拟制/修订单位","拟制/修订人","拟制/修订日期","审核人","复核人","审批人","修订内容及理由"};
String[][] strArray2 = new String[versionHistoryTable.size()][];
List<String[]> list = new LinkedList<>();
for (int i = 0; i < versionHistoryTable.size(); i++) {
JSONObject jsonObject = versionHistoryTable.getJSONObject(0);
String[] strArray = new String[8];
strArray[0] = jsonObject.getString("versions").toString();
strArray[1] = jsonObject.getString("Issuing_department").toString();
strArray[2] = jsonObject.getString("Drafted_and_revised_by").toString();
strArray[3] = jsonObject.getString("Drafted_and_revised_date").toString();
strArray[4] = jsonObject.getString("auditor").toString();
strArray[5] = jsonObject.getString("reviewer").toString();
strArray[6] = jsonObject.getString("approver").toString();
strArray[7] = jsonObject.getString("Contents_and_reasons_for_revision").toString();
list.add(strArray);
strArray2[i] = strArray;
}
String[][] data = strArray2;
//添加表格
Table table = section.addTable(true);
table.resetCells(data.length + 1, header.length);
TableRow row = table.getRows().get(0);
row.isHeader(true);
row.setHeight(20);
row.setHeightType(TableRowHeightType.Auto);
for (int i = 0; i < header.length; i++) {
row.getCells().get(i).getCellFormat().setVerticalAlignment(VerticalAlignment.Middle);
//设置固定列宽
row.getCells().get(0).setWidth(40);
row.getCells().get(1).setWidth(60);
row.getCells().get(2).setWidth(60);
row.getCells().get(3).setWidth(60);
row.getCells().get(4).setWidth(60);
row.getCells().get(5).setWidth(60);
row.getCells().get(6).setWidth(60);
row.getCells().get(7).setWidth(80);
Paragraph p = row.getCells().get(i).addParagraph();
p.getFormat().setHorizontalAlignment(Center);
TextRange txtRange = p.appendText(header[i]);
txtRange.getCharacterFormat().setBold(true);
}
//将数据添加到其余行
for (int r = 0; r < data.length; r++) {
TableRow dataRow = table.getRows().get(r + 1);
dataRow.setHeight(25);
dataRow.setHeightType(TableRowHeightType.Auto);
dataRow.getRowFormat().setBackColor(Color.white);
for (int c = 0; c < data[r].length; c++) {
dataRow.getCells().get(c).getCellFormat().setVerticalAlignment(VerticalAlignment.Middle);
//设置固定列宽
dataRow.getCells().get(0).setWidth(40);
dataRow.getCells().get(1).setWidth(60);
dataRow.getCells().get(2).setWidth(60);
dataRow.getCells().get(3).setWidth(60);
dataRow.getCells().get(4).setWidth(60);
dataRow.getCells().get(5).setWidth(60);
dataRow.getCells().get(6).setWidth(60);
dataRow.getCells().get(7).setWidth(80);
dataRow.getCells().get(c).addParagraph().appendText(data[r][c]);
}
}
document.saveToFile(outFile.getPath(), FileFormat.Docx_2013);
}
String suffix = fileName.substring(fileName.lastIndexOf(".") + 1);
@ -443,11 +540,6 @@ public class OutputWordUtil {
Document doc3 = new Document();
doc3.loadFromFile(tempPath + "横板页眉页脚模板.doc");
// 获取源文档的页眉页脚
/*Section sourceSection = doc1.getSections().get(0);
HeaderFooter sourceHeader = sourceSection.getHeadersFooters().getHeader();
HeaderFooter sourceFooter = sourceSection.getHeadersFooters().getFooter();*/
// 将页眉复制到目标文档的第三节以及后续节
for (int i = 2; i < doc2.getSections().getCount(); i++) {
@ -490,6 +582,8 @@ public class OutputWordUtil {
targetFooter.getChildObjects().add(obj);
}
}
doc2.saveToFile(outFile.getPath(), FileFormat.Docx_2013);
@ -528,6 +622,7 @@ public class OutputWordUtil {
//相关文件 R_relevant_flies
JSONArray relevant_flies = new JSONArray(); //组织职责Table
List<DesignerShapeRelationModel> relationList2 = DesignerShapeRelationCache.getListByAttrId(repositoryModel.getId(), "", "related_files");
@ -584,10 +679,6 @@ public class OutputWordUtil {
Table table = section.addTable(true);
table.resetCells(data.length + 1, header.length);
//自动调整表格大小
table.autoFit(AutoFitBehaviorType.Auto_Fit_To_Window);
TableRow row = table.getRows().get(0);
row.isHeader(true);
row.setHeight(20);
@ -619,8 +710,6 @@ public class OutputWordUtil {
}
}
}
@ -677,9 +766,6 @@ public class OutputWordUtil {
table.resetCells(data.length + 1, header.length);
table.autoFit(AutoFitBehaviorType.Auto_Fit_To_Window);
TableRow row = table.getRows().get(0);
row.isHeader(true);
row.setHeight(20);
@ -1915,4 +2001,78 @@ public class OutputWordUtil {
Collections.sort(list, comparator);
}
}
public static JSONArray getVersionHistoryTable(PALRepositoryModel repositoryModel) {
JSONArray versionHistoryTable = new JSONArray();// 修订记录
List<PALRepositoryModel> list = PALRepositoryCache.getByVersionId(repositoryModel.getVersionId());
list.sort((m1, m2) -> {
return m1.getVersion() - m2.getVersion() > 0 ? 1 : -1;
});
for (PALRepositoryModel model : list) {
if (model.getVersion() > repositoryModel.getVersion()) {
continue;
}
JSONObject obj = new JSONObject();
Map<String, JSONObject> map = PALRepositoryQueryAPIManager.queryRepositoryAttributeById(model.getId());
// 版本P_versions制度用的是versions
String attr = "versions";
String val = "";
String plvers = model.getVersion() + "";
String plver = "";
if (!"".equals(plvers)) {
if (plvers.length() > 1) {
plver = plvers.substring(0, 1) + "."
+ plvers.substring(plvers.length() - 1, plvers.length());
} else {
plver = plvers.substring(0, 1) + ".0";
}
}
//val = specialCharTransfer(map.containsKey(attr) ? (map.get(attr).getString("text")) : "").replace("\n", WRAPSTRING);
obj.put(attr, "V" + plver);
// 拟制/修订单位Issuing_department
attr = "Issuing_department";
val = specialCharTransfer(map.containsKey(attr) ? (map.get(attr).getString("text")) : "").replace("\n", WRAPSTRING);
obj.put(attr, val);
// 拟制/修订人Drafted_and_revised_by
attr = "Drafted_and_revised_by";
val = specialCharTransfer(map.containsKey(attr) ? (map.get(attr).getString("text")) : "").replace("\n", WRAPSTRING);
obj.put(attr, val);
// 拟制/修订日期Drafted_and_revised_date
attr = "Drafted_and_revised_date";
val = specialCharTransfer(map.containsKey(attr) ? (map.get(attr).getString("text")) : "").replace("\n", WRAPSTRING);
if (UtilString.isNotEmpty(val)) {
try {
Timestamp timestamp = UtilDate.parseTsFromDateTime(val);
val = UtilDate.yearFormat(timestamp) + "" + Integer.parseInt(UtilDate.monthFormat(timestamp)) + "" + UtilDate.dayFormat(timestamp) + "";
} catch (Exception e) {
//e.printStackTrace();
}
}
obj.put(attr, val);
// 审核人auditor
attr = "auditor";
val = specialCharTransfer(map.containsKey(attr) ? (map.get(attr).getString("text")) : "").replace("\n", WRAPSTRING);
obj.put(attr, val);
// 复核人reviewer
attr = "reviewer";
val = specialCharTransfer(map.containsKey(attr) ? (map.get(attr).getString("text")) : "").replace("\n", WRAPSTRING);
obj.put(attr, val);
// 审批人approver
attr = "approver";
val = specialCharTransfer(map.containsKey(attr) ? (map.get(attr).getString("text")) : "").replace("\n", WRAPSTRING);
obj.put(attr, val);
// 修订内容及理由Contents_and_reasons_for_revision
attr = "Contents_and_reasons_for_revision";
val =map.get(attr).getString("text");
obj.put(attr, val);
versionHistoryTable.add(obj);
}
return versionHistoryTable;
}
}

View File

@ -83,6 +83,7 @@ import org.apache.commons.lang.StringUtils;
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@ -4572,4 +4573,48 @@ public class DesignerRelationShapeWeb extends ActionWeb {
}
return ro.toString();
}
public String RefreshManualChangeFile(UserContext me, String plIds) {
int count = 0;
ResponseObject ro = ResponseObject.newOkResponse();
try {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String[] plIdList = plIds.split(",");
for (String plId : plIdList) {
// 重新生成手册
PALRepositoryModel model = PALRepositoryCache.getCache().get(plId);
if(model!=null){
String taskId = createOutputReport(model, "7d3ca852-a0bd-42e6-80b1-3dcea6f55083", "admin", "", plId);
System.err.println("======手动生成手册id======"+taskId);
// 刷新预览加载的表
String sqlr = "UPDATE BO_EU_PAL_OUTPUTREPORT SET TASKID = '" + taskId + "' WHERE PLID = '" + plId + "'";
DBSql.update(sqlr);
String sql1 = "SELECT ID FROM BO_ACT_COE_PUBLISH_N WHERE PUBLISHFILEID = '" + plId + "'";
String sql2 = "SELECT ID FROM BO_ACT_COE_PUBLISH_C WHERE CHANGEDFILEIDNEW = '" + plId + "'";
if (UtilString.isNotEmpty(DBSql.getString(sql1))) {
count = DBSql.update(
"UPDATE BO_ACT_COE_PUBLISH_N SET TASKID='" + taskId + "'WHERE PUBLISHFILEID ='" + plId + "'");
}
if (UtilString.isNotEmpty(DBSql.getString(sql2))) {
count = DBSql.update(
"UPDATE BO_ACT_COE_PUBLISH_C SET TASKID='" + taskId + "'WHERE CHANGEDFILEIDNEW ='" + plId + "'");
}
if (count != 0) {
DBSql.update("UPDATE APP_ACT_COE_PAL_PUBLISH_LIST SET TASKID='" + taskId + "'WHERE PALREPOSITORYID='"
+ plId + "'");
}
System.err.println("重新生成手册成功=====》" + count);
}
}
} catch (AWSDataAccessException e) {
ro.put("result", "创建手册失败!!!");
e.printStackTrace();
}
return ro.toString();
}
}

View File

@ -101,6 +101,7 @@ import com.actionsoft.apps.coe.pal.portal.web.CoEPortalSkins;
import com.actionsoft.apps.coe.pal.system.property.CoePropertyUtil;
import com.actionsoft.apps.coe.pal.team.user.dao.CoeUserDaoFactory;
import com.actionsoft.apps.coe.pal.team.user.model.CoeUserModel;
import com.actionsoft.exception.AWSDataAccessException;
import com.actionsoft.exception.AWSException;
import com.actionsoft.exception.BPMNDefException;
import com.actionsoft.i18n.I18nRes;
@ -12853,4 +12854,14 @@ public String deleteReply(String replyid, String messageid) {
ro.setData(result);
return ro.toString();
}
}