懒羊羊
2023-08-30 71e81ed1d12e4d69f53c8ad9e066650ad4186293
提交 | 用户 | 时间
71e81e 1 package cn.stylefeng.guns.workflow.modular.service.impl;
2
3 import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory;
4 import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
5 import cn.stylefeng.guns.workflow.modular.entity.Procdef;
6 import cn.stylefeng.guns.workflow.modular.mapper.ProcessMapper;
7 import cn.stylefeng.guns.workflow.modular.model.params.ProcdefParam;
8 import cn.stylefeng.guns.workflow.modular.model.result.ProcdefResult;
9 import cn.stylefeng.guns.workflow.modular.service.ProcessService;
10 import cn.stylefeng.roses.core.util.ToolUtil;
11 import com.baomidou.mybatisplus.core.metadata.IPage;
12 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
13 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
14 import org.springframework.stereotype.Service;
15
16 import java.io.Serializable;
17 import java.util.HashMap;
18 import java.util.List;
19 import java.util.Map;
20
21 /**
22  * <p>
23  * 服务实现类
24  * </p>
25  *
26  * @author stylefeng
27  * @since 2019-08-11
28  */
29 @Service
30 public class ProcessServiceImpl extends ServiceImpl<ProcessMapper, Procdef> implements ProcessService {
31
32     @Override
33     public void add(ProcdefParam param) {
34         Procdef entity = getEntity(param);
35         this.save(entity);
36     }
37
38     @Override
39     public void delete(ProcdefParam param) {
40         this.removeById(getKey(param));
41     }
42
43     @Override
44     public void update(ProcdefParam param) {
45         Procdef oldEntity = getOldEntity(param);
46         Procdef newEntity = getEntity(param);
47         ToolUtil.copyProperties(newEntity, oldEntity);
48         this.updateById(newEntity);
49     }
50
51     @Override
52     public ProcdefResult findBySpec(ProcdefParam param) {
53         return null;
54     }
55
56     @Override
57     public List<ProcdefResult> findListBySpec(ProcdefParam param) {
58         return null;
59     }
60
61     @Override
62     public LayuiPageInfo findPageBySpec(ProcdefParam param) {
63         Page pageContext = getPageContext();
64         IPage page = this.baseMapper.customPageList(pageContext, param);
65         return LayuiPageFactory.createPageInfo(page);
66     }
67
68     @Override
69     public void onoffAllTask(String id, Integer status) {
70         this.baseMapper.onoffAllTask(id, status);
71     }
72
73     @Override
74     public void onoffTask(String id, Integer status) {
75         this.baseMapper.onoffTask(id, status);
76     }
77
78     @Override
79     public Map<String, Object> varList(String procInstId) {
80
81         HashMap<String, Object> resultMap = new HashMap<>();
82
83         List<Map<String, Object>> maps = this.baseMapper.varList(procInstId);
84
85         for (Map<String, Object> item : maps) {
86             resultMap.put((String) item.get("name_"), item.get("text_"));
87         }
88
89         return resultMap;
90     }
91
92     @Override
93     public List<Map<String, Object>> hitoryTaskList(String procInstId) {
94         return this.baseMapper.historyTaskList(procInstId);
95     }
96
97     private Serializable getKey(ProcdefParam param) {
98         return param.getId();
99     }
100
101     private Page getPageContext() {
102         return LayuiPageFactory.defaultPage();
103     }
104
105     private Procdef getOldEntity(ProcdefParam param) {
106         return this.getById(getKey(param));
107     }
108
109     private Procdef getEntity(ProcdefParam param) {
110         Procdef entity = new Procdef();
111         ToolUtil.copyProperties(param, entity);
112         return entity;
113     }
114
115 }