QuotaService.isLimited, not READY

This commit is contained in:
Shaun Chyxion 2021-10-22 00:03:07 +08:00
parent 4905c5e22a
commit d6be550e1b
2 changed files with 10 additions and 8 deletions

View File

@ -32,6 +32,7 @@
and cq.campaign_id = #{campaignId}
and time_to_sec(time(now()))
between cq.daily_from and cq.daily_to
and cq.active = 1
group by account, cq.quota

View File

@ -1,11 +1,7 @@
package com.pudonghot.yo.openapi.controller;
import com.pudonghot.yo.model.domain.Campaign;
import com.pudonghot.yo.service.CommonCampaignQuotaService;
import lombok.val;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import lombok.extern.slf4j.Slf4j;
import com.pudonghot.yo.service.AgentService;
import org.springframework.stereotype.Controller;
@ -14,11 +10,13 @@ import com.pudonghot.yo.openapi.auth.SessionAbility;
import com.pudonghot.yo.service.CommonCampaignService;
import com.pudonghot.yo.service.CommonAgentStatusService;
import com.pudonghot.yo.openapi.service.AgentEventService;
import com.pudonghot.yo.service.CommonCampaignQuotaService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import static com.pudonghot.yo.model.agentevent.EventType.AgentState_CancelNotReady_Success;
import static com.pudonghot.yo.model.agentevent.EventType.AgentState_SetNotReady_Success;
/**
* @author Donghuang
@ -55,11 +53,14 @@ public class CampaignController implements SessionAbility {
if (!commonCampaignQuotaService.isLimited(campaign.getId(), account)) {
val queueId = commonCampaignService.enqueue(campaign.getTargetId(), agent);
agent.setQueues(String.valueOf(queueId));
// agent ready
agentStatusService.ready(agent);
agentEventService.publish(agent, AgentState_CancelNotReady_Success);
}
else {
agentStatusService.notReady(agent);
agentEventService.publish(agent, AgentState_SetNotReady_Success);
}
// agent ready
agentStatusService.ready(agent);
agentEventService.publish(agent, AgentState_CancelNotReady_Success);
}
@RequestMapping("/resource/task/start")