You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
726 lines
29 KiB
726 lines
29 KiB
package quan
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"strconv"
|
|
"strings"
|
|
"time"
|
|
|
|
"gin_server_admin/api/wechatapp/sendmessage"
|
|
"gin_server_admin/commonus"
|
|
"gin_server_admin/global"
|
|
"gin_server_admin/model/assessmentmodel"
|
|
"gin_server_admin/model/common/response"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func (a *ApiGroup) SendRationFlowYuan(c *gin.Context) {
|
|
isTrue, userCont := commonus.ClientIdentity()
|
|
if isTrue != true {
|
|
response.Result(1001, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c)
|
|
return
|
|
}
|
|
userKey, userKeyErr := strconv.ParseInt(userCont.Key, 10, 64)
|
|
if userKeyErr != nil {
|
|
response.Result(102, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c)
|
|
return
|
|
}
|
|
departmentId, departmentIdErr := strconv.ParseInt(userCont.Deparment, 10, 64)
|
|
if departmentIdErr != nil {
|
|
response.Result(103, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c)
|
|
return
|
|
}
|
|
userGroup, userGroupErr := strconv.ParseInt(userCont.Company, 10, 64)
|
|
if userGroupErr != nil {
|
|
response.Result(104, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c)
|
|
return
|
|
}
|
|
|
|
todaying := commonus.ComputingTime(time.Now().Unix(), 5)
|
|
|
|
if todaying > 10 {
|
|
// response.Result(1051, todaying, "不在可提交数据提时间期限内!不可提交数据。请每月10号前提交数据!。", c)
|
|
// return
|
|
}
|
|
|
|
var requestData AddRationFlowLog
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
response.Result(105, err, "数据获取失败!", c)
|
|
return
|
|
}
|
|
if requestData.GroupId == "" {
|
|
response.Result(106, err, "数据异常!", c)
|
|
return
|
|
}
|
|
if requestData.DepartmentID == "" {
|
|
response.Result(107, err, "数据异常!", c)
|
|
return
|
|
}
|
|
if len(requestData.List) < 1 {
|
|
response.Result(108, err, "没有要考核的项目", c)
|
|
return
|
|
}
|
|
|
|
//判断是否已经添加的条件
|
|
existenceProess := commonus.MapOut()
|
|
existenceProess["fl_planversion"] = requestData.PlanVersionNumber
|
|
|
|
operationTime := time.Now().Unix()
|
|
keyNumber := commonus.GetFileNumberEs()
|
|
var flowLog assessmentmodel.FlowLog
|
|
|
|
flowLog.Key = keyNumber
|
|
flowLog.Time = time.Now().Unix()
|
|
flowLog.EiteTime = time.Now().Unix()
|
|
flowLog.PlanVersion = requestData.PlanVersionNumber
|
|
if requestData.Addtime != "" {
|
|
timeOccurrence := commonus.DateToTimeStamp(requestData.Addtime) //发生时间
|
|
flowLog.Year = commonus.ComputingTime(timeOccurrence, 1)
|
|
flowLog.Quarter = commonus.ComputingTime(timeOccurrence, 2)
|
|
flowLog.Month = commonus.ComputingTime(timeOccurrence, 3)
|
|
flowLog.Week = commonus.ComputingTime(timeOccurrence, 4)
|
|
flowLog.ToDay = commonus.ComputingTime(timeOccurrence, 5)
|
|
|
|
existenceProess["fl_year"] = commonus.ComputingTime(timeOccurrence, 1)
|
|
existenceProess["fl_quarter"] = commonus.ComputingTime(timeOccurrence, 2)
|
|
existenceProess["fl_month"] = commonus.ComputingTime(timeOccurrence, 3)
|
|
existenceProess["fl_week"] = commonus.ComputingTime(timeOccurrence, 4)
|
|
existenceProess["fl_day"] = commonus.ComputingTime(timeOccurrence, 5)
|
|
|
|
} else {
|
|
lastMonth, _, _ := commonus.GetLastMonth()
|
|
|
|
lastMonthInt, lastMonthErr := commonus.DateToTimeStampEs(fmt.Sprintf("%v-10 12:00:00", lastMonth))
|
|
if lastMonthErr == true {
|
|
operationTime = lastMonthInt
|
|
}
|
|
flowLog.Year = commonus.ComputingTime(operationTime, 1)
|
|
flowLog.Quarter = commonus.ComputingTime(operationTime, 2)
|
|
flowLog.Month = commonus.ComputingTime(operationTime, 3)
|
|
flowLog.Week = commonus.ComputingTime(operationTime, 4)
|
|
flowLog.ToDay = commonus.ComputingTime(operationTime, 5)
|
|
|
|
existenceProess["fl_year"] = commonus.ComputingTime(operationTime, 1)
|
|
existenceProess["fl_quarter"] = commonus.ComputingTime(operationTime, 2)
|
|
existenceProess["fl_month"] = commonus.ComputingTime(operationTime, 3)
|
|
existenceProess["fl_week"] = commonus.ComputingTime(operationTime, 4)
|
|
existenceProess["fl_day"] = commonus.ComputingTime(operationTime, 5)
|
|
}
|
|
|
|
flowLog.EvaluationDepartment = departmentId
|
|
flowLog.EvaluationUser = userKey
|
|
flowLog.EvaluationGroup = userGroup
|
|
|
|
// existenceProess["fl_evaluation_department"] = departmentId
|
|
// existenceProess["fl_evaluation_user"] = userKey
|
|
// existenceProess["fl_evaluation_group"] = userGroup
|
|
|
|
dutyGroup, dutyGroupErr := strconv.ParseInt(requestData.GroupId, 10, 64)
|
|
if dutyGroupErr == nil {
|
|
flowLog.DutyGroup = dutyGroup
|
|
existenceProess["fl_duty_group"] = dutyGroup
|
|
}
|
|
departIdInt, departIdIntErr := strconv.ParseInt(requestData.DepartmentID, 10, 64)
|
|
if departIdIntErr == nil {
|
|
flowLog.DutyDepartment = departIdInt
|
|
existenceProess["fl_duty_department"] = departIdInt
|
|
}
|
|
flowLog.Reply = 2
|
|
var evaluationIdStr string
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.FlowLog{}).Select("fl_evaluation_id").Where(existenceProess).First(&evaluationIdStr)
|
|
var evaluationIdStrAry []string
|
|
if evaluationIdStr != "" {
|
|
evaluationIdStrAry = strings.Split(evaluationIdStr, ",")
|
|
}
|
|
|
|
var flowDataLogAry []assessmentmodel.FlowLogData
|
|
var reason string
|
|
var evaluationPlan []string //方案ID
|
|
var yiTianJianMingc []string
|
|
// jsonMapStr, _ := json.Marshal(requestData.List)
|
|
json.Marshal(requestData.List)
|
|
//fmt.Printf("OutJsonMap-----1------>%\n", string(jsonMapStr))
|
|
for i, v := range requestData.List {
|
|
|
|
if len(evaluationIdStrAry) > 0 {
|
|
if commonus.IsItTrueString(v.Id, evaluationIdStrAry) == false {
|
|
var flowDataLog assessmentmodel.FlowLogData
|
|
evaluationPlan = append(evaluationPlan, v.Id)
|
|
evaluationPlanid, evaluationPlanidErr := strconv.ParseInt(v.Id, 10, 64)
|
|
if evaluationPlanidErr == nil {
|
|
flowDataLog.EvaluationPlan = evaluationPlanid
|
|
}
|
|
flowDataLog.Key = keyNumber
|
|
flowDataLog.Score = commonus.GetDuyCycle(v.Actual, 100)
|
|
flowDataLog.Content = v.Reason
|
|
flowDataLog.Enclosure = strings.Join(v.Enclosure, ",")
|
|
if v.ScoringMethod == 2 {
|
|
flowDataLog.ScoringMethod = 2
|
|
flowDataLog.ScoringScore = v.ScoringScore
|
|
} else {
|
|
flowDataLog.ScoringMethod = 1
|
|
flowDataLog.ScoringScore = 0
|
|
}
|
|
// flowDataLog.PlanVersion = v.PlanVersionNumber
|
|
flowDataLog.Time = time.Now().Unix()
|
|
targetInfo, targetInfoErr := commonus.GetQualitativeEvaluation(strconv.FormatInt(evaluationPlanid, 10))
|
|
tarInfo, _ := commonus.GetTargetInfo(targetInfo.Target)
|
|
if i == 0 {
|
|
if targetInfoErr == true {
|
|
if v.Reason != "" {
|
|
reason = fmt.Sprintf("%v :%v%v\n备注:%v", tarInfo.Title, v.Actual, v.Unit, v.Reason)
|
|
} else {
|
|
reason = fmt.Sprintf("%v :%v%v", tarInfo.Title, v.Actual, v.Unit)
|
|
}
|
|
|
|
}
|
|
} else {
|
|
if targetInfoErr == true {
|
|
if v.Reason != "" {
|
|
reason = fmt.Sprintf("%v\n%v :%v%v\n备注:%v", reason, tarInfo.Title, v.Actual, v.Unit, v.Reason)
|
|
} else {
|
|
reason = fmt.Sprintf("%v\n%v :%v%v", reason, tarInfo.Title, v.Actual, v.Unit)
|
|
}
|
|
|
|
}
|
|
}
|
|
flowDataLogAry = append(flowDataLogAry, flowDataLog)
|
|
} else {
|
|
yiTianJianMingc = append(yiTianJianMingc, v.TargetName)
|
|
}
|
|
} else {
|
|
var flowDataLog assessmentmodel.FlowLogData
|
|
evaluationPlan = append(evaluationPlan, v.Id)
|
|
evaluationPlanid, evaluationPlanidErr := strconv.ParseInt(v.Id, 10, 64)
|
|
if evaluationPlanidErr == nil {
|
|
flowDataLog.EvaluationPlan = evaluationPlanid
|
|
}
|
|
flowDataLog.Key = keyNumber
|
|
flowDataLog.Score = commonus.GetDuyCycle(v.Actual, 100)
|
|
flowDataLog.Content = v.Reason
|
|
flowDataLog.Enclosure = strings.Join(v.Enclosure, ",")
|
|
if v.ScoringMethod == 2 {
|
|
flowDataLog.ScoringMethod = 2
|
|
flowDataLog.ScoringScore = v.ScoringScore
|
|
} else {
|
|
flowDataLog.ScoringMethod = 1
|
|
flowDataLog.ScoringScore = 0
|
|
}
|
|
flowDataLog.PlanVersion = requestData.PlanVersionNumber
|
|
flowDataLog.Time = time.Now().Unix()
|
|
targetInfo, targetInfoErr := commonus.GetQualitativeEvaluation(strconv.FormatInt(evaluationPlanid, 10))
|
|
tarInfo, _ := commonus.GetTargetInfo(targetInfo.Target)
|
|
if i == 0 {
|
|
if targetInfoErr == true {
|
|
if v.Reason != "" {
|
|
reason = fmt.Sprintf("%v :%v%v\n备注:%v", tarInfo.Title, v.Actual, v.Unit, v.Reason)
|
|
} else {
|
|
reason = fmt.Sprintf("%v :%v%v", tarInfo.Title, v.Actual, v.Unit)
|
|
}
|
|
|
|
}
|
|
} else {
|
|
if targetInfoErr == true {
|
|
if v.Reason != "" {
|
|
reason = fmt.Sprintf("%v\n%v :%v%v\n备注:%v", reason, tarInfo.Title, v.Actual, v.Unit, v.Reason)
|
|
} else {
|
|
reason = fmt.Sprintf("%v\n%v :%v%v", reason, tarInfo.Title, v.Actual, v.Unit)
|
|
}
|
|
|
|
}
|
|
}
|
|
flowDataLogAry = append(flowDataLogAry, flowDataLog)
|
|
}
|
|
|
|
}
|
|
gromDb := global.GVA_DB_Performanceappraisal.Begin()
|
|
|
|
flowLog.EvaluationPlan = strings.Join(evaluationPlan, ",")
|
|
if len(flowDataLogAry) <= 0 {
|
|
response.Result(0, yiTianJianMingc, "您的数据已经提交!请不要重复提交!", c)
|
|
return
|
|
}
|
|
addFlowLogErr := gromDb.Create(&flowLog).Error
|
|
addFlowLogDataErr := gromDb.Create(&flowDataLogAry).Error
|
|
if addFlowLogErr == nil && addFlowLogDataErr == nil {
|
|
affairDbErr := gromDb.Commit().Error
|
|
if affairDbErr == nil {
|
|
commonus.StepAddData(keyNumber, 16182159043990656, 2, 7, 2, 2, 1, userCont.Key)
|
|
commonus.WriteReplyLog(keyNumber, departIdInt, departmentId, userKey, 1, commonus.GetSetpName(1), "提交申请")
|
|
sendUserIsTrue, sendUserList := commonus.GetSendMsgUser(16182159043990656, departIdInt) //获取对应部门负责人
|
|
if sendUserIsTrue != true {
|
|
response.Result(0, sendUserList, "未指定相关部门处理人!未能向相关人员发送考核项目!请手动发起!", c)
|
|
return
|
|
}
|
|
|
|
title := fmt.Sprintf("%v数据表", commonus.TimeStampToDate(operationTime, 10))
|
|
desc := ""
|
|
mainTitleDesc := "数据详情:"
|
|
//将步骤写入 判断该步骤是否已经操作
|
|
registerNumber := commonus.GetFileNumberEs()
|
|
var registerContIng assessmentmodel.Register
|
|
registerContIng.Number = registerNumber
|
|
registerContIng.State = 1
|
|
registerContIng.Time = time.Now().Unix()
|
|
registerContIng.AddCont()
|
|
//审批卡片跳转链接
|
|
cardJumpUrl := fmt.Sprintf("http://new.hxgk.group/#/quantitativeList?id=%v&num=%v", keyNumber, strconv.FormatInt(registerNumber, 10))
|
|
jumpUrl := fmt.Sprintf("http://new.hxgk.group/#/quantitativeList?id=%v&num=%v", keyNumber, strconv.FormatInt(registerNumber, 10))
|
|
|
|
jumpUrlTitle := "请前往处理"
|
|
sourceDesc := "审批"
|
|
twoLevelTitle := "审批信息:"
|
|
|
|
twoLevelKeyName := ""
|
|
execDerpat, execDerpatErr := commonus.GetNewOrgCont(departmentId)
|
|
if execDerpatErr == nil {
|
|
twoLevelKeyName = execDerpat.Name
|
|
}
|
|
var twoLevelKeyValue string = ""
|
|
var twoLevelUserId string = ""
|
|
//获取操作人
|
|
if userCont.Wechat != "" {
|
|
userWechatErr, userWechat := commonus.GetUesrContForWechatID(userCont.Wechat)
|
|
if userWechatErr == true {
|
|
twoLevelKeyValue = userWechat.Name
|
|
twoLevelUserId = userCont.Wechat
|
|
}
|
|
}
|
|
|
|
var sendTextMsg sendmessage.TextNoticeTemplateMedium
|
|
callbakcMsg, isTrueCall, callBackCont := sendTextMsg.SendMsgTextShare(sendUserList, strconv.FormatInt(registerNumber, 10), title, desc, mainTitleDesc, reason, twoLevelTitle, twoLevelKeyName, twoLevelKeyValue, twoLevelUserId, cardJumpUrl, jumpUrl, jumpUrlTitle, sourceDesc)
|
|
|
|
//发送文本信息通用
|
|
/*SendMsgTextShare(sendUserList, taskId, title, desc, quoteAreaTitle, quoteAreaContent, twoLevelTitle, twoLevelKeyName, twoLevelKeyValue, twoLevelUserId, cardJumpUrl, jumpUrl, jumpUrlTitle, sourceDesc string) (callbakcMsg []byte, isTrueCall bool, callBackCont string)
|
|
@sendUserList 信息接收人
|
|
@taskId 任务id,同一个应用任务id不能重复,只能由数字、字母和“_-@”组成,最长128字节,填了action_menu字段的话本字段必填
|
|
@Title 一级标题,建议不超过36个字,
|
|
@Desc 标题辅助信息,建议不超过44个字
|
|
@quoteAreaTitle 引用文献标题
|
|
@quoteAreaContent 引用文献内容
|
|
@twoLevelTitle 二级文本标题
|
|
@twoLevelKeyName 二级标题,建议不超过5个字
|
|
@twoLevelValue 二级文本,如果horizontal_content_list.type是2,该字段代表文件名称(要包含文件类型),建议不超过30个字,
|
|
@twoLevelUserId 成员详情的userid,horizontal_content_list.type是3时必填
|
|
@cardJumpUrl 整体卡片跳转链接
|
|
@jumpUrl 底部标题跳转链接
|
|
@jumpUrlTitle 跳转链接文案
|
|
@sourceDesc 左上角标题
|
|
*/
|
|
|
|
outMap := commonus.MapOut()
|
|
outMap["callbakcMsg"] = string(callbakcMsg)
|
|
outMap["isTrueCall"] = isTrueCall
|
|
outMap["callBackCont"] = callBackCont
|
|
outMap["setval"] = 1
|
|
|
|
response.Result(0, outMap, "数据提交成功!", c)
|
|
} else {
|
|
gromDb.Rollback()
|
|
response.Result(118, yiTianJianMingc, "数据提交失败!", c)
|
|
}
|
|
} else {
|
|
affairDbErr := gromDb.Rollback().Error
|
|
if affairDbErr == nil {
|
|
response.Result(119, yiTianJianMingc, "数据提交失败!", c)
|
|
} else {
|
|
response.Result(120, yiTianJianMingc, "数据提交失败!", c)
|
|
}
|
|
}
|
|
}
|
|
|
|
func (a *ApiGroup) SendRationFlow(c *gin.Context) {
|
|
isTrue, userCont := commonus.ClientIdentity()
|
|
if isTrue != true {
|
|
response.Result(1001, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c)
|
|
return
|
|
}
|
|
userKey, userKeyErr := strconv.ParseInt(userCont.Key, 10, 64)
|
|
if userKeyErr != nil {
|
|
response.Result(102, userKeyErr, "您的身份令牌已经失效!请重新登录获取身份令牌!", c)
|
|
return
|
|
}
|
|
departmentId, departmentIdErr := strconv.ParseInt(userCont.MainDeparment, 10, 64)
|
|
if departmentIdErr != nil {
|
|
response.Result(103, userCont, "您的身份令牌已经失效!请重新登录获取身份令牌!", c)
|
|
return
|
|
}
|
|
userGroup, userGroupErr := strconv.ParseInt(userCont.Company, 10, 64)
|
|
if userGroupErr != nil {
|
|
response.Result(104, userGroupErr, "您的身份令牌已经失效!请重新登录获取身份令牌!", c)
|
|
return
|
|
}
|
|
|
|
todaying := commonus.ComputingTime(time.Now().Unix(), 5)
|
|
|
|
if todaying > 10 {
|
|
// response.Result(1051, todaying, "不在可提交数据提时间期限内!不可提交数据。请每月10号前提交数据!。", c)
|
|
// return
|
|
}
|
|
|
|
var requestData AddRationFlowLog
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
response.Result(105, err, "数据获取失败!", c)
|
|
return
|
|
}
|
|
if requestData.GroupId == "" {
|
|
response.Result(106, err, "数据异常!", c)
|
|
return
|
|
}
|
|
if requestData.DepartmentID == "" {
|
|
response.Result(107, err, "数据异常!", c)
|
|
return
|
|
}
|
|
if len(requestData.List) < 1 {
|
|
response.Result(108, err, "没有要考核的项目", c)
|
|
return
|
|
}
|
|
|
|
//判断是否已经添加的条件
|
|
existenceProess := commonus.MapOut()
|
|
existenceProess["fl_planversion"] = requestData.PlanVersionNumber
|
|
|
|
operationTime := time.Now().Unix()
|
|
keyNumber := commonus.GetFileNumberEs()
|
|
var flowLog assessmentmodel.FlowLog
|
|
var allTimeSet TimeAllDay
|
|
flowLog.Key = keyNumber
|
|
flowLog.Time = time.Now().Unix()
|
|
flowLog.EiteTime = time.Now().Unix()
|
|
flowLog.PlanVersion = requestData.PlanVersionNumber
|
|
if requestData.Addtime != "" {
|
|
timeOccurrence := commonus.DateToTimeStamp(fmt.Sprintf("%v-10 12:00:00", requestData.Addtime)) //发生时间
|
|
flowLog.Year = commonus.ComputingTime(timeOccurrence, 1)
|
|
flowLog.Quarter = commonus.ComputingTime(timeOccurrence, 2)
|
|
flowLog.Month = commonus.ComputingTime(timeOccurrence, 3)
|
|
flowLog.Week = commonus.ComputingTime(timeOccurrence, 4)
|
|
flowLog.ToDay = commonus.ComputingTime(timeOccurrence, 5)
|
|
|
|
existenceProess["fl_year"] = commonus.ComputingTime(timeOccurrence, 1)
|
|
existenceProess["fl_quarter"] = commonus.ComputingTime(timeOccurrence, 2)
|
|
existenceProess["fl_month"] = commonus.ComputingTime(timeOccurrence, 3)
|
|
existenceProess["fl_week"] = commonus.ComputingTime(timeOccurrence, 4)
|
|
existenceProess["fl_day"] = commonus.ComputingTime(timeOccurrence, 5)
|
|
|
|
allTimeSet.Year = commonus.ComputingTime(timeOccurrence, 1)
|
|
allTimeSet.Quarter = commonus.ComputingTime(timeOccurrence, 2)
|
|
allTimeSet.Month = commonus.ComputingTime(timeOccurrence, 3)
|
|
allTimeSet.Week = commonus.ComputingTime(timeOccurrence, 4)
|
|
allTimeSet.ToDay = commonus.ComputingTime(timeOccurrence, 5)
|
|
|
|
// fmt.Printf("lastMonth-->%v-->lastMonthInt, -->%v-->lastMonthErr,-->%v--> operationTime-->%v-->flowLog----->%v\n", lastMonth, lastMonthInt, lastMonthErr, operationTime, flowLog)
|
|
// return
|
|
operationTime = timeOccurrence
|
|
} else {
|
|
lastMonth, _, _ := commonus.GetLastMonth()
|
|
|
|
lastMonthInt, lastMonthErr := commonus.DateToTimeStampEs(fmt.Sprintf("%v-10 12:00:00", lastMonth))
|
|
if lastMonthErr == true {
|
|
operationTime = lastMonthInt
|
|
}
|
|
|
|
flowLog.Year = commonus.ComputingTime(operationTime, 1)
|
|
flowLog.Quarter = commonus.ComputingTime(operationTime, 2)
|
|
flowLog.Month = commonus.ComputingTime(operationTime, 3)
|
|
flowLog.Week = commonus.ComputingTime(operationTime, 4)
|
|
flowLog.ToDay = commonus.ComputingTime(operationTime, 5)
|
|
|
|
existenceProess["fl_year"] = commonus.ComputingTime(operationTime, 1)
|
|
existenceProess["fl_quarter"] = commonus.ComputingTime(operationTime, 2)
|
|
existenceProess["fl_month"] = commonus.ComputingTime(operationTime, 3)
|
|
existenceProess["fl_week"] = commonus.ComputingTime(operationTime, 4)
|
|
existenceProess["fl_day"] = commonus.ComputingTime(operationTime, 5)
|
|
|
|
allTimeSet.Year = commonus.ComputingTime(operationTime, 1)
|
|
allTimeSet.Quarter = commonus.ComputingTime(operationTime, 2)
|
|
allTimeSet.Month = commonus.ComputingTime(operationTime, 3)
|
|
allTimeSet.Week = commonus.ComputingTime(operationTime, 4)
|
|
allTimeSet.ToDay = commonus.ComputingTime(operationTime, 5)
|
|
|
|
}
|
|
|
|
flowLog.EvaluationDepartment = departmentId
|
|
flowLog.EvaluationUser = userKey
|
|
flowLog.EvaluationGroup = userGroup
|
|
|
|
// existenceProess["fl_evaluation_department"] = departmentId
|
|
// existenceProess["fl_evaluation_user"] = userKey
|
|
// existenceProess["fl_evaluation_group"] = userGroup
|
|
|
|
dutyGroup, dutyGroupErr := strconv.ParseInt(requestData.GroupId, 10, 64)
|
|
if dutyGroupErr == nil {
|
|
flowLog.DutyGroup = dutyGroup
|
|
existenceProess["fl_duty_group"] = dutyGroup
|
|
}
|
|
departIdInt, departIdIntErr := strconv.ParseInt(requestData.DepartmentID, 10, 64)
|
|
if departIdIntErr == nil {
|
|
flowLog.DutyDepartment = departIdInt
|
|
existenceProess["fl_duty_department"] = departIdInt
|
|
}
|
|
flowLog.Reply = 2
|
|
var evaluationIdStr string
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.FlowLog{}).Select("fl_evaluation_id").Where(existenceProess).First(&evaluationIdStr)
|
|
var evaluationIdStrAry []string
|
|
if evaluationIdStr != "" { //判断已经提交过的数据
|
|
evaluationIdStrAry = strings.Split(evaluationIdStr, ",")
|
|
}
|
|
|
|
var flowDataLogAry []assessmentmodel.FlowLogData
|
|
var reason string
|
|
var evaluationPlan []string //方案ID
|
|
var yiTianJianMingc []string
|
|
// jsonMapStr, _ := json.Marshal(requestData.List)
|
|
json.Marshal(requestData.List)
|
|
//fmt.Printf("OutJsonMap-----1------>%\n", string(jsonMapStr))
|
|
var allZreoConfig []FlowLogAllZreo
|
|
for i, v := range requestData.List {
|
|
|
|
var allZreoConfigInfo FlowLogAllZreo
|
|
allZreoConfigInfo.Id = v.Id
|
|
allZreoConfigInfo.TargetId = v.Target
|
|
|
|
targetInfo, targetInfoErr := commonus.GetQualitativeEvaluation(v.Id)
|
|
tarInfo, _ := commonus.GetTargetInfo(targetInfo.Target)
|
|
switch targetInfo.Cycles {
|
|
case 5:
|
|
qualConfig, _ := commonus.GetDingLiangMuBiao(dutyGroup, departIdInt, targetInfo.Dimension, targetInfo.Target, allTimeSet.Year, allTimeSet.Quarter)
|
|
allZreoConfigInfo.Zeroprize = qualConfig.Zeroprize
|
|
allZreoConfigInfo.Allprize = qualConfig.Allprize
|
|
allZreoConfigInfo.Capping = qualConfig.CappingVal
|
|
case 6:
|
|
qualConfig, _ := commonus.GetDingLiangMuBiao(dutyGroup, departIdInt, targetInfo.Dimension, targetInfo.Target, allTimeSet.Year, 1)
|
|
allZreoConfigInfo.Zeroprize = qualConfig.Zeroprize
|
|
allZreoConfigInfo.Allprize = qualConfig.Allprize
|
|
allZreoConfigInfo.Capping = qualConfig.CappingVal
|
|
default:
|
|
qualConfig, _ := commonus.GetDingLiangMuBiao(dutyGroup, departIdInt, targetInfo.Dimension, targetInfo.Target, allTimeSet.Year, allTimeSet.Month)
|
|
allZreoConfigInfo.Zeroprize = qualConfig.Zeroprize
|
|
allZreoConfigInfo.Allprize = qualConfig.Allprize
|
|
allZreoConfigInfo.Capping = qualConfig.CappingVal
|
|
}
|
|
|
|
allZreoConfig = append(allZreoConfig, allZreoConfigInfo)
|
|
|
|
if len(evaluationIdStrAry) > 0 {
|
|
if commonus.IsItTrueString(v.Id, evaluationIdStrAry) == false {
|
|
var flowDataLog assessmentmodel.FlowLogData
|
|
evaluationPlan = append(evaluationPlan, v.Id)
|
|
evaluationPlanid, evaluationPlanidErr := strconv.ParseInt(v.Id, 10, 64)
|
|
if evaluationPlanidErr == nil {
|
|
flowDataLog.EvaluationPlan = evaluationPlanid
|
|
}
|
|
flowDataLog.Key = keyNumber
|
|
flowDataLog.Score = commonus.GetDuyCycle(v.Actual, 100)
|
|
flowDataLog.Content = v.Reason
|
|
flowDataLog.Enclosure = strings.Join(v.Enclosure, ",")
|
|
if v.ScoringMethod == 2 {
|
|
flowDataLog.ScoringMethod = 2
|
|
flowDataLog.ScoringScore = v.ScoringScore * 100
|
|
} else {
|
|
flowDataLog.ScoringMethod = 1
|
|
flowDataLog.ScoringScore = 0
|
|
}
|
|
// flowDataLog.PlanVersion = v.PlanVersionNumber
|
|
flowDataLog.Time = time.Now().Unix()
|
|
|
|
// tarInfo, _ := commonus.GetTargetInfo(targetInfo.Target)
|
|
if i == 0 {
|
|
if targetInfoErr == true {
|
|
if v.Reason != "" {
|
|
reason = fmt.Sprintf("%v :%v%v\n备注:%v", tarInfo.Title, v.Actual, v.Unit, v.Reason)
|
|
} else {
|
|
reason = fmt.Sprintf("%v :%v%v", tarInfo.Title, v.Actual, v.Unit)
|
|
}
|
|
|
|
}
|
|
} else {
|
|
if targetInfoErr == true {
|
|
if v.Reason != "" {
|
|
reason = fmt.Sprintf("%v\n%v :%v%v\n备注:%v", reason, tarInfo.Title, v.Actual, v.Unit, v.Reason)
|
|
} else {
|
|
reason = fmt.Sprintf("%v\n%v :%v%v", reason, tarInfo.Title, v.Actual, v.Unit)
|
|
}
|
|
|
|
}
|
|
}
|
|
flowDataLog.Year = allTimeSet.Year
|
|
flowDataLog.Quarter = allTimeSet.Quarter
|
|
flowDataLog.Month = allTimeSet.Month
|
|
flowDataLog.Week = allTimeSet.Week
|
|
flowDataLog.ToDay = allTimeSet.ToDay
|
|
targetId, _ := strconv.ParseInt(v.Target, 10, 64)
|
|
flowDataLog.TargetId = targetId
|
|
|
|
flowDataLogAry = append(flowDataLogAry, flowDataLog)
|
|
} else {
|
|
yiTianJianMingc = append(yiTianJianMingc, v.TargetName)
|
|
}
|
|
} else {
|
|
var flowDataLog assessmentmodel.FlowLogData
|
|
evaluationPlan = append(evaluationPlan, v.Id)
|
|
evaluationPlanid, evaluationPlanidErr := strconv.ParseInt(v.Id, 10, 64)
|
|
if evaluationPlanidErr == nil {
|
|
flowDataLog.EvaluationPlan = evaluationPlanid
|
|
}
|
|
flowDataLog.Key = keyNumber
|
|
flowDataLog.Score = commonus.GetDuyCycle(v.Actual, 100)
|
|
flowDataLog.Content = v.Reason
|
|
flowDataLog.Enclosure = strings.Join(v.Enclosure, ",")
|
|
// fmt.Printf("v.ScoringMethod ----->%v\n", v.ScoringMethod)
|
|
if v.ScoringMethod == 2 {
|
|
flowDataLog.ScoringMethod = 2
|
|
flowDataLog.ScoringScore = v.ScoringScore * 100
|
|
} else {
|
|
flowDataLog.ScoringMethod = 1
|
|
flowDataLog.ScoringScore = 0
|
|
}
|
|
flowDataLog.PlanVersion = requestData.PlanVersionNumber
|
|
flowDataLog.Time = time.Now().Unix()
|
|
// targetInfo, targetInfoErr := commonus.GetQualitativeEvaluation(strconv.FormatInt(evaluationPlanid, 10))
|
|
// tarInfo, _ := commonus.GetTargetInfo(targetInfo.Target)
|
|
if i == 0 {
|
|
if targetInfoErr == true {
|
|
if v.Reason != "" {
|
|
reason = fmt.Sprintf("%v :%v%v\n备注:%v", tarInfo.Title, v.Actual, v.Unit, v.Reason)
|
|
} else {
|
|
reason = fmt.Sprintf("%v :%v%v", tarInfo.Title, v.Actual, v.Unit)
|
|
}
|
|
|
|
}
|
|
} else {
|
|
if targetInfoErr == true {
|
|
if v.Reason != "" {
|
|
reason = fmt.Sprintf("%v\n%v :%v%v\n备注:%v", reason, tarInfo.Title, v.Actual, v.Unit, v.Reason)
|
|
} else {
|
|
reason = fmt.Sprintf("%v\n%v :%v%v", reason, tarInfo.Title, v.Actual, v.Unit)
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
flowDataLog.Year = allTimeSet.Year
|
|
flowDataLog.Quarter = allTimeSet.Quarter
|
|
flowDataLog.Month = allTimeSet.Month
|
|
flowDataLog.Week = allTimeSet.Week
|
|
flowDataLog.ToDay = allTimeSet.ToDay
|
|
targetId, _ := strconv.ParseInt(v.Target, 10, 64)
|
|
flowDataLog.TargetId = targetId
|
|
flowDataLogAry = append(flowDataLogAry, flowDataLog)
|
|
}
|
|
|
|
}
|
|
gromDb := global.GVA_DB_Performanceappraisal.Begin()
|
|
baselineJson, _ := json.Marshal(allZreoConfig)
|
|
flowLog.Baseline = string(baselineJson)
|
|
flowLog.EvaluationPlan = strings.Join(evaluationPlan, ",")
|
|
if len(flowDataLogAry) <= 0 {
|
|
response.Result(0, yiTianJianMingc, "您的数据已经提交!请不要重复提交!", c)
|
|
return
|
|
}
|
|
// jsonCont, _ := json.Marshal(flowDataLogAry)
|
|
// fmt.Printf("flowDataLogAry=>%v\n", string(jsonCont))
|
|
// return
|
|
addFlowLogErr := gromDb.Create(&flowLog).Error
|
|
addFlowLogDataErr := gromDb.Create(&flowDataLogAry).Error
|
|
if addFlowLogErr == nil && addFlowLogDataErr == nil {
|
|
affairDbErr := gromDb.Commit().Error
|
|
if affairDbErr == nil {
|
|
commonus.StepAddData(keyNumber, 16182159043990656, 2, 7, 2, 2, 1, userCont.Key)
|
|
commonus.WriteReplyLog(keyNumber, departIdInt, departmentId, userKey, 1, commonus.GetSetpName(1), "提交申请")
|
|
sendUserIsTrue, sendUserList := commonus.GetSendMsgUser(16182159043990656, departmentId) //获取对应部门负责人
|
|
// sendUserIsTrue, sendUserList := commonus.GetSendMsgUser(16182159043990656, departIdInt) //获取对应部门负责人
|
|
if sendUserIsTrue != true {
|
|
response.Result(0, sendUserList, "未指定相关部门处理人!未能向相关人员发送考核项目!请手动发起!", c)
|
|
return
|
|
}
|
|
|
|
title := fmt.Sprintf("%v数据表", commonus.TimeStampToDate(operationTime, 10))
|
|
desc := ""
|
|
mainTitleDesc := "数据详情:"
|
|
//将步骤写入 判断该步骤是否已经操作
|
|
registerNumber := commonus.GetFileNumberEs()
|
|
var registerContIng assessmentmodel.Register
|
|
registerContIng.Number = registerNumber
|
|
registerContIng.State = 1
|
|
registerContIng.Time = time.Now().Unix()
|
|
registerContIng.AddCont()
|
|
//审批卡片跳转链接
|
|
cardJumpUrl := fmt.Sprintf("http://new.hxgk.group/#/quantitativeList?id=%v&num=%v", keyNumber, strconv.FormatInt(registerNumber, 10))
|
|
jumpUrl := fmt.Sprintf("http://new.hxgk.group/#/quantitativeList?id=%v&num=%v", keyNumber, strconv.FormatInt(registerNumber, 10))
|
|
|
|
jumpUrlTitle := "请前往处理"
|
|
sourceDesc := "审批"
|
|
twoLevelTitle := "审批信息:"
|
|
|
|
twoLevelKeyName := ""
|
|
execDerpat, execDerpatErr := commonus.GetNewOrgCont(map[string]interface{}{"`id`": departmentId})
|
|
if execDerpatErr == nil {
|
|
twoLevelKeyName = execDerpat.Name
|
|
}
|
|
var twoLevelKeyValue string = ""
|
|
var twoLevelUserId string = ""
|
|
//获取操作人
|
|
if userCont.Wechat != "" {
|
|
userWechatErr, userWechat := commonus.GetUesrContForWechatID(userCont.Wechat)
|
|
if userWechatErr == true {
|
|
twoLevelKeyValue = userWechat.Name
|
|
twoLevelUserId = userCont.Wechat
|
|
}
|
|
}
|
|
|
|
var sendTextMsg sendmessage.TextNoticeTemplateMedium
|
|
callbakcMsg, isTrueCall, callBackCont := sendTextMsg.SendMsgTextShare(sendUserList, strconv.FormatInt(registerNumber, 10), title, desc, mainTitleDesc, reason, twoLevelTitle, twoLevelKeyName, twoLevelKeyValue, twoLevelUserId, cardJumpUrl, jumpUrl, jumpUrlTitle, sourceDesc)
|
|
|
|
//发送文本信息通用
|
|
/*SendMsgTextShare(sendUserList, taskId, title, desc, quoteAreaTitle, quoteAreaContent, twoLevelTitle, twoLevelKeyName, twoLevelKeyValue, twoLevelUserId, cardJumpUrl, jumpUrl, jumpUrlTitle, sourceDesc string) (callbakcMsg []byte, isTrueCall bool, callBackCont string)
|
|
@sendUserList 信息接收人
|
|
@taskId 任务id,同一个应用任务id不能重复,只能由数字、字母和“_-@”组成,最长128字节,填了action_menu字段的话本字段必填
|
|
@Title 一级标题,建议不超过36个字,
|
|
@Desc 标题辅助信息,建议不超过44个字
|
|
@quoteAreaTitle 引用文献标题
|
|
@quoteAreaContent 引用文献内容
|
|
@twoLevelTitle 二级文本标题
|
|
@twoLevelKeyName 二级标题,建议不超过5个字
|
|
@twoLevelValue 二级文本,如果horizontal_content_list.type是2,该字段代表文件名称(要包含文件类型),建议不超过30个字,
|
|
@twoLevelUserId 成员详情的userid,horizontal_content_list.type是3时必填
|
|
@cardJumpUrl 整体卡片跳转链接
|
|
@jumpUrl 底部标题跳转链接
|
|
@jumpUrlTitle 跳转链接文案
|
|
@sourceDesc 左上角标题
|
|
*/
|
|
|
|
eiteScoreFlow := commonus.MapOut()
|
|
eiteScoreFlow["sf_eite_time"] = time.Now().Unix()
|
|
eiteScoreFlow["sf_reply"] = 2
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.ScoreFlow{}).Where("`sf_key` = ?", keyNumber).Updates(&eiteScoreFlow)
|
|
evalProcSaveData := commonus.MapOut()
|
|
evalProcSaveData["ep_state"] = 2
|
|
evalProcSaveData["ep_happen_time"] = operationTime
|
|
evalProcSaveData["ep_time"] = time.Now().Unix()
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.EvaluationProcess{}).Where("`ep_order_key` = ?", keyNumber).Updates(&evalProcSaveData)
|
|
|
|
outMap := commonus.MapOut()
|
|
outMap["callbakcMsg"] = string(callbakcMsg)
|
|
outMap["isTrueCall"] = isTrueCall
|
|
outMap["callBackCont"] = callBackCont
|
|
outMap["setval"] = 1
|
|
outMap["sendUserList"] = sendUserList
|
|
|
|
response.Result(0, outMap, "数据提交成功!", c)
|
|
} else {
|
|
gromDb.Rollback()
|
|
response.Result(118, yiTianJianMingc, "数据提交失败!", c)
|
|
}
|
|
} else {
|
|
affairDbErr := gromDb.Rollback().Error
|
|
if affairDbErr == nil {
|
|
response.Result(119, yiTianJianMingc, "数据提交失败!", c)
|
|
} else {
|
|
response.Result(120, yiTianJianMingc, "数据提交失败!", c)
|
|
}
|
|
}
|
|
}
|
|
|