|
@@ -1,21 +1,35 @@
|
|
package com.qmth.sop.business.service.impl;
|
|
package com.qmth.sop.business.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.qmth.boot.api.exception.ApiException;
|
|
import com.qmth.sop.business.entity.SysDingDate;
|
|
import com.qmth.sop.business.entity.SysDingDate;
|
|
|
|
+import com.qmth.sop.business.entity.SysUser;
|
|
import com.qmth.sop.business.mapper.SysDingDateMapper;
|
|
import com.qmth.sop.business.mapper.SysDingDateMapper;
|
|
import com.qmth.sop.business.service.SysDingDateService;
|
|
import com.qmth.sop.business.service.SysDingDateService;
|
|
|
|
+import com.qmth.sop.common.contant.SystemConstant;
|
|
import com.qmth.sop.common.enums.DingDateTypeEnum;
|
|
import com.qmth.sop.common.enums.DingDateTypeEnum;
|
|
|
|
+import com.qmth.sop.common.enums.ExceptionResultEnum;
|
|
|
|
+import com.qmth.sop.common.enums.FieldUniqueEnum;
|
|
|
|
+import com.qmth.sop.common.util.ResultUtil;
|
|
|
|
+import com.qmth.sop.common.util.ServletUtil;
|
|
|
|
+import org.springframework.dao.DuplicateKeyException;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
import java.time.DayOfWeek;
|
|
import java.time.DayOfWeek;
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.Map;
|
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 考勤特殊日期 服务实现.
|
|
* 考勤特殊日期 服务实现.
|
|
*
|
|
*
|
|
* @author: shudonghui
|
|
* @author: shudonghui
|
|
- * @date: 2023-08-10 13:52:06
|
|
|
|
|
|
+ * @date: 2023-08-15 10:03:13
|
|
* @version: 1.0
|
|
* @version: 1.0
|
|
* @email: shudonghui@qmth.com.cn
|
|
* @email: shudonghui@qmth.com.cn
|
|
* @Company: www.qmth.com.cn
|
|
* @Company: www.qmth.com.cn
|
|
@@ -24,6 +38,59 @@ import java.time.LocalDate;
|
|
public class SysDingDateServiceImpl extends ServiceImpl<SysDingDateMapper, SysDingDate> implements SysDingDateService {
|
|
public class SysDingDateServiceImpl extends ServiceImpl<SysDingDateMapper, SysDingDate> implements SysDingDateService {
|
|
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 查询列表
|
|
|
|
+ *
|
|
|
|
+ * @param iPage
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public IPage<SysDingDate> query(IPage<Map> iPage, String query) {
|
|
|
|
+ return this.baseMapper.query(iPage, query);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 新增修改考勤特殊日期
|
|
|
|
+ *
|
|
|
|
+ * @param sysDingDate
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ @Transactional
|
|
|
|
+ public Boolean saveSysDingDate(SysDingDate sysDingDate) {
|
|
|
|
+ try {
|
|
|
|
+ SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
|
+ if (Objects.isNull(sysDingDate.getId())) {// 新增
|
|
|
|
+ //sysDingDate.insertInfo(sysUser.getId());
|
|
|
|
+ } else { // 修改
|
|
|
|
+ //sysDingDate.updateInfo(sysUser.getId());
|
|
|
|
+ }
|
|
|
|
+ return saveOrUpdate(sysDingDate);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ if (e instanceof DuplicateKeyException) {
|
|
|
|
+ String errorColumn = e.getCause().toString();
|
|
|
|
+ String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3, errorColumn.length()).replaceAll("'", "");
|
|
|
|
+ throw ExceptionResultEnum.SQL_ERROR.exception("[" + FieldUniqueEnum.convertToTitle(columnStr) + "]数据不允许重复插入");
|
|
|
|
+ } else if (e instanceof ApiException) {
|
|
|
|
+ ResultUtil.error((ApiException) e, e.getMessage());
|
|
|
|
+ } else {
|
|
|
|
+ ResultUtil.error(e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 删除考勤特殊日期
|
|
|
|
+ *
|
|
|
|
+ * @param id
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ @Transactional
|
|
|
|
+ public Boolean delete(Long id) {
|
|
|
|
+ return this.removeById(id);
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public DingDateTypeEnum getDingDateType(LocalDate date) {
|
|
public DingDateTypeEnum getDingDateType(LocalDate date) {
|
|
SysDingDate sysDingDate = this.getOne(new QueryWrapper<SysDingDate>().lambda().eq(SysDingDate::getYear, date.getYear()).eq(SysDingDate::getMonth, date.getMonthValue()).eq(SysDingDate::getDay, date.getDayOfMonth()));
|
|
SysDingDate sysDingDate = this.getOne(new QueryWrapper<SysDingDate>().lambda().eq(SysDingDate::getYear, date.getYear()).eq(SysDingDate::getMonth, date.getMonthValue()).eq(SysDingDate::getDay, date.getDayOfMonth()));
|
|
@@ -35,4 +102,5 @@ public class SysDingDateServiceImpl extends ServiceImpl<SysDingDateMapper, SysDi
|
|
return DingDateTypeEnum.WEEKEND;
|
|
return DingDateTypeEnum.WEEKEND;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|