| | |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.safe.pojo.SafeLineInspectionHazard; |
| | | import com.ruoyi.safe.mapper.SafeLineInspectionHazardMapper; |
| | | import com.ruoyi.safe.service.SafeLineInspectionHazardService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | .orderByDesc(SafeLineInspectionHazard::getCreateTime) |
| | | .list(); |
| | | } |
| | | |
| | | @Override |
| | | public boolean save(SafeLineInspectionHazard entity) { |
| | | if (entity.getHazardCode() == null || entity.getHazardCode().isEmpty()) { |
| | | entity.setHazardCode(generateHazardCode()); |
| | | } |
| | | return super.save(entity); |
| | | } |
| | | |
| | | @Override |
| | | public boolean updateById(SafeLineInspectionHazard entity) { |
| | | if ("已整改".equals(entity.getStatus())) { |
| | | Long currentUserId = SecurityUtils.getUserId(); |
| | | entity.setRectifyUserId(currentUserId.intValue()); |
| | | entity.setRectifyTime(LocalDateTime.now()); |
| | | } |
| | | return super.updateById(entity); |
| | | } |
| | | |
| | | private String generateHazardCode() { |
| | | long count = this.count() + 1; |
| | | return "YH" + String.format("%05d", count); |
| | | } |
| | | } |