From 109ffe9a777658936a38d0c146579a67c60a0d17 Mon Sep 17 00:00:00 2001 From: xuxiuxi <xuxiuxi@454eff88-639b-444f-9e54-f578c98de674> Date: 星期四, 11 五月 2017 17:48:48 +0800 Subject: [PATCH] --- VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/CheckInMng.java | 166 ++++++++++++++++++++++++++++++------------------------- 1 files changed, 91 insertions(+), 75 deletions(-) diff --git a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/CheckInMng.java b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/CheckInMng.java index 6290497..a91c66e 100644 --- a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/CheckInMng.java +++ b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/CheckInMng.java @@ -3,13 +3,16 @@ 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.fragment.SupervisoryFragment; import cn.com.basic.face.util.AppApi; import org.xutils.http.RequestParams; import org.xutils.x; +import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; @@ -17,12 +20,9 @@ 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(); @@ -30,102 +30,118 @@ return instance; } - /** - * 鏌ヨ鏉ヨ浜哄憳鍒楄〃 - */ - public void findSupervisoryBottomList(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 findSupervisoryBottomList() { - //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() { - //SupervisoryFragment.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); + 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) { - 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()); + public void findCheckInLeftList(final boolean isVisitorList, final boolean isSortByDept, String searchText, final int pageNum, final boolean append) { + if (!BaseApplication.deviceAvailable) { + return; } - params.addBodyParameter(VisitorQueryCondition.FieldNames.name, searchText); + RequestParams params = new RequestParams(AppApi.BASE_URL +AppApi.Query.CHECK_IN_QUERY); + String deviceCompanyId = BaseApplication.getInstance().getDevice().getDeviceCompanyId(); + if (isVisitorList) { + params.addBodyParameter(CheckInQueryCondition.FieldNames.visitorCompanyId, deviceCompanyId); + } else { + 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); - CheckInFragment.getInstance().get_fragment_check_in_left_list_view().show(list, isVisitorList); + List itemList = new ArrayList(); + String name = ""; + String prev = ""; + for (int i = 0; i < list.size(); i++) { + CheckInQueryItem item = list.get(i); + if (isSortByDept) { + if (item.getDeptName() != null && item.getDeptName().length() > 0) { + name = CharacterParser.getInstance().getSelling(item.getDeptName()).substring(0, 1); + } + } else { + if (item.getUsername() != null && item.getUsername().length() > 0) + name = CharacterParser.getInstance().getSelling(item.getUsername()).substring(0, 1); + } + if (!name.equals(prev)) { + itemList.add(name); + } + itemList.add(item); + prev = name; + } + addPageFooter(hasMorePages(), getPageNum(), itemList); + if (isVisitorList) { + CheckInFragment.getInstance().get_fragment_check_in_left_visitor().show(itemList); + } else { + 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)) { - return dept1Name.compareTo(dept2Name); + String dept1Name_a = dept1Name.trim(); + String dept1Name_b = dept2Name.trim(); + if (dept1Name_a.length() > 0 && dept1Name_b.length() > 0) { + dept1Name_a = CharacterParser.getInstance().getSelling(dept1Name).toLowerCase(); + dept1Name_b = CharacterParser.getInstance().getSelling(dept2Name).toLowerCase(); + } + return dept1Name_a.compareTo(dept1Name_b); } } - String name1 = t1.getName()==null?"":t1.getName(); - String name2 = t2.getName()==null?"":t2.getName(); - return name1.compareTo(name2); + 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(username1).toLowerCase(); + dept1Name_b = CharacterParser.getInstance().getSelling(username2).toLowerCase(); + } + return dept1Name_a.compareTo(dept1Name_b); } }); } - /** - * 鏌ヨ鎷滆浜嬬敱鍒楄〃 - */ } -- Gitblit v1.8.0