ZengTao
2023-12-07 3045d2e0ff01c40d836ae3b64ff15e71563e4ab4
添加根据用户权限控制主界面功能
8个文件已修改
231 ■■■■ 已修改文件
CanadaMes-ui/src/api/home.js 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
CanadaMes-ui/src/lang/locales/en-US.json 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
CanadaMes-ui/src/lang/locales/zh-CN.json 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
CanadaMes-ui/src/views/home/index.vue 152 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springboot-vue3/src/main/java/com/example/springboot/component/Plchome.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springboot-vue3/src/main/java/com/example/springboot/controller/HomeController.java 34 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springboot-vue3/src/main/java/com/example/springboot/controller/UserController.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springboot-vue3/src/main/java/com/example/springboot/mapper/HomeMapper.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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
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",
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 皮带输送自动慢速",
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);
                    }
                }
            }
        },
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);
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<>();
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("用户未登录或会话已过期");
        }
    }
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);
}