新增下载最新版本数据

master
anthonyywj2 3 years ago
parent 2e672e7250
commit c09c9b97b2

@ -307,18 +307,7 @@ public class ProductInfoController {
@AuthRuleAnnotation("udidl/device/filterByNameCode")
@GetMapping("udidl/device/filterByNameCode")
public BaseResponse filterByNameCode(ProductInfoFilterRequest productInfoFilterRequest) {
List<ProductInfoEntity> productInfoEntityList = productInfoService.findAll(productInfoFilterRequest);
Map<String, List<ProductInfoEntity>> listMap = productInfoEntityList.stream().collect(Collectors.groupingBy(ProductInfoEntity::getUuid));
List<ProductInfoEntity> result = null;
for (List<ProductInfoEntity> 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<ProductInfoEntity> datas = productInfoService.findAll(productInfoFilterRequest);
return ResultVOUtils.success(datas);
return ResultVOUtils.success(productInfoService.findLastVersion(productInfoFilterRequest));
}
}

@ -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("后台已经开始下载");
}
}

@ -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()));
}

@ -30,6 +30,8 @@ public interface ProductInfoService {
List<ProductInfoEntity> findAll(ProductInfoFilterRequest productInfoFilterRequest);
List<ProductInfoEntity> findLastVersion(ProductInfoFilterRequest productInfoFilterRequest);
List<ProductInfoEntity> selectByUpdateTime(String startDate, String endDate);//按更新时间查询
boolean insertProductInfo(ProductInfoEntity productInfoEntity);

@ -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<ProductInfoEntity> findLastVersion(ProductInfoFilterRequest productInfoFilterRequest) {
List<ProductInfoEntity> productInfoEntityList = findAll(productInfoFilterRequest);
Map<String, List<ProductInfoEntity>> listMap = productInfoEntityList.stream().collect(Collectors.groupingBy(ProductInfoEntity::getUuid));
List<ProductInfoEntity> result = null;
for (List<ProductInfoEntity> 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<ProductInfoEntity> datas = findAll(productInfoFilterRequest);
return datas;
}
public List<ProductInfoEntity> selectByUpdateTime(String startDate, String endDate) {
return productInfoDao.selectByUpdateTime(startDate, endDate);
}

Loading…
Cancel
Save