Commit e167e20a authored by đinh thị đầm's avatar đinh thị đầm

Merge remote-tracking branch 'origin/master'

parents b3bd542b 5623fead
......@@ -6,7 +6,6 @@ import lombok.Setter;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
@Entity
......@@ -19,23 +18,23 @@ public class Campaign implements Serializable {
@NotNull
@Basic(optional = false)
@Column(name = "CAMPAIGN_ID")
private BigDecimal campaignId;
private Long campaignId;
@Column(name = "COMPANY_SITE_ID")
private BigDecimal companySiteId;
private Long companySiteId;
@Column(name = "CAMPAIGN_CODE")
private String campaignCode;
@Column(name = "CAMPAIGN_NAME")
private String campaignName;
@Column(name = "CHANEL")
private BigDecimal chanel;
private Long chanel;
@Column(name = "CONTENT")
private String content;
@Column(name = "CUSTOMER_NUMBER")
private BigDecimal customerNumber;
private Long customerNumber;
@Column(name = "TARGET")
private String target;
@Column(name = "STATUS")
private BigDecimal status;
private Long status;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "START_TIME")
private Date startTime;
......@@ -65,7 +64,7 @@ public class Campaign implements Serializable {
@Column(name = "PROCESS_STATUS")
private Integer processStatus;
@Column(name = "DIAL_MODE")
private BigDecimal dialMode;
private Long dialMode;
@Column(name = "DEPT_CODE")
private String deptCode;
@Column(name = "TIME_RANGE")
......@@ -73,29 +72,29 @@ public class Campaign implements Serializable {
@Column(name = "DAY_OF_WEEK")
private String dayOfWeek;
@Column(name = "CURRENT_TIME_MODE")
private BigDecimal currentTimeModel;
private Long currentTimeMode;
@Column(name = "WRAPUP_TIME_CONNECT")
private BigDecimal wrapupTimeConnect;
private Long wrapupTimeConnect;
@Column(name = "WRAPUP_TIME_DISCONNECT")
private BigDecimal wrapupTimeDisconnect;
private Long wrapupTimeDisconnect;
@Column(name = "PREVIEW_TIME")
private BigDecimal previewTime;
private Long previewTime;
@Column(name = "RATE_DIAL")
private BigDecimal rateDial;
private Long rateDial;
@Column(name = "RATE_MISS")
private BigDecimal rateMiss;
private Long rateMiss;
@Column(name = "AVG_TIME_PROCESS")
private BigDecimal avgTimeProcess;
private Long avgTimeProcess;
@Column(name = "IS_APPLY_CUST_LOCK")
private BigDecimal isApplyCustLock;
private Long isApplyCustLock;
@Column(name = "TARGET_TYPE")
private BigDecimal targetType;
private Long targetType;
@Column(name = "IS_TARGET")
private BigDecimal isTarget;
private Long isTarget;
@Column(name = "CAMPAIGN_IVR_CALLED_ID")
private BigDecimal campaignIvrCalledId;
private Long campaignIvrCalledId;
@Column(name = "CONCURRENT_CALL")
private BigDecimal concurrentCall;
private Long concurrentCall;
@Column(name = "CALL_OUT_TIME_IN_DAY")
private String callOutTimeInDay;
@Column(name = "MUSIC_LIST")
......@@ -111,6 +110,6 @@ public class Campaign implements Serializable {
@Column(name = "TIME_WAIT_AGENT")
private Integer timeWaitAgent;
@Column(name = "QUEST_INDEX")
private BigDecimal questIndex;
private Long questIndex;
}
......@@ -4,9 +4,7 @@ import lombok.Getter;
import lombok.Setter;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
@Entity
......@@ -56,6 +54,6 @@ public class CampaignCompleteCode implements Serializable {
@Column(name = "DURATION_LOCK")
private Long durationLock;
@Column(name = "CHANEL")
private BigDecimal chanel;
private Long chanel;
}
package com.viettel.campaign.repository;
import com.viettel.campaign.model.CampaignCompleteCode;
import com.viettel.campaign.web.dto.ResultDTO;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
......@@ -11,6 +10,7 @@ import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface CampaignCompleteCodeRepository extends JpaRepository<CampaignCompleteCode, Long> {
Page<CampaignCompleteCode> findAll(Pageable pageable);
......@@ -20,12 +20,9 @@ public interface CampaignCompleteCodeRepository extends JpaRepository<CampaignCo
List<CampaignCompleteCode> findByCompleteNameContains(String name, Pageable pageable);
@Modifying
@Query("update CampaignCompleteCode c set c.status=0 where c.campaignCompleteCodeId=:id")
int deleted(@Param("id") Long id);
@Modifying
@Query("update CampaignCompleteCode c set c.status=0 where c.campaignCompleteCodeId in (:ids)")
@Query("delete from CampaignCompleteCode c where c.campaignCompleteCodeId in (:ids)")
int deleteds(@Param("ids") List<Long> ids);
......
package com.viettel.campaign.repository;
import com.viettel.campaign.model.TimeRangeDialMode;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
/**
* @author anhvd_itsol
*/
@Repository
public interface TimeRangeDialModeRepository extends JpaRepository<TimeRangeDialMode, Long> {
}
package com.viettel.campaign.repository;
import com.viettel.campaign.model.TimeZoneDialMode;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
/**
* @author anhvd_itsol
*/
@Repository
public interface TimeZoneDialModeRepository extends JpaRepository<TimeZoneDialMode, Long> {
}
package com.viettel.campaign.repository.impl;
import com.viettel.campaign.model.CampaignCompleteCode;
import com.viettel.campaign.repository.CampaignCompleteCodeRepository;
import com.viettel.campaign.utils.HibernateUtil;
import com.viettel.campaign.utils.SQLBuilder;
import com.viettel.campaign.web.dto.CampaignCompleteCodeDTO;
import com.viettel.campaign.web.dto.ResultDTO;
import org.hibernate.SQLQuery;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.transform.Transformers;
import org.hibernate.type.LongType;
import org.hibernate.type.ShortType;
import org.hibernate.type.StringType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import java.util.List;
import java.util.Optional;
public class CampaignCompleteCodeRepositoryIpml implements CampaignCompleteCodeRepository {
@Autowired
EntityManager entityManager;
CampaignCompleteCodeRepository campaignCompleteCodeRepository;
private Logger log = LoggerFactory.getLogger(CampaignCompleteCodeRepositoryIpml.class);
@Override
public Page<CampaignCompleteCode> findAll(Pageable pageable) {
// Page<CampaignCompleteCode>
// try {
//
// } catch (Exception e) {
//
// }
return null;
}
@Override
public List<CampaignCompleteCode> findByName(String name, Pageable pageable) {
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = sessionFactory.openSession();
session.beginTransaction();
List<CampaignCompleteCode> resultList = null;
try {
StringBuilder sql = new StringBuilder(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_STATUS_MNG, "search-campaign-status-by-params"));
SQLQuery query = session.createSQLQuery(sql.toString());
query.setParameter(":p_name", name);
// add SCalar
query.addScalar("campaignId", new LongType());
query.addScalar("completeValue", new StringType());
query.addScalar("completeName", new StringType());
query.addScalar("completeType", new StringType());
query.addScalar("chanel", new ShortType());
query.addScalar("description", new StringType());
query.addScalar("status", new ShortType());
query.addScalar("chanel", new LongType());
query.setResultTransformer(Transformers.aliasToBean(CampaignCompleteCodeDTO.class));
resultList = query.list();
} catch (Exception e) {
session.close();
log.error(e.getMessage(), e);
}
return resultList;
}
@Override
public List<CampaignCompleteCode> findByCompleteNameContains(String name, Pageable pageable) {
return campaignCompleteCodeRepository.findByCompleteNameContains(name, pageable);
}
@Override
public int deleteds(List<Long> ids) {
return 0;
}
@Override
public List<CampaignCompleteCode> findAll() {
return campaignCompleteCodeRepository.findAll();
}
@Override
public List<CampaignCompleteCode> findAll(Sort sort) {
return campaignCompleteCodeRepository.findAll();
}
@Override
public List<CampaignCompleteCode> findAllById(Iterable<Long> iterable) {
return null;
}
@Override
public long count() {
return 0;
}
@Override
@Transactional
public void deleteById(Long id) {
ResultDTO result = new ResultDTO();
try {
// update Status = 0 cho cái ID truyền vào
CampaignCompleteCode entity = entityManager.find(CampaignCompleteCode.class, id);
// set giá trị Status = 0 --> tương đương với inactive
entity.setStatus(new Short("0"));
entityManager.merge(entity);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
@Override
public void delete(CampaignCompleteCode campaignCompleteCode) {
}
@Override
public void deleteAll(Iterable<? extends CampaignCompleteCode> iterable) {
}
@Override
public void deleteAll() {
}
@Override
public <S extends CampaignCompleteCode> S save(S s) {
return null;
}
@Override
public <S extends CampaignCompleteCode> List<S> saveAll(Iterable<S> iterable) {
return null;
}
@Override
public Optional<CampaignCompleteCode> findById(Long aLong) {
return Optional.empty();
}
@Override
public boolean existsById(Long aLong) {
return false;
}
@Override
public void flush() {
}
@Override
public <S extends CampaignCompleteCode> S saveAndFlush(S s) {
return null;
}
@Override
public void deleteInBatch(Iterable<CampaignCompleteCode> iterable) {
}
@Override
public void deleteAllInBatch() {
}
@Override
public CampaignCompleteCode getOne(Long aLong) {
return null;
}
@Override
public <S extends CampaignCompleteCode> Optional<S> findOne(Example<S> example) {
return Optional.empty();
}
@Override
public <S extends CampaignCompleteCode> List<S> findAll(Example<S> example) {
return null;
}
@Override
public <S extends CampaignCompleteCode> List<S> findAll(Example<S> example, Sort sort) {
return null;
}
@Override
public <S extends CampaignCompleteCode> Page<S> findAll(Example<S> example, Pageable pageable) {
return null;
}
@Override
public <S extends CampaignCompleteCode> long count(Example<S> example) {
return 0;
}
@Override
public <S extends CampaignCompleteCode> boolean exists(Example<S> example) {
return false;
}
}
......@@ -21,7 +21,6 @@ import org.springframework.stereotype.Repository;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
......@@ -145,7 +144,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
item.setContent((String) obj[2]);
item.setStartTime((Date) obj[3]);
item.setEndTime((Date) obj[4]);
item.setStatus(((BigDecimal) obj[5]).shortValueExact());
item.setStatus(((Short) obj[5]));
lst.add(item);
}
......@@ -268,7 +267,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
query.setParameter("p_cusNumTo", requestDto.getNumOfCusTo() == 0 ? null : requestDto.getNumOfCusTo());
}
query.addScalar("campaignId", new BigDecimalType());
query.addScalar("campaignId", new LongType());
query.addScalar("campaignCode", new StringType());
query.addScalar("campaignName", new StringType());
query.addScalar("campaignType", new StringType());
......@@ -276,7 +275,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
query.addScalar("chanel", new ShortType());
query.addScalar("startTime", new DateType());
query.addScalar("endTime", new DateType());
query.addScalar("customerNumber", new BigDecimalType());
query.addScalar("customerNumber", new LongType());
query.addScalar("status", new ShortType());
query.addScalar("numOfJoinedCus", new LongType());
query.addScalar("numOfNotJoinedCus", new LongType());
......@@ -346,7 +345,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
.replaceAll("_", "\\\\_")
+ "%");
}
query.addScalar("campaignId", new BigDecimalType());
query.addScalar("campaignId", new LongType());
query.addScalar("campaignCode", new StringType());
query.addScalar("campaignName", new StringType());
query.addScalar("startTime", new DateType());
......
......@@ -41,7 +41,7 @@ public class TicketRepositoryImpl implements TicketRepositoryCustom {
for (Object[] obj : data) {
TicketDTO item = new TicketDTO();
item.setTicketId(((BigDecimal) obj[0]).longValueExact());
item.setTicketId(((Long)obj[0]));
item.setCreateDate((Date) obj[1]);
item.setSubject((String) obj[2]);
item.setStatusName((String) obj[3]);
......
package com.viettel.campaign.service;
import com.viettel.campaign.repository.CampaignCompleteCodeRepositoryCustom;
import com.viettel.campaign.utils.Constants;
import com.viettel.campaign.web.dto.CampaignCompleteCodeDTO;
import com.viettel.campaign.web.dto.ResultDTO;
......@@ -23,10 +22,6 @@ public class CampaignCompleteCodeServiceImpl implements CampaignCompleteCodeServ
@Autowired
CampaignCompleteCodeRepository completeCodeRepository;
@Autowired
CampaignCompleteCodeRepositoryCustom repositoryCustom;
@Override
public Map listAllCompleteCode(int page, int pageSize, String sort) {
Map result = new HashMap();
......@@ -127,22 +122,21 @@ public class CampaignCompleteCodeServiceImpl implements CampaignCompleteCodeServ
return resultDTO;
}
@Transactional
@Override
public ResultDTO deleteList(List<Long> completeCodeDtos) {
ResultDTO resultDTO = new ResultDTO();
CampaignCompleteCode campaignCompleteCode = new CampaignCompleteCode();
try {
completeCodeRepository.deleteds(completeCodeDtos);
campaignCompleteCode = completeCodeRepository.save(campaignCompleteCode);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} catch (Exception e) {
resultDTO.setErrorCode("-1");
return resultDTO;
}
// for (int i = 0; i < completeCodeDtos.size(); i++) {
try {
completeCodeRepository.deleteds(completeCodeDtos);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} catch (Exception e) {
resultDTO.setErrorCode("-1");
return resultDTO;
}
// }
resultDTO.setErrorCode("0");
......@@ -150,8 +144,19 @@ public class CampaignCompleteCodeServiceImpl implements CampaignCompleteCodeServ
}
@Override
public ResultDTO deleteById(Long id) {
return repositoryCustom.updateStatusById(id);
ResultDTO result = new ResultDTO();
try {
completeCodeRepository.deleteById(id);
result.setErrorCode(Constants.Status.ACTIVE_STR);
result.setDescription(Constants.Status.ACTIVE_STR);
} catch (Exception e) {
result.setErrorCode("-1");
return result;
}
result.setErrorCode("0");
return result;
}
}
package com.viettel.campaign.service.impl;
import com.viettel.campaign.model.Campaign;
import com.viettel.campaign.model.TimeZoneDialMode;
import com.viettel.campaign.repository.CampaignRepository;
import com.viettel.campaign.repository.TimeZoneDialModeRepository;
import com.viettel.campaign.repository.impl.CampaignRepositoryImpl;
import com.viettel.campaign.service.CampaignService;
import com.viettel.campaign.utils.Constants;
......@@ -27,6 +29,9 @@ public class CampaignServiceImpl implements CampaignService {
@Autowired
CampaignRepository campaignRepository;
@Autowired
TimeZoneDialModeRepository timeZoneDialModeRepository;
@Autowired
ModelMapper modelMapper;
......@@ -49,10 +54,20 @@ public class CampaignServiceImpl implements CampaignService {
public ResultDTO addNewCampaign(CampaignDTO campaignDTO) {
ResultDTO resultDTO = new ResultDTO();
Campaign campaign = modelMapper.map(campaignDTO, Campaign.class);
TimeZoneDialMode timeZoneDialMode = new TimeZoneDialMode();
try {
campaign = campaignRepository.save(campaign);
//insert sub tables
if(campaignDTO.getCurrentTimeMode().equals(1)){
timeZoneDialMode.setCompanySiteId(campaignDTO.getCompanySiteId());
timeZoneDialMode.setCampaignId(campaign.getCampaignId());
// timeZoneDialMode.setHour(campaignDTO.getT);
timeZoneDialModeRepository.save(timeZoneDialMode);
}
if(campaignDTO.getCurrentTimeMode().equals(2)) {
}
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setErrorCode(Constants.ApiErrorDesc.SUCCESS);
resultDTO.setData(campaign);
......
......@@ -3,7 +3,6 @@ package com.viettel.campaign.web.dto;
import lombok.Getter;
import lombok.Setter;
import java.math.BigDecimal;
import java.util.Date;
@Getter
......@@ -27,5 +26,5 @@ public class CampaignCompleteCodeDTO extends BaseDTO {
private Long companySiteId;
private Short isLock;
private Long durationLock;
private BigDecimal chanel;
private Long chanel;
}
......@@ -3,20 +3,19 @@ package com.viettel.campaign.web.dto;
import lombok.Getter;
import lombok.Setter;
import java.math.BigDecimal;
import java.util.Date;
@Getter
@Setter
public class CampaignDTO extends BaseDTO {
private BigDecimal campaignId;
private BigDecimal companySiteId;
private Long campaignId;
private Long companySiteId;
private String campaignCode;
private String campaignName;
private Short chanel;
private String content;
private BigDecimal customerNumber;
private Long customerNumber;
private String target;
private Short status;
private Date startTime;
......@@ -31,29 +30,29 @@ public class CampaignDTO extends BaseDTO {
private String campaignType;
private String product;
private Integer processStatus;
private BigDecimal dialMode;
private Long dialMode;
private String deptCode;
private String timeRange;
private String dayOfWeek;
private BigDecimal currentTimeModel;
private BigDecimal wrapupTimeConnect;
private BigDecimal wrapupTimeDisconnect;
private BigDecimal previewTime;
private BigDecimal rateDial;
private BigDecimal rateMiss;
private BigDecimal avgTimeProcess;
private BigDecimal isApplyCustLock;
private BigDecimal targetType;
private BigDecimal isTarget;
private BigDecimal campaignIvrCalledId;
private BigDecimal concurrentCall;
private Long currentTimeMode;
private Long wrapupTimeConnect;
private Long wrapupTimeDisconnect;
private Long previewTime;
private Long rateDial;
private Long rateMiss;
private Long avgTimeProcess;
private Long isApplyCustLock;
private Long targetType;
private Long isTarget;
private Long campaignIvrCalledId;
private Long concurrentCall;
private String callOutTimeInDay;
private String musicList;
private Integer timePlayMusic;
private Date campaignStart;
private Date campaignEnd;
private Integer timeWaitAgent;
private BigDecimal questIndex;
private Long questIndex;
private Long numOfJoinedCus;
private Long numOfNotJoinedCus;
private Long numOfLockCus;
......
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