package commonus //公共函数类 import ( "bytes" "crypto/rand" "encoding/json" "fmt" "math" "math/big" "regexp" "strconv" "strings" "time" "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/hrsystem" "github.com/flipped-aurora/gin-vue-admin/server/model/location" "github.com/flipped-aurora/gin-vue-admin/server/model/systemuser" "github.com/flipped-aurora/gin-vue-admin/server/model/testpage" "github.com/flipped-aurora/gin-vue-admin/server/model/wechat" "github.com/flipped-aurora/gin-vue-admin/server/utils/redishandel" "github.com/mitchellh/mapstructure" "github.com/mozillazg/go-pinyin" "gorm.io/gorm" ) //遍历所有父类 type ErgodicStruct struct { ParentId int64 Date []int64 } //遍历组织架构 func (e *ErgodicStruct) ErgodicParentClassGroup(id int64, groupStruct []wechat.GroupForm) { for _, v := range groupStruct { if e.ParentId == 1 { if v.Id == id { e.Date = append(e.Date, v.Parentid) e.ErgodicParentClassGroup(v.Parentid, groupStruct) } } else { if v.Id == id { if v.Parentid != 1 { e.Date = append(e.Date, v.Parentid) } e.ErgodicParentClassGroup(v.Parentid, groupStruct) } } } } //冒泡排序法 func BubbleSort(slice []int64) []int64 { for n := 0; n <= len(slice); n++ { for i := 1; i < len(slice)-n; i++ { if slice[i] < slice[i-1] { slice[i], slice[i-1] = slice[i-1], slice[i] } } } return slice } func BubbleSortInt(slice []int) []int { for n := 0; n <= len(slice); n++ { for i := 1; i < len(slice)-n; i++ { if slice[i] < slice[i-1] { slice[i], slice[i-1] = slice[i-1], slice[i] } } } return slice } //编号,纯数字 func TableNumber(class ...string) (number int64) { result, _ := rand.Int(rand.Reader, big.NewInt(8999)) numberTeam := result.Int64() + 1000 numberStr := fmt.Sprintf("%v%v", time.Now().Unix(), numberTeam) if len(class) > 0 { resultLong, _ := rand.Int(rand.Reader, big.NewInt(8999999)) numberTeamLong := resultLong.Int64() + 1000000 numberStr = fmt.Sprintf("%v%v", time.Now().Unix(), numberTeamLong) } number, _ = strconv.ParseInt(numberStr, 10, 64) return } //获取公司,分厂,工段 func GetGroupInfo(id int64) (isTrue bool, groupStruct wechat.GroupForm) { isTrue = false redisClient := redishandel.RunRedis() isTrues, tokenInfo := redisClient.Get("organStructure:group_" + global.GVA_CONFIG.RedisPrefix.Alias + "_" + strconv.FormatInt(id, 10)) if isTrues == true { jsonUserList := json.Unmarshal([]byte(tokenInfo), &groupStruct) if jsonUserList != nil { return } isTrue = true } else { var groupStructs wechat.GroupForm //集团表结构 err := global.GVA_DB_WatchDate.Where("g_id = ?", id).First(&groupStruct).Error //获取集团信息 if err != nil { groupStruct, isTrue = AddWechatGroup(id, groupStructs) return } jsonUserList, jsonErr := json.Marshal(groupStruct) if jsonErr != nil { return } redisClient.SetRedisTime(604800) redisClient.Set("organStructure:group_"+global.GVA_CONFIG.RedisPrefix.Alias+"_"+strconv.FormatInt(id, 10), string(jsonUserList)) isTrue = true } // groupInfo["name"] = groupStruct.Name return } //获主数据库员工信息(微信版本) func GetMainDataBaseUserInfo(weChatId string) (isTrue bool, myInfo testpage.WorkMan) { isTrue = false err := global.GVA_DB_Master.Where("qywx_key = ? or wx_key = ?", weChatId, weChatId).First(&myInfo).Error //获取集团信息 if err != nil { userWechat := GetWechatUserInfo(weChatId) isTrues, myDepartment := GetGroupInfo(int64(userWechat.MainDepartment)) if isTrues == false { return } myInfo.WorkWechatId = userWechat.UserId var arrAy []int64 errdd := json.Unmarshal([]byte(myDepartment.Group), &arrAy) if errdd == nil { if len(arrAy) >= 2 { if arrAy[0] == 1 { myInfo.Group = arrAy[1] } else { myInfo.Group = arrAy[1] } } } var weChatInfo wechat.WechatUsers weChatInfo.Uid = GetFileNumber() weChatInfo.Userid = userWechat.UserId weChatInfo.Name = userWechat.Name jsonStr, jsonErr := json.Marshal(userWechat.Department) if jsonErr == nil { weChatInfo.Department = string(jsonStr) } else { weChatInfo.Department = "[]" } weChatInfo.Position = userWechat.Position weChatInfo.Mobile = userWechat.Mobile GenderInt, gendererr := strconv.Atoi(userWechat.Gender) if gendererr == nil { weChatInfo.Gender = GenderInt } else { weChatInfo.Gender = 1 } weChatInfo.Email = userWechat.Email weChatInfo.Avatar = userWechat.Avatar weChatInfo.Status = userWechat.Status extattrStr, extattrErr := json.Marshal(userWechat.Extattr) if extattrErr == nil { weChatInfo.Extattr = string(extattrStr) } else { weChatInfo.Extattr = "{\"attrs\":[]}" } weChatInfo.MainDepartment = int64(userWechat.MainDepartment) weChatInfo.QrCode = userWechat.QrCode isLeaderInDeptStr, isLeaderInDeptrErr := json.Marshal(userWechat.IsLeaderInDept) if isLeaderInDeptrErr == nil { weChatInfo.IsLeaderInDept = string(isLeaderInDeptStr) } else { weChatInfo.IsLeaderInDept = "[0]" } weChatInfo.ThumbAvatar = userWechat.ThumbAvatar weChatInfo.Time = time.Now().Unix() addErr := global.GVA_DB_WatchDate.Create(&weChatInfo).Error if addErr == nil { isTrue = true } return } isTrue = true return } //获取成员信息 func GetWechatUserInfo(weChatId string) (us UserListStruct) { if weChatId == "" { return } redisClient := redishandel.RunRedis() isTrue, tokenInfo := redisClient.HashGet("deUserAry:wechat_"+global.GVA_CONFIG.RedisPrefix.Alias, "userinfo_"+"_"+weChatId) if isTrue != true { userInfo, _, _ := GetOneAddressBookMember(weChatId) // var callBackData WechatUserInfo // json.Unmarshal(userInfo, &callBackData) // var us UserListStruct json.Unmarshal(userInfo, &us) userMap := MapOut() json.Unmarshal(userInfo, &userMap) jsonUser, _ := json.Marshal(us) redisClient.SetRedisTime(2678400) redisClient.HashSet("deUserAry:wechat_"+global.GVA_CONFIG.RedisPrefix.Alias, "userinfo_"+"_"+weChatId, string(jsonUser)) // fmt.Printf("未经过redis=====>%v\n", weChatId) } else { // var us UserListStruct json.Unmarshal([]byte(tokenInfo), &us) // fmt.Printf("经过redis=====>%v\n", weChatId) } return } //添加企业微信组织 func AddWechatGroup(id int64, groupStruct wechat.GroupForm) (groupInfo wechat.GroupForm, isTrue bool) { isTrue = false groupFrameWork, isTrueErr := GetWechatFramework(id) if isTrueErr == false { return } var callBackData dePartMent err := json.Unmarshal(groupFrameWork, &callBackData) if err != nil { return } var sunGroup []int64 sunGroup = append(sunGroup, id) if callBackData.Errcode == 0 { redisClient := redishandel.RunRedis() redisClient.SetRedisTime(604800) for _, val := range callBackData.DePartMent { // fmt.Printf("Key ==> %v ------ Val ==> %v\n", key, val) writeRedisData := map[string]interface{}{ "id": val.Id, "name": val.Name, "name_en": val.NameEN, "parentid": val.Parentid, "order": val.Order, } departId := strconv.FormatInt(val.Id, 10) if id == val.Id { groupInfo.Id = val.Id groupInfo.Name = val.Name groupInfo.Parentid = val.Parentid groupInfo.Orderes = val.Order groupInfo.Time = time.Now().Unix() groupInfo.Sate = 1 jsonStr, jsonErr := json.Marshal(sunGroup) if jsonErr == nil { groupInfo.GroupSun = string(jsonStr) } var group []wechat.GroupForm listErr := global.GVA_DB_WatchDate.Find(&group).Error if listErr == nil { var parentGroup ErgodicStruct parentGroup.ParentId = val.Parentid parentGroup.ErgodicParentClassGroup(val.Parentid, group) parentGroup.Date = append(parentGroup.Date, val.Parentid) parentGroup.Date = append(parentGroup.Date, val.Id) parentGroup.Date = BubbleSort(parentGroup.Date) jsonStrFather, jsonErrFather := json.Marshal(parentGroup.Date) if jsonErrFather == nil { groupInfo.Group = string(jsonStrFather) } } addErr := global.GVA_DB_WatchDate.Create(&groupInfo).Error if addErr == nil { isTrue = true } } else { sunGroup = append(sunGroup, val.Id) } redisClient.HashMsetAdd("dePartMentAry:ment_"+global.GVA_CONFIG.RedisPrefix.Alias+"_"+departId, writeRedisData) } dePartMentJson, _ := json.Marshal(callBackData.DePartMent) dePartMentIdStr := strconv.FormatInt(id, 10) redisClient.Set("dePartMentList:list_"+global.GVA_CONFIG.RedisPrefix.Alias+"_"+dePartMentIdStr, string(dePartMentJson)) } // return } //获取成员信息列表(企业威信数据库) func GetMemberList() (userStruct []wechat.WechatUsers, isTrue bool) { isTrue = false var userAry []wechat.WechatUsers redisClient := redishandel.RunRedis() isTrues, tokenInfo := redisClient.Get("deUserAry:wechatUser_" + global.GVA_CONFIG.RedisPrefix.Alias + "_all") if isTrues != true { userErr := global.GVA_DB_WatchDate.Where("status = 1").Find(&userAry).Error if userErr != nil { wechatAllList, _, isYes := GetDepartmentUserList(1) if isYes != true { var callBackData WechatUserInfoDepartment json.Unmarshal(wechatAllList, &callBackData) if callBackData.Errcode != 0 { return } for _, jsonVal := range callBackData.UserList { var userInfo wechat.WechatUsers userInfo.Userid = jsonVal.UserId userInfo.Name = jsonVal.Name jsonStr, jsonErr := json.Marshal(jsonVal.Department) if jsonErr == nil { userInfo.Department = string(jsonStr) } else { userInfo.Department = "[]" } userInfo.Position = jsonVal.Position userInfo.Mobile = jsonVal.Mobile GenderInt, genderErr := strconv.Atoi(jsonVal.Gender) if genderErr == nil { userInfo.Gender = GenderInt } else { userInfo.Gender = 1 } userInfo.Email = jsonVal.Email userInfo.Avatar = jsonVal.Avatar userInfo.Status = jsonVal.Status extattrJson, extattrErr := json.Marshal(jsonVal.Extattr) if extattrErr == nil { userInfo.Extattr = string(extattrJson) } else { userInfo.Extattr = "{\"attrs\":[]}" } userInfo.MainDepartment = int64(jsonVal.MainDepartment) userInfo.QrCode = jsonVal.QrCode isLeaderInDeptJson, isLeaderInDeptErr := json.Marshal(jsonVal.IsLeaderInDept) if isLeaderInDeptErr == nil { userInfo.IsLeaderInDept = string(isLeaderInDeptJson) } else { userInfo.IsLeaderInDept = "[0]" } userInfo.ThumbAvatar = jsonVal.ThumbAvatar userInfo.UserNumber = "" userInfo.SysBf = 0 userInfo.SysWs = 0 userInfo.SysPs = 0 userInfo.WmTema = 0 userInfo.IsAdmin = 1 userInfo.IsRole = 0 userInfo.Pwd = "" userInfo.Time = time.Now().Unix() userStruct = append(userStruct, userInfo) } isTrue = true jsonUserList, jsonErr := json.Marshal(userStruct) if jsonErr != nil { return } redisClient.SetRedisTime(259200) redisClient.Set("deUserAry:wechatUser_"+global.GVA_CONFIG.RedisPrefix.Alias+"_all", string(jsonUserList)) return } return } for _, userCont := range userAry { var userInfo wechat.WechatUsers userInfo.Uid = userCont.Uid userInfo.Userid = userCont.Userid userInfo.Name = userCont.Name userInfo.Department = userCont.Department userInfo.Position = userCont.Position userInfo.Mobile = userCont.Mobile userInfo.Gender = userCont.Gender userInfo.Email = userCont.Email userInfo.Avatar = userCont.Avatar userInfo.Status = userCont.Status userInfo.Extattr = userCont.Extattr userInfo.MainDepartment = userCont.MainDepartment userInfo.QrCode = userCont.QrCode userInfo.IsLeaderInDept = userCont.IsLeaderInDept userInfo.ThumbAvatar = userCont.ThumbAvatar userInfo.UserNumber = userCont.UserNumber userInfo.SysBf = userCont.SysBf userInfo.SysWs = userCont.SysWs userInfo.SysPs = userCont.SysPs userInfo.WmTema = userCont.WmTema userInfo.IsAdmin = userCont.IsAdmin userInfo.IsRole = userCont.IsRole userInfo.Pwd = userCont.Pwd userInfo.Time = userCont.Time userStruct = append(userStruct, userInfo) } isTrue = true jsonUserList, jsonErr := json.Marshal(userAry) if jsonErr != nil { return } redisClient.SetRedisTime(259200) redisClient.Set("deUserAry:wechatUser_"+global.GVA_CONFIG.RedisPrefix.Alias+"_all", string(jsonUserList)) } else { jsonUserList := json.Unmarshal([]byte(tokenInfo), &userAry) if jsonUserList != nil { return } for _, userCont := range userAry { var userInfo wechat.WechatUsers userInfo.Uid = userCont.Uid userInfo.Userid = userCont.Userid userInfo.Name = userCont.Name userInfo.Department = userCont.Department userInfo.Position = userCont.Position userInfo.Mobile = userCont.Mobile userInfo.Gender = userCont.Gender userInfo.Email = userCont.Email userInfo.Avatar = userCont.Avatar userInfo.Status = userCont.Status userInfo.Extattr = userCont.Extattr userInfo.MainDepartment = userCont.MainDepartment userInfo.QrCode = userCont.QrCode userInfo.IsLeaderInDept = userCont.IsLeaderInDept userInfo.ThumbAvatar = userCont.ThumbAvatar userInfo.UserNumber = userCont.UserNumber userInfo.SysBf = userCont.SysBf userInfo.SysWs = userCont.SysWs userInfo.SysPs = userCont.SysPs userInfo.WmTema = userCont.WmTema userInfo.IsAdmin = userCont.IsAdmin userInfo.IsRole = userCont.IsRole userInfo.Pwd = userCont.Pwd userInfo.Time = userCont.Time userStruct = append(userStruct, userInfo) } isTrue = true } return } //获取全国风险地区列表(企鹅接口 https://view.inews.qq.com/g2/getOnsInfo?name=disease_h5) func NationalRiskArea() []byte { nationalUrl := "https://view.inews.qq.com/g2/getOnsInfo?name=disease_h5" userInfo := CurlGet(nationalUrl) return userInfo } //获取全国风险地区列表数据处理 func GetNationalRiskArea() (riskAreaCityList []RegionalRiskLevel, isTrue bool) { isTrue = false redisClient := redishandel.RunRedis() redisClient.SetRedisTime(7200) isTrueStr, riskAreaRedis := redisClient.Get("nationalRiskArea:cityList_" + global.GVA_CONFIG.RedisPrefix.Alias) if isTrueStr != true { nationalRiskArea := NationalRiskArea() //获取鹅厂数据 var tencentJsonData TencentJsonData jsonErr := json.Unmarshal(nationalRiskArea, &tencentJsonData) //反json化鹅厂数据 if jsonErr != nil { return } var DataJSonTencent DataJSonTencent tencentJsonDataSerialize := json.RawMessage(tencentJsonData.Data) jsonSerializeErr := json.Unmarshal(tencentJsonDataSerialize, &DataJSonTencent) //地区反序列化 if jsonSerializeErr != nil { return } // var regionalRiskAry []RegionalRiskLevel //风险等级模型数组切片 for _, chinaAry := range DataJSonTencent.AreaTree { //国家级 for _, provinceAry := range chinaAry.Children { //省级 for _, cityAry := range provinceAry.Children { //市级 isYes := 0 var regionalRisk RegionalRiskLevel //风险等级模型 regionalRisk.ProvinceName = provinceAry.Name regionalRisk.CityName = cityAry.Name regionalRisk.RiskText = cityAry.Total.Grade regionalRisk.RiskLevel = 0 //切分数据结果,判断风险等级 countSplit := strings.Split(cityAry.Total.Grade, "中高") regionalRisk.Province = int64(len(countSplit)) //0:无;1:低风险;2:中低风险;3:中风险;4:中高风险;5:高风险 if len(countSplit) >= 2 { regionalRisk.RiskLevel = 4 isYes = 1 } else { countSplits := strings.Split(cityAry.Total.Grade, "中低") regionalRisk.City = int64(len(countSplits)) if len(countSplits) >= 2 { regionalRisk.RiskLevel = 2 isYes = 1 } else { countSplitcont := strings.Split(cityAry.Total.Grade, "中") regionalRisk.County = int64(len(countSplitcont)) if len(countSplitcont) >= 2 { regionalRisk.RiskLevel = 3 isYes = 1 } else { countSpliHigh := strings.Split(cityAry.Total.Grade, "高") regionalRisk.County = int64(len(countSpliHigh)) if len(countSpliHigh) >= 2 { regionalRisk.RiskLevel = 5 isYes = 1 } countSpliLown := strings.Split(cityAry.Total.Grade, "低") regionalRisk.County = int64(len(countSpliLown)) if len(countSpliLown) >= 2 { regionalRisk.RiskLevel = 1 isYes = 1 } } } } if isYes == 1 { riskAreaCityList = append(riskAreaCityList, regionalRisk) } } } } regionalRiskJson, regionalRiskjsonErr := json.Marshal(riskAreaCityList) if regionalRiskjsonErr == nil { redisClient.Set("nationalRiskArea:cityList_"+global.GVA_CONFIG.RedisPrefix.Alias, string(regionalRiskJson)) } } else { jsonUserList := json.Unmarshal([]byte(riskAreaRedis), &riskAreaCityList) if jsonUserList == nil { isTrue = true } } return } //写入异常人员列表 func WriteInMan(wechat, calCulTime string, groupId int64) { if wechat == "" { return } timeVal := time.Now().Unix() - 86400 if calCulTime != "" { timeVals, errTime := DateToTimeStampEs(calCulTime) if errTime == true { timeVal = timeVals } } var abn location.AbnormalPeople abnErr := global.GVA_DB_HealthReport.Where("abn_wechat_id = ?", wechat).First(&abn).Error if abnErr != nil { abn.WechatId = wechat abn.GroupId = groupId abn.Time = timeVal global.GVA_DB_HealthReport.Create(&abn) // fmt.Printf("Add -----> %v ------>%v\n", abnErr, abn) } else { abn.GroupId = groupId abn.Time = timeVal global.GVA_DB_HealthReport.Save(&abn) // fmt.Printf("Eite -----> %v ------>%v\n", abnErr, abn) } } //通用查询结果到map结构 type GormTopMap struct { Db *gorm.DB TableName string WhereMap map[string]interface{} } //输出Map查询数据库结果(多行) func (g *GormTopMap) PublicOrmToMap() (returnData []map[string]interface{}) { if len(g.WhereMap) > 0 { g.Db.Table(g.TableName).Where(g.WhereMap).Find(&returnData) } else { g.Db.Table(g.TableName).Find(&returnData) } return } //输出Map查询数据库结果(单行) func (g *GormTopMap) PublicOrmToMapOne() (returnData map[string]interface{}) { var selectData []map[string]interface{} if len(g.WhereMap) > 0 { g.Db.Table(g.TableName).Where(g.WhereMap).Take(&selectData) } else { g.Db.Table(g.TableName).Take(&selectData) } if len(selectData) < 1 && len(selectData) > 0 { returnData = selectData[0] } return } //判断地址中是否还有http或https func JudgeHttpOrHttps(urlStr string) (isTrue bool) { isTrue = false re := regexp.MustCompile(`(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?`) result := re.FindAllStringSubmatch(urlStr, -1) // fmt.Printf("urlStr ======>%v\n", result) // for _,regVal := range result{ // if regVal // } if result == nil { isTrue = true } return } //获取工段信息 func GetWorkShopSection(id int64) (isTrue bool, workShopesStruct testpage.WorkShopsection) { //工段表结构 isTrue = false err := global.GVA_DB_Master.Where("ws_id = ?", id).First(&workShopesStruct).Error //获取工段信息 if err != nil { return } isTrue = true return } //用户端身份解析 func ClientIdentity() (isTrue bool, redisUserInfo testpage.RedisUserInfo) { // keyStr := strconv.FormatInt(global.GVA_INDEX_USERKEY, 10) // redisClient := redishandel.RunRedis() // tokenInfo, isTrue := redisClient.HashGetAll("system:userContent_" + global.GVA_CONFIG.RedisPrefix.Alias + "_" + keyStr) // if isTrue != true { // return // } // identityErr := mapstructure.Decode(tokenInfo, &redisUserInfo) // if identityErr != nil { // isTrue = false // return // } redisClient := redishandel.RunRedis() redisClient.SetRedisDb(5) tokenInfo, isTrue := redisClient.HashGetAll("ScanCode:UserInfo:LoginUser_" + global.GVA_CONFIG.RedisPrefix.Alias + "_" + global.GVA_SCANCODE_USERNUMBER) if isTrue == true { identityErr := mapstructure.Decode(tokenInfo, &redisUserInfo) if identityErr == nil { isTrue = true return } else { redisUserInfo, isTrue = getPeopleInfo() return } } else { redisUserInfo, isTrue = getPeopleInfo() return } isTrue = false return } //获取用户信息 func getPeopleInfo() (redisUserInfo testpage.RedisUserInfo, isTrue bool) { isTrue = false var ueInfo hrsystem.Personnel err := global.GVA_DB_HrDataBase.Where("`number` = ?", global.GVA_SCANCODE_USERNUMBER).First(&ueInfo).Error if err != nil { return } wechatStr := ueInfo.Wechat if ueInfo.WorkWechat != "" { wechatStr = ueInfo.WorkWechat } redisUserInfo.Id = strconv.FormatInt(ueInfo.Id, 10) // `json:"id"` redisUserInfo.Key = strconv.FormatInt(ueInfo.Key, 10) // `json:"key"` redisUserInfo.Number = ueInfo.Number // `json:"number"` redisUserInfo.Name = ueInfo.Name // `json:"name"` redisUserInfo.Positionleveles = strconv.FormatInt(ueInfo.PositionLevel, 10) // `json:"positionleveles"` redisUserInfo.Position = strconv.FormatInt(ueInfo.Position, 10) // `json:"position"` redisUserInfo.Adminorg = strconv.FormatInt(ueInfo.AdminOrg, 10) // `json:"adminorg"` redisUserInfo.Company = strconv.FormatInt(ueInfo.Company, 10) // `json:"company"` redisUserInfo.Emptype = fmt.Sprintf("%v", ueInfo.EmpType) // `json:"emptype"` redisUserInfo.Deparment = ueInfo.Deparment // `json:"deparment"` redisUserInfo.Jobclass = strconv.FormatInt(ueInfo.JobClass, 10) // `json:"jobclass"` redisUserInfo.Positiongrade = strconv.FormatInt(ueInfo.PositionGrade, 10) // `json:"positiongrade"` redisUserInfo.Role = ueInfo.Role // `json:"role"` redisUserInfo.Icon = ueInfo.Icon // `json:"icon"` redisUserInfo.Wechat = wechatStr // `json:"wechat"` menuStr, buttonStr := getRoleInt(ueInfo.Role) redisUserInfo.Jurisdiction = buttonStr // `json:"jurisdiction"` redisUserInfo.Menuoper = menuStr // `json:"menuoper"` oldGroup, _ := getOrgCont(strconv.FormatInt(ueInfo.Company, 10)) olddepart, _ := getOrgCont(ueInfo.Deparment) redisUserInfo.Oldgroup = oldGroup // `json:"oldgroup"` redisUserInfo.Olddepartment = olddepart // `json:"olddepartment"` oldpostis, _ := getPositionCont(ueInfo.Position) redisUserInfo.Oldposition = oldpostis // `json:"oldposition"` isTrue = true redisUserInfo.IsAdmin = fmt.Sprintf("%v", ueInfo.IsAdmin) redisClient := redishandel.RunRedis() redisClient.SetRedisDb(5) redisFileKey := fmt.Sprintf("ScanCode:UserInfo:LoginUser_%v_%v", global.GVA_CONFIG.RedisPrefix.Alias, global.GVA_SCANCODE_USERNUMBER) redisClient.SetRedisTime(604800) writeRedisData := map[string]interface{}{ "id": strconv.FormatInt(ueInfo.Id, 10), "key": strconv.FormatInt(ueInfo.Key, 10), "number": ueInfo.Number, "name": ueInfo.Name, "positionleveles": strconv.FormatInt(ueInfo.PositionLevel, 10), "position": strconv.FormatInt(ueInfo.Position, 10), "adminorg": strconv.FormatInt(ueInfo.AdminOrg, 10), "company": strconv.FormatInt(ueInfo.Company, 10), "emptype": fmt.Sprintf("%v", ueInfo.EmpType), "deparment": ueInfo.Deparment, "jobclass": strconv.FormatInt(ueInfo.JobClass, 10), "positiongrade": strconv.FormatInt(ueInfo.PositionGrade, 10), "role": ueInfo.Role, "icon": ueInfo.Icon, "wechat": wechatStr, "jurisdiction": buttonStr, "menuoper": menuStr, "oldgroup": oldGroup, "olddepartment": olddepart, "oldposition": oldpostis, "isadmin": fmt.Sprintf("%v", ueInfo.IsAdmin), } redisClient.HashMsetAdd(redisFileKey, writeRedisData) return } //获取权限点位 func getRoleInt(roleId string) (menuStr, buttonStr string) { var roleInfo systemuser.SystemRole err := global.GVA_DB_Master.Where("`r_id` = ?", roleId).First(&roleInfo).Error if err != nil { return } menuStr = roleInfo.MenuOper buttonStr = roleInfo.Jurisdiction return } //获取员工公司组织 func getOrgCont(id string) (oldId, orgName string) { var orgInfo hrsystem.AdministrativeOrganization err := global.GVA_DB_HrDataBase.Where("`id` = ?", id).First(&orgInfo).Error if err != nil { return } oldId = strconv.FormatInt(orgInfo.Schoole, 10) orgName = orgInfo.Name return } //获取新行政组织内容 func GetNewOrgCont(where interface{}, field ...string) (orgCont hrsystem.AdministrativeOrganization, err error) { gormDb := global.GVA_DB_HrDataBase.Model(&hrsystem.AdministrativeOrganization{}) if len(field) > 0 { fieldStr := strings.Join(field, ",") gormDb = gormDb.Select(fieldStr) } gormDb = gormDb.Where(where) err = gormDb.First(&orgCont).Error return } //获取员工公司职务 func getPositionCont(id int64) (oldId, orgName string) { var orgInfo hrsystem.Position err := global.GVA_DB_HrDataBase.Where("`id` = ?", id).First(&orgInfo).Error if err != nil { return } oldId = strconv.FormatInt(orgInfo.School, 10) orgName = orgInfo.Name return } //自定义管理端身份解析 func AdminClientIdentity() (isTrue bool, redisAdminInfo systemuser.RedisAdminInfo) { // keyStr := strconv.FormatInt(global.GVA_ADMIN_USERKEY, 10) // redisClient := redishandel.RunRedis() // tokenInfo, isTrue := redisClient.HashGetAll("system:SystemAdminInfo_" + global.GVA_CONFIG.RedisPrefix.Alias + "_" + keyStr) // if isTrue != true { // return // } // identityErr := mapstructure.Decode(tokenInfo, &redisAdminInfo) // if identityErr != nil { // isTrue = false // return // } isTrue = false return } //更具微信ID获取员工信息 func GetUesrContForWechatID(wechatId string) (isTrue bool, myCont PublicUserCont) { redisClient := redishandel.RunRedis() isTrue = false redisPrefix := "userInfo_" + global.GVA_CONFIG.RedisPrefix.PreFix + ":" + wechatId //redis KEY redisCont, redisErr := redisClient.HashGetAll(redisPrefix) if redisErr == true { myCont.Number = redisCont["number"] departmentid, departmentidErr := strconv.ParseInt(redisCont["departmentid"], 10, 64) if departmentidErr == nil { myCont.DepartmentId = departmentid } workshop, workshopErr := strconv.ParseInt(redisCont["workshopid"], 10, 64) if workshopErr == nil { myCont.WorkshopId = workshop } postid, postidErr := strconv.ParseInt(redisCont["postid"], 10, 64) if postidErr == nil { myCont.PostId = postid } tema, temaErr := strconv.ParseInt(redisCont["tema"], 10, 64) if temaErr == nil { myCont.Tema = tema } temakey, temakeyErr := strconv.ParseInt(redisCont["key"], 10, 64) if temakeyErr == nil { myCont.Key = temakey } stateval, statevalErr := strconv.Atoi(redisCont["key"]) if statevalErr == nil { myCont.State = stateval } hireset, hiresetErr := strconv.Atoi(redisCont["hireset"]) if hiresetErr == nil { myCont.HireSet = hireset } groupset, groupsetErr := strconv.ParseInt(redisCont["group"], 10, 64) if groupsetErr == nil { myCont.Group = groupset } myCont.WechatId = wechatId myCont.Name = redisCont["name"] gender, genderErr := strconv.Atoi(redisCont["gender"]) if genderErr == nil { myCont.Gender = gender } age, ageErr := strconv.Atoi(redisCont["age"]) if ageErr == nil { myCont.Age = age } myCont.Tel = redisCont["tel"] category, categoryErr := strconv.Atoi(redisCont["category"]) if categoryErr == nil { myCont.Category = category } certificatestype, certificatestypeErr := strconv.Atoi(redisCont["certificatestype"]) if certificatestypeErr == nil { myCont.CertificatesType = certificatestype } myCont.CertificatesNum = redisCont["certificatesnum"] myCont.Birthday = redisCont["birthday"] myCont.EntryTime = redisCont["entrytime"] myCont.QuitTimeAttr = redisCont["quittimeattr"] myCont.Addrest = redisCont["addrest"] myCont.Icon = redisCont["icon"] myCont.NickName = redisCont["nickname"] myCont.DepartmentName = redisCont["departmentname"] myCont.WorkshopName = redisCont["workshopname"] myCont.PostName = redisCont["postname"] myCont.TemaName = redisCont["teamname"] isTrue = true // fmt.Printf("1===============>%v\n", myCont) } else { var userCont testpage.PersonalDetails userErr := global.GVA_DB_Master.Model(&testpage.WorkMan{}).Select("worker_man.*", "worker_man_data.*").Joins("left join worker_man_data on worker_man_data.wmd_key = worker_man.wm_key").Where("`qywx_key` = ? OR `wx_key` = ?", wechatId, wechatId).Find(&userCont).Error userInfo := MapOut() if userErr == nil { userIconUrl := "" if userCont.Icon == "" { wechatInfo, wechatInfoErr := GetWorkWechatDuiZhao(wechatId) if wechatInfoErr == true { if wechatInfo.ThumbAvatar != "" { userIconUrl = wechatInfo.ThumbAvatar } else { userIconUrl = wechatInfo.Avatar } } } else { userIconUrl = userCont.Icon } userInfo["number"] = userCont.Number userInfo["departmentid"] = userCont.DepartmentId userInfo["workshopid"] = userCont.WorkshopId userInfo["postid"] = userCont.PostId userInfo["tema"] = userCont.Tema userInfo["key"] = userCont.Key userInfo["state"] = userCont.State userInfo["hireset"] = userCont.HireSet userInfo["group"] = userCont.Group userInfo["wechatid"] = wechatId userInfo["name"] = userCont.Name userInfo["gender"] = userCont.Gender userInfo["age"] = userCont.Age userInfo["tel"] = userCont.Tel userInfo["category"] = userCont.Category userInfo["certificatestype"] = userCont.CertificatesType userInfo["certificatesnum"] = userCont.CertificatesNum userInfo["birthday"] = TimeStampToDate(userCont.Birthday, 6) userInfo["entrytime"] = TimeStampToDate(userCont.EntryTime, 6) userInfo["quittimeattr"] = TimeStampToDate(userCont.QuitTimeAttr, 6) userInfo["addrest"] = userCont.Addrest userInfo["icon"] = userIconUrl userInfo["nickname"] = userCont.NickName isTrue = true myCont.Number = userCont.Number myCont.DepartmentId = userCont.DepartmentId bfIsTrue, bfInfo := GetBranchFactory(userCont.DepartmentId) if bfIsTrue == true { myCont.DepartmentName = bfInfo.Name userInfo["departmentname"] = bfInfo.Name } else { userInfo["departmentname"] = "" } myCont.WorkshopId = userCont.WorkshopId wsIsTrue, wsInfo := GetWorkShopSection(userCont.WorkshopId) if wsIsTrue == true { myCont.WorkshopName = wsInfo.Name userInfo["workshopname"] = wsInfo.Name } else { userInfo["workshopname"] = "" } myCont.PostId = userCont.PostId posErr, posCont := GetPosition(userCont.PostId) if posErr == true { myCont.PostName = posCont.Name userInfo["postname"] = posCont.Name } else { userInfo["postname"] = "" } myCont.Tema = userCont.Tema temErr, temCont := GetTeaming(userCont.Tema) if temErr == true { myCont.TemaName = temCont.Name userInfo["teamname"] = temCont.Name } else { userInfo["teamname"] = "" } myCont.Key = userCont.Key myCont.State = userCont.State myCont.HireSet = userCont.HireSet myCont.Group = userCont.Group myCont.WechatId = wechatId myCont.Name = userCont.Name myCont.Gender = userCont.Gender myCont.Age = userCont.Age myCont.Tel = userCont.Tel myCont.Category = userCont.Category myCont.CertificatesType = userCont.CertificatesType myCont.CertificatesNum = userCont.CertificatesNum myCont.Birthday = TimeStampToDate(userCont.Birthday, 6) myCont.EntryTime = TimeStampToDate(userCont.EntryTime, 6) myCont.QuitTimeAttr = TimeStampToDate(userCont.QuitTimeAttr, 6) myCont.Addrest = userCont.Addrest myCont.Icon = userIconUrl myCont.NickName = userCont.NickName redisClient.SetRedisTime(604800) redisClient.HashMsetAdd(redisPrefix, userInfo) // fmt.Printf("2===============>\n") } else { var userInfoStruct wechat.WechatUsers myErr := global.GVA_DB_WatchDate.Where("userid = ?", wechatId).First(&userInfoStruct).Error if myErr != nil { return } groupContErr, groupCont := GetGroupInfo(userInfoStruct.MainDepartment) groupID := 1 if groupContErr == true { var groupMap []int jsonErr := json.Unmarshal([]byte(groupCont.Group), &groupMap) if jsonErr == nil { if len(groupMap) > 0 { for g_index, g_val := range groupMap { if g_index == 0 { groupID = g_val } } } } } isTrue = true tadyTime := time.Now().Unix() userInfo["number"] = userInfoStruct.UserNumber userInfo["departmentid"] = userInfoStruct.MainDepartment userInfo["workshopid"] = 0 userInfo["postid"] = 0 userInfo["tema"] = 0 userInfo["key"] = 0 userInfo["state"] = userInfoStruct.Status userInfo["hireset"] = 1 userInfo["group"] = groupID userInfo["wechatid"] = wechatId userInfo["name"] = userInfoStruct.Name userInfo["gender"] = userInfoStruct.Gender userInfo["age"] = 0 userInfo["tel"] = userInfoStruct.Mobile userInfo["category"] = 1 userInfo["certificatestype"] = 1 userInfo["certificatesnum"] = "" userInfo["birthday"] = TimeStampToDate(0, 6) userInfo["entrytime"] = TimeStampToDate(tadyTime, 6) userInfo["quittimeattr"] = TimeStampToDate(0, 6) userInfo["addrest"] = 0 userInfo["icon"] = userInfoStruct.Avatar userInfo["nickname"] = userInfoStruct.Name userInfo["departmentname"] = "" userInfo["workshopname"] = "" userInfo["postname"] = "" userInfo["teamname"] = "" myCont.Number = userInfoStruct.UserNumber myCont.DepartmentId = userInfoStruct.MainDepartment myCont.WorkshopId = 0 myCont.PostId = 0 myCont.Tema = 0 myCont.Key = 0 myCont.State = userInfoStruct.Status myCont.HireSet = 1 myCont.Group = 1 myCont.WechatId = wechatId myCont.Name = userInfoStruct.Name myCont.Gender = userInfoStruct.Gender myCont.Age = 1 myCont.Tel = userInfoStruct.Mobile myCont.Category = 1 myCont.CertificatesType = 1 myCont.CertificatesNum = "" myCont.Birthday = TimeStampToDate(0, 6) myCont.EntryTime = TimeStampToDate(tadyTime, 6) myCont.QuitTimeAttr = TimeStampToDate(0, 6) myCont.Addrest = "" myCont.Icon = userInfoStruct.Avatar myCont.NickName = userInfoStruct.Name redisClient.SetRedisTime(604800) redisClient.HashMsetAdd(redisPrefix, userInfo) // fmt.Printf("3===============>\n") } } return } //获得分厂名称 func GetBranchFactory(id int64) (isTrue bool, ContInfo testpage.BranchFactory) { isTrue = false err := global.GVA_DB_Master.Where("bf_id = ?", id).First(&ContInfo).Error if err == nil { isTrue = true } return } //获取职务信息 func GetPosition(id int64) (isTrue bool, content testpage.Position) { isTrue = false err := global.GVA_DB_Master.Where("ps_id = ?", id).First(&content).Error if err == nil { isTrue = true } return } //获取班组信息 func GetTeaming(id int64) (isTrue bool, content testpage.Teaming) { isTrue = false err := global.GVA_DB_Master.Where("tm_id = ?", id).First(&content).Error if err == nil { isTrue = true } return } //获取职务最大权重ID func GetPositionMaxWeight(departmentID int64) (isTrue bool, content testpage.Position) { isTrue = false selectData := MapOut() err := global.GVA_DB_Master.Model(&testpage.Position{}).Select("MAX(ps_weight) AS weight").Where("ps_bf_id = ?", departmentID).First(&selectData).Error if err != nil { return } conErr := global.GVA_DB_Master.Where("ps_bf_id = ? AND ps_weight = ?", departmentID, selectData["weight"]).First(&content).Error if conErr == nil { isTrue = true } return } //获取职责内容 func GetDutyContDepart(id int64) (isTrue bool, dutyAssClass DutyAssClass) { isTrue = false var dutyCont assessmentmodel.DepartDuty err := global.GVA_DB_Performanceappraisal.Where("de_id = ?", id).First(&dutyCont).Error if err != nil { return } if dutyCont.State != 1 { return } var dutyConts assessmentmodel.DutyContent errCont := global.GVA_DB_Performanceappraisal.Where("dc_id = ?", dutyCont.DutyId).First(&dutyConts).Error if errCont != nil { return } if dutyConts.State != 1 { return } dutyAssClass.Title = dutyConts.Title dutyAssClass.ClassId = dutyCont.ClassId dutyAssClass.AssessId = dutyCont.AssessId var dutyClass assessmentmodel.DutyClass errClass := global.GVA_DB_Performanceappraisal.Where("id = ?", dutyCont.ClassId).First(&dutyClass).Error if errClass == nil { dutyAssClass.ClassTitle = dutyClass.Title } var dutyassess assessmentmodel.AssessMentitems errAss := global.GVA_DB_Performanceappraisal.Where("ai_id = ?", dutyCont.AssessId).First(&dutyassess).Error if errAss == nil { dutyAssClass.AssTitle = dutyassess.Title } isTrue = true return } //获取集团信息 func GetGroupCont(id int64) (isTrue bool, ContInfo wechat.GroupForm) { isTrue = false err := global.GVA_DB_WatchDate.Where("g_id = ?", id).First(&ContInfo).Error if err == nil { isTrue = true } return } //获取考核细则相关内容 func GetDutyCont(field, whereData interface{}) (isTrue bool, outData map[string]interface{}) { isTrue = false errAss := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.DutyContent{}).Select(field).Where(whereData).First(&outData).Error if errAss != nil { return } isTrue = true return } //获取人员信息 func GetUserInfoPublic(field interface{}, whereMap map[string]interface{}) (userCont testpage.PersonalDetails, isTrue bool) { isTrue = false var userInfo testpage.WorkMan userErr := global.GVA_DB_Master.Model(&userInfo).Select(field).Joins("left join worker_man_data on worker_man_data.wmd_key = worker_man.wm_key").Where(whereMap).Find(&userCont).Error if userErr == nil { isTrue = true } return } //获取考核指标信息 func GetTargetInfo(id int64) (content assessmentmodel.EvaluationTarget, isTrue bool) { isTrue = false err := global.GVA_DB_Performanceappraisal.Where("et_id = ?", id).First(&content).Error if err == nil { isTrue = true } return } //获取考核指标信息 func GetQualitativeTargetInfo(id int64) (content assessmentmodel.QualitativeTarget, isTrue bool) { isTrue = false err := global.GVA_DB_Performanceappraisal.Where("q_id = ?", id).First(&content).Error if err == nil { isTrue = true } return } //获取考核指标细则 func GetDetailedTargetInfo(id int64) (content assessmentmodel.DetailedTarget, isTrue bool) { isTrue = false err := global.GVA_DB_Performanceappraisal.Where("dt_id = ?", id).First(&content).Error if err == nil { isTrue = true } return } //获取考核指标细则 func GetDetailedTargetInfoWher(wher interface{}, filed ...string) (content assessmentmodel.DetailedTarget, isTrue bool) { isTrue = false goromDb := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.DetailedTarget{}) if len(filed) > 0 { fieldStr := strings.Join(filed, ",") goromDb = goromDb.Select(fieldStr) } err := goromDb.Where(wher).First(&content).Error if err == nil { isTrue = true } return } //获取考核指标细则 func GetDetailedTargetInfoTitle(id int64, title string) (content assessmentmodel.DetailedTarget, isTrue bool) { isTrue = false gormDb := global.GVA_DB_Performanceappraisal if title != "" { gormDb = gormDb.Where("dt_title LIKE ?", title) } err := gormDb.Where("dt_id = ?", id).First(&content).Error if err == nil { isTrue = true } return } //获取考核类别 func GetDutyClassInfo(id int64) (content assessmentmodel.DutyClass, isTrue bool) { isTrue = false err := global.GVA_DB_Performanceappraisal.Where("id = ?", id).First(&content).Error if err == nil { isTrue = true } return } //添加维度指标或维度权重 func AddDimenTargetWeight(setType, group, departmentID, dimensionId, targetId int64) { var weightSum int64 = 0 // fmt.Printf("1-----@---2------->%v\n", targetId) if targetId != 0 { weghtErr := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Where("`qe_state` = 1 AND `qe_group` = ? AND `qe_accept_evaluation` = ? AND `qe_dimension` = ? AND `qe_target` = ?", group, departmentID, dimensionId, targetId).Pluck("COALESCE(SUM(qe_reference_score), 0) as qe_reference_score", &weightSum).Error // msg = fmt.Sprintf("1-----@---1------->%v\n", weightSum) if weghtErr == nil { var ddwCont assessmentmodel.DepartmentDimensionWeight judgeTrue := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.DepartmentDimensionWeight{}).Select("ddw_id").Where("`ddw_hierarchy` = 2 AND `ddw_group` = ? AND `ddw_derpatment` = ? AND `ddw_dimension` = ? AND `ddw_target` = ?", group, departmentID, dimensionId, targetId).First(&ddwCont).Error if judgeTrue == nil { targetWeightMap := MapOut() targetWeightMap["ddw_hierarchy"] = 2 targetWeightMap["ddw_type"] = setType targetWeightMap["ddw_weight"] = weightSum targetWeightMap["ddw_time"] = time.Now().Unix() // global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.DepartmentDimensionWeight{}).Where("`ddw_group` = ? AND `ddw_derpatment` = ? AND `ddw_dimension` = ? AND `ddw_target` = ?", group, departmentID, dimensionId, targetId).Updates(&targetWeightMap) global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.DepartmentDimensionWeight{}).Where("`ddw_id` = ?", ddwCont.Id).Updates(&targetWeightMap) // msg = fmt.Sprintf("1--------1------->%v\n", weightSum) } else { var saveData assessmentmodel.DepartmentDimensionWeight saveData.Group = group saveData.DepartmentId = departmentID saveData.Dimension = dimensionId saveData.Target = targetId saveData.Weight = weightSum saveData.Addtime = time.Now().Unix() saveData.Type = int64(setType) saveData.Hierarchy = 2 global.GVA_DB_Performanceappraisal.Create(&saveData) // msg = fmt.Sprintf("2--------1------->%v\n", weightSum) } } else { var saveData assessmentmodel.DepartmentDimensionWeight saveData.Group = group saveData.DepartmentId = departmentID saveData.Dimension = dimensionId saveData.Target = targetId saveData.Weight = weightSum saveData.Addtime = time.Now().Unix() saveData.Type = int64(setType) saveData.Hierarchy = 2 global.GVA_DB_Performanceappraisal.Create(&saveData) // msg = fmt.Sprintf("3--------1------->%v\n", weightSum) } AddDimensionWeight(setType, group, departmentID, dimensionId) } // return } func AddDimensionWeight(setType, group, departmentID, dimensionId int64) { var weightSum int64 = 0 fmt.Printf("1-------@-------->%v\n", departmentID) if dimensionId != 0 { weghtErr := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Where("`qe_state` = 1 AND `qe_group` = ? AND `qe_accept_evaluation` = ? AND `qe_dimension` = ?", group, departmentID, dimensionId).Pluck("COALESCE(SUM(qe_reference_score), 0) as qe_reference_score", &weightSum).Error if weghtErr == nil { var ddwCont assessmentmodel.DepartmentDimensionWeight judgeTrue := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.DepartmentDimensionWeight{}).Select("ddw_id").Where("`ddw_hierarchy` = 1 AND `ddw_group` = ? AND `ddw_derpatment` = ? AND `ddw_dimension` = ?", group, departmentID, dimensionId).First(&ddwCont).Error if judgeTrue == nil { targetWeightMap := MapOut() targetWeightMap["ddw_hierarchy"] = 1 targetWeightMap["ddw_type"] = setType targetWeightMap["ddw_weight"] = weightSum targetWeightMap["ddw_time"] = time.Now().Unix() // global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.DepartmentDimensionWeight{}).Where("`ddw_group` = ? AND `ddw_derpatment` = ? AND `ddw_dimension` = ? AND `ddw_target` = ?", group, departmentID, dimensionId, targetId).Updates(&targetWeightMap) global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.DepartmentDimensionWeight{}).Where("`ddw_id` = ?", ddwCont.Id).Updates(&targetWeightMap) // fmt.Printf("1--------------->%v\n", weightSum) } else { var saveData assessmentmodel.DepartmentDimensionWeight saveData.Group = group saveData.DepartmentId = departmentID saveData.Dimension = dimensionId saveData.Target = 0 saveData.Weight = weightSum saveData.Addtime = time.Now().Unix() saveData.Type = int64(setType) saveData.Hierarchy = 1 global.GVA_DB_Performanceappraisal.Create(&saveData) // fmt.Printf("2--------------->%v\n", weightSum) } } else { var saveData assessmentmodel.DepartmentDimensionWeight saveData.Group = group saveData.DepartmentId = departmentID saveData.Dimension = dimensionId saveData.Target = 0 saveData.Weight = weightSum saveData.Addtime = time.Now().Unix() saveData.Type = int64(setType) saveData.Hierarchy = 1 global.GVA_DB_Performanceappraisal.Create(&saveData) // fmt.Printf("3--------------->%v\n", weightSum) } } } //获取维度或指标权重 func GetDimesionTargetWeight(setType, group, departmentID, dimensionId, targetId int64) (weight int64) { var ddwCont assessmentmodel.DepartmentDimensionWeight gormDb := global.GVA_DB_Performanceappraisal gormDb = gormDb.Select("ddw_weight").Where("`ddw_group` = ? AND `ddw_derpatment` = ? AND `ddw_dimension` = ?", group, departmentID, dimensionId) if setType == 2 { gormDb = gormDb.Where("`ddw_hierarchy` = 2 AND `ddw_target` = ?", targetId) } else { gormDb = gormDb.Where("`ddw_hierarchy` = 1") } judgeTrue := gormDb.First(&ddwCont).Error if judgeTrue != nil { weight = 0 } else { weight = ddwCont.Weight } return } //根据部门获取内勤数据 func GetOfficeWork(id, departmentId int64) (isTrue bool, roleUser []roleGroupBodyAry, roleGroup systemuser.RoleGroup) { isTrue = false departID := strconv.FormatInt(departmentId, 10) // var roleGroup systemuser.RoleGroup err := global.GVA_DB_Master.Where("`srg_id` = ?", id).First(&roleGroup).Error //16118387069540343 if err != nil { return } roleAry := MapOut() errMap := json.Unmarshal([]byte(roleGroup.Contentes), &roleAry) if errMap != nil { return } for i, v := range roleAry { // roleArys := MapOut() if i == departID { jsonMAp, _ := json.Marshal(v) jsonErrs := json.Unmarshal(jsonMAp, &roleUser) if jsonErrs == nil { isTrue = true } // fmt.Printf("%v------->%v------->%v\n", i, roleGroup, roleUser) } } return } //获取企业微信信息接收人 func GetSendMsgUser(id, departmentId int64) (isTrue bool, userStr string) { isTrue = false // err, departmentCont := GetBranchFactory(departmentId) // if err != true { // return // } departWhere := MapOut() departWhere["id"] = departmentId departmentCont, errDepart := GetNewOrgCont(departWhere, "wechat_organization_id") if errDepart != nil { return } err, roleGroup, _ := GetOfficeWork(id, int64(departmentCont.WechatOrganizationId)) if err != true { return } var userList []string for _, v := range roleGroup { userList = append(userList, v.Id) } if len(userList) > 0 { userStr = strings.Join(userList, "|") isTrue = true } return } //获取企业微信信息接收人数组形态 func GetSendMsgUserAry(id, departmentId int64) (isTrue bool, userStr []string) { isTrue = false // err, departmentCont := GetBranchFactory(departmentId) // if err != true { // return // } // err, roleGroup, _ := GetOfficeWork(id, int64(departmentCont.WechatId)) departWhere := MapOut() departWhere["id"] = departmentId departmentCont, errDepart := GetNewOrgCont(departWhere, "wechat_organization_id") if errDepart != nil { return } err, roleGroup, _ := GetOfficeWork(id, int64(departmentCont.WechatOrganizationId)) if err != true { return } var userList []string for _, v := range roleGroup { userList = append(userList, v.Id) } if len(userList) > 0 { // userStr = strings.Join(userList, "|") userStr = userList isTrue = true } return } //获取加减分订单 func GetScoreFlow(orderId string) (content assessmentmodel.ScoreFlow, isTrue bool) { isTrue = false judgeErr := global.GVA_DB_Performanceappraisal.Where("`sf_key` = ?", orderId).First(&content).Error if judgeErr == nil { isTrue = true } return } //审批流程 func GetEvaluationProcess(orderId string) (content assessmentmodel.EvaluationProcess, isTrue bool) { isTrue = false judgeErr := global.GVA_DB_Performanceappraisal.Where("`ep_order_key` = ?", orderId).First(&content).Error if judgeErr == nil { isTrue = true } return } //考核方案 func GetQualitativeEvaluation(orderId string) (content assessmentmodel.QualitativeEvaluation, isTrue bool) { isTrue = false judgeErr := global.GVA_DB_Performanceappraisal.Where("`qe_id` = ?", orderId).First(&content).Error if judgeErr == nil { isTrue = true } return } //获取考核项目关联项目 /* @orderId 加减分订单Id returnData #targettitle 指标名称 #detailedRulesTitle 明细 #detailedRulesInfo 明细说明 */ func GetDutyAssociatedItems(orderId string) (targettitle, detailedRulesTitle, detailedRulesInfo, unit string, flowContent assessmentmodel.ScoreFlow, qualEvalInfo assessmentmodel.QualitativeEvaluation, isTrue bool) { flowContent, isTrue = GetScoreFlow(orderId) if isTrue != true { return } qualEvalCont, qualEvalErr := GetQualitativeEvaluation(strconv.FormatInt(flowContent.EvaluationPlan, 10)) if qualEvalErr != true { return } unit = qualEvalCont.Unit targetCont, targetErr := GetTargetInfo(qualEvalCont.Target) if targetErr == true { targettitle = targetCont.Title unit = targetCont.Uniteing } detailedTargetCont, detailedTargetErr := GetDetailedTargetInfo(qualEvalCont.Target) if detailedTargetErr == true { detailedRulesTitle = detailedTargetCont.Title detailedRulesInfo = detailedTargetCont.Content } isTrue = true return } //获取加减分订单 func GetFlowLog(orderId string) (content assessmentmodel.FlowLog, isTrue bool) { isTrue = false judgeErr := global.GVA_DB_Performanceappraisal.Where("`fl_key` = ?", orderId).First(&content).Error if judgeErr == nil { isTrue = true } return } /* @orderId 加减分订单Id returnData #targettitle 指标名称 #detailedRulesTitle 明细 #detailedRulesInfo 明细说明 */ func GetDutyRationtedItems(orderId string) (targettitle, detailedRulesTitle, detailedRulesInfo, unit string, flowContent assessmentmodel.FlowLog, isTrue bool) { flowContent, isTrue = GetFlowLog(orderId) if isTrue != true { return } qualEvalCont, qualEvalErr := GetQualitativeEvaluation(flowContent.EvaluationPlan) if qualEvalErr != true { return } unit = qualEvalCont.Unit targetCont, targetErr := GetTargetInfo(qualEvalCont.Target) if targetErr == true { targettitle = targetCont.Title unit = targetCont.Uniteing } detailedTargetCont, detailedTargetErr := GetDetailedTargetInfo(qualEvalCont.Target) if detailedTargetErr == true { detailedRulesTitle = detailedTargetCont.Title detailedRulesInfo = detailedTargetCont.Content } isTrue = true return } //获取角色组 func GetRoleGroup(id int64) (roleGroup systemuser.RoleGroup, isTrue bool) { isTrue = false err := global.GVA_DB_Master.Where("`srg_id` = ?", id).First(&roleGroup).Error //16118387069540343 if err != nil { return } isTrue = true return } //根据userkey 用户获取信息 func GetWorkUser(key string) (userCont testpage.PersonalDetails, isTrue bool) { isTrue = false var userInfo testpage.WorkMan userErr := global.GVA_DB_Master.Model(&userInfo).Select("worker_man.*,worker_man_data.*").Joins("left join worker_man_data on worker_man_data.wmd_key = worker_man.wm_key").Where("wm_key = ?", key).First(&userCont).Error if userErr == nil { isTrue = true } iconUrl := "" if userCont.Icon == "" { if userCont.WechatId != "" { wechatInfo, wechatErr := GetWorkWechatDuiZhao(userCont.WechatId) if wechatErr == true { iconUrl = wechatInfo.Avatar userCont.Icon = iconUrl } } if userCont.WorkWechatId != "" { if iconUrl == "" { wechatWorkInfo, wechatWorkErr := GetWorkWechatDuiZhao(userCont.WorkWechatId) if wechatWorkErr == true { iconUrl = wechatWorkInfo.Avatar userCont.Icon = iconUrl } } } } return } type sendMsg struct { Title string `json:"title"` Unit string `json:"unit"` //单位"` Cycles int `json:"cycle"` //1:班;2:天;3:周;4:月;5:季度;6:年"` CycleAttres int `json:"cycleattr"` //辅助计数"` Dimension int64 `json:"dimension"` //维度"` Target int64 `json:"target"` //指标"` DetailedTarget int64 `json:"detailedtarget"` //指标细则"` } //查看定量考核数据 func LookRationInfo(id int64) (cont sendMsg, isTrue bool) { isTrue = false qeInfo, isTrue := GetQualitativeEvaluation(strconv.FormatInt(id, 10)) if isTrue == false { return } cont.Cycles = qeInfo.Cycles cont.CycleAttres = qeInfo.CycleAttres cont.Target = qeInfo.Target targetCong, isTrues := GetTargetInfo(qeInfo.Target) if isTrues == false { return } cont.Title = targetCong.Title cont.Unit = targetCong.Uniteing isTrue = true if qeInfo.DetailedTarget != 0 { deTarInfo, isTruees := GetDetailedTargetInfo(qeInfo.DetailedTarget) if isTruees == true { cont.Title = deTarInfo.Title } } cont.Dimension = qeInfo.Dimension cont.DetailedTarget = qeInfo.DetailedTarget return } //获取企业微信对照表 func GetWorkWechatDuiZhao(openid string) (userInfoStruct wechat.WechatUsers, isTrue bool) { isTrue = false myErr := global.GVA_DB_WatchDate.Where("userid = ?", openid).First(&userInfoStruct).Error if myErr == nil { isTrue = true } return } //步骤内容写入 /* @flowID 流程ID @userKey 操作人key @roleGroupId 角色组Id @stepName 步骤名称 @typeclass 1、定性;2、定量 @state 状态 @stepInt 当前是第几部 @recStrat 是否改正 @nextStep 下一步 */ func StepAddData(flowID, roleGroupId int64, nextStep, stepName, typeclass, state, stepInt int, userKey string) { if state < 1 { state = 1 } var evalProCont assessmentmodel.EvaluationProcess judgeErr := global.GVA_DB_Performanceappraisal.Where("`ep_order_key` = ?", flowID).First(&evalProCont).Error var flowStepAryMap []FlowStep if judgeErr != nil { var flowSteping FlowStep flowSteping.Step = 1 flowSteping.StepName = GetSetpName(stepName) //步骤名称 flowSteping.Key = strconv.FormatInt(flowID, 10) //流程ID flowSteping.State = 2 // (1:为操作;2:已操作;3:驳回) flowSteping.RoleGroup = roleGroupId //角色组 flowSteping.NextStep = 2 //下一步 1:创建;2:创建人部门负责人审批:3:责任划分;4:责任部门审批;5:主要责任人整改;6:责任部门审批;7:验收 flowSteping.ClickName = userKey //操作人 flowSteping.AddTime = time.Now().Unix() //添加时间 flowStepAryMap = append(flowStepAryMap, flowSteping) evalProCont.OrderKey = flowID evalProCont.Step = 1 evalProCont.State = state evalProCont.TypeClass = typeclass evalProCont.Time = time.Now().Unix() evalProCont.StartTime = time.Now().Unix() evalProCont.RoleGroup = roleGroupId flowStepJson, flowStepErr := json.Marshal(flowStepAryMap) if flowStepErr == nil { evalProCont.Content = string(flowStepJson) } evalProCont.Participants = userKey evalProCont.NextStep = nextStep if nextStep != 0 { var flowAry []FlowAllMap evalProCont.NextContent, flowAry = IntegrationFlowAll(flowID, typeclass) var userKeyMap []string for _, fav := range flowAry { if fav.Step == nextStep { for _, facv := range fav.UserList { if IsItTrueString(facv.Id, userKeyMap) == false { userKeyMap = append(userKeyMap, facv.Id) } } } } if len(userKeyMap) > 0 { evalProCont.NextExecutor = strings.Join(userKeyMap, ",") } else { evalProCont.NextExecutor = "" } } else { evalProCont.NextExecutor = "" } global.GVA_DB_Performanceappraisal.Create(&evalProCont) } else { var flowStepAry []FlowStep var flowStepArys []FlowStep json.Unmarshal([]byte(evalProCont.Content), &flowStepAry) var userKeyMap []string for _, f_v := range flowStepAry { if f_v.Step == evalProCont.Step { f_v.State = 2 } flowStepArys = append(flowStepArys, f_v) } var flowStep FlowStep flowStep.Step = evalProCont.Step + 1 flowStep.StepName = GetSetpName(stepName) //步骤名称 flowStep.Key = strconv.FormatInt(flowID, 10) flowStep.State = 2 flowStep.RoleGroup = roleGroupId flowStep.NextStep = nextStep flowStep.ClickName = userKey flowStep.AddTime = time.Now().Unix() flowStepArys = append(flowStepArys, flowStep) saveData := MapOut() saveData["ep_time"] = time.Now().Unix() saveData["ep_role_group"] = roleGroupId saveData["ep_step"] = evalProCont.Step + 1 flowStepJson, flowStepErr := json.Marshal(flowStepArys) if flowStepErr == nil { saveData["ep_cont"] = string(flowStepJson) } saveData["ep_next_step"] = nextStep if nextStep > 0 { var flowContAry []FlowAllMap json.Unmarshal([]byte(evalProCont.NextContent), &flowContAry) if len(flowContAry) > 0 { for _, fav := range flowContAry { if fav.Step == nextStep { for _, facv := range fav.UserList { if IsItTrueString(facv.Id, userKeyMap) == false { userKeyMap = append(userKeyMap, facv.Id) } } } } } if len(userKeyMap) > 0 { saveData["ep_next_executor"] = strings.Join(userKeyMap, ",") } else { saveData["ep_next_executor"] = "" } } else { saveData["ep_next_executor"] = "" } saveData["ep_participants"] = fmt.Sprintf("%v,%v", evalProCont.Participants, userKey) saveData["ep_state"] = state saveData["ep_next_cont"] = InsetFlowLog(state, stepInt, userKey, evalProCont.NextContent) // fmt.Printf("Flow---Map:--->%v\n", saveData) caozuoMap := MapOut() caozuoMap["flowID"] = flowID caozuoMap["roleGroupId"] = roleGroupId caozuoMap["nextStep"] = nextStep caozuoMap["stepName"] = stepName caozuoMap["typeclass"] = typeclass caozuoMap["state"] = state caozuoMap["stepInt"] = stepInt caozuoMap["userKey"] = userKey caozuoMap["NextContent"] = evalProCont.NextContent // mapJson, _ := json.Marshal(caozuoMap) // fmt.Printf("Flow---Map:--Out---->%v\n", string(mapJson)) // flowID, roleGroupId int64, nextStep, stepName, typeclass, state, stepInt int, userKey string EiteDutiesInfoes(evalProCont.Id, saveData) } } func StepAddDataEs(flowID, roleGroupId int64, nextStep, stepName, typeclass, state, stepInt int, userKey string, encFile []EnclosureFormat) { if state < 1 { state = 1 } var evalProCont assessmentmodel.EvaluationProcess judgeErr := global.GVA_DB_Performanceappraisal.Where("`ep_order_key` = ?", flowID).First(&evalProCont).Error var flowStepAryMap []FlowStep if judgeErr != nil { var flowSteping FlowStep flowSteping.Step = 1 flowSteping.StepName = GetSetpName(stepName) //步骤名称 flowSteping.Key = strconv.FormatInt(flowID, 10) //流程ID flowSteping.State = 2 // (1:为操作;2:已操作;3:驳回) flowSteping.RoleGroup = roleGroupId //角色组 flowSteping.NextStep = 2 //下一步 1:创建;2:创建人部门负责人审批:3:责任划分;4:责任部门审批;5:主要责任人整改;6:责任部门审批;7:验收 flowSteping.ClickName = userKey //操作人 flowSteping.AddTime = time.Now().Unix() //添加时间 flowStepAryMap = append(flowStepAryMap, flowSteping) evalProCont.OrderKey = flowID evalProCont.Step = 1 evalProCont.State = state evalProCont.TypeClass = typeclass evalProCont.Time = time.Now().Unix() evalProCont.StartTime = time.Now().Unix() evalProCont.RoleGroup = roleGroupId flowStepJson, flowStepErr := json.Marshal(flowStepAryMap) if flowStepErr == nil { evalProCont.Content = string(flowStepJson) } evalProCont.Participants = userKey var flowAry []FlowAllMap evalProCont.NextContent, flowAry = IntegrationFlowAllEs(flowID, typeclass, encFile) evalProCont.NextStep = nextStep if nextStep > 0 { var userKeyMap []string for _, fav := range flowAry { if fav.Step == nextStep { for _, facv := range fav.UserList { if IsItTrueString(facv.Id, userKeyMap) == false { userKeyMap = append(userKeyMap, facv.Id) } } } } if len(userKeyMap) > 0 { evalProCont.NextExecutor = strings.Join(userKeyMap, ",") } else { evalProCont.NextExecutor = "" } } else { evalProCont.NextExecutor = "" } global.GVA_DB_Performanceappraisal.Create(&evalProCont) } else { var flowStepAry []FlowStep var flowStepArys []FlowStep json.Unmarshal([]byte(evalProCont.Content), &flowStepAry) for _, f_v := range flowStepAry { if f_v.Step == evalProCont.Step { f_v.State = 2 } flowStepArys = append(flowStepArys, f_v) } var flowStep FlowStep flowStep.Step = evalProCont.Step + 1 flowStep.StepName = GetSetpName(stepName) //步骤名称 flowStep.Key = strconv.FormatInt(flowID, 10) flowStep.State = 2 flowStep.RoleGroup = roleGroupId flowStep.NextStep = nextStep flowStep.ClickName = userKey flowStep.AddTime = time.Now().Unix() flowStepArys = append(flowStepArys, flowStep) saveData := MapOut() saveData["ep_time"] = time.Now().Unix() saveData["ep_role_group"] = roleGroupId saveData["ep_step"] = evalProCont.Step + 1 flowStepJson, flowStepErr := json.Marshal(flowStepArys) if flowStepErr == nil { saveData["ep_cont"] = string(flowStepJson) } saveData["ep_next_step"] = nextStep if nextStep > 0 { var userKeyMap []string var flowContAry []FlowAllMap json.Unmarshal([]byte(evalProCont.NextContent), &flowContAry) if len(flowContAry) > 0 { for _, fav := range flowContAry { if fav.Step == nextStep { for _, facv := range fav.UserList { if IsItTrueString(facv.Id, userKeyMap) == false { userKeyMap = append(userKeyMap, facv.Id) } } } } } if len(userKeyMap) > 0 { saveData["ep_next_executor"] = strings.Join(userKeyMap, ",") } else { saveData["ep_next_executor"] = "" } } else { saveData["ep_next_executor"] = "" } saveData["ep_participants"] = fmt.Sprintf("%v,%v", evalProCont.Participants, userKey) saveData["ep_state"] = state saveData["ep_next_cont"] = InsetFlowLogEs(state, stepInt, userKey, evalProCont.NextContent, encFile) // fmt.Printf("Flow---Map:--->%v\n", saveData) caozuoMap := MapOut() caozuoMap["flowID"] = flowID caozuoMap["roleGroupId"] = roleGroupId caozuoMap["nextStep"] = nextStep caozuoMap["stepName"] = stepName caozuoMap["typeclass"] = typeclass caozuoMap["state"] = state caozuoMap["stepInt"] = stepInt caozuoMap["userKey"] = userKey caozuoMap["NextContent"] = evalProCont.NextContent // mapJson, _ := json.Marshal(caozuoMap) // fmt.Printf("Flow---Map:--Out---->%v\n", string(mapJson)) // flowID, roleGroupId int64, nextStep, stepName, typeclass, state, stepInt int, userKey string EiteDutiesInfoes(evalProCont.Id, saveData) } } //流程操作解析 /* @state 状态 @stepInt 当前是第几部 @recStrat 是否改正 @userKey 操作人key @flowMapStr 流程图字符串 */ func InsetFlowLog(state, stepInt int, userKey, flowMapStr string) (flowAllMap string) { // fmt.Printf("Flow_log:--Begin-->%v-->%v\n", stepInt, flowMapStr) var flowMap []FlowAllMap jsonErr := json.Unmarshal([]byte(flowMapStr), &flowMap) // fmt.Printf("Flow_log:--Begin---Err---->%v\n", jsonErr) if jsonErr != nil { flowAllMap = flowMapStr return } // fmt.Printf("Flow_log:--Begin-1->%v-->%v", stepInt, flowMapStr) var eiteFlowMap []FlowAllMap for _, v := range flowMap { var eiteFlowInfo FlowAllMap eiteFlowInfo.Step = v.Step eiteFlowInfo.NodeName = v.NodeName if v.Step < stepInt { eiteFlowInfo.State = 2 } else if v.Step == stepInt { eiteFlowInfo.State = state } else { eiteFlowInfo.State = 1 } eiteFlowInfo.Class = v.Class // fmt.Printf("Flow_log:--Step-->%v-->%v\n", v.Step, stepInt) if v.Step == stepInt { var userClickAry []UserListFlowAll for _, u_v := range v.UserList { var userClick UserListFlowAll userClick.Id = u_v.Id userClick.Name = u_v.Name userClick.Icon = u_v.Icon userClick.Wechat = u_v.Wechat userClick.Group = u_v.Group userClick.GroupName = u_v.GroupName userClick.DepartmentId = u_v.DepartmentId userClick.DepartmentName = u_v.DepartmentName userClick.WorkshopId = u_v.WorkshopId userClick.WorkshopName = u_v.WorkshopName userClick.PostId = u_v.PostId userClick.PostName = u_v.PostName userClick.Tema = u_v.Tema userClick.TemaName = u_v.TemaName userClick.Wechat = u_v.Wechat // fmt.Printf("Flow_log:--UsekKey-->%v-->%v\n", u_v.Id, userKey) if u_v.Id == userKey { var logListMap LogList logListMap.State = state logListMap.TimeVal = GetToDayAll() userClick.LogList = append(userClick.LogList, logListMap) } userClickAry = append(userClickAry, userClick) } eiteFlowInfo.UserList = userClickAry } else { eiteFlowInfo.UserList = v.UserList } eiteFlowMap = append(eiteFlowMap, eiteFlowInfo) } jsonStr, jsonErrSet := json.Marshal(eiteFlowMap) // fmt.Printf("Flow_log:--jsonErr-->%v-->%v\n", jsonErrSet, string(jsonStr)) if jsonErrSet == nil { flowAllMap = string(jsonStr) } return } func InsetFlowLogEs(state, stepInt int, userKey, flowMapStr string, encFile []EnclosureFormat) (flowAllMap string) { // fmt.Printf("Flow_log:--Begin-->%v-->%v\n", stepInt, flowMapStr) var flowMap []FlowAllMap jsonErr := json.Unmarshal([]byte(flowMapStr), &flowMap) // fmt.Printf("Flow_log:--Begin---Err---->%v\n", jsonErr) if jsonErr != nil { flowAllMap = flowMapStr return } // fmt.Printf("Flow_log:--Begin-1->%v-->%v", stepInt, flowMapStr) var eiteFlowMap []FlowAllMap for _, v := range flowMap { var eiteFlowInfo FlowAllMap eiteFlowInfo.Step = v.Step eiteFlowInfo.NodeName = v.NodeName if v.Step < stepInt { eiteFlowInfo.State = 2 } else if v.Step == stepInt { eiteFlowInfo.State = state } else { eiteFlowInfo.State = 1 } eiteFlowInfo.Class = v.Class // fmt.Printf("Flow_log:--Step-->%v-->%v\n", v.Step, stepInt) if v.Step == stepInt { var userClickAry []UserListFlowAll for _, u_v := range v.UserList { var userClick UserListFlowAll userClick.Id = u_v.Id userClick.Name = u_v.Name userClick.Icon = u_v.Icon userClick.Wechat = u_v.Wechat userClick.Group = u_v.Group userClick.GroupName = u_v.GroupName userClick.DepartmentId = u_v.DepartmentId userClick.DepartmentName = u_v.DepartmentName userClick.WorkshopId = u_v.WorkshopId userClick.WorkshopName = u_v.WorkshopName userClick.PostId = u_v.PostId userClick.PostName = u_v.PostName userClick.Tema = u_v.Tema userClick.TemaName = u_v.TemaName userClick.Wechat = u_v.Wechat // fmt.Printf("Flow_log:--UsekKey-->%v-->%v\n", u_v.Id, userKey) if u_v.Id == userKey { var logListMap LogList logListMap.State = state logListMap.TimeVal = GetToDayAll() logListMap.Enclosure = encFile userClick.LogList = append(userClick.LogList, logListMap) } userClickAry = append(userClickAry, userClick) } eiteFlowInfo.UserList = userClickAry } else { eiteFlowInfo.UserList = v.UserList } eiteFlowMap = append(eiteFlowMap, eiteFlowInfo) } jsonStr, jsonErrSet := json.Marshal(eiteFlowMap) // fmt.Printf("Flow_log:--jsonErr-->%v-->%v\n", jsonErrSet, string(jsonStr)) if jsonErrSet == nil { flowAllMap = string(jsonStr) } return } //写入责任分配节点人员信息 func WriteFlowMainSet(orderId int64, userKey []int64) { fmt.Printf("Zeren--1-->%v\n", userKey) if len(userKey) < 1 { return } var evalProCont assessmentmodel.EvaluationProcess judgeErr := global.GVA_DB_Performanceappraisal.Where("`ep_order_key` = ?", orderId).First(&evalProCont).Error if judgeErr != nil { fmt.Printf("Zeren--1-1->%v\n", userKey) return } flowAllMapOldStr := evalProCont.NextContent fmt.Printf("Zeren--2-->%v\n", flowAllMapOldStr) var flowMap []FlowAllMap jsonErr := json.Unmarshal([]byte(evalProCont.NextContent), &flowMap) if jsonErr != nil { fmt.Printf("Zeren--2-1->%v\n", jsonErr) return } fmt.Printf("Zeren--3-->%v\n", flowMap) var eiteFlowMap []FlowAllMap for _, v := range flowMap { var eiteFlowInfo FlowAllMap eiteFlowInfo.Step = v.Step eiteFlowInfo.NodeName = v.NodeName eiteFlowInfo.State = v.State eiteFlowInfo.Class = v.Class if v.Step == 5 { var userClickAry []UserListFlowAll for _, u_v := range userKey { userConting, _ := GetWorkUser(strconv.FormatInt(u_v, 10)) var wechatIdStr string if userConting.WechatId != "" { wechatIdStr = userConting.WechatId } if userConting.WorkWechatId != "" { wechatIdStr = userConting.WorkWechatId } _, userCont := GetUesrContForWechatID(wechatIdStr) var returnUser UserListFlowAll returnUser.Id = strconv.FormatInt(userCont.Key, 10) returnUser.Name = userCont.Name returnUser.Icon = userCont.Icon returnUser.Group = userCont.Group // where := MapOut() // where["id"] = userCont.Group // orgCont, _ := GetNewOrgCont(where, "id", "name") // returnUser.GroupName = orgCont.Name _, groupCont := GetGroupCont(userCont.Group) returnUser.GroupName = groupCont.Name returnUser.DepartmentId = userCont.DepartmentId returnUser.DepartmentName = userCont.DepartmentName returnUser.WorkshopId = userCont.WorkshopId returnUser.WorkshopName = userCont.WorkshopName returnUser.PostId = userCont.PostId returnUser.PostName = userCont.PostName returnUser.Tema = userCont.Tema returnUser.TemaName = userCont.TemaName returnUser.Wechat = userCont.WechatId userClickAry = append(userClickAry, returnUser) } eiteFlowInfo.UserList = userClickAry fmt.Printf("Zeren--4-->%v\n", userClickAry) } else { eiteFlowInfo.UserList = v.UserList } eiteFlowMap = append(eiteFlowMap, eiteFlowInfo) } jsonStr, jsonErrSet := json.Marshal(eiteFlowMap) if jsonErrSet == nil { flowAllMapOldStr = string(jsonStr) } saveEiteData := MapOut() saveEiteData["ep_time"] = time.Now().Unix() saveEiteData["ep_next_cont"] = flowAllMapOldStr fmt.Printf("Zeren--5-->%v\n", saveEiteData) EiteDutiesInfoes(evalProCont.Id, saveEiteData) } //组合流程图全面 /* @class 流程类型 */ func IntegrationFlowAll(flowID int64, class int) (flowAllMap string, flowMap []FlowAllMap) { // var flowMap []FlowAllMap //1、创建 var oneFlowInfo FlowAllMap oneFlowInfo.Step = 1 oneFlowInfo.NodeName = GetSetpName(1) oneFlowInfo.State = 2 oneFlowInfo.Class = 1 oneFlowInfo.UserList = GetFlowNodeMan(flowID, class, 1, 1) flowMap = append(flowMap, oneFlowInfo) // fmt.Print("Flow_log:-->%v") if class == 1 { //定性 var scoreFlowCont assessmentmodel.ScoreFlow flowLogErr := global.GVA_DB_Performanceappraisal.Where("sf_key = ?", flowID).First(&scoreFlowCont).Error if flowLogErr == nil { //2、创建人部门负责人审核 var twoFlowInfo FlowAllMap twoFlowInfo.Step = 2 twoFlowInfo.NodeName = GetSetpName(2) twoFlowInfo.State = 1 twoFlowInfo.Class = 1 twoFlowInfo.UserList = GetFlowNodeMan(flowID, class, 3, 2) flowMap = append(flowMap, twoFlowInfo) //3、被考核部门内勤进行责任划分 var threeFlowInfo FlowAllMap threeFlowInfo.Step = 3 threeFlowInfo.NodeName = GetSetpName(3) threeFlowInfo.State = 1 threeFlowInfo.Class = 1 threeFlowInfo.UserList = GetFlowNodeMan(flowID, class, 4, 2) flowMap = append(flowMap, threeFlowInfo) //4、被考核部门负责人对责任划分确认 var fourFlowInfo FlowAllMap fourFlowInfo.Step = 4 fourFlowInfo.NodeName = GetSetpName(7) fourFlowInfo.State = 1 fourFlowInfo.Class = 1 fourFlowInfo.UserList = GetFlowNodeMan(flowID, class, 5, 2) flowMap = append(flowMap, fourFlowInfo) if scoreFlowCont.Rectification == 1 { //5、整改人节点。由内勤指定 var fiveFlowInfo FlowAllMap fiveFlowInfo.Step = 5 fiveFlowInfo.NodeName = GetSetpName(4) fiveFlowInfo.State = 1 fiveFlowInfo.Class = 2 // fiveFlowInfo.UserList = GetFlowNodeMan(flowID, class, 5) flowMap = append(flowMap, fiveFlowInfo) //6、被考核部门负责人对整改措施确认 var sixFlowInfo FlowAllMap sixFlowInfo.Step = 6 sixFlowInfo.NodeName = GetSetpName(7) sixFlowInfo.State = 1 sixFlowInfo.Class = 1 sixFlowInfo.UserList = GetFlowNodeMan(flowID, class, 5, 2) flowMap = append(flowMap, sixFlowInfo) //7、发起人验收 var serverFlowInfo FlowAllMap serverFlowInfo.Step = 7 serverFlowInfo.NodeName = GetSetpName(5) serverFlowInfo.State = 1 serverFlowInfo.Class = 1 serverFlowInfo.UserList = GetFlowNodeMan(flowID, class, 1, 2) flowMap = append(flowMap, serverFlowInfo) } else { //5、发起人验收 var serverEsFlowInfo FlowAllMap serverEsFlowInfo.Step = 5 serverEsFlowInfo.NodeName = GetSetpName(5) serverEsFlowInfo.State = 1 serverEsFlowInfo.Class = 1 serverEsFlowInfo.UserList = GetFlowNodeMan(flowID, class, 1, 2) flowMap = append(flowMap, serverEsFlowInfo) } } } else { //定量 //1、创建 var twoFlowInfo FlowAllMap twoFlowInfo.Step = 2 twoFlowInfo.NodeName = GetSetpName(7) twoFlowInfo.State = 1 twoFlowInfo.Class = 1 twoFlowInfo.UserList = GetFlowNodeMan(flowID, class, 5, 2) flowMap = append(flowMap, twoFlowInfo) } flowAllMapByte, eer := json.Marshal(flowMap) if eer == nil { flowAllMap = string(flowAllMapByte) } return } func IntegrationFlowAllEs(flowID int64, class int, encFile []EnclosureFormat) (flowAllMap string, flowMap []FlowAllMap) { // var flowMap []FlowAllMap //1、创建 var oneFlowInfo FlowAllMap oneFlowInfo.Step = 1 oneFlowInfo.NodeName = GetSetpName(1) oneFlowInfo.State = 2 oneFlowInfo.Class = 1 oneFlowInfo.UserList = GetFlowNodeManEs(flowID, class, 1, 1, encFile) flowMap = append(flowMap, oneFlowInfo) // fmt.Print("Flow_log:-->%v") if class == 1 { var scoreFlowCont assessmentmodel.ScoreFlow flowLogErr := global.GVA_DB_Performanceappraisal.Where("sf_key = ?", flowID).First(&scoreFlowCont).Error if flowLogErr == nil { if scoreFlowCont.PlusReduceScore != 1 { //2、创建人部门负责人审核 var twoFlowInfo FlowAllMap twoFlowInfo.Step = 2 twoFlowInfo.NodeName = GetSetpName(2) twoFlowInfo.State = 1 twoFlowInfo.Class = 1 twoFlowInfo.UserList = GetFlowNodeManEs(flowID, class, 3, 2, encFile) flowMap = append(flowMap, twoFlowInfo) //3、被考核部门内勤进行责任划分 var threeFlowInfo FlowAllMap threeFlowInfo.Step = 3 threeFlowInfo.NodeName = GetSetpName(3) threeFlowInfo.State = 1 threeFlowInfo.Class = 1 threeFlowInfo.UserList = GetFlowNodeManEs(flowID, class, 4, 2, encFile) flowMap = append(flowMap, threeFlowInfo) //4、被考核部门负责人对责任划分确认 var fourFlowInfo FlowAllMap fourFlowInfo.Step = 4 fourFlowInfo.NodeName = GetSetpName(7) fourFlowInfo.State = 1 fourFlowInfo.Class = 1 fourFlowInfo.UserList = GetFlowNodeManEs(flowID, class, 5, 2, encFile) flowMap = append(flowMap, fourFlowInfo) if scoreFlowCont.Rectification == 1 { //5、整改人节点。由内勤指定 var fiveFlowInfo FlowAllMap fiveFlowInfo.Step = 5 fiveFlowInfo.NodeName = GetSetpName(4) fiveFlowInfo.State = 1 fiveFlowInfo.Class = 2 // fiveFlowInfo.UserList = GetFlowNodeManEs(flowID, class, 5,encFile) flowMap = append(flowMap, fiveFlowInfo) //6、被考核部门负责人对整改措施确认 var sixFlowInfo FlowAllMap sixFlowInfo.Step = 6 sixFlowInfo.NodeName = GetSetpName(7) sixFlowInfo.State = 1 sixFlowInfo.Class = 1 sixFlowInfo.UserList = GetFlowNodeManEs(flowID, class, 5, 2, encFile) flowMap = append(flowMap, sixFlowInfo) //7、发起人验收 var serverFlowInfo FlowAllMap serverFlowInfo.Step = 7 serverFlowInfo.NodeName = GetSetpName(5) serverFlowInfo.State = 1 serverFlowInfo.Class = 1 serverFlowInfo.UserList = GetFlowNodeManEs(flowID, class, 1, 2, encFile) flowMap = append(flowMap, serverFlowInfo) } else { //5、发起人验收 var serverEsFlowInfo FlowAllMap serverEsFlowInfo.Step = 5 serverEsFlowInfo.NodeName = GetSetpName(5) serverEsFlowInfo.State = 1 serverEsFlowInfo.Class = 1 serverEsFlowInfo.UserList = GetFlowNodeManEs(flowID, class, 1, 2, encFile) flowMap = append(flowMap, serverEsFlowInfo) } } else { //2、创建人部门负责人审核 var twoFlowInfo FlowAllMap twoFlowInfo.Step = 2 twoFlowInfo.NodeName = GetSetpName(2) twoFlowInfo.State = 1 twoFlowInfo.Class = 1 twoFlowInfo.UserList = GetFlowNodeManEs(flowID, class, 3, 2, encFile) flowMap = append(flowMap, twoFlowInfo) } } } else { //定量 //1、创建 var twoFlowInfo FlowAllMap twoFlowInfo.Step = 2 twoFlowInfo.NodeName = GetSetpName(7) twoFlowInfo.State = 1 twoFlowInfo.Class = 1 twoFlowInfo.UserList = GetFlowNodeManEs(flowID, class, 5, 2, encFile) flowMap = append(flowMap, twoFlowInfo) } flowAllMapByte, eer := json.Marshal(flowMap) if eer == nil { flowAllMap = string(flowAllMapByte) } return } //获取节点操作人 /* @flowID 流程ID @class 1、定性;2、定量 @style 1、测评人;2,测评人部门内勤;3、测评人部门负责人;4、被测评部门内勤;5、被测评部门负责人 */ func GetFlowNodeMan(flowID int64, class, style, writeLog int) (manInfo []UserListFlowAll) { var goDu FlowNodePeopleInfo if class == 1 { var scoreFlowCont assessmentmodel.ScoreFlow flowLogErr := global.GVA_DB_Performanceappraisal.Where("sf_key = ?", flowID).First(&scoreFlowCont).Error if flowLogErr == nil { goDu.EvalCont.Group = scoreFlowCont.EvaluationGroup goDu.EvalCont.DepartmentId = scoreFlowCont.EvaluationDepartment goDu.EvalCont.Id = strconv.FormatInt(scoreFlowCont.EvaluationUser, 10) goDu.DutyCont.Group = scoreFlowCont.DutyGroup goDu.DutyCont.DepartmentId = scoreFlowCont.DutyDepartment } } else { var flowCont assessmentmodel.FlowLog flowLogErrs := global.GVA_DB_Performanceappraisal.Where("fl_key = ?", flowID).First(&flowCont).Error if flowLogErrs == nil { goDu.EvalCont.Group = flowCont.EvaluationGroup goDu.EvalCont.DepartmentId = flowCont.EvaluationDepartment goDu.EvalCont.Id = strconv.FormatInt(flowCont.EvaluationUser, 10) goDu.DutyCont.Group = flowCont.DutyGroup goDu.DutyCont.DepartmentId = flowCont.DutyDepartment } } //1、测评人;2,测评人部门内勤;3、测评人部门负责人;4、被测评部门内勤;5、被测评部门负责人 switch style { case 2: sendUserIsTrue, sendUserList := GetSendMsgUserAry(16118387069540343, goDu.EvalCont.DepartmentId) if sendUserIsTrue == true { for _, v := range sendUserList { _, userCont := GetUesrContForWechatID(v) var returnUser UserListFlowAll returnUser.Id = strconv.FormatInt(userCont.Key, 10) returnUser.Name = userCont.Name returnUser.Icon = userCont.Icon returnUser.Group = userCont.Group // where := MapOut() // where["id"] = userCont.Group // orgCont, _ := GetNewOrgCont(where, "id", "name") // returnUser.GroupName = orgCont.Name _, groupCont := GetGroupCont(userCont.Group) returnUser.GroupName = groupCont.Name returnUser.DepartmentId = userCont.DepartmentId returnUser.DepartmentName = userCont.DepartmentName returnUser.WorkshopId = userCont.WorkshopId returnUser.WorkshopName = userCont.WorkshopName returnUser.PostId = userCont.PostId returnUser.PostName = userCont.PostName returnUser.Tema = userCont.Tema returnUser.TemaName = userCont.TemaName returnUser.Wechat = userCont.WechatId manInfo = append(manInfo, returnUser) } } case 3: sendUserIsTrue, sendUserList := GetSendMsgUserAry(16182159043990656, goDu.EvalCont.DepartmentId) if sendUserIsTrue == true { for _, v := range sendUserList { _, userCont := GetUesrContForWechatID(v) var returnUser UserListFlowAll returnUser.Id = strconv.FormatInt(userCont.Key, 10) returnUser.Name = userCont.Name returnUser.Icon = userCont.Icon returnUser.Group = userCont.Group // where := MapOut() // where["id"] = userCont.Group // orgCont, _ := GetNewOrgCont(where, "id", "name") // returnUser.GroupName = orgCont.Name _, groupCont := GetGroupCont(userCont.Group) returnUser.GroupName = groupCont.Name returnUser.DepartmentId = userCont.DepartmentId returnUser.DepartmentName = userCont.DepartmentName returnUser.WorkshopId = userCont.WorkshopId returnUser.WorkshopName = userCont.WorkshopName returnUser.PostId = userCont.PostId returnUser.PostName = userCont.PostName returnUser.Tema = userCont.Tema returnUser.TemaName = userCont.TemaName returnUser.Wechat = userCont.WechatId manInfo = append(manInfo, returnUser) } } case 4: sendUserIsTrue, sendUserList := GetSendMsgUserAry(16118387069540343, goDu.DutyCont.DepartmentId) if sendUserIsTrue == true { for _, v := range sendUserList { _, userCont := GetUesrContForWechatID(v) var returnUser UserListFlowAll returnUser.Id = strconv.FormatInt(userCont.Key, 10) returnUser.Name = userCont.Name returnUser.Icon = userCont.Icon returnUser.Group = userCont.Group // where := MapOut() // where["id"] = userCont.Group // orgCont, _ := GetNewOrgCont(where, "id", "name") // returnUser.GroupName = orgCont.Name _, groupCont := GetGroupCont(userCont.Group) returnUser.GroupName = groupCont.Name returnUser.DepartmentId = userCont.DepartmentId returnUser.DepartmentName = userCont.DepartmentName returnUser.WorkshopId = userCont.WorkshopId returnUser.WorkshopName = userCont.WorkshopName returnUser.PostId = userCont.PostId returnUser.PostName = userCont.PostName returnUser.Tema = userCont.Tema returnUser.TemaName = userCont.TemaName returnUser.Wechat = userCont.WechatId manInfo = append(manInfo, returnUser) } } case 5: sendUserIsTrue, sendUserList := GetSendMsgUserAry(16182159043990656, goDu.DutyCont.DepartmentId) if sendUserIsTrue == true { for _, v := range sendUserList { _, userCont := GetUesrContForWechatID(v) var returnUser UserListFlowAll returnUser.Id = strconv.FormatInt(userCont.Key, 10) returnUser.Name = userCont.Name returnUser.Icon = userCont.Icon returnUser.Group = userCont.Group // where := MapOut() // where["id"] = userCont.Group // orgCont, _ := GetNewOrgCont(where, "id", "name") // returnUser.GroupName = orgCont.Name _, groupCont := GetGroupCont(userCont.Group) returnUser.GroupName = groupCont.Name returnUser.DepartmentId = userCont.DepartmentId returnUser.DepartmentName = userCont.DepartmentName returnUser.WorkshopId = userCont.WorkshopId returnUser.WorkshopName = userCont.WorkshopName returnUser.PostId = userCont.PostId returnUser.PostName = userCont.PostName returnUser.Tema = userCont.Tema returnUser.TemaName = userCont.TemaName returnUser.Wechat = userCont.WechatId manInfo = append(manInfo, returnUser) } } default: var returnUser UserListFlowAll userCont, _ := GetWorkUser(goDu.EvalCont.Id) returnUser.Id = goDu.EvalCont.Id returnUser.Name = userCont.Name returnUser.Icon = userCont.Icon returnUser.Group = userCont.Group // where := MapOut() // where["id"] = userCont.Group // orgCont, _ := GetNewOrgCont(where, "id", "name") // returnUser.GroupName = orgCont.Name _, groupCont := GetGroupCont(userCont.Group) returnUser.GroupName = groupCont.Name returnUser.DepartmentId = userCont.DepartmentId whereDepart := MapOut() whereDepart["id"] = userCont.DepartmentId orgContDepart, _ := GetNewOrgCont(whereDepart, "id", "name") returnUser.DepartmentName = orgContDepart.Name // _, bfInfo := GetBranchFactory(userCont.DepartmentId) // returnUser.DepartmentName = bfInfo.Name returnUser.WorkshopId = userCont.WorkshopId _, wsInfo := GetWorkShopSection(userCont.WorkshopId) returnUser.WorkshopName = wsInfo.Name returnUser.PostId = userCont.PostId _, posCont := GetPosition(userCont.PostId) returnUser.PostName = posCont.Name returnUser.Tema = userCont.Tema _, temCont := GetTeaming(userCont.Tema) returnUser.TemaName = temCont.Name returnUser.Wechat = userCont.WechatId if writeLog == 1 { // oneFlowInfo? var logListMap LogList logListMap.State = 2 logListMap.TimeVal = GetToDayAll() returnUser.LogList = append(returnUser.LogList, logListMap) } manInfo = append(manInfo, returnUser) } return } func GetFlowNodeManEs(flowID int64, class, style, writeLog int, encFile []EnclosureFormat) (manInfo []UserListFlowAll) { var goDu FlowNodePeopleInfo if class == 1 { var scoreFlowCont assessmentmodel.ScoreFlow flowLogErr := global.GVA_DB_Performanceappraisal.Where("sf_key = ?", flowID).First(&scoreFlowCont).Error if flowLogErr == nil { goDu.EvalCont.Group = scoreFlowCont.EvaluationGroup goDu.EvalCont.DepartmentId = scoreFlowCont.EvaluationDepartment goDu.EvalCont.Id = strconv.FormatInt(scoreFlowCont.EvaluationUser, 10) goDu.DutyCont.Group = scoreFlowCont.DutyGroup goDu.DutyCont.DepartmentId = scoreFlowCont.DutyDepartment } } else { var flowCont assessmentmodel.FlowLog flowLogErrs := global.GVA_DB_Performanceappraisal.Where("fl_key = ?", flowID).First(&flowCont).Error if flowLogErrs == nil { goDu.EvalCont.Group = flowCont.EvaluationGroup goDu.EvalCont.DepartmentId = flowCont.EvaluationDepartment goDu.EvalCont.Id = strconv.FormatInt(flowCont.EvaluationUser, 10) goDu.DutyCont.Group = flowCont.DutyGroup goDu.DutyCont.DepartmentId = flowCont.DutyDepartment } } //1、测评人;2,测评人部门内勤;3、测评人部门负责人;4、被测评部门内勤;5、被测评部门负责人 switch style { case 2: sendUserIsTrue, sendUserList := GetSendMsgUserAry(16118387069540343, goDu.EvalCont.DepartmentId) if sendUserIsTrue == true { for _, v := range sendUserList { _, userCont := GetUesrContForWechatID(v) var returnUser UserListFlowAll returnUser.Id = strconv.FormatInt(userCont.Key, 10) returnUser.Name = userCont.Name returnUser.Icon = userCont.Icon returnUser.Group = userCont.Group // where := MapOut() // where["id"] = userCont.Group // orgCont, _ := GetNewOrgCont(where, "id", "name") // returnUser.GroupName = orgCont.Name _, groupCont := GetGroupCont(userCont.Group) returnUser.GroupName = groupCont.Name returnUser.DepartmentId = userCont.DepartmentId returnUser.DepartmentName = userCont.DepartmentName returnUser.WorkshopId = userCont.WorkshopId returnUser.WorkshopName = userCont.WorkshopName returnUser.PostId = userCont.PostId returnUser.PostName = userCont.PostName returnUser.Tema = userCont.Tema returnUser.TemaName = userCont.TemaName returnUser.Wechat = userCont.WechatId manInfo = append(manInfo, returnUser) } } case 3: sendUserIsTrue, sendUserList := GetSendMsgUserAry(16182159043990656, goDu.EvalCont.DepartmentId) if sendUserIsTrue == true { for _, v := range sendUserList { _, userCont := GetUesrContForWechatID(v) var returnUser UserListFlowAll returnUser.Id = strconv.FormatInt(userCont.Key, 10) returnUser.Name = userCont.Name returnUser.Icon = userCont.Icon returnUser.Group = userCont.Group // where := MapOut() // where["id"] = userCont.Group // orgCont, _ := GetNewOrgCont(where, "id", "name") // returnUser.GroupName = orgCont.Name _, groupCont := GetGroupCont(userCont.Group) returnUser.GroupName = groupCont.Name returnUser.DepartmentId = userCont.DepartmentId returnUser.DepartmentName = userCont.DepartmentName returnUser.WorkshopId = userCont.WorkshopId returnUser.WorkshopName = userCont.WorkshopName returnUser.PostId = userCont.PostId returnUser.PostName = userCont.PostName returnUser.Tema = userCont.Tema returnUser.TemaName = userCont.TemaName returnUser.Wechat = userCont.WechatId manInfo = append(manInfo, returnUser) } } case 4: sendUserIsTrue, sendUserList := GetSendMsgUserAry(16118387069540343, goDu.DutyCont.DepartmentId) if sendUserIsTrue == true { for _, v := range sendUserList { _, userCont := GetUesrContForWechatID(v) var returnUser UserListFlowAll returnUser.Id = strconv.FormatInt(userCont.Key, 10) returnUser.Name = userCont.Name returnUser.Icon = userCont.Icon returnUser.Group = userCont.Group // where := MapOut() // where["id"] = userCont.Group // orgCont, _ := GetNewOrgCont(where, "id", "name") // returnUser.GroupName = orgCont.Name _, groupCont := GetGroupCont(userCont.Group) returnUser.GroupName = groupCont.Name returnUser.DepartmentId = userCont.DepartmentId returnUser.DepartmentName = userCont.DepartmentName returnUser.WorkshopId = userCont.WorkshopId returnUser.WorkshopName = userCont.WorkshopName returnUser.PostId = userCont.PostId returnUser.PostName = userCont.PostName returnUser.Tema = userCont.Tema returnUser.TemaName = userCont.TemaName returnUser.Wechat = userCont.WechatId manInfo = append(manInfo, returnUser) } } case 5: sendUserIsTrue, sendUserList := GetSendMsgUserAry(16182159043990656, goDu.DutyCont.DepartmentId) if sendUserIsTrue == true { for _, v := range sendUserList { _, userCont := GetUesrContForWechatID(v) var returnUser UserListFlowAll returnUser.Id = strconv.FormatInt(userCont.Key, 10) returnUser.Name = userCont.Name returnUser.Icon = userCont.Icon returnUser.Group = userCont.Group // where := MapOut() // where["id"] = userCont.Group // orgCont, _ := GetNewOrgCont(where, "id", "name") // returnUser.GroupName = orgCont.Name _, groupCont := GetGroupCont(userCont.Group) returnUser.GroupName = groupCont.Name returnUser.DepartmentId = userCont.DepartmentId returnUser.DepartmentName = userCont.DepartmentName returnUser.WorkshopId = userCont.WorkshopId returnUser.WorkshopName = userCont.WorkshopName returnUser.PostId = userCont.PostId returnUser.PostName = userCont.PostName returnUser.Tema = userCont.Tema returnUser.TemaName = userCont.TemaName returnUser.Wechat = userCont.WechatId manInfo = append(manInfo, returnUser) } } default: var returnUser UserListFlowAll userCont, _ := GetWorkUser(goDu.EvalCont.Id) returnUser.Id = goDu.EvalCont.Id returnUser.Name = userCont.Name returnUser.Icon = userCont.Icon returnUser.Group = userCont.Group _, groupCont := GetGroupCont(userCont.Group) returnUser.GroupName = groupCont.Name returnUser.DepartmentId = userCont.DepartmentId _, bfInfo := GetBranchFactory(userCont.DepartmentId) returnUser.DepartmentName = bfInfo.Name returnUser.WorkshopId = userCont.WorkshopId _, wsInfo := GetWorkShopSection(userCont.WorkshopId) returnUser.WorkshopName = wsInfo.Name returnUser.PostId = userCont.PostId _, posCont := GetPosition(userCont.PostId) returnUser.PostName = posCont.Name returnUser.Tema = userCont.Tema _, temCont := GetTeaming(userCont.Tema) returnUser.TemaName = temCont.Name returnUser.Wechat = userCont.WechatId if writeLog == 1 { // oneFlowInfo? var logListMap LogList logListMap.State = 2 logListMap.TimeVal = GetToDayAll() logListMap.Enclosure = encFile returnUser.LogList = append(returnUser.LogList, logListMap) } manInfo = append(manInfo, returnUser) } return } //编辑流程步进器 func EiteDutiesInfoes(saveId int64, saveData map[string]interface{}) (isTrue bool, infoErr error) { isTrue = false infoErr = global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.EvaluationProcess{}).Where("`ep_id` = ?", saveId).Updates(saveData).Error if infoErr != nil { return } isTrue = true return } //步骤名称 func GetSetpName(setId int) (setpName string) { switch setId { case 1: setpName = "创建申请" case 2: setpName = "审核确认" case 3: setpName = "责任划分" case 4: setpName = "整改措施" case 5: setpName = "整改验收" case 6: setpName = "抄送" case 7: // setpName = "部门负责人" setpName = "审核确认" default: setpName = "创建申请" } return } //四舍五入 /* @val 目标值 @precision 保留几位 */ func Round(val float64, precision int) float64 { p := math.Pow10(precision) return math.Floor(val*p+0.5) / p } //获取班组成员 func GetTeamUserList(group, department, postId, teamId string) (userCont []testpage.PersonalDetails, isTrue bool) { wheAry := MapOut() wheAry["wm_group"] = group wheAry["wm_bf_id"] = department wheAry["wm_ws_id"] = postId wheAry["wm_tema"] = teamId // userCont, isTrue = GetUserInfoPublic("worker_man.*,worker_man_data.*", wheAry) isTrue = false var userInfo testpage.WorkMan userErr := global.GVA_DB_Master.Model(&userInfo).Select("worker_man.*,worker_man_data.*").Joins("left join worker_man_data on worker_man_data.wmd_key = worker_man.wm_key").Where(wheAry).Find(&userCont).Error if userErr == nil { isTrue = true } return } //编辑分数流水 func EiteScoreFlow(saveId int64, saveData map[string]interface{}) (isTrue bool, infoErr error) { isTrue = false infoErr = global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.ScoreFlow{}).Where("`sf_key` = ?", saveId).Updates(saveData).Error if infoErr != nil { return } isTrue = true return } //获取通用责任划分 func GetDivisionOfResponsibility(orderId string, class int) (contList []map[string]interface{}, err error) { var dataContList []assessmentmodel.DivisionResponsibilities err = global.GVA_DB_Performanceappraisal.Where("`df_sf_id` = ?", orderId).Order("df_type ASC").Find(&dataContList).Error if err != nil { return } if class == 1 { for _, v := range dataContList { cont := MapOut() cont["type"] = v.Type switch v.Type { case 1: cont["typename"] = "主要责任人" case 2: cont["typename"] = "互保责任人" case 3: cont["typename"] = "责任班组" case 4: cont["typename"] = "责任班组长" case 5: cont["typename"] = "主管" case 6: cont["typename"] = "三大员" case 7: cont["typename"] = "主任" case 8: cont["typename"] = "厂长" default: cont["typename"] = "主要责任人" } cont["weight"] = v.Weight cont["userkey"] = v.UserKey //获取人员信息 userCont, userContErr := GetWorkUser(strconv.FormatInt(v.UserKey, 10)) cont["wechatid"] = "" if v.UserName != "" { cont["username"] = v.UserName if userContErr == true { if userCont.WechatId != "" { cont["wechatid"] = userCont.WechatId } if userCont.WorkWechatId != "" { cont["wechatid"] = userCont.WorkWechatId } } } else { if userContErr == true { cont["username"] = userCont.Name if userCont.WechatId != "" { cont["wechatid"] = userCont.WechatId } if userCont.WorkWechatId != "" { cont["wechatid"] = userCont.WorkWechatId } } } cont["groupid"] = v.Group groupErr, groupInfo := GetGroupCont(v.Group) if groupErr == true { cont["groupname"] = groupInfo.Name } else { cont["groupname"] = "" } cont["departmentid"] = v.Department departErr, departInfo := GetBranchFactory(v.Department) if departErr == true { cont["departmentname"] = departInfo.Name } else { cont["departmentname"] = "" } cont["temaid"] = v.Tema teamErr, teamInfo := GetTeaming(v.Tema) if teamErr == true { cont["temaname"] = teamInfo.Name } else { cont["temaname"] = "" } cont["taskid"] = v.DistributionUser contList = append(contList, cont) } } else { teamAry := MapOut() for _, v := range dataContList { if v.Type != 3 { cont := MapOut() cont["type"] = v.Type switch v.Type { case 1: cont["typename"] = "主要责任人" case 2: cont["typename"] = "互保责任人" case 3: cont["typename"] = "责任班组" case 4: cont["typename"] = "责任班组长" case 5: cont["typename"] = "主管" case 6: cont["typename"] = "三大员" case 7: cont["typename"] = "主任" case 8: cont["typename"] = "厂长" default: cont["typename"] = "主要责任人" } cont["weight"] = v.Weight cont["userkey"] = v.UserKey //获取人员信息 userCont, userContErr := GetWorkUser(strconv.FormatInt(v.UserKey, 10)) cont["wechatid"] = "" if v.UserName != "" { cont["username"] = v.UserName if userContErr == true { if userCont.WechatId != "" { cont["wechatid"] = userCont.WechatId } if userCont.WorkWechatId != "" { cont["wechatid"] = userCont.WorkWechatId } } } else { if userContErr == true { cont["username"] = userCont.Name if userCont.WechatId != "" { cont["wechatid"] = userCont.WechatId } if userCont.WorkWechatId != "" { cont["wechatid"] = userCont.WorkWechatId } } } cont["groupid"] = v.Group groupErr, groupInfo := GetGroupCont(v.Group) if groupErr == true { cont["groupname"] = groupInfo.Name } else { cont["groupname"] = "" } cont["departmentid"] = v.Department departErr, departInfo := GetBranchFactory(v.Department) if departErr == true { cont["departmentname"] = departInfo.Name } else { cont["departmentname"] = "" } cont["temaid"] = v.Tema teamErr, teamInfo := GetTeaming(v.Tema) if teamErr == true { cont["temaname"] = teamInfo.Name } else { cont["temaname"] = "" } cont["taskid"] = v.DistributionUser contList = append(contList, cont) } else { teamAry["type"] = v.Type switch v.Type { case 1: teamAry["typename"] = "主要责任人" case 2: teamAry["typename"] = "互保责任人" case 3: teamAry["typename"] = "责任班组" case 4: teamAry["typename"] = "责任班组长" case 5: teamAry["typename"] = "主管" case 6: teamAry["typename"] = "三大员" case 7: teamAry["typename"] = "主任" case 8: teamAry["typename"] = "厂长" default: teamAry["typename"] = "主要责任人" } teamAry["weight"] = v.Weight teamAry["userkey"] = v.UserKey //获取人员信息 userCont, userContErr := GetWorkUser(strconv.FormatInt(v.UserKey, 10)) teamAry["wechatid"] = "" if v.UserName != "" { teamAry["username"] = v.UserName if userContErr == true { if userCont.WechatId != "" { teamAry["wechatid"] = userCont.WechatId } if userCont.WorkWechatId != "" { teamAry["wechatid"] = userCont.WorkWechatId } } } else { if userContErr == true { teamAry["username"] = userCont.Name if userCont.WechatId != "" { teamAry["wechatid"] = userCont.WechatId } if userCont.WorkWechatId != "" { teamAry["wechatid"] = userCont.WorkWechatId } } } teamAry["groupid"] = v.Group groupErr, groupInfo := GetGroupCont(v.Group) if groupErr == true { teamAry["groupname"] = groupInfo.Name } else { teamAry["groupname"] = "" } teamAry["departmentid"] = v.Department departErr, departInfo := GetBranchFactory(v.Department) if departErr == true { teamAry["departmentname"] = departInfo.Name } else { teamAry["departmentname"] = "" } teamAry["temaid"] = v.Tema teamErr, teamInfo := GetTeaming(v.Tema) if teamErr == true { teamAry["temaname"] = teamInfo.Name } else { teamAry["temaname"] = "" } teamAry["taskid"] = v.DistributionUser } } if len(teamAry) > 0 { contList = append(contList, teamAry) } } return } //判断是否存在 func IsItTrue(id int64, idAry []int64) (isTrue bool) { isTrue = false for _, v := range idAry { if v == id { return true } } return } func IsItTrueInt(id int, idAry []int) (isTrue bool) { isTrue = false for _, v := range idAry { if v == id { return true } } return } func IsItTrueString(id string, idAry []string) (isTrue bool) { isTrue = false for _, v := range idAry { if v == id { return true } } return } //获取多部门归属集团 func GetDuboDepart(departAry []string) (group []string) { fmt.Printf("DeparAry--------->%v\n", departAry) for _, v := range departAry { departID, _ := strconv.ParseInt(v, 10, 64) // isTrue, bfInfo := GetBranchFactory(departID) // if isTrue == true { // bfGetID := strconv.FormatInt(bfInfo.Group, 10) // if IsItTrueString(bfGetID, group) == false { // group = append(group, bfGetID) // } // } groupId, isTrue := GetNewHrOrg(departID) fmt.Printf("groupId----->%v\n", groupId) if isTrue == true { bfGetID := strconv.FormatInt(groupId, 10) if IsItTrueString(bfGetID, group) == false { group = append(group, bfGetID) } } } return } //获取新HR系统的集团 func GetNewHrOrg(departID int64) (groupId int64, isTrue bool) { isTrue = false var govMap OutGovCont err := 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 = ?", departID).Find(&govMap).Error if err != nil { return } // fmt.Printf("ZongJie----1-->%v\n", groupId) if govMap.Level <= 2 { isTrue = true groupId = govMap.Id // fmt.Printf("ZongJie---2--->%v\n", groupId) return } else { groupId = diGuiOrg(govMap.Superior) // fmt.Printf("ZongJie--3---->%v\n", groupId) if groupId > 0 { isTrue = true } } // fmt.Printf("ZongJie---4--->%v\n", groupId) return } //递归查找集团 func diGuiOrg(superior int64) (groupId int64) { // fmt.Printf("DiGui----->%v\n", superior) // return // groupId = 0 var govMap OutGovCont err := 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 = ?", superior).Find(&govMap).Error if err != nil { return } // fmt.Printf("Id----%v------>%v------------>%v\n", govMap.Name, superior, govMap.Level) if govMap.Level <= 2 { // fmt.Printf("out---->%v--->%v\n", govMap, govMap.Id) groupId = govMap.Id return } else { // fmt.Printf("digui---->%v\n", govMap) groupId = diGuiOrg(govMap.Superior) } // fmt.Printf("@@@@@@@@@@------>%v\n", govMap.Id) return } //批量获取相关人员部门id func GetDepartmentByUserBast(userKey []string) (userDepartmentId []string) { if len(userKey) < 1 { return } var usDepartId []int64 usDepartErr := global.GVA_DB_Master.Model(&testpage.WorkMan{}).Select("wm_bf_id").Where("`wm_key` IN ?", userKey).Group("wm_bf_id").Find(&usDepartId).Error if usDepartErr != nil { return } if len(usDepartId) < 1 { return } for _, v := range usDepartId { userDepartmentId = append(userDepartmentId, strconv.FormatInt(v, 10)) } return } //判断该子栏目是否存在 /* @ascription 指标ID @columId 子指标ID @title 指标名称 @departMap 关联部门 */ func JudgeColumn(ascription, columId, title, departMap string) (content assessmentmodel.QualitativeTarget, isTrue bool) { isTrue = false if columId != "" { judgeIdErr := global.GVA_DB_Performanceappraisal.Where("`q_id` = ?", columId).First(&content).Error if judgeIdErr == nil { if content.State != 1 { saveSunTarData := MapOut() saveSunTarData["q_state"] = 1 saveSunTarData["q_time"] = time.Now().Unix() global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeTarget{}).Where("`q_id` = ?", columId).Updates(&saveSunTarData) } isTrue = true // fmt.Printf("1\n") return } } judgeErr := global.GVA_DB_Performanceappraisal.Where("`q_parent_id` = ? AND `q_title` = ?", ascription, title).First(&content).Error if judgeErr == nil { if content.State != 1 { saveSunTarData := MapOut() saveSunTarData["q_state"] = 1 saveSunTarData["q_time"] = time.Now().Unix() global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeTarget{}).Where("`q_parent_id` = ? AND `q_title` = ?", ascription, title).Updates(&saveSunTarData) } isTrue = true // fmt.Printf("2\n") return } ascriptionId, ascriptionErr := strconv.ParseInt(ascription, 10, 64) if ascriptionErr != nil { ascriptionId = 0 } saveColum := assessmentmodel.QualitativeTarget{Title: title, ParentId: ascriptionId, State: 1, AddTime: time.Now().Unix(), Depart: departMap} addErr := global.GVA_DB_Performanceappraisal.Create(&saveColum).Error if addErr != nil { // fmt.Printf("3\n") return } isTrue = true content = saveColum // fmt.Printf("4\n") // panic(content) return } //关联集团部门考核维度 /* @groupID 集团 @departId 部门 @dimensionId 维度 @key 1:定性考核;2:定量考核 */ func AddDepartDimension(groupID, departId, dimensionId string, key int64) { judgeMap := MapOut() judgeErr := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.DepartmentDimension{}).Select("dd_id").Where("`dd_group` = ? AND `dd_department` = ? AND `dd_dimension` = ?", groupID, departId, dimensionId).First(&judgeMap).Error if judgeErr != nil { var saveData assessmentmodel.DepartmentDimension saveData.Key = key departIdVal, _ := strconv.ParseInt(departId, 10, 64) saveData.DepartmentId = departIdVal dimensionIdVal, _ := strconv.ParseInt(dimensionId, 10, 64) saveData.Dimension = dimensionIdVal groupIDVal, _ := strconv.ParseInt(groupID, 10, 64) saveData.Group = groupIDVal saveData.Addtime = time.Now().Unix() insetErr := global.GVA_DB_Performanceappraisal.Create(&saveData).Error if insetErr == nil { } } } //判断考核细则是否存在 /* 参数说明 @ascription 归属指标栏目 @title 指标细则 @explain 指标说明' @explainId 指标明细ID @sunTargetId 子栏目 */ func JudgeDetails(ascription, title, explain, explainId string, sunTargetId int64) (content assessmentmodel.DetailedTarget, isTrue bool) { isTrue = false if explainId != "" { judgeIdErr := global.GVA_DB_Performanceappraisal.Where("`dt_id` = ?", explainId).First(&content).Error if judgeIdErr == nil { eiteCont := MapOut() eiteCont["dt_title"] = title eiteCont["dt_content"] = explain eiteCont["dt_time"] = time.Now().Unix() global.GVA_DB_Performanceappraisal.Model(&content).Where("`dt_id` = ?", explainId).Updates(&eiteCont) // fmt.Printf("echo --------------1---------->%v\n", content) isTrue = true return } } judgeErr := global.GVA_DB_Performanceappraisal.Where("`dt_parentid` = ? AND `dt_title` = ?", ascription, title).First(&content).Error if judgeErr == nil { isTrue = true eiteCont := MapOut() eiteCont["dt_content"] = explain eiteCont["dt_time"] = time.Now().Unix() global.GVA_DB_Performanceappraisal.Model(&content).Where("`dt_id` = ?", content.Id).Updates(&eiteCont) // fmt.Printf("echo --------------2---------->%v\n", content) return } ascriptionId, ascriptionErr := strconv.ParseInt(ascription, 10, 64) if ascriptionErr != nil { ascriptionId = 0 } saveColum := assessmentmodel.DetailedTarget{Title: title, Content: explain, ParentId: ascriptionId, ParentIdSun: sunTargetId, State: 1, AddTime: time.Now().Unix()} addErr := global.GVA_DB_Performanceappraisal.Create(&saveColum).Error if addErr != nil { // fmt.Printf("echo --------------3---------->%v\n", saveColum.Id) return } // fmt.Printf("echo --------------4---------->%v\n", saveColum.Id) isTrue = true content = saveColum return } func GetBranchDepartAry(departIdAry []string) (departId []int64, departAry []DepartmentAryType) { for _, v := range departIdAry { bfId, bfIdErr := strconv.ParseInt(v, 10, 64) if bfIdErr == nil { deparConErr, deparConCont := GetBranchFactory(bfId) if deparConErr == true { departId = append(departId, deparConCont.Id) var departcont DepartmentAryType departcont.Parentname = deparConCont.Name departcont.Parentid = v departAry = append(departAry, departcont) } } } return } //获取新组织架构的行政信息 func GetNewOrgList(departIdAry []string) (departId []int64, departAry []DepartmentAryType) { for _, v := range departIdAry { where := MapOut() where["id"] = v orgCont, orgErr := GetNewOrgCont(where, "id", "name") if orgErr == nil { departId = append(departId, orgCont.Id) var departcont DepartmentAryType departcont.Parentname = orgCont.Name departcont.Parentid = v departAry = append(departAry, departcont) } } return } //判断考核细则是否存在(新规则) /* 参数说明 @ascription 归属指标栏目 @title 指标细则 @explain 指标说明' @explainId 指标明细ID @ReferenceScore 分数 @CompanyCont 单位 @sunTargetId 子栏目 */ func JudgeDetailsCopy(ascription, title, explain, explainId, ReferenceScore, CompanyCont string, sunTargetId int64, addReduce int) (content assessmentmodel.DetailedTarget, isTrue bool) { if addReduce == 0 { addReduce = 1 } var minScoreInt int64 var maxScoreInt int64 scoreAry := strings.Split(ReferenceScore, "-") scoreLen := len(scoreAry) fmt.Printf("ScoreAry:%v----------->%v------------>%v------------>%v\n", ReferenceScore, scoreLen, scoreAry[0], scoreAry) if scoreLen > 0 { if scoreLen == 1 { maxScore, _ := strconv.ParseFloat(scoreAry[0], 64) zhhh := maxScore * 100 zhuanStr := strconv.FormatFloat(zhhh, 'f', -1, 64) maxScoreInt, _ = strconv.ParseInt(strconv.FormatFloat(maxScore*100, 'f', -1, 64), 10, 64) minScoreInt = 0 fmt.Printf("ScoreAry--1-----:%v----------->%v------------>%v------------>%v\n", maxScore, maxScoreInt, zhuanStr, zhhh) } else { minScore, _ := strconv.ParseFloat(scoreAry[0], 64) maxScore, _ := strconv.ParseFloat(scoreAry[scoreLen-1], 64) minScoreInt, _ = strconv.ParseInt(strconv.FormatFloat(minScore*100, 'f', -1, 64), 10, 64) maxScoreInt, _ = strconv.ParseInt(strconv.FormatFloat(maxScore*100, 'f', -1, 64), 10, 64) } } else { minScoreInt = 0 maxScoreInt = 0 } isTrue = false if explainId != "" { judgeIdErr := global.GVA_DB_Performanceappraisal.Where("`dt_id` = ?", explainId).First(&content).Error if judgeIdErr == nil { eiteCont := MapOut() if minScoreInt > maxScoreInt { eiteCont["dt_min_score"] = maxScoreInt eiteCont["dt_max_score"] = minScoreInt } else { eiteCont["dt_min_score"] = minScoreInt eiteCont["dt_max_score"] = maxScoreInt } eiteCont["dt_title"] = title eiteCont["dt_content"] = explain eiteCont["dt_company"] = CompanyCont eiteCont["dt_add_reduce"] = addReduce eiteCont["dt_time"] = time.Now().Unix() global.GVA_DB_Performanceappraisal.Model(&content).Where("`dt_id` = ?", explainId).Updates(&eiteCont) // fmt.Printf("echo --------------1---------->%v\n", content) isTrue = true return } } judgeErr := global.GVA_DB_Performanceappraisal.Where("`dt_parentid` = ? AND `dt_title` = ?", ascription, title).First(&content).Error if judgeErr == nil { isTrue = true eiteCont := MapOut() if minScoreInt > maxScoreInt { eiteCont["dt_min_score"] = maxScoreInt eiteCont["dt_max_score"] = minScoreInt } else { eiteCont["dt_min_score"] = minScoreInt eiteCont["dt_max_score"] = maxScoreInt } eiteCont["dt_content"] = explain eiteCont["dt_company"] = CompanyCont eiteCont["dt_add_reduce"] = addReduce eiteCont["dt_time"] = time.Now().Unix() global.GVA_DB_Performanceappraisal.Model(&content).Where("`dt_id` = ?", content.Id).Updates(&eiteCont) // fmt.Printf("echo --------------2---------->%v\n", content) return } ascriptionId, ascriptionErr := strconv.ParseInt(ascription, 10, 64) if ascriptionErr != nil { ascriptionId = 0 } var minScoreIsTrue int64 = 0 var maxScoreIsTrue int64 = 0 if minScoreInt > maxScoreInt { minScoreIsTrue = maxScoreInt maxScoreIsTrue = minScoreInt } else { minScoreIsTrue = minScoreInt maxScoreIsTrue = maxScoreInt } fmt.Printf("ScoreAry---KKKK:%v----------->%v------------>%v------------>%v", minScoreIsTrue, maxScoreIsTrue, minScoreIsTrue, maxScoreIsTrue) saveColum := assessmentmodel.DetailedTarget{Title: title, Content: explain, ParentId: ascriptionId, ParentIdSun: sunTargetId, State: 1, AddTime: time.Now().Unix(), Company: CompanyCont, MinScore: minScoreIsTrue, MaxScore: maxScoreIsTrue, AddReduce: addReduce} addErr := global.GVA_DB_Performanceappraisal.Create(&saveColum).Error if addErr != nil { // fmt.Printf("echo --------------3---------->%v\n", saveColum.Id) return } // fmt.Printf("echo --------------4---------->%v\n", saveColum.Id) isTrue = true content = saveColum return } //判断定性考核项目是否存在使用状态 /* @group 集团 @dimension 维度 @target 指标 @target_sun 子栏目 @detailed 维度 */ func JudegDutyIsUse(group, dimension, target, target_sun, detailed int64) (isTrue bool) { isTrue = false // var qeInfo []assessmentmodel.QualitativeEvaluation var qeID []int64 gormDb := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Select("qe_id").Where("`qe_state` = 1") if group != 0 { gormDb = gormDb.Where("`qe_group` = ?", group) } if dimension != 0 { gormDb = gormDb.Where("`qe_dimension` = ?", dimension) } if target != 0 { gormDb = gormDb.Where("`qe_target` = ?", target) } if target_sun != 0 { gormDb = gormDb.Where("`qe_target_sun` = ?", target_sun) } if detailed != 0 { gormDb = gormDb.Where("`qe_detailed_target` = ?", detailed) } err := gormDb.Find(&qeID).Error if err != nil { isTrue = true return } var sfID []int64 sfErr := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.ScoreFlow{}).Select("sf_id").Where("`sf_reply` > 0 AND `sf_evaluation_plan` IN ?", qeID).Find(&sfID).Error if sfErr != nil { isTrue = true return } if len(sfID) < 1 { isTrue = true return } return } //获取权重 /* @group 集团 @dimension 维度 @derpatment 部门 @target 指标 @class 1:定性考核;2:定量考核 */ func GetWeight(group, dimension, derpatment, target string, class int64) (weightSum int64) { gormDb := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.DepartmentDimensionWeight{}).Where("`ddw_group` = ? AND `ddw_derpatment` = ? AND `ddw_dimension` = ?", group, derpatment, dimension) if target != "" { gormDb = gormDb.Where("`ddw_target` = ? AND `ddw_hierarchy` = 2", target) } else { gormDb = gormDb.Where("`ddw_hierarchy` = 1") } if class != 0 { gormDb = gormDb.Where("`ddw_type` = ?", class) } err := gormDb.Pluck("COALESCE(SUM(ddw_weight), 0) as weight", &weightSum).Error if err != nil { weightSum = 0 } return } //写入权重 /* @group 集团 @dimension 维度 @derpatment 部门 @target 指标 @class 1:定性考核;2:定量考核 */ func AddWeight(group, dimension, derpatment, target string, score, class int64) (isTrue bool) { isTrue = false if target != "" { var id int64 judegErr := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.DepartmentDimensionWeight{}).Select("ddw_id").Where("`ddw_hierarchy` = 2 AND `ddw_group` = ? AND `ddw_derpatment` = ? AND `ddw_dimension` = ? AND `ddw_target` = ? AND `ddw_type` = ?", group, derpatment, dimension, target, class).First(&id).Error if judegErr == nil { eiteCont := MapOut() eiteCont["ddw_time"] = time.Now().Unix() eiteCont["ddw_weight"] = score eiteErr := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.DepartmentDimensionWeight{}).Where("ddw_id = ?", id).Updates(&eiteCont).Error if eiteErr == nil { isTrue = true } } else { var addCont assessmentmodel.DepartmentDimensionWeight groupId, _ := strconv.ParseInt(group, 10, 64) addCont.Group = groupId derpatmentId, _ := strconv.ParseInt(derpatment, 10, 64) addCont.DepartmentId = derpatmentId dimensionId, _ := strconv.ParseInt(dimension, 10, 64) addCont.Dimension = dimensionId targetId, _ := strconv.ParseInt(target, 10, 64) addCont.Target = targetId addCont.Weight = score addCont.Addtime = time.Now().Unix() addCont.Type = class addCont.Hierarchy = 2 addErr := global.GVA_DB_Performanceappraisal.Create(&addCont).Error if addErr == nil { isTrue = true } } } else { //写入维度权重 var id int64 judegErr := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.DepartmentDimensionWeight{}).Select("ddw_id").Where("`ddw_hierarchy` = 1 AND `ddw_group` = ? AND `ddw_derpatment` = ? AND `ddw_dimension` = ?", group, derpatment, dimension).First(&id).Error if judegErr == nil { eiteCont := MapOut() eiteCont["ddw_time"] = time.Now().Unix() eiteCont["ddw_weight"] = score eiteErr := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.DepartmentDimensionWeight{}).Where("ddw_id = ?", id).Updates(&eiteCont).Error if eiteErr == nil { isTrue = true } } else { var addCont assessmentmodel.DepartmentDimensionWeight groupId, _ := strconv.ParseInt(group, 10, 64) addCont.Group = groupId derpatmentId, _ := strconv.ParseInt(derpatment, 10, 64) addCont.DepartmentId = derpatmentId dimensionId, _ := strconv.ParseInt(dimension, 10, 64) addCont.Dimension = dimensionId addCont.Target = 0 addCont.Weight = score addCont.Addtime = time.Now().Unix() addCont.Type = 1 addCont.Hierarchy = 1 addErr := global.GVA_DB_Performanceappraisal.Create(&addCont).Error if addErr == nil { isTrue = true } } } return } //获取定量考核目标设定 func GetQuantitativeConfig(whereData interface{}) (cont assessmentmodel.QuantitativeConfig) { global.GVA_DB_Performanceappraisal.Where(whereData).First(&cont) fmt.Printf("TargrtCont------1------>%v\n", cont) return } //获取定量考核时间内审批通过的考核数据 func GetTimeIntervalDuty(whereData interface{}, schemeID int64) (actual float64) { jsonStr, _ := json.Marshal(whereData) fmt.Printf("jsonStr------1------>%v\n", string(jsonStr)) actual = 0 //相关审批流 var flowLogList []assessmentmodel.FlowLog err := global.GVA_DB_Performanceappraisal.Where("`fl_reply` = 3 AND FIND_IN_SET(?,`fl_evaluation_id`)", schemeID).Where(whereData).Find(&flowLogList).Error if err != nil { return } for _, v := range flowLogList { actual = actual + GetSchemeFlowData(v.Key, schemeID) } return } //获取指定审批流方案数据 func GetSchemeFlowData(flowKwy, schemeID int64) (weightSum float64) { weightSum = 0 global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.FlowLogData{}).Where("`fld_evaluation_id` = ? AND `fld_flow_log` = ?", schemeID, flowKwy).Pluck("COALESCE(SUM(fld_score), 0) as qe_reference_score", &weightSum) return } //获取float字符串转化成Int64 func GetDuyCycle(scoreStr string, multiple int64) (scoreInt64 int64) { coreFloat64, _ := strconv.ParseFloat(scoreStr, 64) //将字符串转换成float64 scoreFloat64ToStr := strconv.FormatFloat(coreFloat64*float64(multiple), 'f', -1, 64) //将乘以系数后的数值转换成字符串 scoreInt64, _ = strconv.ParseInt(scoreFloat64ToStr, 10, 64) //将字符串转换成int64 return } //获取判断定量考核时间内审批中和通过的考核数据 func GetTimeIntervalDutyJudge(whereData interface{}, schemeID int64) (actual float64) { jsonStr, _ := json.Marshal(whereData) fmt.Printf("jsonStr------1------>%v\n", string(jsonStr)) actual = 0 //相关审批流 var flowLogList []assessmentmodel.FlowLog err := global.GVA_DB_Performanceappraisal.Where("`fl_reply` IN (2,3) AND FIND_IN_SET(?,`fl_evaluation_id`)", schemeID).Where(whereData).Find(&flowLogList).Error if err != nil { return } for _, v := range flowLogList { actual = actual + GetSchemeFlowData(v.Key, schemeID) } return } //判断子栏目是否归属此部门 func JudegSunTarToDepart(sunId, departId int64) (isTrue bool) { isTrue = false var title string judgeARTErr := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeTarget{}).Select("q_title").Where("`q_id` = ? AND FIND_IN_SET(?,`q_depart`)", sunId, departId).First(&title).Error if judgeARTErr == nil { isTrue = true } return } //中文首字母大写 func ChinaToPinYinFirstWord(wordStr string) (firstWord string) { pinYinSub := pinyin.NewArgs() rows := pinyin.Pinyin(wordStr, pinYinSub) for i := 0; i < len(rows); i++ { if len(rows[i]) != 0 { str := rows[i][0] pi := str[0:1] firstWord += string(bytes.ToUpper([]byte(pi))) } } return } //判断文件上传的TYPE func JudgeUpFileType(extTage string) int { images := []string{".jpg", ".jpeg", ".png", ".gif", ".bmp", ".avif", ".webp", ".tif", ".pcx", ".tga", ".exif", ".fpx", ".svg", ".psd", ".cdr", ".pcd", ".dxf", ".ufo", ".hdri", ".eps", ".flic", ".ai", ".ico", ".emf", ".raw", ".WMF", ".avif", ".apng", ".Webp", ".BMP", ".PCX", ".TIF", ".GIF", ".JPEG", ".JPG", ".TGA", ".EXIF", ".FPX", ".SVG", ".PSD", ".CDR", ".PCD", ".DXF", ".UFO", ".EPS", ".AI", ".PNG", ".HDRI", ".RAW", ".WMF", ".FLIC", ".EMF", ".APNG", ".ICO"} videoExt := []string{".mp4", ".avi", ".3gp", ".flv", ".rm", ".rmvb", ".wmv", ".mpeg", ".mpeg1", ".mpeg2", ".divx", ".xvid", ".dv", ".mkv", ".asf", ".asx", ".mov", ".m4v", ".dat", ".mkv", ".vob", ".ogg", ".mod", ".MP4", ".3GP", ".AVI", ".RM", ".RMVB", ".WMV", ".MPEG", ".MPEG1", ".MPEG2", ".DivX", ".XVID", ".DV", ".MKV", ".MOV", ".OGG", ".MOD", ".M4V", ".DAT", ".VOB"} officeExt := []string{".doc", ".docx", ".xml", ".xls", ".xlsx", ".ppt", ".pptx", ".pot", ".PPS", ".dot", ".mht", ".xlt"} zipExt := []string{".rar", ".zip", ".7z", ".ar", ".bz", ".car", ".dar", ".cpgz", ".f", ".ha"} if IsItTrueString(extTage, images) == true { return 1 } if IsItTrueString(extTage, videoExt) == true { return 2 } if IsItTrueString(extTage, officeExt) == true { return 3 } if IsItTrueString(extTage, zipExt) == true { return 4 } return 5 } // 字节的单位转换 保留两位小数 func FormatFileSize(fileSize int64) (size string) { if fileSize < 1024 { //return strconv.FormatInt(fileSize, 10) + "B" return fmt.Sprintf("%.2fB", float64(fileSize)/float64(1)) } else if fileSize < (1024 * 1024) { return fmt.Sprintf("%.2fKB", float64(fileSize)/float64(1024)) } else if fileSize < (1024 * 1024 * 1024) { return fmt.Sprintf("%.2fMB", float64(fileSize)/float64(1024*1024)) } else if fileSize < (1024 * 1024 * 1024 * 1024) { return fmt.Sprintf("%.2fGB", float64(fileSize)/float64(1024*1024*1024)) } else if fileSize < (1024 * 1024 * 1024 * 1024 * 1024) { return fmt.Sprintf("%.2fTB", float64(fileSize)/float64(1024*1024*1024*1024)) } else { //if fileSize < (1024 * 1024 * 1024 * 1024 * 1024 * 1024) return fmt.Sprintf("%.2fEB", float64(fileSize)/float64(1024*1024*1024*1024*1024)) } } //获取最大最小值 func NewUserModel(ary []int64) (max, min int64) { if len(ary) < 0 { return } // var teamMax T for _, v := range ary { if v > max { max = v } if v < min { min = v } } return } //去重和排序 func UniqueSort(slice []int64) []int64 { var quChong []int64 if len(slice) < 1 { return quChong } //去重 for _, v := range slice { if IsItTrue(v, quChong) == false { quChong = append(quChong, v) } } //排序 return SortForMerge(quChong, 0, len(quChong)-1) } //插入排序 func SortForMerge(arr []int64, left, right int) []int64 { for i := left; i <= right; i++ { temp := arr[i] var j int for j = i; j > left && arr[j-1] > temp; j-- { //定位 arr[j] = arr[j-1] } arr[j] = temp } return arr } //获取用户信息 func GetNewHrPeopleInfo(where interface{}, filed ...string) (ueInfo hrsystem.Personnel, isTrue bool) { isTrue = false // var ueInfo hrsystem.Personnel gormDb := global.GVA_DB_HrDataBase.Model(&hrsystem.Personnel{}) if len(filed) > 0 { fieldStr := strings.Join(filed, ",") gormDb = gormDb.Select(fieldStr) } err := gormDb.Where(where).First(&ueInfo).Error if err != nil { return } isTrue = true return } //浮点数保留两位小数 func Decimal(value float64) float64 { value, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", value), 64) return value } //判断是否为闰年 func IsLeapYear(year int64) bool { //y == 2000,2004 //判断是否为闰年 if year%4 == 0 && year%100 != 0 || year%400 == 0 { return true } return false }