mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
新增order_plate_less测试入口
This commit is contained in:
+11
@@ -41,6 +41,17 @@ public class ProducingOrderImportReqVO {
|
||||
@NotEmpty(message = "{producing.order.import.materialMappings.notEmpty}")
|
||||
private List<MaterialMapping> materialMappings;
|
||||
|
||||
/**
|
||||
* 是否将板件写入精简测试表。
|
||||
*
|
||||
* <p>仅用于显式对比批量插入字段数量对性能的影响;缺省或传 {@code false} 时仍写入
|
||||
* {@code order_plate},传 {@code true} 时改写 {@code order_plate_less}。测试模式生成的
|
||||
* 订单数据不完整,不应作为后续生产业务数据使用。</p>
|
||||
*/
|
||||
@Schema(description = "是否将板件写入 order_plate_less 进行性能测试,缺省为 false",
|
||||
defaultValue = "false")
|
||||
private Boolean useLessPlateTable = false;
|
||||
|
||||
@Data
|
||||
public static class MaterialMapping {
|
||||
|
||||
|
||||
+1
-1
@@ -122,7 +122,7 @@ public class ProducingOrderImportTransactionalService {
|
||||
organId, order, snowFlakeGenerator, orderMapper, orderBodyMapper, plateMapper,
|
||||
idWorker, goodsMapper, customPlateNoGenerateService, systemConfigApi,
|
||||
assemblyConfigApi, producingOrderImportProperties.getPlateNumThreshold(),
|
||||
jdbcTemplate);
|
||||
jdbcTemplate, Boolean.TRUE.equals(request.getUseLessPlateTable()));
|
||||
stageStartedAt = System.nanoTime();
|
||||
ProducingOrderItemSerialNoUpdateRequest serialNoRequest =
|
||||
factory.analyzeTempData(producingImportData);
|
||||
|
||||
+89
-4
@@ -135,6 +135,9 @@ public class ProducingOrderImportFactory {
|
||||
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
/** 是否将板件写入精简表进行显式性能测试。 */
|
||||
private final boolean useLessPlateTable;
|
||||
|
||||
private Long organId;
|
||||
|
||||
// 批次id
|
||||
@@ -253,6 +256,7 @@ public class ProducingOrderImportFactory {
|
||||
* @param assemblyConfigApi 装配配置 RPC 接口
|
||||
* @param cadImportPlateNumThreshold 单订单允许累计导入的板件数量上限
|
||||
* @param jdbcTemplate JDBC 批量写入工具
|
||||
* @param useLessPlateTable 是否将板件写入 {@code order_plate_less} 性能测试表
|
||||
*/
|
||||
public ProducingOrderImportFactory(Long organId,
|
||||
OrderDO orderDO,
|
||||
@@ -266,7 +270,8 @@ public class ProducingOrderImportFactory {
|
||||
SystemConfigApi systemConfigApi,
|
||||
AssemblyConfigApi assemblyConfigApi,
|
||||
int cadImportPlateNumThreshold,
|
||||
JdbcTemplate jdbcTemplate) {
|
||||
JdbcTemplate jdbcTemplate,
|
||||
boolean useLessPlateTable) {
|
||||
this.organId = organId;
|
||||
this.orderDO = orderDO;
|
||||
this.orderId = orderDO.getId();
|
||||
@@ -284,6 +289,7 @@ public class ProducingOrderImportFactory {
|
||||
sealEdgeConfigList = new ArrayList<>();
|
||||
this.cadImportPlateNumThreshold = cadImportPlateNumThreshold;
|
||||
this.jdbcTemplate = jdbcTemplate;
|
||||
this.useLessPlateTable = useLessPlateTable;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -299,6 +305,10 @@ public class ProducingOrderImportFactory {
|
||||
ProducingImportData producingImportData) {
|
||||
long totalStartedAt = System.nanoTime();
|
||||
try {
|
||||
if (useLessPlateTable) {
|
||||
log.warn("[producing-import-test] orderId={} plateTable=order_plate_less "
|
||||
+ "测试模式生成的数据不完整,仅用于批量插入性能对比", orderId);
|
||||
}
|
||||
cadViewFileId = producingImportData.getCadViewFileId();
|
||||
useConcreteProcessGroupName = producingImportData.isUseConcreteProcessGroupName();
|
||||
|
||||
@@ -2480,12 +2490,23 @@ public class ProducingOrderImportFactory {
|
||||
int batchRows = list.size();
|
||||
long batchStartedAt = System.nanoTime();
|
||||
long[] compressionNanos = {0L};
|
||||
String sql = "INSERT INTO order_plate (id,organ_id,order_id,name,plate_no,type,goods_id,width,height,thickness,split_width,split_height,split_thickness,seal_left,seal_right,seal_up,seal_down,area,texture,hole_face,hole_arrange,unregular_point_count,front_hole_count,back_hole_count,side_hole_count,front_model_count,back_model_count,is_door,open_door_type,offset_x,offset_y,is_arc_across,module_type_id,is_special_shaped,is_sculpt,is_side_sculpt,is_2v,is_side_2v,is_row_hole,is_optimized,is_cutted,filter_type,remark,is_cancel,deleted,custom_plate_no,create_time,update_time,creator,updater, cad_plate_no, model_data, reserved_edge_left, reserved_edge_right, reserved_edge_up, reserved_edge_down, source_block_item_id) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
||||
String tableName = useLessPlateTable ? "order_plate_less" : "order_plate";
|
||||
String sql = useLessPlateTable
|
||||
? "INSERT INTO order_plate_less (id,organ_id,order_id,name,plate_no,type,goods_id,width,height,thickness,split_width,split_height,split_thickness,seal_left,seal_right,seal_up,seal_down,area,texture,is_door,open_door_type,module_type_id,is_optimized,is_cutted,filter_type,remark,is_cancel,deleted,custom_plate_no,create_time,update_time,creator,updater,cad_plate_no,model_data,reserved_edge_left,reserved_edge_right,reserved_edge_up,reserved_edge_down,source_block_item_id) "
|
||||
+ "VALUES (?,?,?,?,?,?,?,?,?,?"
|
||||
+ ",?,?,?,?,?,?,?,?,?,?"
|
||||
+ ",?,?,?,?,?,?,?,?,?,?"
|
||||
+ ",?,?,?,?,?,?,?,?,?,?)"
|
||||
: "INSERT INTO order_plate (id,organ_id,order_id,name,plate_no,type,goods_id,width,height,thickness,split_width,split_height,split_thickness,seal_left,seal_right,seal_up,seal_down,area,texture,hole_face,hole_arrange,unregular_point_count,front_hole_count,back_hole_count,side_hole_count,front_model_count,back_model_count,is_door,open_door_type,offset_x,offset_y,is_arc_across,module_type_id,is_special_shaped,is_sculpt,is_side_sculpt,is_2v,is_side_2v,is_row_hole,is_optimized,is_cutted,filter_type,remark,is_cancel,deleted,custom_plate_no,create_time,update_time,creator,updater, cad_plate_no, model_data, reserved_edge_left, reserved_edge_right, reserved_edge_up, reserved_edge_down, source_block_item_id) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
||||
jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void setValues(PreparedStatement ps, int index) throws SQLException {
|
||||
PlateDO item = list.get(index);
|
||||
if (useLessPlateTable) {
|
||||
compressionNanos[0] += bindLessPlateValues(ps, item);
|
||||
return;
|
||||
}
|
||||
ps.setLong(1, item.getId());
|
||||
ps.setLong(2, item.getOrganId());
|
||||
ps.setLong(3, item.getOrderId());
|
||||
@@ -2564,9 +2585,9 @@ public class ProducingOrderImportFactory {
|
||||
plateModelCompressionNanos += compressionNanos[0];
|
||||
plateBatchCount++;
|
||||
plateBatchRows += batchRows;
|
||||
log.info("[producing-import-batch] orderId={} table=order_plate batch={} rows={} "
|
||||
log.info("[producing-import-batch] orderId={} table={} batch={} rows={} "
|
||||
+ "elapsedMs={} modelCompressMs={} dbAndBindMs={}",
|
||||
orderId, plateBatchCount, batchRows,
|
||||
orderId, tableName, plateBatchCount, batchRows,
|
||||
nanosToMillis(batchElapsed),
|
||||
nanosToMillis(compressionNanos[0]),
|
||||
nanosToMillis(Math.max(0L, batchElapsed - compressionNanos[0])));
|
||||
@@ -2579,6 +2600,70 @@ public class ProducingOrderImportFactory {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将板件绑定到精简性能测试表对应的40个字段。
|
||||
*
|
||||
* <p>造型数据仍按正式导入逻辑压缩,确保两种模式只比较目标表字段数量,避免改变
|
||||
* {@code model_data} 处理方式干扰测试结果。</p>
|
||||
*
|
||||
* @param ps 批量插入预编译语句
|
||||
* @param item 板件数据
|
||||
* @return 本行造型压缩所消耗的纳秒数
|
||||
* @throws SQLException JDBC 参数绑定失败
|
||||
*/
|
||||
private long bindLessPlateValues(PreparedStatement ps, PlateDO item) throws SQLException {
|
||||
ps.setLong(1, item.getId());
|
||||
ps.setLong(2, item.getOrganId());
|
||||
ps.setLong(3, item.getOrderId());
|
||||
ps.setString(4, item.getName());
|
||||
ps.setString(5, item.getPlateNo());
|
||||
ps.setInt(6, item.getType());
|
||||
ps.setLong(7, item.getGoodsId());
|
||||
setSqlDefaultBigDecimal(ps, 8, item.getWidth());
|
||||
setSqlDefaultBigDecimal(ps, 9, item.getHeight());
|
||||
setSqlDefaultBigDecimal(ps, 10, item.getThickness());
|
||||
setSqlDefaultBigDecimal(ps, 11, item.getSplitWidth());
|
||||
setSqlDefaultBigDecimal(ps, 12, item.getSplitHeight());
|
||||
setSqlDefaultBigDecimal(ps, 13, item.getSplitThickness());
|
||||
setSqlDefaultBigDecimal(ps, 14, item.getSealLeft());
|
||||
setSqlDefaultBigDecimal(ps, 15, item.getSealRight());
|
||||
setSqlDefaultBigDecimal(ps, 16, item.getSealUp());
|
||||
setSqlDefaultBigDecimal(ps, 17, item.getSealDown());
|
||||
setSqlDefaultBigDecimal(ps, 18, item.getArea());
|
||||
ps.setInt(19, item.getTexture());
|
||||
ps.setBoolean(20, item.getIsDoor());
|
||||
ps.setInt(21, item.getOpenDoorType());
|
||||
ps.setLong(22, item.getModuleTypeId());
|
||||
ps.setBoolean(23, item.getIsOptimized());
|
||||
ps.setInt(24, item.getIsCutted());
|
||||
ps.setString(25, item.getFilterType());
|
||||
ps.setString(26, item.getRemark());
|
||||
ps.setBoolean(27, item.getIsCancel());
|
||||
ps.setBoolean(28, item.getDeleted());
|
||||
ps.setString(29, item.getCustomPlateNo());
|
||||
ps.setTimestamp(30, Timestamp.valueOf(item.getCreateTime()));
|
||||
ps.setTimestamp(31, Timestamp.valueOf(item.getUpdateTime()));
|
||||
ps.setString(32, item.getCreator());
|
||||
ps.setString(33, item.getUpdater());
|
||||
ps.setString(34, item.getCadPlateNo());
|
||||
|
||||
long compressionNanos = 0L;
|
||||
String modelData = item.getModelData();
|
||||
if (StringUtils.isNotEmpty(modelData)) {
|
||||
long compressionStartedAt = System.nanoTime();
|
||||
ps.setString(35, JsonUtils.zipString(modelData));
|
||||
compressionNanos = System.nanoTime() - compressionStartedAt;
|
||||
} else {
|
||||
ps.setNull(35, Types.LONGVARCHAR);
|
||||
}
|
||||
setSqlDefaultBigDecimal(ps, 36, item.getReservedEdgeLeft());
|
||||
setSqlDefaultBigDecimal(ps, 37, item.getReservedEdgeRight());
|
||||
setSqlDefaultBigDecimal(ps, 38, item.getReservedEdgeUp());
|
||||
setSqlDefaultBigDecimal(ps, 39, item.getReservedEdgeDown());
|
||||
ps.setString(40, item.getSourceBlockItemId());
|
||||
return compressionNanos;
|
||||
}
|
||||
|
||||
/**
|
||||
* 重建板件批量写入缓冲区。
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user