|
@@ -0,0 +1,68 @@
|
|
|
+package com.mooctest.crowd.site.service.impl;
|
|
|
+
|
|
|
+import com.mooctest.crowd.domain.dao.EvaluationAgencyDao;
|
|
|
+import com.mooctest.crowd.domain.dao.ResidentAgencyDao;
|
|
|
+import com.mooctest.crowd.domain.dao.TaskToUserDao;
|
|
|
+import com.mooctest.crowd.domain.dao.UserDao;
|
|
|
+import com.mooctest.crowd.domain.model.EvaluationAgencyPO;
|
|
|
+import com.mooctest.crowd.domain.model.RankCountInfo;
|
|
|
+import com.mooctest.crowd.domain.model.ResidentAgencyPO;
|
|
|
+import com.mooctest.crowd.domain.model.UserPO;
|
|
|
+import com.mooctest.crowd.site.data.vo.ResidentAgencyVO;
|
|
|
+import com.mooctest.crowd.site.service.ResidentAgencyService;
|
|
|
+import com.mooctest.crowd.site.util.DataUtils;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.domain.Page;
|
|
|
+import org.springframework.data.domain.Pageable;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Optional;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author:xx
|
|
|
+ * @date:2020/7/8
|
|
|
+ * @description:
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+public class ResidentServiceImpl implements ResidentAgencyService {
|
|
|
+ @Autowired
|
|
|
+ private TaskToUserDao taskToUserDao;
|
|
|
+ @Autowired
|
|
|
+ private ResidentAgencyDao residentAgencyDao;
|
|
|
+ @Autowired
|
|
|
+ private EvaluationAgencyDao agencyDao;
|
|
|
+ @Autowired
|
|
|
+ private UserDao userDao;
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<ResidentAgencyVO> findAll(Pageable pageable) {
|
|
|
+ List<ResidentAgencyVO> list = new ArrayList<>();
|
|
|
+ List<RankCountInfo> totalCountOfUser = taskToUserDao.findTotalCountOfUser();
|
|
|
+ long ids[] = new long[totalCountOfUser.size()];
|
|
|
+ List<ResidentAgencyPO> residentAgencyPOS = residentAgencyDao.findAll();
|
|
|
+ //获取品牌机构的用户id
|
|
|
+ long resagency[] = new long[residentAgencyPOS.size()];
|
|
|
+ for (int i = 0; i < residentAgencyPOS.size(); i++) {
|
|
|
+ ResidentAgencyVO residentAgencyVO = new ResidentAgencyVO();
|
|
|
+ Optional<UserPO> userPO = userDao.findById(residentAgencyPOS.get(i).getUserId());
|
|
|
+ resagency[i] = residentAgencyPOS.get(i).getUserId();
|
|
|
+ EvaluationAgencyPO evaluationAgencyPO = agencyDao.findByUserId(resagency[i]);
|
|
|
+ residentAgencyVO.setName(evaluationAgencyPO.getEvaluationAgencyName());
|
|
|
+ residentAgencyVO.setTaskCount(totalCountOfUser.get(i).getCount());
|
|
|
+ residentAgencyVO.setAddress(evaluationAgencyPO.getAddress());
|
|
|
+ residentAgencyVO.setAgencyId(residentAgencyPOS.get(i).getAgencyId());
|
|
|
+ residentAgencyVO.setId(residentAgencyPOS.get(i).getId());
|
|
|
+ residentAgencyVO.setUserId(residentAgencyPOS.get(i).getUserId());
|
|
|
+ list.add(residentAgencyVO);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ Page<ResidentAgencyVO> page = DataUtils.listToPage(list, pageable);
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+}
|