Browse Source

常住人口

shiqian 3 years ago
parent
commit
86e7b2536c

+ 3 - 0
boman-api/boman-domain/src/main/java/com/boman/domain/Czrk.java

@@ -222,6 +222,9 @@ public class Czrk extends BaseEntity {
     /** 户籍地址查询展示 安徽省安庆市潜山市xx乡xx村xx组 */
     private String nowInSelect;
 
+    private String startTime;
+    private String endTime;
+
     private java.sql.Timestamp createTime;
     private java.sql.Timestamp updateTime;
     private String createBy;

+ 10 - 0
boman-web-core/src/main/java/com/boman/web/core/controller/CzrkController.java

@@ -115,4 +115,14 @@ public class CzrkController extends BaseController {
     public AjaxResult family(@PathVariable("code") String code) {
         return AjaxResult.success(czrkService.family(code));
     }
+
+    /**
+     * 功能描述: 当前单位:镇,村:7个,组:300个,常住人口:5000人,新增 2人  减少 2人
+     *
+     * @return com.boman.domain.dto.AjaxResult
+     */
+    @GetMapping("/stsByCzrk")
+    public AjaxResult stsByCzrk() {
+        return AjaxResult.success("成功", czrkService.stsByCzrk());
+    }
 }

+ 14 - 15
boman-web-core/src/main/java/com/boman/web/core/controller/RyrlController.java

@@ -2,9 +2,9 @@ package com.boman.web.core.controller;
 
 import com.boman.common.core.web.controller.BaseController;
 import com.boman.domain.TableDataInfo;
-import com.boman.domain.VaccineInfoOperation;
+import com.boman.domain.Czrk;
 import com.boman.domain.dto.AjaxResult;
-import com.boman.web.core.service.vaccineInfo.IVaccineInfoService;
+import com.boman.web.core.service.czrk.ICzrkService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -19,42 +19,41 @@ import java.util.List;
 @RequestMapping("/core/ryrl")
 public class RyrlController extends BaseController {
 
-
     @Autowired
-    private IVaccineInfoService vaccineInfoService;
+    private ICzrkService czrkService;
 
     /**
      * 功能描述: 认领人员list, 如果isDel="Y", 则为回收站的功能,默认是isDelr="N"
      *
-     * @param vaccineInfo vaccineInfo
+     * @param czrk czrk
      * @return com.boman.domain.TableDataInfo
      */
     @GetMapping("/list")
-    public TableDataInfo list(VaccineInfoOperation vaccineInfo) {
-        List<VaccineInfoOperation> list = vaccineInfoService.listByRlry(vaccineInfo);
+    public TableDataInfo list(Czrk czrk) {
+        List<Czrk> list = czrkService.listByRlry(czrk);
         return getDataTable(list);
     }
 
     /**
      * 功能描述: 新增
      *
-     * @param vaccineInfo vaccineInfo
+     * @param czrk czrk
      * @return com.boman.domain.dto.AjaxResult
      */
     @PostMapping("/addRlry")
-    public AjaxResult addRlry(@RequestBody VaccineInfoOperation vaccineInfo) {
-        return vaccineInfoService.addRlry(vaccineInfo);
+    public AjaxResult addRlry(@RequestBody Czrk czrk) {
+        return czrkService.addRlry(czrk);
     }
 
     /**
      * 功能描述: 修改 也即 由未认领到认领
      *
-     * @param vaccineInfo vaccineInfo
+     * @param czrk czrk
      * @return com.boman.domain.dto.AjaxResult
      */
     @PostMapping("/editRlry")
-    public AjaxResult editRlry(@RequestBody VaccineInfoOperation vaccineInfo) {
-        return vaccineInfoService.editRlry(vaccineInfo);
+    public AjaxResult editRlry(@RequestBody Czrk czrk) {
+        return toAjax(czrkService.editRlry(czrk));
     }
 
     /**
@@ -65,7 +64,7 @@ public class RyrlController extends BaseController {
      */
     @GetMapping("/getById/{id}")
     public AjaxResult getById(@PathVariable Long id) {
-        return AjaxResult.success("成功", vaccineInfoService.getById(id));
+        return AjaxResult.success("成功", czrkService.getById(id));
     }
 
     /**
@@ -75,7 +74,7 @@ public class RyrlController extends BaseController {
      */
     @GetMapping("/sts")
     public AjaxResult stsByApplet(Long townId, Long villageId, String userName) {
-        return AjaxResult.success("成功", vaccineInfoService.stsByApplet(townId, villageId, userName));
+        return AjaxResult.success("成功", czrkService.stsByApplet(townId, villageId, userName));
     }
 
 

+ 9 - 0
boman-web-core/src/main/java/com/boman/web/core/mapper/CzrkMapper.java

@@ -2,6 +2,7 @@ package com.boman.web.core.mapper;
 
 import com.boman.domain.Czrk;
 import com.boman.domain.VaccineInfoOperation;
+import org.apache.ibatis.annotations.Param;
 import org.checkerframework.checker.units.qual.C;
 
 import java.util.List;
@@ -21,6 +22,7 @@ public interface CzrkMapper {
      * @return 常住人口
      */
     Czrk selectCzrkById(Long id);
+    int countIdCard(String idCard);
 
     /**
      * 查询常住人口列表
@@ -71,6 +73,13 @@ public interface CzrkMapper {
     List<Czrk> listByJs(Czrk czrk);
     int countByJs(Czrk czrk);
     int countByXz(Czrk czrk);
+    int countCzrk(Czrk czrk);
+
 
     List<Czrk> listByCode(String code);
+
+
+    int stsByYrl(@Param("deptIdList") List<Long> deptIdList, @Param("userName") String userName);
+
+    int stsByWrl(@Param("deptIdList") List<Long> deptIdList, @Param("userName") String userName);
 }

+ 363 - 4
boman-web-core/src/main/java/com/boman/web/core/service/czrk/CzrkServiceImpl.java

@@ -1,29 +1,40 @@
 package com.boman.web.core.service.czrk;
 
+import com.alibaba.fastjson.JSONObject;
+import com.boman.common.core.utils.DateUtils;
+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.sql.SqlUtil;
 import com.boman.common.core.web.page.PageDomain;
 import com.boman.common.core.web.page.TableSupport;
-import com.boman.domain.Czrk;
-import com.boman.domain.SysDept;
-import com.boman.domain.SysRole;
-import com.boman.domain.VaccineInfoOperation;
+import com.boman.common.redis.service.RedisService;
+import com.boman.domain.*;
+import com.boman.domain.dto.AjaxResult;
+import com.boman.domain.utils.ThreadPoolService;
 import com.boman.system.api.RemoteDeptService;
 import com.boman.web.core.mapper.CzrkMapper;
 import com.boman.web.core.utils.AuthUtils;
 import com.github.pagehelper.PageHelper;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.BooleanUtils;
+import org.checkerframework.checker.units.qual.C;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.sql.Date;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
 
 import static com.boman.common.core.utils.StringUtils.isNotEmpty;
 import static com.boman.common.core.utils.obj.ObjectUtils.isEmpty;
 import static com.boman.common.core.utils.obj.ObjectUtils.map;
+import static com.boman.common.redis.RedisKey.STS_CZRK_;
 
 /**
  * 常住人口Service业务层处理
@@ -35,10 +46,14 @@ import static com.boman.common.core.utils.obj.ObjectUtils.map;
 @Slf4j
 public class CzrkServiceImpl implements ICzrkService {
 
+    private static JSONObject QIANSHANSHI = null, ZHEN = null, QIANSHANSHI_SINGEL = null;
+
     @Autowired
     private CzrkMapper czrkMapper;
     @Resource
     private RemoteDeptService remoteDeptService;
+    @Resource
+    private RedisService redisService;
 
 
     @Override
@@ -124,6 +139,31 @@ public class CzrkServiceImpl implements ICzrkService {
         }
     }
 
+    private List<Long> getDeptIdList(Long deptId) {
+        if (deptId == null) {
+            deptId = AuthUtils.getLoginUser().getSysUser().getDeptId();
+            //判断是否是管理员
+            List<SysRole> roles = AuthUtils.getLoginUser().getSysUser().getRoles();
+            if (isNotEmpty(roles)) {
+                for (SysRole role : roles) {
+                    String roleKey = role.getRoleKey();
+                    if ("admin".equals(roleKey) || "city".equals(roleKey)) {
+                        return null;
+                    }
+                }
+            }
+        }
+
+        if (deptId != null) {
+            List<SysDept> sysDepts = remoteDeptService.listChildrenDepts(deptId);
+            if (isNotEmpty(sysDepts)) {
+                return map(sysDepts, SysDept::getId);
+            }
+        }
+
+        return null;
+    }
+
     /**
      * 查询常住人口
      * 
@@ -224,4 +264,323 @@ public class CzrkServiceImpl implements ICzrkService {
         handleList(czrks);
         return czrks;
     }
+
+    @Override
+    public Czrk getById(Long id) {
+        if (isEmpty(id)) {
+            return null;
+        }
+        return czrkMapper.selectCzrkById(id);
+    }
+
+    @Override
+    public AjaxResult addRlry(Czrk czrk) {
+        if (isNotEmpty(czrk.getVillageTowns())) {
+            czrk.setRlr(SecurityUtils.getUsername());
+            czrk.setIsRl("是");
+            czrk.setRlTime(new Date(System.currentTimeMillis()));
+        } else {
+            czrk.setIsRl("否");
+            czrk.setRlTime(null);
+        }
+
+        int count = czrkMapper.countIdCard(czrk.getIdCard());
+        if (count > 0) {
+            return AjaxResult.error(String.format("该人员[身份证号为: %s]已存在,请勿重复添加", czrk.getIdCard()));
+        }
+
+        count = czrkMapper.insertCzrk(czrk);
+        return count > 0 ? AjaxResult.success() : AjaxResult.error();
+    }
+
+    @Override
+    public int editRlry(Czrk czrk) {
+        if (isNotEmpty(czrk.getVillageTowns())) {
+            czrk.setRlr(SecurityUtils.getUsername());
+            czrk.setIsRl("是");
+            czrk.setRlTime(new Date(System.currentTimeMillis()));
+        } else {
+            czrk.setIsRl("否");
+            czrk.setRlTime(null);
+        }
+
+        return czrkMapper.updateCzrk(czrk);
+    }
+
+    @Override
+    public JSONObject stsByApplet(Long townId, Long villageId, String userName) {
+        List<Long> deptIdList = new ArrayList<>(16);
+        // 未加搜索条件
+        if (isEmpty(townId) && isEmpty(villageId)) {
+            deptIdList = getDeptIdList(null);
+        } else {
+            // 查村
+            if (!isEmpty(townId) && !isEmpty(villageId)) {
+                List<SysDept> sysDepts = remoteDeptService.listChildrenDepts(villageId);
+                deptIdList = sysDepts.stream().map(SysDept::getId).collect(Collectors.toList());
+            } else if (!isEmpty(townId) && isEmpty(villageId)) {
+                // 查镇
+                List<SysDept> sysDepts = remoteDeptService.listChildrenDepts(townId);
+                deptIdList = sysDepts.stream().map(SysDept::getId).collect(Collectors.toList());
+            }
+        }
+
+        int yrl = czrkMapper.stsByYrl(deptIdList, userName);
+        int wrl = czrkMapper.stsByWrl(deptIdList, userName);
+        JSONObject result = new JSONObject(3);
+        result.put("yrl", yrl);
+        result.put("wrl", wrl);
+        result.put("total", wrl + yrl);
+        return result;
+    }
+
+    /**
+     * 功能描述: 当前单位:镇,村:7个,组:300个,常住人口:5000人,新增 2人  减少 2人
+     *
+     * @return com.alibaba.fastjson.JSONObject
+     */
+    @Override
+    public JSONObject stsByCzrk() {
+        JSONObject result = new JSONObject(16);
+        SysUser sysUser = AuthUtils.getLoginUser().getSysUser();
+
+        Long deptId = sysUser.getDeptId(); // 当前登陆人的deptId
+        result.put("dqdw", sysUser.getDept().getDeptName());  // 当前单位
+
+        Czrk condition = new Czrk();
+        condition.setStartTime(DateUtils.getTodayStartStr());
+        condition.setEndTime(DateUtils.getTodayEndStr());
+        condition.setIsRl("是");
+
+        // 市领导
+        List<String> roleKeySets = map(sysUser.getRoles(), SysRole::getRoleKey);
+        if (roleKeySets.contains("city") || roleKeySets.contains("admin") || roleKeySets.contains("yanshi")) {
+            JSONObject jsonObject = redisService.getCacheObject(packRedisKey("single:" + deptId));
+            if (isNotEmpty(jsonObject)) {
+                QIANSHANSHI_SINGEL = jsonObject;
+                return jsonObject;
+            }
+
+            ThreadPoolService.execute(() -> {
+                List<SysDept> allDepts = remoteDeptService.listChildrenDepts(1L);
+                List<SysDept> townsDepts = new ArrayList<>(16);
+                for (SysDept allDept : allDepts) {
+                    if (isEmpty(allDept.getParentId())) continue;
+                    if (allDept.getParentId() == (1L)) {
+                        townsDepts.add(allDept);
+                    }
+                }
+                result.put("zhen", townsDepts.size()); // 镇
+
+                List<SysDept> cunDepts = new ArrayList<>(16);
+                for (SysDept townsDept : townsDepts) {
+                    for (SysDept allDept : allDepts) {
+                        if (isEmpty(allDept.getParentId())) continue;
+                        if (townsDept.getId().equals(allDept.getParentId())) {
+                            cunDepts.add(allDept);
+                        }
+                    }
+                }
+                result.put("cun", isEmpty(cunDepts) ? 0 : cunDepts.size());
+
+                List<SysDept> zuDept = new ArrayList<>(16);
+                for (SysDept cunDept : cunDepts) {
+                    for (SysDept allDept : allDepts) {
+                        if (cunDept.getId().equals(allDept.getParentId())) {
+                            zuDept.add(allDept);
+                        }
+                    }
+                }
+
+                result.put("zu", isEmpty(zuDept) ? 0 : zuDept.size()); // 组
+                int czrk = czrkMapper.countCzrk(condition); // 常住人口
+                result.put("czrk", czrk);
+
+                int xz = czrkMapper.countByXz(condition); // 新增
+                int js = czrkMapper.countByJs(condition);// 减少
+                result.put("xz", xz);
+                result.put("js", js);
+
+                condition.setIsRl(null); // 查全部
+                int zrs = czrkMapper.countCzrk(condition);
+                String bfb = NumberUtils.percent(czrk, zrs);
+                result.put("bfb", bfb);
+                result.put("zrs", zrs);
+                setIntoRedis(packRedisKey("single:" + deptId), result);
+                QIANSHANSHI_SINGEL = result;
+            });
+
+            return QIANSHANSHI_SINGEL;
+        } else if (roleKeySets.contains("sys:town")) {
+            JSONObject jsonObject = redisService.getCacheObject(packRedisKey("town:" + deptId));
+            if (isNotEmpty(jsonObject)) {
+                return jsonObject;
+            }
+
+            townSts(result, condition, deptId, sysUser.getDept().getDeptName(), true);
+//            redisService.setCacheObject(packRedisKey("town:" + deptId), result, 1L, TimeUnit.DAYS);
+            setIntoRedis(packRedisKey("town:" + deptId), result);
+        }
+
+        return result;
+    }
+
+    /**
+     * 功能描述: 项目首页统计信息,
+     * 当前单位:镇,村:7个,组:300个,常住人口:5000人,新增 2人  减少 2人
+     *
+     * @return com.boman.domain.dto.AjaxResult
+     */
+    @Override
+    public JSONObject stsByCzrkHomePage() {
+        JSONObject result = new JSONObject(16);
+        // 当前登陆人的deptId
+        SysUser sysUser = AuthUtils.getLoginUser().getSysUser();
+        String deptName = sysUser.getDept().getDeptName();
+        result.put("dqdw", deptName); // 当前单位
+
+        List<String> roleKeySets = map(sysUser.getRoles(), SysRole::getRoleKey);
+
+        Czrk condition = new Czrk();
+        condition.setStartTime(DateUtils.getTodayStartStr());
+        condition.setEndTime(DateUtils.getTodayEndStr());
+        condition.setIsRl("是");
+        Long deptId = sysUser.getDeptId();
+
+        // 市领导 todo 此处不应该写死
+        if (roleKeySets.contains("city") || roleKeySets.contains("admin") || roleKeySets.contains("yanshi")) {
+            JSONObject jsonObject = redisService.getCacheObject(packRedisKey(deptId + ""));
+            if (isNotEmpty(jsonObject)) {
+                QIANSHANSHI = jsonObject;
+                return jsonObject;
+            }
+
+            ThreadPoolService.execute(()->{
+                List<SysDept> allDepts = remoteDeptService.listChildrenDepts(1L);
+                List<SysDept> townsDepts = new ArrayList<>(16);
+                for (SysDept allDept : allDepts) {
+                    if (isEmpty(allDept.getParentId())) continue;
+                    if (allDept.getParentId() == (1L)) {
+                        townsDepts.add(allDept);
+                    }
+                }
+                result.put("zhen", townsDepts.size()); // 镇
+
+                List<SysDept> cunDepts = new ArrayList<>(16);
+                for (SysDept townsDept : townsDepts) {
+                    for (SysDept allDept : allDepts) {
+                        if (isEmpty(allDept.getParentId())) continue;
+                        if (townsDept.getId().equals(allDept.getParentId())) {
+                            cunDepts.add(allDept);
+                        }
+                    }
+                }
+                result.put("cun", isEmpty(cunDepts) ? 0 : cunDepts.size());
+
+                List<SysDept> zuDept = new ArrayList<>(16);
+                for (SysDept cunDept : cunDepts) {
+                    for (SysDept allDept : allDepts) {
+                        if (cunDept.getId().equals(allDept.getParentId())) {
+                            zuDept.add(allDept);
+                        }
+                    }
+                }
+
+                result.put("zu", isEmpty(zuDept) ? 0 : zuDept.size()); // 组
+                int czrk = czrkMapper.countCzrk(condition); // 常住人口
+                result.put("czrk", czrk);
+
+                int xz = czrkMapper.countByXz(condition); // 新增
+                int js = czrkMapper.countByJs(condition);// 减少
+                result.put("xz", xz);
+                result.put("js", js);
+
+                condition.setIsRl(null); // 查全部
+                int zrs = czrkMapper.countCzrk(condition);
+                String bfb = NumberUtils.percent(czrk, zrs);
+                result.put("bfb", bfb);
+                result.put("zrs", zrs);
+
+                // 以各个镇为单位单独处理 townsDepts
+                ArrayList<JSONObject> towsDataList = new ArrayList<>(20);
+                for (SysDept townsDept : townsDepts) {
+                    JSONObject townsResult = new JSONObject(16);
+                    townSts(townsResult, condition, townsDept.getId(), townsDept.getDeptName(), false);
+                    towsDataList.add(townsResult);
+                }
+
+                result.put("townDatas", towsDataList);
+//                redisService.setCacheObject(packRedisKey(deptId + ""), result, 1L, TimeUnit.DAYS);
+                setIntoRedis(packRedisKey(deptId + ""), result);
+                QIANSHANSHI = result;
+            });
+
+            return QIANSHANSHI;
+        } else if (roleKeySets.contains("sys:town")) {
+            JSONObject jsonObject = redisService.getCacheObject(packRedisKey("town:" + deptId));
+            if (isNotEmpty(jsonObject)) {
+                ZHEN = jsonObject;
+                return jsonObject;
+            }
+
+            ThreadPoolService.execute(() -> {
+                townSts(result, condition, deptId, deptName, true);
+//                redisService.setCacheObject(packRedisKey("town:" + deptId), result, 1L, TimeUnit.DAYS);
+                setIntoRedis(packRedisKey("town:" + deptId), result);
+            });
+
+            return ZHEN;
+        }
+
+        return result;
+    }
+
+    private void townSts(JSONObject result, Czrk condition, Long deptId, String deptName, boolean percent) {
+        // 乡镇以下的所有部门
+        List<SysDept> depts = remoteDeptService.listChildrenDepts(deptId);
+        List<SysDept> cunDepts = new ArrayList<>(16);
+        for (SysDept dept : depts) {
+            if (isEmpty(dept.getParentId())) continue;
+            if (deptId.equals(dept.getParentId())) {
+                cunDepts.add(dept);
+            }
+        }
+        result.put("cun", isEmpty(cunDepts) ? 0 : cunDepts.size());
+
+        List<SysDept> zuDept = new ArrayList<>(16);
+        for (SysDept cunDept : cunDepts) {
+            for (SysDept dept : depts) {
+                if (cunDept.getId().equals(dept.getParentId())) {
+                    zuDept.add(dept);
+                }
+            }
+        }
+
+        result.put("zu", isEmpty(zuDept) ? 0 : zuDept.size());
+        condition.setDeptIdList(map(depts, SysDept::getId));
+        int czrk = czrkMapper.countCzrk(condition);
+        result.put("czrk", czrk);
+
+        // 常住人口占总人口的百分比
+        if (BooleanUtils.isTrue(percent)) {
+            condition.setIsRl(null); // 查全部
+            int zrs = czrkMapper.countCzrk(condition);
+            String bfb = NumberUtils.percent(czrk, zrs);
+            result.put("bfb", bfb);
+        }
+
+        int xz = czrkMapper.countByXz(condition);
+        int js = czrkMapper.countByJs(condition);
+        result.put("xz", xz);
+        result.put("js", js);
+        result.put("zhen", deptName);
+    }
+
+    private String packRedisKey(String deptId){
+        return STS_CZRK_ + deptId + ":" + DateUtils.getDate();
+    }
+
+    private void setIntoRedis(String key, Object result){
+        redisService.setCacheObject(key, result, 1L, TimeUnit.HOURS);
+    }
 }

+ 12 - 0
boman-web-core/src/main/java/com/boman/web/core/service/czrk/ICzrkService.java

@@ -1,7 +1,9 @@
 package com.boman.web.core.service.czrk;
 
+import com.alibaba.fastjson.JSONObject;
 import com.boman.domain.Czrk;
 import com.boman.domain.VaccineInfoOperation;
+import com.boman.domain.dto.AjaxResult;
 import org.checkerframework.checker.units.qual.C;
 
 import java.util.List;
@@ -70,4 +72,14 @@ public interface ICzrkService {
     int deleteCzrk(Long id);
     int reduction(String id);
     List<Czrk> family(String code);
+
+    Czrk getById(Long id);
+
+    AjaxResult addRlry(Czrk czrk);
+    int editRlry(Czrk czrk);
+
+    JSONObject stsByApplet(Long townId, Long villageId, String userName);
+    JSONObject stsByCzrk();
+    JSONObject stsByCzrkHomePage();
+
 }

+ 1 - 6
boman-web-core/src/main/java/com/boman/web/core/service/vaccineInfo/IVaccineInfoService.java

@@ -1,6 +1,7 @@
 package com.boman.web.core.service.vaccineInfo;
 
 import com.alibaba.fastjson.JSONObject;
+import com.boman.domain.Czrk;
 import com.boman.domain.dto.AjaxResult;
 import com.boman.domain.VaccineInfoOperation;
 
@@ -86,12 +87,6 @@ public interface IVaccineInfoService
      */
     JSONObject getByIdCard(String idCard);
 
-
-    List<VaccineInfoOperation> listByRlry(VaccineInfoOperation vaccineInfo);
-
-    AjaxResult addRlry(VaccineInfoOperation vaccineInfo);
-    AjaxResult editRlry(VaccineInfoOperation vaccineInfo);
-
     VaccineInfoOperation getById(Long id);
 
     JSONObject stsByApplet(Long townId, Long villageId, String userName);

+ 0 - 111
boman-web-core/src/main/java/com/boman/web/core/service/vaccineInfo/impl/VaccineInfoServiceImpl.java

@@ -1038,117 +1038,6 @@ public class VaccineInfoServiceImpl implements IVaccineInfoService {
         return result;
     }
 
-    @Override
-    public List<VaccineInfoOperation> listByRlry(VaccineInfoOperation vaccineInfoOperation) {
-        vaccineInfoOperation.setIsDel(isEmpty(vaccineInfoOperation.getIsDel()) ? "N" : "Y");
-        Long deptId = vaccineInfoOperation.getDeptId();
-        if (deptId == null) {
-            deptId = AuthUtils.getLoginUser().getSysUser().getDeptId();
-            //判断是否是管理员
-            List<SysRole> roles = AuthUtils.getLoginUser().getSysUser().getRoles();
-            if (isNotEmpty(roles)) {
-                for (SysRole role : roles) {
-                    String roleKey = role.getRoleKey();
-                    if ("admin".equals(roleKey) || "city".equals(roleKey)) {
-                        deptId = null;
-                        break;
-                    }
-                }
-            }
-        }
-
-        if (deptId != null) {
-            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);
-        }
-
-        Map<String, Object> params = vaccineInfoOperation.getParams();
-        String ageScope = (String) params.get("age");
-        if (isNotEmpty(ageScope)) {
-            ageScope = ageScope.trim();
-            String[] split = ageScope.split("-");
-            params.put("startAge", Integer.parseInt(split[0]));
-            if (split.length == 2) {
-                params.put("endAge", Integer.parseInt(split[1]));
-            }
-        }
-
-        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<VaccineInfoOperation> infoOperations = vaccineInfoMapper.listByRlry(vaccineInfoOperation);
-        for (VaccineInfoOperation infoOperation : infoOperations) {
-            String province = infoOperation.getProvince(); // 现居住地的省份
-            String city = infoOperation.getCity();  // 现居住地的城市
-            String region = infoOperation.getRegion();   // 现居住地的区
-            String domicile = infoOperation.getDomicile(); // 户籍地
-            StringBuilder sbDomicile = new StringBuilder(); // 户籍地前端展示用 安徽省安庆市潜山市xx乡xx村xx组
-            StringBuilder sbNowIn = new StringBuilder(); // 現在居住地址查询展示 安徽省安庆市潜山市xx乡xx村xx组
-            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);
-            }
-
-            String nowIn = infoOperation.getNowIn(); //现居地
-            if (StringUtils.isNotBlank(nowIn)) {
-                sbNowIn.append(nowIn);
-            }
-
-            infoOperation.setDomicileSelect(sbDomicile.toString());
-            infoOperation.setNowInSelect(sbNowIn.toString());
-        }
-
-        return infoOperations;
-    }
-
-    @Override
-    public AjaxResult addRlry(VaccineInfoOperation vaccineInfo) {
-        if (isNotEmpty(vaccineInfo.getVillageTowns())) {
-            vaccineInfo.setRlr(SecurityUtils.getUsername());
-        }
-
-        int count = vaccineInfoMapper.countIdCard(vaccineInfo.getIdCard());
-        if (count > 0) {
-            return  AjaxResult.error(String.format("该人员[身份证号为: %s]已存在,请勿重复添加", vaccineInfo.getIdCard()));
-        }
-
-        int i = vaccineInfoMapper.insertVaccineInfo(vaccineInfo);
-        return i > 0 ? AjaxResult.success() : AjaxResult.error();
-    }
-
-    @Override
-    public AjaxResult editRlry(VaccineInfoOperation vaccineInfo) {
-        if (isNotEmpty(vaccineInfo.getVillageTowns())) {
-            vaccineInfo.setRlr(SecurityUtils.getUsername());
-        }
-
-        int i = vaccineInfoMapper.updateVaccineInfo(vaccineInfo);
-        return i > 0 ? AjaxResult.success() : AjaxResult.error();
-    }
-
     @Override
     public VaccineInfoOperation getById(Long id) {
         return vaccineInfoMapper.selectVaccineInfoById(id);

+ 57 - 7
boman-web-core/src/main/resources/mapper/CzrkMapper.xml

@@ -241,11 +241,63 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where vi.is_del = 'N' and code = #{code} order by house_type desc;
     </select>
 
+    <select id="countCzrk" resultType="int">
+        select count(vi.id)
+        from czrk vi
+        where vi.is_del = 'N'
+        <!-- 不关心是否认领 -->
+        <if test="deptIdList != null  and deptIdList.size() > 0">
+            and vi.dept_id in
+            <foreach item="deptId" collection="deptIdList" open="(" separator="," close=")">
+                #{deptId}
+            </foreach>
+        </if>
+    </select>
+
     <select id="selectCzrkById" parameterType="Long" resultMap="CzrkResult">
         <include refid="selectCzrkVo"/>
-        where id = #{id}
+        where id = #{id} limit 1
+    </select>
+
+    <select id="countIdCard" resultType="int">
+        select count(vi.id) from czrk vi where vi.is_del = 'N' and id_card = #{idCard}
+    </select>
+
+    <select id="stsByYrl" resultType="int">
+        select count(vi.id)
+        from czrk vi
+        where vi.is_del = 'N'
+        <!-- 已认领 -->
+        and vi.is_rl = '是'
+        <if test="userName != null  and userName != ''">
+            and (vi.user_name like concat('%', #{userName}, '%') or vi.id_card like concat('%', #{userName}, '%'))
+        </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>
     </select>
-        
+
+    <select id="stsByWrl" resultType="int">
+        select count(vi.id)
+        from czrk vi
+        where vi.is_del = 'N'
+        <!-- 未认领 -->
+        and vi.is_rl = '否'
+        <if test="userName != null  and userName != ''">
+            and (vi.user_name like concat('%', #{userName}, '%') or vi.id_card like concat('%', #{userName}, '%'))
+        </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>
+    </select>
+
+
     <insert id="insertCzrk"  useGeneratedKeys="true" keyProperty="id">
         insert into czrk
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -278,10 +330,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="status != null">status,</if>
             <if test="createBy != null">create_by,</if>
             <if test="updateBy != null">update_by,</if>
-            <if test="updateTime != null">update_time,</if>
             <if test="isDel != null and isDel != ''">is_del,</if>
             <if test="deleteReason != null">delete_reason,</if>
-            create_time
+            create_time, updateTime
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="userName != null">#{userName},</if>
@@ -313,10 +364,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="status != null">#{status},</if>
             <if test="createBy != null">#{createBy},</if>
             <if test="updateBy != null">#{updateBy},</if>
-            <if test="updateTime != null">#{updateTime},</if>
             <if test="isDel != null and isDel != ''">#{isDel},</if>
             <if test="deleteReason != null">#{deleteReason},</if>
-            sysdate()
+            sysdate(), sysdate()
         </trim>
     </insert>
 
@@ -353,7 +403,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="createBy != null">create_by = #{createBy},</if>
             <if test="createTime != null">create_time = #{createTime},</if>
             <if test="updateBy != null">update_by = #{updateBy},</if>
-            <if test="updateTime != null">update_time = #{updateTime},</if>
+            <if test="updateTime != null">update_time = sysdate(),</if>
             <if test="isDel != null and isDel != ''">is_del = #{isDel},</if>
             <if test="deleteReason != null">delete_reason = #{deleteReason},</if>
         </trim>