| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.model.LoginUserInfo; |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.core.utils.DateUtil; |
| | | import com.doumee.dao.business.model.YwElectricalLog; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.dao.business.YwElectricalLogMapper; |
| | | import com.doumee.dao.business.model.YwElectricalLog; |
| | | import com.doumee.service.business.YwElectricalLogService; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.Date; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import com.doumee.core.model.LoginUserInfo; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 电器类操作日志Service实现 |
| | | * @author renkang |
| | | * @date 2026/04/03 |
| | | * @author doumee |
| | | * @date 2026-05-20 14:59:07 |
| | | */ |
| | | @Service |
| | | public class YwElectricalLogServiceImpl implements YwElectricalLogService { |
| | |
| | | |
| | | @Override |
| | | public Integer create(YwElectricalLog ywElectricalLog) { |
| | | if (Objects.isNull(ywElectricalLog) |
| | | || StringUtils.isBlank(ywElectricalLog.getName())) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | LoginUserInfo loginUserInfo = ywElectricalLog.getLoginUserInfo(); |
| | | ywElectricalLog.setCreateDate(new Date()); |
| | | ywElectricalLog.setCreator(loginUserInfo.getId()); |
| | | ywElectricalLog.setEditDate(new Date()); |
| | | ywElectricalLog.setEditor(loginUserInfo.getId()); |
| | | ywElectricalLog.setIsdeleted(Constants.ZERO); |
| | | ywElectricalLogMapper.insert(ywElectricalLog); |
| | | return ywElectricalLog.getId(); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteById(Integer id, LoginUserInfo user) { |
| | | ywElectricalLogMapper.update(new UpdateWrapper<YwElectricalLog>() |
| | | .lambda() |
| | | .set(YwElectricalLog::getIsdeleted, Constants.ONE) |
| | | .set(YwElectricalLog::getEditDate, DateUtil.getCurrDateTime()) |
| | | .set(YwElectricalLog::getEditor, user.getId()) |
| | | .eq(YwElectricalLog::getId, id) |
| | | ); |
| | | public void deleteById(Integer id) { |
| | | ywElectricalLogMapper.deleteById(id); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteByIdInBatch(List<Integer> ids ) { |
| | | if (CollectionUtils.isEmpty(ids)) { |
| | | return; |
| | | } |
| | | for(Integer id :ids){ |
| | | deleteById(id); |
| | | } |
| | | } |
| | | @Override |
| | | public void deleteById(Integer id, LoginUserInfo user) { |
| | | ywElectricalLogMapper.deleteById(id); |
| | | } |
| | | @Override |
| | | public void deleteByIdInBatch(List<Integer> ids, LoginUserInfo user) { |
| | | if (CollectionUtils.isEmpty(ids)) { |
| | | return; |
| | | } |
| | | for (Integer id : ids) { |
| | | this.deleteById(id, user); |
| | | deleteById(id,user); |
| | | } |
| | | } |
| | | @Override |
| | | public void delete(YwElectricalLog ywElectricalLog) { |
| | | UpdateWrapper<YwElectricalLog> deleteWrapper = new UpdateWrapper<>(ywElectricalLog); |
| | | ywElectricalLogMapper.delete(deleteWrapper); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void updateById(YwElectricalLog ywElectricalLog) { |
| | | if (Objects.isNull(ywElectricalLog) || Objects.isNull(ywElectricalLog.getId())) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | LoginUserInfo loginUserInfo = ywElectricalLog.getLoginUserInfo(); |
| | | ywElectricalLog.setEditDate(new Date()); |
| | | ywElectricalLog.setEditor(loginUserInfo.getId()); |
| | | ywElectricalLogMapper.updateById(ywElectricalLog); |
| | | } |
| | | |
| | | @Override |
| | | public void updateByIdInBatch(List<YwElectricalLog> ywElectricalLogs) { |
| | | if (CollectionUtils.isEmpty(ywElectricalLogs)) { |
| | | return; |
| | | } |
| | | for (YwElectricalLog ywElectricalLog: ywElectricalLogs) { |
| | | this.updateById(ywElectricalLog); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public YwElectricalLog findById(Integer id) { |
| | | return ywElectricalLogMapper.selectOne(new QueryWrapper<YwElectricalLog>().lambda() |
| | | .eq(YwElectricalLog::getId, id) |
| | | .last(" limit 1 ")); |
| | | return ywElectricalLogMapper.selectById(id); |
| | | } |
| | | |
| | | @Override |
| | | public YwElectricalLog findOne(YwElectricalLog ywElectricalLog) { |
| | | QueryWrapper<YwElectricalLog> wrapper = new QueryWrapper<>(ywElectricalLog).last("limit 1"); |
| | | return ywElectricalLogMapper.selectOne(wrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<YwElectricalLog> findList(YwElectricalLog ywElectricalLog) { |
| | | QueryWrapper<YwElectricalLog> wrapper = new QueryWrapper<>(ywElectricalLog); |
| | | return ywElectricalLogMapper.selectList(wrapper); |
| | | } |
| | | |
| | | @Override |
| | |
| | | IPage<YwElectricalLog> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); |
| | | MPJLambdaWrapper<YwElectricalLog> queryWrapper = new MPJLambdaWrapper<>(); |
| | | Utils.MP.blankToNull(pageWrap.getModel()); |
| | | YwElectricalLog model = pageWrap.getModel(); |
| | | queryWrapper.selectAll(YwElectricalLog.class) |
| | | .and(Objects.nonNull(model) && StringUtils.isNotBlank(model.getName()), |
| | | i -> i.like(YwElectricalLog::getName, model.getName())) |
| | | .eq(Objects.nonNull(model) && Objects.nonNull(model.getDeviceType()), YwElectricalLog::getDeviceType, model.getDeviceType()) |
| | | .eq(Objects.nonNull(model) && Objects.nonNull(model.getType()), YwElectricalLog::getType, model.getType()) |
| | | .eq(Objects.nonNull(model) && Objects.nonNull(model.getSuccess()), YwElectricalLog::getSuccess, model.getSuccess()) |
| | | .eq(YwElectricalLog::getIsdeleted, Constants.ZERO) |
| | | .orderByDesc(YwElectricalLog::getCreateDate); |
| | | IPage<YwElectricalLog> iPage = ywElectricalLogMapper.selectJoinPage(page, YwElectricalLog.class, queryWrapper); |
| | | return PageData.from(iPage); |
| | | queryWrapper.eq(pageWrap.getModel().getId() != null,YwElectricalLog::getId, pageWrap.getModel().getId()); |
| | | queryWrapper.eq(pageWrap.getModel().getCreator() != null,YwElectricalLog::getCreator, pageWrap.getModel().getCreator()); |
| | | if (pageWrap.getModel().getCreateDate() != null) { |
| | | queryWrapper.ge(YwElectricalLog::getCreateDate, Utils.Date.getStart(pageWrap.getModel().getCreateDate())); |
| | | queryWrapper.le(YwElectricalLog::getCreateDate, Utils.Date.getEnd(pageWrap.getModel().getCreateDate())); |
| | | } |
| | | queryWrapper.eq(pageWrap.getModel().getEditor() != null,YwElectricalLog::getEditor, pageWrap.getModel().getEditor()); |
| | | if (pageWrap.getModel().getEditDate() != null) { |
| | | queryWrapper.ge(YwElectricalLog::getEditDate, Utils.Date.getStart(pageWrap.getModel().getEditDate())); |
| | | queryWrapper.le(YwElectricalLog::getEditDate, Utils.Date.getEnd(pageWrap.getModel().getEditDate())); |
| | | } |
| | | queryWrapper.eq(pageWrap.getModel().getIsdeleted() != null,YwElectricalLog::getIsdeleted, pageWrap.getModel().getIsdeleted()); |
| | | queryWrapper.eq(pageWrap.getModel().getRemark() != null,YwElectricalLog::getRemark, pageWrap.getModel().getRemark()); |
| | | queryWrapper.eq(pageWrap.getModel().getDeviceType() != null,YwElectricalLog::getDeviceType, pageWrap.getModel().getDeviceType()); |
| | | queryWrapper.eq(pageWrap.getModel().getType() != null,YwElectricalLog::getType, pageWrap.getModel().getType()); |
| | | queryWrapper.eq(pageWrap.getModel().getName() != null,YwElectricalLog::getName, pageWrap.getModel().getName()); |
| | | queryWrapper.eq(pageWrap.getModel().getUrl() != null,YwElectricalLog::getUrl, pageWrap.getModel().getUrl()); |
| | | queryWrapper.eq(pageWrap.getModel().getRequest() != null,YwElectricalLog::getRequest, pageWrap.getModel().getRequest()); |
| | | queryWrapper.eq(pageWrap.getModel().getRepose() != null,YwElectricalLog::getRepose, pageWrap.getModel().getRepose()); |
| | | queryWrapper.eq(pageWrap.getModel().getSuccess() != null,YwElectricalLog::getSuccess, pageWrap.getModel().getSuccess()); |
| | | queryWrapper.eq(pageWrap.getModel().getObjId() != null,YwElectricalLog::getObjId, pageWrap.getModel().getObjId()); |
| | | queryWrapper.orderByDesc(YwElectricalLog::getId); |
| | | IPage<YwElectricalLog> result = ywElectricalLogMapper.selectJoinPage(page, YwElectricalLog.class,queryWrapper); |
| | | return PageData.from(result); |
| | | } |
| | | @Override |
| | | public long count(YwElectricalLog ywElectricalLog) { |
| | | QueryWrapper<YwElectricalLog> wrapper = new QueryWrapper<>(ywElectricalLog); |
| | | return ywElectricalLogMapper.selectCount(wrapper); |
| | | } |
| | | } |