添加话单推送

master
bynt 4 months ago
parent 1f04d9770b
commit fb22369e3d

@ -10,7 +10,7 @@ public class ClueTypeConstants {
} }
public static final Integer[] SCREEN_TYPE = new Integer[]{0, 1, 2, 3, 6, 7}; public static final Integer[] SCREEN_TYPE = new Integer[]{0, 1, 2, 3, 6, 7};
public static final Integer[] TOKER_TYPE = new Integer[]{4, 5}; public static final Integer[] TOKER_TYPE = new Integer[]{4, 5, 9};
public static final Integer[] CLUE_POOL = new Integer[]{0, 8, 1, 3}; public static final Integer[] CLUE_POOL = new Integer[]{0, 8, 1, 3};
public static final Integer[] CRM_TOKER = new Integer[]{6, 7}; public static final Integer[] CRM_TOKER = new Integer[]{6, 7};
} }

@ -0,0 +1,14 @@
package com.baiye.constant;
/**
* @author Enzo
* @date : 2024/4/30
*/
public class ImportExcelConstants {
public static final String NAME = "姓名";
public static final String NID = "电话";
}

@ -15,4 +15,14 @@ public class UrlConstants {
public static String CALL_BACK_CLUE_URL="https://ad.oceanengine.com/open_api/2/tools/clue/callback/"; public static String CALL_BACK_CLUE_URL="https://ad.oceanengine.com/open_api/2/tools/clue/callback/";
public static final String SEND_URL = "https://ai.hzdaba.cn/external/activity/addClient";
public static final String GET_URL = "https://ai.hzdaba.cn/external/activity_statistics";
public static final String TOKEN_URL = "https://ai.hzdaba.cn/external/get/authKey";
public static final String UPDATE_STATUS = "https://ai.hzdaba.cn/external/activity/updateStatus";
} }

@ -0,0 +1,57 @@
package com.baiye.listener;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author Enzo
* @date : 2024/4/29
*/
public class ExcelListener extends AnalysisEventListener<Map<Integer, String>> {
// Excel数据
private List<Map<Integer, Map<Integer, String>>> list;
// Excel列名
private Map<Integer, String> headTitleMap = new HashMap<>();
public ExcelListener() {
list = new ArrayList<>();
}
@Override
public void invoke(Map<Integer, String> data, AnalysisContext context) {
Map<Integer, Map<Integer, String>> map = new HashMap<>();
map.put(context.readRowHolder().getRowIndex(), data);
list.add(map);
}
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
}
@Override
public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) {
headTitleMap = headMap;
}
public List<Map<Integer, Map<Integer, String>>> getList() {
return list;
}
public void setList(List<Map<Integer, Map<Integer, String>>> list) {
this.list = list;
}
public Map<Integer, String> getHeadTitleMap() {
return headTitleMap;
}
public void setHeadTitleMap(Map<Integer, String> headTitleMap) {
this.headTitleMap = headTitleMap;
}
}

@ -23,7 +23,7 @@ public class TripartiteResponseUtil {
} }
public static void transmissionParameter(String taskName, List<String> tagList, List<String> decryptList, String password) { public static void transmissionParameter(Integer type, String taskName, List<String> tagList, List<String> decryptList, String password) {
Map<String, Object> map = Maps.newHashMap(); Map<String, Object> map = Maps.newHashMap();
List<DmpDataDTO> arrayList = Lists.newArrayList(); List<DmpDataDTO> arrayList = Lists.newArrayList();
DmpResponse dmpResponse = new DmpResponse(); DmpResponse dmpResponse = new DmpResponse();
@ -40,6 +40,11 @@ public class TripartiteResponseUtil {
map.put("status", DefaultNumberConstants.TWO_HUNDRED); map.put("status", DefaultNumberConstants.TWO_HUNDRED);
map.put("msg", ResponseCode.SUCCESS.getDesc()); map.put("msg", ResponseCode.SUCCESS.getDesc());
map.put("data", dmpResponse); map.put("data", dmpResponse);
HttpUtil.post("https://api.xiaolanben.com/blue-touch/api/v1/open/ad/dmp/exchange", JSONUtil.toJsonStr(map)); if (type == DefaultNumberConstants.SIX_NUMBER) {
HttpUtil.post("", JSONUtil.toJsonStr(map));
}
if (type == DefaultNumberConstants.THREE_NUMBER) {
HttpUtil.post("https://api.xiaolanben.com/blue-touch/api/v1/open/ad/dmp/exchange", JSONUtil.toJsonStr(map));
}
} }
} }

