Commit 9b9e48ee by 王力

Merge branch 'dev_mybatisplus_optimize' into 'develop'

Dev mybatisplus optimize

See merge request !125
2 parents 581b1c34 a87f4757
...@@ -3,8 +3,22 @@ package com.dituhui.pea.order.dao; ...@@ -3,8 +3,22 @@ package com.dituhui.pea.order.dao;
import com.dituhui.pea.order.entity.EngineerInfo; import com.dituhui.pea.order.entity.EngineerInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;
@Mapper @Mapper
public interface EngineerInfoMPDao extends BaseMapper<EngineerInfo> { public interface EngineerInfoMPDao extends BaseMapper<EngineerInfo> {
}
@Select("select * from engineer_info where engineer_code = #{engineerCode}")
EngineerInfo getByEngineerCode(String engineerCode);
@Select("select * from engineer_info where engineer_code = #{engineerCode}")
List<EngineerInfo> selectByEngineerCode(String engineerCode);
@Select("select * from engineer_info where engineer_code in #{engineerCodes}")
List<EngineerInfo> selectByEngineerCodes(List<String> engineerCodes);
@Select("select * from engineer_info where group_id = #{groupId}")
List<EngineerInfo> selectByGroupId(String groupId);
}
\ No newline at end of file
...@@ -3,7 +3,16 @@ package com.dituhui.pea.order.dao; ...@@ -3,7 +3,16 @@ package com.dituhui.pea.order.dao;
import com.dituhui.pea.order.entity.OrgGroup; import com.dituhui.pea.order.entity.OrgGroup;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;
@Mapper @Mapper
public interface OrgGroupMPDao extends BaseMapper<OrgGroup> { public interface OrgGroupMPDao extends BaseMapper<OrgGroup> {
@Select("select * from org_group where group_id = #{groupId}")
OrgGroup getByGroupId(String groupId);
@Select("select * from org_group where group_id = #{groupId}")
List<OrgGroup> selectByGroupId(String groupId);
} }
...@@ -206,7 +206,7 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -206,7 +206,7 @@ public class DispatchServiceImpl implements DispatchService {
public Result<?> dispatchOrderConfirm(String engineerCode, List<String> orderIds) throws BusinessException { public Result<?> dispatchOrderConfirm(String engineerCode, List<String> orderIds) throws BusinessException {
// 派工台确认派单 // 派工台确认派单
EngineerInfo engineer = this.queryEngineer(engineerCode); EngineerInfo engineer = engineerInfoMPDao.getByEngineerCode(engineerCode);
if (engineer == null) { if (engineer == null) {
throw new BusinessException("技术员不存在"); throw new BusinessException("技术员不存在");
} }
...@@ -313,12 +313,6 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -313,12 +313,6 @@ public class DispatchServiceImpl implements DispatchService {
return engineerInfoMPDao.selectList(lqw); return engineerInfoMPDao.selectList(lqw);
} }
private EngineerInfo queryEngineer(String engineerCode) {
LambdaQueryWrapper<EngineerInfo> lqw = new LambdaQueryWrapper<>();
lqw.eq(EngineerInfo::getEngineerCode, engineerCode);
return engineerInfoMPDao.selectOne(lqw);
}
private List<String> queryOrgGroupIds(String levelType, List<String> levelIds) { private List<String> queryOrgGroupIds(String levelType, List<String> levelIds) {
LambdaQueryWrapper<OrgGroup> lqw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<OrgGroup> lqw = new LambdaQueryWrapper<>();
lqw.in(levelType.equals("cluster"), OrgGroup::getClusterId, levelIds); lqw.in(levelType.equals("cluster"), OrgGroup::getClusterId, levelIds);
......
...@@ -17,9 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -17,9 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.sql.Timestamp;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -81,7 +79,7 @@ public class EngineerServiceImpl implements EngineerService { ...@@ -81,7 +79,7 @@ public class EngineerServiceImpl implements EngineerService {
// 获取技术员基础信息详情 // 获取技术员基础信息详情
// 获取技术员列表 // 获取技术员列表
List<EngineerInfo> records = this.queryEngineerInfos(engineerCode); List<EngineerInfo> records = engineerInfoMPDao.selectByEngineerCode(engineerCode);
if (records.isEmpty()) { if (records.isEmpty()) {
throw new BusinessException("技术员不存在"); throw new BusinessException("技术员不存在");
} }
...@@ -115,7 +113,7 @@ public class EngineerServiceImpl implements EngineerService { ...@@ -115,7 +113,7 @@ public class EngineerServiceImpl implements EngineerService {
@Override @Override
public Result<?> getEngineerSkillDetail(String engineerCode) throws BusinessException { public Result<?> getEngineerSkillDetail(String engineerCode) throws BusinessException {
// 获取工程师技能详情 // 获取工程师技能详情
List<EngineerInfo> engineers = this.queryEngineerInfos(engineerCode); List<EngineerInfo> engineers = engineerInfoMPDao.selectByEngineerCode(engineerCode);
if (engineers.isEmpty()) { if (engineers.isEmpty()) {
throw new BusinessException("技术员不存在"); throw new BusinessException("技术员不存在");
} }
...@@ -189,7 +187,7 @@ public class EngineerServiceImpl implements EngineerService { ...@@ -189,7 +187,7 @@ public class EngineerServiceImpl implements EngineerService {
@Override @Override
public Result<?> getEngineerBusinessDetail(String engineerCode) { public Result<?> getEngineerBusinessDetail(String engineerCode) {
// 获取技术员业务熟悉详情 // 获取技术员业务熟悉详情
List<EngineerInfo> engineers = this.queryEngineerInfos(engineerCode); List<EngineerInfo> engineers = engineerInfoMPDao.selectByEngineerCode(engineerCode);
if (engineers.isEmpty()) { if (engineers.isEmpty()) {
throw new BusinessException("技术员不存在"); throw new BusinessException("技术员不存在");
} }
...@@ -240,13 +238,6 @@ public class EngineerServiceImpl implements EngineerService { ...@@ -240,13 +238,6 @@ public class EngineerServiceImpl implements EngineerService {
return pg; return pg;
} }
private List<EngineerInfo> queryEngineerInfos(String engineerCode) {
// 分页查询工程师基础信息
LambdaQueryWrapper<EngineerInfo> lqw = new LambdaQueryWrapper<>();
lqw.eq(EngineerInfo::getEngineerCode, engineerCode);
return engineerInfoMPDao.selectList(lqw);
}
private HashMap<String, String> queryGroupNames(List<String> groupIds) { private HashMap<String, String> queryGroupNames(List<String> groupIds) {
//查询小组名称映射关系 //查询小组名称映射关系
HashMap<String, String> map = new HashMap<>(); HashMap<String, String> map = new HashMap<>();
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!