src/main/java/org/springblade/flow/demo/leave/controller/LeaveController.java
File was deleted src/main/java/org/springblade/flow/demo/leave/controller/LeaveTestController.java
New file @@ -0,0 +1,65 @@ ///* // * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. // * // * Redistribution and use in source and binary forms, with or without // * modification, are permitted provided that the following conditions are met: // * // * Redistributions of source code must retain the above copyright notice, // * this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // * notice, this list of conditions and the following disclaimer in the // * documentation and/or other materials provided with the distribution. // * Neither the name of the dreamlu.net developer nor the names of its // * contributors may be used to endorse or promote products derived from // * this software without specific prior written permission. // * Author: Chill 庄骞 (smallchill@163.com) // */ //package org.springblade.flow.demo.leave.controller; // //import lombok.AllArgsConstructor; //import org.springblade.common.cache.UserCache; //import org.springblade.core.launch.constant.AppConstant; //import org.springblade.core.tenant.annotation.NonDS; //import org.springblade.core.tool.api.R; //import org.springblade.flow.demo.leave.entity.ProcessLeave; //import org.springblade.flow.demo.leave.service.ILeaveService; //import org.springframework.web.bind.annotation.*; //import springfox.documentation.annotations.ApiIgnore; // ///** // * 控制器 // * // * @author Chill // */ //@NonDS //@ApiIgnore //@RestController //@RequestMapping(AppConstant.APPLICATION_DESK_NAME + "/process/leave") //@AllArgsConstructor //public class LeaveController { // // private final ILeaveService leaveService; // // /** // * 详情 // * // * @param businessId 主键 // */ // @GetMapping("detail") // public R<ProcessLeave> detail(Long businessId) { // ProcessLeave detail = leaveService.getById(businessId); // detail.getFlow().setAssigneeName(UserCache.getUser(detail.getCreateUser()).getName()); // return R.data(detail); // } // // /** // * 新增或修改 // * // * @param leave 请假信息 // */ // @PostMapping("start-process") // public R startProcess(@RequestBody ProcessLeave leave) { // return R.status(leaveService.startProcess(leave)); // } // //} src/main/java/org/springblade/flow/demo/leave/mapper/LeaveTestMapper.java
File was renamed from src/main/java/org/springblade/flow/demo/leave/mapper/LeaveMapper.java @@ -17,13 +17,13 @@ package org.springblade.flow.demo.leave.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.springblade.flow.demo.leave.entity.ProcessLeave; import org.springblade.flow.demo.leave.entity.*; /** * Mapper 接口 * * @author Chill */ public interface LeaveMapper extends BaseMapper<ProcessLeave> { public interface LeaveTestMapper extends BaseMapper<ProcessLeave> { } src/main/java/org/springblade/flow/demo/leave/mapper/LeaveTestMapper.xml
File was renamed from src/main/java/org/springblade/flow/demo/leave/mapper/LeaveMapper.xml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="org.springblade.flow.demo.leave.mapper.LeaveMapper"> <mapper namespace="org.springblade.flow.demo.leave.mapper.LeaveTestMapper"> </mapper> src/main/java/org/springblade/flow/demo/leave/service/ILeaveService.java
@@ -1,37 +1,37 @@ /* * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the dreamlu.net developer nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * Author: Chill 庄骞 (smallchill@163.com) */ package org.springblade.flow.demo.leave.service; import org.springblade.core.mp.base.BaseService; import org.springblade.flow.demo.leave.entity.ProcessLeave; /** * 服务类 * * @author Chill */ public interface ILeaveService extends BaseService<ProcessLeave> { /** * 开启流程 * * @param leave 请假实体 * @return boolean */ boolean startProcess(ProcessLeave leave); } ///* // * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. // * // * Redistribution and use in source and binary forms, with or without // * modification, are permitted provided that the following conditions are met: // * // * Redistributions of source code must retain the above copyright notice, // * this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // * notice, this list of conditions and the following disclaimer in the // * documentation and/or other materials provided with the distribution. // * Neither the name of the dreamlu.net developer nor the names of its // * contributors may be used to endorse or promote products derived from // * this software without specific prior written permission. // * Author: Chill 庄骞 (smallchill@163.com) // */ //package org.springblade.flow.demo.leave.service; // //import org.springblade.core.mp.base.BaseService; //import org.springblade.flow.demo.leave.entity.ProcessLeave; // ///** // * 服务类 // * // * @author Chill // */ //public interface ILeaveService extends BaseService<ProcessLeave> { // // /** // * 开启流程 // * // * @param leave 请假实体 // * @return boolean // */ // boolean startProcess(ProcessLeave leave); // //} src/main/java/org/springblade/flow/demo/leave/service/impl/LeaveServiceImpl.java
File was deleted src/main/java/org/springblade/flow/demo/leave/service/impl/LeaveTestServiceImpl.java
New file @@ -0,0 +1,79 @@ ///* // * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. // * // * Redistribution and use in source and binary forms, with or without // * modification, are permitted provided that the following conditions are met: // * // * Redistributions of source code must retain the above copyright notice, // * this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // * notice, this list of conditions and the following disclaimer in the // * documentation and/or other materials provided with the distribution. // * Neither the name of the dreamlu.net developer nor the names of its // * contributors may be used to endorse or promote products derived from // * this software without specific prior written permission. // * Author: Chill 庄骞 (smallchill@163.com) // */ //package org.springblade.flow.demo.leave.service.impl; // //import lombok.AllArgsConstructor; //import lombok.extern.slf4j.Slf4j; //import org.springblade.core.log.exception.ServiceException; //import org.springblade.core.mp.base.BaseServiceImpl; //import org.springblade.core.secure.utils.AuthUtil; //import org.springblade.core.tool.support.Kv; //import org.springblade.core.tool.utils.DateUtil; //import org.springblade.core.tool.utils.Func; //import org.springblade.flow.business.service.IFlowService; //import org.springblade.flow.core.constant.ProcessConstant; //import org.springblade.flow.core.entity.BladeFlow; //import org.springblade.flow.core.utils.FlowUtil; //import org.springblade.flow.core.utils.TaskUtil; //import org.springblade.flow.demo.leave.entity.ProcessLeave; //import org.springblade.flow.demo.leave.mapper.LeaveMapper; //import org.springblade.flow.demo.leave.service.ILeaveService; //import org.springframework.stereotype.Service; //import org.springframework.transaction.annotation.Transactional; // ///** // * 服务实现类 // * // * @author Chill // */ //@Slf4j //@Service //@AllArgsConstructor //public class LeaveServiceImpl extends BaseServiceImpl<LeaveMapper, ProcessLeave> implements ILeaveService { // // private final IFlowService flowService; // // @Override // @Transactional(rollbackFor = Exception.class) // public boolean startProcess(ProcessLeave leave) { // String businessTable = FlowUtil.getBusinessTable(ProcessConstant.LEAVE_KEY); // if (Func.isEmpty(leave.getId())) { // // 保存leave // leave.setApplyTime(DateUtil.now()); // save(leave); // // 启动流程 // Kv variables = Kv.create() // .set(ProcessConstant.TASK_VARIABLE_CREATE_USER, AuthUtil.getUserName()) // .set("taskUser", TaskUtil.getTaskUser(leave.getTaskUser())) // .set("days", DateUtil.between(leave.getStartTime(), leave.getEndTime()).toDays()); // BladeFlow flow = flowService.startProcessInstanceById(leave.getProcessDefinitionId(), FlowUtil.getBusinessKey(businessTable, String.valueOf(leave.getId())), variables); // if (Func.isNotEmpty(flow)) { // log.debug("流程已启动,流程ID:" + flow.getProcessInstanceId()); // // 返回流程id写入leave // leave.setProcessInstanceId(flow.getProcessInstanceId()); // updateById(leave); // } else { // throw new ServiceException("开启流程失败"); // } // } else { // // updateById(leave); // } // return true; // } // //} src/main/java/org/springblade/modules/attendance/controller/AttendanceController.java
New file @@ -0,0 +1,324 @@ package org.springblade.modules.attendance.controller; import com.baomidou.mybatisplus.core.metadata.IPage; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import lombok.AllArgsConstructor; import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.excel.util.ExcelUtil; import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.Func; import org.springblade.modules.attendance.entity.Attendance; import org.springblade.modules.attendance.excel.AttendanceExcel; import org.springblade.modules.attendance.service.IAttendanceService; import org.springblade.modules.attendance.vo.AttendanceVO; import org.springblade.modules.attendance.wrapper.AttendanceWrapper; import org.springblade.modules.system.service.IDictBizService; import org.springblade.modules.system.service.IUserService; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; import java.util.List; /** * 控制器 * * @author BladeX * @since 2021-03-03 */ @RestController @AllArgsConstructor @RequestMapping("/attendance") @Api(value = "", tags = "接口") public class AttendanceController extends BladeController { private final IAttendanceService attendanceService; // private final IEnclosureService iEnclosureService; private final IDictBizService iDictBizService; private final IUserService iUserService; /** * 详情 */ @GetMapping("/detail") @ApiOperationSupport(order = 1) @ApiOperation(value = "详情", notes = "传入attendance") public R<Attendance> detail(Attendance attendance) { Attendance detail = attendanceService.getOne(Condition.getQueryWrapper(attendance)); return R.data(detail); } /** * 分页 */ @GetMapping("/list") @ApiOperationSupport(order = 2) @ApiOperation(value = "分页", notes = "传入attendance") public R<IPage<AttendanceVO>> list(Attendance attendance, Query query) { IPage<Attendance> pages = attendanceService.page(Condition.getPage(query), Condition.getQueryWrapper(attendance)); return R.data(AttendanceWrapper.build().pageVO(pages)); } /** * 自定义分页 */ @GetMapping("/page") @ApiOperationSupport(order = 3) @ApiOperation(value = "分页", notes = "传入attendance") public R<IPage<AttendanceVO>> page(AttendanceVO attendance, Query query, Long department) { IPage<Attendance> pages = attendanceService.selectAttendancePage(Condition.getPage(query), department, attendance); return R.data(AttendanceWrapper.build().pageVO(pages)); } // /** // * 保安位置比对 // */ // @GetMapping("/positionThan") // public R positionThan(@Valid Attendance attendance, HttpServletResponse response) { // response.setHeader("Access-Control-Allow-Origin", "*"); // response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); // response.setHeader("Access-Control-Allow-Credentials", "true"); // Enclosure enclosure = new Enclosure(); // enclosure.setAnumber(attendance.getNumber()); // //查询当前处警人员的电子围栏信息 // Boolean onArea = iEnclosureService.isOnArea(attendance.getJd(),attendance.getWd(),enclosure); // if (onArea){ // return R.data(true); // } // return R.data(false); // } // /** // * 新增 // */ // @PostMapping("/AppSave") // @ApiOperationSupport(order = 4) // @ApiOperation(value = "新增", notes = "传入attendance") // public R AppSave(@Valid Attendance attendance, HttpServletResponse response) { // response.setHeader("Access-Control-Allow-Origin", "*"); // response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); // response.setHeader("Access-Control-Allow-Credentials", "true"); // Enclosure enclosure = new Enclosure(); // enclosure.setAnumber(attendance.getNumber()); // //查询当前处警人员的电子围栏信息 // Boolean onArea = iEnclosureService.isOnArea(attendance.getJd(),attendance.getWd(),enclosure); // //判断是否在所在区域打卡,返回数据 // if (onArea) { // //查询当前考勤人员的部门信息 // attendance.setDepartment(iUserService.selUserByCode(attendance.getNumber()).getDeptId()); // //获取当前日期是礼拜几 // attendance.setWeek(new SimpleDateFormat("EEEE").format(new Date())); // //获取打卡时间标准 // List<DictBiz> dictBizList = iDictBizService.getList("attendanceStandard"); // //定义打卡时间标准,上午,下午 // StringBuilder forenoon = new StringBuilder(); // StringBuilder afternoon = new StringBuilder(); // String format = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); // for (DictBiz dictBiz : dictBizList) { // if (dictBiz.getDictValue().contains("上午")) { // forenoon = forenoon.append(dictBiz.getDictKey()); // } // if (dictBiz.getDictValue().contains("下午")) { // afternoon = afternoon.append(dictBiz.getDictKey()); // } // } // //上午打卡时间标准 // String forenoonWorkTime = format + " " + forenoon.toString().split("-")[0] + ":00"; // String forenoonOfDutyTime = format + " " + forenoon.toString().split("-")[1] + ":00"; // //下午打卡时间标准 // String afternoonWorkTime = format + " " + afternoon.toString().split("-")[0] + ":00"; // String afternoonOfDutyTime = format + " " + afternoon.toString().split("-")[1] + ":00"; // //判断打卡时间 // try { // long time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(attendance.getClockTime()).getTime(); // // //判断上午上班之前半小时前打卡为无效打卡 // if (time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonWorkTime).getTime()-30*60*1000)<0){ // attendance.setClocktype("0"); // attendance.setAttendancetype("4"); // return R.status(attendanceService.save(attendance)); // } // // //上午上班半小时前到上班时间打卡为正常打卡 // if (time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonWorkTime).getTime()-30*60*1000)>=0 // && time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonWorkTime).getTime()<=0) { // attendance.setClocktype("0"); // attendance.setAttendancetype("0"); // return R.status(attendanceService.save(attendance)); // } // // //上午上班后到上班下班前打卡为正常打卡 // if (time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonWorkTime).getTime()>0 // && time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime()<0) { // //查询当前时间之前当前考勤人员的最新的一条考勤数据 // Attendance attendanceNow = attendanceService.selAttendanceNewNow(attendance.getNumber()); // if (null!=attendanceNow){ // if (attendanceNow.getAttendancetype().equals("0") || attendanceNow.getClocktype().equals("1")) { // //下班早退 // attendance.setClocktype("1"); // attendance.setAttendancetype("2"); // } // if (attendanceNow.getAttendancetype().equals("4")){ // //上班迟到 // attendance.setClocktype("0"); // attendance.setAttendancetype("1"); // } // }else { // //上班迟到 // attendance.setClocktype("0"); // attendance.setAttendancetype("1"); // } // return R.status(attendanceService.save(attendance)); // } // // //正常下班时间-下班半小时后 // if (time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime()>=0 // && time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime()+30*60*1000)<=0){ // //正常下班打卡 // attendance.setClocktype("1"); // attendance.setAttendancetype("0"); // return R.status(attendanceService.save(attendance)); // } // // //上午下班半小时后-下午上班之前半小時打卡为无效打卡 // if (time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime()-30*60*1000)<0 // && time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime()+30*60*1000)>0){ // //无效打卡 // attendance.setClocktype("0"); // attendance.setAttendancetype("4"); // return R.status(attendanceService.save(attendance)); // } // // //下午上班之前半小時-下午上班时间之前打卡为下午正常上班打卡 // if (time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime()-30*60*1000)>=0 // && time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime()<=0){ // //下午正常打卡 // attendance.setClocktype("0"); // attendance.setAttendancetype("0"); // return R.status(attendanceService.save(attendance)); // } // // //下午上班之后到下午下班之前 // if (time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime()>0 // && time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()<0){ // //查询当前时间之前当前考勤人员的最新的一条考勤数据 // Attendance attendanceNow = attendanceService.selAttendanceNewNow(attendance.getNumber()); // if (null!=attendanceNow){ // if (attendanceNow.getAttendancetype().equals("0") && attendanceNow.getClocktype().equals("0")) { // //下班早退 // attendance.setClocktype("1"); // attendance.setAttendancetype("2"); // } // if (attendanceNow.getClocktype().equals("1")) { // //下班早退 // attendance.setClocktype("1"); // attendance.setAttendancetype("2"); // } // if (attendanceNow.getAttendancetype().equals("4")){ // //上班迟到 // attendance.setClocktype("0"); // attendance.setAttendancetype("1"); // } // }else { // //上班迟到 // attendance.setClocktype("0"); // attendance.setAttendancetype("1"); // } // return R.status(attendanceService.save(attendance)); // } // // //正常打下午下班卡 // if (time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()>=0 // && time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()+30*60*1000)<=0 // ){ // //下午正常下班打卡 // attendance.setClocktype("1"); // attendance.setAttendancetype("0"); // return R.status(attendanceService.save(attendance)); // } // // //打卡时间超过下午下班打卡时间后的半小时为无效打卡 // if (time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()+30*60*1000)>0){ // //下午下班打卡无效 // attendance.setClocktype("1"); // attendance.setAttendancetype("4"); // return R.status(attendanceService.save(attendance)); // } // // } catch (ParseException e) { // e.printStackTrace(); // } // } // return R.status(false); // } /** * 修改 */ @PostMapping("/update") @ApiOperationSupport(order = 5) @ApiOperation(value = "修改", notes = "传入attendance") public R update(@Valid @RequestBody Attendance attendance) { return R.status(attendanceService.updateById(attendance)); } /** * 新增或修改 */ @PostMapping("/submit") @ApiOperationSupport(order = 6) @ApiOperation(value = "新增或修改", notes = "传入attendance") public R submit(@Valid @RequestBody Attendance attendance) { return R.status(attendanceService.saveOrUpdate(attendance)); } /** * 删除 */ @PostMapping("/remove") @ApiOperationSupport(order = 8) @ApiOperation(value = "删除", notes = "传入ids") public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { return R.status(attendanceService.removeByIds(Func.toLongList(ids))); } /** * 导出用户 */ @GetMapping("/export-Attendance") public void exportAttendane(String name, String beginTime, String endTime, String attendancetype, HttpServletResponse response) { String beginTimes = null; String endTimes = null; String attendancetypes = null; if (beginTime.equals("undefined ") && endTime.equals("undefined")) { beginTimes=null; endTimes=null; attendancetypes=attendancetype; } else if (attendancetype.equals("undefined")){ attendancetypes=null; } else { beginTimes=beginTime; endTimes=endTime; attendancetypes=attendancetype; } List<AttendanceExcel> list = attendanceService.exportAttendane(name, beginTimes, endTimes, attendancetypes); ExcelUtil.export(response, "考勤数据" + DateUtil.time(), "考勤数据表", list, AttendanceExcel.class); } } src/main/java/org/springblade/modules/attendance/dto/AttendanceDTO.javacopy from src/main/java/org/springblade/flow/demo/leave/mapper/LeaveMapper.java copy to src/main/java/org/springblade/modules/attendance/dto/AttendanceDTO.java
File was copied from src/main/java/org/springblade/flow/demo/leave/mapper/LeaveMapper.java @@ -14,16 +14,21 @@ * this software without specific prior written permission. * Author: Chill 庄骞 (smallchill@163.com) */ package org.springblade.flow.demo.leave.mapper; package org.springblade.modules.attendance.dto; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.springblade.flow.demo.leave.entity.ProcessLeave; import lombok.Data; import lombok.EqualsAndHashCode; import org.springblade.modules.attendance.entity.Attendance; /** * Mapper 接口 * 数据传输对象实体类 * * @author Chill * @author BladeX * @since 2021-03-03 */ public interface LeaveMapper extends BaseMapper<ProcessLeave> { @Data @EqualsAndHashCode(callSuper = true) public class AttendanceDTO extends Attendance { private static final long serialVersionUID = 1L; } src/main/java/org/springblade/modules/attendance/entity/Attendance.java
New file @@ -0,0 +1,79 @@ package org.springblade.modules.attendance.entity; import com.baomidou.mybatisplus.annotation.*; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.Serializable; /** * 考勤打卡实体类 * * @author zhongrj * @since 2022-02-28 */ @Data @TableName("sys_attendance") @ApiModel(value = "Attendance对象", description = "Attendance对象") public class Attendance implements Serializable { private static final long serialVersionUID = 1L; @TableId(value = "id", type = IdType.AUTO) private Integer id; /** * 姓名 */ private String name; /** * 编号 */ private String number; /** * 部门 */ private String department; /** * 天气 */ private String weather; /** * 打卡时间 */ private String clockTime; /** * 经度 */ private String jd; /** * 纬度 */ private String wd; /** * 打卡类型 0:上班 1:下班 */ private String clocktype; /** * 考勤类型 0:正常 1:迟到 2:早退 3:外勤 */ private String attendancetype; private String week; private String address; @TableLogic private Integer isDeleted; } src/main/java/org/springblade/modules/attendance/excel/AttendanceExcel.java
New file @@ -0,0 +1,78 @@ /* * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the dreamlu.net developer nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * Author: Chill 庄骞 (smallchill@163.com) */ package org.springblade.modules.attendance.excel; import com.alibaba.excel.annotation.ExcelIgnore; import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.write.style.ColumnWidth; import com.alibaba.excel.annotation.write.style.ContentRowHeight; import com.alibaba.excel.annotation.write.style.HeadRowHeight; import lombok.Data; import java.io.Serializable; /** * UserExcel * * @author Chill */ @Data @ColumnWidth(25) @HeadRowHeight(20) @ContentRowHeight(18) public class AttendanceExcel implements Serializable { private static final long serialVersionUID = 1L; @ColumnWidth(10) @ExcelProperty("姓名") private String name; @ColumnWidth(20) @ExcelProperty("编号") private String number; @ColumnWidth(15) @ExcelProperty("部门") private String department; /** * 天气,忽略不显示 */ @ExcelIgnore private String weather; @ColumnWidth(20) @ExcelProperty("打卡时间") private String clockTime; @ColumnWidth(15) @ExcelProperty("打卡类型") private String clockType; @ColumnWidth(15) @ExcelProperty("考勤类型") private String attendanceType; @ColumnWidth(15) @ExcelProperty("星期") private String week; @ColumnWidth(40) @ExcelProperty("地址") private String address; } src/main/java/org/springblade/modules/attendance/mapper/AttendanceMapper.java
New file @@ -0,0 +1,66 @@ /* * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the dreamlu.net developer nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * Author: Chill 庄骞 (smallchill@163.com) */ package org.springblade.modules.attendance.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import org.springblade.modules.attendance.entity.Attendance; import org.springblade.modules.attendance.excel.AttendanceExcel; import org.springblade.modules.attendance.vo.AttendanceVO; import java.util.List; /** * Mapper 接口 * * @author BladeX * @since 2021-03-03 */ public interface AttendanceMapper extends BaseMapper<Attendance> { /** * 自定义分页 * * @param page * @param attendance * @return */ List<Attendance> selectAttendancePage(IPage page, Long department, AttendanceVO attendance); /** * 获取导出用户数据 * * @param * @return */ List<AttendanceExcel> exportAttendane(String name,String beginTimes,String endTimes,String attendancetypes); /** * 查询当前考勤人员当天的考勤信息 * @param number 考勤人员编号 * @return */ List<Attendance> selAttendanceListNow(String number); /** * 查询当前时间之前最新的一条数据 * @param number 考勤人员编号 * @return */ Attendance selAttendanceNewNow(String number); } src/main/java/org/springblade/modules/attendance/mapper/AttendanceMapper.xml
New file @@ -0,0 +1,83 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="org.springblade.modules.attendance.mapper.AttendanceMapper"> <!-- 通用查询映射结果 --> <resultMap id="attendanceResultMap" type="org.springblade.modules.attendance.entity.Attendance"> <id column="id" property="id"/> <result column="name" property="name"/> <result column="number" property="number"/> <result column="department" property="department"/> <result column="weather" property="weather"/> <result column="clockTime" property="clockTime"/> <result column="jd" property="jd"/> <result column="wd" property="wd"/> <result column="clockType" property="clocktype"/> <result column="attendanceType" property="attendancetype"/> <result column="tenant_id" property="tenantId"/> <result column="week" property="week"/> <result column="address" property="address"/> </resultMap> <select id="selectAttendancePage" resultMap="attendanceResultMap"> select * from sys_attendance where is_deleted = 0 <if test="attendance.name!=null and attendance.name != ''"> and name = #{attendance.name} </if> <if test="attendance.department!=null and attendance.department != ''"> and department = #{department} </if> <if test="attendance.attendancetype!=null and attendance.attendancetype != ''"> and attendancetype = #{attendance.attendancetype} </if> <if test="attendance.beginTime!=null and attendance.beginTime!=''"> and clockTime>=#{attendance.beginTime} </if> <if test="attendance.endTime!=null and attendance.endTime!=''"> and clockTime<=#{attendance.endTime} </if> </select> <select id="exportAttendane" resultType="org.springblade.modules.attendance.excel.AttendanceExcel"> SELECT id, name, number, department, weather, clockTime, clockType, attendanceType,week,address FROM sys_attendance where is_deleted = 0 <if test="name!=null and name != ''"> and name = #{name} </if> <if test="beginTimes!=null and beginTimes!=''"> and clockTime>=#{beginTimes} </if> <if test="endTimes!=null and endTimes!=''"> and clockTime<=#{endTimes} </if> <if test="attendancetypes!=null and attendancetypes!=''"> and attendancetype=#{attendancetypes} </if> </select> <!--查询当前考勤人员当天的考勤信息--> <select id="selAttendanceListNow" resultType="org.springblade.modules.attendance.entity.Attendance"> select * from sys_attendance where number = #{number} and to_days(now())=to_days(clockTime) and is_deleted=0 </select> <!--查询当前时间之前最新的一条数据--> <select id="selAttendanceNewNow" resultType="org.springblade.modules.attendance.entity.Attendance"> select * from sys_attendance where number = #{number} and to_days(now())=to_days(clockTime) and is_deleted=0 order by clockTime desc limit 1 </select> </mapper> src/main/java/org/springblade/modules/attendance/service/IAttendanceService.java
New file @@ -0,0 +1,63 @@ /* * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the dreamlu.net developer nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * Author: Chill 庄骞 (smallchill@163.com) */ package org.springblade.modules.attendance.service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; import org.springblade.modules.attendance.entity.Attendance; import org.springblade.modules.attendance.excel.AttendanceExcel; import org.springblade.modules.attendance.vo.AttendanceVO; import java.util.List; /** * 服务类 * * @author BladeX * @since 2021-03-03 */ public interface IAttendanceService extends IService<Attendance> { /** * 自定义分页 * * @param page * @param attendance * @return */ IPage<Attendance> selectAttendancePage(IPage<Attendance> page, Long department, AttendanceVO attendance); /** * 导出用户数据 * * @return */ List<AttendanceExcel> exportAttendane(String name,String beginTimes,String endTimes,String attendancetypes); /** * 查询当前考勤人员当天的考勤信息 * @param number 考勤人员编号 * @return */ List<Attendance> selAttendanceListNow(String number); /** * 查询当前时间之前最新的一条数据 * @param number 考勤人员编号 * @return */ Attendance selAttendanceNewNow(String number); } src/main/java/org/springblade/modules/attendance/service/impl/AttendanceServiceImpl.java
New file @@ -0,0 +1,79 @@ /* * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the dreamlu.net developer nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * Author: Chill 庄骞 (smallchill@163.com) */ package org.springblade.modules.attendance.service.impl; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springblade.common.cache.DictBizCache; import org.springblade.common.cache.SysCache; import org.springblade.common.enums.DictBizEnum; import org.springblade.core.tool.utils.StringUtil; import org.springblade.modules.attendance.entity.Attendance; import org.springblade.modules.attendance.excel.AttendanceExcel; import org.springblade.modules.attendance.mapper.AttendanceMapper; import org.springblade.modules.attendance.service.IAttendanceService; import org.springblade.modules.attendance.vo.AttendanceVO; import org.springframework.stereotype.Service; import java.util.List; /** * 服务实现类 * * @author BladeX * @since 2021-03-03 */ @Service public class AttendanceServiceImpl extends ServiceImpl<AttendanceMapper, Attendance> implements IAttendanceService { @Override public IPage<Attendance> selectAttendancePage(IPage<Attendance> page, Long department, AttendanceVO attendance) { return page.setRecords(baseMapper.selectAttendancePage(page,department, attendance)); } @Override public List<AttendanceExcel> exportAttendane(String name,String beginTimes,String endTimes,String attendancetypes) { List<AttendanceExcel> userList = baseMapper.exportAttendane(name, beginTimes, endTimes,attendancetypes); userList.forEach(user -> { user.setAttendanceType(DictBizCache.getValue(DictBizEnum.TEST,user.getAttendanceType())); // user.setClockType(DictBizCache.getValue(DictBizEnum.CLOCKTYPE,user.getClockType())); user.setDepartment(StringUtil.join(SysCache.getDeptNames(user.getDepartment()))); }); return userList; } /** * 查询当前考勤人员当天的考勤信息 * @param number 考勤人员编号 * @return */ @Override public List<Attendance> selAttendanceListNow(String number) { return baseMapper.selAttendanceListNow(number); } /** * 查询当前时间之前最新的一条数据 * @param number 考勤人员编号 * @return */ @Override public Attendance selAttendanceNewNow(String number) { return baseMapper.selAttendanceNewNow(number); } } src/main/java/org/springblade/modules/attendance/util/PointMapUtil.java
New file @@ -0,0 +1,263 @@ package org.springblade.modules.attendance.util; import org.springblade.modules.attendance.entity.Attendance; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import javax.annotation.PostConstruct; import java.awt.geom.Point2D; import java.util.ArrayList; import java.util.List; /** * 判断当前坐标点是否在多边形区域内 * @author zhongrj * @time 2021--5-14 */ @Component public class PointMapUtil { public static PointMapUtil pointMapUtil; @PostConstruct public void init(){ pointMapUtil=this; } public static void main(String[] args) { // Attendance attendance = new Attendance(); // attendance.setNumber("32165165"); // attendance.setJd("114.9161"); // attendance.setWd("25.85101"); // Enclosure enclosure = new Enclosure(); // enclosure.setAnumber(attendance.getNumber()); // //查询当前处警人员的电子围栏信息 // Enclosure enclosureDetail = pointMapUtil.iEnclosureService.selectEnclosureDetail(enclosure); // //取出经纬度 // Boolean onArea = PointMapUtil.isOnArea(Double.parseDouble(attendance.getJd()), // Double.parseDouble(attendance.getWd()), // enclosureDetail.getCoordinate()); // System.out.println("onArea = " + onArea); } /** * 判断坐标点是否在多边形区域内 * @return */ public static Boolean isOnArea(Double x,Double y,String partitionLocation){ /** * 定义一个点 */ Point2D.Double point = new Point2D.Double(x, y); List<Point2D.Double> pointList= new ArrayList(); //坐标数据处理 int i = partitionLocation.indexOf("("); int j = partitionLocation.indexOf(")"); String split = partitionLocation.substring(i+1, j); System.out.println("split = " + split); //读取多边形区域中的顶点 String[] strList = split.split(","); //遍历形成多边形区域的顶点 for (String str : strList){ String[] points = str.split(" "); System.out.println("points[0] = " + points[0]); System.out.println("points[1] = " + points[1]); double polygonPoint_x=Double.parseDouble(points[1]); double polygonPoint_y=Double.parseDouble(points[0]); Point2D.Double polygonPoint = new Point2D.Double(polygonPoint_x,polygonPoint_y); pointList.add(polygonPoint); } return IsPtInPoly(point,pointList); } /** * 判断点是否在多边形内,如果点位于多边形的顶点或边上,也算做点在多边形内,直接返回true * @param point 检测点 * @param pts 多边形的顶点 * @return 点在多边形内返回true,否则返回false */ public static boolean IsPtInPoly(Point2D.Double point, List<Point2D.Double> pts){ int N = pts.size(); boolean boundOrVertex = true; //如果点位于多边形的顶点或边上,也算做点在多边形内,直接返回true int intersectCount = 0;//cross points count of x double precision = 2e-10; //浮点类型计算时候与0比较时候的容差 Point2D.Double p1, p2;//neighbour bound vertices Point2D.Double p = point; //当前点 p1 = pts.get(0);//left vertex for(int i = 1; i <= N; ++i){//check all rays if(p.equals(p1)){ return boundOrVertex;//p is an vertex } p2 = pts.get(i % N);//right vertex if(p.x < Math.min(p1.x, p2.x) || p.x > Math.max(p1.x, p2.x)){//ray is outside of our interests p1 = p2; continue;//next ray left point } if(p.x > Math.min(p1.x, p2.x) && p.x < Math.max(p1.x, p2.x)){//ray is crossing over by the algorithm (common part of) if(p.y <= Math.max(p1.y, p2.y)){//x is before of ray if(p1.x == p2.x && p.y >= Math.min(p1.y, p2.y)){//overlies on a horizontal ray return boundOrVertex; } if(p1.y == p2.y){//ray is vertical if(p1.y == p.y){//overlies on a vertical ray return boundOrVertex; }else{//before ray ++intersectCount; } }else{//cross point on the left side double xinters = (p.x - p1.x) * (p2.y - p1.y) / (p2.x - p1.x) + p1.y;//cross point of y if(Math.abs(p.y - xinters) < precision){//overlies on a ray return boundOrVertex; } if(p.y < xinters){//before ray ++intersectCount; } } } }else{//special case when ray is crossing through the vertex if(p.x == p2.x && p.y <= p2.y){//p crossing over p2 Point2D.Double p3 = pts.get((i+1) % N); //next vertex if(p.x >= Math.min(p1.x, p3.x) && p.x <= Math.max(p1.x, p3.x)){//p.x lies between p1.x & p3.x ++intersectCount; }else{ intersectCount += 2; } } } p1 = p2;//next ray left point } if(intersectCount % 2 == 0){//偶数在多边形外 return false; } else { //奇数在多边形内 return true; } } /** * 返回一个点是否在一个多边形区域内, 如果点位于多边形的顶点或边上,不算做点在多边形内,返回false * @param point * @param polygon * @return */ public static boolean checkWithJdkGeneralPath(Point2D.Double point, List<Point2D.Double> polygon) { java.awt.geom.GeneralPath p = new java.awt.geom.GeneralPath(); Point2D.Double first = polygon.get(0); p.moveTo(first.x, first.y); polygon.remove(0); for (Point2D.Double d : polygon) { p.lineTo(d.x, d.y); } p.lineTo(first.x, first.y); p.closePath(); return p.contains(point); } // public static boolean isPtInPoly (double ALon , double ALat , Point[] ps) { // int iSum, iCount, iIndex; // double dLon1 = 0, dLon2 = 0, dLat1 = 0, dLat2 = 0, dLon; // if (ps.length < 3) { // return false; // } // iSum = 0; // iCount = ps.length; // for (iIndex = 0; iIndex<iCount;iIndex++) { // if (iIndex == iCount - 1) { // dLon1 = ps[iIndex].getX(); // dLat1 = ps[iIndex].getY(); // dLon2 = ps[0].getX(); // dLat2 = ps[0].getY(); // } else { // dLon1 = ps[iIndex].getX(); // dLat1 = ps[iIndex].getY(); // dLon2 = ps[iIndex + 1].getX(); // dLat2 = ps[iIndex + 1].getY(); // } // // 以下语句判断A点是否在边的两端点的水平平行线之间,在则可能有交点,开始判断交点是否在左射线上 // if (((ALat >= dLat1) && (ALat < dLat2)) || ((ALat >= dLat2) && (ALat < dLat1))) { // if (Math.abs(dLat1 - dLat2) > 0) { // //得到 A点向左射线与边的交点的x坐标: // dLon = dLon1 - ((dLon1 - dLon2) * (dLat1 - ALat) ) / (dLat1 - dLat2); // // 如果交点在A点左侧(说明是做射线与 边的交点),则射线与边的全部交点数加一: // if (dLon < ALon) { // iSum++; // } // } // } // } // if ((iSum % 2) != 0) { // return true; // } // return false; // } } src/main/java/org/springblade/modules/attendance/vo/AttendanceVO.java
New file @@ -0,0 +1,46 @@ /* * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the dreamlu.net developer nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * Author: Chill 庄骞 (smallchill@163.com) */ package org.springblade.modules.attendance.vo; import io.swagger.annotations.ApiModel; import lombok.Data; import lombok.EqualsAndHashCode; import org.springblade.modules.attendance.entity.Attendance; /** * 视图实体类 * * @author BladeX * @since 2021-03-03 */ @Data @EqualsAndHashCode(callSuper = true) @ApiModel(value = "AttendanceVO对象", description = "AttendanceVO对象") public class AttendanceVO extends Attendance { private static final long serialVersionUID = 1L; /** * 部门名 */ private String deptName; private String beginTime; private String endTime; } src/main/java/org/springblade/modules/attendance/wrapper/AttendanceWrapper.java
New file @@ -0,0 +1,49 @@ /* * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the dreamlu.net developer nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * Author: Chill 庄骞 (smallchill@163.com) */ package org.springblade.modules.attendance.wrapper; import org.springblade.common.cache.SysCache; import org.springblade.core.mp.support.BaseEntityWrapper; import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.Func; import org.springblade.modules.attendance.entity.Attendance; import org.springblade.modules.attendance.vo.AttendanceVO; import org.springblade.modules.system.entity.Tenant; import java.util.List; import java.util.Objects; /** * 包装类,返回视图层所需的字段 * * @author Chill */ public class AttendanceWrapper extends BaseEntityWrapper<Attendance, AttendanceVO> { public static AttendanceWrapper build() { return new AttendanceWrapper(); } @Override public AttendanceVO entityVO(Attendance attendance) { AttendanceVO attendanceVO = Objects.requireNonNull(BeanUtil.copy(attendance, AttendanceVO.class)); List<String> deptName = SysCache.getDeptNames(attendance.getDepartment()); attendanceVO.setDeptName(Func.join(deptName)); return attendanceVO; } } src/main/java/org/springblade/modules/extra/controller/ExtraController.java
New file @@ -0,0 +1,91 @@ package org.springblade.modules.extra.controller; import com.baomidou.mybatisplus.core.metadata.IPage; import io.swagger.annotations.ApiParam; import lombok.AllArgsConstructor; import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.Func; import org.springblade.modules.extra.entity.Extra; import org.springblade.modules.extra.service.ExtraService; import org.springblade.modules.extra.vo.ExtraVO; import org.springframework.web.bind.annotation.*; /** * 加班控制器 * @author zhongrj * @since 2022-02-28 */ @RestController @AllArgsConstructor @RequestMapping("/extra") public class ExtraController extends BladeController { private final ExtraService extraService; /** * 详情 */ @GetMapping("/detail") public R<Extra> detail(Extra extra) { Extra detail = extraService.getOne(Condition.getQueryWrapper(extra)); return R.data(detail); } /** * 分页 */ @GetMapping("/list") public R<IPage<Extra>> list(Extra extra, Query query) { IPage<Extra> pages = extraService.page(Condition.getPage(query), Condition.getQueryWrapper(extra)); return R.data(pages); } /** * 自定义分页 */ @GetMapping("/page") public R<IPage<ExtraVO>> page(ExtraVO extra, Query query) { IPage<ExtraVO> pages = extraService.selectExtraPage(Condition.getPage(query), extra); return R.data(pages); } /** * 新增 */ @PostMapping("/save") public R save(@RequestBody Extra extra) { return R.data(extraService.save(extra)); } /** * 修改 */ @PostMapping("/update") public R update(@RequestBody Extra extra) { return R.data(extraService.updateById(extra)); } /** * 新增或修改 */ @PostMapping("/submit") public R submit(@RequestBody Extra extra) { return R.status(extraService.saveOrUpdate(extra)); } /** * 删除 */ @PostMapping("/remove") public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { return R.status(extraService.removeByIds(Func.toLongList(ids))); } } src/main/java/org/springblade/modules/extra/entity/Extra.java
New file @@ -0,0 +1,83 @@ package org.springblade.modules.extra.entity; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; import java.io.Serializable; import java.util.Date; /** * 加班实体类 * * @author zhongrj * @since 2020-02-28 */ @Data @TableName("sys_extra_work") public class Extra implements Serializable { private static final long serialVersionUID = 1L; /** * 主键id */ @TableId(value = "id",type = IdType.AUTO) private Long id; /** * 用户id */ private Long userId; /** * 加班类型 */ private Integer extraType; /** * 加班原因 */ private String extraReason; /** * 加班开始时间 */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date startTime; /** * 加班截止时间 */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date endTime; /** * 创建时间 */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date createTime; /** * 审核状态 1:通过 2:不通过 3:待审核 */ private Integer auditStatus; /** * 审核明细 */ private String auditDetail; /** * 审核时间 */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date auditTime; } src/main/java/org/springblade/modules/extra/mapper/ExtraMapper.java
New file @@ -0,0 +1,28 @@ package org.springblade.modules.extra.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import org.apache.ibatis.annotations.Param; import org.springblade.modules.extra.entity.Extra; import org.springblade.modules.extra.vo.ExtraVO; import java.util.List; /** * 加班Mapper 接口 * * @author zhongrj * @since 2022-02-21 */ public interface ExtraMapper extends BaseMapper<Extra> { /** * 自定义分页 * * @param page * @param extra * @return */ List<ExtraVO> selectExtraPage(IPage<ExtraVO> page, @Param("extra") ExtraVO extra); } src/main/java/org/springblade/modules/extra/mapper/ExtraMapper.xml
New file @@ -0,0 +1,14 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="org.springblade.modules.extra.mapper.ExtraMapper"> <!--自定义查询加班分页数据--> <select id="selectExtraPage" resultType="org.springblade.modules.extra.vo.ExtraVO"> select * from sys_extra_work where 1=1 <if test="extra.userId!=null"> and user_id = #{extra.idCardNo} </if> </select> </mapper> src/main/java/org/springblade/modules/extra/service/ExtraService.java
New file @@ -0,0 +1,27 @@ package org.springblade.modules.extra.service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; import org.apache.ibatis.annotations.Param; import org.springblade.modules.extra.entity.Extra; import org.springblade.modules.extra.vo.ExtraVO; /** * 加班服务类 * * @author zhongrj * @since 2022-02-28 */ public interface ExtraService extends IService<Extra> { /** * 自定义分页 * * @param page * @param extraVO * @return */ IPage<ExtraVO> selectExtraPage(IPage<ExtraVO> page, @Param("extraVO") ExtraVO extraVO); } src/main/java/org/springblade/modules/extra/service/impl/ExtraServiceImpl.java
New file @@ -0,0 +1,31 @@ package org.springblade.modules.extra.service.impl; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springblade.modules.extra.entity.Extra; import org.springblade.modules.extra.mapper.ExtraMapper; import org.springblade.modules.extra.service.ExtraService; import org.springblade.modules.extra.vo.ExtraVO; import org.springframework.stereotype.Service; /** * 加班服务实现类 * * @author zhongrj * @since 2022-02-28 */ @Service public class ExtraServiceImpl extends ServiceImpl<ExtraMapper, Extra> implements ExtraService { /** * 自定义分页查询加班数据 * @param page * @param extra * @return */ @Override public IPage<ExtraVO> selectExtraPage(IPage<ExtraVO> page, ExtraVO extra) { return page.setRecords(baseMapper.selectExtraPage(page, extra)); } } src/main/java/org/springblade/modules/extra/vo/ExtraVO.java
New file @@ -0,0 +1,15 @@ package org.springblade.modules.extra.vo; import lombok.Data; import org.springblade.modules.extra.entity.Extra; /** * 加班视图实体类 * @author zhongrj * @since 2022-02-28 */ @Data public class ExtraVO extends Extra { private static final long serialVersionUID = 1L; } src/main/java/org/springblade/modules/leave/controller/LeaveController.java
New file @@ -0,0 +1,91 @@ package org.springblade.modules.leave.controller; import com.baomidou.mybatisplus.core.metadata.IPage; import io.swagger.annotations.ApiParam; import lombok.AllArgsConstructor; import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.Func; import org.springblade.modules.leave.entity.Leave; import org.springblade.modules.leave.service.LeaveService; import org.springblade.modules.leave.vo.LeaveVO; import org.springframework.web.bind.annotation.*; /** * 请假控制器 * @author zhongrj * @since 2022-02-28 */ @RestController @AllArgsConstructor @RequestMapping("/leave") public class LeaveController extends BladeController { private final LeaveService leaveService; /** * 详情 */ @GetMapping("/detail") public R<Leave> detail(Leave leave) { Leave detail = leaveService.getOne(Condition.getQueryWrapper(leave)); return R.data(detail); } /** * 分页 */ @GetMapping("/list") public R<IPage<Leave>> list(Leave leave, Query query) { IPage<Leave> pages = leaveService.page(Condition.getPage(query), Condition.getQueryWrapper(leave)); return R.data(pages); } /** * 自定义分页 */ @GetMapping("/page") public R<IPage<LeaveVO>> page(LeaveVO leave, Query query) { IPage<LeaveVO> pages = leaveService.selectLeavePage(Condition.getPage(query), leave); return R.data(pages); } /** * 新增 */ @PostMapping("/save") public R save(@RequestBody Leave leave) { return R.data(leaveService.save(leave)); } /** * 修改 */ @PostMapping("/update") public R update(@RequestBody Leave leave) { return R.data(leaveService.updateById(leave)); } /** * 新增或修改 */ @PostMapping("/submit") public R submit(@RequestBody Leave leave) { return R.status(leaveService.saveOrUpdate(leave)); } /** * 删除 */ @PostMapping("/remove") public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { return R.status(leaveService.removeByIds(Func.toLongList(ids))); } } src/main/java/org/springblade/modules/leave/entity/Leave.java
New file @@ -0,0 +1,84 @@ package org.springblade.modules.leave.entity; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; import java.io.Serializable; import java.util.Date; /** * 请假实体类 * * @author zhongrj * @since 2020-02-28 */ @Data @TableName("sys_leave") public class Leave implements Serializable { private static final long serialVersionUID = 1L; /** * 主键id */ @TableId(value = "id",type = IdType.AUTO) private Long id; /** * 用户id */ private Long userId; /** * 请假类型 */ private Integer leaveType; /** * 请假原因 */ private String leaveReason; /** * 请假开始时间 */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date startTime; /** * 请假截止时间 */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date endTime; /** * 创建时间 */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date createTime; /** * 审核状态 1:通过 2:不通过 3:待审核 */ private Integer auditStatus; /** * 审核明细 */ private String auditDetail; /** * 审核时间 */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date auditTime; } src/main/java/org/springblade/modules/leave/mapper/LeaveMapper.java
New file @@ -0,0 +1,28 @@ package org.springblade.modules.leave.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import org.apache.ibatis.annotations.Param; import org.springblade.modules.leave.entity.Leave; import org.springblade.modules.leave.vo.LeaveVO; import java.util.List; /** * Mapper 接口 * * @author zhongrj * @since 2022-02-21 */ public interface LeaveMapper extends BaseMapper<Leave> { /** * 自定义分页 * * @param page * @param leave * @return */ List<LeaveVO> selectLeavePage(IPage<LeaveVO> page, @Param("leave") LeaveVO leave); } src/main/java/org/springblade/modules/leave/mapper/LeaveMapper.xml
New file @@ -0,0 +1,14 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="org.springblade.modules.leave.mapper.LeaveMapper"> <!--自定义查询请假分页数据--> <select id="selectLeavePage" resultType="org.springblade.modules.leave.vo.LeaveVO"> select * from sys_leave where 1=1 <if test="leave.userId!=null"> and user_id = #{leave.idCardNo} </if> </select> </mapper> src/main/java/org/springblade/modules/leave/service/LeaveService.java
New file @@ -0,0 +1,27 @@ package org.springblade.modules.leave.service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; import org.apache.ibatis.annotations.Param; import org.springblade.modules.leave.entity.Leave; import org.springblade.modules.leave.vo.LeaveVO; /** * 请假服务类 * * @author zhongrj * @since 2022-02-28 */ public interface LeaveService extends IService<Leave> { /** * 自定义分页 * * @param page * @param leaveVO * @return */ IPage<LeaveVO> selectLeavePage(IPage<LeaveVO> page, @Param("leaveVO") LeaveVO leaveVO); } src/main/java/org/springblade/modules/leave/service/impl/LeaveServiceImpl.java
New file @@ -0,0 +1,31 @@ package org.springblade.modules.leave.service.impl; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springblade.modules.leave.entity.Leave; import org.springblade.modules.leave.mapper.LeaveMapper; import org.springblade.modules.leave.service.LeaveService; import org.springblade.modules.leave.vo.LeaveVO; import org.springframework.stereotype.Service; /** * 请假服务实现类 * * @author zhongrj * @since 2022-02-28 */ @Service public class LeaveServiceImpl extends ServiceImpl<LeaveMapper, Leave> implements LeaveService { /** * 自定义分页查询用户会员数据 * @param page * @param leave * @return */ @Override public IPage<LeaveVO> selectLeavePage(IPage<LeaveVO> page, LeaveVO leave) { return page.setRecords(baseMapper.selectLeavePage(page, leave)); } } src/main/java/org/springblade/modules/leave/vo/LeaveVO.java
New file @@ -0,0 +1,15 @@ package org.springblade.modules.leave.vo; import lombok.Data; import org.springblade.modules.leave.entity.Leave; /** * 视图实体类 * @author zhongrj * @since 2022-02-21 */ @Data public class LeaveVO extends Leave { private static final long serialVersionUID = 1L; } src/main/resources/application-test.yml
@@ -33,7 +33,7 @@ #图片批量上传zip upload: localtion: ${UPLOAD_DIR:D:/test} localtion: ${UPLOAD_DIR:E:/test} maxFileSize: 10240KB maxRequestSize: 102400KB