Commit dcf5c10b authored by nie'hong's avatar nie'hong

导出完成

parent fb31745c
package cn.wisenergy.model.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* @Authotr:陈奇
* @QQ1799796883
*/
@Data
@ApiModel(value="CalendarDto", description="日历展示类")
public class CalendarDto implements Serializable {
private static final long serialVersionUID = -1678604782365034642L;
@ApiModelProperty(name = "userId",value = "填报工时人员")
private Integer userId;
@ApiModelProperty(name = "status",value = "状态: 1:已填报 ,2:已审核,3:被驳回")
private Integer status;
@ApiModelProperty(name = "workDay",value = "工时的日期")
private Date workDay;
}
package cn.wisenergy.model.dto;
import lombok.Data;
import java.io.Serializable;
/**
* @description: 一天的工时信息
* @author: nh
* @create: 2021-01-20 13:36
**/
@Data
public class DayWorkTimeAndType implements Serializable {
private static final long serialVersionUID = 1198786417184957375L;
private Integer day;
/**
* 工时类型
*/
private Integer type;
private Integer workTime;
}
package cn.wisenergy.model.dto;
import lombok.Data;
import java.io.Serializable;
/**
* @description:
* @author: nh
* @create: 2021-01-19 15:47
**/
@Data
public class MonthlyWorkingHoursStatistics implements Serializable {
private static final long serialVersionUID = -8216457470821285624L;
/**
* 填报次数
*/
private Integer count;
/**
* 填报工时
*/
private Integer workTime;
/**
* 审核情况(非审核人员为空)
*/
private ApprovalStatistics approvalStatistics;
}
package cn.wisenergy.model.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @description: 月汇总信息
* @author: nh
* @create: 2021-01-19 17:22
**/
@Data
public class StatisticsTableDto implements Serializable {
private static final long serialVersionUID = -7581698349760684467L;
private Integer userId;
private String userName;
List<DayWorkTimeAndType> dayWorkTimeAndTypeList;
}
package cn.wisenergy.service;
import cn.wisenergy.model.dto.StatisticsTableDto;
import java.util.List;
public interface StatisticsService {
/**
* 获取部门所有员工每天工时
* @param year
* @param month
* @param deptId
* @return
*/
List<StatisticsTableDto> getMonthlyCollect(Integer year, Integer month,Integer userId, Integer deptId);
}
package cn.wisenergy.service.impl;
import cn.wisenergy.common.utils.DateUtil;
import cn.wisenergy.common.utils.exception.BASE_RESP_CODE_ENUM;
import cn.wisenergy.common.utils.exception.BaseCustomException;
import cn.wisenergy.mapper.WorkTimeOrderMapper;
import cn.wisenergy.mapper.WorkUserDeptMapper;
import cn.wisenergy.model.app.WorkUser;
import cn.wisenergy.model.dto.DayWorkTimeAndType;
import cn.wisenergy.model.dto.StatisticsTableDto;
import cn.wisenergy.model.enums.ManagerEnum;
import cn.wisenergy.service.StatisticsService;
import cn.wisenergy.service.WorkUserService;
import com.alibaba.excel.util.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* @description:
* @author: nh
* @create: 2021-01-19 17:19
**/
@Service
@Slf4j
public class StatisticsServiceImpl implements StatisticsService {
@Autowired
WorkUserService workUserService;
@Autowired
WorkTimeOrderMapper workOrderMapper;
@Autowired
WorkUserDeptMapper workUserDeptMapper;
@Override
public List<StatisticsTableDto> getMonthlyCollect(Integer year, Integer month, Integer userId, Integer deptId) {
log.info("StatisticsServiceImpl[]getMonthlyCollect[]input.param" + year + month + userId, deptId);
if (userId == null) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL);
}
//管理员用户
WorkUser user = workUserService.getUserById(userId);
if (user.getLevel() != ManagerEnum.IS_SYSTEM_MANAGER.getCode()) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.THE_USER_NOT_MANAGER_PLASE_MANAGER_LOGIN);
}
//默认时间为当月
if (StringUtils.isEmpty(year) || StringUtils.isEmpty(month)) {
Date now = new Date();
year = DateUtil.getYear(now);
month = DateUtil.getMonth(now)+1;
}
//默认部门主键为1
if (deptId == null) {
deptId = 1;
}
//获取部门下所有员工主键
List<Integer> userIdList = workUserDeptMapper.listByDeptId(deptId);
//获取员工一个月中已审核、自动审核的工单单日汇总汇总
ArrayList<StatisticsTableDto> statisticsTableDtos = new ArrayList<>();
for (Integer id : userIdList) {
//获取部门下用户信息
WorkUser workUser = workUserService.getUserById(id);
//获取当月每天工时信息
List<DayWorkTimeAndType> dayWorkTimeAndTypes = workOrderMapper.listByDateAndUserId(year, month, id);
//封装成对象
StatisticsTableDto statisticsTableDto = new StatisticsTableDto();
statisticsTableDto.setUserId(id);
statisticsTableDto.setUserName(workUser.getName());
statisticsTableDto.setDayWorkTimeAndTypeList(dayWorkTimeAndTypes);
statisticsTableDtos.add(statisticsTableDto);
}
return statisticsTableDtos;
}
}
package cn.wisenergy.web.admin.controller.app;
import cn.wisenergy.common.utils.exception.BASE_RESP_CODE_ENUM;
import cn.wisenergy.common.utils.exception.BaseCustomException;
import cn.wisenergy.model.app.WorkDept;
import cn.wisenergy.model.dto.StatisticsTableDto;
import cn.wisenergy.service.StatisticsService;
import cn.wisenergy.service.WorkDeptService;
import cn.wisenergy.web.admin.controller.common.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @description:
* @author: nh
* @create: 2021-01-19 17:13
**/
@RestController
@RequestMapping(value = "/statistics")
@Slf4j
@Api(tags = "月统计报表")
public class StatisticsController extends BaseController {
@Autowired
StatisticsService statisticsService;
@Autowired
WorkDeptService workDeptService;
@ApiOperation(value = "获取部门员工一个月每天的工时", notes = "获取部门员工一个月每天的工时")
@ApiImplicitParams({
@ApiImplicitParam(name = "year", value = "年"),
@ApiImplicitParam(name = "month", value = "月"),
@ApiImplicitParam(name = "userId", value = "用户主键", required = true),
@ApiImplicitParam(name = "deptId", value = "部门编号")
})
@GetMapping("/getMonthlyCollect")
public List<StatisticsTableDto> getMonthlyCollect(Integer year, Integer month, Integer userId, Integer deptId) {
log.info("StatisticsController[]getMonthlyCollect[]input.param" + year + month + userId + deptId);
List<StatisticsTableDto> statisticsTableDtos = statisticsService.getMonthlyCollect(year, month, userId, deptId);
return statisticsTableDtos;
}
@ApiOperation(value = "")
@GetMapping("getDeptInfo")
public List<WorkDept> getDeptInfo(Integer userId, Integer deptId) {
log.info("StatisticsController[]getDeptInfo[]input.param" + userId + deptId);
if (userId == null) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL);
}
List<WorkDept> workDepts = workDeptService.getDeptInfo(userId, deptId);
return workDepts;
}
}
......@@ -3,9 +3,9 @@ spring:
type: com.alibaba.druid.pool.DruidDataSource
druid:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/work_hours?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=GMT%2B8
url: jdbc:mysql://localhost:3306/working_hours?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=GMT%2B8
username: root
password: 123456
password: admin
initial-size: 10
max-active: 100
min-idle: 10
......@@ -68,3 +68,5 @@ jwt:
expire: 14400
logging:
config: classpath:logback-spring.xml
......@@ -65,3 +65,6 @@ camera:
mybatis:
mapper-locations: classpath:/mapper/*Mapper.xml
logging:
level:
cn.wisenergy.mapper : debug
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment