| | |
| | | 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; |
| | |
| | | @Resource |
| | | private SnapConfMapper snapConfMapper; |
| | | |
| | | 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()); |
| | | } |
| | | /** |
| | | * 查询列表数据 |
| | | * |
| | | * @param param 查询参数 |
| | | * @return 数据列表 |
| | | */ |
| | | public List<SnapConf> selectList(SnapConf param) { |
| | | QueryWrapper<SnapConf> queryWrapper = getQueryWrapper(param); |
| | | return snapConfMapper.selectList(queryWrapper); |
| | | } |
| | | |
| | | 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("添加失败"); |
| | | /** |
| | | * 封装查询条件 |
| | | * |
| | | * @param param 查询参数 |
| | | * @return 查询构造器 |
| | | */ |
| | | 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; |
| | | } |
| | | |
| | | public BaseResp updateData(SnapConf snapConf) { |
| | | snapConf.setUpdateBy(ContextUtil.getLoginUserName()); |
| | | snapConf.setUpdateTime(new Date()); |
| | | return snapConfMapper.updateById(snapConf) > 0 ? BaseResp.success() : BaseResp.error("更新失败"); |
| | | /** |
| | | * 根据ID查询详情 |
| | | * |
| | | * @param id 主键ID |
| | | * @return 实体对象 |
| | | */ |
| | | public SnapConf selectById(String id) { |
| | | return snapConfMapper.selectById(id); |
| | | } |
| | | |
| | | public BaseResp deleteData(SnapConf snapConf) { |
| | | return snapConfMapper.deleteById(snapConf) > 0 ? BaseResp.success() : BaseResp.error("删除失败"); |
| | | /** |
| | | * 插入新数据 |
| | | * |
| | | * @param param 数据实体 |
| | | * @return 操作结果 |
| | | */ |
| | | 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); |
| | | } |
| | | |
| | | } |