|
@@ -3,24 +3,28 @@ package service
|
|
import (
|
|
import (
|
|
quitl "app.yhyue.com/moapp/jybase/common"
|
|
quitl "app.yhyue.com/moapp/jybase/common"
|
|
elastic "app.yhyue.com/moapp/jybase/esv1"
|
|
elastic "app.yhyue.com/moapp/jybase/esv1"
|
|
|
|
+ "app.yhyue.com/moapp/jybase/mysql"
|
|
"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/entity"
|
|
"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/entity"
|
|
- IC "bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/init"
|
|
|
|
"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/medical"
|
|
"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/medical"
|
|
"fmt"
|
|
"fmt"
|
|
"log"
|
|
"log"
|
|
"strings"
|
|
"strings"
|
|
)
|
|
)
|
|
|
|
|
|
-type InstitutionService struct{}
|
|
|
|
|
|
+type InstitutionService struct {
|
|
|
|
+ Bidfield string
|
|
|
|
+ BasesqlCon *mysql.Mysql
|
|
|
|
+ MysqlConn *mysql.Mysql
|
|
|
|
+}
|
|
|
|
|
|
// GetFilterItem 医疗机构搜索条件
|
|
// GetFilterItem 医疗机构搜索条件
|
|
func (b InstitutionService) GetFilterItem() (levelList, typeList *[]map[string]interface{}) {
|
|
func (b InstitutionService) GetFilterItem() (levelList, typeList *[]map[string]interface{}) {
|
|
//机构类型
|
|
//机构类型
|
|
levelSql := fmt.Sprintf("select * from %s where name!='%s'", entity.CODE_MEDICAL_INSTITUTION_LEVEL, "其它")
|
|
levelSql := fmt.Sprintf("select * from %s where name!='%s'", entity.CODE_MEDICAL_INSTITUTION_LEVEL, "其它")
|
|
- levelList = entity.Mysql.SelectBySql(levelSql)
|
|
|
|
|
|
+ levelList = b.MysqlConn.SelectBySql(levelSql)
|
|
//医院等级
|
|
//医院等级
|
|
typeSql := fmt.Sprintf("select * from %s where name!='%s' and level=1", entity.CODE_MEDICAL_INSTITUTION_TYPE, "其它")
|
|
typeSql := fmt.Sprintf("select * from %s where name!='%s' and level=1", entity.CODE_MEDICAL_INSTITUTION_TYPE, "其它")
|
|
- typeList = entity.Mysql.SelectBySql(typeSql)
|
|
|
|
|
|
+ typeList = b.MysqlConn.SelectBySql(typeSql)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
@@ -97,7 +101,7 @@ func (b InstitutionService) Institution(in *medical.SearchInstitutionReq) (dataL
|
|
companyMap := make(map[string]map[string]interface{})
|
|
companyMap := make(map[string]map[string]interface{})
|
|
if len(*companyList) > 0 && companyList != nil {
|
|
if len(*companyList) > 0 && companyList != nil {
|
|
//认领数据查询
|
|
//认领数据查询
|
|
- companyIdMap := ClaimCompanyData(in.Appid, in.NewUserId, entity.TypeDistributor)
|
|
|
|
|
|
+ companyIdMap := b.ClaimCompanyData(in.Appid, in.NewUserId, entity.TypeDistributor)
|
|
for key, value := range *companyList {
|
|
for key, value := range *companyList {
|
|
if key > 0 {
|
|
if key > 0 {
|
|
companyName += `,`
|
|
companyName += `,`
|
|
@@ -122,7 +126,7 @@ func (b InstitutionService) Institution(in *medical.SearchInstitutionReq) (dataL
|
|
if in.Sort == 1 {
|
|
if in.Sort == 1 {
|
|
orderField = "count"
|
|
orderField = "count"
|
|
}
|
|
}
|
|
- aggStr := fmt.Sprintf(`{"query":{"bool":{"must":[{"terms":{"buyer":[%s]}},{"terms":{"bidstatus":["中标","成交","合同"]}},{"term":{"bid_field":"%s"}}],"minimum_should_match":0}},"aggs":{"group_field":{"terms":{"field":"buyer","order":[{"%s":"%s"}]},"aggs":{"count":{"sum":{"field":"bidamount"}}}}},"size":0}`, companyName, IC.C.Bidfield, orderField, orderType)
|
|
|
|
|
|
+ aggStr := fmt.Sprintf(`{"query":{"bool":{"must":[{"terms":{"buyer":[%s]}},{"terms":{"bidstatus":["中标","成交","合同"]}},{"term":{"bid_field":"%s"}}],"minimum_should_match":0}},"aggs":{"group_field":{"terms":{"field":"buyer","order":[{"%s":"%s"}]},"aggs":{"count":{"sum":{"field":"bidamount"}}}}},"size":0}`, companyName, b.Bidfield, orderField, orderType)
|
|
log.Println(aggStr)
|
|
log.Println(aggStr)
|
|
countList := entity.GetAggs(entity.PROJECTSET_INDEX, entity.PROJECTSET_TYPE, aggStr)
|
|
countList := entity.GetAggs(entity.PROJECTSET_INDEX, entity.PROJECTSET_TYPE, aggStr)
|
|
//
|
|
//
|
|
@@ -210,7 +214,7 @@ func (b InstitutionService) Distributor(in *medical.SearchDistributorReq) (dataL
|
|
companyMap := make(map[string]map[string]interface{})
|
|
companyMap := make(map[string]map[string]interface{})
|
|
if len(*companyList) > 0 && companyList != nil {
|
|
if len(*companyList) > 0 && companyList != nil {
|
|
//认领数据查询
|
|
//认领数据查询
|
|
- companyIdMap := ClaimCompanyData(in.Appid, in.NewUserId, entity.TypeDistributor)
|
|
|
|
|
|
+ companyIdMap := b.ClaimCompanyData(in.Appid, in.NewUserId, entity.TypeDistributor)
|
|
for key, value := range *companyList {
|
|
for key, value := range *companyList {
|
|
if key > 0 {
|
|
if key > 0 {
|
|
companyIds += `,`
|
|
companyIds += `,`
|
|
@@ -234,7 +238,7 @@ func (b InstitutionService) Distributor(in *medical.SearchDistributorReq) (dataL
|
|
if in.Sort == 1 {
|
|
if in.Sort == 1 {
|
|
orderField = "count"
|
|
orderField = "count"
|
|
}
|
|
}
|
|
- aggStr := fmt.Sprintf(`{"query":{"bool":{"must":[{"terms":{"entidlist":[%s]}},{"terms":{"bidstatus":["中标","成交","合同"]}},{"term":{"bid_field":"%s"}}],"minimum_should_match":0}},"aggs":{"group_field":{"terms":{"field":"entidlist","order":[{"%s":"%s"}]},"aggs":{"count":{"sum":{"field":"bidamount"}}}}},"size":0}`, companyIds, IC.C.Bidfield, orderField, orderType)
|
|
|
|
|
|
+ aggStr := fmt.Sprintf(`{"query":{"bool":{"must":[{"terms":{"entidlist":[%s]}},{"terms":{"bidstatus":["中标","成交","合同"]}},{"term":{"bid_field":"%s"}}],"minimum_should_match":0}},"aggs":{"group_field":{"terms":{"field":"entidlist","order":[{"%s":"%s"}]},"aggs":{"count":{"sum":{"field":"bidamount"}}}}},"size":0}`, companyIds, b.Bidfield, orderField, orderType)
|
|
log.Println(aggStr)
|
|
log.Println(aggStr)
|
|
countList := entity.GetAggs(entity.PROJECTSET_INDEX, entity.PROJECTSET_TYPE, aggStr)
|
|
countList := entity.GetAggs(entity.PROJECTSET_INDEX, entity.PROJECTSET_TYPE, aggStr)
|
|
if len(countList) > 0 && countList != nil {
|
|
if len(countList) > 0 && countList != nil {
|
|
@@ -259,8 +263,8 @@ func (b InstitutionService) Distributor(in *medical.SearchDistributorReq) (dataL
|
|
// @param appId 用户标识
|
|
// @param appId 用户标识
|
|
// @param newUserId 用户标识
|
|
// @param newUserId 用户标识
|
|
// @param claimType 数据类型
|
|
// @param claimType 数据类型
|
|
-func ClaimCompanyData(appId string, newUserId, claimType int64) map[string]map[string]interface{} {
|
|
|
|
- claimList := entity.BaseMysql.Find(entity.TableDomainEntClaim, map[string]interface{}{
|
|
|
|
|
|
+func (b InstitutionService) ClaimCompanyData(appId string, newUserId, claimType int64) map[string]map[string]interface{} {
|
|
|
|
+ claimList := b.MysqlConn.Find(entity.TableDomainEntClaim, map[string]interface{}{
|
|
"user_id": newUserId,
|
|
"user_id": newUserId,
|
|
"status": 1,
|
|
"status": 1,
|
|
"type": claimType,
|
|
"type": claimType,
|