¶Ô±ÈÐÂÎļþ |
| | |
| | | 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.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.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.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.aspect.annotation.EquipmentHistoryLog; |
| | | import org.jeecg.modules.eam.constant.*; |
| | | import org.jeecg.modules.eam.entity.EamEquipment; |
| | | import org.jeecg.modules.eam.entity.EamWeekMaintenanceOrder; |
| | | import org.jeecg.modules.eam.entity.EamWeekMaintenanceOrderDetail; |
| | | import org.jeecg.modules.eam.mapper.EamWeekMaintenanceOrderMapper; |
| | | import org.jeecg.modules.eam.request.EamWeekMaintenanceQuery; |
| | | import org.jeecg.modules.eam.request.EamWeekMaintenanceRequest; |
| | | import org.jeecg.modules.eam.service.*; |
| | | 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.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @Description: å¨ä¿å·¥å |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-04-02 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Service("IEamWeekMaintenanceOrderService") |
| | | public class EamWeekMaintenanceOrderServiceImpl extends ServiceImpl<EamWeekMaintenanceOrderMapper, EamWeekMaintenanceOrder> implements IEamWeekMaintenanceOrderService, FlowCallBackServiceI { |
| | | |
| | | @Resource |
| | | private EamWeekMaintenanceOrderMapper eamWeekMaintenanceOrderMapper; |
| | | |
| | | @Autowired |
| | | private IEamWeekMaintenanceOrderDetailService eamWeekMaintenanceOrderDetailService; |
| | | |
| | | @Autowired |
| | | private FlowCommonService flowCommonService; |
| | | @Autowired |
| | | private IFlowDefinitionService flowDefinitionService; |
| | | @Autowired |
| | | private IFlowMyBusinessService flowMyBusinessService; |
| | | @Autowired |
| | | private TaskService taskService; |
| | | @Autowired |
| | | private IFlowTaskService flowTaskService; |
| | | |
| | | @Autowired |
| | | private ISysUserService sysUserService; |
| | | @Autowired |
| | | private IEamEquipmentService eamEquipmentService; |
| | | @Autowired |
| | | private IEamReportRepairService eamReportRepairService; |
| | | @Autowired |
| | | private IEamEquipmentExtendService eamEquipmentExtendService; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean addWeekMaintenance(EamWeekMaintenanceRequest request) { |
| | | EamEquipment equipment = eamEquipmentService.getById(request.getEquipmentId()); |
| | | if (equipment == null) { |
| | | throw new JeecgBootException("设å¤ä¸åå¨ï¼æ·»å 失败ï¼"); |
| | | } |
| | | EamWeekMaintenanceOrder order = new EamWeekMaintenanceOrder(); |
| | | order.setOrderNum(request.getOrderNum()); |
| | | order.setEquipmentId(request.getEquipmentId()); |
| | | order.setStandardId(request.getStandardId()); |
| | | order.setMaintenanceDate(request.getMaintenanceDate()); |
| | | order.setOperator(request.getOperator()); |
| | | order.setRemark(request.getRemark()); |
| | | //ç¶æåå§å |
| | | order.setMaintenanceStatus(WeekMaintenanceStatusEnum.WAIT_MAINTENANCE.name()); |
| | | order.setCreationMethod(request.getCreationMethod()); |
| | | //å 餿 è®° |
| | | order.setDelFlag(CommonConstant.DEL_FLAG_0); |
| | | eamWeekMaintenanceOrderMapper.insert(order); |
| | | //å¤çæç»æ°æ® |
| | | if (CollectionUtil.isNotEmpty(request.getTableDetailList())) { |
| | | request.getTableDetailList().forEach(tableDetail -> { |
| | | tableDetail.setId(null); |
| | | tableDetail.setOrderId(order.getId()); |
| | | }); |
| | | eamWeekMaintenanceOrderDetailService.saveBatch(request.getTableDetailList()); |
| | | } |
| | | //夿æ¯å¦åå¨ä¿å
»äºº 妿åå¨åå¯å¨æµç¨ |
| | | if (StringUtils.isNotBlank(order.getOperator())) { |
| | | //å¯å¨æµç¨ |
| | | flowCommonService.initActBusiness("å·¥åå·:" + order.getOrderNum() + ";设å¤ç¼å·: " + equipment.getEquipmentCode() + ";è¿è¡è®¾å¤å¨ä¿", |
| | | order.getId(), "IEamWeekMaintenanceOrderService", "week_maintenance_process", null); |
| | | Map<String, Object> variables = new HashMap<>(); |
| | | variables.put("dataId", order.getId()); |
| | | if (StrUtil.isEmpty(order.getRemark())) { |
| | | variables.put("organization", "æ°å¢å¨ä¿å·¥åé»è®¤å¯å¨æµç¨"); |
| | | variables.put("comment", "æ°å¢å¨ä¿å·¥åé»è®¤å¯å¨æµç¨"); |
| | | } else { |
| | | variables.put("organization", order.getRemark()); |
| | | variables.put("comment", order.getRemark()); |
| | | } |
| | | variables.put("proofreading", true); |
| | | List<String> usernames = new ArrayList<>(); |
| | | usernames.add(order.getOperator()); |
| | | variables.put("NextAssignee", usernames); |
| | | Result result = flowDefinitionService.startProcessInstanceByKey("week_maintenance_process", variables); |
| | | if (result != null) { |
| | | //æ´æ°å¨ä¿ç¶æ |
| | | order.setMaintenanceStatus(WeekMaintenanceStatusEnum.UNDER_MAINTENANCE.name()); |
| | | order.setActualStartTime(new Date()); |
| | | eamWeekMaintenanceOrderMapper.updateById(order); |
| | | //æ´æ°è®¾å¤ä¿å
»ç¶æ |
| | | eamEquipmentExtendService.updateEquipmentMaintenanceStatus(order.getEquipmentId(), EquipmentMaintenanceStatus.UNDER_WEEK_MAINTENANCE.name()); |
| | | return result.isSuccess(); |
| | | } |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public IPage<EamWeekMaintenanceOrder> queryPageList(Page<EamWeekMaintenanceOrder> page, EamWeekMaintenanceQuery query) { |
| | | QueryWrapper<EamWeekMaintenanceOrder> queryWrapper = new QueryWrapper<>(); |
| | | //ç¨æ·æ°æ®æé |
| | | LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | if (sysUser == null) { |
| | | return page; |
| | | } |
| | | if (StringUtils.isNotBlank(sysUser.getEquipmentIds())) { |
| | | //éæ©äºè®¾å¤ï¼æ ¹æ®è®¾å¤idè¿æ»¤è®¾å¤ |
| | | List<String> equipArr = Arrays.asList(sysUser.getEquipmentIds().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()); |
| | | } |
| | | //æ¥è¯¢æ¡ä»¶è¿æ»¤ |
| | | if (query != null) { |
| | | if (StringUtils.isNotBlank(query.getEquipmentId())) { |
| | | queryWrapper.eq("wmo.equipment_id", query.getEquipmentId()); |
| | | } |
| | | if (StringUtils.isNotBlank(query.getOrderNum())) { |
| | | queryWrapper.like("wmo.order_num", query.getOrderNum()); |
| | | } |
| | | if (StringUtils.isNotBlank(query.getMaintenanceStatus())) { |
| | | queryWrapper.eq("wmo.maintenance_status", query.getMaintenanceStatus()); |
| | | } |
| | | if (query.getMaintenanceDateBegin() != null && query.getMaintenanceDateEnd() != null) { |
| | | queryWrapper.between("wmo.maintenance_date", query.getMaintenanceDateBegin(), query.getMaintenanceDateEnd()); |
| | | } |
| | | //æåº |
| | | if (StringUtils.isNotBlank(query.getColumn()) && StringUtils.isNotBlank(query.getOrder())) { |
| | | String column = query.getColumn(); |
| | | if (column.endsWith(CommonConstant.DICT_TEXT_SUFFIX)) { |
| | | column = column.substring(0, column.lastIndexOf(CommonConstant.DICT_TEXT_SUFFIX)); |
| | | } |
| | | if (DataBaseConstant.SQL_ASC.equalsIgnoreCase(query.getOrder())) { |
| | | queryWrapper.orderByAsc("wmo." + oConvertUtils.camelToUnderline(column)); |
| | | } else { |
| | | queryWrapper.orderByDesc("wmo." + oConvertUtils.camelToUnderline(column)); |
| | | } |
| | | } else { |
| | | queryWrapper.orderByDesc("wmo.create_time"); |
| | | } |
| | | } else { |
| | | queryWrapper.orderByDesc("wmo.create_time"); |
| | | } |
| | | |
| | | return eamWeekMaintenanceOrderMapper.queryPageList(page, queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean editWeekMaintenance(EamWeekMaintenanceRequest request) { |
| | | EamEquipment equipment = eamEquipmentService.getById(request.getEquipmentId()); |
| | | if (equipment == null) { |
| | | throw new JeecgBootException("设å¤ä¸åå¨ï¼æ·»å 失败ï¼"); |
| | | } |
| | | EamWeekMaintenanceOrder entity = eamWeekMaintenanceOrderMapper.selectById(request.getId()); |
| | | if (entity == null) { |
| | | throw new JeecgBootException("ç¼è¾çæ°æ®å·²å é¤ï¼è¯·å·æ°éè¯ï¼"); |
| | | } |
| | | if (!WeekMaintenanceStatusEnum.WAIT_MAINTENANCE.name().equals(entity.getMaintenanceStatus())) { |
| | | throw new JeecgBootException("åªæå¾
ä¿å
»ç¶æçæ°æ®æå¯ç¼è¾ï¼"); |
| | | } |
| | | entity.setMaintenanceDate(request.getMaintenanceDate()); |
| | | entity.setOperator(request.getOperator()); |
| | | entity.setRemark(request.getRemark()); |
| | | |
| | | eamWeekMaintenanceOrderMapper.updateById(entity); |
| | | //å¤ç详æ
|
| | | if (CollectionUtil.isNotEmpty(request.getTableDetailList())) { |
| | | List<EamWeekMaintenanceOrderDetail> addList = new ArrayList<>(); |
| | | List<EamWeekMaintenanceOrderDetail> updateList = new ArrayList<>(); |
| | | request.getTableDetailList().forEach(tableDetail -> { |
| | | tableDetail.setOrderId(entity.getId()); |
| | | if (tableDetail.getId() == null) { |
| | | addList.add(tableDetail); |
| | | } else { |
| | | updateList.add(tableDetail); |
| | | } |
| | | }); |
| | | if (CollectionUtil.isNotEmpty(addList)) { |
| | | eamWeekMaintenanceOrderDetailService.saveBatch(addList); |
| | | } |
| | | if (CollectionUtil.isNotEmpty(updateList)) { |
| | | eamWeekMaintenanceOrderDetailService.updateBatchById(updateList); |
| | | } |
| | | } |
| | | if (CollectionUtil.isNotEmpty(request.getRemoveDetailList())) { |
| | | List<String> ids = request.getRemoveDetailList().stream().map(EamWeekMaintenanceOrderDetail::getId).collect(Collectors.toList()); |
| | | eamWeekMaintenanceOrderDetailService.removeBatchByIds(ids); |
| | | } |
| | | //夿æ¯å¦åå¨ä¿å
»äºº 妿åå¨åå¯å¨æµç¨ |
| | | if (StringUtils.isNotBlank(entity.getOperator())) { |
| | | //å¯å¨æµç¨ |
| | | flowCommonService.initActBusiness("å·¥åå·:" + entity.getOrderNum() + ";设å¤ç¼å·: " + equipment.getEquipmentCode() + ";è¿è¡è®¾å¤å¨ä¿", |
| | | entity.getId(), "IEamWeekMaintenanceOrderService", "week_maintenance_process", null); |
| | | Map<String, Object> variables = new HashMap<>(); |
| | | variables.put("dataId", entity.getId()); |
| | | if (StrUtil.isEmpty(entity.getRemark())) { |
| | | variables.put("organization", "æ°å¢å¨ä¿å·¥åé»è®¤å¯å¨æµç¨"); |
| | | variables.put("comment", "æ°å¢å¨ä¿å·¥åé»è®¤å¯å¨æµç¨"); |
| | | } else { |
| | | variables.put("organization", entity.getRemark()); |
| | | variables.put("comment", entity.getRemark()); |
| | | } |
| | | variables.put("proofreading", true); |
| | | List<String> usernames = new ArrayList<>(); |
| | | usernames.add(entity.getOperator()); |
| | | variables.put("NextAssignee", usernames); |
| | | Result result = flowDefinitionService.startProcessInstanceByKey("week_maintenance_process", variables); |
| | | if (result != null) { |
| | | //æ´æ°å¨ä¿ç¶æ |
| | | entity.setMaintenanceStatus(WeekMaintenanceStatusEnum.UNDER_MAINTENANCE.name()); |
| | | entity.setActualStartTime(new Date()); |
| | | eamWeekMaintenanceOrderMapper.updateById(entity); |
| | | //æ´æ°è®¾å¤ä¿å
»ç¶æ |
| | | eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.UNDER_WEEK_MAINTENANCE.name()); |
| | | return result.isSuccess(); |
| | | } |
| | | |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean collect(String id) { |
| | | EamWeekMaintenanceOrder entity = eamWeekMaintenanceOrderMapper.selectById(id); |
| | | if (entity == null) { |
| | | throw new JeecgBootException("è¦é¢åçå·¥åä¸åå¨ï¼è¯·å·æ°éè¯ï¼"); |
| | | } |
| | | if (!WeekMaintenanceStatusEnum.WAIT_MAINTENANCE.name().equals(entity.getMaintenanceStatus())) { |
| | | throw new JeecgBootException("该工åå·²è¿è¡è¿é¢åï¼"); |
| | | } |
| | | EamEquipment equipment = eamEquipmentService.getById(entity.getEquipmentId()); |
| | | if (equipment == null) { |
| | | throw new JeecgBootException("设å¤ä¸åå¨ï¼æ·»å 失败ï¼"); |
| | | } |
| | | LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | if(sysUser == null || !BusinessCodeConst.PCR0001.equals(sysUser.getPost())) { |
| | | throw new JeecgBootException("䏿¯æä½å·¥ï¼æ æ³é¢åæ¤å·¥åï¼"); |
| | | } |
| | | entity.setOperator(sysUser.getUsername()); |
| | | entity.setMaintenanceStatus(WeekMaintenanceStatusEnum.UNDER_MAINTENANCE.name()); |
| | | entity.setActualStartTime(new Date()); |
| | | eamWeekMaintenanceOrderMapper.updateById(entity); |
| | | |
| | | //å¯å¨æµç¨ |
| | | flowCommonService.initActBusiness("å·¥åå·:" + entity.getOrderNum() + ";设å¤ç¼å·: " + equipment.getEquipmentCode() + ";è¿è¡è®¾å¤å¨ä¿", |
| | | entity.getId(), "IEamWeekMaintenanceOrderService", "week_maintenance_process", null); |
| | | Map<String, Object> variables = new HashMap<>(); |
| | | variables.put("dataId", entity.getId()); |
| | | if (StrUtil.isEmpty(entity.getRemark())) { |
| | | variables.put("organization", "æ°å¢å¨ä¿å·¥åé»è®¤å¯å¨æµç¨"); |
| | | variables.put("comment", "æ°å¢å¨ä¿å·¥åé»è®¤å¯å¨æµç¨"); |
| | | } else { |
| | | variables.put("organization", entity.getRemark()); |
| | | variables.put("comment", entity.getRemark()); |
| | | } |
| | | variables.put("proofreading", true); |
| | | List<String> usernames = new ArrayList<>(); |
| | | usernames.add(entity.getOperator()); |
| | | variables.put("NextAssignee", usernames); |
| | | Result result = flowDefinitionService.startProcessInstanceByKey("week_maintenance_process", variables); |
| | | if (result != null) { |
| | | //æ´æ°è®¾å¤ä¿å
»ç¶æ |
| | | eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.UNDER_WEEK_MAINTENANCE.name()); |
| | | return result.isSuccess(); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @EquipmentHistoryLog(operationTag = EquipmentOperationTagEnum.WEEK_MAINTENANCE, businessTable = "eam_week_maintenance_order") |
| | | public EamWeekMaintenanceOrder approval(EamWeekMaintenanceRequest request) { |
| | | EamWeekMaintenanceOrder entity = eamWeekMaintenanceOrderMapper.selectById(request.getId()); |
| | | if (entity == null) { |
| | | throw new JeecgBootException("审æ¹çæ°æ®å·²å é¤ï¼è¯·å·æ°éè¯ï¼"); |
| | | } |
| | | // è·åå½åç»å½ç¨æ· |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | if (user == null || StrUtil.isBlank(user.getId())) { |
| | | throw new JeecgBootException("æªè·åå°ç»å½ç¨æ·ï¼è¯·éæ°ç»å½ååè¯ï¼"); |
| | | } |
| | | request.setAssignee(user.getUsername()); |
| | | // è·åæµç¨ä¸å¡è®°å½ |
| | | FlowMyBusiness flowMyBusiness = flowMyBusinessService.getFlowMyBusiness(request.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(entity.getEquipmentId()); |
| | | if (equipment == null) { |
| | | throw new JeecgBootException("设å¤ä¸åå¨ï¼è¯·æ£æ¥ï¼"); |
| | | } |
| | | |
| | | WeekMaintenanceStatusEnum status = WeekMaintenanceStatusEnum.getInstance(entity.getMaintenanceStatus()); |
| | | if (status == null) { |
| | | return null; |
| | | } |
| | | //æµç¨åé |
| | | Map<String, Object> values = new HashMap<>(); |
| | | List<UserSelector> userSelectors; |
| | | List<String> userApprovalList; |
| | | switch (status) { |
| | | case UNDER_MAINTENANCE: |
| | | //æ§è¡å®æ |
| | | userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getOrgId(), BusinessCodeConst.PCR0003); |
| | | if (CollectionUtil.isEmpty(userSelectors)) { |
| | | throw new JeecgBootException("è®¾å¤æªåé
ç»çç»é¿ï¼æ æ³è¿å
¥ä¸çº§å®¡æ¹ï¼"); |
| | | } |
| | | userApprovalList = userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList()); |
| | | values.put("dataId", entity.getId()); |
| | | values.put("organization", "å¨ä¿æ§è¡ç»æ"); |
| | | values.put("comment", "å¨ä¿æ§è¡ç»æ"); |
| | | values.put("NextAssignee", userApprovalList); |
| | | request.setComment("å¨ä¿æ§è¡ç»æ"); |
| | | //设置entity |
| | | entity.setMaintenanceStatus(WeekMaintenanceStatusEnum.WAIT_CONFIRM.name()); |
| | | entity.setActualEndTime(new Date()); |
| | | //å¤çéä»¶ |
| | | if (CollectionUtil.isNotEmpty(request.getImageFilesResult())) { |
| | | List<FileUploadResult> fileUploadResultList = request.getImageFilesResult(); |
| | | ObjectMapper mapper = new ObjectMapper(); |
| | | try { |
| | | String referenceFile = mapper.writeValueAsString(fileUploadResultList); |
| | | entity.setImageFiles(referenceFile); |
| | | } catch (JsonProcessingException e) { |
| | | log.error("JSON转æ¢å¤±è´¥ï¼" + e.getMessage(), e); |
| | | } |
| | | } |
| | | //å¤ç详æ
|
| | | if (CollectionUtil.isNotEmpty(request.getTableDetailList())) { |
| | | eamWeekMaintenanceOrderDetailService.updateBatchById(request.getTableDetailList()); |
| | | } |
| | | //æ´æ°è®¾å¤ä¿å
»ç¶æ |
| | | eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.WEEK_MAINTENANCE_WAIT_CONFIRM.name()); |
| | | break; |
| | | case WAIT_CONFIRM: |
| | | if (StringUtils.isBlank(equipment.getEquipmentManager())) { |
| | | throw new JeecgBootException("è®¾å¤æªåé
设å¤ç®¡çåï¼æ æ³è¿å
¥ä¸çº§å®¡æ¹ï¼"); |
| | | } |
| | | //çç»é¿ç¡®è®¤ |
| | | userApprovalList = new ArrayList<>(); |
| | | userApprovalList.add(equipment.getEquipmentManager()); |
| | | values.put("dataId", entity.getId()); |
| | | values.put("organization", request.getConfirmComment()); |
| | | values.put("comment", request.getConfirmComment()); |
| | | values.put("NextAssignee", userApprovalList); |
| | | values.put("confirmation", request.getConfirmDealType()); |
| | | request.setComment(request.getConfirmComment()); |
| | | //设置entity |
| | | entity.setMaintenanceStatus(WeekMaintenanceStatusEnum.WAIT_INITIAL_ACCEPTANCE.name()); |
| | | entity.setConfirmUser(user.getUsername()); |
| | | entity.setConfirmComment(request.getConfirmComment()); |
| | | entity.setConfirmTime(new Date()); |
| | | entity.setConfirmDealType(request.getConfirmDealType()); |
| | | if (CommonConstant.HAS_CANCLE.equals(request.getConfirmDealType())) { |
| | | //驳å |
| | | userApprovalList = new ArrayList<>(); |
| | | userApprovalList.add(entity.getOperator()); |
| | | values.put("NextAssignee", userApprovalList); |
| | | entity.setMaintenanceStatus(WeekMaintenanceStatusEnum.UNDER_MAINTENANCE.name()); |
| | | } |
| | | //å¤çæ¥ä¿® |
| | | List<EamWeekMaintenanceOrderDetail> collect = request.getTableDetailList().stream().filter((detail) -> CommonConstant.DEFAULT_1.equals(detail.getReportFlag())).collect(Collectors.toList()); |
| | | if (CollectionUtil.isNotEmpty(collect)) { |
| | | eamReportRepairService.reportRepairFromMaintenance(equipment.getId(), entity.getOperator(), collect); |
| | | } |
| | | break; |
| | | case WAIT_INITIAL_ACCEPTANCE: |
| | | userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getOrgId(), BusinessCodeConst.PCR0005); |
| | | if (CollectionUtil.isEmpty(userSelectors)) { |
| | | throw new JeecgBootException("è®¾å¤æªåé
ç»è®¾è½é¨ç®¡çåï¼æ æ³è¿å
¥ä¸çº§å®¡æ¹ï¼"); |
| | | } |
| | | userApprovalList = userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList()); |
| | | values.put("dataId", entity.getId()); |
| | | values.put("organization", request.getInitialAcceptanceComment()); |
| | | values.put("comment", request.getInitialAcceptanceComment()); |
| | | values.put("NextAssignee", userApprovalList); |
| | | request.setComment(request.getInitialAcceptanceComment()); |
| | | //设置entity |
| | | entity.setMaintenanceStatus(WeekMaintenanceStatusEnum.WAIT_FINAL_ACCEPTANCE.name()); |
| | | entity.setInitialAcceptanceUser(user.getUsername()); |
| | | entity.setInitialAcceptanceComment(request.getInitialAcceptanceComment()); |
| | | entity.setInitialAcceptanceTime(new Date()); |
| | | //å¤çéä»¶ |
| | | if (CollectionUtil.isNotEmpty(request.getInitialAcceptanceFilesResult())) { |
| | | List<FileUploadResult> fileUploadResultList = request.getInitialAcceptanceFilesResult(); |
| | | ObjectMapper mapper = new ObjectMapper(); |
| | | try { |
| | | String referenceFile = mapper.writeValueAsString(fileUploadResultList); |
| | | entity.setInitialAcceptanceFiles(referenceFile); |
| | | } catch (JsonProcessingException e) { |
| | | log.error("JSON转æ¢å¤±è´¥ï¼" + e.getMessage(), e); |
| | | } |
| | | } |
| | | break; |
| | | case WAIT_FINAL_ACCEPTANCE: |
| | | values.put("dataId", entity.getId()); |
| | | values.put("organization", request.getFinalAcceptanceComment()); |
| | | values.put("comment", request.getFinalAcceptanceComment()); |
| | | request.setComment(request.getFinalAcceptanceComment()); |
| | | //设置entity |
| | | entity.setMaintenanceStatus(WeekMaintenanceStatusEnum.COMPLETE.name()); |
| | | entity.setFinalAcceptanceUser(user.getUsername()); |
| | | entity.setFinalAcceptanceComment(request.getFinalAcceptanceComment()); |
| | | entity.setFinalAcceptanceTime(new Date()); |
| | | //å¤çéä»¶ |
| | | if (CollectionUtil.isNotEmpty(request.getFinalAcceptanceFilesResult())) { |
| | | List<FileUploadResult> fileUploadResultList = request.getFinalAcceptanceFilesResult(); |
| | | ObjectMapper mapper = new ObjectMapper(); |
| | | try { |
| | | String referenceFile = mapper.writeValueAsString(fileUploadResultList); |
| | | entity.setFinalAcceptanceFiles(referenceFile); |
| | | } catch (JsonProcessingException e) { |
| | | log.error("JSON转æ¢å¤±è´¥ï¼" + e.getMessage(), e); |
| | | } |
| | | } |
| | | //æ´æ°è®¾å¤ä¿å
»ç¶æ |
| | | eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.NORMAL.name()); |
| | | break; |
| | | } |
| | | request.setValues(values); |
| | | |
| | | // 宿æµç¨ä»»å¡ |
| | | Result result = flowTaskService.complete(request); |
| | | if (!result.isSuccess()) { |
| | | throw new JeecgBootException("审æ¹å¤±è´¥ï¼è¯·å·æ°æ¥çï¼"); |
| | | } |
| | | //ä¿åå·¥å |
| | | eamWeekMaintenanceOrderMapper.updateById(entity); |
| | | return entity; |
| | | } |
| | | |
| | | @Override |
| | | public List<EamWeekMaintenanceOrder> selectUnCompleteOrder(String expiredDate) { |
| | | LambdaQueryWrapper<EamWeekMaintenanceOrder> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.lt(EamWeekMaintenanceOrder::getMaintenanceDate, expiredDate); |
| | | List<String> unCompleteStatus = new ArrayList<>(); |
| | | unCompleteStatus.add(WeekMaintenanceStatusEnum.WAIT_MAINTENANCE.name()); |
| | | unCompleteStatus.add(WeekMaintenanceStatusEnum.UNDER_MAINTENANCE.name()); |
| | | queryWrapper.in(EamWeekMaintenanceOrder::getMaintenanceStatus, unCompleteStatus); |
| | | queryWrapper.orderByAsc(EamWeekMaintenanceOrder::getMaintenanceDate); |
| | | return eamWeekMaintenanceOrderMapper.selectList(queryWrapper); |
| | | } |
| | | |
| | | private boolean isUserAuthorized(FlowMyBusiness flowMyBusiness, LoginUser user) { |
| | | List<String> todoUsers = JSON.parseArray(flowMyBusiness.getTodoUsers(), String.class); |
| | | return todoUsers != null && todoUsers.contains(user.getUsername()); |
| | | } |
| | | |
| | | 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; |
| | | } |
| | | |
| | | @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) { |
| | | //ä¸å¡æ¯å¦å¹²é¢æµç¨ï¼ä¸å¡å¹²é¢ï¼æµç¨å¹²é¢ï¼æå®äººåè¿è¡å¤ç |
| | | //è·åä¸ä¸æ¥å¤ç人 |
| | | Object object = values.get("NextAssignee"); |
| | | return (List<String>) object; |
| | | } |
| | | } |