|
@@ -8,6 +8,7 @@ import (
|
|
|
"sort"
|
|
|
"strings"
|
|
|
"sync"
|
|
|
+ "time"
|
|
|
|
|
|
. "app.yhyue.com/moapp/jybase/common"
|
|
|
. "app.yhyue.com/moapp/jybase/date"
|
|
@@ -30,11 +31,36 @@ type networkTree struct {
|
|
|
Children []*networkTreeChild `json:"children"`
|
|
|
}
|
|
|
type networkTreeChild struct {
|
|
|
- Count int64 `json:"count"`
|
|
|
- Name string `json:"name"`
|
|
|
- Id string `json:"id"`
|
|
|
- Type string `json:"type"`
|
|
|
+ Count int64 `json:"count"`
|
|
|
+ Name string `json:"name"`
|
|
|
+ Id string `json:"id"`
|
|
|
+ Type string `json:"type"`
|
|
|
+ CreateTime string `json:"createTime"`
|
|
|
}
|
|
|
+
|
|
|
+func (s *networkTree) Len() int {
|
|
|
+ return len(s.Children)
|
|
|
+}
|
|
|
+
|
|
|
+func (s *networkTree) Less(i, j int) bool {
|
|
|
+ if s.Name == "甲方" {
|
|
|
+ return s.Children[i].Name < s.Children[j].Name
|
|
|
+ }
|
|
|
+ it, err1 := time.ParseInLocation(Date_Full_Layout, s.Children[i].CreateTime, time.Local)
|
|
|
+ if err1 != nil {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ jt, err2 := time.ParseInLocation(Date_Full_Layout, s.Children[j].CreateTime, time.Local)
|
|
|
+ if err2 != nil {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ return it.Unix() < jt.Unix()
|
|
|
+}
|
|
|
+
|
|
|
+func (s *networkTree) Swap(i, j int) {
|
|
|
+ s.Children[i], s.Children[j] = s.Children[j], s.Children[i]
|
|
|
+}
|
|
|
+
|
|
|
type projectInfo struct {
|
|
|
BuyerCount int64
|
|
|
ProjectCount int64
|
|
@@ -268,7 +294,7 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- q := `SELECT a.company_id,a.company_name,a.itype,COUNT(b.id) AS ipc FROM crm.connection a
|
|
|
+ q := `SELECT a.company_id,a.company_name,a.itype,a.create_time,COUNT(b.id) AS ipc FROM crm.connection a
|
|
|
LEFT JOIN crm.connection_introduce b ON (b.position_id=? AND b.itype=2 AND a.id=b.connection_id) WHERE a.position_id=?`
|
|
|
args := []interface{}{in.PositionId, in.PositionId}
|
|
|
if in.Name != "" {
|
|
@@ -317,9 +343,10 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
|
|
|
company_name = "未填写"
|
|
|
}
|
|
|
ntc := &networkTreeChild{
|
|
|
- Name: company_name,
|
|
|
- Id: ObjToString(v["company_id"]),
|
|
|
- Type: n.TypeIntConvert(Int64All(v["itype"])),
|
|
|
+ Name: company_name,
|
|
|
+ Id: ObjToString(v["company_id"]),
|
|
|
+ Type: n.TypeIntConvert(Int64All(v["itype"])),
|
|
|
+ CreateTime: ObjToString(v["create_time"]),
|
|
|
}
|
|
|
if wh != "" {
|
|
|
thisArgs := []interface{}{ntc.Id}
|
|
@@ -359,6 +386,7 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
|
|
|
}
|
|
|
ID := ""
|
|
|
pType := ""
|
|
|
+ sort.Sort(v)
|
|
|
for _, vv := range v.Children {
|
|
|
if ID != "" {
|
|
|
ID += ","
|
|
@@ -371,6 +399,7 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
|
|
|
cm := map[string]interface{}{
|
|
|
"NAME": v.Name,
|
|
|
"ID": vv.Id,
|
|
|
+ "SZ_PID0": v.Name,
|
|
|
"SZ_PID1": v.Name + ":" + vv.Id,
|
|
|
"CODE": v.Name + ":" + vv.Id,
|
|
|
"PCODE": v.Name,
|
|
@@ -648,7 +677,7 @@ func (n *network) FirstpartyNetwork(name string, values []string) map[string][]*
|
|
|
q += ` where c.company_name like ?`
|
|
|
args = append(args, "%"+name+"%")
|
|
|
}
|
|
|
- q += ` order by a.a_id,b.name,a.b_name`
|
|
|
+ q += ` order by b.name,a.a_id,a.b_name`
|
|
|
rows, err := ClickhouseConn.Query(context.Background(), q, args...)
|
|
|
if err != nil {
|
|
|
logx.Error(err)
|