正在显示
8 个修改的文件
包含
357 行增加
和
18 行删除
@@ -167,4 +167,48 @@ func (c *AuditController) GetChanceReviseLog() { | @@ -167,4 +167,48 @@ func (c *AuditController) GetChanceReviseLog() { | ||
167 | return | 167 | return |
168 | } | 168 | } |
169 | 169 | ||
170 | -// GetChanceReviseLog | 170 | +//GetChanceCheckResultList 获取机会的自查内容的筛选结果列表 |
171 | +//@router /v1/audit/check_result/list | ||
172 | +func (c *AuditController) GetChanceCheckResultList() { | ||
173 | + var msg *protocol.ResponseMessage | ||
174 | + defer func() { | ||
175 | + c.ResposeJson(msg) | ||
176 | + }() | ||
177 | + type Parameter struct { | ||
178 | + protocol.RequestPageInfo | ||
179 | + CheckResultStatus int8 `json:"check_result_status"` | ||
180 | + } | ||
181 | + var param Parameter | ||
182 | + if err := json.Unmarshal(c.Ctx.Input.RequestBody, ¶m); err != nil { | ||
183 | + log.Error("json 解析失败", err) | ||
184 | + msg = protocol.BadRequestParam("1") | ||
185 | + return | ||
186 | + } | ||
187 | + companyId := c.GetCompanyId() | ||
188 | + rspData := serveaudit.GetChanceCheckResultList(param.PageIndex, param.PageSize, companyId, param.CheckResultStatus) | ||
189 | + msg = protocol.NewReturnResponse(rspData, nil) | ||
190 | + return | ||
191 | +} | ||
192 | + | ||
193 | +//GetChanceCheckResultInfo 获取机会的自查内容的筛选结果详情 | ||
194 | +//@router /v1/audit/check_result/info | ||
195 | +func (c *AuditController) GetChanceCheckResultInfo() { | ||
196 | + // var msg *protocol.ResponseMessage | ||
197 | + // defer func() { | ||
198 | + // c.ResposeJson(msg) | ||
199 | + // }() | ||
200 | + // type Parameter struct { | ||
201 | + // protocol.RequestPageInfo | ||
202 | + // CheckResultStatus int8 `json:"check_result_status"` | ||
203 | + // } | ||
204 | + // var param Parameter | ||
205 | + // if err := json.Unmarshal(c.Ctx.Input.RequestBody, ¶m); err != nil { | ||
206 | + // log.Error("json 解析失败", err) | ||
207 | + // msg = protocol.BadRequestParam("1") | ||
208 | + // return | ||
209 | + // } | ||
210 | + // companyId := c.GetCompanyId() | ||
211 | + // rspData := serveaudit.GetChanceCheckResultList(param.PageIndex, param.PageSize, companyId, param.CheckResultStatus) | ||
212 | + // msg = protocol.NewReturnResponse(rspData, nil) | ||
213 | + return | ||
214 | +} |
@@ -35,6 +35,8 @@ type Chance struct { | @@ -35,6 +35,8 @@ type Chance struct { | ||
35 | Code string `orm:"column(code)" description:"机会编码"` | 35 | Code string `orm:"column(code)" description:"机会编码"` |
36 | Status int8 `orm:"column(status)" description:"机会状态 1:开启 2:关闭"` | 36 | Status int8 `orm:"column(status)" description:"机会状态 1:开启 2:关闭"` |
37 | SelfChecks string `orm:"column(self_checks)" description:"自查内容"` | 37 | SelfChecks string `orm:"column(self_checks)" description:"自查内容"` |
38 | + CheckResultStatus int8 ` orm:"column(check_result_status)"` | ||
39 | + CheckTime time.Time `orm:"column(check_time);type(timestamp);"` | ||
38 | } | 40 | } |
39 | 41 | ||
40 | func (t *Chance) TableName() string { | 42 | func (t *Chance) TableName() string { |
@@ -95,6 +97,19 @@ var ChanceStatusMap = map[int8]string{ | @@ -95,6 +97,19 @@ var ChanceStatusMap = map[int8]string{ | ||
95 | ChanceStatusForbid: "已关闭", | 97 | ChanceStatusForbid: "已关闭", |
96 | } | 98 | } |
97 | 99 | ||
100 | +//机会自查内容筛选状态 【1:待处理未设置】【2:通过】【3:不通过】 | ||
101 | +const ( | ||
102 | + CheckResultStatusWait int8 = 1 | ||
103 | + CheckResultStatusPass int8 = 2 | ||
104 | + CheckResultStatusNOPass int8 = 3 | ||
105 | +) | ||
106 | + | ||
107 | +var CheckResultStatusMap = map[int8]string{ | ||
108 | + CheckResultStatusWait: "未设置", | ||
109 | + CheckResultStatusPass: "通过", | ||
110 | + CheckResultStatusNOPass: "未通过", | ||
111 | +} | ||
112 | + | ||
98 | //ChanceSelfCheck chance表中SelfChecks字段的json结构 | 113 | //ChanceSelfCheck chance表中SelfChecks字段的json结构 |
99 | type ChanceSelfCheck struct { | 114 | type ChanceSelfCheck struct { |
100 | ChickItem string `json:"checkItem"` | 115 | ChickItem string `json:"checkItem"` |
models/chance_check_result.go
0 → 100644
1 | +package models | ||
2 | + | ||
3 | +import ( | ||
4 | + "time" | ||
5 | + | ||
6 | + "github.com/astaxie/beego/orm" | ||
7 | +) | ||
8 | + | ||
9 | +type ChanceCheckResult struct { | ||
10 | + Id int `orm:"column(id);pk"` | ||
11 | + ChanceId int64 `orm:"column(chance_id)"` | ||
12 | + GroupId int64 `orm:"column(group_id);null"` | ||
13 | + Pid int64 `orm:"column(pid)"` | ||
14 | + CheckItem string `orm:"column(check_item);size(20);null" description:"检查项"` | ||
15 | + Answer string `orm:"column(answer);size(50);null" description:"回答"` | ||
16 | + Reason string `orm:"column(reason);size(200);null" description:"理由"` | ||
17 | + UserCompanyId int64 `orm:"column(user_company_id);null"` | ||
18 | + CreateAt time.Time `orm:"column(create_at);type(timestamp);null"` | ||
19 | +} | ||
20 | + | ||
21 | +func (t *ChanceCheckResult) TableName() string { | ||
22 | + return "chance_check_result" | ||
23 | +} | ||
24 | + | ||
25 | +func init() { | ||
26 | + orm.RegisterModel(new(ChanceCheckResult)) | ||
27 | +} | ||
28 | + | ||
29 | +// GetChanceCheckResultById retrieves ChanceCheckResult by Id. Returns error if | ||
30 | +// Id doesn't exist | ||
31 | +func GetChanceCheckResultById(id int) (v *ChanceCheckResult, err error) { | ||
32 | + o := orm.NewOrm() | ||
33 | + v = &ChanceCheckResult{Id: id} | ||
34 | + if err = o.Read(v); err == nil { | ||
35 | + return v, nil | ||
36 | + } | ||
37 | + return nil, err | ||
38 | +} | ||
39 | + | ||
40 | +func GetChanceCheckResultByChancce(chanceId int64) ([]ChanceCheckResult, error) { | ||
41 | + var ( | ||
42 | + err error | ||
43 | + data []ChanceCheckResult | ||
44 | + ) | ||
45 | + o := orm.NewOrm() | ||
46 | + _, err = o.QueryTable(&ChanceCheckResult{}). | ||
47 | + Filter("chance_id", chanceId). | ||
48 | + All(&data) | ||
49 | + return data, err | ||
50 | +} |
@@ -293,3 +293,41 @@ type ChanceFlowLog struct { | @@ -293,3 +293,41 @@ type ChanceFlowLog struct { | ||
293 | NickName string `json:"nick_name" orm:"column(nick_name)"` | 293 | NickName string `json:"nick_name" orm:"column(nick_name)"` |
294 | Code int `json:"code" orm:"column(code)"` | 294 | Code int `json:"code" orm:"column(code)"` |
295 | } | 295 | } |
296 | + | ||
297 | +//ReponseChanceCheckResult 响应筛选结果详情 | ||
298 | +type ReponseChanceCheckResult struct { | ||
299 | + CustomItem []string `json:"custom_item"` | ||
300 | + CheckData []ChanceCheckResultData `json:"check_data"` | ||
301 | +} | ||
302 | + | ||
303 | +// ChanceCheckResultData 筛选结果详情数据 | ||
304 | +type ChanceCheckResultData struct { | ||
305 | + Total string `json:"total"` | ||
306 | + CheckItem string `json:"check_item"` | ||
307 | + CustomItemData map[string]string `json:"custom_item_data"` | ||
308 | +} | ||
309 | + | ||
310 | +//ResponseChanceCheckResultList 响应自查内容筛选结果列表 | ||
311 | +type ResponseChanceCheckResultList struct { | ||
312 | + ResponsePageInfo | ||
313 | + List []RspCheckResultList `json:"lists"` | ||
314 | +} | ||
315 | + | ||
316 | +type RspCheckResultList struct { | ||
317 | + Id string `json:"id"` //机会的id | ||
318 | + Code string `json:"code" ` | ||
319 | + ChanceType string `json:"chance_type"` //一级分类 | ||
320 | + TemplateName string `json:"template_name"` //二级分类 | ||
321 | + UserName string `json:"user_name"` // 提交人 | ||
322 | + Department string `json:"department"` //提交部门 | ||
323 | + CreateTime string `json:"create_time"` //提交时间 | ||
324 | + PublishStatus int `json:"publish_status"` //公开状态 | ||
325 | + PublishStatusName string `json:"publish_status_name"` // | ||
326 | + ReviewStatus int8 `json:"review_status"` //审批状态 | ||
327 | + ReviewStatusName string `json:"review_status_name"` | ||
328 | + Status int8 `json:"status"` //开启、关闭状态 | ||
329 | + StatusName string `json:"status_name"` | ||
330 | + DiscoveryScore string `json:"discovery_score"` | ||
331 | + CommentTotal string `json:"comment_total"` | ||
332 | + CheckResultStatusName string `json:"check_result_status_name"` //自查内容筛选状态 | ||
333 | +} |
@@ -107,6 +107,7 @@ func init() { | @@ -107,6 +107,7 @@ func init() { | ||
107 | beego.NSRouter("/info", &controllers.AuditController{}, "post:AuditInfo"), | 107 | beego.NSRouter("/info", &controllers.AuditController{}, "post:AuditInfo"), |
108 | beego.NSRouter("/allow_forbid", &controllers.AuditController{}, "post:AllowForbidAudit"), | 108 | beego.NSRouter("/allow_forbid", &controllers.AuditController{}, "post:AllowForbidAudit"), |
109 | beego.NSRouter("/revise/info", &controllers.AuditController{}, "post:GetChanceReviseLog"), | 109 | beego.NSRouter("/revise/info", &controllers.AuditController{}, "post:GetChanceReviseLog"), |
110 | + beego.NSRouter("/check_result/list", &controllers.AuditController{}, "post:GetChanceCheckResultList"), | ||
110 | ), | 111 | ), |
111 | beego.NSNamespace("/rank", | 112 | beego.NSNamespace("/rank", |
112 | beego.NSRouter("/type/list", &controllers.RankController{}, "post:GetRankType"), | 113 | beego.NSRouter("/type/list", &controllers.RankController{}, "post:GetRankType"), |
@@ -14,22 +14,6 @@ import ( | @@ -14,22 +14,6 @@ import ( | ||
14 | "time" | 14 | "time" |
15 | ) | 15 | ) |
16 | 16 | ||
17 | -type SqlData struct { | ||
18 | - Id int64 `orm:"column(id)"` | ||
19 | - UserId int64 `orm:"column(user_id)"` | ||
20 | - NickName string `orm:"column(nick_name)"` | ||
21 | - DepartmentId int64 `orm:"column(department_id)"` | ||
22 | - AuditTemplateId int64 `orm:"column(audit_template_id)"` | ||
23 | - ChanceTypeId int `orm:"column(chance_type_id)"` | ||
24 | - PublishStatus int `orm:"column(publish_status)"` | ||
25 | - CreateAt string `orm:"column(create_at)"` | ||
26 | - ReviewStatus int8 `orm:"column(review_status)"` | ||
27 | - Status int8 `orm:"column(status)"` | ||
28 | - DiscoveryScore string `orm:"column(discovery_score)"` | ||
29 | - CommentTotal string `orm:"column(comment_total)"` | ||
30 | - Code string `orm:"column(code)"` | ||
31 | -} | ||
32 | - | ||
33 | func getAuditUserHasPermission(userid int64, usercompanyid int64) ( | 17 | func getAuditUserHasPermission(userid int64, usercompanyid int64) ( |
34 | serverabc.PermissionOptionObject, error) { | 18 | serverabc.PermissionOptionObject, error) { |
35 | var permissionObject serverabc.PermissionOptionObject | 19 | var permissionObject serverabc.PermissionOptionObject |
@@ -155,7 +139,21 @@ func buildSqlForAuditList(usercompanyid int64, companyid int64, userid int64) st | @@ -155,7 +139,21 @@ func buildSqlForAuditList(usercompanyid int64, companyid int64, userid int64) st | ||
155 | } | 139 | } |
156 | 140 | ||
157 | func GetAuditList(param protocol.RequestAuditList, companyid int64, userid int64) (protocol.ResponseAuditList, error) { | 141 | func GetAuditList(param protocol.RequestAuditList, companyid int64, userid int64) (protocol.ResponseAuditList, error) { |
158 | - | 142 | + type SqlData struct { |
143 | + Id int64 `orm:"column(id)"` | ||
144 | + UserId int64 `orm:"column(user_id)"` | ||
145 | + NickName string `orm:"column(nick_name)"` | ||
146 | + DepartmentId int64 `orm:"column(department_id)"` | ||
147 | + AuditTemplateId int64 `orm:"column(audit_template_id)"` | ||
148 | + ChanceTypeId int `orm:"column(chance_type_id)"` | ||
149 | + PublishStatus int `orm:"column(publish_status)"` | ||
150 | + CreateAt string `orm:"column(create_at)"` | ||
151 | + ReviewStatus int8 `orm:"column(review_status)"` | ||
152 | + Status int8 `orm:"column(status)"` | ||
153 | + DiscoveryScore string `orm:"column(discovery_score)"` | ||
154 | + CommentTotal string `orm:"column(comment_total)"` | ||
155 | + Code string `orm:"column(code)"` | ||
156 | + } | ||
159 | var ( | 157 | var ( |
160 | datasql = strings.Builder{} | 158 | datasql = strings.Builder{} |
161 | countsql = strings.Builder{} | 159 | countsql = strings.Builder{} |
services/audit/self_check.go
0 → 100644
1 | +package audit | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "oppmg/common/log" | ||
6 | + "oppmg/models" | ||
7 | + "oppmg/protocol" | ||
8 | + "oppmg/utils" | ||
9 | +) | ||
10 | + | ||
11 | +//GetChanceCheckResultInfo 获取机会详情 | ||
12 | +func GetChanceCheckResultInfo(chanceId int64, companyid int64) (protocol.ReponseChanceCheckResult, error) { | ||
13 | + var ( | ||
14 | + chanceData *models.Chance | ||
15 | + err error | ||
16 | + ) | ||
17 | + rsp := protocol.ReponseChanceCheckResult{ | ||
18 | + CustomItem: []string{}, | ||
19 | + CheckData: []protocol.ChanceCheckResultData{}, | ||
20 | + } | ||
21 | + chanceData, err = models.GetChanceById(chanceId) | ||
22 | + if err != nil { | ||
23 | + log.Error("获取机会数据失败,err:%s", err) | ||
24 | + return rsp, protocol.NewErrWithMessage("1") | ||
25 | + } | ||
26 | + if chanceData.CompanyId != companyid { | ||
27 | + log.Error("机会的公司数据无法对应") | ||
28 | + return rsp, protocol.NewErrWithMessage("1") | ||
29 | + } | ||
30 | + if chanceData.CheckResultStatus < models.CheckResultStatusWait { | ||
31 | + log.Error("机会的自查内容筛选状态错误") | ||
32 | + return rsp, protocol.NewErrWithMessage("1") | ||
33 | + } | ||
34 | + var ( | ||
35 | + checkResultData []models.ChanceCheckResult | ||
36 | + ) | ||
37 | + checkResultData, err = models.GetChanceCheckResultByChancce(chanceId) | ||
38 | + if err != nil { | ||
39 | + log.Error("未获得指定的机会自查内容筛选结果,err;%s", err) | ||
40 | + return rsp, nil | ||
41 | + } | ||
42 | + //组装响应数据 | ||
43 | + //定义动态数据列 | ||
44 | + customItems := utils.NewArraySetString() | ||
45 | + //自查内容项 | ||
46 | + checkItems := utils.NewArraySetString() | ||
47 | + _ = checkResultData | ||
48 | + _ = customItems | ||
49 | + _ = checkItems | ||
50 | + return rsp, err | ||
51 | +} | ||
52 | + | ||
53 | +func GetChanceCheckResultList(pageIndex int, pageSize int, companyId int64, checkResultStatus int8) protocol.ResponseChanceCheckResultList { | ||
54 | + type SqlData struct { | ||
55 | + Id int64 `orm:"column(id)"` | ||
56 | + UserId int64 `orm:"column(user_id)"` | ||
57 | + NickName string `orm:"column(nick_name)"` | ||
58 | + DepartmentId int64 `orm:"column(department_id)"` | ||
59 | + AuditTemplateId int64 `orm:"column(audit_template_id)"` | ||
60 | + ChanceTypeId int `orm:"column(chance_type_id)"` | ||
61 | + PublishStatus int `orm:"column(publish_status)"` | ||
62 | + CreateAt string `orm:"column(create_at)"` | ||
63 | + ReviewStatus int8 `orm:"column(review_status)"` | ||
64 | + Status int8 `orm:"column(status)"` | ||
65 | + DiscoveryScore string `orm:"column(discovery_score)"` | ||
66 | + CommentTotal string `orm:"column(comment_total)"` | ||
67 | + Code string `orm:"column(code)"` | ||
68 | + CheckResultStatus int8 `orm:"column(check_result_status)"` | ||
69 | + } | ||
70 | + | ||
71 | + returnData := protocol.ResponseChanceCheckResultList{ | ||
72 | + ResponsePageInfo: protocol.ResponsePageInfo{ | ||
73 | + TotalPage: 0, | ||
74 | + CurrentPage: pageIndex, | ||
75 | + }, | ||
76 | + List: make([]protocol.RspCheckResultList, 0), | ||
77 | + } | ||
78 | + datasql := `SELECT a.id,a.department_id,a.audit_template_id,a.chance_type_id | ||
79 | + ,a.publish_status,a.create_at,a.review_status,a.status,a.check_result_status | ||
80 | + ,a.discovery_score,a.comment_total ,a.code,d.nick_name,d.id as user_id | ||
81 | + FROM chance AS a | ||
82 | + LEFt JOIN user_company AS c ON c.id = a.user_id | ||
83 | + LEFt JOIN user AS d ON c.user_id = d.id | ||
84 | + where a.company_id=? ` | ||
85 | + countsql := ` SELECT count(*) FROM chance as a | ||
86 | + where a.company_id=? ` | ||
87 | + cond := []interface{}{companyId} | ||
88 | + if checkResultStatus > 0 { | ||
89 | + datasql += ` AND a.check_result_status=? ` | ||
90 | + countsql += ` AND a.check_result_status=? ` | ||
91 | + cond = append(cond, checkResultStatus) | ||
92 | + } else { | ||
93 | + datasql += ` AND a.check_result_status>0 ` | ||
94 | + countsql += ` AND a.check_result_status>0 ` | ||
95 | + } | ||
96 | + dataStart := (pageIndex - 1) * pageSize | ||
97 | + datasql += fmt.Sprintf(` ORDER BY a.create_at DESC limit %d,%d `, dataStart, pageSize) | ||
98 | + var ( | ||
99 | + cnt int | ||
100 | + sqldata []SqlData | ||
101 | + err error | ||
102 | + ) | ||
103 | + err = utils.ExecuteQueryOne(&cnt, countsql, cond...) | ||
104 | + if err != nil { | ||
105 | + log.Error("EXCUTE SQL ERR:%s", err) | ||
106 | + return returnData | ||
107 | + } | ||
108 | + if cnt <= 0 { | ||
109 | + return returnData | ||
110 | + } | ||
111 | + err = utils.ExecuteQueryAll(&sqldata, datasql, cond...) | ||
112 | + if err != nil { | ||
113 | + log.Error("EXCUTE SQL ERR:%s", err) | ||
114 | + return returnData | ||
115 | + } | ||
116 | + for _, v := range sqldata { | ||
117 | + item := protocol.RspCheckResultList{ | ||
118 | + Id: fmt.Sprint(v.Id), | ||
119 | + Status: v.Status, | ||
120 | + StatusName: models.ChanceStatusMap[v.Status], | ||
121 | + PublishStatus: v.PublishStatus, | ||
122 | + PublishStatusName: models.ChancePublishStatusMap[v.PublishStatus], | ||
123 | + ReviewStatus: v.ReviewStatus, | ||
124 | + ReviewStatusName: models.ChanceReviewStatusMap[v.ReviewStatus], | ||
125 | + Code: v.Code, | ||
126 | + DiscoveryScore: v.DiscoveryScore, | ||
127 | + CommentTotal: v.CommentTotal, | ||
128 | + UserName: v.NickName, | ||
129 | + CreateTime: v.CreateAt, | ||
130 | + CheckResultStatusName: models.CheckResultStatusMap[v.CheckResultStatus], | ||
131 | + } | ||
132 | + if d, err := models.GetDepartmentById(v.DepartmentId); err == nil { | ||
133 | + item.Department = d.Name | ||
134 | + } | ||
135 | + if ct, err := models.GetChanceTypeById(v.ChanceTypeId); err == nil { | ||
136 | + item.ChanceType = ct.Name | ||
137 | + } | ||
138 | + if tp, err := models.GetAuditTemplateById(v.AuditTemplateId); err == nil { | ||
139 | + item.TemplateName = tp.Name | ||
140 | + } | ||
141 | + returnData.List = append(returnData.List, item) | ||
142 | + | ||
143 | + } | ||
144 | + returnData.TotalPage = cnt | ||
145 | + returnData.CurrentPage = pageIndex | ||
146 | + return returnData | ||
147 | +} |
@@ -75,3 +75,49 @@ func ArrayInt64Unique(s []int64) []int64 { | @@ -75,3 +75,49 @@ func ArrayInt64Unique(s []int64) []int64 { | ||
75 | } | 75 | } |
76 | return newS | 76 | return newS |
77 | } | 77 | } |
78 | + | ||
79 | +//ArraySetString 构建元素不重复的数组 | ||
80 | +//可按需扩展 | ||
81 | +type ArraySetString struct { | ||
82 | + m map[string]int | ||
83 | +} | ||
84 | + | ||
85 | +func NewArraySetString() ArraySetString { | ||
86 | + return ArraySetString{ | ||
87 | + m: make(map[string]int), | ||
88 | + } | ||
89 | +} | ||
90 | +func (set *ArraySetString) Has(str string) bool { | ||
91 | + if _, ok := set.m[str]; ok { | ||
92 | + return true | ||
93 | + } | ||
94 | + return false | ||
95 | +} | ||
96 | + | ||
97 | +//Add 追加元素 | ||
98 | +func (set *ArraySetString) Add(str string) { | ||
99 | + if _, ok := set.m[str]; ok { | ||
100 | + return | ||
101 | + } | ||
102 | + l := len(set.m) | ||
103 | + set.m[str] = l | ||
104 | +} | ||
105 | + | ||
106 | +//Remove 移除指定元素 | ||
107 | +func (set *ArraySetString) Remove(str string) { | ||
108 | + delete(set.m, str) | ||
109 | +} | ||
110 | + | ||
111 | +//Len 元素长度 | ||
112 | +func (set *ArraySetString) Len() int { | ||
113 | + return len(set.m) | ||
114 | +} | ||
115 | + | ||
116 | +//ToSlice 转换为切片输出 | ||
117 | +func (set *ArraySetString) ToSlice() []string { | ||
118 | + newSlice := make([]string, len(set.m)) | ||
119 | + for k, v := range set.m { | ||
120 | + newSlice[v] = k | ||
121 | + } | ||
122 | + return newSlice | ||
123 | +} |
-
请 注册 或 登录 后发表评论