|
@@ -1,11 +1,22 @@
|
|
package com.yh.saas.plugin.yiliangyiyun.service.impl;
|
|
package com.yh.saas.plugin.yiliangyiyun.service.impl;
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.plugins.Page;
|
|
|
|
+import com.google.common.collect.Lists;
|
|
|
|
+import com.winsea.svc.base.security.util.AuthSecurityUtils;
|
|
|
|
+import com.yh.saas.common.support.util.IdGenerator;
|
|
|
|
+import com.yh.saas.common.support.util.StringUtils;
|
|
import com.yh.saas.plugin.yiliangyiyun.entity.ClockInfo;
|
|
import com.yh.saas.plugin.yiliangyiyun.entity.ClockInfo;
|
|
import com.yh.saas.plugin.yiliangyiyun.mapper.ClockInfoMapper;
|
|
import com.yh.saas.plugin.yiliangyiyun.mapper.ClockInfoMapper;
|
|
import com.yh.saas.plugin.yiliangyiyun.service.IClockInfoService;
|
|
import com.yh.saas.plugin.yiliangyiyun.service.IClockInfoService;
|
|
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
|
+import java.time.LocalDate;
|
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
|
+import java.util.*;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
* 记录打卡信息 服务实现类
|
|
* 记录打卡信息 服务实现类
|
|
@@ -17,4 +28,130 @@ import org.springframework.stereotype.Service;
|
|
@Service
|
|
@Service
|
|
public class ClockInfoServiceImpl extends ServiceImpl<ClockInfoMapper, ClockInfo> implements IClockInfoService {
|
|
public class ClockInfoServiceImpl extends ServiceImpl<ClockInfoMapper, ClockInfo> implements IClockInfoService {
|
|
|
|
|
|
-}
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 添加打卡信息
|
|
|
|
+ *
|
|
|
|
+ * @param clockInfo
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public String addClock(ClockInfo clockInfo) {
|
|
|
|
+ //当天零点
|
|
|
|
+ SimpleDateFormat now = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
|
|
|
|
+ Calendar a = Calendar.getInstance();
|
|
|
|
+ a.setTime(new Date());
|
|
|
|
+ a.add(Calendar.YEAR, 0);
|
|
|
|
+ Date x = a.getTime();
|
|
|
|
+ String timeOfDay = now.format(x);
|
|
|
|
+ //早八
|
|
|
|
+ SimpleDateFormat eight = new SimpleDateFormat("yyyy-MM-dd 08:00:00");
|
|
|
|
+ Calendar b = Calendar.getInstance();
|
|
|
|
+ b.setTime(new Date());
|
|
|
|
+ b.add(Calendar.YEAR, 0);
|
|
|
|
+ Date y = b.getTime();
|
|
|
|
+ String timeOfEight = eight.format(y);
|
|
|
|
+ //晚五
|
|
|
|
+ SimpleDateFormat five = new SimpleDateFormat("yyyy-MM-dd 17:00:00");
|
|
|
|
+ Calendar c = Calendar.getInstance();
|
|
|
|
+ c.setTime(new Date());
|
|
|
|
+ c.add(Calendar.YEAR, 0);
|
|
|
|
+ Date z = c.getTime();
|
|
|
|
+ String timeOfFive = five.format(z);
|
|
|
|
+ //获取当前系统时间
|
|
|
|
+ Date date = new Date();
|
|
|
|
+ SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
+ String currentTime = s.format(date);
|
|
|
|
+ //查询打卡信息
|
|
|
|
+ ClockInfo clockInfo1 = this.selectOne(new EntityWrapper<ClockInfo>()
|
|
|
|
+ .eq("comp_id", clockInfo.getCompId())
|
|
|
|
+ .eq("common_id", clockInfo.getCommonId())
|
|
|
|
+ .gt("create_date", timeOfDay));
|
|
|
|
+ //信息不为空,下班打卡
|
|
|
|
+ if (clockInfo1 != null) {
|
|
|
|
+ if (timeOfFive.compareTo(currentTime) > 0) {
|
|
|
|
+ //早退
|
|
|
|
+ clockInfo1.setLeaveEarlyFlag("1");
|
|
|
|
+ }
|
|
|
|
+ clockInfo1.setOffClockDate(date);
|
|
|
|
+ //更新主表数据
|
|
|
|
+ this.updateById(clockInfo1);
|
|
|
|
+ }
|
|
|
|
+ //信息为空
|
|
|
|
+ else {
|
|
|
|
+ clockInfo.setId(IdGenerator.generateUUID());
|
|
|
|
+ //下班打卡
|
|
|
|
+ if ("3".equals(clockInfo.getClockType())) {
|
|
|
|
+ if (timeOfFive.compareTo(currentTime) > 0) {
|
|
|
|
+ //早退
|
|
|
|
+ clockInfo.setLeaveEarlyFlag("1");
|
|
|
|
+ }
|
|
|
|
+ clockInfo.setOffClockDate(date);
|
|
|
|
+ }
|
|
|
|
+ //上班打卡
|
|
|
|
+ else {
|
|
|
|
+ if (currentTime.compareTo(timeOfEight) > 0) {
|
|
|
|
+ //迟到
|
|
|
|
+ clockInfo.setLateFlag("1");
|
|
|
|
+ }
|
|
|
|
+ clockInfo.setToClockDate(date);
|
|
|
|
+ }
|
|
|
|
+ //操作主表数据
|
|
|
|
+ this.insert(clockInfo);
|
|
|
|
+ }
|
|
|
|
+ return "OK";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 打卡记录
|
|
|
|
+ *
|
|
|
|
+ * @param clockInfo
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public Page<ClockInfo> selectClockInfo(ClockInfo clockInfo) {
|
|
|
|
+ Map<String, Object> pageView = new HashMap<>();
|
|
|
|
+ pageView.put("startRecord", (clockInfo.getCurrentPage() - 1)
|
|
|
|
+ * clockInfo.getPageSize());
|
|
|
|
+ // 公司ID
|
|
|
|
+ pageView.put("compId", clockInfo.getCompId());
|
|
|
|
+ pageView.put("commonId", clockInfo.getCommonId());
|
|
|
|
+ pageView.put("pageSize", clockInfo.getPageSize());
|
|
|
|
+ pageView.put("currentPage", clockInfo.getCurrentPage());
|
|
|
|
+ // 查询总数
|
|
|
|
+ Integer dataCount = baseMapper.getCountByCondition(pageView);
|
|
|
|
+ List<ClockInfo> dataList = baseMapper.getListByCondition(pageView);
|
|
|
|
+ Page<ClockInfo> page = new Page<>();
|
|
|
|
+ page.setRecords(dataList == null ? Lists.newArrayList() : dataList);
|
|
|
|
+ page.setTotal(dataCount == null ? 0 : dataCount);
|
|
|
|
+ page.setCurrent(clockInfo.getCurrentPage());
|
|
|
|
+ page.setSize(clockInfo.getPageSize());
|
|
|
|
+ return page;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 添加补卡信息
|
|
|
|
+ *
|
|
|
|
+ * @param clockInfo
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public String suppClock(ClockInfo clockInfo) {
|
|
|
|
+ //当天零点
|
|
|
|
+ SimpleDateFormat zero = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
|
|
|
|
+ Calendar d = Calendar.getInstance();
|
|
|
|
+ d.setTime(new Date());
|
|
|
|
+ d.add(Calendar.YEAR, 0);
|
|
|
|
+ Date n = d.getTime();
|
|
|
|
+ String zeroOfDay = zero.format(n);
|
|
|
|
+ //查询打卡信息
|
|
|
|
+ ClockInfo clockInfo1 = this.selectOne(new EntityWrapper<ClockInfo>()
|
|
|
|
+ .eq("common_id", clockInfo.getCommonId())
|
|
|
|
+ .gt("create_date",zeroOfDay));
|
|
|
|
+ if (clockInfo1 != null) {
|
|
|
|
+ clockInfo1.setSupplementClockType(clockInfo.getSupplementClockType());
|
|
|
|
+ clockInfo1.setReasonForApplication(clockInfo.getReasonForApplication());
|
|
|
|
+ this.updateById(clockInfo1);
|
|
|
|
+ }
|
|
|
|
+ return "OK";
|
|
|
|
+ }
|
|
|
|
+}
|