发布流程代码整理合并

This commit is contained in:
lihongyu 2022-11-07 10:15:02 +08:00
parent 4a6c7513a5
commit 646a4984fc
8 changed files with 6 additions and 1303 deletions

View File

@ -1,276 +0,0 @@
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.PALRepositoryAPIManager;
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.CoeProcessLevelDaoFacotory;
import com.actionsoft.apps.coe.pal.pal.repository.dao.PALRepositoryPropertyDao;
import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel;
import com.actionsoft.apps.coe.pal.pal.repository.util.CoeProcessLevelUtil;
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.bpms.util.UtilString;
import com.actionsoft.sdk.local.SDK;
import com.alibaba.fastjson.JSONArray;
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);
CARA1();
/*
* System.err.println("本次共新增手册:" + createNum); System.err.println("本次共更新手册:" +
* updateNum);
*/
}
// 批量移动文件架构
public void CARA3() {
System.err.println("开始移动文件=======>");
String sql = "SELECT * FROM BO_EU_PAL_FRAMEWORK_TOOL where RESULT not like '%成功%'";
List<RowMap> maps = DBSql.getMaps(sql);
for (RowMap rowMap : maps) {
String plName = rowMap.getString("PALNAME");
String error = rowMap.getString("ERRORFRAMEWORK");
String right = rowMap.getString("CORRECTFRAMEWORK");
System.err.println("错误架构名=======>"+error);
System.err.println("正确架构名=======>"+right);
// 获取导入表的错误架构id
String sqlerror = "SELECT ID FROM App_Act_Coe_Pal_Repository WHERE PLNAME ='" + error + "'";
String maperrorId = DBSql.getString(sqlerror);
// 获取导入表的正确架构id
String sqlright = "SELECT ID FROM App_Act_Coe_Pal_Repository WHERE PLNAME ='" + right + "'";
String maprightId = DBSql.getString(sqlright);
// 获取文件id和父架构ID33
String sqlS = "SELECT ID,PLPARENTID FROM App_Act_Coe_Pal_Repository WHERE PLNAME ='" + plName + "'";
RowMap map = DBSql.getMap(sqlS);
String uuid = map.getString("ID");
String prId = map.getString("PLPARENTID");
// 获取文件库父架构名称
String sqlT = "SELECT PLNAME FROM App_Act_Coe_Pal_Repository WHERE ID ='" + prId + "'";
String prName = DBSql.getString(sqlT);
String prName3 = DBSql.getString(sqlT);
String substring = right.substring(right.lastIndexOf(".") + 2);
// 判断是否是导入表的错误架构
//
System.err.println("当前文件架构名=======>"+prName);
if (error.equals(prName)) {
String update = "UPDATE App_Act_Coe_Pal_Repository SET PLPARENTID = '" + maprightId + "' WHERE ID ='"
+ uuid + "'";
int update2 = DBSql.update(update);
PALRepositoryPropertyDao propertyDao = new PALRepositoryPropertyDao();
String name1 = right.substring(right.lastIndexOf(".") + 2).trim();
// 设置三级架构名称
propertyDao.updatePropertyByPropertyId(uuid, "Process_Architecture_L3", name1);
// 设置二级架构名称
String sql2 = "SELECT PLPARENTID FROM App_Act_Coe_Pal_Repository WHERE ID ='" + maprightId + "'";
String prd2 = DBSql.getString(sql2);
String sqlp2 = "SELECT PLNAME,ID FROM App_Act_Coe_Pal_Repository WHERE ID ='" + prd2 + "'";
RowMap map2 = DBSql.getMap(sqlp2);
if (map2 != null) {
String uuid2 = map2.getString("ID");
String plName2 = map2.getString("PLNAME");
String name2 = plName2.substring(plName2.lastIndexOf(".") + 2).trim();
propertyDao.updatePropertyByPropertyId(uuid, "Process_Architecture_L2", name2);
// 设置一级架构名称
String sql1 = "SELECT PLPARENTID FROM App_Act_Coe_Pal_Repository WHERE ID ='" + uuid2 + "'";
String prd1 = DBSql.getString(sql1);
String sqlp1 = "SELECT PLNAME,ID FROM App_Act_Coe_Pal_Repository WHERE ID ='" + prd1 + "'";
RowMap map1 = DBSql.getMap(sqlp1);
if (map1 != null) {
String uuid1 = map1.getString("ID");
String plName1 = map1.getString("PLNAME");
String name3 = plName1.substring(plName1.lastIndexOf(".") + 2).trim();
propertyDao.updatePropertyByPropertyId(uuid, "Process_Architecture_L1", name3);
} else {
propertyDao.updatePropertyByPropertyId(uuid, "Process_Architecture_L3", "/");
propertyDao.updatePropertyByPropertyId(uuid, "Process_Architecture_L1", name2);
propertyDao.updatePropertyByPropertyId(uuid, "Process_Architecture_L2", name1);
}
} else {
propertyDao.updatePropertyByPropertyId(uuid, "Process_Architecture_L2", "/");
propertyDao.updatePropertyByPropertyId(uuid, "Process_Architecture_L3", "/");
propertyDao.updatePropertyByPropertyId(uuid, "Process_Architecture_L1", name1);
}
String result = "文件从【"+error+"】移动到【"+right+"】成功!";
String updateSql = "UPDATE BO_EU_PAL_FRAMEWORK_TOOL SET RESULT = '"+result+"',PAID = '"+uuid+"' WHERE PALNAME = '"+plName+"'";
DBSql.update(updateSql);
}else {
String updateSql = "UPDATE BO_EU_PAL_FRAMEWORK_TOOL SET RESULT ='文件移动失败,架构不匹配!' WHERE PALNAME = '"+plName+"'";
DBSql.update(updateSql);
}
}
}
public static String getQuantity(String regular){
int index = 0;
for (int i = 0; i < regular.length(); i++) {
char c = regular.charAt(i);
if (Character.isDigit(c)) {
if (i == regular.length() - 1) {
index = i + 1;
} else {
index = i;
}
continue;
} else {
index = i;
break;
}
}
return regular.substring(0, index);
}
public void CARA2() {
String sql1 = "SELECT PUBLISHFILEID FROM BO_ACT_COE_PUBLISH_N WHERE PUBLISHDESC = '批量发布'";
List<RowMap> maps = DBSql.getMaps(sql1);
for (RowMap rowMap : maps) {
String uuid = rowMap.getString("PUBLISHFILEID");
String sql2 = "SELECT PUBLISHFILEID FROM BO_ACT_COE_PUBLISH_N WHERE PUBLISHFILEID = '"+uuid+"' AND PUBLISHDESC ='待删除'";
String uuid2 = DBSql.getString(sql2);
if(UtilString.isNotEmpty(uuid2)) {
String sql = "DELETE FROM BO_ACT_COE_PUBLISH_N WHERE PUBLISHFILEID = '"+uuid+"' AND PUBLISHDESC ='待删除'";
int update = DBSql.update(sql1);
System.out.println("删除N表=======>"+update);
String sqls = "SELECT PLVERSIONID FROM App_Act_Coe_Pal_Repository WHERE ID = '"+uuid+"'";
String versionId = DBSql.getString(sqls);
String sqlt = "DELETE FROM app_act_coe_pal_publish_list WHERE PALREPOSITORYID = '"+versionId+"' ";
int update2 = DBSql.update(sqlt);
System.out.println("删除List表=======>"+update2);
}
}
}
//批量发布文件
public void CARA1() {
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 != '手册转换成功!'";
String sql = "SELECT PLNAME FROM BO_EU_PAL_PLFB ";
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) {
String plname = rowMap.getString("PLNAME");
if(UtilString.isNotEmpty(plname)) {
PALRepositoryModel repositoryByName = getRepositoryByName("7d3ca852-a0bd-42e6-80b1-3dcea6f55083", plname);
//String sqls = "SELECT ID FROM APP_ACT_COE_PAL_REPOSITORY WHERE PLNAME = '"+plname+"'";
//System.err.println("======sqls======="+sqls);
if(repositoryByName!=null) {
subBo = new BO();
//String uuid = rowMap.getString("PLID");
String uuid = repositoryByName.getId();
subBo.set("PUBLISTHTYPE", "N");
subBo.set("PUBLISHFILENAME", 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);
}
/**
* 创建手册
* @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;
}
public static PALRepositoryModel getRepositoryByName(String wsId, String repositoryName) {
List<PALRepositoryModel> palRepositoryModels = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getAllCoeProcessLevelByWsId(wsId);
for (PALRepositoryModel palRepositoryModel : palRepositoryModels) {
if (palRepositoryModel.getName().equals(repositoryName)&&palRepositoryModel.isUse()) {
return palRepositoryModel;
}
}
return null;
}
}

View File

@ -1,253 +0,0 @@
package com.actionsoft.apps.coe.pal.publisher.extend;
import java.util.List;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import com.actionsoft.apps.coe.pal.pal.manage.publish.cache.PublishHistoryCache;
import com.actionsoft.apps.coe.pal.pal.manage.publish.cache.PublishUserGroupCache;
import com.actionsoft.apps.coe.pal.pal.manage.publish.cache.PublishUserGroupPermCache;
import com.actionsoft.apps.coe.pal.pal.manage.publish.cache.PublishUserGroupRoleCache;
import com.actionsoft.apps.coe.pal.pal.repository.cache.CoeProcessLevelCorrelateCache;
import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryAttributeCache;
import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache;
import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryPropertyCache;
import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryRemoveCache;
import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryShapeAttributeCache;
import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryShapeConfigCache;
import com.actionsoft.apps.coe.pal.pal.repository.designer.cache.CoeDesignerImageCache;
import com.actionsoft.apps.coe.pal.pal.repository.designer.cache.CoeDesignerShapeCache;
import com.actionsoft.apps.coe.pal.pal.repository.designer.cache.PALDesignerFileCache;
import com.actionsoft.apps.coe.pal.pal.repository.designer.cache.PALDesignerFileDragModelCache;
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.relation.cache.DesignerShapeRelationCache;
import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel;
import com.actionsoft.apps.coe.pal.teamwork.cache.TeamMemberPermCache;
import com.actionsoft.apps.coe.pal.teamwork.cache.TeamPermCache;
import com.actionsoft.bpms.bo.engine.BO;
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.bpms.util.UtilString;
import com.actionsoft.sdk.local.SDK;
import com.alibaba.fastjson.JSONObject;
import com.sun.org.apache.xalan.internal.xsltc.compiler.sym;
/**
* 空模型改为发布态文件发布状态
* @author Administrator
*
*/
public class CreateOutputReportJob2 implements IJob {
@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
count2();
}
public void count2() {
int count = 0;
String sqls = "DELETE FROM BO_EU__PAL_NULL_L";
DBSql.update(sqls);
String sql = "select ID from App_Act_Coe_Pal_Repository ";
// String sql = "select ID from App_Act_Coe_Pal_Repository where PLNAME =
// '测试文件测'";
List<RowMap> maps = DBSql.getMaps(sql);
for (RowMap rowMap : maps) {
BO bo = new BO();
String id = rowMap.getString("ID");
PALRepositoryModel model = PALRepositoryCache.getCache().get(id);
if (model != null) {
bo.set("PLNAME", model.getName());
PALRepositoryModel prmodel = PALRepositoryCache.getCache().get(model.getParentId());
if (prmodel != null) {
bo.set("FRAMEWORK", prmodel.getName());
}
bo.set("VERSION", model.getVersion());
if(model.isPublish()) {
bo.set("ISPUBLISH","已发布");
}else {
bo.set("ISPUBLISH","未发布");
}
String methodId = model.getMethodId();
if (methodId.contains("data")) {
bo.set("TYPE", "表单");
}else if (methodId.contains("control.policy")) {
bo.set("TYPE", "制度");
}else if (methodId.contains("process")) {
bo.set("TYPE", "流程");
}
CoeDesignerAPIManager instance = CoeDesignerAPIManager.getInstance();
if (instance != null) {
BaseModel defineModel = null;
try {
defineModel = instance.getDefinition(id, 0);
} catch (Exception e) {
bo.set("ERRORTYPE", "1");
count += SDK.getBOAPI().createDataBO("BO_EU_PAL_ERROR_FILE", bo, UserContext.fromUID("admin"));
}
if (null == defineModel) {
bo.set("ERRORTYPE", "2");
count += SDK.getBOAPI().createDataBO("BO_EU_PAL_ERROR_FILE", bo, UserContext.fromUID("admin"));
} else {
try {
String define = defineModel.getDefinition();
JSONObject definition = JSONObject.parseObject(define);
} catch (Exception e) {
bo.set("ERRORTYPE", "错误文件");
count += SDK.getBOAPI().createDataBO("BO_EU_PAL_ERROR_FILE", bo, UserContext.fromUID("admin"));
}
}
}
}
}
}
public void count1() {
int updateNum = 0;
int createNum = 0;
String sqls = "DELETE FROM BO_EU__PAL_NULL_L";
DBSql.update(sqls);
String sqls2 = "DELETE FROM BO_EU_PAL_FILE_NULL_L";
DBSql.update(sqls2);
// String sql = "select ID from App_Act_Coe_Pal_Repository where PUBLISHDATE <
// to_date('2022/10/5 9:46:18 ','yyyy-mm-dd hh24:mi:ss')";
// String sql = "select ID from App_Act_Coe_Pal_Repository where PUBLISHDATE >
// '2022/7/5 9:46:18'";
String sql = "select ID from App_Act_Coe_Pal_Repository ";
// String sql = "select ID from App_Act_Coe_Pal_Repository where PLNAME =
// '测试文件测'";
List<RowMap> maps = DBSql.getMaps(sql);
for (RowMap rowMap : maps) {
String id = rowMap.getString("ID");
PALRepositoryModel model = PALRepositoryCache.getCache().get(id);
// 查询对应绩效模型中数据模型进行填充数据
/*
* String s = "SELECT * FROM BO_ACT_BATCH_PUBLIS_N WHERE PLNAME = '" +
* model.getName() + "'"; if (UtilString.isNotEmpty(DBSql.getString(s))) {
* String updataSql =
* "UPDATE App_Act_Coe_Pal_Repository SET ISPUBLISH = 0 , PUBLISHDATE = null WHERE ID = '"
* + id + "'"; updateNum += DBSql.update(updataSql);
* System.err.println("刷新为设计的模型:" + model.getName());
*
* }
*/
if (model != null) {
CoeDesignerAPIManager instance = CoeDesignerAPIManager.getInstance();
if (instance != null) {
BaseModel defineModel = null;
try {
defineModel = instance.getDefinition(id, 0);
} catch (Exception e) {
System.out.println("有问题的模型=====>" + model.getName());
}
if (null == defineModel) {
} else {
String define = defineModel.getDefinition();
JSONObject definition = JSONObject.parseObject(define);
JSONObject elements = definition.getJSONObject("elements");
if (elements.size() == 0) {
BO bo = new BO();
BO bo2 = new BO();
bo.set("PLNAME", model.getName());
bo2.set("PLNAME", model.getName());
PALRepositoryModel prmodel = PALRepositoryCache.getCache().get(model.getParentId());
if (prmodel != null) {
bo.set("FRAMEWORK", prmodel.getName());
bo2.set("FRAMEWORK", prmodel.getName());
}
bo.set("VERSION", model.getVersion());
bo2.set("VERSION", model.getVersion());
if(model.isPublish()) {
bo.set("ISPUBLISH","已发布");
bo2.set("ISPUBLISH","已发布");
}else {
bo.set("ISPUBLISH","未发布");
bo2.set("ISPUBLISH","未发布");
}
String methodId = model.getMethodId();
if (methodId.contains("data")) {
bo.set("TYPE", "表单");
createNum += SDK.getBOAPI().createDataBO("BO_EU__PAL_NULL_L", bo, UserContext.fromUID("admin"));
String sqlt ="UPDATE BO_EU_PAL_FILE1 SET FILESTATE = 0 WHERE PLNAME = '"+model.getName()+"'";
int a = DBSql.update(sqlt);
if(a!=0) {
bo2.set("TYPE", "表单");
System.err.println("刷新为设计的模型:" +model.getName());
updateNum += SDK.getBOAPI().createDataBO("BO_EU_PAL_FILE_NULL_L", bo2, UserContext.fromUID("admin"));
}
} else if (methodId.contains("control.policy")) {
bo.set("TYPE", "制度");
createNum += SDK.getBOAPI().createDataBO("BO_EU__PAL_NULL_L", bo, UserContext.fromUID("admin"));
String sqlt ="UPDATE BO_EU_PAL_FILE1 SET FILESTATE = 0 WHERE PLNAME = '"+model.getName()+"'";
int a = DBSql.update(sqlt);
if(a!=0) {
bo2.set("TYPE", "制度");
System.err.println("刷新为设计的模型:" +model.getName());
updateNum += SDK.getBOAPI().createDataBO("BO_EU_PAL_FILE_NULL_L", bo2, UserContext.fromUID("admin"));
}
} else if (methodId.contains("process")) {
bo.set("TYPE", "流程");
createNum += SDK.getBOAPI().createDataBO("BO_EU__PAL_NULL_L", bo, UserContext.fromUID("admin"));
String sqlt ="UPDATE BO_EU_PAL_FILE1 SET FILESTATE = 0 WHERE PLNAME = '"+model.getName()+"'";
int a = DBSql.update(sqlt);
if(a!=0) {
bo2.set("TYPE", "流程");
System.err.println("刷新为设计的模型:" +model.getName());
updateNum += SDK.getBOAPI().createDataBO("BO_EU_PAL_FILE_NULL_L", bo2, UserContext.fromUID("admin"));
}
}
/*
* String updataSql =
* "UPDATE App_Act_Coe_Pal_Repository SET ISPUBLISH = 0 , PUBLISHDATE = null WHERE ID = '"
* + id + "'"; DBSql.update(updataSql);
*/
}
}
}
}
}
SDK.getLogAPI().consoleInfo("更新状态后刷新缓存开始===========>");
TeamPermCache.getCache().reload();
TeamMemberPermCache.getCache().reload();
PublishHistoryCache.getCache().reload();
PublishUserGroupCache.getCache().reload();
PublishUserGroupPermCache.getCache().reload();
PublishUserGroupRoleCache.getCache().reload();
PALDesignerFileCache.getCache().reload();
PALDesignerFileDragModelCache.getCache().reload();
PALRepositoryCache.getCache().reload();
PALRepositoryRemoveCache.getCache().reload();
CoeDesignerShapeCache.getCache().reload();
DesignerShapeRelationCache.getCache().reload();
PALRepositoryPropertyCache.getCache().reload();
PALRepositoryAttributeCache.getCache().reload();
PALRepositoryShapeConfigCache.getCache().reload();
PALRepositoryShapeAttributeCache.getCache().reload();
CoeProcessLevelCorrelateCache.getCache().reload();
CoeDesignerImageCache.getCache().reload();
SDK.getLogAPI().consoleInfo("更新状态后刷新缓存结束===========>");
System.err.println("更新文件表数量:" + updateNum);
System.err.println("本次共查询到的模型:" + createNum);
}
}

View File

@ -1,271 +0,0 @@
package com.actionsoft.apps.coe.pal.publisher.extend;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import com.actionsoft.apps.coe.pal.pal.repository.dao.PALRepositoryPropertyDao;
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.commons.mvc.view.ResponseObject;
import com.actionsoft.bpms.server.UserContext;
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.UUIDGener;
import com.actionsoft.bpms.util.UtilString;
import com.actionsoft.sdk.local.SDK;
import com.alibaba.fastjson.JSONObject;
import bsh.util.Util;
/*
* 新建流程
*/
@Controller
public class CreateProcessController {
@Mapping("com.awspaas.user.apps.xitongfankui.createProcess")
public JSONObject CheckUser(String sid,String processDefId) {
JSONObject result = new JSONObject();
UserContext uc = UserContext.fromSessionId(sid);
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
ProcessInstance processInst = SDK.getProcessAPI().createProcessInstance(processDefId, uc.getUID(), "流程管理平台问题反馈"+"-"+uc.getUserName()+"-"+df.format(new Date()));
TaskInstance taskInst = SDK.getProcessAPI().start(processInst).fetchActiveTasks().get(0);
String portalUrl = SDK.getPortalAPI().getPortalUrl();
String url = portalUrl + "/r/w?sid=" + uc.getSessionId()
+ "&cmd=CLIENT_BPM_FORM_MAIN_PAGE_OPEN&processInstId=" + processInst.getId() + "&taskInstId="
+ taskInst.getId() + "&openState=1&reloadedFile=1";
result.put("url",url);
return result;
}
// 批量移动文件架构
@Mapping("com.awspaas.user.apps.app.controller.movePalFile")
public ResponseObject move(String sid,String plname) {
ResponseObject ro = ResponseObject.newOkResponse();
System.err.println("开始移动文件=======>"+plname);
String sql = "SELECT * FROM BO_EU_PAL_FRAMEWORK_TOOL WHERE RESULT NOT LIKE '%成功%' ";
if(UtilString.isNotEmpty(plname)) {
sql = "SELECT * FROM BO_EU_PAL_FRAMEWORK_TOOL WHERE PALNAME ='"+plname+"'";
}
List<RowMap> maps = DBSql.getMaps(sql);
System.err.println("maps===>"+maps);
if(maps.size()>0) {
for (RowMap rowMap : maps) {
String plName = rowMap.getString("PALNAME");
String error = rowMap.getString("ERRORFRAMEWORK");
String right = rowMap.getString("CORRECTFRAMEWORK");
// 获取导入表的错误架构id
String sqlerror = "SELECT ID FROM App_Act_Coe_Pal_Repository WHERE PLNAME ='" + error + "'";
String maperrorId = DBSql.getString(sqlerror);
// 获取导入表的正确架构id
String sqlright = "SELECT ID FROM App_Act_Coe_Pal_Repository WHERE PLNAME ='" + right + "'";
String maprightId = DBSql.getString(sqlright);
// 获取文件id和父架构ID33
String sqlS = "SELECT ID,PLPARENTID FROM App_Act_Coe_Pal_Repository WHERE PLNAME ='" + plName + "'";
RowMap map = DBSql.getMap(sqlS);
String uuid = map.getString("ID");
String prId = map.getString("PLPARENTID");
// 获取文件库父架构名称
String sqlT = "SELECT PLNAME FROM App_Act_Coe_Pal_Repository WHERE ID ='" + prId + "'";
String prName = DBSql.getString(sqlT);
String prName3 = DBSql.getString(sqlT);
String substring = right.substring(right.lastIndexOf(".") + 2);
// 判断是否是导入表的错误架构
//
System.err.println("当前文件架构名=======>"+prName);
if (error.trim().equals(prName.trim())) {
String update = "UPDATE App_Act_Coe_Pal_Repository SET PLPARENTID = '" + maprightId + "' WHERE ID ='"
+ uuid + "'";
int update2 = DBSql.update(update);
PALRepositoryPropertyDao propertyDao = new PALRepositoryPropertyDao();
String name1 = right.substring(right.lastIndexOf(".") + 2).trim();
// 设置三级架构名称
propertyDao.updatePropertyByPropertyId(uuid, "Process_Architecture_L3", name1);
// 设置二级架构名称
String sql2 = "SELECT PLPARENTID FROM App_Act_Coe_Pal_Repository WHERE ID ='" + maprightId + "'";
String prd2 = DBSql.getString(sql2);
String sqlp2 = "SELECT PLNAME,ID FROM App_Act_Coe_Pal_Repository WHERE ID ='" + prd2 + "'";
RowMap map2 = DBSql.getMap(sqlp2);
if (map2 != null) {
String uuid2 = map2.getString("ID");
String plName2 = map2.getString("PLNAME");
String name2 = plName2.substring(plName2.lastIndexOf(".") + 2).trim();
propertyDao.updatePropertyByPropertyId(uuid, "Process_Architecture_L2", name2);
// 设置一级架构名称
String sql1 = "SELECT PLPARENTID FROM App_Act_Coe_Pal_Repository WHERE ID ='" + uuid2 + "'";
String prd1 = DBSql.getString(sql1);
String sqlp1 = "SELECT PLNAME,ID FROM App_Act_Coe_Pal_Repository WHERE ID ='" + prd1 + "'";
RowMap map1 = DBSql.getMap(sqlp1);
if (map1 != null) {
String uuid1 = map1.getString("ID");
String plName1 = map1.getString("PLNAME");
String name3 = plName1.substring(plName1.lastIndexOf(".") + 2).trim();
propertyDao.updatePropertyByPropertyId(uuid, "Process_Architecture_L1", name3);
} else {
propertyDao.updatePropertyByPropertyId(uuid, "Process_Architecture_L3", "/");
propertyDao.updatePropertyByPropertyId(uuid, "Process_Architecture_L1", name2);
propertyDao.updatePropertyByPropertyId(uuid, "Process_Architecture_L2", name1);
}
} else {
propertyDao.updatePropertyByPropertyId(uuid, "Process_Architecture_L2", "/");
propertyDao.updatePropertyByPropertyId(uuid, "Process_Architecture_L3", "/");
propertyDao.updatePropertyByPropertyId(uuid, "Process_Architecture_L1", name1);
}
ro.put("result", "ok");
String result = "文件从【"+error+"】移动到【"+right+"】成功!";
String updateSql = "UPDATE BO_EU_PAL_FRAMEWORK_TOOL SET RESULT = '"+result+"',PAID = '"+uuid+"' WHERE PALNAME = '"+plName+"'";
DBSql.update(updateSql);
}else {
ro.put("result", "error");
String updateSql = "UPDATE BO_EU_PAL_FRAMEWORK_TOOL SET RESULT ='文件移动失败,架构不匹配!' WHERE PALNAME = '"+plName+"'";
DBSql.update(updateSql);
}
}
}
return ro;
}
//批量导入权限
@Mapping("com.awspaas.user.apps.xitongfankui.createPrem")
public JSONObject createPrem(String sid,String processDefId) {
JSONObject result = new JSONObject();
UserContext uc = UserContext.fromSessionId(sid);
List<BO> list = SDK.getBOAPI().query("BO_ACT_PUBLISH_SCOPE_IMPORT").list();
for (BO bos : list) {
String palName = bos.getString("PALNAME");
String orgPerm = bos.getString("ORGPERM");
String postPerm = bos.getString("POSTPERM");
String levelPrem = bos.getString("LEVELPERM");
String sendScope = bos.getString("SEND_SCOP");
StringBuffer orgSuccess = new StringBuffer();
StringBuffer orgFail = new StringBuffer();
StringBuffer orgPermBuf = new StringBuffer();
String[] orgPermArr = orgPerm.split("");
for (String str : orgPermArr) {
String dsql = "SELECT ID FROM ORGDEPARTMENT WHERE DEPARTMENTNAME = '"+str+"'";
String depId = DBSql.getString(dsql);
if(UtilString.isNotEmpty(depId)) {
if(str.equals(orgPermArr[orgPermArr.length-1])) {
orgPermBuf.append(depId);
}else {
orgPermBuf.append(depId).append(",");
}
}else {
orgFail.append(str).append(",");
}
}
bos.set("ORGFAIL", orgFail);
StringBuffer postFail = new StringBuffer();
StringBuffer postPermBuf = new StringBuffer();
String[] postPermArr = postPerm.split("");
for (String str : postPermArr) {
String postNbrSql = "SELECT POSITION_NBR FROM BO_EU_ORG_POSTS WHERE DESCR = '"+str+"'";
String postNbr = DBSql.getString(postNbrSql);
if(UtilString.isNotEmpty(postNbr)) {
if(str.equals(postPermArr[postPermArr.length-1])) {
postPermBuf.append(postNbr);
}else {
postPermBuf.append(postNbr).append(",");
}
}else {
postFail.append(str).append(",");
}
}
bos.set("POSTFAIL", postFail);
StringBuffer levelFail = new StringBuffer();
StringBuffer levelPremArrBuf = new StringBuffer();
String[] levelPremArr = levelPrem.split("");
for (String str : levelPremArr) {
String levelSql = "SELECT RANKSUB_NO FROM BO_ACT_PAL_LEVEL_SUB WHERE RANKSUB_NAME = '"+str+"'";
String leveNo = DBSql.getString(levelSql);
if(UtilString.isNotEmpty(leveNo)) {
if(str.equals(levelPremArr[levelPremArr.length-1])) {
levelPremArrBuf.append(str);
}else {
levelPremArrBuf.append(str).append(",");
}
}else {
levelFail.append(str).append(",");
}
}
bos.set("LEVELFAIL", postFail);
if("1".equals(sendScope)||orgPermBuf.length()!=0||postPermBuf.length()!=0||levelPremArrBuf.length()!=0) {
List<BO> premlist = new ArrayList<>();
String sqls = "SELECT * FROM APP_ACT_COE_PAL_REPOSITORY WHERE PLNAME = '"+palName+"'";
List<RowMap> maps = DBSql.getMaps(sqls);
Set<String> removeIds = new HashSet<>();
for (RowMap rowMap : maps) {
List<BO> delList = SDK.getBOAPI().query("BO_ACT_PUBLISH_PERM_SCOPE2").addQuery("PALVERSIONID=", rowMap.getString("PALVERSIONID")).list();
if (delList != null && delList.size() > 0) {
for (BO del : delList) {
removeIds.add(del.getId());
}
}
}
for (String removeId : removeIds) {
SDK.getBOAPI().remove("BO_ACT_PUBLISH_PERM_SCOPE2", removeId);
}
for (RowMap rowMap : maps) {
BO bo = new BO();
bo.set("PERMID", UUIDGener.getUUID());
bo.set("WSID", rowMap.getString("WSID"));
bo.set("PALVERSIONID", rowMap.getString("PLVERSIONID"));
bo.set("PALNAME", rowMap.getString("PLNAME"));
bo.set("PERMTYPE", sendScope);
bo.set("ORGPERM", orgPermBuf);
bo.set("POSTPERM", postPermBuf);
bo.set("LEVELPERM",levelPremArrBuf);
premlist.add(bo);
}
if (premlist.size() > 0) {
bos.set("RESULT", "导入成功!");
SDK.getBOAPI().update("BO_ACT_PUBLISH_SCOPE_IMPORT", bos);
SDK.getBOAPI().createDataBO("BO_ACT_PUBLISH_PERM_SCOPE2", premlist, uc);
SDK.getLogAPI().consoleInfo("[发布范围权限信息保存至范围权限表]更新成功");
}
}else {
bos.set("RESULT", "导入失败!");
SDK.getBOAPI().update("BO_ACT_PUBLISH_SCOPE_IMPORT", bos);
}
}
return result;
}
}

View File

@ -1,239 +0,0 @@
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 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.resource.AppContext;
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;
/**
* 模型附件去重
* @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)) {
try {
outputReportPreview(fromSessionId, session, taskId, plId);
} catch (Exception e) {
// TODO: handle exception
}
}
/*
* 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"));
}
}
}
}
}
}
}

View File

@ -1,52 +0,0 @@
package com.actionsoft.apps.coe.pal.publisher.extend;
import java.sql.Connection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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.server.bind.annotation.Controller;
import com.actionsoft.bpms.server.bind.annotation.Mapping;
import com.actionsoft.bpms.util.DBSql;
import com.actionsoft.sdk.local.SDK;
/**
* 表单加载前获取内部校对人和流程经理
* @author lihongyu
*
*/
@Controller
public class PublisherGetManagerController {
private static Logger logger = LoggerFactory.getLogger(PublisherGetManagerController.class);
// 修改文件发布状态
@Mapping("com.actionsoft.apps.coe.pal.publisher.PublisherGetManagerController")
public ResponseObject checkIsSend(String sid) {
ResponseObject ro = ResponseObject.newOkResponse();
//根据部门名称 和单位 计算出 内部校对人 和流程经理
UserContext me = UserContext.fromSessionId(sid);
String departmentId = me.getUserModel().getDepartmentId();
String allpath = SDK.getORGAPI().getDepartmentById(departmentId).getPathNameOfCache();
String[] patharr = allpath.split("/");
StringBuffer sb = new StringBuffer();
for (String str : patharr) {
sb.append("'").append(str).append("'").append(",");
}
String substring = sb.substring(0, sb.length()-1);
// 可以为boData中的字段进行赋值
Connection open = DBSql.open();
RowMap data = DBSql.getMap(open,"select DEAPRTMNUM,PROCESSMNUMBER from BO_ACT_PROCESSMANAGER where ORGDEPART in ("+substring+")");
if(null==data) {
ro.put("result","error");
}else {
ro.put("result","ok");
ro.put("DEAPRTMNUM",data.getString("DEAPRTMNUM"));
ro.put("PROCESSMNUMBER",data.getString("PROCESSMNUMBER"));
}
return ro;
}
}

View File

@ -1,90 +0,0 @@
package com.actionsoft.apps.coe.pal.publisher.extend;
import java.util.List;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache;
import com.actionsoft.apps.coe.pal.pal.repository.dao.CoeProcessLevelDaoFacotory;
import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel;
import com.actionsoft.bpms.bo.engine.BO;
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;
/**
* 模型附件去重
* @author Administrator
*
*/
public class SelectPremJob implements IJob {
@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
List<PALRepositoryModel> palRepositoryModels = CoeProcessLevelDaoFacotory.createCoeProcessLevel()
.getAllCoeProcessLevelByWsId("7d3ca852-a0bd-42e6-80b1-3dcea6f55083");
for (PALRepositoryModel palRepositoryModel : palRepositoryModels) {
String methodId = palRepositoryModel.getMethodId();
if (!palRepositoryModel.getName().contains("测试") && palRepositoryModel.isUse()
&& ("process.epc".equals(methodId) || "control.policy".equals(methodId)
|| "data.form".equals(methodId) || "process.flowchart".equals(methodId))) {
String versionId = palRepositoryModel.getVersionId();
String sql = "SELECT * FROM BO_ACT_PUBLISH_PERM_SCOPE WHERE PALVERSIONID ='" + versionId + "'";
RowMap map = DBSql.getMap(sql);
if (map == null) {
BO bo = new BO();
bo.set("PALVERSIONID", versionId);
bo.set("PALNAME", palRepositoryModel.getName());
int level = palRepositoryModel.getLevel();
PALRepositoryModel prmodel = PALRepositoryCache.getCache().get(palRepositoryModel.getParentId());
if (prmodel != null) {
String name = prmodel.getName();
if (level == 2 || level == 5 || level == 6) {
if (name.contains("测试") || name.contains("练习")) {
continue;
}
} else if (level == 3) {
if (name.contains("测试") || name.contains("Test") || name.contains("培训")) {
continue;
}
} else if (level == 4) {
if (name.contains("测试") || name.contains("Test")) {
continue;
}
}
}
if (prmodel != null) {
bo.set("FRNAME", prmodel.getName());
}
bo.set("PALVERSIONID", versionId);
if ("process.epc".equals(methodId)) {
bo.set("FILETYPE", "流程模型");
} else if ("control.policy".equals(methodId)) {
bo.set("FILETYPE", "制度模型");
} else if ("data.form".equals(methodId)) {
bo.set("FILETYPE", "表单模型");
} else if ("process.flowchart".equals(methodId)) {
bo.set("FILETYPE", "泳道图模型");
}
if (palRepositoryModel.isPublish()) {
bo.set("IDPLUBSH", "已发布");
} else {
bo.set("IDPLUBSH", "未发布");
}
SDK.getBOAPI().createDataBO("BO_EU_PUBLISH_SCOPE_IMPORT", bo, UserContext.fromUID("admin"));
}
}
}
}
}

