代码优化
This commit is contained in:
-2
@@ -15,8 +15,6 @@ public class FangjiaConstant {
|
||||
|
||||
public static final byte POTENTIAL_SEND_TYPE = 4;
|
||||
|
||||
public static String FANGJIA_API_TOKEN = "F54F52381C49BB9EB4A33EB1B65604AE4B71A28AEE53518A94A2F360408B9056D57553931D15CE6DDE765562DAD286BA38E05A4CDAFC51C3D527A4959BF8E75A3B95DB7108FCEA340DDE61925616DB55118E1851E67D83EAD800460D100D6B667A4ED8EE67C8F7FB";
|
||||
|
||||
public static final int SUCCESS_RESPONSE_CODE = 200;
|
||||
|
||||
}
|
||||
|
||||
+12
-9
@@ -35,16 +35,19 @@ public class CityRankingSendJob implements SimpleJob {
|
||||
|
||||
@Autowired
|
||||
private CitySendLogService citySendLogService;
|
||||
|
||||
|
||||
@Autowired
|
||||
private EnterpriseProductUserService enterpriseProductUserService;
|
||||
|
||||
|
||||
@Autowired
|
||||
private PushMessageService pushMessageService;
|
||||
|
||||
@Value("${open.url}")
|
||||
private String openApiUrl;
|
||||
|
||||
@Value("${FANGJIA_API_TOKEN}")
|
||||
private String token;
|
||||
|
||||
private static final int NUM = 10;// 排名前10
|
||||
|
||||
@Override
|
||||
@@ -53,7 +56,7 @@ public class CityRankingSendJob implements SimpleJob {
|
||||
// 1.查询
|
||||
// 查询全部城市
|
||||
FshApiRemoteService fshApiRemoteService = RestApiCallUtils.getRestClient(FshApiRemoteService.class, openApiUrl);
|
||||
CityNewPriceResultDto resultDto = fshApiRemoteService.getAllCitys(FangjiaConstant.FANGJIA_API_TOKEN);
|
||||
CityNewPriceResultDto resultDto = fshApiRemoteService.getAllCitys(token);
|
||||
List<CityStatInfoDto> topTenList = new ArrayList<CityStatInfoDto>();
|
||||
List<CityStatInfoDto> bottomTenList = new ArrayList<CityStatInfoDto>();
|
||||
List<CityStatInfoDto> potentialTenList = new ArrayList<CityStatInfoDto>();
|
||||
@@ -90,8 +93,7 @@ public class CityRankingSendJob implements SimpleJob {
|
||||
bottomTenList = upList.subList(copyList.size() - NUM, copyList.size());
|
||||
Collections.reverse(bottomTenList);// 涨幅后10名倒序
|
||||
// 深复制失败,再次访问,用新list做潜力排序
|
||||
CityNewPriceResultDto resultDto2 = fshApiRemoteService
|
||||
.getAllCitys(FangjiaConstant.FANGJIA_API_TOKEN);
|
||||
CityNewPriceResultDto resultDto2 = fshApiRemoteService.getAllCitys(token);
|
||||
CityNewPriceDto dto2 = resultDto2.getResult();
|
||||
List<CityStatInfoDto> rets2 = dto2.getRets();
|
||||
// 潜力排序
|
||||
@@ -179,16 +181,17 @@ public class CityRankingSendJob implements SimpleJob {
|
||||
private void baseSend(CityCollect city, Integer rankings, byte sendType) {
|
||||
String title = null;
|
||||
if (FangjiaConstant.INCREASE_SEND_TYPE == sendType) {
|
||||
title = city.getCity()+",全国城市涨幅排名第" + rankings + "位";
|
||||
title = city.getCity() + ",全国城市涨幅排名第" + rankings + "位";
|
||||
} else if (FangjiaConstant.DECLINES_SEND_TYPE == sendType) {
|
||||
title = city.getCity()+",全国城市跌幅排名第" + rankings + "位";
|
||||
title = city.getCity() + ",全国城市跌幅排名第" + rankings + "位";
|
||||
|
||||
} else {
|
||||
title = city.getCity()+",全国城市潜力排名第" + rankings + "位";
|
||||
title = city.getCity() + ",全国城市潜力排名第" + rankings + "位";
|
||||
}
|
||||
LOG.info("全国城市涨幅(跌幅、潜力)排名推送开始,uid:" + city.getUid() + ",city:" + city.getCity());
|
||||
// 发送
|
||||
EnterpriseProductUser user = enterpriseProductUserService.getById(city.getUid(), new String[] { "push_client_id" });
|
||||
EnterpriseProductUser user = enterpriseProductUserService.getById(city.getUid(),
|
||||
new String[] { "push_client_id" });
|
||||
LOG.info(title);
|
||||
PushMessageParam param = new PushMessageParam();
|
||||
param.setTitle("排行榜提醒");
|
||||
|
||||
-1
@@ -5,7 +5,6 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.cxytiandi.jdbc.util.DateUtils;
|
||||
import com.dangdang.ddframe.job.api.ShardingContext;
|
||||
import com.dangdang.ddframe.job.api.simple.SimpleJob;
|
||||
import com.fangjia.job.common.base.FangjiaConstant;
|
||||
|
||||
Reference in New Issue
Block a user