package cn.com.goldenwater.dcproj.service.impl.ducha; import cn.com.goldenwater.core.service.AbstractCrudService; import cn.com.goldenwater.dcproj.dao.BisInspAllDao; import cn.com.goldenwater.dcproj.dao.BisInspAllRlationDao; import cn.com.goldenwater.dcproj.dto.BisInspAllDto; import cn.com.goldenwater.dcproj.model.*; import cn.com.goldenwater.dcproj.param.BisInspAllObjParam; import cn.com.goldenwater.dcproj.param.BisInspAllParam; import cn.com.goldenwater.dcproj.param.BisInspAllRlationParam; import cn.com.goldenwater.dcproj.param.BisInspSelAreaParam; import cn.com.goldenwater.dcproj.service.*; import cn.com.goldenwater.dcproj.util.StatisticalUtil; import cn.com.goldenwater.dcproj.utils.AdLevelUtil; import cn.com.goldenwater.dcproj.utils.Builder; import cn.com.goldenwater.dcproj.utils.RedisOperator; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.stream.Collectors; /** * @author lune * @date 2019-2-23 */ @Service @Transactional public class BisInspAllServiceImpl extends AbstractCrudService implements BisInspAllService { @Autowired private BisInspAllDao bisInspAllDao; @Autowired private BisInspAllRlationDao bisInspAllRlationDao; @Autowired private BisInspAllObjService bisInspAllObjService; @Autowired private BisInspSelAreaService bisInspSelAreaService; @Autowired private AttAdBaseService attAdBaseService; @Autowired private RedisOperator redisOperator; public BisInspAllServiceImpl(BisInspAllDao bisInspAllDao) { super(bisInspAllDao); this.bisInspAllDao = bisInspAllDao; } @Autowired private OlBisInspOrgService inspOrgService; @Override public PageInfo listByMap(Map paramMap) { String adCode = MapUtils.getString(paramMap, "adCode"); if (StringUtils.isNotBlank(adCode)) { paramMap.put("adCode", AdLevelUtil.getAddvcd(adCode)); } PageHelper.startPage(MapUtils.getIntValue(paramMap, "pageNum"), MapUtils.getIntValue(paramMap, "pageSize")); StatisticalUtil.setDate(paramMap); List allList = bisInspAllDao.listByMap(paramMap); allList.forEach(all -> { List> perMapList = bisInspAllRlationDao.getPersNameById(Builder.of(BisInspAllRlationParam::new) .with(BisInspAllRlationParam::setId, all.getId()) .build()); // 1:组长;2:组员;3:联络员;4:专家 all.setGroupLeader(perMapList.stream() .filter(per -> "1".equals(per.get("PERTYPE"))) .map(per -> per.get("PERS_NAME")) .collect(Collectors.joining("、"))); all.setGroupMember(perMapList.stream() .filter(per -> "2".equals(per.get("PERTYPE"))) .map(per -> per.get("PERS_NAME")) .collect(Collectors.joining("、"))); all.setLiaisonOfficer(perMapList.stream() .filter(per -> "3".equals(per.get("PERTYPE"))) .map(per -> per.get("PERS_NAME")) .collect(Collectors.joining("、"))); all.setSpecialist(perMapList.stream() .filter(per -> "4".equals(per.get("PERTYPE"))) .map(per -> per.get("PERS_NAME")) .collect(Collectors.joining("、"))); // 获取区域 List bisInspSelAreaList = bisInspSelAreaService.findList(Builder.of(BisInspSelAreaParam::new) .with(BisInspSelAreaParam::setId, all.getId()) .build()); if (bisInspSelAreaList != null && bisInspSelAreaList.size() > 0) { all.setObjNm(bisInspSelAreaList.stream() .map(BisInspSelArea::getAdName) .collect(Collectors.joining("、"))); } else { List bisInspAllObjList = bisInspAllObjService.findList(Builder.of(BisInspAllObjParam::new) .with(BisInspAllObjParam::setId, all.getId()) .build()); String area = bisInspAllObjList.stream() .map(BisInspAllObj::getObjAdCode) .distinct() .filter(StringUtils::isNotBlank) .map(o -> { AttAdBase attAdBase = attAdBaseService.get(o); if (attAdBase != null) { return attAdBase.getAdName(); } else { return null; } }) .filter(StringUtils::isNotBlank) .collect(Collectors.joining("、")); all.setObjNm(area); } //添加组长联系方式 List> perPhoneMapList = bisInspAllRlationDao.getPersPhoneById(Builder.of(BisInspAllRlationParam::new) .with(BisInspAllRlationParam::setId, all.getId()) .build()); all.setGroupLeaderPhone(perPhoneMapList.stream() .filter(per -> "1".equals(per.get("PERTYPE"))) .map(phone -> phone.get("MOBILENUMB")) .collect(Collectors.joining("、"))); // 116.600941 + 0-2.834473 // 25.295836 + 0-2.048097 all.setCenterXGd(116.600941 + Math.random() * 2); all.setCenterYGd(25.295836 + Math.random() * 2); }); return new PageInfo<>(allList); } @Override public List> getUserByOrg(String orgType, String orgId) { return bisInspAllDao.getUserByOrg(orgType, inspOrgService.getProvince(orgId)); } @Override public List> getNodeByPidAndCode(String pid, String code, String type, String orgId) { List> list = new ArrayList<>(); if (StringUtils.isNotBlank(pid)) { list = bisInspAllDao.getNodeByPidAndCode(pid, code, type, inspOrgService.getProvince(orgId)); } return list; } @Override public String selectMax(BisInspAllParam inspAllParam) { return bisInspAllDao.selectMax(inspAllParam); } @Override public BisInspAll getOne(BisInspAllParam inspAllParam) { return bisInspAllDao.getOne(inspAllParam); } @Override public int selectCount(BisInspAllParam inspAllParam) { return bisInspAllDao.selectCount(inspAllParam); } @Override public List listInspType() { return bisInspAllDao.listInspType(); } @Override public List findExistList(BisInspAllParam inspAllRParam) { return bisInspAllDao.findExistList(inspAllRParam); } @Override public List listByName(String pTypes) { // 获取二级小组 List secondList = bisInspAllDao.listByName(pTypes, "9"); if (secondList != null && secondList.size() > 0) { for (BisInspAll bisInspAll : secondList) { // 获取三级小组 List thirdList = bisInspAllDao.listByName(bisInspAll.getCode(), "12"); bisInspAll.setChildrens(thirdList); } } return secondList; } @Override public String[] getYearById(String id) { return bisInspAllDao.getYearById(id); } @Override public List getPersDcWork(String persId) { return bisInspAllDao.getPersDcWork(persId); } /** * 首页 四川 批次数汇总 * @param paramMap * @return */ @Override public List> getInspBatchNum(Map paramMap) { StatisticalUtil.setDate(paramMap); List> batchNumList = bisInspAllDao.getInspBatchNum(paramMap); return batchNumList; } }