From cda9decfde8c6b518639c5da506aa293c07f88ff Mon Sep 17 00:00:00 2001 From: p-honggang.li <p-honggang.li@pcitc.com> Date: 星期一, 08 九月 2025 16:43:04 +0800 Subject: [PATCH] 修改附件上传用户id类型为string,及审核页面不显示带文件上传状态 --- src/main/java/com/webmanage/service/impl/PointsRuleServiceImpl.java | 86 ++++++++++++++++++++++--------------------- 1 files changed, 44 insertions(+), 42 deletions(-) diff --git a/src/main/java/com/webmanage/service/impl/PointsRuleServiceImpl.java b/src/main/java/com/webmanage/service/impl/PointsRuleServiceImpl.java index 05d9e37..1512773 100644 --- a/src/main/java/com/webmanage/service/impl/PointsRuleServiceImpl.java +++ b/src/main/java/com/webmanage/service/impl/PointsRuleServiceImpl.java @@ -5,24 +5,30 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.webmanage.common.BusinessException; import com.webmanage.dto.PointsRuleDTO; + import com.webmanage.emun.RuleTypeEnum; import com.webmanage.entity.Points; import com.webmanage.entity.PointsRule; -import com.webmanage.entity.PointsRuleDetail; import com.webmanage.mapper.PointsRuleMapper; import com.webmanage.service.PointsRuleService; import com.webmanage.service.PointsService; -import com.webmanage.service.PointsRuleDetailService; + import com.webmanage.vo.PointsRuleResultVO; import com.webmanage.vo.PointsRuleVO; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; +import java.beans.Transient; +import java.text.DateFormat; import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.ArrayList; +import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -36,9 +42,7 @@ @Autowired private PointsService pointsService; - - @Autowired - private PointsRuleDetailService pointsRuleDetailService; + @Override public PointsRuleResultVO getPointsRuleList(Long ruleId) { @@ -46,7 +50,7 @@ QueryWrapper<PointsRule> wrapper = new QueryWrapper<>(); wrapper.eq("deleted", 0).eq("is_enabled",0); - + if(ruleId != null){ wrapper.eq("points_id", ruleId); } @@ -54,7 +58,7 @@ List<PointsRule> list = list(wrapper); PointsRuleResultVO pointsRuleResultVO = new PointsRuleResultVO(); if (!CollectionUtil.isEmpty(list)) { - Map<Long, List<PointsRule>> collect = list.stream().collect(Collectors.groupingBy(PointsRule::getRuleType)); + Map<Integer, List<PointsRule>> collect = list.stream().collect(Collectors.groupingBy(PointsRule::getRuleType)); Map<String, List<PointsRule>> getRules = collect.get(RuleTypeEnum.GET.getCode()).stream().collect(Collectors.groupingBy(PointsRule::getCategory)); Map<String, List<PointsRule>> consumeRules = collect.get(RuleTypeEnum.CONSUME.getCode()).stream().collect(Collectors.groupingBy(PointsRule::getCategory)); @@ -62,6 +66,7 @@ List<PointsRuleVO> consumePointsRuleVOList = new ArrayList<>(); getRules.forEach((k,v)->{ PointsRuleVO pointsRuleVO = new PointsRuleVO(); + pointsRuleVO.setRlueSort(v.get(0).getRuleOrder()); pointsRuleVO.setCategory(k); pointsRuleVO.setPointsRules(v); getPointsRuleVOList.add(pointsRuleVO); @@ -69,11 +74,14 @@ }); consumeRules.forEach((k,v)->{ PointsRuleVO pointsRuleVO = new PointsRuleVO(); + pointsRuleVO.setRlueSort(v.get(0).getRuleOrder()); pointsRuleVO.setCategory(k); pointsRuleVO.setPointsRules(v); consumePointsRuleVOList.add(pointsRuleVO); }); + getPointsRuleVOList.sort(Comparator.comparing(PointsRuleVO::getRlueSort)); + consumePointsRuleVOList.sort(Comparator.comparing(PointsRuleVO::getRlueSort)); pointsRuleResultVO.setGetPointsRuleList(getPointsRuleVOList); pointsRuleResultVO.setConsumePointsRuleList(consumePointsRuleVOList); } @@ -99,48 +107,42 @@ } @Override - public boolean updatePointsRule(PointsRuleDTO pointsRuleDTO) { - if (pointsRuleDTO.getId() == null) { - throw new BusinessException("瑙勫垯ID涓嶈兘涓虹┖"); + @Transactional(rollbackFor = Exception.class) + public boolean updatePointsRule(List<PointsRuleDTO> pointsRuleDTO) { + if (CollectionUtils.isEmpty(pointsRuleDTO)){ + return false; } - - PointsRule existingRule = getById(pointsRuleDTO.getId()); - if (existingRule == null) { - throw new BusinessException("绉垎瑙勫垯涓嶅瓨鍦�"); - } - - // 楠岃瘉瑙勫垯鍚嶇О鏄惁閲嶅锛堟帓闄よ嚜韬級 - QueryWrapper<PointsRule> wrapper = new QueryWrapper<>(); - wrapper.eq("rule_name", pointsRuleDTO.getRuleName()) - .eq("deleted", 0) - .ne("id", pointsRuleDTO.getId()); - - if (count(wrapper) > 0) { - throw new BusinessException("瑙勫垯鍚嶇О宸插瓨鍦�"); - } - + + // 鏌ヨ瑙勫垯鍚嶇О + Points pointsOld = pointsService.query().eq("id", pointsRuleDTO.get(0).getPointsId()) + .eq("deleted", 0).one(); + // 鏌ヨ褰撳ぉ鏄惁鏈夌増鏈洿鏂拌褰� + DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("YYYY-MM-DD HH:mm:ss"); + LocalDateTime nowDatetime = LocalDateTime.now(); + LocalDateTime localDateTimeStart = nowDatetime.toLocalDate().atStartOfDay(); + LocalDateTime localDateTimeEnd = nowDatetime.toLocalDate().atStartOfDay(); + // dateTimeFormatter.format(localDateTimeStart), dateTimeFormatter.format(localDateTimeEnd) + Long counts = pointsService.query().between("created_at", localDateTimeStart, localDateTimeEnd).count(); // 鍒涘缓鏂扮殑绉垎涓昏〃璁板綍 Points points = new Points(); - points.setPointsName(pointsRuleDTO.getRuleName() + "_" + System.currentTimeMillis()); + points.setPointsName(pointsOld.getPointsName()); points.setEffectiveStart(LocalDateTime.now()); - points.setModifierId(1L); // 杩欓噷搴旇浠庝笂涓嬫枃涓幏鍙栧綋鍓嶇敤鎴稩D + points.setModifierId(pointsOld.getModifierId()); // 杩欓噷搴旇浠庝笂涓嬫枃涓幏鍙栧綋鍓嶇敤鎴稩D points.setModifierName("admin"); // 杩欓噷搴旇浠庝笂涓嬫枃涓幏鍙栧綋鍓嶇敤鎴峰悕 - points.setVersion(1.0f); + points.setVersion(counts>0 ? pointsOld.getVersion() + 0.1f: 1.0f); points.setStatus(0); pointsService.save(points); - // 鍒涘缓绉垎瑙勫垯璇︽儏璁板綍 - PointsRuleDetail pointsRuleDetail = new PointsRuleDetail(); - pointsRuleDetail.setRuleId(pointsRuleDTO.getId()); - pointsRuleDetail.setPointsId(points.getId()); - pointsRuleDetail.setPointsValue(pointsRuleDTO.getPointsValue()); - pointsRuleDetail.setEffectiveStart(LocalDateTime.now()); - pointsRuleDetailService.save(pointsRuleDetail); - - BeanUtils.copyProperties(pointsRuleDTO, existingRule); - existingRule.setUpdatedAt(LocalDateTime.now()); - - return updateById(existingRule); + // 鍒涘缓绉垎瑙勫垯璁板綍 + for (PointsRuleDTO ruleDTO : pointsRuleDTO) { + PointsRule pointsRule = new PointsRule(); + BeanUtils.copyProperties(ruleDTO,pointsRule); + pointsRule.setPointsId(points.getId()); + pointsRule.setUpdatedAt(LocalDateTime.now()); + save(pointsRule); + } + + return true; } @Override @@ -168,7 +170,7 @@ throw new BusinessException("绉垎瑙勫垯涓嶅瓨鍦�"); } - pointsRule.setIsEnabled(isEnabled); + pointsRule.setIsEnabled(isEnabled ? 0: 1); pointsRule.setUpdatedAt(LocalDateTime.now()); return updateById(pointsRule); -- Gitblit v1.8.0