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.
136 lines
5.4 KiB
136 lines
5.4 KiB
package departmentpc
|
|
|
|
import (
|
|
"fmt"
|
|
"key_performance_indicators/models/modelshr"
|
|
"key_performance_indicators/models/modelskpi"
|
|
"key_performance_indicators/overall"
|
|
"key_performance_indicators/overall/publicmethod"
|
|
"strconv"
|
|
"strings"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// 定性指标细则与部门矩阵
|
|
func (a *ApiMethod) DepartmentRulesMatrix(c *gin.Context) {
|
|
var receivedValue rulesMatrixParameter
|
|
err := c.ShouldBindJSON(&receivedValue)
|
|
if err != nil {
|
|
publicmethod.Result(100, receivedValue, c)
|
|
return
|
|
}
|
|
if receivedValue.Company == "" {
|
|
publicmethod.Result(101, receivedValue, c)
|
|
return
|
|
}
|
|
if receivedValue.Target == "" {
|
|
publicmethod.Result(101, receivedValue, c)
|
|
return
|
|
}
|
|
var zbz []matrixZhuBiaoZhoo
|
|
//获取公司下的最小主责部门
|
|
organizationList := publicmethod.GetMinMainDutyDeparment(receivedValue.Company)
|
|
var departmentList []int64
|
|
for _, dv := range organizationList {
|
|
if publicmethod.IsInTrue[int64](dv.Id, departmentList) == false {
|
|
var zbzCont matrixZhuBiaoZhoo
|
|
var ordCont modelshr.AdministrativeOrganization
|
|
ordCont.GetCont(map[string]interface{}{"`id`": dv.Id}, "`name`")
|
|
zbzCont.Id = strconv.FormatInt(dv.Id, 10)
|
|
zbzCont.Name = ordCont.Name
|
|
zbz = append(zbz, zbzCont)
|
|
departmentList = append(departmentList, dv.Id)
|
|
}
|
|
}
|
|
//获取该指标下的所有细则
|
|
var targetList []modelskpi.DetailedTarget
|
|
overall.CONSTANT_DB_KPI.Where("`dt_state` = 1 AND `dt_parentid` = ?", receivedValue.Target).Order("dt_parentid ASC").Order("dt_parentid_sun ASC").Find(&targetList)
|
|
if len(targetList) < 1 {
|
|
publicmethod.Result(105, receivedValue, c)
|
|
return
|
|
}
|
|
var sendDataList []rulesMatrixParaList
|
|
for _, v := range targetList {
|
|
var sendDataCont rulesMatrixParaList
|
|
|
|
sendDataCont.Id = v.Id
|
|
sendDataCont.Title = v.Title //指标细则"`
|
|
sendDataCont.Content = v.Content //指标说明"`
|
|
sendDataCont.ParentId = v.ParentId //归属指标栏目"`
|
|
sendDataCont.ParentIdSun = v.ParentIdSun //归属指标子栏目"`
|
|
sendDataCont.State = v.State //状态(1:启用;2:禁用;3:删除)"`
|
|
sendDataCont.AddTime = v.AddTime //制定时间"`
|
|
sendDataCont.MinScore = v.MinScore //最小分*100保存"`
|
|
sendDataCont.MaxScore = v.MaxScore //100保存"`
|
|
sendDataCont.Company = v.Company //单位"`
|
|
sendDataCont.AddReduce = v.AddReduce //1:减少;2:增加;3:无属性,现场确认加或减"`
|
|
sendDataCont.CensorType = v.CensorType //检查方式"`
|
|
sendDataCont.CensorCont = v.CensorCont //检查依据"`
|
|
sendDataCont.CensorRate = v.CensorRate //检查频次"`
|
|
sendDataCont.Cycles = v.Cycles //1:班;2:天;3:周;4:月;5:季度;6:年"`
|
|
sendDataCont.CycleAttres = v.CycleAttres //辅助计数"`
|
|
sendDataCont.Paretment = v.Paretment //接受考核的部门"`
|
|
sendDataCont.Reportary = v.Reportary //提报人"`
|
|
|
|
standardStr := ""
|
|
if v.MinScore != 0 {
|
|
standardStr = fmt.Sprintf("%v-%v", publicmethod.DecimalEs(float64(v.MinScore)/100, 2), publicmethod.DecimalEs(float64(v.MaxScore)/100, 2))
|
|
} else {
|
|
standardStr = fmt.Sprintf("%v", publicmethod.DecimalEs(float64(v.MaxScore)/100, 2))
|
|
}
|
|
sendDataCont.Standard = standardStr
|
|
//子栏目信息
|
|
var sonTargetInfo modelskpi.QualitativeTarget
|
|
sonTargetInfo.GetCont(map[string]interface{}{"`q_id`": v.ParentIdSun}, "q_title")
|
|
sendDataCont.SonTargetName = sonTargetInfo.Title
|
|
sendDataCont.CensorTypeList = strings.Split(v.CensorType, ",")
|
|
|
|
relationOrg := GetRulesDepartment(v.ParentId, v.ParentIdSun, v.Id, 1)
|
|
for i := 0; i < len(departmentList); i++ {
|
|
// var matrDepart matrixDepartment
|
|
// matrDepart.Id = strconv.FormatInt(departmentList[i], 10)
|
|
// var ordCont modelshr.AdministrativeOrganization
|
|
// ordCont.GetCont(map[string]interface{}{"`id`": departmentList[i]}, "`name`")
|
|
// matrDepart.Name = ordCont.Name
|
|
if publicmethod.IsInTrue[int64](departmentList[i], relationOrg) == true {
|
|
// fmt.Printf("relationOrg--------True------>%v------>%v\n", v.Id, departmentList[i])
|
|
sendDataCont.IsTrue = append(sendDataCont.IsTrue, 1)
|
|
// matrDepart.IsTrue = 1
|
|
} else {
|
|
// fmt.Printf("relationOrg--------False------>%v------>%v\n", v.Id, departmentList[i])
|
|
sendDataCont.IsTrue = append(sendDataCont.IsTrue, 0)
|
|
// matrDepart.IsTrue = 0
|
|
}
|
|
// sendDataCont.DepartmentIsTrue = append(sendDataCont.DepartmentIsTrue, matrDepart)
|
|
}
|
|
sendDataList = append(sendDataList, sendDataCont)
|
|
|
|
}
|
|
sendMap := publicmethod.MapOut[string]()
|
|
// orgJson, _ := json.Marshal(organizationList)
|
|
// fmt.Printf("orgJson-------------->%v\n", string(orgJson))
|
|
sendMap["list"] = sendDataList
|
|
sendMap["department"] = zbz
|
|
publicmethod.Result(0, sendMap, c)
|
|
}
|
|
|
|
/*
|
|
获取指标细则关联部门
|
|
@target 指标
|
|
@sonTarget 子栏目
|
|
@bylaws 细则
|
|
@level 级别(1:部门级;2:岗位级)"`
|
|
*/
|
|
func GetRulesDepartment(target, sonTarget, bylaws int64, level int) (orgId []int64) {
|
|
// var targetDepartmentList []modelskpi.TargetDetailedRelationDepartment
|
|
// var
|
|
overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetDetailedRelationDepartment{}).Distinct("`tddepartment`").Where("`dt_state` = 1 AND `dt_parentid` = ? AND `dt_parentid_sun` = ? AND `dt_id` = ? AND `level` = ?", target, sonTarget, bylaws, level).Find(&orgId)
|
|
// var snedId []int64
|
|
// for _, v := range orgId {
|
|
// snedId = append(snedId, publicmethod.GetGroupOrDepartPower(v, 1))
|
|
|
|
// }
|
|
// fmt.Printf("orgId----------->%v----------->%v\n", orgId, snedId)
|
|
return
|
|
}
|
|
|