作者 yangfu

部门统计修改

@@ -657,9 +657,14 @@ func ExitsChanceByAuditUser(chanceId int64, auditUserId int64) (v *Chance, err e @@ -657,9 +657,14 @@ func ExitsChanceByAuditUser(chanceId int64, auditUserId int64) (v *Chance, err e
657 return 657 return
658 } 658 }
659 659
660 -//是否存在发布机会的部门编号查询 660 +//机会统计-按部门
  661 +//@departmentIds 按部门编号查询
661 func GetChanceStatisticByDepartment(companyId int64, departmentIds []int, reviewStatus int) (v int, err error) { 662 func GetChanceStatisticByDepartment(companyId int64, departmentIds []int, reviewStatus int) (v int, err error) {
662 - sql := fmt.Sprintf(`select count(0) from chance where company_id=%v and review_status=%v and department_id in (%v)`, 663 + sql := fmt.Sprintf(`select count(0) from chance where company_id=%v
  664 +and review_status=%v
  665 +and status=1
  666 +and enable_status=1
  667 +and department_id in (%v)`,
663 companyId, reviewStatus, utils.JoinInts(departmentIds, ",")) 668 companyId, reviewStatus, utils.JoinInts(departmentIds, ","))
664 o := orm.NewOrm() 669 o := orm.NewOrm()
665 if err = o.Raw(sql).QueryRow(&v); err != nil { 670 if err = o.Raw(sql).QueryRow(&v); err != nil {
@@ -717,6 +717,7 @@ func CheckChanceDifferent(header *protocol.RequestHeader, chance *models.Chance, @@ -717,6 +717,7 @@ func CheckChanceDifferent(header *protocol.RequestHeader, chance *models.Chance,
717 isSaveLog bool = false 717 isSaveLog bool = false
718 chanceReviseLog *models.ChanceReviseLog 718 chanceReviseLog *models.ChanceReviseLog
719 message string 719 message string
  720 + changeCount int
720 ) 721 )
721 defer func() { 722 defer func() {
722 if p := recover(); p != nil { 723 if p := recover(); p != nil {
@@ -799,18 +800,25 @@ func CheckChanceDifferent(header *protocol.RequestHeader, chance *models.Chance, @@ -799,18 +800,25 @@ func CheckChanceDifferent(header *protocol.RequestHeader, chance *models.Chance,
799 diffFormList(chance.SourceContent, request.FormList) 800 diffFormList(chance.SourceContent, request.FormList)
800 diffChanceData() 801 diffChanceData()
801 checkModifyLog := func() { 802 checkModifyLog := func() {
  803 + changeCount += len(modifyLog.Speechs)
802 if len(modifyLog.Speechs) == 0 { 804 if len(modifyLog.Speechs) == 0 {
803 modifyLog.Speechs = make([]protocol.Speech, 0) 805 modifyLog.Speechs = make([]protocol.Speech, 0)
804 } 806 }
  807 + changeCount += len(modifyLog.Pictures)
805 if len(modifyLog.Pictures) == 0 { 808 if len(modifyLog.Pictures) == 0 {
806 modifyLog.Pictures = make([]protocol.Picture, 0) 809 modifyLog.Pictures = make([]protocol.Picture, 0)
807 } 810 }
  811 + changeCount += len(modifyLog.Videos)
808 if len(modifyLog.Videos) == 0 { 812 if len(modifyLog.Videos) == 0 {
809 modifyLog.Videos = make([]protocol.Video, 0) 813 modifyLog.Videos = make([]protocol.Video, 0)
810 } 814 }
  815 + changeCount += len(modifyLog.DiffContents)
  816 + if len(modifyLog.DiffContents) == 0 {
  817 + modifyLog.DiffContents = make([]protocol.ReviseContent, 0)
  818 + }
811 } 819 }
812 checkModifyLog() 820 checkModifyLog()
813 - if isSaveLog { 821 + if isSaveLog && changeCount > 0 {
814 orm := orm.NewOrm() 822 orm := orm.NewOrm()
815 orm.Begin() 823 orm.Begin()
816 var logId int64 824 var logId int64
@@ -850,7 +858,6 @@ func CheckChanceDifferent(header *protocol.RequestHeader, chance *models.Chance, @@ -850,7 +858,6 @@ func CheckChanceDifferent(header *protocol.RequestHeader, chance *models.Chance,
850 return 858 return
851 } 859 }
852 860
853 - //TODO:保存变更日志  
854 orm.Commit() 861 orm.Commit()
855 } 862 }
856 } 863 }