|
@@ -3,7 +3,7 @@
|
|
<html>
|
|
<html>
|
|
<head>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
- <title>service: Go Coverage Report</title>
|
|
|
|
|
|
+ <title>Go Coverage Report</title>
|
|
<style>
|
|
<style>
|
|
body {
|
|
body {
|
|
background: black;
|
|
background: black;
|
|
@@ -55,464 +55,27 @@
|
|
<div id="nav">
|
|
<div id="nav">
|
|
<select id="files">
|
|
<select id="files">
|
|
|
|
|
|
- <option value="file0">bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/AuthService.go (81.0%)</option>
|
|
|
|
-
|
|
|
|
- <option value="file1">bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/InstitutionService.go (100.0%)</option>
|
|
|
|
-
|
|
|
|
-<<<<<<< HEAD
|
|
|
|
- <option value="file2">bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/claim.go (27.6%)</option>
|
|
|
|
-
|
|
|
|
- <option value="file3">bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/portrait.go (88.1%)</option>
|
|
|
|
-=======
|
|
|
|
- <option value="file2">bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/claim.go (93.5%)</option>
|
|
|
|
->>>>>>> 10627a5dbc739e87e4aa15f75c91adb5de38af2d
|
|
|
|
-
|
|
|
|
</select>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div id="legend">
|
|
<div id="legend">
|
|
<span>not tracked</span>
|
|
<span>not tracked</span>
|
|
|
|
|
|
- <span class="cov0">not covered</span>
|
|
|
|
- <span class="cov8">covered</span>
|
|
|
|
|
|
+ <span class="cov0">no coverage</span>
|
|
|
|
+ <span class="cov1">low coverage</span>
|
|
|
|
+ <span class="cov2">*</span>
|
|
|
|
+ <span class="cov3">*</span>
|
|
|
|
+ <span class="cov4">*</span>
|
|
|
|
+ <span class="cov5">*</span>
|
|
|
|
+ <span class="cov6">*</span>
|
|
|
|
+ <span class="cov7">*</span>
|
|
|
|
+ <span class="cov8">*</span>
|
|
|
|
+ <span class="cov9">*</span>
|
|
|
|
+ <span class="cov10">high coverage</span>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div id="content">
|
|
<div id="content">
|
|
|
|
|
|
- <pre class="file" id="file0" style="display: none">package service
|
|
|
|
-
|
|
|
|
-import (
|
|
|
|
- "app.yhyue.com/moapp/jybase/go-xweb/log"
|
|
|
|
- "bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/entity"
|
|
|
|
- "bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/medical"
|
|
|
|
- "fmt"
|
|
|
|
- "time"
|
|
|
|
-)
|
|
|
|
-
|
|
|
|
-type AuthService struct{}
|
|
|
|
-
|
|
|
|
-//认证信息保存
|
|
|
|
-func (b AuthService) UserAuthInfoSave(in *medical.UserInfo) (bool, string) <span class="cov8" title="1">{
|
|
|
|
- //先判断用户是否存在
|
|
|
|
- user := entity.BaseMysql.FindOne(entity.DOMAIN_CAPITAL_RETENTION, map[string]interface{}{
|
|
|
|
- "user_id": in.UserId, "appid": in.Appid,
|
|
|
|
- }, "id", "")
|
|
|
|
- if user != nil </span><span class="cov8" title="1">{
|
|
|
|
- if in.OperationType == "add" </span><span class="cov8" title="1">{
|
|
|
|
- return false, "用户已验证"
|
|
|
|
- }</span>
|
|
|
|
- } else<span class="cov8" title="1"> {
|
|
|
|
- if in.OperationType == "update" </span><span class="cov8" title="1">{
|
|
|
|
- return false, "用户未认证,不可修改"
|
|
|
|
- }</span>
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- <span class="cov8" title="1">if in.OperationType == "update" </span><span class="cov8" title="1">{
|
|
|
|
- //修改处理
|
|
|
|
- data := map[string]interface{}{
|
|
|
|
- "name": in.Name,
|
|
|
|
- "phone": in.Phone,
|
|
|
|
- "position": in.Position,
|
|
|
|
- "department": in.Department,
|
|
|
|
- "mail": in.Mail,
|
|
|
|
- "ent_code": in.EntCode,
|
|
|
|
- "ent_name": in.EntName,
|
|
|
|
- }
|
|
|
|
- ok1 := entity.BaseMysql.Update(entity.DOMAIN_CAPITAL_RETENTION, map[string]interface{}{"user_id": in.UserId, "appid": in.Appid}, data)
|
|
|
|
-<<<<<<< HEAD
|
|
|
|
- if ok1 </span><span class="cov8" title="1">{
|
|
|
|
-=======
|
|
|
|
- if ok1 </span><span class="cov1" title="1">{
|
|
|
|
->>>>>>> 10627a5dbc739e87e4aa15f75c91adb5de38af2d
|
|
|
|
- return true, ""
|
|
|
|
- }</span> else<span class="cov0" title="0"> {
|
|
|
|
- log.Println(fmt.Sprintf("认证修改失败:入参:%v:%v,", in.UserId, data))
|
|
|
|
- return false, "修改失败"
|
|
|
|
- }</span>
|
|
|
|
- } else<span class="cov8" title="1"> {
|
|
|
|
- //新增处理
|
|
|
|
- data := map[string]interface{}{
|
|
|
|
- "name": in.Name,
|
|
|
|
- "phone": in.Phone,
|
|
|
|
- "position": in.Position,
|
|
|
|
- "department": in.Department,
|
|
|
|
- "mail": in.Mail,
|
|
|
|
- "ent_code": in.EntCode,
|
|
|
|
- "ent_name": in.EntName,
|
|
|
|
- "user_id": in.UserId,
|
|
|
|
- "create_time": time.Now().Local(),
|
|
|
|
- "appid": in.Appid,
|
|
|
|
- }
|
|
|
|
- ok := entity.BaseMysql.Insert(entity.DOMAIN_CAPITAL_RETENTION, data)
|
|
|
|
- if ok > 0 </span><span class="cov8" title="1">{
|
|
|
|
- return true, ""
|
|
|
|
- }</span> else<span class="cov0" title="0"> {
|
|
|
|
- log.Println(fmt.Sprintf("认证失败:参数:%v", data))
|
|
|
|
- return false, "认证失败"
|
|
|
|
- }</span>
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-//认证信息查询
|
|
|
|
-func (b AuthService) UserAuthInfo(in *medical.CommonReq) *map[string]interface{} <span class="cov8" title="1">{
|
|
|
|
- //先判断用户是否存在
|
|
|
|
- user := entity.BaseMysql.FindOne(entity.DOMAIN_CAPITAL_RETENTION, map[string]interface{}{
|
|
|
|
- "user_id": in.UserId, "appid": in.Appid,
|
|
|
|
- }, "id", "")
|
|
|
|
- return user
|
|
|
|
-}</span>
|
|
|
|
-</pre>
|
|
|
|
-
|
|
|
|
- <pre class="file" id="file1" style="display: none">package service
|
|
|
|
-
|
|
|
|
-import (
|
|
|
|
- "bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/entity"
|
|
|
|
-)
|
|
|
|
-
|
|
|
|
-type InstitutionService struct{}
|
|
|
|
-
|
|
|
|
-//医疗机构搜索条件
|
|
|
|
-func (b InstitutionService) GetFilterItem() (levelList, typeList *[]map[string]interface{}) <span class="cov8" title="1">{
|
|
|
|
- //机构类型
|
|
|
|
- levelList = entity.Mysql.Find(entity.CODE_MEDICAL_INSTITUTION_LEVEL, nil, "*", "", -1, -1)
|
|
|
|
- //医院等级
|
|
|
|
- typeList = entity.Mysql.Find(entity.CODE_MEDICAL_INSTITUTION_TYPE, nil, "*", "", -1, -1)
|
|
|
|
- return
|
|
|
|
-}</span>
|
|
|
|
-</pre>
|
|
|
|
-
|
|
|
|
- <pre class="file" id="file2" style="display: none">package service
|
|
|
|
-
|
|
|
|
-import (
|
|
|
|
- "app.yhyue.com/moapp/jybase/common"
|
|
|
|
- "app.yhyue.com/moapp/jybase/date"
|
|
|
|
- "bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/entity"
|
|
|
|
- "github.com/zeromicro/go-zero/core/logx"
|
|
|
|
-)
|
|
|
|
-
|
|
|
|
-// EntClaimService 企业认领
|
|
|
|
-type EntClaimService struct {
|
|
|
|
- *entity.Conn
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// NewEntClaimSrv 创建一个EntClaimSrv实例
|
|
|
|
-<<<<<<< HEAD
|
|
|
|
-func NewEntClaimSrv(conn *entity.Conn) *EntClaimService <span class="cov8" title="1">{
|
|
|
|
-=======
|
|
|
|
-func NewEntClaimSrv(conn *entity.Conn) *EntClaimService <span class="cov1" title="1">{
|
|
|
|
->>>>>>> 10627a5dbc739e87e4aa15f75c91adb5de38af2d
|
|
|
|
- return &EntClaimService{
|
|
|
|
- conn,
|
|
|
|
- }
|
|
|
|
-}</span>
|
|
|
|
-
|
|
|
|
-// Claim 认领
|
|
|
|
-<<<<<<< HEAD
|
|
|
|
-func (e *EntClaimService) Claim(data *entity.EntClaim) bool <span class="cov8" title="1">{
|
|
|
|
- return e.BaseMysql.Insert(entity.TableDomainEntClaim, common.StructToMapMore(data)) > 0
|
|
|
|
-}</span>
|
|
|
|
-
|
|
|
|
-// Unclaimed // 取消认领
|
|
|
|
-func (e *EntClaimService) Unclaimed(id, userId int) bool <span class="cov0" title="0">{
|
|
|
|
-=======
|
|
|
|
-func (e *EntClaimService) Claim(data *entity.EntClaim) bool <span class="cov6" title="2">{
|
|
|
|
- if e.IsClaimed(data.UserId, data.AppId, data.EntId, data.Type) </span><span class="cov0" title="0">{
|
|
|
|
- return true
|
|
|
|
- }</span>
|
|
|
|
- <span class="cov6" title="2">return e.BaseMysql.Insert(entity.TableDomainEntClaim, common.StructToMapMore(data)) > 0</span>
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Unclaimed // 取消认领
|
|
|
|
-func (e *EntClaimService) Unclaimed(id, userId int) bool <span class="cov10" title="3">{
|
|
|
|
->>>>>>> 10627a5dbc739e87e4aa15f75c91adb5de38af2d
|
|
|
|
- query := map[string]interface{}{
|
|
|
|
- "id": id,
|
|
|
|
- }
|
|
|
|
- // 1. 查询该条数据
|
|
|
|
- rs := e.BaseMysql.FindOne(entity.TableDomainEntClaim, query, "user_id", "")
|
|
|
|
-<<<<<<< HEAD
|
|
|
|
- if rs == nil || len(*rs) == 0 </span><span class="cov0" title="0">{
|
|
|
|
-=======
|
|
|
|
- if rs == nil || len(*rs) == 0 </span><span class="cov1" title="1">{
|
|
|
|
->>>>>>> 10627a5dbc739e87e4aa15f75c91adb5de38af2d
|
|
|
|
- logx.Errorf("取消认领:无效的id %v", id)
|
|
|
|
- return false
|
|
|
|
- }</span>
|
|
|
|
- // 2. 存在则判断是否是该用户的
|
|
|
|
-<<<<<<< HEAD
|
|
|
|
- <span class="cov0" title="0">rsUerId := common.IntAll((*rs)["user_id"])
|
|
|
|
- if rsUerId != userId </span><span class="cov0" title="0">{
|
|
|
|
-=======
|
|
|
|
- <span class="cov6" title="2">rsUerId := common.IntAll((*rs)["user_id"])
|
|
|
|
- if rsUerId != userId </span><span class="cov1" title="1">{
|
|
|
|
->>>>>>> 10627a5dbc739e87e4aa15f75c91adb5de38af2d
|
|
|
|
- logx.Errorf("取消认领:id[%v]与用户id[%v]不匹配 ", id, userId)
|
|
|
|
- return false
|
|
|
|
- }</span>
|
|
|
|
- // 3. 取消认领
|
|
|
|
-<<<<<<< HEAD
|
|
|
|
- <span class="cov0" title="0">update := map[string]interface{}{
|
|
|
|
-=======
|
|
|
|
- <span class="cov1" title="1">update := map[string]interface{}{
|
|
|
|
->>>>>>> 10627a5dbc739e87e4aa15f75c91adb5de38af2d
|
|
|
|
- "status": entity.StatusUnClaimed,
|
|
|
|
- "update_time": date.NowFormat(date.Date_Full_Layout),
|
|
|
|
- }
|
|
|
|
- return e.BaseMysql.Update(entity.TableDomainEntClaim, query, update)</span>
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// IsClaimed 是否认领
|
|
|
|
-<<<<<<< HEAD
|
|
|
|
-func (e *EntClaimService) IsClaimed(userId int, appId string, entId int, typeCode int) bool <span class="cov0" title="0">{
|
|
|
|
-=======
|
|
|
|
-func (e *EntClaimService) IsClaimed(userId int, appId string, entId string, typeCode int) bool <span class="cov10" title="3">{
|
|
|
|
->>>>>>> 10627a5dbc739e87e4aa15f75c91adb5de38af2d
|
|
|
|
- query := map[string]interface{}{
|
|
|
|
- "user_id": userId,
|
|
|
|
- "type": typeCode,
|
|
|
|
- "ent_id": entId,
|
|
|
|
- "status": entity.StatusClaimed,
|
|
|
|
- }
|
|
|
|
- return e.BaseMysql.Count(entity.TableDomainEntClaim, query) > 0
|
|
|
|
-}</span>
|
|
|
|
-
|
|
|
|
-// DistributorList 关注的经销商列表
|
|
|
|
-<<<<<<< HEAD
|
|
|
|
-func (e *EntClaimService) DistributorList(userId int, appId string, page int, pageSize int) (*[]map[string]interface{}, int) <span class="cov8" title="1">{
|
|
|
|
-=======
|
|
|
|
-func (e *EntClaimService) DistributorList(userId int, appId string, page int, pageSize int) (*[]map[string]interface{}, int) <span class="cov6" title="2">{
|
|
|
|
->>>>>>> 10627a5dbc739e87e4aa15f75c91adb5de38af2d
|
|
|
|
-
|
|
|
|
- query := map[string]interface{}{
|
|
|
|
- "user_id": userId,
|
|
|
|
- "appid": appId,
|
|
|
|
- "type": entity.TypeDistributor,
|
|
|
|
- "status": entity.StatusClaimed,
|
|
|
|
- }
|
|
|
|
- field := "id,appid,user_id,ent_id,ent_name,address,create_time"
|
|
|
|
- order := "create_time desc"
|
|
|
|
- total := e.BaseMysql.Count(entity.TableDomainEntClaim, query)
|
|
|
|
-<<<<<<< HEAD
|
|
|
|
- if total == 0 </span><span class="cov8" title="1">{
|
|
|
|
-=======
|
|
|
|
- if total == 0 </span><span class="cov6" title="2">{
|
|
|
|
->>>>>>> 10627a5dbc739e87e4aa15f75c91adb5de38af2d
|
|
|
|
- return nil, 0
|
|
|
|
- }</span>
|
|
|
|
- <span class="cov0" title="0">return e.BaseMysql.Find(entity.TableDomainEntClaim, query, field, order, (page-1)*pageSize, pageSize), int(total)</span>
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// InstitutionList 我关注的医疗机构列表
|
|
|
|
-<<<<<<< HEAD
|
|
|
|
-func (e *EntClaimService) InstitutionList(userId int, appId string, page int, pageSize int) (*[]map[string]interface{}, int) <span class="cov0" title="0">{
|
|
|
|
-=======
|
|
|
|
-func (e *EntClaimService) InstitutionList(userId int, appId string, page int, pageSize int) (*[]map[string]interface{}, int) <span class="cov6" title="2">{
|
|
|
|
->>>>>>> 10627a5dbc739e87e4aa15f75c91adb5de38af2d
|
|
|
|
- query := map[string]interface{}{
|
|
|
|
- "user_id": userId,
|
|
|
|
- "appid": appId,
|
|
|
|
- "type": entity.TypeInstitution,
|
|
|
|
- "status": entity.StatusClaimed,
|
|
|
|
- }
|
|
|
|
- field := "id,appid,user_id,ent_id,ent_name,address,create_time"
|
|
|
|
- order := "create_time desc"
|
|
|
|
- total := e.BaseMysql.Count(entity.TableDomainEntClaim, query)
|
|
|
|
-<<<<<<< HEAD
|
|
|
|
- if total == 0 </span><span class="cov0" title="0">{
|
|
|
|
- return nil, 0
|
|
|
|
- }</span>
|
|
|
|
- <span class="cov0" title="0">return e.BaseMysql.Find(entity.TableDomainEntClaim, query, field, order, (page-1)*pageSize, pageSize), int(total)</span>
|
|
|
|
-}
|
|
|
|
-</pre>
|
|
|
|
-
|
|
|
|
- <pre class="file" id="file3" style="display: none">// @Description 画像相关
|
|
|
|
-package service
|
|
|
|
-
|
|
|
|
-import (
|
|
|
|
- "errors"
|
|
|
|
- "fmt"
|
|
|
|
- "log"
|
|
|
|
- "regexp"
|
|
|
|
- "strings"
|
|
|
|
- "time"
|
|
|
|
-
|
|
|
|
- . "app.yhyue.com/moapp/jybase/common"
|
|
|
|
- "app.yhyue.com/moapp/jybase/encrypt"
|
|
|
|
- elastic "app.yhyue.com/moapp/jybase/esv1"
|
|
|
|
- "bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/entity"
|
|
|
|
-)
|
|
|
|
-
|
|
|
|
-//画像
|
|
|
|
-type PortraitService struct {
|
|
|
|
- *entity.Conn
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-var ClearHtml = regexp.MustCompile("<[^>]*>")
|
|
|
|
-
|
|
|
|
-// @description 生成结构体
|
|
|
|
-// @param conn 数据库实例
|
|
|
|
-// @return Portrait 画像实例
|
|
|
|
-func NewPortrait(conn *entity.Conn) *PortraitService <span class="cov8" title="1">{
|
|
|
|
- return &PortraitService{
|
|
|
|
- conn,
|
|
|
|
- }
|
|
|
|
-}</span>
|
|
|
|
-
|
|
|
|
-// @description 获取画像内容
|
|
|
|
-// @param companyId 机构id
|
|
|
|
-// @return PortraitInfo 画像信息
|
|
|
|
-// @return error 错误信息
|
|
|
|
-func (this *PortraitService) Info(companyId string) (*entity.PortraitInfo, error) <span class="cov8" title="1">{
|
|
|
|
- //判断是否存在companyid
|
|
|
|
- if companyId == "" </span><span class="cov8" title="1">{
|
|
|
|
- return nil, errors.New(entity.NO_DATA_ERROR_MSG)
|
|
|
|
- }</span>
|
|
|
|
- //获取信息
|
|
|
|
- <span class="cov8" title="1">data := this.Mysql.SelectBySql(fmt.Sprintf(`SELECT a.sdequipment_code,a.area_code,a.beds,a.visit_perday,a.doctorsnum,a.address,a.website,a.business_type,a.equipment, e.equipment sdleveltypeequip ,a.mi_name,a.establish_date,b.name LEVEL,c.name miType,d.class FROM %s a
|
|
|
|
- LEFT JOIN %s b ON a.level_code=b.code
|
|
|
|
- LEFT JOIN %s c ON c.code =a.mi_type_code
|
|
|
|
- LEFT JOIN (SELECT GROUP_CONCAT(DISTINCT departname_class1 SEPARATOR '、') class,company_id FROM %s WHERE company_id=?) AS d ON d.company_id =a.company_id
|
|
|
|
- left join %s e on e.code =a.sdequipment_code
|
|
|
|
- WHERE a.company_id=?`, entity.Institution_baseinfo, entity.Code_level, entity.Code_type, entity.Institution_department, entity.Code_sdleveltypeequip), companyId, companyId)
|
|
|
|
- if data == nil || len(*data) == 0 </span><span class="cov8" title="1">{
|
|
|
|
- return nil, errors.New(entity.NO_DATA_ERROR_MSG)
|
|
|
|
- }</span>
|
|
|
|
- //获取area_code 省份,城市,区县
|
|
|
|
- <span class="cov8" title="1">area, city, district := "", "", ""
|
|
|
|
- rdata := (*data)[0]
|
|
|
|
- adata := this.CommonMysql.SelectBySql(fmt.Sprintf(`select area,city,district from %s where code =? limit 1`, entity.Code_area), ObjToString(rdata["area_code"]))
|
|
|
|
- if adata != nil && len(*adata) > 0 </span><span class="cov8" title="1">{
|
|
|
|
- area = ObjToString((*adata)[0]["area"])
|
|
|
|
- city = ObjToString((*adata)[0]["city"])
|
|
|
|
- district = ObjToString((*adata)[0]["district"])
|
|
|
|
- }</span>
|
|
|
|
- //医疗设备如果基本信息表中没有,则根据sdequipment_code、code联合查询得到equipment
|
|
|
|
- <span class="cov8" title="1">equipment := ObjToString(rdata["equipment"])
|
|
|
|
- sdleveltypeequip := ObjToString(rdata["sdleveltypeequip"])
|
|
|
|
- if equipment == "" && sdleveltypeequip != "" </span><span class="cov8" title="1">{
|
|
|
|
- equipment = ObjToString(rdata["sdleveltypeequip"])
|
|
|
|
- }</span>
|
|
|
|
- //TODO 是否关注还没搞呢
|
|
|
|
- <span class="cov8" title="1">isFollow := 0
|
|
|
|
- portraitInfo := &entity.PortraitInfo{
|
|
|
|
- Beds: Int64All(rdata["beds"]),
|
|
|
|
- VisitPerday: Int64All(rdata["visit_perday"]), // 门诊量/日
|
|
|
|
- Doctorsnum: Int64All(rdata["doctorsnum"]), //医生人数
|
|
|
|
- Address: ObjToString(rdata["address"]), //医疗机构地址
|
|
|
|
- Website: ObjToString(rdata["website"]), //医疗机构网站
|
|
|
|
- Area: area, //省
|
|
|
|
- City: city, //市
|
|
|
|
- District: district, //区
|
|
|
|
- BusinessType: Int64All(rdata["business_type"]), //医疗机构经营方式(0:公立、1:民营、2:其它)
|
|
|
|
- Level: ObjToString(rdata["level"]), //医疗机构等级
|
|
|
|
- MiType: ObjToString(rdata["miType"]), //医疗机构类型
|
|
|
|
- Equipment: equipment, //医院设备
|
|
|
|
- Departnames: ObjToString(rdata["class"]), //医院科室
|
|
|
|
- Follow: int64(isFollow), //是否关注 0-未关注 1已关注
|
|
|
|
- CompanyName: ObjToString(rdata["mi_name"]), //医疗机构名称
|
|
|
|
- EstablishDate: ObjToString(rdata["establish_date"]), //成立日期
|
|
|
|
- }
|
|
|
|
- return portraitInfo, nil</span>
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// @description 获取医疗机构画像相关招标动态
|
|
|
|
-// @param companyId 机构id
|
|
|
|
-// @param pageSize 条数
|
|
|
|
-// @param pageNum 页码
|
|
|
|
-// @return GetNewMsgList 招标动态
|
|
|
|
-// @return count 招标数量
|
|
|
|
-// @return error 错误信息
|
|
|
|
-func (this *PortraitService) List(companyId string, pageSize, pageNum int64) (*[]*entity.GetNewMsgList, int64, error) <span class="cov8" title="1">{
|
|
|
|
- //判断是否存在companyid
|
|
|
|
- if companyId == "" </span><span class="cov0" title="0">{
|
|
|
|
- return nil, 0, errors.New(entity.NO_DATA_ERROR_MSG)
|
|
|
|
- }</span>
|
|
|
|
- <span class="cov8" title="1">var total int64
|
|
|
|
- mustQueryArr := this.CommonPare(companyId)
|
|
|
|
- log.Println("~~~~,", mustQueryArr)
|
|
|
|
- //仅第一页查询总量(非数据导出)
|
|
|
|
- if pageNum == 1 </span><span class="cov8" title="1">{
|
|
|
|
- total = elastic.Count(entity.BiddingIndex, entity.BiddingIndex, fmt.Sprintf(entity.NewMustSearch, strings.Join(mustQueryArr, ","), ""))
|
|
|
|
- if total <= 0 </span><span class="cov0" title="0">{
|
|
|
|
- return nil, 0, errors.New(entity.NO_DATA_ERROR_MSG)
|
|
|
|
- }</span>
|
|
|
|
- }
|
|
|
|
- <span class="cov8" title="1">start, limit := (pageNum-1)*pageSize, pageSize
|
|
|
|
- fields := `"title","area","subtype","_id","projectname","publishtime"`
|
|
|
|
- list := &[]*entity.GetNewMsgList{}
|
|
|
|
- //列表查询
|
|
|
|
- if total <= entity.DataExportBatchSearchLimit </span><span class="cov8" title="1">{
|
|
|
|
- listQuery := fmt.Sprintf(entity.NewMustSearch, strings.Join(mustQueryArr, ","), fmt.Sprintf(entity.ListSearchLimit, fields, "publishtime", start, limit))
|
|
|
|
- log.Printf("PortraitWinnerProject GetList Sql %s\n", listQuery)
|
|
|
|
- newData := elastic.Get(entity.BiddingIndex, entity.BiddingType, listQuery)
|
|
|
|
- if newData == nil || len(*newData) == 0 </span><span class="cov0" title="0">{
|
|
|
|
- return nil, 0, errors.New(entity.NO_DATA_ERROR_MSG)
|
|
|
|
- }</span>
|
|
|
|
- <span class="cov8" title="1">log.Println("newdata:", newData)
|
|
|
|
- for k, v := range *newData </span><span class="cov8" title="1">{
|
|
|
|
- if len(v) > 0 </span><span class="cov8" title="1">{
|
|
|
|
- if v["_id"] != nil </span><span class="cov8" title="1">{
|
|
|
|
- (*newData)[k]["id"] = encrypt.EncodeArticleId2ByCheck(v["_id"].(string))
|
|
|
|
- delete((*newData)[k], "_id") //删除未加密id
|
|
|
|
- }</span>
|
|
|
|
- <span class="cov8" title="1">title := ObjToString(ObjToString(v["title"]))
|
|
|
|
- if title == "" </span><span class="cov0" title="0">{
|
|
|
|
- title = ObjToString(v["projectname"])
|
|
|
|
- }</span>
|
|
|
|
- <span class="cov8" title="1">(*newData)[k]["title"] = ClearHtml.ReplaceAllString(title, "")</span>
|
|
|
|
- }
|
|
|
|
- <span class="cov8" title="1">*list = append(*list, &entity.GetNewMsgList{
|
|
|
|
- Area: ObjToString(v["area"]),
|
|
|
|
- Bidstatus: ObjToString(v["subtype"]), //信息类型
|
|
|
|
- Firsttime: Int64All(v["publishtime"]), //时间
|
|
|
|
- Id: ObjToString((*newData)[k]["id"]), //加密信息id
|
|
|
|
- Title: ObjToString((*newData)[k]["title"]), //标题
|
|
|
|
- })
|
|
|
|
- log.Println("~~list:", list)</span>
|
|
|
|
- }
|
|
|
|
- <span class="cov8" title="1">return list, total, nil</span>
|
|
|
|
- }
|
|
|
|
- <span class="cov0" title="0">return nil, 0, errors.New(entity.NO_DATA_ERROR_MSG)</span>
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-//医疗机构画像查询语句拼接
|
|
|
|
-func (this *PortraitService) CommonPare(companyId string) (mustQueryArr []string) <span class="cov8" title="1">{
|
|
|
|
- //按照当前年份,往前推4年,共5个年份可选
|
|
|
|
- sTime, eTime := this.PareTimeSelect() //采购单位不校验权限
|
|
|
|
-
|
|
|
|
- mustQueryArr = append(mustQueryArr, fmt.Sprintf(`{"term":{"buyer":"%s"}}`, companyId))
|
|
|
|
- mustQueryArr = append(mustQueryArr, fmt.Sprintf(`{"range":{"publishtime":{"gte":"%d","lte":"%d"}}}`, sTime.Unix(), eTime.Unix()))
|
|
|
|
-
|
|
|
|
- return
|
|
|
|
-}</span>
|
|
|
|
-
|
|
|
|
-//PareTimeSelect 格式筛选时间,默认2年
|
|
|
|
-func (this *PortraitService) PareTimeSelect() (st, et time.Time) <span class="cov8" title="1">{
|
|
|
|
- now := time.Now()
|
|
|
|
- sYear := now.Year() - 4
|
|
|
|
- eYear := now.Year()
|
|
|
|
- //返回默认时间
|
|
|
|
- sTimeStamp := time.Date(sYear, 1, 1, 0, 0, 0, 0, time.Local)
|
|
|
|
- eTimeStamp := time.Date(eYear+1, 1, 1, 0, 0, -1, 0, time.Local)
|
|
|
|
- if eYear == now.Year() </span><span class="cov8" title="1">{
|
|
|
|
- eTimeStamp = time.Date(eYear, now.Month(), now.Day(), now.Hour(), now.Minute(), 0, 0, time.Local)
|
|
|
|
- }</span>
|
|
|
|
- <span class="cov8" title="1">return sTimeStamp, eTimeStamp</span>
|
|
|
|
-}
|
|
|
|
-func EncodeId(sid string) string <span class="cov0" title="0">{
|
|
|
|
- if sid == "" || sid == "-" </span><span class="cov0" title="0">{ //不存在的id为-
|
|
|
|
- return ""
|
|
|
|
- }</span>
|
|
|
|
- <span class="cov0" title="0">return encrypt.EncodeArticleId2ByCheck(sid)</span>
|
|
|
|
-=======
|
|
|
|
- if total == 0 </span><span class="cov1" title="1">{
|
|
|
|
- return nil, 0
|
|
|
|
- }</span>
|
|
|
|
- <span class="cov1" title="1">return e.BaseMysql.Find(entity.TableDomainEntClaim, query, field, order, (page-1)*pageSize, pageSize), int(total)</span>
|
|
|
|
->>>>>>> 10627a5dbc739e87e4aa15f75c91adb5de38af2d
|
|
|
|
-}
|
|
|
|
-</pre>
|
|
|
|
-
|
|
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</body>
|
|
<script>
|
|
<script>
|