|
|
@ -1,10 +1,20 @@
|
|
|
|
package com.shxy.xymanager_common.util;
|
|
|
|
package com.shxy.xymanager_common.util;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DateField;
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
|
|
|
import com.shxy.xymanager_common.dto.PhotoTimeResultDto;
|
|
|
|
import com.shxy.xymanager_common.dto.ScheduleDetailsDto;
|
|
|
|
import com.shxy.xymanager_common.dto.ScheduleDetailsDto;
|
|
|
|
import com.shxy.xymanager_common.entity.ScheduleDetails;
|
|
|
|
import com.shxy.xymanager_common.entity.ScheduleDetails;
|
|
|
|
import com.shxy.xymanager_common.model.TerminalScheduleRuleModel;
|
|
|
|
import com.shxy.xymanager_common.model.TerminalScheduleRuleModel;
|
|
|
|
|
|
|
|
import com.shxy.xymanager_common.model.TerminalScheduleRuleTimeListModel;
|
|
|
|
import com.shxy.xymanager_common.vo.ScheduleRuleVo;
|
|
|
|
import com.shxy.xymanager_common.vo.ScheduleRuleVo;
|
|
|
|
|
|
|
|
import net.sf.jsqlparser.expression.DateTimeLiteralExpression;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
import java.sql.Time;
|
|
|
|
import java.sql.Time;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
@ -65,6 +75,9 @@ public class ScheduleListUtils {
|
|
|
|
StringBuffer timestr = new StringBuffer();
|
|
|
|
StringBuffer timestr = new StringBuffer();
|
|
|
|
short perset = dtoList.get(0).getPreset().shortValue();
|
|
|
|
short perset = dtoList.get(0).getPreset().shortValue();
|
|
|
|
int index = 0;
|
|
|
|
int index = 0;
|
|
|
|
|
|
|
|
String startstring = "";
|
|
|
|
|
|
|
|
String endstring = "";
|
|
|
|
|
|
|
|
String spanstring = "";
|
|
|
|
for (int i = 0; i < dtoList.size(); i++) {
|
|
|
|
for (int i = 0; i < dtoList.size(); i++) {
|
|
|
|
short startHour = 0;
|
|
|
|
short startHour = 0;
|
|
|
|
short startMin = 0;
|
|
|
|
short startMin = 0;
|
|
|
@ -72,9 +85,9 @@ public class ScheduleListUtils {
|
|
|
|
short endMin = 0;
|
|
|
|
short endMin = 0;
|
|
|
|
short spanHour = 0;
|
|
|
|
short spanHour = 0;
|
|
|
|
short spanMin = 0;
|
|
|
|
short spanMin = 0;
|
|
|
|
String string = "";
|
|
|
|
|
|
|
|
if (XyNumberUtils.remainder(i, 3) == 0) {
|
|
|
|
if (XyNumberUtils.remainder(i, 3) == 0) {
|
|
|
|
index = index + 3;
|
|
|
|
index = i + 2;
|
|
|
|
Number add = XyNumberUtils.add((Number) dtoList.get(i).getMinute(), offset);
|
|
|
|
Number add = XyNumberUtils.add((Number) dtoList.get(i).getMinute(), offset);
|
|
|
|
if (add.intValue() >= 60) {
|
|
|
|
if (add.intValue() >= 60) {
|
|
|
|
Number add1 = XyNumberUtils.add((Number) dtoList.get(i).getHour(), 1);
|
|
|
|
Number add1 = XyNumberUtils.add((Number) dtoList.get(i).getHour(), 1);
|
|
|
@ -89,9 +102,9 @@ public class ScheduleListUtils {
|
|
|
|
startHour = dtoList.get(i).getHour().shortValue();
|
|
|
|
startHour = dtoList.get(i).getHour().shortValue();
|
|
|
|
startMin = add.shortValue();
|
|
|
|
startMin = add.shortValue();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
string = " --hour" + index + "=" + startHour + " --min" + index + "=" + startMin + " --preset" + index + "=" + perset;
|
|
|
|
startstring = " --hour" + index + "=" + startHour + " --min" + index + "=" + startMin + " --preset" + index + "=" + perset;
|
|
|
|
} else if (XyNumberUtils.remainder(i, 3) == 1) {
|
|
|
|
} else if (XyNumberUtils.remainder(i, 3) == 1) {
|
|
|
|
index = index - 1;
|
|
|
|
index = i + 2;
|
|
|
|
Number add = XyNumberUtils.add((Number) dtoList.get(i).getMinute(), offset);
|
|
|
|
Number add = XyNumberUtils.add((Number) dtoList.get(i).getMinute(), offset);
|
|
|
|
if (add.intValue() >= 60) {
|
|
|
|
if (add.intValue() >= 60) {
|
|
|
|
Number add1 = XyNumberUtils.add((Number) dtoList.get(i).getHour(), 1);
|
|
|
|
Number add1 = XyNumberUtils.add((Number) dtoList.get(i).getHour(), 1);
|
|
|
@ -106,15 +119,17 @@ public class ScheduleListUtils {
|
|
|
|
endHour = dtoList.get(i).getHour().shortValue();
|
|
|
|
endHour = dtoList.get(i).getHour().shortValue();
|
|
|
|
endMin = add.shortValue();
|
|
|
|
endMin = add.shortValue();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
string = " --hour" + index + "=" + endHour + " --min" + index + "=" + endMin + " --preset" + index + "=" + perset;
|
|
|
|
endstring = " --hour" + index + "=" + endHour + " --min" + index + "=" + endMin + " --preset" + index + "=" + perset;
|
|
|
|
} else if (XyNumberUtils.remainder(i, 3) == 2) {
|
|
|
|
} else if (XyNumberUtils.remainder(i, 3) == 2) {
|
|
|
|
index = index - 1;
|
|
|
|
index = i - 1;
|
|
|
|
spanHour = dtoList.get(i).getHour().shortValue();
|
|
|
|
spanHour = dtoList.get(i).getHour().shortValue();
|
|
|
|
spanMin = dtoList.get(i).getMinute().shortValue();
|
|
|
|
spanMin = dtoList.get(i).getMinute().shortValue();
|
|
|
|
string = " --hour" + index + "=" + spanHour + " --min" + index + "=" + spanMin + " --preset" + index + "=" + perset;
|
|
|
|
spanstring = " --hour" + index + "=" + spanHour + " --min" + index + "=" + spanMin + " --preset" + index + "=" + perset;
|
|
|
|
index = index + 2;
|
|
|
|
if (StrUtil.isNotEmpty(spanstring) && StrUtil.isNotEmpty(startstring) && StrUtil.isNotEmpty(endstring)) {
|
|
|
|
|
|
|
|
timestr.append(spanstring).append(startstring).append(endstring);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
timestr.append(string);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return timestr.toString();
|
|
|
|
return timestr.toString();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -188,4 +203,41 @@ public class ScheduleListUtils {
|
|
|
|
return detailsBeans;
|
|
|
|
return detailsBeans;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* 讲查询转为前端的时间字符串
|
|
|
|
|
|
|
|
* */
|
|
|
|
|
|
|
|
public static List<String> getResultDetails(List<PhotoTimeResultDto> resultDtoList) {
|
|
|
|
|
|
|
|
List<String> resultList = new ArrayList<>();
|
|
|
|
|
|
|
|
if (CollectionUtil.isNotEmpty(resultDtoList)) {
|
|
|
|
|
|
|
|
DateTime starttime = null;
|
|
|
|
|
|
|
|
Integer span = null;
|
|
|
|
|
|
|
|
DateTime endtime;
|
|
|
|
|
|
|
|
for (int j = 0; j < resultDtoList.size(); j++) {
|
|
|
|
|
|
|
|
if (XyNumberUtils.remainder(j, 3) == 0) {//时间间隔
|
|
|
|
|
|
|
|
Integer hour = resultDtoList.get(j).getHour();
|
|
|
|
|
|
|
|
Integer minute = resultDtoList.get(j).getMinute();
|
|
|
|
|
|
|
|
Number mul = XyNumberUtils.mul((Number) hour, 60);
|
|
|
|
|
|
|
|
Number add = XyNumberUtils.add(mul, minute);
|
|
|
|
|
|
|
|
span = add.intValue();
|
|
|
|
|
|
|
|
} else if (XyNumberUtils.remainder(j, 3) == 1) {//开始时间
|
|
|
|
|
|
|
|
Integer hour = resultDtoList.get(j).getHour();
|
|
|
|
|
|
|
|
Integer minute = resultDtoList.get(j).getMinute();
|
|
|
|
|
|
|
|
starttime = MyDateUtils.HHMMToDate(hour, minute);
|
|
|
|
|
|
|
|
} else if (XyNumberUtils.remainder(j, 3) == 2) {//结束时间
|
|
|
|
|
|
|
|
Integer hour = resultDtoList.get(j).getHour();
|
|
|
|
|
|
|
|
Integer minute = resultDtoList.get(j).getMinute();
|
|
|
|
|
|
|
|
endtime = MyDateUtils.HHMMToDate(hour, minute);
|
|
|
|
|
|
|
|
if (starttime != null && endtime != null && span != null) {
|
|
|
|
|
|
|
|
List<DateTime> dateTimes = MyDateUtils.rangeToList(starttime, endtime, DateField.MINUTE, span);
|
|
|
|
|
|
|
|
for (DateTime data : dateTimes) {
|
|
|
|
|
|
|
|
String dateTime = DateUtil.formatTime(data);
|
|
|
|
|
|
|
|
resultList.add(dateTime);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return resultList;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|