|
|
@@ -0,0 +1,158 @@
|
|
|
+package com.xjrsoft.module.liteflow.node;
|
|
|
+
|
|
|
+import cn.hutool.core.convert.Convert;
|
|
|
+import cn.hutool.db.Entity;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
+import com.xjrsoft.common.enums.ArchivesStatusEnum;
|
|
|
+import com.xjrsoft.common.enums.StudentTypeEnum;
|
|
|
+import com.xjrsoft.common.enums.WorkflowApproveType;
|
|
|
+import com.xjrsoft.common.mybatis.SqlRunnerAdapter;
|
|
|
+import com.xjrsoft.common.utils.VoToColumnUtil;
|
|
|
+import com.xjrsoft.module.organization.entity.User;
|
|
|
+import com.xjrsoft.module.organization.mapper.UserMapper;
|
|
|
+import com.xjrsoft.module.student.dto.AddBaseStudentContactDto;
|
|
|
+import com.xjrsoft.module.student.dto.AddBaseStudentDto;
|
|
|
+import com.xjrsoft.module.student.dto.AddBaseStudentFamilyDto;
|
|
|
+import com.xjrsoft.module.student.dto.AddBaseStudentFamilyMemberDto;
|
|
|
+import com.xjrsoft.module.student.dto.AddBaseStudentSchoolRollDto;
|
|
|
+import com.xjrsoft.module.student.dto.AddBaseStudentSubsidizeDto;
|
|
|
+import com.xjrsoft.module.student.dto.AddBaseStudentUserDto;
|
|
|
+import com.xjrsoft.module.student.service.IBaseStudentSchoolRollService;
|
|
|
+import com.xjrsoft.module.student.service.IBaseStudentService;
|
|
|
+import com.xjrsoft.module.student.service.IStudentManagerService;
|
|
|
+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.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Optional;
|
|
|
+import java.util.concurrent.CompletableFuture;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 学生复读流程规则
|
|
|
+ */
|
|
|
+@Component("wf_student_repeat_study_node")
|
|
|
+public class WfStudentRepeatStudyNode extends NodeComponent {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IStudentManagerService studentService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IWorkflowExecuteService workflowExecuteService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UserMapper userMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IBaseStudentSchoolRollService schoolRollService;
|
|
|
+
|
|
|
+
|
|
|
+ @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_COMPLETED)) {
|
|
|
+ String tableName = "wf_student_repeat_study";
|
|
|
+ Entity where = Entity.create(tableName);
|
|
|
+ where.set("id", formId);
|
|
|
+ Map<String, Object> objectMap = SqlRunnerAdapter.db().dynamicSelectOne(tableName, where);
|
|
|
+ int isOriginal = Integer.parseInt(objectMap.get("is_original").toString());
|
|
|
+
|
|
|
+ String credentialNumber = objectMap.get("credential_number").toString();
|
|
|
+
|
|
|
+ User user = userMapper.selectOne(
|
|
|
+ new MPJLambdaWrapper<User>()
|
|
|
+ .disableLogicDel()
|
|
|
+ .select(User::getId)
|
|
|
+ .select(User.class, x -> VoToColumnUtil.fieldsToColumns(User.class).contains(x.getProperty()))
|
|
|
+ .eq(User::getCredentialNumber, credentialNumber)
|
|
|
+ );
|
|
|
+
|
|
|
+ if(isOriginal == 0 && user == null){
|
|
|
+ AddBaseStudentUserDto baseStudentUser = new AddBaseStudentUserDto();
|
|
|
+ baseStudentUser.setName(objectMap.get("name").toString());
|
|
|
+ baseStudentUser.setCredentialType("ZZLS10007");
|
|
|
+ baseStudentUser.setCredentialNumber(objectMap.get("credential_number").toString());
|
|
|
+ baseStudentUser.setMobile(objectMap.get("mobile").toString());
|
|
|
+ baseStudentUser.setUserName(objectMap.get("credential_number").toString());
|
|
|
+
|
|
|
+ List<AddBaseStudentSchoolRollDto> baseStudentSchoolRollList = new ArrayList<>();
|
|
|
+ AddBaseStudentSchoolRollDto rollDto = new AddBaseStudentSchoolRollDto();
|
|
|
+ rollDto.setStduyStatus(objectMap.get("stduy_status").toString());
|
|
|
+ rollDto.setStduyStatus(ArchivesStatusEnum.FB2901.getCode());
|
|
|
+ rollDto.setMajorSetId(Long.parseLong(objectMap.get("major_set_id").toString()));
|
|
|
+ rollDto.setStudentType(StudentTypeEnum.FB2801.getCode());
|
|
|
+ rollDto.setClassId(Long.parseLong(objectMap.get("class_id").toString()));
|
|
|
+ rollDto.setGradeId(Long.parseLong(objectMap.get("grade_id").toString()));
|
|
|
+ baseStudentSchoolRollList.add(rollDto);
|
|
|
+ baseStudentUser.setBaseStudentSchoolRollList(baseStudentSchoolRollList);
|
|
|
+
|
|
|
+ List<AddBaseStudentDto> baseStudentList = new ArrayList<>();
|
|
|
+ AddBaseStudentDto studentDto = new AddBaseStudentDto();
|
|
|
+ studentDto.setIsMigrateChildren(0);
|
|
|
+ studentDto.setStudentId(baseStudentUser.getCredentialNumber());
|
|
|
+ studentDto.setIsFloatingPopulation(0);
|
|
|
+ baseStudentList.add(studentDto);
|
|
|
+ baseStudentUser.setBaseStudentList(baseStudentList);
|
|
|
+
|
|
|
+ List<AddBaseStudentContactDto> baseStudentContactList = new ArrayList<>();
|
|
|
+ baseStudentContactList.add(new AddBaseStudentContactDto());
|
|
|
+ baseStudentUser.setBaseStudentContactList(baseStudentContactList);
|
|
|
+
|
|
|
+ List<AddBaseStudentFamilyDto> baseStudentFamilyList = new ArrayList<>();
|
|
|
+ baseStudentFamilyList.add(new AddBaseStudentFamilyDto());
|
|
|
+ baseStudentUser.setBaseStudentFamilyList(baseStudentFamilyList);
|
|
|
+
|
|
|
+ List<AddBaseStudentFamilyMemberDto> baseStudentFamilyMemberList = new ArrayList<>();
|
|
|
+ baseStudentFamilyMemberList.add(new AddBaseStudentFamilyMemberDto());
|
|
|
+ baseStudentUser.setBaseStudentFamilyMemberList(baseStudentFamilyMemberList);
|
|
|
+
|
|
|
+ List<AddBaseStudentSubsidizeDto> baseStudentSubsidizeList = new ArrayList<>();
|
|
|
+ baseStudentUser.setBaseStudentSubsidizeList(baseStudentSubsidizeList);
|
|
|
+
|
|
|
+ studentService.add(baseStudentUser);
|
|
|
+ }else{
|
|
|
+ schoolRollService.activateStudent(user.getId());
|
|
|
+ schoolRollService.updateStudentClassGradeMajorStduyStatus(
|
|
|
+ Long.parseLong(objectMap.get("class_id").toString()),
|
|
|
+ Long.parseLong(objectMap.get("grade_id").toString()),
|
|
|
+ Long.parseLong(objectMap.get("major_set_id").toString()),
|
|
|
+ objectMap.get("stduy_status").toString(),
|
|
|
+ user.getId()
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|