Commit 3ba004a878bbf2912d1f2d4563e19c792277e929

Authored by 张志伟
1 parent efdaf957

feature(*): 修改人员站岗信息

- 修改人员站岗信息
fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/PubStandDTO.java 0 → 100644
  1 +package cn.fw.valhalla.domain.dto;
  2 +
  3 +import cn.fw.common.validator.EnumValue;
  4 +import cn.fw.valhalla.domain.enums.PubStandType;
  5 +import lombok.Data;
  6 +import org.hibernate.validator.constraints.ScriptAssert;
  7 +
  8 +import javax.validation.constraints.NotNull;
  9 +import java.util.Objects;
  10 +
  11 +/**
  12 + * 公共池站岗
  13 + *
  14 + * @author : kurisu
  15 + * @version : 2.0
  16 + * @className : PubStandDTO
  17 + * @description : 公共池站岗
  18 + * @date : 2023-04-13 19:19
  19 + */
  20 +@Data
  21 +@ScriptAssert.List({
  22 + @ScriptAssert(lang = "javascript", script = "_this.checkMktNo()", message = "活动信息不能为空"),
  23 +})
  24 +public class PubStandDTO {
  25 + private Long id;
  26 + /**
  27 + * 站岗类型
  28 + */
  29 + @EnumValue(enumClass = PubStandType.class, message = "站岗类型不正确")
  30 + @NotNull(message = "站岗类型不能为空")
  31 + private Integer standType;
  32 + /**
  33 + * 站岗标识码「活动类型为活动编号」
  34 + */
  35 + private Long idCode;
  36 + /**
  37 + * 站岗范围
  38 + */
  39 + @EnumValue(enumClass = PubStandType.class, message = "站岗范围不正确")
  40 + @NotNull(message = "站岗范围不能为空")
  41 + private Integer standRang;
  42 +
  43 + public boolean checkMktNo() {
  44 + if (PubStandType.ACTIVITY.getValue().equals(standType)) {
  45 + return Objects.nonNull(idCode) && idCode > 0;
  46 + }
  47 + return true;
  48 + }
  49 +}
