|
@@ -137,9 +137,10 @@ data class Node(
|
|
|
val createTime: Long = 0L,
|
|
val createTime: Long = 0L,
|
|
|
val approvalStatus: String = "",
|
|
val approvalStatus: String = "",
|
|
|
val approvalOpinion: String = "",
|
|
val approvalOpinion: String = "",
|
|
|
- val isolationType: String? = null,
|
|
|
|
|
- val isolationPoints: String? = null,
|
|
|
|
|
- val nodeUserList: List<User>? = null,
|
|
|
|
|
|
|
+ val isolationType: String? = null, // 隔离类型
|
|
|
|
|
+ val isolationPoints: String? = null, // 解除隔离的点位
|
|
|
|
|
+ val isolationNodeUuid: String? = null, // 解除隔离关联的节点uuid
|
|
|
|
|
+ val nodeUserList: List<User>? = null, // 隔离和解除隔离关联的上锁人和共锁人
|
|
|
) {
|
|
) {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -164,21 +165,19 @@ data class Node(
|
|
|
*
|
|
*
|
|
|
* @param forms 表单数据
|
|
* @param forms 表单数据
|
|
|
*/
|
|
*/
|
|
|
- fun buildSubmitParams(forms: List<FormField>, workFormList: List<TaskFormInfo>): MutableMap<String, Any> {
|
|
|
|
|
|
|
+ fun buildSubmitParams(forms: List<FormField>, workFormList: List<TaskFormInfo>): MutableMap<String, Any?> {
|
|
|
val nodeName = forms.find { it.name == "nodeName" }?.value?.getOrNull(0) ?: ""
|
|
val nodeName = forms.find { it.name == "nodeName" }?.value?.getOrNull(0) ?: ""
|
|
|
- val params = mutableMapOf<String, Any>("nodeId" to id, "nodeName" to nodeName)
|
|
|
|
|
|
|
+ val params = mutableMapOf<String, Any?>("nodeId" to id, "nodeName" to nodeName)
|
|
|
if (type != "createJob") {
|
|
if (type != "createJob") {
|
|
|
val workerUserId = forms.find { it.name == "workerUserId" }?.value?.getOrNull(0) ?: "0"
|
|
val workerUserId = forms.find { it.name == "workerUserId" }?.value?.getOrNull(0) ?: "0"
|
|
|
val formId = forms.find { it.name == "formId" }?.value?.getOrNull(0) ?: "0"
|
|
val formId = forms.find { it.name == "formId" }?.value?.getOrNull(0) ?: "0"
|
|
|
val findWork = workFormList.find { it.id == formId.toInt() }
|
|
val findWork = workFormList.find { it.id == formId.toInt() }
|
|
|
- val formData = if (findWork != null) {
|
|
|
|
|
- Json.encodeToString(formData)
|
|
|
|
|
- } else null
|
|
|
|
|
|
|
+ val formData = if (findWork != null) Json.encodeToString(findWork) else null
|
|
|
params["workerUserId"] = workerUserId.toInt()
|
|
params["workerUserId"] = workerUserId.toInt()
|
|
|
params["formId"] = formId.toInt()
|
|
params["formId"] = formId.toInt()
|
|
|
- if (formData != null) params["formData"] = formData
|
|
|
|
|
|
|
+ params["formData"] = formData
|
|
|
// 处理隔离点信息表单
|
|
// 处理隔离点信息表单
|
|
|
- if (type == "isolation") {
|
|
|
|
|
|
|
+ if (listOf("isolation", "releaseIsolation").contains(type)) {
|
|
|
val isolationType = forms.find { it.name == "isolationType" }?.value?.getOrNull(0) ?: "-1"
|
|
val isolationType = forms.find { it.name == "isolationType" }?.value?.getOrNull(0) ?: "-1"
|
|
|
val isolationPoints = forms.find { it.name == "isolationPoints" }?.value ?: emptyList()
|
|
val isolationPoints = forms.find { it.name == "isolationPoints" }?.value ?: emptyList()
|
|
|
if (isolationType == "1") {
|
|
if (isolationType == "1") {
|
|
@@ -208,19 +207,43 @@ data class Node(
|
|
|
*
|
|
*
|
|
|
* @param forms
|
|
* @param forms
|
|
|
*/
|
|
*/
|
|
|
- fun updateNodeInfo(forms: List<FormField>): Node {
|
|
|
|
|
|
|
+ fun updateNodeInfo(forms: List<FormField>, nodes: List<NodeUI>): Node {
|
|
|
val nodeName = forms.find { it.name == "nodeName" }?.value?.getOrNull(0) ?: ""
|
|
val nodeName = forms.find { it.name == "nodeName" }?.value?.getOrNull(0) ?: ""
|
|
|
if (type != "createJob") {
|
|
if (type != "createJob") {
|
|
|
- // 解析负责人
|
|
|
|
|
- val workerUserId = forms.find { it.name == "workerUserId" }?.value?.getOrNull(0) ?: "0"
|
|
|
|
|
// 解析关联表单
|
|
// 解析关联表单
|
|
|
- val formId = forms.find { it.name == "formId" }?.value?.getOrNull(0) ?: "0"
|
|
|
|
|
|
|
+ val formId = forms.find { it.name == "formId" }?.value?.getOrNull(0) ?: "-1"
|
|
|
// 解析表单数据
|
|
// 解析表单数据
|
|
|
- val formData = forms.find { it.name == "formData" }?.value?.getOrNull(0) ?: ""
|
|
|
|
|
|
|
+ val formData = forms.find { it.name == "formData" }?.value?.getOrNull(0)
|
|
|
|
|
+ // 解析负责人
|
|
|
|
|
+ var workerUserId = forms.find { it.name == "workerUserId" }?.value?.getOrNull(0) ?: "0"
|
|
|
// 解析隔离方式
|
|
// 解析隔离方式
|
|
|
- val isolationType = forms.find { it.name == "isolationType" }?.value?.getOrNull(0)
|
|
|
|
|
- // 解析节点
|
|
|
|
|
- val isolationPoints = forms.find { it.name == "isolationPoints" }?.value ?: emptyList()
|
|
|
|
|
|
|
+ var isolationType = forms.find { it.name == "isolationType" }?.value?.getOrNull(0)
|
|
|
|
|
+ // 解析点位
|
|
|
|
|
+ var isolationPoints = forms.find { it.name == "isolationPoints" }?.value ?: emptyList()
|
|
|
|
|
+ // 解析上锁人
|
|
|
|
|
+ val locker = forms.find { it.name == "locker" }?.value?.getOrNull(0) ?: "-1"
|
|
|
|
|
+ // 解析共锁人
|
|
|
|
|
+ val group = forms.find { it.name == "group" }?.value ?: emptyList()
|
|
|
|
|
+ // 构建上锁人和共锁人列表
|
|
|
|
|
+ val userList = mutableListOf<User>()
|
|
|
|
|
+ if (locker.toInt() > 0) userList += User(userId = locker.toInt(), type = "jtlocker")
|
|
|
|
|
+ if (group.isNotEmpty()) group.forEach { userList += User(userId = it.toInt(), type = "jtcolocker") }
|
|
|
|
|
+ // 解析隔离节点
|
|
|
|
|
+ val isolationNode = forms.find { it.name == "isolationNode" }?.value?.getOrNull(0)
|
|
|
|
|
+ // 如果是解除隔离操作,隔离方式、隔离点位、负责人(或者上锁人、解锁人)需要从选中的点位中获取
|
|
|
|
|
+ if (type == "releaseIsolation") {
|
|
|
|
|
+ nodes.find { it.node?.uuid == isolationNode }?.node?.let {
|
|
|
|
|
+ // 从节点中将数据copy到当前节点
|
|
|
|
|
+ workerUserId = "${it.workerUserId}"
|
|
|
|
|
+ isolationType = it.isolationType
|
|
|
|
|
+ isolationPoints = if (it.isolationPoints.isNullOrEmpty()) {
|
|
|
|
|
+ emptyList()
|
|
|
|
|
+ } else {
|
|
|
|
|
+ it.isolationPoints.replace("[", "").replace("]", "").split(",")
|
|
|
|
|
+ }
|
|
|
|
|
+ userList.addAll(it.nodeUserList ?: emptyList())
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
return Node(
|
|
return Node(
|
|
|
id = id,
|
|
id = id,
|
|
@@ -239,7 +262,9 @@ data class Node(
|
|
|
prefix = "[",
|
|
prefix = "[",
|
|
|
postfix = "]",
|
|
postfix = "]",
|
|
|
separator = ","
|
|
separator = ","
|
|
|
- )
|
|
|
|
|
|
|
+ ),
|
|
|
|
|
+ isolationNodeUuid = isolationNode,
|
|
|
|
|
+ nodeUserList = if (userList.isEmpty()) null else userList
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
return Node(
|
|
return Node(
|
|
@@ -272,6 +297,7 @@ data class Node(
|
|
|
workFormList: List<TaskFormInfo>,
|
|
workFormList: List<TaskFormInfo>,
|
|
|
isolationMethodList: List<Dict>,
|
|
isolationMethodList: List<Dict>,
|
|
|
isolationList: List<IsolationPoint>,
|
|
isolationList: List<IsolationPoint>,
|
|
|
|
|
+ nodes: List<NodeUI> = listOf(),
|
|
|
isLocker: Boolean = false,
|
|
isLocker: Boolean = false,
|
|
|
): List<FormField> {
|
|
): List<FormField> {
|
|
|
Log.d("NodeOption", "buildFormList -> $this")
|
|
Log.d("NodeOption", "buildFormList -> $this")
|
|
@@ -311,7 +337,7 @@ data class Node(
|
|
|
name = "formId",
|
|
name = "formId",
|
|
|
true,
|
|
true,
|
|
|
placeholder = listOf("请选择业务表单"),
|
|
placeholder = listOf("请选择业务表单"),
|
|
|
- options = workFormList.map { FormOption(it.name?:"", it.id.toString()) },
|
|
|
|
|
|
|
+ options = workFormList.map { FormOption(it.name ?: "", it.id.toString()) },
|
|
|
value = if (formId > 0) listOf(formId.toString()) else listOf()
|
|
value = if (formId > 0) listOf(formId.toString()) else listOf()
|
|
|
)
|
|
)
|
|
|
// 隔离配置
|
|
// 隔离配置
|
|
@@ -322,6 +348,26 @@ data class Node(
|
|
|
val formField = list.find { it.name == "formId" }?.copy(required = false)
|
|
val formField = list.find { it.name == "formId" }?.copy(required = false)
|
|
|
list.removeIf { it.name == "formId" }
|
|
list.removeIf { it.name == "formId" }
|
|
|
formField?.let { list.add(it) }
|
|
formField?.let { list.add(it) }
|
|
|
|
|
+ val isolations = nodes.map { it.node }.filter { it != null && it.type == "isolation" }
|
|
|
|
|
+ var enabled = true
|
|
|
|
|
+ var isLockerTemp = isLocker
|
|
|
|
|
+ // 如果是解除隔离操作,这里只能选择当前流程中已经存在的隔离点位
|
|
|
|
|
+ if (type == "releaseIsolation") {
|
|
|
|
|
+ enabled = false
|
|
|
|
|
+ // 增加隔离点选择列表
|
|
|
|
|
+ list += FormField(
|
|
|
|
|
+ id.toString(),
|
|
|
|
|
+ type = "select",
|
|
|
|
|
+ label = "选择隔离节点",
|
|
|
|
|
+ name = "isolationNode",
|
|
|
|
|
+ required = true,
|
|
|
|
|
+ placeholder = listOf("请选择隔离节点"),
|
|
|
|
|
+ options = isolations.map { FormOption(it?.nodeName ?: "", value = it?.uuid ?: "") },
|
|
|
|
|
+ value = if (isolationNodeUuid.isNullOrEmpty()) listOf() else listOf(isolationNodeUuid)
|
|
|
|
|
+ )
|
|
|
|
|
+ // 如果是解除隔离的操作,这里需要先校验选择的节点是否是拆除
|
|
|
|
|
+ isLockerTemp = isolationType == "1"
|
|
|
|
|
+ }
|
|
|
// 抽取隔离方式value值
|
|
// 抽取隔离方式value值
|
|
|
val valueOfIsolationType = if (isolationType.isNullOrEmpty()) {
|
|
val valueOfIsolationType = if (isolationType.isNullOrEmpty()) {
|
|
|
listOf()
|
|
listOf()
|
|
@@ -337,7 +383,8 @@ data class Node(
|
|
|
true,
|
|
true,
|
|
|
placeholder = listOf("请选择隔离方式"),
|
|
placeholder = listOf("请选择隔离方式"),
|
|
|
options = isolationMethodList.map { FormOption(it.label, it.value) },
|
|
options = isolationMethodList.map { FormOption(it.label, it.value) },
|
|
|
- value = valueOfIsolationType
|
|
|
|
|
|
|
+ value = valueOfIsolationType,
|
|
|
|
|
+ enabled = enabled
|
|
|
)
|
|
)
|
|
|
// 抽取隔离点位value值
|
|
// 抽取隔离点位value值
|
|
|
val points = if (isolationPoints.isNullOrEmpty()) "" else isolationPoints.replace("[", "").replace("]", "")
|
|
val points = if (isolationPoints.isNullOrEmpty()) "" else isolationPoints.replace("[", "").replace("]", "")
|
|
@@ -366,9 +413,10 @@ data class Node(
|
|
|
listOf("请选择隔离点"),
|
|
listOf("请选择隔离点"),
|
|
|
multiSelect = true,
|
|
multiSelect = true,
|
|
|
options = isolationList.map { FormOption(it.pointName, it.id.toString()) },
|
|
options = isolationList.map { FormOption(it.pointName, it.id.toString()) },
|
|
|
- value = valueOfIsolationPoints
|
|
|
|
|
|
|
+ value = valueOfIsolationPoints,
|
|
|
|
|
+ enabled = enabled
|
|
|
)
|
|
)
|
|
|
- if (isLocker) {
|
|
|
|
|
|
|
+ if (isLockerTemp) {
|
|
|
val locker = nodeUserList?.find { it.type == "jtlocker" }
|
|
val locker = nodeUserList?.find { it.type == "jtlocker" }
|
|
|
val group = nodeUserList?.filter { it.type == "jtcolocker" } ?: emptyList()
|
|
val group = nodeUserList?.filter { it.type == "jtcolocker" } ?: emptyList()
|
|
|
// 上锁人
|
|
// 上锁人
|
|
@@ -380,7 +428,8 @@ data class Node(
|
|
|
true,
|
|
true,
|
|
|
placeholder = listOf("请选择上锁人"),
|
|
placeholder = listOf("请选择上锁人"),
|
|
|
options = lockerUserList.map { FormOption(it.nickname, it.id.toString()) },
|
|
options = lockerUserList.map { FormOption(it.nickname, it.id.toString()) },
|
|
|
- value = if (locker != null) listOf(locker.userId.toString()) else listOf()
|
|
|
|
|
|
|
+ value = if (locker != null) listOf(locker.userId.toString()) else listOf(),
|
|
|
|
|
+ enabled = enabled
|
|
|
)
|
|
)
|
|
|
// 共锁人
|
|
// 共锁人
|
|
|
list += FormField(
|
|
list += FormField(
|
|
@@ -392,7 +441,8 @@ data class Node(
|
|
|
placeholder = listOf("请选择共锁人"),
|
|
placeholder = listOf("请选择共锁人"),
|
|
|
options = groupUserList.map { FormOption(it.nickname, it.id.toString()) },
|
|
options = groupUserList.map { FormOption(it.nickname, it.id.toString()) },
|
|
|
value = if (group.isNotEmpty()) group.map { it.userId.toString() } else listOf(),
|
|
value = if (group.isNotEmpty()) group.map { it.userId.toString() } else listOf(),
|
|
|
- multiSelect = true
|
|
|
|
|
|
|
+ multiSelect = true,
|
|
|
|
|
+ enabled = enabled
|
|
|
)
|
|
)
|
|
|
} else {
|
|
} else {
|
|
|
// 负责人
|
|
// 负责人
|
|
@@ -404,7 +454,8 @@ data class Node(
|
|
|
true,
|
|
true,
|
|
|
placeholder = listOf("请选择负责人"),
|
|
placeholder = listOf("请选择负责人"),
|
|
|
options = workerUserList.map { FormOption(it.nickname, it.id.toString()) },
|
|
options = workerUserList.map { FormOption(it.nickname, it.id.toString()) },
|
|
|
- value = if (workerUserId > 0) listOf(workerUserId.toString()) else listOf()
|
|
|
|
|
|
|
+ value = if (workerUserId > 0) listOf(workerUserId.toString()) else listOf(),
|
|
|
|
|
+ enabled = enabled
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|