加载失败日志再发送
This commit is contained in:
@ -0,0 +1,72 @@
|
||||
package com.chinaunicom.mall.ebtp.extend.blockchain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.chinaunicom.mall.ebtp.common.config.CustomLocalDateTimeTypeHandler;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 实体类 BlockChainLog
|
||||
*
|
||||
* @auto.generated
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@ApiModel
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class BlockChainLogVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ApiModelProperty(value = "")
|
||||
private String id;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ApiModelProperty(value = "")
|
||||
private String tpId;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ApiModelProperty(value = "")
|
||||
private String sectionId;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ApiModelProperty(value = "")
|
||||
private String assessRoomId;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ApiModelProperty(value = "")
|
||||
private String turnId;
|
||||
|
||||
/**
|
||||
* 0-成功 1-失败
|
||||
*/
|
||||
@ApiModelProperty(value = "0-成功 1-失败")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty("开始时间")
|
||||
private String startTime;
|
||||
|
||||
@ApiModelProperty("结束时间")
|
||||
private String endTime;
|
||||
}
|
@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.chinaunicom.baas.util.AccessToken;
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseResponse;
|
||||
import com.chinaunicom.mall.ebtp.extend.blockchain.entity.BlockChainLogVo;
|
||||
import com.chinaunicom.mall.ebtp.extend.crypconfigure.entity.CrypBean;
|
||||
import com.chinaunicom.mall.ebtp.extend.crypconfigure.entity.CrypConfigure;
|
||||
import com.chinaunicom.mall.ebtp.extend.crypconfigure.service.ICrypConfigureService;
|
||||
@ -120,6 +121,18 @@ public class CrypConfigureController{
|
||||
return BaseResponse.success(this.iCrypConfigureService.callUniInterface(bean));
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载失败日志再发送
|
||||
*
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation("加载失败日志再发送")
|
||||
@PostMapping("/errorLogsGoToCryp")
|
||||
public BaseResponse<Boolean> errorLogsGoToCryp(@RequestBody BlockChainLogVo vo) {
|
||||
|
||||
return BaseResponse.success(this.iCrypConfigureService.errorLogsGoToCryp(vo));
|
||||
}
|
||||
/**
|
||||
* 区块链数据加密
|
||||
*
|
||||
|
@ -2,6 +2,7 @@ package com.chinaunicom.mall.ebtp.extend.crypconfigure.service;
|
||||
|
||||
|
||||
import com.chinaunicom.mall.ebtp.common.base.service.IBaseService;
|
||||
import com.chinaunicom.mall.ebtp.extend.blockchain.entity.BlockChainLogVo;
|
||||
import com.chinaunicom.mall.ebtp.extend.crypconfigure.entity.CrypBean;
|
||||
import com.chinaunicom.mall.ebtp.extend.crypconfigure.entity.CrypConfigure;
|
||||
|
||||
@ -17,7 +18,12 @@ public interface ICrypConfigureService extends IBaseService<CrypConfigure> {
|
||||
* @return
|
||||
*/
|
||||
Boolean callUniInterface(CrypBean bean);
|
||||
|
||||
/**
|
||||
* 加载失败日志再发送
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
Boolean errorLogsGoToCryp(BlockChainLogVo vo);
|
||||
/**
|
||||
* 加密
|
||||
* @param object
|
||||
|
@ -1,8 +1,12 @@
|
||||
package com.chinaunicom.mall.ebtp.extend.crypconfigure.service.impl;
|
||||
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.chinaunicom.baas.util.AccessToken;
|
||||
import com.chinaunicom.mall.ebtp.common.base.service.IBaseCacheUserService;
|
||||
import com.chinaunicom.mall.ebtp.common.base.service.impl.BaseServiceImpl;
|
||||
@ -14,6 +18,7 @@ import com.chinaunicom.mall.ebtp.common.uniBss.entity.*;
|
||||
import com.chinaunicom.mall.ebtp.common.uniBss.service.UniBssServiceImpl;
|
||||
import com.chinaunicom.mall.ebtp.common.util.PropertyUtils;
|
||||
import com.chinaunicom.mall.ebtp.extend.blockchain.entity.BlockChainLog;
|
||||
import com.chinaunicom.mall.ebtp.extend.blockchain.entity.BlockChainLogVo;
|
||||
import com.chinaunicom.mall.ebtp.extend.blockchain.service.IBlockChainLogService;
|
||||
import com.chinaunicom.mall.ebtp.extend.crypconfigure.dao.CrypConfigureMapper;
|
||||
import com.chinaunicom.mall.ebtp.extend.crypconfigure.entity.CrypBean;
|
||||
@ -40,7 +45,6 @@ import static com.chinaunicom.mall.ebtp.common.uniBss.service.UniBssServiceImpl.
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
@EnableAsync
|
||||
@Service
|
||||
public class CrypConfigureServiceImpl extends BaseServiceImpl<CrypConfigureMapper,CrypConfigure> implements ICrypConfigureService {
|
||||
|
||||
@ -134,6 +138,82 @@ public class CrypConfigureServiceImpl extends BaseServiceImpl<CrypConfigureMappe
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载失败日志再发送
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Boolean errorLogsGoToCryp(BlockChainLogVo vo){
|
||||
log.info("区块链------callUniInterface:---入参-----"+JSON.toJSONString(vo));
|
||||
if(vo.getStatus()==null||"".equals(vo.getStatus())){
|
||||
vo.setStatus(1);//默认失败
|
||||
}
|
||||
SimpleDateFormat dateFormate = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String date = dateFormate.format(new Date());
|
||||
if(vo.getStartTime()==null||"".equals(vo.getStartTime())){
|
||||
vo.setStartTime(date+" 00:00:00");//默认当天00000
|
||||
}
|
||||
if(vo.getEndTime()==null||"".equals(vo.getEndTime())){
|
||||
vo.setEndTime(date+" 23:59:59");//默认当天235959
|
||||
}
|
||||
|
||||
BlockChainLog blog = BeanUtil.toBean(vo,BlockChainLog.class);
|
||||
|
||||
LambdaQueryWrapper<BlockChainLog> query = Wrappers.lambdaQuery(blog);
|
||||
//状态
|
||||
if(vo.getStatus()!=null&&!"".equals(vo.getStatus())){
|
||||
query.eq(BlockChainLog::getStatus,vo.getStatus());
|
||||
}
|
||||
//时间
|
||||
if(vo.getStartTime()!=null&&!"".equals(vo.getStartTime())){
|
||||
query.ge(BlockChainLog::getCreateDate,vo.getStartTime());
|
||||
}
|
||||
if(vo.getEndTime()!=null&&!"".equals(vo.getEndTime())){
|
||||
query.le(BlockChainLog::getCreateDate,vo.getEndTime());
|
||||
}
|
||||
|
||||
List<BlockChainLog> logList = this.iBlockChainLogService.list(query);
|
||||
|
||||
logList.forEach(blockChainLog->{
|
||||
log.info("请求路径:"+blockChainLog.getInterfaceUrl());
|
||||
|
||||
try {
|
||||
|
||||
String json = blockChainLog.getParam();
|
||||
|
||||
//blockChainLog.setParam(json);//请求参数
|
||||
String str = UniBssServiceImpl.uniBssHttpPost(blockChainLog.getInterfaceUrl(), json);
|
||||
blockChainLog.setResult(str);//返回参数
|
||||
UniBss uniBssRsp = JSONArray.parseObject(str, UniBss.class);
|
||||
if (uniBssRsp != null && UniBssConstant.RESP_CODE_00000.equals(uniBssRsp.getUniBssHead().getRespCode())) {
|
||||
System.out.println("返回接口:"+uniBssRsp);
|
||||
|
||||
if(str!=null&&!"".equals(str)&&str.indexOf("_RSP\":{\"Code\":200,")>=0){
|
||||
blockChainLog.setStatus(0);//成功
|
||||
this.iBlockChainLogService.saveOrUpdate(blockChainLog);
|
||||
|
||||
}else{
|
||||
blockChainLog.setStatus(1);//失败
|
||||
}
|
||||
} else {
|
||||
blockChainLog.setStatus(1);//失败
|
||||
log.error("天擎接口调用错误," +
|
||||
"RESP_CODE:" + uniBssRsp.getUniBssHead().getRespCode() + "" +
|
||||
"(" + UniBssConstant.getRESP_CODE_Map(uniBssRsp.getUniBssHead().getRespCode()) + ")。" +
|
||||
"RESP_DESC:" + uniBssRsp.getUniBssHead().getRespDesc());
|
||||
}
|
||||
}catch (Exception e){
|
||||
blockChainLog.setStatus(1);
|
||||
blockChainLog.setResult(e.getMessage());
|
||||
}
|
||||
|
||||
this.iBlockChainLogService.saveOrUpdate(blockChainLog);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 加密
|
||||
* @param object
|
||||
|
Reference in New Issue
Block a user