diff --git a/com.actionsoft.apps.coe.pal/lib/com.actionsoft.apps.coe.pal.jar b/com.actionsoft.apps.coe.pal/lib/com.actionsoft.apps.coe.pal.jar index d2615321..a6a81580 100644 Binary files a/com.actionsoft.apps.coe.pal/lib/com.actionsoft.apps.coe.pal.jar and b/com.actionsoft.apps.coe.pal/lib/com.actionsoft.apps.coe.pal.jar differ diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/CoEPALController.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/CoEPALController.java index 1942487b..b4d8a0c5 100755 --- a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/CoEPALController.java +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/CoEPALController.java @@ -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文件 * diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/cooperation/CoeCooperationAPIManager.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/cooperation/CoeCooperationAPIManager.java index 29ae85f6..0b23c848 100644 --- a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/cooperation/CoeCooperationAPIManager.java +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/cooperation/CoeCooperationAPIManager.java @@ -1149,8 +1149,33 @@ public class CoeCooperationAPIManager { } } if (deleteIds.size() > 0){ - // 删除不在小组权限范围内的数据 - rolePermDao.removeDataByTeamAndPalVersionIds(teamId, roleModel.getId(), deleteIds); + if (deleteIds.size() <= 1000){ // 直接删除 + // 删除不在小组权限范围内的数据 + rolePermDao.removeDataByTeamAndPalVersionIds(teamId, roleModel.getId(), deleteIds); + }else { // 分批次删除 + // 每个小集合的大小 + int batchSize = 1000; + + // 计算需要拆分的次数 + int numBatches = (deleteIds.size() + batchSize - 1) / batchSize; + + // 拆分成多个小集合 + List> batches = new ArrayList<>(); + Iterator iterator = deleteIds.iterator(); + for (int i = 0; i < numBatches; i++) { + Set batch = new HashSet<>(); + for (int j = 0; j < batchSize && iterator.hasNext(); j++) { + batch.add(iterator.next()); + } + batches.add(batch); + } + + // 遍历小集合,进行相应的操作 + for (Set batch : batches) { + // 在这里执行你的操作,例如删除操作 + rolePermDao.removeDataByTeamAndPalVersionIds(teamId, roleModel.getId(), batch); + } + } } } } diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/output/util/OutputWordUtil.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/output/util/OutputWordUtil.java index 92c2f169..b437de7c 100755 --- a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/output/util/OutputWordUtil.java +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/output/util/OutputWordUtil.java @@ -23,6 +23,7 @@ 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; @@ -43,6 +44,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 +371,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 list = new LinkedList<>(); + for (int i = 0; i < versionHistoryTable.size(); i++) { + JSONObject jsonObject = versionHistoryTable.getJSONObject(i); + 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 +539,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 +581,8 @@ public class OutputWordUtil { targetFooter.getChildObjects().add(obj); } } + + doc2.saveToFile(outFile.getPath(), FileFormat.Docx_2013); @@ -528,6 +621,7 @@ public class OutputWordUtil { + //相关文件 R_relevant_flies JSONArray relevant_flies = new JSONArray(); //组织职责Table List relationList2 = DesignerShapeRelationCache.getListByAttrId(repositoryModel.getId(), "", "related_files"); @@ -584,10 +678,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 +709,6 @@ public class OutputWordUtil { } } - - } @@ -677,9 +765,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 +2000,78 @@ public class OutputWordUtil { Collections.sort(list, comparator); } } + + + + + + + public static JSONArray getVersionHistoryTable(PALRepositoryModel repositoryModel) { + JSONArray versionHistoryTable = new JSONArray();// 修订记录 + List 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 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; + } } diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/designer/relation/web/DesignerRelationShapeWeb.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/designer/relation/web/DesignerRelationShapeWeb.java index 99b4d9c3..2fa4ea73 100755 --- a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/designer/relation/web/DesignerRelationShapeWeb.java +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/designer/relation/web/DesignerRelationShapeWeb.java @@ -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(); + } + + } \ No newline at end of file diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/web/CoeProcessLevelWeb.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/web/CoeProcessLevelWeb.java index 6a98d98c..af47a68c 100755 --- a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/web/CoeProcessLevelWeb.java +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/web/CoeProcessLevelWeb.java @@ -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; @@ -6157,6 +6158,8 @@ public class CoeProcessLevelWeb extends ActionWeb { if (UtilString.isNotEmpty(resultMsg.toString())){ // 将当前文件节点变动的信息 存放到所有引用当前文件的端到端总图中 for (DesignerShapeRelationModel subProcessNode : subProcessModelList) { + PALRepositoryModel tempModel = PALRepositoryCache.getCache().get(subProcessNode.getFileId()); + if (tempModel == null) continue; BaseModel subProcessBaseModel = CoeDesignerAPIManager.getInstance().getDefinition(subProcessNode.getFileId(), 0); if (subProcessBaseModel == null) continue; String subProcessDefine = subProcessBaseModel.getDefinition(); @@ -12851,4 +12854,14 @@ public String deleteReply(String replyid, String messageid) { ro.setData(result); return ro.toString(); } + + + + + + + + + + } diff --git a/com.awspaas.user.apps.coe.pal.output.zd/lib/com.awspaas.user.apps.coe.pal.output.zd.jar b/com.awspaas.user.apps.coe.pal.output.zd/lib/com.awspaas.user.apps.coe.pal.output.zd.jar new file mode 100644 index 00000000..2b2d0bbb Binary files /dev/null and b/com.awspaas.user.apps.coe.pal.output.zd/lib/com.awspaas.user.apps.coe.pal.output.zd.jar differ diff --git a/com.awspaas.user.apps.coe.pal.output.zd/src/com/awspaas/apps/coe/pal/output/zd/InstitutionalTextWeb.java b/com.awspaas.user.apps.coe.pal.output.zd/src/com/awspaas/apps/coe/pal/output/zd/InstitutionalTextWeb.java index 0644dd9b..f1717658 100644 --- a/com.awspaas.user.apps.coe.pal.output.zd/src/com/awspaas/apps/coe/pal/output/zd/InstitutionalTextWeb.java +++ b/com.awspaas.user.apps.coe.pal.output.zd/src/com/awspaas/apps/coe/pal/output/zd/InstitutionalTextWeb.java @@ -46,6 +46,7 @@ import org.apache.commons.compress.utils.IOUtils; import java.awt.*; import java.io.*; +import java.nio.file.Files; import java.text.SimpleDateFormat; import java.util.List; import java.util.*; @@ -79,7 +80,6 @@ public class InstitutionalTextWeb extends ActionWeb { public String systemManualTextExport() { List listIds = OutputAppManager.getProfileName(""); - //查询制度流程文件 List policyMap = DBSql.getMaps("SELECT * FROM APP_ACT_COE_PAL_REPOSITORY WHERE PLMETHODID='control.policy' "); @@ -166,7 +166,7 @@ public class InstitutionalTextWeb extends ActionWeb { RowMap policyMap = DBSql.getMap("SELECT * FROM APP_ACT_COE_PAL_REPOSITORY WHERE PLMETHODID='control.policy' AND ID='" + targetFileIdArray[i] + "' "); if (policyMap != null) { - exportText(policyMap.getString("ID"), policyMap.getString("WSID"), policyMap.getString("PLNAME"), policyMap.getString("PLVER"), zipName, times, targetDir, targetFileDir); + exportOnceText(policyMap.getString("ID"), policyMap.getString("WSID"), policyMap.getString("PLNAME"), policyMap.getString("PLVER"), zipName, times, targetDir, targetFileDir); } } @@ -184,6 +184,7 @@ public class InstitutionalTextWeb extends ActionWeb { } + @SuppressWarnings("deprecation") public void exportText(String targetFileId, String wsId, String plname, String versionNumer, String zipName, long times, String targetDir, File targetFileDir) { ProcessInstance boProcessInstance = SDK.getProcessAPI() @@ -300,14 +301,9 @@ public class InstitutionalTextWeb extends ActionWeb { msg = sourceDc.getDCMessage().getMessage(); } } - try { - IOUtils.copy(in, out); - in.close(); - out.close(); - } finally { - IOUtils.closeQuietly(in); - IOUtils.closeQuietly(out); - } + IOUtils.copy(in, out); + in.close(); + out.close(); if (filePath != null) { @@ -355,6 +351,138 @@ public class InstitutionalTextWeb extends ActionWeb { } + public void exportOnceText(String targetFileId, String wsId, String plname, String versionNumer, String zipName, long times, String targetDir, File targetFileDir) { + ProcessInstance boProcessInstance = SDK.getProcessAPI() + .createBOProcessInstance("obj_c0fd5262f1c64df9ab5e725aae3eff2e", "admin", "正文导出"); + + String fileName = null; + try { + String tempName = "制度-手册7.xml"; + String tempPath = "../apps/install/com.awspaas.user.apps.coe.pal.output.zd/"; + String fileValue = UUIDGener.getUUID() + "_outputText"; + String sourceAppId = "com.awspaas.user.apps.coe.pal.output.zd"; + String filename = plname; + DCContext sourceDc = new DCContext(_uc, DCProfileManager.getDCProfile(sourceAppId, "output"), sourceAppId, wsId, fileValue, filename); + String docPath = sourceDc.getPath(); + UtilFile upfileDir = new UtilFile(docPath); + if (!upfileDir.exists()) { + upfileDir.mkdirs(); + } + //{"orderNuberFirst":true,"targetShape":"","targetFileId":"ca45dc6a-0f77-44ee-adfe-f36b014586f3", + // "orderNametwo":false,"reportNameIsItName":"%fileName%_%fileVersion%","relationFileId":"","isItReport":true} + + JSONObject wizardJsonData = new JSONObject(); + wizardJsonData.put("orderNuberFirst", true); + wizardJsonData.put("targetShape", ""); + wizardJsonData.put("targetFileId", targetFileId); + wizardJsonData.put("orderNametwo", false); + wizardJsonData.put("reportNameIsItName", "%fileName%_%fileVersion%"); + wizardJsonData.put("relationFileId", ""); + wizardJsonData.put("isItReport", true); + + + String reportName = wizardJsonData.getString("reportNameIsItName"); //页面上设计的文件命名规则 + Map indexMap = new HashMap(); + + PALRepositoryModel model = PALRepositoryQueryAPIManager.getInstance().queryPalRepositoryModelByPalId(targetFileId); + if (model != null) { + //获取文件扩展属性 + String json = CoePropertyUtil.getPropertyValue(model.getId() + "_attr"); + JSONObject extendAttr = new JSONObject(); + if (json != null && !"".equals(json) && !"null".equals(json)) { + JSONArray jsonArray = JSONArray.parseArray(json); + for (int j = 0; j < jsonArray.size(); j++) { + JSONObject object = jsonArray.getJSONObject(j); + extendAttr.put(object.getString("id"), object.get("value")); + } + } + //文件的扩展属性 + List repositoryPropertyList = PALRepositoryPropertyCache.getPropertyByPlId(model.getId()); + if (repositoryPropertyList != null && repositoryPropertyList.size() > 0) { + for (PALRepositoryPropertyModel repositoryPropertyModel : repositoryPropertyList) { + if ("P_versions".equals(repositoryPropertyModel.getPropertyId())) { + 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"; + } + } + extendAttr.put(repositoryPropertyModel.getPropertyId(), "V" + plver); + } else { + extendAttr.put(repositoryPropertyModel.getPropertyId(), repositoryPropertyModel.getPropertyValue()); + } + } + } + List reportNameLabels = OutputExcelUtil.string2label(reportName); + String reportNameValue = reportName; + if (reportNameLabels.size() > 0) { + reportNameValue = OutputExcelUtil.label2value(model, extendAttr, null, reportName); + + } + reportNameValue = reportNameValue.replaceAll(OutputExcelUtil.FILENAMEREGX, ""); + if (reportNameValue.length() > 255) { + reportNameValue = reportNameValue.substring(0, 255); + } + String docName = ""; + if (indexMap.containsKey(reportNameValue)) { + int index = indexMap.get(reportNameValue); + index++; + fileName = reportNameValue + "(" + index + ")"; + log.info("得到word名称为:" + fileName); + docName = docPath + fileName + ".doc"; + indexMap.put(reportNameValue, index); + } else { + fileName = reportNameValue; + log.info("得到word名称为:" + fileName); + docName = docPath + fileName + ".doc"; + indexMap.put(fileName, 1); + } + + + JSONObject dataMap = getData2(targetFileId, wizardJsonData, docPath, fileName); + System.out.println("dpcpath=======" + docPath); + + if (dataMap != null) { + + String filePath = createDoc2(dataMap, tempPath, tempName, docName, wizardJsonData, targetFileId, docPath); + DCContext sourceDc2 = new DCContext(_uc, DCProfileManager.getDCProfile(sourceAppId, "output"), sourceAppId, wsId, fileValue, fileName + ".doc"); + String downUrl = SDK.getConfAPI().getPortalUrl() + "/r/" + + sourceDc2.getDownloadURL().replace("./", ""); + + + File targetFile = new File(targetDir + fileName + ".doc"); + if (!targetFile.exists()) { + targetFile.createNewFile(); + } + OutputStream out = new FileOutputStream(targetFile); + InputStream in = DCUtil.decryptFile(sourceDc2); + if (in == null) { + String msg = "+ dcContext.getFileName() + "; + if (sourceDc.getDCMessage() != null) { + msg = sourceDc.getDCMessage().getMessage(); + } + } + IOUtils.copy(in, out); + in.close(); + out.close(); + + + } + + + } + } catch (Exception e) { + e.printStackTrace(); + + + } + + } + /** * 生成word文件 * @@ -448,6 +576,7 @@ public class InstitutionalTextWeb extends ActionWeb { String suffix = fileName.substring(fileName.lastIndexOf(".") + 1); + System.out.println("文件名称为================" + fileName); if (suffix.equals("xml")) { // 输出文档路径及名称 File sourceFile = new UtilFile(path + fileName); @@ -571,8 +700,7 @@ public class InstitutionalTextWeb extends ActionWeb { TableRow row = table.getRows().get(0); row.isHeader(true); row.setHeight(20); - row.setHeightType(TableRowHeightType.Exactly); - + row.setHeightType(TableRowHeightType.Auto); //循环表头 for (int i = 0; i < header.length; i++) { row.getCells().get(i).getCellFormat().setVerticalAlignment(VerticalAlignment.Middle); @@ -627,8 +755,10 @@ public class InstitutionalTextWeb extends ActionWeb { JSONArray organizationTable = new JSONArray(); //组织职责Table // 属性特征 属性代码KEY + PALRepositoryPropertyModel Organizational = PALRepositoryPropertyCache.getPropertyByPropertyId(repositoryModel.getId(), "Organizational_role"); String OrganizationalVal = Organizational.getPropertyValue(); + JSONObject OrganizationalObj = JSONObject.parseObject(OrganizationalVal); if (OrganizationalObj != null && !OrganizationalObj.isEmpty()) { JSONArray tableArr = OrganizationalObj.getJSONArray("table"); @@ -674,7 +804,7 @@ public class InstitutionalTextWeb extends ActionWeb { TableRow row = table.getRows().get(0); row.isHeader(true); row.setHeight(20); - row.setHeightType(TableRowHeightType.Exactly); + row.setHeightType(TableRowHeightType.Auto); for (int i = 0; i < orgheader.length; i++) { row.getCells().get(i).getCellFormat().setVerticalAlignment(VerticalAlignment.Middle); //设置固定列宽 @@ -743,7 +873,7 @@ public class InstitutionalTextWeb extends ActionWeb { com.sini.com.spire.doc.Document document2 = new com.sini.com.spire.doc.Document(appendUrl); - int sectionCount = document.getSections().getCount(); + int sectionCount = document2.getSections().getCount(); ProcessInstance boProcessInstance = SDK.getProcessAPI() .createBOProcessInstance("obj_70c7c5eb0e8f425fa1b57a94038089a8", "admin", "页面方向"); @@ -751,7 +881,7 @@ public class InstitutionalTextWeb extends ActionWeb { boolean isLandscape = false; // 循环遍历每个节(Section) for (int i = 0; i < sectionCount; i++) { - Section souresection = document.getSections().get(i); + Section souresection = document2.getSections().get(i); // 获取当前节的页面方向 PageSetup pageSetup = souresection.getPageSetup(); @@ -777,11 +907,11 @@ public class InstitutionalTextWeb extends ActionWeb { //保存结果文档 document.saveToFile(outFile.getPath(), FileFormat.Docx_2013); - BO bo = new BO(); + /*BO bo = new BO(); bo.set("FILENAME", fileName); bo.set("PALID", repositoryId); bo.set("PAGE_ORIENTATION", "横向"); - SDK.getBOAPI().create("BO_ACT_PAGE_ORIENTATION", bo, boProcessInstance.getId(), ""); + SDK.getBOAPI().create("BO_ACT_PAGE_ORIENTATION", bo, boProcessInstance.getId(), "");*/ } else { @@ -804,11 +934,11 @@ public class InstitutionalTextWeb extends ActionWeb { //保存结果文档 document.saveToFile(outFile.getPath(), FileFormat.Docx_2013); - BO bo = new BO(); + /*BO bo = new BO(); bo.set("FILENAME", fileName); bo.set("PALID", repositoryId); bo.set("PAGE_ORIENTATION", "纵向"); - SDK.getBOAPI().create("BO_ACT_PAGE_ORIENTATION", bo, boProcessInstance.getId(), ""); + SDK.getBOAPI().create("BO_ACT_PAGE_ORIENTATION", bo, boProcessInstance.getId(), "");*/ } } @@ -822,9 +952,6 @@ public class InstitutionalTextWeb extends ActionWeb { //创建 Document 类的对象并从磁盘加载 Word 文档 com.sini.com.spire.doc.Document document = new com.sini.com.spire.doc.Document(outFile.getPath()); - // 删除第一页 - /*Section section1 = document.getSections().get(0); - document.getSections().remove(section1);*/ Section section = document.getLastSection(); @@ -884,10 +1011,6 @@ public class InstitutionalTextWeb extends ActionWeb { com.sini.com.spire.doc.Document doc3 = new com.sini.com.spire.doc.Document(); doc3.loadFromFile(tempPath + "横板页眉页脚模板.doc"); - // 获取源文档的页眉页脚 - /*Section sourceSection = doc1.getSections().get(0); - HeaderFooter sourceHeader = sourceSection.getHeadersFooters().getHeader(); - HeaderFooter sourceFooter = sourceSection.getHeadersFooters().getFooter();*/ // 将页眉复制到目标文档的第一节以及后续节 for (int i = 0; i < doc2.getSections().getCount(); i++) { @@ -1005,4 +1128,201 @@ public class InstitutionalTextWeb extends ActionWeb { } + public String systemManualTextTextOriginal() { + + List listIds = OutputAppManager.getProfileName(""); + + //查询制度流程文件 + List policyMap = DBSql.getMaps("SELECT * FROM APP_ACT_COE_PAL_REPOSITORY WHERE PLMETHODID='control.policy' "); + + String downUrl = ""; + + Date date = new Date(); + SimpleDateFormat dateFormat = new + SimpleDateFormat("yyyyMMddhhmmss"); + + long times = System.currentTimeMillis(); + final String zipName = "批量下载正文原文导出" + dateFormat.format(date) + ".zip"; + String targetDir = AWSServerConf.getProperty("dc.path") + File.separator + "com.awspaas.user.apps.coe.pal.output.zd" + File.separator + "tmp/grouppackage/zip" + times + "/"; + + File targetFileDir = new File(targetDir); + if (!targetFileDir.exists()) { + targetFileDir.mkdirs(); + } + + for (int i = 0; i < policyMap.size(); i++) { + vvvv(policyMap.get(i).getString("ID"), policyMap.get(i).getString("WSID"), policyMap.get(i).getString("PLNAME"), policyMap.get(i).getString("PLVER"), zipName, times, targetDir, targetFileDir); + } + + try { + UtilFile.zipCompress(targetDir, new File(targetDir + zipName)); + + File[] files = targetFileDir.listFiles(new FilenameFilter() { + @Override + public boolean accept(File dir, String name) { + if (name.equals(zipName)) { + return false; + } + return true; + } + }); + + } catch (Exception e) { + e.printStackTrace(); + } + + DCContext zipDcContext = new DCContext(getContext(), DCProfileManager.getDCProfile("com.awspaas.user.apps.coe.pal.output.zd", "tmp"), "com.awspaas.user.apps.coe.pal.output.zd", "grouppackage", "zip" + times, zipName); + + downUrl = SDK.getConfAPI().getPortalUrl() + "/r/" + zipDcContext.getDownloadURL().replace("./", ""); + + + return downUrl; + + + } + + public void vvvv(String targetFileId, String wsId, String plname, String versionNumer, String zipName, long times, String targetDir, File targetFileDir) { + + ProcessInstance boProcessInstance = SDK.getProcessAPI() + .createBOProcessInstance("obj_ddbc1403613b42279439eb35069be0f0", "admin", "正文原文导出"); + + PALRepositoryModel model = PALRepositoryQueryAPIManager.getInstance().queryPalRepositoryModelByPalId(targetFileId); + + String fileName = null; + try { + String tempName = "制度-手册7.xml"; + String tempPath = "../apps/install/com.awspaas.user.apps.coe.pal.output.zd/"; + String fileValue = UUIDGener.getUUID() + "_outputText"; + String sourceAppId = "com.awspaas.user.apps.coe.pal.output.zd"; + String filename = plname; + DCContext sourceDc = new DCContext(_uc, DCProfileManager.getDCProfile(sourceAppId, "output"), sourceAppId, wsId, fileValue, filename); + String docPath = sourceDc.getPath(); + UtilFile upfileDir = new UtilFile(docPath); + if (!upfileDir.exists()) { + upfileDir.mkdirs(); + } + //{"orderNuberFirst":true,"targetShape":"","targetFileId":"ca45dc6a-0f77-44ee-adfe-f36b014586f3", + // "orderNametwo":false,"reportNameIsItName":"%fileName%_%fileVersion%","relationFileId":"","isItReport":true} + + JSONObject wizardJsonData = new JSONObject(); + wizardJsonData.put("orderNuberFirst", true); + wizardJsonData.put("targetShape", ""); + wizardJsonData.put("targetFileId", targetFileId); + wizardJsonData.put("orderNametwo", false); + wizardJsonData.put("reportNameIsItName", "%fileName%_%fileVersion%"); + wizardJsonData.put("relationFileId", ""); + wizardJsonData.put("isItReport", true); + + + String reportName = wizardJsonData.getString("reportNameIsItName"); //页面上设计的文件命名规则 + Map indexMap = new HashMap(); + + + if (model != null) { + + String filePath1 = upfileText(targetFileId); + + if (filePath1 != null) { + + File oldpaths = new File(filePath1); + File newpaths = new File(targetDir + filePath1.substring(filePath1.lastIndexOf("/") + 1)); + if (!newpaths.exists()) { + Files.copy(oldpaths.toPath(), newpaths.toPath()); + } else { + newpaths.delete(); + Files.copy(oldpaths.toPath(), newpaths.toPath()); + + } + + BO bo = new BO(); + bo.set("PALID", targetFileId); + bo.set("FILENAME", filePath1.substring(filePath1.lastIndexOf("/") + 1)); + bo.set("VERSIONNUMBER", versionNumer); + bo.set("UPFILESTATE", "下载成功"); + bo.set("PALNAME", model.getName()); + SDK.getBOAPI().create("BO_ACT_TEXT_ORIGIN_EXPORT", bo, boProcessInstance.getId(), ""); + + } + + + } + } catch (Exception e) { + e.printStackTrace(); + BO bo = new BO(); + bo.set("PALID", targetFileId); + bo.set("FILENAME", model.getName()); + bo.set("VERSIONNUMBER", versionNumer); + bo.set("UPFILESTATE", "下载失败"); + bo.set("PALNAME", model.getName()); + bo.set("REASONSPROBLEM", e.getMessage()); + SDK.getBOAPI().create("BO_ACT_TEXT_DERIVATION", bo, boProcessInstance.getId(), ""); + + } + } + + + public String upfileText(String repositoryId) { + + //***********************************************************使用spire 生成模板后复制文件****************************************************/ + List> repositoryFileElements = CoeDesignerUtil.getShapeMessageJson4(repositoryId); //流程文件内容 + + String controlShapeId = ""; + if (repositoryFileElements != null) { + int index = 1;// 流程步骤序号 + int dangerIndex = 1;// 风险序号 + int regulateIndex = 1;// 控制序号 + for (Map shape : repositoryFileElements) { + String type = shape.get("type").toString(); + if ("regulation".equals(type)) { + controlShapeId = shape.get("id").toString(); + } else if ("I/O_L4".equals(type)) { + controlShapeId = shape.get("id").toString(); + } + } + } + + + UserContext userContext = DispatcherRequest.getUserContext(); + + Map result = new HashMap<>(); + result.put("listDef", ""); + result.put("content", ""); + if (UtilString.isEmpty(controlShapeId)) { + + } + PALRepositoryModel repositoryModel = PALRepositoryQueryAPIManager.getInstance().queryPalRepositoryModelByPalId(repositoryId); + if (repositoryModel == null) { + + } + String content = ""; + StringBuilder listStr = new StringBuilder(); + // 读取附件 + // 流程附件列表 + UpFileDao upFileDao = new UpFileDao(); + List search = upFileDao.search(repositoryModel.getId(), controlShapeId, null); + + DCContext dcContextpdf = null; + File file = null; + + String fileUrl = null; + if (search != null && search.size() > 0) { + long b1 = System.currentTimeMillis(); + // 复制附件 + for (UpfileModel upfileModel : search) { + DCPluginProfile dcProfile = DCProfileManager.getDCProfile(CoEConstant.APP_ID, CoeFileConstant.COE_UPFILE); + + if (dcProfile != null) { + dcContextpdf = new DCContext(userContext, dcProfile, CoEConstant.APP_ID, upfileModel.getPl_uuid(), upfileModel.getShape_uuid(), upfileModel.getFileName()); + String path = dcContextpdf.getPath(); + String fileName = dcContextpdf.getFileName(); + + String suffix = fileName.substring(fileName.lastIndexOf(".") + 1); + + fileUrl = path + fileName; + } + } + } + return fileUrl; + } } + diff --git a/com.awspaas.user.apps.coe.pal.output.zd/src/com/awspaas/apps/coe/pal/output/zd/ReportPrController.java b/com.awspaas.user.apps.coe.pal.output.zd/src/com/awspaas/apps/coe/pal/output/zd/ReportPrController.java index c54ed163..0c7b45d1 100644 --- a/com.awspaas.user.apps.coe.pal.output.zd/src/com/awspaas/apps/coe/pal/output/zd/ReportPrController.java +++ b/com.awspaas.user.apps.coe.pal.output.zd/src/com/awspaas/apps/coe/pal/output/zd/ReportPrController.java @@ -204,4 +204,23 @@ public class ReportPrController { } + /** + * 制度手册正文导出 + * + * @param me + * @param teamId + * @param wsid + * @return + */ + @Mapping("com.awspaas.user.apps.coe.pal.output.zd_systemManualTextTextOriginal") + public String systemManualTextTextOriginal(UserContext me) { + ResponseObject ro = null; + ro = ResponseObject.newOkResponse(); + InstitutionalTextWeb institutionalTextWeb = new InstitutionalTextWeb(me); + String result = institutionalTextWeb.systemManualTextTextOriginal(); + ro.put("result", result); + return ro.toString(); + } + + } diff --git a/com.awspaas.user.apps.coe.pal.output.zd/制度-手册5.xml b/com.awspaas.user.apps.coe.pal.output.zd/制度-手册5.xml index 02c7dd22..eacc32e0 100644 --- a/com.awspaas.user.apps.coe.pal.output.zd/制度-手册5.xml +++ b/com.awspaas.user.apps.coe.pal.output.zd/制度-手册5.xml @@ -4397,7 +4397,7 @@ y7fdOgAAAABJRU5ErkJggk== --> - +