作者 yangfu

自查内容

... ... @@ -286,11 +286,12 @@ func (this *ChanceController) ChanceSubmit() {
msg = m
return
}
if e := request.SelfChecks.Valid(); e != nil {
log.Error(e)
msg = protocol.NewReturnResponse(nil, e)
return
}
header := controllers.GetRequestHeader(this.Ctx)
//if request.Id > 0 {
// msg = protocol.NewReturnResponse(chance.ChanceUpdate(header, request))
// return
//}
msg = protocol.NewReturnResponse(chance.ChanceSubmit(header, request))
}
... ... @@ -311,6 +312,11 @@ func (this *ChanceController) ChanceUpdate() {
msg = m
return
}
if e := request.SelfChecks.Valid(); e != nil {
log.Error(e)
msg = protocol.NewReturnResponse(nil, e)
return
}
header := controllers.GetRequestHeader(this.Ctx)
msg = protocol.NewReturnResponse(chance.ChanceUpdate(header, request))
}
... ... @@ -443,6 +449,11 @@ func (this *ChanceController) ChanceApprove() {
return
}
}
if e := request.SelfChecks.Valid(); e != nil {
log.Error(e)
msg = protocol.NewReturnResponse(nil, e)
return
}
header := controllers.GetRequestHeader(this.Ctx)
msg = protocol.NewReturnResponse(chance.ChanceApprove(header, request))
}
... ... @@ -636,3 +647,24 @@ func (this *ChanceController) ChanceReviseDetail() {
header := controllers.GetRequestHeader(this.Ctx)
msg = protocol.NewReturnResponse(chance.ChanceReviseDetail(header, request))
}
//CheckQuestions 自查问题列表
//@router /checkQuestions [post]
func (this *ChanceController) CheckQuestions() {
var msg *protocol.ResponseMessage
defer func() {
this.Resp(msg)
}()
var request *protocol.CheckQuestionsRequest
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.CheckQuestions(header, request))
}
... ...
package models
import (
"time"
"github.com/astaxie/beego/orm"
)
type AuditCheck struct {
Id int `orm:"column(id);pk"`
Pid int64 `orm:"column(pid)"`
TemplateId int64 `orm:"column(template_id)" description:"模板id"`
Title string `orm:"column(title);size(100)" description:"标题"`
Items string `orm:"column(items)" description:"选项数据json格式"`
Enable int8 `orm:"column(enable)" description:"是否有效【0:无效】【1:有效】"`
CreateTime time.Time `orm:"column(create_time);type(timestamp)"`
}
func (t *AuditCheck) TableName() string {
return "audit_check"
}
func init() {
orm.RegisterModel(new(AuditCheck))
}
// GetAuditCheckById retrieves AuditCheck by Id. Returns error if
// Id doesn't exist
func GetAuditCheckById(id int) (v *AuditCheck, err error) {
o := orm.NewOrm()
v = &AuditCheck{Id: id}
if err = o.Read(v); err == nil {
return v, nil
}
return nil, err
}
func GetAuditCheckBy(tpId int64) (v []*AuditCheck, err error) {
sql := `select * from(
select id,(case when pid=0 then id else id end) pid,title,items 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 == orm.ErrNoRows {
err = nil
}
return
}
return
}
... ...
... ... @@ -32,6 +32,7 @@ type AuditFlowProcess struct {
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:"自查内容"`
}
func (t *AuditFlowProcess) TableName() string {
... ... @@ -125,7 +126,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 from audit_flow_process
template_id,self_checks 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
... ...
... ... @@ -35,6 +35,7 @@ type Chance struct {
ApproveTime time.Time `orm:"column(approve_time);type(timestamp)" description:"审批时间"`
Code string `orm:"column(code)" description:"机会编码 一级编码+二级编码"`
Status int8 `orm:"column(status)" description:"状态 1:开启 2:关闭 "`
SelfChecks string `orm:"column(self_checks);size(1000);null" description:"自查内容"`
}
const (
... ... @@ -42,6 +43,10 @@ const (
ChanceStatusClose = 2 //关闭
)
var (
SqlGetChanceSelfChecks = `select self_checks from chance where id =?` //机会自查数据
)
func (t *Chance) TableName() string {
return "chance"
}
... ... @@ -159,7 +164,7 @@ from audit_flow_process where uid=? and review_status in (%v) `, utils.JoinInt8
func GetChanceMyApproveChanceEnable(uid, cid int64, reviewStatus []int8, lastId int64, pageSize int, v interface{}) (total int, err error) {
sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from (
select a.*,b.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.update_at process_create_time from (
select a.*,b.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.update_at process_create_time,b.self_checks from (
select id,approve_time,approve_data,uid,chance_id,approve_message
from audit_flow_process where uid=? and review_status in (%v) and enable_status =1
)a left outer join chance b on a.chance_id = b.id
... ...
package models
import (
"fmt"
"time"
"github.com/astaxie/beego/orm"
)
type ChanceSelfCheck struct {
Id int64 `orm:"column(id);pk" description:"编号"`
UserCompanyId int64 `orm:"column(user_company_id);null" description:"提交人"`
ChanceId int64 `orm:"column(chanceId);null" description:"机会编号"`
RelateId int64 `orm:"column(relateId)" description:"关联编号 机会编号 / 审核流程编号"`
CheckItem string `orm:"column(checkItem);size(50)" description:"检查项"`
GroupId int64 `orm:"column(groupId)" description:"分组编号(audit_check.id/pid)"`
Answer string `orm:"column(answer);size(50);null" description:"回答"`
Reason string `orm:"column(reason);size(200);null" description:"理由"`
CreateAt time.Time `orm:"column(create_at);type(timestamp);null" description:"创建时间"`
UpdateAt time.Time `orm:"column(update_at);type(timestamp);null" description:"更新时间"`
}
func (t *ChanceSelfCheck) TableName() string {
return "chance_self_check"
}
func init() {
orm.RegisterModel(new(ChanceSelfCheck))
}
// AddChanceSelfCheck insert a new ChanceSelfCheck into database and returns
// last inserted Id on success.
func AddChanceSelfCheck(m *ChanceSelfCheck) (id int64, err error) {
o := orm.NewOrm()
id, err = o.Insert(m)
return
}
// GetChanceSelfCheckById retrieves ChanceSelfCheck by Id. Returns error if
// Id doesn't exist
func GetChanceSelfCheckById(id int64) (v *ChanceSelfCheck, err error) {
o := orm.NewOrm()
v = &ChanceSelfCheck{Id: id}
if err = o.Read(v); err == nil {
return v, nil
}
return nil, err
}
// UpdateChanceSelfCheck updates ChanceSelfCheck by Id and returns error if
// the record to be updated doesn't exist
func UpdateChanceSelfCheckById(m *ChanceSelfCheck) (err error) {
o := orm.NewOrm()
v := ChanceSelfCheck{Id: m.Id}
// ascertain id exists in the database
if err = o.Read(&v); err == nil {
var num int64
if num, err = o.Update(m); err == nil {
fmt.Println("Number of records updated in database:", num)
}
}
return
}
... ...
... ... @@ -117,14 +117,15 @@ type ChanceExampleResponse struct {
/*提交机会*/
type ChanceSubmitRequest struct {
Id int64 `json:"id"` // = 0添加 >0 编辑
AuditTemplateId int64 `json:"auditTemplateId" valid:"Required"`
Content string `json:"content"`
FormList []*Form `json:"formList" valid:"Required"`
Speechs []Speech `json:"speechs"`
Pictures []Picture `json:"pictures"`
Videos []Video `json:"videos"`
RelatedDepartment int64 `json:"relatedDepartments" valid:"Required"`
Id int64 `json:"id"` // = 0添加 >0 编辑
AuditTemplateId int64 `json:"auditTemplateId" valid:"Required"`
Content string `json:"content"`
FormList []*Form `json:"formList" valid:"Required"`
SelfChecks SelfChecks `json:"selfChecks"`
Speechs []Speech `json:"speechs"`
Pictures []Picture `json:"pictures"`
Videos []Video `json:"videos"`
RelatedDepartment int64 `json:"relatedDepartments" valid:"Required"`
}
type ChanceSubmitResponse struct {
}
... ... @@ -140,7 +141,8 @@ type ChanceUpdateRequest struct {
Videos []Video `json:"videos"`
RelatedDepartment int64 `json:"relatedDepartments"`
IsPublish bool `json:"isPublish"` //是否重新发布
IsPublish bool `json:"isPublish"` //是否重新发布
SelfChecks SelfChecks `json:"selfChecks"`
}
type ChanceUpdateResponse struct {
}
... ... @@ -236,6 +238,8 @@ type ChanceApproveItemOrm struct {
ApproveUserId int64 `orm:"column(uid)"`
ProcessCreateTime time.Time `orm:"column(process_create_time)"`
ChanceId int64 `orm:"column(chance_id)"` // 机会id
SelfChecks string `orm:"column(self_checks)"`
}
/*MyCollectChance 我的收藏*/
... ... @@ -451,12 +455,13 @@ type ChanceDetail struct {
//模板
type Template struct {
Id int64 `json:"id"`
Name string `json:"name"`
Doc string `json:"doc"`
Icon string `json:"icon"`
FormList []*Form `json:"formList"`
Link string `json:"link"` //示例
Id int64 `json:"id"`
Name string `json:"name"`
Doc string `json:"doc"`
Icon string `json:"icon"`
FormList []*Form `json:"formList"`
Question []*CheckQuestion `json:"question"`
Link string `json:"link"` //示例
}
//表单
... ... @@ -527,6 +532,8 @@ type CommonListItem struct {
ThumbUpData interface{} `json:"thumbUpData,omitempty"` //点赞数据
//我审核的-通过
Score interface{} `json:"score,omitempty"`
//我审核的-待审核
SelfCheckResult interface{} `json:"selfCheckResult,omitempty"` //自查统计数据
//模板
ChanceType interface{} `json:"chanceType,omitempty"` //机会类型
... ... @@ -580,14 +587,16 @@ type ChanceItem struct {
Id int64 `json:"id"`
CreateTime int64 `json:"createTime"`
//CreateTimeCopy int64 `json:"createTimeCopy"`
UpdateTime int64 `json:"updateTime"`
ApproveTime int64 `json:"approveTime"`
Provider *BaseUserInfo `json:"provider"`
FormList []*Form `json:"formList" valid:"Required"`
Speechs []Speech `json:"speechs"`
Pictures []Picture `json:"pictures"`
Videos []Video `json:"videos"`
PublicStatus int `json:"-"` //publicStatus
UpdateTime int64 `json:"updateTime"`
ApproveTime int64 `json:"approveTime"`
Provider *BaseUserInfo `json:"provider"`
FormList []*Form `json:"formList" valid:"Required"`
SelfChecks SelfChecks `json:"selfChecks"`
Speechs []Speech `json:"speechs"`
Pictures []Picture `json:"pictures"`
Videos []Video `json:"videos"`
PublicStatus int `json:"-"` //publicStatus
}
type ChanceData struct {
ThumbsUpTotal int `json:"thumbsupTotal"` //点赞总数
... ...
... ... @@ -24,6 +24,7 @@ type ChanceApproveRequest struct {
ReviewStatus int `json:"reviewStatus"` //protocol.ReviewStatus
//Suggestion string `json:"suggestion"` //原因/建议
ApproveData ApproveData `json:"approveData"` //审核数据
SelfChecks SelfChecks `json:"selfChecks"`
}
type ChanceApproveResponse struct {
}
... ... @@ -66,13 +67,13 @@ type ProcessItem struct {
ApproveType int `json:"approveType"` //审批类型 1 业务区域负责人 2 指定成员 3 角色
ApproveTime int64 `json:"approveTime"` //审核时间
//Role Role `json:"role"` //角色
Uid int64 `json:"uid"`
Name string `json:"name"`
RoleName string `json:"roleName"`
Role int `json:"-"`
ApproveData *ApproveData `json:"approveData"` //审核数据
//ApproveUser UserItem `json:"approveUser"` //审核人 //状态不是审核中
ApproveUsers []UserItem `json:"approveUsers"` //审核人员 //1 会签 2 或签 //审核中 1.部门长 2.角色
Uid int64 `json:"uid"`
Name string `json:"name"`
RoleName string `json:"roleName"`
Role int `json:"-"`
SelfChecks SelfChecks `json:"selfChecks"`
ApproveData *ApproveData `json:"approveData"` //审核数据
ApproveUsers []UserItem `json:"approveUsers"` //审核人员 //1 会签 2 或签 //审核中 1.部门长 2.角色
}
//公开数据
... ...
package protocol
import "strings"
import (
"bytes"
"encoding/json"
"fmt"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
"opp/internal/utils"
"strings"
)
/*机会-自查内容*/
var CheckOptionsCommit = []CheckOption{{Item: "是", NeedOther: false}, {Item: "否", NeedOther: false}, {Item: "不清楚", NeedOther: false}}
//var CheckOptionsApprove = []CheckOption{{Item: "是",NeedOther:false},{Item: "否",NeedOther:true},{Item: "不清楚",NeedOther:false}}
//自查结果列表
type SelfCheckResults []selfCheckResult
type selfCheckResult struct {
CheckItem string `json:"checkItem"`
Total int `json:"total"`
Item string `json:"item"`
Total int `json:"total"`
}
//自查项列表
type SelfChecks []SelfCheck
type SelfCheck struct {
Id int64 `json:"id"`
CheckItem string `json:"checkItem"`
GroupId int64 `json:"groupId"` //分组
Answer string `json:"answer,omitempty"`
Reason string `json:"reason,omitempty"`
Group int `json:"group"` //分组
}
func (c SelfCheck) Key() string {
return fmt.Sprintf("%v-%v", c.GroupId, c.CheckItem)
}
func NewSelfChecks(data string) (rsp SelfChecks) {
if len(data) == 0 {
return
}
e := json.Unmarshal([]byte(data), &rsp)
if e != nil {
log.Error(e)
}
return
}
//统计自查结果
func (s SelfChecks) Static() SelfCheckResults {
results := []selfCheckResult{{CheckItem: "是"}, {CheckItem: "否"}, {CheckItem: "不清楚"}}
if len(s) == 0 {
return []selfCheckResult{}
}
results := []selfCheckResult{{Item: "是"}, {Item: "否"}, {Item: "不清楚"}}
for i := range s {
check := (s)[i]
for k := range results {
if strings.EqualFold(results[k].CheckItem, check.CheckItem) {
if strings.EqualFold(results[k].Item, check.Answer) {
results[k].Total = results[k].Total + 1
break
}
... ... @@ -35,3 +61,104 @@ func (s SelfChecks) Static() SelfCheckResults {
}
return SelfCheckResults(results)
}
//自查校验
func (s SelfChecks) Valid() (err error) {
if len(s) == 0 {
return
}
for i := range s {
c := s[i]
if c.GroupId == 0 {
err = NewErrWithMessage(2)
return
}
if len(c.CheckItem) == 0 {
err = NewErrWithMessage(2)
return
}
if len(c.Answer) == 0 {
err = NewCustomMessage(2, "自查项未填写")
return
}
}
return
}
//自查内容
func (s SelfChecks) String() string {
var buf bytes.Buffer
for i := range s {
c := s[i]
if len(c.Reason) == 0 {
buf.WriteString(fmt.Sprintf("%v:%v;\n", c.CheckItem, c.Answer))
} else {
buf.WriteString(fmt.Sprintf("%v:%v,理由:%v;\n", c.CheckItem, c.Answer, c.Reason))
}
}
return buf.String()
}
func (s SelfChecks) Compare(dst string) (rspChecks SelfChecks, err error) {
var (
dstChecks SelfChecks
mapChecks = make(map[string]SelfCheck)
)
rspChecks = make([]SelfCheck, 0)
if len(s) == 0 {
return
}
utils.JsonUnmarshal(dst, &dstChecks)
if len(s) != len(dstChecks) {
err = NewCustomMessage(1, "自查项有误")
log.Error(err, s, dstChecks)
return
}
for i := range dstChecks {
c := dstChecks[i]
mapChecks[c.Key()] = c
}
for i := range s {
c := s[i]
if v, ok := mapChecks[c.Key()]; ok {
//回答不一直
if !strings.EqualFold(c.Answer, v.Answer) {
rspChecks = append(rspChecks, c)
continue
}
if len(c.Reason) > 0 {
rspChecks = append(rspChecks, c)
continue
}
}
}
return
}
//自查问题
type CheckQuestion struct {
CheckItem string `json:"checkItem"`
Title string `json:"title"`
GroupId int64 `json:"groupId"`
CheckOptions []CheckOption `json:"options"`
}
type CheckOption struct {
Item string `json:"item"`
NeedOther bool `json:"needOther"` //是否需填写其他的内容【1:需要】【2:不需要】
}
func NewCheckQuestion(checkItem, title string, groupId int64, ops []CheckOption) *CheckQuestion {
return &CheckQuestion{
CheckItem: checkItem,
Title: title,
GroupId: groupId,
CheckOptions: ops,
}
}
/*CheckQuestions 自查问题列表*/
type CheckQuestionsRequest struct {
ChanceId int64 `json:"chanceId" valid:"Required"`
}
type CheckQuestionsResponse struct {
Questions []*CheckQuestion `json:"questions"`
}
... ...
... ... @@ -61,9 +61,9 @@ func init() {
var ApproveLog = map[int]string{
1: "提交了机会", //提交人提交机会
2: "删除了机会", //提交人删除机会
3: "退回了机会", //审批人退回机会
4: "通过了机会;基础评分:%v分,附加评分:%v分,价值评分:%v分,公开状态:公司公开", //审批人通过机会(公司公开)
5: "通过了机会;基础评分:%v分,附加评分:%v分,价值评分:%v分,公开状态:%v", //审批人通过机会(部门公开) 测试部、销售部
3: "退回了机会;\n%v", //审批人退回机会
4: "通过了机会;\n%v\n基础评分:%v分,附加评分:%v分,价值评分:%v分,公开状态:公司公开", //审批人通过机会(公司公开)
5: "通过了机会;\n%v\n基础评分:%v分,附加评分:%v分,价值评分:%v分,公开状态:%v", //审批人通过机会(部门公开) 测试部、销售部
6: "系统 自动通过了机会;基础评分:%v分,附加评分:%v分,价值评分:%v分,公开状态:公司公开", //审批人通过了机会(系统自动通过)
7: "修改了公开状态:公司公开", //审批通过后修改公开状态(公司公开)
8: "修改了公开状态:%v", //审批通过后修改公开状态(部门公开)
... ...
package agg
import (
"encoding/json"
"fmt"
"github.com/astaxie/beego/orm"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
"opp/internal/utils"
"opp/models"
... ... @@ -233,3 +235,79 @@ func SetMsgItem(header *protocol.RequestHeader, msg protocol.MsgItemOrm, commIte
commItem.SourceId = msg.SourceId
commItem.SourceType = msg.SourceType
}
//获取自查问题列表 通过模板
func GetCheckQuestionsByTemplateId(id int64) (rsp []*protocol.CheckQuestion, err error) {
var (
checks []*models.AuditCheck
)
rsp = make([]*protocol.CheckQuestion, 0)
if checks, err = models.GetAuditCheckBy(id); err != nil {
log.Error(err)
return
}
if len(checks) == 0 {
return
}
var tmpGroupId int64
var idx int = 0
var groupIdx = 0
for i := range checks {
c := checks[i]
if tmpGroupId != c.Pid {
groupIdx++
idx = 0
}
tmpGroupId = c.Pid
item := protocol.NewCheckQuestion(c.Title, getQuestionTitle(groupIdx, idx, c.Title), c.Pid, protocol.CheckOptionsCommit)
rsp = append(rsp, item)
idx++
}
return
}
//获取自查问题列表 通过机会(历史模板)
func GetCheckQuestionsByChanceId(id int64) (rsp []*protocol.CheckQuestion, err error) {
var (
chance *models.Chance
selfChecks protocol.SelfChecks
)
rsp = make([]*protocol.CheckQuestion, 0)
if err = utils.ExecuteQueryOne(&chance, models.SqlGetChanceSelfChecks, id); err != nil {
if err == orm.ErrNoRows {
err = nil
return
}
log.Error(err)
return
}
if len(chance.SelfChecks) == 0 {
return
}
if e := json.Unmarshal([]byte(chance.SelfChecks), &selfChecks); e != nil {
log.Error(e)
return
}
var tmpGroupId int64
var idx int = 0
var groupIdx = 0
for i := range selfChecks {
c := selfChecks[i]
if tmpGroupId != c.GroupId {
groupIdx++
idx = 0
}
item := protocol.NewCheckQuestion(c.CheckItem, getQuestionTitle(groupIdx, idx, c.CheckItem), c.GroupId, protocol.CheckOptionsCommit)
rsp = append(rsp, item)
idx++
}
return
}
func getQuestionTitle(groupIdx int, idx int, title string) string {
if idx == 0 {
return fmt.Sprintf("%v、%v?", groupIdx, title)
}
return fmt.Sprintf("%v.%v、%v?", groupIdx, idx, title)
}
... ...
... ... @@ -276,6 +276,7 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro
mapProcess = make(map[string]interface{})
mapChance = make(map[string]interface{})
result *protocol.ChanceCalculateScoreResponse
difChecks protocol.SelfChecks
)
rsp = &protocol.ChanceApproveResponse{}
//TODO:测试注入
... ... @@ -308,6 +309,7 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro
err = protocol.NewErrWithMessage(5202)
return
}
difChecks, _ = request.SelfChecks.Compare(chance.SelfChecks)
{
if request.ReviewStatus == protocol.ReviewStatusPass {
//计算发现分
... ... @@ -325,6 +327,7 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro
mapProcess["ApproveTime"] = time.Now()
mapProcess["IsActive"] = int8(0)
mapProcess["UpdateAt"] = time.Now()
mapProcess["SelfChecks"] = common.AssertJson(difChecks)
mapChance["ApproveTime"] = time.Now()
mapChance["BasicScore"] = request.ApproveData.Score.BasicScore
... ... @@ -341,13 +344,7 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro
mapProcess["DiscoveryScore"] = request.ApproveData.Score.DiscoveryScore
mapProcess["ApproveData"] = common.AssertJson(request.ApproveData)
mapProcess["EnableStatus"] = int8(1)
//mapChance["BasicScore"] = request.ApproveData.Score.BasicScore
//mapChance["ExtraScore"] = request.ApproveData.Score.ExtraScore
//mapChance["ValueScore"] = request.ApproveData.Score.ValueScore
//mapChance["DiscoveryScore"] = request.ApproveData.Score.DiscoveryScore
//mapChance["ApproveData"] = common.AssertJson(request.ApproveData)
//mapChance["PublishStatus"] = request.ApproveData.PublicData.PublishStatus
mapChance["SelfChecks"] = common.AssertJson(request.SelfChecks)
}
}
log.Info(fmt.Sprintf("用户:%v 提交审核 机会编号:%v 审批流编号:%v 审批状态:%v", header.UserId, chance.Id, process.Id, request.ReviewStatus))
... ... @@ -384,16 +381,6 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro
{
mapChance["ReviewStatus"] = int8(request.ReviewStatus)
}
//发送审核结果消息给提交人
//for i := range approveItemResponse.MessageData.ApplyUserMessage {
// message := approveItemResponse.MessageData.ApplyUserMessage[i]
// nextApprovers = append(nextApprovers, message.ReceiverInfo.ReceiverUid)
// if err = agg.SendApprovedMsg(message.ReceiverInfo.ReceiverUid, message.ReceiverInfo.ReceiverName,
// header.CompanyId, chance.Id, chance.ChanceTypeId, request.ReviewStatus, protocol.MsgTypeAuditBy); err != nil {
// log.Error(err)
// return
// }
//}
} else {
//发送下一个消息给下一流程的审核人
for i := range approveItemResponse.MessageData.ApproveMessage {
... ... @@ -423,7 +410,7 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro
}
}
}
if err = saveApproveMsgByApproveData(header, orm, request.ReviewStatus, chance, request.ApproveData); err != nil {
if err = saveApproveMsgByApproveData(header, orm, request.ReviewStatus, chance, request.ApproveData, difChecks); err != nil {
orm.Rollback()
log.Error("发送审核日志失败", err)
return
... ... @@ -486,7 +473,7 @@ func ProcessIntegrate(header *protocol.RequestHeader, request *ProcessIntegrateR
}
//发送审核日志
func saveApproveMsgByApproveData(header *protocol.RequestHeader, orm orm.Ormer, reviewStatus int, chance *models.Chance, approveData protocol.ApproveData) (err error) {
func saveApproveMsgByApproveData(header *protocol.RequestHeader, orm orm.Ormer, reviewStatus int, chance *models.Chance, approveData protocol.ApproveData, selfChecks protocol.SelfChecks) (err error) {
var (
parames = make([]interface{}, 0)
code = 0
... ... @@ -494,11 +481,12 @@ func saveApproveMsgByApproveData(header *protocol.RequestHeader, orm orm.Ormer,
if reviewStatus == protocol.ReviewStatusReturn {
//发送退回日志
code = 3
parames = append(parames, selfChecks.String())
}
if reviewStatus == protocol.ReviewStatusPass {
//发送通过日志
score := approveData.Score
parames = append(parames, []interface{}{score.BasicScore, score.ExtraScore, score.ValueScore}...)
parames = append(parames, []interface{}{selfChecks.String(), score.BasicScore, score.ExtraScore, score.ValueScore}...)
if approveData.PublicData.PublishStatus == protocol.PublicToCompany {
code = 4
}
... ... @@ -561,6 +549,7 @@ func ChanceApproveProcess(header *protocol.RequestHeader, chance *models.Chance)
Uid: process.Uid,
Name: process.UserName,
}
utils.JsonUnmarshal(process.SelfChecks, &item.SelfChecks)
if item.ApproveType == protocol.AuditBySpecailUser {
item.ApproveType = protocol.AuditByUser
}
... ...
... ... @@ -292,6 +292,10 @@ func Template(header *protocol.RequestHeader, request *protocol.TemplateRequest)
if len(item.Example) > 0 {
template.Link = fmt.Sprintf("%v/#/ability/opportunity?id=%v", beego.AppConfig.String("h5_host"), item.Id)
}
if template.Question, err = agg.GetCheckQuestionsByTemplateId(templates.Id); err != nil {
log.Error(err)
return
}
for j := range forms {
form := forms[j]
template.FormList[j] = &protocol.Form{
... ... @@ -395,6 +399,7 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit
DepartmentId: request.RelatedDepartment,
Code: fmt.Sprintf("%v%v", chanceType.Code, template.Code),
Status: models.ChanceStatusOpen,
SelfChecks: common.AssertJson(request.SelfChecks),
}
//生成提交记录
if _, err = orm.Insert(GenAuditFlowProcess_Submit(header.UserId, chance.Id, template.Id, protocol.ReviewStatusSubmit)); err != nil {
... ... @@ -591,13 +596,13 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceUpdate
//6.更新文件
{
if chanceData, err = models.GetChanceDataByChanceId(chance.Id); err == nil {
if err = utils.UpdateTableByMapWithOrmer(orm, chanceData, map[string]interface{}{
chanceDataMap := map[string]interface{}{
"Speechs": common.AssertJson(request.Speechs),
"Images": common.AssertJson(request.Pictures),
"Videos": common.AssertJson(request.Videos),
"UpdateAt": time.Now(),
}); err != nil {
}
if err = utils.UpdateTableByMapWithOrmer(orm, chanceData, chanceDataMap); err != nil {
log.Error(err)
orm.Rollback()
return
... ... @@ -700,6 +705,7 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceUpdate
//机会发布 并且当前机会不是已经通过的,机会状态审核中(存在更新时自动通过)
if request.IsPublish && chance.ReviewStatus != protocol.ReviewStatusPass {
updateMap["ReviewStatus"] = int8(protocol.ReviewStatusAuditging)
updateMap["SelfChecks"] = common.AssertJson(request.SelfChecks)
}
updateMap["AuditTemplateConfig"] = common.AssertJson(auditConfig)
updateMap["Content"] = request.Content
... ... @@ -1655,7 +1661,6 @@ func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApprove
commItem.ChanceStatus = protocol.ChanceStatusDelete
log.Error(chance.ChanceUserId, header.CompanyId, err)
err = nil
//return
} else {
item := protocol.ChanceItem{
Id: chance.ChanceId,
... ... @@ -1663,8 +1668,6 @@ func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApprove
CreateTime: chance.CreateTime.Unix() * 1000,
UpdateTime: chance.UpdateTime.Unix() * 1000,
ApproveTime: chance.ChanceApproveTime.Unix() * 1000,
//CreateTime:chance.c
//CreateTime: chance.CreateTime.Unix() * 1000,
}
if item.ApproveTime < 0 {
item.ApproveTime = chance.UpdateTime.Unix() * 1000
... ... @@ -1678,8 +1681,7 @@ func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApprove
}
}
approve := protocol.Approve{
ProcessId: chance.Id,
//Provider:provider,
ProcessId: chance.Id,
CreateTime: chance.ProcessCreateTime.Unix() * 1000,
}
//审核过的才有审核时间
... ... @@ -1701,6 +1703,7 @@ func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApprove
commItem.Score = approveData.Score
}
}
commItem.SelfCheckResult = protocol.NewSelfChecks(chance.SelfChecks).Static()
rsp.List = append(rsp.List, commItem)
}
return
... ... @@ -2084,6 +2087,7 @@ func ChanceDetail(header *protocol.RequestHeader, request *protocol.ChanceDetail
UpdateTime: chance.UpdateAt.Unix() * 1000,
}
jsonUnmarshal(chance.SourceContent, &item.FormList)
jsonUnmarshal(chance.SelfChecks, &item.SelfChecks)
item.FormList = clearEmptyForm(item.FormList)
if chanceData, err = models.GetChanceDataByChanceId(chance.Id); err == nil {
... ... @@ -2324,3 +2328,14 @@ func ChanceReviseDetail(header *protocol.RequestHeader, request *protocol.Chance
rsp.ChanceId = detail.ChanceId
return
}
//自查问题列表
func CheckQuestions(header *protocol.RequestHeader, request *protocol.CheckQuestionsRequest) (rsp *protocol.CheckQuestionsResponse, err error) {
var ()
rsp = &protocol.CheckQuestionsResponse{}
rsp.Questions, err = agg.GetCheckQuestionsByChanceId(request.ChanceId)
if err != nil {
log.Error(err)
}
return
}
... ...