Browse Source

启信宝字段错误

liyuan 2 months ago
parent
commit
0732cd0ea1

+ 1 - 4
ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/HttpUtils.java

@@ -12,10 +12,7 @@ import com.mashape.unirest.http.HttpResponse;
 import com.mashape.unirest.http.Unirest;
 import com.ruoyi.basicData.domain.TEnterpriseInformation;
 import com.ruoyi.common.utils.SecurityUtils;
-import com.ruoyi.web.controller.enums.CategoryNewEnum;
 import com.ruoyi.web.controller.enums.ErrorCodeEnum;
-import com.ruoyi.web.controller.enums.TagsEnum;
-import com.ruoyi.web.controller.enums.TypeNewEnum;
 
 import java.net.URLEncoder;
 import java.nio.charset.StandardCharsets;
@@ -152,7 +149,7 @@ public class HttpUtils {
 
                     enterpriseInformation.setStatus(jsonData.getString("status"));
                     enterpriseInformation.setActualCapi(jsonData.getString("actual_capi"));
-                    enterpriseInformation.setOrgNo(jsonData.getString("orgNo"));
+                    enterpriseInformation.setOrgNo(jsonData.getString("org_no"));
                     JSONArray branches = jsonData.getJSONArray("branches");
                     if (!branches.isEmpty()) {
                         enterpriseInformation.setBranches(branches.toString());

+ 8 - 18
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warehouse/basicData/TEnterpriseInformationController.java

@@ -10,6 +10,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
 import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.web.controller.tool.HttpUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.ObjectUtils;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
@@ -97,63 +98,52 @@ public class TEnterpriseInformationController extends BaseController {
     public AjaxResult getBasicInfo(@RequestParam(value = "keyword") String keyword) throws Exception {
         TEnterpriseInformation tEnterpriseInformation = tEnterpriseInformationService.selectTEnterpriseInformation(keyword);
         if (tEnterpriseInformation != null) {
+            ObjectMapper mapper = new ObjectMapper();
             if (ObjectUtil.isNotNull(tEnterpriseInformation.getBranches())) {
-                ObjectMapper mapper = new ObjectMapper();
                 tEnterpriseInformation.setBranchesList(mapper.readValue(tEnterpriseInformation.getBranches(),
                         mapper.getTypeFactory().constructCollectionType(List.class, Map.class)));
             }
             if (ObjectUtil.isNotNull(tEnterpriseInformation.getPartners())) {
-                ObjectMapper mapper = new ObjectMapper();
                 tEnterpriseInformation.setPartnersList(mapper.readValue(tEnterpriseInformation.getPartners(),
                         mapper.getTypeFactory().constructCollectionType(List.class, Map.class)));
             }
             if (ObjectUtil.isNotNull(tEnterpriseInformation.getEmployees())) {
-                ObjectMapper mapper = new ObjectMapper();
                 tEnterpriseInformation.setEmployeesList(mapper.readValue(tEnterpriseInformation.getEmployees(),
                         mapper.getTypeFactory().constructCollectionType(List.class, Map.class)));
             }
             if (ObjectUtil.isNotNull(tEnterpriseInformation.getChangerecords())) {
-                ObjectMapper mapper = new ObjectMapper();
                 tEnterpriseInformation.setChangerecordsList(mapper.readValue(tEnterpriseInformation.getChangerecords(),
                         mapper.getTypeFactory().constructCollectionType(List.class, Map.class)));
             }
             if (ObjectUtil.isNotNull(tEnterpriseInformation.getAbnormalItems())) {
-                ObjectMapper mapper = new ObjectMapper();
                 tEnterpriseInformation.setAbnormalItemsList(mapper.readValue(tEnterpriseInformation.getAbnormalItems(),
                         mapper.getTypeFactory().constructCollectionType(List.class, Map.class)));
             }
             if (ObjectUtil.isNotNull(tEnterpriseInformation.getWebsites())) {
-                ObjectMapper mapper = new ObjectMapper();
                 tEnterpriseInformation.setWebsitesList(mapper.readValue(tEnterpriseInformation.getWebsites(),
                         mapper.getTypeFactory().constructCollectionType(List.class, Map.class)));
             }
             if (ObjectUtil.isNotNull(tEnterpriseInformation.getContact())) {
-                ObjectMapper mapper = new ObjectMapper();
                 tEnterpriseInformation.setContactMap(mapper.readValue(tEnterpriseInformation.getContact(), Map.class));
             }
             if (ObjectUtil.isNotNull(tEnterpriseInformation.getIndustryCode())) {
-                ObjectMapper mapper = new ObjectMapper();
                 tEnterpriseInformation.setIndustryCodeMap(mapper.readValue(tEnterpriseInformation.getIndustryCode(), Map.class));
             }
             if (ObjectUtil.isNotNull(tEnterpriseInformation.getDomains())) {
-                ObjectMapper mapper = new ObjectMapper();
                 tEnterpriseInformation.setDomainsList(mapper.readValue(tEnterpriseInformation.getDomains(),
                         mapper.getTypeFactory().constructCollectionType(List.class, String.class)));
             }
             if (ObjectUtil.isNotNull(tEnterpriseInformation.getQuotedType())) {
-                ObjectMapper mapper = new ObjectMapper();
                 tEnterpriseInformation.setQuotedTypeList(mapper.readValue(tEnterpriseInformation.getQuotedType(),
                         mapper.getTypeFactory().constructCollectionType(List.class, String.class)));
             }
             return AjaxResult.success(tEnterpriseInformation);
-        } else {
-            TEnterpriseInformation tEnterpriseInformationNew = HttpUtils.getDetailAndContactByName(keyword);
-            if (tEnterpriseInformationNew != null) {
-                tEnterpriseInformationService.insertTEnterpriseInformation(tEnterpriseInformationNew);
-                return AjaxResult.success(tEnterpriseInformationNew);
-            } else {
-                return AjaxResult.error("获取公司数据失败");
-            }
         }
+        TEnterpriseInformation tEnterpriseInformationNew = HttpUtils.getDetailAndContactByName(keyword);
+        if (ObjectUtils.isEmpty(tEnterpriseInformationNew)) {
+            return AjaxResult.error("获取公司数据失败");
+        }
+        tEnterpriseInformationService.insertTEnterpriseInformation(tEnterpriseInformationNew);
+        return AjaxResult.success(tEnterpriseInformationNew);
     }
 }