将历史已发布并且删除到回收站的数据执行定时任务将kms知识进行取消发布并且删除索引,并且将历史的废止发布表中的数据进行执行,并且将kms知识进行取消发布并且删除索引
This commit is contained in:
parent
9dc8fb7a68
commit
a912149346
@ -0,0 +1,125 @@
|
|||||||
|
package com.awspaas.user.apps.app.job;
|
||||||
|
|
||||||
|
import com.actionsoft.apps.coe.pal.constant.CoEConstant;
|
||||||
|
import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryRemoveCache;
|
||||||
|
import com.actionsoft.apps.coe.pal.pal.repository.dao.PALRepository;
|
||||||
|
import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryRemoveModel;
|
||||||
|
import com.actionsoft.apps.coe.pal.pal.repository.model.impl.PALRepositoryModelImpl;
|
||||||
|
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.util.DBSql;
|
||||||
|
import com.actionsoft.sdk.local.SDK;
|
||||||
|
import com.actionsoft.sdk.local.api.AppAPI;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.quartz.JobExecutionContext;
|
||||||
|
import org.quartz.JobExecutionException;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class UPdateRemoveFileJob implements IJob {
|
||||||
|
@Override
|
||||||
|
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
System.out.println("开始执行定时任务>>>>>>>>>回收站历史管理员删除已发布数据>>>>>>>>>>>>开始执行>>>>>>>>"+sdf.format(new Date()));
|
||||||
|
Connection open = DBSql.open();
|
||||||
|
String sql = "select * from (SELECT info.* FROM APP_ACT_COE_PAL_REPO_R_INFO info,APP_ACT_COE_PAL_REPO_R r where r.REMOVEID = info.ID and info.RESOURCEID = r.ID and info.WSID='7d3ca852-a0bd-42e6-80b1-3dcea6f55083') where removeuser = 'admin'";
|
||||||
|
List<RowMap> maps = DBSql.getMaps(open,sql);
|
||||||
|
for (RowMap rowMap:
|
||||||
|
maps) {
|
||||||
|
List<PALRepositoryRemoveModel> list = PALRepositoryRemoveCache.getCache().getModelsByRemoveId(rowMap.getString("ID"));
|
||||||
|
if (list.size() > 0) {
|
||||||
|
PALRepository dao = new PALRepository();
|
||||||
|
for (PALRepositoryRemoveModel model : list) {
|
||||||
|
PALRepositoryModelImpl models = (PALRepositoryModelImpl) model;
|
||||||
|
|
||||||
|
if (models.isPublish()){
|
||||||
|
SSOUtil ssoUtil = new SSOUtil();
|
||||||
|
String sessionId = ssoUtil.registerClientSessionNoPassword(models.getCreateUser(), "cn", SDK.getPortalAPI().getPortalUrl(), "pc");
|
||||||
|
CancelPublishKnwl(CoEConstant.APP_ID,sessionId,model.getExt4());
|
||||||
|
deleteIndex(CoEConstant.APP_ID,model.getExt4());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println("执行定时任务>>>>>>>>>回收站历史管理员删除已发布数据>>>>>>>>>>>>结束执行>>>>>"+sdf.format(new Date()));
|
||||||
|
List<BO> bo_act_coe_publish_s = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_S", true).connection(open).list();
|
||||||
|
|
||||||
|
|
||||||
|
// 废止知识库文件
|
||||||
|
for (BO bo : bo_act_coe_publish_s) {
|
||||||
|
// 将旧的知识取消发布或者移动到废止发布中
|
||||||
|
String publishfileid_stop = bo.getString("STOPFILEID");
|
||||||
|
String sql_s = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '" + publishfileid_stop
|
||||||
|
+ "'";
|
||||||
|
RowMap map1 = DBSql.getMap(open,sql_s);
|
||||||
|
if (StringUtils.isNotEmpty(map1.getString("EXT4"))) {
|
||||||
|
SSOUtil ssoUtil = new SSOUtil();
|
||||||
|
String sessionId = ssoUtil.registerClientSessionNoPassword(bo.getCreateUser(), "cn", SDK.getPortalAPI().getPortalUrl(), "pc");
|
||||||
|
CancelPublishKnwl(CoEConstant.APP_ID,sessionId,
|
||||||
|
map1.getString("EXT4"));
|
||||||
|
DBSql.update(open,"UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT4 = '' WHERE ID = '"
|
||||||
|
+ publishfileid_stop + "'");
|
||||||
|
deleteIndex(CoEConstant.APP_ID,map1.getString("EXT4"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println("开始执行定时任务>>>>>>>>>历史废止发布数据>>>>>>>>>>>>结束执行>>>>>>"+sdf.format(new Date()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取消发布知识
|
||||||
|
* @param sourceAppId
|
||||||
|
* @param sid
|
||||||
|
* @param knwlId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean CancelPublishKnwl(String sourceAppId,String sid,String knwlId) {
|
||||||
|
// 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);
|
||||||
|
return ro.isOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除索引
|
||||||
|
* @param processExecutionContext
|
||||||
|
* @param documentId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean deleteIndex(String sourceAppId, String documentId) {
|
||||||
|
// 调用App
|
||||||
|
// 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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user