Эх сурвалжийг харах

Merge remote-tracking branch 'origin/master'

tjf 3 жил өмнө
parent
commit
8d2cbeed69

+ 14 - 4
boman-common/boman-common-core/src/main/java/com/boman/common/core/utils/DateUtils.java

@@ -7,10 +7,7 @@ import java.text.ParsePosition;
 import java.text.SimpleDateFormat;
 import java.time.LocalDate;
 import java.time.temporal.ChronoUnit;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 import java.util.stream.Collectors;
 import java.util.stream.IntStream;
 
@@ -449,4 +446,17 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
         return maxDate;
     }
 
+    public static List<String> splitDate(Date startTimeDate, Date endTimeDate) {
+        if (null == startTimeDate) return Collections.emptyList();
+        if (null == endTimeDate) return Collections.emptyList();
+        List<String> weeks = new ArrayList<>(7);
+        weeks.add(dateTime1(addDay(endTimeDate, -1)));
+        weeks.add(dateTime1(addDay(endTimeDate, -2)));
+        weeks.add(dateTime1(addDay(endTimeDate, -3)));
+        weeks.add(dateTime1(addDay(endTimeDate, -4)));
+        weeks.add(dateTime1(addDay(endTimeDate, -5)));
+        weeks.add(dateTime1(addDay(endTimeDate, -6)));
+        weeks.add(dateTime1(addDay(endTimeDate, -7)));
+        return weeks;
+    }
 }

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

