Commit d8d42a3a by 谢海旭

学习中心 接口实现

1 parent b8010bb7
package cn.com.glsx.dj.riskmanage.dto.beisen;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@Data
public class BeisenEmployeeInfoDTO implements Serializable {
/**
* 员工UserID
*/
private Integer userID;
/**
* 姓名
*/
private String name;
/**
* 姓名(拼音)
*/
private String _Name;
/**
* 姓拼音
*/
private String phoneticOfXing;
/**
* 名拼音
*/
private String phoneticOfMing;
/**
* 性别:0男、1女
*/
private Integer gender;
/**
* 电子邮件
*/
private String email;
/**
* 证件类型(查看可用选项)
*/
private String iDType;
/**
* 证件号码
*/
private String iDNumber;
/**
* 时区,示例:Asia/Shanghai
*/
private String timeZone;
/**
* 是否长期证件
*/
private Boolean isLongTermCertificate;
/**
* 证件开始日期
*/
private Date certificateStartDate;
/**
* 证件截止日期
*/
private Date certificateValidityTerm;
/**
* 出生日期
*/
private Date birthday;
/**
* 参加工作日期
*/
private Date workDate;
/**
* 手机号码
*/
private String mobilePhone;
/**
* 微信
*/
private String weiXin;
/**
* 照片路径(DFS附件路径)
*/
private String idPhoto;
/**
* 照片缩略图路径
*/
private String smallIdPhoto;
/**
* 身份证人像面路径
*/
private String idPortraitSide;
/**
* 身份证国徽面路径
*/
private String idCountryEmblemSide;
/**
* 允许登录系统
*/
private Boolean allowToLoginIn;
/**
* 个人主页
*/
private String personalHomepage;
/**
* 专业
*/
private String major;
/**
* 邮政编码
*/
private String postalCode;
/**
* 护照号码
*/
private String passportNumber;
/**
* 星座
*/
private String constellation;
/**
* 血型
*/
private String bloodType;
/**
* 入党/团日期
*/
private Date joinPartyDate;
/**
* 户口类别(查看可用选项)
*/
private Integer domicileType;
/**
* 紧急联系人
*/
private String emergencyContact;
/**
* 紧急联系人与本人关系
*/
private String emergencyContactRelationship;
/**
* 紧急联系电话
*/
private String emergencyContactPhone;
/**
* QQ
*/
private String qq;
/**
* 家庭电话
*/
private String homePhone;
/**
* 毕业时间
*/
private Date graduateDate;
/**
* 婚姻状况(查看可用选项)
*/
private String marryCategory;
/**
* 政治面貌(查看可用选项)
*/
private String politicalStatus;
/**
* 国家(地区)(查看可用选项)
*/
private Integer nationality;
/**
* 民族(查看可用选项)
*/
private String nation;
/**
* 户籍所在地
*/
private String birthplace;
/**
* 籍贯(查看可用选项)
*/
private String registAddress;
/**
* 最高学历:1本科,2硕士研究生,3高中,4中技,5大专,6MBA,7博士研究生,8初中,9小学,10保密,120EMBA,130MPA
*/
private String educationLevel;
/**
* 毕业学校
*/
private String lastSchool;
/**
* 其他语言姓名
*/
private String engName;
/**
* 其他语言姓名_名
*/
private String firstname;
/**
* 其他语言姓名_姓
*/
private String lastname;
/**
* 办公电话
*/
private String officeTel;
/**
* 个人邮箱
*/
private String backupMail;
/**
* 应聘者id(招聘系统使用)
*/
private Integer applicantId;
/**
* 招聘申请id
*/
private String applyIdV6;
/**
* 应聘者id(只查询)
*/
private String applicantIdV6;
/**
* 年龄
*/
private Integer age;
/**
* 业务修改人
*/
private Integer businessModifiedBy;
/**
* 业务修改时间
*/
private Date businessModifiedTime;
/**
* 类型(查看可用选项)
*/
private Integer sourceType;
/**
* 首次进入公司日期
*/
private Date firstEntryDate;
/**
* 最新进入公司日期
*/
private Date latestEntryDate;
/**
* 导师UserID
*/
private Integer tutorNew;
/**
* 证件正面路径
*/
private String idFront;
/**
* 证件反面路径
*/
private String idBehind;
/**
* 预计退休日期
*/
private Date preRetireDate;
/**
* 实际退休日期
*/
private Date actualRetireDate;
/**
* 预计退休日期已核准
*/
private Boolean isConfirmRetireDate;
/**
* 账号激活状态:0未激活、1已激活
*/
private Byte activationState;
/**
* 签发机关
*/
private String issuingAuthority;
/**
* 是否残疾人
*/
private Boolean isDisabled;
/**
* 残疾证号
*/
private String disabledNumber;
/**
* 排序编码
*/
private Integer orderCode;
/**
* 业务对象实体主键GUID
*/
private String objectId;
/**
* 创建人员工UserID
*/
private Integer createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 修改人员工UserID
*/
private Integer modifiedBy;
/**
* 修改时间
*/
private Date modifiedTime;
/**
* 是否删除:0否,1是
*/
private Integer stdIsDeleted;
/**
* 在职状态:1.是,0.否
*/
private Integer zzStatus;
/**
* 离职时间
*/
private Date lastWorkDate;
/**
* 入职时间
*/
private Date entryDate;
private String homeAddress;
private String speciality;
private String residenceAddress;
private String aboutMe;
private String businessAddress;
private String oIdJobPost;
private String changeReason;
}
\ No newline at end of file
package cn.com.glsx.dj.riskmanage.enums.learningcenter;
/**
* @Title:
* @Description:
* @Author xiehx
* @Date 2025/11/27
**/
public enum BeisenExamStatusEnum {
NOT_PUBLISHED("10", "未发布"),
PUBLISHED("20", "已发布");
private String code;
private String message;
BeisenExamStatusEnum(String code, String message) {
this.code = code;
this.message = message;
}
public String getCode() {
return code;
}
public String getMessage() {
return message;
}
public static String getMessageByCode(String code) {
for (BeisenExamStatusEnum value : BeisenExamStatusEnum.values()) {
if (value.getCode().equals(code)) {
return value.getMessage();
}
}
return null;
}
public static BeisenExamStatusEnum getByCode(String code) {
for (BeisenExamStatusEnum value : BeisenExamStatusEnum.values()) {
if (value.getCode().equals(code)) {
return value;
}
}
return null;
}
}
package cn.com.glsx.dj.riskmanage.enums.learningcenter;
/**
* @Title:
* @Description:
* @Author xiehx
* @Date 2025/11/27
**/
public enum LevelExamPersonCompletedStatusEnum {
NOT_COMPLETED((byte) 0, "未完成"),
COMPLETED((byte) 1, "已完成");
private byte value;
private String name;
LevelExamPersonCompletedStatusEnum(byte value, String name) {
this.value = value;
this.name = name;
}
public byte getValue() {
return value;
}
public String getName() {
return name;
}
public static String getNameByValue(byte value) {
for (LevelExamPersonCompletedStatusEnum item : values()) {
if (item.getValue() == value) {
return item.getName();
}
}
return null;
}
public static byte getValueByName(String name) {
for (LevelExamPersonCompletedStatusEnum item : values()) {
if (item.getName().equals(name)) {
return item.getValue();
}
}
return -1;
}
}
......@@ -94,6 +94,10 @@
<groupId>org.oreframework.boot</groupId>
<artifactId>ore-boot-starter-distribute-lock</artifactId>
</dependency>
<dependency>
<groupId>org.oreframework</groupId>
<artifactId>ore-jms</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package cn.com.glsx.dj.riskmanage.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
/**
* @Title: kafka消息 topic
* @Description:
* @Author xiehx
* @Date 2025/111/26
**/
@Data
@Configuration
@ConfigurationProperties(prefix = "kafka.topic")
public class KafkaTopicConfig {
/**
* 等级考试推送 topic
*/
private String levelExamPushTopic;
}
package cn.com.glsx.dj.riskmanage.job.learningcenter;
import cn.com.glsx.dj.riskmanage.service.learningcenter.LearningCenterLevelExamService;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import lombok.extern.slf4j.Slf4j;
import org.oreframework.boot.autoconfigure.elasticjob.annotation.ElasticJobConf;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @Title:
* @Description: 推送等级考试给员工 任务
* @Author xiehx
* @Date 2025/11/25
**/
@Service
@Slf4j
@ElasticJobConf(name = "LevelExamPushJob", cron = "0 0 6-22 * * ?", description = "推送等级考试给员工 任务", overwrite = false)
public class LevelExamPushJob implements SimpleJob {
@Autowired
private LearningCenterLevelExamService levelExamService;
@Override
public void execute(ShardingContext shardingContext) {
log.info("推送等级考试给员工任务开始");
try {
levelExamService.pushLevelExam();
} catch (Exception e) {
log.error(e.getMessage(), e);
}
log.info("推送等级考试给员工任务结束");
}
}
......@@ -16,7 +16,7 @@ import org.springframework.stereotype.Service;
**/
@Service
@Slf4j
@ElasticJobConf(name = "LevelExamTakeEffectJob", cron = "0/5 * * * * ?", description = "等级考试-定时生效任务", overwrite = false)
@ElasticJobConf(name = "LevelExamTakeEffectJob", cron = "0 * * * * ?", description = "等级考试-定时生效任务", overwrite = false)
public class LevelExamTakeEffectJob implements SimpleJob {
@Autowired
......
package cn.com.glsx.dj.riskmanage.mqlistener;
import cn.com.glsx.dj.riskmanage.config.KafkaTopicConfig;
import cn.com.glsx.dj.riskmanage.service.learningcenter.LearningCenterLevelExamService;
import lombok.extern.slf4j.Slf4j;
import org.oreframework.jms.kafka.consumer.KafkaConsumer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* 等级考试推送 kafka消息消费
* 给符合条件的员工推送相应的考试
*
*/
@Slf4j
@Component
public class LearningCenterLevelExamPushConsumer extends KafkaConsumer {
@Autowired
private LearningCenterLevelExamService levelExamService;
public LearningCenterLevelExamPushConsumer(@Autowired KafkaTopicConfig kafkaTopicConfig) {
super(kafkaTopicConfig.getLevelExamPushTopic(), false);
}
@Override
public void processMessage(Object o) {
String msg = new String(getMessage());
log.info("等级考试推送kafka消息消费,处理开始,msg:{}", msg);
int levelExamId = Integer.parseInt(msg);
try {
levelExamService.pushExamToEmployees(levelExamId);
} catch (Exception e) {
log.error("等级考试推送员工失败 examId:{}", levelExamId, e);
}
log.info("等级考试推送kafka消息消费,处理结束,msg:{}", msg);
}
}
package cn.com.glsx.dj.riskmanage.service.learningcenter;
import cn.com.glsx.dj.riskmanage.dto.beisen.BeisenEmployeeInfoDTO;
import cn.com.glsx.dj.riskmanage.dto.beisen.OrganizationListResponseDTO;
import cn.com.glsx.dj.riskmanage.config.KafkaTopicConfig;
import cn.com.glsx.dj.riskmanage.dto.learningcenter.*;
import cn.com.glsx.dj.riskmanage.enums.RiskmanageErrorEnum;
import cn.com.glsx.dj.riskmanage.enums.learningcenter.BeisenExamStatusEnum;
import cn.com.glsx.dj.riskmanage.enums.learningcenter.LevelExamEffectiveTypeEnum;
import cn.com.glsx.dj.riskmanage.enums.learningcenter.LevelExamPersonCompletedStatusEnum;
import cn.com.glsx.dj.riskmanage.enums.learningcenter.LevelExamStatusEnum;
import cn.com.glsx.dj.riskmanage.mapper.BeiSenOrganizationMapper;
import cn.com.glsx.dj.riskmanage.mapper.beisen.BeiSenExaminationMapper;
import cn.com.glsx.dj.riskmanage.mapper.learningcenter.LearningCenterLevelExamLevelMapper;
import cn.com.glsx.dj.riskmanage.mapper.learningcenter.LearningCenterLevelExamMapper;
import cn.com.glsx.dj.riskmanage.mapper.learningcenter.LearningCenterLevelExamPersonMapper;
import cn.com.glsx.dj.riskmanage.model.BeiSenOrganization;
import cn.com.glsx.dj.riskmanage.model.examination.BeiSenExamination;
import cn.com.glsx.dj.riskmanage.model.learningcenter.LearningCenterLevelExam;
import cn.com.glsx.dj.riskmanage.model.learningcenter.LearningCenterLevelExamLevel;
import cn.com.glsx.dj.riskmanage.model.learningcenter.LearningCenterLevelExamPerson;
import cn.com.glsx.dj.riskmanage.model.learningcenter.LearningCenterTrainingPlanPerson;
import cn.com.glsx.dj.riskmanage.service.beisen.BeiSenOrganizationService;
import cn.com.glsx.framework.core.beans.BaseModel;
......@@ -24,8 +34,10 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.oreframework.distribute.lock.annotation.GlsxDistributeLockable;
import org.oreframework.jms.kafka.producer.KafkaProducer;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.task.TaskExecutor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
......@@ -33,6 +45,7 @@ import tk.mybatis.mapper.entity.Example;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
@Slf4j
......@@ -48,6 +61,24 @@ public class LearningCenterLevelExamService {
@Autowired
private BeiSenOrganizationService beiSenOrganizationService;
@Autowired
private TaskExecutor taskExecutor;
@Autowired
private KafkaProducer kafkaProducer;
@Autowired
private KafkaTopicConfig kafkaTopicConfig;
@Autowired
private LearningCenterLevelExamPersonMapper levelExamPersonMapper;
@Autowired
private BeiSenExaminationMapper beiSenExaminationMapper;
@Autowired
private BeiSenOrganizationMapper beiSenOrganizationMapper;
public Page<LevelExamPageListResponseDTO> levelExamListPage(RpcPagination<LevelExamPageListRequestDTO> pagination) {
Page<LevelExamPageListResponseDTO> page = PageHelper.startPage(pagination.getPageNum(), pagination.getPageSize(),pagination.isNeedCount());
LevelExamPageListRequestDTO condition = pagination.getCondition();
......@@ -134,7 +165,14 @@ public class LearningCenterLevelExamService {
Integer departmentId = request.getDepartmentId();
String positionCode = request.getPositionCode();
Integer examTime = request.getExamTime();
// TODO 获取北森考试信息,校验状态 只能是 已发布
BeiSenExamination beiSenExamination = beiSenExaminationMapper.selectByPrimaryKey(beisenExamId);
if (beiSenExamination == null || BaseModel.DeletedFlagEnum.D.name().equals(beiSenExamination.getDeletedFlag())) {
throw new RpcServiceException(RiskmanageErrorEnum.BUSINESS_ERROR, "考试不存在");
}
if (!BeisenExamStatusEnum.PUBLISHED.getCode().equals(beiSenExamination.getExamStatus())) {
throw new RpcServiceException(RiskmanageErrorEnum.BUSINESS_ERROR, "考试未发布");
}
List<LevelExamLevelDTO> examLevelDTOs = request.getLevelExamLevels();
if (CollectionUtils.isEmpty(examLevelDTOs) || examLevelDTOs.size() > 6) {
......@@ -162,8 +200,9 @@ public class LearningCenterLevelExamService {
levelExam.setUpdatedBy(levelExam.getCreatedBy());
levelExam.setUpdatedDate(new Date());
// TODO 查询部门信息
levelExam.setDepartmentName(null);
BeiSenOrganization organization = beiSenOrganizationMapper.selectByPrimaryKey(levelExam.getDepartmentId());
levelExam.setDepartmentName(organization.getName());
// TODO 查询职务信息
levelExam.setPositionName(null);
......@@ -248,4 +287,95 @@ public class LearningCenterLevelExamService {
levelExamMapper.updateByPrimaryKeySelective(update);
}
}
public void pushLevelExam() {
Example effectiveExamQueryExample = new Example(LearningCenterLevelExam.class);
Example.Criteria effectiveExamQueryCriteria = effectiveExamQueryExample.createCriteria();
effectiveExamQueryCriteria
.andEqualTo("status", LevelExamStatusEnum.EFFECTIVE.getValue())
.andEqualTo("deletedFlag", BaseModel.DeletedFlagEnum.N.name());
List<LearningCenterLevelExam> levelExams = levelExamMapper.selectByExample(effectiveExamQueryExample);
if (CollectionUtils.isEmpty(levelExams)) {
log.warn("无待推送等级考试");
return;
}
for (LearningCenterLevelExam levelExam : levelExams) {
Integer levelExamId = levelExam.getId();
try {
taskExecutor.execute(() -> {
kafkaProducer.send(kafkaTopicConfig.getLevelExamPushTopic(), levelExamId.toString().getBytes());
log.info("等级考试推送 mq发送成功 id:{}", levelExamId);
});
} catch (Exception e) {
log.error("等级考试推送 mq发送失败 id:{}", levelExamId, e);
}
}
}
/**
* 查询并推送等级考试给符合条件的员工
*
* @param levelExamId
*/
@Transactional
public void pushExamToEmployees(int levelExamId) {
LearningCenterLevelExam levelExam = levelExamMapper.selectByPrimaryKey(levelExamId);
if (levelExam == null || levelExam.getDeletedFlag().equals(BaseModel.DeletedFlagEnum.D.name())) {
log.info("等级考试不存在 id:{}", levelExamId);
return;
}
Byte status = levelExam.getStatus();
if (LevelExamStatusEnum.EFFECTIVE.getValue().compareTo(status) != 0) {
log.info("等级考试未生效 id:{}", levelExamId);
return;
}
// TODO dubbo 查询全部员工
List<BeisenEmployeeInfoDTO> employees = new ArrayList<>();
Integer examTime = levelExam.getExamTime();
employees = employees.stream()
.filter(employee -> {
Date entryDate = employee.getEntryDate();
return DateUtil.betweenDay(entryDate, new Date(), true) == examTime.longValue();
}).collect(Collectors.toList());
Set<Integer> userIds = employees.stream().map(BeisenEmployeeInfoDTO::getUserID).collect(Collectors.toSet());
Example pushedQueryExample = new Example(LearningCenterLevelExamPerson.class);
Example.Criteria pushedQueryCriteria = pushedQueryExample.createCriteria();
pushedQueryCriteria
.andEqualTo("examId", levelExamId)
.andIn("personId", userIds)
.andEqualTo("deletedFlag", BaseModel.DeletedFlagEnum.N.name());
List<LearningCenterLevelExamPerson> existPersonList = levelExamPersonMapper.selectByExample(pushedQueryExample);
if (CollectionUtils.isNotEmpty(existPersonList)) {
Set<Integer> existPersonIds = existPersonList.stream().map(LearningCenterLevelExamPerson::getPersonId).collect(Collectors.toSet());
employees = employees.stream()
.filter(employee -> !existPersonIds.contains(employee.getUserID()))
.collect(Collectors.toList());
}
String created_by = "system";
Date createdDate = new Date();
List<LearningCenterLevelExamPerson> personInsertList = employees.stream()
.map(employee -> {
LearningCenterLevelExamPerson person = new LearningCenterLevelExamPerson();
person.setExamId(levelExamId);
person.setPersonId(employee.getUserID());
person.setIsCompleted(LevelExamPersonCompletedStatusEnum.NOT_COMPLETED.getValue());
person.setCreatedBy(created_by);
person.setCreatedDate(createdDate);
person.setUpdatedBy(created_by);
person.setUpdatedDate(createdDate);
person.setDeletedFlag(BaseModel.DeletedFlagEnum.N.name());
return person;
}).collect(Collectors.toList());
levelExamPersonMapper.insertList(personInsertList);
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!