| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.fzzy.igds.data.BaseResp; |
| | | import com.fzzy.igds.data.IgdsBaseParam; |
| | | import com.fzzy.igds.domain.EventInfo; |
| | | import com.fzzy.igds.mapper.EventInfoMapper; |
| | | import com.fzzy.igds.utils.ContextUtil; |
| | | import com.fzzy.igds.utils.DateUtil; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | |
| | | param.setCompanyId(ContextUtil.getCompanyId()); |
| | | queryWrapper.eq("company_id", param.getCompanyId()); |
| | | //库区 |
| | | //库区检索 |
| | | if (StringUtils.isNotBlank(param.getDeptId())) { |
| | | queryWrapper.eq("dept_id", param.getDeptId()); |
| | | } |
| | | //仓库 |
| | | //仓库检索 |
| | | if (StringUtils.isNotBlank(param.getDepotId())) { |
| | | queryWrapper.eq("depot_id", param.getDepotId()); |
| | | } |
| | | // 收储公司检索 |
| | | if (StringUtils.isNotBlank(param.getKey())) { |
| | | queryWrapper.likeRight("dept_id", param.getKey()); |
| | | } |
| | | //抓拍时间检索 |
| | | if (null != param.getStart()) { |
| | | queryWrapper.ge("time", param.getStart()); |
| | | } |
| | | if (null != param.getEnd()) { |
| | | queryWrapper.le("time", param.getEnd()); |
| | | } |
| | | //事件名称 |
| | | if (StringUtils.isNotBlank(param.getName())) { |
| | | queryWrapper.like("name", param.getName()); |
| | | } |
| | | |
| | | queryWrapper.orderByDesc("create_time"); |
| | | |
| | | return queryWrapper; |
| | | } |
| | | |
| | | public List<EventInfo> listAll(IgdsBaseParam param) { |
| | | if (null == param) |
| | | return eventInfoMapper.selectList(null); |
| | | /** |
| | | * |
| | | * @param param |
| | | * @return |
| | | */ |
| | | public List<EventInfo> getListByParam(IgdsBaseParam param) { |
| | | if (null == param) { |
| | | param = new IgdsBaseParam(); |
| | | } |
| | | |
| | | QueryWrapper<EventInfo> queryWrapper = new QueryWrapper<>(); |
| | | if (StringUtils.isNotEmpty(param.getName())) { |
| | | queryWrapper.like("name", param.getName()); |
| | | if (StringUtils.isNotBlank(param.getCompanyId())) { |
| | | queryWrapper.eq("company_id", param.getCompanyId()); |
| | | } |
| | | if (StringUtils.isNotBlank(param.getDeptId())) { |
| | | queryWrapper.likeRight("dept_id", param.getDeptId()); |
| | | } |
| | | if (null != param.getStart()) { |
| | | queryWrapper.ge("time", DateUtil.getCurZero(param.getStart())); |
| | | } |
| | | if (null != param.getEnd()) { |
| | | queryWrapper.le("time", DateUtil.getNextZero(param.getEnd())); |
| | | } |
| | | |
| | | return eventInfoMapper.selectList(queryWrapper); |
| | | } |
| | | |
| | | public BaseResp addData(EventInfo eventInfo) { |
| | | eventInfo.setId(ContextUtil.generateId()); |
| | | eventInfo.setCompanyId(ContextUtil.getCompanyId()); |
| | | eventInfo.setUpdateBy(ContextUtil.getLoginUserName()); |
| | | eventInfo.setUpdateTime(new Date()); |
| | | eventInfo.setCreateBy(ContextUtil.getLoginUserName()); |
| | | eventInfo.setCreateTime(new Date()); |
| | | return eventInfoMapper.insert(eventInfo) > 0 ? BaseResp.success() : BaseResp.error("添加失败"); |
| | | /** |
| | | * 持久化保存 |
| | | * |
| | | * @param info |
| | | */ |
| | | public void addData(EventInfo info) { |
| | | if (StringUtils.isBlank(info.getId())) { |
| | | info.setId(ContextUtil.generateId()); |
| | | } |
| | | if (StringUtils.isBlank(info.getCompanyId())) { |
| | | info.setCompanyId(ContextUtil.getCompanyId()); |
| | | } |
| | | |
| | | info.setUpdateBy(ContextUtil.getLoginUserName()); |
| | | info.setUpdateTime(new Date()); |
| | | info.setCreateBy(ContextUtil.getLoginUserName()); |
| | | info.setCreateTime(new Date()); |
| | | eventInfoMapper.insert(info); |
| | | } |
| | | |
| | | public BaseResp updateData(EventInfo eventInfo) { |
| | | eventInfo.setUpdateBy(ContextUtil.getLoginUserName()); |
| | | eventInfo.setUpdateTime(new Date()); |
| | | return eventInfoMapper.updateById(eventInfo) > 0 ? BaseResp.success() : BaseResp.error("更新失败"); |
| | | } |
| | | |
| | | public BaseResp deleteData(EventInfo eventInfo) { |
| | | return eventInfoMapper.deleteById(eventInfo) > 0 ? BaseResp.success() : BaseResp.error("删除失败"); |
| | | } |
| | | } |