时间戳服务BUG修复

This commit is contained in:
zhangqinbin
2021-07-16 15:04:01 +08:00
parent 4f3863f36c
commit 80e7867b24
2 changed files with 18 additions and 12 deletions

View File

@ -11,6 +11,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.binary.Base64;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Service;
import java.io.InputStream;
import java.text.SimpleDateFormat;
@ -18,6 +19,7 @@ import java.util.Date;
import java.util.Properties;
@Slf4j
@Service
public class TimeServiceConstant {
public static TSAClient client;

View File

@ -2,6 +2,7 @@ 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.templatewarehouse.sevice.BizBidTemplateWarehouseService;
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;
@ -11,6 +12,7 @@ import io.swagger.annotations.ApiParam;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
@ -21,6 +23,8 @@ import java.util.Date;
@RequestMapping("/v1/timeService")
public class TimeServiceController {
@Resource
private TimeServiceConstant timeServiceConstant;
/**
* 申请时间戳
* @param data 待申请时间戳的原文
@ -29,8 +33,8 @@ public class TimeServiceController {
@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));
//TimeServiceConstant constant = new TimeServiceConstant();
return BaseResponse.success(timeServiceConstant.signTimeStamp(data));
}
/**
@ -41,8 +45,8 @@ public class TimeServiceController {
@ApiOperation("解析时间戳加密原文")
@PostMapping(value = "/verifyTimeStamp")
public BaseResponse<TtsAgent.TtsParseResult> verifyTimeStamp(@ApiParam(value = "时间戳加密原文", required = true) @RequestBody String timestamp) {
TimeServiceConstant constant = new TimeServiceConstant();
return BaseResponse.success(constant.verifyTimeStamp2(timestamp));
//TimeServiceConstant constant = new TimeServiceConstant();
return BaseResponse.success(timeServiceConstant.verifyTimeStamp2(timestamp));
}
/**
@ -53,8 +57,8 @@ public class TimeServiceController {
@ApiOperation("直接获取时间戳对象(内涵日期)")
@GetMapping(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));
//TimeServiceConstant constant = new TimeServiceConstant();
return BaseResponse.success(timeServiceConstant.getServiceTimeObj(data));
}
/**
* 直接获取获取时间戳
@ -64,8 +68,8 @@ public class TimeServiceController {
@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));
//TimeServiceConstant constant = new TimeServiceConstant();
return BaseResponse.success(timeServiceConstant.getServiceTime(data));
}
/**
* 获取年月日时分秒分割存储对象
@ -75,8 +79,8 @@ public class TimeServiceController {
@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));
//TimeServiceConstant constant = new TimeServiceConstant();
return BaseResponse.success(timeServiceConstant.getServiceSystemTime(data));
}
/**
* 获取开标剩余时间倒数
@ -88,9 +92,9 @@ public class TimeServiceController {
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();
//TimeServiceConstant constant = new TimeServiceConstant();
Date now = constant.getServiceDate("getDescOpenRoomTime");;//当前时间
Date now = timeServiceConstant.getServiceDate("getDescOpenRoomTime");;//当前时间
Date date = df.parse(openTime);//过去
long l = date.getTime()-now.getTime();
long day = l / (24 * 60 * 60 * 1000);