master
parent
5171395253
commit
7ee22a55da
|
|
@ -1,6 +1,7 @@
|
|||
package com.whdc.component;
|
||||
|
||||
import com.whdc.mapper.AutoCallConfigMapper;
|
||||
import com.whdc.mapper.AutoCallPersonMapper;
|
||||
import com.whdc.model.entity.AutoCallPerson;
|
||||
import com.whdc.service.AutoCallTaskService2;
|
||||
import com.whdc.utils.AutoCallHelper;
|
||||
|
|
@ -14,7 +15,6 @@ import org.springframework.scheduling.annotation.Scheduled;
|
|||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
|
@ -30,6 +30,8 @@ public class AutoCallTaskScheduled {
|
|||
@Autowired
|
||||
private AutoCallTaskService2 autoCallTaskService;
|
||||
@Autowired
|
||||
private AutoCallPersonMapper personMapper;
|
||||
@Autowired
|
||||
private AutoCallConfigMapper configMapper;
|
||||
@Autowired
|
||||
private AutoCallHelper autoCallHelper;
|
||||
|
|
@ -71,15 +73,7 @@ public class AutoCallTaskScheduled {
|
|||
autoCallTaskService.cancelPerson(person);
|
||||
continue;
|
||||
}
|
||||
// else if (person.getUploadedTimes() == 1) {
|
||||
// autoCallTaskService.resetPerson(person);
|
||||
// autoCallTaskService.step3UploadAICCTask(person);
|
||||
// } else {
|
||||
// autoCallTaskService.cancelPerson(person);
|
||||
// continue;
|
||||
// }
|
||||
|
||||
int pendingDuration = 60 * 1000 * 3;
|
||||
int pendingDuration = 60 * 1000 * 2;
|
||||
int loopGap = 1000;
|
||||
boolean success = false;
|
||||
while (pendingDuration > 0) {
|
||||
|
|
@ -96,7 +90,10 @@ public class AutoCallTaskScheduled {
|
|||
}
|
||||
|
||||
if (!success) {
|
||||
autoCallTaskService.markPersonDetailQueryTimeout(person);
|
||||
person.setUploadedTimes(personMapper.selectById(person.getId()).getUploadedTimes());
|
||||
if (person.getUploadedTimes() == 2) {
|
||||
autoCallTaskService.markPersonDetailQueryTimeout(person);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
import com.whdc.mapper.WarningResponderMapper;
|
||||
import com.whdc.model.dto.AutoCallDto;
|
||||
import com.whdc.model.dto.CallPutDto;
|
||||
import com.whdc.model.dto.FindPageDto;
|
||||
import com.whdc.model.entity.AutoCallPerson;
|
||||
import com.whdc.model.entity.AutoCallTask;
|
||||
import com.whdc.model.entity.WarnCallMap;
|
||||
|
|
@ -177,6 +178,54 @@ public class AutoCallController {
|
|||
}
|
||||
}
|
||||
|
||||
@GetMapping("/getPdf")
|
||||
//{"etm":"2025-08-07","stm":"2025-07-31","page":{"pageNumber":1,"pageSize":20}}
|
||||
public void getPdf(@RequestParam("stm")String stm, @RequestParam("etm")String etm, HttpServletResponse response,
|
||||
HttpServletRequest request) {
|
||||
AutoCallDto dto = new AutoCallDto();
|
||||
dto.setStm(stm);
|
||||
dto.setEtm(etm);
|
||||
dto.setPage(new FindPageDto());
|
||||
Page<AutoCallTask> autoCallTaskPage = autoCallApiService.pageForPdf(dto);
|
||||
List<AutoCallTask> records = autoCallTaskPage.getRecords();
|
||||
ByteArrayInputStream pdfStream = autoCallApiService.exportPDF(records, response, dto.getStm(), dto.getEtm());
|
||||
// 3. 设置响应头
|
||||
try {
|
||||
// 设置响应头
|
||||
response.setContentType("application/pdf");
|
||||
String fileName = "智能呼叫记录_" + dto.getStm().toString().replace(":", "-") + "_to_"
|
||||
+ dto.getEtm().toString().replace(":", "-") + ".pdf";
|
||||
|
||||
// 获取User-Agent判断浏览器类型
|
||||
String userAgent = request.getHeader("User-Agent");
|
||||
|
||||
// 针对不同浏览器设置不同的Content-Disposition
|
||||
if (userAgent != null && userAgent.toLowerCase().contains("firefox")) {
|
||||
// Firefox浏览器
|
||||
response.setHeader("Content-Disposition",
|
||||
"attachment; filename*=UTF-8''" + URLEncoder.encode(fileName, "UTF-8"));
|
||||
} else {
|
||||
// 其他浏览器(Chrome, Edge, Safari等)
|
||||
response.setHeader("Content-Disposition",
|
||||
"attachment; filename=\"" + new String(fileName.getBytes("GBK"), "ISO-8859-1") + "\"");
|
||||
}
|
||||
IOUtils.copy(pdfStream,response.getOutputStream());
|
||||
response.flushBuffer();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/newPerson")
|
||||
public ResultJson newPerson(@RequestParam("taskId")Integer taskId) {
|
||||
AutoCallTask task = autoCallTaskService2.getTaskMapper().selectById(taskId);
|
||||
return ResultJson.ok(autoCallTaskService2.newPerson(task));
|
||||
}
|
||||
|
||||
@GetMapping("/getUploadedPerson")
|
||||
public ResultJson getUploadedPerson() {
|
||||
return ResultJson.ok(autoCallTaskService2.step2GetOneUnUploadedPerson());
|
||||
}
|
||||
// @Autowired
|
||||
// private WarningResponderMapper wrm;
|
||||
// @Autowired
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ public interface AutoCallPersonMapper extends BaseMapper<AutoCallPerson> {
|
|||
long failCnt = selectCount(
|
||||
new QueryWrapper<AutoCallPerson>()
|
||||
.eq("task_id", taskId)
|
||||
.eq("uploaded_times", 2)
|
||||
.in("status", AutoCallPerson.STATUS_CALLED, AutoCallPerson.STATUS_CANCELLED,AutoCallPerson.STATUS_PUT)
|
||||
//__tag == null or __tag != "已知晓"
|
||||
.and(wrapper -> wrapper.isNull("__tag").or().ne("__tag", "已知晓"))
|
||||
|
|
|
|||
|
|
@ -46,6 +46,9 @@ public class AutoCallPerson {
|
|||
private Integer manualClose; //default 0
|
||||
@TableField(value = "position")
|
||||
private String position;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@TableField(value = "manual_close_tm")
|
||||
private Date manualCloseTm;
|
||||
|
||||
@TableField(value = "__request_id")
|
||||
private String uploadRequestId; //任务名,同时作为参数的taskName,用custId
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ public class WarningResponder extends Model<WarningResponder> implements Seriali
|
|||
|
||||
public static void main(String[] args) {
|
||||
WarningResponder a = new WarningResponder();
|
||||
a.setPhone("13933930962");
|
||||
a.setPhone("18872619396");
|
||||
a.encryptPhone();
|
||||
System.out.println(a.salt);
|
||||
System.out.println(a.phone);
|
||||
|
|
|
|||
|
|
@ -380,14 +380,14 @@ public class AutoCallApiService {
|
|||
// 定义表格列宽(适配横向A4,新增字段列)
|
||||
float[] columnWidths = {
|
||||
30, // 序号
|
||||
150, // 预警名称
|
||||
150+28+28, // 预警名称
|
||||
100, // 县(市、区)
|
||||
120, // 智能呼叫时间
|
||||
160, // 呼叫对象及职务
|
||||
130, // 状态
|
||||
80, // 通话时长(秒)
|
||||
130, // 拨打时间
|
||||
130 // 结束时间
|
||||
// 120, // 智能呼叫时间
|
||||
160+28+28+28, // 呼叫对象及职务
|
||||
130, // 叫应情况
|
||||
// 80, // 通话时长(秒)
|
||||
130+28, // 智能呼叫时间
|
||||
130+28 // 人工处置时间
|
||||
};
|
||||
Table table = new Table(columnWidths);
|
||||
table.setKeepTogether(true);
|
||||
|
|
@ -402,16 +402,25 @@ public class AutoCallApiService {
|
|||
|
||||
// 更新表头(添加新字段)
|
||||
private void addTableHeader(Table table) {
|
||||
// String[] headers = {
|
||||
// "序号",
|
||||
// "预警名称",
|
||||
// "县(市、区)",
|
||||
// "智能呼叫时间",
|
||||
// "呼叫对象及职务",
|
||||
// "状态",
|
||||
// "通话时长",
|
||||
// "拨打时间",
|
||||
// "结束时间"
|
||||
// };
|
||||
String[] headers = {
|
||||
"序号",
|
||||
"预警名称",
|
||||
"县(市、区)",
|
||||
"智能呼叫时间",
|
||||
"呼叫对象及职务",
|
||||
"状态",
|
||||
"通话时长",
|
||||
"拨打时间",
|
||||
"结束时间"
|
||||
"叫应情况",
|
||||
"智能呼叫时间",
|
||||
"人工处置时间"
|
||||
};
|
||||
for (String header : headers) {
|
||||
table.addHeaderCell(new Cell()
|
||||
|
|
@ -433,44 +442,66 @@ private void addTableHeader(Table table) {
|
|||
String name = item.getUploadCustName() != null ? item.getUploadCustName() : "未知对象";
|
||||
String position = item.getPosition() != null ? item.getPosition() : "无职务";
|
||||
callInfo.append(name).append("(").append(position).append(")\n");
|
||||
// if (item.getStatus() == AutoCallPerson.STATUS_MANUAL_CLOSE) {
|
||||
// callInfo.append("(人工处置)");
|
||||
// }
|
||||
// callInfo.append("\n");
|
||||
}
|
||||
//处理通话时长
|
||||
StringBuilder callTime = new StringBuilder();
|
||||
for (AutoCallPerson item : record.getCallList()) {
|
||||
String time = item.getDetailTalkTimes() != null? item.getDetailTalkTimes() + "秒" : "未知";
|
||||
callTime.append(time).append("\n");
|
||||
}
|
||||
//处理状态
|
||||
// StringBuilder callTime = new StringBuilder();
|
||||
// for (AutoCallPerson item : record.getCallList()) {
|
||||
// String time = item.getDetailTalkTimes() != null? item.getDetailTalkTimes() + "秒" : "未知";
|
||||
// callTime.append(time).append("\n");
|
||||
// }
|
||||
//叫应情况
|
||||
StringBuilder status = new StringBuilder();
|
||||
for (AutoCallPerson item : record.getCallList()) {
|
||||
String s = item.getDetailRemark() != null? item.getDetailRemark() : "未知";
|
||||
status.append(s).append("\n");
|
||||
// String s = item.getDetailRemark() != null? item.getDetailRemark() : "未知";
|
||||
// status.append(s).append("\n");
|
||||
if (item.getStatus() == AutoCallPerson.STATUS_MANUAL_CLOSE) {
|
||||
status.append("人工处置");
|
||||
} else {
|
||||
status.append("智能叫应");
|
||||
}
|
||||
}
|
||||
//处理拨打时间
|
||||
//人工处置时间
|
||||
StringBuilder startTime = new StringBuilder();
|
||||
for (AutoCallPerson item : record.getCallList()) {
|
||||
String s = formatTime(item.getDetailStartedAt());
|
||||
startTime.append(s).append("\n");
|
||||
}
|
||||
//处理结束拨打时间
|
||||
StringBuilder endTime = new StringBuilder();
|
||||
// StringBuilder endTime = new StringBuilder();
|
||||
// for (AutoCallPerson item : record.getCallList()) {
|
||||
// String s = formatTime(item.getDetailDisconnectedAt());
|
||||
// endTime.append(s).append("\n");
|
||||
// }
|
||||
//人工处置时间
|
||||
StringBuilder manualCloseTime = new StringBuilder();
|
||||
for (AutoCallPerson item : record.getCallList()) {
|
||||
String s = formatTime(item.getDetailDisconnectedAt());
|
||||
endTime.append(s).append("\n");
|
||||
String s = formatTime(item.getManualCloseTm());
|
||||
manualCloseTime.append(s).append("\n");
|
||||
}
|
||||
// 格式化时间
|
||||
String formattedCreateTime = formatTime(record.getCreateTm());
|
||||
// String formattedCreateTime = formatTime(record.getCreateTm());
|
||||
|
||||
// 添加行数据
|
||||
//序号
|
||||
table.addCell(new Cell().add(new Paragraph(String.valueOf(serialNumber++)).setFontSize(10)).setKeepTogether(true));
|
||||
//预警名称
|
||||
table.addCell(new Cell().add(new Paragraph(record.getWarnName() != null ? record.getWarnName() : "").setFontSize(10)).setKeepTogether(true));
|
||||
//县(市、区)
|
||||
table.addCell(new Cell().add(new Paragraph(region).setFontSize(10)).setKeepTogether(true));
|
||||
table.addCell(new Cell().add(new Paragraph(formattedCreateTime).setFontSize(10)).setKeepTogether(true));
|
||||
// table.addCell(new Cell().add(new Paragraph(formattedCreateTime).setFontSize(10)).setKeepTogether(true));
|
||||
//呼叫对象及职务
|
||||
table.addCell(new Cell().add(new Paragraph(callInfo.toString()).setFontSize(10)).setKeepTogether(true));
|
||||
//叫应情况
|
||||
table.addCell(new Cell().add(new Paragraph(status.toString()).setFontSize(10)).setKeepTogether(true));
|
||||
table.addCell(new Cell().add(new Paragraph(callTime.toString()).setFontSize(10)).setKeepTogether(true));
|
||||
// table.addCell(new Cell().add(new Paragraph(callTime.toString()).setFontSize(10)).setKeepTogether(true));
|
||||
//智能呼叫时间
|
||||
table.addCell(new Cell().add(new Paragraph(startTime.toString()).setFontSize(10)).setKeepTogether(true));
|
||||
table.addCell(new Cell().add(new Paragraph(endTime.toString()).setFontSize(10)).setKeepTogether(true));
|
||||
//人工处置时间
|
||||
table.addCell(new Cell().add(new Paragraph(manualCloseTime.toString()).setFontSize(10)).setKeepTogether(true));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import com.whdc.model.entity.autocall.AICCCallRespWrapper;
|
|||
import com.whdc.model.entity.autocall.AICCUploadTask;
|
||||
import com.whdc.utils.AICCHelper;
|
||||
import com.whdc.utils.SmsHelper;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
|
@ -36,6 +37,7 @@ import java.util.stream.Collectors;
|
|||
@Slf4j
|
||||
public class AutoCallTaskService2 {
|
||||
@Autowired
|
||||
@Getter
|
||||
private AutoCallTaskMapper taskMapper;
|
||||
@Autowired
|
||||
private AutoCallPersonMapper personMapper;
|
||||
|
|
@ -55,15 +57,11 @@ public class AutoCallTaskService2 {
|
|||
public void generateFakeCall() {
|
||||
QXWarning warn = qxWarningMapper.selectOne(
|
||||
new QueryWrapper<QXWarning>()
|
||||
// .like("CNNM", "洪湖")
|
||||
.orderByDesc("WARNID")
|
||||
.last("limit 1")
|
||||
);
|
||||
// warn.setCtnm("恩施州");
|
||||
// warn.setCnnm("咸丰 ");
|
||||
warn.setCtnm("荆州市");
|
||||
warn.setCnnm("洪湖 ");
|
||||
|
||||
List<AutoCallTask> taskList = newTask(warn);
|
||||
AutoCallTask task = taskList.get(0);
|
||||
task.setStatus(0);
|
||||
|
|
@ -71,6 +69,36 @@ public class AutoCallTaskService2 {
|
|||
task.setWarnCnnm("洪湖 ");
|
||||
taskMapper.insert(task);
|
||||
generatePerson(task);
|
||||
|
||||
warn = qxWarningMapper.selectOne(
|
||||
new QueryWrapper<QXWarning>()
|
||||
.orderByDesc("WARNID")
|
||||
.last("limit 1")
|
||||
);
|
||||
warn.setCtnm("荆州市");
|
||||
warn.setCnnm("秭归 ");
|
||||
taskList = newTask(warn);
|
||||
task = taskList.get(0);
|
||||
task.setStatus(0);
|
||||
task.setCreateTm(new Date());
|
||||
task.setWarnCnnm("秭归 ");
|
||||
taskMapper.insert(task);
|
||||
generatePerson(task);
|
||||
|
||||
warn = qxWarningMapper.selectOne(
|
||||
new QueryWrapper<QXWarning>()
|
||||
.orderByDesc("WARNID")
|
||||
.last("limit 1")
|
||||
);
|
||||
warn.setCtnm("荆州市");
|
||||
warn.setCnnm("竹溪 ");
|
||||
taskList = newTask(warn);
|
||||
task = taskList.get(0);
|
||||
task.setStatus(0);
|
||||
task.setCreateTm(new Date());
|
||||
task.setWarnCnnm("竹溪 ");
|
||||
taskMapper.insert(task);
|
||||
generatePerson(task);
|
||||
}
|
||||
|
||||
public List<AutoCallPerson> doCallTest() {
|
||||
|
|
@ -261,7 +289,7 @@ public class AutoCallTaskService2 {
|
|||
}
|
||||
}
|
||||
|
||||
private List<AutoCallPerson> newPerson(AutoCallTask task) {
|
||||
public List<AutoCallPerson> newPerson(AutoCallTask task) {
|
||||
String cnnm = task.getWarnCnnm();
|
||||
long millis = task.getCreateTm().getTime();
|
||||
List<Integer> warnLevels = mapWarnSignalLevel(task.getWarnLevel());
|
||||
|
|
@ -368,11 +396,13 @@ public class AutoCallTaskService2 {
|
|||
} catch (GeneralSecurityException | UnsupportedEncodingException e) {
|
||||
person.setStatus(AutoCallPerson.STATUS_CANCELLED);
|
||||
person.setErrorCode(AutoCallPerson.ERRCODE_ENCODE);
|
||||
person.setDetailRemark("平台异常");
|
||||
personMapper.updateById(person);
|
||||
log.error("外呼任务编码异常", e);
|
||||
}
|
||||
if (AICCCallRespWrapper == null) {
|
||||
person.setStatus(AutoCallPerson.STATUS_CANCELLED);
|
||||
person.setDetailRemark("提交外呼失败");
|
||||
person.setErrorCode(AutoCallPerson.ERRCODE_UPLOAD_FAIL);
|
||||
personMapper.updateById(person);
|
||||
} else {
|
||||
|
|
@ -422,17 +452,21 @@ public class AutoCallTaskService2 {
|
|||
person.setTag(tag);
|
||||
}
|
||||
//再判断状态
|
||||
if ("接通".equals(dialRemark)) {
|
||||
person.setStatus(AutoCallPerson.STATUS_PUT);
|
||||
} else {
|
||||
// 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)) {
|
||||
if ("接通".equals(dialRemark)) {
|
||||
person.setStatus(AutoCallPerson.STATUS_PUT);
|
||||
personMapper.updateById(person);
|
||||
}
|
||||
markRemnantPersonStatus(taskId);
|
||||
taskMapper.setTag(taskId, tag);
|
||||
taskMapper.setStatus(taskId, AutoCallTask.STATUS_ANY_SUCCESS);
|
||||
|
|
@ -491,6 +525,8 @@ public class AutoCallTaskService2 {
|
|||
|
||||
person.setStatus(AutoCallPerson.STATUS_MANUAL_CLOSE);
|
||||
person.setTag("已知晓");
|
||||
person.setManualClose(1);
|
||||
person.setManualCloseTm(new Date());
|
||||
personMapper.updateById(person);
|
||||
task.setTag("已知晓");
|
||||
task.setStatus(AutoCallTask.STATUS_MANUAL_CLOSE);
|
||||
|
|
@ -579,8 +615,13 @@ public class AutoCallTaskService2 {
|
|||
|
||||
|
||||
public void cancelPerson(AutoCallPerson person) {
|
||||
Integer taskId = person.getTaskId();
|
||||
person.setStatus(AutoCallPerson.STATUS_CANCELLED);
|
||||
personMapper.updateById(person);
|
||||
boolean allFail = personMapper.isAllFail(taskId);
|
||||
if (allFail) {
|
||||
taskMapper.setStatus(taskId, AutoCallTask.STATUS_ALL_FAIL);
|
||||
}
|
||||
}
|
||||
|
||||
private void markRemnantPersonStatus(Integer taskId) {
|
||||
|
|
@ -594,16 +635,16 @@ public class AutoCallTaskService2 {
|
|||
|
||||
}
|
||||
|
||||
private boolean markTaskStatus(Integer taskId) {
|
||||
boolean anySuccess = personMapper.isAnySuccess(taskId);
|
||||
if (anySuccess) {
|
||||
taskMapper.setStatus(taskId, AutoCallTask.STATUS_ANY_SUCCESS);
|
||||
return true;
|
||||
}
|
||||
boolean allFail = personMapper.isAllFail(taskId);
|
||||
if (allFail) {
|
||||
taskMapper.setStatus(taskId, AutoCallTask.STATUS_ALL_FAIL);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// private boolean markTaskStatus(Integer taskId) {
|
||||
// boolean anySuccess = personMapper.isAnySuccess(taskId);
|
||||
// if (anySuccess) {
|
||||
// taskMapper.setStatus(taskId, AutoCallTask.STATUS_ANY_SUCCESS);
|
||||
// return true;
|
||||
// }
|
||||
// boolean allFail = personMapper.isAllFail(taskId);
|
||||
// if (allFail) {
|
||||
// taskMapper.setStatus(taskId, AutoCallTask.STATUS_ALL_FAIL);
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -124,6 +124,8 @@ public class AICCHelper {
|
|||
log.error("apiUploadCallData first time: {}", resp);
|
||||
log.error("error: ", ex);
|
||||
}
|
||||
} else {
|
||||
log.info("apiUploadCallData first time: {}", resp);
|
||||
}
|
||||
|
||||
if (AICCCallRespWrapper == null || !AICCCallRespWrapper.isSuccess()) {
|
||||
|
|
@ -137,6 +139,8 @@ public class AICCHelper {
|
|||
log.error("apiUploadCallData second time: {}", resp);
|
||||
log.error("error: ", ex);
|
||||
}
|
||||
} else {
|
||||
log.info("apiUploadCallData second time: {}", resp);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -169,6 +173,7 @@ public class AICCHelper {
|
|||
}
|
||||
|
||||
if (AICCCallRespWrapper == null || !AICCCallRespWrapper.isSuccess()) {
|
||||
log.info("获取任务详情失败:{}", resp);
|
||||
return null;
|
||||
}
|
||||
return AICCCallRespWrapper;
|
||||
|
|
|
|||
Loading…
Reference in New Issue