diff --git a/api/version1/departmentseting/departmentpc/rulesmatrix.go b/api/version1/departmentseting/departmentpc/rulesmatrix.go new file mode 100644 index 0000000..9358e90 --- /dev/null +++ b/api/version1/departmentseting/departmentpc/rulesmatrix.go @@ -0,0 +1,66 @@ +package departmentpc + +import ( + "encoding/json" + "fmt" + "key_performance_indicators/models/modelskpi" + "key_performance_indicators/overall" + "key_performance_indicators/overall/publicmethod" + + "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 + } + //获取公司下的最小主责部门 + organizationList := publicmethod.GetMinMainDutyDeparment(receivedValue.Company) + //获取该指标下的所有细则 + 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 + } + for _, v := range targetList { + relationOrg := GetRulesDepartment(v.ParentId, v.ParentIdSun, v.Id, 1) + // for + + } + + orgJson, _ := json.Marshal(organizationList) + fmt.Printf("orgJson-------------->%v\n", string(orgJson)) +} + +/* +获取指标细则关联部门 +@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 +} diff --git a/api/version1/departmentseting/departmentpc/type.go b/api/version1/departmentseting/departmentpc/type.go index 408b771..8ddf100 100644 --- a/api/version1/departmentseting/departmentpc/type.go +++ b/api/version1/departmentseting/departmentpc/type.go @@ -198,3 +198,9 @@ type LoopStruct struct { publicmethod.PublicId Child []LoopStruct `json:"child"` } + +// 定性指标细则与部门矩阵参数 +type rulesMatrixParameter struct { + Company string `json:"company"` + Target string `json:"target"` +} diff --git a/apirouter/v1/departmentseting/pc.go b/apirouter/v1/departmentseting/pc.go index 318f3a5..fb56db8 100644 --- a/apirouter/v1/departmentseting/pc.go +++ b/apirouter/v1/departmentseting/pc.go @@ -43,5 +43,8 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) { apiRouter.POST("deparment_target_about_post", methodBinding.DeparmentTargetAboutPost) //指标关联岗位 apiRouter.POST("depar_son_target_about_post", methodBinding.DeparSonTargetAboutPost) //子栏目关联部门岗位 apiRouter.POST("depar_detaile_about_post", methodBinding.DeparDetaileAboutPost) //指标细则关联部门岗位 + //部门指标与部门关系举证 + apiRouter.POST("department_rules_matrix", methodBinding.DepartmentRulesMatrix) //定性指标细则与部门矩阵 + } } diff --git a/models/modelskpi/target_detailed_relation_department.go b/models/modelskpi/target_detailed_relation_department.go new file mode 100644 index 0000000..5ee3881 --- /dev/null +++ b/models/modelskpi/target_detailed_relation_department.go @@ -0,0 +1,84 @@ +package modelskpi + +import ( + "key_performance_indicators/overall" + "strings" +) + +//部门考核细则关联部门视图 +//target_detailed_relation_department + +// 指标、栏目、细则关联部门 +type TargetDetailedRelationDepartment struct { + Id int64 `json:"id" gorm:"primaryKey;column:dt_id;type:bigint(20) unsigned;not null;comment:Id;index"` + Title string `json:"title" gorm:"column:dt_title;type:text;comment:指标细则"` + Content string `json:"content" gorm:"column:dt_content;type:text;comment:指标说明"` + ParentId int64 `json:"parentid" gorm:"column:dt_parentid;type:bigint(20) unsigned;default:0;not null;comment:归属指标栏目"` + ParentIdSun int64 `json:"parentidsun" gorm:"column:dt_parentid_sun;type:bigint(20) unsigned;default:0;not null;comment:归属指标子栏目"` + State int `json:"state" gorm:"column:dt_state;type:int(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` + AddTime int64 `json:"addtime" gorm:"column:dt_time;type:bigint(20) unsigned;default:0;not null;comment:制定时间"` + MinScore int64 `json:"minscore" gorm:"column:dt_min_score;type:bigint(20) unsigned;default:0;not null;comment:最小分*100保存"` + MaxScore int64 `json:"maxscore" gorm:"column:dt_max_score;type:bigint(20) unsigned;default:0;not null;comment:最大分*100保存"` + Company string `json:"company" gorm:"column:dt_company;type:varchar(20) unsigned;default:0;not null;comment:单位"` + AddReduce int `json:"addreduce" gorm:"column:dt_add_reduce;type:int(1) unsigned;default:1;not null;comment:1:减少;2:增加;3:无属性,现场确认加或减"` + CensorType string `json:"censortype" gorm:"column:dt_censor_type;type:text;comment:检查方式"` + CensorCont string `json:"censorcont" gorm:"column:dt_censor_cont;type:longtext;comment:检查依据"` + CensorRate int `json:"censorrate" gorm:"column:dt_censor_rate;type:int(5) unsigned;default:1;not null;comment:检查频次"` + Cycles int `json:"cycle" gorm:"column:dt_cycle;type:tinyint(1) unsigned;default:1;not null;comment:1:班;2:天;3:周;4:月;5:季度;6:年"` + CycleAttres int `json:"cycleattr" gorm:"column:dt_cycleattr;type:int(9) unsigned;default:1;not null;comment:辅助计数"` + Paretment string `json:"paretment" gorm:"column:dt_paretment;type:longtext;comment:接受考核的部门"` + Reportary string `json:"reportary" gorm:"column:reportary;type:longtext;comment:提报人"` + //关联表 + Dimension int64 `json:"dimension" gorm:"column:dimensionid;type:bigint(20) unsigned;default:0;not null;comment:维度"` + Type int `json:"type" gorm:"column:type;tdtype:tinyint(1) unsigned;default:1;not null;comment:类型(1:指标;2:子目标;3:细则)"` + DepartmentId int64 `json:"departmentid" gorm:"column:tddepartment;type:bigint(20) unsigned;default:0;not null;comment:部门ID"` + PostId int64 `json:"postid" gorm:"column:postid;type:bigint(20) unsigned;default:0;not null;comment:岗位ID"` + TdState int `json:"tastate" gorm:"column:tastate;type:tinyint(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` + Class int `json:"class" gorm:"column:tdclass;type:tinyint(1) unsigned;default:1;not null;comment:1:定性考核;2:定量考核"` + Level int `json:"level" gorm:"column:level;type:tinyint(1) unsigned;default:1;not null;comment:级别(1:部门级;2:岗位级)"` +} + +func (TargetDetailedRelationDepartment *TargetDetailedRelationDepartment) TableName() string { + return "target_detailed_relation_department" +} + +// 编辑内容 +func (cont *TargetDetailedRelationDepartment) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Updates(saveData).Error + return +} + +// 获取内容 +func (cont *TargetDetailedRelationDepartment) GetCont(whereMap interface{}, field ...string) (err error) { + gormDb := overall.CONSTANT_DB_KPI.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + gormDb = gormDb.Where(whereMap) + err = gormDb.First(&cont).Error + return +} + +// 根据条件获取总数 +func (cont *TargetDetailedRelationDepartment) CountCont(whereMap interface{}) (countId int64) { + overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Count(&countId) + return +} + +// 读取全部信息 +func (cont *TargetDetailedRelationDepartment) ContMap(whereMap interface{}, field ...string) (countAry []TargetDetailedRelationDepartment, err error) { + gormDb := overall.CONSTANT_DB_KPI.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + err = gormDb.Where(whereMap).Order("sort ASC").Find(&countAry).Error + return +} + +// 删除内容 +func (cont *TargetDetailedRelationDepartment) DelCont(whereMap interface{}) (err error) { + err = overall.CONSTANT_DB_KPI.Where(whereMap).Delete(&cont).Error + return +} diff --git a/overall/publicmethod/technique.go b/overall/publicmethod/technique.go index 2e0634c..632b533 100644 --- a/overall/publicmethod/technique.go +++ b/overall/publicmethod/technique.go @@ -770,3 +770,29 @@ func getStorageSystemEmpower(menuIdAry []string) (menuUrl []string, err error) { } return } + +// 获取公司最小主责部门 +func GetMinMainDutyDeparment(company string) (organization []modelshr.AdministrativeOrganization) { + var allOrg []modelshr.AdministrativeOrganization + err := overall.CONSTANT_DB_HR.Model(&modelshr.AdministrativeOrganization{}).Where("ispower = 1 AND state = 1 AND organization_type > 2 AND superior = ?", company).Find(&allOrg).Error + if err != nil || len(allOrg) < 1 { + return + } + for _, v := range allOrg { + sunOrgList, orgSunErr := getSunOrgList(v.Id) + if orgSunErr == nil && len(sunOrgList) > 0 { + for _, sv := range sunOrgList { + organization = append(organization, sv) + } + } else { + organization = append(organization, v) + } + } + return +} + +// 获取下级行政组织是否有主行政部门 +func getSunOrgList(orgId int64) (orgList []modelshr.AdministrativeOrganization, ovErr error) { + ovErr = overall.CONSTANT_DB_HR.Where("state = 1").Where("ispower = 1 AND superior = ?", orgId).Find(&orgList).Error + return +}