Prechádzať zdrojové kódy

同步h4a部门数据

lin.liu 3 týždňov pred
rodič
commit
b54dd581a4

+ 12 - 0
pom.xml

@@ -387,6 +387,18 @@
 			<groupId>com.fasterxml.jackson.core</groupId>
 			<artifactId>jackson-annotations</artifactId>
 		</dependency>
+
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-test</artifactId>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>4.13</version>
+			<scope>test</scope>
+		</dependency>
 	</dependencies>
 
 	<build>

+ 0 - 6
secure-producting-host/pom.xml

@@ -108,12 +108,6 @@
             <systemPath>${pom.basedir}/src/main/resources/lib/config-sdk-1.0.6.jar</systemPath>
         </dependency>
 
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-test</artifactId>
-            <scope>test</scope>
-        </dependency>
-
         <!--mapstruct编译-->
         <dependency>
             <groupId>org.mapstruct</groupId>

+ 126 - 0
secure-producting-host/src/test/java/com/customs/cq/datacenter/host/H4ATest.java

@@ -0,0 +1,126 @@
+package com.customs.cq.datacenter.host;
+
+import cn.gov.customs.casp.sdk.h4a.entity.OrganizationChildren;
+import cn.gov.customs.casp.sdk.h4a.ogu.ws.IOguReaderGetOrganizationChildrenCupaaFaultArgsFaultFaultMessage;
+import com.customs.cq.datacenter.common.core.domain.entity.SysDept;
+import com.customs.cq.datacenter.common.enums.EYesOrNo;
+import com.customs.cq.datacenter.common.utils.StringUtil;
+import com.customs.cq.datacenter.system.h4a.H4AReaderHelper;
+import com.customs.cq.datacenter.system.mapper.SysDeptMapper;
+import org.junit.jupiter.api.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+@SpringBootTest
+@RunWith(SpringRunner.class)
+@ContextConfiguration(classes = SpringConfig.class)
+public class H4ATest {
+    @Autowired
+    private SysDeptMapper mapper;
+
+    @Test
+    public void getListOrgChildren() throws IOguReaderGetOrganizationChildrenCupaaFaultArgsFaultFaultMessage {
+        OrganizationChildren[] list = H4AReaderHelper.getListOrganization();
+
+        Map<String, List<OrganizationChildren>> map4Parent = Arrays.stream(list).collect(Collectors.groupingBy(OrganizationChildren::getParent_guid));
+
+        LocalDateTime now = LocalDateTime.now();
+        List<SysDept> listNew = new ArrayList<>();
+
+        String rootGuid = "94480300-fca2-4268-86c2-4c13963bf4cb";
+        SysDept root = new SysDept();
+        root.setDeptId(StringUtil.guidToId(rootGuid));
+        root.setParentId(0L);
+        root.setAncestors("");
+        root.setOrderNum(0);
+        root.setDeptName("海关总署");
+        root.setLeader("");
+        root.setPhone("");
+        root.setEmail("");
+        root.setStatus("0");
+        root.setCreateBy("system");
+        root.setCreateTime(now);
+        root.setUpdateBy("");
+        root.setUpdateTime(null);
+        root.setGuid(rootGuid);
+        root.setParentGuid("");
+        root.setAllPathName("海关总署");
+        root.setIsDelete(EYesOrNo.NO.getValue());
+
+        mapper.insert(root);
+
+        for (OrganizationChildren org : map4Parent.get(rootGuid)) {
+            SysDept item = new SysDept();
+            item.setDeptId(StringUtil.guidToId(org.getOrg_guid()));
+            item.setGuid(org.getOrg_guid());
+            item.setParentGuid(org.getParent_guid());
+            item.setAllPathName(org.getAll_path_name());
+            item.setDeptName(org.getDisplay_name());
+            if (StringUtil.isNullOrEmpty(item.getDeptName())) {
+                item.setDeptName(org.getObj_name());
+            }
+            item.setParentId(0L);
+            item.setAncestors(item.getAllPathName().replaceAll("\\\\", "/").replace("/" + item.getDeptName(), ""));
+            item.setOrderNum(0);
+            item.setLeader("");
+            item.setPhone("");
+            item.setEmail("");
+            item.setStatus("0");
+            item.setCreateBy("system");
+            item.setCreateTime(now);
+            item.setUpdateBy("");
+            item.setUpdateTime(null);
+            item.setIsDelete(EYesOrNo.NO.getValue());
+            if (StringUtil.isNotNullOrEmpty(org.getParent_guid())) {
+                item.setParentId(StringUtil.guidToId(org.getParent_guid()));
+            }
+            this.insertChildren(item, map4Parent);
+        }
+
+        System.out.println("END");
+    }
+
+    private void insertChildren(SysDept dep, Map<String, List<OrganizationChildren>> map4Parent) {
+        mapper.insert(dep);
+
+        if (map4Parent.containsKey(dep.getGuid())) {
+            for (OrganizationChildren org : map4Parent.get(dep.getGuid())) {
+                SysDept item = new SysDept();
+                item.setDeptId(StringUtil.guidToId(org.getOrg_guid()));
+                item.setGuid(org.getOrg_guid());
+                item.setParentGuid(org.getParent_guid());
+                item.setAllPathName(org.getAll_path_name());
+                item.setDeptName(org.getDisplay_name());
+                if (StringUtil.isNullOrEmpty(item.getDeptName())) {
+                    item.setDeptName(org.getObj_name());
+                }
+                item.setParentId(0L);
+                item.setAncestors(item.getAllPathName().replaceAll("\\\\", "/").replace(item.getDeptName(), ""));
+                item.setOrderNum(0);
+                item.setLeader("");
+                item.setPhone("");
+                item.setEmail("");
+                item.setStatus("0");
+                item.setCreateBy("system");
+                item.setCreateTime(dep.getCreateTime());
+                item.setUpdateBy("");
+                item.setUpdateTime(null);
+                item.setIsDelete(EYesOrNo.NO.getValue());
+                if (StringUtil.isNotNullOrEmpty(org.getParent_guid())) {
+                    item.setParentId(StringUtil.guidToId(org.getParent_guid()));
+                }
+                this.insertChildren(item, map4Parent);
+            }
+        }
+    }
+}

