866 lines
39 KiB
Java
866 lines
39 KiB
Java
package com.awspaas.user.apps.app.controller;
|
||
|
||
import com.actionsoft.apps.coe.pal.pal.output.constant.OutputConst;
|
||
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.dao.CoeProcessLevelDaoFacotory;
|
||
import com.actionsoft.apps.coe.pal.pal.repository.upfile.model.UpfileModel;
|
||
import com.actionsoft.apps.coe.pal.pal.repository.upfile.web.UpfileWeb;
|
||
import com.actionsoft.apps.coe.pal.system.util.StringUtil;
|
||
import com.actionsoft.apps.resource.plugin.profile.DCPluginProfile;
|
||
import com.actionsoft.bpms.bo.engine.BO;
|
||
import com.actionsoft.bpms.bpmn.engine.core.delegate.ProcessExecutionContext;
|
||
import com.actionsoft.bpms.bpmn.engine.model.run.delegate.ProcessInstance;
|
||
import com.actionsoft.bpms.commons.database.RowMap;
|
||
import com.actionsoft.bpms.commons.database.RowMapper;
|
||
import com.actionsoft.bpms.commons.login.constant.LoginConst;
|
||
import com.actionsoft.bpms.org.model.DepartmentModel;
|
||
import com.actionsoft.bpms.server.SSOUtil;
|
||
import com.actionsoft.bpms.server.UserContext;
|
||
import com.actionsoft.bpms.server.fs.DCContext;
|
||
import com.actionsoft.bpms.util.UUIDGener;
|
||
import com.actionsoft.exception.AWSException;
|
||
import com.actionsoft.sdk.local.api.AppAPI;
|
||
import com.actionsoft.sdk.local.api.BOQueryAPI;
|
||
import com.alibaba.fastjson.JSONArray;
|
||
import com.awspaas.user.apps.app.util.RepositoryAttribute;
|
||
import org.apache.commons.lang.StringUtils;
|
||
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;
|
||
|
||
import java.sql.ResultSet;
|
||
import java.sql.SQLException;
|
||
import java.text.SimpleDateFormat;
|
||
import java.util.*;
|
||
|
||
/**
|
||
* 修改文件状态
|
||
* @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(UserContext me , String sid, String plIds, String state, String type) {
|
||
System.err.println("修改文件状态========>" + plIds + "/" + state + "/" + type);
|
||
ResponseObject ro = ResponseObject.newOkResponse();
|
||
int count = 0;
|
||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||
String[] plIdList = plIds.split(",");
|
||
|
||
for (String plId : plIdList){
|
||
|
||
String date = simpleDateFormat.format(new Date());
|
||
if ("1".equals(type)) {
|
||
|
||
//修改发布状态
|
||
String updataSql = "UPDATE APP_ACT_COE_PAL_REPOSITORY SET ISPUBLISH = '" + state + "',MODIFYDATE = TO_DATE('"+date+"','YY-MM-DD HH24:MI:SS') WHERE ID = '" + plId
|
||
+ "'";
|
||
DBSql.update("UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT5 = '"+state+"',MODIFYDATE = TO_DATE('"+date+"','YY-MM-DD HH24:MI:SS') WHERE ID = '"+plId+"'");
|
||
count = DBSql.update(updataSql);
|
||
String sqlt = "UPDATE BO_EU_PAL_FILE1 SET FILESTATE = '" + state + "' WHERE FILEID = '" + plId + "'";
|
||
DBSql.update(sqlt);
|
||
/*
|
||
String id = DBSql.getString("SELECT ID FROM APP_ACT_COE_PAL_PUBLISH_LIST WHERE PALREPOSITORYID='" + plId + "'");
|
||
* if (UtilString.isNotEmpty(id)) { PALRepositoryModel model =
|
||
* PALRepositoryCache.getCache().get(plId); if
|
||
* ("control.policy".equals(model.getMethodId()) ||
|
||
* "process.flowchart".equals(model.getMethodId()) ||
|
||
* "data.form".equals(model.getMethodId()) ||
|
||
* "process.epc".equals(model.getMethodId())) { 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 + "'"); } }
|
||
*/
|
||
|
||
PALRepositoryModel plModel = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(plId);
|
||
if (plModel != null) {
|
||
PALRepositoryCache.getCache().put(plId, plModel);
|
||
}
|
||
SDK.getLogAPI().consoleInfo("更新状态后刷新缓存结束===========>");
|
||
if(Integer.valueOf(state) == 1){
|
||
UpdateDept(plModel,plId);
|
||
createPermScopeData(plId , me);
|
||
SDK.getLogAPI().consoleInfo("修改为发布状态后同步权限数据到权限阅览成功===========>");
|
||
}
|
||
|
||
createFile(plId,me);
|
||
|
||
} else if ("2".equals(type)) {
|
||
// 修改流程文件的审批状态
|
||
String updataSql = "UPDATE APP_ACT_COE_PAL_REPOSITORY SET ISAPPROVAL = '" + state + "',MODIFYDATE =TO_DATE('"+date+"','YY-MM-DD HH24:MI:SS') WHERE ID = '" + plId
|
||
+ "'";
|
||
System.err.println("审批改为设计=======>" + updataSql);
|
||
count = DBSql.update(updataSql);
|
||
|
||
PALRepositoryModel plModel = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(plId);
|
||
if (plModel != null) {
|
||
PALRepositoryCache.getCache().put(plId, plModel);
|
||
}
|
||
SDK.getLogAPI().consoleInfo("更新状态后刷新缓存结束===========>");
|
||
} else if ("3".equals(type)) {
|
||
// 重新生成手册
|
||
PALRepositoryModel model = PALRepositoryCache.getCache().get(plId);
|
||
String taskId = createOutputReport(model, "7d3ca852-a0bd-42e6-80b1-3dcea6f55083", "admin", "", plId);
|
||
System.err.println("======手动生成手册id======"+taskId);
|
||
// 刷新预览加载的表
|
||
String sqlr = "UPDATE BO_EU_PAL_OUTPUTREPORT SET TASKID = '" + taskId + "' WHERE PLID = '" + plId + "'";
|
||
DBSql.update(sqlr);
|
||
String sql1 = "SELECT ID FROM BO_ACT_COE_PUBLISH_N WHERE PUBLISHFILEID = '" + plId + "'";
|
||
String sql2 = "SELECT ID FROM BO_ACT_COE_PUBLISH_C WHERE CHANGEDFILEIDNEW = '" + plId + "'";
|
||
if (UtilString.isNotEmpty(DBSql.getString(sql1))) {
|
||
count = DBSql.update(
|
||
"UPDATE BO_ACT_COE_PUBLISH_N SET TASKID='" + taskId + "'WHERE PUBLISHFILEID ='" + plId + "'");
|
||
}
|
||
if (UtilString.isNotEmpty(DBSql.getString(sql2))) {
|
||
count = DBSql.update(
|
||
"UPDATE BO_ACT_COE_PUBLISH_C SET TASKID='" + taskId + "'WHERE CHANGEDFILEIDNEW ='" + plId + "'");
|
||
}
|
||
if (count != 0) {
|
||
DBSql.update("UPDATE APP_ACT_COE_PAL_PUBLISH_LIST SET TASKID='" + taskId + "'WHERE PALREPOSITORYID='"
|
||
+ plId + "'");
|
||
}
|
||
if(UtilString.isEmpty(DBSql.getString(sql1)) && UtilString.isEmpty(DBSql.getString(sql2))){
|
||
System.out.println("发布流程无数据===================================================");
|
||
////String sql = "SELECT pl.TASKID FROM APP_ACT_COE_PAL_PUBLISH p, APP_ACT_COE_PAL_PUBLISH_LIST pl
|
||
// // WHERE pl.pid = p.id AND pl.palrepositoryid = ? ORDER BY publishdate DESC";
|
||
|
||
//审批改为发布,如果发布表未存数据,则自动生成发布关联表数据,可使部门视图正常使用
|
||
BO publishN=new BO();
|
||
publishN.set("PUBLISTHTYPE","N");
|
||
publishN.set("PUBLISHFILENAME",model.getName());
|
||
publishN.set("PUBLISHFILEID",plId);
|
||
ProcessInstance processInstance = SDK.getProcessAPI().createProcessInstance("obj_a228b4816a7b4f58a862b9612299948c", "admin", "");
|
||
SDK.getBOAPI().create("BO_ACT_COE_PUBLISH_N",publishN,processInstance,me);
|
||
|
||
|
||
/*BO publish=new BO();
|
||
publish.set("PROCESSINSTID",processInstance.getId());
|
||
publish.set("PUBLISH","1");
|
||
SDK.getBOAPI().createDataBO("APP_ACT_COE_PAL_PUBLISH",publish,me);*/
|
||
|
||
String sql = "insert into APP_ACT_COE_PAL_PUBLISH (ID,PROCESSINSTID,PUBLISH) values ('%s', '%s', '%s')";
|
||
String id = UUIDGener.getUUID();
|
||
int update = DBSql.update(String.format(sql, id, processInstance.getId(), '1'));
|
||
|
||
|
||
//BO app_act_coe_pal_publish = SDK.getBOAPI().query("APP_ACT_COE_PAL_PUBLISH").addQuery("BINDID=", processInstance.getId()).detail();
|
||
RowMap map = DBSql.getMap("select * from APP_ACT_COE_PAL_PUBLISH where BINDID = '" + processInstance.getId() + "'");
|
||
/*BO publishList=new BO();
|
||
publishList.set("PID",app_act_coe_pal_publish.getString("ID"));
|
||
publishList.set("PALREPOSITORYID",plId);
|
||
SDK.getBOAPI().createDataBO("APP_ACT_COE_PAL_PUBLISH_LIST",publishList,me);*/
|
||
|
||
|
||
String app_act_coe_pal_publishsql = "insert into APP_ACT_COE_PAL_PUBLISH_LIST (ID,PID,PALREPOSITORYID) values ('%s', '%s', '%s')";
|
||
String app_act_coe_pal_publishid = UUIDGener.getUUID();
|
||
int app_act_coe_pal_publishupdate = DBSql.update(String.format(app_act_coe_pal_publishsql, app_act_coe_pal_publishid,map.getString("ID"), plId));
|
||
|
||
String repetition_TaskId = createOutputReport(model, "7d3ca852-a0bd-42e6-80b1-3dcea6f55083", "admin", "", plId);
|
||
System.err.println("======手动生成手册id======"+repetition_TaskId);
|
||
// 刷新预览加载的表
|
||
String repetition_sqlr = "UPDATE BO_EU_PAL_OUTPUTREPORT SET TASKID = '" + repetition_TaskId + "' WHERE PLID = '" + plId + "'";
|
||
DBSql.update(sqlr);
|
||
String repetition_sql1 = "SELECT ID FROM BO_ACT_COE_PUBLISH_N WHERE PUBLISHFILEID = '" + plId + "'";
|
||
String repetition_sql2 = "SELECT ID FROM BO_ACT_COE_PUBLISH_C WHERE CHANGEDFILEIDNEW = '" + plId + "'";
|
||
if (UtilString.isNotEmpty(DBSql.getString(repetition_sql1))) {
|
||
count = DBSql.update(
|
||
"UPDATE BO_ACT_COE_PUBLISH_N SET TASKID='" + repetition_TaskId + "'WHERE PUBLISHFILEID ='" + plId + "'");
|
||
}
|
||
if (UtilString.isNotEmpty(DBSql.getString(repetition_sql2))) {
|
||
count = DBSql.update(
|
||
"UPDATE BO_ACT_COE_PUBLISH_C SET TASKID='" + repetition_TaskId + "'WHERE CHANGEDFILEIDNEW ='" + plId + "'");
|
||
}
|
||
if (count != 0) {
|
||
DBSql.update("UPDATE APP_ACT_COE_PAL_PUBLISH_LIST SET TASKID='" + repetition_TaskId + "'WHERE PALREPOSITORYID='"
|
||
+ plId + "'");
|
||
}
|
||
}
|
||
System.err.println("重新生成手册成功=====》" + count);
|
||
}else if ("4".equals(type)) {
|
||
// 修改流程文件的停用状态
|
||
String updataSql = "UPDATE APP_ACT_COE_PAL_REPOSITORY SET ISSTOP = '" + state + "',MODIFYDATE = TO_DATE('"+date+"','YY-MM-DD HH24:MI:SS') WHERE ID = '" + plId
|
||
+ "'";
|
||
System.err.println("停用改设计=======>" + updataSql);
|
||
count = DBSql.update(updataSql);
|
||
|
||
PALRepositoryModel plModel = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(plId);
|
||
if (plModel != null) {
|
||
PALRepositoryCache.getCache().put(plId, plModel);
|
||
}
|
||
|
||
RowMap map = DBSql.getMap("SELECT * FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID = '" + plId + "'");
|
||
String ext4 = map.getString("EXT4");
|
||
if (UtilString.isNotEmpty(ext4)){
|
||
ProcessInstance processInstance = SDK.getProcessAPI().createProcessInstance("obj_a228b4816a7b4f58a862b9612299948c", "admin", "");
|
||
CancelPublishKnwl(processInstance,sid,ext4);
|
||
}else {
|
||
System.out.println("该文件未被发布,不进行取消发布知识以及删除索引");
|
||
}
|
||
|
||
SDK.getLogAPI().consoleInfo("更新状态后刷新缓存结束===========>");
|
||
}
|
||
}
|
||
|
||
|
||
if (count > 0) {
|
||
/*
|
||
* 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();
|
||
*/
|
||
|
||
ro.put("result", "ok");
|
||
} else {
|
||
ro.put("result", "error");
|
||
}
|
||
return ro;
|
||
}
|
||
|
||
/**
|
||
* 文件修改为发布状态时同步权限数据到权限阅览
|
||
*
|
||
* @param palId palid
|
||
* @param me me
|
||
*/
|
||
private void createPermScopeData(String palId , UserContext me) {
|
||
PALRepositoryModel parentModel = PALRepositoryCache.getCache().get(palId);
|
||
String plVersionid = parentModel.getVersionId();
|
||
BO oldBo = (BO) ((BOQueryAPI) SDK.getBOAPI().query("BO_ACT_PUBLISH_PERM_SCOPE").addQuery("PALVERSIONID = ", plVersionid)).detail();
|
||
if (oldBo == null) {
|
||
BO scopeBo = new BO();
|
||
scopeBo.set("PALVERSIONID" , plVersionid);
|
||
scopeBo.set("PALNAME" , parentModel.getName());
|
||
String sql = "select * from APP_ACT_COE_PAL_REPOSITORY where ID = '"+palId+"'";
|
||
RowMap map = DBSql.getMap(sql);
|
||
if (map!=null){
|
||
scopeBo.set("ORGPERM" ,map.getString("EXT6"));
|
||
}
|
||
ProcessInstance processInst = SDK.getProcessAPI().createBOProcessInstance("obj_e076b01bd0d04bc39e5af12e2c8c188c", me.getUID(), "权限阅览");
|
||
SDK.getBOAPI().create("BO_ACT_PUBLISH_PERM_SCOPE", scopeBo, processInst, me);
|
||
}
|
||
}
|
||
|
||
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 void UpdateDept(PALRepositoryModel palRepositoryModel,String id){
|
||
int count = 0;
|
||
int count2 = 0;
|
||
try {
|
||
Map<String, JSONObject> queryRepositoryAttributeById = new RepositoryAttribute().queryRepositoryAttributeById(id);
|
||
if (null != queryRepositoryAttributeById && !queryRepositoryAttributeById.isEmpty()) {
|
||
// 发布部门
|
||
String dempId = "";
|
||
JSONObject Issuing_department = queryRepositoryAttributeById.get("Issuing_department");
|
||
if (null != Issuing_department && !Issuing_department.equals("")) {
|
||
JSONArray PUBDEPTJA = Issuing_department.getJSONArray("value");
|
||
SDK.getLogAPI().consoleInfo(Issuing_department.toString());
|
||
if (null != PUBDEPTJA && !PUBDEPTJA.isEmpty()) {
|
||
for (Object PUBDEPTO : PUBDEPTJA) {
|
||
JSONObject PUBDEPTJO = JSONObject.parseObject(String.valueOf(PUBDEPTO));
|
||
dempId += PUBDEPTJO.getString("id")+",";
|
||
}
|
||
dempId = dempId.substring(0,dempId.length()-1);
|
||
count2 += DBSql.update("UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT6 = TO_CLOB('"+dempId+"') WHERE ID = '"+id+"'");
|
||
}
|
||
}
|
||
}
|
||
} catch (Exception e) {
|
||
// TODO: handle exception
|
||
}
|
||
|
||
|
||
// String methodId = palRepositoryModel.getMethodId();
|
||
String plVersionId = palRepositoryModel.getVersionId();
|
||
String sqly = "SELECT ID FROM APP_ACT_COE_PAL_REPOSITORY WHERE PLVERSIONID = '" + plVersionId + "'";
|
||
|
||
|
||
List<RowMap> maps = DBSql.getMaps(sqly);
|
||
if (maps.size() > 1) {
|
||
String sqlu = "SELECT ID FROM (SELECT ID FROM APP_ACT_COE_PAL_REPOSITORY WHERE PLVERSIONID = '"
|
||
+ plVersionId + "' AND ISPUBLISH ='1' ORDER BY PLVER DESC ) WHERE ROWNUM<2";
|
||
String palId = DBSql.getString(sqlu);
|
||
if (UtilString.isNotEmpty(palId)) {
|
||
if (!id.equals(palId)) {
|
||
count += DBSql.update("UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT5 = '0' WHERE ID = '"+id+"'");
|
||
// continue;
|
||
} else {
|
||
count += DBSql.update("UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT5 = '1' WHERE ID = '"+id+"'");
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
|
||
//刷新状态
|
||
if(palRepositoryModel.isStop()) {
|
||
count += DBSql.update("UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT5 = '0' WHERE ID = '"+id+"'");
|
||
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/**
|
||
* @methodName:
|
||
* @param:
|
||
* @return:
|
||
* @description:获取taskId
|
||
* @auther: Lizj
|
||
* @date: 2022/8/5 16:18
|
||
*/
|
||
public static String getLastPublishTaskIdByModelId(String repositoryId) {
|
||
//String sql = "SELECT pl.TASKID FROM APP_ACT_COE_PAL_PUBLISH p, APP_ACT_COE_PAL_PUBLISH_N pl WHERE pl.pid = p.id AND pl.palrepositoryid = ? ORDER BY publishdate DESC";
|
||
String sql = "SELECT pl.TASKID FROM APP_ACT_COE_PAL_PUBLISH p, APP_ACT_COE_PAL_PUBLISH_LIST pl WHERE pl.pid = p.id AND pl.palrepositoryid = ? ORDER BY publishdate DESC";
|
||
//String sql = "SELECT * FROM (SELECT TASKID FROM BO_ACT_COE_PUBLISH_N WHERE PUBLISHFILEID= ? ORDER BY CREATEDATE DESC) WHERE ROWNUM = 1";
|
||
String taskId = DBSql.getObject(sql, new RowMapper<String>() {
|
||
@Override
|
||
public String mapRow(ResultSet rs, int arg1) throws SQLException {
|
||
return rs.getString(1);
|
||
}
|
||
}, new Object[] { repositoryId });
|
||
return taskId;
|
||
}
|
||
|
||
/**
|
||
* 创建手册,如果是未发布的流程模型,会在N表中创建一个数据
|
||
* @param plId 流程模型ID
|
||
* @param me 用户信息
|
||
*/
|
||
public void createFile(String plId,UserContext me){
|
||
int count = 0;
|
||
// 生成手册
|
||
PALRepositoryModel model = PALRepositoryCache.getCache().get(plId);
|
||
String taskId = createOutputReport(model, "7d3ca852-a0bd-42e6-80b1-3dcea6f55083", "admin", "", plId);
|
||
System.err.println("======手动生成手册id======"+taskId);
|
||
// 刷新预览加载的表
|
||
String sqlr = "UPDATE BO_EU_PAL_OUTPUTREPORT SET TASKID = '" + taskId + "' WHERE PLID = '" + plId + "'";
|
||
DBSql.update(sqlr);
|
||
String sql1 = "SELECT ID FROM BO_ACT_COE_PUBLISH_N WHERE PUBLISHFILEID = '" + plId + "'";
|
||
String string = DBSql.getString(sql1);
|
||
System.out.println(">>>>>>>>>>>>>>>"+string);
|
||
String sql2 = "SELECT ID FROM BO_ACT_COE_PUBLISH_C WHERE CHANGEDFILEIDNEW = '" + plId + "'";
|
||
if (UtilString.isNotEmpty(DBSql.getString(sql1))) {
|
||
count = DBSql.update(
|
||
"UPDATE BO_ACT_COE_PUBLISH_N SET TASKID='" + taskId + "'WHERE PUBLISHFILEID ='" + plId + "'");
|
||
}
|
||
if (UtilString.isNotEmpty(DBSql.getString(sql2))) {
|
||
count = DBSql.update(
|
||
"UPDATE BO_ACT_COE_PUBLISH_C SET TASKID='" + taskId + "'WHERE CHANGEDFILEIDNEW ='" + plId + "'");
|
||
}
|
||
if (count != 0) {
|
||
DBSql.update("UPDATE APP_ACT_COE_PAL_PUBLISH_LIST SET TASKID='" + taskId + "'WHERE PALREPOSITORYID='"
|
||
+ plId + "'");
|
||
}
|
||
if(UtilString.isEmpty(DBSql.getString(sql1)) && UtilString.isEmpty(DBSql.getString(sql2))){
|
||
System.out.println("发布流程无数据===================================================");
|
||
////String sql = "SELECT pl.TASKID FROM APP_ACT_COE_PAL_PUBLISH p, APP_ACT_COE_PAL_PUBLISH_LIST pl
|
||
// // WHERE pl.pid = p.id AND pl.palrepositoryid = ? ORDER BY publishdate DESC";
|
||
|
||
//审批改为发布,如果发布表未存数据,则自动生成发布关联表数据,可使部门视图正常使用
|
||
BO publishN=new BO();
|
||
publishN.set("PUBLISTHTYPE","N");
|
||
publishN.set("PUBLISHFILENAME",model.getName());
|
||
publishN.set("PUBLISHFILEID",plId);
|
||
ProcessInstance processInstance = SDK.getProcessAPI().createProcessInstance("obj_a228b4816a7b4f58a862b9612299948c", "admin", "");
|
||
SDK.getBOAPI().create("BO_ACT_COE_PUBLISH_N",publishN,processInstance,me);
|
||
|
||
|
||
/*BO publish=new BO();
|
||
publish.set("PROCESSINSTID",processInstance.getId());
|
||
publish.set("PUBLISH","1");
|
||
SDK.getBOAPI().createDataBO("APP_ACT_COE_PAL_PUBLISH",publish,me);*/
|
||
|
||
String sql = "insert into APP_ACT_COE_PAL_PUBLISH (ID,PROCESSINSTID,PUBLISHN) values ('%s', '%s', '%s')";
|
||
String id = UUIDGener.getUUID();
|
||
int update = DBSql.update(String.format(sql, id, processInstance.getId(), '1'));
|
||
|
||
|
||
//BO app_act_coe_pal_publish = SDK.getBOAPI().query("APP_ACT_COE_PAL_PUBLISH").addQuery("BINDID=", processInstance.getId()).detail();
|
||
RowMap map = DBSql.getMap("select * from APP_ACT_COE_PAL_PUBLISH where PROCESSINSTID = '" + processInstance.getId() + "'");
|
||
/*BO publishList=new BO();
|
||
publishList.set("PID",app_act_coe_pal_publish.getString("ID"));
|
||
publishList.set("PALREPOSITORYID",plId);
|
||
SDK.getBOAPI().createDataBO("APP_ACT_COE_PAL_PUBLISH_LIST",publishList,me);*/
|
||
|
||
|
||
String app_act_coe_pal_publishsql = "insert into APP_ACT_COE_PAL_PUBLISH_LIST (ID,PID,PALREPOSITORYID) values ('%s', '%s', '%s')";
|
||
String app_act_coe_pal_publishid = UUIDGener.getUUID();
|
||
int app_act_coe_pal_publishupdate = DBSql.update(String.format(app_act_coe_pal_publishsql, app_act_coe_pal_publishid,map.getString("ID"), plId));
|
||
String repetition_TaskId = createOutputReport(model, "7d3ca852-a0bd-42e6-80b1-3dcea6f55083", "admin", "", plId);
|
||
System.err.println("======手动生成手册id======"+repetition_TaskId);
|
||
// 刷新预览加载的表
|
||
String repetition_sqlr = "UPDATE BO_EU_PAL_OUTPUTREPORT SET TASKID = '" + repetition_TaskId + "' WHERE PLID = '" + plId + "'";
|
||
String n_sql = "UPDATE BO_ACT_COE_PUBLISH_N SET TASKID = '" + repetition_TaskId + "' WHERE PUBLISHFILEID = '" + plId + "'";
|
||
DBSql.update(sqlr);
|
||
DBSql.update(n_sql);
|
||
String repetition_sql1 = "SELECT ID FROM BO_ACT_COE_PUBLISH_N WHERE PUBLISHFILEID = '" + plId + "'";
|
||
BO bo_act_coe_publish_n = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_N", true).addQuery("PUBLISHFILEID = ", plId).detail();
|
||
System.out.println("bo_act_coe_publish_nL>>>>>>>>>>>>>>>>>>"+bo_act_coe_publish_n);
|
||
createKmsByNew(bo_act_coe_publish_n,"7d3ca852-a0bd-42e6-80b1-3dcea6f55083",processInstance,"admin");
|
||
String repetition_sql2 = "SELECT ID FROM BO_ACT_COE_PUBLISH_C WHERE CHANGEDFILEIDNEW = '" + plId + "'";
|
||
if (UtilString.isNotEmpty(DBSql.getString(repetition_sql1))) {
|
||
count = DBSql.update(
|
||
"UPDATE BO_ACT_COE_PUBLISH_N SET TASKID='" + repetition_TaskId + "'WHERE PUBLISHFILEID ='" + plId + "'");
|
||
}
|
||
if (UtilString.isNotEmpty(DBSql.getString(repetition_sql2))) {
|
||
count = DBSql.update(
|
||
"UPDATE BO_ACT_COE_PUBLISH_C SET TASKID='" + repetition_TaskId + "'WHERE CHANGEDFILEIDNEW ='" + plId + "'");
|
||
}
|
||
if (count != 0) {
|
||
DBSql.update("UPDATE APP_ACT_COE_PAL_PUBLISH_LIST SET TASKID='" + repetition_TaskId + "'WHERE PALREPOSITORYID='"
|
||
+ plId + "'");
|
||
}
|
||
}
|
||
System.err.println("重新生成手册成功=====》" + count);
|
||
}
|
||
|
||
|
||
|
||
/**
|
||
* 通过发布知识创建知识
|
||
*
|
||
* @param bo 发布清单表数据
|
||
* @param wsId 知识库id
|
||
* @param processExecutionContext 流程数据
|
||
* @param uid 账户合计
|
||
*/
|
||
public void createKmsByNew(BO bo, String wsId, ProcessInstance processExecutionContext,
|
||
String uid) {
|
||
{
|
||
OutputTaskModel model = new OutputTask().getTaskReportById(bo.getString("TASKID"));
|
||
wsId = model.getWsId();
|
||
String publishfileid = bo.getString("PUBLISHFILEID");
|
||
String sql_n = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '" + publishfileid + "'";
|
||
RowMap map = DBSql.getMap(sql_n);
|
||
if (StringUtils.isEmpty(map.getString("EXT4"))) {
|
||
// aslp服务地址
|
||
String aslps_create = "aslp://com.actionsoft.apps.kms/CreateKnwl";
|
||
// 参数定义列表
|
||
Map params_create = new HashMap<String, Object>();
|
||
//保密级别, 0: 普通 1:秘密 2:机密,必填
|
||
params_create.put("securityLevel", 0);
|
||
//知识名称,必填
|
||
|
||
String level = "";
|
||
if (map != null) {
|
||
String pver = map.getString("PLVER");
|
||
if (UtilString.isNotEmpty(pver)) {
|
||
if (pver.contains(".00")) {
|
||
String levels = pver;
|
||
String[] plvers = levels.split("\\.");
|
||
plvers[1] = plvers[1].replaceAll("0", "");
|
||
level = plvers[0] + "." + plvers[1];
|
||
} else {
|
||
level = pver + ".0";
|
||
}
|
||
}
|
||
}
|
||
params_create.put("knwlName", map.getString("PLNAME") + "V" + level);
|
||
//是否可以评论,必填
|
||
params_create.put("isComment", true);
|
||
//是否可以评分,必填
|
||
params_create.put("isRate", true);
|
||
//有效期:yyyy-MM-dd,非必填
|
||
params_create.put("validDate", "2099-12-31");
|
||
//只读控制,1:在线阅读和下载 0:在线阅读,必填
|
||
params_create.put("onlineLevel", 1);
|
||
//知识创建人,某些特殊场景下,sid和createUser代表的用户并不一样,如果此参数为null,则使用sid代表的用户,非必填
|
||
params_create.put("createUser", "admin");
|
||
//知识内容,非必填
|
||
params_create.put("cardContext", "");
|
||
//sid,必填
|
||
params_create.put("sid", UserContext.fromUID(processExecutionContext.getCreateUser()).getSessionId());
|
||
AppAPI appAPI_create = SDK.getAppAPI();
|
||
//创建知识
|
||
ResponseObject ro_create = appAPI_create.callASLP(
|
||
appAPI_create.getAppContext(processExecutionContext.getAppId()),
|
||
aslps_create, params_create);
|
||
String cardId = ((LinkedHashMap) ro_create.getData()).get("cardId").toString();
|
||
String sessionId = new SSOUtil().registerClientSessionNoPassword("admin", LoginConst.DEFAULT_LANG, "localhost", LoginConst.DEVICE_PC);
|
||
//AddKnwlAC(processExecutionContext, jsonArray1, processExecutionContext.getUserContext().getSessionId(),cardId);
|
||
|
||
String update_sql = "UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT4 = '" + cardId + "' WHERE "
|
||
+ " PLCATEGORY = 'process'and PLMETHODID !='process.framework' "
|
||
+ " and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试'"
|
||
+ " ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试')"
|
||
+ " and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e',"
|
||
+ " 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09',"
|
||
+ " '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5',"
|
||
+ " '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093',"
|
||
+ " '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c',"
|
||
+ " '42c09260-c1d3-44b7-ac3d-f8280e04c294') and ID = '" + publishfileid + "'";
|
||
int update = DBSql.update(update_sql);
|
||
System.out.println("更新id为:" + publishfileid + "版本为:的知识对应的资产库的EXT4的影响行数为" + update);
|
||
creadteFile(processExecutionContext, "BO_ACT_COE_PUBLISH_N", UserContext.fromUID(processExecutionContext.getCreateUser()),
|
||
cardId, "PUBLISHFILEID = ",sessionId);
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
|
||
/**
|
||
* 创建附件及文件
|
||
*
|
||
* @param processExecutionContext
|
||
* @param bo_name
|
||
* @param userContext
|
||
* @param cardId
|
||
* @param fileid
|
||
*/
|
||
public void creadteFile(ProcessInstance processExecutionContext, String bo_name, UserContext userContext,
|
||
String cardId, String fileid,String sid) {
|
||
/**
|
||
* 这个主要是负责对流程手册进行相关的文件的生成
|
||
*/
|
||
String sourceAppId = processExecutionContext.getAppId();
|
||
// aslp服务地址
|
||
String aslp = "aslp://com.actionsoft.apps.kms/CreateFile";
|
||
|
||
if (StringUtils.isNotEmpty(cardId)) {
|
||
String sql_ext4 = "select * from APP_ACT_COE_PAL_REPOSITORY where EXT4 = '" + cardId + "'";
|
||
RowMap map = DBSql.getMap(sql_ext4);
|
||
System.out.println("maps======>>>>>>>" + map);
|
||
System.out.println("fileid==》》》》" + fileid);
|
||
System.out.println("id==》》》》" + map.getString("ID"));
|
||
RowMap rowMap = DBSql
|
||
.getMap("SELECT * FROM " + bo_name + " where " + fileid + " '" + map.getString("ID") + "'");
|
||
// BO bos =
|
||
// SDK.getBOAPI().query(bo_name,true).addQuery(fileid,"17e7d198-1656-4a2c-8912-a81850170be9").detail();
|
||
if (rowMap != null) {
|
||
|
||
if (StringUtils.isNotEmpty(rowMap.getString("TASKID"))) {
|
||
|
||
OutputTaskModel model = new OutputTask().getTaskReportById(rowMap.getString("TASKID"));
|
||
if (model != null) {
|
||
// System.out.println(",pdel============" + model);
|
||
OutputAppProfile appProfile = OutputAppManager.getProfile(model.getProfileId());
|
||
if (appProfile == null) {
|
||
throw new AWSException("Not Find OutputAppProfile! profileId=" + model.getProfileId());
|
||
}
|
||
DCPluginProfile dcProfile = SDK.getDCAPI().getDCProfile(appProfile.getAppContext().getId(),
|
||
OutputConst.EXT_APP_DC_OUTPUT);
|
||
if (dcProfile == null)
|
||
throw new AWSException(
|
||
"Not Find DCProfile! repositoryName=" + OutputConst.EXT_APP_DC_OUTPUT);
|
||
String sql_lever = "";
|
||
if (bo_name.equals("BO_ACT_COE_PUBLISH_N")) {
|
||
sql_lever = "SELECT PLVER FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID = '"
|
||
+ rowMap.getString("PUBLISHFILEID") + "'";
|
||
|
||
} else if (bo_name.equals("BO_ACT_COE_PUBLISH_C")) {
|
||
sql_lever = "SELECT PLVER FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID = '"
|
||
+ rowMap.getString("CHANGEDFILEIDNEW") + "'";
|
||
}
|
||
String lever = DBSql.getString(sql_lever);
|
||
System.out.println("版本号::::::::::::" + lever);
|
||
// lever = lever.substring(0,3);
|
||
if (lever.length() == 5 && lever.substring(4).equals("0")) {
|
||
lever.substring(0, 3);
|
||
} else if (lever.length() == 1) {
|
||
lever = lever + ".0";
|
||
}
|
||
String filename = "";
|
||
if (bo_name.equals("BO_ACT_COE_PUBLISH_N")) {
|
||
filename = rowMap.getString("PUBLISHFILENAME");
|
||
} else if (bo_name.equals("BO_ACT_COE_PUBLISH_C")) {
|
||
filename = rowMap.getString("CHANGEDFILENAMENEW");
|
||
}
|
||
DCContext dcContext = new DCContext(userContext, dcProfile, appProfile.getAppContext().getId(),
|
||
model.getWsId(), rowMap.getString("TASKID"), filename + "_" + lever + ".doc");
|
||
// UtilFile file = new UtilFile(dcContext.getPath());
|
||
|
||
Map params = new HashMap<String, Object>();
|
||
//知识ID,必填
|
||
params.put("cardId", cardId);
|
||
//sid,必填
|
||
params.put("sid", sid);
|
||
|
||
params.put("dc", dcContext);
|
||
AppAPI appAPI = SDK.getAppAPI();
|
||
//创建文件
|
||
ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params);
|
||
System.out.println("流程手册的存入=================" + ro);
|
||
JSONArray coontest = new JSONArray(new LinkedList<>());
|
||
JSONObject jsonObject = new JSONObject(new LinkedHashMap<>());
|
||
jsonObject.put("documentId", cardId);
|
||
jsonObject.put("content", "");//信息附件
|
||
//jsonObject.put("abstract", dcContext);//信息摘要
|
||
jsonObject.put("title", dcContext.getFileName().substring(0,dcContext.getFileName().indexOf(".")));//信息标题
|
||
coontest.add(jsonObject);
|
||
createIndexesByContent(processExecutionContext,coontest,cardId);
|
||
|
||
}
|
||
}
|
||
|
||
}
|
||
String sql_A = "SELECT PLNAME FROM APP_ACT_COE_PAL_REPOSITORY where ID = '" + map.getString("ID")
|
||
+ "' AND PLMETHODID != 'process.framework' AND PLMETHODID IN (select distinct PLMETHODID from APP_ACT_COE_PAL_REPOSITORY)";
|
||
List<RowMap> rows = DBSql.getMaps(sql_A);
|
||
|
||
for (RowMap bo : rows) {
|
||
|
||
/**
|
||
* 这个是模型中的附件获取的并插入的数据信息,需要做修改
|
||
*/
|
||
// 调用App
|
||
|
||
// 参数定义列表
|
||
Map paramss = new HashMap<String, Object>();
|
||
//知识ID,必填
|
||
paramss.put("cardId", cardId);
|
||
//sid,必填
|
||
paramss.put("sid", sid);
|
||
|
||
UpfileWeb upfileWeb = new UpfileWeb(userContext);
|
||
|
||
String sql_upfile = "select * from APP_ACT_COE_PAL_UPFILE where palrepositoryid in (select ID from APP_ACT_COE_PAL_REPOSITORY where PLMETHODID != 'process.framework' AND ID= '"
|
||
+ map.getString("ID") + "'" + ") ORDER BY FILENAME ASC";
|
||
List<RowMap> maps = DBSql.getMaps(sql_upfile);
|
||
for (RowMap row : maps) {
|
||
if (!row.getString("FILENAME").contains(".xml")) {
|
||
UpfileModel upfileModel = new UpfileModel();
|
||
upfileModel.setType(row.getString("FILETYPE"));
|
||
upfileModel.setFileName(row.getString("FILENAME"));
|
||
upfileModel.setPl_uuid(row.getString("PALREPOSITORYID"));
|
||
upfileModel.setShape_uuid(row.getString("SHAPEID"));
|
||
DCContext dcContexts = upfileWeb.getDCContext(upfileModel);
|
||
paramss.put("dc", dcContexts);
|
||
AppAPI appAPIs = SDK.getAppAPI();
|
||
ResponseObject ros = appAPIs.callASLP(appAPIs.getAppContext(sourceAppId), aslp, paramss);
|
||
|
||
JSONArray coontest = new JSONArray(new LinkedList<>());
|
||
JSONObject jsonObject = new JSONObject(new LinkedHashMap<>());
|
||
jsonObject.put("documentId", cardId);
|
||
jsonObject.put("content", "");//信息附件
|
||
//jsonObject.put("abstract", dcContexts);//信息摘要
|
||
jsonObject.put("title", dcContexts.getFileName().substring(0,dcContexts.getFileName().indexOf(".")));//信息标题
|
||
coontest.add(jsonObject);
|
||
createIndexesByContent(processExecutionContext,coontest,cardId);
|
||
}
|
||
}
|
||
}
|
||
try {
|
||
|
||
PublishKnow(processExecutionContext, userContext, cardId,sid);
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
|
||
public boolean deleteIndex(ProcessInstance processExecutionContext,String documentId) {
|
||
// 调用App
|
||
String sourceAppId = processExecutionContext.getAppId();
|
||
// aslp服务地址
|
||
String aslp = "aslp://com.actionsoft.apps.addons.es/deleteIndex";
|
||
// 参数定义列表
|
||
Map params = new HashMap<String, Object>();
|
||
//索引名称(文档在哪存放),必填
|
||
params.put("index", "com.actionsoft.apps.kms_kmsdoc_card");
|
||
//类型(索引中对数据进行逻辑分区。不同 type的文档可能有不同的字段,但最好能够非常相似,比如:存储所有产品到索引products中,但是你有许多不同的产品类别,这些产品共享一种相同的(或非常相似)的模式:他们有一个标题、描述、产品代码和价格。他们只是正好属于“产品”下的一些子类。用type表示不同的类别),必填
|
||
params.put("type", "kmsdoc_card");
|
||
//索引ID,入库时给定的ID,非必填
|
||
params.put("documentId", documentId);
|
||
AppAPI appAPI = SDK.getAppAPI();
|
||
//删除索引
|
||
ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params);
|
||
System.out.println("删除索引成功>>>>>>>>"+ro.isOk());
|
||
return ro.isOk();
|
||
}
|
||
|
||
|
||
/**
|
||
* 取消发布知识
|
||
*
|
||
* @param processExecutionContext
|
||
* @param sid
|
||
* @param knwlId
|
||
* @return
|
||
*/
|
||
public boolean CancelPublishKnwl(ProcessInstance processExecutionContext, String sid, String knwlId) {
|
||
// 调用App
|
||
String sourceAppId = processExecutionContext.getAppId();
|
||
// aslp服务地址
|
||
String aslp = "aslp://com.actionsoft.apps.kms/CancelPublishKnwl";
|
||
// 参数定义列表
|
||
Map params = new HashMap<String, Object>();
|
||
// sid,如果为空,则需要传createUser参数,非必填
|
||
params.put("sid", sid);
|
||
// 知识ID,必填
|
||
params.put("knwlId", knwlId);
|
||
AppAPI appAPI = SDK.getAppAPI();
|
||
// 取消发布知识(全部维度)
|
||
ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params);
|
||
System.out.println("取消发布的ro=====>>>>" + ro);
|
||
List<BO> bo_act_document = SDK.getBOAPI().query("BO_ACT_DOCUMENT", true).addQuery("CARDID = ", knwlId).list();
|
||
for (BO bo:
|
||
bo_act_document) {
|
||
String documentid = bo.getString("DOCUMENTID");
|
||
deleteIndex(processExecutionContext,documentid);
|
||
}
|
||
return ro.isOk();
|
||
}
|
||
|
||
|
||
/**
|
||
* 创建索引
|
||
* @param processExecutionContext 流程实例
|
||
* @param contents 索引内容
|
||
* @return
|
||
*/
|
||
|
||
public boolean createIndexesByContent(ProcessInstance processExecutionContext,JSONArray contents,String cardId) {
|
||
// 调用App
|
||
String sourceAppId =processExecutionContext.getAppId() ;
|
||
// aslp服务地址
|
||
String aslp = "aslp://com.actionsoft.apps.addons.es/createIndexesByContent";
|
||
// 参数定义列表
|
||
Map params = new HashMap<String, Object>();
|
||
//索引内容(JSONArray格式, JSONArray中包含JSONObject, JSONObject的内容同创建单个索引),必填
|
||
params.put("contents", contents);
|
||
//索引名称(文档在哪存放),必填
|
||
params.put("index", "com.actionsoft.apps.kms_kmsdoc_card");
|
||
//类型(索引中对数据进行逻辑分区。不同 type的文档可能有不同的字段,但最好能够非常相似,比如:存储所有产品到索引products中,但是你有许多不同的产品类别,这些产品共享一种相同的(或非常相似)的模式:他们有一个标题、描述、产品代码和价格。他们只是正好属于“产品”下的一些子类。用type表示不同的类别),必填
|
||
params.put("type", "kmsdoc_card");
|
||
AppAPI appAPI = SDK.getAppAPI();
|
||
//入库操作,创建内容索引(多个)
|
||
ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params);
|
||
|
||
if(ro.isOk()){
|
||
String documentId = ((LinkedHashMap) ro.getData()).get("documentId").toString();
|
||
BO bo = new BO();
|
||
bo.set("DOCUMENTID",documentId);
|
||
bo.set("CARDID",cardId);
|
||
JSONObject jsonObject = contents.getJSONObject(0);
|
||
String title = jsonObject.get("title").toString();
|
||
bo.set("TITLE",title);
|
||
SDK.getBOAPI().create("BO_ACT_DOCUMENT",bo,processExecutionContext,UserContext.fromUID(processExecutionContext.getCreateUser()));
|
||
}
|
||
|
||
return ro.isOk();
|
||
}
|
||
|
||
/**
|
||
* 发布知识
|
||
*
|
||
* @param processExecutionContext
|
||
* @param userContext
|
||
* @param id
|
||
*/
|
||
public void PublishKnow(ProcessInstance processExecutionContext, UserContext userContext, String id,String sid) {
|
||
|
||
String sql = "select EXT4 from APP_ACT_COE_PAL_REPOSITORY where id in (select PLPARENTID from APP_ACT_COE_PAL_REPOSITORY where EXT4 = '"
|
||
+ id + "')";
|
||
List<RowMap> maps = DBSql.getMaps(sql);
|
||
String ids = "";
|
||
for (RowMap rowmap : maps) {
|
||
ids += rowmap.getString("EXT4") + ",";
|
||
}
|
||
String[] deptSplit_id = ids.split(",");
|
||
|
||
JSONArray jsonArray = new JSONArray();
|
||
for (String id_names : deptSplit_id) {
|
||
jsonArray.add(id_names);
|
||
}
|
||
// jsonObject.put(deptSplit_id);
|
||
id += ",";
|
||
String[] deptSplit_das = id.split(",");
|
||
JSONArray jsonArray_das = new JSONArray();
|
||
for (String das : deptSplit_das) {
|
||
jsonArray_das.add(das);
|
||
}
|
||
// jsonObject.put(deptSplit_id);
|
||
|
||
if (!jsonArray_das.isEmpty() && !jsonArray.isEmpty()) {
|
||
|
||
// 调用App
|
||
String sourceAppId = processExecutionContext.getAppId();
|
||
// aslp服务地址
|
||
String aslp = "aslp://com.actionsoft.apps.kms/PublishKnwl";
|
||
// 参数定义列表
|
||
Map params = new HashMap<String, Object>();
|
||
// 要发布到的维度ID的JSON数组字符串,必填
|
||
params.put("dimensionIDArray", jsonArray.toString());
|
||
// 要发布的知识ID的JSON数组字符串,必填
|
||
params.put("knwlIDArray", jsonArray_das.toString());
|
||
// 标签的JSON数组字符串,非必填
|
||
|
||
// sid,必填
|
||
params.put("sid", sid);
|
||
AppAPI appAPI = SDK.getAppAPI();
|
||
// 发布知识
|
||
ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params);
|
||
|
||
System.out.println("知识发布============" + ro);
|
||
|
||
}
|
||
|
||
}
|
||
|
||
|
||
}
|