Commit 9f28efa0 by chamberone

Merge branch 'develop' of https://zhangguoping@gitlab.dituhui.com/bsh/project/pr…

…oject.git into develop
2 parents f85dffad bd7e6e87
......@@ -3,13 +3,14 @@ package com.dituhui.pea.order.common;
import java.sql.Timestamp;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
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 TIME_HH_MM_FORMAT = "HH:mm";
public static final String IsoTimestamp2DateTime(Timestamp timestamp) {
// Timestamp转换为日期时间字符串
......@@ -51,6 +52,10 @@ public class TimeUtils {
return localDate.format(DateTimeFormatter.ofPattern(DATE_GAP_FORMAT));
}
public static final LocalTime time2LocalTime(String s) {
return LocalTime.parse(s, DateTimeFormatter.ofPattern(TIME_HH_MM_FORMAT));
}
public static final LocalDate addDays(LocalDate date, long days) {
return date.plusDays(days);
}
......
......@@ -132,8 +132,8 @@ public class EngineerController {
Result<?> res = null;
try {
res = engineerService.engineerBusinessUpdate(
req.getEngineerCode(), req.getMaxNum(), req.getMaxMinute(),
req.getDeparture(), req.getPriority());
req.getEngineerCode(), req.getMaxNum(), req.getDeparture(), req.getPriority(),
req.getWorkOn(), req.getWorkOff(), req.getTransportMode());
} catch (BusinessException e) {
return Result.failed(e.getMessage());
}
......
......@@ -17,12 +17,15 @@ public class EngineerBusinessListResp {
private String engineerCode;
private String engineerName;
private String groupName;
private String workOn;
private String workOff;
private String kind;
private Integer maxNum;
private Integer maxMinute;
private Integer priority;
private String address;
private String location;
private String transportMode;
private Integer departure;
}
}
......@@ -9,4 +9,7 @@ public class EngineerBusinessUpdateReqDTO {
private Integer maxMinute;
private Integer departure;
private Integer priority;
private String workOn;
private String workOff;
private String transportMode;
}
......@@ -8,12 +8,16 @@ import java.sql.Timestamp;
public class EngineerBusiness {
private Integer id;
private String engineerCode;
private String workOn;
private String workOff;
private Integer maxNum;
private Integer maxMinute;
private Integer maxDistance;
private String address;
private String x;
private String y;
private String vehicle;
private String vehicleNo;
private Integer priority;
private Integer departure;
private String memo;
......
......@@ -20,5 +20,7 @@ public interface EngineerService {
Result<?> getEngineerBusinessDetail(String engineerCode);
// 技术员业务属性配置修改
Result<?> engineerBusinessUpdate(String engineerCode, Integer maxNum, Integer maxMinute, Integer departure, Integer priority);
Result<?> engineerBusinessUpdate(
String engineerCode, Integer maxNum, Integer departure, Integer priority,
String workOn, String workOff, String transportMode);
}
......@@ -18,6 +18,9 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat;
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.*;
import java.util.stream.Collectors;
......@@ -202,15 +205,22 @@ public class EngineerServiceImpl implements EngineerService {
@Transactional
@Override
public Result<?> engineerBusinessUpdate(String engineerCode, Integer maxNum, Integer maxMinute, Integer departure, Integer priority) {
// 技术员业务属性配置修改
public Result<?> engineerBusinessUpdate(String engineerCode, Integer maxNum, Integer departure, Integer priority,
String workOn, String workOff, String transportMode) {
// 计算时间差
int minute = this.getMinuteDiff(TimeUtils.time2LocalTime(workOn), TimeUtils.time2LocalTime(workOff));
// 技术员业务属性配置修改
LambdaUpdateWrapper<EngineerBusiness> wrapper = new LambdaUpdateWrapper<>();
wrapper.eq(EngineerBusiness::getEngineerCode, engineerCode);
wrapper.set(maxNum >= 0, EngineerBusiness::getMaxNum, maxNum);
wrapper.set(maxMinute >= 0, EngineerBusiness::getMaxMinute, maxMinute);
wrapper.set(EngineerBusiness::getMaxNum, maxNum);
wrapper.set(EngineerBusiness::getDeparture, departure);
wrapper.set(EngineerBusiness::getPriority, priority);
wrapper.set(EngineerBusiness::getWorkOn, workOn);
wrapper.set(EngineerBusiness::getWorkOff, workOff);
wrapper.set(EngineerBusiness::getMaxMinute, minute);
wrapper.set(EngineerBusiness::getVehicle, transportMode);
// 更新字段
engineerBusinessDao.update(null, wrapper);
......@@ -398,28 +408,25 @@ public class EngineerServiceImpl implements EngineerService {
List<EngineerBusinessListResp.EngineerBusiness> items = new ArrayList<>();
for (EngineerInfo e : engineers) {
EngineerBusinessListResp.EngineerBusiness item = new EngineerBusinessListResp.EngineerBusiness();
EngineerBusiness b = buss.getOrDefault(e.getEngineerCode(), null);
if(b == null){
// 若没有配置,则不返回, 由同步程序初始化
continue;
}
item.setEngineerCode(e.getEngineerCode());
item.setGroupName(groupNames.getOrDefault(e.getGroupId(), ""));
item.setEngineerName(e.getName());
item.setKind((e.getKind() == 1) ? "fullJob" : "partJob");
EngineerBusiness b = buss.getOrDefault(e.getEngineerCode(), null);
if (b == null) {
item.setAddress("");
item.setLocation("");
item.setDeparture(1);
item.setMaxMinute(0);
item.setMaxNum(0);
item.setPriority(1);
} else {
item.setAddress(b.getAddress());
item.setLocation(String.format("%s,%s", b.getX(), b.getY()));
item.setWorkOn(b.getWorkOn());
item.setWorkOff(b.getWorkOff());
item.setTransportMode(b.getVehicle());
item.setDeparture(b.getDeparture());
item.setMaxMinute(b.getMaxMinute());
item.setMaxNum(b.getMaxNum());
item.setPriority(b.getPriority());
}
items.add(item);
}
return items;
......@@ -456,4 +463,20 @@ public class EngineerServiceImpl implements EngineerService {
return (age <= 0) ? "" : Integer.toString(age);
}
private int getMinuteDiff(LocalTime tBegin, LocalTime tEnd) {
int r = tBegin.compareTo(tEnd);
if (r == 0) {
return 0;
}
LocalDateTime dtBegin = LocalDateTime.of(LocalDateTime.now().toLocalDate(), tBegin);
LocalDateTime dtEnd;
if(r < 0) {
dtEnd = LocalDateTime.of(LocalDateTime.now().toLocalDate(), tEnd);
} else {
dtEnd = LocalDateTime.of(LocalDateTime.now().plusDays(1).toLocalDate(), tEnd);
}
Duration duration = Duration.between(dtBegin, dtEnd);
return (int) duration.toMinutes();
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!