Commit 94a4c54a by 王力

Merge branch 'dev_dispatch_filter0711' into 'develop'

Dev dispatch filter0711

See merge request !201
2 parents 0991c619 7328d21b
...@@ -2,27 +2,31 @@ package com.dituhui.pea.order.controller; ...@@ -2,27 +2,31 @@ 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.DispatchEngineerOrderListReq;
import com.dituhui.pea.order.dto.DispatchOrderConfirmReqDTO; import com.dituhui.pea.order.dto.DispatchOrderConfirmReqDTO;
import com.dituhui.pea.order.dto.DispatchOrderListReq;
import com.dituhui.pea.order.service.DispatchService; import com.dituhui.pea.order.service.DispatchService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List; import java.util.List;
@RestController @RestController
@RequestMapping("/pea-order") @RequestMapping("/pea-order")
@Validated
public class DispatchController { public class DispatchController {
@Autowired @Autowired
private DispatchService dispatchService; private DispatchService dispatchService;
@GetMapping("/dispatch/order/list") @GetMapping("/dispatch/order/list")
public Result<?> getDispatchOrderList(@RequestParam String levelType, @RequestParam("levelValue") List<String> levelIds, public Result<?> getDispatchOrderList(@Valid DispatchOrderListReq reqDTO) {
@RequestParam String date, @RequestParam String groupTagId) {
// 获取派工台待派订单列表 // 获取派工台待派订单列表
Result<?> res = null; Result<?> res = null;
try { try {
res = dispatchService.getDispatchOrderList(levelType, levelIds, date, groupTagId); res = dispatchService.getDispatchOrderList(reqDTO);
}catch (BusinessException e) { }catch (BusinessException e) {
return Result.failed(e.getMessage()); return Result.failed(e.getMessage());
} }
...@@ -30,11 +34,11 @@ public class DispatchController { ...@@ -30,11 +34,11 @@ public class DispatchController {
} }
@GetMapping("/dispatch/engineer/order/list") @GetMapping("/dispatch/engineer/order/list")
public Result<?> getDispatchEngineerOrderList(@RequestParam String levelType, @RequestParam("levelValue") List<String> levelIds, @RequestParam String date) { public Result<?> getDispatchEngineerOrderList(@Valid DispatchEngineerOrderListReq reqDTO) {
// 获取派工台工程师已派订单列表 // 获取派工台工程师已派订单列表
Result<?> res = null; Result<?> res = null;
try { try {
res = dispatchService.getDispatchEngineerOrderList(levelType, levelIds, date); res = dispatchService.getDispatchEngineerOrderList(reqDTO);
}catch (BusinessException e) { }catch (BusinessException e) {
return Result.failed(e.getMessage()); return Result.failed(e.getMessage());
} }
......
package com.dituhui.pea.order.dto;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.util.List;
@Data
public class DispatchEngineerOrderListReq {
@NotNull
private String levelType;
@NotNull
private String levelValue;
@NotNull
private String Date;
private String groupId;
private List<String> branchIds;
private List<String> groupIds;
private List<String> teamIds;
private List<String> engineerCodes;
private String key;
}
package com.dituhui.pea.order.dto;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.util.List;
@Data
public class DispatchOrderListReq {
@NotNull
private String levelType;
@NotNull
private String levelValue;
@NotNull
private String Date;
@NotNull
private String groupTagId;
private List<String> branchIds;
private List<String> groupIds;
private List<String> teamIds;
private List<String> engineerCodes;
private List<Integer> priorities;
private List<String> productCategory;
private List<String> serviceCategory;
private String phone;
private String orderId;
private List<String> appointmentStatus;
private List<String> appointmentType;
}
package com.dituhui.pea.order.service; package com.dituhui.pea.order.service;
import com.dituhui.pea.common.Result; import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.dto.DispatchEngineerOrderListReq;
import com.dituhui.pea.order.dto.DispatchOrderListReq;
import java.util.List; import java.util.List;
public interface DispatchService { public interface DispatchService {
Result<?> getDispatchOrderList(String levelType, List<String> levelIds, String date, String groupTagId); Result<?> getDispatchOrderList(DispatchOrderListReq reqDTO);
Result<?> getDispatchEngineerOrderList(String levelType, List<String> levelIds, String date); Result<?> getDispatchEngineerOrderList(DispatchEngineerOrderListReq reqDTO);
Result<?> dispatchOrderConfirm(String engineerCode, List<String> orderIds); Result<?> dispatchOrderConfirm(String engineerCode, List<String> orderIds);
} }
...@@ -4,12 +4,16 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; ...@@ -4,12 +4,16 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
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.common.ListUtils;
import com.dituhui.pea.order.common.TimeUtils; import com.dituhui.pea.order.common.TimeUtils;
import com.dituhui.pea.order.dao.*; import com.dituhui.pea.order.dao.*;
import com.dituhui.pea.order.dto.DispatchEngineerOrderListReq;
import com.dituhui.pea.order.dto.DispatchEngineerOrderListResp; import com.dituhui.pea.order.dto.DispatchEngineerOrderListResp;
import com.dituhui.pea.order.dto.DispatchOrderListReq;
import com.dituhui.pea.order.dto.DispatchOrderListResp; import com.dituhui.pea.order.dto.DispatchOrderListResp;
import com.dituhui.pea.order.entity.*; import com.dituhui.pea.order.entity.*;
import com.dituhui.pea.order.service.DispatchService; import com.dituhui.pea.order.service.DispatchService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; 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;
...@@ -36,7 +40,7 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -36,7 +40,7 @@ public class DispatchServiceImpl implements DispatchService {
private OrderAppointmentMPDao orderAppointmentMPDao; private OrderAppointmentMPDao orderAppointmentMPDao;
@Autowired @Autowired
private OrgGroupMPDao orgGroupMPDao; private OrgTeamMPDao orgTeamMPDao;
@Autowired @Autowired
private EngineerInfoMPDao engineerInfoMPDao; private EngineerInfoMPDao engineerInfoMPDao;
...@@ -47,18 +51,19 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -47,18 +51,19 @@ public class DispatchServiceImpl implements DispatchService {
@Autowired @Autowired
private CapacityEngineerStatMPDao capacityEngineerStatMPDao; private CapacityEngineerStatMPDao capacityEngineerStatMPDao;
@Transactional @Transactional
@Override @Override
public Result<?> getDispatchOrderList(String levelType, List<String> levelIds, String date, String groupTagId) { public Result<?> getDispatchOrderList(DispatchOrderListReq reqDTO) {
// 获取技能需要时间列表 // 获取技能需要时间列表
HashMap<String, Integer> skillTakeTime = this.querySkillTakeTime(); HashMap<String, Integer> skillTakeTime = this.querySkillTakeTime();
// 获取工单列表 // 获取工单列表
List<OrderRequest> orders = this.queryOrderRequests(levelType, levelIds, date); List<OrderRequest> orders = this.queryOrderRequests(reqDTO);
// 获取分组标签 // 获取分组标签
GroupTag gt = new GroupTagFactory().getGroupTag(groupTagId); GroupTag gt = new GroupTagFactory().getGroupTag(reqDTO.getGroupTagId());
List<DispatchOrderListResp.Order> items = new ArrayList<>(); List<DispatchOrderListResp.Order> items = new ArrayList<>();
for (OrderRequest o : orders) { for (OrderRequest o : orders) {
...@@ -94,20 +99,21 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -94,20 +99,21 @@ public class DispatchServiceImpl implements DispatchService {
@Transactional @Transactional
@Override @Override
public Result<?> getDispatchEngineerOrderList(String levelType, List<String> levelIds, String date) throws BusinessException { public Result<?> getDispatchEngineerOrderList(DispatchEngineerOrderListReq reqDTO) throws BusinessException {
// 派工台技术员预约单列表 // 派工台技术员预约单列表
// 获取技能耗时 // 获取技能耗时
HashMap<String, Integer> skillTakeTime = this.querySkillTakeTime(); HashMap<String, Integer> skillTakeTime = this.querySkillTakeTime();
// 获取groupIds // 获取groupIds
List<String> groupIds = this.queryOrgGroupIds(levelType, levelIds); List<String> groupIds = this.queryOrgGroupIds(reqDTO.getLevelType(), reqDTO.getLevelValue(), reqDTO.getBranchIds(),
reqDTO.getGroupIds(), reqDTO.getTeamIds());
if (groupIds.isEmpty()) { if (groupIds.isEmpty()) {
throw new BusinessException("大区/分部/小组组织结构配置可能错误或缺失,请联系管理员/研发"); throw new BusinessException("大区/分部/小组组织结构配置可能错误或缺失,请联系管理员/研发");
} }
// 获取engineer列表 // 获取engineer列表
List<EngineerInfo> engineers = this.queryEngineers(groupIds); List<EngineerInfo> engineers = this.queryEngineers(groupIds, reqDTO.getEngineerCodes(), reqDTO.getKey());
if (engineers.isEmpty()) { if (engineers.isEmpty()) {
// 该group下没有技术员,返回空 // 该group下没有技术员,返回空
DispatchEngineerOrderListResp res = new DispatchEngineerOrderListResp(); DispatchEngineerOrderListResp res = new DispatchEngineerOrderListResp();
...@@ -120,10 +126,10 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -120,10 +126,10 @@ public class DispatchServiceImpl implements DispatchService {
List<String> engineerCodes = engineers.stream().map(EngineerInfo::getEngineerCode).collect(Collectors.toList()); List<String> engineerCodes = engineers.stream().map(EngineerInfo::getEngineerCode).collect(Collectors.toList());
// 获取技术员已指派单列表 // 获取技术员已指派单列表
Map<String, List<OrderAppointment>> engineerOrders = this.queryEngineerOrders(engineerCodes, date); Map<String, List<OrderAppointment>> engineerOrders = this.queryEngineerOrders(engineerCodes, reqDTO.getDate());
// 获取技术员的容量 // 获取技术员的容量
HashMap<String, CapacityEngineerStat> engineerCap = this.queryCapacityEngineerStat(engineerCodes, date); HashMap<String, CapacityEngineerStat> engineerCap = this.queryCapacityEngineerStat(engineerCodes, reqDTO.getDate());
// 获取订单ID // 获取订单ID
Set<String> orderIds = new HashSet<>(); Set<String> orderIds = new HashSet<>();
...@@ -144,7 +150,7 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -144,7 +150,7 @@ public class DispatchServiceImpl implements DispatchService {
List<DispatchEngineerOrderListResp.OrderInfo> items = new ArrayList<>(); List<DispatchEngineerOrderListResp.OrderInfo> items = new ArrayList<>();
// 技术员已指派的订单列表 // 技术员已指派的订单列表
List<OrderAppointment> records = engineerOrders.getOrDefault(e.getEngineerCode(), List.of()); List<OrderAppointment> records = engineerOrders.getOrDefault(e.getEngineerCode(), new ArrayList<>());
for (OrderAppointment r : records) { for (OrderAppointment r : records) {
DispatchEngineerOrderListResp.OrderInfo item = new DispatchEngineerOrderListResp.OrderInfo(); DispatchEngineerOrderListResp.OrderInfo item = new DispatchEngineerOrderListResp.OrderInfo();
...@@ -263,16 +269,30 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -263,16 +269,30 @@ public class DispatchServiceImpl implements DispatchService {
return Result.success(null); return Result.success(null);
} }
private List<OrderRequest> queryOrderRequests(String levelType, List<String> levelIds, String date) { private List<OrderRequest> queryOrderRequests(DispatchOrderListReq reqDTO) {
// 获取服务单列表 // 获取服务单列表
LambdaQueryWrapper<OrderRequest> lqw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<OrderRequest> lqw = new LambdaQueryWrapper<>();
lqw.in(levelType.equals("cluster"), OrderRequest::getOrgClusterId, levelIds); lqw.eq(reqDTO.getLevelType().equals("cluster"), OrderRequest::getOrgClusterId, reqDTO.getLevelValue());
lqw.in(levelType.equals("branch"), OrderRequest::getOrgBranchId, levelIds); lqw.eq(reqDTO.getLevelType().equals("branch"), OrderRequest::getOrgBranchId, reqDTO.getLevelValue());
lqw.in(levelType.equals("group"), OrderRequest::getOrgGroupId, levelIds); lqw.eq(reqDTO.getLevelType().equals("group"), OrderRequest::getOrgGroupId, reqDTO.getLevelValue());
lqw.eq(OrderRequest::getStatus, "open"); lqw.eq(OrderRequest::getDt, TimeUtils.IsoDate2LocalDate(reqDTO.getDate()));
lqw.eq(OrderRequest::getAppointmentStatus, "NOT_ASSIGNED"); //筛选项
lqw.ge(OrderRequest::getExpectTimeBegin, TimeUtils.IsoDateTime2Timestamp(String.format("%s 00:00:00", date))); lqw.eq(StringUtils.isNotEmpty(reqDTO.getPhone()), OrderRequest::getPhone, reqDTO.getPhone());
lqw.le(OrderRequest::getExpectTimeBegin, TimeUtils.IsoDateTime2Timestamp(String.format("%s 23:59:59", date))); lqw.eq(StringUtils.isNotEmpty(reqDTO.getOrderId()), OrderRequest::getOrderId, reqDTO.getOrderId());
lqw.in(ListUtils.isNotEmpty(reqDTO.getBranchIds()), OrderRequest::getOrgBranchId, reqDTO.getBranchIds());
lqw.in(ListUtils.isNotEmpty(reqDTO.getGroupIds()), OrderRequest::getOrgGroupId, reqDTO.getGroupIds());
lqw.in(ListUtils.isNotEmpty(reqDTO.getTeamIds()), OrderRequest::getOrgTeamId, reqDTO.getTeamIds());
lqw.in(ListUtils.isNotEmpty(reqDTO.getPriorities()), OrderRequest::getPriority, reqDTO.getPriorities());
lqw.in(ListUtils.isNotEmpty(reqDTO.getProductCategory()), OrderRequest::getType, reqDTO.getProductCategory());
lqw.in(ListUtils.isNotEmpty(reqDTO.getProductCategory()), OrderRequest::getSkill, reqDTO.getServiceCategory());
lqw.in(ListUtils.isNotEmpty(reqDTO.getAppointmentType()), OrderRequest::getAppointmentMethod, reqDTO.getAppointmentType());
lqw.in(ListUtils.isNotEmpty(reqDTO.getAppointmentStatus()), OrderRequest::getAppointmentStatus, reqDTO.getAppointmentStatus());
if(ListUtils.isNotEmpty(reqDTO.getEngineerCodes())) {
String engineerCodes = String.join(",", reqDTO.getEngineerCodes());
String sql = String.format("select 1 from order_appointment oa where oa.order_id = order_request.order_id and oa.dt = order_request.dt and oa.engineer_code in (%s)", engineerCodes);
lqw.exists(sql);
}
return orderRequestMPDao.selectList(lqw); return orderRequestMPDao.selectList(lqw);
} }
...@@ -306,22 +326,36 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -306,22 +326,36 @@ public class DispatchServiceImpl implements DispatchService {
} }
private List<EngineerInfo> queryEngineers(List<String> groupIds) { private List<EngineerInfo> queryEngineers(List<String> groupIds, List<String> engineerCodes, String key) {
// 通过groupIds获取技术员列表 // 通过groupIds获取技术员列表
LambdaQueryWrapper<EngineerInfo> lqw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<EngineerInfo> lqw = new LambdaQueryWrapper<>();
lqw.in(EngineerInfo::getGroupId, groupIds); lqw.in(EngineerInfo::getGroupId, groupIds);
lqw.eq(EngineerInfo::getBeanStatus, 1); lqw.eq(EngineerInfo::getBeanStatus, 1);
lqw.in(ListUtils.isNotEmpty(engineerCodes), EngineerInfo::getEngineerCode, engineerCodes);
if (StringUtils.isNotEmpty(key)) {
lqw.and(w ->
w.like(EngineerInfo::getPhone, key)
.or()
.like(EngineerInfo::getName, key)
.or()
.like(EngineerInfo::getEngineerCode, key)
);
}
return engineerInfoMPDao.selectList(lqw); return engineerInfoMPDao.selectList(lqw);
} }
private List<String> queryOrgGroupIds(String levelType, List<String> levelIds) { private List<String> queryOrgGroupIds(String levelType, String levelIds, List<String> branchIds, List<String> groupIds, List<String> teamIds) {
LambdaQueryWrapper<OrgGroup> lqw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<OrgTeam> lqw = new LambdaQueryWrapper<>();
lqw.in(levelType.equals("cluster"), OrgGroup::getClusterId, levelIds); lqw.eq(levelType.equals("cluster"), OrgTeam::getClusterId, levelIds);
lqw.in(levelType.equals("branch"), OrgGroup::getBranchId, levelIds); lqw.eq(levelType.equals("branch"), OrgTeam::getBranchId, levelIds);
lqw.in(levelType.equals("group"), OrgGroup::getGroupId, levelIds); lqw.eq(levelType.equals("group"), OrgTeam::getGroupId, levelIds);
lqw.in(ListUtils.isNotEmpty(branchIds), OrgTeam::getBranchId, branchIds);
List<OrgGroup> groups = orgGroupMPDao.selectList(lqw); lqw.in(ListUtils.isNotEmpty(groupIds), OrgTeam::getGroupId, groupIds);
return groups.stream().map(OrgGroup::getGroupId).collect(Collectors.toList()); lqw.in(ListUtils.isNotEmpty(teamIds), OrgTeam::getTeamId, teamIds);
List<OrgTeam> groups = orgTeamMPDao.selectList(lqw);
return groups.stream().map(OrgTeam::getGroupId).collect(Collectors.toList());
} }
private HashMap<String, Integer> querySkillTakeTime() { private HashMap<String, Integer> querySkillTakeTime() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!