package com.ruoyi.staff.service.impl;
|
|
import cn.hutool.core.date.DateTime;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.ruoyi.common.utils.SecurityUtils;
|
import com.ruoyi.project.system.domain.SysDictData;
|
import com.ruoyi.staff.dto.PerformanceShiftAddDto;
|
import com.ruoyi.staff.dto.PerformanceShiftMapDto;
|
import com.ruoyi.staff.mapper.PersonalAttendanceLocationConfigMapper;
|
import com.ruoyi.staff.pojo.PersonalAttendanceLocationConfig;
|
import com.ruoyi.staff.pojo.PersonalShift;
|
import com.ruoyi.staff.mapper.PersonalShiftMapper;
|
import com.ruoyi.staff.service.PersonalAttendanceLocationConfigService;
|
import com.ruoyi.staff.service.PersonalShiftService;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.ruoyi.staff.utils.JackSonUtil;
|
import org.apache.commons.lang3.StringUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
import cn.hutool.core.date.DateUtil;
|
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.util.ObjectUtils;
|
|
import java.math.BigDecimal;
|
import java.text.SimpleDateFormat;
|
import java.time.LocalDate;
|
import java.time.LocalDateTime;
|
import java.time.YearMonth;
|
import java.time.ZoneId;
|
import java.time.format.DateTimeFormatter;
|
import java.time.temporal.TemporalAdjusters;
|
import java.util.*;
|
|
|
/**
|
* <p>
|
* 服务实现类
|
* </p>
|
*
|
* @author 芯导软件(江苏)有限公司
|
* @since 2026-03-05 03:52:19
|
*/
|
@Service
|
@Transactional(rollbackFor = Exception.class)
|
public class PersonalShiftServiceImpl extends ServiceImpl<PersonalShiftMapper, PersonalShift> implements PersonalShiftService {
|
|
@Autowired
|
private PersonalAttendanceLocationConfigMapper personalAttendanceLocationConfigMapper;
|
|
@Override
|
public int performanceShiftAdd(PerformanceShiftAddDto performanceShiftAddDto) {
|
List<PersonalShift> list = new ArrayList<>();
|
LocalDateTime startWeek = performanceShiftAddDto.getStartWeek();//开始日期
|
LocalDateTime endWeek = performanceShiftAddDto.getEndWeek();//结束日期
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
String formattedDateTime = performanceShiftAddDto.getStartWeek().format(formatter);
|
String[] splitUserId = performanceShiftAddDto.getStaffOnJobId().split(",");
|
for (String userId : splitUserId) {
|
//判断是否跨月
|
boolean isMonth = startWeek.getMonthValue() != endWeek.getMonthValue();
|
if (isMonth){
|
//如果跨月,则两个月都判断一下看数据库是哪个月份的数据没有
|
boolean exists1 = baseMapper.exists(Wrappers.<PersonalShift>lambdaQuery()
|
.eq(PersonalShift::getWorkTime, startWeek)
|
.eq(PersonalShift::getStaffOnJobId, userId));
|
boolean exists2 = baseMapper.exists(Wrappers.<PersonalShift>lambdaQuery()
|
.eq(PersonalShift::getWorkTime, endWeek)
|
.eq(PersonalShift::getStaffOnJobId, userId));
|
if (!exists1 && !exists2){
|
//两个月都不存在数据
|
list = saveMonth(performanceShiftAddDto.getStartWeek(), userId, list);
|
list = saveMonth(performanceShiftAddDto.getEndWeek(), userId, list);
|
}else if (!exists1 && exists2){
|
//开始的月份不存在数据
|
list = saveMonth(performanceShiftAddDto.getStartWeek(), userId, list);
|
}else if (exists1 && !exists2){
|
//结束的月份不存在数据
|
list = saveMonth(performanceShiftAddDto.getEndWeek(), userId, list);
|
}
|
}else {
|
//不跨月
|
boolean exists = baseMapper.exists(Wrappers.<PersonalShift>lambdaQuery()
|
.in(PersonalShift::getWorkTime, formattedDateTime)
|
.eq(PersonalShift::getStaffOnJobId, userId));
|
// 如果不存在添加数据
|
if (!exists) {
|
list = saveMonth(performanceShiftAddDto.getEndWeek(), userId, list);
|
}
|
}
|
}
|
if (!list.isEmpty()) {
|
saveBatch(list);
|
list.clear();
|
}
|
// 再次更新
|
List<LocalDateTime> datesBetween = getLocalDateTimesBetween(performanceShiftAddDto.getStartWeek(), performanceShiftAddDto.getEndWeek());
|
for (LocalDateTime date : datesBetween) {
|
for (String s : splitUserId) {
|
PersonalShift personalShift = new PersonalShift();
|
personalShift.setPersonalAttendanceLocationConfigId(performanceShiftAddDto.getPersonalAttendanceLocationConfigId());
|
personalShift.setStaffOnJobId(Long.valueOf(s));
|
personalShift.setWorkTime(date);
|
String formatterDateTime = date.format(formatter);
|
baseMapper.update(new PersonalShift(), Wrappers.<PersonalShift>lambdaUpdate()
|
.set(PersonalShift::getPersonalAttendanceLocationConfigId, performanceShiftAddDto.getPersonalAttendanceLocationConfigId())
|
.eq(PersonalShift::getStaffOnJobId, s)
|
.eq(PersonalShift::getWorkTime, formatterDateTime));
|
}
|
}
|
return 0;
|
}
|
|
@Override
|
public Map<String, Object> performanceShiftPage(Page<Object> page, String time, String userName, Integer sysDeptId) {
|
IPage<PerformanceShiftMapDto> mapIPage = baseMapper.performanceShiftPage(page, time, userName, sysDeptId);
|
//查询所有班次(打卡规则)
|
List<PersonalAttendanceLocationConfig> personalAttendanceLocationConfigs = personalAttendanceLocationConfigMapper.selectList(null);
|
mapIPage.getRecords().forEach(i -> {
|
String[] shiftTimes = i.getShiftTime().split(";");
|
double totalAttendance = 0;//总出勤天数
|
List<Map<String, Object>> map = new ArrayList<>();
|
// 分割日期
|
for (String shiftTime : shiftTimes) {
|
i.setShiftTime(null);
|
Map<String, Object> hashMap = new HashMap<>();
|
String[] shiftTimeAndShift = shiftTime.split(":");
|
//排班详细数据
|
hashMap.put("id", shiftTimeAndShift[2]);
|
hashMap.put("shift", shiftTimeAndShift[1]);
|
hashMap.put("time", shiftTimeAndShift[0]);
|
map.add(hashMap);
|
i.setList(map);
|
//汇总的各班次统计数据
|
for (PersonalAttendanceLocationConfig personalAttendanceLocationConfig : personalAttendanceLocationConfigs) {
|
if (!i.getMonthlyAttendance().containsKey(personalAttendanceLocationConfig.getShift())){
|
i.getMonthlyAttendance().put(personalAttendanceLocationConfig.getShift(), 0);
|
}
|
if (personalAttendanceLocationConfig.getShift().equals(shiftTimeAndShift[1])) {
|
BigDecimal bigDecimal = new BigDecimal(i.getMonthlyAttendance().get(personalAttendanceLocationConfig.getShift()).toString());
|
i.getMonthlyAttendance().put(personalAttendanceLocationConfig.getShift(), bigDecimal.add(new BigDecimal("1")));
|
}
|
}
|
//统计总出勤天数(早/中/晚/夜)都算出勤,其余都是休息
|
if (shiftTimeAndShift[1].contains("早") ||
|
shiftTimeAndShift[1].contains("中") ||
|
shiftTimeAndShift[1].contains("晚") ||
|
shiftTimeAndShift[1].contains("夜")) {
|
i.getMonthlyAttendance().put("totalAttendance", totalAttendance += 1);
|
}
|
}
|
});
|
// 获取header时间
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
DateTimeFormatter formatters = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
// 将字符串时间转换为 LocalDateTime 类型时间
|
LocalDateTime localDateTime = LocalDateTime.parse(time, formatters);
|
LocalDate firstDayOfMonth = localDateTime.toLocalDate().withDayOfMonth(1);
|
LocalDate lastDayOfMonth = localDateTime.toLocalDate().with(TemporalAdjusters.lastDayOfMonth());
|
List<LocalDateTime> localDateTimesBetween = getLocalDateTimesBetween(firstDayOfMonth.atStartOfDay(), lastDayOfMonth.atStartOfDay());
|
List<Object> list1 = new ArrayList<>();
|
for (LocalDateTime dateTime : localDateTimesBetween) {
|
Map<Object, Object> hashMap = new HashMap<>();
|
DateTime parse = DateUtil.parse(dateTime.format(formatter));
|
hashMap.put("weekly", DateUtil.weekOfYear(DateUtil.offsetDay(parse, 1)));
|
hashMap.put("headerTime", getWeek(dateTime.format(formatters)));
|
list1.add(hashMap);
|
}
|
Map<String, Object> resultMap = new HashMap<>();
|
resultMap.put("page", mapIPage);
|
resultMap.put("headerList", list1);
|
return resultMap;
|
}
|
|
@Override
|
public void performanceShiftUpdate(PersonalShift personalShift) {
|
baseMapper.update(new PersonalShift(), Wrappers.<PersonalShift>lambdaUpdate()
|
.eq(PersonalShift::getId, personalShift.getId())
|
.set(PersonalShift::getPersonalAttendanceLocationConfigId, personalShift.getPersonalAttendanceLocationConfigId()));
|
}
|
|
@Override
|
public IPage<Map<String, Object>> performanceShiftPageYear(Page<Object> page, String time, String userName, Integer sysDeptId) {
|
IPage<Map<String, Object>> mapYearIPage = baseMapper.performanceShiftYear(page, time, userName, sysDeptId);
|
//查询所有班次(打卡规则)
|
List<PersonalAttendanceLocationConfig> personalAttendanceLocationConfigs = personalAttendanceLocationConfigMapper.selectList(null);
|
mapYearIPage.setRecords(annualAttendanceProcessing(mapYearIPage.getRecords(), personalAttendanceLocationConfigs));
|
return mapYearIPage;
|
}
|
|
@Override
|
public Map<Object, Object> exportToYearExcel(String time, String userName, Integer sysDeptId) throws Exception {
|
Map<Object, Object> map = new HashMap<>();
|
//查询所有班次(打卡规则)
|
List<PersonalAttendanceLocationConfig> personalAttendanceLocationConfigs = personalAttendanceLocationConfigMapper.selectList(null);
|
DateTimeFormatter formatters = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
// 将字符串时间转换为 LocalDateTime 类型时间
|
LocalDateTime localDateTime = LocalDateTime.parse(time, formatters);
|
map.put("header", getYearHeader(localDateTime.getYear() + " 年", personalAttendanceLocationConfigs));
|
List<Map<String, Object>> mapYearList = baseMapper.performanceShiftYearList(time, userName, sysDeptId);
|
annualAttendanceProcessing(mapYearList, personalAttendanceLocationConfigs);
|
List<List<Object>> lists = dataRequiredForProcessingIntoExcel(mapYearList, personalAttendanceLocationConfigs);
|
map.put("data", lists);
|
return map;
|
}
|
|
@Override
|
public Map<Object, Object> exportToMonthExcel(String time, String userName, Integer sysDeptId) {
|
//查询所有班次(打卡规则)
|
List<PersonalAttendanceLocationConfig> personalAttendanceLocationConfigs = personalAttendanceLocationConfigMapper.selectList(null);
|
List<PerformanceShiftMapDto> mapIPage = baseMapper.performanceShiftList(time, userName, sysDeptId);
|
mapIPage.forEach(i -> {
|
String[] shiftTimes = i.getShiftTime().split(";");
|
double totalAttendance = 0;
|
List<Map<String, Object>> map = new ArrayList<>();
|
// 分割日期
|
for (String shiftTime : shiftTimes) {
|
Map<String, Object> hashMap = new HashMap<>();
|
String[] shiftTimeAndShift = shiftTime.split(":");
|
for (PersonalAttendanceLocationConfig personalAttendanceLocationConfig : personalAttendanceLocationConfigs) {
|
if (!i.getMonthlyAttendance().containsKey(personalAttendanceLocationConfig.getShift())) {
|
i.getMonthlyAttendance().put(personalAttendanceLocationConfig.getShift(), 0);
|
}
|
if (personalAttendanceLocationConfig.getShift().equals(shiftTimeAndShift[1])) {
|
BigDecimal bigDecimal = new BigDecimal(i.getMonthlyAttendance().get(personalAttendanceLocationConfig.getShift()).toString());
|
i.getMonthlyAttendance().put(personalAttendanceLocationConfig.getShift(), bigDecimal.add(new BigDecimal("1")));
|
}
|
}
|
//统计总出勤天数(早/中/晚/夜)都算出勤,其余都是休息
|
if (shiftTimeAndShift[1].contains("早") ||
|
shiftTimeAndShift[1].contains("中") ||
|
shiftTimeAndShift[1].contains("晚") ||
|
shiftTimeAndShift[1].contains("夜")) {
|
i.getMonthlyAttendance().put("totalAttendance", totalAttendance += 1);
|
}
|
hashMap.put("id", shiftTimeAndShift[2]);
|
hashMap.put("shift", shiftTimeAndShift[1]);
|
hashMap.put("time", shiftTimeAndShift[0]);
|
map.add(hashMap);
|
}
|
i.setList(map);
|
i.setShiftTime(null);
|
});
|
Map<Object, Object> map = new HashMap<>();
|
DateTimeFormatter formatters = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
// 将字符串时间转换为 LocalDateTime 类型时间
|
LocalDateTime localDateTime = LocalDateTime.parse(time, formatters);
|
map.put("header", getMonthHeader(localDateTime));
|
List<List<Object>> lists = dataRequiredForProcessingIntoExcelMonth(mapIPage, personalAttendanceLocationConfigs);
|
map.put("data", lists);
|
return map;
|
}
|
|
// 年分页与导出共同使用
|
public List<Map<String, Object>> annualAttendanceProcessing(List<Map<String, Object>> mapYearList,List<PersonalAttendanceLocationConfig> personalAttendanceLocationConfigs) {
|
for (Map<String, Object> map : mapYearList) {
|
Map<String, Object> resultMap = new LinkedHashMap<>();
|
Map<String, Object> hashMapYear = new LinkedHashMap<>();
|
double totalYearAttendance = 0;
|
// 一年12个月
|
for (int i = 1; i < 13; i++) {
|
Map<String, Object> hashMapMonth = new LinkedHashMap<>();
|
double totalMonthAttendance = 0;
|
for (PersonalAttendanceLocationConfig personalAttendanceLocationConfig : personalAttendanceLocationConfigs) {
|
// 初始化赋值
|
if (!hashMapYear.containsKey(personalAttendanceLocationConfig.getShift())){
|
hashMapYear.put(personalAttendanceLocationConfig.getShift(), 0);
|
}
|
// 月
|
if (!ObjectUtils.isEmpty(map.get("month_str"))) {
|
String charArray = map.get("month_str").toString();
|
int count = countOccurrences(charArray, i + ":" + personalAttendanceLocationConfig.getShift());
|
hashMapMonth.put(personalAttendanceLocationConfig.getShift(), count);
|
hashMapYear.put(personalAttendanceLocationConfig.getShift(), new BigDecimal(hashMapYear.get(personalAttendanceLocationConfig.getShift()).toString()).add(new BigDecimal(count)));
|
// 早,中,夜,差
|
if (personalAttendanceLocationConfig.getShift().contains("早") ||
|
personalAttendanceLocationConfig.getShift().contains("中") ||
|
personalAttendanceLocationConfig.getShift().contains("晚") ||
|
personalAttendanceLocationConfig.getShift().contains("夜")) {
|
totalMonthAttendance += count;
|
totalYearAttendance += count;
|
}
|
}
|
// 空数据
|
else {
|
map.put("work_time", i);
|
hashMapMonth.put(personalAttendanceLocationConfig.getShift(), 0);
|
}
|
}
|
hashMapMonth.put("totalMonthAttendance", totalMonthAttendance);
|
hashMapYear.put("totalYearAttendance", totalYearAttendance);
|
resultMap.put(i + "", hashMapMonth);
|
}
|
map.remove("month_str");
|
map.remove("year_str");
|
map.put("year", hashMapYear);
|
map.put("month", resultMap);
|
}
|
return mapYearList;
|
}
|
|
public static int countOccurrences(String str, String target) {
|
int count = 0;
|
int index = 0;
|
while ((index = str.indexOf(target, index)) != -1) {
|
count++;
|
index += target.length();
|
}
|
return count;
|
}
|
|
public List<List<Object>> dataRequiredForProcessingIntoExcel(List<Map<String, Object>> list, List<PersonalAttendanceLocationConfig> personalAttendanceLocationConfigs) throws Exception {
|
List<List<Object>> data = new ArrayList<>();
|
for (int i = 0; i < list.size(); i++) {
|
List<Object> excelRowList = new ArrayList<>();
|
excelRowList.add(i + 1);
|
excelRowList.add(list.get(i).get("account"));
|
excelRowList.add(list.get(i).get("name"));
|
Map<String, Object> year = JackSonUtil.unmarshal(JackSonUtil.marshal(list.get(i).get("year")), Map.class);
|
excelRowList.add(year.get("totalYearAttendance"));
|
personalAttendanceLocationConfigs.forEach(j -> {
|
excelRowList.add(year.get(j.getShift()));
|
});
|
Map<String, Map<String, Object>> month = JackSonUtil.unmarshal(JackSonUtil.marshal(list.get(i).get("month")), Map.class);
|
for (int j = 1; j < 13; j++) {
|
Object totalMonthAttendance = month.get(j + "").get("totalMonthAttendance");
|
excelRowList.add(totalMonthAttendance);
|
for (PersonalAttendanceLocationConfig personalAttendanceLocationConfig : personalAttendanceLocationConfigs) {
|
excelRowList.add(month.get(j + "").get(personalAttendanceLocationConfig.getShift()));
|
}
|
}
|
data.add(excelRowList);
|
}
|
return data;
|
}
|
|
|
private List<PersonalShift> saveMonth (LocalDateTime week,String userId,List<PersonalShift> list){
|
LocalDate firstDayOfMonth = week.toLocalDate().withDayOfMonth(1);
|
LocalDate lastDayOfMonth = week.toLocalDate().with(TemporalAdjusters.lastDayOfMonth());
|
List<LocalDateTime> localDateTimesBetween = getLocalDateTimesBetween(firstDayOfMonth.atStartOfDay(), lastDayOfMonth.atStartOfDay());
|
localDateTimesBetween.forEach(i -> {
|
PersonalShift personalShift = new PersonalShift();
|
personalShift.setStaffOnJobId(Long.valueOf(userId));
|
personalShift.setWorkTime(i);
|
list.add(personalShift);
|
if (list.size() >= 1000) {
|
saveBatch(list);
|
list.clear();
|
}
|
});
|
return list;
|
}
|
|
// 获取两个localDateTime的每一天
|
public static List<LocalDateTime> getLocalDateTimesBetween(LocalDateTime start, LocalDateTime end) {
|
List<LocalDateTime> localDateTimes = new ArrayList<>();
|
LocalDate currentDate = start.toLocalDate();
|
LocalDateTime currentLocalDateTime = start;
|
while (!currentDate.isAfter(end.toLocalDate())) {
|
localDateTimes.add(currentLocalDateTime);
|
currentLocalDateTime = currentLocalDateTime.plusDays(1);
|
currentDate = currentDate.plusDays(1);
|
}
|
return localDateTimes;
|
}
|
|
public static String getWeek(String dayStr) {
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
try {
|
Date date = sdf.parse(dayStr);
|
Calendar calendar = Calendar.getInstance();
|
calendar.setTime(date);
|
int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
|
int day = calendar.get(Calendar.DAY_OF_MONTH);
|
return day + " " + getWeekDay(dayOfWeek);
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return null;
|
}
|
|
public static String getWeekDay(int dayOfWeek) {
|
switch (dayOfWeek) {
|
case Calendar.MONDAY:
|
return "周一";
|
case Calendar.TUESDAY:
|
return "周二";
|
case Calendar.WEDNESDAY:
|
return "周三";
|
case Calendar.THURSDAY:
|
return "周四";
|
case Calendar.FRIDAY:
|
return "周五";
|
case Calendar.SATURDAY:
|
return "周六";
|
case Calendar.SUNDAY:
|
return "周日";
|
default:
|
return "未知";
|
}
|
}
|
|
/**
|
* 返回表头
|
* <p>
|
* 外层List代表行内层 List代表列 相同的列数据会被主动合并
|
* 构造双列表头
|
*
|
* @return List<List < String>>
|
*/
|
private static List<List<String>> getYearHeader(String year, List<PersonalAttendanceLocationConfig> personalAttendanceLocationConfigs) {
|
List<List<String>> line = new ArrayList<>();
|
line.add(Arrays.asList("考勤汇总", "序号", "序号"));
|
line.add(Arrays.asList("考勤汇总", "工号", "工号"));
|
line.add(Arrays.asList("考勤汇总", "姓名", "姓名"));
|
line.add(Arrays.asList("出勤详情", year, "出勤"));
|
// 年 header
|
for (PersonalAttendanceLocationConfig personalAttendanceLocationConfig : personalAttendanceLocationConfigs) {
|
line.add(Arrays.asList("考勤汇总", year, personalAttendanceLocationConfig.getShift()));
|
}
|
// 月header
|
for (int i = 1; i < 13; i++) {
|
line.add(Arrays.asList("出勤详情", i + " 月", "出勤"));
|
for (PersonalAttendanceLocationConfig personalAttendanceLocationConfig : personalAttendanceLocationConfigs) {
|
line.add(Arrays.asList("出勤详情", i + " 月", personalAttendanceLocationConfig.getShift()));
|
}
|
}
|
return line;
|
}
|
|
private static List<List<String>> getMonthHeader(LocalDateTime localDateTimeYear) {
|
String year = localDateTimeYear.getYear() + " 年人员班次";
|
List<List<String>> line = new ArrayList<>();
|
line.add(Arrays.asList(year, "序号", "序号", "序号"));
|
line.add(Arrays.asList(year, "姓名", "姓名", "姓名"));
|
line.add(Arrays.asList(year, "部门", "部门", "部门"));
|
line.add(Arrays.asList(year, localDateTimeYear.getYear() + "", localDateTimeYear.getYear() + "", "出勤"));
|
line.add(Arrays.asList(year, localDateTimeYear.getYear() + "", localDateTimeYear.getYear() + "","休"));
|
line.add(Arrays.asList(year, "年", "年", "请假"));
|
line.add(Arrays.asList(year, localDateTimeYear.getMonthValue() + "", localDateTimeYear.getMonthValue() + "", "早"));
|
line.add(Arrays.asList(year, "月", "月", "中"));
|
line.add(Arrays.asList(year, "", "", "夜"));
|
line.add(Arrays.asList(year, "周次", "星期", "出差"));
|
LocalDate firstDayOfMonth = localDateTimeYear.toLocalDate().withDayOfMonth(1);
|
LocalDate lastDayOfMonth = localDateTimeYear.toLocalDate().with(TemporalAdjusters.lastDayOfMonth());
|
List<LocalDateTime> timeList = getLocalDateTimesBetween(firstDayOfMonth.atStartOfDay(), lastDayOfMonth.atStartOfDay());
|
timeList.forEach(i -> {
|
int dayOfYear = i.getDayOfMonth();
|
Date from = Date.from(i.atZone(ZoneId.systemDefault()).toInstant());
|
String weekDay = getWeekDay(i.getDayOfWeek().getValue());
|
line.add(Arrays.asList(year, DateUtil.weekOfYear(DateUtil.offsetDay(from, 1)) + "", weekDay, dayOfYear + ""));
|
});
|
return line;
|
}
|
|
public List<List<Object>> dataRequiredForProcessingIntoExcelMonth(List<PerformanceShiftMapDto> list, List<PersonalAttendanceLocationConfig> personalAttendanceLocationConfigs) {
|
List<List<Object>> data = new ArrayList<>();
|
for (int i = 0; i < list.size(); i++) {
|
List<Object> excelRowList = new ArrayList<>();
|
excelRowList.add(i + 1);
|
excelRowList.add(list.get(i).getName());
|
excelRowList.add(list.get(i).getDepartment());
|
excelRowList.add(list.get(i).getMonthlyAttendance().get("totalAttendance"));
|
excelRowList.add(list.get(i).getMonthlyAttendance().get("%休%")); // 休
|
excelRowList.add(list.get(i).getMonthlyAttendance().get("%假%")); // 假
|
excelRowList.add(list.get(i).getMonthlyAttendance().get("%早%")); // 早
|
excelRowList.add(list.get(i).getMonthlyAttendance().get("%中%")); // 中
|
excelRowList.add(list.get(i).getMonthlyAttendance().get("%夜%")); // 夜
|
excelRowList.add(list.get(i).getMonthlyAttendance().get("%差%")); // 差
|
for (Map<String, Object> o : list.get(i).getList()) {
|
String enumLabel = "";
|
for (PersonalAttendanceLocationConfig personalAttendanceLocationConfig : personalAttendanceLocationConfigs) {
|
if (personalAttendanceLocationConfig.getShift().equals(o.get("shift"))) {
|
enumLabel = personalAttendanceLocationConfig.getShift();
|
}
|
}
|
excelRowList.add(ObjectUtils.isEmpty(enumLabel) ? "-" : enumLabel);
|
}
|
data.add(excelRowList);
|
}
|
return data;
|
}
|
|
}
|