czt
5 天以前 d24dd35d265a0b6bd0620285d226b5bed3d4566e
fzzy-igdss-core/src/main/java/com/fzzy/igds/service/SnapConfService.java
@@ -6,6 +6,7 @@
import com.fzzy.igds.domain.SnapConf;
import com.fzzy.igds.mapper.SnapConfMapper;
import com.fzzy.igds.utils.ContextUtil;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@@ -22,63 +23,110 @@
    private SnapConfMapper snapConfMapper;
    /**
     * 查询所有数据
     * 查询列表数据
     *
     * @param param
     * @author sgj
     * @date 2025/12/10
     * @param param 查询参数
     * @return 数据列表
     */
    public List<SnapConf> listAll(IgdsBaseParam param) {
        if (null == param)
            return snapConfMapper.selectList(null);
        QueryWrapper<SnapConf> queryWrapper = new QueryWrapper<>();
        if (StringUtils.isNotEmpty(param.getName())) {
            queryWrapper.like("name", param.getName());
        }
    public List<SnapConf> selectList(SnapConf param) {
        QueryWrapper<SnapConf> queryWrapper = getQueryWrapper(param);
        return snapConfMapper.selectList(queryWrapper);
    }
    /**
     * 新增数据
     * 封装查询条件
     *
     * @param snapConf
     * @author sgj
     * @date 2025/12/10
     * @param param 查询参数
     * @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 QueryWrapper<SnapConf> getQueryWrapper(SnapConf param) {
        QueryWrapper<SnapConf> queryWrapper = new QueryWrapper<>();
        if(null == param) param= new SnapConf();
        // 设置公司ID并作为查询条件
        param.setCompanyId(ContextUtil.getCompanyId());
        queryWrapper.eq("company_id", param.getCompanyId());
        // 按更新时间倒序排序
        queryWrapper.orderByDesc("update_time");
        return queryWrapper;
    }
    /**
     * 更新数据
     * 根据ID查询详情
     *
     * @param snapConf
     * @author sgj
     * @date 2025/12/10
     * @param id 主键ID
     * @return 实体对象
     */
    public BaseResp updateData(SnapConf snapConf) {
        snapConf.setUpdateBy(ContextUtil.getLoginUserName());
        snapConf.setUpdateTime(new Date());
        return snapConfMapper.updateById(snapConf) > 0 ? BaseResp.success() : BaseResp.error("更新失败");
    public SnapConf selectById(String id) {
        return snapConfMapper.selectById(id);
    }
    /**
     * 删除数据
     * 插入新数据
     *
     * @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 insertData(SnapConf param) {
        try {
            param.setId(ContextUtil.generateId());
            param.setCompanyId(ContextUtil.getCompanyId());
            param.setCreateBy(ContextUtil.getLoginUserName());
            param.setCreateTime(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());
        }
    }
    /**
     * 删除指定ID的数据
     *
     * @param param 要删除的记录
     * @return 操作结果
     */
    public BaseResp deleteData(SnapConf param) {
        return snapConfMapper.deleteById(param) > 0 ? BaseResp.success() : BaseResp.error("删除失败");
    }
    /**
     * 更新执行时间
     *
     */
    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);
    }
}