Commit ec6b6e02 authored by cq990612's avatar cq990612

优化代码结构

parent 99d186ad
......@@ -55,7 +55,10 @@ public enum BASE_RESP_CODE_ENUM {
DEPT_NOT_FOUND("633", "部门信息未找到"),
DATE_IS_ERROR("634","时间不匹配"),
CENTRE_NOT_FOUND("635","中心信息未找到"),
TIME_NOT_IS_NULL("636","工时不能为0")
TIME_NOT_IS_NULL("636","工时不能为0"),
WORKDAY_NOT_NULL("637","工时日期不能为空"),
PROJECT_NOT_NULL("638","项目类型不能为空"),
;
/**
......
......@@ -186,6 +186,7 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
// 判断是否超过8小时
int count = 0;
List<WorkTimeOrder> byDayToDto = getByDayToDto(workTimeOrders.get(0).getUserId(), workTimeOrders.get(0).getWorkDay());
// 判断是否重复填报
isRepeat(workTimeOrders);
......@@ -559,22 +560,8 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
for (WorkTimeOrderDto dto : list) {
if (null == dto.getWorkTime() || 0 == dto.getWorkTime()) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.TIME_NOT_IS_NULL);
}
if (null == dto.getDes()) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.DES_NOT_NULL);
}
if (null == dto.getWorkDay() || null == dto.getType()) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL);
}
if (thanDate(dto.getWorkDay())) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.WORK_TIME_OVER_NOW_DAY);
}
isEmpty(dto);
// 2、默认设置超过系统默认3天(包括驳回3天)未填报的工时将不能填报
if (date.getTime() - dto.getWorkDay().getTime() > submitTime * 24 * 60 * 60 * 1000) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.WORK_DAY_THAN_DATE);
......@@ -596,15 +583,27 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
}
private void isEmpty(WorkTimeOrderDto dto) {
if (null == dto.getWorkTime() || 0 == dto.getWorkTime()) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.TIME_NOT_IS_NULL);
}
if (null == dto.getDes() || "".equals(dto.getDes())) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.DES_NOT_NULL);
}
if (null == dto.getWorkDay()) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.WORKDAY_NOT_NULL);
}
if (null == dto.getType() || 0 == dto.getType()) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.PROJECT_NOT_NULL);
}
if (thanDate(dto.getWorkDay())) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.WORK_TIME_OVER_NOW_DAY);
}
}
//3.每天工时累加不得超过八小时
private void timeNotEight(int count, List<WorkTimeOrderDto> list) {
for (WorkTimeOrderDto workOrder : list) {
if (null == workOrder.getWorkDay()) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL);
}
if (0 == workOrder.getWorkTime()) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.TIME_NOT_IS_NULL);
}
isEmpty(workOrder);
count = count + workOrder.getWorkTime();
if (count > 8) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.WORK_TIME_NOT_OVER_EIGHT);
......
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