diff --git a/src/main/java/com/alihealth/d2d/provtest/controller/ProvTestServerController.java b/src/main/java/com/alihealth/d2d/provtest/controller/ProvTestServerController.java index 0f3caa9..9d4a7ca 100644 --- a/src/main/java/com/alihealth/d2d/provtest/controller/ProvTestServerController.java +++ b/src/main/java/com/alihealth/d2d/provtest/controller/ProvTestServerController.java @@ -15,6 +15,8 @@ import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.Date; import java.util.Map; /** @@ -41,6 +43,9 @@ public class ProvTestServerController { @RequestMapping("/receive") public @ResponseBody Map receive(HttpServletRequest request) throws IOException { + //时间格式 + SimpleDateFormat formatterDatetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + RequestWrapper requestWrapper = new RequestWrapper(request); String body = requestWrapper.getBodyString(); System.out.println(body); @@ -86,6 +91,7 @@ public class ProvTestServerController { log.setSubTypeName(SubTypeEnum.getNameByType(eventPojo.getSubType())); log.setData(eventPojo.getData()); log.setVer(ver); + log.setEventTime(new Date(Long.parseLong(timeStamp))); receiveDataLogService.save(log); //解析并处理数据 diff --git a/src/main/java/com/alihealth/d2d/provtest/controller/ResolveTest.java b/src/main/java/com/alihealth/d2d/provtest/controller/ResolveTest.java index b09d0ba..0553aa7 100644 --- a/src/main/java/com/alihealth/d2d/provtest/controller/ResolveTest.java +++ b/src/main/java/com/alihealth/d2d/provtest/controller/ResolveTest.java @@ -1,8 +1,14 @@ package com.alihealth.d2d.provtest.controller; import com.alihealth.d2d.provtest.common.AjaxResult; +import com.alihealth.d2d.provtest.domain.ReceiveDataLog; import com.alihealth.d2d.provtest.searcher.DrugResolveSearcher; import com.alihealth.d2d.provtest.service.IReceiveDataLogService; +import com.alihealth.d2d.provtest.service.impl.EventProcessingServiceImpl; +import com.alihealth.d2d.provtest.utils.CertManager; +import com.alihealth.d2d.provtest.utils.EventPojo; +import com.alihealth.d2d.provtest.utils.StreamUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -16,6 +22,7 @@ import java.io.IOException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.spec.InvalidKeySpecException; +import java.util.List; @RestController @RequestMapping("/resolve") @@ -24,9 +31,36 @@ public class ResolveTest { @Autowired private IReceiveDataLogService receiveDataLogService; + + @Autowired + private EventProcessingServiceImpl processingService; + + @Autowired + private CertManager certManager; + + @PostMapping(value = "/resolve") public AjaxResult resolve(@RequestBody DrugResolveSearcher searcher) throws NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, InvalidKeySpecException, BadPaddingException, IOException, InvalidKeyException { receiveDataLogService.resolve(searcher); return AjaxResult.success(true); } + + @PostMapping(value = "/resolve2") + public AjaxResult resolve2() throws NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, InvalidKeySpecException, BadPaddingException, IOException, InvalidKeyException { + List list = receiveDataLogService.list(new QueryWrapper() + .lambda().between(ReceiveDataLog::getCreateTime, "2025-06-11 00:00:00", "2025-06-12 00:00:00") + ); + String privateKey = certManager.getPrivateKey(); + for (ReceiveDataLog receiveDataLog : list) { + String eventId = receiveDataLog.getEventId(); + String de = certManager.testDecrypt(privateKey, receiveDataLog.getData()); + String xml = StreamUtil.getUnStreamContent(de); + EventPojo eventPojo = new EventPojo(); + eventPojo.setData(receiveDataLog.getData()); + eventPojo.setSubType(receiveDataLog.getSubType()); + processingService.processEvent(eventPojo, xml, eventId); + } + + return AjaxResult.success(true); + } } diff --git a/src/main/java/com/alihealth/d2d/provtest/domain/ReceiveDataLog.java b/src/main/java/com/alihealth/d2d/provtest/domain/ReceiveDataLog.java index e99a2d7..e88e794 100644 --- a/src/main/java/com/alihealth/d2d/provtest/domain/ReceiveDataLog.java +++ b/src/main/java/com/alihealth/d2d/provtest/domain/ReceiveDataLog.java @@ -51,8 +51,8 @@ public class ReceiveDataLog { private Date createTime; - @TableField( "update_time") - private Date updateTime; + @TableField( "event_time") + private Date eventTime; @TableField( "is_deleted")