Commit b5d9513a authored by 5359's avatar 5359

UAT环境银行代扣

parent 961699eb
package com.chinapay.bean;
/**
* @author huang.xuting
*
*/
public class TransactionBean {
private String MerId; //商户号,数字,定长15位
private String MerKeyPath; //商户私钥路径
private String PubKeyPath; //商户公钥路径
private String FileName; //上传txt文件名
private String Plain; //存款批量交易信息
private String FileHeader; //txt文件头
private String FileMatter; //txt文件体
private String FilePath; //txt文件路径
private String ChkValue; //交易签名,字符,定长256位
//应答数据
private String ResponseCode; //应答码
private String Message; //应答信息
//返回报文数据
private String Data; //控台返回报文
public void setMerId(String merId) {
MerId = merId;
}
public String getMerId() {
return MerId;
}
public void setResponseCode(String responseCode) {
ResponseCode = responseCode;
}
public String getResponseCode() {
return ResponseCode;
}
public void setData(String data) {
Data = data;
}
public String getData() {
return Data;
}
public void setMerKeyPath(String merKeyPath) {
MerKeyPath = merKeyPath;
}
public String getMerKeyPath() {
return MerKeyPath;
}
public void setPubKeyPath(String pubKeyPath) {
PubKeyPath = pubKeyPath;
}
public String getPubKeyPath() {
return PubKeyPath;
}
public void setFileName(String fileName) {
FileName = fileName;
}
public String getFileName() {
return FileName;
}
public void setPlain(String plain) {
Plain = plain;
}
public String getPlain() {
return Plain;
}
public void setFileHeader(String fileHeader) {
FileHeader = fileHeader;
}
public String getFileHeader() {
return FileHeader;
}
public void setFileMatter(String fileMatter) {
FileMatter = fileMatter;
}
public String getFileMatter() {
return FileMatter;
}
public void setFilePath(String filePath) {
FilePath = filePath;
}
public String getFilePath() {
return FilePath;
}
public void setChkValue(String chkValue) {
ChkValue = chkValue;
}
public String getChkValue() {
return ChkValue;
}
public void setMessage(String message) {
Message = message;
}
public String getMessage() {
return Message;
}
}
/**
* 项目名称(中文)
* 项目名称(英文)
* Copyright (c) 2016 ChinaPay Ltd. All Rights Reserved.
*/
package com.chinapay.comm;
/**
* @author hrtc .
*/
public class Constants {
/**
* 默认编码.
*/
public static final String ENCODING = "UTF-8";
/**
* 文件分隔符.
*/
public static final String FILE_SPLIT_STR = "/";
/**
* 默认错误码.
*/
public static final String DEFAULT_ERROR_CODE = "9999";
/******** 报文字段 ********/
/**
* 卡信息字段.
*/
public static final String CARD_TRAN_DATA = "CardTranData";
/**
* 交易保留域.
*/
public static final String TRAN_RESERVED = "TranReserved";
/**
* 风控保留域.
*/
public static final String RISK_DATA = "RiskData";
/**
* 风控保留域.
*/
public static final String FILE_DATA = "FileData";
/**
* 响应信息.
*/
public static final String RESP_MSG = "respMsg";
/**
* 响应码.
*/
public static final String RESP_CODE = "respCode";
/**
* 签名.
*/
public static final String SIGNATURE = "Signature";
/**
* .
*/
public static final String MER_ID = "MerId";
/**
* .
*/
public static final String INSTU_ID = "InstuId";
/******** demo特殊字段 ********/
/**
* 特殊字段前缀.
*/
public static final String SPEC_PRIFEX = "__";
/**
* 请求参数-定制接口类型.
*/
public static final String SPEC_INTERFACE_TYPE = "__interfaceType";
/**
* 请求参数-交易类型.
*/
public static final String SPEC_TRAN_TYPE = "__tranType";
/**
* 请求参数-交易子类型.
*/
public static final String SPEC_SUB_TRAN_TYPE = "__subTransType";
/**
* 请求参数-调用方法.
*/
public static final String SPEC_METHOD = "__method";
/**
* 请求参数-通知类型 0前台 1后台 默认是后台.
*/
public static final String SPEC_NOTIFY_TYPE = "__notifyType";
/**
* 请求参数-请求地址.
*/
public static final String SPEC_REQUEST_URL = "__requestUrl";
/**
* 响应参数-发送map.
*/
public static final String SEND_MAP = "sendMap";
/**
* 响应参数-响应map.
*/
public static final String RESULT_MAP = "resultMap";
/**
* 响应参数-接口缓存.
*/
public static final String INTERFACE_CACHE = "interfaceCache";
/**
* 响应参数-报文.
*/
public static final String PACKET = "packet";
/**
* 响应参数-请求地址.
*/
public static final String REQUEST_URL = "requestUrl";
/**
* 方法-生成请求页面.
*/
public static final String METHOD_GEN_REQUEST_PAGE = "genRequestPage";
/**
* 方法-组报文页面.
*/
public static final String METHOD_PACK = "pack";
/**
* 方法-解包.
*/
public static final String METHOD_UNPACK = "unpack";
/**
* 方法-发送.
*/
public static final String METHOD_SEND = "send";
/**
* 通知类型-前台.
*/
public static final String NOTIFY_TYPE_FRONT = "0";
/**
* 通知类型-后台.
*/
public static final String NOTIFY_TYPE_BACK = "1";
/**
* 接口版本.
*/
public static final String VERSION = "20140728";
/**
* 业务类型.
*/
public static final String BUSI_TYPE="0001";
/**
* 交易类型0610.
*/
public static final String TRAN_TYPE_0610="0608";
/**
* 交易类型9910.
*/
public static final String TRAN_TYPE_9910="9904";
/**
* 交易类型0506.
*/
public static final String TRAN_TYPE_0506="0506";
}
/**
* Copyright (C), 2018-2021
* FileName: HclcChinaPayController
* Author: lsy
* Date: 2021/12/8 14:40
* Description:
* History:
* <author> <time> <version> <desc>
* lishuangyi 修改时间 版本号 描述
*/
package com.chinapay.controllers;
import com.alibaba.fastjson.JSONObject;
import com.chinapay.service.IHclcChinaPayService;
import com.hand.hap.core.IRequest;
import com.hand.hap.system.controllers.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
/*
* 〈〉
*
* @author 27214
* @create 2021/12/8
* @since 1.0.0
*/
@Controller
@RequestMapping(value = {"/r/api", "/"})
public class HclcChinaPayController extends BaseController {
@Autowired
IHclcChinaPayService hclcChinaPayService;
/**
* 4.4签约短信接口
*
* @param request
* @param params 4.4签约短信接口
* @return Map
*/
@ResponseBody
@RequestMapping("/china/pay/send/sign/message")
public JSONObject sendSignMessage(HttpServletRequest request,
@RequestBody(required = true) JSONObject params) {
JSONObject jsonResult = new JSONObject();
IRequest iRequest = createRequestContext(request);
jsonResult = hclcChinaPayService.sendSignMessage(iRequest, params);
return jsonResult;
}
/**
* 4.5签约接口
*
* @param request
* @param params 4.5签约接口
* @return Map
*/
@ResponseBody
@RequestMapping("/china/pay/send/sign")
public JSONObject sendSign(HttpServletRequest request,
@RequestBody(required = true) JSONObject params) {
JSONObject jsonResult = new JSONObject();
IRequest iRequest = createRequestContext(request);
jsonResult = hclcChinaPayService.sendSign(iRequest, params);
return jsonResult;
}
/**
* 4.9 批量交易文件上传接口
*
* @param request
* @param params 4.9 批量交易文件上传接口
* @return Map
*/
@ResponseBody
@RequestMapping("/china/pay/upload/batch")
public JSONObject uploadBatch(HttpServletRequest request,
@RequestBody(required = true) JSONObject params) {
JSONObject jsonResult = new JSONObject();
IRequest iRequest = createRequestContext(request);
jsonResult = hclcChinaPayService.uploadBatch(iRequest, params);
return jsonResult;
}
/**
* 4.11 批量交易回盘文件内容下载接口
*
* @param request
* @param params 4.11 批量交易回盘文件内容下载接口
* @return Map
*/
@ResponseBody
@RequestMapping("/china/pay/download/batch")
public JSONObject downloadBatch(HttpServletRequest request,
@RequestBody(required = true) JSONObject params) {
JSONObject jsonResult = new JSONObject();
IRequest iRequest = createRequestContext(request);
jsonResult = hclcChinaPayService.downloadBatch(iRequest, params);
return jsonResult;
}
/**
* 4.12 批量交易文件查询接口
*
* @param request
* @param params 4.12 批量交易文件查询接口
* @return Map
*/
@ResponseBody
@RequestMapping("/china/pay/query/batch")
public JSONObject queryBatch(HttpServletRequest request,
@RequestBody(required = true) JSONObject params) {
JSONObject jsonResult = new JSONObject();
IRequest iRequest = createRequestContext(request);
jsonResult = hclcChinaPayService.queryBatch(iRequest, params);
return jsonResult;
}
}
\ No newline at end of file
/**
* Copyright (C), 2018-2021
* FileName: HclcCupSignInfo
* Author: lsy
* Date: 2021/12/10 11:25
* Description:
* History:
* <author> <time> <version> <desc>
* lishuangyi 修改时间 版本号 描述
*/
package com.chinapay.dto;
import com.hand.hap.mybatis.annotation.ExtensionAttribute;
import com.hand.hap.system.dto.BaseDTO;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
/*
* 〈〉
*
* @author 27214
* @create 2021/12/10
* @since 1.0.0
*/
@Table(name = "hclc_cup_sign_info")
@ExtensionAttribute(disable = true)
public class HclcCupSignInfo extends BaseDTO {
@Id
@GeneratedValue
private Long signId;
private String cardNo;
private String accName;
private String certType;
private String certNo;
private String mobileNo;
private String entrstAuthNo;
private String entrstAmtLmt;
private String entrstStrDtTm;
private String entrstEndDtTm;
private String entrstDtUnt;
private Long entrstDtStp;
private String status;
private String accType;
private String protocolNo;
private String merOrderNo;
private String merId;
private String remark;
public Long getSignId() {
return signId;
}
public void setSignId(Long signId) {
this.signId = signId;
}
public String getCardNo() {
return cardNo;
}
public void setCardNo(String cardNo) {
this.cardNo = cardNo;
}
public String getAccName() {
return accName;
}
public void setAccName(String accName) {
this.accName = accName;
}
public String getCertType() {
return certType;
}
public void setCertType(String certType) {
this.certType = certType;
}
public String getCertNo() {
return certNo;
}
public void setCertNo(String certNo) {
this.certNo = certNo;
}
public String getMobileNo() {
return mobileNo;
}
public void setMobileNo(String mobileNo) {
this.mobileNo = mobileNo;
}
public String getEntrstAuthNo() {
return entrstAuthNo;
}
public void setEntrstAuthNo(String entrstAuthNo) {
this.entrstAuthNo = entrstAuthNo;
}
public String getEntrstAmtLmt() {
return entrstAmtLmt;
}
public void setEntrstAmtLmt(String entrstAmtLmt) {
this.entrstAmtLmt = entrstAmtLmt;
}
public String getEntrstStrDtTm() {
return entrstStrDtTm;
}
public void setEntrstStrDtTm(String entrstStrDtTm) {
this.entrstStrDtTm = entrstStrDtTm;
}
public String getEntrstEndDtTm() {
return entrstEndDtTm;
}
public void setEntrstEndDtTm(String entrstEndDtTm) {
this.entrstEndDtTm = entrstEndDtTm;
}
public String getEntrstDtUnt() {
return entrstDtUnt;
}
public void setEntrstDtUnt(String entrstDtUnt) {
this.entrstDtUnt = entrstDtUnt;
}
public Long getEntrstDtStp() {
return entrstDtStp;
}
public void setEntrstDtStp(Long entrstDtStp) {
this.entrstDtStp = entrstDtStp;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getAccType() {
return accType;
}
public void setAccType(String accType) {
this.accType = accType;
}
public String getProtocolNo() {
return protocolNo;
}
public void setProtocolNo(String protocolNo) {
this.protocolNo = protocolNo;
}
public String getMerOrderNo() {
return merOrderNo;
}
public void setMerOrderNo(String merOrderNo) {
this.merOrderNo = merOrderNo;
}
public String getMerId() {
return merId;
}
public void setMerId(String merId) {
this.merId = merId;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
}
\ No newline at end of file
/**
* Copyright (C), 2018-2021
* FileName: HclcCupSignInfo
* Author: lsy
* Date: 2021/12/10 11:25
* Description:
* History:
* <author> <time> <version> <desc>
* lishuangyi 修改时间 版本号 描述
*/
package com.chinapay.dto;
import com.hand.hap.mybatis.annotation.ExtensionAttribute;
import com.hand.hap.system.dto.BaseDTO;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;
/*
* 〈〉
*
* @author 27214
* @create 2021/12/10
* @since 1.0.0
*/
@Table(name = "hls_ebank_ccb_transaction")
@ExtensionAttribute(disable = true)
public class HlsEbankCcbTransaction extends BaseDTO {
@Id
@GeneratedValue
private Long transactionId;
private String transactionNumber;
private String status;
private Date newDate;
private Double amount;
private Long count;
private String returnCode;
private String returnMsg;
private Double successAmount;
private Long successCount;
private String sendFileName;
private String backFileName;
private String bankType;
private String merId;
private String version;
private String merOrderNo;
private String tranDate;
private String tranTime;
private String tranType;
private String orderStatus;
private String fileFlag;
public Long getTransactionId() {
return transactionId;
}
public void setTransactionId(Long transactionId) {
this.transactionId = transactionId;
}
public String getTransactionNumber() {
return transactionNumber;
}
public void setTransactionNumber(String transactionNumber) {
this.transactionNumber = transactionNumber;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public Date getNewDate() {
return newDate;
}
public void setNewDate(Date newDate) {
this.newDate = newDate;
}
public Double getAmount() {
return amount;
}
public void setAmount(Double amount) {
this.amount = amount;
}
public Long getCount() {
return count;
}
public void setCount(Long count) {
this.count = count;
}
public String getReturnCode() {
return returnCode;
}
public void setReturnCode(String returnCode) {
this.returnCode = returnCode;
}
public String getReturnMsg() {
return returnMsg;
}
public void setReturnMsg(String returnMsg) {
this.returnMsg = returnMsg;
}
public Double getSuccessAmount() {
return successAmount;
}
public void setSuccessAmount(Double successAmount) {
this.successAmount = successAmount;
}
public Long getSuccessCount() {
return successCount;
}
public void setSuccessCount(Long successCount) {
this.successCount = successCount;
}
public String getSendFileName() {
return sendFileName;
}
public void setSendFileName(String sendFileName) {
this.sendFileName = sendFileName;
}
public String getBackFileName() {
return backFileName;
}
public void setBackFileName(String backFileName) {
this.backFileName = backFileName;
}
public String getBankType() {
return bankType;
}
public void setBankType(String bankType) {
this.bankType = bankType;
}
public String getMerId() {
return merId;
}
public void setMerId(String merId) {
this.merId = merId;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getMerOrderNo() {
return merOrderNo;
}
public void setMerOrderNo(String merOrderNo) {
this.merOrderNo = merOrderNo;
}
public String getTranDate() {
return tranDate;
}
public void setTranDate(String tranDate) {
this.tranDate = tranDate;
}
public String getTranTime() {
return tranTime;
}
public void setTranTime(String tranTime) {
this.tranTime = tranTime;
}
public String getTranType() {
return tranType;
}
public void setTranType(String tranType) {
this.tranType = tranType;
}
public String getOrderStatus() {
return orderStatus;
}
public void setOrderStatus(String orderStatus) {
this.orderStatus = orderStatus;
}
public String getFileFlag() {
return fileFlag;
}
public void setFileFlag(String fileFlag) {
this.fileFlag = fileFlag;
}
}
\ No newline at end of file
/**
* Copyright (C), 2018-2021
* FileName: HclcCupSignInfo
* Author: lsy
* Date: 2021/12/10 11:25
* Description:
* History:
* <author> <time> <version> <desc>
* lishuangyi 修改时间 版本号 描述
*/
package com.chinapay.dto;
import com.hand.hap.mybatis.annotation.ExtensionAttribute;
import com.hand.hap.system.dto.BaseDTO;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
/*
* 〈〉
*
* @author 27214
* @create 2021/12/10
* @since 1.0.0
*/
@Table(name = "hls_ws_config")
@ExtensionAttribute(disable = true)
public class HlsWsConfig {
@Id
@GeneratedValue
private Long configId;
private String configName;
private String configDesc;
private String wsdlAddress;
private String endpointAddress;
public Long getConfigId() {
return configId;
}
public void setConfigId(Long configId) {
this.configId = configId;
}
public String getConfigName() {
return configName;
}
public void setConfigName(String configName) {
this.configName = configName;
}
public String getConfigDesc() {
return configDesc;
}
public void setConfigDesc(String configDesc) {
this.configDesc = configDesc;
}
public String getWsdlAddress() {
return wsdlAddress;
}
public void setWsdlAddress(String wsdlAddress) {
this.wsdlAddress = wsdlAddress;
}
public String getEndpointAddress() {
return endpointAddress;
}
public void setEndpointAddress(String endpointAddress) {
this.endpointAddress = endpointAddress;
}
}
\ No newline at end of file
package com.chinapay.mapper;
import com.chinapay.dto.HclcCupSignInfo;
import com.hand.app.esignHclc.dto.Lm005Hclc;
import com.hand.hap.mybatis.common.Mapper;
/**
* Created with IntelliJ IDEA.
* User: lsy
* Date: 2020/2/24
* Time: 9:08
*/
public interface HclcCupSignInfoMapper extends Mapper<HclcCupSignInfo> {
}
package com.chinapay.mapper;
import com.chinapay.dto.HlsEbankCcbTransaction;
import com.hand.hap.mybatis.common.Mapper;
/**
* Created with IntelliJ IDEA.
* User: lsy
* Date: 2020/2/24
* Time: 9:08
*/
public interface HlsEbankCcbTransactionMapper extends Mapper<HlsEbankCcbTransaction> {
}
package com.chinapay.mapper;
import com.chinapay.dto.HlsWsConfig;
import com.hand.hap.mybatis.common.Mapper;
/**
* Created with IntelliJ IDEA.
* User: lsy
* Date: 2020/2/24
* Time: 9:08
*/
public interface HlsWsConfigMapper extends Mapper<HlsWsConfig> {
}
package com.chinapay.service;
import com.alibaba.fastjson.JSONObject;
import com.chinapay.dto.HclcCupSignInfo;
import com.hand.hap.core.IRequest;
import com.hand.hap.core.ProxySelf;
import com.hand.hap.system.service.IBaseService;
/**
* Created with IntelliJ IDEA.
* User: lsy
* Date: 2020/2/24
* Time: 9:08
*/
public interface IHclcChinaPayService extends IBaseService<HclcCupSignInfo>, ProxySelf<IHclcChinaPayService> {
JSONObject sendSignMessage(IRequest iRequest, JSONObject params);
JSONObject sendSign(IRequest iRequest, JSONObject params);
JSONObject uploadBatch(IRequest iRequest, JSONObject params);
JSONObject downloadBatch(IRequest iRequest, JSONObject params);
JSONObject queryBatch(IRequest iRequest, JSONObject params);
}
## Security properties configuration file
#the location of verify file
verify.file=F:\\work\\workspace\\IdeaProjects\\hls-support-rlwx\\key\\cp_test.cer
#
sign.filePath=F:\\work\\workspace\\IdeaProjects\\hls-support-rlwx\\key\\
#location of sign file
sign.file=F:\\work\\workspace\\IdeaProjects\\hls-support-rlwx\\key\\000092112092486.pfx
#
sign.file.password=123456
#
sign.cert.type=PKCS12
#
sign.invalid.fields=Signature,CertId
#
signature.field=Signature
#
log4j.name=CONSOLE
package com.chinapay.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.chinapay.comm.Constants;
import com.chinapay.dto.HclcCupSignInfo;
import com.chinapay.dto.HlsEbankCcbTransaction;
import com.chinapay.dto.HlsWsConfig;
import com.chinapay.mapper.HclcCupSignInfoMapper;
import com.chinapay.mapper.HlsEbankCcbTransactionMapper;
import com.chinapay.mapper.HlsWsConfigMapper;
import com.chinapay.secss.SecssConstants;
import com.chinapay.secss.SecssUtil;
import com.chinapay.service.IHclcChinaPayService;
import com.chinapay.util.HttpUtils;
import com.chinapay.util.StringUtil;
import com.hand.app.zhongDengWang.dto.HlsWsRequests;
import com.hand.app.zhongDengWang.mapper.HlsWsRequestsMapper;
import com.hand.hap.core.IRequest;
import com.hand.hap.intergration.service.IHapInterfaceHeaderService;
import com.hand.hap.system.service.impl.BaseServiceImpl;
import org.apache.commons.codec.binary.Base64;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.*;
import java.math.BigDecimal;
import java.util.*;
/**
* Created with IntelliJ IDEA.
* User: lsy
* Date: 2020/2/24
* Time: 9:08
*/
@Service
public class HclcChinaPayServiceImpl extends BaseServiceImpl<HclcCupSignInfo> implements IHclcChinaPayService {
@Autowired
IHapInterfaceHeaderService headerService;
/*签约短信状态*/
public static final String sendNew = "SEND_NEW";
public static final String sendSuccess = "SEND_SUCCESS";
public static final String sendFail = "SEND_FAIL";
/*签约状态*/
public static final String signFail = "SING_FAIL";
public static final String signSuccess = "SING_SUCCESS";
/*交易类型*/
public static final String cupSendMessage = "CUP_SEND_MESSAGE";
public static final String cupSignSend = "CUP_SIGN_SEND";
public static final String cupBatchUpload = "CUP_BATCH_UPLOAD";
public static final String cupBatchQuery = "CUP_BATCH_QUERY";
public static final String cupBatchDownload = "CUP_BATCH_DOWNLOAD";
/*代扣交易状态*/
public static final String transNew = "NEW";
public static final String transDeal = "DEAL";
public static final String transSuccess = "SUCCESS";
public static final String transFail = "FAIL";
@Value("${cup.mer.id}")
private String cupMerId;
@Value("${cup.upload.file.path}")
private String cupUploadFilePath;
@Value("${cup.download.file.path}")
private String cupDownloadFilePath;
@Value("${cup.init.file.path}")
private String cupInitFilePath;
@Autowired
private HclcCupSignInfoMapper hclcCupSignInfoMapper;
@Autowired
private HlsWsRequestsMapper hlsWsRequestsMapper;
@Autowired
private HlsWsConfigMapper hlsWsConfigMapper;
@Autowired
private HlsEbankCcbTransactionMapper hlsEbankCcbTransactionMapper;
private Logger logger = LoggerFactory.getLogger(getClass());
public HclcChinaPayServiceImpl() {
}
private HclcCupSignInfo createCupSignInfo(IRequest iRequest, JSONObject cardTranDataJson) {
HclcCupSignInfo hclcCupSignInfo = new HclcCupSignInfo();
Map<String, String> additionMapFromJSON = JSONObject.parseObject(cardTranDataJson.toJSONString(), Map.class);
StringUtil.setFieldValue4Bean(hclcCupSignInfo, additionMapFromJSON);
hclcCupSignInfo.setStatus(sendNew);
hclcCupSignInfoMapper.insertSelective(hclcCupSignInfo);
return hclcCupSignInfo;
}
/***
* 签约短信接口;
* @param iRequest
* @param params 签约短信接口
***/
public JSONObject sendSignMessage(IRequest iRequest, JSONObject params) {
JSONObject result = new JSONObject();
Map<String, String> sendMap = new HashMap<String, String>();
sendMap.put("Version", Constants.VERSION);
sendMap.put("AccessType", "0");
sendMap.put(Constants.MER_ID, cupMerId);
String merOrderNo = UUID.randomUUID().toString().replace("-", "").toUpperCase();
sendMap.put("MerOrderNo", merOrderNo);
sendMap.put("TranDate", StringUtil.getRelevantDate(new Date()));
sendMap.put("TranTime", StringUtil.getRelevantTime(new Date()));
sendMap.put("BusiType", Constants.BUSI_TYPE);
sendMap.put("TranType", Constants.TRAN_TYPE_0610);
// 机构或商户接入
String ownerId = cupMerId;
// 获得签名加密类
SecssUtil secssUtil = getSecssUtil(ownerId);
// 构建卡信息保留域
JSONObject cardTranDataJson = new JSONObject();
cardTranDataJson.put("CardNo", params.getString("card_no").replace(" ", ""));
cardTranDataJson.put("AccName", params.getString("acc_name").replace(" ", ""));
cardTranDataJson.put("CertType", "01");
cardTranDataJson.put("CertNo", params.getString("cert_no").replace(" ", ""));
cardTranDataJson.put("MobileNo", params.getString("mobile_no").replace(" ", ""));
cardTranDataJson.put("EntrstAuthNo", params.getString("cert_no").replace(" ", ""));
cardTranDataJson.put("EntrstAmtLmt", "50000000");
//测试由于测试环境日期原因往前调一天
Date strDtT = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(strDtT);
calendar.add(Calendar.DAY_OF_MONTH, -1);
strDtT = calendar.getTime();
cardTranDataJson.put("EntrstStrDtTm", StringUtil.getEntrstStrDtT(strDtT));
cardTranDataJson.put("EntrstEndDtTm", StringUtil.yearAddNum(strDtT, 10));
/*委托扣款时间单位 枚举值: 00-年,03-季,04-月,05-周,07-日*/
cardTranDataJson.put("EntrstDtUnt", "07");
/*委托扣款时间步长*/
cardTranDataJson.put("EntrstDtStp", "9999");
logger.info("send sign message start!");
//创建签约记录
HclcCupSignInfo hclcCupSignInfo = new HclcCupSignInfo();
hclcCupSignInfo = createCupSignInfo(iRequest, cardTranDataJson);
hclcCupSignInfo.setMerOrderNo(merOrderNo);
hclcCupSignInfo.setMerId(cupMerId);
try {
String strCardTranData = null;
if (Objects.nonNull(cardTranDataJson)) {
strCardTranData = cardTranDataJson.toString();
logger.info("加密前的卡保留域=" + strCardTranData);
// 加密
strCardTranData = Base64.encodeBase64String(strCardTranData.getBytes(Constants.ENCODING));
secssUtil.encryptData(strCardTranData);
if (SecssConstants.SUCCESS.equals(secssUtil.getErrCode())) {
strCardTranData = secssUtil.getEncValue();
} else {
result.put(Constants.RESP_CODE, "E");
result.put("respMsg", "加密卡保留域失败,联系管理员!");
logger.info("加密卡保留域失败!" + secssUtil.getErrCode());
return result;
}
}
if (strCardTranData != null) {
sendMap.put(Constants.CARD_TRAN_DATA, strCardTranData);
}
// 签名
secssUtil.sign(sendMap);
if (SecssConstants.SUCCESS.equals(secssUtil.getErrCode())) {
sendMap.put(Constants.SIGNATURE, secssUtil.getSign());
} else {
result.put(Constants.RESP_CODE, "E");
result.put("respMsg", "签名失败,联系管理员!");
logger.info("签名失败!");
return result;
}
result = doSend(sendMap, secssUtil, cupSendMessage, hclcCupSignInfo.getSignId());
if ("0000".equalsIgnoreCase(result.getString(Constants.RESP_CODE))) {
hclcCupSignInfo.setStatus(sendSuccess);
} else {
hclcCupSignInfo.setStatus(sendFail);
}
hclcCupSignInfo.setRemark(result.getString(Constants.RESP_MSG));
} catch (Exception e) {
e.printStackTrace();
logger.info("签约短信接口异常:" + e.getMessage());
result.put(Constants.RESP_CODE, "E");
result.put("respMsg", "签约短信接口异常,联系管理员!");
hclcCupSignInfo.setStatus(sendFail);
}
hclcCupSignInfoMapper.updateByPrimaryKeySelective(hclcCupSignInfo);
result.put("signId", hclcCupSignInfo.getSignId());
return result;
}
/***
* 签约接口;
* @param iRequest
* @param params 签约接口
***/
public JSONObject sendSign(IRequest iRequest, JSONObject params) {
JSONObject result = new JSONObject();
if (Objects.isNull(params.get("signId"))) {
result.put(Constants.RESP_CODE, "E");
result.put("respMsg", "请求必须参数signId缺失,无法签约!");
return result;
}
HclcCupSignInfo hclcCupSignInfo = new HclcCupSignInfo();
hclcCupSignInfo.setSignId(params.getLong("signId"));
hclcCupSignInfo = hclcCupSignInfoMapper.selectByPrimaryKey(hclcCupSignInfo);
if (signSuccess.equalsIgnoreCase(hclcCupSignInfo.getStatus())) {
result.put(Constants.RESP_CODE, "E");
result.put("respMsg", "签约已完成,无需重复签约!");
return result;
}
Map<String, String> sendMap = new HashMap<String, String>();
sendMap.put("Version", Constants.VERSION);
sendMap.put(Constants.MER_ID, hclcCupSignInfo.getMerId());
sendMap.put("MerOrderNo", hclcCupSignInfo.getMerOrderNo());
sendMap.put("TranDate", StringUtil.getRelevantDate(new Date()));
sendMap.put("TranTime", StringUtil.getRelevantTime(new Date()));
sendMap.put("BusiType", Constants.BUSI_TYPE);
sendMap.put("TranType", Constants.TRAN_TYPE_9910);
sendMap.put("MerBgUrl", "http://lease.hitachics.com/core/api/public/china/send/sign/listen");
// 机构或商户接入
String ownerId = cupMerId;
// 获得签名加密类
SecssUtil secssUtil = getSecssUtil(ownerId);
// 构建卡信息保留域
JSONObject cardTranDataJson = new JSONObject();
cardTranDataJson.put("CardNo", hclcCupSignInfo.getCardNo());
cardTranDataJson.put("AccName", hclcCupSignInfo.getAccName());
cardTranDataJson.put("CertType", hclcCupSignInfo.getCertType());
cardTranDataJson.put("CertNo", hclcCupSignInfo.getCertNo());
cardTranDataJson.put("MobileNo", hclcCupSignInfo.getMobileNo());
cardTranDataJson.put("EntrstAuthNo", hclcCupSignInfo.getCertNo());
cardTranDataJson.put("EntrstAmtLmt", hclcCupSignInfo.getEntrstAmtLmt());
cardTranDataJson.put("EntrstStrDtTm", hclcCupSignInfo.getEntrstStrDtTm());
cardTranDataJson.put("EntrstEndDtTm", hclcCupSignInfo.getEntrstEndDtTm());
/*委托扣款时间单位 枚举值: 00-年,03-季,04-月,05-周,07-日*/
cardTranDataJson.put("EntrstDtUnt", hclcCupSignInfo.getEntrstDtUnt());
/*委托扣款时间步长*/
cardTranDataJson.put("EntrstDtStp", hclcCupSignInfo.getEntrstDtStp().toString());
cardTranDataJson.put("MobileAuthCode", params.getString("auth_code"));
String strCardTranData = null;
try {
logger.info("send sign start!");
if (Objects.nonNull(cardTranDataJson)) {
strCardTranData = cardTranDataJson.toString();
logger.info("加密前的卡保留域=" + strCardTranData);
// 加密
strCardTranData = Base64.encodeBase64String(strCardTranData.getBytes(Constants.ENCODING));
secssUtil.encryptData(strCardTranData);
if (SecssConstants.SUCCESS.equals(secssUtil.getErrCode())) {
strCardTranData = secssUtil.getEncValue();
} else {
result.put(Constants.RESP_CODE, "E");
result.put("respMsg", "加密卡保留域失败,联系管理员!");
logger.info("加密卡保留域失败!");
return result;
}
}
if (strCardTranData != null) {
sendMap.put(Constants.CARD_TRAN_DATA, strCardTranData);
}
// 构建交易扩展域
JSONObject tranReservedJson = new JSONObject();
tranReservedJson.put("SubTransType", "99100001");
// String strTranReserved = null;
//
// if (Objects.nonNull(tranReservedJson)) {
// strTranReserved = tranReservedJson.toString();
// logger.info(String.format("加密前的交易扩展域=%s", strTranReserved));
// // 加密
// strTranReserved = Base64.encodeBase64String(strTranReserved.getBytes(Constants.ENCODING));
// secssUtil.encryptData(strTranReserved);
// if (SecssConstants.SUCCESS.equals(secssUtil.getErrCode())) {
// strTranReserved = secssUtil.getEncValue();
// } else {
// result.put(Constants.RESP_CODE, "E");
// result.put("respMsg", "加密交易扩展域失败,联系管理员!");
// logger.info("加密交易扩展域失败!");
// return result;
// }
// }
//
// if (strTranReserved != null) {
// sendMap.put(Constants.TRAN_RESERVED, strTranReserved);
// }
sendMap.put(Constants.TRAN_RESERVED, tranReservedJson.toString());
// 签名
secssUtil.sign(sendMap);
if (SecssConstants.SUCCESS.equals(secssUtil.getErrCode())) {
sendMap.put(Constants.SIGNATURE, secssUtil.getSign());
} else {
result.put(Constants.RESP_CODE, "E");
result.put("respMsg", "签名失败,联系管理员!");
logger.info("签名失败!");
return result;
}
result = doSend(sendMap, secssUtil, cupSignSend, hclcCupSignInfo.getSignId());
if ("0000".equalsIgnoreCase(result.getString(Constants.RESP_CODE)) && "01".equalsIgnoreCase(result.getString("SignState"))) {
hclcCupSignInfo.setStatus(signSuccess);
hclcCupSignInfo.setProtocolNo(result.getJSONObject("CardTranData").getString("ProtocolNo"));
} else {
hclcCupSignInfo.setStatus(signFail);
}
} catch (Exception e) {
e.printStackTrace();
logger.info("签约接口异常:" + e.getMessage());
result.put(Constants.RESP_CODE, "E");
result.put("respMsg", "签约接口异常,联系管理员!");
hclcCupSignInfo.setStatus(signFail);
}
hclcCupSignInfoMapper.updateByPrimaryKeySelective(hclcCupSignInfo);
return result;
}
/***
* 批量交易文件上传接口;
* @param iRequest
* @param params 批量交易文件上传接口
***/
public JSONObject uploadBatch(IRequest iRequest, JSONObject params) {
JSONObject result = new JSONObject();
if (Objects.isNull(params.get("transaction_id"))) {
result.put(Constants.RESP_CODE, "E");
result.put("respMsg", "请求必须参数transaction_id缺失,无法上传!");
return result;
}
HlsEbankCcbTransaction hlsEbankCcbTransaction = new HlsEbankCcbTransaction();
hlsEbankCcbTransaction.setTransactionId(params.getLongValue("transaction_id"));
hlsEbankCcbTransaction = hlsEbankCcbTransactionMapper.selectByPrimaryKey(hlsEbankCcbTransaction);
if (!transNew.equalsIgnoreCase(hlsEbankCcbTransaction.getStatus())) {
result.put(Constants.RESP_CODE, "E");
result.put("respMsg", "批扣单据状态异常,批扣文件无法发送!");
logger.info("批扣单据状态异常,批扣文件无法发送!");
return result;
}
logger.info("upload batch start, transaction_id:" + hlsEbankCcbTransaction.getTransactionId());
try {
Map<String, String> sendMap = new HashMap<String, String>();
sendMap.put("Version", Constants.VERSION);
sendMap.put(Constants.MER_ID, cupMerId);
sendMap.put("FileName", hlsEbankCcbTransaction.getSendFileName());
sendMap.put("BusiType", Constants.BUSI_TYPE);
String filepath = cupUploadFilePath + hlsEbankCcbTransaction.getSendFileName();
//将获取批量代扣文件内容信息
File file = new File(filepath);
long fileSize = file.length();
if (fileSize > Integer.MAX_VALUE) {
System.out.println("file too big...");
result.put(Constants.RESP_CODE, "E");
result.put("respMsg", "批扣文件上传接口异常,上传文件太大!");
logger.info("批扣文件上传接口异常,上传文件太大!");
return result;
}
if (fileSize <= 0) {//如果文件太小
result.put(Constants.RESP_CODE, "E");
result.put("respMsg", "批扣文件上传接口异常,文件不存在!");
logger.info("批扣文件上传接口异常,文件不存在!");
return result;
}
FileInputStream fi = new FileInputStream(file);
InputStreamReader reader = new InputStreamReader(fi, "UTF-8");
BufferedReader br = new BufferedReader(reader);
String readResult = "";
String line;
while ((line = br.readLine()) != null) {
readResult += line;
readResult += "\n";
}
br.close();
reader.close();
if (readResult.startsWith("\uFEFF")) {
readResult = readResult.substring(1);
}
// 机构或商户接入
String ownerId = cupMerId;
// 获得签名加密类
SecssUtil secssUtil = getSecssUtil(ownerId);
String contentStr = secssUtil.encodeEnvelope(readResult.getBytes("UTF-8"));
sendMap.put("FileContent", contentStr);
secssUtil.sign(sendMap);
if (SecssConstants.SUCCESS.equals(secssUtil.getErrCode())) {
sendMap.put(Constants.SIGNATURE, secssUtil.getSign());
} else {
result.put(Constants.RESP_CODE, "E");
result.put("respMsg", "签名失败,联系管理员!");
logger.info("签名失败!");
return result;
}
hlsEbankCcbTransaction.setVersion(sendMap.get("Version"));
hlsEbankCcbTransaction.setTranDate(StringUtil.getRelevantDate(new Date()));
hlsEbankCcbTransaction.setTranTime(StringUtil.getRelevantTime(new Date()));
hlsEbankCcbTransaction.setTranType("0101");
result = doSend(sendMap, secssUtil, cupBatchUpload, hlsEbankCcbTransaction.getTransactionId());
if ("0014".equalsIgnoreCase(result.getString(Constants.RESP_CODE)) || "2043".equalsIgnoreCase(result.getString(Constants.RESP_CODE)) || "E".equalsIgnoreCase(result.getString(Constants.RESP_CODE))) {
hlsEbankCcbTransaction.setStatus(transDeal);
hlsEbankCcbTransaction.setOrderStatus("0001");
} else {
hlsEbankCcbTransaction.setStatus(transFail);
hlsEbankCcbTransaction.setOrderStatus("0003");
}
hlsEbankCcbTransaction.setReturnCode(result.getString(Constants.RESP_CODE));
hlsEbankCcbTransaction.setReturnMsg(result.getString(Constants.RESP_MSG));
} catch (Exception e) {
e.printStackTrace();
logger.info("批量交易文件上传异常," + e.getMessage());
result.put(Constants.RESP_CODE, "E");
result.put(Constants.RESP_MSG, "批量交易文件上传异常,联系管理员!");
hlsEbankCcbTransaction.setStatus(transDeal);
}
hlsEbankCcbTransactionMapper.updateByPrimaryKeySelective(hlsEbankCcbTransaction);
return result;
}
/***
* 批量交易文件查询接口;
* @param iRequest
* @param params 批量交易文件查询接口
***/
public JSONObject queryBatch(IRequest iRequest, JSONObject params) {
JSONObject result = new JSONObject();
if (Objects.isNull(params.get("transaction_id"))) {
result.put(Constants.RESP_CODE, "E");
result.put(Constants.RESP_MSG, "请求必须参数transaction_id缺失,无法查询!");
return result;
}
HlsEbankCcbTransaction hlsEbankCcbTransaction = new HlsEbankCcbTransaction();
hlsEbankCcbTransaction.setTransactionId(params.getLongValue("transaction_id"));
hlsEbankCcbTransaction = hlsEbankCcbTransactionMapper.selectByPrimaryKey(hlsEbankCcbTransaction);
Map<String, String> sendMap = new HashMap<String, String>();
sendMap.put("Version", Constants.VERSION);
sendMap.put(Constants.MER_ID, cupMerId);
sendMap.put("MerBatchId", hlsEbankCcbTransaction.getSendFileName().split("_")[2]);
sendMap.put("MerBatchDate", hlsEbankCcbTransaction.getSendFileName().split("_")[1]);
sendMap.put("BusiType", Constants.BUSI_TYPE);
sendMap.put("TranType", Constants.TRAN_TYPE_0506);
logger.info("query batch start, transaction_id:" + hlsEbankCcbTransaction.getTransactionId());
try {
// 机构或商户接入
String ownerId = cupMerId;
// 获得签名加密类
SecssUtil secssUtil = getSecssUtil(ownerId);
secssUtil.sign(sendMap);
if (SecssConstants.SUCCESS.equals(secssUtil.getErrCode())) {
sendMap.put(Constants.SIGNATURE, secssUtil.getSign());
} else {
result.put(Constants.RESP_CODE, "E");
result.put(Constants.RESP_MSG, "签名失败,联系管理员!");
logger.info("签名失败!");
return result;
}
result = doSend(sendMap, secssUtil, cupBatchQuery, hlsEbankCcbTransaction.getTransactionId());
if ("0000".equalsIgnoreCase(result.getString(Constants.RESP_CODE))) {
String orderStatus = result.getString("OrderStatus");
if ("0000".equalsIgnoreCase(orderStatus)) {
hlsEbankCcbTransaction.setBackFileName(result.getString("DownloadFileName"));
} else if ("0003".equalsIgnoreCase(orderStatus) || "1002".equalsIgnoreCase(orderStatus)) {
hlsEbankCcbTransaction.setStatus(transFail);
}
hlsEbankCcbTransaction.setOrderStatus(orderStatus);
} else if ("3441".equalsIgnoreCase(result.getString(Constants.RESP_CODE))) {
hlsEbankCcbTransaction.setStatus(transFail);
}
} catch (Exception e) {
e.printStackTrace();
logger.info("批量交易文件查询异常!" + e.getMessage());
result.put(Constants.RESP_CODE, "E");
result.put(Constants.RESP_MSG, "批量交易文件查询异常,联系管理员!");
}
hlsEbankCcbTransactionMapper.updateByPrimaryKeySelective(hlsEbankCcbTransaction);
return result;
}
/***
* 批量交易文件下载接口;
* @param iRequest
* @param params 批量交易文件下载接口
***/
public JSONObject downloadBatch(IRequest iRequest, JSONObject params) {
JSONObject result = new JSONObject();
if (Objects.isNull(params.get("transaction_id"))) {
result.put(Constants.RESP_CODE, "E");
result.put(Constants.RESP_MSG, "请求必须参数transaction_id缺失,无法下载!");
return result;
}
HlsEbankCcbTransaction hlsEbankCcbTransaction = new HlsEbankCcbTransaction();
hlsEbankCcbTransaction.setTransactionId(params.getLongValue("transaction_id"));
hlsEbankCcbTransaction = hlsEbankCcbTransactionMapper.selectByPrimaryKey(hlsEbankCcbTransaction);
Map<String, String> sendMap = new HashMap<String, String>();
sendMap.put("Version", Constants.VERSION);
sendMap.put(Constants.MER_ID, cupMerId);
sendMap.put("OriFileName", hlsEbankCcbTransaction.getSendFileName());
sendMap.put("DownloadFileName", hlsEbankCcbTransaction.getBackFileName());
logger.info("download batch start, transaction_id:" + hlsEbankCcbTransaction.getTransactionId());
try {
// 机构或商户接入
String ownerId = cupMerId;
// 获得签名加密类
SecssUtil secssUtil = getSecssUtil(ownerId);
secssUtil.sign(sendMap);
if (SecssConstants.SUCCESS.equals(secssUtil.getErrCode())) {
sendMap.put(Constants.SIGNATURE, secssUtil.getSign());
} else {
result.put(Constants.RESP_CODE, "E");
result.put(Constants.RESP_MSG, "签名失败,联系管理员!");
logger.info("签名失败!");
return result;
}
result = doSend(sendMap, secssUtil, cupBatchDownload, hlsEbankCcbTransaction.getTransactionId());
if ("0000".equalsIgnoreCase(result.getString(Constants.RESP_CODE))) {
String fileData = result.getString("FileData");
String filepath = cupDownloadFilePath + hlsEbankCcbTransaction.getBackFileName();
FileOutputStream fos = new FileOutputStream(filepath);
OutputStreamWriter write = new OutputStreamWriter(fos, "UTF-8");
BufferedWriter writer = new BufferedWriter(write);
writer.write(fileData);
writer.close();
hlsEbankCcbTransaction.setFileFlag("1");
hlsEbankCcbTransactionMapper.updateByPrimaryKeySelective(hlsEbankCcbTransaction);
result.remove("FileData");
}
} catch (Exception e) {
e.printStackTrace();
logger.info("批量交易文件下载接口异常" + e.getMessage());
result.put(Constants.RESP_CODE, "E");
result.put(Constants.RESP_MSG, "批量交易文件下载接口异常,联系管理员!");
}
return result;
}
/***
* 通用发送接口;
* @param
* @param sendMap 通用发送接口
***/
public JSONObject doSend(Map<String, String> sendMap, SecssUtil secssUtil, String functionName, Long pkValue) throws UnsupportedEncodingException {
JSONObject resultJson = new JSONObject();
JSONObject requestJson = new JSONObject();
for (String key : sendMap.keySet()) {
String value = sendMap.get(key);
if (value == null) {
value = "null";
}
value = value.trim();
requestJson.put(key, value);
}
//获取配置url信息
HlsWsConfig hlsWsConfig = new HlsWsConfig();
List<HlsWsConfig> configs = new ArrayList<>();
hlsWsConfig.setConfigName(functionName);
configs = hlsWsConfigMapper.select(hlsWsConfig);
if (Objects.nonNull(configs) && configs.size() > 0) {
hlsWsConfig = configs.get(0);
} else {
resultJson.put(Constants.RESP_CODE, "E");
resultJson.put(Constants.RESP_MSG, "发送请求失败,请求地址信息:" + functionName + "未定义");
logger.info("发送请求失败,请求地址信息: {} 未定义!", functionName);
return resultJson;
}
//初始化日志
HlsWsRequests hlsWsRequests = logInterfaceRequest(functionName, hlsWsConfig.getWsdlAddress(), requestJson.toString(), pkValue);
logger.info("发送请求,请求参数: {}", requestJson.toString());
String result = "";
try {
result = HttpUtils.sendJson(hlsWsConfig.getWsdlAddress(), requestJson, Constants.ENCODING);
logger.info("发送请求结果: {} ", result);
} catch (Exception e) {
e.printStackTrace();
logger.info("发送请求异常: {} ", e.getMessage());
resultJson.put(Constants.RESP_CODE, "E");
resultJson.put(Constants.RESP_MSG, "发送请求异常,异常原因" + e.getMessage());
hlsWsRequests.setReturnStatus("E");
hlsWsRequests.setResponsedDate(new Date());
hlsWsRequestsMapper.updateByPrimaryKeySelective(hlsWsRequests);
return resultJson;
}
Map<String, String> retMap = JSONObject.parseObject(result, Map.class);
hlsWsRequests.setResponseClob(result);
hlsWsRequests.setReturnStatus("S");
hlsWsRequests.setResponsedDate(new Date());
hlsWsRequestsMapper.updateByPrimaryKeySelective(hlsWsRequests);
//验签
String sign = retMap.get(Constants.SIGNATURE);
if (StringUtil.isNotEmpty(sign)) {
secssUtil.verify(retMap);
}
if ((Objects.isNull(retMap.get(Constants.RESP_CODE)))) {
//TODO:抛异常
resultJson.put(Constants.RESP_CODE, "E");
resultJson.put(Constants.RESP_MSG, "请求返回结果未发现验签验签信息,请联系系统管理员");
logger.info("请求返回结果未发现验签验签信息");
return resultJson;
}
for (Map.Entry<String, String> entry : retMap.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
if (StringUtil.isEmpty(value)) {
continue;
}
// 解密交易保留域
if (Constants.CARD_TRAN_DATA.equals(key)) {
secssUtil.decryptData(value);
if (SecssConstants.SUCCESS.equals(secssUtil.getErrCode())) {
value = secssUtil.getDecValue();
// value = new String(Base64.decodeBase64(value),
// Constants.ENCODING);
} else {
}
}
// 解密风控保留域
if (Constants.RISK_DATA.equals(key)) {
secssUtil.decryptData(value);
if (SecssConstants.SUCCESS.equals(secssUtil.getErrCode())) {
value = secssUtil.getDecValue();
// value = new String(Base64.decodeBase64(value),
// Constants.ENCODING);
} else {
}
}
// 解密文件内容
if (Constants.FILE_DATA.equals(key)) {
byte[] bytes = secssUtil.decodeEnvelope(value);
value = new String(bytes, "UTF-8");
}
resultJson.put(key, value);
}
hlsWsRequests.setResponseClob(resultJson.toString());
hlsWsRequestsMapper.updateByPrimaryKeySelective(hlsWsRequests);
return resultJson;
}
/**
* 加载安全秘钥 .
*
* @param ownerId 所有者id
* @return SecssUtil .
*/
protected SecssUtil getSecssUtil(String ownerId) {
String path = String.format("%s%s.properties", cupInitFilePath, ownerId);
SecssUtil secssUtil = new SecssUtil(true);
secssUtil.init(path);
return secssUtil;
}
private String getTableName(String functionName) {
String tableName = "";
if ("CUP_SIGN_SEND".equalsIgnoreCase(functionName) || "CUP_SEND_MESSAGE".equalsIgnoreCase(functionName)) {
tableName = "HCLC_CUP_SIGN_INFO";
} else if ("CUP_BATCH_UPLOAD".equalsIgnoreCase(functionName) || "CUP_BATCH_QUERY".equalsIgnoreCase(functionName) || "CUP_BATCH_DOWNLOAD".equalsIgnoreCase(functionName)) {
tableName = "HLS_EBANK_CCB_TRANSACTION";
}
return tableName;
}
public HlsWsRequests logInterfaceRequest(String functionName, String url, String request, Long pkValue) {
HlsWsRequests hlsWsRequests = new HlsWsRequests();
hlsWsRequests.setRequestDate(new Date());
hlsWsRequests.setRequestWsdlUrl(url);
hlsWsRequests.setFunctionName(functionName);
String tableName = getTableName(functionName);
hlsWsRequests.setTableName(tableName);
hlsWsRequests.setStatusCode("1");
hlsWsRequests.setStatusDate(new Date());
hlsWsRequests.setPkValue(pkValue);
hlsWsRequests.setRequestClob(request);
hlsWsRequestsMapper.insertSelective(hlsWsRequests);
return hlsWsRequests;
}
}
/**
* 项目名称(中文)
* 项目名称(英文)
* Copyright (c) 2016 ChinaPay Ltd. All Rights Reserved.
*/
package com.chinapay.util;
import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject;
import com.chinapay.comm.Constants;
import org.apache.commons.lang.StringUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHeaders;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.ssl.AllowAllHostnameVerifier;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author hrtc .
*/
public class HttpUtils {
/**
* 超时时间 .
*/
private static int SOCKET_TIMEOUT = 60000;
/**
* 连接超时时间 .
*/
private static int CONNECT_TIMEOUT = 60000;
private static Logger logger = LoggerFactory.getLogger(HttpUtils.class);
/**
* 发送http,注意如果调用频繁请自行改造成http连接池.
*
* @param url 请求地址
* @param dataMap 请求map
* @return 返回字符串
*/
public static String send(String url, Map<String, String> dataMap) {
CloseableHttpClient client = null;
CloseableHttpResponse resp = null;
try {
client = HttpClients.custom().build();
RequestConfig config = RequestConfig.custom()
.setSocketTimeout(SOCKET_TIMEOUT)
.setConnectTimeout(CONNECT_TIMEOUT)
.setAuthenticationEnabled(false).build();
HttpPost post = new HttpPost(url);
post.setProtocolVersion(org.apache.http.HttpVersion.HTTP_1_1);
post.setConfig(config);
HttpEntity entity = null;
List<NameValuePair> formpair = new ArrayList<NameValuePair>();
{
for (String str : dataMap.keySet().toArray(
new String[dataMap.size()])) {
formpair.add(new BasicNameValuePair(str, dataMap.get(str)
.toString()));
}
}
entity = new UrlEncodedFormEntity(formpair, Constants.ENCODING);
if (entity != null) {
post.setEntity(entity);
}
resp = client.execute(post);
if (resp.getStatusLine().getStatusCode() == 200) {
InputStream is = null;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
byte[] buffer = new byte[1024];
is = resp.getEntity().getContent();
int count = is.read(buffer);
while (count != -1) {
baos.write(buffer, 0, count);
count = is.read(buffer);
}
return baos.toString(Constants.ENCODING);
} finally {
if (is != null) {
try {
is.close();
} finally {
// ignore
}
}
if (baos != null) {
try {
baos.close();
} finally {
// ignore
}
}
}
} else {
throw new RuntimeException(String.format(
"发送请求失败,statusCode=%s", resp.getStatusLine()
.getStatusCode()));
}
} catch (ClientProtocolException e) {
throw new RuntimeException(e.getMessage(), e);
} catch (IOException e) {
throw new RuntimeException(e.getMessage(), e);
} finally {
if (resp != null) {
try {
resp.close();
} catch (Exception e) {
// ignore
}
}
if (client != null) {
try {
client.close();
} catch (Exception e) {
// ignore
}
}
}
}
public static String sendJson(String url, JSONObject params, String charset) throws Exception {
String result = "";
// 字符集编码
if (StringUtils.isBlank(charset)) {
charset = Constants.ENCODING;
}
// 创建http POST请求
CloseableHttpClient httpclient = null;
HttpPost httpPost = new HttpPost(url);
CloseableHttpResponse response = null;
try {
httpPost.setHeader(HttpHeaders.CONTENT_ENCODING, charset);
httpPost.setHeader(HttpHeaders.CONTENT_TYPE, "application/x-www-form-urlencoded;charset=" + charset);
List<NameValuePair> nameValuePairList = new ArrayList<NameValuePair>();
for (String key : params.keySet()) {
nameValuePairList.add(new BasicNameValuePair(key, params.get(key).toString()));
}
UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(nameValuePairList, "utf-8");
formEntity.setContentType("application/x-www-form-urlencoded; charset=UTF-8");
httpPost.setEntity(formEntity);
// 设置参数
RequestConfig.Builder customReqConf = RequestConfig.custom();
customReqConf.setSocketTimeout(SOCKET_TIMEOUT);
customReqConf.setConnectTimeout(CONNECT_TIMEOUT);
if (url.startsWith("https")) {
SSLContext context = buildSSLContext();
// 执行Https请求
httpclient = HttpClientBuilder.create().setDefaultRequestConfig(customReqConf.build())
.setHostnameVerifier(new AllowAllHostnameVerifier())
.setSslcontext(context).build();
} else {
httpclient = HttpClientBuilder.create().setDefaultRequestConfig(customReqConf.build()).build();
}
response = httpclient.execute(httpPost);
if (response != null) {
logger.info("返回状态码:" + response.getStatusLine().getStatusCode());
// 判断返回状态是否为200
if (response.getStatusLine().getStatusCode() == 200) {
// logger.info("返回结果:" + EntityUtils.toString(response.getEntity(), charset));
result = getJsonStrByQueryUrl(EntityUtils.toString(response.getEntity(), charset));
}
} else {
logger.info("发送无结果");
}
} catch (Exception e) {
logger.error("发送失败", e);
throw e;
} finally {
if (response != null) {
try {
response.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (httpclient != null) {
httpclient.close();
}
}
return result;
}
public static String getJsonStrByQueryUrl(String paramStr) throws UnsupportedEncodingException {
String[] params = paramStr.split("&");
JSONObject obj = new JSONObject();
for (int i = 0; i < params.length; i++) {
String[] param = params[i].split("=");
if (param.length >= 2) {
String key = param[0];
String value = URLDecoder.decode(param[1], "utf-8");
for (int j = 2; j < param.length; j++) {
value += "=" + param[j];
}
try {
obj.put(key, value);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
return obj.toString();
}
/**
* 构建SSL上下文.
*
* @return SSLContext
* @author cp
*/
private static SSLContext buildSSLContext() {
try {
SSLContext sslc = SSLContext.getInstance("TLS");
sslc.init(null, createNonValidateTrustmanager(), null);
return sslc;
} catch (Exception ex) {
logger.error("SSL上下文创建失败,请联系管理员.", ex);
}
return null;
}
/**
* 信任一切证书.
*
* @return TrustManager[]
* @author cp
*/
private static TrustManager[] createNonValidateTrustmanager() {
TrustManager[] trustAllCerts = new TrustManager[]{
new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted(X509Certificate[] certs, String authType) {
}
public void checkServerTrusted(X509Certificate[] certs, String authType) {
}
}};
return trustAllCerts;
}
}
package com.chinapay.util;
import java.io.*;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.chinapay.comm.Constants;
import com.chinapay.secss.SecssConstants;
import com.chinapay.secss.SecssUtil;
import com.hand.hap.system.dto.BaseDTO;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang.time.DateUtils;
import org.apache.http.HttpResponse;
/**
* 字符串工具.
*
* @author hrtc
* .
*/
public class StringUtil {
/**
* 判断字符串为空.
*
* @param str 字符串
* @return 是否为空
*/
public static boolean isEmpty(String str) {
return str == null || str.trim().length() == 0 ? true : false;
}
/**
* 判断字符串不为空.
*
* @param str 字符串
* @return 是否不为空
*/
public static boolean isNotEmpty(String str) {
return !isEmpty(str);
}
/**
* 获取传入时间所对应的年月日时间 .
*
* @param date 当前时间 .
* @return 返回字符串格式 yyyyMMdd .
*/
public static String getRelevantDate(Date date) {
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
String dateString = formatter.format(date);
return dateString;
}
/**
* 获取传入时间所对应的时分秒时间 .
*
* @param date 当前时间 .
* @return 返回字符串格式 HHmmss .
*/
public static String getRelevantTime(Date date) {
SimpleDateFormat formatter = new SimpleDateFormat("HHmmss");
String dateString = formatter.format(date);
return dateString;
}
/**
* 获取传入时间所对应的时分秒时间 .
*
* @param date 当前时间 .
* @return 返回字符串格式 yyyymmddhhmmss .
*/
public static String getEntrstStrDtT(Date date) {
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
String dateString = formatter.format(date);
return dateString;
}
public static void main(String[] args) throws IOException {
// String path = String.format("%s%s.properties", "F:\\work\\workspace\\IdeaProjects\\hls-support-rlwx\\key\\", "000092112092486");
// SecssUtil secssUtil = new SecssUtil(true);
// secssUtil.init(path);
// Map<String, String> sendMap=new HashMap<String, String>();
// sendMap.put("TranType","0101");
// sendMap.put("AcqDate","20211222");
// sendMap.put("AcqSeqId","202112220003958");
// sendMap.put("BusiType","0001");
// sendMap.put("Version","20140728");
//// sendMap.put("CardTranData","cVhbUCg8yizfv4CvpKsGbqfXpT08VpVF+31IU1eWkP5RIhLddaoOZ7ZSbdo01AVufwILglZQQZBbCTzKvwCdLM4NGSWXIW6sbIXvU24TLC6oETFM1/SAD8vaZW5+AwaD6O/khtC9H5zG2xGMCJ9sX2j+/0xNZ/WLsEi6ZAljwplU38LtY1DMJAieGqoNVPk370lwpCXa196v83H5eiD3XlYe3Hr/Qw5JQOwPj1WV/uHcCgS0wMeinLQ1yniOlTdMQWMeDy/6OubTFLhEXVIAk76SKH4uQsZP8Q3PnuIksxEqpf63RXBLaZp5E4Fuy35BkTgVke3ad437I++ZtO0h7w==");
//// sendMap.put("MerOrderNo","7F93B4C920A64B88A60B10E82D9712BE");
// sendMap.put("MerBatchId","000001");
// sendMap.put("OrderStatus","1015");
// sendMap.put("MerId","000092112092486");
// sendMap.put("respMsg","查询成功");
// sendMap.put("TotalAmt","00000000000000000200");
// sendMap.put("MerBatchDate","20211222");
// sendMap.put("respCode","0000");
//
// sendMap.put("Signature","d9sL1jRijMaaxchY 9AvYahuSNmO5QbcD/WAgMgqOzTxAwslITrDVW1lfEj9VealeJ4wmaOKttc ZaoxbfSqcDYX4DvvaTxqQ4BSO4EtgG5GrKQr8SxOx6QOat7J l7KNtbW3l4EkVsQJ0y0wF3ClBSaFkAaXdgLFIrNJ8QGtto1nbSYyEJBD06WXfpAtnsiqT3K95ETaUV6DivQYfV CoCfzlNfR1oZNfL6p zxALnwHLLyBTltcVAl pccxynFHVKlW1cS1wBbUxz9TCJr5YO1Q6kFI5dmxRtoXHckIooS7u9rSLWfRmEShm8yXLVDWRllo159uSGLPLaB2iSucA");
// secssUtil.verify(sendMap);
// System.out.println(secssUtil.getErrCode());
// HttpUtils.getJsonStrByQueryUrl("BusiType=0001&TranType=0610&AcqCode=000000000000014&TranDate=20211222&Version=20140728&MerOrderNo=5F03D054A6ED4C9B90382CC11D555FC1&Signature=iVNHtphvHqGVxgwpNgEGGG5cmCjTlooDLveLlu%2FrTZH0gJbZ0xRbaFhxYd1NUSvyv7dLLL2v43FcnUnpPSJb8WXNPEVyXzZGvy1W1bYhyvksMFDIfn8Fmgg%2F6782efGfGanpWCs%2Bdcy2fvngNlN47aAwM8YkdlD8Q0hgLaOVhBehsf9ex1jAySCaHSu3mOp2fL%2B3kSlXQ7l3A5BT8iI4fydvXl9c0djeOMhk%2Bk5A2eVBYcTlMmvf7KaColVTKF5mbrMFYB8%2Bbl4qDxi77KYNnwb7g0GMU95xsgfGW03VxFdRiJvMfnNbjv7sVf35Uq9Eu8YBS%2B7fgUiQXOVLq7K7uA%3D%3D&MerId=000092112092486&respMsg=%E6%88%90%E5%8A%9F&TranTime=105332&AccessType=0&respCode=0000");
// File file = new File("F:\\work\\workspace\\HCLC_Leasing\\运维\\运维报告\\日立建机新开项目2021\\银联代扣\\测试环境\\000092112092486_20211222_000001_Q.txt");
// FileInputStream fi = new FileInputStream(file);
// InputStreamReader reader = new InputStreamReader(fi, "UTF-8"); //最后的"GBK"根据文件属性而定,如果不行,改成"UTF-8"试试
// BufferedReader br = new BufferedReader(reader);
// String result = "";
// String line;
// while ((line = br.readLine()) != null) {
// result+=line;
// result+="\n";
// }
// br.close();
// reader.close();
//
// if (result.startsWith("\uFEFF")) {
// result = result.substring(1);
// }
//
// String path = String.format("%s%s.properties", "F:\\work\\workspace\\IdeaProjects\\hls-support-rlwx\\key\\", "000092112092486");
// SecssUtil secssUtil = new SecssUtil(true);
// secssUtil.init(path);
// String contentStr = secssUtil.encodeEnvelope(result.getBytes("UTF-8"));
// Map<String, String> sendMap = new HashMap<String, String>();
// sendMap.put("BusiType", "0001");
// sendMap.put("Version", "20140728");
// sendMap.put("MerId", "000092112092486");
// sendMap.put("FileName", "000092112092486_20211222_000001_Q.txt");
// sendMap.put("FileContent", contentStr);
//
// secssUtil.sign(sendMap);
// if (SecssConstants.SUCCESS.equals(secssUtil.getErrCode())) {
// sendMap.put(Constants.SIGNATURE, secssUtil.getSign());
// }
// System.out.println(contentStr);
// String fileData = "6226 0912 1056 2371";
// fileData.trim();
String strCardTranData = null;
String path = String.format("%s%s.properties", "F:\\work\\workspace\\IdeaProjects\\hls-support-rlwx\\key\\", "000092112092486");
SecssUtil secssUtil = new SecssUtil(true);
secssUtil.init(path);
// strCardTranData = "{\"AccName\":\"张博\",\"MobileNo\":\"18653352435\",\"CardNo\":\"6215686000014576697\",\"EntrstAuthNo\":\"370321199004060610\",\"EntrstAmtLmt\":\"50000000\",\"CertType\":\"01\",\"EntrstDtStp\":\"9999\",\"EntrstEndDtTm\":\"20320118202019\",\"CertNo\":\"370321199004060610\",\"EntrstStrDtTm\":\"20220118202019\",\"EntrstDtUnt\":\"07\"}";
// // 加密
// strCardTranData = Base64.encodeBase64String(strCardTranData.getBytes(Constants.ENCODING));
// secssUtil.encryptData(strCardTranData);
Map<String, String> sendMap=new HashMap<String, String>();
sendMap.put("TranType","0608");
sendMap.put("BusiType","0001");
sendMap.put("Version","20140728");
sendMap.put("TranDate","20220119");
sendMap.put("CardTranData","i4T9Hpt/Qmkhh/xSzULM39qft9MS4KhMi+MQ3dvxJtbihUTlrk/xR1U8DhIAxvzsTVjINd14GbxYuXdG/N8cFZ15bHhDp89gkk6hvK9A+7l0WWNDnVlJWcLag0ERgA0v0FhXgfheqrMWuWnr9zrVp7yN+9SOs6XzTEUpN/ejhLd/nDkRBEyzJcPtxEWDB+M2KWOWLEjZf4L0NO3UN93ir7IvzoZmwzmwvpEW3Y4+sW9X9VMP8riaGnYV5VtoUvzUr55uBR6mIeuoqrZApvs0Pj8mJ687AvOz/yeyhlPvm1WMzjsrjPeztx1C3hstwwAEk9i6K3VjNkD2KaFwgFK1jcdTzqE5IqvXh5jRVlmBHaVnRzmfhBaZiFVvSkqbGdY90icPfDFhPR843ZsQOvO6Xul1fKfl5oH8UfASwqkCmYRKSnVwmK1oAN/QrOgNmTLBRuKY6F2qKLvX4ZJ784aqRimWVYLVdIknAj224MHoSG4bWRDIvu7kw2+tI9+wne1ng4t6KZtEreAL8BpDpvIVUhApKapf5l4T9qWS7BC8EFMIGSl5qyxi686C+EFRXSp9J9m6H3cia1Pad5URvkFItvSIhwyulL8pcUEnr0uIJdohJUHbuevCRVQEJffA1MSY0MEbYSRaMBzPfqqsORfRjGI+XO1Qwtq2rQw+ShXirlc=");
sendMap.put("MerOrderNo","F38CE3A782984D21AD8584238D40C890");
sendMap.put("MerId","739412105210001");
sendMap.put("TranTime","224028");
sendMap.put("AccessType","0");
secssUtil.sign(sendMap);
sendMap.put("Signature",secssUtil.getSign());
// sendMap.put("Signature","zJ0CnwrHFzSL8OcAXI1YudMCHXLkB98P78JSBcCTmV4zhJIcgpGcgiKkrIdI4PXi5NUtJsxZ8S5bYbNE8XkWGQocfgDqwvzFGuU64adxxW6yNMNPg0Ug7TX6GOZatmGenLPL9YyyRxsIpUhPN2nDBYc4jCpAtMKYE/mCZLIvXdXyUnUgRD7D5KiXTN5Ka0QClmNQcmbiG22lMYb63i9fCJtcXeIK8FW0XiCbN1dv9ZSeMUgeXQzQWNQSRb5R8+GpWTpaTO4vHv+MEne9fW3p7ud33jhfwo/Cap5CdFyLU9r5kvk1sBx6XdOjDHuN84rK1nvaVaxqm9EdSEeck64rXw==");
secssUtil.verify(sendMap);
System.out.println(secssUtil.getErrCode());
System.out.println(secssUtil.getErrCode());
System.out.println(secssUtil.getEncValue());
}
/**
* 日期相加减
*
* @param time 时间字符串 yyyy-MM-dd HH:mm:ss
* @param num 加的数,-num就是减去
* @return 减去相应的数量的年的日期
*/
public static String yearAddNum(Date time, Integer num) {
//SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//Date date = format.parse(time);
Calendar calendar = Calendar.getInstance();
calendar.setTime(time);
calendar.add(Calendar.YEAR, num);
Date newTime = calendar.getTime();
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
String dateString = formatter.format(newTime);
return dateString;
}
/**
* 字符串补位.
*
* @param val 字符串 .
* @param type r右补位l左补位 .
* @param size 补足长度 .
* @param delim 补位用字符串 .
* @return String .
*/
public static String pad(String val, String type, int size, String delim) {
if (isEmpty(val)) return val;
if ("r".equals(type)) {
if (val.length() >= size) {
return val.substring(0, size);
} else {
return val + repeat('r', delim, size - val.length());
}
} else {
if (val.length() >= size) {
return val.substring(val.length() - size);
} else {
return repeat('l', delim, size - val.length()) + val;
}
}
}
/**
* 重复字符串 .
*
* @param type r右补位l左补位 .
* @param val 字符串 .
* @param len 长度 .
* @return .
*/
public static String repeat(char type, String val, int len) {
if (isEmpty(val)) return val;
StringBuffer tBuffer = new StringBuffer();
while (tBuffer.length() < len) {
tBuffer.append(val);
}
if ('r' == type) {
return tBuffer.substring(0, len);
} else {
return tBuffer.substring(tBuffer.length() - len);
}
}
/**
* 解析map到str .
*
* @param dataMap map
* @return 字符串
*/
public static String paserMaptoStr(Map<String, Object> dataMap) {
StringBuffer sb = new StringBuffer();
for (Map.Entry<String, Object> entry : dataMap.entrySet()) {
sb.append("&").append(entry.getKey()).append("=").append(entry.getValue());
}
if (sb.length() > 0) {
sb.deleteCharAt(0);
}
return sb.toString();
}
/**
* 解析响应字符串 .
*
* @param httpResonse http响应
* @return 字符串
* @throws IOException .
*/
public static String parseResponseToStr(HttpResponse httpResonse) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(httpResonse.getEntity().getContent(), "utf-8"));
StringBuffer sb = new StringBuffer();
String str = null;
while ((str = br.readLine()) != null) {
sb.append(str);
}
return sb.toString();
}
/**
* 将字符串转成map.
*
* @param respStr 字符串
* @return map
*/
public static Map<String, String> paserStrToMap(String respStr) {
Map<String, String> data = new HashMap<String, String>();
if (isNotEmpty(respStr)) {
String[] strs = respStr.split("&");
for (String str : strs) {
if (isEmpty(str)) {
continue;
}
int index = str.indexOf("=");
// if (entryStrs.length > 1) {
// data.put(entryStrs[0], entryStrs[1]);
// }
data.put(str.substring(0, index), str.substring(index + 1));
}
}
return data;
}
/**
* 拼接在某属性的 set方法
*
* @param fieldName
* @return String
*/
public static String parSetName(String fieldName) {
if (null == fieldName || "".equals(fieldName)) {
return null;
}
int startIndex = 0;
if (fieldName.charAt(0) == '_')
startIndex = 1;
return "set"
+ fieldName.substring(startIndex, startIndex + 1).toUpperCase()
+ fieldName.substring(startIndex + 1);
}
/**
* 判断是否存在某属性的 set方法
*
* @param methods
* @param fieldSetMet
* @return boolean
*/
public static boolean checkSetMet(Method[] methods, String fieldSetMet) {
for (Method met : methods) {
if (fieldSetMet.equals(met.getName())) {
return true;
}
}
return false;
}
//驼峰型转下划线
public static String camel2Underline(String line) {
if (line == null || "".equals(line)) {
return "";
}
line = String.valueOf(line.charAt(0)).toUpperCase().concat(line.substring(1));
StringBuffer sb = new StringBuffer();
Pattern pattern = Pattern.compile("[A-Z]([a-z\\d]+)?");
Matcher matcher = pattern.matcher(line);
while (matcher.find()) {
String word = matcher.group();
sb.append(word.toUpperCase());
sb.append(matcher.end() == line.length() ? "" : "_");
}
return sb.toString();
}
/**
* 格式化string为Date
*
* @param datestr
* @return date
*/
public static Date parseDate(String datestr) {
if (null == datestr || "".equals(datestr)) {
return null;
}
try {
String fmtstr = null;
if (datestr.indexOf(':') > 0) {
fmtstr = "yyyy-MM-dd HH:mm:ss";
} else {
fmtstr = "yyyy-MM-dd";
}
SimpleDateFormat sdf = new SimpleDateFormat(fmtstr, Locale.UK);
return sdf.parse(datestr);
} catch (Exception e) {
//如果全是数字则为天数,通过天数转化日期
Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$");
if (pattern.matcher(datestr).matches()) {
Calendar c = new GregorianCalendar(1900, 0, -1);
Date d = c.getTime();
Date _d = DateUtils.addDays(d, Integer.parseInt(datestr)); //42605是距离1900年1月1日的天数
return _d;
} else {
return null;
}
}
}
/**
* set属性的值到Bean,数值不做小数处理
*
* @param bean
* @param valMap
*/
public static void setFieldValue4Bean(Object bean, Map<String, String> valMap) {
Class<?> cls = bean.getClass();
for (; cls.getSuperclass() != null; cls = cls.getSuperclass()) {
if (cls == BaseDTO.class) {
break;
}
for (Field field : cls.getDeclaredFields()) {
try {
String fieldSetName = parSetName(field.getName());
if (!checkSetMet(cls.getDeclaredMethods(), fieldSetName)) {
continue;
}
Method fieldSetMet = cls.getMethod(fieldSetName, field.getType());
String fieldKeyName = field.getName().substring(0, 1).toUpperCase() + field.getName().substring(1);
//不是统一用驼峰发命名的,因此在这里做格式化
if (Objects.nonNull(valMap.get(fieldKeyName))) {
String value = String.valueOf(valMap.get(fieldKeyName));
if (null != value && !"".equals(value)) {
String fieldType = field.getType().getSimpleName();
if ("String".equals(fieldType)) {
fieldSetMet.invoke(bean, value);
} else if ("Date".equals(fieldType)) {
Date temp = parseDate(value);
fieldSetMet.invoke(bean, temp);
} else if ("Integer".equals(fieldType)
|| "int".equals(fieldType)) {
Integer intval = Integer.parseInt(value);
fieldSetMet.invoke(bean, intval);
} else if ("Long".equalsIgnoreCase(fieldType)) {
Long temp = Long.parseLong(value);
fieldSetMet.invoke(bean, temp);
} else if ("Double".equalsIgnoreCase(fieldType)) {
Double temp = Double.parseDouble(value);
fieldSetMet.invoke(bean, temp);
} else if ("BigDecimal".equalsIgnoreCase(fieldType)) {
BigDecimal bigDecimal = new BigDecimal(value);
fieldSetMet.invoke(bean, bigDecimal);
} else if ("Boolean".equalsIgnoreCase(fieldType)) {
Boolean temp = Boolean.parseBoolean(value);
fieldSetMet.invoke(bean, temp);
} else {
System.out.println("not supper type" + fieldType);
}
}
}
} catch (Exception e) {
e.printStackTrace();
break;
}
}
}
}
}
...@@ -64,4 +64,11 @@ public class SignHclcListenController extends BaseController { ...@@ -64,4 +64,11 @@ public class SignHclcListenController extends BaseController {
responseData.put("name","黎双意"); responseData.put("name","黎双意");
return responseData; return responseData;
} }
@ResponseBody
@RequestMapping(value = "/api/public/china/send/sign/listen", method = RequestMethod.POST)
public JSONObject chinaSignListen(HttpServletRequest request) {
JSONObject responseData = new JSONObject();
return responseData;
}
} }
...@@ -80,6 +80,8 @@ public class SignInfoHclcServiceImpl extends BaseServiceImpl<SignUserInfoHclc> i ...@@ -80,6 +80,8 @@ public class SignInfoHclcServiceImpl extends BaseServiceImpl<SignUserInfoHclc> i
private String listenSignUrl; private String listenSignUrl;
@Value("${tsign.api.signRedirectUrl}") @Value("${tsign.api.signRedirectUrl}")
private String signRedirectUrl; private String signRedirectUrl;
@Value("${tsign.face.api.url}")
private String faceApiUrl;
private CloseableHttpClient httpClient; private CloseableHttpClient httpClient;
...@@ -546,16 +548,18 @@ public class SignInfoHclcServiceImpl extends BaseServiceImpl<SignUserInfoHclc> i ...@@ -546,16 +548,18 @@ public class SignInfoHclcServiceImpl extends BaseServiceImpl<SignUserInfoHclc> i
result.put("img", img); result.put("img", img);
JSONObject json = new JSONObject(result); JSONObject json = new JSONObject(result);
SignHclcUtils signHclcUtils = new SignHclcUtils(); SignHclcUtils signHclcUtils = new SignHclcUtils();
String tokenApiUrl = "https://smlopenapi.esign.cn/v1/oauth2/access_token"; //获取鉴权Token
this.logger.info("token url: {}", tokenApiUrl); //初始化接口密钥参数信息
String token = signHclcUtils.getFaceApiToken(tokenApiUrl, "7438830952", "07e5a0e1bf7ff6891058c1f52b8e141b"); String tokenApiUrl = getApiUrl(indivSysName, tokenApiName);
logger.info("token url: {}", tokenApiUrl);
String token = signHclcUtils.getFaceApiToken(tokenApiUrl, appId, secret);
Map<String, String> headInfo = new HashMap(); Map<String, String> headInfo = new HashMap();
headInfo.put("X-Tsign-Open-App-Id", "7438830952"); headInfo.put("X-Tsign-Open-App-Id", appId);
headInfo.put("X-Tsign-Open-Token", token); headInfo.put("X-Tsign-Open-Token", token);
JSONObject jsonResult = null; JSONObject jsonResult = null;
try { try {
String url = "https://smlopenapi.esign.cn/v2/identity/auth/api/ocr/idcard"; String url = faceApiUrl + "/v2/identity/auth/api/ocr/idcard";
this.logger.info("get ocr result url: {}", url); this.logger.info("get ocr result url: {}", url);
SignHclcUtils signHclcUtils1 = new SignHclcUtils(); SignHclcUtils signHclcUtils1 = new SignHclcUtils();
String stringResult = signHclcUtils1.postString(url, json, headInfo, "application/json"); String stringResult = signHclcUtils1.postString(url, json, headInfo, "application/json");
...@@ -584,6 +588,51 @@ public class SignInfoHclcServiceImpl extends BaseServiceImpl<SignUserInfoHclc> i ...@@ -584,6 +588,51 @@ public class SignInfoHclcServiceImpl extends BaseServiceImpl<SignUserInfoHclc> i
return resultjson; return resultjson;
} }
/***
* E签宝银行卡OCR;
* @param iRequest
* @param img 银行卡
***/
public JSONObject bankcard(IRequest iRequest, String img) {
JSONObject resultjson = new JSONObject();
JSONObject result = new JSONObject();
result.put("img", img);
JSONObject json = new JSONObject(result);
SignHclcUtils signHclcUtils = new SignHclcUtils();
String tokenApiUrl = getApiUrl(indivSysName, tokenApiName);
logger.info("token url: {}", tokenApiUrl);
String token = signHclcUtils.getFaceApiToken(tokenApiUrl, appId, secret);
Map<String, String> headInfo = new HashMap();
headInfo.put("X-Tsign-Open-App-Id", appId);
headInfo.put("X-Tsign-Open-Token", token);
JSONObject jsonResult = null;
try {
String url = faceApiUrl + "/v2/identity/auth/api/ocr/bankcard";
this.logger.info("get ocr result url: {}", url);
SignHclcUtils signHclcUtils1 = new SignHclcUtils();
String stringResult = signHclcUtils1.postString(url, json, headInfo, "application/json");
jsonResult = JSONObject.parseObject(stringResult);
if ("0".equalsIgnoreCase(jsonResult.getString("code"))) {
JSONObject data = jsonResult.getJSONObject("data");
resultjson.put("银行卡号", data.getString("bankCardNo"));
resultjson.put("银行名称", data.getString("bankName"));
resultjson.put("code", "0");
resultjson.put("message", "e签宝银行卡OCR成功!");
} else {
this.logger.info("get ocr result failed, code:{} ,message:{}", jsonResult.getString("code"), jsonResult.getString("message"));
resultjson.put("code", jsonResult.getString("code"));
resultjson.put("message", "e签宝银行卡OCR失败," + jsonResult.getString("message"));
}
} catch (Exception var15) {
this.logger.info("get ocr result failed, msg:{}", var15.getMessage());
resultjson.put("code", "000006");
resultjson.put("message", "e签宝银行卡OCR失败," + var15.getMessage());
}
return resultjson;
}
/*** /***
* E签宝营业执照OCR; * E签宝营业执照OCR;
* @param iRequest * @param iRequest
...@@ -601,17 +650,17 @@ public class SignInfoHclcServiceImpl extends BaseServiceImpl<SignUserInfoHclc> i ...@@ -601,17 +650,17 @@ public class SignInfoHclcServiceImpl extends BaseServiceImpl<SignUserInfoHclc> i
SignHclcUtils signHclcUtils = new SignHclcUtils(); SignHclcUtils signHclcUtils = new SignHclcUtils();
//获取鉴权Token //获取鉴权Token
// String tokenApiUrl = getApiUrl(indivSysName, tokenApiName); String tokenApiUrl = getApiUrl(indivSysName, tokenApiName);
String tokenApiUrl = "https://smlopenapi.esign.cn/v1/oauth2/access_token"; // String tokenApiUrl = "https://open.esign.cn/v1/oauth2/access_token";
logger.info("token url: {}", tokenApiUrl); logger.info("token url: {}", tokenApiUrl);
String token = signHclcUtils.getFaceApiToken(tokenApiUrl, "7438830952", "07e5a0e1bf7ff6891058c1f52b8e141b"); // String token = signHclcUtils.getFaceApiToken(tokenApiUrl, "7438830952", "07e5a0e1bf7ff6891058c1f52b8e141b");
//初始化接口密钥参数信息 //初始化接口密钥参数信息
// String token = signHclcUtils.getFaceApiToken(tokenApiUrl, appId, secret); String token = signHclcUtils.getFaceApiToken(tokenApiUrl, appId, secret);
//设置http请求head信息 //设置http请求head信息
Map<String, String> headInfo = new HashMap<String, String>(); Map<String, String> headInfo = new HashMap<String, String>();
// headInfo.put("X-Tsign-Open-App-Id", appId); headInfo.put("X-Tsign-Open-App-Id", appId);
headInfo.put("X-Tsign-Open-App-Id", "7438830952"); // headInfo.put("X-Tsign-Open-App-Id", "7438830952");
headInfo.put("X-Tsign-Open-Token", token); headInfo.put("X-Tsign-Open-Token", token);
JSONObject jsonResult = null; JSONObject jsonResult = null;
...@@ -619,7 +668,7 @@ public class SignInfoHclcServiceImpl extends BaseServiceImpl<SignUserInfoHclc> i ...@@ -619,7 +668,7 @@ public class SignInfoHclcServiceImpl extends BaseServiceImpl<SignUserInfoHclc> i
//初始化接口信息 //初始化接口信息
// String url = getApiUrl(indivSysName , getLicenseApiName); // String url = getApiUrl(indivSysName , getLicenseApiName);
String url = "https://smlopenapi.esign.cn/v2/identity/auth/api/ocr/license"; String url = faceApiUrl + "/v2/identity/auth/api/ocr/license";
logger.info("get ocr result url: {}", url); logger.info("get ocr result url: {}", url);
//发送http请求 //发送http请求
...@@ -703,9 +752,13 @@ public class SignInfoHclcServiceImpl extends BaseServiceImpl<SignUserInfoHclc> i ...@@ -703,9 +752,13 @@ public class SignInfoHclcServiceImpl extends BaseServiceImpl<SignUserInfoHclc> i
SignHclcUtils signHclcUtils = new SignHclcUtils(); SignHclcUtils signHclcUtils = new SignHclcUtils();
String img; String img;
if ("app_file_id_card".equalsIgnoreCase(attachmentInfo.getSourceType())) { if ("app_file_id_card".equalsIgnoreCase(attachmentInfo.getSourceType())) {
// json = signHclcUtils.idcard(bytes); json = signHclcUtils.idcard(bytes);
img = Base64.encodeBase64String(bytes); // img = Base64.encodeBase64String(bytes);
json = this.idcard(iRequest, img); // json = this.idcard(iRequest, img);
} else if ("app_file_id_bank".equalsIgnoreCase(attachmentInfo.getSourceType())) {
json = signHclcUtils.bankcard(bytes);
// img = Base64.encodeBase64String(bytes);
// json = this.bankcard(iRequest, img);
} else { } else {
//营业执照 //营业执照
// json = signHclcUtils.businessLicense(bytes); // json = signHclcUtils.businessLicense(bytes);
......
...@@ -363,6 +363,29 @@ public class SignHclcUtils { ...@@ -363,6 +363,29 @@ public class SignHclcUtils {
return jsonObject; return jsonObject;
} }
/***
* orc银行卡识别;
* @param image
*/
public JSONObject bankcard(byte[] image) {
// 传入可选参数调用接口
AipOcr client = new AipOcr(APP_ID, API_KEY, SECRET_KEY);
HashMap<String, String> options = new HashMap<String, String>();
// 参数为本地图片路径
org.json.JSONObject res = client.bankcard(image, options);
JSONObject jsonObject = new JSONObject();
if (Objects.nonNull(res.get("result"))) {
jsonObject.put("bank_card_number",res.getJSONObject("result").getString("bank_card_number").replace(" ",""));
jsonObject.put("bank_name",res.getJSONObject("result").getString("bank_name"));
jsonObject.put("bank_card_type",res.getJSONObject("result").getLong("bank_card_type"));
}
logger.info("OCR身份证识别成功, result ={}", jsonObject.toString());
return jsonObject;
}
/*** /***
* 营业执照识别; * 营业执照识别;
* @param image * @param image
......
...@@ -139,3 +139,9 @@ face.check.enable=false ...@@ -139,3 +139,9 @@ face.check.enable=false
#金格电子合同配置文件地址 #金格电子合同配置文件地址
electronic.signature.path=/Volumes/work/idea/APIconfig electronic.signature.path=/Volumes/work/idea/APIconfig
#银联代扣
cup.mer.id=000092112092486
cup.upload.file.path=D:\\HCLC_FTP\\CUP_OUT\\
cup.download.file.path=D:\\HCLC_FTP\\CUP_IN\\
cup.init.file.path=F:\\work\\workspace\\IdeaProjects\\hls-support-rlwx\\key\\
\ No newline at end of file
...@@ -46,6 +46,24 @@ ...@@ -46,6 +46,24 @@
<destination>elk-hap:4560</destination> <destination>elk-hap:4560</destination>
</appender> --> </appender> -->
<appender name="CUP-FILE" class="ch.qos.logback.classic.sift.SiftingAppender">
<discriminator>
<key>logName</key>
<defaultValue>default</defaultValue>
</discriminator>
<sift>
<appender name="REQ-${logName}" class="ch.qos.logback.core.rolling.RollingFileAppender">
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%X{userId}] [%X{requestId}] %logger - %msg%n</pattern>
</encoder>
<file>${catalina.base}/logs/hls-cup-${logName}.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${catalina.base}/logs/%d{yyyy-MM-dd}/hls-cup-${logName}.log</fileNamePattern>
</rollingPolicy>
</appender>
</sift>
</appender>
<root level="ERROR"> <root level="ERROR">
<appender-ref ref="STDOUT"/> <appender-ref ref="STDOUT"/>
...@@ -95,4 +113,10 @@ ...@@ -95,4 +113,10 @@
<appender-ref ref="STDOUT"/> <appender-ref ref="STDOUT"/>
</logger> </logger>
<logger name="com.hand.app.zhongDengWang.mapper" level="DEBUG"/> <logger name="com.hand.app.zhongDengWang.mapper" level="DEBUG"/>
<logger name="com.chinapay.service.impl.HclcChinaPayServiceImpl" level="INFO" additivity="false">
<appender-ref ref="CUP-FILE"/>
</logger>
<logger name="com.chinapay.util.HttpUtils" level="INFO" additivity="false">
<appender-ref ref="CUP-FILE"/>
</logger>
</configuration> </configuration>
\ No newline at end of file
...@@ -145,3 +145,9 @@ zdw.login.clientKey=04593D186F5AB68871891C235A35ED90E6D5E8DC33414C89E05C29EBF5D1 ...@@ -145,3 +145,9 @@ zdw.login.clientKey=04593D186F5AB68871891C235A35ED90E6D5E8DC33414C89E05C29EBF5D1
zdw.login.userName=hclczhongdengwang1 zdw.login.userName=hclczhongdengwang1
zdw.login.password=zhongdengwang12345 zdw.login.password=zhongdengwang12345
zdw.login.authCode=7b7-f08f197fe2e5 zdw.login.authCode=7b7-f08f197fe2e5
#银联代扣
cup.mer.id=000092112092486
cup.upload.file.path=D:\\HCLC_FTP\\CUP_OUT\\
cup.download.file.path=D:\\HCLC_FTP\\CUP_IN\\
cup.init.file.path=F:\\work\\workspace\\IdeaProjects\\hls-support-rlwx\\key\\
\ No newline at end of file
...@@ -139,3 +139,15 @@ face.check.enable=false ...@@ -139,3 +139,15 @@ face.check.enable=false
#金格电子合同配置文件地址 #金格电子合同配置文件地址
electronic.signature.path=/Volumes/work/idea/APIconfig electronic.signature.path=/Volumes/work/idea/APIconfig
#中登网
zdw.login.clientKey=04593D186F5AB68871891C235A35ED90E6D5E8DC33414C89E05C29EBF5D19C3919F0D1956568619BA138AC724F4E5DC730266C8186F610D8CC85BFC0748F899695
zdw.login.userName=hclc-hand
zdw.login.password=Pass20211221
zdw.login.authCode=bf4-7be3edba9a9b
#银联代扣
cup.mer.id=000092112092486
cup.upload.file.path=D:\\HCLC_FTP\\CUP_OUT\\
cup.download.file.path=D:\\HCLC_FTP\\CUP_IN\\
cup.init.file.path=F:\\work\\workspace\\IdeaProjects\\hls-support-rlwx\\key\\
\ No newline at end of file
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Built-By: qixiangyu
Created-By: Apache Maven 3.5.0
Build-Jdk: 1.8.0_131
#Generated by Apache Maven
#Fri Nov 17 15:00:12 CST 2017
version=3.3.1-RELEASE
groupId=com.hand
artifactId=hap
<?xml version="1.0" encoding="UTF-8"?>
<!--suppress MavenModelInspection -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>hap-parent</artifactId>
<groupId>com.hand</groupId>
<version>3.3.1-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>hap</artifactId>
<packaging>war</packaging>
<version>3.3.1-RELEASE</version>
<name>hap</name>
<url>http://maven.apache.org</url>
<properties>
<skipLiquibaseRun>true</skipLiquibaseRun>
</properties>
<repositories>
<repository>
<id>jsqlparser-snapshots</id>
<snapshots>
<enabled>true</enabled>
</snapshots>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
</repositories>
<profiles>
<profile>
<!-- 本地开发环境 -->
<id>dev</id>
<properties>
<profiles.active>dev</profiles.active>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<!-- 客户测试环境 -->
<id>sit</id>
<properties>
<profiles.active>sit</profiles.active>
</properties>
</profile>
<profile>
<!-- 客户UAT环境 -->
<id>uat</id>
<properties>
<profiles.active>uat</profiles.active>
</properties>
</profile>
<profile>
<!-- 生产环境 -->
<id>pro</id>
<properties>
<profiles.active>pro</profiles.active>
</properties>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>com.bstek.ureport</groupId>
<artifactId>ureport2-console</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>2.3.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>xalan</groupId>
<artifactId>xalan</artifactId>
<version>${xalan.version}</version>
</dependency>
<!-- <dependency>
<groupId>com.github.jsqlparser</groupId>
<artifactId>jsqlparser</artifactId>
<version>0.9.6</version>
</dependency> -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<!--<scope>test</scope>-->
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<version>2.2.0</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.hand</groupId>
<artifactId>hap-db</artifactId>
<version>3.3.1-RELEASE</version>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>${jedis.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>${spring.redis.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session</artifactId>
<version>1.2.2.RELEASE</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>${spring.security.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>${spring.security.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-cas</artifactId>
<version>${spring.security.version}</version>
<exclusions>
<exclusion>
<artifactId>log4j-over-slf4j</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
<version>2.0.7.RELEASE</version>
<exclusions>
<exclusion>
<artifactId>spring-security-core</artifactId>
<groupId>org.springframework.security</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-ldap</artifactId>
<version>${spring.security.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-jwt</artifactId>
<version>1.0.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>${freemarker.version}</version>
</dependency>
<!--工作流相关-->
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-engine</artifactId>
<version>${activiti.version}</version>
<exclusions>
<exclusion>
<artifactId>spring-core</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>spring-beans</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>jcl-over-slf4j</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring</artifactId>
<version>${activiti.version}</version>
<exclusions>
<exclusion>
<artifactId>spring-core</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>spring-beans</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>spring-tx</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>spring-orm</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>jcl-over-slf4j</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-bpmn-converter</artifactId>
<version>${activiti.version}</version>
<exclusions>
<exclusion>
<artifactId>jcl-over-slf4j</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-json-converter</artifactId>
<version>${activiti.version}</version>
<exclusions>
<exclusion>
<artifactId>jcl-over-slf4j</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-rest</artifactId>
<version>${activiti.version}</version>
<exclusions>
<exclusion>
<artifactId>spring-core</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>spring-security</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>spring-security-core</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>spring-web</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>spring-cas</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>spring-beans</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>spring-tx</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>spring-orm</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>jcl-over-slf4j</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
<exclusion>
<artifactId>spring-security-config</artifactId>
<groupId>org.springframework.security</groupId>
</exclusion>
<exclusion>
<artifactId>spring-security-core</artifactId>
<groupId>org.springframework.security</groupId>
</exclusion>
<exclusion>
<artifactId>slf4j-log4j12</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>batik-codec</artifactId>
<version>1.7</version>
</dependency>
<dependency>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>batik-transcoder</artifactId>
<version>1.7</version>
<exclusions>
<exclusion>
<artifactId>xercesImpl</artifactId>
<groupId>xerces</groupId>
</exclusion>
<exclusion>
<artifactId>xml-apis</artifactId>
<groupId>xml-apis</groupId>
</exclusion>
<exclusion>
<artifactId>xalan</artifactId>
<groupId>xalan</groupId>
</exclusion>
<exclusion>
<artifactId>fop</artifactId>
<groupId>fop</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>xmlgraphics-commons</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>${drools.version}</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
<version>${drools.version}</version>
</dependency>
<!--end-->
<!--cxf-->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-security</artifactId>
<version>${cxf.version}</version>
</dependency>
<!--end-->
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>4.7</version>
</dependency>
<!-- begin metrics -->
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-core</artifactId>
<version>${metrics.version}</version>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-healthchecks</artifactId>
<version>${metrics.version}</version>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-annotation</artifactId>
<version>${metrics.version}</version>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-jvm</artifactId>
<version>${metrics.version}</version>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-servlet</artifactId>
<version>${metrics.version}</version>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-servlets</artifactId>
<version>${metrics.version}</version>
<exclusions>
<exclusion>
<artifactId>metrics-healthchecks</artifactId>
<groupId>io.dropwizard.metrics</groupId>
</exclusion>
</exclusions>
</dependency>
<!--<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-ganglia</artifactId>
<version>${metrics.version}</version>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-graphite</artifactId>
<version>${metrics.version}</version>
</dependency> -->
<dependency>
<groupId>com.ryantenney.metrics</groupId>
<artifactId>metrics-spring</artifactId>
<version>3.1.3</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- end metrics -->
<!--add by xiangyuQi-->
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk15</classifier>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
</dependency>
<!--end -->
<!-- excel -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>${poi.version}</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>${poi.version}</version>
</dependency>
<!-- end excel -->
<!--kaptcha -->
<dependency>
<groupId>com.github.penggle</groupId>
<artifactId>kaptcha</artifactId>
<version>2.3.2</version>
</dependency>
<!-- -->
<!--redisson -->
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson</artifactId>
<version>3.2.2</version>
</dependency>
<!--end redisson -->
<!-- quartz -->
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>${quartz.version}</version>
</dependency>
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz-jobs</artifactId>
<version>${quartz.version}</version>
</dependency>
<!--rabbitmq-->
<dependency>
<groupId>org.springframework.amqp</groupId>
<artifactId>spring-rabbit</artifactId>
<version>${spring.rabbit.version}</version>
</dependency>
<!-- Wsdl4j-->
<dependency>
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
<version>1.6.2</version>
</dependency>
<!-- end Wsdl4j -->
</dependencies>
<build>
<finalName>hap</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>src/main/java</directory>
<filtering>true</filtering>
<includes>
<include>**/*.groovy</include>
<include>**/*.xml</include>
</includes>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/resources</directory>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<attachClasses>true</attachClasses>
<webResources>
<resource>
<directory>src/main/resources/profiles/${profiles.active}</directory>
<targetPath>WEB-INF/classes</targetPath>
</resource>
<resource>
<directory>src/main/resources</directory>
<targetPath>WEB-INF/classes</targetPath>
</resource>
<resource>
<directory>src/main/webapp/resources</directory>
<targetPath>resources</targetPath>
</resource>
<resource>
<directory>src/main/webapp/WEB-INF</directory>
<targetPath>WEB-INF</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>3.4.2</version>
<configuration>
<skip>${skipLiquibaseRun}</skip>
</configuration>
<dependencies>
<!-- http://mvnrepository.com/artifact/com.oracle/ojdbc14 -->
<!-- Oracle JDBC 驱动 -->
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc7</artifactId>
<version>12.1.0.1.0</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.34</version>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-groovy-dsl</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>com.hand</groupId>
<artifactId>hap-db</artifactId>
<type>jar</type>
<version>3.3.1-RELEASE</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-xml</artifactId>
<version>2.4.6</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>clearCheckSums</id>
<phase>process-resources</phase>
<configuration>
<driver>${db.driver}</driver>
<url>${db.url}</url>
<username>${db.user}</username>
<password>${db.password}</password>
<promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
</configuration>
<goals>
<goal>clearCheckSums</goal>
</goals>
</execution>
<execution>
<id>update</id>
<phase>process-resources</phase>
<configuration>
<changeLogFile>com/hand/hap/db/liquibase.groovy</changeLogFile>
<driver>${db.driver}</driver>
<url>${db.url}</url>
<username>${db.user}</username>
<password>${db.password}</password>
<promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
</configuration>
<goals>
<goal>update</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<!-- if including source jars, use the no-fork goals
otherwise both the Groovy sources and Java stub sources
will get included in your jar -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<!-- source plugin \> = 2.1 is required to use the no-fork goals -->
<version>2.4</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
<goal>test-jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment