Merge remote-tracking branch 'origin/master'
This commit is contained in:
@ -27,6 +27,7 @@ import com.ruoyi.common.enums.RecruitStatus;
|
|||||||
import com.ruoyi.common.exception.BaseException;
|
import com.ruoyi.common.exception.BaseException;
|
||||||
import com.ruoyi.common.service.IAnnexService;
|
import com.ruoyi.common.service.IAnnexService;
|
||||||
import com.ruoyi.common.service.IAsyncService;
|
import com.ruoyi.common.service.IAsyncService;
|
||||||
|
import com.ruoyi.common.service.IWgzService;
|
||||||
import com.ruoyi.common.utils.PageUtils;
|
import com.ruoyi.common.utils.PageUtils;
|
||||||
import com.ruoyi.common.utils.SecurityUtils;
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
import com.ruoyi.system.service.ISysDictTypeService;
|
import com.ruoyi.system.service.ISysDictTypeService;
|
||||||
@ -89,6 +90,9 @@ public class BgtProjectRecruitApplyServiceImpl extends ServicePlusImpl<BgtProjec
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IAsyncService iAsyncService;
|
private IAsyncService iAsyncService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IWgzService iWgzService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BgtProjectRecruitApply queryById(Long id) {
|
public BgtProjectRecruitApply queryById(Long id) {
|
||||||
return getById(id);
|
return getById(id);
|
||||||
@ -559,9 +563,10 @@ public class BgtProjectRecruitApplyServiceImpl extends ServicePlusImpl<BgtProjec
|
|||||||
//2、当前申请报名的工地信息
|
//2、当前申请报名的工地信息
|
||||||
BgtProjectRecruitApply recruitApply = queryById(req.getRecruitApplyId());
|
BgtProjectRecruitApply recruitApply = queryById(req.getRecruitApplyId());
|
||||||
BgtProjectRecruit recruit = iBgtProjectRecruitService.getAppById(recruitApply.getRecruitId());
|
BgtProjectRecruit recruit = iBgtProjectRecruitService.getAppById(recruitApply.getRecruitId());
|
||||||
//数据库行级锁
|
//数据库行级锁(判断是否满员或失效 )
|
||||||
String s = iWgzMessageService.JudgingRecruitment(recruit.getId(), recruit.getRecruitStaffNum(), recruit.getRecruitEndTime());
|
Map<String, Object> judMp = iWgzMessageService.JudgingRecruitment(recruit.getId(), recruit.getRecruitStaffNum(), recruit.getRecruitEndTime());
|
||||||
switch (s) {
|
String status = judMp.get("status").toString();
|
||||||
|
switch (status) {
|
||||||
case "1":
|
case "1":
|
||||||
//异步修改状态为已招满
|
//异步修改状态为已招满
|
||||||
iAsyncService.updateRecruitStatus(recruit);
|
iAsyncService.updateRecruitStatus(recruit);
|
||||||
@ -569,6 +574,15 @@ public class BgtProjectRecruitApplyServiceImpl extends ServicePlusImpl<BgtProjec
|
|||||||
case "2":
|
case "2":
|
||||||
throw new RuntimeException("已失效!");
|
throw new RuntimeException("已失效!");
|
||||||
}
|
}
|
||||||
|
// int count = ((Number) judMp.get("count")).intValue();
|
||||||
|
// if (count > 0){
|
||||||
|
// throw new RuntimeException("您已在其他工地!");
|
||||||
|
// }
|
||||||
|
//数据库行级锁(是否进入其他工地)
|
||||||
|
Integer i = iWgzService.QueryWhetherTheCurrentUserHasAnOngoingProject(byUserId.getUserId());
|
||||||
|
if (i>0) {
|
||||||
|
throw new RuntimeException("您已在其他工地!");
|
||||||
|
}
|
||||||
//3、更新报名状态、及更新消息的操作状态(用户同意更新进场时间、状态;用户拒绝更新状态)
|
//3、更新报名状态、及更新消息的操作状态(用户同意更新进场时间、状态;用户拒绝更新状态)
|
||||||
BgtProjectRecruitApply apply = new BgtProjectRecruitApply();
|
BgtProjectRecruitApply apply = new BgtProjectRecruitApply();
|
||||||
apply.setId(req.getRecruitApplyId());
|
apply.setId(req.getRecruitApplyId());
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
package com.ruoyi.common.mapper;
|
||||||
|
|
||||||
|
import com.ruoyi.bgt.domain.BgtProjectRecruitApply;
|
||||||
|
import com.ruoyi.common.core.mybatisplus.cache.MybatisPlusRedisCache;
|
||||||
|
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
|
||||||
|
import com.ruoyi.common.domain.Annex;
|
||||||
|
import org.apache.ibatis.annotations.CacheNamespace;
|
||||||
|
import org.apache.ibatis.annotations.Options;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 务工者Mapper接口
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2025-02-14
|
||||||
|
*/
|
||||||
|
// 如使需切换数据源 请勿使用缓存 会造成数据不一致现象
|
||||||
|
@CacheNamespace(implementation = MybatisPlusRedisCache.class, eviction = MybatisPlusRedisCache.class)
|
||||||
|
public interface WgzMapper extends BaseMapperPlus<BgtProjectRecruitApply> {
|
||||||
|
|
||||||
|
@Select("SELECT count(1) FROM bgt_project_recruit_apply WHERE user_id = #{userId} and status in ('3','5') FOR UPDATE")
|
||||||
|
@Options(useCache = false) // 禁用 MyBatis 缓存
|
||||||
|
Integer QueryWhetherTheCurrentUserHasAnOngoingProject(@Param("userId") Long userId);
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package com.ruoyi.common.service;
|
||||||
|
|
||||||
|
import com.ruoyi.bgt.domain.BgtProjectRecruitApply;
|
||||||
|
import com.ruoyi.common.core.mybatisplus.core.IServicePlus;
|
||||||
|
|
||||||
|
public interface IWgzService extends IServicePlus<BgtProjectRecruitApply> {
|
||||||
|
//行级锁-查询当前用户是否已有进行中项目
|
||||||
|
Integer QueryWhetherTheCurrentUserHasAnOngoingProject(Long userId);
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.ruoyi.common.service.impl;
|
||||||
|
|
||||||
|
import com.ruoyi.bgt.domain.BgtProjectRecruitApply;
|
||||||
|
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
||||||
|
import com.ruoyi.common.mapper.WgzMapper;
|
||||||
|
import com.ruoyi.common.service.IWgzService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class WgzServiceImpl extends ServicePlusImpl<WgzMapper, BgtProjectRecruitApply> implements IWgzService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer QueryWhetherTheCurrentUserHasAnOngoingProject(Long userId) {
|
||||||
|
return baseMapper.QueryWhetherTheCurrentUserHasAnOngoingProject(userId);
|
||||||
|
}
|
||||||
|
}
|
@ -31,6 +31,7 @@ public class WgzAppRegisteredProjectRes implements Serializable {
|
|||||||
private String recruitName;
|
private String recruitName;
|
||||||
|
|
||||||
@ApiModelProperty("创建时间/报名时间")
|
@ApiModelProperty("创建时间/报名时间")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd", shape = JsonFormat.Shape.STRING)
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
@ApiModelProperty("封面图(多个逗号分隔)")
|
@ApiModelProperty("封面图(多个逗号分隔)")
|
||||||
|
@ -15,6 +15,7 @@ import org.springframework.validation.annotation.Validated;
|
|||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 消息Service接口
|
* 消息Service接口
|
||||||
@ -91,7 +92,7 @@ public interface IWgzMessageService extends IServicePlus<WgzMessage> {
|
|||||||
/**
|
/**
|
||||||
* 判断招工是否已招满或已过期
|
* 判断招工是否已招满或已过期
|
||||||
*/
|
*/
|
||||||
String JudgingRecruitment(Long recruitId, int num, LocalDate recruitEndTime);
|
Map<String, Object> JudgingRecruitment(Long recruitId, int num, LocalDate recruitEndTime);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改已读未读状态
|
* 修改已读未读状态
|
||||||
|
@ -249,6 +249,7 @@ public class WgzDailyClockServiceImpl extends ServicePlusImpl<WgzDailyClockMappe
|
|||||||
if ( insert > 0 && req.getStatus().equals("1")){
|
if ( insert > 0 && req.getStatus().equals("1")){
|
||||||
WgzUser byId = wgzUserService.findByUserId(appUserId);
|
WgzUser byId = wgzUserService.findByUserId(appUserId);
|
||||||
Map<String, String> mp = new HashMap<>();
|
Map<String, String> mp = new HashMap<>();
|
||||||
|
mp.put("userName",byId.getUsername());
|
||||||
mp.put("data",String.valueOf(LocalDate.now()));
|
mp.put("data",String.valueOf(LocalDate.now()));
|
||||||
WgzMessage wgzMessage = new WgzMessage().
|
WgzMessage wgzMessage = new WgzMessage().
|
||||||
setSenderType(USERTYPE_SYSTEM).
|
setSenderType(USERTYPE_SYSTEM).
|
||||||
|
@ -212,7 +212,8 @@ public class WgzMessageServiceImpl extends ServicePlusImpl<WgzMessageMapper, Wgz
|
|||||||
//2、根据招工ID得到招工信息及附件
|
//2、根据招工ID得到招工信息及附件
|
||||||
WgzAppRegistrationInformationRes byRecruitIdData = baseMapper.findByRecruitIdData(byId.getTableId());
|
WgzAppRegistrationInformationRes byRecruitIdData = baseMapper.findByRecruitIdData(byId.getTableId());
|
||||||
byRecruitIdData.setMessageId(byId.getId()).setIsOperation(byId.getIsOperation());
|
byRecruitIdData.setMessageId(byId.getId()).setIsOperation(byId.getIsOperation());
|
||||||
byRecruitIdData.setFull(JudgingRecruitment(byId.getTableId(), Integer.parseInt(byRecruitIdData.getRecruitStaffNum()), byRecruitIdData.getRecruitEndTime()));
|
Map<String, Object> stringObjectMap = JudgingRecruitment(byId.getTableId(), Integer.parseInt(byRecruitIdData.getRecruitStaffNum()), byRecruitIdData.getRecruitEndTime());
|
||||||
|
byRecruitIdData.setFull(stringObjectMap.get("status").toString());
|
||||||
return byRecruitIdData;
|
return byRecruitIdData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,15 +232,20 @@ public class WgzMessageServiceImpl extends ServicePlusImpl<WgzMessageMapper, Wgz
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String JudgingRecruitment(Long recruitId,int num,LocalDate recruitEndTime) {
|
public Map<String, Object> JudgingRecruitment(Long recruitId,int num,LocalDate recruitEndTime) {
|
||||||
|
Map<String, Object> mp = new HashMap<>();
|
||||||
//使用数据库行级锁
|
//使用数据库行级锁
|
||||||
int count = baseMapper.countRecruitApply(recruitId);
|
int count = baseMapper.countRecruitApply(recruitId);
|
||||||
if(count == num){
|
mp.put("count", count);
|
||||||
return "1"; //已招满
|
|
||||||
}
|
|
||||||
if (LocalDate.now().isAfter(recruitEndTime)){
|
if (LocalDate.now().isAfter(recruitEndTime)){
|
||||||
return "2"; //已失效
|
mp.put("status", "2");
|
||||||
|
return mp; //已失效
|
||||||
}
|
}
|
||||||
return "0";
|
if(count == num){
|
||||||
|
mp.put("status", "1");
|
||||||
|
return mp; //已招满
|
||||||
|
}
|
||||||
|
mp.put("status", "0");
|
||||||
|
return mp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
c.task_name,
|
c.task_name,
|
||||||
c.task_address,
|
c.task_address,
|
||||||
c.task_img,
|
c.task_img,
|
||||||
|
c.create_time as taskCreateTime,
|
||||||
d.dict_label AS typeOfWorkLabel,
|
d.dict_label AS typeOfWorkLabel,
|
||||||
(SELECT count(1) FROM bgt_project_recruit_apply WHERE recruit_id = b.id) as numberOfRegistered
|
(SELECT count(1) FROM bgt_project_recruit_apply WHERE recruit_id = b.id) as numberOfRegistered
|
||||||
FROM
|
FROM
|
||||||
|
10
ruoyi-system/src/main/resources/mapper/common/WgzMapper.xml
Normal file
10
ruoyi-system/src/main/resources/mapper/common/WgzMapper.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.ruoyi.common.mapper.WgzMapper">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</mapper>
|
Reference in New Issue
Block a user