|
|
package BaseOrganizationService
|
|
|
|
|
|
import (
|
|
|
"dsBaseWeb/Business/BaseOrganization/BaseOrganizationProto"
|
|
|
"dsBaseWeb/Business/SysDict/SysDictProto"
|
|
|
"dsBaseWeb/Business/SysDict/SysDictService"
|
|
|
"dsBaseWeb/Utils/CommonUtil"
|
|
|
"encoding/json"
|
|
|
"strings"
|
|
|
)
|
|
|
|
|
|
func PageEnableEduInfo(page int32, limit int32, areaCode string, orgName string, actionPersonId string, actionIpAddress string) (*BaseOrganizationProto.Reply, error) {
|
|
|
Reply, err := PageBaseOrganization(BaseOrganizationProto.QueryArg{Page: page, Limit: limit, AreaCode: areaCode, OrgName: orgName, BUse: 1, OrgType: 1, ActionPersonId: actionPersonId, ActionIpAddress: actionIpAddress})
|
|
|
return Reply, err
|
|
|
}
|
|
|
|
|
|
func PageDisableEduInfo(page int32, limit int32, areaCode string, orgName string, actionPersonId string, actionIpAddress string) (*BaseOrganizationProto.Reply, error) {
|
|
|
Reply, err := PageBaseOrganization(BaseOrganizationProto.QueryArg{Page: page, Limit: limit, AreaCode: areaCode, OrgName: orgName, BUse: -1, OrgType: 1, ActionPersonId: actionPersonId, ActionIpAddress: actionIpAddress})
|
|
|
return Reply, err
|
|
|
}
|
|
|
|
|
|
func GetEduInfoById(orgId string, actionPersonId string, actionIpAddress string) (*BaseOrganizationProto.Reply, error) {
|
|
|
Reply, err := GetBaseOrganization(BaseOrganizationProto.ModelArg{OrgId: orgId, ActionPersonId: actionPersonId, ActionIpAddress: actionIpAddress})
|
|
|
return Reply, err
|
|
|
}
|
|
|
|
|
|
func EnableEdu(orgId string, orgCode string, orgName string, fddbr string, fddbrdh string, address string, lxdh string, sortId int32, actionPersonId string, actionIpAddress string) (*BaseOrganizationProto.Reply, error) {
|
|
|
forceUpdateFields := []string{"fddbr", "fddbrdh", "address", "lxdh"}
|
|
|
Reply, err := UpdateBaseOrganization(BaseOrganizationProto.ModelArg{OrgId: orgId, OrgCode: orgCode, OrgName: orgName, Fddbr: fddbr, Fddbrdh: fddbrdh, Address: address, Lxdh: lxdh, SortId: sortId, BUse: 1, ForceUpdateFields: forceUpdateFields, ActionPersonId: actionPersonId, ActionIpAddress: actionIpAddress})
|
|
|
idsArr := strings.Split(orgId, ",")
|
|
|
SetEnableEdu(BaseOrganizationProto.MultipleQueryArg{Ids: idsArr, ActionPersonId: actionPersonId, ActionIpAddress: actionIpAddress})
|
|
|
return Reply, err
|
|
|
}
|
|
|
|
|
|
func DisableEdu(orgId string, actionPersonId string, actionIpAddress string) (*BaseOrganizationProto.Reply, error) {
|
|
|
idsArr := strings.Split(orgId, ",")
|
|
|
Reply, err := SetDisableEdu(BaseOrganizationProto.MultipleQueryArg{Ids: idsArr, ActionPersonId: actionPersonId, ActionIpAddress: actionIpAddress})
|
|
|
return Reply, err
|
|
|
}
|
|
|
|
|
|
func UpdateEduInfo(orgId string, orgCode string, orgName string, fddbr string, fddbrdh string, address string, lxdh string, sortId int32, actionPersonId string, actionIpAddress string) (*BaseOrganizationProto.Reply, error) {
|
|
|
forceUpdateFields := []string{"fddbr", "fddbrdh", "address", "lxdh"}
|
|
|
Reply, err := UpdateBaseOrganization(BaseOrganizationProto.ModelArg{OrgId: orgId, OrgCode: orgCode, OrgName: orgName, Fddbr: fddbr, Fddbrdh: fddbrdh, Address: address, Lxdh: lxdh, SortId: sortId, ForceUpdateFields: forceUpdateFields, OrgType: 1, ActionPersonId: actionPersonId, ActionIpAddress: actionIpAddress})
|
|
|
return Reply, err
|
|
|
}
|
|
|
|
|
|
func PageEduAssistInfo(page int32, limit int32, areaCode string, orgName string, actionPersonId string, actionIpAddress string) (*BaseOrganizationProto.Reply, error) {
|
|
|
Reply, err := PageBaseOrganization(BaseOrganizationProto.QueryArg{Page: page, Limit: limit, AreaCode: areaCode, OrgName: orgName, OrgType: 7, BUse: 1, ActionPersonId: actionPersonId, ActionIpAddress: actionIpAddress})
|
|
|
return Reply, err
|
|
|
}
|
|
|
|
|
|
func GetEduAssistInfoById(orgId string, actionPersonId string, actionIpAddress string) (*BaseOrganizationProto.Reply, error) {
|
|
|
Reply, err := GetBaseOrganization(BaseOrganizationProto.ModelArg{OrgId: orgId, ActionPersonId: actionPersonId, ActionIpAddress: actionIpAddress})
|
|
|
return Reply, err
|
|
|
}
|
|
|
|
|
|
func AddEduAssistInfo(areaCode string, orgCode string, orgName string, fddbr string, fddbrdh string, address string, lxdh string, sortId int32, actionPersonId string, actionIpAddress string) (*BaseOrganizationProto.Reply, error) {
|
|
|
Reply, err := AddBaseOrganization(BaseOrganizationProto.ModelArg{AreaCode: areaCode, OrgCode: orgCode, OrgName: orgName, Fddbr: fddbr, Fddbrdh: fddbrdh, Address: address, Lxdh: lxdh, SortId: sortId, OrgType: 7, BUse: 1, ActionPersonId: actionPersonId, ActionIpAddress: actionIpAddress})
|
|
|
return Reply, err
|
|
|
}
|
|
|
|
|
|
func UpdateEduAssistInfo(orgId string, orgCode string, orgName string, fddbr string, fddbrdh string, address string, lxdh string, sortId int32, actionPersonId string, actionIpAddress string) (*BaseOrganizationProto.Reply, error) {
|
|
|
forceUpdateFields := []string{"fddbr", "fddbrdh", "address", "lxdh"}
|
|
|
Reply, err := UpdateBaseOrganization(BaseOrganizationProto.ModelArg{OrgId: orgId, OrgCode: orgCode, OrgName: orgName, Fddbr: fddbr, Fddbrdh: fddbrdh, Address: address, Lxdh: lxdh, SortId: sortId, ForceUpdateFields: forceUpdateFields, OrgType: 7, ActionPersonId: actionPersonId, ActionIpAddress: actionIpAddress})
|
|
|
return Reply, err
|
|
|
}
|
|
|
|
|
|
func DeleteEduAssistInfo(ids string, actionPersonId string, actionIpAddress string) (*BaseOrganizationProto.Reply, error) {
|
|
|
idsArr := strings.Split(ids, ",")
|
|
|
Reply, err := DeleteBaseOrganization(BaseOrganizationProto.DeleteIdsArg{Ids: idsArr, ActionPersonId: actionPersonId, ActionIpAddress: actionIpAddress})
|
|
|
return Reply, err
|
|
|
}
|
|
|
|
|
|
func PageSchoolInfo(page int32, limit int32, areaCode string, xxbxlxm string, orgName string, actionPersonId string, actionIpAddress string) (*BaseOrganizationProto.Reply, error) {
|
|
|
Reply, err := PageBaseOrganization(BaseOrganizationProto.QueryArg{Page: page, Limit: limit, AreaCode: areaCode, Xxbxlxm: xxbxlxm, OrgName: orgName, OrgType: 2, BUse: 1, IsMainSchool: false, ActionPersonId: actionPersonId, ActionIpAddress: actionIpAddress})
|
|
|
if Reply.List != "[]" {
|
|
|
codeArr := CommonUtil.ListCollectAttributes(Reply.List, "xxbxlxm")
|
|
|
DictReply, _ := SysDictService.PageSysDictMultipleDictCode(SysDictProto.MultipleQueryArg{DictKind: "xxbxlxm", MultipleDictCode: codeArr, ActionPersonId: actionPersonId, ActionIpAddress: actionIpAddress})
|
|
|
handleListStr := CommonUtil.ListMerge(Reply.List, DictReply.List, "xxbxlxm", "dict_code", "xxbxlxm_name", "dict_value")
|
|
|
Reply.List = handleListStr
|
|
|
}
|
|
|
return Reply, err
|
|
|
}
|
|
|
|
|
|
func PageMainSchoolInfo(page int32, limit int32, areaCode string, orgId string, actionPersonId string, actionIpAddress string) (*BaseOrganizationProto.Reply, error) {
|
|
|
Reply, err := PageBaseOrganization(BaseOrganizationProto.QueryArg{Page: page, Limit: limit, AreaCode: areaCode, BureauId: orgId, OrgType: 2, BUse: 1, IsMainSchool: true, Xxbxlxm: "-1", ActionPersonId: actionPersonId, ActionIpAddress: actionIpAddress})
|
|
|
if Reply.List != "[]" {
|
|
|
codeArr := CommonUtil.ListCollectAttributes(Reply.List, "xxbxlxm")
|
|
|
DictReply, _ := SysDictService.PageSysDictMultipleDictCode(SysDictProto.MultipleQueryArg{DictKind: "xxbxlxm", MultipleDictCode: codeArr, ActionPersonId: actionPersonId, ActionIpAddress: actionIpAddress})
|
|
|
handleListStr := CommonUtil.ListMerge(Reply.List, DictReply.List, "xxbxlxm", "dict_code", "xxbxlxm_name", "dict_value")
|
|
|
Reply.List = handleListStr
|
|
|
}
|
|
|
return Reply, err
|
|
|
}
|
|
|
|
|
|
func GetSchoolInfoById(orgId string, actionPersonId string, actionIpAddress string) (*BaseOrganizationProto.Reply, error) {
|
|
|
Reply, err := GetBaseOrganization(BaseOrganizationProto.ModelArg{OrgId: orgId, ActionPersonId: actionPersonId, ActionIpAddress: actionIpAddress})
|
|
|
return Reply, err
|
|
|
}
|
|
|
|
|
|
func AddSchoolInfo(areaCode string, orgCode string, orgName string, managerAreaCode string, isBranchSchool int32, mainSchoolId string, fsbIds string, xxbxlxm string, szdcxlxm string, xxjbzm string, fddbr string, fddbrdh string, address string, lxdh string, sortId int32, actionPersonId string, actionIpAddress string) (*BaseOrganizationProto.Reply, error) {
|
|
|
idArr := make([]string, 0)
|
|
|
if len(fsbIds) > 0 {
|
|
|
idArr = strings.Split(fsbIds, ",")
|
|
|
}
|
|
|
Reply, err := AddBaseOrganization(BaseOrganizationProto.ModelArg{AreaCode: areaCode, OrgCode: orgCode, OrgName: orgName, OrgType: 2, ManagerAreaCode: managerAreaCode, IsBranchSchool: isBranchSchool, MainSchoolId: mainSchoolId, FsbIds: idArr, Xxbxlxm: xxbxlxm, Szdcxlxm: szdcxlxm, Xxjbzm: xxjbzm, Fddbr: fddbr, Fddbrdh: fddbrdh, Address: address, Lxdh: lxdh, SortId: sortId, BUse: 1, ActionPersonId: actionPersonId, ActionIpAddress: actionIpAddress})
|
|
|
return Reply, err
|
|
|
}
|
|
|
|
|
|
func UpdateSchoolInfo(orgId string, orgCode string, orgName string, managerAreaCode string, isBranchSchool int32, mainSchoolId string, fsbIds string, xxbxlxm string, szdcxlxm string, xxjbzm string, fddbr string, fddbrdh string, address string, lxdh string, sortId int32, actionPersonId string, actionIpAddress string) (*BaseOrganizationProto.Reply, error) {
|
|
|
forceUpdateFields := []string{"fddbr", "fddbrdh", "address", "lxdh"}
|
|
|
idArr := make([]string, 0)
|
|
|
if len(fsbIds) > 0 {
|
|
|
idArr = strings.Split(fsbIds, ",")
|
|
|
}
|
|
|
Reply, err := UpdateBaseOrganization(BaseOrganizationProto.ModelArg{OrgId: orgId, OrgCode: orgCode, OrgName: orgName, ManagerAreaCode: managerAreaCode, IsBranchSchool: isBranchSchool, MainSchoolId: mainSchoolId, FsbIds: idArr, Xxbxlxm: xxbxlxm, Szdcxlxm: szdcxlxm, Xxjbzm: xxjbzm, Fddbr: fddbr, Fddbrdh: fddbrdh, Address: address, Lxdh: lxdh, SortId: sortId, ForceUpdateFields: forceUpdateFields, OrgType: 2, ActionPersonId: actionPersonId, ActionIpAddress: actionIpAddress})
|
|
|
return Reply, err
|
|
|
}
|
|
|
|
|
|
func DeleteSchoolInfo(ids string, actionPersonId string, actionIpAddress string) (*BaseOrganizationProto.Reply, error) {
|
|
|
idsArr := strings.Split(ids, ",")
|
|
|
Reply, err := DeleteBaseOrganization(BaseOrganizationProto.DeleteIdsArg{Ids: idsArr, ActionPersonId: actionPersonId, ActionIpAddress: actionIpAddress})
|
|
|
return Reply, err
|
|
|
}
|
|
|
|
|
|
func PageOrgInfo(page int32, limit int32, bureauId string, actionPersonId string, actionIpAddress string) (*BaseOrganizationProto.Reply, error) {
|
|
|
Reply, err := PageBaseOrganization(BaseOrganizationProto.QueryArg{Page: page, Limit: limit, BureauId: bureauId, BUse: 1, ActionPersonId: actionPersonId, ActionIpAddress: actionIpAddress})
|
|
|
return Reply, err
|
|
|
}
|
|
|
|
|
|
func GetOrgInfo(orgId string, actionPersonId string, actionIpAddress string) (*BaseOrganizationProto.Reply, error) {
|
|
|
Reply, err := GetBaseOrganization(BaseOrganizationProto.ModelArg{OrgId: orgId, ActionPersonId: actionPersonId, ActionIpAddress: actionIpAddress})
|
|
|
if Reply.List != "[]" {
|
|
|
codeArr := CommonUtil.ListCollectAttributes(Reply.List, "org_id")
|
|
|
OrgReply, _ := GetOrgManager(codeArr)
|
|
|
handleListStr := CommonUtil.ListMerge(Reply.List, OrgReply.List, "org_id", "org_id", "org_manager_id", "person_id")
|
|
|
Reply.List = handleListStr
|
|
|
handleListStr = CommonUtil.ListMerge(Reply.List, OrgReply.List, "org_id", "org_id", "org_manager_name", "xm")
|
|
|
Reply.List = handleListStr
|
|
|
|
|
|
}
|
|
|
return Reply, err
|
|
|
}
|
|
|
|
|
|
func AddOrgInfo(bureauId string, orgCode string, orgName string, parentId string, sortId int32, orgManagerIds string, actionPersonId string, actionIpAddress string) (*BaseOrganizationProto.Reply, error) {
|
|
|
var idsArr = make([]string, 0)
|
|
|
if len(orgManagerIds) > 0 {
|
|
|
idsArr = strings.Split(orgManagerIds, ",")
|
|
|
}
|
|
|
|
|
|
Reply, err := AddBaseOrganization(BaseOrganizationProto.ModelArg{BureauId: bureauId, OrgCode: orgCode, OrgName: orgName, ParentId: parentId, SortId: sortId, OrgManagerIds: idsArr, OrgType: 3, BUse: 1, ActionPersonId: actionPersonId, ActionIpAddress: actionIpAddress})
|
|
|
return Reply, err
|
|
|
}
|
|
|
|
|
|
func UpdateOrgInfo(orgId string, orgCode string, orgName string, sortId int32, orgManagerIds string, actionPersonId string, actionIpAddress string) (*BaseOrganizationProto.Reply, error) {
|
|
|
var idsArr = make([]string, 0)
|
|
|
if len(orgManagerIds) > 0 {
|
|
|
idsArr = strings.Split(orgManagerIds, ",")
|
|
|
}
|
|
|
Reply, err := UpdateBaseOrganization(BaseOrganizationProto.ModelArg{OrgId: orgId, OrgCode: orgCode, OrgName: orgName, SortId: sortId, OrgManagerIds: idsArr, ActionPersonId: actionPersonId, ActionIpAddress: actionIpAddress})
|
|
|
return Reply, err
|
|
|
}
|
|
|
|
|
|
func DeleteOrgInfo(ids string, actionPersonId string, actionIpAddress string) (*BaseOrganizationProto.Reply, error) {
|
|
|
idsArr := strings.Split(ids, ",")
|
|
|
Reply, err := DeleteBaseOrganization(BaseOrganizationProto.DeleteIdsArg{Ids: idsArr, ActionPersonId: actionPersonId, ActionIpAddress: actionIpAddress})
|
|
|
return Reply, err
|
|
|
}
|
|
|
|
|
|
func ListOrgByOrgKeyWord(personId string, keyWord string) (*BaseOrganizationProto.Reply, error) {
|
|
|
Reply, err := ListOrgInfoByOrgKeyWord(BaseOrganizationProto.ListOrgArg{PersonId: personId, OrgKeyWord: keyWord})
|
|
|
return Reply, err
|
|
|
}
|
|
|
|
|
|
func ListEduByCityCodeInfo(cityCode string) (*BaseOrganizationProto.Reply, error) {
|
|
|
Reply, err := ListEduByCityCode(BaseOrganizationProto.CityCodeArg{CityCode: cityCode})
|
|
|
return Reply, err
|
|
|
}
|
|
|
|
|
|
func GetOrgTreeInfo(bureauId string, actionPersonId string, actionIpAddress string) (*BaseOrganizationProto.Reply, error) {
|
|
|
Reply, err := GetBureauOrgTree(BaseOrganizationProto.ModelArg{BureauId: bureauId, ActionPersonId: actionPersonId, ActionIpAddress: actionIpAddress})
|
|
|
if Reply.List != "[]" {
|
|
|
codeArr := CommonUtil.ListCollectAttributes(Reply.List, "org_id")
|
|
|
OrgReply, _ := GetOrgManager(codeArr)
|
|
|
handleListStr := CommonUtil.ListMerge(Reply.List, OrgReply.List, "org_id", "org_id", "manager_name", "xm")
|
|
|
Reply.List = convertOrgTree(handleListStr)
|
|
|
}
|
|
|
return Reply, err
|
|
|
}
|
|
|
|
|
|
func convertOrgTree(listStr string) string {
|
|
|
list := CommonUtil.ConvertJsonStringToMapArray(listStr)
|
|
|
ListOrgNode := make([]*OrgNode, 0)
|
|
|
for i := range list {
|
|
|
record := list[i]
|
|
|
//添加数据
|
|
|
a := OrgNode{
|
|
|
OrgId: record["org_id"].(string),
|
|
|
ParentId: record["parent_id"].(string),
|
|
|
SortId: record["sort_id"].(float64),
|
|
|
OrgCode: record["org_code"].(string),
|
|
|
ManageName: record["manager_name"].(string),
|
|
|
OrgName: record["org_name"].(string),
|
|
|
}
|
|
|
ListOrgNode = append(ListOrgNode, &a)
|
|
|
}
|
|
|
//结构体的SortId根据数据库获取时,使用order by方法获取有序的子元素集合,这里就不在代码中进行排序了。
|
|
|
|
|
|
//从根节点开始进行构建,递归调用生成tree
|
|
|
startOrgNode := ListOrgNode[0]
|
|
|
makeTree(ListOrgNode, startOrgNode)
|
|
|
//根据结构体生成json数据
|
|
|
jsonByte, _ := json.Marshal(startOrgNode)
|
|
|
|
|
|
return string(jsonByte)
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
功能:部门实体Struct
|
|
|
作者:黄海
|
|
|
时间:2020-06-03
|
|
|
*/
|
|
|
type OrgNode struct {
|
|
|
OrgId string `json:"org_id"`
|
|
|
OrgCode string `json:"org_code"`
|
|
|
ParentId string `json:"parent_id"`
|
|
|
SortId float64 `json:"sort_id"`
|
|
|
OrgName string `json:"org_name"`
|
|
|
ManageName string `json:"manager_name"`
|
|
|
Children []*OrgNode `json:"children,omitempty"`
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
功能:从指定节点开始构建树状结构
|
|
|
作者:黄海
|
|
|
时间:2020-06-03
|
|
|
*/
|
|
|
func makeTree(allNode []*OrgNode, node *OrgNode) {
|
|
|
children, _ := haveChild(allNode, node) //是不是有子节点
|
|
|
if children != nil {
|
|
|
node.Children = append(node.Children, children[0:]...) //添加子节点
|
|
|
for _, v := range children { //查询子节点的子节点,并添加到子节点
|
|
|
_, has := haveChild(allNode, v)
|
|
|
if has {
|
|
|
makeTree(allNode, v) //递归添加节点
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
功能:判断是不是有子节点
|
|
|
作者:黄海
|
|
|
时间:2020-06-03
|
|
|
*/
|
|
|
func haveChild(AllNode []*OrgNode, node *OrgNode) (children []*OrgNode, yes bool) {
|
|
|
for _, v := range AllNode {
|
|
|
if v.ParentId == node.OrgId {
|
|
|
children = append(children, v)
|
|
|
}
|
|
|
}
|
|
|
if children != nil {
|
|
|
yes = true
|
|
|
}
|
|
|
return
|
|
|
}
|