提交 f21654e2 编写于 作者: O o2null

Merge branch 'feature/#436' into 'wrdp'

Feature/#436

See merge request o2oa/o2oa!2546
......@@ -6,13 +6,13 @@ import org.quartz.JobListener;
import com.x.base.core.project.config.Config;
import com.x.base.core.project.connection.CipherConnectionAction;
import com.x.base.core.project.gson.XGsonBuilder;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
public class JobReportListener implements JobListener {
private static Logger logger = LoggerFactory.getLogger(JobReportListener.class);
@Override
public String getName() {
return this.getClass().getName();
......@@ -25,7 +25,12 @@ public class JobReportListener implements JobListener {
@Override
public void jobToBeExecuted(JobExecutionContext jobExecutionContext) {
ScheduleLogRequest request = new ScheduleLogRequest(jobExecutionContext);
try {
CipherConnectionAction.post(false, Config.url_x_program_center_jaxrs("schedule", "report"), request);
} catch (Exception e) {
logger.error(e);
}
}
@Override
......
package com.x.base.core.project.schedule;
import java.util.Date;
import java.util.Objects;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.quartz.JobDetail;
......@@ -8,9 +9,17 @@ import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import com.x.base.core.project.gson.GsonPropertyObject;
import com.x.base.core.project.tools.StringTools;
public class ScheduleLogRequest extends GsonPropertyObject {
private static final long serialVersionUID = -1472780383077011677L;
public static final String FIELDSCHEDULELOGID = "scheduleLogId";
// 新增id字段,用于保存ScheduleLog的时候覆盖自动生成的id
private String scheduleLogId;
private String type;
private String node;
......@@ -27,8 +36,20 @@ public class ScheduleLogRequest extends GsonPropertyObject {
private Boolean success;
public ScheduleLogRequest(JobExecutionContext jobExecutionContext) {
JobDetail jobDetail = jobExecutionContext.getJobDetail();
this.scheduleLogId = StringTools.uniqueToken();
jobExecutionContext.put(FIELDSCHEDULELOGID, scheduleLogId);
this.className = jobDetail.getKey().getName();
this.application = jobDetail.getKey().getGroup();
this.node = jobDetail.getDescription();
this.type = jobExecutionContext.getTrigger().getDescription();
this.fireTime = jobExecutionContext.getFireTime();
}
public ScheduleLogRequest(JobExecutionContext jobExecutionContext, JobExecutionException jobExecutionException) {
JobDetail jobDetail = jobExecutionContext.getJobDetail();
this.scheduleLogId = Objects.toString(jobExecutionContext.get(FIELDSCHEDULELOGID));
this.className = jobDetail.getKey().getName();
this.application = jobDetail.getKey().getGroup();
this.node = jobDetail.getDescription();
......@@ -107,4 +128,12 @@ public class ScheduleLogRequest extends GsonPropertyObject {
this.success = success;
}
public String getScheduleLogId() {
return scheduleLogId;
}
public void setScheduleLogId(String scheduleLogId) {
this.scheduleLogId = scheduleLogId;
}
}
\ No newline at end of file
......@@ -38,7 +38,7 @@ public class ThisApplication {
// 每30秒检查一次需要推送的消息
context.schedule(AlarmTrigger.class, "0/30 * * * * ?");
// 每两小时检查一次comment信息的引用情况,删除多余的不必要的数据
context.schedule(CheckEventComment.class, "* * */2 * * ?");
context.schedule(CheckEventComment.class, "4 4 */2 * * ?");
} catch (Exception e) {
e.printStackTrace();
}
......
......@@ -57,9 +57,16 @@ public class LogQueue extends AbstractQueue<NameValuePair> {
private <T extends JpaObject> void concrete(Class<T> cls, T o) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
emc.beginTransaction(cls);
emc.persist(o, CheckPersistType.all);
emc.commit();
T t = emc.find(o.getId(), cls);
if (null != t) {
o.copyTo(t, JpaObject.FieldsUnmodify);
emc.beginTransaction(cls);
emc.commit();
} else {
emc.beginTransaction(cls);
emc.persist(o, CheckPersistType.all);
emc.commit();
}
}
}
......
......@@ -21,8 +21,10 @@ class ActionReport extends BaseAction {
Wi wi = gson.fromJson(jsonElement, Wi.class);
ScheduleLog o = Wi.copier.copy(wi);
/** 默认使用传递过来的id,如果不存在那么重新赋值 */
if (StringUtils.isEmpty(o.getId())) {
if (StringUtils.isEmpty(wi.getScheduleLogId())) {
o.setId(StringTools.uniqueToken());
} else {
o.setId(wi.getScheduleLogId());
}
NameValuePair pair = new NameValuePair();
pair.setName(ScheduleLog.class.getName());
......@@ -39,6 +41,17 @@ class ActionReport extends BaseAction {
private static final long serialVersionUID = 1996856138701159925L;
static WrapCopier<Wi, ScheduleLog> copier = WrapCopierFactory.wi(Wi.class, ScheduleLog.class, null,
JpaObject.FieldsUnmodify);
private String scheduleLogId;
public String getScheduleLogId() {
return scheduleLogId;
}
public void setScheduleLogId(String scheduleLogId) {
this.scheduleLogId = scheduleLogId;
}
}
public static class Wo extends WrapBoolean {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册