作者 yangfu

增加 机会筛选结果列表

... ... @@ -686,6 +686,35 @@ func (this *ChanceController) SiftingPool() {
msg = m
return
}
if request.SubmitStatus == protocol.Submiting {
request.SiftedStatus = protocol.None
} else if request.SubmitStatus == protocol.Submited {
request.SiftedStatus = protocol.Waiting
} else {
msg = protocol.BadRequestParamWithMessage(2, "obj.SubmitStatus must in (0,1)")
return
}
header := controllers.GetRequestHeader(this.Ctx)
msg = protocol.NewReturnResponse(chance.SiftingPool(header, request))
}
//SiftingResults 筛选结果
//@router /siftingResults [post]
func (this *ChanceController) SiftingResults() {
var msg *protocol.ResponseMessage
defer func() {
this.Resp(msg)
}()
var request *protocol.SiftingResultsRequest
if err := json.Unmarshal(this.ByteBody, &request); err != nil {
log.Error(err)
msg = protocol.BadRequestParam(1)
return
}
if b, m := this.Valid(request); !b {
msg = m
return
}
header := controllers.GetRequestHeader(this.Ctx)
msg = protocol.NewReturnResponse(chance.SiftingResults(header, request))
}
... ...
... ... @@ -687,23 +687,21 @@ and department_id in (%v)`,
func GetSiftingChance(uid int64, submitStatus int, checkResultStatus int, offset int, pageSize int, v interface{}) (total int, err error) {
var where string
if submitStatus == 1 {
where = fmt.Sprintf(`where length(self_checks)>5
order by a.submit_check_time desc`)
where = fmt.Sprintf(`order by a.submit_check_time desc`)
} else {
where = fmt.Sprintf(`where length(self_checks)>5
order by a.chance_approve_time desc`)
where = fmt.Sprintf(`order by a.chance_approve_time desc`)
}
sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos
from (
select a.*,b.user_id chance_user_id,b.source_content,b.enable_status,b.review_status,b.audit_template_id,b.chance_type_id,b.create_at,
b.update_at,b.approve_time chance_approve_time,b.status,b.self_checks,b.check_result_status
b.update_at,b.approve_time chance_approve_time,b.status,b.self_checks,b.check_result_status,b.check_time
from (
select max(id) id,approve_time,approve_data,uid,chance_id,submit_check_status,submit_check_time,level
from audit_flow_process a,(select MAX(id) AS max_id from audit_flow_process as t where t.uid=%v group by chance_id) b
where a.uid=%v and b.max_id=a.id and a.submit_check_status=%v and level>0
GROUP BY chance_id
)a left outer join chance b on a.chance_id = b.id
where b.review_status=3 and b.enable_status=1 and b.status=1 and b.check_result_status =%v and a.level=b.audit_level
where b.review_status=3 and b.enable_status=1 and b.status=1 and b.check_result_status =%v and a.level=b.audit_level and length(b.self_checks)>5
)a left outer join chance_data b on a.chance_id =b.chance_id
%v
limit %v,%v`, uid, uid, submitStatus, checkResultStatus, where, offset, pageSize) //,update_at process_create_time
... ... @@ -718,9 +716,51 @@ from (
where a.uid=%v and b.max_id=a.id and a.submit_check_status=%v and level>0
GROUP BY chance_id
)a left outer join chance b on a.chance_id = b.id
where b.review_status=3 and b.enable_status=1 and b.status=1 and b.check_result_status =%v and a.level=b.audit_level
)a
where length(self_checks)>5
where b.review_status=3 and b.enable_status=1 and b.status=1 and b.check_result_status =%v and a.level=b.audit_level and length(b.self_checks)>5
)a
`, uid, uid, submitStatus, checkResultStatus) //and enable_status =1
if err = utils.ExecuteQueryOne(&total, sqlCount); err != nil {
return
}
if v != nil {
if err = utils.ExecuteQueryAll(v, sql); err != nil {
return
}
}
return
}
//获取筛选结果的机会
//@submitStatus 提交状态:已提交 未提交
//@checkResultStatus 筛选结果状态:通过 / 不通过
func GetSiftingResults(uid int64, submitStatus, checkResultStatus int, offset int, pageSize int, v interface{}) (total int, err error) {
sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos
from (
select a.*,b.user_id chance_user_id,b.source_content,b.enable_status,b.review_status,b.audit_template_id,b.chance_type_id,b.create_at,
b.update_at,b.approve_time chance_approve_time,b.status,b.self_checks,b.check_result_status,b.check_time
from (
select max(id) id,approve_time,approve_data,uid,chance_id,submit_check_status,submit_check_time,level
from audit_flow_process a,(select MAX(id) AS max_id from audit_flow_process as t where t.uid=%v group by chance_id) b
where a.uid=%v and b.max_id=a.id and a.submit_check_status=%v and level>0
GROUP BY chance_id
)a left outer join chance b on a.chance_id = b.id
where b.review_status=3 and b.enable_status=1 and b.status=1 and b.check_result_status =%v and a.level=b.audit_level
)a left outer join chance_data b on a.chance_id =b.chance_id
order by a.check_time desc
limit %v,%v`, uid, uid, submitStatus, checkResultStatus, offset, pageSize) //,update_at process_create_time
sqlCount := fmt.Sprintf(`select count(0)
from (
select a.*,b.user_id chance_user_id,b.source_content,b.enable_status,b.review_status,b.create_at,
b.update_at,b.approve_time chance_approve_time,b.status,b.self_checks,b.check_result_status
from (
select max(id) id,approve_time,approve_data,uid,chance_id,submit_check_status,submit_check_time,level
from audit_flow_process a,(select MAX(id) AS max_id from audit_flow_process as t where t.uid=%v group by chance_id) b
where a.uid=%v and b.max_id=a.id and a.submit_check_status=%v and level>0
GROUP BY chance_id
)a left outer join chance b on a.chance_id = b.id
where b.review_status=3 and b.enable_status=1 and b.status=1 and b.check_result_status =%v and a.level=b.audit_level
)a
`, uid, uid, submitStatus, checkResultStatus) //and enable_status =1
if err = utils.ExecuteQueryOne(&total, sqlCount); err != nil {
return
... ...
... ... @@ -377,6 +377,9 @@ type CommChanceItemOrm struct {
CommentTotal int `orm:"column(comment_total)"`
ZanTotal int `orm:"column(zan_total)"`
ViewTotal int `orm:"column(view_total)"`
TemplateId int `orm:"column(audit_template_id)"`
ChanceTypeId int `orm:"column(chance_type_id)"`
}
/*ChanceDetail 机会详情*/
... ... @@ -671,3 +674,14 @@ type ChanceSiftItemOrm struct {
SubmitCheckTime time.Time `orm:"column(submit_check_time)"` //提交自查时间
}
//机会池筛选项
type ChanceSiftResultOrm struct {
CommChanceItemOrm
//ApproveData string `json:"approveData"` //审核数据
TemplateId int `orm:"column(audit_template_id)"`
ChanceTypeId int `orm:"column(chance_type_id)"`
CheckTime time.Time `orm:"column(check_time)"` //通过时间时间
}
... ...
... ... @@ -10,8 +10,8 @@ import (
)
const (
TypeSubmit = iota + 1
TypeApprove
TypeSubmit = iota + 1 //提交者类型
TypeApprove //审核人类型
)
//提交状态
... ... @@ -23,7 +23,7 @@ const (
//通过状态
const (
None = iota //未提交
Waiting //已提交待审核
Waiting //已提交待处理
Reject //退回
Pass //通过
)
... ... @@ -200,3 +200,14 @@ type SiftingPoolRequest struct {
type SiftingPoolResponse struct {
ChancePoolResponse
}
/*筛选结果 SiftingResults */
type SiftingResultsRequest struct {
PageInfo
Uid int64 `json:"uid"` //注入用户 测试使用
//SubmitStatus int `json:"submitStatus"` //0:待我提交 1:提交
SiftedStatus int `json:"siftedStatus"` //筛选状态 1:待处理 2:通过 3:不通过
}
type SiftingResultsResponse struct {
ChancePoolResponse
}
... ...
... ... @@ -108,6 +108,12 @@ func BadRequestParam(code int) *ResponseMessage {
return NewMesage(code)
}
func BadRequestParamWithMessage(code int, message string) *ResponseMessage {
msg := NewMesage(code)
msg.Errmsg = message
return msg
}
func NewSuccessWithMessage(msg string) *ErrWithMessage {
return &ErrWithMessage{
Err: nil,
... ...
... ... @@ -265,6 +265,14 @@ func init() {
beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
beego.ControllerComments{
Method: "SiftingResults",
Router: `/siftingResults`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
beego.ControllerComments{
Method: "ChanceStatistics",
Router: `/statistics`,
AllowHTTPMethods: []string{"post"},
... ...
... ... @@ -430,3 +430,44 @@ func NewChanceSelfCheck(header *protocol.RequestHeader, check protocol.SelfCheck
Type: checkerType,
}
}
//新建通用列表项
func NewCommonListItem(header *protocol.RequestHeader, ormItem protocol.CommChanceItemOrm) protocol.CommonListItem {
commItem := protocol.CommonListItem{}
commItem.Chance, commItem.ChanceStatus = SetChanceItem(header, ormItem)
commItem.ReviewStatus = ormItem.ReviewStatus
commItem.ChanceId = ormItem.ChanceId
////模板数据
commItem.ChanceTemplate = GetTemplate(ormItem.TemplateId)
commItem.ChanceType = GetChanceType(ormItem.ChanceTypeId)
return commItem
}
//获取模板
func GetTemplate(templateId int) protocol.NameItem {
if template, e := models.GetAuditTemplateById(int64(templateId)); e == nil {
item := protocol.NameItem{
Id: int(template.Id),
Name: template.Name,
}
return item
} else {
log.Error(templateId, e)
}
return protocol.NameItem{}
}
//获取机会一级分类
func GetChanceType(chanceTypeId int) protocol.NameItem {
if template, e := models.GetChanceTypeById(chanceTypeId); e == nil {
item := protocol.NameItem{
Id: int(template.Id),
Name: template.Name,
}
return item
} else {
log.Error(chanceTypeId, e)
}
return protocol.NameItem{}
}
... ...
... ... @@ -2234,14 +2234,6 @@ func SiftingPool(header *protocol.RequestHeader, request *protocol.SiftingPoolRe
if request.Uid != 0 {
header.UserId = request.Uid
}
if request.SubmitStatus == protocol.Submiting {
request.SiftedStatus = protocol.None
} else if request.SubmitStatus == protocol.Submited {
request.SiftedStatus = protocol.Waiting
} else {
err = protocol.NewCustomMessage(2, "obj.SubmitStatus must in (0,1)")
return
}
if rsp.Total, err = models.GetSiftingChance(header.UserId, request.SubmitStatus, request.SiftedStatus, request.Offset(), request.PageSize, &ormItems); err != nil {
if err == orm.ErrNoRows {
err = nil
... ... @@ -2252,21 +2244,41 @@ func SiftingPool(header *protocol.RequestHeader, request *protocol.SiftingPoolRe
}
for i := 0; i < len(ormItems); i++ {
ormItem := ormItems[i]
commItem := protocol.CommonListItem{}
commItem.Chance, commItem.ChanceStatus = agg.SetChanceItem(header, ormItem.CommChanceItemOrm)
commItem.ReviewStatus = ormItem.ReviewStatus
commItem.ChanceId = ormItem.ChanceId
commItem := agg.NewCommonListItem(header, ormItem.CommChanceItemOrm)
commItem.Chance.CreateTime = ormItem.ChanceApproveTime.Unix() * 1000
if request.SubmitStatus == protocol.Submited {
commItem.Chance.CreateTime = ormItem.SubmitCheckTime.Unix() * 1000
}
rsp.List = append(rsp.List, commItem)
}
//模板数据
commItem.ChanceTemplate = getTemplate(ormItem.TemplateId)
commItem.ChanceType = getChanceType(ormItem.ChanceTypeId)
return
}
//筛选结果
func SiftingResults(header *protocol.RequestHeader, request *protocol.SiftingResultsRequest) (rsp *protocol.SiftingResultsResponse, err error) {
var (
ormItems []protocol.ChanceSiftResultOrm
)
rsp = &protocol.SiftingResultsResponse{}
rsp.List = make([]protocol.CommonListItem, 0)
//测试使用
if request.Uid != 0 {
header.UserId = request.Uid
}
if rsp.Total, err = models.GetSiftingResults(header.UserId, protocol.Submited, request.SiftedStatus, request.Offset(), request.PageSize, &ormItems); err != nil {
if err == orm.ErrNoRows {
err = nil
return
}
log.Error(err)
return
}
for i := 0; i < len(ormItems); i++ {
ormItem := ormItems[i]
commItem := agg.NewCommonListItem(header, ormItem.CommChanceItemOrm)
commItem.Chance.CreateTime = ormItem.CheckTime.Unix() * 1000
rsp.List = append(rsp.List, commItem)
}
return
}
... ...