zzx пре 2 година
родитељ
комит
bef696ebb0

+ 0 - 3
src/test/java/com/galaxis/manatee/Test/buildProjectTest/BuildProjectTest.java

@@ -28,9 +28,6 @@ public class BuildProjectTest {
     @Autowired
     private ChuanYunManager chuanYunManager;
 
-    @Autowired
-    private WorkGroupService workGroupService;
-
     @Test
     void test1() {
         //从氚云查询数据

+ 207 - 0
src/test/java/com/galaxis/manatee/Test/zzx/ProjectTest1.java

@@ -0,0 +1,207 @@
+package com.galaxis.manatee.Test.zzx;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.galaxis.manatee.entity.chuanyun.data.object.ChuanyunBuildProject;
+import com.galaxis.manatee.entity.chuanyun.data.object.ChuanyunGroupProjectDO;
+import com.galaxis.manatee.entity.chuanyun.dto.ChuanyunFindAllBizDTO;
+import com.galaxis.manatee.entity.chuanyun.dto.ChuanyunFindBizDTO;
+import com.galaxis.manatee.entity.chuanyun.dto.Filter;
+import com.galaxis.manatee.exception.BigSizeException;
+import com.galaxis.manatee.manager.ChuanYunManager;
+import lombok.Data;
+import lombok.extern.slf4j.Slf4j;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+import java.util.List;
+
+@Slf4j
+@SpringBootTest
+public class ProjectTest1 {
+    @Autowired
+    private ChuanYunManager chuanYunManager;
+
+    @Test
+    void test1() {
+
+    }
+
+    @Test
+    void accountChildEnter() {
+        List<String> m = List.of("F0000016_2,实施", "Status_2,1");
+        // List<String> m = List.of("F0000003_2,D22429", "Status_2,1");
+        var filter = Filter.instance(0, 400, true, Filter.AND, m);
+
+        ChuanyunFindAllBizDTO<Object> chuanyunFindAllResponse = null;
+        try {
+            chuanyunFindAllResponse = chuanYunManager.findAll(ChuanyunBuildProject.SCHEMA_CODE, filter);
+        } catch (JsonProcessingException e) {
+            e.printStackTrace();
+        }
+
+        if (chuanyunFindAllResponse.getReturnData() == null || chuanyunFindAllResponse.getReturnData().getBizObjectArray() == null) {
+            return;
+        }
+
+        List<Object> bizObjectArray = chuanyunFindAllResponse.getReturnData().getBizObjectArray();
+        ObjectMapper objectMapper = new ObjectMapper();
+        List<ChuanyunBuildProject> bpList = objectMapper.convertValue(bizObjectArray, new TypeReference<>() {
+        });
+
+        bpList.forEach(chuanyunBuildProject -> {
+            try {
+                Thread.sleep(200);
+                ProjectSubAccount projectSubAccount = new ProjectSubAccount();
+                projectSubAccount.setProjectType("实施");
+                projectSubAccount.setImplProjectName(chuanyunBuildProject.getProjectName());
+                projectSubAccount.setImplProjectCode(chuanyunBuildProject.getProjectCode());
+                projectSubAccount.setSigningCompany(chuanyunBuildProject.getSigningCompany());
+                projectSubAccount.setCustomerName(chuanyunBuildProject.getCustomerName());
+                projectSubAccount.setNameOfOwner(chuanyunBuildProject.getNameOfOwner());
+                projectSubAccount.setProjectManager(chuanyunBuildProject.getProjectManager());
+                projectSubAccount.setSalesDirector(chuanyunBuildProject.getSalesDirector());
+                projectSubAccount.setSystemWarranty(chuanyunBuildProject.getSystemWarranty());
+                projectSubAccount.setDeviceWarranty(chuanyunBuildProject.getDeviceWarranty());
+
+                String projectCode = chuanyunBuildProject.getProjectCode();
+                //售前转实施
+                if (this.getPreSales(projectCode) != null && this.getPreSales(projectCode).size() > 0) {
+                    String projectCode2 = this.getProjectCode(this.getPreSales(projectCode).get(0).getPreSaleProjectObjectId());
+                    projectSubAccount.setPreSaleNumber(projectCode2);
+                }
+
+                //实施转售后
+                if (this.getAfterSales(projectCode) != null && this.getAfterSales(projectCode).size() > 0) {
+                    projectSubAccount.setAfterSaleNumber(this.getAfterSales(projectCode).get(0).getAfterSaleProjectCode());
+                }
+
+                String json = null;
+                try {
+                    json = objectMapper.writeValueAsString(projectSubAccount);
+                    log.info("{json => {}}", json);
+                    chuanYunManager.save("D0017894df4f53e50244f29ad440f11ead89fad",json,true);
+                } catch (JsonProcessingException | BigSizeException e) {
+                    e.printStackTrace();
+                }
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+        });
+    }
+
+    //售前
+    List<SaleToImpl> getPreSales(String projectCode) {
+        List<String> m = List.of("F0000064_2," + projectCode, "Status_2,1");
+        var filter = Filter.instance(0, 400, true, Filter.AND, m);
+
+        ChuanyunFindAllBizDTO<Object> chuanyunFindAllResponse = null;
+        try {
+            chuanyunFindAllResponse = chuanYunManager.findAll("D0017899897ba28eca44996a3a7cb430ed4f07d", filter);
+        } catch (JsonProcessingException e) {
+            e.printStackTrace();
+        }
+
+        if (chuanyunFindAllResponse.getReturnData() == null || chuanyunFindAllResponse.getReturnData().getBizObjectArray() == null) {
+            return null;
+        }
+
+        List<Object> bizObjectArray = chuanyunFindAllResponse.getReturnData().getBizObjectArray();
+        ObjectMapper objectMapper = new ObjectMapper();
+        List<SaleToImpl> bpList = objectMapper.convertValue(bizObjectArray, new TypeReference<>() {
+        });
+
+        return bpList;
+    }
+
+    //获取项目号
+    String getProjectCode(String saleProjectObjectId) {
+        ChuanyunFindBizDTO<Object> objectChuanyunFindBizDTO = null;
+        try {
+            objectChuanyunFindBizDTO = chuanYunManager.find(ChuanyunGroupProjectDO.SCHEMA_CODE, saleProjectObjectId);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        if (objectChuanyunFindBizDTO.getReturnData() == null || objectChuanyunFindBizDTO.getReturnData().getBizObject() == null) {
+            return null;
+        }
+
+        ObjectMapper objectMapper = new ObjectMapper();
+        Object bizObject = objectChuanyunFindBizDTO.getReturnData().getBizObject();
+        ChuanyunGroupProjectDO groupProjectDO = objectMapper.convertValue(bizObject, new TypeReference<>() {
+        });
+        return groupProjectDO.getProjectCode();
+    }
+
+    //售后
+    List<SaleToAfter> getAfterSales(String projectCode) {
+        List<String> m = List.of("F0000042_2," + projectCode, "Status_2,1");
+        var filter = Filter.instance(0, 400, true, Filter.AND, m);
+
+        ChuanyunFindAllBizDTO<Object> chuanyunFindAllResponse = null;
+        try {
+            chuanyunFindAllResponse = chuanYunManager.findAll("D001789Sk18j1niro92y5dxj2indfx583", filter);
+        } catch (JsonProcessingException e) {
+            e.printStackTrace();
+        }
+
+        if (chuanyunFindAllResponse.getReturnData() == null || chuanyunFindAllResponse.getReturnData().getBizObjectArray() == null) {
+            return null;
+        }
+
+        List<Object> bizObjectArray = chuanyunFindAllResponse.getReturnData().getBizObjectArray();
+        ObjectMapper objectMapper = new ObjectMapper();
+        List<SaleToAfter> bpList = objectMapper.convertValue(bizObjectArray, new TypeReference<>() {
+        });
+
+        return bpList;
+    }
+
+    @Data
+    static class ProjectSubAccount {    //这里对应的是台账字表录入表的填充项
+        @JsonProperty("F0000102")
+        private String projectType;
+        @JsonProperty("F0000075")
+        private String implProjectName;
+        @JsonProperty("F0000001")
+        private String implProjectCode;
+        @JsonProperty("F0000007")
+        private String signingCompany;
+        @JsonProperty("F0000008")
+        private String customerName;
+        @JsonProperty("F0000034")
+        private String nameOfOwner;
+        @JsonProperty("F0000035")
+        private String projectManager;
+        @JsonProperty("F0000027")
+        private String SalesDirector;
+        @JsonProperty("F0000071")
+        private Integer systemWarranty;
+        @JsonProperty("F0000072")
+        private Integer deviceWarranty;
+        @JsonProperty("F0000076")
+        private String preSaleNumber;
+        @JsonProperty("F0000033")   //传递到氚云上去的
+        private String afterSaleNumber;
+    }
+
+    @Data
+    @JsonIgnoreProperties(ignoreUnknown = true)
+    static class SaleToImpl {
+        @JsonProperty("F0000015")
+        private String preSaleProjectObjectId; //售前转实施查出来的售前项目的ID
+    }
+
+    @Data
+    @JsonIgnoreProperties(ignoreUnknown = true)
+    static class SaleToAfter {
+        @JsonProperty("F0000073")   //从氚云获取的
+        private String afterSaleProjectCode; //实施转售后
+    }
+}
+