Merge branch 'master' of http://14.103.246.124:16000/bonus/Bonus-Cloud-Material
This commit is contained in:
commit
fa79b4467e
110
CacheConfig.java
110
CacheConfig.java
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -106,4 +106,7 @@ public class BmQrBoxInfo extends BaseEntity
|
|||
@ApiModelProperty(value = "任务ID")
|
||||
private String taskId;
|
||||
|
||||
@ApiModelProperty("机具类型(1机具,2安全工器具)")
|
||||
private int jiJuType;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
@ -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<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()) {
|
||||
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;
|
||||
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<String, Object> result = new HashMap<>(2);
|
||||
|
|
|
|||
|
|
@ -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<TypeTreeNode> groupList = new ArrayList<>();
|
||||
List<TypeTreeNode> 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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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则证明没有重复提交
|
||||
|
|
|
|||
|
|
@ -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())) {
|
||||
|
|
|
|||
|
|
@ -234,7 +234,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'
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
|
|
|
|||
Loading…
Reference in New Issue