Commit 5cc374ce by 谢海旭

学习中心

1 parent eeba21fa
...@@ -29,4 +29,8 @@ public interface LearningCenterLevelExamRemote { ...@@ -29,4 +29,8 @@ public interface LearningCenterLevelExamRemote {
@ApiParam(name = "dto", notes = "新增等级考试信息", dataType = ApiParam.DataTypeEnum.OBJECT, required = true) @ApiParam(name = "dto", notes = "新增等级考试信息", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("等级考试id") @ApiResponse("等级考试id")
RpcResponse<Integer> addLevelExam(@NotNull LevelExamDetailDTO request); RpcResponse<Integer> addLevelExam(@NotNull LevelExamDetailDTO request);
@ApiMethod("等级考试-失效|生效")
@ApiParam(name = "dto", notes = "等级考试信息", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
RpcResponse<String> levelExamStatusToggle(@NotNull LevelExamDetailDTO request);
} }
...@@ -90,7 +90,10 @@ ...@@ -90,7 +90,10 @@
<artifactId>rpc-dj-beisen-api</artifactId> <artifactId>rpc-dj-beisen-api</artifactId>
<version>5.5.0-SNAPSHOT</version> <version>5.5.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<groupId>org.oreframework.boot</groupId>
<artifactId>ore-boot-starter-distribute-lock</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>
\ No newline at end of file \ No newline at end of file
...@@ -47,4 +47,18 @@ public class LearningCenterLevelExamRemoteImpl implements LearningCenterLevelExa ...@@ -47,4 +47,18 @@ public class LearningCenterLevelExamRemoteImpl implements LearningCenterLevelExa
return RpcResponse.error(e); return RpcResponse.error(e);
} }
} }
@Override
public RpcResponse<String> levelExamStatusToggle(LevelExamDetailDTO request) {
try {
learningCenterLevelExamService.levelExamStatusToggle(request);
return RpcResponse.success("success");
}catch(RpcServiceException e){
log.error(e.getMessage(),e);
return RpcResponse.error(e);
}catch(Exception e){
log.error(e.getMessage(),e);
return RpcResponse.error(e);
}
}
} }
...@@ -18,6 +18,7 @@ import com.github.pagehelper.PageHelper; ...@@ -18,6 +18,7 @@ import com.github.pagehelper.PageHelper;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.oreframework.distribute.lock.annotation.GlsxDistributeLockable;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -33,19 +34,19 @@ import java.util.stream.Collectors; ...@@ -33,19 +34,19 @@ import java.util.stream.Collectors;
@RequiredArgsConstructor @RequiredArgsConstructor
public class LearningCenterLevelExamService { public class LearningCenterLevelExamService {
@Autowired @Autowired
private LearningCenterLevelExamMapper learningCenterLevelExamMapper; private LearningCenterLevelExamMapper levelExamMapper;
@Autowired @Autowired
private LearningCenterLevelExamLevelMapper levelExamLevelMapper; private LearningCenterLevelExamLevelMapper levelExamLevelMapper;
public Page<LevelExamPageListResponseDTO> levelExamListPage(RpcPagination<LevelExamPageListRequestDTO> pagination) { public Page<LevelExamPageListResponseDTO> levelExamListPage(RpcPagination<LevelExamPageListRequestDTO> pagination) {
Page<LevelExamPageListResponseDTO> page = PageHelper.startPage(pagination.getPageNum(), pagination.getPageSize(),pagination.isNeedCount()); Page<LevelExamPageListResponseDTO> page = PageHelper.startPage(pagination.getPageNum(), pagination.getPageSize(),pagination.isNeedCount());
List<LevelExamPageListResponseDTO> responseDTOS = learningCenterLevelExamMapper.levelExamListPage(pagination.getCondition()); List<LevelExamPageListResponseDTO> responseDTOS = levelExamMapper.levelExamListPage(pagination.getCondition());
return page; return page;
} }
public LevelExamDetailResponseDTO getLevelExamDetail(Integer id) { public LevelExamDetailResponseDTO getLevelExamDetail(Integer id) {
LearningCenterLevelExam learningCenterLevelExam = learningCenterLevelExamMapper.selectByPrimaryKey(id); LearningCenterLevelExam learningCenterLevelExam = levelExamMapper.selectByPrimaryKey(id);
if (learningCenterLevelExam == null) { if (learningCenterLevelExam == null) {
return null; return null;
} }
...@@ -82,9 +83,10 @@ public class LearningCenterLevelExamService { ...@@ -82,9 +83,10 @@ public class LearningCenterLevelExamService {
.andEqualTo("departmentId", departmentId) .andEqualTo("departmentId", departmentId)
.andEqualTo("positionCode", positionCode) .andEqualTo("positionCode", positionCode)
.andEqualTo("examTime", examTime) .andEqualTo("examTime", examTime)
.andEqualTo("status", LevelExamStatusEnum.EFFECTIVE.getValue())
.andEqualTo("deletedFlag", BaseModel.DeletedFlagEnum.N.name()); .andEqualTo("deletedFlag", BaseModel.DeletedFlagEnum.N.name());
int existCount = learningCenterLevelExamMapper.selectCountByExample(repeatQueryExample); int existCount = levelExamMapper.selectCountByExample(repeatQueryExample);
if (existCount == 0) { if (existCount != 0) {
log.info("存在重复等级考试 existCount:{}", existCount); log.info("存在重复等级考试 existCount:{}", existCount);
throw new RpcServiceException(RiskmanageErrorEnum.BUSINESS_ERROR, "存在重复等级考试,请修改后提交"); throw new RpcServiceException(RiskmanageErrorEnum.BUSINESS_ERROR, "存在重复等级考试,请修改后提交");
} }
...@@ -115,7 +117,7 @@ public class LearningCenterLevelExamService { ...@@ -115,7 +117,7 @@ public class LearningCenterLevelExamService {
} }
} }
learningCenterLevelExamMapper.insertSelective(levelExam); levelExamMapper.insertSelective(levelExam);
Integer levelExamId = levelExam.getId(); Integer levelExamId = levelExam.getId();
String createdBy = request.getCreatedBy(); String createdBy = request.getCreatedBy();
...@@ -138,4 +140,46 @@ public class LearningCenterLevelExamService { ...@@ -138,4 +140,46 @@ public class LearningCenterLevelExamService {
public void levelExamTakeEffect() { public void levelExamTakeEffect() {
levelExamLevelMapper.updateLevelExamTakeEffect(); levelExamLevelMapper.updateLevelExamTakeEffect();
} }
@GlsxDistributeLockable(name="'LearningCenterLevelExamService_levelExamStatusToggle_' + #request.id", timeoutException=RpcServiceException.class)
@Transactional
public void levelExamStatusToggle(LevelExamDetailDTO request) {
Integer id = request.getId();
LearningCenterLevelExam levelExam = levelExamMapper.selectByPrimaryKey(id);
if (levelExam == null || levelExam.getDeletedFlag().equals(BaseModel.DeletedFlagEnum.D.name())) {
throw new RpcServiceException(RiskmanageErrorEnum.BUSINESS_ERROR, "等级考试不存在");
}
Byte status = levelExam.getStatus();
if (LevelExamStatusEnum.EFFECTIVE.getValue().compareTo(status) == 0) {
LearningCenterLevelExam update = new LearningCenterLevelExam();
update.setId(id);
update.setStatus(LevelExamStatusEnum.INVALID.getValue());
update.setUpdatedBy(request.getUpdatedBy());
update.setUpdatedDate(new Date());
levelExamMapper.updateByPrimaryKeySelective(update);
} else if (LevelExamStatusEnum.INVALID.getValue().compareTo(status) == 0) {
Example repeatQueryExample = new Example(LearningCenterLevelExam.class);
Example.Criteria repeatQueryCriteria = repeatQueryExample.createCriteria();
repeatQueryCriteria
.andEqualTo("beisenExamId", levelExam.getBeisenExamId())
.andEqualTo("departmentId", levelExam.getDepartmentId())
.andEqualTo("positionCode", levelExam.getPositionCode())
.andEqualTo("examTime", levelExam.getExamTime())
.andEqualTo("status", LevelExamStatusEnum.EFFECTIVE.getValue())
.andEqualTo("deletedFlag", BaseModel.DeletedFlagEnum.N.name());
int existCount = levelExamMapper.selectCountByExample(repeatQueryExample);
if (existCount != 0) {
log.info("存在重复等级考试 existCount:{}", existCount);
throw new RpcServiceException(RiskmanageErrorEnum.BUSINESS_ERROR, "已存在相同生效的考试");
}
LearningCenterLevelExam update = new LearningCenterLevelExam();
update.setId(id);
update.setStatus(LevelExamStatusEnum.EFFECTIVE.getValue());
update.setUpdatedBy(request.getUpdatedBy());
update.setUpdatedDate(new Date());
levelExamMapper.updateByPrimaryKeySelective(update);
}
}
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!