Browse Source

上传一下代码

master
HY 3 months ago
parent
commit
3fd76e37d9
3 changed files with 188 additions and 50 deletions
  1. +40
    -2
      admin-hanhai-vue/src/views/xcx/ClockinLogList.vue
  2. +147
    -47
      jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/clockinlog/controller/ClockinLogController.java
  3. +1
    -1
      pom.xml

+ 40
- 2
admin-hanhai-vue/src/views/xcx/ClockinLogList.vue View File

@ -14,6 +14,11 @@
<j-search-select-tag dict="clockin_auth,name,user_id,del_flag=0" 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-col :md="6" :sm="12">
<a-form-item label="项目">
<j-search-select-tag dict="clock_in_project,name,id,del_flag=0" placeholder="请输入项目名称" v-model="queryParam.projectId"></j-search-select-tag>
</a-form-item>
</a-col>
</a-row> </a-row>
</a-form> </a-form>
</div> </div>
@ -22,7 +27,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('打卡报表')">导出</a-button>
<a-button type="primary" icon="download" @click="handleExportXls2('打卡报表')">导出</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>-->
@ -110,6 +115,7 @@
import { JeecgListMixin } from '@/mixins/JeecgListMixin' import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import ClockinLogModal from './modules/ClockinLogModal' import ClockinLogModal from './modules/ClockinLogModal'
import {filterMultiDictText} from '@/components/dict/JDictSelectUtil' import {filterMultiDictText} from '@/components/dict/JDictSelectUtil'
import {downFile} from "@api/manage";
export default { export default {
name: 'ClockinLogList', name: 'ClockinLogList',
@ -209,7 +215,39 @@
fieldList.push({type:'string',value:'lat',text:'纬度',dictCode:''}) fieldList.push({type:'string',value:'lat',text:'纬度',dictCode:''})
fieldList.push({type:'int',value:'delFlag',text:'是否删除',dictCode:'is_delete'}) fieldList.push({type:'int',value:'delFlag',text:'是否删除',dictCode:'is_delete'})
this.superFieldList = fieldList this.superFieldList = fieldList
}
},
handleExportXls2(fileName){
if(!fileName || typeof fileName != "string"){
fileName = "导出文件"
}
let param = this.getQueryParams();
if(this.selectedRowKeys && this.selectedRowKeys.length>0){
param['selections'] = this.selectedRowKeys.join(",")
}
console.log("导出参数",param)
this.loading = true;
downFile(this.url.exportXlsUrl,param).then((data)=>{
if (!data) {
this.$message.warning("文件下载失败")
return
}
if (typeof window.navigator.msSaveBlob !== 'undefined') {
window.navigator.msSaveBlob(new Blob([data],{type: 'application/vnd.ms-excel'}), fileName+'.xls')
}else{
let url = window.URL.createObjectURL(new Blob([data],{type: 'application/vnd.ms-excel'}))
let link = document.createElement('a')
link.style.display = 'none'
link.href = url
link.setAttribute('download', fileName+'.xls')
document.body.appendChild(link)
link.click()
document.body.removeChild(link); //
window.URL.revokeObjectURL(url); //blob
}
}).finally(() => {
this.loading = false;
});
},
} }
} }
</script> </script>


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

