From e6c0c5a119c814b1ae777f14897e9e15daab8c50 Mon Sep 17 00:00:00 2001
From: songhuangfeng123 <shf18767906695@163.com>
Date: 星期四, 04 八月 2022 14:15:02 +0800
Subject: [PATCH] 事故报告状态fix

---
 incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/impl/AccidentExpressServiceImpl.java |   80 ++++++++++++++++++++++++++++++++++-----
 1 files changed, 69 insertions(+), 11 deletions(-)

diff --git a/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/impl/AccidentExpressServiceImpl.java b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/impl/AccidentExpressServiceImpl.java
index 90851c2..757bcec 100644
--- a/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/impl/AccidentExpressServiceImpl.java
+++ b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/impl/AccidentExpressServiceImpl.java
@@ -1,6 +1,10 @@
 package com.gkhy.safePlatform.incidentManage.service.impl;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.gkhy.safePlatform.account.rpc.apimodel.AccountAuthService;
+import com.gkhy.safePlatform.account.rpc.apimodel.AccountDepartmentService;
+import com.gkhy.safePlatform.account.rpc.apimodel.model.resp.DepInfoRPCRespDTO;
+import com.gkhy.safePlatform.commons.co.ContextCacheUser;
 import com.gkhy.safePlatform.commons.enums.ResultCodes;
 import com.gkhy.safePlatform.commons.query.PageQuery;
 import com.gkhy.safePlatform.commons.utils.BeanCopyUtils;
@@ -10,24 +14,26 @@
 import com.gkhy.safePlatform.incidentManage.entity.*;
 import com.gkhy.safePlatform.incidentManage.enums.AccidentResultCodes;
 import com.gkhy.safePlatform.incidentManage.exception.AccidentException;
+import com.gkhy.safePlatform.incidentManage.model.dto.req.AccidentExpressCasualtyReqDTO;
 import com.gkhy.safePlatform.incidentManage.model.dto.req.AccidentExpressFileReqDTO;
 import com.gkhy.safePlatform.incidentManage.model.dto.req.AccidentExpressReqDTO;
+import com.gkhy.safePlatform.incidentManage.model.dto.resp.AccidentExpressCasualtyRespDTO;
 import com.gkhy.safePlatform.incidentManage.model.dto.resp.AccidentExpressDetailRespDTO;
 import com.gkhy.safePlatform.incidentManage.model.dto.resp.AccidentExpressFileRespDTO;
 import com.gkhy.safePlatform.incidentManage.model.dto.resp.AccidentExpressPageRespDTO;
 import com.gkhy.safePlatform.incidentManage.query.AccidentExpressQuery;
 import com.gkhy.safePlatform.incidentManage.query.db.AccidentExpressDBQuery;
 import com.gkhy.safePlatform.incidentManage.service.AccidentExpressService;
+import com.gkhy.safePlatform.incidentManage.service.baseService.AccidentExpressCasualtyInfoService;
 import com.gkhy.safePlatform.incidentManage.service.baseService.AccidentExpressFileInfoService;
 import com.gkhy.safePlatform.incidentManage.service.baseService.AccidentExpressInfoService;
+import org.apache.dubbo.config.annotation.DubboReference;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 import java.util.stream.Collectors;
 
 @Service("accidentExpressService")
@@ -38,6 +44,12 @@
 
     @Autowired
     private AccidentExpressFileInfoService accidentExpressFileInfoService;
+
+    @Autowired
+    private AccidentExpressCasualtyInfoService accidentExpressCasualtyInfoService;
+
+    @DubboReference(check = false)
+    private AccountDepartmentService accountDepartmentService;
 
 
     @Override
@@ -51,14 +63,31 @@
             BeanUtils.copyProperties(query.getSearchParams(), accidentExpressDBQuery);
         }
 
-
         List<AccidentExpressInfoPageDO> accidentExpressInfoPageDOList = accidentExpressInfoService.selectAccidentExpressList(page, accidentExpressDBQuery);
         List<AccidentExpressPageRespDTO> respList = BeanCopyUtils.copyBeanList(accidentExpressInfoPageDOList, AccidentExpressPageRespDTO.class);
