|
|
package audit
|
|
|
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
"oppmg/common/log"
|
|
|
"oppmg/models"
|
...
|
...
|
@@ -243,7 +244,15 @@ func ChanceCheckResultPass(chanceId int64, companyId int64) error { |
|
|
return protocol.NewErrWithMessage("1")
|
|
|
}
|
|
|
chanceData.CheckResultStatus = models.CheckResultStatusPass
|
|
|
err = models.UpdateChanceById(chanceData, []string{"CheckResultStatus"})
|
|
|
checkResultData, err := models.GetChanceCheckResultByChancce(chanceId)
|
|
|
if err != nil {
|
|
|
log.Error("未找到相应的筛选结果")
|
|
|
}
|
|
|
collectCheckData := collectChanceCheckResultData(checkResultData)
|
|
|
if jsonBt, err := json.Marshal(collectCheckData); err == nil {
|
|
|
chanceData.CheckResult = string(jsonBt)
|
|
|
}
|
|
|
err = models.UpdateChanceById(chanceData, []string{"CheckResultStatus", "CheckResult"})
|
|
|
if err != nil {
|
|
|
log.Error("更新chance数据失败,err;%s", err)
|
|
|
}
|
...
|
...
|
@@ -265,7 +274,15 @@ func ChanceCheckResultNoPass(chanceId int64, companyId int64) error { |
|
|
return protocol.NewErrWithMessage("1")
|
|
|
}
|
|
|
chanceData.CheckResultStatus = models.CheckResultStatusNOPass
|
|
|
err = models.UpdateChanceById(chanceData, []string{"CheckResultStatus"})
|
|
|
checkResultData, err := models.GetChanceCheckResultByChancce(chanceId)
|
|
|
if err != nil {
|
|
|
log.Error("未找到相应的筛选结果")
|
|
|
}
|
|
|
collectCheckData := collectChanceCheckResultData(checkResultData)
|
|
|
if jsonBt, err := json.Marshal(collectCheckData); err == nil {
|
|
|
chanceData.CheckResult = string(jsonBt)
|
|
|
}
|
|
|
err = models.UpdateChanceById(chanceData, []string{"CheckResultStatus", "CheckResult"})
|
|
|
if err != nil {
|
|
|
log.Error("更新chance数据失败,err;%s", err)
|
|
|
}
|
...
|
...
|
@@ -284,7 +301,7 @@ type chanceCheckResultTotal struct { |
|
|
}
|
|
|
|
|
|
//collectChanceCheckResultData 汇总机会自查内容筛选结果
|
|
|
func collectChanceCheckResultData(checkResultData []models.ChanceCheckResult) ([]models.ChanceSelfCheckData, error) {
|
|
|
func collectChanceCheckResultData(checkResultData []models.ChanceCheckResult) []models.ChanceSelfCheckData {
|
|
|
checkResultMap := map[int64]*chanceCheckResultTotal{}
|
|
|
checkReusltSlice := []*chanceCheckResultTotal{}
|
|
|
for _, resultData := range checkResultData {
|
...
|
...
|
@@ -324,7 +341,7 @@ func collectChanceCheckResultData(checkResultData []models.ChanceCheckResult) ([ |
|
|
}
|
|
|
pid := checkReusltSlice[i].CheckPid
|
|
|
if _, ok := checkResultMap[pid]; ok {
|
|
|
checkResultMap[pid].Child = append(checkResultMap[pid].Child, checkResultMap[pid])
|
|
|
checkResultMap[pid].Child = append(checkResultMap[pid].Child, checkReusltSlice[i])
|
|
|
}
|
|
|
}
|
|
|
var selfCheckData []models.ChanceSelfCheckData
|
...
|
...
|
@@ -363,5 +380,5 @@ func collectChanceCheckResultData(checkResultData []models.ChanceCheckResult) ([ |
|
|
selfCheckData = append(selfCheckData, dd)
|
|
|
}
|
|
|
}
|
|
|
return selfCheckData, nil
|
|
|
return selfCheckData
|
|
|
} |
...
|
...
|
|