Commit dd709610 by 王力

Merge branch 'dev_assign' into 'develop'

Dev assign

See merge request !184
2 parents 8f19fc45 390620f2
......@@ -3,6 +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.OrderAssignReq;
import com.dituhui.pea.order.dto.OrderRevokeAssign;
import com.dituhui.pea.order.service.OrderAssign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
......@@ -40,4 +41,16 @@ public class OrderAssignController {
}
return res;
}
@PostMapping("/order/revoke/assign")
public Result<?> orderRevokeAssign(@RequestBody OrderRevokeAssign req){
// 放回工单池
Result<?> res = null;
try{
res = orderAssign.orderRevokeAssign(req.getOrderId());
} catch (BusinessException e){
return Result.failed(e.getMessage());
}
return res;
}
}
......@@ -17,6 +17,12 @@ public interface OrderAppointmentMPDao extends BaseMapper<OrderAppointment> {
@Select("select * from order_appointment where order_id=#{orderId}")
List<OrderAppointment> selectByOrderId(String orderId);
@Select("select * from order_appointment where order_id=#{orderId} and dt=#{dt}")
OrderAppointment getByOrderIdAndDt(String orderId, LocalDate dt);
@Select("select * from order_appointment where order_id=#{orderId} and dt=#{dt}")
List<OrderAppointment> selectByOrderIdAndDt(String orderId, LocalDate dt);
@Select("select * from order_appointment where engineer_code=#{engineerCode} and dt=#{dt}")
List<OrderAppointment> selectByEngineerCodeAndDt(String engineerCode, LocalDate dt);
}
package com.dituhui.pea.order.dto;
import lombok.Data;
@Data
public class OrderRevokeAssign {
private String orderId;
}
......@@ -9,4 +9,6 @@ public interface OrderAssign {
// 服务单指派-指派提交
Result<?> orderAssign(String orderId, String engineerCode);
Result<?> orderRevokeAssign(String orderId);
}
package com.dituhui.pea.order.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.dituhui.pea.common.BusinessException;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.common.TimeUtils;
......@@ -8,8 +10,6 @@ import com.dituhui.pea.order.dto.DispatchEngineerOrderListResp;
import com.dituhui.pea.order.dto.DispatchOrderListResp;
import com.dituhui.pea.order.entity.*;
import com.dituhui.pea.order.service.DispatchService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -94,7 +94,7 @@ public class DispatchServiceImpl implements DispatchService {
@Transactional
@Override
public Result<?> getDispatchEngineerOrderList(String levelType, List<String> levelIds, String date) throws BusinessException{
public Result<?> getDispatchEngineerOrderList(String levelType, List<String> levelIds, String date) throws BusinessException {
// 派工台技术员预约单列表
// 获取技能耗时
......@@ -102,13 +102,13 @@ public class DispatchServiceImpl implements DispatchService {
// 获取groupIds
List<String> groupIds = this.queryOrgGroupIds(levelType, levelIds);
if (groupIds.isEmpty()){
if (groupIds.isEmpty()) {
throw new BusinessException("大区/分部/小组组织结构配置可能错误或缺失,请联系管理员/研发");
}
// 获取engineer列表
List<EngineerInfo> engineers = this.queryEngineers(groupIds);
if(engineers.isEmpty()) {
if (engineers.isEmpty()) {
// 该group下没有技术员,返回空
DispatchEngineerOrderListResp res = new DispatchEngineerOrderListResp();
List<DispatchEngineerOrderListResp.EngineerInfo> egs = new ArrayList<>();
......
......@@ -7,12 +7,14 @@ import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.common.TimeUtils;
import com.dituhui.pea.order.dao.EngineerInfoMPDao;
import com.dituhui.pea.order.dao.OrderAppointmentMPDao;
import com.dituhui.pea.order.dao.OrderEventMPDao;
import com.dituhui.pea.order.dao.OrderRequestMPDao;
import com.dituhui.pea.order.dto.LabelValueDTO;
import com.dituhui.pea.order.dto.OrderAssignRecommendResp;
import com.dituhui.pea.order.dto.TimeLineDTO;
import com.dituhui.pea.order.entity.EngineerInfo;
import com.dituhui.pea.order.entity.OrderAppointment;
import com.dituhui.pea.order.entity.OrderEvent;
import com.dituhui.pea.order.entity.OrderRequest;
import com.dituhui.pea.order.service.CommonService;
import com.dituhui.pea.order.service.OrderAssign;
......@@ -44,6 +46,9 @@ public class OrderAssignImpl implements OrderAssign {
@Autowired
private CommonService commonService;
@Autowired
private OrderEventMPDao orderEventMPDao;
@Transactional
@Override
public Result<?> getOrderAssignRecommendEngineers(String orderId, String key, String distance, String recommend) {
......@@ -159,6 +164,40 @@ public class OrderAssignImpl implements OrderAssign {
return Result.success(null);
}
@Override
public Result<?> orderRevokeAssign(String orderId) throws BusinessException{
OrderRequest order = orderRequestMPDao.getByOrderId(orderId);
if (order == null){
throw new BusinessException("订单不存在");
}
// 更新order_request表为未指派
LambdaUpdateWrapper<OrderRequest> orderWrapper = new LambdaUpdateWrapper<>();
orderWrapper.set(OrderRequest::getAppointmentStatus, "NOT_ASSIGNED");
orderRequestMPDao.updateById(order);
// 更新order_appointment表为未指派
LambdaUpdateWrapper<OrderAppointment> appWrapper = new LambdaUpdateWrapper<>();
appWrapper.set(OrderAppointment::getStatus, "NOT_ASSIGNED")
.eq(OrderAppointment::getOrderId, orderId).eq(OrderAppointment::getDt, order.getDt());
orderAppointmentMPDao.update(null, appWrapper);
// 登记事件
OrderEvent oe = new OrderEvent();
oe.setOrderId(orderId);
oe.setSuborderId("");
oe.setHappen(new Timestamp(System.currentTimeMillis()));
oe.setEvent("放回工单池");
oe.setOperator("123"); // 操作员ID TODO-用户系统
oe.setOperatorName("测试用户"); // 操作员姓名 TODO-用户系统
oe.setOperator("PEA");
oe.setDescription("");
oe.setMemo("");
oe.setCreateTime(new Timestamp(System.currentTimeMillis()));
orderEventMPDao.insert(oe);
return null;
}
private List<OrderAppointment> queryOrderAppointments(String engineerCode, String date) {
LambdaQueryWrapper<OrderAppointment> lqw = new LambdaQueryWrapper<>();
lqw.eq(OrderAppointment::getEngineerCode, engineerCode);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!