调整导出
This commit is contained in:
parent
595d0f4896
commit
4571d299fd
@ -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<EqButton>().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);
|
||||
|
||||
@ -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<String, String> hourMaps = JSONObject.parseObject(val, Map.class);
|
||||
Map.Entry<String,String> 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());
|
||||
}
|
||||
|
||||
/***
|
||||
* 获取每月的工作天数
|
||||
|
||||
@ -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<RzAttendance>().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<RzAttendance>().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<RzAttendance>().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));
|
||||
|
||||
@ -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<RzAttendance>().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<RzAttendance>().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<RzAttendance>().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);
|
||||
|
||||
@ -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<RzRestaurantStatistics> util = new ExcelUtilCy<RzRestaurantStatistics>(RzRestaurantStatistics.class);
|
||||
//创建总表
|
||||
List<RzRestaurantStatistics> list = new ArrayList<RzRestaurantStatistics>();
|
||||
//创建各个部门工资数据集合的集合
|
||||
List<List<RzRestaurantStatistics>> lists = new ArrayList<>();
|
||||
//创建各个部门sheetname集合
|
||||
List<String> sheetNameList = new ArrayList<>();
|
||||
List<RzRestaurantStatistics> 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<RzRestaurantStatistics> c_list = null;
|
||||
//部门合计
|
||||
RzRestaurantStatistics vo_obj = null;
|
||||
RzRestaurantStatistics res_obj = null;
|
||||
for (String s : sheetNameList) {
|
||||
c_list = new ArrayList<RzRestaurantStatistics>();
|
||||
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")
|
||||
|
||||
@ -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;
|
||||
}
|
||||
@ -46,4 +46,6 @@ public interface IRzRestaurantStatisticsService
|
||||
*/
|
||||
public List<RzRestaurantStatistics> selectRzRestaurantStatisticsListBySxs(RzRestaurantStatistics rzRestaurantStatistics);
|
||||
|
||||
|
||||
public AjaxResult export(RzRestaurantStatistics rzRestaurantStatistics);
|
||||
}
|
||||
|
||||
@ -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<RzRestaurantS
|
||||
@Override
|
||||
public List<RzRestaurantStatistics> selectRzRestaurantStatisticsList(RzRestaurantStatistics rzRestaurantStatistics)
|
||||
{
|
||||
List<RzRestaurantStatistics> res_list = getBaseMapper().selectRzRestaurantStatisticsList(rzRestaurantStatistics);
|
||||
Map<Long, String> deptNameMap = deptMapper.selectList(new LambdaQueryWrapper<SysDept>()).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<SysDept> deptList = deptMapper.selectList(new LambdaQueryWrapper<SysDept>());
|
||||
// Map<Long, String> deptNameMap = deptList.stream().collect(Collectors.toMap(SysDept::getDeptId, SysDept::getDeptName));
|
||||
// Map<String, String> nameAndDeptIdMap = deptList.stream().filter(d -> d.getParentId().equals(0l)).collect(Collectors.toMap(d->String.valueOf(d.getDeptId()), SysDept::getDeptName));
|
||||
// Map<Long, String> companyNameMap = Collections.emptyMap();
|
||||
// deptList.stream().filter(d -> !d.getParentId().equals(0l)).forEach(d ->{
|
||||
// List<String> parentIdList = Collections.asList(d.getAncestors().split(","));
|
||||
// Iterator<String> it = nameAndDeptIdMap.keySet().iterator();
|
||||
// while (it.hasNext()){
|
||||
// String pid = it.next();
|
||||
// if(parentIdList.contains(pid)){
|
||||
// companyNameMap.put(d.getDeptId(), nameAndDeptIdMap.get(pid));
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// List<RzRestaurantStatistics> 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<RzRestaurantS
|
||||
return getBaseMapper().selectRzRestaurantStatisticsByDate(rzRestaurantStatistics.getMonth());
|
||||
}
|
||||
|
||||
|
||||
public List<RzRestaurantStatisticsExportVo> buildExportData(RzRestaurantStatistics rzRestaurantStatistics){
|
||||
|
||||
List<SysDept> deptList = deptMapper.selectList(new LambdaQueryWrapper<SysDept>());
|
||||
Map<Long, String> deptNameMap = deptList.stream().collect(Collectors.toMap(SysDept::getDeptId, SysDept::getDeptName));
|
||||
Map<String, String> nameAndDeptIdMap = deptList.stream().filter(d -> d.getParentId().equals(0l)).collect(Collectors.toMap(d->String.valueOf(d.getDeptId()), SysDept::getDeptName));
|
||||
Map<Long, String> companyNameMap = Collections.emptyMap();
|
||||
deptList.stream().filter(d -> !d.getParentId().equals(0l)).forEach(d ->{
|
||||
List<String> parentIdList = Collections.asList(d.getAncestors().split(","));
|
||||
Iterator<String> 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<RzRestaurantStatisticsExportVo> voResult = Collections.emptyList();
|
||||
String month = new SimpleDateFormat("yyyy-MM").format(rzRestaurantStatistics.getMonth());
|
||||
List<RzRestaurantStatistics> 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<RzRestaurantStatisticsExportVo> util = new ExcelUtilCy<RzRestaurantStatisticsExportVo>(RzRestaurantStatisticsExportVo.class);
|
||||
|
||||
Map<String,List<RzRestaurantStatisticsExportVo>> dataList = buildExportData(rzRestaurantStatistics).stream().collect(Collectors.groupingBy(RzRestaurantStatisticsExportVo::getCompanyName));
|
||||
//总表
|
||||
List<RzRestaurantStatisticsExportVo> allList = new ArrayList<RzRestaurantStatisticsExportVo>();
|
||||
//创建各个部门工资数据集合的集合
|
||||
List<List<RzRestaurantStatisticsExportVo>> 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()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user