Skip to content

Commit

Permalink
Merge pull request #10807 from yjieliang/perf-10129
Browse files Browse the repository at this point in the history
perf:研发商店组件指标数据字段优化 #10219
  • Loading branch information
bkci-bot authored Sep 19, 2024
2 parents ba2888f + dc55664 commit 38a253e
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 127 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import io.swagger.v3.oas.annotations.media.Schema

@Schema(title = "组件指标要素信息")
data class StoreIndexElementInfo(
@get:Schema(title = "指标要素标识", required = true)
val elementCode: String,
@get:Schema(title = "指标要素名称", required = true)
val elementName: String,
@get:Schema(title = "指标要素值", required = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,38 +178,40 @@ class StoreIndexManageInfoDao {

fun batchCreateStoreIndexResult(dslContext: DSLContext, tStoreIndexResultRecords: List<TStoreIndexResultRecord>) {
with(TStoreIndexResult.T_STORE_INDEX_RESULT) {
dslContext.batch(tStoreIndexResultRecords.map {
dslContext.insertInto(
this,
ID,
STORE_CODE,
STORE_TYPE,
INDEX_ID,
INDEX_CODE,
ICON_TIPS,
LEVEL_ID,
CREATOR,
MODIFIER,
UPDATE_TIME,
CREATE_TIME
).values(
it.id,
it.storeCode,
it.storeType,
it.indexId,
it.indexCode,
it.iconTips,
it.levelId,
it.creator,
it.modifier,
it.updateTime,
it.createTime
).onDuplicateKeyUpdate()
.set(ICON_TIPS, it.iconTips)
.set(LEVEL_ID, it.levelId)
.set(MODIFIER, it.modifier)
.set(UPDATE_TIME, it.updateTime)
}).execute()
dslContext.batch(
tStoreIndexResultRecords.map {
dslContext.insertInto(
this,
ID,
STORE_CODE,
STORE_TYPE,
INDEX_ID,
INDEX_CODE,
ICON_TIPS,
LEVEL_ID,
CREATOR,
MODIFIER,
UPDATE_TIME,
CREATE_TIME
).values(
it.id,
it.storeCode,
it.storeType,
it.indexId,
it.indexCode,
it.iconTips,
it.levelId,
it.creator,
it.modifier,
it.updateTime,
it.createTime
).onDuplicateKeyUpdate()
.set(ICON_TIPS, it.iconTips)
.set(LEVEL_ID, it.levelId)
.set(MODIFIER, it.modifier)
.set(UPDATE_TIME, it.updateTime)
}
).execute()
}
}

Expand Down Expand Up @@ -246,8 +248,10 @@ class StoreIndexManageInfoDao {
).from(this)
.leftJoin(tStoreIndexBaseInfo)
.on(INDEX_ID.eq(tStoreIndexBaseInfo.ID))
.join(tStoreIndexLevelInfo).on(INDEX_ID.eq(tStoreIndexLevelInfo.INDEX_ID)
.and(LEVEL_ID.eq(tStoreIndexLevelInfo.ID)))
.join(tStoreIndexLevelInfo).on(
INDEX_ID.eq(tStoreIndexLevelInfo.INDEX_ID)
.and(LEVEL_ID.eq(tStoreIndexLevelInfo.ID))
)
.where(STORE_CODE.`in`(storeCodes).and(STORE_TYPE.eq(storeType.type.toByte())))
.orderBy(tStoreIndexBaseInfo.WEIGHT.desc())
.fetch()
Expand Down Expand Up @@ -307,39 +311,43 @@ class StoreIndexManageInfoDao {
tStoreIndexElementDetailRecords: List<TStoreIndexElementDetailRecord>
) {
with(TStoreIndexElementDetail.T_STORE_INDEX_ELEMENT_DETAIL) {
dslContext.batch(tStoreIndexElementDetailRecords.map {
dslContext.insertInto(
this,
ID,
STORE_CODE,
STORE_TYPE,
INDEX_ID,
INDEX_CODE,
ELEMENT_NAME,
ELEMENT_VALUE,
REMARK,
CREATOR,
MODIFIER,
UPDATE_TIME,
CREATE_TIME
).values(
it.id,
it.storeCode,
it.storeType,
it.indexId,
it.indexCode,
it.elementName,
it.elementValue,
it.remark,
it.creator,
it.modifier,
it.updateTime,
it.createTime
).onDuplicateKeyUpdate()
.set(ELEMENT_VALUE, it.elementValue)
.set(REMARK, it.remark)
.set(UPDATE_TIME, it.updateTime)
}).execute()
dslContext.batch(
tStoreIndexElementDetailRecords.map {
dslContext.insertInto(
this,
ID,
STORE_CODE,
STORE_TYPE,
INDEX_ID,
INDEX_CODE,
ELEMENT_CODE,
ELEMENT_NAME,
ELEMENT_VALUE,
REMARK,
CREATOR,
MODIFIER,
UPDATE_TIME,
CREATE_TIME
).values(
it.id,
it.storeCode,
it.storeType,
it.indexId,
it.indexCode,
it.elementCode,
it.elementName,
it.elementValue,
it.remark,
it.creator,
it.modifier,
it.updateTime,
it.createTime
).onDuplicateKeyUpdate()
.set(ELEMENT_VALUE, it.elementValue)
.set(REMARK, it.remark)
.set(UPDATE_TIME, it.updateTime)
}
).execute()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ class StoreIndexManageServiceImpl @Autowired constructor(
storeIndexManageInfoDao.batchCreateStoreIndexLevelInfo(dslContext, indexLevelInfoRecords)
// 如果运算类型为插件则需要初始化流水线
if (storeIndexCreateRequest.operationType == IndexOperationTypeEnum.ATOM &&
!storeIndexCreateRequest.atomCode.isNullOrBlank()) {
!storeIndexCreateRequest.atomCode.isNullOrBlank()
) {
tStoreIndexBaseInfoRecord.atomCode = storeIndexCreateRequest.atomCode
storeIndexManageInfoDao.createStoreIndexBaseInfo(dslContext, tStoreIndexBaseInfoRecord)
storeIndexPipelineService.initStoreIndexPipeline(
Expand Down Expand Up @@ -160,7 +161,8 @@ class StoreIndexManageServiceImpl @Autowired constructor(
).data?.get(storePipelineRelRecord.pipelineId)
pipelineBuildInfo?.let {
if (it.status == BuildStatus.PREPARE_ENV.name ||
it.status == BuildStatus.RUNNING.name) {
it.status == BuildStatus.RUNNING.name
) {
client.get(ServiceBuildResource::class).manualShutdown(
userId = userId,
projectId = initProjectCode,
Expand Down Expand Up @@ -270,34 +272,36 @@ class StoreIndexManageServiceImpl @Autowired constructor(
indexId,
createIndexComputeDetailRequest.levelName
)?.id
val tStoreIndexResultRecord = TStoreIndexResultRecord()
tStoreIndexResultRecord.id = UUIDUtil.generate()
tStoreIndexResultRecord.indexId = indexId
tStoreIndexResultRecord.indexCode = createIndexComputeDetailRequest.indexCode
tStoreIndexResultRecord.storeCode = createIndexComputeDetailRequest.storeCode
tStoreIndexResultRecord.storeType = createIndexComputeDetailRequest.storeType.type.toByte()
tStoreIndexResultRecord.iconTips = createIndexComputeDetailRequest.iconTips
tStoreIndexResultRecord.levelId = levelId
tStoreIndexResultRecord.creator = userId
tStoreIndexResultRecord.modifier = userId
tStoreIndexResultRecord.updateTime = LocalDateTime.now()
tStoreIndexResultRecord.createTime = LocalDateTime.now()
val tStoreIndexResultRecord = TStoreIndexResultRecord().apply {
this.id = UUIDUtil.generate()
this.indexId = indexId
this.indexCode = createIndexComputeDetailRequest.indexCode
this.storeCode = createIndexComputeDetailRequest.storeCode
this.storeType = createIndexComputeDetailRequest.storeType.type.toByte()
this.iconTips = createIndexComputeDetailRequest.iconTips
this.levelId = levelId
this.creator = userId
this.modifier = userId
this.updateTime = LocalDateTime.now()
this.createTime = LocalDateTime.now()
}
storeIndexManageInfoDao.batchCreateStoreIndexResult(dslContext, listOf(tStoreIndexResultRecord))
val tStoreIndexElementDetailRecords = createIndexComputeDetailRequest.elementInfos.map {
val tStoreIndexElementDetailRecord = TStoreIndexElementDetailRecord()
tStoreIndexElementDetailRecord.id = UUIDUtil.generate()
tStoreIndexElementDetailRecord.storeCode = createIndexComputeDetailRequest.storeCode
tStoreIndexElementDetailRecord.storeType = createIndexComputeDetailRequest.storeType.type.toByte()
tStoreIndexElementDetailRecord.indexId = indexId
tStoreIndexElementDetailRecord.indexCode = createIndexComputeDetailRequest.indexCode
tStoreIndexElementDetailRecord.elementName = it.elementName
tStoreIndexElementDetailRecord.elementValue = it.elementValue
tStoreIndexElementDetailRecord.remark = it.remark
tStoreIndexElementDetailRecord.creator = userId
tStoreIndexElementDetailRecord.modifier = userId
tStoreIndexElementDetailRecord.updateTime = LocalDateTime.now()
tStoreIndexElementDetailRecord.createTime = LocalDateTime.now()
tStoreIndexElementDetailRecord
TStoreIndexElementDetailRecord().apply {
this.id = UUIDUtil.generate()
this.storeCode = createIndexComputeDetailRequest.storeCode
this.storeType = createIndexComputeDetailRequest.storeType.type.toByte()
this.indexId = indexId
this.indexCode = createIndexComputeDetailRequest.indexCode
this.elementCode = it.elementCode
this.elementName = it.elementName
this.elementValue = it.elementValue
this.remark = it.remark
this.creator = userId
this.modifier = userId
this.updateTime = LocalDateTime.now()
this.createTime = LocalDateTime.now()
}
}
storeIndexManageInfoDao.batchCreateElementDetail(dslContext, tStoreIndexElementDetailRecords)
return Result(true)
Expand Down Expand Up @@ -362,41 +366,43 @@ class StoreIndexManageServiceImpl @Autowired constructor(
params = arrayOf("indexCode: $TRUSTWORTHY_INDEX_CODE")
)
val levelId = storeIndexManageInfoDao.getStoreIndexLevelInfo(
dslContext,
indexId,
TRUSTWORTHY_INDEX_LEVEL_NAME
dslContext = dslContext,
indexId = indexId,
levelName = TRUSTWORTHY_INDEX_LEVEL_NAME
)?.id
val tStoreIndexResultRecords = mutableListOf<TStoreIndexResultRecord>()
val tStoreIndexElementDetailRecords = mutableListOf<TStoreIndexElementDetailRecord>()
newStoreCodes.forEach {

val tStoreIndexResultRecord = TStoreIndexResultRecord()
tStoreIndexResultRecord.id = UUIDUtil.generate()
tStoreIndexResultRecord.indexId = indexId
tStoreIndexResultRecord.indexCode = TRUSTWORTHY_INDEX_CODE
tStoreIndexResultRecord.storeCode = it
tStoreIndexResultRecord.storeType = storeType.type.toByte()
tStoreIndexResultRecord.iconTips = I18nUtil.getCodeLanMessage(TRUSTWORTHY_INDEX_LEVEL_NAME)
tStoreIndexResultRecord.levelId = levelId
tStoreIndexResultRecord.creator = userId
tStoreIndexResultRecord.modifier = userId
tStoreIndexResultRecord.updateTime = LocalDateTime.now()
tStoreIndexResultRecord.createTime = LocalDateTime.now()
tStoreIndexResultRecords.add(tStoreIndexResultRecord)
val tStoreIndexElementDetailRecord = TStoreIndexElementDetailRecord()
tStoreIndexElementDetailRecord.id = UUIDUtil.generate()
tStoreIndexElementDetailRecord.storeCode = it
tStoreIndexElementDetailRecord.storeType = storeType.type.toByte()
tStoreIndexElementDetailRecord.indexId = indexId
tStoreIndexElementDetailRecord.indexCode = TRUSTWORTHY_INDEX_CODE
tStoreIndexElementDetailRecord.elementName = deptCode
tStoreIndexElementDetailRecord.elementValue = "Certified"
tStoreIndexElementDetailRecord.remark = null
tStoreIndexElementDetailRecord.creator = userId
tStoreIndexElementDetailRecord.modifier = userId
tStoreIndexElementDetailRecord.updateTime = LocalDateTime.now()
tStoreIndexElementDetailRecord.createTime = LocalDateTime.now()
tStoreIndexElementDetailRecords.add(tStoreIndexElementDetailRecord)
newStoreCodes.forEach {
val tStoreIndexResultRecord = TStoreIndexResultRecord().apply {
this.id = UUIDUtil.generate()
this.indexId = indexId
this.indexCode = TRUSTWORTHY_INDEX_CODE
this.storeCode = it
this.storeType = storeType.type.toByte()
this.iconTips = I18nUtil.getCodeLanMessage(TRUSTWORTHY_INDEX_LEVEL_NAME)
this.levelId = levelId
this.creator = userId
this.modifier = userId
this.updateTime = LocalDateTime.now()
this.createTime = LocalDateTime.now()
}
tStoreIndexResultRecords.add(tStoreIndexResultRecord)
val tStoreIndexElementDetailRecord = TStoreIndexElementDetailRecord().apply {
this.id = UUIDUtil.generate()
this.storeCode = it
this.storeType = storeType.type.toByte()
this.indexId = indexId
this.indexCode = TRUSTWORTHY_INDEX_CODE
this.elementCode = TRUSTWORTHY_INDEX_CODE
this.elementName = TRUSTWORTHY_INDEX_CODE
this.elementValue = "Certified"
this.remark = null
this.creator = userId
this.modifier = userId
this.updateTime = LocalDateTime.now()
this.createTime = LocalDateTime.now()
}
tStoreIndexElementDetailRecords.add(tStoreIndexElementDetailRecord)
}
dslContext.transaction { configuration ->
val context = DSL.using(configuration)
Expand Down
2 changes: 2 additions & 0 deletions support-files/sql/1001_ci_store_ddl_mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1255,8 +1255,10 @@ CREATE TABLE IF NOT EXISTS `T_STORE_INDEX_ELEMENT_DETAIL` (
`MODIFIER` varchar(50) NOT NULL DEFAULT 'system' COMMENT '修改者',
`UPDATE_TIME` datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '修改时间',
`CREATE_TIME` datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
`ELEMENT_CODE` varchar(64) NOT NULL DEFAULT '' COMMENT '指标要素标识',
PRIMARY KEY (`ID`),
UNIQUE KEY `T_STORE_INDEX_ELEMENT_DETAIL_UN` (`STORE_TYPE`,`STORE_CODE`,`INDEX_CODE`,`ELEMENT_NAME`),
UNIQUE KEY `UNI_INX_TSIE_CODE` (`STORE_CODE`,`STORE_TYPE`,`INDEX_CODE`,`ELEMENT_CODE`),
KEY `INX_TSIR_INDEX_ID` (`INDEX_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='研发商店组件指标要素详情表';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,14 @@ BEGIN
ALTER TABLE T_STORE_PROJECT_REL ADD COLUMN `INSTANCE_ID` varchar(256) COMMENT '实例ID';
END IF;

IF NOT EXISTS(SELECT 1
FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = db
AND TABLE_NAME = 'T_STORE_INDEX_ELEMENT_DETAIL'
AND COLUMN_NAME = 'ELEMENT_CODE') THEN
ALTER TABLE T_STORE_INDEX_ELEMENT_DETAIL ADD COLUMN ELEMENT_CODE varchar(64) NOT NULL DEFAULT '';
END IF;

COMMIT;
END <CI_UBF>
DELIMITER ;
Expand Down

0 comments on commit 38a253e

Please sign in to comment.