From cc1098fc00a50cb1591d182f04bc37066ff0a9e2 Mon Sep 17 00:00:00 2001
From: 罗元桥 <2376770955@qq.com>
Date: 星期四, 05 八月 2021 15:12:39 +0800
Subject: [PATCH] Merge branch 'test' into 'master'

---
 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComSwDangerReportServiceImpl.java |  205 +++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 190 insertions(+), 15 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComSwDangerReportServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComSwDangerReportServiceImpl.java
index d0a3837..a28111e 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComSwDangerReportServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComSwDangerReportServiceImpl.java
@@ -15,6 +15,7 @@
 import com.panzhihua.common.model.vos.community.ComSwDangerReportVO;
 import com.panzhihua.common.model.vos.community.ComSwSafetyWorkRecordVO;
 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.ComSwDangerReportDAO;
 import com.panzhihua.service_community.dao.ComSwPatrolRecordDAO;
@@ -30,9 +31,7 @@
 
 import javax.annotation.Resource;
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
+import java.util.*;
 
 /**
  * @auther txb
@@ -72,10 +71,48 @@
         IPage<ComSwDangerReportVO> iPage = comSwDangerReportDAO.pageDangerReport(page, comSwPatrolRecordPageDTO);
         if (!iPage.getRecords().isEmpty()) {
             iPage.getRecords().forEach(comSwDangerReportVO -> {
-                if (StringUtils.isNotEmpty(comSwDangerReportVO.getAssignPerson())) {
-                    comSwDangerReportVO.setIsAssign(ComSwDangerReportVO.isOk.no);
-                }else {
+                if (StringUtils.isNotEmpty(comSwDangerReportVO.getStatus()) && "2".equals(comSwDangerReportVO.getStatus())) {
                     comSwDangerReportVO.setIsAssign(ComSwDangerReportVO.isOk.yes);
+                }else {
+                    comSwDangerReportVO.setIsAssign(ComSwDangerReportVO.isOk.no);
+                }
+                StringBuilder patrolNameString = new StringBuilder();
+                StringBuilder patrolPhoneString = new StringBuilder();
+                //巡查人员id查询巡查人员的名字和电话
+                if(StringUtils.isNotEmpty(comSwDangerReportVO.getPatrolPerson())){
+                    String[] patrolIds = comSwDangerReportVO.getPatrolPerson().split(",");
+                    for (int i = 0; i < patrolIds.length ; i++) {
+                        Map<String,String> leader = comSwPatrolRecordDAO.getPbServiceTeamById(patrolIds[i]);
+                        if(leader != null){
+                            if(i != 0){
+                                patrolNameString.append(",");
+                                patrolPhoneString.append(",");
+                            }
+                            patrolNameString.append(leader.get("name"));
+                            patrolPhoneString.append(leader.get("phone"));
+                        }
+                    }
+                    comSwDangerReportVO.setPPersonName(patrolNameString.toString());
+                    comSwDangerReportVO.setPPersonPhone(patrolPhoneString.toString());
+                }
+                //整改人员id查询整改人员的名字和电话
+                StringBuilder dangerNameString = new StringBuilder();
+                StringBuilder dangerPhoneString = new StringBuilder();
+                if(StringUtils.isNotEmpty(comSwDangerReportVO.getRectifyPerson())){
+                    String[] dangerIds = comSwDangerReportVO.getRectifyPerson().split(",");
+                    for (int i = 0; i < dangerIds.length ; i++) {
+                        Map<String,String> person = comSwPatrolRecordDAO.getPbServiceTeamById(dangerIds[i]);
+                        if(person != null){
+                            if(i != 0){
+                                dangerNameString.append(",");
+                                dangerPhoneString.append(",");
+                            }
+                            dangerNameString.append(person.get("name"));
+                            dangerPhoneString.append(person.get("phone"));
+                        }
+                    }
+                    comSwDangerReportVO.setDPersonName(dangerNameString.toString());
+                    comSwDangerReportVO.setDPersonPhone(dangerPhoneString.toString());
                 }
             });
         }
@@ -95,12 +132,111 @@
             BeanUtils.copyProperties(comSwPatrolRecordDO, comSwDangerReportVO);
         }
         BeanUtils.copyProperties(comSwDangerReportDO, comSwDangerReportVO);
+
+        //组装巡查类型
+        if(StringUtils.isNotEmpty(comSwDangerReportVO.getPatrolType())){
+            StringBuilder sb = new StringBuilder();
+            String patrolTypes[] = comSwDangerReportVO.getPatrolType().split(",");
+            for (int i = 0; i < patrolTypes.length; i++) {
+                if(i != 0){
+                    sb.append(",");
+                }
+                if(patrolTypes[i].equals("1")){
+                    sb.append("防火巡查");
+                }else if(patrolTypes[i].equals("2")){
+                    sb.append("防汛巡查");
+                }else if(patrolTypes[i].equals("3")){
+                    sb.append("防疫巡查");
+                }
+            }
+            comSwDangerReportVO.setPatrolType(sb.toString());
+        }
+
+        //查询整改人员信息
+        if(StringUtils.isNotEmpty(comSwDangerReportVO.getRectifyPerson())){
+            StringBuilder sb = new StringBuilder();
+            String personIds[] = comSwDangerReportVO.getRectifyPerson().split(",");
+            for (int i = 0; i < personIds.length; i++) {
+                if(i != 0){
+                    sb.append(",");
+                }
+                Map<String,String> personMap = comSwPatrolRecordDAO.getPbServiceTeamById(personIds[i]);
+                if(personMap != null){
+                    sb.append(personMap.get("name"));
+                }
+            }
+            comSwDangerReportVO.setPersonName(sb.toString());
+        }
+
+        //查询填报人名称
+        if(comSwDangerReportVO.getCreateBy() != null){
+            comSwDangerReportVO.setCreateName(comSwPatrolRecordDAO.getCreateName(comSwDangerReportVO.getCreateBy()));
+        }
+
+        //查询指派人名称
+        if(StringUtils.isNotEmpty(comSwDangerReportVO.getAssignPerson())){
+            StringBuilder sb = new StringBuilder();
+            String personIds[] = comSwDangerReportVO.getAssignPerson().split(",");
+            for (int i = 0; i < personIds.length; i++) {
+                if(i != 0){
+                    sb.append(",");
+                }
+                Map<String,String> personMap = comSwPatrolRecordDAO.getPbServiceTeamById(personIds[i]);
+                if(personMap != null){
+                    sb.append(personMap.get("name"));
+                }
+            }
+            comSwDangerReportVO.setAssignPersonName(sb.toString());
+        }
+
+        StringBuilder patrolNameString = new StringBuilder();
+        StringBuilder patrolPhoneString = new StringBuilder();
+        //巡查人员id查询巡查人员的名字和电话
+        if(StringUtils.isNotEmpty(comSwDangerReportVO.getPatrolPerson())){
+            String[] patrolIds = comSwDangerReportVO.getPatrolPerson().split(",");
+            for (int i = 0; i < patrolIds.length ; i++) {
+                Map<String,String> leader = comSwPatrolRecordDAO.getPbServiceTeamById(patrolIds[i]);
+                if(leader != null){
+                    if(i != 0){
+                        patrolNameString.append(",");
+                        patrolPhoneString.append(",");
+                    }
+                    patrolNameString.append(leader.get("name"));
+                    patrolPhoneString.append(leader.get("phone"));
+                }
+            }
+            comSwDangerReportVO.setPPersonName(patrolNameString.toString());
+            comSwDangerReportVO.setPPersonPhone(patrolPhoneString.toString());
+        }
+        //整改人员id查询整改人员的名字和电话
+        StringBuilder dangerNameString = new StringBuilder();
+        StringBuilder dangerPhoneString = new StringBuilder();
+        if(StringUtils.isNotEmpty(comSwDangerReportVO.getRectifyPerson())){
+            String[] dangerIds = comSwDangerReportVO.getRectifyPerson().split(",");
+            for (int i = 0; i < dangerIds.length ; i++) {
+                Map<String,String> person = comSwPatrolRecordDAO.getPbServiceTeamById(dangerIds[i]);
+                if(person != null){
+                    if(i != 0){
+                        dangerNameString.append(",");
+                        dangerPhoneString.append(",");
+                    }
+                    dangerNameString.append(person.get("name"));
+                    dangerPhoneString.append(person.get("phone"));
+                }
+            }
+            comSwDangerReportVO.setDPersonName(dangerNameString.toString());
+            comSwDangerReportVO.setDPersonPhone(dangerPhoneString.toString());
+        }
+
         return R.ok(comSwDangerReportVO);
     }
 
     @Override
     public R detailDangerReportByPrId(Long patrolRecordId) {
         ComSwPatrolRecordDO comSwPatrolRecordDO = comSwPatrolRecordDAO.selectById(patrolRecordId);
+        if(comSwPatrolRecordDO == null){
+            return R.fail("该隐患报告不存在");
+        }
         ComSwDangerReportVO comSwDangerReportVO = new ComSwDangerReportVO();
         ComSwPatrolRecordReportDO comSwPatrolRecordReportDO = comSwPatrolRecordReportDAO.selectOne(new QueryWrapper<ComSwPatrolRecordReportDO>().lambda().eq(ComSwPatrolRecordReportDO::getPatrolRecordId, patrolRecordId));
         if (null != comSwPatrolRecordReportDO) {
@@ -111,6 +247,44 @@
             BeanUtils.copyProperties(comSwDangerReportDO, comSwDangerReportVO);
         }
         BeanUtils.copyProperties(comSwPatrolRecordDO, comSwDangerReportVO);
+        StringBuilder patrolNameString = new StringBuilder();
+        StringBuilder patrolPhoneString = new StringBuilder();
+        //巡查人员id查询巡查人员的名字和电话
+        if(StringUtils.isNotEmpty(comSwDangerReportVO.getPatrolPerson())){
+            String[] patrolIds = comSwDangerReportVO.getPatrolPerson().split(",");
+            for (int i = 0; i < patrolIds.length ; i++) {
+                Map<String,String> leader = comSwPatrolRecordDAO.getPbServiceTeamById(patrolIds[i]);
+                if(leader != null){
+                    if(i != 0){
+                        patrolNameString.append(",");
+                        patrolPhoneString.append(",");
+                    }
+                    patrolNameString.append(leader.get("name"));
+                    patrolPhoneString.append(leader.get("phone"));
+                }
+            }
+            comSwDangerReportVO.setPPersonName(patrolNameString.toString());
+            comSwDangerReportVO.setPPersonPhone(patrolPhoneString.toString());
+        }
+        //整改人员id查询整改人员的名字和电话
+        StringBuilder dangerNameString = new StringBuilder();
+        StringBuilder dangerPhoneString = new StringBuilder();
+        if(StringUtils.isNotEmpty(comSwDangerReportVO.getRectifyPerson())){
+            String[] dangerIds = comSwDangerReportVO.getRectifyPerson().split(",");
+            for (int i = 0; i < dangerIds.length ; i++) {
+                Map<String,String> person = comSwPatrolRecordDAO.getPbServiceTeamById(dangerIds[i]);
+                if(person != null){
+                    if(i != 0){
+                        dangerNameString.append(",");
+                        dangerPhoneString.append(",");
+                    }
+                    dangerNameString.append(person.get("name"));
+                    dangerPhoneString.append(person.get("phone"));
+                }
+            }
+            comSwDangerReportVO.setDPersonName(dangerNameString.toString());
+            comSwDangerReportVO.setDPersonPhone(dangerPhoneString.toString());
+        }
         return R.ok(comSwDangerReportVO);
     }
 
@@ -137,6 +311,7 @@
         }
         BeanUtils.copyProperties(comSwDangerReportRectifyDTO, comSwDangerReportDO);
         comSwDangerReportDO.setStatus(String.valueOf(SafeWordStatusEnum.YZG.getCode()));
+        comSwDangerReportDO.setRectifyTime(DateUtils.getCurrentDateStr());
         int update = comSwDangerReportDAO.updateById(comSwDangerReportDO);
         if (update > 0) {
             return R.ok();
@@ -147,15 +322,15 @@
     @Override
     public R exportDangerReport(List<Long> dangerReportIds) {
         List<ComSwDangerReportExcelVO> list = comSwDangerReportDAO.exportDangerReport(dangerReportIds);
-        list.forEach(comSwDangerReportExcelVO -> {
-            List<String> patrolUserIds = Arrays.asList(comSwDangerReportExcelVO.getPatrolPerson().split(","));
-            List<String> patrolPhones = new ArrayList<>();
-            for (String userId : patrolUserIds) {
-                LoginUserInfoVO loginUserInfoVO = userService.getUserInfoByUserId(userId).getData();
-                patrolPhones.add(loginUserInfoVO.getPhone());
-            }
-            comSwDangerReportExcelVO.setPatrolPersonPhone(StringUtils.join(patrolPhones,","));
-        });
+//        list.forEach(comSwDangerReportExcelVO -> {
+//            List<String> patrolUserIds = Arrays.asList(comSwDangerReportExcelVO.getPatrolPerson().split(","));
+//            List<String> patrolPhones = new ArrayList<>();
+//            for (String userId : patrolUserIds) {
+//                LoginUserInfoVO loginUserInfoVO = userService.getUserInfoByUserId(userId).getData();
+//                patrolPhones.add(loginUserInfoVO.getPhone());
+//            }
+//            comSwDangerReportExcelVO.setPatrolPersonPhone(StringUtils.join(patrolPhones,","));
+//        });
         return R.ok(list);
     }
 }

--
Gitblit v1.7.1