修改dealWithMapping的默认值空指针异常bug修改
parent
e23fc2161e
commit
c69aeb13bf
|
@ -47,5 +47,5 @@ src/test/resources/font
|
||||||
src/main/resources/WEB-INF/vm/outFile
|
src/main/resources/WEB-INF/vm/outFile
|
||||||
target/
|
target/
|
||||||
*.back
|
*.back
|
||||||
src/main/aiyh_old_src/
|
src/main/youhong_ai_old_src/
|
||||||
src/main/jitu_src/
|
src/main/youhong_ai_jitu_src/
|
|
@ -2,6 +2,7 @@ package aiyh.utils.fileUtil.pdf;
|
||||||
|
|
||||||
import aiyh.utils.Util;
|
import aiyh.utils.Util;
|
||||||
import aiyh.utils.excention.CustomerException;
|
import aiyh.utils.excention.CustomerException;
|
||||||
|
import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil;
|
||||||
import com.itextpdf.text.DocumentException;
|
import com.itextpdf.text.DocumentException;
|
||||||
import com.itextpdf.text.Image;
|
import com.itextpdf.text.Image;
|
||||||
import com.itextpdf.text.pdf.PdfContentByte;
|
import com.itextpdf.text.pdf.PdfContentByte;
|
||||||
|
@ -107,6 +108,9 @@ public class PdfUtil {
|
||||||
}
|
}
|
||||||
InputStream inputStream = ImageFileManager.getInputStreamById(pdfImageFileId);
|
InputStream inputStream = ImageFileManager.getInputStreamById(pdfImageFileId);
|
||||||
List<PdfPointItem> keywordPoints = findKeywordPoints(inputStream, keyword);
|
List<PdfPointItem> keywordPoints = findKeywordPoints(inputStream, keyword);
|
||||||
|
if (CollectionUtil.isEmpty(keywordPoints)) {
|
||||||
|
throw new CustomerException("关键字定位异常,未发现关键字!");
|
||||||
|
}
|
||||||
PdfReader pdfReader = null;
|
PdfReader pdfReader = null;
|
||||||
Image image = null;
|
Image image = null;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -27,11 +27,7 @@ public class FloatTypeHandler implements TypeHandler {
|
||||||
}
|
}
|
||||||
return 0.0F;
|
return 0.0F;
|
||||||
}
|
}
|
||||||
float v = Float.parseFloat(string);
|
return Float.parseFloat(string);
|
||||||
if (!string.equals(String.valueOf(v))) {
|
|
||||||
return Double.parseDouble(string);
|
|
||||||
}
|
|
||||||
return v;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -45,11 +41,8 @@ public class FloatTypeHandler implements TypeHandler {
|
||||||
}
|
}
|
||||||
return 0.0F;
|
return 0.0F;
|
||||||
}
|
}
|
||||||
float v = Float.parseFloat(string);
|
|
||||||
if (!string.equals(String.valueOf(v))) {
|
return Float.parseFloat(string);
|
||||||
return Double.parseDouble(string);
|
|
||||||
}
|
|
||||||
return v;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -63,11 +56,8 @@ public class FloatTypeHandler implements TypeHandler {
|
||||||
}
|
}
|
||||||
return 0.0F;
|
return 0.0F;
|
||||||
}
|
}
|
||||||
float v = Float.parseFloat(string);
|
|
||||||
if (!string.equals(String.valueOf(v))) {
|
return Float.parseFloat(string);
|
||||||
return Double.parseDouble(string);
|
|
||||||
}
|
|
||||||
return v;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -81,11 +71,8 @@ public class FloatTypeHandler implements TypeHandler {
|
||||||
}
|
}
|
||||||
return 0.0F;
|
return 0.0F;
|
||||||
}
|
}
|
||||||
float v = Float.parseFloat(string);
|
|
||||||
if (!string.equals(String.valueOf(v))) {
|
return Float.parseFloat(string);
|
||||||
return Double.parseDouble(string);
|
|
||||||
}
|
|
||||||
return v;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1746,9 +1746,14 @@ public class RequestRemindBiz {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* ******************* youhong.ai 添加发送邮箱的黑名单拓展start ******************* */
|
/* ******************* youhong.ai 添加发送邮箱的黑名单拓展start ******************* */
|
||||||
Set<String> expansionList = BlackListRegister.getExpansionList(mailAddress);
|
|
||||||
if (Objects.nonNull(expansionList)) {
|
try {
|
||||||
mailAddress = expansionList;
|
Set<String> expansionList = BlackListRegister.getExpansionList(mailAddress);
|
||||||
|
if (Objects.nonNull(expansionList)) {
|
||||||
|
mailAddress = expansionList;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
aiyh.utils.Util.getLogger().error("过滤黑名单日志失败:" + aiyh.utils.Util.getErrString(e));
|
||||||
}
|
}
|
||||||
/* ******************* youhong.ai 添加发送邮箱的黑名单拓展 end ******************* */
|
/* ******************* youhong.ai 添加发送邮箱的黑名单拓展 end ******************* */
|
||||||
if (mailAddress.isEmpty()) return;
|
if (mailAddress.isEmpty()) return;
|
||||||
|
@ -1781,9 +1786,13 @@ public class RequestRemindBiz {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* ******************* youhong.ai 添加发送邮箱的黑名单拓展start ******************* */
|
/* ******************* youhong.ai 添加发送邮箱的黑名单拓展start ******************* */
|
||||||
Set<String> expansionList = BlackListRegister.getExpansionApproveList(mailAddress);
|
try {
|
||||||
if (Objects.nonNull(expansionList)) {
|
Set<String> expansionList = BlackListRegister.getExpansionApproveList(mailAddress);
|
||||||
mailAddress = expansionList;
|
if (Objects.nonNull(expansionList)) {
|
||||||
|
mailAddress = expansionList;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
aiyh.utils.Util.getLogger().error("过滤黑名单日志失败:" + aiyh.utils.Util.getErrString(e));
|
||||||
}
|
}
|
||||||
/* ******************* youhong.ai 添加发送邮箱的黑名单拓展 end ******************* */
|
/* ******************* youhong.ai 添加发送邮箱的黑名单拓展 end ******************* */
|
||||||
EmailApprovalRunnable.threadModeReminder(String.join(",", mailAddress), title, content, String.valueOf(requestId), allAttchment);
|
EmailApprovalRunnable.threadModeReminder(String.join(",", mailAddress), title, content, String.valueOf(requestId), allAttchment);
|
||||||
|
|
|
@ -2,8 +2,8 @@ package com.engine.youhong.ai.taibao.email;
|
||||||
|
|
||||||
import aiyh.utils.Util;
|
import aiyh.utils.Util;
|
||||||
import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil;
|
import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil;
|
||||||
import aiyh.utils.tool.cn.hutool.core.util.StrUtil;
|
|
||||||
import com.engine.youhong.ai.taibao.email.mapper.InitBlackEmailListMapper;
|
import com.engine.youhong.ai.taibao.email.mapper.InitBlackEmailListMapper;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
@ -28,33 +28,31 @@ public class BlackListRegister {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
List<String> hrmList = mapper.selectWorkflowBlackEmailList();
|
List<String> hrmList = mapper.selectWorkflowBlackEmailList();
|
||||||
if (CollectionUtil.isEmpty(hrmList)) {
|
return getBlackListEamil(set, hrmList);
|
||||||
return null;
|
|
||||||
}
|
|
||||||
String ids = Util.join(hrmList, ",");
|
|
||||||
List<String> blackEmailList = mapper.selectEmailListByHrmIds(ids);
|
|
||||||
if (CollectionUtil.isEmpty(blackEmailList)) {
|
|
||||||
return set;
|
|
||||||
}
|
|
||||||
return set.stream()
|
|
||||||
.filter(item -> !blackEmailList.contains(item))
|
|
||||||
.collect(Collectors.toSet());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Set<String> getExpansionApproveList(Set<String> set) {
|
public static Set<String> getExpansionApproveList(Set<String> set) {
|
||||||
if (Objects.isNull(set)) {
|
if (Objects.isNull(set)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
String ids = mapper.selectWorkflowApproveBlackEmailList();
|
List<String> hrmList = mapper.selectWorkflowApproveBlackEmailList();
|
||||||
if (StrUtil.isBlank(ids)) {
|
return getBlackListEamil(set, hrmList);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private static Set<String> getBlackListEamil(Set<String> set, List<String> hrmList) {
|
||||||
|
if (CollectionUtil.isEmpty(hrmList)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
String ids = Util.join(hrmList, ",");
|
||||||
List<String> blackEmailList = mapper.selectEmailListByHrmIds(ids);
|
List<String> blackEmailList = mapper.selectEmailListByHrmIds(ids);
|
||||||
if (CollectionUtil.isEmpty(blackEmailList)) {
|
if (CollectionUtil.isEmpty(blackEmailList)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return set.stream()
|
Set<String> collect = set.stream()
|
||||||
.filter(item -> !blackEmailList.contains(item))
|
.filter(item -> !blackEmailList.contains(item))
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
Util.getLogger().info("拦截后邮箱:" + collect);
|
||||||
|
return collect;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,8 @@ public interface InitBlackEmailListMapper {
|
||||||
*
|
*
|
||||||
* @return email黑名单
|
* @return email黑名单
|
||||||
*/
|
*/
|
||||||
@Select("select email from uf_black_email_conf where type = 1")
|
@Select("select black_hrm from uf_black_email_conf where type = 0")
|
||||||
String selectWorkflowApproveBlackEmailList();
|
List<String> selectWorkflowApproveBlackEmailList();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -123,7 +123,7 @@ public class DealWithMapping extends ToolUtil {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ("DOUBLE".equalsIgnoreCase(type)) {
|
if ("DOUBLE".equalsIgnoreCase(type)) {
|
||||||
map.put(key,Util.getDoubleValue(rs.getString(i)));
|
map.put(key, Util.getDoubleValue(rs.getString(i)));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ("DECIMAL".equalsIgnoreCase(type) || "NUMERIC".equalsIgnoreCase(type)) {
|
if ("DECIMAL".equalsIgnoreCase(type) || "NUMERIC".equalsIgnoreCase(type)) {
|
||||||
|
@ -465,8 +465,7 @@ public class DealWithMapping extends ToolUtil {
|
||||||
}
|
}
|
||||||
tempList.add(map);
|
tempList.add(map);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
tempList.add(o);
|
tempList.add(o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -559,8 +558,7 @@ public class DealWithMapping extends ToolUtil {
|
||||||
}
|
}
|
||||||
tempList.add(map);
|
tempList.add(map);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
tempList.add(o);
|
tempList.add(o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -627,14 +625,18 @@ public class DealWithMapping extends ToolUtil {
|
||||||
String fieldName = fieldMassage.getFieldName();
|
String fieldName = fieldMassage.getFieldName();
|
||||||
String fieldNameLowe = fieldName.toLowerCase();
|
String fieldNameLowe = fieldName.toLowerCase();
|
||||||
if ("1".equals(childSource)) {
|
if ("1".equals(childSource)) {
|
||||||
workFlowVal = Util.null2String(detailMap.get(fieldNameLowe));
|
if (Objects.nonNull(detailMap)) {
|
||||||
if ("".equals(workFlowVal)) {
|
workFlowVal = Util.null2String(detailMap.get(fieldNameLowe));
|
||||||
workFlowVal = Util.null2String(detailMap.get(fieldName));
|
if ("".equals(workFlowVal)) {
|
||||||
|
workFlowVal = Util.null2String(detailMap.get(fieldName));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if ("0".equals(childSource)) {
|
} else if ("0".equals(childSource)) {
|
||||||
workFlowVal = Util.null2String(mainMap.get(fieldNameLowe));
|
if (Objects.nonNull(mainMap)) {
|
||||||
if ("".equals(workFlowVal)) {
|
workFlowVal = Util.null2String(mainMap.get(fieldNameLowe));
|
||||||
workFlowVal = Util.null2String(mainMap.get(fieldName));
|
if ("".equals(workFlowVal)) {
|
||||||
|
workFlowVal = Util.null2String(mainMap.get(fieldName));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,224 @@
|
||||||
|
package youhong.ai.yashilandai;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class GroupByTime {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// 假设我们有一个包含Map对象的List
|
||||||
|
List<Map<String, Object>> list = new ArrayList<>();
|
||||||
|
|
||||||
|
// 向List中添加一些Map对象,每个Map对象都有一个createTime键,值为yyyy-MM-dd HH:mm:ss格式的时间字符串
|
||||||
|
Map<String, Object> map1 = new HashMap<>();
|
||||||
|
map1.put("createTime", "2022-04-24 12:34:56");
|
||||||
|
map1.put("type", "test_1");
|
||||||
|
list.add(map1);
|
||||||
|
|
||||||
|
Map<String, Object> map2 = new HashMap<>();
|
||||||
|
map2.put("createTime", "2022-04-23 11:22:33");
|
||||||
|
map2.put("type", "test_1");
|
||||||
|
list.add(map2);
|
||||||
|
|
||||||
|
Map<String, Object> map3 = new HashMap<>();
|
||||||
|
map3.put("createTime", "2022-04-22 10:11:12");
|
||||||
|
map3.put("type", "test_1");
|
||||||
|
list.add(map3);
|
||||||
|
|
||||||
|
Map<String, Object> map4 = new HashMap<>();
|
||||||
|
map4.put("createTime", "2022-04-21 09:08:07");
|
||||||
|
map4.put("type", "test_1");
|
||||||
|
list.add(map4);
|
||||||
|
|
||||||
|
Map<String, Object> map5 = new HashMap<>();
|
||||||
|
map5.put("createTime", "2022-04-20 08:07:06");
|
||||||
|
map5.put("type", "test_2");
|
||||||
|
list.add(map5);
|
||||||
|
|
||||||
|
Map<String, Object> map6 = new HashMap<>();
|
||||||
|
map6.put("createTime", "2022-04-19 07:06:05");
|
||||||
|
map6.put("type", "test_2");
|
||||||
|
list.add(map6);
|
||||||
|
|
||||||
|
Map<String, Object> map7 = new HashMap<>();
|
||||||
|
map7.put("createTime", "2022-04-18 06:05:04");
|
||||||
|
map7.put("type", "test_2");
|
||||||
|
list.add(map7);
|
||||||
|
|
||||||
|
Map<String, Object> map8 = new HashMap<>();
|
||||||
|
map8.put("createTime", "2022-04-17 05:04:03");
|
||||||
|
map8.put("type", "test_3");
|
||||||
|
list.add(map8);
|
||||||
|
|
||||||
|
Map<String, Object> map9 = new HashMap<>();
|
||||||
|
map9.put("createTime", "2022-04-16 05:04:03");
|
||||||
|
map9.put("type", "test_4");
|
||||||
|
list.add(map9);
|
||||||
|
|
||||||
|
Map<String, Object> map10 = new HashMap<>();
|
||||||
|
map10.put("createTime", "2022-04-15 05:04:03");
|
||||||
|
map10.put("type", "test_1");
|
||||||
|
list.add(map10);
|
||||||
|
|
||||||
|
Map<String, Object> map11 = new HashMap<>();
|
||||||
|
map11.put("createTime", "2022-04-14 05:04:03");
|
||||||
|
map11.put("type", "test_2");
|
||||||
|
list.add(map11);
|
||||||
|
|
||||||
|
Map<String, Object> map12 = new HashMap<>();
|
||||||
|
map12.put("createTime", "2022-04-09 05:04:03");
|
||||||
|
map12.put("type", "test_1");
|
||||||
|
list.add(map12);
|
||||||
|
|
||||||
|
Map<String, Object> map13 = new HashMap<>();
|
||||||
|
map13.put("createTime", "2022-04-13 05:04:03");
|
||||||
|
map13.put("type", "test_1");
|
||||||
|
list.add(map13);
|
||||||
|
|
||||||
|
Map<String, Object> map14 = new HashMap<>();
|
||||||
|
map14.put("createTime", "2022-04-12 05:04:03");
|
||||||
|
map14.put("type", "test_5");
|
||||||
|
list.add(map14);
|
||||||
|
|
||||||
|
Map<String, Object> map15 = new HashMap<>();
|
||||||
|
map15.put("createTime", "2022-04-11 05:04:03");
|
||||||
|
map15.put("type", "test_1");
|
||||||
|
list.add(map15);
|
||||||
|
|
||||||
|
Map<String, Object> map16 = new HashMap<>();
|
||||||
|
map16.put("createTime", "2022-04-10 05:04:03");
|
||||||
|
map16.put("type", "test_5");
|
||||||
|
list.add(map16);
|
||||||
|
|
||||||
|
// 调用groupByTime方法进行分组
|
||||||
|
|
||||||
|
Object result = groupByCreateTime(list);
|
||||||
|
System.out.println(JSON.toJSONString(result));
|
||||||
|
Object result2 = groupData(list);
|
||||||
|
System.out.println(JSON.toJSONString(result2));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Map<Integer, List<Map<String, Object>>> groupData(List<Map<String, Object>> dataList) {
|
||||||
|
// 根据type进行分组
|
||||||
|
// Map<String, List<Map<String, Object>>> typeMap = new HashMap<>();
|
||||||
|
// for (Map<String, Object> data : dataList) {
|
||||||
|
// String type = data.get("type").toString();
|
||||||
|
// if (!typeMap.containsKey(type)) {
|
||||||
|
// typeMap.put(type, new ArrayList<>());
|
||||||
|
// }
|
||||||
|
// typeMap.get(type).add(data);
|
||||||
|
// }
|
||||||
|
Map<String, List<Map<String, Object>>> typeMap = dataList.stream()
|
||||||
|
.collect(Collectors.groupingBy(item -> String.valueOf(item.get("type"))));
|
||||||
|
// 对每个type的数据进行日期分组
|
||||||
|
Map<Integer, List<Map<String, Object>>> result = new HashMap<>();
|
||||||
|
int groupIndex = 1;
|
||||||
|
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
for (String type : typeMap.keySet()) {
|
||||||
|
List<Map<String, Object>> typeDataList = typeMap.get(type);
|
||||||
|
typeDataList.sort((o1, o2) -> {
|
||||||
|
try {
|
||||||
|
Date date1 = dateFormat.parse(o1.get("createTime").toString());
|
||||||
|
Date date2 = dateFormat.parse(o2.get("createTime").toString());
|
||||||
|
return date1.compareTo(date2);
|
||||||
|
} catch (ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Map<String, Object> baseData = typeDataList.get(0);
|
||||||
|
Date baseDate = null;
|
||||||
|
try {
|
||||||
|
baseDate = dateFormat.parse(baseData.get("createTime").toString());
|
||||||
|
} catch (ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Map<String, Object>> groupList = new ArrayList<>();
|
||||||
|
groupList.add(baseData);
|
||||||
|
|
||||||
|
for (int i = 1; i < typeDataList.size(); i++) {
|
||||||
|
Map<String, Object> data = typeDataList.get(i);
|
||||||
|
Date date = null;
|
||||||
|
try {
|
||||||
|
date = dateFormat.parse(data.get("createTime").toString());
|
||||||
|
} catch (ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (date == null || baseDate == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (Math.abs(date.getTime() - baseDate.getTime()) <= 7 * 24 * 60 * 60 * 1000) {
|
||||||
|
groupList.add(data);
|
||||||
|
} else {
|
||||||
|
baseDate = date;
|
||||||
|
result.put(groupIndex++, groupList);
|
||||||
|
groupList = new ArrayList<>();
|
||||||
|
groupList.add(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (groupList.size() > 0) {
|
||||||
|
result.put(groupIndex++, groupList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Map<Integer, List<Map<String, Object>>> groupByCreateTime(List<Map<String, Object>> dataList) {
|
||||||
|
// 按照时间进行升序排序
|
||||||
|
dataList.sort((a, b) -> {
|
||||||
|
try {
|
||||||
|
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(a.get("createTime").toString())
|
||||||
|
.compareTo(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(b.get("createTime").toString()));
|
||||||
|
} catch (ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
Map<Integer, List<Map<String, Object>>> result = new HashMap<>();
|
||||||
|
|
||||||
|
if (dataList.size() > 0) {
|
||||||
|
int groupIndex = 1; // 分组序号
|
||||||
|
List<Map<String, Object>> group = new ArrayList<>(); // 当前分组
|
||||||
|
group.add(dataList.get(0)); // 将第一个元素添加到当前分组
|
||||||
|
|
||||||
|
// 从第二个元素开始遍历
|
||||||
|
for (int i = 1; i < dataList.size(); i++) {
|
||||||
|
Map<String, Object> item = dataList.get(i); // 当前元素
|
||||||
|
Map<String, Object> base = group.get(0); // 基准元素
|
||||||
|
|
||||||
|
// 时间差
|
||||||
|
long diff = 0;
|
||||||
|
try {
|
||||||
|
diff = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(item.get("createTime").toString()).getTime()
|
||||||
|
- new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(base.get("createTime").toString()).getTime();
|
||||||
|
} catch (ParseException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 时间差在7天以内
|
||||||
|
if (diff <= 7 * 24 * 60 * 60 * 1000) {
|
||||||
|
// 将当前元素加入当前分组
|
||||||
|
group.add(item);
|
||||||
|
} else { // 时间差超过7天
|
||||||
|
result.put(groupIndex++, group); // 将当前分组添加到结果列表
|
||||||
|
group = new ArrayList<>(); // 新建一组
|
||||||
|
group.add(item); // 将当前元素加入新分组
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 处理最后一组
|
||||||
|
if (!group.isEmpty()) {
|
||||||
|
result.put(groupIndex, group);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package youhong.ai.yashilandai;
|
||||||
|
|
||||||
|
import basetest.BaseTest;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>雅诗兰黛测试</h1>
|
||||||
|
*
|
||||||
|
* <p>create: 2023/4/23 14:00</p>
|
||||||
|
*
|
||||||
|
* @author youHong.ai
|
||||||
|
*/
|
||||||
|
public class MyTest extends BaseTest {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue