Merge branch 'uat' into sim

This commit is contained in:
zhangqinbin
2021-09-29 16:09:58 +08:00
25 changed files with 979 additions and 5 deletions

View File

@ -16,6 +16,7 @@ import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableAsync;
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class, DruidDataSourceAutoConfigure.class})
@EnableFeignClients
@ -23,6 +24,7 @@ import org.springframework.context.annotation.ComponentScan;
@MapperScan({"com.chinaunicom.mall.ebtp.extend.**.dao"})
@ComponentScan("com.chinaunicom.mall.ebtp.*")
@EnableApolloConfig
@EnableAsync
public class BizServiceEbtpExtendApplication {
public static void main(String[] args) {

View File

@ -0,0 +1,58 @@
package com.chinaunicom.mall.ebtp.extend.blockchain.controller;
import com.chinaunicom.mall.ebtp.common.base.entity.BaseResponse;
import com.chinaunicom.mall.ebtp.common.util.PropertyUtils;
import com.chinaunicom.mall.ebtp.extend.blockchain.entity.BlockChainLog;
import com.chinaunicom.mall.ebtp.extend.blockchain.service.IBlockChainLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
@RestController
@Api(tags = "供应链+区块链接口调用日志")
@RequestMapping("/v1/blockchainlog")
public class BlockChainLogController {
@Resource
private IBlockChainLogService iBlockChainLogService;
/**
* 插入新数据
*
* @param blockChainLog
*
* @return
*/
@ApiOperation("插入新数据")
@PostMapping("")
public BaseResponse<Boolean> insert(@ApiParam(value = "对象数据", required = true) @RequestBody @Valid BlockChainLog blockChainLog){
blockChainLog.setId(PropertyUtils.getSnowflakeId());
boolean save = iBlockChainLogService.save(blockChainLog);
return BaseResponse.success(save);
}
/**
* 查询数据
*
* @param id
*
* @return
*/
@ApiOperation("查询数据")
@GetMapping("/{id}")
public BaseResponse<BlockChainLog> get(@ApiParam(value = "主键id", required = true) @PathVariable String id){
BlockChainLog blockChainLog = iBlockChainLogService.getById(id);
return BaseResponse.success(blockChainLog);
}
}

View File

@ -0,0 +1,13 @@
package com.chinaunicom.mall.ebtp.extend.blockchain.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.chinaunicom.mall.ebtp.extend.blockchain.entity.BlockChainLog;
/**
* @auto.generated
*/
public interface BlockChainLogMapper extends BaseMapper<BlockChainLog> {
}

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.chinaunicom.mall.ebtp.extend.blockchain.dao.BlockChainLogMapper">
<resultMap id="BaseResultMap"
type="com.chinaunicom.mall.ebtp.extend.blockchain.entity.BlockChainLog">
<result column="id" property="id"/>
<result column="tp_id" property="tpId"/>
<result column="section_id" property="sectionId"/>
<result column="assess_room_id" property="assessRoomId"/>
<result column="turn_id" property="turnId"/>
<result column="interface_url" property="interfaceUrl"/>
<result column="param" property="param"/>
<result column="result" property="result"/>
<result column="status" property="status"/>
<result column="create_date" property="createDate"/>
</resultMap>
<!--逻辑删除方法 此方法为代码生成器生成 不允许修改 如有特殊需求 请自行新建SQL语句-->
<update id="deleteOff" parameterType="java.lang.Long">
update supply_block_chain_log
set
delete_flag="deleted"
where ID=#{id,jdbcType=BIGINT}
</update>
</mapper>

View File

@ -0,0 +1,93 @@
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.ByteArrayOutputStream;
import java.io.PrintStream;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* 实体类 BlockChainLog
*
* @auto.generated
*/
@Data
@Accessors(chain = true)
@ApiModel
@EqualsAndHashCode(callSuper = false)
@TableName(value = "block_chain_log", autoResultMap = true)
public class BlockChainLog 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;
/**
*
*/
@ApiModelProperty(value = "调用接口的地址")
private String interfaceUrl;
/**
* 传参
*/
@ApiModelProperty(value = "传参")
private String param;
/**
* 返回的结果或异常
*/
@ApiModelProperty(value = "返回的结果或异常")
private String result;
/**
* 0-成功 1-失败
*/
@ApiModelProperty(value = "0-成功 1-失败")
private Integer status;
@TableField(fill = FieldFill.INSERT,typeHandler = CustomLocalDateTimeTypeHandler.class)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty("创建时间")
private LocalDateTime createDate;
}

View File

@ -0,0 +1,16 @@
package com.chinaunicom.mall.ebtp.extend.blockchain.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.chinaunicom.mall.ebtp.extend.blockchain.entity.BlockChainLog;
/**
* 对数据表 supply_block_chain_log 操作的 service
* @author Auto create
*
*/
public interface IBlockChainLogService extends IService<BlockChainLog> {
}

View File

@ -0,0 +1,17 @@
package com.chinaunicom.mall.ebtp.extend.blockchain.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chinaunicom.mall.ebtp.extend.blockchain.dao.BlockChainLogMapper;
import com.chinaunicom.mall.ebtp.extend.blockchain.entity.BlockChainLog;
import com.chinaunicom.mall.ebtp.extend.blockchain.service.IBlockChainLogService;
import org.springframework.stereotype.Service;
/**
* 对数据表 supply_block_chain_log 操作的 serviceImpl
* blockchain
*
*/
@Service
public class BlockChainLogServiceImpl extends ServiceImpl<BlockChainLogMapper, BlockChainLog> implements IBlockChainLogService {
}

View File

@ -0,0 +1,161 @@
package com.chinaunicom.mall.ebtp.extend.crypconfigure.controller;
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.crypconfigure.entity.CrypBean;
import com.chinaunicom.mall.ebtp.extend.crypconfigure.entity.CrypConfigure;
import com.chinaunicom.mall.ebtp.extend.crypconfigure.service.ICrypConfigureService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;
@RestController
@Api(value = "区块链参数配置表")
@RequestMapping("/v1/crypconfigure")
public class CrypConfigureController{
@Resource
private ICrypConfigureService iCrypConfigureService;
// /**
// * 插入新数据
// *
// * @param crypConfigure
// *
// * @return
// */
// @ApiOperation("插入新数据")
// @PostMapping
// public BaseResponse<Integer> insert(@ApiParam(value = "对象数据", required = true) @RequestBody @Valid CrypConfigure crypConfigure){
//
// int i = iCrypConfigureService.insert(crypConfigure);
//
// return BaseResponse.success(i);
// }
//
// /**
// * 修改数据
// *
// * @param crypConfigure
// *
// * @return
// */
// @ApiOperation("修改数据")
// @PutMapping
// public BaseResponse<Boolean> update(@ApiParam(value = "对象数据", required = true) @RequestBody CrypConfigure crypConfigure){
//
// Boolean i = iCrypConfigureService.updateCrypConfigureById(crypConfigure);
//
// return BaseResponse.success(i);
// }
//
// /**
// * 查询数据
// *
// * @param id
// *
// * @return
// */
// @ApiOperation("根据id查询数据")
// @GetMapping("/{id}")
// public BaseResponse<CrypConfigure> get(@ApiParam(value = "主键id", required = true) @PathVariable String id){
//
// CrypConfigure crypConfigure = iCrypConfigureService.getById(id);
//
// return BaseResponse.success(crypConfigure);
// }
//
// /**
// * 删除数据
// * @param id 主键id
// * @return BaseResponse<Boolean>
// * @author dino
// * @date 2020/10/21 14:56
// */
// @ApiOperation(value = "delete",notes = "删除数据")
// @DeleteMapping("/{id}")
// public BaseResponse<Integer> delete(@ApiParam(value = "主键id", required = true) @PathVariable Long id) {
// int i = iCrypConfigureService.deleteById(id);
// return BaseResponse.success(i);
// }
/**
* 查询数据
*
* @param param
* @return
*/
@ApiOperation("查询列表数据")
@GetMapping("/list")
public BaseResponse<List<CrypConfigure>> list(@ApiParam(value = "查询对象数据", required = false) CrypConfigure param) {
//查询
LambdaQueryWrapper<CrypConfigure> query = Wrappers.lambdaQuery(param);
List<CrypConfigure> list = iCrypConfigureService.list(query);
//异常处理
//RespsExceptionEnum.FRAME_EXCEPTION_DEMO_NOT_FIND.customValid(list.isEmpty());
return BaseResponse.success(list);
}
/**
* 调用天擎接口
*
* @param bean
* @return
*/
@ApiOperation("调用天擎接口")
@PostMapping("/callUniInterface")
public BaseResponse<Boolean> callUniInterface(@RequestBody CrypBean bean) {
return BaseResponse.success(this.iCrypConfigureService.callUniInterface(bean));
}
/**
* 区块链数据加密
*
* @param object
* @return
*/
@ApiOperation("区块链数据加密")
@PostMapping("/signObject")
public BaseResponse<CrypBean> signObject(@RequestBody Object object) {
return BaseResponse.success(this.iCrypConfigureService.signObject(object));
}
/**
* 区块链数据解密
*
* @param bean
* @return
*/
@ApiOperation("区块链数据解密")
@PostMapping("/verifyObject")
public BaseResponse<Boolean> verifyObject(@RequestBody CrypBean bean) {
return BaseResponse.success(this.iCrypConfigureService.verifyObject(bean));
}
/**
* accessToken获取
*
* @param
* @return
*/
@ApiOperation("accessToken获取")
@GetMapping("/getAccessToken")
public BaseResponse<String> getAccessToken() {
return BaseResponse.success( AccessToken.tokenCreate("bidding"));
}
}

View File

@ -0,0 +1,10 @@
package com.chinaunicom.mall.ebtp.extend.crypconfigure.dao;
import com.chinaunicom.mall.ebtp.common.base.dao.IBaseMapper;
import com.chinaunicom.mall.ebtp.extend.crypconfigure.entity.CrypConfigure;
import org.springframework.stereotype.Repository;
@Repository
public interface CrypConfigureMapper extends IBaseMapper<CrypConfigure> {
}

View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.chinaunicom.mall.ebtp.extend.crypconfigure.dao.CrypConfigureMapper">
<resultMap id="crypconfigureResultMap" type="com.chinaunicom.mall.ebtp.extend.crypconfigure.entity.CrypConfigure">
<result column="id" jdbcType="VARCHAR" property="id" />
<result column="c_code" jdbcType="VARCHAR" property="cCode" />
<result column="c_show" jdbcType="VARCHAR" property="cShow" />
<result column="type" jdbcType="INTEGER" property="type" />
<result column="c_value" jdbcType="VARCHAR" property="cValue" />
<result column="remarks" jdbcType="VARCHAR" property="remarks" />
<result column="state" jdbcType="INTEGER" property="state" />
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
<result column="create_date" jdbcType="VARCHAR" property="createDate" />
<result column="update_by" jdbcType="VARCHAR" property="updateBy" />
<result column="update_date" jdbcType="VARCHAR" property="updateDate" />
<result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
<result column="tenant_name" jdbcType="VARCHAR" property="tenantName" />
<result column="delete_flag" jdbcType="VARCHAR" property="deleteFlag" />
<result column="last_update_time" jdbcType="VARCHAR" property="lastUpdateTime" />
<result column="cutover_status" jdbcType="INTEGER" property="cutoverStatus" />
</resultMap>
<!--逻辑删除方法 此方法为代码生成器生成 不允许修改 如有特殊需求 请自行新建SQL语句-->
<update id="deleteOff" >
update biz_bid_cryp_configure
set
delete_flag="1"
where ID=#{id }
</update>
</mapper>

View File

@ -0,0 +1,35 @@
package com.chinaunicom.mall.ebtp.extend.crypconfigure.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 实体类 CrypConfigure-区块链参数配置表
*
* @author yss
*/
@Data
public class CrypBean {
/**
* 能力req名称
* BIDDING_PUBLISH_REQ 发标
*/
@ApiModelProperty(value = "能力req名称")
public String reqName;
/**
* 签名
*/
@ApiModelProperty(value = "签名")
public String sign;
/**
* 待签名参数 Map
*/
@ApiModelProperty(value = "待签名参数")
public Object object;
/**
* 天擎接口地址
*/
@ApiModelProperty(value = "天擎接口地址")
public String url;
}

View File

@ -0,0 +1,73 @@
package com.chinaunicom.mall.ebtp.extend.crypconfigure.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.chinaunicom.mall.ebtp.common.base.entity.BaseEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* 实体类 CrypConfigure-区块链参数配置表
*
* @author yss
*/
@Data
@Accessors(chain = true)
@TableName(value = "biz_bid_cryp_configure", autoResultMap = true)
@ApiModel(value = "CrypConfigure对象", description = "区块链参数配置表")
public class CrypConfigure extends BaseEntity implements Serializable {
private static final long serialVersionUID = 1L;
@TableId
@ApiModelProperty(value = "主键ID")
private String id;
@ApiModelProperty(value = "配置标识")
private String cCode;
@ApiModelProperty(value = "配置说明")
private String cShow;
@ApiModelProperty(value = "配置类型 1-区块链")
private Integer type;
@ApiModelProperty(value = "")
private String cValue;
@ApiModelProperty(value = "备注")
private String remarks;
@ApiModelProperty(value = "状态 0-失效 1-生效")
private Integer state;
@ApiModelProperty(value = "租户ID")
private String tenantId;
@ApiModelProperty(value = "租户名称")
private String tenantName;
@ApiModelProperty(value = "删除标识")
private String deleteFlag;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "删除标识")
private LocalDateTime lastUpdateTime;
@ApiModelProperty(value = "割接状态0-割接数据1-新数据")
private Integer cutoverStatus;
}

