|
|
@@ -1,122 +1,15 @@
|
|
|
package com.iscs.bozzys.api
|
|
|
|
|
|
import android.util.Log
|
|
|
-import androidx.compose.runtime.snapshots.SnapshotStateMap
|
|
|
-import androidx.compose.ui.geometry.Offset
|
|
|
-import androidx.compose.ui.graphics.Color
|
|
|
import com.iscs.bozzys.R
|
|
|
-import com.iscs.bozzys.ui.pages.edit.step.compose.Anchor
|
|
|
-import com.iscs.bozzys.ui.pages.edit.step.compose.Connection
|
|
|
import com.iscs.bozzys.ui.pages.edit.step.compose.NodeUI
|
|
|
import com.iscs.bozzys.utils.StringToListSerializer
|
|
|
import kotlinx.serialization.Serializable
|
|
|
import kotlinx.serialization.encodeToString
|
|
|
import kotlinx.serialization.json.Json
|
|
|
|
|
|
-
|
|
|
-/**
|
|
|
- * 请求基础响应对象
|
|
|
- *
|
|
|
- * @param code
|
|
|
- * @param msg
|
|
|
- * @param data
|
|
|
- */
|
|
|
-open class Response<T>(var code: Int = 500, var msg: String = "", var data: T? = null)
|
|
|
-
|
|
|
-/**
|
|
|
- * 账号登录接口响应数据
|
|
|
- *
|
|
|
- * @param userId 用户id
|
|
|
- * @param username 用户名
|
|
|
- * @param nickname 用户昵称
|
|
|
- * @param accessToken 使用token
|
|
|
- * @param refreshToken 刷新token
|
|
|
- */
|
|
|
-class LoginRsp(
|
|
|
- val userId: Int,
|
|
|
- val username: String,
|
|
|
- val nickname: String,
|
|
|
- val accessToken: String,
|
|
|
- val refreshToken: String
|
|
|
-)
|
|
|
-
|
|
|
-/**
|
|
|
- * 获取分页数据
|
|
|
- *
|
|
|
- * @param total 数据总数
|
|
|
- * @param list 当前获取到的数据
|
|
|
- */
|
|
|
-class Page<T>(val total: Int, val list: List<T>)
|
|
|
-
|
|
|
-/**
|
|
|
- * 获取用户角色
|
|
|
- *
|
|
|
- * @param user 用户信息
|
|
|
- * @param roles 角色信息
|
|
|
- */
|
|
|
-class PermissionRsp(val user: User, val roles: List<String>,val roleList: List<Role>)
|
|
|
-
|
|
|
-/**
|
|
|
- * 任务统计
|
|
|
- */
|
|
|
-data class TaskStatistics(val inProgressCount: Int, val completedCount: Int)
|
|
|
-
|
|
|
-
|
|
|
-/**
|
|
|
- * 点位基类
|
|
|
- */
|
|
|
-@Serializable
|
|
|
-data class IsolationPoint(val id: Int, val pointName: String, val pointNfc: String)
|
|
|
-
|
|
|
-/**
|
|
|
- * 用户
|
|
|
- */
|
|
|
-@Serializable
|
|
|
-data class User(
|
|
|
- val id: Int = 0,
|
|
|
- val userId: Int? = null,
|
|
|
- val username: String = "",
|
|
|
- val nickname: String = "",
|
|
|
- val cardNfc: String? = null,
|
|
|
- val remark: String = "",
|
|
|
- val deptId: Int = 0,
|
|
|
- val deptName: String? = null,
|
|
|
- val postIds: List<Int> = listOf(),
|
|
|
- val email: String? = null,
|
|
|
- val mobile: String? = null,
|
|
|
- val sex: Int = 1,
|
|
|
- val avatar: String = "",
|
|
|
- val status: Int = 0,
|
|
|
- val loginIp: String = "",
|
|
|
- val loginDate: Long = 0L,
|
|
|
- val createTime: Long = 0L,
|
|
|
- val workstationIds: List<Int>? = null,
|
|
|
- val type: String? = "",
|
|
|
-) : java.io.Serializable
|
|
|
-
|
|
|
-/**
|
|
|
- * 流程模板
|
|
|
- */
|
|
|
-@Serializable
|
|
|
-data class Sop(
|
|
|
- val id: Int,
|
|
|
- val name: String,
|
|
|
- val content: String,
|
|
|
- val nodeCount: Int,
|
|
|
- val status: Int,
|
|
|
- val description: String,
|
|
|
- val createTime: Long,
|
|
|
- val updateTime: Long
|
|
|
-)
|
|
|
-
|
|
|
-/**
|
|
|
- * 字典结构
|
|
|
- */
|
|
|
-@Serializable
|
|
|
-data class Dict(val id: Int, val sort: Int, val label: String, val value: String, val status: Int)
|
|
|
-
|
|
|
/**
|
|
|
- * 任务信息
|
|
|
+ * 流程节点
|
|
|
*/
|
|
|
@Serializable
|
|
|
data class Node(
|
|
|
@@ -542,177 +435,6 @@ data class Node(
|
|
|
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
- * 任务表单信息
|
|
|
- */
|
|
|
-@Serializable
|
|
|
-data class TaskFormInfo(
|
|
|
- val id: Int = 0,
|
|
|
- val name: String? = null,
|
|
|
- val conf: String? = null,
|
|
|
- val fields: List<String>? = null,
|
|
|
- val status: Int? = null,
|
|
|
- val remark: String? = null,
|
|
|
- val createTime: Long? = null
|
|
|
-)
|
|
|
-
|
|
|
-/**
|
|
|
- * 作业基类信息
|
|
|
- */
|
|
|
-@Serializable
|
|
|
-data class Job(
|
|
|
- val id: Int = -1, // 作业Id
|
|
|
- val orderNo: String = "", // 作业编号
|
|
|
- val name: String = "", // 作业名称
|
|
|
- val type: String = "", // 作业类型
|
|
|
- val typeName: String = "", // 作业类型名称,服务端不返回,本地使用
|
|
|
- val urgencyLevel: String = "", // 紧急等级
|
|
|
- val designId: Int = -1, // sopId
|
|
|
- val designName: String = "", // 设计模板
|
|
|
- val designContent: String? = null, // sopInfo
|
|
|
- val description: String = "", // 描述
|
|
|
- val initiatorId: Int = -1, // 创建者id
|
|
|
- val initiatorName: String = "", // 创建者名称
|
|
|
- val initiatorTime: Long = -1L, // 创建者创建时间
|
|
|
- val status: String = "", // 作业状态
|
|
|
- val createTime: Long = -1L, // 创建时间
|
|
|
- val currentNodeId: String? = null,
|
|
|
- val currentNodeName: String? = null,
|
|
|
- val completionTime: Long? = null,
|
|
|
- val cancellationTime: Long? = null,
|
|
|
- val cancellationReason: String? = null,
|
|
|
- val workflowWorkNodeDOList: List<Node>? = null
|
|
|
-) : java.io.Serializable {
|
|
|
- /**
|
|
|
- * 将接口返回的node转换为可显示的Node
|
|
|
- */
|
|
|
- fun toUINodeMap(): SnapshotStateMap<String, NodeUI> {
|
|
|
- val json = Json { ignoreUnknownKeys = true }
|
|
|
- val map = SnapshotStateMap<String, NodeUI>()
|
|
|
- workflowWorkNodeDOList?.forEach {
|
|
|
- val pos = json.decodeFromString<NodePositon>(it.position)
|
|
|
- map[it.id.toString()] = NodeUI(it.id.toString(), Offset(pos.x, pos.y), node = it)
|
|
|
- }
|
|
|
- return map
|
|
|
- }
|
|
|
-
|
|
|
- fun String.toAnchor(): Anchor {
|
|
|
- return when (this) {
|
|
|
- "left-source" -> Anchor.LEFT
|
|
|
- "right-source" -> Anchor.RIGHT
|
|
|
- "top-source" -> Anchor.TOP
|
|
|
- "bottom-source" -> Anchor.BOTTOM
|
|
|
- "left-target" -> Anchor.LEFT
|
|
|
- "right-target" -> Anchor.RIGHT
|
|
|
- "top-target" -> Anchor.TOP
|
|
|
- "bottom-target" -> Anchor.BOTTOM
|
|
|
- else -> if (this.contains("source")) Anchor.LEFT else Anchor.RIGHT
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 将api连线数据转化为UI层连线数据
|
|
|
- */
|
|
|
- fun toUIConnectList(): List<Connection> {
|
|
|
- val connections = ArrayList<Connection>()
|
|
|
- val json = Json { ignoreUnknownKeys = true }
|
|
|
- val nodeInfo: NodeInfo = json.decodeFromString(designContent?.ifEmpty { "{}" } ?: "{}")
|
|
|
- nodeInfo.edges.forEach {
|
|
|
- val fromUuid = it.target
|
|
|
- val toUuid = it.source
|
|
|
- val fromId = workflowWorkNodeDOList?.find { node -> node.uuid == fromUuid }?.id ?: 0
|
|
|
- val fromAnchor = it.targetHandle.toAnchor()
|
|
|
- val toId = workflowWorkNodeDOList?.find { node -> node.uuid == toUuid }?.id ?: 0
|
|
|
- val toAnchor = it.sourceHandle.toAnchor()
|
|
|
- connections.add(Connection(fromId.toString(), toId.toString(), fromAnchor, toAnchor))
|
|
|
- }
|
|
|
- return connections
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取等级名称和背景色
|
|
|
- */
|
|
|
- fun getLevelNameAndColor(): Pair<String, Color> {
|
|
|
- return when (urgencyLevel) {
|
|
|
- "1" -> "紧急" to Color(0xFFFF9800)
|
|
|
- "2" -> "非常紧急" to Color(0xFFFF4500)
|
|
|
- else -> "正常" to Color(0xFF1E90FF)
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取任务状态名称
|
|
|
- */
|
|
|
- fun getJobStatusName(): String {
|
|
|
- return when (status) {
|
|
|
- "unreleased" -> "待发布"
|
|
|
- "approved" -> "已审核"
|
|
|
- "running" -> "进行中"
|
|
|
- "completed" -> "已完成"
|
|
|
- else -> status
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * Task任务
|
|
|
- */
|
|
|
-@Serializable
|
|
|
-data class Task(
|
|
|
- val workId: Int,
|
|
|
- val nodeId: Int,
|
|
|
- val orderNo: String,
|
|
|
- val name: String,
|
|
|
- val urgencyLevel: String,
|
|
|
- val completionTime: Long?,
|
|
|
- val cancellationTime: Long?,
|
|
|
- val cancellationReason: String?,
|
|
|
- val initiatorName: String?, // 发起人
|
|
|
- val workerUserName: String?, // 当前执行人
|
|
|
- val workTime: Long?,
|
|
|
- val currentNodeId: String?,
|
|
|
- val currentNodeName: String?,
|
|
|
- val approvalStatus: String
|
|
|
-) : java.io.Serializable {
|
|
|
- /**
|
|
|
- * 获取等级名称和背景色
|
|
|
- */
|
|
|
- fun getLevelNameAndColor(): Pair<String, Color> {
|
|
|
- return when (urgencyLevel) {
|
|
|
- "1" -> "紧急" to Color(0xFFFF9800)
|
|
|
- "2" -> "非常紧急" to Color(0xFFFF4500)
|
|
|
- else -> "正常" to Color(0xFF1E90FF)
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取任务状态名称
|
|
|
- */
|
|
|
- fun getTaskStatusName(): String {
|
|
|
- return when (approvalStatus) {
|
|
|
- "approved" -> "已完成"
|
|
|
- "running" -> "进行中"
|
|
|
- "pending" -> "待处理"
|
|
|
- else -> approvalStatus
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * 消息结构体
|
|
|
- */
|
|
|
-@Serializable
|
|
|
-data class Message(
|
|
|
- val id: Int = 0,
|
|
|
- val userId: Int = 0,
|
|
|
- val userType: Int = 0,
|
|
|
- val readStatus: Boolean = false,
|
|
|
- val createTime: Long = -1L,
|
|
|
- val title: String? = null,
|
|
|
- val templateContent: String = "",
|
|
|
- val isTitle: Boolean = false,
|
|
|
-)
|
|
|
-
|
|
|
/**
|
|
|
* 表单需要的组件
|
|
|
*
|
|
|
@@ -746,6 +468,7 @@ data class FormField(
|
|
|
val children: List<FormField> = listOf()
|
|
|
)
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 表单Option字段
|
|
|
*
|