当前位置: 首页 > wzjs >正文

易语言网站建设wordpress 做仿站

易语言网站建设,wordpress 做仿站,360建筑网撤销挂证,代发关键词排名包收录此篇主要用于记录Excel一行中,单条数据的日期拿取,并判断上下班打卡情况。代码可能满足不了大部分需求,目前只够本公司用,如果需要,可以参考。 需要把飞书月度汇总的考勤表导入系统中可以参考下。 下图为需要获取的年…

此篇主要用于记录Excel一行中,单条数据的日期拿取,并判断上下班打卡情况。代码可能满足不了大部分需求,目前只够本公司用,如果需要,可以参考。
在这里插入图片描述
需要把飞书月度汇总的考勤表导入系统中可以参考下。

下图为需要获取的年月日以及对应表格的数据。

在这里插入图片描述
实现代码如下


//导入Excel接口并调用下方的readAttendanceRecords()方法	/*** 导入飞书考勤列表*//** 示例:@ApiOperation("导入飞书考勤表")@Log(title = "导入飞书考勤表", businessType = BusinessType.IMPORT)@PostMapping("/importFeiShuDataFile")public AjaxResult importFeiShuDataFile(MultipartFile file, boolean updateSupport) throws Exception {File convertFile = convert(file);List<Attendance> attendanceFeiShus = readAttendanceRecords(convertFile);String message = attendanceService.importAttendance(attendanceFeiShus, false, "1");return AjaxResult.success(message);}
**//*** 将MultipartFile转换为File** @param multipartFile 上传的文件* @return 转换后的File对象* @throws IOException 如果文件操作失败*/public static File convert(MultipartFile multipartFile) throws IOException {// 创建一个临时文件Path tempFile = Files.createTempFile("upload-", ".tmp");try (InputStream inputStream = multipartFile.getInputStream()) {// 将MultipartFile的内容复制到临时文件Files.copy(inputStream, tempFile, StandardCopyOption.REPLACE_EXISTING);}// 返回File对象return tempFile.toFile();}public List<Attendance> readAttendanceRecords(File file) throws IOException, InvalidFormatException, ParseException {List<Attendance> records = new ArrayList<>();// 创建工作簿对象Workbook workbook = new XSSFWorkbook(file);Sheet sheet = workbook.getSheetAt(0); // 获取第一个工作表// 遍历第一行(跳过表头)Row row = sheet.getRow(1);String date = getCellValue(row.getCell(58)); // 日期
//        截取字符串日期String[] dataArray = date.split("-");String year = dataArray[0];String month = dataArray[1];LocalDate localDate = LocalDate.of(Integer.parseInt(year), Integer.parseInt(month), 1);LocalDate origin = LocalDate.of(Integer.parseInt(year), Integer.parseInt(month), 1);// 获取这个月的总天数int monthLength = localDate.lengthOfMonth();// 遍历每一行(跳过表头)for (int i = 2; i <= sheet.getLastRowNum(); i++) {Row row2 = sheet.getRow(i);if (row2 == null) continue;// 解析每一列的数据String employeeName = getCellValue(row2.getCell(0)); // 员工姓名String employeeNo = getCellValue(row2.getCell(1));   // 员工ID
//            需要查询员工id的员工对象Employee employee = new Employee();if (employeeNo.equals("-")) {employee.setEmployeeName(employeeName);// 根据姓名查询员工idList<Employee> employees = employeeService.selectEmployeeList(employee);if (CollUtil.isNotEmpty(employees)) {employee = employees.get(0); // 如果出现多个员工,请在excel里面把员工编号填写上,否则如果姓名相同根据姓名来获取默认第一个}}String day = getCellValue(row2.getCell(58));       // 日期
//           一个月的数据for (int j = 1; j < monthLength; j++) {Attendance record = new Attendance();record.setEmployeeName(employeeName);record.setEmployeeNo(employee.getEmployeeNo() == null ? employeeNo : employee.getEmployeeNo()); // 如果excel的员工id不为空的话,用excel,否则用查询的if (day.equals("-")) { // 如果为-,代表没来day = getCellValue(row2.getCell(58 + j));localDate = localDate.plusDays(1);// 加一天//                    continue;} else {//                 解析day 的上下班时间if (!day.contains(",")) { // 说明只上班,没下班,默认下午18:00;Date startTime = DateUtils.dateTime("HH:mm:ss", day + ":00");record.setStartTime(startTime);record.setEndTime(DateUtils.dateTime("HH:mm:ss", "18:00:00"));} else {String[] split = day.split(",");record.setStartTime(DateUtils.dateTime("HH:mm:ss", split[0] + ":00")); // 拼接成HH:mm:ss格式if (split.length == 3) {record.setEndTime(DateUtils.dateTime("HH:mm:ss", "18:00:00")); // 一天只打了三次卡,设置默认下班时间为18点}else {record.setEndTime(DateUtils.dateTime("HH:mm:ss", split[split.length-1] + ":00" )); // 一天只打了三次卡,设置默认下班时间为18点}}// 将LocalDate转换为ZonedDateTime(默认时区)ZonedDateTime zonedDateTime = localDate.atStartOfDay(ZoneId.systemDefault());// 将ZonedDateTime转换为InstantInstant instant = zonedDateTime.toInstant();// 将Instant转换为DateDate Day = Date.from(instant);record.setDay(Day); // 从该月第一天开始records.add(record);localDate = localDate.plusDays(1);// 加一天day = getCellValue(row2.getCell(58 + j));}}localDate = origin;}logger.info("考勤信息:{{}}", records);workbook.close();return records;}// 获取单元格的值private static String getCellValue(Cell cell) {if (cell == null) {return "";}switch (cell.getCellType()) {case STRING:return cell.getStringCellValue();case NUMERIC:if (DateUtil.isCellDateFormatted(cell)) {return cell.getLocalDateTimeCellValue().toString(); // 如果是日期类型,返回日期字符串} else {return String.valueOf(cell.getNumericCellValue());}case BOOLEAN:return String.valueOf(cell.getBooleanCellValue());case FORMULA:return cell.getCellFormula();default:return "";}}/*** 判断某一年是否是闰年** @param year 年份* @return true表示是闰年,false表示是平年*/public static boolean isLeapYear(int year) {// 规则1:能被4整除但不能被100整除// 规则2:能被400整除return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);}
http://www.dtcms.com/wzjs/805501.html

