lidongdong
2024-07-11 4ad4b51a4fb177eafee8a3a355496e7b6c1be662
springcloud_k8s_panzhihuazhihuishequ/service_partybuilding/src/main/java/com/panzhihua/service_dangjian/service/impl/ComPbCheckUnitServiceImpl.java
@@ -1,36 +1,42 @@
package com.panzhihua.service_dangjian.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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.google.common.collect.Lists;
import com.panzhihua.common.enums.ComPbCheckUnitTypeEnum;
import com.panzhihua.common.model.dtos.common.AddComPbCheckUnitDto;
import com.panzhihua.common.model.dtos.common.EditComPbCheckUnitDto;
import com.panzhihua.common.model.dtos.common.PageComPbCheckUnitDto;
import com.panzhihua.common.model.dtos.common.PagePbCheckUnitCommonDto;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.TreeListVO;
import com.panzhihua.common.model.vos.common.ComPbCheckUnitVo;
import com.panzhihua.common.model.vos.common.PbCheckUnitStatisticsVo;
import com.panzhihua.common.model.vos.partybuilding.excel.ComPbCheckUnitErrorExcelVO;
import com.panzhihua.common.model.vos.partybuilding.excel.ComPbCheckUnitExcelVO;
import com.panzhihua.common.service.community.CommunityService;
import com.panzhihua.common.utlis.StringUtils;
import com.panzhihua.service_dangjian.dao.ComPbCheckUnitMapper;
import com.panzhihua.service_dangjian.dao.ComPbMemberDAO;
import com.panzhihua.service_dangjian.dao.ComPbMemberRoleDAO;
import com.panzhihua.service_dangjian.entity.ComPbCheckUnit;
import com.panzhihua.service_dangjian.dao.ComPbCheckUnitMapper;
import com.panzhihua.service_dangjian.model.dos.ComPbMemberDO;
import com.panzhihua.service_dangjian.model.dos.ComPbMemberRoleDO;
import com.panzhihua.service_dangjian.service.ComPbCheckUnitService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.panzhihua.service_dangjian.service.ComPbMemberService;
import org.springframework.beans.BeanUtils;
import com.panzhihua.common.model.dtos.common.*;
import com.panzhihua.common.model.vos.R;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
 * title: 党建-报到单位表服务实现类
