diff --git a/evo-admin/src/main/java/com/evo/attendance/processor/impl/KQDeviceExchangeProcessor.java b/evo-admin/src/main/java/com/evo/attendance/processor/impl/KQDeviceExchangeProcessor.java index 4b909fe..89330fa 100644 --- a/evo-admin/src/main/java/com/evo/attendance/processor/impl/KQDeviceExchangeProcessor.java +++ b/evo-admin/src/main/java/com/evo/attendance/processor/impl/KQDeviceExchangeProcessor.java @@ -201,6 +201,12 @@ public class KQDeviceExchangeProcessor implements PunchTheClockStrategyExchangeP Long hours = (date.getTime() - attendance.getWorkStartTime().getTime())/1000/60/60; EqButton eqButton = eqButtonMapper.selectOne(new LambdaQueryWrapper().eq(EqButton::getName, rules)); + + Integer maxWorkHour = ParamUtils.getTsWorkHour(attendance.getName()); + if(maxWorkHour == null){ + maxWorkHour = eqButton.getWorkHour(); + } + //判断打卡时间, 添加夜班次数 打卡时间在晚上7点以后 if(eqButton.getWorkHour() ==12 && hours >= 12 && attendance.getWorkStartTime().getHours() > 12){ attendance.setNightNumber(1); @@ -209,8 +215,8 @@ public class KQDeviceExchangeProcessor implements PunchTheClockStrategyExchangeP } //获取工作时长 BigDecimal res = new BigDecimal(hours); - if(hours.compareTo(Long.valueOf(eqButton.getWorkHour())) >= 0){ - res = new BigDecimal(eqButton.getWorkHour()); + if(hours.compareTo(Long.valueOf(maxWorkHour)) >= 0){ + res = new BigDecimal(maxWorkHour); } // else if(hours.compareTo(Long.valueOf(eqButton.getWorkHour()/2)) > 0){ // res = new BigDecimal(eqButton.getWorkHour()/2); diff --git a/evo-admin/src/main/java/com/evo/common/utils/ParamUtils.java b/evo-admin/src/main/java/com/evo/common/utils/ParamUtils.java index 254583f..5a91dd8 100644 --- a/evo-admin/src/main/java/com/evo/common/utils/ParamUtils.java +++ b/evo-admin/src/main/java/com/evo/common/utils/ParamUtils.java @@ -144,6 +144,21 @@ public class ParamUtils { return typeJson != null ? typeJson.getString(buttonName) : null; } + /*** + * 获取特殊加班的考勤规则 + * sn 设备号 + * rules 规则 + * @return + */ + public static Integer getTsWorkHour(String name){ + if(StringUtils.isEmpty(name)) return null; + RzSysParam param= paramService.getRzSysParam("特殊上班人员", "ts_work_hour","{\"11\":\"丁世强,陈亮,贾中恒,孙小建,刘佳,宋娇娇\"}","特殊上班人员, 上班时长做key, 员工做value, 一个员工存在多个value, 以第一个为准"); + String val = param.getParamValue(); + if(StringUtils.isEmpty(val)) return null; + Map hourMaps = JSONObject.parseObject(val, Map.class); + Map.Entry mapVal = hourMaps.entrySet().stream().filter(d-> Collections.asList(d.getValue().split(",")).contains(name)).findFirst().orElse(null); + return ObjectUtils.isEmpty(mapVal) ? null : Integer.valueOf(mapVal.getKey()); + } /*** * 获取每月的工作天数 diff --git a/evo-admin/src/main/java/com/evo/finance/processor/impl/DailyWageStrategyExchangeProcessor.java b/evo-admin/src/main/java/com/evo/finance/processor/impl/DailyWageStrategyExchangeProcessor.java index 7e5e919..d483de9 100644 --- a/evo-admin/src/main/java/com/evo/finance/processor/impl/DailyWageStrategyExchangeProcessor.java +++ b/evo-admin/src/main/java/com/evo/finance/processor/impl/DailyWageStrategyExchangeProcessor.java @@ -96,7 +96,7 @@ public class DailyWageStrategyExchangeProcessor implements SalaryCalculationStra ; - deduction(detail, rzSalaryDetail, new BigDecimal(DateUtils.getMonthDays(rzSalaryDetail.getMonth())).multiply(Constants.DAY_WORK_HOUR), rzAttendanceMapper.selectOne(new QueryWrapper().select( " sum(work_num) as workNum ").lambda().isNotNull(RzAttendance::getWorkSum).gt(RzAttendance::getWorkSum, 0).eq(RzAttendance::getDelFlag, Constants.DELETE_FLAG_0).eq(RzAttendance::getStaffId, sysStaff.getUserId()).apply(" DATE_FORMAT( attendance_date, '%Y%m' ) = DATE_FORMAT({0} , '%Y%m' )", rzSalaryDetail.getMonth())).getWorkSum()); + deduction(detail, rzSalaryDetail, new BigDecimal(DateUtils.getMonthDays(rzSalaryDetail.getMonth())).multiply(Constants.DAY_WORK_HOUR), rzAttendanceMapper.selectOne(new QueryWrapper().select( " sum(work_sum) as workNum ").lambda().isNotNull(RzAttendance::getWorkSum).gt(RzAttendance::getWorkSum, 0).eq(RzAttendance::getDelFlag, Constants.DELETE_FLAG_0).eq(RzAttendance::getStaffId, sysStaff.getUserId()).apply(" DATE_FORMAT( attendance_date, '%Y%m' ) = DATE_FORMAT({0} , '%Y%m' )", rzSalaryDetail.getMonth())).getWorkSum()); //deduction(detail, rzSalaryDetail, String.valueOf(DateUtils.getMonthDays(rzSalaryDetail.getMonth())), rzAttendanceMapper.selectCount(new LambdaQueryWrapper().isNotNull(RzAttendance::getWorkSum).gt(RzAttendance::getWorkSum, 0).eq(RzAttendance::getDelFlag, Constants.DELETE_FLAG_0).eq(RzAttendance::getStaffId, sysStaff.getUserId()).apply(" DATE_FORMAT( attendance_date, '%Y%m' ) = DATE_FORMAT({0} , '%Y%m' )", rzSalaryDetail.getMonth()).select(RzAttendance::getId))); //日薪没有缺勤扣款, 上一天就一天 rzSalaryDetail.setAbsenteeismSalary(new BigDecimal(0)); diff --git a/evo-admin/src/main/java/com/evo/finance/processor/impl/MonthlySalaryStrategyExchangeProcessor.java b/evo-admin/src/main/java/com/evo/finance/processor/impl/MonthlySalaryStrategyExchangeProcessor.java index 8cf3061..f1426f8 100644 --- a/evo-admin/src/main/java/com/evo/finance/processor/impl/MonthlySalaryStrategyExchangeProcessor.java +++ b/evo-admin/src/main/java/com/evo/finance/processor/impl/MonthlySalaryStrategyExchangeProcessor.java @@ -93,7 +93,7 @@ public class MonthlySalaryStrategyExchangeProcessor implements SalaryCalculation subsidy(sysStaff, detail, rzSalaryDetail, attendanceStatistical); //计算扣减 - deduction(detail, rzSalaryDetail, new BigDecimal(workNum).multiply(Constants.DAY_WORK_HOUR), rzAttendanceMapper.selectOne(new QueryWrapper().select( " sum(work_num) as workNum ").lambda().isNotNull(RzAttendance::getWorkSum).gt(RzAttendance::getWorkSum, 0).eq(RzAttendance::getDelFlag, Constants.DELETE_FLAG_0).eq(RzAttendance::getStaffId, sysStaff.getUserId()).apply(" DATE_FORMAT( attendance_date, '%Y%m' ) = DATE_FORMAT({0} , '%Y%m' )", rzSalaryDetail.getMonth())).getWorkSum()); + deduction(detail, rzSalaryDetail, new BigDecimal(workNum).multiply(Constants.DAY_WORK_HOUR), rzAttendanceMapper.selectOne(new QueryWrapper().select( " sum(work_sum) as workNum ").lambda().isNotNull(RzAttendance::getWorkSum).gt(RzAttendance::getWorkSum, 0).eq(RzAttendance::getDelFlag, Constants.DELETE_FLAG_0).eq(RzAttendance::getStaffId, sysStaff.getUserId()).apply(" DATE_FORMAT( attendance_date, '%Y%m' ) = DATE_FORMAT({0} , '%Y%m' )", rzSalaryDetail.getMonth())).getWorkSum()); //deduction(detail, rzSalaryDetail,workNum, rzAttendanceMapper.selectCount(new LambdaQueryWrapper().isNotNull(RzAttendance::getWorkSum).gt(RzAttendance::getWorkSum, 0).eq(RzAttendance::getDelFlag, Constants.DELETE_FLAG_0).eq(RzAttendance::getStaffId, sysStaff.getUserId()).apply(" DATE_FORMAT( attendance_date, '%Y%m' ) = DATE_FORMAT({0} , '%Y%m' )", rzSalaryDetail.getMonth()).select(RzAttendance::getId))); //计算社保 socialSecurity(detail, attendanceStatistical); diff --git a/evo-admin/src/main/java/com/evo/restaurant/controller/RzRestaurantStatisticsController.java b/evo-admin/src/main/java/com/evo/restaurant/controller/RzRestaurantStatisticsController.java index 378ed10..b4838fc 100644 --- a/evo-admin/src/main/java/com/evo/restaurant/controller/RzRestaurantStatisticsController.java +++ b/evo-admin/src/main/java/com/evo/restaurant/controller/RzRestaurantStatisticsController.java @@ -18,6 +18,8 @@ import javax.servlet.http.HttpServletResponse; import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; /** * 餐饮统计Controller @@ -52,166 +54,7 @@ public class RzRestaurantStatisticsController extends BaseController @PostMapping ("/export") public AjaxResult export(RzRestaurantStatistics rzRestaurantStatistics) { - ExcelUtilCy util = new ExcelUtilCy(RzRestaurantStatistics.class); - //创建总表 - List list = new ArrayList(); - //创建各个部门工资数据集合的集合 - List> lists = new ArrayList<>(); - //创建各个部门sheetname集合 - List sheetNameList = new ArrayList<>(); - List res_list = rzRestaurantStatisticsService.selectRzRestaurantStatisticsList(rzRestaurantStatistics); - //先找到有多少个公司部门 - for (RzRestaurantStatistics restaurantStatistics : res_list) { - if(sheetNameList.isEmpty()){ - sheetNameList.add(restaurantStatistics.getCompanyName()); - continue; - } - if(sheetNameList.contains(restaurantStatistics.getCompanyName())){ - continue; - } - sheetNameList.add(restaurantStatistics.getCompanyName()); - } - List c_list = null; - //部门合计 - RzRestaurantStatistics vo_obj = null; - RzRestaurantStatistics res_obj = null; - for (String s : sheetNameList) { - c_list = new ArrayList(); - vo_obj = new RzRestaurantStatistics(); - res_obj = new RzRestaurantStatistics(); - for (RzRestaurantStatistics restaurantStatistics : res_list) { - if(s.equals(restaurantStatistics.getCompanyName())){ - if(null == vo_obj.getBreakfastNumber()){ - vo_obj.setBreakfastNumber(0L); - } - vo_obj.setBreakfastNumber(vo_obj.getBreakfastNumber() + restaurantStatistics.getBreakfastNumber()); - if(null == vo_obj.getBreakfastExpend()){ - vo_obj.setBreakfastExpend(new BigDecimal("0.00")); - } - vo_obj.setBreakfastExpend(vo_obj.getBreakfastExpend().add(restaurantStatistics.getBreakfastExpend())); - if(null == vo_obj.getBreakfastPreSumExpend()){ - vo_obj.setBreakfastPreSumExpend(new BigDecimal("0.00")); - } - vo_obj.setBreakfastPreSumExpend(vo_obj.getBreakfastPreSumExpend().add(restaurantStatistics.getBreakfastPreSumExpend())); - if(null == vo_obj.getBreakfastSumExpend()){ - vo_obj.setBreakfastSumExpend(new BigDecimal("0.00")); - } - vo_obj.setBreakfastSumExpend(vo_obj.getBreakfastSumExpend().add(restaurantStatistics.getBreakfastSumExpend())); - if(null == vo_obj.getLunchNumber()){ - vo_obj.setLunchNumber(0l); - } - vo_obj.setLunchNumber(vo_obj.getLunchNumber() + restaurantStatistics.getLunchNumber()); - if(null == vo_obj.getLunchExpend()){ - vo_obj.setLunchExpend(new BigDecimal("0.00")); - } - vo_obj.setLunchExpend(vo_obj.getLunchExpend().add(restaurantStatistics.getLunchExpend())); - if(null == vo_obj.getLunchPreSumExpend()){ - vo_obj.setLunchPreSumExpend(new BigDecimal("0.00")); - } - vo_obj.setLunchPreSumExpend(vo_obj.getLunchPreSumExpend().add(restaurantStatistics.getLunchPreSumExpend())); - if(null == vo_obj.getLunchSumExpend()){ - vo_obj.setLunchSumExpend(new BigDecimal("0.00")); - } - vo_obj.setLunchSumExpend(vo_obj.getLunchSumExpend().add(restaurantStatistics.getLunchSumExpend())); - if(null == vo_obj.getSupperNumber()){ - vo_obj.setSupperNumber(0l); - } - vo_obj.setSupperNumber(vo_obj.getSupperNumber() + restaurantStatistics.getSupperNumber()); - if(null == vo_obj.getSupperExpend()){ - vo_obj.setSupperExpend(new BigDecimal("0.00")); - } - vo_obj.setSupperExpend(vo_obj.getSupperExpend().add(restaurantStatistics.getSupperExpend())); - if(null == vo_obj.getSupperPreSumExpend()){ - vo_obj.setSupperPreSumExpend(new BigDecimal("0.00")); - } - vo_obj.setSupperPreSumExpend(vo_obj.getSupperPreSumExpend().add(restaurantStatistics.getSupperPreSumExpend())); - if(null == vo_obj.getSupperSumExpend()){ - vo_obj.setSupperSumExpend(new BigDecimal("0.00")); - } - vo_obj.setSupperSumExpend(vo_obj.getSupperSumExpend().add(restaurantStatistics.getSupperSumExpend())); - if(null == vo_obj.getPersonalSumConsumption()){ - vo_obj.setPersonalSumConsumption(new BigDecimal("0.00")); - } - vo_obj.setPersonalSumConsumption(vo_obj.getPersonalSumConsumption().add(restaurantStatistics.getPersonalSumConsumption())); - if(vo_obj.getSumConsumption() == null){ - vo_obj.setSumConsumption(new BigDecimal("0.00")); - } - vo_obj.setSumConsumption(vo_obj.getSumConsumption().add(restaurantStatistics.getSumConsumption())); - c_list.add(restaurantStatistics); - } - } - vo_obj.setName("合计: "); - c_list.add(vo_obj); - lists.add(c_list); - BeanUtils.copyProperties(vo_obj,res_obj); - res_obj.setMonth(rzRestaurantStatistics.getMonth()); - res_obj.setName(s); - list.add(res_obj); - } - - //计算共计 - vo_obj = new RzRestaurantStatistics(); - vo_obj.setName("共计: "); - for (RzRestaurantStatistics restaurantStatistics : list) { - if(null == vo_obj.getBreakfastNumber()){ - vo_obj.setBreakfastNumber(0l); - } - vo_obj.setBreakfastNumber(vo_obj.getBreakfastNumber() + restaurantStatistics.getBreakfastNumber()); - if(null == vo_obj.getBreakfastExpend()){ - vo_obj.setBreakfastExpend(new BigDecimal("0.00")); - } - vo_obj.setBreakfastExpend(vo_obj.getBreakfastExpend().add(restaurantStatistics.getBreakfastExpend())); - if(null == vo_obj.getBreakfastPreSumExpend()){ - vo_obj.setBreakfastPreSumExpend(new BigDecimal("0.00")); - } - vo_obj.setBreakfastPreSumExpend(vo_obj.getBreakfastPreSumExpend().add(restaurantStatistics.getBreakfastPreSumExpend())); - if(null == vo_obj.getBreakfastSumExpend()){ - vo_obj.setBreakfastSumExpend(new BigDecimal("0.00")); - } - vo_obj.setBreakfastSumExpend(vo_obj.getBreakfastSumExpend().add(restaurantStatistics.getBreakfastSumExpend())); - if(null == vo_obj.getLunchNumber()){ - vo_obj.setLunchNumber(0l); - } - vo_obj.setLunchNumber(vo_obj.getLunchNumber() + restaurantStatistics.getLunchNumber()); - if(null == vo_obj.getLunchExpend()){ - vo_obj.setLunchExpend(new BigDecimal("0.00")); - } - vo_obj.setLunchExpend(vo_obj.getLunchExpend().add(restaurantStatistics.getLunchExpend())); - if(null == vo_obj.getLunchPreSumExpend()){ - vo_obj.setLunchPreSumExpend(new BigDecimal("0.00")); - } - vo_obj.setLunchPreSumExpend(vo_obj.getLunchPreSumExpend().add(restaurantStatistics.getLunchPreSumExpend())); - if(null == vo_obj.getLunchSumExpend()){ - vo_obj.setLunchSumExpend(new BigDecimal("0.00")); - } - vo_obj.setLunchSumExpend(vo_obj.getLunchSumExpend().add(restaurantStatistics.getLunchSumExpend())); - if(null == vo_obj.getSupperNumber()){ - vo_obj.setSupperNumber(0l); - } - vo_obj.setSupperNumber(vo_obj.getSupperNumber() + restaurantStatistics.getSupperNumber()); - if(null == vo_obj.getSupperExpend()){ - vo_obj.setSupperExpend(new BigDecimal("0.00")); - } - vo_obj.setSupperExpend(vo_obj.getSupperExpend().add(restaurantStatistics.getSupperExpend())); - if(null == vo_obj.getSupperPreSumExpend()){ - vo_obj.setSupperPreSumExpend(new BigDecimal("0.00")); - } - vo_obj.setSupperPreSumExpend(vo_obj.getSupperPreSumExpend().add(restaurantStatistics.getSupperPreSumExpend())); - if(null == vo_obj.getSupperSumExpend()){ - vo_obj.setSupperSumExpend(new BigDecimal("0.00")); - } - vo_obj.setSupperSumExpend(vo_obj.getSupperSumExpend().add(restaurantStatistics.getSupperSumExpend())); - if(null == vo_obj.getPersonalSumConsumption()){ - vo_obj.setPersonalSumConsumption(new BigDecimal("0.00")); - } - vo_obj.setPersonalSumConsumption(vo_obj.getPersonalSumConsumption().add(restaurantStatistics.getPersonalSumConsumption())); - if(vo_obj.getSumConsumption() == null){ - vo_obj.setSumConsumption(new BigDecimal("0.00")); - } - vo_obj.setSumConsumption(vo_obj.getSumConsumption().add(restaurantStatistics.getSumConsumption())); - } - list.add(vo_obj); - return util.exportExcel(list,lists,"总表",sheetNameList); + return rzRestaurantStatisticsService.export(rzRestaurantStatistics); } @GetMapping("/exportkd") diff --git a/evo-admin/src/main/java/com/evo/restaurant/domain/vo/RzRestaurantStatisticsExportVo.java b/evo-admin/src/main/java/com/evo/restaurant/domain/vo/RzRestaurantStatisticsExportVo.java new file mode 100644 index 0000000..6089649 --- /dev/null +++ b/evo-admin/src/main/java/com/evo/restaurant/domain/vo/RzRestaurantStatisticsExportVo.java @@ -0,0 +1,83 @@ +package com.evo.restaurant.domain.vo; + +import com.evo.common.annotation.Excel; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * 类 + * + * @ClassName:RzRestaurantStatisticsExportVo + * @date: 2025年06月05日 11:37 + * @author: andy.shi + * @contact: 17330188597 + * @remark: 开发人员联系方式 1042025947@qq.com/微信同步 + */ +@Data +public class RzRestaurantStatisticsExportVo { + + @Excel(name = "统计月份") + private String month; + @Excel(name = "姓名") + private String name; + @Excel(name = "部门") + private String deptName; + @Excel(name = "公司") + private String companyName; + /** 早餐消费 */ + @Excel(name = "早餐消费") + private BigDecimal breakfastExpend; + + /** 早餐次数 */ + @Excel(name = "早餐次数") + private Long breakfastNumber; + + /** 早餐个人总消费 */ + @Excel(name = "早餐个人总消费") + private BigDecimal breakfastPreSumExpend; + + /** 早餐总消费 */ + @Excel(name = "早餐总消费") + private BigDecimal breakfastSumExpend; + + /** 午餐消费 */ + @Excel(name = "午餐消费") + private BigDecimal lunchExpend; + + /** 午餐次数 */ + @Excel(name = "午餐次数") + private Long lunchNumber; + + /** 午餐个人总消费 */ + @Excel(name = "午餐个人总消费") + private BigDecimal lunchPreSumExpend; + + /** 午餐总消费 */ + @Excel(name = "午餐总消费") + private BigDecimal lunchSumExpend; + + /** 晚餐消费 */ + @Excel(name = "晚餐消费") + private BigDecimal supperExpend; + + /** 晚餐次数 */ + @Excel(name = "晚餐次数") + private Long supperNumber; + + /** 晚餐个人总消费 */ + @Excel(name = "晚餐个人总消费") + private BigDecimal supperPreSumExpend; + + /** 晚餐总消费 */ + @Excel(name = "晚餐总消费") + private BigDecimal supperSumExpend; + + /** 个人总消费 */ + @Excel(name = "个人总消费") + private BigDecimal personalSumConsumption; + + /** 总消费 */ + @Excel(name = "总消费") + private BigDecimal sumConsumption; +} diff --git a/evo-admin/src/main/java/com/evo/restaurant/service/IRzRestaurantStatisticsService.java b/evo-admin/src/main/java/com/evo/restaurant/service/IRzRestaurantStatisticsService.java index c8fec50..5c47a2f 100644 --- a/evo-admin/src/main/java/com/evo/restaurant/service/IRzRestaurantStatisticsService.java +++ b/evo-admin/src/main/java/com/evo/restaurant/service/IRzRestaurantStatisticsService.java @@ -46,4 +46,6 @@ public interface IRzRestaurantStatisticsService */ public List selectRzRestaurantStatisticsListBySxs(RzRestaurantStatistics rzRestaurantStatistics); + + public AjaxResult export(RzRestaurantStatistics rzRestaurantStatistics); } diff --git a/evo-admin/src/main/java/com/evo/restaurant/service/impl/RzRestaurantStatisticsServiceImpl.java b/evo-admin/src/main/java/com/evo/restaurant/service/impl/RzRestaurantStatisticsServiceImpl.java index 57a2a88..d356bf3 100644 --- a/evo-admin/src/main/java/com/evo/restaurant/service/impl/RzRestaurantStatisticsServiceImpl.java +++ b/evo-admin/src/main/java/com/evo/restaurant/service/impl/RzRestaurantStatisticsServiceImpl.java @@ -13,16 +13,22 @@ import com.evo.common.utils.StringUtils; import com.evo.restaurant.domain.RzRestaurantDetail; import com.evo.restaurant.domain.RzRestaurantImages; import com.evo.restaurant.domain.RzRestaurantStatistics; +import com.evo.restaurant.domain.vo.RzRestaurantStatisticsExportVo; import com.evo.restaurant.mapper.RzRestaurantDetailMapper; import com.evo.restaurant.mapper.RzRestaurantImagesMapper; import com.evo.restaurant.mapper.RzRestaurantStatisticsMapper; import com.evo.restaurant.service.IRzRestaurantStatisticsService; +import com.evo.restaurant.utils.ExcelUtilCy; import com.evo.system.domain.SysStaff; import com.evo.system.domain.SysStaffDetail; import com.evo.system.mapper.*; +import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -68,12 +74,29 @@ public class RzRestaurantStatisticsServiceImpl extends ServiceImpl selectRzRestaurantStatisticsList(RzRestaurantStatistics rzRestaurantStatistics) { - List res_list = getBaseMapper().selectRzRestaurantStatisticsList(rzRestaurantStatistics); - Map deptNameMap = deptMapper.selectList(new LambdaQueryWrapper()).stream().collect(Collectors.toMap(SysDept::getDeptId, SysDept::getDeptName)); - for (RzRestaurantStatistics restaurantStatistics : res_list) { - restaurantStatistics.setCompanyName(DataUtils.findDefaultValue(deptNameMap.get(restaurantStatistics.getDeptId()), "实习生")); - } - return res_list; + + return getBaseMapper().selectRzRestaurantStatisticsList(rzRestaurantStatistics); +// +// List deptList = deptMapper.selectList(new LambdaQueryWrapper()); +// Map deptNameMap = deptList.stream().collect(Collectors.toMap(SysDept::getDeptId, SysDept::getDeptName)); +// Map nameAndDeptIdMap = deptList.stream().filter(d -> d.getParentId().equals(0l)).collect(Collectors.toMap(d->String.valueOf(d.getDeptId()), SysDept::getDeptName)); +// Map companyNameMap = Collections.emptyMap(); +// deptList.stream().filter(d -> !d.getParentId().equals(0l)).forEach(d ->{ +// List parentIdList = Collections.asList(d.getAncestors().split(",")); +// Iterator it = nameAndDeptIdMap.keySet().iterator(); +// while (it.hasNext()){ +// String pid = it.next(); +// if(parentIdList.contains(pid)){ +// companyNameMap.put(d.getDeptId(), nameAndDeptIdMap.get(pid)); +// } +// } +// }); +// List res_list = getBaseMapper().selectRzRestaurantStatisticsList(rzRestaurantStatistics); +// for (RzRestaurantStatistics restaurantStatistics : res_list) { +// restaurantStatistics.setCompanyName(DataUtils.findDefaultValue(companyNameMap.get(restaurantStatistics.getDeptId()), "实习生")); +// restaurantStatistics.setDeptName(DataUtils.findDefaultValue(deptNameMap.get(restaurantStatistics.getDeptId()), "实习生")); +// } +// return res_list; } /** * 新增餐饮统计 @@ -179,4 +202,59 @@ public class RzRestaurantStatisticsServiceImpl extends ServiceImpl buildExportData(RzRestaurantStatistics rzRestaurantStatistics){ + + List deptList = deptMapper.selectList(new LambdaQueryWrapper()); + Map deptNameMap = deptList.stream().collect(Collectors.toMap(SysDept::getDeptId, SysDept::getDeptName)); + Map nameAndDeptIdMap = deptList.stream().filter(d -> d.getParentId().equals(0l)).collect(Collectors.toMap(d->String.valueOf(d.getDeptId()), SysDept::getDeptName)); + Map companyNameMap = Collections.emptyMap(); + deptList.stream().filter(d -> !d.getParentId().equals(0l)).forEach(d ->{ + List parentIdList = Collections.asList(d.getAncestors().split(",")); + Iterator it = nameAndDeptIdMap.keySet().iterator(); + while (it.hasNext()){ + String pid = it.next(); + if(parentIdList.contains(pid)){ + companyNameMap.put(d.getDeptId(), nameAndDeptIdMap.get(pid)); + } + } + }); + + nameAndDeptIdMap.entrySet().stream().forEach(d->{ + companyNameMap.put(Long.valueOf(d.getKey()), d.getValue()); + }); + + List voResult = Collections.emptyList(); + String month = new SimpleDateFormat("yyyy-MM").format(rzRestaurantStatistics.getMonth()); + List res_list = selectRzRestaurantStatisticsList(rzRestaurantStatistics); + for (RzRestaurantStatistics restaurantStatistics : res_list) { + RzRestaurantStatisticsExportVo vo = new RzRestaurantStatisticsExportVo(); + com.evo.common.utils.bean.BeanUtils.copyProperties(restaurantStatistics, vo); + vo.setCompanyName(DataUtils.findDefaultValue(companyNameMap.get(restaurantStatistics.getDeptId()), "实习生")); + vo.setDeptName(DataUtils.findDefaultValue(deptNameMap.get(restaurantStatistics.getDeptId()), "实习生")); + vo.setMonth(month); + voResult.add(vo); + } + + + return voResult; +} + + @Override + public AjaxResult export(RzRestaurantStatistics rzRestaurantStatistics) { + ExcelUtilCy util = new ExcelUtilCy(RzRestaurantStatisticsExportVo.class); + + Map> dataList = buildExportData(rzRestaurantStatistics).stream().collect(Collectors.groupingBy(RzRestaurantStatisticsExportVo::getCompanyName)); + //总表 + List allList = new ArrayList(); + //创建各个部门工资数据集合的集合 + List> lists = new ArrayList<>(); + + for (String sheetName : dataList.keySet()) { + allList.addAll(dataList.get(sheetName)); + lists.add(dataList.get(sheetName)); + } + return util.exportExcel(allList,lists,"总表",dataList.keySet().stream().collect(Collectors.toList())); + } + }