+ 7 - 0
secure-producting-host/src/test/java/com/customs/cq/datacenter/host/SpringConfig.java

@@ -0,0 +1,7 @@
+package com.customs.cq.datacenter.host;
+
+import org.springframework.context.annotation.ComponentScan;
+
+@ComponentScan(basePackages = { "com.customs.cq.datacenter" })
+public class SpringConfig {
+}

+ 17 - 1
secure-producting-system/src/main/java/com/customs/cq/datacenter/system/h4a/H4AReaderHelper.java

@@ -296,7 +296,6 @@ public class H4AReaderHelper {
      * @param appCode
      * @return
      */
-
     public static FunctionsOfUser[] getBeanFunctionsOfUser(String userGuid, String parentGuid, String appCode) throws IAccreditReaderGetFunctionsOfUserCupaaFaultArgsFaultFaultMessage {
         FunctionsOfUser[] beanFunctionsOfUser = accreditBeanReaderHelper.getBeanFunctionsOfUser(
                 userGuid, UserCategory.USER_GUID,
@@ -524,6 +523,7 @@ public class H4AReaderHelper {
         }
         return null;
     }
+
     public static Roles [] getRoles(String appCode) {
         AccreditBeanReaderHelper accreditBeanReaderHelper = new AccreditBeanReaderHelper();
         Roles [] returnObjectList = null;
@@ -537,4 +537,20 @@ public class H4AReaderHelper {
         }
         return returnObjectList;
     }
+
+    public static OrganizationChildren[] getListOrganization() throws IOguReaderGetOrganizationChildrenCupaaFaultArgsFaultFaultMessage {
+        return oguBeanReaderHelper.getBeanOrganizationChildren(
+                "BASE_VIEW",
+                ViewCategory.ViewCode,
+                "海关总署",
+                cn.gov.customs.casp.sdk.h4a.ogu.ws.OrganizationCategory.ORG_ALL_PATH_NAME,
+                ListObjectCategories.Organizations,
+                ObjectStatusCategories.Common,
+                0,
+                "",
+                "",
+                "UM",
+                0,
+                "");
+    }
 }