Null
2021-03-19 fa5a0d6eca31dfe7dde16a403c192df4494273eb
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
112
113
114
115
116
package com.panzhihua.service_community.service.impl;
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.panzhihua.common.model.dtos.community.ExportRealAssetsExcelDTO;
import com.panzhihua.common.model.dtos.community.PageComMngRealAssetsDTO;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.community.ComMngRealAssetsExcelVO;
import com.panzhihua.common.model.vos.community.ComMngRealAssetsVO;
import com.panzhihua.service_community.dao.ComMngRealAssetsDAO;
import com.panzhihua.service_community.model.dos.ComMngRealAssetsDO;
import com.panzhihua.service_community.service.ComMngRealAssetsService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
 
/**
 * @description: 实有资产
 * @author: Null
 * @date: 2021/3/19 11:55
 */
@Service
public class ComMngRealAssetsServiceImpl extends ServiceImpl<ComMngRealAssetsDAO, ComMngRealAssetsDO>  implements ComMngRealAssetsService {
 
    @Resource
    private ComMngRealAssetsDAO comMngRealAssetsDAO;
 
    @Override
    public R pageQueryComMngRealAssets(PageComMngRealAssetsDTO pageComMngRealAssetsDTO) {
        Page page = new Page<>();
        Long pageNum = pageComMngRealAssetsDTO.getPageNum();
        Long pageSize = pageComMngRealAssetsDTO.getPageSize();
        if (null == pageNum || 0 == pageNum) {
            pageNum = 1l;
        }
        if (null == pageSize || 0 == pageSize) {
            pageSize = 10l;
        }
        page.setSize(pageSize);
        page.setCurrent(pageNum);
        IPage<ComMngRealAssetsVO> iPage = comMngRealAssetsDAO.pageQueryComMngRealAssets(page, pageComMngRealAssetsDTO);
        return R.ok(iPage);
    }
 
    @Override
    public R saveComMngRealAssets(ComMngRealAssetsVO comMngRealAssetsVO) {
        if(null!=comMngRealAssetsVO.getId() && comMngRealAssetsVO.getId()!=0){
            //修改
            ComMngRealAssetsDO comMngRealAssetsDO = comMngRealAssetsDAO.selectById(comMngRealAssetsVO.getId());
            BeanUtils.copyProperties(comMngRealAssetsVO,comMngRealAssetsDO);
            int update = comMngRealAssetsDAO.updateById(comMngRealAssetsDO);
            if(update>0){
                return R.ok();
            }
        }else{
            ComMngRealAssetsDO comMngRealAssetsDO = new ComMngRealAssetsDO();
            BeanUtils.copyProperties(comMngRealAssetsVO,comMngRealAssetsDO);
            int insert = comMngRealAssetsDAO.insert(comMngRealAssetsDO);
            if(insert>0){
                return R.ok();
            }
        }
 
        return R.fail("添加失败");
    }
 
    @Override
    public R deleteComMngRealAssets(Long id) {
        ComMngRealAssetsDO comMngRealAssetsDO = comMngRealAssetsDAO.selectById(id);
        if(null==comMngRealAssetsDO){
            return R.fail("该资产不存在");
        }
        int delete = comMngRealAssetsDAO.deleteById(id);
        if(delete>0){
            return R.ok();
        }
        return R.fail("删除失败");
    }
 
    @Override
    public R detailComMngRealAssets(Long id) {
        ComMngRealAssetsDO comMngRealAssetsDO = comMngRealAssetsDAO.selectById(id);
        if(null==comMngRealAssetsDO){
            return R.fail("该资产不存在");
        }
        ComMngRealAssetsVO comMngRealAssetsVO = new ComMngRealAssetsVO();
        BeanUtils.copyProperties(comMngRealAssetsDO,comMngRealAssetsVO);
        return R.ok(comMngRealAssetsVO);
    }
 
    @Override
    public R listSaveMngRealAssetsExcelVO(List<ComMngRealAssetsExcelVO> list, Long communityId) {
        List<ComMngRealAssetsDO> comMngRealAssetsDOS = new ArrayList<>();
        list.forEach(l->{
            ComMngRealAssetsDO comMngRealAssetsDO = new ComMngRealAssetsDO();
            BeanUtils.copyProperties(l,comMngRealAssetsDO);
            comMngRealAssetsDO.setCommunityId(communityId);
            comMngRealAssetsDOS.add(comMngRealAssetsDO);
        });
        boolean batch = this.saveBatch(comMngRealAssetsDOS);
        if(batch){
            return R.ok();
        }
        return R.fail("请检查数据是否重复,格合是否正确");
    }
 
    @Override
    public R exportRealAssetsExcel(ExportRealAssetsExcelDTO exportRealAssetsExcelDTO) {
        List<ComMngRealAssetsExcelVO> list = comMngRealAssetsDAO.exportRealAssetsExcel(exportRealAssetsExcelDTO);
        return R.ok(list);
    }
}