czt
2026-01-19 8384104f76b6e6df077bdb3a22c4f3d9e93619d8
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
package com.fzzy.igds.service;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fzzy.igds.data.BaseResp;
import com.fzzy.igds.domain.SnapConf;
import com.fzzy.igds.mapper.SnapConfMapper;
import com.fzzy.igds.utils.ContextUtil;
import com.ruoyi.common.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
 
@Slf4j
@Service
public class SnapConfService {
 
    @Resource
    private SnapConfMapper snapConfMapper;
 
    /**
     * 查询列表数据
     *
     * @param deptId 查询参数
     * @return 数据列表
     */
    public List<SnapConf> selectList(String deptId) {
 
        QueryWrapper<SnapConf> queryWrapper = new QueryWrapper<>();
 
        if(StringUtils.isNotBlank(deptId)){
            queryWrapper.eq("dept_id", deptId);
        }
        return snapConfMapper.selectList(queryWrapper);
    }
 
    /**
     * 获取更新配置数量
     * @param deptId
     * @param start
     * @param end
     * @return
     */
    public int getUpdateCount(String deptId, Date start, Date end) {
 
        QueryWrapper<SnapConf> queryWrapper = new QueryWrapper<>();
 
        if(StringUtils.isNotBlank(deptId)){
            queryWrapper.eq("dept_id", deptId);
        }
        if (null != start) {
            queryWrapper.ge("update_time", start);
        }
        if (null != end) {
            queryWrapper.le("update_time", end);
        }
        return snapConfMapper.selectCount(queryWrapper);
    }
 
    /**
     * 插入新数据
     *
     * @param param 数据实体
     * @return 操作结果
     */
    public BaseResp insertData(SnapConf param) {
        try {
            param.setId(ContextUtil.generateId());
            if(StringUtils.isBlank(param.getCompanyId())){
                param.setCompanyId(ContextUtil.getCompanyId());
            }
            param.setCreateBy(ContextUtil.getLoginUserName());
            param.setCreateTime(new Date());
            param.setUpdateBy(ContextUtil.getLoginUserName());
            param.setUpdateTime(new Date());
            return snapConfMapper.insert(param) > 0 ? BaseResp.success() : BaseResp.error("添加失败");
        } catch (Exception e) {
            log.error("插入快拍配置数据异常", e);
            return BaseResp.error("添加失败:" + e.getMessage());
        }
    }
 
    /**
     * 更新已有数据
     *
     * @param param 数据实体
     * @return 操作结果
     */
    public BaseResp updateData(SnapConf param) {
        try {
            param.setUpdateBy(ContextUtil.getLoginUserName());
            param.setUpdateTime(new Date());
            return snapConfMapper.updateById(param) > 0 ? BaseResp.success() : BaseResp.error("更新失败");
        } catch (Exception e) {
            log.error("更新快拍配置数据异常", e);
            return BaseResp.error("更新失败:" + e.getMessage());
        }
    }
 
    /**
     * 更新执行时间
     *
     */
    public void updateActHour(SnapConf param) {
        // 创建更新条件包装器
        QueryWrapper<SnapConf> queryWrapper = new QueryWrapper<>();
        // 设置组织ID条件
        queryWrapper.eq("company_id", param.getCompanyId());
        // 创建更新实体,只更新执行时间相关字段
        SnapConf updateEntity = new SnapConf();
        updateEntity.setActHour1(param.getActHour1());
        updateEntity.setActHour2(param.getActHour2());
        updateEntity.setActHour3(param.getActHour3());
        updateEntity.setUpdateTime(new Date());
        updateEntity.setUpdateBy(ContextUtil.getLoginUserName());
        // 执行批量更新
        snapConfMapper.update(updateEntity, queryWrapper);
    }
 
}