优化
This commit is contained in:
@ -8,6 +8,8 @@ import com.ruoyi.common.core.controller.BaseController;
|
|||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.domain.entity.BgtUser;
|
import com.ruoyi.common.core.domain.entity.BgtUser;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
|
import com.ruoyi.framework.web.service.TokenService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@ -31,6 +33,8 @@ public class AppBgtUserController extends BaseController {
|
|||||||
|
|
||||||
private final IBgtUserService iBgtUserService;
|
private final IBgtUserService iBgtUserService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TokenService tokenService;
|
||||||
/**
|
/**
|
||||||
* 实名认证
|
* 实名认证
|
||||||
*/
|
*/
|
||||||
@ -39,7 +43,13 @@ public class AppBgtUserController extends BaseController {
|
|||||||
@RepeatSubmit
|
@RepeatSubmit
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult<Boolean> realNameAuthentication(@Validated @RequestBody UserRealNameAuthenticationDTO dto) {
|
public AjaxResult<Boolean> realNameAuthentication(@Validated @RequestBody UserRealNameAuthenticationDTO dto) {
|
||||||
return AjaxResult.success(iBgtUserService.realNameAuthentication(dto));
|
Boolean b = iBgtUserService.realNameAuthentication(dto);
|
||||||
|
if(b){
|
||||||
|
//更新上下文和缓存
|
||||||
|
SecurityUtils.updateUsername(dto.getUsername());
|
||||||
|
tokenService.refreshToken(SecurityUtils.getLoginUser());
|
||||||
|
}
|
||||||
|
return AjaxResult.success(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ import com.ruoyi.common.core.domain.entity.SysUser;
|
|||||||
import com.ruoyi.common.core.domain.model.BgtLoginBody;
|
import com.ruoyi.common.core.domain.model.BgtLoginBody;
|
||||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||||
import com.ruoyi.common.util.DataUtil;
|
import com.ruoyi.common.util.DataUtil;
|
||||||
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
import com.ruoyi.common.utils.ServletUtils;
|
import com.ruoyi.common.utils.ServletUtils;
|
||||||
import com.ruoyi.framework.web.service.AppLoginService;
|
import com.ruoyi.framework.web.service.AppLoginService;
|
||||||
import com.ruoyi.framework.web.service.SysPermissionService;
|
import com.ruoyi.framework.web.service.SysPermissionService;
|
||||||
@ -133,6 +134,16 @@ public class AppLoginController
|
|||||||
return AjaxResult.success(data);
|
return AjaxResult.success(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping(value = "/test")
|
||||||
|
public void test(String name)
|
||||||
|
{
|
||||||
|
System.out.println(SecurityUtils.getUsername());
|
||||||
|
SecurityUtils.updateUsername(name);
|
||||||
|
tokenService.refreshToken(SecurityUtils.getLoginUser());
|
||||||
|
System.out.println(SecurityUtils.getUsername());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * 获取用户信息
|
// * 获取用户信息
|
||||||
|
@ -309,9 +309,6 @@ public class UploadZipController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (parts.length > 1) {
|
|
||||||
folderName = folderName + "_" + timeStamp;
|
|
||||||
}
|
|
||||||
File newDir = new File(destination, folderName);
|
File newDir = new File(destination, folderName);
|
||||||
ensureDirectoryExists(newDir);
|
ensureDirectoryExists(newDir);
|
||||||
File[] files = source.listFiles();
|
File[] files = source.listFiles();
|
||||||
@ -322,7 +319,16 @@ public class UploadZipController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
File destFile = new File(destination, source.getName());
|
// 获取文件名和扩展名
|
||||||
|
String fileName = source.getName();
|
||||||
|
int dotIndex = fileName.lastIndexOf('.');
|
||||||
|
String nameWithoutExtension = dotIndex == -1 ? fileName : fileName.substring(0, dotIndex);
|
||||||
|
String extension = dotIndex == -1 ? "" : fileName.substring(dotIndex);
|
||||||
|
|
||||||
|
// 在文件名后面添加时间戳
|
||||||
|
String newFileName = nameWithoutExtension + "_" + timeStamp + extension;
|
||||||
|
File destFile = new File(destination, newFileName);
|
||||||
|
|
||||||
ensureDirectoryExists(destFile.getParentFile());
|
ensureDirectoryExists(destFile.getParentFile());
|
||||||
try (InputStream in = new FileInputStream(source);
|
try (InputStream in = new FileInputStream(source);
|
||||||
OutputStream out = new FileOutputStream(destFile)) {
|
OutputStream out = new FileOutputStream(destFile)) {
|
||||||
@ -332,19 +338,17 @@ public class UploadZipController {
|
|||||||
out.write(buffer, 0, length);
|
out.write(buffer, 0, length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String relativePath = RECORD_DIR + File.separator +timeStamp+ getRelativePath(source, new File(TEMP_DIR));
|
|
||||||
relativePath = relativePath.replace("\\", "/").replace("ruoyi/uploadPath", "/profile");
|
|
||||||
System.out.println("文件在记录目录里的相对目录: " + relativePath);
|
|
||||||
|
|
||||||
// 存到数据库作为记录
|
// 记录文件信息到数据库
|
||||||
|
String relativePath = RECORD_DIR + File.separator + getRelativePath(destFile, new File(RECORD_DIR));
|
||||||
|
relativePath = relativePath.replace("\\", "/").replace("ruoyi/uploadPath", "/profile");
|
||||||
|
|
||||||
String parentName = destination.getParentFile().getName();
|
String parentName = destination.getParentFile().getName();
|
||||||
System.out.println("上上一级文件名: " + parentName);
|
|
||||||
String[] split = parentName.split("_");
|
String[] split = parentName.split("_");
|
||||||
String card = split[1];
|
String card = split[1];
|
||||||
WgzUser wgzUser = wgzUserService.findByIdentityCard(card);
|
WgzUser wgzUser = wgzUserService.findByIdentityCard(card);
|
||||||
|
|
||||||
String name = destination.getName();
|
String name = destination.getName();
|
||||||
System.out.println("上一级文件名: " + name);
|
|
||||||
String type = "";
|
String type = "";
|
||||||
if ("保险".equals(name)) {
|
if ("保险".equals(name)) {
|
||||||
type = "2";
|
type = "2";
|
||||||
@ -352,18 +356,19 @@ public class UploadZipController {
|
|||||||
if ("劳务合同".equals(name)) {
|
if ("劳务合同".equals(name)) {
|
||||||
type = "1";
|
type = "1";
|
||||||
}
|
}
|
||||||
AnnexRecord annex = new AnnexRecord();
|
|
||||||
annex.setAnnexName(destFile.getName());
|
AnnexRecord annexRecord = new AnnexRecord();
|
||||||
annex.setAnnexUrl(relativePath);
|
annexRecord.setAnnexName(newFileName);
|
||||||
annex.setAnnexType(type);
|
annexRecord.setAnnexUrl(relativePath);
|
||||||
annex.setUserType(Constants.WGZ);
|
annexRecord.setAnnexType(type);
|
||||||
annex.setUserId(wgzUser.getUserId());
|
annexRecord.setUserType(Constants.WGZ);
|
||||||
annex.setRecruitId(recruitId);
|
annexRecord.setUserId(wgzUser.getUserId());
|
||||||
annex.setCreateBy(username);
|
annexRecord.setRecruitId(recruitId);
|
||||||
annex.setUpdateBy(username);
|
annexRecord.setCreateBy(username);
|
||||||
annex.setCreateUserId(userId);
|
annexRecord.setUpdateBy(username);
|
||||||
annex.setCreateUserType(Constants.BGT);
|
annexRecord.setCreateUserId(userId);
|
||||||
annexRecordList.add(annex);
|
annexRecord.setCreateUserType(Constants.BGT);
|
||||||
|
annexRecordList.add(annexRecord);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
package com.ruoyi.common.utils;
|
package com.ruoyi.common.utils;
|
||||||
|
|
||||||
import cn.hutool.http.HttpStatus;
|
import cn.hutool.http.HttpStatus;
|
||||||
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||||
|
import com.ruoyi.common.exception.CustomException;
|
||||||
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
|
||||||
import com.ruoyi.common.exception.CustomException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 安全服务工具类
|
* 安全服务工具类
|
||||||
@ -102,4 +104,27 @@ public class SecurityUtils
|
|||||||
{
|
{
|
||||||
return userId != null && 1L == userId;
|
return userId != null && 1L == userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新已登录用户的用户名
|
||||||
|
* @param newUsername 新的用户名
|
||||||
|
*/
|
||||||
|
public static void updateUsername(String newUsername) {
|
||||||
|
Authentication currentAuth = getAuthentication();
|
||||||
|
LoginUser loginUser = getLoginUser();
|
||||||
|
SysUser user = loginUser.getUser();
|
||||||
|
// 更新 LoginUser 中的用户名
|
||||||
|
user.setUserName(newUsername);
|
||||||
|
|
||||||
|
// 创建新的认证对象
|
||||||
|
UsernamePasswordAuthenticationToken newAuth = new UsernamePasswordAuthenticationToken(
|
||||||
|
loginUser,
|
||||||
|
currentAuth.getCredentials(),
|
||||||
|
currentAuth.getAuthorities()
|
||||||
|
);
|
||||||
|
|
||||||
|
// 更新安全上下文
|
||||||
|
SecurityContextHolder.getContext().setAuthentication(newAuth);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,8 +111,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
|
|||||||
"/**/*.js"
|
"/**/*.js"
|
||||||
).permitAll()
|
).permitAll()
|
||||||
.antMatchers("/profile/**").anonymous()
|
.antMatchers("/profile/**").anonymous()
|
||||||
.antMatchers("/common/download**").anonymous()
|
.antMatchers("/common/download**").permitAll()
|
||||||
.antMatchers("/common/download/resource**").anonymous()
|
.antMatchers("/common/download/resource**").permitAll()
|
||||||
.antMatchers("/doc.html").anonymous()
|
.antMatchers("/doc.html").anonymous()
|
||||||
.antMatchers("/swagger-resources/**").anonymous()
|
.antMatchers("/swagger-resources/**").anonymous()
|
||||||
.antMatchers("/webjars/**").anonymous()
|
.antMatchers("/webjars/**").anonymous()
|
||||||
|
@ -443,6 +443,12 @@ public class BgtProjectRecruitApplyServiceImpl extends ServicePlusImpl<BgtProjec
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Boolean quit(Long id) {
|
public Boolean quit(Long id) {
|
||||||
BgtProjectRecruitApply recruitApply = getById(id);
|
BgtProjectRecruitApply recruitApply = getById(id);
|
||||||
|
|
||||||
|
if(RecruitApplyStatus.OUT_WORK.getCode().equals(recruitApply.getStatus())){
|
||||||
|
throw new BaseException("您已退场!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BgtProjectRecruit recruit = iBgtProjectRecruitService.getById(recruitApply.getRecruitId());
|
BgtProjectRecruit recruit = iBgtProjectRecruitService.getById(recruitApply.getRecruitId());
|
||||||
if(RecruitStatus.FULL.getCode().equals(recruit.getStatus())){
|
if(RecruitStatus.FULL.getCode().equals(recruit.getStatus())){
|
||||||
recruit.setStatus(RecruitStatus.PROGRESS.getCode());
|
recruit.setStatus(RecruitStatus.PROGRESS.getCode());
|
||||||
|
@ -482,9 +482,6 @@ public class WgzAttendanceServiceImpl extends ServicePlusImpl<WgzAttendanceMappe
|
|||||||
bgtAttendanceVO.setReportToDutyRate(rate);
|
bgtAttendanceVO.setReportToDutyRate(rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
//缺勤人数
|
|
||||||
bgtAttendanceVO.setAbsenceDutyNum(totalNum-bgtAttendanceVO.getReportToDutyNum());
|
|
||||||
|
|
||||||
//任务拥有的所有招工
|
//任务拥有的所有招工
|
||||||
List<BgtProjectRecruit> bgtProjectRecruits = iBgtProjectRecruitService.getBaseMapper().selectList(Wrappers.<BgtProjectRecruit>lambdaQuery()
|
List<BgtProjectRecruit> bgtProjectRecruits = iBgtProjectRecruitService.getBaseMapper().selectList(Wrappers.<BgtProjectRecruit>lambdaQuery()
|
||||||
.eq(BgtProjectRecruit::getTaskId, dto.getTaskId()));
|
.eq(BgtProjectRecruit::getTaskId, dto.getTaskId()));
|
||||||
@ -505,6 +502,11 @@ public class WgzAttendanceServiceImpl extends ServicePlusImpl<WgzAttendanceMappe
|
|||||||
.in(WgzAttendance::getRecruitId, recruitIds).eq(WgzAttendance::getDate, date));
|
.in(WgzAttendance::getRecruitId, recruitIds).eq(WgzAttendance::getDate, date));
|
||||||
bgtAttendanceVO.setEarlyLeaveNum(earlyLeaveNum);
|
bgtAttendanceVO.setEarlyLeaveNum(earlyLeaveNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//缺勤人数
|
||||||
|
bgtAttendanceVO.setAbsenceDutyNum(totalNum-bgtAttendanceVO.getReportToDutyNum()-bgtAttendanceVO.getLeaveNum());
|
||||||
|
|
||||||
|
|
||||||
return bgtAttendanceVO;
|
return bgtAttendanceVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,10 +286,12 @@ public class WgzLeaveServiceImpl extends ServicePlusImpl<WgzLeaveMapper, WgzLeav
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Boolean bgtAudit(BgtLeaveUpdateDTO dto) {
|
public Boolean bgtAudit(BgtLeaveUpdateDTO dto) {
|
||||||
WgzLeave wgzLeave = getById(dto.getId());
|
WgzLeave wgzLeave = getById(dto.getId());
|
||||||
if(!AuditStatus.UNREAD.getCode().equals(wgzLeave.getAuditorType())){
|
if(AuditStatus.getAudit().contains(wgzLeave.getAuditorType())){
|
||||||
throw new BaseException("该条请假申请状态已改变,请刷新页面");
|
throw new BaseException("该条请假已审批");
|
||||||
}
|
}
|
||||||
BeanUtil.copyProperties(dto, wgzLeave);
|
BeanUtil.copyProperties(dto, wgzLeave);
|
||||||
|
|
||||||
|
if(AuditStatus.getAudit().contains(dto.getAuditorType())){
|
||||||
wgzLeave.setAuditorTime(LocalDateTime.now());
|
wgzLeave.setAuditorTime(LocalDateTime.now());
|
||||||
BgtProjectRecruit recruit = iBgtProjectRecruitService.getById(wgzLeave.getRecruitId());
|
BgtProjectRecruit recruit = iBgtProjectRecruitService.getById(wgzLeave.getRecruitId());
|
||||||
|
|
||||||
@ -311,6 +313,9 @@ public class WgzLeaveServiceImpl extends ServicePlusImpl<WgzLeaveMapper, WgzLeav
|
|||||||
.setMessageSmallType(SMALL_LEAVE);
|
.setMessageSmallType(SMALL_LEAVE);
|
||||||
iWgzMessageService.sendAMessage(wgzMessage);
|
iWgzMessageService.sendAMessage(wgzMessage);
|
||||||
|
|
||||||
|
//处理消息
|
||||||
|
iBgtMessageService.operation(USERTYPE_WGZ, wgzLeave.getUserId(), USERTYPE_BGT, SecurityUtils.getAppUserId(), wgzLeave.getId(),SqlHelper.table(WgzLeave.class).getTableName());
|
||||||
|
|
||||||
if(AuditStatus.PASS.getCode().equals(dto.getAuditorType())){
|
if(AuditStatus.PASS.getCode().equals(dto.getAuditorType())){
|
||||||
//考勤信息
|
//考勤信息
|
||||||
List<WgzAttendance> list = attendanceService.list(Wrappers.<WgzAttendance>lambdaQuery()
|
List<WgzAttendance> list = attendanceService.list(Wrappers.<WgzAttendance>lambdaQuery()
|
||||||
@ -333,10 +338,7 @@ public class WgzLeaveServiceImpl extends ServicePlusImpl<WgzLeaveMapper, WgzLeav
|
|||||||
attendanceService.save(wgzAttendance);
|
attendanceService.save(wgzAttendance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(AuditStatus.getAudit().contains(dto.getAuditorType())){{
|
}
|
||||||
//处理消息
|
|
||||||
iBgtMessageService.operation(USERTYPE_WGZ, wgzLeave.getUserId(), USERTYPE_BGT, SecurityUtils.getAppUserId(), wgzLeave.getId(),SqlHelper.table(WgzLeave.class).getTableName());
|
|
||||||
}}
|
|
||||||
return updateById(wgzLeave);
|
return updateById(wgzLeave);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,6 +112,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
wu.identity_card,
|
wu.identity_card,
|
||||||
bpr.recruit_name,
|
bpr.recruit_name,
|
||||||
fpt.task_name,
|
fpt.task_name,
|
||||||
|
bpra.status,
|
||||||
bpra.task_id,
|
bpra.task_id,
|
||||||
bpra.recruit_id,
|
bpra.recruit_id,
|
||||||
CASE
|
CASE
|
||||||
|
Reference in New Issue
Block a user