Merge branch 'dev' into 'master'

Dev

See merge request eshop/biz_service_ebtp_extend!22
This commit is contained in:
付庆吉
2021-04-02 09:38:54 +08:00
11 changed files with 528 additions and 50 deletions

Binary file not shown.

20
pom.xml
View File

@ -66,7 +66,18 @@
<artifactId>poi-ooxml-schemas</artifactId> <artifactId>poi-ooxml-schemas</artifactId>
<version>4.1.2</version> <version>4.1.2</version>
</dependency> </dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>jit.vstk</groupId>
<artifactId>jit-vstk</artifactId>
<version>2.0.50</version>
<scope>system</scope>
<systemPath>${basedir}/lib/jit-vstk-jdk15-2.0.50-20150603.060911-1.jar</systemPath>
</dependency>
<dependency> <dependency>
<groupId>org.apache.velocity</groupId> <groupId>org.apache.velocity</groupId>
<artifactId>velocity-tools</artifactId> <artifactId>velocity-tools</artifactId>
@ -108,6 +119,13 @@
<include>**/mapper/*Mapper.xml</include> <include>**/mapper/*Mapper.xml</include>
</includes> </includes>
</resource> </resource>
<resource>
<directory>lib</directory>
<targetPath>BOOT-INF/lib/</targetPath>
<includes>
<include>**/*.jar</include>
</includes>
</resource>
</resources> </resources>
<plugins> <plugins>
<plugin> <plugin>

View File

@ -47,25 +47,25 @@ spec:
mountPath: /log mountPath: /log
ports: ports:
- containerPort: 18018 #[8] 容器需要监听的端口号与配置文件中的server.port参数相同与参数[4]相同 - containerPort: 18018 #[8] 容器需要监听的端口号与配置文件中的server.port参数相同与参数[4]相同
livenessProbe: #livenessProbe:
failureThreshold: 3 # failureThreshold: 3
httpGet: # httpGet:
port: 18018 #[11] pod存活检测端口,修改为该微服务配置文件中server.port的端口号,与参数[5]相同 # port: 18018 #[11] pod存活检测端口,修改为该微服务配置文件中server.port的端口号,与参数[5]相同
path: /actuator/prometheus # path: /actuator/prometheus
scheme: HTTP # scheme: HTTP
initialDelaySeconds: 300 # initialDelaySeconds: 300
periodSeconds: 60 # periodSeconds: 60
successThreshold: 1 # successThreshold: 1
timeoutSeconds: 2 # timeoutSeconds: 2
readinessProbe: #readinessProbe:
failureThreshold: 1 # failureThreshold: 1
httpGet: # httpGet:
port: 18018 #[12] pod就绪检测端口,修改为该微服务配置文件中server.port的端口号,与参数[5]相同 # port: 18018 #[12] pod就绪检测端口,修改为该微服务配置文件中server.port的端口号,与参数[5]相同
path: /actuator/prometheus # path: /actuator/prometheus
scheme: HTTP # scheme: HTTP
periodSeconds: 5 # periodSeconds: 5
successThreshold: 2 # successThreshold: 2
timeoutSeconds: 2 # timeoutSeconds: 2
resources: resources:
requests: requests:
cpu: 1000m cpu: 1000m
@ -75,7 +75,7 @@ spec:
memory: 6Gi memory: 6Gi
env: env:
- name: APP_NAME - name: APP_NAME
value: biz-ebtp-extend value: biz_ebtp_extend
- name: AGENT_LICENCE - name: AGENT_LICENCE
value: 527BFA7B28577578 value: 527BFA7B28577578
- name: APOLLO_CONFIGSERVICE - name: APOLLO_CONFIGSERVICE

View File

