Commit d608f591 authored by Vu Duy Anh's avatar Vu Duy Anh

anhvd commit change

parent 55a6b806
...@@ -13,4 +13,6 @@ public interface CampaignRepositoryCustom { ...@@ -13,4 +13,6 @@ public interface CampaignRepositoryCustom {
ResultDTO findByCampaignCode(CampaignRequestDTO requestDTO); ResultDTO findByCampaignCode(CampaignRequestDTO requestDTO);
String getMaxCampaignIndex(); String getMaxCampaignIndex();
ResultDTO checkAllowStatusToPrepare (Long campaignId);
} }
...@@ -192,7 +192,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom { ...@@ -192,7 +192,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
if (!DataUtil.isNullOrEmpty(requestDto.getCampaignName())) { if (!DataUtil.isNullOrEmpty(requestDto.getCampaignName())) {
sqlStr.append(" AND UPPER(a.CAMPAIGN_NAME) LIKE :p_name"); sqlStr.append(" AND UPPER(a.CAMPAIGN_NAME) LIKE :p_name");
} }
if (requestDto.getStatus() != null && requestDto.getStatus() > 0) { if (requestDto.getStatus() != null && requestDto.getStatus() >= 0) {
sqlStr.append(" AND a.STATUS = :p_status"); sqlStr.append(" AND a.STATUS = :p_status");
} }
if (!DataUtil.isNullOrEmpty(requestDto.getFromDateFr())) { if (!DataUtil.isNullOrEmpty(requestDto.getFromDateFr())) {
...@@ -245,7 +245,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom { ...@@ -245,7 +245,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
query.setParameter("p_company_site_id", requestDto.getCompanySiteId()); query.setParameter("p_company_site_id", requestDto.getCompanySiteId());
if (requestDto.getStatus() != null && requestDto.getStatus() > 0) { if (requestDto.getStatus() != null && requestDto.getStatus() >= 0) {
query.setParameter("p_status", requestDto.getStatus()); query.setParameter("p_status", requestDto.getStatus());
} }
if (!DataUtil.isNullOrEmpty(requestDto.getFromDateFr())) { if (!DataUtil.isNullOrEmpty(requestDto.getFromDateFr())) {
...@@ -287,6 +287,14 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom { ...@@ -287,6 +287,14 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
query.addScalar("numOfJoinedCus", new LongType()); query.addScalar("numOfJoinedCus", new LongType());
query.addScalar("numOfNotJoinedCus", new LongType()); query.addScalar("numOfNotJoinedCus", new LongType());
query.addScalar("numOfLockCus", new LongType()); query.addScalar("numOfLockCus", new LongType());
query.addScalar("companySiteId", new LongType());
query.addScalar("content", new StringType());
query.addScalar("maxRecall", new IntegerType());
query.addScalar("recallType", new IntegerType());
query.addScalar("recallDuration", new IntegerType());
query.addScalar("currentTimeMode", new LongType());
query.addScalar("wrapupTimeConnect", new LongType());
query.addScalar("wrapupTimeDisconnect", new LongType());
query.setResultTransformer(Transformers.aliasToBean(CampaignDTO.class)); query.setResultTransformer(Transformers.aliasToBean(CampaignDTO.class));
int count = 0; int count = 0;
...@@ -407,4 +415,36 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom { ...@@ -407,4 +415,36 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
return null; return null;
} }
@Override
public ResultDTO checkAllowStatusToPrepare(Long campaignId) {
logger.info("Start check allow campaign status to prepare::");
ResultDTO result = new ResultDTO();
if(DataUtil.isNullOrZero(campaignId)) {
result.setErrorCode(Constants.ApiErrorCode.ERROR);
result.setDescription(Constants.ApiErrorDesc.ERROR);
return result;
}
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = sessionFactory.openSession();
try {
StringBuilder sqlStr = new StringBuilder();
sqlStr.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "check-allow-campaign-status-to-prepare"));
SQLQuery query = session.createSQLQuery(sqlStr.toString());
query.setParameter("p_campaignId", campaignId);
List<Object[]> list = query.list();
if(list.size() > 0) {
result.setData(list.get(0));
result.setErrorCode(Constants.ApiErrorCode.SUCCESS);
result.setDescription(Constants.ApiErrorDesc.SUCCESS);
}
}catch (Exception ex) {
logger.error(ex.getMessage(), ex);
result.setErrorCode(Constants.ApiErrorCode.ERROR);
result.setDescription(Constants.ApiErrorDesc.ERROR);
}finally {
session.close();
}
return result;
}
} }
...@@ -20,4 +20,6 @@ public interface CampaignService { ...@@ -20,4 +20,6 @@ public interface CampaignService {
ResultDTO findCampaignById(Long campaignId); ResultDTO findCampaignById(Long campaignId);
ResultDTO changeCampaignStatus(CampaignDTO dto); ResultDTO changeCampaignStatus(CampaignDTO dto);
ResultDTO checkAllowStatusToPrepare(Long campaignId);
} }
...@@ -163,13 +163,13 @@ public class CampaignServiceImpl implements CampaignService { ...@@ -163,13 +163,13 @@ public class CampaignServiceImpl implements CampaignService {
if(dto.getStatus().equals((short) -1)) { if(dto.getStatus().equals((short) -1)) {
userActionLog.setActionType((short) 2); userActionLog.setActionType((short) 2);
} }
else if(dto.getStatus().equals((short) 5)) { else if(dto.getStatus().equals((short) 4)) {
userActionLog.setActionType((short) 7); userActionLog.setActionType((short) 7);
} }
else if(dto.getStatus().equals((short) 4)) { else if(dto.getStatus().equals((short) 3)) {
userActionLog.setActionType((short) 4); userActionLog.setActionType((short) 4);
} }
else if(dto.getStatus().equals((short) 3)) { else if(dto.getStatus().equals((short) 2)) {
userActionLog.setActionType((short) 5); userActionLog.setActionType((short) 5);
} }
...@@ -189,12 +189,17 @@ public class CampaignServiceImpl implements CampaignService { ...@@ -189,12 +189,17 @@ public class CampaignServiceImpl implements CampaignService {
return result; return result;
} }
@Override
public ResultDTO checkAllowStatusToPrepare(Long campaignId) {
return campaignRepository.checkAllowStatusToPrepare(campaignId);
}
private String generateCampaignCode(String campaignType, Short chanel) { private String generateCampaignCode(String campaignType, Short chanel) {
int year = Calendar.getInstance().get(Calendar.YEAR); int year = Calendar.getInstance().get(Calendar.YEAR);
String maxIndexStr = campaignRepository.getMaxCampaignIndex(); String maxIndexStr = campaignRepository.getMaxCampaignIndex();
if(maxIndexStr != null) { if(maxIndexStr != null) {
Long maxIndex = Long.valueOf(maxIndexStr) + 1; Long maxIndex = Long.valueOf(maxIndexStr) + 1;
String result = campaignType + "_" + String.valueOf(chanel) + "_" + String.valueOf(year) + "_" + maxIndex.toString(); String result = campaignType + "_" + chanel + "_" + year + "_" + maxIndex.toString();
return result; return result;
} }
return null; return null;
......
...@@ -110,4 +110,9 @@ public class CampaignController { ...@@ -110,4 +110,9 @@ public class CampaignController {
dto.setSessionId(request.getSession().getId()); dto.setSessionId(request.getSession().getId());
return campaignService.changeCampaignStatus(dto); return campaignService.changeCampaignStatus(dto);
} }
@RequestMapping(value = "/check-allow-status-to-prepare", method = RequestMethod.GET)
public ResultDTO checkAllowStatusToPrepare(@RequestParam("campaignId") Long campaignId) {
return campaignService.checkAllowStatusToPrepare(campaignId);
}
} }
WITH COUNT_LIST AS (SELECT (SELECT COUNT(1) FROM CAMPAIGN_CUSTOMER WHERE CAMPAIGN_ID = :p_campaignId) countCamp,
(SELECT COUNT(1) FROM CAMPAIGN_AGENT WHERE CAMPAIGN_ID = :p_campaignId) countAgent,
(select COUNT(1)
FROM SCENARIO s
INNER JOIN SCENARIO_QUESTION sq ON s.SCENARIO_ID = sq.SCENARIO_ID
INNER JOIN SCENARIO_ANSWER sa ON sq.SCENARIO_QUESTION_ID = sa.SCENARIO_QUESTION_ID
WHERE s.CAMPAIGN_ID = :p_campaignId) countScenario
FROM DUAL)
SELECT c.countCamp countCamp,
c.countAgent countAgent,
c.countScenario countScenario,
CASE
WHEN (c.countCamp IS NOT NULL AND c.countAgent IS NOT NULL AND c.countScenario IS NOT NULL) THEN '00'
ELSE '01' END as code
FROM COUNT_LIST c
...@@ -12,7 +12,15 @@ SELECT ...@@ -12,7 +12,15 @@ SELECT
a.CUSTOMER_NUMBER cusNum, a.CUSTOMER_NUMBER cusNum,
b.SLKHThamgiaCD numOfJoinedCus, b.SLKHThamgiaCD numOfJoinedCus,
c.SLKHChuaTuongTac numOfNotJoinedCus, c.SLKHChuaTuongTac numOfNotJoinedCus,
d.SLKHDoNotCall_Khoa numOfLockCus d.SLKHDoNotCall_Khoa numOfLockCus,
a.COMPANY_SITE_ID companySiteId,
a.CONTENT content,
a.MAX_RECALL maxRecall,
a.RECALL_TYPE recallType,
a.RECALL_DURATION recallDuration,
a.CURRENT_TIME_MODE currentTimeMode,
a.WRAPUP_TIME_CONNECT wrapupTimeConnect,
a.WRAPUP_TIME_DISCONNECT wrapupTimeDisconnect
FROM CAMPAIGN a FROM CAMPAIGN a
LEFT JOIN (SELECT campaign_id, COUNT (*) AS SLKHThamgiaCD LEFT JOIN (SELECT campaign_id, COUNT (*) AS SLKHThamgiaCD
FROM campaign_customer cc INNER JOIN CUSTOMER cus ON cc.CUSTOMER_ID = cus.CUSTOMER_ID FROM campaign_customer cc INNER JOIN CUSTOMER cus ON cc.CUSTOMER_ID = cus.CUSTOMER_ID
......
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