作者 yangfu

自查修改

... ... @@ -12,7 +12,6 @@ import (
/*机会-自查内容*/
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 {
... ... @@ -21,7 +20,19 @@ type selfCheckResult struct {
}
//自查项列表
func NewSelfChecks(data string) (rsp SelfChecks) {
if len(data) == 0 {
return
}
e := json.Unmarshal([]byte(data), &rsp)
if e != nil {
log.Error(e)
}
return
}
type SelfChecks []SelfCheck
type SelfCheck struct {
CheckItem string `json:"checkItem"`
GroupId int64 `json:"groupId"` //分组
... ... @@ -33,17 +44,6 @@ 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 {
if len(s) == 0 {
... ... @@ -91,9 +91,9 @@ func (s SelfChecks) String() string {
for i := range s {
c := s[i]
if len(c.Reason) == 0 {
buf.WriteString(fmt.Sprintf("%v:%v;\n", c.CheckItem, c.Answer))
buf.WriteString(fmt.Sprintf("\n%v:%v;", c.CheckItem, c.Answer))
} else {
buf.WriteString(fmt.Sprintf("%v:%v,理由:%v;\n", c.CheckItem, c.Answer, c.Reason))
buf.WriteString(fmt.Sprintf("\n%v:%v,理由:%v;", c.CheckItem, c.Answer, c.Reason))
}
}
return buf.String()
... ... @@ -135,6 +135,15 @@ func (s SelfChecks) Compare(dst string) (rspChecks SelfChecks, err error) {
}
//自查问题
func NewCheckQuestion(checkItem, title string, groupId int64, ops []CheckOption) *CheckQuestion {
return &CheckQuestion{
CheckItem: checkItem,
Title: title,
GroupId: groupId,
CheckOptions: ops,
}
}
type CheckQuestion struct {
CheckItem string `json:"checkItem"`
Title string `json:"title"`
... ... @@ -143,16 +152,7 @@ type CheckQuestion struct {
}
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,
}
NeedOther bool `json:"-"` //是否需填写其他的内容【1:需要】【2:不需要】
}
/*CheckQuestions 自查问题列表*/
... ...
... ... @@ -61,9 +61,9 @@ func init() {
var ApproveLog = map[int]string{
1: "提交了机会", //提交人提交机会
2: "删除了机会", //提交人删除机会
3: "退回了机会;\n%v", //审批人退回机会
4: "通过了机会;\n%v\n基础评分:%v分,附加评分:%v分,价值评分:%v分,公开状态:公司公开", //审批人通过机会(公司公开)
5: "通过了机会;\n%v\n基础评分:%v分,附加评分:%v分,价值评分:%v分,公开状态:%v", //审批人通过机会(部门公开) 测试部、销售部
3: "退回了机会;%v", //审批人退回机会
4: "通过了机会;%v\n基础评分:%v分,附加评分:%v分,价值评分:%v分,公开状态:公司公开", //审批人通过机会(公司公开)
5: "通过了机会;%v\n基础评分:%v分,附加评分:%v分,价值评分:%v分,公开状态:%v", //审批人通过机会(部门公开) 测试部、销售部
6: "系统 自动通过了机会;基础评分:%v分,附加评分:%v分,价值评分:%v分,公开状态:公司公开", //审批人通过了机会(系统自动通过)
7: "修改了公开状态:公司公开", //审批通过后修改公开状态(公司公开)
8: "修改了公开状态:%v", //审批通过后修改公开状态(部门公开)
... ...
... ... @@ -4,10 +4,12 @@ import (
"encoding/json"
"fmt"
"github.com/astaxie/beego/orm"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/identity/idgen"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
"opp/internal/utils"
"opp/models"
"opp/protocol"
"time"
)
//机会池
... ... @@ -227,7 +229,6 @@ func SetChanceItem(header *protocol.RequestHeader, chance protocol.CommChanceIte
utils.JsonUnmarshal(chance.Videos, &item.Videos)
return item, chanceStatus
}
func SetMsgItem(header *protocol.RequestHeader, msg protocol.MsgItemOrm, commItem *protocol.MsgCommonListItem) {
commItem.MsgId = msg.MsgId
commItem.MsgTime = msg.MsgTime.Unix() * 1000
... ... @@ -304,10 +305,62 @@ func GetCheckQuestionsByChanceId(id int64) (rsp []*protocol.CheckQuestion, err e
}
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)
}
//自查问题回答批量入库
func BulkInsertSelfChecks(header *protocol.RequestHeader, relateId, chanceId int64, selfChecks protocol.SelfChecks) {
defer func() {
if p := recover(); p != nil {
log.Warn(p)
}
}()
var (
count int
err error
Exists = `select count(0) from chance_self_check where chanceId=? and relateId=?`
DeleteExistedRow = `update chance_self_check set enable=0 where chanceId=? and relateId=?`
)
if len(selfChecks) == 0 {
return
}
o := orm.NewOrm()
o.Begin()
if err = utils.ExecuteQueryOneWithOrmer(o, &count, Exists, relateId, chanceId); err != nil {
log.Error(err)
o.Rollback()
return
}
if count > 0 {
if err = utils.ExecuteSQLWithOrmer(o, DeleteExistedRow, relateId, chanceId); err != nil {
log.Error(err)
o.Rollback()
return
}
}
for i := range selfChecks {
check := selfChecks[i]
m := models.ChanceSelfCheck{
Id: idgen.Next(),
UserCompanyId: header.UserId,
ChanceId: chanceId,
RelateId: relateId,
CheckItem: check.CheckItem,
GroupId: check.GroupId,
Answer: check.Answer,
Reason: check.Reason,
CreateAt: time.Now(),
}
if _, err = o.Insert(m); err != nil {
log.Error(err)
o.Rollback()
return
}
}
o.Commit()
}
... ...