第一笔数据与第二笔数据比较
Map<String, Object> jHpictureMap = new HashMap<String, Object>(); // 存放照片SID StringBuilder jHpictureIds = new StringBuilder(); for (int i = 0 , size = jHActualPictureList.size(); i < size; i++) { // 当前笔 Map<String, Object> object = jHActualPictureList.get(i); String storeDisplaySid = String.valueOf(object.get("STORE_DISPLAY_SID")); String pictureId = String.valueOf(object.get("TASK_PICTURE_SID")); // 下一笔(当为最后一笔时,设置下一笔为空) Map<String, Object> nextObject = (i == size-1) ? null : jHActualPictureList.get(i+1); // 将 当前pictureId 拼接至 jHpictureIds jHpictureIds.append((jHpictureIds.length() > 0) ? ("," + pictureId) : pictureId); // 如果当前笔不等于下一笔,或者当前笔为最后一笔 if ((null != nextObject && !String.valueOf(nextObject.get("STORE_DISPLAY_SID")).equals(storeDisplaySid)) || i == size - 1) { jHpictureMap.put(String.valueOf(object.get("STORE_DISPLAY_SID")), String.valueOf(jHpictureIds)); // 不是最后一笔,创建一个新的 jHpictureIds实例,是最后一笔清空jHpictureIds jHpictureIds = (i == size-1) ? null : new StringBuilder(); } } logger.errorT("=================测试:" + jHpictureMap.toString());