New file |
| | |
| | | package enumeration.general; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.EnumValue; |
| | | import com.fasterxml.jackson.annotation.JsonValue; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * 通知目标类型 |
| | | * |
| | | * @author:gonghl |
| | | * @date:2024/4/15 15:15 |
| | | */ |
| | | @Getter |
| | | public enum NotifyTargetTypeEnum { |
| | | |
| | | USER("USER", "用户"), |
| | | UNIT("UNIT", "运维单位"), |
| | | ; |
| | | |
| | | |
| | | @EnumValue // 标明该字段存入数据库 |
| | | @JsonValue // 标明在转JSON时使用该字段,即响应时 |
| | | private final String value; |
| | | |
| | | private final String desc; |
| | | |
| | | NotifyTargetTypeEnum(String value, String desc) { |
| | | this.value = value; |
| | | this.desc = desc; |
| | | } |
| | | |
| | | } |
| | |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * 通知状态 |
| | | * 通知类型 |
| | | * |
| | | * @author:gonghl |
| | | * @date:2024/4/15 15:15 |
New file |
| | |
| | | package enumeration.general; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.EnumValue; |
| | | import com.fasterxml.jackson.annotation.JsonValue; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * 通知紧急程度 |
| | | * |
| | | * @author:xp |
| | | * @date:2024/4/29 10:44 |
| | | */ |
| | | @Getter |
| | | public enum UrgentLevelEnum { |
| | | |
| | | NORMAL("info", "正常"), |
| | | SUCCESS("success", "好的,成功的"), |
| | | WARNING("warning", "警告"), |
| | | DANGER("danger", "错误"), |
| | | ; |
| | | |
| | | @EnumValue |
| | | @JsonValue |
| | | private final String value; |
| | | |
| | | private final String desc; |
| | | |
| | | UrgentLevelEnum(String value, String desc) { |
| | | this.value = value; |
| | | this.desc = desc; |
| | | } |
| | | } |
New file |
| | |
| | | package enumeration.general; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.EnumValue; |
| | | import com.fasterxml.jackson.annotation.JsonValue; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * @author:xp |
| | | * @date:2023/11/28 18:04 |
| | | */ |
| | | @Getter |
| | | public enum YesOrNoEnum { |
| | | |
| | | YES("0", "是"), |
| | | NO("1", "否") |
| | | ; |
| | | |
| | | @EnumValue |
| | | @JsonValue |
| | | private String code; |
| | | |
| | | private String desc; |
| | | |
| | | YesOrNoEnum(String code, String desc) { |
| | | this.code = code; |
| | | this.desc = desc; |
| | | } |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.ycl.platform.base.AbsEntity; |
| | | import enumeration.general.NotifyTargetTypeEnum; |
| | | import enumeration.general.NotifyTypeEnum; |
| | | import enumeration.general.UrgentLevelEnum; |
| | | import enumeration.general.YesOrNoEnum; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.AllArgsConstructor; |
| | |
| | | private String content; |
| | | |
| | | @ApiModelProperty("通知谁") |
| | | @TableField("notify_who") |
| | | private Integer notifyWho; |
| | | @TableField("notify_user") |
| | | private Integer notifyUser; |
| | | |
| | | @ApiModelProperty("已读") |
| | | @TableField("readed") |
| | | private String readed; |
| | | private YesOrNoEnum readed; |
| | | |
| | | @ApiModelProperty("紧急") |
| | | @TableField("urgent") |
| | | private String urgent; |
| | | private UrgentLevelEnum urgent; |
| | | |
| | | @ApiModelProperty("工单ID") |
| | | @TableField("work_order_id") |
| | | private Integer workOrderId; |
| | | @ApiModelProperty("工单号") |
| | | @TableField("work_order_no") |
| | | private String workOrderNo; |
| | | |
| | | @ApiModelProperty("通知目标类型") |
| | | @TableField("notify_target_type") |
| | | private NotifyTargetTypeEnum notifyTargetType; |
| | | |
| | | @ApiModelProperty("通知运维单位") |
| | | @TableField("notify_unit") |
| | | private Integer notifyUnit; |
| | | |
| | | /** |
| | | * 通知用户 |
| | | * |
| | | * @param notifyType |
| | | * @param content |
| | | * @param notifyUser |
| | | * @param urgent |
| | | * @param workOrderNo |
| | | * @return |
| | | */ |
| | | public static Notify genEntityByPeople(NotifyTypeEnum notifyType, String content, Integer notifyUser, UrgentLevelEnum urgent, String workOrderNo) { |
| | | Notify notify = new Notify(); |
| | | notify.setNotifyType(notifyType); |
| | | notify.setContent(content); |
| | | notify.setNotifyUser(notifyUser); |
| | | notify.setUrgent(urgent); |
| | | notify.setWorkOrderNo(workOrderNo); |
| | | notify.setNotifyTargetType(NotifyTargetTypeEnum.USER); |
| | | notify.setReaded(YesOrNoEnum.NO); |
| | | return notify; |
| | | } |
| | | |
| | | /** |
| | | * 通知单位 |
| | | * |
| | | * @param notifyType |
| | | * @param content |
| | | * @param notifyUnit |
| | | * @param urgent |
| | | * @param workOrderNo |
| | | * @return |
| | | */ |
| | | public static Notify genEntityByUnit(NotifyTypeEnum notifyType, String content, Integer notifyUnit, UrgentLevelEnum urgent, String workOrderNo) { |
| | | Notify notify = new Notify(); |
| | | notify.setNotifyType(notifyType); |
| | | notify.setContent(content); |
| | | notify.setUrgent(urgent); |
| | | notify.setNotifyUnit(notifyUnit); |
| | | notify.setWorkOrderNo(workOrderNo); |
| | | notify.setNotifyTargetType(NotifyTargetTypeEnum.UNIT); |
| | | notify.setReaded(YesOrNoEnum.NO); |
| | | return notify; |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | private Integer unitId; |
| | | |
| | | @NotNull(message = "点位开始时间不能为空", groups = {Add.class, Update.class}) |
| | | private LocalDateTime startTime; |
| | | |
| | | @NotNull(message = "点位结束时间不能为空", groups = {Add.class, Update.class}) |
| | | private LocalDateTime endTime; |
| | | |
| | | } |
| | |
| | | @ApiModelProperty("点位名称") |
| | | private String pointName; |
| | | |
| | | @NotNull(message = "点位开始时间不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("点位开始时间") |
| | | private LocalDateTime startTime; |
| | | |
| | | @NotNull(message = "点位结束时间不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("点位结束时间") |
| | | private LocalDateTime endTime; |
| | | |
| | | @NotNull(message = "运维单位不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("运维单位") |
| | | private Integer unitId; |
| | |
| | | package com.ycl.platform.domain.query; |
| | | |
| | | import com.ycl.platform.base.AbsQuery; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import org.springframework.lang.NonNull; |
| | | import jakarta.validation.constraints.NotBlank; |
| | |
| | | * @since 2024-04-07 |
| | | */ |
| | | @Data |
| | | @Accessors(chain = true) |
| | | @ApiModel(value = "Notify查询", description = "通知查询") |
| | | public class NotifyQuery extends AbsQuery { |
| | | |
| | | /** 工单号 */ |
| | | private String workOrderNo; |
| | | |
| | | /** 开始时间 */ |
| | | private Date start; |
| | | |
| | | /** 结束时间 */ |
| | | private Date end; |
| | | |
| | | } |
| | | |
| | |
| | | |
| | | import com.ycl.platform.base.AbsVo; |
| | | import com.ycl.platform.domain.entity.Notify; |
| | | import java.util.List; |
| | | import java.time.LocalDateTime; |
| | | import org.springframework.lang.NonNull; |
| | | import org.springframework.beans.BeanUtils; |
| | | import io.swagger.annotations.ApiModel; |
| | | import enumeration.general.NotifyTypeEnum; |
| | | import enumeration.general.UrgentLevelEnum; |
| | | import enumeration.general.YesOrNoEnum; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.experimental.Accessors; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.lang.NonNull; |
| | | |
| | | /** |
| | | * 通知展示 |
| | |
| | | public class NotifyVO extends AbsVo { |
| | | |
| | | /** 通知类型 */ |
| | | private String notifyType; |
| | | private NotifyTypeEnum notifyType; |
| | | |
| | | /** 通知内容 */ |
| | | private String content; |
| | | |
| | | /** 通知谁 */ |
| | | private Integer notifyWho; |
| | | |
| | | /** 已读 */ |
| | | private String readed; |
| | | private YesOrNoEnum readed; |
| | | |
| | | /** 紧急 */ |
| | | private String urgent; |
| | | private UrgentLevelEnum urgent; |
| | | |
| | | /** 工单ID */ |
| | | private Integer workOrderId; |
| | | /** 工单号 */ |
| | | private String workOrderNo; |
| | | |
| | | |
| | | public static NotifyVO getVoByEntity(@NonNull Notify entity, NotifyVO vo) { |
| | | if(vo == null) { |
| | |
| | | |
| | | /** |
| | | * 登录用户身份权限 |
| | | * |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class LoginUser implements UserDetails |
| | |
| | | * 部门ID |
| | | */ |
| | | private Long deptId; |
| | | |
| | | /** |
| | | * 运维单位ID |
| | | */ |
| | | private Integer unitId; |
| | | /** 是否是运维单位管理员账号 */ |
| | | private Boolean unitAdmin; |
| | | |
| | | /** |
| | | * 用户唯一标识 |
| | |
| | | this.permissions = permissions; |
| | | } |
| | | |
| | | public Integer getUnitId() { |
| | | return unitId; |
| | | } |
| | | |
| | | public void setUnitId(Integer unitId) { |
| | | this.unitId = unitId; |
| | | } |
| | | |
| | | public Boolean getUnitAdmin() { |
| | | return unitAdmin; |
| | | } |
| | | |
| | | public void setUnitAdmin(Boolean unitAdmin) { |
| | | this.unitAdmin = unitAdmin; |
| | | } |
| | | |
| | | public Long getUserId() |
| | | { |
| | | return userId; |
| | |
| | | |
| | | /** |
| | | * 指定用户是否解锁,锁定的用户无法进行身份验证 |
| | | * |
| | | * |
| | | * @return |
| | | */ |
| | | @JSONField(serialize = false) |
| | |
| | | |
| | | /** |
| | | * 指示是否已过期的用户的凭据(密码),过期的凭据防止认证 |
| | | * |
| | | * |
| | | * @return |
| | | */ |
| | | @JSONField(serialize = false) |
| | |
| | | |
| | | /** |
| | | * 是否可用 ,禁用的用户不能身份验证 |
| | | * |
| | | * |
| | | * @return |
| | | */ |
| | | @JSONField(serialize = false) |
New file |
| | |
| | | package com.ycl.platform.controller; |
| | | |
| | | import com.ycl.platform.domain.query.NotifyQuery; |
| | | import com.ycl.platform.service.NotifyService; |
| | | import com.ycl.system.Result; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | /** |
| | | * @author:xp |
| | | * @date:2024/4/29 9:38 |
| | | */ |
| | | @RestController |
| | | @RequiredArgsConstructor |
| | | @RequestMapping("/notify") |
| | | public class NotifyController { |
| | | |
| | | private final NotifyService notifyService; |
| | | |
| | | @PostMapping("/page") |
| | | public Result page(@RequestBody NotifyQuery query) { |
| | | return notifyService.page(query); |
| | | } |
| | | |
| | | } |
| | |
| | | package com.ycl.platform.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.ycl.platform.domain.entity.Notify; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.ycl.platform.domain.query.NotifyQuery; |
| | | import com.ycl.platform.domain.vo.NotifyVO; |
| | | import com.ycl.platform.domain.form.NotifyForm; |
| | | import java.util.List; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | /** |
| | | * 通知 Mapper 接口 |
| | |
| | | * @return 数据 |
| | | */ |
| | | List<YwUnitVO> workList(); |
| | | |
| | | /** |
| | | * 通过用户ID查找运维单位 |
| | | * |
| | | * @param userId |
| | | * @return |
| | | */ |
| | | YwUnit getByUserId(Long userId); |
| | | } |
| | |
| | | import com.ycl.platform.domain.entity.YwUnit; |
| | | import com.ycl.platform.domain.form.YwUnitForm; |
| | | import com.ycl.platform.domain.query.YwUnitQuery; |
| | | import com.ycl.system.model.LoginUser; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | * @return |
| | | */ |
| | | Result workList(); |
| | | |
| | | /** |
| | | * 设置登录用户的运维单位信息 |
| | | * |
| | | * @param loginUser |
| | | */ |
| | | void setUnitInfo(LoginUser loginUser); |
| | | } |
| | |
| | | import com.ycl.platform.domain.vo.NotifyVO; |
| | | import com.ycl.platform.domain.query.NotifyQuery; |
| | | import java.util.List; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.ycl.system.page.PageUtil; |
| | | import com.ycl.utils.SecurityUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.security.core.context.SecurityContextHolder; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.Assert; |
| | | import java.util.ArrayList; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | /** |
| | | * 通知 服务实现类 |
| | |
| | | */ |
| | | @Override |
| | | public Result page(NotifyQuery query) { |
| | | |
| | | IPage<Notify> page = new LambdaQueryChainWrapper<>(baseMapper) |
| | | .orderByDesc(Notify::getCreateTime) |
| | | .page(PageUtil.getPage(query, Notify.class)); |
| | | |
| | | List<NotifyVO> vos = page.getRecords().stream() |
| | | .map( |
| | | entity -> NotifyVO.getVoByEntity(entity, null) |
| | | ) |
| | | .collect(Collectors.toList()); |
| | | return Result.ok().data(vos).total(page.getTotal()); |
| | | IPage<Notify> page = PageUtil.getPage(query, Notify.class); |
| | | // 如果是单位管理员:查询单位通知 |
| | | if (SecurityUtils.getLoginUser().getUnitAdmin()) { |
| | | new LambdaQueryChainWrapper<>(baseMapper) |
| | | .between(Objects.nonNull(query.getEnd()) && Objects.nonNull(query.getStart()), |
| | | Notify::getCreateTime, |
| | | query.getStart(), |
| | | query.getEnd()) |
| | | .eq(StringUtils.hasText(query.getWorkOrderNo()), Notify::getWorkOrderNo, query.getWorkOrderNo()) |
| | | .eq(Notify::getNotifyUnit, SecurityUtils.getLoginUser().getUnitId()) |
| | | .orderByDesc(Notify::getCreateTime) |
| | | .page(page); |
| | | } else { |
| | | // 如果是单位人员:查询自己的通知 |
| | | new LambdaQueryChainWrapper<>(baseMapper) |
| | | .between(Objects.nonNull(query.getEnd()) && Objects.nonNull(query.getStart()), |
| | | Notify::getCreateTime, |
| | | query.getStart(), |
| | | query.getEnd()) |
| | | .eq(StringUtils.hasText(query.getWorkOrderNo()), Notify::getWorkOrderNo, query.getWorkOrderNo()) |
| | | .eq(Notify::getNotifyUser, SecurityUtils.getLoginUser().getUnitId()) |
| | | .orderByDesc(Notify::getCreateTime) |
| | | .page(page); |
| | | } |
| | | List<NotifyVO> result = page.getRecords().stream().map(entity -> { |
| | | return NotifyVO.getVoByEntity(entity, null); |
| | | }).collect(Collectors.toList()); |
| | | return Result.ok().data(result).total(page.getTotal()); |
| | | } |
| | | |
| | | /** |
| | |
| | | import com.ycl.utils.DateUtils; |
| | | import com.ycl.utils.SecurityUtils; |
| | | import com.ycl.utils.redis.RedisCache; |
| | | import enumeration.general.NotifyTypeEnum; |
| | | import enumeration.general.WorkOrderDistributeWayEnum; |
| | | import enumeration.general.WorkOrderStatusEnum; |
| | | import enumeration.general.*; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.apache.commons.lang3.ArrayUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | |
| | | workOrderAuditingRecord.setRemark(form.getAuditingRemark()); |
| | | workOrderAuditingRecordMapper.insert(workOrderAuditingRecord); |
| | | // 添加新通知 |
| | | try { |
| | | Notify notify = new Notify(NotifyTypeEnum.WORK_ORDER, form.getAuditingResult().getDesc(), workOrder.getYwPeopleId(), "0", "0", workOrder.getId()); |
| | | notifyService.save(notify); |
| | | } catch (Exception e) { |
| | | return Result.error("审核成功,通知运维人员失败"); |
| | | } |
| | | Notify notify = Notify.genEntityByUnit(NotifyTypeEnum.WORK_ORDER, |
| | | form.getAuditingResult().getDesc(), |
| | | workOrder.getUnitId(), |
| | | UrgentLevelEnum.WARNING, |
| | | workOrder.getWorkOrderNo()); |
| | | notifyService.save(notify); |
| | | return Result.ok("操作成功"); |
| | | } |
| | | |
| | |
| | | new LambdaUpdateChainWrapper<>(baseMapper) |
| | | .in(YwPoint::getId, form.getIds()) |
| | | .set(YwPoint::getUnitId, form.getUnitId()) |
| | | .set(YwPoint::getStartTime, form.getStartTime()) |
| | | .set(YwPoint::getEndTime, form.getEndTime()) |
| | | .update(); |
| | | } else { |
| | | new LambdaUpdateChainWrapper<>(baseMapper) |
| | |
| | | import com.ycl.system.mapper.SysRoleMapper; |
| | | import com.ycl.system.mapper.SysUserMapper; |
| | | import com.ycl.system.mapper.SysUserRoleMapper; |
| | | import com.ycl.system.model.LoginUser; |
| | | import com.ycl.system.page.PageUtil; |
| | | import com.ycl.platform.service.YwUnitService; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void setUnitInfo(LoginUser loginUser) { |
| | | // 单位管理员查询 |
| | | YwUnit unit = new LambdaQueryChainWrapper<>(baseMapper) |
| | | .eq(YwUnit::getUnitAdminAccount, loginUser.getUsername()) |
| | | .one(); |
| | | if (Objects.nonNull(unit)) { |
| | | loginUser.setUnitAdmin(Boolean.TRUE); |
| | | loginUser.setUnitId(unit.getId()); |
| | | } else { |
| | | unit = baseMapper.getByUserId(loginUser.getUserId()); |
| | | if (Objects.nonNull(unit)) { |
| | | loginUser.setUnitAdmin(Boolean.FALSE); |
| | | loginUser.setUnitId(unit.getId()); |
| | | } |
| | | else { |
| | | loginUser.setUnitAdmin(Boolean.FALSE); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<YwUnitVO> export(YwUnitQuery query) { |
| | | // 分页条件查询你 |
| | | IPage<YwUnit> page = new LambdaQueryChainWrapper<>(baseMapper) |
| | |
| | | package com.ycl.system.service; |
| | | |
| | | import com.ycl.exception.ServiceException; |
| | | import com.ycl.platform.service.YwUnitService; |
| | | import com.ycl.system.entity.SysUser; |
| | | import com.ycl.system.model.LoginUser; |
| | | import com.ycl.utils.MessageUtils; |
| | | import com.ycl.utils.StringUtils; |
| | | import enumeration.UserStatus; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | * @author ruoyi |
| | | */ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class UserDetailsServiceImpl implements UserDetailsService |
| | | { |
| | | private static final Logger log = LoggerFactory.getLogger(UserDetailsServiceImpl.class); |
| | | |
| | | @Autowired |
| | | private ISysUserService userService; |
| | | |
| | | @Autowired |
| | | private SysPasswordService passwordService; |
| | | |
| | | @Autowired |
| | | private SysPermissionService permissionService; |
| | | private final ISysUserService userService; |
| | | private final SysPasswordService passwordService; |
| | | private final SysPermissionService permissionService; |
| | | private final YwUnitService unitService; |
| | | |
| | | @Override |
| | | public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException |
| | |
| | | |
| | | public UserDetails createLoginUser(SysUser user) |
| | | { |
| | | return new LoginUser(user.getUserId(), user.getDeptId(), user, permissionService.getMenuPermission(user)); |
| | | LoginUser loginUser = new LoginUser(user.getUserId(), user.getDeptId(), user, permissionService.getMenuPermission(user)); |
| | | unitService.setUnitInfo(loginUser); |
| | | return loginUser; |
| | | } |
| | | } |
| | |
| | | <result column="update_time" property="updateTime" /> |
| | | <result column="notify_type" property="notifyType" /> |
| | | <result column="content" property="content" /> |
| | | <result column="notify_who" property="notifyWho" /> |
| | | <result column="readed" property="readed" /> |
| | | <result column="urgent" property="urgent" /> |
| | | <result column="work_order_id" property="workOrderId" /> |
| | | <result column="work_order_id" property="workOrderNo" /> |
| | | </resultMap> |
| | | |
| | | </mapper> |
| | |
| | | #{id} |
| | | </foreach> |
| | | </delete> |
| | | |
| | | <select id="getByUserId" resultMap="YwUnitResult"> |
| | | SELECT |
| | | tyw.* |
| | | FROM |
| | | t_yw_unit tyw |
| | | INNER JOIN t_unit_people tup ON tup.unit_id = tyw.id and tyw.deleted = 0 |
| | | INNER JOIN t_yw_people typ ON tup.yw_people_id = typ.id AND typ.user_id = #{userId} AND typ.deleted = 0 |
| | | </select> |
| | | </mapper> |