Commit 54179e59 authored by cq990612's avatar cq990612

优化代码结构

parent 3f97e249
package cn.wisenergy.model.dto;
import lombok.Data;
import java.util.List;
/**
* @Authotr:陈奇
* @QQ1799796883
*/
@Data
public class CalendarMonthDto {
private List<CalendarDto> calendarDtos;
private Integer rejectMonth;
}
......@@ -29,10 +29,6 @@ public class SubtotalDto {
@ApiModelProperty(name = "status", value ="状态")
private Integer status;
@ApiModelProperty(name = "rejectMonth",value = "当月被驳回待处理条数")
private Integer rejectMonth;
@ApiModelProperty(name = "modifyTime",value = "驳回时间")
private Integer modifyTime;
......
......@@ -2,7 +2,7 @@ package cn.wisenergy.service;
import cn.wisenergy.model.app.WorkCollect;
import cn.wisenergy.model.app.WorkTimeOrder;
import cn.wisenergy.model.dto.CalendarDto;
import cn.wisenergy.model.dto.CalendarMonthDto;
import cn.wisenergy.model.dto.SubtotalDto;
import java.util.Date;
......@@ -25,7 +25,7 @@ public interface WorkCollectService {
* @param workMonth 查询年月
* @return List<CalendarDto>
*/
List<CalendarDto> calendarMonth(Integer userId, Date workMonth);
CalendarMonthDto calendarMonth(Integer userId, Date workMonth);
/**
......
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.WorkCollectMapper;
import cn.wisenergy.mapper.WorkTimeOrderMapper;
import cn.wisenergy.model.app.WorkCollect;
import cn.wisenergy.model.app.WorkSubmitAdopt;
import cn.wisenergy.model.app.WorkTimeOrder;
import cn.wisenergy.model.dto.CalendarDto;
import cn.wisenergy.model.dto.CalendarMonthDto;
import cn.wisenergy.model.dto.SubtotalDto;
import cn.wisenergy.model.enums.StatusEnum;
import cn.wisenergy.service.WorkCollectService;
import cn.wisenergy.service.WorkSubmitAdoptService;
import cn.wisenergy.service.WorkTimeOrderService;
......@@ -67,8 +67,9 @@ public class WorkCollectServiceImpl implements WorkCollectService {
* @return List<CalendarDto>
*/
@Override
public List<CalendarDto> calendarMonth(Integer userId, Date workMonth) {
public CalendarMonthDto calendarMonth(Integer userId, Date workMonth) {
log.info("WorkCollectServiceImpl[]calendarMonth[]input.param.userId:{},workMonth:{}", userId, workMonth);
CalendarMonthDto calendarMonthDto = new CalendarMonthDto();
if (null == userId || StringUtils.isEmpty(workMonth)) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL);
}
......@@ -76,7 +77,15 @@ public class WorkCollectServiceImpl implements WorkCollectService {
if (CollectionUtils.isEmpty(calendarDtoList)) {
calendarDtoList.add(new CalendarDto().setWorkDay(DateUtil.getFirstDayOfMonth(workMonth)).setUserId(userId));
}
return calendarDtoList;
calendarMonthDto.setCalendarDtos(calendarDtoList);
//返回当月被驳回次数
int rejectMonth = 0;
List<WorkTimeOrder> timeOrders = workTimeOrderMapper.geByMonth(userId, workMonth, StatusEnum.REJECTED.getCode());
if (!CollectionUtils.isEmpty(timeOrders)) {
rejectMonth = timeOrders.size();
}
calendarMonthDto.setRejectMonth(rejectMonth);
return calendarMonthDto;
}
/**
......
......@@ -133,8 +133,6 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
int totalTime = 0;
// 被驳回原因
StringBuilder reason = new StringBuilder();
// 今日被驳回次数
int rejectMonth = 0;
subtotalDto.setUserId(userId);
subtotalDto.setWorkDay(workDay);
List<Integer> typeIds = workTypeService.getIdByReviewer(1);
......@@ -161,14 +159,8 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
}
}
List<WorkTimeOrder> timeOrders = workTimeOrderMapper.geByMonth(userId, workDay, REJECTED);
if (!CollectionUtils.isEmpty(timeOrders)) {
rejectMonth = timeOrders.size();
}
subtotalDto.setReason(reason.toString());
subtotalDto.setTotalTime(totalTime);
subtotalDto.setRejectMonth(rejectMonth);
return subtotalDto;
}
......
......@@ -2,7 +2,7 @@ package cn.wisenergy.web.admin.controller.app;
import cn.wisenergy.common.utils.DateUtil;
import cn.wisenergy.common.utils.exception.Result;
import cn.wisenergy.model.dto.CalendarDto;
import cn.wisenergy.model.dto.CalendarMonthDto;
import cn.wisenergy.model.dto.SubtotalDto;
import cn.wisenergy.service.WorkCollectService;
import cn.wisenergy.web.admin.controller.common.BaseController;
......@@ -17,7 +17,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
import java.util.List;
@RestController
......@@ -35,11 +34,11 @@ public class WorkCollectController extends BaseController {
@ApiImplicitParam(name = "workMonth", value = "工单日期(yyyy-MM)", dataType = "String", required = true)
})
@GetMapping(value = "/month")
public Result<List<CalendarDto>> calendarMonth(Integer userId, String workMonth) {
public Result<CalendarMonthDto> calendarMonth(Integer userId, String workMonth) {
log.info("WorkCollectController[]calendarMonth[]input.param.userId:{},workMonth:{}", userId, workMonth);
Date date = DateUtil.convertStrToDate(workMonth, "yyyy-MM");
List<CalendarDto> calendarDtos = workCollectService.calendarMonth(userId, date);
return getResult( calendarDtos);
CalendarMonthDto calendarMonthDto = workCollectService.calendarMonth(userId, date);
return getResult( calendarMonthDto);
}
@ApiOperation(value = "日历->日详细", notes = "某日填报情况", httpMethod = "GET")
......
......@@ -76,7 +76,7 @@ public class WorkTimeOrderController extends BaseController {
@ApiImplicitParam(name = "projectId", value = "项目id", dataType = "int"),
@ApiImplicitParam(name = "type", value = "部门经理:工单类型type(5,6,7)", dataType = "int"),
@ApiImplicitParam(name = "page", value = "PC端当前页", dataType = "int"),
@ApiImplicitParam(name = "size", value = "PC端一页多少条记录", dataType = "int"),
@ApiImplicitParam(name = "pageSize", value = "PC端一页多少条记录", dataType = "int"),
@ApiImplicitParam(name = "status", value = "PC端审批状态", dataType = "int"),
})
@GetMapping(value = "/getExamine")
......
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