| | |
| | | package org.jeecg.modules.eam.service.impl; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.flowable.engine.TaskService; |
| | | import org.flowable.task.api.Task; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.constant.CommonConstant; |
| | | import org.jeecg.common.constant.DataBaseConstant; |
| | | import org.jeecg.common.exception.JeecgBootException; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.common.util.oConvertUtils; |
| | | import org.jeecg.modules.eam.constant.*; |
| | | import org.jeecg.modules.eam.dto.EamReportAccidentsRegisterDto; |
| | | import org.jeecg.modules.eam.entity.EamReportAccidentsRegister; |
| | | import org.jeecg.modules.eam.entity.EamReportProductHazards; |
| | | import org.jeecg.modules.eam.entity.EamReportRepair; |
| | | import org.jeecg.modules.eam.entity.*; |
| | | import org.jeecg.modules.eam.mapper.EamReportAccidentsRegisterMapper; |
| | | import org.jeecg.modules.eam.request.EamReportAccidentsRegisterQuery; |
| | | import org.jeecg.modules.eam.service.IEamEquipmentService; |
| | | import org.jeecg.modules.eam.service.IEamReportAccidentsRegisterService; |
| | | import org.jeecg.modules.eam.service.IEamReportRepairService; |
| | | import org.jeecg.modules.flowable.apithird.business.entity.FlowMyBusiness; |
| | | import org.jeecg.modules.flowable.apithird.business.service.IFlowMyBusinessService; |
| | | import org.jeecg.modules.flowable.apithird.service.FlowCallBackServiceI; |
| | | import org.jeecg.modules.flowable.apithird.service.FlowCommonService; |
| | | import org.jeecg.modules.flowable.service.IFlowDefinitionService; |
| | | import org.jeecg.modules.flowable.service.IFlowTaskService; |
| | | import org.jeecg.modules.system.entity.BaseFactory; |
| | | import org.jeecg.modules.system.entity.BaseFactoryUser; |
| | | import org.jeecg.modules.system.service.IBaseFactoryService; |
| | | import org.jeecg.modules.system.service.IBaseFactoryUserService; |
| | | import org.jeecg.modules.system.service.ISysUserService; |
| | | import org.jeecg.modules.system.vo.UserSelector; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | * @Date: 2025-07-17 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Service |
| | | public class EamReportAccidentsRegisterServiceImpl extends ServiceImpl<EamReportAccidentsRegisterMapper, EamReportAccidentsRegister> implements IEamReportAccidentsRegisterService { |
| | | @Service("IEamReportAccidentsRegisterService") |
| | | public class EamReportAccidentsRegisterServiceImpl extends ServiceImpl<EamReportAccidentsRegisterMapper, EamReportAccidentsRegister> implements IEamReportAccidentsRegisterService, FlowCallBackServiceI { |
| | | |
| | | @Autowired |
| | | private IBaseFactoryUserService baseFactoryUserService; |
| | |
| | | @Autowired |
| | | @Lazy |
| | | private IEamReportRepairService iEamReportRepairService; |
| | | @Resource |
| | | private FlowCommonService flowCommonService; |
| | | |
| | | @Resource |
| | | private IFlowDefinitionService flowDefinitionService; |
| | | |
| | | @Resource |
| | | private IEamEquipmentService eamEquipmentService; |
| | | |
| | | @Resource |
| | | private IFlowMyBusinessService flowMyBusinessService; |
| | | |
| | | @Resource |
| | | private TaskService taskService; |
| | | |
| | | @Resource |
| | | private IFlowTaskService flowTaskService; |
| | | |
| | | @Autowired |
| | | private ISysUserService sysUserService; |
| | | /** |
| | | * 分页列表 |
| | | * @param page |
| | |
| | | if (StringUtils.isNotBlank(eamReportAccidentsRegisterQuery.getEquipmentName())) { |
| | | queryWrapper.like("e.equipment_name", eamReportAccidentsRegisterQuery.getEquipmentName()); |
| | | } |
| | | if (StringUtils.isNotBlank(eamReportAccidentsRegisterQuery.getRegisterStatus())) { |
| | | queryWrapper.eq("aar.register_status", eamReportAccidentsRegisterQuery.getRegisterStatus()); |
| | | } |
| | | queryWrapper.eq("aar.del_flag", CommonConstant.DEL_FLAG_0); |
| | | //排序 |
| | | if (StringUtils.isNotBlank(eamReportAccidentsRegisterQuery.getColumn()) && StringUtils.isNotBlank(eamReportAccidentsRegisterQuery.getOrder())) { |
| | | String column = eamReportAccidentsRegisterQuery.getColumn(); |
| | |
| | | return false; |
| | | } |
| | | BeanUtils.copyProperties(eamReportAccidentsRegisterDto,eamReportAccidentsRegister); |
| | | eamReportAccidentsRegister.setRegisterStatus(EamReportAccidentsRegisterEnum.PENDING_SUBMIT.name()); |
| | | UpdateWrapper<EamReportRepair> updateWrapper = new UpdateWrapper<>(); |
| | | updateWrapper.eq("id",eamReportAccidentsRegister.getReportId()); |
| | | updateWrapper.set("scrap_part_number",eamReportAccidentsRegister.getScrapPartNumber()); |
| | | updateWrapper.set("scrap_part_quantity",eamReportAccidentsRegister.getScrapPartQuantity()); |
| | | updateWrapper.set("scrap_part_value",eamReportAccidentsRegister.getScrapPartValue()); |
| | | iEamReportRepairService.update(updateWrapper); |
| | | this.updateById(eamReportAccidentsRegister); |
| | | return true; |
| | | } |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Result<?> submit(String id){ |
| | | return null; |
| | | EamReportAccidentsRegister eamReportAccidentsRegister=this.getById(id); |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | EamEquipment eamEquipment = eamEquipmentService.getById(eamReportAccidentsRegister.getEquipmentId()); |
| | | List<UserSelector> userSelectorList = sysUserService.selectOperatorList(eamEquipment.getEquipmentCode(), eamEquipment.getFactoryOrgCode(), BusinessCodeConst.PCR0019); |
| | | // 启动设备事故登记流程 |
| | | flowCommonService.initActBusiness("设备编号:" + eamEquipment.getEquipmentCode() + ", 设备名称:" + eamEquipment.getEquipmentName()+"发起设备事故登记流程", |
| | | eamReportAccidentsRegister.getId(), |
| | | "IEamReportAccidentsRegisterService", |
| | | "eam_report_accidents_register", |
| | | null); |
| | | Map<String, Object> variables = new HashMap<>(); |
| | | variables.put("dataId", eamReportAccidentsRegister.getId()); |
| | | variables.put("organization", "操作工提交启动流程"); |
| | | variables.put("comment", "操作工提交单启动流程"); |
| | | variables.put("proofreading", true); |
| | | if (CollectionUtils.isEmpty(userSelectorList)) { |
| | | throw new JeecgBootException("设备未存在区长,无法进入下级审批!"); |
| | | }else { |
| | | List<String> usernameList = userSelectorList.stream().map(UserSelector::getUsername).collect(Collectors.toList()); |
| | | variables.put("NextAssignee", usernameList); |
| | | } |
| | | Result result = flowDefinitionService.startProcessInstanceByKey("eam_report_accidents_register", variables); |
| | | if (!result.isSuccess()) { |
| | | return Result.error("流程启动失败"); |
| | | } else { |
| | | eamReportAccidentsRegister.setConfirmer(user.getUsername()); |
| | | eamReportAccidentsRegister.setConfirmTime(new Date()); |
| | | eamReportAccidentsRegister.setRegisterStatus(EamReportAccidentsRegisterEnum.PENDING_REGIONAL_MANAGER.name()); |
| | | this.updateById(eamReportAccidentsRegister); |
| | | return result; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 流程审核 |
| | | * @param eamReportAccidentsRegisterDto |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Result<?> audit(EamReportAccidentsRegisterDto eamReportAccidentsRegisterDto){ |
| | | EamReportAccidentsRegister eamReportAccidentsRegister = this.baseMapper.selectById(eamReportAccidentsRegisterDto.getId()); |
| | | if (eamReportAccidentsRegister == null) { |
| | | throw new JeecgBootException("工单不存在,请刷新重试!"); |
| | | } |
| | | // 获取当前登录用户 |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | if (user == null || StrUtil.isBlank(user.getId())) { |
| | | throw new JeecgBootException("未获取到登录用户,请重新登录后再试!"); |
| | | } |
| | | eamReportAccidentsRegisterDto.setAssignee(user.getUsername()); |
| | | // 获取流程业务记录 |
| | | FlowMyBusiness flowMyBusiness = flowMyBusinessService.getFlowMyBusiness(eamReportAccidentsRegisterDto.getInstanceId()); |
| | | if (flowMyBusiness == null) { |
| | | throw new JeecgBootException("流程实例不存在,请刷新后重试!"); |
| | | } |
| | | boolean userAuthorized = isUserAuthorized(flowMyBusiness, user); |
| | | if (!userAuthorized) { |
| | | throw new JeecgBootException("用户无权操作此任务,请刷新后重试!"); |
| | | } |
| | | // 认领任务 |
| | | if (!claimTask(flowMyBusiness.getTaskId(), user)) { |
| | | throw new JeecgBootException("任务不存在、已完成或已被他人认领!"); |
| | | } |
| | | EamEquipment equipment = eamEquipmentService.getById(eamReportAccidentsRegisterDto.getEquipmentId()); |
| | | if (equipment == null) { |
| | | throw new JeecgBootException("设备不存在,请检查!"); |
| | | } |
| | | EamReportAccidentsRegisterEnum status = EamReportAccidentsRegisterEnum.getInstance(eamReportAccidentsRegister.getRegisterStatus()); |
| | | if (status == null) { |
| | | return null; |
| | | } |
| | | //流程变量 |
| | | Map<String, Object> values = new HashMap<>(); |
| | | List<String> userApprovalList; |
| | | List<UserSelector> userSelectors; |
| | | switch (status) { |
| | | //待区长处理 |
| | | case PENDING_REGIONAL_MANAGER: |
| | | userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getFactoryOrgCode(), BusinessCodeConst.PCR0020); |
| | | if (CollectionUtil.isEmpty(userSelectors)) { |
| | | throw new JeecgBootException("设备未存在中心主任,无法进入下级审批!"); |
| | | }else{ |
| | | userApprovalList= userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList()); |
| | | values.put("NextAssignee", userApprovalList); |
| | | values.put("dataId", eamReportAccidentsRegisterDto.getId()); |
| | | if (StrUtil.isEmpty(eamReportAccidentsRegisterDto.getDistrictConfirm())){ |
| | | eamReportAccidentsRegisterDto.setDistrictConfirm(""); |
| | | } |
| | | values.put("organization",eamReportAccidentsRegisterDto.getDistrictConfirm()); |
| | | values.put("comment", eamReportAccidentsRegisterDto.getDistrictConfirm()); |
| | | values.put("districtResult", eamReportAccidentsRegisterDto.getDistrictResult()); |
| | | eamReportAccidentsRegisterDto.setComment(eamReportAccidentsRegisterDto.getDistrictConfirm()); |
| | | eamReportAccidentsRegister.setDistrict(user.getUsername()); |
| | | eamReportAccidentsRegister.setDistrictTime(new Date()); |
| | | eamReportAccidentsRegister.setDistrictResult(eamReportAccidentsRegisterDto.getDistrictResult()); |
| | | eamReportAccidentsRegister.setDistrictConfirm(eamReportAccidentsRegisterDto.getDistrictConfirm()); |
| | | if ("2".equals(eamReportAccidentsRegisterDto.getDistrictResult())){ |
| | | //区长拒绝 |
| | | eamReportAccidentsRegister.setRegisterStatus(EamReportAccidentsRegisterEnum.REJECTED.name()); |
| | | }else { |
| | | eamReportAccidentsRegister.setRegisterStatus(EamReportAccidentsRegisterEnum.PENDING_CENTER_MANAGER.name()); |
| | | } |
| | | } |
| | | break; |
| | | //待中心主任处理 |
| | | case PENDING_CENTER_MANAGER: |
| | | userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getFactoryOrgCode(), BusinessCodeConst.PCR0002); |
| | | if (CollectionUtil.isEmpty(userSelectors)) { |
| | | throw new JeecgBootException("设备未存在维修工,无法进入下级审批!"); |
| | | }else{ |
| | | userApprovalList= userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList()); |
| | | values.put("NextAssignee", userApprovalList); |
| | | values.put("dataId", eamReportAccidentsRegisterDto.getId()); |
| | | if (StrUtil.isEmpty(eamReportAccidentsRegisterDto.getCenterDirectorConfirm())){ |
| | | eamReportAccidentsRegisterDto.setCenterDirectorConfirm(""); |
| | | } |
| | | values.put("organization",eamReportAccidentsRegisterDto.getCenterDirectorConfirm()); |
| | | values.put("comment", eamReportAccidentsRegisterDto.getCenterDirectorConfirm()); |
| | | values.put("centerDirectorResult", eamReportAccidentsRegisterDto.getCenterDirectorResult()); |
| | | eamReportAccidentsRegisterDto.setComment(eamReportAccidentsRegisterDto.getCenterDirectorConfirm()); |
| | | eamReportAccidentsRegister.setCenterDirector(user.getUsername()); |
| | | eamReportAccidentsRegister.setCenterDirectorTime(new Date()); |
| | | eamReportAccidentsRegister.setCenterDirectorResult(eamReportAccidentsRegisterDto.getCenterDirectorResult()); |
| | | eamReportAccidentsRegister.setCenterDirectorConfirm(eamReportAccidentsRegisterDto.getCenterDirectorConfirm()); |
| | | if ("2".equals(eamReportAccidentsRegisterDto.getCenterDirectorResult())){ |
| | | //中心主任拒绝 |
| | | eamReportAccidentsRegister.setRegisterStatus(EamReportAccidentsRegisterEnum.REJECTED.name()); |
| | | }else { |
| | | eamReportAccidentsRegister.setRegisterStatus(EamReportAccidentsRegisterEnum.PENDING_REPAIR_WORKER.name()); |
| | | } |
| | | } |
| | | break; |
| | | //待维修工处理 |
| | | case PENDING_REPAIR_WORKER: |
| | | userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getFactoryOrgCode(), BusinessCodeConst.PCR0008); |
| | | if (CollectionUtil.isEmpty(userSelectors)) { |
| | | throw new JeecgBootException("设备未存在维修组长,无法进入下级审批!"); |
| | | }else{ |
| | | userApprovalList= userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList()); |
| | | values.put("NextAssignee", userApprovalList); |
| | | values.put("dataId", eamReportAccidentsRegisterDto.getId()); |
| | | if (StrUtil.isEmpty(eamReportAccidentsRegisterDto.getRepairConfirmComment())){ |
| | | eamReportAccidentsRegisterDto.setRepairConfirmComment(""); |
| | | } |
| | | values.put("organization",eamReportAccidentsRegisterDto.getRepairConfirmComment()); |
| | | values.put("comment", eamReportAccidentsRegisterDto.getRepairConfirmComment()); |
| | | values.put("repairConfirmResult", eamReportAccidentsRegisterDto.getRepairConfirmResult()); |
| | | eamReportAccidentsRegisterDto.setComment(eamReportAccidentsRegisterDto.getRepairConfirmComment()); |
| | | eamReportAccidentsRegister.setRepairConfirm(user.getUsername()); |
| | | eamReportAccidentsRegister.setRepairConfirmTime(new Date()); |
| | | eamReportAccidentsRegister.setRepairConfirmResult(eamReportAccidentsRegisterDto.getRepairConfirmResult()); |
| | | eamReportAccidentsRegister.setRepairConfirmComment(eamReportAccidentsRegisterDto.getRepairConfirmComment()); |
| | | eamReportAccidentsRegister.setReportStartTime(eamReportAccidentsRegisterDto.getReportStartTime()); |
| | | eamReportAccidentsRegister.setEquipmentStatus(eamReportAccidentsRegisterDto.getEquipmentStatus()); |
| | | eamReportAccidentsRegister.setCauseAnalysis(eamReportAccidentsRegisterDto.getCauseAnalysis()); |
| | | eamReportAccidentsRegister.setInspectionResults(eamReportAccidentsRegisterDto.getInspectionResults()); |
| | | eamReportAccidentsRegister.setTakeSteps(eamReportAccidentsRegisterDto.getTakeSteps()); |
| | | eamReportAccidentsRegister.setSuggestionTakeSteps(eamReportAccidentsRegisterDto.getSuggestionTakeSteps()); |
| | | eamReportAccidentsRegister.setSuggestionTakeStepsTime(eamReportAccidentsRegisterDto.getSuggestionTakeStepsTime()); |
| | | if ("2".equals(eamReportAccidentsRegisterDto.getRepairConfirmResult())){ |
| | | //维修工拒绝 |
| | | eamReportAccidentsRegister.setRegisterStatus(EamReportAccidentsRegisterEnum.REJECTED.name()); |
| | | }else { |
| | | eamReportAccidentsRegister.setRegisterStatus(EamReportAccidentsRegisterEnum.PENDING_REPAIR_TEAM_LEADER.name()); |
| | | } |
| | | } |
| | | break; |
| | | //待维修组长处理 |
| | | case PENDING_REPAIR_TEAM_LEADER: |
| | | userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getFactoryOrgCode(), BusinessCodeConst.PCR0013); |
| | | if (CollectionUtil.isEmpty(userSelectors)) { |
| | | throw new JeecgBootException("设备未存在维修区长,无法进入下级审批"); |
| | | } |
| | | userApprovalList= userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList()); |
| | | values.put("NextAssignee", userApprovalList); |
| | | if (StrUtil.isEmpty(eamReportAccidentsRegisterDto.getRepairGroupLeaderComment())){ |
| | | eamReportAccidentsRegisterDto.setRepairGroupLeaderComment(""); |
| | | } |
| | | values.put("organization",eamReportAccidentsRegisterDto.getRepairGroupLeaderComment()); |
| | | values.put("comment", eamReportAccidentsRegisterDto.getRepairGroupLeaderComment()); |
| | | values.put("repairGroupLeaderResult", eamReportAccidentsRegisterDto.getRepairGroupLeaderResult()); |
| | | eamReportAccidentsRegisterDto.setComment(eamReportAccidentsRegisterDto.getRepairGroupLeaderComment()); |
| | | eamReportAccidentsRegister.setRepairGroupLeader(user.getUsername()); |
| | | eamReportAccidentsRegister.setRepairGroupLeaderTime(new Date()); |
| | | eamReportAccidentsRegister.setRepairGroupLeaderResult(eamReportAccidentsRegisterDto.getRepairGroupLeaderResult()); |
| | | eamReportAccidentsRegister.setRepairGroupLeaderComment(eamReportAccidentsRegisterDto.getRepairGroupLeaderComment()); |
| | | if ("2".equals(eamReportAccidentsRegisterDto.getRepairGroupLeaderResult())){ |
| | | //维修组长拒绝 |
| | | eamReportAccidentsRegister.setRegisterStatus(EamReportAccidentsRegisterEnum.REJECTED.name()); |
| | | }else { |
| | | eamReportAccidentsRegister.setRegisterStatus(EamReportAccidentsRegisterEnum.PENDING_REPAIR_REGIONAL_MANAGER.name()); |
| | | } |
| | | break; |
| | | //待维修区长处理 |
| | | case PENDING_REPAIR_REGIONAL_MANAGER: |
| | | userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getFactoryOrgCode(), BusinessCodeConst.PCR0021); |
| | | if (CollectionUtil.isEmpty(userSelectors)) { |
| | | throw new JeecgBootException("设备未存在技术负责人,无法进入下级审批"); |
| | | } |
| | | userApprovalList= userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList()); |
| | | values.put("NextAssignee", userApprovalList); |
| | | if (StrUtil.isEmpty(eamReportAccidentsRegisterDto.getRepairDistrictComment())){ |
| | | eamReportAccidentsRegisterDto.setRepairDistrictComment(""); |
| | | } |
| | | values.put("organization",eamReportAccidentsRegisterDto.getRepairDistrictComment()); |
| | | values.put("comment", eamReportAccidentsRegisterDto.getRepairDistrictComment()); |
| | | values.put("repairDistrictResult", eamReportAccidentsRegisterDto.getRepairDistrictResult()); |
| | | eamReportAccidentsRegisterDto.setComment(eamReportAccidentsRegisterDto.getRepairDistrictComment()); |
| | | eamReportAccidentsRegister.setRepairDistrict(user.getUsername()); |
| | | eamReportAccidentsRegister.setRepairDistrictTime(new Date()); |
| | | eamReportAccidentsRegister.setRepairDistrictResult(eamReportAccidentsRegisterDto.getRepairDistrictResult()); |
| | | eamReportAccidentsRegister.setRepairDistrictComment(eamReportAccidentsRegisterDto.getRepairDistrictComment()); |
| | | if ("2".equals(eamReportAccidentsRegisterDto.getRepairDistrictResult())){ |
| | | //维修区长拒绝 |
| | | eamReportAccidentsRegister.setRegisterStatus(EamReportAccidentsRegisterEnum.REJECTED.name()); |
| | | }else { |
| | | eamReportAccidentsRegister.setRegisterStatus(EamReportAccidentsRegisterEnum.PENDING_TECHNICAL_RESPONSIBLE.name()); |
| | | } |
| | | break; |
| | | //待技术负责人处理 |
| | | case PENDING_TECHNICAL_RESPONSIBLE: |
| | | userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getFactoryOrgCode(), BusinessCodeConst.PCR0022); |
| | | if (CollectionUtil.isEmpty(userSelectors)) { |
| | | throw new JeecgBootException("设备未存在技术主管室级领导,无法进入下级审批"); |
| | | } |
| | | userApprovalList= userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList()); |
| | | values.put("NextAssignee", userApprovalList); |
| | | if (StrUtil.isEmpty(eamReportAccidentsRegisterDto.getTechnicalDirectorConfirm())){ |
| | | eamReportAccidentsRegisterDto.setTechnicalDirectorConfirm(""); |
| | | } |
| | | values.put("organization",eamReportAccidentsRegisterDto.getTechnicalDirectorConfirm()); |
| | | values.put("comment", eamReportAccidentsRegisterDto.getTechnicalDirectorConfirm()); |
| | | values.put("technicalDirectorResult", eamReportAccidentsRegisterDto.getTechnicalDirectorResult()); |
| | | eamReportAccidentsRegisterDto.setComment(eamReportAccidentsRegisterDto.getTechnicalDirectorConfirm()); |
| | | eamReportAccidentsRegister.setCheckAgree(eamReportAccidentsRegisterDto.getCheckAgree()); |
| | | eamReportAccidentsRegister.setDisagreeReason(eamReportAccidentsRegisterDto.getDisagreeReason()); |
| | | eamReportAccidentsRegister.setRectificationMeasures(eamReportAccidentsRegisterDto.getRectificationMeasures()); |
| | | eamReportAccidentsRegister.setAccidentConclusion(eamReportAccidentsRegisterDto.getAccidentConclusion()); |
| | | eamReportAccidentsRegister.setTechnicalDirector(user.getUsername()); |
| | | eamReportAccidentsRegister.setTechnicalDirectorTime(new Date()); |
| | | eamReportAccidentsRegister.setTechnicalDirectorResult(eamReportAccidentsRegisterDto.getTechnicalDirectorResult()); |
| | | eamReportAccidentsRegister.setTechnicalDirectorConfirm(eamReportAccidentsRegisterDto.getTechnicalDirectorConfirm()); |
| | | if ("2".equals(eamReportAccidentsRegisterDto.getTechnicalDirectorResult())){ |
| | | //技术负责人拒绝 |
| | | eamReportAccidentsRegister.setRegisterStatus(EamReportAccidentsRegisterEnum.REJECTED.name()); |
| | | }else { |
| | | eamReportAccidentsRegister.setRegisterStatus(EamReportAccidentsRegisterEnum.PENDING_TECHNICAL_SUPERVISOR.name()); |
| | | } |
| | | break; |
| | | //待技术主管室级领导处理 |
| | | case PENDING_TECHNICAL_SUPERVISOR: |
| | | userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getFactoryOrgCode(), BusinessCodeConst.PCR0023); |
| | | if (CollectionUtil.isEmpty(userSelectors)) { |
| | | throw new JeecgBootException("设备未存在主管部级领导,无法进入下级审批"); |
| | | } |
| | | userApprovalList= userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList()); |
| | | values.put("NextAssignee", userApprovalList); |
| | | if (StrUtil.isEmpty(eamReportAccidentsRegisterDto.getTechnicalDirectorLeaderConfirm())){ |
| | | eamReportAccidentsRegisterDto.setTechnicalDirectorLeaderConfirm(""); |
| | | } |
| | | values.put("organization",eamReportAccidentsRegisterDto.getTechnicalDirectorLeaderConfirm()); |
| | | values.put("comment", eamReportAccidentsRegisterDto.getTechnicalDirectorLeaderConfirm()); |
| | | values.put("technicalDirectorLeaderResult", eamReportAccidentsRegisterDto.getTechnicalDirectorLeaderResult()); |
| | | eamReportAccidentsRegisterDto.setComment(eamReportAccidentsRegisterDto.getTechnicalDirectorLeaderConfirm()); |
| | | eamReportAccidentsRegister.setTechnicalDirectorLeader(user.getUsername()); |
| | | eamReportAccidentsRegister.setTechnicalDirectorLeaderTime(new Date()); |
| | | eamReportAccidentsRegister.setTechnicalDirectorLeaderResult(eamReportAccidentsRegisterDto.getTechnicalDirectorLeaderResult()); |
| | | eamReportAccidentsRegister.setTechnicalDirectorLeaderConfirm(eamReportAccidentsRegisterDto.getTechnicalDirectorLeaderConfirm()); |
| | | if ("2".equals(eamReportAccidentsRegisterDto.getTechnicalDirectorLeaderResult())){ |
| | | //技术主管室级领导拒绝 |
| | | eamReportAccidentsRegister.setRegisterStatus(EamReportAccidentsRegisterEnum.REJECTED.name()); |
| | | }else { |
| | | eamReportAccidentsRegister.setRegisterStatus(EamReportAccidentsRegisterEnum.PENDING_SUPERIOR_DEPARTMENT.name()); |
| | | } |
| | | break; |
| | | //待主管部级领导处理 |
| | | case PENDING_SUPERIOR_DEPARTMENT: |
| | | if (StrUtil.isEmpty(eamReportAccidentsRegisterDto.getTechnicalDirectorPartConfirm())){ |
| | | eamReportAccidentsRegisterDto.setTechnicalDirectorPartConfirm(""); |
| | | } |
| | | values.put("organization",eamReportAccidentsRegisterDto.getTechnicalDirectorPartConfirm()); |
| | | values.put("comment", eamReportAccidentsRegisterDto.getTechnicalDirectorPartConfirm()); |
| | | values.put("technicalDirectorPartResult", eamReportAccidentsRegisterDto.getTechnicalDirectorPartResult()); |
| | | eamReportAccidentsRegisterDto.setComment(eamReportAccidentsRegisterDto.getTechnicalDirectorPartConfirm()); |
| | | eamReportAccidentsRegister.setTechnicalDirectorPart(user.getUsername()); |
| | | eamReportAccidentsRegister.setTechnicalDirectorPartTime(new Date()); |
| | | eamReportAccidentsRegister.setTechnicalDirectorPartResult(eamReportAccidentsRegisterDto.getTechnicalDirectorPartResult()); |
| | | eamReportAccidentsRegister.setTechnicalDirectorPartConfirm(eamReportAccidentsRegisterDto.getTechnicalDirectorPartConfirm()); |
| | | if ("2".equals(eamReportAccidentsRegisterDto.getTechnicalDirectorPartResult())){ |
| | | //技术主管室级领导拒绝 |
| | | eamReportAccidentsRegister.setRegisterStatus(EamReportAccidentsRegisterEnum.REJECTED.name()); |
| | | }else { |
| | | eamReportAccidentsRegister.setRegisterStatus(EamReportAccidentsRegisterEnum.REPAIR_COMPLETED.name()); |
| | | } |
| | | break; |
| | | default: |
| | | throw new JeecgBootException("审批失败"); |
| | | } |
| | | eamReportAccidentsRegisterDto.setValues(values); |
| | | //保存工单 |
| | | this.updateById(eamReportAccidentsRegister); |
| | | Result result = flowTaskService.complete(eamReportAccidentsRegisterDto); |
| | | if (!result.isSuccess()) { |
| | | throw new JeecgBootException("审批失败,请刷新查看!"); |
| | | } |
| | | return Result.ok("审批成功"); |
| | | } |
| | | |
| | | private boolean claimTask(String taskId, LoginUser user) { |
| | | Task task = taskService.createTaskQuery().taskId(taskId).singleResult(); |
| | | if (task == null) { |
| | | return false; |
| | | } |
| | | if (task.getAssignee() != null && !task.getAssignee().equals(user.getUsername())) { |
| | | return false; |
| | | } |
| | | taskService.claim(taskId, user.getUsername()); |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * 判断用户是否拥有此权限 |
| | | * @param flowMyBusiness |
| | | * @param user |
| | | * @return |
| | | */ |
| | | private boolean isUserAuthorized(FlowMyBusiness flowMyBusiness, LoginUser user) { |
| | | List<String> todoUsers = JSON.parseArray(flowMyBusiness.getTodoUsers(), String.class); |
| | | return todoUsers != null && todoUsers.contains(user.getUsername()); |
| | | } |
| | | |
| | | /** |
| | |
| | | this.removeById(id); |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public void afterFlowHandle(FlowMyBusiness business) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public Object getBusinessDataById(String dataId) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> flowValuesOfTask(String taskNameId, Map<String, Object> values) { |
| | | return Collections.emptyMap(); |
| | | } |
| | | |
| | | @Override |
| | | public List<String> flowCandidateUsernamesOfTask(String taskNameId, Map<String, Object> values) { |
| | | //获取下一步处理人 |
| | | Object object = values.get("NextAssignee"); |
| | | return (List<String>) object; |
| | | } |
| | | } |