Commit 4363ef22 by 丁伟峰

技术员日历、技术员甘特图剥离到独立的service实现中

1 parent 7217b709
...@@ -6,6 +6,8 @@ import com.dituhui.pea.order.dto.EngineerBusinessUpdateReqDTO; ...@@ -6,6 +6,8 @@ import com.dituhui.pea.order.dto.EngineerBusinessUpdateReqDTO;
import com.dituhui.pea.order.dto.EngineerCalendarDTO; import com.dituhui.pea.order.dto.EngineerCalendarDTO;
import com.dituhui.pea.order.dto.EngineerSkillUpdateReqDTO; import com.dituhui.pea.order.dto.EngineerSkillUpdateReqDTO;
import com.dituhui.pea.order.dto.EngineersGanttReqDTO; import com.dituhui.pea.order.dto.EngineersGanttReqDTO;
import com.dituhui.pea.order.service.EngineerCalendarService;
import com.dituhui.pea.order.service.EngineerGanttService;
import com.dituhui.pea.order.service.EngineerService; import com.dituhui.pea.order.service.EngineerService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -20,6 +22,12 @@ public class EngineerController { ...@@ -20,6 +22,12 @@ public class EngineerController {
@Autowired @Autowired
private EngineerService engineerService; private EngineerService engineerService;
@Autowired
private EngineerGanttService engineerGanttService;
@Autowired
private EngineerCalendarService engineerCalendarService;
@GetMapping("/engineer/info/list") @GetMapping("/engineer/info/list")
public Result<?> getEngineerInfoList(@RequestParam long page, @RequestParam long size) { public Result<?> getEngineerInfoList(@RequestParam long page, @RequestParam long size) {
// 获取工程师基础信息列表 // 获取工程师基础信息列表
...@@ -122,7 +130,7 @@ public class EngineerController { ...@@ -122,7 +130,7 @@ public class EngineerController {
log.info("getEngineersGanttList: {}", reqDTO); log.info("getEngineersGanttList: {}", reqDTO);
Result<?> res = null; Result<?> res = null;
try { try {
res = engineerService.getEngineersGanttList(reqDTO); res = engineerGanttService.getEngineersGanttList(reqDTO);
} catch (BusinessException e) { } catch (BusinessException e) {
return Result.failed(e.getMessage()); return Result.failed(e.getMessage());
} }
...@@ -133,7 +141,7 @@ public class EngineerController { ...@@ -133,7 +141,7 @@ public class EngineerController {
public Result<?> getEngineerCalendar(@Validated EngineerCalendarDTO.Request reqDTO) { public Result<?> getEngineerCalendar(@Validated EngineerCalendarDTO.Request reqDTO) {
Result<?> res = null; Result<?> res = null;
try { try {
res = engineerService.getEngineersCalendar(reqDTO); res = engineerCalendarService.getEngineersCalendar(reqDTO);
} catch (BusinessException e) { } catch (BusinessException e) {
return Result.failed(e.getMessage()); return Result.failed(e.getMessage());
} }
......
package com.dituhui.pea.order.service;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.dto.EngineerCalendarDTO;
public interface EngineerCalendarService {
Result<?> getEngineersCalendar(EngineerCalendarDTO.Request engineerCalendarReq);
}
package com.dituhui.pea.order.service;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.dto.EngineersGanttReqDTO;
public interface EngineerGanttService {
Result<?> getEngineersGanttList(EngineersGanttReqDTO ganttReqDTO);
}
...@@ -23,8 +23,4 @@ public interface EngineerService { ...@@ -23,8 +23,4 @@ public interface EngineerService {
// 技术员业务属性配置修改 // 技术员业务属性配置修改
Result<?> engineerBusinessUpdate(String engineerCode, Integer maxNum, Integer maxMutine, String departure, String priority); Result<?> engineerBusinessUpdate(String engineerCode, Integer maxNum, Integer maxMutine, String departure, String priority);
Result<?> getEngineersGanttList(EngineersGanttReqDTO ganttReqDTO);
Result<?> getEngineersCalendar(EngineerCalendarDTO.Request engineerCalendarReq);
} }
package com.dituhui.pea.order.service.impl;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.date.Week;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.common.EngineerUtil;
import com.dituhui.pea.order.dao.CapacityEngineerCalendarDao;
import com.dituhui.pea.order.dao.OrgTeamDao;
import com.dituhui.pea.order.dao.OrgTeamEngineerDao;
import com.dituhui.pea.order.dto.EngineerCalendarDTO;
import com.dituhui.pea.order.entity.CapacityEngineerCalendarEntity;
import com.dituhui.pea.order.entity.EngineerInfoEntity;
import com.dituhui.pea.order.entity.OrgTeamEntity;
import com.dituhui.pea.order.service.EngineerCalendarService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static com.dituhui.pea.order.config.OrderConfig.PATTERN_DATE;
import static com.dituhui.pea.order.config.OrderConfig.PATTERN_DATETIME;
@Slf4j
@Service
public class EngineerCalendarServiceImpl implements EngineerCalendarService {
@Autowired
private EngineerUtil engineerUtil;
@Autowired
private OrgTeamEngineerDao orgTeamEngineerDao;
@Autowired
private CapacityEngineerCalendarDao capacityEngineerCalendarDao;
@Autowired
private OrgTeamDao orgTeamDao;
@Override
public Result<?> getEngineersCalendar(EngineerCalendarDTO.Request req) {
// 技术员日历,查询 capacity_engineer_calendar表,如果当日有各种事项,进行显示;否则显示正常上班;
List<EngineerCalendarDTO.Engineer> engineers = new ArrayList<>();
List<EngineerInfoEntity> entities = engineerUtil.getEngineesByLevel(req.getLevelType(), req.getLevelValue());
String edate = LocalDate.parse(req.getDate()).plusDays(14).toString();
for (EngineerInfoEntity e : entities) {
EngineerCalendarDTO.Engineer engineer = new EngineerCalendarDTO.Engineer();
engineer.setEngineerCode(e.getEngineerCode());
engineer.setName(e.getName());
engineer.setCalendar(getOneEngineerCalendars(e.getEngineerCode(), req.getDate(), edate));
engineers.add(engineer);
}
EngineerCalendarDTO.Result rs = new EngineerCalendarDTO.Result();
rs.setEngineers(engineers);
return Result.success(rs);
}
private List<EngineerCalendarDTO.Calendar> getOneEngineerCalendars(String engineerCode, String bdate, String edate) {
// 返回某一个技术员,日期范围内的日历列表
List<EngineerCalendarDTO.Calendar> calendars = null;
List<String> teamIds = orgTeamEngineerDao.getTeamIdsByEngineerCode(engineerCode);
if (teamIds == null || teamIds.size() == 0) {
return new ArrayList<>();
}
LocalDate startDate = LocalDate.parse(bdate);
LocalDate endDate = LocalDate.parse(edate);
List<LocalDate> datesInRange = Stream.iterate(startDate, date -> date.plusDays(1))
.limit(ChronoUnit.DAYS.between(startDate, endDate.plusDays(1)))
.collect(Collectors.toList());
Map<String, List<CapacityEngineerCalendarEntity>> configs = capacityEngineerCalendarDao.findCalendarByEngineerCodeAndDateBetween(engineerCode, bdate, edate).stream()
.collect(Collectors.groupingBy(CapacityEngineerCalendarEntity::getWorkday));
for (LocalDate date : datesInRange) {
String sDate = LocalDateTimeUtil.format(date, PATTERN_DATE);
EngineerCalendarDTO.Calendar calander = null;
if (!configs.containsKey(sDate)) {
calander = getEmptyCalendar(teamIds.get(0), sDate);
} else {
calander = new EngineerCalendarDTO.Calendar();
calander.setDate(sDate);
int week = LocalDate.parse(sDate).getDayOfWeek().getValue();
calander.setWeek(Week.of(week).toChinese("周"));
List<EngineerCalendarDTO.Content> contents = new ArrayList<>();
// 有配置
for (CapacityEngineerCalendarEntity e : configs.get(sDate)) {
EngineerCalendarDTO.Content content = new EngineerCalendarDTO.Content();
content.setType("rest");
content.setTitle(e.getType());
content.setValue(getCalendarDuration(e.getStartTime(), e.getEndTime()));
}
calander.setContent(contents);
}
calendars.add(calander);
}
return calendars;
}
private String getCalendarDuration(LocalDateTime btime, LocalDateTime etime) {
String b2 = LocalDateTimeUtil.format(btime, PATTERN_DATETIME);
String e2 = LocalDateTimeUtil.format(etime, PATTERN_DATETIME);
return getCalendarDuration(b2, e2);
}
private String getCalendarDuration(String btime, String etime) {
LocalTime t1 = LocalTime.parse(btime);
LocalTime t2 = LocalTime.parse(etime);
Duration duration = Duration.between(t1, t2);
long hours = duration.toHours();
long minutes = duration.toMinutesPart();
if (minutes > 0 && hours == 0) {
return String.format("%d分钟", minutes);
} else if (minutes == 0 && hours > 0) {
return String.format("%d小时", hours);
} else {
return String.format("%d小时%d分钟", hours, minutes);
}
}
private EngineerCalendarDTO.Calendar getEmptyCalendar(String teamId, String date) {
// 初始化一天的日历
OrgTeamEntity e = orgTeamDao.getByTeamId(teamId);
EngineerCalendarDTO.Calendar calendar = new EngineerCalendarDTO.Calendar();
calendar.setDate(date);
int week = LocalDate.parse(date).getDayOfWeek().getValue();
EngineerCalendarDTO.Content content = new EngineerCalendarDTO.Content();
List<String> workdays = Arrays.asList(e.getWorkdays().split(","));
if (workdays.contains(String.valueOf(week))) {
content.setType("woring");
content.setTitle(String.format("日常出勤 %s-%s", e.getWorkOn(), e.getWorkOff()));
content.setValue(getCalendarDuration(e.getWorkOn(), e.getWorkOff()));
} else {
content.setType("rest");
content.setTitle("休息");
}
calendar.setContent(Collections.singletonList(content));
return calendar;
}
}
package com.dituhui.pea.order.service.impl;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.dao.CapacityEngineerStatDao;
import com.dituhui.pea.order.dao.EngineerInfoDao;
import com.dituhui.pea.order.dao.OrderAppointmentDao;
import com.dituhui.pea.order.dao.OrderRequestDao;
import com.dituhui.pea.order.dto.EngineersGanttReqDTO;
import com.dituhui.pea.order.dto.EngineersGanttRespDTO;
import com.dituhui.pea.order.dto.LabelValueDTO;
import com.dituhui.pea.order.entity.CapacityEngineerStatEntity;
import com.dituhui.pea.order.entity.EngineerInfoEntity;
import com.dituhui.pea.order.entity.OrderAppointmentEntity;
import com.dituhui.pea.order.entity.OrderRequestEntity;
import com.dituhui.pea.order.service.EngineerGanttService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Slf4j
@Service
public class EngineerGanttServiceImpl implements EngineerGanttService {
@Autowired
private OrderAppointmentDao orderAppointmentDao;
@Autowired
private CapacityEngineerStatDao capacityEngineerStatDao;
@Autowired
private EngineerInfoDao engineerInfoDao;
@Autowired
private OrderRequestDao orderRequestDao;
@Override
public Result<?> getEngineersGanttList(EngineersGanttReqDTO reqDTO) {
// 按日期返回技术员们当天的服务甘特图,不需要翻页
log.info("getEngineersGanttList: {}", reqDTO);
List<OrderAppointmentEntity> orderAppointments = orderAppointmentDao.findByDateAndEngineerCodeIn(reqDTO.getDate(), reqDTO.getEngineerCodes());
List<String> orderIds = orderAppointments.stream().map(OrderAppointmentEntity::getOrderId).collect(Collectors.toList());
Map<String, OrderRequestEntity> mapOrderRequest = getOrdersByOrderIds(orderIds);
HashMap<String, List<EngineersGanttRespDTO.Order>> mapEngineers = new HashMap<>();
for (OrderAppointmentEntity e : orderAppointments) {
log.info("===== order_id: [{}]", e.getOrderId());
EngineersGanttRespDTO.Order order = new EngineersGanttRespDTO.Order();
// todo 需要根据订单时间和状态,采用expectXXXX或者actualXXXX
order.setStartTime(e.getExpectStartTime()).setEndTime(e.getExpectEndTime());
order.setOrderId(e.getOrderId()).setPreStatus(e.getPreStatus());
order.setTips(getOrderTips(e.getOrderId()));
order.setAppointmentStatus(mapOrderRequest.get(e.getOrderId()).getAppointmentStatus());
List<EngineersGanttRespDTO.Order> orders = null;
if (mapEngineers.containsKey(e.getEngineerCode())) {
orders = mapEngineers.get(e.getEngineerCode());
} else {
orders = new ArrayList<>();
}
orders.add(order);
mapEngineers.put(e.getEngineerCode(), orders);
}
List<EngineersGanttRespDTO.GanttChart> engineers = new ArrayList<>();
for (String engineerCode : reqDTO.getEngineerCodes()) {
EngineerInfoEntity engineerInfo = engineerInfoDao.getByEngineerCode(engineerCode);
EngineersGanttRespDTO.GanttChart engineer = new EngineersGanttRespDTO.GanttChart();
engineer.setEngineerCode(engineerCode)
.setStartTime(String.format("%s 08:00", reqDTO.getDate()))
.setEndTime(String.format("%s 18:00", reqDTO.getDate()))
.setHoliday(false) // todo
.setEngineerName(engineerInfo.getName())
.setGrade(engineerInfo.getGrade());
CapacityEngineerStatEntity capacityEngineerStat = capacityEngineerStatDao.getByEngineerCodeAndWorkday(engineerCode, reqDTO.getDate());
if (capacityEngineerStat == null) {
log.warn("技术员当日的容量数据不存在,{}{}", engineerCode, reqDTO.getDate());
} else {
engineer.setCapTotal(capacityEngineerStat.getCapTotal().toString()).setCapUsed(capacityEngineerStat.getCapUsed().toString());
}
if (mapEngineers.containsKey(engineerCode)) {
engineer.setOrders(mapEngineers.get(engineerCode));
}
// engineer.setErrorTip(); todo
engineers.add(engineer);
}
EngineersGanttRespDTO data = new EngineersGanttRespDTO().setDate(reqDTO.getDate()).setEngineers(engineers);
return Result.success(data);
}
public Map<String, OrderRequestEntity> getOrdersByOrderIds(List<String> orderIds) {
List<OrderRequestEntity> orders = orderRequestDao.findAllByOrderIdIn(orderIds);
return orders.stream()
.collect(Collectors.toMap(OrderRequestEntity::getOrderId, order -> order));
}
private List<?> getOrderTips(String orderId) {
log.info("==> getOrderTips: orderId[{}]", orderId);
OrderRequestEntity order = orderRequestDao.getByOrderId(orderId);
if (order == null) {
log.error("对应的订单不存在!{}", orderId);
return null;
}
List<LabelValueDTO> tips = new ArrayList<>();
tips.add(new LabelValueDTO().setLabel("工单号码").setValue(orderId));
tips.add(new LabelValueDTO().setLabel("类型/品牌").setValue(String.format("%s %s", order.getBrand(), order.getType())));
tips.add(new LabelValueDTO().setLabel("电话/地址").setValue(String.format("%s %s\n %s", order.getName(), order.getPhone(), order.getAddress())));
if (StringUtils.isNotBlank(order.getApplyNote())) {
tips.add(new LabelValueDTO().setLabel("备注").setValue(order.getApplyNote()));
}
tips.add(new LabelValueDTO().setLabel("标签").setValue(order.getTags()));
return tips;
}
}
...@@ -486,186 +486,5 @@ public class EngineerServiceImpl implements EngineerService { ...@@ -486,186 +486,5 @@ public class EngineerServiceImpl implements EngineerService {
return df.format(t.toLocalDateTime()); return df.format(t.toLocalDateTime());
} }
@Override
public Result<?> getEngineersGanttList(EngineersGanttReqDTO reqDTO) {
// 按日期返回技术员们当天的服务甘特图,不需要翻页
log.info("getEngineersGanttList: {}", reqDTO);
List<OrderAppointmentEntity> orderAppointments = orderAppointmentDao.findByDateAndEngineerCodeIn(reqDTO.getDate(), reqDTO.getEngineerCodes());
List<String> orderIds = orderAppointments.stream().map(OrderAppointmentEntity::getOrderId).collect(Collectors.toList());
Map<String, OrderRequestEntity> mapOrderRequest = getOrdersByOrderIds(orderIds);
HashMap<String, List<EngineersGanttRespDTO.Order>> mapEngineers = new HashMap<>();
for (OrderAppointmentEntity e : orderAppointments) {
log.info("===== order_id: [{}]", e.getOrderId());
EngineersGanttRespDTO.Order order = new EngineersGanttRespDTO.Order();
// todo 需要根据订单时间和状态,采用expectXXXX或者actualXXXX
order.setStartTime(e.getExpectStartTime()).setEndTime(e.getExpectEndTime());
order.setOrderId(e.getOrderId()).setPreStatus(e.getPreStatus());
order.setTips(getOrderTips(e.getOrderId()));
order.setAppointmentStatus(mapOrderRequest.get(e.getOrderId()).getAppointmentStatus());
List<EngineersGanttRespDTO.Order> orders = null;
if (mapEngineers.containsKey(e.getEngineerCode())) {
orders = mapEngineers.get(e.getEngineerCode());
} else {
orders = new ArrayList<>();
}
orders.add(order);
mapEngineers.put(e.getEngineerCode(), orders);
}
List<EngineersGanttRespDTO.GanttChart> engineers = new ArrayList<>();
for (String engineerCode : reqDTO.getEngineerCodes()) {
EngineerInfoEntity engineerInfo = engineerInfoDao.getByEngineerCode(engineerCode);
EngineersGanttRespDTO.GanttChart engineer = new EngineersGanttRespDTO.GanttChart();
engineer.setEngineerCode(engineerCode)
.setStartTime(String.format("%s 08:00", reqDTO.getDate()))
.setEndTime(String.format("%s 18:00", reqDTO.getDate()))
.setHoliday(false) // todo
.setEngineerName(engineerInfo.getName())
.setGrade(engineerInfo.getGrade());
CapacityEngineerStatEntity capacityEngineerStat = capacityEngineerStatDao.getByEngineerCodeAndWorkday(engineerCode, reqDTO.getDate());
if (capacityEngineerStat == null) {
log.warn("技术员当日的容量数据不存在,{}{}", engineerCode, reqDTO.getDate());
} else {
engineer.setCapTotal(capacityEngineerStat.getCapTotal().toString()).setCapUsed(capacityEngineerStat.getCapUsed().toString());
}
if (mapEngineers.containsKey(engineerCode)) {
engineer.setOrders(mapEngineers.get(engineerCode));
}
// engineer.setErrorTip(); todo
engineers.add(engineer);
}
EngineersGanttRespDTO data = new EngineersGanttRespDTO().setDate(reqDTO.getDate()).setEngineers(engineers);
return Result.success(data);
}
@Override
public Result<?> getEngineersCalendar(EngineerCalendarDTO.Request req) {
// 技术员日历,查询 capacity_engineer_calendar表,如果当日有各种事项,进行显示;否则显示正常上班;
List<EngineerCalendarDTO.Engineer> engineers = new ArrayList<>();
List<EngineerInfoEntity> entities = engineerUtil.getEngineesByLevel(req.getLevelType(), req.getLevelValue());
String edate = LocalDate.parse(req.getDate()).plusDays(14).toString();
for (EngineerInfoEntity e : entities) {
EngineerCalendarDTO.Engineer engineer = new EngineerCalendarDTO.Engineer();
engineer.setEngineerCode(e.getEngineerCode());
engineer.setName(e.getName());
engineer.setCalendar(getOneEngineerCalendars(e.getEngineerCode(), req.getDate(), edate));
engineers.add(engineer);
}
EngineerCalendarDTO.Result rs = new EngineerCalendarDTO.Result();
rs.setEngineers(engineers);
return Result.success(rs);
}
public Map<String, OrderRequestEntity> getOrdersByOrderIds(List<String> orderIds) {
List<OrderRequestEntity> orders = orderRequestDao.findAllByOrderIdIn(orderIds);
return orders.stream()
.collect(Collectors.toMap(OrderRequestEntity::getOrderId, order -> order));
}
private List<?> getOrderTips(String orderId) {
log.info("==> getOrderTips: orderId[{}]", orderId);
OrderRequestEntity order = orderRequestDao.getByOrderId(orderId);
if (order == null) {
log.error("对应的订单不存在!{}", orderId);
return null;
}
List<LabelValueDTO> tips = new ArrayList<>();
tips.add(new LabelValueDTO().setLabel("工单号码").setValue(orderId));
tips.add(new LabelValueDTO().setLabel("类型/品牌").setValue(String.format("%s %s", order.getBrand(), order.getType())));
tips.add(new LabelValueDTO().setLabel("电话/地址").setValue(String.format("%s %s\n %s", order.getName(), order.getPhone(), order.getAddress())));
if (StringUtils.isNotBlank(order.getApplyNote())) {
tips.add(new LabelValueDTO().setLabel("备注").setValue(order.getApplyNote()));
}
tips.add(new LabelValueDTO().setLabel("标签").setValue(order.getTags()));
return tips;
}
private List<EngineerCalendarDTO.Calendar> getOneEngineerCalendars(String engineerCode, String bdate, String edate) {
// 返回某一个技术员,日期范围内的日历列表
List<EngineerCalendarDTO.Calendar> calendars = null;
List<String> teamIds = orgTeamEngineerDao.getTeamIdsByEngineerCode(engineerCode);
if (teamIds == null || teamIds.size() == 0) {
return new ArrayList<>();
}
LocalDate startDate = LocalDate.parse(bdate);
LocalDate endDate = LocalDate.parse(edate);
List<LocalDate> datesInRange = Stream.iterate(startDate, date -> date.plusDays(1))
.limit(ChronoUnit.DAYS.between(startDate, endDate.plusDays(1)))
.collect(Collectors.toList());
Map<String, List<CapacityEngineerCalendarEntity>> configs = capacityEngineerCalendarDao.findCalendarByEngineerCodeAndDateBetween(engineerCode, bdate, edate).stream()
.collect(Collectors.groupingBy(CapacityEngineerCalendarEntity::getWorkday));
for (LocalDate date : datesInRange) {
String sDate = LocalDateTimeUtil.format(date, PATTERN_DATE);
EngineerCalendarDTO.Calendar calander = null;
if (!configs.containsKey(sDate)) {
calander = getEmptyCalendar(teamIds.get(0), sDate);
} else {
calander = new EngineerCalendarDTO.Calendar();
calander.setDate(sDate);
int week = LocalDate.parse(sDate).getDayOfWeek().getValue();
calander.setWeek(Week.of(week).toChinese("周"));
List<EngineerCalendarDTO.Content> contents = new ArrayList<>();
// 有配置
for (CapacityEngineerCalendarEntity e : configs.get(sDate)) {
EngineerCalendarDTO.Content content = new EngineerCalendarDTO.Content();
content.setType("rest");
content.setTitle(e.getType());
content.setValue(getCalendarDuration(e.getStartTime(), e.getEndTime()));
}
calander.setContent(contents);
}
calendars.add(calander);
}
return calendars;
}
private String getCalendarDuration(LocalDateTime btime, LocalDateTime etime) {
String b2 = LocalDateTimeUtil.format(btime, PATTERN_DATETIME);
String e2 = LocalDateTimeUtil.format(etime, PATTERN_DATETIME);
return getCalendarDuration(b2, e2);
}
private String getCalendarDuration(String btime, String etime) {
LocalTime t1 = LocalTime.parse(btime);
LocalTime t2 = LocalTime.parse(etime);
Duration duration = Duration.between(t1, t2);
long hours = duration.toHours();
long minutes = duration.toMinutesPart();
if (minutes > 0 && hours == 0) {
return String.format("%d分钟", minutes);
} else if (minutes == 0 && hours > 0) {
return String.format("%d小时", hours);
} else {
return String.format("%d小时%d分钟", hours, minutes);
}
}
private EngineerCalendarDTO.Calendar getEmptyCalendar(String teamId, String date) {
// 初始化一天的日历
OrgTeamEntity e = orgTeamDao.getByTeamId(teamId);
EngineerCalendarDTO.Calendar calendar = new EngineerCalendarDTO.Calendar();
calendar.setDate(date);
int week = LocalDate.parse(date).getDayOfWeek().getValue();
EngineerCalendarDTO.Content content = new EngineerCalendarDTO.Content();
List<String> workdays = Arrays.asList(e.getWorkdays().split(","));
if (workdays.contains(String.valueOf(week))) {
content.setType("woring");
content.setTitle(String.format("日常出勤 %s-%s", e.getWorkOn(), e.getWorkOff()));
content.setValue(getCalendarDuration(e.getWorkOn(), e.getWorkOff()));
} else {
content.setType("rest");
content.setTitle("休息");
}
calendar.setContent(Collections.singletonList(content));
return calendar;
}
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!