Commit 7a80999c by 刘鑫

Merge branch 'develop' of https://gitlab.dituhui.com/bsh/project/project into develop

2 parents 26c2f36a f40775de
......@@ -27,7 +27,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
*/
@SpringBootApplication
@EnableScheduling
@EnableFeignClients(basePackages = {"com.dituhui.pea.user", "com.dituhui.pea.msg"})
@EnableFeignClients(basePackages = {"com.dituhui.pea.user", "com.dituhui.pea.msg", "com.dituhui.pea.bean"})
@Import(cn.hutool.extra.spring.SpringUtil.class)
public class DispatchServiceApplication {
......
......@@ -3,8 +3,12 @@ package com.dituhui.pea.dispatch.service.impl;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.nacos.common.utils.CollectionUtils;
import com.dituhui.pea.bean.AllotResultParam;
import com.dituhui.pea.bean.RemoteBeanApi;
import com.dituhui.pea.dispatch.dao.*;
import com.dituhui.pea.dispatch.entity.*;
import com.dituhui.pea.dispatch.pojo.Customer;
......@@ -25,6 +29,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Map;
......@@ -68,6 +73,9 @@ public class ExtractServiceImpl implements ExtractService {
@Autowired
private JdbcTemplate jdbcTemplate;
@Autowired
private RemoteBeanApi remoteBeanApi;
/**
* 将dispath_order 中的计算结果,回写到 order_info
......@@ -276,6 +284,18 @@ public class ExtractServiceImpl implements ExtractService {
orderInfoRepo.save(orderInfo);
if (cutOff) {
AllotResultParam allotResultParam = new AllotResultParam();
allotResultParam.setRisId(orderInfo.getOrderId());
allotResultParam.setExecutorWorkNo(orderInfo.getEngineerCode());
allotResultParam.setAssistantWorkNo(null);
allotResultParam.setReason("自动派单");
String format = "yyyy-MM-dd HH:mm:ss";
allotResultParam.setAppointmentStartTime(orderInfo.getPlanStartTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli());
allotResultParam.setAppointmentEndTime(orderInfo.getPlanEndTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli());
boolean result = remoteBeanApi.allotResultUpdate(allotResultParam);
log.info(">>> 【服务工单派单结果更新】请求参数:{}, 响应结果:{}", JSONObject.toJSON(allotResultParam), result);
OrderEvent orderEvent = new OrderEvent().setOrderId(orderId).setSuborderId(orderInfo.getSubId()).setHappen(LocalDateTime.now())
.setEvent("批量自动指派").setOperator("DISPATCH").setOperatorName("算法批量指派").setSource("PEA-DISPATCH")
.setDescription(String.format("批量自动指派:<%s,%s>", engCode, engName)).setMemo("")
......@@ -309,6 +329,7 @@ public class ExtractServiceImpl implements ExtractService {
orderInfo.setUpdateTime(LocalDateTime.now());
orderInfoRepo.save(orderInfo);
OrderLog orderLog = new OrderLog().setOrderId(orderId).setSuborderId(orderInfo.getSubId()).setSource("PEA-DISPATCH").setOperator("DISPATCH")
.setContent(String.format("批量自动指派:<%s,%s>", "", "抹掉技术员")).setContentOld("")
.setMemo("批量自动指派").setCreateTime(LocalDateTime.now()).setUpdateTime(LocalDateTime.now());
......
......@@ -3,7 +3,7 @@ server:
dispatch:
cron:
expr: 0 3 8-23 * * ?
expr: 0 57 8-23 * * ?
next-day-limit: 2
scheduler:
......
......@@ -23,6 +23,8 @@ public interface OrderInfoDao extends JpaRepository<OrderInfoEntity, Long>, JpaS
List<OrderInfoEntity> findByDtAndServiceStatusNotAndEngineerCodeIn(LocalDate date, String serviceSatus, List<String> engineerCodes);
List<OrderInfoEntity> findByDtAndServiceStatusNotAndEngineerCodeSubIn(LocalDate date, String serviceSatus, List<String> engineerCodes);
List<OrderInfoEntity> findByDtAndEngineerCode(LocalDate date, String engineerCode);
List<OrderInfoEntity> findByDtAndEngineerCodeSub(LocalDate date, String engineerCode);
......
......@@ -90,5 +90,10 @@ public class EngineersGanttDTO {
* 服务状态:INIT-初始化/PENDING待服务/CONTACTED已排期/STARTED-已开始/FINISHED已完成/UNFINISHED-已上门未完成
*/
private String serviceStatus;
/**
* 是否是辅助单
*/
private Boolean isSub = false;
}
}
......@@ -12,4 +12,9 @@ public class TimeLineDTO {
private String startTime;
private String endTime;
private List<LabelValueDTO> tips;
/**
* 是否是辅助单
*/
private Boolean isSub = false;
}
\ No newline at end of file
......@@ -266,7 +266,7 @@ public class OrderInfoEntity {
private LocalDateTime subPlanEndTime;
/**
* 辅助工程师在途时长
* 辅助工程师在途里面(米)
*/
@Column(name = "sub_distance", nullable = true, columnDefinition = "int(11) default '0'")
private Integer subDistance = 0;
......
......@@ -148,13 +148,14 @@ public class CalcOrgCapacityScheduler {
entity.setUpdateTime(LocalDateTime.now());
// todo entity.setOrderCount();
capacityOrgStatDao.save(entity);
if (dto.getCapTotal() > 0) {
double usedPercentage = (double) dto.getCapUsed() / dto.getCapTotal();
log.info("[calcOneBranch] {}小组容量已使用占比{}", groupId, usedPercentage);
if (BigDecimal.valueOf(usedPercentage).compareTo(new BigDecimal("0.8")) >= 0) {
addCapacityMsg("", "", groupId, LocalDate.parse(date, DateUtil.DATE_FORMATTER),
dto.getLayer(), dto.getLayerId());
}
}
}
}
......@@ -193,7 +194,7 @@ public class CalcOrgCapacityScheduler {
entity.setUpdateTime(LocalDateTime.now());
// todo entity.setOrderCount();
capacityOrgStatDao.save(entity);
if (dto.getCapTotal() > 0) {
double usedPercentage = (double) dto.getCapUsed() / dto.getCapTotal();
log.info("[calcOneBranch] {}分部容量已使用占比{}", branchId, usedPercentage);
if (BigDecimal.valueOf(usedPercentage).compareTo(new BigDecimal("0.8")) >= 0) {
......@@ -202,6 +203,7 @@ public class CalcOrgCapacityScheduler {
}
}
}
}
private void addCapacityMsg(String clusterId, String branchId, String groupId,
......
......@@ -53,6 +53,7 @@ public class BeanRemoteServiceImpl {
add("1575934912659275778");
}
};
private static List<String> qaaa = new ArrayList<>();
@Value("${bean.app-key}")
private String appKey;
......@@ -211,6 +212,7 @@ public class BeanRemoteServiceImpl {
log.info("开始同步人员信息{}", JsonUtil.toJson(account));
saveEngineerInfoByHrId(departId, account.getHrId(), account.getUserName());
}
System.out.println(qaaa);
}
/**
......@@ -231,11 +233,10 @@ public class BeanRemoteServiceImpl {
String engineerCode = userDetailInfo.getWorkNo();
if (StringUtils.isBlank(engineerCode)) {
log.warn("分站:{}工程师{}没有工号", departId, userDetailInfo.getUsername());
qaaa.add(userDetailInfo.getUsername());
return;
}
final Address address = userDetailInfo.getAddress();
//fixme 正式同步需移除当前逻辑
engineerCode = "BEAN" + engineerCode;
EngineerInfoEntity engineerInfo = getEngineerInfoEntity(departId, engineerCode, userDetailInfo, address);
engineerInfoDao.save(engineerInfo);
engineerInfoDao.flush();
......@@ -272,12 +273,13 @@ public class BeanRemoteServiceImpl {
//fixme 工作地址存贮
if (Objects.nonNull(address)) {
engineerInfo.setAddress(address.getAddress());
engineerInfo.setAddress(StringUtils.isNotBlank(address.getAddress()) ? address.getAddress() : "");
engineerInfo.setWorkAddress(address.getAddress());
engineerInfo.setWorkX(Objects.isNull(address.getLongitude()) ? "" : String.valueOf(address.getLongitude()));
engineerInfo.setWorkY(Objects.isNull(address.getLatitude()) ? "" : String.valueOf(address.getLatitude()));
} else {
engineerInfo.setWorkAddress("");
engineerInfo.setAddress("无");
engineerInfo.setWorkAddress("无");
}
engineerInfo.setCreateTime(LocalDateTime.now());
......
package com.dituhui.pea.order.service.impl;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import com.dituhui.pea.common.BusinessException;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.common.DateUtils;
......@@ -17,10 +18,7 @@ import com.dituhui.pea.order.dto.BusinessTeamDetailDTO;
import com.dituhui.pea.order.dto.BusinessTeamUpdateDTO;
import com.dituhui.pea.order.dto.BusinessTeamWarehousesDTO;
import com.dituhui.pea.order.dto.BusinessTeamsDTO;
import com.dituhui.pea.order.entity.OrgGroupEntity;
import com.dituhui.pea.order.entity.OrgTeamEngineerEntity;
import com.dituhui.pea.order.entity.OrgTeamEntity;
import com.dituhui.pea.order.entity.OrgWarehouseInfoEntity;
import com.dituhui.pea.order.entity.*;
import com.dituhui.pea.order.service.BusinessTeamService;
import com.dituhui.pea.order.service.CommonService;
import lombok.extern.slf4j.Slf4j;
......@@ -81,9 +79,14 @@ public class BusinessTeamServiceImpl implements BusinessTeamService {
page = orgTeamDao.findAllByGroupId(req.getLevelValue(), pageable);
}
for (OrgTeamEntity e : page.getContent()) {
List<String> engineers = orgTeamEngineerDao.findAllByTeamId(e.getTeamId()).stream().map(e2 -> {
return engineerInfoDao.getByEngineerCode(e2.getEngineerCode()).getName();
}).collect(Collectors.toList());
List<String> engineers = new ArrayList<>();
for (OrgTeamEngineerEntity e2 : orgTeamEngineerDao.findAllByTeamId(e.getTeamId())) {
EngineerInfoEntity infoEntity = engineerInfoDao.getByEngineerCode(e2.getEngineerCode());
if (ObjectUtil.isNull(infoEntity)) {
continue;
}
engineers.add(infoEntity.getName());
}
BusinessTeamsDTO.Content content = new BusinessTeamsDTO.Content();
content.setTeamId(e.getTeamId()).setTeamName(e.getTeamName());
content.setWorkdays(String.join("、", getWorkdaysChinese(e.getWorkdays())));
......
......@@ -124,7 +124,53 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
slots.sort(Comparator.comparing(EngineersGanttDTO.Slot::getBtime));
mapEngineers.put(order.getEngineerCode(), slots);
}
log.info("mapEngineers ===> {}", mapEngineers);
// 查询辅助工单
List<OrderInfoEntity> subOrders = orderInfoDao.findByDtAndServiceStatusNotAndEngineerCodeSubIn(localDate, ServiceStatusEnum.CANCELED.getCode(), engineerCodes);
HashMap<String, List<EngineersGanttDTO.Slot>> mapSubEngineers = new HashMap<>();
for (OrderInfoEntity order : subOrders) {
// 服务工单本体
EngineersGanttDTO.Slot slot = new EngineersGanttDTO.Slot();
// todo 需要根据订单时间和状态,采用expectXXXX或者actualXXXX
slot.setOrderId(order.getOrderId());
slot.setServiceStatus(OrderUtil.handleServiceStatus(order));
String startServiceStr = null;
slot.setBtime(getHourMinute(order.getSubPlanStartTime()));
slot.setEtime(getHourMinute(order.getSubPlanEndTime()));
slot.setTooltip(getOrderTips(order, startServiceStr));
OrderSkillProjection orderSkill = orderInfoDao.getOrderSkillCaptionByOrderIdAndDt(order.getOrderId(), localDate);
if (orderSkill != null) {
slot.setText(orderSkill.getSkillCaption());
}
slot.setBgColor(order.getAppointmentStatus());
List<EngineersGanttDTO.Slot> slots = null;
if (mapSubEngineers.containsKey(order.getEngineerCodeSub())) {
slots = mapSubEngineers.get(order.getEngineerCodeSub());
} else {
slots = new ArrayList<>();
}
slot.setBgColor(getColor(order.getServiceStatus()));
slot.setIsSub(true);
if (!order.getAppointmentStatus().equals(OrderFlowEnum.CONFIRM.name())) {
slot.setBorderStyle("dashed"); // 未确认的指派,统一加上虚框
}
// 有在途时长先计算在途时间
if (order.getSubElapsed() > 0 && order.getSubDistance() > 0) {
// 有在途,起止时间,分别是订单的开始时间减去在途时间、订单的开始时间
EngineersGanttDTO.Slot slot2 = new EngineersGanttDTO.Slot();
slot2.setBtime(getHourMinute(order.getSubPlanStartTime(), -order.getSubElapsed()));
slot2.setEtime(getHourMinute(order.getSubPlanStartTime()));
slot2.setShapeSize("mini");
slot2.setBgColor(getColor("ONWAY"));
slot2.setTooltip(getOnwayTips(order));
slot2.setIsSub(true);
slots.add(slot2);
}
slots.add(slot);
slots.sort(Comparator.comparing(EngineersGanttDTO.Slot::getBtime));
mapSubEngineers.put(order.getEngineerCodeSub(), slots);
}
List<EngineersGanttDTO.GanttChart> engineers = new ArrayList<>();
for (String engineerCode : engineerCodes) {
EngineerInfoEntity engineerInfo = engineerInfoDao.getByEngineerCode(engineerCode);
......@@ -148,9 +194,14 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
engineer.setCapTotal(capacityEngineerStat.getCapTotal().toString()).setCapUsed(capacityEngineerStat.getCapUsed().toString());
}
if (mapEngineers.containsKey(engineerCode)) {
engineer.setSlots(mapEngineers.get(engineerCode));
List<EngineersGanttDTO.Slot> slots = mapEngineers.get(engineerCode);
List<EngineersGanttDTO.Slot> slotsSub = mapSubEngineers.get(engineerCode);
if (CollectionUtils.isNotEmpty(slotsSub)) {
slots.addAll(slotsSub);
slots.sort(Comparator.comparing(EngineersGanttDTO.Slot::getBtime));
}
engineer.setSlots(slots);
}
// engineer.setErrorTip(); todo
engineers.add(engineer);
}
// 按技术员名称进行排序
......
......@@ -555,7 +555,7 @@ public class OrderInfoServiceImpl implements OrderInfoService {
seg.setDistance(orderInfo.getArriveDistance());
seg.setStart(orderInfo.getPlanStartTime());
seg.setEnd(orderInfo.getPlanEndTime());
if (StringUtils.isNotBlank(orderInfo.getEngineerCodeSub()) && orderInfo.getIsMultiple() == 1 && orderInfo.getEngineerCodeSub().equals(engineer.getEngineerCode())) {
if (OrderUtil.isSub(orderInfo, engineer.getEngineerCode())) {
seg.setIsSub(true);
seg.setElapsed(orderInfo.getSubElapsed());
seg.setDistance(orderInfo.getSubDistance());
......
......@@ -231,9 +231,11 @@ public class ScheduleServiceImpl implements ScheduleService {
Sort sort = Sort.by(Sort.Direction.valueOf(sortType.toUpperCase()), sortColumn);
//查询包含已取消在内所以工单,后续数据筛选只用预指派和确认指派数据
List<OrderInfoEntity> orderAppointmentsAll = orderInfoDao.findByDtAndEngineerCode(date, engineerCode, sort);
List<OrderInfoEntity> subOrders = orderInfoDao.findByDtAndEngineerCodeSub(date, engineerCode);
List<OrderInfoEntity> orderAppointments = orderAppointmentsAll.stream().filter(e -> (e.getAppointmentStatus()
.equals(OrderFlowEnum.PRE.name())) || e.getAppointmentStatus().equals(OrderFlowEnum.CONFIRM.name()))
.collect(Collectors.toList());
orderAppointments.addAll(subOrders);
List<TimeLineDTO> timelines = new ArrayList<>();
int sumDistance = 0;
int sumElapsed = 0;
......@@ -241,13 +243,21 @@ public class ScheduleServiceImpl implements ScheduleService {
TimeLineDTO item = new TimeLineDTO();
item.setOrderId(o.getOrderId());
item.setAppointmentStatus(o.getAppointmentStatus());
if (OrderUtil.isSub(o, engineerCode)) {
item.setIsSub(true);
item.setStartTime(TimeUtils.IsoLocalDateTime2String(o.getSubPlanStartTime()));
item.setEndTime(TimeUtils.IsoLocalDateTime2String(o.getSubPlanEndTime()));
sumDistance += Objects.isNull(o.getSubDistance()) ? 0 : o.getSubDistance();
sumElapsed += Objects.isNull(o.getSubElapsed()) ? 0 : o.getSubElapsed();
} else {
item.setStartTime(TimeUtils.IsoLocalDateTime2String(o.getPlanStartTime()));
item.setEndTime(TimeUtils.IsoLocalDateTime2String(o.getPlanEndTime()));
item.setTips(emptyTips);
timelines.add(item);
sumDistance += Objects.isNull(o.getArriveDistance()) ? 0 : o.getArriveDistance();
sumElapsed += Objects.isNull(o.getArriveElapsed()) ? 0 : o.getArriveElapsed();
}
item.setTips(emptyTips);
timelines.add(item);
}
String groupName = "";
OrgGroupEntity group = orgGroupDao.getByGroupId(engineer.getGroupId());
......
......@@ -29,6 +29,7 @@ public class OrderUtil {
order.setEngineerCode(null);
return order;
}
/**
* 分处理辅助工程师数据
*
......@@ -217,4 +218,17 @@ public class OrderUtil {
return tagList;
}
/**
* 分单,超派,特殊时间等处理工单指派工程师,网点等数据
*
* @return
*/
public static Boolean isSub(OrderInfoEntity orderInfo, String enginnerCode) {
if (StringUtils.isNotBlank(orderInfo.getEngineerCodeSub()) && orderInfo.getIsMultiple() == 1 && orderInfo.getEngineerCodeSub().equals(enginnerCode)) {
return true;
}
return false;
}
}
package com.dituhui.pea.order.common;
import cn.hutool.core.date.LocalDateTimeUtil;
import com.dituhui.pea.bean.AllotResultParam;
import com.dituhui.pea.common.BusinessException;
import com.dituhui.pea.order.OrderServiceApplication;
import com.dituhui.pea.order.common.jackson.JsonUtil;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!