View File

@ -0,0 +1,34 @@
package com.chinaunicom.mall.ebtp.extend.crypconfigure.service;
import com.chinaunicom.mall.ebtp.common.base.service.IBaseService;
import com.chinaunicom.mall.ebtp.extend.crypconfigure.entity.CrypBean;
import com.chinaunicom.mall.ebtp.extend.crypconfigure.entity.CrypConfigure;
/**
* 对数据表 biz_bid_cryp_configure 操作的 service
* @author yss
*
*/
public interface ICrypConfigureService extends IBaseService<CrypConfigure> {
/**
* 调用天擎接口
* @param bean
* @return
*/
Boolean callUniInterface(CrypBean bean);
/**
* 加密
* @param object
* @return
*/
CrypBean signObject(Object object);
/**
* 解密
* @param bean
* @return
*/
Boolean verifyObject(CrypBean bean);
}

View File

@ -0,0 +1,348 @@
package com.chinaunicom.mall.ebtp.extend.crypconfigure.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
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;
import com.chinaunicom.mall.ebtp.common.constant.CommonConstants;
import com.chinaunicom.mall.ebtp.common.crypto.service.CrypServiceImpl;
import com.chinaunicom.mall.ebtp.common.exception.common.CommonExceptionEnum;
import com.chinaunicom.mall.ebtp.common.uniBss.constant.UniBssConstant;
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.service.IBlockChainLogService;
import com.chinaunicom.mall.ebtp.extend.crypconfigure.dao.CrypConfigureMapper;
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;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.*;
import static com.chinaunicom.mall.ebtp.common.uniBss.service.UniBssServiceImpl.MD5min;
/**
* 对数据表 biz_bid_cryp_configure 操作的 serviceImpl
* @author yss
*
*/
@Slf4j
@Service
public class CrypConfigureServiceImpl extends BaseServiceImpl<CrypConfigureMapper,CrypConfigure> implements ICrypConfigureService {
@Autowired
private IBlockChainLogService iBlockChainLogService;
private @Autowired
IBaseCacheUserService service;
// 测试 PEM_PATH = "admin_certPrivateNew.pem" CRT_PATH = "adminNew.crt"
// 生产 PEM_PATH = "bidding_certPrivate.pem" CRT_PATH = "bidding.crt"
// 私钥文件路径 - 加密
private static String PEM_PATH = "bidding_certPrivate.pem";
// 证书文件路径 - 解密
private static String CRT_PATH = "bidding.crt";
@Value("${mconfig.bss.app-id}")
private String app_id;
@Value("${mconfig.bss.app-secret}")
private String app_secret;
@Value("${mconfig.bss.app-url-test}")
private String app_url_test;
@Value("${mconfig.bss.app-url}")
private String app_url;
/**
* 调用天擎接口
* @param bean
* @return
*/
@Override
@Async
public Boolean callUniInterface(CrypBean bean){
log.info("区块链------callUniInterface---入参-----"+JSON.toJSONString(bean));
BlockChainLog blockChainLog = new BlockChainLog();
blockChainLog.setId(PropertyUtils.getSnowflakeId());
//天擎地址
if(app_secret.equals("1mb6n6635cJkDb3pEQPUFXc2nRJ8RPaS")){
//测试环境
bean.setUrl(bean.getUrl().replace(app_url,app_url_test));
PEM_PATH = "admin_certPrivateNew.pem";
CRT_PATH = "adminNew.crt";
}else{
PEM_PATH = "bidding_certPrivate.pem";
CRT_PATH = "bidding.crt";
//生产环境
bean.setUrl(bean.getUrl().replace(app_url_test,app_url));
}
log.info("加密文件:"+PEM_PATH);
log.info("解密文件:"+CRT_PATH);
log.info("请求路径:"+bean.getUrl());
blockChainLog.setInterfaceUrl(bean.getUrl());
try {
Map<String, Object> map = JSONArray.parseObject(JSONArray.toJSONString(bean.getObject()), Map.class);
//传入数据解密
String sign = getSignValue(map);
map.put("SIGN", sign);
String json = getUniBss(bean.getReqName(),map);
blockChainLog.setParam(json);//请求参数
String str = UniBssServiceImpl.uniBssHttpPost(bean.getUrl(), 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.save(blockChainLog);
return true;
}else{
blockChainLog.setStatus(1);//失败
}
} else {
blockChainLog.setStatus(1);//失败
CommonExceptionEnum.FRAME_EXCEPTION_COMMON_DATA_OTHER_ERROR.assertStringNotNullByKey("天擎接口调用错误," +
"RESP_CODE:" + uniBssRsp.getUniBssHead().getRespCode() + "" +
"(" + UniBssConstant.getRESP_CODE_Map(uniBssRsp.getUniBssHead().getRespCode()) + ")。" +
"RESP_DESC:" + uniBssRsp.getUniBssHead().getRespDesc(), bean);
}
}catch (Exception e){
blockChainLog.setStatus(1);
blockChainLog.setResult(e.getMessage());
}
this.iBlockChainLogService.save(blockChainLog);
return false;
}
/**
* 加密
* @param object
* @return
*/
@Override
public CrypBean signObject(Object object){
CrypBean bean = new CrypBean();
try{
bean.setObject(object);
String signValue = getSignValue(bean.getObject());
bean.setSign(signValue);
return bean;
}catch (Exception e){
log.error("加密异常:"+e);
}
return bean;
}
/**
* 获取加密签名
* @param object
* @return
*/
private String getSignValue(Object object){
String signValue = "";
try{
log.info("加密参数1:"+object);
String json = JSONArray.toJSONString(object);
Map<String,Object> jsonMap = JSONArray.parseObject(json);
Object signObject = new Object();
if(jsonMap.get("BODY_LIST")!=null){
List jsonList = (List)jsonMap.get("BODY_LIST");
log.info("加密参数2:"+jsonList);
InputStream is = CrypConfigureServiceImpl.class.getClassLoader().getResourceAsStream(PEM_PATH);
signValue = CrypServiceImpl.signObject2(jsonList,IOUtils.toString(is));
}else{
log.info("加密参数2:"+jsonMap);
InputStream is = CrypConfigureServiceImpl.class.getClassLoader().getResourceAsStream(PEM_PATH);
signValue = CrypServiceImpl.signObject2(jsonMap,IOUtils.toString(is));
}
log.info("加密结果:"+signValue);
}catch (Exception e){
log.info("---------加密异常-"+e.getMessage());
}
return signValue;
}
/**
* 获取加密签名
* @param map
* @return
*/
private String getUniBss(String reqName, Map<String,Object> map){
//获取token
Date date = new Date();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss SSS");
SimpleDateFormat format2 = new SimpleDateFormat("yyyyMMddHHmmssSSS");
String TIMESTAMP = format.format(date);
String TRANS_ID = format2.format(date) + (int) ((Math.random() * 9 + 1) * 100000);
String s = "APP_ID" + app_id + "TIMESTAMP" + TIMESTAMP + "TRANS_ID" + TRANS_ID + app_secret;
String token = MD5min(s);
UniBss uniBss = new UniBss();
uniBss.setUniBssAttached(new UniBssAttached().setMediaInf(""));
//天擎部分head
UniBssHead head = new UniBssHead();
head.setAppId(app_id);
head.setTimeStamp(TIMESTAMP);
head.setTransId(TRANS_ID);
head.setToken(token);
uniBss.setUniBssHead(head);
UniReqHead reqhead = new UniReqHead();
//测试写死
String accessToken = "MQjkzVoYoSHe6r/3uZm0MV/TLx+n8PS9ivfPhgY4bWmh+8DVxj7vTC15xbBkuV8oujD3XBZPP7PhcWag9UU5IzsUBT7PSwPhqi/fUqa+iAWhCWpvyihG/23BAY3rJyaoa3OdMNSnIh8woPDCJQTzCTpNtg0toKwdWnuc2mig7vI0Lm9lePvrx3XxFLSaFr+jB5C3qnAX4uUBioZzithSjtra1QUK6S1cb9DCmpj6NRI=";
//SystemId测试环境 990001 生产环境 74
if(app_secret.equals("1mb6n6635cJkDb3pEQPUFXc2nRJ8RPaS")){
//测试环境
reqhead.setSystemId("990001");
}else{
//生产环境
reqhead.setSystemId("74");
accessToken = AccessToken.tokenCreate("bidding");
accessToken = accessToken.replaceAll("\n","");
log.info("获取token:"+accessToken);
}
reqhead.setSystemName("bidding");
reqhead.setUserId(service.getCacheUser().getUserId()!=null?service.getCacheUser().getUserId():"dzztb");
reqhead.setUserName(service.getCacheUser().getUserId()!=null?service.getCacheUser().getUserId():"dzztb");
reqhead.setAccessToken(accessToken);
log.info("业务参数封装前:"+map);
UniCrpyReq req = new UniCrpyReq();
req.setBody(map);
req.setHead(reqhead);
log.info("业务参数封装中:"+req);;
Map reqMap = new HashMap();
reqMap.put(reqName,req);
uniBss.setUniBssBodyMap(reqMap);
log.info("业务参数封装后:"+reqMap);
log.info("业务参数封装后uniBss"+uniBss);
return JSON.toJSONString(uniBss);
}
/**
* 解密
* @param bean
* @return
*/
@Override
public Boolean verifyObject(CrypBean bean){
try{
log.info("解密参数1:" + bean);
String json = JSONArray.toJSONString(bean.getObject());
Map<String, Object> jsonMap = JSONArray.parseObject(json, Map.class);
if(jsonMap.get("BODY_LIST")!=null){
List jsonList = (List)jsonMap.get("BODY_LIST");
log.info("解密参数2:"+jsonList);
InputStream is = CrypConfigureServiceImpl.class.getClassLoader().getResourceAsStream(CRT_PATH);
Boolean b = CrypServiceImpl.verifyValue(bean.getSign(), jsonList, IOUtils.toString(is));
return b;
}else {
log.info("解密参数2:" + bean);
InputStream is = CrypConfigureServiceImpl.class.getClassLoader().getResourceAsStream(CRT_PATH);
Boolean b = CrypServiceImpl.verifyValue(bean.getSign(), jsonMap, IOUtils.toString(is));
return b;
}
}catch (Exception e){
log.info("-----------解密失败"+e.getMessage());
}
return false;
}
public static Map<String,Object> parseJSON2Map(String jsonStr){
Map<String,Object> map = new HashMap<String,Object>();
Map strmap = JSONArray.parseObject(jsonStr,Map.class);
for(Object k : strmap.keySet()){
Object v = strmap.get(k);
if(v instanceof JSONArray){
List<Map<String,Object>> list = new ArrayList<Map<String,Object>>();
Iterator it = ((JSONArray)v).iterator();
while (it.hasNext()){
Object json2 = it.next();
list.add(parseJSON2Map(json2.toString()));
}
map.put(k.toString(),list);
}else{
map.put(k.toString(),v);
}
}
return map;
}
public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException, InstantiationException, UnsupportedEncodingException {
//String json = "{\"RESULT_ID\":\"1\",\"TP_ID\":\"2\",\"SECTION_ID\":\"3\",\"REPORT_ID\":\"4\",\"RESULTDETAIL\":[{\"RESULT_DETAIL_ID\":\"51\",\"RESULT_ID\":\"52\",\"TENDERER_ID\":\"53\",\"WINNER_CANDIDATE\":\"54\",\"PRICE\":\"55\",\"PRICE_REVIEW\":\"56\",\"BUSINESS_SCORE\":\"57\",\"TECHNICAL_SCORE\":\"58\",\"SERVICE_SCORE\":\"59\",\"PRICE_SCORE\":\"60\",\"TOTAL_SCORE\":\"61\",\"CONTRACTED_MONEY\":\"62\",\"TAX_RATE_PRICE\":\"63\",\"SCOREDETAIL\":[{\"RESULT_DETAIL_ID\":\"71\",\"TENDERER_ID\":\"72\",\"USER_ID\":\"73\",\"BUSINESS_SCORE\":\"74\",\"TECHNICAL_SCORE\":\"75\",\"SERVICE_SCORE\":\"76\",\"PRICE_SCORE\":\"77\"}]}]}";
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//format.setTimeZone(TimeZone.getTimeZone("GMT"));
String date = format.format(new Date());
String token = AccessToken.tokenCreate("bidding");
System.out.println(token);
// example of HashMap entity, treeMap can also work out,
// but LinkedHashMap is NOT supported
// Map<String,Object> mapb= new HashMap<>();
//
// Map<String,String> map = new HashMap<>(1);
// map.put("TENDERER_ID","8533");
// map.put("SHOPPINGCART_ID","L3307");
// map.put("AMOUNT","1000");
// map.put("TP_ID","L3307A");
// map.put("SECTION_ID","1111");
// List list = new ArrayList();
// list.add(map);
//mapb.put("BODY_LIST",list);
// String json = "{\"BODY_LIST\":[{\"AMOUNT\":\"0\",\"SHOPPINGCART_ID\":\"1434792850257195008\",\"TENDERER_ID\":\"100002372\",\"TP_ID\":\"1433613698540576768\",\"SECTION_ID\":\"1433613698543464448\"}]}";
// Map jsonMap = parseJSON2Map(json);
// System.out.println(jsonMap);
// CrypConfigureServiceImpl crypService = new CrypConfigureServiceImpl();
//
// CrypBean bean = new CrypBean();
//
// String key = crypService.getSignValue(jsonMap);
// System.out.println(key);
//bean.setObject(jsonMap);
//bean.setSign("MEUCIQCqbcS4d8je+XvTwlSJ1/5IEgiZBYgJlQ+nU/oi2ZeLAgIgd+SZ72Hk8xdKhcVnxwrFsIL6gHMKOFDIbo4nLzmYroM=");
// System.out.println(bean);
//System.out.println("signature of Map: "+bean.getSign());
//System.out.println("signature object of Map: "+bean.getObject());
//byte[] b = JSON.toJSONBytes(bean.getObject(), new SerializerFeature[]{SerializerFeature.MapSortField, SerializerFeature.SortField});
//System.out.println("signature object2 of Map: "+new String(b));
// boolean isOk = crypService.verifyObject(bean);
// System.out.println("verify result of Map: "+ isOk);
}
}

