| | |
| | | package cn.com.basic.face.service;
|
| | |
|
| | | 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;
|
| | |
|
| | | import cn.com.basic.face.discern.common.BaseCommonCallBack;
|
| | | import cn.com.basic.face.discern.query.item.SupervisoryQueryItem;
|
| | | import cn.com.basic.face.fragment.SupervisoryFragment;
|
| | | import cn.com.basic.face.util.AppApi;
|
| | | import cn.com.basic.face.util.Constant;
|
| | |
|
| | | /**
|
| | | * Created by xiuxi on 2017/3/31.
|
| | | */
|
| | |
| | | return instance;
|
| | | }
|
| | |
|
| | | public void findSupervisoryBottomList() {
|
| | | public void findSupervisoryBottomList(final boolean isVisit) {
|
| | |
|
| | | RequestParams params = new RequestParams(AppApi.BASEURL+AppApi.SupervisoryQuery);
|
| | | // params.addBodyParameter(VisitorQueryCondition.FieldNames.notCompanyId, BaseApplication.getInstance().getPlace().getCompanyId());
|
| | | x.http().post(params, new BaseCommonCallBack() {
|
| | | public void success() {
|
| | | List<SupervisoryQueryItem> list = getList(SupervisoryQueryItem.class);
|
| | | if (isVisit) {
|
| | | int i = 0;
|
| | | for (SupervisoryQueryItem item : list) {
|
| | | if (i % 5 == 0) {
|
| | | item.setType(Constant.Supervisory.VISIT_REGISTER_ITEM_TYPE);
|
| | | } else {
|
| | | item.setType(Constant.Supervisory.VISIT_CHECK_IN_ITEM_TYPE);
|
| | | }
|
| | | i++;
|
| | | }
|
| | |
|
| | | List<SupervisoryQueryItem> doubleList = new ArrayList<SupervisoryQueryItem>();
|
| | | fillBlank(list, doubleList);
|
| | |
|
| | | SupervisoryFragment.getInstance().get_fragment_supervisory_bottom_visit_list_view().show(doubleList, true);
|
| | | } else {
|
| | | SupervisoryFragment.getInstance().get_fragment_supervisory_bottom_attendance_list_view().show(list, true);
|
| | | }
|
| | | }
|
| | | });
|
| | |
|
| | | }
|
| | |
|
| | | private void fillBlank(List<SupervisoryQueryItem> list, List<SupervisoryQueryItem> doubleList) {
|
| | | List<SupervisoryQueryItem> registerList = new ArrayList<SupervisoryQueryItem>();
|
| | | List<SupervisoryQueryItem> checkInList = new ArrayList<SupervisoryQueryItem>();
|
| | |
|
| | | for (SupervisoryQueryItem item : list) {
|
| | | if (item.getType() == Constant.Supervisory.VISIT_REGISTER_ITEM_TYPE) {
|
| | | registerList.add(item);
|
| | | }
|
| | | if (item.getType() == Constant.Supervisory.VISIT_CHECK_IN_ITEM_TYPE) {
|
| | | checkInList.add(item);
|
| | | }
|
| | | }
|
| | |
|
| | | List<SupervisoryQueryItem> blenderList = new ArrayList<SupervisoryQueryItem>();
|
| | |
|
| | | int i = 0, m = 0, n = 0;
|
| | | for (i = 0; i < registerList.size() + checkInList.size(); i++) {
|
| | | SupervisoryQueryItem item;
|
| | | if (i % 2 == 0 && m < registerList.size()) {
|
| | | item = registerList.get(m);
|
| | | m++;
|
| | | } else {
|
| | | item = checkInList.get(n);
|
| | | n++;
|
| | | }
|
| | | blenderList.add(item);
|
| | | }
|
| | |
|
| | | for (SupervisoryQueryItem item : blenderList) {
|
| | | if (doubleList.size() % 2 == 0 && item.getType() != Constant.Supervisory.VISIT_REGISTER_ITEM_TYPE) {
|
| | | doubleList.add(getBlankItem());
|
| | | }
|
| | | if (doubleList.size() % 2 != 0 && item.getType() != Constant.Supervisory.VISIT_CHECK_IN_ITEM_TYPE) {
|
| | | doubleList.add(getBlankItem());
|
| | | }
|
| | | doubleList.add(item);
|
| | | }
|
| | | }
|
| | |
|
| | | private SupervisoryQueryItem getBlankItem() {
|
| | | SupervisoryQueryItem blankItem = new SupervisoryQueryItem();
|
| | | blankItem.setType(Constant.Supervisory.VISIT_BLANK_ITEM_TYPE);
|
| | | return blankItem;
|
| | | }
|
| | |
|
| | | }
|