feat:调度座位信息
This commit is contained in:
@@ -6,6 +6,7 @@ import com.xiang.xservice.basic.common.req.BaseRequest;
|
||||
import com.xiang.xservice.basic.config.MyThreadFactory;
|
||||
import com.xiang.xservice.basic.utils.DateUtils;
|
||||
import com.xiang.xservice.fwd.entity.pojo.FAudienceConfig;
|
||||
import com.xiang.xservice.fwd.entity.pojo.FPerformConfig;
|
||||
import com.xiang.xservice.fwd.entity.pojo.FPerformProjectInfo;
|
||||
import com.xiang.xservice.fwd.entity.pojo.FPerformSeatInfo;
|
||||
import com.xiang.xservice.fwd.entity.pojo.FUserConfig;
|
||||
@@ -19,6 +20,7 @@ import com.xiang.xservice.fwd.entity.resp.http.perform.ProjectsResp;
|
||||
import com.xiang.xservice.fwd.entity.resp.http.perform.SeatPlan;
|
||||
import com.xiang.xservice.fwd.entity.resp.http.perform.SeatPlanStatus;
|
||||
import com.xiang.xservice.fwd.mapper.FwdAudienceConfigMapper;
|
||||
import com.xiang.xservice.fwd.mapper.FwdPerformConfigMapper;
|
||||
import com.xiang.xservice.fwd.mapper.FwdPerformProjectInfoMapper;
|
||||
import com.xiang.xservice.fwd.mapper.FwdPerformSeatInfoMapper;
|
||||
import com.xiang.xservice.fwd.mapper.FwdUserConfigMapper;
|
||||
@@ -33,6 +35,7 @@ import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@@ -41,6 +44,7 @@ import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -57,6 +61,7 @@ public class PullDataFromFWDJob {
|
||||
|
||||
private final IPerformServiceHttp performServiceHttp;
|
||||
private final FwdPerformProjectInfoMapper performProjectInfoMapper;
|
||||
private final FwdPerformConfigMapper performConfigMapper;
|
||||
private final FwdPerformSeatInfoMapper performSeatInfoMapper;
|
||||
private final FwdUserConfigMapper userConfigMapper;
|
||||
private final FwdAudienceConfigMapper audienceConfigMapper;
|
||||
@@ -275,6 +280,81 @@ public class PullDataFromFWDJob {
|
||||
}
|
||||
}
|
||||
|
||||
@Scheduled(cron = "0 10 8 1/1 * ?")
|
||||
@PostMapping("/pullSeatDataJob")
|
||||
public void pullSeatDataJob() {
|
||||
List<FPerformConfig> availablePerform = performConfigMapper.getAvailablePerform();
|
||||
if (CollectionUtils.isEmpty(availablePerform)) {
|
||||
return;
|
||||
}
|
||||
for (FPerformConfig performConfig : availablePerform) {
|
||||
Perform performs = performServiceHttp.getPerformsByProjectIdFromHttp(performConfig.getProjectId());
|
||||
if (Objects.isNull(performs)) {
|
||||
continue;
|
||||
}
|
||||
if (CollectionUtils.isEmpty(performs.getPerformInfos())) {
|
||||
continue;
|
||||
}
|
||||
for (PerformInfo performInfo : performs.getPerformInfos()) {
|
||||
List<PerformDetail> info = performInfo.getPerformInfo();
|
||||
if (CollectionUtils.isEmpty(info)) {
|
||||
continue;
|
||||
}
|
||||
for (PerformDetail performDetail : info) {
|
||||
List<SeatPlan> seatPlans = performDetail.getSeatPlans();
|
||||
if (CollectionUtils.isEmpty(seatPlans)) {
|
||||
continue;
|
||||
}
|
||||
Map<Long, SeatPlan> map = seatPlans.stream().collect(Collectors.toMap(SeatPlan::getSeatPlanId, Function.identity(), (a, b) -> a));
|
||||
List<SeatPlanStatus> planStatusFromHttp = performServiceHttp.getSeatPlanStatusFromHttp(new ArrayList<>(map.keySet()));
|
||||
List<FPerformSeatInfo> seatInfoAddList = Lists.newArrayList();
|
||||
for (SeatPlanStatus seatPlanStatus : planStatusFromHttp) {
|
||||
if (!seatPlanStatus.getSoldOutFlag() && seatPlanStatus.getStandbyStatus() == 10) {
|
||||
FPerformSeatInfo seatInfo = performSeatInfoMapper.getPerformSeatInfoBySeatIdAndPerformIdAndProjectId(seatPlanStatus.getSeatPlanId(), seatPlanStatus.getPerformId(), performs.getProjectId());
|
||||
SeatPlan seatPlan = map.get(seatPlanStatus.getSeatPlanId());
|
||||
if (Objects.isNull(seatInfo)) {
|
||||
if (Objects.nonNull(seatPlan)) {
|
||||
seatInfo = new FPerformSeatInfo();
|
||||
seatInfo.setSeatPlanId(seatPlanStatus.getSeatPlanId());
|
||||
seatInfo.setSeatPlanName(seatPlan.getSeatPlanName());
|
||||
seatInfo.setPerformId(seatPlanStatus.getPerformId());
|
||||
seatInfo.setPerformName(seatPlan.getPerformName());
|
||||
seatInfo.setStopSale(seatPlan.getStopSale());
|
||||
seatInfo.setShelfStatus(seatPlan.getShelfStatus());
|
||||
seatInfo.setPrice(seatPlan.getPrice());
|
||||
seatInfo.setDiscountPrice(seatPlan.getDiscountPrice());
|
||||
seatInfo.setSubStatus(seatPlan.getSubStatus());
|
||||
seatInfo.setQuantity(seatPlan.getQuantity());
|
||||
seatInfo.setStatus(seatPlan.getStatus());
|
||||
seatInfo.setMaxSellStock(seatPlan.getMaxSellStock());
|
||||
seatInfo.setSoldStock(seatPlan.getSoldStock());
|
||||
seatInfo.setLeftStock(seatPlan.getLeftStock());
|
||||
seatInfo.setAbleSaleQuantity(seatPlan.getAbleSaleQuantity());
|
||||
seatInfo.setAshShow(seatPlan.getAshShow());
|
||||
seatInfo.setAshShowDesc(seatPlan.getAshShow());
|
||||
seatInfo.setSelectable(seatPlan.getSelectable());
|
||||
seatInfo.setDisplay(seatPlan.getDisplay());
|
||||
seatInfo.setAvailableTicketQuantity(seatPlan.getAvailableTicketQuantity());
|
||||
seatInfo.setAvailableAllTicketQuantity(seatPlan.getAvailableAllTicketQuantity());
|
||||
seatInfo.setSaleTime(DateUtils.getDateTimeFromStr(seatPlan.getSaleTime()));
|
||||
seatInfo.setProjectId(performs.getProjectId());
|
||||
seatInfo.setSoldOut(0);
|
||||
seatInfoAddList.add(seatInfo);
|
||||
}
|
||||
} else {
|
||||
seatInfo.setSoldOut(0);
|
||||
performSeatInfoMapper.update(seatInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(seatInfoAddList)) {
|
||||
performSeatInfoMapper.batchSave(seatInfoAddList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 每月拉取观影人数据更新
|
||||
*/
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<select id="getAvailableUser" resultMap="BaseResultMap">
|
||||
<select id="getAvailablePerform" resultMap="BaseResultMap">
|
||||
select <include refid="Base_Column_List"/>
|
||||
from fwd_perform_config where del_flag = 0
|
||||
</select>
|
||||
|
||||
Reference in New Issue
Block a user