From 77c2dba508bc65ee55c3d5f7ad45de868083cf1e Mon Sep 17 00:00:00 2001 From: ieaii <1069385070@qq.com> Date: Thu, 26 Dec 2024 09:32:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E4=B8=80=E4=B8=8B=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin-hanhai-vue/.env.development | 2 +- admin-hanhai-vue/src/views/xcx/ClockinLogList.vue | 35 +++-- jeecg-boot-base/jeecg-boot-base-core/pom.xml | 22 ++- .../java/org/jeecg/common/util/DateUtils2.java | 11 ++ .../java/org/jeecg/common/util/ExcelStyleUtil.java | 39 ++++++ .../controller/ClockInProjectController.java | 30 ++++ .../entity/ClockInProjectItem.java | 2 + .../controller/ClockinLogController.java | 153 +++++++++++++++++++-- .../modules/clockinlog/entity/ClockinLog.java | 1 + .../clockinlog/mapper/ClockinLogMapper.java | 2 +- .../clockinlog/ressp/ClockInLogExportResp.java | 14 +- .../clockinlog/ressp/ClockInLogExportResp2.java | 26 ++++ jeecg-boot-module-system/pom.xml | 6 + .../clockin/service/impl/ClockinServiceImpl.java | 31 ++++- .../src/test/java/org/jeecg/Test.java | 19 ++- pom.xml | 35 ++++- 16 files changed, 375 insertions(+), 53 deletions(-) create mode 100644 jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/ExcelStyleUtil.java create mode 100644 jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/clockinlog/ressp/ClockInLogExportResp2.java diff --git a/admin-hanhai-vue/.env.development b/admin-hanhai-vue/.env.development index 888fbbf..2ad6386 100644 --- a/admin-hanhai-vue/.env.development +++ b/admin-hanhai-vue/.env.development @@ -1,5 +1,5 @@ NODE_ENV=development -VUE_APP_API_BASE_URL=http://dev.java996.icu/clockin-api +VUE_APP_API_BASE_URL=http://127.0.0.1:8081/clockin-api VUE_APP_CAS_BASE_URL=http://cas.example.org:8443/cas VUE_APP_ONLINE_BASE_URL=http://fileview.jeecg.com/onlinePreview VUE_APP_MAP_KEY=WPKBZ-OKICI-ZAIGE-U6TQ4-RPQIV-OXBJO diff --git a/admin-hanhai-vue/src/views/xcx/ClockinLogList.vue b/admin-hanhai-vue/src/views/xcx/ClockinLogList.vue index d34ed09..8cde1fa 100644 --- a/admin-hanhai-vue/src/views/xcx/ClockinLogList.vue +++ b/admin-hanhai-vue/src/views/xcx/ClockinLogList.vue @@ -11,7 +11,7 @@ - + @@ -22,7 +22,7 @@
- 导出 + 导出 @@ -119,23 +119,23 @@ }, data () { return { - description: 'clockin_log管理页面', + description: '打卡管理页面', // 表头 columns: [ + // { + // title: '#', + // dataIndex: '', + // key:'rowIndex', + // width:60, + // align:"center", + // customRender:function (t,r,index) { + // return parseInt(index)+1; + // } + // }, { - title: '#', - dataIndex: '', - key:'rowIndex', - width:60, + title:'用户', align:"center", - customRender:function (t,r,index) { - return parseInt(index)+1; - } - }, - { - title:'用户编号', - align:"center", - dataIndex: 'userId' + dataIndex: 'userId_dictText' }, { title:'照片', @@ -143,6 +143,11 @@ dataIndex: 'pic', scopedSlots: {customRender: 'imgSlot'} }, + { + title:'打卡时间', + align:"center", + dataIndex: 'clockInTime' + }, { title:'打卡地址', align:"center", diff --git a/jeecg-boot-base/jeecg-boot-base-core/pom.xml b/jeecg-boot-base/jeecg-boot-base-core/pom.xml index 8ff7738..9064ab5 100644 --- a/jeecg-boot-base/jeecg-boot-base-core/pom.xml +++ b/jeecg-boot-base/jeecg-boot-base-core/pom.xml @@ -73,7 +73,7 @@ commons-io commons-io - ${commons.version} + ${commons-io.version} commons-lang @@ -273,6 +273,26 @@ 3.1.978 + + org.apache.poi + poi-ooxml + ${poi-ooxml.version} + + + org.apache.poi + poi + ${poi-ooxml.version} + + + org.apache.xmlbeans + xmlbeans + 5.1.1 + + + org.apache.poi + poi-ooxml-schemas + 4.1.2 + diff --git a/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/DateUtils2.java b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/DateUtils2.java index 1e42c79..3217a6e 100644 --- a/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/DateUtils2.java +++ b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/DateUtils2.java @@ -95,6 +95,17 @@ public class DateUtils2 { return dateTimeFormatter.format(localDateTime); } + /** + * 获取当前日期 yyyymmdd + * @return + */ + public static String getNowDateString4(String zoneId){ + + ZonedDateTime zonedDateTime = ZonedDateTime.now(ZoneId.of(zoneId)); + DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(YYYYMMDD); + return dateTimeFormatter.format(zonedDateTime); + } + /** * 获取当前日期 yyyymmdd * @return diff --git a/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/ExcelStyleUtil.java b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/ExcelStyleUtil.java new file mode 100644 index 0000000..f6fa8ac --- /dev/null +++ b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/ExcelStyleUtil.java @@ -0,0 +1,39 @@ +package org.jeecg.common.util; + +import org.apache.poi.ss.usermodel.*; +import org.jeecgframework.poi.excel.export.styler.ExcelExportStylerDefaultImpl; + +public class ExcelStyleUtil extends ExcelExportStylerDefaultImpl { + + public ExcelStyleUtil(Workbook workbook) { + super(workbook); + } + + @Override + public CellStyle getHeaderStyle(short color) { + CellStyle style = workbook.createCellStyle(); + style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex()); + style.setFillPattern(FillPatternType.SOLID_FOREGROUND); + Font font = workbook.createFont(); + font.setBold(true); + font.setColor(IndexedColors.WHITE.getIndex()); + style.setFont(font); + style.setAlignment(HorizontalAlignment.CENTER); + style.setVerticalAlignment(VerticalAlignment.CENTER); + return style; + } + + @Override + public CellStyle getTitleStyle(short color) { + CellStyle style = workbook.createCellStyle(); + Font font = workbook.createFont(); + font.setBold(true); + font.setFontHeightInPoints((short) 14); + font.setColor(IndexedColors.DARK_BLUE.getIndex()); + style.setFont(font); + style.setAlignment(HorizontalAlignment.CENTER); + style.setVerticalAlignment(VerticalAlignment.CENTER); + return style; + } + +} diff --git a/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/clockInproject/controller/ClockInProjectController.java b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/clockInproject/controller/ClockInProjectController.java index 68635d8..64b3e33 100644 --- a/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/clockInproject/controller/ClockInProjectController.java +++ b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/clockInproject/controller/ClockInProjectController.java @@ -9,7 +9,10 @@ import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.lang3.StringUtils; import org.jeecg.common.api.vo.Result; +import org.jeecg.common.exception.JeecgBootException; import org.jeecg.common.system.query.QueryGenerator; import org.jeecg.common.util.oConvertUtils; import org.jeecg.modules.clockInproject.entity.ClockInProject; @@ -82,6 +85,16 @@ public class ClockInProjectController extends JeecgController add(@RequestBody ClockInProject clockInProject) { + if(StringUtils.isNotBlank(clockInProject.getTeamId())){ + List clockInProjects = clockInProjectService.lambdaQuery() + .eq(ClockInProject::getDelFlag, 0) + .eq(ClockInProject::getTeamId, clockInProject.getTeamId()) + .list(); + + if(clockInProjects!= null && clockInProjects.size()!=0){ + throw new JeecgBootException("该团队已有绑定项目"); + } + } clockInProjectService.save(clockInProject); return Result.OK("添加成功!"); } @@ -96,6 +109,23 @@ public class ClockInProjectController extends JeecgController edit(@RequestBody ClockInProject clockInProject) { + if(StringUtils.isNotBlank(clockInProject.getTeamId())){ + List clockInProjects = clockInProjectService.lambdaQuery() + .eq(ClockInProject::getDelFlag, 0) + .eq(ClockInProject::getTeamId, clockInProject.getTeamId()) + .list(); + + if(clockInProjects!= null && clockInProjects.size()!=0){ + for (ClockInProject clockInProject1:clockInProjects){ + if(StringUtils.equals(clockInProject.getId(),clockInProject1.getId())){ + break; + }else{ + throw new JeecgBootException("该团队已有绑定项目"); + } + } + + } + } clockInProjectService.updateById(clockInProject); return Result.OK("编辑成功!"); } diff --git a/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/clockInprojectitem/entity/ClockInProjectItem.java b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/clockInprojectitem/entity/ClockInProjectItem.java index 376ffd3..535bda3 100644 --- a/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/clockInprojectitem/entity/ClockInProjectItem.java +++ b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/clockInprojectitem/entity/ClockInProjectItem.java @@ -73,4 +73,6 @@ public class ClockInProjectItem implements Serializable { @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") @ApiModelProperty(value = "修改时间") private java.util.Date updateTime; + /**类型 0正常 1周末 2加班*/ + private Integer type; } diff --git a/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/clockinlog/controller/ClockinLogController.java b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/clockinlog/controller/ClockinLogController.java index ef5508a..9325578 100644 --- a/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/clockinlog/controller/ClockinLogController.java +++ b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/clockinlog/controller/ClockinLogController.java @@ -10,13 +10,20 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; import org.apache.commons.beanutils.PropertyUtils; +import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.shiro.SecurityUtils; import org.jeecg.common.api.vo.Result; import org.jeecg.common.system.query.QueryGenerator; import org.jeecg.common.system.vo.LoginUser; import org.jeecg.common.util.DateUtils2; +import org.jeecg.common.util.ExcelStyleUtil; import org.jeecg.common.util.oConvertUtils; import org.jeecg.modules.clockInproject.entity.ClockInProject; import org.jeecg.modules.clockInproject.service.IClockInProjectService; @@ -25,6 +32,7 @@ import org.jeecg.modules.clockinauth.service.IClockinAuthService; import org.jeecg.modules.clockinlog.entity.ClockinLog; import org.jeecg.modules.clockinlog.mapper.ClockinLogMapper; import org.jeecg.modules.clockinlog.ressp.ClockInLogExportResp; +import org.jeecg.modules.clockinlog.ressp.ClockInLogExportResp2; import org.jeecg.modules.clockinlog.ressp.ClockInLogResp; import org.jeecg.modules.clockinlog.service.IClockinLogService; @@ -35,12 +43,15 @@ import lombok.extern.slf4j.Slf4j; import org.jeecg.modules.clockinteamlog.entity.ClockinTeamLog; import org.jeecg.modules.clockinteamlog.service.IClockinTeamLogService; +import org.jeecgframework.poi.excel.ExcelExportUtil; import org.jeecgframework.poi.excel.ExcelImportUtil; import org.jeecgframework.poi.excel.def.NormalExcelConstants; import org.jeecgframework.poi.excel.entity.ExportParams; import org.jeecgframework.poi.excel.entity.ImportParams; +import org.jeecgframework.poi.excel.entity.enmus.ExcelType; import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; import org.jeecg.common.system.base.controller.JeecgController; +import org.jeecgframework.poi.excel.view.JeecgMapExcelView; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.*; @@ -185,7 +196,7 @@ public class ClockinLogController extends JeecgController parameterMap = request.getParameterMap(); String[] clockStartTimes = parameterMap.get("clockStartTime"); + String[] userIds = parameterMap.get("userId"); // QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(object, request.getParameterMap()); LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - List clockinTeamLogs = clockinTeamLogService.lambdaQuery() - .eq(ClockinTeamLog::getDelFlag, 0) -// .eq(ClockinTeamLog::getStatus,1) - .list(); + LambdaQueryChainWrapper queryChainWrapper = clockinTeamLogService.lambdaQuery() + .eq(ClockinTeamLog::getDelFlag, 0); +// List clockinTeamLogs = clockinTeamLogService.lambdaQuery() +// .eq(ClockinTeamLog::getDelFlag, 0) +// .list(); + if(userIds!=null && userIds.length!=0 && StringUtils.isNotBlank(userIds[0])){ + queryChainWrapper.eq(ClockinTeamLog::getUserId,userIds[0]); + } + List clockinTeamLogs = queryChainWrapper.list(); // int day = Integer.parseInt(DateUtils2.getNowMonthMaxDay()); @@ -229,6 +246,9 @@ public class ClockinLogController extends JeecgController clockInLogExportResp2s = new ArrayList<>(); + ClockInLogExportResp clockInLogExportResp = new ClockInLogExportResp(); + clockInLogExportResp.setName(clockinAuth.getName()); + clockInLogExportResp.setDate(nowYearMonth); for (int n= 1;n<=day;n++){ - ClockInLogExportResp clockInLogExportResp = new ClockInLogExportResp(); - clockInLogExportResp.setName(clockinAuth.getName()); - clockInLogExportResp.setDate(nowYearMonth); - clockInLogExportResp.setDay(n+""); - yearMonthDay = nowYearMonth+"-"+n; + ClockInLogExportResp2 clockInLogExportResp2 = new ClockInLogExportResp2(); + + + clockInLogExportResp2.setDay(n+""); + yearMonthDay = nowYearMonth+"-"+n; + if(n < 10){ + yearMonthDay = nowYearMonth+"-0"+n; + } + List clockInLogExpeort = clockinLogMapper.getClockInLogExpeort(yearMonthDay, clockInProject.getId(), clockinTeamLog.getUserId()); String clockInTime = ""; for (ClockInLogResp clockInLogResp:clockInLogExpeort) { @@ -253,10 +280,12 @@ public class ClockinLogController extends JeecgController clazz, String title) { + // Step.1 组装查询条件 + Map parameterMap = request.getParameterMap(); + String[] clockStartTimes = parameterMap.get("clockStartTime"); + String[] userIds = parameterMap.get("userId"); + + LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + LambdaQueryChainWrapper queryChainWrapper = clockinTeamLogService.lambdaQuery() + .eq(ClockinTeamLog::getDelFlag, 0); + + if (userIds != null && userIds.length != 0 && StringUtils.isNotBlank(userIds[0])) { + queryChainWrapper.eq(ClockinTeamLog::getUserId, userIds[0]); + } + List clockinTeamLogs = queryChainWrapper.list(); + + // 确定导出月份 + String nowYearMonth = DateUtils2.getNowYearMonth(); + if (clockStartTimes != null && clockStartTimes.length != 0 && StringUtils.isNotBlank(clockStartTimes[0])) { + nowYearMonth = clockStartTimes[0]; + } + YearMonth yearMonth = YearMonth.parse(nowYearMonth); + int daysInMonth = yearMonth.lengthOfMonth(); // 当前月份的天数 + + // Step.2 获取导出数据 + List> exportList = new ArrayList<>(); + for (ClockinTeamLog clockinTeamLog : clockinTeamLogs) { + ClockInProject clockInProject = clockInProjectService.lambdaQuery() + .eq(ClockInProject::getDelFlag, 0) + .eq(ClockInProject::getTeamId, clockinTeamLog.getTeamId()) + .one(); + + ClockinAuth clockinAuth = clockinAuthService.lambdaQuery() + .eq(ClockinAuth::getDelFlag, 0) + .eq(ClockinAuth::getUserId, clockinTeamLog.getUserId()) + .one(); + if (clockinAuth == null) { + continue; + } + + // 初始化记录,包含“姓名”和每日打卡记录 + Map record = new LinkedHashMap<>(); + record.put("name", clockinAuth.getName()); + record.put("date", nowYearMonth); + + for (int day = 1; day <= daysInMonth; day++) { + String yearMonthDay = nowYearMonth + "-" + (day < 10 ? "0" + day : day); + List clockInLogs = clockinLogMapper.getClockInLogExpeort( + yearMonthDay, clockInProject.getId(), clockinTeamLog.getUserId() + ); + + // 拼接打卡时间或标记“缺卡” + StringBuilder clockInTime = new StringBuilder(); + for (ClockInLogResp log : clockInLogs) { + if (StringUtils.isBlank(log.getTime())) { + log.setClockStartTime("缺卡"); + } + if (clockInTime.length() > 0) { + clockInTime.append("\n"); + } + clockInTime.append(log.getClockStartTime()); + } + record.put(day + "号", clockInTime.length() > 0 ? clockInTime.toString() : "缺卡"); + } + exportList.add(record); + } + + // Step.3 动态表头生成 + List headers = new ArrayList<>(); + headers.add("姓名"); + headers.add("日期"); + for (int i = 1; i <= daysInMonth; i++) { + headers.add(i + "号"); + } + + // Step.4 AutoPoi 导出Excel + ModelAndView mv = new ModelAndView(new JeecgMapExcelView()); + mv.addObject(NormalExcelConstants.FILE_NAME, title); +// mv.addObject(NormalExcelConstants.CLASS, clazz); + ExportParams exportParams = new ExportParams( + title + "报表", "导出人:" + sysUser.getRealname(), title); +// exportParams.setExclusions(headers.toArray(new String[0])); // 设置表头排除无用列 + mv.addObject(NormalExcelConstants.PARAMS, exportParams); + mv.addObject(NormalExcelConstants.MAP_LIST, exportList); + return mv; + } + + + + + private String getId(ClockinLog item) { try { return PropertyUtils.getProperty(item, "id").toString(); } catch (Exception e) { @@ -304,4 +426,5 @@ public class ClockinLogController extends JeecgController { @Select("SELECT IFNULL(count(1),0) FROM clockin_log WHERE del_flag = 0 AND user_id = #{userId} AND clock_in_time like '%${date}%'") Integer getClockInTotal(@Param("userId") String userId,@Param("date") String date); - @Select("select clock_start_time,(select clock_in_time from clockin_log where project_item_id = a.id and del_flag = 0 and user_id = #{userId} and clock_in_time like '%${date}%') time from clock_in_project_item a where project_id = #{projectId}\n") + @Select("select clock_start_time,(select clock_in_time from clockin_log where project_item_id = a.id and del_flag = 0 and user_id = '${userId}' and clock_in_time like '%${date}%') time from clock_in_project_item a where project_id = '${projectId}'\n") List getClockInLogExpeort(@Param("date") String date,@Param("projectId") String projectId,@Param("userId") String userId); } diff --git a/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/clockinlog/ressp/ClockInLogExportResp.java b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/clockinlog/ressp/ClockInLogExportResp.java index 62aeee1..a9f0e1e 100644 --- a/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/clockinlog/ressp/ClockInLogExportResp.java +++ b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/clockinlog/ressp/ClockInLogExportResp.java @@ -2,6 +2,7 @@ package org.jeecg.modules.clockinlog.ressp; import lombok.Data; import org.jeecgframework.poi.excel.annotation.Excel; +import org.jeecgframework.poi.excel.annotation.ExcelCollection; import java.util.List; @@ -17,16 +18,13 @@ import java.util.List; public class ClockInLogExportResp { /**年月*/ - @Excel(name = "时间", width = 15,height = 30) + @Excel(name = "时间", width = 15,height = 30,needMerge = true) private String date; /**姓名*/ - @Excel(name = "姓名", width = 15,height = 30) + @Excel(name = "姓名", width = 15,height = 30,needMerge = true) private String name; - /**日期*/ - @Excel(name = "日期", width = 15,height = 30) - private String day; - /**打卡时间*/ - @Excel(name = "打卡时间", width = 15,height = 30) - private String clockInTime; + @ExcelCollection(name = "打卡详情") + private List clockInLogExportResp2s; + } diff --git a/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/clockinlog/ressp/ClockInLogExportResp2.java b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/clockinlog/ressp/ClockInLogExportResp2.java new file mode 100644 index 0000000..934e58a --- /dev/null +++ b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/clockinlog/ressp/ClockInLogExportResp2.java @@ -0,0 +1,26 @@ +package org.jeecg.modules.clockinlog.ressp; + +import lombok.Data; +import org.jeecgframework.poi.excel.annotation.Excel; + +import java.util.Map; + +/** + * @author java996.icu + * @title: ClockInLogExperResp + * @projectName clockin-api + * @description: TODO + * @date 2024/11/29 11:53 + * @Version V1.0 + */ +@Data +public class ClockInLogExportResp2 { + + /**日期*/ + @Excel(name = "日期", width = 15,height = 30,needMerge = true) + private String day; + /**打卡时间*/ + @Excel(name = "打卡时间", width = 15,height = 30,needMerge = true) + private String clockInTime; + +} diff --git a/jeecg-boot-module-system/pom.xml b/jeecg-boot-module-system/pom.xml index 4ae1645..bed1725 100644 --- a/jeecg-boot-module-system/pom.xml +++ b/jeecg-boot-module-system/pom.xml @@ -74,6 +74,12 @@ compile + + org.apache.poi + poi-ooxml + 5.2.3 + + diff --git a/jeecg-boot-module-system/src/main/java/org/jeecg/modules/xcx/clockin/service/impl/ClockinServiceImpl.java b/jeecg-boot-module-system/src/main/java/org/jeecg/modules/xcx/clockin/service/impl/ClockinServiceImpl.java index eb87246..10408b9 100644 --- a/jeecg-boot-module-system/src/main/java/org/jeecg/modules/xcx/clockin/service/impl/ClockinServiceImpl.java +++ b/jeecg-boot-module-system/src/main/java/org/jeecg/modules/xcx/clockin/service/impl/ClockinServiceImpl.java @@ -13,6 +13,8 @@ import org.jeecg.modules.clockInproject.entity.ClockInProject; import org.jeecg.modules.clockInproject.service.IClockInProjectService; import org.jeecg.modules.clockInprojectitem.entity.ClockInProjectItem; import org.jeecg.modules.clockInprojectitem.service.IClockInProjectItemService; +import org.jeecg.modules.clockIntimezone.entity.ClockInTimeZone; +import org.jeecg.modules.clockIntimezone.service.IClockInTimeZoneService; import org.jeecg.modules.clockinconf.service.IClockInConfService; import org.jeecg.modules.clockinlog.entity.ClockinLog; import org.jeecg.modules.clockinlog.ressp.ClockInLogResp; @@ -29,6 +31,9 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; import java.util.*; @Slf4j @Service @@ -47,6 +52,8 @@ public class ClockinServiceImpl implements IClockinService { private IClockinTeamLogService clockinTeamLogService; @Resource private IClockInConfService clockInConfService; + @Resource + private IClockInTimeZoneService clockInTimeZoneService; @Transactional(rollbackFor = Exception.class) @Override @@ -78,8 +85,13 @@ public class ClockinServiceImpl implements IClockinService { log.info("距离:"+distance); throw new JeecgBootException("不在有效打卡距离内"); } - ClockInProjectItem validClockInTime = clockInProjectItemService.getValidClockInTime(DateUtils2.getZonedDateTimeNow(clockInProject.getTimeZone()), clockInProject.getId()); + ClockInTimeZone clockInTimeZone = clockInTimeZoneService.lambdaQuery() + .eq(ClockInTimeZone::getId, clockInProject.getTimeZone()) + .one(); + String zonedDateTimeNow = DateUtils2.getZonedDateTimeNow(clockInTimeZone.getTimeZone()); + ClockInProjectItem validClockInTime = clockInProjectItemService.getValidClockInTime(zonedDateTimeNow, clockInProject.getId()); if(validClockInTime == null){ + log.info("时间:"+zonedDateTimeNow+"项目id:"+clockInProject.getId()); throw new JeecgBootException("当前未到打卡时间"); } @@ -88,7 +100,8 @@ public class ClockinServiceImpl implements IClockinService { ClockinLog clockinLog1 = clockinLogService.lambdaQuery() .eq(ClockinLog::getDelFlag, 0) .eq(ClockinLog::getProjectItemId, validClockInTime.getId()) - .like(ClockinLog::getCreateTime, DateUtils2.getNowDateString3()) + .eq(ClockinLog::getUserId,hanHaiMember.getId()) + .like(ClockinLog::getCreateTime, DateUtils2.getNowDateString4(clockInTimeZone.getTimeZone())) .one(); ClockinLog clockinLog = new ClockinLog(); if(clockinLog1 != null){ @@ -103,7 +116,10 @@ public class ClockinServiceImpl implements IClockinService { clockinLog.setProjectId(clockInProject.getId()); clockinLog.setProjectItemId(validClockInTime.getId()); clockinLog.setTeamId(clockinTeamLog.getTeamId()); - clockinLog.setClockInTime(new Date()); + ZonedDateTime zonedDateTime = ZonedDateTime.now(ZoneId.of(clockInTimeZone.getTimeZone())); + LocalDateTime localDateTime = zonedDateTime.toLocalDateTime(); + Date date = Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant()); + clockinLog.setClockInTime(date); clockinLogService.saveOrUpdate(clockinLog); return Result.OK(); } @@ -150,6 +166,7 @@ public class ClockinServiceImpl implements IClockinService { List clockInProjectItemList = clockInProjectItemService.lambdaQuery() .eq(ClockInProjectItem::getDelFlag, 0) + .eq(ClockInProjectItem::getType,0) .eq(ClockInProjectItem::getProjectId, clockInProject.getId()) .list(); Date date = new Date(); @@ -237,9 +254,13 @@ public class ClockinServiceImpl implements IClockinService { if(clockInProject == null){ throw new JeecgBootException("当前团队未配置项目"); } - - ClockInProjectItem validClockInTime = clockInProjectItemService.getValidClockInTime(DateUtils2.getNowDateTimeStrings(), clockInProject.getId()); + ClockInTimeZone clockInTimeZone = clockInTimeZoneService.lambdaQuery() + .eq(ClockInTimeZone::getId, clockInProject.getTimeZone()) + .one(); + String zonedDateTimeNow = DateUtils2.getZonedDateTimeNow(clockInTimeZone.getTimeZone()); + ClockInProjectItem validClockInTime = clockInProjectItemService.getValidClockInTime(zonedDateTimeNow, clockInProject.getId()); if(validClockInTime == null){ + log.info("时间:"+zonedDateTimeNow+"项目id:"+clockInProject.getId()); throw new JeecgBootException("当前未到打卡时间"); } diff --git a/jeecg-boot-module-system/src/test/java/org/jeecg/Test.java b/jeecg-boot-module-system/src/test/java/org/jeecg/Test.java index 500140c..6a51b51 100644 --- a/jeecg-boot-module-system/src/test/java/org/jeecg/Test.java +++ b/jeecg-boot-module-system/src/test/java/org/jeecg/Test.java @@ -1,18 +1,29 @@ package org.jeecg; +import org.apache.commons.io.IOUtils; import org.jeecg.common.util.DateUtils2; +import java.time.LocalDateTime; import java.time.ZoneId; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.util.Date; +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import java.io.FileOutputStream; +import java.io.IOException; public class Test { @org.junit.Test public void test(){ - ZonedDateTime utc = ZonedDateTime.now(ZoneId.of("Asia/Jakarta")); + ZonedDateTime utc = ZonedDateTime.now(ZoneId.of("UTC+7")); + LocalDateTime localDateTime = utc.toLocalDateTime(); + Date date = Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant()); + System.out.println(date); + DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss"); System.out.println(dateTimeFormatter.format(utc)); ZonedDateTime beijingTime = ZonedDateTime.now(ZoneId.of("Asia/Shanghai")); @@ -24,4 +35,10 @@ public class Test { // System.out.println(yyyymm); } + @org.junit.Test + public void test2(){ + Package pkg = IOUtils.class.getPackage(); + System.out.println("Commons IO Version: " + pkg.getImplementationVersion()); + } + } diff --git a/pom.xml b/pom.xml index 833d0f6..1b16994 100644 --- a/pom.xml +++ b/pom.xml @@ -44,6 +44,7 @@ 1.9.0 1.1.22 2.6 + 2.11.0 2.1.0 3.11.2 @@ -59,6 +60,7 @@ 2.17.0 1.2.9 + 5.2.3 @@ -264,12 +266,12 @@ commons-fileupload commons-fileupload 1.4 - - - commons-io - commons-io - - + + + + commons-io + commons-io + ${commons-io.version} @@ -338,6 +340,27 @@ tencentcloud-sdk-java-iai 3.1.978 + + + org.apache.poi + poi-ooxml + ${poi-ooxml.version} + + + org.apache.poi + poi + ${poi-ooxml.version} + + + org.apache.xmlbeans + xmlbeans + 5.1.1 + + + org.apache.poi + poi-ooxml-schemas + 4.1.2 +