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 { ...@@ -6,4 +6,8 @@ public class ListUtils {
public static <T> boolean isNotEmpty(List<T> list) { public static <T> boolean isNotEmpty(List<T> list) {
return list != null && !list.isEmpty(); 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; ...@@ -3,7 +3,7 @@ package com.dituhui.pea.order.controller;
import com.dituhui.pea.common.BusinessException; import com.dituhui.pea.common.BusinessException;
import com.dituhui.pea.common.Result; import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.dto.CapacityStatQueryDTO; 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.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -13,13 +13,13 @@ import org.springframework.web.bind.annotation.*; ...@@ -13,13 +13,13 @@ import org.springframework.web.bind.annotation.*;
public class CapacityController { public class CapacityController {
@Autowired @Autowired
private CapacityQueryService capacityQueryService; private OrgCapacityService orgCapacityService;
@GetMapping("/capacity/query") @GetMapping("/capacity/query")
public Result<?> capacityQuery(@Validated CapacityStatQueryDTO.Request reqDTO) { public Result<?> capacityQuery(@Validated CapacityStatQueryDTO.Request reqDTO) {
Result<?> res = null; Result<?> res = null;
try { try {
res = capacityQueryService.getTeamStatData(reqDTO); res = orgCapacityService.getOrgCapacityData(reqDTO);
} catch (BusinessException e) { } catch (BusinessException e) {
return Result.failed(e.getMessage()); return Result.failed(e.getMessage());
} }
......
...@@ -27,4 +27,15 @@ public class PublicController { ...@@ -27,4 +27,15 @@ public class PublicController {
} }
return res; 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; ...@@ -3,88 +3,59 @@ package com.dituhui.pea.order.entity;
import lombok.Data; import lombok.Data;
import javax.persistence.*; import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Date;
@Entity
@Data @Data
@Table(name="map_block_Info") @Entity
@Table(name = "map_block_info")
public class MapBlockInfoEntity { public class MapBlockInfoEntity {
private static final long serialVersionUID = 1L;
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
/**
* 主键
*/
private Integer id; private Integer id;
/** @Column(name = "block_id", length = 50, nullable = false)
* 区块id
*/
private String blockId; private String blockId;
/** @Column(name = "block_name", length = 20, nullable = false)
* 区块名称
*/
private String blockName; private String blockName;
/** @Column(name = "subsection_id", length = 50, nullable = false)
* 归属分部
*/
private String subsectionId; private String subsectionId;
/** @Column(name = "group_id", length = 50, nullable = false)
* 归属小组
*/
private String groupId; private String groupId;
/** @Column(name = "city_code", nullable = false)
* 所在城市id
*/
private String cityCode; private String cityCode;
/** @Column(name = "area_data", nullable = false, columnDefinition = "json")
* 面数据
*/
private String areaData; private String areaData;
/** @Column(nullable = false)
* 类型(1自然行政片区,2自定义片区) private Boolean kind;
*/
private Integer kind;
/** @Column(name = "team_id", length = 50, nullable = false)
* 关联小队id
*/
private String teamId; private String teamId;
/** @Column(name = "layer_id", length = 50, nullable = false)
* 图标标签,[基础图层,ggn] -- 与map_layer.layer 对应 private String layerId;
*/
@Column(length = 50, nullable = false)
private String layer; private String layer;
/** @Column(nullable = false)
* 状态(0无效 1有效) private Boolean status;
*/
private Integer status;
/** @Column(length = 100, nullable = false)
* 备注
*/
private String memo; private String memo;
/** @Column(name = "create_time", nullable = false, columnDefinition = "datetime DEFAULT CURRENT_TIMESTAMP")
* 创建时间
*/
private LocalDateTime createTime; private LocalDateTime createTime;
/** @Column(name = "update_time", nullable = false, columnDefinition = "datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
* 更新时间
*/
private LocalDateTime updateTime; private LocalDateTime updateTime;
public MapBlockInfoEntity() {} // Getters and Setters
// ...
} }
...@@ -6,107 +6,74 @@ import javax.persistence.*; ...@@ -6,107 +6,74 @@ import javax.persistence.*;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import javax.persistence.*;
@Data @Data
@Entity @Entity
@Table(name="order_appointment") @Table(name = "order_appointment")
public class OrderAppointmentEntity { public class OrderAppointmentEntity {
/**
* 自增id
*/
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id; private Integer id;
/** @Column(name = "order_id", nullable = false)
* 服务单id
*/
private String orderId; private String orderId;
/** @Column(name = "suborder_id", nullable = false)
* 子工单id
*/
private String suborderId; private String suborderId;
/** @Column(name = "main_sub", nullable = false)
* 多人单标识(1主单 2副单) private Boolean mainSub;
*/
private Integer mainSub;
/** @Column(name = "engineer_code", nullable = false)
* 工程师工号
*/
private String engineerCode; private String engineerCode;
/** @Column(name = "engineer_name", nullable = false)
* 工程师姓名
*/
private String engineerName; private String engineerName;
/** @Column(name = "engineer_phone", nullable = false)
* 工程师电话(快照)
*/
private String engineerPhone; private String engineerPhone;
/** @Column(name = "engineer_age", nullable = false)
* 工程师年龄(快照)
*/
private Integer engineerAge; private Integer engineerAge;
/** @Column(name = "is_workshop", nullable = false)
* 是否车间单(0否 1是) private Boolean isWorkshop;
*/
private Integer isWorkshop;
/** @Column
* 预约日期
*/
private LocalDate dt; private LocalDate dt;
/** @Column(name = "expect_start_time")
* 客户预约上门时间
*/
private LocalDateTime expectStartTime; private LocalDateTime expectStartTime;
@Column(name = "expect_end_time")
private LocalDateTime expectEndTime; private LocalDateTime expectEndTime;
/**
* 实际上门时间 @Column(name = "actual_time")
*/
private LocalDateTime actualTime; private LocalDateTime actualTime;
/** @Column(name = "actual_start_time")
* 开始服务时间
*/
private LocalDateTime actualStartTime; private LocalDateTime actualStartTime;
/** @Column(name = "actual_end_time")
* 结束服务时间
*/
private LocalDateTime actualEndTime; private LocalDateTime actualEndTime;
/** @Column(name = "pre_status")
* pre-预排班/confirm-已确认
*/
private String preStatus; private String preStatus;
/** @Column(nullable = false)
* bean预约单状态(pre-预指派/虚拟指派 contact-已联系 depart-已出发 start-已开始 finish-已完成 undone-已上门未完成 reschedule-已改约)
*/
private String status; private String status;
/** @Column(length = 100, nullable = false)
* 备注
*/
private String memo; private String memo;
/** @Column(name = "create_time", nullable = false, columnDefinition = "timestamp DEFAULT CURRENT_TIMESTAMP")
* 创建时间
*/
private LocalDateTime createTime; private LocalDateTime createTime;
/** @Column(name = "update_time", nullable = false, columnDefinition = "timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
* 更新时间
*/
private LocalDateTime updateTime; 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; package com.dituhui.pea.order.entity;
import lombok.Data; import lombok.Data;
...@@ -22,50 +6,132 @@ import javax.persistence.*; ...@@ -22,50 +6,132 @@ import javax.persistence.*;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@Entity
@Data @Data
@Table(name="order_request") @Entity
@Table(name = "order_request")
public class OrderRequestEntity { public class OrderRequestEntity {
@Id @Id
private String id; private String id;
@Column(name = "order_id", nullable = false)
private String orderId; private String orderId;
@Column(nullable = false)
private LocalDate dt;
@Column(nullable = false)
private String name; private String name;
@Column(nullable = false)
private String phone; private String phone;
@Column(nullable = false)
private String address; private String address;
@Column(nullable = false)
private String x; private String x;
@Column(nullable = false)
private String y; private String y;
@Column
private String province; private String province;
@Column
private String city; private String city;
@Column
private String county; private String county;
@Column(name = "category_id", nullable = false)
private String categoryId; private String categoryId;
@Column(nullable = false)
private String brand; private String brand;
@Column(nullable = false)
private String type; private String type;
@Column(nullable = false)
private String skill; private String skill;
@Column(name = "apply_note")
private String applyNote; private String applyNote;
@Column(name = "fault_describe")
private String faultDescribe; private String faultDescribe;
private LocalDate dt;
@Column(name = "expect_time_begin", nullable = false, columnDefinition = "timestamp DEFAULT CURRENT_TIMESTAMP")
private LocalDateTime expectTimeBegin; private LocalDateTime expectTimeBegin;
@Column(name = "expect_time_end")
private LocalDateTime expectTimeEnd; private LocalDateTime expectTimeEnd;
@Column(name = "expect_time_desc")
private String expectTimeDesc; private String expectTimeDesc;
@Column
private String source; private String source;
@Column(name = "area_id")
private String areaId; private String areaId;
@Column(name = "order_priority")
private String orderPriority; private String orderPriority;
@Column(name = "order_tags")
private String orderTags; private String orderTags;
@Column
private Integer priority; private Integer priority;
@Column
private String tags; private String tags;
@Column(nullable = false)
private String status; private String status;
@Column(name = "appointment_status", nullable = false)
private String appointmentStatus; private String appointmentStatus;
@Column(name = "appointment_method", nullable = false)
private String appointmentMethod; private String appointmentMethod;
@Column(name = "org_cluster_id")
private String orgClusterId; private String orgClusterId;
@Column(name = "org_cluster_name")
private String orgClusterName; private String orgClusterName;
@Column(name = "org_branch_id")
private String orgBranchId; private String orgBranchId;
@Column(name = "org_branch_name")
private String orgBranchName; private String orgBranchName;
@Column(name = "org_group_id")
private String orgGroupId; private String orgGroupId;
@Column(name = "org_group_name")
private String orgGroupName; private String orgGroupName;
@Column(name = "org_team_id")
private String orgTeamId; private String orgTeamId;
@Column(name = "org_team_name")
private String orgTeamName; private String orgTeamName;
@Column
private String description; private String description;
@Column(name = "create_time", nullable = false, columnDefinition = "timestamp DEFAULT CURRENT_TIMESTAMP")
private LocalDateTime createTime; private LocalDateTime createTime;
@Column(name = "update_time", nullable = false, columnDefinition = "timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
private LocalDateTime updateTime; 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; ...@@ -6,14 +6,5 @@ import com.dituhui.pea.order.dto.CapacityStatQueryDTO;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
public interface CapacityQueryService { public interface CapacityQueryService {
/**
* 单条容量查询
* @param capacityQueryReqDTO
* @return
* @throws JsonProcessingException
*/
Result<?> getOneCapacityData(CapacityOrderQueryDTO.Request capacityQueryReqDTO); 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; ...@@ -4,4 +4,6 @@ import com.dituhui.pea.common.Result;
public interface PublicService { public interface PublicService {
Result<?> getPublicParameter(); Result<?> getPublicParameter();
Result<?> getSkillTree();
} }
...@@ -73,69 +73,6 @@ public class CapacityQueryServiceImpl implements CapacityQueryService { ...@@ -73,69 +73,6 @@ public class CapacityQueryServiceImpl implements CapacityQueryService {
return legends; 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) { private int getSpanType(int capLeft, int capTotal) {
float ratio = (float) capLeft / capTotal; float ratio = (float) capLeft / capTotal;
if (ratio < 0.3) { if (ratio < 0.3) {
......
...@@ -46,12 +46,11 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -46,12 +46,11 @@ public class DispatchServiceImpl implements DispatchService {
private EngineerInfoMPDao engineerInfoMPDao; private EngineerInfoMPDao engineerInfoMPDao;
@Autowired @Autowired
private ProductCategoryMPDao productCategoryMPDao; private SkillInfoMPDao skillInfoMPDao;
@Autowired @Autowired
private CapacityEngineerStatMPDao capacityEngineerStatMPDao; private CapacityEngineerStatMPDao capacityEngineerStatMPDao;
@Transactional @Transactional
@Override @Override
public Result<?> getDispatchOrderList(DispatchOrderListReq reqDTO) { public Result<?> getDispatchOrderList(DispatchOrderListReq reqDTO) {
...@@ -140,8 +139,11 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -140,8 +139,11 @@ public class DispatchServiceImpl implements DispatchService {
} }
// 获取服务单/工单列表 // 获取服务单/工单列表
Map<String, List<OrderRequest>> orders = this.queryOrderRequestByOrderIds(new ArrayList<>(orderIds)).stream().collect( Map<String, List<OrderRequest>> orders = new HashMap<>();
Collectors.groupingBy(OrderRequest::getOrderId)); if(!orderIds.isEmpty()) {
orders = orderRequestMPDao.selectByOrderIds(new ArrayList<>(orderIds)).stream().collect(
Collectors.groupingBy(OrderRequest::getOrderId));
}
// 获取技术员已指派单列表 // 获取技术员已指派单列表
List<DispatchEngineerOrderListResp.EngineerInfo> egs = new ArrayList<>(); List<DispatchEngineerOrderListResp.EngineerInfo> egs = new ArrayList<>();
...@@ -152,12 +154,14 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -152,12 +154,14 @@ public class DispatchServiceImpl implements DispatchService {
// 技术员已指派的订单列表 // 技术员已指派的订单列表
List<OrderAppointment> records = engineerOrders.getOrDefault(e.getEngineerCode(), new ArrayList<>()); List<OrderAppointment> records = engineerOrders.getOrDefault(e.getEngineerCode(), new ArrayList<>());
for (OrderAppointment r : records) { 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); OrderRequest o = orders.get(r.getOrderId()).get(0);
DispatchEngineerOrderListResp.OrderInfo item = new DispatchEngineerOrderListResp.OrderInfo();
item.setOrderId(r.getOrderId()); item.setOrderId(r.getOrderId());
item.setCategory(String.format("%s-%s", o.getType(), o.getBrand())); item.setCategory(String.format("%s-%s", o.getType(), o.getBrand()));
item.setSkill(o.getSkill()); item.setSkill(o.getSkill());
...@@ -217,7 +221,7 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -217,7 +221,7 @@ public class DispatchServiceImpl implements DispatchService {
throw new BusinessException("技术员不存在"); throw new BusinessException("技术员不存在");
} }
List<OrderRequest> orders = this.queryOrderRequestByOrderIds(orderIds); List<OrderRequest> orders = orderRequestMPDao.selectByOrderIds(orderIds);
if (orders.isEmpty()) { if (orders.isEmpty()) {
throw new BusinessException("订单号错误"); throw new BusinessException("订单号错误");
} }
...@@ -297,16 +301,6 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -297,16 +301,6 @@ public class DispatchServiceImpl implements DispatchService {
return orderRequestMPDao.selectList(lqw); 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) { private Map<String, List<OrderAppointment>> queryEngineerOrders(List<String> engineerCodes, String date) {
// 获取工程师服务单列表 // 获取工程师服务单列表
...@@ -360,8 +354,8 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -360,8 +354,8 @@ public class DispatchServiceImpl implements DispatchService {
private HashMap<String, Integer> querySkillTakeTime() { private HashMap<String, Integer> querySkillTakeTime() {
HashMap<String, Integer> map = new HashMap<>(); HashMap<String, Integer> map = new HashMap<>();
List<ProductCategory> records = productCategoryMPDao.selectList(null); List<SkillInfo> records = skillInfoMPDao.selectList(null);
for (ProductCategory r : records) { for (SkillInfo r : records) {
String key = String.format("%s%s%sd", r.getBrand(), r.getType(), r.getSkill()); String key = String.format("%s%s%sd", r.getBrand(), r.getType(), r.getSkill());
map.put(key, r.getTakeTime()); map.put(key, r.getTakeTime());
} }
......
...@@ -155,9 +155,7 @@ public class EngineerServiceImpl implements EngineerService { ...@@ -155,9 +155,7 @@ public class EngineerServiceImpl implements EngineerService {
Set<String> sInput = new HashSet<>(skillGroupIds); Set<String> sInput = new HashSet<>(skillGroupIds);
Set<String> sDB = new HashSet<>(engineerSkills.getOrDefault(engineerCode, new ArrayList<>())); Set<String> sDB = new HashSet<>(engineerSkills.getOrDefault(engineerCode, new ArrayList<>()));
log.info("before sInput:{}, sDB:{}", sInput, sDB);
sInput.removeAll(sDB); sInput.removeAll(sDB);
log.info("after sInput:{}", sInput);
for (String skillGroupId : sInput) { for (String skillGroupId : sInput) {
EngineerSkillGroup e = new EngineerSkillGroup(); EngineerSkillGroup e = new EngineerSkillGroup();
e.setEngineerCode(engineerCode); 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; ...@@ -2,8 +2,11 @@ package com.dituhui.pea.order.service.impl;
import com.dituhui.pea.common.Result; import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.dao.PubParamsDao; 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.PubParameterDTO;
import com.dituhui.pea.order.dto.PublicSkillTreeDTO;
import com.dituhui.pea.order.entity.PubParamsEntity; import com.dituhui.pea.order.entity.PubParamsEntity;
import com.dituhui.pea.order.entity.SkillInfoEntity;
import com.dituhui.pea.order.service.PublicService; import com.dituhui.pea.order.service.PublicService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -12,6 +15,7 @@ import org.springframework.stereotype.Service; ...@@ -12,6 +15,7 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
@Slf4j @Slf4j
@Service @Service
...@@ -20,6 +24,9 @@ public class PublicServiceImpl implements PublicService { ...@@ -20,6 +24,9 @@ public class PublicServiceImpl implements PublicService {
@Autowired @Autowired
private PubParamsDao pubParamsDao; private PubParamsDao pubParamsDao;
@Autowired
private SkillInfoDao skillInfoDao;
@Override @Override
public Result<?> getPublicParameter() { public Result<?> getPublicParameter() {
List<PubParameterDTO.Enum> enums = new ArrayList<>(); List<PubParameterDTO.Enum> enums = new ArrayList<>();
...@@ -42,6 +49,19 @@ public class PublicServiceImpl implements PublicService { ...@@ -42,6 +49,19 @@ public class PublicServiceImpl implements PublicService {
return Result.success(rs); 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() { private HashMap<String, String> getMapping() {
String[] pairs = { String[] pairs = {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!