'20240315'

This commit is contained in:
xd 2024-03-15 15:41:34 +08:00
parent 0b18a6f546
commit 09d6670b8e
10 changed files with 496 additions and 48 deletions

View File

@ -42,7 +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, "车间库位号占用状态"));
caches.add(new SysCache(CacheConstants.STORAGE_LOCATION, "车间库位"));
}
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")

View File

@ -38,13 +38,15 @@ public class storageLocationController extends BaseController
@Autowired
private ISysConfigService configService;
/*===========================================库位设置==========================================================*/
/**
* 获取库位信息
* 获取库位占用信息
*/
@GetMapping("/list")
public AjaxResult list(StorageLocation storageLocation)
{
AjaxResult ajaxResult = new AjaxResult();
String user_name = getLoginUser().getUsername();//当前登陆者
List<StorageLocation> listA = storageLocationService.selectStorageLocationAList(storageLocation);
List<StorageLocation> listB = storageLocationService.selectStorageLocationBList(storageLocation);
List<StorageLocation> listC = storageLocationService.selectStorageLocationCList(storageLocation);
@ -52,6 +54,38 @@ public class storageLocationController extends BaseController
ajaxResult.put("materialDetailA",listA);
ajaxResult.put("materialDetailB",listB);
ajaxResult.put("materialDetailC",listC);
//根据库位状态 同步更新库位占用缓存-刷新页面时用
for(StorageLocation sl:listA){
String materialBh = sl.getMaterialBh();
String materialState = sl.getMaterialState();
String kw_user_name = redisCache.getCacheObject(getLocationZyCacheKey(materialBh));
if("0".equals(materialState)){
if(StringUtils.isNotNull(kw_user_name)&&user_name.equals(kw_user_name)){
redisCache.deleteObject(getLocationZyCacheKey(materialBh));
}
}
}
for(StorageLocation sl:listB){
String materialBh = sl.getMaterialBh();
String materialState = sl.getMaterialState();
String kw_user_name = redisCache.getCacheObject(getLocationZyCacheKey(materialBh));
if("0".equals(materialState)){
if(StringUtils.isNotNull(kw_user_name)&&user_name.equals(kw_user_name)){
redisCache.deleteObject(getLocationZyCacheKey(materialBh));
}
}
}
for(StorageLocation sl:listC){
String materialBh = sl.getMaterialBh();
String materialState = sl.getMaterialState();
String kw_user_name = redisCache.getCacheObject(getLocationZyCacheKey(materialBh));
if("0".equals(materialState)){
if(StringUtils.isNotNull(kw_user_name)&&user_name.equals(kw_user_name)){
redisCache.deleteObject(getLocationZyCacheKey(materialBh));
}
}
}
return ajaxResult;
}
@ -65,13 +99,13 @@ public class storageLocationController extends BaseController
String user_name = getLoginUser().getUsername();//当前登陆者
String materialBh = storageLocation.getMaterialBh();
String kw_user_name = redisCache.getCacheObject(getCacheKey(materialBh));
String kw_user_name = redisCache.getCacheObject(getLocationZyCacheKey(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);
redisCache.setCacheObject(getLocationZyCacheKey(materialBh),user_name);
return toAjax(storageLocationService.addStorageLocation(storageLocation));
}
@ -89,11 +123,11 @@ public class storageLocationController extends BaseController
String user_name = getLoginUser().getUsername();//当前登陆者
String materialBh = storageLocation.getMaterialBh();
String kw_user_name = redisCache.getCacheObject(getCacheKey(materialBh));
String kw_user_name = redisCache.getCacheObject(getLocationZyCacheKey(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);
redisCache.setCacheObject(getLocationZyCacheKey(materialBh),user_name,Integer.valueOf(storageExpire), TimeUnit.SECONDS);
return success();
}
}
@ -108,22 +142,153 @@ public class storageLocationController extends BaseController
String user_name = getLoginUser().getUsername();//当前登陆者
String materialBh = storageLocation.getMaterialBh();
String kw_user_name = redisCache.getCacheObject(getCacheKey(materialBh));
String kw_user_name = redisCache.getCacheObject(getLocationZyCacheKey(materialBh));
if(StringUtils.isNotNull(kw_user_name)&&user_name.equals(kw_user_name)){
redisCache.deleteObject(getCacheKey(materialBh));
redisCache.deleteObject(getLocationZyCacheKey(materialBh));
}
return success();
}
/*===========================================库位设置==========================================================*/
/*===========================================库位领用==========================================================*/
/**
* 获取库位领用信息
*/
@GetMapping("/lyList")
public AjaxResult lyList(StorageLocation storageLocation)
{
AjaxResult ajaxResult = new AjaxResult();
String user_name = getLoginUser().getUsername();//当前登陆者
List<StorageLocation> listA = storageLocationService.selectStorageLocationAList(storageLocation);
List<StorageLocation> listB = storageLocationService.selectStorageLocationBList(storageLocation);
List<StorageLocation> listC = storageLocationService.selectStorageLocationCList(storageLocation);
ajaxResult.put("materialDetailA",listA);
ajaxResult.put("materialDetailB",listB);
ajaxResult.put("materialDetailC",listC);
//根据库位状态 同步更新库位占用缓存-刷新页面时用
for(StorageLocation sl:listA){
String materialBh = sl.getMaterialBh();
String materialState = sl.getMaterialState();
String kw_user_name = redisCache.getCacheObject(getLocationLyCacheKey(materialBh));
if("1".equals(materialState)){
if(StringUtils.isNotNull(kw_user_name)&&user_name.equals(kw_user_name)){
redisCache.deleteObject(getLocationLyCacheKey(materialBh));
}
}
}
for(StorageLocation sl:listB){
String materialBh = sl.getMaterialBh();
String materialState = sl.getMaterialState();
String kw_user_name = redisCache.getCacheObject(getLocationLyCacheKey(materialBh));
if("1".equals(materialState)){
if(StringUtils.isNotNull(kw_user_name)&&user_name.equals(kw_user_name)){
redisCache.deleteObject(getLocationLyCacheKey(materialBh));
}
}
}
for(StorageLocation sl:listC){
String materialBh = sl.getMaterialBh();
String materialState = sl.getMaterialState();
String kw_user_name = redisCache.getCacheObject(getLocationLyCacheKey(materialBh));
if("1".equals(materialState)){
if(StringUtils.isNotNull(kw_user_name)&&user_name.equals(kw_user_name)){
redisCache.deleteObject(getLocationLyCacheKey(materialBh));
}
}
}
return ajaxResult;
}
/**
* 校验库位是否被领用
*/
@Log(title = "校验库位是否被领用", businessType = BusinessType.OTHER)
@PostMapping("/checklyStorageLocation")
public AjaxResult checklyStorageLocation(@RequestBody StorageLocation storageLocation)
{
String storageExpire = configService.selectConfigByKey("storage.expire.ly");
String user_name = getLoginUser().getUsername();//当前登陆者
String materialBh = storageLocation.getMaterialBh();
String kw_user_name = redisCache.getCacheObject(getLocationLyCacheKey(materialBh));
if(StringUtils.isNotNull(kw_user_name)&&!user_name.equals(kw_user_name)){
return error("当前库位有人正在操作,请勿操作!");
}else{
redisCache.setCacheObject(getLocationLyCacheKey(materialBh),user_name);
return success();
}
}
/**
* 清除库位领用缓存
*/
@Log(title = "清除库位领用缓存", businessType = BusinessType.OTHER)
@PostMapping("/clearLocationLyCacheKey")
public AjaxResult clearLocationLyCacheKey(@RequestBody StorageLocation storageLocation)
{
String user_name = getLoginUser().getUsername();//当前登陆者
String materialBh = storageLocation.getMaterialBh();
String kw_user_name = redisCache.getCacheObject(getLocationLyCacheKey(materialBh));
if(StringUtils.isNotNull(kw_user_name)&&user_name.equals(kw_user_name)){
redisCache.deleteObject(getLocationLyCacheKey(materialBh));
}
return success();
}
/**
* 库位缓存键名
* 确认完成认领
*/
@Log(title = "确认完成认领", businessType = BusinessType.OTHER)
@PostMapping("/confirmStorageLocation")
public AjaxResult confirmStorageLocation(@RequestBody String [] materialBhArr)
{
System.out.println(materialBhArr);
/* String storageExpire = configService.selectConfigByKey("storage.expire.ly");
String user_name = getLoginUser().getUsername();//当前登陆者
String materialBh = storageLocation.getMaterialBh();
String kw_user_name = redisCache.getCacheObject(getLocationLyCacheKey(materialBh));
if(StringUtils.isNotNull(kw_user_name)&&!user_name.equals(kw_user_name)){
return error("当前库位有人正在操作,请勿操作!");
}else{
redisCache.setCacheObject(getLocationLyCacheKey(materialBh),user_name);
return success();
}*/
storageLocationService.confirmStorageLocation(materialBhArr);
return success();
}
/*===========================================库位领用==========================================================*/
/**
* 库位占用缓存键名
*
* @param materialBh 库位号
* @return 缓存键key
*/
private String getCacheKey(String materialBh)
private String getLocationZyCacheKey(String materialBh)
{
return CacheConstants.STORAGE_LOCATION + materialBh;
return CacheConstants.STORAGE_LOCATION + materialBh + "-ZY";
}
/**
* 库位领用缓存键名
*
* @param materialBh 库位号
* @return 缓存键key
*/
private String getLocationLyCacheKey(String materialBh)
{
return CacheConstants.STORAGE_LOCATION + materialBh + "-LY";
}
}

