feat: There is no way the,

This commit is contained in:
super_liu
2022-01-06 18:02:47 +08:00
parent 5fdb04f96f
commit fe2949edd5
3 changed files with 163 additions and 5 deletions
@@ -2,6 +2,7 @@ package com.adc.da.search.service.impl;
import com.adc.da.search.entity.*;
import com.adc.da.search.service.SearchCenterService;
import com.adc.da.search.util.DateUtil;
import com.adc.da.search.util.InitStandAttrSearchUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
@@ -421,7 +422,12 @@ public class SearchCenterServiceImpl implements SearchCenterService {
}
}
if(!fields.isEmpty()){
if(fields.size() > 1){
if(field.equals("SSRQ") || field.equals("XCXSSRQ") || field.equals("ZCCSSRQ")){
List<String> fieldRQList = DateUtil.getAllDate(fields.get(0),fields.get(1));
fields.addAll(fieldRQList);
}
BoolQueryBuilder boolQueryBuilderShould = new BoolQueryBuilder();
fields.forEach(s -> {
boolQueryBuilderShould.should(QueryBuilders.wildcardQuery(keyWordField, "*"+s+"*"));
@@ -805,13 +811,13 @@ public class SearchCenterServiceImpl implements SearchCenterService {
// 循环统计各种类型数据
String[] seniortype;
if("stand".equals(searchInfoEO.getSelectIndex())) {
String[] seniortypeStand = {"standSort", "numbershow","statecode","CYSD","ZRLX","CLLX","CBCD","textStatus","textStatusName","NYLXCLASS"};
String[] seniortypeStand = {"standSort", "numbershow","statecode","CYSD","ZRLX","CLLX","CBCD","textStatus","textStatusName","NYLXCLASS","NYLX"};
seniortype = seniortypeStand.clone();
} else if("laws".equals(searchInfoEO.getSelectIndex())){
String[] seniortypeLaws = {"lawsSyqy","lawsSycx","CYSDLAWS"};
seniortype = seniortypeLaws.clone();
} else if ("bussstand".equals(searchInfoEO.getSelectIndex())) {
String[] seniortypeBuss = {"standSort", "numbershow", "statecode","CLLX","textStatus","textStatusName","NYLXCLASS"};
String[] seniortypeBuss = {"standSort", "numbershow", "statecode","CLLX","textStatus","textStatusName","NYLXCLASS","SYCXCLASS"};
seniortype = seniortypeBuss.clone();
} else {
String[] seniortypeMsg = {"module"};
@@ -0,0 +1,124 @@
package com.adc.da.search.util;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* @Description: 判断是否为日期格式
* @Author: super_liu
* date: 2020/12/31 11:25
*/
public class DateUtil {
/**
* 取起始时间到结束时间 所有的时间
* @param startTime
* @param endTime
* @return
*/
public static List<String> getAllDate(String startTime, String endTime) {
List<String> list = new ArrayList<String>();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar cal = Calendar.getInstance();
try {
cal.setTime(sdf.parse(startTime));
for (long d = cal.getTimeInMillis(); d <= sdf.parse(endTime).getTime(); d = get_D_Plaus_1(cal)) {
list.add(sdf.format(d));
}
} catch (ParseException e) {
System.out.println("date change err");
}
return list;
}
public static long get_D_Plaus_1(Calendar c) {
c.set(Calendar.DAY_OF_MONTH, c.get(Calendar.DAY_OF_MONTH) + 1);
return c.getTimeInMillis();
}
/***
* @Description: 判断多个日期是否都符合日期格式
* @Author: super_liu
* @Date: 2020/12/31 11:31
* @Param: [str]
* @Return: boolean
*/
public static boolean isValidDate(String str) throws Exception{
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
String[] strArr = str.split(",");
for (String dateStr : strArr) {
try {
simpleDateFormat.setLenient(false);
simpleDateFormat.parse(dateStr);
} catch (Exception e){
return false;
}
}
return true;
}
/**
* utc 时间格式转换正常格式 2018-08-07T03:41:59Z
* @param utcTime 时间
* @return
*/
public static String formatStrUTCToDateStr(String utcTime) {
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.SIMPLIFIED_CHINESE);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
TimeZone utcZone = TimeZone.getTimeZone("UTC");
sf.setTimeZone(utcZone);
Date date = null;
String dateTime = "";
try {
date = sf.parse(utcTime);
dateTime = sdf.format(date);
} catch (ParseException e) {
e.printStackTrace();
}
return dateTime;
}
/**
* 将日期对象转换为指定的日期字符串
*
* @param date 传入的日期对象
* @param format 格式
* @return 日期字符串
* @author 赵肖云
*/
public static String dateToString(Date date, String format) {
String string = "";
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format);
if (date != null) {
string = simpleDateFormat.format(date);
}
return string;
}
/**
* 将日期字符串转换为一个日期对象
*
* @param datestr 日期字符串
* @param format 格式
* @return Date
* @author 赵肖云
*/
public static Date stingToDate(String datestr, String format) throws ParseException {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format);
return simpleDateFormat.parse(datestr);
}
public static void main(String[] args) {
String utcTime = "2021-04-15T01:43:54.296Z";
String time = formatStrUTCToDateStr("2021-04-15T01:43:54.296Z");
System.out.println("utcTime 转换前:" + utcTime);
System.out.println("utcTime 转换后 time " + time);
}
}
@@ -2,9 +2,7 @@ package com.adc.da.utils.util;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import java.util.*;
/**
* @Description: 判断是否为日期格式
@@ -13,6 +11,36 @@ import java.util.TimeZone;
*/
public class DateUtil {
/**
* 取起始时间到结束时间 所有的时间
* @param startTime
* @param endTime
* @return
*/
public static List<String> getAllDate(String startTime, String endTime) {
List<String> list = new ArrayList<String>();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar cal = Calendar.getInstance();
try {
cal.setTime(sdf.parse(startTime));
for (long d = cal.getTimeInMillis(); d <= sdf.parse(endTime).getTime(); d = get_D_Plaus_1(cal)) {
list.add(sdf.format(d));
}
} catch (ParseException e) {
System.out.println("date change err");
}
return list;
}
public static long get_D_Plaus_1(Calendar c) {
c.set(Calendar.DAY_OF_MONTH, c.get(Calendar.DAY_OF_MONTH) + 1);
return c.getTimeInMillis();
}
/***
* @Description: 判断多个日期是否都符合日期格式
* @Author: super_liu