|
|
@ -4,6 +4,7 @@ import java.time.LocalDateTime; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
import net.lab1024.sa.admin.common.enums.ReviewEnum; |
|
|
import net.lab1024.sa.admin.common.enums.ReviewEnum; |
|
|
|
|
|
import net.lab1024.sa.admin.module.letter.service.LetterService; |
|
|
import net.lab1024.sa.admin.module.penalty.dao.PenaltyApplyDao; |
|
|
import net.lab1024.sa.admin.module.penalty.dao.PenaltyApplyDao; |
|
|
import net.lab1024.sa.admin.module.penalty.domain.entity.PenaltyApplyEntity; |
|
|
import net.lab1024.sa.admin.module.penalty.domain.entity.PenaltyApplyEntity; |
|
|
import net.lab1024.sa.admin.module.penalty.domain.form.PenaltyApplyAddForm; |
|
|
import net.lab1024.sa.admin.module.penalty.domain.form.PenaltyApplyAddForm; |
|
|
@ -30,6 +31,8 @@ import org.springframework.stereotype.Service; |
|
|
import javax.annotation.Resource; |
|
|
import javax.annotation.Resource; |
|
|
import javax.validation.Valid; |
|
|
import javax.validation.Valid; |
|
|
|
|
|
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 无处罚证明申请主表 Service |
|
|
* 无处罚证明申请主表 Service |
|
|
* |
|
|
* |
|
|
@ -39,6 +42,7 @@ import javax.validation.Valid; |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
|
|
|
@Service |
|
|
@Service |
|
|
|
|
|
@Slf4j |
|
|
public class PenaltyApplyService { |
|
|
public class PenaltyApplyService { |
|
|
|
|
|
|
|
|
@Resource |
|
|
@Resource |
|
|
@ -49,16 +53,25 @@ public class PenaltyApplyService { |
|
|
private EmployeeService employeeService; |
|
|
private EmployeeService employeeService; |
|
|
@Resource |
|
|
@Resource |
|
|
private RoleEmployeeService roleEmployeeService; |
|
|
private RoleEmployeeService roleEmployeeService; |
|
|
|
|
|
@Resource |
|
|
|
|
|
private LetterService letterService; |
|
|
/** |
|
|
/** |
|
|
* 分页查询 |
|
|
* 分页查询 |
|
|
*/ |
|
|
*/ |
|
|
public PageResult<PenaltyApplyVO> queryPage(PenaltyApplyQueryForm queryForm) { |
|
|
public PageResult<PenaltyApplyVO> queryPage(PenaltyApplyQueryForm queryForm) { |
|
|
Page<?> page = SmartPageUtil.convert2PageQuery(queryForm); |
|
|
Page<?> page = SmartPageUtil.convert2PageQuery(queryForm); |
|
|
RequestEmployee requestUser = AdminRequestUtil.getRequestUser(); |
|
|
RequestEmployee requestUser = AdminRequestUtil.getRequestUser(); |
|
|
List<RoleVO> roleIdList = roleEmployeeService.getRoleIdList(requestUser.getEmployeeId()); |
|
|
|
|
|
if (!UserTypeEnum.CEO.getDesc().equals(roleIdList.get(0).getRoleCode())) { |
|
|
// 安全获取角色代码,避免NPE
|
|
|
queryForm.setUserId(requestUser.getEmployeeId()); |
|
|
String roleCode = getUserRoleCode(requestUser); |
|
|
|
|
|
if (roleCode.equals(UserTypeEnum.CEO.getDesc())) { |
|
|
|
|
|
queryForm.setUserType(roleCode); |
|
|
|
|
|
}else if(roleCode.equals(UserTypeEnum.CTO.getDesc())){ |
|
|
|
|
|
queryForm.setDepartmentId(requestUser.getDepartmentId()); |
|
|
|
|
|
}else { |
|
|
|
|
|
queryForm.setUserId(requestUser.getUserId()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
List<PenaltyApplyVO> list = penaltyApplyDao.queryPage(page, queryForm); |
|
|
List<PenaltyApplyVO> list = penaltyApplyDao.queryPage(page, queryForm); |
|
|
return SmartPageUtil.convert2PageResult(page, list); |
|
|
return SmartPageUtil.convert2PageResult(page, list); |
|
|
} |
|
|
} |
|
|
@ -76,7 +89,15 @@ public class PenaltyApplyService { |
|
|
} |
|
|
} |
|
|
PenaltyApplyEntity penaltyApplyEntity = SmartBeanUtil.copy(addForm, PenaltyApplyEntity.class); |
|
|
PenaltyApplyEntity penaltyApplyEntity = SmartBeanUtil.copy(addForm, PenaltyApplyEntity.class); |
|
|
penaltyApplyEntity.setUserId(userId); |
|
|
penaltyApplyEntity.setUserId(userId); |
|
|
penaltyApplyEntity.setStatus(ReviewEnum.APPROVAL.getValue()); |
|
|
String roleCode = letterService.getRoleCode(); |
|
|
|
|
|
//判断类型
|
|
|
|
|
|
if (roleCode.equals(UserTypeEnum.CTO.getDesc())){ |
|
|
|
|
|
penaltyApplyEntity.setStatus(ReviewEnum.PASS.getValue()); |
|
|
|
|
|
penaltyApplyEntity.setAuditStatus(ReviewEnum.APPROVAL.getValue()); |
|
|
|
|
|
}else { |
|
|
|
|
|
penaltyApplyEntity.setStatus(ReviewEnum.APPROVAL.getValue()); |
|
|
|
|
|
} |
|
|
|
|
|
penaltyApplyEntity.setDepartmentId(entity.getDepartmentId()); |
|
|
penaltyApplyEntity.setApplyDate(LocalDateTime.now()); |
|
|
penaltyApplyEntity.setApplyDate(LocalDateTime.now()); |
|
|
penaltyApplyDao.insert(penaltyApplyEntity); |
|
|
penaltyApplyDao.insert(penaltyApplyEntity); |
|
|
return ResponseDTO.ok(); |
|
|
return ResponseDTO.ok(); |
|
|
@ -118,7 +139,17 @@ public class PenaltyApplyService { |
|
|
|
|
|
|
|
|
public ResponseDTO<String> review(@Valid PenaltyApplyUpdateForm updateForm) { |
|
|
public ResponseDTO<String> review(@Valid PenaltyApplyUpdateForm updateForm) { |
|
|
PenaltyApplyEntity penaltyApplyEntity = penaltyApplyDao.selectById(updateForm.getId()); |
|
|
PenaltyApplyEntity penaltyApplyEntity = penaltyApplyDao.selectById(updateForm.getId()); |
|
|
penaltyApplyEntity.setStatus(updateForm.getStatus()); |
|
|
String roleCode = letterService.getRoleCode(); |
|
|
|
|
|
//判断类型
|
|
|
|
|
|
if (roleCode.equals(UserTypeEnum.CTO.getDesc())){ |
|
|
|
|
|
//审核通过,则下一个为律协审核
|
|
|
|
|
|
if (ReviewEnum.PASS.getValue().equals(updateForm.getAuditStatus())){ |
|
|
|
|
|
penaltyApplyEntity.setAuditStatus(ReviewEnum.APPROVAL.getValue()); |
|
|
|
|
|
} |
|
|
|
|
|
penaltyApplyEntity.setStatus(updateForm.getAuditStatus()); |
|
|
|
|
|
}else{ |
|
|
|
|
|
penaltyApplyEntity.setAuditStatus(updateForm.getAuditStatus()); |
|
|
|
|
|
} |
|
|
penaltyApplyDao.updateById(penaltyApplyEntity); |
|
|
penaltyApplyDao.updateById(penaltyApplyEntity); |
|
|
return ResponseDTO.ok(); |
|
|
return ResponseDTO.ok(); |
|
|
} |
|
|
} |
|
|
@ -126,4 +157,37 @@ public class PenaltyApplyService { |
|
|
public PenaltyApplyEntity selectOne(Integer id) { |
|
|
public PenaltyApplyEntity selectOne(Integer id) { |
|
|
return penaltyApplyDao.selectById(id); |
|
|
return penaltyApplyDao.selectById(id); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 安全获取用户角色代码,避免NPE |
|
|
|
|
|
* @param requestUser 请求用户信息 |
|
|
|
|
|
* @return 用户角色代码,如果获取失败则返回USER默认角色 |
|
|
|
|
|
*/ |
|
|
|
|
|
private String getUserRoleCode(RequestEmployee requestUser) { |
|
|
|
|
|
try { |
|
|
|
|
|
if (requestUser == null) { |
|
|
|
|
|
log.warn("请求用户信息为空,返回默认用户角色"); |
|
|
|
|
|
return UserTypeEnum.USER.getDesc(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
List<RoleVO> roleIdList = roleEmployeeService.getRoleIdList(requestUser.getEmployeeId()); |
|
|
|
|
|
if (roleIdList == null || roleIdList.isEmpty()) { |
|
|
|
|
|
log.warn("用户ID {} 的角色列表为空,返回默认用户角色", requestUser.getEmployeeId()); |
|
|
|
|
|
return UserTypeEnum.USER.getDesc(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
RoleVO roleVO = roleIdList.get(0); |
|
|
|
|
|
if (roleVO == null || roleVO.getRoleCode() == null) { |
|
|
|
|
|
log.warn("角色信息为空或角色代码为空,返回默认用户角色"); |
|
|
|
|
|
return UserTypeEnum.USER.getDesc(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String roleCode = roleVO.getRoleCode(); |
|
|
|
|
|
log.debug("用户ID {} 的角色代码: {}", requestUser.getEmployeeId(), roleCode); |
|
|
|
|
|
return roleCode; |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
log.error("获取用户角色代码时发生异常", e); |
|
|
|
|
|
return UserTypeEnum.USER.getDesc(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|