Commit 05f7092d by 张晓

fix 左连查询不对业务业务配置bug

1 parent 978701b5
...@@ -17,10 +17,6 @@ import java.util.List; ...@@ -17,10 +17,6 @@ import java.util.List;
public interface EngineerBusinessDao extends CrudRepository<EngineerBusinessEntity, Long> { public interface EngineerBusinessDao extends CrudRepository<EngineerBusinessEntity, Long> {
@Query("select a from EngineerBusinessEntity a join EngineerInfoEntity o on a.engineerCode=o.engineerCode where o.groupId= :groupId")
List<EngineerBusinessEntity> findByGroupId(String groupId);
@Transactional @Transactional
@Modifying @Modifying
@Query("UPDATE EngineerBusinessEntity tt SET tt.address = :address, tt.X= :x, tt.Y=:y WHERE tt.engineerCode = :engineerCode") @Query("UPDATE EngineerBusinessEntity tt SET tt.address = :address, tt.X= :x, tt.Y=:y WHERE tt.engineerCode = :engineerCode")
......
...@@ -9,6 +9,9 @@ import com.dituhui.pea.order.entity.*; ...@@ -9,6 +9,9 @@ import com.dituhui.pea.order.entity.*;
import com.dituhui.pea.order.service.EngineerBusinessService; import com.dituhui.pea.order.service.EngineerBusinessService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
...@@ -32,17 +35,31 @@ public class EngineerBusinessServiceImpl implements EngineerBusinessService { ...@@ -32,17 +35,31 @@ public class EngineerBusinessServiceImpl implements EngineerBusinessService {
@Autowired @Autowired
private WarehouseInfoDao warehouseInfoDao; private WarehouseInfoDao warehouseInfoDao;
@Autowired
private JdbcTemplate jdbcTemplate;
@Override @Override
public List<EngineerBusinessDTO.Engineer> getEngineerCenterList(EngineerBusinessDTO.Request engineerReq) { public List<EngineerBusinessDTO.Engineer> getEngineerCenterList(EngineerBusinessDTO.Request engineerReq) {
String sql = "select a.engineer_code , b.address, b.x, b.y from engineer_info a left join engineer_business b on a.engineer_code= b.engineer_code\n" +
" where a.group_id=?";
// 创建一个新的BeanPropertyRowMapper对象
RowMapper<EngineerBusinessEntity> rowMapper = new BeanPropertyRowMapper<>(EngineerBusinessEntity.class);
List<EngineerBusinessEntity> engineerEntiryList = this.jdbcTemplate.query(sql, rowMapper, engineerReq.getLevelValue());
Map<String, String> codeNameMap = engineerInfoDao.findByGroupId(engineerReq.getLevelValue()).stream().collect(Collectors.toMap(EngineerInfoEntity::getEngineerCode, EngineerInfoEntity::getName)); Map<String, String> codeNameMap = engineerInfoDao.findByGroupId(engineerReq.getLevelValue()).stream().collect(Collectors.toMap(EngineerInfoEntity::getEngineerCode, EngineerInfoEntity::getName));
return engineerBusinessDao.findByGroupId(engineerReq.getLevelValue()).stream().map(item -> { return engineerEntiryList.stream().map(item -> {
EngineerBusinessDTO.Engineer engineer = new EngineerBusinessDTO.Engineer(); EngineerBusinessDTO.Engineer engineer = new EngineerBusinessDTO.Engineer();
engineer.setEngineerCode(item.getEngineerCode()); engineer.setEngineerCode(item.getEngineerCode());
engineer.setEngineerName(codeNameMap.getOrDefault(item.getEngineerCode(), item.getEngineerCode())); engineer.setEngineerName(codeNameMap.getOrDefault(item.getEngineerCode(), item.getEngineerCode()));
engineer.setAddress(item.getAddress()); engineer.setAddress(item.getAddress() == null ? "" : item.getAddress());
engineer.setLocation(item.getX() + "," + item.getY()); if (item.getX() == null) {
engineer.setLocation("");
} else {
engineer.setLocation(item.getX() + "," + item.getY());
}
return engineer; return engineer;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!