Browse Source

企业收录处理

WH01243 1 year ago
parent
commit
acc5d27f93
1 changed files with 21 additions and 12 deletions
  1. 21 12
      api/internal/service/employService.go

+ 21 - 12
api/internal/service/employService.go

@@ -64,14 +64,15 @@ func (e *EmPloyService) InfoEmployinfo(in *types.InfoEmployinfoReq) ([]map[strin
 		batchEmploy = gconv.Int64((*configData)["batch_employ"])
 	}
 	//版本查询
-	res := MC.Middleground.ResourceCenter.Haspowers(in.AccountId, in.EntAccountId, in.EntId, in.EntUserId)
+	/*res := MC.Middleground.ResourceCenter.Haspowers(in.AccountId, in.EntAccountId, in.EntId, in.EntUserId)
 	version := 0
 	for _, pCode := range res.Powers {
 		//0:通用版 1:物业专版
 		if pCode == "bi_yx_wyzb" {
 			version = 1
 		}
-	}
+	}*/
+	version := 1
 	infoId1Arr := []string{}
 	niJianIdArr := []string{}
 	infoId2Arr := []string{}
@@ -669,20 +670,24 @@ func employInfoPerson(table, employKey, findKey string, in *types.InfoEmployinfo
 	niJianData := &[]map[string]interface{}{}
 	wuyeData1 := &[]map[string]interface{}{}
 	wuyeData2 := &[]map[string]interface{}{}
+	orderKey := "type"
+	if employKey == "company_id" {
+		orderKey = "source"
+	}
 	if len(infoId1Arr) > 0 {
-		infoData1 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select   %s, is_ignore,status,id,type from  %s   where position_id =? and  %s in ('%s')    GROUP BY %s ,type  order  by type desc", employKey, table, employKey, strings.Join(infoId1Arr, "','"), employKey), in.PositionId)
+		infoData1 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select   %s, is_ignore,status,id,%s from  %s   where position_id =? and  %s in ('%s')    GROUP BY %s ,%s  order  by %s desc", employKey, orderKey, table, employKey, strings.Join(infoId1Arr, "','"), employKey, orderKey, orderKey), in.PositionId)
 	}
 	if len(infoId2Arr) > 0 {
-		infoData2 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select  %s,  is_ignore,status,id,type from  %s   where position_id =? and  %s in '%s')    GROUP BY %s ,type order  by type desc", employKey, table, employKey, strings.Join(infoId2Arr, "','"), employKey), in.PositionId)
+		infoData2 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select  %s,  is_ignore,status,id,%s from  %s   where position_id =? and  %s in ('%s')    GROUP BY %s ,%s order  by %s desc", employKey, orderKey, table, employKey, strings.Join(infoId2Arr, "','"), employKey, orderKey, orderKey), in.PositionId)
 	}
 	if len(niJianIdArr) > 0 {
-		niJianData = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s,   is_ignore,status,id,type from  %s   where position_id =? and  %s in ('%s')    GROUP BY %s  ,type order  by type desc", employKey, table, employKey, strings.Join(niJianIdArr, "','"), employKey), in.PositionId)
+		niJianData = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s,   is_ignore,status,id,%s from  %s   where position_id =? and  %s in ('%s')    GROUP BY %s  ,%s order  by %s desc", employKey, orderKey, table, employKey, strings.Join(niJianIdArr, "','"), employKey, orderKey, orderKey), in.PositionId)
 	}
 	if len(wuye1Arr) > 0 {
-		wuyeData1 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select  %s,  is_ignore,status,id,type from  %s   where position_id =? and  %s in ('%s')  GROUP BY %s  ,type order  by type desc", employKey, table, employKey, strings.Join(wuye1Arr, "','"), employKey), in.PositionId)
+		wuyeData1 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select  %s,  is_ignore,status,id,%s from  %s   where position_id =? and  %s in ('%s')  GROUP BY %s  ,%s order  by %s desc", employKey, orderKey, table, employKey, strings.Join(wuye1Arr, "','"), employKey, orderKey, orderKey), in.PositionId)
 	}
 	if len(wuye2Arr) > 0 {
-		wuyeData2 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select   %s, is_ignore,status,id,type from  %s   where position_id =? and  %s in ('%s')    GROUP BY %s ,type order  by type desc", employKey, table, employKey, strings.Join(wuye2Arr, "','"), employKey), in.PositionId)
+		wuyeData2 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select   %s, is_ignore,status,id,%s from  %s   where position_id =? and  %s in ('%s')    GROUP BY %s ,%s order  by %s desc", employKey, orderKey, table, employKey, strings.Join(wuye2Arr, "','"), employKey, orderKey, orderKey), in.PositionId)
 	}
 	for _, v := range *infoData1 {
 		valueMap := map[string]interface{}{
@@ -789,20 +794,24 @@ func employInfoEnt(table, employKey, findKey, depIDArr string, in *types.InfoEmp
 	niJianData := &[]map[string]interface{}{}
 	wuyeData1 := &[]map[string]interface{}{}
 	wuyeData2 := &[]map[string]interface{}{}
+	orderKey := "type"
+	if employKey == "company_id" {
+		orderKey = "source"
+	}
 	if len(infoId1Arr) > 0 {
-		infoData1 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select  %s,GROUP_CONCAT(id) as  employIdArr,MAX(is_ignore) as is_ignore,MAX(status) as status from  %s   where %s in ('%s') and  source=? and    ent_dept_id in  (%s) GROUP BY %s ,type order  by type", employKey, table, employKey, strings.Join(infoId1Arr, "','"), depIDArr, employKey), 1)
+		infoData1 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select  %s,GROUP_CONCAT(id) as  employIdArr,MAX(is_ignore) as is_ignore,MAX(status) as status from  %s   where %s in ('%s') and  source=? and    ent_dept_id in  (%s) GROUP BY %s ,%s order  by %s", employKey, table, employKey, strings.Join(infoId1Arr, "','"), depIDArr, employKey, orderKey, orderKey), 1)
 	}
 	if len(infoId2Arr) > 0 {
-		infoData2 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s, GROUP_CONCAT(id) as  employIdArr,MAX(is_ignore) as is_ignore,MAX(status) as status from  %s   where %s in ('%s') and  source=? and    ent_dept_id in  (%s)  GROUP BY %s ,type order  by type", employKey, table, employKey, strings.Join(infoId2Arr, "','"), depIDArr, employKey), 2)
+		infoData2 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s, GROUP_CONCAT(id) as  employIdArr,MAX(is_ignore) as is_ignore,MAX(status) as status from  %s   where %s in ('%s') and  source=? and    ent_dept_id in  (%s)  GROUP BY %s ,%s order  by %s", employKey, table, employKey, strings.Join(infoId2Arr, "','"), depIDArr, employKey, orderKey, orderKey), 2)
 	}
 	if len(niJianIdArr) > 0 {
-		niJianData = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s, GROUP_CONCAT(id) as  employIdArr,MAX(is_ignore) as is_ignore,MAX(status) as status from  %s   where %s  in ('%s') and  source=? and    ent_dept_id in  (%s) GROUP BY %s ,type order  by type", employKey, table, employKey, strings.Join(niJianIdArr, "','"), depIDArr, employKey), 2)
+		niJianData = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s, GROUP_CONCAT(id) as  employIdArr,MAX(is_ignore) as is_ignore,MAX(status) as status from  %s   where %s  in ('%s') and  source=? and    ent_dept_id in  (%s) GROUP BY %s ,%s order  by %s", employKey, table, employKey, strings.Join(niJianIdArr, "','"), depIDArr, employKey, orderKey, orderKey), 2)
 	}
 	if len(wuye1Arr) > 0 {
-		wuyeData1 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s,  id,is_ignore,status ,type  from  %s   where %s in ('%s')  and status =1 and  source=? and    ent_dept_id in  (%s)  GROUP BY %s  ,type order  by type", employKey, table, employKey, strings.Join(wuye1Arr, "','"), depIDArr, employKey), 1)
+		wuyeData1 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s,  id,is_ignore,status   from  %s   where %s in ('%s')  and status =1 and  source=? and    ent_dept_id in  (%s)  GROUP BY %s  ,%s order  by %s", employKey, table, employKey, strings.Join(wuye1Arr, "','"), depIDArr, employKey, orderKey, orderKey), 1)
 	}
 	if len(wuye2Arr) > 0 {
-		wuyeData2 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s, id,is_ignore,status ,type  from  %s   where %s  in ('%s')  and status =1 and  source=? and    ent_dept_id in  (%s) GROUP BY %s ,type order  by type", employKey, table, employKey, strings.Join(wuye2Arr, "','"), depIDArr, employKey), 2)
+		wuyeData2 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s, id,is_ignore,status   from  %s   where %s  in ('%s')  and status =1 and  source=? and    ent_dept_id in  (%s) GROUP BY %s ,%s order  by %s", employKey, table, employKey, strings.Join(wuye2Arr, "','"), depIDArr, employKey, orderKey, orderKey), 2)
 	}
 	for _, v := range *infoData1 {
 		valueMap := map[string]interface{}{