Pārlūkot izejas kodu

当前单位:镇,村:7个,组:300个,常住人口:5000人,新增 2人 减少 2人

shiqian 3 gadi atpakaļ
vecāks
revīzija
25c316a9c7

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

@@ -108,4 +108,13 @@ public interface VaccineInfoMapper
     int stsByWrl(@Param("deptIdList") List<Long> deptIdList);
 
     int deleteCzrk(VaccineInfoOperation vaccineInfoOperation);
+
+    List<VaccineInfoOperation> listByXzAndJs(VaccineInfoOperation condition);
+    /**
+     * 功能描述: 根据deptIdList查找多少已经认领的(常住人口数量)
+     *
+     * @param condition deptIdList
+     * @return int
+     */
+    int countCzrk(VaccineInfoOperation condition);
 }

+ 68 - 36
boman-web-core/src/main/java/com/boman/web/core/service/vaccineInfo/impl/VaccineInfoServiceImpl.java

@@ -1141,15 +1141,28 @@ public class VaccineInfoServiceImpl implements IVaccineInfoService {
 
         List<SysRole> roles = sysUser.getRoles();
         List<String> roleKeySets = map(roles, SysRole::getRoleKey);
+        Date todayStart = DateUtils.getTodayStart();
+        Date todayEnd = DateUtils.getTodayEnd();
+        VaccineInfoOperation condition = new VaccineInfoOperation();
+        condition.setStartTime(todayStart);
+        condition.setEndTime(todayEnd);
+        List<VaccineInfoOperation> list = null;
         // 市领导
         if (roleKeySets.contains("city") || roleKeySets.contains("admin")) {
             List<SysDept> allDepts = remoteDeptService.listChildrenDepts(1L);
-            List<SysDept> townsDepts = filter(allDepts, dept -> 1L == dept.getParentId());
+            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);
                     }
@@ -1167,51 +1180,70 @@ public class VaccineInfoServiceImpl implements IVaccineInfoService {
             }
             result.put("zu", isEmpty(zuDept) ? 0 : zuDept.size());
 
-            VaccineInfoOperation condition = new VaccineInfoOperation();
-            condition.setStartTime(DateUtils.getTodayStart());
-            condition.setEndTime(DateUtils.getTodayEnd());
-
-//            if (deptId == null) {
-//                deptId = AuthUtils.getLoginUser().getSysUser().getDeptId();
-//                //判断是否是管理员
-//                if (isNotEmpty(roles)) {
-//                    for (SysRole role : roles) {
-//                        String roleKey = role.getRoleKey();
-//                        if ("admin".equals(roleKey) || "city".equals(roleKey)) {
-//                            deptId = null;
-//                            break;
-//                        }
-//                    }
-//                }
-//            }
-//
-//            List<Long> deptIdList = new ArrayList<>();
-//            if (deptId != null) {
-//                List<SysDept> sysDepts = remoteDeptService.listChildrenDepts(deptId);
-//                if (sysDepts != null && sysDepts.size() > 0) {
-//                    for (SysDept sysDept : sysDepts) {
-//                        Long id = sysDept.getId();
-//                        deptIdList.add(id);
-//                    }
-//                }
-//            }
-//            condition.setDeptIdList(deptIdList);
-            List<VaccineInfoOperation> list = vaccineInfoMapper.selectVaccineInfoList(condition);
+            list = vaccineInfoMapper.listByXzAndJs(condition);
+        } else if (roleKeySets.contains("sys:town")) {
+            // 乡镇以下的所有部门
+            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));
+            list = vaccineInfoMapper.listByXzAndJs(condition);
+        }
 
+        // 增加、减少
+        if (isEmpty(list)) {
             result.put("xz", 0);
             result.put("js", 0);
-        } else if (roleKeySets.contains("sys:town")) {
-            // 镇领导
+        } else {
+            int xz = 0, js = 0;
+            for (VaccineInfoOperation operation : list) {
+                Date createTime = operation.getCreateTime(), updateTime = operation.getUpdateTime();
+                String isDel = operation.getIsDel();
+                if ("N".equals(isDel) && createTime.after(todayStart) && createTime.before(todayEnd)) {
+                    xz++;
+                } else if ("Y".equals(isDel) && updateTime.after(todayStart) && updateTime.before(todayEnd)) {
+                    js++;
+                }
+            }
 
+            result.put("xz", xz);
+            result.put("js", js);
         }
-//        int village = remoteDeptService.countChildrenByVillage(deptId);
-
 
-        return null;
+        result.put("czrk", vaccineInfoMapper.countCzrk(condition));
+        return result;
     }
 
     @Override
     public AjaxResult deleteCzrk(VaccineInfoOperation vaccineInfoOperation) {
+        VaccineInfoOperation operation = vaccineInfoMapper.selectVaccineInfoById(vaccineInfoOperation.getId());
+        if (null == operation) {
+            return AjaxResult.error("该信息不存在,无法删除");
+        }
+
+        if (isEmpty(operation.getVillageTowns())) {
+            return AjaxResult.error("该人员为未认领人员,无法删除");
+        }
+
         vaccineInfoOperation.setUpdateBy(AuthUtils.getLoginUser().getSysUser().getUserName());
         int delete = vaccineInfoMapper.deleteCzrk(vaccineInfoOperation);
         return delete > 0 ? AjaxResult.success() : AjaxResult.error();

+ 36 - 0
boman-web-core/src/main/resources/mapper/VaccineInfoMapper.xml

@@ -135,6 +135,42 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         order by vi.create_time DESC ,vi.vaccination_time DESC
     </select>
 
+    <select id="listByXzAndJs"  resultMap="VaccineInfoResult">
+        select vi.id, vi.village_towns, vi.village, vi.villager_group,vi.age, vi.house_type, vi.domicile, vi.province,
+        vi.city,vi.should_slow,
+        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.dept_id
+        from vaccine_info vi
+        where (vi.is_del = 'N' and vi.create_time &gt;= #{startTime} and vi.create_time &lt;= #{endTime}) or
+        (vi.is_del = 'Y' and vi.update_time &gt;= #{startTime} and vi.update_time &lt;= #{endTime})
+        <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="countCzrk" resultType="int">
+        select count(vi.id)
+        from vaccine_info vi
+        where vi.is_del = 'N'
+        <!-- 已认领 -->
+        <if test="ryrl == true">and (vi.village_towns is not null or vi.village_towns != '')</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="listByRlry" resultMap="VaccineInfoResult">
         select vi.id, vi.user_name, vi.phone_num, vi.id_card, vi.gender
         from vaccine_info vi