Browse Source

上传一下代码

master
HY 2 months ago
parent
commit
77c2dba508
16 changed files with 375 additions and 53 deletions
  1. +1
    -1
      admin-hanhai-vue/.env.development
  2. +20
    -15
      admin-hanhai-vue/src/views/xcx/ClockinLogList.vue
  3. +21
    -1
      jeecg-boot-base/jeecg-boot-base-core/pom.xml
  4. +11
    -0
      jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/DateUtils2.java
  5. +39
    -0
      jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/ExcelStyleUtil.java
  6. +30
    -0
      jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/clockInproject/controller/ClockInProjectController.java
  7. +2
    -0
      jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/clockInprojectitem/entity/ClockInProjectItem.java
  8. +138
    -15
      jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/clockinlog/controller/ClockinLogController.java
  9. +1
    -0
      jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/clockinlog/entity/ClockinLog.java
  10. +1
    -1
      jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/clockinlog/mapper/ClockinLogMapper.java
  11. +6
    -8
      jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/clockinlog/ressp/ClockInLogExportResp.java
  12. +26
    -0
      jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/clockinlog/ressp/ClockInLogExportResp2.java
  13. +6
    -0
      jeecg-boot-module-system/pom.xml
  14. +26
    -5
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/xcx/clockin/service/impl/ClockinServiceImpl.java
  15. +18
    -1
      jeecg-boot-module-system/src/test/java/org/jeecg/Test.java
  16. +29
    -6
      pom.xml

+ 1
- 1
admin-hanhai-vue/.env.development View File

@ -1,5 +1,5 @@
NODE_ENV=development 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_CAS_BASE_URL=http://cas.example.org:8443/cas
VUE_APP_ONLINE_BASE_URL=http://fileview.jeecg.com/onlinePreview VUE_APP_ONLINE_BASE_URL=http://fileview.jeecg.com/onlinePreview
VUE_APP_MAP_KEY=WPKBZ-OKICI-ZAIGE-U6TQ4-RPQIV-OXBJO VUE_APP_MAP_KEY=WPKBZ-OKICI-ZAIGE-U6TQ4-RPQIV-OXBJO


+ 20
- 15
admin-hanhai-vue/src/views/xcx/ClockinLogList.vue View File

