From 70d2a5d0f9c6951b2d4cac954041ed73582ff7eb Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期一, 09 六月 2025 11:54:00 +0800
Subject: [PATCH] 6.9新增登录失败冻结逻辑

---
 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActAcidRecordServiceImpl.java |  238 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 226 insertions(+), 12 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActAcidRecordServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActAcidRecordServiceImpl.java
index f382014..72bf5de 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActAcidRecordServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActAcidRecordServiceImpl.java
@@ -8,16 +8,18 @@
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.panzhihua.common.model.dtos.community.acid.BatchCheckAcidRecordDTO;
 import com.panzhihua.common.model.dtos.community.acid.ComActAcidRecordDTO;
 import com.panzhihua.common.model.vos.R;
+import com.panzhihua.common.model.vos.community.StatisticsPhotoVO;
 import com.panzhihua.common.model.vos.community.acid.*;
 import com.panzhihua.common.service.user.UserService;
 import com.panzhihua.common.utlis.DateUtils;
 import com.panzhihua.common.utlis.StringUtils;
 import com.panzhihua.service_community.dao.*;
-import com.panzhihua.service_community.entity.ComActAcidDangerMember;
-import com.panzhihua.service_community.entity.ComActAcidRecord;
-import com.panzhihua.service_community.entity.ComActAcidUpdateRecord;
+import com.panzhihua.service_community.entity.*;
+import com.panzhihua.service_community.model.dos.ComActDO;
+import com.panzhihua.service_community.model.dos.ComStreetDO;
 import com.panzhihua.service_community.service.ComActAcidRecordService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.amqp.rabbit.core.RabbitTemplate;
@@ -28,9 +30,10 @@
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
+import java.time.LocalDate;
+import java.util.*;
+import java.util.function.Function;
+import java.util.stream.Collectors;
 
 import static com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isNotEmpty;
 import static com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isNull;
@@ -60,15 +63,31 @@
     private ComActAcidUpdateRecordDao comActAcidUpdateRecordDao;
     @Resource
     private ComAreaTownCommunityDao comAreaTownCommunityDao;
