Commit 9a237d45 by wangli

派单台工单列表接口实现

1 parent 91c06d2d
package com.alibaba.cloud.integration.order.service.impl;
import com.alibaba.cloud.integration.common.Result;
import com.alibaba.cloud.integration.order.dao.EngineerInfoMPDao;
import com.alibaba.cloud.integration.order.dao.OrderAppointmentMPDao;
import com.alibaba.cloud.integration.order.dao.OrderRequestMPDao;
import com.alibaba.cloud.integration.order.dao.OrgGroupMPDao;
import com.alibaba.cloud.integration.order.entity.EngineerInfo;
import com.alibaba.cloud.integration.order.entity.OrderAppointment;
import com.alibaba.cloud.integration.order.entity.OrderRequest;
import com.alibaba.cloud.integration.order.entity.OrgGroup;
import com.alibaba.cloud.integration.order.dao.*;
import com.alibaba.cloud.integration.order.dto.DispatchOrderListResp;
import com.alibaba.cloud.integration.order.entity.*;
import com.alibaba.cloud.integration.order.service.DispatchService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
......@@ -33,22 +33,45 @@ public class DispatchServiceImpl implements DispatchService {
@Autowired
private EngineerInfoMPDao engineerInfoMPDao;
@Autowired
private ProductCategoryMPDao productCategoryMPDao;
@Transactional
@Override
public Result<?> getDispatchOrderList(String levelType, List<String> levelIds, String date, String groupTagId) {
// 获取技能需要时间列表
HashMap<String, Integer> skillTakeTime = this.querySkillTakeTime();
// 获取工单列表
List<OrderRequest> orders = this.queryOrderRequests(levelType, levelIds, date);
for (OrderRequest o: orders) {
String a = String.format("%s:%s%s-%s %s:%s", o.getOrderId(),o.getSkill(), o.getType(), o.getBrand(), o.getName(), o.getAddress());
String intentionTime = String.format("");
String duration = "1";
String type = o.getType();
String category = String.format("%s-%s", o.getType(), o.getBrand());
String orderId ="";
String customerName = o.getName();
String remark = o.getDescription();
String groupTag = "紧急";
int groupWeight = 10;
List<DispatchOrderListResp.Order> items = new ArrayList<>();
for (OrderRequest o : orders) {
DispatchOrderListResp.Order item = new DispatchOrderListResp.Order();
item.setOrderId(o.getOrderId());
item.setCategory(String.format("%s-%s", o.getType(), o.getBrand()));
item.setSkill(o.getSkill());
item.setRemark(o.getDescription());
item.setCustomerName(o.getName());
String description = String.format("%s:%s%s-%s %s:%s", o.getOrderId(), o.getSkill(),
o.getType(), o.getBrand(), o.getName(), o.getAddress());
item.setDescription(description);
String key = String.format("%s%s%s", o.getBrand(), o.getType(), o.getSkill());
item.setDuration(skillTakeTime.getOrDefault(key, 30));
String time = this.timestamp2Datetime(o.getExpectTimeBegin(), "HH:mm");
String timeSlot = this.parseTimeSlot(o.getExpectTimeBegin());
item.setIntentionTime(String.format("%s/%s", time, timeSlot));
items.add(item);
}
return null;
DispatchOrderListResp res = new DispatchOrderListResp();
res.setOrders(items);
return Result.success(res);
}
@Override
......@@ -107,6 +130,16 @@ public class DispatchServiceImpl implements DispatchService {
return groups.stream().map(OrgGroup::getGroupId).collect(Collectors.toList());
}
private HashMap<String, Integer> querySkillTakeTime() {
HashMap<String, Integer> map = new HashMap<>();
List<ProductCategory> records = productCategoryMPDao.selectList(null);
for (ProductCategory r : records) {
String key = String.format("%s%s%sd", r.getBrand(), r.getType(), r.getSkill());
map.put(key, r.getTakeTime());
}
return map;
}
private long DateString2Timestamp(String date, String time) {
String datetime = String.format("%s %s", date, time);
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
......@@ -117,4 +150,21 @@ public class DispatchServiceImpl implements DispatchService {
}
return 0;
}
private String timestamp2Datetime(Timestamp t, String pattern) {
DateTimeFormatter df = DateTimeFormatter.ofPattern(pattern);
return df.format(t.toLocalDateTime());
}
private String parseTimeSlot(Timestamp t) {
String h = this.timestamp2Datetime(t, "HH");
Integer hour = Integer.parseInt(h);
if (hour <= 12) {
return "上午";
} else if (hour <= 18) {
return "下午";
} else {
return "晚上";
}
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!