| | |
| | | package org.jeecg.modules.eam.service.impl; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | 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 org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | 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.modules.eam.request.EamWeekMaintenanceRequest; |
| | | import org.jeecg.modules.eam.service.IEamWeekMaintenanceOrderDetailService; |
| | | import org.jeecg.modules.eam.service.IEamWeekMaintenanceOrderService; |
| | | import org.jeecg.modules.flowable.apithird.business.entity.FlowMyBusiness; |
| | | 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.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | * @Date: 2025-04-02 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Service |
| | | public class EamWeekMaintenanceOrderServiceImpl extends ServiceImpl<EamWeekMaintenanceOrderMapper, EamWeekMaintenanceOrder> implements IEamWeekMaintenanceOrderService { |
| | | @Service("IEamWeekMaintenanceOrderService") |
| | | public class EamWeekMaintenanceOrderServiceImpl extends ServiceImpl<EamWeekMaintenanceOrderMapper, EamWeekMaintenanceOrder> implements IEamWeekMaintenanceOrderService, FlowCallBackServiceI { |
| | | |
| | | @Resource |
| | | private EamWeekMaintenanceOrderMapper eamWeekMaintenanceOrderMapper; |
| | | |
| | | @Autowired |
| | | private IEamWeekMaintenanceOrderDetailService eamWeekMaintenanceOrderDetailService; |
| | | |
| | | @Resource |
| | | private FlowCommonService flowCommonService; |
| | | @Resource |
| | | private IFlowDefinitionService flowDefinitionService; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | }); |
| | | eamWeekMaintenanceOrderDetailService.saveBatch(request.getTableDetailList()); |
| | | } |
| | | //判断是否存在保养人 如果存在则启动流程 |
| | | //TODO |
| | | return true; |
| | | } |
| | | |
| | |
| | | List<String> ids = request.getRemoveDetailList().stream().map(EamWeekMaintenanceOrderDetail::getId).collect(Collectors.toList()); |
| | | eamWeekMaintenanceOrderDetailService.removeBatchByIds(ids); |
| | | } |
| | | //判断是否存在保养人 如果存在则启动流程 |
| | | //TODO |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean collect(String id) { |
| | | EamWeekMaintenanceOrder entity = eamWeekMaintenanceOrderMapper.selectById(id); |
| | | if(entity == null) { |
| | | throw new JeecgBootException("要领取的工单不存在,请刷新重试!"); |
| | | } |
| | | if(!MaintenanceStatusEnum.WAIT_MAINTENANCE.name().equals(entity.getMaintenanceStatus())) { |
| | | throw new JeecgBootException("该工单已进行过领取!"); |
| | | } |
| | | LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | entity.setOperator(sysUser.getUsername()); |
| | | entity.setMaintenanceStatus(MaintenanceStatusEnum.UNDER_MAINTENANCE.name()); |
| | | eamWeekMaintenanceOrderMapper.updateById(entity); |
| | | |
| | | //启动流程 |
| | | flowCommonService.initActBusiness("工单号:" + entity.getOrderNum() + ";开始进行设备周保", |
| | | 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){ |
| | | return result.isSuccess(); |
| | | } |
| | | 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; |
| | | } |
| | | } |