mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
executor 服务添加ES依赖,添加对小板造型数据入库处理
This commit is contained in:
@@ -65,6 +65,24 @@
|
||||
<groupId>com.cf.imes</groupId>
|
||||
<artifactId>cf-spring-boot-starter-redis</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.cf.imes</groupId>
|
||||
<artifactId>cf-spring-boot-starter-elasticsearch</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>jakarta.json</groupId>
|
||||
<artifactId>jakarta.json-api</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>jakarta.json</groupId>
|
||||
<artifactId>jakarta.json-api</artifactId>
|
||||
<version>2.1.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- RPC 远程调用相关 -->
|
||||
<dependency>
|
||||
<groupId>com.cf.imes</groupId>
|
||||
|
||||
+28
@@ -1,5 +1,9 @@
|
||||
package com.cf.imes.module.executor.controller.admin.plan;
|
||||
|
||||
import com.cf.imes.module.executor.service.order.OrderInputProcessor;
|
||||
import com.cf.imes.module.executor.util.RandomUtils;
|
||||
import com.cf.imes.module.executor.util.deviseData.Detail;
|
||||
import com.cf.imes.module.executor.util.deviseData.IBoardProdInfo;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -38,6 +42,9 @@ public class PlanController {
|
||||
@Resource
|
||||
private PlanService planService;
|
||||
|
||||
@Resource
|
||||
private OrderInputProcessor orderInputProcessor;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建排单")
|
||||
@PreAuthorize("@ss.hasPermission('executor:plan:create')")
|
||||
@@ -141,4 +148,25 @@ public class PlanController {
|
||||
BeanUtils.toBean(plateByPlanId, PlateResList.class));
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("test")
|
||||
@Operation(summary = "test")
|
||||
public Boolean test() {
|
||||
ArrayList<Detail> details = new ArrayList<>();
|
||||
for (int i = 0; i < 20; i++) {
|
||||
Detail detail = RandomUtils.randomPojo(Detail.class);
|
||||
IBoardProdInfo iBoardProdInfo = detail.getIBoardProdInfo();
|
||||
iBoardProdInfo.setRawGoodsId(999L);
|
||||
iBoardProdInfo.setGoodsName("abc");
|
||||
iBoardProdInfo.setMaterial("ccc");
|
||||
iBoardProdInfo.setColor("blue");
|
||||
iBoardProdInfo.setBrand("xxx");
|
||||
iBoardProdInfo.setSpec("xxxx");
|
||||
iBoardProdInfo.setGoodType(1);
|
||||
details.add(detail);
|
||||
}
|
||||
orderInputProcessor.input(details, 999L);
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package com.cf.imes.module.executor.dal.dataobject.ordermodel;
|
||||
|
||||
import com.cf.imes.framework.es.core.dal.ESDocument;
|
||||
import com.cf.imes.module.executor.util.deviseData.HoleDetail;
|
||||
import com.cf.imes.module.executor.util.deviseData.ModelDetail;
|
||||
import com.cf.imes.module.executor.util.deviseData.PointDetail;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.checkerframework.checker.units.qual.A;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Beal
|
||||
* 生产单 小板的轮廓数据对象
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class OrderModelDO extends ESDocument {
|
||||
/*@Schema(description = "组织id")
|
||||
private Long organId;*/
|
||||
@Schema(description = "生产单id")
|
||||
private Long orderId;
|
||||
@Schema(description = "小板id")
|
||||
private Long plateId;
|
||||
@Schema(description = "轮廓明细")
|
||||
private List<ModelDetail> contourDetail;
|
||||
@Schema(description = "点明细")
|
||||
private List<PointDetail> pointDetail;
|
||||
@Schema(description = "孔明细")
|
||||
private HoleDetail holeDetail;
|
||||
@Schema(description = "原始点明细")
|
||||
private List<PointDetail> rawPointDetail;
|
||||
@Schema(description = "侧面轮廓明细")
|
||||
private List<ModelDetail> sideModelDetail;
|
||||
@Schema(description = "侧面孔明细")
|
||||
private List<HoleDetail> sideHoleDetail;
|
||||
}
|
||||
+35
-7
@@ -3,6 +3,7 @@ package com.cf.imes.module.executor.service.order;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
|
||||
import com.cf.imes.framework.common.util.json.JsonUtils;
|
||||
import com.cf.imes.framework.es.core.service.ESDocumentService;
|
||||
import com.cf.imes.framework.mybatis.core.generator.SnowFlakeGenerator;
|
||||
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||
import com.cf.imes.module.executor.dal.dataobject.orderBody.OrderBodyDO;
|
||||
@@ -10,6 +11,7 @@ import com.cf.imes.module.executor.dal.dataobject.orderGroup.OrderGroupDO;
|
||||
import com.cf.imes.module.executor.dal.dataobject.orderItem.OrderItemDO;
|
||||
import com.cf.imes.module.executor.dal.dataobject.orderModuleExtra.OrderModuleExtraDO;
|
||||
import com.cf.imes.module.executor.dal.dataobject.orderParts.OrderPartsDO;
|
||||
import com.cf.imes.module.executor.dal.dataobject.ordermodel.OrderModelDO;
|
||||
import com.cf.imes.module.executor.dal.dataobject.plate.PlateDO;
|
||||
import com.cf.imes.module.executor.dal.dataobject.rawgoods.RawGoodsDO;
|
||||
import com.cf.imes.module.executor.dal.mysql.orderBody.OrderBodyMapper;
|
||||
@@ -24,6 +26,7 @@ import com.cf.imes.module.executor.util.deviseData.Detail;
|
||||
import com.cf.imes.module.executor.util.deviseData.IBoardProdInfo;
|
||||
import com.cf.imes.module.executor.util.deviseData.PartsModuleExtra;
|
||||
import com.cf.imes.module.executor.util.deviseData.PlateModuleExtra;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -36,6 +39,7 @@ import java.util.stream.Collectors;
|
||||
* @author Beal
|
||||
* 生产单入库处理器
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class OrderInputProcessor {
|
||||
|
||||
@@ -64,6 +68,11 @@ public class OrderInputProcessor {
|
||||
@Resource
|
||||
private OrderModuleExtraMapper orderModuleExtraMapper;
|
||||
|
||||
@Resource
|
||||
private ESDocumentService esDocumentService;
|
||||
|
||||
public static final String ORDER_PLATE_MODEL = "imes_order_plate_model";
|
||||
|
||||
|
||||
public void input(List<Detail> sourceList, Long orderId) {
|
||||
Long organId = OrganContextHolder.getOrganId();
|
||||
@@ -74,6 +83,7 @@ public class OrderInputProcessor {
|
||||
ArrayList<OrderPartsDO> orderPartsDOS = new ArrayList<>();
|
||||
ArrayList<OrderItemDO> orderItemDOS = new ArrayList<>();
|
||||
ArrayList<OrderModuleExtraDO> orderModuleExtraDOS = new ArrayList<>();
|
||||
ArrayList<OrderModelDO> orderModelDOS = new ArrayList<>();
|
||||
Map<RawGoodsDO, Map<OrderBodyDO, Map<OrderGroupDO, List<Detail>>>> map = sourceList.stream().collect(Collectors.groupingBy(e ->
|
||||
RawGoodsDO.builder()
|
||||
.rawGoodsId(e.getIBoardProdInfo().getGoodsId())
|
||||
@@ -148,7 +158,7 @@ public class OrderInputProcessor {
|
||||
.unit(e.getIBoardProdInfo().getUnit())
|
||||
.build()
|
||||
).toList();
|
||||
if(CollectionUtil.isNotEmpty(plateExtras)) {
|
||||
if (CollectionUtil.isNotEmpty(plateExtras)) {
|
||||
orderModuleExtraDOS.add(
|
||||
OrderModuleExtraDO.builder()
|
||||
.orderId(orderId)
|
||||
@@ -159,7 +169,7 @@ public class OrderInputProcessor {
|
||||
.build());
|
||||
}
|
||||
|
||||
if(CollectionUtil.isNotEmpty(partsModuleExtras)) {
|
||||
if (CollectionUtil.isNotEmpty(partsModuleExtras)) {
|
||||
orderModuleExtraDOS.add(
|
||||
OrderModuleExtraDO.builder()
|
||||
.orderId(orderId)
|
||||
@@ -224,6 +234,17 @@ public class OrderInputProcessor {
|
||||
orderItemDO.setPartsId(0L);
|
||||
orderItemDO.setType(1);
|
||||
plateDOS.add(plateDO);
|
||||
orderModelDOS.add(
|
||||
OrderModelDO.builder()
|
||||
.orderId(orderId)
|
||||
.plateId(plateDO.getId())
|
||||
.contourDetail(e.getContourDetail())
|
||||
.pointDetail(e.getPointDetail())
|
||||
.holeDetail(e.getHoleDetail())
|
||||
.rawPointDetail(e.getRawPointDetail())
|
||||
.sideHoleDetail(e.getSideHoleDetail())
|
||||
.sideModelDetail(e.getSideModelDetail())
|
||||
.build());
|
||||
} else {
|
||||
OrderPartsDO orderPartsDO = OrderPartsDO.builder()
|
||||
.id(identifierGenerator.nextId(null).longValue())
|
||||
@@ -252,13 +273,14 @@ public class OrderInputProcessor {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
batchSaveModel(orderModelDOS);
|
||||
batchInsert(rawGoodsDOS, orderBodyDOS, orderGroupDOS, orderPartsDOS, plateDOS, orderModuleExtraDOS, orderItemDOS);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量保存生产单小板五金数据
|
||||
*
|
||||
* @param rawGoodsDOS
|
||||
* @param orderBodyDOS
|
||||
* @param orderGroupDOS
|
||||
@@ -282,11 +304,17 @@ public class OrderInputProcessor {
|
||||
|
||||
/**
|
||||
* 保存生产单造型数据
|
||||
* @param sourceList
|
||||
* @param orderId
|
||||
*
|
||||
* @param orderModelDOs
|
||||
*/
|
||||
public void saveModel(List<Detail> sourceList, Long orderId) {
|
||||
|
||||
public void batchSaveModel(List<OrderModelDO> orderModelDOs) {
|
||||
try {
|
||||
esDocumentService.bulkCreate(ORDER_PLATE_MODEL, orderModelDOs);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error(e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -68,7 +68,8 @@ spring:
|
||||
# Kafka 配置项,对应 KafkaProperties 配置类
|
||||
kafka:
|
||||
bootstrap-servers: 127.0.0.1:9092 # 指定 Kafka Broker 地址,可以设置多个,以逗号分隔
|
||||
|
||||
elasticsearch:
|
||||
uris: 192.168.1.205:9200
|
||||
--- #################### 定时任务相关配置 ####################
|
||||
xxl:
|
||||
job:
|
||||
|
||||
+2
@@ -74,6 +74,8 @@ spring:
|
||||
# Kafka 配置项,对应 KafkaProperties 配置类
|
||||
kafka:
|
||||
bootstrap-servers: 127.0.0.1:9092 # 指定 Kafka Broker 地址,可以设置多个,以逗号分隔
|
||||
elasticsearch:
|
||||
uris: 192.168.1.205:9200
|
||||
|
||||
--- #################### 定时任务相关配置 ####################
|
||||
xxl:
|
||||
|
||||
Reference in New Issue
Block a user