Commit 8713b158 by chamberone

Merge branch 'develop' of https://zhangguoping@gitlab.dituhui.com/bsh/project/pr…

…oject.git into develop
2 parents 055bc15b 601ac13a
Showing with 482 additions and 227 deletions
......@@ -6,4 +6,8 @@ public class ListUtils {
public static <T> boolean isNotEmpty(List<T> list) {
return list != null && !list.isEmpty();
}
public static <T> boolean isEmpty(List<T> list) {
return list == null || list.isEmpty();
}
}
......@@ -3,7 +3,7 @@ package com.dituhui.pea.order.controller;
import com.dituhui.pea.common.BusinessException;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.dto.CapacityStatQueryDTO;
import com.dituhui.pea.order.service.CapacityQueryService;
import com.dituhui.pea.order.service.OrgCapacityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
......@@ -13,13 +13,13 @@ import org.springframework.web.bind.annotation.*;
public class CapacityController {
@Autowired
private CapacityQueryService capacityQueryService;
private OrgCapacityService orgCapacityService;
@GetMapping("/capacity/query")
public Result<?> capacityQuery(@Validated CapacityStatQueryDTO.Request reqDTO) {
Result<?> res = null;
try {
res = capacityQueryService.getTeamStatData(reqDTO);
res = orgCapacityService.getOrgCapacityData(reqDTO);
} catch (BusinessException e) {
return Result.failed(e.getMessage());
}
......
......@@ -27,4 +27,15 @@ public class PublicController {
}
return res;
}
@GetMapping("/public/skill/tree")
public Result<?> getPublicSkillTree() {
Result<?> res = null;
try {
res = publicService.getSkillTree();
} catch (BusinessException e) {
return Result.failed(e.getMessage());
}
return res;
}
}
package com.dituhui.pea.order.dao;
import com.dituhui.pea.order.entity.SkillInfoEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface SkillInfoDao extends JpaRepository<SkillInfoEntity, Long> {
List<SkillInfoEntity> findAll();
}
package com.dituhui.pea.order.dto;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
public class PublicSkillTreeDTO {
@Data
public static class Result {
private List<Content> content;
}
@Data
@Accessors(chain = true)
public static class Content {
private String brand;
private String skill;
private String type;
}
}
package com.dituhui.pea.order.entity;
import lombok.Data;
import javax.persistence.*;
import java.time.LocalDateTime;
@Data
@Entity
@Table(name = "engineer_skill_group")
public class EngineerSkillGroupEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(name = "engineer_code", length = 32, nullable = false)
private String engineerCode;
@Column(name = "skill_group_code", length = 50, nullable = false)
private String skillGroupCode;
@Column(length = 50, nullable = false)
private String description;
@Column(name = "bean_status", nullable = false)
private Boolean beanStatus;
@Column(nullable = false)
private Boolean status;
@Column(length = 100, nullable = false)
private String memo;
@Column(name = "create_time", nullable = false, columnDefinition = "timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
private LocalDateTime createTime;
@Column(name = "update_time", nullable = false, columnDefinition = "timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
private LocalDateTime updateTime;
// Getters and Setters
// ...
}
......@@ -3,88 +3,59 @@ package com.dituhui.pea.order.entity;
import lombok.Data;
import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
@Entity
@Data
@Table(name="map_block_Info")
@Entity
@Table(name = "map_block_info")
public class MapBlockInfoEntity {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
/**
* 主键
*/
private Integer id;
/**
* 区块id
*/
@Column(name = "block_id", length = 50, nullable = false)
private String blockId;
/**
* 区块名称
*/
@Column(name = "block_name", length = 20, nullable = false)
private String blockName;
/**
* 归属分部
*/
@Column(name = "subsection_id", length = 50, nullable = false)
private String subsectionId;
/**
* 归属小组
*/
@Column(name = "group_id", length = 50, nullable = false)
private String groupId;
/**
* 所在城市id
*/
@Column(name = "city_code", nullable = false)
private String cityCode;
/**
* 面数据
*/
@Column(name = "area_data", nullable = false, columnDefinition = "json")
private String areaData;
/**
* 类型(1自然行政片区,2自定义片区)
*/
private Integer kind;
@Column(nullable = false)
private Boolean kind;
/**
* 关联小队id
*/
@Column(name = "team_id", length = 50, nullable = false)
private String teamId;
/**
* 图标标签,[基础图层,ggn] -- 与map_layer.layer 对应
*/
@Column(name = "layer_id", length = 50, nullable = false)
private String layerId;
@Column(length = 50, nullable = false)
private String layer;
/**
* 状态(0无效 1有效)
*/
private Integer status;
@Column(nullable = false)
private Boolean status;
/**
* 备注
*/
@Column(length = 100, nullable = false)
private String memo;
/**
* 创建时间
*/
@Column(name = "create_time", nullable = false, columnDefinition = "datetime DEFAULT CURRENT_TIMESTAMP")
private LocalDateTime createTime;
/**
* 更新时间
*/
@Column(name = "update_time", nullable = false, columnDefinition = "datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
private LocalDateTime updateTime;
public MapBlockInfoEntity() {}
// Getters and Setters
// ...
}
......@@ -6,107 +6,74 @@ import javax.persistence.*;
import java.time.LocalDate;
import java.time.LocalDateTime;
import javax.persistence.*;
@Data
@Entity
@Table(name="order_appointment")
@Table(name = "order_appointment")
public class OrderAppointmentEntity {
/**
* 自增id
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
/**
* 服务单id
*/
@Column(name = "order_id", nullable = false)
private String orderId;
/**
* 子工单id
*/
@Column(name = "suborder_id", nullable = false)
private String suborderId;
/**
* 多人单标识(1主单 2副单)
*/
private Integer mainSub;
@Column(name = "main_sub", nullable = false)
private Boolean mainSub;
/**
* 工程师工号
*/
@Column(name = "engineer_code", nullable = false)
private String engineerCode;
/**
* 工程师姓名
*/
@Column(name = "engineer_name", nullable = false)
private String engineerName;
/**
* 工程师电话(快照)
*/
@Column(name = "engineer_phone", nullable = false)
private String engineerPhone;
/**
* 工程师年龄(快照)
*/
@Column(name = "engineer_age", nullable = false)
private Integer engineerAge;
/**
* 是否车间单(0否 1是)
*/
private Integer isWorkshop;
@Column(name = "is_workshop", nullable = false)
private Boolean isWorkshop;
/**
* 预约日期
*/
@Column
private LocalDate dt;
/**
* 客户预约上门时间
*/
@Column(name = "expect_start_time")
private LocalDateTime expectStartTime;
@Column(name = "expect_end_time")
private LocalDateTime expectEndTime;
/**
* 实际上门时间
*/
@Column(name = "actual_time")
private LocalDateTime actualTime;
/**
* 开始服务时间
*/
@Column(name = "actual_start_time")
private LocalDateTime actualStartTime;
/**
* 结束服务时间
*/
@Column(name = "actual_end_time")
private LocalDateTime actualEndTime;
/**
* pre-预排班/confirm-已确认
*/
@Column(name = "pre_status")
private String preStatus;
/**
* bean预约单状态(pre-预指派/虚拟指派 contact-已联系 depart-已出发 start-已开始 finish-已完成 undone-已上门未完成 reschedule-已改约)
*/
@Column(nullable = false)
private String status;
/**
* 备注
*/
@Column(length = 100, nullable = false)
private String memo;
/**
* 创建时间
*/
@Column(name = "create_time", nullable = false, columnDefinition = "timestamp DEFAULT CURRENT_TIMESTAMP")
private LocalDateTime createTime;
/**
* 更新时间
*/
@Column(name = "update_time", nullable = false, columnDefinition = "timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
private LocalDateTime updateTime;
// Getters and Setters
// ...
}
/*
* Copyright 2013-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.dituhui.pea.order.entity;
import lombok.Data;
......@@ -22,50 +6,132 @@ import javax.persistence.*;
import java.time.LocalDate;
import java.time.LocalDateTime;
@Entity
@Data
@Table(name="order_request")
@Entity
@Table(name = "order_request")
public class OrderRequestEntity {
@Id
private String id;
@Column(name = "order_id", nullable = false)
private String orderId;
@Column(nullable = false)
private LocalDate dt;
@Column(nullable = false)
private String name;
@Column(nullable = false)
private String phone;
@Column(nullable = false)
private String address;
@Column(nullable = false)
private String x;
@Column(nullable = false)
private String y;
@Column
private String province;
@Column
private String city;
@Column
private String county;
@Column(name = "category_id", nullable = false)
private String categoryId;
@Column(nullable = false)
private String brand;
@Column(nullable = false)
private String type;
@Column(nullable = false)
private String skill;
@Column(name = "apply_note")
private String applyNote;
@Column(name = "fault_describe")
private String faultDescribe;
private LocalDate dt;
@Column(name = "expect_time_begin", nullable = false, columnDefinition = "timestamp DEFAULT CURRENT_TIMESTAMP")
private LocalDateTime expectTimeBegin;
@Column(name = "expect_time_end")
private LocalDateTime expectTimeEnd;
@Column(name = "expect_time_desc")
private String expectTimeDesc;
@Column
private String source;
@Column(name = "area_id")
private String areaId;
@Column(name = "order_priority")
private String orderPriority;
@Column(name = "order_tags")
private String orderTags;
@Column
private Integer priority;
@Column
private String tags;
@Column(nullable = false)
private String status;
@Column(name = "appointment_status", nullable = false)
private String appointmentStatus;
@Column(name = "appointment_method", nullable = false)
private String appointmentMethod;
@Column(name = "org_cluster_id")
private String orgClusterId;
@Column(name = "org_cluster_name")
private String orgClusterName;
@Column(name = "org_branch_id")
private String orgBranchId;
@Column(name = "org_branch_name")
private String orgBranchName;
@Column(name = "org_group_id")
private String orgGroupId;
@Column(name = "org_group_name")
private String orgGroupName;
@Column(name = "org_team_id")
private String orgTeamId;
@Column(name = "org_team_name")
private String orgTeamName;
@Column
private String description;
@Column(name = "create_time", nullable = false, columnDefinition = "timestamp DEFAULT CURRENT_TIMESTAMP")
private LocalDateTime createTime;
@Column(name = "update_time", nullable = false, columnDefinition = "timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
private LocalDateTime updateTime;
// Getters and Setters
// ...
}
package com.dituhui.pea.order.entity;
import lombok.Data;
import javax.persistence.*;
import java.time.LocalDateTime;
@Data
@Entity
@Table(name = "skill_group")
public class SkillGroupEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(name = "skill_group_code", length = 50, nullable = false)
private String skillGroupCode;
@Column(name = "skill_group", length = 50, nullable = false)
private String skillGroup;
@Column(length = 50, nullable = false)
private String description;
@Column(length = 20, nullable = false)
private String category;
@Column(length = 100, nullable = false)
private String memo;
@Column(name = "create_time", nullable = false, columnDefinition = "datetime DEFAULT CURRENT_TIMESTAMP")
private LocalDateTime createTime;
@Column(name = "update_time", nullable = false, columnDefinition = "datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
private LocalDateTime updateTime;
// Getters and Setters
// ...
}
package com.dituhui.pea.order.entity;
import lombok.Data;
import javax.persistence.*;
import java.time.LocalDateTime;
@Data
@Entity
@Table(name = "skill_info")
public class SkillInfoEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(name = "skill_code", length = 32, nullable = false)
private String skillCode;
@Column(length = 20, nullable = false)
private String brand;
@Column(length = 20, nullable = false)
private String type;
@Column(length = 20, nullable = false)
private String skill;
@Column(name = "take_time", nullable = false)
private Integer takeTime;
@Column(name = "take_engineer", nullable = false)
private Integer takeEngineer;
@Column(name = "low_electrician_cert", nullable = false)
private Boolean lowElectricianCert;
@Column(name = "gas_cert", nullable = false)
private Boolean gasCert;
@Column(nullable = false)
private Integer priority;
@Column(name = "skill_group_code", length = 50)
private String skillGroupCode;
@Column(name = "layer_id", length = 32)
private String layerId;
@Column(name = "type_category", length = 50)
private String typeCategory;
@Column(name = "skill_category", length = 50)
private String skillCategory;
@Column(length = 100, nullable = false)
private String memo;
@Column(name = "create_time", nullable = false, columnDefinition = "datetime DEFAULT CURRENT_TIMESTAMP")
private LocalDateTime createTime;
@Column(name = "update_time", nullable = false, columnDefinition = "datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
private LocalDateTime updateTime;
// Getters and Setters
// ...
}
......@@ -6,14 +6,5 @@ import com.dituhui.pea.order.dto.CapacityStatQueryDTO;
import com.fasterxml.jackson.core.JsonProcessingException;
public interface CapacityQueryService {
/**
* 单条容量查询
* @param capacityQueryReqDTO
* @return
* @throws JsonProcessingException
*/
Result<?> getOneCapacityData(CapacityOrderQueryDTO.Request capacityQueryReqDTO);
Result<?> getTeamStatData(CapacityStatQueryDTO.Request capacityStatQueryReqDTO);
}
package com.dituhui.pea.order.service;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.dto.CapacityStatQueryDTO;
public interface OrgCapacityService {
Result<?> getOrgCapacityData(CapacityStatQueryDTO.Request capacityStatQueryReqDTO);
}
......@@ -4,4 +4,6 @@ import com.dituhui.pea.common.Result;
public interface PublicService {
Result<?> getPublicParameter();
Result<?> getSkillTree();
}
......@@ -73,69 +73,6 @@ public class CapacityQueryServiceImpl implements CapacityQueryService {
return legends;
}
@Override
public Result<?> getTeamStatData(CapacityStatQueryDTO.Request reqDTO) {
// 根据大区/分部/分站查询,分别返回分部/分站/工作队的容量
Page<?> stats = null;
Pageable pageable = PageRequest.of(reqDTO.getPage() - 1, reqDTO.getSize());
Map<String, String> names = null;
String levelType = reqDTO.getLevelType();
String levelValue = reqDTO.getLevelValue();
if ("cluster".equals(levelType)) {
names = orgBranchDao.findAllByClusterId(levelValue).stream()
.collect(Collectors.toMap(OrgBranchEntity::getBranchId, OrgBranchEntity::getBranchName));
;
List<String> branchIds = new ArrayList<>(names.keySet());
log.info("levelType: {} ==> branchIds: {}", levelType, branchIds);
stats = capacityOrgStatDao.findByBranchIdsAndWorkdayBetween(branchIds, reqDTO.getStartDate(), reqDTO.getEndDate(), pageable);
} else if ("branch".equals(reqDTO.getLevelType())) {
names = orgGroupDao.findAllByBranchId(levelValue).stream()
.collect(Collectors.toMap(OrgGroupEntity::getGroupId, OrgGroupEntity::getGroupName));
List<String> groupIds = new ArrayList<>(names.keySet());
log.info("levelType: {} ==> groupIds: {}", levelType, groupIds);
stats = capacityOrgStatDao.findByGroupIdsAndWorkdayBetween(groupIds, reqDTO.getStartDate(), reqDTO.getEndDate(), pageable);
} else {
names = orgTeamDao.findAllByGroupId(levelValue).stream()
.collect(Collectors.toMap(OrgTeamEntity::getTeamId, OrgTeamEntity::getTeamName));
List<String> teamIds = new ArrayList<>(names.keySet());
log.info("levelType: {} ==> teamIds: {}", levelType, teamIds);
stats = capacityTeamStatDao.findByTeamIdsAndWorkdayBetween(teamIds, reqDTO.getStartDate(), reqDTO.getEndDate(), pageable);
}
CapacityStatQueryDTO.Result rs = new CapacityStatQueryDTO.Result();
rs.setLevelType(levelType);
rs.setTotal(stats.getTotalElements()).setPages(stats.getTotalPages()).setPageSize(pageable.getPageSize()).setPageCurrent(stats.getNumber());
List<CapacityStatQueryDTO.Content> contents = new ArrayList<>();
for (Object item : stats.getContent()) {
CapacityStatQueryDTO.Content content = new CapacityStatQueryDTO.Content();
if (item instanceof CapacityOrgStatEntity) {
// cluster/branch查询,都是capacity_org_stat
CapacityOrgStatEntity e = (CapacityOrgStatEntity) item;
content.setLevelType(e.getType()).setLevelValue(e.getOrgId());
content.setShowName(names.get(e.getOrgId()));
content.setDate(e.getWorkday()).setLayer(e.getLayer())
.setCapTotal(e.getCapTotal()).setCapUsed(e.getCapUsedTotal())
.setEngineerNum(e.getEngineerCount()).setUpdateTime(e.getUpdateTime());
} else {
// group查询,是capacity_team_stat
CapacityTeamStatEntity e = (CapacityTeamStatEntity) item;
// capacity_team_stat表中的team_id,直接就是字符串
content.setLevelType("team").setLevelValue(e.getTeamId());
content.setShowName(names.get(e.getTeamId()));
content.setDate(e.getWorkday()).setLayer(e.getLayer()).setShowName(e.getTeamId())
.setCapTotal(e.getCapTotal()).setCapUsed(e.getCapUsed()).setCapAdjust(e.getCapAdjust())
.setEngineerNum(e.getEngineerCount()).setUpdateTime(e.getUpdateTime());
}
contents.add(content);
}
contents.stream().sorted(
Comparator.comparing(CapacityStatQueryDTO.Content::getDate)).collect(Collectors.toList());
rs.setContent(contents);
return Result.success(rs);
}
private int getSpanType(int capLeft, int capTotal) {
float ratio = (float) capLeft / capTotal;
if (ratio < 0.3) {
......
......@@ -46,12 +46,11 @@ public class DispatchServiceImpl implements DispatchService {
private EngineerInfoMPDao engineerInfoMPDao;
@Autowired
private ProductCategoryMPDao productCategoryMPDao;
private SkillInfoMPDao skillInfoMPDao;
@Autowired
private CapacityEngineerStatMPDao capacityEngineerStatMPDao;
@Transactional
@Override
public Result<?> getDispatchOrderList(DispatchOrderListReq reqDTO) {
......@@ -140,8 +139,11 @@ public class DispatchServiceImpl implements DispatchService {
}
// 获取服务单/工单列表
Map<String, List<OrderRequest>> orders = this.queryOrderRequestByOrderIds(new ArrayList<>(orderIds)).stream().collect(
Collectors.groupingBy(OrderRequest::getOrderId));
Map<String, List<OrderRequest>> orders = new HashMap<>();
if(!orderIds.isEmpty()) {
orders = orderRequestMPDao.selectByOrderIds(new ArrayList<>(orderIds)).stream().collect(
Collectors.groupingBy(OrderRequest::getOrderId));
}
// 获取技术员已指派单列表
List<DispatchEngineerOrderListResp.EngineerInfo> egs = new ArrayList<>();
......@@ -152,12 +154,14 @@ public class DispatchServiceImpl implements DispatchService {
// 技术员已指派的订单列表
List<OrderAppointment> records = engineerOrders.getOrDefault(e.getEngineerCode(), new ArrayList<>());
for (OrderAppointment r : records) {
DispatchEngineerOrderListResp.OrderInfo item = new DispatchEngineerOrderListResp.OrderInfo();
// 获取对应的工单信息
if (ListUtils.isEmpty(orders.get(r.getOrderId()))){
continue;
}
OrderRequest o = orders.get(r.getOrderId()).get(0);
DispatchEngineerOrderListResp.OrderInfo item = new DispatchEngineerOrderListResp.OrderInfo();
item.setOrderId(r.getOrderId());
item.setCategory(String.format("%s-%s", o.getType(), o.getBrand()));
item.setSkill(o.getSkill());
......@@ -217,7 +221,7 @@ public class DispatchServiceImpl implements DispatchService {
throw new BusinessException("技术员不存在");
}
List<OrderRequest> orders = this.queryOrderRequestByOrderIds(orderIds);
List<OrderRequest> orders = orderRequestMPDao.selectByOrderIds(orderIds);
if (orders.isEmpty()) {
throw new BusinessException("订单号错误");
}
......@@ -297,16 +301,6 @@ public class DispatchServiceImpl implements DispatchService {
return orderRequestMPDao.selectList(lqw);
}
private List<OrderRequest> queryOrderRequestByOrderIds(List<String> orderIds) {
List<OrderRequest> orders = new ArrayList<>();
if (orderIds.isEmpty()) {
return orders;
}
LambdaQueryWrapper<OrderRequest> lqw = new LambdaQueryWrapper<>();
lqw.in(OrderRequest::getOrderId, orderIds);
return orderRequestMPDao.selectList(lqw);
}
private Map<String, List<OrderAppointment>> queryEngineerOrders(List<String> engineerCodes, String date) {
// 获取工程师服务单列表
......@@ -360,8 +354,8 @@ public class DispatchServiceImpl implements DispatchService {
private HashMap<String, Integer> querySkillTakeTime() {
HashMap<String, Integer> map = new HashMap<>();
List<ProductCategory> records = productCategoryMPDao.selectList(null);
for (ProductCategory r : records) {
List<SkillInfo> records = skillInfoMPDao.selectList(null);
for (SkillInfo r : records) {
String key = String.format("%s%s%sd", r.getBrand(), r.getType(), r.getSkill());
map.put(key, r.getTakeTime());
}
......
......@@ -155,9 +155,7 @@ public class EngineerServiceImpl implements EngineerService {
Set<String> sInput = new HashSet<>(skillGroupIds);
Set<String> sDB = new HashSet<>(engineerSkills.getOrDefault(engineerCode, new ArrayList<>()));
log.info("before sInput:{}, sDB:{}", sInput, sDB);
sInput.removeAll(sDB);
log.info("after sInput:{}", sInput);
for (String skillGroupId : sInput) {
EngineerSkillGroup e = new EngineerSkillGroup();
e.setEngineerCode(engineerCode);
......
package com.dituhui.pea.order.service.impl;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.dao.*;
import com.dituhui.pea.order.dto.CapacityStatQueryDTO;
import com.dituhui.pea.order.entity.*;
import com.dituhui.pea.order.service.OrgCapacityService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
@Slf4j
public class OrgCapacityServiceImpl implements OrgCapacityService {
@Autowired
private OrgGroupDao orgGroupDao;
@Autowired
private OrgTeamDao orgTeamDao;
@Autowired
private CapacityOrgStatDao capacityOrgStatDao;
@Autowired
private OrgBranchDao orgBranchDao;
@Autowired
private CapacityTeamStatDao capacityTeamStatDao;
@Override
public Result<?> getOrgCapacityData(CapacityStatQueryDTO.Request reqDTO) {
// 根据大区/分部/分站查询,分别返回分部/分站/工作队的容量
Page<?> stats = null;
Pageable pageable = PageRequest.of(reqDTO.getPage() - 1, reqDTO.getSize());
Map<String, String> names = null;
String levelType = reqDTO.getLevelType();
String levelValue = reqDTO.getLevelValue();
if ("cluster".equals(levelType)) {
names = orgBranchDao.findAllByClusterId(levelValue).stream()
.collect(Collectors.toMap(OrgBranchEntity::getBranchId, OrgBranchEntity::getBranchName));
;
List<String> branchIds = new ArrayList<>(names.keySet());
log.info("levelType: {} ==> branchIds: {}", levelType, branchIds);
stats = capacityOrgStatDao.findByBranchIdsAndWorkdayBetween(branchIds, reqDTO.getStartDate(), reqDTO.getEndDate(), pageable);
} else if ("branch".equals(reqDTO.getLevelType())) {
names = orgGroupDao.findAllByBranchId(levelValue).stream()
.collect(Collectors.toMap(OrgGroupEntity::getGroupId, OrgGroupEntity::getGroupName));
List<String> groupIds = new ArrayList<>(names.keySet());
log.info("levelType: {} ==> groupIds: {}", levelType, groupIds);
stats = capacityOrgStatDao.findByGroupIdsAndWorkdayBetween(groupIds, reqDTO.getStartDate(), reqDTO.getEndDate(), pageable);
} else {
names = orgTeamDao.findAllByGroupId(levelValue).stream()
.collect(Collectors.toMap(OrgTeamEntity::getTeamId, OrgTeamEntity::getTeamName));
List<String> teamIds = new ArrayList<>(names.keySet());
log.info("levelType: {} ==> teamIds: {}", levelType, teamIds);
stats = capacityTeamStatDao.findByTeamIdsAndWorkdayBetween(teamIds, reqDTO.getStartDate(), reqDTO.getEndDate(), pageable);
}
CapacityStatQueryDTO.Result rs = new CapacityStatQueryDTO.Result();
rs.setLevelType(levelType);
rs.setTotal(stats.getTotalElements()).setPages(stats.getTotalPages()).setPageSize(pageable.getPageSize()).setPageCurrent(stats.getNumber());
List<CapacityStatQueryDTO.Content> contents = new ArrayList<>();
for (Object item : stats.getContent()) {
CapacityStatQueryDTO.Content content = new CapacityStatQueryDTO.Content();
if (item instanceof CapacityOrgStatEntity) {
// cluster/branch查询,都是capacity_org_stat
CapacityOrgStatEntity e = (CapacityOrgStatEntity) item;
content.setLevelType(e.getType()).setLevelValue(e.getOrgId());
content.setShowName(names.get(e.getOrgId()));
content.setDate(e.getWorkday()).setLayer(e.getLayer())
.setCapTotal(e.getCapTotal()).setCapUsed(e.getCapUsedTotal())
.setEngineerNum(e.getEngineerCount()).setUpdateTime(e.getUpdateTime());
} else {
// group查询,是capacity_team_stat
CapacityTeamStatEntity e = (CapacityTeamStatEntity) item;
// capacity_team_stat表中的team_id,直接就是字符串
content.setLevelType("team").setLevelValue(e.getTeamId());
content.setShowName(names.get(e.getTeamId()));
content.setDate(e.getWorkday()).setLayer(e.getLayer()).setShowName(e.getTeamId())
.setCapTotal(e.getCapTotal()).setCapUsed(e.getCapUsed()).setCapAdjust(e.getCapAdjust())
.setEngineerNum(e.getEngineerCount()).setUpdateTime(e.getUpdateTime());
}
contents.add(content);
}
contents.stream().sorted(
Comparator.comparing(CapacityStatQueryDTO.Content::getDate)).collect(Collectors.toList());
rs.setContent(contents);
return Result.success(rs);
}
}
......@@ -2,8 +2,11 @@ package com.dituhui.pea.order.service.impl;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.dao.PubParamsDao;
import com.dituhui.pea.order.dao.SkillInfoDao;
import com.dituhui.pea.order.dto.PubParameterDTO;
import com.dituhui.pea.order.dto.PublicSkillTreeDTO;
import com.dituhui.pea.order.entity.PubParamsEntity;
import com.dituhui.pea.order.entity.SkillInfoEntity;
import com.dituhui.pea.order.service.PublicService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -12,6 +15,7 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
@Slf4j
@Service
......@@ -20,6 +24,9 @@ public class PublicServiceImpl implements PublicService {
@Autowired
private PubParamsDao pubParamsDao;
@Autowired
private SkillInfoDao skillInfoDao;
@Override
public Result<?> getPublicParameter() {
List<PubParameterDTO.Enum> enums = new ArrayList<>();
......@@ -42,6 +49,19 @@ public class PublicServiceImpl implements PublicService {
return Result.success(rs);
}
@Override
public Result<?> getSkillTree() {
List<PublicSkillTreeDTO.Content> contents = skillInfoDao.findAll().stream().map(entity -> {
return new PublicSkillTreeDTO.Content()
.setBrand(entity.getBrand())
.setType(entity.getType())
.setSkill(entity.getSkill());
}).collect(Collectors.toList());
PublicSkillTreeDTO.Result rs = new PublicSkillTreeDTO.Result();
rs.setContent(contents);
return Result.success(rs);
}
private HashMap<String, String> getMapping() {
String[] pairs = {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!