@ -69,7 +69,7 @@ public class ValidateCodeFilter extends AbstractGatewayFilterFactory<Object> {
try { try {
validateCodeService.checkCapcha(uuid,code); validateCodeService.checkCapcha(uuid,code);
} catch (CaptchaException e) { } catch (CaptchaException e) {
log.info("验证码有误"); log.error("验证码有误");
ServerHttpResponse response = exchange.getResponse(); ServerHttpResponse response = exchange.getResponse();
response.setStatusCode(HttpStatus.PRECONDITION_REQUIRED); response.setStatusCode(HttpStatus.PRECONDITION_REQUIRED);
response.getHeaders().setContentType(MediaType.APPLICATION_JSON); response.getHeaders().setContentType(MediaType.APPLICATION_JSON);

@ -0,0 +1,19 @@
package com.baiye.config.properties;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Getter
@Setter
@Configuration
@ConfigurationProperties(prefix = "urls")
public class UrlsProperties {
/**
*
*/
private String dbPushUrl;
}

@ -0,0 +1,54 @@
package com.baiye.modules.platform.domain;
import com.baiye.model.base.BaseEntity;
import com.baiye.util.JpaConverterAes;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import javax.persistence.*;
import java.io.Serializable;
/**
* @author Enzo
* @date : 2024/4/27
*/
@Setter
@Getter
@Entity
@Table(name = "tb_traffic_material")
@ApiModel(value = "话务材料")
public class TrafficMaterial extends BaseEntity implements Serializable {
private static final long serialVersionUID = 8723232289324510063L;
@Id
@ApiModelProperty(value = "id")
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ApiModelProperty(value = "姓名")
@Column(name = "name")
private String name;
@ApiModelProperty(value = "nid")
@Column(name = "nid")
@Convert(converter = JpaConverterAes.class)
private String nid;
@ApiModelProperty(value = "线索分配人")
private Long userId;
@ApiModelProperty(value = "线索分配人")
private Long taskId;
@ApiModelProperty(value = "其他信息")
private String otherInfo;
}

@ -0,0 +1,15 @@
package com.baiye.modules.platform.repository;
import com.baiye.modules.platform.domain.TrafficMaterial;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;
/**
* @author Enzo
* @date 2024-4-27
*/
@Repository
public interface TrafficMaterialRepository extends JpaRepository<TrafficMaterial, Long>, JpaSpecificationExecutor<TrafficMaterial> {
}

@ -171,10 +171,13 @@ public class TaskController {
public TaskUserDTO findTaskId(@RequestParam(value = "userId") Long userId, @RequestParam("number") Integer number) { public TaskUserDTO findTaskId(@RequestParam(value = "userId") Long userId, @RequestParam("number") Integer number) {
return taskService.queryTaskByUserId(userId, number); return taskService.queryTaskByUserId(userId, number);
} }
@Inner @Inner
@ApiOperation("用户id获取任务id") @ApiOperation("用户id获取任务id")
@GetMapping("/findTaskIdByUserId") @GetMapping("/findTaskIdByUserId")
public Long findTaskIdByUserId(@RequestParam(value = "userId") Long userId, @RequestParam("isForm") Integer isForm) { public Long findTaskIdByUserId(@RequestParam(value = "userId") Long userId, @RequestParam("isForm") Integer isForm) {
return taskService.findTaskIdByUserId(userId, isForm); return taskService.findTaskIdByUserId(userId, isForm);
} }
} }

@ -4,7 +4,7 @@ import com.baiye.http.CommonResponse;
import com.baiye.modules.platform.service.TaskImeiService; import com.baiye.modules.platform.service.TaskImeiService;
import com.baiye.modules.platform.service.TripartiteSourceService; import com.baiye.modules.platform.service.TripartiteSourceService;
import com.baiye.modules.platform.service.dto.PlatformTransmitDTO; import com.baiye.modules.platform.service.dto.PlatformTransmitDTO;
import com.baiye.modules.platform.service.dto.TaskImeiDTO; import com.baiye.modules.platform.service.dto.TaskZDataDTO;
import com.baiye.modules.platform.service.dto.TripartiteTransmitDTO; import com.baiye.modules.platform.service.dto.TripartiteTransmitDTO;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -21,7 +21,7 @@ import org.springframework.web.bind.annotation.*;
@RestController @RestController
@RequiredArgsConstructor @RequiredArgsConstructor
@Api(tags = "系统:角色管理") @Api(tags = "系统:角色管理")
@RequestMapping("/api/taskImei") @RequestMapping("/api/data")
public class TaskImeiController { public class TaskImeiController {
private final TaskImeiService taskImeiService; private final TaskImeiService taskImeiService;
@ -51,8 +51,8 @@ public class TaskImeiController {
@ApiOperation("兑换条数") @ApiOperation("兑换条数")
@PostMapping("/exchange") @PostMapping("/exchange")
public CommonResponse<Object> acceptAdBackSource(@Validated @RequestBody TaskImeiDTO taskImeiDTO) { public CommonResponse<Object> acceptAdBackSource(@Validated @RequestBody TaskZDataDTO taskZDataDTO) {
return taskImeiService.processingData(taskImeiDTO); return taskImeiService.processingData(taskZDataDTO);
} }
} }

@ -0,0 +1,70 @@
package com.baiye.modules.platform.rest;
import com.baiye.annotation.Inner;
import com.baiye.annotation.Log;
import com.baiye.constant.DefaultNumberConstants;
import com.baiye.http.CommonResponse;
import com.baiye.http.ResponseCode;
import com.baiye.modules.platform.service.TelephoneTrafficService;
import com.baiye.util.SecurityUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
/**
* @author Enzo
* @date : 2024/4/27
* ai
*/
@Slf4j
@RestController
@RequiredArgsConstructor
@Api(tags = "话务资源推送")
@RequestMapping("/api/telephone/traffic")
public class TelephoneTrafficController {
private final TelephoneTrafficService telephoneTrafficService;
@ApiOperation("资源文件上传")
@PostMapping("/upload")
@Log("资源文件上传")
public ResponseEntity<Object> clueFileUpload(@RequestParam("file") MultipartFile[] file,
@RequestParam(value = "taskId") Long taskId) {
if (file.length > DefaultNumberConstants.ZERO_NUMBER) {
return new ResponseEntity<>(telephoneTrafficService.uploadFile(file, taskId), HttpStatus.OK);
}
return new ResponseEntity<>(CommonResponse.createBySuccess(ResponseCode.EMPTY_ARGUMENT.getDesc()), HttpStatus.OK);
}
@ApiOperation("修改授权")
@GetMapping("/update")
public ResponseEntity<Object> update(Boolean flag, Long taskId) {
return new ResponseEntity<>(telephoneTrafficService.updateAuthorizationStatus(flag, taskId), HttpStatus.OK);
}
@ApiOperation("获取链接地址")
@GetMapping("/url")
public ResponseEntity<Object> queryUrl() {
return new ResponseEntity<>(telephoneTrafficService.queryUrlByUserId(SecurityUtils.getCurrentUserId()), HttpStatus.OK);
}
@Inner
@ApiOperation("获取链接地址")
@GetMapping("/detail")
public ResponseEntity<Object> detail(@RequestParam Long sourceId) {
return new ResponseEntity<>(telephoneTrafficService.queryById(sourceId), HttpStatus.OK);
}
}

@ -3,6 +3,7 @@ package com.baiye.modules.platform.service;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
import com.baiye.modules.platform.domain.DeliveryRecord; import com.baiye.modules.platform.domain.DeliveryRecord;
import com.baiye.modules.platform.service.dto.ImeiDTO; import com.baiye.modules.platform.service.dto.ImeiDTO;
import com.baiye.modules.platform.service.dto.ZDataDTO;
import java.util.List; import java.util.List;
@ -79,4 +80,15 @@ public interface DeliveryRecordService {
* @return * @return
*/ */
DeliveryRecord queryByDownId(Long downId); DeliveryRecord queryByDownId(Long downId);
/**
* zdata
* @param filterList
* @param batchNo
* @param type
* @param publicKey
* @param privateKey
* @return
*/
Boolean exchangeZDataByInterFace(List<ZDataDTO> filterList, String batchNo, Integer type, String publicKey, String privateKey);
} }

@ -4,7 +4,7 @@ import cn.hutool.core.date.DateTime;
import com.baiye.http.CommonResponse; import com.baiye.http.CommonResponse;
import com.baiye.modules.platform.domain.TaskImei; import com.baiye.modules.platform.domain.TaskImei;
import com.baiye.modules.platform.service.dto.PlatformTransmitDTO; import com.baiye.modules.platform.service.dto.PlatformTransmitDTO;
import com.baiye.modules.platform.service.dto.TaskImeiDTO; import com.baiye.modules.platform.service.dto.TaskZDataDTO;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@ -77,10 +77,10 @@ public interface TaskImeiService {
/** /**
* *
* @param taskImeiDTO * @param taskZDataDTO
* @return * @return
*/ */
CommonResponse<Object> processingData(TaskImeiDTO taskImeiDTO); CommonResponse<Object> processingData(TaskZDataDTO taskZDataDTO);
/** /**
* *

@ -0,0 +1,46 @@
package com.baiye.modules.platform.service;
import com.baiye.model.dto.TelephoneTrafficDTO;
import org.springframework.web.multipart.MultipartFile;
/**
* @author Enzo
* @date : 2024/4/27
*/
public interface TelephoneTrafficService {
/**
*
*
* @param files
* @param taskId
* @return
*/
Boolean uploadFile(MultipartFile[] files, Long taskId);
/**
* ai
*
* @param flag
* @param id
* @return
*/
Boolean updateAuthorizationStatus(Boolean flag, Long id);
/**
*
*
* @param currentUserId
* @return
*/
String queryUrlByUserId(Long currentUserId);
/**
* id
* @param sourceId
* @return
*/
TelephoneTrafficDTO queryById(Long sourceId);
}

@ -0,0 +1,38 @@
package com.baiye.modules.platform.service.dto;
import cn.hutool.core.annotation.Alias;
import lombok.Data;
import java.util.Objects;
/**
* @author Enzo
* @date : 2024/3/4
*/
@Data
public class ImportExcelDTO {
private Long id;
@Alias("姓名")
private String name;
@Alias("电话")
private String nid;
@Alias("其他信息")
private String otherInfo;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ImportExcelDTO dto = (ImportExcelDTO) o;
return Objects.equals(name, dto.name) && Objects.equals(nid, dto.nid);
}
@Override
public int hashCode() {
return Objects.hash(name, nid);
}
}

@ -7,6 +7,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import javax.persistence.Column;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -53,4 +54,12 @@ public class TaskDto implements Serializable {
* *
*/ */
private Integer unassigned; private Integer unassigned;
private Boolean isAiDelivery;
private String actName;
private String actId;
} }

@ -42,7 +42,7 @@ public class TaskTagDto {
private Integer isForm = 0; private Integer isForm = 0;
@ApiModelProperty(value = "是否dmp投放") @ApiModelProperty(value = "是否投放")
private Boolean isDmpDelivery; private Boolean isDmpDelivery;
} }

@ -12,15 +12,19 @@ import java.util.List;
* @date : 2023/1/13 * @date : 2023/1/13
*/ */
@Data @Data
public class TaskImeiDTO { public class TaskZDataDTO {
@NotBlank @NotBlank
@ApiModelProperty(value = "批次号") @ApiModelProperty(value = "批次号")
private String batchNo; private String batchNo;
@NotBlank
@ApiModelProperty(value = "兑换类型 0 imei 1 oaid")
private Integer type;
@NotEmpty @NotEmpty
@ApiModelProperty(value = "兑换数量") @ApiModelProperty(value = "兑换数量")
private List<ImeiDTO> imeiList; private List<ZDataDTO> dataList;
} }

