调用其他平台接口

@Slf4j
@Validated
@RestController
@RequestMapping("/elderlyReferralInfo")
@Api(value = "elderlyReferralInfo", tags = "康养联合体转介转养")
public class ElderlyReferralInfoController {

    @Autowired
    private EchoService echoService;

    @Value("${kylht.baseUrl}")
    private String kylhtBaseUrl;

    @ApiOperation(value = "康养联合体-机构列表")
    @GetMapping(value = "/getHealthDeptList")
    public R<List<HealthDeptDTO>> getHealthDeptList(HttpServletResponse servletResponse, HealthDeptDTO dto) {
        try {
            String body = HttpUtil.createGet(kylhtBaseUrl + "/health-care/data/healthDept/queryDeptByName")
                    .form("deptName",dto.getDeptName())
                    .form("idcard",dto.getIdCard())
                    .execute().body();
            JSONObject jsonObject = JSONUtil.parseObj(body);
            List<HealthDeptDTO> list = new ArrayList<>();
            if (jsonObject.getStr("success").equals("true")) {
                JSONArray object = jsonObject.getJSONArray("result");
                list = JSONUtil.toList (object, HealthDeptDTO.class);
            }
            return R.success(list);
        } catch (Exception e) {
            return R.success(Collections.emptyList());
        }
    }

    @ApiOperation("康养联合体-历史记录列表")
    @GetMapping("/getReferralInfoList")
    public R<IPage<ReferralInfoDTO>> getReferralInfoList(HttpServletResponse response, ReferralInfoDTO dto,
        @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
        @RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
        IPage<ReferralInfoDTO> iPage = new Page<>(pageNo,pageSize);
        try {
            String body = HttpUtil.createGet(kylhtBaseUrl + "/health-care/data/referralInfo/list")
                .form("idcard", dto.getIdcard())
                .execute().body();
            JSONObject jsonObject = JSONUtil.parseObj(body);
            if (jsonObject.getStr("success").equals("true")) {
                JSONObject result = jsonObject.getJSONObject("result");
                Object records = result.get("records");
                JSONArray objects = new JSONArray(records);
                List<ReferralInfoDTO> toList = JSONUtil.toList(objects,
                    ReferralInfoDTO.class);
                iPage.setRecords(toList);
                iPage.setTotal(toList.size());
            }
            return R.success(iPage);
        } catch (Exception e) {
            return R.success(iPage);
        }
    }

    @ApiOperation("历史记录详情")
    @GetMapping("/getReferralInfoById")
    public ReferralInfoDTO getReferralInfoById(HttpServletResponse response,@RequestParam String id){
        ReferralInfoDTO infoDTO = new ReferralInfoDTO();
        try {
            String body = HttpUtil.createGet(
                kylhtBaseUrl + "/health-care/data/referralInfo/queryById")
                .form("id",id).execute().body();
            JSONObject jsonObject = JSONUtil.parseObj(body);
            if (jsonObject.getStr("success").equals("true")) {
                JSONObject result = jsonObject.getJSONObject("result");
                infoDTO = JSONUtil.toBean(result, ReferralInfoDTO.class);
                JSONObject oldPerson = result.getJSONObject("oldPerson");
                infoDTO.setDepart(oldPerson.getStr("depart"));;
            }
            return infoDTO;
        }catch (Exception e){
            return infoDTO;
        }
    }

    @ApiOperation("转介转养申请")
    @PostMapping("/apply")
    public R<String> apply(HttpServletResponse response,@RequestBody ReferralInfoDTO dto){
        String str = null;
        try {
            HashMap<Object, Object> map = new HashMap<>();
            map.put("applyDept", dto.getApplyDept());
            map.put("applyTime", dto.getApplyTime());
            map.put("applyItem", dto.getApplyItem());
            map.put("applyReason", dto.getApplyReason());
            map.put("applyType", dto.getApplyType());
            map.put("depart", dto.getDepart());
            map.put("idcard", dto.getIdcard());
            map.put("name", dto.getName());
            map.put("approvalProgress","待审核");
            String body = HttpUtil.createPost(kylhtBaseUrl + "/health-care/data/referralInfo/add")
                .body(JSONUtil.toJsonStr(map))
                .execute().body();
            JSONObject jsonObject = JSONUtil.parseObj(body);
            if (jsonObject.getStr("success").equals("true")){
                str = jsonObject.getStr("result");
            }
            return R.success(str);
        }catch (Exception e){
                return R.success(str);
        }
    }

}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值