@ -11,7 +11,7 @@
</a-col> </a-col>
<a-col :md="6" :sm="12"> <a-col :md="6" :sm="12">
<a-form-item label="员工姓名"> <a-form-item label="员工姓名">
<j-search-select-tag dict-code="clockin_auth,name,user_id" placeholder="请输入员工姓名" v-model="queryParam.userId"></j-search-select-tag>
<j-search-select-tag dict="clockin_auth,name,user_id,del_flag=0" placeholder="请输入员工姓名" v-model="queryParam.userId"></j-search-select-tag>
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row> </a-row>
@ -22,7 +22,7 @@
<!-- 操作按钮区域 --> <!-- 操作按钮区域 -->
<div class="table-operator"> <div class="table-operator">
<!-- <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>--> <!-- <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>-->
<a-button type="primary" icon="download" @click="handleExportXls('clockin_log')">导出</a-button>
<a-button type="primary" icon="download" @click="handleExportXls('打卡报表')">导出</a-button>
<!-- <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">--> <!-- <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">-->
<!-- <a-button type="primary" icon="import">导入</a-button>--> <!-- <a-button type="primary" icon="import">导入</a-button>-->
<!-- </a-upload>--> <!-- </a-upload>-->
@ -119,23 +119,23 @@
}, },
data () { data () {
return { return {
description: 'clockin_log管理页面',
description: '打卡管理页面',
// //
columns: [ 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", align:"center",
customRender:function (t,r,index) {
return parseInt(index)+1;
}
},
{
title:'用户编号',
align:"center",
dataIndex: 'userId'
dataIndex: 'userId_dictText'
}, },
{ {
title:'照片', title:'照片',
@ -143,6 +143,11 @@
dataIndex: 'pic', dataIndex: 'pic',
scopedSlots: {customRender: 'imgSlot'} scopedSlots: {customRender: 'imgSlot'}
}, },
{
title:'打卡时间',
align:"center",
dataIndex: 'clockInTime'
},
{ {
title:'打卡地址', title:'打卡地址',
align:"center", align:"center",


+ 21
- 1
jeecg-boot-base/jeecg-boot-base-core/pom.xml View File

@ -73,7 +73,7 @@
<dependency> <dependency>
<groupId>commons-io</groupId> <groupId>commons-io</groupId>
<artifactId>commons-io</artifactId> <artifactId>commons-io</artifactId>
<version>${commons.version}</version>
<version>${commons-io.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>commons-lang</groupId> <groupId>commons-lang</groupId>
@ -273,6 +273,26 @@
<version>3.1.978</version> <version>3.1.978</version>
</dependency> </dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>${poi-ooxml.version}</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>${poi-ooxml.version}</version>
</dependency>
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>5.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>4.1.2</version>
</dependency>
</dependencies> </dependencies>


+ 11
- 0
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/DateUtils2.java View File

@ -95,6 +95,17 @@ public class DateUtils2 {
return dateTimeFormatter.format(localDateTime); 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 * 获取当前日期 yyyymmdd
* @return * @return


+ 39
- 0
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/ExcelStyleUtil.java View File

@ -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;
}
}

+ 30
- 0
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/clockInproject/controller/ClockInProjectController.java View File

@ -9,7 +9,10 @@ import java.io.UnsupportedEncodingException;
import java.net.URLDecoder; import java.net.URLDecoder;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.api.vo.Result; import org.jeecg.common.api.vo.Result;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.system.query.QueryGenerator; import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.oConvertUtils; import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.clockInproject.entity.ClockInProject; import org.jeecg.modules.clockInproject.entity.ClockInProject;
@ -82,6 +85,16 @@ public class ClockInProjectController extends JeecgController<ClockInProject, IC
@ApiOperation(value="clock_in_project-添加", notes="clock_in_project-添加") @ApiOperation(value="clock_in_project-添加", notes="clock_in_project-添加")
@PostMapping(value = "/add") @PostMapping(value = "/add")
public Result<String> add(@RequestBody ClockInProject clockInProject) { public Result<String> add(@RequestBody ClockInProject clockInProject) {
if(StringUtils.isNotBlank(clockInProject.getTeamId())){
List<ClockInProject> 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); clockInProjectService.save(clockInProject);
return Result.OK("添加成功!"); return Result.OK("添加成功!");
} }
@ -96,6 +109,23 @@ public class ClockInProjectController extends JeecgController<ClockInProject, IC
@ApiOperation(value="clock_in_project-编辑", notes="clock_in_project-编辑") @ApiOperation(value="clock_in_project-编辑", notes="clock_in_project-编辑")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST}) @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
public Result<String> edit(@RequestBody ClockInProject clockInProject) { public Result<String> edit(@RequestBody ClockInProject clockInProject) {
if(StringUtils.isNotBlank(clockInProject.getTeamId())){
List<ClockInProject> 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); clockInProjectService.updateById(clockInProject);
return Result.OK("编辑成功!"); return Result.OK("编辑成功!");
} }


+ 2
- 0
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/clockInprojectitem/entity/ClockInProjectItem.java View File

@ -73,4 +73,6 @@ public class ClockInProjectItem implements Serializable {
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "修改时间") @ApiModelProperty(value = "修改时间")
private java.util.Date updateTime; private java.util.Date updateTime;
/**类型 0正常 1周末 2加班*/
private Integer type;
} }

+ 138
- 15
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/clockinlog/controller/ClockinLogController.java View File

@ -10,13 +10,20 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import org.apache.commons.beanutils.PropertyUtils; import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils; 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.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result; import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator; import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.vo.LoginUser; import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.DateUtils2; import org.jeecg.common.util.DateUtils2;
import org.jeecg.common.util.ExcelStyleUtil;
import org.jeecg.common.util.oConvertUtils; import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.clockInproject.entity.ClockInProject; import org.jeecg.modules.clockInproject.entity.ClockInProject;
import org.jeecg.modules.clockInproject.service.IClockInProjectService; 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.entity.ClockinLog;
import org.jeecg.modules.clockinlog.mapper.ClockinLogMapper; import org.jeecg.modules.clockinlog.mapper.ClockinLogMapper;
import org.jeecg.modules.clockinlog.ressp.ClockInLogExportResp; 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.ressp.ClockInLogResp;
import org.jeecg.modules.clockinlog.service.IClockinLogService; 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.entity.ClockinTeamLog;
import org.jeecg.modules.clockinteamlog.service.IClockinTeamLogService; import org.jeecg.modules.clockinteamlog.service.IClockinTeamLogService;
import org.jeecgframework.poi.excel.ExcelExportUtil;
import org.jeecgframework.poi.excel.ExcelImportUtil; import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants; import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams; import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams; import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.entity.enmus.ExcelType;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.jeecg.common.system.base.controller.JeecgController; 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.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -185,7 +196,7 @@ public class ClockinLogController extends JeecgController<ClockinLog, IClockinLo
@RequestMapping(value = "/exportXls2") @RequestMapping(value = "/exportXls2")
public ModelAndView exportXls3(HttpServletRequest request, ClockinLog clockinLog) { public ModelAndView exportXls3(HttpServletRequest request, ClockinLog clockinLog) {
return this.exportXls2(request, ClockInLogExportResp.class, "打卡");
return this.exportXls3(request,ClockInLogExportResp2.class, "打卡");
} }
// @RequestMapping(value = "/exportXls2") // @RequestMapping(value = "/exportXls2")
@ -193,15 +204,21 @@ public class ClockinLogController extends JeecgController<ClockinLog, IClockinLo
// Step.1 组装查询条件 // Step.1 组装查询条件
Map<String, String[]> parameterMap = request.getParameterMap(); Map<String, String[]> parameterMap = request.getParameterMap();
String[] clockStartTimes = parameterMap.get("clockStartTime"); String[] clockStartTimes = parameterMap.get("clockStartTime");
String[] userIds = parameterMap.get("userId");
// QueryWrapper<ClockinLog> queryWrapper = QueryGenerator.initQueryWrapper(object, request.getParameterMap()); // QueryWrapper<ClockinLog> queryWrapper = QueryGenerator.initQueryWrapper(object, request.getParameterMap());
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
List<ClockinTeamLog> clockinTeamLogs = clockinTeamLogService.lambdaQuery()
.eq(ClockinTeamLog::getDelFlag, 0)
// .eq(ClockinTeamLog::getStatus,1)
.list();
LambdaQueryChainWrapper<ClockinTeamLog> queryChainWrapper = clockinTeamLogService.lambdaQuery()
.eq(ClockinTeamLog::getDelFlag, 0);
// List<ClockinTeamLog> 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<ClockinTeamLog> clockinTeamLogs = queryChainWrapper.list();
// int day = Integer.parseInt(DateUtils2.getNowMonthMaxDay()); // int day = Integer.parseInt(DateUtils2.getNowMonthMaxDay());
@ -229,6 +246,9 @@ public class ClockinLogController extends JeecgController<ClockinLog, IClockinLo
.eq(ClockInProject::getTeamId, clockinTeamLog.getTeamId()) .eq(ClockInProject::getTeamId, clockinTeamLog.getTeamId())
.one(); .one();
if(clockInProject == null){
continue;
}
ClockinAuth clockinAuth = clockinAuthService.lambdaQuery() ClockinAuth clockinAuth = clockinAuthService.lambdaQuery()
.eq(ClockinAuth::getDelFlag, 0) .eq(ClockinAuth::getDelFlag, 0)
.eq(ClockinAuth::getUserId, clockinTeamLog.getUserId()) .eq(ClockinAuth::getUserId, clockinTeamLog.getUserId())
@ -236,13 +256,20 @@ public class ClockinLogController extends JeecgController<ClockinLog, IClockinLo
if(clockinAuth == null){ if(clockinAuth == null){
continue; continue;
} }
List<ClockInLogExportResp2> clockInLogExportResp2s = new ArrayList<>();
ClockInLogExportResp clockInLogExportResp = new ClockInLogExportResp();
clockInLogExportResp.setName(clockinAuth.getName());
clockInLogExportResp.setDate(nowYearMonth);
for (int n= 1;n<=day;n++){ 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<ClockInLogResp> clockInLogExpeort = clockinLogMapper.getClockInLogExpeort(yearMonthDay, clockInProject.getId(), clockinTeamLog.getUserId()); List<ClockInLogResp> clockInLogExpeort = clockinLogMapper.getClockInLogExpeort(yearMonthDay, clockInProject.getId(), clockinTeamLog.getUserId());
String clockInTime = ""; String clockInTime = "";
for (ClockInLogResp clockInLogResp:clockInLogExpeort) { for (ClockInLogResp clockInLogResp:clockInLogExpeort) {
@ -253,10 +280,12 @@ public class ClockinLogController extends JeecgController<ClockinLog, IClockinLo
clockInTime = clockInTime+"\n"+clockInLogResp.getClockStartTime(); clockInTime = clockInTime+"\n"+clockInLogResp.getClockStartTime();
// strings.add(clockInLogResp.getClockStartTime()); // strings.add(clockInLogResp.getClockStartTime());
} }
clockInLogExportResp.setClockInTime(clockInTime);
exportList.add(clockInLogExportResp);
}
clockInLogExportResp2.setClockInTime(clockInTime);
clockInLogExportResp2s.add(clockInLogExportResp2);
}
clockInLogExportResp.setClockInLogExportResp2s(clockInLogExportResp2s);
exportList.add(clockInLogExportResp);
} }
@ -276,14 +305,107 @@ public class ClockinLogController extends JeecgController<ClockinLog, IClockinLo
mv.addObject(NormalExcelConstants.CLASS, clazz); mv.addObject(NormalExcelConstants.CLASS, clazz);
//update-begin--Author:liusq Date:20210126 for图片导出报错ImageBasePath未设置-------------------- //update-begin--Author:liusq Date:20210126 for图片导出报错ImageBasePath未设置--------------------
ExportParams exportParams=new ExportParams(title + "报表", "导出人:" + sysUser.getRealname(), title); ExportParams exportParams=new ExportParams(title + "报表", "导出人:" + sysUser.getRealname(), title);
// exportParams.setType(ExcelType.XSSF);
exportParams.setImageBasePath(upLoadPath); exportParams.setImageBasePath(upLoadPath);
//update-end--Author:liusq Date:20210126 for图片导出报错ImageBasePath未设置---------------------- //update-end--Author:liusq Date:20210126 for图片导出报错ImageBasePath未设置----------------------
mv.addObject(NormalExcelConstants.PARAMS,exportParams); mv.addObject(NormalExcelConstants.PARAMS,exportParams);
mv.addObject(NormalExcelConstants.DATA_LIST, exportList); mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
return mv; return mv;
} }
private String getId(ClockinLog item) {
protected ModelAndView exportXls3(HttpServletRequest request, Class<ClockInLogExportResp2> clazz, String title) {
// Step.1 组装查询条件
Map<String, String[]> parameterMap = request.getParameterMap();
String[] clockStartTimes = parameterMap.get("clockStartTime");
String[] userIds = parameterMap.get("userId");
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
LambdaQueryChainWrapper<ClockinTeamLog> queryChainWrapper = clockinTeamLogService.lambdaQuery()
.eq(ClockinTeamLog::getDelFlag, 0);
if (userIds != null && userIds.length != 0 && StringUtils.isNotBlank(userIds[0])) {
queryChainWrapper.eq(ClockinTeamLog::getUserId, userIds[0]);
}
List<ClockinTeamLog> 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<Map<String, Object>> 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<String, Object> 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<ClockInLogResp> 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<String> 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 { try {
return PropertyUtils.getProperty(item, "id").toString(); return PropertyUtils.getProperty(item, "id").toString();
} catch (Exception e) { } catch (Exception e) {
@ -304,4 +426,5 @@ public class ClockinLogController extends JeecgController<ClockinLog, IClockinLo
return super.importExcel(request, response, ClockinLog.class); return super.importExcel(request, response, ClockinLog.class);
} }
} }

