jialh
1 天以前 dd6687b118561100e1677e88a9c2f5842a54c531
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
package com.java110.community.smo.impl;
 
import com.alibaba.fastjson.JSONObject;
import com.java110.community.dao.ICommunityServiceDao;
import com.java110.core.base.smo.BaseServiceSMO;
import com.java110.dto.community.CommunityMemberDto;
import com.java110.dto.PageDto;
import com.java110.dto.community.CommunityAttrDto;
import com.java110.dto.community.CommunityDto;
import com.java110.intf.community.ICommunityInnerServiceSMO;
import com.java110.po.community.CommunityAttrPo;
import com.java110.utils.exception.DAOException;
import com.java110.utils.util.BeanConvertUtil;
import com.java110.utils.util.ListUtil;
import org.slf4j.Logger;
import com.java110.core.log.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
/**
 * 小区服务内部类
 */
@RestController
public class CommunityInnerServiceSMOImpl extends BaseServiceSMO implements ICommunityInnerServiceSMO {
    private static Logger logger = LoggerFactory.getLogger(CommunityServiceSMOImpl.class);
 
 
    @Autowired
    private ICommunityServiceDao communityServiceDaoImpl;
 
 
    @Override
    public List<CommunityMemberDto> getCommunityMembers(@RequestBody CommunityMemberDto communityMemberDto) {
 
        logger.debug("communityMemberDto:{}", JSONObject.toJSONString(communityMemberDto));
 
        //校验是否传了 分页信息
 
        int page = communityMemberDto.getPage();
 
        if (page != PageDto.DEFAULT_PAGE) {
            communityMemberDto.setPage((page - 1) * communityMemberDto.getRow());
        }
 
        List<Map> communityMembers = communityServiceDaoImpl.getCommunityMembers(BeanConvertUtil.beanCovertMap(communityMemberDto));
        return BeanConvertUtil.covertBeanList(communityMembers, CommunityMemberDto.class);
    }
    @Override
    public List<CommunityDto> getCommunitys(){
        return communityServiceDaoImpl.getCommunitys();
    }
 
 
    @Override
    public List<CommunityDto> getStoreCommunitys(CommunityMemberDto communityMemberDto) {
        List<Map> communityMembers = communityServiceDaoImpl.getStoreCommunitys(BeanConvertUtil.beanCovertMap(communityMemberDto));
        List<CommunityDto> communitys = BeanConvertUtil.covertBeanList(communityMembers, CommunityDto.class);
 
        List<String> communityIds = new ArrayList<>();
 
        if (communitys == null || communitys.size() < 1) {
            return communitys;
        }
        for (CommunityDto tmpCommunityDto : communitys) {
            communityIds.add(tmpCommunityDto.getCommunityId());
        }
        Map info = new HashMap();
        info.put("communityIds", communityIds.toArray(new String[communityIds.size()]));
        List<CommunityAttrDto> communityAttrDtos = BeanConvertUtil.covertBeanList(communityServiceDaoImpl.getCommunityAttrs(info), CommunityAttrDto.class);
 
        if (communityAttrDtos == null || communityAttrDtos.size() < 1) {
            return communitys;
        }
        for (CommunityDto tmpCommunityDto : communitys) {
            List<CommunityAttrDto> tmpCommunityAttrDtos = new ArrayList<>();
            for (CommunityAttrDto communityAttrDto : communityAttrDtos) {
                if (tmpCommunityDto.getCommunityId().equals(communityAttrDto.getCommunityId())) {
                    tmpCommunityAttrDtos.add(communityAttrDto);
                }
            }
            tmpCommunityDto.setCommunityAttrDtos(tmpCommunityAttrDtos);
        }
        return communitys;
    }
 
    @Override
    public int getCommunityMemberCount(@RequestBody CommunityMemberDto communityMemberDto) {
        logger.debug("getCommunityMemberCount:{}", JSONObject.toJSONString(communityMemberDto));
 
        return communityServiceDaoImpl.getCommunityMemberCount(BeanConvertUtil.beanCovertMap(communityMemberDto));
    }
 
    @Override
    public List<CommunityAttrDto> getCommunityAttrs(@RequestBody CommunityAttrDto communityAttrDto) {
        return BeanConvertUtil.covertBeanList(communityServiceDaoImpl.getCommunityAttrs(BeanConvertUtil.beanCovertMap(communityAttrDto)), CommunityAttrDto.class);
    }
 
    @Override
    public int getCommunityAttrsCount(@RequestBody CommunityAttrDto communityAttrDto) {
        logger.debug("queryCommunityAttrsCount:{}", JSONObject.toJSONString(communityAttrDto));
 
        return communityServiceDaoImpl.getCommunityAttrsCount(BeanConvertUtil.beanCovertMap(communityAttrDto));
    }
 
    /**
     * 保存小区属性
     *
     * @param communityAttrPo 数据对象分享
     * @return
     */
    @Override
    public int saveCommunityAttr(CommunityAttrPo communityAttrPo) {
        return communityServiceDaoImpl.saveCommunityAttr(BeanConvertUtil.beanCovertMap(communityAttrPo));
    }
 
    @Override
    public List<CommunityDto> queryCommunitys(@RequestBody CommunityDto communityDto) {
 
        //校验是否传了 分页信息
 
        int page = communityDto.getPage();
 
        if (page != PageDto.DEFAULT_PAGE) {
            communityDto.setPage((page - 1) * communityDto.getRow());
        }
 
        List<CommunityDto> communitys = BeanConvertUtil.covertBeanList(communityServiceDaoImpl.getCommunityInfoNew(BeanConvertUtil.beanCovertMap(communityDto)), CommunityDto.class);
 
        List<String> communityIds = new ArrayList<>();
 
        if (ListUtil.isNull(communitys)) {
            return communitys;
        }
        for (CommunityDto tmpCommunityDto : communitys) {
            communityIds.add(tmpCommunityDto.getCommunityId());
        }
        Map info = new HashMap();
        info.put("communityIds", communityIds.toArray(new String[communityIds.size()]));
        List<CommunityAttrDto> communityAttrDtos = BeanConvertUtil.covertBeanList(communityServiceDaoImpl.getCommunityAttrs(info), CommunityAttrDto.class);
 
        if (ListUtil.isNull(communityAttrDtos)) {
            return communitys;
        }
 
        for (CommunityDto tmpCommunityDto : communitys) {
            List<CommunityAttrDto> tmpCommunityAttrDtos = new ArrayList<>();
            for (CommunityAttrDto communityAttrDto : communityAttrDtos) {
                if (tmpCommunityDto.getCommunityId().equals(communityAttrDto.getCommunityId())) {
                    tmpCommunityAttrDtos.add(communityAttrDto);
                }
            }
            tmpCommunityDto.setCommunityAttrDtos(tmpCommunityAttrDtos);
        }
 
        return communitys;
    }
 
 
    @Override
    public int queryCommunitysCount(@RequestBody CommunityDto communityDto) {
        return communityServiceDaoImpl.queryCommunitysCount(BeanConvertUtil.beanCovertMap(communityDto));
    }
 
//    @Override
//    public int saveCommunity(@RequestBody CommunityPo communityPo) {
//        return communityServiceDaoImpl.saveCommunity(BeanConvertUtil.beanCovertMap(communityPo));
//    }
 
 
    public ICommunityServiceDao getCommunityServiceDaoImpl() {
        return communityServiceDaoImpl;
    }
 
    public void setCommunityServiceDaoImpl(ICommunityServiceDao communityServiceDaoImpl) {
        this.communityServiceDaoImpl = communityServiceDaoImpl;
    }
}