|
@@ -94,8 +94,7 @@ func (this *ReportController) IndustryList() {
|
|
|
return
|
|
|
}
|
|
|
uid := user.UserId
|
|
|
- var orderSrt string
|
|
|
- var condition string
|
|
|
+
|
|
|
ChartPermissionId, _ := this.GetInt("ChartPermissionId")
|
|
|
orderColumn := this.GetString("OrderColumn")
|
|
|
isNewLabel := this.GetString("IsNewLabel")
|
|
@@ -103,7 +102,10 @@ func (this *ReportController) IndustryList() {
|
|
|
keyWord := this.GetString("KeyWord")
|
|
|
pageSize, _ := this.GetInt("PageSize")
|
|
|
currentIndex, _ := this.GetInt("CurrentIndex")
|
|
|
+ var orderSrt string
|
|
|
+ var condition string
|
|
|
var startSize int
|
|
|
+ resp := new(models.IndustrialManagementList)
|
|
|
if pageSize <= 0 {
|
|
|
pageSize = utils.PageSize20
|
|
|
}
|
|
@@ -111,7 +113,6 @@ func (this *ReportController) IndustryList() {
|
|
|
currentIndex = 1
|
|
|
}
|
|
|
startSize = paging.StartIndex(currentIndex, pageSize)
|
|
|
-
|
|
|
if isNewLabel != "" {
|
|
|
condition += ` AND is_new_label = ` + isNewLabel
|
|
|
}
|
|
@@ -125,25 +126,48 @@ func (this *ReportController) IndustryList() {
|
|
|
br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
+ var conditionkeyWord string
|
|
|
+ conditionkeyWord += ` subject_names LIKE '%` + keyWord + `%'`
|
|
|
keyWordArr = services.RemoveDuplicatesAndEmpty(keyWordArr)
|
|
|
keyWordLen := len(keyWordArr)
|
|
|
if keyWordLen <= 0 {
|
|
|
keyWordArr = append(keyWordArr, keyWord)
|
|
|
keyWordLen = len(keyWordArr)
|
|
|
}
|
|
|
-
|
|
|
+ for _, v := range keyWordArr {
|
|
|
+ conditionkeyWord += ` OR subject_names LIKE '%` + v + `%'`
|
|
|
+ }
|
|
|
+ industrialManagementIds, err := models.GetIndustrialManagementIdsBykeyWord(conditionkeyWord)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if industrialManagementIds == "" {
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "获取成功"
|
|
|
+ br.Data = resp
|
|
|
+ return
|
|
|
+ }
|
|
|
+ condition += ` AND man.industrial_management_id IN (` + industrialManagementIds + `)`
|
|
|
}
|
|
|
- resp := new(models.IndustrialManagementList)
|
|
|
+ var sqlChartPermissionId string
|
|
|
+ if ChartPermissionId > 0 {
|
|
|
+ sqlChartPermissionId += ` AND man_g.industrial_management_id IN ( SELECT industrial_management_id FROM cygx_industrial_management WHERE chart_permission_id = ` + strconv.Itoa(ChartPermissionId) + ` ) `
|
|
|
+ condition += ` AND man.chart_permission_id IN (` + strconv.Itoa(ChartPermissionId) + `)`
|
|
|
+ }
|
|
|
+
|
|
|
var total int
|
|
|
var list []*models.IndustrialManagement
|
|
|
- totalTopList, errTop := models.GetIndustrialManagemenCountTop(ChartPermissionId, uid, condition)
|
|
|
+ totalTopList, errTop := models.GetIndustrialManagemenCountTop(sqlChartPermissionId, uid, condition)
|
|
|
totalTop := len(totalTopList)
|
|
|
if errTop != nil {
|
|
|
br.Msg = "获取信息失败"
|
|
|
br.ErrMsg = "获取品种信息失败,Err:" + errTop.Error()
|
|
|
return
|
|
|
}
|
|
|
- totalNoTopList, errNoTop := models.GetIndustrialManagemenCountNoTop(ChartPermissionId, uid, condition)
|
|
|
+ totalNoTopList, errNoTop := models.GetIndustrialManagemenCountNoTop(sqlChartPermissionId, uid, condition)
|
|
|
totalNoTop := len(totalNoTopList)
|
|
|
if errNoTop != nil {
|
|
|
br.Msg = "获取信息失败"
|
|
@@ -155,10 +179,10 @@ func (this *ReportController) IndustryList() {
|
|
|
if orderColumn == "" {
|
|
|
orderColumn = "NewTime"
|
|
|
}
|
|
|
- if ChartPermissionId < 1 {
|
|
|
- br.Msg = "请输入分类ID"
|
|
|
- return
|
|
|
- }
|
|
|
+ //if ChartPermissionId < 1 {
|
|
|
+ // br.Msg = "请输入分类ID"
|
|
|
+ // return
|
|
|
+ //}
|
|
|
if orderColumn == "NewTime" {
|
|
|
orderSrt = "update_time DESC"
|
|
|
} else {
|
|
@@ -167,7 +191,7 @@ func (this *ReportController) IndustryList() {
|
|
|
fmt.Println(orderSrt)
|
|
|
//全部都是置顶
|
|
|
if totalTop >= currentIndex*pageSize {
|
|
|
- listTop, err := models.GetIndustrialManagementTopAll(ChartPermissionId, uid, condition, startSize, pageSize)
|
|
|
+ listTop, err := models.GetIndustrialManagementTopAll(uid, condition, startSize, pageSize)
|
|
|
for k, _ := range listTop {
|
|
|
listTop[k].IsTop = true
|
|
|
}
|
|
@@ -178,7 +202,7 @@ func (this *ReportController) IndustryList() {
|
|
|
}
|
|
|
list = listTop
|
|
|
} else if totalTop < (currentIndex-1)*pageSize { //全部都是不置顶
|
|
|
- listNoTop, err := models.GetIndustrialManagementAll(ChartPermissionId, uid, condition, orderSrt, startSize-totalTop, pageSize)
|
|
|
+ listNoTop, err := models.GetIndustrialManagementAll(uid, condition, orderSrt, startSize-totalTop, pageSize)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取信息失败"
|
|
|
br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
|
|
@@ -186,7 +210,7 @@ func (this *ReportController) IndustryList() {
|
|
|
}
|
|
|
list = listNoTop
|
|
|
} else { //部分置顶,部分不置顶
|
|
|
- listTop, err := models.GetIndustrialManagementTopAll(ChartPermissionId, uid, condition, startSize, pageSize)
|
|
|
+ listTop, err := models.GetIndustrialManagementTopAll(uid, condition, startSize, pageSize)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取信息失败"
|
|
|
br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
|
|
@@ -195,7 +219,7 @@ func (this *ReportController) IndustryList() {
|
|
|
for k, _ := range listTop {
|
|
|
listTop[k].IsTop = true
|
|
|
}
|
|
|
- listNoTop, err := models.GetIndustrialManagementAll(ChartPermissionId, uid, condition, orderSrt, 0, pageSize-len(listTop))
|
|
|
+ listNoTop, err := models.GetIndustrialManagementAll(uid, condition, orderSrt, 0, pageSize-len(listTop))
|
|
|
if err != nil {
|
|
|
br.Msg = "获取信息失败"
|
|
|
br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
|