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

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.engine.core.impl.Service;
import com.engine.htsc.general.dao.UfZbsplDao;
import com.engine.htsc.general.model.UfZbspl;
import com.engine.htsc.general.model.UfZbsplVo;
import com.engine.htsc.general.model.ZbDept;
import com.engine.htsc.general.model.ZbUser;
import com.engine.htsc.general.service.GeneralPaymentLinkService;
import com.engine.htsc.general.tools.ItUfzbsplServiceTools;
import com.engine.htsc.general.tools.UfzbsplServiceTools;
import weaver.general.Util;
import weaver.interfaces.htsc.GlobatTools.JAVATools;

import java.util.*;

public class ItGeneralPaymentLinkServiceImpl extends GeneralPaymentLinkServiceImpl {

    protected ItUfzbsplServiceTools itUfzbsplServiceTools = new ItUfzbsplServiceTools();

    protected List<UfZbsplVo> getReportVO(String unnumbercode, List<Map<String, String>> reqMapList ,List fycdbmList) {
        List<UfZbsplVo> respListBefore = new ArrayList<>();
        //合并不同入参
        for(Map<String,String> mingxiMap : reqMapList) {
            //根据不同业务获取Dao层入参
            Map<String,String> mapReqSql = this.getMapReqSql(unnumbercode, mingxiMap);
            //查询初步符合条件的审批链
            List<UfZbspl> ufZbsplList = ufZbsplDao.getUfZbspl(mapReqSql);
            //条件过滤并赋值
            List<UfZbsplVo> ufZbsplVoList = itUfzbsplServiceTools.convertModelToVO(ufZbsplList,mingxiMap.get("ngr"),(HashMap)mingxiMap,unnumbercode,fycdbmList);
            respListBefore.addAll(ufZbsplVoList);
        }
        return respListBefore;
    }

    /**
     * 根据map生成查询审批链的条件map
     * [子类按需重写]
     * @param mapR
     * @return
     */
    protected Map<String,String> getMapReqSql(String unumbercode,Map<String,String> mapR) {
        HashMap<String,String> mapReqSql = new HashMap<>();
        ZbUser zbUser = new ZbUser(mapR.get("ngr"));
        String cxsprjs = zbUser.getJobGradeLevel();
        mapReqSql.put("cxspr","ngr");//查询审批人
        mapReqSql.put("cxsprjs",cxsprjs);//查询审批人角色
        mapReqSql.put("sslc",unumbercode);//查询所属流程
        mapReqSql.put("userCode","WK_" + zbUser.getWorkCode());//直接使用人员Code进行匹配
        return mapReqSql;
    }
}