... ...
fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/app/PubClueController.java
... ... @@ -5,7 +5,6 @@ import cn.fw.common.web.auth.LoginAuthBean;
5 5 import cn.fw.common.web.auth.annotation.CurrentUser;
6 6 import cn.fw.data.base.domain.common.Message;
7 7 import cn.fw.security.auth.client.annotation.Authorization;
8   -import cn.fw.security.auth.client.annotation.IgnoreAuth;
9 8 import cn.fw.security.auth.client.enums.AuthType;
10 9 import cn.fw.valhalla.domain.vo.pool.PubPoolSimpleVO;
11 10 import cn.fw.valhalla.service.bus.pub.PubFollowBizService;
... ... @@ -44,7 +43,6 @@ public class PubClueController {
44 43 }
45 44  
46 45 @GetMapping("/log")
47   - @IgnoreAuth
48 46 @ControllerMethod("查看分配日志")
49 47 public Message<List<PubPoolSimpleVO>> info(@CurrentUser final LoginAuthBean user) {
50 48 return success(pubFollowBizService.log(user.getUserId(), user.getGroupId()));
... ...
fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/app/PubStandController.java
... ... @@ -5,17 +5,14 @@ import cn.fw.common.web.auth.LoginAuthBean;
5 5 import cn.fw.common.web.auth.annotation.CurrentUser;
6 6 import cn.fw.data.base.domain.common.Message;
7 7 import cn.fw.security.auth.client.annotation.Authorization;
8   -import cn.fw.security.auth.client.annotation.IgnoreAuth;
9 8 import cn.fw.security.auth.client.enums.AuthType;
  9 +import cn.fw.valhalla.domain.dto.PubStandDTO;
10 10 import cn.fw.valhalla.domain.vo.pool.PubStandVO;
11 11 import cn.fw.valhalla.service.bus.pub.PubStandBizService;
12 12 import lombok.extern.slf4j.Slf4j;
13 13 import org.springframework.beans.factory.annotation.Autowired;
14 14 import org.springframework.validation.annotation.Validated;
15   -import org.springframework.web.bind.annotation.GetMapping;
16   -import org.springframework.web.bind.annotation.PutMapping;
17   -import org.springframework.web.bind.annotation.RequestMapping;
18   -import org.springframework.web.bind.annotation.RestController;
  15 +import org.springframework.web.bind.annotation.*;
19 16  
20 17 import static cn.fw.common.web.util.ResultBuilder.success;
21 18  
... ... @@ -42,14 +39,19 @@ public class PubStandController {
42 39 }
43 40  
44 41 @GetMapping("/info")
45   - @IgnoreAuth
46 42 @ControllerMethod("人员站岗信息")
47 43 public Message<PubStandVO> info(@CurrentUser final LoginAuthBean user) {
48 44 return success(pubStandBizService.standInfo(user));
49 45 }
50 46  
  47 + @PostMapping("/update")
  48 + @ControllerMethod("人员站岗信息")
  49 + public Message<Void> update(@CurrentUser final LoginAuthBean user, @Validated @RequestBody PubStandDTO standDTO) {
  50 + pubStandBizService.updateInfo(user, standDTO);
  51 + return success();
  52 + }
  53 +
51 54 @PutMapping("/join")
52   - @IgnoreAuth
53 55 @ControllerMethod("加入站岗队列")
54 56 public Message<Void> join(@CurrentUser final LoginAuthBean user) {
55 57 pubStandBizService.join(user.getUserId());
... ... @@ -57,7 +59,6 @@ public class PubStandController {
57 59 }
58 60  
59 61 @PutMapping("/exit")
60   - @IgnoreAuth
61 62 @ControllerMethod("退出站岗队列")
62 63 public Message<Void> exit(@CurrentUser final LoginAuthBean user) {
63 64 pubStandBizService.exitStand(user.getUserId(), user.getGroupId());
... ...
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/pub/PubStandBizService.java
... ... @@ -7,6 +7,7 @@ import cn.fw.erp.sdk.api.result.UserRoleDataRange;
7 7 import cn.fw.valhalla.common.constant.RoleCode;
8 8 import cn.fw.valhalla.common.utils.DateUtil;
9 9 import cn.fw.valhalla.domain.db.pub.PubStandStaffInfo;
  10 +import cn.fw.valhalla.domain.dto.PubStandDTO;
10 11 import cn.fw.valhalla.domain.enums.PubStandRang;
11 12 import cn.fw.valhalla.domain.enums.PubStandType;
12 13 import cn.fw.valhalla.domain.vo.pool.PubStandVO;
... ... @@ -99,6 +100,7 @@ public class PubStandBizService {
99 100 * @param currentUser
100 101 * @return
101 102 */
  103 + @Transactional(rollbackFor = Exception.class)
102 104 public PubStandVO standInfo(final LoginAuthBean currentUser) {
103 105 final Long staffId = currentUser.getUserId();
104 106 final Long groupId = currentUser.getGroupId();
... ... @@ -126,6 +128,33 @@ public class PubStandBizService {
126 128 }
127 129  
128 130 /**
  131 + * 查询用户站岗详情
  132 + *
  133 + * @param currentUser
  134 + * @param standDTO
  135 + * @return
  136 + */
  137 + @Transactional(rollbackFor = Exception.class)
  138 + public void updateInfo(final LoginAuthBean currentUser, final PubStandDTO standDTO) {
  139 + final Long staffId = currentUser.getUserId();
  140 + final Long groupId = currentUser.getGroupId();
  141 + final UserInfoDTO user = ehrRpcService.user(staffId);
  142 + BV.notNull(user, () -> "人员信息读取失败,请稍后重试");
  143 + PubStandStaffInfo staffInfo = null;
  144 + if (Objects.nonNull(standDTO.getId())) {
  145 + staffInfo = pubStandStaffInfoService.getById(standDTO.getId());
  146 + }
  147 + if (Objects.isNull(staffInfo)) {
  148 + staffInfo = pubStandStaffInfoService.queryStaffByGroupId(staffId, groupId).orElse(null);
  149 + }
  150 + BV.notNull(staffInfo, () -> "修改失败,请刷新后重试");
  151 + staffInfo.setStandType(PubStandType.ofValue(standDTO.getStandType()));
  152 + staffInfo.setStandRang(PubStandRang.ofValue(standDTO.getStandRang()));
  153 + staffInfo.setIdCode(standDTO.getIdCode());
  154 + pubStandStaffInfoService.updateById(staffInfo);
  155 + }
  156 +
  157 + /**
129 158 * 加入队列
130 159 *
131 160 * @param staffId
... ...