|  |  | 
 |  |  | package com.doumee.service.business.impl; | 
 |  |  |  | 
 |  |  | import com.doumee.core.model.LoginUserInfo; | 
 |  |  | import com.doumee.core.model.PageData; | 
 |  |  | import com.doumee.core.model.PageWrap; | 
 |  |  | import com.doumee.core.utils.Constants; | 
 |  |  | 
 |  |  | import com.doumee.dao.business.model.Company; | 
 |  |  | import com.doumee.dao.business.model.InsuranceApply; | 
 |  |  | import com.doumee.dao.business.model.Notices; | 
 |  |  | import com.doumee.dao.business.vo.ApplyNoticeVO; | 
 |  |  | import com.doumee.service.business.NoticesService; | 
 |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
 |  |  | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; | 
 |  |  | 
 |  |  | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
 |  |  | import com.github.xiaoymin.knife4j.core.util.CollectionUtils; | 
 |  |  | import com.github.yulichang.wrapper.MPJLambdaWrapper; | 
 |  |  | import org.apache.shiro.SecurityUtils; | 
 |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
 |  |  | import org.springframework.stereotype.Service; | 
 |  |  | import java.util.List; | 
 |  |  | import java.util.stream.Collectors; | 
 |  |  |  | 
 |  |  | /** | 
 |  |  |  * 系统消息信息表Service实现 | 
 |  |  | 
 |  |  |         IPage<Notices> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); | 
 |  |  |         MPJLambdaWrapper<Notices> queryWrapper = new MPJLambdaWrapper<>(); | 
 |  |  |         Utils.MP.blankToNull(pageWrap.getModel()); | 
 |  |  |         LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); | 
 |  |  |  | 
 |  |  |         //企业人员查看本企业数据 | 
 |  |  |         if(loginUserInfo.getType().equals(Constants.ONE)||loginUserInfo.getType().equals(Constants.TWO)){ | 
 |  |  |             queryWrapper.eq(Notices::getCompanyId, loginUserInfo.getCompanyId()); | 
 |  |  |         }else{ | 
 |  |  |             if(loginUserInfo.getCompanyIdList()!=null && loginUserInfo.getCompanyIdList().size()>0){ | 
 |  |  |                 queryWrapper.in(Notices::getCompanyId, loginUserInfo.getCompanyIdList()); | 
 |  |  |             }else{ | 
 |  |  |                 queryWrapper.eq(Notices::getCompanyId, -1); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         queryWrapper.selectAll(Notices.class); | 
 |  |  |         queryWrapper.selectAs(Company::getName,Notices::getCompanyName); | 
 |  |  |         queryWrapper.leftJoin(Company.class,Company::getId,Notices::getCompanyId); | 
 |  |  |         queryWrapper.eq(Notices::getType, Constants.NoticeType.SIX.getStatus()); | 
 |  |  |         if (pageWrap.getModel().getIsdeleted() != null) { | 
 |  |  |             queryWrapper.eq(Notices::getIsdeleted, pageWrap.getModel().getIsdeleted()); | 
 |  |  |         } | 
 |  |  | 
 |  |  |         if (pageWrap.getModel().getReaded() != null) { | 
 |  |  |             queryWrapper.eq(Notices::getReaded, pageWrap.getModel().getReaded()); | 
 |  |  |         } | 
 |  |  |         if(pageWrap.getModel().getQueryType()!=null){ | 
 |  |  |             if(pageWrap.getModel().getQueryType().equals(Constants.ZERO)){ | 
 |  |  |                 queryWrapper.in(Notices::getObjType,new Integer[]{Constants.NoticeObjectType.INSURANCE_APPLY.getKey(), | 
 |  |  |                         Constants.NoticeObjectType.APPLY_CHANGE.getKey(), | 
 |  |  |                         Constants.NoticeObjectType.DISPATCH_UNIT.getKey(), | 
 |  |  |                         Constants.NoticeObjectType.CHANGE_FACTORY.getKey()}); | 
 |  |  |             } else if(pageWrap.getModel().getQueryType().equals(Constants.ONE)){ | 
 |  |  |                 queryWrapper.in(Notices::getObjType,new Integer[]{Constants.NoticeObjectType.TAXES.getKey() }); | 
 |  |  |             } else if(pageWrap.getModel().getQueryType().equals(Constants.TWO)){ | 
 |  |  |                 queryWrapper.in(Notices::getObjType,new Integer[]{Constants.NoticeObjectType.SETTLE_CLAIMS.getKey() }); | 
 |  |  |             }else if(pageWrap.getModel().getQueryType().equals(Constants.THREE)){ | 
 |  |  |                 //委托保代办 | 
 |  |  |                 queryWrapper.notIn(Notices::getType,new Integer[]{Constants.NoticeType.SEVEN.getStatus() }); | 
 |  |  |             }else if(pageWrap.getModel().getQueryType().equals(Constants.FOUR)){ | 
 |  |  |                 //委托保代办 | 
 |  |  |                 queryWrapper.in(Notices::getType,new Integer[]{Constants.NoticeType.SEVEN.getStatus() }); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         if(CollectionUtils.isNotEmpty(pageWrap.getSorts())){ | 
 |  |  |             for(PageWrap.SortData sortData: pageWrap.getSorts()) { | 
 |  |  |                 if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) { | 
 |  |  | 
 |  |  |         PageData<Notices> pageData = PageData.from(noticesMapper.selectJoinPage(page,Notices.class, queryWrapper)); | 
 |  |  |         pageData.getRecords().forEach(i->{ | 
 |  |  |             i.setTypeDetail( | 
 |  |  |                     Constants.NoticeType.getDetail(i.getObjType(),i.getType()) | 
 |  |  |                     Constants.NoticeType.getDetail(i.getType(),i.getObjType()) | 
 |  |  |             ); | 
 |  |  |         }); | 
 |  |  |         return pageData; | 
 |  |  | 
 |  |  |         QueryWrapper<Notices> wrapper = new QueryWrapper<>(notices); | 
 |  |  |         return noticesMapper.selectCount(wrapper); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 查询投保单 提醒数量 | 
 |  |  |      * @param companyId | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     @Override | 
 |  |  |     public ApplyNoticeVO getApplyNotice(Integer companyId){ | 
 |  |  |         ApplyNoticeVO applyNoticeVO = new ApplyNoticeVO(); | 
 |  |  |         applyNoticeVO.setWaitSignNum(Constants.ZERO); | 
 |  |  |         applyNoticeVO.setRenewalNum(Constants.ZERO); | 
 |  |  |         List<Notices> noticesList = noticesMapper.selectList(new QueryWrapper<Notices>() | 
 |  |  |                 .lambda() | 
 |  |  |                 .select(Notices::getType) | 
 |  |  |                 .eq(Notices::getPalt,Constants.ONE) | 
 |  |  |                 .eq(Notices::getCompanyId,companyId) | 
 |  |  |                 .eq(Notices::getObjType,Constants.NoticeObjectType.INSURANCE_APPLY.getKey()) | 
 |  |  |                 .eq(Notices::getStatus,Constants.ZERO) | 
 |  |  |                 .in(Notices::getType,Constants.NoticeType.SIX.getStatus(),Constants.NoticeType.ONE.getStatus()) | 
 |  |  |         ); | 
 |  |  |         if(CollectionUtils.isNotEmpty(noticesList)){ | 
 |  |  |             applyNoticeVO.setRenewalNum(noticesList.stream().filter(m->m.getType().equals(Constants.NoticeType.SIX.getStatus())).collect(Collectors.toList()).size()); | 
 |  |  |             applyNoticeVO.setWaitSignNum(noticesList.size() - applyNoticeVO.getRenewalNum()); | 
 |  |  |         } | 
 |  |  |         return applyNoticeVO ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 关闭提醒 | 
 |  |  |      * @param companyId | 
 |  |  |      * @param type | 
 |  |  |      */ | 
 |  |  |     @Override | 
 |  |  |     public void closeApplyNotice(Integer companyId,Integer type){ | 
 |  |  |         noticesMapper.update(null,new UpdateWrapper<Notices>() | 
 |  |  |                 .lambda() | 
 |  |  |                 .set(Notices::getStatus,Constants.ONE) | 
 |  |  |                 .eq(Notices::getPalt,Constants.ONE) | 
 |  |  |                 .eq(Notices::getCompanyId,companyId) | 
 |  |  |                 .eq(Notices::getStatus,Constants.ZERO) | 
 |  |  |                 .eq(Notices::getObjType,Constants.NoticeObjectType.INSURANCE_APPLY.getKey()) | 
 |  |  |                 .eq(Notices::getType,type) | 
 |  |  |         ); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | } |