From c09c9b97b2078c4ace1a85feae8631d684d34032 Mon Sep 17 00:00:00 2001 From: anthonyywj2 <353682448@qq.com> Date: Fri, 29 Jul 2022 17:06:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=B8=8B=E8=BD=BD=E6=9C=80?= =?UTF-8?q?=E6=96=B0=E7=89=88=E6=9C=AC=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../device/ProductInfoController.java | 13 +----------- .../device/UdidlDeviceController.java | 21 +++++++++++++++++++ .../service/dataSync/DeviceSyncService.java | 2 ++ .../service/inout/ProductInfoService.java | 2 ++ .../inout/impl/ProductInfoServiceImpl.java | 18 ++++++++++++++++ 5 files changed, 44 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/glxp/udidl/admin/controller/device/ProductInfoController.java b/src/main/java/com/glxp/udidl/admin/controller/device/ProductInfoController.java index 0ebb47e..b20ea14 100644 --- a/src/main/java/com/glxp/udidl/admin/controller/device/ProductInfoController.java +++ b/src/main/java/com/glxp/udidl/admin/controller/device/ProductInfoController.java @@ -307,18 +307,7 @@ public class ProductInfoController { @AuthRuleAnnotation("udidl/device/filterByNameCode") @GetMapping("udidl/device/filterByNameCode") public BaseResponse filterByNameCode(ProductInfoFilterRequest productInfoFilterRequest) { - List productInfoEntityList = productInfoService.findAll(productInfoFilterRequest); - Map> listMap = productInfoEntityList.stream().collect(Collectors.groupingBy(ProductInfoEntity::getUuid)); - List result = null; - for (List value : listMap.values()) { - if (result == null || value.get(0).getVersionNumber() > result.get(0).getVersionNumber()) { - result = value; - } - } - productInfoFilterRequest.setNameCode(null); - productInfoFilterRequest.setUuid(result.get(0).getUuid()); - List datas = productInfoService.findAll(productInfoFilterRequest); - return ResultVOUtils.success(datas); + return ResultVOUtils.success(productInfoService.findLastVersion(productInfoFilterRequest)); } } diff --git a/src/main/java/com/glxp/udidl/admin/controller/device/UdidlDeviceController.java b/src/main/java/com/glxp/udidl/admin/controller/device/UdidlDeviceController.java index 364328f..a0a36e0 100644 --- a/src/main/java/com/glxp/udidl/admin/controller/device/UdidlDeviceController.java +++ b/src/main/java/com/glxp/udidl/admin/controller/device/UdidlDeviceController.java @@ -2,10 +2,12 @@ package com.glxp.udidl.admin.controller.device; import com.glxp.udidl.admin.annotation.AuthRuleAnnotation; import com.glxp.udidl.admin.entity.udid.DeviceEntity; +import com.glxp.udidl.admin.req.ProductInfoFilterRequest; import com.glxp.udidl.admin.req.udid.DeviceRequest; import com.glxp.udidl.admin.res.BaseResponse; import com.glxp.udidl.admin.res.udid.DataSetSingleHistoryResult; import com.glxp.udidl.admin.service.dataSync.DeviceSyncService; +import com.glxp.udidl.admin.service.inout.ProductInfoService; import com.glxp.udidl.admin.util.ResultVOUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -20,6 +22,7 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; +import javax.annotation.Resource; import java.util.Date; @Api(tags = "下载医疗器械信息接口") @@ -30,6 +33,8 @@ public class UdidlDeviceController { @Autowired DeviceSyncService deviceSyncService; + @Resource + ProductInfoService productInfoService; @ApiOperation(value = "按日期段下载医疗器械信息") @ApiImplicitParams({@ApiImplicitParam(name = "startDate", value = "开始时间", required = true, dataType = "Date"), @@ -90,6 +95,20 @@ public class UdidlDeviceController { return deviceSyncService.downloadHistory(key); } + + @ApiOperation(value = "下载最新版本数据", response = DeviceEntity.class) + @ApiImplicitParam(name = "deviceId", value = "医疗器械设备ID", required = true, dataType = "String") + @AuthRuleAnnotation("udidl/device/dlLastVersionByDi") + @GetMapping("udidl/device/dlLastVersionByDi") + public BaseResponse dlLastVersionByDi(String deviceId) { + BaseResponse baseResponse = deviceSyncService.downloadSingle(deviceId); + ProductInfoFilterRequest productInfoFilterRequest = new ProductInfoFilterRequest(); + productInfoFilterRequest.setNameCode(deviceId); + return ResultVOUtils.success(productInfoService.findLastVersion(productInfoFilterRequest)); + + } + + /** * 下载医疗器械信息 * @@ -106,4 +125,6 @@ public class UdidlDeviceController { deviceSyncService.downloadUdiData(deviceRequest); return ResultVOUtils.success("后台已经开始下载"); } + + } diff --git a/src/main/java/com/glxp/udidl/admin/service/dataSync/DeviceSyncService.java b/src/main/java/com/glxp/udidl/admin/service/dataSync/DeviceSyncService.java index b2b078c..2c2d207 100644 --- a/src/main/java/com/glxp/udidl/admin/service/dataSync/DeviceSyncService.java +++ b/src/main/java/com/glxp/udidl/admin/service/dataSync/DeviceSyncService.java @@ -238,6 +238,8 @@ public class DeviceSyncService { jobLog.setMsg("下载失败:" + res.getReturnMsg()); jobLog.setType(Constant.LOG_TYPE_ERROR); jobLogService.update(jobLog); + + return ResultVOUtils.error(500, res.getReturnMsg()); } return ResultVOUtils.success(Convert(res.getDataSet())); } diff --git a/src/main/java/com/glxp/udidl/admin/service/inout/ProductInfoService.java b/src/main/java/com/glxp/udidl/admin/service/inout/ProductInfoService.java index 2b11d00..997d694 100644 --- a/src/main/java/com/glxp/udidl/admin/service/inout/ProductInfoService.java +++ b/src/main/java/com/glxp/udidl/admin/service/inout/ProductInfoService.java @@ -30,6 +30,8 @@ public interface ProductInfoService { List findAll(ProductInfoFilterRequest productInfoFilterRequest); + List findLastVersion(ProductInfoFilterRequest productInfoFilterRequest); + List selectByUpdateTime(String startDate, String endDate);//按更新时间查询 boolean insertProductInfo(ProductInfoEntity productInfoEntity); diff --git a/src/main/java/com/glxp/udidl/admin/service/inout/impl/ProductInfoServiceImpl.java b/src/main/java/com/glxp/udidl/admin/service/inout/impl/ProductInfoServiceImpl.java index dbb27b5..710b5e8 100644 --- a/src/main/java/com/glxp/udidl/admin/service/inout/impl/ProductInfoServiceImpl.java +++ b/src/main/java/com/glxp/udidl/admin/service/inout/impl/ProductInfoServiceImpl.java @@ -11,6 +11,8 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.Collections; import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; @Service public class ProductInfoServiceImpl implements ProductInfoService { @@ -116,6 +118,22 @@ public class ProductInfoServiceImpl implements ProductInfoService { return data; } + @Override + public List findLastVersion(ProductInfoFilterRequest productInfoFilterRequest) { + List productInfoEntityList = findAll(productInfoFilterRequest); + Map> listMap = productInfoEntityList.stream().collect(Collectors.groupingBy(ProductInfoEntity::getUuid)); + List result = null; + for (List value : listMap.values()) { + if (result == null || value.get(0).getVersionNumber() > result.get(0).getVersionNumber()) { + result = value; + } + } + productInfoFilterRequest.setNameCode(null); + productInfoFilterRequest.setUuid(result.get(0).getUuid()); + List datas = findAll(productInfoFilterRequest); + return datas; + } + public List selectByUpdateTime(String startDate, String endDate) { return productInfoDao.selectByUpdateTime(startDate, endDate); }