|
|
@@ -1,41 +1,33 @@
|
|
|
package com.xunmei.system.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
-import cn.hutool.core.collection.ListUtil;
|
|
|
import cn.hutool.core.date.DateField;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
-import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.xunmei.common.core.constant.SecurityConstants;
|
|
|
+import com.xunmei.common.core.domain.worktime.domain.SysWorkTime;
|
|
|
import com.xunmei.common.core.domain.worktime.dto.WorkTimeDto;
|
|
|
-import com.xunmei.common.core.event.WorkTimeChangeEvent;
|
|
|
-import com.xunmei.common.core.utils.DateHelper;
|
|
|
import com.xunmei.common.core.utils.DateUtils;
|
|
|
import com.xunmei.common.core.utils.Ymd;
|
|
|
-import com.xunmei.common.core.web.domain.AjaxResult;
|
|
|
import com.xunmei.common.core.web.page.TableDataInfo;
|
|
|
import com.xunmei.common.security.utils.SecurityUtils;
|
|
|
-import com.xunmei.common.core.domain.worktime.domain.SysWorkTime;
|
|
|
import com.xunmei.system.domain.SysWorkTimeSet;
|
|
|
import com.xunmei.system.dto.SysWorkTimeDto;
|
|
|
-import com.xunmei.system.dto.WorkTimeMonthEditNewDto;
|
|
|
import com.xunmei.system.mapper.SysWorkTimeMapper;
|
|
|
import com.xunmei.system.mapper.SysWorkTimeSetMapper;
|
|
|
import com.xunmei.system.service.ISysOrgService;
|
|
|
import com.xunmei.system.service.ISysWorkTimeService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.ApplicationContext;
|
|
|
-import org.springframework.context.ApplicationEventPublisher;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
@@ -94,41 +86,39 @@ public class SysWorkTimeServiceImpl extends ServiceImpl<SysWorkTimeMapper, SysWo
|
|
|
//查询条件
|
|
|
QueryWrapper<SysWorkTime> query = new QueryWrapper<>();
|
|
|
|
|
|
- if (sysWorkTime.getIsEnable() != null) {
|
|
|
- query.eq("t.is_enable", sysWorkTime.getIsEnable());
|
|
|
- }
|
|
|
- if (sysWorkTime.getOrgId() != null && !sysWorkTime.getCheckSub()) {
|
|
|
- query.eq("t.org_id", sysWorkTime.getOrgId());
|
|
|
- }
|
|
|
- if (sysWorkTime.getModifiedName() != null) {
|
|
|
- query.eq("t.modified_name", sysWorkTime.getModifiedName());
|
|
|
- }
|
|
|
- if (sysWorkTime.getOrgType() != null) {
|
|
|
- query.eq("o.type", sysWorkTime.getOrgType());
|
|
|
- }
|
|
|
- //下穿
|
|
|
- if (sysWorkTime.getCheckSub()) {
|
|
|
- query.like("o.path", sysWorkTime.getOrgId());
|
|
|
- } else {
|
|
|
- query.likeLeft("o.path", sysWorkTime.getOrgId() + "-");
|
|
|
- }
|
|
|
+ if (sysWorkTime.getIsEnable() != null) {
|
|
|
+ query.eq("t.is_enable", sysWorkTime.getIsEnable());
|
|
|
+ }
|
|
|
+ if (sysWorkTime.getOrgId() != null && !sysWorkTime.getCheckSub()) {
|
|
|
+ query.eq("t.org_id", sysWorkTime.getOrgId());
|
|
|
+ }
|
|
|
+ if (sysWorkTime.getModifiedName() != null) {
|
|
|
+ query.eq("t.modified_name", sysWorkTime.getModifiedName());
|
|
|
+ }
|
|
|
+ if (sysWorkTime.getOrgType() != null) {
|
|
|
+ query.eq("o.type", sysWorkTime.getOrgType());
|
|
|
+ }
|
|
|
+ //下穿
|
|
|
+ if (sysWorkTime.getCheckSub()) {
|
|
|
+ query.like("o.path", sysWorkTime.getOrgId());
|
|
|
+ } else {
|
|
|
+ query.likeLeft("o.path", sysWorkTime.getOrgId() + "-");
|
|
|
+ }
|
|
|
// sysWorkTime.setOrgId(null);
|
|
|
|
|
|
- //时间范围查询
|
|
|
- if (sysWorkTime.getRange() != null && sysWorkTime.getRange().length > 1) {
|
|
|
- query.between("t.ymd_date", extractDate(sysWorkTime.getRange()[0].toString(), "EEE MMM dd HH:mm:ss zzz yyyy"), extractDate(sysWorkTime.getRange()[1].toString(), "EEE MMM dd HH:mm:ss zzz yyyy"));
|
|
|
- }
|
|
|
- query.orderByDesc("ymd_date");
|
|
|
+ //时间范围查询
|
|
|
+ if (sysWorkTime.getRange() != null && sysWorkTime.getRange().length > 1) {
|
|
|
+ query.between("t.ymd_date", extractDate(sysWorkTime.getRange()[0].toString(), "EEE MMM dd HH:mm:ss zzz yyyy"), extractDate(sysWorkTime.getRange()[1].toString(), "EEE MMM dd HH:mm:ss zzz yyyy"));
|
|
|
+ }
|
|
|
+ query.orderByDesc("ymd_date");
|
|
|
|
|
|
//获取数据
|
|
|
- IPage<SysWorkTimeDto> page1= null;
|
|
|
- if(sysWorkTime.getNoWorkTime())
|
|
|
- {
|
|
|
- page1 = sysWorkTimeMapper.selectNoWorkTimeByPage(page, query,sysWorkTime);
|
|
|
- }
|
|
|
- else{
|
|
|
- page1 = sysWorkTimeMapper.selectByPage(page, query);
|
|
|
- }
|
|
|
+ IPage<SysWorkTimeDto> page1 = null;
|
|
|
+ if (sysWorkTime.getNoWorkTime()) {
|
|
|
+ page1 = sysWorkTimeMapper.selectNoWorkTimeByPage(page, query, sysWorkTime);
|
|
|
+ } else {
|
|
|
+ page1 = sysWorkTimeMapper.selectByPage(page, query);
|
|
|
+ }
|
|
|
|
|
|
//抓换为TableDataInfo适配前端
|
|
|
return TableDataInfo.build(page1);
|
|
|
@@ -341,7 +331,7 @@ public class SysWorkTimeServiceImpl extends ServiceImpl<SysWorkTimeMapper, SysWo
|
|
|
Date updateTime = new Date();
|
|
|
|
|
|
for (SysWorkTime s : workTimeDtoList) {
|
|
|
- if (s.getIsEnable() == null || s.getYmdDate().compareTo(now)<=0) {
|
|
|
+ if (s.getIsEnable() == null || s.getYmdDate().compareTo(now) <= 0) {
|
|
|
|
|
|
} else {
|
|
|
List<SysWorkTime> list = baseMapper.selectList(new LambdaQueryWrapper<SysWorkTime>().eq(SysWorkTime::getOrgId, orgId).eq(SysWorkTime::getYmdDate, s.getYmdDate()));
|
|
|
@@ -362,6 +352,35 @@ public class SysWorkTimeServiceImpl extends ServiceImpl<SysWorkTimeMapper, SysWo
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public List<SysWorkTime> batchNew(List<Long> orgIdList, List<SysWorkTime> workTimeDtoList) {
|
|
|
+ if (orgIdList.isEmpty() || workTimeDtoList.isEmpty()) {
|
|
|
+ return workTimeDtoList;
|
|
|
+ }
|
|
|
+ Date now = DateUtil.beginOfDay(new Date());
|
|
|
+ Date updateTime = new Date();
|
|
|
+ final List<SysWorkTime> collect = workTimeDtoList.stream().filter(w -> ObjectUtil.isNotNull(w.getIsEnable()) && w.getYmdDate().compareTo(now) > 0).collect(Collectors.toList());
|
|
|
+ final List<Date> dateList = workTimeDtoList.stream().map(SysWorkTime::getYmdDate).distinct().collect(Collectors.toList());
|
|
|
+ final int delete = baseMapper.delete(new LambdaQueryWrapper<SysWorkTime>().in(SysWorkTime::getOrgId, orgIdList).in(SysWorkTime::getYmdDate, dateList));
|
|
|
+ List<SysWorkTime> list = new ArrayList<>();
|
|
|
+ SysWorkTime workTime=null;
|
|
|
+ for (Long orgId : orgIdList) {
|
|
|
+ for (SysWorkTime s : collect) {
|
|
|
+ workTime=new SysWorkTime();
|
|
|
+ BeanUtils.copyProperties(s,workTime);
|
|
|
+ workTime.setId(String.valueOf(IdWorker.getId()));
|
|
|
+ workTime.setOrgId(orgId);
|
|
|
+ workTime.setIsManual(1L);
|
|
|
+ workTime.setUpdateTime(updateTime);
|
|
|
+ workTime.setModifiedId(SecurityUtils.getUserId());
|
|
|
+ workTime.setModifiedName(SecurityUtils.getUsername());
|
|
|
+ list.add(workTime);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ final int i = baseMapper.batchInsertByXML(list);
|
|
|
+ return workTimeDtoList;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public boolean existByYmd(Long orgId, Ymd ymd, boolean isEnable) {
|
|
|
QueryWrapper<SysWorkTime> queryWrapper = new QueryWrapper<>();
|
|
|
if (ymd.getDay() != null) {
|
|
|
@@ -470,7 +489,7 @@ public class SysWorkTimeServiceImpl extends ServiceImpl<SysWorkTimeMapper, SysWo
|
|
|
.ge(SysWorkTime::getYmdDate, workTimeDto.getStartTime())
|
|
|
.le(SysWorkTime::getYmdDate, workTimeDto.getEndTime())
|
|
|
.in(SysWorkTime::getOrgId, workTimeDto.getOrgIdList())
|
|
|
- .eq(SysWorkTime::getIsEnable,1L)
|
|
|
+ .eq(SysWorkTime::getIsEnable, 1L)
|
|
|
.select(SysWorkTime::getId,
|
|
|
SysWorkTime::getIsEnable,
|
|
|
SysWorkTime::getYmdDate,
|