@ -1,35 +1,30 @@
package com.chinaunicom.mall.ebtp.extend.templatewarehouse.sevice.impl; package com.chinaunicom.mall.ebtp.extend.templatewarehouse.sevice.impl;
import com.alibaba.fastjson.JSON; import java.io.IOException;
import com.alibaba.fastjson.JSONObject; import java.net.URLEncoder;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import java.util.Map;
import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.convertor.ModelConvertor; import java.util.Optional;
import com.chinaunicom.mall.ebtp.common.util.JsonUtils;
import com.chinaunicom.mall.ebtp.extend.export.enums.ExportExceptionEnum;
import com.chinaunicom.mall.ebtp.extend.feign.client.DocumentCenterService;
import com.chinaunicom.mall.ebtp.extend.templatewarehouse.entity.BizBidClientVersion;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.chinaunicom.mall.ebtp.extend.templatewarehouse.dao.BizBidClientVersionMapper;
import com.chinaunicom.mall.ebtp.extend.templatewarehouse.sevice.BizBidClientVersionService;
import com.chinaunicom.mall.ebtp.common.base.service.impl.BaseServiceImpl;
import sun.nio.cs.ext.GBK;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.ServletOutputStream; import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder; import org.springframework.stereotype.Service;
import java.text.DateFormat;
import java.util.HashMap; import com.alibaba.fastjson.JSON;
import java.util.Map; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import java.util.Optional; import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.convertor.ModelConvertor;
import java.util.zip.ZipEntry; import com.chinaunicom.mall.ebtp.common.base.service.impl.BaseServiceImpl;
import java.util.zip.ZipOutputStream; import com.chinaunicom.mall.ebtp.common.util.JsonUtils;
import com.chinaunicom.mall.ebtp.extend.export.enums.ExportExceptionEnum;
import com.chinaunicom.mall.ebtp.extend.feign.client.DocumentCenterService;
import com.chinaunicom.mall.ebtp.extend.templatewarehouse.dao.BizBidClientVersionMapper;
import com.chinaunicom.mall.ebtp.extend.templatewarehouse.entity.BizBidClientVersion;
import com.chinaunicom.mall.ebtp.extend.templatewarehouse.sevice.BizBidClientVersionService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
/** /**
* 对数据表 biz_bid_client_version 操作的 serviceImpl * 对数据表 biz_bid_client_version 操作的 serviceImpl

View File

@ -0,0 +1,165 @@
package com.chinaunicom.mall.ebtp.extend.timeService;
import cn.com.jit.assp.css.client.util.HelperUtil;
import cn.com.jit.tsa.client.TSAClient;
import cn.com.jit.tsa.client.TSAClientFactory;
import cn.com.jit.tsa.client.TSASignedResult;
import cn.com.jit.tsa.client.TSAVerifyResult;
import com.chinaunicom.mall.ebtp.extend.timeService.tsa.SystemTime;
import com.chinaunicom.mall.ebtp.extend.timeService.tsa.TtsAgent;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.binary.Base64;
import org.springframework.core.io.ClassPathResource;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Properties;
@Slf4j
public class TimeServiceConstant {
public static TSAClient client;
public TimeServiceConstant(){
try{
Properties prop = new Properties();
ClassPathResource classPathResource = new ClassPathResource("cssconfig.properties");
InputStream inputStream =classPathResource.getInputStream();
prop.load(inputStream);
inputStream.close();
// 获得TSAClient工厂实例
TSAClientFactory factory = TSAClientFactory.newInstance(prop);
// 获得TSAClient
client = (TSAClient) factory.getTSAClient();
}catch (Exception e){
log.error("读取配置文件或连接时间戳服务器异常", e);
}
}
/**
* 申请时间戳
* @param data 待申请时间戳的原文
* @return 时间戳加密原文
*/
public String signTimeStamp(String data){
try{
data = data!=null&&!"".equals(data)?data:"system";
//第三步:申请时间戳,向时间戳服务器发起申请时间戳请求,返回时间戳结果
TSASignedResult result = client.signTimeStamp("SHA1", data.getBytes("UTF-8"));
//第四步:获取时间戳数据,tsaData为时间戳数据,验证时间戳时使用,如果不是实时验证,需要将时间戳数据保存在应用服务器
byte[] tsaData = result.getSignedData();
log.info("tsaData -->"+tsaData);
String timestamp = Base64.encodeBase64String(tsaData);
log.info("timestamp -->"+timestamp);
return timestamp;
}catch (Exception e){
log.error("申请时间戳异常", e);
}
return null;
}
/**
* 解析时间戳
* @param timestamp 时间戳加密原文
* @return 时间戳对象
*/
public TSAVerifyResult verifyTimeStamp(String timestamp){
try{
log.info("timestamp -->"+timestamp);
TSAVerifyResult verifyResult = client.verifyTimeStamp(Base64.decodeBase64(timestamp));
return verifyResult;
}catch (Exception e){
log.error("解析时间戳", e);
}
return null;
}
/**
* 获取时间戳
* @param data 待申请时间戳的原文
* @return 时间戳对象
*/
public TtsAgent.TtsParseResult getServiceTimeObj(String data){
try{
String timestamp = this.signTimeStamp(data);
TSAVerifyResult verifyResult = this.verifyTimeStamp(timestamp);
String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(verifyResult.getSignedTime());
TtsAgent.TtsParseResult ttsParseResult = new TtsAgent.TtsParseResult(time, HelperUtil.bytesToHexString(verifyResult.getData()),
verifyResult.getSignerSubject());
return ttsParseResult;
}catch (Exception e){
log.error("获取时间戳异常", e);
}
return null;
}
/**
* 直接获取获取时间戳 时间1
* @param data 待申请时间戳的原文
* @return 时间
*/
public String getServiceTime(String data){
try{
String timestamp = this.signTimeStamp(data);
TSAVerifyResult verifyResult = this.verifyTimeStamp(timestamp);
String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(verifyResult.getSignedTime());
return time;
}catch (Exception e){
log.error("获取时间戳异常", e);
}
return null;
}
/**
* 直接获取获取时间戳 时间1
* @param data 待申请时间戳的原文
* @return date时间
*/
public Date getServiceDate(String data){
try{
String timestamp = this.signTimeStamp(data);
TSAVerifyResult verifyResult = this.verifyTimeStamp(timestamp);
Date date = verifyResult.getSignedTime();
return date;
}catch (Exception e){
log.error("获取时间戳异常", e);
}
return null;
}
/**
* 获取年月日时分秒分割存储对象
* @param data 待申请时间戳的原文
* @return SystemTime
*/
public SystemTime getServiceSystemTime(String data){
try{
String timestamp = this.signTimeStamp(data);
TSAVerifyResult verifyResult = this.verifyTimeStamp(timestamp);
Date date = verifyResult.getSignedTime();
SystemTime systemTime = new SystemTime()
.setYear(date.getYear()+1900)
.setMonth(date.getMonth()+1)
.setDate(date.getDate())
.setHour(date.getHours())
.setMinute(date.getMinutes())
.setSecond(date.getSeconds());
return systemTime;
}catch (Exception e){
log.error("获取时间戳异常", e);
}
return null;
}
public static void main(String arge[]){
Date date = new Date();
System.out.println("-----------"+(date.getYear()+1900));
System.out.println("-----------"+(date.getMonth()+1));
System.out.println("-----------"+date.getDate());
System.out.println("-----------"+date.getHours());
System.out.println("-----------"+date.getMinutes());
System.out.println("-----------"+date.getSeconds());
}
}

