清理废弃代码
parent
7ee22a55da
commit
f4f5d8b822
|
|
@ -1,20 +1,15 @@
|
|||
package com.whdc.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.whdc.mapper.WarningResponderMapper;
|
||||
import com.whdc.mapper.AutoCallConfigMapper;
|
||||
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;
|
||||
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.AICCHelper;
|
||||
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.*;
|
||||
|
|
@ -25,8 +20,6 @@ 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;
|
||||
|
||||
/**
|
||||
|
|
@ -39,15 +32,11 @@ public class AutoCallController {
|
|||
@Autowired
|
||||
private AutoCallApiService autoCallApiService;
|
||||
@Autowired
|
||||
private AutoCallTaskService autoCallTaskService;
|
||||
@Autowired
|
||||
private AutoCallTaskService2 autoCallTaskService2;
|
||||
|
||||
@GetMapping("/doCallTest")
|
||||
public ResultJson<String> doCallTest() throws ParseException {
|
||||
autoCallTaskService.generateFakeCall();
|
||||
return ResultJson.ok("resp");
|
||||
}
|
||||
@Autowired
|
||||
private AICCHelper aiccHelper;
|
||||
@Autowired
|
||||
private AutoCallConfigMapper configMapper;
|
||||
|
||||
@GetMapping("/doGenerateTest2")
|
||||
public ResultJson<String> doGenerateTest2() throws ParseException {
|
||||
|
|
@ -63,21 +52,12 @@ public class AutoCallController {
|
|||
|
||||
@GetMapping("/getToken")
|
||||
public ResultJson<String> getToken() {
|
||||
return ResultJson.ok(autoCallTaskService.getToken());
|
||||
}
|
||||
|
||||
@GetMapping("/queryTaskResult")
|
||||
public ResultJson<String> queryTaskResult(@RequestParam("requestId") String requestId, @RequestParam("custId") String custId) {
|
||||
return ResultJson.ok(autoCallTaskService.queryTaskResult(requestId, custId));
|
||||
}
|
||||
|
||||
@PostMapping("/page")
|
||||
public ResultJson<Page<WarnCallMap>> newList(@RequestBody AutoCallDto dto) {
|
||||
return ResultJson.ok(autoCallApiService.page(dto));
|
||||
return ResultJson.ok(aiccHelper.getToken());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有未接通的数据
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/listCallIsNotPass")
|
||||
|
|
@ -87,6 +67,7 @@ public class AutoCallController {
|
|||
|
||||
/**
|
||||
* 分页查询所有未接通的数据
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/listCallIsNotPassPage")
|
||||
|
|
@ -99,19 +80,15 @@ public class AutoCallController {
|
|||
return ResultJson.ok(autoCallApiService.page2(dto));
|
||||
}
|
||||
|
||||
@GetMapping("/listCallIsNotPut")
|
||||
public ResultJson<List<WarnCallMap>> listCallIsNotPut() {
|
||||
return ResultJson.ok(autoCallApiService.listCallIsNotPut());
|
||||
}
|
||||
|
||||
@GetMapping("/isEnable")
|
||||
public ResultJson<Boolean> isEnable() {
|
||||
return ResultJson.ok(autoCallTaskService.isEnable());
|
||||
return ResultJson.ok(configMapper.isEnable());
|
||||
}
|
||||
|
||||
@GetMapping("/setEnable")
|
||||
public ResultJson<Boolean> setEnable(@RequestParam("enable") Boolean enable) {
|
||||
autoCallTaskService.setEnable(enable);
|
||||
configMapper.setEnable(enable);
|
||||
return ResultJson.ok(true);
|
||||
}
|
||||
|
||||
|
|
@ -120,30 +97,6 @@ public class AutoCallController {
|
|||
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);
|
||||
return ResultJson.ok(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 预警的批量关闭
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
@PostMapping("/setCallIsPutList")
|
||||
public ResultJson<Boolean> setCallIsPutList(@RequestBody CallPutDto dto) {
|
||||
autoCallTaskService.setCallIsPutList(dto);
|
||||
return ResultJson.ok(true);
|
||||
}
|
||||
|
||||
@PostMapping("/exportPdf")
|
||||
public void exportPDF(@RequestBody AutoCallDto dto,
|
||||
HttpServletResponse response,
|
||||
|
|
@ -171,7 +124,7 @@ public class AutoCallController {
|
|||
response.setHeader("Content-Disposition",
|
||||
"attachment; filename=\"" + new String(fileName.getBytes("GBK"), "ISO-8859-1") + "\"");
|
||||
}
|
||||
IOUtils.copy(pdfStream,response.getOutputStream());
|
||||
IOUtils.copy(pdfStream, response.getOutputStream());
|
||||
response.flushBuffer();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
|
@ -180,7 +133,7 @@ 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,
|
||||
public void getPdf(@RequestParam("stm") String stm, @RequestParam("etm") String etm, HttpServletResponse response,
|
||||
HttpServletRequest request) {
|
||||
AutoCallDto dto = new AutoCallDto();
|
||||
dto.setStm(stm);
|
||||
|
|
@ -209,7 +162,7 @@ public class AutoCallController {
|
|||
response.setHeader("Content-Disposition",
|
||||
"attachment; filename=\"" + new String(fileName.getBytes("GBK"), "ISO-8859-1") + "\"");
|
||||
}
|
||||
IOUtils.copy(pdfStream,response.getOutputStream());
|
||||
IOUtils.copy(pdfStream, response.getOutputStream());
|
||||
response.flushBuffer();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
|
@ -217,7 +170,7 @@ public class AutoCallController {
|
|||
}
|
||||
|
||||
@GetMapping("/newPerson")
|
||||
public ResultJson newPerson(@RequestParam("taskId")Integer taskId) {
|
||||
public ResultJson newPerson(@RequestParam("taskId") Integer taskId) {
|
||||
AutoCallTask task = autoCallTaskService2.getTaskMapper().selectById(taskId);
|
||||
return ResultJson.ok(autoCallTaskService2.newPerson(task));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,17 @@ public interface AutoCallConfigMapper extends BaseMapper<AutoCallConfig> {
|
|||
return config != null && "1".equals(config.getValue());
|
||||
}
|
||||
|
||||
default void setEnable(Boolean enable) {
|
||||
AutoCallConfig config = new AutoCallConfig();
|
||||
config.setKey("enable");
|
||||
config.setValue(enable ? "1" : "0");
|
||||
update(
|
||||
config,
|
||||
new QueryWrapper<AutoCallConfig>()
|
||||
.eq("key", "enable")
|
||||
);
|
||||
}
|
||||
|
||||
default boolean isScheduled() {
|
||||
AutoCallConfig config = selectOne(
|
||||
new QueryWrapper<AutoCallConfig>()
|
||||
|
|
|
|||
|
|
@ -1,57 +0,0 @@
|
|||
package com.whdc.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.whdc.model.entity.QXWarning;
|
||||
import com.whdc.model.entity.WarnCallMap;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lyf
|
||||
* @since 2025-06-19
|
||||
*/
|
||||
public interface WarnCallMapMapper extends BaseMapper<WarnCallMap> {
|
||||
List<QXWarning> listWarnsThatNotGeneratedWcm();
|
||||
|
||||
default List<WarnCallMap> listUnGeneratedWcm() {
|
||||
return selectList(
|
||||
new QueryWrapper<WarnCallMap>()
|
||||
.eq("should_generate", 1)
|
||||
.eq("generated", 0)
|
||||
.eq("err_step", 0)
|
||||
.orderByAsc("id")
|
||||
);
|
||||
}
|
||||
|
||||
default List<WarnCallMap> listUnUploadedWcm() {
|
||||
return selectList(
|
||||
new QueryWrapper<WarnCallMap>()
|
||||
.eq("generated", 1)
|
||||
.eq("uploaded", 0)
|
||||
.eq("err_step", 0)
|
||||
.orderByAsc("id")
|
||||
);
|
||||
}
|
||||
|
||||
default List<WarnCallMap> listUnCalledWcm() {
|
||||
return selectList(
|
||||
new QueryWrapper<WarnCallMap>()
|
||||
.eq("uploaded", 1)
|
||||
.eq("called", 0)
|
||||
.eq("err_step", 0)
|
||||
.orderByAsc("id")
|
||||
);
|
||||
}
|
||||
|
||||
default List<WarnCallMap> listCallIsNotPutWcm() {
|
||||
return selectList(
|
||||
new QueryWrapper<WarnCallMap>()
|
||||
.eq("uploaded", 1)
|
||||
.eq("called", 1)
|
||||
.eq("call_is_put", 0)
|
||||
.eq("err_step", 0)
|
||||
.orderByDesc("id")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,73 +0,0 @@
|
|||
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;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lyf
|
||||
* @since 2025-06-19
|
||||
*/
|
||||
@Data
|
||||
@TableName("FXKH_TXL.WARN_CALL_MAP")
|
||||
public class WarnCallMap {
|
||||
/*
|
||||
new的时候必填warnId,shouldGenerate,cnnm,requestId,custId,custName,warnName,warnTm,warnLevel,callContent,createTm
|
||||
生成autoCall后必填generated
|
||||
upload后必填uploadRespMsg,uploaded
|
||||
query后必填callIsPut,called
|
||||
*/
|
||||
@TableId(value = "ID", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
@TableField(value = "warn_id")
|
||||
private Integer warnId; //not null
|
||||
@TableField(value = "should_generate")
|
||||
private Integer shouldGenerate; //0:不生成,1:生成, not null
|
||||
@TableField(value = "generated")
|
||||
private Integer generated; //0:未生成,1:已生成, default 0
|
||||
@TableField(value = "uploaded")
|
||||
private Integer uploaded; //0:未上传,1:已上传, default 0
|
||||
@TableField(value = "cnnm")
|
||||
private String cnnm;
|
||||
@TableField(value = "upload_resp_msg")
|
||||
private String uploadRespMsg;
|
||||
@TableField(value = "request_id")
|
||||
private String requestId; //任务名,作为参数的taskName
|
||||
@TableField(value = "cust_id")
|
||||
private String custId; //联系人id
|
||||
@TableField(value = "cust_name")
|
||||
private String custName; //联系人
|
||||
@TableField(value = "call_is_put")
|
||||
private Integer callIsPut; //0:未接通,1:已接通, default 0
|
||||
@TableField(value = "called")
|
||||
private Integer called; //0:未拨打,1:已拨打, default 0
|
||||
@TableField(value = "err_step")
|
||||
private Integer errStep; //0:初始化,1:step1出错, 以此类推,default 0
|
||||
|
||||
@TableField(value = "warn_name")
|
||||
private String warnName;
|
||||
@TableField(value = "warn_tm")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
private Date warnTm;
|
||||
@TableField(value = "warn_level")
|
||||
private String warnLevel;
|
||||
@TableField(value = "call_content")
|
||||
private String warnContent;
|
||||
|
||||
@TableField(value = "_create_tm")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
private Date createTm;
|
||||
@TableField(value = "_remark")
|
||||
private String remark;
|
||||
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<AutoCall> callList;
|
||||
|
||||
}
|
||||
|
|
@ -1,522 +0,0 @@
|
|||
package com.whdc.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.whdc.mapper.*;
|
||||
import com.whdc.model.dto.CallPutDto;
|
||||
import com.whdc.model.entity.*;
|
||||
import com.whdc.model.entity.autocall.AICCCallRespDetail;
|
||||
import com.whdc.model.entity.autocall.AICCCallRespWrapper;
|
||||
import com.whdc.model.entity.autocall.AICCUploadTask;
|
||||
import com.whdc.model.entity.autocall.AICCCallRespTask;
|
||||
import com.whdc.utils.AutoCallHelper;
|
||||
import com.whdc.utils.SmsHelper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.whdc.model.entity.AutoCallTask.STATUS_MANUAL_CLOSE;
|
||||
|
||||
/**
|
||||
* @author lyf
|
||||
* @since 2025-06-14
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class AutoCallTaskService {
|
||||
private static final String[] excludeNames = new String[]{"高新", "开发", "自治", "技术", "旅游", "管理", "工业", "产业", "示范"};
|
||||
private static final AtomicBoolean isCalling = new AtomicBoolean(false);
|
||||
|
||||
|
||||
@Autowired
|
||||
private AutoCallTaskMapper autoCallTaskMapper;
|
||||
@Autowired
|
||||
private WarningResponderMapper warningResponderMapper;
|
||||
@Autowired
|
||||
private QXWarningMapper qxWarningMapper;
|
||||
@Autowired
|
||||
private AutoCallMapper autoCallMapper;
|
||||
@Autowired
|
||||
private AutoCallConfigMapper configMapper;
|
||||
@Autowired
|
||||
private WarnCallMapMapper warnCallMapMapper;
|
||||
@Autowired
|
||||
private AutoCallHelper autoCallHelper;
|
||||
@Autowired
|
||||
private SmsHelper smsHelper;
|
||||
@Value("${autocall.processId}")
|
||||
private String processId;
|
||||
@Value("${autocall.callerGroup}")
|
||||
private String callerGroup;
|
||||
@Value("${autocall.secret}")
|
||||
private String secret;
|
||||
@Value("${autocall.sysUserId}")
|
||||
private String sysUserId;
|
||||
|
||||
@Transactional
|
||||
public void generateFakeCall() throws ParseException {
|
||||
QXWarning warn = qxWarningMapper.selectOne(
|
||||
new QueryWrapper<QXWarning>()
|
||||
.orderByDesc("WARNID")
|
||||
.last("limit 1")
|
||||
);
|
||||
warn.setCtnm("恩施州");
|
||||
warn.setCnnm("咸丰,");
|
||||
|
||||
List<WarnCallMap> wcmList = newWcmByWarn(warn);
|
||||
WarnCallMap wcm = wcmList.get(0);
|
||||
wcm.setCreateTm(new Date());
|
||||
warnCallMapMapper.insert(wcm);
|
||||
}
|
||||
|
||||
public void step1GenerateWarnCallMap() {
|
||||
List<QXWarning> warnList = warnCallMapMapper.listWarnsThatNotGeneratedWcm();
|
||||
for (QXWarning warn : warnList) {
|
||||
try {
|
||||
List<WarnCallMap> wcmList = newWcmByWarn(warn);
|
||||
for (WarnCallMap wcm : wcmList) {
|
||||
if (wcm.getCnnm() == null) {
|
||||
wcm.setErrStep(1);
|
||||
wcm.setRemark("未找到县区");
|
||||
}
|
||||
wcm.setCreateTm(new Date());
|
||||
warnCallMapMapper.insert(wcm);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("根据预警生成呼叫失败", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
return autoCallHelper.getToken();
|
||||
}
|
||||
|
||||
private @NotNull List<WarnCallMap> newWcmByWarn(QXWarning warn) throws ParseException {
|
||||
String cnnmStr = warn.getCnnm();
|
||||
Integer warnId = warn.getWarnid();
|
||||
String warnSignalLevel = warn.getWarnSignalLevel();
|
||||
String content = warn.getContent();
|
||||
String ctnm = warn.getCtnm();
|
||||
Date publishTime = warn.getPublishTime();
|
||||
|
||||
List<WarnCallMap> wcmList = new ArrayList<>();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日HH时mm分");
|
||||
// content = "我是省防办智能外呼系统," + content + "如需咨询请拨打02787221781";
|
||||
content = "我是省防办智能外呼系统," +warn.getCtnm()+sdf.format(warn.getPublishTime()) +"发布暴雨"+warn.getWarnSignalLevel()+"预警信号:"+ content + "如需咨询请拨打02787221781,相关信息以短信发送给您。";
|
||||
if (cnnmStr == null || cnnmStr.trim().isEmpty()) {
|
||||
WarnCallMap wcm = newWcm(null, warnId, publishTime, ctnm, warnSignalLevel, content);
|
||||
wcmList.add(wcm);
|
||||
return wcmList;
|
||||
}
|
||||
String[] cnnms = cnnmStr.trim().split(",");
|
||||
for (String cnnm : cnnms) {
|
||||
if (cnnm.isEmpty()) continue;
|
||||
if (publishTime == null) continue;
|
||||
|
||||
WarnCallMap wcm = newWcm(cnnm, warnId, publishTime, ctnm, warnSignalLevel, content);
|
||||
wcmList.add(wcm);
|
||||
}
|
||||
return wcmList;
|
||||
}
|
||||
|
||||
private @NotNull WarnCallMap newWcm(String cnnm, Integer warnId, Date publishTime, String ctnm, String warnSignalLevel, String content) throws ParseException {
|
||||
WarnCallMap wcm = new WarnCallMap();
|
||||
wcm.setWarnId(warnId);
|
||||
wcm.setCnnm(cnnm);
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
wcm.setWarnTm(publishTime);
|
||||
|
||||
wcm.setWarnName(String.format("%s%s%s%s预警", sdf.format(publishTime), ctnm, cnnm, warnSignalLevel));
|
||||
wcm.setWarnLevel(warnSignalLevel);
|
||||
wcm.setWarnContent(content);
|
||||
wcm.setRequestId("hbsl" + new Date().getTime() + cnnm);
|
||||
|
||||
if (isEnable()) {
|
||||
wcm.setShouldGenerate(1);
|
||||
} else {
|
||||
wcm.setShouldGenerate(0);
|
||||
}
|
||||
return wcm;
|
||||
}
|
||||
|
||||
//为什么wcm和autocall的生成要分开:wcm是根据qxwarning生成的,自动呼叫可能会暂停,避免之后开启会根据早时的qxwarning生成wcm进而呼叫
|
||||
public void step2GenerateAutoCallByWcm() {
|
||||
List<WarnCallMap> wcmList = warnCallMapMapper.listUnGeneratedWcm();
|
||||
for (WarnCallMap wcm : wcmList) {
|
||||
List<AutoCall> autoCallList = newAutoCall(wcm);
|
||||
if (autoCallList.size() == 0) {
|
||||
wcm.setErrStep(2);
|
||||
wcm.setRemark("未找到责任人");
|
||||
warnCallMapMapper.updateById(wcm);
|
||||
return;
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
//将responderId合并为custId
|
||||
for (AutoCall autoCall : autoCallList) {
|
||||
sb.append(autoCall.getResponderId()).append("-");
|
||||
}
|
||||
sb.deleteCharAt(sb.length() - 1);
|
||||
String custId = System.currentTimeMillis() + "-" + sb;
|
||||
//将responderName合并为custName
|
||||
sb = new StringBuilder();
|
||||
for (AutoCall autoCall : autoCallList) {
|
||||
sb.append(autoCall.getResponderName()).append(",");
|
||||
}
|
||||
sb.deleteCharAt(sb.length() - 1);
|
||||
String custName = sb.toString();
|
||||
wcm.setCustId(custId);
|
||||
wcm.setCustName(custName);
|
||||
wcm.setGenerated(1);
|
||||
|
||||
Date now = new Date();
|
||||
autoCallList.forEach(a -> {
|
||||
a.setCreateTm(now);
|
||||
autoCallMapper.insert(a);
|
||||
});
|
||||
|
||||
warnCallMapMapper.updateById(wcm);
|
||||
}
|
||||
}
|
||||
|
||||
private @NotNull List<AutoCall> newAutoCall(WarnCallMap wcm) {
|
||||
Integer wcmId = wcm.getId();
|
||||
String cnnm = wcm.getCnnm();
|
||||
List<AutoCall> existList = autoCallMapper.listByWcmIdAndCnnmOrderByLevelAsc(wcmId, cnnm);
|
||||
if (existList != null && existList.size() > 0) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return newAutoCall(wcmId, cnnm, wcm.getWarnLevel());
|
||||
}
|
||||
|
||||
private @NotNull List<AutoCall> newAutoCall(Integer wcmId, String cnnm, String warnLevelStr) {
|
||||
//处理行政区划和预警级别,橙色预警拨打1,2level的,红色预警只拨打3level的
|
||||
List<Integer> warnLevel = mapWarnSignalLevel(warnLevelStr);
|
||||
List<WarningResponder> wrList = listWarningResponderByCnnmAndLevelOrderByLevelAsc(cnnm, warnLevel);
|
||||
if (wrList.isEmpty()) return Collections.emptyList();
|
||||
//处理县区包含高新区、开发区等情况
|
||||
doSomethingWith(cnnm, wrList);
|
||||
//按level从小到大排序
|
||||
wrList.sort(Comparator.comparingInt(WarningResponder::getLevel));
|
||||
List<AutoCall> autoCallList = new ArrayList<>();
|
||||
for (WarningResponder wr : wrList) {
|
||||
Integer wrLevel = wr.getLevel();
|
||||
wr.decryptPhone();
|
||||
AutoCall autoCall = new AutoCall();
|
||||
autoCall.setResponderId(wr.getId())
|
||||
.setResponderName(wr.getName())
|
||||
.setWcmId(wcmId)
|
||||
.setLevel(wrLevel)
|
||||
.setNumber(wr.getPhone());
|
||||
autoCallList.add(autoCall);
|
||||
}
|
||||
|
||||
return autoCallList;
|
||||
}
|
||||
|
||||
public void step3UploadCallTask() {
|
||||
if (!isCalling.compareAndSet(false, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
//已提交,提交返回内容为“导入成功”,未拨打
|
||||
List<WarnCallMap> wcmList = warnCallMapMapper.listUnUploadedWcm();
|
||||
if (wcmList == null || wcmList.isEmpty()) return;
|
||||
|
||||
for (WarnCallMap wcm : wcmList) {
|
||||
Integer wcmId = wcm.getId();
|
||||
List<AutoCall> autoCallList = autoCallMapper.listByWcmIdAndCnnmOrderByLevelAsc(wcmId, wcm.getCnnm());
|
||||
if (autoCallList == null || autoCallList.isEmpty()) {
|
||||
wcm.setErrStep(3);
|
||||
wcm.setRemark("未找到呼叫列表");
|
||||
warnCallMapMapper.updateById(wcm);
|
||||
continue;
|
||||
}
|
||||
|
||||
List<String> numbers = autoCallList.stream()
|
||||
.map(AutoCall::getNumber)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
AICCUploadTask task = autoCallHelper.newTask(
|
||||
wcm.getRequestId(),
|
||||
wcm.getCustId(),
|
||||
wcm.getCustName(),
|
||||
wcm.getWarnContent(),
|
||||
numbers
|
||||
);
|
||||
AICCCallRespWrapper<AICCCallRespTask> AICCCallRespWrapper = autoCallHelper.apiUploadCallData(task);
|
||||
|
||||
String msg = AICCCallRespWrapper.getResult().getMsg();
|
||||
wcm.setUploaded(1);
|
||||
wcm.setUploadRespMsg(msg);
|
||||
warnCallMapMapper.updateById(wcm);
|
||||
|
||||
smsHelper.send(numbers, wcm.getWarnContent());
|
||||
}
|
||||
} finally {
|
||||
isCalling.set(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void step4QueryTaskResult() {
|
||||
List<WarnCallMap> wcmList = warnCallMapMapper.listUnCalledWcm();
|
||||
if (wcmList.isEmpty()) return;
|
||||
|
||||
for (WarnCallMap wcm : wcmList) {
|
||||
Integer wcmId = wcm.getId();
|
||||
String requestId = wcm.getRequestId();
|
||||
String custId = wcm.getCustId();
|
||||
|
||||
List<AutoCall> autoCallList = autoCallMapper.listByWcmIdAndCnnmOrderByLevelAsc(wcmId, wcm.getCnnm());
|
||||
if (autoCallList == null || autoCallList.isEmpty()) {
|
||||
wcm.setErrStep(4);
|
||||
wcm.setRemark("未找到呼叫列表");
|
||||
warnCallMapMapper.updateById(wcm);
|
||||
continue;
|
||||
}
|
||||
|
||||
AICCCallRespWrapper<AICCCallRespDetail> AICCCallRespWrapper = autoCallHelper.apiGetTaskCallDetail(requestId, custId);
|
||||
if (AICCCallRespWrapper == null || !AICCCallRespWrapper.isSuccess()) {
|
||||
wcm.setErrStep(4);
|
||||
wcm.setRemark("请求外呼平台失败");
|
||||
warnCallMapMapper.updateById(wcm);
|
||||
continue;
|
||||
}
|
||||
|
||||
//任务不存在
|
||||
if (AICCCallRespWrapper.getResult() == null
|
||||
|| AICCCallRespWrapper.getResult().getData() == null
|
||||
|| AICCCallRespWrapper.getResult().getData().getRecords() == null
|
||||
|| AICCCallRespWrapper.getResult().getData().getRecords().isEmpty()) {
|
||||
wcm.setErrStep(4);
|
||||
wcm.setRemark("外呼平台查询不到任务");
|
||||
warnCallMapMapper.updateById(wcm);
|
||||
continue;
|
||||
}
|
||||
|
||||
List<AICCCallRespDetail.Record> records = AICCCallRespWrapper.getResult().getData().getRecords();
|
||||
boolean anyCalled = true;
|
||||
boolean anyCallIsPut = false;
|
||||
for (AICCCallRespDetail.Record record : records) {
|
||||
if (record.getRemark() == null || record.getRemark().isEmpty()) {
|
||||
anyCalled = false;
|
||||
continue;
|
||||
}
|
||||
if ("接通".equals(record.getRemark())) anyCallIsPut = true;
|
||||
AICCCallRespDetail.RawVarListMap rawVarListMap = record.getRawVarListMap();
|
||||
String number = rawVarListMap.getNumber();
|
||||
AutoCall call = null;
|
||||
for (AutoCall a : autoCallList) {
|
||||
if (a.getNumber().equals(number)) {
|
||||
call = a;
|
||||
break;
|
||||
}
|
||||
}
|
||||
copyDataFromDetailToAutoCall(record, call, rawVarListMap);
|
||||
}
|
||||
if (!records.isEmpty() && anyCalled) {
|
||||
wcm.setCalled(1);
|
||||
warnCallMapMapper.updateById(wcm);
|
||||
}
|
||||
|
||||
for (AutoCall a : autoCallList) {
|
||||
if (a.getStatus() == null && anyCallIsPut) {
|
||||
a.setStatus("已呼通其他责任人");
|
||||
}
|
||||
autoCallMapper.updateById(a);
|
||||
}
|
||||
if (anyCallIsPut) {
|
||||
wcm.setCallIsPut(1);
|
||||
warnCallMapMapper.updateById(wcm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public AICCCallRespWrapper<AICCCallRespDetail> queryTaskResult(String requestId, String custId) {
|
||||
return autoCallHelper.apiGetTaskCallDetail(requestId, custId);
|
||||
}
|
||||
|
||||
private void copyDataFromDetailToAutoCall(AICCCallRespDetail.Record record, AutoCall call, AICCCallRespDetail.RawVarListMap rawVarListMap) {
|
||||
if (call != null) {
|
||||
call.setStatus(record.getRemark());
|
||||
call.setTalkTimes(record.getTalkTimes());
|
||||
call.setSipTermCause(rawVarListMap.getSipTermCause());
|
||||
call.setCaller(rawVarListMap.getCaller());
|
||||
|
||||
Date d;
|
||||
long l;
|
||||
|
||||
if (rawVarListMap.getStartringAt() != null) {
|
||||
d = new Date();
|
||||
l = Long.parseLong(rawVarListMap.getStartringAt().substring(0, 13));
|
||||
d.setTime(l);
|
||||
call.setStartringAt(d);
|
||||
}
|
||||
|
||||
if (rawVarListMap.getConnectedAt() != null) {
|
||||
d = new Date();
|
||||
l = Long.parseLong(rawVarListMap.getConnectedAt().substring(0, 13));
|
||||
d.setTime(l);
|
||||
call.setConnectedAt(d);
|
||||
}
|
||||
|
||||
if (rawVarListMap.getStartedAt() != null) {
|
||||
d = new Date();
|
||||
l = Long.parseLong(rawVarListMap.getStartedAt());
|
||||
d.setTime(l);
|
||||
call.setStartedAt(d);
|
||||
}
|
||||
|
||||
if (rawVarListMap.getEndringAt() != null) {
|
||||
d = new Date();
|
||||
l = Long.parseLong(rawVarListMap.getEndringAt().substring(0, 13));
|
||||
d.setTime(l);
|
||||
call.setEndringAt(d);
|
||||
}
|
||||
|
||||
if (rawVarListMap.getDisconnectedAt() != null) {
|
||||
d = new Date();
|
||||
l = Long.parseLong(rawVarListMap.getDisconnectedAt().substring(0, 13));
|
||||
d.setTime(l);
|
||||
call.setDisconnectedAt(d);
|
||||
}
|
||||
|
||||
if (rawVarListMap.getStopedAt() != null) {
|
||||
d = new Date();
|
||||
l = Long.parseLong(rawVarListMap.getStopedAt());
|
||||
d.setTime(l);
|
||||
call.setStopedAt(d);
|
||||
}
|
||||
|
||||
if (rawVarListMap.getLastModify() != null) {
|
||||
d = new Date();
|
||||
l = Long.parseLong(rawVarListMap.getLastModify());
|
||||
d.setTime(l);
|
||||
call.setLastModify(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private List<Integer> mapWarnSignalLevel(String warnSignalLevel) {
|
||||
/**
|
||||
* 目前需求不区分预警级别,固定查取 1 2 3 4级,全部都呼叫
|
||||
*/
|
||||
List<Integer> ret = new ArrayList<>();
|
||||
ret.add(1);
|
||||
ret.add(2);
|
||||
ret.add(3);
|
||||
ret.add(4);
|
||||
// if ("红色".equals(warnSignalLevel)) {
|
||||
// ret.add(3);
|
||||
// } else {
|
||||
// ret.add(1);
|
||||
// ret.add(2);
|
||||
// }
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
更新字典,是否开启自动呼叫
|
||||
*/
|
||||
public void setEnable(Boolean enable) {
|
||||
AutoCallConfig config = new AutoCallConfig();
|
||||
config.setKey("enable");
|
||||
config.setValue(enable ? "1" : "0");
|
||||
configMapper.update(
|
||||
config,
|
||||
new QueryWrapper<AutoCallConfig>()
|
||||
.eq("key", "enable")
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
查询字典,是否开启自动呼叫
|
||||
*/
|
||||
public boolean isEnable() {
|
||||
AutoCallConfig config = configMapper.selectOne(
|
||||
new QueryWrapper<AutoCallConfig>()
|
||||
.eq("key", "enable")
|
||||
.last("limit 1")
|
||||
);
|
||||
return config != null && "1".equals(config.getValue());
|
||||
}
|
||||
|
||||
public void setCallIsPut(Integer wcmId) {
|
||||
WarnCallMap wcm = warnCallMapMapper.selectById(wcmId);
|
||||
wcm.setCalled(1);
|
||||
wcm.setCallIsPut(1);
|
||||
warnCallMapMapper.updateById(wcm);
|
||||
}
|
||||
|
||||
/*
|
||||
查询字典,是否开启定时任务
|
||||
*/
|
||||
public boolean isScheduled() {
|
||||
AutoCallConfig config = configMapper.selectOne(
|
||||
new QueryWrapper<AutoCallConfig>()
|
||||
.eq("key", "schedule")
|
||||
.last("limit 1")
|
||||
);
|
||||
return config != null && "1".equals(config.getValue());
|
||||
}
|
||||
|
||||
private static void doSomethingWith(String cnmm, List<WarningResponder> wrList) {
|
||||
//预警包含高新等字符,可跳出
|
||||
boolean skip = false;
|
||||
for (String excludeName : excludeNames) {
|
||||
if (cnmm.contains(excludeName)) {
|
||||
skip = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (skip) {
|
||||
return;
|
||||
}
|
||||
//预警不包含高新等字符,检查人员,保留不包含高新等字符的人员
|
||||
Iterator<WarningResponder> iter = wrList.iterator();
|
||||
while (iter.hasNext()) {
|
||||
WarningResponder autoCall = iter.next();
|
||||
boolean anyMatch = false;
|
||||
for (String excludeName : excludeNames) {
|
||||
if (autoCall.getCnnm().contains(excludeName)) {
|
||||
anyMatch = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (anyMatch) {
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<WarningResponder> listWarningResponderByCnnmAndLevelOrderByLevelAsc(String cnnm, List<Integer> levels) {
|
||||
return warningResponderMapper.listByCnnmAndLevelOrderByLevelAsc(cnnm, levels);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void setCallIsPutList(CallPutDto dto) {
|
||||
LambdaQueryWrapper<AutoCallTask> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.in(AutoCallTask::getId,dto.getTaskIds());
|
||||
List<AutoCallTask> autoCallTasks = autoCallTaskMapper.selectList(queryWrapper);
|
||||
for (AutoCallTask autoCallTask : autoCallTasks) {
|
||||
//告警任务取消
|
||||
autoCallTask.setStatus(STATUS_MANUAL_CLOSE);
|
||||
autoCallTask.setRemark("人工处置");
|
||||
autoCallTaskMapper.updateById(autoCallTask);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue