作者 yangfu

增加 机会筛选池列表

@@ -668,3 +668,24 @@ func (this *ChanceController) CheckQuestions() { @@ -668,3 +668,24 @@ func (this *ChanceController) CheckQuestions() {
668 header := controllers.GetRequestHeader(this.Ctx) 668 header := controllers.GetRequestHeader(this.Ctx)
669 msg = protocol.NewReturnResponse(chance.CheckQuestions(header, request)) 669 msg = protocol.NewReturnResponse(chance.CheckQuestions(header, request))
670 } 670 }
  671 +
  672 +//SiftingPool 筛选池
  673 +//@router /siftingPool [post]
  674 +func (this *ChanceController) SiftingPool() {
  675 + var msg *protocol.ResponseMessage
  676 + defer func() {
  677 + this.Resp(msg)
  678 + }()
  679 + var request *protocol.SiftingPoolRequest
  680 + if err := json.Unmarshal(this.ByteBody, &request); err != nil {
  681 + log.Error(err)
  682 + msg = protocol.BadRequestParam(1)
  683 + return
  684 + }
  685 + if b, m := this.Valid(request); !b {
  686 + msg = m
  687 + return
  688 + }
  689 + header := controllers.GetRequestHeader(this.Ctx)
  690 + msg = protocol.NewReturnResponse(chance.SiftingPool(header, request))
  691 +}
