lipenghui 4 hete
szülő
commit
7dd5b17c58

+ 18 - 7
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/oa/OaFlow.java

@@ -28,7 +28,9 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.HttpEntity;
 import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
 import org.springframework.stereotype.Component;
+import org.springframework.util.LinkedMultiValueMap;
 import org.springframework.util.MultiValueMap;
 import org.springframework.web.client.RestTemplate;
 
@@ -61,6 +63,8 @@ public class OaFlow {
     private String requestName;
     @Value("${oa.outMaintain}")
     private String outMaintainUrl;
+    @Value("${oa.userid}")
+    private String userid;
 
     private static String spk = "";
     private static String secret = "";
@@ -187,7 +191,7 @@ public class OaFlow {
         HttpHeaders headersOut = new HttpHeaders();
         headersOut.add("token", token);
         headersOut.add("appid", appid);
-        headersOut.add("userid", "cLPEaFs9moW6b3xZMl1kNNWAAo7bp61ZRRTKmpiJUe56hSxQvrC2vWtY5ogj7g5FAnUOlzYjYg9MRktKXcseh/nsvZCQGa3BAlYixlDJruV19y4Omx5dYnqu/qv2rJAqTzUS71sOwuB1M2nKlLVsphw1GF74UhGP4xsjpZP7mC8=");
+        headersOut.add("userid", userid);
 
         Map<String, Object> params = new HashMap<>();
         Map<String, Object> map = new HashMap<>();
@@ -229,6 +233,7 @@ public class OaFlow {
         headersOut.add("appid", appid);
         String person = E9ApiTokenUtil.encryptString(spk, iotMaintainDO.getApplyPersonId());
         headersOut.add("userid", person);
+        headersOut.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
 
         OutRepairFlow flow = new OutRepairFlow().setFieldName("xmjl").setFieldValue(iotMaintainDO.getProjectManager());
         OutRepairFlow flow1 = new OutRepairFlow().setFieldName("sqr").setFieldValue(iotMaintainDO.getApplyPersonId());
@@ -262,18 +267,24 @@ public class OaFlow {
         ImmutableList<OutRepairFlow> outRepairFlows = ImmutableList.of(flow16,flow12, flow3, flow4, flow5, flow6, flow7, flow8, flow9, flow10, flow11, flow2, flow, flow14, flow1, flow15, flow13,flow17);
 
 
-        Map<String, Object> params = new HashMap<>();
-        params.put("workflowId", workflowId);
-        params.put("requestName", requestName);
-        params.put("mainData", outRepairFlows);
+
+        // 创建表单数据
+        MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
+        params.add("workflowId", workflowId);
+        params.add("requestName", requestName);
+        params.add("mainData", JSON.toJSONString(outRepairFlows));
+        Map<String, String> other = new HashMap<>();
+        other.put("isnextflow", "1");
+        params.add("otherParams", JSON.toJSONString(other));
+        System.out.println("------------"+JSON.toJSONString(outRepairFlows));
         // 3. 组合请求头和请求体
-        HttpEntity<Map<String, Object>> requestEntityOut = new HttpEntity<>(params, headersOut);
+        HttpEntity<MultiValueMap<String, Object>> requestEntityOut = new HttpEntity<>(params, headersOut);
         RestTemplate restTemplate = SslSkippingRestTemplate.createRestTemplate();
         String out = restTemplate.postForObject(outMaintainUrl, requestEntityOut, String.class);
         JSONObject outInfo = JSON.parseObject(out);
         //请求成功
         if (Objects.isNull(outInfo) || !"success".equalsIgnoreCase(String.valueOf(outInfo.get("code")))) {
-            throw new ServiceException(new ErrorCode(777, "发起oa流程失败"));
+            throw new ServiceException(new ErrorCode(777, String.valueOf(outInfo.get("msg"))));
         }
         JSONObject jsonObject = JSON.parseObject(outInfo.get("data").toString());
         String requestid = String.valueOf(jsonObject.get("requestid"));

+ 24 - 4
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/maintain/IotMaintainServiceImpl.java

@@ -211,7 +211,7 @@ public class IotMaintainServiceImpl implements IotMaintainService {
         //如果委外发起流程
         if ("out".equals(createReqVO.getMaintain().getType())){
             try {
-//                oaFlow.createOutRepairFlow(iotMaintain);
+                oaFlow.createOutRepairFlow(iotMaintain);
             } catch (Exception e) {
                 throw new ServiceException(122, e.getMessage());
             }
@@ -493,7 +493,7 @@ public class IotMaintainServiceImpl implements IotMaintainService {
             return currentUser;
         }
         Long deptId = user.getDeptId();
-        DeptRespDTO dept = deptApi.getDept(deptId);
+        DeptRespDTO dept = deptApi.getDeptNoPermission(deptId);
         String name = dept.getName();
         String companyCode = "";
         if (name.contains("瑞恒")) {
@@ -503,7 +503,7 @@ public class IotMaintainServiceImpl implements IotMaintainService {
         } else if (name.contains("瑞鹰")) {
             companyCode = "6010";
         } else {
-            DeptRespDTO dept1 = deptApi.getDept(dept.getParentId());
+            DeptRespDTO dept1 = deptApi.getDeptNoPermission(dept.getParentId());
             String name1 = dept1.getName();
             if (name1.contains("瑞恒")) {
                 companyCode = "6000";
@@ -512,7 +512,7 @@ public class IotMaintainServiceImpl implements IotMaintainService {
             } else if (name1.contains("瑞鹰")) {
                 companyCode = "6010";
             } else {
-                DeptRespDTO dept2 = deptApi.getDept(dept1.getParentId());
+                DeptRespDTO dept2 = deptApi.getDeptNoPermission(dept1.getParentId());
                 String name2 = dept2.getName();
                 if (name2.contains("瑞恒")) {
                     companyCode = "6000";
@@ -520,6 +520,16 @@ public class IotMaintainServiceImpl implements IotMaintainService {
                     companyCode = "5020";
                 } else if (name2.contains("瑞鹰")) {
                     companyCode = "6010";
+                } else {
+                    DeptRespDTO dept3= deptApi.getDeptNoPermission(dept2.getParentId());
+                    String name3 = dept3.getName();
+                    if (name3.contains("瑞恒")) {
+                        companyCode = "6000";
+                    } else if (name3.contains("瑞都")) {
+                        companyCode = "5020";
+                    } else if (name3.contains("瑞鹰")) {
+                        companyCode = "6010";
+                    }
                 }
             }
         }
@@ -576,6 +586,16 @@ public class IotMaintainServiceImpl implements IotMaintainService {
                     companyCode = "5020";
                 } else if (name2.contains("瑞鹰")) {
                     companyCode = "6010";
+                } else {
+                    DeptRespDTO dept3= deptApi.getDeptNoPermission(dept2.getParentId());
+                    String name3 = dept3.getName();
+                    if (name3.contains("瑞恒")) {
+                        companyCode = "6000";
+                    } else if (name3.contains("瑞都")) {
+                        companyCode = "5020";
+                    } else if (name3.contains("瑞鹰")) {
+                        companyCode = "6010";
+                    }
                 }
             }
         }