|
@@ -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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|