shiqian 3 жил өмнө
parent
commit
97f5faaf46

+ 2 - 0
boman-api/boman-domain/src/main/java/com.boman.domain/BaseEntity.java

@@ -1,6 +1,8 @@
 package com.boman.domain;
 
 
+import com.fasterxml.jackson.annotation.JsonFormat;
+
 import java.io.Serializable;
 import java.util.Date;
 import java.util.HashMap;

+ 11 - 0
boman-api/boman-domain/src/main/java/com/boman/domain/VaccineInfoOperation.java

@@ -290,6 +290,9 @@ public class VaccineInfoOperation extends BaseEntity {
     /** 认领人***/
     private String rlr;
 
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date updateTime;
+
     public String getRlr() {
         return rlr;
     }
@@ -722,4 +725,12 @@ public class VaccineInfoOperation extends BaseEntity {
     public void setResidenceVillage(String residenceVillage) {
         this.residenceVillage = residenceVillage;
     }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
 }

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

@@ -69,7 +69,7 @@ public class CzrkController extends BaseController {
     }
 
     /**
-     * 功能描述: 删除常住人口
+     * 功能描述: 删除常住人口,人员认领中的删除也是这个接口
      *
      * @return com.boman.domain.dto.AjaxResult
      */
@@ -78,6 +78,17 @@ public class CzrkController extends BaseController {
         return vaccineInfoService.deleteCzrk(vaccineInfoOperation);
     }
 
+    /**
+     * 功能描述: 回收站的还原功能
+     *
+     * @return com.boman.domain.dto.AjaxResult
+     */
+    @GetMapping("/reduction/{id}")
+    public AjaxResult reduction(@PathVariable("id") String id) {
+        int reduction = vaccineInfoService.reduction(id);
+        return reduction > 0 ? AjaxResult.success() : AjaxResult.error();
+    }
+
     /**
      * 功能描述: 根据户号查找家庭中所有人员
      *

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

@@ -74,8 +74,8 @@ public class RyrlController extends BaseController {
      * @return com.boman.domain.dto.AjaxResult
      */
     @GetMapping("/sts")
-    public AjaxResult stsByApplet() {
-        return AjaxResult.success("成功", vaccineInfoService.stsByApplet());
+    public AjaxResult stsByApplet(Long townId, Long villageId, String userName) {
+        return AjaxResult.success("成功", vaccineInfoService.stsByApplet(townId, villageId, userName));
     }
 
 

+ 4 - 2
boman-web-core/src/main/java/com/boman/web/core/mapper/VaccineInfoMapper.java

@@ -103,9 +103,9 @@ public interface VaccineInfoMapper
      */
     VaccineInfoOperation getByIdCard(String idCard);
 
-    int stsByYrl(@Param("deptIdList") List<Long> deptIdList);
+    int stsByYrl(@Param("deptIdList") List<Long> deptIdList, @Param("userName") String userName);
 
-    int stsByWrl(@Param("deptIdList") List<Long> deptIdList);
+    int stsByWrl(@Param("deptIdList") List<Long> deptIdList, @Param("userName") String userName);
 
     int deleteCzrk(VaccineInfoOperation vaccineInfoOperation);
 
@@ -124,4 +124,6 @@ public interface VaccineInfoMapper
     int countIdCard(String idCard);
 
     List<VaccineInfoOperation> listByCode(String code);
+
+    int reduction(String id);
 }

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

@@ -94,7 +94,7 @@ public interface IVaccineInfoService
 
     VaccineInfoOperation getById(Long id);
 
-    JSONObject stsByApplet();
+    JSONObject stsByApplet(Long townId, Long villageId, String userName);
 
     JSONObject stsByCzrk();
     JSONObject stsByCzrkHomePage();
@@ -106,4 +106,12 @@ public interface IVaccineInfoService
     AjaxResult deleteCzrk(VaccineInfoOperation vaccineInfoOperation);
 
     List<VaccineInfoOperation> family(String code);
+
+    /**
+     * 功能描述: 回收站的还原功能
+     *
+     * @param id id
+     * @return int
+     */
+    int reduction(String id);
 }

