@ -5,11 +5,14 @@ import (
"appPlatform/models/modelshr"
"appPlatform/overall"
"appPlatform/overall/publicmethod"
"fmt"
"encoding/json"
"regexp"
"sort"
"strconv"
"strings"
"time"
"github.com/gin-gonic/gin"
)
/ *
@ -19,8 +22,7 @@ import (
@ 功能 : 生成步进工作流
@ 参数
# creater 发起人信息
# orgId 执行行政组织
#
@ 返回值
@ -30,9 +32,123 @@ import (
#
* /
func ( f * FlowMainBody ) GenerateFlow ( creater modelshr . ManCont , orgId int64 , condition [ ] ConditionListInfo ) ( workFlowInfo [ ] RunFlow ) {
//生成工作流
workFlowInfo = f . NodeConfig . CircularParsing ( 1 , creater , orgId , condition )
func ( a * ApiMethod ) GenerateFlow ( c * gin . Context ) {
var requestData CreatFlowView
err := c . ShouldBindJSON ( & requestData )
if err != nil {
publicmethod . Result ( 10001 , err , c )
return
}
if requestData . Step == 0 {
requestData . Step = 1
}
var flowInfo modelAppPlatform . FlowVersion
err = flowInfo . GetCont ( map [ string ] interface { } { "`key`" : requestData . Id } )
if err != nil && flowInfo . Content == "" {
publicmethod . Result ( 107 , err , c )
return
}
var flowVersionCont FlowMainBody
err = json . Unmarshal ( [ ] byte ( flowInfo . Content ) , & flowVersionCont )
if err != nil {
publicmethod . Result ( 104 , err , c )
return
}
context , _ := c . Get ( overall . MyContJwt )
var userCont modelshr . ManCont
userCont . GetLoginCont ( context )
workFlowInfo := flowVersionCont . NodeConfig . CircularParsing ( 1 , userCont , 349 , requestData . ConditionList , requestData . NodelPeople )
var sendInfo SendFlowInfo
sendInfo . Step = requestData . Step
sendInfo . NodeKey , sendInfo . NextStep , sendInfo . FlowList = ReformFlow ( requestData . Step , workFlowInfo )
publicmethod . Result ( 0 , sendInfo , c )
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2023 - 11 - 21 0 9 : 26 : 44
@ 功能 : 重整工作流步进值
@ 参数
# step 当前在执行第几步
# nodeList 工作流主体
@ 返回值
# nodeKey 当前执行节点标识
# nodeMap 工作流主体
@ 方法原型
#
* /
func ReformFlow ( step int , nodeList [ ] RunFlow ) ( nodeKey string , nextStep int , nodeMap [ ] RunFlow ) {
sort . Slice ( nodeList , func ( i , j int ) bool {
return nodeList [ i ] . Step < nodeList [ j ] . Step
} )
nodeNum := make ( map [ int ] string )
for i , v := range nodeList {
nodeNum [ i ] = v . NodeKey
}
for i , v := range nodeList {
if v . Step == step {
nodeKey = v . NodeKey
}
lastStep := step + 1
if lastStep == v . Step {
nextStep = lastStep
}
var nodeInfo RunFlow
nodeInfo . Step = v . Step //步骤
nodeInfo . Types = v . Types //0:发起节点;1:审批节点;2:抄送;3:执行节点
nodeInfo . NodeKey = v . NodeKey //节点识别符
nodeInfo . NodeName = v . NodeName //节点名称
nodeInfo . Status = v . Status //1:未到达;2:已审批;3:已驳回;4:再次审批
if i - 1 >= 0 {
nodeInfo . FromNode = nodeNum [ i - 1 ]
}
if val , isOk := nodeNum [ i + 1 ] ; isOk {
nodeInfo . ArriveNode = val //到哪个节点
} else {
nodeInfo . ArriveNode = "endflow" //到哪个节点
}
nodeInfo . GoBackNode = v . GoBackNode //驳回返回节点
nodeInfo . ExamineMode = v . ExamineMode //多人审批时采用的审批方式。0:无操作 1依次审批 2会签 3:非会签
nodeInfo . NoHanderAction = v . NoHanderAction //审批人为空时 1自动审批通过/不允许发起 2转交给审核管理员
nodeInfo . CustomNode = v . CustomNode //由哪个节点指定本节点审批人
nodeInfo . JudgeList = v . JudgeList //是否可自己选中操作人
var operAry [ ] OperatorList
for _ , op := range v . Operator {
var operInfo OperatorList
operInfo . Id = op . Id //操作人ID
operInfo . Types = op . Types //1:人员;2:角色;3:行政组织
operInfo . Name = op . Name //操作人姓名
operInfo . Number = op . Number //操作人工号
operInfo . Icon = op . Icon //操作人头像
operInfo . IconBase64 = op . IconBase64 //操作人头像
operInfo . Wechat = op . Wechat //微信Openid
operInfo . DepartmentId = op . DepartmentId //分厂Id
operInfo . DepartmentName = op . DepartmentName //分厂名称
operInfo . PostId = op . PostId //职务Id
operInfo . PostName = op . PostName //职务名称
operInfo . Tema = op . Tema //班组Id
operInfo . TemaName = op . TemaName //班组名称
operInfo . LogList = op . LogList //操作记录
operInfo . NoEdit = true //不可删除
operInfo . Tel = op . Tel //
operInfo . CompanyName = op . CompanyName
operAry = append ( operAry , operInfo )
}
nodeInfo . Operator = operAry //操作人
nodeInfo . RunType = v . RunType //运行时选择 0:禁闭;1:发起人自选,2:发起人自己,3:有选中得节点指定,4:抄送节点
nodeInfo . RunScope = v . RunScope //运行时选择范围 0:不可选,1:本公司;2:本部门;当RunType = 4时:1:自选;非1:不可自选
nodeInfo . PendPers = v . PendPers //
nodeMap = append ( nodeMap , nodeInfo )
}
// nodeMap = nodeList
return
}
@ -56,9 +172,10 @@ func (f *FlowMainBody) GenerateFlow(creater modelshr.ManCont, orgId int64, condi
#
* /
func ( n * NodePublicInfo ) CircularParsing ( step int , creater modelshr . ManCont , orgId int64 , condition [ ] ConditionListInfo ) ( nodeList [ ] RunFlow ) {
fmt . Printf ( "step: %v; name:%v; Types:%v\n" , step , n . NodeName , n . Types )
func ( n * NodePublicInfo ) CircularParsing ( step int , creater modelshr . ManCont , orgId int64 , condition [ ] ConditionListInfo , nodelPeople [ ] NodelPeopleInfo ) ( nodeList [ ] RunFlow ) {
// fmt.Printf("step: %v; name:%v; Types:%v\n", step, n.NodeName, n.Types)
var nodeInfo RunFlow
nodeInfo . Step = step
nodeInfo . Types = n . Types
nodeInfo . NodeKey = n . NodeNumber
@ -72,6 +189,7 @@ func (n *NodePublicInfo) CircularParsing(step int, creater modelshr.ManCont, org
}
nodeInfo . ExamineMode = n . ExamineMode
nodeInfo . NoHanderAction = n . NoHanderAction
//判断节点类型
//0:发起人;1:审批;2:抄送;3:执行人;4:条件;5:路由
switch n . Types {
@ -98,9 +216,16 @@ func (n *NodePublicInfo) CircularParsing(step int, creater modelshr.ManCont, org
nodeInfo . Operator = GainOrgPostUserList ( orgId , n . NodeUserList )
}
case 4 : //发起人自选
nodeInfo . RunType = 1
nodeInfo . RunScope = n . SelectRange
if n . SelectRange != 1 {
// fmt.Printf("发起人自选--->%v\n--->%v\n", n.SelectRange, OperatorHandle(n.NodeUserList))
nodeInfo . PendPers = OperatorHandle ( n . NodeUserList )
}
case 5 : //发起人自己
var myCont modelshr . PersonArchives
myCont . GetCont ( map [ string ] interface { } { "`id`" : creater . Id } , "`key`" , "`name`" , "`number`" , "`icon`" , "`icon_photo`" , "`wechat`" , "`work_wechat`" , "`admin_org`" , "`position`" , "`teamid`" )
var myCont modelshr . ManCont
myCont . GetCont ( map [ string ] interface { } { "`id`" : creater . Id } , "`key`" , "`name`" , "`number`" , "`icon`" , "`icon_photo`" , "`wechat`" , "`work_wechat`" , "`admin_org`" , "`position`" , "`teamid`" , "`mobilephone`,`company`" )
nodeInfo . Operator = append ( nodeInfo . Operator , TransformPublicUs ( myCont ) )
case 6 : //连续多级主管
var levelUserList ContinuousMultiLevelSupervisor
@ -114,7 +239,29 @@ func (n *NodePublicInfo) CircularParsing(step int, creater modelshr.ManCont, org
nodeInfo . Operator = levelUserList . ObtainRelevantLevelLeaders ( orgId )
}
case 7 : //指定前置审批为本节点设置审批人
nodeInfo . RunType = 3
nodeInfo . CustomNode = n . CustomNode
case 8 : //表单字段
reg1 := regexp . MustCompile ( ` \(([^)]+)\) ` ) //解析()内的数据
var userNumber [ ] string //工号切片
for _ , v := range n . NodeUserList { //判断本节点需要什么样的表格字段
for _ , e := range nodelPeople { //循环找出提交得表格字段
if v . Id == e . FactorId { //判断提交得字段是否为当前节点操作字段
userAry := reg1 . FindAllStringSubmatch ( e . UserList , - 1 ) //按照正则规则提取数据
for _ , u := range userAry {
vLen := len ( u )
if vLen > 0 {
if ! publicmethod . IsInTrue [ string ] ( u [ vLen - 1 ] , userNumber ) {
userNumber = append ( userNumber , u [ vLen - 1 ] ) //将工号写入数组
}
}
}
}
}
}
if len ( userNumber ) > 0 {
nodeInfo . Operator = GainUserCode ( userNumber )
}
case 9 : //权限矩阵
if n . Attribute == 1 {
nodeInfo . Operator = GainMatrixUserList ( creater . AdminOrg , n . Matrix )
@ -123,15 +270,19 @@ func (n *NodePublicInfo) CircularParsing(step int, creater modelshr.ManCont, org
}
default :
}
// jsonCont, _ := json.Marshal(nodeInfo)
// fmt.Printf("第%v步------>%v\n", step, string(jsonCont))
nodeList = append ( nodeList , nodeInfo )
if n . ChildNode != nil {
nodeList = append ( nodeList , n . ChildNode . CircularParsing ( step + 1 , creater , orgId , condition ) ... )
nodeList = append ( nodeList , n . ChildNode . CircularParsing ( step + 1 , creater , orgId , condition , nodelPeople ) ... )
}
case 2 :
nodeInfo . RunType = 4
nodeInfo . RunScope = n . CcSelfSelectFlag
nodeInfo . Operator = OperatorHandle ( n . NodeUserList )
nodeList = append ( nodeList , nodeInfo )
if n . ChildNode != nil {
nodeList = append ( nodeList , n . ChildNode . CircularParsing ( step + 1 , creater , orgId , condition ) ... )
nodeList = append ( nodeList , n . ChildNode . CircularParsing ( step + 1 , creater , orgId , condition , nodelPeople ) ... )
}
case 4 :
case 5 :
@ -142,7 +293,7 @@ func (n *NodePublicInfo) CircularParsing(step int, creater modelshr.ManCont, org
} )
lastStrp := step
for _ , pv := range n . ConditionNodes { //循环解析相关条件
routerNodes := pv . ResolveRouting ( step , creater , orgId , condition )
routerNodes := pv . ResolveRouting ( step , creater , orgId , condition , nodelPeople )
if len ( routerNodes ) > 0 {
lastStrp = lastStrp + len ( routerNodes )
nodeList = append ( nodeList , routerNodes ... )
@ -150,14 +301,15 @@ func (n *NodePublicInfo) CircularParsing(step int, creater modelshr.ManCont, org
}
}
if n . ChildNode != nil {
nodeList = append ( nodeList , n . ChildNode . CircularParsing ( lastStrp , creater , orgId , condition ) ... )
nodeList = append ( nodeList , n . ChildNode . CircularParsing ( lastStrp , creater , orgId , condition , nodelPeople ) ... )
}
} else {
if n . ChildNode != nil {
nodeList = append ( nodeList , n . ChildNode . CircularParsing ( step + 1 , creater , orgId , condition ) ... )
nodeList = append ( nodeList , n . ChildNode . CircularParsing ( step + 1 , creater , orgId , condition , nodelPeople ) ... )
}
}
default :
nodeInfo . RunType = 0
//发起人
var originator OperatorList
originator . Id = strconv . FormatInt ( creater . Key , 10 ) //操作人ID
@ -193,12 +345,12 @@ func (n *NodePublicInfo) CircularParsing(step int, creater modelshr.ManCont, org
}
var logCont LogList
logCont . State = 1 //状态 1、未操作;2、通过;3、驳回
logCont . TimeVal = publicmethod . UnixTimeToDay ( time . Now ( ) . Unix ( ) , 24 )
logCont . TimeVal = publicmethod . UnixTimeToDay ( time . Now ( ) . Unix ( ) , 1 )
// originator.LogList = append(originator.LogList, logCont) //操作记录
nodeInfo . Operator = append ( nodeInfo . Operator , originator )
nodeList = append ( nodeList , nodeInfo )
if n . ChildNode != nil {
nodeList = append ( nodeList , n . ChildNode . CircularParsing ( step + 1 , creater , orgId , condition ) ... )
nodeList = append ( nodeList , n . ChildNode . CircularParsing ( step + 1 , creater , orgId , condition , nodelPeople ) ... )
}
}
return
@ -224,7 +376,7 @@ func (n *NodePublicInfo) CircularParsing(step int, creater modelshr.ManCont, org
#
* /
func ( n * NodePublicInfoES ) ResolveRouting ( step int , creater modelshr . ManCont , orgId int64 , condition [ ] ConditionListInfo ) ( nodeList [ ] RunFlow ) {
func ( n * NodePublicInfoES ) ResolveRouting ( step int , creater modelshr . ManCont , orgId int64 , condition [ ] ConditionListInfo , nodelPeople [ ] NodelPeopleInfo ) ( nodeList [ ] RunFlow ) {
// fmt.Printf("解析条件---》%v\n", n.NodeName)
if len ( n . ConditionList ) > 0 {
// fmt.Printf("解析条件--1-》%v\n", n.ConditionList)
@ -249,16 +401,16 @@ func (n *NodePublicInfoES) ResolveRouting(step int, creater modelshr.ManCont, or
default :
}
}
fmt . Printf ( "termAry:%v----->%v\n" , len ( n . ConditionList ) , termAry )
// fmt.Printf("termAry:%v----->%v\n", len(n.ConditionList), termAry)
// if len(termAry) == len(n.ConditionList) {
if termAry == len ( n . ConditionList ) {
if n . ChildNode != nil {
nodeList = append ( nodeList , n . ChildNode . CircularParsing ( step , creater , orgId , condition ) ... )
nodeList = append ( nodeList , n . ChildNode . CircularParsing ( step , creater , orgId , condition , nodelPeople ) ... )
}
}
} else {
if n . ChildNode != nil {
nodeList = append ( nodeList , n . ChildNode . CircularParsing ( step , creater , orgId , condition ) ... )
nodeList = append ( nodeList , n . ChildNode . CircularParsing ( step , creater , orgId , condition , nodelPeople ) ... )
}
}
return
@ -401,7 +553,7 @@ func JudgingCustomConditions(customFields []CustomFieldsInfo, presetVal []Condit
}
}
}
fmt . Printf ( "处理自定义条件-->%v-->%v\n" , isOk , len ( customFields ) )
// fmt.Printf("处理自定义条件-->%v-->%v\n", isOk, len(customFields))
if isOk == len ( customFields ) {
isTrue = true
}
@ -435,7 +587,7 @@ func ProcessMultipleSelectionResults(judging ConditionListInfo, presetVal []Cond
if v . Types == 3 && judging . Factorid == v . Factorid {
if judging . IsCheckbox {
fmt . Printf ( "termAry:%v----->%v----->%v\n" , v . Answers , judging . Answers , len ( v . Answers ) <= len ( judging . Answers ) )
// fmt.Printf("termAry:%v----->%v----->%v\n", v.Answers, judging.Answers, len(v.Answers) <= len(judging.Answers))
//多选
if len ( v . Answers ) <= len ( judging . Answers ) { //判断答案个数是否小于等于设定条件值个数
isTrue = true
@ -446,7 +598,7 @@ func ProcessMultipleSelectionResults(judging ConditionListInfo, presetVal []Cond
}
}
} else { //单选
fmt . Printf ( "termAry:%v----->%v----->%v\n" , v . Oneanswer , judging . Oneanswer , v . Oneanswer == judging . Oneanswer )
// fmt.Printf("termAry:%v----->%v----->%v\n", v.Oneanswer, judging.Oneanswer, v.Oneanswer == judging.Oneanswer)
// if len(v.Answers) == len(judging.Answers) {
// isTrue = false
// for i := 0; i < len(v.Answers); i++ {
@ -551,7 +703,7 @@ func JudgingTermPeoOrgRoles(term []FlowPermissionInfo, creater modelshr.ManCont)
* /
func GainMatrixUserList ( orgId int64 , matrix MatrixInfo ) ( UserList [ ] OperatorList ) {
allOrgId := publicmethod . HaveAllOrgRelation ( orgId ) //获取全部归属行政单位
fmt . Printf ( "全部行政组织:%v---->%v\n" , orgId , allOrgId )
// fmt.Printf("全部行政组织:%v---->%v\n", orgId, allOrgId)
var keyVal int64
err := overall . CONSTANT_DB_AppPlatform . Model ( & modelAppPlatform . MatrixHandler { } ) . Select ( "`number`" ) . Where ( "`types` = 1 AND `mc_id` = ? AND `mh_id` = ? AND `hand_id` IN ?" , matrix . MatrixId , matrix . FactorId , allOrgId ) . First ( & keyVal ) . Error
if err != nil {
@ -562,8 +714,8 @@ func GainMatrixUserList(orgId int64, matrix MatrixInfo) (UserList []OperatorList
if err != nil || len ( userKeys ) < 1 {
return
}
var userInfoAry [ ] modelshr . PersonArchives
overall . CONSTANT_DB_HR . Model ( & modelshr . PersonArchives { } ) . Select ( "`key`,`name`,`number`,`icon`,`icon_photo`,`wechat`,`work_wechat`,`admin_org`,`position`,`teamid`" ) . Where ( "`key` IN ? AND `emp_type` BETWEEN ? AND ?" , userKeys , 1 , 10 ) . Find ( & userInfoAry )
var userInfoAry [ ] modelshr . ManCont
overall . CONSTANT_DB_HR . Model ( & modelshr . ManCont { } ) . Select ( "`key`,`name`,`number`,`icon`,`icon_photo`,`wechat`,`work_wechat`,`admin_org`,`position`,`teamid`,`mobilephone`,`company `" ) . Where ( "`key` IN ? AND `emp_type` BETWEEN ? AND ?" , userKeys , 1 , 10 ) . Find ( & userInfoAry )
if len ( userInfoAry ) > 0 {
for _ , uv := range userInfoAry {
UserList = append ( UserList , TransformPublicUs ( uv ) )
@ -592,7 +744,9 @@ func GainMatrixUserList(orgId int64, matrix MatrixInfo) (UserList []OperatorList
* /
func GainOrgPostUserList ( orgId int64 , approvers [ ] NodeUserListInfo ) ( UserList [ ] OperatorList ) {
if len ( approvers ) > 0 {
allOrgId := publicmethod . HaveAllOrgRelation ( orgId ) //获取全部归属行政单位
_ , companyId , _ , _ , _ := publicmethod . GetOrgStructurees ( orgId )
allOrgId := publicmethod . HaveAllOrgRelation ( companyId ) //获取全部归属行政单位
var userAry MultiLeveUserList
for _ , v := range approvers { //逐行分析职务
if v . Types == 4 {
@ -634,8 +788,8 @@ func (m *MultiLeveUserList) GainOrgPostPeople(orgId []int64, options []OptionsIn
}
}
if len ( postId ) > 0 {
var userInfoAry [ ] modelshr . PersonArchives
overall . CONSTANT_DB_HR . Model ( & modelshr . PersonArchives { } ) . Select ( "`key`,`name`,`number`,`icon`,`icon_photo`,`wechat`,`work_wechat`,`admin_org`,`position`,`teamid`" ) . Where ( "`person_in_charge` = 1 AND `admin_org` IN ? AND position = ? AND `emp_type` BETWEEN ? AND ?" , orgId , postId , 1 , 10 ) . Find ( & userInfoAry )
var userInfoAry [ ] modelshr . ManCont
overall . CONSTANT_DB_HR . Model ( & modelshr . ManCont { } ) . Select ( "`key`,`name`,`number`,`icon`,`icon_photo`,`wechat`,`work_wechat`,`admin_org`,`position`,`teamid`,`mobilephone`,`company `" ) . Where ( "`person_in_charge` = 1 AND `admin_org` IN ? AND position = ? AND `emp_type` BETWEEN ? AND ?" , orgId , postId , 1 , 10 ) . Find ( & userInfoAry )
if len ( userInfoAry ) > 0 {
for _ , uv := range userInfoAry {
m . UserList = append ( m . UserList , TransformPublicUs ( uv ) )
@ -738,8 +892,8 @@ func (c *ContinuousMultiLevelSupervisor) ObtainRelevantLevelLeadersUser(level in
var orgInfo modelshr . AdministrativeOrganization
err := orgInfo . GetCont ( map [ string ] interface { } { "`id`" : orgId } , "`superior`" )
if err == nil {
var userList [ ] modelshr . PersonArchives
err = overall . CONSTANT_DB_HR . Model ( & modelshr . PersonArchives { } ) . Select ( "`key`,`name`,`number`,`icon`,`icon_photo`,`wechat`,`work_wechat`,`admin_org`,`position`,`teamid`" ) . Where ( "`person_in_charge` = 1 AND `admin_org` = ? AND `emp_type` BETWEEN ? AND ?" , orgId , 1 , 10 ) . Find ( & userList ) . Error
var userList [ ] modelshr . ManCont
err = overall . CONSTANT_DB_HR . Model ( & modelshr . ManCont { } ) . Select ( "`key`,`name`,`number`,`icon`,`icon_photo`,`wechat`,`work_wechat`,`admin_org`,`position`,`teamid`,`mobilephone`,`company `" ) . Where ( "`person_in_charge` = 1 AND `admin_org` = ? AND `emp_type` BETWEEN ? AND ?" , orgId , 1 , 10 ) . Find ( & userList ) . Error
if err == nil {
var userAry MultiLeveUserList
@ -805,8 +959,8 @@ func OperatorHandle(userList []NodeUserListInfo) (userAry []OperatorList) {
default :
}
}
var userContMap [ ] modelshr . PersonArchives
overall . CONSTANT_DB_HR . Model ( & modelshr . PersonArchives { } ) . Select ( "`key`,`name`,`number`,`icon`,`icon_photo`,`wechat`,`work_wechat`,`admin_org`,`position`,`teamid`" ) . Where ( "`key` IN ?" , userIdAry ) . Find ( & userContMap )
var userContMap [ ] modelshr . ManCont
overall . CONSTANT_DB_HR . Model ( & modelshr . ManCont { } ) . Select ( "`key`,`name`,`number`,`icon`,`icon_photo`,`wechat`,`work_wechat`,`admin_org`,`position`,`teamid`,`mobilephone`,`company `" ) . Where ( "`key` IN ?" , userIdAry ) . Find ( & userContMap )
for _ , v := range userContMap {
userAry = append ( userAry , TransformPublicUs ( v ) )
}
@ -831,17 +985,23 @@ func OperatorHandle(userList []NodeUserListInfo) (userAry []OperatorList) {
#
* /
func TransformPublicUs ( v modelshr . PersonArchives ) ( userCont OperatorList ) {
func TransformPublicUs ( v modelshr . ManCont ) ( userCont OperatorList ) {
userCont . Id = strconv . FormatInt ( v . Key , 10 )
userCont . Types = 1 //1:人员;2:角色;3:行政组织
userCont . Name = v . Name //操作人姓名
userCont . Number = v . Number //操作人工号
userCont . Icon = v . Icon //操作人头像
userCont . IconBase64 = v . IconPhoto //操作人头像
userCont . Wechat = v . Wechat //微信Openid
userCont . IconBase64 = v . IconPhpto //操作人头像
userCont . Wechat = v . Wechat //微信Openid、
userCont . Tel = v . Mobilephone
if v . WorkWechat != "" {
userCont . Wechat = v . WorkWechat //微信Openid
}
if v . Company != 0 {
var orgGroupCont modelshr . AdministrativeOrganization
orgGroupCont . GetCont ( map [ string ] interface { } { "`id`" : v . Company } , "`name`" )
userCont . CompanyName = orgGroupCont . Name //公司名称
}
_ , companyId , _ , _ , _ := publicmethod . GetOrgStructurees ( v . AdminOrg )
userCont . DepartmentId = companyId //分厂Id
if companyId != 0 {
@ -864,3 +1024,121 @@ func TransformPublicUs(v modelshr.PersonArchives) (userCont OperatorList) {
}
return
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2023 - 11 - 20 16 : 06 : 0 9
@ 功能 : 根据工号获取人员信息
@ 参数
#
@ 返回值
#
@ 方法原型
#
* /
func GainUserCode ( userNumber [ ] string ) ( userAry [ ] OperatorList ) {
var userInfoAry [ ] modelshr . ManCont
overall . CONSTANT_DB_HR . Model ( & modelshr . ManCont { } ) . Select ( "`key`,`name`,`number`,`icon`,`icon_photo`,`wechat`,`work_wechat`,`admin_org`,`position`,`teamid`,`mobilephone`,`company`" ) . Where ( "`number` IN ? AND `emp_type` BETWEEN ? AND ?" , userNumber , 1 , 10 ) . Find ( & userInfoAry )
if len ( userInfoAry ) > 0 {
for _ , uv := range userInfoAry {
userAry = append ( userAry , TransformPublicUs ( uv ) )
}
}
return
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2023 - 11 - 22 10 : 00 : 34
@ 功能 : 获取操作人 、
@ 参数
#
@ 返回值
#
@ 方法原型
#
* /
func ( a * ApiMethod ) GainFlowPeople ( c * gin . Context ) {
var requestData GainFlowOperator
err := c . ShouldBindJSON ( & requestData )
if err != nil || len ( requestData . Numbers ) < 1 {
publicmethod . Result ( 10001 , err , c )
return
}
usSry := GainUserCode ( requestData . Numbers )
if len ( usSry ) < 1 {
publicmethod . Result ( 10001 , err , c , "没有数据" )
return
}
publicmethod . Result ( 0 , usSry , c )
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2023 - 11 - 22 10 : 19 : 10
@ 功能 : 自定义表单搜索人员
@ 参数
#
@ 返回值
#
@ 方法原型
#
* /
func ( a * ApiMethod ) SearchUserList ( c * gin . Context ) {
var requestData SearchUserCont
c . ShouldBindJSON ( & requestData )
if requestData . Page == 0 {
requestData . Page = 1
}
if requestData . PageSize == 0 {
requestData . PageSize = 10
}
gormDb := overall . CONSTANT_DB_HR . Model ( & modelshr . PersonArchives { } ) . Select ( "`number`" ) . Where ( "`number` NOT LIKE ?" , "%W%" )
if requestData . Name != "" {
gormDb = gormDb . Where ( "number LIKE ? OR name LIKE ?" , "%" + requestData . Name + "%" , "%" + requestData . Name + "%" )
}
if requestData . Department != 0 {
var sunOrg publicmethod . GetOrgAllParent
sunOrg . GetOrgSonAllId ( requestData . Department )
sunOrg . Id = append ( sunOrg . Id , requestData . Department )
gormDb = gormDb . Where ( "admin_org IN ?" , sunOrg . Id )
}
gormDb = gormDb . Where ( "emp_type BETWEEN ? AND ?" , 1 , 10 )
var total int64
totalErr := gormDb . Count ( & total ) . Error
if totalErr != nil {
total = 0
}
var idAry [ ] string
gormDb = publicmethod . PageTurningSettings ( gormDb , requestData . Page , requestData . PageSize )
err := gormDb . Find ( & idAry ) . Error
var userList [ ] OperatorList
if err != nil || len ( idAry ) < 1 {
publicmethod . ResultList ( 0 , requestData . Page , requestData . PageSize , total , int64 ( len ( userList ) ) , userList , c )
return
}
usSry := GainUserCode ( idAry )
if len ( usSry ) < 1 {
publicmethod . ResultList ( 0 , requestData . Page , requestData . PageSize , total , int64 ( len ( userList ) ) , userList , c )
return
}
publicmethod . ResultList ( 0 , requestData . Page , requestData . PageSize , total , int64 ( len ( usSry ) ) , usSry , c )
}