+ 1
- 0
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/clockinlog/entity/ClockinLog.java View File

@ -37,6 +37,7 @@ public class ClockinLog implements Serializable {
@ApiModelProperty(value = "id") @ApiModelProperty(value = "id")
private java.lang.String id; private java.lang.String id;
/**用户编号*/ /**用户编号*/
@Dict(dictTable = "clockin_auth",dicCode = "user_id",dicText = "name")
@Excel(name = "用户编号", width = 15) @Excel(name = "用户编号", width = 15)
@ApiModelProperty(value = "用户编号") @ApiModelProperty(value = "用户编号")
private java.lang.String userId; private java.lang.String userId;


+ 1
- 1
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/clockinlog/mapper/ClockinLogMapper.java View File

@ -41,7 +41,7 @@ public interface ClockinLogMapper extends BaseMapper<ClockinLog> {
@Select("SELECT IFNULL(count(1),0) FROM clockin_log WHERE del_flag = 0 AND user_id = #{userId} AND clock_in_time like '%${date}%'") @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); 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<ClockInLogResp> getClockInLogExpeort(@Param("date") String date,@Param("projectId") String projectId,@Param("userId") String userId); List<ClockInLogResp> getClockInLogExpeort(@Param("date") String date,@Param("projectId") String projectId,@Param("userId") String userId);
} }