View File

@ -1,121 +0,0 @@
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.dao.PALRepository;
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);
//刷新预览加载的表
String sqlr = "UPDATE BO_EU_PAL_OUTPUTREPORT SET TASKID = '" + taskId + "' WHERE PLID = '" + plId + "'";
DBSql.update(sqlr);
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 {
PALRepository repositoryDao = new PALRepository();
//修改流程文件的发布属性和发布时间
repositoryDao.updatePublishStatusAndDate("N",plId, null, null);
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) {
SDK.getLogAPI().consoleInfo("更新状态后刷新缓存开始===========>");
PALRepositoryCache.getCache().reload();
/*
* TeamPermCache.getCache().reload(); TeamMemberPermCache.getCache().reload();
* PublishHistoryCache.getCache().reload();
* PublishUserGroupCache.getCache().reload();
* PublishUserGroupPermCache.getCache().reload();
* PublishUserGroupRoleCache.getCache().reload();
* PALDesignerFileCache.getCache().reload();
* PALDesignerFileDragModelCache.getCache().reload();
* PALRepositoryRemoveCache.getCache().reload();
* CoeDesignerShapeCache.getCache().reload();
* DesignerShapeRelationCache.getCache().reload();
* PALRepositoryPropertyCache.getCache().reload();
* PALRepositoryAttributeCache.getCache().reload();
* PALRepositoryShapeConfigCache.getCache().reload();
* PALRepositoryShapeAttributeCache.getCache().reload();
* CoeProcessLevelCorrelateCache.getCache().reload();
* CoeDesignerImageCache.getCache().reload();
*/
SDK.getLogAPI().consoleInfo("更新状态后刷新缓存结束===========>");
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;
}
}

