package com.fzzl.hrp.cw.voucher.job;
import org.nutz.dao.Dao;
import org.nutz.ioc.loader.annotation.IocBean;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import com.fzzl.hrp.cw.voucher.bean.CwVoucherPojo;
import com.fzzl.hrp.cw.voucher.disbursement.service.CwDisbursementVoucherService;
import com.sys.framework.service.BaseService;
import com.sys.util.nutz.NutzUtil;
@IocBean
public class CwVoucherOverTimeAutoApproveJob extends BaseService<CwVoucherPojo> implements Job{
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
CwDisbursementVoucherService cwDisbursementVoucherService = new CwDisbursementVoucherService();
//超过24h未审批的自动审批通过。
cwDisbursementVoucherService.agreeOverTimeNotApprove();
}
}
问答
定时任务调用service封装好的方法,可是报错dao对象为空,并且service的方法内有调用activiti的方法,不好把dao对象传过去
标签:
无
13 回复
通过 @Inject 注入,而不是继承
这个解决了,但是有一个新的问题,在调用activiti的claim方法时,我们自己写的ActivitiUserTaskActivityBehavior类继承了activiti的UserTaskActivityBehavior类,里面获取Ioc获取不到。
public class ActivitiUserTaskActivityBehavior extends UserTaskActivityBehavior {
Ioc ioc = Mvcs.getIoc();
XtWorkFlowTaskService xtWorkFlowTaskService = ioc.get(XtWorkFlowTaskService.class);
public ActivitiUserTaskActivityBehavior(String userTaskId, TaskDefinition taskDefinition) {
super(userTaskId, taskDefinition);
}
package com.sys.activiti.restructure;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.activiti.engine.ActivitiException;
import org.activiti.engine.ActivitiIllegalArgumentException;
import org.activiti.engine.DynamicBpmnConstants;
import org.activiti.engine.delegate.Expression;
import org.activiti.engine.delegate.TaskListener;
import org.activiti.engine.delegate.event.ActivitiEventType;
import org.activiti.engine.delegate.event.impl.ActivitiEventBuilder;
import org.activiti.engine.history.HistoricIdentityLink;
import org.activiti.engine.history.HistoricTaskInstance;
import org.activiti.engine.identity.User;
import org.activiti.engine.impl.bpmn.behavior.UserTaskActivityBehavior;
import org.activiti.engine.impl.bpmn.helper.SkipExpressionUtil;
import org.activiti.engine.impl.calendar.BusinessCalendar;
import org.activiti.engine.impl.context.Context;
import org.activiti.engine.impl.persistence.entity.TaskEntity;
import org.activiti.engine.impl.pvm.PvmActivity;
import org.activiti.engine.impl.pvm.delegate.ActivityExecution;
import org.activiti.engine.impl.task.TaskDefinition;
import org.activiti.engine.task.IdentityLink;
import org.activiti.engine.task.Task;
import org.apache.bcel.generic.IXOR;
import org.nutz.ioc.Ioc;
import org.nutz.ioc.impl.NutIoc;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.ioc.loader.combo.ComboIocLoader;
import org.nutz.mvc.Mvcs;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.sys.activiti.task.service.XtWorkFlowTaskService;
import com.sys.util.util.DataTypeUtil;
public class ActivitiUserTaskActivityBehavior extends UserTaskActivityBehavior {
// Ioc ioc = Mvcs.getIoc();
public Ioc ioc;
XtWorkFlowTaskService xtWorkFlowTaskService;
public ActivitiUserTaskActivityBehavior(String userTaskId, TaskDefinition taskDefinition) {
super(userTaskId, taskDefinition);
try {
ioc = new NutIoc(new ComboIocLoader("*js", "/mvc", "/ioc", "*anno", "com.sys", "com.fzzl","*tx", "*jedis","*activiti"));
xtWorkFlowTaskService = ioc.get(XtWorkFlowTaskService.class);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
这个应该属于非MVC下,我是通过new的方法,但是这样太慢了,都扫描了5分钟还没好
这个应该属于非MVC下,我是通过new的方法,但是这样太慢了,都扫描了5分钟还没好
public class ActivitiUserTaskActivityBehavior extends UserTaskActivityBehavior {
// Ioc ioc = Mvcs.getIoc();
public Ioc ioc;
XtWorkFlowTaskService xtWorkFlowTaskService;
public ActivitiUserTaskActivityBehavior(String userTaskId, TaskDefinition taskDefinition) {
super(userTaskId, taskDefinition);
try {
ioc = new NutIoc(new ComboIocLoader("*js", "/mvc", "/ioc", "*anno", "com.sys", "com.fzzl","*tx", "*jedis","*activiti"));
xtWorkFlowTaskService = ioc.get(XtWorkFlowTaskService.class);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
添加回复
请先登陆