+ 6
- 8
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/clockinlog/ressp/ClockInLogExportResp.java View File

@ -2,6 +2,7 @@ package org.jeecg.modules.clockinlog.ressp;
import lombok.Data; import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel; import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecgframework.poi.excel.annotation.ExcelCollection;
import java.util.List; import java.util.List;
@ -17,16 +18,13 @@ import java.util.List;
public class ClockInLogExportResp { public class ClockInLogExportResp {
/**年月*/ /**年月*/
@Excel(name = "时间", width = 15,height = 30)
@Excel(name = "时间", width = 15,height = 30,needMerge = true)
private String date; private String date;
/**姓名*/ /**姓名*/
@Excel(name = "姓名", width = 15,height = 30)
@Excel(name = "姓名", width = 15,height = 30,needMerge = true)
private String name; 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<ClockInLogExportResp2> clockInLogExportResp2s;
} }

+ 26
- 0
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/clockinlog/ressp/ClockInLogExportResp2.java View File

@ -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;
}

+ 6
- 0
jeecg-boot-module-system/pom.xml View File

@ -74,6 +74,12 @@
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.2.3</version>
</dependency>
</dependencies> </dependencies>
<build> <build>


+ 26
- 5
jeecg-boot-module-system/src/main/java/org/jeecg/modules/xcx/clockin/service/impl/ClockinServiceImpl.java View File