@@ -136,9 +136,11 @@ public class CzrkController extends BaseController {
 
     /**
      * 功能描述: 当前单位:镇,村:7个,组:300个,常住人口:5000人,新增 2人  减少 2人
+     * {@link IndexController#stsByCzrkHomePage()}
      *
      * @return com.boman.domain.dto.AjaxResult
      */
+    @Deprecated
     @GetMapping("/stsByCzrkHomePage")
     public AjaxResult stsByCzrkHomePage() {
         return AjaxResult.success("成功", czrkService.stsByCzrkHomePage());

+ 42 - 0
boman-web-core/src/main/java/com/boman/web/core/controller/IndexController.java

@@ -0,0 +1,42 @@
+package com.boman.web.core.controller;
+
+import com.boman.domain.dto.AjaxResult;
+import com.boman.web.core.service.czrk.ICzrkService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @author shiqian
+ * @date 2022年01月19日 10:49
+ **/
+@RestController
+@RequestMapping("/index")
+public class IndexController {
+
+    @Autowired
+    private ICzrkService czrkService;
+
+    /**
+     * 功能描述: 项目首页统计信息,
+     * 当前单位:镇,村:7个,组:300个,常住人口:5000人,新增 2人  减少 2人
+     *
+     * @return com.boman.domain.dto.AjaxResult
+     */
+    @GetMapping("/stsByCzrkHomePage")
+    public AjaxResult stsByCzrkHomePage() {
+        return AjaxResult.success("成功", czrkService.stsByCzrkHomePage());
+    }
+
+
+    /**
+     * 功能描述: 项目首页统计信息 折线图,一个星期内常住新增、减少,户籍新增、减少
+     *
+     * @return com.boman.domain.dto.AjaxResult
+     */
+    @GetMapping("/hjczLine")
+    public AjaxResult hjczLine() {
+        return AjaxResult.success("成功", czrkService.hjczLine());
+    }
+}

+ 15 - 3
boman-web-core/src/main/java/com/boman/web/core/mapper/CzrkMapper.java

@@ -72,9 +72,9 @@ public interface CzrkMapper {
 
     List<Czrk> listByXz(Czrk czrk);
     List<Czrk> listByJs(Czrk czrk);
-    int countByJs(Czrk czrk);
-    int countByXz(Czrk czrk);
-    int countCzrk(Czrk czrk);
+//    int countByJs(Czrk czrk);
+//    int countByXz(Czrk czrk);
+    int countCzrk(@Param("type") int type, @Param("areaId") Long areaId);
 
 
     List<Czrk> listByCode(String code);
@@ -95,4 +95,16 @@ public interface CzrkMapper {
      */
    Czrk findHjInfo(Czrk czrk);
     List<Czrk> stsByAppletCz(@Param("type") int type, @Param("areaId") Long areaId, @Param("userName") String userName);
+
+    List<Czrk> listByCzXz(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("type") int type, @Param("areaId") Long areaId);
+    List<Czrk> listByCzJs(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("type") int type, @Param("areaId") Long areaId);
+
+    int countByCzXz(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("type") int type, @Param("areaId") Long areaId);
+    int countByCzJs(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("type") int type, @Param("areaId") Long areaId);
+
+    List<Czrk>  countByHjXz(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("type") int type, @Param("areaId") Long areaId);
+
+    List<Czrk>  countByHjJs(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("type") int type, @Param("areaId") Long areaId);
+
+    List<Czrk> countHj(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("type") int type, @Param("areaId") Long areaId);
 }

+ 182 - 84
boman-web-core/src/main/java/com/boman/web/core/service/czrk/CzrkServiceImpl.java

@@ -27,6 +27,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import java.sql.Date;
+import java.sql.Timestamp;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -34,10 +35,10 @@ import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
 import static com.boman.common.core.utils.StringUtils.isNotEmpty;
-import static com.boman.common.core.utils.fieldTranslator.IdCardUtils.getAge;
 import static com.boman.common.core.utils.fieldTranslator.IdCardUtils.getSex;
 import static com.boman.common.core.utils.obj.ObjectUtils.*;
 import static com.boman.common.redis.RedisKey.STS_CZRK_;
+import static com.boman.web.core.utils.IdCardUtils.getAge;
 import static com.google.common.base.Strings.nullToEmpty;
 
 /**
@@ -459,10 +460,8 @@ public class CzrkServiceImpl implements ICzrkService {
         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("是");
+        String startTime = DateUtils.getTodayStartStr();
+        String endTime = DateUtils.getTodayEndStr();
 
         // 市领导
         List<String> roleKeySets = map(sysUser.getRoles(), SysRole::getRoleKey);
@@ -474,6 +473,7 @@ public class CzrkServiceImpl implements ICzrkService {
             }
 
             ThreadPoolService.execute(() -> {
+                Long areaId = 340882000000L;
                 List<SysDept> allDepts = remoteDeptService.listChildrenDepts(1L);
                 List<SysDept> townsDepts = new ArrayList<>(16);
                 for (SysDept allDept : allDepts) {
@@ -493,8 +493,8 @@ public class CzrkServiceImpl implements ICzrkService {
                         }
                     }
                 }
-                result.put("cun", isEmpty(cunDepts) ? 0 : cunDepts.size());
-
+                result.put("cun", isEmpty(cunDepts) ? 0 : cunDepts.size()); //村
+//
                 List<SysDept> zuDept = new ArrayList<>(16);
                 for (SysDept cunDept : cunDepts) {
                     for (SysDept allDept : allDepts) {
@@ -505,19 +505,40 @@ public class CzrkServiceImpl implements ICzrkService {
                 }
 
                 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);
+
+                // 常住人口信息 areaId 为潜山市的为常住人口
+                int type = 3;
+                int czzrs = czrkMapper.countCzrk(type, areaId); // 常住人口
+                result.put("czzrs", czzrs);
+
+                int czxz = czrkMapper.countByCzXz(startTime, endTime, type, areaId); // 新增
+                int czjs = czrkMapper.countByCzJs(startTime, endTime, type, areaId);// 减少
+                result.put("czxz", czxz);
+                result.put("czjs", czjs);
+
+                // condition.setIsRl(null); // 查全部
+                type = 0;
+                int zrs = czrkMapper.countCzrk(type, areaId);
+                String czbfb = NumberUtils.percent(czzrs, zrs);
+                result.put("czbfb", czbfb);
                 result.put("zrs", zrs);
+
+                // 户籍人口信息
+                // 户籍总人数
+                List<Czrk> hjzrsList = czrkMapper.countHj(startTime, endTime, type, areaId);
+                int hjzrs= isEmpty(hjzrsList) ? 0 : hjzrsList.size();
+                result.put("hjzrs", hjzrs);
+
+                // 户籍人口信息 新增 减少
+                type = 3; // regionId
+                List<Czrk> hjxzs = czrkMapper.countByHjXz(startTime, endTime, type, areaId); // 新增
+                List<Czrk> hjjss = czrkMapper.countByHjJs(startTime, endTime, type, areaId);// 减少
+                result.put("hjxz", isEmpty(hjxzs) ? 0 : hjxzs.size());
+                result.put("hjjs", isEmpty(hjjss) ? 0 : hjjss.size());
+
+                // 户籍人口信息 百分比
+                String hjbfb = NumberUtils.percent(hjzrs, zrs);
+                result.put("hjbfb", hjbfb);
                 setIntoRedis(packRedisKey("single:" + deptId), result);
                 QIANSHANSHI_SINGEL = result;
             });
@@ -529,7 +550,7 @@ public class CzrkServiceImpl implements ICzrkService {
                 return jsonObject;
             }
 
-            townSts(result, condition, deptId, sysUser.getDept().getDeptName(), true);
+            townSts(result, deptId, sysUser.getDept().getDeptName(), true);
 //            redisService.setCacheObject(packRedisKey("town:" + deptId), result, 1L, TimeUnit.DAYS);
             setIntoRedis(packRedisKey("town:" + deptId), result);
         }
@@ -553,10 +574,8 @@ public class CzrkServiceImpl implements ICzrkService {
 
         List<String> roleKeySets = map(sysUser.getRoles(), SysRole::getRoleKey);
 
-        Czrk condition = new Czrk();
-        condition.setStartTime(DateUtils.getTodayStartStr());
-        condition.setEndTime(DateUtils.getTodayEndStr());
-        condition.setIsRl("是");
+        String todayStart = DateUtils.getTodayStartStr();
+        String todayEnd = DateUtils.getTodayEndStr();
         Long deptId = sysUser.getDeptId();
 
         // 市领导 todo 此处不应该写死
@@ -568,6 +587,7 @@ public class CzrkServiceImpl implements ICzrkService {
             }
 
             ThreadPoolService.execute(() -> {
+                Long areaId = 340882000000L;
                 List<SysDept> allDepts = remoteDeptService.listChildrenDepts(1L);
                 List<SysDept> townsDepts = new ArrayList<>(16);
                 for (SysDept allDept : allDepts) {
@@ -589,35 +609,45 @@ public class CzrkServiceImpl implements ICzrkService {
                 }
                 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);
+                // 常住人口信息 areaId 为潜山市的为常住人口
+                int type = 3;
+                int czzrs = czrkMapper.countCzrk(type, areaId); // 常住人口
+                result.put("czzrs", czzrs);
+
+                int czxz = czrkMapper.countByCzXz(todayStart, todayEnd, type, areaId); // 新增
+                int czjs = czrkMapper.countByCzJs(todayStart, todayEnd, type, areaId);// 减少
+                result.put("czxz", czxz);
+                result.put("czjs", czjs);
+
+                // condition.setIsRl(null); // 查全部
+                type = 0;
+                int zrs = czrkMapper.countCzrk(type, areaId);
+                String czbfb = NumberUtils.percent(czzrs, zrs);
+                result.put("czbfb", czbfb);
                 result.put("zrs", zrs);
 
+                // 户籍人口信息
+                // 户籍总人数
+                List<Czrk> hjzrsList = czrkMapper.countHj(todayStart, todayEnd, type, areaId);
+                int hjzrs= isEmpty(hjzrsList) ? 0 : hjzrsList.size();
+                result.put("hjzrs", hjzrs);
+
+                // 户籍人口信息 新增 减少
+                type = 3; // regionId
+                List<Czrk> hjxzs = czrkMapper.countByHjXz(todayStart, todayEnd, type, areaId); // 新增
+                List<Czrk> hjjss = czrkMapper.countByHjJs(todayStart, todayEnd, type, areaId);// 减少
+                result.put("hjxz", isEmpty(hjxzs) ? 0 : hjxzs.size());
+                result.put("hjjs", isEmpty(hjjss) ? 0 : hjjss.size());
+
+                // 户籍人口信息 百分比
+                String hjbfb = NumberUtils.percent(hjzrs, zrs);
+                result.put("hjbfb", hjbfb);
+
                 // 以各个镇为单位单独处理 townsDepts
                 ArrayList<JSONObject> towsDataList = new ArrayList<>(20);
                 for (SysDept townsDept : townsDepts) {
                     JSONObject townsResult = new JSONObject(16);
-                    townSts(townsResult, condition, townsDept.getId(), townsDept.getDeptName(), false);
+                    townSts(townsResult, townsDept.getId(), townsDept.getDeptName(), false);
                     towsDataList.add(townsResult);
                 }
 
@@ -636,7 +666,7 @@ public class CzrkServiceImpl implements ICzrkService {
             }
 
             ThreadPoolService.execute(() -> {
-                townSts(result, condition, deptId, deptName, true);
+                townSts(result, deptId, deptName, true);
 //                redisService.setCacheObject(packRedisKey("town:" + deptId), result, 1L, TimeUnit.DAYS);
                 setIntoRedis(packRedisKey("town:" + deptId), result);
             });
@@ -647,31 +677,10 @@ public class CzrkServiceImpl implements ICzrkService {
         return result;
     }
 
-    /**
-     * 根据身份证号查询用户信息
-     * @param czrk
-     * @return
-     */
-    @Override
-    public Czrk findHjInfo(Czrk czrk) {
-        Czrk hjInfo = czrkMapper.findHjInfo(czrk);
-        if (hjInfo == null) {
-            String idCard = czrk.getIdCard();
-            if (StringUtils.isNotBlank(idCard)) {
-                //根据身份证提取出生日和性别,年龄
-                String sex = getSex(idCard);
-                Integer age = getAge(idCard);
-                String birthday = IdCardUtils.getBirthday(idCard);
-                czrk.setAge(age);
-                czrk.setGender(sex);
-                czrk.setBirthday(birthday);
-                return czrk;
-            }
-        }
-        return hjInfo;
-    }
-
-    private void townSts(JSONObject result, Czrk condition, Long deptId, String deptName, boolean percent) {
+    private void townSts(JSONObject result, Long deptId, String deptName, boolean percent) {
+        String startTime = DateUtils.getTodayStartStr();
+        String endTime = DateUtils.getTodayEndStr();
+        Long areaId = deptId;
         // 乡镇以下的所有部门
         List<SysDept> depts = remoteDeptService.listChildrenDepts(deptId);
         List<SysDept> cunDepts = new ArrayList<>(16);
@@ -693,23 +702,112 @@ public class CzrkServiceImpl implements ICzrkService {
         }
 
         result.put("zu", isEmpty(zuDept) ? 0 : zuDept.size());
-        condition.setDeptIdList(map(depts, SysDept::getId));
-        int czrk = czrkMapper.countCzrk(condition);
-        result.put("czrk", czrk);
 
+        // 常住人口信息 areaId 为潜山市的为常住人口
+        int type = 0;
+        int czzrs = czrkMapper.countCzrk(type, areaId); // 常住人口
+        result.put("czzrs", czzrs);
+
+        int zrs = 0;
         // 常住人口占总人口的百分比
         if (BooleanUtils.isTrue(percent)) {
-            condition.setIsRl(null); // 查全部
-            int zrs = czrkMapper.countCzrk(condition);
-            String bfb = NumberUtils.percent(czrk, zrs);
-            result.put("bfb", bfb);
+             // 查全部
+            zrs = czrkMapper.countCzrk(type, areaId);
+            String czbfb = NumberUtils.percent(czzrs, zrs);
+            result.put("czbfb", czbfb);
         }
 
-        int xz = czrkMapper.countByXz(condition);
-        int js = czrkMapper.countByJs(condition);
-        result.put("xz", xz);
-        result.put("js", js);
+        type = 4;
+        int czxz = czrkMapper.countByCzXz(startTime, endTime, type, areaId);
+        int czjs = czrkMapper.countByCzJs(startTime, endTime, type, areaId);
+        result.put("czxz", czxz);
+        result.put("czjs", czjs);
+
         result.put("zhen", deptName);
+
+        // 户籍人口信息
+        List<Czrk> hjxzs = czrkMapper.countByHjXz(startTime, endTime, type, areaId); // 新增
+        List<Czrk> hjjss = czrkMapper.countByHjJs(startTime, endTime, type, areaId);// 减少
+        result.put("hjxz", isEmpty(hjxzs) ? 0 : hjxzs.size());
+        result.put("hjjs", isEmpty(hjjss) ? 0 : hjjss.size());
+
+        // 户籍总人数
+        List<Czrk> hjzrsList = czrkMapper.countHj(startTime, endTime, type, areaId);
+        int hjzrs= isEmpty(hjzrsList) ? 0 : hjzrsList.size();
+        result.put("hjzrs", hjzrs);
+        String hjbfb = NumberUtils.percent(hjzrs, zrs);
+        result.put("hjbfb", hjbfb);
+    }
+
+    @Override
+    public JSONObject hjczLine() {
+        // 统计范围 从今天往前推7天
+        java.util.Date startTimeDate = DateUtils.getTodayStart(), endTimeDate = DateUtils.addDays(startTimeDate, -7);
+        String startTime = DateUtils.dateTime1(startTimeDate), endTime = DateUtils.dateTime1(endTimeDate);
+        SysUser sysUser = AuthUtils.getLoginUser().getSysUser();
+        int type = 0;
+        Long areaId = null;
+
+        // 市领导 todo 此处不应该写死
+        List<String> roleKeySets = map(sysUser.getRoles(), SysRole::getRoleKey);
+        if (roleKeySets.contains("city") || roleKeySets.contains("admin") || roleKeySets.contains("yanshi")) {
+            type = 3;
+            areaId = 340882000000L;
+        } else if (roleKeySets.contains("sys:town")) {
+            type = 4;
+            areaId = sysUser.getDeptId();
+        }
+
+        List<String> dateList = DateUtils.splitDate(startTimeDate, endTimeDate);
+
+        // 常住人口信息
+        List<Czrk> czxzs = czrkMapper.listByCzXz(startTime, endTime, type, areaId);
+        List<Czrk> czjss = czrkMapper.listByCzJs(startTime, endTime, type, areaId);
+
+        // 户籍人口信息
+        List<Czrk> hjxzs = czrkMapper.countByHjXz(startTime, endTime, type, areaId); // 新增
+        List<Czrk> hjjss = czrkMapper.countByHjJs(startTime, endTime, type, areaId);// 减少
+
+//        String lastDate = dateList.get(dateList.size() - 1);
+        for (String week : dateList) {
+            JSONObject temp = new JSONObject();
+            temp.put("time", week);
+            for (Czrk czxz : czxzs) {
+                Timestamp createTime = czxz.getCreateTime();
+
+            }
+
+            for (Czrk czjs : czjss) {
+
+            }
+
+        }
+
+        return null;
+    }
+
+    /**
+     * 根据身份证号查询用户信息
+     * @param czrk
+     * @return
+     */
+    @Override
+    public Czrk findHjInfo(Czrk czrk) {
+        Czrk hjInfo = czrkMapper.findHjInfo(czrk);
+        if (hjInfo == null) {
+            String idCard = czrk.getIdCard();
+            if (StringUtils.isNotBlank(idCard)) {
+                //根据身份证提取出生日和性别,年龄
+                String sex = getSex(idCard);
+                Integer age = getAge(idCard);
+                String birthday = IdCardUtils.getBirthday(idCard);
+                czrk.setAge(age);
+                czrk.setGender(sex);
+                czrk.setBirthday(birthday);
+                return czrk;
+            }
+        }
+        return hjInfo;
     }
 
     private String packRedisKey(String deptId) {

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

@@ -87,4 +87,5 @@ public interface ICzrkService {
      */
     Czrk findHjInfo(Czrk czrk);
 
+    JSONObject hjczLine();
 }

+ 111 - 62
boman-web-core/src/main/resources/mapper/CzrkMapper.xml

@@ -230,36 +230,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </if>
     </select>
 
-    <select id="countByXz" resultType="int">
+    <select id="countByCzXz" resultType="int">
         select count(1)
         from czrk vi
         where vi.is_del = 'N' and vi.create_time &gt;= #{startTime} and vi.create_time &lt;= #{endTime}
-        <if test="villageTowns != null  and 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>
-        <if test="houseType != null  and houseType != ''"> and vi.house_type = #{houseType}</if>
-        <if test="province != null  and province != ''"> and vi.province = #{province}</if>
-        <if test="city != null  and city != ''"> and vi.city = #{city}</if>
-        <if test="region != null  and region != ''"> and vi.region = #{region}</if>
-        <if test="userName != null  and userName != ''"> and vi.user_name like concat('%', #{userName}, '%')</if>
-        <if test="gender != null  and gender != ''"> and vi.gender = #{gender}</if>
-        <if test="idCard != null  and idCard != ''"> and vi.id_card like concat('%', #{idCard}, '%')</if>
-        <if test="phoneNum != null  and phoneNum != ''"> and vi.phone_num = #{phoneNum}</if>
-        <if test="params.startAge != null  and params.startAge != ''"> and vi.age &gt;= #{params.startAge}</if>
-        <if test="params.endAge != null  and params.endAge != ''"> and vi.age &lt;= #{params.endAge}</if>
-        <if test="status != null  and status != ''"> and vi.status = #{status}</if>
-        <if test="code != null  and code != ''"> and vi.code = #{code}</if>
-        <if test="birthday != null  and birthday != ''"> and vi.birthday = #{birthday}</if>
-        <if test="workUnit != null  and workUnit != ''"> and vi.work_unit = #{workUnit}</if>
-        <if test="nowIn != null  and nowIn != ''"> and vi.now_in = #{nowIn}</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>
+        <choose>
+            <when test="type == 1">and vi.province_id = #{areaId}</when>
+            <when test="type == 2">and vi.city_id = #{areaId}</when>
+            <when test="type == 3">and vi.region_id = #{areaId}</when>
+            <when test="type == 4">and vi.village_towns_id = #{areaId}</when>
+            <when test="type == 5">and vi.village_id = #{areaId}</when>
+        </choose>
+    </select>
+
+    <select id="listByCzXz" resultMap="CzrkResult">
+        select vi.id, vi.create_time
+        from czrk vi
+        where vi.is_del = 'N' and vi.create_time &gt;= #{startTime} and vi.create_time &lt;= #{endTime}
+        <choose>
+            <when test="type == 1">and vi.province_id = #{areaId}</when>
+            <when test="type == 2">and vi.city_id = #{areaId}</when>
+            <when test="type == 3">and vi.region_id = #{areaId}</when>
+            <when test="type == 4">and vi.village_towns_id = #{areaId}</when>
+            <when test="type == 5">and vi.village_id = #{areaId}</when>
+        </choose>
     </select>
 
     <select id="listByJs" resultMap="CzrkResult">
@@ -298,36 +292,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </if>
     </select>
 
-    <select id="countByJs" resultType="int">
+    <select id="countByCzJs" resultType="int">
         select count(1)
         from czrk vi
         where vi.is_del = 'Y' and vi.update_time &gt;= #{startTime} and vi.update_time &lt;= #{endTime}
-        <if test="villageTowns != null  and 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>
-        <if test="houseType != null  and houseType != ''"> and vi.house_type = #{houseType}</if>
-        <if test="province != null  and province != ''"> and vi.province = #{province}</if>
-        <if test="city != null  and city != ''"> and vi.city = #{city}</if>
-        <if test="region != null  and region != ''"> and vi.region = #{region}</if>
-        <if test="userName != null  and userName != ''"> and vi.user_name like concat('%', #{userName}, '%')</if>
-        <if test="gender != null  and gender != ''"> and vi.gender = #{gender}</if>
-        <if test="idCard != null  and idCard != ''"> and vi.id_card like concat('%', #{idCard}, '%')</if>
-        <if test="phoneNum != null  and phoneNum != ''"> and vi.phone_num = #{phoneNum}</if>
-        <if test="params.startAge != null  and params.startAge != ''"> and vi.age &gt;= #{params.startAge}</if>
-        <if test="params.endAge != null  and params.endAge != ''"> and vi.age &lt;= #{params.endAge}</if>
-        <if test="status != null  and status != ''"> and vi.status = #{status}</if>
-        <if test="code != null  and code != ''"> and vi.code = #{code}</if>
-        <if test="birthday != null  and birthday != ''"> and vi.birthday = #{birthday}</if>
-        <if test="workUnit != null  and workUnit != ''"> and vi.work_unit = #{workUnit}</if>
-        <if test="nowIn != null  and nowIn != ''"> and vi.now_in = #{nowIn}</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>
+        <choose>
+            <when test="type == 1">and vi.province_id = #{areaId}</when>
+            <when test="type == 2">and vi.city_id = #{areaId}</when>
+            <when test="type == 3">and vi.region_id = #{areaId}</when>
+            <when test="type == 4">and vi.village_towns_id = #{areaId}</when>
+            <when test="type == 5">and vi.village_id = #{areaId}</when>
+        </choose>
+    </select>
+
+    <select id="listByCzJs" resultMap="CzrkResult">
+        select vi.id, vi.update_time
+        from czrk vi
+        where vi.is_del = 'Y' and vi.update_time &gt;= #{startTime} and vi.update_time &lt;= #{endTime}
+        <choose>
+            <when test="type == 1">and vi.province_id = #{areaId}</when>
+            <when test="type == 2">and vi.city_id = #{areaId}</when>
+            <when test="type == 3">and vi.region_id = #{areaId}</when>
+            <when test="type == 4">and vi.village_towns_id = #{areaId}</when>
+            <when test="type == 5">and vi.village_id = #{areaId}</when>
+        </choose>
     </select>
 
     <select id="listByCode" resultMap="CzrkResult">
@@ -342,13 +330,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         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>
+        <choose>
+            <when test="type == 1">and vi.province_id = #{areaId}</when>
+            <when test="type == 2">and vi.city_id = #{areaId}</when>
+            <when test="type == 3">and vi.region_id = #{areaId}</when>
+            <when test="type == 4">and vi.village_towns_id = #{areaId}</when>
+            <when test="type == 5">and vi.village_id = #{areaId}</when>
+        </choose>
     </select>
 
     <select id="selectCzrkById" parameterType="Long" resultMap="CzrkResult">
@@ -394,6 +382,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </choose>
     </select>
 
+
     <select id="stsByWrl" resultType="int">
         select count(vi.id)
         from czrk vi
@@ -587,7 +576,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                 <when test="type == 1">and jzdz.province_id = #{areaId}</when>
                 <when test="type == 2">and jzdz.city_id = #{areaId}</when>
                 <when test="type == 3">and jzdz.region_id = #{areaId}</when>
-                <when test="type == 4">and jzdz.village_towns_id = #{areaId}</when>
+                <when test="type == 4">and jzdz.town_id = #{areaId}</when>
                 <when test="type == 5">and jzdz.village_id = #{areaId}</when>
             </choose>
 
@@ -606,4 +595,64 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </where>
         GROUP BY czrk.id
     </select>
+
+    <select id="countByHjXz" resultMap="CzrkResult">
+        SELECT czrk.id, czrk.create_time
+        from czrk
+        left join czrk_jzdz jzdz on czrk.id = jzdz.czrk_id
+        where czrk.is_del = 'N' and czrk.create_time &gt;= #{startTime} and czrk.create_time &lt;= #{endTime}
+       <!-- <if test="userName != null  and userName != ''">
+            and (czrk.user_name like concat('%', #{userName}, '%') or czrk.id_card like concat('%', #{userName}, '%'))
+        </if>-->
+
+        <choose>
+            <when test="type == 1">and jzdz.province_id = #{areaId}</when>
+            <when test="type == 2">and jzdz.city_id = #{areaId}</when>
+            <when test="type == 3">and jzdz.region_id = #{areaId}</when>
+            <when test="type == 4">and jzdz.town_id = #{areaId}</when>
+            <when test="type == 5">and jzdz.village_id = #{areaId}</when>
+        </choose>
+        GROUP BY czrk.id
+    </select>
+
+    <select id="countByHjJs" resultMap="CzrkResult">
+        SELECT czrk.id, czrk.create_time
+        from czrk
+        left join czrk_jzdz jzdz on czrk.id = jzdz.czrk_id
+        where czrk.is_del = 'Y' and czrk.update_time &gt;= #{startTime} and czrk.update_time &lt;= #{endTime}
+       <!-- <if test="userName != null  and userName != ''">
+            and (czrk.user_name like concat('%', #{userName}, '%') or czrk.id_card like concat('%', #{userName}, '%'))
+        </if>-->
+
+        <choose>
+            <when test="type == 1">and jzdz.province_id = #{areaId}</when>
+            <when test="type == 2">and jzdz.city_id = #{areaId}</when>
+            <when test="type == 3">and jzdz.region_id = #{areaId}</when>
+            <when test="type == 4">and jzdz.town_id = #{areaId}</when>
+            <when test="type == 5">and jzdz.village_id = #{areaId}</when>
+        </choose>
+        GROUP BY czrk.id
+    </select>
+
+
+    <select id="countHj" resultMap="CzrkResult">
+        SELECT czrk.id
+        from czrk
+        left join czrk_jzdz jzdz on czrk.id = jzdz.czrk_id
+        where czrk.is_del = 'N'
+        <!--<if test="userName != null  and userName != ''">
+            and (czrk.user_name like concat('%', #{userName}, '%') or czrk.id_card like concat('%', #{userName}, '%'))
+        </if>-->
+
+        <choose>
+            <when test="type == 1">and jzdz.province_id = #{areaId}</when>
+            <when test="type == 2">and jzdz.city_id = #{areaId}</when>
+            <when test="type == 3">and jzdz.region_id = #{areaId}</when>
+            <when test="type == 4">and jzdz.town_id = #{areaId}</when>
+            <when test="type == 5">and jzdz.village_id = #{areaId}</when>
+        </choose>
+        GROUP BY czrk.id
+    </select>
+
+
 </mapper>