浏览代码

fix 修改疫苗权限查询

Administrator 3 年之前
父节点
当前提交
e5a2e345b9

+ 8 - 0
boman-api/boman-api-system/src/main/java/com/boman/system/api/RemoteDeptService.java

@@ -35,5 +35,13 @@ public interface RemoteDeptService {
 
     @GetMapping("/dept/parentId/{parentId}")
     List<SysDept> getByParentId(@PathVariable("parentId") Long parentId);
+
+    /**
+     * 根据部门名称获取该用户属于哪一个部门(疫苗新增/修改时使用)
+     * @param deptName
+     * @return
+     */
+    @GetMapping("/dept/selectByDeptName/{deptName}")
+    List<SysDept> selectByDeptName(@PathVariable("deptName") String deptName);
 }
 

+ 18 - 0
boman-modules/boman-system/src/main/java/com/boman/system/controller/SysDeptController.java

@@ -52,6 +52,15 @@ public class SysDeptController extends BaseController
         return AjaxResult.success(depts);
     }
 
+    /**
+     * 获取部门列表
+     */
+    @GetMapping("/deptList")
+    public AjaxResult deptList(SysDept dept) {
+        List<SysDept> depts = deptService.selectDepts(dept);
+        return AjaxResult.success(depts);
+    }
+
     /**
      * 查询部门列表(排除节点)
      */
@@ -104,6 +113,15 @@ public class SysDeptController extends BaseController
         return deptService.selectDeptById(id);
     }
 
+    /**
+     * 根据部门名称获取该用户属于哪一个部门(疫苗新增/修改时使用)
+     */
+    @GetMapping(value = "/selectByDeptName/{deptName}")
+    public List<SysDept> selectByDeptName(@PathVariable("deptName") String deptName)
+    {
+        return deptService.selectByDeptName(deptName);
+    }
+
     /**
      * 获取部门下拉树列表
      */

+ 2 - 2
boman-modules/boman-system/src/main/java/com/boman/system/controller/SysUserController.java

@@ -143,7 +143,7 @@ public class SysUserController extends BaseController
         Set<String> permissions = permissionService.getMenuPermission(sysUser.getId());
 
         // todo
