czt
2024-07-13 b030109e665301e7edd6ad0fe5c832ee10fe39b4
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
package com.ld.igds.sec.view;
 
import com.bstek.dorado.annotation.DataProvider;
import com.bstek.dorado.annotation.DataResolver;
import com.bstek.dorado.annotation.Expose;
import com.bstek.dorado.data.provider.Page;
import com.ld.igds.models.SecSnapConf;
import com.ld.igds.models.SecSnapDepot;
import com.ld.igds.sec.service.SecSnapDepotService;
import com.ld.igds.util.ContextUtil;
 
import org.springframework.stereotype.Component;
 
import javax.annotation.Resource;
 
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
/**
 * @author: andy.jia
 * @description: 仓内抓拍信息获取管理
 * @version:
 */
@Component
public class SecSnapDepotPR {
 
    @Resource
    private SecSnapDepotService snapDepotService;
 
 
    /**
     * secSnapDepotPR#pageSnapDepot
     *
     * @param param
     * @throws Exception
     */
    @DataProvider
    public void pageSnapDepot(Page<SecSnapDepot> page, Map<String, Object> param)
            throws Exception {
 
        if (null == param) param = new HashMap<>();
        param.put("companyId", ContextUtil.getCompanyId());
        param.put("deptId", ContextUtil.subDeptId(null));
 
        snapDepotService.pageSnapDepot(page, param);
 
        //添加4条测试数据
        if (null == page.getEntities() || page.getEntities().isEmpty()) {
            Collection<SecSnapDepot> list = new ArrayList<>();
            list.add(new SecSnapDepot("TEST"));
            list.add(new SecSnapDepot("TEST"));
            list.add(new SecSnapDepot("TEST"));
            list.add(new SecSnapDepot("TEST"));
 
            page.setEntities(list);
        }
    }
    
    
    
    /**
     * secSnapDepotPR#getConfActHour
     * 
     * 默认获取第一条数据的配置信息,如果没有就返回一个空的对象
     * @param page
     * @param param
     * @return
     * @throws Exception
     */
    @DataProvider
    public SecSnapConf getConfActHour()throws Exception {
        List<SecSnapConf> list =   snapDepotService.listSnapConf(ContextUtil.getCompanyId(), ContextUtil.subDeptId(null));
        if(null == list || list.isEmpty()) return new SecSnapConf();
        return list.get(0);
    }
    
    
    /**
     * secSnapDepotPR#listConf
     * 
     * 默认获取第一条数据的配置信息,如果没有就返回一个空的对象
     * @param page
     * @param param
     * @return
     * @throws Exception
     */
    @DataProvider
    public List<SecSnapConf> listConf()throws Exception {
        return  snapDepotService.listSnapConf(ContextUtil.getCompanyId(), ContextUtil.subDeptId(null));
    }
    
    
    /**
     * secSnapDepotPR#updateConf
     * @param items
     * @throws Exception
     */
    @DataResolver
    public void updateConf(List<SecSnapConf> items)throws Exception {
        if(null ==items || items.isEmpty() ) return;
        for(SecSnapConf conf:items){
            if(null == conf.getId()){
                if(null == conf.getCompanyId()){
                    conf.setCompanyId(ContextUtil.getCompanyId());
                }
                if(null == conf.getDeptId()){
                    conf.setDeptId(ContextUtil.subDeptId(null));
                }
                snapDepotService.addConf(conf);
            }else{
                snapDepotService.updateConf(conf);
            }
        }
        
    }
    
    
    /**
     * secSnapDepotPR#updateActHour
     * @param items
     * @throws Exception
     */
    @Expose
    public void updateActHour(SecSnapConf conf)throws Exception {
    
        if(null == conf.getCompanyId()){
            conf.setCompanyId(ContextUtil.getCompanyId());
        }
        if(null == conf.getDeptId()){
            conf.setDeptId(ContextUtil.subDeptId(null));
        }
        
        //同步更新所有的执行时间一致
        snapDepotService.updateActHour(conf);
        
    }
}