feat:完善项目信息

This commit is contained in:
henry
2022-01-04 15:37:00 +08:00
parent 40841a4a27
commit d2b182952c
8 changed files with 343 additions and 26 deletions

View File

@ -1,8 +1,8 @@
package manage
import (
"SciencesServer/app/api/website/controller/technology"
"SciencesServer/app/api/website/model"
"SciencesServer/app/api/enterprise/controller/technology"
"SciencesServer/app/api/enterprise/model"
"SciencesServer/app/basic/controller"
model2 "SciencesServer/app/common/model"
"errors"
@ -13,7 +13,7 @@ import (
type (
// AchievementInfo 成果信息
AchievementInfo struct {
*model.TechnologyAchievementInfo
*model.TechnologyAchievementsInfo
ChargeInfo *model2.TechnologyAchievementChargeInfo `json:"charge_info"`
}
// ProjectInfo 项目信息
@ -24,7 +24,7 @@ type (
// PatentInfo 专利信息
PatentInfo struct {
ID string `json:"id"`
*model.PatentInfo
*model.PatentInstance
}
// PaperInfo 论文信息
PaperInfo struct {
@ -41,9 +41,9 @@ type (
}
// CooperateDetailInfo 合作的企业详细信息
CooperateDetailInfo struct {
Title string `json:"title"`
Patent []*technology.PatentInfo `json:"patent"`
Paper []*technology.PaperInfo `json:"paper"`
Title string `json:"title"`
Patent []*technology.PatentInstance `json:"patent"`
Paper []*technology.PaperInstance `json:"paper"`
}
EquipmentInfo struct {
ID string `json:"id"`
@ -57,7 +57,7 @@ func achievement(uids []uint64, page, pageSize int) (*controller.ReturnPages, er
var count int64
out, err := mTechnologyAchievement.Achievement(page, pageSize, &count, model2.NewWhereIn("uid", uids))
out, err := mTechnologyAchievement.Achievements(page, pageSize, &count, model2.NewWhereIn("uid", uids))
if err != nil {
return nil, err
@ -66,8 +66,8 @@ func achievement(uids []uint64, page, pageSize int) (*controller.ReturnPages, er
for _, v := range out {
list = append(list, &AchievementInfo{
TechnologyAchievementInfo: v,
ChargeInfo: v.GetChargeInfoAttribute(),
TechnologyAchievementsInfo: v,
ChargeInfo: v.GetChargeInfoAttribute(),
})
}
return &controller.ReturnPages{Data: list, Count: count}, nil
@ -105,7 +105,7 @@ func patent(uids []uint64, page, pageSize int) (*controller.ReturnPages, error)
mUserPatent := model.NewUserPatent()
var count int64
out, err := mUserPatent.Patent(page, pageSize, &count, model2.NewWhereIn("u_p.uid", uids))
out, err := mUserPatent.Instance(page, pageSize, &count, model2.NewWhereIn("u_p.uid", uids))
if err != nil {
return nil, err
@ -114,8 +114,7 @@ func patent(uids []uint64, page, pageSize int) (*controller.ReturnPages, error)
for _, v := range out {
list = append(list, &PatentInfo{
ID: v.GetEncodeID(),
PatentInfo: v,
ID: v.GetEncodeID(), PatentInstance: v,
})
}
return &controller.ReturnPages{Data: list, Count: count}, nil
@ -190,8 +189,8 @@ func cooperateDetail(id uint64) (*CooperateDetailInfo, error) {
}
out := &CooperateDetailInfo{
Title: mUserCooperateEnterprise.Title,
Patent: make([]*technology.PatentInfo, 0),
Paper: make([]*technology.PaperInfo, 0),
Patent: make([]*technology.PatentInstance, 0),
Paper: make([]*technology.PaperInstance, 0),
}
// 专利信息
mSysPatent := model.NewSysPatent()
@ -202,7 +201,7 @@ func cooperateDetail(id uint64) (*CooperateDetailInfo, error) {
return nil, err
}
for _, v := range patents {
out.Patent = append(out.Patent, &technology.PatentInfo{
out.Patent = append(out.Patent, &technology.PatentInstance{
ID: v.GetEncodeID(),
SysPatentInfo: v,
})
@ -220,7 +219,7 @@ func cooperateDetail(id uint64) (*CooperateDetailInfo, error) {
return nil, err
}
for _, v := range papers {
out.Paper = append(out.Paper, &technology.PaperInfo{
out.Paper = append(out.Paper, &technology.PaperInstance{
ID: v.GetEncodeID(), Title: v.Title, Ext: v.Ext, Keywords: v.GetKeywordAttribute(),
})
}

View File

@ -1,8 +1,13 @@
package manage
import (
"SciencesServer/app/api/enterprise/model"
"SciencesServer/app/basic/config"
"SciencesServer/app/basic/controller"
model2 "SciencesServer/app/common/model"
"SciencesServer/app/service"
"SciencesServer/app/session"
"strings"
)
type Laboratory struct {
@ -12,6 +17,29 @@ type Laboratory struct {
type LaboratoryHandle func(session *session.Enterprise, local string) *Laboratory
type (
// LaboratoryMatchInfo 实验室匹配信息
LaboratoryMatchInfo struct {
ID string `json:"id"`
*model.ManageLaboratoryInstance
Industrys []string `json:"industrys"`
Keywords []string `json:"keywords"`
Researchs []string `json:"researchs"`
}
)
// expert 所有专家信息
func (c *Laboratory) expert(id uint64) ([]uint64, error) {
mManageExpert := model.NewManageExpert()
uids := make([]uint64, 0)
err := model2.Pluck(mManageExpert.ManageExpert, "uid", &uids, model2.NewWhere("laboratory_id", id),
model2.NewWhere("examine_status", model2.ExamineStatusForAgree))
return uids, err
}
func (c *Laboratory) Instance() (*controller.ReturnPages, error) {
//mManageLaboratory := model.NewManageLaboratory()
@ -22,6 +50,149 @@ func (c *Laboratory) Instance() (*controller.ReturnPages, error) {
return nil, nil
}
// Match 匹配信息
func (c *Laboratory) Match(title string, industrys, keywords []string) ([]*LaboratoryMatchInfo, error) {
params := strings.Join([]string{
title, strings.Join(industrys, ","), strings.Join(keywords, ","),
}, ",")
manage := service.NewESManage(
service.WithManageIdentity(config.TenantUserIdentityForLaboratory),
)
out, err := manage.Search(0, 0, map[string]interface{}{
"title": params, "industry": params, "keyword": params, "research": params,
})
if err != nil {
return nil, err
}
ids := make([]uint64, 0)
for _, v := range out.([]interface{}) {
val := v.(*service.ESManage)
ids = append(ids, val.ID)
}
mManageLaboratory := model.NewManageLaboratory()
laboratorys := make([]*model.ManageLaboratoryInstance, 0)
if laboratorys, err = mManageLaboratory.Instance(model2.NewWhereIn("l.id", ids)); err != nil {
return nil, err
}
list := make([]*LaboratoryMatchInfo, 0)
for _, v := range laboratorys {
list = append(list, &LaboratoryMatchInfo{
ID: v.GetEncodeID(),
ManageLaboratoryInstance: v,
Industrys: v.GetIndustryAttribute(),
Keywords: v.GetKeywordAttribute(),
Researchs: v.GetResearchAttribute(),
})
}
return list, nil
}
// Instance 实验室信息
func (c *Laboratory) Detail(id uint64) (*LaboratoryMatchInfo, error) {
mManageLaboratory := model.NewManageLaboratory()
out, err := mManageLaboratory.Instance(model2.NewWhere("l.id", id))
if err != nil {
return nil, err
}
if len(out) <= 0 {
return nil, nil
}
_out := out[0]
return &LaboratoryMatchInfo{
ID: _out.GetEncodeID(),
ManageLaboratoryInstance: &model.ManageLaboratoryInstance{
ManageLaboratory: _out.ManageLaboratory,
ResearchName: _out.ResearchName,
ExpertCount: _out.ExpertCount,
CollectCount: _out.CollectCount,
VisitCount: _out.VisitCount,
},
Industrys: _out.GetIndustryAttribute(),
Keywords: _out.GetKeywordAttribute(),
Researchs: _out.GetResearchAttribute(),
}, nil
}
// Achievement 成果信息
func (c *Laboratory) Achievement(id uint64, page, pageSize int) (*controller.ReturnPages, error) {
uids, err := c.expert(id)
if err != nil {
return nil, err
}
return achievement(uids, page, pageSize)
}
// Project 项目信息
func (c *Laboratory) Project(id uint64, page, pageSize int) (*controller.ReturnPages, error) {
// 查询专家身份下用户信息
uids, err := c.expert(id)
if err != nil {
return nil, err
}
return project(uids, page, pageSize)
}
// Patent 专利信息
func (c *Laboratory) Patent(id uint64, page, pageSize int) (*controller.ReturnPages, error) {
// 查询专家身份下用户信息
uids, err := c.expert(id)
if err != nil {
return nil, err
}
return paper(uids, page, pageSize)
}
// Paper 论文信息
func (c *Laboratory) Paper(id uint64, page, pageSize int) (*controller.ReturnPages, error) {
// 查询专家身份下用户信息
uids, err := c.expert(id)
if err != nil {
return nil, err
}
return paper(uids, page, pageSize)
}
// Cooperate 企业信息
func (c *Laboratory) Cooperate(id uint64, page, pageSize int) (*controller.ReturnPages, error) {
// 查询专家身份下用户信息
uids, err := c.expert(id)
if err != nil {
return nil, err
}
return cooperate(uids, page, pageSize)
}
// CooperateDetail 公司企业详细信息
func (c *Laboratory) CooperateDetail(id uint64) (*CooperateDetailInfo, error) {
return cooperateDetail(id)
}
// Equipment 设备信息
func (c *Laboratory) Equipment(id uint64, page, pageSize int) (*controller.ReturnPages, error) {
// 查询专家身份下用户信息
uids, err := c.expert(id)
if err != nil {
return nil, err
}
return equipment(model2.ManageEquipmentKindForExperiment, uids, page, pageSize)
}
func NewLaboratory() LaboratoryHandle {
return func(session *session.Enterprise, local string) *Laboratory {
return &Laboratory{

View File

@ -24,6 +24,12 @@ type (
*model2.TechnologyPaper
Tags []string `json:"tags"`
}
PaperInstance struct {
ID string `json:"id"`
Title string `json:"title"`
Ext string `json:"ext"`
Keywords []string `json:"keywords"`
}
PaperParams struct {
ID uint64
Title, Ext, Author, PublishAt, Remark string

View File

@ -37,6 +37,11 @@ type (
Description string `json:"description"`
ApplyAt string `json:"apply_at"`
}
// PatentInstance 专利信息
PatentInstance struct {
ID string `json:"id"`
*model.SysPatentInfo
}
// PatentDetailInfo 专利详细信息
PatentDetailInfo struct {
ID string `json:"id"`

View File

@ -11,15 +11,52 @@ type ManageLaboratory struct {
*model.ManageLaboratory
}
type ManageLaboratoryInfo struct {
model.Model
Name string `json:"name"`
Industry string `json:"-"`
Username string `json:"username"`
Mobile string `json:"mobile"`
VisitCount int `json:"visit_count"`
CollectCount int `json:"collect_count"`
SettledAt time.Time `json:"settled_at"`
type (
ManageLaboratoryInfo struct {
model.Model
Name string `json:"name"`
Industry string `json:"-"`
Username string `json:"username"`
Mobile string `json:"mobile"`
VisitCount int `json:"visit_count"`
CollectCount int `json:"collect_count"`
SettledAt time.Time `json:"settled_at"`
}
// ManageLaboratoryInstance 实验室信息
ManageLaboratoryInstance struct {
*model.ManageLaboratory
ResearchName string `json:"research_name"`
ExpertCount int `json:"expert_count"`
CollectCount int `json:"collect_count"`
VisitCount int `json:"visit_count"`
}
)
// Instance 实验室信息
func (m *ManageLaboratory) Instance(where ...*model.ModelWhere) ([]*ManageLaboratoryInstance, error) {
db := orm.GetDB().Table(m.TableName()+" AS l").
Select("l.id", "l.image", "l.url", "l.industry", "l.keyword", "l.contact", "l.contact_mobile", "l.research",
"e.name AS research_name", "e.count AS expert_count", "c.count AS collect_count", "v.count AS visit_count").
Joins(fmt.Sprintf("LEFT JOIN %s AS e ON l.research_id = e.id", model.NewManageResearch().TableName())).
Joins(fmt.Sprintf("LEFT JOIN (SELECT laboratory_id, COUNT(laboratory_id) AS count FROM %s WHERE examine_status = %d AND is_deleted = %d GROUP BY laboratory_id) AS e ON l.id = e.laboratory_id",
model.NewManageExpert().TableName(), model.ExamineStatusForAgree, model.DeleteStatusForNot)).
Joins(fmt.Sprintf("LEFT JOIN (SELECT object_id, COUNT(id) AS count FROM %s WHERE kind = %d AND is_deleted = %d GROUP BY object_id) AS c ON l.id = c.object_id",
model.NewUserCollect().TableName(), model.UserCollectKindForLaboratory, model.DeleteStatusForNot)).
Joins(fmt.Sprintf("LEFT JOIN (SELECT object_id, SUM(count) AS count FROM %s WHERE kind = %d AND is_deleted = %d GROUP BY object_id) AS v ON l.id = v.object_id",
model.NewUserVisit().TableName(), model.UserVisitKindForLaboratory, model.DeleteStatusForNot)).
Where("l.examine_status = ?", model.ExamineStatusForAgree).
Where("l.is_deleted = ?", model.DeleteStatusForNot)
if len(where) > 0 {
for _, wo := range where {
db = db.Where(wo.Condition, wo.Value)
}
}
out := make([]*ManageLaboratoryInstance, 0)
err := db.Scan(&out).Error
return out, err
}
// Laboratory 实验室信息

View File

@ -11,6 +11,36 @@ type SysPatent struct {
*model.SysPatent
}
type SysPatentInfo struct {
model.Model
Kind model.SysParentKind `json:"kind"`
Title string `json:"title"`
Description string `json:"description"`
ApplyAt string `json:"apply_at"`
}
// Instance 专利信息
func (m *SysPatent) Instance(where ...*model.ModelWhere) ([]*SysPatentInfo, error) {
db := orm.GetDB().Table(m.TableName()+" AS p").
Select("p.id", "p.title", "LEFT(p.description, 80) AS description", "p.apply_at").
Joins(fmt.Sprintf("LEFT JOIN %s AS c ON p.ipc_code = c.ipc AND c.is_deleted = %d",
model.NewSysPatentClassify().TableName(), model.DeleteStatusForNot)).
Where("p.shelf_status = ?", model.ShelfStatusForUp).
Where("p.is_deleted = ?", model.DeleteStatusForNot)
if len(where) > 0 {
for _, v := range where {
db = db.Where(v.Condition, v.Value)
}
}
out := make([]*SysPatentInfo, 0)
if err := db.Scan(&out).Error; err != nil {
return nil, err
}
return out, nil
}
func (m *SysPatent) IsExistParams(params map[string]interface{}) (bool, error) {
var count int64
db := orm.GetDB().Table(m.TableName())

View File

@ -30,6 +30,41 @@ type TechnologyAchievementInstance struct {
CollectCount int `json:"collect_count"`
}
// TechnologyAchievementsInfo 技术成果信息
type TechnologyAchievementsInfo struct {
*model.TechnologyAchievement
VisitCount int `json:"visit_count"`
CollectCount int `json:"collect_count"`
}
// Achievements 成果信息
func (m *TechnologyAchievement) Achievements(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*TechnologyAchievementsInfo, error) {
db := orm.GetDB().Table(m.TableName()+" AS a").
Select("a.id", "a.title", "a.mode", "a.image", "a.charge_info", "a.industry", "a.customer", "a.maturity",
"a.cooperation_mode", "a.keyword", "v.count AS visit_count", "c.count AS collect_count").
Joins(fmt.Sprintf("LEFT JOIN (SELECT object_id, SUM(count) AS count FROM %s WHERE kind = %d AND is_deleted = %d GROUP BY object_id) AS v ON a.id = v.object_id",
model.NewUserVisit().TableName(), model.UserCollectKindForTechnologyAchievement, model.DeleteStatusForNot)).
Joins(fmt.Sprintf("LEFT JOIN (SELECT object_id, COUNT(id) AS count FROM %s WHERE kind = %d AND is_deleted = %d GROUP BY object_id) AS c ON a.id = c.object_id",
model.NewUserCollect().TableName(), model.UserCollectKindForTechnologyAchievement, model.DeleteStatusForNot)).
Where("a.status = ?", model.TechnologyAchievementStatusForAgree).
Where("a.is_deleted = ?", model.DeleteStatusForNot)
if len(where) > 0 {
for _, v := range where {
db = db.Where(v.Condition, v.Value)
}
}
out := make([]*TechnologyAchievementsInfo, 0)
if err := db.Count(count).Error; err != nil {
return nil, err
}
if err := db.Order("a.id " + model.OrderModeToDesc).Offset((page - 1) * pageSize).Limit(pageSize).Scan(&out).Error; err != nil {
return nil, err
}
return out, nil
}
// Instance 成果信息
func (m *TechnologyAchievement) Instance(where ...*model.ModelWhere) ([]*TechnologyAchievementInstance, error) {
db := orm.GetDB().Table(m.TableName()+" AS a").

View File

@ -10,6 +10,40 @@ type UserPatent struct {
*model.UserPatent
}
type (
// PatentInstance 专利信息
PatentInstance struct {
model.Model
Title string `json:"title"`
ApplyAt string `json:"apply_at"`
}
)
// Patent 专利信息
func (m *UserPatent) Instance(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*PatentInstance, error) {
db := orm.GetDB().Table(m.TableName()+" AS u_p").
Select("p.id", "p.title", "p.apply_at", "p.description").
Joins(fmt.Sprintf("LEFT JOIN %s AS p ON u_p.patent_id = p.id",
model.NewSysPatent().TableName())).
Where("u_p.is_deleted = ?", model.DeleteStatusForNot).
Where("p.shelf_status = ?", model.ShelfStatusForUp)
if len(where) > 0 {
for _, wo := range where {
db = db.Where(wo.Condition, wo.Value)
}
}
out := make([]*PatentInstance, 0)
if err := db.Count(count).Error; err != nil {
return nil, err
}
if err := db.Order("p.id " + model.OrderModeToDesc).Offset((page - 1) * pageSize).Limit(pageSize).Scan(&out).Error; err != nil {
return nil, err
}
return out, nil
}
// Patents 专利信息
func (m *UserPatent) Patents(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*model.SysPatent, error) {
db := orm.GetDB().Table(m.TableName()+" AS u").