|
@@ -2,15 +2,21 @@ package com.persagy.labsl.service.impl
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil
|
|
|
import cn.hutool.core.collection.CollUtil
|
|
|
+import cn.hutool.core.util.ObjectUtil
|
|
|
import cn.hutool.core.util.StrUtil
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers
|
|
|
import com.baomidou.mybatisplus.extension.kotlin.KtQueryWrapper
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
|
|
|
+import com.persagy.database.SFilter
|
|
|
import com.persagy.labsl.Opts
|
|
|
import com.persagy.labsl.domain.*
|
|
|
import com.persagy.labsl.mapper.GraphMapper
|
|
|
-import com.persagy.labsl.models.entities.tpt.Graph
|
|
|
import com.persagy.labsl.service.*
|
|
|
+import com.persagy.labsl.utils.IdUtils
|
|
|
import com.persagy.service.models.enums.SResponseType
|
|
|
+import com.persagy.service.models.requests.SCreateRequest
|
|
|
+import com.persagy.service.models.requests.SUpdateRequest
|
|
|
+import com.persagy.service.models.responses.SBaseResponse
|
|
|
import com.persagy.service.models.responses.SCreateResponse
|
|
|
import lombok.extern.slf4j.Slf4j
|
|
|
import org.springframework.beans.factory.annotation.Autowired
|
|
@@ -34,16 +40,77 @@ open class GraphServiceImpl : ServiceImpl<GraphMapper?, GraphEntity?>(), GraphSe
|
|
|
lateinit var relationService: RelationService
|
|
|
@Autowired
|
|
|
lateinit var anchorService: AnchorService
|
|
|
+ @Autowired
|
|
|
+ lateinit var graphPubService: GraphPubService
|
|
|
+ @Autowired
|
|
|
+ lateinit var nodePubService: NodePubService
|
|
|
+ @Autowired
|
|
|
+ lateinit var markerPubService: MarkerPubService
|
|
|
+ @Autowired
|
|
|
+ lateinit var relationPubService: RelationPubService
|
|
|
+ @Autowired
|
|
|
+ lateinit var anchorPubService: AnchorPubService
|
|
|
+ /**
|
|
|
+ * 创建草稿图
|
|
|
+ * @author : lijie
|
|
|
+ * Update By 2022/6/7 14:41
|
|
|
+ */
|
|
|
+ @Transactional
|
|
|
+ override fun draftsCreateLogic(request: SCreateRequest<GraphEntity>): SCreateResponse<GraphEntity> {
|
|
|
+ val sCreateResponse = SCreateResponse<GraphEntity>(SResponseType.success)
|
|
|
+ if (request.content.isNullOrEmpty()){
|
|
|
+ sCreateResponse.message = "不可以为空"
|
|
|
+ return sCreateResponse
|
|
|
+ }
|
|
|
+ for (content in request.content) {
|
|
|
+ /** id 赋值 */
|
|
|
+ if (content.id.isNullOrEmpty()){
|
|
|
+ content.id = IdUtils.uuidCreate()
|
|
|
+ }
|
|
|
+ /** 图 id */
|
|
|
+ if (content.graphId.isNullOrEmpty()){
|
|
|
+ content.graphId = IdUtils.uuidCreate()
|
|
|
+ }
|
|
|
|
|
|
+ /** 版本 */
|
|
|
+ if (content.version.isNullOrEmpty())
|
|
|
+ content.version = "2.0.1"
|
|
|
+
|
|
|
+ /** 项目 id */
|
|
|
+ if (content.projectId.isNullOrEmpty()){
|
|
|
+ content.projectId = Opts.projectId
|
|
|
+ }
|
|
|
+ val entity = list(Wrappers.lambdaQuery(GraphEntity::class.java)
|
|
|
+ .eq(StrUtil.isNotBlank(Opts.projectId),GraphEntity::projectId, Opts.projectId!!)
|
|
|
+ .eq(StrUtil.isNotBlank(content.categoryId),GraphEntity::categoryId, content.categoryId!!)
|
|
|
+ .eq(StrUtil.isNotBlank(content.name),GraphEntity::name, content.name!!))
|
|
|
+ if (CollUtil.isNotEmpty(entity)) {
|
|
|
+ sCreateResponse.result = SResponseType.failure
|
|
|
+ sCreateResponse.message = "同一分类下图名称不可以重复"
|
|
|
+ return sCreateResponse
|
|
|
+ }
|
|
|
+ val entity1 = graphPubService.list(Wrappers.lambdaQuery(GraphPubEntity::class.java)
|
|
|
+ .eq(StrUtil.isNotBlank(Opts.projectId),GraphPubEntity::projectId, Opts.projectId!!)
|
|
|
+ .eq(StrUtil.isNotBlank(content.categoryId),GraphPubEntity::categoryId, content.categoryId!!)
|
|
|
+ .eq(StrUtil.isNotBlank(content.name),GraphPubEntity::name, content.name!!))
|
|
|
+ if (CollUtil.isNotEmpty(entity1)) {
|
|
|
+ sCreateResponse.result = SResponseType.failure
|
|
|
+ sCreateResponse.message = "同一分类下已发布图名称已存在"
|
|
|
+ return sCreateResponse
|
|
|
+ }
|
|
|
+ save(content)
|
|
|
+ }
|
|
|
+ sCreateResponse.entityList = request.content
|
|
|
+ return sCreateResponse
|
|
|
+ }
|
|
|
/**
|
|
|
- * 创建图
|
|
|
- *
|
|
|
+ * 保存草稿图
|
|
|
* @param graph 图对象
|
|
|
* @return 图形对象列表
|
|
|
*/
|
|
|
@Transactional
|
|
|
- override fun saveLogic(graph: Graph): SCreateResponse<Graph> {
|
|
|
- val sCreateResponse = SCreateResponse<Graph>()
|
|
|
+ override fun saveLogic(graph: GraphEntity): SCreateResponse<GraphEntity> {
|
|
|
+ val sCreateResponse = SCreateResponse<GraphEntity>()
|
|
|
/** 未发布 */
|
|
|
if (graph.id.isNullOrEmpty()) {
|
|
|
/** id赋值 */
|
|
@@ -71,8 +138,7 @@ open class GraphServiceImpl : ServiceImpl<GraphMapper?, GraphEntity?>(), GraphSe
|
|
|
/** 图标记设置为 1 草稿箱 */
|
|
|
graph.state = 1
|
|
|
/** 插入图形数据 */
|
|
|
- val graphEntity = BeanUtil.copyProperties(graph, GraphEntity::class.java)
|
|
|
- save(graphEntity)
|
|
|
+ save(graph)
|
|
|
/** 列表不能为空 */
|
|
|
saveElements(graph)
|
|
|
/** 返回标志 */
|
|
@@ -82,8 +148,367 @@ open class GraphServiceImpl : ServiceImpl<GraphMapper?, GraphEntity?>(), GraphSe
|
|
|
/** 返回对象 */
|
|
|
return sCreateResponse
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 发布草稿
|
|
|
+ * @author : lijie
|
|
|
+ * Update By 2022/6/7 14:49
|
|
|
+ */
|
|
|
+ @Transactional
|
|
|
+ override fun pubDrawingsLogic(graphPub: GraphPubEntity): SCreateResponse<GraphPubEntity> {
|
|
|
+ /** 返回对象 */
|
|
|
+ val sCreateResponse = SCreateResponse<GraphPubEntity>()
|
|
|
+ /** 图对象 */
|
|
|
+ val graph1 = GraphEntity()
|
|
|
+ /** 项目 id */
|
|
|
+ graph1.projectId = Opts.projectId!!
|
|
|
+ /** 图编码 */
|
|
|
+ graph1.id = graphPub.id
|
|
|
+ /** 图 id */
|
|
|
+ graph1.graphId = graphPub.graphId
|
|
|
+ /** 设置表明,查询 */
|
|
|
+ val graphEntity = getOne(Wrappers.lambdaQuery(GraphEntity::class.java)
|
|
|
+ .eq(StrUtil.isNotBlank(Opts.projectId),GraphEntity::projectId,Opts.projectId!!)
|
|
|
+ .eq(StrUtil.isNotBlank(graphPub.id),GraphEntity::id,graphPub.id!!)
|
|
|
+ .eq(StrUtil.isNotBlank(graphPub.graphId),GraphEntity::graphId,graphPub.graphId!!)
|
|
|
+ .eq(GraphEntity::state,1))
|
|
|
+ if (ObjectUtil.isNull(graphEntity)){
|
|
|
+ /** 返回标志 */
|
|
|
+ sCreateResponse.result = SResponseType.failure
|
|
|
+ sCreateResponse.message = "草稿箱中没有待发布图形"
|
|
|
+ /** 返回对象 */
|
|
|
+ return sCreateResponse
|
|
|
+ }
|
|
|
+ val graph = BeanUtil.copyProperties(graphEntity, GraphPubEntity::class.java)
|
|
|
+ /** 清除已发布的老数据 */
|
|
|
+ delOldDataPub(graph1)
|
|
|
+ /** 版本号 */
|
|
|
+ val listVersion = graph.version!!.split(".")
|
|
|
+ /** 版本号加 1 */
|
|
|
+ val num = listVersion[1].toInt() + 1
|
|
|
+ /** 版本号赋值 */
|
|
|
+ graph.version = listVersion[0] + "." + num + "." + 0
|
|
|
+ /** 已发布标志 */
|
|
|
+ graph.state = 0
|
|
|
+ /** 已发布 */
|
|
|
+ graph.isAvailable = true
|
|
|
+ graphPubService.save(graph)
|
|
|
+ /** 设置表明,查询 */
|
|
|
+ val nodeList = nodeService.list(Wrappers.lambdaQuery(NodeEntity::class.java)
|
|
|
+ .eq(StrUtil.isNotBlank(graphPub.id),NodeEntity::id,graphPub.id!!)
|
|
|
+ .eq(StrUtil.isNotBlank(graphPub.graphId),NodeEntity::graphId,graph.graphId!!)
|
|
|
+ .eq(NodeEntity::state,1))
|
|
|
+ /** 列表长度大于 0 */
|
|
|
+ if (CollUtil.isNotEmpty(nodeList)){
|
|
|
+ log.debug("对象长度 = ${nodeList.size} ******************************************************")
|
|
|
+ val nodePubList = ArrayList<NodePubEntity>()
|
|
|
+ /** 遍历列表 */
|
|
|
+ for (node in nodeList){
|
|
|
+ val nodePub = BeanUtil.copyProperties(node, NodePubEntity::class.java)
|
|
|
+ /** 图编码 */
|
|
|
+ nodePub.id = graph.id
|
|
|
+ /** 图 id */
|
|
|
+ nodePub.graphId = graph.graphId
|
|
|
+ /** 发布标志 */
|
|
|
+ nodePub.state = 0
|
|
|
+ nodePubList.add(nodePub)
|
|
|
+ }
|
|
|
+ /** 插入数据 */
|
|
|
+ nodePubService.saveBatch(CollUtil.newArrayList(nodePubList))
|
|
|
+ }
|
|
|
+ /** 设置表明,查询 */
|
|
|
+ val markersList = markerService.list(Wrappers.lambdaQuery(MarkerEntity::class.java)
|
|
|
+ .eq(StrUtil.isNotBlank(graphPub.id),MarkerEntity::id,graphPub.id!!)
|
|
|
+ .eq(StrUtil.isNotBlank(graphPub.graphId),MarkerEntity::graphId,graph.graphId!!)
|
|
|
+ .eq(MarkerEntity::state,1))
|
|
|
+ /** 列表大于 0 */
|
|
|
+ if (CollUtil.isNotEmpty(markersList)){
|
|
|
+ val markerPubList = ArrayList<MarkerPubEntity>()
|
|
|
+ /** 遍历列表 */
|
|
|
+ for (markers in markersList){
|
|
|
+ val markersPub = BeanUtil.copyProperties(markers, MarkerPubEntity::class.java)
|
|
|
+ /** 图编码 */
|
|
|
+ markersPub.id = graph.id
|
|
|
+ /** 图 id */
|
|
|
+ markersPub.graphId = graph.graphId
|
|
|
+ /** 发布标志 */
|
|
|
+ markersPub.state = 0
|
|
|
+ markerPubList.add(markersPub)
|
|
|
+ }
|
|
|
+ markerPubService.saveBatch(CollUtil.newArrayList(markerPubList))
|
|
|
+ }
|
|
|
+ /** 设置表明,查询 */
|
|
|
+ val relationList = relationService.list(Wrappers.lambdaQuery(RelationEntity::class.java)
|
|
|
+ .eq(StrUtil.isNotBlank(graphPub.id),RelationEntity::id,graphPub.id!!)
|
|
|
+ .eq(StrUtil.isNotBlank(graphPub.graphId),RelationEntity::graphId,graph.graphId!!)
|
|
|
+ .eq(RelationEntity::state,1))
|
|
|
+ /** 列表长度大于 0 */
|
|
|
+ if (CollUtil.isNotEmpty(relationList)){
|
|
|
+ val relationPubList = ArrayList<RelationPubEntity>()
|
|
|
+ /** 遍历列表 */
|
|
|
+ for (relation in relationList){
|
|
|
+ val relationPub = BeanUtil.copyProperties(relation, RelationPubEntity::class.java)
|
|
|
+ /** 图编码 */
|
|
|
+ relationPub.id = graph.id
|
|
|
+ /** 图 id */
|
|
|
+ relationPub.graphId = graph.graphId
|
|
|
+ /** 已发布标志 */
|
|
|
+ relationPub.state = 0
|
|
|
+ relationPubList.add(relationPub)
|
|
|
+ }
|
|
|
+ relationPubService.saveBatch(CollUtil.newArrayList(relationPubList))
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 设置表明,查询 */
|
|
|
+ val anchorList = anchorService.list(Wrappers.lambdaQuery(AnchorEntity::class.java)
|
|
|
+ .eq(StrUtil.isNotBlank(graphPub.id),AnchorEntity::id,graphPub.id!!)
|
|
|
+ .eq(StrUtil.isNotBlank(graphPub.graphId),AnchorEntity::graphId,graph.graphId!!)
|
|
|
+ .eq(AnchorEntity::state,1))
|
|
|
+ /** 列表长度大于 0 */
|
|
|
+ if (CollUtil.isNotEmpty(anchorList)){
|
|
|
+ val anchorPubList = ArrayList<AnchorPubEntity>()
|
|
|
+ /** 遍历列表 */
|
|
|
+ for (anchor in anchorList){
|
|
|
+ val anchorPub = BeanUtil.copyProperties(anchor, AnchorPubEntity::class.java)
|
|
|
+ /** 图编码 */
|
|
|
+ anchorPub.id = graph.id
|
|
|
+ /** 图 id */
|
|
|
+ anchorPub.graphId = graph.graphId
|
|
|
+ /** 已发布图标志 */
|
|
|
+ anchorPub.state = 0
|
|
|
+ anchorPubList.add(anchorPub)
|
|
|
+ }
|
|
|
+ anchorPubService.saveBatch(CollUtil.newArrayList(anchorPubList))
|
|
|
+ }
|
|
|
|
|
|
- private fun saveElements(graph: Graph) {
|
|
|
+ /** 清除草稿箱图 */
|
|
|
+ delOldData(graph1)
|
|
|
+ /** 对象列表 */
|
|
|
+ sCreateResponse.entityList = arrayListOf(graph)
|
|
|
+ /** 返回标志 */
|
|
|
+ sCreateResponse.result = SResponseType.success
|
|
|
+ /** 返回对象 */
|
|
|
+ return sCreateResponse
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 图、移至或移出回收站
|
|
|
+ * @author : lijie
|
|
|
+ * Update By 2022/6/7 15:39
|
|
|
+ */
|
|
|
+ @Transactional
|
|
|
+ override fun recycleLogic(idList: ArrayList<GraphEntity>): SBaseResponse {
|
|
|
+ /** 返回对象 */
|
|
|
+ val sBaseResponse = SBaseResponse()
|
|
|
+ if (idList.isNullOrEmpty()){
|
|
|
+ /** 返回标记 */
|
|
|
+ sBaseResponse.result = SResponseType.failure
|
|
|
+ return sBaseResponse
|
|
|
+ }
|
|
|
+ /** 遍历列表 */
|
|
|
+ for (graph in idList) {
|
|
|
+ /** 删除时间 */
|
|
|
+ graph.delTime = Date()
|
|
|
+ /** 回收站标记 */
|
|
|
+ graph.state = 4
|
|
|
+ }
|
|
|
+ updateBatchById(CollUtil.newArrayList(idList))
|
|
|
+ /** 返回标记 */
|
|
|
+ sBaseResponse.result = SResponseType.success
|
|
|
+ return sBaseResponse
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 已发布图形移至回收站
|
|
|
+ * @author : lijie
|
|
|
+ * Update By 2022/6/7 15:48
|
|
|
+ */
|
|
|
+ @Transactional
|
|
|
+ override fun recyclePubLogic(idList: java.util.ArrayList<GraphEntity>): SBaseResponse {
|
|
|
+ /** 返回对象 */
|
|
|
+ val sBaseResponse = SBaseResponse()
|
|
|
+ if (idList.isNullOrEmpty()){
|
|
|
+ /** 返回标志 */
|
|
|
+ sBaseResponse.result = SResponseType.failure
|
|
|
+ return sBaseResponse
|
|
|
+ }
|
|
|
+ /** 遍历列表 */
|
|
|
+ for (graph in idList){
|
|
|
+ /** 项目 id */
|
|
|
+ graph.projectId = Opts.projectId
|
|
|
+ /** 设置表明,查询 */
|
|
|
+ val graphPub = graphPubService.getOne(Wrappers.lambdaQuery(GraphPubEntity::class.java)
|
|
|
+ .eq(StrUtil.isNotBlank(Opts.projectId),GraphPubEntity::projectId,Opts.projectId!!)
|
|
|
+ .eq(StrUtil.isNotBlank(graph.id),GraphPubEntity::id,graph.id!!)
|
|
|
+ .eq(StrUtil.isNotBlank(graph.graphId),GraphPubEntity::graphId,graph.graphId!!))
|
|
|
+ if (ObjectUtil.isNull(graphPub)){
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ val graphEntity = BeanUtil.copyProperties(graphPub, GraphEntity::class.java)
|
|
|
+ /** 图编码 */
|
|
|
+ graphEntity.id = IdUtils.uuidCreate()
|
|
|
+ /** 回收站标志 */
|
|
|
+ graphEntity.state = 4
|
|
|
+ graphEntity.delTime = Date()
|
|
|
+ save(graphEntity)
|
|
|
+ /** 查询 */
|
|
|
+ val nodeBuilder = com.persagy.labsl.services.NodeService.select(
|
|
|
+ SFilter.eq("id", graph.id!!),
|
|
|
+ SFilter.eq("graphId", graph.graphId!!)
|
|
|
+ )
|
|
|
+
|
|
|
+ /** 设置表明,查询 */
|
|
|
+ val nodePubList = nodePubService.list(Wrappers.lambdaQuery(NodePubEntity::class.java)
|
|
|
+ .eq(StrUtil.isNotBlank(graph.id),NodePubEntity::id,graph.id!!)
|
|
|
+ .eq(StrUtil.isNotBlank(graph.graphId),NodePubEntity::graphId,graph.graphId!!))
|
|
|
+ /** 里边数量大于 0 */
|
|
|
+ if (CollUtil.isNotEmpty(nodePubList)){
|
|
|
+ val nodeList = ArrayList<NodeEntity>()
|
|
|
+ /** 遍历列表 */
|
|
|
+ for (nodePub in nodePubList){
|
|
|
+ val node = BeanUtil.copyProperties(nodePub, NodeEntity::class.java)
|
|
|
+ /** 图编码 */
|
|
|
+ node.id = graphEntity.id
|
|
|
+ /** 回收站标志 */
|
|
|
+ node.state = 4
|
|
|
+ nodeList.add(node)
|
|
|
+ }
|
|
|
+ nodeService.saveBatch(CollUtil.newArrayList(nodeList))
|
|
|
+ /** 设置表明,查询 */
|
|
|
+ val anchorPubList = anchorPubService.list(Wrappers.lambdaQuery(AnchorPubEntity::class.java)
|
|
|
+ .eq(StrUtil.isNotBlank(graph.id),AnchorPubEntity::id,graph.id!!)
|
|
|
+ .eq(StrUtil.isNotBlank(graph.graphId),AnchorPubEntity::graphId,graph.graphId!!))
|
|
|
+ /** 列表大于 0 */
|
|
|
+ if (CollUtil.isNotEmpty(anchorPubList)){
|
|
|
+ val anchorList = ArrayList<AnchorEntity>()
|
|
|
+ /** 遍历列表 */
|
|
|
+ for (anchorPub in anchorPubList){
|
|
|
+ val anchor = BeanUtil.copyProperties(anchorPub, AnchorEntity::class.java)
|
|
|
+ /** 图编码 */
|
|
|
+ anchor.id = graphEntity.id
|
|
|
+ /** 回收站标志 */
|
|
|
+ anchor.state = 4
|
|
|
+ anchorList.add(anchor)
|
|
|
+ }
|
|
|
+ anchorService.saveBatch(CollUtil.newArrayList(anchorList))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /** 设置表明,查询 */
|
|
|
+ val markerPubList = markerPubService.list(Wrappers.lambdaQuery(MarkerPubEntity::class.java)
|
|
|
+ .eq(StrUtil.isNotBlank(graph.id),MarkerPubEntity::id,graph.id!!)
|
|
|
+ .eq(StrUtil.isNotBlank(graph.graphId),MarkerPubEntity::graphId,graph.graphId!!))
|
|
|
+ /** 列表大于 0 */
|
|
|
+ if (CollUtil.isNotEmpty(markerPubList)){
|
|
|
+ val markerList = ArrayList<MarkerEntity>()
|
|
|
+ /** 遍历列表 */
|
|
|
+ for (markerPub in markerPubList){
|
|
|
+ val marker = BeanUtil.copyProperties(markerPub, MarkerEntity::class.java)
|
|
|
+ /** 图编码 */
|
|
|
+ marker.id = graphEntity.id
|
|
|
+ /** 回收站标志 */
|
|
|
+ marker.state = 4
|
|
|
+ markerList.add(marker)
|
|
|
+ }
|
|
|
+ markerService.saveBatch(CollUtil.newArrayList(markerList))
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 查询 */
|
|
|
+ val relationBuilder = com.persagy.labsl.services.RelationService.select(
|
|
|
+ SFilter.eq("id", graph.id!!),
|
|
|
+ SFilter.eq("graphId", graph.graphId!!)
|
|
|
+ )
|
|
|
+ /** 设置表明,查询 */
|
|
|
+ val relationPubList = relationPubService.list(Wrappers.lambdaQuery(RelationPubEntity::class.java)
|
|
|
+ .eq(StrUtil.isNotBlank(graph.id),RelationPubEntity::id,graph.id!!)
|
|
|
+ .eq(StrUtil.isNotBlank(graph.graphId),RelationPubEntity::graphId,graph.graphId!!))
|
|
|
+ /** 列表大于 0 */
|
|
|
+ if (CollUtil.isNotEmpty(relationPubList)){
|
|
|
+ val relationList = ArrayList<RelationEntity>()
|
|
|
+ /** 遍历列表 */
|
|
|
+ for (relationPub in relationPubList){
|
|
|
+ val relation = BeanUtil.copyProperties(relationPub, RelationEntity::class.java)
|
|
|
+ /** 图编码 */
|
|
|
+ relation.id = graphEntity.id
|
|
|
+ /** 回收站标志 */
|
|
|
+ relation.state = 4
|
|
|
+ relationList.add(relation)
|
|
|
+ }
|
|
|
+ relationService.saveBatch(CollUtil.newArrayList(relationList))
|
|
|
+ }
|
|
|
+ /** 删除已发布的图形数据 */
|
|
|
+ delOldDataPub(graph)
|
|
|
+ }
|
|
|
+ /** 返回标志 */
|
|
|
+ sBaseResponse.result = SResponseType.success
|
|
|
+ return sBaseResponse
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 更新草稿
|
|
|
+ * @author : lijie
|
|
|
+ * Update By 2022/6/7 16:28
|
|
|
+ */
|
|
|
+ @Transactional
|
|
|
+ override fun draftsUpdateLogic(request: SUpdateRequest<GraphEntity>): SBaseResponse {
|
|
|
+ val sBaseResponse = SBaseResponse(SResponseType.success)
|
|
|
+ if (request.content.isNullOrEmpty()){
|
|
|
+ return sBaseResponse
|
|
|
+ }
|
|
|
+ for (content in request.content!!) {
|
|
|
+ val entity = list(Wrappers.lambdaQuery(GraphEntity::class.java)
|
|
|
+ .eq(StrUtil.isNotBlank(Opts.projectId),GraphEntity::projectId, Opts.projectId!!)
|
|
|
+ .eq(StrUtil.isNotBlank(content.categoryId),GraphEntity::categoryId, content.categoryId!!)
|
|
|
+ .eq(StrUtil.isNotBlank(content.name),GraphEntity::name, content.name!!))
|
|
|
+ if (CollUtil.isNotEmpty(entity)) {
|
|
|
+ sBaseResponse.result = SResponseType.failure
|
|
|
+ sBaseResponse.message = "图名称已经存在"
|
|
|
+ return sBaseResponse
|
|
|
+ }
|
|
|
+ val entity1 = graphPubService.list(Wrappers.lambdaQuery(GraphPubEntity::class.java)
|
|
|
+ .eq(StrUtil.isNotBlank(Opts.projectId),GraphPubEntity::projectId, Opts.projectId!!)
|
|
|
+ .eq(StrUtil.isNotBlank(content.categoryId),GraphPubEntity::categoryId, content.categoryId!!)
|
|
|
+ .eq(StrUtil.isNotBlank(content.name),GraphPubEntity::name, content.name!!))
|
|
|
+ if (CollUtil.isNotEmpty(entity1)) {
|
|
|
+ sBaseResponse.result = SResponseType.failure
|
|
|
+ sBaseResponse.message = "同一分类下已发布图名称已存在"
|
|
|
+ return sBaseResponse
|
|
|
+ }
|
|
|
+ }
|
|
|
+ updateBatchById(CollUtil.newArrayList(request.content))
|
|
|
+ return sBaseResponse
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 清除已发布的老数据
|
|
|
+ *
|
|
|
+ * @param graph 图对象
|
|
|
+ */
|
|
|
+ private fun delOldDataPub(graph: GraphEntity) {
|
|
|
+ val graphWrapper= KtQueryWrapper(GraphPubEntity())
|
|
|
+ val nodeWrapper=KtQueryWrapper(NodePubEntity())
|
|
|
+ val markerWrapper=KtQueryWrapper(MarkerPubEntity())
|
|
|
+ val relationWrapper=KtQueryWrapper(RelationPubEntity())
|
|
|
+ val anchorWrapper=KtQueryWrapper(AnchorPubEntity())
|
|
|
+ graphWrapper.eq(StrUtil.isNotBlank(graph.projectId),GraphPubEntity::projectId,graph.projectId!!)
|
|
|
+ graphWrapper.eq(StrUtil.isNotBlank(graph.id),GraphPubEntity::id,graph.id!!)
|
|
|
+ graphWrapper.eq(StrUtil.isNotBlank(graph.graphId),GraphPubEntity::graphId,graph.graphId)
|
|
|
+ graphPubService.remove(graphWrapper)
|
|
|
+ nodeWrapper.eq(StrUtil.isNotBlank(graph.id),NodePubEntity::id,graph.id!!)
|
|
|
+ nodeWrapper.eq(StrUtil.isNotBlank(graph.graphId),NodePubEntity::graphId,graph.graphId)
|
|
|
+ nodePubService.remove(nodeWrapper)
|
|
|
+ markerWrapper.eq(StrUtil.isNotBlank(graph.id),MarkerPubEntity::id,graph.id!!)
|
|
|
+ markerWrapper.eq(StrUtil.isNotBlank(graph.graphId),MarkerPubEntity::graphId,graph.graphId)
|
|
|
+ markerPubService.remove(markerWrapper)
|
|
|
+ relationWrapper.eq(StrUtil.isNotBlank(graph.id),RelationPubEntity::id,graph.id!!)
|
|
|
+ relationWrapper.eq(StrUtil.isNotBlank(graph.graphId),RelationPubEntity::graphId,graph.graphId)
|
|
|
+ relationPubService.remove(relationWrapper)
|
|
|
+ anchorWrapper.eq(StrUtil.isNotBlank(graph.id),AnchorPubEntity::id,graph.id!!)
|
|
|
+ anchorWrapper.eq(StrUtil.isNotBlank(graph.graphId),AnchorPubEntity::graphId,graph.graphId)
|
|
|
+ anchorPubService.remove(anchorWrapper)
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存子数据
|
|
|
+ * @author : lijie
|
|
|
+ * Update By 2022/6/7 15:10
|
|
|
+ */
|
|
|
+ private fun saveElements(graph: GraphEntity) {
|
|
|
if (null==graph.elements){
|
|
|
return
|
|
|
}
|
|
@@ -104,7 +529,7 @@ open class GraphServiceImpl : ServiceImpl<GraphMapper?, GraphEntity?>(), GraphSe
|
|
|
/** id 赋值 */
|
|
|
nodes.nodeId = UUID.randomUUID().toString().replace("-", "")
|
|
|
}
|
|
|
- addNodesList.add(BeanUtil.copyProperties(nodes,NodeEntity::class.java))
|
|
|
+ addNodesList.add(nodes)
|
|
|
val anchorList = nodes.anchorList
|
|
|
/** 列表不能为空 */
|
|
|
if (anchorList.isNullOrEmpty()) {
|
|
@@ -123,7 +548,7 @@ open class GraphServiceImpl : ServiceImpl<GraphMapper?, GraphEntity?>(), GraphSe
|
|
|
/** id赋值 */
|
|
|
anchor.anchorId = UUID.randomUUID().toString().replace("-", "")
|
|
|
}
|
|
|
- addAnchorsList.add(BeanUtil.copyProperties(anchor,AnchorEntity::class.java))
|
|
|
+ addAnchorsList.add(anchor)
|
|
|
}
|
|
|
}
|
|
|
if (CollUtil.isNotEmpty(addNodesList)){
|
|
@@ -151,7 +576,7 @@ open class GraphServiceImpl : ServiceImpl<GraphMapper?, GraphEntity?>(), GraphSe
|
|
|
/** id赋值 */
|
|
|
markers.markerId = UUID.randomUUID().toString().replace("-", "")
|
|
|
}
|
|
|
- addMarkerList.add(BeanUtil.copyProperties(markers,MarkerEntity::class.java))
|
|
|
+ addMarkerList.add(markers)
|
|
|
}
|
|
|
if (CollUtil.isNotEmpty(addMarkerList)){
|
|
|
markerService.saveBatch(CollUtil.newArrayList(addMarkerList))
|
|
@@ -175,7 +600,7 @@ open class GraphServiceImpl : ServiceImpl<GraphMapper?, GraphEntity?>(), GraphSe
|
|
|
/** id 赋值 */
|
|
|
relations.relationId = UUID.randomUUID().toString().replace("-", "")
|
|
|
}
|
|
|
- addRelationList.add(BeanUtil.copyProperties(relations,RelationEntity::class.java))
|
|
|
+ addRelationList.add(relations)
|
|
|
}
|
|
|
if (CollUtil.isNotEmpty(addRelationList)){
|
|
|
relationService.saveBatch(CollUtil.newArrayList(addRelationList))
|
|
@@ -188,7 +613,7 @@ open class GraphServiceImpl : ServiceImpl<GraphMapper?, GraphEntity?>(), GraphSe
|
|
|
*
|
|
|
* @param graph 图对象
|
|
|
*/
|
|
|
- private fun delOldData(graph: Graph) {
|
|
|
+ private fun delOldData(graph: GraphEntity) {
|
|
|
val graphWrapper= KtQueryWrapper(GraphEntity())
|
|
|
val nodeWrapper=KtQueryWrapper(NodeEntity())
|
|
|
val markerWrapper=KtQueryWrapper(MarkerEntity())
|