update code
parent
a0094c618a
commit
3a494c9bb2
|
@ -98,7 +98,7 @@ public class ExcelUtil<T>
|
||||||
/**
|
/**
|
||||||
* 工作表对象
|
* 工作表对象
|
||||||
*/
|
*/
|
||||||
private Sheet sheet;
|
protected Sheet sheet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 样式列表
|
* 样式列表
|
||||||
|
@ -108,7 +108,7 @@ public class ExcelUtil<T>
|
||||||
/**
|
/**
|
||||||
* 导入导出数据列表
|
* 导入导出数据列表
|
||||||
*/
|
*/
|
||||||
private List<T> list;
|
protected List<T> list;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 注解列表
|
* 注解列表
|
||||||
|
|
|
@ -111,6 +111,16 @@ public class AttendanceUbiData extends BaseEntity
|
||||||
return userIds;
|
return userIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<String> days;
|
||||||
|
|
||||||
|
public List<String> getDays() {
|
||||||
|
return days;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDays(List<String> days) {
|
||||||
|
this.days = days;
|
||||||
|
}
|
||||||
|
|
||||||
public void setUserIds(List<Long> userIds) {
|
public void setUserIds(List<Long> userIds) {
|
||||||
this.userIds = userIds;
|
this.userIds = userIds;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.yanzhu.manage.controller;
|
package com.yanzhu.manage.controller;
|
||||||
|
|
||||||
|
import com.yanzhu.common.core.annotation.Excel;
|
||||||
|
import com.yanzhu.common.core.utils.DateUtils;
|
||||||
import com.yanzhu.common.core.utils.poi.ExcelUtil;
|
import com.yanzhu.common.core.utils.poi.ExcelUtil;
|
||||||
import com.yanzhu.common.core.web.controller.BaseController;
|
import com.yanzhu.common.core.web.controller.BaseController;
|
||||||
import com.yanzhu.common.core.web.domain.AjaxResult;
|
import com.yanzhu.common.core.web.domain.AjaxResult;
|
||||||
|
@ -9,12 +11,14 @@ import com.yanzhu.common.log.enums.BusinessType;
|
||||||
import com.yanzhu.common.security.annotation.RequiresPermissions;
|
import com.yanzhu.common.security.annotation.RequiresPermissions;
|
||||||
import com.yanzhu.manage.domain.AttendanceUbiData;
|
import com.yanzhu.manage.domain.AttendanceUbiData;
|
||||||
import com.yanzhu.manage.service.IAttendanceUbiDataService;
|
import com.yanzhu.manage.service.IAttendanceUbiDataService;
|
||||||
|
import org.apache.poi.ss.usermodel.Cell;
|
||||||
|
import org.apache.poi.ss.usermodel.Row;
|
||||||
|
import org.apache.poi.util.IOUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 考勤管理Controller
|
* 考勤管理Controller
|
||||||
|
@ -29,6 +33,7 @@ public class AttendanceUbiDataController extends BaseController
|
||||||
@Autowired
|
@Autowired
|
||||||
private IAttendanceUbiDataService attendanceUbiDataService;
|
private IAttendanceUbiDataService attendanceUbiDataService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询考勤管理列表
|
* 查询考勤管理列表
|
||||||
*/
|
*/
|
||||||
|
@ -55,10 +60,81 @@ public class AttendanceUbiDataController extends BaseController
|
||||||
}
|
}
|
||||||
attendanceUbiData.setUserIds(userIds);
|
attendanceUbiData.setUserIds(userIds);
|
||||||
List<AttendanceUbiData> userDatas=attendanceUbiDataService.queryStatisticsByUserIds(attendanceUbiData);
|
List<AttendanceUbiData> userDatas=attendanceUbiDataService.queryStatisticsByUserIds(attendanceUbiData);
|
||||||
data.setRows(userDatas);
|
//处理汇总数据
|
||||||
|
List<AttendanceUbiData> retUsers= attendanceUbiDataService.procStatistics(attendanceUbiData.getInTime(), datas,userDatas);
|
||||||
|
data.setRows(retUsers);
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequiresPermissions("manage:attendanceUbiData:list")
|
||||||
|
@PostMapping("/statisticsExport")
|
||||||
|
public void statisticsExport(HttpServletResponse response,AttendanceUbiData attendanceUbiData){
|
||||||
|
List<AttendanceUbiData> list = attendanceUbiDataService.queryStatistics(attendanceUbiData);
|
||||||
|
if(list.size()>0){
|
||||||
|
List<Long> userIds=new ArrayList<>();
|
||||||
|
for(AttendanceUbiData ad:list){
|
||||||
|
userIds.add(ad.getUserId());
|
||||||
|
}
|
||||||
|
attendanceUbiData.setUserIds(userIds);
|
||||||
|
|
||||||
|
List<AttendanceUbiData> userDatas=attendanceUbiDataService.queryStatisticsByUserIds(attendanceUbiData);
|
||||||
|
Date inTime=attendanceUbiData.getInTime();
|
||||||
|
Calendar calendar = new GregorianCalendar(inTime.getYear(), inTime.getMonth(), 1);
|
||||||
|
int daysInMonth = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
|
||||||
|
//处理汇总数据
|
||||||
|
List<AttendanceUbiData> retUsers= attendanceUbiDataService.procStatistics(attendanceUbiData.getInTime(), list,userDatas);
|
||||||
|
ExcelUtil<AttendanceUbiData> util = new ExcelUtil<AttendanceUbiData>(AttendanceUbiData.class){
|
||||||
|
@Override
|
||||||
|
public void writeSheet() {
|
||||||
|
createSheet(0,0);
|
||||||
|
Row row = sheet.createRow(0);
|
||||||
|
Cell cell=row.createCell(0);
|
||||||
|
cell.setCellValue("公司");
|
||||||
|
cell=row.createCell(1);
|
||||||
|
cell.setCellValue("项目");
|
||||||
|
cell=row.createCell(2);
|
||||||
|
cell.setCellValue("用户");
|
||||||
|
cell=row.createCell(3);
|
||||||
|
cell.setCellValue("班组");
|
||||||
|
cell=row.createCell(4);
|
||||||
|
cell.setCellValue("工种类型");
|
||||||
|
cell=row.createCell(5);
|
||||||
|
cell.setCellValue("工种岗位");
|
||||||
|
for(int i=1;i<=daysInMonth;i++){
|
||||||
|
cell=row.createCell(i+5);
|
||||||
|
cell.setCellValue(i);
|
||||||
|
}
|
||||||
|
for(int i=0;i<this.list.size();i++){
|
||||||
|
AttendanceUbiData item=list.get(i);
|
||||||
|
row=sheet.createRow(i+1);
|
||||||
|
cell=row.createCell(0);
|
||||||
|
cell.setCellValue(item.getComName());
|
||||||
|
cell=row.createCell(1);
|
||||||
|
cell.setCellValue(item.getProjectName());
|
||||||
|
cell=row.createCell(2);
|
||||||
|
cell.setCellValue(item.getUserName());
|
||||||
|
cell=row.createCell(3);
|
||||||
|
cell.setCellValue(item.getSubDeptGroupName());
|
||||||
|
cell=row.createCell(4);
|
||||||
|
cell.setCellValue(item.getCraftType());
|
||||||
|
cell=row.createCell(5);
|
||||||
|
cell.setCellValue(item.getCraftPost());
|
||||||
|
for(int j=1;j<=daysInMonth;j++){
|
||||||
|
cell=row.createCell(5+j);
|
||||||
|
cell.setCellValue(item.getDays().get(j-1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||||
|
response.setCharacterEncoding("utf-8");
|
||||||
|
util.init(list, "考勤管理数据", "", Excel.Type.EXPORT);
|
||||||
|
util.exportExcel(response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出考勤管理列表
|
* 导出考勤管理列表
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.yanzhu.manage.service;
|
package com.yanzhu.manage.service;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.yanzhu.manage.domain.AttendanceUbiData;
|
import com.yanzhu.manage.domain.AttendanceUbiData;
|
||||||
|
|
||||||
|
@ -73,4 +74,6 @@ public interface IAttendanceUbiDataService
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<AttendanceUbiData> queryStatisticsByUserIds(AttendanceUbiData attendanceUbiData);
|
List<AttendanceUbiData> queryStatisticsByUserIds(AttendanceUbiData attendanceUbiData);
|
||||||
|
|
||||||
|
List<AttendanceUbiData> procStatistics(Date inTime, List<AttendanceUbiData> datas, List<AttendanceUbiData> userDatas);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
package com.yanzhu.manage.service.impl;
|
package com.yanzhu.manage.service.impl;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
|
|
||||||
import com.yanzhu.common.core.context.SecurityContextHolder;
|
import com.yanzhu.common.core.context.SecurityContextHolder;
|
||||||
import com.yanzhu.common.core.utils.DateUtils;
|
import com.yanzhu.common.core.utils.DateUtils;
|
||||||
|
import com.yanzhu.common.core.utils.StringUtils;
|
||||||
import com.yanzhu.manage.domain.AttendanceUbiData;
|
import com.yanzhu.manage.domain.AttendanceUbiData;
|
||||||
import com.yanzhu.manage.mapper.AttendanceUbiDataMapper;
|
import com.yanzhu.manage.mapper.AttendanceUbiDataMapper;
|
||||||
import com.yanzhu.manage.service.IAttendanceUbiDataService;
|
import com.yanzhu.manage.service.IAttendanceUbiDataService;
|
||||||
|
@ -22,6 +23,7 @@ public class AttendanceUbiDataServiceImpl implements IAttendanceUbiDataService
|
||||||
@Autowired
|
@Autowired
|
||||||
private AttendanceUbiDataMapper attendanceUbiDataMapper;
|
private AttendanceUbiDataMapper attendanceUbiDataMapper;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询考勤管理
|
* 查询考勤管理
|
||||||
*
|
*
|
||||||
|
@ -112,4 +114,58 @@ public class AttendanceUbiDataServiceImpl implements IAttendanceUbiDataService
|
||||||
public List<AttendanceUbiData> queryStatisticsByUserIds(AttendanceUbiData attendanceUbiData) {
|
public List<AttendanceUbiData> queryStatisticsByUserIds(AttendanceUbiData attendanceUbiData) {
|
||||||
return attendanceUbiDataMapper.queryStatisticsByUserIds(attendanceUbiData);
|
return attendanceUbiDataMapper.queryStatisticsByUserIds(attendanceUbiData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AttendanceUbiData> procStatistics(Date inTime, List<AttendanceUbiData> datas, List<AttendanceUbiData> userDatas) {
|
||||||
|
List<AttendanceUbiData> users=new ArrayList<>();
|
||||||
|
if(datas.size()==0){
|
||||||
|
return users;
|
||||||
|
}
|
||||||
|
Calendar calendar = new GregorianCalendar(inTime.getYear(), inTime.getMonth(), 1);
|
||||||
|
int daysInMonth = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
|
||||||
|
for(AttendanceUbiData ad :datas){
|
||||||
|
List<String> days=makeEmptyDays(daysInMonth);
|
||||||
|
List<AttendanceUbiData> findDatas=findUserDatas(ad,userDatas);
|
||||||
|
int j=0;
|
||||||
|
for(AttendanceUbiData fd:findDatas){
|
||||||
|
if(j==0){
|
||||||
|
fd.setDays(days);
|
||||||
|
users.add(fd);
|
||||||
|
}
|
||||||
|
j++;
|
||||||
|
Date dt=fd.getInTime();
|
||||||
|
String inStr=fd.getInTime()!=null?DateUtils.parseDateToStr("HH:MM:SS",fd.getInTime()):"";
|
||||||
|
String outStr=fd.getOutTime()!=null?DateUtils.parseDateToStr("HH:MM:SS",fd.getOutTime()):"";
|
||||||
|
if(dt==null){
|
||||||
|
dt=fd.getOutTime();
|
||||||
|
}
|
||||||
|
if(dt==null){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
int day=dt.getDate();
|
||||||
|
if(StringUtils.isNotEmpty(inStr) || StringUtils.isNotEmpty(outStr)){
|
||||||
|
days.set(day-1,inStr+"-"+outStr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return users;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<AttendanceUbiData> findUserDatas(AttendanceUbiData ad, List<AttendanceUbiData> userDatas) {
|
||||||
|
List<AttendanceUbiData> list=new ArrayList<>();
|
||||||
|
for(AttendanceUbiData it :userDatas){
|
||||||
|
if(it.getUserId().equals(ad.getUserId())){
|
||||||
|
list.add(it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<String> makeEmptyDays(int daysInMonth) {
|
||||||
|
List<String> days=new ArrayList<>();
|
||||||
|
for(int i=0;i<daysInMonth;i++){
|
||||||
|
days.add("");
|
||||||
|
}
|
||||||
|
return days;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,3 +50,11 @@ export function statisticsAttendanceUbiData(query) {
|
||||||
params: query
|
params: query
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function statisticsExportAttendanceUbiData(query) {
|
||||||
|
return request({
|
||||||
|
url: '/manage/attendanceUbiData/statisticsExport',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
|
@ -23,13 +23,7 @@ const props = defineProps({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
function getInfo(row,it){
|
function getInfo(row,it){
|
||||||
let obj=row[it]
|
return row.days[it-1];
|
||||||
if(!obj){
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
let inTime=obj.in?proxy.$dt(obj.in).format("HH:mm:ss"):""
|
|
||||||
let outTime=obj.out?proxy.$dt(obj.out).format("HH:mm:ss"):""
|
|
||||||
return inTime+" - "+ outTime;
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||||
|
<el-button type="primary" icon="Search" @click="handleExport">导出</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
|
@ -64,7 +65,7 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { findMyProjectList } from "@/api/publics";
|
import { findMyProjectList } from "@/api/publics";
|
||||||
import { listProProjectInfoSubdepts } from "@/api/manage/proProjectInfoSubdepts";
|
import { listProProjectInfoSubdepts } from "@/api/manage/proProjectInfoSubdepts";
|
||||||
import {statisticsAttendanceUbiData} from '@/api/manage/attendanceUbiData.js'
|
import {statisticsAttendanceUbiData,statisticsExportAttendanceUbiData} from '@/api/manage/attendanceUbiData.js'
|
||||||
import useUserStore from '@/store/modules/user'
|
import useUserStore from '@/store/modules/user'
|
||||||
import attItem from './item.vue'
|
import attItem from './item.vue'
|
||||||
const { proxy } = getCurrentInstance();
|
const { proxy } = getCurrentInstance();
|
||||||
|
@ -114,6 +115,12 @@ function getProjectList() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleExport(){
|
||||||
|
proxy.download('manage/attendanceUbiData/statisticsExport', {
|
||||||
|
...queryParams.value
|
||||||
|
}, `attendanceUbiData_${new Date().getTime()}.xlsx`)
|
||||||
|
}
|
||||||
|
|
||||||
function getList() {
|
function getList() {
|
||||||
let queryData={
|
let queryData={
|
||||||
pageNum:queryParams.value.pageNum,
|
pageNum:queryParams.value.pageNum,
|
||||||
|
|
|
@ -32,6 +32,7 @@ export default defineConfig(({ mode, command }) => {
|
||||||
// https://cn.vitejs.dev/config/#server-proxy
|
// https://cn.vitejs.dev/config/#server-proxy
|
||||||
'/dev-api': {
|
'/dev-api': {
|
||||||
target: 'http://localhost:8080',
|
target: 'http://localhost:8080',
|
||||||
|
//target: 'http://62.234.3.186/prod-api/',
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
rewrite: (p) => p.replace(/^\/dev-api/, '')
|
rewrite: (p) => p.replace(/^\/dev-api/, '')
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue