作者 yangfu

修改

机会审核(退回理由)
机会池/筛选池/筛选结果
部门统计/储备池
... ... @@ -449,12 +449,23 @@ func (this *ChanceController) ChanceApprove() {
return
}
}
if request.ReviewStatus != protocol.ReviewStatusReturn && len(request.Reason) > 0 {
msg = protocol.BadRequestParamWithMessage(2, "机会退回时才需要填写理由")
log.Error(msg)
return
}
if e := request.SelfChecks.SetSelfChecksLevel1ByRule(); e != nil {
log.Error(e)
msg = protocol.NewReturnResponse(nil, e)
return
}
if len([]rune(request.Reason)) > 100 {
msg = protocol.BadRequestParamWithMessage(2, "填写理由长度有误,最多输入100个字符")
log.Error(msg)
return
}
header := controllers.GetRequestHeader(this.Ctx)
request.ApproveData.Reason = request.Reason
msg = protocol.NewReturnResponse(chance.ChanceApprove(header, request))
}
... ...
... ... @@ -14,7 +14,7 @@ type ConfigController struct {
controllers.BaseController
}
//GetConfigScore
//GetConfigScore 获取评分配置
//@router /score/get [post]
func (this *ConfigController) GetConfigScore() {
var msg *protocol.ResponseMessage
... ...
... ... @@ -35,6 +35,7 @@ type AuditFlowProcess struct {
SelfChecks string `orm:"column(self_checks);null" description:"自查内容"`
SubmitCheckTime time.Time `orm:"column(submit_check_time);type(timestamp)" description:"提交筛选时间"`
SubmitCheckStatus int `orm:"column(submit_check_status)" description:"提交筛选状态 0:未提交 1:已提交"`
Reason string `orm:"column(reason);null" description:"理由(退回)"`
}
func (t *AuditFlowProcess) TableName() string {
... ... @@ -128,7 +129,7 @@ func GetAuditFlowProcessList(chanceId int64) (v []*AuditFlowProcess, err error)
o := orm.NewOrm()
sql := `select id ,chance_id,uid,level,is_active,IFNULL(approve_time,NOW()) approve_time,basic_score,extra_score,value_score,discovery_score,
review_status,audit_flow_type,flow_type,action_type,update_at,create_at,enable_status,approve_data,user_name,role_name,role_id,approve_message,
template_id,self_checks from audit_flow_process
template_id,self_checks,reason from audit_flow_process
where chance_id =? and enable_status=1 order by approve_time,level desc`
if _, err = o.Raw(sql, chanceId).QueryRows(&v); err == nil {
return v, nil
... ...
package models
import (
"bytes"
"fmt"
"opp/internal/utils"
"time"
... ... @@ -16,7 +17,7 @@ type Chance struct {
ChanceTypeId int `orm:"column(chance_type_id)" description:"表chance_type.id 机会类型 "`
AuditTemplateId int64 `orm:"column(audit_template_id)" description:"表audit_template.id 所属审批模板编号"`
AuditTemplateConfig string `orm:"column(audit_template_config);size(255);null" description:"模板配置 (存旧的配置信息,对新改动的不影响)"`
Content string `orm:"column(content)" description:"格式化后的文本内容"`
//Content string `orm:"column(content)" description:"格式化后的文本内容"`
SourceContent string `orm:"column(source_content)" description:"原始表单内容 json"`
ViewTotal int `orm:"column(view_total)" description:"查看总数"`
CommentTotal int `orm:"column(comment_total)" description:"评论总数"`
... ... @@ -39,6 +40,8 @@ type Chance struct {
CheckTime time.Time `orm:"column(check_time);type(timestamp)" description:"时间"`
CheckResultStatus int `orm:"column(check_result_status)" description:"机会筛选状态【1:待处理】【2:通过】【3:不通过】"`
CheckResult string `orm:"column(check_result);null" description:"筛选结果"`
Type int8 `orm:"column(type)" description:"机会类别:0:机会池 1:储备池 "`
ReserveTypeId int `orm:"column(reserve_type_id)" description:"当前审批步骤"`
}
const (
... ... @@ -46,6 +49,32 @@ const (
ChanceStatusClose = 2 //关闭
)
const (
ChancePool = iota //机会池
ChanceReserve //机会储备池
)
type ChancePoolOption struct {
ChanceTypeId int //机会类型编号
DIds []int //部门编号列表
Type int8 //机会类型
ReserveTypeId int //机会储备类型编号
}
//机会池查询选项
//@chanceTypeId 机会类型编号
//@deps 部门编号列表
//@t 机会类型
//@rt 储备类型
func NewChancePoolOption(chanceTypeId int, deps []int, t int8, rt int) *ChancePoolOption {
return &ChancePoolOption{
ChanceTypeId: chanceTypeId,
DIds: deps,
Type: t,
ReserveTypeId: rt,
}
}
var (
SqlGetChanceSelfChecks = `select user_id,review_status,self_checks from chance where id =?` //机会自查数据
)
... ... @@ -273,28 +302,28 @@ where user_id =?`
}
//type4 查看所有机会
func GetChancePoolAll(uid, cid int64, chanceTypeId int, dIds []int, lastId int64, pageSize int, v interface{}) (total int, err error) {
var filterDepartment string = getFilterSqlByDIds(dIds)
func GetChancePoolAll(uid, cid int64, option *ChancePoolOption, lastId int64, pageSize int, v interface{}) (total int, err error) {
var filter string = getFilterSql(option)
sql := fmt.Sprintf(`select a.*,b.images,speechs,videos
from (
select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total from chance
where company_id=? and review_status=3 and (?=0 or chance_type_id =?) and (?=0 or unix_timestamp(approve_time)<?) and enable_status=1 and status=1 %v
where company_id=? and review_status=3 and (?=0 or unix_timestamp(approve_time)<?) and enable_status=1 and status=1 %v
) a left JOIN chance_data b on a.id =b.chance_id
order by create_at desc
limit ?
`, filterDepartment)
`, filter)
//if public==protocol.pu
sqlCount := fmt.Sprintf(`select count(0) from (
select id from chance
where company_id=? and review_status=3 and (%v=0 or chance_type_id =%v) and enable_status=1 and status=1 %v
) a left JOIN chance_data b on a.id =b.chance_id`, chanceTypeId, chanceTypeId, filterDepartment)
where company_id=? and review_status=3 and enable_status=1 and status=1 %v
) a left JOIN chance_data b on a.id =b.chance_id`, filter)
if err = utils.ExecuteQueryOne(&total, sqlCount, cid); err != nil {
return
}
if v != nil {
if err = utils.ExecuteQueryAll(v, sql, cid, chanceTypeId, chanceTypeId, lastId, lastId, pageSize); err != nil {
if err = utils.ExecuteQueryAll(v, sql, cid, lastId, lastId, pageSize); err != nil {
return
}
}
... ... @@ -302,61 +331,61 @@ where company_id=? and review_status=3 and (%v=0 or chance_type_id =%v) and ena
}
//type3 特定部门机会
func GetChancePoolSpecialDepartment(uid, cid int64, chanceTypeId int, dIds []int, lastId int64, pageSize int, v interface{}, departmentIds []int64) (total int, err error) {
var filterDepartment string = getFilterSqlByDIds(dIds)
func GetChancePoolSpecialDepartment(uid, cid int64, option *ChancePoolOption, lastId int64, pageSize int, v interface{}, departmentIds []int64) (total int, err error) {
var filter string = getFilterSql(option)
sql := fmt.Sprintf(`
select a.*,b.images,speechs,videos from (
select * from (
##公司公开的机会
select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from chance
select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from chance
where company_id = %v and publish_status = 2 and review_status=3
UNION
##指定部门-机会提交的部门
select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from chance
select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from chance
where department_id in (%v) and review_status=3
UNION
##本人
select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from chance
select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from chance
where user_id = %v and review_status=3
UNION
##我审核
select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from (
select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from (
select DISTINCT chance_id from audit_flow_process where uid =%v
) a inner join chance b on a.chance_id = b.id
) a where review_status=3 and (0=%v or chance_type_id =%v) and (0=%v or unix_timestamp(create_at)<%v) and a.enable_status=1 and status=1 %v
) a where review_status=3 and (0=%v or unix_timestamp(create_at)<%v) and a.enable_status=1 and status=1 %v
) a left JOIN chance_data b on a.id =b.chance_id
order by create_at desc
limit %v
`, cid, utils.JoinInt64s(departmentIds, ","), uid, uid, chanceTypeId, chanceTypeId, lastId, lastId, filterDepartment, pageSize)
`, cid, utils.JoinInt64s(departmentIds, ","), uid, uid, lastId, lastId, filter, pageSize)
sqlCount := fmt.Sprintf(`
select count(0) from (
##公司公开的机会
select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from chance
select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from chance
where company_id = %v and publish_status = 2 and review_status=3
UNION
##指定部门-机会提交的部门
select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from chance
select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from chance
where department_id in (%v) and review_status=3
UNION
##本人
select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from chance
select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from chance
where user_id = %v and review_status=3
UNION
##我审核
select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from (
select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from (
select DISTINCT chance_id from audit_flow_process where uid =%v
) a inner join chance b on a.chance_id = b.id
) a where review_status=3 and (0=%v or chance_type_id =%v) and a.enable_status=1 and status=1 %v
`, cid, utils.JoinInt64s(departmentIds, ","), uid, uid, chanceTypeId, chanceTypeId, filterDepartment)
) a where review_status=3 and a.enable_status=1 and status=1 %v
`, cid, utils.JoinInt64s(departmentIds, ","), uid, uid, filter)
if err = utils.ExecuteQueryOne(&total, sqlCount); err != nil {
return
}
... ... @@ -369,13 +398,13 @@ select count(0) from (
}
//type32 特定部门机会 - 多角色时包含levl2 部门公开
func GetChancePoolDepartment(uid, cid int64, chanceTypeId int, dIds []int, lastId int64, pageSize int, v interface{}, departmentIds []int64, userDepartmetIds []int64) (total int, err error) {
var filterDepartment string = getFilterSqlByDIds(dIds)
func GetChancePoolDepartment(uid, cid int64, option *ChancePoolOption, lastId int64, pageSize int, v interface{}, departmentIds []int64, userDepartmetIds []int64) (total int, err error) {
var filter string = getFilterSql(option)
sql := fmt.Sprintf(`
select a.*,b.images,speechs,videos from (
select * from (
##指定部门-机会公开的部门
select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from (
select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from (
select DISTINCT chance_id from chance_department where department_id in (%v)
)a inner join chance b on a.chance_id = b.id
where review_status=3
... ... @@ -383,35 +412,35 @@ select * from (
UNION
##公司公开的机会
select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from chance
select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from chance
where company_id = %v and publish_status = 2 and review_status=3
UNION
##指定部门-机会提交的部门
select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from chance
select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from chance
where department_id in (%v) and review_status=3
UNION
##本人
select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from chance
select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from chance
where user_id = %v and review_status=3
UNION
##我审核
select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from (
select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from (
select DISTINCT chance_id from audit_flow_process where uid =%v
) a inner join chance b on a.chance_id = b.id
) a where review_status=3 and (0=%v or chance_type_id =%v) and (0=%v or unix_timestamp(create_at)<%v) and a.enable_status=1 and status=1 %v
) a where review_status=3 and (0=%v or unix_timestamp(create_at)<%v) and a.enable_status=1 and status=1 %v
) a left JOIN chance_data b on a.id =b.chance_id
order by create_at desc
limit %v
`, utils.JoinInt64s(userDepartmetIds, ","), cid, utils.JoinInt64s(departmentIds, ","), uid, uid, chanceTypeId, chanceTypeId, lastId, lastId, filterDepartment, pageSize)
`, utils.JoinInt64s(userDepartmetIds, ","), cid, utils.JoinInt64s(departmentIds, ","), uid, uid, lastId, lastId, filter, pageSize)
sqlCount := fmt.Sprintf(`
select count(0) from (
##指定部门-机会公开的部门
select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from (
select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from (
select DISTINCT chance_id from chance_department where department_id in (%v)
)a inner join chance b on a.chance_id = b.id
where review_status=3
... ... @@ -419,27 +448,27 @@ select count(0) from (
UNION
##公司公开的机会
select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from chance
select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from chance
where company_id = %v and publish_status = 2 and review_status=3
UNION
##指定部门-机会提交的部门
select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from chance
select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from chance
where department_id in (%v) and review_status=3
UNION
##本人
select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from chance
select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from chance
where user_id = %v and review_status=3
UNION
##我审核
select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from (
select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from (
select DISTINCT chance_id from audit_flow_process where uid =%v
) a inner join chance b on a.chance_id = b.id
) a where review_status=3 and (0=%v or chance_type_id =%v) and a.enable_status=1 and status=1 %v
`, utils.JoinInt64s(userDepartmetIds, ","), cid, utils.JoinInt64s(departmentIds, ","), uid, uid, chanceTypeId, chanceTypeId, filterDepartment)
) a where review_status=3 and a.enable_status=1 and status=1 %v
`, utils.JoinInt64s(userDepartmetIds, ","), cid, utils.JoinInt64s(departmentIds, ","), uid, uid, filter)
if err = utils.ExecuteQueryOne(&total, sqlCount); err != nil {
return
}
... ... @@ -452,18 +481,18 @@ select count(0) from (
}
//type2 对我所在部门公开的机会 公司公开的机会
func GetChancePoolPublicCompany(uid, cid int64, chanceTypeId int, dIds []int, lastId int64, pageSize int, v interface{}, departmentIds []int64) (total int, err error) {
var filterDepartment string = getFilterSqlByDIds(dIds)
func GetChancePoolPublicCompany(uid, cid int64, option *ChancePoolOption, lastId int64, pageSize int, v interface{}, departmentIds []int64) (total int, err error) {
var filter string = getFilterSql(option)
sql := fmt.Sprintf(`
select a.*,b.images,speechs,videos from (
select * from (
##公司公开的机会
select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from chance
select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from chance
where company_id = %v and publish_status = 2 and review_status=3
UNION
##指定部门-机会公开的部门
select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from (
select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from (
select DISTINCT chance_id from chance_department where department_id in (%v)
)a inner join chance b on a.chance_id = b.id
where review_status=3
... ... @@ -471,30 +500,30 @@ select * from (
UNION
##本人
select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from chance
select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from chance
where user_id = %v and review_status=3
UNION
##我审核
select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from (
select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from (
select DISTINCT chance_id from audit_flow_process where uid =%v
) a inner join chance b on a.chance_id = b.id
) a where review_status=3 and (0=%v or chance_type_id =%v) and (0=%v or unix_timestamp(create_at)<%v) and a.enable_status=1 and status=1 %v
) a where review_status=3 and (0=%v or unix_timestamp(create_at)<%v) and a.enable_status=1 and status=1 %v
) a left JOIN chance_data b on a.id =b.chance_id
order by create_at desc
limit %v
`, cid, utils.JoinInt64s(departmentIds, ","), uid, uid, chanceTypeId, chanceTypeId, lastId, lastId, filterDepartment, pageSize)
`, cid, utils.JoinInt64s(departmentIds, ","), uid, uid, lastId, lastId, filter, pageSize)
sqlCount := fmt.Sprintf(`
select count(0) from (
##公司公开的机会
select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from chance
select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from chance
where company_id = %v and publish_status = 2 and review_status=3
UNION
##指定部门-机会公开的部门
select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from (
select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from (
select DISTINCT chance_id from chance_department where department_id in (%v)
)a inner join chance b on a.chance_id = b.id
where review_status=3
... ... @@ -502,17 +531,17 @@ select count(0) from (
UNION
##本人
select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from chance
select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from chance
where user_id = %v and review_status=3
UNION
##我审核
select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from (
select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from (
select DISTINCT chance_id from audit_flow_process where uid =%v
) a inner join chance b on a.chance_id = b.id
) a where review_status=3 and (0=%v or chance_type_id =%v) and a.enable_status=1 and status=1 %v
`, cid, utils.JoinInt64s(departmentIds, ","), uid, uid, chanceTypeId, chanceTypeId, filterDepartment)
) a where review_status=3 and a.enable_status=1 and status=1 %v
`, cid, utils.JoinInt64s(departmentIds, ","), uid, uid, filter)
if err = utils.ExecuteQueryOne(&total, sqlCount); err != nil {
return
}
... ... @@ -530,42 +559,57 @@ func getFilterSqlByDIds(dIds []int) string {
return fmt.Sprintf(" and department_id in(%v) ", utils.JoinInts(dIds, ","))
}
func getFilterSql(option *ChancePoolOption) string {
var rsp *bytes.Buffer = bytes.NewBuffer(nil)
rsp.WriteString(fmt.Sprintf(" and type =%v ", option.Type))
if option.ChanceTypeId > 0 {
rsp.WriteString(fmt.Sprintf(" and chance_type_id =%v ", option.ChanceTypeId))
}
if len(option.DIds) > 0 {
rsp.WriteString(fmt.Sprintf(" and department_id in(%v) ", utils.JoinInts(option.DIds, ",")))
}
if option.ReserveTypeId > 0 {
rsp.WriteString(fmt.Sprintf(" and reserve_type_id =%v ", option.ReserveTypeId))
}
return rsp.String()
}
//type1 禁止查看所有机会
func GetChancePoolMyself(uid, cid int64, chanceTypeId int, dIds []int, lastId int64, pageSize int, v interface{}) (total int, err error) {
var filterDepartment string = getFilterSqlByDIds(dIds)
func GetChancePoolMyself(uid, cid int64, option *ChancePoolOption, lastId int64, pageSize int, v interface{}) (total int, err error) {
var filter string = getFilterSql(option) // getFilterSqlByDIds(dIds)
sql := fmt.Sprintf(`
select a.*,b.images,speechs,videos from (
select * from (
##本人
select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from chance
select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from chance
where user_id = %v and review_status=3
UNION
##我审核
select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from (
select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from (
select DISTINCT chance_id from audit_flow_process where uid =%v
) a inner join chance b on a.chance_id = b.id
) a where review_status=3 and (0=%v or chance_type_id =%v) and (0=%v or unix_timestamp(create_at)<%v) and a.enable_status=1 and status=1 %v
) a where review_status=3 and (0=%v or unix_timestamp(create_at)<%v) and a.enable_status=1 and status=1 %v
) a left JOIN chance_data b on a.id =b.chance_id
order by create_at desc
limit %v
`, uid, uid, chanceTypeId, chanceTypeId, lastId, lastId, filterDepartment, pageSize)
`, uid, uid, lastId, lastId, filter, pageSize)
sqlCount := fmt.Sprintf(`
select count(0) from (
##本人
select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from chance
select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from chance
where user_id = %v and review_status=3
UNION
##我审核
select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from (
select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from (
select DISTINCT chance_id from audit_flow_process where uid =%v
) a inner join chance b on a.chance_id = b.id
) a where review_status=3 and (0=%v or chance_type_id =%v) and a.enable_status=1 and status=1 %v
`, uid, uid, chanceTypeId, chanceTypeId, filterDepartment)
) a where review_status=3 and a.enable_status=1 and status=1 %v
`, uid, uid, filter)
if err = utils.ExecuteQueryOne(&total, sqlCount); err != nil {
return
}
... ... @@ -577,62 +621,6 @@ select count(0) from (
return
}
//type4 查看所有机会
func ValidChanceAll(uid, cid int64, chanceTypeId int, lastId int64, pageSize int, v interface{}) (total int, err error) {
// sql := `select a.*,b.images,speechs,videos
//from (
//select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total from chance
//where company_id=? and review_status=3 and (?=0 or chance_type_id =?) and (?=0 or id<?) and enable_status=1
//order by create_at desc
//limit ?
//) a left JOIN chance_data b on a.id =b.chance_id`
// //if public==protocol.pu
//
// sqlCount := fmt.Sprintf(`select count(0) from (
//select id from chance
//where company_id=? and review_status=3 and (%v=0 or chance_type_id =%v) and enable_status=1
//order by create_at desc
//) a left JOIN chance_data b on a.id =b.chance_id`, chanceTypeId, chanceTypeId)
// if err = utils.ExecuteQueryOne(&total, sqlCount, cid); err != nil {
// return
// }
// if v != nil {
// if err = utils.ExecuteQueryAll(v, sql, cid, chanceTypeId, chanceTypeId, lastId, lastId, pageSize); err != nil {
// return
// }
// }
return
}
//type3 特定部门机会
func ValidChanceSpecialDepartment(uid, chanceIds string, v interface{}) (err error) {
sql := fmt.Sprintf(`
select * from (
##指定部门-机会提交的部门
##select chance_id from chance
##where id in (v) and department_id in (v)
##UNION
##本人
##select chance_id from chance
##where user_id = v and id in (v)
##UNION
##我审核
select DISTINCT chance_id from audit_flow_process where uid =%v and chance_id in (%v)
)
`, chanceIds)
if v != nil {
if err = utils.ExecuteQueryAll(v, sql); err != nil {
return
}
}
return
}
//是否存在按发布机会部门编号查询
func ExitsChanceByDeparmentIds(chanceId int64, departmentIds []int64) (v *Chance, err error) {
sql := fmt.Sprintf(`select id from chance where id=%v and department_id in (%v)`,
... ... @@ -696,14 +684,14 @@ func GetSiftingChance(uid int64, submitStatus int, checkResultStatus int, offset
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.view_total,
b.update_at,b.approve_time chance_approve_time,b.status,b.self_checks,b.check_result_status,b.check_time
b.update_at,b.approve_time chance_approve_time,b.status,b.self_checks,b.check_result_status,b.check_time,b.type
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 length(b.self_checks)>5
where b.review_status=3 and b.enable_status=1 and b.status=1 and b.type=0 and b.check_result_status <=%v 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
... ... @@ -711,14 +699,14 @@ limit %v,%v`, uid, uid, submitStatus, checkResultStatus, where, offset, pageSize
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
b.update_at,b.approve_time chance_approve_time,b.status,b.self_checks,b.check_result_status,b.type
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 length(b.self_checks)>5
where b.review_status=3 and b.enable_status=1 and b.status=1 and b.type=0 and b.check_result_status <=%v and length(b.self_checks)>5
)a
`, uid, uid, submitStatus, checkResultStatus) //and enable_status =1
if err = utils.ExecuteQueryOne(&total, sqlCount); err != nil {
... ... @@ -747,7 +735,7 @@ 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
where b.review_status=3 and b.enable_status=1 and b.status=1 and b.type=0 and b.check_result_status =%v
)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
... ... @@ -762,7 +750,7 @@ 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
where b.review_status=3 and b.enable_status=1 and b.status=1 and b.type=0 and b.check_result_status =%v
)a
`, uid, uid, submitStatus, checkResultStatus) //and enable_status =1
if err = utils.ExecuteQueryOne(&total, sqlCount); err != nil {
... ...
... ... @@ -173,6 +173,8 @@ type ChancePoolRequest struct {
ChanceTypeId int `json:"chanceTypeId"` //0:所有机会 编号:对应机会类型编号的机会
DepartmentId int `json:"departmentId"` //部门编号
IncludeSubDepartment bool
Type int8 `json:"type"` //0:机会池 1:储备池
ReserveTypeId int `json:"reserveTypeId"` //储备类型编号
}
type ChancePoolResponse struct {
List []CommonListItem `json:"list"`
... ...
... ... @@ -22,9 +22,11 @@ type ChanceApproveRequest struct {
ChanceId int64 `json:"chanceId"` //机会编号
ProcessId int64 `json:"processId"` //审批流程编号
ReviewStatus int `json:"reviewStatus"` //protocol.ReviewStatus
//Suggestion string `json:"suggestion"` //原因/建议
ApproveData ApproveData `json:"approveData"` //审核数据
SelfChecks SelfChecks `json:"selfChecks"`
Reason string `json:"reason"` //理由
Type int8 `json:"type"` //机会类型 0:机会池 1:储备池
ReserveTypeId int `json:"reserveTypeId"` //储备池类型编号
}
type ChanceApproveResponse struct {
}
... ... @@ -57,6 +59,7 @@ type ApproveAccess struct {
type ApproveData struct {
PublicData PublicData `json:"publicData"` // 公开数据
Score Score `json:"score"`
Reason string `json:"-"`
}
//进程项
... ... @@ -71,6 +74,7 @@ type ProcessItem struct {
Name string `json:"name"`
RoleName string `json:"roleName"`
Role int `json:"-"`
Reason string `json:"reason"` //退回理由
SelfChecks SelfChecks `json:"selfChecks"`
ApproveData *ApproveData `json:"approveData"` //审核数据
ApproveUsers []UserItem `json:"approveUsers"` //审核人员 //1 会签 2 或签 //审核中 1.部门长 2.角色
... ...
... ... @@ -119,6 +119,7 @@ type DepartmentStatistics struct {
ChanceApprovedTotal int `json:"chanceApprovedTotal"` //已审核的机会
ChanceApprovingTotal int `json:"chanceApprovingTotal"` //待审核的机会
AchievementTotal int `json:"achievementTotal"` //已创建的成果 (显示)
ChanceReservedTotal int `json:"chanceReservedTotal"` //储备的机会
ACTotal int `json:"-"` //机会成果总数 (显示)
}
... ...
... ... @@ -64,7 +64,7 @@ func init() {
var ApproveLog = map[int]string{
1: "提交了机会", //提交人提交机会
2: "删除了机会", //提交人删除机会
3: "退回了机会;%v", //审批人退回机会
3: "退回了机会%v;%v", //审批人退回机会
4: "通过了机会;%v\n基础评分:%v分,附加评分:%v分,价值评分:%v分,公开状态:公司公开", //审批人通过机会(公司公开)
5: "通过了机会;%v\n基础评分:%v分,附加评分:%v分,价值评分:%v分,公开状态:%v", //审批人通过机会(部门公开) 测试部、销售部
6: "系统 自动通过了机会;基础评分:%v分,附加评分:%v分,价值评分:%v分,公开状态:公司公开", //审批人通过了机会(系统自动通过)
... ...
... ... @@ -326,4 +326,5 @@ type Answer struct {
//扩展消息附加数据
type MsgData struct {
Score *Score `json:"score,omitempty"`
Reason string `json:"-"`
}
... ...
... ... @@ -171,7 +171,6 @@ func GetChance(chanceId int64, companyId int64) (v *protocol.ChanceDetail, err e
Id: c.Id,
Provider: baseUserInfo,
Content: c.Content,
ChanceType: c.ChanceTypeId,
ViewTotal: c.ViewTotal,
CommentTotal: c.CommentTotal,
... ...
... ... @@ -14,7 +14,7 @@ import (
//机会池
//@isIncludeSubDeps 是否包含子部门编号
func GetChancePool(uid, cid int64, chanceTypeId int, departmentId int, isIncludeSubDeps bool, lastId int64, pageSize int, v interface{}) (total int, err error) {
func GetChancePool(uid, cid int64, o *models.ChancePoolOption, departmentId int, isIncludeSubDeps bool, lastId int64, pageSize int, v interface{}) (total int, err error) {
var (
check int
checkMap map[int]int
... ... @@ -24,6 +24,7 @@ func GetChancePool(uid, cid int64, chanceTypeId int, departmentId int, isInclude
chance *models.Chance
dIds []int
)
chanceTypeId := o.ChanceTypeId
if user, err = models.GetUserByCompanyId(cid); err != nil {
log.Error(err)
return
... ... @@ -54,28 +55,29 @@ func GetChancePool(uid, cid int64, chanceTypeId int, departmentId int, isInclude
dIds, _ = GetDepartmentIds(cid, int64(departmentId), isIncludeSubDeps)
}
log.Debug(fmt.Sprintf("user:%v check:%v is_amdin:%v", uid, check, user.Id == uid))
option := models.NewChancePoolOption(chanceTypeId, dIds, o.Type, o.ReserveTypeId)
switch check {
case OpportunityCheckLv1:
return models.GetChancePoolMyself(uid, cid, chanceTypeId, dIds, lastId, pageSize, v)
return models.GetChancePoolMyself(uid, cid, option, lastId, pageSize, v)
case OpportunityCheckLv2:
if err = models.GetUserDepartmentIds(uid, cid, &userDIds); err != nil {
log.Error(err)
return
}
return models.GetChancePoolPublicCompany(uid, cid, chanceTypeId, dIds, lastId, pageSize, v, userDIds)
return models.GetChancePoolPublicCompany(uid, cid, option, lastId, pageSize, v, userDIds)
case OpportunityCheckLv3:
if _, ok := checkMap[OpportunityCheckLv2]; ok { //同时存在对部门公开的机会
if err = models.GetUserDepartmentIds(uid, cid, &userDIds); err != nil {
log.Error(err)
return
}
return models.GetChancePoolDepartment(uid, cid, chanceTypeId, dIds, lastId, pageSize, v, specialDIds, userDIds)
return models.GetChancePoolDepartment(uid, cid, option, lastId, pageSize, v, specialDIds, userDIds)
}
return models.GetChancePoolSpecialDepartment(uid, cid, chanceTypeId, dIds, lastId, pageSize, v, specialDIds)
return models.GetChancePoolSpecialDepartment(uid, cid, option, lastId, pageSize, v, specialDIds)
case OpportunityCheckLv4:
return models.GetChancePoolAll(uid, cid, chanceTypeId, dIds, lastId, pageSize, v)
return models.GetChancePoolAll(uid, cid, option, lastId, pageSize, v)
default:
return models.GetChancePoolAll(uid, cid, chanceTypeId, dIds, lastId, pageSize, v)
return models.GetChancePoolAll(uid, cid, option, lastId, pageSize, v)
}
return
}
... ...
... ... @@ -32,6 +32,9 @@ func SendApproveMsg(receiverId int64, name string, companyId int64, chanceId int
break
case protocol.ReviewStatusReturn:
format = MessageApproveReject
if len(data.Reason) > 0 {
format += fmt.Sprintf(",退回理由:%v", data.Reason)
}
break
case protocol.ReviewStatusPass:
format = MessageApproveSuccess
... ... @@ -86,6 +89,9 @@ func sendApproveMsg(header *protocol.RequestHeader, receiverId int64, name strin
case protocol.ReviewStatusReturn:
jsonData = ""
format = MessageApproveReject
if len(data.Reason) > 0 {
format += fmt.Sprintf(",退回理由:%v", data.Reason)
}
break
case protocol.ReviewStatusPass:
format = MessageApproveSuccess
... ...
... ... @@ -328,6 +328,7 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro
mapProcess["IsActive"] = int8(0)
mapProcess["UpdateAt"] = time.Now()
mapProcess["SelfChecks"] = common.AssertJson(difChecks)
mapProcess["Reason"] = request.Reason
mapChance["ApproveTime"] = time.Now()
mapChance["BasicScore"] = request.ApproveData.Score.BasicScore
... ... @@ -371,7 +372,7 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro
{
//发送审核消息给提交机会的人
var nextApprovers []int64
if err = agg.SendApproveMsgWithHeader(header, chance.UserId, chance.Id, chance.ChanceTypeId, request.ReviewStatus, protocol.MsgTypeAuditBy, protocol.MsgData{Score: &request.ApproveData.Score}); err != nil {
if err = agg.SendApproveMsgWithHeader(header, chance.UserId, chance.Id, chance.ChanceTypeId, request.ReviewStatus, protocol.MsgTypeAuditBy, protocol.MsgData{Score: &request.ApproveData.Score, Reason: request.Reason}); err != nil {
log.Error(err)
orm.Rollback()
return
... ... @@ -462,18 +463,6 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro
return
}
/*ProcessIntegrate */
type ProcessIntegrateRequest struct {
}
type ProcessIntegrateResponse struct {
}
func ProcessIntegrate(header *protocol.RequestHeader, request *ProcessIntegrateRequest) (rsp *ProcessIntegrateResponse, err error) {
var ()
rsp = &ProcessIntegrateResponse{}
return
}
//发送审核日志
func saveApproveMsgByApproveData(header *protocol.RequestHeader, orm orm.Ormer, reviewStatus int, chance *models.Chance, approveData protocol.ApproveData, selfChecks protocol.SelfChecks) (err error) {
var (
... ... @@ -483,7 +472,11 @@ func saveApproveMsgByApproveData(header *protocol.RequestHeader, orm orm.Ormer,
if reviewStatus == protocol.ReviewStatusReturn {
//发送退回日志
code = 3
parames = append(parames, selfChecks.String())
reason := ""
if len(approveData.Reason) > 0 {
reason = fmt.Sprintf(",理由:%v", approveData.Reason)
}
parames = append(parames, reason, selfChecks.String())
}
if reviewStatus == protocol.ReviewStatusPass {
//发送通过日志
... ... @@ -550,6 +543,7 @@ func ChanceApproveProcess(header *protocol.RequestHeader, chance *models.Chance)
ApproveType: process.AuditFlowType,
Uid: process.Uid,
Name: process.UserName,
Reason: process.Reason,
}
utils.JsonUnmarshal(process.SelfChecks, &item.SelfChecks)
if len(item.SelfChecks) > 0 {
... ...
... ... @@ -401,7 +401,6 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit
ChanceTypeId: template.ChanceTypeId,
AuditTemplateId: template.Id,
AuditTemplateConfig: common.AssertJson(auditConfig),
Content: request.Content,
SourceContent: common.AssertJson(request.FormList),
EnableStatus: 1,
CreateAt: time.Now(),
... ... @@ -1476,7 +1475,7 @@ func ChanceStatistics(header *protocol.RequestHeader, request *protocol.ChanceSt
rsp = &protocol.ChanceStatisticsResponse{}
for i := range chanceType {
item := chanceType[i]
if total, err = agg.GetChancePool(header.UserId, header.CompanyId, item.Id, 0, false, 0, 0, nil); err != nil {
if total, err = agg.GetChancePool(header.UserId, header.CompanyId, models.NewChancePoolOption(item.Id, []int{}, models.ChancePool, 0), 0, false, 0, 0, nil); err != nil {
log.Error(err)
return
}
... ... @@ -1539,7 +1538,7 @@ func ChancePool(header *protocol.RequestHeader, request *protocol.ChancePoolRequ
provider *protocol.BaseUserInfo
flag int
)
if total, err = agg.GetChancePool(header.UserId, header.CompanyId, request.ChanceTypeId, request.DepartmentId, request.IncludeSubDepartment, request.LastId, request.PageSize, &chanceItems); err != nil {
if total, err = agg.GetChancePool(header.UserId, header.CompanyId, models.NewChancePoolOption(request.ChanceTypeId, []int{}, request.Type, request.ReserveTypeId), request.DepartmentId, request.IncludeSubDepartment, request.LastId, request.PageSize, &chanceItems); err != nil {
if err == orm.ErrNoRows {
err = nil
return
... ...
... ... @@ -114,8 +114,9 @@ func Statistics(header *protocol.RequestHeader, request *protocol.DepartmentStat
item := &protocol.DepartmentStatistics{}
dIds := departmentsResponse.GetChildDepartmentIds(d, true)
item.AchievementTotal, _ = agg.AchievementDepartmentStatic(header, 0, dIds)
item.ChanceApprovedTotal, _ = agg.GetChancePool(header.UserId, header.CompanyId, 0, d.DepartmentId, true, 0, 0, nil)
item.ACTotal = item.AchievementTotal + item.ChanceApprovedTotal
item.ChanceApprovedTotal, _ = agg.GetChancePool(header.UserId, header.CompanyId, models.NewChancePoolOption(0, []int{}, models.ChancePool, 0), d.DepartmentId, true, 0, 0, nil)
item.ChanceReservedTotal, _ = agg.GetChancePool(header.UserId, header.CompanyId, models.NewChancePoolOption(0, []int{}, models.ChanceReserve, 0), d.DepartmentId, true, 0, 0, nil)
item.ACTotal = item.AchievementTotal + item.ChanceApprovedTotal + item.ChanceReservedTotal
item.ChanceApprovingTotal, _ = agg.ChanceApprovingStatistic(header, departmentsResponse.GetChildDepartmentIds(d, true))
return item
}
... ... @@ -163,8 +164,9 @@ func DepartmentStatistic(header *protocol.RequestHeader, request *protocol.Depar
return
}
departmentStatistic.AchievementTotal, _ = agg.AchievementDepartmentStatic(header, 0, dIds)
departmentStatistic.ChanceApprovedTotal, _ = agg.GetChancePool(header.UserId, header.CompanyId, 0, int(request.DepartmentId), false, 0, 0, nil)
departmentStatistic.ACTotal = departmentStatistic.AchievementTotal + departmentStatistic.ChanceApprovedTotal
departmentStatistic.ChanceApprovedTotal, _ = agg.GetChancePool(header.UserId, header.CompanyId, models.NewChancePoolOption(0, []int{}, models.ChancePool, 0), int(request.DepartmentId), false, 0, 0, nil)
departmentStatistic.ChanceReservedTotal, _ = agg.GetChancePool(header.UserId, header.CompanyId, models.NewChancePoolOption(0, []int{}, models.ChanceReserve, 0), int(request.DepartmentId), false, 0, 0, nil)
departmentStatistic.ACTotal = departmentStatistic.AchievementTotal + departmentStatistic.ChanceApprovedTotal + departmentStatistic.ChanceReservedTotal
departmentStatistic.ChanceApprovingTotal, _ = agg.ChanceApprovingStatistic(header, dIds)
rsp.DepartmentStatistic = departmentStatistic
return
... ...