@@ -98,6 +98,8 @@ func main() { @@ -98,6 +98,8 @@ func main() {
98 beego.BConfig.Listen.HTTPSKeyFile = "conf/_.fjmaimaimai.com.key" 98 beego.BConfig.Listen.HTTPSKeyFile = "conf/_.fjmaimaimai.com.key"
99 contrab.Run() 99 contrab.Run()
100 100
  101 + //beego.BConfig.Listen.EnableAdmin = true //开启进程内监控模块
  102 +
101 beego.Run() 103 beego.Run()
102 } 104 }
103 105
@@ -35,13 +35,13 @@ func GetAuditCheckById(id int) (v *AuditCheck, err error) { @@ -35,13 +35,13 @@ func GetAuditCheckById(id int) (v *AuditCheck, err error) {
35 return nil, err 35 return nil, err
36 } 36 }
37 37
38 -func GetAuditCheckBy(tpId int64) (v []*AuditCheck, err error) { 38 +func GetAuditCheckBy(tpId int64, v interface{}) (err error) {
39 sql := `select * from( 39 sql := `select * from(
40 -select id,(case when pid=0 then id else pid end) pid,title,items from audit_check where template_id=? and enable=1 40 +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
41 )a 41 )a
42 order by a.pid` 42 order by a.pid`
43 o := orm.NewOrm() 43 o := orm.NewOrm()
44 - if _, err = o.Raw(sql, tpId).QueryRows(&v); err != nil { 44 + if _, err = o.Raw(sql, tpId).QueryRows(v); err != nil {
45 if err == orm.ErrNoRows { 45 if err == orm.ErrNoRows {
46 err = nil 46 err = nil
47 } 47 }
@@ -33,6 +33,8 @@ type AuditFlowProcess struct { @@ -33,6 +33,8 @@ type AuditFlowProcess struct {
33 ApproveMessage string `orm:"column(approve_message);size(50)" description:"审核消息-冗余"` 33 ApproveMessage string `orm:"column(approve_message);size(50)" description:"审核消息-冗余"`
34 TemplateId int `orm:"column(template_id);size(50)" description:"模板编号-冗余"` 34 TemplateId int `orm:"column(template_id);size(50)" description:"模板编号-冗余"`
35 SelfChecks string `orm:"column(self_checks);null" description:"自查内容"` 35 SelfChecks string `orm:"column(self_checks);null" description:"自查内容"`
  36 + CheckTime time.Time `orm:"column(check_time);type(timestamp)" description:"机会筛选审核时间"`
  37 + CheckResultStatus int `orm:"column(check_result_status)" description:"机会筛选状态【1:待处理】【2:通过】【3:不通过】"`
36 } 38 }
37 39
38 func (t *AuditFlowProcess) TableName() string { 40 func (t *AuditFlowProcess) TableName() string {
@@ -36,6 +36,8 @@ type Chance struct { @@ -36,6 +36,8 @@ type Chance struct {
36 Code string `orm:"column(code)" description:"机会编码 一级编码+二级编码"` 36 Code string `orm:"column(code)" description:"机会编码 一级编码+二级编码"`
37 Status int8 `orm:"column(status)" description:"状态 1:开启 2:关闭 "` 37 Status int8 `orm:"column(status)" description:"状态 1:开启 2:关闭 "`
38 SelfChecks string `orm:"column(self_checks);size(1000);null" description:"自查内容"` 38 SelfChecks string `orm:"column(self_checks);size(1000);null" description:"自查内容"`
  39 + SubmitCheckTime time.Time `orm:"column(submit_check_time);type(timestamp)" description:"提交筛选时间"`
  40 + SubmitCheckStatus int `orm:"column(submit_check_status)" description:"提交筛选状态 0:未提交 1:已提交"`
39 } 41 }
40 42
41 const ( 43 const (
@@ -678,3 +680,55 @@ and department_id in (%v)`, @@ -678,3 +680,55 @@ and department_id in (%v)`,
678 } 680 }
679 return 681 return
680 } 682 }
  683 +
  684 +//获取筛选中的机会
  685 +//@submitStatus 提交状态:已提交 未提交
  686 +//@checkResultStatus 筛选结果状态:通过 / 不通过
  687 +func GetSiftingChance(uid int64, submitStatus int, checkResultStatus int, offset int, pageSize int, v interface{}) (total int, err error) {
  688 + var where string
  689 + if submitStatus == 1 {
  690 + where = fmt.Sprintf(`where length(self_checks)>5
  691 +order by a.submit_check_time desc`)
  692 + } else {
  693 + where = fmt.Sprintf(`where length(self_checks)>5
  694 +order by a.chance_approve_time desc`)
  695 + }
  696 + sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos
  697 +from (
  698 + 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,
  699 + b.update_at,b.approve_time chance_approve_time,b.status,b.self_checks,b.check_result_status
  700 + from (
  701 + select max(id) id,approve_time,approve_data,uid,chance_id,submit_check_status,submit_check_time,level
  702 + 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
  703 + where a.uid=%v and b.max_id=a.id and a.submit_check_status=%v and level>0
  704 + GROUP BY chance_id
  705 + )a left outer join chance b on a.chance_id = b.id
  706 + 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
  707 +)a left outer join chance_data b on a.chance_id =b.chance_id
  708 +%v
  709 +limit %v,%v`, uid, uid, submitStatus, checkResultStatus, where, offset, pageSize) //,update_at process_create_time
  710 +
  711 + sqlCount := fmt.Sprintf(`select count(0)
  712 +from (
  713 + select a.*,b.user_id chance_user_id,b.source_content,b.enable_status,b.review_status,b.create_at,
  714 + b.update_at,b.approve_time chance_approve_time,b.status,b.self_checks,b.check_result_status
  715 + from (
  716 + select max(id) id,approve_time,approve_data,uid,chance_id,submit_check_status,submit_check_time,level
  717 + 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
  718 + where a.uid=%v and b.max_id=a.id and a.submit_check_status=%v and level>0
  719 + GROUP BY chance_id
  720 + )a left outer join chance b on a.chance_id = b.id
  721 + 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
  722 +)a
  723 +where length(self_checks)>5
  724 +`, uid, uid, submitStatus, checkResultStatus) //and enable_status =1
  725 + if err = utils.ExecuteQueryOne(&total, sqlCount); err != nil {
  726 + return
  727 + }
  728 + if v != nil {
  729 + if err = utils.ExecuteQueryAll(v, sql); err != nil {
  730 + return
  731 + }
  732 + }
  733 + return
  734 +}
@@ -660,3 +660,14 @@ type ChanceReviseDetailResponse struct { @@ -660,3 +660,14 @@ type ChanceReviseDetailResponse struct {
660 ChanceReviseData ChanceReviseLog `json:"chanceReviseData"` 660 ChanceReviseData ChanceReviseLog `json:"chanceReviseData"`
661 ChanceId int64 `json:"chanceId"` //机会编号 661 ChanceId int64 `json:"chanceId"` //机会编号
662 } 662 }
  663 +
  664 +//机会池筛选项
  665 +type ChanceSiftItemOrm struct {
  666 + CommChanceItemOrm
  667 +
  668 + //ApproveData string `json:"approveData"` //审核数据
  669 + TemplateId int `orm:"column(audit_template_id)"`
  670 + ChanceTypeId int `orm:"column(chance_type_id)"`
  671 +
  672 + SubmitCheckTime time.Time `orm:"column(submit_check_time)"` //提交自查时间
  673 +}
@@ -14,6 +14,20 @@ const ( @@ -14,6 +14,20 @@ const (
14 TypeApprove 14 TypeApprove
15 ) 15 )
16 16
  17 +//提交状态
  18 +const (
  19 + Submiting = iota //待我提交
  20 + Submited //我已提交
  21 +)
  22 +
  23 +//通过状态
  24 +const (
  25 + None = iota //未提交
  26 + Waiting //已提交待审核
  27 + Reject //退回
  28 + Pass //通过
  29 +)
  30 +
17 /*机会-自查内容*/ 31 /*机会-自查内容*/
18 var CheckOptionsCommit = []CheckOption{{Item: "是", NeedOther: false}, {Item: "否", NeedOther: false}, {Item: "不清楚", NeedOther: false}} 32 var CheckOptionsCommit = []CheckOption{{Item: "是", NeedOther: false}, {Item: "否", NeedOther: false}, {Item: "不清楚", NeedOther: false}}
19 var CheckOptionsApprove = []CheckOption{{Item: "是", NeedOther: false}, {Item: "否", NeedOther: true}, {Item: "不清楚", NeedOther: false}} 33 var CheckOptionsApprove = []CheckOption{{Item: "是", NeedOther: false}, {Item: "否", NeedOther: true}, {Item: "不清楚", NeedOther: false}}
@@ -44,6 +58,9 @@ type SelfCheck struct { @@ -44,6 +58,9 @@ type SelfCheck struct {
44 GroupId int64 `json:"groupId"` //分组 58 GroupId int64 `json:"groupId"` //分组
45 Answer string `json:"answer,omitempty"` 59 Answer string `json:"answer,omitempty"`
46 Reason string `json:"reason,omitempty"` 60 Reason string `json:"reason,omitempty"`
  61 +
  62 + Id int64 `json:"Id"`
  63 + ParentId int64 `json:"parentId"`
47 } 64 }
48 65
49 func (c SelfCheck) Key() string { 66 func (c SelfCheck) Key() string {
@@ -151,6 +168,9 @@ func NewCheckQuestion(checkItem, title string, groupId int64, ops []CheckOption) @@ -151,6 +168,9 @@ func NewCheckQuestion(checkItem, title string, groupId int64, ops []CheckOption)
151 } 168 }
152 169
153 type CheckQuestion struct { 170 type CheckQuestion struct {
  171 + Id int64 `json:"-"`
  172 + ParentId int64 `json:"-"`
  173 +
154 CheckItem string `json:"checkItem"` 174 CheckItem string `json:"checkItem"`
155 Title string `json:"title"` 175 Title string `json:"title"`
156 GroupId int64 `json:"groupId"` 176 GroupId int64 `json:"groupId"`
@@ -169,3 +189,14 @@ type CheckQuestionsRequest struct { @@ -169,3 +189,14 @@ type CheckQuestionsRequest struct {
169 type CheckQuestionsResponse struct { 189 type CheckQuestionsResponse struct {
170 Questions []*CheckQuestion `json:"questions"` 190 Questions []*CheckQuestion `json:"questions"`
171 } 191 }
  192 +
  193 +//SiftingPool 筛选池
  194 +type SiftingPoolRequest struct {
  195 + PageInfo
  196 + Uid int64 `json:"uid"` //注入用户 测试使用
  197 + SubmitStatus int `json:"submitStatus"` //0:待我提交 1:提交
  198 + SiftedStatus int `-` //筛选状态 1:提交中 2:通过 3:不通过
  199 +}
  200 +type SiftingPoolResponse struct {
  201 + ChancePoolResponse
  202 +}
1 package protocol 1 package protocol
2 2
3 -const RequireVersion = "0.9.0" 3 +const (
  4 + VERSION = "0.11.5"
  5 + RequireVersion = "0.9.0"
  6 +)
4 7
5 /* 8 /*
6 全局变量声明 9 全局变量声明
@@ -87,3 +90,18 @@ type NameItem struct { @@ -87,3 +90,18 @@ type NameItem struct {
87 Id int `json:"id"` 90 Id int `json:"id"`
88 Name string `json:"name"` 91 Name string `json:"name"`
89 } 92 }
  93 +
  94 +type PageInfo struct {
  95 + PageIndex int `json:"pageIndex"` //页码(默认0代表第1页)
  96 + PageSize int `json:"pageSize" valid:"Required"` //每页数量
  97 +}
  98 +
  99 +//获取分页信息
  100 +func (p PageInfo) Offset() (offset int) {
  101 + var size = p.PageSize
  102 + if size == 0 {
  103 + size = 20
  104 + }
  105 + offset = size * p.PageIndex
  106 + return
  107 +}
@@ -257,6 +257,14 @@ func init() { @@ -257,6 +257,14 @@ func init() {
257 257
258 beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], 258 beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
259 beego.ControllerComments{ 259 beego.ControllerComments{
  260 + Method: "SiftingPool",
  261 + Router: `/siftingPool`,
  262 + AllowHTTPMethods: []string{"post"},
  263 + MethodParams: param.Make(),
  264 + Params: nil})
  265 +
  266 + beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
  267 + beego.ControllerComments{
260 Method: "ChanceStatistics", 268 Method: "ChanceStatistics",
261 Router: `/statistics`, 269 Router: `/statistics`,
262 AllowHTTPMethods: []string{"post"}, 270 AllowHTTPMethods: []string{"post"},
@@ -247,11 +247,17 @@ func SetMsgItem(header *protocol.RequestHeader, msg protocol.MsgItemOrm, commIte @@ -247,11 +247,17 @@ func SetMsgItem(header *protocol.RequestHeader, msg protocol.MsgItemOrm, commIte
247 247
248 //获取自查问题列表 通过模板 248 //获取自查问题列表 通过模板
249 func GetCheckQuestionsByTemplateId(id int64) (rsp []*protocol.CheckQuestion, err error) { 249 func GetCheckQuestionsByTemplateId(id int64) (rsp []*protocol.CheckQuestion, err error) {
  250 + type check struct {
  251 + models.AuditCheck
  252 + Id int64 `orm:"column(id)"`
  253 + ParentId int64 `orm:"column(parent_id)"`
  254 + }
250 var ( 255 var (
251 - checks []*models.AuditCheck 256 + checks []*check
252 ) 257 )
253 rsp = make([]*protocol.CheckQuestion, 0) 258 rsp = make([]*protocol.CheckQuestion, 0)
254 - if checks, err = models.GetAuditCheckBy(id); err != nil { 259 +
  260 + if err = models.GetAuditCheckBy(id, &checks); err != nil {
255 log.Error(err) 261 log.Error(err)
256 return 262 return
257 } 263 }
@@ -270,6 +276,8 @@ func GetCheckQuestionsByTemplateId(id int64) (rsp []*protocol.CheckQuestion, err @@ -270,6 +276,8 @@ func GetCheckQuestionsByTemplateId(id int64) (rsp []*protocol.CheckQuestion, err
270 } 276 }
271 tmpGroupId = c.Pid 277 tmpGroupId = c.Pid
272 item := protocol.NewCheckQuestion(c.Title, getQuestionTitle(groupIdx, idx, c.Title), c.Pid, protocol.CheckOptionsCommit) 278 item := protocol.NewCheckQuestion(c.Title, getQuestionTitle(groupIdx, idx, c.Title), c.Pid, protocol.CheckOptionsCommit)
  279 + item.Id = c.Id
  280 + item.ParentId = c.ParentId
273 rsp = append(rsp, item) 281 rsp = append(rsp, item)
274 idx++ 282 idx++
275 } 283 }
@@ -319,6 +327,9 @@ func GetCheckQuestionsByChanceId(header *protocol.RequestHeader, id int64) (rsp @@ -319,6 +327,9 @@ func GetCheckQuestionsByChanceId(header *protocol.RequestHeader, id int64) (rsp
319 item.Answer = c.Answer 327 item.Answer = c.Answer
320 } 328 }
321 } 329 }
  330 + if item.Id == 0 {
  331 + item.Id, item.ParentId = genCustomizeQuestionId(idx, groupIdx)
  332 + }
322 rsp = append(rsp, item) 333 rsp = append(rsp, item)
323 idx++ 334 idx++
324 } 335 }
@@ -331,6 +342,19 @@ func getQuestionTitle(groupIdx int, idx int, title string) string { @@ -331,6 +342,19 @@ func getQuestionTitle(groupIdx int, idx int, title string) string {
331 return fmt.Sprintf("%v.%v、%v?", groupIdx, idx, title) 342 return fmt.Sprintf("%v.%v、%v?", groupIdx, idx, title)
332 } 343 }
333 344
  345 +//自定义id
  346 +//@return id:问题序号 parentId:父级id
  347 +func genCustomizeQuestionId(idx, groupId int) (id int64, parentId int64) {
  348 + id = int64(idx) + 1
  349 + //同一分组的第一个 是一级
  350 + if idx == 0 {
  351 + parentId = 0
  352 + return
  353 + }
  354 + parentId = int64(groupId)
  355 + return
  356 +}
  357 +
334 //自查问题回答批量入库 358 //自查问题回答批量入库
335 //@isDelete 359 //@isDelete
336 func BulkInsertSelfChecks(header *protocol.RequestHeader, relateId, chanceId int64, selfChecks protocol.SelfChecks, isDeleteExisted bool, checkerType int) { 360 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 @@ -389,6 +413,7 @@ func BulkInsertSelfChecks(header *protocol.RequestHeader, relateId, chanceId int
389 o.Commit() 413 o.Commit()
390 } 414 }
391 415
  416 +//自查问题回答内容
392 func NewChanceSelfCheck(header *protocol.RequestHeader, check protocol.SelfCheck, chanceId, r int64, checkerType int) *models.ChanceSelfCheck { 417 func NewChanceSelfCheck(header *protocol.RequestHeader, check protocol.SelfCheck, chanceId, r int64, checkerType int) *models.ChanceSelfCheck {
393 return &models.ChanceSelfCheck{ 418 return &models.ChanceSelfCheck{
394 Id: idgen.Next(), 419 Id: idgen.Next(),
@@ -2222,3 +2222,51 @@ func CheckQuestions(header *protocol.RequestHeader, request *protocol.CheckQuest @@ -2222,3 +2222,51 @@ func CheckQuestions(header *protocol.RequestHeader, request *protocol.CheckQuest
2222 } 2222 }
2223 return 2223 return
2224 } 2224 }
  2225 +
  2226 +//SiftingPool 筛选池
  2227 +func SiftingPool(header *protocol.RequestHeader, request *protocol.SiftingPoolRequest) (rsp *protocol.SiftingPoolResponse, err error) {
  2228 + var (
  2229 + ormItems []protocol.ChanceSiftItemOrm
  2230 + )
  2231 + rsp = &protocol.SiftingPoolResponse{}
  2232 + rsp.List = make([]protocol.CommonListItem, 0)
  2233 + //测试使用
  2234 + if request.Uid != 0 {
  2235 + header.UserId = request.Uid
  2236 + }
  2237 + if request.SubmitStatus == protocol.Submiting {
  2238 + request.SiftedStatus = protocol.None
  2239 + } else if request.SubmitStatus == protocol.Submited {
  2240 + request.SiftedStatus = protocol.Waiting
  2241 + } else {
  2242 + err = protocol.NewCustomMessage(2, "obj.SubmitStatus must in (0,1)")
  2243 + return
  2244 + }
  2245 + if rsp.Total, err = models.GetSiftingChance(header.UserId, request.SubmitStatus, request.SiftedStatus, request.Offset(), request.PageSize, &ormItems); err != nil {
  2246 + if err == orm.ErrNoRows {
  2247 + err = nil
  2248 + return
  2249 + }
  2250 + log.Error(err)
  2251 + return
  2252 + }
  2253 + for i := 0; i < len(ormItems); i++ {
  2254 + ormItem := ormItems[i]
  2255 + commItem := protocol.CommonListItem{}
  2256 + commItem.Chance, commItem.ChanceStatus = agg.SetChanceItem(header, ormItem.CommChanceItemOrm)
  2257 + commItem.ReviewStatus = ormItem.ReviewStatus
  2258 + commItem.ChanceId = ormItem.ChanceId
  2259 + commItem.Chance.CreateTime = ormItem.ChanceApproveTime.Unix() * 1000
  2260 + if request.SubmitStatus == protocol.Submited {
  2261 + commItem.Chance.CreateTime = ormItem.SubmitCheckTime.Unix() * 1000
  2262 + }
  2263 +
  2264 + //模板数据
  2265 + commItem.ChanceTemplate = getTemplate(ormItem.TemplateId)
  2266 + commItem.ChanceType = getChanceType(ormItem.ChanceTypeId)
  2267 +
  2268 + rsp.List = append(rsp.List, commItem)
  2269 + }
  2270 +
  2271 + return
  2272 +}