Ver código fonte

是否收录查询

WH01243 1 ano atrás
pai
commit
6847e5ac84

+ 2 - 0
api/application.api

@@ -66,6 +66,7 @@ type (
 		IsEmploy   bool   `json:"isEmploy"`   //是否收录true收录 false取消收录
 		EmployType int64  `json:"employType"` //来源方式来源;1招标采购、2企业、3采购单位、4拟在建项目
 		EntDeptId  int64  `header:"entDeptId,optional"`
+		From       string `json:"form,optional"` //来源
 	}
 
 	TransferReq {
@@ -102,6 +103,7 @@ type (
 		PositionType int64  `header:"positionType,optional"` //职位类型 0个人 1企业
 		AccountId    int64  `header:"accountId,optional"`    //账户id
 		EntAccountId int64  `header:"entAccountId,optional"` //企业账户id
+		From         string `json:"form,optional"`           //来源
 	}
 
 	CustomAddReq {

+ 6 - 3
api/common/initconfig.go

@@ -1,6 +1,7 @@
 package common
 
 import (
+	"app.yhyue.com/moapp/jypkg/middleground"
 	"flag"
 	"log"
 
@@ -27,7 +28,6 @@ var logc entity.Logc
 var dbFile = flag.String("df", "etc/db.yaml", "the db file")
 var DB config.Db
 
-//
 var pushFile = flag.String("pf", "etc/push.yaml", "the push file")
 var Push config.Push
 
@@ -42,8 +42,9 @@ var (
 	FileCenterRpc     filecenter.FileCenter
 	BaseCenterRpc     basecenter.BaseCenter
 	SocialPlatformRpc social.Social
-	MgoProject    mongodb.MongodbSim
-	NiJian        *mysql.Mysql
+	MgoProject        mongodb.MongodbSim
+	NiJian            *mysql.Mysql
+	Middleground      *middleground.Middleground
 )
 
 func init() {
@@ -166,5 +167,7 @@ func init() {
 	FileCenterRpc = filecenter.NewFileCenter(zrpc.MustNewClient(C.FileCenterRpc))
 	BaseCenterRpc = basecenter.NewBaseCenter(zrpc.MustNewClient(C.BaseCenterRpc))
 	SocialPlatformRpc = social.NewSocial(zrpc.MustNewClient(C.SocialPlatformRpc))
+	Middleground = middleground.NewMiddleground(C.BaseCenterRpc.Etcd.Hosts).
+		RegResourceCenter(C.ResourceCenterKey)
 	conf.MustLoad(*pushFile, &Push)
 }

+ 2 - 1
api/etc/crmapplication.yaml

@@ -1,6 +1,6 @@
 Name: crmApplication
 Host: 0.0.0.0
-Port: 8888
+Port: 8887
 Timeout: 20000
 Gateway:
   ServerCode: crmApplication
@@ -29,3 +29,4 @@ SocialPlatformRpc:
     Hosts:
     - 192.168.3.206:2379
     Key: social.rpc
+ResourceCenterKey: resource.rpc

+ 1 - 0
api/internal/config/config.go

@@ -19,6 +19,7 @@ type Config struct {
 	BaseCenterRpc     zrpc.RpcClientConf
 	NextFollowUpTime  int
 	SocialPlatformRpc zrpc.RpcClientConf
+	ResourceCenterKey string
 }
 
 type Db struct {

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

@@ -63,18 +63,27 @@ func (e *EmPloyService) InfoEmployinfo(in *types.InfoEmployinfoReq) ([]map[strin
 	if configData != nil {
 		batchEmploy = gconv.Int64((*configData)["batch_employ"])
 	}
+	//版本查询
+	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
+		}
+	}
 	for _, v := range strings.Split(in.IdArr, ",") {
 		id := ""
 		id = idFormat(v, in.EmployType)
-		table, findKey, employKey, source, projectId, isNiJian := employKeyFormat(in.EmployType, id)
+		table, findKey, employKey, source, projectId, isNiJian, subtype := employKeyFormat(in.EmployType, id)
 		if id == "" {
 			log.Println(v, in.EmployType, "该信息查询不到数据")
 			continue
 		}
 		if in.EntNicheDis > 0 {
-			data = append(data, employInfoEnt(v, table, id, employKey, findKey, depIDArr, source, in, projectId, isNiJian))
+			data = append(data, employInfoEnt(v, table, id, employKey, findKey, depIDArr, source, in, projectId, isNiJian, version, subtype))
 		} else {
-			data = append(data, employInfoPerson(v, table, id, employKey, findKey, source, in, projectId, isNiJian))
+			data = append(data, employInfoPerson(v, table, id, employKey, findKey, source, in, projectId, isNiJian, version, subtype))
 		}
 	}
 	return data, batchEmploy
@@ -94,7 +103,7 @@ func (e *EmPloyService) EmployOperate(in *types.EmployOperateReq) (bool, string)
 			findMap := map[string]interface{}{}
 			findMap["position_id"] = in.PositionId
 			id = idFormat(v1, in.EmployType)
-			table, _, employKey, source, projectId, isNijian := employKeyFormat(in.EmployType, id)
+			table, _, employKey, source, projectId, isNijian, _ := employKeyFormat(in.EmployType, id)
 			findMap["source"] = source
 			if isNijian {
 				findMap[employKey] = projectId
@@ -137,6 +146,9 @@ func (e *EmPloyService) EmployOperate(in *types.EmployOperateReq) (bool, string)
 				fool = true
 			} else {
 				//取消收录
+				if in.From == "jhfp" {
+					findMap["type"] = 3
+				}
 				if MC.CrmMysql.Count(table, findMap) > 0 {
 					ok := MC.CrmMysql.UpdateByTx(tx, table, findMap, map[string]interface{}{
 						"status": -1,
@@ -235,14 +247,12 @@ func infoFind(id string, v1 string) map[string]interface{} {
 				data["type"] = 1
 			}
 		}
-
 		if obj["projectinfo"] != nil {
 			projectinfo := common.ObjToMap(obj["projectinfo"])
 			if (*projectinfo)["attachments"] != nil {
 				data["annex"] = 1
 			}
 		}
-
 		data["publishtime"] = pushTime
 		data["show_time"] = pushTime
 		data["projectname"] = obj["projectname"]
@@ -295,13 +305,14 @@ func idFormat(encryptionId string, employType int64) string {
 }
 
 // employKeyFormat 根据收录类型 字段处理 table,findKey,employKey,source
-func employKeyFormat(employType int64, id string) (string, string, string, int64, string, bool) {
+func employKeyFormat(employType int64, id string) (string, string, string, int64, string, bool, string) {
 	table := ""
 	employKey := "company_id"
 	findKey := "employ_custom_id"
 	projectId := ""
 	source := int64(0)
 	IsNiJian := false
+	subtype := ""
 	switch employType {
 	case 1:
 		table = entity.EMPLOY_INFO
@@ -320,7 +331,7 @@ func employKeyFormat(employType int64, id string) (string, string, string, int64
 			obj = *aobj
 		}
 		if ok && obj != nil && len(obj) > 0 {
-			subtype := common.InterfaceToStr(obj["subtype"])
+			subtype = common.InterfaceToStr(obj["subtype"])
 			if subtype == "拟建" {
 				project, _ := MC.MgoProject.FindOne("projectset_proposed", map[string]interface{}{
 					"ids": id,
@@ -344,7 +355,7 @@ func employKeyFormat(employType int64, id string) (string, string, string, int64
 		employKey = "source_id"
 		findKey = "employ_info_id"
 	}
-	return table, findKey, employKey, source, projectId, IsNiJian
+	return table, findKey, employKey, source, projectId, IsNiJian, subtype
 
 }
 
@@ -570,7 +581,7 @@ func niJianHandle(infoId string, data map[string]interface{}, v1, pushTime strin
 }
 
 // 个人收录情况查询
-func employInfoPerson(v, table, id, employKey, findKey string, source int64, in *types.InfoEmployinfoReq, projectId string, isNiJian bool) map[string]interface{} {
+func employInfoPerson(v, table, id, employKey, findKey string, source int64, in *types.InfoEmployinfoReq, projectId string, isNiJian bool, version int, subtype string) map[string]interface{} {
 	valueMap := map[string]interface{}{
 		"id": v,
 	}
@@ -580,27 +591,60 @@ func employInfoPerson(v, table, id, employKey, findKey string, source int64, in
 	} else {
 		sourceId = id
 	}
-	employData := &map[string]interface{}{}
+
+	employData := &[]map[string]interface{}{}
 	if in.EmployType == 1 {
-		employData = MC.CrmMysql.FindOne(table, map[string]interface{}{
+		employData = MC.CrmMysql.Find(table, map[string]interface{}{
 			employKey:     sourceId,
 			"position_id": in.PositionId,
 			"source":      source,
-		}, "is_ignore,status,id,type", "")
+		}, "is_ignore,status,id,type", "id", -1, -1)
 	} else {
-		employData = MC.CrmMysql.FindOne(table, map[string]interface{}{
+		employData = MC.CrmMysql.Find(table, map[string]interface{}{
 			employKey:     sourceId,
 			"position_id": in.PositionId,
 			"source":      source,
-		}, "is_ignore,status,id", "")
+		}, "is_ignore,status,id", "id", -1, -1)
 	}
 	employId := int64(0)
 	if employData != nil && len(*employData) > 0 {
-		valueMap["isIgnore"] = common.If(common.Int64All((*employData)["is_ignore"]) == 1, true, false)
-		valueMap["isEmploy"] = common.If(common.Int64All((*employData)["status"]) == 1, true, false)
-		valueMap["type"] = common.Int64All((*employData)["type"])
-		employId = common.Int64All((*employData)["id"])
-		valueMap["employId"] = employId
+		if (subtype == "成交" || subtype == "中标" || subtype == "合同" || subtype == "验收" || subtype == "违规") && in.EmployType == 1 {
+			employ2 := false
+			employ3 := false
+			employIgnore := false
+			employType := int64(0)
+			for _, v1 := range *employData {
+				employType := common.Int64All(v1["type"])
+				employStatus := common.Int64All(v1["status"])
+				is_ignore := common.Int64All(v1["is_ignore"])
+				switch employType {
+				case 2:
+					if employStatus == 1 {
+						employ2 = true
+					}
+				case 3:
+					if employStatus == 1 {
+						employ3 = true
+					}
+				}
+				if is_ignore > 0 {
+					employIgnore = true
+				}
+				employType = common.Int64All(v1["type"])
+				employId = common.Int64All(v1["id"])
+			}
+			valueMap["isIgnore"] = employIgnore
+			valueMap["isEmploy"] = common.If(employ2 && employ3, true, false)
+			valueMap["type"] = employType
+			valueMap["employId"] = employId
+		} else {
+			valueMap["isIgnore"] = common.If(common.Int64All((*employData)[0]["is_ignore"]) == 1, true, false)
+			valueMap["isEmploy"] = common.If(common.Int64All((*employData)[0]["status"]) == 1, true, false)
+			valueMap["type"] = common.Int64All((*employData)[0]["type"])
+			employId = common.Int64All((*employData)[0]["id"])
+			valueMap["employId"] = employId
+		}
+
 	} else {
 		valueMap["isIgnore"] = false
 		valueMap["isEmploy"] = false
@@ -639,7 +683,7 @@ func employInfoPerson(v, table, id, employKey, findKey string, source int64, in
 }
 
 // 企业收录情况查询
-func employInfoEnt(v, table, id, employKey, findKey, depIDArr string, source int64, in *types.InfoEmployinfoReq, projectId string, isNiJian bool) map[string]interface{} {
+func employInfoEnt(v, table, id, employKey, findKey, depIDArr string, source int64, in *types.InfoEmployinfoReq, projectId string, isNiJian bool, version int, subtype string) map[string]interface{} {
 	valueMap := map[string]interface{}{
 		"id":          v,
 		"isIgnore":    false,
@@ -657,17 +701,54 @@ func employInfoEnt(v, table, id, employKey, findKey, depIDArr string, source int
 	}
 	employData := &[]map[string]interface{}{}
 	if in.EmployType == 1 {
-		employData = MC.CrmMysql.SelectBySql(fmt.Sprintf("select  GROUP_CONCAT(id) as  employIdArr,MAX(is_ignore) as is_ignore,MAX(status) as status,MAX(type) as  type from  %s   where %s=? and  source=? and    ent_dept_id in  (%s) ", table, employKey, depIDArr), sourceId, source)
+		if (subtype == "成交" || subtype == "中标" || subtype == "合同" || subtype == "验收" || subtype == "违规") && in.EmployType == 1 {
+			//物业版本查询
+			employData = MC.CrmMysql.SelectBySql(fmt.Sprintf("select  id,is_ignore,status ,type  from  %s   where %s=?  and status =1 and  source=? and    ent_dept_id in  (%s) ", table, employKey, depIDArr), sourceId, source)
+		} else {
+			employData = MC.CrmMysql.SelectBySql(fmt.Sprintf("select  GROUP_CONCAT(id) as  employIdArr,MAX(is_ignore) as is_ignore,MAX(status) as status,MAX(type) as  type from  %s   where %s=? and  source=? and    ent_dept_id in  (%s) ", table, employKey, depIDArr), sourceId, source)
+		}
 	} else {
 		employData = MC.CrmMysql.SelectBySql(fmt.Sprintf("select  GROUP_CONCAT(id) as  employIdArr,MAX(is_ignore) as is_ignore,MAX(status) as status from  %s   where %s=? and  source=? and    ent_dept_id in  (%s) ", table, employKey, depIDArr), sourceId, source)
 	}
 	employArrStr := ""
 	if employData != nil && len(*employData) > 0 {
-		valueMap["isIgnore"] = common.If(common.Int64All((*employData)[0]["is_ignore"]) == 1, true, false)
-		valueMap["isEmploy"] = common.If(common.Int64All((*employData)[0]["status"]) == 1, true, false)
-		valueMap["type"] = common.Int64All((*employData)[0]["type"])
-		employArrStr = common.InterfaceToStr((*employData)[0]["employIdArr"])
-		valueMap["employId"] = strings.Split(employArrStr, ",")[0]
+		if (subtype == "成交" || subtype == "中标" || subtype == "合同" || subtype == "验收" || subtype == "违规") && in.EmployType == 1 {
+			employ2 := false
+			employ3 := false
+			employIgnore := false
+			employType := int64(0)
+			employId := int64(0)
+			for _, v1 := range *employData {
+				employType := common.Int64All(v1["type"])
+				employStatus := common.Int64All(v1["status"])
+				is_ignore := common.Int64All(v1["is_ignore"])
+				switch employType {
+				case 2:
+					if employStatus == 1 {
+						employ2 = true
+					}
+				case 3:
+					if employStatus == 1 {
+						employ3 = true
+					}
+				}
+				if is_ignore > 0 {
+					employIgnore = true
+				}
+				employType = common.Int64All(v1["type"])
+				employId = common.Int64All(v1["id"])
+			}
+			valueMap["isIgnore"] = employIgnore
+			valueMap["isEmploy"] = common.If(employ2 && employ3, true, false)
+			valueMap["type"] = employType
+			valueMap["employId"] = employId
+		} else {
+			valueMap["isIgnore"] = common.If(common.Int64All((*employData)[0]["is_ignore"]) == 1, true, false)
+			valueMap["isEmploy"] = common.If(common.Int64All((*employData)[0]["status"]) == 1, true, false)
+			valueMap["type"] = common.Int64All((*employData)[0]["type"])
+			employArrStr = common.InterfaceToStr((*employData)[0]["employIdArr"])
+			valueMap["employId"] = strings.Split(employArrStr, ",")[0]
+		}
 	} else {
 		valueMap["isIgnore"] = false
 		valueMap["isIgnore"] = false

+ 2 - 0
api/internal/types/types.go

@@ -67,6 +67,7 @@ type EmployOperateReq struct {
 	IsEmploy   bool   `json:"isEmploy"`   //是否收录true收录 false取消收录
 	EmployType int64  `json:"employType"` //来源方式来源;1招标采购、2企业、3采购单位、4拟在建项目
 	EntDeptId  int64  `header:"entDeptId,optional"`
+	From       string `json:"form,optional"` //来源
 }
 
 type TransferReq struct {
@@ -103,6 +104,7 @@ type InfoEmployinfoReq struct {
 	PositionType int64  `header:"positionType,optional"` //职位类型 0个人 1企业
 	AccountId    int64  `header:"accountId,optional"`    //账户id
 	EntAccountId int64  `header:"entAccountId,optional"` //企业账户id
+	From         string `json:"form,optional"`           //来源
 }
 
 type CustomAddReq struct {