@ -0,0 +1,32 @@
package com.baiye.modules.platform.service.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @author Enzo
* @date : 2022/10/21
*/
@Data
public class ZDataDTO implements Serializable {
private static final long serialVersionUID = -3271582444610218303L;
/**
* This field is used for IMEI exchange in the early stage, and OAID can also be exchanged later
* Enzo
*/
@ApiModelProperty(value = "zid")
private String zid;
@ApiModelProperty(value = "tag")
private String tag;
@ApiModelProperty(value = "time")
private String time;
}

@ -15,6 +15,7 @@ import com.baiye.modules.platform.repository.DeliveryRecordRepository;
import com.baiye.modules.platform.service.DeliveryRecordService; import com.baiye.modules.platform.service.DeliveryRecordService;
import com.baiye.modules.platform.service.dto.ExchangeStripsDTO; import com.baiye.modules.platform.service.dto.ExchangeStripsDTO;
import com.baiye.modules.platform.service.dto.ImeiDTO; import com.baiye.modules.platform.service.dto.ImeiDTO;
import com.baiye.modules.platform.service.dto.ZDataDTO;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -110,4 +111,22 @@ public class DeliveryRecordServiceImpl implements DeliveryRecordService {
} }
return new DeliveryRecord(); return new DeliveryRecord();
} }
@Override
public Boolean exchangeZDataByInterFace(List<ZDataDTO> filterList, String batchNo, Integer type, String publicKey, String privateKey) {
List<ExchangeStripsDTO.Data> list = Lists.newArrayList();
filterList.forEach(imeiDTO -> {
ExchangeStripsDTO.Data data = new ExchangeStripsDTO.Data();
if (StringUtils.isNotBlank(imeiDTO.getZid()) && StringUtils.isNotBlank(imeiDTO.getTag())) {
data.setData(Base64.encode(imeiDTO.getZid().concat(StrPool.COMMA).concat(imeiDTO.getTag())));
list.add(data);
}
});
ExchangeStripsDTO build = ExchangeStripsDTO.builder().batchId(batchNo).reqId
(RandomUtil.randomString(DefaultNumberConstants.TEN_NUMBER)).orgCode
(exchangeProperties.getOrgCode()).datas(list).type(type).build();
String post = HttpUtil.post(exchangeProperties.getSubmitUrl(), JSONUtil.toJsonStr(build));
log.info("============ the submit result as {} =========", JSONUtil.toJsonStr(post));
return Boolean.TRUE;
}
} }