@@ -49,10 +55,7 @@
    private ComPbMemberDAO comPbMemberDAO;
    @Resource
    private ComPbMemberRoleDAO comPbMemberRoleDAO;
    @Resource
    private ComPbMemberService comPbMemberService;
    @Resource
    private CommunityService communityService;
    /**
     * description  queryByPage  分页查询
@@ -66,19 +69,14 @@
    public R queryByPage(PageComPbCheckUnitDto comPbCheckUnit) {
        Long communityId = comPbCheckUnit.getCommunityId();
        R r = communityService.selectCommunityIds(communityId);
        List<Long> communityIds = null;
        if(R.isOk(r)){
            communityIds = JSONArray.parseArray(JSONArray.toJSONString(r.getData()), Long.class);
        if (communityId != null){
            List<Long> communityIds = comPbMemberDAO.selectIds(communityId);
            if (CollUtil.isEmpty(communityIds)) {
                communityIds = new ArrayList<>();
                communityIds.add(communityId);
            }
        }else {
            communityIds = new ArrayList<>();
            communityIds.add(communityId);
            comPbCheckUnit.setCommunityIds(communityIds);
        }
        comPbCheckUnit.setCommunityIds(communityIds);
        IPage<ComPbCheckUnitVo> checkUnitVoPage= this.baseMapper.queryAllByLimit(comPbCheckUnit, new Page(comPbCheckUnit.getPageNum(), comPbCheckUnit.getPageSize()));
        checkUnitVoPage.getRecords().forEach(checkUnit -> {
            if(StringUtils.isEmpty(checkUnit.getOrgName())){
@@ -86,6 +84,34 @@
            }
        });
        return R.ok(checkUnitVoPage);
    }
    @Override
    public R treeList(TreeListVO treeListVO) {
        QueryWrapper<ComPbCheckUnit> wrapper = new QueryWrapper<>();
        if(treeListVO.getName() != null){
            wrapper.eq("belong_to",treeListVO.getName());
        } else if(treeListVO.getOrgName() != null){
            wrapper.eq("org_name",treeListVO.getOrgName());
        } else {
            return R.ok();
        }
        List<ComPbCheckUnit> comPbCheckUnits = this.baseMapper.selectList(wrapper);
        return R.ok(comPbCheckUnits);
    }
    @Override
    public R orgList() {
        QueryWrapper<ComPbCheckUnit> wrapper = new QueryWrapper<>();
        List<ComPbCheckUnitVo> voList = new ArrayList<>();
        List<ComPbCheckUnit> list = this.baseMapper.selectList(wrapper);
        Map<String, List<ComPbCheckUnit>> map = list.stream().filter(f -> f.getOrgName() != null).collect(Collectors.groupingBy(ComPbCheckUnit::getOrgName));
        for (Map.Entry<String, List<ComPbCheckUnit>> entry : map.entrySet()) {
            ComPbCheckUnitVo pbCheckUnitVo = new ComPbCheckUnitVo();
            pbCheckUnitVo.setOrgName(entry.getKey());
            voList.add(pbCheckUnitVo);
        }
        return R.ok(voList);
    }
    /**
@@ -102,6 +128,15 @@
        Long communityId=this.baseMapper.selectCommunityId(comPbCheckUnit.getHelpCommunityName().split(",")[0],comPbCheckUnit.getHelpCommunityName().split(",")[1],comPbCheckUnit.getHelpCommunityName().split(",")[2]);
        ComPbCheckUnit entity = new ComPbCheckUnit();
        BeanUtils.copyProperties(comPbCheckUnit, entity);
        int a=0;
        if(!StringUtils.isEmpty(comPbCheckUnit.getAdminPhone()))
        {
            a=this.baseMapper.selectOrgAdmin(comPbCheckUnit.getAdminPhone());
        }
        if(a!=0)
        {
            return R.fail("该手机号已绑定管理员!");
        }
        if(communityId!=null){
            entity.setCommunityId(communityId);
        }
@@ -189,19 +224,14 @@
    @Override
    public R queryByList(PageComPbCheckUnitDto comPbCheckUnit) {
        Long communityId = comPbCheckUnit.getCommunityId();
        R r = communityService.selectCommunityIds(communityId);
        List<Long> communityIds = null;
        if(R.isOk(r)){
            communityIds = JSONArray.parseArray(JSONArray.toJSONString(r.getData()), Long.class);
        if (communityId != null){
            List<Long> communityIds = comPbMemberDAO.selectIds(communityId);
            if (CollUtil.isEmpty(communityIds)) {
                communityIds = new ArrayList<>();
                communityIds.add(communityId);
            }
        }else {
            communityIds = new ArrayList<>();
            communityIds.add(communityId);
            comPbCheckUnit.setCommunityIds(communityIds);
        }
        comPbCheckUnit.setCommunityIds(communityIds);
        IPage<ComPbCheckUnitVo> checkUnitList = this.baseMapper.queryAllByLimit(comPbCheckUnit,new Page(comPbCheckUnit.getPageNum(),comPbCheckUnit.getPageSize()));
        checkUnitList.getRecords().forEach(checkUnit -> {
            if(StringUtils.isEmpty(checkUnit.getOrgName())){
@@ -279,20 +309,21 @@
     * @return
     */
    @Override
    public R unitStatisticsTop(Long communityId, String belongTo, String choice) {
        R r = communityService.selectCommunityIds(communityId);
        List<Long> communityIds = null;
        if(R.isOk(r)){
            communityIds = JSONArray.parseArray(JSONArray.toJSONString(r.getData()), Long.class);
    public R unitStatisticsTop(Long communityId, String belongTo, String choice,Long[] unitIds,String yearTime) {
        List<Long> communityIds = new ArrayList<>();
        if (null != communityId){
             communityIds = comPbMemberDAO.selectIds(communityId);
            if (CollUtil.isEmpty(communityIds)) {
                communityIds = new ArrayList<>();
                communityIds.add(communityId);
            }
        }else {
            communityIds = new ArrayList<>();
            communityIds.add(communityId);
        }
        return R.ok(this.baseMapper.unitStatisticsTop(communityIds, belongTo, choice));
        //查询 活动总积分
        PbCheckUnitStatisticsVo vo = this.baseMapper.unitStatisticsTop(communityIds, belongTo, choice,unitIds,yearTime);
        if(null != vo) {
            Integer sum = this.baseMapper.organSumIntegral(communityIds,yearTime);
            vo.setOrganSumIntegral(sum);
        }
        return R.ok(vo);
    }
    /**
@@ -303,19 +334,14 @@
    @Override
    public R unitStatistics(PagePbCheckUnitCommonDto commonDto) {
        Long communityId = commonDto.getCommunityId();
        R r = communityService.selectCommunityIds(communityId);
        List<Long> communityIds = null;
        if(R.isOk(r)){
            communityIds = JSONArray.parseArray(JSONArray.toJSONString(r.getData()), Long.class);
        if (null != communityId) {
            List<Long> communityIds = comPbMemberDAO.selectIds(communityId);
            if (CollUtil.isEmpty(communityIds)) {
                communityIds = new ArrayList<>();
                communityIds.add(communityId);
            }
        }else {
            communityIds = new ArrayList<>();
            communityIds.add(communityId);
            commonDto.setCommunityIds(communityIds);
        }
        commonDto.setCommunityIds(communityIds);
        return R.ok(this.baseMapper.unitStatistics(commonDto, new Page(commonDto.getPageNum(), commonDto.getPageSize())));
    }
@@ -328,21 +354,22 @@
     * @return
     */
    @Override
    public R pbStatisticsTop(Long communityId, String belongTo, String choice, Long checkUnitId) {
    public R pbStatisticsTop(Long communityId, String belongTo, String choice, Long checkUnitId,Long[] unitIds ,String yearTime) {
        R r = communityService.selectCommunityIds(communityId);
        List<Long> communityIds = null;
        if(R.isOk(r)){
            communityIds = JSONArray.parseArray(JSONArray.toJSONString(r.getData()), Long.class);
        List<Long> communityIds = new ArrayList<>();
        if (null != communityId){
            communityIds = comPbMemberDAO.selectIds(communityId);
            if (CollUtil.isEmpty(communityIds)) {
                communityIds = new ArrayList<>();
                communityIds.add(communityId);
            }
        }else {
            communityIds = new ArrayList<>();
            communityIds.add(communityId);
        }
        return R.ok(this.baseMapper.pbStatisticsTop(communityIds, belongTo, choice, checkUnitId));
        //查询 活动总积分
        PbCheckUnitStatisticsVo vo = this.baseMapper.pbStatisticsTop(communityIds, belongTo, choice, checkUnitId,unitIds,yearTime);
        if(null != vo) {
            Integer sum = this.baseMapper.pbOrganSumIntegral(communityIds,yearTime);
            vo.setOrganSumIntegral(sum);
        }
        return R.ok(vo);
    }
    /**
@@ -353,19 +380,14 @@
    @Override
    public R pbStatisticsBelong(PagePbCheckUnitCommonDto commonDto) {
        Long communityId = commonDto.getCommunityId();
        R r = communityService.selectCommunityIds(communityId);
        List<Long> communityIds = null;
        if(R.isOk(r)){
            communityIds = JSONArray.parseArray(JSONArray.toJSONString(r.getData()), Long.class);
        if (null != communityId) {
            List<Long> communityIds = comPbMemberDAO.selectIds(communityId);
            if (CollUtil.isEmpty(communityIds)) {
                communityIds = new ArrayList<>();
                communityIds.add(communityId);
            }
        }else {
            communityIds = new ArrayList<>();
            communityIds.add(communityId);
            commonDto.setCommunityIds(communityIds);
        }
        commonDto.setCommunityIds(communityIds);
        return R.ok(this.baseMapper.pbStatisticsBelong(commonDto, new Page(commonDto.getPageNum(), commonDto.getPageSize())));
    }
@@ -377,15 +399,8 @@
    @Override
    public R pbStatisticsUnit(PagePbCheckUnitCommonDto commonDto) {
        Long communityId = commonDto.getCommunityId();
        R r = communityService.selectCommunityIds(communityId);
        List<Long> communityIds = null;
        if(R.isOk(r)){
            communityIds = JSONArray.parseArray(JSONArray.toJSONString(r.getData()), Long.class);
            if (CollUtil.isEmpty(communityIds)) {
                communityIds = new ArrayList<>();
                communityIds.add(communityId);
            }
        }else {
        List<Long> communityIds = comPbMemberDAO.selectIds(communityId);
        if (CollUtil.isEmpty(communityIds)) {
            communityIds = new ArrayList<>();
            communityIds.add(communityId);
        }