From 4aa4a9f3ddeccf7d8f05f54a127f0334b7691aaf Mon Sep 17 00:00:00 2001
From: zqy <2522236926@qq.com>
Date: 星期一, 19 一月 2026 10:59:02 +0800
Subject: [PATCH] 修改缩略图翻转问题
---
zhang-content/src/main/java/com/ruoyi/service/impl/TravelCountServiceImpl.java | 301 ++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 269 insertions(+), 32 deletions(-)
diff --git a/zhang-content/src/main/java/com/ruoyi/service/impl/TravelCountServiceImpl.java b/zhang-content/src/main/java/com/ruoyi/service/impl/TravelCountServiceImpl.java
index e8a3c85..16ea477 100644
--- a/zhang-content/src/main/java/com/ruoyi/service/impl/TravelCountServiceImpl.java
+++ b/zhang-content/src/main/java/com/ruoyi/service/impl/TravelCountServiceImpl.java
@@ -2,21 +2,28 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
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.domain.TravelCount;
-import com.ruoyi.domain.TravelDetail;
+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.TravelCountService;
-import com.ruoyi.service.TravelDetailService;
+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.List;
+import java.time.LocalDateTime;
+import java.util.*;
+import java.util.stream.Collectors;
+
+import static com.ruoyi.constant.MenuAuthority.*;
/**
* <p>
@@ -27,49 +34,118 @@
* @since 2023-10-06
*/
@Service
-public class TravelCountServiceImpl extends ServiceImpl<TravelCountMapper, TravelCount> implements TravelCountService {
+public class TravelCountServiceImpl extends ServiceImpl<TravelCountMapper, TravelCount> implements TravelCountService, ModuleSearchable {
@Autowired
private TravelDetailService travelDetailService;
@Autowired
private TravelCountService travelCountService;
+ @Autowired
+ ZInfoUserService zInfoUserService;
+
+ @Resource
+ ZAuthorityService zAuthorityService;
+
+
@Override
- public AjaxResult selectDataList(Long userId, Integer pageNum, Integer pageSize) {
- LambdaQueryWrapper<TravelCount> lqw = new LambdaQueryWrapper<>();
- lqw.eq(TravelCount::getUid,userId);
+ public AjaxResult selectDataList(Long userId, Integer pageNum, Integer pageSize, TravelCount travelCount, String happenStartTime, String happenEndTime) {
- Page<TravelCount> resultPage = page(new Page<>(pageNum, pageSize), lqw);
+ //瑕佹煡鑷繁瀹跺涵鐨�
+ ZInfoUser myself = zInfoUserService.getMyself();
+ if (myself == null) {
+ // System.out.println("ssssss");
+ return AjaxResult.success("鎮ㄦ病鍔犲叆鍒板搴旂殑瀹跺涵锛岃鑱旂郴绠$悊鍛�");
+ }
+ Long familyId = myself.getFamilyId();
- resultPage.getRecords().forEach(data ->{
- //鍏堟壘鍒板搴斾竴鏉$粺璁℃暟鎹殑鎵�鏈夎缁嗘暟鎹�
- List<TravelDetail> travelDetailList = travelDetailService.getDataByCid(data.getId());
- double entranceTotal = 0;
- double eatTotal = 0;
- double stayTotal = 0;
- double travelTotal = 0;
+ //鏌ョ湅鐖舵瘝鐨勬暟鎹細
+ 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();
- //鎶婃墍鏈夎缁嗘暟鎹殑璐圭敤鍊肩疮鍔犺捣鏉�
- for (TravelDetail detail : travelDetailList) {
- entranceTotal+=detail.getEntrance();
- eatTotal+=detail.getEat();
- stayTotal+=detail.getStay();
- travelTotal+=detail.getTravel();
- }
+ //涔熻鏌ュ埆浜烘巿鏉冪殑
+ List<ZAuthority> authority = zAuthorityService.getAuthority();
+ List<Long> idList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(TRAVEL_LIST)).map(ZAuthority::getFid).collect(Collectors.toList());
+ //鍔犱笂鑷繁瀹跺涵鐨刬d
+ idList.add(familyId);
- data.setEntranceTotal(entranceTotal);
- data.setEatTotal(eatTotal);
- data.setStayTotal(stayTotal);
- data.setTravelTotal(travelTotal);
+ //鍔犱笂鐖舵瘝瀹舵棌id
+ idList.add(fatherFaId);
+ idList.add(motherFaId);
+ List<Long> fms = zInfoUserService.findByUaidToFaid(myself.getUaid()).stream().map(ZInfoUser::getFamilyId).collect(Collectors.toList());
+ if(!fms.isEmpty())
+ {
+ idList.addAll(fms);
+ }
- DecimalFormat df = new DecimalFormat("0.00");
- data.setTotalPrice(Double.parseDouble(df.format(entranceTotal+eatTotal+data.getGroupTotal()+stayTotal+travelTotal)));
- });
+ LambdaQueryWrapper<TravelCount> lqw = buildCondition(travelCount, idList);
- return AjaxResult.success(MapUtils.getResult(resultPage));
+ 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();
+
+ //鍏堟牴鎹甶d鏌ヨ鍑烘暟鎹殑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();
+ }
+ }
/**
* 鎵归噺鍒犻櫎缁熻琛ㄦ暟鎹�
*/
@@ -77,10 +153,171 @@
@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);
//鍐嶅垹闄よ嚜宸辫〃鐨勬暟鎹�
travelCountService.removeBatchByIds(list);
}
+
+ @Override
+ public TravelCount getDataById(Long id) {
+ TravelCount travelCount = getById(id);
+ inputTotalData(travelCount);
+ return travelCount;
+ }
+
+ private void inputTotalData(TravelCount travelCount){
+ //鍏堟壘鍒板搴斾竴鏉$粺璁℃暟鎹殑鎵�鏈夎缁嗘暟鎹�
+ List<TravelDetail> travelDetailList = travelDetailService.getDataByCid(travelCount.getId(),null);
+ double entranceTotal = 0;
+ double eatTotal = 0;
+ double stayTotal = 0;
+ double travelTotal = 0;
+ double shopTotal = 0;
+ //鎶婃墍鏈夎缁嗘暟鎹殑璐圭敤鍊肩疮鍔犺捣鏉�
+ for (TravelDetail detail : travelDetailList) {
+ entranceTotal+=detail.getEntrance();
+ eatTotal+=detail.getEat();
+ stayTotal+=detail.getStay();
+ travelTotal+=detail.getTravel();
+ shopTotal += detail.getShop();
+ }
+
+ travelCount.setEntranceTotal(entranceTotal);
+ travelCount.setEatTotal(eatTotal);
+ travelCount.setStayTotal(stayTotal);
+ travelCount.setTravelTotal(travelTotal);
+ travelCount.setShopTotal(shopTotal);
+ DecimalFormat df = new DecimalFormat("0.00");
+ travelCount.setTotalPrice(Double.parseDouble(df.format(entranceTotal+eatTotal+travelCount.getGroupTotal()+stayTotal+travelTotal)));
+ }
+
+
+ private LambdaQueryWrapper<TravelCount> buildCondition(TravelCount travelCount, List<Long> familyIdList) {
+ 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
+ .ne(TravelCount::getIsHide, "鏄�")
+ .or()
+ .isNull(TravelCount::getIsHide)
+ );
+ }
+ if (travelCount.getHasAttachment() != null && travelCount.getHasAttachment().equals("鏄�")) {
+ lqw.apply("url IS NOT NULL AND url != ''");
+ }
+// lqw.in(StringUtils.isNotEmpty(travelCount.getCompanionList()),travelCount::getCompanion,travelCount.getCompanionList());
+// if (travelCount.getYear() != 0) {
+// System.out.println("pppppppppppppppppppppppppppppppppppppppppppppppppppp"+travelCount.getYear());
+// lqw.apply("YEAR(happen_time) = {0}", travelCount.getYear());
+// }
+
+ if (CollectionUtils.isNotEmpty(travelCount.getCompanionList())) {
+ List<String> companionList = travelCount.getCompanionList();
+
+ // 娓呯悊鍜屽幓閲�
+ companionList = companionList.stream()
+ .map(String::trim)
+ .filter(s -> !s.isEmpty())
+ .distinct()
+ .collect(Collectors.toList());
+
+ if (!companionList.isEmpty()) {
+ // 纭繚鎵�鏈夊弬涓庝汉閮藉湪companion瀛楁涓�
+ for (String companion : companionList) {
+ lqw.apply("FIND_IN_SET({0}, REPLACE(REPLACE(companion, ' ', ''), '锛�', ',')) > 0",
+ companion);
+ }
+ }
+ }
+
+ System.out.println("鏌ヨ鏉′欢: " + lqw.getCustomSqlSegment());
+
+ return lqw;
+ }
+
+ @Override
+ public String getModuleCode() {
+ return "鏃呮父";
+ }
+
+ @Override
+// @Cacheable(value = "economy_search", key = "T(String).format('2045_%s_%s_%s_%s',#companion != null ? #companion : 'null',#happenStartTime != null ? #happenStartTime.getTime() : 0,#happenEndTime != null ? #happenEndTime.getTime() : 0,#hasAttachment != null ? #hasAttachment : 'null')")
+ public List<?> search(String companion, Date happenStartTime, Date happenEndTime, String hasAttachment) {
+ TravelCount travelCount = new TravelCount();
+ travelCount.setCompanion(companion);
+
+
+ String[] split = companion.split(",");
+ List<String> list = Arrays.asList(split);
+
+ travelCount.setCompanionList(list);
+ travelCount.setHasAttachment(hasAttachment);
+ travelCount.setIsHide("鍚�");
+
+ System.out.println("[[[[[[[["+travelCount);
+
+ return dataList(travelCount);
+ }
+
+ public List<zfEventdto> dataList(TravelCount travelCount) {
+
+ LambdaQueryWrapper<TravelCount> lqw = buildCondition(travelCount, null);
+
+ List<TravelCount> beanRecords = list(lqw);
+
+
+
+ return encapData(beanRecords);
+ }
+
+ public List<zfEventdto> encapData(List<TravelCount> lis)
+ {
+ List<zfEventdto> daoRes = new ArrayList<>() ;
+ for(TravelCount obj : lis)
+ {
+ zfEventdto atd = new zfEventdto();
+ atd.setId(Math.toIntExact(obj.getId()));
+ atd.setModule("鏃呮父");
+ atd.setName(obj.getCompanion());
+ atd.setCreateTime(obj.getCreateTime());
+ daoRes.add(atd);
+ }
+ return daoRes;
+ }
+
}
--
Gitblit v1.9.1