|
@@ -2,10 +2,11 @@ package controllers
|
|
|
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
- contractReq "hongze/hongze_mobile_admin/models/request/contract"
|
|
|
+ sealReq "hongze/hongze_mobile_admin/models/request/seal"
|
|
|
sealResp "hongze/hongze_mobile_admin/models/response/seal"
|
|
|
"hongze/hongze_mobile_admin/models/tables/contract_approval"
|
|
|
"hongze/hongze_mobile_admin/models/tables/contract_approval_record"
|
|
|
+ "hongze/hongze_mobile_admin/models/tables/seal"
|
|
|
sealService "hongze/hongze_mobile_admin/services/seal"
|
|
|
"hongze/hongze_mobile_admin/utils"
|
|
|
"rdluck_tools/paging"
|
|
@@ -211,50 +212,109 @@ func (this *SealApprovalCommon) List() {
|
|
|
}, "获取成功")
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-func (this *SealApprovalCommon) Reject() {
|
|
|
- var req contractReq.RejectReq
|
|
|
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func (this *SealApprovalCommon) Detail() {
|
|
|
+
|
|
|
+ contractApprovalId, _ := this.GetInt("ContractApprovalId")
|
|
|
+
|
|
|
+
|
|
|
+ contractApprovalInfo, err := contract_approval.GetContractApprovalById(contractApprovalId)
|
|
|
if err != nil {
|
|
|
- this.FailWithMessage("参数解析异常!", "参数解析失败,Err:"+err.Error())
|
|
|
+ this.FailWithMessage("获取审批单失败!", "获取审批单失败,Err:"+err.Error())
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
- contractApprovalId := req.ApprovalId
|
|
|
- if contractApprovalId <= 0 {
|
|
|
- this.FailWithMessage("请传入审批单编号!", "请传入审批单编号!")
|
|
|
+ var sealDetail *seal.Seal
|
|
|
+ jsonErr := json.Unmarshal([]byte(contractApprovalInfo.ContractDetail), sealDetail)
|
|
|
+ if jsonErr != nil {
|
|
|
+ this.FailWithMessage("审批合同数据转换失败!", "审批合同数据转换失败,Err:"+jsonErr.Error())
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
- approvalInfo, err := contract_approval.GetContractApprovalById(contractApprovalId)
|
|
|
+
|
|
|
+
|
|
|
+ sealInfo, err := seal.GetSealInfoById(contractApprovalInfo.ContractId)
|
|
|
if err != nil {
|
|
|
- this.FailWithMessage("获取审批单失败!", "获取审批单失败,Err:"+err.Error())
|
|
|
+ this.FailWithMessage("获取用印详情失败!", "获取用印详情失败,Err:"+err.Error())
|
|
|
return
|
|
|
}
|
|
|
- if approvalInfo.Status != "待审批" {
|
|
|
- this.FailWithMessage("当前审批单状态异常,不允许审批", "当前审批单状态异常,不允许审批,审批单状态:"+approvalInfo.Status)
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+ sealDetail.Status = sealInfo.Status
|
|
|
+
|
|
|
+
|
|
|
+ var sealOpButton sealResp.OpButton
|
|
|
+
|
|
|
|
|
|
- approvalRecordList, err := contract_approval_record.GetContractApprovalRecordListByContractApprovalIdAndNodeId(contractApprovalId, approvalInfo.CurrNodeId)
|
|
|
+ approvalRecordList, err := contract_approval_record.GetContractApprovalRecordListByContractApprovalId(contractApprovalId)
|
|
|
if err != nil {
|
|
|
this.FailWithMessage("获取审批失败!", "获取审批失败,Err:"+err.Error())
|
|
|
return
|
|
|
}
|
|
|
- var approvalRecord *contract_approval_record.ContractApprovalRecord
|
|
|
- for _, tmpApprovalRecord := range approvalRecordList {
|
|
|
- if tmpApprovalRecord.NodeType == "check" && tmpApprovalRecord.ApproveUserId == this.AdminWx.AdminId {
|
|
|
- approvalRecord = tmpApprovalRecord
|
|
|
+ flowNodeMap := make(map[int][]contract_approval_record.ContractApprovalRecord, 0)
|
|
|
+ keySort := make([]int, 0)
|
|
|
+ for _, approvalRecord := range approvalRecordList {
|
|
|
+
|
|
|
+ if contractApprovalInfo.CurrNodeId == approvalRecord.NodeId && contractApprovalInfo.Status == "待审批" {
|
|
|
+ if this.AdminWx.AdminId == approvalRecord.ApproveUserId && approvalRecord.NodeType == "check" {
|
|
|
+ sealOpButton.ApprovalButton = true
|
|
|
+ }
|
|
|
}
|
|
|
+ if tmpFlowNodeList, ok := flowNodeMap[approvalRecord.NodeId]; ok {
|
|
|
+ flowNodeMap[approvalRecord.NodeId] = append(tmpFlowNodeList, *approvalRecord)
|
|
|
+ } else {
|
|
|
+ tmpFlowNodeList := make([]contract_approval_record.ContractApprovalRecord, 1)
|
|
|
+ tmpFlowNodeList[0] = *approvalRecord
|
|
|
+ flowNodeMap[approvalRecord.NodeId] = tmpFlowNodeList
|
|
|
+
|
|
|
+ keySort = append(keySort, approvalRecord.NodeId)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ flowNodeListResp := make([][]contract_approval_record.ContractApprovalRecord, 0)
|
|
|
+ for _, key := range keySort {
|
|
|
+ flowNodeListResp = append(flowNodeListResp, flowNodeMap[key])
|
|
|
}
|
|
|
|
|
|
- if approvalRecord == nil {
|
|
|
- this.FailWithMessage("当前账号没有审批权限", "当前账号没有审批权限")
|
|
|
+
|
|
|
+ if (this.AdminWx.RoleTypeCode == utils.ROLE_TYPE_CODE_COMPLIANCE || this.AdminWx.AdminId == sealInfo.UserId) && sealInfo.Status == "已审批" {
|
|
|
+ sealOpButton.Invalid = true
|
|
|
}
|
|
|
- err = sealService.Reject(approvalRecord, this.AdminWx, req.Remark)
|
|
|
+ resp := sealResp.SealDetailResp{
|
|
|
+ SealDetail: sealDetail,
|
|
|
+ FlowNodeList: flowNodeListResp,
|
|
|
+ OpButton: sealOpButton,
|
|
|
+ }
|
|
|
+ this.OkDetailed(resp, "获取成功")
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func (this *SealApprovalCommon) Reject() {
|
|
|
+ var req sealReq.RejectReq
|
|
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
+ if err != nil {
|
|
|
+ this.FailWithMessage("参数解析异常!", "参数解析失败,Err:"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ sealId := req.SealId
|
|
|
+ if sealId <= 0 {
|
|
|
+ this.FailWithMessage("请传入用印单编号!", "请传入用印单编号!")
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ sealInfo, approvalInfo, approvalRecord, err := sealService.CheckApproveAuth(sealId, this.AdminWx)
|
|
|
+ if err != nil {
|
|
|
+ this.FailWithMessage("驳回审批失败!", "驳回审批失败,Err:"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ err = sealService.Reject(sealInfo, approvalInfo, approvalRecord, this.AdminWx, req.Remark)
|
|
|
if err != nil {
|
|
|
this.FailWithMessage("驳回审批失败!", "驳回审批失败,Err:"+err.Error())
|
|
|
return
|
|
@@ -268,45 +328,26 @@ func (this *SealApprovalCommon) Reject() {
|
|
|
|
|
|
|
|
|
func (this *SealApprovalCommon) Approved() {
|
|
|
-
|
|
|
- var req contractReq.ApprovedReq
|
|
|
+ var req sealReq.ApprovedReq
|
|
|
err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
if err != nil {
|
|
|
this.FailWithMessage("参数解析异常!", "参数解析失败,Err:"+err.Error())
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
- contractApprovalId := req.ApprovalId
|
|
|
- if contractApprovalId <= 0 {
|
|
|
- this.FailWithMessage("请传入审批单编号!", "请传入审批单编号!")
|
|
|
+
|
|
|
+ sealId := req.SealId
|
|
|
+ if sealId <= 0 {
|
|
|
+ this.FailWithMessage("请传入用印单编号!", "请传入用印单编号!")
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
- approvalInfo, err := contract_approval.GetContractApprovalById(contractApprovalId)
|
|
|
- if err != nil {
|
|
|
- this.FailWithMessage("获取审批单失败!", "获取审批单失败,Err:"+err.Error())
|
|
|
- return
|
|
|
- }
|
|
|
- if approvalInfo.Status != "待审批" {
|
|
|
- this.FailWithMessage("当前审批单状态异常,不允许审批", "当前审批单状态异常,不允许审批,审批单状态:"+approvalInfo.Status)
|
|
|
- }
|
|
|
-
|
|
|
- approvalRecordList, err := contract_approval_record.GetContractApprovalRecordListByContractApprovalIdAndNodeId(contractApprovalId, approvalInfo.CurrNodeId)
|
|
|
+
|
|
|
+
|
|
|
+ sealInfo, approvalInfo, approvalRecord, err := sealService.CheckApproveAuth(sealId, this.AdminWx)
|
|
|
if err != nil {
|
|
|
- this.FailWithMessage("获取审批失败!", "获取审批失败,Err:"+err.Error())
|
|
|
+ this.FailWithMessage("驳回审批失败!", "驳回审批失败,Err:"+err.Error())
|
|
|
return
|
|
|
}
|
|
|
- var approvalRecord *contract_approval_record.ContractApprovalRecord
|
|
|
- for _, tmpApprovalRecord := range approvalRecordList {
|
|
|
- if tmpApprovalRecord.NodeType == "check" && tmpApprovalRecord.ApproveUserId == this.AdminWx.AdminId {
|
|
|
- approvalRecord = tmpApprovalRecord
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if approvalRecord == nil {
|
|
|
- this.FailWithMessage("当前账号没有审批权限", "当前账号没有审批权限")
|
|
|
- }
|
|
|
- err = sealService.Approved(approvalRecord, this.AdminWx, req.Remark)
|
|
|
+ err = sealService.Approved(sealInfo, approvalInfo, approvalRecord, this.AdminWx, req.Remark)
|
|
|
if err != nil {
|
|
|
this.FailWithMessage("审核失败!", "审核失败,Err:"+err.Error())
|
|
|
return
|