...
|
...
|
@@ -8,7 +8,7 @@ import ( |
|
|
"oppmg/utils"
|
|
|
)
|
|
|
|
|
|
//GetChanceCheckResultInfo 获取机会详情
|
|
|
//GetChanceCheckResultInfo 获取机会自查内容筛选详情
|
|
|
func GetChanceCheckResultInfo(chanceId int64, companyid int64) (protocol.ReponseChanceCheckResult, error) {
|
|
|
var (
|
|
|
chanceData *models.Chance
|
...
|
...
|
@@ -31,23 +31,82 @@ func GetChanceCheckResultInfo(chanceId int64, companyid int64) (protocol.Reponse |
|
|
log.Error("机会的自查内容筛选状态错误")
|
|
|
return rsp, protocol.NewErrWithMessage("1")
|
|
|
}
|
|
|
rsp, err = getChanceCheckResultData(chanceId)
|
|
|
return rsp, err
|
|
|
}
|
|
|
|
|
|
//getChanceCheckResultData 机会自查内容筛选详情数据输出
|
|
|
func getChanceCheckResultData(chanceId int64) (protocol.ReponseChanceCheckResult, error) {
|
|
|
var (
|
|
|
checkResultData []models.ChanceCheckResult
|
|
|
err error
|
|
|
)
|
|
|
rsp := protocol.ReponseChanceCheckResult{}
|
|
|
checkResultData, err = models.GetChanceCheckResultByChancce(chanceId)
|
|
|
if err != nil {
|
|
|
log.Error("未获得指定的机会自查内容筛选结果,err;%s", err)
|
|
|
return rsp, nil
|
|
|
}
|
|
|
//组装响应数据
|
|
|
//定义动态数据列
|
|
|
customItems := utils.NewArraySetString()
|
|
|
//自查内容中的用户id
|
|
|
userIds := utils.NewArraySetInt64()
|
|
|
//自查内容项
|
|
|
checkItems := utils.NewArraySetString()
|
|
|
_ = checkResultData
|
|
|
_ = customItems
|
|
|
_ = checkItems
|
|
|
return rsp, err
|
|
|
checkResultMap := make(map[string]*protocol.ChanceCheckResultData)
|
|
|
for _, v := range checkResultData {
|
|
|
userIds.Add(v.UserCompanyId)
|
|
|
checkItems.Add(v.CheckItem)
|
|
|
if _, ok := checkResultMap[v.CheckItem]; ok {
|
|
|
checkResultMap[v.CheckItem].CustomItemData[fmt.Sprint(v.UserCompanyId)] = v.Answer
|
|
|
continue
|
|
|
}
|
|
|
userAnswer := map[string]string{
|
|
|
fmt.Sprint(v.UserCompanyId): v.Answer,
|
|
|
}
|
|
|
checkResultMap[v.CheckItem] = &protocol.ChanceCheckResultData{
|
|
|
CheckItem: v.CheckItem,
|
|
|
CustomItemData: userAnswer,
|
|
|
}
|
|
|
|
|
|
}
|
|
|
usernameMap := make(map[string]string)
|
|
|
for _, v := range userIds.ToSlice() {
|
|
|
idString := fmt.Sprint(v)
|
|
|
u, err := models.GetUserCompanyById(v)
|
|
|
if err == nil {
|
|
|
usernameMap[idString] = u.NickName
|
|
|
} else {
|
|
|
usernameMap[idString] = idString
|
|
|
}
|
|
|
rsp.CustomItem = append(rsp.CustomItem, usernameMap[idString])
|
|
|
}
|
|
|
for _, v := range checkItems.ToSlice() {
|
|
|
newCustomItemData := map[string]string{}
|
|
|
for kk, vv := range usernameMap {
|
|
|
if answer, ok := checkResultMap[v].CustomItemData[kk]; ok {
|
|
|
newCustomItemData[vv] = answer
|
|
|
} else {
|
|
|
newCustomItemData[vv] = ""
|
|
|
}
|
|
|
}
|
|
|
answerYes := 0 //回答:是
|
|
|
answerNo := 0 //回答:否
|
|
|
answerAny := 0 //回答:不清楚
|
|
|
checkResultMap[v].CustomItemData = newCustomItemData
|
|
|
for _, answerData := range checkResultMap[v].CustomItemData {
|
|
|
switch answerData {
|
|
|
case "是":
|
|
|
answerYes++
|
|
|
case "否":
|
|
|
answerNo++
|
|
|
case "不清楚":
|
|
|
answerAny++
|
|
|
}
|
|
|
}
|
|
|
checkResultMap[v].Total = fmt.Sprintf("是:%d 否:%d 不清楚:%d", answerYes, answerNo, answerAny)
|
|
|
rsp.CheckData = append(rsp.CheckData, *checkResultMap[v])
|
|
|
}
|
|
|
return rsp, nil
|
|
|
}
|
|
|
|
|
|
func GetChanceCheckResultList(pageIndex int, pageSize int, companyId int64, checkResultStatus int8) protocol.ResponseChanceCheckResultList {
|
...
|
...
|
@@ -145,3 +204,47 @@ func GetChanceCheckResultList(pageIndex int, pageSize int, companyId int64, chec |
|
|
returnData.CurrentPage = pageIndex
|
|
|
return returnData
|
|
|
}
|
|
|
|
|
|
func ChanceCheckResultPass(chanceId int64, companyId int64) error {
|
|
|
var (
|
|
|
err error
|
|
|
chanceData *models.Chance
|
|
|
)
|
|
|
chanceData, err = models.GetChanceById(chanceId)
|
|
|
if err != nil {
|
|
|
log.Error("未找到指定机会id=%d,err:%s", chanceId, err)
|
|
|
return protocol.NewErrWithMessage("1")
|
|
|
}
|
|
|
if chanceData.CompanyId != companyId {
|
|
|
log.Error("机会对应的公司不匹配")
|
|
|
return protocol.NewErrWithMessage("1")
|
|
|
}
|
|
|
chanceData.CheckResultStatus = models.CheckResultStatusPass
|
|
|
err = models.UpdateChanceById(chanceData, []string{"CheckResultStatus"})
|
|
|
if err != nil {
|
|
|
log.Error("更新chance数据失败,err;%s", err)
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
func ChanceCheckResultNoPass(chanceId int64, companyId int64) error {
|
|
|
var (
|
|
|
err error
|
|
|
chanceData *models.Chance
|
|
|
)
|
|
|
chanceData, err = models.GetChanceById(chanceId)
|
|
|
if err != nil {
|
|
|
log.Error("未找到指定机会id=%d,err:%s", chanceId, err)
|
|
|
return protocol.NewErrWithMessage("1")
|
|
|
}
|
|
|
if chanceData.CompanyId != companyId {
|
|
|
log.Error("机会对应的公司不匹配")
|
|
|
return protocol.NewErrWithMessage("1")
|
|
|
}
|
|
|
chanceData.CheckResultStatus = models.CheckResultStatusNOPass
|
|
|
err = models.UpdateChanceById(chanceData, []string{"CheckResultStatus"})
|
|
|
if err != nil {
|
|
|
log.Error("更新chance数据失败,err;%s", err)
|
|
|
}
|
|
|
return nil
|
|
|
} |
...
|
...
|
|