View File

@ -28,4 +28,10 @@ public interface StorageLocationMapper
* @return
*/
int addStorageLocation(StorageLocation storageLocation);
/**
* 确认完成认领
* @param materialBhArr
*/
void confirmStorageLocation(String[] materialBhArr);
}

View File

@ -29,4 +29,10 @@ public interface StorageLocationService
* @return
*/
int addStorageLocation(StorageLocation storageLocation);
/**
* 确认完成认领
* @param materialBhArr
*/
void confirmStorageLocation(String[] materialBhArr);
}

View File

@ -47,4 +47,13 @@ public class StorageLocationServiceImpl implements StorageLocationService
public int addStorageLocation(StorageLocation storageLocation) {
return storageLocationMapper.addStorageLocation(storageLocation);
}
/**
* 确认完成认领
* @param materialBhArr
*/
@Override
public void confirmStorageLocation(String[] materialBhArr) {
storageLocationMapper.confirmStorageLocation(materialBhArr);
}
}

View File

@ -40,4 +40,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where materialBh = #{materialBh}
</update>
<update id="confirmStorageLocation">
update storageLocation set materialState = '0'
<where>
materialBh
<foreach collection="array" item="materialBh" index="index" open="in (" close=")" separator=",">
#{materialBh}
</foreach>
</where>
</update>
</mapper>

