| | |
| | | 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.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | 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.BusinessCodeConst; |
| | | import org.jeecg.modules.eam.constant.EquipmentMaintenanceStatus; |
| | | import org.jeecg.modules.eam.constant.SecondMaintenanceStatusEnum; |
| | | import org.jeecg.modules.eam.constant.ThirdMaintenanceStatusEnum; |
| | | import org.jeecg.modules.eam.entity.EamEquipment; |
| | |
| | | import org.jeecg.modules.eam.request.EamThirdMaintenanceQuery; |
| | | import org.jeecg.modules.eam.request.EamThirdMaintenanceRequest; |
| | | 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.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | * @Date: 2025-04-29 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Service |
| | | public class EamThirdMaintenanceOrderServiceImpl extends ServiceImpl<EamThirdMaintenanceOrderMapper, EamThirdMaintenanceOrder> implements IEamThirdMaintenanceOrderService { |
| | | @Service("IEamThirdMaintenanceOrderService") |
| | | public class EamThirdMaintenanceOrderServiceImpl extends ServiceImpl<EamThirdMaintenanceOrderMapper, EamThirdMaintenanceOrder> implements IEamThirdMaintenanceOrderService, FlowCallBackServiceI { |
| | | @Resource |
| | | private EamThirdMaintenanceOrderMapper eamThirdMaintenanceOrderMapper; |
| | | @Autowired |
| | |
| | | private IEamReportRepairService eamReportRepairService; |
| | | @Autowired |
| | | private IEamEquipmentExtendService eamEquipmentExtendService; |
| | | @Autowired |
| | | private IEamPrecisionCheckDetailService precisionCheckDetailService; |
| | | |
| | | @Override |
| | | public IPage<EamThirdMaintenanceOrder> queryPageList(Page<EamThirdMaintenanceOrder> page, EamThirdMaintenanceQuery query) { |
| | |
| | | }); |
| | | thirdMaintenanceOrderDetailService.saveBatch(request.getTableDetailList()); |
| | | } |
| | | //处理精度参数 TODO |
| | | |
| | | //判断是否存在保养人 如果存在则启动流程 |
| | | if (StringUtils.isNotBlank(order.getOperator())) { |
| | | //启动流程 TODO |
| | |
| | | entity.setActualStartTime(new Date()); |
| | | eamThirdMaintenanceOrderMapper.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_MAINTENANCE.name()); |
| | | // return result.isSuccess(); |
| | | // } |
| | | //启动流程 |
| | | flowCommonService.initActBusiness("工单号:" + entity.getOrderNum() + ";设备编号: " + equipment.getEquipmentCode() + ";进行设备三保", |
| | | entity.getId(), "IEamThirdMaintenanceOrderService", "third_maintenance_process", null); |
| | | Map<String, Object> variables = new HashMap<>(); |
| | | boolean equipmentPrecisionFlag = precisionCheckDetailService.hasPrecisionCheckDetail(entity.getId()); |
| | | variables.put("equipmentPrecisionFlag", equipmentPrecisionFlag); |
| | | 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("third_maintenance_process", variables); |
| | | if (result != null) { |
| | | //更新设备保养状态 |
| | | eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.UNDER_THIRD_MAINTENANCE.name()); |
| | | return result.isSuccess(); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | 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; |
| | | } |
| | | } |