Browse Source

阿米巴开发

anderx 3 years ago
parent
commit
e2cb929938

+ 51 - 0
src/main/java/com/goafanti/ambSystem/bo/AmbAll.java

@@ -0,0 +1,51 @@
+package com.goafanti.ambSystem.bo;
+
+import java.util.List;
+
+public class AmbAll {
+    private Long id;
+    private String name;
+    private Integer lvl;
+    private Long parentId;
+    private List<AmbAll> list;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Integer getLvl() {
+        return lvl;
+    }
+
+    public void setLvl(Integer lvl) {
+        this.lvl = lvl;
+    }
+
+    public Long getParentId() {
+        return parentId;
+    }
+
+    public void setParentId(Long parentId) {
+        this.parentId = parentId;
+    }
+
+    public List<AmbAll> getList() {
+        return list;
+    }
+
+    public void setList(List<AmbAll> list) {
+        this.list = list;
+    }
+}

+ 54 - 1
src/main/java/com/goafanti/ambSystem/bo/OutAmb.java

@@ -2,5 +2,58 @@ package com.goafanti.ambSystem.bo;
 
 import com.goafanti.common.model.AmbSystem;
 
-public class OutAmb extends AmbSystem {
+
+public class OutAmb extends AmbSystem{
+    /**
+     * 部门id
+     */
+    private Long id;
+    private String name;
+    private String ancestorsNames;
+    private String leaderName;
+    private String  financeName;
+
+
+
+
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getAncestorsNames() {
+        return ancestorsNames;
+    }
+
+    public void setAncestorsNames(String ancestorsNames) {
+        this.ancestorsNames = ancestorsNames;
+    }
+
+    public String getLeaderName() {
+        return leaderName;
+    }
+
+    public void setLeaderName(String leaderName) {
+        this.leaderName = leaderName;
+    }
+
+    public String getFinanceName() {
+        return financeName;
+    }
+
+    public void setFinanceName(String financeName) {
+        this.financeName = financeName;
+    }
 }

+ 7 - 0
src/main/java/com/goafanti/ambSystem/controller/AmbApiController.java

@@ -51,4 +51,11 @@ public class AmbApiController extends CertifyApiController {
 		return res;
 	}
 
+	@RequestMapping(value="/selectAll",method = RequestMethod.GET)
+	public Result selectAll( ){
+		Result res =new Result();
+		res.data(ambService.selectAll());
+		return res;
+	}
+
 }

+ 4 - 0
src/main/java/com/goafanti/ambSystem/service/AmbService.java

@@ -3,10 +3,14 @@ package com.goafanti.ambSystem.service;
 import com.goafanti.ambSystem.bo.InputAmb;
 import com.goafanti.core.mybatis.page.Pagination;
 
+import java.util.List;
+
 public interface AmbService {
     int addAmb(InputAmb in);
 
     int updateAmb(InputAmb in);
 
     Pagination<?> selectAmb(InputAmb in);
+
+    List<?> selectAll();
 }

+ 32 - 6
src/main/java/com/goafanti/ambSystem/service/Impl/AmbServiceImpl.java

@@ -1,5 +1,6 @@
 package com.goafanti.ambSystem.service.Impl;
 
+import com.goafanti.ambSystem.bo.AmbAll;
 import com.goafanti.ambSystem.bo.InputAmb;
 import com.goafanti.ambSystem.bo.OutAmb;
 import com.goafanti.ambSystem.service.AmbService;
@@ -11,10 +12,7 @@ import com.goafanti.core.shiro.token.TokenManager;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.Arrays;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
+import java.util.*;
 
 @Service
 public class AmbServiceImpl extends BaseMybatisDao<AmbSystemMapper> implements AmbService {
@@ -55,12 +53,40 @@ public class AmbServiceImpl extends BaseMybatisDao<AmbSystemMapper> implements A
         return (Pagination<OutAmb>) findPage("selectAmbSystemList","selectAmbSystemCount",param,in.getPageNo(),in.getPageSize());
     }
 
