作者 yangfu

增加 机会筛选池列表

... ... @@ -668,3 +668,24 @@ func (this *ChanceController) CheckQuestions() {
header := controllers.GetRequestHeader(this.Ctx)
msg = protocol.NewReturnResponse(chance.CheckQuestions(header, request))
}
//SiftingPool 筛选池
//@router /siftingPool [post]
func (this *ChanceController) SiftingPool() {
var msg *protocol.ResponseMessage
defer func() {
this.Resp(msg)
}()
var request *protocol.SiftingPoolRequest
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.SiftingPool(header, request))
}
... ...
... ... @@ -98,6 +98,8 @@ func main() {
beego.BConfig.Listen.HTTPSKeyFile = "conf/_.fjmaimaimai.com.key"
contrab.Run()
//beego.BConfig.Listen.EnableAdmin = true //开启进程内监控模块
beego.Run()
}
... ...
... ... @@ -35,13 +35,13 @@ func GetAuditCheckById(id int) (v *AuditCheck, err error) {
return nil, err
}
func GetAuditCheckBy(tpId int64) (v []*AuditCheck, err error) {
func GetAuditCheckBy(tpId int64, v interface{}) (err error) {
sql := `select * from(
select id,(case when pid=0 then id else pid end) pid,title,items from audit_check where template_id=? and enable=1
select id,(case when pid=0 then id else pid end) pid,title,items,pid parent_id from audit_check where template_id=? and enable=1
)a
order by a.pid`
o := orm.NewOrm()
if _, err = o.Raw(sql, tpId).QueryRows(&v); err != nil {
if _, err = o.Raw(sql, tpId).QueryRows(v); err != nil {
if err == orm.ErrNoRows {
err = nil
}
... ...
... ... @@ -9,30 +9,32 @@ import (
)
type AuditFlowProcess struct {
Id int64 `orm:"column(id);pk" description:"唯一标识"`
ChanceId int64 `orm:"column(chance_id)" description:"实例id,关联chance表id"`
Uid int64 `orm:"column(uid)" description:"用户id(审批人)"`
Level int `orm:"column(level)" description:"审批步骤"`
IsActive int8 `orm:"column(is_active)" description:"是否激活"`
ApproveTime time.Time `orm:"column(approve_time);type(timestamp)" description:"审批时间"`
BasicScore float64 `orm:"column(basic_score);null;digits(4);decimals(1)" description:"基础评分"`
ExtraScore float64 `orm:"column(extra_score);null;digits(4);decimals(1)" description:"附加评分"`
ValueScore float64 `orm:"column(value_score);null;digits(4);decimals(1)" description:"价值评分"`
DiscoveryScore float64 `orm:"column(discovery_score);null;digits(4);decimals(1)" description:"发现得分(发现得分=基础评分*系数 + 附加评分*系数 + 价值评分*系数)"`
ReviewStatus int8 `orm:"column(review_status)" description:"审核状态 0:审核中 1:被退回 2:已通过 3.自动通过 "`
AuditFlowType int `orm:"column(audit_flow_type)" description:"审核流类型 1.部门长 2.指定成员 3.指定角色 4.特殊审核人"`
FlowType int `orm:"column(flow_type)" description:"审批类型 1:正常审核 2:特殊审核"`
ActionType int `orm:"column(action_type)" description:"审批执行方式【1:or】【2:and】"`
CreateAt time.Time `orm:"column(create_at);type(timestamp)" description:"创建时间"`
UpdateAt time.Time `orm:"column(update_at);type(timestamp)" description:"更新时间"`
EnableStatus int8 `orm:"column(enable_status)" description:"有效状态 0:无效 1:有效 (被驳回以后,未完成的审核置为无效)"`
ApproveData string `orm:"column(approve_data);size(500)" description:"审核数据 json{公开状态 公开对象 分数}"`
UserName string `orm:"column(user_name);size(50)" description:"用户名-冗余"`
RoleName string `orm:"column(role_name);size(50)" description:"角色名-冗余"`
RoleId int `orm:"column(role_id);size(50)" description:"角色id-冗余"`
ApproveMessage string `orm:"column(approve_message);size(50)" description:"审核消息-冗余"`
TemplateId int `orm:"column(template_id);size(50)" description:"模板编号-冗余"`
SelfChecks string `orm:"column(self_checks);null" description:"自查内容"`
Id int64 `orm:"column(id);pk" description:"唯一标识"`
ChanceId int64 `orm:"column(chance_id)" description:"实例id,关联chance表id"`
Uid int64 `orm:"column(uid)" description:"用户id(审批人)"`
Level int `orm:"column(level)" description:"审批步骤"`
IsActive int8 `orm:"column(is_active)" description:"是否激活"`
ApproveTime time.Time `orm:"column(approve_time);type(timestamp)" description:"审批时间"`
BasicScore float64 `orm:"column(basic_score);null;digits(4);decimals(1)" description:"基础评分"`
ExtraScore float64 `orm:"column(extra_score);null;digits(4);decimals(1)" description:"附加评分"`
ValueScore float64 `orm:"column(value_score);null;digits(4);decimals(1)" description:"价值评分"`
DiscoveryScore float64 `orm:"column(discovery_score);null;digits(4);decimals(1)" description:"发现得分(发现得分=基础评分*系数 + 附加评分*系数 + 价值评分*系数)"`
ReviewStatus int8 `orm:"column(review_status)" description:"审核状态 0:审核中 1:被退回 2:已通过 3.自动通过 "`
AuditFlowType int `orm:"column(audit_flow_type)" description:"审核流类型 1.部门长 2.指定成员 3.指定角色 4.特殊审核人"`
FlowType int `orm:"column(flow_type)" description:"审批类型 1:正常审核 2:特殊审核"`
ActionType int `orm:"column(action_type)" description:"审批执行方式【1:or】【2:and】"`
CreateAt time.Time `orm:"column(create_at);type(timestamp)" description:"创建时间"`
UpdateAt time.Time `orm:"column(update_at);type(timestamp)" description:"更新时间"`
EnableStatus int8 `orm:"column(enable_status)" description:"有效状态 0:无效 1:有效 (被驳回以后,未完成的审核置为无效)"`
ApproveData string `orm:"column(approve_data);size(500)" description:"审核数据 json{公开状态 公开对象 分数}"`
UserName string `orm:"column(user_name);size(50)" description:"用户名-冗余"`
RoleName string `orm:"column(role_name);size(50)" description:"角色名-冗余"`
RoleId int `orm:"column(role_id);size(50)" description:"角色id-冗余"`
ApproveMessage string `orm:"column(approve_message);size(50)" description:"审核消息-冗余"`
TemplateId int `orm:"column(template_id);size(50)" description:"模板编号-冗余"`
SelfChecks string `orm:"column(self_checks);null" description:"自查内容"`
CheckTime time.Time `orm:"column(check_time);type(timestamp)" description:"机会筛选审核时间"`
CheckResultStatus int `orm:"column(check_result_status)" description:"机会筛选状态【1:待处理】【2:通过】【3:不通过】"`
}
func (t *AuditFlowProcess) TableName() string {
... ...
... ... @@ -36,6 +36,8 @@ type Chance struct {
Code string `orm:"column(code)" description:"机会编码 一级编码+二级编码"`
Status int8 `orm:"column(status)" description:"状态 1:开启 2:关闭 "`
SelfChecks string `orm:"column(self_checks);size(1000);null" description:"自查内容"`
SubmitCheckTime time.Time `orm:"column(submit_check_time);type(timestamp)" description:"提交筛选时间"`
SubmitCheckStatus int `orm:"column(submit_check_status)" description:"提交筛选状态 0:未提交 1:已提交"`
}
const (
... ... @@ -678,3 +680,55 @@ and department_id in (%v)`,
}
return
}
//获取筛选中的机会
//@submitStatus 提交状态:已提交 未提交
//@checkResultStatus 筛选结果状态:通过 / 不通过
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`)
} else {
where = fmt.Sprintf(`where length(self_checks)>5
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
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
%v
limit %v,%v`, uid, uid, submitStatus, checkResultStatus, where, 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
where length(self_checks)>5
`, 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
}
... ...
... ... @@ -660,3 +660,14 @@ type ChanceReviseDetailResponse struct {
ChanceReviseData ChanceReviseLog `json:"chanceReviseData"`
ChanceId int64 `json:"chanceId"` //机会编号
}
//机会池筛选项
type ChanceSiftItemOrm struct {
CommChanceItemOrm
//ApproveData string `json:"approveData"` //审核数据
TemplateId int `orm:"column(audit_template_id)"`
ChanceTypeId int `orm:"column(chance_type_id)"`
SubmitCheckTime time.Time `orm:"column(submit_check_time)"` //提交自查时间
}
... ...
... ... @@ -14,6 +14,20 @@ const (
TypeApprove
)
//提交状态
const (
Submiting = iota //待我提交
Submited //我已提交
)
//通过状态
const (
None = iota //未提交
Waiting //已提交待审核
Reject //退回
Pass //通过
)
/*机会-自查内容*/
var CheckOptionsCommit = []CheckOption{{Item: "是", NeedOther: false}, {Item: "否", NeedOther: false}, {Item: "不清楚", NeedOther: false}}
var CheckOptionsApprove = []CheckOption{{Item: "是", NeedOther: false}, {Item: "否", NeedOther: true}, {Item: "不清楚", NeedOther: false}}
... ... @@ -44,6 +58,9 @@ type SelfCheck struct {
GroupId int64 `json:"groupId"` //分组
Answer string `json:"answer,omitempty"`
Reason string `json:"reason,omitempty"`
Id int64 `json:"Id"`
ParentId int64 `json:"parentId"`
}
func (c SelfCheck) Key() string {
... ... @@ -151,6 +168,9 @@ func NewCheckQuestion(checkItem, title string, groupId int64, ops []CheckOption)
}
type CheckQuestion struct {
Id int64 `json:"-"`
ParentId int64 `json:"-"`
CheckItem string `json:"checkItem"`
Title string `json:"title"`
GroupId int64 `json:"groupId"`
... ... @@ -169,3 +189,14 @@ type CheckQuestionsRequest struct {
type CheckQuestionsResponse struct {
Questions []*CheckQuestion `json:"questions"`
}
//SiftingPool 筛选池
type SiftingPoolRequest struct {
PageInfo
Uid int64 `json:"uid"` //注入用户 测试使用
SubmitStatus int `json:"submitStatus"` //0:待我提交 1:提交
SiftedStatus int `-` //筛选状态 1:提交中 2:通过 3:不通过
}
type SiftingPoolResponse struct {
ChancePoolResponse
}
... ...
package protocol
const RequireVersion = "0.9.0"
const (
VERSION = "0.11.5"
RequireVersion = "0.9.0"
)
/*
全局变量声明
... ... @@ -87,3 +90,18 @@ type NameItem struct {
Id int `json:"id"`
Name string `json:"name"`
}
type PageInfo struct {
PageIndex int `json:"pageIndex"` //页码(默认0代表第1页)
PageSize int `json:"pageSize" valid:"Required"` //每页数量
}
//获取分页信息
func (p PageInfo) Offset() (offset int) {
var size = p.PageSize
if size == 0 {
size = 20
}
offset = size * p.PageIndex
return
}
... ...
... ... @@ -257,6 +257,14 @@ func init() {
beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
beego.ControllerComments{
Method: "SiftingPool",
Router: `/siftingPool`,
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"},
... ...
... ... @@ -247,11 +247,17 @@ func SetMsgItem(header *protocol.RequestHeader, msg protocol.MsgItemOrm, commIte
//获取自查问题列表 通过模板
func GetCheckQuestionsByTemplateId(id int64) (rsp []*protocol.CheckQuestion, err error) {
type check struct {
models.AuditCheck
Id int64 `orm:"column(id)"`
ParentId int64 `orm:"column(parent_id)"`
}
var (
checks []*models.AuditCheck
checks []*check
)
rsp = make([]*protocol.CheckQuestion, 0)
if checks, err = models.GetAuditCheckBy(id); err != nil {
if err = models.GetAuditCheckBy(id, &checks); err != nil {
log.Error(err)
return
}
... ... @@ -270,6 +276,8 @@ func GetCheckQuestionsByTemplateId(id int64) (rsp []*protocol.CheckQuestion, err
}
tmpGroupId = c.Pid
item := protocol.NewCheckQuestion(c.Title, getQuestionTitle(groupIdx, idx, c.Title), c.Pid, protocol.CheckOptionsCommit)
item.Id = c.Id
item.ParentId = c.ParentId
rsp = append(rsp, item)
idx++
}
... ... @@ -319,6 +327,9 @@ func GetCheckQuestionsByChanceId(header *protocol.RequestHeader, id int64) (rsp
item.Answer = c.Answer
}
}
if item.Id == 0 {
item.Id, item.ParentId = genCustomizeQuestionId(idx, groupIdx)
}
rsp = append(rsp, item)
idx++
}
... ... @@ -331,6 +342,19 @@ func getQuestionTitle(groupIdx int, idx int, title string) string {
return fmt.Sprintf("%v.%v、%v?", groupIdx, idx, title)
}
//自定义id
//@return id:问题序号 parentId:父级id
func genCustomizeQuestionId(idx, groupId int) (id int64, parentId int64) {
id = int64(idx) + 1
//同一分组的第一个 是一级
if idx == 0 {
parentId = 0
return
}
parentId = int64(groupId)
return
}
//自查问题回答批量入库
//@isDelete
func BulkInsertSelfChecks(header *protocol.RequestHeader, relateId, chanceId int64, selfChecks protocol.SelfChecks, isDeleteExisted bool, checkerType int) {
... ... @@ -389,6 +413,7 @@ func BulkInsertSelfChecks(header *protocol.RequestHeader, relateId, chanceId int
o.Commit()
}
//自查问题回答内容
func NewChanceSelfCheck(header *protocol.RequestHeader, check protocol.SelfCheck, chanceId, r int64, checkerType int) *models.ChanceSelfCheck {
return &models.ChanceSelfCheck{
Id: idgen.Next(),
... ...
... ... @@ -2222,3 +2222,51 @@ func CheckQuestions(header *protocol.RequestHeader, request *protocol.CheckQuest
}
return
}
//SiftingPool 筛选池
func SiftingPool(header *protocol.RequestHeader, request *protocol.SiftingPoolRequest) (rsp *protocol.SiftingPoolResponse, err error) {
var (
ormItems []protocol.ChanceSiftItemOrm
)
rsp = &protocol.SiftingPoolResponse{}
rsp.List = make([]protocol.CommonListItem, 0)
//测试使用
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
return
}
log.Error(err)
return
}
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.Chance.CreateTime = ormItem.ChanceApproveTime.Unix() * 1000
if request.SubmitStatus == protocol.Submited {
commItem.Chance.CreateTime = ormItem.SubmitCheckTime.Unix() * 1000
}
//模板数据
commItem.ChanceTemplate = getTemplate(ormItem.TemplateId)
commItem.ChanceType = getChanceType(ormItem.ChanceTypeId)
rsp.List = append(rsp.List, commItem)
}
return
}
... ...