Explorar o código

Merge remote-tracking branch 'origin/master'

LiFei %!s(int64=4) %!d(string=hai) anos
pai
achega
ff479d08b3

+ 20 - 13
happy-boot-module-flexjob/src/main/java/org/jeecg/modules/ordermanager/service/impl/HwOrderServiceImpl.java

@@ -1,6 +1,7 @@
 package org.jeecg.modules.ordermanager.service.impl;
 
 import cn.hutool.core.date.DateUtil;
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.Wrapper;
@@ -1058,20 +1059,26 @@ public class HwOrderServiceImpl extends ServiceImpl<HwOrderMapper, HwOrder> impl
      */
     @Override
     public List<HwSubcontractor> querySubcontractList(HwOrder hwOrder) {
-        //慧盈-查询所有服务商信息
-        String accessToken = OauthTokenUtils.getDayAccessToken();
-        String requestUrl = OauthApi.ORDER_SUBCONTRACTOR_LIST;
-        JSONObject jsonObjectParam = new JSONObject();
-        jsonObjectParam.put("orderCode", hwOrder.getOrderCode());
-        log.info("param============{}", JSONObject.toJSONString(jsonObjectParam));
-        //数据加密
-        String biz_content = CryptTool.encode(JSONObject.toJSONString(jsonObjectParam));
-        JSONObject jsonObjectResult = OauthTokenUtils.doRequest(requestUrl, HttpsContants.POST, biz_content, accessToken);
-        log.info("查询所有服务商信息===={}", jsonObjectResult);
         List<HwSubcontractor> list = new ArrayList<>();
-        if (jsonObjectResult != null) {
-            if (jsonObjectResult.getBoolean("success")) {
-                list = (List<HwSubcontractor>) jsonObjectResult.get("result");
+        if (StringUtils.isNotBlank(hwOrder.getOrderCode())) {
+            //慧盈-查询所有服务商信息
+            String accessToken = OauthTokenUtils.getDayAccessToken();
+            String requestUrl = OauthApi.ORDER_SUBCONTRACTOR_LIST;
+            JSONObject jsonObjectParam = new JSONObject();
+            jsonObjectParam.put("orderCode", hwOrder.getOrderCode());
+            log.info("param============{}", JSONObject.toJSONString(jsonObjectParam));
+            //数据加密
+            String biz_content = CryptTool.encode(JSONObject.toJSONString(jsonObjectParam));
+            JSONObject jsonObjectResult = OauthTokenUtils.doRequest(requestUrl, HttpsContants.POST, biz_content, accessToken);
+            log.info("查询所有服务商信息===={}", jsonObjectResult);
+            if (jsonObjectResult != null) {
+                if (jsonObjectResult.getBoolean("success")) {
+                    list = JSON.parseArray(jsonObjectResult.getString("result"), HwSubcontractor.class);
+                    //只保留该订单所属需求的服务商
+                    HwOrder hwOrderDto = baseMapper.getByOrderCode(hwOrder.getOrderCode());
+                    HwRequirement hwRequirement = hwRequirementMapper.selectById(hwOrderDto.getRequirementId());
+                    list = list.stream().filter(item -> hwRequirement.getSubcontractorId().equals(item.getId())).collect(Collectors.toList());
+                }
             }
         }
         return list;