+
+        Map<Long, String> depPool = new HashMap<>();
+
+        respList.forEach(AccidentExpressPageRespDTO ->{
+            // 设置部门名称
+            if (!depPool.containsKey(AccidentExpressPageRespDTO.getAccidentDepartmentId())) {
+                ResultVO<DepInfoRPCRespDTO> rpcResult = accountDepartmentService.getDepInfoByDepId(AccidentExpressPageRespDTO.getAccidentDepartmentId());
+                if (rpcResult != null && rpcResult.getCode().equals(ResultCodes.OK.getCode())) {
+                    if (rpcResult.getData() != null) {
+                        DepInfoRPCRespDTO dep = (DepInfoRPCRespDTO) rpcResult.getData();
+
+                        depPool.put(dep.getDepId(), dep.getDepName());
+                    }
+                }}
+
+            String depName = depPool.get(AccidentExpressPageRespDTO.getAccidentDepartmentId());
+            AccidentExpressPageRespDTO.setDeptName(depName);
+        });
 
         return new SearchResultVO<>(
                 true,
                 pageIndex,
-                pageSize,
+                pageSize,page.getPages(),
                 page.getTotal(),
                 respList,
                 ResultCodes.OK
@@ -66,7 +95,9 @@
     }
 
     @Override
-    public ResultVO addAccidentExpress(Long uid, AccidentExpressReqDTO accidentExpressReqDTO) {
+    public ResultVO addAccidentExpress(ContextCacheUser contextCacheUser, AccidentExpressReqDTO accidentExpressReqDTO) {
+        Long uid = contextCacheUser.getUid();
+        String uName = contextCacheUser.getRealName();
         //必填项验证
         checkRequired(accidentExpressReqDTO);
 
@@ -76,6 +107,7 @@
         BeanUtils.copyProperties(accidentExpressReqDTO, accidentExpressInfo);
         accidentExpressInfo.setDelFlag(false);
         accidentExpressInfo.setCreateUid(uid);
+        accidentExpressInfo.setCreateName(uName);
         accidentExpressInfo.setGmtCreate(nowDate);
         accidentExpressInfoService.addAccidentExpress(accidentExpressInfo);
         //2.新增应急队伍附件
@@ -179,13 +211,12 @@
 
 
     @Override
-    public ResultVO batchDeleteAccidentExpress(String ids) {
-        if (StringUtils.isBlank(ids)){
+    public ResultVO batchDeleteAccidentExpress(Long[] ids) {
+        if (ids == null ||  ids.length==0){
             throw new AccidentException(AccidentResultCodes.ACCIDENT_EXPRESS_NULL);
         }else{
-            String[] idArr = ids.split(",");
-            for (String id : idArr) {
-                deleteAccidentExpress(Long.valueOf(id));
+            for (Long id : ids){
+                deleteAccidentExpress(id);
             }
             return new ResultVO(ResultCodes.OK);
         }
@@ -203,6 +234,33 @@
         }
     }
 
+    @Override
+    public ResultVO selectAccidentExpressCasualtyList(Long accidentExpressId) {
+        List<AccidentExpressCasualtyInfoDO> accidentExpressCasualtyInfoDOList = accidentExpressCasualtyInfoService.selectByAccidentExpressId(accidentExpressId);
+        List<AccidentExpressCasualtyRespDTO> respList =BeanCopyUtils.copyBeanList(accidentExpressCasualtyInfoDOList, AccidentExpressCasualtyRespDTO.class);
+        return new ResultVO<>(ResultCodes.OK,respList);
+    }
+
+    @Override
+    public ResultVO addAccidentExpressCasualty(Long uid, AccidentExpressCasualtyReqDTO accidentExpressCasualtyReqDTO) {
+        if (accidentExpressCasualtyReqDTO.getAccidentExpressId()==null){
+            throw new AccidentException(AccidentResultCodes.ACCIDENT_EXPRESS_NULL);
+        }else{
+            AccidentExpressCasualtyInfo accidentExpressCasualtyInfo = new AccidentExpressCasualtyInfo();
+            BeanUtils.copyProperties(accidentExpressCasualtyReqDTO,accidentExpressCasualtyInfo);
+            accidentExpressCasualtyInfo.setDelFlag(false);
+            accidentExpressCasualtyInfo.setGmtCreate(new Date());
+            accidentExpressCasualtyInfo.setCreateUid(uid);
+            accidentExpressCasualtyInfoService.addAccidentExpressCasualty(accidentExpressCasualtyInfo);
+            return new ResultVO(ResultCodes.OK);
+        }
+    }
+
+    @Override
+    public ResultVO delAccidentExpressCasualty(Long accidentExpressId) {
+        accidentExpressCasualtyInfoService.deleteAccidentExpressCasualtyById(accidentExpressId);
+        return new ResultVO(ResultCodes.OK);
+    }
 
 
 

--
Gitblit v1.9.2