发布代码提交
This commit is contained in:
parent
9dfaf0b4c2
commit
098a2ea603
@ -68,7 +68,7 @@ public class PublishLoadBefore extends ExecuteListener {
|
||||
Connection open = DBSql.open();
|
||||
RowMap data = DBSql.getMap(open,"select DEAPRTMNUM,PROCESSMNUMBER from BO_ACT_PROCESSMANAGER where ORGDEPART in ("+substring+")");
|
||||
if(null==data) {
|
||||
throw new AWSException("请配置联系管理员流程经理和流程校对人!");
|
||||
throw new AWSException("请联系管理员,配置流程经理和流程校对人!");
|
||||
}
|
||||
|
||||
open.close();
|
||||
|
||||
@ -0,0 +1,109 @@
|
||||
package com.actionsoft.apps.coe.pal.publisher.extend;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
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.model.PALRepositoryModel;
|
||||
import com.actionsoft.bpms.bo.engine.BO;
|
||||
import com.actionsoft.bpms.bpmn.engine.model.run.delegate.ProcessInstance;
|
||||
import com.actionsoft.bpms.bpmn.engine.model.run.delegate.TaskInstance;
|
||||
import com.actionsoft.bpms.commons.database.RowMap;
|
||||
import com.actionsoft.bpms.schedule.IJob;
|
||||
import com.actionsoft.bpms.server.UserContext;
|
||||
import com.actionsoft.bpms.util.DBSql;
|
||||
import com.actionsoft.sdk.local.SDK;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
/**
|
||||
* 批量重新生成手册
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
public class CreateOutputReportJob implements IJob {
|
||||
@Override
|
||||
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||
|
||||
String jobParameter = SDK.getJobAPI().getJobParameter(jobExecutionContext);
|
||||
int updateNum = 0;
|
||||
int createNum = 0;
|
||||
UserContext _uc = UserContext.fromUID("admin");
|
||||
ProcessInstance createProcessInstance = SDK.getProcessAPI().createProcessInstance("obj_7cb02971312c47febd508bdffa122614", "admin", "批量发布文件-");
|
||||
TaskInstance taskInst = SDK.getProcessAPI().start(createProcessInstance).fetchActiveTasks().get(0);
|
||||
String sql = "SELECT PLID,PLNAME FROM BO_EU_PAL_OUTPUTREPORT WHERE RESULT != '手册转换成功!'";
|
||||
BO bo = new BO();
|
||||
bo.set("OPTIONTYPE", "流程制度发布");
|
||||
bo.set("PROCESS_TITLE", "文件发布_批量发布");
|
||||
SDK.getBOAPI().create("BO_ACT_COE_PUBLISH", bo, createProcessInstance, _uc);
|
||||
ArrayList<BO> boList = new ArrayList<BO>();
|
||||
BO subBo = null;
|
||||
List<RowMap> maps = DBSql.getMaps(sql);
|
||||
System.err.println("批量发布文件数量为:"+maps.size());
|
||||
for (RowMap rowMap : maps) {
|
||||
subBo = new BO();
|
||||
String uuid = rowMap.getString("PLID");
|
||||
subBo.set("PUBLISTHTYPE", "N");
|
||||
subBo.set("PUBLISHFILENAME", rowMap.getString("PLNAME"));
|
||||
subBo.set("PUBLISHDESC", "批量发布");
|
||||
subBo.set("PUBLISHFILEID", uuid);
|
||||
PALRepositoryModel model = PALRepositoryCache.getCache().get(uuid);
|
||||
String sqly = "UPDATE BO_ACT_COE_PUBLISH_N SET PUBLISHDESC ='待删除' WHERE PUBLISHFILEID = '"+uuid+"'";
|
||||
DBSql.update(sqly);
|
||||
String taskId = "N";
|
||||
try {
|
||||
System.err.println("批量转换模型名称=========>"+rowMap.getString("PLNAME"));
|
||||
taskId = createOutputReport(model, "7d3ca852-a0bd-42e6-80b1-3dcea6f55083", "admin","", uuid);
|
||||
System.err.println("批量转换模型名称=========>"+rowMap.getString("PLNAME")+"===>"+taskId);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
subBo.set("TASKID", taskId);
|
||||
boList.add(subBo);
|
||||
}
|
||||
SDK.getBOAPI().create("BO_ACT_COE_PUBLISH_N", boList, createProcessInstance, _uc);
|
||||
|
||||
/*
|
||||
* System.err.println("本次共新增手册:" + createNum); System.err.println("本次共更新手册:" +
|
||||
* updateNum);
|
||||
*/
|
||||
|
||||
}
|
||||
/**
|
||||
* 创建手册
|
||||
* @param model
|
||||
* @param wsId
|
||||
* @param userId
|
||||
* @param teamId
|
||||
* @param uuid
|
||||
* @return
|
||||
*/
|
||||
private String createOutputReport(PALRepositoryModel model, String wsId, String userId, String teamId, String uuid) {
|
||||
String taskId = "";
|
||||
if (model.getMethodId().contains("process.")) {
|
||||
taskId = PALRepositoryQueryAPIManager.getInstance().createOutputReportPr(wsId, userId, teamId, uuid);
|
||||
JSONObject object = JSONObject.parseObject(taskId);
|
||||
if ("ok".equals(object.getString("result"))) {
|
||||
taskId = object.getJSONObject("data").getString("taskId");
|
||||
}
|
||||
} else if ("data.form".equals(model.getMethodId())) {
|
||||
taskId = PALRepositoryQueryAPIManager.getInstance().createOutputReportBd(wsId, userId, teamId, uuid);
|
||||
JSONObject object = JSONObject.parseObject(taskId);
|
||||
if ("ok".equals(object.getString("result"))) {
|
||||
taskId = object.getJSONObject("data").getString("taskId");
|
||||
}
|
||||
} else if ("control.policy".equals(model.getMethodId())) {
|
||||
taskId = PALRepositoryQueryAPIManager.getInstance().createOutputReportZd(wsId, userId, teamId, uuid);
|
||||
JSONObject object = JSONObject.parseObject(taskId);
|
||||
if ("ok".equals(object.getString("result"))) {
|
||||
taskId = object.getJSONObject("data").getString("taskId");
|
||||
}
|
||||
}
|
||||
return taskId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,240 @@
|
||||
package com.actionsoft.apps.coe.pal.publisher.extend;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
import com.actionsoft.apps.coe.pal.pal.output.OutputAPIManager;
|
||||
import com.actionsoft.apps.coe.pal.pal.output.dao.OutputTask;
|
||||
import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppManager;
|
||||
import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppProfile;
|
||||
import com.actionsoft.apps.coe.pal.pal.output.model.OutputTaskModel;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.upfile.model.UpfileModel;
|
||||
import com.actionsoft.apps.resource.AppContext;
|
||||
import com.actionsoft.bpms.api.Utils;
|
||||
import com.actionsoft.bpms.bo.engine.BO;
|
||||
import com.actionsoft.bpms.commons.database.RowMap;
|
||||
import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
|
||||
import com.actionsoft.bpms.schedule.IJob;
|
||||
import com.actionsoft.bpms.server.SSOUtil;
|
||||
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.DBSql;
|
||||
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.JSONObject;
|
||||
/**
|
||||
* 模型附件去重
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
public class PAlOnlinedocFileConvertJob implements IJob {
|
||||
private UserContext _uc;
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||
System.err.println("文件转换开始====>");
|
||||
// String sql = "select * from app_act_coe_pal_publish_list ";
|
||||
String sql = "select ID,PLNAME from App_Act_Coe_Pal_Repository where ISPUBLISH ='1'";
|
||||
SSOUtil ssoUtil = new SSOUtil();
|
||||
String portalUrl = SDK.getPortalAPI().getPortalUrl();
|
||||
String session = ssoUtil.registerClientSessionNoPassword("admin", "cn", portalUrl, "pc");
|
||||
UserContext fromSessionId = UserContext.fromSessionId(session);
|
||||
List<RowMap> maps = DBSql.getMaps(sql);
|
||||
// ExecutorService service = Executors.newFixedThreadPool(4);
|
||||
for (RowMap rowMap : maps) {
|
||||
String plId = rowMap.getString("ID");
|
||||
String palname = rowMap.getString("PLNAME");
|
||||
|
||||
String sqls = "select taskId from (select * from BO_ACT_COE_PUBLISH_N where PUBLISHFILEID = '" + plId
|
||||
+ "' order by CREATEDATE desc) where rownum = 1";
|
||||
String taskId = DBSql.getString(sqls);
|
||||
String sqld = "SELECT BINDID FROM BO_ACT_COE_PUBLISH_N WHERE TASKID = '" + taskId + "'";
|
||||
String bindid = DBSql.getString(sqld);
|
||||
if (!"7964be16-dc8b-41b1-a10a-bc8a84885074".equals(bindid)) {
|
||||
outputReportPreview(fromSessionId, session, taskId, plId);
|
||||
}
|
||||
|
||||
/*
|
||||
* service.execute(new Runnable() {
|
||||
*
|
||||
* @Override public void run() { } });
|
||||
*/
|
||||
|
||||
}
|
||||
System.err.println("文件转换结束====>");
|
||||
}
|
||||
|
||||
public void outputReportPreview(UserContext _uc, String session, String taskId, String palId) {
|
||||
String sqlt = "SELECT * FROM BO_EU_PAL_OUTPUTREPORT WHERE PLID = '" + palId + "' AND RESULT = '手册转换成功!'";
|
||||
//String sqlt = "SELECT * FROM BO_EU_PAL_OUTPUTREPORT WHERE PLID = '" + palId + "'";
|
||||
RowMap maps = DBSql.getMap(sqlt);
|
||||
if (maps != null) {
|
||||
return;
|
||||
}
|
||||
BO bo = new BO();
|
||||
String sql = "select * from App_Act_Coe_Pal_Repository where id = '" + palId + "' ";
|
||||
RowMap map = DBSql.getMap(sql);
|
||||
if (map != null) {
|
||||
String ispulish = map.getString("ISPUBLISH");
|
||||
String palname = map.getString("PLNAME");
|
||||
String methodid = map.getString("PLMETHODID");
|
||||
String plparid = map.getString("PLPARENTID");
|
||||
if ("1".equals(ispulish)) {
|
||||
//if ("control.policy".equals(methodid)) {
|
||||
if("control.policy".equals(methodid)||"data.form".equals(methodid)||"process.epc".equals(methodid)||"process.flowchart".equals(methodid)){
|
||||
try {
|
||||
bo.set("PLNAME", map.getString("PLNAME"));
|
||||
bo.set("PLID", palId);
|
||||
bo.set("TASKID", taskId);
|
||||
PALRepositoryModel prmodel = PALRepositoryCache.getCache().get(plparid);
|
||||
if (prmodel != null) {
|
||||
bo.set("FRNAME", prmodel.getName());
|
||||
}
|
||||
bo.set("PLVERSION", map.getString("PLVER"));
|
||||
bo.set("PLMETHODID", map.getString("PLMETHODID"));
|
||||
OutputTaskModel model = new OutputTask().getTaskReportById(taskId);
|
||||
ResponseObject result = ResponseObject.newOkResponse();
|
||||
if (model != null) {
|
||||
UtilFile file = OutputAPIManager.getInstance().getFilePath(model.getWsId(), taskId,
|
||||
model.getProfileId());
|
||||
if (file.exists()) {
|
||||
File[] fileList = file.listFiles();
|
||||
if (fileList.length > 0) {
|
||||
File docFile = null;
|
||||
for (File file2 : fileList) {
|
||||
if (file2.isFile() && "doc".equals(
|
||||
(file2.getName().substring(file2.getName().lastIndexOf(".") + 1)))) {
|
||||
docFile = file2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (docFile == null) {
|
||||
bo.set("RESULT", "模型没有手册文件_1!");
|
||||
result = ResponseObject.newErrResponse("没有手册文件!");
|
||||
}
|
||||
if (SDK.getAppAPI().isActive("com.actionsoft.apps.addons.onlinedoc")) {
|
||||
OutputAppProfile appFile = OutputAppManager.getProfile(model.getProfileId());
|
||||
String sourceAppId = appFile.getAppContext().getId();
|
||||
String filename = docFile.getName();
|
||||
System.err.println("开始转换===>" + filename + "===>" + sourceAppId);
|
||||
DCContext sourceDc = new DCContext(_uc,
|
||||
DCProfileManager.getDCProfile(sourceAppId, "output"), sourceAppId,
|
||||
model.getWsId(), taskId, filename);
|
||||
/*
|
||||
* Map<String, Object> aslpParams = new HashMap<String, Object>();
|
||||
*
|
||||
* aslpParams.put("sid", _uc.getSessionId()); aslpParams.put("fileNameOriginal",
|
||||
* filename); aslpParams.put("sourceDc", sourceDc);
|
||||
* aslpParams.put("isShowDefaultToolbar", true); aslpParams.put("isShowBackbtn",
|
||||
* false); aslpParams.put("isEncrypt", true); aslpParams.put("isCopy", true);
|
||||
* aslpParams.put("isPrint", true); aslpParams.put("isDownload", true); AppAPI
|
||||
* appAPI = SDK.getAppAPI(); ResponseObject responseObject =
|
||||
* appAPI.callASLP(appAPI.getAppContext(sourceAppId),
|
||||
* "aslp://com.actionsoft.apps.addons.onlinedoc/filePreview", aslpParams);
|
||||
*/
|
||||
|
||||
// 调用App
|
||||
// aslp服务地址
|
||||
String aslp = "aslp://com.actionsoft.apps.addons.onlinedoc/fileConvert";
|
||||
// 参数定义列表
|
||||
HashMap<String, Object> params = new HashMap<String, Object>();
|
||||
// PDF转图片处理选项。- 0代表只在需要时做转换;- 1代表打开即检查是否已转换成图片,如未处理,强制转换。默认0,非必填
|
||||
params.put("isPDFCovertPNG", "0");
|
||||
// 原文件DC,必填
|
||||
params.put("sourceDc", sourceDc);
|
||||
// 文档是否允许复制。true为允许复制,转换结果为PDF格式文件;false为不可复制,转换结果为PNG格式文件(注意参数值为false时转换时间稍长),必填
|
||||
params.put("isCopy", true);
|
||||
// sessionid,必填
|
||||
params.put("sid", session);
|
||||
AppAPI appAPI = SDK.getAppAPI();
|
||||
// 调用转换服务.在预览之前提前进行转换,预览时直接打开转换后的文件
|
||||
String sourceId = "com.actionsoft.apps.coe.pal.publisher";
|
||||
AppContext appContext = appAPI.getAppContext(sourceId);
|
||||
ResponseObject responseObject = appAPI.callASLP(appContext, aslp, params);
|
||||
System.err.println("转换结果=======>" + responseObject);
|
||||
if (responseObject != null) {
|
||||
String results = responseObject.toString();
|
||||
if (UtilString.isNotEmpty(results)) {
|
||||
if (results.contains("200")) {
|
||||
bo.set("RESULT", "手册转换成功!");
|
||||
Map<String, Object> aslpParams = new HashMap<String, Object>();
|
||||
aslpParams.put("sid", _uc.getSessionId());
|
||||
aslpParams.put("fileNameOriginal", filename);
|
||||
aslpParams.put("sourceDc", sourceDc);
|
||||
aslpParams.put("isShowDefaultToolbar", true);
|
||||
aslpParams.put("isShowBackbtn", false);
|
||||
aslpParams.put("isEncrypt", true);
|
||||
aslpParams.put("isCopy", true);
|
||||
aslpParams.put("isPrint", true);
|
||||
aslpParams.put("isDownload", true);
|
||||
ResponseObject responseObjects = appAPI.callASLP(
|
||||
appAPI.getAppContext(sourceAppId),
|
||||
"aslp://com.actionsoft.apps.addons.onlinedoc/filePreview",
|
||||
aslpParams);
|
||||
|
||||
if (responseObjects != null) {
|
||||
if (responseObjects.isOk()) {
|
||||
String url = responseObjects.get("url").toString();
|
||||
bo.set("FILEURL", url.substring(url.indexOf("&cmd")));
|
||||
result = ResponseObject.newErrResponse("模型转换成功!");
|
||||
} else {
|
||||
bo.set("FILEURL", "链接获取失败!");
|
||||
result = ResponseObject.newErrResponse("文档转换服务不可用,请联系管理员");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
bo.set("RESULT", "文件转换失败_1!");
|
||||
result = ResponseObject.newErrResponse("文档转换服务不可用,请联系管理员");
|
||||
}
|
||||
} else {
|
||||
bo.set("RESULT", "文件转换失败_2!");
|
||||
}
|
||||
} else {
|
||||
bo.set("RESULT", "文件转换失败_3!");
|
||||
}
|
||||
|
||||
} else {
|
||||
bo.set("RESULT", "文档转换服务不可用!");
|
||||
result = ResponseObject.newErrResponse("文档转换服务不可用,请联系管理员");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
bo.set("RESULT", "模型没有手册文件_2!");
|
||||
result = ResponseObject.newErrResponse("没有手册文件!");
|
||||
}
|
||||
|
||||
} else {
|
||||
bo.set("RESULT", "模型没有手册文件_3!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
bo.set("RESULT", "文件转换失败_4!");
|
||||
} finally {
|
||||
String sqlT = "SELECT ID FROM BO_EU_PAL_OUTPUTREPORT WHERE PLID = '" + palId + "'";
|
||||
String Id = DBSql.getString(sqlT);
|
||||
if (UtilString.isNotEmpty(Id)) {
|
||||
bo.setId(Id);
|
||||
SDK.getBOAPI().update("BO_EU_PAL_OUTPUTREPORT", bo);
|
||||
} else {
|
||||
SDK.getBOAPI().createDataBO("BO_EU_PAL_OUTPUTREPORT", bo, UserContext.fromUID("admin"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,777 @@
|
||||
package com.actionsoft.apps.coe.pal.publisher.extend;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import com.actionsoft.apps.coe.pal.pal.manage.publish.dao.PublishHistory;
|
||||
import com.actionsoft.apps.coe.pal.pal.manage.publish.dao.PublishListHistory;
|
||||
import com.actionsoft.apps.coe.pal.pal.manage.publish.model.PublishHistoryModel;
|
||||
import com.actionsoft.apps.coe.pal.pal.manage.publish.model.PublishListHistoryModel;
|
||||
import com.actionsoft.apps.coe.pal.pal.output.dao.OutputTask;
|
||||
import com.actionsoft.apps.coe.pal.pal.output.model.OutputTaskModel;
|
||||
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.dao.PALRepository;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.dao.PALRepositoryPropertyDao;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.designer.manage.CoeDesignerAPIManager;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.designer.model.BaseModel;
|
||||
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.model.PALRepositoryPropertyModel;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.web.CoeProcessLevelWeb;
|
||||
import com.actionsoft.apps.coe.pal.publisher.client.util.ProcessStatusAPIManager;
|
||||
import com.actionsoft.apps.coe.pal.publisher.constant.PublisherConstant;
|
||||
import com.actionsoft.bpms.bo.engine.BO;
|
||||
import com.actionsoft.bpms.bpmn.engine.core.delegate.ProcessExecutionContext;
|
||||
import com.actionsoft.bpms.bpmn.engine.listener.ExecuteListener;
|
||||
import com.actionsoft.bpms.bpmn.engine.listener.ExecuteListenerInterface;
|
||||
import com.actionsoft.bpms.bpmn.engine.model.run.delegate.ProcessInstance;
|
||||
import com.actionsoft.bpms.commons.database.RowMap;
|
||||
import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
|
||||
import com.actionsoft.bpms.server.UserContext;
|
||||
import com.actionsoft.bpms.util.DBSql;
|
||||
import com.actionsoft.bpms.util.UUIDGener;
|
||||
import com.actionsoft.bpms.util.UtilDate;
|
||||
import com.actionsoft.bpms.util.UtilString;
|
||||
import com.actionsoft.exception.AWSAPIException;
|
||||
import com.actionsoft.exception.AWSDataAccessException;
|
||||
import com.actionsoft.exception.AWSException;
|
||||
import com.actionsoft.exception.BPMNError;
|
||||
import com.actionsoft.sdk.local.SDK;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
public class PublishExecuteListenerInterfaceImpl extends ExecuteListener implements ExecuteListenerInterface {
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "将发布信息保存至CoE中(用于批量发布流程)";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProvider() {
|
||||
return "aws-coe";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return "V6.0";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(ProcessExecutionContext param) throws Exception {
|
||||
//将发布信息保存至coe的发布表中
|
||||
PublishHistoryModel model = new PublishHistoryModel();
|
||||
String processInstId = param.getProcessInstance().getId();
|
||||
if ("terminate".equals(param.getProcessInstance().getControlState())) {
|
||||
// 流程实例中止,取消审批中状态
|
||||
ProcessStatusAPIManager.getInstance().batchUpdateApprovalStatus(processInstId, false);
|
||||
return;
|
||||
}
|
||||
BO bo = SDK.getBOAPI().query(PublisherConstant.BOTABLENAME).detailByBindId(processInstId);
|
||||
Timestamp nowTime = new Timestamp(System.currentTimeMillis());
|
||||
model.setId(UUIDGener.getUUID());
|
||||
model.setProcessInstId(processInstId);
|
||||
model.setWsId(bo.get("WSID").toString());
|
||||
model.setUserId(bo.get("APPLYUSERID").toString());
|
||||
String auditorId = "";
|
||||
if (bo.get("AUDITOR3") != null && !"".equals(bo.get("AUDITOR3").toString())) {
|
||||
auditorId = bo.get("AUDITOR3").toString();
|
||||
} else if (bo.get("AUDITOR2") != null && !"".equals(bo.get("AUDITOR2").toString())) {
|
||||
auditorId = bo.get("AUDITOR2").toString();
|
||||
} else {
|
||||
auditorId = bo.get("AUDITOR1").toString();
|
||||
}
|
||||
model.setAuditorId(auditorId);
|
||||
model.setPublishDate(nowTime);
|
||||
model.setPublishDesc(bo.get("PUBLISHDESC") == null ? "" : bo.get("PUBLISHDESC").toString());
|
||||
model.setTeamId(bo.get("TEAMID").toString());
|
||||
|
||||
List<BO> bolistN = SDK.getBOAPI().query(PublisherConstant.BOSUBTABLE_N).bindId(processInstId).list();
|
||||
model.setPublishNew(bolistN == null ? 0 : bolistN.size());
|
||||
List<BO> bolistC = SDK.getBOAPI().query(PublisherConstant.BOSUBTABLE_C).bindId(processInstId).list();
|
||||
model.setPublishChange(bolistC == null ? 0 : bolistC.size());
|
||||
List<BO> bolistS = SDK.getBOAPI().query(PublisherConstant.BOSUBTABLE_S).bindId(processInstId).list();
|
||||
model.setPublishStop(bolistS == null ? 0 : bolistS.size());
|
||||
|
||||
PublishHistory dao = new PublishHistory();
|
||||
dao.insert(model);
|
||||
|
||||
PublishListHistory listDao = new PublishListHistory();
|
||||
PALRepository repositoryDao = new PALRepository();
|
||||
//将发布信息保存至coe的发布子表中
|
||||
if (bolistN != null) {
|
||||
for (BO boN : bolistN) {
|
||||
PublishListHistoryModel publishListHistoryModelN = new PublishListHistoryModel();
|
||||
publishListHistoryModelN.setId(UUIDGener.getUUID());
|
||||
publishListHistoryModelN.setActionType("N");
|
||||
publishListHistoryModelN.setpId(model.getId());
|
||||
publishListHistoryModelN.setPublishDate(model.getPublishDate());
|
||||
publishListHistoryModelN.setPalRepositoryId(boN.get("PUBLISHFILEID").toString());
|
||||
publishListHistoryModelN.setPublishDesc(boN.get("PUBLISHDESC") == null ? "" : boN.get("PUBLISHDESC").toString());
|
||||
if (boN.get("TASKID") != null && !"".equals(boN.get("TASKID"))) {
|
||||
publishListHistoryModelN.setTaskId(boN.get("TASKID").toString());
|
||||
} else {
|
||||
publishListHistoryModelN.setTaskId("");
|
||||
}
|
||||
listDao.insert(publishListHistoryModelN);
|
||||
//修改流程文件的发布属性和发布时间
|
||||
repositoryDao.updatePublishStatusAndDate("N", boN.get("PUBLISHFILEID").toString(), null, model.getPublishDate());
|
||||
|
||||
//修改关联角色、绩效发布状态
|
||||
updateRoleAndPerformance(boN.get("PUBLISHFILEID").toString(),model.getPublishDate(),"N");
|
||||
|
||||
//绩效模型中数据模型回填流程编号
|
||||
updateProcessNumber(boN.get("PUBLISHFILEID").toString(),param.getUserContext(),bo.get("WSID").toString(),boN.getString("PUBLISH_NUMBER"),model.getPublishDate());
|
||||
|
||||
|
||||
}
|
||||
//by bzp 测试编号生成
|
||||
//new ProcesNumberUtil().getNumber(processInstId);
|
||||
}
|
||||
if (bolistC != null) {
|
||||
for (BO boC : bolistC) {
|
||||
PublishListHistoryModel publishListHistoryModelC = new PublishListHistoryModel();
|
||||
publishListHistoryModelC.setId(UUIDGener.getUUID());
|
||||
publishListHistoryModelC.setActionType("C");
|
||||
publishListHistoryModelC.setpId(model.getId());
|
||||
publishListHistoryModelC.setPublishDate(model.getPublishDate());
|
||||
publishListHistoryModelC.setPalRepositoryId(boC.get("CHANGEDFILEIDNEW").toString());
|
||||
publishListHistoryModelC.setPublishDesc(boC.get("CHANGEDDESC") == null ? "" : boC.get("CHANGEDDESC").toString());
|
||||
if (boC.get("TASKID") != null && !"".equals(boC.get("TASKID"))) {
|
||||
publishListHistoryModelC.setTaskId(boC.get("TASKID").toString());
|
||||
} else {
|
||||
publishListHistoryModelC.setTaskId("");
|
||||
}
|
||||
listDao.insert(publishListHistoryModelC);
|
||||
//修改流程文件的发布属性
|
||||
repositoryDao.updatePublishStatusAndDate("C", boC.get("CHANGEDFILEIDNEW").toString(), boC.get("CHANGEFILEID").toString(), model.getPublishDate());
|
||||
|
||||
|
||||
//修改关联角色、绩效发布状态
|
||||
updateRoleAndPerformance(boC.get("CHANGEDFILEIDNEW").toString(),model.getPublishDate(),"C");
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
if (bolistS != null) {
|
||||
for (BO boS : bolistS) {
|
||||
PublishListHistoryModel publishListHistoryModelS = new PublishListHistoryModel();
|
||||
publishListHistoryModelS.setId(UUIDGener.getUUID());
|
||||
publishListHistoryModelS.setActionType("S");
|
||||
publishListHistoryModelS.setpId(model.getId());
|
||||
publishListHistoryModelS.setPublishDate(model.getPublishDate());
|
||||
publishListHistoryModelS.setPalRepositoryId(boS.get("STOPFILEID").toString());
|
||||
publishListHistoryModelS.setPublishDesc(boS.get("STOPDESC") == null ? "" : boS.get("STOPDESC").toString());
|
||||
if (boS.get("TASKID") != null && !"".equals(boS.get("TASKID"))) {
|
||||
publishListHistoryModelS.setTaskId(boS.get("TASKID").toString());
|
||||
} else {
|
||||
publishListHistoryModelS.setTaskId("");
|
||||
}
|
||||
listDao.insert(publishListHistoryModelS);
|
||||
//修改流程文件的发布属性
|
||||
repositoryDao.updatePublishStatusAndDate("S", boS.get("STOPFILEID").toString(), null, model.getPublishDate());
|
||||
}
|
||||
}
|
||||
// 生效日期信息处理&并创建手册
|
||||
updateEffectiveDateProperty(processInstId, bo, nowTime, bolistN, bolistC);
|
||||
// 流程发布范围权限单独存储
|
||||
//savePublishScope(bo, bolistN, bolistC, bolistS);
|
||||
}
|
||||
|
||||
private void updateEffectiveDateProperty(String processInstId, BO bo, Timestamp publishDate, List<BO> bolistN, List<BO> bolistC) {
|
||||
// 对epc、表单、制度图进行生效日期更新和手册重新生成
|
||||
// epc:process.epc effective_date
|
||||
// 表单:data.form form_effective_date
|
||||
// 制度:control.policy effective_date
|
||||
String applyUser = bo.getString("APPLYUSERID");// 以申请人身份创建流程手册
|
||||
String date = UtilDate.datetimeFormat(publishDate);
|
||||
PALRepositoryPropertyDao propertyDao = new PALRepositoryPropertyDao();
|
||||
// 创建线程池进行流程手册的处理
|
||||
ExecutorService service = Executors.newFixedThreadPool(4);
|
||||
//将发布范围权限信息保存至范围权限表
|
||||
if (bolistN != null) {
|
||||
for (BO boN : bolistN) {
|
||||
String palId = boN.get("PUBLISHFILEID").toString();
|
||||
PALRepositoryModel model = PALRepositoryCache.getCache().get(palId);
|
||||
if (model == null) {
|
||||
SDK.getLogAPI().consoleErr("[更新生效日期和创建手册]更新失败,模型不存在,模型[" + palId + "]");
|
||||
continue;
|
||||
}
|
||||
// 重新创建手册
|
||||
service.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateProcessReport(model.getId(), processInstId, "N", applyUser);
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
* // 新增模型时间 if (updatePropertyEffectiveDate(model, date, propertyDao)) {
|
||||
*
|
||||
* }
|
||||
*/
|
||||
|
||||
}
|
||||
}
|
||||
if (bolistC != null) {
|
||||
for (BO boC : bolistC) {
|
||||
String palId = boC.get("CHANGEDFILEIDNEW").toString();
|
||||
PALRepositoryModel model = PALRepositoryCache.getCache().get(palId);
|
||||
if (model == null) {
|
||||
SDK.getLogAPI().consoleErr("[更新生效日期和创建手册]更新失败,模型不存在,模型[" + palId + "]");
|
||||
continue;
|
||||
}
|
||||
// 重新创建手册
|
||||
service.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateProcessReport(model.getId(), processInstId, "C", applyUser);
|
||||
}
|
||||
});
|
||||
/*
|
||||
* // 新增模型时间 if (updatePropertyEffectiveDate(model, date, propertyDao)) { }
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新生成流程手册,编号进行处理
|
||||
* @param uuid
|
||||
*/
|
||||
private void updateProcessReport(String uuid, String processInstId, String type, String appUser) {
|
||||
// epc:process.epc effective_date
|
||||
// 表单:data.form form_effective_date
|
||||
// 制度:control.policy effective_date
|
||||
PALRepositoryModel model = PALRepositoryCache.getCache().get(uuid);
|
||||
String category = model.getMethodCategory();
|
||||
if ("default".equals(model.getMethodId())) {
|
||||
return;
|
||||
}
|
||||
// 校验流程手册是否安装并启动
|
||||
if (model.getMethodId().contains("process.") && !SDK.getAppAPI().isActive("com.actionsoft.apps.coe.pal.output.pr")) {
|
||||
SDK.getLogAPI().consoleErr("[流程手册未安装]流程手册更新失败");
|
||||
return;
|
||||
}
|
||||
if ("data.form".equals(model.getMethodId()) && !SDK.getAppAPI().isActive("com.awspaas.user.apps.coe.pal.output.bd")) {
|
||||
SDK.getLogAPI().consoleErr("[表单手册未安装]流程手册更新失败");
|
||||
return;
|
||||
}
|
||||
if ("control.policy".equals(model.getMethodId()) && !SDK.getAppAPI().isActive("com.awspaas.user.apps.coe.pal.output.zd")) {
|
||||
SDK.getLogAPI().consoleErr("[表单手册未安装]流程手册更新失败");
|
||||
return;
|
||||
}
|
||||
|
||||
if ("N".equals(type)) {
|
||||
BO nBo = SDK.getBOAPI().query(PublisherConstant.BOSUBTABLE_N, true)
|
||||
.bindId(processInstId)
|
||||
.addQuery("PUBLISHFILEID=", uuid)
|
||||
.detail();
|
||||
if (nBo != null) {
|
||||
String boId = nBo.getId();
|
||||
// 创建流程手册
|
||||
String oldTaskId = nBo.getString("TASKID");
|
||||
// 获取报告类型
|
||||
OutputTaskModel taskModel = new OutputTask().getTaskReportById(oldTaskId);
|
||||
if (taskModel != null) {
|
||||
String taskId = createOutputReport(model, model.getWsId(), appUser, "", model.getId());
|
||||
if (UtilString.isNotEmpty(taskId)) {
|
||||
// 更新流程发布表
|
||||
SDK.getLogAPI().consoleInfo("流程发布[发布]审核完成后创建手册,流程名称:" + model.getName() + "[" + model.getId() + "],taskId:" + taskId + " 成功");
|
||||
// 更新BO表taskId字段
|
||||
int r1 = DBSql.update("UPDATE BO_ACT_COE_PUBLISH_N SET TASKID='" + taskId + "'WHERE ID ='" + boId + "'");
|
||||
PublishHistory dao = new PublishHistory();// 发布结果主表
|
||||
PublishHistoryModel history = dao.queryBy("PROCESSINSTID = ?", processInstId);
|
||||
int r2 = -1;
|
||||
if (history != null) {
|
||||
r2 = DBSql.update("UPDATE APP_ACT_COE_PAL_PUBLISH_LIST SET TASKID='" + taskId + "'WHERE PID ='" + history.getId() + "' AND PALREPOSITORYID='" + uuid + "'");
|
||||
}
|
||||
SDK.getLogAPI().consoleInfo("流程发布[发布]审核完成后更新数据库taskId,流程名称:" + model.getName() + "[" + model.getId() + "],影响结果数量:BO_ACT_COE_PUBLISH_N[" + r1 + "],APP_ACT_COE_PAL_PUBLISH_LIST[" + r2 + "]");
|
||||
} else {
|
||||
SDK.getLogAPI().consoleInfo("流程发布[发布]审核完成后创建手册,流程名称:" + model.getName() + "[" + model.getId() + "] 失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ("C".equals(type)) {
|
||||
BO cBo = SDK.getBOAPI().query(PublisherConstant.BOSUBTABLE_C, true)
|
||||
.bindId(processInstId)
|
||||
.addQuery("CHANGEDFILEIDNEW=", uuid)
|
||||
.detail();
|
||||
if (cBo != null) {
|
||||
String boId = cBo.getId();
|
||||
// 创建流程手册
|
||||
String oldTaskId = cBo.getString("TASKID");
|
||||
// 获取报告类型
|
||||
OutputTaskModel taskModel = new OutputTask().getTaskReportById(oldTaskId);
|
||||
if (taskModel != null) {
|
||||
String taskId = createOutputReport(model, model.getWsId(), appUser, "", model.getId());
|
||||
if (UtilString.isNotEmpty(taskId)) {
|
||||
// 更新流程发布表
|
||||
SDK.getLogAPI().consoleInfo("流程发布[变更]审核完成后创建手册,流程名称:" + model.getName() + "[" + model.getId() + "],taskId:" + taskId + " 成功");
|
||||
// 更新BO表taskId字段
|
||||
int r1 = DBSql.update("UPDATE BO_ACT_COE_PUBLISH_C SET TASKID='" + taskId + "'WHERE ID ='" + boId + "'");
|
||||
PublishHistory dao = new PublishHistory();// 发布结果主表
|
||||
PublishHistoryModel history = dao.queryBy("PROCESSINSTID = ?", processInstId);
|
||||
int r2 = -1;
|
||||
if (history != null) {
|
||||
r2 = DBSql.update("UPDATE APP_ACT_COE_PAL_PUBLISH_LIST SET TASKID='" + taskId + "'WHERE PID ='" + history.getId() + "' AND PALREPOSITORYID='" + uuid + "'");
|
||||
}
|
||||
SDK.getLogAPI().consoleInfo("流程发布[变更]审核完成后更新数据库taskId,流程名称:" + model.getName() + "[" + model.getId() + "],影响结果数量:BO_ACT_COE_PUBLISH_C[" + r1 + "],APP_ACT_COE_PAL_PUBLISH_LIST[" + r2 + "]");
|
||||
} else {
|
||||
SDK.getLogAPI().consoleInfo("流程发布[变更]审核完成后创建手册,流程名称:" + model.getName() + "[" + model.getId() + "] 失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建手册
|
||||
* @param model
|
||||
* @param wsId
|
||||
* @param _uc
|
||||
* @param teamId
|
||||
* @param uuid
|
||||
* @return
|
||||
*/
|
||||
private String createOutputReport(PALRepositoryModel model, String wsId, String userId, String teamId, String uuid) {
|
||||
String taskId = "";
|
||||
if (model.getMethodId().contains("process.")) {
|
||||
taskId = PALRepositoryQueryAPIManager.getInstance().createOutputReportPr(wsId, userId, teamId, uuid);
|
||||
JSONObject object = JSONObject.parseObject(taskId);
|
||||
if ("ok".equals(object.getString("result"))) {
|
||||
taskId = object.getJSONObject("data").getString("taskId");
|
||||
}
|
||||
} else if ("data.form".equals(model.getMethodId())) {
|
||||
taskId = PALRepositoryQueryAPIManager.getInstance().createOutputReportBd(wsId, userId, teamId, uuid);
|
||||
JSONObject object = JSONObject.parseObject(taskId);
|
||||
if ("ok".equals(object.getString("result"))) {
|
||||
taskId = object.getJSONObject("data").getString("taskId");
|
||||
}
|
||||
} else if ("control.policy".equals(model.getMethodId())) {
|
||||
taskId = PALRepositoryQueryAPIManager.getInstance().createOutputReportZd(wsId, userId, teamId, uuid);
|
||||
JSONObject object = JSONObject.parseObject(taskId);
|
||||
if ("ok".equals(object.getString("result"))) {
|
||||
taskId = object.getJSONObject("data").getString("taskId");
|
||||
}
|
||||
}
|
||||
return taskId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新文件属性(生效日期)
|
||||
*
|
||||
* @param model
|
||||
* @param publishDate
|
||||
* @param propertyDao
|
||||
*/
|
||||
private boolean updatePropertyEffectiveDate(PALRepositoryModel model, String date, PALRepositoryPropertyDao propertyDao) {
|
||||
// epc:process.epc effective_date
|
||||
// 表单:data.form form_effective_date
|
||||
// 制度:control.policy effective_date
|
||||
String method = model.getMethodId();
|
||||
String attrId = "";
|
||||
if ("process.epc".equals(method)) {
|
||||
attrId = "effective_date";
|
||||
} else if ("data.form".equals(method)) {
|
||||
attrId = "form_effective_date";
|
||||
} else if ("control.policy".equals(method)) {
|
||||
attrId = "effective_date";
|
||||
}
|
||||
if (UtilString.isEmpty(attrId)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 更新生效时间
|
||||
boolean existProp = false;
|
||||
List<PALRepositoryPropertyModel> list = propertyDao.getPropertysByPlid(model.getId(), attrId);
|
||||
for (PALRepositoryPropertyModel propertyModel : list) {
|
||||
if (attrId.equals(propertyModel.getPropertyId())) {
|
||||
propertyDao.updatePropertyByPropertyId(model.getId(), attrId, date);
|
||||
SDK.getLogAPI().consoleInfo("[更新模型生效时间]成功,模型[" + model.getName() + "][" + model.getId() + "],生效时间[" + date + "]");
|
||||
existProp = true;
|
||||
}
|
||||
}
|
||||
if (!existProp) {
|
||||
// 属性不存在,新增一个
|
||||
PALRepositoryPropertyModel property = new PALRepositoryPropertyModel();
|
||||
property.setId(UUIDGener.getUUID());
|
||||
property.setOrderIndex(0);
|
||||
property.setPlId(model.getId());
|
||||
property.setPropertyId(attrId);
|
||||
property.setPropertyName("生效时间");
|
||||
property.setPropertyValue(date);
|
||||
propertyDao.insert(property);
|
||||
SDK.getLogAPI().consoleInfo("[新增模型生效时间]成功,模型[" + model.getName() + "][" + model.getId() + "],生效时间[" + date + "]");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 流程发布范围权限单独存储
|
||||
* @param bo 流程发布bo主表
|
||||
* @param bolistN 新增发布流程信息
|
||||
* @param bolistC 变更发布流程信息,需要将已存在的相应流程权限信息进行删除,再进行权限存储
|
||||
* @param bolistS 停用发布流程信息,删除相应流程权限信息
|
||||
*/
|
||||
private void savePublishScope(BO publish, List<BO> bolistN, List<BO> bolistC, List<BO> bolistS) {
|
||||
String bindId = publish.getBindId();
|
||||
String wsId = publish.getString("WSID");
|
||||
String applyUser = publish.getString("APPLYUSERID");
|
||||
String sendScope = publish.getString("SEND_SCOP");
|
||||
String sendScopeOrg = publish.getString("SEND_SCOPE_ORG");
|
||||
String sendScopePost = publish.getString("SEND_SCOPE_POST");
|
||||
String sendScopeLevel = publish.getString("SEND_SCOPE_LEVEL");
|
||||
Set<String> removeVerIds = new HashSet<>();
|
||||
Map<String, String> addVerMap = new HashMap<>();
|
||||
//将发布范围权限信息保存至范围权限表
|
||||
if (bolistN != null) {
|
||||
for (BO boN : bolistN) {
|
||||
String palId = boN.get("PUBLISHFILEID").toString();
|
||||
PALRepositoryModel model = PALRepositoryCache.getCache().get(palId);
|
||||
if (model == null) {
|
||||
SDK.getLogAPI().consoleErr("[发布范围权限信息保存至范围权限表]更新失败,模型[" + palId + "]");
|
||||
continue;
|
||||
}
|
||||
addVerMap.put(model.getVersionId(), model.getName());
|
||||
removeVerIds.add(model.getVersionId());
|
||||
}
|
||||
}
|
||||
if (bolistC != null) {
|
||||
for (BO boC : bolistC) {
|
||||
String palId = boC.get("CHANGEDFILEIDNEW").toString();
|
||||
PALRepositoryModel model = PALRepositoryCache.getCache().get(palId);
|
||||
if (model == null) {
|
||||
SDK.getLogAPI().consoleErr("[发布范围权限信息保存至范围权限表]更新失败,模型[" + palId + "]");
|
||||
continue;
|
||||
}
|
||||
addVerMap.put(model.getVersionId(), model.getName());
|
||||
removeVerIds.add(model.getVersionId());
|
||||
}
|
||||
}
|
||||
if (bolistS != null) {
|
||||
for (BO boS : bolistS) {
|
||||
String palId = boS.get("STOPFILEID").toString();
|
||||
PALRepositoryModel model = PALRepositoryCache.getCache().get(palId);
|
||||
if (model == null) {
|
||||
SDK.getLogAPI().consoleErr("[发布范围权限信息保存至范围权限表]更新失败,模型[" + palId + "]");
|
||||
continue;
|
||||
}
|
||||
removeVerIds.add(model.getVersionId());
|
||||
}
|
||||
}
|
||||
|
||||
String newBoName = "BO_ACT_PUBLISH_PERM_SCOPE";
|
||||
// 先删除相应原有权限数据,再进行数据更新
|
||||
Set<String> removeIds = new HashSet<>();
|
||||
for (String removeVerId : removeVerIds) {
|
||||
List<BO> delList = SDK.getBOAPI().query(newBoName).addQuery("PALVERSIONID=", removeVerId).list();
|
||||
if (delList != null && delList.size() > 0) {
|
||||
for (BO del : delList) {
|
||||
removeIds.add(del.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
for (String removeId : removeIds) {
|
||||
SDK.getBOAPI().remove(newBoName, removeId);
|
||||
}
|
||||
|
||||
// 重新添加权限
|
||||
List<BO> list = new ArrayList<>();
|
||||
for (Map.Entry<String, String> entry : addVerMap.entrySet()) {
|
||||
String verId = entry.getKey();
|
||||
String name = entry.getValue();
|
||||
BO bo = new BO();
|
||||
bo.set("PERMID", UUIDGener.getUUID());
|
||||
bo.set("WSID", wsId);
|
||||
bo.set("PALVERSIONID", verId);
|
||||
bo.set("PALNAME", name);
|
||||
bo.set("PERMTYPE", sendScope);
|
||||
bo.set("ORGPERM", "1".equals(sendScope) ? SDK.getORGAPI().getCompanyByUser(applyUser).getId() : sendScopeOrg);
|
||||
bo.set("POSTPERM", "1".equals(sendScope) ? "" : sendScopePost);
|
||||
bo.set("LEVELPERM", "1".equals(sendScope) ? "" : sendScopeLevel);
|
||||
list.add(bo);
|
||||
}
|
||||
if (list.size() > 0) {
|
||||
SDK.getBOAPI().create(newBoName, list, bindId, applyUser);
|
||||
SDK.getLogAPI().consoleInfo("[发布范围权限信息保存至范围权限表]更新成功");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/****
|
||||
* 发布明细如果关联角色、绩效图,不显示在发布界面,在流程结束后同步发布
|
||||
*/
|
||||
public void updateRoleAndPerformance(String publishFileId,Timestamp publishDate,String type){
|
||||
try {
|
||||
List roleList = new ArrayList();
|
||||
roleList.add(0, "org.role");
|
||||
roleList.add(1, publishFileId);
|
||||
PALRepository repositoryDao = new PALRepository();
|
||||
RowMap rolerowMap = DBSql.getMap("SELECT ID FROM APP_ACT_COE_PAL_REPOSITORY WHERE EXT2=?", roleList.toString());
|
||||
|
||||
if (rolerowMap != null) {
|
||||
//修改流程文件的发布属性
|
||||
repositoryDao.updatePublishStatusAndDate(type, rolerowMap.getString("ID"), null, publishDate);
|
||||
}
|
||||
List performanceList = new ArrayList();
|
||||
performanceList.add(0, "control.kpi");
|
||||
performanceList.add(1, publishFileId);
|
||||
|
||||
RowMap performrowMap = DBSql.getMap("SELECT ID FROM APP_ACT_COE_PAL_REPOSITORY WHERE EXT2=?", performanceList.toString());
|
||||
|
||||
if (performrowMap != null) {
|
||||
//修改流程文件的发布属性
|
||||
repositoryDao.updatePublishStatusAndDate(type, performrowMap.getString("ID"), null, publishDate);
|
||||
}
|
||||
} catch (AWSDataAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 1、发布结束后获取关联绩效模型填充流程编号
|
||||
* 2、获取信息插入绩效指标库
|
||||
* @param publishFileId
|
||||
* @param publishDate
|
||||
*/
|
||||
public void updateProcessNumber(String publishFileId, UserContext uc, String wsId, String processNumber,Timestamp publishDate) {
|
||||
try {
|
||||
//获取关联绩效模型数据
|
||||
List performanceList = new ArrayList();
|
||||
performanceList.add(0, "control.kpi");
|
||||
performanceList.add(1, publishFileId);
|
||||
|
||||
RowMap performrowMap = DBSql.getMap("SELECT ID FROM APP_ACT_COE_PAL_REPOSITORY WHERE EXT2=?", performanceList.toString());
|
||||
|
||||
ProcessInstance processInst = SDK.getProcessAPI().createBOProcessInstance("obj_1ffbc1e73b99427ca64469e466f97dbe", uc.getUID(), "指标绩效数据插入");
|
||||
|
||||
|
||||
ProcessInstance performNumberProcess = SDK.getProcessAPI().createBOProcessInstance("obj_b92c1343b4914e969ead13db62f360f2", uc.getUID(), "绩效编号插入");
|
||||
|
||||
if (performrowMap != null) {
|
||||
|
||||
PALRepositoryModel parentModel = PALRepositoryCache.getCache().get(performrowMap.getString("ID"));
|
||||
|
||||
String id = performrowMap.getString("ID");
|
||||
|
||||
|
||||
Map<String, Map<String, JSONObject>> methodAttrsMap = new HashMap<>();// 属性存储
|
||||
|
||||
Map<String, String> methodValueAttrsMap = new HashMap<>();// 属性存储
|
||||
|
||||
//查询对应绩效模型中数据模型进行填充数据
|
||||
BaseModel defineModel = CoeDesignerAPIManager.getInstance().getDefinition(id, 0);
|
||||
|
||||
CoeProcessLevelWeb coeProcessLevelWeb = new CoeProcessLevelWeb(uc);
|
||||
|
||||
String define = defineModel.getDefinition();
|
||||
JSONObject definition = JSONObject.parseObject(define);
|
||||
JSONObject elements = definition.getJSONObject("elements");
|
||||
|
||||
coeProcessLevelWeb.handleShapeDefaultAttr(wsId, parentModel, elements, methodAttrsMap);
|
||||
|
||||
|
||||
if(UtilString.isNotEmpty(processNumber)){
|
||||
//编号规则为: MP(流程编号是:08.01.05.05/P05V1.0-YLYYYY,对应的流程绩效编号MP-08.01.05.05-YLYYYY.AA(AA=1~99顺序排号)对流程编号,去除"/P05V1.0)
|
||||
|
||||
|
||||
//去掉 /P05V1.0-
|
||||
String before = null;
|
||||
String after = null;
|
||||
try {
|
||||
before = processNumber.substring(0, processNumber.indexOf("/"));
|
||||
after = processNumber.substring(processNumber.lastIndexOf("-"), processNumber.length());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
int currentnumber = 0;
|
||||
//拿去流程数据填充绩效模型中数据属性
|
||||
for (String key : elements.keySet()) {
|
||||
//获取当前MP绩效最新排序数值
|
||||
BO performanceNumberBO = SDK.getBOAPI().query("BO_EU_PERFORMANCE_NUMBER").addQuery("PERFORMANCE_TYPE=", "control.kpi").addQuery("PROCESS_NUMBER=", processNumber).detail();
|
||||
|
||||
JSONObject shape1 = elements.getJSONObject(key);
|
||||
if ("linker".equals(shape1.getString("name"))) {
|
||||
continue;
|
||||
}
|
||||
String shapeText = shape1.getString("text");
|
||||
JSONArray dataAttributes = shape1.getJSONArray("dataAttributes");
|
||||
if (!dataAttributes.isEmpty() && dataAttributes.size() > 0) {
|
||||
|
||||
if (performanceNumberBO != null) {
|
||||
currentnumber = Integer.valueOf(performanceNumberBO.getString("CURRENTNUMBER"));
|
||||
} else {
|
||||
BO performanceBo = new BO();
|
||||
performanceBo.set("PROCESS_NUMBER", processNumber);
|
||||
performanceBo.set("CURRENTNUMBER", 1);
|
||||
performanceBo.set("PERFORMANCE_TYPE", "control.kpi");
|
||||
SDK.getBOAPI().create("BO_EU_PERFORMANCE_NUMBER", performanceBo, performNumberProcess.getId(), "");
|
||||
currentnumber = 0;
|
||||
}
|
||||
currentnumber++;
|
||||
|
||||
for (Object attribute : dataAttributes) {
|
||||
JSONObject obj = (JSONObject) attribute;
|
||||
if (obj.containsKey("attributesJsonArray")) {
|
||||
JSONArray attributesJsonArray = obj.getJSONArray("attributesJsonArray");
|
||||
BO recordBO = new BO();
|
||||
if (attributesJsonArray.size() > 0) {
|
||||
for (int i = 0; i < attributesJsonArray.size(); i++) {
|
||||
if (attributesJsonArray.getJSONObject(i).containsKey("id")) {
|
||||
String getid = attributesJsonArray.getJSONObject(i).getString("id");
|
||||
String value = attributesJsonArray.getJSONObject(i).getString("value");
|
||||
|
||||
//回填流程编号到绩效模型
|
||||
if (getid.equals("Number_of_the_associated_flow_file")) {
|
||||
attributesJsonArray.getJSONObject(i).put("value", processNumber);
|
||||
}
|
||||
|
||||
|
||||
//插入绩效指标库操作
|
||||
if (getid.equals("Process_Architecture_L1")) {//L1
|
||||
recordBO.set("PROCESS_ARCHITECTURE_L1", value);
|
||||
}
|
||||
if (getid.equals("Process_Architecture_L2")) {//L2
|
||||
recordBO.set("PROCESS_ARCHITECTURE_L2", value);
|
||||
}
|
||||
if (getid.equals("Process_Architecture_L3")) {//L3
|
||||
recordBO.set("PROCESS_ARCHITECTURE_L3", value);
|
||||
}
|
||||
if (getid.equals("Number_of_the_associated_flow_file")) {//关联流程文件编号
|
||||
recordBO.set("NUMBER_OF_THE_ASSO_FLOW_FILE", value);
|
||||
}
|
||||
if (getid.equals("Associated_process_name")) {//关联流程名称
|
||||
recordBO.set("ASSOCIATED_PROCESS_NAME", value);
|
||||
}
|
||||
if (getid.equals("Name_process_performance_indicator")) {//流程绩效指标名称
|
||||
recordBO.set("PERFORMANCE_INDICATOR_NAME", value);
|
||||
}
|
||||
|
||||
if (getid.equals("Index_properties")) {//指标性质
|
||||
recordBO.set("INDEX_PROPERTIES", value);
|
||||
}
|
||||
if (getid.equals("ndicator_User_defined_label")) {//指标自定义标签
|
||||
recordBO.set("NDICATOR_USER_DEFINED_LABEL", value);
|
||||
}
|
||||
if (getid.equals("Index_definition")) {//指标定义
|
||||
recordBO.set("INDEX_DEFINITION", value);
|
||||
}
|
||||
if (getid.equals("unit_measurement")) {//计量单位
|
||||
recordBO.set("UNIT_MEASUREMENT", value);
|
||||
}
|
||||
if (getid.equals("statistical_period")) {//统计周期
|
||||
recordBO.set("STATISTICAL_PERIOD", value);
|
||||
}
|
||||
|
||||
if (getid.equals("computational_formula")) {//计算公式
|
||||
recordBO.set("COMPUTATIONAL_FORMULA", value);
|
||||
}
|
||||
if (getid.equals("Data_fetch_logic")) {//数据取数逻辑
|
||||
recordBO.set("DATA_FETCH_LOGIC", value);
|
||||
}
|
||||
if (getid.equals("Take_the_number_aperture")) {//取数口径
|
||||
recordBO.set("TAKE_THE_NUMBER_APERTURE", value);
|
||||
}
|
||||
if (getid.equals("remark")) {//备注
|
||||
recordBO.set("REMARK", value);
|
||||
}
|
||||
if (getid.equals("oa_process")) {//OA流程
|
||||
recordBO.set("OA_PROCESS", value);
|
||||
}
|
||||
|
||||
if (getid.equals("The_upstream_indicators")) {//上游指标
|
||||
if(UtilString.isNotEmpty(value)){
|
||||
String The_upstream_indicatorsValue=value.substring(value.indexOf('"')+1,value.lastIndexOf('"'));
|
||||
RowMap rowMap=DBSql.getMap("SELECT RELATIONSHAPETEXT FROM APP_ACT_COE_PAL_SHAPE_RLAT WHERE FILEID=? AND RELATIONSHAPEID=?",id,The_upstream_indicatorsValue);
|
||||
recordBO.set("THE_UPSTREAM_INDICATORS_ID", The_upstream_indicatorsValue);
|
||||
if(rowMap!=null){
|
||||
recordBO.set("THE_UPSTREAM_INDICATORS",rowMap.getString("RELATIONSHAPETEXT"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (getid.equals("Downstream_target")) {//下游指标
|
||||
if(UtilString.isNotEmpty(value)){
|
||||
String Downstream_target=value.substring(value.indexOf('"')+1,value.lastIndexOf('"'));
|
||||
RowMap rowMap=DBSql.getMap("SELECT RELATIONSHAPETEXT FROM APP_ACT_COE_PAL_SHAPE_RLAT WHERE FILEID=? AND RELATIONSHAPEID=?",id,Downstream_target);
|
||||
recordBO.set("DOWNSTREAM_TARGET_ID", Downstream_target);
|
||||
if(rowMap!=null){
|
||||
recordBO.set("DOWNSTREAM_TARGET",rowMap.getString("RELATIONSHAPETEXT"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
recordBO.set("PERFORMANCE_TYPE", "末级流程绩效");
|
||||
|
||||
if (getid.equals("element")) {//元素
|
||||
JSONObject getvalue = attributesJsonArray.getJSONObject(i).getJSONObject("value");
|
||||
if (getvalue != null) {
|
||||
JSONArray elejsonArray = attributesJsonArray.getJSONObject(i).getJSONObject("value").getJSONArray("table");
|
||||
for (int k = 1; k < elejsonArray.size(); k++) {
|
||||
String name = elejsonArray.getJSONObject(k).get("name").toString();
|
||||
String desc = elejsonArray.getJSONObject(k).get("desc").toString();
|
||||
BO eleBO = new BO();
|
||||
eleBO.set("ELEMENT", name);
|
||||
eleBO.set("DATASOURCES", desc);
|
||||
SDK.getBOAPI().create("BO_EU_ELEMENT", eleBO, processInst.getId(), "");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//发布时间
|
||||
recordBO.set("PUBDATE", publishDate);
|
||||
//回填绩效编号操作
|
||||
if (getid.equals("Process_performance_indicator_Number")) {
|
||||
if(UtilString.isEmpty(value)){
|
||||
attributesJsonArray.getJSONObject(i).put("value", "MA." + before + after +"."+ currentnumber);
|
||||
|
||||
recordBO.set("PROCESS_PERFORMANCE_IND_NUM","MA." + before + after +"."+ currentnumber);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
SDK.getBOAPI().create("BO_EU_PER_IND_LIB", recordBO, processInst.getId(), "");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(performanceNumberBO!=null){
|
||||
performanceNumberBO.set("CURRENTNUMBER", currentnumber);
|
||||
}else{
|
||||
performanceNumberBO=SDK.getBOAPI().query("BO_EU_PERFORMANCE_NUMBER").addQuery("PERFORMANCE_TYPE=", "control.kpi").addQuery("PROCESS_NUMBER=", processNumber).detail();
|
||||
}
|
||||
SDK.getBOAPI().update("BO_EU_PERFORMANCE_NUMBER", performanceNumberBO);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
defineModel.setDefinition(definition.toString());
|
||||
// 保存文件
|
||||
CoeDesignerAPIManager.getInstance().storeDefinition(defineModel);// dao操作
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
} catch (AWSDataAccessException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,88 @@
|
||||
package com.actionsoft.apps.coe.pal.publisher.extend;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
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.model.PALRepositoryModel;
|
||||
import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
|
||||
import com.actionsoft.bpms.server.bind.annotation.Controller;
|
||||
import com.actionsoft.bpms.server.bind.annotation.Mapping;
|
||||
import com.actionsoft.bpms.util.DBSql;
|
||||
import com.actionsoft.bpms.util.UtilString;
|
||||
import com.actionsoft.sdk.local.SDK;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
/**
|
||||
* 修改文件状态
|
||||
* @author lihongyu
|
||||
*
|
||||
*/
|
||||
@Controller
|
||||
public class UpateFileStateController {
|
||||
private static Logger logger = LoggerFactory.getLogger(UpateFileStateController.class);
|
||||
|
||||
// 修改文件发布状态
|
||||
@Mapping("com.awspaas.user.apps.app.controller.updatePalFileState")
|
||||
public ResponseObject checkIsSend(String sid, String plId, String state, String type) {
|
||||
ResponseObject ro = ResponseObject.newOkResponse();
|
||||
int count = 0;
|
||||
if ("1".equals(type)) {
|
||||
String id = DBSql.getString("SELECT ID FROM APP_ACT_COE_PAL_PUBLISH_LIST WHERE PALREPOSITORYID='" + plId + "'");
|
||||
if (UtilString.isNotEmpty(id)) {
|
||||
String updataSql = "UPDATE APP_ACT_COE_PAL_REPOSITORY SET ISPUBLISH = '" + state + "' WHERE ID = '"
|
||||
+ plId + "'";
|
||||
count += DBSql.update(updataSql);
|
||||
String sqlt = "UPDATE BO_EU_PAL_FILE1 SET FILESTATE = '" + state + "' WHERE FILEID = '" + plId + "'";
|
||||
DBSql.update(sqlt);
|
||||
PALRepositoryModel model = PALRepositoryCache.getCache().get(plId);
|
||||
String taskId = createOutputReport(model, "7d3ca852-a0bd-42e6-80b1-3dcea6f55083", "admin", "", plId);
|
||||
System.err.println("重新生成手册:" + model.getName() + "--->taskId" + taskId);
|
||||
DBSql.update(
|
||||
"UPDATE BO_ACT_COE_PUBLISH_N SET TASKID='" + taskId + "'WHERE PUBLISHFILEID ='" + plId + "'");
|
||||
count += DBSql.update("UPDATE APP_ACT_COE_PAL_PUBLISH_LIST SET TASKID='" + taskId
|
||||
+ "'WHERE PALREPOSITORYID='" + plId + "'");
|
||||
} else {
|
||||
//SDK.getPALPublishAPI().publishPALRepository(publishInfo, publishList)
|
||||
}
|
||||
} else {
|
||||
String updataSql = "UPDATE APP_ACT_COE_PAL_REPOSITORY SET ISPUBLISH = '" + state + "' WHERE ID = '" + plId
|
||||
+ "'";
|
||||
count += DBSql.update(updataSql);
|
||||
String sqlt = "UPDATE BO_EU_PAL_FILE1 SET FILESTATE = '" + state + "' WHERE FILEID = '" + plId + "'";
|
||||
DBSql.update(sqlt);
|
||||
|
||||
}
|
||||
if (count > 0) {
|
||||
ro.put("result", "ok");
|
||||
} else {
|
||||
ro.put("result", "error");
|
||||
}
|
||||
return ro;
|
||||
}
|
||||
|
||||
private String createOutputReport(PALRepositoryModel model, String wsId, String userId, String teamId, String uuid) {
|
||||
String taskId = "";
|
||||
if (model.getMethodId().contains("process.")) {
|
||||
taskId = PALRepositoryQueryAPIManager.getInstance().createOutputReportPr(wsId, userId, teamId, uuid);
|
||||
JSONObject object = JSONObject.parseObject(taskId);
|
||||
if ("ok".equals(object.getString("result"))) {
|
||||
taskId = object.getJSONObject("data").getString("taskId");
|
||||
}
|
||||
} else if ("data.form".equals(model.getMethodId())) {
|
||||
taskId = PALRepositoryQueryAPIManager.getInstance().createOutputReportBd(wsId, userId, teamId, uuid);
|
||||
JSONObject object = JSONObject.parseObject(taskId);
|
||||
if ("ok".equals(object.getString("result"))) {
|
||||
taskId = object.getJSONObject("data").getString("taskId");
|
||||
}
|
||||
} else if ("control.policy".equals(model.getMethodId())) {
|
||||
taskId = PALRepositoryQueryAPIManager.getInstance().createOutputReportZd(wsId, userId, teamId, uuid);
|
||||
JSONObject object = JSONObject.parseObject(taskId);
|
||||
if ("ok".equals(object.getString("result"))) {
|
||||
taskId = object.getJSONObject("data").getString("taskId");
|
||||
}
|
||||
}
|
||||
return taskId;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user