View File

@ -59,6 +59,6 @@ public class RiskManageController {
*/
@PostMapping({"/findApplyRegulation"})
public BaseResponse<Object> findApplyRegulation(@RequestBody RiskManageRegulationVO riskManageRegulation){
return BaseResponse.success(riskManageService.findApplyRegulation(riskManageRegulation));
return riskManageService.findApplyRegulation(riskManageRegulation);
}
}

View File

@ -1,5 +1,6 @@
package com.chinaunicom.mall.ebtp.extend.riskmanage.service;
import com.chinaunicom.mall.ebtp.common.base.entity.BaseResponse;
import com.chinaunicom.mall.ebtp.extend.riskmanage.entity.RiskManageRegulationVO;
/**
@ -14,5 +15,5 @@ public interface IRiskManageService {
* @param riskManageRegulation 访问实体
* @return 返回结果
*/
Object findApplyRegulation(RiskManageRegulationVO riskManageRegulation);
BaseResponse<Object> findApplyRegulation(RiskManageRegulationVO riskManageRegulation);
}

View File

@ -3,6 +3,7 @@ package com.chinaunicom.mall.ebtp.extend.riskmanage.service.impl;
import com.chinaunicom.mall.ebtp.common.base.entity.BaseCacheUser;
import com.chinaunicom.mall.ebtp.common.base.entity.BaseResponse;
import com.chinaunicom.mall.ebtp.common.base.service.IBaseCacheUserService;
import com.chinaunicom.mall.ebtp.common.util.JsonUtils;
import com.chinaunicom.mall.ebtp.extend.feign.client.RiskManageRegulationService;
import com.chinaunicom.mall.ebtp.extend.feign.entity.risk.RiskManageRegulationGroupOuterVO;
import com.chinaunicom.mall.ebtp.extend.feign.utils.CallRegulationUtil;
@ -11,6 +12,7 @@ import com.chinaunicom.mall.ebtp.extend.riskmanage.entity.RiskManageRegulationGr
import com.chinaunicom.mall.ebtp.extend.riskmanage.entity.RiskManageRegulationVO;
import com.chinaunicom.mall.ebtp.extend.riskmanage.service.IRiskManageService;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@ -22,6 +24,7 @@ import java.util.Map;
* @author daixc
* @date 2021/08/19
*/
@Slf4j
@Service
public class RiskManageServiceImpl implements IRiskManageService {
@ -33,7 +36,7 @@ public class RiskManageServiceImpl implements IRiskManageService {
@SneakyThrows
@Override
public Object findApplyRegulation(RiskManageRegulationVO riskManageRegulation) {
public BaseResponse<Object> findApplyRegulation(RiskManageRegulationVO riskManageRegulation) {
Map<String,Object> params = riskManageRegulation.getParams();
RiskManageRegulation regulation = riskManageRegulation.getRiskManageRegulation();
@ -55,7 +58,7 @@ public class RiskManageServiceImpl implements IRiskManageService {
BaseCacheUser cacheUser = cacheUserService.getCacheUser();
regulationGroupApply.setOuterVoList(CallRegulationUtil.getCallRegulationMap(params,regulationParams,cacheUser.getOrganizationId()));
log.info("调用山分风控接口参数:{}", JsonUtils.objectToJson(regulationGroupApply));
//校验信息
return regulationService.applyRegulation(regulationGroupApply);
}

View File

@ -0,0 +1,16 @@
-----BEGIN CERTIFICATE-----
MIICgjCCAimgAwIBAgIUYP62P06sD2LqFyrCW8gDB4EvOmowCgYIKoZIzj0EAwIw
ZzELMAkGA1UEBhMCQ04xETAPBgNVBAgTCFNoYW5Eb25nMQ4wDAYDVQQHEwVKaU5h
bjEYMBYGA1UEChMPYWRtaW50MDgxMmFvcmczMRswGQYDVQQDExJjYS5hZG1pbnQw
ODEyYW9yZzMwHhcNMjEwODMxMDYzMDAwWhcNMjIwODMxMDYzNTAwWjAzMRwwDQYD
VQQLEwZjbGllbnQwCwYDVQQLEwRvcmczMRMwEQYDVQQDDAphZG1pbkBvcmczMFkw
EwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEPHT7VRH2X5tsF3aqKmKQqJWieDMYiaxa
FFDHqQMLiEC2kmSB9fmG1JK/z/smwtXG4gTK2YwsYgIppO3S8ZlJMaOB5jCB4zAO
BgNVHQ8BAf8EBAMCB4AwDAYDVR0TAQH/BAIwADAdBgNVHQ4EFgQUxhcLh6TJkZkr
4aj4/P9YvfuSWGwwKwYDVR0jBCQwIoAg39Z8xQV3+pq1DBYm7uNMvAqFNpkbsvGe
LZX537X16UEwFAYDVR0RBA0wC4IJSlpaSEpTLTcyMGEGCCoDBAUGBwgBBFV7ImF0
dHJzIjp7ImhmLkFmZmlsaWF0aW9uIjoib3JnMyIsImhmLkVucm9sbG1lbnRJRCI6
ImFkbWluQG9yZzMiLCJoZi5UeXBlIjoiY2xpZW50In19MAoGCCqGSM49BAMCA0cA
MEQCIHqfq7vUlpdZUzV/qOeIvmLpom4qKzVuBmp2Bkl5M0LNAiAl7Y9a6TiCMx9/
0XMXsg5XS07GeLH9e94vY2y5GN/QZA==
-----END CERTIFICATE-----

View File

@ -0,0 +1,5 @@
-----BEGIN PRIVATE KEY-----
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgfb0OcgWWFJGaOmVI
LxEpIRTsICs0ssgJZqpuZQUhTIGhRANCAAQ8dPtVEfZfm2wXdqoqYpColaJ4MxiJ
rFoUUMepAwuIQLaSZIH1+YbUkr/P+ybC1cbiBMrZjCxiAimk7dLxmUkx
-----END PRIVATE KEY-----

View File

@ -164,6 +164,7 @@ mconfig:
tender: biz-service-ebtp-tender #投标服务
documentcenter: core-service-document-center #文档中心
usercenter: core-service-usercenter-public #用户中心
strategy-center: core-service-strategy-center #风控中心
file:
font-address: /storage/fonts/
upload-address: /storage/reviewReport/

View File

@ -0,0 +1,17 @@
-----BEGIN CERTIFICATE-----
MIICtjCCAlygAwIBAgIUe215ilr4OdlnuVCXfgTrqJrcqpcwCgYIKoZIzj0EAwIw
ezELMAkGA1UEBhMCQ04xETAPBgNVBAgTCFNoYW5Eb25nMQ4wDAYDVQQHEwVKaU5h
bjEiMCAGA1UEChMZc2V0dGxlc3VwcGx5Y2hhaW40cnN1cHBseTElMCMGA1UEAxMc
Y2Euc2V0dGxlc3VwcGx5Y2hhaW40cnN1cHBseTAeFw0yMTA4MjYwODAwMDBaFw0y
MjA4MjYwODA1MDBaMDkxHjANBgNVBAsTBmNsaWVudDANBgNVBAsTBnN1cHBseTEX
MBUGA1UEAwwOYmlkZGluZ0BzdXBwbHkwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNC
AARrEnl3cvS8/iptIoDWCbzdEDYBmCPQLQSsCfiv+qSJ3dx0UQv16t0v1JaL6ihp
N5GwdGn16k8gLER0Z3Pivhyko4H/MIH8MA4GA1UdDwEB/wQEAwIHgDAMBgNVHRMB
Af8EAjAAMB0GA1UdDgQWBBQqt95Q16+r/2QBxPOt9baxT6hRCzArBgNVHSMEJDAi
gCCoEmkNovEkOgVGTQoOz5I4GjY1A8RZIA08NVJkoU/TczAnBgNVHREEIDAeghxi
YWFzLWZhYnJpYy03ZjY2ODU1Y2ZmLTZ4NThyMGcGCCoDBAUGBwgBBFt7ImF0dHJz
Ijp7ImhmLkFmZmlsaWF0aW9uIjoic3VwcGx5IiwiaGYuRW5yb2xsbWVudElEIjoi
YmlkZGluZ0BzdXBwbHkiLCJoZi5UeXBlIjoiY2xpZW50In19MAoGCCqGSM49BAMC
A0gAMEUCIQCjRuJ4PjFSQxpBZGLrYF7AkwkzV+tWpHRoWffYWnAGWgIgP8L6WIBC
CRrxg9Jv/oB2MNAHjaw6WLJdpSjB2Xv/QCs=
-----END CERTIFICATE-----

View File

@ -0,0 +1,5 @@
-----BEGIN PRIVATE KEY-----
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgXgGSyYeypZ4JK9Au
gOxkTu0Yj2SMVkzcKZOC1Pe2LRqhRANCAARrEnl3cvS8/iptIoDWCbzdEDYBmCPQ
LQSsCfiv+qSJ3dx0UQv16t0v1JaL6ihpN5GwdGn16k8gLER0Z3Pivhyk
-----END PRIVATE KEY-----