From ac45215146e554a21545ce2a67d9a71e79a5b720 Mon Sep 17 00:00:00 2001 From: xd <844539747@qq.com> Date: Fri, 15 Mar 2024 09:05:05 +0800 Subject: [PATCH] =?UTF-8?q?'=E8=BD=A6=E9=97=B4=E5=BA=93=E4=BD=8D=E7=AE=A1?= =?UTF-8?q?=E7=90=86'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/monitor/CacheController.java | 3 +- .../storageLocationController.java | 131 +++++++ .../src/main/resources/application-druid.yml | 9 + .../ruoyi/common/constant/CacheConstants.java | 7 +- .../ruoyi/common/enums/DataSourceType.java | 7 +- .../ruoyi/framework/config/DruidConfig.java | 10 + .../domain/StorageLocation.java | 69 ++++ .../mapper/StorageLocationMapper.java | 31 ++ .../service/StorageLocationService.java | 32 ++ .../impl/StorageLocationServiceImpl.java | 50 +++ .../storageLocation/StorageLocationMapper.xml | 41 +++ .../api/storageLocation/storageLocation.js | 37 ++ .../src/views/storageLocation/locationSet.vue | 328 +++++++++++++++--- 13 files changed, 696 insertions(+), 59 deletions(-) create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/web/controller/storageLocation/storageLocationController.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/storageLocation/domain/StorageLocation.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/storageLocation/mapper/StorageLocationMapper.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/storageLocation/service/StorageLocationService.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/storageLocation/service/impl/StorageLocationServiceImpl.java create mode 100644 ruoyi-system/src/main/resources/mapper/storageLocation/StorageLocationMapper.xml create mode 100644 ruoyi-ui/src/api/storageLocation/storageLocation.js diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/CacheController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/CacheController.java index 69470d0..7ece41e 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/CacheController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/CacheController.java @@ -23,7 +23,7 @@ import com.ruoyi.system.domain.SysCache; /** * 缓存监控 - * + * * @author ruoyi */ @RestController @@ -42,6 +42,7 @@ public class CacheController caches.add(new SysCache(CacheConstants.REPEAT_SUBMIT_KEY, "防重提交")); caches.add(new SysCache(CacheConstants.RATE_LIMIT_KEY, "限流处理")); caches.add(new SysCache(CacheConstants.PWD_ERR_CNT_KEY, "密码错误次数")); + caches.add(new SysCache(CacheConstants.STORAGE_LOCATION, "车间库位号占用状态")); } @PreAuthorize("@ss.hasPermi('monitor:cache:list')") diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/storageLocation/storageLocationController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/storageLocation/storageLocationController.java new file mode 100644 index 0000000..b38976d --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/storageLocation/storageLocationController.java @@ -0,0 +1,131 @@ +package com.ruoyi.web.controller.storageLocation; + +import com.ruoyi.clMaterial.domain.CYlMaterial; +import com.ruoyi.common.annotation.DataSource; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.constant.CacheConstants; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.redis.RedisCache; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.enums.DataSourceType; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.storageLocation.domain.StorageLocation; +import com.ruoyi.storageLocation.service.StorageLocationService; +import com.ruoyi.system.service.ISysConfigService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.concurrent.TimeUnit; + +/** + * 库位管理Controller + */ +@RestController +@RequestMapping("/storageLocation/storageLocation") +@DataSource(DataSourceType.STORAGE) +public class storageLocationController extends BaseController +{ + + @Autowired + private RedisCache redisCache; + + @Autowired + private StorageLocationService storageLocationService; + + @Autowired + private ISysConfigService configService; + + /** + * 获取库位信息 + */ + @GetMapping("/list") + public AjaxResult list(StorageLocation storageLocation) + { + AjaxResult ajaxResult = new AjaxResult(); + List listA = storageLocationService.selectStorageLocationAList(storageLocation); + List listB = storageLocationService.selectStorageLocationBList(storageLocation); + List listC = storageLocationService.selectStorageLocationCList(storageLocation); + + ajaxResult.put("materialDetailA",listA); + ajaxResult.put("materialDetailB",listB); + ajaxResult.put("materialDetailC",listC); + return ajaxResult; + } + + /** + * 录入库位信息 + */ + @Log(title = "录入库位信息", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody StorageLocation storageLocation) + { + String user_name = getLoginUser().getUsername();//当前登陆者 + String materialBh = storageLocation.getMaterialBh(); + + String kw_user_name = redisCache.getCacheObject(getCacheKey(materialBh)); + if(StringUtils.isNull(kw_user_name)){ + return error("已超过有效录入信息时间,请关闭重新录入!"); + }else if(!user_name.equals(kw_user_name)){ + return error("已超过有效录入信息时间,当前库位有人正在操作!"); + }else{ + redisCache.setCacheObject(getCacheKey(materialBh),user_name); + return toAjax(storageLocationService.addStorageLocation(storageLocation)); + } + + } + + /** + * 校验库位是否已占用 + */ + @Log(title = "校验库位是否已占用", businessType = BusinessType.OTHER) + @PostMapping("/checkStorageLocation") + public AjaxResult checkStorageLocation(@RequestBody StorageLocation storageLocation) + { + String storageExpire = configService.selectConfigByKey("storage.expire"); + + String user_name = getLoginUser().getUsername();//当前登陆者 + String materialBh = storageLocation.getMaterialBh(); + + String kw_user_name = redisCache.getCacheObject(getCacheKey(materialBh)); + if(StringUtils.isNotNull(kw_user_name)&&!user_name.equals(kw_user_name)){ + return error("当前库位有人正在操作,请勿操作!"); + }else{ + redisCache.setCacheObject(getCacheKey(materialBh),user_name,Integer.valueOf(storageExpire), TimeUnit.SECONDS); + return success(); + } + } + + /** + * 弹窗取消按钮 清除库位缓存 + */ + @Log(title = "校验库位是否已占用", businessType = BusinessType.OTHER) + @PostMapping("/cancelStorageLocation") + public AjaxResult cancelStorageLocation(@RequestBody StorageLocation storageLocation) + { + String storageExpire = configService.selectConfigByKey("storage.expire"); + + String user_name = getLoginUser().getUsername();//当前登陆者 + String materialBh = storageLocation.getMaterialBh(); + + String kw_user_name = redisCache.getCacheObject(getCacheKey(materialBh)); + if(StringUtils.isNotNull(kw_user_name)&&user_name.equals(kw_user_name)){ + redisCache.deleteObject(getCacheKey(materialBh)); + } + return success(); + } + + /** + * 库位缓存键名 + * + * @param materialBh 库位号 + * @return 缓存键key + */ + private String getCacheKey(String materialBh) + { + return CacheConstants.STORAGE_LOCATION + materialBh; + } + +} diff --git a/ruoyi-admin/src/main/resources/application-druid.yml b/ruoyi-admin/src/main/resources/application-druid.yml index ccbd973..dd7b311 100644 --- a/ruoyi-admin/src/main/resources/application-druid.yml +++ b/ruoyi-admin/src/main/resources/application-druid.yml @@ -36,6 +36,15 @@ spring: url: jdbc:sqlserver://192.168.9.2:1433;DatabaseName=jn_erp username: sa password: it12345 + # 车间库位管理数据库数据源 + storage: + # 从数据源开关/默认关闭 + enabled: true + driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver + # 正式数据库 + url: jdbc:sqlserver://192.168.9.99:1433;DatabaseName=jn_storage + username: sa + password: Itcenter110- # 初始连接数 initialSize: 10 # 最小连接池数量 diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/constant/CacheConstants.java b/ruoyi-common/src/main/java/com/ruoyi/common/constant/CacheConstants.java index 0080343..34e5e2a 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/constant/CacheConstants.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/constant/CacheConstants.java @@ -2,7 +2,7 @@ package com.ruoyi.common.constant; /** * 缓存的key 常量 - * + * * @author ruoyi */ public class CacheConstants @@ -41,4 +41,9 @@ public class CacheConstants * 登录账户密码错误次数 redis key */ public static final String PWD_ERR_CNT_KEY = "pwd_err_cnt:"; + + /** + * 一车间库位号占用状态 redis key + */ + public static final String STORAGE_LOCATION = "storage_location:"; } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/enums/DataSourceType.java b/ruoyi-common/src/main/java/com/ruoyi/common/enums/DataSourceType.java index c4c19ce..2d9e661 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/enums/DataSourceType.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/enums/DataSourceType.java @@ -25,6 +25,11 @@ public enum DataSourceType /** * 江南ERP数据库 */ - JNERP + JNERP, + + /** + * 车间库位管理数据库 + */ + STORAGE } diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/DruidConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/DruidConfig.java index 1fdc2f8..38833e7 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/DruidConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/DruidConfig.java @@ -67,6 +67,15 @@ public class DruidConfig return druidProperties.dataSource(dataSource); } + @Bean + @ConfigurationProperties("spring.datasource.druid.storage") + @ConditionalOnProperty(prefix = "spring.datasource.druid.storage", name = "enabled", havingValue = "true") + public DataSource storageDataSource(DruidProperties druidProperties) + { + DruidDataSource dataSource = DruidDataSourceBuilder.create().build(); + return druidProperties.dataSource(dataSource); + } + @Bean(name = "dynamicDataSource") @Primary public DynamicDataSource dataSource(DataSource masterDataSource) @@ -76,6 +85,7 @@ public class DruidConfig setDataSource(targetDataSources, DataSourceType.REDBOOK.name(), "redbookDataSource"); setDataSource(targetDataSources, DataSourceType.QUOT.name(), "quotDataSource"); setDataSource(targetDataSources, DataSourceType.JNERP.name(), "jnerpDataSource"); + setDataSource(targetDataSources, DataSourceType.STORAGE.name(), "storageDataSource"); return new DynamicDataSource(masterDataSource, targetDataSources); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/storageLocation/domain/StorageLocation.java b/ruoyi-system/src/main/java/com/ruoyi/storageLocation/domain/StorageLocation.java new file mode 100644 index 0000000..feb518d --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/storageLocation/domain/StorageLocation.java @@ -0,0 +1,69 @@ +package com.ruoyi.storageLocation.domain; + +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 库位管理对象 StorageLocation + * + * @author ruoyi + * @date 2024-02-28 + */ +public class StorageLocation extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + private String materialBh; + private String materialXingh; + private String materialGuig; + private String materialDiany; + private String materialMs; + private String materialState; + + public String getMaterialBh() { + return materialBh; + } + + public void setMaterialBh(String materialBh) { + this.materialBh = materialBh; + } + + public String getMaterialXingh() { + return materialXingh; + } + + public void setMaterialXingh(String materialXingh) { + this.materialXingh = materialXingh; + } + + public String getMaterialGuig() { + return materialGuig; + } + + public void setMaterialGuig(String materialGuig) { + this.materialGuig = materialGuig; + } + + public String getMaterialDiany() { + return materialDiany; + } + + public void setMaterialDiany(String materialDiany) { + this.materialDiany = materialDiany; + } + + public String getMaterialMs() { + return materialMs; + } + + public void setMaterialMs(String materialMs) { + this.materialMs = materialMs; + } + + public String getMaterialState() { + return materialState; + } + + public void setMaterialState(String materialState) { + this.materialState = materialState; + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/storageLocation/mapper/StorageLocationMapper.java b/ruoyi-system/src/main/java/com/ruoyi/storageLocation/mapper/StorageLocationMapper.java new file mode 100644 index 0000000..85b3ae5 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/storageLocation/mapper/StorageLocationMapper.java @@ -0,0 +1,31 @@ +package com.ruoyi.storageLocation.mapper; + +import com.ruoyi.storageLocation.domain.StorageLocation; + +import java.util.List; + +/** + * 库位管理Mapper接口 + * + * @author ruoyi + * @date 2024-02-28 + */ +public interface StorageLocationMapper +{ + + /** + * 获取库位信息 + * @param storageLocation + * @return + */ + List selectStorageLocationAList(StorageLocation storageLocation); + List selectStorageLocationBList(StorageLocation storageLocation); + List selectStorageLocationCList(StorageLocation storageLocation); + + /** + * 录入库位信息 + * @param storageLocation + * @return + */ + int addStorageLocation(StorageLocation storageLocation); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/storageLocation/service/StorageLocationService.java b/ruoyi-system/src/main/java/com/ruoyi/storageLocation/service/StorageLocationService.java new file mode 100644 index 0000000..4757a27 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/storageLocation/service/StorageLocationService.java @@ -0,0 +1,32 @@ +package com.ruoyi.storageLocation.service; + +import com.ruoyi.clMaterial.domain.CYlMaterial; +import com.ruoyi.storageLocation.domain.StorageLocation; + +import java.util.List; + +/** + * 库位管理Service接口 + * + * @author ruoyi + * @date 2024-02-28 + */ +public interface StorageLocationService +{ + + /** + * 获取库位信息 + * @param storageLocation + * @return + */ + List selectStorageLocationAList(StorageLocation storageLocation); + List selectStorageLocationBList(StorageLocation storageLocation); + List selectStorageLocationCList(StorageLocation storageLocation); + + /** + * 录入库位信息 + * @param storageLocation + * @return + */ + int addStorageLocation(StorageLocation storageLocation); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/storageLocation/service/impl/StorageLocationServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/storageLocation/service/impl/StorageLocationServiceImpl.java new file mode 100644 index 0000000..96a274a --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/storageLocation/service/impl/StorageLocationServiceImpl.java @@ -0,0 +1,50 @@ +package com.ruoyi.storageLocation.service.impl; + +import com.ruoyi.storageLocation.domain.StorageLocation; +import com.ruoyi.storageLocation.mapper.StorageLocationMapper; +import com.ruoyi.storageLocation.service.StorageLocationService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 库位管理Service业务层处理 + * + * @author ruoyi + * @date 2024-02-28 + */ +@Service +public class StorageLocationServiceImpl implements StorageLocationService +{ + @Autowired + private StorageLocationMapper storageLocationMapper; + + /** + * 获取库位信息 + * @param storageLocation + * @return + */ + @Override + public List selectStorageLocationAList(StorageLocation storageLocation) { + return storageLocationMapper.selectStorageLocationAList(storageLocation); + } + @Override + public List selectStorageLocationBList(StorageLocation storageLocation) { + return storageLocationMapper.selectStorageLocationBList(storageLocation); + } + @Override + public List selectStorageLocationCList(StorageLocation storageLocation) { + return storageLocationMapper.selectStorageLocationCList(storageLocation); + } + + /** + * 录入库位信息 + * @param storageLocation + * @return + */ + @Override + public int addStorageLocation(StorageLocation storageLocation) { + return storageLocationMapper.addStorageLocation(storageLocation); + } +} diff --git a/ruoyi-system/src/main/resources/mapper/storageLocation/StorageLocationMapper.xml b/ruoyi-system/src/main/resources/mapper/storageLocation/StorageLocationMapper.xml new file mode 100644 index 0000000..da40667 --- /dev/null +++ b/ruoyi-system/src/main/resources/mapper/storageLocation/StorageLocationMapper.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + update storageLocation + + materialXingh = #{materialXingh}, + materialGuig = #{materialGuig}, + materialDiany = #{materialDiany}, + materialMs = #{materialMs}, + materialState = '1' + + where materialBh = #{materialBh} + + + diff --git a/ruoyi-ui/src/api/storageLocation/storageLocation.js b/ruoyi-ui/src/api/storageLocation/storageLocation.js new file mode 100644 index 0000000..61fd134 --- /dev/null +++ b/ruoyi-ui/src/api/storageLocation/storageLocation.js @@ -0,0 +1,37 @@ +import request from '@/utils/request' + +// 获取库位信息 +export function listStorageLocation(query) { + return request({ + url: '/storageLocation/storageLocation/list', + method: 'get', + params: query + }) +} + +// 录入库位信息 +export function addStorageLocation(data) { + return request({ + url: '/storageLocation/storageLocation', + method: 'post', + data: data + }) +} + +// 校验库位是否已占用 +export function checkStorageLocation(data) { + return request({ + url: '/storageLocation/storageLocation/checkStorageLocation', + method: 'post', + data: data + }) +} + +// 弹窗取消按钮 清除库位缓存 +export function cancelStorageLocation(data) { + return request({ + url: '/storageLocation/storageLocation/cancelStorageLocation', + method: 'post', + data: data + }) +} diff --git a/ruoyi-ui/src/views/storageLocation/locationSet.vue b/ruoyi-ui/src/views/storageLocation/locationSet.vue index 62c4fc5..ef533a3 100644 --- a/ruoyi-ui/src/views/storageLocation/locationSet.vue +++ b/ruoyi-ui/src/views/storageLocation/locationSet.vue @@ -1,23 +1,37 @@