+ 98 - 58
boman-web-core/src/main/java/com/boman/web/core/service/vaccineInfo/impl/VaccineInfoServiceImpl.java

@@ -6,7 +6,6 @@ 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.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;
@@ -34,8 +33,6 @@ 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.sql.Timestamp;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
@@ -43,9 +40,11 @@ import java.util.*;
 import java.util.concurrent.TimeUnit;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
+import java.util.stream.Collectors;
 
 import static com.boman.common.core.utils.StringUtils.isNotEmpty;
-import static com.boman.common.core.utils.obj.ObjectUtils.*;
+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_;
 
 /**
@@ -1145,33 +1144,46 @@ public class VaccineInfoServiceImpl implements IVaccineInfoService {
     }
 
     @Override
-    public JSONObject stsByApplet() {
+    public JSONObject stsByApplet(Long townId, Long villageId, String userName) {
         Long 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;
+        List<Long> deptIdList = new ArrayList<>(16);
+        // 未加搜索条件
+        if (isEmpty(townId) && isEmpty(villageId)) {
+            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;
+                    }
                 }
             }
-        }
 
-        List<Long> deptIdList = new ArrayList<>(16);
-        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);
+            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);
+                    }
                 }
             }
+        } 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 = vaccineInfoMapper.stsByYrl(deptIdList);
-        int wrl = vaccineInfoMapper.stsByWrl(deptIdList);
+        int yrl = vaccineInfoMapper.stsByYrl(deptIdList, userName);
+        int wrl = vaccineInfoMapper.stsByWrl(deptIdList, userName);
         JSONObject result = new JSONObject(3);
         result.put("yrl", yrl);
         result.put("wrl", wrl);
@@ -1204,45 +1216,52 @@ public class VaccineInfoServiceImpl implements IVaccineInfoService {
         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;
             }
-            
-            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) {
+            ThreadPoolService.execute(() -> {
+                List<SysDept> allDepts = remoteDeptService.listChildrenDepts(1L);
+                List<SysDept> townsDepts = new ArrayList<>(16);
                 for (SysDept allDept : allDepts) {
                     if (isEmpty(allDept.getParentId())) continue;
-                    if (townsDept.getId().equals(allDept.getParentId())) {
-                        cunDepts.add(allDept);
+                    if (allDept.getParentId() == (1L)) {
+                        townsDepts.add(allDept);
                     }
                 }
-            }
-            result.put("cun", isEmpty(cunDepts) ? 0 : cunDepts.size());
+                result.put("zhen", townsDepts.size()); // 镇
 
-            List<SysDept> zuDept = new ArrayList<>(16);
-            for (SysDept cunDept : cunDepts) {
-                for (SysDept allDept : allDepts) {
-                    if (cunDept.getId().equals(allDept.getParentId())) {
-                        zuDept.add(allDept);
+                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("zu", isEmpty(zuDept) ? 0 : zuDept.size());
-            int xz = vaccineInfoMapper.countByXz(condition);
-            int js = vaccineInfoMapper.countByJs(condition);
-            result.put("xz", xz);
-            result.put("js", js);
-            result.put("czrk", vaccineInfoMapper.countCzrk(condition));
-            redisService.setCacheObject(packRedisKey("single:" + deptId), result, 1L, TimeUnit.DAYS);
+                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 xz = vaccineInfoMapper.countByXz(condition);
+                int js = vaccineInfoMapper.countByJs(condition);
+                result.put("xz", xz);
+                result.put("js", js);
+                result.put("czrk", vaccineInfoMapper.countCzrk(condition));
+//            redisService.setCacheObject(packRedisKey("single:" + deptId), result, 1L, TimeUnit.DAYS);
+                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)) {
@@ -1250,7 +1269,8 @@ public class VaccineInfoServiceImpl implements IVaccineInfoService {
             }
 
             townSts(result, condition, deptId, deptName, true);
-            redisService.setCacheObject(packRedisKey("town:" + deptId), result, 1L, TimeUnit.DAYS);
+//            redisService.setCacheObject(packRedisKey("town:" + deptId), result, 1L, TimeUnit.DAYS);
+            setIntoRedis(packRedisKey("town:" + deptId), result);
         }
 
         return result;
@@ -1341,7 +1361,9 @@ public class VaccineInfoServiceImpl implements IVaccineInfoService {
                 }
 
                 result.put("townDatas", towsDataList);
-                redisService.setCacheObject(packRedisKey(deptId + ""), result, 1L, TimeUnit.DAYS);
+//                redisService.setCacheObject(packRedisKey(deptId + ""), result, 1L, TimeUnit.DAYS);
+                setIntoRedis(packRedisKey(deptId + ""), result);
+                QIANSHANSHI = result;
             });
 
             return QIANSHANSHI;
@@ -1354,7 +1376,8 @@ public class VaccineInfoServiceImpl implements IVaccineInfoService {
 
             ThreadPoolService.execute(() -> {
                 townSts(result, condition, deptId, deptName, true);
-                redisService.setCacheObject(packRedisKey("town:" + deptId), result, 1L, TimeUnit.DAYS);
+//                redisService.setCacheObject(packRedisKey("town:" + deptId), result, 1L, TimeUnit.DAYS);
+                setIntoRedis(packRedisKey("town:" + deptId), result);
             });
 
             return ZHEN;
@@ -1551,9 +1574,9 @@ public class VaccineInfoServiceImpl implements IVaccineInfoService {
             return AjaxResult.error("该信息不存在,无法删除");
         }
 
-        if (isEmpty(operation.getVillageTowns())) {
-            return AjaxResult.error("该人员为未认领人员,无法删除");
-        }
+//        if (isEmpty(operation.getVillageTowns())) {
+//            return AjaxResult.error("该人员为未认领人员,无法删除");
+//        }
 
         vaccineInfoOperation.setUpdateBy(AuthUtils.getLoginUser().getSysUser().getUserName());
         int delete = vaccineInfoMapper.deleteCzrk(vaccineInfoOperation);
@@ -1602,7 +1625,24 @@ public class VaccineInfoServiceImpl implements IVaccineInfoService {
         return infoOperations;
     }
 
+    /**
+     * 功能描述: 回收站的还原功能
+     *
+     * @param id id
+     * @return int
+     */
+    @Override
+    public int reduction(String id) {
+        if (isEmpty(id)) return 0;
+
+        return vaccineInfoMapper.reduction(id);
+    }
+
     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);