@ -3,12 +3,10 @@ package com.baiye.modules.platform.service.impl;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.text.StrPool;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.baiye.config.properties.DeliveryProperties; import com.baiye.config.properties.DeliveryProperties;
import com.baiye.constant.DefaultNumberConstants; import com.baiye.constant.DefaultNumberConstants;
import com.baiye.http.CommonResponse; import com.baiye.http.CommonResponse;
import com.baiye.model.dto.wechat.SendMailDTO;
import com.baiye.model.enums.ResponseCode; import com.baiye.model.enums.ResponseCode;
import com.baiye.modules.platform.domain.DeliveryRecord; import com.baiye.modules.platform.domain.DeliveryRecord;
@ -114,9 +112,9 @@ public class TaskImeiServiceImpl implements TaskImeiService {
} }
@Override @Override
public CommonResponse<Object> processingData(TaskImeiDTO taskImeiDTO) { public CommonResponse<Object> processingData(TaskZDataDTO dataDTO) {
// imei去除重复重新组装 // imei去除重复重新组装
List<ImeiDTO> dtoList = Lists.newArrayList(Sets.newHashSet(taskImeiDTO.getImeiList())); List<ZDataDTO> dtoList = Lists.newArrayList(Sets.newHashSet(dataDTO.getDataList()));
// 最大最小数量设置 // 最大最小数量设置
if (dtoList.size() < DefaultNumberConstants.ONE_HUNDRED) { if (dtoList.size() < DefaultNumberConstants.ONE_HUNDRED) {
@ -128,39 +126,26 @@ public class TaskImeiServiceImpl implements TaskImeiService {
(DefaultNumberConstants.ZERO_NUMBER, ResponseCode.SEND_MAIL_MAX_NUM_FRIEND.getDesc()); (DefaultNumberConstants.ZERO_NUMBER, ResponseCode.SEND_MAIL_MAX_NUM_FRIEND.getDesc());
} }
if (redisUtils.get(CacheKey.UPLOAD_BATCH.concat(taskImeiDTO.getBatchNo())) != null) { if (redisUtils.get(CacheKey.UPLOAD_BATCH.concat(dataDTO.getBatchNo())) != null) {
List<DeliveryRecord> recordList = deliveryRecordService.findByBatchNo(taskImeiDTO.getBatchNo()); List<DeliveryRecord> recordList = deliveryRecordService.findByBatchNo(dataDTO.getBatchNo());
if (CollUtil.isNotEmpty(recordList)) { if (CollUtil.isNotEmpty(recordList)) {
return CommonResponse.createByErrorCodeMessage return CommonResponse.createByErrorCodeMessage
(DefaultNumberConstants.ZERO_NUMBER, ResponseCode.BATCH_NUMBER_ALREADY_EXISTS.getDesc()); (DefaultNumberConstants.ZERO_NUMBER, ResponseCode.BATCH_NUMBER_ALREADY_EXISTS.getDesc());
} }
} }
dtoList.forEach(o -> o.setImei(AESUtils.decrypt(o.getImei(), deliveryProperties.getExchangePassword()))); dtoList.forEach(o -> o.setZid(AESUtils.decrypt(o.getZid(), deliveryProperties.getExchangePassword())));
// 过滤未解密完成的 // 过滤未解密完成的
List<ImeiDTO> filterList = dtoList.stream().filter List<ZDataDTO> filterList = dtoList.stream().filter
(o -> ObjectUtil.isNotNull(o.getImei())).collect(Collectors.toList()); (o -> ObjectUtil.isNotNull(o.getZid())).collect(Collectors.toList());
if (CollUtil.isNotEmpty(filterList)) { if (CollUtil.isNotEmpty(filterList)) {
log.info("================ the exchange list size as {} =================", filterList.size()); log.info("================ the exchange list size as {} =================", filterList.size());
Boolean result = deliveryRecordService.exchangeZDataByInterFace
// 传输方式 (filterList, dataDTO.getBatchNo(), dataDTO.getType(), deliveryProperties.getPublicKey(), deliveryProperties.getPrivateKey());
Integer type = (Integer) redisUtils.get(CacheKey.DMP_REQUEST_UPLOAD_TYPE);
if (ObjectUtil.isNotNull(type) && type.equals(DefaultNumberConstants.TWO_NUMBER)) {
String file = deliveryProperties.getFileUrl().concat(StrPool.SLASH).concat(taskImeiDTO.getBatchNo());
SendMailDTO sendMailDTO = FileAndMailUtil.zipFileAndSendDMPMail
(filterList, file, taskImeiDTO.getBatchNo(), deliveryProperties, DefaultNumberConstants.TWO_NUMBER);
Long recordId = deliveryRecordService.saveDeliveryRecord(sendMailDTO.getZipPath(), taskImeiDTO.getBatchNo(), null, dtoList.size(),
null, (long) DefaultNumberConstants.ONE_NUMBER, DefaultNumberConstants.THREE_NUMBER, DefaultNumberConstants.ZERO_NUMBER, null);
// 缓存一天
redisUtils.set(CacheKey.UPLOAD_BATCH.concat(taskImeiDTO.getBatchNo()), recordId, DefaultNumberConstants.ONE_NUMBER, TimeUnit.DAYS);
return CommonResponse.createBySuccess(DefaultNumberConstants.TWO_HUNDRED);
}
Boolean result = deliveryRecordService.exchangeByInterFace
(filterList, taskImeiDTO.getBatchNo(), DefaultNumberConstants.ZERO_NUMBER, deliveryProperties.getPublicKey(), deliveryProperties.getPrivateKey());
if (Boolean.TRUE.equals(result)) { if (Boolean.TRUE.equals(result)) {
Long recordId = deliveryRecordService.saveDeliveryRecord(null, taskImeiDTO.getBatchNo(), null, dtoList.size(), Long recordId = deliveryRecordService.saveDeliveryRecord(null, dataDTO.getBatchNo(), null, dtoList.size(),
null, (long) DefaultNumberConstants.ONE_NUMBER, DefaultNumberConstants.THREE_NUMBER, DefaultNumberConstants.ZERO_NUMBER, null); null, (long) DefaultNumberConstants.ONE_NUMBER, DefaultNumberConstants.SIX_NUMBER, dataDTO.getType(), null);
// 缓存一天 // 缓存一天
redisUtils.set(CacheKey.UPLOAD_BATCH.concat(taskImeiDTO.getBatchNo()), recordId, DefaultNumberConstants.ONE_NUMBER, TimeUnit.DAYS); redisUtils.set(CacheKey.UPLOAD_BATCH.concat(dataDTO.getBatchNo()), recordId, DefaultNumberConstants.ONE_NUMBER, TimeUnit.DAYS);
log.info("============= interface sending send recordId {} =============", recordId); log.info("============= interface sending send recordId {} =============", recordId);
} }
} }

@ -403,6 +403,9 @@ public class TaskServiceImpl implements TaskService {
if (task.getLabelOrganizeId() != null) { if (task.getLabelOrganizeId() != null) {
updateTask.setLabelOrganizeId(task.getLabelOrganizeId()); updateTask.setLabelOrganizeId(task.getLabelOrganizeId());
} }
if (task.getIsAiDelivery() != null) {
updateTask.setIsAiDelivery(task.getIsAiDelivery());
}
taskRepository.save(updateTask); taskRepository.save(updateTask);
} }
} else { } else {

@ -0,0 +1,175 @@
package com.baiye.modules.platform.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.text.csv.CsvReader;
import cn.hutool.core.text.csv.CsvUtil;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import com.baiye.config.properties.UrlsProperties;
import com.baiye.constant.*;
import com.baiye.exception.BadRequestException;
import com.baiye.http.PreTestResponse;
import com.baiye.model.dto.TelephoneTrafficDTO;
import com.baiye.modules.agent.entity.ChannelCustom;
import com.baiye.modules.platform.domain.Task;
import com.baiye.modules.platform.domain.TrafficMaterial;
import com.baiye.modules.platform.repository.TrafficMaterialRepository;
import com.baiye.modules.platform.service.TaskService;
import com.baiye.modules.platform.service.TelephoneTrafficService;
import com.baiye.modules.platform.service.dto.ImportExcelDTO;
import com.baiye.modules.platform.service.mapstruct.TrafficMaterialMapper;
import com.baiye.modules.telemarkting.entity.PreTestAccount;
import com.baiye.modules.telemarkting.entity.dto.UpdateTrafficDTO;
import com.baiye.modules.telemarkting.service.PreTestService;
import com.baiye.timed.FileTask;
import com.baiye.util.AESUtils;
import com.baiye.util.FileUtil;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* @author Enzo
* @description
* @date 2024-4-27
**/
@Slf4j
@Service
@RequiredArgsConstructor
public class TelephoneTrafficServiceImpl implements TelephoneTrafficService {
private final TrafficMaterialRepository trafficMaterialRepository;
private final TrafficMaterialMapper trafficMaterialMapper;
private final UrlsProperties urlsProperties;
private final PreTestService preTestService;
private final TaskService taskService;
private final FileTask fileTask;
@Value("${snowflake.workerId}")
private int workerId;
@Value("${snowflake.datacenterId}")
private int datacenterId;
@Override
public Boolean uploadFile(MultipartFile[] files, Long taskId) {
Set<ImportExcelDTO> dtoList = Sets.newHashSet();
Task task = taskService.queryDetails(taskId);
if (ObjectUtil.isNotNull(task) && task.getIsAiDelivery().equals(Boolean.TRUE)) {
throw new BadRequestException("当前任务未关闭 请关闭后进行导入操作!");
}
for (MultipartFile file : files) {
// 解析数据
String originalFilename = file.getOriginalFilename();
if (StringUtils.isNotBlank(originalFilename)) {
dtoList.addAll(parseFile(file, originalFilename));
}
}
PreTestAccount dbAccount = preTestService.accountQuery();
if (ObjectUtil.isNull(dbAccount) || StringUtils.isBlank(dbAccount.getToken())) {
throw new BadRequestException("未配置预测试账号!");
}
// 保存数据
fileTask.runFileAnalysisTask(dtoList, task, dbAccount.getToken());
return Boolean.TRUE;
}
private Set<ImportExcelDTO> parseFile(MultipartFile file, String originalFilename) {
List<ImportExcelDTO> dtoList = Lists.newArrayList();
List<Map<String, Object>> maps = Lists.newArrayList();
// 解析 文件
File upload = FileUtil.multiToFile(file);
if (ObjectUtil.isNotNull(upload)) {
if (originalFilename.endsWith(FileConstant.XLS_FILE_SUB_NAME)
|| originalFilename.endsWith(FileConstant.XLSX_FILE_SUB_NAME)) {
ExcelReader reader = ExcelUtil.getReader(upload);
maps = reader.readAll();
}
if (originalFilename.endsWith(FileConstant.CSV_FILE_SUB_NAME)) {
// TODO
CsvReader reader = CsvUtil.getReader();
Convert.toList(Map.class, reader.readMapList(FileUtil.getReader(upload, CharsetUtil.CHARSET_UTF_8)));
}
for (Map<String, Object> map : maps) {
long nextId = IdUtil.getSnowflake(workerId, datacenterId).nextId();
ImportExcelDTO dto = new ImportExcelDTO();
Map<String, Object> hashMap = Maps.newHashMap(map);
dto.setId(nextId);
Object name = hashMap.getOrDefault(ImportExcelConstants.NAME, CharSequenceUtil.EMPTY);
dto.setName(ObjectUtil.isNotNull(name) ? name.toString() : CharSequenceUtil.EMPTY);
hashMap.remove(ImportExcelConstants.NAME);
Object nid = hashMap.getOrDefault(ImportExcelConstants.NID, CharSequenceUtil.EMPTY);
dto.setNid(ObjectUtil.isNotNull(nid) ? nid.toString() : CharSequenceUtil.EMPTY);
hashMap.remove(ImportExcelConstants.NID);
dto.setOtherInfo(hashMap.entrySet().toString());
dtoList.add(dto);
}
}
return Sets.newHashSet(dtoList);
}
@Override
public Boolean updateAuthorizationStatus(Boolean flag, Long id) {
Task task = taskService.queryDetails(id);
if (ObjectUtil.isNotNull(task) && !task.getIsAiDelivery().equals(flag)) {
PreTestAccount dbAccount = preTestService.accountQuery();
if (ObjectUtil.isNotNull(dbAccount) && StringUtils.isNotBlank(dbAccount.getToken())) {
UpdateTrafficDTO build = UpdateTrafficDTO.builder().actId(task.getActId()).status
(flag.equals(Boolean.TRUE) ? DefaultNumberConstants.ONE_NUMBER : DefaultNumberConstants.ZERO_NUMBER).authKey(dbAccount.getToken()).build();
String body = HttpUtil.post(UrlConstants.UPDATE_STATUS, JSONUtil.toJsonStr(build));
log.info("====================== the log response {} ======================", body);
if (JSONUtil.isJson(body)) {
PreTestResponse bean = JSONUtil.toBean(body, PreTestResponse.class);
if (ObjectUtil.isNotNull(bean) && bean.getResult().equals(Boolean.TRUE)) {
task.setIsAiDelivery(flag);
taskService.updateTask(task);
return Boolean.TRUE;
}
}
}
}
return Boolean.FALSE;
}
@Override
public String queryUrlByUserId(Long currentUserId) {
String baseUtl = urlsProperties.getDbPushUrl();
String encrypt = AESUtils.encrypt(currentUserId.toString(), AdPlatFormConstants.AD_PLATFORM);
return baseUtl.concat(ObjectUtil.isNotNull(encrypt) ? encrypt : CharSequenceUtil.EMPTY).concat("?dataType=detail&encrypt=1");
}
@Override
public TelephoneTrafficDTO queryById(Long sourceId) {
return trafficMaterialMapper.toDto(trafficMaterialRepository.findById(sourceId).orElse(new TrafficMaterial()));
}
}

@ -0,0 +1,30 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.baiye.modules.platform.service.mapstruct;
import com.baiye.model.base.BaseMapper;
import com.baiye.model.dto.TelephoneTrafficDTO;
import com.baiye.modules.platform.domain.TrafficMaterial;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @author ENZO
*
*/
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface TrafficMaterialMapper extends BaseMapper<TelephoneTrafficDTO, TrafficMaterial> {
}

@ -49,7 +49,7 @@ public class CallImportDTO {
private String variable; private String variable;
// private List<Variable> variableList; private List<Variable> variableList;
} }

@ -0,0 +1,28 @@
package com.baiye.modules.telemarkting.entity.dto;
import lombok.Builder;
import lombok.Data;
/**
* @author wjt
* @date 2023/11/13
*/
@Data
@Builder
public class UpdateTrafficDTO {
/**
* token
*/
private String authKey;
/**
*
*/
private String actId;
/**
*
*/
private Integer status;
}

@ -4,6 +4,7 @@ import cn.hutool.http.HttpRequest;
import cn.hutool.json.JSONArray; import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.baiye.constant.UrlConstants;
import com.baiye.exception.BadRequestException; import com.baiye.exception.BadRequestException;
import com.baiye.http.PreTestResponse; import com.baiye.http.PreTestResponse;
import com.baiye.modules.telemarkting.entity.dto.CallImportDTO; import com.baiye.modules.telemarkting.entity.dto.CallImportDTO;
@ -18,15 +19,13 @@ import org.springframework.stereotype.Component;
@Slf4j @Slf4j
@Component @Component
public class PreTestReq { public class PreTestReq {
String sendUrl = "https://ai.hzdaba.cn/external/activity/addClient";
String getUrl = "https://ai.hzdaba.cn/external/activity_statistics";
String tokenUrl = "https://ai.hzdaba.cn/external/get/authKey";
/** /**
* *
*/ */
public Boolean sendDaBa(CallImportDTO callImportDTO) { public Boolean sendDaBa(CallImportDTO callImportDTO) {
String body = sendCallReq(sendUrl, JSONUtil.toJsonStr(callImportDTO)); String body = sendCallReq(UrlConstants.SEND_URL, JSONUtil.toJsonStr(callImportDTO));
PreTestResponse response = JSONUtil.toBean(body, PreTestResponse.class); PreTestResponse response = JSONUtil.toBean(body, PreTestResponse.class);
if (!response.getResult()) { if (!response.getResult()) {
log.info("导入失败 参数{}, 返回结果{}", JSONUtil.toJsonStr(callImportDTO), JSONUtil.toJsonStr(response)); log.info("导入失败 参数{}, 返回结果{}", JSONUtil.toJsonStr(callImportDTO), JSONUtil.toJsonStr(response));
@ -45,7 +44,7 @@ public class PreTestReq {
json.putOpt("status", 0); json.putOpt("status", 0);
json.putOpt("pageNum", 1); json.putOpt("pageNum", 1);
json.putOpt("pageSize", 10); json.putOpt("pageSize", 10);
String body = sendCallReq(getUrl, JSONUtil.toJsonStr(json)); String body = sendCallReq(UrlConstants.GET_URL, JSONUtil.toJsonStr(json));
PreTestResponse response = JSONUtil.toBean(body, PreTestResponse.class); PreTestResponse response = JSONUtil.toBean(body, PreTestResponse.class);
if (response.getResult()) { if (response.getResult()) {
return JSONUtil.parseArray(response.getData()); return JSONUtil.parseArray(response.getData());
@ -62,7 +61,7 @@ public class PreTestReq {
JSONObject json = new JSONObject(8); JSONObject json = new JSONObject(8);
json.putOpt("username", username); json.putOpt("username", username);
json.putOpt("password", password); json.putOpt("password", password);
String body = sendCallReq(tokenUrl, JSONUtil.toJsonStr(json)); String body = sendCallReq(UrlConstants.TOKEN_URL, JSONUtil.toJsonStr(json));
PreTestResponse response = JSONUtil.toBean(body, PreTestResponse.class); PreTestResponse response = JSONUtil.toBean(body, PreTestResponse.class);
if (response.getResult()) { if (response.getResult()) {
return String.valueOf(response.getData()); return String.valueOf(response.getData());

@ -0,0 +1,112 @@
package com.baiye.timed;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import com.baiye.constant.DefaultNumberConstants;
import com.baiye.constant.UrlConstants;
import com.baiye.modules.platform.domain.Task;
import com.baiye.modules.platform.domain.TrafficMaterial;
import com.baiye.modules.platform.repository.TrafficMaterialRepository;
import com.baiye.modules.platform.service.TaskService;
import com.baiye.modules.platform.service.dto.ImportExcelDTO;
import com.baiye.modules.telemarkting.entity.dto.CallImportDTO;
import com.google.common.collect.Lists;
import com.sun.org.apache.xalan.internal.XalanConstants;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
* @author Enzo
* @date : 2024/4/27
*/
@Slf4j
@Component
@RequiredArgsConstructor
public class FileTask {
@Value(value = "${inter.sendClientAddress}")
private String sendClientAddress;
private final TaskService taskService;
private final TrafficMaterialRepository trafficMaterialRepository;
@Async(value = "WorkExecutor")
@Transactional(rollbackFor = Exception.class)
public void runFileAnalysisTask(Set<ImportExcelDTO> dtoSet, Task task, String token) {
log.info("================== run task begin time {} ==================", DateUtil.now());
CallImportDTO dto = new CallImportDTO();
Long taskId = task.getId();
int count = DefaultNumberConstants.ZERO_NUMBER;
// 去除空字符串
List<ImportExcelDTO> dtoList = Lists.newArrayList(dtoSet).stream().filter(str -> StringUtils.isNotBlank(str.getNid())).collect(Collectors.toList());
List<List<ImportExcelDTO>> partition = Lists.partition(dtoList, DefaultNumberConstants.ONE_THOUSAND);
if (ObjectUtil.isNotNull(task) && ObjectUtil.isNotNull(task.getActId())) {
// 调用推送地址进行推送
for (List<ImportExcelDTO> list : partition) {
List<CallImportDTO.Source> sendClientList = Lists.newArrayList();
try {
list.forEach(str -> {
if (StringUtils.isNotBlank(str.getNid())) {
CallImportDTO.Source client = new CallImportDTO.Source();
client.setCellphone(str.getNid());
List<CallImportDTO.Variable> variableList = Lists.newArrayList();
CallImportDTO.Variable taskVariable =
CallImportDTO.Variable.builder().field
("taskId").value(taskId.toString()).build();
CallImportDTO.Variable sourceVariable =
CallImportDTO.Variable.builder().field
("sourceId").value(str.getId().toString()).build();
variableList.add(taskVariable);
variableList.add(sourceVariable);
client.setCellphone(str.getNid());
client.setVariableList(variableList);
sendClientList.add(client);
}
});
dto.setAuthKey(token);
dto.setActId(task.getActId());
dto.setActName(task.getActName());
dto.setClientList(sendClientList);
log.info("============ the request as {} =========", JSONUtil.toJsonStr(dto));
String post = HttpUtil.post(UrlConstants.SEND_URL, JSONUtil.toJsonStr(dto));
if (post.contains(XalanConstants.FEATURE_TRUE)) {
count += list.size();
}
log.info("============ the submit result as {} =========", JSONUtil.toJsonStr(post));
if (count > DefaultNumberConstants.ZERO_NUMBER) {
// 保存数据
List<TrafficMaterial> saveList = Lists.newArrayList();
list.forEach(tf -> {
TrafficMaterial material = new TrafficMaterial();
material.setTaskId(taskId);
material.setId(tf.getId());
material.setNid(tf.getNid());
material.setName(tf.getName());
material.setUserId(task.getCreateBy());
saveList.add(material);
});
trafficMaterialRepository.saveAll(saveList);
}
} catch (Exception exception) {
// TODO throw new exception
log.error("============ the request exception {} ============", exception.getMessage());
}
}
}
log.info("================== run task end time {} ==================", DateUtil.now());
}
}

@ -68,6 +68,8 @@ spring:
config: config:
multi-statement-allow: true multi-statement-allow: true
jpa:
show-sql: false
# 登录相关配置 # 登录相关配置
login: login:
@ -217,7 +219,7 @@ ocean:
engine: engine:
appId: 1744002574259247 appId: 1744002574259247
appSecret: f1bef553cd635b7cd8057052654ebaaa30fa92a5 appSecret: f1bef553cd635b7cd8057052654ebaaa30fa92a5
redirectUrl: http:///39.100.77.21:8866/api/oceanEngine/callback redirectUrl: http://39.100.77.21:8866/api/oceanEngine/callback
welcomeUrl: https://baiyee.vip/ welcomeUrl: https://baiyee.vip/
ad-back: ad-back:
@ -242,3 +244,6 @@ exchange:
org-code: org_by_test org-code: org_by_test
callback-url: http://proxy.hzdaba.cn:58888/pub/data/set callback-url: http://proxy.hzdaba.cn:58888/pub/data/set
submit-url: http://proxy.hzdaba.cn:58888/pub/data/submit submit-url: http://proxy.hzdaba.cn:58888/pub/data/submit
urls:
dbPushUrl: http://39.100.77.21:8899/source/traffic/v1/exchange/callback/

@ -235,3 +235,6 @@ channel:
logstash: logstash:
url: 127.0.0.1:5044 url: 127.0.0.1:5044
urls:
dbPushUrl: https://baiyee.vip/source/traffic/v1/exchange/callback/

@ -52,7 +52,7 @@ security:
- /operlog - /operlog
- /logininfor - /logininfor
- /oauth/check_token - /oauth/check_token
- /api/taskImei/** - /api/data/exchange
- /pay/aliPay/pay-notify - /pay/aliPay/pay-notify
- /api/oceanEngine/callback - /api/oceanEngine/callback
- /api/back/cdrUrl - /api/back/cdrUrl

@ -0,0 +1,47 @@
package com.baiye.model.dto;
import lombok.Data;
import java.util.Map;
/**
* @author Enzo
* @date 2023-12-6
*/
@Data
public class PushClueDTO {
private String remark;
/**
* , mobile
*/
private String called;
/**
* id
*/
private String recId;
/**
* 线ID
*/
private Long variable;
/**
* nid
*/
private String mobile;
private String empClientTypeName;
private Map<String, String> clientVariables;
}

@ -0,0 +1,51 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.baiye.model.dto;
import com.baiye.util.JpaConverterAes;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.persistence.*;
import java.io.Serializable;
/**
* @author Zheng Jie
* @date 2018-11-23
*/
@Data
public class TelephoneTrafficDTO implements Serializable {
@ApiModelProperty(value = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ApiModelProperty(value = "姓名")
private String name;
@ApiModelProperty(value = "nid")
@Convert(converter = JpaConverterAes.class)
private String nid;
@ApiModelProperty(value = "线索分配人")
private Long userId;
@ApiModelProperty(value = "线索分配人")
private Long taskId;
@ApiModelProperty(value = "其他信息")
private String otherSource;
}

@ -98,4 +98,20 @@ public class BaseTask implements Serializable {
private Boolean isDmpDelivery = Boolean.TRUE; private Boolean isDmpDelivery = Boolean.TRUE;
@ApiModelProperty(value = "是否开启话务投送")
@Column(name = "is_ai_delivery")
private Boolean isAiDelivery = Boolean.FALSE;
@Column(name = "act_name")
@ApiModelProperty(value = "活动名称")
private String actName;
@ApiModelProperty(value = "活动id")
@Column(name = "act_id")
private String actId;
} }

@ -4,11 +4,13 @@ import com.baiye.constant.SecurityConstants;
import com.baiye.feign.fallback.PreTestClientFallback; import com.baiye.feign.fallback.PreTestClientFallback;
import com.baiye.model.dto.AddSourceDTO; import com.baiye.model.dto.AddSourceDTO;
import com.baiye.model.dto.AddWeChatFriendRecordDTO; import com.baiye.model.dto.AddWeChatFriendRecordDTO;
import com.baiye.model.dto.TelephoneTrafficDTO;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
/** /**
* @author Enzo * @author Enzo
@ -29,4 +31,17 @@ public interface PreTestClient {
@GetMapping( "/api/add/source") @GetMapping( "/api/add/source")
ResponseEntity<AddWeChatFriendRecordDTO> addSource(@RequestBody AddSourceDTO source, @RequestHeader(SecurityConstants.FROM) String from); ResponseEntity<AddWeChatFriendRecordDTO> addSource(@RequestBody AddSourceDTO source, @RequestHeader(SecurityConstants.FROM) String from);
/**
* Id线Id
* @param sourceId
* @param from
* @return
*/
@GetMapping("/api/telephone/traffic/detail")
ResponseEntity<TelephoneTrafficDTO> findByDetail(@RequestParam("sourceId") Long sourceId, @RequestHeader(SecurityConstants.FROM) String from);
} }

@ -3,6 +3,7 @@ package com.baiye.feign.fallback;
import com.baiye.feign.PreTestClient; import com.baiye.feign.PreTestClient;
import com.baiye.model.dto.AddSourceDTO; import com.baiye.model.dto.AddSourceDTO;
import com.baiye.model.dto.AddWeChatFriendRecordDTO; import com.baiye.model.dto.AddWeChatFriendRecordDTO;
import com.baiye.model.dto.TelephoneTrafficDTO;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -18,4 +19,9 @@ public class PreTestClientFallback implements PreTestClient {
public ResponseEntity<AddWeChatFriendRecordDTO> addSource(AddSourceDTO source, String from) { public ResponseEntity<AddWeChatFriendRecordDTO> addSource(AddSourceDTO source, String from) {
return null; return null;
} }
@Override
public ResponseEntity<TelephoneTrafficDTO> findByDetail(Long sourceId, String from) {
return null;
}
} }

@ -0,0 +1,35 @@
package com.baiye.module.controller;
import cn.hutool.json.JSONUtil;
import com.baiye.annotation.Log;
import com.baiye.model.dto.PushClueDTO;
import com.baiye.module.service.TrafficCallbackService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
/**
* @author Enzo
* @date : 2023/3/2
*/
@Slf4j
@RestController
@RequestMapping("/traffic/v1/exchange")
@RequiredArgsConstructor
public class TrafficCallbackController {
private final TrafficCallbackService trafficCallbackService;
@Log("推送资源")
@PostMapping("/callback")
public ResponseEntity<String> pushClue(@RequestBody String body) {
log.info("=============== the push body {} ==============", JSONUtil.toJsonStr(body));
PushClueDTO pushClueDTO = JSONUtil.toBean(body, PushClueDTO.class);
return new ResponseEntity<>(Boolean.TRUE.equals(trafficCallbackService.callbackByAppKeyAndNid(pushClueDTO)) ? HttpStatus.OK : HttpStatus.BAD_REQUEST);
}
}

@ -30,7 +30,10 @@ import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.*; import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/** /**
* @Author YQY * @Author YQY
@ -56,10 +59,10 @@ public class ClueQueryDSL {
public List<ClueDto> getCRMClueList(ClueQueryCriteria clueQueryCriteria, Pageable pageable) { public List<ClueDto> getCRMClueList(ClueQueryCriteria clueQueryCriteria, Pageable pageable) {
JPAQuery<ClueDto> query = JPAQuery<ClueDto> query =
jpaQueryFactory.select( jpaQueryFactory.select(
Projections.bean( Projections.bean(
ClueDto.class, ClueDto.class,
cluePojo(DefaultNumberConstants.ONE_NUMBER) cluePojo(DefaultNumberConstants.ONE_NUMBER)
)).from(qClue) )).from(qClue)
.innerJoin(qClueMiddle) .innerJoin(qClueMiddle)
.on(qClue.id.eq(qClueMiddle.clueId)) .on(qClue.id.eq(qClueMiddle.clueId))
.where(this.builder(clueQueryCriteria, DefaultNumberConstants.ONE_NUMBER)) .where(this.builder(clueQueryCriteria, DefaultNumberConstants.ONE_NUMBER))
@ -75,8 +78,8 @@ public class ClueQueryDSL {
*/ */
public Long getCRMCount(ClueQueryCriteria clueQueryCriteria) { public Long getCRMCount(ClueQueryCriteria clueQueryCriteria) {
return jpaQueryFactory.select( return jpaQueryFactory.select(
QClue.clue.count() QClue.clue.count()
).from(QClue.clue) ).from(QClue.clue)
.innerJoin(QClueMiddle.clueMiddle) .innerJoin(QClueMiddle.clueMiddle)
.on(QClue.clue.id.eq(QClueMiddle.clueMiddle.clueId)) .on(QClue.clue.id.eq(QClueMiddle.clueMiddle.clueId))
.where(this.builder(clueQueryCriteria, DefaultNumberConstants.ONE_NUMBER)) .where(this.builder(clueQueryCriteria, DefaultNumberConstants.ONE_NUMBER))
@ -89,10 +92,10 @@ public class ClueQueryDSL {
public List<ClueDto> getTalkClueList(ClueQueryCriteria clueQueryCriteria, Pageable pageable) { public List<ClueDto> getTalkClueList(ClueQueryCriteria clueQueryCriteria, Pageable pageable) {
JPAQuery<ClueDto> query = JPAQuery<ClueDto> query =
jpaQueryFactory.select( jpaQueryFactory.select(
Projections.bean( Projections.bean(
ClueDto.class, ClueDto.class,
cluePojo(DefaultNumberConstants.TWO_NUMBER) cluePojo(DefaultNumberConstants.TWO_NUMBER)
)).from(qClue) )).from(qClue)
.innerJoin(qClueTalk) .innerJoin(qClueTalk)
.on(qClue.id.eq(qClueTalk.clueId)) .on(qClue.id.eq(qClueTalk.clueId))
.where(this.builder(clueQueryCriteria, DefaultNumberConstants.TWO_NUMBER)) .where(this.builder(clueQueryCriteria, DefaultNumberConstants.TWO_NUMBER))
@ -108,8 +111,8 @@ public class ClueQueryDSL {
*/ */
public Long getTalkCount(ClueQueryCriteria clueQueryCriteria) { public Long getTalkCount(ClueQueryCriteria clueQueryCriteria) {
return jpaQueryFactory.select( return jpaQueryFactory.select(
QClue.clue.count() QClue.clue.count()
).from(QClue.clue) ).from(QClue.clue)
.innerJoin(QClueTalk.clueTalk) .innerJoin(QClueTalk.clueTalk)
.on(QClue.clue.id.eq(QClueTalk.clueTalk.clueId)) .on(QClue.clue.id.eq(QClueTalk.clueTalk.clueId))
.where(this.builder(clueQueryCriteria, DefaultNumberConstants.TWO_NUMBER)) .where(this.builder(clueQueryCriteria, DefaultNumberConstants.TWO_NUMBER))
@ -290,16 +293,16 @@ public class ClueQueryDSL {
*/ */
public List<ResSourceLabel> findSourceLabel(List<Long> clueIds) { public List<ResSourceLabel> findSourceLabel(List<Long> clueIds) {
return jpaQueryFactory.select( return jpaQueryFactory.select(
Projections.bean( Projections.bean(
ResSourceLabel.class, ResSourceLabel.class,
qClue.nid, qClue.nid,
qClue.createTime, qClue.createTime,
qClue.name, qClue.name,
qClueMiddle.clueId, qClueMiddle.clueId,
qClueMiddle.remark, qClueMiddle.remark,
qClueMiddle.sourceLabel, qClueMiddle.sourceLabel,
qClueMiddle.clueStage qClueMiddle.clueStage
)).from(qClue) )).from(qClue)
.innerJoin(qClueMiddle) .innerJoin(qClueMiddle)
.on(qClue.id.eq(qClueMiddle.clueId)) .on(qClue.id.eq(qClueMiddle.clueId))
.where(qClueMiddle.clueId.in(clueIds)) .where(qClueMiddle.clueId.in(clueIds))

@ -10,7 +10,6 @@ import com.baiye.module.service.dto.ClueRecordCriteria;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -243,4 +242,19 @@ public interface ClueService {
* @return * @return
*/ */
Map<Long, String> saveClueTalk(List<String> onLineNotblackList, List<String> tagList, Long taskId, Long userId, Integer number, Long memberId, Integer status); Map<Long, String> saveClueTalk(List<String> onLineNotblackList, List<String> tagList, Long taskId, Long userId, Integer number, Long memberId, Integer status);
/**
*
*
* @param phone
* @param taskId
* @param userId
* @param otherSource
* @param numer
* @param zeroNumber
* @param remark
* @param memberId
* @return
*/
Boolean saveSingleClueTalk(String phone, Long taskId, Long userId, String otherSource, Integer numer, Integer zeroNumber, String remark, Long memberId);
} }

@ -0,0 +1,18 @@
package com.baiye.module.service;
import com.baiye.model.dto.PushClueDTO;
/**
* @author Enzo
* @date : 2023/3/2
*/
public interface TrafficCallbackService {
/**
*
*
* @param dto
* @return
*/
Boolean callbackByAppKeyAndNid(PushClueDTO dto);
}

@ -1139,6 +1139,24 @@ public class ClueServiceImpl implements ClueService {
return map; return map;
} }
@Override
public Boolean saveSingleClueTalk(String phone, Long taskId, Long userId, String otherSource, Integer numer, Integer zeroNumber, String remark, Long memberId) {
Clue clue = new Clue();
NidLocation byPhone = nidLocationService.findByPhone(phone.substring(DefaultNumberConstants.ZERO_NUMBER, DefaultNumberConstants.SEVEN_NUMBER));
clue.setAddress(ObjectUtil.isNotNull(byPhone) && StringUtils.isNotBlank(byPhone.getProvince())
&& StringUtils.isNotBlank(byPhone.getCity()) ? byPhone.getProvince().concat(byPhone.getCity()) : CharSequenceUtil.EMPTY);
clue.setIsEncryption(DefaultNumberConstants.ONE_NUMBER);
clue.setCastInfo(otherSource);
clue.setCreateBy(userId);
clue.setRouteId(0L);
clue.setNid(phone);
Clue save = clueRepository.save(clue);
ClueTalk clueTalk = new ClueTalk(save.getId(), taskId, zeroNumber, 0, 0, 0, numer, new Date(), memberId);
clueTalk.setRemark(remark);
return clueTalkRepository.save(clueTalk).getClueId() != null;
}
/** /**
* *
*/ */

@ -132,9 +132,11 @@ public class DmpCallbackServiceImpl implements DmpCallbackService {
} }
} }
// 兑换结果失败也将结果返回 // 兑换结果失败也将结果返回
if (byTaskName.getType() == DefaultNumberConstants.THREE_NUMBER) { if (byTaskName.getType() == DefaultNumberConstants.THREE_NUMBER
sendRequest(bathNo, tagList, responseList); || byTaskName.getType() == DefaultNumberConstants.SIX_NUMBER ) {
sendRequest(byTaskName.getType(), bathNo, tagList, responseList);
} }
} finally { } finally {
lock.unlock(); lock.unlock();
} }
@ -179,8 +181,8 @@ public class DmpCallbackServiceImpl implements DmpCallbackService {
} }
private void sendRequest(String taskName, List<String> tagList, List<String> decryptList) { private void sendRequest(Integer type, String taskName, List<String> tagList, List<String> decryptList) {
TripartiteResponseUtil.transmissionParameter(taskName, tagList, decryptList, deliveryProperties.getExchangePassword()); TripartiteResponseUtil.transmissionParameter(type, taskName, tagList, decryptList, deliveryProperties.getExchangePassword());
deliveryRecordService.updateStatusByTaskName(DefaultNumberConstants.ONE_NUMBER, decryptList.size(), taskName); deliveryRecordService.updateStatusByTaskName(DefaultNumberConstants.ONE_NUMBER, decryptList.size(), taskName);
} }

@ -0,0 +1,97 @@
package com.baiye.module.service.impl;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baiye.constant.DefaultNumberConstants;
import com.baiye.constant.SecurityConstants;
import com.baiye.feign.PreTestClient;
import com.baiye.feign.TaskClient;
import com.baiye.model.dto.PushClueDTO;
import com.baiye.model.dto.TelephoneTrafficDTO;
import com.baiye.module.entity.Task;
import com.baiye.module.service.ClueService;
import com.baiye.module.service.TrafficCallbackService;
import com.baiye.util.DecryptPnoUtil;
import com.baiye.util.RedisUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
* @author Enzo
* @date : 2022/11/24
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class TrafficCallbackServiceImpl implements TrafficCallbackService {
private final TaskClient taskClient;
private final RedisUtils redisUtils;
private final ClueService clueService;
private final PreTestClient preTestClient;
@Override
public Boolean callbackByAppKeyAndNid(PushClueDTO dto) {
String recId = dto.getRecId();
String called = dto.getCalled();
String remark = dto.getRemark();
String phone = CharSequenceUtil.EMPTY;
String typeName = dto.getEmpClientTypeName();
if (StringUtils.isNotBlank(dto.getMobile())) {
phone = Base64.decodeStr(dto.getMobile());
}
// 格式校验
if (StringUtils.isNotBlank(called) && StringUtils.isNotBlank(typeName)
&& "A".equalsIgnoreCase(typeName)) {
phone = called.length() > DefaultNumberConstants.ELEVEN_NUMBER
? DecryptPnoUtil.decryptPno(called) : called;
}
if (StringUtils.isNotBlank(phone)) {
Map<String, String> clientVariables = dto.getClientVariables();
String taskId = clientVariables.getOrDefault("taskId", CharSequenceUtil.EMPTY);
String sourceId = clientVariables.getOrDefault("sourceId", CharSequenceUtil.EMPTY);
if (CharSequenceUtil.isNotBlank(taskId) && CharSequenceUtil.isNotBlank(sourceId)) {
// 已经存在的不进行操作
if (StringUtils.isNotBlank(recId) && ObjectUtil.isNotNull(redisUtils.get(recId))) {
// TODO Do not modify for the time being
return Boolean.TRUE;
}
Long id = Long.parseLong(taskId);
Task task = findByTaskId(id);
if (ObjectUtil.isNotNull(task)) {
TelephoneTrafficDTO telephoneTrafficDTO = preTestClient.findByDetail(Long.parseLong(sourceId), SecurityConstants.FROM_IN).getBody();
if (ObjectUtil.isNotNull(telephoneTrafficDTO)) {
clueService.saveSingleClueTalk
(phone, id, task.getCreateBy(), telephoneTrafficDTO.getOtherSource(), DefaultNumberConstants.NINE_NUMBER, DefaultNumberConstants.ZERO_NUMBER, remark, null);
}
}
if (StringUtils.isNotBlank(recId)) {
// 缓存三天
redisUtils.set(recId, phone, DefaultNumberConstants.THREE_NUMBER, TimeUnit.DAYS);
}
}
}
return Boolean.TRUE;
}
public Task findByTaskId(Long taskId) {
Task body = taskClient.queryDetails(taskId, SecurityConstants.FROM_IN).getBody();
if (body != null) {
return body;
}
return null;
}
}

@ -129,7 +129,7 @@ public class MailSourceTask {
downResource(taskName, byTaskName, decryptList, path, data.getRows(), parseFile); downResource(taskName, byTaskName, decryptList, path, data.getRows(), parseFile);
} }
if (byTaskName.getType() == DefaultNumberConstants.THREE_NUMBER) { if (byTaskName.getType() == DefaultNumberConstants.THREE_NUMBER) {
sendRequest(taskName, tagList, decryptList, path, unzipPath); sendRequest(byTaskName.getType(), taskName, tagList, decryptList, path, unzipPath);
} }
FileUtil.del(path); FileUtil.del(path);
} }
@ -178,8 +178,8 @@ public class MailSourceTask {
deliveryRecordClient.updatePath(path, deliveryProperties.getDmpDownPath().concat(filePath), byTaskName.getDownId(), SecurityConstants.FROM_IN); deliveryRecordClient.updatePath(path, deliveryProperties.getDmpDownPath().concat(filePath), byTaskName.getDownId(), SecurityConstants.FROM_IN);
} }
private void sendRequest(String taskName, List<String> tagList, List<String> decryptList, String path, String unzipPath) { private void sendRequest(Integer type, String taskName, List<String> tagList, List<String> decryptList, String path, String unzipPath) {
TripartiteResponseUtil.transmissionParameter(taskName, tagList, decryptList, deliveryProperties.getExchangePassword()); TripartiteResponseUtil.transmissionParameter(type, taskName, tagList, decryptList, deliveryProperties.getExchangePassword());
deliveryRecordService.updateStatusByTaskName(DefaultNumberConstants.ONE_NUMBER, decryptList.size(), taskName); deliveryRecordService.updateStatusByTaskName(DefaultNumberConstants.ONE_NUMBER, decryptList.size(), taskName);
log.info("============== message parsing succeeded file path as {} unzip path as {} ===============", path, unzipPath); log.info("============== message parsing succeeded file path as {} unzip path as {} ===============", path, unzipPath);
} }

@ -5,7 +5,8 @@ spring:
discovery: discovery:
# server-addr: ${NACOS_HOST:8.130.96.163}:${NACOS_PORT:8848} # server-addr: ${NACOS_HOST:8.130.96.163}:${NACOS_PORT:8848}
server-addr: ${NACOS_HOST:localhost}:${NACOS_PORT:8848} server-addr: ${NACOS_HOST:localhost}:${NACOS_PORT:8848}
jpa:
show-sql: false
redis: redis:
database: 2 database: 2
host: 39.100.77.21 host: 39.100.77.21
@ -73,7 +74,7 @@ storage:
download-template: /usr/local/webapp/ad-platform/ad-platform-source/custom.xlsx download-template: /usr/local/webapp/ad-platform/ad-platform-source/custom.xlsx
download-template-move: /usr/local/webapp/ad-platform/ad-platform-source/dynamictemplate.xlsx download-template-move: /usr/local/webapp/ad-platform/ad-platform-source/dynamictemplate.xlsx
download-template-toker: /usr/local/webapp/ad-platform/ad-platform-source/toker.xlsx download-template-toker: /usr/local/webapp/ad-platform/ad-platform-source/toker.xlsx
download-auditing-file: http:///39.100.77.21:8001/source/auditingFiles/ download-auditing-file: http://39.100.77.21:8001/source/auditingFiles/
private-key: C:\Users\Admin\Desktop\ private-key: C:\Users\Admin\Desktop\
# 线程池配置 # 线程池配置
@ -89,3 +90,4 @@ logstash:
url: 39.100.77.21:9601 url: 39.100.77.21:9601

@ -96,3 +96,5 @@ platform:
logstash: logstash:
url: 127.0.0.1:5044 url: 127.0.0.1:5044

@ -54,6 +54,7 @@ security:
- /open/v1/form/add - /open/v1/form/add
- /dmp/v1/exchange/callback - /dmp/v1/exchange/callback
- /gender/exchange/v1/callback - /gender/exchange/v1/callback
- /traffic/v1/exchange/callback
#hutool雪花算法 #hutool雪花算法
snowflake: snowflake:

Loading…
Cancel
Save