diff --git a/src/main/java/com/glxp/api/controller/basic/BasicDestinyRelController.java b/src/main/java/com/glxp/api/controller/basic/BasicDestinyRelController.java index a81f4bb8..f7cad89c 100644 --- a/src/main/java/com/glxp/api/controller/basic/BasicDestinyRelController.java +++ b/src/main/java/com/glxp/api/controller/basic/BasicDestinyRelController.java @@ -1,13 +1,17 @@ package com.glxp.api.controller.basic; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.thread.ThreadUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.github.pagehelper.PageInfo; import com.glxp.api.annotation.AuthRuleAnnotation; +import com.glxp.api.annotation.CusRedissonAnnotation; import com.glxp.api.common.enums.ResultEnum; import com.glxp.api.common.res.BaseResponse; import com.glxp.api.common.util.ResultVOUtils; +import com.glxp.api.constant.RedissonCacheKey; import com.glxp.api.entity.auth.AuthAdmin; import com.glxp.api.entity.basic.BasicSkProjectEntity; import com.glxp.api.entity.basic.UdiEntity; @@ -177,12 +181,14 @@ public class BasicDestinyRelController { companyProductRelevanceRequest.setDiType(1); } //查询详情id过滤 - List idList = basicDestinyRelService.filterDestinyRelIds(Long.valueOf(companyProductRelevanceRequest.getId())); + List idList = null; + if (companyProductRelevanceRequest.getId() != null) + idList = basicDestinyRelService.filterDestinyRelIds(Long.valueOf(companyProductRelevanceRequest.getId())); List basicInstrumentMaintainRelevanceResponses = null; FilterUdiRelRequest filterUdiRelRequest = new FilterUdiRelRequest(); BeanCopyUtils.copy(companyProductRelevanceRequest, filterUdiRelRequest); - if (idList.size() > 0) { + if (CollUtil.isNotEmpty(idList)) { filterUdiRelRequest.setIds(idList); } basicInstrumentMaintainRelevanceResponses = basicDestinyRelService.filterUdiJoinSup(filterUdiRelRequest); @@ -268,4 +274,18 @@ public class BasicDestinyRelController { } + @CusRedissonAnnotation(cacheName = RedissonCacheKey.DL_SICKER, key = {"#dlThirdDestinyRequest.thirdSys"}, waitTime = 3, timeOutMsg = "后台正在下载,请勿重复提交") + @PostMapping("/udiwms/basic/destiny/project/download") + public BaseResponse dlProject(@RequestBody DlThirdDestinyRequest dlThirdDestinyRequest, BindingResult bindingResult) { + + if (bindingResult.hasErrors()) { + return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage()); + } + ThreadUtil.execAsync(() -> { + basicDestinyRelService.dlThirdDestiny(dlThirdDestinyRequest); + }); + return ResultVOUtils.success("后台已开始下载,请稍后刷新查看!"); + } + + } diff --git a/src/main/java/com/glxp/api/http/ErpBasicClient.java b/src/main/java/com/glxp/api/http/ErpBasicClient.java index e99da0b8..d8de4fa2 100644 --- a/src/main/java/com/glxp/api/http/ErpBasicClient.java +++ b/src/main/java/com/glxp/api/http/ErpBasicClient.java @@ -1,19 +1,27 @@ package com.glxp.api.http; +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; import com.glxp.api.common.res.BaseResponse; import com.glxp.api.common.util.ResultVOUtils; +import com.glxp.api.entity.basic.BasicSkProjectDetailEntity; +import com.glxp.api.entity.basic.BasicSkProjectEntity; +import com.glxp.api.entity.basic.BasicSkSickerEntity; import com.glxp.api.entity.thrsys.ThrSystemBusApiEntity; import com.glxp.api.entity.thrsys.ThrSystemEntity; import com.glxp.api.http.req.UdiwmsBusTypeRequest; import com.glxp.api.http.req.UdiwmsUnitRequest; +import com.glxp.api.req.basic.DlThirdDestinyRequest; import com.glxp.api.req.basic.GetSickPrescribeRequest; import com.glxp.api.req.basic.GetSickRequest; import com.glxp.api.req.thrsys.*; import com.glxp.api.res.PageSimpleResponse; import com.glxp.api.res.basic.BasicSkPrescribeResponse; +import com.glxp.api.res.basic.BasicSkProjectDetailResponse; +import com.glxp.api.res.basic.BasicSkProjectResponse; import com.glxp.api.res.basic.BasicSkSickerResponse; import com.glxp.api.res.thrsys.ThrCorpsResponse; import com.glxp.api.res.thrsys.ThrProductsResponse; @@ -25,6 +33,7 @@ import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.util.List; /** * 第三方服务HttpClient @@ -231,4 +240,23 @@ public class ErpBasicClient { } } + + /** + * 获取项目组套信息 + */ + + public BaseResponse> getBasicProject(DlThirdDestinyRequest dlThirdDestinyRequest) { + ThrSystemEntity basicThirdSysEntity = basicThirdSysService.selectByThirdId(dlThirdDestinyRequest.getThirdSys()); + String url = basicThirdSysEntity.getThridUrl() + "/udiwms/erp/basic/getProject"; + try { + String response = httpOkClient.uCloudPost(url, dlThirdDestinyRequest); + BaseResponse> listBaseResponse = + JSONObject.parseObject(response, new TypeReference>>() { + }); + return listBaseResponse; + } catch (Exception e) { + log.error("获取患者处方信息", e); + return ResultVOUtils.error(500, "连接第三方系统接口服务出错"); + } + } } diff --git a/src/main/java/com/glxp/api/req/basic/DlThirdDestinyRequest.java b/src/main/java/com/glxp/api/req/basic/DlThirdDestinyRequest.java new file mode 100644 index 00000000..5537095d --- /dev/null +++ b/src/main/java/com/glxp/api/req/basic/DlThirdDestinyRequest.java @@ -0,0 +1,13 @@ +package com.glxp.api.req.basic; + +import com.glxp.api.util.page.ListPageRequest; +import lombok.Data; + +@Data +public class DlThirdDestinyRequest extends ListPageRequest { + + + private String lastUpdateTime; + private String thirdSys; + +} diff --git a/src/main/java/com/glxp/api/res/basic/BasicSkProjectDetailResponse.java b/src/main/java/com/glxp/api/res/basic/BasicSkProjectDetailResponse.java index b80795d4..9da42bd1 100644 --- a/src/main/java/com/glxp/api/res/basic/BasicSkProjectDetailResponse.java +++ b/src/main/java/com/glxp/api/res/basic/BasicSkProjectDetailResponse.java @@ -1,4 +1,40 @@ package com.glxp.api.res.basic; +import lombok.Data; + +@Data public class BasicSkProjectDetailResponse { + + + private Long id; + + /** + * 耗材产品id + */ + private Long relId; + + /** + * 定数包模板id + */ + private Long pId; + + /** + * 数量 + */ + private Integer count; + + private String thrName; + private String thrCode; + private String measureCount; + private String measureUnit; + private String category; + private String frequency; + private String price; + private String ggxh; + private String remark; + private String createTime; + private String createUser; + private String updateTime; + private String updateUser; + } diff --git a/src/main/java/com/glxp/api/res/basic/BasicSkProjectResponse.java b/src/main/java/com/glxp/api/res/basic/BasicSkProjectResponse.java index 3ac6ab2e..6532cd24 100644 --- a/src/main/java/com/glxp/api/res/basic/BasicSkProjectResponse.java +++ b/src/main/java/com/glxp/api/res/basic/BasicSkProjectResponse.java @@ -3,6 +3,7 @@ package com.glxp.api.res.basic; import lombok.Data; import java.util.Date; +import java.util.List; @Data public class BasicSkProjectResponse { @@ -53,4 +54,7 @@ public class BasicSkProjectResponse { * 类型:1:定数包,内部使用;2:项目、组套外部关联 */ private Integer type; + + + private List basicSkProjectDetailResponses; } diff --git a/src/main/java/com/glxp/api/service/basic/impl/BasicDestinyRelService.java b/src/main/java/com/glxp/api/service/basic/impl/BasicDestinyRelService.java index 50121eb7..9000764e 100644 --- a/src/main/java/com/glxp/api/service/basic/impl/BasicDestinyRelService.java +++ b/src/main/java/com/glxp/api/service/basic/impl/BasicDestinyRelService.java @@ -1,17 +1,29 @@ package com.glxp.api.service.basic.impl; +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.IdUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.pagehelper.PageHelper; +import com.glxp.api.common.res.BaseResponse; +import com.glxp.api.common.util.ResultVOUtils; import com.glxp.api.dao.basic.BasicDestinyRelMapper; import com.glxp.api.dao.basic.BasicSkProjectMapper; import com.glxp.api.dao.basic.UdiRelevanceDao; import com.glxp.api.entity.basic.BasicSkProjectDetailEntity; import com.glxp.api.entity.basic.BasicSkProjectEntity; +import com.glxp.api.entity.basic.BasicSkSickerEntity; +import com.glxp.api.http.ErpBasicClient; import com.glxp.api.req.basic.BasicDestinyRelRequest; +import com.glxp.api.req.basic.DlThirdDestinyRequest; import com.glxp.api.req.basic.FilterUdiRelRequest; +import com.glxp.api.req.basic.GetSickRequest; +import com.glxp.api.res.PageSimpleResponse; +import com.glxp.api.res.basic.BasicSkProjectDetailResponse; +import com.glxp.api.res.basic.BasicSkProjectResponse; +import com.glxp.api.res.basic.BasicSkSickerResponse; import com.glxp.api.res.basic.UdiRelevanceResponse; import org.springframework.stereotype.Service; @@ -26,7 +38,8 @@ public class BasicDestinyRelService extends ServiceImpl 0 ? true : false; } + + + public BaseResponse dlThirdDestiny(DlThirdDestinyRequest request) { + int page = 1; + int limit = 200; + request.setThirdSys("thirdId"); + request.setLimit(limit); + while (true) { + request.setPage(page); + BaseResponse> baseResponse = erpBasicClient.getBasicProject(request); + if (baseResponse.getCode() == 20000) { + List list = baseResponse.getData().getList(); + List basicSkProjectEntities = new ArrayList<>(); + if (CollUtil.isNotEmpty(list)) { + list.forEach(item -> { //todo 数据转换 + BasicSkProjectEntity basicSkProjectEntity = new BasicSkProjectEntity(); + BeanUtil.copyProperties(item, basicSkProjectEntity); + List basicSkProjectDetailResponses = item.getBasicSkProjectDetailResponses(); + if (CollUtil.isNotEmpty(basicSkProjectDetailResponses)) { + list.forEach(detailItem -> + { + //todo 数据转换 + BasicSkProjectDetailEntity basicSkProjectDetailEntity = new BasicSkProjectDetailEntity(); + BeanUtil.copyProperties(detailItem, basicSkProjectDetailEntity); + + } + ); + } + }); + } + if (list.size() >= limit && !baseResponse.getData().getTotal().equals(-666)) { +// basicDestinyRelMapper.replaceBatchs(basicSkProjectEntities); + page++; + } else { + break; + } + } else { + return ResultVOUtils.error(500, "下载异常中断"); + } + } + return ResultVOUtils.success("下载成功!"); + } }