Commit 11fc2225 by 王力

Merge branch 'feature_timeutil' into 'master'

Feature timeutil

See merge request !117
2 parents e633dcd8 2fac4207
package com.dituhui.pea.order.common;
import java.sql.Timestamp;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
public class TimeUtils {
public static final String DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
public static final String DATE_NO_GAP_FORMAT = "yyyyMMdd";
public static final String DATE_GAP_FORMAT = "yyyy-MM-dd";
public static final String TIME_HH_MM_FORMAT = "HHmm";
public static final String IsoTimestamp2DateTime(Timestamp timestamp) {
// Timestamp转换为日期时间字符串
LocalDateTime localDateTime = timestamp.toLocalDateTime();
return localDateTime.format(DateTimeFormatter.ofPattern(DATE_TIME_FORMAT));
}
public static final Timestamp IsoDateTime2Timestamp(String datetime) {
// 将日期时间字符串转换为Timestamp
LocalDateTime localDateTime = LocalDateTime.parse(datetime, DateTimeFormatter.ofPattern(DATE_TIME_FORMAT));
return Timestamp.valueOf(localDateTime);
}
public static final String timestamp2DateTime(Timestamp timestamp, String pattern) {
// Timestamp转换为日期时间字符串
LocalDateTime localDateTime = timestamp.toLocalDateTime();
return localDateTime.format(DateTimeFormatter.ofPattern(pattern));
}
public static final Timestamp dateTime2Timestamp(String datetime, String pattern) {
// 将日期时间字符串转换为Timestamp
LocalDateTime localDateTime = LocalDateTime.parse(datetime, DateTimeFormatter.ofPattern(pattern));
return Timestamp.valueOf(localDateTime);
}
public static final LocalDate IsoDate2LocalDate(String s) {
return LocalDate.parse(s, DateTimeFormatter.ofPattern(DATE_GAP_FORMAT));
}
public static final LocalDate date2LocalDate(String s, String pattern) {
return LocalDate.parse(s, DateTimeFormatter.ofPattern(pattern));
}
public static final LocalDate addDays(LocalDate date, long days) {
return date.plusDays(days);
}
public static final LocalDate subDays(LocalDate date, long days) {
return date.minusDays(days);
}
}
...@@ -2,6 +2,7 @@ package com.dituhui.pea.order.service.impl; ...@@ -2,6 +2,7 @@ package com.dituhui.pea.order.service.impl;
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.TimeUtils;
import com.dituhui.pea.order.dao.*; import com.dituhui.pea.order.dao.*;
import com.dituhui.pea.order.dto.DispatchEngineerOrderListResp; import com.dituhui.pea.order.dto.DispatchEngineerOrderListResp;
import com.dituhui.pea.order.dto.DispatchOrderListResp; import com.dituhui.pea.order.dto.DispatchOrderListResp;
...@@ -75,7 +76,7 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -75,7 +76,7 @@ public class DispatchServiceImpl implements DispatchService {
String key = String.format("%s%s%s", o.getBrand(), o.getType(), o.getSkill()); String key = String.format("%s%s%s", o.getBrand(), o.getType(), o.getSkill());
item.setDuration(skillTakeTime.getOrDefault(key, 30)); item.setDuration(skillTakeTime.getOrDefault(key, 30));
String time = this.timestamp2Datetime(o.getExpectTimeBegin(), "HH:mm"); String time = TimeUtils.timestamp2DateTime(o.getExpectTimeBegin(), "HH:mm");
String timeSlot = this.parseTimeSlot(o.getExpectTimeBegin()); String timeSlot = this.parseTimeSlot(o.getExpectTimeBegin());
item.setIntentionTime(String.format("%s/%s", time, timeSlot)); item.setIntentionTime(String.format("%s/%s", time, timeSlot));
...@@ -166,7 +167,7 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -166,7 +167,7 @@ public class DispatchServiceImpl implements DispatchService {
String key = String.format("%s%s%s", o.getBrand(), o.getType(), o.getSkill()); String key = String.format("%s%s%s", o.getBrand(), o.getType(), o.getSkill());
item.setDuration(skillTakeTime.getOrDefault(key, 30)); item.setDuration(skillTakeTime.getOrDefault(key, 30));
String time = this.timestamp2Datetime(o.getExpectTimeBegin(), "HH:mm"); String time = TimeUtils.timestamp2DateTime(o.getExpectTimeBegin(), "HH:mm");
String timeSlot = this.parseTimeSlot(o.getExpectTimeBegin()); String timeSlot = this.parseTimeSlot(o.getExpectTimeBegin());
item.setIntentionTime(String.format("%s/%s", time, timeSlot)); item.setIntentionTime(String.format("%s/%s", time, timeSlot));
...@@ -355,13 +356,8 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -355,13 +356,8 @@ public class DispatchServiceImpl implements DispatchService {
return Timestamp.valueOf(date + " " + time); return Timestamp.valueOf(date + " " + time);
} }
private String timestamp2Datetime(Timestamp t, String pattern) {
DateTimeFormatter df = DateTimeFormatter.ofPattern(pattern);
return df.format(t.toLocalDateTime());
}
private String parseTimeSlot(Timestamp t) { private String parseTimeSlot(Timestamp t) {
String h = this.timestamp2Datetime(t, "HH"); String h = TimeUtils.timestamp2DateTime(t, "HH");
Integer hour = Integer.parseInt(h); Integer hour = Integer.parseInt(h);
if (hour <= 12) { if (hour <= 12) {
return "上午"; return "上午";
......
...@@ -2,6 +2,7 @@ package com.dituhui.pea.order.service.impl; ...@@ -2,6 +2,7 @@ package com.dituhui.pea.order.service.impl;
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.TimeUtils;
import com.dituhui.pea.order.dao.*; import com.dituhui.pea.order.dao.*;
import com.dituhui.pea.order.dto.*; import com.dituhui.pea.order.dto.*;
import com.dituhui.pea.order.entity.*; import com.dituhui.pea.order.entity.*;
...@@ -369,7 +370,7 @@ public class EngineerServiceImpl implements EngineerService { ...@@ -369,7 +370,7 @@ public class EngineerServiceImpl implements EngineerService {
skill.setEngineerCode(e.getEngineerCode()); skill.setEngineerCode(e.getEngineerCode());
skill.setEngineerName(e.getName()); skill.setEngineerName(e.getName());
skill.setGroupName(groupNames.getOrDefault(e.getGroupId(), "")); skill.setGroupName(groupNames.getOrDefault(e.getGroupId(), ""));
skill.setUpdateTime(this.Timestamp2Datetime(e.getUpdateTime(), "yyyy-MM-dd hh:mm:ss")); skill.setUpdateTime(TimeUtils.IsoTimestamp2DateTime(e.getUpdateTime()));
// 获取一个工程师的技能列表 // 获取一个工程师的技能列表
skill.setCategoryIds(engineerSkills.getOrDefault(e.getEngineerCode(), emptySkills)); skill.setCategoryIds(engineerSkills.getOrDefault(e.getEngineerCode(), emptySkills));
...@@ -458,11 +459,6 @@ public class EngineerServiceImpl implements EngineerService { ...@@ -458,11 +459,6 @@ public class EngineerServiceImpl implements EngineerService {
return (age <= 0) ? "" : Integer.toString(age); return (age <= 0) ? "" : Integer.toString(age);
} }
private String Timestamp2Datetime(Timestamp t, String pattern) {
DateTimeFormatter df = DateTimeFormatter.ofPattern(pattern);
return df.format(t.toLocalDateTime());
}
@Override @Override
public Result<?> getEngineersGanttList(EngineersGanttReqDTO reqDTO) { public Result<?> getEngineersGanttList(EngineersGanttReqDTO reqDTO) {
// 按日期返回技术员们当天的服务甘特图,不需要翻页 // 按日期返回技术员们当天的服务甘特图,不需要翻页
......
package com.dituhui.pea.order.service.impl; package com.dituhui.pea.order.service.impl;
import com.dituhui.pea.common.Result; import com.dituhui.pea.common.Result;
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.EnginnerTimelineResp; import com.dituhui.pea.order.dto.EnginnerTimelineResp;
import com.dituhui.pea.order.entity.*; import com.dituhui.pea.order.entity.*;
...@@ -162,7 +163,7 @@ public class EngineerTimelineServiceImpl implements EngineerTimelineService { ...@@ -162,7 +163,7 @@ public class EngineerTimelineServiceImpl implements EngineerTimelineService {
location = locations.get(t.getOrderId()); location = locations.get(t.getOrderId());
} }
item.setTitle(title); item.setTitle(title);
item.setTime(this.Timestamp2Datetime(t.getHappen())); item.setTime(TimeUtils.IsoTimestamp2DateTime(t.getHappen()));
item.setStatus(1); item.setStatus(1);
item.setText(text); item.setText(text);
...@@ -181,7 +182,7 @@ public class EngineerTimelineServiceImpl implements EngineerTimelineService { ...@@ -181,7 +182,7 @@ public class EngineerTimelineServiceImpl implements EngineerTimelineService {
index += 1; index += 1;
EnginnerTimelineResp.DynamicItem item = new EnginnerTimelineResp.DynamicItem(); EnginnerTimelineResp.DynamicItem item = new EnginnerTimelineResp.DynamicItem();
item.setTitle(String.format("第%d单出发", index)); item.setTitle(String.format("第%d单出发", index));
item.setTime(this.Timestamp2Datetime(o.getExpectStartTime())); item.setTime(TimeUtils.IsoTimestamp2DateTime(o.getExpectStartTime()));
item.setStatus(0); item.setStatus(0);
item.setText(String.format("%d", index)); item.setText(String.format("%d", index));
item.setLocation(locations.get(o.getOrderId())); item.setLocation(locations.get(o.getOrderId()));
...@@ -191,9 +192,4 @@ public class EngineerTimelineServiceImpl implements EngineerTimelineService { ...@@ -191,9 +192,4 @@ public class EngineerTimelineServiceImpl implements EngineerTimelineService {
// 根据items的time升序排序 // 根据items的time升序排序
return items.stream().sorted(Comparator.comparing(EnginnerTimelineResp.DynamicItem::getTime)).collect(Collectors.toList()); return items.stream().sorted(Comparator.comparing(EnginnerTimelineResp.DynamicItem::getTime)).collect(Collectors.toList());
} }
private String Timestamp2Datetime(Timestamp t) {
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
return df.format(t.toLocalDateTime());
}
} }
...@@ -2,6 +2,7 @@ package com.dituhui.pea.order.service.impl; ...@@ -2,6 +2,7 @@ package com.dituhui.pea.order.service.impl;
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.TimeUtils;
import com.dituhui.pea.order.dao.EngineerInfoMPDao; import com.dituhui.pea.order.dao.EngineerInfoMPDao;
import com.dituhui.pea.order.dao.OrderAppointmentMPDao; import com.dituhui.pea.order.dao.OrderAppointmentMPDao;
import com.dituhui.pea.order.dao.OrderRequestMPDao; import com.dituhui.pea.order.dao.OrderRequestMPDao;
...@@ -45,7 +46,7 @@ public class OrderAssignImpl implements OrderAssign { ...@@ -45,7 +46,7 @@ public class OrderAssignImpl implements OrderAssign {
throw new BusinessException("订单不存在"); throw new BusinessException("订单不存在");
} }
String date = this.Timestamp2Datetime(order.getExpectTimeBegin(), "yyyy-MM-dd"); String date = TimeUtils.timestamp2DateTime(order.getExpectTimeBegin(), TimeUtils.DATE_GAP_FORMAT);
// 获取group内的小组成员 // 获取group内的小组成员
List<EngineerInfo> engineers = this.queryEngineerInfoByGroupId(order.getOrgGroupId()); List<EngineerInfo> engineers = this.queryEngineerInfoByGroupId(order.getOrgGroupId());
...@@ -101,7 +102,7 @@ public class OrderAssignImpl implements OrderAssign { ...@@ -101,7 +102,7 @@ public class OrderAssignImpl implements OrderAssign {
EngineerInfo engineer = this.queryEngineerInfo(engineerCode); EngineerInfo engineer = this.queryEngineerInfo(engineerCode);
String date = this.Timestamp2Datetime(order.getExpectTimeBegin(), "yyyy-MM-dd"); String date = TimeUtils.timestamp2DateTime(order.getExpectTimeBegin(), TimeUtils.DATE_GAP_FORMAT);
List<OrderAppointment> orderAppointments = this.queryOrderAppointments(engineerCode, date); List<OrderAppointment> orderAppointments = this.queryOrderAppointments(engineerCode, date);
OrderRecommend recommend = new OrderRecommend(); OrderRecommend recommend = new OrderRecommend();
...@@ -168,19 +169,14 @@ public class OrderAssignImpl implements OrderAssign { ...@@ -168,19 +169,14 @@ public class OrderAssignImpl implements OrderAssign {
List<OrderAssignRecommendResp.Timeline> items = new ArrayList<>(); List<OrderAssignRecommendResp.Timeline> items = new ArrayList<>();
for(OrderAppointment order: orders){ for(OrderAppointment order: orders){
OrderAssignRecommendResp.Timeline item = new OrderAssignRecommendResp.Timeline(); OrderAssignRecommendResp.Timeline item = new OrderAssignRecommendResp.Timeline();
item.setStartTime(this.Timestamp2Datetime(order.getExpectStartTime(), "HH:mm")); item.setStartTime(TimeUtils.timestamp2DateTime(order.getExpectStartTime(), "HH:mm"));
item.setEndTime(this.Timestamp2Datetime(order.getExpectEndTime(), "HH:mm")); item.setEndTime(TimeUtils.timestamp2DateTime(order.getExpectEndTime(), "HH:mm"));
item.setType(order.getStatus()); item.setType(order.getStatus());
items.add(item); items.add(item);
} }
return items; return items;
} }
private String Timestamp2Datetime(Timestamp t, String pattern) {
DateTimeFormatter df = DateTimeFormatter.ofPattern(pattern);
return df.format(t.toLocalDateTime());
}
} }
@Data @Data
......
package com.dituhui.pea.order.service.impl; package com.dituhui.pea.order.service.impl;
import com.dituhui.pea.common.Result; import com.dituhui.pea.common.Result;
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.*; import com.dituhui.pea.order.dto.*;
import com.dituhui.pea.order.entity.*; import com.dituhui.pea.order.entity.*;
...@@ -132,7 +133,7 @@ public class OrderServiceDetailImpl implements OrderServiceDetail { ...@@ -132,7 +133,7 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
// 获取title // 获取title
String title = engineerName; String title = engineerName;
if (!lastSubOrderId.equals(subOrderId)) { if (!lastSubOrderId.equals(subOrderId)) {
title = String.format("%s_%s", engineerName, this.Timestamp2Datetime(o.getExpectStartTime(), "yyyyMMdd")); title = String.format("%s_%s", engineerName, TimeUtils.timestamp2DateTime(o.getExpectStartTime(), TimeUtils.DATE_NO_GAP_FORMAT));
} }
OrderAppointmentListResp.OrderAppointment item = new OrderAppointmentListResp.OrderAppointment(); OrderAppointmentListResp.OrderAppointment item = new OrderAppointmentListResp.OrderAppointment();
...@@ -345,7 +346,7 @@ public class OrderServiceDetailImpl implements OrderServiceDetail { ...@@ -345,7 +346,7 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
OrderServiceDynamicsResp.Dynamics d = new OrderServiceDynamicsResp.Dynamics(); OrderServiceDynamicsResp.Dynamics d = new OrderServiceDynamicsResp.Dynamics();
d.setTitle(o.getEvent()); d.setTitle(o.getEvent());
d.setSubTitle(String.format("操作人: %s", o.getOperatorName())); d.setSubTitle(String.format("操作人: %s", o.getOperatorName()));
d.setTime(this.Timestamp2Datetime(o.getHappen(), "yyyy-mm-dd HH:MM")); d.setTime(TimeUtils.IsoTimestamp2DateTime(o.getHappen()));
d.setMemo(o.getMemo()); d.setMemo(o.getMemo());
dynamics.add(d); dynamics.add(d);
} }
...@@ -384,9 +385,4 @@ public class OrderServiceDetailImpl implements OrderServiceDetail { ...@@ -384,9 +385,4 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
item.setParams(params); item.setParams(params);
return item; return item;
} }
private String Timestamp2Datetime(Timestamp t, String pattern) {
DateTimeFormatter df = DateTimeFormatter.ofPattern(pattern);
return df.format(t.toLocalDateTime());
}
} }
package com.dituhui.pea.order.service.impl; package com.dituhui.pea.order.service.impl;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.TimeUtils;
import com.dituhui.pea.order.dao.OrderAppointmentMPDao; import com.dituhui.pea.order.dao.OrderAppointmentMPDao;
import com.dituhui.pea.order.dao.OrderRequestMPDao; import com.dituhui.pea.order.dao.OrderRequestMPDao;
import com.dituhui.pea.order.dto.OrderServiceList; import com.dituhui.pea.order.dto.OrderServiceList;
...@@ -10,15 +13,11 @@ import com.dituhui.pea.order.dto.OrderServiceListResp; ...@@ -10,15 +13,11 @@ import com.dituhui.pea.order.dto.OrderServiceListResp;
import com.dituhui.pea.order.entity.OrderAppointment; import com.dituhui.pea.order.entity.OrderAppointment;
import com.dituhui.pea.order.entity.OrderRequest; import com.dituhui.pea.order.entity.OrderRequest;
import com.dituhui.pea.order.service.OrderServiceListService; import com.dituhui.pea.order.service.OrderServiceListService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.netty.util.internal.StringUtil; import io.netty.util.internal.StringUtil;
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;
import java.sql.Timestamp;
import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -42,8 +41,8 @@ public class OrderServiceListServiceImpl implements OrderServiceListService { ...@@ -42,8 +41,8 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
Page<OrderRequest> pg = new Page(page, size); Page<OrderRequest> pg = new Page(page, size);
LambdaQueryWrapper<OrderRequest> lqw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<OrderRequest> lqw = new LambdaQueryWrapper<>();
lqw.ge(OrderRequest::getExpectTimeBegin, this.getTimestampFromDate(startDate)); //预约开始日期 lqw.ge(OrderRequest::getExpectTimeBegin, TimeUtils.IsoDateTime2Timestamp(String.format("%s 00:00:00", startDate))); //预约开始日期
lqw.le(OrderRequest::getExpectTimeBegin, this.getTimestampFromDate(endDate)); //预约结束日期 lqw.le(OrderRequest::getExpectTimeBegin, TimeUtils.IsoDateTime2Timestamp(String.format("%s 00:00:00", endDate))); //预约结束日期
lqw.eq(!StringUtil.isNullOrEmpty(appointmentStatus), OrderRequest::getAppointmentStatus, appointmentStatus); //指派状态 lqw.eq(!StringUtil.isNullOrEmpty(appointmentStatus), OrderRequest::getAppointmentStatus, appointmentStatus); //指派状态
lqw.eq(!StringUtil.isNullOrEmpty(type), OrderRequest::getType, type); //设备类型 lqw.eq(!StringUtil.isNullOrEmpty(type), OrderRequest::getType, type); //设备类型
lqw.eq(!StringUtil.isNullOrEmpty(brand), OrderRequest::getBrand, brand); //品牌 lqw.eq(!StringUtil.isNullOrEmpty(brand), OrderRequest::getBrand, brand); //品牌
...@@ -56,7 +55,7 @@ public class OrderServiceListServiceImpl implements OrderServiceListService { ...@@ -56,7 +55,7 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
//获取工单订单号列表 //获取工单订单号列表
List<String> orderIds = new ArrayList<>(); List<String> orderIds = new ArrayList<>();
for(OrderRequest r: records) { for (OrderRequest r : records) {
orderIds.add(r.getOrderId()); orderIds.add(r.getOrderId());
} }
// 获取工程师姓名列表 // 获取工程师姓名列表
...@@ -64,7 +63,7 @@ public class OrderServiceListServiceImpl implements OrderServiceListService { ...@@ -64,7 +63,7 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
List<String> names; List<String> names;
List<OrderServiceList> content = new ArrayList<>(); List<OrderServiceList> content = new ArrayList<>();
for (OrderRequest o: records) { for (OrderRequest o : records) {
OrderServiceList record = new OrderServiceList(); OrderServiceList record = new OrderServiceList();
names = engineerNames.getOrDefault(o.getOrderId(), null); names = engineerNames.getOrDefault(o.getOrderId(), null);
record.setOrderId(o.getOrderId()); record.setOrderId(o.getOrderId());
...@@ -82,12 +81,12 @@ public class OrderServiceListServiceImpl implements OrderServiceListService { ...@@ -82,12 +81,12 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
record.setOrgBranchName(o.getOrgBranchName()); record.setOrgBranchName(o.getOrgBranchName());
record.setEngineerNum(this.getEngNum(names)); //工程师数量 record.setEngineerNum(this.getEngNum(names)); //工程师数量
record.setEngineerNames(this.getEngNames(names)); //工程师姓名列表 record.setEngineerNames(this.getEngNames(names)); //工程师姓名列表
record.setExpectTimeBegin(this.Timestamp2Datetime(o.getExpectTimeBegin())); record.setExpectTimeBegin(TimeUtils.IsoTimestamp2DateTime(o.getExpectTimeBegin()));
record.setExpectTimeEnd(this.Timestamp2Datetime(o.getExpectTimeEnd())); record.setExpectTimeEnd(TimeUtils.IsoTimestamp2DateTime(o.getExpectTimeEnd()));
record.setAppointmentTime(null); record.setAppointmentTime(null);
record.setAppointmentStatus(o.getAppointmentStatus()); record.setAppointmentStatus(o.getAppointmentStatus());
record.setAppointmentType(o.getAppointmentMethod()); record.setAppointmentType(o.getAppointmentMethod());
record.setCreateTime(this.Timestamp2Datetime(o.getCreateTime())); record.setCreateTime(TimeUtils.IsoTimestamp2DateTime(o.getCreateTime()));
content.add(record); content.add(record);
} }
...@@ -106,7 +105,7 @@ public class OrderServiceListServiceImpl implements OrderServiceListService { ...@@ -106,7 +105,7 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
public List<OrderAppointment> getOrderAppointments(List<String> orderIds) { public List<OrderAppointment> getOrderAppointments(List<String> orderIds) {
// 获取指派单列表 // 获取指派单列表
if(CollectionUtil.isEmpty(orderIds)) { if (CollectionUtil.isEmpty(orderIds)) {
return new ArrayList<>(); return new ArrayList<>();
} }
LambdaQueryWrapper<OrderAppointment> lqw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<OrderAppointment> lqw = new LambdaQueryWrapper<>();
...@@ -115,14 +114,14 @@ public class OrderServiceListServiceImpl implements OrderServiceListService { ...@@ -115,14 +114,14 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
} }
public HashMap<String, List<String>> getEngineerNames(List<OrderAppointment> orders){ public HashMap<String, List<String>> getEngineerNames(List<OrderAppointment> orders) {
// 获取orderId最新订单对应的工程师姓名列表 // 获取orderId最新订单对应的工程师姓名列表
HashMap<String, List<String>> engineerNames = new HashMap<>(); HashMap<String, List<String>> engineerNames = new HashMap<>();
Map<String, List<OrderAppointment>> g =this.groupOrderAppointments(orders); Map<String, List<OrderAppointment>> g = this.groupOrderAppointments(orders);
for(String orderId: g.keySet()) { for (String orderId : g.keySet()) {
List<String> names = new ArrayList<>(); List<String> names = new ArrayList<>();
for(OrderAppointment o: g.get(orderId)) { for (OrderAppointment o : g.get(orderId)) {
names.add(o.getEngineerName()); names.add(o.getEngineerName());
} }
engineerNames.put(orderId, names); engineerNames.put(orderId, names);
...@@ -130,7 +129,7 @@ public class OrderServiceListServiceImpl implements OrderServiceListService { ...@@ -130,7 +129,7 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
return engineerNames; return engineerNames;
} }
public Map<String, List<OrderAppointment>> groupOrderAppointments(List<OrderAppointment> orders){ public Map<String, List<OrderAppointment>> groupOrderAppointments(List<OrderAppointment> orders) {
// 获取orderId对应的最新的subOrderId的订单列表 // 获取orderId对应的最新的subOrderId的订单列表
// 根据orderId+subOrderId降序排序 // 根据orderId+subOrderId降序排序
...@@ -143,7 +142,7 @@ public class OrderServiceListServiceImpl implements OrderServiceListService { ...@@ -143,7 +142,7 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
String orderId = ""; String orderId = "";
String subOrderId = ""; String subOrderId = "";
List<OrderAppointment> items = new ArrayList<>(); List<OrderAppointment> items = new ArrayList<>();
for (OrderAppointment o: results) { for (OrderAppointment o : results) {
if (!orderId.equals(o.getOrderId())) { if (!orderId.equals(o.getOrderId())) {
orderId = o.getOrderId(); orderId = o.getOrderId();
subOrderId = o.getSuborderId(); subOrderId = o.getSuborderId();
...@@ -157,9 +156,9 @@ public class OrderServiceListServiceImpl implements OrderServiceListService { ...@@ -157,9 +156,9 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
return items.stream().collect(Collectors.groupingBy(OrderAppointment::getOrderId)); return items.stream().collect(Collectors.groupingBy(OrderAppointment::getOrderId));
} }
private Integer getEngNum(List<String> names){ private Integer getEngNum(List<String> names) {
/*获取工程师数量*/ /*获取工程师数量*/
if(names == null) { if (names == null) {
return 0; return 0;
} }
return names.size(); return names.size();
...@@ -172,13 +171,4 @@ public class OrderServiceListServiceImpl implements OrderServiceListService { ...@@ -172,13 +171,4 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
} }
return String.join("、", names); return String.join("、", names);
} }
public Timestamp getTimestampFromDate(String date){
return Timestamp.valueOf(date + " 00:00:00");
}
private String Timestamp2Datetime(Timestamp t) {
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
return df.format(t.toLocalDateTime());
}
} }
package com.dituhui.pea.order.service.impl; package com.dituhui.pea.order.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.TimeUtils;
import com.dituhui.pea.order.dao.*; import com.dituhui.pea.order.dao.*;
import com.dituhui.pea.order.dto.ScheduleEngineerOverviewResp; import com.dituhui.pea.order.dto.ScheduleEngineerOverviewResp;
import com.dituhui.pea.order.dto.ScheduleOverviewResp; import com.dituhui.pea.order.dto.ScheduleOverviewResp;
import com.dituhui.pea.order.entity.*; import com.dituhui.pea.order.entity.*;
import com.dituhui.pea.order.service.ScheduleService; import com.dituhui.pea.order.service.ScheduleService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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 java.sql.Timestamp;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -136,8 +135,8 @@ public class ScheduleServiceImpl implements ScheduleService { ...@@ -136,8 +135,8 @@ public class ScheduleServiceImpl implements ScheduleService {
List<ScheduleEngineerOverviewResp.Timeline> timelines = new ArrayList<>(); List<ScheduleEngineerOverviewResp.Timeline> timelines = new ArrayList<>();
for (OrderAppointment o : orderAppointments) { for (OrderAppointment o : orderAppointments) {
ScheduleEngineerOverviewResp.Timeline item = new ScheduleEngineerOverviewResp.Timeline(); ScheduleEngineerOverviewResp.Timeline item = new ScheduleEngineerOverviewResp.Timeline();
item.setStartTime(this.Timestamp2Datetime(o.getExpectStartTime(), "hh:mm")); item.setStartTime(TimeUtils.timestamp2DateTime(o.getExpectStartTime(), "hh:mm"));
item.setEndTime(this.Timestamp2Datetime(o.getExpectEndTime(), "hh:mm")); item.setEndTime(TimeUtils.timestamp2DateTime(o.getExpectEndTime(), "hh:mm"));
item.setType(o.getStatus()); item.setType(o.getStatus());
timelines.add(item); timelines.add(item);
} }
...@@ -181,7 +180,7 @@ public class ScheduleServiceImpl implements ScheduleService { ...@@ -181,7 +180,7 @@ public class ScheduleServiceImpl implements ScheduleService {
orders.add(item); orders.add(item);
} }
String groupName=""; String groupName = "";
OrgGroup group = this.queryOrgGroupInfo(engineer.getGroupId()); OrgGroup group = this.queryOrgGroupInfo(engineer.getGroupId());
if (group != null) { if (group != null) {
groupName = group.getGroupName(); groupName = group.getGroupName();
...@@ -225,8 +224,8 @@ public class ScheduleServiceImpl implements ScheduleService { ...@@ -225,8 +224,8 @@ public class ScheduleServiceImpl implements ScheduleService {
LambdaQueryWrapper<OrderRequest> lqw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<OrderRequest> lqw = new LambdaQueryWrapper<>();
lqw.in(OrderRequest::getOrgTeamId, teamId); lqw.in(OrderRequest::getOrgTeamId, teamId);
lqw.eq(OrderRequest::getAppointmentStatus, "ASSIGNED"); lqw.eq(OrderRequest::getAppointmentStatus, "ASSIGNED");
lqw.gt(OrderRequest::getExpectTimeBegin, this.getTimestampFromDate(date, "00:00:00")); lqw.ge(OrderRequest::getExpectTimeBegin, TimeUtils.IsoDateTime2Timestamp(String.format("%s 00:00:00", date)));
lqw.lt(OrderRequest::getExpectTimeBegin, this.getTimestampFromDate(date, "23:59:59")); lqw.le(OrderRequest::getExpectTimeBegin, TimeUtils.IsoDateTime2Timestamp(String.format("%s 23:59:59", date)));
return orderRequestMPDao.selectList(lqw); return orderRequestMPDao.selectList(lqw);
} }
...@@ -239,16 +238,16 @@ public class ScheduleServiceImpl implements ScheduleService { ...@@ -239,16 +238,16 @@ public class ScheduleServiceImpl implements ScheduleService {
private List<OrderAppointment> queryOrderAppointments(List<String> orderIds, String date) { private List<OrderAppointment> queryOrderAppointments(List<String> orderIds, String date) {
LambdaQueryWrapper<OrderAppointment> lqw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<OrderAppointment> lqw = new LambdaQueryWrapper<>();
lqw.in(OrderAppointment::getOrderId, orderIds); lqw.in(OrderAppointment::getOrderId, orderIds);
lqw.ge(OrderAppointment::getExpectStartTime, this.getTimestampFromDate(date, "00:00:00")); lqw.ge(OrderAppointment::getExpectStartTime, TimeUtils.IsoDateTime2Timestamp(String.format("%s 00:00:00", date)));
lqw.le(OrderAppointment::getExpectEndTime, this.getTimestampFromDate(date, "23:59:59")); lqw.le(OrderAppointment::getExpectEndTime, TimeUtils.IsoDateTime2Timestamp(String.format("%s 23:59:59", date)));
return orderAppointmentMPDao.selectList(lqw); return orderAppointmentMPDao.selectList(lqw);
} }
private List<OrderAppointment> queryOrderAppointmentsByEngineerCode(String engineerCode, String date) { private List<OrderAppointment> queryOrderAppointmentsByEngineerCode(String engineerCode, String date) {
LambdaQueryWrapper<OrderAppointment> lqw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<OrderAppointment> lqw = new LambdaQueryWrapper<>();
lqw.in(OrderAppointment::getEngineerCode, engineerCode); lqw.in(OrderAppointment::getEngineerCode, engineerCode);
lqw.ge(OrderAppointment::getExpectStartTime, this.getTimestampFromDate(date, "00:00:00")); lqw.ge(OrderAppointment::getExpectStartTime, TimeUtils.IsoDateTime2Timestamp(String.format("%s 00:00:00", date)));
lqw.le(OrderAppointment::getExpectEndTime, this.getTimestampFromDate(date, "23:59:59")); lqw.le(OrderAppointment::getExpectEndTime, TimeUtils.IsoDateTime2Timestamp(String.format("%s 23:59:59", date)));
return orderAppointmentMPDao.selectList(lqw); return orderAppointmentMPDao.selectList(lqw);
} }
...@@ -291,13 +290,4 @@ public class ScheduleServiceImpl implements ScheduleService { ...@@ -291,13 +290,4 @@ public class ScheduleServiceImpl implements ScheduleService {
item.setValue(value); item.setValue(value);
return item; return item;
} }
private Timestamp getTimestampFromDate(String date, String t) {
return Timestamp.valueOf(date + " " + t);
}
private String Timestamp2Datetime(Timestamp t, String pattern) {
DateTimeFormatter df = DateTimeFormatter.ofPattern(pattern);
return df.format(t.toLocalDateTime());
}
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!