|
@@ -14,18 +14,22 @@ import com.github.zuihou.base.service.SuperServiceImpl;
|
|
|
|
|
|
import com.github.zuihou.common.constant.CodeRuleModule;
|
|
import com.github.zuihou.common.constant.CodeRuleModule;
|
|
import com.github.zuihou.common.constant.DictionaryType;
|
|
import com.github.zuihou.common.constant.DictionaryType;
|
|
|
|
+import com.github.zuihou.common.util.DateUtil;
|
|
import com.github.zuihou.database.mybatis.conditions.Wraps;
|
|
import com.github.zuihou.database.mybatis.conditions.Wraps;
|
|
import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
|
|
import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
|
|
import com.github.zuihou.injection.annonation.InjectionResult;
|
|
import com.github.zuihou.injection.annonation.InjectionResult;
|
|
import com.github.zuihou.model.RemoteData;
|
|
import com.github.zuihou.model.RemoteData;
|
|
import com.github.zuihou.tenant.service.CodeRuleService;
|
|
import com.github.zuihou.tenant.service.CodeRuleService;
|
|
import com.github.zuihou.utils.BeanPlusUtil;
|
|
import com.github.zuihou.utils.BeanPlusUtil;
|
|
|
|
+import com.github.zuihou.utils.DateUtils;
|
|
import com.github.zuihou.utils.StrPool;
|
|
import com.github.zuihou.utils.StrPool;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
+import java.util.Arrays;
|
|
|
|
+import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
@@ -68,7 +72,10 @@ public class ScheduleFrequencyServiceImpl extends SuperServiceImpl<ScheduleFrequ
|
|
@Override
|
|
@Override
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
public ScheduleFrequency save(ScheduleFrequencySaveDTO data) {
|
|
public ScheduleFrequency save(ScheduleFrequencySaveDTO data) {
|
|
|
|
+ // 校验班次是否已经存在
|
|
isFalse(check(data), "班次名称已存在,请重新输入");
|
|
isFalse(check(data), "班次名称已存在,请重新输入");
|
|
|
|
+ // 班次日期是否重叠
|
|
|
|
+ isFalse(checkScheduleFrequencyTime(data), "班次名称日期与其他班次日期有重叠,请重新输入");
|
|
|
|
|
|
ScheduleFrequency scheduleFrequency = BeanPlusUtil.toBean(data, ScheduleFrequency.class);
|
|
ScheduleFrequency scheduleFrequency = BeanPlusUtil.toBean(data, ScheduleFrequency.class);
|
|
//根据编码规则
|
|
//根据编码规则
|
|
@@ -78,6 +85,62 @@ public class ScheduleFrequencyServiceImpl extends SuperServiceImpl<ScheduleFrequ
|
|
return scheduleFrequency;
|
|
return scheduleFrequency;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 判断时间是否有交集
|
|
|
|
+ * @param data
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private boolean checkScheduleFrequencyTime(ScheduleFrequencySaveDTO data) {
|
|
|
|
+ boolean flag = false;
|
|
|
|
+ List<String> frequencyTypes = Arrays.asList("01,02,03".split(","));
|
|
|
|
+ List<ScheduleFrequency> frequencys = baseMapper.selectList(Wraps.<ScheduleFrequency>lbQ().in(ScheduleFrequency::getName,frequencyTypes ));
|
|
|
|
+ for(ScheduleFrequency scheduleFrequency : frequencys){
|
|
|
|
+ String endDateOne;
|
|
|
|
+ if("1".equals(scheduleFrequency.getAccossDay())){
|
|
|
|
+ String[] times = scheduleFrequency.getEndTime().split(":");
|
|
|
|
+ endDateOne = String.valueOf(24 + Integer.valueOf(times[0])) + times[1];
|
|
|
|
+ }else{
|
|
|
|
+ endDateOne=scheduleFrequency.getEndTime();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String endDateTwo;
|
|
|
|
+ if("1".equals(data.getAccossDay())){
|
|
|
|
+ String[] times = data.getEndTime().split(":");
|
|
|
|
+ endDateTwo = String.valueOf(24 + Integer.valueOf(times[0])) + times[1];
|
|
|
|
+ }else{
|
|
|
|
+ endDateTwo=data.getEndTime();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(IsInterSection(scheduleFrequency.getStartTime(),endDateOne,data.getStartTime(),endDateTwo)){
|
|
|
|
+ flag = true;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return flag;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static Boolean IsInterSection(String startDateOne, String endDateOne, String startDateTwo, String endDateTwo)
|
|
|
|
+ {
|
|
|
|
+ String maxStartDate = startDateOne;
|
|
|
|
+ if(maxStartDate.compareTo(startDateTwo)<0)
|
|
|
|
+ {
|
|
|
|
+ maxStartDate = startDateTwo;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String minEndDate = endDateOne;
|
|
|
|
+ if(endDateTwo.compareTo(minEndDate) < 0)
|
|
|
|
+ {
|
|
|
|
+ minEndDate = endDateTwo;
|
|
|
|
+ }
|
|
|
|
+ if(maxStartDate.compareTo(minEndDate) < 0 )
|
|
|
|
+ {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
public ScheduleFrequency update(ScheduleFrequencyUpdateDTO data) {
|
|
public ScheduleFrequency update(ScheduleFrequencyUpdateDTO data) {
|