+    }
 }

+ 16 - 2
boman-web-core/src/main/resources/mapper/VaccineInfoMapper.xml

@@ -256,7 +256,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         select vi.id, vi.create_time, vi.update_time, vi.is_del, vi.update_by, vi.user_name, vi.phone_num, vi.id_card
         , vi.gender, vi.province, vi.city, vi.region, vi.now_in, vi.house_type, vi.update_by, vi.code
         from vaccine_info vi
-        where vi.is_del = 'N' and vi.update_time &gt;= #{startTime} and vi.update_time &lt;= #{endTime}
+        where vi.is_del = 'Y' and vi.update_time &gt;= #{startTime} and vi.update_time &lt;= #{endTime}
         <if test="userName != null  and userName != ''">
             and (vi.user_name like concat('%', #{userName}, '%') or vi.id_card like concat('%', #{userName}, '%'))
         </if>
@@ -313,7 +313,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="countByJs" resultType="int">
         select count(1)
         from vaccine_info vi
-        where vi.is_del = 'N' and vi.update_time &gt;= #{startTime} and vi.update_time &lt;= #{endTime}
+        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>
@@ -463,6 +463,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where vi.is_del = 'N'
         <!-- 已认领 -->
         and (vi.village_towns is not null or vi.village_towns != '')
+        <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=")">
@@ -477,6 +480,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where vi.is_del = 'N'
         <!-- 未认领 -->
         and (vi.village_towns is null or vi.village_towns = '')
+        <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=")">
@@ -494,6 +500,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where id = #{id}
     </update>
 
+    <update id="reduction">
+        update vaccine_info
+        set is_del        = 'N'
+          , update_by     = #{updateBy}
+          , update_time   = sysdate()
+        where id = #{id}
+    </update>
+
     <select id="selectVaccineInfoListByPage" parameterType="Integer" resultMap="VaccineInfoResult">
         select * from vaccine_info limit   #{startNum}, #{endNum}
     </select>