//package com.bonus.material.common.utils;
//
//import com.bonus.common.biz.constant.MaterialConstants;
//import com.bonus.material.basic.service.IBmConfigService;
//import com.bonus.material.task.domain.TmTaskAuditLogs;
//import com.bonus.material.task.domain.TmTaskAuditResult;
//import com.bonus.material.task.service.ITmTaskAuditLogsService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.util.CollectionUtils;
//import java.util.ArrayList;
//import java.util.List;
//
//public class AuditTool {
//
//    @Autowired
//    private IBmConfigService bmConfigService;
//
//    @Autowired
//    private ITmTaskAuditLogsService tmTaskAuditLogsService;
//
//    public TmTaskAuditResult getAuditResult(Long taskId, Long taskType) {
//        List<String> needRoles = new ArrayList<>();
//        if (MaterialConstants.LEASE_TASK.equals(taskType)) {
//            needRoles = bmConfigService.getLeaseTaskAuditRoleKeys();
//        }
//        //TODO, add more tasks logic to get needRoles
//        if (CollectionUtils.isEmpty(needRoles)) {
//            return new TmTaskAuditResult(true);
//        } else {
//            List<String> auditRoleKeys = tmTaskAuditLogsService.selectTmTaskAuditRoleKeyList(new TmTaskAuditLogs(taskId, taskType));
//            String nextRole = needRoles.get(0);
//            boolean isFinished = false;
//            for (int i = 0; i < needRoles.size(); i++) {
//                if (i < needRoles.size() - 1) {
//                    // 遍历，还没到最后一个
//                    if (auditRoleKeys.contains(needRoles.get(i))) {
//                        nextRole = needRoles.get(i + 1);
//                    }
//                } else {
//                    // 遍历，已经到最后一个了
//                    if (auditRoleKeys.contains(needRoles.get(i))) {
//                        nextRole = "";
//                        isFinished = true;
//                    }
//                }
//            }
//            return new TmTaskAuditResult(isFinished, needRoles, nextRole);
//        }
//    }
//}
