提交日志

master
wjt 1 year ago
parent 8001cbb26b
commit 50f9fc8c2a

@ -77,7 +77,8 @@ public class CommonLog {
/**
* ,traceId
*/
public static void infoBusinessPartyTypeNewTraceId(String message, String logBusinessPartyType) {
public static void infoBusinessPartyTypeNewTraceId(String message, String logBusinessPartyType, String traceId) {
updateTraceId(traceId);
MDC.put("businessPartyType", logBusinessPartyType);
printType(message, null, LogType.INFO);
}

@ -1,6 +1,7 @@
package com.baiye.modules.agent.controller;
import com.baiye.annotation.Inner;
import com.baiye.annotation.Log;
import com.baiye.http.CommonResponse;
import com.baiye.modules.agent.entity.ChannelCustom;
import com.baiye.modules.agent.entity.query.ChannelQuery;
@ -45,20 +46,21 @@ public class ChannelManageController {
@ApiOperation("激活开通")
@PostMapping("/active")
@Log("管理员开通子账号")
public CommonResponse<Object> active(@RequestBody Set<Long> ids) {
log.info("激活账号 操作人={}", SecurityUtils.getCurrentUserId());
return channelManageService.active(ids);
}
@ApiOperation("禁用")
@PostMapping("/forbidden")
@Log("管理员禁用子账号")
public CommonResponse<Object> forbidden(@RequestBody Set<Long> ids) {
log.info("禁用账号 操作人={}", SecurityUtils.getCurrentUserId());
return channelManageService.forbidden(ids);
}
@ApiOperation("配置开通账号")
@PostMapping("/update")
@Log("管理员修改渠道商")
public CommonResponse<Object> update(@RequestBody @Validated ChannelCustom channelCustom) {
channelManageService.update(channelCustom);
return CommonResponse.createBySuccess();

@ -3,6 +3,7 @@ package com.baiye.modules.agent.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.baiye.common.CommonLog;
import com.baiye.constant.DefaultNumberConstants;
import com.baiye.feign.IRemoteAuthService;
import com.baiye.http.CommonResponse;
@ -138,6 +139,7 @@ public class ChannelManageServiceImpl implements ChannelManageService {
@Override
@Transactional(rollbackFor = Exception.class)
public CommonResponse<Object> forbidden(Set<Long> ids) {
CommonLog.getTraceId();
List<ChannelCustom> list = new ArrayList<>();
List<ChannelCustom> channelCustoms = channelCustomRepository.findAllById(ids);
for (ChannelCustom channelCustom : channelCustoms) {

@ -28,6 +28,18 @@ public class ExcellentCases implements Serializable {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "cases_name")
@ApiModelProperty(value = "案例名")
private String casesName;
@Column(name = "type")
@ApiModelProperty(value = "类型 1-公司 2-小组")
private Integer type;
@Column(name = "watch_user_id")
@ApiModelProperty(value = "业务管理员id")
private Long watchUserId;
@Column(name = "url")
@NotNull(groups = AddGroup.class)
@ApiModelProperty(value = "url")

@ -51,4 +51,8 @@ public class ScriptOrganize implements Serializable {
@ApiModelProperty(value = "话术模板")
@Transient
private List<ScriptTemplate> scriptTemplateList;
@ApiModelProperty(value = "置顶话术")
@Transient
private ScriptTemplate top;
}

@ -2,12 +2,14 @@ package com.baiye.modules.platform.domain;
import cn.hutool.core.date.DateUtil;
import com.baiye.util.SecurityUtils;
import com.baiye.valid.AddGroup;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
@ -34,6 +36,7 @@ public class ScriptTemplate implements Serializable {
@Column(name = "answer")
@ApiModelProperty(value = "回答")
@NotNull(message = "问答不能为空", groups = {AddGroup.class})
private String answer;
@Column(name = "create_by")
@ -44,16 +47,21 @@ public class ScriptTemplate implements Serializable {
@ApiModelProperty(value = "话术组id")
private Long scriptOrganizeId;
@Column(name = "is_top")
@ApiModelProperty(value = "是否置顶")
private Boolean isTop = false;
@Column(name = "create_time")
@ApiModelProperty(value = "创建时间")
private Date createTime;
public ScriptTemplate addScriptTemplate(String question, String answer, Long scriptOrganizeId) {
public ScriptTemplate addScriptTemplate(String question, String answer) {
this.setQuestion(question);
this.setAnswer(answer);
this.setCreateBy(SecurityUtils.getCurrentUserId());
this.setCreateTime(DateUtil.date());
this.setScriptOrganizeId(scriptOrganizeId);
this.setScriptOrganizeId(null);
this.setIsTop(false);
return this;
}
}

@ -20,4 +20,6 @@ public interface ScriptTemplateRepository extends JpaRepository<ScriptTemplate,
List<ScriptTemplate> findByScriptOrganizeIdAndAndCreateBy(Long scriptOrganizeId, Long createBy);
List<ScriptTemplate> findByScriptOrganizeIdIn(Set<Long> scriptOrganizeIds);
ScriptTemplate findByCreateByAndIsTop(Long createBy, Boolean isTop);
}

@ -1,5 +1,6 @@
package com.baiye.modules.platform.rest;
import com.baiye.annotation.Log;
import com.baiye.http.CommonResponse;
import com.baiye.modules.platform.domain.ExcellentCases;
import com.baiye.modules.platform.service.ExcellentCasesService;
@ -25,6 +26,7 @@ public class ExcellentCasesController {
@PostMapping("/addCases")
@ApiOperation("新增案例")
@Log("新增优秀案例")
public CommonResponse<Object> addExcellentCases(@RequestBody @Validated ExcellentCases excellentCases) {
excellentCasesService.addExcellentCases(excellentCases);
return CommonResponse.createBySuccess();
@ -32,13 +34,14 @@ public class ExcellentCasesController {
@DeleteMapping("/delete/{id}")
@ApiOperation("删除")
@Log("删除优秀案例")
public CommonResponse<Object> delete(@PathVariable("id") Long id) {
excellentCasesService.delete(id);
return CommonResponse.createBySuccess();
}
@GetMapping("/queryAll")
public ResponseEntity<Object> query(ExcellentCasesQueryCriteria excellentCasesQueryCriteria, Pageable pageable) {
public ResponseEntity<Object> query(@Validated ExcellentCasesQueryCriteria excellentCasesQueryCriteria, Pageable pageable) {
return new ResponseEntity<>(excellentCasesService.queryAll(excellentCasesQueryCriteria, pageable), HttpStatus.OK);
}

@ -1,5 +1,6 @@
package com.baiye.modules.platform.rest;
import com.baiye.annotation.Log;
import com.baiye.http.CommonResponse;
import com.baiye.modules.platform.domain.ScriptOrganize;
import com.baiye.modules.platform.service.ScriptOrganizeService;
@ -26,6 +27,7 @@ public class ScriptOrganizeController {
@ApiOperation("新增话术组和话术")
@PostMapping("/add")
@Log("新增话术")
public CommonResponse<Object> save(@Validated({AddGroup.class}) @RequestBody ScriptOrganize scriptOrganize) {
scriptOrganizeService.save(scriptOrganize);
return CommonResponse.createBySuccess();
@ -33,6 +35,7 @@ public class ScriptOrganizeController {
@ApiOperation("修改话术组")
@PostMapping("/update")
@Log("修改话术")
public CommonResponse<Object> update(@Validated({UpdateGroup.class}) @RequestBody ScriptOrganize scriptOrganize) {
scriptOrganizeService.update(scriptOrganize);
return CommonResponse.createBySuccess();
@ -40,6 +43,7 @@ public class ScriptOrganizeController {
@ApiOperation("删除话术组")
@DeleteMapping("/delete/{id}")
@Log("删除话术组")
public CommonResponse<Object> delete(@PathVariable("id") Long id) {
scriptOrganizeService.delete(id);
return CommonResponse.createBySuccess();

@ -1,16 +1,15 @@
package com.baiye.modules.platform.rest;
import com.baiye.annotation.Log;
import com.baiye.http.CommonResponse;
import com.baiye.modules.platform.domain.ScriptTemplate;
import com.baiye.modules.platform.service.ScriptTemplateService;
import com.baiye.modules.platform.service.dto.ScriptTemplateDTO;
import com.baiye.valid.AddGroup;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @author wjt
@ -25,11 +24,13 @@ public class ScriptTemplateController {
@PostMapping("/add")
@ApiOperation("新建话术模板")
public CommonResponse<Object> add(@Validated({AddGroup.class}) @RequestBody List<ScriptTemplateDTO> scriptTemplateDTOList) {
return scriptTemplateService.addScriptTemplate(scriptTemplateDTOList);
@Log("新增置顶话术")
public CommonResponse<Object> add(@Validated({AddGroup.class}) @RequestBody ScriptTemplate scriptTemplate) {
return scriptTemplateService.addScriptTemplate(scriptTemplate);
}
@DeleteMapping("/del/{id}")
@Log("删除话术")
public CommonResponse<Object> del(@PathVariable("id") Long id) {
scriptTemplateService.del(id);
return CommonResponse.createBySuccess();
@ -37,6 +38,7 @@ public class ScriptTemplateController {
@PostMapping("/update")
@ApiOperation("修改话术模板")
@Log("修改话术")
public CommonResponse<Object> update(@RequestBody ScriptTemplate scriptTemplate) {
scriptTemplateService.update(scriptTemplate);
return CommonResponse.createBySuccess();

@ -4,7 +4,7 @@ import com.baiye.modules.platform.domain.ScriptOrganize;
import com.baiye.modules.platform.service.dto.ScriptOrganizeQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.List;
import java.util.Map;
/**
* @author wjt
@ -23,5 +23,5 @@ public interface ScriptOrganizeService {
Object queryAll(ScriptOrganizeQueryCriteria scriptOrganizeQueryCriteria, Pageable pageable);
List<ScriptOrganize> queryOrganize(Long userId);
Map<String, Object> queryOrganize(Long userId);
}

@ -2,7 +2,6 @@ package com.baiye.modules.platform.service;
import com.baiye.http.CommonResponse;
import com.baiye.modules.platform.domain.ScriptTemplate;
import com.baiye.modules.platform.service.dto.ScriptTemplateDTO;
import java.util.List;
@ -15,10 +14,10 @@ public interface ScriptTemplateService {
/**
*
*
* @param scriptTemplateDTOList
* @param scriptTemplate
* @return
*/
CommonResponse<Object> addScriptTemplate(List<ScriptTemplateDTO> scriptTemplateDTOList);
CommonResponse<Object> addScriptTemplate(ScriptTemplate scriptTemplate);
/**
*
@ -35,4 +34,5 @@ public interface ScriptTemplateService {
void update(ScriptTemplate scriptTemplate);
List<ScriptTemplate> queryScript(Long scriptOrganizeId, Long userId);
}

@ -4,6 +4,7 @@ import com.baiye.annotation.Query;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* @author wjt
@ -17,4 +18,17 @@ public class ExcellentCasesQueryCriteria {
@Query(type = Query.Type.EQUAL)
private Long createBy;
@Query(type = Query.Type.EQUAL)
@NotNull(message = "类型不能为空")
private Integer type;
@Query(type = Query.Type.EQUAL)
@NotNull(message = "管理员id不能为空")
private Long watchUserId;
private Boolean isManager = false;
@Query(propName = "createBy", type = Query.Type.IN)
private List<Long> createByList;
}

@ -30,4 +30,6 @@ public class ScriptTemplateDTO {
@NotNull(message = "回答话术不能为空", groups = {AddGroup.class})
private String answer;
@ApiModelProperty(value = "是否置顶")
private Boolean isTop;
}

@ -5,8 +5,11 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.URLUtil;
import com.baiye.common.CommonLog;
import com.baiye.config.properties.FileProperties;
import com.baiye.constant.DefaultNumberConstants;
import com.baiye.exception.BadRequestException;
import com.baiye.model.dto.UserDto;
import com.baiye.modules.platform.domain.ExcellentCases;
import com.baiye.modules.platform.repository.ExcellentCasesRepository;
import com.baiye.modules.platform.repository.OrganizeUserRepository;
@ -25,6 +28,8 @@ import org.springframework.stereotype.Service;
import java.io.*;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
/**
* @author wjt
@ -38,6 +43,7 @@ public class ExcellentCasesServiceImpl implements ExcellentCasesService {
private final ExcellentCasesRepository excellentCasesRepository;
private final OrganizeUserRepository organizeUserRepository;
private final FileProperties fileProperties;
@Override
@ -51,54 +57,60 @@ public class ExcellentCasesServiceImpl implements ExcellentCasesService {
return;
}
}
UserDto user = SecurityUtils.getCurrentUser().getUser();
Long whichUserId = user.getWhichUserId();
excellentCases.setWatchUserId(whichUserId);
excellentCases.setCreateBy(SecurityUtils.getCurrentUserId());
excellentCases.setCreateTime(DateUtil.date());
excellentCases.setCreateName(SecurityUtils.getCurrentUsername());
excellentCases.setType(2);
URL url1 = URLUtil.url(excellentCases.getUrl());
BufferedInputStream inputStream;
String url;
try {
inputStream = new BufferedInputStream(url1.openStream());
String substring = DateUtil.format(DateUtil.date(), "MMdd") + RandomUtil.randomString(6) + ".wav";
File file = inputStreamToFile(inputStream, substring);
inputStreamToFile(inputStream, substring);
url = "cases" + File.separator + substring;
} catch (Exception e) {
e.printStackTrace();
throw new BadRequestException("保存错误,获取录音错误");
CommonLog.error("保存案例失败,获取录音错误");
throw new BadRequestException("保存失败,获取录音错误");
}
if (StrUtil.isBlank(url)) {
throw new BadRequestException("保存错误,未获取到录音");
CommonLog.error("保存案例失败,未获取到录音");
throw new BadRequestException("保存失败,未获取到录音");
}
excellentCases.setUrl(url);
excellentCasesRepository.save(excellentCases);
}
public File inputStreamToFile(InputStream ins, String name) throws Exception {
String path = fileProperties.getPath().getPath();
File file = new File(path + File.separator + "cases" + File.separator + name);
if (file.exists()) {
return file;
}
OutputStream os = new FileOutputStream(file);
int bytesRead;
int len = 8192;
byte[] buffer = new byte[len];
while ((bytesRead = ins.read(buffer, 0, len)) != -1) {
os.write(buffer, 0, bytesRead);
}
os.close();
ins.close();
return file;
}
@Override
public Object queryAll(ExcellentCasesQueryCriteria excellentCasesQueryCriteria, Pageable pageable) {
if (excellentCasesQueryCriteria.getIsManager()) {
excellentCasesQueryCriteria.setWatchUserId(SecurityUtils.getCurrentUserId());
PageRequest pageRequest = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), Sort.by(Sort.Direction.DESC, "createTime"));
Page<ExcellentCases> all = excellentCasesRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, excellentCasesQueryCriteria, criteriaBuilder), pageRequest);
return PageUtil.toPage(all);
} else {
if (excellentCasesQueryCriteria.getType() == DefaultNumberConstants.TWO_NUMBER) {
Long userIdAndIsLeader = organizeUserRepository.findUserIdAndIsLeader(SecurityUtils.getCurrentUserId());
excellentCasesQueryCriteria.setCreateBy(userIdAndIsLeader);
} else if (excellentCasesQueryCriteria.getType() == DefaultNumberConstants.ONE_NUMBER) {
excellentCasesQueryCriteria.setCreateBy(excellentCasesQueryCriteria.getWatchUserId());
} else {
Long userIdAndIsLeader = organizeUserRepository.findUserIdAndIsLeader(SecurityUtils.getCurrentUserId());
List<Long> list = new ArrayList<>();
list.add(userIdAndIsLeader);
list.add(excellentCasesQueryCriteria.getWatchUserId());
excellentCasesQueryCriteria.setCreateByList(list);
excellentCasesQueryCriteria.setType(null);
}
PageRequest pageRequest = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), Sort.by(Sort.Direction.DESC, "createTime"));
Page<ExcellentCases> all = excellentCasesRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, excellentCasesQueryCriteria, criteriaBuilder), pageRequest);
return PageUtil.toPage(all);
}
}
@Override
public void delete(Long id) {
@ -109,4 +121,21 @@ public class ExcellentCasesServiceImpl implements ExcellentCasesService {
public ExcellentCases queryBySessionId(String sessionId) {
return excellentCasesRepository.findBySessionId(sessionId);
}
private void inputStreamToFile(InputStream ins, String name) throws Exception {
String path = fileProperties.getPath().getPath();
File file = new File(path + File.separator + "cases" + File.separator + name);
if (file.exists()) {
return;
}
OutputStream os = new FileOutputStream(file);
int bytesRead;
int len = 8192;
byte[] buffer = new byte[len];
while ((bytesRead = ins.read(buffer, 0, len)) != -1) {
os.write(buffer, 0, bytesRead);
}
os.close();
ins.close();
}
}

@ -2,13 +2,14 @@ package com.baiye.modules.platform.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.baiye.exception.BadRequestException;
import com.baiye.modules.platform.domain.ScriptOrganize;
import com.baiye.modules.platform.domain.ScriptTemplate;
import com.baiye.modules.platform.repository.ScriptOrganizeRepository;
import com.baiye.modules.platform.repository.ScriptTemplateRepository;
import com.baiye.modules.platform.service.ScriptOrganizeService;
import com.baiye.modules.platform.service.dto.ScriptOrganizeQueryCriteria;
import com.baiye.util.PageUtil;
import com.baiye.util.QueryHelp;
import com.baiye.util.SecurityUtils;
import lombok.RequiredArgsConstructor;
@ -19,9 +20,7 @@ import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -40,6 +39,9 @@ public class ScriptOrganizeServiceImpl implements ScriptOrganizeService {
public void save(ScriptOrganize scriptOrganize) {
Long currentUserId = SecurityUtils.getCurrentUserId();
if (scriptOrganize.getId() == null) {
if (StrUtil.isBlank(scriptOrganize.getScriptOrganizeName())) {
throw new BadRequestException("话术组名不能为空");
}
scriptOrganize.setCreateBy(currentUserId);
scriptOrganize.setCreateTime(DateUtil.date());
scriptOrganize.setStatus(true);
@ -90,11 +92,23 @@ public class ScriptOrganizeServiceImpl implements ScriptOrganizeService {
scriptOrganize.setScriptTemplateList(collect.get(id));
}
}
return PageUtil.toPage(all);
ScriptTemplate byCreateByAndIsTop = scriptTemplateRepository.findByCreateByAndIsTop(SecurityUtils.getCurrentUserId(), true);
Map<String, Object> map = new HashMap<>(2);
Map<String, Object> map1 = new HashMap<>();
map1.put("content", all.getContent());
map1.put("top", byCreateByAndIsTop);
map.put("content", map1);
map.put("totalElements", all.getTotalElements());
return map;
}
@Override
public List<ScriptOrganize> queryOrganize(Long userId) {
return scriptOrganizeRepository.findByCreateByAndStatus(userId, true);
public Map<String, Object> queryOrganize(Long userId) {
List<ScriptOrganize> byCreateByAndStatus = scriptOrganizeRepository.findByCreateByAndStatus(userId, true);
ScriptTemplate byCreateByAndIsTop = scriptTemplateRepository.findByCreateByAndIsTop(userId, true);
Map<String, Object> map = new HashMap<>(2);
map.put("organize", byCreateByAndStatus);
map.put("top", byCreateByAndIsTop);
return map;
}
}

@ -1,16 +1,16 @@
package com.baiye.modules.platform.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baiye.http.CommonResponse;
import com.baiye.modules.platform.domain.ScriptTemplate;
import com.baiye.modules.platform.repository.ScriptTemplateRepository;
import com.baiye.modules.platform.service.ScriptTemplateService;
import com.baiye.modules.platform.service.dto.ScriptTemplateDTO;
import com.baiye.util.SecurityUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@ -25,13 +25,22 @@ public class ScriptTemplateImpl implements ScriptTemplateService {
private final ScriptTemplateRepository scriptTemplateRepository;
@Override
public CommonResponse<Object> addScriptTemplate(List<ScriptTemplateDTO> scriptTemplateDTOList) {
List<ScriptTemplate> list = new ArrayList<>();
for (ScriptTemplateDTO scriptTemplateDTO : scriptTemplateDTOList) {
ScriptTemplate scriptTemplate = new ScriptTemplate().addScriptTemplate(scriptTemplateDTO.getQuestion(), scriptTemplateDTO.getAnswer(), scriptTemplateDTO.getScriptOrganizeId());
list.add(scriptTemplate);
public CommonResponse<Object> addScriptTemplate(ScriptTemplate scriptTemplate) {
ScriptTemplate scriptTemplate1 = new ScriptTemplate().addScriptTemplate(scriptTemplate.getQuestion(), scriptTemplate.getAnswer());
if (scriptTemplate.getScriptOrganizeId() == null) {
ScriptTemplate byCreateByAndIsTop = scriptTemplateRepository.findByCreateByAndIsTop(SecurityUtils.getCurrentUserId(), true);
if (ObjectUtil.isNotEmpty(byCreateByAndIsTop)) {
byCreateByAndIsTop.setAnswer(scriptTemplate.getAnswer());
byCreateByAndIsTop.setQuestion(scriptTemplate.getQuestion());
byCreateByAndIsTop.setCreateTime(DateUtil.date());
scriptTemplateRepository.save(byCreateByAndIsTop);
return CommonResponse.createBySuccess();
}
scriptTemplate1.setIsTop(true);
} else {
scriptTemplate1.setScriptOrganizeId(scriptTemplate.getScriptOrganizeId());
}
scriptTemplateRepository.saveAll(list);
scriptTemplateRepository.save(scriptTemplate1);
return CommonResponse.createBySuccess();
}

@ -1,5 +1,6 @@
package com.baiye.modules.telemarkting.api;
import com.baiye.annotation.Log;
import com.baiye.http.CommonResponse;
import com.baiye.modules.telemarkting.entity.dto.ClueBoostQueryCriteria;
import com.baiye.modules.telemarkting.service.ClueBoostService;
@ -31,6 +32,7 @@ public class ClueBoostController {
@ApiOperation("赔付")
@PostMapping("/compensate")
@Log("线索赔付")
public CommonResponse<Object> compensate(@RequestBody Set<Long> ids) {
clueBoostService.compensate(ids);
return CommonResponse.createBySuccess();

@ -1,6 +1,7 @@
package com.baiye.modules.telemarkting.api;
import com.baiye.annotation.Inner;
import com.baiye.annotation.Log;
import com.baiye.http.CommonResponse;
import com.baiye.modules.telemarkting.entity.ExtensionNumber;
import com.baiye.modules.telemarkting.entity.dto.ExtensionNumberCriteria;
@ -32,6 +33,7 @@ public class ExtensionNumberController {
@PostMapping("/add/extension")
@ApiOperation("导入分机号和外显号")
@Log("导入分机号和去显号")
public CommonResponse<String> addNumbers(@RequestParam(value = "file", required = false) MultipartFile file,
@RequestParam("display") Long display,
@RequestParam("dyDisplay") Long dyDisplay,

@ -4,6 +4,8 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.baiye.annotation.Log;
import com.baiye.common.CommonLog;
import com.baiye.constant.DefaultNumberConstants;
import com.baiye.exception.BadRequestException;
import com.baiye.http.CommonResponse;
@ -47,16 +49,19 @@ public class TelephoneCallController {
@PostMapping("/telephone/req")
@ApiOperation("拨打电话")
@Log("电话请求")
public CommonResponse<TelephoneCallStopDTO> doubleCallReq(@Validated @RequestBody TelephoneCallReqDTO telephoneCallReqDTO) {
int hour = DateUtil.hour(DateUtil.date(), true);
if (hour < DefaultNumberConstants.EIGHT_NUMBER || hour >= DefaultNumberConstants.TWENTY_ONE) {
CommonLog.error("请在8点-21点之间拨打电话");
return CommonResponse.createByErrorMessage("请在8点-21点之间拨打电话");
}
//判断账号是否到期
Date expirationTime = userService.findExpirationTimeByUserId(SecurityUtils.getCurrentUserId());
if (ObjectUtil.isNull(expirationTime)
|| DateUtil.compare(expirationTime, DateUtil.date()) < DefaultNumberConstants.ZERO_NUMBER) {
return CommonResponse.createByErrorMessage("您的账号已到期,请续费后使用");
CommonLog.error("您的账号已到期,请联系管理员");
return CommonResponse.createByErrorMessage("您的账号已到期,请联系管理员");
}
Long companyId = SecurityUtils.getCompanyId();
Organize organize;
@ -68,13 +73,11 @@ public class TelephoneCallController {
}
Company company = companyService.findById(companyId);
if (ObjectUtil.isNull(organize) || ObjectUtil.isNull(company)) {
CommonLog.error("缺失小组信息或公司信息");
return CommonResponse.createByErrorMessage("缺失小组信息或公司信息");
}
// if (company.getUserBalance() == null || company.getUserBalance() <= 0) {
// return CommonResponse.createByErrorMessage("余额不足,请充值后使用");
// }
if (organize.getCallMode() == null) {
CommonLog.error("请指定呼叫方式后使用");
return CommonResponse.createByErrorMessage("请指定呼叫方式后使用");
}
//呼叫方式0:双呼 1:点呼 2:AXB
@ -138,12 +141,6 @@ public class TelephoneCallController {
return telephoneCallService.doubleCallStop(telephoneCallStopDTO);
}
@PostMapping("/roll/stop")
@ApiOperation("点呼挂断呼叫")
public CommonResponse<Object> rollCallStop(@RequestBody TelephoneCallStopDTO telephoneCallStopDTO) {
return telephoneCallService.rollCallStop(telephoneCallStopDTO);
}
@PostMapping("/roll/cdrUrl")
@ApiOperation("点呼系统回调话单")
public CommonResponse<String> rollCallBack(@RequestBody String json) {
@ -159,4 +156,10 @@ public class TelephoneCallController {
}
return CommonResponse.createBySuccess();
}
@PostMapping("/roll/stop")
@ApiOperation("点呼挂断呼叫")
public CommonResponse<Object> rollCallStop(@RequestBody TelephoneCallStopDTO telephoneCallStopDTO) {
return telephoneCallService.rollCallStop(telephoneCallStopDTO);
}
}

@ -9,6 +9,7 @@ import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baiye.common.CommonLog;
import com.baiye.constant.DefaultNumberConstants;
import com.baiye.exception.BadRequestException;
import com.baiye.http.RollCallResponse;
@ -60,7 +61,7 @@ public class RollCallReq {
rollCallSystemDTO.setCdr_url(cdrUrl);
rollCallSystemDTO.setDisplay_callee(String.valueOf(doubleCallReq.getDisplay()));
rollCallSystemDTO.setDisplay_caller(String.valueOf(doubleCallReq.getDisplay()));
log.info("点呼请求参数:{}", BeanUtil.beanToMap(rollCallSystemDTO));
CommonLog.info("点呼请求参数: " + BeanUtil.beanToMap(rollCallSystemDTO));
//设置重试机制
int count = 0;
@ -75,7 +76,7 @@ public class RollCallReq {
return doubleCallResponse.getReqid();
} else {
count++;
log.error("点呼请求失败,response==={}", doubleCallResponse.getReason());
CommonLog.error("点呼请求失败,response===" + doubleCallResponse.getReason());
Thread.sleep(3000);
}
} catch (Exception e) {

@ -8,6 +8,7 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import com.baiye.common.CommonLog;
import com.baiye.constant.DefaultNumberConstants;
import com.baiye.exception.BadRequestException;
import com.baiye.http.CommonResponse;
@ -133,7 +134,7 @@ public class ExtensionNumberServiceImpl implements ExtensionNumberService {
try {
reader = ExcelUtil.getReader(file.getInputStream());
} catch (Exception e) {
log.error("读取文件错误:{}", e.getMessage());
CommonLog.error("文件读取错误");
return CommonResponse.createByErrorMessage("读取文件错误");
}
List<List<Object>> read = reader.read(0, reader.getRowCount());
@ -152,7 +153,7 @@ public class ExtensionNumberServiceImpl implements ExtensionNumberService {
String sip = numberSipReq.req(number, company.getCompanyName());
if (StrUtil.isBlank(sip)) {
log.error("未获取到分机号密码,分机号={},公司={}", number, company.getCompanyName());
CommonLog.error("未获取到分机号密码");
throw new BadRequestException("未获取到分机号密码,分机号=" + number + "-----公司={}" + company.getCompanyName());
}
extensionNumber.setSip(sip);

@ -5,6 +5,8 @@ import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import com.baiye.common.CommonLog;
import com.baiye.constant.BusinessPartyType;
import com.baiye.constant.ClueTypeConstants;
import com.baiye.constant.DefaultNumberConstants;
import com.baiye.exception.BadRequestException;
@ -17,7 +19,6 @@ import com.baiye.modules.agent.repository.ChannelCustomRepository;
import com.baiye.modules.platform.domain.CallDeduct;
import com.baiye.modules.platform.domain.Clue;
import com.baiye.modules.platform.repository.CallDeductRepository;
import com.baiye.modules.platform.service.CompanyService;
import com.baiye.modules.system.service.UserService;
import com.baiye.modules.telemarkting.dao.*;
import com.baiye.modules.telemarkting.entity.*;
@ -26,6 +27,7 @@ import com.baiye.modules.telemarkting.httpRequest.AxbRequest;
import com.baiye.modules.telemarkting.httpRequest.DoubleCallReq;
import com.baiye.modules.telemarkting.httpRequest.RollCallReq;
import com.baiye.modules.telemarkting.service.TelephoneCallService;
import com.baiye.util.RedisUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationContext;
import org.springframework.http.ResponseEntity;
@ -37,6 +39,7 @@ import java.util.Arrays;
import java.util.Date;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
/**
* @author wjt
@ -63,8 +66,6 @@ public class TelephoneCallServiceImpl implements TelephoneCallService {
@Resource
private ExtensionDisplayRepository extensionDisplayRepository;
@Resource
private CompanyService companyService;
@Resource
private CallDeductRepository callDeductRepository;
@Resource
private UserService userService;
@ -74,6 +75,9 @@ public class TelephoneCallServiceImpl implements TelephoneCallService {
@Resource
private ChannelCustomRepository channelCustomRepository;
@Resource
private RedisUtils redisUtils;
@Override
public CommonResponse<TelephoneCallStopDTO> doubleCallReq(TelephoneCallReqDTO doubleCallReq, Long companyId) {
String requestId = RandomUtil.randomString(10);
@ -133,10 +137,10 @@ public class TelephoneCallServiceImpl implements TelephoneCallService {
//实时扣费
callCostCount(allCallInfo.getMemberId(), allCallInfo.getClueId(), allCallInfo.getClueType(), allCallInfo.getDuration(), DefaultNumberConstants.TWO_NUMBER, whichUserId);
//更新资源通话状态
CompletableFuture.runAsync(() -> updateSourceCallStatus(userDate, DefaultNumberConstants.TWO_NUMBER, allCallInfo.getClueType()));
CompletableFuture.runAsync(() -> updateSourceCallStatus(userDate, DefaultNumberConstants.TWO_NUMBER, allCallInfo.getClueType(), null));
} else {
//更新资源通话状态
CompletableFuture.runAsync(() -> updateSourceCallStatus(userDate, DefaultNumberConstants.ONE_NUMBER, allCallInfo.getClueType()));
CompletableFuture.runAsync(() -> updateSourceCallStatus(userDate, DefaultNumberConstants.ONE_NUMBER, allCallInfo.getClueType(), null));
}
}
@ -186,19 +190,59 @@ public class TelephoneCallServiceImpl implements TelephoneCallService {
Long whichUserId = user.getWhichUserId();
Integer surplusPhoneBillByUserId = channelCustomRepository.findSurplusPhoneBillByUserId(whichUserId);
if (surplusPhoneBillByUserId == null || surplusPhoneBillByUserId <= 0) {
CommonLog.error("话费不足");
return CommonResponse.createByErrorMessage("话费不足");
}
String requestId = RandomUtil.randomString(10);
telephoneCallReqDTO.setRequestId(requestId);
if (telephoneCallReqDTO.getDisplay() == null || telephoneCallReqDTO.getTelA() == null) {
//获取去显号和分机号
getNumberAndDisplay(telephoneCallReqDTO, companyId);
}
//获取被叫号
CallClueDTO body;
try {
body = sourceClueClient.queryDetailsByClueType(Long.parseLong(telephoneCallReqDTO.getUserData()), telephoneCallReqDTO.getClueType()).getBody();
} catch (Exception e) {
CommonLog.error("呼叫失败");
throw new BadRequestException("呼叫失败");
}
if (ObjectUtil.isNull(body) || StrUtil.isEmpty(body.getNid())) {
CommonLog.error("未获取到号码");
return CommonResponse.createByErrorMessage("未获取到号码");
}
if (body.getMemberId() == null) {
CommonLog.error("线索未分配");
return CommonResponse.createByErrorMessage("线索未分配,请刷新后重试");
}
telephoneCallReqDTO.setTelB("474" + telephoneCallReqDTO.getDisplay() + body.getNid());
//请求呼叫
String reqId = rollCallReq.startReq(telephoneCallReqDTO);
AllCallInfo allCallInfo = new AllCallInfo().init(requestId, requestId, Long.parseLong(telephoneCallReqDTO.getUserData()), telephoneCallReqDTO.getClueType(), telephoneCallReqDTO.getMemberId(), DefaultNumberConstants.ONE_NUMBER, DefaultNumberConstants.TWO_NUMBER);
allCallInfoRepository.save(allCallInfo);
CallClueInfo clueInfo = new CallClueInfo().init(Long.parseLong(telephoneCallReqDTO.getUserData()), telephoneCallReqDTO.getTeamId(), telephoneCallReqDTO.getMemberId(), telephoneCallReqDTO.getTaskId(), companyId, DefaultNumberConstants.ONE_NUMBER);
callClueRepository.save(clueInfo);
redisUtils.set(requestId, CommonLog.getTraceId(), 3, TimeUnit.HOURS);
TelephoneCallStopDTO telephoneCallStopDTO = new TelephoneCallStopDTO();
telephoneCallStopDTO.setSessionid(reqId);
telephoneCallStopDTO.setCallId(requestId);
return CommonResponse.createBySuccess(telephoneCallStopDTO);
}
private void getNumberAndDisplay(TelephoneCallReqDTO telephoneCallReqDTO, Long companyId) {
//获取分机号
Integer number = extensionUserRepository.findNumberByMemberId(telephoneCallReqDTO.getMemberId());
if (number == null) {
return CommonResponse.createByErrorMessage("未分配分机号");
CommonLog.error("未分配分机号");
throw new BadRequestException("未分配分机号");
}
ExtensionDisplay extensionDisplay = extensionDisplayRepository.findExtensionDisplayByCompanyId(companyId);
if (ObjectUtil.isNull(extensionDisplay)) {
return CommonResponse.createByErrorMessage("未配置去显号");
CommonLog.error("未配置去显号");
throw new BadRequestException("未配置去显号");
}
telephoneCallReqDTO.setTelA(String.valueOf(number));
//获取去显号
@ -206,61 +250,35 @@ public class TelephoneCallServiceImpl implements TelephoneCallService {
switch (telephoneCallReqDTO.getClueType()) {
case DefaultNumberConstants.THREE_NUMBER:
if (extensionDisplay.getDyDisplay() == null) {
return CommonResponse.createByErrorMessage("未配置抖音去显号");
CommonLog.error("未配置抖音去显号");
throw new BadRequestException("未配置抖音去显号");
}
display = extensionDisplay.getDyDisplay();
break;
case DefaultNumberConstants.FOUR_NUMBER:
if (extensionDisplay.getDeliveryDisplay() == null) {
return CommonResponse.createByErrorMessage("未配置投流去显号");
CommonLog.error("未配置投流去显号");
throw new BadRequestException("未配置投流去显号");
}
display = extensionDisplay.getDeliveryDisplay();
break;
case DefaultNumberConstants.FIVE_NUMBER:
if (extensionDisplay.getTokerDisplay() == null) {
return CommonResponse.createByErrorMessage("未配置拓客去显号");
CommonLog.error("未配置拓客去显号");
throw new BadRequestException("未配置拓客去显号");
}
display = extensionDisplay.getTokerDisplay();
break;
default:
if (extensionDisplay.getDisplay() == null) {
return CommonResponse.createByErrorMessage("未配置去显号");
CommonLog.error("未配置去显号");
throw new BadRequestException("未配置去显号");
}
display = extensionDisplay.getDisplay();
}
telephoneCallReqDTO.setDisplay(display);
}
//获取被叫号
CallClueDTO body;
try {
body = sourceClueClient.queryDetailsByClueType(Long.parseLong(telephoneCallReqDTO.getUserData()), telephoneCallReqDTO.getClueType()).getBody();
} catch (Exception e) {
log.error("获取被叫号错误:{},time:{} ", e.getMessage(), DateUtil.now());
throw new BadRequestException("呼叫失败");
}
if (ObjectUtil.isNull(body) || StrUtil.isEmpty(body.getNid())) {
log.error("未获取到号码");
return CommonResponse.createByErrorMessage("未获取到号码");
}
if (body.getMemberId() == null) {
return CommonResponse.createByErrorMessage("线索未分配,请刷新后重试");
}
telephoneCallReqDTO.setTelB("474" + telephoneCallReqDTO.getDisplay() + body.getNid());
//请求呼叫
String reqId = rollCallReq.startReq(telephoneCallReqDTO);
AllCallInfo allCallInfo = new AllCallInfo().init(requestId, requestId, Long.parseLong(telephoneCallReqDTO.getUserData()), telephoneCallReqDTO.getClueType(), telephoneCallReqDTO.getMemberId(), DefaultNumberConstants.ONE_NUMBER, DefaultNumberConstants.TWO_NUMBER);
allCallInfoRepository.save(allCallInfo);
CallClueInfo clueInfo = new CallClueInfo().init(Long.parseLong(telephoneCallReqDTO.getUserData()), telephoneCallReqDTO.getTeamId(), telephoneCallReqDTO.getMemberId(), telephoneCallReqDTO.getTaskId(), companyId, DefaultNumberConstants.ONE_NUMBER);
callClueRepository.save(clueInfo);
TelephoneCallStopDTO telephoneCallStopDTO = new TelephoneCallStopDTO();
telephoneCallStopDTO.setSessionid(reqId);
telephoneCallStopDTO.setCallId(requestId);
return CommonResponse.createBySuccess(telephoneCallStopDTO);
}
@Override
public CommonResponse<Object> rollCallStop(TelephoneCallStopDTO telephoneCallStopDTO) {
@ -278,17 +296,19 @@ public class TelephoneCallServiceImpl implements TelephoneCallService {
@Override
@Transactional(rollbackFor = Exception.class)
public void rollCallBack(RollCallBackDTO rollCallBackDTO) {
String sessionId = rollCallBackDTO.getSessionid();
String otherLeg = rollCallBackDTO.getOtherLeg();
String traceId = String.valueOf(redisUtils.get(otherLeg));
AllCallInfo allCallInfo = allCallInfoRepository.findBySessionId(otherLeg);
if (ObjectUtil.isNotEmpty(allCallInfo)) {
//相同说明是分机号的回调
if (sessionId.equals(otherLeg) && StrUtil.isNotBlank(rollCallBackDTO.getRecord_file_url())) {
log.info("分机回调-点呼otherLeg:{},详情:{}", otherLeg, rollCallBackDTO);
CommonLog.infoBusinessPartyTypeNewTraceId("分机回调-点呼:" + rollCallBackDTO, BusinessPartyType.DB, traceId);
allCallInfoRepository.updateByRecord(DefaultNumberConstants.ONE_NUMBER, rollCallBackDTO.getRecord_file_url(), allCallInfo.getId());
} else {
log.info("被叫回调-点呼otherLeg:{},详情:{}", otherLeg, rollCallBackDTO);
CommonLog.infoBusinessPartyType("被叫回调-点呼:" + rollCallBackDTO, BusinessPartyType.DB);
UserDto user = userService.findById(allCallInfo.getMemberId());
Long whichUserId = user.getWhichUserId();
boolean status;
@ -298,13 +318,13 @@ public class TelephoneCallServiceImpl implements TelephoneCallService {
callClueRepository.updateByStatus(DefaultNumberConstants.TWO_NUMBER, allCallInfo.getClueId());
allCallInfoRepository.updateByDurationAndStatus(DefaultNumberConstants.TWO_NUMBER, Integer.valueOf(rollCallBackDTO.getDuration()), allCallInfo.getId());
//更新资源通话状态
CompletableFuture.runAsync(() -> updateSourceCallStatus(allCallInfo.getClueId(), DefaultNumberConstants.TWO_NUMBER, allCallInfo.getClueType()));
CompletableFuture.runAsync(() -> updateSourceCallStatus(allCallInfo.getClueId(), DefaultNumberConstants.TWO_NUMBER, allCallInfo.getClueType(), traceId));
//实时扣除话费
callCostCount(allCallInfo.getMemberId(), allCallInfo.getClueId(), allCallInfo.getClueType(), Integer.valueOf(rollCallBackDTO.getDuration()), 2, whichUserId);
status = true;
} else {
//更新资源通话状态
CompletableFuture.runAsync(() -> updateSourceCallStatus(allCallInfo.getClueId(), DefaultNumberConstants.ONE_NUMBER, allCallInfo.getClueType()));
CompletableFuture.runAsync(() -> updateSourceCallStatus(allCallInfo.getClueId(), DefaultNumberConstants.ONE_NUMBER, allCallInfo.getClueType(), traceId));
status = false;
}
if (Arrays.asList(ClueTypeConstants.TOKER_TYPE).contains(allCallInfo.getClueType())) {
@ -322,14 +342,17 @@ public class TelephoneCallServiceImpl implements TelephoneCallService {
* @param clueId ID
* @param status 1 2
*/
private void updateSourceCallStatus(Long clueId, Integer status, Integer clueType) {
private void updateSourceCallStatus(Long clueId, Integer status, Integer clueType, String traceId) {
ClueMiddle clueMiddle = new ClueMiddle();
clueMiddle.setClueId(clueId);
clueMiddle.setClueCallStatus(status);
clueMiddle.setOptimisticVersion(DefaultNumberConstants.THREE_NUMBER);
clueMiddle.setNewestCallTime(new Date());
clueMiddle.setClueType(clueType);
sourceClueClient.update(clueMiddle);
int code = sourceClueClient.update(clueMiddle).getStatus();
if (code != 0) {
CommonLog.infoTraceId("通话同步状态错误", traceId);
}
}
/**
@ -405,6 +428,8 @@ public class TelephoneCallServiceImpl implements TelephoneCallService {
if (num > 0) {
save.setStatus(true);
callDeductRepository.save(save);
} else {
CommonLog.error("话费扣除失败,记录id" + save.getId());
}
// else {
// updateBalance(mul, companyId, version + 1, save);

@ -1,6 +1,5 @@
package com.baiye.module.dao;
import com.baiye.module.entity.ClueMiddle;
import com.baiye.module.entity.TurnoverRecord;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

@ -3,6 +3,7 @@ package com.baiye.task;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baiye.common.CommonLog;
import com.baiye.constant.DefaultNumberConstants;
import com.baiye.enums.ClueStageEnum;
import com.baiye.feign.UserClient;
@ -136,7 +137,6 @@ public class PublicCluePoolSync {
publicCluePool.setStatus(0);
publicCluePoolRepository.save(publicCluePool);
ConductRecord conductRecord = new ConductRecord();
conductRecord.setClueId(clueMiddle.getClueId());
conductRecord.setRecordInfo("移入公海");
@ -151,6 +151,8 @@ public class PublicCluePoolSync {
clueMiddle.setMemberStatus(DefaultNumberConstants.ZERO_NUMBER);
clueMiddle.setOptimisticVersion(clueMiddle.getOptimisticVersion() + 1);
clueMiddleRepository.save(clueMiddle);
CommonLog.info("线索:" + clueMiddle.getClueId() + "移入公海");
}
}
}

Loading…
Cancel
Save