Commit 42ebb51a authored by Quxl's avatar Quxl

x

parents
Pipeline #152 failed with stages
/target/
/.settings/
/.classpath
/.project
/application.properties
/bin/
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.egolm</groupId>
<artifactId>search-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<start-class>com.egolm.search.SearchApplication</start-class>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.0.RELEASE</version>
</parent>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Finchley.SR2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.apache.solr</groupId>
<artifactId>solr-solrj</artifactId>
<version>8.1.1</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.38</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.17</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
</dependency>
<dependency>
<groupId>com.egolm</groupId>
<artifactId>common</artifactId>
<version>0.0.1-RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.solr</groupId>
<artifactId>solr-solrj</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>${start-class}</mainClass>
<layout>ZIP</layout>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
package com.egolm.search;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
import org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration;
import org.springframework.scheduling.annotation.EnableScheduling;
@EnableScheduling
@SpringBootApplication(exclude = { RedisAutoConfiguration.class, RedisRepositoriesAutoConfiguration.class })
public class SearchApplication {
public static void main(String[] args) {
SpringApplication.run(SearchApplication.class, args);
}
}
package com.egolm.search;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.egolm.common.DateUtil;
import com.egolm.search.schedules.house.HouseCollectTask;
@RestController
@RequestMapping
public class TestController {
@Value("${spring.profiles.active}")
private String profiles;
@Autowired
private HouseCollectTask task;
@RequestMapping(method = {RequestMethod.GET, RequestMethod.POST})
public String list(HttpServletRequest request) {
Map<String, String> map = new LinkedHashMap<String, String>();
map.put("/", "接口列表");
map.put("/houseIndexCreate", "房源索引全量更新");
map.put("/houseIndexUpdate?start=" + DateUtil.format(new Date(), "yyyyMMdd"), "房源索引增量更新(默认当天)");
StringBuffer sb = new StringBuffer();
for(String key : map.keySet()) {
sb.append("<A HREF=\"" + key + "\">" + map.get(key) + "</A>").append("<BR/>\n");
}
String html = "<HTML>\n" + sb.toString() + "</HTML>";
return html;
}
@RequestMapping(value= {"/houseIndexCreate"}, method = {RequestMethod.GET, RequestMethod.POST})
public String houseIndexCreate() {
task.createIndex();
return "OK";
}
@RequestMapping(value= {"/houseIndexUpdate"}, method = {RequestMethod.GET, RequestMethod.POST})
public String houseIndexUpdate(@DateTimeFormat(pattern="yyyyMMdd")Date start) {
if(start == null) {
start = DateUtil.start(DateUtil.day(new Date(), -1));
}
task.updateIndex(start);
return "OK";
}
}
package com.egolm.search.config;
import javax.sql.DataSource;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;
import com.alibaba.druid.pool.DruidDataSource;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.jdbc.dialect.SqlServerDialect;
@Configuration
public class DataSourceConfig {
@Bean
@Primary
@ConfigurationProperties(prefix = "spring.datasource")
public DataSource getDataSource() {
return DataSourceBuilder.create().type(DruidDataSource.class).build();
}
@Bean
@Primary
public PlatformTransactionManager getTransactionManager(DataSource dataSource) {
return new DataSourceTransactionManager(dataSource);
}
@Bean
@Primary
public JdbcTemplate getJdbcTemplate(DataSource dataSource) {
JdbcTemplate jdbcTemplate = new JdbcTemplate();
jdbcTemplate.setDataSource(dataSource);
jdbcTemplate.setDialect(new SqlServerDialect());
jdbcTemplate.setSql_level(3);
return jdbcTemplate;
}
}
\ No newline at end of file
package com.egolm.search.config;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient.Builder;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class SolrConfig {
@Value("${solr.house.core-url}")
private String houseUrl;
@Bean
@Qualifier("houseSolrClient")
public HttpSolrClient getHouseHttpSolrClient() {
return new Builder().withBaseSolrUrl(houseUrl).build();
}
}
package com.egolm.search.config;
import com.egolm.common.bean.Rjx;
public class XException extends RuntimeException {
private static final long serialVersionUID = 1L;
protected Rjx rjx = Rjx.jsonErr().setCode(500).setMessage("operation failed");
public XException(String msg) {
super(msg);
rjx.setMessage(msg);
}
public XException(String msg, Throwable e) {
super(msg, e);
rjx.setMessage(msg);
}
public XException(String msg, int code) {
super(msg);
rjx.setMessage(msg);
rjx.setCode(code);
}
public XException(String msg, int code, Throwable e) {
super(msg, e);
rjx.setMessage(msg);
rjx.setCode(code);
}
public Rjx getRjx() {
return rjx;
}
public static void assertNotBlank(String message, Object... objs) {
for(Object obj : objs) {
if(obj == null || obj.toString().trim().equals("")) {
throw new XException((message == null || message.trim().equals("")) ? "对象不能为空" : message);
}
}
}
}
package com.egolm.search.config;
import com.egolm.common.bean.Rjx;
public class XRException extends XException {
private static final long serialVersionUID = 1L;
public XRException(String msg) {
super(msg);
rjx.setMessage(msg);
}
public XRException(String msg, Throwable e) {
super(msg, e);
rjx.setMessage(msg);
}
public XRException(String msg, int code) {
super(msg);
rjx.setMessage(msg);
rjx.setCode(code);
}
public XRException(String msg, int code, Throwable e) {
super(msg, e);
rjx.setMessage(msg);
rjx.setCode(code);
}
public Rjx getRjx() {
return rjx;
}
public static void assertNotBlank(String message, Object... objs) {
for(Object obj : objs) {
if(obj == null || obj.toString().trim().equals("")) {
throw new XException((message == null || message.trim().equals("")) ? "对象不能为空" : message);
}
}
}
}
package com.egolm.search.schedules;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrQuery.ORDER;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.response.FacetField;
import org.apache.solr.client.solrj.response.FacetField.Count;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.SolrInputDocument;
import com.alibaba.fastjson.JSON;
import com.egolm.common.StringUtil;
import com.egolm.common.bean.Rjx;
import com.egolm.common.jdbc.Page;
import com.egolm.search.config.XRException;
public abstract class AbstractSolrApi implements SolrApi {
public abstract HttpSolrClient getSolrClient();
@Override
public Map<String, Object> query(Page page, String queryKey, String[] keywords, String[] orders, String... groupNames) {
logger.info("收到商品检索请求:" + Rjx.json().set("page", page).set("queryKey", queryKey).set("keywords", keywords).set("orders", orders).set("groupNames", groupNames).toString());
if(page == null) {
page = new Page(1L, 20L);
}
queryKey = queryKey.toUpperCase();
Rjx result = Rjx.json();
SolrQuery solrQuery = new SolrQuery(queryKey);
if(keywords != null) {
for(String keyword : keywords) {
solrQuery.addFilterQuery(keyword);
}
}
if(orders != null) {
for(String order : orders) {
String[] kv = order.split(":", 2);
ORDER sc = kv[1] == null || kv[1].trim().length() == 0 || kv[1].equalsIgnoreCase("asc") ? ORDER.asc : ORDER.desc;
solrQuery.addSort(kv[0], sc);
}
}
solrQuery.setFacet(true);
solrQuery.addFacetField(groupNames);
solrQuery.setRows(page.getLimit().intValue());
solrQuery.setStart(page.getFirstRowNumber().intValue() - 1);
try {
QueryResponse resp = getSolrClient().query(solrQuery);
Map<String, List<String>> groups = new HashMap<String, List<String>>();
List<FacetField> facetFields = resp.getFacetFields();
for (FacetField facet : facetFields) {
String fieldName = facet.getName();
if(StringUtil.isNotBlank(fieldName)) {
List<Count> values = facet.getValues();
for(int i = 0; i < values.size(); i++) {
Count count = values.get(i);
List<String> list = groups.get(fieldName);
if(list == null) {
list = new ArrayList<String>();
}
if(count.getCount() > 0) {
list.add(count.getName());
} else {
break;
}
groups.put(fieldName, list);
}
}
}
SolrDocumentList docList = resp.getResults();
page.setTotal(docList.getNumFound());
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
for(SolrDocument doc : docList) {
Map<String, Object> map = new HashMap<String, Object>();
for(String key : doc.keySet()) {
Object objValue = doc.get(key);
map.put(key, objValue);
}
list.add(map);
}
result.set("datas", list).set("page", page).set("groups", groups);
return result.getMap();
} catch (Exception e) {
throw new XRException("SolrQuery:" + queryKey + "," + JSON.toJSONString(keywords), e);
}
}
public void update(List<Map<String, Object>> list) {
List<SolrInputDocument> docs = new ArrayList<SolrInputDocument>();
for(Map<String, Object> map : list) {
SolrInputDocument solrInputDocument = new SolrInputDocument();
for(String key : map.keySet()) {
if(key != null && key.trim().length() > 0) {
solrInputDocument.addField(key, StringUtil.toString(map.get(key)));
}
}
docs.add(solrInputDocument);
}
int size = 1000;
List<SolrInputDocument> tmp = new ArrayList<SolrInputDocument>();
HttpSolrClient solrClient = getSolrClient();
try {
for(int docIndex = 0; docIndex < docs.size(); docIndex++) {
tmp.add(docs.get(docIndex));
if((docIndex%size == 0 || docIndex == docs.size() - 1) && docIndex > 0) {
solrClient.add(tmp);
tmp = new ArrayList<SolrInputDocument>();
}
}
solrClient.commit();
} catch (Exception e) {
try {
solrClient.rollback();
} catch (Exception ex) {
logger.error("重索引异常回滚失败", ex);
}
throw new XRException("重建索引失败", e);
}
}
@Override
public void deleteById(List<String> documentIds) {
HttpSolrClient solrClient = getSolrClient();
try {
if(documentIds != null && documentIds.size() > 0) {
solrClient.deleteById(documentIds);
solrClient.commit();
}
} catch (Exception e) {
try {
solrClient.rollback();
} catch (Exception ex) {
logger.error("重索引异常回滚失败", ex);
}
throw new XRException("SolrDelete:" + JSON.toJSONString(documentIds), e);
}
}
@Override
public void clear() {
HttpSolrClient solrClient = getSolrClient();
try {
solrClient.deleteByQuery("*");
solrClient.commit();
} catch (Exception e) {
try {
solrClient.rollback();
} catch (Exception ex) {
logger.error("重索引异常回滚失败", ex);
}
throw new XRException("删除全部索引失败", e);
}
}
}
package com.egolm.search.schedules;
import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
import com.egolm.common.jdbc.Page;
public interface SolrApi {
Logger logger = Logger.getLogger(SolrApi.class);
public Map<String, Object> query(Page page, String queryKey, String[] keywords, String[] orders, String... groupsNames);
public void update(List<Map<String, Object>> datas);
public void deleteById(List<String> idList);
public void clear();
}
package com.egolm.search.schedules.house;
import java.io.InputStream;
import java.util.Date;
import java.util.stream.Collectors;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import com.egolm.common.FileUtil;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.search.schedules.AbstractSolrApi;
@Component
public class HouseCollectTask extends AbstractSolrApi{
@Autowired
JdbcTemplate jdbcTemplate;
@Autowired
@Qualifier("houseSolrClient")
HttpSolrClient solrClient;
@Value("${solr.house.offset-minute-for-day}")
private Long offsetMinuteForDay;
@Value("${solr.house.offset-minute-for-minute}")
private Long offsetMinuteForMinute;
@Scheduled(cron="${solr.house.cron-for-day}")
public void dayExecute() {
Date date = new Date(System.currentTimeMillis() - (offsetMinuteForDay*60L*1000L));
this.updateIndex(date);
}
@Scheduled(cron="${solr.house.cron-for-minute}")
public void minuteExecute() {
Date date = new Date(System.currentTimeMillis() - (offsetMinuteForMinute*60L*1000L));
this.updateIndex(date);
}
public void createIndex() {
this.clear();
this.update(jdbcTemplate.queryForList(createIndexQuerySql));
}
public void updateIndex(Date date) {
this.deleteById(jdbcTemplate.queryForList(deleteIndexQuerySql, date).stream().map(o -> String.valueOf(o.get("id"))).collect(Collectors.toList()));
this.update(jdbcTemplate.queryForList(updateIndexQuerySql, date));
}
@Override
public HttpSolrClient getSolrClient() {
return solrClient;
}
static {
try {
Resource createIndexQuerySqlResource = new ClassPathResource("sql/house/create-index-query.sql");
Resource updateIndexQuerySqlResource = new ClassPathResource("sql/house/update-index-query.sql");
Resource deleteIndexQuerySqlResource = new ClassPathResource("sql/house/delete-index-query.sql");
InputStream createIndexQuerySqlStream = createIndexQuerySqlResource.getInputStream();
InputStream updateIndexQuerySqlStream = updateIndexQuerySqlResource.getInputStream();
InputStream deleteIndexQuerySqlStream = deleteIndexQuerySqlResource.getInputStream();
createIndexQuerySql = new String(FileUtil.streamToBytes(createIndexQuerySqlStream));
updateIndexQuerySql = new String(FileUtil.streamToBytes(updateIndexQuerySqlStream));
deleteIndexQuerySql = new String(FileUtil.streamToBytes(deleteIndexQuerySqlStream));
} catch (Throwable e) {
throw new RuntimeException("索引更新查询[SQL]加载错误", e);
}
}
private static final String createIndexQuerySql;
private static final String updateIndexQuerySql;
private static final String deleteIndexQuerySql;
}
/application.properties
solr:
house:
core-url: http://10.10.0.15:8983/solr/house
offset-minute-for-day: 1500
offset-minute-for-minute: 10
cron-for-day: 0 0 3 * * ?
cron-for-minute: 0 1/5 * * * ?
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
url: jdbc:sqlserver://10.10.0.51:56443;DatabaseName=AiRMSDB
username: sa
password: qiyang
maxActive: 20
initialSize: 1
maxWait: 60000
minIdle: 1
timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 300000
validationQuery: SELECT 1
testWhileIdle: true
testOnBorrow: true
testOnReturn: true
poolPreparedStatements: true
maxOpenPreparedStatements: 20
\ No newline at end of file
solr:
house:
core-url: http://10.10.0.15:8983/solr/house
offset-minute: 86400
cron-index-create: 0 0 3 * * ?
cron-index-update: 0 1/5 * * * ?
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
url: jdbc:sqlserver://10.10.0.51:56443;DatabaseName=AiRMSDB
username: sa
password: qiyang
maxActive: 20
initialSize: 1
maxWait: 60000
minIdle: 1
timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 300000
validationQuery: SELECT 1
testWhileIdle: true
testOnBorrow: true
testOnReturn: true
poolPreparedStatements: true
maxOpenPreparedStatements: 20
\ No newline at end of file
server:
port: 9090
spring:
profiles:
active: dev
\ No newline at end of file
log4j.rootLogger=info,appender
log4j.appender.appender=org.apache.log4j.ConsoleAppender
log4j.appender.appender.layout=org.apache.log4j.TTCCLayout
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/base.xml" />
<appender name="siftingAppender" class="ch.qos.logback.classic.sift.SiftingAppender">
<discriminator>
<key>context</key>
<DefaultValue>logback</DefaultValue>
</discriminator>
<sift>
<appender name="rollingFileAppender"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>/data/logs/search/${context}-%d{yyyy-MM-dd}.log</FileNamePattern>
<MaxHistory>30</MaxHistory>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
</encoder>
</appender>
</sift>
</appender>
<root level="INFO">
<appender-ref ref="siftingAppender" />
</root>
<springProfile name="dev">
<root level="INFO">
<appender-ref ref="siftingAppender" />
</root>
</springProfile>
<springProfile name="pro">
<root level="INFO">
<appender-ref ref="siftingAppender" />
</root>
</springProfile>
<logger name="com.microsoft" level="INFO" />
<logger name="com.alibaba" level="INFO" />
<logger name="springfox" level="ERROR" />
<logger name="javax" level="ERROR" />
<logger name="java" level="ERROR" />
<logger name="net" level="ERROR" />
<logger name="org" level="INFO" />
<logger name="io" level="INFO" />
</configuration>
\ No newline at end of file
DECLARE @ChoiceOssKEY VARCHAR(40)
DECLARE @AliyunOssKey VARCHAR(40)
DECLARE @HttpUrl VARCHAR(255)
DECLARE @Value1 VARCHAR(100)
DECLARE @Value5 VARCHAR(100)
DECLARE @LangID VARCHAR(20)
SELECT @ChoiceOssKEY = sValue1 FROM tSystemCtrl WHERE sCode = 'ChoiceOssKEY'
SELECT @HttpUrl = ''
SELECT @LangID = '936'
--自建OSS系统参数
IF @ChoiceOssKEY = 'SelfOssKey'
BEGIN
SELECT @Value1 = sValue1 FROM tSystemCtrl WHERE sCode = 'SelfOssKey'
--处理参数
IF RIGHT(@Value1,1) = '/' OR RIGHT(@Value1,1) = '\'
SELECT @Value1 = LEFT(@Value1, len(@Value1) - 1) + '/'
ELSE
SELECT @Value1 = @Value1 + '/'
SELECT @HttpUrl = @Value1
END
ELSE
--阿里OSS系统参数
IF @ChoiceOssKEY = 'AliyunOssKey'
BEGIN
SELECT @Value5 = sValue5 FROM tSystemCtrl WHERE sCode = 'AliyunOssKey'
--处理参数
IF RIGHT(@Value5,1) = '/' OR RIGHT(@Value5,1) = '\'
SELECT @Value5 = LEFT(@Value5, len(@Value5) - 1) + '/'
ELSE
SELECT @Value5 = @Value5 + '/'
SELECT @HttpUrl = @Value5
END
SELECT sFileNO, nItem, sURL
INTO #__tmp
FROM tFile WHERE nTag&1=0 AND sFileTypeID = 'Room'
SELECT a.sFileNO, a.sURL
INTO #__tmp1
FROM #__tmp a, (
SELECT sFileNO, nItem = min(nItem)
FROM #__tmp
GROUP BY sFileNO) b
WHERE a.sFileNO = b.sFileNO
AND a.nItem = b.nItem
SELECT
id = r.nRoomID,
PropertyID = a.nPropertyID,
PropertyName = p.sPropertyName,
HouseID = a.nHouseID,
RoomID = r.nRoomID,
RoomTypeID = a.nRoomTypeID,
RoomTypeNO = rt.sRoomTypeNO,
RoomTypeName = rt.sRoomTypeName,
HouseNO = a.sHouseNO,
HouseName = a.sHouseName,
HouseAddress = a.sHouseAddress,
RentTypeID = a.sRentTypeID, --出租类型:1.整租;2.合租;3.不限
RentType = a.sRentType,
TripDesc = p.sTripDesc, --出行描述
RentArea = a.nRentArea, --出租面积
TotalFloorsNum = a.nTotalFloorsNum, --总层数
Building = a.sBuilding, --楼栋
Cell = a.sCell, --单元
FloorNO = a.nFloor, --楼层
BedRooms = a.nBedRooms, --卧室
Kitchens = a.nKitchens, --厨房
LivingRooms = a.nLivingRooms, --客厅
Toilets = a.nToilets, --厕所
Balconys = a.nBalconys, --阳台
HousePrice = r.nHousePrice, --房价
Unit = '',
AdultCount = r.nAdultCount,
ChildCount = r.nChildCount,
Longitude = a.sLongitude,
Latitude = a.sLatitude,
Province = a.sProvince,
City = a.sCity,
Area = a.sArea,
HouseTypeID = a.sHouseTypeID, --房源类型:办公、公寓
HouseType = (SELECT DISTINCT sComDesc FROM tCommon WHERE sLangID = @LangID AND sCommonNO = 'HouseType' AND sComID = a.sHouseTypeID),
BrandTypeID = a.sBrandTypeID,
BrandType = (SELECT DISTINCT sComDesc FROM tCommon WHERE sLangID = @LangID AND sCommonNO = 'Brand' AND sComID = a.sBrandTypeID),
URL = @HttpUrl + CASE WHEN LEFT(f.sURL,1) = '/' THEN RIGHT(f.sURL,len(f.sURL) - 1) ELSE f.sURL END,
RoomStatusTypeID = r.sStatus, --当前房态
RoomStatusType = (SELECT DISTINCT sComDesc FROM tCommon where sCommonNO = 'RoomStatusType' AND sLangID = @LangID and sComID = r.sStatus),
CreateDate = a.dCreateDate,
ChangeDate = a.dChangeDate,
LastUpdateTime = a.dLastUpdateTime
FROM tHouse a join tProperty p on a.nPropertyID = p.nPropertyID
left join tRoomType rt on a.nHouseID = rt.nHouseID AND a.nRoomTypeID = rt.nRoomTypeID
left join tRoom r on a.nHouseID = r.nHouseID --and r.nTag&4=4 --整租属性
left join #__tmp1 f on f.sFileNO = convert(varchar,a.nHouseID)
WHERE a.nTag&1=0
AND a.nHouseStatus = 2 --房源有效状态
DROP TABLE #__tmp
DROP TABLE #__tmp1
\ No newline at end of file
DECLARE @ChoiceOssKEY VARCHAR(40)
DECLARE @AliyunOssKey VARCHAR(40)
DECLARE @HttpUrl VARCHAR(255)
DECLARE @Value1 VARCHAR(100)
DECLARE @Value5 VARCHAR(100)
DECLARE @LangID VARCHAR(20)
SELECT @ChoiceOssKEY = sValue1 FROM tSystemCtrl WHERE sCode = 'ChoiceOssKEY'
SELECT @HttpUrl = ''
SELECT @LangID = '936'
--自建OSS系统参数
IF @ChoiceOssKEY = 'SelfOssKey'
BEGIN
SELECT @Value1 = sValue1 FROM tSystemCtrl WHERE sCode = 'SelfOssKey'
--处理参数
IF RIGHT(@Value1,1) = '/' OR RIGHT(@Value1,1) = '\'
SELECT @Value1 = LEFT(@Value1, len(@Value1) - 1) + '/'
ELSE
SELECT @Value1 = @Value1 + '/'
SELECT @HttpUrl = @Value1
END
ELSE
--阿里OSS系统参数
IF @ChoiceOssKEY = 'AliyunOssKey'
BEGIN
SELECT @Value5 = sValue5 FROM tSystemCtrl WHERE sCode = 'AliyunOssKey'
--处理参数
IF RIGHT(@Value5,1) = '/' OR RIGHT(@Value5,1) = '\'
SELECT @Value5 = LEFT(@Value5, len(@Value5) - 1) + '/'
ELSE
SELECT @Value5 = @Value5 + '/'
SELECT @HttpUrl = @Value5
END
SELECT sFileNO, nItem, sURL
INTO #__tmp
FROM tFile WHERE nTag&1=0 AND sFileTypeID = 'Room'
SELECT a.sFileNO, a.sURL
INTO #__tmp1
FROM #__tmp a, (
SELECT sFileNO, nItem = min(nItem)
FROM #__tmp
GROUP BY sFileNO) b
WHERE a.sFileNO = b.sFileNO
AND a.nItem = b.nItem
SELECT
id = r.nRoomID,
PropertyID = a.nPropertyID,
PropertyName = p.sPropertyName,
HouseID = a.nHouseID,
RoomID = r.nRoomID,
RoomTypeID = a.nRoomTypeID,
RoomTypeNO = rt.sRoomTypeNO,
RoomTypeName = rt.sRoomTypeName,
HouseNO = a.sHouseNO,
HouseName = a.sHouseName,
HouseAddress = a.sHouseAddress,
RentTypeID = a.sRentTypeID, --出租类型:1.整租;2.合租;3.不限
RentType = a.sRentType,
TripDesc = p.sTripDesc, --出行描述
RentArea = a.nRentArea, --出租面积
TotalFloorsNum = a.nTotalFloorsNum, --总层数
Building = a.sBuilding, --楼栋
Cell = a.sCell, --单元
FloorNO = a.nFloor, --楼层
BedRooms = a.nBedRooms, --卧室
Kitchens = a.nKitchens, --厨房
LivingRooms = a.nLivingRooms, --客厅
Toilets = a.nToilets, --厕所
Balconys = a.nBalconys, --阳台
HousePrice = r.nHousePrice, --房价
Unit = '',
AdultCount = r.nAdultCount,
ChildCount = r.nChildCount,
Longitude = a.sLongitude,
Latitude = a.sLatitude,
Province = a.sProvince,
City = a.sCity,
Area = a.sArea,
HouseTypeID = a.sHouseTypeID, --房源类型:办公、公寓
HouseType = (SELECT DISTINCT sComDesc FROM tCommon WHERE sLangID = @LangID AND sCommonNO = 'HouseType' AND sComID = a.sHouseTypeID),
BrandTypeID = a.sBrandTypeID,
BrandType = (SELECT DISTINCT sComDesc FROM tCommon WHERE sLangID = @LangID AND sCommonNO = 'Brand' AND sComID = a.sBrandTypeID),
URL = @HttpUrl + CASE WHEN LEFT(f.sURL,1) = '/' THEN RIGHT(f.sURL,len(f.sURL) - 1) ELSE f.sURL END,
RoomStatusTypeID = r.sStatus, --当前房态
RoomStatusType = (SELECT DISTINCT sComDesc FROM tCommon where sCommonNO = 'RoomStatusType'
AND sLangID = @LangID and sComID = r.sStatus),
CreateDate = a.dCreateDate,
ChangeDate = a.dChangeDate,
LastUpdateTime = a.dLastUpdateTime
FROM tHouse a join tProperty p on a.nPropertyID = p.nPropertyID
left join tRoomType rt on a.nHouseID = rt.nHouseID AND a.nRoomTypeID = rt.nRoomTypeID
left join tRoom r on a.nHouseID = r.nHouseID --and r.nTag&4=4 --整租属性
left join #__tmp1 f on f.sFileNO = convert(varchar,a.nHouseID)
WHERE (a.nTag&1=1 or a.nHouseStatus <> 2) --房源无效状态
AND a.dLastUpdateTime >= ?
DROP TABLE #__tmp
DROP TABLE #__tmp1
\ No newline at end of file
DECLARE @ChoiceOssKEY VARCHAR(40)
DECLARE @AliyunOssKey VARCHAR(40)
DECLARE @HttpUrl VARCHAR(255)
DECLARE @Value1 VARCHAR(100)
DECLARE @Value5 VARCHAR(100)
DECLARE @LangID VARCHAR(20)
SELECT @ChoiceOssKEY = sValue1 FROM tSystemCtrl WHERE sCode = 'ChoiceOssKEY'
SELECT @HttpUrl = ''
SELECT @LangID = '936'
--自建OSS系统参数
IF @ChoiceOssKEY = 'SelfOssKey'
BEGIN
SELECT @Value1 = sValue1 FROM tSystemCtrl WHERE sCode = 'SelfOssKey'
--处理参数
IF RIGHT(@Value1,1) = '/' OR RIGHT(@Value1,1) = '\'
SELECT @Value1 = LEFT(@Value1, len(@Value1) - 1) + '/'
ELSE
SELECT @Value1 = @Value1 + '/'
SELECT @HttpUrl = @Value1
END
ELSE
--阿里OSS系统参数
IF @ChoiceOssKEY = 'AliyunOssKey'
BEGIN
SELECT @Value5 = sValue5 FROM tSystemCtrl WHERE sCode = 'AliyunOssKey'
--处理参数
IF RIGHT(@Value5,1) = '/' OR RIGHT(@Value5,1) = '\'
SELECT @Value5 = LEFT(@Value5, len(@Value5) - 1) + '/'
ELSE
SELECT @Value5 = @Value5 + '/'
SELECT @HttpUrl = @Value5
END
SELECT sFileNO, nItem, sURL
INTO #__tmp
FROM tFile WHERE nTag&1=0 AND sFileTypeID = 'Room'
SELECT a.sFileNO, a.sURL
INTO #__tmp1
FROM #__tmp a, (
SELECT sFileNO, nItem = min(nItem)
FROM #__tmp
GROUP BY sFileNO) b
WHERE a.sFileNO = b.sFileNO
AND a.nItem = b.nItem
SELECT
id = r.nRoomID,
PropertyID = a.nPropertyID,
PropertyName = p.sPropertyName,
HouseID = a.nHouseID,
RoomID = r.nRoomID,
RoomTypeID = a.nRoomTypeID,
RoomTypeNO = rt.sRoomTypeNO,
RoomTypeName = rt.sRoomTypeName,
HouseNO = a.sHouseNO,
HouseName = a.sHouseName,
HouseAddress = a.sHouseAddress,
RentTypeID = a.sRentTypeID, --出租类型:1.整租;2.合租;3.不限
RentType = a.sRentType,
TripDesc = p.sTripDesc, --出行描述
RentArea = a.nRentArea, --出租面积
TotalFloorsNum = a.nTotalFloorsNum, --总层数
Building = a.sBuilding, --楼栋
Cell = a.sCell, --单元
FloorNO = a.nFloor, --楼层
BedRooms = a.nBedRooms, --卧室
Kitchens = a.nKitchens, --厨房
LivingRooms = a.nLivingRooms, --客厅
Toilets = a.nToilets, --厕所
Balconys = a.nBalconys, --阳台
HousePrice = r.nHousePrice, --房价
Unit = '',
AdultCount = r.nAdultCount,
ChildCount = r.nChildCount,
Longitude = a.sLongitude,
Latitude = a.sLatitude,
Province = a.sProvince,
City = a.sCity,
Area = a.sArea,
HouseTypeID = a.sHouseTypeID, --房源类型:办公、公寓
HouseType = (SELECT DISTINCT sComDesc FROM tCommon WHERE sLangID = @LangID AND sCommonNO = 'HouseType' AND sComID = a.sHouseTypeID),
BrandTypeID = a.sBrandTypeID,
BrandType = (SELECT DISTINCT sComDesc FROM tCommon WHERE sLangID = @LangID AND sCommonNO = 'Brand' AND sComID = a.sBrandTypeID),
URL = @HttpUrl + CASE WHEN LEFT(f.sURL,1) = '/' THEN RIGHT(f.sURL,len(f.sURL) - 1) ELSE f.sURL END,
RoomStatusTypeID = r.sStatus, --当前房态
RoomStatusType = (SELECT DISTINCT sComDesc FROM tCommon where sCommonNO = 'RoomStatusType'
AND sLangID = @LangID and sComID = r.sStatus),
CreateDate = a.dCreateDate,
ChangeDate = a.dChangeDate,
LastUpdateTime = a.dLastUpdateTime
FROM tHouse a join tProperty p on a.nPropertyID = p.nPropertyID
left join tRoomType rt on a.nHouseID = rt.nHouseID AND a.nRoomTypeID = rt.nRoomTypeID
left join tRoom r on a.nHouseID = r.nHouseID --and r.nTag&4=4 --整租属性
left join #__tmp1 f on f.sFileNO = convert(varchar,a.nHouseID)
WHERE a.nTag&1=0
AND a.nHouseStatus = 2 --房源有效状态
AND a.dLastUpdateTime >= ?
DROP TABLE #__tmp
DROP TABLE #__tmp1
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment