@@ -0,0 +1,55 @@ | |||
package cn.com.taiji.core.entity.msgw; | |||
import java.time.LocalDateTime; | |||
import java.time.format.DateTimeFormatter; | |||
import javax.persistence.*; | |||
import javax.validation.constraints.NotBlank; | |||
import javax.validation.constraints.NotNull; | |||
import javax.validation.constraints.Size; | |||
import cn.com.taiji.common.entity.StringPropertyUUIDEntity; | |||
import cn.com.taiji.core.entity.dict.EnableStatus; | |||
import cn.com.taiji.core.entity.dict.msgw.MessageType; | |||
import lombok.Getter; | |||
import lombok.Setter; | |||
/** | |||
* 上行信息记录表 | |||
* | |||
*/ | |||
@Getter | |||
@Setter | |||
@Entity | |||
@Table(name = "MSGW_UPWARD_SHORT") | |||
public class MsgwUpwardShort extends StringPropertyUUIDEntity { | |||
@NotBlank | |||
@Column(name = "BATCH_ID") | |||
private String batchId; | |||
@NotBlank | |||
@Column(name = "MOBILE") | |||
private String mobile; | |||
@NotBlank | |||
@Column(name = "MSG_ID") | |||
private String msgId; | |||
@NotBlank | |||
@Column(name = "CUSTOM_MSG_ID") | |||
private String customMsgId; | |||
@NotBlank | |||
@Column(name = "STATE") | |||
private String state; | |||
@NotNull | |||
@Column(name = "SUBMIT_TIME") | |||
private LocalDateTime submitTime; | |||
@Column(name = "DONE_TIME") | |||
private LocalDateTime doneTime; | |||
@NotBlank | |||
@Column(name = "ORIGIN_RESULT") | |||
private String originResult; | |||
@Size(max = 100) | |||
@Column(name = "RESERVE") | |||
private String reserve; | |||
} |
@@ -59,7 +59,8 @@ public class QdCallUtil extends CommonAbstract { | |||
.setCardId(order.getCardId()) | |||
.setObuId(order.getObuId()) | |||
.setPlateNum(order.getVehiclePlate()) | |||
.setPlateColor(order.getVehiclePlateColor()); | |||
.setPlateColor(order.getVehiclePlateColor()) | |||
.setActiveTime(order.getActivationTime().format(TimeTools.ISO_LOCAL_DATE_TIME)); | |||
List<IssueOrderPay> pays = orderPayRepo.listByOrderNo(order.getOrderNo()); | |||
if (!isEmpty(pays)) { | |||
List<PayInfoModelQd> payInfoList = pays.stream().map(pay -> { |
@@ -0,0 +1,28 @@ | |||
package cn.com.taiji.core.model.comm.protocol.ats.sendShort; | |||
import javax.validation.constraints.NotBlank; | |||
import cn.com.taiji.common.model.BaseModel; | |||
import lombok.Getter; | |||
import lombok.Setter; | |||
/** | |||
* @ClassName InterfaceRequest | |||
* @Description 公共请求参数实体 | |||
*/ | |||
@Setter | |||
@Getter | |||
public class MTReport extends BaseModel { | |||
private String id; | |||
private String batchID;// 批次号 | |||
private String phone;// 手机号码 | |||
private String msgID;// 消息ID | |||
private String customMsgID;// 用户自定义消息ID | |||
private Integer state;// 状态 | |||
private Integer submitTime;// 提交时间 | |||
private Integer doneTime;// 完成时间 | |||
private String originResult; | |||
private String reserve; | |||
} |
@@ -8,6 +8,8 @@ import cn.com.taiji.core.model.comm.protocol.ats.AtsServiceType; | |||
public enum SendShortServiceCmd implements SignServiceCommand { | |||
SENDSHORT("短信发送",SendShortRequest.class), | |||
UPWARDSHORT("上行短信获取",UpwardShortQueryRequest.class), | |||
; | |||
@@ -0,0 +1,25 @@ | |||
package cn.com.taiji.core.model.comm.protocol.ats.sendShort; | |||
import cn.com.taiji.core.model.comm.protocol.ats.AbstractAtsRequest; | |||
import cn.com.taiji.core.model.comm.protocol.valid.ErrorMsgBuilder; | |||
import lombok.Getter; | |||
import lombok.Setter; | |||
/*** | |||
* 汇联通-上行信息获取 | |||
*/ | |||
@Getter | |||
@Setter | |||
public class UpwardShortQueryRequest extends AbstractAtsRequest<UpwardShortQueryResponse> { | |||
public UpwardShortQueryRequest() { | |||
super(SendShortServiceCmd.UPWARDSHORT); | |||
} | |||
private Integer fetchSize; | |||
@Override | |||
protected void validate(ErrorMsgBuilder builder) { | |||
} | |||
} |
@@ -0,0 +1,17 @@ | |||
package cn.com.taiji.core.model.comm.protocol.ats.sendShort; | |||
import cn.com.taiji.core.model.comm.protocol.ats.AbstractAtsResponse; | |||
import lombok.Getter; | |||
import lombok.Setter; | |||
import java.util.List; | |||
/*** | |||
* 汇联通-上行信息获取 | |||
*/ | |||
@Getter | |||
@Setter | |||
public class UpwardShortQueryResponse extends AbstractAtsResponse { | |||
List<MTReport> MTReports; | |||
} |
@@ -0,0 +1,8 @@ | |||
package cn.com.taiji.core.repo.jpa.msgw; | |||
import cn.com.taiji.common.repo.jpa.AbstractJpaRepo; | |||
import cn.com.taiji.core.entity.msgw.MsgwUpwardShort; | |||
public interface MsgwUpwardShortRepo extends AbstractJpaRepo<MsgwUpwardShort, String>{ | |||
} |
@@ -0,0 +1,29 @@ | |||
package cn.com.taiji.core.repo.request.msgw; | |||
import cn.com.taiji.common.pub.dao.HqlBuilder; | |||
import cn.com.taiji.common.repo.request.jpa.JpaDateTimePageableDataRequest; | |||
import cn.com.taiji.core.entity.msgw.MsgwUpwardShort; | |||
import lombok.Getter; | |||
import lombok.Setter; | |||
@Getter | |||
@Setter | |||
public class MsgwUpwardShortPageRequest extends JpaDateTimePageableDataRequest<MsgwUpwardShort>{ | |||
private String mobile; | |||
public MsgwUpwardShortPageRequest() { | |||
this.orderBy="submitTime"; | |||
this.desc=true; | |||
} | |||
@Override | |||
public HqlBuilder toSelectHql(){ | |||
HqlBuilder hql = new HqlBuilder("from MsgwUpwardShort where 1=1 "); | |||
hql.append(" and mobile=:mobile", mobile); | |||
hql.append(" and submitTime>=:startTime", startTime); | |||
hql.append(" and submitTime<=:endTime", endTime); | |||
return hql; | |||
} | |||
} |
@@ -5,6 +5,8 @@ import cn.com.taiji.common.web.ApiResponse; | |||
import cn.com.taiji.core.model.comm.protocol.ias.vaild.VehiclePlateCheckRequest; | |||
import cn.com.taiji.core.model.comm.protocol.ias.vaild.VehiclePlateCheckResponse; | |||
import cn.com.taiji.iaw.api.MyValidController; | |||
import cn.com.taiji.iaw.dto.comm.PlateCheckResponse; | |||
import cn.com.taiji.iaw.dto.comm.VehiclePlateCheckYgzRequestDTO; | |||
import cn.com.taiji.iaw.manager.issue.PlateCheckManager; | |||
import io.swagger.annotations.Api; | |||
import io.swagger.annotations.ApiOperation; | |||
@@ -35,4 +37,10 @@ public class PlateCheckController extends MyValidController { | |||
return ApiResponse.of(query); | |||
} | |||
@ApiOperation(value = "营改增车牌校验") | |||
@PostMapping(value = "/checkYGZ") | |||
public ApiResponse<PlateCheckResponse> checkYGZ(@Valid @RequestBody VehiclePlateCheckYgzRequestDTO reqDto) throws ManagerException { | |||
return ApiResponse.of(manager.checkYGZ(reqDto)); | |||
} | |||
} |
@@ -0,0 +1,14 @@ | |||
package cn.com.taiji.iaw.dto.comm; | |||
import lombok.Data; | |||
@Data | |||
public class PlateCheckResponse { | |||
private Boolean result; | |||
private Integer reason; | |||
private Integer vehicleCompare; | |||
private String info; | |||
private int status; | |||
private String message; | |||
} |
@@ -0,0 +1,16 @@ | |||
package cn.com.taiji.iaw.dto.comm; | |||
import cn.com.taiji.core.dto.AbstractBizRequestDTO; | |||
import io.swagger.annotations.ApiModel; | |||
import lombok.Getter; | |||
import lombok.Setter; | |||
@ApiModel(description = "用户车辆信息查看详情") | |||
@Getter | |||
@Setter | |||
public class VehiclePlateCheckYgzRequestDTO extends AbstractBizRequestDTO { | |||
private String vehiclePlate; | |||
private String vehiclePlateColor; | |||
private String vehicleType; | |||
private String releaseType; | |||
} |
@@ -3,6 +3,8 @@ package cn.com.taiji.iaw.manager.issue; | |||
import cn.com.taiji.common.manager.ManagerException; | |||
import cn.com.taiji.core.model.comm.protocol.ias.vaild.VehiclePlateCheckRequest; | |||
import cn.com.taiji.core.model.comm.protocol.ias.vaild.VehiclePlateCheckResponse; | |||
import cn.com.taiji.iaw.dto.comm.PlateCheckResponse; | |||
import cn.com.taiji.iaw.dto.comm.VehiclePlateCheckYgzRequestDTO; | |||
/** | |||
* @Author:ChenChao | |||
@@ -12,4 +14,6 @@ import cn.com.taiji.core.model.comm.protocol.ias.vaild.VehiclePlateCheckResponse | |||
*/ | |||
public interface PlateCheckManager { | |||
VehiclePlateCheckResponse query(VehiclePlateCheckRequest reqDto) throws ManagerException; | |||
PlateCheckResponse checkYGZ(VehiclePlateCheckYgzRequestDTO reqDto) throws ManagerException; | |||
} |
@@ -2,11 +2,33 @@ package cn.com.taiji.iaw.manager.issue; | |||
import cn.com.taiji.common.manager.ManagerException; | |||
import cn.com.taiji.common.manager.net.http.ServiceHandleException; | |||
import cn.com.taiji.common.pub.StringTools; | |||
import cn.com.taiji.core.entity.basic.QtkCardInfo; | |||
import cn.com.taiji.core.entity.basic.QtkObuInfo; | |||
import cn.com.taiji.core.entity.basic.QtkVehicleInfo; | |||
import cn.com.taiji.core.entity.dict.basic.CardStatus; | |||
import cn.com.taiji.core.entity.dict.basic.ObuStatus; | |||
import cn.com.taiji.core.entity.dict.basic.VehicleType; | |||
import cn.com.taiji.core.entity.dict.ygz.DataSourceEnum; | |||
import cn.com.taiji.core.model.comm.protocol.ias.vaild.VehiclePlateCheckRequest; | |||
import cn.com.taiji.core.model.comm.protocol.ias.vaild.VehiclePlateCheckResponse; | |||
import cn.com.taiji.core.model.comm.protocol.ias.ygz.YgzVehiclePlateCheckRequest; | |||
import cn.com.taiji.core.model.comm.protocol.ias.ygz.YgzVehiclePlateCheckResponse; | |||
import cn.com.taiji.core.model.comm.protocol.valid.GlyServiceError; | |||
import cn.com.taiji.core.repo.jpa.basic.QtkCardInfoRepo; | |||
import cn.com.taiji.core.repo.jpa.basic.QtkObuInfoRepo; | |||
import cn.com.taiji.core.repo.jpa.basic.QtkVehicleInfoRepo; | |||
import cn.com.taiji.iaw.dto.comm.PlateCheckResponse; | |||
import cn.com.taiji.iaw.dto.comm.VehiclePlateCheckYgzRequestDTO; | |||
import cn.com.taiji.iaw.manager.AbstractIawManager; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.stream.Collectors; | |||
/** | |||
* @Author:ChenChao | |||
* @Date:2025/7/9 20:51 | |||
@@ -14,20 +36,116 @@ import org.springframework.stereotype.Service; | |||
* @description: | |||
*/ | |||
@Service | |||
public class PlateCheckManagerImpl extends AbstractIawManager implements PlateCheckManager{ | |||
public class PlateCheckManagerImpl extends AbstractIawManager implements PlateCheckManager { | |||
@Autowired | |||
private QtkVehicleInfoRepo vehicleInfoRepo; | |||
@Autowired | |||
private QtkCardInfoRepo cardInfoRepo; | |||
@Autowired | |||
private QtkObuInfoRepo obuInfoRepo; | |||
@Override | |||
public VehiclePlateCheckResponse query(VehiclePlateCheckRequest reqDto) throws ManagerException { | |||
reqDto.setCustomerId(""); | |||
VehiclePlateCheckResponse response = null; | |||
try { | |||
response = jsonPostRepeat(reqDto); | |||
}catch (ManagerException e){ | |||
} catch (ManagerException e) { | |||
if (e.getMessage().contains("车牌发行校验失败")) { | |||
throw new ManagerException("请核对车牌号和车牌颜色"); | |||
}else { | |||
} else { | |||
throw e; | |||
} | |||
} | |||
return response; | |||
} | |||
@Override | |||
public PlateCheckResponse checkYGZ(VehiclePlateCheckYgzRequestDTO req) throws ManagerException { | |||
// 本地车牌校验 | |||
PlateCheckResponse res = localPlateCheck(req); | |||
// 本地没有查询营改增 | |||
if (res == null) { | |||
res = new PlateCheckResponse(); | |||
YgzVehiclePlateCheckRequest plateCheck = new YgzVehiclePlateCheckRequest(); | |||
plateCheck.setVehiclePlate(req.getVehiclePlate()); | |||
plateCheck.setVehicleColor(Integer.valueOf(req.getVehiclePlateColor())); | |||
plateCheck.setVehicleType(Integer.valueOf(req.getVehicleType())); | |||
plateCheck.setIssueType(("2").equals(req.getReleaseType()) ? 2 : 1); | |||
plateCheck.setDataSource(DataSourceEnum.DSI_INTERFACE); | |||
try { | |||
YgzVehiclePlateCheckResponse response = jsonPostRepeat(plateCheck); | |||
if(response != null){ | |||
res.setInfo(response.getInfo()); | |||
}else { | |||
res.setInfo("该车牌本省可以发行对应卡/签!"); | |||
} | |||
}catch (ManagerException e) { | |||
throw new ManagerException(e.getMessage()); | |||
} | |||
} | |||
res.setMessage(res.getInfo()); | |||
return res; | |||
} | |||
private PlateCheckResponse localPlateCheck(VehiclePlateCheckYgzRequestDTO req) throws ManagerException { | |||
PlateCheckResponse response = new PlateCheckResponse(); | |||
// 查询车辆信息 | |||
String vehicleId = req.getVehiclePlate() + "_" + req.getVehiclePlateColor(); | |||
QtkVehicleInfo vehicle = vehicleInfoRepo.findByVehicleId(vehicleId); | |||
if (vehicle == null) { | |||
return null; | |||
} | |||
// 验证车辆类型 | |||
if (vehicle.getType() == null) { | |||
throw new ManagerException("收费车型为空,请修改车辆信息!"); | |||
} | |||
if (!String.valueOf(vehicle.getType()).equals(req.getVehicleType())) { | |||
response.setInfo("收费车型与数据记录不相符"); | |||
return response; | |||
} | |||
// 根据releaseType处理不同情况 | |||
switch (req.getReleaseType()) { | |||
case "1": | |||
return checkCard(response, vehicleId); | |||
case "2": | |||
return checkObu(response, vehicleId); | |||
case "0": | |||
checkCard(response, vehicleId); | |||
return checkObu(response, vehicleId); | |||
default: | |||
return response; | |||
} | |||
} | |||
private PlateCheckResponse checkCard(PlateCheckResponse response, String vehicleId) { | |||
List<QtkCardInfo> activeCards = cardInfoRepo.listByVehicleIdInUse(vehicleId, new CardStatus[]{CardStatus.ZC, CardStatus.KGS}); | |||
if (isEmpty(activeCards)) { | |||
return null; | |||
} | |||
response.setInfo("车牌有在用的卡,卡号:"+activeCards.get(0).getCardId()); | |||
return response; | |||
} | |||
private PlateCheckResponse checkObu(PlateCheckResponse response, String vehicleId) { | |||
List<QtkObuInfo> activeObus = obuInfoRepo.listObuByVehicleIdInUse(vehicleId, new ObuStatus[]{ObuStatus.ZC, ObuStatus.BQGS, ObuStatus.YFX}); | |||
if (isEmpty(activeObus)) { | |||
return null; | |||
} | |||
if(hasText(response.getInfo())) { | |||
response.setInfo(response.getInfo()+";车牌有在用的OBU,OBU编号:" + activeObus.get(0).getObuId()); | |||
}else { | |||
response.setInfo("车牌有在用的OBU,OBU编号:" + activeObus.get(0).getObuId()); | |||
} | |||
return response; | |||
} | |||
} |
@@ -0,0 +1,36 @@ | |||
package cn.com.taiji.msgw.api; | |||
import javax.validation.Valid; | |||
import cn.com.taiji.core.repo.request.msgw.MsgwUpwardShortPageRequest; | |||
import cn.com.taiji.msgw.dto.UpwardShortRequestDto; | |||
import cn.com.taiji.msgw.manager.upwardShort.UpwardShortManager; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.PostMapping; | |||
import org.springframework.web.bind.annotation.RequestBody; | |||
import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RestController; | |||
import cn.com.taiji.common.manager.ManagerException; | |||
import cn.com.taiji.common.model.dao.Pagination; | |||
import cn.com.taiji.common.web.ApiResponse; | |||
import cn.com.taiji.core.repo.request.msgw.MsgwSmsKeyConfigPageRequest; | |||
import cn.com.taiji.msgw.manager.smsKey.SmsKeyConfigManager; | |||
import io.swagger.annotations.Api; | |||
import io.swagger.annotations.ApiOperation; | |||
@Api(tags = {"013.上行短信管理"}) | |||
@RestController | |||
@RequestMapping("/upwardShort") | |||
public class UpwardShortController { | |||
@Autowired | |||
private UpwardShortManager upwardShortManager; | |||
@ApiOperation(value = "上行短信-分页查询") | |||
@PostMapping(value = "/page") | |||
public ApiResponse<Pagination> page(@RequestBody @Valid UpwardShortRequestDto request) { | |||
Pagination pagination = upwardShortManager.page(request); | |||
return ApiResponse.of(pagination); | |||
} | |||
} |
@@ -0,0 +1,25 @@ | |||
package cn.com.taiji.msgw.dto; | |||
import java.time.LocalDateTime; | |||
import java.util.List; | |||
import cn.com.taiji.core.dto.AbstractStaffBizRequestDTO; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Getter; | |||
import lombok.Setter; | |||
/*** | |||
* 短信上行-查询 | |||
*/ | |||
@Getter | |||
@Setter | |||
public class UpwardShortRequestDto extends AbstractStaffBizRequestDTO { | |||
private String mobile; | |||
private int pageNo; | |||
private int pageSize; | |||
private LocalDateTime startTime; | |||
private LocalDateTime endTime; | |||
} |
@@ -0,0 +1,18 @@ | |||
package cn.com.taiji.msgw.manager.upwardShort; | |||
import cn.com.taiji.common.model.dao.Pagination; | |||
import cn.com.taiji.core.repo.request.msgw.MsgwSmsKeyConfigPageRequest; | |||
import cn.com.taiji.core.repo.request.msgw.MsgwUpwardShortPageRequest; | |||
import cn.com.taiji.msgw.dto.UpwardShortRequestDto; | |||
/** | |||
* @Author weicailin | |||
* @Date 2023/4/27 17:54 | |||
* @Email 13079168756@163.com | |||
*/ | |||
public interface UpwardShortManager { | |||
Pagination page(UpwardShortRequestDto request); | |||
} |
@@ -0,0 +1,39 @@ | |||
package cn.com.taiji.msgw.manager.upwardShort; | |||
import java.util.List; | |||
import cn.com.taiji.core.repo.jpa.msgw.MsgwUpwardShortRepo; | |||
import cn.com.taiji.core.repo.request.msgw.MsgwUpwardShortPageRequest; | |||
import cn.com.taiji.msgw.dto.*; | |||
import org.springframework.beans.BeanUtils; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import cn.com.taiji.common.manager.ManagerException; | |||
import cn.com.taiji.common.model.dao.Pagination; | |||
import cn.com.taiji.common.pub.CommonAbstract; | |||
import cn.com.taiji.core.entity.msgw.MsgwSmsKeyConfig; | |||
import cn.com.taiji.core.repo.jpa.msgw.MsgwSmsKeyConfigRepo; | |||
import cn.com.taiji.core.repo.request.msgw.MsgwSmsKeyConfigPageRequest; | |||
/** | |||
* @Author weicailin | |||
* @Date 2023/4/27 17:54 | |||
* @Email 13079168756@163.com | |||
*/ | |||
@Service | |||
public class UpwardShortManagerImpl extends CommonAbstract implements UpwardShortManager { | |||
@Autowired | |||
private MsgwUpwardShortRepo upwardShortRepo; | |||
@Override | |||
public Pagination page(UpwardShortRequestDto request) { | |||
MsgwUpwardShortPageRequest pageRequest = new MsgwUpwardShortPageRequest(); | |||
BeanUtils.copyProperties(request, pageRequest); | |||
//获取分页 | |||
Pagination pagination = upwardShortRepo.page(pageRequest); | |||
return pagination; | |||
} | |||
} |
@@ -1,8 +1,15 @@ | |||
package cn.com.taiji.iasq.manager.quartz.msgw; | |||
import java.time.Instant; | |||
import java.time.LocalDateTime; | |||
import java.time.ZoneOffset; | |||
import java.util.List; | |||
import cn.com.taiji.core.entity.msgw.MsgwUpwardShort; | |||
import cn.com.taiji.core.model.comm.protocol.ats.sendShort.MTReport; | |||
import cn.com.taiji.core.model.comm.protocol.ats.sendShort.UpwardShortQueryRequest; | |||
import cn.com.taiji.core.model.comm.protocol.ats.sendShort.UpwardShortQueryResponse; | |||
import cn.com.taiji.core.repo.jpa.msgw.MsgwUpwardShortRepo; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
@@ -22,71 +29,36 @@ import cn.com.taiji.iasq.manager.AbstractCommManager; | |||
public class MsgwUpwardManagerImpl extends AbstractCommManager implements MsgwUpwardManager { | |||
@Autowired | |||
private MsgwSendDetailsRepo sendDetailsRepo; | |||
@Autowired | |||
private MsgwAlarmConfigRepo alarmConfigRepo; | |||
@Autowired | |||
private MsgwAlarmLogRepo alarmLogRepo; | |||
LocalDateTime startDateTime = LocalDateTime.now().minusHours(1); | |||
LocalDateTime endDateTime = LocalDateTime.now(); | |||
private MsgwUpwardShortRepo sendDetailsRepo; | |||
@Override | |||
public void execute() { | |||
logger.info("-------消息推送-消息发送失败告警开始-------"); | |||
// 查询时间段内是否有需要告警的数据 | |||
// Long failNum = sendDetailsRepo.countStatistics(null, MessageResult.FAIL, startDateTime, endDateTime); | |||
// boolean isAlerts = failNum.equals(0); | |||
// // 如果有,查询是哪个的,触发告警发送 | |||
// while (!isAlerts) { | |||
// for (MessageType type : MessageType.values()) { | |||
// Long failTotalNum = sendDetailsRepo.countStatistics(type, MessageResult.FAIL, startDateTime, endDateTime); | |||
// // 如果不为空,发送告警 | |||
// if (failTotalNum != 0){ | |||
// try { | |||
// sendAlerts(type, failTotalNum); | |||
// } catch (ManagerException e) { | |||
// logger.error("--消息推送-消息发送失败告警失败:", e); | |||
// } | |||
// } | |||
// } | |||
// } | |||
logger.info("-------消息推送-消息发送失败告警结束-------"); | |||
logger.info("-------消息系统-获取上行短信任务开始-------"); | |||
// 查询数据,循环查询 | |||
try { | |||
upwardShortQuery(100); | |||
} catch (ManagerException e) { | |||
logger.error("--消息系统-获取上行短信任务失败:", e); | |||
} | |||
logger.info("-------消息系统-获取上行短信任务结束-------"); | |||
} | |||
// public void sendAlerts(MessageType type, Long num) throws ManagerException{ | |||
// List<MsgwAlarmConfig> configs = alarmConfigRepo.findConfigByCondition(type, EnableStatus.ENABLE); | |||
// MsgwAlarmLog alarmLog = new MsgwAlarmLog(); | |||
// alarmLog.setInsertTime(endDateTime); | |||
// alarmLog.setMessageType(type); | |||
// if (configs.isEmpty()){ | |||
// //告警配置内容 | |||
// alarmLog.setSendResult(0);//默认失败 告警结果(0-失败,1-成功) | |||
// String failReason = "未找到可用的告警配置!原因:没有配置【" + ",消息类型为:" + type.name() + "】的告警配置。"; | |||
// alarmLog.setAlarmReason(failReason); | |||
// alarmLogRepo.persist(alarmLog); | |||
// return; | |||
// } | |||
// // 循环发送告警人 | |||
// for (MsgwAlarmConfig config : configs){ | |||
// HltSendShortRequest request = new HltSendShortRequest(); | |||
// String message = "类型" + type.getValue() + "发送错误,共计" + num + "个。"; | |||
// request.setTitle("告警提醒"); | |||
// request.setMessage(message); | |||
// request.setMobile(config.getMobile()); | |||
// alarmLog.setAlarmConfigId(config.getId()); | |||
// alarmLog.setStaffName(config.getStaffName()); | |||
// alarmLog.setMobile(config.getMobile()); | |||
// alarmLog.setAlarmMessage(message); | |||
// try { | |||
// jsonPostRepeat(request); | |||
// // 记录日志 | |||
// alarmLog.setSendResult(1); | |||
// alarmLogRepo.persist(alarmLog); | |||
// } catch (ManagerException e) { | |||
// alarmLog.setSendResult(0); | |||
// alarmLog.setAlarmReason("告警短信发送失败!"); | |||
// } | |||
// } | |||
// } | |||
public void upwardShortQuery(Integer num) throws ManagerException{ | |||
UpwardShortQueryRequest req = new UpwardShortQueryRequest(); | |||
req.setFetchSize(num); | |||
UpwardShortQueryResponse upwardShortQueryResponse = jsonPostRepeat(req); | |||
if (upwardShortQueryResponse.getMTReports().size() == 0){ | |||
return; | |||
}else { | |||
for (MTReport mtReport : upwardShortQueryResponse.getMTReports()){ | |||
MsgwUpwardShort msgwUpwardShort = new MsgwUpwardShort(); | |||
copyProperties(mtReport, msgwUpwardShort); | |||
msgwUpwardShort.setMobile(mtReport.getPhone()); | |||
msgwUpwardShort.setSubmitTime(LocalDateTime.ofInstant(Instant.ofEpochMilli(mtReport.getSubmitTime()), ZoneOffset.of("+8"))); | |||
msgwUpwardShort.setDoneTime(LocalDateTime.ofInstant(Instant.ofEpochMilli(mtReport.getDoneTime()), ZoneOffset.of("+8"))); | |||
sendDetailsRepo.save(msgwUpwardShort); | |||
} | |||
} | |||
} | |||
} |
@@ -1,5 +1,6 @@ | |||
package cn.com.taiji.ats.manager.handler; | |||
import cn.com.taiji.core.model.comm.protocol.ats.sendShort.UpwardShortQueryRequest; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
@@ -41,6 +42,8 @@ public class SendShortServiceHandler extends AbstractAtsServiceHandler<SendShort | |||
switch (cmd) { | |||
case SENDSHORT: | |||
return sendShortManager.send((SendShortRequest) request); | |||
case UPWARDSHORT: | |||
return sendShortManager.upwardShort((UpwardShortQueryRequest) request); | |||
default: | |||
throw FileProtocolSystemError.NOT_SUPPORT.toHandleException(jsonReq.getIfCode()); | |||
} |
@@ -5,8 +5,11 @@ import static org.springframework.util.StringUtils.hasText; | |||
import java.io.IOException; | |||
import java.nio.charset.StandardCharsets; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import java.util.UUID; | |||
import cn.com.taiji.core.model.comm.protocol.ats.sendShort.*; | |||
import org.springframework.stereotype.Service; | |||
import cn.com.taiji.ats.manager.request.HltSmsSendRequest; | |||
@@ -14,8 +17,6 @@ import cn.com.taiji.ats.manager.tools.MD5Util; | |||
import cn.com.taiji.ats.tools.DesUtil; | |||
import cn.com.taiji.common.manager.net.http.ServiceHandleException; | |||
import cn.com.taiji.common.pub.json.JsonTools; | |||
import cn.com.taiji.core.model.comm.protocol.ats.sendShort.SendShortRequest; | |||
import cn.com.taiji.core.model.comm.protocol.ats.sendShort.SendShortResponse; | |||
import okhttp3.*; | |||
@Service | |||
@@ -80,4 +81,21 @@ public class SendShortManager { | |||
return MD5Util.MD5(str, "UTF-8"); | |||
} | |||
public UpwardShortQueryResponse upwardShort(UpwardShortQueryRequest request) throws ServiceHandleException { | |||
MTReport mtReport = new MTReport(); | |||
mtReport.setId("f97f1629be7e4363b1f109bc447ad594"); | |||
mtReport.setBatchID("123"); | |||
mtReport.setPhone("13888889999"); | |||
mtReport.setMsgID("测试"); | |||
mtReport.setCustomMsgID("13888889999"); | |||
mtReport.setState(1); | |||
mtReport.setSubmitTime(1755484481); | |||
mtReport.setDoneTime(1755484492); | |||
List<MTReport> list = new ArrayList<>(); | |||
list.add(mtReport); | |||
UpwardShortQueryResponse response = new UpwardShortQueryResponse(); | |||
response.setMTReports(list); | |||
return response; | |||
} | |||
} |