diff --git a/shapelight-admin/src/main/java/net/shapelight/common/utils/Constant.java b/shapelight-admin/src/main/java/net/shapelight/common/utils/Constant.java index 9921533..ad61a1c 100644 --- a/shapelight-admin/src/main/java/net/shapelight/common/utils/Constant.java +++ b/shapelight-admin/src/main/java/net/shapelight/common/utils/Constant.java @@ -98,6 +98,12 @@ public class Constant { public static final String DEVICE_FLAG_2D = "0"; public static final String DEVICE_FLAG_3D = "1"; + //上班状态0缺卡1正常2迟到 下班状态0缺卡1正常3早退 + public static final int CHECK_QUEKA =0; + public static final int CHECK_OK =1; + public static final int CHECK_CHIDAO =2; + public static final int CHECK_ZAOTUI =3; + diff --git a/shapelight-admin/src/main/java/net/shapelight/common/utils/MyDateUtils.java b/shapelight-admin/src/main/java/net/shapelight/common/utils/MyDateUtils.java index 460d824..0aa9fb4 100644 --- a/shapelight-admin/src/main/java/net/shapelight/common/utils/MyDateUtils.java +++ b/shapelight-admin/src/main/java/net/shapelight/common/utils/MyDateUtils.java @@ -1,5 +1,6 @@ package net.shapelight.common.utils; +import java.sql.Time; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; @@ -71,4 +72,9 @@ public class MyDateUtils { calendar2.set(Calendar.DAY_OF_MONTH, calendar2.getActualMaximum(Calendar.DAY_OF_MONTH)); return sdf.format(calendar2.getTime())+" 23:59:59"; } + + public static int getSeconds(Time time){ + int sec = time.getHours() * 3600 + time.getMinutes()*60 + time.getSeconds(); + return sec; + } } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/httpapi/controler/HttpApiController.java b/shapelight-admin/src/main/java/net/shapelight/modules/httpapi/controler/HttpApiController.java index 4ea8600..1306560 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/httpapi/controler/HttpApiController.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/httpapi/controler/HttpApiController.java @@ -96,6 +96,8 @@ public class HttpApiController { private TenCellDeptService tenCellDeptService; @Autowired private TenLabelService tenLabelService; + @Autowired + private TenCheckService tenCheckService; /** * @@ -744,6 +746,14 @@ public class HttpApiController { // log.info("保存记录:----------------------"+record.getRecordTime()+"-"+record.getMemberId().intValue()); tenRecordService.saveForFace(record); + + // 考勤记录,没有删除的人记录考勤 + TenPersonEntity memberEntity = tenPersonService.getById(personId,deviceEntity.getCellId()); + if(memberEntity!=null){ + if(memberEntity.getDeleteFlag().intValue() == 0){ + tenCheckService.saveCheck(memberEntity,record); + } + } return R.ok(); } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/nettyapi/service/impl/DeviceApiServiceImpl.java b/shapelight-admin/src/main/java/net/shapelight/modules/nettyapi/service/impl/DeviceApiServiceImpl.java index 3e5ea91..b922683 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/nettyapi/service/impl/DeviceApiServiceImpl.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/nettyapi/service/impl/DeviceApiServiceImpl.java @@ -75,6 +75,8 @@ public class DeviceApiServiceImpl implements DeviceApiService { private MinioConfig minioConfig; @Autowired private MinioClient minioClient; + @Autowired + private TenCheckService tenCheckService; /* @@ -575,6 +577,14 @@ public class DeviceApiServiceImpl implements DeviceApiService { // log.info("保存记录:----------------------"+record.getRecordTime()+"-"+record.getMemberId().intValue()); tenRecordService.saveForFace(record); + // 考勤记录,没有删除的人记录考勤 + TenPersonEntity memberEntity = tenPersonService.getById(personId,cellEntity.getCellId()); + if(memberEntity!=null){ + if(memberEntity.getDeleteFlag().intValue() == 0){ + tenCheckService.saveCheck(memberEntity,record); + } + } + Result res = new Result(); String resContent = JSONObject.toJSONString(res); MyMessage message = new MyMessage(CmdConstant.CMD_UPRECORD,resContent.getBytes().length,resContent.getBytes()); diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenCheckController.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenCheckController.java new file mode 100644 index 0000000..2d72249 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenCheckController.java @@ -0,0 +1,539 @@ +package net.shapelight.modules.ten.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import net.shapelight.common.config.GlobalValue; +import net.shapelight.common.utils.Constant; +import net.shapelight.common.utils.PageUtils; +import net.shapelight.common.utils.R; +import net.shapelight.modules.sys.controller.AbstractController; +import net.shapelight.modules.ten.entity.TenCheckEntity; +import net.shapelight.modules.ten.entity.TenCheckScheduleEntity; +import net.shapelight.modules.ten.entity.TenRecordEntity; +import net.shapelight.modules.ten.service.TenCheckScheduleService; +import net.shapelight.modules.ten.service.TenCheckService; +import net.shapelight.modules.ten.service.TenRecordService; +import net.shapelight.modules.ten.vo.AttendanceDayVo; +import net.shapelight.modules.ten.vo.TenCheckMemberCountVo; +import org.apache.poi.hssf.usermodel.*; +import org.apache.poi.ss.usermodel.BorderStyle; +import org.apache.poi.ss.usermodel.FillPatternType; +import org.apache.poi.ss.usermodel.HorizontalAlignment; +import org.apache.poi.ss.usermodel.IndexedColors; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + + +/** + * + * + */ +@RestController +@RequestMapping("ten/check") +@Api(value="考勤记录",tags={"考勤记录"}) +@Slf4j +public class TenCheckController extends AbstractController { + @Autowired + private TenCheckService tenCheckService; + @Autowired + private TenRecordService tenRecordService; + @Autowired + private TenCheckScheduleService tenCheckScheduleService; + @Autowired + private HttpServletResponse response; + @Autowired + private GlobalValue globalValue; + + /** + * 列表 + */ + @GetMapping("/list") + @RequiresPermissions("ten:check:list") + @ApiOperation(value = "考勤记录列表",response = TenCheckEntity.class) + @ApiImplicitParams({ + @ApiImplicitParam(name="limit",value = "每页条数",paramType = "query",dataType = "String",required = true), + @ApiImplicitParam(name="page",value = "页码",paramType = "query",dataType = "String",required = true), + @ApiImplicitParam(name="memberName",value = "姓名",paramType = "query",dataType = "String",required = true), + @ApiImplicitParam(name="memberId",value = "姓名id",paramType = "query",dataType = "String",required = true), + @ApiImplicitParam(name="dateStart",value = "日期开始",paramType = "query",dataType = "String",required = true), + @ApiImplicitParam(name="dateEnd",value = "日期结束",paramType = "query",dataType = "String",required = true), + @ApiImplicitParam(name="deptId",value = "部门id多个,逗号隔开",paramType = "query",dataType = "String",required = true), + @ApiImplicitParam(name="jobNumber",value = "工号",paramType = "query",dataType = "String",required = true), + @ApiImplicitParam(name="checkDay",value = "星期",paramType = "query",dataType = "String",required = true), + + }) + public R list(@RequestParam Map params){ + params.put("tenantId",getUser().getTenantId()); + PageUtils page = tenCheckService.queryPage(params); + return R.ok().put("data", page); + } + + + /** + * 考勤详细信息,所有考勤识别记录 + */ + @GetMapping("/checkDetail/{checkId}") + @RequiresPermissions("ten:check:list") + @ApiOperation(value = "考勤详细信息,所有考勤识别记录",response = TenRecordEntity.class) + public R checkDetail(@PathVariable("checkId") Long checkId){ + Long tenantId = getUser().getTenantId(); + TenCheckEntity tenCheck = tenCheckService.getById(checkId); +// List recordIds = new ArrayList<>(); + List csList = tenCheckScheduleService.list( + new QueryWrapper() + .eq("check_id",tenCheck.getCheckId()) + ); + List records = new ArrayList<>(); + for(TenCheckScheduleEntity ss: csList){ +// recordIds.add(ss.getDutyOnRecordId()); +// recordIds.add(ss.getDutyOffRecordId()); + if (ss.getDutyOnRecordId()!=null) { + TenRecordEntity recordEntityOn = tenRecordService.getById(ss.getDutyOnRecordId(),tenantId); + if (recordEntityOn!=null) { + records.add(recordEntityOn); + } + } + if(ss.getDutyOffRecordId()!=null){ + TenRecordEntity recordEntityOff = tenRecordService.getById(ss.getDutyOffRecordId(),tenantId); + if(recordEntityOff!=null){ + records.add(recordEntityOff); + } + } + + } + +// for(TenRecordEntity recordEntity: records){ +// recordEntity.setRgb(recordEntity.getRgb()); +// } +// List records = new ArrayList<>(); + return R.ok().put("data", records); + } + + + + + /** + * 日考勤统计 + */ + @GetMapping("/attendanceDayList") + @RequiresPermissions("ten:check:list") + @ApiOperation(value = "日考勤统计",response = AttendanceDayVo.class) + @ApiImplicitParams({ + @ApiImplicitParam(name="limit",value = "每页条数",paramType = "query",dataType = "String",required = true), + @ApiImplicitParam(name="page",value = "页码",paramType = "query",dataType = "String",required = true), + @ApiImplicitParam(name="dateStart",value = "日期开始",paramType = "query",dataType = "String",required = true), + @ApiImplicitParam(name="dateEnt",value = "日期结束",paramType = "query",dataType = "String",required = true), + @ApiImplicitParam(name="deptId",value = "部门id多个,逗号隔开",paramType = "query",dataType = "String",required = true), + }) + public R attendanceDayList(@RequestParam Map params){ + params.put("tenantId",getUser().getTenantId()); + PageUtils page = tenCheckService.attendanceDayPage(params); + return R.ok().put("data", page); + } + + + + + + + + + + + /** + * 考勤人员统计 + */ + @GetMapping("/checkMemberCount") + @RequiresPermissions("ten:check:list") + @ApiOperation(value = "考勤人员统计",response = TenCheckMemberCountVo.class) + @ApiImplicitParams({ + @ApiImplicitParam(name="limit",value = "每页条数",paramType = "query",dataType = "String",required = true), + @ApiImplicitParam(name="page",value = "页码",paramType = "query",dataType = "String",required = true), + @ApiImplicitParam(name="memberName",value = "姓名",paramType = "query",dataType = "String",required = true), + @ApiImplicitParam(name="deptId",value = "部门id多个,逗号隔开",paramType = "query",dataType = "String",required = true), + @ApiImplicitParam(name="jobNumber",value = "工号",paramType = "query",dataType = "String",required = true), + @ApiImplicitParam(name="dateStart",value = "日期开始",paramType = "query",dataType = "String",required = true), + @ApiImplicitParam(name="dateEnt",value = "日期结束",paramType = "query",dataType = "String",required = true), + + }) + public R checkMemberCount(@RequestParam Map params){ + params.put("tenantId",getUser().getTenantId()); + PageUtils page = tenCheckService.findCheckMemberCount(params); + return R.ok().put("data", page); + } + + /** + * 查询正常签到 + */ + @GetMapping("/detailDutyOnOk") + @RequiresPermissions("ten:check:list") + @ApiOperation(value = "查询正常签到",response = TenCheckScheduleEntity.class) + @ApiImplicitParams({ + @ApiImplicitParam(name="memberId",value = "姓名Id",paramType = "query",dataType = "String",required = true), + @ApiImplicitParam(name="deptId",value = "部门id多个,逗号隔开",paramType = "query",dataType = "String",required = true), +// @ApiImplicitParam(name="jobNumber",value = "工号",paramType = "query",dataType = "String",required = true), + @ApiImplicitParam(name="dateStart",value = "日期开始",paramType = "query",dataType = "String",required = true), + @ApiImplicitParam(name="dateEnd",value = "日期结束",paramType = "query",dataType = "String",required = true), + }) + public R detailDutyOnOk(@RequestParam Map params){ + + params.put("status", Constant.CHECK_OK); + List onOK = tenCheckService.findDutyOnInfo(params); + for(TenCheckScheduleEntity schedule: onOK){ + TenCheckEntity check = tenCheckService.getById(schedule.getCheckId()); + check.setRgb(check.getRgb()); + schedule.setCheckEntity(check); + schedule.setCheckTime(schedule.getDutyOnTime()); + schedule.setStatusInfo(schedule.getDutyOnStatusInfo()); + } + return R.ok().put("data",onOK); + } + + /** + * 查询正常签退 + */ + @GetMapping("/detailDutyOffOk") + @RequiresPermissions("ten:check:list") + @ApiOperation(value = "查询正常签退",response = TenCheckMemberCountVo.class) + @ApiImplicitParams({ + @ApiImplicitParam(name="memberId",value = "姓名Id",paramType = "query",dataType = "String",required = true), + @ApiImplicitParam(name="deptId",value = "部门id多个,逗号隔开",paramType = "query",dataType = "String",required = true), +// @ApiImplicitParam(name="jobNumber",value = "工号",paramType = "query",dataType = "String",required = true), + @ApiImplicitParam(name="dateStart",value = "日期开始",paramType = "query",dataType = "String",required = true), + @ApiImplicitParam(name="dateEnd",value = "日期结束",paramType = "query",dataType = "String",required = true), + }) + public R detailDutyOffOk(@RequestParam Map params){ + + params.put("status", Constant.CHECK_OK); + List offOk = tenCheckService.findDutyOffInfo(params); + for(TenCheckScheduleEntity schedule: offOk){ + TenCheckEntity check = tenCheckService.getById(schedule.getCheckId()); + check.setRgb(check.getRgb()); + schedule.setCheckEntity(check); + schedule.setCheckTime(schedule.getDutyOffTime()); + schedule.setStatusInfo(schedule.getDutyOffStatusInfo()); + } + return R.ok().put("data",offOk); + } + + /** + * 查询迟到 + */ + @GetMapping("/detailDutyLate") + @RequiresPermissions("ten:check:list") + @ApiOperation(value = "查询迟到",response = TenCheckMemberCountVo.class) + @ApiImplicitParams({ + @ApiImplicitParam(name="memberId",value = "姓名Id",paramType = "query",dataType = "String",required = true), + @ApiImplicitParam(name="deptId",value = "部门id多个,逗号隔开",paramType = "query",dataType = "String",required = true), +// @ApiImplicitParam(name="jobNumber",value = "工号",paramType = "query",dataType = "String",required = true), + @ApiImplicitParam(name="dateStart",value = "日期开始",paramType = "query",dataType = "String",required = true), + @ApiImplicitParam(name="dateEnd",value = "日期结束",paramType = "query",dataType = "String",required = true), + }) + public R detailDutyLate(@RequestParam Map params){ + + params.put("status", Constant.CHECK_CHIDAO); + List onLate = tenCheckService.findDutyOnInfo(params); + for(TenCheckScheduleEntity schedule: onLate){ + TenCheckEntity check = tenCheckService.getById(schedule.getCheckId()); + check.setRgb(check.getRgb()); + schedule.setCheckEntity(check); + schedule.setCheckTime(schedule.getDutyOnTime()); + schedule.setStatusInfo(schedule.getDutyOnStatusInfo()); + } + return R.ok().put("data",onLate); + } + + + /** + * 查询早退 + */ + @GetMapping("/detailDutyEarly") + @RequiresPermissions("ten:check:list") + @ApiOperation(value = "查询早退",response = TenCheckMemberCountVo.class) + @ApiImplicitParams({ + @ApiImplicitParam(name="memberId",value = "姓名Id",paramType = "query",dataType = "String",required = true), + @ApiImplicitParam(name="deptId",value = "部门id多个,逗号隔开",paramType = "query",dataType = "String",required = true), +// @ApiImplicitParam(name="jobNumber",value = "工号",paramType = "query",dataType = "String",required = true), + @ApiImplicitParam(name="dateStart",value = "日期开始",paramType = "query",dataType = "String",required = true), + @ApiImplicitParam(name="dateEnd",value = "日期结束",paramType = "query",dataType = "String",required = true), + }) + public R detailDutyEarly(@RequestParam Map params){ + + params.put("status", Constant.CHECK_ZAOTUI); + List onEarly = tenCheckService.findDutyOffInfo(params); + for(TenCheckScheduleEntity schedule: onEarly){ + TenCheckEntity check = tenCheckService.getById(schedule.getCheckId()); + check.setRgb(check.getRgb()); + schedule.setCheckEntity(check); + schedule.setCheckTime(schedule.getDutyOffTime()); + schedule.setStatusInfo(schedule.getDutyOffStatusInfo()); + + } + return R.ok().put("data",onEarly); + } + + + + + + + + /** + * 下载考勤统计 + */ + @GetMapping("/checkMemberExcel") + @RequiresPermissions("ten:check:list") + @ApiOperation("下载考勤统计") + @ApiImplicitParams({ + @ApiImplicitParam(name="memberName",value = "姓名",paramType = "query",dataType = "String",required = true), + @ApiImplicitParam(name="deptId",value = "部门id多个,逗号隔开",paramType = "query",dataType = "String",required = true), + @ApiImplicitParam(name="jobNumber",value = "工号",paramType = "query",dataType = "String",required = true), + @ApiImplicitParam(name="dateStart",value = "日期开始",paramType = "query",dataType = "String",required = true), + @ApiImplicitParam(name="dateEnd",value = "日期结束",paramType = "query",dataType = "String",required = true), + @ApiImplicitParam(name="deptName",value = "部门名称",paramType = "query",dataType = "String",required = true), + }) + public void checkMemberExcel(@RequestParam Map params) { + String deptName = (String)params.get("deptName"); + String startTime = (String)params.get("dateStart"); + String endTime = (String)params.get("dateEnd"); + params.put("tenantId",getUser().getTenantId()); + + List dataList = tenCheckService.findCheckMemberCountList(params); + + + HSSFWorkbook workbook = new HSSFWorkbook(); + + HSSFCellStyle cellStyle = workbook.createCellStyle(); + cellStyle.setBorderBottom(BorderStyle.THIN); //下边框 + cellStyle.setBorderLeft(BorderStyle.THIN);//左边框 + cellStyle.setBorderTop(BorderStyle.THIN);//上边框 + cellStyle.setBorderRight(BorderStyle.THIN);//右边框 + + + HSSFCellStyle biaoTi1 = workbook.createCellStyle(); + biaoTi1.setAlignment(HorizontalAlignment.CENTER); // 居中 + HSSFFont font = workbook.createFont(); + font.setFontName("宋体"); + font.setFontHeightInPoints((short) 14);// 字体大小 + font.setBold(true); + biaoTi1.setFont(font); + + + HSSFCellStyle biaoTi2 = workbook.createCellStyle(); + HSSFFont font2 = workbook.createFont(); + font2.setFontName("宋体"); + font2.setFontHeightInPoints((short) 11);// 字体大小 + font2.setBold(true); + biaoTi2.setFont(font2); + + + HSSFCellStyle biaoTi3 = workbook.createCellStyle(); + biaoTi3.setBorderBottom(BorderStyle.THIN); //下边框 + biaoTi3.setBorderLeft(BorderStyle.THIN);//左边框 + biaoTi3.setBorderTop(BorderStyle.THIN);//上边框 + biaoTi3.setBorderRight(BorderStyle.THIN);//右边框 + biaoTi3.setFillForegroundColor(IndexedColors.GREY_40_PERCENT.index); + biaoTi3.setFillPattern(FillPatternType.SOLID_FOREGROUND); + + + HSSFCellStyle juzhong = workbook.createCellStyle(); + //垂直居中 + juzhong.setVerticalAlignment(juzhong.getVerticalAlignmentEnum().CENTER); + + + HSSFCellStyle biaoTiRiQi = workbook.createCellStyle(); + biaoTiRiQi.setBorderBottom(BorderStyle.THIN); //下边框 + biaoTiRiQi.setBorderLeft(BorderStyle.THIN);//左边框 + biaoTiRiQi.setBorderTop(BorderStyle.THIN);//上边框 + biaoTiRiQi.setBorderRight(BorderStyle.THIN);//右边框 + biaoTiRiQi.setFillForegroundColor(IndexedColors.GREY_40_PERCENT.index); + biaoTiRiQi.setFillPattern(FillPatternType.SOLID_FOREGROUND); + + + HSSFSheet sheet = workbook.createSheet("考勤统计"); + //第一行 + HSSFRow row1 = sheet.createRow(0); + //第一单元格 + HSSFCell cell = row1.createCell(0); + //设置单元格内容 + cell.setCellValue("考勤统计"); + //合并单元格CellRangeAddress构造参数依次表示起始行,截至行,起始列, 截至列 + // 合并单元格 + CellRangeAddress cellRangeBiaoti = new CellRangeAddress(0, 0, 0, 10); // 起始行, 终止行, 起始列, 终止列 + sheet.addMergedRegion(cellRangeBiaoti); + cell.setCellStyle(biaoTi1); + + + // 第二行 + HSSFRow row2 = sheet.createRow(1); + //创建单元格并设置单元格内容 + HSSFCell cellProjectName = row2.createCell(0); + cellProjectName.setCellValue("部门:" + deptName); + cellProjectName.setCellStyle(biaoTi2); + + // 第三行 + HSSFRow row3 = sheet.createRow(2); + //创建单元格并设置单元格内容 + HSSFCell cellDateUnit = row3.createCell(0); + cellDateUnit.setCellValue("时间段:" + startTime + " - " + endTime); + cellDateUnit.setCellStyle(biaoTi2); + + // 第四行 + HSSFRow row4 = sheet.createRow(3); + //创建单元格并设置单元格内容 + HSSFCell xingming = row4.createCell(0); + xingming.setCellValue("姓名"); +// CellRangeAddress cellRangeXingming = new CellRangeAddress(3, 4, 0, 0); +// sheet.addMergedRegion(cellRangeXingming); + xingming.setCellStyle(biaoTi3); +// ExcelUtil.setCellRangeBorder(BorderStyle.THIN, cellRangeXingming, sheet); + + HSSFCell deptNamecell = row4.createCell(1); + deptNamecell.setCellValue("部门"); +// CellRangeAddress cellRangeDeptName = new CellRangeAddress(3, 4, 1, 1); +// sheet.addMergedRegion(cellRangeDeptName); + deptNamecell.setCellStyle(biaoTi3); + + HSSFCell jobNumber = row4.createCell(2); + jobNumber.setCellValue("工号"); +// CellRangeAddress cellRangejobNumber = new CellRangeAddress(3, 4, 2, 2); +// sheet.addMergedRegion(cellRangejobNumber); + jobNumber.setCellStyle(biaoTi3); + + HSSFCell idNumber = row4.createCell(3); + idNumber.setCellValue("身份证号"); +// CellRangeAddress cellRangejobNumber = new CellRangeAddress(3, 4, 2, 2); +// sheet.addMergedRegion(cellRangejobNumber); + idNumber.setCellStyle(biaoTi3); + + HSSFCell checkDays = row4.createCell(4); + checkDays.setCellValue("出勤天数"); +// CellRangeAddress cellRangecheckDays = new CellRangeAddress(3, 4, 3, 3); +// sheet.addMergedRegion(cellRangecheckDays); + checkDays.setCellStyle(biaoTi3); + + HSSFCell dutyOnOkCell = row4.createCell(5); + dutyOnOkCell.setCellValue("正常签到"); +// CellRangeAddress cellRangeDutyOnOk = new CellRangeAddress(3, 4, 4, 4); +// sheet.addMergedRegion(cellRangeDutyOnOk); + dutyOnOkCell.setCellStyle(biaoTi3); + + HSSFCell dutyOnLateCell = row4.createCell(6); + dutyOnLateCell.setCellValue("迟到"); +// CellRangeAddress cellRangeWubie = new CellRangeAddress(3, 4, 5, 5); +// sheet.addMergedRegion(cellRangeWubie); + dutyOnLateCell.setCellStyle(biaoTi3); + + HSSFCell dutyOnNoCell = row4.createCell(7); + dutyOnNoCell.setCellValue("未签到"); +// CellRangeAddress cellRangeOnNo = new CellRangeAddress(3, 4, 6, 6); +// sheet.addMergedRegion(cellRangeOnNo); + dutyOnNoCell.setCellStyle(biaoTi3); + + + HSSFCell dutyOffOkCell = row4.createCell(8); + dutyOffOkCell.setCellValue("正常签退"); +// CellRangeAddress cellRangeDutyOffOk = new CellRangeAddress(3, 4, 7, 7); +// sheet.addMergedRegion(cellRangeDutyOffOk); + dutyOffOkCell.setCellStyle(biaoTi3); + + HSSFCell dutyOnEarlyCell = row4.createCell(9); + dutyOnEarlyCell.setCellValue("早退"); +// CellRangeAddress cellRangeearly = new CellRangeAddress(3, 4, 8, 8); +// sheet.addMergedRegion(cellRangeearly); + dutyOnEarlyCell.setCellStyle(biaoTi3); + + HSSFCell dutyOffNoCell = row4.createCell(10); + dutyOffNoCell.setCellValue("未签退"); +// CellRangeAddress cellRangeOffNo = new CellRangeAddress(3, 4, 9, 9); +// sheet.addMergedRegion(cellRangeOffNo); + dutyOffNoCell.setCellStyle(biaoTi3); + + + + //创建数据行 + for(int i = 0;i params){ + String tenantId = getUser().getTenantId() + ""; + params.put("tenantId", tenantId + ""); + SysUserEntity user = getUser(); + List roleIdList = sysUserRoleService.queryRoleIdList(user.getUserId()); + //小区管理员 + if (roleIdList.get(0).longValue() == Constant.ROLE_TEN_CELL) { + TenUserScopeEntity scope = tenUserScopeService.getOne(new QueryWrapper().eq("user_id", user.getUserId())); + params.put("cellId", scope.getCellId().toString()); + }else{ + return R.error("您无权访问"); + } + PageUtils page = tenRuleService.queryPage(params); + + return R.ok().put("data", page); + } + + + /** + * 信息 + */ + @GetMapping("/info/{ruleId}") + @RequiresPermissions("ten:rule") + @ApiOperation(value = "考勤规则详细信息",response = TenRuleEntity.class) + public R info(@PathVariable("ruleId") Long ruleId){ + TenRuleEntity ruleEntity = tenRuleService.getById(ruleId); + List scheduleEntityList = tenScheduleService.list( + new QueryWrapper() + .eq("rule_id",ruleEntity.getRuleId()) +// .eq("tenant_id",ruleEntity.getTenantId()) + ); + ruleEntity.setScheduleEntityList(scheduleEntityList); + return R.ok().put("data", ruleEntity); + } + + /** + * 保存 + */ + @PostMapping("/save") + @RequiresPermissions("ten:rule") + @ApiOperation(value = "添加") + public R save(@RequestBody TenRuleEntity tenRule){ + SysUserEntity user = getUser(); + List roleIdList = sysUserRoleService.queryRoleIdList(user.getUserId()); + //小区管理员 + if (roleIdList.get(0).longValue() == Constant.ROLE_TEN_CELL) { + TenUserScopeEntity scope = tenUserScopeService.getOne(new QueryWrapper().eq("user_id", user.getUserId())); + tenRule.setCellId(scope.getCellId()); + tenRule.getScheduleEntityList().get(0).setCellId(scope.getCellId()); + }else{ + return R.error("您无权访问"); + } +// tenRuleService.save(tenRule); + TenScheduleEntity scheduleEntity = tenRule.getScheduleEntityList().get(0); + int onTime = MyDateUtils.getSeconds(scheduleEntity.getDutyOn()); + int offTime = MyDateUtils.getSeconds(scheduleEntity.getDutyOff()); + int chidaoTime = onTime + scheduleEntity.getLateTime() * 60; + int zaotuiTime = offTime - scheduleEntity.getEarlyTime() * 60; + int onBegin = MyDateUtils.getSeconds(scheduleEntity.getOnBegin()); + int onEnd = MyDateUtils.getSeconds(scheduleEntity.getOnEnd()); + int offBegin = MyDateUtils.getSeconds(scheduleEntity.getOffBegin()); + int offEnd = MyDateUtils.getSeconds(scheduleEntity.getOffEnd()); + + if(onTime>offTime){ + return R.error("上班时间不能再当天里晚于下班时间"); + } + if (onBegin>onTime) { + return R.error("上班最早打卡时间必须在上班时间之前"); + } + if(offEndoffTime){ + return R.error("迟到时间必须在下班时间之前"); + } + if(zaotuiTimezaotuiTime){ + return R.error("迟到时间必须在早退时间之前"); + } + if(onEnd>offBegin){ + return R.error("上班最晚打卡时间必须在下班最早打卡时间之前"); + } + if(onEndzaotuiTime){ + return R.error("下班最早打卡时间必须在早退时间之后"); + } + Date now = new Date(); + tenRule.setTenantId(getUser().getTenantId()); + tenRule.setCreateBy(getUser().getUsername()); + tenRule.setCreateTime(now); + tenRule.setLastUpdateBy(getUser().getUsername()); + tenRule.setLastUpdateTime(now); + tenRuleService.saveTr(tenRule); + return R.ok(); + } + + /** + * 修改 + */ + @PostMapping("/update") + @RequiresPermissions("ten:rule") + @ApiOperation(value = "修改") + public R update(@RequestBody TenRuleEntity tenRule){ + tenRule.setLastUpdateBy(getUser().getUsername()); + tenRule.setLastUpdateTime(new Date()); + tenRuleService.updateByIdTr(tenRule); + + return R.ok(); + } + + /** + * 删除 + */ + @PostMapping("/delete") + @RequiresPermissions("ten:rule") + @ApiOperation(value = "删除") + public R delete(@RequestBody Long[] ruleIds){ + tenRuleService.removeByIds(Arrays.asList(ruleIds)); + for(Long ruleId: ruleIds){ + tenScheduleService.remove(new QueryWrapper() + .eq("rule_id",ruleId)); + } + return R.ok(); + } + + + @GetMapping("/getDeptTree") + @RequiresPermissions("ten:rule") + public R getDeptTree(){ + SysUserEntity user = getUser(); + List roleIdList = sysUserRoleService.queryRoleIdList(user.getUserId()); + Long cellId = new Long(0l); + //小区管理员 + if (roleIdList.get(0).longValue() == Constant.ROLE_TEN_CELL) { + TenUserScopeEntity scope = tenUserScopeService.getOne(new QueryWrapper().eq("user_id", user.getUserId())); + cellId = scope.getCellId(); + }else{ + return R.error("您无权访问"); + } + List page = tenCellDeptService.list(new QueryWrapper() + .eq("cell_id",cellId)); + for(TenCellDeptEntity cellDeptEntity: page){ + if(cellDeptEntity.getChildrenList().size() == 0){ + cellDeptEntity.setHasChildren(false); + } + } + JSONArray dataTree = TreeUtils.listToTree(JSONArray.parseArray(JSON.toJSONString(page)),"deptId","parentId","childrenList"); + return R.ok().put("data", dataTree); + } + +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenCheckDao.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenCheckDao.java new file mode 100644 index 0000000..d035f91 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenCheckDao.java @@ -0,0 +1,39 @@ +package net.shapelight.modules.ten.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import net.shapelight.modules.ten.entity.TenCheckEntity; +import net.shapelight.modules.ten.entity.TenCheckScheduleEntity; +import net.shapelight.modules.ten.vo.AttendanceDayVo; +import net.shapelight.modules.ten.vo.TenCheckMemberCountVo; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + +/** + * + * + */ +@Mapper +public interface TenCheckDao extends BaseMapper { + + IPage findCheckMemberCount(Page page, @Param("params") Map params); + + IPage findMemberCheckList(Page page, @Param("params") Map params); + + List findCheckMemberList(@Param("params") Map params); + + Integer findDutyOnCount(@Param("params") Map params); + List findDutyOnInfo(@Param("params") Map params); + + Integer findDutyOffCount(@Param("params") Map params); + List findDutyOffInfo(@Param("params") Map params); + + + IPage findAttendanceDayPage(Page page, @Param("params") Map params); + + +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenCheckScheduleDao.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenCheckScheduleDao.java new file mode 100644 index 0000000..135b582 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenCheckScheduleDao.java @@ -0,0 +1,14 @@ +package net.shapelight.modules.ten.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import net.shapelight.modules.ten.entity.TenCheckScheduleEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * + * + */ +@Mapper +public interface TenCheckScheduleDao extends BaseMapper { + +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenPersonDao.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenPersonDao.java index 75b5960..e431314 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenPersonDao.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenPersonDao.java @@ -112,7 +112,7 @@ public interface TenPersonDao { IPage selectByDeptId(Page page,@Param("deptId")Long deptId, @Param("cellId")Long cellId, @Param("key")String key); IPage selectByDeptIdForGuest(Page page,@Param("deptId")Long deptId, @Param("cellId")Long cellId, @Param("key")String key); - + TenPersonEntity getByIdWithDelete(@Param("personId")Long personId); } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenRuleDao.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenRuleDao.java new file mode 100644 index 0000000..5e2d873 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenRuleDao.java @@ -0,0 +1,14 @@ +package net.shapelight.modules.ten.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import net.shapelight.modules.ten.entity.TenRuleEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * + * + */ +@Mapper +public interface TenRuleDao extends BaseMapper { + +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenScheduleDao.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenScheduleDao.java new file mode 100644 index 0000000..1b36720 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenScheduleDao.java @@ -0,0 +1,14 @@ +package net.shapelight.modules.ten.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import net.shapelight.modules.ten.entity.TenScheduleEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * + * + */ +@Mapper +public interface TenScheduleDao extends BaseMapper { + +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenCheckEntity.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenCheckEntity.java new file mode 100644 index 0000000..93b5e52 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenCheckEntity.java @@ -0,0 +1,133 @@ +package net.shapelight.modules.ten.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +/** + * + * + */ +@Data +@TableName("ten_check") +public class TenCheckEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId + @ApiModelProperty("id") + private Long checkId; + /** + * 人员id + */ + @ApiModelProperty("人员id") + private Long memberId; + /** + * 考勤规则id + */ + @ApiModelProperty("考勤规则id") + private Long ruleId; + /** + * 打卡日期 + */ + @ApiModelProperty("打卡日期") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date checkDate; + /** + * 星期几1,2,3,4,5,6,7 + */ + @ApiModelProperty("星期几") + private Integer checkDay; + /** + * 姓名 + */ + @ApiModelProperty("姓名") + private String memberName; + /** + * 0没有1女2男 + */ + @ApiModelProperty("0没有1女2男") + private Integer gender; + /** + * 手机 + */ + @ApiModelProperty("手机") + private String mobile; + /** + * 工号 + */ + @ApiModelProperty("工号") + private String jobNumber; + /** + * 职位 + */ + @ApiModelProperty("职位") + private String position; + /** + * ic卡号 + */ + @ApiModelProperty("ic卡号") + private String icNumber; + /** + * 身份证号 + */ + @ApiModelProperty("身份证号") + private String idNumber; + /** + * 部门id + */ + @ApiModelProperty("部门id") + private Long deptId; + /** + * rgb + */ + @ApiModelProperty("rgb头像") + private String rgb; + /** + * 部门名称 + */ + @ApiModelProperty("部门名称") + private String deptName; +// + @ApiModelProperty("打卡信息") + @TableField(exist = false) + private String checkScheduleInfo; + + @ApiModelProperty("打卡详细信息") + @TableField(exist = false) + private List checkScheduleList; + + @ApiModelProperty("规则名称") + @TableField(exist = false) + private String ruleName; + + @ApiModelProperty("考勤星期") + @TableField(exist = false) + private String days; + + @ApiModelProperty("考勤时间段") + @TableField(exist = false) + private String schedules; + + @JsonSerialize(using = ToStringSerializer.class) + private Long tenantId; + + /** + * 小区ID + */ + @ApiModelProperty("小区ID") + @JsonSerialize(using = ToStringSerializer.class) + private Long cellId; + +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenCheckScheduleEntity.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenCheckScheduleEntity.java new file mode 100644 index 0000000..fdda8fa --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenCheckScheduleEntity.java @@ -0,0 +1,103 @@ +package net.shapelight.modules.ten.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.sql.Time; + +/** + * + * + */ +@Data +@TableName("ten_check_schedule") +public class TenCheckScheduleEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId + @ApiModelProperty("id") + private Long checkScheduleId; + /** + * 打卡id + */ + @ApiModelProperty("打卡id") + private Long checkId; + /** + * 班次序列号1,2,3 + */ + @ApiModelProperty("班次序列号1,2,3") + private Integer scheduleIndex; + /** + * 上班识别记录id + */ + @ApiModelProperty("上班识别记录id") + private Long dutyOnRecordId; + /** + * 下班识别记录id + */ + @ApiModelProperty("下班识别记录id") + private Long dutyOffRecordId; + /** + * 上班识别时间 + */ + @ApiModelProperty("上班识别时间") + @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+8") + private Time dutyOnTime; + /** + * 下班识别时间 + */ + @ApiModelProperty("下班识别时间") + @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+8") + private Time dutyOffTime; + /** + * 上班状态0缺卡1正常2迟到 + */ + @ApiModelProperty("上班状态0缺卡1正常2迟到") + private Integer dutyOnStatus; + /** + * 上班状态信息 + */ + @ApiModelProperty("上班状态信息") + private String dutyOnStatusInfo; + /** + * 下班状态0缺卡1正常3早退 + */ + @ApiModelProperty("下班状态0缺卡1正常3早退") + private Integer dutyOffStatus; + /** + * 下班状态信息 + */ + @ApiModelProperty("下班状态信息") + private String dutyOffStatusInfo; + + @TableField(exist = false) + private TenCheckEntity checkEntity; + + @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+8") + @TableField(exist = false) + private Time checkTime; + + @TableField(exist = false) + private String statusInfo; + + @JsonSerialize(using = ToStringSerializer.class) + private Long tenantId; + + /** + * 小区ID + */ + @ApiModelProperty("小区ID") + @JsonSerialize(using = ToStringSerializer.class) + private Long cellId; + +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenRuleEntity.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenRuleEntity.java new file mode 100644 index 0000000..a5d340f --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenRuleEntity.java @@ -0,0 +1,75 @@ +package net.shapelight.modules.ten.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import net.shapelight.common.base.BaseEntity; + +import java.io.Serializable; +import java.util.List; + +/** + * + * + */ +@Data +@TableName("ten_rule") +public class TenRuleEntity extends BaseEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId + @ApiModelProperty("id") + private Long ruleId; + /** + * 规则名称 + */ + @ApiModelProperty("规则名称") + private String ruleName; + /** + * 班次1,2,3 + */ + @ApiModelProperty("班次1,2,3") + private Integer ruleType; + /** + * 星期几1,2,3,4,5,6,7 + */ + @ApiModelProperty("星期几1,2,3,4,5,6,7") + private String days; + /** + * 部门id数组 + */ + @ApiModelProperty("部门id数组") + private String deptIds; + + @ApiModelProperty("班次列表") + @TableField(exist = false) + private List scheduleEntityList; + + @ApiModelProperty("部门信息") + @TableField(exist = false) + private String deptNames; + + @ApiModelProperty("人数") + @TableField(exist = false) + private Integer memberCount; + + @JsonSerialize(using = ToStringSerializer.class) + private Long tenantId; + + /** + * 小区ID + */ + @ApiModelProperty("小区ID") + @JsonSerialize(using = ToStringSerializer.class) + private Long cellId; + + + +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenScheduleEntity.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenScheduleEntity.java new file mode 100644 index 0000000..d97e879 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenScheduleEntity.java @@ -0,0 +1,105 @@ +package net.shapelight.modules.ten.entity; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.sql.Time; + +/** + * + * + */ +@Data +@TableName("ten_schedule") +public class TenScheduleEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId + @ApiModelProperty("id") + private Long scheduleId; + /** + * 考勤规则id + */ + @ApiModelProperty("考勤规则id") + private Long ruleId; + /** + * 班次序号 + */ + @ApiModelProperty("班次序号") + private Integer scheduleIndex; + /** + * 上班时间 + */ + @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+8") + @ApiModelProperty("上班时间") + private Time dutyOn; + /** + * 下班时间 + */ + @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+8") + @ApiModelProperty("下班时间") + private Time dutyOff; + /** + * 迟到时间 + */ + @ApiModelProperty("迟到时间") + private Integer lateTime; + /** + * 早退时间 + */ + @ApiModelProperty("早退时间") + private Integer earlyTime; + /** + * 上班最早签到时间 + */ + @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+8") + @ApiModelProperty("上班最早签到时间") + private Time onBegin; + /** + * 上班最晚签到时间 + */ + @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+8") + @ApiModelProperty("上班最晚签到时间") + private Time onEnd; + /** + * 下班最早签退时间 + */ + @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+8") + @ApiModelProperty("下班最早签退时间") + private Time offBegin; + /** + * 下班最晚签退时间 + */ + @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+8") + @ApiModelProperty("下班最晚签退时间") + private Time offEnd; + /** + * 上班是否打卡 + */ + @ApiModelProperty("上班是否打卡") + private Integer onCheckFlag; + /** + * 下班是否打卡 + */ + @ApiModelProperty("下班是否打卡") + private Integer offCheckFlag; + + @JsonSerialize(using = ToStringSerializer.class) + private Long tenantId; + + /** + * 小区ID + */ + @ApiModelProperty("小区ID") + @JsonSerialize(using = ToStringSerializer.class) + private Long cellId; +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenCheckScheduleService.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenCheckScheduleService.java new file mode 100644 index 0000000..16746bf --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenCheckScheduleService.java @@ -0,0 +1,17 @@ +package net.shapelight.modules.ten.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import net.shapelight.common.utils.PageUtils; +import net.shapelight.modules.ten.entity.TenCheckScheduleEntity; + +import java.util.Map; + +/** + * + * + */ +public interface TenCheckScheduleService extends IService { + + PageUtils queryPage(Map params); +} + diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenCheckService.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenCheckService.java new file mode 100644 index 0000000..51da881 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenCheckService.java @@ -0,0 +1,39 @@ +package net.shapelight.modules.ten.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import net.shapelight.common.utils.PageUtils; +import net.shapelight.modules.ten.entity.TenCheckEntity; +import net.shapelight.modules.ten.entity.TenCheckScheduleEntity; +//import net.shapelight.modules.ten.entity.TenMemberEntity; +import net.shapelight.modules.ten.entity.TenPersonEntity; +import net.shapelight.modules.ten.entity.TenRecordEntity; +import net.shapelight.modules.ten.vo.TenCheckMemberCountVo; + +import java.util.List; +import java.util.Map; + +/** + * + * + */ +public interface TenCheckService extends IService { + + PageUtils queryPage(Map params); + + TenCheckEntity findMemberCheck(Long memberId, String checkDate); + + void saveCheck(TenPersonEntity member, TenRecordEntity record); + + PageUtils findCheckMemberCount(Map params); + List findCheckMemberCountList(Map params); + + int findDutyOnCount(Map params); + List findDutyOnInfo(Map params); + + int findDutyOffCount(Map params); + List findDutyOffInfo(Map params); + + PageUtils attendanceDayPage(Map params); + +} + diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenPersonService.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenPersonService.java index f8fad57..8571635 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenPersonService.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenPersonService.java @@ -140,5 +140,7 @@ public interface TenPersonService { PageUtils selectByDeptIdQueryPage(Map params); PageUtils selectByDeptIdForGuestQueryPage(Map params); + TenPersonEntity getByIdWithDelete(Long id); + } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenRuleService.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenRuleService.java new file mode 100644 index 0000000..72fc040 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenRuleService.java @@ -0,0 +1,33 @@ +package net.shapelight.modules.ten.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import net.shapelight.common.utils.PageUtils; +import net.shapelight.modules.ten.entity.TenRuleEntity; + +import java.util.Map; + +/** + * + * + */ +public interface TenRuleService extends IService { + + PageUtils queryPage(Map params); + + boolean saveTr(TenRuleEntity entity); + + boolean updateByIdTr(TenRuleEntity entity); + + boolean removeByIdsTr(Long[] ruleIds); + + /** + * + * @param memberId 人员id + * @param week 星期 + * @return + */ + TenRuleEntity findMemberRules(Long memberId, Long cellId, Integer week); + + +} + diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenScheduleService.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenScheduleService.java new file mode 100644 index 0000000..dd3e142 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenScheduleService.java @@ -0,0 +1,17 @@ +package net.shapelight.modules.ten.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import net.shapelight.common.utils.PageUtils; +import net.shapelight.modules.ten.entity.TenScheduleEntity; + +import java.util.Map; + +/** + * + * + */ +public interface TenScheduleService extends IService { + + PageUtils queryPage(Map params); +} + diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenCheckScheduleServiceImpl.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenCheckScheduleServiceImpl.java new file mode 100644 index 0000000..40f7d01 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenCheckScheduleServiceImpl.java @@ -0,0 +1,29 @@ +package net.shapelight.modules.ten.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import net.shapelight.common.utils.PageUtils; +import net.shapelight.common.utils.Query; +import net.shapelight.modules.ten.dao.TenCheckScheduleDao; +import net.shapelight.modules.ten.entity.TenCheckScheduleEntity; +import net.shapelight.modules.ten.service.TenCheckScheduleService; +import org.springframework.stereotype.Service; + +import java.util.Map; + + +@Service("tenCheckScheduleService") +public class TenCheckScheduleServiceImpl extends ServiceImpl implements TenCheckScheduleService { + + @Override + public PageUtils queryPage(Map params) { + IPage page = this.page( + new Query().getPage(params), + new QueryWrapper() + ); + + return new PageUtils(page); + } + +} \ No newline at end of file diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenCheckServiceImpl.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenCheckServiceImpl.java new file mode 100644 index 0000000..418fc38 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenCheckServiceImpl.java @@ -0,0 +1,562 @@ +package net.shapelight.modules.ten.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import net.shapelight.common.config.GlobalValue; +import net.shapelight.common.utils.Constant; +import net.shapelight.common.utils.DateUtils; +import net.shapelight.common.utils.PageUtils; +import net.shapelight.modules.ten.dao.TenCheckDao; +import net.shapelight.modules.ten.entity.*; +import net.shapelight.modules.ten.service.*; +import net.shapelight.modules.ten.vo.AttendanceDayVo; +import net.shapelight.modules.ten.vo.TenCheckMemberCountVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.sql.Time; +import java.text.SimpleDateFormat; +import java.time.LocalTime; +import java.time.ZoneId; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +@Service("tenCheckService") +public class TenCheckServiceImpl extends ServiceImpl implements TenCheckService { + + @Autowired + private TenCheckScheduleService tenCheckScheduleService; + @Autowired + private TenRuleService tenRuleService; + @Autowired + private TenScheduleService tenScheduleService; + @Autowired + private TenCellDeptService tenCellDeptService; + @Autowired + private GlobalValue globalValue; + @Autowired + private TenPersonService tenPersonService; + + + /** + * 考勤记录 + */ + @Override + public PageUtils queryPage(Map params) { + String deptId = (String) params.get("deptId"); +// +// List depts = new ArrayList<>(); +// if(StringUtils.isNotBlank(deviceId)){ +// depts = tenDeptService.getSubDeptIdList(Long.parseLong(deviceId)); +// depts.add(Long.parseLong(deviceId)); +// } +// IPage page = this.page( +// new Query().getPage(params), +// new QueryWrapper() +// .eq("tenant_id",params.get("tenantId")) +// .eq(StringUtils.isNotBlank((String) params.get("memberId")), "member_Id", params.get("memberId")) +// .like(StringUtils.isNotBlank((String) params.get("memberName")), "member_name", params.get("memberName")) +// .ge(StringUtils.isNotBlank((String) params.get("dateStart")), "check_date", params.get("dateStart")) +// .le(StringUtils.isNotBlank((String) params.get("dateEnd")), "check_date", params.get("dateEnd")) +// .in(depts.size()>0, "dept_id", depts) +// .like(StringUtils.isNotBlank((String) params.get("jobNumber")), "job_number", params.get("jobNumber")) +// .eq(StringUtils.isNotBlank((String) params.get("checkDay")), "check_day", params.get("checkDay")) +// .orderByDesc("check_date") +// ); +// if (depts.size()>0) { +// params.put("deptIds",depts); +// } + Page pageParam = new Page(); + pageParam.setCurrent(Long.parseLong((String) params.get("page"))); + pageParam.setSize(Long.parseLong((String) params.get("limit"))); + IPage page = baseMapper.findMemberCheckList(pageParam,params); + for (TenCheckEntity checkEntity : page.getRecords()) { + List checkSchedules = tenCheckScheduleService.list( + new QueryWrapper() + .eq("check_id", checkEntity.getCheckId()) + .orderByAsc("schedule_index") + ); + StringBuffer info = new StringBuffer(); + for (TenCheckScheduleEntity cs : checkSchedules) { + //上班状态0缺卡1正常2迟到 + if (cs.getDutyOnStatus().intValue() != 0) { + info.append("签到:" + cs.getDutyOnTime() + " " + cs.getDutyOnStatusInfo() + ","); + } + //下班状态0缺卡1正常3早退 + if (cs.getDutyOffStatus().intValue() != 0) { + info.append("签退:" + cs.getDutyOffTime() + " " + cs.getDutyOffStatusInfo() + ","); + } + } + checkEntity.setCheckScheduleInfo(info.toString()); + TenRuleEntity ruleEntity = tenRuleService.getById(checkEntity.getRuleId()); + if(ruleEntity!=null){ + checkEntity.setRuleName(ruleEntity.getRuleName()); + checkEntity.setDays(ruleEntity.getDays()); + + List schedules = tenScheduleService.list( + new QueryWrapper() + .eq("rule_id",ruleEntity.getRuleId()) + ); + StringBuffer schBuf = new StringBuffer(); + for(TenScheduleEntity schedule: schedules){ + schBuf.append(schedule.getDutyOn()+"-"+schedule.getDutyOff()+","); + } + checkEntity.setSchedules(schBuf.toString()); + }else{ + checkEntity.setRuleName(""); + checkEntity.setDays(""); + checkEntity.setSchedules(""); + } +// checkEntity.setRgb(globalValue.getFileUrl()+checkEntity.getRgb()); + checkEntity.setRgb(checkEntity.getRgb()); + } + return new PageUtils(page); + } + + + @Override + public PageUtils attendanceDayPage(Map params) { +// String dateStart = (String) params.get("dateStart"); +// String dateEnd = (String) params.get("dateEnd"); + String deptId = (String) params.get("deptId"); + Page pageParam = new Page(); + pageParam.setCurrent(Long.parseLong((String) params.get("page"))); + pageParam.setSize(Long.parseLong((String) params.get("limit"))); + IPage page = baseMapper.findAttendanceDayPage(pageParam, params); + for(AttendanceDayVo vo: page.getRecords()){ + Map p = new HashMap<>(); + p.put("deptId",deptId); + String date = DateUtils.format(vo.getCheckDate(), DateUtils.DATE_DAY); + p.put("dateStart",date); + p.put("dateEnd",date); + p.put("status", Constant.CHECK_OK); + p.put("tenantId",params.get("tenantId")); + Integer dutyOnOkCount = baseMapper.findDutyOnCount(p); + vo.setDutyOnOkCount(dutyOnOkCount); + + Integer dutyOffOkCount = baseMapper.findDutyOffCount(p); + vo.setDutyOffOkCount(dutyOffOkCount); + + p.put("status", Constant.CHECK_CHIDAO); + Integer dutyOnLateCount = baseMapper.findDutyOnCount(p); + vo.setDutyOnLateCount(dutyOnLateCount); + + p.put("status", Constant.CHECK_ZAOTUI); + Integer dutyOnEarlyCount = baseMapper.findDutyOffCount(p); + vo.setDutyOffEarlyCount(dutyOnEarlyCount); + } + return new PageUtils(page); + } + + + + + @Override + public PageUtils findCheckMemberCount(Map params) { + Page pageParam = new Page(); + pageParam.setCurrent(Long.parseLong((String) params.get("page"))); + pageParam.setSize(Long.parseLong((String) params.get("limit"))); + IPage page = baseMapper.findCheckMemberCount(pageParam, params); + + for(TenCheckMemberCountVo vo: page.getRecords()){ + +// TenPersonEntity memberEntity = tenPersonService.getByIdWithDelete(vo.getMemberId()); + TenPersonEntity memberEntity = tenPersonService.getByIdWithDelete(vo.getMemberId()); + vo.setMemberName(memberEntity.getName()); + vo.setRgb(memberEntity.getOrgImage()); + vo.setDeptId(memberEntity.getDeptId()); + TenCellDeptEntity deptEntity = tenCellDeptService.getById(memberEntity.getDeptId()); + if(deptEntity!=null){ + vo.setDeptName(deptEntity.getName()); + } +// vo.setJobNumber(memberEntity.getJobNumber()); + vo.setIdNumber(memberEntity.getIdCard()); + + + Map p = new HashMap<>(); + p.put("memberId",vo.getMemberId()); + p.put("deptId",vo.getDeptId()); + p.put("dateStart",params.get("dateStart")); + p.put("dateEnd",params.get("dateEnd")); + p.put("status", Constant.CHECK_OK); + Integer dutyOnOkCount = baseMapper.findDutyOnCount(p); + vo.setDutyOnOkCount(dutyOnOkCount); + + Integer dutyOffOkCount = baseMapper.findDutyOffCount(p); + vo.setDutyOffOkCount(dutyOffOkCount); + + p.put("status", Constant.CHECK_CHIDAO); + Integer dutyOnLateCount = baseMapper.findDutyOnCount(p); + vo.setDutyOnLateCount(dutyOnLateCount); + + p.put("status", Constant.CHECK_ZAOTUI); + Integer dutyOnEarlyCount = baseMapper.findDutyOffCount(p); + vo.setDutyOffEarlyCount(dutyOnEarlyCount); + + vo.setRgb(vo.getRgb()); + } + return new PageUtils(page); + } + + + + @Override + public List findCheckMemberCountList(Map params) { +// Page pageParam = new Page(); +// pageParam.setCurrent(Long.parseLong((String) params.get("page"))); +// pageParam.setSize(Long.parseLong((String) params.get("limit"))); + List page = baseMapper.findCheckMemberList( params); + + for(TenCheckMemberCountVo vo: page){ + + + TenPersonEntity memberEntity = tenPersonService.getByIdWithDelete(vo.getMemberId()); + vo.setMemberName(memberEntity.getName()); + vo.setRgb(memberEntity.getOrgImage()); + vo.setDeptId(memberEntity.getDeptId()); + TenCellDeptEntity deptEntity = tenCellDeptService.getById(memberEntity.getDeptId()); + if(deptEntity!=null){ + vo.setDeptName(deptEntity.getName()); + } +// vo.setJobNumber(memberEntity.getJobNumber()); + vo.setIdNumber(memberEntity.getIdCard()); + + Map p = new HashMap<>(); + p.put("memberId",vo.getMemberId()); + p.put("deptId",vo.getDeptId()); + p.put("dateStart",params.get("dateStart")); + p.put("dateEnd",params.get("dateEnd")); + p.put("status", Constant.CHECK_OK); + Integer dutyOnOkCount = baseMapper.findDutyOnCount(p); + vo.setDutyOnOkCount(dutyOnOkCount); + + Integer dutyOffOkCount = baseMapper.findDutyOffCount(p); + vo.setDutyOffOkCount(dutyOffOkCount); + + p.put("status", Constant.CHECK_CHIDAO); + Integer dutyOnLateCount = baseMapper.findDutyOnCount(p); + vo.setDutyOnLateCount(dutyOnLateCount); + + p.put("status", Constant.CHECK_ZAOTUI); + Integer dutyOnEarlyCount = baseMapper.findDutyOffCount(p); + vo.setDutyOffEarlyCount(dutyOnEarlyCount); + } + return page; + } + + + + @Override + public List findDutyOnInfo(Map params) { + return baseMapper.findDutyOnInfo(params); + } + + @Override + public List findDutyOffInfo(Map params) { + return baseMapper.findDutyOffInfo(params); + } + + @Override + public int findDutyOnCount(Map params) { + return baseMapper.findDutyOnCount(params); + } + + @Override + public int findDutyOffCount(Map params) { + return baseMapper.findDutyOffCount(params); + } + + @Override + public TenCheckEntity findMemberCheck(Long memberId, String checkDate) { +// TenCheckEntity check = this.getOne(new QueryWrapper() +// .eq("member_id", memberId) +// .eq("check_date", checkDate)); + List checkList = this.list(new QueryWrapper() + .eq("member_id", memberId) + .eq("check_date", checkDate)); + TenCheckEntity check = null; + if(checkList.size()>0){ + check = checkList.get(0); + } + if (check != null) { + List cs = tenCheckScheduleService.list( + new QueryWrapper() + .eq("check_id", check.getCheckId()) + ); + check.setCheckScheduleList(cs); + } + return check; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void saveCheck(TenPersonEntity member, TenRecordEntity record) { + String checkDate = DateUtils.format(record.getRecordTime(), DateUtils.DATE_DAY); + int week = DateUtils.dateToWeek(checkDate); + TenRuleEntity rule = tenRuleService.findMemberRules(member.getPersonId(), member.getCellId(), week); + TenCheckEntity checkEntity = this.findMemberCheck(member.getPersonId(), checkDate); + //1. 当天首次打卡 + if (checkEntity == null) { + //如果有考勤规则,则打卡 + if (rule != null) { + checkEntity = new TenCheckEntity(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + String s = sdf.format(record.getRecordTime()); + try { + Date date = sdf.parse(s); + checkEntity.setCheckDate(date); + } catch (Exception e) { + e.printStackTrace(); + log.error("格式化日期失败"); + } + checkEntity.setMemberId(member.getPersonId()); + checkEntity.setMemberName(member.getName()); + checkEntity.setRuleId(rule.getRuleId()); + checkEntity.setCheckDay(week); + checkEntity.setGender(member.getGender()); +// checkEntity.setIcNumber(member.getIcNumber()); + checkEntity.setIdNumber(member.getIdCard()); +// checkEntity.setJobNumber(member.getJobNumber()); + checkEntity.setDeptId(member.getDeptId()); + checkEntity.setMobile(member.getMobile()); + TenCellDeptEntity deptEntity = tenCellDeptService.getById(member.getDeptId()); + checkEntity.setDeptName(deptEntity.getName()); +// checkEntity.setPosition(member.getPosition()); + checkEntity.setRgb(member.getOrgImage()); + checkEntity.setTenantId(record.getTenantId()); + //保存打卡基础信息 + + // + for (TenScheduleEntity schedule : rule.getScheduleEntityList()) { + //打卡时间 + LocalTime recordTime = record.getRecordTime().toInstant().atZone(ZoneId.systemDefault()).toLocalTime(); + TenCheckScheduleEntity checkSchedule = null; + //上班需要打卡 + if (schedule.getOnCheckFlag().intValue() == 1) { + //打卡时间在最早打卡时间和最晚打卡时间之间,可以打卡 + if (recordTime.isAfter(schedule.getOnBegin().toLocalTime()) + && recordTime.isBefore(schedule.getOnEnd().toLocalTime())) { + checkSchedule = new TenCheckScheduleEntity(); + + checkSchedule.setScheduleIndex(schedule.getScheduleIndex()); + + checkSchedule.setDutyOnRecordId(record.getRecordId()); + checkSchedule.setDutyOnTime(Time.valueOf(recordTime)); + //判断状态 + LocalTime chidaoTime = schedule.getDutyOn().toLocalTime().plusMinutes(schedule.getLateTime()); + + //正常 + if (recordTime.isBefore(chidaoTime)) { + checkSchedule.setDutyOnStatus(Constant.CHECK_OK); + checkSchedule.setDutyOnStatusInfo("正常"); + } else { + checkSchedule.setDutyOnStatus(Constant.CHECK_CHIDAO); + int chidao = recordTime.getHour() * 60 + recordTime.getMinute() - (schedule.getDutyOn().toLocalTime().getHour() * 60 + schedule.getDutyOn().toLocalTime().getMinute()); + checkSchedule.setDutyOnStatusInfo("迟到" + chidao + "分钟"); + } + this.save(checkEntity); + checkSchedule.setCheckId(checkEntity.getCheckId()); + checkSchedule.setTenantId(checkEntity.getTenantId()); + tenCheckScheduleService.save(checkSchedule); + } else { + //不在上班打卡时间内 + } + } else {//上班不需要打卡 + + } + + //下班需要打卡 + if (schedule.getOffCheckFlag().intValue() == 1) { + //打卡时间在最早打卡时间和最晚打卡时间之间,可以打卡 + if (recordTime.isAfter(schedule.getOffBegin().toLocalTime()) + && recordTime.isBefore(schedule.getOffEnd().toLocalTime())) { + checkSchedule = new TenCheckScheduleEntity(); +// checkSchedule.setCheckId(checkEntity.getCheckId()); + checkSchedule.setScheduleIndex(schedule.getScheduleIndex()); + + checkSchedule.setDutyOffRecordId(record.getRecordId()); + checkSchedule.setDutyOffTime(Time.valueOf(recordTime)); + //判断状态 + LocalTime zaotuiTime = schedule.getDutyOff().toLocalTime().minusMinutes(schedule.getLateTime()); + + //正常 + if (recordTime.isAfter(zaotuiTime)) { + checkSchedule.setDutyOffStatus(Constant.CHECK_OK); + checkSchedule.setDutyOffStatusInfo("正常"); + } else { + checkSchedule.setDutyOffStatus(Constant.CHECK_ZAOTUI); + int zaotui = schedule.getDutyOff().toLocalTime().getHour() * 60 + schedule.getDutyOff().toLocalTime().getMinute() - (recordTime.getHour() * 60 + recordTime.getMinute()); + checkSchedule.setDutyOffStatusInfo("早退" + zaotui + "分钟"); + } + TenCheckEntity checkEntityTest = this.findMemberCheck(member.getPersonId(), checkDate); + if(checkEntityTest==null){ + this.save(checkEntity); + checkSchedule.setCheckId(checkEntity.getCheckId()); + checkSchedule.setTenantId(checkEntity.getTenantId()); + }else{ + checkSchedule.setCheckId(checkEntityTest.getCheckId()); + checkSchedule.setTenantId(checkEntityTest.getTenantId()); + } + tenCheckScheduleService.save(checkSchedule); + } else { + //不在上班打卡时间内 + } + } else {//上班不需要打卡 + + } + + } + } else { + //没有考勤规则,不打卡 + } + } else {//非首次打卡 + //如果有考勤规则,则打卡 + if (rule != null) { + for (TenScheduleEntity schedule : rule.getScheduleEntityList()) { + //打卡时间 + LocalTime recordTime = record.getRecordTime().toInstant().atZone(ZoneId.systemDefault()).toLocalTime(); + TenCheckScheduleEntity checkSchedule = tenCheckScheduleService.getOne( + new QueryWrapper() + .eq("check_id", checkEntity.getCheckId()) + .eq("schedule_index", schedule.getScheduleIndex()) + .eq("tenant_id",checkEntity.getTenantId()) + ); + //上班需要打卡 + if (schedule.getOnCheckFlag().intValue() == 1) { + if(checkSchedule!=null){//当前班次有打过卡 + //当前班次上班还没有打过卡 + if(checkSchedule.getDutyOnStatus().intValue()==0){ + if (recordTime.isAfter(schedule.getOnBegin().toLocalTime()) + && recordTime.isBefore(schedule.getOnEnd().toLocalTime())) { + checkSchedule.setDutyOnRecordId(record.getRecordId()); + checkSchedule.setDutyOnTime(Time.valueOf(recordTime)); + //判断状态 + LocalTime chidaoTime = schedule.getDutyOn().toLocalTime().plusMinutes(schedule.getLateTime()); + + //正常 + if (recordTime.isBefore(chidaoTime)) { + checkSchedule.setDutyOnStatus(Constant.CHECK_OK); + checkSchedule.setDutyOnStatusInfo("正常"); + } else { + checkSchedule.setDutyOnStatus(Constant.CHECK_CHIDAO); + int chidao = recordTime.getHour() * 60 + recordTime.getMinute() - (schedule.getDutyOn().toLocalTime().getHour() * 60 + schedule.getDutyOn().toLocalTime().getMinute()); + checkSchedule.setDutyOnStatusInfo("迟到" + chidao + "分钟"); + } + tenCheckScheduleService.updateById(checkSchedule); + }else{ + //不在打卡范围内 + } + }else{ + //上班已打卡 + } + }else{//当前班次还没有打过卡 + if (recordTime.isAfter(schedule.getOnBegin().toLocalTime()) + && recordTime.isBefore(schedule.getOnEnd().toLocalTime())) { + + checkSchedule = new TenCheckScheduleEntity(); + checkSchedule.setScheduleIndex(schedule.getScheduleIndex()); + checkSchedule.setCheckId(checkEntity.getCheckId()); + checkSchedule.setDutyOnRecordId(record.getRecordId()); + checkSchedule.setDutyOnTime(Time.valueOf(recordTime)); + checkSchedule.setTenantId(record.getTenantId()); + //判断状态 + LocalTime chidaoTime = schedule.getDutyOn().toLocalTime().plusMinutes(schedule.getLateTime()); + + //正常 + if (recordTime.isBefore(chidaoTime)) { + checkSchedule.setDutyOnStatus(Constant.CHECK_OK); + checkSchedule.setDutyOnStatusInfo("正常"); + } else { + checkSchedule.setDutyOnStatus(Constant.CHECK_CHIDAO); + int chidao = recordTime.getHour() * 60 + recordTime.getMinute() - (schedule.getDutyOn().toLocalTime().getHour() * 60 + schedule.getDutyOn().toLocalTime().getMinute()); + checkSchedule.setDutyOnStatusInfo("迟到" + chidao + "分钟"); + } + tenCheckScheduleService.save(checkSchedule); + }else{ + //不在范围内 + } + } + } + + //下班需要打卡 + if (schedule.getOffCheckFlag().intValue() == 1) { + if(checkSchedule!=null){//当前班次有打过卡 + //当前班次下班还没有打过卡 +// if(checkSchedule.getDutyOffStatus().intValue()==0){ +// if (recordTime.isAfter(schedule.getOffBegin().toLocalTime()) +// && recordTime.isBefore(schedule.getOffEnd().toLocalTime())) { +// checkSchedule.setDutyOffRecordId(record.getRecordId()); +// checkSchedule.setDutyOffTime(Time.valueOf(recordTime)); +// //判断状态 +// LocalTime zaotuiTime = schedule.getDutyOff().toLocalTime().minusMinutes(schedule.getLateTime()); +// +// //正常 +// if (recordTime.isAfter(zaotuiTime)) { +// checkSchedule.setDutyOffStatus(Constant.CHECK_OK); +// checkSchedule.setDutyOffStatusInfo("正常"); +// } else { +// checkSchedule.setDutyOffStatus(Constant.CHECK_ZAOTUI); +// int zaotui = schedule.getDutyOff().toLocalTime().getHour() * 60 + schedule.getDutyOff().toLocalTime().getMinute() - (recordTime.getHour() * 60 + recordTime.getMinute()); +// checkSchedule.setDutyOffStatusInfo("早退" + zaotui + "分钟"); +// } +// tenCheckScheduleService.updateById(checkSchedule); +// } +// }else{ +// //下班已经打过卡,再次更新打卡时间 +// } + if (recordTime.isAfter(schedule.getOffBegin().toLocalTime()) + && recordTime.isBefore(schedule.getOffEnd().toLocalTime())) { + checkSchedule.setDutyOffRecordId(record.getRecordId()); + checkSchedule.setDutyOffTime(Time.valueOf(recordTime)); + //判断状态 + LocalTime zaotuiTime = schedule.getDutyOff().toLocalTime().minusMinutes(schedule.getLateTime()); + + //正常 + if (recordTime.isAfter(zaotuiTime)) { + checkSchedule.setDutyOffStatus(Constant.CHECK_OK); + checkSchedule.setDutyOffStatusInfo("正常"); + } else { + checkSchedule.setDutyOffStatus(Constant.CHECK_ZAOTUI); + int zaotui = schedule.getDutyOff().toLocalTime().getHour() * 60 + schedule.getDutyOff().toLocalTime().getMinute() - (recordTime.getHour() * 60 + recordTime.getMinute()); + checkSchedule.setDutyOffStatusInfo("早退" + zaotui + "分钟"); + } + tenCheckScheduleService.updateById(checkSchedule); + } + }else{//当前班次还没有打过卡 + if (recordTime.isAfter(schedule.getOffBegin().toLocalTime()) + && recordTime.isBefore(schedule.getOffEnd().toLocalTime())) { + checkSchedule = new TenCheckScheduleEntity(); + checkSchedule.setScheduleIndex(schedule.getScheduleIndex()); + checkSchedule.setCheckId(checkEntity.getCheckId()); + + checkSchedule.setDutyOffRecordId(record.getRecordId()); + checkSchedule.setDutyOffTime(Time.valueOf(recordTime)); + //判断状态 + LocalTime zaotuiTime = schedule.getDutyOff().toLocalTime().minusMinutes(schedule.getLateTime()); + + //正常 + if (recordTime.isAfter(zaotuiTime)) { + checkSchedule.setDutyOffStatus(Constant.CHECK_OK); + checkSchedule.setDutyOffStatusInfo("正常"); + } else { + checkSchedule.setDutyOffStatus(Constant.CHECK_ZAOTUI); + int zaotui = schedule.getDutyOff().toLocalTime().getHour() * 60 + schedule.getDutyOff().toLocalTime().getMinute() - (recordTime.getHour() * 60 + recordTime.getMinute()); + checkSchedule.setDutyOffStatusInfo("早退" + zaotui + "分钟"); + } + tenCheckScheduleService.save(checkSchedule); + } + } + } + } + } else { + //没有考勤规则,不打卡 + } + } + } +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenPersonServiceImpl.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenPersonServiceImpl.java index 9afb480..c229e8d 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenPersonServiceImpl.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenPersonServiceImpl.java @@ -2304,4 +2304,9 @@ public class TenPersonServiceImpl implements TenPersonService { IPage page = tenPersonDao.selectByDeptIdForGuest(pageParam, deptId, cellId, key); return new PageUtils(page); } + + @Override + public TenPersonEntity getByIdWithDelete(Long id) { + return tenPersonDao.getByIdWithDelete(id); + } } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenRuleServiceImpl.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenRuleServiceImpl.java new file mode 100644 index 0000000..d8915e3 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenRuleServiceImpl.java @@ -0,0 +1,133 @@ +package net.shapelight.modules.ten.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import net.shapelight.common.utils.PageUtils; +import net.shapelight.common.utils.Query; +import net.shapelight.modules.ten.dao.TenRuleDao; +import net.shapelight.modules.ten.entity.TenCellDeptEntity; +import net.shapelight.modules.ten.entity.TenPersonEntity; +import net.shapelight.modules.ten.entity.TenRuleEntity; +import net.shapelight.modules.ten.entity.TenScheduleEntity; +import net.shapelight.modules.ten.service.TenCellDeptService; +import net.shapelight.modules.ten.service.TenPersonService; +import net.shapelight.modules.ten.service.TenRuleService; +import net.shapelight.modules.ten.service.TenScheduleService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + + +@Service("tenRuleService") +public class TenRuleServiceImpl extends ServiceImpl implements TenRuleService { + + @Autowired + private TenScheduleService tenScheduleService; + @Autowired + private TenPersonService tenPersonService; + @Autowired + private TenCellDeptService tenCellDeptService; + + @Override + public PageUtils queryPage(Map params) { + IPage page = this.page( + new Query().getPage(params), + new QueryWrapper() + .eq("tenant_id",params.get("tenantId")) + .eq("cell_id",params.get("cellId")) + ); + + //获取详细班次,通过规则id + for(TenRuleEntity ruleEntity: page.getRecords()){ + List scheduleEntityList = tenScheduleService.list( + new QueryWrapper() + .eq("rule_id",ruleEntity.getRuleId()) + .eq("tenant_id",ruleEntity.getTenantId()) + .eq("cell_id",params.get("cellId")) + ); + ruleEntity.setScheduleEntityList(scheduleEntityList); + + String deptIds = ruleEntity.getDeptIds(); + String[] deptIdArray = deptIds.split(","); + StringBuffer deptNames = new StringBuffer(); + int memberCount = 0; + for(String deptId: deptIdArray){ + TenCellDeptEntity deptEntity = tenCellDeptService.getById(deptId); + if(deptEntity!=null){ + deptNames.append(deptEntity.getName()+","); +// int mCount = tenPersonService.count(new QueryWrapper() +// .eq("dept_id",deptId)); +// memberCount += mCount; + } + } + ruleEntity.setDeptNames(deptNames.toString()); + ruleEntity.setMemberCount(memberCount); + } + + return new PageUtils(page); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public boolean saveTr(TenRuleEntity entity) { + //1. 保存基础规则信息 + this.save(entity); + + //2. 保存班次信息 + for(TenScheduleEntity schedule: entity.getScheduleEntityList()){ + schedule.setRuleId(entity.getRuleId()); + schedule.setTenantId(entity.getTenantId()); + } + tenScheduleService.saveBatch(entity.getScheduleEntityList()); + return true; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public boolean updateByIdTr(TenRuleEntity entity) { + //1. 保存基础规则信息 + this.updateById(entity); + + //2. 保存班次信息 + for(TenScheduleEntity schedule: entity.getScheduleEntityList()){ + schedule.setRuleId(entity.getRuleId()); + schedule.setTenantId(entity.getTenantId()); + } + tenScheduleService.saveOrUpdateBatch(entity.getScheduleEntityList()); + return true; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public boolean removeByIdsTr(Long[] ruleIds) { + //1. 删除基础规则信息 + this.removeByIds(Arrays.asList(ruleIds)); + //2. 删除班次信息 + tenScheduleService.remove(new QueryWrapper().in("rule_id",ruleIds)); + return true; + } + + @Override + public TenRuleEntity findMemberRules(Long memberId, Long cellId, Integer week) { + TenPersonEntity member = tenPersonService.getById(memberId,cellId); + Long deptId = member.getDeptId(); + List rules = this.list(new QueryWrapper() + .last("where find_in_set("+deptId+",dept_ids) and find_in_set("+week+",days) order by create_time desc")); + //只拿出来第一个,最后一次添加的哪个 + TenRuleEntity memberRule = null; + if(rules.size()>0){ + memberRule = rules.get(0); + List ss = tenScheduleService.list( + new QueryWrapper() + .eq("rule_id",memberRule.getRuleId()) + ); + memberRule.setScheduleEntityList(ss); + } + return memberRule; + } +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenScheduleServiceImpl.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenScheduleServiceImpl.java new file mode 100644 index 0000000..eb3aaef --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenScheduleServiceImpl.java @@ -0,0 +1,29 @@ +package net.shapelight.modules.ten.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import net.shapelight.common.utils.PageUtils; +import net.shapelight.common.utils.Query; +import net.shapelight.modules.ten.dao.TenScheduleDao; +import net.shapelight.modules.ten.entity.TenScheduleEntity; +import net.shapelight.modules.ten.service.TenScheduleService; +import org.springframework.stereotype.Service; + +import java.util.Map; + + +@Service("tenScheduleService") +public class TenScheduleServiceImpl extends ServiceImpl implements TenScheduleService { + + @Override + public PageUtils queryPage(Map params) { + IPage page = this.page( + new Query().getPage(params), + new QueryWrapper() + ); + + return new PageUtils(page); + } + +} \ No newline at end of file diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/vo/AttendanceDayVo.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/vo/AttendanceDayVo.java new file mode 100644 index 0000000..23833a5 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/vo/AttendanceDayVo.java @@ -0,0 +1,59 @@ +package net.shapelight.modules.ten.vo; + + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +@Data +public class AttendanceDayVo { + /** + * 打卡日期 + */ + @ApiModelProperty("打卡日期") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date checkDate; + /** + * 星期几1,2,3,4,5,6,7 + */ + @ApiModelProperty("星期几") + private Integer checkDay; + +// @ApiModelProperty("部门id") +// private Long deptId; +// +// @ApiModelProperty("部门名称") +// private String deptName; + + /** + * 出勤天数 + */ + @ApiModelProperty("出勤天数") + private Integer checkDayCount; + + /** + * 正常签到 + */ + @ApiModelProperty("正常签到次数") + private Integer dutyOnOkCount; + + /** + * 迟到次数 + */ + @ApiModelProperty("迟到次数") + private Integer dutyOnLateCount; + + /** + * 正常签退次数 + */ + @ApiModelProperty("正常签退次数") + private Integer dutyOffOkCount; + + /** + * 早退次数 + */ + @ApiModelProperty("早退次数") + private Integer dutyOffEarlyCount; +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/vo/TenCheckMemberCountVo.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/vo/TenCheckMemberCountVo.java new file mode 100644 index 0000000..59b32f9 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/vo/TenCheckMemberCountVo.java @@ -0,0 +1,86 @@ +package net.shapelight.modules.ten.vo; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * + * + */ +@Data +public class TenCheckMemberCountVo implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 人员id + */ + @ApiModelProperty("人员id") + @JsonSerialize(using = ToStringSerializer.class) + private Long memberId; + /** + * 姓名 + */ + @ApiModelProperty("姓名") + private String memberName; + /** + * 工号 + */ + @ApiModelProperty("工号") + private String jobNumber; + /** + * 身份证号 + */ + @ApiModelProperty("身份证号") + private String idNumber; + /** + * 部门id + */ + @ApiModelProperty("部门id") + private Long deptId; + /** + * rgb + */ + @ApiModelProperty("rgb头像") + private String rgb; + /** + * 部门名称 + */ + @ApiModelProperty("部门名称") + private String deptName; + + /** + * 出勤天数 + */ + @ApiModelProperty("出勤天数") + private Integer checkDayCount; + + /** + * 正常签到 + */ + @ApiModelProperty("正常签到次数") + private Integer dutyOnOkCount; + + /** + * 迟到次数 + */ + @ApiModelProperty("迟到次数") + private Integer dutyOnLateCount; + + /** + * 正常签退次数 + */ + @ApiModelProperty("正常签退次数") + private Integer dutyOffOkCount; + + /** + * 早退次数 + */ + @ApiModelProperty("早退次数") + private Integer dutyOffEarlyCount; + + +} diff --git a/shapelight-admin/src/main/resources/application-dev.yml b/shapelight-admin/src/main/resources/application-dev.yml index 56c8b5d..7298d25 100644 --- a/shapelight-admin/src/main/resources/application-dev.yml +++ b/shapelight-admin/src/main/resources/application-dev.yml @@ -3,7 +3,7 @@ spring: type: com.alibaba.druid.pool.DruidDataSource druid: driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://192.168.10.20:3306/cell_db_v8_http_test?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useSSL=false&rewriteBatchedStatements=true + url: jdbc:mysql://192.168.10.20:3306/cell_db_v9_check?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useSSL=false&rewriteBatchedStatements=true username: user password: user@server001 # url: jdbc:mysql://39.96.9.232:3306/cell_db_v8_http?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useSSL=false&rewriteBatchedStatements=true diff --git a/shapelight-admin/src/main/resources/application.yml b/shapelight-admin/src/main/resources/application.yml index b670f7b..b09c296 100644 --- a/shapelight-admin/src/main/resources/application.yml +++ b/shapelight-admin/src/main/resources/application.yml @@ -31,7 +31,7 @@ spring: enabled: true file-size-threshold: 1000MB redis: - database: 0 + database: 10 host: 192.168.10.20 port: 6379 password: 123456 # 密码(默认为空) diff --git a/shapelight-admin/src/main/resources/mapper/ten/TenCheckDao.xml b/shapelight-admin/src/main/resources/mapper/ten/TenCheckDao.xml new file mode 100644 index 0000000..fca5d2c --- /dev/null +++ b/shapelight-admin/src/main/resources/mapper/ten/TenCheckDao.xml @@ -0,0 +1,271 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/shapelight-admin/src/main/resources/mapper/ten/TenCheckScheduleDao.xml b/shapelight-admin/src/main/resources/mapper/ten/TenCheckScheduleDao.xml new file mode 100644 index 0000000..499f464 --- /dev/null +++ b/shapelight-admin/src/main/resources/mapper/ten/TenCheckScheduleDao.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/shapelight-admin/src/main/resources/mapper/ten/TenPersonDao.xml b/shapelight-admin/src/main/resources/mapper/ten/TenPersonDao.xml index 0a31ca2..868c581 100644 --- a/shapelight-admin/src/main/resources/mapper/ten/TenPersonDao.xml +++ b/shapelight-admin/src/main/resources/mapper/ten/TenPersonDao.xml @@ -1214,6 +1214,10 @@ + + diff --git a/shapelight-admin/src/main/resources/mapper/ten/TenRuleDao.xml b/shapelight-admin/src/main/resources/mapper/ten/TenRuleDao.xml new file mode 100644 index 0000000..a48e44f --- /dev/null +++ b/shapelight-admin/src/main/resources/mapper/ten/TenRuleDao.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/shapelight-admin/src/main/resources/mapper/ten/TenScheduleDao.xml b/shapelight-admin/src/main/resources/mapper/ten/TenScheduleDao.xml new file mode 100644 index 0000000..a7abd04 --- /dev/null +++ b/shapelight-admin/src/main/resources/mapper/ten/TenScheduleDao.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/shapelight-common/src/main/java/net/shapelight/common/utils/DateUtils.java b/shapelight-common/src/main/java/net/shapelight/common/utils/DateUtils.java index f4875bb..5832768 100644 --- a/shapelight-common/src/main/java/net/shapelight/common/utils/DateUtils.java +++ b/shapelight-common/src/main/java/net/shapelight/common/utils/DateUtils.java @@ -8,6 +8,7 @@ import org.joda.time.LocalDate; import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormatter; +import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; @@ -25,6 +26,10 @@ public class DateUtils { public final static String DATE_TIME_DB= "yyyyMMddHHmmss"; public final static String DATE_YEAR_MONTH= "yyyyMMdd"; public final static String DATE_MONTH= "yyyy-MM"; + public final static String DATE_TIME_YEARMONTH= "yyyyMM"; + public final static String DATE_DAY= "yyyy-MM-dd"; + public final static String DATE_HOUR= "HH:mm:ss"; + public final static String DATE_DIR = "YYYYMM"; /** * 日期格式化 日期格式为:yyyy-MM-dd @@ -183,4 +188,27 @@ public class DateUtils { return lastDayOfMonth; } + + /** + * 根据日期获取 星期 (2019-05-06 ——> 星期一) + * @param datetime + * @return + */ + public static int dateToWeek(String datetime) { + + SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd"); + Calendar cal = Calendar.getInstance(); + Date date; + try { + date = f.parse(datetime); + cal.setTime(date); + } catch (ParseException e) { + e.printStackTrace(); + } + //一周的第几天 + int w = cal.get(Calendar.DAY_OF_WEEK)-1; + if (w <= 0) + w = 7; + return w; + } } diff --git a/version9.txt b/version9.txt new file mode 100644 index 0000000..067db90 --- /dev/null +++ b/version9.txt @@ -0,0 +1,125 @@ +v4.0 +1.sys_device_type表 启用other字段,0表示2d,1表示3d,v4.0加入,空表示2d +2.ten_device表增加两个字段,识别阈值:recognize_score_3d,检测方式:detection_type +3.ten_person表增加5个字段:depth,face_model,source_file,camera_param +4.ten_record表增加8个字段:depth,source_file,duration,threshold,distance,score3d,temperature,camera_param + + +v4.0 数据库修改内容 +alter table ten_device_copy1 +ADD COLUMN recognize_score3d varchar(30) DEFAULT '62,65' COMMENT '3d识别阈值', +ADD COLUMN detection_type tinyint(1) DEFAULT 0 COMMENT '0:默认2d检测, 1:3d检测'; + + +alter table ten_person_copy1 +ADD COLUMN depth varchar(200) COMMENT '深度图片', +ADD COLUMN face_model varchar(200) COMMENT '脸模', +ADD COLUMN source_file varchar(200) COMMENT '源文件', +ADD COLUMN camera_param varchar(200) COMMENT '相机参数'; + +alter table ten_record_9999999999999 +ADD COLUMN depth varchar(200) COMMENT '深度图片', +ADD COLUMN source_file varchar(200) COMMENT '源文件', +ADD COLUMN camera_param varchar(200) COMMENT '相机参数', +ADD COLUMN duration int(11) COMMENT '耗时', +ADD COLUMN threshold varchar(50) COMMENT '阈值', +ADD COLUMN distance float COMMENT '距离', +ADD COLUMN score3d varchar(50) COMMENT '分数', +ADD COLUMN temperature float COMMENT '体温'; + + + + + +------------------------v8.0 http协议版本,数据库更新说明:先执行以下sql语句,在跑批处理程序----------------- +1.ten_device表增加字段:app_language,lat,lon +2.ten_person表增加字段:thd_feature,dept_id +3.ten_person表person_type字段默认5000 +4.sys_menu表增加4条参数2001,2002,2003,2004 +5.ten_company表增加type_id字段关联 +6.ten_label表type字段类型修改为int +7.增加表 ten_cell_dept +8.增加表 ten_device_operate_log +9.增加表 ten_company_type +10.页面修改角色 + + + +alter table ten_device ADD COLUMN app_language tinyint(1) DEFAULT 0 COMMENT 'app版本'; +alter table ten_device ADD COLUMN lat varchar(50) DEFAULT '' COMMENT '纬度'; +alter table ten_device ADD COLUMN lon varchar(50) DEFAULT '' COMMENT '经度'; + +alter table ten_person ADD COLUMN thd_feature varchar(10240) COMMENT '3d特征'; +alter table ten_person ADD COLUMN dept_id bigint(20) COMMENT '部门id'; +alter table ten_person ALTER COLUMN person_type SET DEFAULT 5000; + +INSERT INTO `sys_menu` VALUES (2001, 3, '设备Log', 'sys/deviceLog', 'sys:devicelog', 1, 'shebei', 6, 'system_devicelog'); +INSERT INTO `sys_menu` VALUES (2002, 1210, '操作记录', 'ten/deviceoperatelog', 'ten:deviceoperatelog', 1, 'shebei', 6, 'tenant_deviceoperatelog'); +INSERT INTO `sys_menu` VALUES (2003, 1234, '组织管理', 'ten/celldept', 'ten:celldept', 1, 'shebei', 6, 'tenant_celldept'); +INSERT INTO `sys_menu` VALUES (2004, 1220, '单位类别', 'ten/companytype', 'ten:companytype', 1, 'shebei', 6, 'tenant_companytype'); + +alter table ten_company ADD COLUMN type_id bigint(20) COMMENT '类别id'; + +ALTER TABLE ten_label MODIFY COLUMN type INT(11); + +CREATE TABLE `ten_cell_dept` ( + `dept_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '部门/楼栋', + `parent_id` bigint(20) DEFAULT NULL COMMENT '父级目录', + `cell_id` bigint(20) NOT NULL COMMENT '小区ID', + `name` varchar(200) DEFAULT NULL COMMENT '名称', + `lable` varchar(100) DEFAULT NULL COMMENT '标签', + `lat` varchar(50) DEFAULT '' COMMENT '纬度', + `lon` varchar(50) DEFAULT '' COMMENT '经度', + `other` varchar(200) DEFAULT '' COMMENT '其他', + `remark` varchar(100) DEFAULT '' COMMENT '备注', + `picture` varchar(1024) DEFAULT '' COMMENT '照片', + `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `create_by` varchar(100) DEFAULT '' COMMENT '创建人', + `last_update_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间', + `last_update_by` varchar(100) DEFAULT '' COMMENT '更新人', + `delete_flag` tinyint(1) DEFAULT '0' COMMENT '0未删除1删除', + `tenant_id` bigint(20) unsigned zerofill DEFAULT '00000000000000000000' COMMENT '运营商ID', + `xa_sync` tinyint(1) DEFAULT '0' COMMENT '第三方是否同步1是0否默认0', + `p_id` int(18) DEFAULT NULL COMMENT '地址序号', + `dzbm` varchar(100) DEFAULT NULL COMMENT '地址编码', + `is_room` tinyint(1) DEFAULT '0' COMMENT '是否是户室0否1是', + `room_type` tinyint(1) DEFAULT '0' COMMENT '类型:自住,出租', + PRIMARY KEY (`dept_id`) +) ENGINE=InnoDB AUTO_INCREMENT=37291 DEFAULT CHARSET=utf8mb4; + +CREATE TABLE `ten_company_type` ( + `type_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', + `name` varchar(100) DEFAULT '' COMMENT '标签名称', + `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `create_by` varchar(100) DEFAULT '' COMMENT '创建人', + `last_update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + `last_update_by` varchar(100) DEFAULT '' COMMENT '更新人', + `delete_flag` tinyint(1) DEFAULT '0' COMMENT '0未删除1删除', + `tenant_id` bigint(20) NOT NULL COMMENT '运营商ID', + PRIMARY KEY (`type_id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=10033 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='标签'; + +CREATE TABLE `ten_device_operate_log` ( + `log_id` bigint(20) NOT NULL AUTO_INCREMENT, + `sn` varchar(100) DEFAULT NULL, + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `operation` varchar(200) DEFAULT NULL COMMENT '用户操作', + `tenant_id` bigint(20) DEFAULT NULL COMMENT '运营商Id', + PRIMARY KEY (`log_id`) +) ENGINE=InnoDB AUTO_INCREMENT=667 DEFAULT CHARSET=utf8mb4; + +CREATE TABLE `sys_device_log` ( + `log_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', + `sn` varchar(50) DEFAULT NULL, + `create_time` datetime DEFAULT NULL, + `log` varchar(16000) DEFAULT NULL, + PRIMARY KEY (`log_id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=418 DEFAULT CHARSET=utf8mb4; + + +------------------------v9.0 考勤版本----------------- +1.增加表ten_rule +2.增加表ten_schedule +3.增加表ten_check +4.增加表ten_check_schedule +5.menu表增加2010,2011,2012,2013,2014五条记录 \ No newline at end of file