Merge branch 'master' of http://10.153.19.25:10101/r/HangZhouMes
# Conflicts:
# hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downworkstation/service/DownGlassLogic.java
1 文件已复制
31个文件已修改
6 文件已重命名
56个文件已添加
12个文件已删除
| | |
| | | spring: |
| | | datasource: |
| | | dynamic: |
| | | primary: user_info #设置默认的数据源或者数据源组,默认值即为master |
| | | primary: hangzhoumes #设置默认的数据源或者数据源组,默认值即为master |
| | | strict: false #设置严格模式,默认false不启动. 启动后在未匹配到指定数据源时候回抛出异常,不启动会使用默认数据源. |
| | | datasource: |
| | | user_info: |
| | | url: jdbc:mysql://10.153.19.150:3306/erp_user_info?serverTimezone=GMT%2b8 |
| | | hangzhoumes: |
| | | url: jdbc:mysql://10.153.19.150:3306/hangzhoumes?serverTimezone=GMT%2b8 |
| | | username: root |
| | | password: beibo.123/ |
| | | driver-class-name: com.mysql.cj.jdbc.Driver |
| | | sd: |
| | | url: jdbc:mysql://10.153.19.150:3306/sd?serverTimezone=GMT%2b8 |
| | | username: root |
| | | password: beibo.123/ |
| | | driver-class-name: com.mysql.cj.jdbc.Driver |
| | | mm: |
| | | url: jdbc:mysql://10.153.19.150:3306/mm?serverTimezone=GMT%2b8 |
| | | username: root |
| | | password: beibo.123/ |
| | | driver-class-name: com.mysql.cj.jdbc.Driver |
| | | pp: |
| | | url: jdbc:mysql://10.153.19.150:3306/pp?serverTimezone=GMT%2b8 |
| | | username: root |
| | | password: beibo.123/ |
| | | driver-class-name: com.mysql.cj.jdbc.Driver |
| | |
| | | spring: |
| | | datasource: |
| | | dynamic: |
| | | primary: user_info #设置默认的数据源或者数据源组,默认值即为master |
| | | primary: hangzhoumes #设置默认的数据源或者数据源组,默认值即为master |
| | | strict: false #设置严格模式,默认false不启动. 启动后在未匹配到指定数据源时候回抛出异常,不启动会使用默认数据源. |
| | | datasource: |
| | | user_info: |
| | | url: jdbc:mysql://10.153.19.150:3306/erp_user_info?serverTimezone=GMT%2b8 |
| | | hangzhoumes: |
| | | url: jdbc:mysql://10.153.19.150:3306/hangzhoumes?serverTimezone=GMT%2b8 |
| | | username: root |
| | | password: beibo.123/ |
| | | driver-class-name: com.mysql.cj.jdbc.Driver |
| | | sd: |
| | | url: jdbc:mysql://10.153.19.150:3306/sd?serverTimezone=GMT%2b8 |
| | | username: root |
| | | password: beibo.123/ |
| | | driver-class-name: com.mysql.cj.jdbc.Driver |
| | | mm: |
| | | url: jdbc:mysql://10.153.19.150:3306/mm?serverTimezone=GMT%2b8 |
| | | username: root |
| | | password: beibo.123/ |
| | | driver-class-name: com.mysql.cj.jdbc.Driver |
| | | pp: |
| | | url: jdbc:mysql://10.153.19.150:3306/pp?serverTimezone=GMT%2b8 |
| | | username: root |
| | | password: beibo.123/ |
| | | driver-class-name: com.mysql.cj.jdbc.Driver |
| | |
| | | export default { |
| | | serverUrl:"localhost:8080/mesModuleTools", |
| | | serverUrl2:"localhost:8081/mesModuleTools" |
| | | serverUrl: "localhost:8081", |
| | | serverUrl2: "localhost:8081/mesModuleTools" |
| | | //serverUrl:"res.abeim.cn" |
| | | } |
| | |
| | | "dependencies": { |
| | | "@element-plus/icons-vue": "^2.1.0", |
| | | "@vue-macros/reactivity-transform": "^0.3.23", |
| | | "axios": "^1.5.1", |
| | | "axios": "^1.6.8", |
| | | "element-plus": "^2.4.0", |
| | | "moment": "^2.30.1", |
| | | "pinia": "^2.1.6", |
| | |
| | | "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" |
| | | }, |
| | | "node_modules/axios": { |
| | | "version": "1.5.1", |
| | | "resolved": "https://registry.npmjs.org/axios/-/axios-1.5.1.tgz", |
| | | "integrity": "sha512-Q28iYCWzNHjAm+yEAot5QaAMxhMghWLFVf7rRdwhUI+c2jix2DUXjAHXVi+s1ibs3mjPO/cCgbA++3BjD0vP/A==", |
| | | "version": "1.6.8", |
| | | "resolved": "https://registry.npmmirror.com/axios/-/axios-1.6.8.tgz", |
| | | "integrity": "sha512-v/ZHtJDU39mDpyBoFVkETcd/uNdxrWRrg3bKpOKzXFA6Bvqopts6ALSMU3y6ijYxbw2B+wPrIv46egTzJXCLGQ==", |
| | | "dependencies": { |
| | | "follow-redirects": "^1.15.0", |
| | | "follow-redirects": "^1.15.6", |
| | | "form-data": "^4.0.0", |
| | | "proxy-from-env": "^1.1.0" |
| | | } |
| | |
| | | } |
| | | }, |
| | | "node_modules/follow-redirects": { |
| | | "version": "1.15.3", |
| | | "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.3.tgz", |
| | | "integrity": "sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==", |
| | | "funding": [ |
| | | { |
| | | "type": "individual", |
| | | "url": "https://github.com/sponsors/RubenVerborgh" |
| | | } |
| | | ], |
| | | "version": "1.15.6", |
| | | "resolved": "https://registry.npmmirror.com/follow-redirects/-/follow-redirects-1.15.6.tgz", |
| | | "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", |
| | | "engines": { |
| | | "node": ">=4.0" |
| | | }, |
| | |
| | | "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" |
| | | }, |
| | | "axios": { |
| | | "version": "1.5.1", |
| | | "resolved": "https://registry.npmjs.org/axios/-/axios-1.5.1.tgz", |
| | | "integrity": "sha512-Q28iYCWzNHjAm+yEAot5QaAMxhMghWLFVf7rRdwhUI+c2jix2DUXjAHXVi+s1ibs3mjPO/cCgbA++3BjD0vP/A==", |
| | | "version": "1.6.8", |
| | | "resolved": "https://registry.npmmirror.com/axios/-/axios-1.6.8.tgz", |
| | | "integrity": "sha512-v/ZHtJDU39mDpyBoFVkETcd/uNdxrWRrg3bKpOKzXFA6Bvqopts6ALSMU3y6ijYxbw2B+wPrIv46egTzJXCLGQ==", |
| | | "requires": { |
| | | "follow-redirects": "^1.15.0", |
| | | "follow-redirects": "^1.15.6", |
| | | "form-data": "^4.0.0", |
| | | "proxy-from-env": "^1.1.0" |
| | | } |
| | |
| | | } |
| | | }, |
| | | "follow-redirects": { |
| | | "version": "1.15.3", |
| | | "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.3.tgz", |
| | | "integrity": "sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==" |
| | | "version": "1.15.6", |
| | | "resolved": "https://registry.npmmirror.com/follow-redirects/-/follow-redirects-1.15.6.tgz", |
| | | "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==" |
| | | }, |
| | | "form-data": { |
| | | "version": "4.0.0", |
| | |
| | | "dependencies": { |
| | | "@element-plus/icons-vue": "^2.1.0", |
| | | "@vue-macros/reactivity-transform": "^0.3.23", |
| | | "axios": "^1.5.1", |
| | | "axios": "^1.6.8", |
| | | "element-plus": "^2.4.0", |
| | | "moment": "^2.30.1", |
| | | "pinia": "^2.1.6", |
| | |
| | | <script setup> |
| | | import { RouterLink,useRouter} from 'vue-router' |
| | | import useUserInfoStore from '@/stores/userInfo' |
| | | import {useRouter} from 'vue-router' |
| | | import useUserInfoStore from '@/stores/userInfo' |
| | | import userInfo from '@/stores/userInfo' |
| | | import request from "@/utils/request"; |
| | | import {ElMessage} from "element-plus"; |
| | | import {onMounted, reactive, ref, watch} from "vue" |
| | | import {ref, watch} from "vue" |
| | | import deepClone from "@/utils/deepClone" |
| | | import userInfo from '@/stores/userInfo' |
| | | import {Close, Grid, Histogram, MessageBox, SwitchButton} from "@element-plus/icons-vue"; |
| | | const store=userInfo() |
| | | |
| | | const store = userInfo() |
| | | |
| | | const router = useRouter() |
| | | const userStore = useUserInfoStore() |
| | | const user = userStore.user.userName |
| | | |
| | | // store.createWebSocket(); |
| | | function quit(){ |
| | | function quit() { |
| | | userStore.$patch({ |
| | | user:null |
| | | user: null |
| | | }) |
| | | router.push("/login") |
| | | } |
| | | |
| | | |
| | | //提取模块列表 |
| | | let menuList=$ref([]) |
| | | request.get("/menu").then((res) => { |
| | | if(res.code==200){ |
| | | menuList= deepClone(res.data) |
| | | }else{ |
| | | let menuList = $ref([]) |
| | | request.get('/menu/sysMenu/list').then((res) => { |
| | | if (res.code == 200) { |
| | | menuList = deepClone(res.data) |
| | | } else { |
| | | ElMessage.warning(res.msg) |
| | | router.push("/login") |
| | | router.push('/login') |
| | | } |
| | | }) |
| | | |
| | | //获取菜单列表 |
| | | let menuItemList=$ref([]) |
| | | request.get("/menuItem").then((res) => { |
| | | if(res.code==200){ |
| | | menuItemList= deepClone(res.data) |
| | | }else{ |
| | | ElMessage.warning(res.msg) |
| | | router.push("/login") |
| | | } |
| | | }) |
| | | // let menuItemList = $ref([]) |
| | | // request.get('/menuItem').then((res) => { |
| | | // if (res.code == 200) { |
| | | // menuItemList = deepClone(res.data) |
| | | // } else { |
| | | // ElMessage.warning(res.msg) |
| | | // router.push('/login') |
| | | // } |
| | | // }) |
| | | |
| | | const menu = ref(null) |
| | | let indexKey = ref(null) |
| | | |
| | | function handleOpen(key) { |
| | | indexKey.value=key |
| | | indexKey.value = key |
| | | } |
| | | watch(indexKey,(newVal,oldVal) => { |
| | | if(oldVal !== newVal && oldVal !== null){ |
| | | menu.value.close(oldVal) |
| | | } |
| | | |
| | | watch(indexKey, (newVal, oldVal) => { |
| | | if (oldVal !== newVal && oldVal !== null) { |
| | | menu.value.close(oldVal) |
| | | } |
| | | }, |
| | | {deep:true} |
| | | ) |
| | |
| | | <div style="height: 100%;width: 100%;display: flex;background-color: #fff;"> |
| | | <img src="../assets/northGlass.ico" alt="" style="max-width: 100%;max-height: 100%"> |
| | | <h3 style="margin: 1rem ;font-weight: bold;width: 20vw;"> 欢迎{{ user }}使用北玻MES系统!</h3> |
| | | <span style="height: 70%;width: 78vw;margin-top: 1rem;" > |
| | | <el-button class="sys-quit" @click="quit" round> |
| | | <el-icon size="large"><SwitchButton size=""/></el-icon> |
| | | <span style="height: 70%;width: 78vw;margin-top: 1rem;"> |
| | | <el-button class="sys-quit" @click="quit" round> |
| | | <el-icon size="large"><SwitchButton size=""/></el-icon> |
| | | </el-button> |
| | | </span> |
| | | </div> |
| | | </el-header> |
| | | <div id="line"></div> |
| | | <el-container > |
| | | <el-aside width="160px" style="height: 99%; background-color: #fff;" > |
| | | <div class="menu" > |
| | | <div v-for="items in menuList"> |
| | | <div class='menu_title' @click="openMenu(items.id)" > |
| | | <!-- <span class='indicator' >⌵</span> --> |
| | | <!-- <span class='indicator' >≡</span> --> |
| | | <!-- <img src="../assets/9.png" alt="" style="max-width: 50%;max-height: 50%;"> --> |
| | | <span>☰</span> |
| | | {{items.menuName}} |
| | | </div> |
| | | <ul class='enter-x-left' v-show="openFlag==items.id"> |
| | | |
| | | <li v-for="menuItem in menuItemList" |
| | | v-show="items.id==menuItem.menuID" |
| | | style="margin-bottom: 2px" |
| | | > |
| | | <router-link |
| | | :to="{path:menuItem.url}"> |
| | | {{ menuItem.itemName}} |
| | | </router-link> |
| | | |
| | | </li> |
| | | </ul> |
| | | <el-container> |
| | | <el-aside width="160px" |
| | | style="height: 99%; background-color: #fff;"> |
| | | <div class="menu"> |
| | | <div v-for="items in menuList"> |
| | | <div class='menu_title' |
| | | @click="openMenu(items.id)"> |
| | | <!-- <span class='indicator' >⌵</span> --> |
| | | <!-- <span class='indicator' >≡</span> --> |
| | | <!-- <img src="../assets/9.png" alt="" style="max-width: 50%;max-height: 50%;"> --> |
| | | <span>☰</span> |
| | | {{ items.menuName }} |
| | | </div> |
| | | <ul class='enter-x-left' |
| | | v-show="openFlag==items.id"> |
| | | |
| | | <li v-for="menuItem in items.children" |
| | | style="margin-bottom:2px"> |
| | | <router-link :to="{path:menuItem.url}"> |
| | | {{ menuItem.menuName }} |
| | | </router-link> |
| | | |
| | | </li> |
| | | </ul> |
| | | </div> |
| | | </div> |
| | | </el-aside> |
| | | |
| | |
| | | baseURL: `http://${config.serverUrl}`, // 注意!! 这里是全局统一加上了 后端接口前缀 前缀,后端必须进行跨域配置! |
| | | timeout: 5000 |
| | | }) |
| | | |
| | | |
| | | // |
| | | |
| | | |
| | | // request 拦截器 |
| | | // 可以自请求发送前对请求做一些处理 |
| | | // 比如统一加token,对请求参数统一加密 |
| | |
| | | }, error => { |
| | | return Promise.reject(error) |
| | | }); |
| | | |
| | | |
| | | // response 拦截器 |
| | | // 可以在接口响应后统一处理结果 |
| | | request.interceptors.response.use( |
| | |
| | | return Promise.reject(error) |
| | | } |
| | | ) |
| | | |
| | | |
| | | export default request |
| | | |
| | | |
| | | |
| | | export default request |
| | |
| | | |
| | | <script> |
| | | import Swal from 'sweetalert2' |
| | | import request from "@/utils/request"; |
| | | |
| | | |
| | | request.get("/TidyUpGlassModule/CurrentCutTerritory").then((res) => { |
| | | if (res.code == 200) { |
| | | console.log(res.data); |
| | | } else { |
| | | ElMessage.warning(res.msg) |
| | | router.push("/login") |
| | | } |
| | | }); |
| | | |
| | | export default { |
| | | data() { |
| | | return { |
| | |
| | | <script lang="ts" setup> |
| | | import {onMounted, onUnmounted, reactive, ref} from "vue" |
| | | import {useRouter,useRoute } from 'vue-router' |
| | | import {onMounted, onUnmounted, reactive, ref} from 'vue' |
| | | import {useRoute, useRouter} from 'vue-router' |
| | | import type {FormInstance, FormRules} from 'element-plus' |
| | | import { ElMessage } from "element-plus"; |
| | | import { Lock,Avatar } from '@element-plus/icons-vue' |
| | | import {ElMessage} from 'element-plus' |
| | | import request from '@/utils/request' |
| | | import userInfo from '@/stores/userInfo' |
| | | |
| | | |
| | | const store=userInfo() |
| | | let ruleFormRef = ref<FormInstance>() |
| | | const store = userInfo() |
| | | let ruleFormRef = ref<FormInstance>() |
| | | const router = useRouter() |
| | | const route = useRoute() |
| | | |
| | | const userForm = reactive({ |
| | | userId: '', |
| | | pass: '' |
| | | userName: '', |
| | | password: '', |
| | | }) |
| | | |
| | | if (typeof(route.query.id) != "undefined"){ |
| | | if (typeof route.query.id != 'undefined') { |
| | | userForm.userId = <string>route.query.id |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | const rules = reactive<FormRules<typeof userForm>>({ |
| | | userId: [{ validator: validateUser, trigger: 'blur' }], |
| | | pass: [{ validator: validatePass, trigger: 'blur' }] |
| | | userId: [{validator: validateUser, trigger: 'blur'}], |
| | | pass: [{validator: validatePass, trigger: 'blur'}], |
| | | }) |
| | | |
| | | //登陆方法 |
| | |
| | | if (!formEl) return |
| | | formEl.validate((valid) => { |
| | | if (valid) { |
| | | loginLoadings.value=true |
| | | request.post('/user/login', |
| | | userForm).then((res) => { |
| | | if(res['code']==200){ |
| | | store.$patch({user:res.data}) |
| | | loginLoadings.value = true |
| | | request |
| | | .post('/userinfo/login', userForm) |
| | | .then((res) => { |
| | | if (res['code'] == 200) { |
| | | store.$patch({user: res.data}) |
| | | console.log(res.data) |
| | | |
| | | router.push('/main') |
| | | ElMessage.success(`登录成功`) |
| | | } else { |
| | | ElMessage.error(res['msg']) |
| | | loginLoadings.value=false |
| | | return false |
| | | } |
| | | }).catch(error => { |
| | | ElMessage.error("服务器连接失败") |
| | | loginLoadings.value=false |
| | | return false |
| | | }) |
| | | router.push('/main') |
| | | ElMessage.success(`登录成功`) |
| | | } else { |
| | | ElMessage.error(res['msg']) |
| | | loginLoadings.value = false |
| | | return false |
| | | } |
| | | }) |
| | | .catch((error) => { |
| | | ElMessage.error('服务器连接失败') |
| | | loginLoadings.value = false |
| | | return false |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | function register() { |
| | | |
| | | router.push({ |
| | | path:'/register', |
| | | path: '/register', |
| | | }) |
| | | } |
| | | |
| | | let loginLoadings= ref(false) |
| | | let registerLoadings= ref(false) |
| | | let loginLoadings = ref(false) |
| | | let registerLoadings = ref(false) |
| | | |
| | | const keyDown = (e) => { |
| | | // 回车则执行登录方法 enter键的ASCII是13 |
| | |
| | | submitForm(ruleFormRef.value) |
| | | } |
| | | } |
| | | onMounted(()=>{ |
| | | onMounted(() => { |
| | | window.addEventListener('keydown', keyDown) |
| | | }) |
| | | onUnmounted(() => { |
| | | window.removeEventListener('keydown', keyDown) |
| | | }) |
| | | |
| | | </script> |
| | | |
| | | <template> |
| | | <div class="mainDiv" > |
| | | <div class="mainDiv"> |
| | | <div id="main-login"> |
| | | <!-- <img |
| | | style="width: 100%; height: 99vh" |
| | | src="../../src/assets/background.jpg" |
| | | /> --> |
| | | <div> |
| | | <div style="position: absolute; left: 8vw; top: 6vw; "> |
| | | <img src="../../src/assets/3.png"> |
| | | </div> |
| | | <div style="position: absolute; left: 15vw; top: 22vw; font-size: 55px;color: rgba(29, 33, 41, 1);"> |
| | | 北玻MES系统 |
| | | </div> |
| | | </div> |
| | | <div id="div-login"> |
| | | <el-form |
| | | @submit.native.prevent |
| | | ref="ruleFormRef" |
| | | :model="userForm" |
| | | status-icon |
| | | :rules="rules" |
| | | > |
| | | <div id="center"> |
| | | <div style="color: rgba(78, 89, 105, 1);margin-bottom: 10px;">账号</div> |
| | | <el-form-item prop="userId"> |
| | | <el-input |
| | | style="width: 340px;" |
| | | v-model="userForm.userId" |
| | | type="text" |
| | | autocomplete="off" |
| | | :prefix-icon="Avatar" |
| | | placeholder="请输入账号" |
| | | /> |
| | | </el-form-item> |
| | | <div style="color: rgba(78, 89, 105, 1);margin-bottom: 10px;">密码</div> |
| | | <el-form-item prop="pass"> |
| | | <el-input |
| | | style="width: 340px;" |
| | | v-model="userForm.pass" |
| | | type="password" |
| | | autocomplete="off" |
| | | :prefix-icon="Lock" |
| | | show-password |
| | | placeholder="请输入密码" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item id="submitForm"> |
| | | <el-button |
| | | :loading="loginLoadings" |
| | | type="primary" |
| | | native-type="submit" |
| | | @click="submitForm(ruleFormRef)" |
| | | @keyup.enter.native="keyDown(e)" |
| | | plain |
| | | >登录 |
| | | </el-button> |
| | | <el-button |
| | | :loading="registerLoadings" |
| | | type="primary" |
| | | @click="register" |
| | | plain |
| | | >注册 |
| | | </el-button> |
| | | |
| | | </el-form-item> |
| | | <div style="position: absolute; left: 8vw; top: 6vw; "> |
| | | <img src="../../src/assets/3.png"> |
| | | </div> |
| | | <div style="position: absolute; left: 15vw; top: 22vw; font-size: 55px;color: rgba(29, 33, 41, 1);"> |
| | | 北玻MES系统 |
| | | </div> |
| | | </div> |
| | | <div id="div-login"> |
| | | <el-form @submit.native.prevent |
| | | ref="ruleFormRef" |
| | | :model="userForm" |
| | | status-icon |
| | | :rules="rules"> |
| | | <div id="center"> |
| | | <div style="color: rgba(78, 89, 105, 1);margin-bottom: 10px;">账号</div> |
| | | <el-form-item prop="userId"> |
| | | <el-input style="width: 340px;" |
| | | v-model="userForm.userName" |
| | | type="text" |
| | | autocomplete="off" |
| | | :prefix-icon="Avatar" |
| | | placeholder="请输入账号"/> |
| | | </el-form-item> |
| | | <div style="color: rgba(78, 89, 105, 1);margin-bottom: 10px;">密码</div> |
| | | <el-form-item prop="pass"> |
| | | <el-input style="width: 340px;" |
| | | v-model="userForm.password" |
| | | type="password" |
| | | autocomplete="off" |
| | | :prefix-icon="Lock" |
| | | show-password |
| | | placeholder="请输入密码"/> |
| | | </el-form-item> |
| | | <el-form-item id="submitForm"> |
| | | <el-button :loading="loginLoadings" |
| | | type="primary" |
| | | native-type="submit" |
| | | @click="submitForm(ruleFormRef)" |
| | | @keyup.enter.native="keyDown(e)" |
| | | plain>登录 |
| | | </el-button> |
| | | <el-button :loading="registerLoadings" |
| | | type="primary" |
| | | @click="register" |
| | | plain>注册 |
| | | </el-button> |
| | | |
| | | </el-form-item> |
| | | </div> |
| | | </el-form> |
| | | </div> |
| | | </div> |
| | |
| | | </template> |
| | | |
| | | <style scoped> |
| | | .mainDiv{ |
| | | .mainDiv { |
| | | overflow: hidden; |
| | | min-width: 718px; |
| | | background-image: url("../../src/assets/background.jpg"); |
| | | |
| | | background-image: url('../../src/assets/background.jpg'); |
| | | } |
| | | #main-login{ |
| | | |
| | | #main-login { |
| | | margin: 150px auto 0 auto; |
| | | height: 70vh; |
| | | width: 80vw; |
| | | } |
| | | #img-div{ |
| | | |
| | | #img-div { |
| | | width: 55%; |
| | | height: 100%; |
| | | display: flex; |
| | |
| | | align-items: center; |
| | | float: left; |
| | | } |
| | | #img-pic{ |
| | | |
| | | #img-pic { |
| | | max-height: 90%; |
| | | max-width: 100%; |
| | | } |
| | | #div-login{ |
| | | |
| | | #div-login { |
| | | margin-top: 5%; |
| | | /* margin-top: 20%; */ |
| | | /* margin-left: 650px; */ |
| | |
| | | height: 60%; |
| | | min-width: 318px; |
| | | border-radius: 4px; |
| | | box-shadow: 0 8px 16px 0 rgba(0,0,0,0), 0 6px 5px 0 rgba(0,0,0,0.19); |
| | | box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0), 0 6px 5px 0 rgba(0, 0, 0, 0.19); |
| | | } |
| | | #center{ |
| | | |
| | | #center { |
| | | margin-top: -30px; |
| | | } |
| | | .el-form{ |
| | | |
| | | .el-form { |
| | | width: 60%; |
| | | margin: 20% auto auto; |
| | | } |
| | | |
| | | #submitForm { |
| | | display: flex; |
| | | justify-content: space-evenly; |
| | | margin-top: 2rem; |
| | | } |
| | | :deep(.el-form-item__content){ |
| | | flex: unset |
| | | |
| | | :deep(.el-form-item__content) { |
| | | flex: unset; |
| | | } |
| | | </style> |
| | |
| | | const dialogFormVisible = ref(false) |
| | | const add = ref(false) |
| | | const adda = ref(false) |
| | | |
| | | const value = ref('') |
| | | import request from "@/utils/request" |
| | | |
| | | request.post(`/LoadGlass/SelectAll`).then((res) => { |
| | | console.log(555555555555); |
| | | if (res.code == 200) { |
| | | console.log(1111); |
| | | // console.log(res.data); |
| | | } else { |
| | | ElMessage.warning(res.msg) |
| | | router.push("/login") |
| | | } |
| | | }); |
| | | |
| | | // request.get("/LoadGlass/SelectAll").then((res) => { |
| | | // if (res.code == 200) { |
| | | // console.log(res.data); |
| | | // } else { |
| | | // ElMessage.warning(res.msg) |
| | | // router.push("/login") |
| | | // } |
| | | // }); |
| | | |
| | | interface User { |
| | | id: string |
| | |
| | | } |
| | | #parent{ |
| | | position: relative; |
| | | width: 1500px; |
| | | } |
| | | #overlay{ |
| | | position: absolute; |
| | |
| | | CanvaDraws(id,Datas,StoveCount) { |
| | | //var StoveCount=43;//炉数 |
| | | var ArrangementMode='linefeed';//排布方式:linefeed(换行) /Wholeline 整行 |
| | | var RowMaxCount=4;//每行最多显示的图数 |
| | | var RowMaxCount=3;//每行最多显示的图数 |
| | | var StoveWidth=3000; //实际炉宽 2850 |
| | | var StoveLength=5500;//实际炉长 5000 |
| | | var StoveColor='#CFC8C5';//炉子背景颜色 |
| | |
| | | import { fileURLToPath, URL } from 'node:url' |
| | | import {fileURLToPath, URL} from 'node:url' |
| | | |
| | | import { defineConfig } from 'vite' |
| | | import {defineConfig} from 'vite' |
| | | import vue from '@vitejs/plugin-vue' |
| | | import ReactivityTransform from '@vue-macros/reactivity-transform/vite' |
| | | |
| | |
| | | https: false, |
| | | proxy: { |
| | | '/api': { |
| | | target: 'http://localhost:8080/mesModuleTools', |
| | | target: 'http://localhost:8081/', |
| | | changeOrigin: true, |
| | | rewrite: (path) => path.replace(/^\/api/, '/mesModuleTools'), |
| | | rewrite: (path) => path.replace(/^\/api/, '/'), |
| | | }, |
| | | '/api2': { |
| | | target: 'http://localhost:8081/mesModuleTools', |
| | |
| | | <packaging>pom</packaging> |
| | | <modules> |
| | | <module>servicebase</module> |
| | | <!-- <module>springsecurity</module>--> |
| | | <module>springsecurity</module> |
| | | </modules> |
| | | <properties> |
| | | <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
| | |
| | | <dependency> |
| | | <groupId>com.baomidou</groupId> |
| | | <artifactId>mybatis-plus-boot-starter</artifactId> |
| | | <version>3.2.0</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.baomidou</groupId> |
| | | <artifactId>dynamic-datasource-spring-boot-starter</artifactId> |
| | | <version>3.2.0</version> |
| | | </dependency> |
| | | |
| | |
| | | <groupId>org.apache.velocity</groupId> |
| | | <artifactId>velocity-engine-core</artifactId> |
| | | <version>2.0</version> |
| | | <exclusions> |
| | | <exclusion> |
| | | <groupId>com.alibaba</groupId> |
| | | <artifactId>fastjson</artifactId> |
| | | </exclusion> |
| | | </exclusions> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.alibaba</groupId> |
| | |
| | | <version>1.1.8</version> |
| | | </dependency> |
| | | |
| | | <!-- 数据库文档--> |
| | | <dependency> |
| | | <groupId>com.alibaba</groupId> |
| | | <artifactId>fastjson</artifactId> |
| | | <version>1.2.60</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.apache.poi</groupId> |
| | | <artifactId>poi</artifactId> |
| | | <version>3.17</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.apache.poi</groupId> |
| | | <artifactId>poi-ooxml</artifactId> |
| | | <version>3.17</version> |
| | | </dependency> |
| | | |
| | | <!-- 数据库设计文档生成工具--> |
| | | <dependency> |
| | | <groupId>cn.smallbun.screw</groupId> |
| | | <artifactId>screw-core</artifactId> |
| | | <version>1.0.5</version> |
| | | <exclusions> |
| | | <exclusion> |
| | | <groupId>com.alibaba</groupId> |
| | | <artifactId>fastjson</artifactId> |
| | | </exclusion> |
| | | </exclusions> |
| | | </dependency> |
| | | <!-- 2.0~2.2 Knife4j 2.0.0 ~ 2.0.6--> |
| | | <!-- <dependency>--> |
| | |
| | | <version>2.7.0</version> |
| | | </dependency> |
| | | |
| | | |
| | | <!--jwt 项目生成token--> |
| | | <dependency> |
| | | <groupId>com.auth0</groupId> |
| | | <artifactId>java-jwt</artifactId> |
| | | <version>3.10.3</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.assertj</groupId> |
| | | <artifactId>assertj-core</artifactId> |
| | | </dependency> |
| | | <!--hutool java验证方法类--> |
| | | <dependency> |
| | | <groupId>cn.hutool</groupId> |
| | |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-starter-data-redis</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springframework.session</groupId> |
| | | <artifactId>spring-session-data-redis</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-starter-security</artifactId> |
| | | <groupId>com.alibaba</groupId> |
| | | <artifactId>fastjson</artifactId> |
| | | <version>1.2.33</version> |
| | | </dependency> |
| | | |
| | | </dependencies> |
| | | |
| | | |
| | |
| | | |
| | | import com.mes.common.interceptor.JwtInterceptor; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.web.servlet.config.annotation.CorsRegistry; |
| | | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; |
| | | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | @Configuration |
| | | |
| | | public class InterceptorConfig implements WebMvcConfigurer { |
| | | @Resource |
| | | private JwtInterceptor jwtInterceptor; |
| | | |
| | | @Override |
| | | public void addInterceptors(InterceptorRegistry registry) { |
| | | registry.addInterceptor(jwtInterceptor) |
| | |
| | | .excludePathPatterns("/user/login", |
| | | "/user/register", |
| | | "/swagger-resources/**" |
| | | ,"/webjars/**" |
| | | ,"/v2/**" |
| | | ,"/swagger-ui.html/**" |
| | | ,"/swagger-ui.html#/**"); |
| | | , "/webjars/**" |
| | | , "/v2/**" |
| | | , "/swagger-ui.html/**" |
| | | , "/swagger-ui.html#/**"); |
| | | } |
| | | |
| | | @Override |
| | | public void addCorsMappings(CorsRegistry registry) { |
| | | // 设置允许跨域的路径 |
| | | registry.addMapping("/**") |
| | | // 设置允许跨域请求的域名 |
| | | // .allowedOriginPatterns("*") |
| | | // 是否允许cookie |
| | | .allowCredentials(true) |
| | | // 设置允许的请求方式 |
| | | .allowedMethods("GET", "POST", "DELETE", "PUT") |
| | | // 设置允许的header属性 |
| | | .allowedHeaders("*") |
| | | // 跨域允许时间 |
| | | .maxAge(3600); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.mes.device; |
| | | |
| | | import com.mes.tools.InitUtil; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | public class PLCAutoMes extends Thread { |
| | | |
| | | // 用于存储应用程序的配置信息 |
| | | private Configuration config; |
| | | private static InitUtil initUtil; |
| | | |
| | | |
| | | // 单例实例 |
| | | private static PLCAutoMes instance; |
| | | private static String PlcMes = PLCAutoMes.class.getResource("/JsonFile/PlcMes.json").getPath(); |
| | | private static String PlcRead = PLCAutoMes.class.getResource("/JsonFile/PlcRead.json").getPath(); |
| | | private static String Plcframe = PLCAutoMes.class.getResource("/JsonFile/Plcframe.json").getPath(); |
| | | // private static String PlcParameter = PLCAutomaticParameterSettingReview2.class |
| | | // .getResource("/JsonFile/PlcParameter.json").getPath(); |
| | | // private static String PlcSign = PLCAutomaticParameterSettingReview2.class.getResource("/JsonFile/PlcSign.json") |
| | | // .getPath(); |
| | | // private static String PlcState = PLCAutomaticParameterSettingReview2.class.getResource("/JsonFile/PlcState.json") |
| | | // .getPath(); |
| | | private static String PlcAlarm = PLCAutoMes.class.getResource("/JsonFile/PlcAlarm.json").getPath(); |
| | | // private static String PlcTest = PLCAutoMes.class.getResource("/JsonFile/PlcTest.json").getPath(); |
| | | |
| | | // 调用initword方法 |
| | | |
| | | // |
| | | // public static PlcBitObject plcPlcAlarm = initUtil.initbit(PlcAlarm); |
| | | public static PlcParameterObject PlcMesObject = initUtil.initword(PlcMes); |
| | | public static PlcParameterObject PlcReadObject = initUtil.initword(PlcRead); |
| | | public static PlcParameterObject PlcframeObject = initUtil.initword(Plcframe); |
| | | |
| | | // 私有构造函数 |
| | | public PLCAutoMes() throws IOException { |
| | | |
| | | initUtil = new InitUtil(); |
| | | } |
| | | |
| | | // 获取单例实例 |
| | | public static synchronized PLCAutoMes getInstance() throws IOException { |
| | | if (instance == null) { |
| | | instance = new PLCAutoMes(); |
| | | } |
| | | return instance; |
| | | } |
| | | |
| | | @Override |
| | | public void run() { |
| | | while (this != null) { |
| | | try { |
| | | Thread.sleep(100); |
| | | |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | // System.out.println(jsonFilePath); |
| | | |
| | | // readAndUpdateWordValues(PlcReadObject); |
| | | InitUtil.readAndUpdateWordValues(PlcMesObject); |
| | | // readAndUpdateWordValues(PlcframeObject); |
| | | // readAndUpdateWordValues(PlcframeObject); |
| | | |
| | | // readAndUpdateWordValues(plcStateObject); |
| | | // int index = PlcMesObject.getPlcParameter("AddStart").getAddressIndex(); |
| | | // System.out.println(index); |
| | | // PlcMesObject.getPlcParameter("AddStart").getAddress(index); |
| | | // System.out.println(PlcMesObject.getPlcParameter("AddStart").getAddress(index)); |
| | | List<String> addresses = new ArrayList<>(); |
| | | addresses.add("FeedID"); |
| | | addresses.add("AddStart"); |
| | | // System.out.println(addresses); |
| | | // System.out.println(PlcMesObject.getPlcParameterValues(addresses)); |
| | | List<String> addresses2 = new ArrayList<>(); |
| | | addresses2.add("FeedID"); |
| | | addresses2.add("FeedCarStatus"); |
| | | |
| | | // System.out.println(PlcReadObject.getPlcParameterValues(addresses2)); |
| | | |
| | | } |
| | | } |
| | | } |
File was renamed from hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/tools/InitUtil.java |
| | |
| | | package com.mes.tools;
|
| | |
|
| | | import cn.hutool.json.JSONArray;
|
| | | import cn.hutool.json.JSONObject;
|
| | | import com.mes.device.PlcBitInfo;
|
| | | import com.mes.device.PlcBitObject;
|
| | | import com.mes.device.PlcParameterInfo;
|
| | | import com.mes.device.PlcParameterObject;
|
| | |
|
| | | import java.io.BufferedReader;
|
| | | import java.io.FileReader;
|
| | | import java.io.IOException;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Arrays;
|
| | | import java.util.List;
|
| | |
|
| | | public class InitUtil {
|
| | | //初始化word
|
| | | public static PlcParameterObject initword(String jsonFilePath) {
|
| | | try {
|
| | | FileReader fileReader = new FileReader(jsonFilePath);
|
| | | BufferedReader bufferedReader = new BufferedReader(fileReader);
|
| | |
|
| | | StringBuilder content = new StringBuilder();
|
| | | String line;
|
| | |
|
| | | while ((line = bufferedReader.readLine()) != null) {
|
| | | content.append(line);
|
| | | }
|
| | |
|
| | | bufferedReader.close();
|
| | | fileReader.close();
|
| | |
|
| | | JSONObject jsonfileobj = new JSONObject(content.toString());
|
| | | JSONArray jsonArray = jsonfileobj.getJSONArray("parameteInfor");
|
| | | PlcParameterObject plcParameterObject = new PlcParameterObject();
|
| | | plcParameterObject.setPlcAddressBegin(jsonfileobj.getStr("plcAddressBegin"));//设置起始位地址
|
| | | plcParameterObject.setPlcAddressLength(Integer.valueOf(jsonfileobj.getStr("plcAddressLenght")));//设置地址长度
|
| | |
|
| | | for (int i = 0; i < jsonArray.size(); i++) {
|
| | | JSONObject parameterObj = jsonArray.getJSONObject(i);
|
| | | PlcParameterInfo plcParameterInfo = new PlcParameterInfo(jsonfileobj.getStr("plcAddressBegin")); //参数实例
|
| | | String codeid = parameterObj.getStr("codeId");
|
| | | plcParameterInfo.setCodeId(codeid);
|
| | | plcParameterInfo.setAddressIndex(Integer.valueOf(parameterObj.getStr("addressIndex")));
|
| | | //plcParameterInfo.setRatio(Integer.valueOf(parameterObj.getStr("ratio")));
|
| | | plcParameterInfo.setAddressLength(Integer.valueOf(parameterObj.getStr("addressLenght")));
|
| | | plcParameterInfo.setUnit(parameterObj.getStr("unit"));
|
| | | plcParameterObject.addPlcParameter(plcParameterInfo);
|
| | | }
|
| | | // byte[] getplcvlues = {0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02};
|
| | | // byte[] getplcvlues = S7control.getinstance().ReadByte(plcParameterObject.getPlcAddressBegin(), plcParameterObject.getPlcAddressLength());
|
| | | // plcParameterObject.setPlcParameterList(getplcvlues);
|
| | |
|
| | | return plcParameterObject;
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | //初始化bit
|
| | | public static PlcBitObject initbit(String jsonFilePath) {
|
| | | PlcBitObject plcBitObject = new PlcBitObject();
|
| | |
|
| | | try {
|
| | | FileReader fileReader = new FileReader(jsonFilePath);
|
| | | BufferedReader bufferedReader = new BufferedReader(fileReader);
|
| | |
|
| | | StringBuilder content = new StringBuilder();
|
| | | String line;
|
| | |
|
| | | while ((line = bufferedReader.readLine()) != null) {
|
| | | content.append(line);
|
| | | }
|
| | |
|
| | | bufferedReader.close();
|
| | | fileReader.close();
|
| | |
|
| | | JSONObject jsonfileobj = new JSONObject(content.toString());
|
| | | JSONArray jsonArray = jsonfileobj.getJSONArray("parameteInfor");
|
| | | plcBitObject.setPlcAddressBegin(jsonfileobj.getStr("plcAddressBegin"));//设置起始位地址
|
| | | plcBitObject.setPlcAddressLength(Integer.valueOf(jsonfileobj.getStr("plcAddressLenght")));//设置地址长度
|
| | |
|
| | | for (int i = 0; i < jsonArray.size(); i++) {
|
| | | JSONObject parameterObj = jsonArray.getJSONObject(i);
|
| | |
|
| | | PlcBitInfo plcBitInfo = new PlcBitInfo(jsonfileobj.getStr("plcAddressBegin")); //参数实例
|
| | | String codeid = parameterObj.getStr("codeId");
|
| | | plcBitInfo.setCodeId(codeid);
|
| | | plcBitInfo.setAddressIndex(Integer.valueOf(parameterObj.getStr("addressIndex")));
|
| | |
|
| | | plcBitObject.addPlcBit(plcBitInfo);
|
| | | }
|
| | | System.out.println("");
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | //Boolean[] values1 = { false, true, true, true, false, false, true, false,
|
| | | // false, true ,true };
|
| | | // List<Boolean> getplcvlues = new ArrayList<>(Arrays.asList(values1));
|
| | |
|
| | | // List<Boolean> getplcvlues = S7control.getinstance().ReadBits(plcBitObject.getPlcAddressBegin(), plcBitObject.getPlcAddressLength());
|
| | | // plcBitObject.setPlcBitList(getplcvlues);
|
| | | return plcBitObject;
|
| | | }
|
| | |
|
| | | //
|
| | | public static void readAndUpdateBitValues(PlcBitObject plcBitObject) {
|
| | |
|
| | | Boolean[] values1 = { false, true, true, true, false, false, true, false,
|
| | | false, true ,true };
|
| | | List<Boolean> getplcvlues = new ArrayList<>(Arrays.asList(values1));
|
| | | //List<Boolean> getplcvlues = S7control.getinstance().ReadBits(plcBitObject.getPlcAddressBegin(), plcBitObject.getPlcAddressLength());
|
| | | plcBitObject.setPlcBitList(getplcvlues);
|
| | | }
|
| | |
|
| | |
|
| | | public static void readAndUpdateWordValues(PlcParameterObject plcParameterObject) {
|
| | |
|
| | | byte[] getplcvlues = {0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03,0x03};
|
| | | // byte[] getplcvlues = MockS7PLC.getInstance().readByte(plcParameterObject.getPlcAddressBegin(), plcParameterObject.getPlcAddressLength());
|
| | | plcParameterObject.setPlcParameterList(getplcvlues);
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | | }
|
| | | package com.mes.tools; |
| | | |
| | | import cn.hutool.json.JSONArray; |
| | | import cn.hutool.json.JSONObject; |
| | | import com.mes.device.PlcBitInfo; |
| | | import com.mes.device.PlcBitObject; |
| | | import com.mes.device.PlcParameterInfo; |
| | | import com.mes.device.PlcParameterObject; |
| | | |
| | | import java.io.BufferedReader; |
| | | import java.io.FileReader; |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | public class InitUtil { |
| | | //初始化word |
| | | public static PlcParameterObject initword(String jsonFilePath) { |
| | | try { |
| | | FileReader fileReader = new FileReader(jsonFilePath); |
| | | BufferedReader bufferedReader = new BufferedReader(fileReader); |
| | | |
| | | StringBuilder content = new StringBuilder(); |
| | | String line; |
| | | |
| | | while ((line = bufferedReader.readLine()) != null) { |
| | | content.append(line); |
| | | } |
| | | |
| | | bufferedReader.close(); |
| | | fileReader.close(); |
| | | |
| | | JSONObject jsonfileobj = new JSONObject(content.toString()); |
| | | JSONArray jsonArray = jsonfileobj.getJSONArray("parameteInfor"); |
| | | PlcParameterObject plcParameterObject = new PlcParameterObject(); |
| | | plcParameterObject.setPlcAddressBegin(jsonfileobj.getStr("plcAddressBegin"));//设置起始位地址 |
| | | plcParameterObject.setPlcAddressLength(Integer.valueOf(jsonfileobj.getStr("plcAddressLenght")));//设置地址长度 |
| | | |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | JSONObject parameterObj = jsonArray.getJSONObject(i); |
| | | PlcParameterInfo plcParameterInfo = new PlcParameterInfo(jsonfileobj.getStr("plcAddressBegin")); //参数实例 |
| | | String codeid = parameterObj.getStr("codeId"); |
| | | plcParameterInfo.setCodeId(codeid); |
| | | plcParameterInfo.setAddressIndex(Integer.valueOf(parameterObj.getStr("addressIndex"))); |
| | | //plcParameterInfo.setRatio(Integer.valueOf(parameterObj.getStr("ratio"))); |
| | | plcParameterInfo.setAddressLength(Integer.valueOf(parameterObj.getStr("addressLenght"))); |
| | | plcParameterInfo.setUnit(parameterObj.getStr("unit")); |
| | | plcParameterObject.addPlcParameter(plcParameterInfo); |
| | | } |
| | | // byte[] getplcvlues = {0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02}; |
| | | // byte[] getplcvlues = S7control.getinstance().ReadByte(plcParameterObject.getPlcAddressBegin(), plcParameterObject.getPlcAddressLength()); |
| | | // plcParameterObject.setPlcParameterList(getplcvlues); |
| | | |
| | | return plcParameterObject; |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | //初始化bit |
| | | public static PlcBitObject initbit(String jsonFilePath) { |
| | | PlcBitObject plcBitObject = new PlcBitObject(); |
| | | |
| | | try { |
| | | FileReader fileReader = new FileReader(jsonFilePath); |
| | | BufferedReader bufferedReader = new BufferedReader(fileReader); |
| | | |
| | | StringBuilder content = new StringBuilder(); |
| | | String line; |
| | | |
| | | while ((line = bufferedReader.readLine()) != null) { |
| | | content.append(line); |
| | | } |
| | | |
| | | bufferedReader.close(); |
| | | fileReader.close(); |
| | | |
| | | JSONObject jsonfileobj = new JSONObject(content.toString()); |
| | | JSONArray jsonArray = jsonfileobj.getJSONArray("parameteInfor"); |
| | | plcBitObject.setPlcAddressBegin(jsonfileobj.getStr("plcAddressBegin"));//设置起始位地址 |
| | | plcBitObject.setPlcAddressLength(Integer.valueOf(jsonfileobj.getStr("plcAddressLenght")));//设置地址长度 |
| | | |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | JSONObject parameterObj = jsonArray.getJSONObject(i); |
| | | |
| | | PlcBitInfo plcBitInfo = new PlcBitInfo(jsonfileobj.getStr("plcAddressBegin")); //参数实例 |
| | | String codeid = parameterObj.getStr("codeId"); |
| | | plcBitInfo.setCodeId(codeid); |
| | | plcBitInfo.setAddressIndex(Integer.valueOf(parameterObj.getStr("addressIndex"))); |
| | | |
| | | plcBitObject.addPlcBit(plcBitInfo); |
| | | } |
| | | System.out.println(""); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | //Boolean[] values1 = { false, true, true, true, false, false, true, false, |
| | | // false, true ,true }; |
| | | // List<Boolean> getplcvlues = new ArrayList<>(Arrays.asList(values1)); |
| | | |
| | | // List<Boolean> getplcvlues = S7control.getinstance().ReadBits(plcBitObject.getPlcAddressBegin(), plcBitObject.getPlcAddressLength()); |
| | | // plcBitObject.setPlcBitList(getplcvlues); |
| | | return plcBitObject; |
| | | } |
| | | |
| | | // |
| | | public static void readAndUpdateBitValues(PlcBitObject plcBitObject) { |
| | | |
| | | Boolean[] values1 = { false, true, true, true, false, false, true, false, |
| | | false, true ,true }; |
| | | List<Boolean> getplcvlues = new ArrayList<>(Arrays.asList(values1)); |
| | | //List<Boolean> getplcvlues = S7control.getinstance().ReadBits(plcBitObject.getPlcAddressBegin(), plcBitObject.getPlcAddressLength()); |
| | | plcBitObject.setPlcBitList(getplcvlues); |
| | | } |
| | | |
| | | |
| | | public static void readAndUpdateWordValues(PlcParameterObject plcParameterObject) { |
| | | |
| | | byte[] getplcvlues = {0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03,0x03}; |
| | | // byte[] getplcvlues = MockS7PLC.getInstance().readByte(plcParameterObject.getPlcAddressBegin(), plcParameterObject.getPlcAddressLength()); |
| | | plcParameterObject.setPlcParameterList(getplcvlues); |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | <version>1.0-SNAPSHOT</version> |
| | | </dependency> |
| | | <!-- Spring Security依赖 --> |
| | | <!-- <dependency>--> |
| | | <!-- <groupId>org.springframework.boot</groupId>--> |
| | | <!-- <artifactId>spring-boot-starter-security</artifactId>--> |
| | | <!-- </dependency>--> |
| | | <dependency> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-starter-security</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- <dependency>--> |
| | | <!-- <groupId>io.jsonwebtoken</groupId>--> |
| | | <!-- <artifactId>jjwt</artifactId>--> |
| | | <!-- </dependency>--> |
| | | <dependency> |
| | | <groupId>io.jsonwebtoken</groupId> |
| | | <artifactId>jjwt</artifactId> |
| | | <version>0.9.0</version> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | </project> |
New file |
| | |
| | | package com.mes.common.config; |
| | | |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.web.cors.CorsConfiguration; |
| | | import org.springframework.web.cors.reactive.CorsWebFilter; |
| | | import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource; |
| | | import org.springframework.web.servlet.config.annotation.CorsRegistry; |
| | | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
| | | |
| | | /** |
| | | * @Author : zhoush |
| | | * @Date: 2024/3/25 14:13 |
| | | * @Description: |
| | | */ |
| | | @Configuration |
| | | public class MyCorsConfig { |
| | | |
| | | @Bean |
| | | public WebMvcConfigurer corsConfigurer() { |
| | | return new WebMvcConfigurer() { |
| | | @Override |
| | | public void addCorsMappings(CorsRegistry registry) { |
| | | registry.addMapping("/**"); |
| | | } |
| | | }; |
| | | } |
| | | |
| | | @Bean |
| | | public CorsWebFilter corsWebFilter() { |
| | | UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); |
| | | |
| | | CorsConfiguration corsConfiguration = new CorsConfiguration(); |
| | | |
| | | //1、配置跨域 |
| | | corsConfiguration.addAllowedHeader("*"); |
| | | corsConfiguration.addAllowedMethod("*"); |
| | | corsConfiguration.addAllowedOrigin("*"); |
| | | corsConfiguration.setAllowCredentials(true); |
| | | |
| | | source.registerCorsConfiguration("/**", corsConfiguration); |
| | | return new CorsWebFilter(source); |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.mes.common.config; |
| | | |
| | | import com.mes.common.utils.FastJsonRedisSerializer; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.data.redis.connection.RedisConnectionFactory; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.data.redis.serializer.StringRedisSerializer; |
| | | |
| | | /** |
| | | * @Author : zhoush |
| | | * @Date: 2024/4/9 19:13 |
| | | * @Description: |
| | | */ |
| | | @Configuration |
| | | public class RedisConfig { |
| | | |
| | | @Bean |
| | | @SuppressWarnings(value = {"unchecked", "rawtypes"}) |
| | | public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory connectionFactory) { |
| | | RedisTemplate<Object, Object> template = new RedisTemplate<>(); |
| | | template.setConnectionFactory(connectionFactory); |
| | | |
| | | FastJsonRedisSerializer serializer = new FastJsonRedisSerializer(Object.class); |
| | | |
| | | // 使用StringRedisSerializer来序列化和反序列化redis的key值 |
| | | template.setKeySerializer(new StringRedisSerializer()); |
| | | template.setValueSerializer(serializer); |
| | | |
| | | // Hash的key也采用StringRedisSerializer的序列化方式 |
| | | template.setHashKeySerializer(new StringRedisSerializer()); |
| | | template.setHashValueSerializer(serializer); |
| | | |
| | | template.afterPropertiesSet(); |
| | | return template; |
| | | } |
| | | } |
New file |
| | |
| | | package com.mes.common.config; |
| | | |
| | | |
| | | import com.mes.common.filter.JwtAuthenticationTokenFilter; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.security.authentication.AuthenticationManager; |
| | | import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; |
| | | import org.springframework.security.config.annotation.web.builders.HttpSecurity; |
| | | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; |
| | | import org.springframework.security.config.http.SessionCreationPolicy; |
| | | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; |
| | | import org.springframework.security.crypto.password.PasswordEncoder; |
| | | |
| | | @Configuration |
| | | //@EnableWebSecurity |
| | | @EnableGlobalMethodSecurity(prePostEnabled = true) |
| | | public class TokenWebSecurityConfig extends WebSecurityConfigurerAdapter { |
| | | @Autowired |
| | | private JwtAuthenticationTokenFilter jwtAuthenticationTokenFilter; |
| | | |
| | | @Bean |
| | | public PasswordEncoder passwordEncoder() { |
| | | return new BCryptPasswordEncoder(); |
| | | } |
| | | |
| | | /** |
| | | * 配置过滤规则 |
| | | */ |
| | | @Override |
| | | protected void configure(HttpSecurity http) throws Exception { |
| | | http |
| | | //关闭csrf |
| | | .csrf().disable() |
| | | //不通过Session获取SecurityContext |
| | | .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS) |
| | | .and() |
| | | .authorizeRequests() |
| | | // 对于登录接口 允许匿名访问 |
| | | .antMatchers("/userinfo/login").anonymous() |
| | | .antMatchers("/hello").permitAll() |
| | | // 除上面外的所有请求全部需要鉴权认证 |
| | | .anyRequest().permitAll(); |
| | | // http.addFilterBefore(jwtAuthenticationTokenFilter, UsernamePasswordAuthenticationFilter.class); |
| | | } |
| | | |
| | | @Bean |
| | | @Override |
| | | public AuthenticationManager authenticationManagerBean() throws Exception { |
| | | return super.authenticationManagerBean(); |
| | | } |
| | | } |
New file |
| | |
| | | package com.mes.common.filter; |
| | | |
| | | import com.mes.common.utils.JwtUtil; |
| | | import com.mes.common.utils.RedisUtil; |
| | | import com.mes.menu.mapper.SysMenuMapper; |
| | | import com.mes.userinfo.entity.LoginUser; |
| | | import io.jsonwebtoken.Claims; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; |
| | | import org.springframework.security.core.GrantedAuthority; |
| | | import org.springframework.security.core.authority.SimpleGrantedAuthority; |
| | | import org.springframework.security.core.context.SecurityContextHolder; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.filter.OncePerRequestFilter; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.FilterChain; |
| | | import javax.servlet.ServletException; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @Author : zhoush |
| | | * @Date: 2024/4/10 9:42 |
| | | * @Description: |
| | | */ |
| | | @Component |
| | | public class JwtAuthenticationTokenFilter extends OncePerRequestFilter { |
| | | // 此处解释为什么不去实现Filter接口,因为在某些情况下会过滤两次,执行两次Filter里面的方法,所以我们选择继承SpringSecurity中的OncePerRequestFilter |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | | @Resource |
| | | private SysMenuMapper menuMapper; |
| | | |
| | | @Override |
| | | protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { |
| | | //获取token |
| | | String token = request.getHeader("token"); |
| | | if (!StringUtils.hasText(token)) { |
| | | //放行 |
| | | filterChain.doFilter(request, response); |
| | | return; // 此处加上return好处是后面结果返回的时候就不会再走一遍此过滤器的方法了 |
| | | } |
| | | //解析token |
| | | String userid; |
| | | try { |
| | | Claims claims = JwtUtil.parseJWT(token); |
| | | userid = claims.getSubject(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | throw new RuntimeException("token非法"); |
| | | } |
| | | //从redis中获取用户信息 |
| | | String redisKey = "login:" + userid; |
| | | LoginUser loginUser = redisUtil.getCacheObject(redisKey); |
| | | if (Objects.isNull(loginUser)) { |
| | | throw new RuntimeException("用户未登录"); |
| | | } |
| | | //存入SecurityContextHolder,以供后面的过滤器使用 |
| | | List<String> permissionKeyList = menuMapper.selectPermsByUserId(Long.parseLong(userid)); |
| | | List<GrantedAuthority> authorities = permissionKeyList.stream(). |
| | | map(SimpleGrantedAuthority::new) |
| | | .collect(Collectors.toList()); |
| | | UsernamePasswordAuthenticationToken authenticationToken = |
| | | new UsernamePasswordAuthenticationToken(loginUser, null, authorities); |
| | | SecurityContextHolder.getContext().setAuthentication(authenticationToken); |
| | | //放行 |
| | | filterChain.doFilter(request, response); |
| | | } |
| | | } |
New file |
| | |
| | | package com.mes.common.handler; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.mes.common.utils.WebUtils; |
| | | import com.mes.utils.Result; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.security.access.AccessDeniedException; |
| | | import org.springframework.security.web.access.AccessDeniedHandler; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.servlet.ServletException; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | |
| | | /** |
| | | * @Author : zhoush |
| | | * @Date: 2024/4/12 10:38 |
| | | * @Description: |
| | | */ |
| | | @Component |
| | | public class AccessDeniedHandlerImpl implements AccessDeniedHandler { |
| | | @Override |
| | | public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException, ServletException { |
| | | Result result = Result.error(HttpStatus.FORBIDDEN.value(), "权限不足"); |
| | | String json = JSON.toJSONString(result); |
| | | WebUtils.renderString(response, json); |
| | | |
| | | } |
| | | } |
New file |
| | |
| | | package com.mes.common.handler; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.mes.common.utils.WebUtils; |
| | | import com.mes.utils.Result; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.security.core.AuthenticationException; |
| | | import org.springframework.security.web.AuthenticationEntryPoint; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.servlet.ServletException; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | |
| | | /** |
| | | * @Author : zhoush |
| | | * @Date: 2024/4/12 10:38 |
| | | * @Description: |
| | | */ |
| | | @Component |
| | | public class AuthenticationEntryPointImpl implements AuthenticationEntryPoint { |
| | | @Override |
| | | public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException { |
| | | Result result = Result.error(HttpStatus.UNAUTHORIZED.value(), "认证失败请重新登录"); |
| | | String json = JSON.toJSONString(result); |
| | | WebUtils.renderString(response, json); |
| | | } |
| | | } |
New file |
| | |
| | | package com.mes.common.utils; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.parser.ParserConfig; |
| | | import com.alibaba.fastjson.serializer.SerializerFeature; |
| | | import com.fasterxml.jackson.databind.JavaType; |
| | | import com.fasterxml.jackson.databind.type.TypeFactory; |
| | | import org.springframework.data.redis.serializer.RedisSerializer; |
| | | import org.springframework.data.redis.serializer.SerializationException; |
| | | |
| | | import java.nio.charset.Charset; |
| | | |
| | | /** |
| | | * @Author : zhoush |
| | | * @Date: 2024/4/11 15:28 |
| | | * @Description: |
| | | */ |
| | | public class FastJsonRedisSerializer<T> implements RedisSerializer<T> { |
| | | |
| | | public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8"); |
| | | |
| | | private Class<T> clazz; |
| | | |
| | | static { |
| | | ParserConfig.getGlobalInstance().setAutoTypeSupport(true); |
| | | } |
| | | |
| | | public FastJsonRedisSerializer(Class<T> clazz) { |
| | | super(); |
| | | this.clazz = clazz; |
| | | } |
| | | |
| | | @Override |
| | | public byte[] serialize(T t) throws SerializationException { |
| | | if (t == null) { |
| | | return new byte[0]; |
| | | } |
| | | return JSON.toJSONString(t, SerializerFeature.WriteClassName).getBytes(DEFAULT_CHARSET); |
| | | } |
| | | |
| | | @Override |
| | | public T deserialize(byte[] bytes) throws SerializationException { |
| | | if (bytes == null || bytes.length <= 0) { |
| | | return null; |
| | | } |
| | | String str = new String(bytes, DEFAULT_CHARSET); |
| | | |
| | | return JSON.parseObject(str, clazz); |
| | | } |
| | | |
| | | |
| | | protected JavaType getJavaType(Class<?> clazz) { |
| | | return TypeFactory.defaultInstance().constructType(clazz); |
| | | } |
| | | } |
New file |
| | |
| | | package com.mes.common.utils; |
| | | |
| | | |
| | | import io.jsonwebtoken.Claims; |
| | | import io.jsonwebtoken.JwtBuilder; |
| | | import io.jsonwebtoken.Jwts; |
| | | import io.jsonwebtoken.SignatureAlgorithm; |
| | | |
| | | import javax.crypto.SecretKey; |
| | | import javax.crypto.spec.SecretKeySpec; |
| | | import java.util.Base64; |
| | | import java.util.Date; |
| | | import java.util.UUID; |
| | | |
| | | /** |
| | | * @Author : zhoush |
| | | * @Date: 2024/4/9 19:15 |
| | | * @Description: |
| | | */ |
| | | public class JwtUtil { |
| | | |
| | | //有效期为 |
| | | public static final Long JWT_TTL = 60 * 60 * 1000L;// 60 * 60 *1000 一个小时 |
| | | //设置秘钥明文 |
| | | public static final String JWT_KEY = "sangeng"; |
| | | |
| | | public static String getUUID() { |
| | | String token = UUID.randomUUID().toString().replaceAll("-", ""); |
| | | return token; |
| | | } |
| | | |
| | | /** |
| | | * 生成jtw |
| | | * |
| | | * @param subject token中要存放的数据(json格式) |
| | | * @return |
| | | */ |
| | | public static String createJWT(String subject) { |
| | | JwtBuilder builder = getJwtBuilder(subject, null, getUUID());// 设置过期时间 |
| | | return builder.compact(); |
| | | } |
| | | |
| | | /** |
| | | * 生成jtw |
| | | * |
| | | * @param subject token中要存放的数据(json格式) |
| | | * @param ttlMillis token超时时间 |
| | | * @return |
| | | */ |
| | | public static String createJWT(String subject, Long ttlMillis) { |
| | | JwtBuilder builder = getJwtBuilder(subject, ttlMillis, getUUID());// 设置过期时间 |
| | | return builder.compact(); |
| | | } |
| | | |
| | | private static JwtBuilder getJwtBuilder(String subject, Long ttlMillis, String uuid) { |
| | | SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.HS256; |
| | | SecretKey secretKey = generalKey(); |
| | | long nowMillis = System.currentTimeMillis(); |
| | | Date now = new Date(nowMillis); |
| | | if (ttlMillis == null) { |
| | | ttlMillis = JwtUtil.JWT_TTL; |
| | | } |
| | | long expMillis = nowMillis + ttlMillis; |
| | | Date expDate = new Date(expMillis); |
| | | return Jwts.builder() |
| | | .setId(uuid) //唯一的ID |
| | | .setSubject(subject) // 主题 可以是JSON数据 |
| | | .setIssuer("sg") // 签发者 |
| | | .setIssuedAt(now) // 签发时间 |
| | | .signWith(signatureAlgorithm, secretKey) //使用HS256对称加密算法签名, 第二个参数为秘钥 |
| | | .setExpiration(expDate); |
| | | } |
| | | |
| | | /** |
| | | * 创建token |
| | | * |
| | | * @param id |
| | | * @param subject |
| | | * @param ttlMillis |
| | | * @return |
| | | */ |
| | | public static String createJWT(String id, String subject, Long ttlMillis) { |
| | | JwtBuilder builder = getJwtBuilder(subject, ttlMillis, id);// 设置过期时间 |
| | | return builder.compact(); |
| | | } |
| | | |
| | | public static void main(String[] args) throws Exception { |
| | | String token = "eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiJjYWM2ZDVhZi1mNjVlLTQ0MDAtYjcxMi0zYWEwOGIyOTIwYjQiLCJzdWIiOiJzZyIsImlzcyI6InNnIiwiaWF0IjoxNjM4MTA2NzEyLCJleHAiOjE2MzgxMTAzMTJ9.JVsSbkP94wuczb4QryQbAke3ysBDIL5ou8fWsbt_ebg"; |
| | | Claims claims = parseJWT(token); |
| | | System.out.println(claims); |
| | | } |
| | | |
| | | /** |
| | | * 生成加密后的秘钥 secretKey |
| | | * |
| | | * @return |
| | | */ |
| | | public static SecretKey generalKey() { |
| | | byte[] encodedKey = Base64.getDecoder().decode(JwtUtil.JWT_KEY); |
| | | SecretKey key = new SecretKeySpec(encodedKey, 0, encodedKey.length, "AES"); |
| | | return key; |
| | | } |
| | | |
| | | /** |
| | | * 解析 |
| | | * |
| | | * @param jwt |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public static Claims parseJWT(String jwt) throws Exception { |
| | | SecretKey secretKey = generalKey(); |
| | | return Jwts.parser() |
| | | .setSigningKey(secretKey) |
| | | .parseClaimsJws(jwt) |
| | | .getBody(); |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.mes.common.utils; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.BoundSetOperations; |
| | | import org.springframework.data.redis.core.HashOperations; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.data.redis.core.ValueOperations; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | /** |
| | | * spring redis 工具类 |
| | | **/ |
| | | @Component |
| | | public class RedisUtil { |
| | | @Autowired |
| | | public RedisTemplate redisTemplate; |
| | | |
| | | /** |
| | | * 缓存基本的对象,Integer、String、实体类等 |
| | | * |
| | | * @param key 缓存的键值 |
| | | * @param value 缓存的值 |
| | | */ |
| | | public <T> void setCacheObject(final String key, final T value) { |
| | | redisTemplate.opsForValue().set(key, value); |
| | | } |
| | | |
| | | /** |
| | | * 缓存基本的对象,Integer、String、实体类等 |
| | | * |
| | | * @param key 缓存的键值 |
| | | * @param value 缓存的值 |
| | | * @param timeout 时间 |
| | | * @param timeUnit 时间颗粒度 |
| | | */ |
| | | public <T> void setCacheObject(final String key, final T value, final Integer timeout, final TimeUnit timeUnit) { |
| | | redisTemplate.opsForValue().set(key, value, timeout, timeUnit); |
| | | } |
| | | |
| | | /** |
| | | * 设置有效时间 |
| | | * |
| | | * @param key Redis键 |
| | | * @param timeout 超时时间 |
| | | * @return true=设置成功;false=设置失败 |
| | | */ |
| | | public boolean expire(final String key, final long timeout) { |
| | | return expire(key, timeout, TimeUnit.SECONDS); |
| | | } |
| | | |
| | | /** |
| | | * 设置有效时间 |
| | | * |
| | | * @param key Redis键 |
| | | * @param timeout 超时时间 |
| | | * @param unit 时间单位 |
| | | * @return true=设置成功;false=设置失败 |
| | | */ |
| | | public boolean expire(final String key, final long timeout, final TimeUnit unit) { |
| | | return redisTemplate.expire(key, timeout, unit); |
| | | } |
| | | |
| | | /** |
| | | * 获得缓存的基本对象。 |
| | | * |
| | | * @param key 缓存键值 |
| | | * @return 缓存键值对应的数据 |
| | | */ |
| | | public <T> T getCacheObject(final String key) { |
| | | ValueOperations<String, T> operation = redisTemplate.opsForValue(); |
| | | return operation.get(key); |
| | | } |
| | | |
| | | /** |
| | | * 删除单个对象 |
| | | * |
| | | * @param key |
| | | */ |
| | | public boolean deleteObject(final String key) { |
| | | return redisTemplate.delete(key); |
| | | } |
| | | |
| | | /** |
| | | * 删除集合对象 |
| | | * |
| | | * @param collection 多个对象 |
| | | * @return |
| | | */ |
| | | public long deleteObject(final Collection collection) { |
| | | return redisTemplate.delete(collection); |
| | | } |
| | | |
| | | /** |
| | | * 缓存List数据 |
| | | * |
| | | * @param key 缓存的键值 |
| | | * @param dataList 待缓存的List数据 |
| | | * @return 缓存的对象 |
| | | */ |
| | | public <T> long setCacheList(final String key, final List<T> dataList) { |
| | | Long count = redisTemplate.opsForList().rightPushAll(key, dataList); |
| | | return count == null ? 0 : count; |
| | | } |
| | | |
| | | /** |
| | | * 获得缓存的list对象 |
| | | * |
| | | * @param key 缓存的键值 |
| | | * @return 缓存键值对应的数据 |
| | | */ |
| | | public <T> List<T> getCacheList(final String key) { |
| | | return redisTemplate.opsForList().range(key, 0, -1); |
| | | } |
| | | |
| | | /** |
| | | * 缓存Set |
| | | * |
| | | * @param key 缓存键值 |
| | | * @param dataSet 缓存的数据 |
| | | * @return 缓存数据的对象 |
| | | */ |
| | | public <T> BoundSetOperations<String, T> setCacheSet(final String key, final Set<T> dataSet) { |
| | | BoundSetOperations<String, T> setOperation = redisTemplate.boundSetOps(key); |
| | | Iterator<T> it = dataSet.iterator(); |
| | | while (it.hasNext()) { |
| | | setOperation.add(it.next()); |
| | | } |
| | | return setOperation; |
| | | } |
| | | |
| | | /** |
| | | * 获得缓存的set |
| | | * |
| | | * @param key |
| | | * @return |
| | | */ |
| | | public <T> Set<T> getCacheSet(final String key) { |
| | | return redisTemplate.opsForSet().members(key); |
| | | } |
| | | |
| | | /** |
| | | * 缓存Map |
| | | * |
| | | * @param key |
| | | * @param dataMap |
| | | */ |
| | | public <T> void setCacheMap(final String key, final Map<String, T> dataMap) { |
| | | if (dataMap != null) { |
| | | redisTemplate.opsForHash().putAll(key, dataMap); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获得缓存的Map |
| | | * |
| | | * @param key |
| | | * @return |
| | | */ |
| | | public <T> Map<String, T> getCacheMap(final String key) { |
| | | return redisTemplate.opsForHash().entries(key); |
| | | } |
| | | |
| | | /** |
| | | * 往Hash中存入数据 |
| | | * |
| | | * @param key Redis键 |
| | | * @param hKey Hash键 |
| | | * @param value 值 |
| | | */ |
| | | public <T> void setCacheMapValue(final String key, final String hKey, final T value) { |
| | | redisTemplate.opsForHash().put(key, hKey, value); |
| | | } |
| | | |
| | | /** |
| | | * 获取Hash中的数据 |
| | | * |
| | | * @param key Redis键 |
| | | * @param hKey Hash键 |
| | | * @return Hash中的对象 |
| | | */ |
| | | public <T> T getCacheMapValue(final String key, final String hKey) { |
| | | HashOperations<String, String, T> opsForHash = redisTemplate.opsForHash(); |
| | | return opsForHash.get(key, hKey); |
| | | } |
| | | |
| | | /** |
| | | * 删除Hash中的数据 |
| | | * |
| | | * @param key |
| | | * @param hkey |
| | | */ |
| | | public void delCacheMapValue(final String key, final String hkey) { |
| | | HashOperations hashOperations = redisTemplate.opsForHash(); |
| | | hashOperations.delete(key, hkey); |
| | | } |
| | | |
| | | /** |
| | | * 获取多个Hash中的数据 |
| | | * |
| | | * @param key Redis键 |
| | | * @param hKeys Hash键集合 |
| | | * @return Hash对象集合 |
| | | */ |
| | | public <T> List<T> getMultiCacheMapValue(final String key, final Collection<Object> hKeys) { |
| | | return redisTemplate.opsForHash().multiGet(key, hKeys); |
| | | } |
| | | |
| | | /** |
| | | * 获得缓存的基本对象列表 |
| | | * |
| | | * @param pattern 字符串前缀 |
| | | * @return 对象列表 |
| | | */ |
| | | public Collection<String> keys(final String pattern) { |
| | | return redisTemplate.keys(pattern); |
| | | } |
| | | } |
New file |
| | |
| | | package com.mes.common.utils; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | |
| | | /** |
| | | * @Author : zhoush |
| | | * @Date: 2024/4/9 19:16 |
| | | * @Description: |
| | | */ |
| | | public class WebUtils { |
| | | /** |
| | | * 将字符串渲染到客户端 |
| | | * |
| | | * @param response 渲染对象 |
| | | * @param string 待渲染的字符串 |
| | | * @return null |
| | | */ |
| | | public static String renderString(HttpServletResponse response, String string) { |
| | | try { |
| | | response.setStatus(200); |
| | | response.setContentType("application/json"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | response.getWriter().print(string); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | } |
New file |
| | |
| | | package com.mes.menu.controller; |
| | | |
| | | |
| | | import com.mes.menu.entity.SysMenu; |
| | | import com.mes.menu.service.SysMenuService; |
| | | import com.mes.utils.Result; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * 菜单表 |
| | | * </p> |
| | | * |
| | | * @author zhoush |
| | | * @since 2024-04-11 |
| | | */ |
| | | @ApiModel("获取菜单信息") |
| | | @RestController |
| | | @RequestMapping("/menu/sysMenu") |
| | | public class SysMenuController { |
| | | |
| | | @Autowired |
| | | SysMenuService sysMenuService; |
| | | |
| | | @ApiOperation("获取用户有权限的所有菜单") |
| | | @GetMapping("/list") |
| | | public Result<List<SysMenu>> getMenuTree() { |
| | | return Result.success(sysMenuService.getMenuTree()); |
| | | } |
| | | |
| | | } |
| | | |
New file |
| | |
| | | package com.mes.menu.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.experimental.Accessors; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * |
| | | * </p> |
| | | * |
| | | * @author zhoush |
| | | * @since 2024-04-13 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @Accessors(chain = true) |
| | | public class SysMenu implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 自增id |
| | | */ |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | |
| | | /** |
| | | * 父id |
| | | */ |
| | | private Integer parentId; |
| | | |
| | | /** |
| | | * 模块名称 |
| | | */ |
| | | private String menuName; |
| | | |
| | | /** |
| | | * 图标 |
| | | */ |
| | | private String icon; |
| | | |
| | | /** |
| | | * 地址 |
| | | */ |
| | | private String url; |
| | | |
| | | /** |
| | | * 语言类型 |
| | | */ |
| | | private String languageType; |
| | | |
| | | /** |
| | | * 状态 |
| | | */ |
| | | private Integer status; |
| | | |
| | | /** |
| | | * 排序 |
| | | */ |
| | | private String listSort; |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | private Date createTime; |
| | | |
| | | /** |
| | | * 子菜单 |
| | | */ |
| | | @TableField(exist = false) |
| | | private List<SysMenu> children; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.mes.menu.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.mes.menu.entity.SysMenu; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * 菜单表 Mapper 接口 |
| | | * </p> |
| | | * |
| | | * @author zhoush |
| | | * @since 2024-04-11 |
| | | */ |
| | | public interface SysMenuMapper extends BaseMapper<SysMenu> { |
| | | |
| | | List<String> selectPermsByUserId(long parseLong); |
| | | } |
New file |
| | |
| | | package com.mes.menu.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.mes.menu.entity.SysMenu; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * 菜单表 服务类 |
| | | * </p> |
| | | * |
| | | * @author zhoush |
| | | * @since 2024-04-11 |
| | | */ |
| | | public interface SysMenuService extends IService<SysMenu> { |
| | | |
| | | List<SysMenu> getMenuTree(); |
| | | } |
New file |
| | |
| | | package com.mes.menu.service.impl; |
| | | |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.mes.menu.entity.SysMenu; |
| | | import com.mes.menu.mapper.SysMenuMapper; |
| | | import com.mes.menu.service.SysMenuService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | | * 菜单表 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author zhoush |
| | | * @since 2024-04-11 |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements SysMenuService { |
| | | |
| | | @Override |
| | | public List<SysMenu> getMenuTree() { |
| | | List<SysMenu> menuList = this.baseMapper.selectList(null); |
| | | return create(menuList); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 将数据库中查询出来的list集合传入此方法即可获得排成树形结构的list集合 |
| | | * |
| | | * @param lists |
| | | * @return |
| | | */ |
| | | public List<SysMenu> create(List<SysMenu> lists) { |
| | | List<SysMenu> deptTreeList = lists.stream() |
| | | .filter(item -> item.getParentId() == 0) |
| | | .map(item -> { |
| | | item.setChildren(getChildren(item, lists)); |
| | | return item; |
| | | }).collect(Collectors.toList()); |
| | | return deptTreeList; |
| | | } |
| | | |
| | | /** |
| | | * 此方法将被递归调用 |
| | | * |
| | | * @param menu |
| | | * @param menus |
| | | * @return |
| | | */ |
| | | private List<SysMenu> getChildren(SysMenu menu, List<SysMenu> menus) { |
| | | List<SysMenu> res = menus.stream() |
| | | .filter(item -> item.getParentId().equals(menu.getId())) |
| | | .map(item -> { |
| | | item.setChildren(getChildren(item, menus)); |
| | | return item; |
| | | }).collect(Collectors.toList()); |
| | | log.info("菜单树:{}", JSONUtil.toJsonStr(res)); |
| | | return res; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.mes.role.controller; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | /** |
| | | * <p> |
| | | * 角色表 前端控制器 |
| | | * </p> |
| | | * |
| | | * @author zhoush |
| | | * @since 2024-04-11 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/role/sys-role") |
| | | public class SysRoleController { |
| | | |
| | | } |
| | | |
New file |
| | |
| | | package com.mes.role.controller; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | /** |
| | | * <p> |
| | | * 前端控制器 |
| | | * </p> |
| | | * |
| | | * @author zhoush |
| | | * @since 2024-04-11 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/role/sys-role-menu") |
| | | public class SysRoleMenuController { |
| | | |
| | | } |
| | | |
New file |
| | |
| | | package com.mes.role.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * <p> |
| | | * 角色表 |
| | | * </p> |
| | | * |
| | | * @author zhoush |
| | | * @since 2024-04-11 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | public class SysRole implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | private String name; |
| | | |
| | | /** |
| | | * 角色权限字符串 |
| | | */ |
| | | private String roleKey; |
| | | |
| | | /** |
| | | * 角色状态(0正常 1停用) |
| | | */ |
| | | private String status; |
| | | |
| | | /** |
| | | * 删除标志 |
| | | */ |
| | | private Integer delFlag; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String remark; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.mes.role.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * <p> |
| | | * |
| | | * </p> |
| | | * |
| | | * @author zhoush |
| | | * @since 2024-04-11 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | public class SysRoleMenu implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 角色ID |
| | | */ |
| | | @TableId(value = "role_id", type = IdType.AUTO) |
| | | private Long roleId; |
| | | |
| | | /** |
| | | * 菜单id |
| | | */ |
| | | private Long menuId; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.mes.role.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.mes.role.entity.SysRole; |
| | | |
| | | /** |
| | | * <p> |
| | | * 角色表 Mapper 接口 |
| | | * </p> |
| | | * |
| | | * @author zhoush |
| | | * @since 2024-04-11 |
| | | */ |
| | | public interface SysRoleMapper extends BaseMapper<SysRole> { |
| | | |
| | | } |
New file |
| | |
| | | package com.mes.role.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.mes.role.entity.SysRoleMenu; |
| | | |
| | | /** |
| | | * <p> |
| | | * Mapper 接口 |
| | | * </p> |
| | | * |
| | | * @author zhoush |
| | | * @since 2024-04-11 |
| | | */ |
| | | public interface SysRoleMenuMapper extends BaseMapper<SysRoleMenu> { |
| | | |
| | | } |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.mes.role.mapper.SysRoleMapper"> |
| | | |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.mes.role.mapper.SysRoleMenuMapper"> |
| | | |
| | | </mapper> |
New file |
| | |
| | | package com.mes.role.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.mes.role.entity.SysRoleMenu; |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务类 |
| | | * </p> |
| | | * |
| | | * @author zhoush |
| | | * @since 2024-04-11 |
| | | */ |
| | | public interface SysRoleMenuService extends IService<SysRoleMenu> { |
| | | |
| | | } |
New file |
| | |
| | | package com.mes.role.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.mes.role.entity.SysRole; |
| | | |
| | | /** |
| | | * <p> |
| | | * 角色表 服务类 |
| | | * </p> |
| | | * |
| | | * @author zhoush |
| | | * @since 2024-04-11 |
| | | */ |
| | | public interface SysRoleService extends IService<SysRole> { |
| | | |
| | | } |
New file |
| | |
| | | package com.mes.role.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.mes.role.entity.SysRoleMenu; |
| | | import com.mes.role.mapper.SysRoleMenuMapper; |
| | | import com.mes.role.service.SysRoleMenuService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author zhoush |
| | | * @since 2024-04-11 |
| | | */ |
| | | @Service |
| | | public class SysRoleMenuServiceImpl extends ServiceImpl<SysRoleMenuMapper, SysRoleMenu> implements SysRoleMenuService { |
| | | |
| | | } |
New file |
| | |
| | | package com.mes.role.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.mes.role.entity.SysRole; |
| | | import com.mes.role.mapper.SysRoleMapper; |
| | | import com.mes.role.service.SysRoleService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * <p> |
| | | * 角色表 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author zhoush |
| | | * @since 2024-04-11 |
| | | */ |
| | | @Service |
| | | public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements SysRoleService { |
| | | |
| | | } |
New file |
| | |
| | | package com.mes.userinfo.controller; |
| | | |
| | | |
| | | import com.mes.userinfo.entity.SysUser; |
| | | import com.mes.userinfo.service.SysUserService; |
| | | import com.mes.utils.Result; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | /** |
| | | * <p> |
| | | * 用户表 前端控制器 |
| | | * </p> |
| | | * |
| | | * @author zhoush |
| | | * @since 2024-04-11 |
| | | */ |
| | | @RestController |
| | | @CrossOrigin |
| | | @RequestMapping("/userinfo") |
| | | public class SysUserController { |
| | | |
| | | @Autowired |
| | | private SysUserService sysUserService; |
| | | |
| | | @PostMapping("/login") |
| | | public Result login(@RequestBody SysUser user) { |
| | | return sysUserService.login(user); |
| | | } |
| | | |
| | | @GetMapping("/hello") |
| | | public Result hello() { |
| | | return Result.success("eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiJlZjMyMjQ4NDcyODE0ZWFlYWRlOTBkYmZjYWFlZmNmZSIsInN1YiI6IjEiLCJpc3MiOiJzZyIsImlhdCI6MTcxMjkwMjI0NCwiZXhwIjoxNzEyOTA1ODQ0fQ.DlJkhkiwjZSqprdLzKaTB3yuyxGukerKeF0FbJK_6HY"); |
| | | } |
| | | } |
| | | |
New file |
| | |
| | | package com.mes.userinfo.controller; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | /** |
| | | * <p> |
| | | * 前端控制器 |
| | | * </p> |
| | | * |
| | | * @author zhoush |
| | | * @since 2024-04-11 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/userinfo/sys-user-role") |
| | | public class SysUserRoleController { |
| | | |
| | | } |
| | | |
New file |
| | |
| | | package com.mes.userinfo.entity; |
| | | |
| | | import com.alibaba.fastjson.annotation.JSONField; |
| | | import org.springframework.security.core.GrantedAuthority; |
| | | import org.springframework.security.core.authority.SimpleGrantedAuthority; |
| | | import org.springframework.security.core.userdetails.UserDetails; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @Author : zhoush |
| | | * @Date: 2024/4/11 15:46 |
| | | * @Description: |
| | | */ |
| | | public class LoginUser implements UserDetails { |
| | | |
| | | |
| | | private SysUser user; |
| | | |
| | | /** |
| | | * 存储权限信息 |
| | | */ |
| | | @JSONField(serialize = false) |
| | | private List<String> permissions; |
| | | |
| | | /** |
| | | * 存储SpringSecurity调用getAuthorities()方法获取的权限信息的集合 |
| | | */ |
| | | @JSONField(serialize = false) |
| | | private List<GrantedAuthority> authorities; |
| | | |
| | | |
| | | public LoginUser() { |
| | | } |
| | | |
| | | public LoginUser(SysUser user, List<String> permissions) { |
| | | this.user = user; |
| | | this.permissions = permissions; |
| | | } |
| | | |
| | | public SysUser getUser() { |
| | | return user; |
| | | } |
| | | |
| | | public void setUser(SysUser user) { |
| | | this.user = user; |
| | | } |
| | | |
| | | @Override |
| | | public Collection<? extends GrantedAuthority> getAuthorities() { |
| | | |
| | | // 优化为只需要第一次获取的时候进行遍历,后面再用就会从authorities这个成员变量中获取了,不会再进行Stream循环遍历了 |
| | | if (authorities != null) { |
| | | return authorities; |
| | | } |
| | | //把permissions中字符串类型的权限信息转换成GrantedAuthority对象存入authorities中 |
| | | authorities = permissions.stream(). |
| | | map(SimpleGrantedAuthority::new) |
| | | .collect(Collectors.toList()); |
| | | return authorities; |
| | | } |
| | | |
| | | @Override |
| | | public String getPassword() { |
| | | return user.getPassword(); |
| | | } |
| | | |
| | | @Override |
| | | public String getUsername() { |
| | | return user.getUserName(); |
| | | } |
| | | |
| | | @Override |
| | | public boolean isAccountNonExpired() { |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public boolean isAccountNonLocked() { |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public boolean isCredentialsNonExpired() { |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public boolean isEnabled() { |
| | | return true; |
| | | } |
| | | } |
New file |
| | |
| | | package com.mes.userinfo.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * <p> |
| | | * 用户表 |
| | | * </p> |
| | | * |
| | | * @author zhoush |
| | | * @since 2024-04-11 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | public class SysUser implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 用户名 |
| | | */ |
| | | private String userName; |
| | | |
| | | /** |
| | | * 昵称 |
| | | */ |
| | | private String nickName; |
| | | |
| | | /** |
| | | * 密码 |
| | | */ |
| | | private String password; |
| | | |
| | | /** |
| | | * 账号状态(0正常 1停用) |
| | | */ |
| | | private String status; |
| | | |
| | | /** |
| | | * 头像 |
| | | */ |
| | | private String avatar; |
| | | |
| | | /** |
| | | * 用户类型(0管理员,1普通用户) |
| | | */ |
| | | private String userType; |
| | | |
| | | /** |
| | | * 删除标志 |
| | | */ |
| | | private Integer delFlag; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.mes.userinfo.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * <p> |
| | | * |
| | | * </p> |
| | | * |
| | | * @author zhoush |
| | | * @since 2024-04-11 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | public class SysUserRole implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 用户id |
| | | */ |
| | | @TableId(value = "user_id", type = IdType.AUTO) |
| | | private Long userId; |
| | | |
| | | /** |
| | | * 角色id |
| | | */ |
| | | private Long roleId; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.mes.userinfo.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.mes.userinfo.entity.SysUser; |
| | | |
| | | /** |
| | | * <p> |
| | | * 用户表 Mapper 接口 |
| | | * </p> |
| | | * |
| | | * @author zhoush |
| | | * @since 2024-04-11 |
| | | */ |
| | | public interface SysUserMapper extends BaseMapper<SysUser> { |
| | | |
| | | } |
New file |
| | |
| | | package com.mes.userinfo.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.mes.userinfo.entity.SysUserRole; |
| | | |
| | | /** |
| | | * <p> |
| | | * Mapper 接口 |
| | | * </p> |
| | | * |
| | | * @author zhoush |
| | | * @since 2024-04-11 |
| | | */ |
| | | public interface SysUserRoleMapper extends BaseMapper<SysUserRole> { |
| | | |
| | | } |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.mes.userinfo.mapper.SysUserMapper"> |
| | | |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.mes.userinfo.mapper.SysUserRoleMapper"> |
| | | |
| | | </mapper> |
New file |
| | |
| | | package com.mes.userinfo.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.mes.userinfo.entity.SysUserRole; |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务类 |
| | | * </p> |
| | | * |
| | | * @author zhoush |
| | | * @since 2024-04-11 |
| | | */ |
| | | public interface SysUserRoleService extends IService<SysUserRole> { |
| | | |
| | | } |
New file |
| | |
| | | package com.mes.userinfo.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.mes.userinfo.entity.SysUser; |
| | | import com.mes.utils.Result; |
| | | |
| | | /** |
| | | * <p> |
| | | * 用户表 服务类 |
| | | * </p> |
| | | * |
| | | * @author zhoush |
| | | * @since 2024-04-11 |
| | | */ |
| | | public interface SysUserService extends IService<SysUser> { |
| | | |
| | | Result login(SysUser user); |
| | | |
| | | Result logout(); |
| | | } |
New file |
| | |
| | | package com.mes.userinfo.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.mes.userinfo.entity.SysUserRole; |
| | | import com.mes.userinfo.mapper.SysUserRoleMapper; |
| | | import com.mes.userinfo.service.SysUserRoleService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author zhoush |
| | | * @since 2024-04-11 |
| | | */ |
| | | @Service |
| | | public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUserRole> implements SysUserRoleService { |
| | | |
| | | } |
New file |
| | |
| | | package com.mes.userinfo.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.mes.common.utils.JwtUtil; |
| | | import com.mes.common.utils.RedisUtil; |
| | | import com.mes.menu.mapper.SysMenuMapper; |
| | | import com.mes.userinfo.entity.LoginUser; |
| | | import com.mes.userinfo.entity.SysUser; |
| | | import com.mes.userinfo.mapper.SysUserMapper; |
| | | import com.mes.userinfo.service.SysUserService; |
| | | import com.mes.utils.Result; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.authentication.AuthenticationManager; |
| | | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; |
| | | import org.springframework.security.core.Authentication; |
| | | import org.springframework.security.core.context.SecurityContextHolder; |
| | | import org.springframework.security.core.userdetails.UserDetails; |
| | | import org.springframework.security.core.userdetails.UserDetailsService; |
| | | import org.springframework.security.core.userdetails.UsernameNotFoundException; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * <p> |
| | | * 用户表 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author zhoush |
| | | * @since 2024-04-11 |
| | | */ |
| | | @Service |
| | | public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements SysUserService, UserDetailsService { |
| | | |
| | | @Autowired |
| | | private AuthenticationManager authenticationManager; |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | | @Resource |
| | | private SysMenuMapper sysMenuMapper; |
| | | |
| | | @Override |
| | | public Result login(SysUser user) { |
| | | UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(user.getUserName(), user.getPassword()); |
| | | Authentication authenticate = authenticationManager.authenticate(authenticationToken); |
| | | if (Objects.isNull(authenticate)) { |
| | | throw new RuntimeException("用户名或密码错误"); |
| | | } |
| | | //使用userid生成token |
| | | LoginUser loginUser = (LoginUser) authenticate.getPrincipal(); |
| | | String userId = loginUser.getUser().getId().toString(); |
| | | String jwt = JwtUtil.createJWT(userId); |
| | | //authenticate存入redis |
| | | redisUtil.setCacheObject("login:" + userId, loginUser); |
| | | //把token响应给前端 |
| | | HashMap<String, String> map = new HashMap<>(); |
| | | map.put("token", jwt); |
| | | return Result.success(map); |
| | | } |
| | | |
| | | @Override |
| | | public Result logout() { |
| | | Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); |
| | | LoginUser loginUser = (LoginUser) authentication.getPrincipal(); |
| | | Long userid = loginUser.getUser().getId(); |
| | | redisUtil.deleteObject("login:" + userid); |
| | | return Result.success("退出成功"); |
| | | } |
| | | |
| | | @Override |
| | | public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { |
| | | LambdaQueryWrapper<SysUser> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(SysUser::getUserName, username); |
| | | SysUser user = this.baseMapper.selectOne(lqw); |
| | | //判断是否为空 |
| | | if (Objects.isNull(user)) { |
| | | throw new RuntimeException("用户名或密码错误"); |
| | | } |
| | | //查询权限信息 |
| | | List<String> perms = sysMenuMapper.selectPermsByUserId(user.getId()); |
| | | |
| | | return new LoginUser(user, perms); |
| | | } |
| | | } |
New file |
| | |
| | | server: |
| | | port: 8089 |
| | | spring: |
| | | datasource: |
| | | driver-class-name: com.mysql.cj.jdbc.Driver |
| | | url: jdbc:mysql://10.153.19.150:3306/hangzhoumes?serverTimezone=GMT%2b8&characterEncoding=utf-8&useSSL=false |
| | | username: root |
| | | password: beibo.123/ |
| | | cloud: |
| | | nacos: |
| | | discovery: |
| | | server-addr: 10.153.19.150:8848 |
| | | application: |
| | | name: security |
| | | redis: |
| | | database: 0 |
| | | host: 10.153.19.150 |
| | | port: 6379 |
| | | password: |
| | | session: |
| | | store-type: redis |
| | | mybatis-plus: |
| | | mapper-locations: classpath*:mapper/*.xml |
| | | configuration: |
| | | log-impl: org.apache.ibatis.logging.stdout.StdOutImpl |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.mes.menu.mapper.SysMenuMapper"> |
| | | |
| | | <select id="selectPermsByUserId" resultType="java.lang.String"> |
| | | SELECT DISTINCT m.perms |
| | | FROM sys_user_role ur |
| | | LEFT JOIN sys_role r ON ur.role_id = r.id |
| | | LEFT JOIN sys_role_menu rm ON ur.role_id = rm.role_id |
| | | LEFT JOIN sys_menu m ON m.id = rm.menu_id |
| | | WHERE user_id = #{userid} |
| | | AND r.status = 0 |
| | | AND m.status = 0 |
| | | </select> |
| | | </mapper> |
| | |
| | | package com.mes.bigstorage.controller; |
| | | |
| | | |
| | | import com.mes.bigstorage.entity.BigStorageCage; |
| | | import com.mes.bigstorage.entity.BigStorageCageDetails; |
| | | import com.mes.bigstorage.service.BigStorageCageDetailsService; |
| | | import com.mes.bigstorage.service.BigStorageCageService; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * 前端控制器 |
| | | * 前端控制器 |
| | | * </p> |
| | | * |
| | | * @author zhoush |
| | |
| | | @RequestMapping("/bigStorageCage") |
| | | public class BigStorageCageController { |
| | | |
| | | @Autowired |
| | | private BigStorageCageService bigStorageCageService; |
| | | private BigStorageCageDetailsService bigStorageCageDetailsService; |
| | | |
| | | //todo: 实例代码 待删除 |
| | | @ApiOperation("测试") |
| | |
| | | } |
| | | |
| | | @ApiOperation("理片笼信息") |
| | | @GetMapping("/BigStorageCage") |
| | | public List<BigStorageCage> BigStorageCage() { |
| | | return bigStorageCageService.list(); |
| | | } |
| | | |
| | | @ApiOperation("理片笼详情") |
| | | @GetMapping("/BigStorageCageDetails") |
| | | public List<BigStorageCageDetails> BigStorageCageDetails() { |
| | | return bigStorageCageDetailsService.list(); |
| | | } |
| | | |
| | | @ApiOperation("小车实时位置") |
| | | @GetMapping("/CarPosition") |
| | | public List<Integer> CarPosition() { |
| | | return bigStorageCageDetailsService.getCarposition(); |
| | | @GetMapping("/bigStorageCage") |
| | | public List<BigStorageCage> querybigStorageCageDetail() { |
| | | // return bigStorageCageService.list(); |
| | | return bigStorageCageService.querybigStorageCageDetail(); |
| | | } |
| | | |
| | | @ApiOperation("手动完成任务") |
| | |
| | | package com.mes.bigstorage.controller; |
| | | |
| | | |
| | | import com.mes.bigstorage.entity.BigStorageCageDetails; |
| | | import com.mes.bigstorage.service.BigStorageCageDetailsService; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * 前端控制器 |
| | | * 前端控制器 |
| | | * </p> |
| | | * |
| | | * @author zhoush |
| | | * @since 2024-03-27 |
| | | */ |
| | | @ApiModel(description = "理片笼详情") |
| | | @RestController |
| | | @RequestMapping("/bigStorageCageDetails") |
| | | public class BigStorageCageDetailsController { |
| | | |
| | | @Autowired |
| | | private BigStorageCageDetailsService bigStorageCageDetailsService; |
| | | |
| | | @ApiOperation("理片笼详情") |
| | | @GetMapping("/BigStorageCageDetails") |
| | | public List<BigStorageCageDetails> BigStorageCageDetails() { |
| | | return bigStorageCageDetailsService.list(); |
| | | } |
| | | |
| | | @ApiOperation("小车实时位置") |
| | | @GetMapping("/CarPosition") |
| | | public List<Integer> CarPosition() { |
| | | return bigStorageCageDetailsService.getCarposition(); |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | package com.mes.bigstorage.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import java.io.Serializable; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * |
| | | * |
| | | * </p> |
| | | * |
| | | * @author zhoush |
| | |
| | | */ |
| | | private Integer remainWidth; |
| | | |
| | | @TableField(exist = false) |
| | | private List<BigStorageCageDetails> bigStorageCageDetails; |
| | | |
| | | |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.mes.bigstorage.entity.BigStorageCage; |
| | | import com.mes.bigstorage.entity.BigStorageCageDetails; |
| | | import com.mes.bigstorage.mapper.BigStorageCageDetailsMapper; |
| | | import com.mes.bigstorage.mapper.BigStorageCageMapper; |
| | | import com.mes.uppattenusage.entity.GlassInfo; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务类 |
| | | * 服务类 |
| | | * </p> |
| | | * |
| | | * @author zhoush |
| | | * @since 2024-03-27 |
| | | */ |
| | | public interface BigStorageCageService extends IService<BigStorageCage> { |
| | | public void updateRemainWidth(int Slot); |
| | | public BigStorageCageDetails FeedGlass(GlassInfo glassInfo, BigStorageCageDetails bigStorageCageDetails); |
| | | |
| | | void updateRemainWidth(int Slot); |
| | | |
| | | BigStorageCageDetails FeedGlass(GlassInfo glassInfo, BigStorageCageDetails bigStorageCageDetails); |
| | | |
| | | List<BigStorageCage> querybigStorageCageDetail(); |
| | | } |
| | |
| | | import com.mes.bigstorage.mapper.BigStorageCageMapper; |
| | | import com.mes.bigstorage.service.BigStorageCageService; |
| | | import com.mes.uppattenusage.entity.GlassInfo; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import javax.annotation.Resource; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务实现类 |
| | | * 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author zhoush |
| | | * @since 2024-03-27 |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | public class BigStorageCageServiceImpl extends ServiceImpl<BigStorageCageMapper, BigStorageCage> implements BigStorageCageService { |
| | | @Autowired |
| | | |
| | | @Resource |
| | | private BigStorageCageMapper bigStorageCageMapper; |
| | | @Autowired |
| | | |
| | | @Resource |
| | | private BigStorageCageDetailsMapper bigStorageCageDetailsMapper; |
| | | |
| | | @Override |
| | | public BigStorageCageDetails FeedGlass(GlassInfo glassInfo, BigStorageCageDetails bigStorageCageDetails) { |
| | | |
| | | |
| | | //获取同钢化版图id可进片的格子 |
| | | BigStorageCageDetails layoutSlotInfo =bigStorageCageMapper.SelectTemperingFeedSlot(glassInfo); |
| | | BigStorageCageDetails layoutSlotInfo = bigStorageCageMapper.SelectTemperingFeedSlot(glassInfo); |
| | | //有符合条件的格子时 |
| | | if (layoutSlotInfo!=null) { |
| | | if (layoutSlotInfo != null) { |
| | | //将玻璃信息填入理片笼详情表 |
| | | bigStorageCageDetails.setSlot(layoutSlotInfo.getSlot()); |
| | | }else{ |
| | | } else { |
| | | //获取不到时: |
| | | |
| | | //获取可进片格子信息 |
| | | BigStorageCageDetails EmptySlotInfo=bigStorageCageMapper.SelectEmptyFeedSlot(); |
| | | if (EmptySlotInfo!=null){ |
| | | BigStorageCageDetails EmptySlotInfo = bigStorageCageMapper.SelectEmptyFeedSlot(); |
| | | if (EmptySlotInfo != null) { |
| | | bigStorageCageDetails.setSlot(EmptySlotInfo.getSlot()); |
| | | }else{ |
| | | } else { |
| | | //获取其他笼格子- |
| | | BigStorageCageDetails OtherSlotInfo=bigStorageCageMapper.SelectOtherFeedSlot(); |
| | | BigStorageCageDetails OtherSlotInfo = bigStorageCageMapper.SelectOtherFeedSlot(); |
| | | bigStorageCageDetails.setSlot(OtherSlotInfo.getSlot()); |
| | | } |
| | | //将玻璃信息放入该格子 |
| | |
| | | return bigStorageCageDetails; |
| | | } |
| | | |
| | | @Override |
| | | public List<BigStorageCage> querybigStorageCageDetail() { |
| | | //1、获取大理片笼信息 |
| | | // List<BigStorageCage> bigStorageCages = bigStorageCageMapper.querybigStorageCageDetail(null); |
| | | List<BigStorageCage> bigStorageCages = bigStorageCageMapper.selectList(null); |
| | | log.info("1、获取大理片笼信息完成,获取到的数据{}", bigStorageCages.size()); |
| | | //2获取理片笼所有信息 |
| | | List<BigStorageCageDetails> bigStorageCageDetailsList = bigStorageCageDetailsMapper.selectList(null); |
| | | Map<Integer, List<BigStorageCageDetails>> listMap = bigStorageCageDetailsList.stream().collect(Collectors.groupingBy(BigStorageCageDetails::getSlot)); |
| | | for (BigStorageCage bigStorageCage : bigStorageCages) { |
| | | List<BigStorageCageDetails> bigStorageCageDetails = listMap.get(bigStorageCage.getSlot()); |
| | | bigStorageCage.setBigStorageCageDetails(bigStorageCageDetails); |
| | | } |
| | | return bigStorageCages; |
| | | |
| | | } |
| | | |
| | | //修改格子剩余宽度 |
| | | @Override |
| | | public void updateRemainWidth(int Slot){ |
| | | public void updateRemainWidth(int Slot) { |
| | | //获取该格子内玻璃信息 |
| | | int width=5000; |
| | | List<BigStorageCageDetails> bigStorageCageDetailsList= Collections.singletonList(bigStorageCageDetailsMapper.selectById(Slot)); |
| | | for (BigStorageCageDetails bigStorageCageDetails:bigStorageCageDetailsList |
| | | int width = 5000; |
| | | List<BigStorageCageDetails> bigStorageCageDetailsList = Collections.singletonList(bigStorageCageDetailsMapper.selectById(Slot)); |
| | | for (BigStorageCageDetails bigStorageCageDetails : bigStorageCageDetailsList |
| | | ) { |
| | | width-=Integer.parseInt(bigStorageCageDetails.getWidth().toString())+bigStorageCageDetails.getGap(); |
| | | width -= Integer.parseInt(bigStorageCageDetails.getWidth().toString()) + bigStorageCageDetails.getGap(); |
| | | } |
| | | //修改格子剩余宽度 |
| | | bigStorageCageMapper.UpdateRemainWidth(Slot,width); |
| | | bigStorageCageMapper.UpdateRemainWidth(Slot, width); |
| | | } |
| | | |
| | | } |
| | |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | | <artifactId>cacheGlass</artifactId> |
| | | <artifactId>loadGlass</artifactId> |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>junit</groupId> |
| | |
| | | @MapperScan(basePackages = "com.mes.*.mapper") |
| | | public class LoadGlassModuleApplication { |
| | | public static void main(String[] args) { |
| | | try { |
| | | SpringApplication.run(LoadGlassModuleApplication.class, args); |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage()); |
| | | } |
| | | |
| | | SpringApplication.run(LoadGlassModuleApplication.class, args); |
| | | } |
| | | } |
copy from hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/tools/InitUtil.java
copy to hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/common/InitUtil.java
File was copied from hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/tools/InitUtil.java |
| | |
| | | package com.mes.tools;
|
| | |
|
| | | import cn.hutool.json.JSONArray;
|
| | | import cn.hutool.json.JSONObject;
|
| | | import com.mes.device.PlcBitInfo;
|
| | | import com.mes.device.PlcBitObject;
|
| | | import com.mes.device.PlcParameterInfo;
|
| | | import com.mes.device.PlcParameterObject;
|
| | |
|
| | | import java.io.BufferedReader;
|
| | | import java.io.FileReader;
|
| | | import java.io.IOException;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Arrays;
|
| | | import java.util.List;
|
| | |
|
| | | public class InitUtil {
|
| | | //初始化word
|
| | | public static PlcParameterObject initword(String jsonFilePath) {
|
| | | try {
|
| | | FileReader fileReader = new FileReader(jsonFilePath);
|
| | | BufferedReader bufferedReader = new BufferedReader(fileReader);
|
| | |
|
| | | StringBuilder content = new StringBuilder();
|
| | | String line;
|
| | |
|
| | | while ((line = bufferedReader.readLine()) != null) {
|
| | | content.append(line);
|
| | | }
|
| | |
|
| | | bufferedReader.close();
|
| | | fileReader.close();
|
| | |
|
| | | JSONObject jsonfileobj = new JSONObject(content.toString());
|
| | | JSONArray jsonArray = jsonfileobj.getJSONArray("parameteInfor");
|
| | | PlcParameterObject plcParameterObject = new PlcParameterObject();
|
| | | plcParameterObject.setPlcAddressBegin(jsonfileobj.getStr("plcAddressBegin"));//设置起始位地址
|
| | | plcParameterObject.setPlcAddressLength(Integer.valueOf(jsonfileobj.getStr("plcAddressLenght")));//设置地址长度
|
| | |
|
| | | for (int i = 0; i < jsonArray.size(); i++) {
|
| | | JSONObject parameterObj = jsonArray.getJSONObject(i);
|
| | | PlcParameterInfo plcParameterInfo = new PlcParameterInfo(jsonfileobj.getStr("plcAddressBegin")); //参数实例
|
| | | String codeid = parameterObj.getStr("codeId");
|
| | | plcParameterInfo.setCodeId(codeid);
|
| | | plcParameterInfo.setAddressIndex(Integer.valueOf(parameterObj.getStr("addressIndex")));
|
| | | //plcParameterInfo.setRatio(Integer.valueOf(parameterObj.getStr("ratio")));
|
| | | plcParameterInfo.setAddressLength(Integer.valueOf(parameterObj.getStr("addressLenght")));
|
| | | plcParameterInfo.setUnit(parameterObj.getStr("unit"));
|
| | | plcParameterObject.addPlcParameter(plcParameterInfo);
|
| | | }
|
| | | // byte[] getplcvlues = {0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02};
|
| | | // byte[] getplcvlues = S7control.getinstance().ReadByte(plcParameterObject.getPlcAddressBegin(), plcParameterObject.getPlcAddressLength());
|
| | | // plcParameterObject.setPlcParameterList(getplcvlues);
|
| | |
|
| | | return plcParameterObject;
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | //初始化bit
|
| | | public static PlcBitObject initbit(String jsonFilePath) {
|
| | | PlcBitObject plcBitObject = new PlcBitObject();
|
| | |
|
| | | try {
|
| | | FileReader fileReader = new FileReader(jsonFilePath);
|
| | | BufferedReader bufferedReader = new BufferedReader(fileReader);
|
| | |
|
| | | StringBuilder content = new StringBuilder();
|
| | | String line;
|
| | |
|
| | | while ((line = bufferedReader.readLine()) != null) {
|
| | | content.append(line);
|
| | | }
|
| | |
|
| | | bufferedReader.close();
|
| | | fileReader.close();
|
| | |
|
| | | JSONObject jsonfileobj = new JSONObject(content.toString());
|
| | | JSONArray jsonArray = jsonfileobj.getJSONArray("parameteInfor");
|
| | | plcBitObject.setPlcAddressBegin(jsonfileobj.getStr("plcAddressBegin"));//设置起始位地址
|
| | | plcBitObject.setPlcAddressLength(Integer.valueOf(jsonfileobj.getStr("plcAddressLenght")));//设置地址长度
|
| | |
|
| | | for (int i = 0; i < jsonArray.size(); i++) {
|
| | | JSONObject parameterObj = jsonArray.getJSONObject(i);
|
| | |
|
| | | PlcBitInfo plcBitInfo = new PlcBitInfo(jsonfileobj.getStr("plcAddressBegin")); //参数实例
|
| | | String codeid = parameterObj.getStr("codeId");
|
| | | plcBitInfo.setCodeId(codeid);
|
| | | plcBitInfo.setAddressIndex(Integer.valueOf(parameterObj.getStr("addressIndex")));
|
| | |
|
| | | plcBitObject.addPlcBit(plcBitInfo);
|
| | | }
|
| | | System.out.println("");
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | //Boolean[] values1 = { false, true, true, true, false, false, true, false,
|
| | | // false, true ,true };
|
| | | // List<Boolean> getplcvlues = new ArrayList<>(Arrays.asList(values1));
|
| | |
|
| | | // List<Boolean> getplcvlues = S7control.getinstance().ReadBits(plcBitObject.getPlcAddressBegin(), plcBitObject.getPlcAddressLength());
|
| | | // plcBitObject.setPlcBitList(getplcvlues);
|
| | | return plcBitObject;
|
| | | }
|
| | |
|
| | | //
|
| | | public static void readAndUpdateBitValues(PlcBitObject plcBitObject) {
|
| | |
|
| | | Boolean[] values1 = { false, true, true, true, false, false, true, false,
|
| | | false, true ,true };
|
| | | List<Boolean> getplcvlues = new ArrayList<>(Arrays.asList(values1));
|
| | | //List<Boolean> getplcvlues = S7control.getinstance().ReadBits(plcBitObject.getPlcAddressBegin(), plcBitObject.getPlcAddressLength());
|
| | | plcBitObject.setPlcBitList(getplcvlues);
|
| | | }
|
| | |
|
| | |
|
| | | public static void readAndUpdateWordValues(PlcParameterObject plcParameterObject) {
|
| | |
|
| | | byte[] getplcvlues = {0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03,0x03};
|
| | | // byte[] getplcvlues = MockS7PLC.getInstance().readByte(plcParameterObject.getPlcAddressBegin(), plcParameterObject.getPlcAddressLength());
|
| | | plcParameterObject.setPlcParameterList(getplcvlues);
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | | }
|
| | | package com.mes.common; |
| | | |
| | | import cn.hutool.json.JSONArray; |
| | | import cn.hutool.json.JSONObject; |
| | | |
| | | import java.io.BufferedReader; |
| | | import java.io.FileReader; |
| | | import java.io.IOException; |
| | | import java.util.List; |
| | | |
| | | public class InitUtil { |
| | | //初始化word |
| | | public static PlcParameterObject initword(String jsonFilePath) { |
| | | try { |
| | | FileReader fileReader = new FileReader(jsonFilePath); |
| | | BufferedReader bufferedReader = new BufferedReader(fileReader); |
| | | |
| | | StringBuilder content = new StringBuilder(); |
| | | String line; |
| | | |
| | | while ((line = bufferedReader.readLine()) != null) { |
| | | content.append(line); |
| | | } |
| | | |
| | | bufferedReader.close(); |
| | | fileReader.close(); |
| | | |
| | | JSONObject jsonfileobj = new JSONObject(content.toString()); |
| | | JSONArray jsonArray = jsonfileobj.getJSONArray("parameteInfor"); |
| | | PlcParameterObject plcParameterObject = new PlcParameterObject(); |
| | | plcParameterObject.setPlcAddressBegin(jsonfileobj.getStr("plcAddressBegin"));//设置起始位地址 |
| | | plcParameterObject.setPlcAddressLength(Integer.valueOf(jsonfileobj.getStr("plcAddressLenght")));//设置地址长度 |
| | | |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | JSONObject parameterObj = jsonArray.getJSONObject(i); |
| | | PlcParameterInfo plcParameterInfo = new PlcParameterInfo(jsonfileobj.getStr("plcAddressBegin")); //参数实例 |
| | | String codeid = parameterObj.getStr("codeId"); |
| | | plcParameterInfo.setCodeId(codeid); |
| | | plcParameterInfo.setAddressIndex(Integer.valueOf(parameterObj.getStr("addressIndex"))); |
| | | //plcParameterInfo.setRatio(Integer.valueOf(parameterObj.getStr("ratio"))); |
| | | plcParameterInfo.setAddressLength(Integer.valueOf(parameterObj.getStr("addressLenght"))); |
| | | plcParameterInfo.setUnit(parameterObj.getStr("unit")); |
| | | plcParameterObject.addPlcParameter(plcParameterInfo); |
| | | } |
| | | // byte[] getplcvlues = {0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02}; |
| | | // byte[] getplcvlues = S7control.getinstance().ReadByte(plcParameterObject.getPlcAddressBegin(), plcParameterObject.getPlcAddressLength()); |
| | | // plcParameterObject.setPlcParameterList(getplcvlues); |
| | | |
| | | return plcParameterObject; |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | //初始化bit |
| | | public static PlcBitObject initbit(String jsonFilePath) { |
| | | PlcBitObject plcBitObject = new PlcBitObject(); |
| | | |
| | | try { |
| | | FileReader fileReader = new FileReader(jsonFilePath); |
| | | BufferedReader bufferedReader = new BufferedReader(fileReader); |
| | | |
| | | StringBuilder content = new StringBuilder(); |
| | | String line; |
| | | |
| | | while ((line = bufferedReader.readLine()) != null) { |
| | | content.append(line); |
| | | } |
| | | |
| | | bufferedReader.close(); |
| | | fileReader.close(); |
| | | |
| | | JSONObject jsonfileobj = new JSONObject(content.toString()); |
| | | JSONArray jsonArray = jsonfileobj.getJSONArray("parameteInfor"); |
| | | plcBitObject.setPlcAddressBegin(jsonfileobj.getStr("plcAddressBegin"));//设置起始位地址 |
| | | plcBitObject.setPlcAddressLength(Integer.valueOf(jsonfileobj.getStr("plcAddressLenght")));//设置地址长度 |
| | | |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | JSONObject parameterObj = jsonArray.getJSONObject(i); |
| | | |
| | | PlcBitInfo plcBitInfo = new PlcBitInfo(jsonfileobj.getStr("plcAddressBegin")); //参数实例 |
| | | String codeid = parameterObj.getStr("codeId"); |
| | | plcBitInfo.setCodeId(codeid); |
| | | plcBitInfo.setAddressIndex(Integer.valueOf(parameterObj.getStr("addressIndex"))); |
| | | |
| | | plcBitObject.addPlcBit(plcBitInfo); |
| | | } |
| | | System.out.println(""); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | //Boolean[] values1 = { false, true, true, true, false, false, true, false, |
| | | // false, true ,true }; |
| | | // List<Boolean> getplcvlues = new ArrayList<>(Arrays.asList(values1)); |
| | | |
| | | // List<Boolean> getplcvlues = S7control.getinstance().ReadBits(plcBitObject.getPlcAddressBegin(), plcBitObject.getPlcAddressLength()); |
| | | // plcBitObject.setPlcBitList(getplcvlues); |
| | | return plcBitObject; |
| | | } |
| | | |
| | | // |
| | | public static void readAndUpdateBitValues(PlcBitObject plcBitObject) { |
| | | |
| | | // Boolean[] values1 = { false, true, true, true, false, false, true, false, |
| | | // false, true ,true }; |
| | | // List<Boolean> getplcvlues = new ArrayList<>(Arrays.asList(values1)); |
| | | List<Boolean> getplcvlues = S7object.getinstance().plccontrol.ReadBits(plcBitObject.getPlcAddressBegin(), plcBitObject.getPlcAddressLength()); |
| | | plcBitObject.setPlcBitList(getplcvlues); |
| | | } |
| | | |
| | | |
| | | public static void readAndUpdateWordValues(PlcParameterObject plcParameterObject) { |
| | | |
| | | // byte[] getplcvlues = {0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02}; |
| | | byte[] getplcvlues = S7object.getinstance().plccontrol.ReadByte(plcParameterObject.getPlcAddressBegin(), plcParameterObject.getPlcAddressLength()); |
| | | plcParameterObject.setPlcParameterList(getplcvlues); |
| | | } |
| | | |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.mes.common; |
| | | |
| | | |
| | | import java.io.IOException; |
| | | |
| | | import static com.mes.common.InitUtil.readAndUpdateWordValues; |
| | | |
| | | public class PLCAutoMes extends Thread { |
| | | |
| | | // // 用于存储应用程序的配置信息 |
| | | // private Configuration config; |
| | | private static InitUtil initUtil; |
| | | // public static PlcParameterObject PlcMesObject; |
| | | // public static PlcParameterObject PlcReadObject; |
| | | // public static PlcParameterObject PlcframeObject; |
| | | |
| | | // // 创建一个自定义的 S7 控制器消息处理器对象 |
| | | // MessageHandler customS7Control = new MessageHandler(); |
| | | |
| | | // 单例实例 |
| | | private static PLCAutoMes instance; |
| | | // private static String PlcMes = PLCAutoMes.class.getResource("/JsonFile/PlcMes.json").getPath(); |
| | | private static String PlcAlbania = PLCAutoMes.class.getResource("/JsonFile/PlcLoadGlass.json").getPath(); |
| | | // private static String PlcRead = PLCAutoMes.class.getResource("/JsonFile/PlcRead.json").getPath(); |
| | | // private static String Plcframe = PLCAutoMes.class.getResource("/JsonFile/Plcframe.json").getPath(); |
| | | // private static String PlcParameter = PLCAutomaticParameterSettingReview2.class.getResource("/JsonFile/PlcParameter.json").getPath(); |
| | | |
| | | // private static String PlcSign = PLCAutomaticParameterSettingReview2.class.getResource("/JsonFile/PlcSign.json").getPath(); |
| | | |
| | | // private static String PlcState = PLCAutomaticParameterSettingReview2.class.getResource("/JsonFile/PlcState.json").getPath(); |
| | | |
| | | // private static String PlcAlarm = PLCAutoMes.class.getResource("/JsonFile/PlcAlarm.json").getPath(); |
| | | // private static String PlcTest = PLCAutoMes.class.getResource("/JsonFile/PlcTest.json").getPath(); |
| | | |
| | | // 调用initword方法 |
| | | |
| | | // public static PlcParameterObject plcParameterObject = initUtil.initword(PlcParameter); |
| | | // public static PlcBitObject plcPlcTest = initUtil.initbit(PlcTest); |
| | | // public static PlcBitObject plcBitObject = initUtil.initbit(PlcSign); |
| | | // public static PlcParameterObject plcStateObject= initUtil.initword(PlcState); |
| | | // public static PlcBitObject plcPlcAlarm = initUtil.initbit(PlcAlarm); |
| | | public static PlcParameterObject PlcMesObject = InitUtil.initword(PlcAlbania); |
| | | // public static PlcParameterObject PlcReadObject = initUtil.initword(PlcRead); |
| | | // public static PlcParameterObject PlcframeObject = initUtil.initword(Plcframe); |
| | | |
| | | // 私有构造函数 |
| | | public PLCAutoMes() throws IOException { |
| | | //config = new Configuration("config.properties"); |
| | | initUtil = new InitUtil(); |
| | | } |
| | | |
| | | // 获取单例实例 |
| | | public static synchronized PLCAutoMes getInstance() throws IOException { |
| | | if (instance == null) { |
| | | instance = new PLCAutoMes(); |
| | | } |
| | | return instance; |
| | | } |
| | | |
| | | @Override |
| | | public void run() { |
| | | while (this != null) { |
| | | try { |
| | | Thread.sleep(100); |
| | | |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | // System.out.println(jsonFilePath); |
| | | |
| | | //readAndUpdateWordValues(PlcReadObject); |
| | | readAndUpdateWordValues(PlcMesObject); |
| | | //readAndUpdateWordValues(PlcframeObject); |
| | | // readAndUpdateWordValues(PlcframeObject); |
| | | |
| | | // readAndUpdateWordValues(plcStateObject); |
| | | // int index = PlcMesObject.getPlcParameter("AddStart").getAddressIndex(); |
| | | // // System.out.println(index); |
| | | // PlcMesObject.getPlcParameter("AddStart").getAddress(index); |
| | | // // System.out.println(PlcMesObject.getPlcParameter("AddStart").getAddress(index)); |
| | | // List<String> addresses = new ArrayList<>(); |
| | | // addresses.add("FeedID"); |
| | | // addresses.add("AddStart"); |
| | | // // System.out.println(addresses); |
| | | // // System.out.println(PlcMesObject.getPlcParameterValues(addresses)); |
| | | // List<String> addresses2 = new ArrayList<>(); |
| | | // addresses2.add("FeedID"); |
| | | // addresses2.add("FeedCarStatus"); |
| | | |
| | | //System.out.println(PlcReadObject.getPlcParameterValues(addresses2)); |
| | | |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.mes.common; |
| | | |
| | | |
| | | |
| | | public class PlcBitInfo { |
| | | |
| | | public PlcBitInfo(String startAddress) { |
| | | this.startAddress = startAddress; |
| | | } |
| | | private String startAddress; |
| | | // 参数标识 |
| | | private String codeId; |
| | | |
| | | // 参数名称 |
| | | private String name; |
| | | |
| | | // 读取 参数值 |
| | | private Boolean value; |
| | | // 参数地址 |
| | | private int addressIndex; |
| | | |
| | | public String getCodeId() { |
| | | return this.codeId; |
| | | } |
| | | |
| | | public void setCodeId(String codeId) { |
| | | this.codeId = codeId; |
| | | } |
| | | |
| | | public String getName() { |
| | | return this.name; |
| | | } |
| | | |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | public Boolean getValue() { |
| | | return this.value; |
| | | } |
| | | |
| | | public void setValue(Boolean value) { |
| | | this.value = value; |
| | | } |
| | | |
| | | |
| | | public int getAddressIndex() { |
| | | return this.addressIndex; |
| | | } |
| | | /** |
| | | * 获取地址 |
| | | * |
| | | * @param index 索引地址 |
| | | */ |
| | | public String getAddress(int index) { |
| | | String[] stringdatas = this.startAddress.trim().split("\\."); |
| | | if (stringdatas.length < 2 ) |
| | | return null; |
| | | int dbwindex = 0; |
| | | int bitindex = 0; |
| | | if (stringdatas.length == 3) { |
| | | dbwindex = Integer.parseInt(stringdatas[1]); |
| | | bitindex = Integer.parseInt(stringdatas[2]); |
| | | } else |
| | | return null; |
| | | dbwindex+=index/8; |
| | | bitindex+=index%8; |
| | | return stringdatas[0]+"."+dbwindex+"."+bitindex; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | public void setAddressIndex(int addressindex) { |
| | | this.addressIndex = addressindex; |
| | | } |
| | | } |
New file |
| | |
| | | package com.mes.common; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | public class PlcBitObject { |
| | | |
| | | // 该模块数据类型,数据起始位置 |
| | | private String plcAddressBegin; |
| | | // 数据地址长度:第一参数到最后一个参数的长度 |
| | | private int plcAddressLength; |
| | | private ArrayList<PlcBitInfo> plcBitList; |
| | | |
| | | /** |
| | | * @return 数据区开始地址 |
| | | */ |
| | | public String getPlcAddressBegin() { |
| | | return plcAddressBegin; |
| | | } |
| | | |
| | | /** |
| | | * @param plcAddressBegin 设置数据区开始地址 |
| | | */ |
| | | public void setPlcAddressBegin(String plcAddressBegin) { |
| | | this.plcAddressBegin = plcAddressBegin; |
| | | } |
| | | |
| | | /** |
| | | * @return 数据区 读取所有数据所需的长度(以byte类型为基准) |
| | | */ |
| | | public int getPlcAddressLength() { |
| | | return plcAddressLength; |
| | | } |
| | | |
| | | /** |
| | | * @return 设置:数据区 读取所有数据所需的长度(以byte类型为基准) |
| | | */ |
| | | public void setPlcAddressLength(int plcAddressLength) { |
| | | this.plcAddressLength = plcAddressLength; |
| | | } |
| | | |
| | | /** |
| | | * @return 获取参数实例集合 |
| | | */ |
| | | public ArrayList<PlcBitInfo> getBitList() { |
| | | return plcBitList; |
| | | } |
| | | |
| | | /** |
| | | * 根据参数标识 获取某个参数实例 |
| | | * |
| | | * @param codeid 参数标识 |
| | | * @return 获取某个参数实例 |
| | | */ |
| | | public PlcBitInfo getPlcBit(String codeid) { |
| | | if (plcBitList != null) { |
| | | for (PlcBitInfo plcbitInfo : plcBitList) { |
| | | if (plcbitInfo.getCodeId().equals(codeid)) |
| | | return plcbitInfo; |
| | | } |
| | | return null; |
| | | } else |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 根据参数标识 获取某个参数实例 |
| | | * |
| | | * @param codeid 参数标识 |
| | | * @return 获取某个参数实例 |
| | | */ |
| | | public List<Boolean> getPlcBitValues(List<String> codeids) { |
| | | List<Boolean> arrayList = new ArrayList<>(); |
| | | if (plcBitList != null) { |
| | | Map<String, Boolean> resultMap = new LinkedHashMap<>(); // 使用 LinkedHashMap 保留插入顺序 |
| | | for (PlcBitInfo plcBitInfo : plcBitList) { |
| | | if (codeids.contains(plcBitInfo.getCodeId().toString())) { |
| | | resultMap.put(plcBitInfo.getCodeId().toString(), plcBitInfo.getValue()); |
| | | } |
| | | } |
| | | for (String codeId : codeids) { // 按照传入参数的顺序遍历 |
| | | Boolean value = resultMap.get(codeId); |
| | | if (value != null) { |
| | | arrayList.add(value); |
| | | } else { |
| | | arrayList.add(null); // 如果找不到对应的值,添加 null |
| | | } |
| | | } |
| | | } |
| | | return arrayList; |
| | | } |
| | | |
| | | |
| | | public List<String> getAddressListByCodeId(List<String> codeIdList) { |
| | | List<String> addressList = new ArrayList<>(); |
| | | for (String codeId : codeIdList) { |
| | | for (PlcBitInfo plcBitInfo : plcBitList) { |
| | | if (plcBitInfo.getCodeId().equals(codeId)) { |
| | | int index = plcBitInfo.getAddressIndex(); |
| | | String address = plcBitInfo.getAddress(index); |
| | | if (address != null) { |
| | | addressList.add(address); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return addressList; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 添加参数实例 |
| | | * |
| | | * @param param 参数实例 |
| | | */ |
| | | public void addPlcBit(PlcBitInfo param) { |
| | | if (plcBitList != null) |
| | | plcBitList.add(param); |
| | | else { |
| | | plcBitList = new ArrayList<PlcBitInfo>(); |
| | | plcBitList.add(param); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据PLC返回的数据 给参数实例赋值 |
| | | * |
| | | * @param plcValueArray PLC读取回来的byte类型数据集合 |
| | | */ |
| | | public void setPlcBitList(List<Boolean> plcValueArray) { |
| | | if (plcBitList != null) { |
| | | for (PlcBitInfo plcbitInfo : plcBitList) { |
| | | plcbitInfo.setValue(plcValueArray.get(plcbitInfo.getAddressIndex())); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.mes.common; |
| | | public class PlcParameterInfo { |
| | | public PlcParameterInfo(String startAddress) { |
| | | this.startAddress = startAddress; |
| | | } |
| | | private String startAddress; |
| | | // 参数标识 |
| | | private String codeId; |
| | | |
| | | // 参数名称 |
| | | private String name; |
| | | |
| | | // 读取 参数值 |
| | | private String value; |
| | | |
| | | // // 写入 参数值 |
| | | // private String writeValue; |
| | | |
| | | // 参数单位 |
| | | private String unit; |
| | | |
| | | // 参数值转换系数 |
| | | private int ratio; |
| | | |
| | | // 参数地址 |
| | | private int addressIndex; |
| | | |
| | | // 参数地址位长度 |
| | | private int addressLength; |
| | | |
| | | public String getCodeId() { |
| | | return this.codeId; |
| | | } |
| | | |
| | | public void setCodeId(String codeId) { |
| | | this.codeId = codeId; |
| | | } |
| | | |
| | | public String getName() { |
| | | return this.name; |
| | | } |
| | | |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | public String getValue() { |
| | | return this.value; |
| | | } |
| | | |
| | | public void setValue(String value) { |
| | | this.value = value; |
| | | } |
| | | |
| | | // public String getWriteValue() { |
| | | // return this.writeValue; |
| | | // } |
| | | |
| | | // public void setWriteValue(String writeValue) { |
| | | // this.writeValue = writeValue; |
| | | // } |
| | | |
| | | public String getUnit() { |
| | | return this.unit; |
| | | } |
| | | |
| | | public void setUnit(String unit) { |
| | | this.unit = unit; |
| | | } |
| | | |
| | | public int getAddressIndex() { |
| | | return this.addressIndex; |
| | | } |
| | | |
| | | public void setAddressIndex(int addressindex) { |
| | | this.addressIndex = addressindex; |
| | | } |
| | | |
| | | public int getAddressLength() { |
| | | return this.addressLength; |
| | | } |
| | | |
| | | public void setAddressLength(int addresslength) { |
| | | this.addressLength = addresslength; |
| | | } |
| | | |
| | | public int getRatio() { |
| | | return this.ratio; |
| | | } |
| | | |
| | | public void setRatio(int ratio) { |
| | | this.ratio = ratio; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取地址 |
| | | * |
| | | * @param index 索引地址 |
| | | */ |
| | | public String getAddress(int index) { |
| | | String[] stringdatas = this.startAddress.trim().split("\\."); |
| | | int addressLength=this.addressLength; |
| | | if (addressLength < 2 ){ |
| | | return null; |
| | | } |
| | | |
| | | if (addressLength == 2 ) { |
| | | int wordindex = index; |
| | | |
| | | return stringdatas[0] + "." + wordindex; |
| | | } |
| | | if (addressLength == 14 ) { |
| | | int wordindex = index; |
| | | //int newIndex = wordindex + 13; |
| | | return stringdatas[0] + "." + wordindex ; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public int getPlcAddress() { |
| | | |
| | | return addressIndex; |
| | | } |
| | | public String getAddress() { |
| | | return getAddress(this.addressIndex); |
| | | } |
| | | } |
New file |
| | |
| | | package com.mes.common; |
| | | |
| | | import java.lang.reflect.Array; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.ArrayList; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | public class PlcParameterObject { |
| | | |
| | | // 该模块数据类型,数据起始位置 |
| | | private String plcAddressBegin; |
| | | // 数据地址长度:第一参数到最后一个参数的长度 |
| | | private int plcAddressLength; |
| | | private ArrayList<PlcParameterInfo> plcParameterList; |
| | | |
| | | /** |
| | | * @return 数据区开始地址 |
| | | */ |
| | | public String getPlcAddressBegin() { |
| | | return plcAddressBegin; |
| | | } |
| | | |
| | | /** |
| | | * @param plcAddressBegin 设置数据区开始地址 |
| | | */ |
| | | public void setPlcAddressBegin(String plcAddressBegin) { |
| | | this.plcAddressBegin = plcAddressBegin; |
| | | } |
| | | |
| | | /** |
| | | * @return 数据区 读取所有数据所需的长度(以byte类型为基准) |
| | | */ |
| | | public int getPlcAddressLength() { |
| | | return plcAddressLength; |
| | | } |
| | | |
| | | /** |
| | | * @return 设置:数据区 读取所有数据所需的长度(以byte类型为基准) |
| | | */ |
| | | public void setPlcAddressLength(int plcAddressLength) { |
| | | this.plcAddressLength = plcAddressLength; |
| | | } |
| | | |
| | | /** |
| | | * @return 获取参数实例集合 |
| | | */ |
| | | public ArrayList<PlcParameterInfo> getPlcParameterList() { |
| | | return plcParameterList; |
| | | } |
| | | |
| | | /** |
| | | * 根据参数标识 获取某个参数实例 |
| | | * |
| | | * @param codeid 参数标识 |
| | | * @return 获取某个参数实例 |
| | | */ |
| | | public PlcParameterInfo getPlcParameter(String codeid) { |
| | | if (plcParameterList != null) { |
| | | for (PlcParameterInfo plcParameterInfo : plcParameterList) { |
| | | if (plcParameterInfo.getCodeId().equals(codeid)) |
| | | return plcParameterInfo; |
| | | } |
| | | return null; |
| | | } else |
| | | return null; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 根据参数标识 获取某个参数实例 |
| | | * |
| | | * @param codeids 参数标识 |
| | | * @return 获取某个参数实例 |
| | | */ |
| | | public List<String> getPlcParameterValues(List<String> codeids) { |
| | | List<String> arrayList = new ArrayList<>(); |
| | | if (plcParameterList != null) { |
| | | Map<String, PlcParameterInfo> resultMap = new LinkedHashMap<>(); // 使用 LinkedHashMap 保留插入顺序 |
| | | for (PlcParameterInfo plcParameterInfo : plcParameterList) { |
| | | if (codeids.contains(plcParameterInfo.getCodeId())) { |
| | | resultMap.put(plcParameterInfo.getCodeId(), plcParameterInfo); |
| | | } |
| | | } |
| | | for (String codeId : codeids) { // 按照传入参数的顺序遍历 |
| | | PlcParameterInfo plcParameterInfo = resultMap.get(codeId); |
| | | if (plcParameterInfo != null) { |
| | | arrayList.add(plcParameterInfo.getValue()); |
| | | } else { |
| | | arrayList.add(null); // 如果找不到对应的值,添加 null |
| | | } |
| | | } |
| | | } |
| | | return arrayList; |
| | | } |
| | | |
| | | |
| | | public List<String> getAddressListByCodeId(List<String> codeIdList) { |
| | | List<String> addressList = new ArrayList<>(); |
| | | for (String codeId : codeIdList) { |
| | | for (PlcParameterInfo plcParameterInfo : plcParameterList) { |
| | | if (plcParameterInfo.getCodeId().equals(codeId)) { |
| | | int index = plcParameterInfo.getAddressIndex(); |
| | | String address = plcParameterInfo.getAddress(index); |
| | | if (address != null) { |
| | | addressList.add(address); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return addressList; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 添加参数实例 |
| | | * |
| | | * @param param 参数实例 |
| | | */ |
| | | public void addPlcParameter(PlcParameterInfo param) { |
| | | if (plcParameterList != null) |
| | | plcParameterList.add(param); |
| | | else { |
| | | plcParameterList = new ArrayList<PlcParameterInfo>(); |
| | | plcParameterList.add(param); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据PLC返回的数据 给参数实例赋值 |
| | | * |
| | | * @param plcValueArray PLC读取回来的byte类型数据集合 |
| | | */ |
| | | public void setPlcParameterList(byte[] plcValueArray) { |
| | | if (plcParameterList != null) { |
| | | |
| | | for (PlcParameterInfo plcParameterInfo : plcParameterList) { |
| | | |
| | | byte[] valueList = new byte[plcParameterInfo.getAddressLength()]; |
| | | |
| | | // System.out.println(plcParameterInfo.getAddressLength()); |
| | | |
| | | for (int i = 0; i < plcParameterInfo.getAddressLength(); i++) { |
| | | Array.setByte(valueList, i, plcValueArray[plcParameterInfo.getAddressIndex() + i]); |
| | | |
| | | } |
| | | if (plcParameterInfo.getAddressLength()==2) { |
| | | plcParameterInfo.setValue(String.valueOf(byte2short(valueList))); |
| | | } |
| | | else if (plcParameterInfo.getAddressLength()==14) { |
| | | plcParameterInfo.setValue((byteToHexString(valueList))); |
| | | } |
| | | |
| | | else |
| | | { |
| | | String valuestr = new String(valueList); |
| | | plcParameterInfo.setValue(valuestr); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | /** |
| | | * short类型转byte[] |
| | | * |
| | | * @param s short类型值 |
| | | */ |
| | | public static byte[] short2byte(short s){ |
| | | byte[] b = new byte[2]; |
| | | for(int i = 0; i < 2; i++){ |
| | | int offset = 16 - (i+1)*8; //因为byte占4个字节,所以要计算偏移量 |
| | | b[i] = (byte)((s >> offset)&0xff); //把16位分为2个8位进行分别存储 |
| | | } |
| | | return b; |
| | | } |
| | | /** |
| | | * byte[]类型转short |
| | | * |
| | | * @param b byte[]类型值 |
| | | */ |
| | | public static short byte2short(byte[] b){ |
| | | short l = 0; |
| | | for (int i = 0; i < 2; i++) { |
| | | l<<=8; //<<=和我们的 +=是一样的,意思就是 l = l << 8 |
| | | l |= (b[i] & 0xff); //和上面也是一样的 l = l | (b[i]&0xff) |
| | | } |
| | | return l; |
| | | } |
| | | |
| | | public static String byteToHexString(byte[] bytes) { |
| | | |
| | | String str = new String(bytes, StandardCharsets.UTF_8); |
| | | return str; |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.mes.common; |
| | | |
| | | import com.github.xingshuangs.iot.protocol.s7.enums.EPlcType; |
| | | import com.mes.tools.S7control; |
| | | |
| | | /** |
| | | * @Author : zhoush |
| | | * @Date: 2024/4/9 15:13 |
| | | * @Description: |
| | | */ |
| | | public class S7object { |
| | | public S7control plccontrol; // PLC通讯类实例 |
| | | private EPlcType plcType = EPlcType.S1500; // 西门子PLC类型 |
| | | private String ip = "192.168.10.1"; // plc ip地址 |
| | | private int port = 102; // plc 端口号 |
| | | |
| | | private static volatile S7object instance = null; |
| | | |
| | | private S7object() { |
| | | if (plccontrol == null) { |
| | | plccontrol = new S7control(plcType, ip, port,0,0); |
| | | } |
| | | } |
| | | |
| | | // 单例模式 获取类的唯一实例 |
| | | public static S7object getinstance() { |
| | | if (instance == null) { |
| | | synchronized (S7object.class) { |
| | | if (instance == null) { |
| | | instance = new S7object(); |
| | | } |
| | | } |
| | | } |
| | | return instance; |
| | | } |
| | | } |
New file |
| | |
| | | package com.mes.workstation.controller; |
| | | |
| | | |
| | | import com.mes.workstation.entity.UpWorkstation; |
| | | import com.mes.workstation.service.UpWorkstationService; |
| | | import com.mes.utils.Result; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * 前端控制器 |
| | | * </p> |
| | | * |
| | | * @author zhoush |
| | | * @since 2024-04-07 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/LoadGlass") |
| | | @Slf4j |
| | | public class UpWorkstationController { |
| | | @Autowired |
| | | private UpWorkstationService upWorkstationService; |
| | | |
| | | @ApiOperation("显示工位上的玻璃信息") |
| | | @GetMapping("/list") //查询现在上片机的玻璃信息 |
| | | public Result<List<UpWorkstation>> list() { |
| | | List<UpWorkstation> glass = upWorkstationService.list(); |
| | | log.info("显示工位上的玻璃信息:{}", glass); |
| | | return Result.build(200, "", glass); |
| | | } |
| | | |
| | | @PostMapping("/updateGlassMessage") //修改一条工位信息,接收实例类字段为宽高厚膜系数量工位id |
| | | @ResponseBody |
| | | public void updateGlassMessage(@RequestBody UpWorkstation upwork) { |
| | | upWorkstationService.updateGlassMessage(upwork); |
| | | } |
| | | |
| | | //todo: 和updateGlassMessage类似 |
| | | // @PostMapping("/deleteGlass") //修改一条工位的玻璃信息,传输工位id将玻璃信息相关字段更改为null |
| | | // @ResponseBody |
| | | // public void selectCutTerritory(int upworkid) { |
| | | // loadGlassService.deleteGlass(upworkid); |
| | | // } |
| | | |
| | | @PostMapping("/selectPriority") //开始上片任务 |
| | | @ResponseBody |
| | | public void selectPriority() { |
| | | upWorkstationService.selectPriority(); |
| | | } |
| | | } |
| | | |
New file |
| | |
| | | package com.mes.workstation.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * <p> |
| | | * |
| | | * </p> |
| | | * |
| | | * @author zhoush |
| | | * @since 2024-04-07 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | public class GlassInfo implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 玻璃信息表id |
| | | */ |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 流程卡 |
| | | */ |
| | | private String flowcardId; |
| | | |
| | | /** |
| | | * 流程卡玻璃类型 |
| | | */ |
| | | private Integer glassType; |
| | | |
| | | /** |
| | | * 宽 |
| | | */ |
| | | private Double width; |
| | | |
| | | /** |
| | | * 高 |
| | | */ |
| | | private Double height; |
| | | |
| | | /** |
| | | * 厚度 |
| | | */ |
| | | private Double thickness; |
| | | |
| | | /** |
| | | * 膜系 |
| | | */ |
| | | private Integer filmsid; |
| | | |
| | | /** |
| | | * 磨前宽 |
| | | */ |
| | | private Double edgWidth; |
| | | |
| | | /** |
| | | * 磨前高 |
| | | */ |
| | | private Double edgHeight; |
| | | |
| | | /** |
| | | * 是否配片 |
| | | */ |
| | | private Integer ismultiple; |
| | | |
| | | /** |
| | | * 配片最大宽 |
| | | */ |
| | | private Double maxWidth; |
| | | |
| | | /** |
| | | * 配片最大高 |
| | | */ |
| | | private Double maxHeight; |
| | | |
| | | /** |
| | | * 钢化是否接受横放 |
| | | */ |
| | | private Integer ishorizontal; |
| | | |
| | | /** |
| | | * 原片顺序 |
| | | */ |
| | | private Integer patternSequence; |
| | | |
| | | /** |
| | | * 钢化版图id |
| | | */ |
| | | private Integer temperingLayoutId; |
| | | |
| | | /** |
| | | * 钢化版图片序 |
| | | */ |
| | | private Integer temperingFeedSequence; |
| | | |
| | | /** |
| | | * x坐标 |
| | | */ |
| | | private Integer xCoordinate; |
| | | |
| | | /** |
| | | * y坐标 |
| | | */ |
| | | private Integer yCoordinate; |
| | | |
| | | /** |
| | | * 旋转角度(逆时针) |
| | | */ |
| | | private Integer angle; |
| | | |
| | | /** |
| | | * 工程号 |
| | | */ |
| | | private Integer engineerId; |
| | | |
| | | /** |
| | | * 生产规则id |
| | | */ |
| | | private Integer ruleId; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.mes.workstation.entity; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author wu |
| | | */ |
| | | @Data |
| | | public class UpWorkSequence { |
| | | |
| | | private int sequence; |
| | | |
| | | private int number; |
| | | |
| | | } |
File was renamed from hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/upworkstation/entity/UpWorkstation.java |
| | |
| | | package com.mes.upworkstation.entity; |
| | | package com.mes.workstation.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
New file |
| | |
| | | package com.mes.workstation.mapper; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | |
| | | import java.util.Map; |
| | | |
| | | import org.apache.ibatis.annotations.*; |
| | | import com.mes.workstation.entity.UpWorkstation; |
| | | @Mapper |
| | | public interface LoadGlassMapper extends BaseMapper<UpWorkstation> { |
| | | //判断优先工位吸片 |
| | | @Select("select b.layout_sequence,a.number from up_workstation a left join up_patten_usage b " + |
| | | "on a.pattern_width=b.width and a.pattern_heigth=b.width " + |
| | | "and a.pattern_thickness=b.thickness where a.workstation_id=#{id}") |
| | | Map<String,Object> selectPriority(int id); |
| | | |
| | | } |
New file |
| | |
| | | package com.mes.workstation.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.mes.workstation.entity.UpWorkSequence; |
| | | import com.mes.workstation.entity.UpWorkstation; |
| | | import io.lettuce.core.dynamic.annotation.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * Mapper 接口 |
| | | * </p> |
| | | * |
| | | * @author zhoush |
| | | * @since 2024-04-07 |
| | | */ |
| | | public interface UpWorkstationMapper extends BaseMapper<UpWorkstation> { |
| | | |
| | | List<UpWorkSequence> selectPriority(@Param("id") int id); |
| | | } |
New file |
| | |
| | | package com.mes.workstation.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.mes.workstation.entity.UpWorkstation; |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务类 |
| | | * </p> |
| | | * |
| | | * @author zhoush |
| | | * @since 2024-04-07 |
| | | */ |
| | | public interface UpWorkstationService extends IService<UpWorkstation> { |
| | | //PlcParameterObject plcmes=PLCAutoMes.PlcMesObject; |
| | | |
| | | //删除人工搬走的玻璃信息 |
| | | // public void deleteGlass(int id); |
| | | //判断是否可以吸片进行任务 |
| | | |
| | | //判断优先吸片位置后发送出片任务 |
| | | public void selectPriority() ; |
| | | |
| | | |
| | | /** |
| | | * 增加人工输入的工位玻璃信息 |
| | | * @param upwork |
| | | */ |
| | | void updateGlassMessage(UpWorkstation upwork); |
| | | } |
New file |
| | |
| | | package com.mes.workstation.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.mes.common.S7object; |
| | | import com.mes.workstation.entity.UpWorkSequence; |
| | | import com.mes.workstation.entity.UpWorkstation; |
| | | import com.mes.workstation.mapper.UpWorkstationMapper; |
| | | import com.mes.workstation.service.UpWorkstationService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author zhoush |
| | | * @since 2024-04-07 |
| | | */ |
| | | @Service |
| | | public class UpWorkstationServiceImpl extends ServiceImpl<UpWorkstationMapper, UpWorkstation> implements UpWorkstationService { |
| | | |
| | | public static final String DB_100_10 = "DB_100_10"; |
| | | |
| | | //判断是否可以吸片进行任务 |
| | | public boolean isCanLoadGlass() { |
| | | String loadstart="吸片信号";//plcmes.getPlcParameter("吸片信号").getValue(); |
| | | return "1".equals(loadstart); |
| | | |
| | | } |
| | | //判断优先吸片位置后发送出片任务 |
| | | public void selectPriority() { |
| | | //todo:判断是否可以吸片进行任务 |
| | | // String loadstart="吸片信号";//plcmes.getPlcParameter("吸片信号").getValue(); |
| | | // if (!"1".equals(loadstart)) { |
| | | // return; |
| | | // } |
| | | UpWorkSequence loadid1 = this.baseMapper.selectPriority(1).get(0); |
| | | UpWorkSequence loadid2 = this.baseMapper.selectPriority(2).get(0); |
| | | //判断一二号工位哪边的顺序更先 |
| | | if(loadid1.getSequence()>loadid2.getSequence()) { |
| | | S7object.getinstance().plccontrol.WriteWord(DB_100_10, (short)2); |
| | | }else if(loadid1.getSequence()==loadid2.getSequence()){ |
| | | //当两个工位上的玻璃数相同时,判断哪个工位上的玻璃数更少,优先清空一个架子 |
| | | int glassnum1=loadid1.getNumber();//Integer.parseInt(plcmes.getPlcParameter("玻璃数").getValue()); |
| | | int glassnum2=loadid2.getNumber();//Integer.parseInt(plcmes.getPlcParameter("玻璃数").getValue()); |
| | | if(glassnum1>glassnum2){ |
| | | S7object.getinstance().plccontrol.WriteWord(DB_100_10, (short)2); |
| | | }else{ |
| | | S7object.getinstance().plccontrol.WriteWord(DB_100_10, (short)1); |
| | | } |
| | | }else{ |
| | | S7object.getinstance().plccontrol.WriteWord(DB_100_10, (short)1); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 增加人工输入的工位玻璃信息/删除人工搬走的玻璃信息 |
| | | * @param upwork |
| | | */ |
| | | @Override |
| | | public void updateGlassMessage(UpWorkstation upwork) { |
| | | UpdateWrapper<UpWorkstation> updateWrapper = new UpdateWrapper<>(); |
| | | updateWrapper.eq("workstation_id", upwork.getWorkstationId()); |
| | | int update = this.baseMapper.update(upwork, updateWrapper); |
| | | } |
| | | |
| | | } |
| | |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | | <artifactId>cacheGlass</artifactId> |
| | | <artifactId>temperingGlass</artifactId> |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>junit</groupId> |
| | |
| | | package com.mes.temperingglass.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.mes.temperingglass.entity.GlassInfo; |
| | | import com.mes.temperingglass.entity.TemperingGlassInfo; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Select; |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.apache.ibatis.annotations.*; |
| | | |
| | | @Mapper |
| | | public interface TemperingMapper extends BaseMapper<TemperingGlassInfo> { |
| | | |
| | | |
| | | //查询该玻璃的尺寸和坐标 |
| | | @Select("select *from glass_info where id=#{glassid};") |
| | | GlassInfo SelectGlass(String glassid); |
| | | //查询该玻璃的尺寸和坐标 |
| | | //@Select("select *from glass_info where id=#{glassid};") |
| | | //GlassInfo SelectGlass(String glassid); |
| | | //是否可以发送进炉信号 |
| | | @Select("select count(*) from glass_info where id=#{glassid};") |
| | | int SelectTempering(String glassid); |
| | | //查询等待中的钢化版图玻璃信息 |
| | | @Select("select*from tempering_glass_info a left join (select flowcard_id,count(state)state from tempering_glass_info GROUP BY flowcard_id,state)b on a.flowcard_id=b.flowcard_id where b.state=2") |
| | | List<TemperingGlassInfo> SelectWaitingGlass(); |
| | | //查询进炉中的钢化版图玻璃信息 |
| | | @Select("select*from tempering_glass_info a left join (select flowcard_id,min(state)state1 from tempering_glass_info GROUP BY flowcard_id having state1=1)b on a.flowcard_id=b.flowcard_id where b.state1=1") |
| | | List<TemperingGlassInfo> SelectInGlass(); |
| | | //查询钢化后的钢化版图信息 |
| | | @Select("select*from tempering_glass_info a left join (select flowcard_id,min(state)state1 from tempering_glass_info GROUP BY flowcard_id having state1=2)b on a.flowcard_id=b.flowcard_id where b.state1=2") |
| | | List <TemperingGlassInfo> SelectOutGlass(); |
| | | @Select("select count(*) from glass_info where id=#{glassid};") |
| | | int SelectTempering(String glassid); |
| | | |
| | | //查询等待中的钢化版图玻璃信息 |
| | | @Select("select*from tempering_glass_info a left join (select flowcard_id,count(state)state from tempering_glass_info GROUP BY flowcard_id,state)b on a.flowcard_id=b.flowcard_id where b.state=2") |
| | | List<TemperingGlassInfo> SelectWaitingGlass(); |
| | | |
| | | //查询进炉中的钢化版图玻璃信息 |
| | | @Select("select*from tempering_glass_info a left join (select flowcard_id,min(state)state1 from tempering_glass_info GROUP BY flowcard_id having state1=1)b on a.flowcard_id=b.flowcard_id where b.state1=1") |
| | | List<TemperingGlassInfo> SelectInGlass(); |
| | | |
| | | //查询钢化后的钢化版图信息 |
| | | @Select("select*from tempering_glass_info a left join (select flowcard_id,min(state)state1 from tempering_glass_info GROUP BY flowcard_id having state1=2)b on a.flowcard_id=b.flowcard_id where b.state1=2") |
| | | List<TemperingGlassInfo> SelectOutGlass(); |
| | | |
| | | |
| | | } |
| | |
| | | package com.mes.temperingglass.service; |
| | | import com.mes.temperingglass.entity.GlassInfo; |
| | | //import com.mes.temperingglass.entity.GlassInfo; |
| | | |
| | | import com.mes.temperingglass.entity.TemperingGlassInfo; |
| | | import com.mes.tools.S7control; |
| | | import com.mes.temperingglass.mapper.TemperingMapper; |
| | | import java.util.List; |
| | | import com.mes.tools.S7control; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Service |
| | | public class TemperingService { |
| | | |
| | | |
| | | private final TemperingMapper temperingMapper; |
| | | private S7control s7control; |
| | | |
| | | public TemperingService(TemperingMapper temperingMapper) { |
| | | this.temperingMapper =temperingMapper; |
| | | this.temperingMapper = temperingMapper; |
| | | } |
| | | //接收id返回坐标和数据 |
| | | public GlassInfo SelectOutGlass (String glassid) { |
| | | GlassInfo GlassInfo = temperingMapper.SelectGlass(glassid); |
| | | return GlassInfo; |
| | | } |
| | | |
| | | // //接收id返回坐标和数据 |
| | | // public GlassInfo SelectOutGlass (String glassid) { |
| | | // GlassInfo GlassInfo = temperingMapper.SelectGlass(glassid); |
| | | // return GlassInfo; |
| | | // } |
| | | //发送坐标信息 |
| | | public void SendCoordinate (short glassX,short glassY) { |
| | | public void SendCoordinate(short glassX, short glassY) { |
| | | s7control.WriteWord("DB100.10", glassX); |
| | | s7control.WriteWord("DB100.10", glassY); |
| | | } |
| | | |
| | | //判断是否可以发送进炉信号 |
| | | public int SelectTempering (String glassid) { |
| | | public int SelectTempering(String glassid) { |
| | | int tempering = temperingMapper.SelectTempering(glassid); |
| | | if (tempering == 1) { |
| | | return 1; |
| | |
| | | <artifactId>unLoadGlass</artifactId> |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>com.google.code.gson</groupId> |
| | | <artifactId>gson</artifactId> |
| | | <version>2.9.0</version> |
| | | <groupId>org.apache.poi</groupId> |
| | | <artifactId>poi-ooxml</artifactId> |
| | | <version>5.2.4</version> |
| | | <scope>compile</scope> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.baomidou</groupId> |
| | | <artifactId>dynamic-datasource-spring-boot-starter</artifactId> |
| | | <version>3.5.2</version> |
| | | <groupId>com.google.code.gson</groupId> |
| | | <artifactId>gson</artifactId> |
| | | <version>2.8.9</version> |
| | | <scope>compile</scope> |
| | | </dependency> |
| | | |
| | | |
| | |
| | | package com.mes.config; |
| | | |
| | | import com.mes.common.PLCAutoMes; |
| | | import com.mes.common.Plchome; |
| | | |
| | | import com.mes.device.PLCAutoMes; |
| | | import org.springframework.boot.ApplicationArguments; |
| | | import org.springframework.boot.ApplicationRunner; |
| | | import org.springframework.core.annotation.Order; |
| | |
| | | import com.baomidou.mybatisplus.annotation.InterceptorIgnore; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.mes.downglassinfo.entity.DownGlassInfo; |
| | | import com.mes.downglassinfo.entity.DownGlassTask; |
| | | import com.mes.downworkstation.entity.DownWorkstation; |
| | | import org.apache.ibatis.annotations.*; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import java.util.List; |
| | |
| | | @Mapper |
| | | @Repository |
| | | @InterceptorIgnore(tenantLine = "true") |
| | | @DS("hangzhoumes") // 指定使用 hangzhoumes 数据源 |
| | | @DS("salve_1") // 指定使用 hangzhoumes 数据源 |
| | | public interface DownWorkstationMapper extends BaseMapper<DownWorkstation> { |
| | | |
| | | |
| | | //查询工位表和任务表中状态为1的流程卡号和已落架数量 |
| | | @Select("SELECT dwt.flow_card_id,dw.id,dw.racks_number FROM down_workstation_task dwt JOIN down_workstation dw ON dwt.flow_card_id = dw.flow_card_id WHERE dwt.state = 1 LIMIT 1") |
| | | List<DownWorkstation> selectdownWorkstationstate(); |
| | | |
| | | |
| | | @Select("SELECT flow_card_id,filmsid,width,height,thickness FROM down_glass_task WHERE task_stauts = 1;") |
| | | List<DownGlassTask> selectunloadingtaskstate(); |
| | | //更新落架数量 |
| | | // @Update("UPDATE down_workstation SET racks_number = #{racksNumber} " + |
| | | // "WHERE flow_card_id = #{flowCardId}") |
| | |
| | | @Autowired
|
| | | private DownGlassInfo downGlassInfo;
|
| | | private DownWorkstation downWorkstation;
|
| | | // private DownGlassInfoMapper downGlassInfoMapper;
|
| | | private DownGlassInfoMapper downGlassInfoMapper;
|
| | | private DownGlassInfoService downGlassInfoService;
|
| | | private DownGlassTaskService downGlassTaskService;
|
| | | private DownWorkstationMapper downWorkstationMapper;
|
| | |
| | | downWorkstationService = WebSocketServer.applicationContext.getBean(DownWorkstationService.class);
|
| | | downWorkstationTaskService = WebSocketServer.applicationContext.getBean(DownWorkstationTaskService.class);
|
| | | downGlassInfoService = WebSocketServer.applicationContext.getBean(DownGlassInfoService.class);
|
| | | // downGlassInfoMapper = WebSocketServer.applicationContext.getBean(DownGlassInfoMapper.class);
|
| | | downGlassInfoMapper = WebSocketServer.applicationContext.getBean(DownGlassInfoMapper.class);
|
| | | downGlassTaskService = WebSocketServer.applicationContext.getBean(DownGlassTaskService.class);
|
| | | List<DownGlassTask> taskdownGlassInf = downGlassTaskService.getUnloadingTaskState();
|
| | | List<DownGlassTask> taskdownGlassInf = downWorkstationMapper.selectunloadingtaskstate();
|
| | | //
|
| | |
|
| | |
|
| | |
| | | // }
|
| | |
|
| | |
|
| | | }
|
| | | } |
| | |
| | | password: beibo.123/ |
| | | driver-class-name: com.mysql.cj.jdbc.Driver |
| | | |
| | | sqlserver: |
| | | url: jdbc:sqlserver://localhost:1433;databaseName=hangzhoumes |
| | | username: sa |
| | | password: beibo.123/ |
| | | driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver |
| | | # sqlserver: |
| | | # url: jdbc:sqlserver://localhost:1433;databaseName=hangzhoumes |
| | | # username: sa |
| | | # password: beibo.123/ |
| | | # driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver |
| | | cloud: |
| | | nacos: |
| | | discovery: |
| | |
| | | |
| | | mapper-locations: classpath*:mapper/sqlserver/*.xml |
| | | |
| | | # log-impl: org.apache.ibatis.logging.stdout.StdOutImpl |
| | | # 设置 MyBatis 日志级别为 ERROR |
| | | # log-impl: org.apache.ibatis.logging.stdout.StdOutImpl |
| | | # 设置 MyBatis 日志级别为 ERROR |
| | | logging: |
| | | level: |
| | | com: |
| | |
| | | <version>1.0-SNAPSHOT</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <artifactId>servicebase</artifactId> |
| | | <groupId>com.mes</groupId> |
| | | <version>1.0-SNAPSHOT</version> |
| | | </dependency> |
| | | <dependency> |
| | | <artifactId>springsecurity</artifactId> |
| | | <groupId>com.mes</groupId> |
| | | <version>1.0-SNAPSHOT</version> |
| | | </dependency> |
| | | |
| | | <!--开发者工具--> |
| | | <dependency> |
| | | <groupId>org.springframework.boot</groupId> |