作者 yangfu

1.机会搜索 2.审核是否需要提交自查

... ... @@ -671,6 +671,31 @@ func (this *ChanceController) ChanceReservePool() {
msg = protocol.NewReturnResponse(chance.ChancePool(header, request))
}
//SearchChance 搜索
//@router /search [post]
func (this *ChanceController) SearchChance() {
var msg *protocol.ResponseMessage
defer func() {
this.Resp(msg)
}()
var request *protocol.ChancePoolRequest
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
}
if len(strings.TrimSpace(request.KeyWord)) == 0 {
msg = protocol.BadRequestParamWithMessage(2, "请输入机会内容、员工姓名")
return
}
header := controllers.GetRequestHeader(this.Ctx)
msg = protocol.NewReturnResponse(chance.ChancePool(header, request))
}
//ChanceReviseDetail 机会补充详情
//@router /chanceReviseDetail [post]
func (this *ChanceController) ChanceReviseDetail() {
... ...
... ... @@ -17,6 +17,7 @@ type AuditTemplate struct {
Code string `orm:"column(code);size(50);null" description:" 编码"`
NoticeType int8 `orm:"column(notice_type)" description:"通知方式"`
NoApprover int8 `orm:"column(no_approver)" description:"审核人空时:【1:自动通过】【2:转交给管理员】"`
SelfCheckNeed int8 `orm:"column(self_check_need)" description:"是否需要自查内容 【1:需要自查内容】【2:不需要】"`
SortNum int `orm:"column(sort_num)" description:"自定义排序编号"`
VisibleType int8 `orm:"column(visible_type)" description:"可见范围 0:所有人 1:指定部门 "`
VisibleObject string `orm:"column(visible_object);size(1000);null" description:"可见的对象 部门 指定人 json"`
... ...
... ... @@ -55,10 +55,12 @@ const (
)
type ChancePoolOption struct {
ChanceTypeId int //机会类型编号
DIds []int //部门编号列表
Type int8 //机会类型
ReserveTypeId int //机会储备类型编号
ChanceTypeId int //机会类型编号
DIds []int //部门编号列表
Type int8 //机会类型
ReserveTypeId int //机会储备类型编号
KeyWord string //搜索特定内容的机会 (基础/附加)
InUsers []int64 //搜索特定User的机会
}
//机会池查询选项
... ... @@ -74,6 +76,17 @@ func NewChancePoolOption(chanceTypeId int, deps []int, t int8, rt int) *ChancePo
ReserveTypeId: rt,
}
}
func (o *ChancePoolOption) SetKeyWord(keyWord string) *ChancePoolOption {
o.KeyWord = keyWord
return o
}
func (o *ChancePoolOption) SetInUsers(inUsers []int64) *ChancePoolOption {
if len(inUsers) == 0 {
return o
}
o.InUsers = inUsers
return o
}
var (
SqlGetChanceSelfChecks = `select user_id,review_status,self_checks from chance where id =?` //机会自查数据
... ... @@ -569,6 +582,11 @@ func getFilterSql(option *ChancePoolOption) string {
if option.ReserveTypeId > 0 {
rsp.WriteString(fmt.Sprintf(" and reserve_type_id =%v ", option.ReserveTypeId))
}
if len(option.KeyWord) > 0 && len(option.InUsers) > 0 {
rsp.WriteString(fmt.Sprintf(" and (user_id in (%v) or source_content like '%%%v%%' )", utils.JoinInt64s(option.InUsers, ","), option.KeyWord))
} else if len(option.KeyWord) > 0 {
rsp.WriteString(fmt.Sprintf(" and source_content like '%%%v%%' ", option.KeyWord))
}
return rsp.String()
}
... ...
... ... @@ -129,3 +129,20 @@ func GetUserAllCompany(uid int64) (v []*UserCompany, err error) {
}
return nil, err
}
//获取用户Id列表
//@key CompanyId NickName
func GetUserCompanyIdAllBy(options map[string]interface{}) (v []int64, err error) {
o := orm.NewOrm()
sql := "select id from user_company where enable=1"
if _, ok := options["CompanyId"]; ok {
sql += fmt.Sprintf(" and company_id=%v ", options["CompanyId"])
}
if _, ok := options["NickName"]; ok {
sql += fmt.Sprintf(" and nick_name like '%%%v%%' ", options["NickName"])
}
if _, err = o.Raw(sql).QueryRows(&v); err == nil {
return v, nil
}
return nil, err
}
... ...
... ... @@ -203,8 +203,9 @@ 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 int8 `json:"type"` //0:机会池 1:储备池
ReserveTypeId int `json:"reserveTypeId"` //储备类型编号
KeyWord string `json:"keyWord"` //搜索特定内容的机会
}
type ChancePoolResponse struct {
List []CommonListItem `json:"list"`
... ... @@ -508,12 +509,28 @@ type Template struct {
//表单
type Form struct {
Id int `json:"id"`
Label string `json:"label"`
InputType string `json:"inputType"`
SectionType int8 `json:"sectionType"`
Value string `json:"value"`
Required int8 `json:"required"`
Id int `json:"id"`
Label string `json:"label"`
InputType string `json:"inputType"`
SectionType int8 `json:"sectionType"`
Required int8 `json:"required"`
Value string `json:"value"`
ValueList []*ValueListItem `json:"valueList"`
Data []*FormDataItem `json:"data"`
}
type ValueListItem struct {
Type string `json:"type"`
Value string `json:"value"`
}
type FormDataItem struct {
Type string `json:"type"`
Value string `json:"value"`
Path string `json:"path,omitempty"`
Cover *Cover `json:"cover,omitempty"`
Duration int `json:"duration,omitempty"`
Remark string `json:"remark,omitempty"`
}
//清楚未填写的表单数据
... ... @@ -563,7 +580,18 @@ type Video struct {
//审批配置
type AuditConfig struct {
NoApprover int8 `json:"no_approver"` //审核人空时:【1:自动通过】【2:转交给管理员】
NoApprover int8 `json:"no_approver"` //审核人空时:【1:自动通过】【2:转交给管理员】
SelfCheckNeed int8 `json:"self_check_need"` //审核人是否需要提交自查 1:需要 0:不需要
}
func (c AuditConfig) GetSelfCheckNeed() int {
if c.SelfCheckNeed == 1 {
return 1
}
if c.SelfCheckNeed == 2 {
return 0
}
return 1
}
//机会池 - 统计
... ...
... ... @@ -50,9 +50,10 @@ type Approve struct {
//审核操作权限
type ApproveAccess struct {
ProcessId int64 `json:"processId"`
AllowApprove int `json:"allowApprove"`
AllowReject int `json:"allowReject"`
ProcessId int64 `json:"processId"`
AllowApprove int `json:"allowApprove"`
AllowReject int `json:"allowReject"`
SelfCheckNeed int `json:"selfCheckNeed"` //是否需要提交自查
}
//审核数据 审核通过
... ...
... ... @@ -44,6 +44,14 @@ const (
MyGraspAchievement //我把握的成果
)
//输入类型
const (
InputRadio = "radio"
InputFiles = "files"
InputCheckbox = "checkbox"
InputText = "text"
)
var MapStaticName map[int64]string
func init() {
... ...
... ... @@ -178,7 +178,7 @@ type Cover struct {
Path string `json:"path" valid:"Required"`
H int `json:"-"`
W int `json:"-"`
ImageId string `json:"imageId"`
ImageId string `json:"-"`
}
/*公告列表 BulletinList */
... ...
... ... @@ -305,6 +305,14 @@ func init() {
beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
beego.ControllerComments{
Method: "SearchChance",
Router: `/search`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
beego.ControllerComments{
Method: "SiftingPool",
Router: `/siftingPool`,
AllowHTTPMethods: []string{"post"},
... ...
... ... @@ -56,6 +56,13 @@ func GetChancePool(uid, cid int64, o *models.ChancePoolOption, departmentId int,
}
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)
if len(o.KeyWord) > 0 {
option.SetKeyWord(o.KeyWord)
ids, _ := models.GetUserCompanyIdAllBy(map[string]interface{}{"CompanyId": cid, "NickName": o.KeyWord})
if len(ids) > 0 {
option.SetInUsers(ids)
}
}
switch check {
case OpportunityCheckLv1:
return models.GetChancePoolMyself(uid, cid, option, lastId, pageSize, v)
... ...
... ... @@ -538,7 +538,9 @@ func ConverTypeToReviewStaus(approveType int) (reviewStatus int) {
func ChanceApproveProcess(header *protocol.RequestHeader, chance *models.Chance) (rsp *protocol.ChanceApproveProcessResponse, err error) {
var (
processList []*models.AuditFlowProcess
config *protocol.AuditConfig
)
utils.JsonUnmarshal(chance.AuditTemplateConfig, &config)
if processList, err = models.GetAuditFlowProcessList(chance.Id); err != nil {
log.Error(fmt.Sprintf("chance_id :%v 未查询到审核流信息", chance.Id), err)
if err == orm.ErrNoRows {
... ... @@ -590,9 +592,10 @@ func ChanceApproveProcess(header *protocol.RequestHeader, chance *models.Chance)
}
if process.ReviewStatus == protocol.ReviewStatusAuditging && process.Uid == header.UserId {
rsp.ApproveAccess = &protocol.ApproveAccess{
AllowApprove: 1,
AllowReject: 1,
ProcessId: process.Id,
AllowApprove: 1,
AllowReject: 1,
SelfCheckNeed: config.GetSelfCheckNeed(),
ProcessId: process.Id,
}
}
}
... ...
... ... @@ -347,14 +347,20 @@ func Template(header *protocol.RequestHeader, request *protocol.TemplateRequest)
}
for j := range forms {
form := forms[j]
template.FormList[j] = &protocol.Form{
formItem := &protocol.Form{
Id: form.Id,
Label: form.Label,
Value: "",
InputType: form.InputType,
SectionType: form.Section,
Required: form.Required,
Data: make([]*protocol.FormDataItem, 0),
ValueList: make([]*protocol.ValueListItem, 0),
}
if len(form.ValueList) > 0 && form.InputType == protocol.InputRadio {
utils.JsonUnmarshal(form.ValueList, &formItem.ValueList)
}
template.FormList[j] = formItem
}
rsp.Template = template
return
... ... @@ -432,7 +438,7 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit
err = protocol.NewErrWithMessage(5302)
return
}
auditConfig = &protocol.AuditConfig{NoApprover: template.NoApprover}
auditConfig = &protocol.AuditConfig{NoApprover: template.NoApprover, SelfCheckNeed: template.SelfCheckNeed}
orm := orm.NewOrm()
orm.Begin()
//2.检查模板是否有权限
... ... @@ -1590,7 +1596,9 @@ func ChancePool(header *protocol.RequestHeader, request *protocol.ChancePoolRequ
provider *protocol.BaseUserInfo
flag int
)
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 {
options := models.NewChancePoolOption(request.ChanceTypeId, []int{}, request.Type, request.ReserveTypeId)
options.SetKeyWord(request.KeyWord)
if total, err = agg.GetChancePool(header.UserId, header.CompanyId, options, request.DepartmentId, request.IncludeSubDepartment, request.LastId, request.PageSize, &chanceItems); err != nil {
if err == orm.ErrNoRows {
err = nil
return
... ... @@ -2018,9 +2026,8 @@ func ChanceDetail(header *protocol.RequestHeader, request *protocol.ChanceDetail
UpdateTime: chance.UpdateAt.Unix() * 1000,
}
jsonUnmarshal(chance.SourceContent, &item.FormList)
//jsonUnmarshal(chance.SelfChecks, &item.SelfChecks)
item.SelfChecks = agg.GetChanceSelfChecks(chance)
item.FormList = clearEmptyForm(item.FormList)
//item.FormList = clearEmptyForm(item.FormList)
item.RelatedDepartmentId = chance.DepartmentId
item.RelatedDepartmentInfo = agg.GetDepartment(int(chance.DepartmentId))
if chanceData, err = models.GetChanceDataByChanceId(chance.Id); err == nil {
... ...