| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.entity.EsModel; |
| | | import com.ruoyi.common.utils.MapUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.domain.*; |
| | | import com.ruoyi.domain.dto.zfEventdto; |
| | | import com.ruoyi.mapper.TravelCountMapper; |
| | | import com.ruoyi.service.ModuleSearchable; |
| | | import com.ruoyi.service.TravelCountService; |
| | | import com.ruoyi.service.TravelDetailService; |
| | | import com.ruoyi.service.ZInfoUserService; |
| | | import com.ruoyi.service.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.text.DecimalFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.time.LocalDateTime; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.ruoyi.constant.MenuAuthority.*; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | private TravelCountService travelCountService; |
| | | @Autowired |
| | | ZInfoUserService zInfoUserService; |
| | | |
| | | @Resource |
| | | ZAuthorityService zAuthorityService; |
| | | |
| | | |
| | | |
| | | @Override |
| | | public AjaxResult selectDataList(Long userId, Integer pageNum, Integer pageSize, TravelCount travelCount, String happenStartTime, String happenEndTime) { |
| | | //设置查询条件 |
| | | LambdaQueryWrapper<TravelCount> lqw = new LambdaQueryWrapper<>(); |
| | | // lqw.eq(TravelCount::getUid,userId); |
| | | if(travelCount!=null){ |
| | | lqw.like(travelCount.getName()!=null,TravelCount::getName,travelCount.getName()); |
| | | lqw.like(travelCount.getDestination()!=null,TravelCount::getDestination,travelCount.getDestination()); |
| | | lqw.like(travelCount.getProperty()!=null,TravelCount::getProperty,travelCount.getProperty()); |
| | | lqw.like(travelCount.getManner()!=null,TravelCount::getManner,travelCount.getManner()); |
| | | lqw.like(travelCount.getName()!=null,TravelCount::getName,travelCount.getName()); |
| | | lqw.like(travelCount.getName()!=null,TravelCount::getName,travelCount.getName()); |
| | | lqw.like(travelCount.getName()!=null,TravelCount::getName,travelCount.getName()); |
| | | } |
| | | if(happenStartTime!=null){ |
| | | lqw.gt(TravelCount::getStartTime,happenStartTime); |
| | | } |
| | | |
| | | if(happenEndTime!=null){ |
| | | lqw.lt(TravelCount::getEndTime,happenEndTime); |
| | | //要查自己家庭的 |
| | | ZInfoUser myself = zInfoUserService.getMyself(); |
| | | if (myself == null) { |
| | | // System.out.println("ssssss"); |
| | | return AjaxResult.success("您没加入到对应的家庭,请联系管理员"); |
| | | } |
| | | lqw.orderByDesc(TravelCount::getCreateTime); |
| | | Long familyId = myself.getFamilyId(); |
| | | |
| | | //查看父母的数据: |
| | | Long fatherFaId = 0L; |
| | | if(myself.getFatherId()!=null) |
| | | fatherFaId = zInfoUserService.getInfoById(myself.getFatherId()).getFamilyId(); |
| | | Long motherFaId = 0L; |
| | | if(myself.getMomId()!=null) |
| | | motherFaId = zInfoUserService.getInfoById(myself.getMomId()).getFamilyId(); |
| | | |
| | | System.out.println("--sdfdsf000sfssssssssssssssssss"); |
| | | //根据userId查询到infouser的uaid |
| | | ZInfoUser zInfoUser = zInfoUserService.getInfoBysysId(userId); |
| | | //拿到所有的sysid |
| | | List<Long> fms = zInfoUserService.findByUaidToFaid(zInfoUser.getUaid()).stream().map(ZInfoUser::getSysId).collect(Collectors.toList()); |
| | | // LambdaQueryWrapper<TravelCount> lqw; |
| | | //也要查别人授权的 |
| | | List<ZAuthority> authority = zAuthorityService.getAuthority(); |
| | | List<Long> idList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(TRAVEL_LIST)).map(ZAuthority::getFid).collect(Collectors.toList()); |
| | | //加上自己家庭的id |
| | | idList.add(familyId); |
| | | |
| | | //加上父母家族id |
| | | idList.add(fatherFaId); |
| | | idList.add(motherFaId); |
| | | List<Long> fms = zInfoUserService.findByUaidToFaid(myself.getUaid()).stream().map(ZInfoUser::getFamilyId).collect(Collectors.toList()); |
| | | if(!fms.isEmpty()) |
| | | lqw = lqw.in(TravelCount::getUid, fms); |
| | | else |
| | | lqw.eq(TravelCount::getUid,userId); |
| | | // else |
| | | // lqw = buildCondition(zProperty, userId); |
| | | |
| | | |
| | | Page<TravelCount> resultPage = page(new Page<>(pageNum, pageSize), lqw); |
| | | resultPage.getRecords().forEach(this::inputTotalData); |
| | | return AjaxResult.success(MapUtils.getResult(resultPage)); |
| | | { |
| | | idList.addAll(fms); |
| | | } |
| | | |
| | | LambdaQueryWrapper<TravelCount> lqw = buildCondition(travelCount, idList); |
| | | |
| | | Page<TravelCount> travelCountPage = new Page<>(pageNum, pageSize); |
| | | Page<TravelCount> pageResult = page(travelCountPage, lqw); |
| | | |
| | | List<TravelCount> beanRecords = pageResult.getRecords();//得到查询出来的数据 |
| | | HashMap<String, Object> data = MapUtils.getResult(pageResult, beanRecords); |
| | | return AjaxResult.success(data); |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult addData(TravelCount travelCount) { |
| | | ZInfoUser myself = zInfoUserService.getMyself(); |
| | | Long familyId = myself.getFamilyId(); |
| | | |
| | | if (familyId == null) { |
| | | throw new RuntimeException("您还未加入任何家庭"); |
| | | } |
| | | |
| | | List<ZAuthority> authority = zAuthorityService.getAuthority(); |
| | | List<Long> familyIdList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(TRAVEL_LIST_ADD)).map(ZAuthority::getFid).collect(Collectors.toList()); |
| | | familyIdList.add(familyId); |
| | | |
| | | if (travelCount.getFamilyId() != null && !familyIdList.contains(travelCount.getFamilyId())) { |
| | | throw new RuntimeException("你没有权限操作此家庭的数据"); |
| | | } |
| | | |
| | | |
| | | if (travelCount.getFamilyId() == null) { |
| | | //默认添加自己家庭的数据 |
| | | travelCount.setFamilyId(familyId); |
| | | } |
| | | |
| | | if (save(travelCount)) { |
| | | return AjaxResult.success(); |
| | | } else { |
| | | return AjaxResult.error(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult updateData(TravelCount travelCount) { |
| | | ZInfoUser myself = zInfoUserService.getMyself(); |
| | | Long familyId = myself.getFamilyId(); |
| | | |
| | | //先根据id查询出数据的familyId,看看有没有权限操作 |
| | | Long dataFamilyId = getById(travelCount.getId()).getFamilyId(); |
| | | |
| | | List<ZAuthority> authority = zAuthorityService.getAuthority(); |
| | | List<Long> familyIdList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(TRAVEL_LIST_UPDATE)).map(ZAuthority::getFid).collect(Collectors.toList()); |
| | | familyIdList.add(familyId); |
| | | |
| | | if (dataFamilyId != null && !familyIdList.contains(dataFamilyId)) { |
| | | throw new RuntimeException("你没有权限操作此家庭的数据"); |
| | | } |
| | | |
| | | |
| | | if (updateById(travelCount)) { |
| | | return AjaxResult.success(); |
| | | } else { |
| | | return AjaxResult.error(); |
| | | } |
| | | } |
| | | /** |
| | | * 批量删除统计表数据 |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public void removeData(List<Long> list) { |
| | | |
| | | List<TravelCount> dataList = this.listByIds(list); |
| | | |
| | | ZInfoUser myself = zInfoUserService.getMyself(); |
| | | Long familyId = myself.getFamilyId(); |
| | | |
| | | List<ZAuthority> authority = zAuthorityService.getAuthority(); |
| | | List<Long> familyIdList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(TRAVEL_LIST_REMOVE)).map(ZAuthority::getFid).collect(Collectors.toList()); |
| | | familyIdList.add(familyId); |
| | | |
| | | for (TravelCount data : dataList) { |
| | | if (!familyIdList.contains(data.getFamilyId())) { |
| | | throw new RuntimeException("你没有权限操作此家庭的数据"); |
| | | } |
| | | } |
| | | |
| | | //在删除统计表数据之前,要先删除明细表的数据 |
| | | travelDetailService.removeBatchByCid(list); |
| | |
| | | LambdaQueryWrapper<TravelCount> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.orderByDesc(TravelCount::getCreateTime); |
| | | |
| | | lqw.in(familyIdList != null,TravelCount::getFamilyId, familyIdList); |
| | | lqw.orderByDesc(TravelCount::getCreateTime); |
| | | |
| | | |
| | | |
| | | lqw.like(travelCount.getName()!=null,TravelCount::getName,travelCount.getName()); |
| | | lqw.like(travelCount.getDestination()!=null,TravelCount::getDestination,travelCount.getDestination()); |
| | | lqw.like(travelCount.getProperty()!=null,TravelCount::getProperty,travelCount.getProperty()); |
| | | lqw.like(travelCount.getManner()!=null,TravelCount::getManner,travelCount.getManner()); |
| | | lqw.like(travelCount.getName()!=null,TravelCount::getName,travelCount.getName()); |
| | | lqw.like(travelCount.getName()!=null,TravelCount::getName,travelCount.getName()); |
| | | lqw.like(travelCount.getName()!=null,TravelCount::getName,travelCount.getName()); |
| | | |
| | | |
| | | |
| | | |
| | | if (StringUtils.isNotEmpty(travelCount.getIsHide())) { |
| | | |
| | | lqw.and(wrapper -> wrapper |