时间戳格式化入库

This commit is contained in:
daichao 2025-06-26 18:35:34 +08:00
parent 925b4b4d6a
commit b9f68281b7
1 changed files with 6 additions and 5 deletions

View File

@ -5,18 +5,19 @@ import com.alihealth.d2d.provtest.domain.ReceiveDataLog;
import com.alihealth.d2d.provtest.enums.BuzStatusEnum;
import com.alihealth.d2d.provtest.enums.EventTypeEnum;
import com.alihealth.d2d.provtest.enums.SubTypeEnum;
import com.alihealth.d2d.provtest.service.*;
import com.alihealth.d2d.provtest.service.IReceiveDataLogService;
import com.alihealth.d2d.provtest.service.impl.EventProcessingServiceImpl;
import com.alihealth.d2d.provtest.utils.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
/**
@ -44,7 +45,7 @@ public class ProvTestServerController {
public @ResponseBody
Map<String, Object> receive(HttpServletRequest request) throws IOException {
//时间格式
SimpleDateFormat formatterDatetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat formatterDatetime = new SimpleDateFormat("YYYYMMddHHmmssSSS");
RequestWrapper requestWrapper = new RequestWrapper(request);
String body = requestWrapper.getBodyString();
@ -91,7 +92,7 @@ public class ProvTestServerController {
log.setSubTypeName(SubTypeEnum.getNameByType(eventPojo.getSubType()));
log.setData(eventPojo.getData());
log.setVer(ver);
log.setEventTime(new Date(Long.parseLong(timeStamp)));
log.setEventTime(formatterDatetime.parse(timeStamp) );
receiveDataLogService.save(log);
//解析并处理数据