新增获取时间范围内年月日小时的方法
统计横坐标根据时间范围内的年月日小时填充数据并回显
This commit is contained in:
parent
229d1980dd
commit
a6deb7c53f
|
@ -805,4 +805,51 @@ public class DateUtils extends PropertyEditorSupport {
|
||||||
return days;
|
return days;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取开始时间和结束时间之间的全部小时信息
|
||||||
|
* @param beginDay
|
||||||
|
* @param endDay
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static List<String> getAllDayTime(String beginDay, String endDay){
|
||||||
|
List<String> dayTimes = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
//开始日期
|
||||||
|
Calendar begin = Calendar.getInstance();
|
||||||
|
begin.setTime(DateUtils.parseDate(beginDay, "yyyy-MM-dd"));
|
||||||
|
//将开始日期的24个小时放入集合中
|
||||||
|
for (int i=0; i< 24; i++) {
|
||||||
|
String dayTime = beginDay;
|
||||||
|
if (i < 10) {
|
||||||
|
dayTime+=" 0"+i;
|
||||||
|
} else {
|
||||||
|
dayTime+=" "+i;
|
||||||
|
}
|
||||||
|
dayTime+=":00:00";
|
||||||
|
dayTimes.add(dayTime);
|
||||||
|
}
|
||||||
|
//结束日期
|
||||||
|
Calendar end = Calendar.getInstance();
|
||||||
|
end.setTime(DateUtils.parseDate(endDay, "yyyy-MM-dd"));
|
||||||
|
//判断 如果结束日期的时间在开始日期的时间之后
|
||||||
|
while(end.getTime().after(begin.getTime())){
|
||||||
|
//开始日期需要+1天
|
||||||
|
begin.add(Calendar.DAY_OF_MONTH, 1);
|
||||||
|
for (int i=0; i< 24; i++) {
|
||||||
|
String dayTime = DateUtils.formatDate(begin.getTime(),"yyyy-MM-dd");
|
||||||
|
if (i < 10) {
|
||||||
|
dayTime+=" 0"+i;
|
||||||
|
} else {
|
||||||
|
dayTime+=" "+i;
|
||||||
|
}
|
||||||
|
dayTime+=":00:00";
|
||||||
|
dayTimes.add(dayTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (ParseException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return dayTimes;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -885,6 +885,8 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl<GardsSampleDataWe
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
String endTime = DateUtils.formatDate(endDate, "yyyy-MM-dd") + " 23:59:59";
|
String endTime = DateUtils.formatDate(endDate, "yyyy-MM-dd") + " 23:59:59";
|
||||||
|
List<String> allDayTime = DateUtils.getAllDayTime(DateUtils.formatDate(startDate, "yyyy-MM-dd"), DateUtils.formatDate(endDate, "yyyy-MM-dd"));
|
||||||
|
resultMap.put("AllDayTime", allDayTime);
|
||||||
//判断查询的核素内容是否为空
|
//判断查询的核素内容是否为空
|
||||||
List<String> nuclideNameList = new LinkedList<>();
|
List<String> nuclideNameList = new LinkedList<>();
|
||||||
if (nuclideNames != null && nuclideNames.length > 0) {
|
if (nuclideNames != null && nuclideNames.length > 0) {
|
||||||
|
@ -933,7 +935,7 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl<GardsSampleDataWe
|
||||||
//拼接sql查询结果
|
//拼接sql查询结果
|
||||||
List<Map<String, Object>> nuclideStatisticsMap = this.baseMapper.findNuclideStatistics(stationId, startTime, endTime, nuclideSql);
|
List<Map<String, Object>> nuclideStatisticsMap = this.baseMapper.findNuclideStatistics(stationId, startTime, endTime, nuclideSql);
|
||||||
//处理查询结果
|
//处理查询结果
|
||||||
handleNuclideData(nuclideStatisticsMap, systemType, nuclideNameList, resultMap);
|
handleNuclideData(nuclideStatisticsMap, systemType, nuclideNameList, allDayTime, resultMap);
|
||||||
//返回台站名称
|
//返回台站名称
|
||||||
String stationName = stationMap.get(stationId);
|
String stationName = stationMap.get(stationId);
|
||||||
resultMap.put("STATION_NAME", stationName);
|
resultMap.put("STATION_NAME", stationName);
|
||||||
|
@ -1159,38 +1161,45 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl<GardsSampleDataWe
|
||||||
return sql;
|
return sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleNuclideData(List<Map<String, Object>> nuclideStatisticsMap, String systemType, List<String> nuclideNameList, Map<String, Object> resultMap) {
|
private void handleNuclideData(List<Map<String, Object>> nuclideStatisticsMap, String systemType, List<String> nuclideNameList, List<String> allDateTime, Map<String, Object> resultMap) {
|
||||||
//存储横坐标采集开始时间
|
//存储横坐标采集开始时间
|
||||||
List<String> collectStartList = new LinkedList<>();
|
List<String> collectStartList = new LinkedList<>();
|
||||||
//存储横坐标对应体积
|
//存储横坐标对应体积
|
||||||
List<Double> quantityList = new LinkedList<>();
|
List<Double> quantityList = new LinkedList<>();
|
||||||
//存储横坐标对应acq活时间
|
//存储横坐标对应acq活时间
|
||||||
List<Double> acqLiveSecList = new LinkedList<>();
|
List<Double> acqLiveSecList = new LinkedList<>();
|
||||||
|
//遍历日期时间
|
||||||
|
for (int i=0; i< allDateTime.size(); i++) {
|
||||||
|
//根据下标获取日期时间
|
||||||
|
String dayTime = allDateTime.get(i);
|
||||||
//遍历查询结果数组
|
//遍历查询结果数组
|
||||||
for (Map<String, Object> nuclideStatistics: nuclideStatisticsMap) {
|
for (int j=0; j< nuclideStatisticsMap.size(); j++) {
|
||||||
|
//根据下标获取核素查询结果
|
||||||
|
Map<String, Object> nuclideStatistics = nuclideStatisticsMap.get(j);
|
||||||
//获取采集开始时间
|
//获取采集开始时间
|
||||||
Object collectStart = nuclideStatistics.get("COLLECT_START");
|
Object collectStart = nuclideStatistics.get("COLLECT_START");
|
||||||
//如果采集开始时间不为空 则存储
|
//采集开始时间转为字符串
|
||||||
if (Objects.nonNull(collectStart)) {
|
String collectStartStr = collectStart.toString();
|
||||||
|
//截取采集开始时间的年月日小时
|
||||||
|
collectStartStr = collectStartStr.substring(0, 14) + ":00:00";
|
||||||
|
//如果采集时间包含当前日期 则正常的读取数据并存入数组
|
||||||
|
if (dayTime.equals(collectStartStr)) {
|
||||||
collectStartList.add(collectStart.toString());
|
collectStartList.add(collectStart.toString());
|
||||||
} else {//否则跳过本次循环
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
//获取体积
|
//获取体积
|
||||||
Object quantity = nuclideStatistics.get("QUANTITY");
|
Object quantity = nuclideStatistics.get("QUANTITY");
|
||||||
//判断体积数值是否有 如果有 正常存储
|
//判断体积数值是否有 如果有 正常存储
|
||||||
if (Objects.nonNull(quantity)) {
|
if (Objects.nonNull(quantity)) {
|
||||||
quantityList.add(Double.valueOf(quantity.toString()));
|
quantityList.add(Double.valueOf(quantity.toString()));
|
||||||
} else {//如果没有存储0
|
} else {
|
||||||
quantityList.add(0.0);
|
quantityList.add(null);
|
||||||
}
|
}
|
||||||
//获取acq活时间
|
//获取acq活时间
|
||||||
Object acquisitionLiveSec = nuclideStatistics.get("ACQUISITION_LIVE_SEC");
|
Object acquisitionLiveSec = nuclideStatistics.get("ACQUISITION_LIVE_SEC");
|
||||||
//判断活时间是否为空 如果不为空 正常存储
|
//判断活时间是否为空 如果不为空 正常存储
|
||||||
if (Objects.nonNull(acquisitionLiveSec)) {
|
if (Objects.nonNull(acquisitionLiveSec)) {
|
||||||
acqLiveSecList.add(Double.valueOf(acquisitionLiveSec.toString()));
|
acqLiveSecList.add(Double.valueOf(acquisitionLiveSec.toString()));
|
||||||
} else {//如果为空存储0
|
} else {
|
||||||
acqLiveSecList.add(0.0);
|
acqLiveSecList.add(null);
|
||||||
}
|
}
|
||||||
//判断系统类型决定读取核素的信息
|
//判断系统类型决定读取核素的信息
|
||||||
if (systemType.equals("beta") || systemType.equals("gamma")) {
|
if (systemType.equals("beta") || systemType.equals("gamma")) {
|
||||||
|
@ -1204,8 +1213,8 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl<GardsSampleDataWe
|
||||||
//判断如果浓度不为空 正常存储
|
//判断如果浓度不为空 正常存储
|
||||||
if (Objects.nonNull(conc)) {
|
if (Objects.nonNull(conc)) {
|
||||||
concList.add(Double.valueOf(conc.toString()));
|
concList.add(Double.valueOf(conc.toString()));
|
||||||
} else {//如果为空 存储0
|
} else {
|
||||||
concList.add(0.0);
|
concList.add(null);
|
||||||
}
|
}
|
||||||
//读取查询出的mdc结果
|
//读取查询出的mdc结果
|
||||||
Object mdc = nuclideStatistics.get(columnName + "MDC");
|
Object mdc = nuclideStatistics.get(columnName + "MDC");
|
||||||
|
@ -1213,7 +1222,7 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl<GardsSampleDataWe
|
||||||
if (Objects.nonNull(mdc)) {
|
if (Objects.nonNull(mdc)) {
|
||||||
mdcList.add(Double.valueOf(mdc.toString()));
|
mdcList.add(Double.valueOf(mdc.toString()));
|
||||||
} else {
|
} else {
|
||||||
mdcList.add(0.0);
|
mdcList.add(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (systemType.equals("Particulate")) {
|
} else if (systemType.equals("Particulate")) {
|
||||||
|
@ -1226,8 +1235,32 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl<GardsSampleDataWe
|
||||||
//判断如果浓度不为空 正常存储
|
//判断如果浓度不为空 正常存储
|
||||||
if (Objects.nonNull(conc)) {
|
if (Objects.nonNull(conc)) {
|
||||||
concList.add(Double.valueOf(conc.toString()));
|
concList.add(Double.valueOf(conc.toString()));
|
||||||
} else {//如果为空 存储0
|
} else {
|
||||||
concList.add(0.0);
|
concList.add(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
} else { //如果采集时间不包含当前日期 各数组填补null
|
||||||
|
//如果全数组遍历后都没有 就填充空数据
|
||||||
|
if (j == nuclideStatisticsMap.size()-1) {
|
||||||
|
collectStartList.add(dayTime);
|
||||||
|
quantityList.add(null);
|
||||||
|
acqLiveSecList.add(null);
|
||||||
|
//判断系统类型决定读取核素的信息
|
||||||
|
if (systemType.equals("beta") || systemType.equals("gamma")) {
|
||||||
|
for (String nuclideName: nuclideNameList) {
|
||||||
|
List<Double> concList = (List<Double>) resultMap.get(nuclideName + "Conc");
|
||||||
|
List<Double> mdcList = (List<Double>) resultMap.get(nuclideName + "MDC");
|
||||||
|
concList.add(null);
|
||||||
|
mdcList.add(null);
|
||||||
|
}
|
||||||
|
} else if (systemType.equals("Particulate")) {
|
||||||
|
for (String nuclideName: nuclideNameList) {
|
||||||
|
List<Double> concList = (List<Double>) resultMap.get(nuclideName + "Conc");
|
||||||
|
concList.add(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user