View File

@ -35,6 +35,7 @@ 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.bpmn.engine.model.run.delegate.TaskInstance;
import com.actionsoft.bpms.commons.database.RowMap;
import com.actionsoft.bpms.commons.login.constant.LoginConst;
import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
@ -233,6 +234,10 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
}
}
long endTimes = System.currentTimeMillis();
//文件发布成功回执流程
ProcessInstance processInst = SDK.getProcessAPI().createProcessInstance("obj_b4700f89a7a144c086d047de0cfe9531", "admin", bo_act_coe_publish1.getString("PROCESS_TITLE")+"成功发布回执单");
TaskInstance taskInst = SDK.getProcessAPI().start(processInst).fetchActiveTasks().get(0);
SDK.getTaskAPI().completeTask(taskInst.getId(), "admin");
//存入日志
createReadLog(processExecutionContext, jsonObject, sendList, startTime,endTimes);
System.err.println(instanceById.getTitle() + "推送OA待阅执行完毕====>" + "用时:"+(endTimes-startTime)/1000/60+"分钟");
@ -1021,7 +1026,7 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
bo_Read_log.set("STARTTIMES", startTime);
bo_Read_log.set("ENDTIMES", endTimes);
bo_Read_log.set("TIMECOUNT", (endTimes-startTime)/1000/60+"分钟");
SDK.getBOAPI().createDataBO("BO_EU_PAL_READ_LOG", bo_Read_log, processExecutionContext.getUserContext());
SDK.getBOAPI().createDataBO("BO_EU_PAL_PULBISH_SUCCESS", bo_Read_log, processExecutionContext.getUserContext());
}