|
@@ -224,8 +224,10 @@ func ApprovalListExport(this *SealApprovalController, condition, joinCondition s
|
|
|
if len(list) > 0 {
|
|
|
// 取出所有列表的关联合同id
|
|
|
contractIdSlice := make([]string, 0)
|
|
|
+ contractApprovalIdSlice := make([]string, 0)
|
|
|
for i := 0; i < len(list); i++ {
|
|
|
contractIdSlice = append(contractIdSlice, strconv.Itoa(list[i].ContractId))
|
|
|
+ contractApprovalIdSlice = append(contractApprovalIdSlice, strconv.Itoa(list[i].ContractApprovalId))
|
|
|
}
|
|
|
|
|
|
// 获取所有关联的合同列表
|
|
@@ -244,11 +246,70 @@ func ApprovalListExport(this *SealApprovalController, condition, joinCondition s
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ selfContractApprovalRecordMap := make(map[int][]*contract.ContractApprovalRecord)
|
|
|
+ {
|
|
|
+ if len(contractApprovalIdSlice) > 0 {
|
|
|
+ contractApprovalIdStr := strings.Join(contractApprovalIdSlice, ",")
|
|
|
+ contractApprovalList, tempErr := contract.GetContractApprovalRecordListByContractApprovalIds(contractApprovalIdStr)
|
|
|
+ if tempErr != nil {
|
|
|
+ err = errors.New(fmt.Sprint("获取合同审批记录失败,Err:"+tempErr.Error(), err))
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for i := 0; i < len(contractApprovalList); i++ {
|
|
|
+ selfContractApprovalRecordMap[contractApprovalList[i].ContractApprovalId] = append(selfContractApprovalRecordMap[contractApprovalList[i].ContractApprovalId], contractApprovalList[i])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
for i, v := range list {
|
|
|
// 合同编码
|
|
|
if selfContract, has := selfContractMap[v.ContractId]; has {
|
|
|
list[i].ContractCode = selfContract.ContractCode
|
|
|
}
|
|
|
+
|
|
|
+ // 审批人和抄送人
|
|
|
+ if recordList, ok := selfContractApprovalRecordMap[v.ContractApprovalId]; ok {
|
|
|
+ keySort := make([]int, 0)
|
|
|
+ flowNodeMap := make(map[int][]contract.ContractApprovalRecord, 0)
|
|
|
+ for _, approvalRecord := range recordList {
|
|
|
+ if tmpFlowNodeList, ok := flowNodeMap[approvalRecord.NodeId]; ok {
|
|
|
+ flowNodeMap[approvalRecord.NodeId] = append(tmpFlowNodeList, *approvalRecord)
|
|
|
+ } else {
|
|
|
+ tmpFlowNodeList := make([]contract.ContractApprovalRecord, 1)
|
|
|
+ tmpFlowNodeList[0] = *approvalRecord
|
|
|
+ flowNodeMap[approvalRecord.NodeId] = tmpFlowNodeList
|
|
|
+
|
|
|
+ keySort = append(keySort, approvalRecord.NodeId)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for ii, key := range keySort {
|
|
|
+ if ii == 0 {
|
|
|
+ if node, ok := flowNodeMap[key]; ok {
|
|
|
+ for _, vv := range node {
|
|
|
+ if vv.NodeType == "check" {
|
|
|
+ list[i].FirstLevelApprovers += vv.ApproveUserName + ","
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if node, ok := flowNodeMap[key]; ok {
|
|
|
+ for _, vv := range node {
|
|
|
+ if vv.NodeType == "check" {
|
|
|
+ list[i].SecondLevelApprovers += vv.ApproveUserName + ","
|
|
|
+ } else if vv.NodeType == "cc" && list[i].FirstLevelCC == "" {
|
|
|
+ list[i].FirstLevelCC += vv.ApproveUserName + ","
|
|
|
+ } else {
|
|
|
+ list[i].SecondLevelCC += vv.ApproveUserName + ","
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ list[i].FirstLevelApprovers = strings.TrimRight(list[i].FirstLevelApprovers, ",")
|
|
|
+ list[i].FirstLevelCC = strings.TrimRight(list[i].FirstLevelCC, ",")
|
|
|
+ list[i].SecondLevelApprovers = strings.TrimRight(list[i].SecondLevelApprovers, ",")
|
|
|
+ list[i].SecondLevelCC = strings.TrimRight(list[i].SecondLevelCC, ",")
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
//创建excel
|
|
@@ -327,17 +388,17 @@ func ApprovalListExport(this *SealApprovalController, condition, joinCondition s
|
|
|
cellH := row.AddCell()
|
|
|
cellH.Value = v.ApplyUserName
|
|
|
cellI := row.AddCell()
|
|
|
- cellI.Value = v.CreateTimeStr
|
|
|
+ cellI.Value = v.CreateTime.Format(utils.FormatDateTime)
|
|
|
cellJ := row.AddCell()
|
|
|
cellJ.Value = v.Status
|
|
|
cellK := row.AddCell()
|
|
|
- cellK.Value = "一级审批人"
|
|
|
+ cellK.Value = v.FirstLevelApprovers
|
|
|
cellL := row.AddCell()
|
|
|
- cellL.Value = "一级抄送人"
|
|
|
+ cellL.Value = v.FirstLevelCC
|
|
|
cellM := row.AddCell()
|
|
|
- cellM.Value = "二级审批人"
|
|
|
+ cellM.Value = v.SecondLevelApprovers
|
|
|
cellN := row.AddCell()
|
|
|
- cellN.Value = "二级抄送人"
|
|
|
+ cellN.Value = v.SecondLevelCC
|
|
|
}
|
|
|
|
|
|
err = xlsxFile.Save(downLoadnFilePath)
|