<%@page import="weaver.conn.RecordSet"%>
<%@ page import="org.apache.commons.lang3.StringUtils" %>
<%@ page import="weaver.general.Util" %>
<%@ page import="java.util.*" %>
<%@ page import="weaver.conn.RecordSetDataSource" %>
<%@ page import="weaver.general.BaseBean" %>
<jsp:useBean id="bb" class="weaver.general.BaseBean" scope="page" />
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%
    String dataResource = "E7TEST";
    List<String> E7HrmjobtitlesList = getE7HrmjobtitlesList(dataResource);
    List<String> E9jobtitlesList = getE9HrmjobtitlesList();


    String E7IDS = "";
    out.println("E7比E9多的:</br>");
    for(String e7id : E7HrmjobtitlesList){
        if(!E9jobtitlesList.contains(e7id)){
            E7IDS += StringUtils.isBlank(E7IDS) ? e7id : ","+e7id ;
        }
    }
    out.println(E7IDS+"</br>");

    out.println("E9比E7多的:</br>");
    String E9IDS = "";
    for(String e9id : E9jobtitlesList){
        if(!E7HrmjobtitlesList.contains(e9id)){
            E9IDS += StringUtils.isBlank(E9IDS) ? e9id : ","+ e9id ;
        }
    }
    out.println(E9IDS+"</br>");

%>

<%!

    public List<String> getE9HrmjobtitlesList(){

        RecordSet rs = new RecordSet();
        List<String> jobtitlesList = new ArrayList<String>();
        String sql = " select id,outkey from hrmjobtitles " ;
        rs.executeQuery(sql);
        while (rs.next()){
            String outkey = Util.null2String(rs.getString("outkey"));
            jobtitlesList.add(outkey);
        }
        return jobtitlesList;
    }


    /***
     *
     * @return
     */
    public List<String> getE7HrmjobtitlesList(String dataResource){

        RecordSetDataSource rsd = new RecordSetDataSource(dataResource);
        List<String> E7HrmjobtitlesList = new ArrayList<String>();
        String sql = " select id from hrmjobtitles " ;
        rsd.execute(sql);
        while (rsd.next()){
            String id = Util.null2String(rsd.getString("id"));
            E7HrmjobtitlesList.add(id);
        }
        return E7HrmjobtitlesList;
    }


    public List<String> getE7HrmTitlesList(String dataResource){

        RecordSetDataSource rsd = new RecordSetDataSource(dataResource);
        List<String> E7JobtitlesList = new ArrayList<String>();
        String sql = " select id from hrmjobactivities " ;
        rsd.execute(sql);
        while (rsd.next()){
            String id = Util.null2String(rsd.getString("id"));
            E7JobtitlesList.add(id);
        }
        return E7JobtitlesList;
    }


    public Map<String,String> getE9HrmJobActivitiesList(){

        RecordSet rs = new RecordSet();
        Map<String,String> E7JobtitlesMap = new HashMap<String,String>();
        String sql =" select id,outkey from hrmjobactivities where id in(select jobactivityid from hrmjobtitles) ";
        rs.execute(sql);
        while (rs.next()){
            String id = Util.null2String(rs.getString("id"));
            String outkey = Util.null2String(rs.getString("outkey"));
            E7JobtitlesMap.put(id,outkey);
        }
        return E7JobtitlesMap;
    }


    public Map<String,Map<String,String>> getE7HrmTitlesList2(String dataResource){

        RecordSetDataSource rsd = new RecordSetDataSource(dataResource);
        Map<String,Map<String,String>> E7JobtitlesMap = new HashMap<String,Map<String,String>>();
        String sql = " select id,jobtitlemark,jobtitlename,jobactivityid,jobdepartmentid,jobtitlecode from hrmjobtitles " ;
        rsd.execute(sql);
        while (rsd.next()){
            String e7id = Util.null2String(rsd.getString("id"));
            String e7jobtitlemark = Util.null2String(rsd.getString("jobtitlemark"));
            String e7jobtitlename = Util.null2String(rsd.getString("jobtitlename"));
            String e7jobactivityid = Util.null2String(rsd.getString("jobactivityid"));
            String e7jobdepartmentid = Util.null2String(rsd.getString("jobdepartmentid"));
            String e7jobtitlecode = Util.null2String(rsd.getString("jobtitlecode"));

            Map<String,String> jobtitlesMap = new HashMap<String,String>();
            jobtitlesMap.put("e7id",e7id);
            jobtitlesMap.put("e7jobtitlemark",e7jobtitlemark);
            jobtitlesMap.put("e7jobtitlename",e7jobtitlename);
            jobtitlesMap.put("e7jobactivityid",e7jobactivityid);
            jobtitlesMap.put("e7jobdepartmentid",e7jobdepartmentid);
            jobtitlesMap.put("e7jobtitlecode",e7jobtitlecode);
            E7JobtitlesMap.put(e7id,jobtitlesMap);
        }
        return E7JobtitlesMap;
    }


    public String insertE7Data(RecordSetDataSource rsd,String insert_sql,String uuid,int insert_fail_count){
        String newE7Id = "";
        BaseBean bb = new BaseBean();
        bb.writeLog("insert-sql:"+insert_sql);
        boolean isTrue = rsd.execute(insert_sql);
        if(isTrue){
            String sql = " select max(id) as id from hrmjobtitles ";
            rsd.executeSql(sql);
            if(rsd.next()){
                newE7Id = Util.null2String(rsd.getString("id"));
            }
        }else{
            insert_fail_count++;
        }
        return newE7Id;
    }


    public boolean updateE7SubcompanyData(RecordSetDataSource rsd,String update_sql){
        BaseBean bb = new BaseBean();
        bb.writeLog("update-sql:"+update_sql);
        boolean isTrue = rsd.execute(update_sql);
        return isTrue;
    }

%>




