package com.engine.htsc.subcompany.service.impl;

import com.engine.htsc.subcompany.model.ReportSequenceVO;
import com.engine.htsc.subcompany.model.UfZgsspl;
import com.engine.htsc.subcompany.model.ZgsUser;
import com.engine.htsc.subcompany.tools.ZgsclUfzgsServiceTools;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class SubClCompanyLinkServiceImpl extends SubCompanyLinkServiceImpl {

    protected ZgsclUfzgsServiceTools zgsclUfzgsServiceTools = new ZgsclUfzgsServiceTools();

    @Override
    protected List<ReportSequenceVO> getReportVO(String unumbercode, List<Map<String,String>> reqMapList) {
        List<ReportSequenceVO> respListBefore = new ArrayList<>();
        for(Map<String,String> mingxiMap : reqMapList) {
            Map<String,String> mapReqSql = getMapReqSql(unumbercode, mingxiMap);
            //查询初步符合条件的审批链
            List<UfZgsspl> ufFzjgsplList = ufZgssplDao.getUfzgsspl(mapReqSql);
            //条件过滤并赋值
            List<ReportSequenceVO> fzjgsplVoList = zgsclUfzgsServiceTools.convertModelToVO(ufFzjgsplList,mingxiMap.get("bxry"),(HashMap)mingxiMap,unumbercode);
            respListBefore.addAll(fzjgsplVoList);
        }
        return respListBefore;
    }

    @Override
    protected Map<String,String> getMapReqSql(String unumbercode,Map<String,String> map) {
        HashMap<String,String> mapReqSql = new HashMap<>();
        String cxsprjs = ufzgsplModelTools.getUfzgsJobGrade(map.get("bxry"));
        ZgsUser zgsUser = new ZgsUser(map.get("bxry"));
        mapReqSql.put("cxspr","bxry");//查询审批人
        mapReqSql.put("cxsprjs",cxsprjs);//查询审批人角色
        mapReqSql.put("sslc",unumbercode);//查询所属流程
        mapReqSql.put("userCode","WK_" + zgsUser.getWorkCode());//查询单个人
        return mapReqSql;
    }
}
