Commit 97be5dc6 by 张晓

资源文件夹内文件读取调整

2 parents 1fbbd566 a662680b
Showing with 369 additions and 260 deletions
......@@ -72,6 +72,18 @@
<artifactId>optaplanner-core</artifactId>
<version>${version.org.optaplanner}</version>
</dependency>
<dependency>
<groupId>org.optaplanner</groupId>
<artifactId>optaplanner-persistence-jackson</artifactId>
<version>${version.org.optaplanner}</version>
</dependency>
<!-- Testing -->
<dependency>
<groupId>org.optaplanner</groupId>
<artifactId>optaplanner-test</artifactId>
<scope>test</scope>
<version>${version.org.optaplanner}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
......
package com.dituhui.pea.dispatch.pojo;
import org.optaplanner.core.api.domain.entity.PlanningEntity;
import org.optaplanner.core.api.domain.variable.InverseRelationShadowVariable;
import org.optaplanner.core.api.domain.variable.ShadowVariable;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import org.optaplanner.core.api.domain.variable.InverseRelationShadowVariable;
import lombok.Getter;
import lombok.Setter;
/**
* 订单
......@@ -14,13 +15,14 @@ import org.optaplanner.core.api.domain.variable.InverseRelationShadowVariable;
* @author gpzhang
*
*/
@Data
@Setter
@Getter
@PlanningEntity
public class Customer {
private long id;
private String code;
@JsonIgnore
@JsonIgnore
private Location location;
// 时间窗 分钟
private int startTime;
......@@ -30,11 +32,11 @@ public class Customer {
private String requiredSkill;
// Shadow variables
@JsonIgnore
@JsonIgnore
private Technician technician;
@JsonIgnore
@JsonIgnore
private Customer previousCustomer;
@JsonIgnore
@JsonIgnore
private Customer nextCustomer;
// 到达时间
private Integer arrivalTime;
......@@ -44,7 +46,8 @@ public class Customer {
public Customer() {
}
public Customer(long id, String code, Location location, int startTime, int endTime, String requiredSkill, int serviceDuration) {
public Customer(long id, String code, Location location, int startTime, int endTime, String requiredSkill,
int serviceDuration) {
this.id = id;
this.code = code;
this.location = location;
......@@ -145,4 +148,25 @@ public class Customer {
return previousCustomer.getLocation().getPathTimeTo(location);
}
@Override
public int hashCode() {
return Long.valueOf(this.id).hashCode();
}
@Override
public boolean equals(Object obj) {
if (obj == null)
return false;
if (!(obj instanceof Customer))
return false;
if (obj == this)
return true;
return this.id == ((Customer) obj).getId();
}
@Override
public String toString() {
return "Customer{" + "id=" + id + '}';
}
}
......@@ -36,15 +36,6 @@ public class Location {
this.latitude = latitude;
}
@Override
public String toString() {
return "Location{" +
"code='" + code + '\'' +
", type='" + type + '\'' +
", latitude=" + latitude +
", longitude=" + longitude +
'}';
}
/**
......@@ -98,4 +89,15 @@ public class Location {
}
@Override
public String toString() {
return "Location{" +
"code='" + code + '\'' +
", type='" + type + '\'' +
", latitude=" + latitude +
", longitude=" + longitude +
'}';
}
}
This diff could not be displayed because it is too large.
......@@ -92,6 +92,16 @@
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.7.5</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
</dependencies>
<build>
......
package com.dituhui.pea.order;
import com.dituhui.pea.order.interceptor.RequestInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@EnableJpaRepositories
@Configuration
public class WebConfig implements WebMvcConfigurer {
@Autowired
private RequestInterceptor requestInterceptor;
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(requestInterceptor).addPathPatterns("/**");
}
}
......@@ -118,7 +118,6 @@ public class EngineerController {
@PostMapping(value = "/engineer/schedule/gantt")
public Result<?> getEngineersGanttList(@Validated @RequestBody EngineersGanttReqDTO reqDTO) {
// todo 待移到 controller的engineer中
log.info("getEngineersGanttList: {}", reqDTO);
Result<?> res = null;
try {
......
package com.dituhui.pea.order.controller;
import com.dituhui.pea.common.Result;
import org.springframework.validation.BindException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;
@RestControllerAdvice
public class GlobalExceptionHandler {
@ExceptionHandler(BindException.class)
@ResponseBody
public Result<?> handleBindException(BindException e) {
// 处理 BindException 异常并返回自定义错误信息
return Result.failed("Invalid request parameters");
}
@ExceptionHandler(Exception.class)
@ResponseBody
public Result<?> handleException(Exception e) {
return Result.failed(e.getMessage());
}
}
......@@ -22,7 +22,7 @@ public class ScheduleController {
public Result<?> getScheduleOverview(@RequestParam long page, @RequestParam long size, @RequestParam String date,
@RequestParam String levelType, @RequestParam("levelValue") List<String> levelIds) {
Result<?> res = null;
try{
try {
res = scheduleService.getScheduleOverview(page, size, date, levelType, levelIds);
} catch (BusinessException e) {
return Result.failed(e.getMessage());
......
......@@ -8,6 +8,7 @@ import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.time.LocalDate;
import java.util.Date;
@Repository
......@@ -15,12 +16,12 @@ import java.util.Date;
public interface OrderChangeDao extends JpaRepository<OrderChangeEntity, Integer> {
@Query("select a from OrderChangeEntity a join OrderRequestEntity b on a.orderId=b.orderId where b.orgClusterId = :clusterId and Date(a.createTime) = :date")
Page<OrderChangeEntity> findAllByClusterId(String clusterId, Date date, Pageable pageable);
Page<OrderChangeEntity> findAllByClusterId(String clusterId, LocalDate date, Pageable pageable);
@Query("select a from OrderChangeEntity a join OrderRequestEntity b on a.orderId=b.orderId where b.orgBranchId = :branchId and Date(a.createTime) = :date")
Page<OrderChangeEntity> findAllByBranchId(String branchId, Date date, Pageable pageable);
Page<OrderChangeEntity> findAllByBranchId(String branchId, LocalDate date, Pageable pageable);
@Query("select a from OrderChangeEntity a join OrderRequestEntity b on a.orderId=b.orderId where b.orgGroupId = :groupId and Date(a.createTime) = :date")
Page<OrderChangeEntity> findAllByGroupId(String groupId, Date date, Pageable pageable);
Page<OrderChangeEntity> findAllByGroupId(String groupId, LocalDate date, Pageable pageable);
}
package com.dituhui.pea.order.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import lombok.experimental.Accessors;
import java.util.Date;
import java.time.LocalDateTime;
import java.util.List;
@lombok.Data
@Accessors(chain = true)
public class CapacityStatQueryRespDTO {
private List<?> content;
private List<Content> content;
private String levelType;
private long pageCurrent;
private long pages;
......@@ -21,13 +26,22 @@ public class CapacityStatQueryRespDTO {
private long capAdjust;
private long capTotal;
private long capUsed;
private Date updateTime;
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonSerialize(using = LocalDateTimeSerializer.class)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime updateTime;
private String date;
private long engineerNum;
private String levelType;
private String levelValue;
private String layer;
private String showName;
public Content(){
updateTime = LocalDateTime.now();
}
}
}
......
package com.dituhui.pea.order.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import lombok.experimental.Accessors;
import java.util.Date;
import java.time.LocalDateTime;
import java.util.List;
@lombok.Data
......@@ -65,13 +70,17 @@ public class EngineersGanttRespDTO {
/**
* 开始时间
*/
// @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date startTime;
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonSerialize(using = LocalDateTimeSerializer.class)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime startTime;
/**
* 结束时间
*/
// @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date endTime;
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonSerialize(using = LocalDateTimeSerializer.class)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime endTime;
/**
* 鼠标悬停提示
*/
......
package com.dituhui.pea.order.dto;
import com.dituhui.pea.order.config.OrderConfig;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
import java.time.LocalDate;
import java.time.LocalDateTime;
@lombok.Data
public class OrderChangeListReqDTO {
......@@ -17,8 +23,11 @@ public class OrderChangeListReqDTO {
private String levelValue;
private int page = OrderConfig.DEFAULT_PAGE_INDEX;
private int size = OrderConfig.DEFAULT_PAGE_SIZE;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date date = new Date();
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonSerialize(using = LocalDateTimeSerializer.class)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDate date = LocalDate.now();
/**
* 排序
*/
......
package com.dituhui.pea.order.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
import java.util.List;
@lombok.Data
......@@ -39,6 +45,9 @@ public class OrderChangeListRespDTO {
/**
* 更新时间
*/
private String updateTime;
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonSerialize(using = LocalDateTimeSerializer.class)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime updateTime;
}
}
......@@ -3,6 +3,7 @@ package com.dituhui.pea.order.entity;
import lombok.Data;
import java.sql.Timestamp;
import java.time.LocalDateTime;
@Data
public class CapacityEngineerStat {
......
......@@ -3,6 +3,7 @@ package com.dituhui.pea.order.entity;
import lombok.Data;
import javax.persistence.*;
import java.time.LocalDateTime;
import java.util.Date;
@Data
......@@ -62,10 +63,10 @@ public class CapacityEngineerStatEntity {
/**
* 创建时间
*/
private Date createTime;
private LocalDateTime createTime;
/**
* 更新时间
*/
private Date updateTime;
private LocalDateTime updateTime;
}
......@@ -3,6 +3,7 @@ package com.dituhui.pea.order.entity;
import lombok.Data;
import javax.persistence.*;
import java.time.LocalDateTime;
import java.util.Date;
@Data
......@@ -67,11 +68,11 @@ public class CapacityOrgStatEntity {
/**
* 创建时间
*/
private Date createTime;
private LocalDateTime createTime;
/**
* 更新时间
*/
private Date updateTime;
private LocalDateTime updateTime;
}
......@@ -4,6 +4,7 @@ import lombok.Data;
import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
@Entity
......@@ -57,9 +58,9 @@ public class CapacityTeamStatEntity implements Serializable {
private String memo;
private Date createTime;
private LocalDateTime createTime;
private Date updateTime;
private LocalDateTime updateTime;
}
......@@ -3,6 +3,7 @@ package com.dituhui.pea.order.entity;
import lombok.Data;
import javax.persistence.*;
import java.time.LocalDateTime;
import java.util.Date;
@Data
......@@ -99,12 +100,12 @@ public class EngineerInfoEntity {
/**
* 创建时间
*/
private Date createTime;
private LocalDateTime createTime;
/**
* 更新时间
*/
private Date updateTime;
private LocalDateTime updateTime;
public EngineerInfoEntity() {}
}
......@@ -4,6 +4,7 @@ import lombok.Data;
import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
@Entity
......@@ -78,12 +79,12 @@ public class MapBlockInfoEntity {
/**
* 创建时间
*/
private Date createTime;
private LocalDateTime createTime;
/**
* 更新时间
*/
private Date updateTime;
private LocalDateTime updateTime;
public MapBlockInfoEntity() {}
}
......@@ -3,7 +3,8 @@ package com.dituhui.pea.order.entity;
import lombok.Data;
import javax.persistence.*;
import java.util.Date;
import java.time.LocalDate;
import java.time.LocalDateTime;
@Data
@Entity
......@@ -58,25 +59,30 @@ public class OrderAppointmentEntity {
private Integer isWorkshop;
/**
* 预约日期
*/
private LocalDate dt;
/**
* 客户预约上门时间
*/
private Date expectStartTime;
private LocalDateTime expectStartTime;
private Date expectEndTime;
private LocalDateTime expectEndTime;
/**
* 实际上门时间
*/
private Date actualTime;
private LocalDateTime actualTime;
/**
* 开始服务时间
*/
private Date actualStartTime;
private LocalDateTime actualStartTime;
/**
* 结束服务时间
*/
private Date actualEndTime;
private LocalDateTime actualEndTime;
/**
* pre-预排班/confirm-已确认
......@@ -96,11 +102,11 @@ public class OrderAppointmentEntity {
/**
* 创建时间
*/
private Date createTime;
private LocalDateTime createTime;
/**
* 更新时间
*/
private Date updateTime;
private LocalDateTime updateTime;
}
......@@ -4,6 +4,7 @@ import lombok.Data;
import lombok.experimental.Accessors;
import javax.persistence.*;
import java.time.LocalDateTime;
import java.util.Date;
......@@ -57,12 +58,12 @@ public class OrderChangeEntity {
/**
* 创建时间
*/
private Date createTime;
private LocalDateTime createTime;
/**
* 创建时间
*/
private Date updateTime;
private LocalDateTime updateTime;
public OrderChangeEntity() {}
}
......@@ -19,7 +19,8 @@ package com.dituhui.pea.order.entity;
import lombok.Data;
import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime;
@Entity
@Data
......@@ -43,8 +44,9 @@ public class OrderRequestEntity {
private String skill;
private String applyNote;
private String faultDescribe;
private String expectTimeBegin;
private String expectTimeEnd;
private LocalDate dt;
private LocalDateTime expectTimeBegin;
private LocalDateTime expectTimeEnd;
private String expectTimeDesc;
private String source;
private String areaId;
......@@ -64,6 +66,6 @@ public class OrderRequestEntity {
private String orgTeamId;
private String orgTeamName;
private String description;
private String createTime;
private String updateTime;
private LocalDateTime createTime;
private LocalDateTime updateTime;
}
......@@ -3,6 +3,7 @@ package com.dituhui.pea.order.entity;
import lombok.Data;
import javax.persistence.*;
import java.time.LocalDateTime;
import java.util.Date;
@Entity
......@@ -18,6 +19,6 @@ public class OrderTagStrategyEntity {
private Integer priority;
private Integer disabled;
private String memo;
private Date createTime;
private Date updateTime;
private LocalDateTime createTime;
private LocalDateTime updateTime;
}
......@@ -3,6 +3,7 @@ package com.dituhui.pea.order.entity;
import lombok.Data;
import javax.persistence.*;
import java.time.LocalDateTime;
import java.util.Date;
@Entity
......@@ -44,10 +45,10 @@ public class OrgBranchEntity {
private String memo;
private Date createTime;
private LocalDateTime createTime;
private Date updateTime;
private LocalDateTime updateTime;
public OrgBranchEntity() {}
}
......@@ -3,6 +3,7 @@ package com.dituhui.pea.order.entity;
import lombok.Data;
import javax.persistence.*;
import java.time.LocalDateTime;
import java.util.Date;
@Entity
......@@ -36,10 +37,10 @@ public class OrgClusterEntity {
private String updateUser;
private Date createTime;
private LocalDateTime createTime;
private Date updateTime;
private LocalDateTime updateTime;
public OrgClusterEntity() {
}
......
......@@ -3,6 +3,7 @@ package com.dituhui.pea.order.entity;
import lombok.Data;
import javax.persistence.*;
import java.time.LocalDateTime;
import java.util.Date;
@Entity
......@@ -80,12 +81,12 @@ public class OrgGroupEntity {
/**
* 创建时间
*/
private Date createTime;
private LocalDateTime createTime;
/**
* 更新时间
*/
private Date updateTime;
private LocalDateTime updateTime;
public OrgGroupEntity() {}
}
......@@ -3,6 +3,7 @@ package com.dituhui.pea.order.entity;
import lombok.Data;
import javax.persistence.*;
import java.time.LocalDateTime;
import java.util.Date;
@Entity
......@@ -42,12 +43,12 @@ public class OrgTeamEngineerEntity {
/**
* 创建时间
*/
private Date createTime;
private LocalDateTime createTime;
/**
* 更新时间
*/
private Date updateTime;
private LocalDateTime updateTime;
public OrgTeamEngineerEntity() {
}
......
......@@ -3,6 +3,7 @@ package com.dituhui.pea.order.entity;
import lombok.Data;
import javax.persistence.*;
import java.time.LocalDateTime;
import java.util.Date;
@Entity
......@@ -65,12 +66,12 @@ public class OrgTeamEntity {
/**
* 创建时间
*/
private Date createTime;
private LocalDateTime createTime;
/**
* 更新时间
*/
private Date updateTime;
private LocalDateTime updateTime;
public OrgTeamEntity(){
......
......@@ -7,6 +7,7 @@ import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
import javax.persistence.*;
......@@ -73,12 +74,12 @@ public class ProductCategoryEntity {
/**
* 创建时间
*/
private Date createTime;
private LocalDateTime createTime;
/**
* 更新时间
*/
private Date updateTime;
private LocalDateTime updateTime;
public ProductCategoryEntity() {
}
......
......@@ -3,6 +3,7 @@ package com.dituhui.pea.order.entity;
import lombok.Data;
import javax.persistence.*;
import java.time.LocalDateTime;
import java.util.Date;
@Entity
......@@ -44,10 +45,10 @@ public class PubParamsEntity {
/**
* 创建时间
*/
private Date createTime;
private LocalDateTime createTime;
/**
* 更新时间
*/
private Date updateTime;
private LocalDateTime updateTime;
}
package com.dituhui.pea.order.service;
import com.dituhui.pea.order.dao.CapacityTeamStatDao;
import com.dituhui.pea.order.dao.MapBlockInfoDao;
import com.dituhui.pea.order.dao.OrderChangeDao;
import com.dituhui.pea.order.entity.OrderChangeEntity;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.experimental.Accessors;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.*;
import org.springframework.stereotype.Service;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
public interface CommonService {
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Random;
@Service
@Slf4j
public class CommonService {
String getTeamIdByInput(String location, String address, String layer);
@Autowired
private MapBlockInfoDao mapBlockInfoDao;
void addOrderChange(String orderId, String subOrderId, String source, String operator, String content, String memo);
@Autowired
private CapacityTeamStatDao capacityTeamStatDao;
@Autowired
private OrderChangeDao orderChangeDao;
public String getTeamIdByInput(String location, String address, String layer) {
// todo 目前会随机兜底,后面将合理化
String teamId = null;
List<LayerAndArea> layerAndAreas = getLayerAndAreas(location, address);
if (layerAndAreas == null || layerAndAreas.size() == 0) {
// 分单接口没有查到,本地随机处理一下
teamId = capacityTeamStatDao.getRandomTeamIdByLayer(layer);
} else {
// 生成随机索引
int randomIndex = new Random().nextInt(layerAndAreas.size());
// 获取随机元素
LayerAndArea layerAndArea = layerAndAreas.get(randomIndex);
teamId = mapBlockInfoDao.getTeamIdByBlockIdAndLayer(layerAndArea.areaId, layer);
}
if (StringUtils.isEmpty(teamId)) {
teamId = capacityTeamStatDao.getRandomTeamId();
}
log.info("teamId ==> {}", teamId);
assert (StringUtils.isNotEmpty(teamId));
return teamId;
}
/**
* 根据提供的地址信息,获取对应的片区图层定义的工作队;如果没有找到,返回为空
* 目前layer_info表中,area_data是保存位置围栏的json数据,后面可能会是对于其他图层的引用;
*
* @param location
* @return
*/
private List<LayerAndArea> getLayerAndAreas(String location, String address) {
// 根据坐标 查询分单接口,获得区块、图层列表 ===> 查询map_block_info表,根据优先级,确定 工作队;
// 根据工作队+图层,查询 capacity_team_stat,返回
// todo 由于saas的分单接口尚未完成,目前仅仅是调用分单获取图层、区块名称,对于我们的容量查询没有真正使用,目前采用随机返回方式
// 创建RestTemplate实例
log.info("===> getLayerAndAreas({}, {})", location, address);
RestTemplate restTemplate = new RestTemplate();
// 设置请求头
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
// 构建请求参数
String url;
MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
params.add("ak", "284c57cbabad4755a9c657885a8df3e2");
if (StringUtils.isNotEmpty(location)) {
url = "https://pea-test.bshg.com.cn/v2/xyfendan";
params.add("coordinate", location);
} else {
url = "https://pea-test.bshg.com.cn/v2/fendan";
params.add("addresses", String.format("[{\"address\":\"%s\"}]", address));
}
params.add("need_district", "false");
params.add("need_layer", "true");
// params.add("related_point_fields", "");
params.add("area_fields", "名称,唯一编号,区块");
log.info("request params ==> {}", params);
// 构建请求实体
HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers);
// 发送POST请求
ResponseEntity<String> responseEntity = restTemplate.exchange(url, HttpMethod.POST, requestEntity, String.class);
// 获取响应结果
String responseBody = responseEntity.getBody();
log.info("after call saas ==> {}", responseEntity.getBody());
// 使用Jackson库解析JSON数据
ObjectMapper objectMapper = new ObjectMapper();
try {
List<LayerAndArea> results = new ArrayList<>();
JsonNode responseJson = objectMapper.readTree(responseBody);
// 获取areaResults[0]的值
for (JsonNode r : responseJson.get("result").get(0).get("areaResults")) {
// 分单接口暂时无图层返回
results.add(new LayerAndArea().setAreaId(r.get("field3").asText()).setAreaName(r.get("field1").asText()));
}
return results;
} catch (Exception e) {
return null;
}
}
@lombok.Data
@Accessors(chain = true)
private static class LayerAndArea {
private String layer;
private String areaId;
private String areaName;
}
public void addOrderChange(String orderId, String subOrderId, String source, String operator, String content, String memo){
OrderChangeEntity entity = new OrderChangeEntity();
entity.setOrderId(orderId).setSuborderId(subOrderId).setSource(source).setOperator(operator).setContent(content).setMemo(memo);
entity.setCreateTime(new Date()).setUpdateTime(new Date());
orderChangeDao.save(entity);
}
}
......@@ -109,6 +109,7 @@ public class CapacityQueryServiceImpl implements CapacityQueryService {
List<CapacityStatQueryRespDTO.Content> contents = new ArrayList<>();
for (Object item : stats.getContent()) {
CapacityStatQueryRespDTO.Content content = new CapacityStatQueryRespDTO.Content();
log.info("===== content1: {}", content);
if (item instanceof CapacityOrgStatEntity) {
// cluster/branch查询,都是capacity_org_stat
CapacityOrgStatEntity e = (CapacityOrgStatEntity) item;
......@@ -127,12 +128,14 @@ public class CapacityQueryServiceImpl implements CapacityQueryService {
.setCapTotal(e.getCapTotal()).setCapUsed(e.getCapUsed()).setCapAdjust(e.getCapAdjust())
.setEngineerNum(e.getEngineerCount()).setUpdateTime(e.getUpdateTime());
}
log.info("===== content2: {}", content);
contents.add(content);
}
};
log.info("===== contents: {}", contents);
contents.stream().sorted(
Comparator.comparing(CapacityStatQueryRespDTO.Content::getDate)).collect(Collectors.toList());
data.setContent(contents);
log.info("===== data: {}", data);
return Result.success(data);
}
......
package com.dituhui.pea.order.service.impl;
import com.dituhui.pea.order.dao.CapacityTeamStatDao;
import com.dituhui.pea.order.dao.MapBlockInfoDao;
import com.dituhui.pea.order.dao.OrderChangeDao;
import com.dituhui.pea.order.entity.OrderChangeEntity;
import com.dituhui.pea.order.service.CommonService;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.experimental.Accessors;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.*;
import org.springframework.stereotype.Service;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
@Service
@Slf4j
public class CommonServiceImpl implements CommonService {
@Autowired
private MapBlockInfoDao mapBlockInfoDao;
@Autowired
private CapacityTeamStatDao capacityTeamStatDao;
@Autowired
private OrderChangeDao orderChangeDao;
public String getTeamIdByInput(String location, String address, String layer) {
// todo 目前会随机兜底,后面将合理化
log.info("====== getTeamIdByInput ===");
String teamId = null;
List<LayerAndArea> layerAndAreas = getLayerAndAreas(location, address);
if (layerAndAreas == null || layerAndAreas.size() == 0) {
// 分单接口没有查到,本地随机处理一下
teamId = capacityTeamStatDao.getRandomTeamIdByLayer(layer);
log.info("分单接口没有查到,本地随机处理一下 ==> {}", teamId);
} else {
// 分单接口查到了areaId(blockId),查询map_block_info,从而限定groupId,然后再随机teamId,这样就相对真实一点
// 生成随机索引
int randomIndex = new Random().nextInt(layerAndAreas.size());
// 获取随机元素
LayerAndArea layerAndArea = layerAndAreas.get(randomIndex);
teamId = mapBlockInfoDao.getTeamIdByBlockIdAndLayer(layerAndArea.areaId, layer);
log.info("分单接口查询返回区块,layerAndArea=={}, teamId=={}", layerAndArea, teamId);
}
if (StringUtils.isEmpty(teamId)) {
teamId = capacityTeamStatDao.getRandomTeamId();
log.info("查询没有teamId,需要随机生成teamId=={}", teamId);
}
log.info("teamId ==> {}", teamId);
assert (StringUtils.isNotEmpty(teamId));
return teamId;
}
/**
* 根据提供的地址信息,获取对应的片区图层定义的工作队;如果没有找到,返回为空
* 目前layer_info表中,area_data是保存位置围栏的json数据,后面可能会是对于其他图层的引用;
*
* @param location
* @return
*/
private List<LayerAndArea> getLayerAndAreas(String location, String address) {
// 根据坐标 查询分单接口,获得区块、图层列表 ===> 查询map_block_info表,根据优先级,确定 工作队;
// 根据工作队+图层,查询 capacity_team_stat,返回
// todo 由于saas的分单接口尚未完成,目前仅仅是调用分单获取图层、区块名称,对于我们的容量查询没有真正使用,目前采用随机返回方式
// 创建RestTemplate实例
log.info("===> getLayerAndAreas({}, {})", location, address);
RestTemplate restTemplate = new RestTemplate();
// 设置请求头
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
// 构建请求参数
String url;
MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
params.add("ak", "284c57cbabad4755a9c657885a8df3e2");
if (StringUtils.isNotEmpty(location)) {
url = "https://pea-test.bshg.com.cn/v1/xyfendan";
String[] coordinates = location.split(",");
params.add("coordinate", String.format("{\"x\":%s, \"y\":%s}", coordinates[0], coordinates[1]));
} else {
url = "https://pea-test.bshg.com.cn/v2/fendan";
params.add("addresses", String.format("[{\"address\":\"%s\"}]", address));
}
params.add("need_district", "false");
params.add("need_layer", "true");
// params.add("related_point_fields", "");
params.add("area_fields", "名称,唯一编号,区块");
log.info("request params ==> {}", params);
// 构建请求实体
HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers);
// 发送POST请求
ResponseEntity<String> responseEntity = restTemplate.exchange(url, HttpMethod.POST, requestEntity, String.class);
// 获取响应结果
String responseBody = responseEntity.getBody();
log.info("after call saas ==> {}", responseEntity.getBody());
// 使用Jackson库解析JSON数据
ObjectMapper objectMapper = new ObjectMapper();
try {
List<LayerAndArea> results = new ArrayList<>();
JsonNode responseJson = objectMapper.readTree(responseBody);
// 获取areaResults[0]的值
for (JsonNode r : responseJson.get("result").get(0).get("areaResults")) {
// 分单接口暂时无图层返回
results.add(new LayerAndArea().setAreaId(r.get("field3").asText()).setAreaName(r.get("field1").asText()));
}
return results;
} catch (Exception e) {
return null;
}
}
@lombok.Data
@Accessors(chain = true)
private static class LayerAndArea {
private String layer;
private String areaId;
private String areaName;
}
public void addOrderChange(String orderId, String subOrderId, String source, String operator, String content, String memo) {
OrderChangeEntity entity = new OrderChangeEntity();
entity.setOrderId(orderId).setSuborderId(subOrderId).setSource(source).setOperator(operator).setContent(content).setMemo(memo);
entity.setCreateTime(LocalDateTime.now()).setUpdateTime(LocalDateTime.now());
orderChangeDao.save(entity);
}
}
......@@ -477,14 +477,13 @@ public class EngineerServiceImpl implements EngineerService {
}
List<EngineersGanttRespDTO.GanttChart> engineers = new ArrayList<>();
for (String engineerCode : mapEngineers.keySet()) {
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
.setOrders(mapEngineers.get(engineerCode))
.setEngineerName(engineerInfo.getName())
.setGrade(engineerInfo.getGrade());
......@@ -494,6 +493,9 @@ public class EngineerServiceImpl implements EngineerService {
} 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);
}
......
......@@ -14,6 +14,7 @@ import com.dituhui.pea.order.dto.TimeLineDTO;
import com.dituhui.pea.order.entity.EngineerInfo;
import com.dituhui.pea.order.entity.OrderAppointment;
import com.dituhui.pea.order.entity.OrderRequest;
import com.dituhui.pea.order.service.CommonService;
import com.dituhui.pea.order.service.OrderAssign;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -40,6 +41,9 @@ public class OrderAssignImpl implements OrderAssign {
@Autowired
private EngineerInfoMPDao engineerInfoMPDao;
@Autowired
private CommonService commonService;
@Transactional
@Override
public Result<?> getOrderAssignRecommendEngineers(String orderId, String key, String distance, String recommend) {
......@@ -149,6 +153,9 @@ public class OrderAssignImpl implements OrderAssign {
wrapper.eq(OrderRequest::getOrderId, orderId);
orderRequestMPDao.update(null, wrapper);
// 工单变更登记
commonService.addOrderChange(orderId, "", "PEA-WEB", "API", "工单指派", "" );
return Result.success(null);
}
......
......@@ -16,6 +16,7 @@
package com.dituhui.pea.order.service.impl;
import cn.hutool.core.util.IdUtil;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.dao.OrderRequestDao;
import com.dituhui.pea.order.dao.OrgTeamDao;
......@@ -35,6 +36,8 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
......@@ -85,10 +88,11 @@ public class OrderCreateServiceImpl implements OrderCreateService {
public Result<?> createOrder(OrderCreateReqDTO req) {
log.info("[createOrder] current XID: {}", RootContext.getXID());
OrderRequestEntity entity = new OrderRequestEntity();
entity.setId(UUID.randomUUID().toString().replace("-", ""));
entity.setId(IdUtil.getSnowflake().nextIdStr());
String orderId = req.getOrderId();
if (StringUtils.isEmpty(orderId)) {
orderId = UUID.randomUUID().toString().replace("-", "");
String s = UUID.randomUUID().toString().replace("-", "");
orderId = s.substring(s.length()-9);
}
entity.setOrderId(orderId);
entity.setName(req.getName());
......@@ -98,10 +102,11 @@ public class OrderCreateServiceImpl implements OrderCreateService {
entity.setSkill(req.getSkill());
entity.setFaultDescribe(req.getFaultDescribe());
entity.setExpectTimeBegin(req.getExpectBegin());
entity.setExpectTimeEnd(req.getExpectEnd());
entity.setExpectTimeBegin(LocalDateTime.parse(req.getExpectBegin()));
entity.setExpectTimeEnd(LocalDateTime.parse(req.getExpectEnd()));
entity.setExpectTimeDesc(req.getExpectDesc());
entity.setDescription(req.getDescription());
entity.setDt(LocalDate.parse(req.getExpectBegin()));
// location
LocationDTO location = req.getLocation();
entity.setProvince(location.getProvince());
......
......@@ -7,6 +7,7 @@ import com.dituhui.pea.order.dto.*;
import com.dituhui.pea.order.entity.*;
import com.dituhui.pea.order.service.OrderServiceDetail;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -14,6 +15,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
@Service
public class OrderServiceDetailImpl implements OrderServiceDetail {
......@@ -315,7 +317,9 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
items.add(this.packOrderItem("服务", order.getSkill()));
items.add(this.packOrderItem("故障描述", order.getFaultDescribe()));
items.add(this.packOrderItem("备注", order.getApplyNote()));
items.add(this.packOrderItem("意向时间", TimeUtils.IsoTimestamp2DateTime(order.getExpectTimeBegin())));
log.info("======= 意向时间111 {}", order.getExpectTimeBegin());
items.add(this.packOrderItem("意向时间", TimeUtils.IsoTimestamp2DateTime(order.getExpectTimeBegin())));
log.info("======= 意向时间222 {}", TimeUtils.IsoTimestamp2DateTime(order.getExpectTimeBegin()));
items.add(this.packOrderItem("时间要求", order.getExpectTimeDesc()));
items.add(this.packOrderItem("预约方式", order.getSource()));
return items;
......
......@@ -22,6 +22,7 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
public class ScheduleServiceImpl implements ScheduleService {
......@@ -162,7 +163,10 @@ public class ScheduleServiceImpl implements ScheduleService {
dynamics.add(new LabelValueDTO("交通工具", "电动车"));
List<String> orderIds = orderAppointments.stream().map(OrderAppointment::getOrderId).collect(Collectors.toList());
List<OrderRequest> orderRequests = orderRequestMPDao.selectByOrderIds(orderIds);
List<OrderRequest> orderRequests = new ArrayList<>();
if(orderIds!=null && !orderIds.isEmpty()) {
orderRequests = orderRequestMPDao.selectByOrderIds(orderIds);
}
List<ScheduleEngineerOverviewResp.Order> orders = new ArrayList<>();
for (OrderRequest o : orderRequests) {
ScheduleEngineerOverviewResp.Order item = new ScheduleEngineerOverviewResp.Order();
......
......@@ -59,7 +59,7 @@ public class WorkbenchServiceImpl implements WorkbenchService {
.setOperator(e.getOperator())
.setDescription(e.getContent())
.setMemo(e.getMemo())
.setUpdateTime(e.getUpdateTime().toString());
.setUpdateTime(e.getUpdateTime());
contents.add(content);
}
OrderChangeListRespDTO respDTO = new OrderChangeListRespDTO();
......
......@@ -6,7 +6,7 @@ spring:
name: project-order
jackson:
default-property-inclusion: NON_NULL
# time-zone: GMT+8
time-zone: GMT+8
date-format: yyyy-MM-dd HH:mm:ss
cloud:
nacos:
......@@ -26,7 +26,7 @@ spring:
# - optional:nacos:datasource-config.yaml
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://10.10.0.116:3306/saas_aftersale_test?serverTimezone=UTC
url: jdbc:mysql://10.10.0.116:3306/saas_aftersale_test?serverTimezone=Asia/Shanghai
username: root
password: 123456
type: com.alibaba.druid.pool.DruidDataSource
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!