diff --git a/api/shiyan/maptostruct/cang_chu.go b/api/shiyan/maptostruct/cang_chu.go new file mode 100644 index 0000000..fdbd2ad --- /dev/null +++ b/api/shiyan/maptostruct/cang_chu.go @@ -0,0 +1,171 @@ +package maptostruct + +import ( + "fmt" + "key_performance_indicators/models/modelsstorage" + "key_performance_indicators/overall" + "key_performance_indicators/overall/publicmethod" + + "github.com/gin-gonic/gin" +) + +/* +* +@ 作者: 秦东 +@ 时间: 2022-11-14 16:43:22 +@ 功能: 实验仓储类型树 +@ 参数 + + # + +@ 返回值 + + # +*/ +func (a *ApiMethod) CangChuThree(c *gin.Context) { + var mType []modelsstorage.MaterialType + overall.CONSTANT_DB_Storage.Where("`state` = 1").Find(&mType) + var toalVal int64 + // overall.CONSTANT_DB_Storage.Model(&modelsstorage.Material{}).Where("`state` = 1").Count(&toalVal) + // var materList []modelsstorage.Material + // err = overall.CONSTANT_DB_Storage.Find(&materList).Error + // var jibuq []int + // toalVal := 0 + var mTypeGroup []modelsstorage.MaterialType + var mttt readDataLock + for i, v := range mType { + + if (i+1)%100 == 0 { + syncSeting.Add(1) + mTypeGroup = append(mTypeGroup, v) + go mttt.chuLiType(mTypeGroup, toalVal) + mTypeGroup = []modelsstorage.MaterialType{} + } else { + mTypeGroup = append(mTypeGroup, v) + } + // if i == 0 { + // // syncSeting.Add(1) + // mTypeGroup = append(mTypeGroup, v) + // // go mttt.chuLiType(mTypeGroup, toalVal) + // } + } + if len(mTypeGroup) > 0 { + syncSeting.Add(1) + go mttt.chuLiType(mTypeGroup, toalVal) + } + syncSeting.Wait() + + // fmt.Printf("%v", mttt) + + var chanzongshu int + chanzongshu = 0 + for _, vvv := range mttt.MaterialAry { + chanzongshu = chanzongshu + len(vvv.MaterialList) + fmt.Printf("%v------>%v------>%v\n", vvv.Id, vvv.Name, len(vvv.MaterialList)) + } + + threeList := GetMenuThreePeiQuan(0, mttt.MaterialAry) + + outData := publicmethod.MapOut[string]() + outData["mttt_count"] = len(mttt.MaterialAry) + outData["chanzongshu"] = chanzongshu + // outData["mtttList"] = mttt.MaterialAry + outData["threeList"] = threeList + fmt.Printf("%v------>%v------>%v------>%v\n", len(mType), toalVal, toalVal/1000, toalVal%1000) + publicmethod.Result(0, outData, c) +} + +// 多类别数据处理 +func (m *readDataLock) chuLiType(mType []modelsstorage.MaterialType, toalVal int64) { + defer syncSeting.Done() + var idList []int64 + for _, v := range mType { + idList = append(idList, v.OrderId) + } + + pageSum := toalVal / 1000 + if toalVal%1000 > 0 { + pageSum = pageSum + 1 + } + var i int64 + for i = 1; i <= pageSum; i++ { + // pageSize := publicmethod.LimitPage64(i, 1000) + // fmt.Printf("第%v页,结束点%v\n", i, pageSize) + // syncSetings.Add(1) + // go m.Xiecheng(idList, pageSize, mType) + } + pageSize := publicmethod.LimitPage64(i, 1000) + syncSetings.Add(1) + go m.Xiecheng(idList, pageSize, mType) + syncSetings.Wait() + // fmt.Println("--------------------------------") +} + +func (m *readDataLock) Xiecheng(id []int64, pageSize int64, mType []modelsstorage.MaterialType) { + defer syncSetings.Done() + // pageSizeStr := strconv.FormatInt(pageSize, 10) + // pageSizeInt, _ := strconv.Atoi(pageSizeStr) + var materList []modelsstorage.Material + // overall.CONSTANT_DB_Storage.Where("`type_id` IN ? AND `state` = 1", id).Limit(1000).Offset(pageSizeInt).Find(&materList) + overall.CONSTANT_DB_Storage.Where("`type_id` IN ? AND `state` = 1", id).Find(&materList) + for _, v := range mType { + var materialCont MaterialCont + materialCont.Id = v.Id // + materialCont.Name = v.Name // 类型名称"` + materialCont.Introduce = v.Introduce // 类型介绍"` + materialCont.State = v.State //状态(启用2禁用3删除4不对其做任何操作)"` + materialCont.ParentId = v.ParentId //父级"` + materialCont.OrderId = v.OrderId //导入时id"` + for _, mv := range materList { + if v.OrderId == mv.TypeId { + var materialcont modelsstorage.Material + + materialcont.Id = mv.Id // `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;index"` + materialcont.DepositoryId = mv.DepositoryId // `json:"depositoryid" gorm:"column:depository_id;type:bigint(20) unsigned;default:0;not null;comment:仓库编号"` + materialcont.Name = mv.Name // `json:"name" gorm:"column:mname;type:varchar(100);comment:材料名称"` + materialcont.Quantity = mv.Quantity // `json:"quantity" gorm:"column:type;quantity:int(11) unsigned;default:1;not null;comment:数量"` + materialcont.Amounts = mv.Amounts // `json:"amounts" gorm:"column:amounts;type:int(11) unsigned;default:1;not null;comment:总金额"` + materialcont.TypeId = mv.TypeId // `json:"typeid" gorm:"column:type_id;type:bigint(20) unsigned;default:0;not null;comment:材料种类id"` + materialcont.State = mv.State // `json:"state" gorm:"column:state;type:int(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` + materialcont.Code = mv.Code // `json:"code" gorm:"column:code;type:varchar(255);comment:存货编码"` + materialcont.Version = mv.Version // `json:"version" gorm:"column:version;type:varchar(255);comment:规格型号"` + materialcont.Price = mv.Price // `json:"price" gorm:"column:price;type:int(11) unsigned;default:1;not null;comment:单价"` + materialcont.Unit = mv.Unit // `json:"unit" gorm:"column:unit;type:varchar(255);comment:计量单位"` + materialcont.Texture = mv.Texture // `json:"texture" gorm:"column:texture;type:varchar(255);comment:材质"` + materialcont.DepositoryCode = mv.DepositoryCode // `json:"depositoryCode" gorm:"column:depositoryCode;type:varchar(255);comment:货位码(存放位置)"` + materialcont.Kingdeecode = mv.Kingdeecode // `json:"kingdeecode" gorm:"column:kingdeecode;type:varchar(255);comment:计量单位"` + materialcont.NumberOfTemporary = mv.NumberOfTemporary // `json:"numberoftemporary" gorm:"column:number_of_temporary;type:int(11) unsigned;default:1;not null;comment:临时数目(临时出库数目)"` + + materialCont.MaterialList = append(materialCont.MaterialList, materialcont) + } + } + m.MaterialAry = append(m.MaterialAry, materialCont) + } +} + +// 递归无限极菜单树 +/* + +@parentId 上级ID +@threeData 结果值 + +*/ +func GetMenuThreePeiQuan(parentId int64, threeData []MaterialCont) []CaiDanShu { + treeList := []CaiDanShu{} + for _, v := range threeData { + if v.ParentId == parentId { + child := GetMenuThreePeiQuan(v.OrderId, threeData) + var node CaiDanShu + node.Id = v.Id // + node.Name = v.Name // 类型名称"` + node.Introduce = v.Introduce // 类型介绍"` + node.State = v.State //状态(启用2禁用3删除4不对其做任何操作)"` + node.ParentId = v.ParentId //父级"` + node.OrderId = v.OrderId //导入时id"` + node.MaterialList = v.MaterialList + node.Child = child + treeList = append(treeList, node) + } + } + return treeList +} diff --git a/api/shiyan/maptostruct/type.go b/api/shiyan/maptostruct/type.go index a48f379..f4a97a2 100644 --- a/api/shiyan/maptostruct/type.go +++ b/api/shiyan/maptostruct/type.go @@ -1,13 +1,34 @@ package maptostruct import ( + "key_performance_indicators/models/modelsstorage" "key_performance_indicators/overall/publicmethod" + "sync" "github.com/gin-gonic/gin" ) type ApiMethod struct{} +// 协程设置 +var syncSeting = sync.WaitGroup{} +var syncSetings = sync.WaitGroup{} + +type readDataLock struct { + MaterialAry []MaterialCont `json:"materialary"` +} + +type MaterialCont struct { + modelsstorage.MaterialType + MaterialList []modelsstorage.Material `json:"materiallist"` +} + +// 菜单树 +type CaiDanShu struct { + MaterialCont + Child []CaiDanShu `json:"child"` +} + // 实验入口 func (a *ApiMethod) Index(c *gin.Context) { outputCont := publicmethod.MapOut[string]() diff --git a/api/version1/jurisdiction/jurisdictionpc/power.go b/api/version1/jurisdiction/jurisdictionpc/power.go index 1fdabff..272ade6 100644 --- a/api/version1/jurisdiction/jurisdictionpc/power.go +++ b/api/version1/jurisdiction/jurisdictionpc/power.go @@ -529,3 +529,187 @@ func DiGuiMenuList(menuList []publicmethod.PowerThree, menuId, menuOperId []stri // fmt.Printf("menuOper--jieshuzhi->%v---->%v\n", menuIdList, menuOperIdList) return } + +/* +* +@ 作者: 秦东 +@ 时间: 2022-11-09 13:28:39 +@ 功能: 角色配权菜单 +@ 参数 + + # + +@ 返回值 + + # +*/ +func (a *ApiMethod) SystemRoleAboutMenu(c *gin.Context) { + var receivedValue GetSystemRoleMenuPower + err := c.ShouldBindJSON(&receivedValue) + if err != nil { + publicmethod.Result(100, err, c) + return + } + if receivedValue.Name == "" { + publicmethod.Result(101, err, c) + return + } + var systemPower modelssystempermission.Appsystem + err = systemPower.GetCont(map[string]interface{}{"`coder`": receivedValue.Name}) + if err != nil { + publicmethod.Result(105, err, c) + return + } + if systemPower.State == 2 { + publicmethod.Result(1, err, c, "该系统授权已经禁用!") + return + } + if systemPower.State == 3 { + publicmethod.Result(1, err, c, "该系统授权已经取消合作!") + return + } + var menuThree []publicmethod.PowerThree + // fmt.Printf("ApiUrl------>%v\n", receivedValue) + if systemPower.ApiUrl != "" { + //api入口不为空的情况下采用get访问方式接收数据 + htmlByte := publicmethod.CurlGet(systemPower.ApiUrl) + fmt.Printf("%v\n", string(htmlByte)) + var jsonAry callBackUrlMenu + jsonErr := json.Unmarshal(htmlByte, &jsonAry) + if jsonErr != nil { + publicmethod.Result(1, jsonErr, c, "数据获取错误!") + return + } + if jsonAry.Code != 0 { + publicmethod.Result(1, jsonErr, c, jsonAry.Msg) + return + } + menuThree = jsonAry.Data + } else { + var pointInt []string + var operatIon []string + var systemEmpowerCont modelssystempermission.RoleEmpower + err = systemEmpowerCont.GetCont(map[string]interface{}{"`role_id`": receivedValue.RoleId, "`system`": systemPower.Coder}, "`point_id`", `operation`) + if err == nil { + pointInt = strings.Split(systemEmpowerCont.PointId, ",") + operatIon = strings.Split(systemEmpowerCont.Operation, ",") + } + //api入口为空,采用系统内置获取授权菜单 + switch systemPower.Coder { + case "cangchu": + menuThree = wmsMenuThree(pointInt, operatIon) + // fmt.Printf("ApiUrl----2-->%v\n", systemPower.ApiUrl) + default: + //获取绩效考核菜单树 + menuThree = kpiMenuThree(pointInt, operatIon) + // fmt.Printf("ApiUrl---1--->%v\n", systemPower.ApiUrl) + } + } + publicmethod.Result(0, menuThree, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2022-11-07 13:46:06 +@ 功能: 编辑权限新版(角色) +@ 参数 + + # + +@ 返回值 + + # +*/ +func (a *ApiMethod) EditRolePowerNew(c *gin.Context) { + var receivedValue editRolePowerStructNew + err := c.ShouldBindJSON(&receivedValue) + if err != nil { + publicmethod.Result(100, err, c) + return + } + if receivedValue.RoleId == "" || receivedValue.RoleId == "0" { + publicmethod.Result(1, receivedValue, c, "未知角色!不可进行配权") + return + } + + if receivedValue.SystemName == "" { + publicmethod.Result(1, receivedValue, c, "未知配权系统!不可进行配权") + return + } + if receivedValue.Level == 0 { + receivedValue.Level = 2 + } + + var menuList []string //权限点位 + var menuOperationList []string //操作点位 + addTime := time.Now().Unix() + var empowerCont modelssystempermission.RoleEmpower + err = empowerCont.GetCont(map[string]interface{}{"`role_id`": receivedValue.RoleId, "`system`": receivedValue.SystemName}, "`id`") + if len(receivedValue.PowerList) < 1 { + if err == nil { + err = empowerCont.EiteCont(map[string]interface{}{"`id`": empowerCont.Id}, map[string]interface{}{"`point_id`": "", "`operation`": "", "`level`": receivedValue.Level, "`time`": addTime, "`state`": 1}) + if err != nil { + publicmethod.Result(1, err, c, "权限配置失败") + return + } + } else { + roleIdInt, _ := strconv.ParseInt(receivedValue.RoleId, 10, 64) + empowerCont.RoleId = roleIdInt //行政组织"` + empowerCont.System = receivedValue.SystemName //系统"` + empowerCont.PointId = strings.Join(menuList, ",") //权限点位"` + empowerCont.State = 1 //状态(1:启用;2:禁用;3:删除)"` + empowerCont.Time = addTime //创建时间"` + empowerCont.Level = receivedValue.Level //授权范围等级(1:本部门;2:本分部;3:所有)"` + empowerCont.Operation = strings.Join(menuOperationList, ",") //操作点位 + err = overall.CONSTANT_DB_System_Permission.Create(&empowerCont).Error + if err != nil { + publicmethod.Result(1, err, c, "权限配置失败") + return + } + } + } else { + var munePowerList empowerSync + for _, v := range receivedValue.PowerList { + // if v.Id == "1" { + syncSeting.Add(1) + go munePowerList.GetAllSunCont(v) + // } + + } + syncSeting.Wait() + menuIdList, menuOperIdList := munePowerList.readDataLock() + // fmt.Printf("\n\n%v-------结果-------->%v\n", menuIdList, menuOperIdList) + // publicmethod.Result(0, receivedValue.PowerList, c) + // return + // outData := publicmethod.MapOut[string]() + // outData["menuIdList"] = menuIdList + // outData["menuOperIdList"] = menuOperIdList + // publicmethod.Result(0, outData, c) + menuIdListStr := strings.Join(menuIdList, ",") + menuOperIdListStr := strings.Join(menuOperIdList, ",") + if err == nil { + err = empowerCont.EiteCont(map[string]interface{}{"`id`": empowerCont.Id}, map[string]interface{}{"`point_id`": menuIdListStr, "`operation`": menuOperIdListStr, "`level`": receivedValue.Level, "`time`": addTime, "`state`": 1}) + if err != nil { + publicmethod.Result(1, err, c, "权限配置失败") + return + } + } else { + roleIdInt, _ := strconv.ParseInt(receivedValue.RoleId, 10, 64) + empowerCont.RoleId = roleIdInt //行政组织"` + empowerCont.System = receivedValue.SystemName //系统"` + empowerCont.PointId = menuIdListStr //权限点位"` + empowerCont.State = 1 //状态(1:启用;2:禁用;3:删除)"` + empowerCont.Time = addTime //创建时间"` + empowerCont.Level = receivedValue.Level //授权范围等级(1:本部门;2:本分部;3:所有)"` + empowerCont.Operation = menuOperIdListStr //操作点位 + err = overall.CONSTANT_DB_System_Permission.Create(&empowerCont).Error + if err != nil { + publicmethod.Result(1, err, c, "权限配置失败") + return + } + } + } + + publicmethod.Result(0, receivedValue, c) +} diff --git a/api/version1/jurisdiction/jurisdictionpc/systemrole.go b/api/version1/jurisdiction/jurisdictionpc/systemrole.go index 40121e3..12321a1 100644 --- a/api/version1/jurisdiction/jurisdictionpc/systemrole.go +++ b/api/version1/jurisdiction/jurisdictionpc/systemrole.go @@ -129,12 +129,27 @@ func (a *ApiMethod) SystemRoleList(c *gin.Context) { if receivedValue.Name != "" { gormDb = gormDb.Where("`name` LIKE ?", "%"+receivedValue.Name+"%") } - err := gormDb.Order("`sort` ASC").Order("`id` DESC").Find(&systemRoleInfoList) + err := gormDb.Order("`sort` ASC").Order("`id` DESC").Find(&systemRoleInfoList).Error if err != nil { publicmethod.Result(107, err, c) return } - publicmethod.Result(0, systemRoleInfoList, c) + var sendList []sendSystemRoleList + for _, v := range systemRoleInfoList { + var sendCont sendSystemRoleList + sendCont.Id = v.Id + sendCont.Name = v.Name //角色名称"` + sendCont.State = v.State //状态(1:启用;2:禁用;3:删除)"` + sendCont.Time = v.Time //创建时间"` + sendCont.Sort = v.Sort //排序"` + if v.State == 1 { + sendCont.IsTrue = true + } else { + sendCont.IsTrue = false + } + sendList = append(sendList, sendCont) + } + publicmethod.Result(0, sendList, c) } /* diff --git a/api/version1/jurisdiction/jurisdictionpc/type.go b/api/version1/jurisdiction/jurisdictionpc/type.go index c6edbcc..6415a36 100644 --- a/api/version1/jurisdiction/jurisdictionpc/type.go +++ b/api/version1/jurisdiction/jurisdictionpc/type.go @@ -1,6 +1,7 @@ package jurisdictionpc import ( + "key_performance_indicators/models/modelssystempermission" "key_performance_indicators/overall/publicmethod" "sync" @@ -92,6 +93,10 @@ type GetSystemMenuPower struct { OrdId string `json:"ordid"` //行政组织 PostId string `json:"postid"` //岗位 } +type GetSystemRoleMenuPower struct { + publicmethod.PublicName //系统标识符 + RoleId string `json:"roleid"` //行政组织 +} // 添加权限参数 type editPowerStructNew struct { @@ -118,3 +123,17 @@ type editSystemRoleCont struct { type systemRoleContList struct { publicmethod.PublicName } + +// 输出列表 +type sendSystemRoleList struct { + modelssystempermission.SystemRole + IsTrue bool `json:"istrue"` +} + +// 编辑角色权限参数 +type editRolePowerStructNew struct { + RoleId string `json:"roleid"` //行政组织 + SystemName string `json:"systemname"` //系统识别符 + Level int `json:"level"` //授权范围等级(1:本岗位;2:本部门;3:本分部;4:指定行政组织;5:所有) + PowerList []publicmethod.PowerThree `json:"power"` //权限列表 +} diff --git a/api/version1/postseting/postpc/scheme.go b/api/version1/postseting/postpc/scheme.go index d602f3d..1a188af 100644 --- a/api/version1/postseting/postpc/scheme.go +++ b/api/version1/postseting/postpc/scheme.go @@ -98,12 +98,16 @@ func (a *ApiMethod) GetSchemeList(c *gin.Context) { // 获取岗位相关指标 func (a *ApiMethod) GetPostAboutTarget(c *gin.Context) { - var receivedValue publicmethod.PublicId + var receivedValue targetFormPost err := c.ShouldBindJSON(&receivedValue) if err != nil { publicmethod.Result(100, err, c) return } + if receivedValue.Id == "" { + publicmethod.Result(101, err, c) + return + } //获取岗位相关信息 var postCont modelshr.Position postContErr := postCont.GetCont(map[string]interface{}{"`id`": receivedValue.Id}, "`id`", "`duties`", "`administrative_organization`", "`superior`", "`department`") @@ -124,7 +128,7 @@ func (a *ApiMethod) GetPostAboutTarget(c *gin.Context) { var postPlanSync postDimeTarSync for _, v := range dimensionList { syncSeting.Add(1) - go postPlanSync.GetPostTargent(postCont, v) + go postPlanSync.GetPostTargent(postCont, receivedValue.State, v) } syncSeting.Wait() planAry := postPlanSync.readDataLock() //读取线程通道数据 @@ -143,13 +147,18 @@ func (a *ApiMethod) GetPostAboutTarget(c *gin.Context) { /* @position 岗位信息 @dutyClass 维度信息 +@classType 0:全部,1:定性;2:定量 */ -func (p *postDimeTarSync) GetPostTargent(position modelshr.Position, dutyClass modelskpi.DutyClass) { +func (p *postDimeTarSync) GetPostTargent(position modelshr.Position, classType int, dutyClass modelskpi.DutyClass) { p.mutext.Lock() defer p.mutext.Unlock() //获取相关指标 var postTargetList []modelskpi.PostTarget - postTarErr := overall.CONSTANT_DB_KPI.Model(&modelskpi.PostTarget{}).Where("`state` = 1 AND `dimension` = ? AND `rele_depart` = ? AND FIND_IN_SET(?,`departments_post`)", dutyClass.Id, position.AdministrativeOrganization, position.Id).Find(&postTargetList).Error + gormDb := overall.CONSTANT_DB_KPI.Model(&modelskpi.PostTarget{}).Where("`state` = 1 AND `dimension` = ? AND `rele_depart` = ? AND FIND_IN_SET(?,`departments_post`)", dutyClass.Id, position.AdministrativeOrganization, position.Id) + if classType != 0 { + gormDb = gormDb.Where("`type` = ?", classType) + } + postTarErr := gormDb.Find(&postTargetList).Error // fmt.Printf("postTargetList---->%v\n", postTargetList) if postTarErr == nil && len(postTargetList) > 0 { var planCont postAboutDimeTar diff --git a/api/version1/postseting/postpc/serpostconfig.go b/api/version1/postseting/postpc/serpostconfig.go index 800f0d7..07c4f6f 100644 --- a/api/version1/postseting/postpc/serpostconfig.go +++ b/api/version1/postseting/postpc/serpostconfig.go @@ -232,7 +232,7 @@ func (a *ApiMethod) SetEvaluationObjectives(c *gin.Context) { eiteDataMap["capping_val"] = 0 } eiteDataMap["time"] = time.Now().Unix() - gromDb := overall.CONSTANT_DB_KPI.Model(&modelskpi.QuanPostConfig{}).Select("Timecopy").Where("`company_id` = ? AND `org_id` = ? AND `post_id` = ? AND `dimension` = ? AND `target` = ? AND `year` = ? AND `type` = ?", requestData.Group, requestData.DepartMent, requestData.PostId, requestData.Dimension, requestData.Target, requestData.Year, requestData.Cycle) + gromDb := overall.CONSTANT_DB_KPI.Model(&modelskpi.QuanPostConfig{}).Select("Timecopy").Where("`company_id` = ? AND `org_id` = ? AND `post_id` = ? AND `dimension` = ? AND `target` = ? AND `year` = ? AND `type` = ?", companyId, requestData.DepartMent, requestData.PostId, requestData.Dimension, requestData.Target, requestData.Year, requestData.Cycle) gromDb.Updates(eiteDataMap) eiteAddData = append(eiteAddData, 1) @@ -414,6 +414,38 @@ func (a *ApiMethod) DelQuantitativeConfig(c *gin.Context) { } } +/* +* +@ 作者: 秦东 +@ 时间: 2022-11-12 13:25:51 +@ 功能: 删除考核目标设置(新版) +@ 参数 + + # + +@ 返回值 + + # +*/ +func (a *ApiMethod) NewDelQuantitativeConfig(c *gin.Context) { + var receivedValue newDelTargetConfig + err := c.ShouldBindJSON(&receivedValue) + if err != nil { + publicmethod.Result(100, err, c) + return + } + if receivedValue.OrgID == "" || receivedValue.PostId == "" || receivedValue.Dimension == "" || receivedValue.Target == "" || receivedValue.Type == 0 || receivedValue.Year == 0 { + publicmethod.Result(101, receivedValue, c, "数据获取失败!") + return + } + err = overall.CONSTANT_DB_KPI.Where("`org_id` = ? AND `post_id` = ? AND `dimension` = ? AND `target` = ? AND `type` = ? AND `year` = ?", receivedValue.OrgID, receivedValue.PostId, receivedValue.Dimension, receivedValue.Target, receivedValue.Type, receivedValue.Year).Delete(&modelskpi.QuanPostConfig{}).Error + if err != nil { + publicmethod.Result(108, err, c) + } else { + publicmethod.Result(0, err, c) + } +} + // 查看定量岗位考核目标设定 func (a *ApiMethod) LookPosttiveConfig(c *gin.Context) { var requestData SelectQuantitativeConfig @@ -431,8 +463,11 @@ func (a *ApiMethod) LookPosttiveConfig(c *gin.Context) { if requestData.DepartmentID != "" { gormDb = gormDb.Where("`department_id` = ?", requestData.DepartmentID) } + if requestData.OrgID != "" { + gormDb = gormDb.Where("`org_id` = ?", requestData.OrgID) + } if requestData.PostId != "" { - gormDb = gormDb.Where("`org_id` = ?", requestData.PostId) + gormDb = gormDb.Where("`post_id` = ?", requestData.PostId) } if requestData.Dimension != "" { gormDb = gormDb.Where("`dimension` = ?", requestData.Dimension) @@ -476,6 +511,7 @@ func (a *ApiMethod) LookPosttiveConfig(c *gin.Context) { for _, v := range qualConfigList { var outCont OutQuantitativeConfig outCont.Id = v.Id + outCont.IdStr = strconv.FormatInt(v.Id, 10) outCont.DepartmentId = v.DepartmentId outCont.CompanyId = v.CompanyId outCont.Dimension = v.Dimension @@ -514,3 +550,106 @@ func (a *ApiMethod) LookPosttiveConfig(c *gin.Context) { } publicmethod.Result(0, outList, c) } + +// 岗位定量考核目标列表(新版) +func (a *ApiMethod) PostConfigListNews(c *gin.Context) { + var requestData SelectQuantitativeConfig + c.ShouldBindJSON(&requestData) + // if err != nil { + // publicmethod.Result(1, err, c, "数据获取失败!") + // return + // } + // var qualConfigList []assessmentmodel.QuantitativeConfig + var qualConfigList []modelskpi.QuanPostConfigTarget + gormDb := overall.CONSTANT_DB_KPI.Model(&modelskpi.QuanPostConfigTarget{}).Distinct("`company_id`,`department_id`,`org_id`,`post_id`,`dimension`,`target`,`title`,`year`,`type`") + if requestData.GroupId != "" { + gormDb = gormDb.Where("`company_id` = ?", requestData.GroupId) + } + if requestData.DepartmentID != "" { + gormDb = gormDb.Where("`org_id` = ?", requestData.DepartmentID) + } + if requestData.PostId != "" { + gormDb = gormDb.Where("`post_id` = ?", requestData.PostId) + } + if requestData.Dimension != "" { + gormDb = gormDb.Where("`dimension` = ?", requestData.Dimension) + } + if requestData.Target != "" { + gormDb = gormDb.Where("`target` = ?", requestData.Target) + } + + if requestData.Year != 0 { + gormDb = gormDb.Where("`year` = ?", requestData.Year) + } + if requestData.State != 0 { + gormDb = gormDb.Where("`state` = ?", requestData.State) + } else { + gormDb = gormDb.Where("`state` = 1") + } + if requestData.Type != 0 { + gormDb = gormDb.Where("`type` = ?", requestData.Type) + } + if requestData.Title != "" { + gormDb = gormDb.Where("`title` LIKE ?", "%"+requestData.Title+"%") + } + // gormDb = gormDb.Order("group ASC,departmentid ASC,dimension ASC,target ASC,targetconfig ASC").Order("year DESC").Order("timecopy ASC,id ASC") + gormDb = gormDb.Order("`company_id` ASC").Order("`department_id` ASC").Order("`org_id` ASC").Order("`post_id` ASC").Order("`dimension` ASC").Order("`target` ASC").Order("`year` DESC") + contErr := gormDb.Find(&qualConfigList).Error + if contErr != nil { + publicmethod.Result(1, contErr, c, "没有数据!") + return + } + var outList []OutQuantitativeConfig + for _, v := range qualConfigList { + var outCont OutQuantitativeConfig + outCont.Id = v.Id + outCont.Title = v.Title + outCont.CompanyId = v.CompanyId + outCont.DepartmentId = v.DepartmentId + outCont.OrgId = v.OrgId + outCont.PostId = v.PostId + + outCont.Dimension = v.Dimension + outCont.Target = v.Target + + outCont.Type = v.Type + outCont.Year = v.Year + outCont.Timecopy = v.Timecopy + outCont.Zeroprize = v.Zeroprize / 100 + outCont.Allprize = v.Allprize / 100 + outCont.Capping = v.Capping + outCont.CappingVal = v.CappingVal / 100 + outCont.Time = v.Time + outCont.State = v.State + outCont.DimensionId = strconv.FormatInt(v.Dimension, 10) + + var companyCont modelshr.AdministrativeOrganization + companyCont.GetCont(map[string]interface{}{"`id`": v.CompanyId}, "id", "name") + outCont.GroupTitle = companyCont.Name + + var departmenCont modelshr.AdministrativeOrganization + departmenCont.GetCont(map[string]interface{}{"`id`": v.DepartmentId}, "id", "name") + outCont.DepartmentTitle = departmenCont.Name + + var postCont modelshr.Position + postCont.GetCont(map[string]interface{}{"`id`": v.PostId}, "id", "name") + outCont.PostTitle = postCont.Name + + var dimensionCont modelskpi.DutyClass + dimensionCont.GetCont(map[string]interface{}{"`id`": v.Dimension}, "id", "title") + outCont.DimensionTitle = dimensionCont.Title + + outCont.TargetTitle = v.Title + // dErr, departmentInfo := commonus.GetBranchFactory(v.DepartmentId) + // if dErr == true { + // outCont.DimensionTitle = departmentInfo.Name + // } + // targetInfo, tErr := commonus.GetTargetInfo(v.Target) + // if tErr == true { + // outCont.TargetTitle = targetInfo.Title + // } + + outList = append(outList, outCont) + } + publicmethod.Result(0, outList, c) +} diff --git a/api/version1/postseting/postpc/type.go b/api/version1/postseting/postpc/type.go index 87cae8e..6fb597d 100644 --- a/api/version1/postseting/postpc/type.go +++ b/api/version1/postseting/postpc/type.go @@ -231,7 +231,7 @@ type lookPostTargetDeta struct { // 输出岗位定性指标详细列表 type sendNaitonTargetDeiment struct { modelskpi.PostTargetDetails - SonTargetTitle string `sontargettitle` //指标名称 + SonTargetTitle string `json:"sontargettitle"` //指标名称 ReferenceScore string `json:"referencescore"` //考核标准 CashStandard string `json:"cashstandard"` //现金标准 } @@ -284,10 +284,10 @@ type sonTargetAddDieastion struct { // 设定指标结算周期 type SetEvaluationObjectives struct { - Year int64 `json:"year"` //年度 - Group string `json:"group"` //集团 + Year int64 `json:"year"` //年度 + // Group string `json:"group"` //集团 DepartMent string `json:"department"` //部门 - PostId string `postid` + PostId string `json:"postid"` Dimension string `json:"dimension"` //维度 Target string `json:"target"` //指标 Cycle int `json:"cycle"` //周期 @@ -307,7 +307,8 @@ type SelectQuantitativeConfig struct { Title string `json:"title"` //指标标题 GroupId string `json:"groupid"` DepartmentID string `json:"departmentid"` - PostId string `postid` + OrgID string `json:"orgid"` //行政组织 + PostId string `json:"postid"` //岗位 Dimension string `json:"dimension"` //维度 Target string `json:"target"` //指标 Type int `json:"type"` //1、年度;2、季度;3、月度 @@ -326,6 +327,7 @@ type OutQuantitativeConfig struct { DimensionId string `json:"dimensionid"` //维度 TargetTitle string `json:"targettitle"` //指标 DetailedTargetTitle string `json:"detailedtargenttitle"` //指标明细 + IdStr string `json:"idstr"` //字符型Id } // 修改考核目标设定 @@ -340,3 +342,19 @@ type EiteQuantConfig struct { type DelQuantConfig struct { Id string `json:"id"` } + +// 获取岗位指标列表 +type targetFormPost struct { + publicmethod.PublicId //岗位Id + State int `json:"state"` //0:所有;1:定性;2:定量 +} + +// 删除指标设定的目标值 +type newDelTargetConfig struct { + OrgID string `json:"orgid"` //行政组织 + PostId string `json:"postid"` //岗位 + Dimension string `json:"dimension"` //维度 + Target string `json:"target"` //指标 + Type int `json:"type"` //1、年度;2、季度;3、月度 + Year int `json:"year"` //年度 +} diff --git a/apirouter/apishiyan/maptostruct.go b/apirouter/apishiyan/maptostruct.go index b8e12bd..075135e 100644 --- a/apirouter/apishiyan/maptostruct.go +++ b/apirouter/apishiyan/maptostruct.go @@ -19,5 +19,8 @@ func (a *ApiRouter) RouterGroup(router *gin.RouterGroup) { apiRouter.POST("simulationcallback", methodBinding.SimulationCallBack) //模拟回调 apiRouter.POST("setuphrsystem", methodBinding.SetUpHrSystem) //设置HR系统对接账号和密码 + + apiRouter.POST("cang_chu_three", methodBinding.CangChuThree) //实验仓储数据读取 + } } diff --git a/apirouter/v1/postseting/pc.go b/apirouter/v1/postseting/pc.go index 793fd29..847e11a 100644 --- a/apirouter/v1/postseting/pc.go +++ b/apirouter/v1/postseting/pc.go @@ -22,9 +22,15 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) { apiRouter.POST("set_evaluation_objectives", methodBinding.SetEvaluationObjectives) //提交岗位定量目标设定 apiRouter.POST("post_config_list", methodBinding.PostConfigList) //岗位定量考核目标列表 - apiRouter.POST("eite_quantitative_config", methodBinding.EiteQuantitativeConfig) //修改考核目标设置 - apiRouter.POST("del_quantitative_config", methodBinding.DelQuantitativeConfig) //删除考核目标设置 - apiRouter.POST("lookposttiveconfig", methodBinding.LookPosttiveConfig) // 查看定量考核目标设定 + + apiRouter.POST("post_config_list_news", methodBinding.PostConfigListNews) //岗位定量考核目标列表(新版) + + apiRouter.POST("eite_quantitative_config", methodBinding.EiteQuantitativeConfig) //修改考核目标设置 + apiRouter.POST("del_quantitative_config", methodBinding.DelQuantitativeConfig) //删除考核目标设置 + apiRouter.POST("lookposttiveconfig", methodBinding.LookPosttiveConfig) // 查看定量考核目标设定 + + apiRouter.POST("new_del_quantitative_config", methodBinding.NewDelQuantitativeConfig) //删除考核目标设置(新版) + /* 岗位定性指标 */ diff --git a/apirouter/v1/systempower/pc.go b/apirouter/v1/systempower/pc.go index a517f25..76510b6 100644 --- a/apirouter/v1/systempower/pc.go +++ b/apirouter/v1/systempower/pc.go @@ -12,19 +12,25 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) { var methodBinding = version1.AppApiEntry.JurisdictionpcApi { - apiRouter.GET("", methodBinding.Index) //入口 - apiRouter.POST("", methodBinding.Index) //入口 - apiRouter.POST("edit_power", methodBinding.EditPower) //编辑权限 - apiRouter.POST("edit_power_new", methodBinding.EditPowerNew) //编辑权限 + apiRouter.GET("", methodBinding.Index) //入口 + apiRouter.POST("", methodBinding.Index) //入口 + apiRouter.POST("edit_power", methodBinding.EditPower) //编辑权限 + apiRouter.POST("edit_power_new", methodBinding.EditPowerNew) //编辑权限 + apiRouter.POST("edit_role_power_new", methodBinding.EditRolePowerNew) //编辑角色权限 + //系统 apiRouter.POST("add_system", methodBinding.AddSystem) //添加应用系统 apiRouter.POST("system_list", methodBinding.SystemList) //系统列表 apiRouter.POST("edit_system", methodBinding.EditSystem) //编辑应用系统信息 apiRouter.POST("edit_state_of_del", methodBinding.EditStateOfDel) //更改状态或删除 //相关系统菜单 - apiRouter.POST("system_about_menu", methodBinding.SystemAboutMenu) //系统菜单 + apiRouter.POST("system_about_menu", methodBinding.SystemAboutMenu) //系统菜单行政组织岗位 + apiRouter.POST("system_about_role_menu", methodBinding.SystemRoleAboutMenu) //系统菜单角色 //角色 - + apiRouter.POST("add_system_role", methodBinding.AddSystemRole) //系统角色添加 + apiRouter.POST("edit_system_role", methodBinding.EditSystemRole) //系统角色编辑 + apiRouter.POST("system_role_list", methodBinding.SystemRoleList) //系统角色列表 + apiRouter.POST("edit_system_role_state", methodBinding.EditSystemRoleState) //系统角色状态 } } diff --git a/models/modelsstorage/accesstoaddress.go b/models/modelsstorage/accesstoaddress.go index 6f46bf6..785bc7f 100644 --- a/models/modelsstorage/accesstoaddress.go +++ b/models/modelsstorage/accesstoaddress.go @@ -14,7 +14,7 @@ type AccesstoAddress struct { RoleId int `json:"roleid" gorm:"column:role_id;type:int(1) unsigned;default:1;not null;comment:菜单对应的角色"` Menuparent int `json:"menuparent" gorm:"column:menuparent;type:int(1) unsigned;default:0;not null;comment:父菜单,0代表无父菜单"` State int `json:"state" gorm:"column:state;type:int(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` - Icon string `json:"icon" gorm:"icon:name;type:varchar(100);comment:图标"` + Icon string `json:"icon" gorm:"column:icon;type:varchar(100);comment:图标"` Target string `json:"target" gorm:"column:target;type:varchar(100);comment:目标"` IsChild int `json:"ischild" gorm:"column:ischild;type:int(1) unsigned;default:1;not null;comment:是否有子菜单\r\n(1有2无)"` } diff --git a/models/modelsstorage/material.go b/models/modelsstorage/material.go new file mode 100644 index 0000000..df67af6 --- /dev/null +++ b/models/modelsstorage/material.go @@ -0,0 +1,70 @@ +package modelsstorage + +import ( + "key_performance_indicators/overall" + "strings" +) + +// 仓储系统菜单管理 +type Material struct { + Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;index"` + DepositoryId int64 `json:"depositoryid" gorm:"column:depository_id;type:bigint(20) unsigned;default:0;not null;comment:仓库编号"` + Name string `json:"name" gorm:"column:mname;type:varchar(100);comment:材料名称"` + Quantity int `json:"quantity" gorm:"column:type;quantity:int(11) unsigned;default:1;not null;comment:数量"` + Amounts int `json:"amounts" gorm:"column:amounts;type:int(11) unsigned;default:1;not null;comment:总金额"` + TypeId int64 `json:"typeid" gorm:"column:type_id;type:bigint(20) unsigned;default:0;not null;comment:材料种类id"` + State int `json:"state" gorm:"column:state;type:int(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` + Code string `json:"code" gorm:"column:code;type:varchar(255);comment:存货编码"` + Version string `json:"version" gorm:"column:version;type:varchar(255);comment:规格型号"` + Price int `json:"price" gorm:"column:price;type:int(11) unsigned;default:1;not null;comment:单价"` + Unit string `json:"unit" gorm:"column:unit;type:varchar(255);comment:计量单位"` + Texture string `json:"texture" gorm:"column:texture;type:varchar(255);comment:材质"` + DepositoryCode string `json:"depositoryCode" gorm:"column:depositoryCode;type:varchar(255);comment:货位码(存放位置)"` + Kingdeecode string `json:"kingdeecode" gorm:"column:kingdeecode;type:varchar(255);comment:计量单位"` + NumberOfTemporary int `json:"numberoftemporary" gorm:"column:number_of_temporary;type:int(11) unsigned;default:1;not null;comment:临时数目(临时出库数目)"` +} + +func (Material *Material) TableName() string { + return "material" +} + +// 编辑内容 +func (cont *Material) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_Storage.Model(&cont).Where(whereMap).Updates(saveData).Error + return +} + +// 获取内容 +func (cont *Material) GetCont(whereMap interface{}, field ...string) (err error) { + gormDb := overall.CONSTANT_DB_Storage.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 *Material) CountCont(whereMap interface{}) (countId int64) { + overall.CONSTANT_DB_Storage.Model(&cont).Where(whereMap).Count(&countId) + return +} + +// 读取全部信息 +func (cont *Material) ContMap(whereMap interface{}, field ...string) (countAry []Material, err error) { + gormDb := overall.CONSTANT_DB_Storage.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + err = gormDb.Where(whereMap).Find(&countAry).Error + return +} + +// 删除内容 +func (cont *Material) DelCont(whereMap interface{}) (err error) { + err = overall.CONSTANT_DB_Storage.Where(whereMap).Delete(&cont).Error + return +} diff --git a/models/modelsstorage/material_type.go b/models/modelsstorage/material_type.go new file mode 100644 index 0000000..8dee475 --- /dev/null +++ b/models/modelsstorage/material_type.go @@ -0,0 +1,61 @@ +package modelsstorage + +import ( + "key_performance_indicators/overall" + "strings" +) + +// 仓储系统菜单管理 +type MaterialType struct { + Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;index"` + Name string `json:"name" gorm:"column:tname;type:varchar(255);comment:类型名称"` + Introduce string `json:"introduce" gorm:"column:introduce;type:varchar(255);comment:类型介绍"` + State int `json:"state" gorm:"column:state;type:int(1) unsigned;default:1;not null;comment:状态(启用2禁用3删除4不对其做任何操作)"` + ParentId int64 `json:"parentId" gorm:"column:parentId;type:bigint(20) unsigned;default:0;not null;comment:父级"` + OrderId int64 `json:"orderid" gorm:"column:oldId;type:bigint(20) unsigned;default:0;not null;comment:导入时id"` +} + +func (MaterialType *MaterialType) TableName() string { + return "material_type" +} + +// 编辑内容 +func (cont *MaterialType) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_Storage.Model(&cont).Where(whereMap).Updates(saveData).Error + return +} + +// 获取内容 +func (cont *MaterialType) GetCont(whereMap interface{}, field ...string) (err error) { + gormDb := overall.CONSTANT_DB_Storage.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 *MaterialType) CountCont(whereMap interface{}) (countId int64) { + overall.CONSTANT_DB_Storage.Model(&cont).Where(whereMap).Count(&countId) + return +} + +// 读取全部信息 +func (cont *MaterialType) ContMap(whereMap interface{}, field ...string) (countAry []MaterialType, err error) { + gormDb := overall.CONSTANT_DB_Storage.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + err = gormDb.Where(whereMap).Find(&countAry).Error + return +} + +// 删除内容 +func (cont *MaterialType) DelCont(whereMap interface{}) (err error) { + err = overall.CONSTANT_DB_Storage.Where(whereMap).Delete(&cont).Error + return +} diff --git a/models/modelssystempermission/role_empower.go b/models/modelssystempermission/role_empower.go index 0b011d9..6e0ff2d 100644 --- a/models/modelssystempermission/role_empower.go +++ b/models/modelssystempermission/role_empower.go @@ -18,7 +18,7 @@ type RoleEmpower struct { } func (RoleEmpower *RoleEmpower) TableName() string { - return "role_RoleEmpower" + return "role_empower" } // 编辑内容 diff --git a/overall/publicmethod/technique.go b/overall/publicmethod/technique.go index 99466ba..f81229e 100644 --- a/overall/publicmethod/technique.go +++ b/overall/publicmethod/technique.go @@ -178,6 +178,18 @@ func LimitPage(page, pageSize int) (offSet int) { return } +// 数据库查询翻页 +func LimitPage64(page, pageSize int64) (offSet int64) { + if page < 1 { + page = 1 + } + offSet = pageSize * (page - 1) + if offSet < 0 { + offSet = 0 + } + return +} + // 中文首字母大写 func ChineseFirstWordCapitalize(wordStr string) (firstWord string) { pinYinSub := pinyin.NewArgs()