This commit is contained in:
hongchao 2025-09-08 10:08:16 +08:00
commit fa79b4467e
11 changed files with 51 additions and 142 deletions

View File

@ -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<String, RedisCacheConfiguration> 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();
}
}
*/

View File

@ -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.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.security.utils.SecurityUtils; 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.*;
import com.bonus.material.basic.domain.vo.MaTypeSelectInfo; import com.bonus.material.basic.domain.vo.MaTypeSelectInfo;
import com.bonus.material.basic.service.ComplexQueryService; import com.bonus.material.basic.service.ComplexQueryService;
import com.bonus.material.ma.domain.Type; import com.bonus.material.ma.domain.Type;
import com.bonus.system.api.domain.SysUser;
import com.bonus.system.api.model.LoginUser; import com.bonus.system.api.model.LoginUser;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;

View File

@ -106,4 +106,7 @@ public class BmQrBoxInfo extends BaseEntity
@ApiModelProperty(value = "任务ID") @ApiModelProperty(value = "任务ID")
private String taskId; private String taskId;
@ApiModelProperty("机具类型1机具2安全工器具")
private int jiJuType;
} }

View File

@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
/** /**
@ -14,7 +15,7 @@ import java.math.BigDecimal;
*/ */
@ApiModel(description = "退料查询") @ApiModel(description = "退料查询")
@Data @Data
public class ProjUsingRecordExport { public class ProjUsingRecordExport implements Serializable {
private static final long serialVersionUID = 2227217051604273598L; private static final long serialVersionUID = 2227217051604273598L;

View File

@ -1,10 +1,11 @@
package com.bonus.material.basic; package com.bonus.material.basic.domain;
import com.bonus.common.core.annotation.Excel; import com.bonus.common.core.annotation.Excel;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
/** /**
@ -14,7 +15,7 @@ import java.math.BigDecimal;
*/ */
@ApiModel(description = "退料查询") @ApiModel(description = "退料查询")
@Data @Data
public class ProjUsingRecordExports { public class ProjUsingRecordExports implements Serializable {
private static final long serialVersionUID = 2227217051604273598L; private static final long serialVersionUID = 2227217051604273598L;

View File

@ -83,7 +83,23 @@ public class BmQrBoxServiceImpl implements BmQrBoxService {
if (null != bmQrBoxInfo.getStatus()) { if (null != bmQrBoxInfo.getStatus()) {
bmQrBoxInfo.setStatusList(Arrays.asList(bmQrBoxInfo.getStatus().split(","))); bmQrBoxInfo.setStatusList(Arrays.asList(bmQrBoxInfo.getStatus().split(",")));
} }
return bmQrBoxMapper.find(bmQrBoxInfo); List<BmQrBoxInfo> 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;
} }
/** /**
@ -573,18 +589,21 @@ public class BmQrBoxServiceImpl implements BmQrBoxService {
if (null == bmQrBoxInfo.getBoxCode() || null == bmQrBoxInfo.getMaTypeId()) { if (null == bmQrBoxInfo.getBoxCode() || null == bmQrBoxInfo.getMaTypeId()) {
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), "标准箱编码或机具类型id不能为空"); return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), "标准箱编码或机具类型id不能为空");
} }
final List<BmQrBoxInfo> recordList = bmQrBoxMapper.getBoxBindListByCode(bmQrBoxInfo); List<BmQrBoxInfo> recordList = new ArrayList<>();
List<BmQrBoxInfo> list = bmQrBoxMapper.getBoxBindListByCode(bmQrBoxInfo);
int num = 0; int num = 0;
String msg; String msg;
if (CollectionUtil.isNotEmpty(recordList)) { if (CollectionUtil.isNotEmpty(list)) {
for (final BmQrBoxInfo qrBoxInfo : recordList) { for (BmQrBoxInfo qrBoxInfo : list) {
if (qrBoxInfo.getMaStatus().equals(MaMachineStatusEnum.IN_STORE.getStatus().toString())) { if (qrBoxInfo.getMaStatus().equals(MaMachineStatusEnum.IN_STORE.getStatus().toString())) {
recordList.add(qrBoxInfo);
num ++; num ++;
} }
} }
msg = "监测到" + bmQrBoxInfo.getBoxCode() + "标准箱中有" + recordList.size() + "台设备,符合出库条件设备" + num + "台,请确认是否出库!"; msg = "监测到" + bmQrBoxInfo.getBoxCode() + "标准箱中有" + list.size() + "台设备,符合出库条件设备" + num + "台,请确认是否出库!";
} else { } else {
msg = "监测到" + bmQrBoxInfo.getBoxCode() + "标准箱中无符合出库条件的设备,请检查后重新提交!"; msg = "监测到" + bmQrBoxInfo.getBoxCode() + "标准箱中无符合出库条件的设备,请检查后重新提交!";
recordList = new ArrayList<>();
} }
// 返回包含设备列表和消息的结果 // 返回包含设备列表和消息的结果
final Map<String, Object> result = new HashMap<>(2); final Map<String, Object> result = new HashMap<>(2);

View File

@ -46,7 +46,6 @@ import com.bonus.material.task.domain.TmTaskAgreement;
import com.bonus.material.task.mapper.TmTaskAgreementMapper; import com.bonus.material.task.mapper.TmTaskAgreementMapper;
import com.bonus.material.task.mapper.TmTaskMapper; import com.bonus.material.task.mapper.TmTaskMapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.dao.DataAccessException; import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -1335,16 +1334,11 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService {
/** /**
* 材料站在库设备类型树(即机具在用设备) * 材料站在库设备类型树(即机具在用设备)
* @param bean
* @return
*/ */
@Override @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) { public AjaxResult getUseTypeTree(MaterialLeaseApplyInfo bean) {
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
log.info("开始执行getUseTypeTree方法参数proId={}, teamName={}, agreementIdList={}", log.info("开始执行getUseTypeTree方法参数proId={}, teamName={}, agreementIdList={}", bean.getProId(), bean.getTeamName(), bean.getAgreementIdList());
bean.getProId(), bean.getTeamName(), bean.getAgreementIdList());
List<TypeTreeNode> groupList = new ArrayList<>(); List<TypeTreeNode> groupList = new ArrayList<>();
List<TypeTreeNode> list = new ArrayList<>(); List<TypeTreeNode> list = new ArrayList<>();
@ -1507,8 +1501,7 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService {
* @param teamName 班组名称 * @param teamName 班组名称
* @return 班组信息 * @return 班组信息
*/ */
@Cacheable(value = "teamCache", key = "#teamName", unless = "#result == null") private BmTeam getTeamByNameCached(String teamName) {
public BmTeam getTeamByNameCached(String teamName) {
BmTeam bmTeam = new BmTeam(); BmTeam bmTeam = new BmTeam();
bmTeam.setTeamName(teamName); bmTeam.setTeamName(teamName);
return bmTeamMapper.selectByName(bmTeam); return bmTeamMapper.selectByName(bmTeam);
@ -1519,8 +1512,7 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService {
* @param bean 查询参数 * @param bean 查询参数
* @return 协议信息 * @return 协议信息
*/ */
@Cacheable(value = "agreementCache", key = "#bean.proId + '_' + #bean.teamId", unless = "#result == null") private BmAgreementInfo getAgreementInfoCached(MaterialLeaseApplyInfo bean) {
public BmAgreementInfo getAgreementInfoCached(MaterialLeaseApplyInfo bean) {
return materialLeaseInfoMapper.getAgreeId(bean); return materialLeaseInfoMapper.getAgreeId(bean);
} }

View File

@ -24,7 +24,7 @@ import java.util.concurrent.TimeUnit;
@Aspect @Aspect
@Component @Component
public class PreventRepeatSubmitAspect { 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"; private static final String header = "Authorization";
@Autowired @Autowired
@ -38,18 +38,17 @@ public class PreventRepeatSubmitAspect {
@Around("preventRepeatSubmit()") @Around("preventRepeatSubmit()")
public Object checkPrs(ProceedingJoinPoint pjp) throws Throwable { public Object checkPrs(ProceedingJoinPoint pjp) throws Throwable {
LOG.info("进入preventRepeatSubmit切面"); log.info("进入preventRepeatSubmit切面");
//得到request对象 //得到request对象
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
String requestURI = request.getRequestURI(); String requestURI = request.getRequestURI();
LOG.info("防重复提交的请求地址:{} ,请求方式:{}",requestURI,request.getMethod()); log.info("防重复提交的请求地址:{} ,请求方式:{}",requestURI,request.getMethod());
LOG.info("防重复提交拦截到的类名:{} ,方法:{}",pjp.getTarget().getClass().getSimpleName(),pjp.getSignature().getName()); log.info("防重复提交拦截到的类名:{} ,方法:{}",pjp.getTarget().getClass().getSimpleName(),pjp.getSignature().getName());
//获取请求参数 //获取请求参数
Object[] args = pjp.getArgs(); Object[] args = pjp.getArgs();
String argStr = ""; String argStr = "";
for (int i = 0; i < args.length; i++) { for (Object obj : args) {
Object obj = args[i];
try { try {
if (Objects.nonNull(obj)) { if (Objects.nonNull(obj)) {
//这里替换是为了在redis可视化工具中方便查看, argStr=argStr.replace(":","#"); //这里替换是为了在redis可视化工具中方便查看, argStr=argStr.replace(":","#");
@ -57,7 +56,7 @@ public class PreventRepeatSubmitAspect {
} }
break; break;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); log.error("获取参数异常", e);
} }
} }
@ -69,7 +68,7 @@ public class PreventRepeatSubmitAspect {
Method method=ms.getMethod(); Method method=ms.getMethod();
PreventRepeatSubmit preventRepeatSubmit=method.getAnnotation(PreventRepeatSubmit.class); PreventRepeatSubmit preventRepeatSubmit=method.getAnnotation(PreventRepeatSubmit.class);
int interval = preventRepeatSubmit.interval(); int interval = preventRepeatSubmit.interval();
LOG.info("获取到preventRepeatSubmit的有效期时间"+interval); log.info("获取到preventRepeatSubmit的有效期时间{}", interval);
//redis分布式锁 //redis分布式锁
Boolean aBoolean = redisCache.setNxCacheObject(cacheRepeatKey, 1, preventRepeatSubmit.interval(), TimeUnit.SECONDS); Boolean aBoolean = redisCache.setNxCacheObject(cacheRepeatKey, 1, preventRepeatSubmit.interval(), TimeUnit.SECONDS);
//aBoolean为true则证明没有重复提交 //aBoolean为true则证明没有重复提交

View File

@ -1412,6 +1412,9 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
} }
} }
if (leaseOutDetails.getManageType().equals(MaTypeManageTypeEnum.NUMBER_DEVICE.getTypeId())) { if (leaseOutDetails.getManageType().equals(MaTypeManageTypeEnum.NUMBER_DEVICE.getTypeId())) {
if (leaseOutDetails.getInputNum().compareTo(BigDecimal.ZERO) <= 0) {
return AjaxResult.error("出库数量不能小于0");
}
// 查询待出库数量 // 查询待出库数量
LeaseApplyDetails info = new LeaseApplyDetails(); LeaseApplyDetails info = new LeaseApplyDetails();
if (StringUtils.isNotBlank(leaseOutDetails.getPublishTask())) { if (StringUtils.isNotBlank(leaseOutDetails.getPublishTask())) {

View File

@ -234,7 +234,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
mm.ma_id as maId, mm.ma_id as maId,
mm.ma_code as maCode, mm.ma_code as maCode,
mm.type_id as maTypeId, 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 FROM bm_qrcode_box_bind qb
LEFT JOIN ma_machine mm ON qb.ma_id = mm.ma_id 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' LEFT JOIN ma_type mt ON mm.type_id = mt.type_id AND mt.del_flag = '0'

View File

@ -347,7 +347,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
case when mm.ma_status = '1' then '在库' case when mm.ma_status = '1' then '在库'
else '' else ''
end as statusName, end as statusName,
mt.manage_type as manageType mt.manage_type as manageType,
mt.jiju_type as jijuType
FROM ma_machine mm 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 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' LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id AND mt1.del_flag = '0'