@ -13,6 +13,8 @@ import org.jeecg.modules.clockInproject.entity.ClockInProject;
import org.jeecg.modules.clockInproject.service.IClockInProjectService; import org.jeecg.modules.clockInproject.service.IClockInProjectService;
import org.jeecg.modules.clockInprojectitem.entity.ClockInProjectItem; import org.jeecg.modules.clockInprojectitem.entity.ClockInProjectItem;
import org.jeecg.modules.clockInprojectitem.service.IClockInProjectItemService; 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.clockinconf.service.IClockInConfService;
import org.jeecg.modules.clockinlog.entity.ClockinLog; import org.jeecg.modules.clockinlog.entity.ClockinLog;
import org.jeecg.modules.clockinlog.ressp.ClockInLogResp; import org.jeecg.modules.clockinlog.ressp.ClockInLogResp;
@ -29,6 +31,9 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.*; import java.util.*;
@Slf4j @Slf4j
@Service @Service
@ -47,6 +52,8 @@ public class ClockinServiceImpl implements IClockinService {
private IClockinTeamLogService clockinTeamLogService; private IClockinTeamLogService clockinTeamLogService;
@Resource @Resource
private IClockInConfService clockInConfService; private IClockInConfService clockInConfService;
@Resource
private IClockInTimeZoneService clockInTimeZoneService;
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Override @Override
@ -78,8 +85,13 @@ public class ClockinServiceImpl implements IClockinService {
log.info("距离:"+distance); log.info("距离:"+distance);
throw new JeecgBootException("不在有效打卡距离内"); 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){ if(validClockInTime == null){
log.info("时间:"+zonedDateTimeNow+"项目id:"+clockInProject.getId());
throw new JeecgBootException("当前未到打卡时间"); throw new JeecgBootException("当前未到打卡时间");
} }
@ -88,7 +100,8 @@ public class ClockinServiceImpl implements IClockinService {
ClockinLog clockinLog1 = clockinLogService.lambdaQuery() ClockinLog clockinLog1 = clockinLogService.lambdaQuery()
.eq(ClockinLog::getDelFlag, 0) .eq(ClockinLog::getDelFlag, 0)
.eq(ClockinLog::getProjectItemId, validClockInTime.getId()) .eq(ClockinLog::getProjectItemId, validClockInTime.getId())
.like(ClockinLog::getCreateTime, DateUtils2.getNowDateString3())
.eq(ClockinLog::getUserId,hanHaiMember.getId())
.like(ClockinLog::getCreateTime, DateUtils2.getNowDateString4(clockInTimeZone.getTimeZone()))
.one(); .one();
ClockinLog clockinLog = new ClockinLog(); ClockinLog clockinLog = new ClockinLog();
if(clockinLog1 != null){ if(clockinLog1 != null){
@ -103,7 +116,10 @@ public class ClockinServiceImpl implements IClockinService {
clockinLog.setProjectId(clockInProject.getId()); clockinLog.setProjectId(clockInProject.getId());
clockinLog.setProjectItemId(validClockInTime.getId()); clockinLog.setProjectItemId(validClockInTime.getId());
clockinLog.setTeamId(clockinTeamLog.getTeamId()); 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); clockinLogService.saveOrUpdate(clockinLog);
return Result.OK(); return Result.OK();
} }
@ -150,6 +166,7 @@ public class ClockinServiceImpl implements IClockinService {
List<ClockInProjectItem> clockInProjectItemList = clockInProjectItemService.lambdaQuery() List<ClockInProjectItem> clockInProjectItemList = clockInProjectItemService.lambdaQuery()
.eq(ClockInProjectItem::getDelFlag, 0) .eq(ClockInProjectItem::getDelFlag, 0)
.eq(ClockInProjectItem::getType,0)
.eq(ClockInProjectItem::getProjectId, clockInProject.getId()) .eq(ClockInProjectItem::getProjectId, clockInProject.getId())
.list(); .list();
Date date = new Date(); Date date = new Date();
@ -237,9 +254,13 @@ public class ClockinServiceImpl implements IClockinService {
if(clockInProject == null){ if(clockInProject == null){
throw new JeecgBootException("当前团队未配置项目"); 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){ if(validClockInTime == null){
log.info("时间:"+zonedDateTimeNow+"项目id:"+clockInProject.getId());
throw new JeecgBootException("当前未到打卡时间"); throw new JeecgBootException("当前未到打卡时间");
} }


+ 18
- 1
jeecg-boot-module-system/src/test/java/org/jeecg/Test.java View File

@ -1,18 +1,29 @@
package org.jeecg; package org.jeecg;
import org.apache.commons.io.IOUtils;
import org.jeecg.common.util.DateUtils2; import org.jeecg.common.util.DateUtils2;
import java.time.LocalDateTime;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.Date; 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 { public class Test {
@org.junit.Test @org.junit.Test
public void 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"); DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss");
System.out.println(dateTimeFormatter.format(utc)); System.out.println(dateTimeFormatter.format(utc));
ZonedDateTime beijingTime = ZonedDateTime.now(ZoneId.of("Asia/Shanghai")); ZonedDateTime beijingTime = ZonedDateTime.now(ZoneId.of("Asia/Shanghai"));
@ -24,4 +35,10 @@ public class Test {
// System.out.println(yyyymm); // System.out.println(yyyymm);
} }
@org.junit.Test
public void test2(){
Package pkg = IOUtils.class.getPackage();
System.out.println("Commons IO Version: " + pkg.getImplementationVersion());
}
} }

+ 29
- 6
pom.xml View File

@ -44,6 +44,7 @@
<minidao.version>1.9.0</minidao.version> <minidao.version>1.9.0</minidao.version>
<druid.version>1.1.22</druid.version> <druid.version>1.1.22</druid.version>
<commons.version>2.6</commons.version> <commons.version>2.6</commons.version>
<commons-io.version>2.11.0</commons-io.version>
<aliyun-java-sdk-dysmsapi.version>2.1.0</aliyun-java-sdk-dysmsapi.version> <aliyun-java-sdk-dysmsapi.version>2.1.0</aliyun-java-sdk-dysmsapi.version>
<aliyun.oss.version>3.11.2</aliyun.oss.version> <aliyun.oss.version>3.11.2</aliyun.oss.version>
<!-- shiro --> <!-- shiro -->
@ -59,6 +60,7 @@
<!-- Log4j2爆雷漏洞 --> <!-- Log4j2爆雷漏洞 -->
<log4j2.version>2.17.0</log4j2.version> <log4j2.version>2.17.0</log4j2.version>
<logback.version>1.2.9</logback.version> <logback.version>1.2.9</logback.version>
<poi-ooxml.version>5.2.3</poi-ooxml.version>
</properties> </properties>
<modules> <modules>
@ -264,12 +266,12 @@
<groupId>commons-fileupload</groupId> <groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId> <artifactId>commons-fileupload</artifactId>
<version>1.4</version> <version>1.4</version>
<exclusions>
<exclusion>
<artifactId>commons-io</artifactId>
<groupId>commons-io</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons-io.version}</version>
</dependency> </dependency>
<!-- justauth第三方登录 --> <!-- justauth第三方登录 -->
@ -338,6 +340,27 @@
<artifactId>tencentcloud-sdk-java-iai</artifactId> <artifactId>tencentcloud-sdk-java-iai</artifactId>
<version>3.1.978</version> <version>3.1.978</version>
</dependency> </dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>${poi-ooxml.version}</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>${poi-ooxml.version}</version>
</dependency>
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>5.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>4.1.2</version>
</dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>


Loading…
Cancel
Save