From 3045d2e0ff01c40d836ae3b64ff15e71563e4ab4 Mon Sep 17 00:00:00 2001
From: ZengTao <2773468879@qq.com>
Date: 星期四, 07 十二月 2023 08:30:22 +0800
Subject: [PATCH] 添加根据用户权限控制主界面功能
---
springboot-vue3/src/main/java/com/example/springboot/controller/UserController.java | 14 +++
CanadaMes-ui/src/views/home/index.vue | 152 +++++++++++++++++++++++++-------------
CanadaMes-ui/src/api/home.js | 17 ++++
CanadaMes-ui/src/lang/locales/en-US.json | 1
springboot-vue3/src/main/java/com/example/springboot/component/Plchome.java | 9 +-
springboot-vue3/src/main/java/com/example/springboot/mapper/HomeMapper.java | 3
springboot-vue3/src/main/java/com/example/springboot/controller/HomeController.java | 34 +++++++-
CanadaMes-ui/src/lang/locales/zh-CN.json | 1
8 files changed, 169 insertions(+), 62 deletions(-)
diff --git a/CanadaMes-ui/src/api/home.js b/CanadaMes-ui/src/api/home.js
index 64fb220..beef5bd 100644
--- a/CanadaMes-ui/src/api/home.js
+++ b/CanadaMes-ui/src/api/home.js
@@ -1,5 +1,22 @@
import request from "../utils/request";
+
+export function SelectPermissionByUserName(username) {
+ return request({
+ url: '/home/SelectPermissionByUserName?username='+username,
+ method: 'get',
+ data:""
+ })
+}
+
+export function currentUsername() {
+ return request({
+ url: '/api/user/currentUsername',
+ method: 'get',
+
+ })
+ }
+
/**
*鐧诲綍
* @param data
diff --git a/CanadaMes-ui/src/lang/locales/en-US.json b/CanadaMes-ui/src/lang/locales/en-US.json
index 4a8de1b..964f665 100644
--- a/CanadaMes-ui/src/lang/locales/en-US.json
+++ b/CanadaMes-ui/src/lang/locales/en-US.json
@@ -319,6 +319,7 @@
"Top":"Top",
"Up":"Up",
"Down":"Down",
+ "You do not have this permission":"You do not have this permission",
"ServoManualone": {
"A01 鎵�鍦ㄦ牸瀛�": "A01 Current Grid",
"鏁伴噺": "Quantity",
diff --git a/CanadaMes-ui/src/lang/locales/zh-CN.json b/CanadaMes-ui/src/lang/locales/zh-CN.json
index 05c7ab5..62696fd 100644
--- a/CanadaMes-ui/src/lang/locales/zh-CN.json
+++ b/CanadaMes-ui/src/lang/locales/zh-CN.json
@@ -313,6 +313,7 @@
"Top":"缃《",
"Up":"涓婄Щ",
"Down":"涓嬬Щ",
+ "You do not have this permission":"You do not have this permission",
"langparameter": {
"conveyor Velocity(Auto FAST)": "D01-D06 鐨甫杈撻�佽嚜鍔ㄥ揩閫�",
"conveyor Velocity(Auto SLOW)": "D01-D06 鐨甫杈撻�佽嚜鍔ㄦ參閫�",
diff --git a/CanadaMes-ui/src/views/home/index.vue b/CanadaMes-ui/src/views/home/index.vue
index 88190e1..68e98c2 100644
--- a/CanadaMes-ui/src/views/home/index.vue
+++ b/CanadaMes-ui/src/views/home/index.vue
@@ -199,9 +199,12 @@
font-size: 25px;
}
-@media screen and (min-width: 1900px) {
- .blocks{transform: scale(1.5,1.05);width: 1210px;}
-}
+@media screen and (min-width: 1900px) {
+ .blocks {
+ transform: scale(1.5, 1.05);
+ width: 1210px;
+ }
+}
.el-message-box__btns {
padding: 0px 15px 0;
@@ -228,7 +231,8 @@
</div>
<div style="display:flex;justify-content: space-around;width: 9zz5%;margin: 0 auto;">
<el-input style="width:15%;" :placeholder="$t('Enter the glass barcode')" v-model="glassid1"></el-input>
- <el-button type="primary" @click="SelectGlassByGlassIDs(2)">{{ $t('Manually Infeed Glass') }}</el-button>
+ <el-button type="primary" @click="SelectGlassByGlassIDs(2)" :disabled="ManuallyInfeedGlass">
+ {{ $t('Manually Infeed Glass') }}</el-button>
<!-- <el-input style="width:15%;" :placeholder="$t('Enter the Order No')" v-model="order"></el-input>
<el-button type="warning" @click="showform1();">{{ $t('Exit the glass by order number') }}</el-button> -->
</div>
@@ -312,14 +316,19 @@
@click="showcageinfo(item['cage'])"></div>
</div>
<div class="blue gezi"
- :style="{ display: 'flex', position: 'absolute', float: 'left', top: 105 + 'px', left: 1050 + 'px', height: loadglassheight + 'px', width: 5 + 'px' }">
+ :style="{ display: 'flex', position: 'absolute', float: 'left', top: 28 + 'px', left: 1050 + 'px', height: loadglassheight1 + 'px', width: 4 + 'px' }">
+ </div>
+ <div class="blue gezi"
+ :style="{ display: 'flex', position: 'absolute', float: 'left', top: 105 + 'px', left: 1050 + 'px', height: loadglassheight2 + 'px', width: 4 + 'px' }">
</div>
<div class="blocks-img" :style="{ left: car1 + 'px', top: '16px' }"></div>
<div class="blocks-img" :style="{ left: car2 + 'px', top: '175px' }"></div>
<div class="blocks-img2"></div>
<div class="blocks-img3"></div>
- <el-button class="orderbutton1" type="primary" @click="showform2()">{{ $t('OrderInfo') }}</el-button>
- <el-button class="orderbutton2" type="primary" @click="showform6()">{{ $t('Outing Queue') }}</el-button>
+ <el-button class="orderbutton1" type="primary" @click="showform2()" :disabled="OrderInfo">{{ $t('OrderInfo')
+ }}</el-button>
+ <el-button class="orderbutton2" type="primary" @click="showform6()" :disabled="OutingQueue">
+ {{ $t('Outing Queue') }}</el-button>
<!-- <div style="display:flex;position: absolute;float:left;z-index: 999;top:112px;left:328px;">
<div :class="getStatusClass(item.state)" v-for="(item,index) in cagelist1" :key="item['date']"
@@ -639,17 +648,20 @@
<el-table-column prop="barcode" :label="$t('Frame No')"></el-table-column>
<el-table-column :width="280" :label="$t('Operate')">
<template slot-scope='scope'>
- <el-button type="text" size="small" @click="getTopMove(scope.row, scope.$index)" style="font-size: 15px;"
+ <el-button type="text" size="small" @click="getTopMove(scope.row, scope.$index)"
+ style="font-size: 15px;"
:disabled="(scope.$index == 0 || isAllowQueue == true || scope.row.state == 1)">
- {{$t('Top')}}
+ {{ $t('Top') }}
</el-button>
- <el-button type="text" size="small" @click="getUpMove(scope.row, scope.$index)" style="font-size: 15px;"
+ <el-button type="text" size="small" @click="getUpMove(scope.row, scope.$index)"
+ style="font-size: 15px;"
:disabled="(scope.$index == 0 || isAllowQueue == true || scope.row.state == 1)">
- {{$t('Up')}}
+ {{ $t('Up') }}
</el-button>
- <el-button type="text" size="small" @click="getDownMove(scope.row, scope.$index)" style="font-size: 15px;"
+ <el-button type="text" size="small" @click="getDownMove(scope.row, scope.$index)"
+ style="font-size: 15px;"
:disabled="(OutSlice.length - 1 == scope.$index || isAllowQueue == true || scope.row.state == 1)">
- {{$t('Down')}}
+ {{ $t('Down') }}
</el-button>
<el-button type="primary" style="padding: 4px 10px;font-size: 12px;" :disabled="isAllowQueue"
@click="deleteproductionqueueglass(scope.row.barcode)">{{ $t('Delete') }}</el-button>
@@ -702,7 +714,7 @@
import {
home, home2, InsertOrder, Addglassid, UpdateTask, SelectAlarmmgInfo, SelectCageInfo, DeleteByGlassID, OutByGlassID, Loadcarlist,
SelectPassword, SelectGlassByGlassID, Disabled, Inglassid, SelectGlass, InsertQueueGlassId, UpdateQueueState, DeleteQueueGlass, SelectGlassNo,
- SelectAluminumFrameInfoById, DeleteProductionQueueGlass, AddOutSliceS, isAllowQueues, isConfirmStates
+ SelectAluminumFrameInfoById, DeleteProductionQueueGlass, AddOutSliceS, isAllowQueues, isConfirmStates, SelectPermissionByUserName, currentUsername
} from "../../api/home";
@@ -761,7 +773,8 @@
cageinfo: [],
cage: 0,
carlist: [],
- loadglassheight: 0,
+ loadglassheight1: 0,
+ loadglassheight2: 0,
password: 1,
text: "",
zhuangtai: "",
@@ -776,13 +789,16 @@
currentPages: 1, //榛樿鍒濆椤�
pagesizes: 21, //姣忛〉榛樿鏄剧ず鐨勬暟鎹�
pageCounts: 0,
-
OutSlice: [],
AluminumFrame: [],
framebarcode: "",
isAllowQueue: true,
FrameNoFlag: "",
- isConfirm: true
+ isConfirm: true,
+ ManuallyInfeedGlass: true,
+ OutingQueue: true,
+ OrderInfo: true,
+ CageDetails: true
};
},
created() {
@@ -835,32 +851,37 @@
this.OutSlice = obj.listoutslice[0];
}
//鑾峰彇涓婄墖浣嶇幓鐠冧俊鎭�
- this.loadglassheight = obj.loadglassheight;
+
if (obj.zhuangtai != null) {
this.zhuangtai = obj.zhuangtai[0];
}
//涓婄墖浣嶇幓鐠冧俊鎭�
if (obj.form2 != null && obj.form2 != "") {
this.form2 = obj.form2[0];
+ this.loadglassheight2 = 70;
} else {
this.form2 = {};
}
-
+
//鏄惁闇�瑕佹墜鍔ㄧ‘璁や笂鐗�
this.isConfirm = obj.isConfirm[0];
//鎵爜浣嶇幓鐠冧俊鎭�
if (obj.form3 != null && obj.form3 != "" && obj.state[0] == 1) {
this.form3 = obj.form3[0];
+ this.loadglassheight1 = 70;
} else {
this.form3 = {};
}
if (obj.form3 != null && obj.form3 != "" && obj.state[0] == 0) {
+ this.loadglassheight1 = 70;
this.form5 = obj.form3[0];
this.showform3();
this.Sizerange(this.form5, 3);
-
+ this.glassid1="";
} else {
- this.Sizerange(this.form5, 3);
+ if(this.glassid1==""){
+ this.DeleteBarcodeGlass();
+ }
}
//鏁版嵁搴撹繛鎺ユ槸鍚︽甯�
if (obj.dbconnected == "false") {
@@ -888,6 +909,26 @@
}
},
load() {
+ //鍔犺浇鐢ㄦ埛鏉冮檺
+ currentUsername().then(res => {
+ SelectPermissionByUserName(res.data).then(res => {
+ res.data.permission.forEach(item => {
+ if (item.permissionId == "32" && item.state == 1) {
+ this.ManuallyInfeedGlass = false;
+ }
+ if (item.permissionId == "32" && item.state == 1) {
+ this.OutingQueue = false;
+ }
+ if (item.permissionId == "33" && item.state == 1) {
+ this.OrderInfo = false;
+ }
+ if (item.permissionId == "34" && item.state == 1) {
+ this.CageDetails = false;
+ }
+ });
+ });
+
+ });
//鍔犺浇绗煎瓙浣跨敤鎯呭喌鏁版嵁
home().then(res => {
this.tableData = res.data.list;
@@ -1139,12 +1180,17 @@
},
//鏄剧ず鐞嗙墖绗艰鎯呬俊鎭�
showcageinfo(cage) {
- cage = this.cageglassid;
- SelectCageInfo(cage).then(res => {
- this.cageinfo = res.data.cageinfo;
- this.currentPages = 1;
- this.dialogFormVisible3 = true;
- });
+ if (this.CageDetails == false) {
+ cage = this.cageglassid;
+ SelectCageInfo(cage).then(res => {
+ this.cageinfo = res.data.cageinfo;
+ this.currentPages = 1;
+ this.dialogFormVisible3 = true;
+ });
+ } else {
+ this.$message.error(this.$t('You do not have this permission'));
+ }
+
},
//鍒犻櫎鐞嗙墖绗肩幓鐠�
deleteglass(glassid, state) {
@@ -1379,7 +1425,7 @@
this.$message.success(this.$t('Operation successful'));
}
});
- },
+ },
//缃《
getTopMove(row, index) {
let Sequence = [];
@@ -1548,32 +1594,34 @@
},
//鍒ゆ柇鐜荤拑鏄惁瓒呭嚭鑼冨洿
Sizerange(Glass, position) {
- if ((Glass.glassheight < 380 || Glass.glasswidth < 390 || Glass.glassheight > 1810 || Glass.glasswidth > 2760) || (Glass.glassheight < 390 || Glass.glasswidth < 380 || Glass.glassheight > 2760 || Glass.glasswidth > 1810)) {
- this.$alert(this.$t('The glass size is not within the range'), this.$t('confirm'), {
- confirmButtonText: this.$t('Yes'),
- type: 'info',
- callback: (action) => {
- this.$message({
- type: 'info',
- message: `action: ${ action }`
- }).then(
- this.DeleteBarcodeGlass()
- );
+ if (this.ManuallyInfeedGlass == true) {
+ if ((Glass.glassheight < 380 || Glass.glasswidth < 390 || Glass.glassheight > 1810 || Glass.glasswidth > 2760) || (Glass.glassheight < 390 || Glass.glasswidth < 380 || Glass.glassheight > 2760 || Glass.glasswidth > 1810)) {
+ this.$alert(this.$t('The glass size is not within the range'), this.$t('confirm'), {
+ confirmButtonText: this.$t('Yes'),
+ type: 'info',
+ callback: (action) => {
+ this.$message({
+ type: 'info',
+ message: `action: ${action}`
+ }).then(
+ this.DeleteBarcodeGlass()
+ );
+ }
+ });
+ if (position == 1 || position == 3) {
+ this.disabled1 = true;
+ } else {
+ this.disabled = true;
}
- });
- if (position == 1 || position == 3) {
- this.disabled1 = true;
} else {
- this.disabled = true;
- }
- } else {
- if (position == 1 || position == 3) {
- this.disabled1 = false;
- } else {
- this.disabled = false;
- }
- if (position == 3&&this.isConfirmState==true) {
- this.InsertQueueGlass(1);
+ if (position == 1 || position == 3) {
+ this.disabled1 = false;
+ } else {
+ this.disabled = false;
+ }
+ if (position == 3 && this.isConfirmState == true) {
+ this.InsertQueueGlass(1);
+ }
}
}
},
diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/Plchome.java b/springboot-vue3/src/main/java/com/example/springboot/component/Plchome.java
index 8d1b7c3..de38cb9 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/component/Plchome.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/component/Plchome.java
@@ -1,9 +1,7 @@
package com.example.springboot.component;
import cn.hutool.json.JSONObject;
-import cn.hutool.poi.excel.sax.handler.MapRowHandler;
-
-import java.sql.SQLException;
+import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
@@ -32,7 +30,7 @@
//閾濇id
public static String FrameNo;
//鏄惁闇�瑕佹墜鍔ㄧ‘璁ょ幓鐠�
- public static Boolean isConfirm=true;
+ public static Boolean isConfirm=false;
// public static Map b=new HashMap<>();
// b.put()
@Override
@@ -89,10 +87,11 @@
// if (inglassInfo.size() > 0)
// jsonObject.append("loadglassheight", inglassInfo.get(0) * 70);
// }
+
// 浼� 鑾峰彇杩涙槸鍚︽湁寰呯‘璁ょ殑鐜荤拑id
String queid = spianMapper.Selectqueueid();
int state = spianMapper.Selectqueuestate();
- jsonObject.append("state", queid);
+ jsonObject.append("queid", queid);
jsonObject.append("state", state);
// 鑾峰彇鎵爜浣嶄笌涓婄墖浣嶇幓鐠冧俊鎭�
Queue form2 = homeMapper.GetQueueInfo(2);
diff --git a/springboot-vue3/src/main/java/com/example/springboot/controller/HomeController.java b/springboot-vue3/src/main/java/com/example/springboot/controller/HomeController.java
index 25d72ac..1f3445c 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/controller/HomeController.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/controller/HomeController.java
@@ -5,27 +5,42 @@
import java.util.List;
import java.util.Map;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import com.example.springboot.mapper.HomeMapper;
import com.example.springboot.mapper.SpianMapper;
+import com.example.springboot.security.constant.SystemConstant;
+import com.example.springboot.security.util.JwtUtil;
+import com.example.springboot.security.util.SecurityUtil;
import com.example.springboot.service.HomeService;
import com.example.springboot.service.JdbcConnections;
import com.example.springboot.service.North_Glass_Buffer1Service;
import com.example.springboot.service.OutSliceServive;
+import com.example.springboot.service.PermissionService;
import com.example.springboot.service.SpianService;
+
+import cn.hutool.core.util.StrUtil;
+
import com.example.springboot.common.Result;
import com.example.springboot.component.Plchome;
import com.example.springboot.component.S7control;
import com.example.springboot.entity.CarPosition;
import com.example.springboot.entity.StorageCage;
+import com.example.springboot.entity.User;
import com.example.springboot.entity.alarmmg;
import com.example.springboot.entity.north_glass_buffer1;
import com.example.springboot.entity.Out_slice;
+import com.example.springboot.entity.Permission;
import com.example.springboot.entity.Queue;
+import com.example.springboot.entity.RolePermission;
import org.springframework.web.bind.annotation.*;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
@RestController
@RequestMapping("/home")
@@ -51,6 +66,15 @@
@Autowired
private JdbcConnections jdbcConnections;
+ // 鑾峰彇褰撳墠鐧诲綍鐢ㄦ埛鏉冮檺
+ @GetMapping("/SelectPermissionByUserName")
+ public Result SelectPermissionByUserName(String username) {
+ Map<String, Object> map = new HashMap<>();
+ List<RolePermission> permission = homeMapper.SelectPermissionByUserName(username);
+ map.put("permission", permission);
+ return Result.success(map);
+ }
+
// 鏌ヨ鐞嗙墖绗间娇鐢ㄦ儏鍐�
@GetMapping("/load")
public Result selectAll() {
@@ -63,6 +87,7 @@
// 鏌ヨ鐞嗙墖绗肩幓鐠冩儏鍐�
@GetMapping("/loads")
public Result selectRack() {
+
List<StorageCage> storageCagelist1 = homeMapper.selectRack1();
List<StorageCage> storageCagelist2 = homeMapper.selectRack2();
List<StorageCage> storageCagelist3 = homeMapper.selectRack3();
@@ -167,9 +192,10 @@
north_glass_buffer1 north_glass_buffer1 = jdbcConnections.SelectGlassByGlassIdOrderIdFrameId(glassid, "", "");
String flip = jdbcConnections.SelectFlipByFrameBarcode(north_glass_buffer1.getFrameBarcode());
String position = jdbcConnections.SelectPositionByFrameBarcode(north_glass_buffer1.getFrameBarcode());
- int sequence=homeMapper.SelectMaxSquence();
+ int sequence = homeMapper.SelectMaxSquence();
homeMapper.AddOutSliceS(glassid, flip, north_glass_buffer1.getFrameBarcode(),
- north_glass_buffer1.getglasslengthmm().toString(), north_glass_buffer1.getglassheightmm().toString(),sequence,position);
+ north_glass_buffer1.getglasslengthmm().toString(), north_glass_buffer1.getglassheightmm().toString(),
+ sequence, position);
map.put("message2", "200");
} else {
map.put("message2", "500");
@@ -285,7 +311,7 @@
@PostMapping("/SelectAluminumFrameInfoById")
public Result SelectAluminumFrameInfoById(String FrameBarcode) throws SQLException {
String flip = jdbcConnections.SelectFlipByFrameBarcode(FrameBarcode);
- List<north_glass_buffer1> listAluminumFrame=north_Glass_Buffer1Service.SelectAluminumFrameInfoById(FrameBarcode);
+ List<north_glass_buffer1> listAluminumFrame = north_Glass_Buffer1Service.SelectAluminumFrameInfoById(FrameBarcode);
Map<String, Object> map = new HashMap<>();
map.put("listAluminumFrame", listAluminumFrame);
map.put("flip", flip);
@@ -332,7 +358,7 @@
Plchome.isAllowQueue = isAllowQueue;
if (isAllowQueue == true) {
for (Out_slice out_slice2 : out_slice) {
- homeMapper.UpdateOutSliceSequence(out_slice2.getGlassId(),out_slice2.getSequence());
+ homeMapper.UpdateOutSliceSequence(out_slice2.getGlassId(), out_slice2.getSequence());
}
}
Map<String, Object> map = new HashMap<>();
diff --git a/springboot-vue3/src/main/java/com/example/springboot/controller/UserController.java b/springboot-vue3/src/main/java/com/example/springboot/controller/UserController.java
index a40ae9e..b882792 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/controller/UserController.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/controller/UserController.java
@@ -168,7 +168,19 @@
private class UpdatePasswordRequest {
}
-
+ @ApiOperation(value = "鑾峰彇褰撳墠鐧诲綍鐢ㄦ埛鐨勭敤鎴峰悕")
+ @GetMapping("/currentUsername")
+ @RequiresAuthentication // 纭繚鍙湁璁よ瘉杩囩殑鐢ㄦ埛鍙互璁块棶姝ゆ帴鍙�
+ public Result getCurrentUsername() {
+ User currentUser = SecurityUtil.getCurrentUser();
+ if (currentUser != null) {
+ // 鍋囪User绫绘湁getUsername鏂规硶鍙互鑾峰彇鐢ㄦ埛鍚�
+ String username = currentUser.getUsername();
+ return Result.success(username);
+ } else {
+ return Result.fail("鐢ㄦ埛鏈櫥褰曟垨浼氳瘽宸茶繃鏈�");
+ }
+ }
diff --git a/springboot-vue3/src/main/java/com/example/springboot/mapper/HomeMapper.java b/springboot-vue3/src/main/java/com/example/springboot/mapper/HomeMapper.java
index 1889fad..3dfec02 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/mapper/HomeMapper.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/mapper/HomeMapper.java
@@ -8,6 +8,7 @@
import com.example.springboot.entity.north_glass_buffer1;
import com.example.springboot.entity.Out_slice;
import com.example.springboot.entity.Queue;
+import com.example.springboot.entity.RolePermission;
import java.util.List;
@@ -167,5 +168,7 @@
@Select("select ifnull(max(sequence),0)+1 from out_slice ")
Short SelectMaxSquence();
+ @Select("select rp.* from role_permission rp inner join role r on rp.role_id=r.id and r.name=#{token} and (permission_id=32 or permission_id=33 or permission_id=34 or permission_id=35)")
+ List<RolePermission> SelectPermissionByUserName(String token);
}
--
Gitblit v1.8.0