Commit b9902faf authored by cq990612's avatar cq990612

优化代码结构

parent d5b09a95
...@@ -10,7 +10,7 @@ import java.util.List; ...@@ -10,7 +10,7 @@ import java.util.List;
*/ */
public interface WorkTypeService { public interface WorkTypeService {
List<WorkType> getAll(); List<WorkType> getAll(Integer isSort);
List<Integer> getIdByReviewer(Integer reviewer); List<Integer> getIdByReviewer(Integer reviewer);
......
...@@ -153,7 +153,7 @@ public class WorkHolidayServiceImpl implements WorkHolidayService { ...@@ -153,7 +153,7 @@ public class WorkHolidayServiceImpl implements WorkHolidayService {
List<WorkHoliday> workHolidays = workHolidayMapper.getByTypeAndStartDate(new Date()); List<WorkHoliday> workHolidays = workHolidayMapper.getByTypeAndStartDate(new Date());
WorkSubmitAdopt submitAdopt = workSubmitAdoptService.getById(1); WorkSubmitAdopt submitAdopt = workSubmitAdoptService.getById(1);
holidayAndAutoDto.setWorkHolidays(workHolidays).setWorkSubmitAdopt(submitAdopt); holidayAndAutoDto.setWorkHolidays(workHolidays).setWorkSubmitAdopt(submitAdopt);
List<WorkType> workTypes = workTypeService.getAll(); List<WorkType> workTypes = workTypeService.getAll(null);
if (!CollectionUtils.isEmpty(workTypes)) { if (!CollectionUtils.isEmpty(workTypes)) {
holidayAndAutoDto.setWorkTypes(workTypes); holidayAndAutoDto.setWorkTypes(workTypes);
} }
......
...@@ -30,6 +30,8 @@ import org.springframework.util.StringUtils; ...@@ -30,6 +30,8 @@ import org.springframework.util.StringUtils;
import java.util.*; import java.util.*;
import static java.util.Collections.*;
/** /**
* <p> * <p>
* 服务实现类 * 服务实现类
...@@ -146,7 +148,7 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService { ...@@ -146,7 +148,7 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
reason.append(workProjectService.getById(wto.getProjectId()).getProjectName()).append(":").append(wto.getReason()).append(";"); reason.append(workProjectService.getById(wto.getProjectId()).getProjectName()).append(":").append(wto.getReason()).append(";");
} }
if (!typeIds.contains(wto.getType())) { if (!typeIds.contains(wto.getType())) {
List<WorkType> workTypes = workTypeService.getAll(); List<WorkType> workTypes = workTypeService.getAll(null);
if (!CollectionUtils.isEmpty(workTimeOrders)) { if (!CollectionUtils.isEmpty(workTimeOrders)) {
for (WorkType value : workTypes) { for (WorkType value : workTypes) {
if (value.getId().equals(wto.getType())) { if (value.getId().equals(wto.getType())) {
...@@ -526,7 +528,7 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService { ...@@ -526,7 +528,7 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
ProjectsDto projectsDto = new ProjectsDto(); ProjectsDto projectsDto = new ProjectsDto();
WorkUser user = workUserService.getById(userId); WorkUser user = workUserService.getById(userId);
// 1.获取可填报的类型 // 1.获取可填报的类型
List<WorkType> workTypes = workTypeService.getAll(); List<WorkType> workTypes = workTypeService.getAll(1);
if (!CollectionUtils.isEmpty(workTypes)) { if (!CollectionUtils.isEmpty(workTypes)) {
projectsDto.setWorkTypes(workTypes); projectsDto.setWorkTypes(workTypes);
} }
...@@ -599,7 +601,7 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService { ...@@ -599,7 +601,7 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
} }
} }
} }
Collections.sort(projectManagerDtos); sort(projectManagerDtos);
projectsDto.setProjectManagerDto(projectManagerDtos); projectsDto.setProjectManagerDto(projectManagerDtos);
return projectsDto; return projectsDto;
} }
...@@ -622,7 +624,7 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService { ...@@ -622,7 +624,7 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
List<WorkProject> projects = workProjectService.getNameByIds(projectIds, 1); List<WorkProject> projects = workProjectService.getNameByIds(projectIds, 1);
ProjectInfoDto projectInfoDto; ProjectInfoDto projectInfoDto;
List<WorkType> workTypes = workTypeService.getAll(); List<WorkType> workTypes = workTypeService.getAll(null);
if (!CollectionUtils.isEmpty(workTypes)) { if (!CollectionUtils.isEmpty(workTypes)) {
for (WorkType value : workTypes) { for (WorkType value : workTypes) {
projectInfoDto = new ProjectInfoDto().setType(value.getId()).setTypeName(value.getName()).setDeptManagerName(deptManagerName); projectInfoDto = new ProjectInfoDto().setType(value.getId()).setTypeName(value.getName()).setDeptManagerName(deptManagerName);
...@@ -719,7 +721,7 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService { ...@@ -719,7 +721,7 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.NO_JOIN_EVERY_PROJECT_PLASE_JION); throw new BaseCustomException(BASE_RESP_CODE_ENUM.NO_JOIN_EVERY_PROJECT_PLASE_JION);
} }
} }
List<WorkType> workTypes = workTypeService.getAll(); List<WorkType> workTypes = workTypeService.getAll(null);
if (!CollectionUtils.isEmpty(workTypes)) { if (!CollectionUtils.isEmpty(workTypes)) {
for (WorkType value : workTypes) { for (WorkType value : workTypes) {
if (value.getReviewer() == 2) { if (value.getReviewer() == 2) {
...@@ -827,7 +829,7 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService { ...@@ -827,7 +829,7 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
} }
private String getTypeName(Integer type) { private String getTypeName(Integer type) {
List<WorkType> workTypes = workTypeService.getAll(); List<WorkType> workTypes = workTypeService.getAll(null);
if (!CollectionUtils.isEmpty(workTypes)) { if (!CollectionUtils.isEmpty(workTypes)) {
for (WorkType value : workTypes) { for (WorkType value : workTypes) {
if (value.getId().equals(type)) { if (value.getId().equals(type)) {
......
...@@ -33,13 +33,15 @@ public class WorkTypeServiceImpl implements WorkTypeService { ...@@ -33,13 +33,15 @@ public class WorkTypeServiceImpl implements WorkTypeService {
@Override @Override
public List<WorkType> getAll() { public List<WorkType> getAll(Integer isSort) {
log.info("WorkTypeServiceImpl[]getAll[]"); log.info("WorkTypeServiceImpl[]getAll[]");
List<WorkType> workTypes = workTypeMapper.getAll(); List<WorkType> workTypes = workTypeMapper.getAll();
if (CollectionUtils.isEmpty(workTypes)) { if (CollectionUtils.isEmpty(workTypes)) {
return null; return null;
} }
if (null != isSort && 1 == isSort) {
Collections.sort(workTypes); Collections.sort(workTypes);
}
return workTypes; return workTypes;
} }
......
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