| | |
| | | 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.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.poi.ss.usermodel.Sheet; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.apache.poi.ss.usermodel.WorkbookFactory; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.flowable.engine.TaskService; |
| | | import org.flowable.task.api.Task; |
| | | import org.jeecg.common.api.vo.FileUploadResult; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.constant.CommonConstant; |
| | | import org.jeecg.common.exception.JeecgBootException; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.modules.eam.base.entity.BaseFactory; |
| | | import org.jeecg.modules.eam.base.entity.BaseFactoryUser; |
| | | import org.jeecg.modules.eam.base.service.IBaseFactoryService; |
| | | import org.jeecg.modules.eam.base.service.IBaseFactoryUserService; |
| | | import org.jeecg.modules.eam.constant.BusinessCodeConst; |
| | | import org.jeecg.modules.eam.constant.MaintenanceStandardStatusEnum; |
| | | import org.jeecg.modules.eam.entity.EamEquipment; |
| | | import org.jeecg.modules.eam.entity.EamMaintenanceStandard; |
| | | import org.jeecg.modules.eam.entity.EamMaintenanceStandardDetail; |
| | | import org.jeecg.modules.eam.mapper.EamMaintenanceStandardMapper; |
| | | import org.jeecg.modules.eam.request.EamMaintenanceStandardRequest; |
| | | import org.jeecg.modules.eam.service.IEamEquipmentService; |
| | | import org.jeecg.modules.eam.service.IEamMaintenanceStandardDetailService; |
| | | import org.jeecg.modules.eam.service.IEamMaintenanceStandardService; |
| | | import org.jeecg.modules.eam.vo.EamMaintenanceStandardVo; |
| | | 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.service.ISysUserService; |
| | | import org.jeecg.modules.system.vo.UserSelector; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | * @Date: 2025-03-26 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Service |
| | | public class EamMaintenanceStandardServiceImpl extends ServiceImpl<EamMaintenanceStandardMapper, EamMaintenanceStandard> implements IEamMaintenanceStandardService { |
| | | @Service("IEamMaintenanceStandardService") |
| | | public class EamMaintenanceStandardServiceImpl extends ServiceImpl<EamMaintenanceStandardMapper, EamMaintenanceStandard> implements IEamMaintenanceStandardService , FlowCallBackServiceI { |
| | | |
| | | @Resource |
| | | private EamMaintenanceStandardMapper eamMaintenanceStandardMapper; |
| | | |
| | | @Autowired |
| | | private IEamMaintenanceStandardDetailService eamMaintenanceStandardDetailService; |
| | | |
| | | @Autowired |
| | | private IBaseFactoryUserService baseFactoryUserService; |
| | | @Autowired |
| | | private IBaseFactoryService baseFactoryService; |
| | | @Resource |
| | | private FlowCommonService flowCommonService; |
| | | @Resource |
| | | private IFlowDefinitionService flowDefinitionService; |
| | | @Autowired |
| | | private IFlowTaskService flowTaskService; |
| | | @Autowired |
| | | private TaskService taskService; |
| | | @Autowired |
| | | private IFlowMyBusinessService flowMyBusinessService; |
| | | @Autowired |
| | | private ISysUserService sysUserService; |
| | | @Autowired |
| | | private IEamEquipmentService eamEquipmentService; |
| | | @Override |
| | | public IPage<EamMaintenanceStandard> queryPageList(Page<EamMaintenanceStandard> page, EamMaintenanceStandard eamMaintenanceStandard) { |
| | | QueryWrapper<EamMaintenanceStandard> queryWrapper = new QueryWrapper<>(); |
| | |
| | | if (sysUser == null) { |
| | | return page; |
| | | } |
| | | if (StringUtils.isNotBlank(sysUser.getEquipmentIds())) { |
| | | if (StringUtils.isNotBlank(sysUser.getEamEquipmentIds())) { |
| | | //选择了设备,根据设备id过滤设备 |
| | | List<String> equipArr = Arrays.asList(sysUser.getEquipmentIds().split(",")); |
| | | List<String> equipArr = Arrays.asList(sysUser.getEamEquipmentIds().split(",")); |
| | | queryWrapper.in("e.equipment_code", equipArr); |
| | | } else { |
| | | //没有选择设备,根据车间过滤设备 |
| | | queryWrapper.exists("select 1 from mdc_user_production t where t.user_id={0} and t.pro_id=e.org_id ", sysUser.getId()); |
| | | //没有选择设备,根据中心过滤设备 |
| | | List<BaseFactoryUser> baseFactoryUserList=baseFactoryUserService. |
| | | list(new LambdaQueryWrapper<BaseFactoryUser>().eq(BaseFactoryUser::getUserId,sysUser.getId())); |
| | | if(!CollectionUtils.isEmpty(baseFactoryUserList)){ |
| | | List<String> factoryIds = baseFactoryUserList.stream().map(BaseFactoryUser::getFactoryId).collect(Collectors.toList()); |
| | | List<String> factoryCode= baseFactoryService.listByIds(factoryIds).stream().map(BaseFactory::getFactoryCode).collect(Collectors.toList()); |
| | | queryWrapper.in("e.factory_code", factoryCode); |
| | | } |
| | | } |
| | | if(eamMaintenanceStandard != null) { |
| | | //编码 模糊查询 |
| | |
| | | } |
| | | //名称 模糊查询 |
| | | if(StringUtils.isNotBlank(eamMaintenanceStandard.getStandardName())) { |
| | | queryWrapper.like("ems.standard_name", eamMaintenanceStandard.getStandardCode()); |
| | | queryWrapper.like("ems.standard_name", eamMaintenanceStandard.getStandardName()); |
| | | } |
| | | //设备 |
| | | if(StringUtils.isNotBlank(eamMaintenanceStandard.getEquipmentId())) { |
| | |
| | | .or() |
| | | .like("e.equipment_code", eamMaintenanceStandard.getKeyword())); |
| | | } |
| | | //id |
| | | if(StringUtils.isNotBlank(eamMaintenanceStandard.getId())) { |
| | | queryWrapper.eq("ems.id", eamMaintenanceStandard.getId()); |
| | | } |
| | | } |
| | | queryWrapper.orderByDesc("ems.create_time"); |
| | | return eamMaintenanceStandardMapper.queryPageList(page, queryWrapper); |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean addMaintenanceStandard(EamMaintenanceStandardRequest standardRequest) { |
| | | EamMaintenanceStandard entity = new EamMaintenanceStandard(); |
| | | entity.setStandardCode(standardRequest.getStandardCode()); |
| | | entity.setStandardName(standardRequest.getStandardName()); |
| | | entity.setMaintenanceCategory(standardRequest.getMaintenanceCategory()); |
| | | entity.setMaintenancePeriod(standardRequest.getMaintenancePeriod()); |
| | | entity.setInitialDate(standardRequest.getInitialDate()); |
| | | entity.setFileCode(standardRequest.getFileCode()); |
| | | entity.setStandardStatus(MaintenanceStandardStatusEnum.NORMAL.name()); |
| | | BeanUtils.copyProperties(standardRequest, entity); |
| | | entity.setStandardStatus(MaintenanceStandardStatusEnum.WAIT_SUBMIT.name()); |
| | | //版本递增 |
| | | entity.setStandardVersion(CommonConstant.OPERATE_TYPE_1); |
| | | entity.setStandardVersion("v"+CommonConstant.OPERATE_TYPE_1); |
| | | //设备处理 |
| | | entity.setEquipmentId(standardRequest.getEquipmentId()); |
| | | //删除标记 |
| | |
| | | EamMaintenanceStandard exist = checkDuplicate(entity.getEquipmentId(), entity.getMaintenanceCategory()); |
| | | if(exist != null){ |
| | | throw new JeecgBootException("设备标准已存在,不能重复添加!"); |
| | | } |
| | | //处理附件 |
| | | if(CollectionUtil.isNotEmpty(standardRequest.getFileList())) { |
| | | FileUploadResult fileUploadResult = standardRequest.getFileList().get(0); |
| | | ObjectMapper mapper = new ObjectMapper(); |
| | | try { |
| | | String referenceFile = mapper.writeValueAsString(fileUploadResult); |
| | | entity.setReferenceFile(referenceFile); |
| | | } catch (JsonProcessingException e) { |
| | | log.error("JSON转换失败:" + e.getMessage(), e); |
| | | } |
| | | } |
| | | eamMaintenanceStandardMapper.insert(entity); |
| | | //处理明细数据 |
| | |
| | | } |
| | | entity.setStandardName(standardRequest.getStandardName()); |
| | | entity.setMaintenancePeriod(standardRequest.getMaintenancePeriod()); |
| | | entity.setFileCode(standardRequest.getFileCode()); |
| | | //处理附件 |
| | | if(CollectionUtil.isNotEmpty(standardRequest.getFileList())) { |
| | | FileUploadResult fileUploadResult = standardRequest.getFileList().get(0); |
| | | ObjectMapper mapper = new ObjectMapper(); |
| | | try { |
| | | String referenceFile = mapper.writeValueAsString(fileUploadResult); |
| | | entity.setReferenceFile(referenceFile); |
| | | } catch (JsonProcessingException e) { |
| | | log.error("JSON转换失败:" + e.getMessage(), e); |
| | | } |
| | | }else { |
| | | entity.setReferenceFile(null); |
| | | } |
| | | eamMaintenanceStandardMapper.updateById(entity); |
| | | //处理详情 |
| | | if(CollectionUtil.isNotEmpty(standardRequest.getTableDetailList())) { |
| | |
| | | if(entity == null){ |
| | | throw new JeecgBootException("编辑的数据已删除,请刷新重试!"); |
| | | } |
| | | entity.setStandardStatus(MaintenanceStandardStatusEnum.ABOLISH.name()); |
| | | //原来的作废 |
| | | eamMaintenanceStandardMapper.updateById(entity); |
| | | |
| | | //新增一个版本 |
| | | EamMaintenanceStandard newEntity = new EamMaintenanceStandard(); |
| | |
| | | newEntity.setMaintenanceCategory(standardRequest.getMaintenanceCategory()); |
| | | newEntity.setMaintenancePeriod(standardRequest.getMaintenancePeriod()); |
| | | newEntity.setInitialDate(standardRequest.getInitialDate()); |
| | | newEntity.setFileCode(standardRequest.getFileCode()); |
| | | newEntity.setStandardStatus(MaintenanceStandardStatusEnum.NORMAL.name()); |
| | | newEntity.setStandardStatus(MaintenanceStandardStatusEnum.WAIT_SUBMIT.name()); |
| | | //版本递增 |
| | | newEntity.setStandardVersion(entity.getStandardVersion() + 1); |
| | | //获取数字 |
| | | Pattern pattern = Pattern.compile("(\\d+)(?:\\.\\d+)*$"); |
| | | Matcher matcher = pattern.matcher(entity.getStandardVersion()); |
| | | if (matcher.find()) { |
| | | try { |
| | | int mainVersion = Integer.parseInt(matcher.group(1)); |
| | | newEntity.setStandardVersion("v"+(mainVersion+1)); |
| | | } catch (NumberFormatException ignored) { |
| | | } |
| | | } |
| | | //设备处理 |
| | | newEntity.setEquipmentId(standardRequest.getEquipmentId()); |
| | | //删除标记 |
| | |
| | | EamMaintenanceStandard exist = checkDuplicate(newEntity.getEquipmentId(), newEntity.getMaintenanceCategory()); |
| | | if(exist != null){ |
| | | throw new JeecgBootException("设备标准已存在,不能重复添加!"); |
| | | } |
| | | //处理附件 |
| | | if(CollectionUtil.isNotEmpty(standardRequest.getFileList())) { |
| | | FileUploadResult fileUploadResult = standardRequest.getFileList().get(0); |
| | | ObjectMapper mapper = new ObjectMapper(); |
| | | try { |
| | | String referenceFile = mapper.writeValueAsString(fileUploadResult); |
| | | newEntity.setReferenceFile(referenceFile); |
| | | } catch (JsonProcessingException e) { |
| | | log.error("JSON转换失败:" + e.getMessage(), e); |
| | | } |
| | | } |
| | | eamMaintenanceStandardMapper.insert(newEntity); |
| | | //处理明细数据 |
| | |
| | | queryWrapper.eq(EamMaintenanceStandard::getEquipmentId, equipmentId); |
| | | queryWrapper.eq(EamMaintenanceStandard::getMaintenanceCategory, maintenanceCategory); |
| | | queryWrapper.eq(EamMaintenanceStandard::getDelFlag, CommonConstant.DEL_FLAG_0); |
| | | queryWrapper.eq(EamMaintenanceStandard::getStandardStatus, MaintenanceStandardStatusEnum.NORMAL.name()); |
| | | queryWrapper.eq(EamMaintenanceStandard::getStandardStatus, MaintenanceStandardStatusEnum.WAIT_SUBMIT.name()); |
| | | queryWrapper.orderByDesc(EamMaintenanceStandard::getStandardVersion); |
| | | |
| | | List<EamMaintenanceStandard> list = eamMaintenanceStandardMapper.selectList(queryWrapper); |
| | |
| | | query.setEquipmentId(equipmentId); |
| | | query.setKeyword(keyword); |
| | | query.setMaintenanceCategory(maintenanceCategory); |
| | | query.setStandardStatus(MaintenanceStandardStatusEnum.NORMAL.name()); |
| | | query.setStandardStatus(MaintenanceStandardStatusEnum.WAIT_SUBMIT.name()); |
| | | IPage<EamMaintenanceStandard> pageData = this.queryPageList(page, query); |
| | | return pageData.getRecords(); |
| | | } |
| | |
| | | LambdaQueryWrapper<EamMaintenanceStandard> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(EamMaintenanceStandard::getDelFlag, CommonConstant.DEL_FLAG_0); |
| | | queryWrapper.eq(EamMaintenanceStandard::getMaintenanceCategory, maintenanceCategory); |
| | | queryWrapper.eq(EamMaintenanceStandard::getStandardStatus, MaintenanceStandardStatusEnum.NORMAL.name()); |
| | | queryWrapper.eq(EamMaintenanceStandard::getStandardStatus, MaintenanceStandardStatusEnum.WAIT_SUBMIT.name()); |
| | | return eamMaintenanceStandardMapper.selectList(queryWrapper); |
| | | } |
| | | |
| | | |
| | | /*流程业务代码--------------------------开始*/ |
| | | |
| | | /** |
| | | * 流程启动,保存对应的数据 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result<?> saveEamMaintenanceStandardProcess(String id){ |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | EamMaintenanceStandard maintenanceStandard=this.getById(id); |
| | | if (maintenanceStandard==null){ |
| | | return Result.error("未找到对应保养标准"); |
| | | } |
| | | System.out.println("保养规范流程:" + maintenanceStandard.getId()); |
| | | flowCommonService.initActBusiness(maintenanceStandard.getStandardName()+"规范进行流程审核", |
| | | maintenanceStandard.getId(), "IEamMaintenanceStandardService", "eam_maintenance_standard", null); |
| | | Map<String, Object> variables = new HashMap<>(); |
| | | variables.put("dataId", maintenanceStandard.getId()); |
| | | variables.put("organization", "保养规范启动流程"); |
| | | variables.put("comment", "保养规范启动流程"); |
| | | variables.put("proofreading",true); |
| | | Result result= flowDefinitionService.startProcessInstanceByKey("eam_maintenance_standard", variables); |
| | | if (!result.isSuccess()) { |
| | | super.removeById(maintenanceStandard.getId()); |
| | | }else { |
| | | maintenanceStandard.setStandardStatus(MaintenanceStandardStatusEnum.WAIT_REPAIR_DIRECTOR.name()); |
| | | maintenanceStandard.setDesigner(user.getUsername()); |
| | | maintenanceStandard.setDesignTime(new Date()); |
| | | eamMaintenanceStandardMapper.updateById(maintenanceStandard); |
| | | //获取flow的流程实例id,设置下一步的处理人员 |
| | | List<FlowMyBusiness> businessList = flowMyBusinessService.list( |
| | | new QueryWrapper<FlowMyBusiness>() |
| | | .eq("data_id", maintenanceStandard.getId()) |
| | | ); |
| | | if (businessList.isEmpty()) { |
| | | return Result.error("流程记录不存在"); |
| | | } |
| | | FlowMyBusiness flowMyBusiness = businessList.get(0); |
| | | EamEquipment eamEquipment=eamEquipmentService.getById(maintenanceStandard.getEquipmentId()); |
| | | BaseFactory baseFactory=baseFactoryService.getOne(new QueryWrapper<BaseFactory>().eq("org_code", eamEquipment.getFactoryOrgCode())); |
| | | List<UserSelector> userSelectorList=sysUserService.selectOperatorFactoryList(eamEquipment.getEquipmentCode(),baseFactory.getId(), BusinessCodeConst.PCR0007); |
| | | if (!CollectionUtils.isEmpty(userSelectorList)) { |
| | | List<String> usernameList=userSelectorList.stream().map(UserSelector::getUsername).collect(Collectors.toList()); |
| | | flowMyBusiness.setTodoUsers(JSON.toJSONString(usernameList)); |
| | | flowMyBusinessService.updateById(flowMyBusiness); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 审批操作 |
| | | * @param eamMaintenanceStandardVo |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result<?> auditEamMaintenanceStandard(EamMaintenanceStandardVo eamMaintenanceStandardVo){ |
| | | try { |
| | | // 参数校验 |
| | | if (StrUtil.isEmpty(eamMaintenanceStandardVo.getTaskId()) || StrUtil.isEmpty(eamMaintenanceStandardVo.getDataId())) { |
| | | return Result.error("参数错误"); |
| | | } |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | String userId = user.getId(); |
| | | eamMaintenanceStandardVo.setAssignee(user.getUsername()); |
| | | if (StrUtil.isEmpty(userId)) { |
| | | return Result.error("未找到对应用户"); |
| | | } |
| | | |
| | | // 数据查询 |
| | | EamMaintenanceStandard eamMaintenanceStandard = this.getById(eamMaintenanceStandardVo.getDataId()); |
| | | if (eamMaintenanceStandard == null) { |
| | | return Result.error("未找到对应保养标准"); |
| | | } |
| | | |
| | | // 2. 查询流程业务记录(处理空结果) |
| | | List<FlowMyBusiness> businessList = flowMyBusinessService.list( |
| | | new QueryWrapper<FlowMyBusiness>() |
| | | .eq("process_instance_id", eamMaintenanceStandardVo.getInstanceId()) |
| | | ); |
| | | if (businessList.isEmpty()) { |
| | | return Result.error("流程记录不存在"); |
| | | } |
| | | FlowMyBusiness flowMyBusiness = businessList.get(0); |
| | | |
| | | // 3. 校验用户是否为候选处理人 |
| | | List<String> todoUsers = JSON.parseArray(flowMyBusiness.getTodoUsers(), String.class); |
| | | if (todoUsers == null || !todoUsers.contains(user.getUsername())) { |
| | | return Result.error("用户无权操作此任务"); |
| | | } |
| | | |
| | | // 4. 认领任务(处理已被认领的情况) |
| | | String taskId = flowMyBusiness.getTaskId(); |
| | | Task task = taskService.createTaskQuery().taskId(taskId).singleResult(); |
| | | if (task == null) { |
| | | return Result.error("任务不存在或已完成"); |
| | | } |
| | | if (task.getAssignee() != null && !task.getAssignee().equals(user.getUsername())) { |
| | | return Result.error("任务已被他人认领"); |
| | | } |
| | | taskService.claim(taskId, user.getUsername()); |
| | | |
| | | // 设置流程变量 |
| | | Map<String, Object> values = setProcessVariables(eamMaintenanceStandard, userId, eamMaintenanceStandardVo); |
| | | eamMaintenanceStandardVo.setValues(values); |
| | | eamMaintenanceStandardVo.setComment(values.get("comment").toString()); |
| | | // 完成流程任务 |
| | | Result result = flowTaskService.complete(eamMaintenanceStandardVo); |
| | | if (result.isSuccess()) { |
| | | if (eamMaintenanceStandardVo.getRepairManagerApproveResult() != null) { |
| | | if (eamMaintenanceStandardVo.getRepairManagerApproveResult().equals("1")){ |
| | | List<FlowMyBusiness> newbusinessList = flowMyBusinessService.list( |
| | | new QueryWrapper<FlowMyBusiness>() |
| | | .eq("process_instance_id", eamMaintenanceStandardVo.getInstanceId())); |
| | | FlowMyBusiness newflowMyBusiness = newbusinessList.get(0); |
| | | eamMaintenanceStandard.setStandardStatus(MaintenanceStandardStatusEnum.WAIT_TECHNICAL_DIRECTOR.name()); |
| | | //获取flow的流程实例id,设置下一步的处理人员 |
| | | EamMaintenanceStandard maintenanceStandard=this.getById(eamMaintenanceStandardVo.getDataId()); |
| | | EamEquipment eamEquipment=eamEquipmentService.getById(maintenanceStandard.getEquipmentId()); |
| | | BaseFactory baseFactory=baseFactoryService.getOne(new QueryWrapper<BaseFactory>().eq("org_code", eamEquipment.getFactoryOrgCode())); |
| | | List<UserSelector> userSelectorList=sysUserService.selectOperatorFactoryList(eamEquipment.getEquipmentCode(),baseFactory.getId(), BusinessCodeConst.PCR0008); |
| | | if (!CollectionUtils.isEmpty(userSelectorList)) { |
| | | List<String> usernameList=userSelectorList.stream().map(UserSelector::getUsername).collect(Collectors.toList()); |
| | | newflowMyBusiness.setTodoUsers(JSON.toJSONString(usernameList)); |
| | | flowMyBusinessService.updateById(newflowMyBusiness); |
| | | } |
| | | }else { |
| | | eamMaintenanceStandard.setStandardStatus(MaintenanceStandardStatusEnum.WAIT_SUBMIT.name()); |
| | | } |
| | | eamMaintenanceStandard.setRepairManager(user.getUsername()); |
| | | eamMaintenanceStandard.setRepairManagerApproveResult(eamMaintenanceStandardVo.getRepairManagerApproveResult()); |
| | | eamMaintenanceStandard.setRepairManagerApproveTime(new Date()); |
| | | eamMaintenanceStandard.setRepairManagerApproveComment(eamMaintenanceStandardVo.getComment()); |
| | | } |
| | | if (eamMaintenanceStandardVo.getTechnicalManagerApproveResult() != null) { |
| | | if (eamMaintenanceStandardVo.getTechnicalManagerApproveResult().equals("1")){ |
| | | eamMaintenanceStandard.setStandardStatus(MaintenanceStandardStatusEnum.START.name()); |
| | | //判断是否进行升版,通过设备编号、保养分类、状态进行筛选 |
| | | EamMaintenanceStandard maintenanceStandard=this.getById(eamMaintenanceStandardVo.getDataId()); |
| | | QueryWrapper<EamMaintenanceStandard> queryWrapper=new QueryWrapper<>(); |
| | | queryWrapper.eq("equipment_id", maintenanceStandard.getEquipmentId()); |
| | | queryWrapper.eq("maintenance_category", maintenanceStandard.getMaintenanceCategory()); |
| | | queryWrapper.eq("standard_status", MaintenanceStandardStatusEnum.START.name()); |
| | | List<EamMaintenanceStandard> list=eamMaintenanceStandardMapper.selectList(queryWrapper); |
| | | if (!CollectionUtils.isEmpty(list)) { |
| | | //作废原有 |
| | | for (EamMaintenanceStandard eamMaintenanceStandard1 : list) { |
| | | eamMaintenanceStandard1.setStandardStatus(MaintenanceStandardStatusEnum.ABOLISH.name()); |
| | | this.updateById(eamMaintenanceStandard1); |
| | | } |
| | | } |
| | | }else { |
| | | eamMaintenanceStandard.setStandardStatus(MaintenanceStandardStatusEnum.WAIT_SUBMIT.name()); |
| | | } |
| | | eamMaintenanceStandard.setTechnicalManager(user.getUsername()); |
| | | eamMaintenanceStandard.setTechnicalManagerApproveResult(eamMaintenanceStandardVo.getTechnicalManagerApproveResult()); |
| | | eamMaintenanceStandard.setTechnicalManagerApproveTime(new Date()); |
| | | eamMaintenanceStandard.setTechnicalManagerApproveComment(eamMaintenanceStandardVo.getComment()); |
| | | } |
| | | this.updateById(eamMaintenanceStandard); |
| | | } else { |
| | | return result; |
| | | } |
| | | return Result.OK("操作成功"); |
| | | } catch (Exception e) { |
| | | return Result.error("操作失败:" + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | private Map<String, Object> setProcessVariables(EamMaintenanceStandard eamMaintenanceStandard, String userId, EamMaintenanceStandardVo eamMaintenanceStandardVo) { |
| | | Map<String, Object> values = new HashMap<>(); |
| | | values.put("dataId", eamMaintenanceStandard.getId()); |
| | | values.put("assignee", userId); |
| | | if (eamMaintenanceStandardVo.getRepairManagerApproveResult() != null) { |
| | | values.put("repairManagerApproveResult", eamMaintenanceStandardVo.getRepairManagerApproveResult()); |
| | | values.put("organization", eamMaintenanceStandardVo.getRepairManagerApproveComment()); |
| | | values.put("comment", eamMaintenanceStandardVo.getRepairManagerApproveComment()); |
| | | } |
| | | if (eamMaintenanceStandardVo.getTechnicalManagerApproveResult() != null) { |
| | | values.put("technicalManagerApproveResult", eamMaintenanceStandardVo.getTechnicalManagerApproveResult()); |
| | | values.put("organization", eamMaintenanceStandardVo.getTechnicalManagerApproveComment()); |
| | | values.put("comment", eamMaintenanceStandardVo.getTechnicalManagerApproveComment()); |
| | | } |
| | | return values; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void afterFlowHandle(FlowMyBusiness business) { |
| | | business.getTaskNameId();//接下来审批的节点 |
| | | business.getValues();//前端传进来的参数 |
| | | business.getActStatus(); |
| | | } |
| | | |
| | | @Override |
| | | public Object getBusinessDataById(String dataId) { |
| | | return this.getById(dataId); |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> flowValuesOfTask(String taskNameId, Map<String, Object> values) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public List<String> flowCandidateUsernamesOfTask(String taskNameId, Map<String, Object> values) { |
| | | //业务是否干预流程,业务干预,流程干预,指定人员进行处理 |
| | | return null; |
| | | } |
| | | |
| | | /*流程业务代码--------------------------结束*/ |
| | | |
| | | |
| | | /*导入文件--------------------------开始*/ |
| | | /** |
| | | * 导入点检表数据 |
| | | * @param file Excel文件 |
| | | * @return 导入结果 |
| | | */ |
| | | // public Result<?> importInspectionData(MultipartFile file) { |
| | | // int successCount = 0; |
| | | // |
| | | // try (Workbook workbook = WorkbookFactory.create(file.getInputStream())) { |
| | | // Sheet sheet = workbook.getSheetAt(0); |
| | | // // 1. 解析表头信息 |
| | | // Map<String, String> header = parseHeader(sheet, errors); |
| | | // |
| | | // } catch (Exception e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // |
| | | // return new ImportResult(successCount, errors); |
| | | // } |
| | | |
| | | /** |
| | | * 解析表头信息 |
| | | */ |
| | | // private Map<String, String> parseHeader(Sheet sheet, List<ImportError> errors) { |
| | | // Map<String, String> header = new HashMap<>(); |
| | | // try { |
| | | // Row headerRow = sheet.getRow(0); |
| | | // // 示例:第一行:设备名称:割炬 型号:gta001 统一编号:xc001 |
| | | // String cellValue = getCellStringValue(headerRow.getCell(0)); |
| | | // |
| | | // // 使用正则表达式解析关键信息 |
| | | // Pattern pattern = Pattern.compile("设备名称[::](\\S+)\\s+型号[::](\\S+)\\s+统一编号[::](\\S+)\\s+日期[::](\\S+)\\s+单位[::](\\S+)"); |
| | | // Matcher matcher = pattern.matcher(cellValue); |
| | | // |
| | | // if (matcher.find()) { |
| | | // header.put("deviceName", matcher.group(1)); |
| | | // header.put("deviceModel", matcher.group(2)); |
| | | // header.put("deviceCode", matcher.group(3)); |
| | | // header.put("inspectionMonth", matcher.group(4)); |
| | | // header.put("unit", matcher.group(5)); |
| | | // } else { |
| | | // errors.add(new ImportError("表头格式错误", cellValue, 1)); |
| | | // } |
| | | // } catch (Exception e) { |
| | | // errors.add(new ImportError("解析表头异常", e.getMessage(), 1)); |
| | | // } |
| | | // return header; |
| | | // } |
| | | // |
| | | // /** |
| | | // * 解析每日点检项目 |
| | | // */ |
| | | // private List<InspectionItem> parseDailyItems(Sheet sheet, List<ImportError> errors) { |
| | | // List<InspectionItem> items = new ArrayList<>(); |
| | | // |
| | | // // 点检项目从第3行开始(序号从1开始) |
| | | // int startRow = 2; |
| | | // int rowNum = startRow; |
| | | // |
| | | // try { |
| | | // // 找到每日点检表的结束位置(维护责任人签字) |
| | | // while (rowNum <= sheet.getLastRowNum()) { |
| | | // Row row = sheet.getRow(rowNum); |
| | | // if (row == null) { |
| | | // rowNum++; |
| | | // continue; |
| | | // } |
| | | // |
| | | // // 判断是否到达结束位置 |
| | | // String sequenceValue = getCellStringValue(row.getCell(0)); |
| | | // if ("9".equals(sequenceValue) || "维护责任人签字".contains(sequenceValue)) { |
| | | // break; |
| | | // } |
| | | // |
| | | // // 解析项目行 |
| | | // InspectionItem item = new InspectionItem(); |
| | | // item.setSequence(Integer.parseInt(sequenceValue)); |
| | | // item.setProjectName(getCellStringValue(row.getCell(1))); |
| | | // item.setRequirement(getCellStringValue(row.getCell(2))); |
| | | // |
| | | // items.add(item); |
| | | // rowNum++; |
| | | // } |
| | | // } catch (Exception e) { |
| | | // errors.add(new ImportError("解析每日项目异常", e.getMessage(), rowNum + 1)); |
| | | // } |
| | | // |
| | | // return items; |
| | | // } |
| | | // |
| | | // /** |
| | | // * 解析周保养项目 |
| | | // */ |
| | | // private List<InspectionItem> parseWeeklyItems(Sheet sheet, List<ImportError> errors) { |
| | | // List<InspectionItem> items = new ArrayList<>(); |
| | | // |
| | | // try { |
| | | // // 定位周保养标题行(行号11) |
| | | // int startRow = 10; |
| | | // |
| | | // // 从第12行开始是周保养项目 |
| | | // for (int rowNum = startRow + 1; rowNum <= sheet.getLastRowNum(); rowNum++) { |
| | | // Row row = sheet.getRow(rowNum); |
| | | // if (row == null) continue; |
| | | // |
| | | // String sequenceValue = getCellStringValue(row.getCell(0)); |
| | | // |
| | | // // 遇到结束标志则停止解析 |
| | | // if ("周保养操作者执行".contains(sequenceValue)) break; |
| | | // |
| | | // try { |
| | | // InspectionItem item = new InspectionItem(); |
| | | // item.setSequence(Integer.parseInt(sequenceValue)); |
| | | // item.setProjectName(getCellStringValue(row.getCell(1))); |
| | | // item.setStandard(getCellStringValue(row.getCell(2))); |
| | | // item.setRequirement(getCellStringValue(row.getCell(3))); // 执行记录 |
| | | // |
| | | // items.add(item); |
| | | // } catch (Exception e) { |
| | | // errors.add(new ImportError("解析周保养项目异常", e.getMessage(), rowNum + 1)); |
| | | // } |
| | | // } |
| | | // } catch (Exception e) { |
| | | // errors.add(new ImportError("定位周保养项目异常", e.getMessage(), 0)); |
| | | // } |
| | | // |
| | | // return items; |
| | | // } |
| | | /*导入文件--------------------------结束*/ |
| | | } |