package com.ld.igds.timer;
|
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
import org.hibernate.Session;
|
import org.springframework.stereotype.Component;
|
|
import com.bstek.bdf2.core.context.ContextHolder;
|
import com.bstek.bdf2.core.orm.hibernate.HibernateDao;
|
import com.bstek.bdf2.job.model.JobDefinition;
|
import com.bstek.dorado.util.Assert;
|
|
/**
|
* 执行BDF中的job信息
|
*
|
* @author Andy
|
*
|
*/
|
@Component
|
public class BdfJobService extends HibernateDao {
|
|
public void saveJob(JobDefinition job) {
|
Session session = this.getSessionFactory().openSession();
|
try {
|
session.save(job);
|
} finally {
|
session.flush();
|
session.close();
|
}
|
}
|
|
public void updateJob(JobDefinition job) {
|
Session session = this.getSessionFactory().openSession();
|
try {
|
session.update(job);
|
} finally {
|
session.flush();
|
session.close();
|
}
|
}
|
|
/**
|
* 根据主键ID获取到BDF2JOB信息
|
*
|
* @param id
|
* @return
|
*/
|
public JobDefinition getJobById(String id) {
|
Assert.notNull(id, "JOB主键ID没有获取到");
|
String hql = " from " + JobDefinition.class.getName()
|
+ " where companyId = :companyId and id = :id ";
|
Map<String, Object> arg = new HashMap<String, Object>();
|
arg.put("companyId", ContextHolder.getLoginUser().getCompanyId());
|
arg.put("id", id);
|
List<JobDefinition> list = this.query(hql, arg);
|
if (null == list || list.isEmpty())
|
return null;
|
return list.get(0);
|
}
|
|
}
|