| | |
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | | import java.util.HashSet;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.Set;
|
| | |
|
| | | import cn.com.basic.face.discern.common.CommonVariables;
|
| | |
| | | }
|
| | |
|
| | | //所有监控图片
|
| | | private static List<SurveillanceQueryItem> allItems = new ArrayList<>();
|
| | | public static List<SurveillanceQueryItem> allItems = new ArrayList<>();
|
| | | //访客选项卡的分类(未注册/人员类型、来访状态、标签状态)
|
| | | //考勤选项卡(考勤人员类型:教师、学生、员工,来访状态:签到、签退)
|
| | | //第一行显示未注册,第二行显示来访
|
| | | private static List<SurveillanceQueryItem> visitorTwoRows = new ArrayList<>();
|
| | | public static List<SurveillanceQueryItem> visitorTwoRows = new ArrayList<>();
|
| | | //第一行显示签到,第二行显示签退
|
| | | private static List<SurveillanceQueryItem> attendanceTwoRows = new ArrayList<>();
|
| | | //未注册的列表, 选择时用
|
| | | private static List<SurveillanceQueryItem> allUnregisterTwoRowsForSelect = new ArrayList();
|
| | | public static List<SurveillanceQueryItem> attendanceTwoRows = new ArrayList<>();
|
| | | //未注册的访客列表, 选择时用
|
| | | public static List<SurveillanceQueryItem> allUnregisterVisitorTwoRowsForSelect = new ArrayList();
|
| | | //未注册的考勤列表, 选择时用
|
| | | public static List<SurveillanceQueryItem> allUnregisterAttenderTwoRowsForSelect = new ArrayList();
|
| | |
|
| | | public void addItems(List<SurveillanceQueryItem> returnItems, List<SurveillanceQueryItem> requestItems) {
|
| | | public void addItems(List<SurveillanceQueryItem> returnItems, List<SurveillanceQueryItem> requestItems, String cameraInOrOut) {
|
| | | for ( int i = 0; i < returnItems.size(); i++) {
|
| | | SurveillanceQueryItem returnItem = returnItems.get(i);
|
| | | SurveillanceQueryItem requestItem = requestItems.get(i);
|
| | | addItem(returnItem, requestItem);
|
| | | addItem(returnItem, requestItem, cameraInOrOut);
|
| | | }
|
| | | removeTimeoutItemAndShow();
|
| | | limitItemsToN();
|
| | | }
|
| | |
|
| | | public void addItem(SurveillanceQueryItem returnItem, SurveillanceQueryItem requestItem) {
|
| | | public void addItem(SurveillanceQueryItem returnItem, SurveillanceQueryItem requestItem, String cameraInOrOut) {
|
| | | if (!CommonVariables.FACE_SERVER && !CommonVariables.EMULATOR) {
|
| | | RtspFaceNative.setFaceLabel(Integer.parseInt(cameraInOrOut), requestItem.getStTrackId(), returnItem.getVisitorType()==null?"":returnItem.getVisitorType().substring(0,
|
| | | returnItem.getVisitorType().length() > 3 ? 3 : returnItem.getVisitorType().length()
|
| | | ));
|
| | | }
|
| | | returnItem.setCreateTime(new Date());
|
| | | returnItem.setStTrackId(requestItem.getStTrackId());
|
| | | returnItem.setBitmap(requestItem.getBitmap());
|
| | |
| | | returnItem.setWidth(requestItem.getWidth());
|
| | | returnItem.setHeight(requestItem.getHeight());
|
| | | allItems.add(0, returnItem);
|
| | | }
|
| | |
|
| | | private void limitItemsToN() {
|
| | | int max = 25;
|
| | | int unRegisters = 0;
|
| | | int checkIns = 0;
|
| | | int attenderEnter = 0;
|
| | | int attenderExit = 0;
|
| | | List<SurveillanceQueryItem> itemsToRemove = new ArrayList<>();
|
| | | for (int i = 0; i < allItems.size(); i++) {
|
| | | SurveillanceQueryItem item = allItems.get(i);
|
| | | int type = item.getRegisterOrCheckIn();
|
| | | if (type == CommonVariables.Surveillance.VISIT_REGISTER_ITEM_TYPE) {
|
| | | unRegisters++;
|
| | | if (unRegisters > max) {
|
| | | itemsToRemove.add(item);
|
| | | }
|
| | | }
|
| | | if (type == CommonVariables.Surveillance.VISIT_CHECK_IN_ITEM_TYPE) {
|
| | | checkIns++;
|
| | | if (checkIns > max) {
|
| | | itemsToRemove.add(item);
|
| | | }
|
| | | }
|
| | | if (type == CommonVariables.Surveillance.VISIT_ATTENDANCE_IN) {
|
| | | attenderEnter++;
|
| | | if (attenderEnter > max) {
|
| | | itemsToRemove.add(item);
|
| | | }
|
| | | }
|
| | | if (type == CommonVariables.Surveillance.VISIT_ATTENDANCE_OUT) {
|
| | | attenderExit++;
|
| | | if (attenderExit > max) {
|
| | | itemsToRemove.add(item);
|
| | | }
|
| | | }
|
| | | }
|
| | | allItems.removeAll(itemsToRemove);
|
| | | }
|
| | |
|
| | | public List getVisitorTwoRows() {
|
| | |
| | | public List getAttendanceTwoRows() {
|
| | | attendanceTwoRows.clear();
|
| | | for (SurveillanceQueryItem item : allItems) {
|
| | | if (item.getRegisterOrCheckIn() == CommonVariables.Surveillance.VISIT_ATTENDANCE_ITEM_TYPE) {
|
| | | if (item.getRegisterOrCheckIn() == CommonVariables.Surveillance.VISIT_ATTENDANCE_IN ||
|
| | | item.getRegisterOrCheckIn() == CommonVariables.Surveillance.VISIT_ATTENDANCE_OUT
|
| | | ) {
|
| | | attendanceTwoRows.add(item);
|
| | | }
|
| | | }
|
| | | AttendentUtil.removeDuplicateAttendanceIn();
|
| | | AttendentUtil.removeDuplicateAttendanceOut();
|
| | | AttendentUtil.sortByRow();
|
| | | return attendanceTwoRows;
|
| | | }
|
| | |
|
| | | public List getAllUnregisterTwoRowsForSelect(long selectedId) {
|
| | | allUnregisterTwoRowsForSelect.clear();
|
| | | public List getAllUnregisterVisitorTwoRowsForSelect(long selectedId) {
|
| | | allUnregisterVisitorTwoRowsForSelect.clear();
|
| | | List<SurveillanceQueryItem> registerList = new ArrayList();
|
| | | int countPerRow = 9;
|
| | | for (SurveillanceQueryItem surveillanceQueryItem : allItems) {
|
| | |
| | | }
|
| | | items.add(item);
|
| | | }
|
| | | allUnregisterTwoRowsForSelect.addAll(items);
|
| | | return allUnregisterTwoRowsForSelect;
|
| | | allUnregisterVisitorTwoRowsForSelect.addAll(items);
|
| | | return allUnregisterVisitorTwoRowsForSelect;
|
| | | }
|
| | |
|
| | | public List getAllUnregisterAttenderTwoRowsForSelect(long selectedId) {
|
| | | allUnregisterAttenderTwoRowsForSelect.clear();
|
| | | List<SurveillanceQueryItem> registerList = new ArrayList();
|
| | | int countPerRow = 9;
|
| | | for (SurveillanceQueryItem surveillanceQueryItem : allItems) {
|
| | | if (surveillanceQueryItem.getRegisterOrCheckIn() == CommonVariables.Surveillance.VISIT_REGISTER_ITEM_TYPE) {
|
| | | if (registerList.size() > countPerRow*2) {
|
| | | break;
|
| | | }
|
| | | if (surveillanceQueryItem.getIdForSelect() == selectedId) {
|
| | | surveillanceQueryItem.setSurveillancePhotoSelected(true);
|
| | | } else {
|
| | | surveillanceQueryItem.setSurveillancePhotoSelected(false);
|
| | | }
|
| | | registerList.add(surveillanceQueryItem);
|
| | | }
|
| | | }
|
| | |
|
| | | SurveillanceQueryItem item;
|
| | | List items = new ArrayList();
|
| | | int m = 0, n = 0;
|
| | | for (int i = 0; i < countPerRow*2; i++) {
|
| | | if (i % 2 == 0) {
|
| | | if (m < registerList.size()) {
|
| | | item = registerList.get(m);
|
| | | m++;
|
| | | } else {
|
| | | item = VisitorUtil.getBlankItem();
|
| | | }
|
| | | } else {
|
| | | if (n < registerList.size() - countPerRow) {
|
| | | item = registerList.get(countPerRow+n);
|
| | | n++;
|
| | | } else {
|
| | | item = VisitorUtil.getBlankItem();
|
| | | }
|
| | | }
|
| | | items.add(item);
|
| | | }
|
| | | allUnregisterAttenderTwoRowsForSelect.addAll(items);
|
| | | return allUnregisterAttenderTwoRowsForSelect;
|
| | | }
|
| | |
|
| | | public void removeTimeoutItemAndShow() {
|
| | |
| | |
|
| | | static class AttendentUtil {
|
| | |
|
| | | public static void removeDuplicateAttendanceIn() {
|
| | | Map<String, String> registerIdMap = new HashMap<>();
|
| | | List itemsToRemove = new ArrayList();
|
| | | for (SurveillanceQueryItem item : attendanceTwoRows) {
|
| | | if (item.getRegisterOrCheckIn() == CommonVariables.Surveillance.VISIT_ATTENDANCE_IN) {
|
| | | String registerId = item.getRegisterId();
|
| | | if (registerIdMap.containsKey(item.getRegisterId())) {
|
| | | itemsToRemove.add(item);
|
| | | } else {
|
| | | registerIdMap.put(registerId, registerId);
|
| | | }
|
| | | }
|
| | | }
|
| | | attendanceTwoRows.removeAll(itemsToRemove);
|
| | | }
|
| | |
|
| | | public static void removeDuplicateAttendanceOut() {
|
| | | Map<String, String> registerIdMap = new HashMap<>();
|
| | | List itemsToRemove = new ArrayList();
|
| | | for (SurveillanceQueryItem item : attendanceTwoRows) {
|
| | | if (item.getRegisterOrCheckIn() == CommonVariables.Surveillance.VISIT_ATTENDANCE_OUT) {
|
| | | String registerId = item.getRegisterId();
|
| | | if (registerIdMap.containsKey(item.getRegisterId())) {
|
| | | itemsToRemove.add(item);
|
| | | } else {
|
| | | registerIdMap.put(registerId, registerId);
|
| | | }
|
| | | }
|
| | | }
|
| | | attendanceTwoRows.removeAll(itemsToRemove);
|
| | | }
|
| | |
|
| | | public static void sortByRow() {
|
| | | List<SurveillanceQueryItem> attenderInList = new ArrayList<SurveillanceQueryItem>();
|
| | | List<SurveillanceQueryItem> attenderOutList = new ArrayList<SurveillanceQueryItem>();
|
| | | int i1 = 0, j = 0;
|
| | | int maxAttenderIn = 50;
|
| | | int maxAttenderOut = 50;
|
| | | for (SurveillanceQueryItem item : attendanceTwoRows) {
|
| | | if (item.getRegisterOrCheckIn() == CommonVariables.Surveillance.VISIT_ATTENDANCE_IN) {
|
| | | if (i1 < maxAttenderIn) {
|
| | | attenderInList.add(item);
|
| | | i1++;
|
| | | }
|
| | | }
|
| | | if (item.getRegisterOrCheckIn() == CommonVariables.Surveillance.VISIT_ATTENDANCE_OUT) {
|
| | | if (j < maxAttenderOut) {
|
| | | attenderOutList.add(item);
|
| | | j++;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | int max = attenderInList.size() > attenderOutList.size() ? attenderInList.size() : attenderOutList.size();
|
| | |
|
| | | List tempList = new ArrayList();
|
| | |
|
| | | int m = 0, n = 0;
|
| | | for (int i = 0; i < max * 2; i++) {
|
| | | SurveillanceQueryItem item;
|
| | | if (i % 2 == 0) {
|
| | | if (m < attenderInList.size()) {
|
| | | item = attenderInList.get(m);
|
| | | } else {
|
| | | item = getBlankItem();
|
| | | }
|
| | | m++;
|
| | | } else {
|
| | | if (n < attenderOutList.size()) {
|
| | | item = attenderOutList.get(n);
|
| | | } else {
|
| | | item = getBlankItem();
|
| | | }
|
| | | n++;
|
| | | }
|
| | | tempList.add(item);
|
| | | }
|
| | | attendanceTwoRows.clear();
|
| | | attendanceTwoRows.addAll(tempList);
|
| | | }
|
| | |
|
| | | public static SurveillanceQueryItem getBlankItem() {
|
| | | SurveillanceQueryItem blankItem = new SurveillanceQueryItem();
|
| | | blankItem.setRegisterOrCheckIn(CommonVariables.Surveillance.VISIT_ATTENDANCE_BLANK);
|
| | | return blankItem;
|
| | | }
|
| | | }
|
| | |
|
| | | }
|