View File

@ -3,34 +3,34 @@ import request from '@/utils/request'
// 获取库位信息
export function listStorageLocation(query) {
return request({
url: '/storageLocation/storageLocation/list',
url: '/storageLocation/storageLocation/lyList',
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',
url: '/storageLocation/storageLocation/checklyStorageLocation',
method: 'post',
data: data
})
}
// 弹窗取消按钮 清除库位缓存
export function cancelStorageLocation(data) {
// 清除库位领用缓存
export function clearLocationLyCacheKey(data) {
return request({
url: '/storageLocation/storageLocation/cancelStorageLocation',
url: '/storageLocation/storageLocation/clearLocationLyCacheKey',
method: 'post',
data: data
})
}
// 确认完成认领
export function confirmStorageLocation(data) {
return request({
url: '/storageLocation/storageLocation/confirmStorageLocation',
method: 'post',
data: data
})

View File

@ -27,7 +27,7 @@ export function checkStorageLocation(data) {
})
}
// 弹窗取消按钮 清除库位缓存
// 弹窗取消按钮 清除库位占用缓存
export function cancelStorageLocation(data) {
return request({
url: '/storageLocation/storageLocation/cancelStorageLocation',

View File

@ -81,11 +81,11 @@
状态
</template>
<span v-if = "item.materialState=='0'">
<el-tag size="mini" type="success">空闲</el-tag>
</span>
<el-tag size="mini" type="success">空闲</el-tag>
</span>
<span v-if = "item.materialState=='1'">
<el-tag size="mini" type="danger">占用</el-tag>
</span>
<el-tag size="mini" type="danger" @click="selectLocation(item)">占用</el-tag>
</span>
</el-descriptions-item>
<el-descriptions-item :span="2" :contentStyle='contentStyle' :labelStyle='labelStyle'>
<template slot="label">
@ -134,11 +134,11 @@
状态
</template>
<span v-if = "item.materialState=='0'">
<el-tag size="mini" type="success">空闲</el-tag>
</span>
<el-tag size="mini" type="success">空闲</el-tag>
</span>
<span v-if = "item.materialState=='1'">
<el-tag size="mini" type="danger">占用</el-tag>
</span>
<el-tag size="mini" type="danger" @click="selectLocation(item)">占用</el-tag>
</span>
</el-descriptions-item>
<el-descriptions-item :span="2" :contentStyle='contentStyle' :labelStyle='labelStyle'>
<template slot="label">
@ -221,17 +221,170 @@
</el-dialog>
</el-tab-pane>
<el-tab-pane label="已选库位" name="locationSelected">
<el-row :gutter="10" style="letter-spacing: 5px;">
<el-col :span="8">
<div class="grid-content bg-purpleA">黄色线芯A区({{countA}})</div>
</el-col>
<el-col :span="8">
<div class="grid-content bg-purpleB">绿色线芯B区({{countB}})</div>
</el-col>
<el-col :span="8">
<div class="grid-content bg-purpleC">红色线芯C区({{countC}})</div>
</el-col>
</el-row>
<el-container>
<el-main>
<el-row :gutter="10" style="letter-spacing: 5px;">
<el-col :span="8">
<div class="grid-content bg-purpleA">黄色线芯A区</div>
</el-col>
<el-col :span="8">
<div class="grid-content bg-purpleB">绿色线芯B区</div>
</el-col>
<el-col :span="8">
<div class="grid-content bg-purpleC">红色线芯C区</div>
</el-col>
</el-row>
<el-row :gutter="10">
<el-col :span="8">
<el-card class="box-card scrollable">
<el-descriptions border :column="2" size="small" :style="index==0?'': 'margin-top :15px'" v-for="(item,index) in selMaterialDetailA" :key="item.materialBh">
<el-descriptions-item :contentStyle='contentStyle' :labelStyle='labelStyle'>
<template slot="label">
库位
</template>
<span class="kw">{{item.materialBh}}</span>
</el-descriptions-item>
<el-descriptions-item :contentStyle='contentStyle' :labelStyle='labelStyle'>
<template slot="label">
操作
</template>
<el-button type="danger" icon="el-icon-delete" size="mini" circle @click="del(item)"></el-button>
</el-descriptions-item>
<el-descriptions-item :span="2" :contentStyle='contentStyle' :labelStyle='labelStyle'>
<template slot="label">
指令号
</template>
{{item.materialZlh}}
</el-descriptions-item>
<el-descriptions-item :contentStyle='contentStyle' :labelStyle='labelStyle'>
<template slot="label">
型号
</template>
{{item.materialXingh}}
</el-descriptions-item>
<el-descriptions-item :contentStyle='contentStyle' :labelStyle='labelStyle'>
<template slot="label">
规格
</template>
{{item.materialGuig}}
</el-descriptions-item>
<el-descriptions-item :contentStyle='contentStyle' :labelStyle='labelStyle'>
<template slot="label">
电压等级
</template>
{{item.materialDiany}}
</el-descriptions-item>
<el-descriptions-item :contentStyle='contentStyle' :labelStyle='labelStyle'>
<template slot="label">
米数
</template>
{{item.materialMs}}
</el-descriptions-item>
</el-descriptions>
</el-card>
</el-col>
<el-col :span="8">
<el-card class="box-card scrollable">
<el-descriptions border :column="2" size="small" :style="index==0?'': 'margin-top :12px'" v-for="(item,index) in selMaterialDetailB" :key="item.materialBh">
<el-descriptions-item :contentStyle='contentStyle' :labelStyle='labelStyle'>
<template slot="label">
库位
</template>
<span class="kw">{{item.materialBh}}</span>
</el-descriptions-item>
<el-descriptions-item :contentStyle='contentStyle' :labelStyle='labelStyle'>
<template slot="label">
操作
</template>
<el-button type="danger" icon="el-icon-delete" size="mini" circle @click="del(item)"></el-button>
</el-descriptions-item>
<el-descriptions-item :span="2" :contentStyle='contentStyle' :labelStyle='labelStyle'>
<template slot="label">
指令号
</template>
{{item.materialZlh}}
</el-descriptions-item>
<el-descriptions-item :contentStyle='contentStyle' :labelStyle='labelStyle'>
<template slot="label">
型号
</template>
{{item.materialXingh}}
</el-descriptions-item>
<el-descriptions-item :contentStyle='contentStyle' :labelStyle='labelStyle'>
<template slot="label">
规格
</template>
{{item.materialGuig}}
</el-descriptions-item>
<el-descriptions-item :contentStyle='contentStyle' :labelStyle='labelStyle'>
<template slot="label">
电压等级
</template>
{{item.materialDiany}}
</el-descriptions-item>
<el-descriptions-item :contentStyle='contentStyle' :labelStyle='labelStyle'>
<template slot="label">
米数
</template>
{{item.materialMs}}
</el-descriptions-item>
</el-descriptions>
</el-card>
</el-col>
<el-col :span="8">
<el-card class="box-card scrollable">
<el-descriptions border :column="2" size="small" :style="index==0?'': 'margin-top :12px'" v-for="(item,index) in selMaterialDetailC" :key="item.materialBh">
<el-descriptions-item :contentStyle='contentStyle' :labelStyle='labelStyle'>
<template slot="label">
库位
</template>
<span class="kw">{{item.materialBh}}</span>
</el-descriptions-item>
<el-descriptions-item :contentStyle='contentStyle' :labelStyle='labelStyle'>
<template slot="label">
操作
</template>
<el-button type="danger" icon="el-icon-delete" size="mini" circle @click="del(item)"></el-button>
</el-descriptions-item>
<el-descriptions-item :span="2" :contentStyle='contentStyle' :labelStyle='labelStyle'>
<template slot="label">
指令号
</template>
{{item.materialZlh}}
</el-descriptions-item>
<el-descriptions-item :contentStyle='contentStyle' :labelStyle='labelStyle'>
<template slot="label">
型号
</template>
{{item.materialXingh}}
</el-descriptions-item>
<el-descriptions-item :contentStyle='contentStyle' :labelStyle='labelStyle'>
<template slot="label">
规格
</template>
{{item.materialGuig}}
</el-descriptions-item>
<el-descriptions-item :contentStyle='contentStyle' :labelStyle='labelStyle'>
<template slot="label">
电压等级
</template>
{{item.materialDiany}}
</el-descriptions-item>
<el-descriptions-item :contentStyle='contentStyle' :labelStyle='labelStyle'>
<template slot="label">
米数
</template>
{{item.materialMs}}
</el-descriptions-item>
</el-descriptions>
</el-card>
</el-col>
</el-row>
</el-main>
<el-footer style="margin:0 auto;">
<el-button type="primary" @click="confirm()">确认</el-button>
</el-footer>
</el-container>
</el-tab-pane>
</el-tabs>
@ -281,7 +434,7 @@
}
</style>
<script>
import { listStorageLocation, addStorageLocation, checkStorageLocation,cancelStorageLocation } from "@/api/storageLocation/storageLocation";
import { listStorageLocation, checkStorageLocation,clearLocationLyCacheKey, confirmStorageLocation } from "@/api/storageLocation/storageConsuming";
export default {
name: "locationConsuming.vue",
@ -314,6 +467,11 @@
materialDetailA:[],
materialDetailB:[],
materialDetailC:[],
//
selMaterialDetailA:[],
selMaterialDetailB:[],
selMaterialDetailC:[],
//
form: {},
//
@ -430,10 +588,98 @@
showClose: false,//
type: "warning",// success/info/warning/error
}).then(()=>{
//
var materialBh = item.materialBh;
this.form.materialBh = materialBh;
//
var index = "";
if(materialBh.indexOf('A-')==0){
index = this.selMaterialDetailA.findIndex(item => item.materialBh === materialBh);
}
if(materialBh.indexOf('B-')==0){
index = this.selMaterialDetailB.findIndex(item => item.materialBh === materialBh);
}
if(materialBh.indexOf('C-')==0){
index = this.selMaterialDetailC.findIndex(item => item.materialBh === materialBh);
}
if (index !== -1) {
this.$message({
message: '该库位 '+ materialBh +' 已选,请勿重复选!',
type: 'error'
});
return;
}
//
checkStorageLocation(this.form).then(response => {
if(materialBh.indexOf('A-')==0){
this.selMaterialDetailA.push(item)
}
if(materialBh.indexOf('B-')==0){
this.selMaterialDetailB.push(item)
}
if(materialBh.indexOf('C-')==0){
this.selMaterialDetailC.push(item)
}
this.$message({
message: '已成功选择库位 '+ materialBh,
type: 'success'
});
}).catch((error) => {
console.error(error);
});
}).catch(() => {
//
});
},
//
del(item){
var materialBh = item.materialBh;
this.form.materialBh = materialBh;
if(materialBh.indexOf('A-')==0){
const index = this.selMaterialDetailA.findIndex(item => item.materialBh === materialBh);
if (index !== -1) {
this.selMaterialDetailA.splice(index, 1);
}
}
if(materialBh.indexOf('B-')==0){
debugger
const index = this.selMaterialDetailB.findIndex(item => item.materialBh === materialBh);
if (index !== -1) {
this.selMaterialDetailB.splice(index, 1);
}
}
if(materialBh.indexOf('C-')==0){
const index = this.selMaterialDetailC.findIndex(item => item.materialBh === materialBh);
if (index !== -1) {
this.selMaterialDetailC.splice(index, 1);
}
}
//
clearLocationLyCacheKey(this.form).then(response => {
}).catch((error) => {
console.error(error);
});
},
//
confirm(){
var materialBhArr = [];
this.selMaterialDetailA.forEach(function(item,index,array) {
materialBhArr.push(item.materialBh)
})
this.selMaterialDetailB.forEach(function(item,index,array) {
materialBhArr.push(item.materialBh)
})
this.selMaterialDetailC.forEach(function(item,index,array) {
materialBhArr.push(item.materialBh)
})
confirmStorageLocation(materialBhArr).then(response => {
this.$modal.msgSuccess("领用成功");
this.activeName = 'locationShow';
this.getStorageLocation();
});
}
}
}

View File

@ -227,6 +227,11 @@
font-size: 15px;color: black;font-weight: bold
}
/* 修改标签本身的样式 */
.el-tag:hover {
cursor: pointer; /* 将鼠标形状改为指针形状 */
}
/*卡片内容滚动条设置*/
::-webkit-scrollbar {
display: none; /* Chrome Safari */