From f85e25fba988942f7f3428d6fabcfbf5785a3513 Mon Sep 17 00:00:00 2001 From: zhangqinbin <181961702@qq.com> Date: Fri, 14 Jan 2022 15:12:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E5=A4=B1=E8=B4=A5=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E5=86=8D=E5=8F=91=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../blockchain/entity/BlockChainLogVo.java | 72 ++++++++++++++++ .../controller/CrypConfigureController.java | 13 +++ .../service/ICrypConfigureService.java | 8 +- .../impl/CrypConfigureServiceImpl.java | 82 ++++++++++++++++++- 4 files changed, 173 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/chinaunicom/mall/ebtp/extend/blockchain/entity/BlockChainLogVo.java diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/blockchain/entity/BlockChainLogVo.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/blockchain/entity/BlockChainLogVo.java new file mode 100644 index 0000000..58f6bc2 --- /dev/null +++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/blockchain/entity/BlockChainLogVo.java @@ -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; +} diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/crypconfigure/controller/CrypConfigureController.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/crypconfigure/controller/CrypConfigureController.java index 35e5449..6554c26 100644 --- a/src/main/java/com/chinaunicom/mall/ebtp/extend/crypconfigure/controller/CrypConfigureController.java +++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/crypconfigure/controller/CrypConfigureController.java @@ -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 errorLogsGoToCryp(@RequestBody BlockChainLogVo vo) { + + return BaseResponse.success(this.iCrypConfigureService.errorLogsGoToCryp(vo)); + } /** * 区块链数据加密 * diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/crypconfigure/service/ICrypConfigureService.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/crypconfigure/service/ICrypConfigureService.java index 865ffe8..2ee9e7c 100644 --- a/src/main/java/com/chinaunicom/mall/ebtp/extend/crypconfigure/service/ICrypConfigureService.java +++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/crypconfigure/service/ICrypConfigureService.java @@ -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 { * @return */ Boolean callUniInterface(CrypBean bean); - + /** + * 加载失败日志再发送 + * @param + * @return + */ + Boolean errorLogsGoToCryp(BlockChainLogVo vo); /** * 加密 * @param object diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/crypconfigure/service/impl/CrypConfigureServiceImpl.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/crypconfigure/service/impl/CrypConfigureServiceImpl.java index de6ab0a..8a9c4ea 100644 --- a/src/main/java/com/chinaunicom/mall/ebtp/extend/crypconfigure/service/impl/CrypConfigureServiceImpl.java +++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/crypconfigure/service/impl/CrypConfigureServiceImpl.java @@ -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 implements ICrypConfigureService { @@ -134,6 +138,82 @@ public class CrypConfigureServiceImpl extends BaseServiceImpl 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 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