<%@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" %>
<jsp:useBean id="bb" class="weaver.general.BaseBean" scope="page" />
<%@ page language="java" contentType="text/html; charset=UTF-8" %>

<%
    String dataResource = "E7";

    Map<String,Map<String,String>> E9ResourceMap = getE9HrmResourceList();
    Map<String,Map<String,String>> E7ResourceMap = getE7HrmResourceList2(dataResource);
    out.println("E9ResourceMap:"+E9ResourceMap.size()+"</br>");
    out.println("E7ResourceMap:"+E7ResourceMap.size()+"</br>");
    String E7IDS = "";
    out.println("E7和E9不一致的:</br>");

    Iterator<Map.Entry<String,Map<String,String>>> iterator = E7ResourceMap.entrySet().iterator();
    while (iterator.hasNext()) {
        Map.Entry<String,Map<String,String>> entry = iterator.next();
        String e7id = entry.getKey();
        Map<String,String> E7Map = entry.getValue();

        String e7workcode = Util.null2String(E7Map.get("workcode"));
        String e7mobile = Util.null2String(E7Map.get("mobile"));
        String e7lastname = Util.null2String(E7Map.get("lastname"));
        String e7loginid = Util.null2String(E7Map.get("loginid"));
        String e7status = Util.null2String(E7Map.get("status"));


        if(E9ResourceMap.containsKey(e7id)){
            Map<String,String> E9Map = E9ResourceMap.get(e7id);

            String e9workcode = Util.null2String(E9Map.get("workcode"));
            String e9mobile = Util.null2String(E9Map.get("mobile"));
            String e9lastname = Util.null2String(E9Map.get("lastname"));
            String e9loginid = Util.null2String(E9Map.get("loginid"));
            String e9status = Util.null2String(E9Map.get("status"));

            if( !e7workcode.equals(e9workcode)
                || !e7mobile.equals(e9mobile)
                || !e7lastname.equals(e9lastname)
                || !e7loginid.equals(e9loginid)
                || !e7status.equals(e9status)
            ){
                E7IDS += StringUtils.isBlank(E7IDS) ? e7id : ","+e7id ;
            }
        }
    }

    out.println(E7IDS+"</br>");

    out.println("E9比E7多的:</br>");
    String E9IDS = "";
    Iterator<Map.Entry<String,Map<String,String>>> iterator2 = E9ResourceMap.entrySet().iterator();
    while (iterator2.hasNext()) {
        Map.Entry<String,Map<String,String>> entry = iterator2.next();
        String outkey = entry.getKey();
        Map<String,String> E9Map = entry.getValue();
        String e9workcode = Util.null2String(E9Map.get("workcode"));
        String e9mobile = Util.null2String(E9Map.get("mobile"));
        String e9lastname = Util.null2String(E9Map.get("lastname"));
        String e9loginid = Util.null2String(E9Map.get("loginid"));
        String e9status = Util.null2String(E9Map.get("status"));

        if(E7ResourceMap.containsKey(outkey)){
            Map<String,String> E7Map = E7ResourceMap.get(outkey);

            String e7workcode = Util.null2String(E7Map.get("workcode"));
            String e7mobile = Util.null2String(E7Map.get("mobile"));
            String e7lastname = Util.null2String(E7Map.get("lastname"));
            String e7loginid = Util.null2String(E7Map.get("loginid"));
            String e7status = Util.null2String(E7Map.get("status"));

            if( !e7workcode.equals(e9workcode)
                    || !e7mobile.equals(e9mobile)
                    || !e7lastname.equals(e9lastname)
                    || !e7loginid.equals(e9loginid)
                    || !e7status.equals(e9status)
            ){
                E9IDS += StringUtils.isBlank(E9IDS) ? outkey : ","+outkey ;
            }
        }
    }
    out.println(E9IDS+"</br>");
%>

<%!
    /***
     *
     * @return
     */
    public Map<String,Map<String,String>> getE9HrmResourceList(){
        RecordSet rs = new RecordSet();
        Map<String,Map<String,String>> E9SubcompanyMap = new HashMap<String,Map<String,String>>();
        String sql = " select outkey,workcode,mobile,lastname,loginid,status from hrmresource " ;
        rs.execute(sql);
        while (rs.next()){
            String outkey = Util.null2String(rs.getString("outkey"));
            String workcode = Util.null2String(rs.getString("workcode"));
            String mobile = Util.null2String(rs.getString("mobile"));
            String lastname = Util.null2String(rs.getString("lastname"));
            String loginid = Util.null2String(rs.getString("loginid"));
            String status = Util.null2String(rs.getString("status"));

            Map<String,String> map = new HashMap<String,String>();
            map.put("outkey",outkey);
            map.put("workcode",workcode);
            map.put("mobile",mobile);
            map.put("lastname",lastname);
            map.put("loginid",loginid);
            map.put("status",status);

            E9SubcompanyMap.put(outkey,map);
        }
        return E9SubcompanyMap;
    }


    public Map<String,Map<String,String>> getE7HrmResourceList2(String dataResource){
        RecordSetDataSource rsd = new RecordSetDataSource(dataResource);
        Map<String,Map<String,String>> E7SubcompanyMap = new HashMap<String,Map<String,String>>();
        String sql = " select id,workcode,mobile,lastname,loginid,status from hrmresource " ;
        rsd.execute(sql);
        while (rsd.next()){
            String id = Util.null2String(rsd.getString("id"));
            String workcode = Util.null2String(rsd.getString("workcode"));
            String mobile = Util.null2String(rsd.getString("mobile"));
            String lastname = Util.null2String(rsd.getString("lastname"));
            String loginid = Util.null2String(rsd.getString("loginid"));
            String status = Util.null2String(rsd.getString("status"));

            Map<String,String> map = new HashMap<String,String>();
            map.put("id",id);
            map.put("workcode",workcode);
            map.put("mobile",mobile);
            map.put("lastname",lastname);
            map.put("loginid",loginid);
            map.put("status",status);
            E7SubcompanyMap.put(id,map);
        }
        return E7SubcompanyMap;
    }
%>