View File

@ -0,0 +1,112 @@
package com.chinaunicom.mall.ebtp.extend.timeService.controller;
import cn.com.jit.tsa.client.TSAVerifyResult;
import com.chinaunicom.mall.ebtp.common.base.entity.BaseResponse;
import com.chinaunicom.mall.ebtp.extend.timeService.TimeServiceConstant;
import com.chinaunicom.mall.ebtp.extend.timeService.tsa.SystemTime;
import com.chinaunicom.mall.ebtp.extend.timeService.tsa.TtsAgent;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
@RestController
@Api(tags = "")
@RequestMapping("/v1/timeService")
public class TimeServiceController {
/**
* 申请时间戳
* @param data 待申请时间戳的原文
* @return 时间戳加密原文
*/
@ApiOperation("申请时间戳")
@GetMapping(value = "/signTimeStamp")
public BaseResponse<String> signTimeStamp(@ApiParam(value = "待申请时间戳的原文", required = false) @RequestParam(name = "data",required = false) String data) {
TimeServiceConstant constant = new TimeServiceConstant();
return BaseResponse.success(constant.signTimeStamp(data));
}
/**
* 解析时间戳
* @param timestamp 时间戳加密原文
* @return 时间戳对象
*/
@ApiOperation("解析时间戳加密原文")
@GetMapping(value = "/verifyTimeStamp")
public BaseResponse<TSAVerifyResult> verifyTimeStamp(@ApiParam(value = "时间戳加密原文", required = true) @RequestBody String timestamp) {
TimeServiceConstant constant = new TimeServiceConstant();
return BaseResponse.success(constant.verifyTimeStamp(timestamp));
}
/**
* 获取时间戳
* @param data 待申请时间戳的原文
* @return 时间戳对象
*/
@ApiOperation("直接获取时间戳对象(内涵日期)")
@PostMapping(value = "/getServiceTimeObj")
public BaseResponse<TtsAgent.TtsParseResult> getServiceTimeObj(@ApiParam(value = "待申请时间戳的原文", required = false) @RequestParam(name = "data",required = false) String data) {
TimeServiceConstant constant = new TimeServiceConstant();
return BaseResponse.success(constant.getServiceTimeObj(data));
}
/**
* 直接获取获取时间戳
* @param data 待申请时间戳的原文
* @return 时间戳对象
*/
@ApiOperation("直接获取日期字符串")
@GetMapping(value = "/getServiceTime")
public BaseResponse<String> getServiceTime(@ApiParam(value = "待申请时间戳的原文", required = false) @RequestParam(name = "data",required = false) String data) {
TimeServiceConstant constant = new TimeServiceConstant();
return BaseResponse.success(constant.getServiceTime(data));
}
/**
* 获取年月日时分秒分割存储对象
* @param data 待申请时间戳的原文
* @return SystemTime
*/
@ApiOperation("获取日期对象SystemTime")
@GetMapping(value = "/getServiceSystemTime")
public BaseResponse<SystemTime> getServiceSystemTime(@ApiParam(value = "待申请时间戳的原文", required = false) @RequestParam(name = "data",required = false) String data) {
TimeServiceConstant constant = new TimeServiceConstant();
return BaseResponse.success(constant.getServiceSystemTime(data));
}
/**
* 获取开标剩余时间倒数
* @return
*/
@ApiOperation("获取开标剩余时间倒数")
@GetMapping("/getDescOpenRoomTime")
@PreAuthorize("hasAnyAuthority('ebtp-agency-project-manager','ebtp-purchase','ebtp-supplier')")
public BaseResponse<SystemTime> getDescOpenRoomTime(@RequestParam(name = "openTime",required = true) String openTime){
try {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
TimeServiceConstant constant = new TimeServiceConstant();
Date now = constant.getServiceDate("getDescOpenRoomTime");;//当前时间
Date date = df.parse(openTime);//过去
long l = date.getTime()-now.getTime();
long day = l / (24 * 60 * 60 * 1000);
long hour = (l / (60 * 60 * 1000) - day * 24);
long min = ((l / (60 * 1000)) - day * 24 * 60 - hour * 60);
long s = (l / 1000 - day * 24 * 60 * 60 - hour * 60 * 60 - min * 60);
SystemTime systemTime = new SystemTime()
.setDate((int) day)
.setHour((int) hour)
.setMinute((int)min)
.setSecond((int)s);
return BaseResponse.success(systemTime);
} catch (ParseException e) {
e.printStackTrace();
}
return BaseResponse.success(new SystemTime());
}
}

