From 40b9706aaef635a203da05c71cb733ae76a28933 Mon Sep 17 00:00:00 2001 From: mashuai Date: Sat, 6 Sep 2025 18:30:29 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=8A=9F=E8=83=BD=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../basic/service/impl/BmQrBoxServiceImpl.java | 18 +++++++++++++++++- .../impl/LeaseApplyInfoServiceImpl.java | 3 +++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/service/impl/BmQrBoxServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/service/impl/BmQrBoxServiceImpl.java index 253a1dbd..12951e84 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/service/impl/BmQrBoxServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/service/impl/BmQrBoxServiceImpl.java @@ -83,7 +83,23 @@ public class BmQrBoxServiceImpl implements BmQrBoxService { if (null != bmQrBoxInfo.getStatus()) { bmQrBoxInfo.setStatusList(Arrays.asList(bmQrBoxInfo.getStatus().split(","))); } - return bmQrBoxMapper.find(bmQrBoxInfo); + List list = bmQrBoxMapper.find(bmQrBoxInfo); + if (CollectionUtil.isNotEmpty(list)) { + if (CollectionUtil.isNotEmpty(bmQrBoxInfo.getStatusList())) { + if(bmQrBoxInfo.getStatusList().contains("2") && bmQrBoxInfo.getStatusList().contains("5")) { + // 将list中状态为2和5并且devNum大于0的数据过滤出来 + list = list.stream() + // 先判空list中的bmQrBoxInfo1和它的statusList,避免空指针 + .filter(bmQrBoxInfo1 -> bmQrBoxInfo1 != null + && bmQrBoxInfo1.getStatus() != null + && bmQrBoxInfo1.getDevNum() > 0) + .filter(bmQrBoxInfo1 -> "2".equals(bmQrBoxInfo1.getStatus()) + || "5".equals(bmQrBoxInfo1.getStatus())) + .collect(Collectors.toList()); + } + } + } + return list; } /** diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseApplyInfoServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseApplyInfoServiceImpl.java index 4c3b2a7f..507574e3 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseApplyInfoServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseApplyInfoServiceImpl.java @@ -1412,6 +1412,9 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService { } } if (leaseOutDetails.getManageType().equals(MaTypeManageTypeEnum.NUMBER_DEVICE.getTypeId())) { + if (leaseOutDetails.getInputNum().compareTo(BigDecimal.ZERO) <= 0) { + return AjaxResult.error("出库数量不能小于0"); + } // 查询待出库数量 LeaseApplyDetails info = new LeaseApplyDetails(); if (StringUtils.isNotBlank(leaseOutDetails.getPublishTask())) { From 1ac2534ff927b0ba28a4bf6625b772d7b7e82a3e Mon Sep 17 00:00:00 2001 From: syruan <15555146157@163.com> Date: Sat, 6 Sep 2025 18:34:32 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=B9=B6=E8=B0=83=E6=95=B4=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 删除了 CacheConfig 类和 RedisCacheConfig 类 - 移除了 ComplexQueryController 中的缓存相关注解 - 调整了 MaterialLeaseInfoServiceImpl 中的缓存相关方法,改为私有方法 - 重命名了 ProjUsingRecordExports 类,修正了包结构 - 优化了 PreventRepeatSubmitAspect 中的日志记录和错误处理 --- CacheConfig.java | 110 ------------------ .../controller/ComplexQueryController.java | 3 +- .../basic/domain/ProjUsingRecordExport.java | 3 +- .../{ => domain}/ProjUsingRecordExports.java | 5 +- .../impl/MaterialLeaseInfoServiceImpl.java | 14 +-- .../aspect/PreventRepeatSubmitAspect.java | 17 ++- 6 files changed, 17 insertions(+), 135 deletions(-) delete mode 100644 CacheConfig.java rename bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/{ => domain}/ProjUsingRecordExports.java (96%) diff --git a/CacheConfig.java b/CacheConfig.java deleted file mode 100644 index c3f8fd59..00000000 --- a/CacheConfig.java +++ /dev/null @@ -1,110 +0,0 @@ -package com.bonus.material.config; - -import org.springframework.cache.CacheManager; -import org.springframework.cache.annotation.EnableCaching; -import org.springframework.cache.concurrent.ConcurrentMapCacheManager; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.cache.interceptor.KeyGenerator; - -import java.lang.reflect.Method; -import java.util.Arrays; - -/** - * 缓存配置类 - * 为getUseTypeTree方法优化提供缓存支持 - */ -@Configuration -@EnableCaching -public class CacheConfig { - - /** - * 缓存管理器配置 - * 使用ConcurrentMapCacheManager作为简单的内存缓存 - * 生产环境建议使用Redis等分布式缓存 - */ - @Bean - public CacheManager cacheManager() { - ConcurrentMapCacheManager cacheManager = new ConcurrentMapCacheManager(); - - // 配置缓存名称 - cacheManager.setCacheNames(Arrays.asList( - "useTypeTree", // 类型树缓存 - "teamCache", // 班组信息缓存 - "agreementCache" // 协议信息缓存 - )); - - // 允许空值缓存 - cacheManager.setAllowNullValues(false); - - return cacheManager; - } - - /** - * 自定义键生成器 - * 用于生成更精确的缓存键 - */ - @Bean("customKeyGenerator") - public KeyGenerator keyGenerator() { - return new KeyGenerator() { - @Override - public Object generate(Object target, Method method, Object... params) { - StringBuilder sb = new StringBuilder(); - sb.append(target.getClass().getSimpleName()).append("."); - sb.append(method.getName()).append("("); - - for (int i = 0; i < params.length; i++) { - if (i > 0) { - sb.append(","); - } - if (params[i] != null) { - sb.append(params[i].toString()); - } else { - sb.append("null"); - } - } - sb.append(")"); - - return sb.toString(); - } - }; - } -} - -/** - * Redis缓存配置(可选) - * 如果需要使用Redis作为缓存,可以启用以下配置 - */ -/* -@Configuration -@EnableCaching -@ConditionalOnProperty(name = "spring.cache.type", havingValue = "redis") -public class RedisCacheConfig { - - @Bean - public RedisCacheManager cacheManager(RedisConnectionFactory connectionFactory) { - RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig() - .entryTtl(Duration.ofMinutes(30)) // 缓存30分钟过期 - .serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(new StringRedisSerializer())) - .serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(new GenericJackson2JsonRedisSerializer())) - .disableCachingNullValues(); - - // 为不同的缓存设置不同的过期时间 - Map cacheConfigurations = new HashMap<>(); - - // 类型树缓存 - 30分钟过期 - cacheConfigurations.put("useTypeTree", config.entryTtl(Duration.ofMinutes(30))); - - // 班组缓存 - 1小时过期 - cacheConfigurations.put("teamCache", config.entryTtl(Duration.ofHours(1))); - - // 协议缓存 - 15分钟过期 - cacheConfigurations.put("agreementCache", config.entryTtl(Duration.ofMinutes(15))); - - return RedisCacheManager.builder(connectionFactory) - .cacheDefaults(config) - .withInitialCacheConfigurations(cacheConfigurations) - .build(); - } -} -*/ diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/controller/ComplexQueryController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/controller/ComplexQueryController.java index 2377580b..d36020d8 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/controller/ComplexQueryController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/controller/ComplexQueryController.java @@ -9,12 +9,11 @@ import com.bonus.common.core.utils.poi.ExcelUtil; import com.bonus.common.core.web.controller.BaseController; import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.common.security.utils.SecurityUtils; -import com.bonus.material.basic.ProjUsingRecordExports; +import com.bonus.material.basic.domain.ProjUsingRecordExports; import com.bonus.material.basic.domain.*; import com.bonus.material.basic.domain.vo.MaTypeSelectInfo; import com.bonus.material.basic.service.ComplexQueryService; import com.bonus.material.ma.domain.Type; -import com.bonus.system.api.domain.SysUser; import com.bonus.system.api.model.LoginUser; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/domain/ProjUsingRecordExport.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/domain/ProjUsingRecordExport.java index bbd076d5..a1f39ed4 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/domain/ProjUsingRecordExport.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/domain/ProjUsingRecordExport.java @@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.io.Serializable; import java.math.BigDecimal; /** @@ -14,7 +15,7 @@ import java.math.BigDecimal; */ @ApiModel(description = "退料查询") @Data -public class ProjUsingRecordExport { +public class ProjUsingRecordExport implements Serializable { private static final long serialVersionUID = 2227217051604273598L; diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/ProjUsingRecordExports.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/domain/ProjUsingRecordExports.java similarity index 96% rename from bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/ProjUsingRecordExports.java rename to bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/domain/ProjUsingRecordExports.java index 031f6a19..73f40425 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/ProjUsingRecordExports.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/domain/ProjUsingRecordExports.java @@ -1,10 +1,11 @@ -package com.bonus.material.basic; +package com.bonus.material.basic.domain; import com.bonus.common.core.annotation.Excel; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.io.Serializable; import java.math.BigDecimal; /** @@ -14,7 +15,7 @@ import java.math.BigDecimal; */ @ApiModel(description = "退料查询") @Data -public class ProjUsingRecordExports { +public class ProjUsingRecordExports implements Serializable { private static final long serialVersionUID = 2227217051604273598L; diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialLeaseInfoServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialLeaseInfoServiceImpl.java index c85fde71..04f3b62b 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialLeaseInfoServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialLeaseInfoServiceImpl.java @@ -46,7 +46,6 @@ import com.bonus.material.task.domain.TmTaskAgreement; import com.bonus.material.task.mapper.TmTaskAgreementMapper; import com.bonus.material.task.mapper.TmTaskMapper; import lombok.extern.slf4j.Slf4j; -import org.springframework.cache.annotation.Cacheable; import org.springframework.dao.DataAccessException; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -1335,16 +1334,11 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService { /** * 材料站在库设备类型树(即机具在用设备) - * @param bean - * @return */ @Override - @Cacheable(value = "useTypeTree", key = "#bean.proId + '_' + #bean.teamName + '_' + (#bean.agreementIdList != null ? #bean.agreementIdList.toString() : 'null')", - unless = "#result == null || #result.data == null", condition = "#bean.proId != null") public AjaxResult getUseTypeTree(MaterialLeaseApplyInfo bean) { long startTime = System.currentTimeMillis(); - log.info("开始执行getUseTypeTree方法,参数:proId={}, teamName={}, agreementIdList={}", - bean.getProId(), bean.getTeamName(), bean.getAgreementIdList()); + log.info("开始执行getUseTypeTree方法,参数:proId={}, teamName={}, agreementIdList={}", bean.getProId(), bean.getTeamName(), bean.getAgreementIdList()); List groupList = new ArrayList<>(); List list = new ArrayList<>(); @@ -1507,8 +1501,7 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService { * @param teamName 班组名称 * @return 班组信息 */ - @Cacheable(value = "teamCache", key = "#teamName", unless = "#result == null") - public BmTeam getTeamByNameCached(String teamName) { + private BmTeam getTeamByNameCached(String teamName) { BmTeam bmTeam = new BmTeam(); bmTeam.setTeamName(teamName); return bmTeamMapper.selectByName(bmTeam); @@ -1519,8 +1512,7 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService { * @param bean 查询参数 * @return 协议信息 */ - @Cacheable(value = "agreementCache", key = "#bean.proId + '_' + #bean.teamId", unless = "#result == null") - public BmAgreementInfo getAgreementInfoCached(MaterialLeaseApplyInfo bean) { + private BmAgreementInfo getAgreementInfoCached(MaterialLeaseApplyInfo bean) { return materialLeaseInfoMapper.getAgreeId(bean); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/aspect/PreventRepeatSubmitAspect.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/aspect/PreventRepeatSubmitAspect.java index d00c80d3..941fac0a 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/aspect/PreventRepeatSubmitAspect.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/aspect/PreventRepeatSubmitAspect.java @@ -24,7 +24,7 @@ import java.util.concurrent.TimeUnit; @Aspect @Component public class PreventRepeatSubmitAspect { - private static final Logger LOG = LoggerFactory.getLogger(PreventRepeatSubmitAspect.class); + private static final Logger log = LoggerFactory.getLogger(PreventRepeatSubmitAspect.class); private static final String header = "Authorization"; @Autowired @@ -38,18 +38,17 @@ public class PreventRepeatSubmitAspect { @Around("preventRepeatSubmit()") public Object checkPrs(ProceedingJoinPoint pjp) throws Throwable { - LOG.info("进入preventRepeatSubmit切面"); + log.info("进入preventRepeatSubmit切面"); //得到request对象 - HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); String requestURI = request.getRequestURI(); - LOG.info("防重复提交的请求地址:{} ,请求方式:{}",requestURI,request.getMethod()); - LOG.info("防重复提交拦截到的类名:{} ,方法:{}",pjp.getTarget().getClass().getSimpleName(),pjp.getSignature().getName()); + log.info("防重复提交的请求地址:{} ,请求方式:{}",requestURI,request.getMethod()); + log.info("防重复提交拦截到的类名:{} ,方法:{}",pjp.getTarget().getClass().getSimpleName(),pjp.getSignature().getName()); //获取请求参数 Object[] args = pjp.getArgs(); String argStr = ""; - for (int i = 0; i < args.length; i++) { - Object obj = args[i]; + for (Object obj : args) { try { if (Objects.nonNull(obj)) { //这里替换是为了在redis可视化工具中方便查看, argStr=argStr.replace(":","#"); @@ -57,7 +56,7 @@ public class PreventRepeatSubmitAspect { } break; } catch (Exception e) { - e.printStackTrace(); + log.error("获取参数异常", e); } } @@ -69,7 +68,7 @@ public class PreventRepeatSubmitAspect { Method method=ms.getMethod(); PreventRepeatSubmit preventRepeatSubmit=method.getAnnotation(PreventRepeatSubmit.class); int interval = preventRepeatSubmit.interval(); - LOG.info("获取到preventRepeatSubmit的有效期时间"+interval); + log.info("获取到preventRepeatSubmit的有效期时间{}", interval); //redis分布式锁 Boolean aBoolean = redisCache.setNxCacheObject(cacheRepeatKey, 1, preventRepeatSubmit.interval(), TimeUnit.SECONDS); //aBoolean为true则证明没有重复提交 From c9eae46186792f13417dd0e1c93af0f1c3557db6 Mon Sep 17 00:00:00 2001 From: mashuai Date: Sat, 6 Sep 2025 19:37:17 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=8A=9F=E8=83=BD=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/bonus/material/basic/domain/BmQrBoxInfo.java | 3 +++ .../basic/service/impl/BmQrBoxServiceImpl.java | 11 +++++++---- .../resources/mapper/material/basic/BmQrBoxMapper.xml | 3 ++- .../mapper/material/lease/LeaseApplyDetailsMapper.xml | 3 ++- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/domain/BmQrBoxInfo.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/domain/BmQrBoxInfo.java index 94de4781..b2da0c07 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/domain/BmQrBoxInfo.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/domain/BmQrBoxInfo.java @@ -106,4 +106,7 @@ public class BmQrBoxInfo extends BaseEntity @ApiModelProperty(value = "任务ID") private String taskId; + @ApiModelProperty("机具类型(1机具,2安全工器具)") + private int jiJuType; + } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/service/impl/BmQrBoxServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/service/impl/BmQrBoxServiceImpl.java index 12951e84..d02ff041 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/service/impl/BmQrBoxServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/service/impl/BmQrBoxServiceImpl.java @@ -589,18 +589,21 @@ public class BmQrBoxServiceImpl implements BmQrBoxService { if (null == bmQrBoxInfo.getBoxCode() || null == bmQrBoxInfo.getMaTypeId()) { return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), "标准箱编码或机具类型id不能为空"); } - final List recordList = bmQrBoxMapper.getBoxBindListByCode(bmQrBoxInfo); + List recordList = new ArrayList<>(); + List list = bmQrBoxMapper.getBoxBindListByCode(bmQrBoxInfo); int num = 0; String msg; - if (CollectionUtil.isNotEmpty(recordList)) { - for (final BmQrBoxInfo qrBoxInfo : recordList) { + if (CollectionUtil.isNotEmpty(list)) { + for (BmQrBoxInfo qrBoxInfo : list) { if (qrBoxInfo.getMaStatus().equals(MaMachineStatusEnum.IN_STORE.getStatus().toString())) { + recordList.add(qrBoxInfo); num ++; } } - msg = "监测到" + bmQrBoxInfo.getBoxCode() + "标准箱中有" + recordList.size() + "台设备,符合出库条件设备" + num + "台,请确认是否出库!"; + msg = "监测到" + bmQrBoxInfo.getBoxCode() + "标准箱中有" + list.size() + "台设备,符合出库条件设备" + num + "台,请确认是否出库!"; } else { msg = "监测到" + bmQrBoxInfo.getBoxCode() + "标准箱中无符合出库条件的设备,请检查后重新提交!"; + recordList = new ArrayList<>(); } // 返回包含设备列表和消息的结果 final Map result = new HashMap<>(2); diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/basic/BmQrBoxMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/basic/BmQrBoxMapper.xml index 81d54d79..65da5e8e 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/basic/BmQrBoxMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/basic/BmQrBoxMapper.xml @@ -233,7 +233,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" mm.ma_id as maId, mm.ma_code as maCode, mm.type_id as maTypeId, - mm.ma_status as maStatus + mm.ma_status as maStatus, + mt.jiju_type as jijuType FROM bm_qrcode_box_bind qb LEFT JOIN ma_machine mm ON qb.ma_id = mm.ma_id LEFT JOIN ma_type mt ON mm.type_id = mt.type_id AND mt.del_flag = '0' diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseApplyDetailsMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseApplyDetailsMapper.xml index 27f61ca5..57d03124 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseApplyDetailsMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseApplyDetailsMapper.xml @@ -347,7 +347,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" case when mm.ma_status = '1' then '在库' else '' end as statusName, - mt.manage_type as manageType + mt.manage_type as manageType, + mt.jiju_type as jijuType FROM ma_machine mm LEFT JOIN ma_type mt ON mm.type_id = mt.type_id AND mt.del_flag = '0' LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id AND mt1.del_flag = '0'