| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- package com.xjrsoft.module.liteflow.node;
- import cn.hutool.core.convert.Convert;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import com.xjrsoft.common.enums.ArchivesStatusEnum;
- import com.xjrsoft.common.enums.DeleteMark;
- import com.xjrsoft.common.enums.StudentChangeTypeEnum;
- import com.xjrsoft.common.enums.WorkflowApproveType;
- import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
- import com.xjrsoft.module.student.entity.StudentDropOut;
- import com.xjrsoft.module.student.mapper.StudentDropOutMapper;
- import com.xjrsoft.module.student.service.IBaseStudentSchoolRollService;
- import com.xjrsoft.module.student.service.IStudentChangeRecordService;
- import com.xjrsoft.module.workflow.entity.WorkflowRecord;
- import com.xjrsoft.module.workflow.mapper.WorkflowRecordMapper;
- import com.xjrsoft.module.workflow.service.IWorkflowExecuteService;
- import com.yomahub.liteflow.core.NodeComponent;
- import org.apache.commons.lang.StringUtils;
- import org.camunda.bpm.engine.history.HistoricProcessInstance;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Component;
- import org.springframework.transaction.support.TransactionSynchronization;
- import org.springframework.transaction.support.TransactionSynchronizationManager;
- import java.util.List;
- import java.util.Map;
- import java.util.Optional;
- import java.util.concurrent.CompletableFuture;
- /**
- * 学生退学
- */
- @Component("student_drop_out_node")
- public class StudentDropOutNode extends NodeComponent {
- @Autowired
- private StudentDropOutMapper studentDropOutMapper;
- @Autowired
- private IBaseStudentSchoolRollService studentSchoolRollService;
- @Autowired
- private IWorkflowExecuteService workflowExecuteService;
- @Autowired
- private WorkflowRecordMapper workflowRecordMapper;
- @Autowired
- private IStudentChangeRecordService changeRecordService;
- @Override
- public void process() throws Exception {
- // 获取表单中数据编号
- Map<String, Object> params = this.getFirstContextBean();
- Object value = util.getFormDatKey(params, "id");
- Long formId = Convert.toLong(value);
- Object processInstanceId = params.get("processInstanceId");
- if (processInstanceId == null) {
- return;
- }
- String processInstanceIdStr = Convert.toStr(processInstanceId);
- if (formId != null && StringUtils.isNotEmpty(processInstanceIdStr)) {
- TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
- @Override
- public void afterCommit() {
- CompletableFuture.runAsync(() -> {
- Optional<HistoricProcessInstance> historicProcessInstanceOptional = workflowExecuteService.getHistoricProcessInstance(processInstanceId.toString());
- if (historicProcessInstanceOptional.isEmpty()) {
- return;
- }
- HistoricProcessInstance historicProcessInstance = historicProcessInstanceOptional.get();
- if (!historicProcessInstance.getState().equals(HistoricProcessInstance.STATE_ACTIVE)) {
- // 获取流程记录中的非正常结束
- LambdaQueryWrapper<WorkflowRecord> workflowRecordLambdaQueryWrapper = new LambdaQueryWrapper<>();
- workflowRecordLambdaQueryWrapper
- .and(wq -> wq.eq(WorkflowRecord::getWorkflowApproveType, WorkflowApproveType.DISAGREE.getCode())
- .or()
- .eq(WorkflowRecord::getWorkflowApproveType, WorkflowApproveType.WITHDRAW.getCode())
- )
- .eq(WorkflowRecord::getProcessId, processInstanceId)
- ;
- List<WorkflowRecord> workflowRecordList = workflowRecordMapper.selectList(workflowRecordLambdaQueryWrapper);
- if (!workflowRecordList.isEmpty()) {
- return;
- }
- }
- //查询出数据
- StudentDropOut studentDropOut = studentDropOutMapper.selectById(formId);
- //跟新学籍信息
- BaseStudentSchoolRoll schoolRoll = studentSchoolRollService.getOne(
- new QueryWrapper<BaseStudentSchoolRoll>().lambda()
- .eq(BaseStudentSchoolRoll::getClassId, studentDropOut.getClassId())
- .eq(BaseStudentSchoolRoll::getUserId, studentDropOut.getStudentUserId())
- .eq(BaseStudentSchoolRoll::getDeleteMark, DeleteMark.NODELETE.getCode())
- );
- //记录异动
- changeRecordService.insertData(
- ArchivesStatusEnum.fromCode(schoolRoll.getArchivesStatus()),
- schoolRoll.getArchivesStatus(),
- ArchivesStatusEnum.FB2904.getValue(),
- ArchivesStatusEnum.FB2904.getCode(),
- studentDropOut.getStudentUserId(),
- studentDropOut.getCreateUserId(),
- StudentChangeTypeEnum.ArchivesStatus.getCode(),
- 2
- );
- schoolRoll.setArchivesStatus(ArchivesStatusEnum.FB2904.getCode());
- studentSchoolRollService.updateById(schoolRoll);
- // studentSchoolRollService.disableStudent(schoolRoll.getUserId(), studentDropOut.getCreateUserId());
- });
- }
- });
- }
- }
- }
|