|
|
@@ -45,13 +45,14 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
@Service
|
|
|
public class SysWorkTimeSetServiceImpl extends ServiceImpl<SysWorkTimeSetMapper, SysWorkTimeSet> implements ISysWorkTimeSetService {
|
|
|
@Autowired
|
|
|
- private SysWorkTimeSetMapper sysWorkTimeSetMapper;
|
|
|
+ private SysWorkTimeSetMapper sysWorkTimeSetMapper;
|
|
|
@Autowired
|
|
|
private ISysOrgService orgService;
|
|
|
@Autowired
|
|
|
private SysWorkTimeSetDayofweekMapper sysWorkTimeSetDayofweekMapper;
|
|
|
@Autowired
|
|
|
private SysWorkTimeMapper sysWorkTimeMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public TableDataInfo<SysWorkTimeSet> selectPage(SysWorkTimeSet sysWorkTimeSet) {
|
|
|
//未删除
|
|
|
@@ -82,6 +83,7 @@ public class SysWorkTimeSetServiceImpl extends ServiceImpl<SysWorkTimeSetMapper,
|
|
|
//抓换为TableDataInfo适配前端
|
|
|
return TableDataInfo.build(page);
|
|
|
}
|
|
|
+
|
|
|
public static Date parseDate(String dateString, String dateFormat) throws ParseException {
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
|
|
|
return sdf.parse(dateString);
|
|
|
@@ -97,6 +99,7 @@ public class SysWorkTimeSetServiceImpl extends ServiceImpl<SysWorkTimeSetMapper,
|
|
|
calendar.set(Calendar.MILLISECOND, 0);
|
|
|
return calendar.getTime();
|
|
|
}
|
|
|
+
|
|
|
@Override
|
|
|
public AjaxResult workTimePageList(SysWorkTimeSet sysWorkTimeSet) throws ParseException {
|
|
|
|
|
|
@@ -231,7 +234,7 @@ public class SysWorkTimeSetServiceImpl extends ServiceImpl<SysWorkTimeSetMapper,
|
|
|
@Override
|
|
|
public SysWorkTimeSet selectSysWorkTimeSetById(Long id) {
|
|
|
SysWorkTimeSet sysWorkTimeSet = sysWorkTimeSetMapper.selectById(id);
|
|
|
- if(sysWorkTimeSet!=null) {
|
|
|
+ if (sysWorkTimeSet != null) {
|
|
|
sysWorkTimeSet.setDayOfWeeks(sysWorkTimeSetDayofweekMapper.selectList(new QueryWrapper<SysWorkTimeSetDayofweek>().eq("work_time_set_id", id)));
|
|
|
for (SysWorkTimeSetDayofweek day :
|
|
|
sysWorkTimeSet.getDayOfWeeks()) {
|
|
|
@@ -239,15 +242,15 @@ public class SysWorkTimeSetServiceImpl extends ServiceImpl<SysWorkTimeSetMapper,
|
|
|
day.setDayOfWeekText("星期天");
|
|
|
} else if (day.getDayOfWeek() == 2) {
|
|
|
day.setDayOfWeekText("星期一");
|
|
|
- }else if (day.getDayOfWeek() == 3) {
|
|
|
+ } else if (day.getDayOfWeek() == 3) {
|
|
|
day.setDayOfWeekText("星期二");
|
|
|
- }else if (day.getDayOfWeek() == 4) {
|
|
|
+ } else if (day.getDayOfWeek() == 4) {
|
|
|
day.setDayOfWeekText("星期三");
|
|
|
- }else if (day.getDayOfWeek() == 5) {
|
|
|
+ } else if (day.getDayOfWeek() == 5) {
|
|
|
day.setDayOfWeekText("星期四");
|
|
|
- }else if (day.getDayOfWeek() == 6) {
|
|
|
+ } else if (day.getDayOfWeek() == 6) {
|
|
|
day.setDayOfWeekText("星期五");
|
|
|
- }else if (day.getDayOfWeek() == 7) {
|
|
|
+ } else if (day.getDayOfWeek() == 7) {
|
|
|
day.setDayOfWeekText("星期六");
|
|
|
}
|
|
|
}
|
|
|
@@ -319,17 +322,18 @@ public class SysWorkTimeSetServiceImpl extends ServiceImpl<SysWorkTimeSetMapper,
|
|
|
}
|
|
|
return "ok";
|
|
|
}
|
|
|
- private void changeOrgWorkTime(List<SysWorkTimeSet> sets,List<SysWorkTimeSetDayofweek> dayOfWeeks, Date effectiveDate, List<Long> orgIds,Integer checkDataResult) {
|
|
|
+
|
|
|
+ private void changeOrgWorkTime(List<SysWorkTimeSet> sets, List<SysWorkTimeSetDayofweek> dayOfWeeks, Date effectiveDate, List<Long> orgIds, Integer checkDataResult) {
|
|
|
int month = new DateHelper(effectiveDate).getMonth();
|
|
|
int monthDay = new DateHelper(new Date()).getMonth();
|
|
|
//如果生效月份等于当前月份,那么就修改当本月生效日期后及下个月的作息时间
|
|
|
- if(month==monthDay||month==monthDay+1){
|
|
|
+ if (month == monthDay || month == monthDay + 1) {
|
|
|
// 获取当前时间的Calendar实例
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
// 将Calendar实例的月份设置为下个月的月份
|
|
|
- if(month==monthDay){
|
|
|
+ if (month == monthDay) {
|
|
|
cal.set(Calendar.MONTH, month + 1);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
cal.set(Calendar.MONTH, month);
|
|
|
}
|
|
|
// 将Calendar实例的日期设置为1号
|
|
|
@@ -338,14 +342,14 @@ public class SysWorkTimeSetServiceImpl extends ServiceImpl<SysWorkTimeSetMapper,
|
|
|
cal.add(Calendar.DATE, -1);
|
|
|
cal.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
|
|
|
//删除当月生效日期后的作息时间及下个月的作息时间
|
|
|
- Map<String,Object> map = new HashMap<>();
|
|
|
- map.put("effectiveDate",effectiveDate);
|
|
|
- map.put("lastDayOfNextMonth", DateUtil.format(cal.getTime(),"yyyy-MM-dd"));
|
|
|
- map.put("orgIds",orgIds);
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("effectiveDate", effectiveDate);
|
|
|
+ map.put("lastDayOfNextMonth", DateUtil.format(cal.getTime(), "yyyy-MM-dd"));
|
|
|
+ map.put("orgIds", orgIds);
|
|
|
//objectMapper.deleteOrgWorkTimeByMonth(map);
|
|
|
//获取不需要生成的日期
|
|
|
List<SysWorkTime> list = new ArrayList<>();
|
|
|
- if(checkDataResult!=null&&checkDataResult==0){
|
|
|
+ if (checkDataResult != null && checkDataResult == 0) {
|
|
|
list = sysWorkTimeMapper.getOrgWorkTimeByMonth(map);
|
|
|
}
|
|
|
//添加当月生效日期后的作息时间及下个月的作息时间
|
|
|
@@ -354,15 +358,15 @@ public class SysWorkTimeSetServiceImpl extends ServiceImpl<SysWorkTimeSetMapper,
|
|
|
for (SysWorkTimeSet workTime : sets) {
|
|
|
List<SysWorkTime> workTimeEditDtoList = new ArrayList<>();
|
|
|
for (DateTime time : dateTimeList) {
|
|
|
- Optional<SysWorkTimeSetDayofweek> dayOfWeekSetNew = workTime.getDayOfWeeks().stream().filter(w -> w.getDayOfWeek() == time.dayOfWeek() && ObjectUtil.isNotNull(w.getIsWorkday()) && w.getIsWorkday()>0).findFirst();
|
|
|
+ Optional<SysWorkTimeSetDayofweek> dayOfWeekSetNew = workTime.getDayOfWeeks().stream().filter(w -> w.getDayOfWeek() == time.dayOfWeek() && ObjectUtil.isNotNull(w.getIsWorkday()) && w.getIsWorkday() > 0).findFirst();
|
|
|
SysWorkTimeSetDayofweek dayOfWeekSet = dayOfWeekSetNew.orElse(null);
|
|
|
- boolean isEnable = ObjectUtil.isNotNull(dayOfWeekSet) && dayOfWeekSet.getIsWorkday()>0;
|
|
|
+ boolean isEnable = ObjectUtil.isNotNull(dayOfWeekSet) && dayOfWeekSet.getIsWorkday() > 0;
|
|
|
SysWorkTime dto = new SysWorkTime();
|
|
|
dto.setDate(time);
|
|
|
- dto.setIsEnable(isEnable?1L:0);
|
|
|
+ dto.setIsEnable(isEnable ? 1L : 0);
|
|
|
workTimeEditDtoList.add(dto);
|
|
|
- if (ObjectUtil.isNull(dayOfWeekSet) || !(dayOfWeekSet.getIsWorkday()>0)) {
|
|
|
- Optional<SysWorkTimeSetDayofweek> firstWorkDay = workTime.getDayOfWeeks().stream().filter(f -> f.getIsWorkday()>0).findFirst();
|
|
|
+ if (ObjectUtil.isNull(dayOfWeekSet) || !(dayOfWeekSet.getIsWorkday() > 0)) {
|
|
|
+ Optional<SysWorkTimeSetDayofweek> firstWorkDay = workTime.getDayOfWeeks().stream().filter(f -> f.getIsWorkday() > 0).findFirst();
|
|
|
if (firstWorkDay.isPresent()) {
|
|
|
dayOfWeekSet = firstWorkDay.get();
|
|
|
}
|
|
|
@@ -376,40 +380,41 @@ public class SysWorkTimeSetServiceImpl extends ServiceImpl<SysWorkTimeSetMapper,
|
|
|
}
|
|
|
workTimeEditDtoListAll.addAll(workTimeEditDtoList);
|
|
|
}
|
|
|
- if(CollectionUtils.isNotEmpty(workTimeEditDtoListAll)){
|
|
|
+ if (CollectionUtils.isNotEmpty(workTimeEditDtoListAll)) {
|
|
|
SysWorkTimeSet requesta = new SysWorkTimeSet();
|
|
|
requesta.setOrgIds(orgIds);
|
|
|
//获取所有的作息配置
|
|
|
List<SysWorkTimeSet> listSet = sysWorkTimeSetMapper.selectWorkTimeSetList(requesta);
|
|
|
- for(Long orgId:orgIds){
|
|
|
- List<SysWorkTimeSet> listSetOrg = listSet.stream().filter(f->f.getOrgId().equals(orgId)&&f.getEffectiveDate().getTime()!=effectiveDate.getTime()).collect(Collectors.toList());
|
|
|
- if(CollectionUtils.isNotEmpty(listSetOrg)){
|
|
|
+ for (Long orgId : orgIds) {
|
|
|
+ List<SysWorkTimeSet> listSetOrg = listSet.stream().filter(f -> f.getOrgId().equals(orgId) && f.getEffectiveDate().getTime() != effectiveDate.getTime()).collect(Collectors.toList());
|
|
|
+ if (CollectionUtils.isNotEmpty(listSetOrg)) {
|
|
|
List<Date> dateList = new ArrayList<>();
|
|
|
dateList.add(effectiveDate);
|
|
|
- listSetOrg.forEach(f->{
|
|
|
+ listSetOrg.forEach(f -> {
|
|
|
dateList.add(f.getEffectiveDate());
|
|
|
});
|
|
|
//dateList排序
|
|
|
dateList.sort(Comparator.comparing(Date::getTime));
|
|
|
//取出request.getEffectiveDate()在dateList中的位置
|
|
|
int index = dateList.indexOf(effectiveDate);
|
|
|
- if(index!=dateList.size()-1){
|
|
|
- Date effectiveDateNext = dateList.get(index+1);
|
|
|
+ if (index != dateList.size() - 1) {
|
|
|
+ Date effectiveDateNext = dateList.get(index + 1);
|
|
|
//取出workTimeEditDtoListAll中ymd_date在EffectiveDate和effectiveDateNext之间的数据
|
|
|
- List<SysWorkTime> workTimeEditDtoList = workTimeEditDtoListAll.stream().filter(f->f.getDate().getTime()>=effectiveDate.getTime()&&f.getDate().getTime()<effectiveDateNext.getTime()).collect(Collectors.toList());
|
|
|
- batchnew(orgId,workTimeEditDtoList,list);
|
|
|
- }else{
|
|
|
- batchnew(orgId,workTimeEditDtoListAll,list);
|
|
|
+ List<SysWorkTime> workTimeEditDtoList = workTimeEditDtoListAll.stream().filter(f -> f.getDate().getTime() >= effectiveDate.getTime() && f.getDate().getTime() < effectiveDateNext.getTime()).collect(Collectors.toList());
|
|
|
+ batchnew(orgId, workTimeEditDtoList, list);
|
|
|
+ } else {
|
|
|
+ batchnew(orgId, workTimeEditDtoListAll, list);
|
|
|
}
|
|
|
- }else{
|
|
|
- batchnew(orgId,workTimeEditDtoListAll,list);
|
|
|
+ } else {
|
|
|
+ batchnew(orgId, workTimeEditDtoListAll, list);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- public List<SysWorkTime> batchnew(Long orgId, List<SysWorkTime> workTimeDtoList,List<SysWorkTime> list) {
|
|
|
+
|
|
|
+ public List<SysWorkTime> batchnew(Long orgId, List<SysWorkTime> workTimeDtoList, List<SysWorkTime> list) {
|
|
|
// 小于现在时间的不允许修改
|
|
|
final Date now = DateUtil.beginOfDay(new Date());
|
|
|
Date updateTime = new Date();
|
|
|
@@ -425,7 +430,7 @@ public class SysWorkTimeSetServiceImpl extends ServiceImpl<SysWorkTimeSetMapper,
|
|
|
workTime.setIsManual(0L);
|
|
|
workTime.setIsEnable(workTimeEditDto.getIsEnable());
|
|
|
workTime.setUpdateTime(updateTime);
|
|
|
- if(!(workTimeEditDto.getIsEnable()>0)){
|
|
|
+ if (!(workTimeEditDto.getIsEnable() > 0)) {
|
|
|
workTime.setWorkTime(null);
|
|
|
workTime.setWorkOffTime(null);
|
|
|
workTime.setOpenTime(null);
|
|
|
@@ -441,12 +446,13 @@ public class SysWorkTimeSetServiceImpl extends ServiceImpl<SysWorkTimeSetMapper,
|
|
|
}).collect(Collectors.toList());
|
|
|
for (SysWorkTime s :
|
|
|
list1) {
|
|
|
- sysWorkTimeMapper.insert(s);
|
|
|
+ sysWorkTimeMapper.insert(s);
|
|
|
workTimeList.add(s);
|
|
|
}
|
|
|
|
|
|
return workTimeList;
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 查询作息设置列表
|
|
|
*
|