优化
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.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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
||||
|
||||
// /**
|
||||
// * 获取用户信息
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -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());
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -286,57 +286,59 @@ 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);
|
||||
wgzLeave.setAuditorTime(LocalDateTime.now());
|
||||
BgtProjectRecruit recruit = iBgtProjectRecruitService.getById(wgzLeave.getRecruitId());
|
||||
|
||||
//发消息
|
||||
HashMap<String, String> mp = new HashMap<>();
|
||||
mp.put("projectName",recruit.getRecruitName());
|
||||
mp.put("auditor",SecurityUtils.getUsername());
|
||||
Map<String, String> map = bgtMessage(mp, BGT_TYPE_LEAVE, AuditStatus.PASS.getCode().equals(dto.getAuditorType()));
|
||||
WgzMessage wgzMessage = new WgzMessage()
|
||||
.setSenderType(USERTYPE_BGT)
|
||||
.setSenderId(SecurityUtils.getAppUserId())
|
||||
.setRecipientType(USERTYPE_WGZ)
|
||||
.setRecipientId(wgzLeave.getUserId())
|
||||
.setHeadline(map.get(HEADLINE))
|
||||
.setSubheading(map.get(SUBHEADING))
|
||||
.setTableId(wgzLeave.getId())
|
||||
.setTableName(SqlHelper.table(WgzLeave.class).getTableName())
|
||||
.setMessageLargeType(LARGE_OTHER)
|
||||
.setMessageSmallType(SMALL_LEAVE);
|
||||
iWgzMessageService.sendAMessage(wgzMessage);
|
||||
if(AuditStatus.getAudit().contains(dto.getAuditorType())){
|
||||
wgzLeave.setAuditorTime(LocalDateTime.now());
|
||||
BgtProjectRecruit recruit = iBgtProjectRecruitService.getById(wgzLeave.getRecruitId());
|
||||
|
||||
if(AuditStatus.PASS.getCode().equals(dto.getAuditorType())){
|
||||
//考勤信息
|
||||
List<WgzAttendance> list = attendanceService.list(Wrappers.<WgzAttendance>lambdaQuery()
|
||||
.eq(WgzAttendance::getRecruitId, recruit.getId())
|
||||
.eq(WgzAttendance::getUserId, wgzLeave.getUserId())
|
||||
.eq(WgzAttendance::getDate, wgzLeave.getStartTime().toLocalDate()));
|
||||
if(CollectionUtil.isNotEmpty(list)){
|
||||
WgzAttendance wgzAttendance = list.get(0);
|
||||
wgzAttendance.setLeaveMarkId(wgzLeave.getId());
|
||||
wgzAttendance.setExceptionType("7");
|
||||
attendanceService.updateById(wgzAttendance);
|
||||
}else {
|
||||
WgzAttendance wgzAttendance = new WgzAttendance();
|
||||
wgzAttendance.setRecruitId(recruit.getId());
|
||||
wgzAttendance.setUserId(wgzLeave.getUserId());
|
||||
wgzAttendance.setLeaveMarkId(wgzLeave.getId());
|
||||
wgzAttendance.setDailyWage(recruit.getRecruitAmount());
|
||||
wgzAttendance.setDate(wgzLeave.getStartTime().toLocalDate());
|
||||
wgzAttendance.setExceptionType("7");
|
||||
attendanceService.save(wgzAttendance);
|
||||
//发消息
|
||||
HashMap<String, String> mp = new HashMap<>();
|
||||
mp.put("projectName",recruit.getRecruitName());
|
||||
mp.put("auditor",SecurityUtils.getUsername());
|
||||
Map<String, String> map = bgtMessage(mp, BGT_TYPE_LEAVE, AuditStatus.PASS.getCode().equals(dto.getAuditorType()));
|
||||
WgzMessage wgzMessage = new WgzMessage()
|
||||
.setSenderType(USERTYPE_BGT)
|
||||
.setSenderId(SecurityUtils.getAppUserId())
|
||||
.setRecipientType(USERTYPE_WGZ)
|
||||
.setRecipientId(wgzLeave.getUserId())
|
||||
.setHeadline(map.get(HEADLINE))
|
||||
.setSubheading(map.get(SUBHEADING))
|
||||
.setTableId(wgzLeave.getId())
|
||||
.setTableName(SqlHelper.table(WgzLeave.class).getTableName())
|
||||
.setMessageLargeType(LARGE_OTHER)
|
||||
.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()
|
||||
.eq(WgzAttendance::getRecruitId, recruit.getId())
|
||||
.eq(WgzAttendance::getUserId, wgzLeave.getUserId())
|
||||
.eq(WgzAttendance::getDate, wgzLeave.getStartTime().toLocalDate()));
|
||||
if(CollectionUtil.isNotEmpty(list)){
|
||||
WgzAttendance wgzAttendance = list.get(0);
|
||||
wgzAttendance.setLeaveMarkId(wgzLeave.getId());
|
||||
wgzAttendance.setExceptionType("7");
|
||||
attendanceService.updateById(wgzAttendance);
|
||||
}else {
|
||||
WgzAttendance wgzAttendance = new WgzAttendance();
|
||||
wgzAttendance.setRecruitId(recruit.getId());
|
||||
wgzAttendance.setUserId(wgzLeave.getUserId());
|
||||
wgzAttendance.setLeaveMarkId(wgzLeave.getId());
|
||||
wgzAttendance.setDailyWage(recruit.getRecruitAmount());
|
||||
wgzAttendance.setDate(wgzLeave.getStartTime().toLocalDate());
|
||||
wgzAttendance.setExceptionType("7");
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user