This commit is contained in:
zt
2025-03-21 15:55:17 +08:00
parent c8edffdfd0
commit fa37ceb800
9 changed files with 140 additions and 78 deletions

View File

@ -8,6 +8,8 @@ import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.BgtUser;
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.ApiOperation;
import lombok.RequiredArgsConstructor;
@ -31,6 +33,8 @@ public class AppBgtUserController extends BaseController {
private final IBgtUserService iBgtUserService;
@Autowired
private TokenService tokenService;
/**
* 实名认证
*/
@ -39,7 +43,13 @@ public class AppBgtUserController extends BaseController {
@RepeatSubmit
@PutMapping
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);
}

View File

@ -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.LoginUser;
import com.ruoyi.common.util.DataUtil;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.framework.web.service.AppLoginService;
import com.ruoyi.framework.web.service.SysPermissionService;
@ -133,6 +134,16 @@ public class AppLoginController
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());
}
// /**
// * 获取用户信息

View File

@ -296,7 +296,7 @@ public class UploadZipController {
}
}
private void moveFilesToRecordDirRecursively(File source, File destination, String timeStamp, List<AnnexRecord> annexRecordList, Long recruitId,String username,Long userId) throws IOException {
private void moveFilesToRecordDirRecursively(File source, File destination, String timeStamp, List<AnnexRecord> annexRecordList, Long recruitId, String username, Long userId) throws IOException {
if (source.isDirectory()) {
String folderName = source.getName();
String[] parts = folderName.split("_");
@ -305,24 +305,30 @@ public class UploadZipController {
File[] files = source.listFiles();
if (files != null) {
for (File file : files) {
moveFilesToRecordDirRecursively(file, destination, timeStamp, annexRecordList, recruitId,username,userId);
moveFilesToRecordDirRecursively(file, destination, timeStamp, annexRecordList, recruitId, username, userId);
}
}
} else {
if (parts.length > 1) {
folderName = folderName + "_" + timeStamp;
}
File newDir = new File(destination, folderName);
ensureDirectoryExists(newDir);
File[] files = source.listFiles();
if (files != null) {
for (File file : files) {
moveFilesToRecordDirRecursively(file, newDir, timeStamp, annexRecordList, recruitId,username,userId);
moveFilesToRecordDirRecursively(file, newDir, timeStamp, annexRecordList, recruitId, username, userId);
}
}
}
} 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());
try (InputStream in = new FileInputStream(source);
OutputStream out = new FileOutputStream(destFile)) {
@ -332,19 +338,17 @@ public class UploadZipController {
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();
System.out.println("上上一级文件名: " + parentName);
String[] split = parentName.split("_");
String card = split[1];
WgzUser wgzUser = wgzUserService.findByIdentityCard(card);
String name = destination.getName();
System.out.println("上一级文件名: " + name);
String type = "";
if ("保险".equals(name)) {
type = "2";
@ -352,18 +356,19 @@ public class UploadZipController {
if ("劳务合同".equals(name)) {
type = "1";
}
AnnexRecord annex = new AnnexRecord();
annex.setAnnexName(destFile.getName());
annex.setAnnexUrl(relativePath);
annex.setAnnexType(type);
annex.setUserType(Constants.WGZ);
annex.setUserId(wgzUser.getUserId());
annex.setRecruitId(recruitId);
annex.setCreateBy(username);
annex.setUpdateBy(username);
annex.setCreateUserId(userId);
annex.setCreateUserType(Constants.BGT);
annexRecordList.add(annex);
AnnexRecord annexRecord = new AnnexRecord();
annexRecord.setAnnexName(newFileName);
annexRecord.setAnnexUrl(relativePath);
annexRecord.setAnnexType(type);
annexRecord.setUserType(Constants.WGZ);
annexRecord.setUserId(wgzUser.getUserId());
annexRecord.setRecruitId(recruitId);
annexRecord.setCreateBy(username);
annexRecord.setUpdateBy(username);
annexRecord.setCreateUserId(userId);
annexRecord.setCreateUserType(Constants.BGT);
annexRecordList.add(annexRecord);
}
}

View File

@ -1,11 +1,13 @@
package com.ruoyi.common.utils;
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.context.SecurityContextHolder;
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;
}
/**
* 更新已登录用户的用户名
* @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);
}
}

View File

@ -111,8 +111,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
"/**/*.js"
).permitAll()
.antMatchers("/profile/**").anonymous()
.antMatchers("/common/download**").anonymous()
.antMatchers("/common/download/resource**").anonymous()
.antMatchers("/common/download**").permitAll()
.antMatchers("/common/download/resource**").permitAll()
.antMatchers("/doc.html").anonymous()
.antMatchers("/swagger-resources/**").anonymous()
.antMatchers("/webjars/**").anonymous()

View File

@ -443,6 +443,12 @@ public class BgtProjectRecruitApplyServiceImpl extends ServicePlusImpl<BgtProjec
@Transactional(rollbackFor = Exception.class)
public Boolean quit(Long id) {
BgtProjectRecruitApply recruitApply = getById(id);
if(RecruitApplyStatus.OUT_WORK.getCode().equals(recruitApply.getStatus())){
throw new BaseException("您已退场!");
}
BgtProjectRecruit recruit = iBgtProjectRecruitService.getById(recruitApply.getRecruitId());
if(RecruitStatus.FULL.getCode().equals(recruit.getStatus())){
recruit.setStatus(RecruitStatus.PROGRESS.getCode());

View File

@ -482,9 +482,6 @@ public class WgzAttendanceServiceImpl extends ServicePlusImpl<WgzAttendanceMappe
bgtAttendanceVO.setReportToDutyRate(rate);
}
//缺勤人数
bgtAttendanceVO.setAbsenceDutyNum(totalNum-bgtAttendanceVO.getReportToDutyNum());
//任务拥有的所有招工
List<BgtProjectRecruit> bgtProjectRecruits = iBgtProjectRecruitService.getBaseMapper().selectList(Wrappers.<BgtProjectRecruit>lambdaQuery()
.eq(BgtProjectRecruit::getTaskId, dto.getTaskId()));
@ -505,6 +502,11 @@ public class WgzAttendanceServiceImpl extends ServicePlusImpl<WgzAttendanceMappe
.in(WgzAttendance::getRecruitId, recruitIds).eq(WgzAttendance::getDate, date));
bgtAttendanceVO.setEarlyLeaveNum(earlyLeaveNum);
}
//缺勤人数
bgtAttendanceVO.setAbsenceDutyNum(totalNum-bgtAttendanceVO.getReportToDutyNum()-bgtAttendanceVO.getLeaveNum());
return bgtAttendanceVO;
}

