This commit is contained in:
xd 2024-03-20 11:24:35 +08:00
parent cc20aa0d3f
commit a2e44acd72
4 changed files with 60 additions and 20 deletions

View File

@ -43,6 +43,7 @@ public class CacheController
caches.add(new SysCache(CacheConstants.RATE_LIMIT_KEY, "限流处理")); caches.add(new SysCache(CacheConstants.RATE_LIMIT_KEY, "限流处理"));
caches.add(new SysCache(CacheConstants.PWD_ERR_CNT_KEY, "密码错误次数")); caches.add(new SysCache(CacheConstants.PWD_ERR_CNT_KEY, "密码错误次数"));
caches.add(new SysCache(CacheConstants.STORAGE_LOCATION, "车间库位")); caches.add(new SysCache(CacheConstants.STORAGE_LOCATION, "车间库位"));
caches.add(new SysCache(CacheConstants.SYS_JOB_KEY, "定时任务"));
} }
@PreAuthorize("@ss.hasPermi('monitor:cache:list')") @PreAuthorize("@ss.hasPermi('monitor:cache:list')")

View File

@ -11,7 +11,6 @@ import com.ruoyi.common.core.redis.RedisLock;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.enums.DataSourceType; import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.ip.IpUtils;
import com.ruoyi.storageLocation.domain.Operlog; import com.ruoyi.storageLocation.domain.Operlog;
import com.ruoyi.storageLocation.domain.StorageLocation; import com.ruoyi.storageLocation.domain.StorageLocation;
import com.ruoyi.storageLocation.domain.StorageSelected; import com.ruoyi.storageLocation.domain.StorageSelected;
@ -19,10 +18,8 @@ import com.ruoyi.storageLocation.service.StorageLocationService;
import com.ruoyi.system.service.ISysConfigService; import com.ruoyi.system.service.ISysConfigService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit;
/** /**
* 库位管理Controller * 库位管理Controller
@ -207,7 +204,10 @@ public class storageLocationController extends BaseController
if(StringUtils.isNotNull(kw_user_name)&&!user_name.equals(kw_user_name)){ if(StringUtils.isNotNull(kw_user_name)&&!user_name.equals(kw_user_name)){
return error("当前库位有人正在操作,请勿操作!"); return error("当前库位有人正在操作,请勿操作!");
}else{ }else{
redisLock.getLock(getLocationZyCacheKey(materialBh), Integer.valueOf(storageExpire), user_name); Boolean lock= redisLock.getLock(getLocationZyCacheKey(materialBh), Integer.valueOf(storageExpire), user_name);
if(!lock){
return error("当前库位有人正在操作,请勿操作!");
}
//redisCache.setCacheObject(getLocationZyCacheKey(materialBh),user_name,Integer.valueOf(storageExpire), TimeUnit.SECONDS); //redisCache.setCacheObject(getLocationZyCacheKey(materialBh),user_name,Integer.valueOf(storageExpire), TimeUnit.SECONDS);
return success(); return success();
} }
@ -327,6 +327,8 @@ public class storageLocationController extends BaseController
Boolean lock = redisLock.getLock(getLocationLyCacheKey(materialBh), -1, user_name); Boolean lock = redisLock.getLock(getLocationLyCacheKey(materialBh), -1, user_name);
if(lock){ if(lock){
storageLocationService.saveStorageLocation(user_name,materialBh); storageLocationService.saveStorageLocation(user_name,materialBh);
}else{
return error("该库位当前有人正在领用操作,请勿操作!");
} }
} }
return success(); return success();

View File

@ -46,4 +46,9 @@ public class CacheConstants
* 一车间库位号占用状态 redis key * 一车间库位号占用状态 redis key
*/ */
public static final String STORAGE_LOCATION = "storage_location:"; public static final String STORAGE_LOCATION = "storage_location:";
/**
* 定时任务 redis key
*/
public static final String SYS_JOB_KEY = "sys_job:";
} }

View File

@ -1,12 +1,17 @@
package com.ruoyi.quartz.task; package com.ruoyi.quartz.task;
import com.ruoyi.common.annotation.DataSource; import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.constant.CacheConstants;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.core.redis.RedisLock;
import com.ruoyi.common.enums.DataSourceType; import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.quartz.domain.c_rb_product_price; import com.ruoyi.quartz.domain.c_rb_product_price;
import com.ruoyi.quartz.domain.c_rb_productbase_price; import com.ruoyi.quartz.domain.c_rb_productbase_price;
import com.ruoyi.quartz.service.SapTjService; import com.ruoyi.quartz.service.SapTjService;
import com.ruoyi.quartz.util.JDBCBatchInsert; import com.ruoyi.quartz.util.JDBCBatchInsert;
import org.quartz.Scheduler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -24,6 +29,15 @@ import java.util.List;
@Component("rbTask") @Component("rbTask")
public class RbTask public class RbTask
{ {
@Autowired
private RedisCache redisCache;
@Autowired
private RedisLock redisLock;
@Autowired
private Scheduler scheduler;
@Resource @Resource
private SapTjService sapTjService; private SapTjService sapTjService;
@ -38,8 +52,12 @@ public class RbTask
* 同步红本数据库 * 同步红本数据库
*/ */
public void tongb() throws Exception { public void tongb() throws Exception {
//判断是否已执行调价 6.3 redbook rb_productVersion 是否有新增uid and sta='1'sdmdm1 调价日期今日的数据是否存在
String jobId = scheduler.getSchedulerInstanceId();
String rbVersionUid = testUtils.sapTjService.selRbVersionUid();//红本调价记录uid String rbVersionUid = testUtils.sapTjService.selRbVersionUid();//红本调价记录uid
Boolean lock= redisLock.getLock(getJobKey(jobId), -1, rbVersionUid);
if(lock){
//判断是否已执行调价 6.3 redbook rb_productVersion 是否有新增uid and sta='1'sdmdm1 调价日期今日的数据是否存在
String locVersionUid = testUtils.sapTjService.selLocVersionUid();//本地红本调价记录uid String locVersionUid = testUtils.sapTjService.selLocVersionUid();//本地红本调价记录uid
String RbProductPriceCount = testUtils.sapTjService.selRbProductPriceVersionUid(rbVersionUid);//RbProductPrice表是否有更新 String RbProductPriceCount = testUtils.sapTjService.selRbProductPriceVersionUid(rbVersionUid);//RbProductPrice表是否有更新
@ -57,9 +75,23 @@ public class RbTask
JDBCBatchInsert.insertRbProductBasePrice(productBasePriceList);//批量插入 JDBCBatchInsert.insertRbProductBasePrice(productBasePriceList);//批量插入
testUtils.sapTjService.updateLocRbVersion(rbVersionUid);//更新本地c_rb_version表 testUtils.sapTjService.updateLocRbVersion(rbVersionUid);//更新本地c_rb_version表
redisCache.deleteObject(getJobKey(jobId));
} }
}catch (Exception e) { }catch (Exception e) {
throw new Exception(e.getMessage(), e); throw new Exception(e.getMessage(), e);
} }
} }
}
/**
* 定时任务缓存键名
*
* @param jobId 任务编号
* @return 缓存键key
*/
private String getJobKey(String jobId)
{
return CacheConstants.SYS_JOB_KEY + jobId;
}
} }