临时提交

master
李一帆 2025-08-06 17:21:07 +08:00
parent a6a9c1926a
commit 67788c9ffe
17 changed files with 393 additions and 163 deletions

View File

@ -24,7 +24,7 @@ import java.util.stream.Collectors;
*/
@Component
@Slf4j
@Profile("default")
@Profile({"dev"})
public class AutoCallTaskScheduled {
@Autowired
@ -65,9 +65,21 @@ public class AutoCallTaskScheduled {
log.info("AutoCallTaskScheduled {}个外呼人, {}", personList.size(), personList.stream().map(AutoCallPerson::getUploadCustName).collect(Collectors.toList()));
try {
for (AutoCallPerson person : personList) {
if (person.getUploadedTimes() < 2) {
autoCallTaskService.step3UploadAICCTask(person);
} else {
autoCallTaskService.cancelPerson(person);
continue;
}
// else if (person.getUploadedTimes() == 1) {
// autoCallTaskService.resetPerson(person);
// autoCallTaskService.step3UploadAICCTask(person);
// } else {
// autoCallTaskService.cancelPerson(person);
// continue;
// }
int pendingDuration = 60 * 1000 * 2;
int pendingDuration = 60 * 1000 * 3;
int loopGap = 1000;
boolean success = false;
while (pendingDuration > 0) {

View File

@ -1,19 +1,19 @@
package com.whdc.controller;
import cn.hutool.http.HttpResponse;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itextpdf.io.font.PdfEncodings;
import com.itextpdf.kernel.font.PdfFont;
import com.itextpdf.kernel.font.PdfFontFactory;
import com.whdc.mapper.WarningResponderMapper;
import com.whdc.model.dto.AutoCallDto;
import com.whdc.model.dto.CallPutDto;
import com.whdc.model.entity.AutoCallPerson;
import com.whdc.model.entity.AutoCallTask;
import com.whdc.model.entity.WarnCallMap;
import com.whdc.model.entity.WarningResponder;
import com.whdc.service.AutoCallApiService;
import com.whdc.service.AutoCallTaskService;
import com.whdc.service.AutoCallTaskService2;
import com.whdc.utils.ResultJson;
import com.whdc.utils.SmsHelper;
import org.apache.poi.util.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -24,6 +24,8 @@ import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.net.URLEncoder;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
@ -112,11 +114,17 @@ public class AutoCallController {
return ResultJson.ok(true);
}
@GetMapping("/manualClose")
public ResultJson<Boolean> manualClose(@RequestParam("taskId") Integer taskId, @RequestParam("personId") Integer personId) {
return ResultJson.ok(autoCallTaskService2.manualClose(taskId, personId));
}
/**
* ID
* @param taskId
* @return
*/
@Deprecated
@GetMapping("/setCallIsPut")
public ResultJson<Boolean> setCallIsPut(@RequestParam("taskId") Integer taskId) {
autoCallTaskService.setCallIsPut(taskId);
@ -128,6 +136,7 @@ public class AutoCallController {
* @param dto
* @return
*/
@Deprecated
@PostMapping("/setCallIsPutList")
public ResultJson<Boolean> setCallIsPutList(@RequestBody CallPutDto dto) {
autoCallTaskService.setCallIsPutList(dto);
@ -138,7 +147,7 @@ public class AutoCallController {
public void exportPDF(@RequestBody AutoCallDto dto,
HttpServletResponse response,
HttpServletRequest request) {
Page<AutoCallTask> autoCallTaskPage = autoCallApiService.page3(dto);
Page<AutoCallTask> autoCallTaskPage = autoCallApiService.pageForPdf(dto);
List<AutoCallTask> records = autoCallTaskPage.getRecords();
ByteArrayInputStream pdfStream = autoCallApiService.exportPDF(records, response, dto.getStm(), dto.getEtm());
// 3. 设置响应头
@ -167,4 +176,25 @@ public class AutoCallController {
throw new RuntimeException(e);
}
}
@Autowired
private WarningResponderMapper wrm;
@Autowired
private SmsHelper smsHelper;
@GetMapping("/temp")
public ResultJson temp() {
String content = "领导您好省防汛抗旱指挥部办公室将于8月7日启用预警叫应智能外呼系统。收到橙色以上气象预警后系统将自动根据预警级别叫应相关责任人来电显示“省防办值班室”电话接通后系统将播报AI预警信息并询问“如您已知晓上述信息请按#号键”。请领导在收到预警叫应后,收听完整预警信息并根据语音提示按“#”号键进行确认。若未完成操作系统将在1分钟内重拨两次失败后将呼叫上一级责任人。特此报告。\n" +
"\n" +
"湖北省防汛抗旱指挥部办公室\n" +
"2025年8月6日";
List<WarningResponder> wrs = wrm.selectList(new QueryWrapper<WarningResponder>()
.ge("level", 0));
List<String> ret = new ArrayList<>();
wrs.forEach(wr -> {
wr.decryptPhone();
String s = smsHelper.send(Collections.singletonList(wr.getPhone()), content);
ret.add(wr.getPhone() + "-" + s);
});
return ResultJson.ok(wrs);
}
}

View File

@ -15,7 +15,8 @@ public interface AutoCallPersonMapper extends BaseMapper<AutoCallPerson> {
default List<AutoCallPerson> listUnUploaded() {
return selectList(
new QueryWrapper<AutoCallPerson>()
.eq("status", AutoCallPerson.STATUS_DEFAULT)
.in("status", AutoCallPerson.STATUS_DEFAULT, AutoCallPerson.STATUS_UPLOADED, AutoCallPerson.STATUS_CALLED)
.lt("uploaded_times", 2)
.orderByAsc("id")
);
}
@ -25,6 +26,7 @@ public interface AutoCallPersonMapper extends BaseMapper<AutoCallPerson> {
new QueryWrapper<AutoCallPerson>()
.eq("task_id", taskId)
.eq("status", AutoCallPerson.STATUS_PUT)
.eq("__tag", "已知晓")
) > 0;
}
@ -36,13 +38,13 @@ public interface AutoCallPersonMapper extends BaseMapper<AutoCallPerson> {
long failCnt = selectCount(
new QueryWrapper<AutoCallPerson>()
.eq("task_id", taskId)
.in("status", AutoCallPerson.STATUS_CALLED, AutoCallPerson.STATUS_CANCELLED)
.in("status", AutoCallPerson.STATUS_CALLED, AutoCallPerson.STATUS_CANCELLED,AutoCallPerson.STATUS_PUT)
//__tag == null or __tag != "已知晓"
.and(wrapper -> wrapper.isNull("__tag").or().ne("__tag", "已知晓"))
);
return personCnt == failCnt;
}
List<AutoCallPerson> selectListByTaskId(@Param("taskId") Integer taskId);
String selectPositionByPhone(@Param("phone") String uploadNumber);
}

View File

@ -25,4 +25,7 @@ public interface AutoCallTaskMapper extends BaseMapper<AutoCallTask> {
@Select("update auto_call_task set status = #{status} where id = #{taskId}")
void setStatus(Integer taskId, int status);
@Select("update auto_call_task set __tag = #{tag} where id = #{taskId}")
void setTag(Integer taskId, String tag);
}

View File

@ -3,6 +3,7 @@ package com.whdc.model.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
@ -13,12 +14,14 @@ import java.util.Date;
* @since 2025-07-08
*/
@Data
@TableName("FXKH_TXL.AUTO_CALL_PERSON")
public class AutoCallPerson {
public static final int STATUS_DEFAULT = 0;
public static final int STATUS_UPLOADED = 1;
public static final int STATUS_CALLED = 2;
public static final int STATUS_PUT = 3;
public static final int STATUS_CANCELLED = 4;
public static final int STATUS_MANUAL_CLOSE = 6;
public static final int ERRCODE_ENCODE = 1;
public static final int ERRCODE_UPLOAD_FAIL = 2;
@ -35,6 +38,14 @@ public class AutoCallPerson {
private Date createTm;
@TableField(value = "error_code")
private Integer errorCode; //default 0
@TableField(value = "uploaded_times")
private Integer uploadedTimes; //default 0
@TableField(value = "sms_content")
private String smsContent; //短信内容
@TableField(value = "manual_close")
private Integer manualClose; //default 0
@TableField(value = "position")
private String position;
@TableField(value = "__request_id")
private String uploadRequestId; //任务名同时作为参数的taskName用custId
@ -43,7 +54,7 @@ public class AutoCallPerson {
@TableField(value = "__cust_name")
private String uploadCustName; //联系人
@TableField(value = "__content")
private String uploadContent; //联系人
private String uploadContent; //外呼内容
@TableField(value = "__number")
private String uploadNumber;
@TableField(value = "__upload_resp_msg")
@ -54,6 +65,8 @@ public class AutoCallPerson {
private Integer detailTalkTimes;//通话时长,单位秒
@TableField(value = "__sip_term_cause")
private String detailSipTermCause; //例如”对方挂机“
@TableField(value = "__tag")
private String tag; //话术识别:未识别,已知晓
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@TableField(value = "__startring_at")
@ -76,6 +89,4 @@ public class AutoCallPerson {
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@TableField(value = "__last_modify")
private Date detailLastModify;
@TableField(exist = false)
private String position;
}

View File

@ -3,6 +3,7 @@ package com.whdc.model.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
@ -14,6 +15,7 @@ import java.util.List;
* @since 2025-07-08
*/
@Data
@TableName("FXKH_TXL.AUTO_CALL_TASK")
public class AutoCallTask {
public static final int STATUS_DEFAULT = 0; // 不生成
public static final int STATUS_SHOULD_GENERATE = 1;
@ -21,11 +23,10 @@ public class AutoCallTask {
public static final int STATUS_ANY_SUCCESS = 3;
public static final int STATUS_ALL_FAIL = 4;
public static final int STATUS_CANCELLED = 5;
public static final int STATUS_MANUAL_CLOSE = 6; //人工处置
public static final int ERRCODE_NO_PERSON = 1;
public static final int ERRCODE_DB_ERROR = 2;
public static final int TASK_CANCEL = 6; //任务取消
@TableId(value = "ID", type = IdType.AUTO)
private Integer id;
@TableField(value = "warn_id")
@ -47,6 +48,8 @@ public class AutoCallTask {
private String warnCnnm;
@TableField(value = "warn_content")
private String warnContent;
@TableField(value = "__tag")
private String tag; //话术识别:未识别,已知晓
@TableField(value = "_create_tm")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
@ -56,4 +59,7 @@ public class AutoCallTask {
@TableField(exist = false)
private List<AutoCallPerson> callList;
@TableField(exist = false)
private AutoCallPerson successPerson;
}

View File

@ -109,7 +109,7 @@ public class WarningResponder extends Model<WarningResponder> implements Seriali
public static void main(String[] args) {
WarningResponder a = new WarningResponder();
a.setPhone("15623775829");
a.setPhone("13933930962");
a.encryptPhone();
System.out.println(a.salt);
System.out.println(a.phone);

View File

@ -38,6 +38,7 @@ public class AICCCallRespDetail {
private Integer sendCount;
private RawVarListMap rawVarListMap;
private List<Tag> tags;
}
@lombok.Data
@ -60,5 +61,10 @@ public class AICCCallRespDetail {
private String lastModify;
}
@lombok.Data
@ToString
public static class Tag {
@JSONField(name = "tag_name")
private String tagName;
}
}

View File

@ -45,10 +45,10 @@ public class AICCUploadTask {
private String processId;
private String callerGroup;
private String requestId;
private int calleeType = 1; //默认0 重乎1 顺乎2 默认为0
private int repeatTimes = 1;//呼叫次数,CallType=0不传; CalleeType=1重乎必传; CalleeType=2顺乎并且autoCall为0必传
private String autoCall = "0";//顺乎未接通是否重乎,开启=0; 关闭=1; CalleeType=2顺乎必传
private int spanSeconds = 3;//重乎间隔时间(秒),CallType=0不传; CalleeType=1重乎必传; CalleeType=2顺乎并且autoCall为0必传
private int calleeType = 0; //默认0 重乎1 顺乎2 默认为0
// private int repeatTimes = 1;//呼叫次数,CallType=0不传; CalleeType=1重乎必传; CalleeType=2顺乎并且autoCall为0必传
private String autoCall = "1";//顺乎未接通是否重乎,开启=0; 关闭=1; CalleeType=2顺乎必传
// private int spanSeconds = 3;//重乎间隔时间(秒),CallType=0不传; CalleeType=1重乎必传; CalleeType=2顺乎并且autoCall为0必传
private String processType = "3";
private String mutiTimeRange;
private List<Cust> param;

View File

@ -93,7 +93,7 @@ public class AutoCallApiService {
AutoCallTask.STATUS_ANY_SUCCESS,
AutoCallTask.STATUS_ALL_FAIL,
AutoCallTask.STATUS_CANCELLED,
AutoCallTask.TASK_CANCEL
AutoCallTask.STATUS_MANUAL_CLOSE
);
}
Page pageParam = dto.getPage().getPage();
@ -106,11 +106,25 @@ public class AutoCallApiService {
if (records.size() > 0) {
for (AutoCallTask task : records) {
Integer taskId = task.getId();
List<AutoCallPerson> autoCallList = personMapper.selectList(
List<AutoCallPerson> personList = personMapper.selectList(
new QueryWrapper<AutoCallPerson>()
.eq("task_id", taskId)
);
task.setCallList(autoCallList);
if ("已知晓".equals(task.getTag())) {
AutoCallPerson successPerson = null;
for (AutoCallPerson person : personList) {
if ("已知晓".equals(person.getTag())) {
successPerson = person;
task.setSuccessPerson(successPerson);
break;
}
}
personList.remove(successPerson);
}
personList.removeIf(p -> "已呼通其他联系人".equals(p.getDetailRemark()));
task.setCallList(personList);
}
}
return pageResult;
@ -180,7 +194,7 @@ public class AutoCallApiService {
private QXWarningMapper warningMapper;
public Page<AutoCallTask> page3(AutoCallDto dto) {
public Page<AutoCallTask> pageForPdf(AutoCallDto dto) {
Date stm = null;
Date etm = null;
try {
@ -214,10 +228,11 @@ public class AutoCallApiService {
AutoCallTask.STATUS_ANY_SUCCESS,
AutoCallTask.STATUS_ALL_FAIL,
AutoCallTask.STATUS_CANCELLED,
AutoCallTask.TASK_CANCEL
AutoCallTask.STATUS_MANUAL_CLOSE
);
}
Page pageParam = dto.getPage().getPage();
pageParam.setSize(9999);
Page<AutoCallTask> pageResult = taskMapper.selectPage(
pageParam,
query
@ -227,15 +242,13 @@ public class AutoCallApiService {
if (records.size() > 0) {
for (AutoCallTask task : records) {
Integer taskId = task.getId();
List<AutoCallPerson> autoCallList = personMapper.selectList(
List<AutoCallPerson> personList = personMapper.selectList(
new QueryWrapper<AutoCallPerson>()
.eq("task_id", taskId)
);
for (AutoCallPerson autoCallPerson : autoCallList) {
String position = personMapper.selectPositionByPhone(autoCallPerson.getUploadNumber());
autoCallPerson.setPosition(position);
}
task.setCallList(autoCallList);
personList.removeIf(p -> !"已知晓".equals(p.getTag()));
task.setCallList(personList);
}
}
return pageResult;
@ -442,7 +455,7 @@ private void addTableHeader(Table table) {
//处理结束拨打时间
StringBuilder endTime = new StringBuilder();
for (AutoCallPerson item : record.getCallList()) {
String s = formatTime(item.getDetailEndringAt());
String s = formatTime(item.getDetailDisconnectedAt());
endTime.append(s).append("\n");
}
// 格式化时间
@ -495,10 +508,13 @@ private void addTableHeader(Table table) {
.orderByDesc("id");
query.in("status",
AutoCallTask.STATUS_ALL_FAIL,
AutoCallTask.STATUS_SHOULD_GENERATE,
AutoCallTask.STATUS_CANCELLED,
AutoCallTask.STATUS_GENERATED
// AutoCallTask.STATUS_SHOULD_GENERATE,
// AutoCallTask.STATUS_CANCELLED,
AutoCallTask.STATUS_GENERATED,
AutoCallTask.STATUS_ANY_SUCCESS
);
//__tag is null or __tag != "已知晓"
query.and(wrapper -> wrapper.isNull("__tag").or().ne("__tag", "已知晓"));
List<AutoCallTask> autoCallTasks = taskMapper.selectList(query);
for (AutoCallTask task : autoCallTasks) {
Integer taskId = task.getId();

View File

@ -24,7 +24,7 @@ import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
import static com.whdc.model.entity.AutoCallTask.TASK_CANCEL;
import static com.whdc.model.entity.AutoCallTask.STATUS_MANUAL_CLOSE;
/**
* @author lyf
@ -514,8 +514,8 @@ public class AutoCallTaskService {
List<AutoCallTask> autoCallTasks = autoCallTaskMapper.selectList(queryWrapper);
for (AutoCallTask autoCallTask : autoCallTasks) {
//告警任务取消
autoCallTask.setStatus(TASK_CANCEL);
autoCallTask.setRemark("告警任务取消");
autoCallTask.setStatus(STATUS_MANUAL_CLOSE);
autoCallTask.setRemark("人工处置");
autoCallTaskMapper.updateById(autoCallTask);
}
}

View File

@ -3,7 +3,10 @@ package com.whdc.service;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.whdc.mapper.*;
import com.whdc.model.entity.*;
import com.whdc.model.entity.AutoCallPerson;
import com.whdc.model.entity.AutoCallTask;
import com.whdc.model.entity.QXWarning;
import com.whdc.model.entity.WarningResponder;
import com.whdc.model.entity.autocall.AICCCallRespDetail;
import com.whdc.model.entity.autocall.AICCCallRespTask;
import com.whdc.model.entity.autocall.AICCCallRespWrapper;
@ -15,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.DefaultTransactionDefinition;
import java.io.UnsupportedEncodingException;
@ -51,7 +55,7 @@ public class AutoCallTaskService2 {
public void generateFakeCall() {
QXWarning warn = qxWarningMapper.selectOne(
new QueryWrapper<QXWarning>()
.like("CNNM", "洪湖")
// .like("CNNM", "洪湖")
.orderByDesc("WARNID")
.last("limit 1")
);
@ -280,6 +284,7 @@ public class AutoCallTaskService2 {
person.setUploadCustId(uniqueId);
person.setUploadCustName(wr.getName());
person.setLevel(wrLevel);
person.setPosition(wr.getPosition());
person.setUploadNumber(wr.getPhone());
person.setUploadContent(
"我是省防办智能外呼系统," +
@ -290,7 +295,18 @@ public class AutoCallTaskService2 {
task.getWarnLevel() +
"预警信号:" +
task.getWarnContent() +
"如需咨询请拨打02787221781相关信息以短信发送给您。"
",相关信息以短信发送给您。"
);
person.setSmsContent(
"我是省防办智能外呼系统," +
wr.getName() + "同志您好," +
task.getWarnCtnm() +
sdf.format(task.getWarnTm()) +
"发布暴雨" +
task.getWarnLevel() +
"预警信号:" +
task.getWarnContent() +
"如需咨询请拨打省防办值班电话027-87221781。"
);
person.setCreateTm(task.getCreateTm());
personList.add(person);
@ -322,6 +338,21 @@ public class AutoCallTaskService2 {
return;
}
try {
if (person.getUploadedTimes() == 2) {
cancelPerson(person);
try {
Thread.sleep(10000);
} catch (InterruptedException ignore) {
}
return;
} else if (person.getUploadedTimes() == 1) {
try {
Thread.sleep(10000);
} catch (InterruptedException ignore) {
}
resetPerson(person);
}
List<String> numbers = Collections.singletonList(person.getUploadNumber());
AICCUploadTask uploadTask = aiccHelper.newTask(
person.getUploadRequestId(),
@ -330,6 +361,7 @@ public class AutoCallTaskService2 {
person.getUploadContent(),
numbers
);
AICCCallRespWrapper<AICCCallRespTask> AICCCallRespWrapper = null;
try {
AICCCallRespWrapper = aiccHelper.apiUploadCallData(uploadTask);
@ -347,8 +379,9 @@ public class AutoCallTaskService2 {
String msg = AICCCallRespWrapper.getResult().getMsg();
person.setStatus(AutoCallPerson.STATUS_UPLOADED);
person.setUploadRespMsg(msg);
person.setUploadedTimes(person.getUploadedTimes() + 1);
personMapper.updateById(person);
smsHelper.send(numbers, person.getUploadContent());
smsHelper.send(numbers, person.getSmsContent());
}
} finally {
isCalling.set(false);
@ -356,27 +389,119 @@ public class AutoCallTaskService2 {
}
public boolean step4QueryAICCTaskResult(AutoCallPerson person) {
person = personMapper.selectById(person.getId());
//切记要设置person的status和task的status
AICCCallRespWrapper<AICCCallRespDetail> detail = aiccHelper.apiGetTaskCallDetail(person.getUploadRequestId(), person.getUploadCustId());
List<AICCCallRespDetail.Record> records = detail.getResult().getData().getRecords();
if (records.isEmpty()) return false; //这个false是平台还未有拨打应继续刷接口
AICCCallRespDetail.Record record = records.get(0);
String dialRemark = record.getRemark();
boolean done = false;
if ("接通".equals(dialRemark)) {
person.setStatus(AutoCallPerson.STATUS_PUT);
done = true;
} else if (records.size() > 1) {
person.setStatus(AutoCallPerson.STATUS_CALLED);
done = true;
if (detail == null ||
detail.getResult() == null ||
detail.getResult().getData() == null ||
detail.getResult().getData().getRecords() == null ||
detail.getResult().getData().getRecords().isEmpty() ||
detail.getResult().getData().getRecords().get(0).getRemark() == null
) {
return false; //remark为空代表联通平台还未或正在呼叫还没有结果信息应继续刷接口
}
if (done) {
Integer taskId = person.getTaskId();
AICCCallRespDetail.Record record = detail.getResult().getData().getRecords().get(0);
String dialRemark = record.getRemark();
AICCCallRespDetail.RawVarListMap rawVarListMap = record.getRawVarListMap();
//已产生结果信息
person.setDetailRemark(dialRemark);
person.setDetailTalkTimes(record.getTalkTimes());
AICCCallRespDetail.RawVarListMap rawVarListMap = record.getRawVarListMap();
person.setDetailSipTermCause(rawVarListMap.getSipTermCause());
fillTimeData(person, record);
//话术部分
String tag = null;
if (record.getTags() != null &&
!record.getTags().isEmpty() &&
record.getTags().get(0).getTagName() != null
) {
tag = record.getTags().get(0).getTagName();
person.setTag(tag);
}
//再判断状态
if ("接通".equals(dialRemark)) {
person.setStatus(AutoCallPerson.STATUS_PUT);
} else {
if (person.getUploadedTimes() < 2) {
person.setStatus(AutoCallPerson.STATUS_CALLED);
} else {
person.setStatus(AutoCallPerson.STATUS_CANCELLED);
}
}
personMapper.updateById(person);
if ("已知晓".equals(tag)) {
markRemnantPersonStatus(taskId);
taskMapper.setTag(taskId, tag);
taskMapper.setStatus(taskId, AutoCallTask.STATUS_ANY_SUCCESS);
} else {
boolean allFail = personMapper.isAllFail(taskId);
if (allFail) {
taskMapper.setStatus(taskId, AutoCallTask.STATUS_ALL_FAIL);
}
}
return true;
// boolean done = false;
// log.info("{}", JSON.toJSONString(record));
// if ("接通".equals(dialRemark)) {
// if (record.getTags() != null && record.getTags().size() > 0) {
// String tag = record.getTags().get(0).getTagName();
// person.setTag(tag);
// personMapper.updateById(person);
// taskMapper.setTag(taskId, tag);
// if ("已知晓".equals(tag)) {
// person.setStatus(AutoCallPerson.STATUS_PUT);
// done = true;
// } else {
// return true;
// }
//
// }
// } else if (dialRemark != null) {
// done = true;
// }
// if (done) {
// personMapper.updateById(person);
// boolean anySuccess = markTaskStatus(taskId);
// if (anySuccess) {
// markRemnantPersonStatus(taskId);
// }
// return true;
// }
// return false; //这个false是平台还未完成重呼应继续刷接口
}
@Transactional
public boolean manualClose(Integer taskId, Integer personId) {
AutoCallTask task = taskMapper.selectById(taskId);
if (task == null) return false;
List<AutoCallPerson> personList = personMapper.selectList(new QueryWrapper<AutoCallPerson>().eq("task_id", taskId));
if (personList == null || personList.isEmpty()) return false;
AutoCallPerson person = null;
for (AutoCallPerson p : personList) {
if (p.getId().equals(personId)) {
person = p;
break;
}
}
if (person == null) return false;
person.setStatus(AutoCallPerson.STATUS_MANUAL_CLOSE);
person.setTag("已知晓");
personMapper.updateById(person);
task.setTag("已知晓");
task.setStatus(AutoCallTask.STATUS_MANUAL_CLOSE);
taskMapper.updateById(task);
return true;
}
private static void fillTimeData(AutoCallPerson person, AICCCallRespDetail.Record record) {
AICCCallRespDetail.RawVarListMap rawVarListMap = record.getRawVarListMap();
{
Date d;
long l;
if (rawVarListMap.getStartringAt() != null) {
@ -428,17 +553,37 @@ public class AutoCallTaskService2 {
person.setDetailLastModify(d);
}
}
public void resetPerson(AutoCallPerson person) {
long millis = System.currentTimeMillis();
String uniqueId = millis + "-" + person.getUploadRequestId().split("-")[1];
person.setUploadRequestId(uniqueId);
person.setUploadCustId(uniqueId);
person.setErrorCode(0);
person.setUploadRespMsg(null);
person.setDetailRemark(null);
person.setDetailTalkTimes(null);
person.setDetailSipTermCause(null);
person.setTag(null);
person.setStatus(AutoCallPerson.STATUS_DEFAULT);
// person.setDetailStartringAt(null);
// person.setDetailConnectedAt(null);
// person.setDetailStartedAt(null);
// person.setDetailEndringAt(null);
// person.setDetailDisconnectedAt(null);
// person.setDetailStopedAt(null);
personMapper.updateById(person);
boolean anySuccess = markTaskStatus(person.getTaskId());
if (anySuccess) {
markRemanentPersonStatus(person.getTaskId());
}
return true;
}
return false; //这个false是平台还未完成重呼应继续刷接口
}
private void markRemanentPersonStatus(Integer taskId) {
public void cancelPerson(AutoCallPerson person) {
person.setStatus(AutoCallPerson.STATUS_CANCELLED);
personMapper.updateById(person);
}
private void markRemnantPersonStatus(Integer taskId) {
personMapper.update(new AutoCallPerson() {{
setStatus(AutoCallPerson.STATUS_CANCELLED);
setDetailRemark("已呼通其他联系人");

View File

@ -117,18 +117,27 @@ public class AICCHelper {
TypeReference<AICCCallRespWrapper<AICCCallRespTask>> type = new TypeReference<AICCCallRespWrapper<AICCCallRespTask>>() {
};
AICCCallRespWrapper<AICCCallRespTask> AICCCallRespWrapper = null;
if (!resp.contains("请求失败") || !resp.contains("网络异常")) {
try {
AICCCallRespWrapper = JSON.parseObject(resp, type);
} catch (Exception ex) {
log.error("apiUploadCallData: {}", resp);
log.error("apiUploadCallData first time: {}", resp);
log.error("error: ", ex);
throw ex;
}
}
if (AICCCallRespWrapper == null || !AICCCallRespWrapper.isSuccess()) {
initToken();
headers.put("X-Access-Token", getToken());
resp = httpHelper.postJsonString("https://aicc.cuopen.net:9801/aicc-api/ssb/callout/thirdParty/task/uploadCallData", request.toJSONString(), headers);
if (!resp.contains("请求失败") || !resp.contains("网络异常")) {
try {
AICCCallRespWrapper = JSON.parseObject(resp, type);
} catch (Exception ex) {
log.error("apiUploadCallData second time: {}", resp);
log.error("error: ", ex);
}
}
}
if (AICCCallRespWrapper == null || !AICCCallRespWrapper.isSuccess()) {
@ -138,11 +147,15 @@ public class AICCHelper {
}
public AICCCallRespWrapper<AICCCallRespDetail> apiGetTaskCallDetail(String requestId, String custId) {
return apiGetTaskCallDetail(requestId, custId, getToken());
}
public AICCCallRespWrapper<AICCCallRespDetail> apiGetTaskCallDetail(String requestId, String custId, String token) {
JSONObject request = new JSONObject();
request.put("requestId", requestId);
request.put("custId", custId);
Map<String, String> headers = new HashMap<>();
headers.put("X-Access-Token", getToken());
headers.put("X-Access-Token", token);
String resp = httpHelper.postJsonString("https://aicc.cuopen.net:9801/aicc-api/ssb/callout/thirdParty/task/getTaskCallDetail", request.toJSONString(),headers);
TypeReference<AICCCallRespWrapper<AICCCallRespDetail>> type = new TypeReference<AICCCallRespWrapper<AICCCallRespDetail>>() {

View File

@ -93,7 +93,7 @@ getGroupWarning: http://127.0.0.1:20000/shzh/met/zyqxfw/api/warning/getGroupWarn
autocall:
sysUserId: HBSL01
processId: 1935233125932101634
processId: 1952550108058906626
# processId: 1934801506242949122
# callerGroup: 02160980358
callerGroup: 02759325005

View File

@ -93,8 +93,8 @@ getGroupWarning: http://127.0.0.1:20000/shzh/met/zyqxfw/api/warning/getGroupWarn
autocall:
sysUserId: HBSL01 # 平台网页https://aicc.cuopen.net:9801/login 密码Gswl@2025
processId: 1935233125932101634
# processId: 1934801506242949122
# processId: 1935233125932101634
processId: 1952550108058906626
# callerGroup: 02160980358
callerGroup: 02759325005
secret: yxt@2024-1234567

View File

@ -10,15 +10,5 @@
where T1.TASK_ID = #{taskId}
</select>
<select id="selectPositionByPhone" resultType="String">
select t.POSITION
from FXKH_TXL.SH_ADDRESS_BOOK t
where
t.DEL = 1
AND t.PHONE = #{phone}
ORDER BY
t.SORT ASC
LIMIT 1
</select>
</mapper>

View File

@ -24,7 +24,7 @@ import java.util.List;
class AICCHelperTest {
private static final Logger LOG = LoggerFactory.getLogger(AICCHelperTest.class);
public static void main(String[] args) throws InterruptedException, ParseException, GeneralSecurityException, UnsupportedEncodingException {
public static void main2(String[] args) throws InterruptedException, ParseException, GeneralSecurityException, UnsupportedEncodingException {
AICCHelper helper = new AICCHelper();
helper.setProcessId("1935233125932101634");
helper.setCallerGroup("02759325005");
@ -74,9 +74,9 @@ class AICCHelperTest {
uploadTask.setParam(Lists.newArrayList(param));
uploadTask.setCalleeType(1);
uploadTask.setRepeatTimes(1);
// uploadTask.setRepeatTimes(1);
uploadTask.setAutoCall("0");
uploadTask.setSpanSeconds(10);
// uploadTask.setSpanSeconds(10);
LOG.info("上传外呼任务: {}", JSON.toJSONString(uploadTask));
AICCCallRespWrapper<AICCCallRespTask> AICCCallRespWrapper = helper.apiUploadCallData(uploadTask);
@ -172,46 +172,42 @@ class AICCHelperTest {
}
}
public static void main2(String[] args) throws GeneralSecurityException, UnsupportedEncodingException {
public static void main3(String[] args) throws GeneralSecurityException, UnsupportedEncodingException {
AICCHelper helper = new AICCHelper();
helper.setProcessId("1935233125932101634");
helper.setProcessId("1952550108058906626");
helper.setCallerGroup("02759325005");
helper.setSecret("yxt@2024-1234567");
helper.setSysUserId("HBSL01");
String token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6IkhCU0wwMSIsInRlbmFudElkIjoiOTYzOTM2NTE3IiwiZXhwIjoxNzUyMTU0NTE0fQ.R4Yg7OhZek9YbJ7xGj2rQTe_YY0KLPQDM2zRebLkRdY";
String token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6IkhCU0wwMSIsInRlbmFudElkIjoiOTYzOTM2NTE3IiwiZXhwIjoxNzU0NjU5ODI0fQ.08Axf2DVQokcl8gDw1061ljq1EHyhxElx4-OBKx0TGw";
String prefix = System.currentTimeMillis() + "";
AICCUploadTask task = new AICCUploadTask();
task.setTaskName("requestId" + prefix);
task.setProcessId("1935233125932101634");
task.setProcessId("1952550108058906626");
task.setCallerGroup("02759325005");
task.setRequestId("requestId" + prefix);
task.genMutiTimeRange();
AICCUploadTask.Cust param1 = AICCUploadTask.Cust.builder()
.setCustName("秦")
.setCustId("秦" + prefix)
.setContent("测试测试测试,这是第一个联系人")
.set_numbers(Collections.singletonList("13933930962"))
.build();
AICCUploadTask.Cust param2 = AICCUploadTask.Cust.builder()
.setCustName("李")
.setCustId("李" + prefix)
.setContent("测试测试测试,这是第二个联系人")
.setCustId(prefix + "-15671545233")
// .setContent("ai话术测试")
.setContent("过去1小时黄陂李家集街道已出现64.4毫米降水受强降雨云团持续影响预计未来3小时黄陂中北部部分街道乡镇将出现暴雨到大暴雨伴有雷电和短时强降水局地7-9级雷暴大风山区山洪、地质灾害、中小河流洪水、城乡积涝风险高请加强防范。")
.set_numbers(Collections.singletonList("15671545233"))
.build();
task.setParam(Lists.newArrayList(param1, param2));
task.setParam(Collections.singletonList(param1));
System.out.println(JSON.toJSONString(task));
AICCCallRespWrapper<AICCCallRespTask> AICCCallRespWrapper = helper.apiUploadCallData(task);
AICCCallRespWrapper<AICCCallRespTask> AICCCallRespWrapper = helper.apiUploadCallData(task, token);
String msg = AICCCallRespWrapper.getResult().getMsg();
System.out.println(msg);
}
public static void main(String[] args) throws GeneralSecurityException, UnsupportedEncodingException {
String token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6IkhCU0wwMSIsInRlbmFudElkIjoiOTYzOTM2NTE3IiwiZXhwIjoxNzU0NjU5ODI0fQ.08Axf2DVQokcl8gDw1061ljq1EHyhxElx4-OBKx0TGw";
AICCHelper helper = new AICCHelper();
AICCCallRespWrapper<AICCCallRespDetail> detail = helper.apiGetTaskCallDetail("requestId1754361918060", "1754361918060-15671545233", token);
System.out.println(JSON.toJSONString(detail));
}
class Cust {
private String custName;
private String custId;
private String content;
private String number;
}
}