소스 검색

新增获取公司部门数据

anderx 4 달 전
부모
커밋
5a2caf36a2

+ 9 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/ProjectTaskController.java

@@ -563,4 +563,13 @@ public class ProjectTaskController extends BaseController {
 
         return AjaxResult.success(projectTaskService.getCompanyData(usci));
     }
+
+
+    /**
+     * 导入公司部门,项目,人员信息
+     */
+    @GetMapping("/pushCompanyData")
+    public AjaxResult pushCompanyData(@RequestBody pushCompanyDataBo in){
+        return AjaxResult.success(projectTaskService.pushCompanyData(in));
+    }
 }

+ 34 - 0
ruoyi-system/src/main/java/com/ruoyi/project/bo/pushCompanyDataBo.java

@@ -0,0 +1,34 @@
+package com.ruoyi.project.bo;
+
+import java.util.List;
+
+public class pushCompanyDataBo {
+
+    private List<pushDataDep> listDep;
+    private List<pushDataUser> listUser;
+    private List<pushDataProject> listUserClock;
+
+    public List<pushDataDep> getListDep() {
+        return listDep;
+    }
+
+    public void setListDep(List<pushDataDep> listDep) {
+        this.listDep = listDep;
+    }
+
+    public List<pushDataUser> getListUser() {
+        return listUser;
+    }
+
+    public void setListUser(List<pushDataUser> listUser) {
+        this.listUser = listUser;
+    }
+
+    public List<pushDataProject> getListUserClock() {
+        return listUserClock;
+    }
+
+    public void setListUserClock(List<pushDataProject> listUserClock) {
+        this.listUserClock = listUserClock;
+    }
+}

+ 101 - 0
ruoyi-system/src/main/java/com/ruoyi/project/bo/pushDataDep.java

@@ -0,0 +1,101 @@
+package com.ruoyi.project.bo;
+
+/**
+ *                 "deptId": 133,
+ *                 "parentId": 131,
+ *                 "ancestors": "0,100,131",
+ *                 "deptName": "研发服务中心",
+ *                 "orderNum": 1,
+ *                 "leader": null,
+ *                 "phone": null,
+ *                 "email": null,
+ *                 "status": "0",
+ *                 "delFlag": "0",
+ *                 "parentName": null,
+ *                 "maxDuration": 8,
+ *                 "companyId": 131,
+ *                 "companyName": "湖南科德信息咨询集团有限公司",
+ *                 "startTime": null,
+ *                 "endTime": null,
+ *                 "companyLogo": null,
+ *                 "companyFullName": null,
+ *                 "kyId": null,
+ *                 "usci": "91430105670766451M",
+ *                 "children": []
+ *
+ */
+public class pushDataDep {
+    private Long deptId;
+    private Long parentId;
+    private String ancestors;
+    private String deptName;
+    private Integer orderNum;
+    private String kyId;
+    private String kySuperId;
+    private String usci;
+
+    public String getKyId() {
+        return kyId;
+    }
+
+    public void setKyId(String kyId) {
+        this.kyId = kyId;
+    }
+
+    public String getKySuperId() {
+        return kySuperId;
+    }
+
+    public void setKySuperId(String kySuperId) {
+        this.kySuperId = kySuperId;
+    }
+
+    public Long getDeptId() {
+        return deptId;
+    }
+
+    public void setDeptId(Long deptId) {
+        this.deptId = deptId;
+    }
+
+    public Long getParentId() {
+        return parentId;
+    }
+
+    public void setParentId(Long parentId) {
+        this.parentId = parentId;
+    }
+
+    public String getAncestors() {
+        return ancestors;
+    }
+
+    public void setAncestors(String ancestors) {
+        this.ancestors = ancestors;
+    }
+
+    public String getDeptName() {
+        return deptName;
+    }
+
+    public void setDeptName(String deptName) {
+        this.deptName = deptName;
+    }
+
+    public Integer getOrderNum() {
+        return orderNum;
+    }
+
+    public void setOrderNum(Integer orderNum) {
+        this.orderNum = orderNum;
+    }
+
+    public String getUsci() {
+        return usci;
+    }
+
+    public void setUsci(String usci) {
+        this.usci = usci;
+    }
+}
+

+ 4 - 0
ruoyi-system/src/main/java/com/ruoyi/project/bo/pushDataProject.java

@@ -0,0 +1,4 @@
+package com.ruoyi.project.bo;
+
+public class pushDataProject {
+}

+ 4 - 0
ruoyi-system/src/main/java/com/ruoyi/project/bo/pushDataUser.java

@@ -0,0 +1,4 @@
+package com.ruoyi.project.bo;
+
+public class pushDataUser {
+}

+ 3 - 0
ruoyi-system/src/main/java/com/ruoyi/project/service/ProjectTaskService.java

@@ -3,6 +3,7 @@ package com.ruoyi.project.service;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.project.bo.ProjectListInput;
 import com.ruoyi.project.bo.ProjectTaskListOut;
+import com.ruoyi.project.bo.pushCompanyDataBo;
 import com.ruoyi.project.domain.ProjectTask;
 
 import javax.servlet.http.HttpServletResponse;
@@ -32,4 +33,6 @@ public interface ProjectTaskService {
     void saveText(String content) ;
 
     Object getCompanyData(String usci);
+
+    Object pushCompanyData(pushCompanyDataBo in);
 }