View File

@ -0,0 +1,48 @@
package com.chinaunicom.mall.ebtp.extend.timeService.tsa;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* 实体类 BizBidOpenroom
*
* @auto.generated
*/
@Data
@Accessors(chain = true)
public class SystemTime {
/**
* 年
*/
private Integer year;
/**
* 月
*/
private Integer month;
/**
* 日
*/
private Integer date;
/**
* 时
*/
private Integer hour;
/**
* 分
*/
private Integer minute;
/**
* 秒
*/
private Integer second;
}

View File

@ -0,0 +1,101 @@
package com.chinaunicom.mall.ebtp.extend.timeService.tsa;
/**
* CA 时间戳服务接口
*
* @工程: EPS(4.0)
*
* @模块:
*
* @作者: 李志慧
*
* @创建日期: 2016年3月17日
*
* @修改记录(修改时间、作者、原因):
*/
public interface TtsAgent {
/**
* 创建hash 的时间戳
*
* @作者: 李志慧 @创建日期: 2016年3月17日
*
* @参数: hash 数据hash值
* @返回值: String
*
* @修改记录(修改时间、作者、原因):
*/
String createTimestamp(String hash);
/**
* 时间戳验证
*
* @作者: 李志慧 @创建日期: 2016年3月17日
*
* @参数: timestamp 时间戳
* @返回值: boolean
*
* @修改记录(修改时间、作者、原因):
*/
boolean verifyTimestamp(String timestamp);
/**
* 解析时间戳
*
* @作者: 李志慧 @创建日期: 2016年3月17日
*
* @参数: timestamp 时间戳
* @返回值: TtsParseResult
*
* @修改记录(修改时间、作者、原因):
*/
TtsParseResult parseTimestamp(String timestamp);
/**
* 时间戳解析结果
*
* @作者: 李志慧
*
*/
public class TtsParseResult {
// 时间
private String timestamp;
// hash 值
private String hash;
// 签名证书
private String cert;
public TtsParseResult(String timestamp, String hash, String cert) {
super();
this.timestamp = timestamp;
this.hash = hash;
this.cert = cert;
}
public String getTimestamp() {
return timestamp;
}
public void setTimestamp(String timestamp) {
this.timestamp = timestamp;
}
public String getHash() {
return hash;
}
public void setHash(String hash) {
this.hash = hash;
}
public String getCert() {
return cert;
}
public void setCert(String cert) {
this.cert = cert;
}
}
}

