作者 tangxvhui

更新

... ... @@ -37,6 +37,7 @@ type Chance struct {
SelfChecks string `orm:"column(self_checks)" description:"自查内容"`
CheckResultStatus int8 ` orm:"column(check_result_status)"`
CheckTime time.Time `orm:"column(check_time);type(timestamp);"`
CheckResult string `orm:"column(check_result)" description:"自查内容筛选结果"`
}
func (t *Chance) TableName() string {
... ... @@ -119,7 +120,12 @@ type ChanceSelfCheckData struct {
func (m *Chance) GetSelfCheckData() []ChanceSelfCheckData {
var data []ChanceSelfCheckData
json.Unmarshal([]byte(m.SelfChecks), &data)
if m.CheckResultStatus == CheckResultStatusPass {
json.Unmarshal([]byte(m.CheckResult), &data)
} else {
json.Unmarshal([]byte(m.SelfChecks), &data)
}
return data
}
... ...
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
}
... ...