相关文章:

  • 提升网站访问速度中国工程有限公司
  • dedecms网站后台模板怎么获取免费的网站域名
  • 本地化吃喝玩乐平台网站可以做吗一个网站的建设流程
  • 东莞高埗网站建设哪里培训学校好
  • 网站的设计页面phcms wordpress
  • 网站建设服务合同交印花税东莞常平汽车站时刻表
  • 域名到期了网站会打不开吗中企建网站
  • 做内销网站深圳市福田区656号
  • 河北衡水市网站制作的公司电子商务查询网站
  • 网站开发常用语言总结北京终端区优化
  • 培训体系搭建北京seo案例
  • 河南金城建设工程有限公司网站静态网站 服务器
  • 盐城网站开发代理咨询wordpress新闻列表模板
  • 汽车用品东莞网站建设网站下拉菜单html做多大
  • 可以做用户调研的网站wordpress赞赏功能
  • 上海广告公司电话网站优化与SEO区别
  • 郑州网站推广优化报价在线A视频网站 一级A做爰片
  • 有特色的企业网站古玩网站建设意义
  • skype在网站上怎么做链接抖音搜索seo软件
  • 质量检测中心培训网站网站备案备案吗
  • 二手交易网站开发方式网站栏目模块
  • 网站建设赚钱么顺德网站建设报价
  • 济南做网站最好的公司wordpress打赏
  • 网站建设案例效果网站模板下载后如何使用
  • 安康企业网站建设价格安徽住房城乡建设厅网站
  • 做动态效果的网站营销传播方式有哪些
  • 网站的优化策略方案wordpress仿站教程百度云
  • 营销型网站方案pptwordpress 详解
  • 珠海做网站那家好国内网站不备案可以吗
  • 在线建站平台蚌埠哪有做网站的