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.
634 lines
21 KiB
634 lines
21 KiB
package departmentpc
|
|
|
|
import (
|
|
"key_performance_indicators/models/modelskpi"
|
|
"key_performance_indicators/overall"
|
|
"key_performance_indicators/overall/publicmethod"
|
|
"strconv"
|
|
"strings"
|
|
"time"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2023-02-16 08:52:27
|
|
@ 功能: 新版添加部门指标细则
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) NewAddDepartDetails(c *gin.Context) {
|
|
var receivedValue NewDetailsCont
|
|
err := c.ShouldBindJSON(&receivedValue)
|
|
if err != nil {
|
|
publicmethod.Result(100, err, c)
|
|
return
|
|
}
|
|
if receivedValue.TargetId == "" {
|
|
publicmethod.Result(1, receivedValue, c, "未知指标!请指定该细则归属指标")
|
|
return
|
|
}
|
|
if receivedValue.TableName == "" {
|
|
publicmethod.Result(1, receivedValue, c, "未知栏目名称!请选择已有栏目或新输入一个栏目名称!")
|
|
return
|
|
}
|
|
if len(receivedValue.DetailsList) < 1 {
|
|
publicmethod.Result(1, receivedValue, c, "没有细则内容提交!请输入至少一条细则内容!")
|
|
return
|
|
}
|
|
writeIsTrue := false
|
|
//验证细则内容
|
|
for _, v := range receivedValue.DetailsList {
|
|
if v.Title == "" {
|
|
writeIsTrue = true
|
|
}
|
|
if v.Standard == "" {
|
|
writeIsTrue = true
|
|
} else {
|
|
scoreAry := strings.Split(v.Standard, "-")
|
|
if len(scoreAry) < 1 {
|
|
writeIsTrue = true
|
|
}
|
|
}
|
|
if v.Unit == "" {
|
|
writeIsTrue = true
|
|
}
|
|
if v.Types == 0 {
|
|
writeIsTrue = true
|
|
}
|
|
if len(v.InspeMethod) < 1 {
|
|
writeIsTrue = true
|
|
}
|
|
if len(v.Department) < 1 {
|
|
writeIsTrue = true
|
|
}
|
|
if len(v.Executor) < 1 {
|
|
writeIsTrue = true
|
|
}
|
|
}
|
|
if writeIsTrue {
|
|
publicmethod.Result(1, receivedValue, c, "至少一条考核细则内容填写不符合规范!请检查并补充完成后,重新提交!")
|
|
return
|
|
}
|
|
// tragetId, _ := strconv.ParseInt(receivedValue.TargetId, 10, 64)
|
|
//获取指标内容
|
|
var targetCont modelskpi.EvaluationTarget
|
|
err = targetCont.GetCont(map[string]interface{}{"`et_id`": receivedValue.TargetId})
|
|
if err != nil {
|
|
publicmethod.Result(1, err, c, "没有此指标!")
|
|
return
|
|
}
|
|
if len(receivedValue.TargetOrgList) < 1 {
|
|
receivedValue.TargetOrgList = GetTargetAboutDepart(targetCont)
|
|
}
|
|
var targetOrgIdList []string
|
|
for _, tov := range receivedValue.TargetOrgList {
|
|
if publicmethod.IsInTrue[string](tov.Key, targetOrgIdList) == false {
|
|
targetOrgIdList = append(targetOrgIdList, tov.Key)
|
|
}
|
|
}
|
|
//处理栏目数据
|
|
tableId, err := HandleTableCont(targetCont.Dimension, targetCont.Id, targetCont.Type, receivedValue.TableName, targetOrgIdList)
|
|
if err != nil {
|
|
publicmethod.Result(104, receivedValue, c)
|
|
return
|
|
}
|
|
// var insetContList []modelskpi.DetailedTarget
|
|
|
|
for _, v := range receivedValue.DetailsList {
|
|
var insetDeatilsCont modelskpi.DetailedTarget
|
|
insetDeatilsCont.Title = v.Title //指标细则"`
|
|
insetDeatilsCont.Content = v.Remarks //指标说明"`
|
|
insetDeatilsCont.ParentId = targetCont.Id //归属指标栏目"`
|
|
insetDeatilsCont.ParentIdSun = tableId //归属指标子栏目"`
|
|
insetDeatilsCont.State = 1 //状态(1:启用;2:禁用;3:删除)"`
|
|
insetDeatilsCont.AddTime = time.Now().Unix() //制定时间"`
|
|
insetDeatilsCont.MinScore, insetDeatilsCont.MaxScore = SplitCriteria(v.Standard) //最小分*100保存"`,最大分*100保存"`
|
|
insetDeatilsCont.Company = v.Unit //单位"`
|
|
insetDeatilsCont.AddReduce = v.Types //1:减少;2:增加;3:无属性,现场确认加或减"`
|
|
insetDeatilsCont.CensorType = strings.Join(v.InspeMethod, ",") //检查方式"`
|
|
insetDeatilsCont.CensorCont = v.Evidence //检查依据"`
|
|
insetDeatilsCont.CensorRate = v.Frequency //检查频次"`
|
|
insetDeatilsCont.Cycles = v.Cycle //1:班;2:天;3:周;4:月;5:季度;6:年"`
|
|
insetDeatilsCont.CycleAttres = 1 //辅助计数"`
|
|
insetDeatilsCont.Paretment = strings.Join(v.Department, ",") //接受考核的部门"`
|
|
insetDeatilsCont.Reportary = strings.Join(v.Executor, ",") //提报人"`
|
|
// insetContList = append(insetContList, insetDeatilsCont)
|
|
addErr := overall.CONSTANT_DB_KPI.Create(&insetDeatilsCont).Error
|
|
if addErr == nil {
|
|
SyncSeting.Add(1)
|
|
go DepartAboutTarget(targetCont.Dimension, targetCont.Id, tableId, insetDeatilsCont.Id, v.Department, 3, targetCont.Type, 1)
|
|
SyncSeting.Add(1)
|
|
go DepartAndReportAboutTarget(targetCont.Dimension, targetCont.Id, tableId, insetDeatilsCont.Id, v.Department, v.Executor, 1, targetCont.Type, 3)
|
|
}
|
|
}
|
|
SyncSeting.Wait()
|
|
publicmethod.Result(0, err, c)
|
|
}
|
|
|
|
// 拆分指标细则考核标准
|
|
|
|
func SplitCriteria(detailsCriteria string) (minScore, maxScore int64) {
|
|
scoreAry := strings.Split(detailsCriteria, "-")
|
|
scoreLen := len(scoreAry)
|
|
if scoreLen > 0 {
|
|
if scoreLen == 1 {
|
|
maxScoreFloat, _ := strconv.ParseFloat(scoreAry[0], 64)
|
|
maxScore, _ = strconv.ParseInt(strconv.FormatFloat(maxScoreFloat*100, 'f', -1, 64), 10, 64)
|
|
minScore = 0
|
|
} else {
|
|
minScoreFloat, _ := strconv.ParseFloat(scoreAry[0], 64)
|
|
maxScoreFloat, _ := strconv.ParseFloat(scoreAry[scoreLen-1], 64)
|
|
minScore, _ = strconv.ParseInt(strconv.FormatFloat(minScoreFloat*100, 'f', -1, 64), 10, 64)
|
|
maxScore, _ = strconv.ParseInt(strconv.FormatFloat(maxScoreFloat*100, 'f', -1, 64), 10, 64)
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2023-02-16 10:06:59
|
|
@ 功能: 处理栏目数据
|
|
@ 参数
|
|
|
|
#dimensionId 维度
|
|
#tragetId 指标Id
|
|
#title 栏目名称
|
|
#targetOrgIdList 关联岗位
|
|
#class 属性1:定性考核;2:定量考核
|
|
|
|
@ 返回值
|
|
|
|
#tableId 栏目ID
|
|
#err 状态数据
|
|
|
|
@ 方法原型
|
|
|
|
#HandleTableCont(dimensionId, tragetId int64, class int, title string, targetOrgIdList []string) (tableId int64, err error)
|
|
*/
|
|
func HandleTableCont(dimensionId, tragetId int64, class int, title string, targetOrgIdList []string) (tableId int64, err error) {
|
|
var tableCont modelskpi.QualitativeTarget
|
|
err = tableCont.GetCont(map[string]interface{}{"`q_title`": title, "`q_parent_id`": tragetId})
|
|
if err != nil {
|
|
//不存在就新增
|
|
var insetTableCont modelskpi.QualitativeTarget
|
|
insetTableCont.Title = title // 指标子栏目名称
|
|
insetTableCont.ParentId = tragetId //归属指标
|
|
insetTableCont.State = 1 //状态(1:启用;2:禁用;3:删除)
|
|
insetTableCont.AddTime = time.Now().Unix() //制定时间"`
|
|
insetTableCont.Depart = strings.Join(targetOrgIdList, ",") //关联部门"`
|
|
err = overall.CONSTANT_DB_KPI.Create(&insetTableCont).Error
|
|
tableId = insetTableCont.Id
|
|
SyncSeting.Add(1)
|
|
go DepartAboutTarget(dimensionId, tragetId, insetTableCont.Id, 0, targetOrgIdList, 2, class, 1)
|
|
} else {
|
|
tableId = tableCont.Id
|
|
//存在就修改
|
|
editCont := publicmethod.MapOut[string]()
|
|
if tableCont.State != 1 {
|
|
editCont["q_state"] = 1
|
|
}
|
|
orgListStr := strings.Join(targetOrgIdList, ",")
|
|
if tableCont.Depart != orgListStr {
|
|
editCont["q_depart"] = orgListStr
|
|
SyncSeting.Add(1)
|
|
go DepartAboutTarget(dimensionId, tragetId, tableCont.Id, 0, targetOrgIdList, 2, class, 1)
|
|
}
|
|
if len(editCont) > 0 {
|
|
editCont["q_time"] = time.Now().Unix()
|
|
var editTableCont modelskpi.QualitativeTarget
|
|
err = editTableCont.EiteCont(map[string]interface{}{"q_id": tableCont.Id}, editCont)
|
|
}
|
|
|
|
}
|
|
SyncSeting.Wait()
|
|
return
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2023-02-16 14:01:48
|
|
@ 功能: 编辑指标细则状态
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) EditDetailsState(c *gin.Context) {
|
|
var receivedValue publicmethod.PublicState
|
|
c.ShouldBindJSON(&receivedValue)
|
|
// err := c.ShouldBindJSON(&receivedValue)
|
|
// if err != nil {
|
|
// publicmethod.Result(100, err, c)
|
|
// return
|
|
// }
|
|
if receivedValue.Id == "" {
|
|
publicmethod.Result(1, receivedValue, c, "未知指标细则!请确认后再提交处理!")
|
|
return
|
|
}
|
|
if receivedValue.State == 0 {
|
|
receivedValue.State = 1
|
|
}
|
|
if receivedValue.IsTrue == 0 {
|
|
receivedValue.IsTrue = 2
|
|
}
|
|
where := publicmethod.MapOut[string]()
|
|
where["dt_id"] = receivedValue.Id
|
|
var detailsCont modelskpi.DetailedTarget
|
|
err := detailsCont.GetCont(where, "dt_id", "dt_parentid", "dt_parentid_sun")
|
|
if err != nil {
|
|
publicmethod.Result(107, err, c)
|
|
return
|
|
}
|
|
softDel := 1
|
|
if receivedValue.State == 3 && receivedValue.IsTrue == 1 {
|
|
//强制删除
|
|
//判断该指标细则是否在使用中,使用中的只能软删除
|
|
var epIdList []int64
|
|
overall.CONSTANT_DB_KPI.Model(&modelskpi.EvaluationProcess{}).Select("`ep_id`").Where("FIND_IN_SET(?,`ep_detailedtarget`)", receivedValue.Id).Find(&epIdList)
|
|
if len(epIdList) > 0 {
|
|
softDel = 1
|
|
} else {
|
|
softDel = 2
|
|
}
|
|
}
|
|
delTime := time.Now().Unix()
|
|
var editDetailsInfo modelskpi.DetailedTarget
|
|
if softDel == 1 {
|
|
//软删除
|
|
editDetailsInfo.EiteCont(where, map[string]interface{}{"`dt_state`": receivedValue.State, "`dt_time`": delTime})
|
|
} else {
|
|
//硬删除
|
|
editDetailsInfo.DelCont(where)
|
|
}
|
|
SyncSeting.Add(1)
|
|
go TarDepartState(detailsCont.ParentId, detailsCont.ParentIdSun, detailsCont.Id, receivedValue.State, softDel, 1, 3) // 处理关联部门
|
|
SyncSeting.Add(1)
|
|
go TarAboutReport(detailsCont.ParentId, detailsCont.ParentIdSun, detailsCont.Id, receivedValue.State, softDel, 1, 3) // 处理相关提报人
|
|
SyncSeting.Wait()
|
|
publicmethod.Result(0, err, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2023-02-18 08:33:09
|
|
@ 功能: 编辑单一指标细则内容(新版)
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) EditDetailsCont(c *gin.Context) {
|
|
var receivedValue EditOneDetailsCont
|
|
c.ShouldBindJSON(&receivedValue)
|
|
if receivedValue.Id == "" {
|
|
publicmethod.Result(1, receivedValue, c, "未知指标细则!请确认后再提交处理!")
|
|
return
|
|
}
|
|
var minVal int64
|
|
var maxVal int64
|
|
if receivedValue.Standard == "" {
|
|
publicmethod.Result(1, receivedValue, c, "请输入考核标准!")
|
|
return
|
|
} else {
|
|
scoreAry := strings.Split(receivedValue.Standard, "-")
|
|
if len(scoreAry) < 1 {
|
|
publicmethod.Result(1, receivedValue, c, "您输入的考核标准不符合规范!(例:1或0.1或0.1-0.5等类型)")
|
|
return
|
|
} else {
|
|
scoreLen := len(scoreAry)
|
|
if scoreLen == 1 {
|
|
maxScoreFloat, _ := strconv.ParseFloat(scoreAry[0], 64)
|
|
maxVal, _ = strconv.ParseInt(strconv.FormatFloat(maxScoreFloat*100, 'f', -1, 64), 10, 64)
|
|
minVal = 0
|
|
} else {
|
|
minScoreFloat, _ := strconv.ParseFloat(scoreAry[0], 64)
|
|
maxScoreFloat, _ := strconv.ParseFloat(scoreAry[scoreLen-1], 64)
|
|
minVal, _ = strconv.ParseInt(strconv.FormatFloat(minScoreFloat*100, 'f', -1, 64), 10, 64)
|
|
maxVal, _ = strconv.ParseInt(strconv.FormatFloat(maxScoreFloat*100, 'f', -1, 64), 10, 64)
|
|
}
|
|
}
|
|
}
|
|
if receivedValue.Unit == "" {
|
|
publicmethod.Result(1, receivedValue, c, "请输入计量单位!")
|
|
return
|
|
}
|
|
if receivedValue.Types == 0 {
|
|
publicmethod.Result(1, receivedValue, c, "请选择操作类型!")
|
|
return
|
|
}
|
|
if len(receivedValue.InspeMethod) < 1 {
|
|
publicmethod.Result(1, receivedValue, c, "请选择检查方式!")
|
|
return
|
|
}
|
|
if len(receivedValue.Department) < 1 {
|
|
publicmethod.Result(1, receivedValue, c, "请选择接受考核部门!")
|
|
return
|
|
}
|
|
if len(receivedValue.Executor) < 1 {
|
|
publicmethod.Result(1, receivedValue, c, "请选择执行人")
|
|
return
|
|
}
|
|
where := publicmethod.MapOut[string]()
|
|
where["dt_id"] = receivedValue.Id
|
|
var detailsCont modelskpi.DetailedTarget
|
|
err := detailsCont.GetCont(where)
|
|
if err != nil {
|
|
publicmethod.Result(107, err, c)
|
|
return
|
|
}
|
|
var targetCont modelskpi.EvaluationTarget
|
|
err = targetCont.GetCont(map[string]interface{}{"`et_id`": detailsCont.ParentId}, "et_dimension", "et_type")
|
|
if err != nil {
|
|
publicmethod.Result(1, err, c, "没有此指标!")
|
|
return
|
|
}
|
|
|
|
editDateCont := publicmethod.MapOut[string]()
|
|
if receivedValue.Title != detailsCont.Title {
|
|
editDateCont["dt_title"] = receivedValue.Title
|
|
}
|
|
if minVal != detailsCont.MinScore {
|
|
editDateCont["dt_min_score"] = minVal
|
|
}
|
|
if maxVal != detailsCont.MaxScore {
|
|
editDateCont["dt_max_score"] = maxVal
|
|
}
|
|
if receivedValue.Unit != detailsCont.Company {
|
|
editDateCont["dt_company"] = receivedValue.Unit
|
|
}
|
|
if receivedValue.Types != detailsCont.AddReduce {
|
|
editDateCont["dt_add_reduce"] = receivedValue.Types
|
|
}
|
|
censorType := strings.Join(receivedValue.InspeMethod, ",")
|
|
if censorType != detailsCont.CensorType {
|
|
editDateCont["dt_censor_type"] = censorType
|
|
}
|
|
if receivedValue.Cycle != detailsCont.Cycles {
|
|
editDateCont["dt_cycle"] = receivedValue.Cycle
|
|
}
|
|
if receivedValue.Frequency != detailsCont.CensorRate {
|
|
editDateCont["dt_censor_rate"] = receivedValue.Frequency
|
|
}
|
|
if receivedValue.Evidence != detailsCont.CensorCont {
|
|
editDateCont["dt_censor_cont"] = receivedValue.Evidence
|
|
}
|
|
if receivedValue.Remarks != detailsCont.Content {
|
|
editDateCont["dt_content"] = receivedValue.Remarks
|
|
}
|
|
orgStr := strings.Join(receivedValue.Department, ",")
|
|
if orgStr != detailsCont.Paretment {
|
|
editDateCont["dt_paretment"] = orgStr
|
|
}
|
|
reportStr := strings.Join(receivedValue.Executor, ",")
|
|
if reportStr != detailsCont.Reportary {
|
|
editDateCont["reportary"] = reportStr
|
|
}
|
|
if len(editDateCont) > 0 {
|
|
editDateCont["dt_time"] = time.Now().Unix()
|
|
editDateCont["dt_state"] = 1
|
|
var editDetaCont modelskpi.DetailedTarget
|
|
errEdit := editDetaCont.EiteCont(where, editDateCont)
|
|
if errEdit != nil {
|
|
publicmethod.Result(107, err, c)
|
|
return
|
|
}
|
|
}
|
|
SyncSeting.Add(1)
|
|
go DepartAboutTarget(targetCont.Dimension, detailsCont.ParentId, detailsCont.ParentIdSun, detailsCont.Id, receivedValue.Department, 3, targetCont.Type, 1)
|
|
SyncSeting.Add(1)
|
|
go DepartAndReportAboutTarget(targetCont.Dimension, detailsCont.ParentId, detailsCont.ParentIdSun, detailsCont.Id, receivedValue.Department, receivedValue.Executor, 1, targetCont.Type, 3)
|
|
SyncSeting.Wait()
|
|
publicmethod.Result(0, err, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2023-02-18 13:00:31
|
|
@ 功能: 根据栏目添加细则
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) TableAddDetailses(c *gin.Context) {
|
|
var receivedValue TableAddDetaCont
|
|
err := c.ShouldBindJSON(&receivedValue)
|
|
if err != nil {
|
|
publicmethod.Result(100, err, c)
|
|
return
|
|
}
|
|
if receivedValue.TargetId == "" {
|
|
publicmethod.Result(1, receivedValue, c, "未知指标!请指定该细则归属指标")
|
|
return
|
|
}
|
|
if receivedValue.TableiId == "" {
|
|
publicmethod.Result(1, receivedValue, c, "未知栏目!请指定栏目!")
|
|
return
|
|
}
|
|
if len(receivedValue.DetailsList) < 1 {
|
|
publicmethod.Result(1, receivedValue, c, "没有细则内容提交!请输入至少一条细则内容!")
|
|
return
|
|
}
|
|
writeIsTrue := false
|
|
//验证细则内容
|
|
for _, v := range receivedValue.DetailsList {
|
|
if v.Title == "" {
|
|
writeIsTrue = true
|
|
}
|
|
if v.Standard == "" {
|
|
writeIsTrue = true
|
|
} else {
|
|
scoreAry := strings.Split(v.Standard, "-")
|
|
if len(scoreAry) < 1 {
|
|
writeIsTrue = true
|
|
}
|
|
}
|
|
if v.Unit == "" {
|
|
writeIsTrue = true
|
|
}
|
|
if v.Types == 0 {
|
|
writeIsTrue = true
|
|
}
|
|
if len(v.InspeMethod) < 1 {
|
|
writeIsTrue = true
|
|
}
|
|
if len(v.Department) < 1 {
|
|
writeIsTrue = true
|
|
}
|
|
if len(v.Executor) < 1 {
|
|
writeIsTrue = true
|
|
}
|
|
}
|
|
if writeIsTrue {
|
|
publicmethod.Result(1, receivedValue, c, "至少一条考核细则内容填写不符合规范!请检查并补充完成后,重新提交!")
|
|
return
|
|
}
|
|
// tragetId, _ := strconv.ParseInt(receivedValue.TargetId, 10, 64)
|
|
//获取指标内容
|
|
var targetCont modelskpi.EvaluationTarget
|
|
err = targetCont.GetCont(map[string]interface{}{"`et_id`": receivedValue.TargetId}, "`et_id`", "`et_type`", "`et_dimension`")
|
|
if err != nil {
|
|
publicmethod.Result(1, err, c, "没有此指标!")
|
|
return
|
|
}
|
|
//
|
|
var tableInfo modelskpi.QualitativeTarget
|
|
err = tableInfo.GetCont(map[string]interface{}{"`q_id`": receivedValue.TableiId}, "`q_id`", "`q_state`")
|
|
if err != nil {
|
|
publicmethod.Result(1, err, c, "没有此指标!")
|
|
return
|
|
}
|
|
if tableInfo.State != 1 {
|
|
var editTableInfo modelskpi.QualitativeTarget
|
|
editTableInfo.EiteCont(map[string]interface{}{"`q_id`": receivedValue.TableiId}, map[string]interface{}{"`q_state`": 1, "`q_time`": time.Now().Unix()})
|
|
}
|
|
for _, v := range receivedValue.DetailsList {
|
|
var insetDeatilsCont modelskpi.DetailedTarget
|
|
insetDeatilsCont.Title = v.Title //指标细则"`
|
|
insetDeatilsCont.Content = v.Remarks //指标说明"`
|
|
insetDeatilsCont.ParentId = targetCont.Id //归属指标栏目"`
|
|
insetDeatilsCont.ParentIdSun = tableInfo.Id //归属指标子栏目"`
|
|
insetDeatilsCont.State = 1 //状态(1:启用;2:禁用;3:删除)"`
|
|
insetDeatilsCont.AddTime = time.Now().Unix() //制定时间"`
|
|
insetDeatilsCont.MinScore, insetDeatilsCont.MaxScore = SplitCriteria(v.Standard) //最小分*100保存"`,最大分*100保存"`
|
|
insetDeatilsCont.Company = v.Unit //单位"`
|
|
insetDeatilsCont.AddReduce = v.Types //1:减少;2:增加;3:无属性,现场确认加或减"`
|
|
insetDeatilsCont.CensorType = strings.Join(v.InspeMethod, ",") //检查方式"`
|
|
insetDeatilsCont.CensorCont = v.Evidence //检查依据"`
|
|
insetDeatilsCont.CensorRate = v.Frequency //检查频次"`
|
|
insetDeatilsCont.Cycles = v.Cycle //1:班;2:天;3:周;4:月;5:季度;6:年"`
|
|
insetDeatilsCont.CycleAttres = 1 //辅助计数"`
|
|
insetDeatilsCont.Paretment = strings.Join(v.Department, ",") //接受考核的部门"`
|
|
insetDeatilsCont.Reportary = strings.Join(v.Executor, ",") //提报人"`
|
|
// insetContList = append(insetContList, insetDeatilsCont)
|
|
addErr := overall.CONSTANT_DB_KPI.Create(&insetDeatilsCont).Error
|
|
if addErr == nil {
|
|
SyncSeting.Add(1)
|
|
go DepartAboutTarget(targetCont.Dimension, targetCont.Id, tableInfo.Id, insetDeatilsCont.Id, v.Department, 3, targetCont.Type, 1)
|
|
SyncSeting.Add(1)
|
|
go DepartAndReportAboutTarget(targetCont.Dimension, targetCont.Id, tableInfo.Id, insetDeatilsCont.Id, v.Department, v.Executor, 1, targetCont.Type, 3)
|
|
}
|
|
}
|
|
SyncSeting.Wait()
|
|
publicmethod.Result(0, err, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2023-02-18 13:53:23
|
|
@ 功能: 修改栏目名称及关联岗位和提报人
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) EditTableContAndDepartOfMan(c *gin.Context) {
|
|
var receivedValue EditTableInfo
|
|
err := c.ShouldBindJSON(&receivedValue)
|
|
if err != nil {
|
|
publicmethod.Result(100, err, c)
|
|
return
|
|
}
|
|
if receivedValue.Id == "" {
|
|
publicmethod.Result(1, receivedValue, c, "未知指标!请指定该细则归属指标")
|
|
return
|
|
}
|
|
|
|
//获取栏目内容
|
|
var targetTableCont modelskpi.QualitativeTarget
|
|
err = targetTableCont.GetCont(map[string]interface{}{"`q_id`": receivedValue.Id})
|
|
if err != nil {
|
|
publicmethod.Result(1, err, c, "没有此栏目!")
|
|
return
|
|
}
|
|
//获取指标内容
|
|
var targetCont modelskpi.EvaluationTarget
|
|
err = targetCont.GetCont(map[string]interface{}{"`et_id`": targetTableCont.ParentId})
|
|
if err != nil {
|
|
publicmethod.Result(1, err, c, "没有此指标!")
|
|
return
|
|
}
|
|
|
|
editSaveData := publicmethod.MapOut[string]()
|
|
if receivedValue.Title != "" && receivedValue.Title != targetTableCont.Title {
|
|
editSaveData["q_title"] = receivedValue.Title
|
|
}
|
|
|
|
if len(receivedValue.Departmentint) > 0 {
|
|
departStr := strings.Join(receivedValue.Departmentint, ",")
|
|
if departStr != targetTableCont.Depart {
|
|
editSaveData["q_depart"] = departStr
|
|
}
|
|
SyncSeting.Add(1)
|
|
go DepartAboutTarget(targetCont.Dimension, targetTableCont.ParentId, targetTableCont.Id, 0, receivedValue.Departmentint, 2, targetCont.Type, 1)
|
|
}
|
|
if len(receivedValue.UserList) > 0 {
|
|
SyncSeting.Add(1)
|
|
go DepartAndReportAboutTarget(targetCont.Dimension, targetTableCont.ParentId, targetTableCont.Id, 0, receivedValue.Departmentint, receivedValue.UserList, 1, targetCont.Type, 2)
|
|
}
|
|
if len(editSaveData) > 0 {
|
|
editSaveData["q_time"] = time.Now().Unix()
|
|
var editTargetCont modelskpi.QualitativeTarget
|
|
editTargetCont.EiteCont(map[string]interface{}{"`q_id`": receivedValue.Id}, editSaveData)
|
|
}
|
|
//该栏目的所有细则
|
|
var bylawsId []int64
|
|
err = overall.CONSTANT_DB_KPI.Model(&modelskpi.DetailedTarget{}).Select("dt_id").Where("`dt_parentid` = ? AND `dt_parentid_sun` = ?", targetTableCont.ParentId, targetTableCont.Id).Find(&bylawsId).Error
|
|
if err == nil && len(bylawsId) > 0 {
|
|
for _, v := range bylawsId {
|
|
SyncSeting.Add(1)
|
|
go DepartAboutTarget(targetCont.Dimension, targetTableCont.ParentId, targetTableCont.Id, v, receivedValue.Departmentint, 3, targetCont.Type, 1)
|
|
SyncSeting.Add(1)
|
|
go DepartAndReportAboutTarget(targetCont.Dimension, targetTableCont.ParentId, targetTableCont.Id, v, receivedValue.Departmentint, receivedValue.UserList, 1, targetCont.Type, 3)
|
|
}
|
|
}
|
|
|
|
SyncSeting.Wait()
|
|
publicmethod.Result(0, err, c)
|
|
}
|
|
|