修复由于resttemplate返回的list元素为linkedhashmap导致的获取基础数据失败的问题。

This commit is contained in:
zhouxiunai
2019-02-19 14:23:28 +08:00
parent e8348be5ab
commit e345f2854d
5 changed files with 65 additions and 3 deletions
@@ -1,5 +1,7 @@
package com.gzzn.omms.msgexchangeapi.basicdata.service;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
@@ -8,6 +10,8 @@ import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.gzzn.omms.msgexchangeapi.basicdata.entity.OrmsStand;
import com.gzzn.omms.msgexchangeapi.dto.ResponseDto;
@@ -29,7 +33,12 @@ public class OrmsStandServiceImpl implements IOrmsStandService{
ResponseDto responseDto = responseEntity.getBody();
if (responseDto.getIs_success()) {
List<OrmsStand> rt = (List<OrmsStand>)responseDto.getBody();
List<LinkedHashMap> lsLinked = (List<LinkedHashMap>)responseDto.getBody();
//
ObjectMapper mapper = new ObjectMapper();
List<OrmsStand> rt = mapper.convertValue(lsLinked, new TypeReference<List<OrmsStand>>() { });
return rt;
}
else {