| | |
| | | import android.widget.Toast;
|
| | |
|
| | | import cn.com.basic.face.base.BaseApplication;
|
| | | import cn.com.basic.face.discern.common.CommonVariables;
|
| | | import cn.com.basic.face.discern.query.condition.CheckInQueryCondition;
|
| | | import cn.com.basic.face.discern.query.item.PhoneCallQueryItem;
|
| | | import cn.com.basic.face.fragment.CheckInFragment;
|
| | | import cn.com.basic.face.util.AppApi;
|
| | |
|
| | |
| | | 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;
|
| | | import cn.com.basic.face.util.CharacterParser;
|
| | |
|
| | | public class CheckInMng {
|
| | | public class CheckInMng extends BaseMng {
|
| | |
|
| | | public static CheckInMng instance = new CheckInMng();
|
| | |
|
| | |
| | | return instance;
|
| | | }
|
| | |
|
| | | public void add(RequestParams params) {
|
| | | public void add(RequestParams params, final String visitReasonId) {
|
| | | if (!BaseApplication.deviceAvailable) {
|
| | | return;
|
| | | }
|
| | | params.setUri(AppApi.BASE_URL +AppApi.VISIT_ADD);
|
| | | x.http().post(params, new BaseCommonCallBack() {
|
| | | @Override
|
| | | public void success() {
|
| | | Toast.makeText(BaseApplication.getInstance(),"添加成功", Toast.LENGTH_SHORT).show();
|
| | | CheckInFragment.getInstance().resetForm();
|
| | | if (visitReasonId == null || "".equals(visitReasonId)) {
|
| | | DictionaryMng.getInstance().loadVisitReasonList();
|
| | | }
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | public void findCheckInLeftList(final boolean isVisitorList, final boolean isSortByDept, String searchText) {
|
| | | public void findCheckInLeftList(final boolean isVisitorList, final boolean isSortByDept, String searchText, final int pageNum, final boolean append) {
|
| | | if (!BaseApplication.deviceAvailable) {
|
| | | return;
|
| | | }
|
| | | RequestParams params = new RequestParams(AppApi.BASE_URL +AppApi.Query.CHECK_IN_QUERY);
|
| | | String deviceCompanyId = BaseApplication.getInstance().getAndroidDevice().getCompanyId();
|
| | | if (isVisitorList) {
|
| | | params.addBodyParameter(CheckInQueryCondition.FieldNames.visitorCompanyId, BaseApplication.getInstance().getDevice().getCompanyId());
|
| | | params.addBodyParameter(CheckInQueryCondition.FieldNames.visitorCompanyId, deviceCompanyId);
|
| | | } else {
|
| | | params.addBodyParameter(CheckInQueryCondition.FieldNames.employeeCompanyId, BaseApplication.getInstance().getDevice().getCompanyId());
|
| | | params.addBodyParameter(CheckInQueryCondition.FieldNames.employeeCompanyId, deviceCompanyId);
|
| | | }
|
| | | params.addBodyParameter(CheckInQueryCondition.FieldNames.username, searchText);
|
| | | params.addBodyParameter(CommonVariables.Page.PAGE_NUM, pageNum+"");
|
| | | params.addBodyParameter(CommonVariables.Page.PAGE_SIZE, CommonVariables.Page.DEFAULT_PAGE_SIZE);
|
| | | x.http().post(params, new BaseCommonCallBack() {
|
| | | public void success() {
|
| | | List<CheckInQueryItem> list = getList(CheckInQueryItem.class);
|
| | |
|
| | | List prevList = null;
|
| | | if (append) {
|
| | | if (isVisitorList) {
|
| | | prevList = CheckInFragment.getInstance().get_fragment_check_in_left_visitor().getPrevList();
|
| | | } else {
|
| | | prevList = CheckInFragment.getInstance().get_fragment_check_in_left_interviewee().getPrevList();
|
| | | }
|
| | | for (int i = 0; i < prevList.size(); i++) {
|
| | | Object item = prevList.get(i);
|
| | | if (item instanceof CheckInQueryItem) {
|
| | | list.add(0, (CheckInQueryItem) item);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | sort(list, isSortByDept);
|
| | | List allItems = new ArrayList();
|
| | | List itemList = new ArrayList();
|
| | | String name = "";
|
| | | String prev = "";
|
| | | for (int i = 0; i < list.size(); i++) {
|
| | |
| | | name = CharacterParser.getInstance().getSelling(item.getUsername()).substring(0, 1);
|
| | | }
|
| | | if (!name.equals(prev)) {
|
| | | allItems.add(name);
|
| | | itemList.add(name);
|
| | | }
|
| | | allItems.add(item);
|
| | | itemList.add(item);
|
| | | prev = name;
|
| | | }
|
| | | addPageFooter(hasMorePages(), getPageNum(), itemList);
|
| | | if (isVisitorList) {
|
| | | CheckInFragment.getInstance().get_fragment_check_in_left_visitor().show(allItems);
|
| | | CheckInFragment.getInstance().get_fragment_check_in_left_visitor().show(itemList);
|
| | | } else {
|
| | | CheckInFragment.getInstance().get_fragment_check_in_left_interviewee().show(allItems, isSortByDept);
|
| | | CheckInFragment.getInstance().get_fragment_check_in_left_interviewee().show(itemList, isSortByDept, append);
|
| | | }
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | private void sort(List<CheckInQueryItem> list, final boolean sortedByDept) {
|
| | | if (!BaseApplication.deviceAvailable) {
|
| | | return;
|
| | | }
|
| | | Collections.sort(list, new Comparator<CheckInQueryItem>() {
|
| | | @Override
|
| | | public int compare(CheckInQueryItem t1, CheckInQueryItem t2) {
|
| | | public int compare(CheckInQueryItem item1, CheckInQueryItem item2) {
|
| | | if (sortedByDept) {
|
| | | String dept1Name = t1.getDeptName()==null?"":t1.getDeptName();
|
| | | String dept2Name = t2.getDeptName()==null?"":t2.getDeptName();
|
| | | String dept1Name = item1.getDeptName()==null?"":item1.getDeptName();
|
| | | String dept2Name = item2.getDeptName()==null?"":item2.getDeptName();
|
| | | if(!dept1Name.equals(dept2Name)) {
|
| | | String dept1Name_a = dept1Name.trim();
|
| | | String dept1Name_b = dept2Name.trim();
|
| | |
| | | return dept1Name_a.compareTo(dept1Name_b);
|
| | | }
|
| | | }
|
| | | String name1 = t1.getUsername()==null?"":t1.getUsername();
|
| | | String name2 = t2.getUsername()==null?"":t2.getUsername();
|
| | | String dept1Name_a = name1.trim();
|
| | | String dept1Name_b = name2.trim();
|
| | | String username1 = item1.getUsername()==null?"":item1.getUsername();
|
| | | String username2 = item2.getUsername()==null?"":item2.getUsername();
|
| | | String dept1Name_a = username1.trim();
|
| | | String dept1Name_b = username2.trim();
|
| | | if (dept1Name_a.length() > 0 && dept1Name_b.length() > 0) {
|
| | | dept1Name_a = CharacterParser.getInstance().getSelling(name1).toLowerCase();
|
| | | dept1Name_b = CharacterParser.getInstance().getSelling(name2).toLowerCase();
|
| | | dept1Name_a = CharacterParser.getInstance().getSelling(username1).toLowerCase();
|
| | | dept1Name_b = CharacterParser.getInstance().getSelling(username2).toLowerCase();
|
| | | }
|
| | | return dept1Name_a.compareTo(dept1Name_b);
|
| | | }
|