|
@@ -75,21 +75,28 @@ func GetReportProjectInfo(param *ReportProjectInfoParam, positionId int64) (data
|
|
|
// 行业 {"水利水电":["水利工程","发电工程","航运工程","其他工程"]} sql中处理成 "水利水电_水利工程"
|
|
|
tmpArr := []string{}
|
|
|
for topIndustry, subList := range param.Industry {
|
|
|
- for i := 0; i < len(subList); i++ {
|
|
|
+ if param.From == From {
|
|
|
tmpArr = append(tmpArr, "find_in_set(?,subscopeclass)")
|
|
|
- values = append(values, fmt.Sprintf("%s_%s", topIndustry, subList[i]))
|
|
|
+ values = append(values, topIndustry)
|
|
|
+ } else {
|
|
|
+ for i := 0; i < len(subList); i++ {
|
|
|
+ tmpArr = append(tmpArr, "find_in_set(?,subscopeclass)")
|
|
|
+ values = append(values, fmt.Sprintf("%s_%s", topIndustry, subList[i]))
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
qstr = append(qstr, fmt.Sprintf("(%s)", strings.Join(tmpArr, " or ")))
|
|
|
}
|
|
|
// 采购单位类型
|
|
|
- if param.BuyerClass != nil && len(param.BuyerClass) > 0 {
|
|
|
- tmpArr := []string{}
|
|
|
- for i := 0; i < len(param.BuyerClass); i++ {
|
|
|
- tmpArr = append(tmpArr, "?")
|
|
|
- values = append(values, param.BuyerClass[i])
|
|
|
+ if param.From != From {
|
|
|
+ if param.BuyerClass != nil && len(param.BuyerClass) > 0 {
|
|
|
+ tmpArr := []string{}
|
|
|
+ for i := 0; i < len(param.BuyerClass); i++ {
|
|
|
+ tmpArr = append(tmpArr, "?")
|
|
|
+ values = append(values, param.BuyerClass[i])
|
|
|
+ }
|
|
|
+ qstr = append(qstr, fmt.Sprintf("buyerclass in (%s)", strings.Join(tmpArr, ",")))
|
|
|
}
|
|
|
- qstr = append(qstr, fmt.Sprintf("buyerclass in (%s)", strings.Join(tmpArr, ",")))
|
|
|
}
|
|
|
// 采购单位
|
|
|
if param.Buyer != "" {
|
|
@@ -110,7 +117,7 @@ func GetReportProjectInfo(param *ReportProjectInfoParam, positionId int64) (data
|
|
|
if param.From == From {
|
|
|
table = TableMemberReportProjectYys
|
|
|
}
|
|
|
- CountQuery := fmt.Sprintf("select count(1) from %s where position_id=? and start_time>=? and end_time<=? %s ", table, q)
|
|
|
+ CountQuery := fmt.Sprintf("select count(1) from %s where position_id=? and start_time=? and end_time=? %s ", table, q)
|
|
|
total = db.Base.CountBySql(CountQuery, values...)
|
|
|
if total == 0 {
|
|
|
return data, 0
|
|
@@ -119,7 +126,7 @@ func GetReportProjectInfo(param *ReportProjectInfoParam, positionId int64) (data
|
|
|
if param.Sort == 1 {
|
|
|
orderby = " (if(bidamount >0,bidamount,budget)) desc,id desc"
|
|
|
}
|
|
|
- query := fmt.Sprintf("select * from %s where position_id=? and start_time>=? and end_time<=? %s order by %s limit %d,%d", table, q, orderby, (param.PageNum-1)*param.PageSize, param.PageSize)
|
|
|
+ query := fmt.Sprintf("select * from %s where position_id=? and start_time=? and end_time=? %s order by %s limit %d,%d", table, q, orderby, (param.PageNum-1)*param.PageSize, param.PageSize)
|
|
|
rs := db.Base.SelectBySql(query, values...)
|
|
|
if rs != nil && len(*rs) > 0 {
|
|
|
data = *rs
|
|
@@ -128,7 +135,7 @@ func GetReportProjectInfo(param *ReportProjectInfoParam, positionId int64) (data
|
|
|
}
|
|
|
|
|
|
// ReportProjectInfoFormat 周报/月报 项目明细 格式化数据
|
|
|
-func ReportProjectInfoFormat(data []map[string]interface{}) []map[string]interface{} {
|
|
|
+func ReportProjectInfoFormat(data []map[string]interface{}, from string) []map[string]interface{} {
|
|
|
rs := []map[string]interface{}{}
|
|
|
for i := 0; i < len(data); i++ {
|
|
|
tmp := map[string]interface{}{}
|
|
@@ -144,12 +151,16 @@ func ReportProjectInfoFormat(data []map[string]interface{}) []map[string]interfa
|
|
|
winIdArr = append(winIdArr, splitWinnerId[j])
|
|
|
}
|
|
|
tmp["id"] = encrypt.EncodeArticleId2ByCheck(common.ObjToString(data[i]["source_infoid"]))
|
|
|
+ if from == From {
|
|
|
+ tmp["id"] = common.ObjToString(data[i]["source_infoid"])
|
|
|
+ }
|
|
|
+
|
|
|
tmp["winnerId"] = winIdArr
|
|
|
tmp["winner"] = strings.Split(tmpWinner, ",")
|
|
|
tmp["name"] = common.ObjToString(data[i]["name"])
|
|
|
tmp["area"] = data[i]["area"]
|
|
|
tmp["bidStatus"] = data[i]["bidstatus"]
|
|
|
- tmp["buyerClass"] = data[i]["buyerclass"]
|
|
|
+ tmp["buyerClass"] = ""
|
|
|
tmp["subscopeclass"] = data[i]["subscopeclass"]
|
|
|
tmp["bidAmount"] = data[i]["bidamount"]
|
|
|
tmp["budget"] = data[i]["budget"]
|
|
@@ -196,7 +207,7 @@ func ReportGetBuyerClass(positionId, start, end int64, from string) []string {
|
|
|
if from == From {
|
|
|
table = TableMemberReportProjectYys
|
|
|
}
|
|
|
- q := "select distinct(buyerclass) from " + table + " where position_id =? and start_time >=? and end_time<=? order by buyerclass "
|
|
|
+ q := "select distinct(buyerclass) from " + table + " where position_id =? and start_time =? and end_time=? order by buyerclass "
|
|
|
rs := db.Base.SelectBySql(q, positionId, start, end)
|
|
|
if rs != nil && len(*rs) > 0 {
|
|
|
for i := 0; i < len(*rs); i++ {
|
|
@@ -207,8 +218,8 @@ func ReportGetBuyerClass(positionId, start, end int64, from string) []string {
|
|
|
}
|
|
|
|
|
|
// ReportGetIndustry 周报月报获取当前行业
|
|
|
-func ReportGetIndustry(positionId, start, end int64, from string) []string {
|
|
|
- subscopeclass := []string{}
|
|
|
+func ReportGetIndustry(positionId, start, end int64, from string) map[string]interface{} {
|
|
|
+ subscopeclassArr := map[string]interface{}{}
|
|
|
table := TableMemberReportProject
|
|
|
if from == From {
|
|
|
table = TableMemberReportProjectYys
|
|
@@ -217,10 +228,14 @@ func ReportGetIndustry(positionId, start, end int64, from string) []string {
|
|
|
rs := db.Base.SelectBySql(q, positionId, start, end)
|
|
|
if rs != nil && len(*rs) > 0 {
|
|
|
for i := 0; i < len(*rs); i++ {
|
|
|
- subscopeclass = append(subscopeclass, common.ObjToString((*rs)[i]["subscopeclass"]))
|
|
|
+ subscopeclass := common.ObjToString((*rs)[i]["subscopeclass"])
|
|
|
+ if subscopeclass != "" {
|
|
|
+ subscopeclassArr[subscopeclass] = []interface{}{}
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
- return subscopeclass
|
|
|
+ return subscopeclassArr
|
|
|
}
|
|
|
|
|
|
// GetMainPositionId 根据用户id获取主账号的职位id
|