患者信息,处方信息下载

test
anthonywj 1 year ago
parent 7450916af4
commit 15e7286003

@ -43,4 +43,16 @@ public interface RedissonCacheKey {
*
*/
String COPY_ORDER = "copy_order";
/**
*
*/
String DL_SICKER = "dl_sicker";
/**
*
*/
String DL_SICKER_PRECRIBE = "dl_sicker_precribe";
}

@ -1,19 +1,19 @@
package com.glxp.api.controller.basic;
import cn.hutool.core.util.IdUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import cn.hutool.core.thread.ThreadUtil;
import com.github.pagehelper.PageInfo;
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.controller.BaseController;
import com.glxp.api.entity.auth.AuthAdmin;
import com.glxp.api.entity.basic.BasicSkSickerEntity;
import com.glxp.api.req.basic.BasicSkSickerRequest;
import com.glxp.api.req.basic.GetSickRequest;
import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.res.basic.BasicSkSickerResponse;
import com.glxp.api.service.basic.BasicSkPrescribeService;
import com.glxp.api.service.basic.BasicSkSickerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@ -21,9 +21,9 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
@Slf4j
@RestController
public class BasicSickerController extends BaseController {
@ -41,4 +41,18 @@ public class BasicSickerController extends BaseController {
return ResultVOUtils.success(pageSimpleResponse);
}
@CusRedissonAnnotation(cacheName = RedissonCacheKey.DL_SICKER, key = {"#getSickRequest.thirdSys"}, waitTime = 3, timeOutMsg = "后台正在下载,请勿重复提交")
@PostMapping("/udiwms/basic/sk/sicker/download")
public BaseResponse sickerDl(@RequestBody GetSickRequest getSickRequest, BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
ThreadUtil.execAsync(() -> {
basicSkSickerService.downloadSicker(getSickRequest);
});
return ResultVOUtils.success("后台已开始下载,请稍后刷新查看!");
}
}

@ -1,16 +1,22 @@
package com.glxp.api.controller.basic;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.StrUtil;
import com.github.pagehelper.PageInfo;
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.controller.BaseController;
import com.glxp.api.entity.basic.BasicSkPrescribeEntity;
import com.glxp.api.entity.basic.BasicSkPrescribeItemEntity;
import com.glxp.api.entity.basic.BasicSkSickerEntity;
import com.glxp.api.req.basic.BasicProductTypeRequest;
import com.glxp.api.req.basic.BasicSkPrescribeRequest;
import com.glxp.api.req.basic.GetSickPrescribeRequest;
import com.glxp.api.req.basic.GetSickRequest;
import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.res.basic.BasicSkPrescribeResponse;
import com.glxp.api.res.basic.BasicSkSickerResponse;
@ -20,6 +26,8 @@ import com.glxp.api.service.basic.BasicSkSickerService;
import com.glxp.api.vo.basic.BasicSkPrescribeDetailVo;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
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;
@ -72,4 +80,18 @@ public class BasicSkPrescribeController extends BaseController {
}
@CusRedissonAnnotation(cacheName = RedissonCacheKey.DL_SICKER_PRECRIBE, key = {"#getSickPrescribeRequest.sickCode"}, waitTime = 3, timeOutMsg = "后台正在下载,请勿重复提交")
@PostMapping("/udiwms/basic/sk/prescribe/download")
public BaseResponse sickerPrescribeDl(@RequestBody GetSickPrescribeRequest getSickPrescribeRequest, BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
ThreadUtil.execAsync(() -> {
basicSkPrescribeService.downloadSickerPrescribe(getSickPrescribeRequest);
});
return ResultVOUtils.success("后台已开始下载,请稍后刷新查看!");
}
}

