记得上下班打卡 | git大法好,push需谨慎

Commit df0daec6 authored by 张国柄's avatar 张国柄

opt:去除feign.api.kylin,直接操作redis.kylin;

parent c40b3bb4
......@@ -6,7 +6,7 @@ import lombok.Data;
import java.io.Serializable;
@ApiModel(value = "AdamCollectInfoVo", description = "演出详情")
@ApiModel(value = "AdamCollectInfoVo", description = "详情")
@Data
public class AdamCollectInfoVo implements Serializable, Cloneable {
private static final long serialVersionUID = 5217696983635918221L;
......@@ -16,69 +16,83 @@ public class AdamCollectInfoVo implements Serializable, Cloneable {
private String title;
@ApiModelProperty(value = "演出图片")
private String imgPoster;
// @ApiModelProperty(value = "支付倒计时")
// private Integer payCountdownMinute;
// @ApiModelProperty(value = "演出批文地址")
// private String approvalUrl;
@ApiModelProperty(value = "101音乐节 102小型演出(livehouse演出) 103巡演")
// @ApiModelProperty(value = "演出类型 1音乐节 2演唱会 3小型演出 4展览 6舞台剧 101音乐节 102小型演出(livehouse演出) 103巡演")
private int type;
@ApiModelProperty(value = "演出开始时间")
private String timeStart;
@ApiModelProperty(value = "演出结束时间")
private String timeEnd;
@ApiModelProperty(value = "停售时间")
private String stopSellTime;
// @ApiModelProperty(value = "演出结束时间")
// private String timeEnd;
// @ApiModelProperty(value = "停售时间")
// private String stopSellTime;
@ApiModelProperty(value = "价格")
private String price;
@ApiModelProperty(value = "开售时间")
private String sellTime;
@ApiModelProperty(value = "城市id")
private Integer cityId;
// @ApiModelProperty(value = "开售时间")
// private String sellTime;
// @ApiModelProperty(value = "会员开售时间")
// private String sellMemberTime;
// @ApiModelProperty(value = "城市id")
// private Integer cityId;
@ApiModelProperty(value = "城市名称")
private String cityName;
@ApiModelProperty(value = "场地id")
private String fieldId;
// @ApiModelProperty(value = "场地id")
// private String fieldId;
@ApiModelProperty(value = "场地名称")
private String fieldName;
@ApiModelProperty(value = "经度")
private String longitude;
@ApiModelProperty(value = "纬度")
private String latitude;
@ApiModelProperty(value = "场地距离当前位置距离")
private String diffDistance;
@ApiModelProperty(value = "搭售id")
private String projectId;
@ApiModelProperty(value = "巡演id")
private String roadShowId;
// @ApiModelProperty(value = "经度")
// private String longitude;
// @ApiModelProperty(value = "纬度")
// private String latitude;
// @ApiModelProperty(value = "场地距离当前位置距离")
// private String diffDistance;
// @ApiModelProperty(value = "搭售id")
// private String projectId;
// @ApiModelProperty(value = "巡演id")
// private String roadShowId;
// OSS
@ApiModelProperty(value = "演出详情")
private String details;
// OSS
@ApiModelProperty(value = "购票须知")
private String noticeImage;
// // OSS
// @ApiModelProperty(value = "演出详情")
// private String details;
// // OSS
// @ApiModelProperty(value = "购票须知")
// private String noticeImage;
@ApiModelProperty(value = "推荐顺序 0为不推荐")
private Integer isRecommend;
@ApiModelProperty(value = "状态")
private Integer appStatus;
@ApiModelProperty(value = "是否可买")
private Integer statusSell;
// @ApiModelProperty(value = "推荐顺序 0为不推荐")
// private Integer isRecommend;
// @ApiModelProperty(value = "状态")
// private Integer appStatus;
// @ApiModelProperty(value = "是否可买")
// private Integer statusSell;
@ApiModelProperty(value = "是否关联会员")
private Integer isMember;
@ApiModelProperty(value = "是否开启缺票登记")
private Integer isLackRegister;
@ApiModelProperty(value = "是否实名")
private Integer isTrueName;
@ApiModelProperty(value = "限购张数")
private Integer limitCount;
@ApiModelProperty(value = "会员限购张数")
private Integer limitCountMember;
// @ApiModelProperty(value = "是否开启缺票登记")
// private Integer isLackRegister;
// @ApiModelProperty(value = "是否实名")
// private Integer isTrueName;
// @ApiModelProperty(value = "限购张数")
// private Integer limitCount;
// @ApiModelProperty(value = "会员限购张数")
// private Integer limitCountMember;
@ApiModelProperty(value = "是否专属")
private Integer isExclusive;
@ApiModelProperty(value = "是否优惠")
private Integer isDiscount;
@ApiModelProperty(value = "是否提前")
private Integer isAdvance;
@ApiModelProperty(value = "文案")
private String message;
// @ApiModelProperty(value = "是否同步大麦 0 1")
// private Integer sysDamai;
// @ApiModelProperty(value = "文案")
// private String message;
// @ApiModelProperty(value = "演出公告")
// private String notice;
// @ApiModelProperty(value = "是否显示")
// private Integer isShow;
// @ApiModelProperty(value = "场次")
// private List<KylinTicketTimesVo> ticketTimeList;
private static final AdamCollectInfoVo obj = new AdamCollectInfoVo();
......
......@@ -16,7 +16,7 @@ public interface IAdamCollectionService {
void add(AdamCollectBaseVo collectVo);
AdamCollectBaseVo query(String uid, String type, String contentId);
boolean exists(String uid, String type, String contentId);
void del(String uid, String type, String... contentIds);
......
package com.liquidnet.service.adam.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.github.pagehelper.PageInfo;
import com.liquidnet.service.adam.dto.vo.AdamDisposedBaseVo;
import com.liquidnet.service.adam.dto.vo.AdamDisposedUserVo;
import com.liquidnet.service.adam.dto.vo.AdamDisposedVo;
import com.liquidnet.service.adam.entity.AdamDisposed;
/**
* <p>
......@@ -19,7 +17,7 @@ public interface IAdamDisposedService {
void add(AdamDisposedBaseVo disposedBaseVo);
AdamDisposedBaseVo query(String uid, String type, String contentId);
boolean exists(String uid, String type, String contentId);
void del(String uid, String type, String... contentId);
......
......@@ -50,8 +50,9 @@ public class AdamCollectionController {
@RequestParam String contentId) {
String currentUid = CurrentUtil.getCurrentUid();
AdamCollectBaseVo existVo = adamCollectionService.query(currentUid, type, contentId);
if (null != existVo) return ResponseDto.success();
if (adamCollectionService.exists(currentUid, type, contentId)) {
return ResponseDto.success();
}
AdamCollectBaseVo collectVo = AdamCollectBaseVo.getNew();
collectVo.setType(type);
......
......@@ -51,8 +51,9 @@ public class AdamDisposedController {
@RequestParam String contentId) {
String currentUid = CurrentUtil.getCurrentUid();
AdamDisposedBaseVo existVo = adamDisposedService.query(currentUid, type, contentId);
if (null != existVo) return ResponseDto.success();
if (adamDisposedService.exists(currentUid, type, contentId)) {
return ResponseDto.success();
}
AdamDisposedBaseVo disposedBaseVo = AdamDisposedBaseVo.getNew();
disposedBaseVo.setType(type);
......
......@@ -490,7 +490,7 @@ public class AdamRdmService {
/* ========================================================== | Other micro-service data inquiry */
public KylinPerformanceVo kylinPerformanceVos(String performancesId) {
public KylinPerformanceVo kylinPerformanceVo(String performancesId) {
return (KylinPerformanceVo) redisUtil.get(KylinRedisConst.PERFORMANCES + performancesId);
}
}
......@@ -25,6 +25,7 @@ import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.time.LocalDateTime;
import java.util.LinkedList;
......@@ -69,10 +70,11 @@ public class AdamCollectionServiceImpl implements IAdamCollectionService {
}
@Override
public AdamCollectBaseVo query(String uid, String type, String contentId) {
return mongoTemplate.findOne(Query.query(Criteria.where("uid").is(uid).and("type").is(type)
.and("contentId").is(contentId).and("state").is(1)),
AdamCollectBaseVo.class, AdamCollectBaseVo.class.getSimpleName());
public boolean exists(String uid, String type, String contentId) {
return mongoTemplate.exists(
Query.query(Criteria.where("uid").is(uid).and("contentId").is(contentId).and("type").is(type).and("state").is(1)),
AdamCollectBaseVo.class.getSimpleName()
);
}
@Override
......@@ -105,7 +107,9 @@ public class AdamCollectionServiceImpl implements IAdamCollectionService {
public PageInfo<AdamCollectVo> queryPage(String uid, String type, int pageNo, int pageSize) {
Query query = Query.query(Criteria.where("uid").is(uid).and("type").is(type).and("state").is(1));
long s = System.currentTimeMillis();
long count = mongoTemplate.count(query, AdamCollectBaseVo.class.getSimpleName());
log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s);
PageInfo<AdamCollectVo> voPageInfo = null;
if (count > 0) {
......@@ -113,31 +117,58 @@ public class AdamCollectionServiceImpl implements IAdamCollectionService {
query.with(pageable);
s = System.currentTimeMillis();
List<AdamCollectVo> collectVoList = mongoTemplate.find(query, AdamCollectVo.class, AdamCollectBaseVo.class.getSimpleName());
try {
String[] contentIds = collectVoList.stream().map(AdamCollectVo::getContentId).toArray(a -> new String[collectVoList.size()]);
ResponseDto<List<KylinPerformanceVo>> performanceVoListDto = feignKylinPerformanceClient.performanceList(contentIds);
if (performanceVoListDto.isSuccess()) {
List<KylinPerformanceVo> kylinPerformanceVoList = performanceVoListDto.getData();
collectVoList.forEach(v -> {
kylinPerformanceVoList.forEach(vl -> {
if (vl.getPerformancesId().equals(v.getContentId())) {
AdamCollectInfoVo collectInfoVo = AdamCollectInfoVo.getNew();
BeanUtils.copyProperties(vl, collectInfoVo);
v.setContentInfo(collectInfoVo);
}
});
});
} else {
log.info("Failed:{}.API.performanceList(...) for AdamCollection:{}", feignKylinPerformanceClient.getClass().getSimpleName(), performanceVoListDto.toJson());
}
} catch (Exception e) {
log.error("Exception:{}.API.performanceList(...) for AdamCollection", feignKylinPerformanceClient.getClass().getSimpleName(), e);
log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s);
if (!CollectionUtils.isEmpty(collectVoList)) {
// try {
// String[] contentIds = collectVoList.stream().map(AdamCollectVo::getContentId).toArray(a -> new String[collectVoList.size()]);
//
// ResponseDto<List<KylinPerformanceVo>> performanceVoListDto = feignKylinPerformanceClient.performanceList(contentIds);
//
// if (performanceVoListDto.isSuccess()) {
// List<KylinPerformanceVo> kylinPerformanceVoList = performanceVoListDto.getData();
//
// collectVoList.forEach(v -> {
// kylinPerformanceVoList.forEach(vl -> {
// if (vl.getPerformancesId().equals(v.getContentId())) {
// AdamCollectInfoVo collectInfoVo = AdamCollectInfoVo.getNew();
// BeanUtils.copyProperties(vl, collectInfoVo);
// v.setContentInfo(collectInfoVo);
// }
// });
// });
// } else {
// log.info("Failed:{}.API.performanceList(...) for AdamCollection:{}", feignKylinPerformanceClient.getClass().getSimpleName(), performanceVoListDto.toJson());
// }
// } catch (Exception e) {
// log.error("Exception:{}.API.performanceList(...) for AdamCollection", feignKylinPerformanceClient.getClass().getSimpleName(), e);
// }
s = System.currentTimeMillis();
collectVoList.forEach(r -> {
AdamCollectInfoVo vo = AdamCollectInfoVo.getNew();
KylinPerformanceVo performanceVo = adamRdmService.kylinPerformanceVo(r.getContentId());
if (null != performanceVo) {
// BeanUtils.copyProperties(performanceVo, vo);
vo.setPerformancesId(performanceVo.getPerformancesId());
vo.setTitle(performanceVo.getTitle());
vo.setImgPoster(performanceVo.getImgPoster());
vo.setType(performanceVo.getType());
vo.setTimeStart(performanceVo.getTimeStart());
vo.setPrice(performanceVo.getPrice());
vo.setCityName(performanceVo.getCityName());
vo.setFieldName(performanceVo.getFieldName());
vo.setIsMember(performanceVo.getIsMember());
vo.setIsExclusive(performanceVo.getIsExclusive());
vo.setIsDiscount(performanceVo.getIsDiscount());
vo.setIsAdvance(performanceVo.getIsAdvance());
}
r.setContentInfo(vo);
});
log.debug("#COL.RDS.K耗时:{}ms", System.currentTimeMillis() - s);
}
voPageInfo = PageInfo.of(collectVoList);
voPageInfo.setTotal(count);
} else {
......
......@@ -52,8 +52,8 @@ public class AdamDisposedServiceImpl implements IAdamDisposedService {
/* ---------------- 外部服务API ---------------- */
@Autowired
FeignKylinPerformanceClient kylinPerformanceClient;
// @Autowired
// FeignKylinPerformanceClient kylinPerformanceClient;
@Override
public void add(AdamDisposedBaseVo vo) {
......@@ -72,10 +72,11 @@ public class AdamDisposedServiceImpl implements IAdamDisposedService {
}
@Override
public AdamDisposedBaseVo query(String uid, String type, String contentId) {
return mongoTemplate.findOne(Query.query(Criteria.where("uid").is(uid).and("type").is(type)
.and("contentId").is(contentId).and("state").is(1)),
AdamDisposedBaseVo.class, AdamDisposedBaseVo.class.getSimpleName());
public boolean exists(String uid, String type, String contentId) {
return mongoTemplate.exists(
Query.query(Criteria.where("uid").is(uid).and("contentId").is(contentId).and("type").is(type).and("state").is(1)),
AdamDisposedBaseVo.class.getSimpleName()
);
}
@Override
......@@ -108,51 +109,79 @@ public class AdamDisposedServiceImpl implements IAdamDisposedService {
public PageInfo<AdamDisposedVo> queryPage(String uid, String type, int pageNo, int pageSize) {
Query query = Query.query(Criteria.where("uid").is(uid).and("type").is(type).and("state").is(1));
long s = System.currentTimeMillis();
long count = mongoTemplate.count(query, AdamDisposedBaseVo.class.getSimpleName());
log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s);
PageInfo<AdamDisposedVo> voPageInfo = null;
if (count > 0) {
query.with(PageRequest.of(pageNo - 1, pageSize, Sort.by(Sort.Direction.DESC, "createdAt")));
s = System.currentTimeMillis();
List<AdamDisposedVo> disposedVoList = mongoTemplate.find(query, AdamDisposedVo.class, AdamDisposedBaseVo.class.getSimpleName());
log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s);
if (!CollectionUtils.isEmpty(disposedVoList)) {
List<KylinPerformanceVo> kylinPerformanceVoList = null;
try {
String[] contentIds = disposedVoList.stream().map(AdamDisposedVo::getContentId).toArray(a -> new String[disposedVoList.size()]);
ResponseDto<List<KylinPerformanceVo>> performanceVoListDto = kylinPerformanceClient.performanceList(contentIds);
if (performanceVoListDto.isSuccess()) {
kylinPerformanceVoList = performanceVoListDto.getData();
} else {
log.info("Failed:{}.API.performanceList(...) for AdamDisposedVo:{}", kylinPerformanceClient.getClass().getSimpleName(), performanceVoListDto.toJson());
// List<KylinPerformanceVo> kylinPerformanceVoList = null;
// try {
// String[] contentIds = disposedVoList.stream().map(AdamDisposedVo::getContentId).toArray(a -> new String[disposedVoList.size()]);
//
// ResponseDto<List<KylinPerformanceVo>> performanceVoListDto = kylinPerformanceClient.performanceList(contentIds);
//
// if (performanceVoListDto.isSuccess()) {
// kylinPerformanceVoList = performanceVoListDto.getData();
// } else {
// log.info("Failed:{}.API.performanceList(...) for AdamDisposedVo:{}", kylinPerformanceClient.getClass().getSimpleName(), performanceVoListDto.toJson());
// }
// } catch (Exception e) {
// log.error("Exception:{}.API.performanceList(...) for AdamDisposedVo >> {}", kylinPerformanceClient.getClass().getSimpleName(), e.getLocalizedMessage());
// }
//
// if (!CollectionUtils.isEmpty(kylinPerformanceVoList)) {
// kylinPerformanceVoList.forEach(pv -> {
// disposedVoList.forEach(v -> {
// if (pv.getPerformancesId().equals(v.getContentId())) {
// AdamCollectInfoVo collectInfoVo = AdamCollectInfoVo.getNew();
// BeanUtils.copyProperties(pv, collectInfoVo);
// v.setContentInfo(collectInfoVo);
// }
//
// PageInfo<AdamDisposedUserVo> disposedUserVoPageInfo = this.queryDisposedUsers(type, v.getContentId(), 1, 3);
//
// if (disposedUserVoPageInfo.getTotal() > 0) v.setUserVos(disposedUserVoPageInfo.getList());
// });
// });
// } else {
// disposedVoList.forEach(v -> {
// PageInfo<AdamDisposedUserVo> disposedUserVoPageInfo = this.queryDisposedUsers(type, v.getContentId(), 1, 3);
//
// if (disposedUserVoPageInfo.getTotal() > 0) v.setUserVos(disposedUserVoPageInfo.getList());
// });
// }
s = System.currentTimeMillis();
disposedVoList.forEach(r -> {
AdamCollectInfoVo vo = AdamCollectInfoVo.getNew();
KylinPerformanceVo performanceVo = adamRdmService.kylinPerformanceVo(r.getContentId());
if (null != performanceVo) {
// BeanUtils.copyProperties(performanceVo, vo);
vo.setPerformancesId(performanceVo.getPerformancesId());
vo.setTitle(performanceVo.getTitle());
vo.setImgPoster(performanceVo.getImgPoster());
vo.setType(performanceVo.getType());
vo.setTimeStart(performanceVo.getTimeStart());
vo.setPrice(performanceVo.getPrice());
vo.setCityName(performanceVo.getCityName());
vo.setFieldName(performanceVo.getFieldName());
vo.setIsMember(performanceVo.getIsMember());
vo.setIsExclusive(performanceVo.getIsExclusive());
vo.setIsDiscount(performanceVo.getIsDiscount());
vo.setIsAdvance(performanceVo.getIsAdvance());
}
} catch (Exception e) {
log.error("Exception:{}.API.performanceList(...) for AdamDisposedVo >> {}", kylinPerformanceClient.getClass().getSimpleName(), e.getLocalizedMessage());
}
if (!CollectionUtils.isEmpty(kylinPerformanceVoList)) {
kylinPerformanceVoList.forEach(pv -> {
disposedVoList.forEach(v -> {
if (pv.getPerformancesId().equals(v.getContentId())) {
AdamCollectInfoVo collectInfoVo = AdamCollectInfoVo.getNew();
BeanUtils.copyProperties(pv, collectInfoVo);
v.setContentInfo(collectInfoVo);
}
PageInfo<AdamDisposedUserVo> disposedUserVoPageInfo = this.queryDisposedUsers(type, v.getContentId(), 1, 3);
if (disposedUserVoPageInfo.getTotal() > 0) v.setUserVos(disposedUserVoPageInfo.getList());
});
});
} else {
disposedVoList.forEach(v -> {
PageInfo<AdamDisposedUserVo> disposedUserVoPageInfo = this.queryDisposedUsers(type, v.getContentId(), 1, 3);
if (disposedUserVoPageInfo.getTotal() > 0) v.setUserVos(disposedUserVoPageInfo.getList());
});
}
r.setContentInfo(vo);
PageInfo<AdamDisposedUserVo> disposedUserVoPageInfo = this.queryDisposedUsers(type, r.getContentId(), 1, 3);
if (disposedUserVoPageInfo.getTotal() > 0) r.setUserVos(disposedUserVoPageInfo.getList());
});
log.debug("#DIS.RDS.MDB.K耗时:{}ms", System.currentTimeMillis() - s);
}
voPageInfo = PageInfo.of(disposedVoList);
......@@ -168,13 +197,17 @@ public class AdamDisposedServiceImpl implements IAdamDisposedService {
public PageInfo<AdamDisposedUserVo> queryDisposedUsers(String type, String contentId, int pageNo, int pageSize) {
Query query = Query.query(Criteria.where("type").is(type).and("contentId").is(contentId).and("state").is(1));
long s = System.currentTimeMillis();
long count = mongoTemplate.count(query, AdamDisposedBaseVo.class.getSimpleName());
log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s);
PageInfo<AdamDisposedUserVo> voPageInfo = null;
if (count > 0) {
query.with(PageRequest.of(pageNo - 1, pageSize, Sort.by(Sort.Direction.DESC, "createdAt")));
s = System.currentTimeMillis();
List<AdamDisposedUserVo> disposedUserVoList = mongoTemplate.find(query, AdamDisposedUserVo.class, AdamDisposedBaseVo.class.getSimpleName());
log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s);
voPageInfo = PageInfo.of(disposedUserVoList);
voPageInfo.setTotal(count);
......
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