Commit 7e3a86fe by baochunxin

#G:加班代码提交

parent 6207d955
...@@ -232,9 +232,14 @@ public class SchoolAttController extends BaseController { ...@@ -232,9 +232,14 @@ public class SchoolAttController extends BaseController {
schoolAttService.checkImport(list); schoolAttService.checkImport(list);
//处理数据 //处理数据
List<SchoolAtt> attList = schoolAttService.dealData(list); List<SchoolAtt> attList = schoolAttService.dealData(list);
//验证是否迟到早退
List<SchoolAtt> attLists = schoolAttService.verifyLateness(attList);
//数据导入 //数据导入
String message = schoolAttService.importData(attList); // String message = schoolAttService.importData(attLists);
return AjaxResult.success(message); boolean b = schoolAttService.saveBatch(attLists);
return AjaxResult.success(b);
} }
......
...@@ -46,5 +46,10 @@ public class SchoolAtt extends OurBaseEntity { ...@@ -46,5 +46,10 @@ public class SchoolAtt extends OurBaseEntity {
@Excel(name = "打卡时间") @Excel(name = "打卡时间")
private String clockTime; private String clockTime;
/**
* 迟到 早退
*/
private String workStatus;
private String remark; private String remark;
} }
package yangtz.cs.liu.campus.domain.workTimes;
import java.util.Date;
import lombok.Data;
/**
* 考勤时间
*/
@Data
public class WorkTime {
/**
* 上午开始时间
*/
private Date amStartTime;
/**
* 上午结束时间
*/
private Date amEndTime;
/**
* 下午开始时间
*/
private Date pmStartTime;
/**
* 下午结束时间
*/
private Date pmEndTime;
/**
* 上午工作迟到时间点
*/
private Date amLateTime;
/**
* 下午打卡时间开始点
*/
private Date pmMiddleTime;
/**
* 下午工作迟到时间点
*/
private Date pmLateTime;
}
package yangtz.cs.liu.campus.mapper.WorkTimes;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import yangtz.cs.liu.campus.domain.schoolAtt.SchoolAtt;
import yangtz.cs.liu.campus.domain.workTimes.WorkTime;
/**
* 考勤打卡时间
*/
@Mapper
public interface WorkTimeMapper extends BaseMapper<WorkTime> {
}
package yangtz.cs.liu.campus.service.impl.schoolAtt; package yangtz.cs.liu.campus.service.impl.schoolAtt;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
...@@ -10,6 +11,7 @@ import com.ruoyi.common.exception.ServiceException; ...@@ -10,6 +11,7 @@ import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.bean.BeanUtils; import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.system.mapper.SysDeptMapper; import com.ruoyi.system.mapper.SysDeptMapper;
import java.text.SimpleDateFormat;
import lombok.Data; import lombok.Data;
import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -19,10 +21,13 @@ import yangtz.cs.liu.campus.domain.schoolAtt.SchoolAtt; ...@@ -19,10 +21,13 @@ import yangtz.cs.liu.campus.domain.schoolAtt.SchoolAtt;
import yangtz.cs.liu.campus.domain.schoolClass.SchoolClass; import yangtz.cs.liu.campus.domain.schoolClass.SchoolClass;
import yangtz.cs.liu.campus.domain.schoolgrade.SchoolGrade; import yangtz.cs.liu.campus.domain.schoolgrade.SchoolGrade;
import yangtz.cs.liu.campus.domain.student.SchoolStudent; import yangtz.cs.liu.campus.domain.student.SchoolStudent;
import yangtz.cs.liu.campus.domain.workTimes.WorkTime;
import yangtz.cs.liu.campus.mapper.WorkTimes.WorkTimeMapper;
import yangtz.cs.liu.campus.mapper.schoolAtt.SchoolAttMapper; import yangtz.cs.liu.campus.mapper.schoolAtt.SchoolAttMapper;
import yangtz.cs.liu.campus.mapper.schoolgrade.SchoolGradeMapper; import yangtz.cs.liu.campus.mapper.schoolgrade.SchoolGradeMapper;
import yangtz.cs.liu.campus.mapper.teacher.SchoolTeacherMapper; import yangtz.cs.liu.campus.mapper.teacher.SchoolTeacherMapper;
import yangtz.cs.liu.campus.service.schoolAtt.ISchoolAttService; import yangtz.cs.liu.campus.service.schoolAtt.ISchoolAttService;
import yangtz.cs.liu.campus.service.workDay.ISchoolWorkDayService;
import yangtz.cs.liu.campus.vo.schoolAtt.SchoolAttVO; import yangtz.cs.liu.campus.vo.schoolAtt.SchoolAttVO;
import yangtz.cs.liu.campus.vo.student.SchoolStudentVO; import yangtz.cs.liu.campus.vo.student.SchoolStudentVO;
import yangtz.cs.liu.campus.vo.teacher.SchoolTeacherDutyVO; import yangtz.cs.liu.campus.vo.teacher.SchoolTeacherDutyVO;
...@@ -53,6 +58,10 @@ public class SchoolAttServiceImpl extends ServiceImpl<SchoolAttMapper, SchoolAtt ...@@ -53,6 +58,10 @@ public class SchoolAttServiceImpl extends ServiceImpl<SchoolAttMapper, SchoolAtt
@Autowired @Autowired
private SysDeptMapper deptMapper; private SysDeptMapper deptMapper;
@Autowired
private WorkTimeMapper workTimeMapper;
@Autowired
private ISchoolWorkDayService dayService;
DateFormat df = DateFormat.getTimeInstance();//只显示出时分秒 DateFormat df = DateFormat.getTimeInstance();//只显示出时分秒
...@@ -378,6 +387,120 @@ public class SchoolAttServiceImpl extends ServiceImpl<SchoolAttMapper, SchoolAtt ...@@ -378,6 +387,120 @@ public class SchoolAttServiceImpl extends ServiceImpl<SchoolAttMapper, SchoolAtt
} }
/** /**
* 验证是否迟到、早退
* @param list
* @return
*/
@Override
public List<SchoolAtt> verifyLateness(List<SchoolAtt> list) throws Exception {
List<SchoolAtt> handUserAttList = new ArrayList<>();
String codeUser = null;
//当前年月份内获取周末、节假日日期
for (SchoolAtt data :list) {
List<SchoolAtt> attUserList = new ArrayList<>();
//将对每个人信息信息处理
if (codeUser!=null && data.getTeacherCode().equals(codeUser)){
continue;
}
for (SchoolAtt times :list) {
if (data.getTeacherCode().equals(times.getTeacherCode()) && (0 == data.getClockDate().compareTo(times.getClockDate()))){
codeUser =times.getTeacherCode();
attUserList.add(times);
}
}
//处理个人时间信息
this.handleAttList(attUserList);
//存储到新得List中
handUserAttList.addAll(attUserList);
}
return handUserAttList;
}
private void handleAttList(List<SchoolAtt> list) throws Exception {
//迟到
Boolean beLateFlag = false;
//早上是否有过第一次打卡
Boolean amFlag = false;
//下午第一次打卡
Boolean pmFlag = false;
//获取时间段
List<WorkTime> workTimes = workTimeMapper.selectList(new LambdaQueryWrapper<WorkTime>());
WorkTime workTime = workTimes.get(0);
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
Date parse = sdf.parse("5:00");
//上午打卡起始世界
Calendar parseCal = Calendar.getInstance();
parseCal.setTime(parse);
//上午开始时间
Calendar amStartIime = Calendar.getInstance();
amStartIime.setTime(workTime.getAmStartTime());
//上午结束时间
Calendar amEndTime = Calendar.getInstance();
amEndTime.setTime(workTime.getAmEndTime());
//上午工作迟到时间点
Calendar amLateTime = Calendar.getInstance();
amLateTime.setTime(workTime.getAmLateTime());
//下午开始时间
Calendar pmStartTime = Calendar.getInstance();
pmStartTime.setTime(workTime.getPmStartTime());
//下午结束时间
Calendar pmEndtTime = Calendar.getInstance();
pmEndtTime.setTime(workTime.getPmEndTime());
//下午打卡时间开始点
Calendar pmMiddleTime = Calendar.getInstance();
pmMiddleTime.setTime(workTime.getPmMiddleTime());
//下午工作迟到时间点
Calendar pmLateTime = Calendar.getInstance();
pmLateTime.setTime(workTime.getPmLateTime());
//当前打卡世界
Calendar clockTime = Calendar.getInstance();
List<String> restList = dayService.getHolidayList("1");
//判断每个人的打卡时间
for (SchoolAtt data: list){
clockTime.setTime(sdf.parse(data.getClockTime()));
//0判断当前是否是工作日
if ("0".equals(HolidayDateUtil.isLawHoliday(data.getClockDate().toString(),restList))){
//判断时间端在早上5到 早上第一个打卡时间内
if (clockTime.after(parseCal) && clockTime.before(amStartIime)){
amFlag = true;
}else if (clockTime.after(amStartIime) && clockTime.before(amLateTime)){
//打卡时间在7.30到9.0之前判断是否有过第一次打卡,没有则迟到,有无效
if (!amFlag){
data.setWorkStatus("迟到");
continue;
}
} else if (clockTime.after(amLateTime) && clockTime.before(amEndTime) ) {
//打卡时间在迟到时间到到下班时间点打卡 就是早退
data.setWorkStatus("早退");
continue;
} else if (clockTime.after(pmMiddleTime) && clockTime.before(pmStartTime)) {
//1点到 下午打卡开始时间
pmFlag = true;
} else if (clockTime.after(pmStartTime) && clockTime.before(pmLateTime)) {
//下午开始时间到迟到时间
if (!pmFlag){
data.setWorkStatus("迟到");
continue;
}
} else if (clockTime.after(pmLateTime) && clockTime.before(pmEndtTime)) {
//下午卡点时间 到下班时间
data.setWorkStatus("早退");
continue;
}
}
}
}
/**
* 导入数据 * 导入数据
* */ * */
@Override @Override
......
...@@ -42,5 +42,20 @@ public class SchoolWorkDayServiceImpl extends ServiceImpl<SchoolWorkDayMapper, S ...@@ -42,5 +42,20 @@ public class SchoolWorkDayServiceImpl extends ServiceImpl<SchoolWorkDayMapper, S
} }
return list; return list;
} }
public List<String> getHolidayList(String type) {
LambdaQueryWrapper<SchoolWorkDay> lqw = new LambdaQueryWrapper<>();
lqw
.eq(isNotBlank(type),SchoolWorkDay::getDateType,type)
;
List<SchoolWorkDay> days = dayMapper.selectList(lqw);
if (StringUtils.isNull(days)){
return new ArrayList<>();
}
List<String> list = new ArrayList<>();
for(SchoolWorkDay day : days){
String time = HolidayDateUtil.format1.format( day.getRepDate());
list.add(time);
}
return list;
}
} }
...@@ -33,6 +33,9 @@ public interface ISchoolAttService extends IService<SchoolAtt> { ...@@ -33,6 +33,9 @@ public interface ISchoolAttService extends IService<SchoolAtt> {
* */ * */
List<SchoolAtt> dealData(List<SchoolAttVO> list); List<SchoolAtt> dealData(List<SchoolAttVO> list);
List<SchoolAtt> verifyLateness( List<SchoolAtt> list) throws Exception;
/** /**
* 导入数据 * 导入数据
* @param list * @param list
......
...@@ -10,4 +10,5 @@ public interface ISchoolWorkDayService extends IService<SchoolWorkDay> { ...@@ -10,4 +10,5 @@ public interface ISchoolWorkDayService extends IService<SchoolWorkDay> {
//获取区间内休息日 //获取区间内休息日
List<String> getHolidayList(Date startTime, Date endTime, String type); List<String> getHolidayList(Date startTime, Date endTime, String type);
List<String> getHolidayList(String type);
} }
...@@ -331,14 +331,14 @@ public class WxApiController extends BaseController { ...@@ -331,14 +331,14 @@ public class WxApiController extends BaseController {
String token = accessTokenUtil.getToken(); String token = accessTokenUtil.getToken();
//获取jsapi_ticket //获取jsapi_ticket
String ticket = null; String ticket = null;
//ticket = redisCache.getCacheObject("ticket"); ticket = redisCache.getCacheObject("ticket");
if (StringUtils.isEmpty(ticket)){ if (StringUtils.isEmpty(ticket)){
String ticketss = HttpUtils.sendGet( String ticketss = HttpUtils.sendGet(
"https://api.weixin.qq.com/cgi-bin/ticket/getticket?" + "access_token=" + token "https://api.weixin.qq.com/cgi-bin/ticket/getticket?" + "access_token=" + token
+ "&type=jsapi"); + "&type=jsapi");
JSONObject jsonObject = JSONUtil.parseObj(ticketss); JSONObject jsonObject = JSONUtil.parseObj(ticketss);
ticket = jsonObject.get("ticket").toString(); ticket = jsonObject.get("ticket").toString();
// redisCache.setCacheObject("ticket", ticket, 5, TimeUnit.MINUTES); redisCache.setCacheObject("ticket", ticket, 90, TimeUnit.MINUTES);
} }
//生成JS-SDK权限验证的签名 //生成JS-SDK权限验证的签名
String noncester = create_nonce_str(); String noncester = create_nonce_str();
...@@ -597,12 +597,12 @@ public class WxApiController extends BaseController { ...@@ -597,12 +597,12 @@ public class WxApiController extends BaseController {
// 微信公众平台 // 微信公众平台
String url = "https://open.weixin.qq.com/connect/oauth2/authorize?" String url = "https://open.weixin.qq.com/connect/oauth2/authorize?"
+ "appid=" + "appid="
+ appid + "wx765a55464b308d13"
+ "&redirect_uri=" + "&redirect_uri="
+ redirectUri + redirectUri
+ "&response_type=code" + "&response_type=code"
+ "&scope=" + "&scope="
+ scope + "aa6741b17f05203975b17f0a64458741"
+ "&state=" + state + "#wechat_redirect"; + "&state=" + state + "#wechat_redirect";
// response.sendRedirect(url); // response.sendRedirect(url);
return "redirect:" + url; return "redirect:" + url;
......
...@@ -38,8 +38,7 @@ public class AccessTokenUtil { ...@@ -38,8 +38,7 @@ public class AccessTokenUtil {
public RedisCache redisCache; public RedisCache redisCache;
public String getToken() { public String getToken() {
// String token = redisCache.getCacheObject(ACCESS_TOKEN); String token = redisCache.getCacheObject(ACCESS_TOKEN);
String token = null;
if (StringUtils.isEmpty(token)) { if (StringUtils.isEmpty(token)) {
try { try {
String url = accessTokenUri; String url = accessTokenUri;
...@@ -55,7 +54,7 @@ public class AccessTokenUtil { ...@@ -55,7 +54,7 @@ public class AccessTokenUtil {
token = accessToken; token = accessToken;
log.info(accessToken); log.info(accessToken);
// 将access_token存入redis // 将access_token存入redis
// redisCache.setCacheObject("access_token", accessToken, 5, TimeUnit.MINUTES); redisCache.setCacheObject("access_token", accessToken, 90, TimeUnit.MINUTES);
} }
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
......
...@@ -12,13 +12,14 @@ ...@@ -12,13 +12,14 @@
<result property="orgname" column="orgname" /> <result property="orgname" column="orgname" />
<result property="clockDate" column="clock_date" /> <result property="clockDate" column="clock_date" />
<result property="clockTime" column="clock_time" /> <result property="clockTime" column="clock_time" />
<result property="workStatus" column="work_status" />
<result property="createBy" column="create_by" /> <result property="createBy" column="create_by" />
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time" />
<result property="remark" column="remark" /> <result property="remark" column="remark" />
</resultMap> </resultMap>
<sql id="selectSchoolAttVo"> <sql id="selectSchoolAttVo">
select id, device_num, teacher_code, user_id, user_name, user_type, orgid, orgname, clock_date, clock_time, create_by, create_time, remark from school_att select id, device_num, teacher_code, user_id, user_name, work_status,user_type, orgid, orgname, clock_date, clock_time, create_by, create_time, remark from school_att
</sql> </sql>
<select id="selectSchoolAttList" parameterType="SchoolAtt" resultMap="SchoolAttResult"> <select id="selectSchoolAttList" parameterType="SchoolAtt" resultMap="SchoolAttResult">
...@@ -42,8 +43,7 @@ ...@@ -42,8 +43,7 @@
</select> </select>
<select id="queryList" parameterType="yangtz.cs.liu.campus.domain.schoolAtt.SchoolAtt" resultMap="SchoolAttResult"> <select id="queryList" parameterType="yangtz.cs.liu.campus.domain.schoolAtt.SchoolAtt" resultMap="SchoolAttResult">
select id, device_num, teacher_code, user_id, user_name, user_type, orgid, orgname, clock_date, GROUP_CONCAT(clock_time) as clock_time, create_by, create_time, remark from school_att select id, device_num, teacher_code, user_id, user_name, user_type, orgid, orgname, clock_date, GROUP_CONCAT(clock_time,IF(ISNULL(work_status),"","("),IF(ISNULL(work_status),"",work_status),IF(ISNULL(work_status),"",")") )as clock_time, create_by, create_time, remark from school_att <where>
<where>
del_flag = '0' del_flag = '0'
<if test="deviceNum != null and deviceNum != ''"> and device_num = #{deviceNum}</if> <if test="deviceNum != null and deviceNum != ''"> and device_num = #{deviceNum}</if>
<if test="teacherCode != null and teacherCode != ''"> and teacher_code = #{teacherCode}</if> <if test="teacherCode != null and teacherCode != ''"> and teacher_code = #{teacherCode}</if>
...@@ -64,8 +64,7 @@ ...@@ -64,8 +64,7 @@
</select> </select>
<select id="queryGradeList" parameterType="yangtz.cs.liu.campus.domain.schoolAtt.SchoolAtt" resultMap="SchoolAttResult"> <select id="queryGradeList" parameterType="yangtz.cs.liu.campus.domain.schoolAtt.SchoolAtt" resultMap="SchoolAttResult">
select id, device_num, teacher_code, user_id, user_name, user_type, orgid, orgname, clock_date, GROUP_CONCAT(clock_time) as clock_time, create_by, create_time, remark from school_att select id, device_num, teacher_code, user_id, user_name, user_type, orgid, orgname, clock_date, GROUP_CONCAT(clock_time,IF(ISNULL(work_status),"","("),IF(ISNULL(work_status),"",work_status),IF(ISNULL(work_status),"",")") )as clock_time, create_by, create_time, remark from school_att <where>
<where>
del_flag = '0' del_flag = '0'
<if test="entity.userName != null and entity.userName != ''"> and user_name like concat('%', #{entity.userName}, '%')</if> <if test="entity.userName != null and entity.userName != ''"> and user_name like concat('%', #{entity.userName}, '%')</if>
<if test="gradeIds != null and gradeIds.size() > 0"> <if test="gradeIds != null and gradeIds.size() > 0">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment