优化
This commit is contained in:
@ -662,18 +662,21 @@ public class BgtProjectRecruitApplyServiceImpl extends ServicePlusImpl<BgtProjec
|
||||
bgtProjectRecruitApply.setId(recruitApplyId);
|
||||
bgtProjectRecruitApply.setStatus("7");
|
||||
if (baseMapper.updateById(bgtProjectRecruitApply) > 0) {
|
||||
Long appUserId = SecurityUtils.getAppUserId();
|
||||
BgtProjectRecruitApply by = baseMapper.selectById(recruitApplyId);
|
||||
BgtProjectRecruit appById = iBgtProjectRecruitService.getAppById(by.getRecruitId());
|
||||
|
||||
//状态取消成功需要把对应消息的状态变更为【不需要操作】
|
||||
iBgtMessageService.operation(
|
||||
USERTYPE_WGZ,
|
||||
recruitApply.getUserId(),
|
||||
USERTYPE_BGT,
|
||||
SecurityUtils.getAppUserId(),
|
||||
appById.getUserId(),
|
||||
recruitApply.getId(),
|
||||
SqlHelper.table(BgtProjectRecruitApply.class).getTableName()
|
||||
);
|
||||
Long appUserId = SecurityUtils.getAppUserId();
|
||||
BgtProjectRecruitApply by = baseMapper.selectById(recruitApplyId);
|
||||
BgtProjectRecruit appById = iBgtProjectRecruitService.getAppById(by.getRecruitId());
|
||||
|
||||
|
||||
Map<String, String> mp = new HashMap<>();
|
||||
mp.put("projectName", appById.getRecruitName());
|
||||
//发送取消报名的系统消息
|
||||
@ -713,25 +716,28 @@ public class BgtProjectRecruitApplyServiceImpl extends ServicePlusImpl<BgtProjec
|
||||
BgtProjectRecruitApply recruitApply = queryById(req.getRecruitApplyId());
|
||||
BgtProjectRecruit recruit = iBgtProjectRecruitService.getAppById(recruitApply.getRecruitId());
|
||||
//数据库行级锁(判断是否满员或失效 )
|
||||
Map<String, Object> judMp = iWgzMessageService.JudgingRecruitment(recruit.getId(), recruit.getRecruitStaffNum(), recruit.getRecruitEndTime());
|
||||
String status = judMp.get("status").toString();
|
||||
switch (status) {
|
||||
case "1":
|
||||
if (req.getStatus().equals("3")) {
|
||||
Map<String, Object> judMp = iWgzMessageService.JudgingRecruitment(recruit.getId(), recruit.getRecruitStaffNum(), recruit.getRecruitEndTime());
|
||||
String status = judMp.get("status").toString();
|
||||
switch (status) {
|
||||
case "1":
|
||||
// //异步修改状态为已招满
|
||||
// iAsyncService.updateRecruitStatus(recruit);
|
||||
throw new RuntimeException("已招满!");
|
||||
case "2":
|
||||
throw new RuntimeException("已失效!");
|
||||
}
|
||||
int count = ((Number) judMp.get("count")).intValue() + 1;
|
||||
if (count == recruit.getRecruitStaffNum()){
|
||||
iAsyncService.updateRecruitStatus(recruit);
|
||||
}
|
||||
//数据库行级锁(是否进入其他工地)
|
||||
Integer i = iWgzService.QueryWhetherTheCurrentUserHasAnOngoingProject(byUserId.getUserId());
|
||||
if (i>0) {
|
||||
throw new RuntimeException("您已在其他工地!");
|
||||
throw new RuntimeException("已招满!");
|
||||
case "2":
|
||||
throw new RuntimeException("已失效!");
|
||||
}
|
||||
int count = ((Number) judMp.get("count")).intValue() + 1;
|
||||
if (count == recruit.getRecruitStaffNum()){
|
||||
iAsyncService.updateRecruitStatus(recruit);
|
||||
}
|
||||
//数据库行级锁(是否进入其他工地)
|
||||
Integer i = iWgzService.QueryWhetherTheCurrentUserHasAnOngoingProject(byUserId.getUserId());
|
||||
if (i>0) {
|
||||
throw new RuntimeException("您已在其他工地!");
|
||||
}
|
||||
}
|
||||
|
||||
//3、更新报名状态、及更新消息的操作状态(用户同意更新进场时间、状态;用户拒绝更新状态)
|
||||
BgtProjectRecruitApply apply = new BgtProjectRecruitApply();
|
||||
apply.setId(req.getRecruitApplyId());
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.ruoyi.common.util;
|
||||
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.ruoyi.common.core.redis.RedisCache;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
@ -8,6 +9,8 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@ -22,11 +25,27 @@ public class SseUtil {
|
||||
public static final String FBS_PREFIX = "fbs-";
|
||||
public static final String ZBF_PREFIX = "zbf-";
|
||||
public static SseEmitter subscribe(String userId,String prefix) {
|
||||
// Spring Boot 2.4.7中SseEmitter构造函数支持超时时间(单位:毫秒)
|
||||
SseEmitter emitter = new SseEmitter(1 * 60 * 1000L); // 30分钟超时
|
||||
// Spring Boot 2.4.7中SseEmitter构造函数支持超时时间(单位:毫秒) 30 * 60
|
||||
SseEmitter emitter = new SseEmitter(30 * 60 * 1000L); // 30分钟超时
|
||||
|
||||
// 存储emitter并设置回调(2.4.7中回调机制与主流版本一致)
|
||||
String key = prefix + "-" +userId;
|
||||
SseEmitter sseEmitter = emitterMap.get(key);
|
||||
if(sseEmitter!=null){
|
||||
try {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("code",401);
|
||||
map.put("msg","您已在其他地方登录,请重新登录");
|
||||
sseEmitter.send(SseEmitter.event()
|
||||
// .id("init")
|
||||
// .name(name)
|
||||
.data(JSONUtil.toJsonStr(map))
|
||||
);
|
||||
} catch (IOException e) {
|
||||
sseEmitter.completeWithError(e);
|
||||
}
|
||||
}
|
||||
|
||||
emitterMap.put(key, emitter);
|
||||
|
||||
// 利用闭包特性捕获userId和prefix
|
||||
@ -34,10 +53,13 @@ public class SseUtil {
|
||||
emitter.onTimeout(() -> {
|
||||
emitter.complete();
|
||||
emitterMap.remove(key);
|
||||
log.info("用户{}连接已超时", key);
|
||||
log.info("时间:{},用户{}连接已超时", LocalDateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss"),key);
|
||||
});
|
||||
emitter.onError(e -> {
|
||||
emitter.completeWithError(e);
|
||||
emitterMap.remove(key);
|
||||
log.warn("用户{}连接异常: {}", key, e.getMessage());
|
||||
});
|
||||
emitter.onError(e -> emitterMap.remove(key));
|
||||
|
||||
String redisKey = "messageCount:"+prefix+":"+userId;
|
||||
|
||||
Object cacheObj = SpringUtils.getBean(RedisCache.class).getCacheObject(redisKey);
|
||||
|
@ -713,7 +713,6 @@ public class WgzPayCalculationServiceImpl extends ServicePlusImpl<WgzPayCalculat
|
||||
//金额*天数=实际工资
|
||||
total = total.add(wgzPayCalculation.getRecruitAmount().multiply(new BigDecimal(wgzPayCalculation.getNum())));
|
||||
}
|
||||
|
||||
return total;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user