+ 51 - 3
ruoyi-system/src/main/java/com/ruoyi/project/service/impl/ProjectTaskServiceImpl.java

@@ -14,9 +14,7 @@ import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.bean.BeanUtils;
 import com.ruoyi.common.utils.bean.BeanValidators;
 import com.ruoyi.common.utils.file.FileUtils;
-import com.ruoyi.project.bo.ProjectListInput;
-import com.ruoyi.project.bo.ProjectTaskListOut;
-import com.ruoyi.project.bo.ProjectTaskOut;
+import com.ruoyi.project.bo.*;
 import com.ruoyi.project.domain.ProjectStaff;
 import com.ruoyi.project.domain.ProjectStaffRecord;
 import com.ruoyi.project.domain.ProjectTask;
@@ -46,6 +44,7 @@ import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.util.*;
+import java.util.stream.Collectors;
 import java.util.zip.ZipOutputStream;
 
 import static java.lang.Thread.sleep;
@@ -581,4 +580,53 @@ public class ProjectTaskServiceImpl   implements ProjectTaskService {
         return map;
     }
 
+    @Override
+    public Object pushCompanyData(pushCompanyDataBo in) {
+        //导入部门
+        if (!in.getListDep().isEmpty()){
+            List<pushDataDep> listDep = in.getListDep();
+            //假设只设置2级 1级为公司
+            List<pushDataDep> sp1 = listDep.stream().filter(e -> StringUtils.isNotEmpty(e.getUsci())).collect(Collectors.toList());
+            //先新增公司
+            pushDataDep pushDataDep = sp1.get(0);
+            SysDept sysDept1 = sysDeptMapper.selectByusci(pushDataDep.getUsci());
+            if (sysDept1!=null) throw new ServiceException("公司已存在");
+            SysDept sysDept=addCompany(pushDataDep);
+            pushDep(listDep, pushDataDep.getKyId(),sysDept);
+        }
+        return 1;
+    }
+
+    private void pushDep(List<pushDataDep> listDep, String kyId, SysDept pushDataDep) {
+        List<pushDataDep> sp2 = listDep.stream().filter(e ->
+                Objects.equals(e.getKySuperId(),kyId)).collect(Collectors.toList());
+        if (sp2.isEmpty()) {
+            return;
+        }
+        SysDept sysDept1 = sysDeptMapper.selectByKyId(kyId);
+        for (pushDataDep e : sp2) {
+            SysDept sysDept = new SysDept();
+            sysDept.setDeptName(e.getDeptName());
+            sysDept.setKyId(e.getKyId());
+            sysDept.setCompanyName(pushDataDep.getDeptName());
+            sysDept.setCompanyId(pushDataDep.getDeptId());
+            sysDept.setParentId(sysDept1.getDeptId());
+            sysDept.setAncestors(sysDept1.getAncestors()+","+sysDept1.getDeptId());
+            sysDeptMapper.insertDept(sysDept);
+            pushDep(listDep, e.getKyId(),pushDataDep);
+        }
+
+    }
+
+    private SysDept addCompany(pushDataDep pushDataDep) {
+            SysDept sysDept = new SysDept();
+            sysDept.setUsci(pushDataDep.getUsci());
+            sysDept.setDeptName(pushDataDep.getDeptName());
+            sysDept.setKyId(pushDataDep.getKyId());
+            sysDept.setParentId(100l);
+            sysDept.setAncestors("0,100");
+            sysDeptMapper.insertDept(sysDept);
+            return sysDept;
+    }
+
 }

+ 2 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java

@@ -123,4 +123,6 @@ public interface SysDeptMapper
     SysDept selectDeptByPid(Long id);
 
     SysDept selectByusci(String usci);
+
+    SysDept selectByKyId(String kyId);
 }

+ 6 - 3
ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml

@@ -121,9 +121,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 	</select>
 
 
-    <insert id="insertDept" parameterType="com.ruoyi.common.core.domain.entity.SysDept">
+    <insert id="insertDept" parameterType="com.ruoyi.common.core.domain.entity.SysDept"  useGeneratedKeys="true" keyProperty="deptId">
  		insert into sys_dept(
- 			<if test="deptId != null and deptId != 0">dept_id,</if>
  			<if test="parentId != null and parentId != 0">parent_id,</if>
  			<if test="deptName != null and deptName != ''">dept_name,</if>
  			<if test="ancestors != null and ancestors != ''">ancestors,</if>
@@ -142,7 +141,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 			<if test="usci != null ">usci,</if>
  			create_time
  		)values(
- 			<if test="deptId != null and deptId != 0">#{deptId},</if>
  			<if test="parentId != null and parentId != 0">#{parentId},</if>
  			<if test="deptName != null and deptName != ''">#{deptName},</if>
  			<if test="ancestors != null and ancestors != ''">#{ancestors},</if>
@@ -225,4 +223,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 	where d.del_flag = '0'
 	and d.usci = #{usci}
 	</select>
+	<select id="selectByKyId" resultMap="SysDeptResult">
+		<include refid="selectDeptVo"/>
+		where d.del_flag = '0'
+		and d.ky_id = #{kyId}
+	</select>
 </mapper>