时间戳服务BUG修复
This commit is contained in:
@ -11,6 +11,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.apache.commons.codec.binary.Base64;
|
import org.apache.commons.codec.binary.Base64;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.core.io.ClassPathResource;
|
import org.springframework.core.io.ClassPathResource;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
@ -18,6 +19,7 @@ import java.util.Date;
|
|||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@Service
|
||||||
public class TimeServiceConstant {
|
public class TimeServiceConstant {
|
||||||
|
|
||||||
public static TSAClient client;
|
public static TSAClient client;
|
||||||
|
@ -2,6 +2,7 @@ package com.chinaunicom.mall.ebtp.extend.timeService.controller;
|
|||||||
|
|
||||||
import cn.com.jit.tsa.client.TSAVerifyResult;
|
import cn.com.jit.tsa.client.TSAVerifyResult;
|
||||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseResponse;
|
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.TimeServiceConstant;
|
||||||
import com.chinaunicom.mall.ebtp.extend.timeService.tsa.SystemTime;
|
import com.chinaunicom.mall.ebtp.extend.timeService.tsa.SystemTime;
|
||||||
import com.chinaunicom.mall.ebtp.extend.timeService.tsa.TtsAgent;
|
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.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@ -21,6 +23,8 @@ import java.util.Date;
|
|||||||
@RequestMapping("/v1/timeService")
|
@RequestMapping("/v1/timeService")
|
||||||
public class TimeServiceController {
|
public class TimeServiceController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private TimeServiceConstant timeServiceConstant;
|
||||||
/**
|
/**
|
||||||
* 申请时间戳
|
* 申请时间戳
|
||||||
* @param data 待申请时间戳的原文
|
* @param data 待申请时间戳的原文
|
||||||
@ -29,8 +33,8 @@ public class TimeServiceController {
|
|||||||
@ApiOperation("申请时间戳")
|
@ApiOperation("申请时间戳")
|
||||||
@GetMapping(value = "/signTimeStamp")
|
@GetMapping(value = "/signTimeStamp")
|
||||||
public BaseResponse<String> signTimeStamp(@ApiParam(value = "待申请时间戳的原文", required = false) @RequestParam(name = "data",required = false) String data) {
|
public BaseResponse<String> signTimeStamp(@ApiParam(value = "待申请时间戳的原文", required = false) @RequestParam(name = "data",required = false) String data) {
|
||||||
TimeServiceConstant constant = new TimeServiceConstant();
|
//TimeServiceConstant constant = new TimeServiceConstant();
|
||||||
return BaseResponse.success(constant.signTimeStamp(data));
|
return BaseResponse.success(timeServiceConstant.signTimeStamp(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,8 +45,8 @@ public class TimeServiceController {
|
|||||||
@ApiOperation("解析时间戳加密原文")
|
@ApiOperation("解析时间戳加密原文")
|
||||||
@PostMapping(value = "/verifyTimeStamp")
|
@PostMapping(value = "/verifyTimeStamp")
|
||||||
public BaseResponse<TtsAgent.TtsParseResult> verifyTimeStamp(@ApiParam(value = "时间戳加密原文", required = true) @RequestBody String timestamp) {
|
public BaseResponse<TtsAgent.TtsParseResult> verifyTimeStamp(@ApiParam(value = "时间戳加密原文", required = true) @RequestBody String timestamp) {
|
||||||
TimeServiceConstant constant = new TimeServiceConstant();
|
//TimeServiceConstant constant = new TimeServiceConstant();
|
||||||
return BaseResponse.success(constant.verifyTimeStamp2(timestamp));
|
return BaseResponse.success(timeServiceConstant.verifyTimeStamp2(timestamp));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -53,8 +57,8 @@ public class TimeServiceController {
|
|||||||
@ApiOperation("直接获取时间戳对象(内涵日期)")
|
@ApiOperation("直接获取时间戳对象(内涵日期)")
|
||||||
@GetMapping(value = "/getServiceTimeObj")
|
@GetMapping(value = "/getServiceTimeObj")
|
||||||
public BaseResponse<TtsAgent.TtsParseResult> getServiceTimeObj(@ApiParam(value = "待申请时间戳的原文", required = false) @RequestParam(name = "data",required = false) String data) {
|
public BaseResponse<TtsAgent.TtsParseResult> getServiceTimeObj(@ApiParam(value = "待申请时间戳的原文", required = false) @RequestParam(name = "data",required = false) String data) {
|
||||||
TimeServiceConstant constant = new TimeServiceConstant();
|
//TimeServiceConstant constant = new TimeServiceConstant();
|
||||||
return BaseResponse.success(constant.getServiceTimeObj(data));
|
return BaseResponse.success(timeServiceConstant.getServiceTimeObj(data));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 直接获取获取时间戳
|
* 直接获取获取时间戳
|
||||||
@ -64,8 +68,8 @@ public class TimeServiceController {
|
|||||||
@ApiOperation("直接获取日期字符串")
|
@ApiOperation("直接获取日期字符串")
|
||||||
@GetMapping(value = "/getServiceTime")
|
@GetMapping(value = "/getServiceTime")
|
||||||
public BaseResponse<String> getServiceTime(@ApiParam(value = "待申请时间戳的原文", required = false) @RequestParam(name = "data",required = false) String data) {
|
public BaseResponse<String> getServiceTime(@ApiParam(value = "待申请时间戳的原文", required = false) @RequestParam(name = "data",required = false) String data) {
|
||||||
TimeServiceConstant constant = new TimeServiceConstant();
|
//TimeServiceConstant constant = new TimeServiceConstant();
|
||||||
return BaseResponse.success(constant.getServiceTime(data));
|
return BaseResponse.success(timeServiceConstant.getServiceTime(data));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 获取年月日时分秒分割存储对象
|
* 获取年月日时分秒分割存储对象
|
||||||
@ -75,8 +79,8 @@ public class TimeServiceController {
|
|||||||
@ApiOperation("获取日期对象SystemTime")
|
@ApiOperation("获取日期对象SystemTime")
|
||||||
@GetMapping(value = "/getServiceSystemTime")
|
@GetMapping(value = "/getServiceSystemTime")
|
||||||
public BaseResponse<SystemTime> getServiceSystemTime(@ApiParam(value = "待申请时间戳的原文", required = false) @RequestParam(name = "data",required = false) String data) {
|
public BaseResponse<SystemTime> getServiceSystemTime(@ApiParam(value = "待申请时间戳的原文", required = false) @RequestParam(name = "data",required = false) String data) {
|
||||||
TimeServiceConstant constant = new TimeServiceConstant();
|
//TimeServiceConstant constant = new TimeServiceConstant();
|
||||||
return BaseResponse.success(constant.getServiceSystemTime(data));
|
return BaseResponse.success(timeServiceConstant.getServiceSystemTime(data));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 获取开标剩余时间倒数
|
* 获取开标剩余时间倒数
|
||||||
@ -88,9 +92,9 @@ public class TimeServiceController {
|
|||||||
public BaseResponse<SystemTime> getDescOpenRoomTime(@RequestParam(name = "openTime",required = true) String openTime){
|
public BaseResponse<SystemTime> getDescOpenRoomTime(@RequestParam(name = "openTime",required = true) String openTime){
|
||||||
try {
|
try {
|
||||||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
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);//过去
|
Date date = df.parse(openTime);//过去
|
||||||
long l = date.getTime()-now.getTime();
|
long l = date.getTime()-now.getTime();
|
||||||
long day = l / (24 * 60 * 60 * 1000);
|
long day = l / (24 * 60 * 60 * 1000);
|
||||||
|
Reference in New Issue
Block a user