|
@@ -32,26 +32,26 @@ public class ZhcxCommissionCheckParameterSetDetalServiceImpl extends ServiceImpl
|
|
|
|
|
|
@Override
|
|
|
public R computeCheckParameterSetDetalEstimatedenddate(String masterId) {
|
|
|
- if(StringUtils.isEmpty(masterId)){
|
|
|
+ if (StringUtils.isEmpty(masterId)) {
|
|
|
return R.error("试车主表ID不能为空");
|
|
|
}
|
|
|
List<ZhcxCommissionCheckParameterSetDetalDo> list = baseMapper.getAllByCheckidOrId(masterId);
|
|
|
- if (list.size() != 1){
|
|
|
+ if (list.size() != 1) {
|
|
|
return R.ok("试车参数数据异常");
|
|
|
}
|
|
|
ZhcxCommissionCheckParameterSetDetalDo parameterSetDetalDo = list.get(0);
|
|
|
// 前端已经计算了 填入开始时间
|
|
|
- if(Objects.isNull(parameterSetDetalDo.getBegindate())){
|
|
|
+ if (Objects.isNull(parameterSetDetalDo.getBegindate())) {
|
|
|
parameterSetDetalDo.setBegindate(parameterSetDetalDo.getRecentlyTime());
|
|
|
}
|
|
|
// 剩余天数 = 难度系数*预估剩余天数
|
|
|
- if(StringUtils.isEmpty(parameterSetDetalDo.getDifficultyfactor())){
|
|
|
+ if (StringUtils.isEmpty(parameterSetDetalDo.getDifficultyfactor())) {
|
|
|
parameterSetDetalDo.setDifficultyfactor("1");
|
|
|
}
|
|
|
- if(StringUtils.isEmpty(parameterSetDetalDo.getDailytime())){
|
|
|
+ if (StringUtils.isEmpty(parameterSetDetalDo.getDailytime())) {
|
|
|
return R.ok("每天试车时间为空");
|
|
|
}
|
|
|
- if(StringUtils.isEmpty(parameterSetDetalDo.getEESIDUALTIME())){
|
|
|
+ if (StringUtils.isEmpty(parameterSetDetalDo.getEESIDUALTIME())) {
|
|
|
return R.ok("剩余试车时间(min)为空,该试车检查内容已全部完成");
|
|
|
}
|
|
|
double eesidualtime = Double.parseDouble(parameterSetDetalDo.getEESIDUALTIME());
|
|
@@ -59,7 +59,7 @@ public class ZhcxCommissionCheckParameterSetDetalServiceImpl extends ServiceImpl
|
|
|
int days = (int) Math.ceil(eesidualtime / (dailytime * 60));
|
|
|
parameterSetDetalDo.setEstimateddaynum(String.valueOf(days));
|
|
|
// 计算预估剩余天数
|
|
|
- if(StringUtils.isEmpty(parameterSetDetalDo.getEstimateddaynum())){
|
|
|
+ if (StringUtils.isEmpty(parameterSetDetalDo.getEstimateddaynum())) {
|
|
|
return R.ok("预估剩余天数为空");
|
|
|
}
|
|
|
int dayNum = 0;
|
|
@@ -75,7 +75,7 @@ public class ZhcxCommissionCheckParameterSetDetalServiceImpl extends ServiceImpl
|
|
|
// 选择的加班日期 (周日,周六,节假日)
|
|
|
String selectdate = parameterSetDetalDo.getSelectdate();
|
|
|
// 防止空指针异常
|
|
|
- if(StringUtils.isEmpty(selectdate)){
|
|
|
+ if (StringUtils.isEmpty(selectdate)) {
|
|
|
selectdate = "";
|
|
|
}
|
|
|
// 计算预估试车结束日期
|
|
@@ -89,7 +89,7 @@ public class ZhcxCommissionCheckParameterSetDetalServiceImpl extends ServiceImpl
|
|
|
}
|
|
|
|
|
|
// 计算实际偏转日期
|
|
|
- private String computeEstimatedenddate(int dayNum,String selectdate){
|
|
|
+ private String computeEstimatedenddate(int dayNum, String selectdate) {
|
|
|
// 是否周六上班 (周日,周六,节假日)
|
|
|
boolean workInSaturDays = selectdate.contains("周六");
|
|
|
// 是否周日上班
|
|
@@ -103,58 +103,58 @@ public class ZhcxCommissionCheckParameterSetDetalServiceImpl extends ServiceImpl
|
|
|
// 拿到放假的日期
|
|
|
String selectholidaydetail = baseMapper.selectholidaydetail();
|
|
|
// 防止空指针异常
|
|
|
- if(StringUtils.isEmpty(selectholidaydetail)){
|
|
|
+ if (StringUtils.isEmpty(selectholidaydetail)) {
|
|
|
selectholidaydetail = "";
|
|
|
}
|
|
|
// 拿到上班的日期
|
|
|
String selectNotholidaydetail = baseMapper.selectNotholidaydetail();
|
|
|
// 防止空指针异常
|
|
|
- if(StringUtils.isEmpty(selectNotholidaydetail)){
|
|
|
+ if (StringUtils.isEmpty(selectNotholidaydetail)) {
|
|
|
selectNotholidaydetail = "";
|
|
|
}
|
|
|
Date baseDate = new Date();
|
|
|
- while (actualDayList.size() != dayNum){
|
|
|
+ while (actualDayList.size() != dayNum) {
|
|
|
// 拿到第一次偏转的日期
|
|
|
DateTime dateTime = DateUtil.offsetDay(baseDate, actualDayNum);
|
|
|
String dateString = new SimpleDateFormat("yyyy-MM-dd").format(dateTime);
|
|
|
// 判断是否为节假日 并且节假日不上班
|
|
|
- if(selectholidaydetail.contains(dateString) && workInHoliday){
|
|
|
+ if (selectholidaydetail.contains(dateString) && workInHoliday) {
|
|
|
actualDayList.add(dateString);
|
|
|
actualDayNum++;
|
|
|
continue;
|
|
|
- }else if(selectholidaydetail.contains(dateString) && !workInHoliday){
|
|
|
+ } else if (selectholidaydetail.contains(dateString) && !workInHoliday) {
|
|
|
actualDayNum++;
|
|
|
continue;
|
|
|
- } else if(isSATURDAY(dateTime) && workInSaturDays){
|
|
|
+ } else if (isSATURDAY(dateTime) && workInSaturDays) {
|
|
|
actualDayList.add(dateString);
|
|
|
actualDayNum++;
|
|
|
continue;
|
|
|
}
|
|
|
// 判断是否为周日 并且周日不上班
|
|
|
- else if(isSUNDAY(dateTime) && workInSunDays){
|
|
|
+ else if (isSUNDAY(dateTime) && workInSunDays) {
|
|
|
actualDayList.add(dateString);
|
|
|
actualDayNum++;
|
|
|
continue;
|
|
|
}
|
|
|
// 判断该天是否因为调休去上班
|
|
|
- else if(selectNotholidaydetail.contains(dateString)){
|
|
|
+ else if (selectNotholidaydetail.contains(dateString)) {
|
|
|
actualDayList.add(dateString);
|
|
|
actualDayNum++;
|
|
|
continue;
|
|
|
- } else if(!isSATURDAY(dateTime) && !isSUNDAY(dateTime)){
|
|
|
+ } else if (!isSATURDAY(dateTime) && !isSUNDAY(dateTime)) {
|
|
|
actualDayList.add(dateString);
|
|
|
actualDayNum++;
|
|
|
continue;
|
|
|
}
|
|
|
actualDayNum++;
|
|
|
}
|
|
|
- if(actualDayList.isEmpty()){
|
|
|
+ if (actualDayList.isEmpty()) {
|
|
|
// 抛出异常
|
|
|
throw new CustomException("计算实际偏转日期异常");
|
|
|
}
|
|
|
- log.info("实际上要上班的日期为:{}",actualDayList.stream().collect(Collectors.joining(", ")));
|
|
|
+ log.info("实际上要上班的日期为:{}", actualDayList.stream().collect(Collectors.joining(", ")));
|
|
|
// 返回最后一个日期
|
|
|
- return actualDayList.get(actualDayList.size()-1);
|
|
|
+ return actualDayList.get(actualDayList.size() - 1);
|
|
|
}
|
|
|
|
|
|
// 是否为周六
|
|
@@ -162,10 +162,22 @@ public class ZhcxCommissionCheckParameterSetDetalServiceImpl extends ServiceImpl
|
|
|
final Week week = DateUtil.dayOfWeekEnum(date);
|
|
|
return Week.SATURDAY == week;
|
|
|
}
|
|
|
+
|
|
|
// 是否为周日
|
|
|
private static boolean isSUNDAY(Date date) {
|
|
|
final Week week = DateUtil.dayOfWeekEnum(date);
|
|
|
return Week.SUNDAY == week;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void scheduledComputeEstimatedenddate() {
|
|
|
+ // 获取全部的试车检查主表
|
|
|
+ List<String> checks = baseMapper.getAllChecks();
|
|
|
+ log.info("定时任务更新试车检查参数设置子表预估试车结束日期开始");
|
|
|
+ // 执行更新试车参数预估结束日期
|
|
|
+ for (String checkId : checks) {
|
|
|
+ computeCheckParameterSetDetalEstimatedenddate(checkId);
|
|
|
+ }
|
|
|
+ log.info("定时任务更新试车检查参数设置子表预估试车结束日期结束");
|
|
|
+ }
|
|
|
}
|