Commit 025ff340 by 丁伟峰

Merge branch 'feature-dingwf-0715' into develop

2 parents c29d74e4 2537d27c
......@@ -18,5 +18,7 @@ public interface OrgTeamDao extends JpaRepository<OrgTeamEntity, Integer> {
Page<OrgTeamEntity> findAllByGroupId(String groupId, Pageable pageable);
Page<OrgTeamEntity> findAllByBranchId(String branchId, Pageable pageable);
OrgTeamEntity getByTeamId(String teamId);
}
......@@ -2,10 +2,17 @@ package com.dituhui.pea.order.dao;
import com.dituhui.pea.order.entity.OrgWarehouseInfoEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
public interface WarehouseInfoDao extends JpaRepository<OrgWarehouseInfoEntity, Long> {
List<OrgWarehouseInfoEntity> getAllByGroupId(String groupId);
// 返回工作队所在的分部所有的配件仓
@Query("select a from OrgWarehouseInfoEntity a join OrgTeamEntity o on a.branchId=o.branchId where o.teamId= :teamId")
List<OrgWarehouseInfoEntity> getAllByTeamId(String teamId);
// 返回工作队关联的配件仓
@Query("select a from OrgWarehouseInfoEntity a join OrgTeamEntity o on a.warehouseId=o.warehouseId where o.teamId= :teamId")
OrgWarehouseInfoEntity getByTeamAssigned(String teamId);
}
......@@ -28,6 +28,11 @@ public class OrgWarehouseInfoEntity {
private String warehouseName;
/**
* 归属分部
*/
private String branchId;
/**
* 归属分站
*/
private String groupId;
......
......@@ -4,7 +4,6 @@ import cn.hutool.core.date.Week;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.dao.*;
import com.dituhui.pea.order.dto.*;
import com.dituhui.pea.order.entity.OrgTeamEngineerEntity;
import com.dituhui.pea.order.entity.OrgTeamEntity;
import com.dituhui.pea.order.entity.OrgWarehouseInfoEntity;
import com.dituhui.pea.order.service.BusinessTeamService;
......@@ -41,36 +40,49 @@ public class BusinessTeamServiceImpl implements BusinessTeamService {
@Override
public Result<?> getTeams(BusinessTeamsDTO.Request req) {
assert "branch".equals(req.getLevelType()) || "group".equals(req.getLevelType());
List<BusinessTeamsDTO.Content> contents = new ArrayList<>();
Pageable pageable = PageRequest.of(req.getPage() - 1, req.getSize());
Page<OrgTeamEntity> page = orgTeamDao.findAllByGroupId(req.getLevelValue(), pageable);
List<String> teamIds = page.getContent().stream().map(OrgTeamEntity::getTeamId).collect(Collectors.toList());
for (OrgTeamEntity e:page.getContent()){
String engineers = orgTeamEngineerDao.findAllByTeamId(e.getTeamId()).stream().map(e2->{
Page<OrgTeamEntity> page = null;
if ("branch".equals(req.getLevelType())){
page = orgTeamDao.findAllByBranchId(req.getLevelValue(), pageable);
} else {
page = orgTeamDao.findAllByGroupId(req.getLevelValue(), pageable);
}
for (OrgTeamEntity e : page.getContent()) {
String engineers = orgTeamEngineerDao.findAllByTeamId(e.getTeamId()).stream().map(e2 -> {
return engineerInfoDao.getByEngineerCode(e2.getEngineerCode()).getName();
}).collect(Collectors.toList()).toString();
BusinessTeamsDTO.Content content = new BusinessTeamsDTO.Content();
content.setTeamId(e.getTeamId()).setTeamName(e.getTeamName());
content.setWorkdays(getWorkdaysChinese(e.getWorkdays()).toString());
content.setEngineers(engineers);
content.setWorkdays(String.join(",", getWorkdaysChinese(e.getWorkdays())));
content.setEngineers(String.join(",", engineers));
// todo 工作队容量
OrgWarehouseInfoEntity warehouse = warehouseInfoDao.getByTeamAssigned(e.getTeamId());
if (warehouse != null){
content.setWarehouseName(warehouse.getWarehouseName());
}
//capacityUse已占容量, capacityRest剩余容量
// ordersNum 当前单数
// pepleMinute 人数/分钟数
contents.add(content);
}
BusinessTeamsDTO.Result rs = new BusinessTeamsDTO.Result();
rs.setContent(contents).setTotal(page.getTotalPages()).setPageSize(page.getSize());
return Result.success(rs);
}
private List<String> getWorkdaysChinese(String workDays){
private List<String> getWorkdaysChinese(String workDays) {
// 将 1,2,3 转换为 周一、周二、周三
return Arrays.stream(workDays.split(",")).map(e->{
return Arrays.stream(workDays.split(",")).map(e -> {
return Week.of(Integer.valueOf(e)).toChinese("周");
}).collect(Collectors.toList());
}
@Override
public Result<?> getWarehouses(BusinessWarehousesDTO.Request req) {
List<OrgWarehouseInfoEntity> warehouseInfoEntityList = warehouseInfoDao.getAllByGroupId(req.getGroupId());
List<OrgWarehouseInfoEntity> warehouseInfoEntityList = warehouseInfoDao.getAllByTeamId(req.getGroupId());
List<BusinessWarehousesDTO.Content> contents = warehouseInfoEntityList.stream().map(entity -> {
BusinessWarehousesDTO.Content dto = new BusinessWarehousesDTO.Content();
dto.setWarehouseId(entity.getWarehouseId());
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!