Parcourir la source

代码格式化

WH01243 il y a 1 an
Parent
commit
2326f4c2f5
1 fichiers modifiés avec 27 ajouts et 23 suppressions
  1. 27 23
      api/internal/service/employService.go

+ 27 - 23
api/internal/service/employService.go

@@ -27,9 +27,9 @@ const (
 
 type EmPloyService struct{}
 
-// 收录情况查询
+// InfoEmployinfo 收录情况查询
 func (e *EmPloyService) InfoEmployinfo(in *types.InfoEmployinfoReq) []map[string]interface{} {
-	data := []map[string]interface{}{}
+	var data []map[string]interface{}
 	for _, v := range strings.Split(in.IdArr, ",") {
 		table, findKey, employKey, source := EmployKeyFormat(in.EmployType)
 		id := ""
@@ -93,7 +93,7 @@ func (e *EmPloyService) InfoEmployinfo(in *types.InfoEmployinfoReq) []map[string
 	return data
 }
 
-// 收录操作
+// EmployOperate 收录操作
 func (e *EmPloyService) EmployOperate(in *types.EmployOperateReq) bool {
 	//收录汇总表
 	table, _, employKey, source := EmployKeyFormat(in.EmployType)
@@ -161,7 +161,7 @@ func (e *EmPloyService) EmployOperate(in *types.EmployOperateReq) bool {
 	})
 }
 
-// 企业信息查询
+// CustomFind 企业信息查询
 func CustomFind(id string, employType int64) map[string]interface{} {
 	data := map[string]interface{}{}
 	//company_id 企业id name户名称 address 地址
@@ -190,7 +190,7 @@ func CustomFind(id string, employType int64) map[string]interface{} {
 	return data
 }
 
-// 标讯信息查询
+// InfoFind 标讯信息查询
 func InfoFind(id string, employType int64) map[string]interface{} {
 	data := map[string]interface{}{}
 	//source_id  信息id、项目id- title 标题-area 省 -city 市 -subtype 信息类型二级分类
@@ -255,9 +255,9 @@ func InfoFind(id string, employType int64) map[string]interface{} {
 	return data
 }
 
-// 通过采购单位名称获取id
-func getBuyerIdByName(buyeName string) (buyerId string) {
-	r := elastic.Get(BuyerIndex, BuyerType, fmt.Sprintf(`{"query":{"bool":{"must":[{"term":{"buyer_name":"%s"}}]}},"size":1,"_source":["city","id"]}`, buyeName))
+// GetBuyerIdByName 通过采购单位名称获取id
+func GetBuyerIdByName(buyerName string) (buyerId string) {
+	r := elastic.Get(BuyerIndex, BuyerType, fmt.Sprintf(`{"query":{"bool":{"must":[{"term":{"buyer_name":"%s"}}]}},"size":1,"_source":["city","id"]}`, buyerName))
 	if r == nil || len(*r) == 0 {
 		return
 	}
@@ -265,7 +265,7 @@ func getBuyerIdByName(buyeName string) (buyerId string) {
 	return
 }
 
-// id解密
+// IdFormat id解密
 func IdFormat(encryptionId string, employType int64) string {
 	decryptId := ""
 	switch employType {
@@ -278,19 +278,22 @@ func IdFormat(encryptionId string, employType int64) string {
 			decryptId = util.DecodeId(encryptionId)
 		} else {
 			//次数据传的名字
-			decryptId = getBuyerIdByName(encryptionId)
+			decryptId = GetBuyerIdByName(encryptionId)
 		}
 	}
 	return decryptId
 }
 
-// 汇总表处理
+// SummaryFormat 汇总表处理
 func SummaryFormat(positionId int64) map[int64]*roaring.Bitmap {
-	byte1 := []byte{}
-	byte2 := []byte{}
-	byte3 := []byte{}
-	byte4 := []byte{}
-	MC.CrmMysql.DB.QueryRow("select   search_tencent, search_buyer, search_ent, search_nzj from employ_summary where  position_id=?", positionId).Scan(&byte1, &byte3, &byte2, &byte4)
+	var byte1 []byte
+	var byte2 []byte
+	var byte3 []byte
+	var byte4 []byte
+	err := MC.CrmMysql.DB.QueryRow("select   search_tencent, search_buyer, search_ent, search_nzj from employ_summary where  position_id=?", positionId).Scan(&byte1, &byte3, &byte2, &byte4)
+	if err != nil {
+		return nil
+	}
 	rb1 := roaring.NewBitmap()
 	rb2 := roaring.NewBitmap()
 	rb3 := roaring.NewBitmap()
@@ -315,7 +318,7 @@ func SummaryFormat(positionId int64) map[int64]*roaring.Bitmap {
 	return data
 }
 
-// 汇总表保存
+// SummarySave 汇总表保存
 func SummarySave(tx *sql.Tx, positionId int64, data map[int64]*roaring.Bitmap) bool {
 	employSummaryData := MC.CrmMysql.FindOne(entity.EMPLOY_SUMMARY, map[string]interface{}{
 		"position_id": positionId,
@@ -344,7 +347,7 @@ func SummarySave(tx *sql.Tx, positionId int64, data map[int64]*roaring.Bitmap) b
 	}
 }
 
-// 根据收录类型 字段处理 table,findKey,employKey,source
+// EmployKeyFormat 根据收录类型 字段处理 table,findKey,employKey,source
 func EmployKeyFormat(employType int64) (string, string, string, int64) {
 	table := ""
 	employKey := "company_id"
@@ -372,7 +375,7 @@ func EmployKeyFormat(employType int64) (string, string, string, int64) {
 
 }
 
-// 忽略操作
+// IgnoreOperate 忽略操作
 func (e *EmPloyService) IgnoreOperate(in *types.IgnoreOperateReq) {
 	//
 	table := ""
@@ -417,7 +420,7 @@ type PersonSmmary struct {
 	Summary   map[int64]*roaring.Bitmap
 }
 
-// 分发操作
+// DistributePerson 分发操作
 func (e *EmPloyService) DistributePerson(in *types.EmployDistributeReq) bool {
 	return MC.CrmMysql.ExecTx("收录操作", func(tx *sql.Tx) bool {
 		personMap := map[int64]PersonSmmary{}
@@ -447,7 +450,7 @@ func (e *EmPloyService) DistributePerson(in *types.EmployDistributeReq) bool {
 						(*infoData)["is_create_chance"] = 0
 						(*infoData)["is_create_custom"] = 0
 						(*infoData)["create_time"] = time.Now().Format(date.Date_Full_Layout)
-						delete((*infoData), "id")
+						delete(*infoData, "id")
 					} else {
 						log.Println(v, "查询不到改收录信息")
 						break
@@ -461,7 +464,7 @@ func (e *EmPloyService) DistributePerson(in *types.EmployDistributeReq) bool {
 						})
 					}
 					infoMap[v] = *infoData
-					VMap = (*infoData)
+					VMap = *infoData
 				} else {
 					VMap = infoMap[v]
 				}
@@ -483,6 +486,7 @@ func (e *EmPloyService) DistributePerson(in *types.EmployDistributeReq) bool {
 						fool = true
 					}*/
 				}
+				return true
 				/*if fool {
 					if !SummarySave(tx, positionId, personSmmary.Summary) {
 						return false
@@ -495,7 +499,7 @@ func (e *EmPloyService) DistributePerson(in *types.EmployDistributeReq) bool {
 }
 
 // 提取字符串中的数字
-func extractNumbers(str string) int64 {
+func ExtractNumbers(str string) int64 {
 	re := regexp.MustCompile(`\d+`)
 	matches := re.FindAllString(str, -1)
 	numbers := make([]int, len(matches))