+    @Resource
+    private ComCunDao comCunDao;
+    @Resource
+    private ComStreetDAO comStreetDAO;
+    @Resource
+    private SysUserDao sysUserDao;
 
     @Override
     public R pageList(ComActAcidRecordDTO comActAcidRecordDTO) {
+        //是否需要筛选
+        comActAcidRecordDTO.setType(isVilliage(comActAcidRecordDTO.getLoginAccount()));
+        log.info("搜索条件=========="+comActAcidRecordDTO);
+        //获取当前登录账号的社区名
         return R.ok(this.baseMapper.pageList(new Page<>(comActAcidRecordDTO.getPage(), comActAcidRecordDTO.getSize()),comActAcidRecordDTO));
     }
 
     @Override
     public R export(ComActAcidRecordDTO comActAcidRecordDTO) {
-        List<ComActAcidRecordExcelReturn> comActAcidRecordExcelVOS=this.baseMapper.export(comActAcidRecordDTO);
+        List<ComActAcidRecordExcelReturn> comActAcidRecordExcelVOS=new ArrayList<>();
+        if(StringUtils.isNotEmpty(comActAcidRecordDTO.getIds())){
+            comActAcidRecordExcelVOS=this.baseMapper.selectByIds(comActAcidRecordDTO.getIds());
+        }
+        else {
+            comActAcidRecordExcelVOS=this.baseMapper.export(comActAcidRecordDTO);
+        }
         comActAcidRecordExcelVOS.forEach(comActAcidRecordExcelVO -> {
             if(StringUtils.isNotEmpty(comActAcidRecordExcelVO.getTouristCity())&&comActAcidRecordExcelVO.getTouristCity().contains("[")){
                 JSONArray jsonArray = JSON.parseArray(comActAcidRecordExcelVO.getTouristCity());
@@ -121,7 +140,7 @@
     public R insertRecord(ComActAcidRecordVO comActAcidRecordVO) {
         Integer count= this.baseMapper.selectCount(new QueryWrapper<ComActAcidRecord>().lambda().eq(ComActAcidRecord::getIsDel,0).eq(ComActAcidRecord::getIdCard,comActAcidRecordVO.getIdCard()).ge(ComActAcidRecord::getCreateTime, DateUtils.getCurrentDate(DateUtils.yyyyMMdd_format)));
         if(count>0){
-            return R.fail("请勿重复提交");
+            return R.fail("您的社区报备信息已填写完整,请勿重复提交!");
         }
         if(StringUtils.isEmpty(comActAcidRecordVO.getLocalCity())){
             rabbitTemplate.convertAndSend("huacheng.acid.exchange", "huacheng.acid.key", comActAcidRecordVO, message -> {
@@ -142,6 +161,12 @@
             String dangerArea = comActAcidRecordVO.getDangerArea();
             String outsideCity = comActAcidRecordVO.getOutsideCity();
             String acidTest = comActAcidRecordVO.getAcidTest();
+            if(StringUtils.isEmpty(acidTest)){
+                acidTest="阴性";
+            }
+            if(StringUtils.isEmpty(travelCard)){
+                travelCard="否";
+            }
             if (StringUtils.inStringIgnoreCase(colorMark, "红码", "黄码") || travelCard.equals("是")
                     || dangerArea.equals("是") || outsideCity.equals("是") || acidTest.equals("阳性")) {
                 //风险人员
@@ -153,7 +178,7 @@
                 //未填住址人员
                 saveAcidDangerMember(comActAcidRecordVO, comActAcidRecord.getId(), 2, null);
             }
-            return R.ok();
+            return R.ok(comActAcidRecord.getId().toString());
         }
 
         return R.fail("操作失败,请重新尝试");
@@ -202,7 +227,7 @@
             }
         }
         ComActAcidDangerMember dangerMember = comActAcidDangerMemberDao.selectOne(new LambdaQueryWrapper<ComActAcidDangerMember>()
-                .eq(ComActAcidDangerMember::getIdCard, comActAcidRecordVO.getIdCard()).eq(ComActAcidDangerMember::getRecordId, recordId));
+                .eq(ComActAcidDangerMember::getIdCard, comActAcidRecordVO.getIdCard()).eq(ComActAcidDangerMember::getRecordId, recordId).orderByDesc(ComActAcidDangerMember::getCreateTime).last("limit 1"));
         if (isNull(dangerMember)) {
             dangerMember = new ComActAcidDangerMember();
             dangerMember.setName(comActAcidRecordVO.getName());
@@ -241,8 +266,12 @@
         return R.ok(this.baseMapper.fiveCount(localCity));
     }
     @Override
-    public R fiveCountPlus(String date,String localCity) {
-        return R.ok(this.baseMapper.fiveCountPlus(date,localCity));
+    public R fiveCountPlus(String date,String localCity,String loginAccount) {
+        Integer type=3;
+        if (StringUtils.isNotEmpty(loginAccount)){
+             type = isVilliage(loginAccount);
+        }
+        return R.ok(this.baseMapper.fiveCountPlus(date,localCity,type));
     }
 
     @Override
@@ -379,6 +408,12 @@
         String dangerArea = comActAcidRecordVO.getDangerArea();
         String outsideCity = comActAcidRecordVO.getOutsideCity();
         String acidTest = comActAcidRecordVO.getAcidTest();
+        if(StringUtils.isEmpty(acidTest)){
+            acidTest="阴性";
+        }
+        if(StringUtils.isEmpty(travelCard)){
+            travelCard="否";
+        }
         if (StringUtils.inStringIgnoreCase(colorMark, "红码", "黄码") || travelCard.equals("是") || dangerArea.equals("是")
             || outsideCity.equals("是") || acidTest.equals("阳性")) {
             // 风险人员
@@ -430,6 +465,12 @@
         String dangerArea = comActAcidRecordVO.getDangerArea();
         String outsideCity = comActAcidRecordVO.getOutsideCity();
         String acidTest = comActAcidRecordVO.getAcidTest();
+        if(StringUtils.isEmpty(acidTest)){
+            acidTest="阴性";
+        }
+        if(StringUtils.isEmpty(travelCard)){
+            travelCard="否";
+        }
         if (StringUtils.inStringIgnoreCase(colorMark, "红码", "黄码") || travelCard.equals("是") || dangerArea.equals("是")
                 || outsideCity.equals("是") || acidTest.equals("阳性")) {
             // 风险人员
@@ -477,4 +518,177 @@
         }
         return R.ok(comActAcidRecordVO);
     }
+
+    @Override
+    public R test() {
+        List<ComCun> comCuns=comCunDao.selectList(new QueryWrapper<ComCun>());
+        comCuns.forEach(comCun->{
+           ComActDO comActDO= comActDAO.selectOne(new QueryWrapper<ComActDO>().lambda().eq(ComActDO::getName,comCun.getCommunity()));
+            if(comActDO==null){
+                ComStreetDO comStreetDO = comStreetDAO.selectOne(new QueryWrapper<ComStreetDO>().lambda().eq(ComStreetDO::getName,comCun.getTown()));
+                if(comStreetDO==null){
+                    comStreetDO=new ComStreetDO();
+                    comStreetDO.setName(comCun.getTown());
+                    areaCheck(comCun,comStreetDO);
+                    comStreetDO.setAccount(comCun.getAccount());
+                    comStreetDAO.insert(comStreetDO);
+                }
+                comActDO=new ComActDO();
+                comActDO.setStreetId(comStreetDO.getStreetId());
+                comActDO.setAreaCode(comStreetDO.getAreaCode().toString());
+                comActDO.setName(comCun.getCommunity());
+                comActDO.setContacts(comCun.getName());
+                comActDO.setContactsPhone(comCun.getPhone());
+                comActDAO.insert(comActDO);
+            }
+            ComAreaTownCommunity community=comAreaTownCommunityDao.selectOne(new QueryWrapper<ComAreaTownCommunity>().lambda().eq(ComAreaTownCommunity::getArea,comCun.getArea()).eq(ComAreaTownCommunity::getTown,comCun.getTown()).eq(ComAreaTownCommunity::getCommunity,comCun.getCommunity()));
+            if(community==null){
+                community=new ComAreaTownCommunity();
+                community.setArea(comCun.getArea());
+                community.setTown(comCun.getTown());
+                community.setCommunity(comCun.getCommunity());
+                comAreaTownCommunityDao.insert(community);
+            }else {
+                community.setCommunityId(comActDO.getCommunityId());
+                comAreaTownCommunityDao.updateById(community);
+            }
+            SysUser sysUser=sysUserDao.selectOne(new QueryWrapper<SysUser>().lambda().eq(SysUser::getAccount,comCun.getAccount()));
+            if(sysUser!=null){
+                System.out.println(comCun.getAccount()+","+comCun.getCommunity());
+            }
+            else {
+                sysUser=new SysUser();
+                sysUser.setAccount(comCun.getAccount());
+                sysUser.setPassword("$2a$10$F/2lE2NMhKNHJfi5.FLmfu7jIr7ImRWgCTTeO6m3IRNR2V4sv8YR.");
+                sysUser.setName(comCun.getCommunity());
+                sysUser.setType(9);
+                sysUserDao.insert(sysUser);
+            }
+        });
+        return null;
+    }
+
+    /**
+     * 批量核对防疫信息数据
+     * @param batchCheckAcidRecordDTO
+     * @return
+     */
+    @Override
+    public R batchCheck(BatchCheckAcidRecordDTO batchCheckAcidRecordDTO) {
+        this.baseMapper.batchCheck(batchCheckAcidRecordDTO);
+        return R.ok();
+    }
+
+    @Override
+    public R checkCommit(Long userId) {
+        if(userId!=null){
+            List<ComActAcidRecord> comActAcidRecords= this.baseMapper.selectList(new QueryWrapper<ComActAcidRecord>().lambda().eq(ComActAcidRecord::getIsDel,0).eq(ComActAcidRecord::getUserId,userId).ge(ComActAcidRecord::getCreateTime, DateUtils.getCurrentDate(DateUtils.yyyyMMdd_format)).isNull(ComActAcidRecord::getColorImage));
+            return R.ok(comActAcidRecords);
+        }
+       return R.ok();
+    }
+
+    public static void areaCheck(ComCun area,ComStreetDO comStreetDO){
+        switch (area.getArea()){
+            case "西区": comStreetDO.setAreaCode(510423); break;
+            case "东区": comStreetDO.setAreaCode(510402); break;
+            case "仁和区": comStreetDO.setAreaCode(510411); break;
+            case "米易县": comStreetDO.setAreaCode(510421); break;
+            case "盐边县": comStreetDO.setAreaCode(510422); break;
+        }
+    }
+
+    /**
+     * 是否需要区分村落/社区
+     * */
+    private Integer isVilliage(String name){
+        if ("fangyipingtai".equals(name)){
+            return 3;
+        }else if ("pandashujuzhongxin".equals(name)){
+            return 1;
+        }else if ("pannongyenongcunju".equals(name)){
+            return 2;
+        }
+        return 3;
+    }
+
+    /**
+     * 统计红黄绿码
+     * @return
+     */
+    public R selectColorMarkGroup(){
+        //所有
+        List<ComActAcidColorChartsVO> comActAcidColorChartsVOS = this.baseMapper.selectColorMarkGroup();
+        int all = comActAcidColorChartsVOS.stream().mapToInt(ComActAcidColorChartsVO::getCountNum).sum();
+        for (ComActAcidColorChartsVO comActAcidColorChartsVO : comActAcidColorChartsVOS) {
+            if (0!=all){
+                BigDecimal countNum = new BigDecimal(comActAcidColorChartsVO.getCountNum());
+                BigDecimal allDecimal = new BigDecimal(all);
+                BigDecimal percent = countNum.divide(allDecimal,4, BigDecimal.ROUND_HALF_DOWN).multiply(new BigDecimal(100));
+                comActAcidColorChartsVO.setPercent(percent);
+            }
+        }
+//        Map<String, ComActAcidColorChartsVO> circleMap = comActAcidColorChartsVOS
+//                .stream()
+//                .collect(Collectors.toMap(ComActAcidColorChartsVO::getColorMark, Function.identity()));
+
+        //月份
+        List<ComActAcidColorChartsVO> comActAcidColorChartsVOS1 = this.baseMapper.selectColorMarkGroupByMonth();
+        //按颜色分组求和
+        Map<String, IntSummaryStatistics> colorCollect = comActAcidColorChartsVOS1
+                .stream()
+                .collect(Collectors.groupingBy(ComActAcidColorChartsVO::getColorMark,
+                        Collectors.summarizingInt(ComActAcidColorChartsVO::getCountNum)));
+
+        for (ComActAcidColorChartsVO comActAcidColorChartsVO : comActAcidColorChartsVOS1) {
+            String colorMark = comActAcidColorChartsVO.getColorMark();
+            if (colorCollect.containsKey(colorMark)){
+                IntSummaryStatistics intSummaryStatistics = colorCollect.get(colorMark);
+                long sum = intSummaryStatistics.getSum();
+                if (0L!=sum) {
+                    BigDecimal countNum = new BigDecimal(comActAcidColorChartsVO.getCountNum());
+                    BigDecimal sumDecimal = new BigDecimal(sum);
+                    BigDecimal percent = countNum.divide(sumDecimal, 4, BigDecimal.ROUND_HALF_DOWN).multiply(new BigDecimal(100));
+                    comActAcidColorChartsVO.setPercent(percent);
+                }
+            }
+        }
+        Map<String, Map<String, ComActAcidColorChartsVO>> colletMap = comActAcidColorChartsVOS1
+                .stream()
+                .collect(Collectors.groupingBy(ComActAcidColorChartsVO::getCountName,
+                        Collectors.toMap(ComActAcidColorChartsVO::getColorMark, Function.identity())));
+
+        String[] statusArr = {"红码","黄码","绿码"};
+        List<String> latest5Month = DateUtils.getLatest12Month(LocalDate.now(), 5);
+        for (String month : latest5Month) {
+            Map<String, ComActAcidColorChartsVO> map1;
+            if(colletMap.containsKey(month)){
+                map1 = colletMap.get(month);
+            }else {
+                map1 = new HashMap<>();
+            }
+            for (String status : statusArr) {
+                if (!map1.containsKey(status)){
+                    ComActAcidColorChartsVO comActAcidColorChartsVO = new ComActAcidColorChartsVO();
+                    comActAcidColorChartsVO.setCountNum(0);
+                    comActAcidColorChartsVO.setCountName(month);
+                    comActAcidColorChartsVO.setColorMark(status);
+                    comActAcidColorChartsVOS1.add(comActAcidColorChartsVO);
+                    map1.put(status,comActAcidColorChartsVO);
+                }
+            }
+            colletMap.put(month,map1);
+        }
+
+
+        Map<String, List<ComActAcidColorChartsVO>> chartMap = comActAcidColorChartsVOS1
+                .stream().sorted(Comparator.comparing(ComActAcidColorChartsVO::getCountName))
+                .collect(Collectors.groupingBy(ComActAcidColorChartsVO::getColorMark));
+
+        Map<String,Object> retMap = new HashMap<>();
+        retMap.put("comActAcidColorChartsVOS",comActAcidColorChartsVOS);
+        retMap.put("chartMap",chartMap);
+
+        return R.ok(retMap);
+    }
 }

--
Gitblit v1.7.1