Commit 3e08e172 authored by cq990612's avatar cq990612

优化代码结构

parent 508c9b38
......@@ -2,6 +2,7 @@ package cn.wisenergy.mapper;
import cn.wisenergy.model.app.WorkProject;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
......@@ -22,4 +23,7 @@ public interface WorkProjectMapper extends BaseMapper<WorkProject> {
* @return
*/
List<WorkProject> getProjectsByCriteria(Map<String, Object> map);
List<WorkProject> getProjectsByIds(@Param("ids") List<Integer> ids, @Param("isConclusion") Integer isConclusion);
}
......@@ -57,5 +57,23 @@
</if>
</where>
</select>
<select id="getProjectsByIds" resultType="cn.wisenergy.model.app.WorkProject">
select <include refid="Base_Column_List"/>
from <include refid="table"/>
<where>
<if test="ids != null">
AND id IN
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
</if>
<if test="null !=isConclusion">
AND is_conclusion = #{isConclusion}
</if>
</where>
</select>
</mapper>
......@@ -23,7 +23,7 @@ public interface WorkProjectService {
WorkProject getById(Integer id);
List<WorkProject> getNameById(List<Integer> ids);
List<WorkProject> getNameByIds(List<Integer> ids,Integer isConclusion);
/**
......@@ -31,7 +31,7 @@ public interface WorkProjectService {
* @param id
* @return
*/
List<ProjectDto> getByManagerId(Integer id);
List<ProjectDto> getByManagerId(Integer id,Integer isConclusion);
/**
......
......@@ -69,12 +69,12 @@ public class WorkProjectServiceImpl implements WorkProjectService {
}
@Override
public List<WorkProject> getNameById(List<Integer> ids) {
public List<WorkProject> getNameByIds(List<Integer> ids,Integer isConclusion) {
log.info("WorkProjectServiceImpl[]getNameById[]input.param.ids:" + ids);
if (CollectionUtils.isEmpty(ids)) {
return null;
}
List<WorkProject> workProjects = workProjectMapper.selectBatchIds(ids);
List<WorkProject> workProjects = workProjectMapper.getProjectsByIds(ids, isConclusion);
if (CollectionUtils.isEmpty(workProjects)) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.MANAGER_NOT_PROJECT);
}
......@@ -88,13 +88,14 @@ public class WorkProjectServiceImpl implements WorkProjectService {
* @return dto
*/
@Override
public List<ProjectDto> getByManagerId(Integer id) {
public List<ProjectDto> getByManagerId(Integer id,Integer isConclusion) {
log.info("WorkProjectServiceImpl[]getByManagerId[]input.param.id:" + id);
if (null == id) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL);
}
QueryWrapper<WorkProject> wrapper = new QueryWrapper<>();
wrapper.eq("manager_id", id);
wrapper.eq("is_conclusion", isConclusion);
List<WorkProject> workProjects = workProjectMapper.selectList(wrapper);
if (!CollectionUtils.isEmpty(workProjects)) {
return workProjectToDto(workProjects);
......
......@@ -539,7 +539,7 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
// 2.获取可审批的项目
if (0 != user.getLevel()) {
List<ProjectManagerDto> projectManagerDtos = new ArrayList<>();
List<ProjectDto> projectDtos = workProjectService.getByManagerId(userId);
List<ProjectDto> projectDtos = workProjectService.getByManagerId(userId,1);
if (!CollectionUtils.isEmpty(projectDtos)) {
QueryWrapper<WorkTimeOrder> wrapper = new QueryWrapper<>();
List<Integer> projectIds = new ArrayList<>();
......@@ -600,8 +600,8 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
String deptManagerName = workUserService.getById(workDeptService.getById(deptId).getDeptManagerId()).getName();
// 2.获取可填报的类型
List<ProjectInfoDto> projectList = new ArrayList<>();
List<WorkProject> projects = workProjectService.getNameById(projectIds);
// 3.获取正在进行中的项目/商机
List<WorkProject> projects = workProjectService.getNameByIds(projectIds,1);
ProjectInfoDto projectInfoDto;
for (ProjectTypeEnum value : ProjectTypeEnum.values()) {
projectInfoDto = new ProjectInfoDto().setType(value.getType()).setTypeName(value.getTypeName()).setDeptManagerName(deptManagerName);
......
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