作者 yangfu

部门统计修改

... ... @@ -657,9 +657,14 @@ func ExitsChanceByAuditUser(chanceId int64, auditUserId int64) (v *Chance, err e
return
}
//是否存在发布机会的部门编号查询
//机会统计-按部门
//@departmentIds 按部门编号查询
func GetChanceStatisticByDepartment(companyId int64, departmentIds []int, reviewStatus int) (v int, err error) {
sql := fmt.Sprintf(`select count(0) from chance where company_id=%v and review_status=%v and department_id in (%v)`,
sql := fmt.Sprintf(`select count(0) from chance where company_id=%v
and review_status=%v
and status=1
and enable_status=1
and department_id in (%v)`,
companyId, reviewStatus, utils.JoinInts(departmentIds, ","))
o := orm.NewOrm()
if err = o.Raw(sql).QueryRow(&v); err != nil {
... ...
... ... @@ -717,6 +717,7 @@ func CheckChanceDifferent(header *protocol.RequestHeader, chance *models.Chance,
isSaveLog bool = false
chanceReviseLog *models.ChanceReviseLog
message string
changeCount int
)
defer func() {
if p := recover(); p != nil {
... ... @@ -799,18 +800,25 @@ func CheckChanceDifferent(header *protocol.RequestHeader, chance *models.Chance,
diffFormList(chance.SourceContent, request.FormList)
diffChanceData()
checkModifyLog := func() {
changeCount += len(modifyLog.Speechs)
if len(modifyLog.Speechs) == 0 {
modifyLog.Speechs = make([]protocol.Speech, 0)
}
changeCount += len(modifyLog.Pictures)
if len(modifyLog.Pictures) == 0 {
modifyLog.Pictures = make([]protocol.Picture, 0)
}
changeCount += len(modifyLog.Videos)
if len(modifyLog.Videos) == 0 {
modifyLog.Videos = make([]protocol.Video, 0)
}
changeCount += len(modifyLog.DiffContents)
if len(modifyLog.DiffContents) == 0 {
modifyLog.DiffContents = make([]protocol.ReviseContent, 0)
}
}
checkModifyLog()
if isSaveLog {
if isSaveLog && changeCount > 0 {
orm := orm.NewOrm()
orm.Begin()
var logId int64
... ... @@ -850,7 +858,6 @@ func CheckChanceDifferent(header *protocol.RequestHeader, chance *models.Chance,
return
}
//TODO:保存变更日志
orm.Commit()
}
}
... ...