CZT
2023-11-27 c206acfaedc69c390fb67daa81bc686f58a212ef
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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);
    }
 
}