@ -1,6 +1,7 @@
package com.glxp.api.dao.basic;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.glxp.api.dao.BaseMapperPlus;
import com.glxp.api.entity.basic.BasicSkPrescribeEntity;
import com.glxp.api.req.basic.BasicSkPrescribeRequest;
import com.glxp.api.res.basic.BasicSkPrescribeResponse;
@ -9,7 +10,7 @@ import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface BasicSkPrescribeMapper extends BaseMapper<BasicSkPrescribeEntity> {
public interface BasicSkPrescribeMapper extends BaseMapperPlus<BasicSkPrescribeMapper, BasicSkPrescribeEntity, BasicSkPrescribeEntity> {
List<BasicSkPrescribeResponse> filterList(BasicSkPrescribeRequest basicSkPrescribeRequest);

@ -1,6 +1,7 @@
package com.glxp.api.dao.basic;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.glxp.api.dao.BaseMapperPlus;
import com.glxp.api.entity.basic.BasicSkSickerEntity;
import com.glxp.api.req.basic.BasicSkSickerRequest;
import com.glxp.api.res.basic.BasicSkSickerResponse;
@ -9,7 +10,7 @@ import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface BasicSkSickerMapper extends BaseMapper<BasicSkSickerEntity> {
public interface BasicSkSickerMapper extends BaseMapperPlus<BasicSkSickerMapper, BasicSkSickerEntity, BasicSkSickerEntity> {
List<BasicSkSickerResponse> filterList(BasicSkSickerRequest basicSkSickerRequest);

@ -9,8 +9,12 @@ 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.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.BasicSkSickerResponse;
import com.glxp.api.res.thrsys.ThrCorpsResponse;
import com.glxp.api.res.thrsys.ThrProductsResponse;
import com.glxp.api.res.thrsys.UdiwmsWarehouseDetail;
@ -95,6 +99,51 @@ public class ErpBasicClient {
}
}
/**
*
*
* @param getSickRequest
* @return
*/
public BaseResponse<PageSimpleResponse<BasicSkSickerResponse>> getSicker(GetSickRequest getSickRequest) {
ThrSystemEntity basicThirdSysEntity = basicThirdSysService.selectByThirdId(getSickRequest.getThirdSys());
String url = basicThirdSysEntity.getThridUrl() + "/udiwms/erp/sicker/getInfo";
try {
String response = httpOkClient.uCloudPost(url, getSickRequest);
BaseResponse<PageSimpleResponse<BasicSkSickerResponse>> listBaseResponse =
JSONObject.parseObject(response, new TypeReference<BaseResponse<PageSimpleResponse<BasicSkSickerResponse>>>() {
});
return listBaseResponse;
} catch (Exception e) {
log.error("获取患者信息异常", e);
return ResultVOUtils.error(500, "连接第三方系统接口服务出错");
}
}
/**
*
*
* @param getSickPrescribeRequest
* @return
*/
public BaseResponse<PageSimpleResponse<BasicSkPrescribeResponse>> getSickPrescribe(GetSickPrescribeRequest getSickPrescribeRequest) {
ThrSystemEntity basicThirdSysEntity = basicThirdSysService.selectByThirdId(getSickPrescribeRequest.getThirdSys());
String url = basicThirdSysEntity.getThridUrl() + "/udiwms/erp/sicker/getPrescribe";
try {
String response = httpOkClient.uCloudPost(url, getSickPrescribeRequest);
BaseResponse<PageSimpleResponse<BasicSkPrescribeResponse>> listBaseResponse =
JSONObject.parseObject(response, new TypeReference<BaseResponse<PageSimpleResponse<BasicSkPrescribeResponse>>>() {
});
return listBaseResponse;
} catch (Exception e) {
log.error("获取患者处方信息", e);
return ResultVOUtils.error(500, "连接第三方系统接口服务出错");
}
}
//测试连通性
public BaseResponse testConnection(ThrSystemEntity thrSystemEntity) {
String response = httpOkClient.uCloudPost(thrSystemEntity.getThridUrl() + "/udiwms/erp/testLocal", "{}");

@ -0,0 +1,16 @@
package com.glxp.api.req.basic;
import com.glxp.api.util.page.ListPageRequest;
import lombok.Data;
@Data
public class GetSickPrescribeRequest extends ListPageRequest {
private String code;
private String sickName;
private String sickCode;
private String idNum;
private String phone;
private String searchTime;
private String thirdSys;
}

@ -0,0 +1,20 @@
package com.glxp.api.req.basic;
import com.glxp.api.util.page.ListPageRequest;
import lombok.Data;
@Data
public class GetSickRequest extends ListPageRequest {
private String code;
private String name;
private String adNum;
private String idNum;
private String phone;
private String searchTime;
private String thirdSys;
}

@ -1,23 +1,47 @@
package com.glxp.api.service.basic;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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.BasicSkProjectMapper;
import com.glxp.api.entity.basic.BasicSkSickerEntity;
import com.glxp.api.entity.basic.UdiRelevanceEntity;
import com.glxp.api.entity.thrsys.ThrProductsEntity;
import com.glxp.api.http.ErpBasicClient;
import com.glxp.api.req.basic.BasicSkPrescribeRequest;
import com.glxp.api.req.basic.BasicSkProjectRequest;
import com.glxp.api.req.basic.GetSickPrescribeRequest;
import com.glxp.api.req.basic.GetSickRequest;
import com.glxp.api.req.thrsys.FilterThrProductsRequest;
import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.res.basic.BasicSkPrescribeResponse;
import com.glxp.api.res.basic.BasicSkProjectResponse;
import com.glxp.api.res.basic.BasicSkSickerResponse;
import com.glxp.api.res.thrsys.ThrProductsResponse;
import com.glxp.api.util.IntUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.glxp.api.entity.basic.BasicSkPrescribeEntity;
import com.glxp.api.dao.basic.BasicSkPrescribeMapper;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
@Service
public class BasicSkPrescribeService extends ServiceImpl<BasicSkPrescribeMapper, BasicSkPrescribeEntity> {
@Resource
ErpBasicClient erpBasicClient;
public List<BasicSkPrescribeResponse> filterList(BasicSkPrescribeRequest basicSkPrescribeRequest) {
if (basicSkPrescribeRequest == null) {
return Collections.emptyList();
@ -29,4 +53,38 @@ public class BasicSkPrescribeService extends ServiceImpl<BasicSkPrescribeMapper,
List<BasicSkPrescribeResponse> data = super.baseMapper.filterList(basicSkPrescribeRequest);
return data;
}
public BaseResponse downloadSickerPrescribe(GetSickPrescribeRequest request) {
int page = 1;
int limit = 200;
request.setThirdSys("thirdId");
request.setLimit(limit);
while (true) {
request.setPage(page);
BaseResponse<PageSimpleResponse<BasicSkPrescribeResponse>> baseResponse = erpBasicClient.getSickPrescribe(request);
if (baseResponse.getCode() == 20000) {
List<BasicSkPrescribeResponse> list = baseResponse.getData().getList();
List<BasicSkPrescribeEntity> basicSkPrescribeEntities = new ArrayList<>();
list.forEach(item -> {
BasicSkPrescribeEntity basicSkSickerEntity = new BasicSkPrescribeEntity();
BeanUtil.copyProperties(item, basicSkSickerEntity);
//todo 数据转换
basicSkPrescribeEntities.add(basicSkSickerEntity);
});
if (list.size() >= limit && !baseResponse.getData().getTotal().equals(-666)) {
super.baseMapper.replaceBatchs(basicSkPrescribeEntities);
page++;
} else {
break;
}
} else {
return ResultVOUtils.error(500, "下载异常中断");
}
}
return ResultVOUtils.success("下载成功!");
}
}

@ -1,9 +1,16 @@
package com.glxp.api.service.basic;
import cn.hutool.core.bean.BeanUtil;
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.BasicSkProjectMapper;
import com.glxp.api.entity.basic.BasicSkPrescribeEntity;
import com.glxp.api.http.ErpBasicClient;
import com.glxp.api.req.basic.BasicSkProjectRequest;
import com.glxp.api.req.basic.BasicSkSickerRequest;
import com.glxp.api.req.basic.GetSickRequest;
import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.res.basic.BasicSkProjectResponse;
import com.glxp.api.res.basic.BasicSkSickerResponse;
import org.springframework.stereotype.Service;
@ -12,6 +19,7 @@ import com.glxp.api.entity.basic.BasicSkSickerEntity;
import com.glxp.api.dao.basic.BasicSkSickerMapper;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@ -19,6 +27,8 @@ import java.util.List;
public class BasicSkSickerService extends ServiceImpl<BasicSkSickerMapper, BasicSkSickerEntity> {
@Resource
BasicSkSickerMapper basicSkSickerMapper;
@Resource
ErpBasicClient erpBasicClient;
public List<BasicSkSickerResponse> filterList(BasicSkSickerRequest basicSkSickerRequest) {
if (basicSkSickerRequest == null) {
@ -31,4 +41,38 @@ public class BasicSkSickerService extends ServiceImpl<BasicSkSickerMapper, Basic
List<BasicSkSickerResponse> data = basicSkSickerMapper.filterList(basicSkSickerRequest);
return data;
}
public BaseResponse downloadSicker(GetSickRequest request) {
int page = 1;
int limit = 200;
request.setThirdSys("thirdId");
request.setLimit(limit);
while (true) {
request.setPage(page);
BaseResponse<PageSimpleResponse<BasicSkSickerResponse>> baseResponse = erpBasicClient.getSicker(request);
if (baseResponse.getCode() == 20000) {
List<BasicSkSickerResponse> list = baseResponse.getData().getList();
List<BasicSkSickerEntity> basicSkSickerEntities = new ArrayList<>();
list.forEach(item -> {
BasicSkSickerEntity basicSkSickerEntity = new BasicSkSickerEntity();
BeanUtil.copyProperties(item, basicSkSickerEntity);
//todo 数据转换
basicSkSickerEntities.add(basicSkSickerEntity);
});
if (list.size() >= limit && !baseResponse.getData().getTotal().equals(-666)) {
basicSkSickerMapper.replaceBatchs(basicSkSickerEntities);
page++;
} else {
break;
}
} else {
return ResultVOUtils.error(500, "下载异常中断");
}
}
return ResultVOUtils.success("下载成功!");
}
}

Loading…
Cancel
Save