songhuangfeng123
2022-07-04 fae1245f6b137cc8375aa71f089a66070e7f9e91
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package com.gkhy.safePlatform.emergency.service.impl;
 
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gkhy.safePlatform.commons.enums.ResultCodes;
import com.gkhy.safePlatform.commons.query.PageQuery;
import com.gkhy.safePlatform.commons.utils.BeanCopyUtils;
import com.gkhy.safePlatform.commons.vo.ResultVO;
import com.gkhy.safePlatform.commons.vo.SearchResultVO;
import com.gkhy.safePlatform.emergency.entity.EmergencyTeamFileInfo;
import com.gkhy.safePlatform.emergency.entity.EmergencyTeamFileInfoDO;
import com.gkhy.safePlatform.emergency.entity.EmergencyTeamInfoPageDO;
import com.gkhy.safePlatform.emergency.model.dto.req.EmergencyTeamReqDTO;
import com.gkhy.safePlatform.emergency.model.dto.resp.EmergencyTeamFileRespDTO;
import com.gkhy.safePlatform.emergency.model.dto.resp.EmergencyTeamPageRespDTO;
import com.gkhy.safePlatform.emergency.query.EmergencyTeamQuery;
import com.gkhy.safePlatform.emergency.query.db.EmergencyTeamDBQuery;
import com.gkhy.safePlatform.emergency.service.EmergencyTeamService;
import com.gkhy.safePlatform.emergency.service.baseService.EmergencyTeamFileInfoService;
import com.gkhy.safePlatform.emergency.service.baseService.EmergencyTeamInfoService;
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.List;
 
@Service("emergencyTeamService")
public class EmergencyTeamServiceImpl implements EmergencyTeamService {
 
    @Autowired
    private EmergencyTeamInfoService emergencyTeamInfoService;
 
    @Autowired
    private EmergencyTeamFileInfoService emergencyTeamFileInfoService;
 
    @Override
    public SearchResultVO<List<EmergencyTeamPageRespDTO>> selectEmergencyTeamList(PageQuery<EmergencyTeamQuery> query) {
        Long pageIndex = query.getPageIndex();
        Long pageSize = query.getPageSize();
        Page<EmergencyTeamInfoPageDO> page = new Page<>(pageIndex, pageSize);
 
        EmergencyTeamDBQuery emergencyTeamDBQuery = new EmergencyTeamDBQuery();
        if (query.getSearchParams() != null) {
            BeanUtils.copyProperties(query.getSearchParams(), emergencyTeamDBQuery);
        }
 
        List<EmergencyTeamPageRespDTO> respList = new ArrayList<>();
        List<EmergencyTeamInfoPageDO> emergencyTeamInfoPageDOList = emergencyTeamInfoService.selectEmergencyTeamList(page,emergencyTeamDBQuery);
 
        if (!CollectionUtils.isEmpty(emergencyTeamInfoPageDOList)){
            for (int i = 0 ; i < emergencyTeamInfoPageDOList.size() ; i++){
                List<EmergencyTeamFileInfoDO> emergencyTeamFileInfoDOList = emergencyTeamFileInfoService.selectByEmergencyTeamId(emergencyTeamInfoPageDOList.get(i).getId());
                List<EmergencyTeamFileRespDTO> emergencyTeamFileRespDTOList =  BeanCopyUtils.copyBeanList(emergencyTeamFileInfoDOList, EmergencyTeamFileRespDTO.class);
 
                EmergencyTeamPageRespDTO emergencyTeamPageRespDTO = new EmergencyTeamPageRespDTO();
                BeanUtils.copyProperties(emergencyTeamInfoPageDOList.get(i),emergencyTeamPageRespDTO);
                emergencyTeamPageRespDTO.setFileList(emergencyTeamFileRespDTOList);
                respList.add(emergencyTeamPageRespDTO);
            }
        }
 
        return new SearchResultVO<>(
                true,
                pageIndex,
                pageSize,
                page.getTotal(),
                respList,
                ResultCodes.OK
                );
    }
 
    @Override
    public ResultVO<String> add(Long valueOf, EmergencyTeamReqDTO emergencyTeamReqDTO) {
        //新增应急预案
        //新增应急预案使用部门表
        //
        return null;
    }
}