+    @Override
+    public List<?> selectAll() {
+        List<AmbAll> list = ambSystemMapper.getAncestorsList(null);
+        List<AmbAll> all=new ArrayList<>();
+        for (AmbAll a : list) {
+            if (a.getLvl()==1){
+                pushLvl(a,list);
+                all.add(a);
+            }
+        }
+
+        return all;
+    }
+
+    private void pushLvl(AmbAll a , List<AmbAll> list) {
+        if (a.getLvl()<7){
+            List<AmbAll> all=new ArrayList<>();
+            for (AmbAll as : list) {
+                if (as.getLvl()>1 && as.getParentId().equals(a.getId())){
+                    pushLvl(as,list);
+                    all.add(as);
+                }
+            }
+            a.setList(all);
+        }
+
+    }
+
     private String getAncestorsNames(String ancestors) {
         String[] split = ancestors.split(",");
         List<String> list = Arrays.asList(split);
-        List<AmbSystem> ancestorsList = ambSystemMapper.getAncestorsList(list);
+        List<AmbAll> ancestorsList = ambSystemMapper.getAncestorsList(list);
         StringBuffer sb=new StringBuffer();
-        for (AmbSystem ambSystem : ancestorsList) {
+        for (AmbAll ambSystem : ancestorsList) {
             for (String s : list) {
                 if (!ambSystem.getId().toString().equals("1")){
                     if (ambSystem.getId().toString().equals(s)){

+ 3 - 1
src/main/java/com/goafanti/common/dao/AmbSystemMapper.java

@@ -1,5 +1,7 @@
 package com.goafanti.common.dao;
 
+import com.goafanti.ambSystem.bo.AmbAll;
+import com.goafanti.ambSystem.bo.OutAmb;
 import com.goafanti.common.model.AmbSystem;
 
 import java.util.List;
@@ -17,5 +19,5 @@ public interface AmbSystemMapper {
 
     int updateByPrimaryKey(AmbSystem record);
 
-    List<AmbSystem> getAncestorsList(List<String> list);
+    List<AmbAll> getAncestorsList(List<String> list);
 }

+ 42 - 2
src/main/java/com/goafanti/common/mapper/AmbSystemMapper.xml

@@ -191,12 +191,52 @@
     where id = #{id,jdbcType=BIGINT}
   </update>
 
-  <select id="getAncestorsList" resultType="com.goafanti.common.model.AmbSystem">
-    select id,name
+  <select id="getAncestorsList" resultType="com.goafanti.ambSystem.bo.AmbAll">
+    select id,name,lvl,parent_id parentId
     from amb_system
+    <if test="list !=null and list.size>0 ">
     where id in
     <foreach close=")" collection="list" item="id" open="(" separator=",">
       #{id}
     </foreach>
+  </if>
+  </select>
+
+  <select id="selectAmbSystemList" resultType="com.goafanti.ambSystem.bo.OutAmb">
+    select a.id,a.name ,a.ancestors_names ancestorsNames ,b.name leaderName,c.name financeName
+    from amb_system a
+    left join admin b on a.leader =b.id
+    left join admin c on a.finance_id =c.id
+    where a.status=0
+    <if test="lvl !=null">
+      and a.lvl= #{lvl}
+    </if>
+    <if test="name !=null">
+      and a.name  like concat('%',#{name},'%')
+    </if>
+    <if test="ancestors !=null">
+      and find_in_set( #{ancestors} ,a.ancestors)
+    </if>
+    order by id
+    <if test="page_sql !=null">
+      ${page_sql}
+    </if>
+  </select>
+
+  <select id="selectAmbSystemCount" resultType="java.lang.Integer">
+    select count(*)
+    from amb_system a
+    left join admin b on a.leader =b.id
+    left join admin c on a.finance_id =c.id
+    where a.status=0
+    <if test="lvl !=null">
+      and a.lvl= #{lvl}
+    </if>
+    <if test="name !=null">
+      and a.name  like concat('%',#{name},'%')
+    </if>
+    <if test="ancestors !=null">
+      and find_in_set( #{ancestors} ,a.ancestors)
+    </if>
   </select>
 </mapper>