-        if (ObjectUtils.isNotEmpty(sysUser.getDeptId())) {
+/*        if (ObjectUtils.isNotEmpty(sysUser.getDeptId())) {
             // 当前人所在部门和下级部门的deptIdList
             List<SysDept> sysDepts = deptService.listChildrenDepts(sysUser.getDeptId());
             if (ObjectUtils.isNotEmpty(sysDepts)) {
@@ -159,7 +159,7 @@ public class SysUserController extends BaseController
                     sysUserVo.setSubDeptUserIds(getUserIds(childUsers));
                 }
             }
-        }
+        }*/
 
         sysUserVo.setSysUser(sysUser);
         sysUserVo.setRoles(roles);

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

@@ -41,6 +41,13 @@ public interface SysDeptMapper
      */
     public SysDept selectDeptById(Long id);
 
+    /**
+     * 根据部门名称查询信息
+     * @param deptName
+     * @return
+     */
+    public SysDept selectDeptByDeptName(String  deptName);
+
     /**
      * 根据ID查询所有子部门
      * 

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

@@ -61,6 +61,13 @@ public interface ISysDeptService
      */
     public SysDept selectDeptById(Long id);
 
+    /**
+     * 根据部门名称查询信息
+     * @param deptName
+     * @return
+     */
+    public List<SysDept> selectByDeptName(String deptName);
+
     /**
      * 根据ID查询所有子部门(正常状态)
      * 

+ 87 - 103
boman-modules/boman-system/src/main/java/com/boman/system/service/impl/SysDeptServiceImpl.java

@@ -26,12 +26,11 @@ import javax.annotation.Resource;
 
 /**
  * 部门管理 服务实现
- * 
+ *
  * @author ruoyi
  */
 @Service
-public class SysDeptServiceImpl implements ISysDeptService
-{
+public class SysDeptServiceImpl implements ISysDeptService {
     @Autowired
     private SysDeptMapper deptMapper;
 
@@ -40,39 +39,39 @@ public class SysDeptServiceImpl implements ISysDeptService
 
     /**
      * 查询部门管理数据
-     * 
+     *
      * @param dept 部门信息
      * @return 部门信息集合
      */
     @Override
     @DataScope(deptAlias = "d")
     public List<SysDept> selectDeptList(SysDept dept) {
-        if(StringUtils.isNotEmpty(dept.getDeptName()) || StringUtils.isNotEmpty(dept.getStatus())) {
+        if (StringUtils.isNotEmpty(dept.getDeptName()) || StringUtils.isNotEmpty(dept.getStatus())) {
             dept.setListByParentId(Boolean.TRUE);
             return deptMapper.selectDeptList(dept);
         }
         Long id = dept.getId();
-        if(id == null) {
+        if (id == null) {
             dept.setListByParentId(Boolean.FALSE);
-        }else{
+        } else {
             dept.setListByParentId(Boolean.TRUE);
             dept.setParentId(id);
         }
         List<SysDept> depts = deptMapper.selectDeptList(dept);
         // 这里的逻辑是:根据id获取到这个下面的所有子部门,每个部门判断是否有下一级别
-        if(depts != null && depts.size() > 0) {
+        if (depts != null && depts.size() > 0) {
             List<SysDept> hasChirlds = deptMapper.validateHasChirld(depts);
-            if(hasChirlds != null && hasChirlds.size() > 0) {
+            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) {
+                    if (hasChirldMap.get(sysDept.getId()) == null) {
                         sysDept.setHasChildren(Boolean.FALSE);
                     }
                 }
-            }else {
+            } else {
                 for (SysDept sysDept : depts) {
                     sysDept.setHasChildren(Boolean.FALSE);
                 }
@@ -90,31 +89,26 @@ public class SysDeptServiceImpl implements ISysDeptService
 
     /**
      * 构建前端所需要树结构
-     * 
+     *
      * @param depts 部门列表
      * @return 树结构列表
      */
     @Override
-    public List<SysDept> buildDeptTree(List<SysDept> depts)
-    {
+    public List<SysDept> buildDeptTree(List<SysDept> depts) {
         List<SysDept> returnList = new ArrayList<SysDept>();
         List<Long> tempList = new ArrayList<Long>();
-        for (SysDept dept : depts)
-        {
+        for (SysDept dept : depts) {
             tempList.add(dept.getId());
         }
-        for (Iterator<SysDept> iterator = depts.iterator(); iterator.hasNext();)
-        {
+        for (Iterator<SysDept> iterator = depts.iterator(); iterator.hasNext(); ) {
             SysDept dept = (SysDept) iterator.next();
             // 如果是顶级节点, 遍历该父节点的所有子节点
-            if (!tempList.contains(dept.getParentId()))
-            {
+            if (!tempList.contains(dept.getParentId())) {
                 recursionFn(depts, dept);
                 returnList.add(dept);
             }
         }
-        if (returnList.isEmpty())
-        {
+        if (returnList.isEmpty()) {
             returnList = depts;
         }
         return returnList;
@@ -122,93 +116,99 @@ public class SysDeptServiceImpl implements ISysDeptService
 
     /**
      * 构建前端所需要下拉树结构
-     * 
+     *
      * @param depts 部门列表
      * @return 下拉树结构列表
      */
     @Override
-    public List<TreeSelect> buildDeptTreeSelect(List<SysDept> depts)
-    {
+    public List<TreeSelect> buildDeptTreeSelect(List<SysDept> depts) {
         List<SysDept> deptTrees = buildDeptTree(depts);
         return deptTrees.stream().map(TreeSelect::new).collect(Collectors.toList());
     }
 
     /**
      * 根据角色ID查询部门树信息
-     * 
+     *
      * @param roleId 角色ID
      * @return 选中部门列表
      */
     @Override
-    public List<Integer> selectDeptListByRoleId(Long roleId)
-    {
+    public List<Integer> selectDeptListByRoleId(Long roleId) {
         SysRole role = roleMapper.selectRoleById(roleId);
         return deptMapper.selectDeptListById(roleId, role.isDeptCheckStrictly());
     }
 
     /**
      * 根据部门ID查询信息
-     * 
+     *
      * @param id 部门ID
      * @return 部门信息
      */
     @Override
-    public SysDept selectDeptById(Long id)
-    {
+    public SysDept selectDeptById(Long id) {
         return deptMapper.selectDeptById(id);
     }
 
+    /**
+     * 根据部门名称查询信息
+     *
+     * @param deptName
+     * @return
+     */
+    @Override
+    public List<SysDept> selectByDeptName(String deptName) {
+        SysDept sysDept = deptMapper.selectDeptByDeptName(deptName);
+        List<SysDept> sysDepts = listChildrenDepts(sysDept.getId());
+        sysDepts.add(sysDept);
+         return sysDepts;
+    }
+
     /**
      * 根据ID查询所有子部门(正常状态)
-     * 
+     *
      * @param id 部门ID
      * @return 子部门数
      */
     @Override
-    public int selectNormalChildrenDeptById(Long id)
-    {
+    public int selectNormalChildrenDeptById(Long id) {
         return deptMapper.selectNormalChildrenDeptById(id);
     }
 
     /**
      * 是否存在子节点
-     * 
+     *
      * @param id 部门ID
      * @return 结果
      */
     @Override
-    public boolean hasChildById(Long id)
-    {
+    public boolean hasChildById(Long id) {
         int result = deptMapper.hasChildById(id);
         return result > 0 ? true : false;
     }
 
     /**
      * 查询部门是否存在用户
-     * 
+     *
      * @param id 部门ID
      * @return 结果 true 存在 false 不存在
      */
     @Override
-    public boolean checkDeptExistUser(Long id)
-    {
+    public boolean checkDeptExistUser(Long id) {
         int result = deptMapper.checkDeptExistUser(id);
         return result > 0 ? true : false;
     }
 
     /**
      * 校验部门名称是否唯一
-     * 
+     *
      * @param dept 部门信息
      * @return 结果
      */
     @Override
-    public String checkDeptNameUnique(SysDept dept)
-    {
+    public String checkDeptNameUnique(SysDept dept) {
         Long id = StringUtils.isNull(dept.getId()) ? -1L : dept.getId();
         SysDept info = deptMapper.checkDeptNameUnique(dept.getDeptName(), dept.getParentId());
-        if (StringUtils.isNotNull(info) && info.getId().longValue() != id.longValue())
-        {
+        if (StringUtils.isNotNull(info) && info.getId().longValue() != id.longValue()) {
             return UserConstants.NOT_UNIQUE;
         }
         return UserConstants.UNIQUE;
@@ -216,17 +216,15 @@ public class SysDeptServiceImpl implements ISysDeptService
 
     /**
      * 新增保存部门信息
-     * 
+     *
      * @param dept 部门信息
      * @return 结果
      */
     @Override
-    public int insertDept(SysDept dept)
-    {
+    public int insertDept(SysDept dept) {
         SysDept info = deptMapper.selectDeptById(dept.getParentId());
         // 如果父节点不为正常状态,则不允许新增子节点
-        if (!UserConstants.DEPT_NORMAL.equals(info.getStatus()))
-        {
+        if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) {
             throw new CustomException("部门停用,不允许新增");
         }
         dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
@@ -235,25 +233,22 @@ public class SysDeptServiceImpl implements ISysDeptService
 
     /**
      * 修改保存部门信息
-     * 
+     *
      * @param dept 部门信息
      * @return 结果
      */
     @Override
-    public int updateDept(SysDept dept)
-    {
+    public int updateDept(SysDept dept) {
         SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId());
         SysDept oldDept = deptMapper.selectDeptById(dept.getId());
-        if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept))
-        {
+        if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept)) {
             String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getId();
             String oldAncestors = oldDept.getAncestors();
             dept.setAncestors(newAncestors);
             updateDeptChildren(dept.getId(), newAncestors, oldAncestors);
         }
         int result = deptMapper.updateDept(dept);
-        if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()))
-        {
+        if (UserConstants.DEPT_NORMAL.equals(dept.getStatus())) {
             // 如果该部门是启用状态,则启用该部门的所有上级部门
             updateParentDeptStatus(dept);
         }
@@ -262,11 +257,10 @@ public class SysDeptServiceImpl implements ISysDeptService
 
     /**
      * 修改该部门的父级部门状态
-     * 
+     *
      * @param dept 当前部门
      */
-    private void updateParentDeptStatus(SysDept dept)
-    {
+    private void updateParentDeptStatus(SysDept dept) {
         String updateBy = dept.getUpdateBy();
         dept = deptMapper.selectDeptById(dept.getId());
         dept.setUpdateBy(updateBy);
@@ -275,48 +269,41 @@ public class SysDeptServiceImpl implements ISysDeptService
 
     /**
      * 修改子元素关系
-     * 
-     * @param id 被修改的部门ID
+     *
+     * @param id           被修改的部门ID
      * @param newAncestors 新的父ID集合
      * @param oldAncestors 旧的父ID集合
      */
-    public void updateDeptChildren(Long id, String newAncestors, String oldAncestors)
-    {
+    public void updateDeptChildren(Long id, String newAncestors, String oldAncestors) {
         List<SysDept> children = deptMapper.selectChildrenDeptById(id);
-        for (SysDept child : children)
-        {
+        for (SysDept child : children) {
             child.setAncestors(child.getAncestors().replace(oldAncestors, newAncestors));
         }
-        if (children.size() > 0)
-        {
+        if (children.size() > 0) {
             deptMapper.updateDeptChildren(children);
         }
     }
 
     /**
      * 删除部门管理信息
-     * 
+     *
      * @param id 部门ID
      * @return 结果
      */
     @Override
-    public int deleteDeptById(Long id)
-    {
+    public int deleteDeptById(Long id) {
         return deptMapper.deleteDeptById(id);
     }
 
     /**
      * 递归列表
      */
-    private void recursionFn(List<SysDept> list, SysDept t)
-    {
+    private void recursionFn(List<SysDept> list, SysDept t) {
         // 得到子节点列表
         List<SysDept> childList = getChildList(list, t);
         t.setChildren(childList);
-        for (SysDept tChild : childList)
-        {
-            if (hasChild(list, tChild))
-            {
+        for (SysDept tChild : childList) {
+            if (hasChild(list, tChild)) {
                 recursionFn(list, tChild);
             }
         }
@@ -325,15 +312,12 @@ public class SysDeptServiceImpl implements ISysDeptService
     /**
      * 得到子节点列表
      */
-    private List<SysDept> getChildList(List<SysDept> list, SysDept t)
-    {
+    private List<SysDept> getChildList(List<SysDept> list, SysDept t) {
         List<SysDept> tlist = new ArrayList<SysDept>();
         Iterator<SysDept> it = list.iterator();
-        while (it.hasNext())
-        {
+        while (it.hasNext()) {
             SysDept n = (SysDept) it.next();
-            if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getId().longValue())
-            {
+            if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getId().longValue()) {
                 tlist.add(n);
             }
         }
@@ -343,8 +327,7 @@ public class SysDeptServiceImpl implements ISysDeptService
     /**
      * 判断是否有子节点
      */
-    private boolean hasChild(List<SysDept> list, SysDept t)
-    {
+    private boolean hasChild(List<SysDept> list, SysDept t) {
         return getChildList(list, t).size() > 0;
     }
 
@@ -382,7 +365,7 @@ public class SysDeptServiceImpl implements ISysDeptService
     @Override
     public List<JSONObject> syncData() throws Exception {
         List<JSONObject> datas = new ArrayList<>();
-        try{
+        try {
             SysDept sysDept = new SysDept();
             // 所有层级数据
             List<TreeSelect> depts = this.getDepts(sysDept);
@@ -401,7 +384,7 @@ public class SysDeptServiceImpl implements ISysDeptService
             for (TreeSelect treeSelect : villegeDept) {
                 String deptName = treeSelect.getLabel();
                 Long deptId = treeSelect.getId();
-                if(villegeMap.containsKey(deptName)) {
+                if (villegeMap.containsKey(deptName)) {
                     System.out.println(deptName);
                 }
                 villegeMap.put(deptName, deptId);
@@ -415,14 +398,14 @@ public class SysDeptServiceImpl implements ISysDeptService
                 update.put("id_card", idCard);
                 // 先判断村数据是否存在,如果村存在,则直接获取村的id,反之获取乡镇id
                 Long deptId = this.getVillegeDeptId(dz, villegeMap, repeatVillageMap);
-                if(deptId == null) {
+                if (deptId == null) {
                     deptId = this.getRegionDeptId(dz, regionMap);
                 }
                 update.put("dept_id", deptId);
                 System.out.println(update.toJSONString());
                 datas.add(update);
             }
-        }catch (Exception e) {
+        } catch (Exception e) {
             e.printStackTrace();
         }
         return datas;
@@ -449,17 +432,17 @@ public class SysDeptServiceImpl implements ISysDeptService
         List<TreeSelect> villegs = new ArrayList<>();
         List<TreeSelect> regions = depts.get(0).getChildren();
         for (TreeSelect region : regions) {
-            if(region.getLabel().equals("王河镇") || region.getLabel().equals("五庙乡")
-                    || region.getLabel().equals("黄铺镇") || region.getLabel().equals("水吼镇") ) {
+            if (region.getLabel().equals("王河镇") || region.getLabel().equals("五庙乡")
+                    || region.getLabel().equals("黄铺镇") || region.getLabel().equals("水吼镇")) {
                 List<TreeSelect> vills = region.getChildren();
                 for (TreeSelect vill : vills) {
-                    if(vill.getLabel().equals("和平村") || vill.getLabel().equals("红光村")) {
+                    if (vill.getLabel().equals("和平村") || vill.getLabel().equals("红光村")) {
                         repeatVillageMap.put(region.getLabel() + vill.getLabel(), vill.getId());
-                    }else{
+                    } else {
                         villegs.add(vill);
                     }
                 }
-            }else {
+            } else {
                 villegs.addAll(region.getChildren());
             }
 
@@ -470,7 +453,7 @@ public class SysDeptServiceImpl implements ISysDeptService
 
     private Long getRegionDeptId(String dz, Map<String, Long> villegeMap) {
         for (String deptName : villegeMap.keySet()) {
-            if(dz.contains(deptName)) {
+            if (dz.contains(deptName)) {
                 return villegeMap.get(deptName);
             }
         }
@@ -478,20 +461,20 @@ public class SysDeptServiceImpl implements ISysDeptService
 
     }
 
-    private Long getVillegeDeptId(String dz, Map<String, Long> villegeMap, Map<String, Long>  repeatVillageMap) {
-        if(dz.contains("和平村") || dz.contains("红光村")) {
-            if(dz.contains("黄铺镇" + "和平村")) {
+    private Long getVillegeDeptId(String dz, Map<String, Long> villegeMap, Map<String, Long> repeatVillageMap) {
+        if (dz.contains("和平村") || dz.contains("红光村")) {
+            if (dz.contains("黄铺镇" + "和平村")) {
                 return repeatVillageMap.get("黄铺镇" + "和平村");
-            }else if(dz.contains("水吼镇" + "和平村")){
+            } else if (dz.contains("水吼镇" + "和平村")) {
                 return repeatVillageMap.get("水吼镇" + "和平村");
-            }else if(dz.contains("王河镇" + "红光村")) {
+            } else if (dz.contains("王河镇" + "红光村")) {
                 return repeatVillageMap.get("王河镇" + "红光村");
-            }else if(dz.contains("五庙乡" + "红光村")){
+            } else if (dz.contains("五庙乡" + "红光村")) {
                 return repeatVillageMap.get("五庙乡" + "红光村");
             }
-        }else{
+        } else {
             for (String deptName : villegeMap.keySet()) {
-                if(dz.contains(deptName)) {
+                if (dz.contains(deptName)) {
                     return villegeMap.get(deptName);
                 }
             }
@@ -500,6 +483,7 @@ public class SysDeptServiceImpl implements ISysDeptService
         return null;
 
     }
+
     @Override
     public List<SysDept> getByParentId(Long deptId) {
         if (null == deptId || deptId <= 0) {

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

@@ -71,6 +71,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		<include refid="selectDeptVo"/>
 		where id = #{id}
 	</select>
+
+	<select id="selectDeptByDeptName" parameterType="String" resultMap="SysDeptResult">
+		<include refid="selectDeptVo"/>
+		where d.del_flag = '0' and dept_name like concat('%', #{deptName}, '%')
+	</select>
     
     <select id="checkDeptExistUser" parameterType="Long" resultType="int">
 		select count(1) from sys_user where id = #{id} and del_flag = '0'

+ 3 - 1
boman-web-core/src/main/java/com/boman/web/core/controller/AdministrativeInfoController.java

@@ -1,6 +1,7 @@
 package com.boman.web.core.controller;
 
 import com.boman.common.core.utils.SecurityUtils;
+import com.boman.common.datascope.annotation.DataScope;
 import com.boman.domain.SysDept;
 import com.boman.domain.dto.AjaxResult;
 import com.boman.web.core.domain.AdministrativeInfo;
@@ -24,9 +25,10 @@ public class AdministrativeInfoController {
     @Resource
     private AdministrativeInfoService administrativeInfoService;
     /**
-     * 获取乡镇列表
+     * 获取乡镇列表,其实就是部门列表
      */
     @GetMapping("/treeSelect")
+    @DataScope(deptAlias = "d")
     public AjaxResult treeSelect(AdministrativeInfo administrativeInfo)
     {
         List<AdministrativeInfo> administrativeInfos = administrativeInfoService.selectAdministrativeInfoList(administrativeInfo);

+ 1 - 1
boman-web-core/src/main/java/com/boman/web/core/controller/VaccineInfoController.java

@@ -9,6 +9,7 @@ import com.boman.common.core.utils.StringUtils;
 import com.boman.common.core.utils.poi.ExcelUtil;
 import com.boman.common.core.web.controller.BaseController;
 import com.boman.common.core.web.page.TableDataInfo;
+import com.boman.common.datascope.annotation.DataScope;
 import com.boman.common.log.annotation.Log;
 import com.boman.common.log.enums.BusinessType;
 import com.boman.common.security.annotation.PreAuthorize;
@@ -50,7 +51,6 @@ public class VaccineInfoController extends BaseController {
 //    @PreAuthorize(hasPermi = "@ss.hasPermi('core:info:list')")
     @GetMapping("/list")
     public TableDataInfo list(VaccineInfoOperation vaccineInfo) {
-        startPage();
         List<VaccineInfoOperation> list = vaccineInfoService.selectVaccineInfoList(vaccineInfo);
         return getDataTable(list);
     }

+ 26 - 0
boman-web-core/src/main/java/com/boman/web/core/domain/VaccineInfoOperation.java

@@ -250,6 +250,32 @@ public class VaccineInfoOperation extends BaseEntity {
      * 查询用的身份证集合
      */
     private List<String> idCardS;
+    /**
+     * 部门id
+     */
+    private Long deptId;
+
+    /**
+     * 部门id集合
+     */
+    private List<Long> deptIdList;
+
+
+    public List<Long> getDeptIdList() {
+        return deptIdList;
+    }
+
+    public void setDeptIdList(List<Long> deptIdList) {
+        this.deptIdList = deptIdList;
+    }
+
+    public Long getDeptId() {
+        return deptId;
+    }
+
+    public void setDeptId(Long deptId) {
+        this.deptId = deptId;
+    }
 
     public String getSuspendUrl() {
         return suspendUrl;

+ 74 - 78
boman-web-core/src/main/java/com/boman/web/core/service/vaccineInfo/impl/VaccineInfoServiceImpl.java

@@ -7,6 +7,10 @@ import com.boman.common.core.utils.SecurityUtils;
 import com.boman.common.core.utils.StringUtils;
 import com.boman.common.core.utils.number.NumberUtils;
 import com.boman.common.core.utils.obj.ObjectUtils;
+import com.boman.common.core.utils.sql.SqlUtil;
+import com.boman.common.core.web.page.PageDomain;
+import com.boman.common.core.web.page.TableSupport;
+import com.boman.common.datascope.annotation.DataScope;
 import com.boman.domain.SysDept;
 import com.boman.domain.dto.AjaxResult;
 import com.boman.system.api.RemoteDeptService;
@@ -20,6 +24,7 @@ import com.boman.web.core.service.vaccineInfo.IVaccineInfoService;
 import com.boman.web.core.service.vaccineInfo.IVaccineInfoUserService;
 import com.boman.web.core.utils.AuthUtils;
 import com.boman.web.core.utils.VaccineUtils;
+import com.github.pagehelper.PageHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
@@ -27,6 +32,8 @@ import org.springframework.transaction.annotation.Isolation;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.Size;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
@@ -101,6 +108,8 @@ public class VaccineInfoServiceImpl implements IVaccineInfoService {
      */
     @Override
     public List<VaccineInfoOperation> selectVaccineInfoList(VaccineInfoOperation vaccineInfoOperation) {
+        Long deptId = AuthUtils.getLoginUser().getSysUser().getDeptId();
+        vaccineInfoOperation.setDeptId(deptId);
         Map<String, Object> params = vaccineInfoOperation.getParams();
         if (params != null) {
             Object age = params.get("age");
@@ -114,12 +123,6 @@ public class VaccineInfoServiceImpl implements IVaccineInfoService {
                 }
             }
         }
-        //疫苗名称
-        String vaccineName = vaccineInfoOperation.getVaccineName();
-        //计次
-        String jici = vaccineInfoOperation.getJici();
-        //接种时间
-        Date vaccinationTime = vaccineInfoOperation.getVaccinationTime();
         //接种地点
         String vaccinationPlace = vaccineInfoOperation.getVaccinationPlace();
         List<String> idCardS = new ArrayList<>();
@@ -132,17 +135,31 @@ public class VaccineInfoServiceImpl implements IVaccineInfoService {
                 flag = false;
             }
             vaccineInfoOperation.setIdCardS(idCardS);
-
         }
 
         //如果查询条件查询疫苗表且没数据,就不要查询主表
         List<VaccineInfoOperation> vaccineInfoOperations = new ArrayList<>();
         if (flag) {
-            setAddrCondition(vaccineInfoOperation);
+            //setAddrCondition(vaccineInfoOperation);
+            //设置分页
+            PageDomain pageDomain = TableSupport.buildPageRequest();
+            Integer pageNum = pageDomain.getPageNum();
+            Integer pageSize = pageDomain.getPageSize();
+            if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) {
+                String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
+                PageHelper.startPage(pageNum, pageSize, orderBy);
+            }
+            List<SysDept> sysDepts = remoteDeptService.listChildrenDepts(deptId);
+            List<Long> deptIdList = new ArrayList<>();
+            if(sysDepts != null && sysDepts.size() > 0){
+                for (SysDept sysDept : sysDepts) {
+                    Long id = sysDept.getId();
+                    deptIdList.add(id);
+                }
+            }
+            vaccineInfoOperation.setDeptIdList(deptIdList);
             vaccineInfoOperations = vaccineInfoMapper.selectVaccineInfoList(vaccineInfoOperation);
         }
-
-
         if (vaccineInfoOperations != null && vaccineInfoOperations.size() > 0) {
             for (VaccineInfoOperation infoOperation : vaccineInfoOperations) {
                 //省
@@ -160,14 +177,18 @@ public class VaccineInfoServiceImpl implements IVaccineInfoService {
                 //户籍地
                 String domicile = infoOperation.getDomicile();
                 StringBuilder sbDomicile = new StringBuilder();
+                StringBuilder sbNowIn = new StringBuilder();
                 if (StringUtils.isNotBlank(province)) {
                     sbDomicile.append(province);
+                    sbNowIn.append(province);
                 }
                 if (StringUtils.isNotBlank(city)) {
                     sbDomicile.append(city);
+                    sbNowIn.append(city);
                 }
                 if (StringUtils.isNotBlank(region)) {
                     sbDomicile.append(region);
+                    sbNowIn.append(region);
                 }
                 if (StringUtils.isNotBlank(domicile)) {
                     sbDomicile.append(domicile);
@@ -175,8 +196,6 @@ public class VaccineInfoServiceImpl implements IVaccineInfoService {
                 infoOperation.setDomicileSelect(sbDomicile.toString());
                 //现居地
                 String nowIn = infoOperation.getNowIn();
-                StringBuilder sbNowIn = new StringBuilder();
-                sbNowIn.append(province).append(city).append(region);
                 if (StringUtils.isNotBlank(nowIn)) {
                     sbNowIn.append(nowIn);
                 }
@@ -217,6 +236,7 @@ public class VaccineInfoServiceImpl implements IVaccineInfoService {
 
     /**
      * 放查询地址
+     *
      * @param vaccineInfoOperation
      */
     private void setAddrCondition(VaccineInfoOperation vaccineInfoOperation) {
@@ -227,6 +247,7 @@ public class VaccineInfoServiceImpl implements IVaccineInfoService {
         vaccineInfoOperation.setVillageTowns(deptName);
     }
 
+    //下一针接种 时间
     private Date vaccinationTimeNext(Date vaccinationTime, String vaccineNameLast) {
         Date date = new Date();
         if ("北京科兴中维".equals(vaccineNameLast)) {
@@ -267,6 +288,8 @@ public class VaccineInfoServiceImpl implements IVaccineInfoService {
         if (vaccineInfoOperationOld == null || vaccineInfoOperationOld.getId() == null) {
             // 疫苗信息
 //        genNowIn(vaccineInfoOperation);
+            Long deptId = getDeptId(vaccineInfoOperation);
+            vaccineInfoOperation.setDeptId(deptId);
             vaccineInfoOperation.setCreateTime(DateUtils.getNowDate());
             //提取出用户接种疫苗信息列表
             List<VaccineInfoUser> vaccineInfoUserList = vaccineInfoOperation.getVaccineInfoUserList();
@@ -332,76 +355,47 @@ public class VaccineInfoServiceImpl implements IVaccineInfoService {
             return rows > 0 ? AjaxResult.success() : AjaxResult.error();
         } else {
             return AjaxResult.error("该用户信息已存在,请勿重复添加");
-/*
-// 暂时不用,勿删
-                //查询出来的用户疫苗信息
-            List<VaccineInfoUser> vaccineInfoUserListOld = vaccineInfoOperationOld.getVaccineInfoUserList();
-            String jiCiOld = vaccineInfoOperationOld.getJici();
-            String vaccineNameOld = vaccineInfoOperationOld.getVaccineName();
-            Date vaccinationTime = vaccineInfoOperationOld.getVaccinationTime();
-            //组装一个map
-            Map<String, Object> map = new HashMap<>();
-            if (vaccineInfoUserListOld != null && vaccineInfoUserListOld.size() > 0) {
-                for (VaccineInfoUser infoUser : vaccineInfoUserListOld) {
-                    //原始的疫苗信息
-                    map.put(infoUser.getVaccineName() + infoUser.getJici(), infoUser);
-                }
-            }
-            //提取出用户接种疫苗信息列表
-            List<VaccineInfoUser> vaccineInfoUserList = vaccineInfoOperation.getVaccineInfoUserList();
-            String isVaccination = vaccineInfoOperation.getIsVaccination();
-            if (!"否".equals(isVaccination)) {
-                if (vaccineInfoUserList != null && vaccineInfoUserList.size() > 0) {
-                    for (VaccineInfoUser vaccineInfoUser : vaccineInfoUserList) {
-                        //新增的疫苗信息
-                        String vaccineName = vaccineInfoUser.getVaccineName();
-                        String jici = vaccineInfoUser.getJici();
-                        Object vaccineInfoUserMap = map.get(vaccineName + jici);
-                        if (ObjectUtils.isEmpty(vaccineInfoUserMap)) {
-                            //说明没有,则新增
-                            if (StringUtils.isNotBlank(vaccineInfoUser.getVaccineName()) || vaccineInfoUser.getVaccinationTime() != null || StringUtils.isNotBlank(vaccineInfoUser.getVaccinationPlace()) || StringUtils.isNotBlank(vaccineInfoUser.getJici()) || StringUtils.isNotBlank(vaccineInfoUser.getProgress())) {
-                                if (vaccinationTime == null) {
-                                    vaccinationTime = vaccineInfoUser.getVaccinationTime();
-                                } else if (vaccineInfoUser.getVaccinationTime() != null && vaccineInfoUser.getVaccinationTime().compareTo(vaccinationTime) > 0) {
-                                    vaccinationTime = vaccineInfoUser.getVaccinationTime();
-                                }
-                                if (StringUtils.isBlank(jiCiOld)) {
-                                    jiCiOld = vaccineInfoUser.getJici();
-                                }
-                                if (StringUtils.isBlank(vaccineNameOld)) {
-                                    vaccineNameOld = vaccineInfoUser.getVaccineName();
-                                }
-                                //剂次可能是 "加强针"
-                                if (isNumeric(jici) && isNumeric(jiCiOld)) {
-                                    if (Integer.parseInt(jici) > Integer.parseInt(jiCiOld)) {
-                                        jiCiOld = vaccineInfoUser.getJici();
-                                        vaccineNameOld = vaccineInfoUser.getVaccineName();
+        }
+    }
+
+    //查询修改的时候,匹配出人员的部门
+    private Long getDeptId(VaccineInfoOperation vaccineInfoOperation) {
+        //乡镇
+        String villageTowns = vaccineInfoOperation.getVillageTowns();
+        List<SysDept> sysDepts = remoteDeptService.selectByDeptName(villageTowns);
+        //村居
+        String village = vaccineInfoOperation.getVillage();
+        //村民组(社区)
+        String villagerGroup = vaccineInfoOperation.getVillagerGroup();
+        Long deptId = null;
+        if (sysDepts != null && sysDepts.size() > 0) {
+            if (StringUtils.isNotBlank(village)) {
+                for (SysDept sysDept : sysDepts) {
+                    String deptName = sysDept.getDeptName();
+                    if (village.equals(deptName)) {
+                        if (StringUtils.isNotBlank(villagerGroup)) {
+                                for (SysDept child : sysDepts) {
+                                    String deptNameChild = child.getDeptName();
+                                    if (villagerGroup.equals(deptNameChild)) {
+                                        deptId = child.getId();
+                                        return deptId;
                                     }
-                                } else if (!isNumeric(jici)) {
-                                    jiCiOld = vaccineInfoUser.getJici();
-                                    vaccineNameOld = vaccineInfoUser.getVaccineName();
                                 }
-                                vaccineInfoUser.setIdCard(vaccineInfoOperationOld.getIdCard());
-                                vaccineInfoUser.setCreateBy(SecurityUtils.getUsername());
-                                vaccineInfoUserMapper.insertVaccineInfoUser(vaccineInfoUser);
-                            }
+
+                        }else {
+                            deptId = sysDept.getId();
                         }
                     }
                 }
+            }else {
+                for (SysDept sysDept : sysDepts) {
+                    if (villageTowns.equals(sysDept.getDeptName())){
+                        deptId = sysDept.getId();
+                    }
+                }
             }
-            //是否完成
-            String isSuccess = getIsSuccess(vaccineNameOld, jiCiOld);
-            vaccineInfoOperationOld.setVaccineName(vaccineNameOld);
-            vaccineInfoOperationOld.setJici(jiCiOld);
-            vaccineInfoOperationOld.setVaccinationTime(vaccinationTime);
-            vaccineInfoOperation.setProgress(isSuccess);
-            vaccineInfoMapper.updateVaccineInfo(vaccineInfoOperationOld);
-            VaccineInfoOperation vaccineInfoOperation1 = vaccineInfoMapper.selectVaccineInfoById(vaccineInfoOperationOld.getId());
-            //判断应续未续
-            VaccineInfoOperation vaccineInfoOperationNew = shouldSlow(vaccineInfoOperation1);
-            int rows = vaccineInfoMapper.updateVaccineInfo(vaccineInfoOperationNew);
-            return rows > 0 ? AjaxResult.success() : AjaxResult.error();*/
         }
+        return deptId;
     }
 
 
@@ -466,7 +460,7 @@ public class VaccineInfoServiceImpl implements IVaccineInfoService {
     }
 
     /**
-     * 判断用户应种未种:就是有禁忌症或者暂缓接种的,应续未续
+     * 判断用户应种未种:就是没有有禁忌症或者暂缓接种的,应续未续
      *
      * @param vaccineInfoOperation
      * @return
@@ -546,6 +540,8 @@ public class VaccineInfoServiceImpl implements IVaccineInfoService {
         } else {
             neetUpdate = true;
         }
+        Long deptId = getDeptId(vaccineInfo);
+        vaccineInfo.setDeptId(deptId);
 
         vaccineInfo.setUpdateTime(DateUtils.getNowDate());
 //        genNowIn(vaccineInfo);
@@ -925,13 +921,13 @@ public class VaccineInfoServiceImpl implements IVaccineInfoService {
                     drjzs++;
                     if ("2".equals(info.getJici())) {
                         dez++;
-                    } else  if ("3".equals(info.getJici())) {
+                    } else if ("3".equals(info.getJici())) {
                         dsz++;
                     }
                 }
 
                 // 接种时间和接种疫苗种类判断 当日任务数
-                if (null != vaccinationTime){
+                if (null != vaccinationTime) {
                     String vaccineName = info.getVaccineName();
                     judgeTodayTask(vaccineName, vaccinationTime, drrws, todayStart, todayEnd);
                 }

+ 4 - 3
boman-web-core/src/main/resources/mapper/AdministrativeInfoMapper.xml

@@ -19,23 +19,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectAdministrativeInfoVo">
-        select id,parent_id, administrative_name, status, create_by, create_time, update_by, update_time, is_del,remark from sys_administrative_info
+        select id,parent_id, dept_name as  administrative_name, status, create_by, create_time, update_by, update_time from sys_dept
     </sql>
 
     <select id="selectAdministrativeInfoList" parameterType="com.boman.web.core.domain.AdministrativeInfo" resultMap="AdministrativeInfoResult">
         <include refid="selectAdministrativeInfoVo"/>
         <where>
-         is_del = 'N'
+            del_flag = '0'
         <if test="parentId != null and parentId != 0">
             AND parent_id = #{parentId}
         </if>
         <if test="administrativeName != null and administrativeName != ''">
-            AND administrative_name like concat('%', #{administrativeName}, '%')
+            AND dept_name like concat('%', #{administrativeName}, '%')
         </if>
         <if test="status != null and status != ''">
             AND status = #{status}
         </if>
         </where>
+        ${params.dataScope}
         order by parent_id, order_num
     </select>
 </mapper>

+ 13 - 3
boman-web-core/src/main/resources/mapper/VaccineInfoMapper.xml

@@ -46,6 +46,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="shouldSlow"    column="should_slow"    />
         <result property="vaccinationTime"    column="vaccination_time"    />
         <result property="progress"    column="progress"    />
+        <result property="deptId"    column="dept_id"    />
         <collection  property="vaccineInfoUserList"   javaType="java.util.List"        resultMap="VaccineInfoUser" />
     </resultMap>
 
@@ -66,7 +67,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         vi.region, vi.user_name, vi.gender, vi.id_card, vi.phone_num, vi.key_industries, vi.is_vaccination, vi.vaccine_name, vi.jici,
         vi.vaccination_time, vi.vaccination_place, vi.contraindication, vi.suspend,vi.suspend_url,vi.other_url,vi.vaccination_time,
         vi.should_be, vi.other, vi.progress, vi.remark, vi.status, vi.create_by, vi.create_time, vi.update_by, vi.update_time,
-               vi.is_del,vi.code,vi.birthday,vi.work_unit,vi.crowd_classification,vi.manufacturer,vi.now_in,vi.url,
+               vi.is_del,vi.code,vi.birthday,vi.work_unit,vi.crowd_classification,vi.manufacturer,vi.now_in,vi.url,vi.dept_id,
 
                viu.id as id_user,viu.id_card as id_card_user,viu.vaccine_name as vaccine_name_user,viu.jici as jici_user,viu.vaccination_time as vaccination_time_user,
                viu.vaccination_place as vaccination_place_user,viu.progress as progress_user,viu.status as status_user,viu.url as url_user
@@ -79,11 +80,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         vi.region, vi.user_name, vi.gender, vi.id_card, vi.phone_num, vi.key_industries, vi.is_vaccination, vi.vaccine_name, vi.jici,
         vi.vaccination_time, vi.vaccination_place, vi.contraindication, vi.suspend,vi.suspend_url,vi.other_url,vi.vaccination_time,
         vi.should_be, vi.other, vi.progress, vi.remark, vi.status, vi.create_by, vi.create_time, vi.update_by, vi.update_time,
-        vi.is_del,vi.code,vi.birthday,vi.work_unit,vi.crowd_classification,vi.manufacturer,vi.now_in,vi.url from vaccine_info vi
+        vi.is_del,vi.code,vi.birthday,vi.work_unit,vi.crowd_classification,vi.manufacturer,vi.now_in,vi.url,vi.dept_id from vaccine_info vi
         <where>
             vi.is_del = 'N'
             <if test="villageTowns != null  and villageTowns != ''">
-                and (vi.village_towns = #{villageTowns} or vi.city = #{villageTowns} or vi.region = #{villageTowns} or vi.province = #{villageTowns} or vi.city = #{villageTowns} or vi.region = #{villageTowns})
+                and vi.village_towns = #{villageTowns}
             </if>
             <if test="village != null  and village != ''"> and vi.village = #{village}</if>
             <if test="villagerGroup != null  and villagerGroup != ''"> and vi.villager_group = #{villagerGroup}</if>
@@ -121,6 +122,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                 #{idCard}
             </foreach>
             </if>
+            <if test="deptIdList != null  and deptIdList.size() > 0">
+                and vi.dept_id in
+                <foreach item="deptId" collection="deptIdList" open="(" separator="," close=")">
+                    #{deptId}
+                </foreach>
+            </if>
         </where>
         order by vi.create_time DESC ,vi.vaccination_time DESC
     </select>
@@ -194,6 +201,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="suspendUrl != null and suspendUrl != ''">suspend_url,</if>
             <if test="otherUrl != null and otherUrl != ''">other_url,</if>
             <if test="age != null and age != ''">age,</if>
+            <if test="deptId != null">dept_id,</if>
             create_time
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
@@ -237,6 +245,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="suspendUrl != null and suspendUrl != ''">#{suspendUrl},</if>
             <if test="otherUrl != null and otherUrl != ''">#{otherUrl},</if>
             <if test="age != null and age != ''">#{age},</if>
+            <if test="deptId != null">#{deptId},</if>
             sysdate()
          </trim>
     </insert>
@@ -285,6 +294,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="suspendUrl != null and suspendUrl != ''">suspend_url = #{suspendUrl},</if>
             <if test="otherUrl != null and otherUrl != ''">other_url = #{otherUrl},</if>
             <if test="age != null and age != ''">age = #{age},</if>
+            <if test="deptId != null">deptId = #{deptId},</if>
         </trim>
         where id = #{id}
     </update>