songhuangfeng123
2022-08-02 aace11a7e1201a8d1fc0b50b659368918d23e794
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package com.gkhy.safePlatform.incidentManage.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.utils.StringUtils;
import com.gkhy.safePlatform.commons.vo.ResultVO;
import com.gkhy.safePlatform.commons.vo.SearchResultVO;
import com.gkhy.safePlatform.incidentManage.entity.AccidentWorkApproveInfo;
import com.gkhy.safePlatform.incidentManage.entity.AccidentWorkApproveInfoDetailDO;
import com.gkhy.safePlatform.incidentManage.entity.AccidentWorkApproveInfoPageDO;
import com.gkhy.safePlatform.incidentManage.enums.ApproveStatus;
import com.gkhy.safePlatform.incidentManage.model.dto.req.AccidentWorkApproveReqDTO;
import com.gkhy.safePlatform.incidentManage.model.dto.resp.AccidentWorkApproveDetailRespDTO;
import com.gkhy.safePlatform.incidentManage.model.dto.resp.AccidentWorkApprovePageRespDTO;
import com.gkhy.safePlatform.incidentManage.query.AccidentWorkApproveQuery;
import com.gkhy.safePlatform.incidentManage.query.db.AccidentWorkApproveDBQuery;
import com.gkhy.safePlatform.incidentManage.service.AccidentWorkApproveService;
import com.gkhy.safePlatform.incidentManage.service.baseService.AccidentWorkApproveInfoService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.Date;
import java.util.List;
 
@Service("AccidentWorkApproveService")
public class AccidentWorkApproveServiceImpl implements AccidentWorkApproveService {
 
    @Autowired
    private AccidentWorkApproveInfoService workApproveInfoService;
 
    @Override
    public SearchResultVO<List<AccidentWorkApprovePageRespDTO>> selectWorkApproveList(PageQuery<AccidentWorkApproveQuery> query) {
        Long pageIndex = query.getPageIndex();
        Long pageSize = query.getPageSize();
        Page<AccidentWorkApproveInfoPageDO> page = new Page<>(pageIndex, pageSize);
 
        AccidentWorkApproveDBQuery AccidentWorkApproveDBQuery = new AccidentWorkApproveDBQuery();
        if (query.getSearchParams() != null) {
            BeanUtils.copyProperties(query.getSearchParams(), AccidentWorkApproveDBQuery);
        }
 
        List<AccidentWorkApproveInfoPageDO> AccidentWorkApproveInfoPageDOList = workApproveInfoService.selectWorkApproveList(page, AccidentWorkApproveDBQuery);
        List<AccidentWorkApprovePageRespDTO> respList = BeanCopyUtils.copyBeanList(AccidentWorkApproveInfoPageDOList, AccidentWorkApprovePageRespDTO.class);
 
        return new SearchResultVO<>(
                true,
                pageIndex,
                pageSize,page.getPages(),
                page.getTotal(),
                respList,
                ResultCodes.OK
        );
    }
 
    @Override
    public ResultVO addWorkApprove(Long uid, AccidentWorkApproveReqDTO AccidentWorkApproveReqDTO) {
 
        Date nowDate = new Date();
        //1.新增应急队伍
        AccidentWorkApproveInfo AccidentWorkApproveInfo = new AccidentWorkApproveInfo();
        BeanUtils.copyProperties(AccidentWorkApproveReqDTO, AccidentWorkApproveInfo);
        AccidentWorkApproveInfo.setDelFlag(false);
        AccidentWorkApproveInfo.setCreateUid(uid);
        AccidentWorkApproveInfo.setGmtCreate(nowDate);
        AccidentWorkApproveInfo.setApproveStatus(ApproveStatus.NOT_APPROVE.getStatus());
        workApproveInfoService.addWorkApprove(AccidentWorkApproveInfo);
        return new ResultVO(ResultCodes.OK);
    }
 
    @Override
    public ResultVO<AccidentWorkApproveDetailRespDTO> getWorkApproveById(Long id) {
 
        AccidentWorkApproveInfoDetailDO AccidentWorkApproveInfoDetailDO = workApproveInfoService.selectWorkApproveById(id);
        AccidentWorkApproveDetailRespDTO AccidentWorkApproveDetailRespDTO = new AccidentWorkApproveDetailRespDTO();
        BeanUtils.copyProperties(AccidentWorkApproveInfoDetailDO, AccidentWorkApproveDetailRespDTO);
 
        return new ResultVO<>(ResultCodes.OK, AccidentWorkApproveDetailRespDTO);
    }
 
    @Override
    public ResultVO updateWorkApprove(Long uid, AccidentWorkApproveReqDTO AccidentWorkApproveReqDTO) {
        Date nowDate = new Date();
        AccidentWorkApproveInfo AccidentWorkApproveInfo = new AccidentWorkApproveInfo();
        BeanUtils.copyProperties(AccidentWorkApproveReqDTO, AccidentWorkApproveInfo);
        AccidentWorkApproveInfo.setUpdateUid(uid);
        AccidentWorkApproveInfo.setGmtModitify(nowDate);
        workApproveInfoService.updateWorkApprove(AccidentWorkApproveInfo);
        return new ResultVO(ResultCodes.OK);
    }
 
    @Override
    public ResultVO batchDeleteWorkApprove(String ids) {
        if (!StringUtils.isBlank(ids)) {
            String[] idArr = ids.split(",");
            for (String id : idArr) {
                deleteWorkApprove(Long.valueOf(id));
            }
        }
        return new ResultVO(ResultCodes.OK);
    }
 
 
    private void deleteWorkApprove(Long id) {
        workApproveInfoService.deleteWorkApproveById(id);
    }
 
 
}