View File

@ -121,7 +121,6 @@ mybatis-plus:
logic-delete-value: deleted # 逻辑已删除值 logic-delete-value: deleted # 逻辑已删除值
logic-not-delete-value: normal # 逻辑未删除值 logic-not-delete-value: normal # 逻辑未删除值
# --------------feign ------------ # --------------feign ------------
feign: feign:
httpclient: httpclient:
@ -168,9 +167,8 @@ mconfig:
tender: biz-service-ebtp-tender #投标服务 tender: biz-service-ebtp-tender #投标服务
documentcenter: core-service-document-center #文档中心 documentcenter: core-service-document-center #文档中心
document: document:
clientHttpUrl: http://10.242.31.158:8100/auth/oauth/token?grant_type=client_credentials&client_id=bVS46ElU&client_secret=58ea04ba02475c8da2321cc99849d2a10f15b749 clientHttpUrl: http://10.238.25.112:8100/auth/oauth/token?grant_type=client_credentials&client_id=bVS46ElU&client_secret=58ea04ba02475c8da2321cc99849d2a10f15b749
# 用户暴露给 prometheus 的健康数据 # 用户暴露给 prometheus 的健康数据
management: management:

View File

@ -1,3 +1,3 @@
spring: spring:
profiles: profiles:
active: uat active: test

View File

@ -0,0 +1,41 @@
#ServerURL=http://192.168.9.110:8000/signxmlhandler
ServerURL=http://10.249.247.133:8000/signserver/service/xml
#ServerURL=http://192.168.9.110:8000/signserver/service/xml
DigestAlg=SHA1
#Encrypt Algorithm: des3/scb2
EncAlg=des3
CertBaseInfo = version;issuerdn;subjectdn;serialnumber;notbefore;notafter
TSACertBaseInfo = issuerdn;subjectdn;serialnumber;signedTime;signedTSA;signedTimeByMS
CertExtendInfo =
AppID=
CertAlias =
BaseInfo =digestalg;digestdata;plaindata;dscert
SendMsgFormat=0
HashActionPosition=0
PrintLog=false
#console/file/log4j ####log4j not implement
logTarget=console
logFilePath=/temp/jit.dss.vstk.log
#rfc3161/rfc2630
TSAType=rfc3161
#dsCert/issuerDNAndSN
p1VerifyCertId=dsCert
Compatible=true
dss.client.class=cn.com.jit.assp.client.DSSClientHttpUrlConnectionImpl
#dss.client.class=cn.com.jit.assp.client.DSSClientHttpClientImpl
#default/encAfterDec/secretEnvelop(use this mode after using VCTK do envelop) secretEnvelop:develop->RSAdecrypt->RSAencrypt->envelop
envelopType=default
#default unit KB and default size is 0,0 is not block;
packageSize=0
#default:10000 unit: ms
timeout=10000
connectTimeOut=10000
# default : system unicode
FileSystemCharSet=UTF-8
vstkVersion=20
EncryptMode=ecb
#package size every time, unit is byte
send_size=1048576
#bigger than this will take big data modle, unit is byte
bigdata_limit=20971520