sgj
8 天以前 71fe4f1f6a75c86640a726b9c230e8aaae2a28e7
fzzy-igdss-core/src/main/java/com/fzzy/igds/service/SnapConfService.java
@@ -2,14 +2,12 @@
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fzzy.igds.data.BaseResp;
import com.fzzy.igds.data.IgdsBaseParam;
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;
@@ -22,63 +20,102 @@
    private SnapConfMapper snapConfMapper;
    /**
     * 查询所有数据
     * 查询列表数据
     *
     * @param param
     * @author sgj
     * @date 2025/12/10
     * @param deptId 查询参数
     * @return 数据列表
     */
    public List<SnapConf> listAll(IgdsBaseParam param) {
        if (null == param)
            return snapConfMapper.selectList(null);
    public List<SnapConf> selectList(String deptId) {
        QueryWrapper<SnapConf> queryWrapper = new QueryWrapper<>();
        if (StringUtils.isNotEmpty(param.getName())) {
            queryWrapper.like("name", param.getName());
        if(StringUtils.isNotBlank(deptId)){
            queryWrapper.eq("dept_id", deptId);
        }
        return snapConfMapper.selectList(queryWrapper);
    }
    /**
     * 新增数据
     *
     * @param snapConf
     * @author sgj
     * @date 2025/12/10
     * 获取更新配置数量
     * @param deptId
     * @param start
     * @param end
     * @return
     */
    public BaseResp addData(SnapConf snapConf) {
        snapConf.setId(ContextUtil.generateId());
        snapConf.setCompanyId(ContextUtil.getCompanyId());
        snapConf.setUpdateBy(ContextUtil.getLoginUserName());
        snapConf.setUpdateTime(new Date());
        snapConf.setCreateBy(ContextUtil.getLoginUserName());
        snapConf.setCreateTime(new Date());
        return snapConfMapper.insert(snapConf) > 0 ? BaseResp.success() : BaseResp.error("添加失败");
    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 snapConf
     * @author sgj
     * @date 2025/12/10
     * @param param 数据实体
     * @return 操作结果
     */
    public BaseResp updateData(SnapConf snapConf) {
        snapConf.setUpdateBy(ContextUtil.getLoginUserName());
        snapConf.setUpdateTime(new Date());
        return snapConfMapper.updateById(snapConf) > 0 ? BaseResp.success() : BaseResp.error("更新失败");
    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 snapConf
     * @author sgj
     * @date 2025/12/10
     * @param param 数据实体
     * @return 操作结果
     */
    public BaseResp deleteData(SnapConf snapConf) {
        return snapConfMapper.deleteById(snapConf) > 0 ? BaseResp.success() : BaseResp.error("删除失败");
    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);
    }
}