zkteco iface702 中控考勤机java开发步骤二---获取考勤机 的考勤数据 (2)

@ResponseBody @RequestMapping(value = "/queryAttendance", method = RequestMethod.POST) public String queryAttendance(@RequestBody String params, HttpServletRequest request, HttpServletResponse response) { String returnString = null; Map<String, Object> map = new HashMap<String, Object>(); List<Map<String,Object>> attendanceList = new ArrayList<Map<String,Object>>(); int realCount =0; try { //是否连接考勤机 String address = PropertiesUtil.loadResource("ZKE_IP", "config/config.properties"); int port =Integer.parseInt(PropertiesUtil.loadResource("PORT", "config/config.properties")); boolean connFlag = ZkemSDKUtils.connect(address, port); if(connFlag){ boolean flag = ZkemSDKUtils.readGeneralLogData(); List<Map<String,Object>> userList = ZkemSDKUtils.getUserInfo();//获取所有用户 List<Map<String,Object>> strList = ZkemSDKUtils.getGeneralLogData();//获取所有数据 Map<String, Object> mapAll = new HashMap<String, Object>(); for (int i = 0; i < userList.size(); i++) { Map<String, Object> userMap = userList.get(i); // 用户真实数据 mapAll = new HashMap<String, Object>(); mapAll.put("EnrollNumber",MapUtils.getString(userMap, "EnrollNumber")); mapAll.put("Name",MapUtils.getString(userMap, "Name")); mapAll.put("Privilege",MapUtils.getString(userMap, "Privilege")); String EnrollNumber1 = MapUtils.getString(userMap, "EnrollNumber"); List<Map<String, Object>> infoList = new ArrayList<Map<String, Object>>(); for (int j = 0; j < strList.size(); j++) { Map<String, Object> strMap = strList.get(j); String EnrollNumber2 =MapUtils.getString(strMap, "EnrollNumber"); if (EnrollNumber1.equals(EnrollNumber2)){ infoList.add(strMap);//这个人所有的打卡数据 } } if (infoList.size()==0){ mapAll.put("startTime",""); mapAll.put("endTime",""); } if (infoList.size()==1){ Map<String, Object> strMap = infoList.get(0); String startTime = MapUtils.getString(strMap, "Time"); mapAll.put("startTime",startTime); mapAll.put("endTime",""); realCount++; } if (infoList.size()>1){ Map<String, Object> strMap0 = infoList.get(0); Map<String, Object> strMap1 = infoList.get(infoList.size()-1); String startTime = MapUtils.getString(strMap0, "Time"); String endTime = MapUtils.getString(strMap1, "Time"); mapAll.put("startTime",startTime); mapAll.put("endTime",endTime); realCount++; } //mapAll.put("timeList",infoList); attendanceList.add(mapAll); } //第一个人打卡的开始时间,最后一个人结束时间 if (strList.size()>1){ Map<String, Object> strMap0 = strList.get(0); Map<String, Object> strMap1 = strList.get(strList.size()-1); String startTime = MapUtils.getString(strMap0, "Time"); String endTime = MapUtils.getString(strMap1, "Time"); map.put("startTime",startTime); map.put("endTime",endTime); } map.put(STATUS, STATUS_TRUE); map.put(DATA, attendanceList); map.put(COUNT, attendanceList.size()); map.put("realCount", realCount); } } catch (NullPointerException e) { SystemLogger.error("appController.queryAttendance", e); map.put(STATUS, STATUS_FALSE); map.put(MSG, ERROR_PARAM_NULL); } catch (ClassCastException e) { SystemLogger.error("appController.queryAttendance", e); map.put(STATUS, STATUS_FALSE); map.put(MSG, ERROR_PARAM_CLASS_CAST); } catch (Exception e) { SystemLogger.error("appController.queryAttendance.Exception", e); map.put(STATUS, STATUS_FALSE); map.put(MSG, ERROR_EXCEPTION); } returnString = JSONObject.fromObject(map).toString(); returnString = JSAESUtils.aesEncrypt(returnString); return returnString; }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zzypsx.html