Commit 0e079575 by 丁伟峰

改善了order_request的id字段(改用了snowflake)

1 parent 6afb08c9
......@@ -92,6 +92,11 @@
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.7.5</version>
</dependency>
</dependencies>
<build>
......
......@@ -36,20 +36,24 @@ public class CommonService {
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);
} 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));
......@@ -125,7 +129,7 @@ public class CommonService {
private String areaName;
}
public void addOrderChange(String orderId, String subOrderId, String source, String operator, String content, String memo){
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());
......
......@@ -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;
......@@ -85,7 +86,7 @@ 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("-", "");
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!