@ -16,12 +16,14 @@ import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapp
import org.apache.commons.beanutils.PropertyUtils; import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; 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.exception.JeecgBootException;
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;
@ -51,6 +53,7 @@ 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.entity.enmus.ExcelType;
import org.jeecgframework.poi.excel.entity.params.ExcelExportEntity;
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.jeecgframework.poi.excel.view.JeecgMapExcelView;
@ -207,6 +210,7 @@ public class ClockinLogController extends JeecgController<ClockinLog, IClockinLo
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"); String[] userIds = parameterMap.get("userId");
String[] projectIds = parameterMap.get("projectId");
// 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();
@ -221,6 +225,27 @@ public class ClockinLogController extends JeecgController<ClockinLog, IClockinLo
queryChainWrapper.eq(ClockinTeamLog::getUserId,userIds[0]); queryChainWrapper.eq(ClockinTeamLog::getUserId,userIds[0]);
} }
List<ClockinTeamLog> clockinTeamLogs = queryChainWrapper.list(); List<ClockinTeamLog> clockinTeamLogs = queryChainWrapper.list();
if(projectIds!=null && projectIds.length!=0 && StringUtils.isNotBlank(projectIds[0])){
ClockInProject clockInProject = clockInProjectService.lambdaQuery()
.eq(ClockInProject::getDelFlag, 0)
.eq(ClockInProject::getId,projectIds[0])
.one();
if(clockInProject == null){
throw new JeecgBootException("项目错误");
}
try {
clockinTeamLogs = clockinTeamLogService.lambdaQuery()
.eq(ClockinTeamLog::getDelFlag, 0)
.eq(ClockinTeamLog::getTeamId, clockInProject.getTeamId())
.list();
// clockinTeamLogs.add(clockinTeamLog);
}catch (Exception e){
throw new JeecgBootException("该项目可能存在两个团队绑定,请检查项目管理");
}
}
// int day = Integer.parseInt(DateUtils2.getNowMonthMaxDay()); // int day = Integer.parseInt(DateUtils2.getNowMonthMaxDay());
@ -235,7 +260,6 @@ public class ClockinLogController extends JeecgController<ClockinLog, IClockinLo
String yearMonthDay = ""; String yearMonthDay = "";
// Step.2 获取导出数据 // Step.2 获取导出数据
// List<ClockinLog> pageList = service.list(queryWrapper); // List<ClockinLog> pageList = service.list(queryWrapper);
// List<ClockinLog> exportList = null; // List<ClockinLog> exportList = null;
@ -314,6 +338,7 @@ 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.setType(ExcelType.XSSF);
exportParams.setImageBasePath(upLoadPath); exportParams.setImageBasePath(upLoadPath);
@ -325,95 +350,170 @@ public class ClockinLogController extends JeecgController<ClockinLog, IClockinLo
protected ModelAndView exportXls3(HttpServletRequest request, Class<ClockInLogExportResp2> clazz, String title) {
protected ModelAndView exportXls3(HttpServletRequest request, Class<ClockInLogExportResp> clazz, String title) {
// 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"); String[] userIds = parameterMap.get("userId");
String[] projectIds = parameterMap.get("projectId");
// QueryWrapper<ClockinLog> queryWrapper = QueryGenerator.initQueryWrapper(object, request.getParameterMap());
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
LambdaQueryChainWrapper<ClockinTeamLog> queryChainWrapper = clockinTeamLogService.lambdaQuery() LambdaQueryChainWrapper<ClockinTeamLog> queryChainWrapper = clockinTeamLogService.lambdaQuery()
.eq(ClockinTeamLog::getDelFlag, 0); .eq(ClockinTeamLog::getDelFlag, 0);
if (userIds != null && userIds.length != 0 && StringUtils.isNotBlank(userIds[0])) {
queryChainWrapper.eq(ClockinTeamLog::getUserId, userIds[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(); List<ClockinTeamLog> clockinTeamLogs = queryChainWrapper.list();
if(projectIds!=null && projectIds.length!=0 && StringUtils.isNotBlank(projectIds[0])){
ClockInProject clockInProject = clockInProjectService.lambdaQuery()
.eq(ClockInProject::getDelFlag, 0)
.eq(ClockInProject::getId,projectIds[0])
.one();
if(clockInProject == null){
throw new JeecgBootException("项目错误");
}
try {
clockinTeamLogs = clockinTeamLogService.lambdaQuery()
.eq(ClockinTeamLog::getDelFlag, 0)
.eq(ClockinTeamLog::getTeamId, clockInProject.getTeamId())
.list();
// clockinTeamLogs.add(clockinTeamLog);
}catch (Exception e){
throw new JeecgBootException("该项目可能存在两个团队绑定,请检查项目管理");
}
}
List<Map<String, Object>> maps = new ArrayList<>();
Map<String, Object> map = new HashMap<>();
List<ExcelExportEntity> entity = new ArrayList<ExcelExportEntity>();
ExcelExportEntity excelExportEntity = new ExcelExportEntity("姓名", "name");
excelExportEntity.setNeedMerge(true);
ExcelExportEntity excelExportEntity1 = new ExcelExportEntity("性别", "sex");
excelExportEntity1.setNeedMerge(true);
ExcelExportEntity excelExportEntity2 = new ExcelExportEntity("数据", "list");
excelExportEntity2.setNeedMerge(true);
// 确定导出月份
entity.add(excelExportEntity);
entity.add(excelExportEntity1);
entity.add(excelExportEntity2);
// int day = Integer.parseInt(DateUtils2.getNowMonthMaxDay());
String nowYearMonth = DateUtils2.getNowYearMonth(); String nowYearMonth = DateUtils2.getNowYearMonth();
if (clockStartTimes != null && clockStartTimes.length != 0 && StringUtils.isNotBlank(clockStartTimes[0])) {
if(clockStartTimes!=null && clockStartTimes.length!=0 && StringUtils.isNotBlank(clockStartTimes[0])){
nowYearMonth = clockStartTimes[0]; nowYearMonth = clockStartTimes[0];
} }
YearMonth yearMonth = YearMonth.parse(nowYearMonth); YearMonth yearMonth = YearMonth.parse(nowYearMonth);
int daysInMonth = yearMonth.lengthOfMonth(); // 当前月份的天数
int day = yearMonth.lengthOfMonth();
String yearMonthDay = "";
// Step.2 获取导出数据 // Step.2 获取导出数据
List<Map<String, Object>> exportList = new ArrayList<>();
for (ClockinTeamLog clockinTeamLog : clockinTeamLogs) {
// List<ClockinLog> pageList = service.list(queryWrapper);
// List<ClockinLog> exportList = null;
List<Map<String, Object>> list = new ArrayList<>();
List<String> strings = null;
List<ClockInLogExportResp> exportList = new ArrayList<>();
for (ClockinTeamLog clockinTeamLog:clockinTeamLogs){
ClockInProject clockInProject = clockInProjectService.lambdaQuery() ClockInProject clockInProject = clockInProjectService.lambdaQuery()
.eq(ClockInProject::getDelFlag, 0) .eq(ClockInProject::getDelFlag, 0)
.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())
.one(); .one();
if (clockinAuth == null) {
if(clockinAuth == null){
continue; continue;
} }
List<ClockInLogExportResp2> clockInLogExportResp2s = new ArrayList<>();
ClockInLogExportResp clockInLogExportResp = new ClockInLogExportResp();
clockInLogExportResp.setName(clockinAuth.getName());
clockInLogExportResp.setDate(nowYearMonth);
map.put("name",clockinAuth.getName());
map.put("sex",nowYearMonth);
List<Map<String, Object>> maps1 = new ArrayList<>();
for (int n= 1;n<=day;n++){
ClockInLogExportResp2 clockInLogExportResp2 = new ClockInLogExportResp2();
clockInLogExportResp2.setDay(n+"");
yearMonthDay = nowYearMonth+"-"+n;
if(n < 10){
yearMonthDay = nowYearMonth+"-0"+n;
}
// 初始化记录包含姓名和每日打卡记录
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);
Date date = DateUtils2.getDate(yearMonthDay + " 23:59:59"); Date date = DateUtils2.getDate(yearMonthDay + " 23:59:59");
LocalDateTime localDateTime = DateUtils2.dateToDateTime(date); LocalDateTime localDateTime = DateUtils2.dateToDateTime(date);
Integer type = 0; Integer type = 0;
if(DayOfWeek.SATURDAY.equals(localDateTime.getDayOfWeek()) || DayOfWeek.SUNDAY.equals(localDateTime.getDayOfWeek())){ if(DayOfWeek.SATURDAY.equals(localDateTime.getDayOfWeek()) || DayOfWeek.SUNDAY.equals(localDateTime.getDayOfWeek())){
type = 1; type = 1;
} }
List<ClockInLogResp> clockInLogs = clockinLogMapper.getClockInLogExpeort(
yearMonthDay, clockInProject.getId(), clockinTeamLog.getUserId(),type
);
// 拼接打卡时间或标记缺卡
StringBuilder clockInTime = new StringBuilder();
for (ClockInLogResp log : clockInLogs) {
if (StringUtils.isBlank(log.getTime())) {
log.setClockStartTime("缺卡");
}
if (clockInTime.length() > 0) {
clockInTime.append("\n");
List<ClockInLogResp> clockInLogExpeort = clockinLogMapper.getClockInLogExpeort(yearMonthDay, clockInProject.getId(), clockinTeamLog.getUserId(),type);
String clockInTime = "";
for (ClockInLogResp clockInLogResp:clockInLogExpeort) {
if(StringUtils.isBlank(clockInLogResp.getTime())){
clockInLogResp.setClockStartTime("缺卡");
} }
clockInTime.append(log.getClockStartTime());
clockInTime = clockInTime+"\n"+clockInLogResp.getClockStartTime();
// strings.add(clockInLogResp.getClockStartTime());
} }
record.put(day + "号", clockInTime.length() > 0 ? clockInTime.toString() : "缺卡");
Map<String, Object> map1 = new HashMap<>();
map1.put(n+"",clockInTime);
maps1.add(map1);
clockInLogExportResp2.setClockInTime(clockInTime);
clockInLogExportResp2s.add(clockInLogExportResp2);
} }
exportList.add(record);
map.put("list",maps1);
maps.add(map);
clockInLogExportResp.setClockInLogExportResp2s(clockInLogExportResp2s);
exportList.add(clockInLogExportResp);
} }
// 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());
// 过滤选中数据
// String selections = request.getParameter("selections");
// if (oConvertUtils.isNotEmpty(selections)) {
// List<String> selectionList = Arrays.asList(selections.split(","));
// exportList = pageList.stream().filter(item -> selectionList.contains(getId(item))).collect(Collectors.toList());
// } else {
// exportList = pageList;
// }
// Step.3 AutoPoi 导出Excel
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
//此处设置的filename无效 ,前端会重更新设置一下
mv.addObject(NormalExcelConstants.FILE_NAME, title); 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);
mv.addObject(NormalExcelConstants.CLASS, entity.getClass());
//update-begin--Author:liusq Date:20210126 for图片导出报错ImageBasePath未设置--------------------
ExportParams exportParams=new ExportParams(title + "报表", "导出人:" + sysUser.getRealname(), title);
// exportParams.setType(ExcelType.XSSF);
exportParams.setImageBasePath(upLoadPath);
//update-end--Author:liusq Date:20210126 for图片导出报错ImageBasePath未设置----------------------
mv.addObject(NormalExcelConstants.PARAMS,exportParams);
mv.addObject(NormalExcelConstants.DATA_LIST, maps);
return mv; return mv;
} }


+ 1
- 1
pom.xml View File

@ -52,7 +52,7 @@
<java-jwt.version>3.11.0</java-jwt.version> <java-jwt.version>3.11.0</java-jwt.version>
<shiro-redis.version>3.1.0</shiro-redis.version> <shiro-redis.version>3.1.0</shiro-redis.version>
<codegenerate.version>1.3.8</codegenerate.version> <codegenerate.version>1.3.8</codegenerate.version>
<autopoi-web.version>1.4.0</autopoi-web.version>
<autopoi-web.version>1.4.11</autopoi-web.version>
<minio.version>8.0.3</minio.version> <minio.version>8.0.3</minio.version>
<justauth-spring-boot-starter.version>1.3.4</justauth-spring-boot-starter.version> <justauth-spring-boot-starter.version>1.3.4</justauth-spring-boot-starter.version>
<dom4j.version>1.6.1</dom4j.version> <dom4j.version>1.6.1</dom4j.version>


Loading…
Cancel
Save