View File

@ -286,10 +286,12 @@ public class WgzLeaveServiceImpl extends ServicePlusImpl<WgzLeaveMapper, WgzLeav
@Transactional(rollbackFor = Exception.class)
public Boolean bgtAudit(BgtLeaveUpdateDTO dto) {
WgzLeave wgzLeave = getById(dto.getId());
if(!AuditStatus.UNREAD.getCode().equals(wgzLeave.getAuditorType())){
throw new BaseException("该条请假申请状态已改变,请刷新页面");
if(AuditStatus.getAudit().contains(wgzLeave.getAuditorType())){
throw new BaseException("该条请假已审批");
}
BeanUtil.copyProperties(dto, wgzLeave);
if(AuditStatus.getAudit().contains(dto.getAuditorType())){
wgzLeave.setAuditorTime(LocalDateTime.now());
BgtProjectRecruit recruit = iBgtProjectRecruitService.getById(wgzLeave.getRecruitId());
@ -311,6 +313,9 @@ public class WgzLeaveServiceImpl extends ServicePlusImpl<WgzLeaveMapper, WgzLeav
.setMessageSmallType(SMALL_LEAVE);
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())){
//考勤信息
List<WgzAttendance> list = attendanceService.list(Wrappers.<WgzAttendance>lambdaQuery()
@ -333,10 +338,7 @@ public class WgzLeaveServiceImpl extends ServicePlusImpl<WgzLeaveMapper, WgzLeav
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);
}

View File

@ -112,6 +112,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
wu.identity_card,
bpr.recruit_name,
fpt.task_name,
bpra.status,
bpra.task_id,
bpra.recruit_id,
CASE