xuxiuxi
2017-03-30 8081d0d398ce1b2987f810e7e89e7c6fe473b4bc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
package cn.com.basic.face.service;
 
import android.widget.Toast;
 
import cn.com.basic.face.base.BaseApplication;
import cn.com.basic.face.fragment.HomeFragment;
import cn.com.basic.face.fragment.CheckInFragment;
import cn.com.basic.face.util.AppApi;
 
import org.xutils.http.RequestParams;
import org.xutils.x;
 
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
 
import cn.com.basic.face.discern.common.BaseCommonCallBack;
import cn.com.basic.face.discern.query.condition.VisitorQueryCondition;
import cn.com.basic.face.discern.query.item.CheckInQueryItem;
 
/**
 * 来访登记
 */
 
public class CheckInMng {
 
    public static CheckInMng instance = new CheckInMng();
 
    public static CheckInMng getInstance() {
        return instance;
    }
 
    /**
     * 查询来访人员列表
     */
    public void findVisitorList(String pageNum, String name, final boolean isClear) {
        //id,名称,头像路径,联系电话,公司名称,证件编号
        RequestParams params = new RequestParams(AppApi.BASEURL+AppApi.CheckInQuery);
        params.addBodyParameter(VisitorQueryCondition.FieldNames.notCompanyId, BaseApplication.getInstance().getPlace().getCompanyId());
        params.addBodyParameter(VisitorQueryCondition.FieldNames.name, name);
        x.http().post(params, new BaseCommonCallBack() {
            public void success() {
                //CheckInFragment.getInstance().listChanged(getList(CheckInQueryItem.class), isClear);
            }
        });
    }
 
    /**
     * 查询来访人员列表
     */
    public void findVisitorList() {
        //id,名称,头像路径,联系电话,公司名称,证件编号
        RequestParams params = new RequestParams(AppApi.BASEURL+AppApi.CheckInQuery);
        params.addBodyParameter(VisitorQueryCondition.FieldNames.notCompanyId, BaseApplication.getInstance().getPlace().getCompanyId());
        x.http().post(params, new BaseCommonCallBack() {
            public void success() {
                //HomeFragment.getInstance().visitorListChanged(getList(CheckInQueryItem.class));
            }
        });
    }
 
    /**
     * 查询被访问人员列表
     */
    public void findIntervieweeList(String pageNum, String name, final boolean isClear) {
        RequestParams params = new RequestParams(AppApi.BASEURL+AppApi.CheckInQuery);
        params.addBodyParameter(VisitorQueryCondition.FieldNames.companyId, BaseApplication.getInstance().getPlace().getCompanyId());
        params.addBodyParameter(VisitorQueryCondition.FieldNames.name, name);
        x.http().post(params, new BaseCommonCallBack() {
            public void success() {
                //CheckInFragment.getInstance().listChanged(getList(CheckInQueryItem.class), isClear);
            }
        });
    }
 
    /**
     * 添加访客记录
     * @param params
     */
    public void add(RequestParams params) {
 
        params.setUri(AppApi.BASEURL+AppApi.CHECK_IN_ADD);
        x.http().post(params, new BaseCommonCallBack() {
            @Override
            public void success() {
                Toast.makeText(BaseApplication.getInstance(),"添加成功", Toast.LENGTH_SHORT).show();
            }
        });
 
    }
 
    public void findCheckInLeftList(final boolean isVisitorList, final boolean isSortByDept, String searchText) {
        RequestParams params = new RequestParams(AppApi.BASEURL+AppApi.CheckInQuery);
        if (isVisitorList) {
            params.addBodyParameter(VisitorQueryCondition.FieldNames.notCompanyId, BaseApplication.getInstance().getPlace().getCompanyId());
        } else {
            params.addBodyParameter(VisitorQueryCondition.FieldNames.companyId, BaseApplication.getInstance().getPlace().getCompanyId());
        }
        params.addBodyParameter(VisitorQueryCondition.FieldNames.name, searchText);
        x.http().post(params, new BaseCommonCallBack() {
            public void success() {
                List<CheckInQueryItem> list = getList(CheckInQueryItem.class);
                sort(list, isSortByDept);
                CheckInFragment.getInstance().get_fragment_check_in_left_list_view().show(list, isVisitorList);
            }
        });
    }
 
    private void sort(List<CheckInQueryItem> list, final boolean sortedByDept) {
        Collections.sort(list, new Comparator<CheckInQueryItem>() {
            @Override
            public int compare(CheckInQueryItem t1, CheckInQueryItem t2) {
                if (sortedByDept) {
                    String dept1Name = t1.getDeptName()==null?"":t1.getDeptName();
                    String dept2Name = t2.getDeptName()==null?"":t2.getDeptName();
                    if(!dept1Name.equals(dept2Name)) {
                        return dept1Name.compareTo(dept2Name);
                    }
                }
                String name1 = t1.getName()==null?"":t1.getName();
                String name2 = t2.getName()==null?"":t2.getName();
                return name1.compareTo(name2);
            }
        });
    }
 
    /**
     * 查询拜访事由列表
     */
 
}