ソースを参照

Merge remote-tracking branch 'origin/master'

Administrator 3 年 前
コミット
d40135335b

+ 31 - 1
boman-api/boman-domain/src/main/java/com.boman.domain/SysDept.java

@@ -50,7 +50,13 @@ public class SysDept extends BaseEntity
 
     /** 父部门名称 */
     private String parentName;
-    
+
+    private boolean listByParentId;
+
+    private boolean hasChildren = Boolean.TRUE;
+
+    private Integer num;
+
     /** 子部门 */
     private List<SysDept> children = new ArrayList<SysDept>();
 
@@ -178,6 +184,30 @@ public class SysDept extends BaseEntity
         this.children = children;
     }
 
+    public boolean isListByParentId() {
+        return listByParentId;
+    }
+
+    public void setListByParentId(boolean listByParentId) {
+        this.listByParentId = listByParentId;
+    }
+
+    public boolean isHasChildren() {
+        return hasChildren;
+    }
+
+    public void setHasChildren(boolean hasChildren) {
+        this.hasChildren = hasChildren;
+    }
+
+    public Integer getNum() {
+        return num;
+    }
+
+    public void setNum(Integer num) {
+        this.num = num;
+    }
+
     @Override
     public String toString() {
         return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

+ 12 - 3
boman-modules/boman-system/src/main/java/com/boman/system/controller/SysDeptController.java

@@ -39,10 +39,9 @@ public class SysDeptController extends BaseController
     /**
      * 获取部门列表
      */
-    @PreAuthorize(hasPermi = "system:dept:list")
+//    @PreAuthorize(hasPermi = "system:dept:list")
     @GetMapping("/list")
-    public AjaxResult list(SysDept dept)
-    {
+    public AjaxResult list(SysDept dept) {
         List<SysDept> depts = deptService.selectDeptList(dept);
         return AjaxResult.success(depts);
     }
@@ -109,6 +108,16 @@ public class SysDeptController extends BaseController
         return AjaxResult.success(deptService.buildDeptTreeSelect(depts));
     }
 
+    /**
+     * 获取部门下拉树列表
+     */
+    @GetMapping("/depts")
+    public AjaxResult depts(SysDept dept)
+    {
+        List<SysDept> depts = deptService.selectDepts(dept);
+        return AjaxResult.success(deptService.buildDeptTreeSelect(depts));
+    }
+
     /**
      * 加载对应角色部门列表树
      */

+ 3 - 0
boman-modules/boman-system/src/main/java/com/boman/system/mapper/SysDeptMapper.java

@@ -30,6 +30,9 @@ public interface SysDeptMapper
      */
     public List<Integer> selectDeptListById(@Param("id") Long id, @Param("deptCheckStrictly") boolean deptCheckStrictly);
 
+
+    public List<SysDept> validateHasChirld(@Param("depts") List<SysDept> depts);
+
     /**
      * 根据部门ID查询信息
      * 

+ 8 - 0
boman-modules/boman-system/src/main/java/com/boman/system/service/ISysDeptService.java

@@ -20,6 +20,14 @@ public interface ISysDeptService
      */
     public List<SysDept> selectDeptList(SysDept dept);
 
+    /**
+     * 查询部门管理数据
+     *
+     * @param dept 部门信息
+     * @return 部门信息集合
+     */
+    public List<SysDept> selectDepts(SysDept dept);
+
     /**
      * 构建前端所需要树结构
      * 

+ 40 - 5
boman-modules/boman-system/src/main/java/com/boman/system/service/impl/SysDeptServiceImpl.java

@@ -1,8 +1,6 @@
 package com.boman.system.service.impl;
 
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
+import java.util.*;
 import java.util.stream.Collectors;
 
 import com.boman.common.core.utils.obj.ObjectUtils;
@@ -42,8 +40,45 @@ public class SysDeptServiceImpl implements ISysDeptService
      */
     @Override
     @DataScope(deptAlias = "d")
-    public List<SysDept> selectDeptList(SysDept dept)
-    {
+    public List<SysDept> selectDeptList(SysDept dept) {
+        if(StringUtils.isNotEmpty(dept.getDeptName()) || StringUtils.isNotEmpty(dept.getStatus())) {
+            dept.setListByParentId(Boolean.TRUE);
+            return deptMapper.selectDeptList(dept);
+        }
+        Long id = dept.getId();
+        if(id == null) {
+            dept.setListByParentId(Boolean.FALSE);
+        }else{
+            dept.setListByParentId(Boolean.TRUE);
+            dept.setParentId(id);
+        }
+        List<SysDept> depts = deptMapper.selectDeptList(dept);
+        // 这里的逻辑是:根据id获取到这个下面的所有子部门,每个部门判断是否有下一级别
+        if(depts != null && depts.size() > 0) {
+            List<SysDept> hasChirlds = deptMapper.validateHasChirld(depts);
+            if(hasChirlds != null && hasChirlds.size() > 0) {
+                Map<Long, SysDept> hasChirldMap = new HashMap<>();
+                for (SysDept hasChirld : hasChirlds) {
+                    hasChirldMap.put(hasChirld.getId(), hasChirld);
+                }
+                for (SysDept sysDept : depts) {
+                    if(hasChirldMap.get(sysDept.getId()) == null) {
+                        sysDept.setHasChildren(Boolean.FALSE);
+                    }
+                }
+            }else {
+                for (SysDept sysDept : depts) {
+                    sysDept.setHasChildren(Boolean.FALSE);
+                }
+            }
+        }
+        return depts;
+    }
+
+    @Override
+    @DataScope(deptAlias = "d")
+    public List<SysDept> selectDepts(SysDept dept) {
+        dept.setListByParentId(Boolean.TRUE);
         return deptMapper.selectDeptList(dept);
     }
 

+ 12 - 0
boman-modules/boman-system/src/main/resources/mapper/system/SysDeptMapper.xml

@@ -16,6 +16,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		<result property="status"     column="status"      />
 		<result property="delFlag"    column="del_flag"    />
 		<result property="parentName" column="parent_name" />
+		<result property="num" column="num" />
 		<result property="createBy"   column="create_by"   />
 		<result property="createTime" column="create_time" />
 		<result property="updateBy"   column="update_by"   />
@@ -30,6 +31,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 	<select id="selectDeptList" parameterType="com.boman.domain.SysDept" resultMap="SysDeptResult">
         <include refid="selectDeptVo"/>
         where d.del_flag = '0'
+		<if test="listByParentId != null and listByParentId == false">
+			AND (parent_id is null or parent_id = 0)
+		</if>
         <if test="parentId != null and parentId != 0">
 			AND parent_id = #{parentId}
 		</if>
@@ -43,6 +47,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		${params.dataScope}
 		order by d.parent_id, d.order_num
     </select>
+
+	<select id="validateHasChirld" parameterType="java.util.List" resultMap="SysDeptResult">
+		SELECT a.id as id, count(1) as num FROM sys_dept a LEFT JOIN sys_dept b on a.id = b.parent_id WHERE b.parent_id in
+		<foreach collection="depts" item="dept" index="index" separator="," open="(" close=")">
+			#{dept.id}
+		</foreach>
+		GROUP BY a.id
+	</select>
     
     <select id="selectDeptListById" resultType="java.lang.Integer">
 		select d.id

+ 2 - 1
boman-web-core/src/main/java/com/boman/web/core/service/vaccineInfo/IVaccineInfoUserService.java

@@ -1,5 +1,6 @@
 package com.boman.web.core.service.vaccineInfo;
 
+import com.alibaba.fastjson.JSONObject;
 import com.boman.web.core.domain.VaccineInfoUser;
 
 import java.util.List;
@@ -25,5 +26,5 @@ public interface IVaccineInfoUserService {
     public List<VaccineInfoUser> selectInfoUserByIdCard(VaccineInfoUser vaccineInfoUser);
 
 
-    public void syncData() throws Exception;
+    public List<JSONObject> syncData() throws Exception;
 }

+ 42 - 52
boman-web-core/src/main/java/com/boman/web/core/service/vaccineInfo/impl/VaccineInfoUserServiceImpl.java

@@ -69,7 +69,7 @@ public class VaccineInfoUserServiceImpl implements IVaccineInfoUserService {
      * 接种情况(是/否)
      * 人群分类
      */
-    public void syncData222() throws Exception {
+  /*  public void syncData222() throws Exception {
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         // 获取疫苗信息,每次处理1000条
         int counts = syncMapper.selectCount("select count(1) from vaccine_info");
@@ -166,70 +166,53 @@ public class VaccineInfoUserServiceImpl implements IVaccineInfoUserService {
             count++;
             startPagte += 1000;
         }
-    }
+    }*/
 
 
     @Override
-    public void syncData() throws Exception {
-        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-
+    public List<JSONObject> syncData() throws Exception {
+        List<JSONObject> datas = new ArrayList<>();
         try{
-            // 获取疫苗信息,每次处理1000条
-            int counts = syncMapper.selectCount("select count(1) from vaccine_info");
-            int count = 1;
-//        int counts = 1;
-            int times = counts / 1000;
-            int startPagte = 0;
-            int endPage = 1000;
-
-            for (int i = 0; i < times + 1; i++) {
-                List<JSONObject> vaccInfos = this.getVaccInfo(startPagte, endPage);
-                // 身份证号码
-                List<String> idCards = new ArrayList<>();
-                Map<String, JSONObject> vannInfoMap = new HashMap<>();
-
-                Map<String, String> progressMap = new HashMap<>();
-                for (JSONObject vanninfo : vaccInfos) {
-                    String idcard = vanninfo.getString("id_card");
-                    JSONObject jsonObject = new JSONObject();
-                    jsonObject.put("id_card", idcard);
-                    progressMap.put(idcard, vanninfo.getString("progress"));
-                    vannInfoMap.put(idcard, jsonObject);
-                    idCards.add(idcard);
-                }
 
-                int secCount = 1;
-                // 查询疫苗是否完成
-                for (String icsard : idCards) {
-                    JSONObject update = vannInfoMap.get(icsard);
-                    JSONObject userInfo = this.getvaccUser(icsard);
-                    if (userInfo != null) {
-                        if(progressMap.get(icsard).equals("否")) {
-                            update.put("should_slow", "是");
-                        }else {
-                            update.put("should_slow", "否");
-                        }
-                        update.put("should_be", "否");
-                    } else {
+
+            List<JSONObject> jz = this.getvaccUser();
+            Map<String, JSONObject> vannInfoMap = new HashMap<>();
+
+            for (JSONObject jsonObject : jz) {
+                String idCard = jsonObject.getString("idCard");
+                JSONObject update = new JSONObject();
+                update.put("id_card", idCard);
+                vannInfoMap.put(idCard, update);
+            }
+            List<JSONObject> vaccInfos = this.getVaccInfo();
+            for (JSONObject vanninfo : vaccInfos) {
+                String idCard = vanninfo.getString("id_card");
+                JSONObject update = vannInfoMap.get(idCard);
+                String progress = vanninfo.getString("progress");
+                if(update == null) {
+                    update = new JSONObject();
+                    update.put("id_card", idCard);
+                    update.put("should_slow", "否");
+                    update.put("should_be", "是");
+                }else {
+                    if("否".equals(progress)) {
+                        update.put("should_slow", "是");
+                    }else {
                         update.put("should_slow", "否");
-                        update.put("should_be", "是");
                     }
-
-                    System.out.println("secCount: " + secCount);
-                    secCount++;
+                    update.put("should_be", "否");
                 }
-                this.updateData(new ArrayList(vannInfoMap.values()), count);
-                count++;
-                startPagte += 1000;
+                System.out.println(update.toJSONString());
+                datas.add(update);
             }
         }catch (Exception e) {
             e.printStackTrace();
         }
-
+        return datas;
     }
 
-    private List<JSONObject> getVaccInfo(int startPagte, int endPage) {
-        String sql = "select * from vaccine_info limit " + startPagte + ", " + endPage;
+    private List<JSONObject> getVaccInfo() {
+        String sql = "select id_card,progress from vaccine_info";
         List<JSONObject> objs = syncMapper.selectBySql(sql);
         return objs;
     }
@@ -248,7 +231,7 @@ public class VaccineInfoUserServiceImpl implements IVaccineInfoUserService {
         return objs;
     }
 
-    private JSONObject getvaccUser(String idcard) {
+    /*private JSONObject getvaccUser(String idcard) {
         String sql = "SELECT id,`接种日期` as v_date,`生产厂家` as prod,`接种针次` as jici, "
                 + " `人群分类` as crowd_classification, `接种单位` as vaccination_place," +
                 " `电话号码` as phone_num , `出生日期` as 'csrq', `工作单位` as work_unit,  `生产厂家` as manufacturer"
@@ -258,6 +241,13 @@ public class VaccineInfoUserServiceImpl implements IVaccineInfoUserService {
             return objs.get(0);
         }
         return null;
+    }*/
+
+    private List<JSONObject> getvaccUser() {
+        String sql = "SELECT `身份证` as idCard FROM ymjz ";
+        List<JSONObject> objs = syncMapper.selectBySql(sql);
+
+        return objs;
     }
 
     private String getTime(JSONObject userInfo, SimpleDateFormat sdf) throws Exception {