|
@@ -37,12 +37,13 @@ type networkTree struct {
|
|
|
Children []*networkTreeChild `json:"children"`
|
|
|
}
|
|
|
type networkTreeChild struct {
|
|
|
- Count int64 `json:"count"`
|
|
|
- Id int64 `json:"id"`
|
|
|
- CompanyId string `json:"companyId"`
|
|
|
- CompanyName string `json:"companyName"`
|
|
|
- Type string `json:"type"`
|
|
|
- CreateTime string `json:"createTime"`
|
|
|
+ Count int64 `json:"count"`
|
|
|
+ Id int64 `json:"id"`
|
|
|
+ CompanyId string `json:"companyId"`
|
|
|
+ CompanyName string `json:"companyName"`
|
|
|
+ Type string `json:"type"`
|
|
|
+ CreateTime string `json:"createTime"`
|
|
|
+ IdNames []*idName `json:"idNames"`
|
|
|
}
|
|
|
|
|
|
func (n *networkTree) Len() int {
|
|
@@ -330,7 +331,7 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
|
|
|
reply = &types.Reply{}
|
|
|
key := fmt.Sprintf(NetworkManageAllProjectKey, in.PositionId)
|
|
|
rbt, rerr := redis.GetNewBytes("newother", key)
|
|
|
- if rerr == nil && rbt != nil {
|
|
|
+ if false && rerr == nil && rbt != nil {
|
|
|
json.Unmarshal(*rbt, &reply)
|
|
|
return
|
|
|
}
|
|
@@ -416,15 +417,18 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
|
|
|
case 2:
|
|
|
if aio.Supplier[v.Company_id] != nil {
|
|
|
ntc.Count = aio.Supplier[v.Company_id].ProjectCount
|
|
|
+ ntc.IdNames = aio.Supplier[v.Company_id].IdNames
|
|
|
}
|
|
|
case 3:
|
|
|
if aio.Adiffb[v.Company_id] != nil {
|
|
|
ntc.Count = aio.Adiffb[v.Company_id].ProjectCount
|
|
|
+ ntc.IdNames = aio.Adiffb[v.Company_id].IdNames
|
|
|
}
|
|
|
case 4:
|
|
|
if v.Relate_buyer_id != "" {
|
|
|
- for _, v := range strings.Split(v.Relate_buyer_id, ",") {
|
|
|
- if aio.Middleman[v] != nil {
|
|
|
+ for _, rbi := range strings.Split(v.Relate_buyer_id, ",") {
|
|
|
+ ntc.IdNames = append(ntc.IdNames, &idName{Id: rbi})
|
|
|
+ if aio.Middleman[rbi] != nil {
|
|
|
ntc.Count++
|
|
|
}
|
|
|
}
|
|
@@ -432,6 +436,7 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
|
|
|
case 5:
|
|
|
if aio.Agency[v.Company_id] != nil {
|
|
|
ntc.Count = aio.Agency[v.Company_id].ProjectCount
|
|
|
+ ntc.IdNames = aio.Agency[v.Company_id].IdNames
|
|
|
}
|
|
|
}
|
|
|
count += ntc.Count
|
|
@@ -439,9 +444,18 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
|
|
|
list[v.Itype-1].Children = append(list[v.Itype-1].Children, ntc)
|
|
|
}
|
|
|
}
|
|
|
+ checkCode := []string{}
|
|
|
parentConvList := &nodeTrees{}
|
|
|
convList := &nodeTrees{}
|
|
|
+ hasDefaultCheck := false
|
|
|
+ if in.ClickId != "" {
|
|
|
+ hasDefaultCheck = true
|
|
|
+ }
|
|
|
for _, v := range list {
|
|
|
+ if len(v.Children) == 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ parentStartCheckCodeLen := len(checkCode)
|
|
|
pm := &nodeTree{
|
|
|
CODE: v.Name,
|
|
|
NAME: v.Name,
|
|
@@ -457,6 +471,7 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
|
|
|
sort.Sort(v)
|
|
|
id, pType, pMyType, pMyId := "", "", "", ""
|
|
|
for _, vv := range v.Children {
|
|
|
+ childStartCheckCodeLen := len(checkCode)
|
|
|
myId := vv.CompanyId
|
|
|
if vv.Type == "middleman" {
|
|
|
myId = fmt.Sprint(vv.Id)
|
|
@@ -470,10 +485,14 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
|
|
|
}
|
|
|
pMyType += vv.Type
|
|
|
myChildIds, myChildTypes := "", ""
|
|
|
+ compareId := fmt.Sprint(vv.Id)
|
|
|
if in.Id == "" && v.Name == "甲方" {
|
|
|
cccNodes := []*nodeTree{}
|
|
|
cccIndexMap := map[string]int{}
|
|
|
for _, vvv := range firstpartyChild[vv.CompanyId] {
|
|
|
+ if in.CheckCode != "" {
|
|
|
+ compareId = vvv.CompanyId
|
|
|
+ }
|
|
|
cccIndex, cccOk := cccIndexMap[vvv.Name]
|
|
|
if cccOk {
|
|
|
cccNodes[cccIndex].ID += "," + vvv.CompanyId
|
|
@@ -481,7 +500,7 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
|
|
|
cccNodes[cccIndex].TYPE += ",firstparty"
|
|
|
cccNodes[cccIndex].MYTYPE += ",firstparty"
|
|
|
} else {
|
|
|
- cccNodes = append(cccNodes, &nodeTree{
|
|
|
+ nt := &nodeTree{
|
|
|
NAME: vvv.Name,
|
|
|
ID: vvv.CompanyId,
|
|
|
SZ_PID0: v.Name,
|
|
@@ -494,8 +513,12 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
|
|
|
TYPE: "firstparty",
|
|
|
MYID: vvv.CompanyId,
|
|
|
MYTYPE: "firstparty",
|
|
|
- })
|
|
|
+ }
|
|
|
+ cccNodes = append(cccNodes, nt)
|
|
|
cccIndexMap[vvv.Name] = len(cccNodes) - 1
|
|
|
+ if !hasDefaultCheck || compareId == in.ClickId {
|
|
|
+ checkCode = append(checkCode, nt.CODE)
|
|
|
+ }
|
|
|
}
|
|
|
if id != "" {
|
|
|
id += ","
|
|
@@ -513,7 +536,7 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
|
|
|
myChildTypes += ","
|
|
|
}
|
|
|
myChildTypes += vv.Type
|
|
|
- *convList = append(*convList, &nodeTree{
|
|
|
+ nt := &nodeTree{
|
|
|
NAME: vvv.CompanyName,
|
|
|
ID: vvv.CompanyId,
|
|
|
SZ_PID0: v.Name,
|
|
@@ -527,7 +550,11 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
|
|
|
TYPE: "firstparty",
|
|
|
MYID: vvv.CompanyId,
|
|
|
MYTYPE: "firstparty",
|
|
|
- })
|
|
|
+ }
|
|
|
+ if !hasDefaultCheck || compareId == in.ClickId {
|
|
|
+ checkCode = append(checkCode, nt.CODE)
|
|
|
+ }
|
|
|
+ *convList = append(*convList, nt)
|
|
|
}
|
|
|
for _, cccNode := range cccNodes {
|
|
|
*convList = append(*convList, cccNode)
|
|
@@ -543,6 +570,18 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
|
|
|
pType += vv.Type
|
|
|
myChildIds = myId
|
|
|
myChildTypes = vv.Type
|
|
|
+ if in.CheckCode != "" {
|
|
|
+ if len(vv.IdNames) == 0 {
|
|
|
+ compareId = "-1"
|
|
|
+ }
|
|
|
+ for in_k, in_v := range vv.IdNames {
|
|
|
+ if in_v.Id == in.ClickId {
|
|
|
+ break
|
|
|
+ } else if in_k == len(vv.IdNames)-1 {
|
|
|
+ compareId = "-1"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
cm := &nodeTree{
|
|
|
NAME: vv.CompanyName,
|
|
@@ -558,6 +597,10 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
|
|
|
MYID: myId,
|
|
|
MYTYPE: vv.Type,
|
|
|
}
|
|
|
+ //如果甲方的子节点被选中了,父节点跟着被选中,非甲方的要对比子节点可介绍业主
|
|
|
+ if !hasDefaultCheck || childStartCheckCodeLen != len(checkCode) || (v.Name != "甲方" && compareId == fmt.Sprint(vv.Id)) {
|
|
|
+ checkCode = append(checkCode, cm.CODE)
|
|
|
+ }
|
|
|
*convList = append(*convList, cm)
|
|
|
}
|
|
|
pm.ID = id
|
|
@@ -565,13 +608,32 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
|
|
|
pm.MYTYPE = pMyType
|
|
|
pm.MYID = pMyId
|
|
|
*parentConvList = append(*parentConvList, pm)
|
|
|
+ if parentStartCheckCodeLen != len(checkCode) {
|
|
|
+ checkCode = append(checkCode, pm.CODE)
|
|
|
+ }
|
|
|
+ hasDefaultCheck = true
|
|
|
}
|
|
|
sort.Sort(convList)
|
|
|
*parentConvList = append(*parentConvList, *convList...)
|
|
|
+ var newCheckCode []string
|
|
|
+ if in.CheckCode != "" {
|
|
|
+ m := map[string]bool{}
|
|
|
+ for _, v := range strings.Split(in.CheckCode, ",") {
|
|
|
+ m[v] = true
|
|
|
+ }
|
|
|
+ for _, v := range checkCode {
|
|
|
+ if m[v] {
|
|
|
+ newCheckCode = append(newCheckCode, v)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ newCheckCode = checkCode
|
|
|
+ }
|
|
|
reply = &types.Reply{
|
|
|
Data: map[string]interface{}{
|
|
|
- "count": count,
|
|
|
- "list": parentConvList,
|
|
|
+ "count": count,
|
|
|
+ "list": parentConvList,
|
|
|
+ "checked": checkCode,
|
|
|
},
|
|
|
}
|
|
|
redis.Put("newother", key, reply, C.CacheTimeOut)
|