package org.jeecg.modules.flowpath.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.flowpath.entity.ItdmFlowPathStep;
import org.jeecg.modules.flowpath.mapper.ItdmFlowPathStepMapper;
import org.jeecg.modules.flowpath.service.IItdmFlowPathStepService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @Description: 流程步骤表
 * @Author: jeecg-boot
 * @Date:   2023-07-20
 * @Version: V1.0
 */
@Service
public class ItdmFlowPathStepServiceImpl extends ServiceImpl<ItdmFlowPathStepMapper, ItdmFlowPathStep> implements IItdmFlowPathStepService {

    @Autowired
    @SuppressWarnings("all")
    private ItdmFlowPathStepMapper flowPathStepMapper;


    /**根据运行流程表的流程步骤id查对应流程步骤表的步骤顺序*/
    public String getSortByFlowPathStepId(String dqStep){
        return flowPathStepMapper.getSortByFlowPathStepId(dqStep);
    }

    /**新增运行流程——选择下一步操作的人*/
    public List<String> AddSelectNextStepUser() {
        ItdmFlowPathStep itdmFlowPathStep = this.baseMapper.selectOne(Wrappers.lambdaQuery(ItdmFlowPathStep.class)
                .eq(ItdmFlowPathStep::getSort, "1")
        );

        String userIds = itdmFlowPathStep.getUserIds();
        List<String> userIdList = new ArrayList<>();
        if(userIds!=null && !userIds.equals("")){
            userIdList = Arrays.asList(userIds.split(","));
        }
        return userIdList;
    }

}
