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.
406 lines
13 KiB
406 lines
13 KiB
|
4 years ago
|
package quantification
|
||
|
|
|
||
|
|
import (
|
||
|
|
"fmt"
|
||
|
|
"strconv"
|
||
|
|
|
||
|
|
"github.com/flipped-aurora/gin-vue-admin/server/commonus"
|
||
|
|
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||
|
|
"github.com/flipped-aurora/gin-vue-admin/server/model/assessmentmodel"
|
||
|
|
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
|
||
|
|
"github.com/flipped-aurora/gin-vue-admin/server/model/hrsystem"
|
||
|
|
"github.com/gin-gonic/gin"
|
||
|
|
)
|
||
|
|
|
||
|
|
//量化考核图标
|
||
|
|
func (a *ApiGroup) GetQuantEChartOrgAndYear(c *gin.Context) {
|
||
|
|
isTrue, _ := commonus.ClientIdentity()
|
||
|
|
if isTrue != true {
|
||
|
|
response.Result(101, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
var requestData getTargetId[string]
|
||
|
|
err := c.ShouldBindJSON(&requestData)
|
||
|
|
if err != nil {
|
||
|
|
response.Result(102, err, "数据获取失败!", c)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
if len(requestData.TargetId) < 1 {
|
||
|
|
response.Result(102, err, "未获取到指标", c)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
var accDepart []string
|
||
|
|
var yearTime []string
|
||
|
|
var orgMap []orgModelsAry
|
||
|
|
for _, v := range requestData.TargetId {
|
||
|
|
var flowLogList []assessmentmodel.FlowLog
|
||
|
|
floLogErr := global.GVA_DB_Performanceappraisal.Where("FIND_IN_SET(?,`fl_evaluation_id`)", v).Find(&flowLogList).Error
|
||
|
|
if floLogErr == nil {
|
||
|
|
for _, fv := range flowLogList {
|
||
|
|
fvDepartId := strconv.FormatInt(fv.DutyDepartment, 10)
|
||
|
|
if commonus.IsItTrueString(fvDepartId, accDepart) == false {
|
||
|
|
accDepart = append(accDepart, fvDepartId)
|
||
|
|
}
|
||
|
|
yearStr := strconv.FormatInt(int64(fv.Year), 10)
|
||
|
|
if commonus.IsItTrueString(yearStr, yearTime) == false {
|
||
|
|
yearTime = append(yearTime, yearStr)
|
||
|
|
}
|
||
|
|
//判断组织架构是否有数据
|
||
|
|
if len(orgMap) > 0 {
|
||
|
|
for oi, ov := range orgMap {
|
||
|
|
//判断公司是否已经存在
|
||
|
|
if ov.Id == strconv.FormatInt(fv.DutyGroup, 10) {
|
||
|
|
//判断是否有分厂数据
|
||
|
|
if len(ov.Child) > 0 {
|
||
|
|
isYes := true
|
||
|
|
for _, dv := range ov.Child {
|
||
|
|
if dv.Id == strconv.FormatInt(fv.DutyDepartment, 10) {
|
||
|
|
isYes = false //该部门分厂已经存在
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if isYes == true {
|
||
|
|
//该部门分厂不存在是添加
|
||
|
|
//写入部门
|
||
|
|
whereDepart := commonus.MapOut()
|
||
|
|
whereDepart["id"] = fv.DutyDepartment
|
||
|
|
orgDepartCont, orgDepartErr := commonus.GetNewOrgCont(whereDepart, "name")
|
||
|
|
if orgDepartErr == nil {
|
||
|
|
var orgDepartMapCont orgModels
|
||
|
|
orgDepartMapCont.Id = strconv.FormatInt(fv.DutyDepartment, 10)
|
||
|
|
orgDepartMapCont.Name = orgDepartCont.Name
|
||
|
|
orgMap[oi].Child = append(orgMap[oi].Child, orgDepartMapCont)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
//没有分厂数据,根据上级数据进行新增
|
||
|
|
if fv.DutyDepartment != 0 {
|
||
|
|
//写入部门
|
||
|
|
whereDepart := commonus.MapOut()
|
||
|
|
whereDepart["id"] = fv.DutyDepartment
|
||
|
|
orgDepartCont, orgDepartErr := commonus.GetNewOrgCont(whereDepart, "name")
|
||
|
|
if orgDepartErr == nil {
|
||
|
|
var orgDepartMapCont orgModels
|
||
|
|
orgDepartMapCont.Id = strconv.FormatInt(fv.DutyDepartment, 10)
|
||
|
|
orgDepartMapCont.Name = orgDepartCont.Name
|
||
|
|
orgMap[oi].Child = append(orgMap[oi].Child, orgDepartMapCont)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
} else {
|
||
|
|
if fv.DutyGroup != 0 {
|
||
|
|
//写入集团信息
|
||
|
|
where := commonus.MapOut()
|
||
|
|
where["id"] = fv.DutyGroup
|
||
|
|
orgGroupCont, orgGroupErr := commonus.GetNewOrgCont(where, "name")
|
||
|
|
if orgGroupErr == nil {
|
||
|
|
var orgMapCont orgModelsAry
|
||
|
|
orgMapCont.Id = strconv.FormatInt(fv.DutyGroup, 10)
|
||
|
|
orgMapCont.Name = orgGroupCont.Name
|
||
|
|
|
||
|
|
if fv.DutyDepartment != 0 {
|
||
|
|
//写入部门
|
||
|
|
whereDepart := commonus.MapOut()
|
||
|
|
whereDepart["id"] = fv.DutyDepartment
|
||
|
|
orgDepartCont, orgDepartErr := commonus.GetNewOrgCont(whereDepart, "name")
|
||
|
|
if orgDepartErr == nil {
|
||
|
|
var orgDepartMapCont orgModels
|
||
|
|
orgDepartMapCont.Id = strconv.FormatInt(fv.DutyDepartment, 10)
|
||
|
|
orgDepartMapCont.Name = orgDepartCont.Name
|
||
|
|
orgMapCont.Child = append(orgMapCont.Child, orgDepartMapCont)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
orgMap = append(orgMap, orgMapCont)
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
//没有数据的时候根据数值进行新增
|
||
|
|
if fv.DutyGroup != 0 {
|
||
|
|
//写入集团信息
|
||
|
|
where := commonus.MapOut()
|
||
|
|
where["id"] = fv.DutyGroup
|
||
|
|
orgGroupCont, orgGroupErr := commonus.GetNewOrgCont(where, "name")
|
||
|
|
if orgGroupErr == nil {
|
||
|
|
var orgMapCont orgModelsAry
|
||
|
|
orgMapCont.Id = strconv.FormatInt(fv.DutyGroup, 10)
|
||
|
|
orgMapCont.Name = orgGroupCont.Name
|
||
|
|
|
||
|
|
if fv.DutyDepartment != 0 {
|
||
|
|
//写入部门
|
||
|
|
whereDepart := commonus.MapOut()
|
||
|
|
whereDepart["id"] = fv.DutyDepartment
|
||
|
|
orgDepartCont, orgDepartErr := commonus.GetNewOrgCont(whereDepart, "name")
|
||
|
|
if orgDepartErr == nil {
|
||
|
|
var orgDepartMapCont orgModels
|
||
|
|
orgDepartMapCont.Id = strconv.FormatInt(fv.DutyDepartment, 10)
|
||
|
|
orgDepartMapCont.Name = orgDepartCont.Name
|
||
|
|
orgMapCont.Child = append(orgMapCont.Child, orgDepartMapCont)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
orgMap = append(orgMap, orgMapCont)
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
outMap := commonus.MapOut()
|
||
|
|
outMap["grouplist"] = orgMap
|
||
|
|
outMap["timelist"] = yearTime
|
||
|
|
response.Result(0, outMap, "数据获取失败!", c)
|
||
|
|
}
|
||
|
|
|
||
|
|
//量化考核图标
|
||
|
|
func (a *ApiGroup) QuantEChart(c *gin.Context) {
|
||
|
|
isTrue, _ := commonus.ClientIdentity()
|
||
|
|
if isTrue != true {
|
||
|
|
response.Result(101, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
var requestData natureParameter
|
||
|
|
c.ShouldBindJSON(&requestData)
|
||
|
|
// err := c.ShouldBindJSON(&requestData)
|
||
|
|
// if err != nil {
|
||
|
|
// response.Result(102, err, "数据获取失败!", c)
|
||
|
|
// return
|
||
|
|
// }
|
||
|
|
if len(requestData.TargetId) < 1 {
|
||
|
|
response.Result(103, requestData, "未获取到指标", c)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
if requestData.AnalysisAngle == 0 {
|
||
|
|
requestData.AnalysisAngle = 1
|
||
|
|
}
|
||
|
|
outMap := commonus.MapOut()
|
||
|
|
var graphicStatistics GraphicStatistics
|
||
|
|
for _, v := range requestData.TargetId {
|
||
|
|
// var qualEvalCont assessmentmodel.QualitativeEvaluation
|
||
|
|
// qualEvaWhe := commonus.MapOut()
|
||
|
|
// qualEvaWhe["qe_id"] = v
|
||
|
|
// qualEvalCont.GetCont(qualEvaWhe, "qe_target")
|
||
|
|
// calculationEvaluation(qualEvalCont.Target, requestData)
|
||
|
|
// calculationEvaluation(v, requestData)
|
||
|
|
// kjs, kjddd := calculationEvaluation(v, requestData)
|
||
|
|
// jsonStr, jsonEr := json.Marshal(kjs)
|
||
|
|
// fmt.Printf("task------------>%v----->%v----->%v\n", string(jsonStr), jsonEr, kjddd)
|
||
|
|
|
||
|
|
// outMap["TimeDimension_"+v] = TimeDimension(v, requestData)
|
||
|
|
if requestData.AnalysisAngle == 1 {
|
||
|
|
getStatistics, gstErr := OrgDimensionStatistics(v, requestData)
|
||
|
|
outMap["TimeDimension_"+v] = getStatistics
|
||
|
|
if gstErr == true {
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
//时间维度
|
||
|
|
getStatistics, gstErr := TimeDimensionStatistics(v, requestData)
|
||
|
|
outMap["TimeDimension_"+v] = getStatistics
|
||
|
|
if gstErr == true {
|
||
|
|
for _, gsv := range getStatistics.XLine {
|
||
|
|
if commonus.IsItTrueString(gsv, graphicStatistics.XLine) == false {
|
||
|
|
graphicStatistics.XLine = append(graphicStatistics.XLine, gsv)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
for _, cilv := range getStatistics.Cylindrical {
|
||
|
|
if commonus.IsItTrueString(cilv, graphicStatistics.Cylindrical) == false {
|
||
|
|
graphicStatistics.Cylindrical = append(graphicStatistics.Cylindrical, cilv)
|
||
|
|
for _, cdv := range getStatistics.CylindricalData {
|
||
|
|
if cdv.Name == cilv {
|
||
|
|
graphicStatistics.CylindricalData = append(graphicStatistics.CylindricalData, cdv)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
// getStatistics, gstErr := TimeDimensionStatistics(v, requestData)
|
||
|
|
// fmt.Println(gstErr)
|
||
|
|
|
||
|
|
}
|
||
|
|
outMap["graphicStatistics"] = graphicStatistics
|
||
|
|
response.Result(0, graphicStatistics, "图形数据", c)
|
||
|
|
}
|
||
|
|
|
||
|
|
//获取行政组织
|
||
|
|
func getGroupOrg(orgAry []string) (orgMap []orgModelsAry, orgWherList []orgModels) {
|
||
|
|
|
||
|
|
var govMap []OutGovCont
|
||
|
|
orgErr := global.GVA_DB_HrDataBase.Model(&hrsystem.AdministrativeOrganization{}).Select("administrative_organization.*,aot.name as classname,aot.level").Joins("left join administrative_organization_type as aot on aot.id = administrative_organization.organization_type").Where("administrative_organization.`state` = 1 AND administrative_organization.id IN ?", orgAry).Find(&govMap).Error
|
||
|
|
if orgErr != nil {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
// fmt.Printf("%v\n", govMap)
|
||
|
|
|
||
|
|
for _, v := range govMap {
|
||
|
|
|
||
|
|
if len(orgMap) > 0 {
|
||
|
|
if v.Level > 2 {
|
||
|
|
groupId, groupIsTrue := commonus.GetNewHrOrg(v.Id)
|
||
|
|
if groupIsTrue == true {
|
||
|
|
newAdd := true
|
||
|
|
for gii, gvv := range orgMap {
|
||
|
|
if gvv.Id == strconv.FormatInt(groupId, 10) {
|
||
|
|
newAdd = false
|
||
|
|
for _, sgv := range orgMap[gii].Child {
|
||
|
|
if sgv.Id != strconv.FormatInt(v.Id, 10) {
|
||
|
|
var orgSun orgModels
|
||
|
|
orgSun.Id = strconv.FormatInt(v.Id, 10)
|
||
|
|
orgSun.Name = v.Name
|
||
|
|
orgSun.Level = v.Level
|
||
|
|
if v.Abbreviation != "" {
|
||
|
|
orgSun.Name = v.Abbreviation
|
||
|
|
}
|
||
|
|
orgMap[gii].Child = append(orgMap[gii].Child, orgSun)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if newAdd == true {
|
||
|
|
where := commonus.MapOut()
|
||
|
|
where["id"] = groupId
|
||
|
|
orgGroupCont, orgGroupErr := commonus.GetNewOrgCont(where, "name", "organization_type")
|
||
|
|
|
||
|
|
if orgGroupErr == nil {
|
||
|
|
var groupInfo orgModelsAry
|
||
|
|
groupInfo.Id = strconv.FormatInt(groupId, 10)
|
||
|
|
groupInfo.Name = orgGroupCont.Name
|
||
|
|
if orgGroupCont.Abbreviation != "" {
|
||
|
|
groupInfo.Name = orgGroupCont.Abbreviation
|
||
|
|
}
|
||
|
|
var aotModel hrsystem.AdministrativeOrganizationType
|
||
|
|
where := commonus.MapOut()
|
||
|
|
where["id"] = orgGroupCont.OrganizationType
|
||
|
|
aotModel.GetCont(where, "level")
|
||
|
|
groupInfo.Level = aotModel.Level
|
||
|
|
var orgSun orgModels
|
||
|
|
orgSun.Id = strconv.FormatInt(v.Id, 10)
|
||
|
|
orgSun.Name = v.Name
|
||
|
|
if v.Abbreviation != "" {
|
||
|
|
orgSun.Name = v.Abbreviation
|
||
|
|
}
|
||
|
|
orgSun.Level = v.Level
|
||
|
|
groupInfo.Child = append(groupInfo.Child, orgSun)
|
||
|
|
orgMap = append(orgMap, groupInfo)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
for _, gv := range orgMap {
|
||
|
|
if gv.Id != strconv.FormatInt(v.Id, 10) {
|
||
|
|
var groupInfo orgModelsAry
|
||
|
|
groupInfo.Id = strconv.FormatInt(v.Id, 10)
|
||
|
|
groupInfo.Name = v.Name
|
||
|
|
if v.Abbreviation != "" {
|
||
|
|
groupInfo.Name = v.Abbreviation
|
||
|
|
}
|
||
|
|
groupInfo.Level = v.Level
|
||
|
|
orgMap = append(orgMap, groupInfo)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
} else {
|
||
|
|
if v.Level > 2 {
|
||
|
|
groupId, groupIsTrue := commonus.GetNewHrOrg(v.Id)
|
||
|
|
if groupIsTrue == true {
|
||
|
|
where := commonus.MapOut()
|
||
|
|
where["id"] = groupId
|
||
|
|
orgGroupCont, orgGroupErr := commonus.GetNewOrgCont(where, "name", "abbreviation", "organization_type")
|
||
|
|
if orgGroupErr == nil {
|
||
|
|
var groupInfo orgModelsAry
|
||
|
|
groupInfo.Id = strconv.FormatInt(groupId, 10)
|
||
|
|
groupInfo.Name = orgGroupCont.Name
|
||
|
|
if orgGroupCont.Abbreviation != "" {
|
||
|
|
groupInfo.Name = orgGroupCont.Abbreviation
|
||
|
|
}
|
||
|
|
var aotModel hrsystem.AdministrativeOrganizationType
|
||
|
|
where := commonus.MapOut()
|
||
|
|
where["id"] = orgGroupCont.OrganizationType
|
||
|
|
aotModel.GetCont(where, "level")
|
||
|
|
groupInfo.Level = aotModel.Level
|
||
|
|
|
||
|
|
var orgSun orgModels
|
||
|
|
orgSun.Id = strconv.FormatInt(v.Id, 10)
|
||
|
|
orgSun.Name = v.Name
|
||
|
|
if v.Abbreviation != "" {
|
||
|
|
orgSun.Name = v.Abbreviation
|
||
|
|
}
|
||
|
|
orgSun.Level = v.Level
|
||
|
|
groupInfo.Child = append(groupInfo.Child, orgSun)
|
||
|
|
orgMap = append(orgMap, groupInfo)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
var groupInfo orgModelsAry
|
||
|
|
groupInfo.Id = strconv.FormatInt(v.Id, 10)
|
||
|
|
groupInfo.Name = v.Name
|
||
|
|
if v.Abbreviation != "" {
|
||
|
|
groupInfo.Name = v.Abbreviation
|
||
|
|
}
|
||
|
|
groupInfo.Level = v.Level
|
||
|
|
orgMap = append(orgMap, groupInfo)
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
if len(orgMap) > 0 {
|
||
|
|
for _, ov := range orgMap {
|
||
|
|
|
||
|
|
if len(orgWherList) > 0 {
|
||
|
|
isInGroup := true //界定是否写入
|
||
|
|
for _, olv := range orgWherList {
|
||
|
|
if ov.Id == olv.Id {
|
||
|
|
isInGroup = false
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if isInGroup == true {
|
||
|
|
var orgList orgModels
|
||
|
|
orgList.Id = ov.Id
|
||
|
|
orgList.Name = ov.Name
|
||
|
|
orgList.Level = ov.Level
|
||
|
|
orgWherList = append(orgWherList, orgList)
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
var orgList orgModels
|
||
|
|
orgList.Id = ov.Id
|
||
|
|
orgList.Name = ov.Name
|
||
|
|
orgList.Level = ov.Level
|
||
|
|
orgWherList = append(orgWherList, orgList)
|
||
|
|
}
|
||
|
|
//判断是否有下级菜单
|
||
|
|
if len(ov.Child) > 0 {
|
||
|
|
for _, ocv := range ov.Child {
|
||
|
|
if len(orgWherList) > 0 {
|
||
|
|
isIn := true //界定是否写入
|
||
|
|
for _, olv := range orgWherList {
|
||
|
|
if ocv.Id == olv.Id {
|
||
|
|
isIn = false
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if isIn == true {
|
||
|
|
var orgList orgModels
|
||
|
|
orgList.Id = ocv.Id
|
||
|
|
orgList.Name = fmt.Sprintf("%v%v", ov.Name, ocv.Name)
|
||
|
|
orgList.Level = ocv.Level
|
||
|
|
orgWherList = append(orgWherList, orgList)
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
var orgList orgModels
|
||
|
|
orgList.Id = ocv.Id
|
||
|
|
orgList.Name = fmt.Sprintf("%v%v", ov.Name, ocv.Name)
|
||
|
|
orgList.Level = ocv.Level
|
||
|
|
orgWherList = append(orgWherList, orgList)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return
|
||
|
|
}
|