1
This commit is contained in:
1
dosc/.WeDrive
Normal file
1
dosc/.WeDrive
Normal file
@@ -0,0 +1 @@
|
||||
C:\Users\李涛\Documents\WXWork\1688851319997782\WeDrive\福莱瑞达\软件产品中心\软件产品中心共享资料\集成授权码功能\vue版本集成\授权码
|
||||
258
dosc/Navbar.vue
Normal file
258
dosc/Navbar.vue
Normal file
@@ -0,0 +1,258 @@
|
||||
<template>
|
||||
<div class="navbar">
|
||||
<hamburger id="hamburger-container" :is-active="sidebar.opened" class="hamburger-container" @toggleClick="toggleSideBar" />
|
||||
|
||||
<breadcrumb v-if="!topNav" id="breadcrumb-container" class="breadcrumb-container" />
|
||||
<top-nav v-if="topNav" id="topmenu-container" class="topmenu-container" />
|
||||
|
||||
<div v-if="licenseWarning" class="license-warning">
|
||||
<i class="el-icon-warning-outline" />
|
||||
系统授权将于 {{ licenseExpireText }} 后过期,请及时联系管理员续期
|
||||
</div>
|
||||
|
||||
<div class="right-menu">
|
||||
<template v-if="device!=='mobile'">
|
||||
<search id="header-search" class="right-menu-item" />
|
||||
|
||||
|
||||
<el-tooltip content="联系我们" effect="dark" placement="bottom">
|
||||
<ruo-yi-doc id="ruoyi-doc" class="right-menu-item hover-effect" />
|
||||
</el-tooltip>
|
||||
|
||||
<screenfull id="screenfull" class="right-menu-item hover-effect" />
|
||||
|
||||
<el-tooltip content="布局大小" effect="dark" placement="bottom">
|
||||
<size-select id="size-select" class="right-menu-item hover-effect" />
|
||||
</el-tooltip>
|
||||
|
||||
</template>
|
||||
|
||||
<el-dropdown class="avatar-container right-menu-item hover-effect" trigger="click">
|
||||
<div class="avatar-wrapper">
|
||||
<img :src="avatar" class="user-avatar">
|
||||
<i class="el-icon-caret-bottom" />
|
||||
</div>
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<router-link to="/user/profile">
|
||||
<el-dropdown-item>个人中心</el-dropdown-item>
|
||||
</router-link>
|
||||
<el-dropdown-item @click.native="setting = true">
|
||||
<span>布局设置</span>
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item divided @click.native="logout">
|
||||
<span>退出登录</span>
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapGetters } from 'vuex'
|
||||
import Breadcrumb from '@/components/Breadcrumb'
|
||||
import TopNav from '@/components/TopNav'
|
||||
import Hamburger from '@/components/Hamburger'
|
||||
import Screenfull from '@/components/Screenfull'
|
||||
import SizeSelect from '@/components/SizeSelect'
|
||||
import Search from '@/components/HeaderSearch'
|
||||
import RuoYiGit from '@/components/RuoYi/Git'
|
||||
import RuoYiDoc from '@/components/RuoYi/Doc'
|
||||
import { getLicenseInfo } from '@/api/license'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
Breadcrumb,
|
||||
TopNav,
|
||||
Hamburger,
|
||||
Screenfull,
|
||||
SizeSelect,
|
||||
Search,
|
||||
RuoYiGit,
|
||||
RuoYiDoc
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
licenseWarning: false,
|
||||
licenseExpireText: '',
|
||||
licenseTimer: null
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters([
|
||||
'sidebar',
|
||||
'avatar',
|
||||
'device'
|
||||
]),
|
||||
setting: {
|
||||
get() {
|
||||
return this.$store.state.settings.showSettings
|
||||
},
|
||||
set(val) {
|
||||
this.$store.dispatch('settings/changeSetting', {
|
||||
key: 'showSettings',
|
||||
value: val
|
||||
})
|
||||
}
|
||||
},
|
||||
topNav: {
|
||||
get() {
|
||||
return this.$store.state.settings.topNav
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.checkLicenseExpire()
|
||||
this.licenseTimer = setInterval(() => this.checkLicenseExpire(), 60 * 1000)
|
||||
},
|
||||
beforeDestroy() {
|
||||
if (this.licenseTimer) {
|
||||
clearInterval(this.licenseTimer)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
checkLicenseExpire() {
|
||||
getLicenseInfo().then(res => {
|
||||
if (res.code === 200 && res.data && res.data.expireTime) {
|
||||
const expireTime = new Date(res.data.expireTime).getTime()
|
||||
const now = Date.now()
|
||||
const diffMs = expireTime - now
|
||||
const diffDays = Math.ceil(diffMs / (1000 * 60 * 60 * 24))
|
||||
if (diffMs > 0 && diffDays <= 30) {
|
||||
this.licenseWarning = true
|
||||
if (diffMs < 1000 * 60 * 60 * 24) {
|
||||
const hours = Math.floor(diffMs / (1000 * 60 * 60))
|
||||
const minutes = Math.floor((diffMs % (1000 * 60 * 60)) / (1000 * 60))
|
||||
if (hours > 0) {
|
||||
this.licenseExpireText = hours + ' 小时 ' + minutes + ' 分钟'
|
||||
} else {
|
||||
this.licenseExpireText = minutes + ' 分钟'
|
||||
}
|
||||
} else if (diffDays < 7) {
|
||||
this.licenseExpireText = diffDays + ' 天'
|
||||
} else {
|
||||
this.licenseExpireText = Math.ceil(diffDays / 7) + ' 周'
|
||||
}
|
||||
}
|
||||
}
|
||||
}).catch(() => {})
|
||||
},
|
||||
toggleSideBar() {
|
||||
this.$store.dispatch('app/toggleSideBar')
|
||||
},
|
||||
logout() {
|
||||
this.$confirm('确定注销并退出系统吗?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
this.$store.dispatch('LogOut').then(() => {
|
||||
location.href = '/index'
|
||||
})
|
||||
}).catch(() => {})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.navbar {
|
||||
height: 50px;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
background: #fff;
|
||||
box-shadow: 0 1px 4px rgba(0,21,41,.08);
|
||||
|
||||
.license-warning {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
top: 0;
|
||||
height: 50px;
|
||||
line-height: 50px;
|
||||
font-size: 13px;
|
||||
color: #e6a23c;
|
||||
font-weight: 500;
|
||||
pointer-events: none;
|
||||
i { margin-right: 4px; }
|
||||
}
|
||||
.hamburger-container {
|
||||
line-height: 46px;
|
||||
height: 100%;
|
||||
float: left;
|
||||
cursor: pointer;
|
||||
transition: background .3s;
|
||||
-webkit-tap-highlight-color:transparent;
|
||||
|
||||
&:hover {
|
||||
background: rgba(0, 0, 0, .025)
|
||||
}
|
||||
}
|
||||
|
||||
.breadcrumb-container {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.topmenu-container {
|
||||
position: absolute;
|
||||
left: 50px;
|
||||
}
|
||||
|
||||
.errLog-container {
|
||||
display: inline-block;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.right-menu {
|
||||
float: right;
|
||||
height: 100%;
|
||||
line-height: 50px;
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.right-menu-item {
|
||||
display: inline-block;
|
||||
padding: 0 8px;
|
||||
height: 100%;
|
||||
font-size: 18px;
|
||||
color: #5a5e66;
|
||||
vertical-align: text-bottom;
|
||||
|
||||
&.hover-effect {
|
||||
cursor: pointer;
|
||||
transition: background .3s;
|
||||
|
||||
&:hover {
|
||||
background: rgba(0, 0, 0, .025)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.avatar-container {
|
||||
margin-right: 30px;
|
||||
|
||||
.avatar-wrapper {
|
||||
margin-top: 5px;
|
||||
position: relative;
|
||||
|
||||
.user-avatar {
|
||||
cursor: pointer;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.el-icon-caret-bottom {
|
||||
cursor: pointer;
|
||||
position: absolute;
|
||||
right: -20px;
|
||||
top: 25px;
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
16
dosc/license.js
Normal file
16
dosc/license.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export function activeLicense(licenseCode) {
|
||||
return request({
|
||||
url: '/system/license/active',
|
||||
method: 'post',
|
||||
params: { licenseCode }
|
||||
})
|
||||
}
|
||||
|
||||
export function getLicenseInfo() {
|
||||
return request({
|
||||
url: '/system/license/info',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
1
dosc/license/.WeDrive
Normal file
1
dosc/license/.WeDrive
Normal file
@@ -0,0 +1 @@
|
||||
C:\Users\李涛\Documents\WXWork\1688851319997782\WeDrive\福莱瑞达\软件产品中心\软件产品中心共享资料\集成授权码功能\vue版本集成\授权码\license
|
||||
127
dosc/license/SysLicenseController.java
Normal file
127
dosc/license/SysLicenseController.java
Normal file
@@ -0,0 +1,127 @@
|
||||
package com.ruoyi.web.controller.system.license;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.license.domain.SysLicense;
|
||||
import com.ruoyi.license.service.ISysLicenseService;
|
||||
import com.ruoyi.license.util.LicenseUtils;
|
||||
|
||||
/**
|
||||
* 授权码Controller
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/license")
|
||||
public class SysLicenseController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ISysLicenseService sysLicenseService;
|
||||
|
||||
/**
|
||||
* 查询授权码列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:license:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysLicense sysLicense)
|
||||
{
|
||||
startPage();
|
||||
List<SysLicense> list = sysLicenseService.selectSysLicenseList(sysLicense);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增授权码
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:license:add')")
|
||||
@Log(title = "授权码", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/add")
|
||||
public AjaxResult add(SysLicense sysLicense)
|
||||
{
|
||||
return toAjax(sysLicenseService.insertSysLicense(sysLicense));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改授权码
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:license:edit')")
|
||||
@Log(title = "授权码", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/edit")
|
||||
public AjaxResult edit(SysLicense sysLicense)
|
||||
{
|
||||
return toAjax(sysLicenseService.updateSysLicense(sysLicense));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除授权码
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:license:remove')")
|
||||
@Log(title = "授权码", businessType = BusinessType.DELETE)
|
||||
@PostMapping("/remove")
|
||||
public AjaxResult remove(String ids)
|
||||
{
|
||||
return toAjax(sysLicenseService.deleteSysLicenseByIds(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 激活授权码(无需登录)
|
||||
*/
|
||||
@Log(title = "激活授权码", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/active")
|
||||
public AjaxResult active(String licenseCode)
|
||||
{
|
||||
if (!LicenseUtils.validateFormat(licenseCode))
|
||||
{
|
||||
return error("授权码格式不正确");
|
||||
}
|
||||
int result = sysLicenseService.activeLicense(licenseCode);
|
||||
if (result > 0)
|
||||
{
|
||||
return success("授权码激活成功");
|
||||
}
|
||||
return error("授权码激活失败,请检查授权码是否正确或已过期");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前授权信息
|
||||
* license 未开启或无有效授权时返回 code=200 data=null,前端静默处理
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:license:list')")
|
||||
@GetMapping("/info")
|
||||
public AjaxResult info()
|
||||
{
|
||||
SysLicense license = sysLicenseService.getActiveLicense();
|
||||
return AjaxResult.success(license);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成授权码
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:license:add')")
|
||||
@GetMapping("/generate")
|
||||
public AjaxResult generate(String type, String projectNo)
|
||||
{
|
||||
if (StringUtils.isEmpty(type) || StringUtils.isEmpty(projectNo))
|
||||
{
|
||||
return error("授权类型和项目编号不能为空");
|
||||
}
|
||||
String licenseCode = LicenseUtils.generateLicense(type, projectNo);
|
||||
if (licenseCode == null)
|
||||
{
|
||||
return error("授权码生成失败");
|
||||
}
|
||||
return AjaxResult.success("授权码生成成功", licenseCode);
|
||||
}
|
||||
}
|
||||
1
dosc/ruoyi-license/.WeDrive
Normal file
1
dosc/ruoyi-license/.WeDrive
Normal file
@@ -0,0 +1 @@
|
||||
C:\Users\李涛\Documents\WXWork\1688851319997782\WeDrive\福莱瑞达\软件产品中心\软件产品中心共享资料\集成授权码功能\vue版本集成\授权码\ruoyi-license
|
||||
270
dosc/ruoyi-license/CHANGES.md
Normal file
270
dosc/ruoyi-license/CHANGES.md
Normal file
@@ -0,0 +1,270 @@
|
||||
# 授权码模块集成改动说明
|
||||
|
||||
> 本文档记录引入 `ruoyi-license` 授权码模块时,对原有项目文件的所有改动(不含 `ruoyi-license` 模块本身及 `SysLicenseController`)。
|
||||
|
||||
---
|
||||
|
||||
## 1. 根模块 `pom.xml`
|
||||
|
||||
**文件路径:** `wms/pom.xml`
|
||||
|
||||
**改动内容:**
|
||||
|
||||
1. `<modules>` 中注册 `ruoyi-license` 子模块:
|
||||
|
||||
```xml
|
||||
<modules>
|
||||
<module>ruoyi-admin</module>
|
||||
<module>ruoyi-framework</module>
|
||||
<module>ruoyi-system</module>
|
||||
<module>ruoyi-quartz</module>
|
||||
<module>ruoyi-generator</module>
|
||||
<module>ruoyi-common</module>
|
||||
<module>ruoyi-license</module> <!-- 新增 -->
|
||||
</modules>
|
||||
```
|
||||
|
||||
2. `<dependencyManagement>` 中声明 `ruoyi-license` 依赖版本:
|
||||
|
||||
```xml
|
||||
<!-- 授权码模块 -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-license</artifactId>
|
||||
<version>${ruoyi.version}</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 2. `ruoyi-admin/pom.xml`
|
||||
|
||||
**文件路径:** `wms/ruoyi-admin/pom.xml`
|
||||
|
||||
**改动内容:**
|
||||
|
||||
引入 `ruoyi-license` 依赖,使授权拦截器和配置能被 Spring Boot 扫描加载:
|
||||
|
||||
```xml
|
||||
<!-- 授权码模块 -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-license</artifactId>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 3. `SecurityConfig.java`
|
||||
|
||||
**文件路径:** `wms/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java`
|
||||
|
||||
**改动内容:**
|
||||
|
||||
在 Spring Security 匿名白名单中加入 `/system/license/active`,允许未登录用户调用激活授权码接口:
|
||||
|
||||
```java
|
||||
// 改动前
|
||||
requests.antMatchers("/login", "/register", "/captchaImage").permitAll()
|
||||
|
||||
// 改动后
|
||||
requests.antMatchers("/login", "/register", "/captchaImage", "/system/license/active").permitAll()
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 4. 前端 `api/license.js`(新建)
|
||||
|
||||
**文件路径:** `wms/ui/src/api/license.js`
|
||||
|
||||
**改动内容:**
|
||||
|
||||
新建文件,封装授权码相关接口:
|
||||
|
||||
```js
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 激活授权码(无需登录)
|
||||
export function activeLicense(licenseCode) {
|
||||
return request({
|
||||
url: '/system/license/active',
|
||||
method: 'post',
|
||||
params: { licenseCode }
|
||||
})
|
||||
}
|
||||
|
||||
// 查询当前授权信息(需登录)
|
||||
export function getLicenseInfo() {
|
||||
return request({
|
||||
url: '/system/license/info',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 5. 登录页 `login.vue`
|
||||
|
||||
**文件路径:** `wms/ui/src/views/login.vue`
|
||||
|
||||
**改动内容:**
|
||||
|
||||
### 5.1 模板部分
|
||||
|
||||
在登录按钮下方新增"激活授权码"按钮,以及激活弹窗:
|
||||
|
||||
```html
|
||||
<!-- 激活授权码按钮 -->
|
||||
<el-form-item style="width:100%;">
|
||||
<el-button
|
||||
size="medium"
|
||||
type="warning"
|
||||
style="width:100%;"
|
||||
@click.native.prevent="openLicenseDialog"
|
||||
>激活授权码</el-button>
|
||||
</el-form-item>
|
||||
|
||||
<!-- 激活授权码弹窗 -->
|
||||
<el-dialog title="激活授权码" :visible.sync="licenseDialogVisible" width="420px" append-to-body>
|
||||
<el-input v-model="licenseCode" type="textarea" :rows="4" placeholder="请输入授权码" />
|
||||
<span slot="footer">
|
||||
<el-button @click="licenseDialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" :loading="licenseLoading" @click="handleActiveLicense">激 活</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
```
|
||||
|
||||
### 5.2 Script 部分
|
||||
|
||||
新增 import、data 字段和方法:
|
||||
|
||||
```js
|
||||
// 新增 import
|
||||
import { activeLicense } from "@/api/license"
|
||||
|
||||
// 新增 data 字段
|
||||
licenseDialogVisible: false,
|
||||
licenseCode: '',
|
||||
licenseLoading: false
|
||||
|
||||
// 新增方法
|
||||
openLicenseDialog() {
|
||||
this.licenseCode = ''
|
||||
this.licenseDialogVisible = true
|
||||
},
|
||||
handleActiveLicense() {
|
||||
if (!this.licenseCode.trim()) {
|
||||
this.$message.warning('请输入授权码')
|
||||
return
|
||||
}
|
||||
this.licenseLoading = true
|
||||
activeLicense(this.licenseCode.trim()).then(res => {
|
||||
if (res.code === 200) {
|
||||
this.$message.success(res.msg || '授权码激活成功')
|
||||
this.licenseDialogVisible = false
|
||||
} else {
|
||||
this.$message.error(res.msg || '授权码激活失败')
|
||||
}
|
||||
}).catch(() => {
|
||||
this.$message.error('授权码激活失败')
|
||||
}).finally(() => {
|
||||
this.licenseLoading = false
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 6. 顶部导航栏 `Navbar.vue`
|
||||
|
||||
**文件路径:** `wms/ui/src/layout/components/Navbar.vue`
|
||||
|
||||
**改动内容:**
|
||||
|
||||
### 6.1 模板部分
|
||||
|
||||
在 navbar 中间插入授权到期警告条(剩余不足 30 天时显示):
|
||||
|
||||
```html
|
||||
<div v-if="licenseWarning" class="license-warning">
|
||||
<i class="el-icon-warning-outline" />
|
||||
系统授权将于 {{ licenseExpireText }} 后过期,请及时联系管理员续期
|
||||
</div>
|
||||
```
|
||||
|
||||
### 6.2 Script 部分
|
||||
|
||||
```js
|
||||
// 新增 import
|
||||
import { getLicenseInfo } from '@/api/license'
|
||||
|
||||
// 新增 data 字段
|
||||
licenseWarning: false,
|
||||
licenseExpireText: '',
|
||||
licenseTimer: null
|
||||
|
||||
// 新增生命周期钩子
|
||||
mounted() {
|
||||
this.checkLicenseExpire()
|
||||
this.licenseTimer = setInterval(() => this.checkLicenseExpire(), 60 * 1000)
|
||||
},
|
||||
beforeDestroy() {
|
||||
if (this.licenseTimer) clearInterval(this.licenseTimer)
|
||||
},
|
||||
|
||||
// 新增方法
|
||||
checkLicenseExpire() {
|
||||
getLicenseInfo().then(res => {
|
||||
if (res.code === 200 && res.data && res.data.expireTime) {
|
||||
const expireTime = new Date(res.data.expireTime).getTime()
|
||||
const now = Date.now()
|
||||
const diffMs = expireTime - now
|
||||
const diffDays = Math.ceil(diffMs / (1000 * 60 * 60 * 24))
|
||||
if (diffMs > 0 && diffDays <= 30) {
|
||||
this.licenseWarning = true
|
||||
if (diffMs < 1000 * 60 * 60 * 24) {
|
||||
const hours = Math.floor(diffMs / (1000 * 60 * 60))
|
||||
const minutes = Math.floor((diffMs % (1000 * 60 * 60)) / (1000 * 60))
|
||||
this.licenseExpireText = hours > 0 ? `${hours} 小时 ${minutes} 分钟` : `${minutes} 分钟`
|
||||
} else if (diffDays < 7) {
|
||||
this.licenseExpireText = diffDays + ' 天'
|
||||
} else {
|
||||
this.licenseExpireText = Math.ceil(diffDays / 7) + ' 周'
|
||||
}
|
||||
}
|
||||
}
|
||||
}).catch(() => {})
|
||||
}
|
||||
```
|
||||
|
||||
### 6.3 样式部分
|
||||
|
||||
```scss
|
||||
.license-warning {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
top: 0;
|
||||
height: 50px;
|
||||
line-height: 50px;
|
||||
font-size: 13px;
|
||||
color: #e6a23c;
|
||||
font-weight: 500;
|
||||
pointer-events: none;
|
||||
i { margin-right: 4px; }
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 改动文件汇总
|
||||
|
||||
| 文件 | 类型 | 说明 |
|
||||
|---|---|---|
|
||||
| `wms/pom.xml` | 修改 | 注册模块 + 声明依赖版本 |
|
||||
| `wms/ruoyi-admin/pom.xml` | 修改 | 引入 ruoyi-license 依赖 |
|
||||
| `ruoyi-framework/.../SecurityConfig.java` | 修改 | 白名单加入激活授权码接口 |
|
||||
| `ui/src/api/license.js` | 新建 | 封装激活和查询授权信息接口 |
|
||||
| `ui/src/views/login.vue` | 修改 | 新增激活授权码按钮和弹窗 |
|
||||
| `ui/src/layout/components/Navbar.vue` | 修改 | 新增授权到期倒计时警告条 |
|
||||
250
dosc/ruoyi-license/DEPLOYMENT_CHECKLIST.md
Normal file
250
dosc/ruoyi-license/DEPLOYMENT_CHECKLIST.md
Normal file
@@ -0,0 +1,250 @@
|
||||
# 授权码模块部署检查清单
|
||||
|
||||
## 📋 部署前检查
|
||||
|
||||
### 1. 文件完整性检查
|
||||
- [ ] ruoyi-license 模块目录存在
|
||||
- [ ] pom.xml 已添加 license 模块
|
||||
- [ ] ruoyi-admin/pom.xml 已添加 license 依赖
|
||||
- [ ] SysLicenseController.java 已创建
|
||||
- [ ] license.html 和 active.html 已创建
|
||||
- [ ] login.html 和 login.js 已修改
|
||||
- [ ] sys_license.sql 脚本已准备
|
||||
|
||||
### 2. 数据库准备
|
||||
- [ ] 创建 sys_license 表
|
||||
- [ ] 插入授权管理菜单数据
|
||||
- [ ] 验证表结构正确
|
||||
- [ ] 检查菜单权限配置
|
||||
|
||||
### 3. 代码配置
|
||||
- [ ] 修改 LicenseUtils.java 中的密钥(生产环境必须)
|
||||
- [ ] 确认拦截器路径配置正确
|
||||
- [ ] 确认定时任务cron表达式
|
||||
- [ ] 启动类添加 @EnableScheduling 注解
|
||||
|
||||
## 🔧 部署步骤
|
||||
|
||||
### 步骤1: 执行数据库脚本
|
||||
```bash
|
||||
mysql -u root -p your_database < sql/sys_license.sql
|
||||
```
|
||||
- [ ] 执行成功
|
||||
- [ ] 表创建成功
|
||||
- [ ] 菜单数据插入成功
|
||||
|
||||
### 步骤2: 修改启动类
|
||||
```java
|
||||
@SpringBootApplication
|
||||
@EnableScheduling // 添加此注解
|
||||
public class RuoYiApplication {
|
||||
// ...
|
||||
}
|
||||
```
|
||||
- [ ] 注解已添加
|
||||
|
||||
### 步骤3: 编译项目
|
||||
```bash
|
||||
mvn clean install
|
||||
```
|
||||
- [ ] 编译成功
|
||||
- [ ] 无错误信息
|
||||
- [ ] JAR包生成
|
||||
|
||||
### 步骤4: 启动应用
|
||||
```bash
|
||||
java -jar ruoyi-admin.jar
|
||||
```
|
||||
- [ ] 启动成功
|
||||
- [ ] 无异常日志
|
||||
- [ ] 端口正常监听
|
||||
|
||||
### 步骤5: 生成授权码
|
||||
**方式A: 使用独立工具**
|
||||
```bash
|
||||
java com.ruoyi.license.util.LicenseGenerator
|
||||
```
|
||||
- [ ] 工具运行成功
|
||||
- [ ] 授权码生成成功
|
||||
- [ ] 授权码已保存
|
||||
|
||||
**方式B: 使用系统界面**
|
||||
- [ ] 登录系统
|
||||
- [ ] 访问授权管理
|
||||
- [ ] 点击生成授权码
|
||||
- [ ] 输入天数并生成
|
||||
|
||||
### 步骤6: 激活授权码
|
||||
- [ ] 访问登录页
|
||||
- [ ] 点击"激活授权码"
|
||||
- [ ] 输入授权码
|
||||
- [ ] 激活成功
|
||||
|
||||
## ✅ 功能测试
|
||||
|
||||
### 测试1: 授权码生成
|
||||
- [ ] 系统界面生成授权码成功
|
||||
- [ ] 独立工具生成授权码成功
|
||||
- [ ] 授权码格式正确
|
||||
|
||||
### 测试2: 授权码激活
|
||||
- [ ] 登录页激活成功
|
||||
- [ ] 系统内激活成功
|
||||
- [ ] 数据库记录正确
|
||||
|
||||
### 测试3: 授权验证
|
||||
- [ ] 有效授权可正常登录
|
||||
- [ ] 无授权无法登录
|
||||
- [ ] 过期授权无法登录
|
||||
|
||||
### 测试4: 授权拦截
|
||||
- [ ] 未授权访问被拦截
|
||||
- [ ] 有效授权可正常访问
|
||||
- [ ] 静态资源不被拦截
|
||||
|
||||
### 测试5: 定时检查
|
||||
- [ ] 定时任务正常执行
|
||||
- [ ] 授权过期自动更新状态
|
||||
- [ ] 在线用户被踢出
|
||||
|
||||
### 测试6: 授权管理
|
||||
- [ ] 授权列表查询正常
|
||||
- [ ] 授权信息显示正确
|
||||
- [ ] 授权删除功能正常
|
||||
|
||||
## 🔍 问题排查
|
||||
|
||||
### 问题1: 编译失败
|
||||
**检查项:**
|
||||
- [ ] Maven依赖是否正确
|
||||
- [ ] JDK版本是否匹配
|
||||
- [ ] pom.xml配置是否正确
|
||||
|
||||
**解决方案:**
|
||||
```bash
|
||||
mvn clean
|
||||
mvn dependency:resolve
|
||||
mvn install
|
||||
```
|
||||
|
||||
### 问题2: 启动失败
|
||||
**检查项:**
|
||||
- [ ] 数据库连接是否正常
|
||||
- [ ] 端口是否被占用
|
||||
- [ ] 配置文件是否正确
|
||||
|
||||
**解决方案:**
|
||||
- 检查 application.yml 配置
|
||||
- 查看启动日志错误信息
|
||||
- 确认数据库表已创建
|
||||
|
||||
### 问题3: 无法激活授权码
|
||||
**检查项:**
|
||||
- [ ] 授权码格式是否正确
|
||||
- [ ] 授权码是否已过期
|
||||
- [ ] 密钥是否一致
|
||||
|
||||
**解决方案:**
|
||||
- 重新生成授权码
|
||||
- 检查 LicenseUtils 密钥配置
|
||||
- 查看后台错误日志
|
||||
|
||||
### 问题4: 授权验证不生效
|
||||
**检查项:**
|
||||
- [ ] 拦截器是否注册
|
||||
- [ ] 数据库授权记录是否正确
|
||||
- [ ] 定时任务是否执行
|
||||
|
||||
**解决方案:**
|
||||
- 检查 LicenseConfig 配置
|
||||
- 验证数据库 status 字段
|
||||
- 确认 @EnableScheduling 已添加
|
||||
|
||||
### 问题5: 在线用户未被踢出
|
||||
**检查项:**
|
||||
- [ ] SessionDAO 是否注入
|
||||
- [ ] 定时任务是否执行
|
||||
- [ ] Shiro配置是否正确
|
||||
|
||||
**解决方案:**
|
||||
- 检查 LicenseCheckTask 日志
|
||||
- 验证 SessionDAO bean
|
||||
- 重启应用服务器
|
||||
|
||||
## 📊 监控指标
|
||||
|
||||
### 运行时监控
|
||||
- [ ] 授权状态正常
|
||||
- [ ] 定时任务执行正常
|
||||
- [ ] 无异常日志
|
||||
- [ ] 内存使用正常
|
||||
- [ ] CPU使用正常
|
||||
|
||||
### 业务监控
|
||||
- [ ] 授权激活次数
|
||||
- [ ] 授权过期提醒
|
||||
- [ ] 用户登录成功率
|
||||
- [ ] 授权拦截次数
|
||||
|
||||
## 🔐 安全检查
|
||||
|
||||
### 配置安全
|
||||
- [ ] 生产环境已修改默认密钥
|
||||
- [ ] 数据库密码已加密
|
||||
- [ ] 授权码传输使用HTTPS
|
||||
- [ ] 敏感日志已脱敏
|
||||
|
||||
### 权限安全
|
||||
- [ ] 授权管理菜单仅管理员可见
|
||||
- [ ] 授权激活操作有日志记录
|
||||
- [ ] 授权码生成有权限控制
|
||||
- [ ] 数据库访问有权限限制
|
||||
|
||||
### 数据安全
|
||||
- [ ] 授权码加密存储
|
||||
- [ ] 定期备份授权数据
|
||||
- [ ] 授权日志完整保存
|
||||
- [ ] 敏感信息不输出到日志
|
||||
|
||||
## 📝 上线清单
|
||||
|
||||
### 上线前
|
||||
- [ ] 所有测试通过
|
||||
- [ ] 代码已提交版本库
|
||||
- [ ] 数据库脚本已准备
|
||||
- [ ] 部署文档已编写
|
||||
- [ ] 回滚方案已准备
|
||||
|
||||
### 上线中
|
||||
- [ ] 备份现有数据
|
||||
- [ ] 执行数据库脚本
|
||||
- [ ] 部署新版本代码
|
||||
- [ ] 生成初始授权码
|
||||
- [ ] 激活授权码
|
||||
|
||||
### 上线后
|
||||
- [ ] 验证功能正常
|
||||
- [ ] 检查日志无异常
|
||||
- [ ] 监控系统运行状态
|
||||
- [ ] 通知相关人员
|
||||
- [ ] 更新运维文档
|
||||
|
||||
## 📞 应急联系
|
||||
|
||||
### 技术支持
|
||||
- 开发负责人: ___________
|
||||
- 运维负责人: ___________
|
||||
- 数据库管理员: ___________
|
||||
|
||||
### 应急预案
|
||||
1. 授权失效 -> 立即激活新授权码
|
||||
2. 系统无法登录 -> 检查授权状态
|
||||
3. 数据丢失 -> 从备份恢复
|
||||
4. 性能问题 -> 调整定时任务频率
|
||||
|
||||
---
|
||||
|
||||
**检查人**: ___________
|
||||
**检查日期**: ___________
|
||||
**部署环境**: [ ] 开发 [ ] 测试 [ ] 生产
|
||||
**部署状态**: [ ] 成功 [ ] 失败 [ ] 部分成功
|
||||
231
dosc/ruoyi-license/INTEGRATION.md
Normal file
231
dosc/ruoyi-license/INTEGRATION.md
Normal file
@@ -0,0 +1,231 @@
|
||||
# RuoYi 授权码模块集成指南
|
||||
|
||||
## 一、模块说明
|
||||
|
||||
本授权码模块已完成开发,包含以下文件:
|
||||
|
||||
```
|
||||
ruoyi-license/ # 授权模块(独立模块)
|
||||
├── src/main/java/com/ruoyi/license/
|
||||
│ ├── config/
|
||||
│ │ └── LicenseConfig.java # 拦截器配置
|
||||
│ ├── domain/
|
||||
│ │ └── SysLicense.java # 授权实体
|
||||
│ ├── interceptor/
|
||||
│ │ └── LicenseInterceptor.java # 授权拦截器
|
||||
│ ├── mapper/
|
||||
│ │ └── SysLicenseMapper.java # 数据访问接口
|
||||
│ ├── service/
|
||||
│ │ ├── ISysLicenseService.java # 服务接口
|
||||
│ │ └── impl/
|
||||
│ │ └── SysLicenseServiceImpl.java # 服务实现
|
||||
│ ├── task/
|
||||
│ │ └── LicenseCheckTask.java # 定时检查任务
|
||||
│ └── util/
|
||||
│ ├── LicenseUtils.java # 授权工具类
|
||||
│ └── LicenseGenerator.java # 授权码生成器
|
||||
├── src/main/resources/mapper/license/
|
||||
│ └── SysLicenseMapper.xml # MyBatis映射
|
||||
├── pom.xml # 模块依赖
|
||||
└── README.md # 使用说明
|
||||
|
||||
sql/
|
||||
└── sys_license.sql # 数据库脚本
|
||||
|
||||
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/license/
|
||||
└── SysLicenseController.java # 授权控制器
|
||||
|
||||
ruoyi-admin/src/main/resources/templates/system/license/
|
||||
├── license.html # 授权列表页
|
||||
└── active.html # 激活页面
|
||||
|
||||
修改的文件:
|
||||
- pom.xml # 添加license模块
|
||||
- ruoyi-admin/pom.xml # 添加license依赖
|
||||
- login.html # 添加激活入口
|
||||
- login.js # 添加激活功能
|
||||
```
|
||||
|
||||
## 二、部署步骤
|
||||
|
||||
### 1. 执行数据库脚本
|
||||
|
||||
```bash
|
||||
# 在MySQL中执行
|
||||
mysql -u root -p your_database < sql/sys_license.sql
|
||||
```
|
||||
|
||||
或手动执行 `sql/sys_license.sql` 中的SQL语句。
|
||||
|
||||
### 2. 启用定时任务
|
||||
|
||||
在启动类上添加 `@EnableScheduling` 注解:
|
||||
|
||||
```java
|
||||
@SpringBootApplication
|
||||
@EnableScheduling // 添加此注解
|
||||
public class RuoYiApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(RuoYiApplication.class, args);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 3. 编译项目
|
||||
|
||||
```bash
|
||||
cd d:\fortucky\project\RuoYi-master
|
||||
mvn clean install
|
||||
```
|
||||
|
||||
### 4. 生成授权码
|
||||
|
||||
**方式一:使用独立工具生成**
|
||||
```bash
|
||||
cd ruoyi-license/src/main/java
|
||||
javac com/ruoyi/license/util/LicenseUtils.java
|
||||
javac com/ruoyi/license/util/LicenseGenerator.java
|
||||
java com.ruoyi.license.util.LicenseGenerator
|
||||
```
|
||||
|
||||
**方式二:启动系统后在界面生成**
|
||||
- 登录系统
|
||||
- 进入"系统管理 -> 授权管理"
|
||||
- 点击"生成授权码"按钮
|
||||
|
||||
### 5. 激活授权码
|
||||
|
||||
**首次激活(登录页):**
|
||||
1. 访问登录页
|
||||
2. 点击"激活授权码"链接
|
||||
3. 输入生成的授权码
|
||||
4. 提交激活
|
||||
|
||||
**系统内激活:**
|
||||
1. 登录系统(需要先有有效授权)
|
||||
2. 进入"系统管理 -> 授权管理"
|
||||
3. 点击"激活授权码"
|
||||
4. 输入新的授权码
|
||||
|
||||
## 三、功能验证
|
||||
|
||||
### 1. 验证授权拦截
|
||||
|
||||
- 未激活授权码时,访问任何页面应跳转到登录页并提示"授权已过期"
|
||||
- 激活授权码后,可正常访问系统
|
||||
|
||||
### 2. 验证定时检查
|
||||
|
||||
- 修改数据库中授权码的 `expire_time` 为过去时间
|
||||
- 等待5分钟(或重启系统)
|
||||
- 在线用户应被强制退出
|
||||
- 尝试登录应提示授权过期
|
||||
|
||||
### 3. 验证授权管理
|
||||
|
||||
- 访问"系统管理 -> 授权管理"
|
||||
- 查看授权列表
|
||||
- 生成新授权码
|
||||
- 激活授权码
|
||||
- 删除过期授权
|
||||
|
||||
## 四、复用到其他项目
|
||||
|
||||
### 方式一:Maven依赖(推荐)
|
||||
|
||||
1. 将 `ruoyi-license` 模块复制到目标项目
|
||||
2. 在父pom.xml添加模块声明
|
||||
3. 在需要的模块添加依赖
|
||||
4. 执行数据库脚本
|
||||
5. 复制Controller和前端页面
|
||||
|
||||
### 方式二:JAR包依赖
|
||||
|
||||
1. 打包license模块:
|
||||
```bash
|
||||
cd ruoyi-license
|
||||
mvn clean package
|
||||
```
|
||||
|
||||
2. 安装到本地仓库:
|
||||
```bash
|
||||
mvn install:install-file -Dfile=target/ruoyi-license-4.8.2.jar \
|
||||
-DgroupId=com.ruoyi -DartifactId=ruoyi-license \
|
||||
-Dversion=4.8.2 -Dpackaging=jar
|
||||
```
|
||||
|
||||
3. 在目标项目添加依赖:
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-license</artifactId>
|
||||
<version>4.8.2</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
## 五、配置说明
|
||||
|
||||
### 1. 修改密钥(重要)
|
||||
|
||||
生产环境必须修改默认密钥:
|
||||
|
||||
```java
|
||||
// LicenseUtils.java
|
||||
private static final String SECRET_KEY = "YourCustomKey123"; // 改为16位自定义密钥
|
||||
```
|
||||
|
||||
### 2. 调整检查频率
|
||||
|
||||
```java
|
||||
// LicenseCheckTask.java
|
||||
@Scheduled(cron = "0 */5 * * * ?") // 每5分钟,可根据需要调整
|
||||
```
|
||||
|
||||
### 3. 自定义拦截路径
|
||||
|
||||
```java
|
||||
// LicenseConfig.java
|
||||
.excludePathPatterns(
|
||||
"/login",
|
||||
"/your-path/**" // 添加需要排除的路径
|
||||
)
|
||||
```
|
||||
|
||||
## 六、注意事项
|
||||
|
||||
1. **首次部署**:必须先生成并激活授权码,否则无法登录
|
||||
2. **时间同步**:确保服务器时间准确,避免授权判断错误
|
||||
3. **密钥安全**:生产环境务必修改默认密钥
|
||||
4. **数据备份**:定期备份 `sys_license` 表数据
|
||||
5. **权限控制**:授权管理菜单仅授予超级管理员
|
||||
|
||||
## 七、故障排查
|
||||
|
||||
### 问题1:无法激活授权码
|
||||
- 检查授权码格式是否正确
|
||||
- 检查授权码是否已过期
|
||||
- 查看后台日志错误信息
|
||||
|
||||
### 问题2:授权有效但仍被拦截
|
||||
- 检查数据库中授权状态是否为"1"
|
||||
- 检查 `expire_time` 是否大于当前时间
|
||||
- 重启应用服务器
|
||||
|
||||
### 问题3:定时任务不执行
|
||||
- 确认启动类添加了 `@EnableScheduling`
|
||||
- 检查日志是否有定时任务执行记录
|
||||
|
||||
### 问题4:在线用户未被踢出
|
||||
- 检查 `SessionDAO` 是否正确注入
|
||||
- 查看定时任务是否正常执行
|
||||
- 检查Shiro配置是否正确
|
||||
|
||||
## 八、技术支持
|
||||
|
||||
如遇到问题,请提供以下信息:
|
||||
1. 错误日志
|
||||
2. 数据库授权记录
|
||||
3. 系统环境信息
|
||||
4. 操作步骤
|
||||
|
||||
联系方式:参考RuoYi官方文档
|
||||
168
dosc/ruoyi-license/LICENSE_FILTER_CONFIG.md
Normal file
168
dosc/ruoyi-license/LICENSE_FILTER_CONFIG.md
Normal file
@@ -0,0 +1,168 @@
|
||||
# 授权码全局拦截配置说明
|
||||
|
||||
## 功能说明
|
||||
|
||||
通过自定义 Shiro Filter,实现授权码失效时,**所有接口**(包括 `anon` 匿名访问的接口)都无法访问。
|
||||
|
||||
## 实现原理
|
||||
|
||||
1. 创建 `LicenseValidateFilter` 继承 `AccessControlFilter`
|
||||
2. 在 Shiro 过滤链的**最前面**添加此过滤器
|
||||
3. 所有请求都会先经过授权码验证,验证失败则拒绝访问
|
||||
|
||||
## 已完成的修改
|
||||
|
||||
### 1. 新增文件
|
||||
- `ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/web/filter/license/LicenseValidateFilter.java`
|
||||
|
||||
### 2. 修改文件
|
||||
- `ruoyi-framework/src/main/java/com/ruoyi/framework/config/ShiroConfig.java`
|
||||
- 导入 `LicenseValidateFilter`
|
||||
- 注册过滤器:`filters.put("licenseValidate", licenseValidateFilter())`
|
||||
- 添加到过滤链:`filterChainDefinitionMap.put("/**", "licenseValidate,user,kickout,onlineSession,syncOnlineSession")`
|
||||
|
||||
## 白名单配置
|
||||
|
||||
以下路径即使授权失效也可以访问(必要的登录和静态资源):
|
||||
|
||||
```java
|
||||
private static final String[] WHITE_LIST = {
|
||||
"/login", // 登录页
|
||||
"/captcha/captchaImage", // 验证码
|
||||
"/css/", // 样式文件
|
||||
"/js/", // 脚本文件
|
||||
"/img/", // 图片资源
|
||||
"/fonts/", // 字体文件
|
||||
"/ajax/", // Ajax资源
|
||||
"/ruoyi/", // 若依资源
|
||||
"/favicon.ico", // 网站图标
|
||||
"/system/license/active" // 授权激活页面(必须放行)
|
||||
};
|
||||
```
|
||||
|
||||
## 自定义白名单
|
||||
|
||||
如果需要添加其他路径到白名单,修改 `LicenseValidateFilter.java`:
|
||||
|
||||
```java
|
||||
private static final String[] WHITE_LIST = {
|
||||
// ... 原有配置
|
||||
"/your-custom-path/**", // 添加你的自定义路径
|
||||
};
|
||||
```
|
||||
|
||||
## 拦截效果
|
||||
|
||||
### 授权有效时
|
||||
- 所有接口正常访问(包括 `/board/**`、`/agv/api/**` 等 anon 接口)
|
||||
|
||||
### 授权失效时
|
||||
- **普通请求**:重定向到 `/login?license=expired`
|
||||
- **Ajax请求**:返回 JSON `{"code":401,"msg":"授权已过期,请联系管理员激活授权码"}`
|
||||
- **白名单路径**:仍可访问(用于激活授权码)
|
||||
|
||||
## 测试步骤
|
||||
|
||||
### 1. 启用授权功能
|
||||
在 `application.yml` 中配置:
|
||||
```yaml
|
||||
license:
|
||||
enabled: true
|
||||
```
|
||||
|
||||
### 2. 配置项目编号
|
||||
在数据库 `sys_config` 表中添加:
|
||||
```sql
|
||||
INSERT INTO sys_config (config_name, config_key, config_value, config_type, create_by, create_time, remark)
|
||||
VALUES ('项目编号', 'fortucky.project.no', 'FT507', 'Y', 'admin', NOW(), '用于授权码验证');
|
||||
```
|
||||
|
||||
### 3. 测试授权失效场景
|
||||
|
||||
**方式一:不激活授权码**
|
||||
- 启动系统
|
||||
- 访问 `/board/**` 接口
|
||||
- 预期:被拦截,重定向到登录页
|
||||
|
||||
**方式二:授权码过期**
|
||||
- 生成5分钟测试授权码并激活
|
||||
- 等待5分钟后访问 `/board/**` 接口
|
||||
- 预期:被拦截
|
||||
|
||||
### 4. 测试授权有效场景
|
||||
- 生成并激活有效授权码
|
||||
- 访问 `/board/**` 接口
|
||||
- 预期:正常访问
|
||||
|
||||
## 注意事项
|
||||
|
||||
1. **白名单必须包含授权激活页面**
|
||||
- `/system/license/active` 必须在白名单中
|
||||
- 否则授权失效后无法激活新授权码
|
||||
|
||||
2. **静态资源必须放行**
|
||||
- CSS、JS、图片等资源必须在白名单
|
||||
- 否则登录页面无法正常显示
|
||||
|
||||
3. **过滤器顺序很重要**
|
||||
- `licenseValidate` 必须在最前面
|
||||
- 确保所有请求都先经过授权验证
|
||||
|
||||
4. **开发环境可关闭授权**
|
||||
```yaml
|
||||
license:
|
||||
enabled: false # 开发时可关闭
|
||||
```
|
||||
|
||||
## 与原有拦截器的区别
|
||||
|
||||
### 原有 LicenseInterceptor(Spring MVC 拦截器)
|
||||
- 在 Spring MVC 层拦截
|
||||
- 只拦截进入 Controller 的请求
|
||||
- 无法拦截 Shiro 已放行的 `anon` 接口
|
||||
|
||||
### 新增 LicenseValidateFilter(Shiro 过滤器)
|
||||
- 在 Shiro 层拦截
|
||||
- 拦截所有请求(包括 `anon` 接口)
|
||||
- 优先级高于 Shiro 的其他过滤器
|
||||
|
||||
## 建议
|
||||
|
||||
1. **保留两个拦截器**
|
||||
- `LicenseValidateFilter`:全局拦截(包括 anon 接口)
|
||||
- `LicenseInterceptor`:作为二次验证(可选)
|
||||
|
||||
2. **生产环境必须启用**
|
||||
```yaml
|
||||
license:
|
||||
enabled: true
|
||||
```
|
||||
|
||||
3. **定期检查白名单**
|
||||
- 确保白名单路径最小化
|
||||
- 避免过度放行
|
||||
|
||||
## 故障排查
|
||||
|
||||
### 问题1:所有请求都被拦截
|
||||
- 检查 `license.enabled` 是否为 `true`
|
||||
- 检查是否有有效授权码
|
||||
- 查看后台日志 `[授权验证]` 相关信息
|
||||
|
||||
### 问题2:anon 接口仍可访问
|
||||
- 检查过滤器是否注册:`filters.put("licenseValidate", ...)`
|
||||
- 检查过滤链配置:`"licenseValidate,user,..."`
|
||||
- 确认 `licenseValidate` 在最前面
|
||||
|
||||
### 问题3:无法激活授权码
|
||||
- 检查 `/system/license/active` 是否在白名单
|
||||
- 检查白名单匹配逻辑是否正确
|
||||
|
||||
## 完成标志
|
||||
|
||||
✅ 授权失效时,`/board/**` 接口无法访问
|
||||
✅ 授权失效时,`/agv/api/**` 接口无法访问
|
||||
✅ 授权失效时,仍可访问登录页和激活页
|
||||
✅ 授权有效时,所有接口正常访问
|
||||
✅ Ajax 请求返回 JSON 错误信息
|
||||
✅ 普通请求重定向到登录页
|
||||
193
dosc/ruoyi-license/README.md
Normal file
193
dosc/ruoyi-license/README.md
Normal file
@@ -0,0 +1,193 @@
|
||||
# RuoYi 授权码模块
|
||||
|
||||
## 模块简介
|
||||
|
||||
ruoyi-license 是一个独立的授权码管理模块,用于控制系统的使用期限。当授权码过期后,系统将无法登录,已登录用户会被强制退出。
|
||||
|
||||
## 功能特性
|
||||
|
||||
- ✅ 授权码加密存储
|
||||
- ✅ 登录时验证授权有效性
|
||||
- ✅ 定时检查授权状态(每5分钟)
|
||||
- ✅ 授权过期自动踢出在线用户
|
||||
- ✅ 系统管理界面查看/激活授权
|
||||
- ✅ 登录页面激活授权码
|
||||
- ✅ 授权码生成工具
|
||||
- ✅ 独立模块,方便其他项目复用
|
||||
|
||||
## 快速开始
|
||||
|
||||
### 1. 执行数据库脚本
|
||||
|
||||
```sql
|
||||
-- 执行 sql/sys_license.sql 创建授权表和菜单
|
||||
```
|
||||
|
||||
### 2. 添加模块依赖
|
||||
|
||||
在需要使用授权功能的项目中,添加依赖:
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-license</artifactId>
|
||||
<version>4.8.2</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
### 3. 配置包扫描
|
||||
|
||||
确保Spring能扫描到授权模块的包:
|
||||
|
||||
```java
|
||||
@SpringBootApplication
|
||||
@ComponentScan(basePackages = {"com.ruoyi"})
|
||||
public class RuoYiApplication {
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
### 4. 生成授权码
|
||||
|
||||
访问系统管理 -> 授权管理,点击"生成授权码"按钮,输入授权天数(如365天),系统会生成加密的授权码。
|
||||
|
||||
### 5. 激活授权码
|
||||
|
||||
**方式一:登录页激活**
|
||||
- 在登录页面点击"激活授权码"链接
|
||||
- 输入授权码并提交
|
||||
|
||||
**方式二:系统内激活**
|
||||
- 登录系统后,进入"系统管理 -> 授权管理"
|
||||
- 点击"激活授权码"按钮
|
||||
- 输入授权码并提交
|
||||
|
||||
## 核心类说明
|
||||
|
||||
### 1. 实体类
|
||||
- `SysLicense`: 授权码实体,包含授权码、开始时间、结束时间、状态等信息
|
||||
|
||||
### 2. 工具类
|
||||
- `LicenseUtils`: 授权码工具类
|
||||
- `generateLicense()`: 生成授权码
|
||||
- `encrypt()`: 加密数据
|
||||
- `decrypt()`: 解密数据
|
||||
- `validateFormat()`: 验证授权码格式
|
||||
|
||||
### 3. 服务类
|
||||
- `ISysLicenseService`: 授权服务接口
|
||||
- `activeLicense()`: 激活授权码
|
||||
- `checkLicenseValid()`: 检查授权是否有效
|
||||
- `getActiveLicense()`: 获取当前有效授权
|
||||
|
||||
### 4. 拦截器
|
||||
- `LicenseInterceptor`: 授权拦截器,在每次请求时验证授权有效性
|
||||
|
||||
### 5. 定时任务
|
||||
- `LicenseCheckTask`: 每5分钟检查授权状态,过期自动踢出在线用户
|
||||
|
||||
## 授权码格式
|
||||
|
||||
授权码采用AES加密,格式为:
|
||||
```
|
||||
加密(开始时间戳|结束时间戳)
|
||||
```
|
||||
|
||||
示例:
|
||||
```
|
||||
原始数据: 1704067200000|1735689600000
|
||||
加密后: Xj8K9mN2pQ5rT7vW1yZ3aB4cD6eF8gH0iJ2kL4mN6oP8qR0sT2uV4wX6yZ8
|
||||
```
|
||||
|
||||
## 集成到其他项目
|
||||
|
||||
### 步骤1:复制模块
|
||||
将 `ruoyi-license` 文件夹复制到目标项目根目录
|
||||
|
||||
### 步骤2:修改pom.xml
|
||||
在父pom.xml中添加:
|
||||
```xml
|
||||
<modules>
|
||||
<module>ruoyi-license</module>
|
||||
</modules>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-license</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
```
|
||||
|
||||
### 步骤3:添加依赖
|
||||
在启动模块的pom.xml中添加:
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-license</artifactId>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
### 步骤4:执行SQL脚本
|
||||
执行 `sql/sys_license.sql` 创建数据库表
|
||||
|
||||
### 步骤5:配置Controller
|
||||
将 `SysLicenseController.java` 复制到项目的controller包中
|
||||
|
||||
### 步骤6:配置前端页面
|
||||
将 `templates/system/license/` 目录复制到项目的templates目录
|
||||
|
||||
### 步骤7:修改登录页面
|
||||
参考 `login.html` 和 `login.js` 的修改,添加授权码激活入口
|
||||
|
||||
## 自定义配置
|
||||
|
||||
### 修改密钥
|
||||
编辑 `LicenseUtils.java`:
|
||||
```java
|
||||
private static final String SECRET_KEY = "YourSecretKey123"; // 16位密钥
|
||||
```
|
||||
|
||||
### 修改检查频率
|
||||
编辑 `LicenseCheckTask.java`:
|
||||
```java
|
||||
@Scheduled(cron = "0 */10 * * * ?") // 改为每10分钟检查
|
||||
```
|
||||
|
||||
### 自定义拦截规则
|
||||
编辑 `LicenseConfig.java`,添加或排除拦截路径:
|
||||
```java
|
||||
.excludePathPatterns(
|
||||
"/login",
|
||||
"/your-custom-path/**"
|
||||
)
|
||||
```
|
||||
|
||||
## 注意事项
|
||||
|
||||
1. **密钥安全**:生产环境务必修改默认密钥
|
||||
2. **时间同步**:确保服务器时间准确
|
||||
3. **数据备份**:定期备份授权表数据
|
||||
4. **权限控制**:授权管理菜单仅授予管理员
|
||||
5. **测试环境**:建议先在测试环境验证功能
|
||||
|
||||
## 常见问题
|
||||
|
||||
**Q: 授权码激活失败?**
|
||||
A: 检查授权码格式是否正确,是否已过期
|
||||
|
||||
**Q: 如何延长授权期限?**
|
||||
A: 生成新的授权码并激活即可
|
||||
|
||||
**Q: 授权过期后如何恢复?**
|
||||
A: 在登录页点击"激活授权码",输入新的授权码
|
||||
|
||||
**Q: 可以同时激活多个授权码吗?**
|
||||
A: 系统只使用最新激活且未过期的授权码
|
||||
|
||||
## 技术支持
|
||||
|
||||
如有问题,请联系技术支持或查看RuoYi官方文档。
|
||||
239
dosc/ruoyi-license/SUMMARY.md
Normal file
239
dosc/ruoyi-license/SUMMARY.md
Normal file
@@ -0,0 +1,239 @@
|
||||
# RuoYi 授权码模块 - 项目总结
|
||||
|
||||
## 📦 已完成的工作
|
||||
|
||||
### 1. 核心模块开发 ✅
|
||||
|
||||
**ruoyi-license 独立模块**
|
||||
- ✅ Maven模块配置 (pom.xml)
|
||||
- ✅ 授权实体类 (SysLicense.java)
|
||||
- ✅ 数据访问层 (SysLicenseMapper.java + XML)
|
||||
- ✅ 业务逻辑层 (ISysLicenseService.java + Impl)
|
||||
- ✅ 授权工具类 (LicenseUtils.java)
|
||||
- ✅ 授权拦截器 (LicenseInterceptor.java)
|
||||
- ✅ 拦截器配置 (LicenseConfig.java)
|
||||
- ✅ 定时检查任务 (LicenseCheckTask.java)
|
||||
- ✅ 授权码生成器 (LicenseGenerator.java)
|
||||
- ✅ 测试工具 (LicenseTest.java)
|
||||
|
||||
### 2. 控制器和前端 ✅
|
||||
|
||||
**后端控制器**
|
||||
- ✅ SysLicenseController.java (授权管理控制器)
|
||||
- 授权列表查询
|
||||
- 授权码激活
|
||||
- 授权码生成
|
||||
- 授权信息查看
|
||||
- 授权删除
|
||||
|
||||
**前端页面**
|
||||
- ✅ license.html (授权列表页)
|
||||
- ✅ active.html (激活页面)
|
||||
- ✅ login.html (添加激活入口)
|
||||
- ✅ login.js (添加激活功能)
|
||||
|
||||
### 3. 数据库脚本 ✅
|
||||
|
||||
- ✅ sys_license.sql
|
||||
- 授权表结构
|
||||
- 菜单权限配置
|
||||
|
||||
### 4. 项目集成 ✅
|
||||
|
||||
- ✅ 主pom.xml (添加license模块)
|
||||
- ✅ ruoyi-admin/pom.xml (添加license依赖)
|
||||
|
||||
### 5. 文档编写 ✅
|
||||
|
||||
- ✅ README.md (使用说明)
|
||||
- ✅ INTEGRATION.md (集成指南)
|
||||
|
||||
## 🎯 功能特性
|
||||
|
||||
### 核心功能
|
||||
1. **授权码加密存储** - AES加密,安全可靠
|
||||
2. **登录验证** - 登录时自动验证授权有效性
|
||||
3. **拦截器保护** - 所有请求都经过授权验证
|
||||
4. **定时检查** - 每5分钟自动检查授权状态
|
||||
5. **自动踢出** - 授权过期自动踢出所有在线用户
|
||||
6. **管理界面** - 完整的授权管理功能
|
||||
7. **登录页激活** - 无需登录即可激活授权码
|
||||
8. **授权码生成** - 内置生成工具,支持自定义天数
|
||||
|
||||
### 技术亮点
|
||||
- 🔒 AES加密算法保护授权码
|
||||
- 🔄 Spring拦截器实现全局授权验证
|
||||
- ⏰ Spring定时任务自动检查授权
|
||||
- 🎨 完整的前后端交互界面
|
||||
- 📦 独立模块设计,方便复用
|
||||
- 🛠️ 提供测试工具和生成工具
|
||||
|
||||
## 📂 文件清单
|
||||
|
||||
```
|
||||
ruoyi-license/
|
||||
├── src/main/java/com/ruoyi/license/
|
||||
│ ├── config/
|
||||
│ │ └── LicenseConfig.java (拦截器配置)
|
||||
│ ├── domain/
|
||||
│ │ └── SysLicense.java (授权实体)
|
||||
│ ├── interceptor/
|
||||
│ │ └── LicenseInterceptor.java (授权拦截器)
|
||||
│ ├── mapper/
|
||||
│ │ └── SysLicenseMapper.java (Mapper接口)
|
||||
│ ├── service/
|
||||
│ │ ├── ISysLicenseService.java (服务接口)
|
||||
│ │ └── impl/
|
||||
│ │ └── SysLicenseServiceImpl.java (服务实现)
|
||||
│ ├── task/
|
||||
│ │ └── LicenseCheckTask.java (定时任务)
|
||||
│ └── util/
|
||||
│ ├── LicenseUtils.java (工具类)
|
||||
│ ├── LicenseGenerator.java (生成器)
|
||||
│ └── LicenseTest.java (测试工具)
|
||||
├── src/main/resources/mapper/license/
|
||||
│ └── SysLicenseMapper.xml (MyBatis映射)
|
||||
├── pom.xml (模块配置)
|
||||
├── README.md (使用说明)
|
||||
└── INTEGRATION.md (集成指南)
|
||||
|
||||
sql/
|
||||
└── sys_license.sql (数据库脚本)
|
||||
|
||||
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/license/
|
||||
└── SysLicenseController.java (控制器)
|
||||
|
||||
ruoyi-admin/src/main/resources/templates/system/license/
|
||||
├── license.html (列表页)
|
||||
└── active.html (激活页)
|
||||
|
||||
修改的文件:
|
||||
├── pom.xml (添加模块)
|
||||
├── ruoyi-admin/pom.xml (添加依赖)
|
||||
├── ruoyi-admin/src/main/resources/templates/login.html
|
||||
└── ruoyi-admin/src/main/resources/static/ruoyi/login.js
|
||||
```
|
||||
|
||||
## 🚀 快速开始
|
||||
|
||||
### 1. 执行数据库脚本
|
||||
```sql
|
||||
source sql/sys_license.sql;
|
||||
```
|
||||
|
||||
### 2. 启用定时任务
|
||||
在 RuoYiApplication.java 添加 @EnableScheduling
|
||||
|
||||
### 3. 编译项目
|
||||
```bash
|
||||
mvn clean install
|
||||
```
|
||||
|
||||
### 4. 生成授权码
|
||||
运行 LicenseGenerator.java 或在系统界面生成
|
||||
|
||||
### 5. 激活授权码
|
||||
登录页点击"激活授权码"输入授权码
|
||||
|
||||
## 🔧 使用场景
|
||||
|
||||
### 场景1:软件交付
|
||||
- 开发完成后生成授权码
|
||||
- 交付给客户时提供授权码
|
||||
- 客户激活后可使用指定期限
|
||||
|
||||
### 场景2:试用版本
|
||||
- 生成30天试用授权码
|
||||
- 客户试用满意后购买正式授权
|
||||
- 激活正式授权码延长使用期限
|
||||
|
||||
### 场景3:订阅服务
|
||||
- 按年生成授权码
|
||||
- 到期前提醒客户续费
|
||||
- 续费后激活新授权码
|
||||
|
||||
### 场景4:多项目复用
|
||||
- 将license模块复制到其他项目
|
||||
- 修改密钥和配置
|
||||
- 快速实现授权功能
|
||||
|
||||
## ⚙️ 自定义配置
|
||||
|
||||
### 修改密钥(必须)
|
||||
```java
|
||||
// LicenseUtils.java
|
||||
private static final String SECRET_KEY = "YourKey16Chars!!";
|
||||
```
|
||||
|
||||
### 调整检查频率
|
||||
```java
|
||||
// LicenseCheckTask.java
|
||||
@Scheduled(cron = "0 */10 * * * ?") // 改为10分钟
|
||||
```
|
||||
|
||||
### 自定义拦截路径
|
||||
```java
|
||||
// LicenseConfig.java
|
||||
.excludePathPatterns("/api/**", "/public/**")
|
||||
```
|
||||
|
||||
## 📊 数据库表结构
|
||||
|
||||
```sql
|
||||
sys_license (授权表)
|
||||
├── license_id (授权ID - 主键)
|
||||
├── license_code (授权码 - 加密存储)
|
||||
├── start_time (开始时间)
|
||||
├── expire_time (结束时间)
|
||||
├── status (状态: 0未激活 1已激活 2已过期)
|
||||
├── active_time (激活时间)
|
||||
├── active_by (激活人)
|
||||
├── create_by (创建者)
|
||||
├── create_time (创建时间)
|
||||
├── update_by (更新者)
|
||||
├── update_time (更新时间)
|
||||
└── remark (备注)
|
||||
```
|
||||
|
||||
## 🔐 安全建议
|
||||
|
||||
1. **生产环境必须修改默认密钥**
|
||||
2. **授权码通过安全渠道传递**
|
||||
3. **定期备份授权表数据**
|
||||
4. **限制授权管理菜单权限**
|
||||
5. **监控授权激活日志**
|
||||
|
||||
## 📝 后续优化建议
|
||||
|
||||
1. **硬件绑定** - 绑定服务器MAC地址或CPU序列号
|
||||
2. **在线验证** - 连接授权服务器在线验证
|
||||
3. **授权分级** - 不同授权码对应不同功能权限
|
||||
4. **自动续费** - 集成支付接口自动续费
|
||||
5. **授权统计** - 统计授权使用情况和到期提醒
|
||||
|
||||
## ✅ 测试清单
|
||||
|
||||
- [ ] 数据库表创建成功
|
||||
- [ ] 菜单权限配置正确
|
||||
- [ ] 授权码生成功能正常
|
||||
- [ ] 授权码加密解密正确
|
||||
- [ ] 登录页激活功能正常
|
||||
- [ ] 系统内激活功能正常
|
||||
- [ ] 授权拦截器生效
|
||||
- [ ] 定时任务执行正常
|
||||
- [ ] 授权过期自动踢出
|
||||
- [ ] 授权列表查询正常
|
||||
|
||||
## 📞 技术支持
|
||||
|
||||
如有问题,请查看:
|
||||
1. README.md - 使用说明
|
||||
2. INTEGRATION.md - 集成指南
|
||||
3. RuoYi官方文档
|
||||
|
||||
---
|
||||
|
||||
**开发完成时间**: 2024
|
||||
**模块版本**: 1.0.0
|
||||
**适用框架**: RuoYi v4.8.2
|
||||
**技术栈**: SpringBoot + MyBatis + Shiro + Thymeleaf
|
||||
39
dosc/ruoyi-license/pom.xml
Normal file
39
dosc/ruoyi-license/pom.xml
Normal file
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>ruoyi</artifactId>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<version>3.8.9</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>ruoyi-license</artifactId>
|
||||
|
||||
<description>
|
||||
授权码管理模块
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- 通用工具-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 系统模块-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-system</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringBoot Web-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1 @@
|
||||
C:\Users\李涛\Documents\WXWork\1688851319997782\WeDrive\福莱瑞达\软件产品中心\软件产品中心共享资料\集成授权码功能\vue版本集成\授权码\ruoyi-license\src\main\java\com\ruoyi\license\config
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.ruoyi.license.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
import com.ruoyi.framework.config.properties.PermitAllUrlProperties;
|
||||
import com.ruoyi.license.interceptor.LicenseInterceptor;
|
||||
|
||||
/**
|
||||
* 授权模块配置
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Configuration
|
||||
public class LicenseConfig implements WebMvcConfigurer
|
||||
{
|
||||
@Autowired
|
||||
private LicenseInterceptor licenseInterceptor;
|
||||
|
||||
@Autowired
|
||||
private PermitAllUrlProperties permitAllUrl;
|
||||
|
||||
@Value("${license.enabled:false}")
|
||||
private boolean licenseEnabled;
|
||||
|
||||
private static final List<String> BASE_EXCLUDE = Arrays.asList(
|
||||
"/login",
|
||||
"/logout",
|
||||
"/register",
|
||||
"/captchaImage",
|
||||
"/system/license/active",
|
||||
"/swagger-ui.html",
|
||||
"/swagger-resources/**",
|
||||
"/webjars/**",
|
||||
"/*/api-docs",
|
||||
"/druid/**",
|
||||
"/*.html",
|
||||
"/**/*.html",
|
||||
"/**/*.css",
|
||||
"/**/*.js",
|
||||
"/profile/**"
|
||||
);
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry)
|
||||
{
|
||||
if (licenseEnabled)
|
||||
{
|
||||
List<String> excludeList = new ArrayList<>(BASE_EXCLUDE);
|
||||
excludeList.addAll(permitAllUrl.getUrls());
|
||||
registry.addInterceptor(licenseInterceptor)
|
||||
.addPathPatterns("/**")
|
||||
.excludePathPatterns(excludeList);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
C:\Users\李涛\Documents\WXWork\1688851319997782\WeDrive\福莱瑞达\软件产品中心\软件产品中心共享资料\集成授权码功能\vue版本集成\授权码\ruoyi-license\src\main\java\com\ruoyi\license\domain
|
||||
@@ -0,0 +1,105 @@
|
||||
package com.ruoyi.license.domain;
|
||||
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 系统授权码对象 sys_license
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class SysLicense extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 授权ID */
|
||||
private Long licenseId;
|
||||
|
||||
/** 授权码 */
|
||||
private String licenseCode;
|
||||
|
||||
/** 授权开始时间 */
|
||||
private Date startTime;
|
||||
|
||||
/** 授权结束时间 */
|
||||
private Date expireTime;
|
||||
|
||||
/** 授权状态(0未激活 1已激活 2已过期) */
|
||||
private String status;
|
||||
|
||||
/** 激活时间 */
|
||||
private Date activeTime;
|
||||
|
||||
/** 激活人 */
|
||||
private String activeBy;
|
||||
|
||||
public Long getLicenseId()
|
||||
{
|
||||
return licenseId;
|
||||
}
|
||||
|
||||
public void setLicenseId(Long licenseId)
|
||||
{
|
||||
this.licenseId = licenseId;
|
||||
}
|
||||
|
||||
public String getLicenseCode()
|
||||
{
|
||||
return licenseCode;
|
||||
}
|
||||
|
||||
public void setLicenseCode(String licenseCode)
|
||||
{
|
||||
this.licenseCode = licenseCode;
|
||||
}
|
||||
|
||||
public Date getStartTime()
|
||||
{
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(Date startTime)
|
||||
{
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public Date getExpireTime()
|
||||
{
|
||||
return expireTime;
|
||||
}
|
||||
|
||||
public void setExpireTime(Date expireTime)
|
||||
{
|
||||
this.expireTime = expireTime;
|
||||
}
|
||||
|
||||
public String getStatus()
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status)
|
||||
{
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Date getActiveTime()
|
||||
{
|
||||
return activeTime;
|
||||
}
|
||||
|
||||
public void setActiveTime(Date activeTime)
|
||||
{
|
||||
this.activeTime = activeTime;
|
||||
}
|
||||
|
||||
public String getActiveBy()
|
||||
{
|
||||
return activeBy;
|
||||
}
|
||||
|
||||
public void setActiveBy(String activeBy)
|
||||
{
|
||||
this.activeBy = activeBy;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
C:\Users\李涛\Documents\WXWork\1688851319997782\WeDrive\福莱瑞达\软件产品中心\软件产品中心共享资料\集成授权码功能\vue版本集成\授权码\ruoyi-license\src\main\java\com\ruoyi\license\interceptor
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.ruoyi.license.interceptor;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
import com.ruoyi.license.service.ISysLicenseService;
|
||||
|
||||
/**
|
||||
* 授权拦截器
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Component
|
||||
public class LicenseInterceptor implements HandlerInterceptor
|
||||
{
|
||||
@Autowired
|
||||
private ISysLicenseService licenseService;
|
||||
|
||||
@Value("${license.enabled:false}")
|
||||
private boolean licenseEnabled;
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception
|
||||
{
|
||||
if (!licenseEnabled)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!licenseService.checkLicenseValid())
|
||||
{
|
||||
response.setStatus(HttpServletResponse.SC_OK);
|
||||
response.setContentType("application/json;charset=UTF-8");
|
||||
PrintWriter writer = response.getWriter();
|
||||
writer.write("{\"code\":500,\"msg\":\"\u7cfb\u7edf\u6388\u6743\u5df2\u8fc7\u671f\uff0c\u8bf7\u8054\u7cfb\u7ba1\u7406\u5458\u6fc0\u6d3b\u6388\u6743\u7801\"}");
|
||||
writer.flush();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
C:\Users\李涛\Documents\WXWork\1688851319997782\WeDrive\福莱瑞达\软件产品中心\软件产品中心共享资料\集成授权码功能\vue版本集成\授权码\ruoyi-license\src\main\java\com\ruoyi\license\mapper
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.ruoyi.license.mapper;
|
||||
|
||||
import com.ruoyi.license.domain.SysLicense;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 授权码Mapper接口
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface SysLicenseMapper
|
||||
{
|
||||
/**
|
||||
* 查询授权码
|
||||
*
|
||||
* @param licenseId 授权码ID
|
||||
* @return 授权码
|
||||
*/
|
||||
public SysLicense selectSysLicenseById(Long licenseId);
|
||||
|
||||
/**
|
||||
* 查询授权码列表
|
||||
*
|
||||
* @param sysLicense 授权码
|
||||
* @return 授权码集合
|
||||
*/
|
||||
public List<SysLicense> selectSysLicenseList(SysLicense sysLicense);
|
||||
|
||||
/**
|
||||
* 查询当前有效的授权码
|
||||
*
|
||||
* @return 授权码
|
||||
*/
|
||||
public SysLicense selectActiveLicense();
|
||||
|
||||
/**
|
||||
* 新增授权码
|
||||
*
|
||||
* @param sysLicense 授权码
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertSysLicense(SysLicense sysLicense);
|
||||
|
||||
/**
|
||||
* 修改授权码
|
||||
*
|
||||
* @param sysLicense 授权码
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateSysLicense(SysLicense sysLicense);
|
||||
|
||||
/**
|
||||
* 删除授权码
|
||||
*
|
||||
* @param licenseId 授权码ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysLicenseById(Long licenseId);
|
||||
|
||||
/**
|
||||
* 批量删除授权码
|
||||
*
|
||||
* @param licenseIds 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysLicenseByIds(String[] licenseIds);
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
C:\Users\李涛\Documents\WXWork\1688851319997782\WeDrive\福莱瑞达\软件产品中心\软件产品中心共享资料\集成授权码功能\vue版本集成\授权码\ruoyi-license\src\main\java\com\ruoyi\license\service
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.ruoyi.license.service;
|
||||
|
||||
import com.ruoyi.license.domain.SysLicense;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 授权码Service接口
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface ISysLicenseService
|
||||
{
|
||||
/**
|
||||
* 查询授权码
|
||||
*
|
||||
* @param licenseId 授权码ID
|
||||
* @return 授权码
|
||||
*/
|
||||
public SysLicense selectSysLicenseById(Long licenseId);
|
||||
|
||||
/**
|
||||
* 查询授权码列表
|
||||
*
|
||||
* @param sysLicense 授权码
|
||||
* @return 授权码集合
|
||||
*/
|
||||
public List<SysLicense> selectSysLicenseList(SysLicense sysLicense);
|
||||
|
||||
/**
|
||||
* 新增授权码
|
||||
*
|
||||
* @param sysLicense 授权码
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertSysLicense(SysLicense sysLicense);
|
||||
|
||||
/**
|
||||
* 修改授权码
|
||||
*
|
||||
* @param sysLicense 授权码
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateSysLicense(SysLicense sysLicense);
|
||||
|
||||
/**
|
||||
* 批量删除授权码
|
||||
*
|
||||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysLicenseByIds(String ids);
|
||||
|
||||
/**
|
||||
* 删除授权码信息
|
||||
*
|
||||
* @param licenseId 授权码ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysLicenseById(Long licenseId);
|
||||
|
||||
/**
|
||||
* 激活授权码
|
||||
*
|
||||
* @param licenseCode 授权码
|
||||
* @return 结果
|
||||
*/
|
||||
public int activeLicense(String licenseCode);
|
||||
|
||||
/**
|
||||
* 检查授权是否有效
|
||||
*
|
||||
* @return true有效 false无效
|
||||
*/
|
||||
public boolean checkLicenseValid();
|
||||
|
||||
/**
|
||||
* 获取当前有效授权信息
|
||||
*
|
||||
* @return 授权信息
|
||||
*/
|
||||
public SysLicense getActiveLicense();
|
||||
|
||||
/**
|
||||
* 更新过期授权码状态
|
||||
*/
|
||||
public void updateExpiredLicenses();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
C:\Users\李涛\Documents\WXWork\1688851319997782\WeDrive\福莱瑞达\软件产品中心\软件产品中心共享资料\集成授权码功能\vue版本集成\授权码\ruoyi-license\src\main\java\com\ruoyi\license\service\impl
|
||||
@@ -0,0 +1,266 @@
|
||||
package com.ruoyi.license.service.impl;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.common.core.text.Convert;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.license.domain.SysLicense;
|
||||
import com.ruoyi.license.mapper.SysLicenseMapper;
|
||||
import com.ruoyi.license.service.ISysLicenseService;
|
||||
import com.ruoyi.license.util.LicenseUtils;
|
||||
|
||||
/**
|
||||
* 授权码Service业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Service
|
||||
public class SysLicenseServiceImpl implements ISysLicenseService
|
||||
{
|
||||
@Autowired
|
||||
private SysLicenseMapper sysLicenseMapper;
|
||||
|
||||
@Autowired
|
||||
private com.ruoyi.system.mapper.SysConfigMapper sysConfigMapper;
|
||||
|
||||
@org.springframework.beans.factory.annotation.Value("${license.enabled:false}")
|
||||
private boolean licenseEnabled;
|
||||
|
||||
/**
|
||||
* 查询授权码
|
||||
*
|
||||
* @param licenseId 授权码ID
|
||||
* @return 授权码
|
||||
*/
|
||||
@Override
|
||||
public SysLicense selectSysLicenseById(Long licenseId)
|
||||
{
|
||||
return sysLicenseMapper.selectSysLicenseById(licenseId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询授权码列表
|
||||
*
|
||||
* @param sysLicense 授权码
|
||||
* @return 授权码
|
||||
*/
|
||||
@Override
|
||||
public List<SysLicense> selectSysLicenseList(SysLicense sysLicense)
|
||||
{
|
||||
return sysLicenseMapper.selectSysLicenseList(sysLicense);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增授权码
|
||||
*
|
||||
* @param sysLicense 授权码
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertSysLicense(SysLicense sysLicense)
|
||||
{
|
||||
sysLicense.setCreateTime(new Date());
|
||||
return sysLicenseMapper.insertSysLicense(sysLicense);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改授权码
|
||||
*
|
||||
* @param sysLicense 授权码
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateSysLicense(SysLicense sysLicense)
|
||||
{
|
||||
sysLicense.setUpdateTime(new Date());
|
||||
return sysLicenseMapper.updateSysLicense(sysLicense);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除授权码对象
|
||||
*
|
||||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysLicenseByIds(String ids)
|
||||
{
|
||||
return sysLicenseMapper.deleteSysLicenseByIds(Convert.toStrArray(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除授权码信息
|
||||
*
|
||||
* @param licenseId 授权码ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysLicenseById(Long licenseId)
|
||||
{
|
||||
return sysLicenseMapper.deleteSysLicenseById(licenseId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 激活授权码
|
||||
*
|
||||
* @param licenseCode 授权码
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int activeLicense(String licenseCode)
|
||||
{
|
||||
if (StringUtils.isEmpty(licenseCode))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 验证授权码格式
|
||||
if (!LicenseUtils.validateFormat(licenseCode))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// 从配置表获取项目编号
|
||||
String projectNo = sysConfigMapper.selectConfigByKey("fortucky.project.no");
|
||||
if (StringUtils.isEmpty(projectNo))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 解析授权码
|
||||
long expireTime = LicenseUtils.parseLicense(licenseCode, projectNo);
|
||||
if (expireTime == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
Date now = new Date();
|
||||
Date startTime = now;
|
||||
Date expireDate = new Date(expireTime);
|
||||
|
||||
// 验证是否已过期
|
||||
if (expireDate.before(now))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 创建授权记录
|
||||
SysLicense license = new SysLicense();
|
||||
license.setLicenseCode(licenseCode);
|
||||
license.setStartTime(startTime);
|
||||
license.setExpireTime(expireDate);
|
||||
license.setStatus("1");
|
||||
license.setActiveTime(now);
|
||||
license.setCreateTime(now);
|
||||
|
||||
return sysLicenseMapper.insertSysLicense(license);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查授权是否有效
|
||||
*
|
||||
* @return true有效 false无效
|
||||
*/
|
||||
@Override
|
||||
public boolean checkLicenseValid()
|
||||
{
|
||||
// 如果授权码功能未启用,直接返回true
|
||||
if (!licenseEnabled)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
SysLicense license = sysLicenseMapper.selectActiveLicense();
|
||||
if (license == null)
|
||||
{
|
||||
System.out.println("[授权检查] 没有找到激活的授权码");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 从配置表获取项目编号
|
||||
String projectNo = sysConfigMapper.selectConfigByKey("fortucky.project.no");
|
||||
if (StringUtils.isEmpty(projectNo))
|
||||
{
|
||||
System.out.println("[授权检查] 项目编号未配置");
|
||||
return false;
|
||||
}
|
||||
|
||||
System.out.println("[授权检查] 授权码: " + license.getLicenseCode());
|
||||
System.out.println("[授权检查] 项目编号: " + projectNo);
|
||||
|
||||
// 从授权码解析过期时间
|
||||
long expireTime = LicenseUtils.parseLicense(license.getLicenseCode(), projectNo);
|
||||
if (expireTime == 0)
|
||||
{
|
||||
System.out.println("[授权检查] 授权码解析失败");
|
||||
return false;
|
||||
}
|
||||
|
||||
Date now = new Date();
|
||||
System.out.println("[授权检查] 当前时间: " + now.getTime());
|
||||
System.out.println("[授权检查] 过期时间: " + expireTime);
|
||||
|
||||
if (expireTime < now.getTime())
|
||||
{
|
||||
System.out.println("[授权检查] 授权已过期");
|
||||
// 更新为过期状态
|
||||
license.setStatus("2");
|
||||
sysLicenseMapper.updateSysLicense(license);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前有效授权信息
|
||||
*
|
||||
* @return 授权信息
|
||||
*/
|
||||
@Override
|
||||
public SysLicense getActiveLicense()
|
||||
{
|
||||
return sysLicenseMapper.selectActiveLicense();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新过期授权码状态
|
||||
*/
|
||||
@Override
|
||||
public void updateExpiredLicenses()
|
||||
{
|
||||
SysLicense query = new SysLicense();
|
||||
query.setStatus("1");
|
||||
List<SysLicense> licenses = sysLicenseMapper.selectSysLicenseList(query);
|
||||
|
||||
// 从配置表获取项目编号
|
||||
String projectNo = sysConfigMapper.selectConfigByKey("fortucky.project.no");
|
||||
if (StringUtils.isEmpty(projectNo))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Date now = new Date();
|
||||
for (SysLicense license : licenses)
|
||||
{
|
||||
// 从授权码解析过期时间
|
||||
long expireTime = LicenseUtils.parseLicense(license.getLicenseCode(), projectNo);
|
||||
if (expireTime > 0 && expireTime < now.getTime())
|
||||
{
|
||||
license.setStatus("2");
|
||||
license.setUpdateTime(now);
|
||||
sysLicenseMapper.updateSysLicense(license);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
C:\Users\李涛\Documents\WXWork\1688851319997782\WeDrive\福莱瑞达\软件产品中心\软件产品中心共享资料\集成授权码功能\vue版本集成\授权码\ruoyi-license\src\main\java\com\ruoyi\license\task
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.ruoyi.license.task;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
import com.ruoyi.common.constant.CacheConstants;
|
||||
import com.ruoyi.common.core.redis.RedisCache;
|
||||
import com.ruoyi.license.service.ISysLicenseService;
|
||||
|
||||
/**
|
||||
* 授权检查定时任务
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Component
|
||||
public class LicenseCheckTask
|
||||
{
|
||||
@Autowired
|
||||
private ISysLicenseService licenseService;
|
||||
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
@Value("${license.enabled:false}")
|
||||
private boolean licenseEnabled;
|
||||
|
||||
/**
|
||||
* 每5分钟检查一次授权状态
|
||||
*/
|
||||
@Scheduled(cron = "0 */5 * * * ?")
|
||||
public void checkLicense()
|
||||
{
|
||||
if (!licenseEnabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!licenseService.checkLicenseValid())
|
||||
{
|
||||
// 授权无效,删除 Redis 中所有登录 token,强制踢出所有在线用户
|
||||
redisCache.deleteObject(redisCache.keys(CacheConstants.LOGIN_TOKEN_KEY + "*"));
|
||||
}
|
||||
|
||||
licenseService.updateExpiredLicenses();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
C:\Users\李涛\Documents\WXWork\1688851319997782\WeDrive\福莱瑞达\软件产品中心\软件产品中心共享资料\集成授权码功能\vue版本集成\授权码\ruoyi-license\src\main\java\com\ruoyi\license\util
|
||||
@@ -0,0 +1,127 @@
|
||||
package com.ruoyi.license.util;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
* 授权码生成工具(独立运行)
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class LicenseGenerator
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
|
||||
System.out.println("========================================");
|
||||
System.out.println(" RuoYi 授权码生成工具");
|
||||
System.out.println("========================================");
|
||||
System.out.println();
|
||||
|
||||
try
|
||||
{
|
||||
// 选择授权类型
|
||||
System.out.println("请选择授权类型:");
|
||||
System.out.println("1. 5分钟测试");
|
||||
System.out.println("2. 1个月授权");
|
||||
System.out.println("3. 3个月授权");
|
||||
System.out.println("4. 1年授权");
|
||||
System.out.println("5. 5年授权");
|
||||
System.out.println("6. 长期授权");
|
||||
System.out.print("请输入选项(1-6): ");
|
||||
String typeChoice = scanner.nextLine().trim();
|
||||
|
||||
String type;
|
||||
String typeDesc;
|
||||
long expireTime;
|
||||
|
||||
switch (typeChoice)
|
||||
{
|
||||
case "1":
|
||||
type = LicenseUtils.TYPE_TEST;
|
||||
typeDesc = "5分钟测试";
|
||||
expireTime = System.currentTimeMillis() + 5 * 60 * 1000L;
|
||||
break;
|
||||
case "2":
|
||||
type = LicenseUtils.TYPE_MONTH;
|
||||
typeDesc = "1个月授权";
|
||||
expireTime = System.currentTimeMillis() + 30L * 24 * 60 * 60 * 1000;
|
||||
break;
|
||||
case "3":
|
||||
type = LicenseUtils.TYPE_THREE;
|
||||
typeDesc = "3个月授权";
|
||||
expireTime = System.currentTimeMillis() + 90L * 24 * 60 * 60 * 1000;
|
||||
break;
|
||||
case "4":
|
||||
type = LicenseUtils.TYPE_YEAR;
|
||||
typeDesc = "1年授权";
|
||||
expireTime = System.currentTimeMillis() + 365L * 24 * 60 * 60 * 1000;
|
||||
break;
|
||||
case "5":
|
||||
type = LicenseUtils.TYPE_FIVE;
|
||||
typeDesc = "5年授权";
|
||||
expireTime = System.currentTimeMillis() + 5 * 365L * 24 * 60 * 60 * 1000;
|
||||
break;
|
||||
case "6":
|
||||
type = LicenseUtils.TYPE_FOREVER;
|
||||
typeDesc = "长期授权";
|
||||
expireTime = System.currentTimeMillis() + 100 * 365L * 24 * 60 * 60 * 1000;
|
||||
break;
|
||||
default:
|
||||
System.out.println("错误:无效的选项");
|
||||
return;
|
||||
}
|
||||
|
||||
// 输入项目编号
|
||||
System.out.print("请输入项目编号: ");
|
||||
String projectNo = scanner.nextLine().trim();
|
||||
|
||||
if (projectNo.isEmpty())
|
||||
{
|
||||
System.out.println("错误:项目编号不能为空");
|
||||
return;
|
||||
}
|
||||
|
||||
// 生成授权码
|
||||
String licenseCode = LicenseUtils.generateLicense(type, projectNo);
|
||||
|
||||
if (licenseCode == null)
|
||||
{
|
||||
System.out.println("错误:授权码生成失败");
|
||||
return;
|
||||
}
|
||||
|
||||
// 格式化日期
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Date now = new Date();
|
||||
Date expire = new Date(expireTime);
|
||||
|
||||
System.out.println();
|
||||
System.out.println("========================================");
|
||||
System.out.println("授权码生成成功!");
|
||||
System.out.println("========================================");
|
||||
System.out.println("授权类型: " + typeDesc);
|
||||
System.out.println("项目编号: " + projectNo);
|
||||
System.out.println("当前时间: " + sdf.format(now));
|
||||
System.out.println("过期时间: " + sdf.format(expire));
|
||||
System.out.println("----------------------------------------");
|
||||
System.out.println("授权码:");
|
||||
System.out.println(licenseCode);
|
||||
System.out.println("========================================");
|
||||
System.out.println();
|
||||
System.out.println("请妥善保管授权码,在系统中激活后即可使用。");
|
||||
System.out.println("注意:系统配置中的项目编号必须与此处一致才能激活。");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.out.println("错误:" + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
scanner.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.ruoyi.license.util;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 授权码测试工具
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class LicenseTest
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
System.out.println("========================================");
|
||||
System.out.println(" 授权码功能测试");
|
||||
System.out.println("========================================");
|
||||
System.out.println();
|
||||
|
||||
String projectNo = "TEST001";
|
||||
|
||||
// 测试1:生成各类型授权码
|
||||
System.out.println("【测试1】生成各类型授权码");
|
||||
String testCode = LicenseUtils.generateLicense(LicenseUtils.TYPE_TEST, projectNo);
|
||||
String yearCode = LicenseUtils.generateLicense(LicenseUtils.TYPE_YEAR, projectNo);
|
||||
String fiveCode = LicenseUtils.generateLicense(LicenseUtils.TYPE_FIVE, projectNo);
|
||||
String foreverCode = LicenseUtils.generateLicense(LicenseUtils.TYPE_FOREVER, projectNo);
|
||||
|
||||
System.out.println("5分钟测试: " + testCode);
|
||||
System.out.println("1年授权: " + yearCode);
|
||||
System.out.println("5年授权: " + fiveCode);
|
||||
System.out.println("长期授权: " + foreverCode);
|
||||
System.out.println("结果: ✓ 通过");
|
||||
System.out.println();
|
||||
|
||||
// 测试2:验证授权码格式
|
||||
System.out.println("【测试2】验证授权码格式");
|
||||
boolean isValid = LicenseUtils.validateFormat(yearCode);
|
||||
System.out.println("格式验证: " + (isValid ? "✓ 通过" : "✗ 失败"));
|
||||
System.out.println();
|
||||
|
||||
// 测试3:解析授权码
|
||||
System.out.println("【测试3】解析授权码");
|
||||
long expireTime = LicenseUtils.parseLicense(yearCode, projectNo);
|
||||
if (expireTime > 0)
|
||||
{
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Date expire = new Date(expireTime);
|
||||
System.out.println("过期时间: " + sdf.format(expire));
|
||||
System.out.println("结果: ✓ 通过");
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("结果: ✗ 失败");
|
||||
}
|
||||
System.out.println();
|
||||
|
||||
// 测试4:项目编号验证
|
||||
System.out.println("【测试4】项目编号验证");
|
||||
long validResult = LicenseUtils.parseLicense(yearCode, projectNo);
|
||||
long invalidResult = LicenseUtils.parseLicense(yearCode, "WRONG001");
|
||||
System.out.println("正确项目编号: " + (validResult > 0 ? "✓ 通过" : "✗ 失败"));
|
||||
System.out.println("错误项目编号: " + (invalidResult == 0 ? "✓ 通过(正确拒绝)" : "✗ 失败"));
|
||||
System.out.println();
|
||||
|
||||
// 测试5:授权码格式展示
|
||||
System.out.println("【测试5】授权码格式展示");
|
||||
System.out.println("授权码: " + yearCode);
|
||||
String[] parts = yearCode.split("_");
|
||||
if (parts.length == 5)
|
||||
{
|
||||
System.out.println("前缀: " + parts[0]);
|
||||
System.out.println("类型: " + parts[1] + " (" + LicenseUtils.getTypeDesc(parts[1]) + ")");
|
||||
System.out.println("项目编号: " + parts[2]);
|
||||
System.out.println("加密时间: " + parts[3]);
|
||||
System.out.println("校验码: " + parts[4]);
|
||||
System.out.println("结果: ✓ 通过");
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("结果: ✗ 失败");
|
||||
}
|
||||
System.out.println();
|
||||
|
||||
System.out.println("========================================");
|
||||
System.out.println("测试完成!");
|
||||
System.out.println("========================================");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,275 @@
|
||||
package com.ruoyi.license.util;
|
||||
|
||||
import java.util.Base64;
|
||||
import java.util.Date;
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
/**
|
||||
* 授权码工具类
|
||||
* 格式: FORTUCKY_授权类型_项目编号_加密时间_校验码
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class LicenseUtils
|
||||
{
|
||||
// 密钥(16位)
|
||||
private static final String SECRET_KEY = "RuoYiLicense2024";
|
||||
|
||||
// 授权类型
|
||||
public static final String TYPE_TEST = "TEST"; // 5分钟测试
|
||||
public static final String TYPE_MONTH = "MONTH"; // 1个月
|
||||
public static final String TYPE_THREE = "THREE"; // 3个月
|
||||
public static final String TYPE_YEAR = "YEAR"; // 1年
|
||||
public static final String TYPE_FIVE = "FIVE"; // 5年
|
||||
public static final String TYPE_FOREVER = "FOREVER"; // 长期
|
||||
|
||||
/**
|
||||
* 生成授权码
|
||||
*
|
||||
* @param type 授权类型
|
||||
* @param projectNo 项目编号
|
||||
* @return 授权码
|
||||
*/
|
||||
public static String generateLicense(String type, String projectNo)
|
||||
{
|
||||
try
|
||||
{
|
||||
long expireTime = calculateExpireTime(type);
|
||||
if (expireTime == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// 加密过期时间
|
||||
String encryptedTime = encrypt(String.valueOf(expireTime));
|
||||
if (encryptedTime == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// 生成校验码(取加密时间的前8位MD5)
|
||||
String checkCode = generateCheckCode(type, projectNo, encryptedTime);
|
||||
|
||||
// 拼接授权码: FORTUCKY_类型_项目编号_加密时间_校验码
|
||||
return "FORTUCKY_" + type + "_" + projectNo + "_" + encryptedTime + "_" + checkCode;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证授权码格式
|
||||
*
|
||||
* @param licenseCode 授权码
|
||||
* @return true有效 false无效
|
||||
*/
|
||||
public static boolean validateFormat(String licenseCode)
|
||||
{
|
||||
if (licenseCode == null || licenseCode.trim().isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
String[] parts = licenseCode.split("_");
|
||||
if (parts.length != 5)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!"FORTUCKY".equals(parts[0]))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// 验证授权类型
|
||||
String type = parts[1];
|
||||
if (!TYPE_TEST.equals(type) && !TYPE_MONTH.equals(type) && !TYPE_THREE.equals(type) &&
|
||||
!TYPE_YEAR.equals(type) && !TYPE_FIVE.equals(type) && !TYPE_FOREVER.equals(type))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析授权码
|
||||
*
|
||||
* @param licenseCode 授权码
|
||||
* @param projectNo 系统项目编号
|
||||
* @return 过期时间戳,0表示解析失败
|
||||
*/
|
||||
public static long parseLicense(String licenseCode, String projectNo)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!validateFormat(licenseCode))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
String[] parts = licenseCode.split("_");
|
||||
String type = parts[1];
|
||||
String codeProjectNo = parts[2];
|
||||
String encryptedTime = parts[3];
|
||||
String checkCode = parts[4];
|
||||
|
||||
// 验证项目编号
|
||||
if (!codeProjectNo.equals(projectNo))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 验证校验码
|
||||
String expectedCheckCode = generateCheckCode(type, codeProjectNo, encryptedTime);
|
||||
if (!checkCode.equals(expectedCheckCode))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 解密时间
|
||||
String decrypted = decrypt(encryptedTime);
|
||||
if (decrypted == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return Long.parseLong(decrypted);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取授权类型描述
|
||||
*
|
||||
* @param type 授权类型
|
||||
* @return 描述
|
||||
*/
|
||||
public static String getTypeDesc(String type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case TYPE_TEST: return "5分钟测试";
|
||||
case TYPE_MONTH: return "1个月授权";
|
||||
case TYPE_THREE: return "3个月授权";
|
||||
case TYPE_YEAR: return "1年授权";
|
||||
case TYPE_FIVE: return "5年授权";
|
||||
case TYPE_FOREVER: return "长期授权";
|
||||
default: return "未知";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算过期时间
|
||||
*
|
||||
* @param type 授权类型
|
||||
* @return 过期时间戳
|
||||
*/
|
||||
private static long calculateExpireTime(String type)
|
||||
{
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case TYPE_TEST:
|
||||
return now + 5 * 60 * 1000L; // 5分钟
|
||||
case TYPE_MONTH:
|
||||
return now + 30L * 24 * 60 * 60 * 1000; // 1个月
|
||||
case TYPE_THREE:
|
||||
return now + 90L * 24 * 60 * 60 * 1000; // 3个月
|
||||
case TYPE_YEAR:
|
||||
return now + 365L * 24 * 60 * 60 * 1000; // 1年
|
||||
case TYPE_FIVE:
|
||||
return now + 5 * 365L * 24 * 60 * 60 * 1000; // 5年
|
||||
case TYPE_FOREVER:
|
||||
return now + 100 * 365L * 24 * 60 * 60 * 1000; // 100年(视为长期)
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成校验码
|
||||
*
|
||||
* @param type 授权类型
|
||||
* @param projectNo 项目编号
|
||||
* @param encryptedTime 加密时间
|
||||
* @return 校验码
|
||||
*/
|
||||
private static String generateCheckCode(String type, String projectNo, String encryptedTime)
|
||||
{
|
||||
try
|
||||
{
|
||||
String data = type + projectNo + encryptedTime;
|
||||
java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5");
|
||||
byte[] hash = md.digest(data.getBytes("UTF-8"));
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < Math.min(4, hash.length); i++)
|
||||
{
|
||||
sb.append(String.format("%02x", hash[i]));
|
||||
}
|
||||
return sb.toString().toUpperCase();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return "00000000";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 加密
|
||||
*
|
||||
* @param data 原始数据
|
||||
* @return 加密后的数据
|
||||
*/
|
||||
private static String encrypt(String data)
|
||||
{
|
||||
try
|
||||
{
|
||||
SecretKeySpec key = new SecretKeySpec(SECRET_KEY.getBytes("UTF-8"), "AES");
|
||||
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
|
||||
cipher.init(Cipher.ENCRYPT_MODE, key);
|
||||
byte[] encrypted = cipher.doFinal(data.getBytes("UTF-8"));
|
||||
return Base64.getEncoder().encodeToString(encrypted).replace("+", "-").replace("/", ".").replace("=", "");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 解密
|
||||
*
|
||||
* @param encryptedData 加密数据
|
||||
* @return 解密后的数据
|
||||
*/
|
||||
private static String decrypt(String encryptedData)
|
||||
{
|
||||
try
|
||||
{
|
||||
String base64Data = encryptedData.replace("-", "+").replace(".", "/");
|
||||
int padding = (4 - base64Data.length() % 4) % 4;
|
||||
for (int i = 0; i < padding; i++)
|
||||
{
|
||||
base64Data += "=";
|
||||
}
|
||||
|
||||
SecretKeySpec key = new SecretKeySpec(SECRET_KEY.getBytes("UTF-8"), "AES");
|
||||
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
|
||||
cipher.init(Cipher.DECRYPT_MODE, key);
|
||||
byte[] decrypted = cipher.doFinal(Base64.getDecoder().decode(base64Data));
|
||||
return new String(decrypted, "UTF-8");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
C:\Users\李涛\Documents\WXWork\1688851319997782\WeDrive\福莱瑞达\软件产品中心\软件产品中心共享资料\集成授权码功能\vue版本集成\授权码\ruoyi-license\src\main\resources\mapper\license
|
||||
@@ -0,0 +1,108 @@
|
||||
<?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.ruoyi.license.mapper.SysLicenseMapper">
|
||||
|
||||
<resultMap type="com.ruoyi.license.domain.SysLicense" id="SysLicenseResult">
|
||||
<result property="licenseId" column="license_id" />
|
||||
<result property="licenseCode" column="license_code" />
|
||||
<result property="startTime" column="start_time" />
|
||||
<result property="expireTime" column="expire_time" />
|
||||
<result property="status" column="status" />
|
||||
<result property="activeTime" column="active_time" />
|
||||
<result property="activeBy" column="active_by" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectSysLicenseVo">
|
||||
select license_id, license_code, start_time, expire_time, status, active_time, active_by, create_by, create_time, update_by, update_time, remark from sys_license
|
||||
</sql>
|
||||
|
||||
<select id="selectSysLicenseList" parameterType="com.ruoyi.license.domain.SysLicense" resultMap="SysLicenseResult">
|
||||
<include refid="selectSysLicenseVo"/>
|
||||
<where>
|
||||
<if test="licenseCode != null and licenseCode != ''"> and license_code = #{licenseCode}</if>
|
||||
<if test="startTime != null "> and start_time = #{startTime}</if>
|
||||
<if test="expireTime != null "> and expire_time = #{expireTime}</if>
|
||||
<if test="status != null and status != ''"> and status = #{status}</if>
|
||||
</where>
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectSysLicenseById" parameterType="Long" resultMap="SysLicenseResult">
|
||||
<include refid="selectSysLicenseVo"/>
|
||||
where license_id = #{licenseId}
|
||||
</select>
|
||||
|
||||
<select id="selectActiveLicense" resultMap="SysLicenseResult">
|
||||
<include refid="selectSysLicenseVo"/>
|
||||
where status = '1'
|
||||
order by create_time desc
|
||||
OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY
|
||||
</select>
|
||||
|
||||
<insert id="insertSysLicense" parameterType="com.ruoyi.license.domain.SysLicense" useGeneratedKeys="true" keyProperty="licenseId">
|
||||
insert into sys_license
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="licenseCode != null and licenseCode != ''">license_code,</if>
|
||||
<if test="startTime != null">start_time,</if>
|
||||
<if test="expireTime != null">expire_time,</if>
|
||||
<if test="status != null and status != ''">status,</if>
|
||||
<if test="activeTime != null">active_time,</if>
|
||||
<if test="activeBy != null">active_by,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="licenseCode != null and licenseCode != ''">#{licenseCode},</if>
|
||||
<if test="startTime != null">#{startTime},</if>
|
||||
<if test="expireTime != null">#{expireTime},</if>
|
||||
<if test="status != null and status != ''">#{status},</if>
|
||||
<if test="activeTime != null">#{activeTime},</if>
|
||||
<if test="activeBy != null">#{activeBy},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateSysLicense" parameterType="com.ruoyi.license.domain.SysLicense">
|
||||
update sys_license
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="licenseCode != null and licenseCode != ''">license_code = #{licenseCode},</if>
|
||||
<if test="startTime != null">start_time = #{startTime},</if>
|
||||
<if test="expireTime != null">expire_time = #{expireTime},</if>
|
||||
<if test="status != null and status != ''">status = #{status},</if>
|
||||
<if test="activeTime != null">active_time = #{activeTime},</if>
|
||||
<if test="activeBy != null">active_by = #{activeBy},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
</trim>
|
||||
where license_id = #{licenseId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteSysLicenseById" parameterType="Long">
|
||||
delete from sys_license where license_id = #{licenseId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteSysLicenseByIds" parameterType="String">
|
||||
delete from sys_license where license_id in
|
||||
<foreach item="licenseId" collection="array" open="(" separator="," close=")">
|
||||
#{licenseId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
270
dosc/vue授权码.md
Normal file
270
dosc/vue授权码.md
Normal file
@@ -0,0 +1,270 @@
|
||||
# 授权码模块集成改动说明
|
||||
|
||||
> 本文档记录引入 `ruoyi-license` 授权码模块时,对原有项目文件的所有改动(不含 `ruoyi-license` 模块本身及 `SysLicenseController`)。
|
||||
|
||||
---
|
||||
|
||||
## 1. 根模块 `pom.xml`
|
||||
|
||||
**文件路径:** `wms/pom.xml`
|
||||
|
||||
**改动内容:**
|
||||
|
||||
1. `<modules>` 中注册 `ruoyi-license` 子模块:
|
||||
|
||||
```xml
|
||||
<modules>
|
||||
<module>ruoyi-admin</module>
|
||||
<module>ruoyi-framework</module>
|
||||
<module>ruoyi-system</module>
|
||||
<module>ruoyi-quartz</module>
|
||||
<module>ruoyi-generator</module>
|
||||
<module>ruoyi-common</module>
|
||||
<module>ruoyi-license</module> <!-- 新增 -->
|
||||
</modules>
|
||||
```
|
||||
|
||||
2. `<dependencyManagement>` 中声明 `ruoyi-license` 依赖版本:
|
||||
|
||||
```xml
|
||||
<!-- 授权码模块 -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-license</artifactId>
|
||||
<version>${ruoyi.version}</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 2. `ruoyi-admin/pom.xml`
|
||||
|
||||
**文件路径:** `wms/ruoyi-admin/pom.xml`
|
||||
|
||||
**改动内容:**
|
||||
|
||||
引入 `ruoyi-license` 依赖,使授权拦截器和配置能被 Spring Boot 扫描加载:
|
||||
|
||||
```xml
|
||||
<!-- 授权码模块 -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-license</artifactId>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 3. `SecurityConfig.java`
|
||||
|
||||
**文件路径:** `wms/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java`
|
||||
|
||||
**改动内容:**
|
||||
|
||||
在 Spring Security 匿名白名单中加入 `/system/license/active`,允许未登录用户调用激活授权码接口:
|
||||
|
||||
```java
|
||||
// 改动前
|
||||
requests.antMatchers("/login", "/register", "/captchaImage").permitAll()
|
||||
|
||||
// 改动后
|
||||
requests.antMatchers("/login", "/register", "/captchaImage", "/system/license/active").permitAll()
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 4. 前端 `api/license.js`(新建)
|
||||
|
||||
**文件路径:** `wms/ui/src/api/license.js`
|
||||
|
||||
**改动内容:**
|
||||
|
||||
新建文件,封装授权码相关接口:
|
||||
|
||||
```js
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 激活授权码(无需登录)
|
||||
export function activeLicense(licenseCode) {
|
||||
return request({
|
||||
url: '/system/license/active',
|
||||
method: 'post',
|
||||
params: { licenseCode }
|
||||
})
|
||||
}
|
||||
|
||||
// 查询当前授权信息(需登录)
|
||||
export function getLicenseInfo() {
|
||||
return request({
|
||||
url: '/system/license/info',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 5. 登录页 `login.vue`
|
||||
|
||||
**文件路径:** `wms/ui/src/views/login.vue`
|
||||
|
||||
**改动内容:**
|
||||
|
||||
### 5.1 模板部分
|
||||
|
||||
在登录按钮下方新增"激活授权码"按钮,以及激活弹窗:
|
||||
|
||||
```html
|
||||
<!-- 激活授权码按钮 -->
|
||||
<el-form-item style="width:100%;">
|
||||
<el-button
|
||||
size="medium"
|
||||
type="warning"
|
||||
style="width:100%;"
|
||||
@click.native.prevent="openLicenseDialog"
|
||||
>激活授权码</el-button>
|
||||
</el-form-item>
|
||||
|
||||
<!-- 激活授权码弹窗 -->
|
||||
<el-dialog title="激活授权码" :visible.sync="licenseDialogVisible" width="420px" append-to-body>
|
||||
<el-input v-model="licenseCode" type="textarea" :rows="4" placeholder="请输入授权码" />
|
||||
<span slot="footer">
|
||||
<el-button @click="licenseDialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" :loading="licenseLoading" @click="handleActiveLicense">激 活</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
```
|
||||
|
||||
### 5.2 Script 部分
|
||||
|
||||
新增 import、data 字段和方法:
|
||||
|
||||
```js
|
||||
// 新增 import
|
||||
import { activeLicense } from "@/api/license"
|
||||
|
||||
// 新增 data 字段
|
||||
licenseDialogVisible: false,
|
||||
licenseCode: '',
|
||||
licenseLoading: false
|
||||
|
||||
// 新增方法
|
||||
openLicenseDialog() {
|
||||
this.licenseCode = ''
|
||||
this.licenseDialogVisible = true
|
||||
},
|
||||
handleActiveLicense() {
|
||||
if (!this.licenseCode.trim()) {
|
||||
this.$message.warning('请输入授权码')
|
||||
return
|
||||
}
|
||||
this.licenseLoading = true
|
||||
activeLicense(this.licenseCode.trim()).then(res => {
|
||||
if (res.code === 200) {
|
||||
this.$message.success(res.msg || '授权码激活成功')
|
||||
this.licenseDialogVisible = false
|
||||
} else {
|
||||
this.$message.error(res.msg || '授权码激活失败')
|
||||
}
|
||||
}).catch(() => {
|
||||
this.$message.error('授权码激活失败')
|
||||
}).finally(() => {
|
||||
this.licenseLoading = false
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 6. 顶部导航栏 `Navbar.vue`
|
||||
|
||||
**文件路径:** `wms/ui/src/layout/components/Navbar.vue`
|
||||
|
||||
**改动内容:**
|
||||
|
||||
### 6.1 模板部分
|
||||
|
||||
在 navbar 中间插入授权到期警告条(剩余不足 30 天时显示):
|
||||
|
||||
```html
|
||||
<div v-if="licenseWarning" class="license-warning">
|
||||
<i class="el-icon-warning-outline" />
|
||||
系统授权将于 {{ licenseExpireText }} 后过期,请及时联系管理员续期
|
||||
</div>
|
||||
```
|
||||
|
||||
### 6.2 Script 部分
|
||||
|
||||
```js
|
||||
// 新增 import
|
||||
import { getLicenseInfo } from '@/api/license'
|
||||
|
||||
// 新增 data 字段
|
||||
licenseWarning: false,
|
||||
licenseExpireText: '',
|
||||
licenseTimer: null
|
||||
|
||||
// 新增生命周期钩子
|
||||
mounted() {
|
||||
this.checkLicenseExpire()
|
||||
this.licenseTimer = setInterval(() => this.checkLicenseExpire(), 60 * 1000)
|
||||
},
|
||||
beforeDestroy() {
|
||||
if (this.licenseTimer) clearInterval(this.licenseTimer)
|
||||
},
|
||||
|
||||
// 新增方法
|
||||
checkLicenseExpire() {
|
||||
getLicenseInfo().then(res => {
|
||||
if (res.code === 200 && res.data && res.data.expireTime) {
|
||||
const expireTime = new Date(res.data.expireTime).getTime()
|
||||
const now = Date.now()
|
||||
const diffMs = expireTime - now
|
||||
const diffDays = Math.ceil(diffMs / (1000 * 60 * 60 * 24))
|
||||
if (diffMs > 0 && diffDays <= 30) {
|
||||
this.licenseWarning = true
|
||||
if (diffMs < 1000 * 60 * 60 * 24) {
|
||||
const hours = Math.floor(diffMs / (1000 * 60 * 60))
|
||||
const minutes = Math.floor((diffMs % (1000 * 60 * 60)) / (1000 * 60))
|
||||
this.licenseExpireText = hours > 0 ? `${hours} 小时 ${minutes} 分钟` : `${minutes} 分钟`
|
||||
} else if (diffDays < 7) {
|
||||
this.licenseExpireText = diffDays + ' 天'
|
||||
} else {
|
||||
this.licenseExpireText = Math.ceil(diffDays / 7) + ' 周'
|
||||
}
|
||||
}
|
||||
}
|
||||
}).catch(() => {})
|
||||
}
|
||||
```
|
||||
|
||||
### 6.3 样式部分
|
||||
|
||||
```scss
|
||||
.license-warning {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
top: 0;
|
||||
height: 50px;
|
||||
line-height: 50px;
|
||||
font-size: 13px;
|
||||
color: #e6a23c;
|
||||
font-weight: 500;
|
||||
pointer-events: none;
|
||||
i { margin-right: 4px; }
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 改动文件汇总
|
||||
|
||||
| 文件 | 类型 | 说明 |
|
||||
|---|---|---|
|
||||
| `wms/pom.xml` | 修改 | 注册模块 + 声明依赖版本 |
|
||||
| `wms/ruoyi-admin/pom.xml` | 修改 | 引入 ruoyi-license 依赖 |
|
||||
| `ruoyi-framework/.../SecurityConfig.java` | 修改 | 白名单加入激活授权码接口 |
|
||||
| `ui/src/api/license.js` | 新建 | 封装激活和查询授权信息接口 |
|
||||
| `ui/src/views/login.vue` | 修改 | 新增激活授权码按钮和弹窗 |
|
||||
| `ui/src/layout/components/Navbar.vue` | 修改 | 新增授权到期倒计时警告条 |
|
||||
BIN
dosc/授权码vue版本配置手册.docx
Normal file
BIN
dosc/授权码vue版本配置手册.docx
Normal file
Binary file not shown.
10
pom.xml
10
pom.xml
@@ -191,6 +191,13 @@
|
||||
<version>${ruoyi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 授权码模块 -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-license</artifactId>
|
||||
<version>${ruoyi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.ai</groupId>
|
||||
<artifactId>spring-ai-bom</artifactId>
|
||||
@@ -243,6 +250,7 @@
|
||||
<module>ruoyi-quartz</module>
|
||||
<module>ruoyi-generator</module>
|
||||
<module>ruoyi-common</module>
|
||||
<module>ruoyi-license</module>
|
||||
</modules>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
@@ -251,7 +259,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.13.0</version>
|
||||
<version>3.11.0</version>
|
||||
<configuration>
|
||||
<parameters>true</parameters>
|
||||
<source>${java.version}</source>
|
||||
|
||||
@@ -54,6 +54,12 @@
|
||||
<artifactId>ruoyi-generator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 授权码模块 -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-license</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.ai</groupId>
|
||||
<artifactId>spring-ai-starter-model-openai</artifactId>
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.ruoyi;
|
||||
|
||||
import java.security.Security;
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Collectors;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
/**
|
||||
@@ -17,6 +19,7 @@ public class RuoYiApplication
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
enableSqlServerLegacyTls();
|
||||
// System.setProperty("spring.devtools.restart.enabled", "false");
|
||||
SpringApplication.run(RuoYiApplication.class, args);
|
||||
System.out.println("""
|
||||
@@ -24,4 +27,25 @@ public class RuoYiApplication
|
||||
This is a text block with Unicode characters.
|
||||
""");
|
||||
}
|
||||
|
||||
private static void enableSqlServerLegacyTls()
|
||||
{
|
||||
if (!Boolean.parseBoolean(System.getProperty("ruoyi.sqlserver.legacyTls.enabled", "true")))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
String propertyName = "jdk.tls.disabledAlgorithms";
|
||||
String disabledAlgorithms = Security.getProperty(propertyName);
|
||||
if (disabledAlgorithms == null || disabledAlgorithms.isBlank())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
String compatibleAlgorithms = Arrays.stream(disabledAlgorithms.split(","))
|
||||
.map(String::trim)
|
||||
.filter(algorithm -> !"TLSv1".equalsIgnoreCase(algorithm))
|
||||
.collect(Collectors.joining(", "));
|
||||
Security.setProperty(propertyName, compatibleAlgorithms);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
package com.ruoyi.api.controller;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.ruoyi.api.moveMsg.domain.MoveMsg;
|
||||
import com.ruoyi.api.service.IToErpService;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.log.service.IRequestLogService;
|
||||
import com.ruoyi.pda.mapper.PdaMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import com.ruoyi.api.domain.DeliveryNoticeVo;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* 作业统计 Controller
|
||||
*/
|
||||
@@ -19,6 +25,8 @@ public class ToErpApiController {
|
||||
private IToErpService toErpService;
|
||||
@Autowired
|
||||
private IRequestLogService requestLogService;
|
||||
@Autowired
|
||||
private PdaMapper pdaMapper;
|
||||
|
||||
/**
|
||||
* 接收入出库通知单
|
||||
@@ -28,7 +36,7 @@ public class ToErpApiController {
|
||||
public AjaxResult receiveDeliveryNotice(@RequestBody DeliveryNoticeVo deliveryNoticeVo) {
|
||||
|
||||
AjaxResult ajaxResult = toErpService.receiveDeliveryNotice(deliveryNoticeVo);
|
||||
requestLogService.insertRequestLog(requestLogService.getRequestLog(deliveryNoticeVo.toString(), "接收入出库通知单", ajaxResult));
|
||||
requestLogService.insertRequestLog(requestLogService.getRequestLogERP(JSONUtil.toJsonStr(deliveryNoticeVo), "接收入出库通知单", ajaxResult));
|
||||
return ajaxResult;
|
||||
|
||||
|
||||
@@ -36,22 +44,107 @@ public class ToErpApiController {
|
||||
|
||||
|
||||
/**
|
||||
* 回传其他入库单
|
||||
* 回传入库单
|
||||
*/
|
||||
// @Scheduled(fixedDelay = 1500)
|
||||
@Scheduled(fixedDelay = 1500)
|
||||
@RequestMapping("/callbackInDeliveryNotice")
|
||||
@ResponseBody
|
||||
public void callbackInDeliveryNotice() {
|
||||
toErpService.callbackInDeliveryNotice();
|
||||
public void callbackInDeliveryNoticeNew() {
|
||||
toErpService.callbackInDeliveryNoticeNew();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 回传出库单(新)
|
||||
*/
|
||||
@Scheduled(fixedDelay = 1500)
|
||||
@RequestMapping("/callbackOutDeliveryNotice")
|
||||
@ResponseBody
|
||||
public void callbackDeliveryOutNoticeNew() {
|
||||
toErpService.callbackDeliveryOutNoticeNew();
|
||||
}
|
||||
|
||||
|
||||
// @Scheduled(fixedDelay = 1500)
|
||||
// @RequestMapping("/callbackOutDeliveryNotice")
|
||||
// @ResponseBody
|
||||
// public void callbackDeliveryOutNoticeNewS() {
|
||||
// toErpService.callbackDeliveryOutNoticeNews();
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// /**
|
||||
// * 回传其他入库单
|
||||
// */
|
||||
// @Scheduled(fixedDelay = 1500)
|
||||
// @RequestMapping("/callbackInDeliveryNotice")
|
||||
// @ResponseBody
|
||||
// public void callbackInDeliveryNotice() {
|
||||
// toErpService.callbackInDeliveryNotice();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 回传其他出库单
|
||||
// */
|
||||
// @Scheduled(fixedDelay = 1500)
|
||||
// @RequestMapping("/callbackOutDeliveryNotice")
|
||||
// @ResponseBody
|
||||
// public void callbackDeliveryOutNotice() {
|
||||
// toErpService.callbackoutDeliveryNotice();
|
||||
// }
|
||||
|
||||
/**
|
||||
* 移库回调接口
|
||||
*/
|
||||
@Scheduled(fixedDelay = 1500)
|
||||
@RequestMapping("/moveCargoSpace")
|
||||
@ResponseBody
|
||||
public void moveCargoSpace() {
|
||||
toErpService.moveCargoSpace();
|
||||
}
|
||||
|
||||
/**
|
||||
* 回传其他出库单
|
||||
* 自动确认入库单据
|
||||
*/
|
||||
@RequestMapping("/callbackOutDeliveryNotice")
|
||||
@Scheduled(fixedDelay = 10000)
|
||||
// @RequestMapping("/FillFinishAllot")
|
||||
@ResponseBody
|
||||
public void callbackDeliveryOutNotice() {
|
||||
toErpService.callbackoutDeliveryNotice();
|
||||
public void FillFinishAllot() {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("v_result", null);
|
||||
map.put("v_result_msg", null);
|
||||
pdaMapper.FillFinishAllot(map);
|
||||
String result = map.get("v_result").toString();
|
||||
String msg = map.get("v_result_msg").toString();
|
||||
if ("10".equals(result)) {
|
||||
System.err.println(msg);
|
||||
} else {
|
||||
// System.err.println(msg);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 自动确认出库单据
|
||||
*/
|
||||
@Scheduled(fixedDelay = 10000)
|
||||
// @RequestMapping("/FillFinishAllot")
|
||||
@ResponseBody
|
||||
public void FillFinishAllotOut() {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("v_result", null);
|
||||
map.put("v_result_msg", null);
|
||||
pdaMapper.FillFinishAllotOut(map);
|
||||
String result = map.get("v_result").toString();
|
||||
String msg = map.get("v_result_msg").toString();
|
||||
if ("10".equals(result)) {
|
||||
System.err.println(msg);
|
||||
} else {
|
||||
// System.err.println(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.ruoyi.api.controller;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.ruoyi.api.domain.ErpProduct;
|
||||
import com.ruoyi.api.domain.ReMaterialParam;
|
||||
@@ -11,6 +12,10 @@ import com.ruoyi.bas.BasProduct.service.IBasProductService;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.device.agv.domain.AgvContainerTask;
|
||||
import com.ruoyi.device.agv.service.IAgvContainerTaskService;
|
||||
import com.ruoyi.job.mydojob.domain.MydoJob;
|
||||
import com.ruoyi.job.mydojob.mapper.MydoJobMapper;
|
||||
import com.ruoyi.log.domain.RequestLog;
|
||||
import com.ruoyi.log.service.IRequestLogService;
|
||||
import com.ruoyi.out.outStockout.domain.OutStockoutVo;
|
||||
@@ -19,7 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 作业统计 Controller
|
||||
@@ -36,6 +41,10 @@ public class ToWmsApiController {
|
||||
private IOutStockoutService outStockoutService;
|
||||
@Autowired
|
||||
private IBasProductService basProductService;
|
||||
@Autowired
|
||||
private MydoJobMapper mapper;
|
||||
@Autowired
|
||||
private IAgvContainerTaskService agvContainerTaskService;
|
||||
|
||||
/**
|
||||
* 入库请求生成作业
|
||||
@@ -43,18 +52,50 @@ public class ToWmsApiController {
|
||||
@PostMapping("/requestEnterByTrayCode")
|
||||
public AjaxResult requestEnterByTrayCode(@RequestBody RequestEnter requestEnter) {
|
||||
AjaxResult ajaxResult = toWmsService.requestEnterByTrayCode(requestEnter);
|
||||
RequestLog requestLog = requestLogService.getRequestLog(JSONUtil.toJsonStr(requestEnter), "入库任务创建请求",ajaxResult);
|
||||
RequestLog requestLog = requestLogService.getRequestLog(JSONUtil.toJsonStr(requestEnter), "入库任务创建请求", ajaxResult);
|
||||
requestLogService.insertRequestLog(requestLog);
|
||||
return ajaxResult;
|
||||
}
|
||||
|
||||
// 入库分货位
|
||||
@PostMapping("/sendCargoSpace")
|
||||
public AjaxResult sendCargoSpace(@RequestBody RequestEnter requestEnter) {
|
||||
AjaxResult ajaxResult = toWmsService.requestEnterByTaskNo(requestEnter);
|
||||
RequestLog requestLog = requestLogService.getRequestLog(JSONUtil.toJsonStr(requestEnter), "入库请求分配货位", ajaxResult);
|
||||
requestLogService.insertRequestLog(requestLog);
|
||||
return ajaxResult;
|
||||
}
|
||||
|
||||
|
||||
// 出库到位更新LED显示屏
|
||||
@PostMapping("/updateLed")
|
||||
public AjaxResult updateLed(@RequestBody RequestEnter requestEnter) {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("v_task_no", requestEnter.getTaskNo());
|
||||
map.put("v_code", requestEnter.getDeviceCode());
|
||||
mapper.updateLed(map);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
||||
// 线体报警更新报警信息
|
||||
@PostMapping("/updateLedError")
|
||||
public AjaxResult updateLedError(@RequestBody RequestEnter requestEnter) {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("v_code", requestEnter.getDeviceCode());
|
||||
map.put("v_error_code", requestEnter.getErrorCode());
|
||||
mapper.updateLedError(map);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 请求补码作业
|
||||
*/
|
||||
@RequestMapping("/requestByNoTrayCode")
|
||||
public AjaxResult requestByNoTrayCode(@RequestBody RequestEnter requestEnter) {
|
||||
AjaxResult ajaxResult = toWmsService.selectMydoJobByEntranceId(requestEnter);
|
||||
RequestLog requestLog = requestLogService.getRequestLog(JSONUtil.toJsonStr(requestEnter), "请求补码作业",ajaxResult);
|
||||
RequestLog requestLog = requestLogService.getRequestLog(JSONUtil.toJsonStr(requestEnter), "请求补码作业", ajaxResult);
|
||||
requestLogService.insertRequestLog(requestLog);
|
||||
return ajaxResult;
|
||||
}
|
||||
@@ -65,7 +106,7 @@ public class ToWmsApiController {
|
||||
@RequestMapping("/requestEnterByTrayCodeAndEntranceId")
|
||||
public AjaxResult requestEnterByTrayCodeAndEntranceId(@RequestBody RequestEnter requestEnter) {
|
||||
AjaxResult ajaxResult = toWmsService.requestEnterByTrayCodeAndEntranceId(requestEnter);
|
||||
RequestLog requestLog = requestLogService.getRequestLog(JSONUtil.toJsonStr(requestEnter), "获取入库作业",ajaxResult);
|
||||
RequestLog requestLog = requestLogService.getRequestLog(JSONUtil.toJsonStr(requestEnter), "获取入库作业", ajaxResult);
|
||||
requestLogService.insertRequestLog(requestLog);
|
||||
return ajaxResult;
|
||||
}
|
||||
@@ -80,12 +121,11 @@ public class ToWmsApiController {
|
||||
* positionCode1:起点
|
||||
* positionCode2:终点
|
||||
* containerCode:容器编码
|
||||
*
|
||||
*/
|
||||
@PostMapping("/jobFinish")
|
||||
public AjaxResult jobFinish(@RequestBody WmsJobRequest wmsJobRequest) {
|
||||
AjaxResult ajaxResult = toWmsService.jobFinish(wmsJobRequest);
|
||||
RequestLog requestLog = requestLogService.getRequestLog(JSONUtil.toJsonStr(wmsJobRequest), "jobFinish",ajaxResult);
|
||||
RequestLog requestLog = requestLogService.getRequestLog(JSONUtil.toJsonStr(wmsJobRequest), "jobFinish", ajaxResult);
|
||||
requestLogService.insertRequestLog(requestLog);
|
||||
return ajaxResult;
|
||||
}
|
||||
@@ -96,7 +136,7 @@ public class ToWmsApiController {
|
||||
@PostMapping("/reAssign")
|
||||
public AjaxResult reAssign(@RequestBody ReMaterialParam reMaterialParam) {
|
||||
AjaxResult ajaxResult = toWmsService.reAssign(reMaterialParam);
|
||||
RequestLog requestLog = requestLogService.getRequestLog(JSONUtil.toJsonStr(reMaterialParam), "reAssign",ajaxResult);
|
||||
RequestLog requestLog = requestLogService.getRequestLog(JSONUtil.toJsonStr(reMaterialParam), "reAssign", ajaxResult);
|
||||
requestLogService.insertRequestLog(requestLog);
|
||||
return ajaxResult;
|
||||
}
|
||||
@@ -107,13 +147,12 @@ public class ToWmsApiController {
|
||||
@PostMapping("/reMaterial")
|
||||
public AjaxResult reMaterial(@RequestBody ReMaterialParam reMaterialParam) {
|
||||
AjaxResult ajaxResult = toWmsService.reMaterial(reMaterialParam);
|
||||
RequestLog requestLog = requestLogService.getRequestLog(JSONUtil.toJsonStr(reMaterialParam), "reMaterial",ajaxResult);
|
||||
RequestLog requestLog = requestLogService.getRequestLog(JSONUtil.toJsonStr(reMaterialParam), "reMaterial", ajaxResult);
|
||||
requestLogService.insertRequestLog(requestLog);
|
||||
return ajaxResult;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 出库单据保存
|
||||
*
|
||||
@@ -137,8 +176,7 @@ public class ToWmsApiController {
|
||||
*/
|
||||
@Log(title = "接收物料", businessType = BusinessType.INSERT)
|
||||
@PutMapping("/receiveProduct")
|
||||
public AjaxResult receiveProduct(@RequestBody ErpProduct erpProduct)
|
||||
{
|
||||
public AjaxResult receiveProduct(@RequestBody ErpProduct erpProduct) {
|
||||
AjaxResult ajaxResult = toWmsService.receiveProduct(erpProduct);
|
||||
RequestLog requestLog = requestLogService.getRequestLog(JSONUtil.toJsonStr(erpProduct), "接收物料", ajaxResult);
|
||||
requestLogService.insertRequestLog(requestLog);
|
||||
@@ -150,8 +188,7 @@ public class ToWmsApiController {
|
||||
*/
|
||||
@Log(title = "修改物料管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/updateProduct")
|
||||
public AjaxResult updateProduct(@RequestBody ErpProduct erpProduct)
|
||||
{
|
||||
public AjaxResult updateProduct(@RequestBody ErpProduct erpProduct) {
|
||||
AjaxResult ajaxResult = toWmsService.updateProduct(erpProduct);
|
||||
RequestLog requestLog = requestLogService.getRequestLog(JSONUtil.toJsonStr(erpProduct), "修改物料管理", ajaxResult);
|
||||
requestLogService.insertRequestLog(requestLog);
|
||||
@@ -163,12 +200,76 @@ public class ToWmsApiController {
|
||||
*/
|
||||
@Log(title = "作废物料", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/InvalidProduct")
|
||||
public AjaxResult InvalidProduct(@RequestBody ErpProduct erpProduct)
|
||||
{
|
||||
public AjaxResult InvalidProduct(@RequestBody ErpProduct erpProduct) {
|
||||
AjaxResult ajaxResult = toWmsService.InvalidProduct(erpProduct);
|
||||
RequestLog requestLog = requestLogService.getRequestLog(JSONUtil.toJsonStr(erpProduct), "作废物料", ajaxResult);
|
||||
requestLogService.insertRequestLog(requestLog);
|
||||
return ajaxResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求AGV执行队列
|
||||
*/
|
||||
// @Log(title = "请求未下发的AGV执行队列", businessType = BusinessType.OTHER)
|
||||
@RequestMapping("/queryAgvQuene")
|
||||
public AjaxResult queryAgvQuene() {
|
||||
AgvContainerTask agvContainerTask = new AgvContainerTask();
|
||||
agvContainerTask.setStatus("0");
|
||||
List<AgvContainerTask> agvContainerTasks = agvContainerTaskService.selectAgvContainerTaskList(agvContainerTask);
|
||||
RequestLog requestLog = requestLogService.getRequestLog(JSONUtil.toJsonStr(""), "请求未下发的AGV执行队列", AjaxResult.success(agvContainerTasks));
|
||||
requestLogService.insertRequestLog(requestLog);
|
||||
if (agvContainerTasks != null && agvContainerTasks.size() > 0) {
|
||||
for (AgvContainerTask containerTask : agvContainerTasks) {
|
||||
containerTask.setStatus("1");
|
||||
agvContainerTaskService.updateAgvContainerTask(containerTask);
|
||||
}
|
||||
return AjaxResult.success(agvContainerTasks.get(0));
|
||||
} else {
|
||||
return AjaxResult.error("无队列");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 请求AGV执行队列
|
||||
*/
|
||||
@Log(title = "完成AGV执行队列", businessType = BusinessType.UPDATE)
|
||||
@RequestMapping("/finishAgvQuene")
|
||||
public AjaxResult finishAgvQuene(@RequestBody JSONObject jsonObject) {
|
||||
String order = (String) jsonObject.get("order");
|
||||
agvContainerTaskService.deleteAgvJobByOrder(order);
|
||||
return AjaxResult.success();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Log(title = "自动生成Agv搬运队列到线边", businessType = BusinessType.INSERT)
|
||||
@PutMapping("/insertAgvQuene")
|
||||
public AjaxResult insertAgvQuene(@RequestBody WmsJobRequest wmsJobRequest) {
|
||||
String taskNo = wmsJobRequest.getTaskNo();// 到位任务号
|
||||
String code = wmsJobRequest.getCode();// 线体号
|
||||
AgvContainerTask agvContainerTask = new AgvContainerTask();
|
||||
agvContainerTask.setTaskNo(taskNo);
|
||||
List<AgvContainerTask> agvContainerTasks = agvContainerTaskService.selectAgvContainerTaskList(agvContainerTask);
|
||||
if (Objects.isNull(agvContainerTasks)) {
|
||||
MydoJob mydoJob = new MydoJob();
|
||||
mydoJob.setTaskNo(taskNo);
|
||||
List<MydoJob> mydoJobs = mapper.selectMydoJobList(mydoJob);
|
||||
AgvContainerTask agvContainerTask1 = new AgvContainerTask();
|
||||
agvContainerTask1.setContainer(UUID.randomUUID().toString());
|
||||
agvContainerTask1.setTaskNo(taskNo);
|
||||
agvContainerTask1.setStartPoint(code);
|
||||
agvContainerTask1.setEndPoint(mydoJobs.get(0).getEndPoint());//TODO 需要修改
|
||||
agvContainerTask1.setSpare2(mydoJobs.get(0).getTrayCode());
|
||||
// 10缓存区到线边 11立库到线边 12 立库到缓存区 13 缓存到立库
|
||||
agvContainerTask1.setSpare1("11");
|
||||
agvContainerTask1.setStatus("0");
|
||||
agvContainerTaskService.insertAgvContainerTask(agvContainerTask1);
|
||||
}
|
||||
RequestLog requestLog = requestLogService.getRequestLog(JSONUtil.toJsonStr(wmsJobRequest), "自动生成Agv搬运队列到线边", AjaxResult.success());
|
||||
requestLogService.insertRequestLog(requestLog);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.annotation.Anonymous;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@@ -23,6 +24,7 @@ public class TwinController {
|
||||
@Autowired
|
||||
private ITwinService twinService;
|
||||
|
||||
//获取所有货位
|
||||
@Anonymous
|
||||
@GetMapping("/getEmptyCargoSpace")
|
||||
public AjaxResult getEmptyCargoSpace() {
|
||||
@@ -30,10 +32,25 @@ public class TwinController {
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
//获取统计信息
|
||||
@Anonymous
|
||||
@GetMapping("/getStockList")
|
||||
public Map<String, Object> getStockList() {
|
||||
return twinService.getStockListOverview();
|
||||
}
|
||||
|
||||
//根据货位号获取库存中的物料信息
|
||||
@Anonymous
|
||||
@GetMapping("/getCargo/{cargoSpaceName}")
|
||||
public Map<String, Object> getCargo(@PathVariable("cargoSpaceName") String cargoSpaceName) {
|
||||
return twinService.getCargo(cargoSpaceName);
|
||||
}
|
||||
|
||||
//根据任务号获取作业表中的物料信息
|
||||
@Anonymous
|
||||
@GetMapping("/getTaskCargo/{taskNo}")
|
||||
public Map<String, Object> getTaskCargo(@PathVariable("taskNo") String taskNo) {
|
||||
return twinService.getTaskCargo(taskNo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,9 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
import org.w3c.dom.stylesheets.LinkStyle;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 出入库通知单-子表接收对象
|
||||
@@ -42,7 +45,38 @@ public class DeliveryNoticeItemVo {
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
|
||||
private List<LocationDetail> locations;
|
||||
/**货位*/
|
||||
private String area;
|
||||
|
||||
/**托盘*/
|
||||
private String location;
|
||||
|
||||
private String areaBefore;
|
||||
|
||||
private String locationBefore;
|
||||
/** 项目号 */
|
||||
private String projectNo;
|
||||
/**
|
||||
* erp子表主键
|
||||
***/
|
||||
private String sourceLineId;
|
||||
/**
|
||||
* 条码号
|
||||
***/
|
||||
private String barCode;
|
||||
/**
|
||||
* 是否批次管理
|
||||
**/
|
||||
private String isBatchManage;
|
||||
|
||||
/**旧项目号**/
|
||||
private String oldProjectNo;
|
||||
/**组件号**/
|
||||
private String groupNum;
|
||||
|
||||
|
||||
/**存放地点 1 立库 2平库*/
|
||||
private String stg_location;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -49,6 +49,17 @@ public class DeliveryNoticeVo {
|
||||
private String warehouseId;
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
/** 配送终点 */
|
||||
private String destination;
|
||||
/** 领料车间 */
|
||||
private String workshop;
|
||||
|
||||
|
||||
private String companyShortName;
|
||||
/** 账套号**/
|
||||
private String accountSetNo;
|
||||
/** 子表明细列表 */
|
||||
|
||||
|
||||
private List<DeliveryNoticeItemVo> detailList;
|
||||
}
|
||||
|
||||
@@ -20,4 +20,8 @@ public class RequestEnter {
|
||||
private String type;
|
||||
|
||||
private String flag;
|
||||
private String taskNo;
|
||||
private String deviceCode;
|
||||
private String code;
|
||||
private String errorCode;
|
||||
}
|
||||
|
||||
@@ -24,4 +24,6 @@ public class WmsJobRequest {
|
||||
private String positionCode2;
|
||||
//任务id
|
||||
private String jobId;
|
||||
//线体号
|
||||
private String code;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.ruoyi.api.service;
|
||||
|
||||
import com.ruoyi.api.domain.DeliveryNoticeVo;
|
||||
import com.ruoyi.api.moveMsg.domain.MoveMsg;
|
||||
import com.ruoyi.bas.BasProduct.domain.BasProduct;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
|
||||
@@ -16,5 +17,13 @@ public interface IToErpService {
|
||||
|
||||
void callbackoutDeliveryNotice();
|
||||
|
||||
void moveCargoSpace();
|
||||
|
||||
AjaxResult createWorkshopInboundOrder(BasProduct basProduct);
|
||||
|
||||
void callbackInDeliveryNoticeNew();
|
||||
|
||||
void callbackDeliveryOutNoticeNew();
|
||||
|
||||
void callbackDeliveryOutNoticeNews();
|
||||
}
|
||||
|
||||
@@ -59,4 +59,6 @@ public interface IToWmsService {
|
||||
* 作废物料
|
||||
*/
|
||||
AjaxResult InvalidProduct(ErpProduct erpProduct);
|
||||
|
||||
AjaxResult requestEnterByTaskNo(RequestEnter requestEnter);
|
||||
}
|
||||
|
||||
@@ -4,5 +4,7 @@ import java.util.Map;
|
||||
|
||||
public interface ITwinService {
|
||||
Map<String, Object> getStockListOverview();
|
||||
Map<String, Object> getCargo(String cargoSpaceName);
|
||||
Map<String, Object> getTaskCargo(String taskNo);
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -33,7 +33,7 @@ public class ToWcsServiceImpl implements IToWcsService {
|
||||
@Autowired
|
||||
private IAgvContainerTaskService agvContainerTaskService;
|
||||
|
||||
public static final String PUSH_OUT_MYDO_JOB = "http://localhost:8081/wcs2Wms/api/receiveOutMydoJob";
|
||||
public static final String PUSH_OUT_MYDO_JOB = "http://192.168.188.236:8081/wcs2Wms/api/receiveOutMydoJob";
|
||||
public static final String PUSH_IN_MYDO_JOB = "http://localhost:8081/wcs2Wms/api/receiveInMydoJob";
|
||||
public static final String PUSH_AGV_MOVE_JOB = "http://localhost:8081/agv/api/receiveAgvMoveJob";
|
||||
public static final String OUT_MYDOJOB_MS = "http://localhost:8081/wcs2Wms/api/outMydojobMakesure";
|
||||
@@ -43,15 +43,12 @@ public class ToWcsServiceImpl implements IToWcsService {
|
||||
|
||||
|
||||
@Override
|
||||
// @Scheduled(fixedDelay=1500)
|
||||
@Scheduled(fixedDelay=1500)
|
||||
public void pushOutMydoJob() {
|
||||
//查询所有未推送的料箱出库作业
|
||||
MydoJob mydoJobParam = new MydoJob();
|
||||
mydoJobParam.setStatus("1");
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add("21");
|
||||
list.add("26");
|
||||
mydoJobParam.setInOutIds(list);
|
||||
mydoJobParam.setInOut("2");
|
||||
List<MydoJob> outMydoJobs = mydoJobService.selectMydoJobListApi(mydoJobParam);
|
||||
for (MydoJob outMydoJob : outMydoJobs) {
|
||||
RequestLog requestLog = requestLogService.getRequestLog(PUSH_OUT_MYDO_JOB, JSONUtil.toJsonStr(outMydoJob), "推送出库任务","wms","wcs");
|
||||
|
||||
@@ -93,27 +93,29 @@ public class ToWmsServiceImpl implements IToWmsService {
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult requestEnterByTrayCode(RequestEnter requestEnter) {
|
||||
|
||||
String trayCode = requestEnter.getTrayCode();
|
||||
MydoJob inJob = mydoJobMapper.selectInJobByTrayCode(trayCode);
|
||||
if(inJob != null && Integer.parseInt(inJob.getInOrOut()) < 20){
|
||||
if(inJob.getCargoSpaceId() != null && !"".equals(inJob.getCargoSpaceId())){
|
||||
return AjaxResult.success(JSONUtil.toJsonStr(inJob));
|
||||
}else{
|
||||
//分配货位
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
// if(inJob.getCargoSpaceId() != null && !"".equals(inJob.getCargoSpaceId())){
|
||||
// return AjaxResult.success(inJob);
|
||||
// }else{
|
||||
// //分配货位
|
||||
// HashMap<String, Object> map = new HashMap<>();
|
||||
//
|
||||
// map.put("v_tray_code", trayCode);
|
||||
// mydoJobMapper.allotInJobSpace(map);
|
||||
// if (!"10".equals(map.get("v_result").toString())) {
|
||||
// return AjaxResult.error(map.get("v_resultmsg").toString());
|
||||
// }else{
|
||||
//
|
||||
// }
|
||||
// }
|
||||
|
||||
// MydoJob inJob2 = mydoJobMapper.selectInJobByTrayCode(trayCode);
|
||||
return AjaxResult.success(inJob);
|
||||
|
||||
map.put("v_tray_code", trayCode);
|
||||
mydoJobMapper.allotInJobSpace(map);
|
||||
if (!"10".equals(map.get("v_result").toString())) {
|
||||
return AjaxResult.error(map.get("v_resultmsg").toString());
|
||||
}else{
|
||||
MydoJob inJob2 = mydoJobMapper.selectInJobByTrayCode(trayCode);
|
||||
return AjaxResult.success(JSONUtil.toJsonStr(inJob2));
|
||||
}
|
||||
}
|
||||
}else{
|
||||
return AjaxResult.error("该条码无入库任务,请扫码绑定!");
|
||||
}
|
||||
@@ -197,9 +199,20 @@ public class ToWmsServiceImpl implements IToWmsService {
|
||||
return AjaxResult.error("任务不存在");
|
||||
}
|
||||
MydoJob outJob = outMydoJobs.get(0);
|
||||
//出库作业
|
||||
outJob.setExecutionPhase("2");
|
||||
mydoJobService.updateMydoJob(outJob);
|
||||
break;
|
||||
case "7":
|
||||
//移库作业
|
||||
mydoJobParam.setTaskNo(wmsJobRequest.getTaskNo());
|
||||
List<MydoJob> ykMydoJobs = mydoJobService.selectMydoJobListApi(mydoJobParam);
|
||||
if (ykMydoJobs.isEmpty()) {
|
||||
return AjaxResult.error("任务不存在");
|
||||
}
|
||||
MydoJob ykJob = ykMydoJobs.get(0);
|
||||
mydoJobService.ykCompleted(ykJob);
|
||||
break;
|
||||
|
||||
default:
|
||||
log.error("作业类型错误");
|
||||
@@ -385,5 +398,32 @@ public class ToWmsServiceImpl implements IToWmsService {
|
||||
return AjaxResult.error(erpProduct.getSys_MainId()+"物料不存在");
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult requestEnterByTaskNo(RequestEnter requestEnter) {
|
||||
String taskNo = requestEnter.getTaskNo();
|
||||
String deviceCode = requestEnter.getDeviceCode();
|
||||
MydoJob inJob = mydoJobMapper.selectInJobByTaskNo(taskNo);
|
||||
if(inJob != null && Integer.parseInt(inJob.getInOrOut()) < 20){
|
||||
if(inJob.getCargoSpaceId() != null && !"".equals(inJob.getCargoSpaceId())){
|
||||
return AjaxResult.success(inJob);
|
||||
}else{
|
||||
//分配货位
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
|
||||
map.put("v_tray_code", inJob.getTrayCode());
|
||||
map.put("v_code", deviceCode);
|
||||
mydoJobMapper.allotInJobSpace(map);
|
||||
if (!"10".equals(map.get("v_result").toString())) {
|
||||
return AjaxResult.error(map.get("v_resultmsg").toString());
|
||||
}else{
|
||||
MydoJob inJob2 = mydoJobMapper.selectInJobByTaskNo(taskNo);
|
||||
return AjaxResult.success(inJob2);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
return AjaxResult.error("该条码无入库任务,请扫码绑定!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,10 @@ import com.ruoyi.bas.cargoSpace.domain.BasCargoSpace;
|
||||
import com.ruoyi.bas.cargoSpace.service.IBasCargoSpaceService;
|
||||
import com.ruoyi.in.stockinfinish.domain.InStockinFinish;
|
||||
import com.ruoyi.in.stockinfinish.service.IInStockinFinishService;
|
||||
import com.ruoyi.job.mydojob.domain.MydoJob;
|
||||
import com.ruoyi.job.mydojob.service.IMydoJobService;
|
||||
import com.ruoyi.job.mydojobdetail.domain.MydoJobDetail;
|
||||
import com.ruoyi.job.mydojobdetail.service.IMydoJobDetailService;
|
||||
import com.ruoyi.out.outStockoutFinish.domain.OutStockoutFinish;
|
||||
import com.ruoyi.out.outStockoutFinish.service.IOutStockoutFinishService;
|
||||
import com.ruoyi.stock.stock.domain.BasStock;
|
||||
@@ -33,6 +37,10 @@ public class TwinServiceImpl implements ITwinService {
|
||||
private IInStockinFinishService inStockinFinishService;
|
||||
@Autowired
|
||||
private IOutStockoutFinishService outStockoutFinishService;
|
||||
@Autowired
|
||||
private IMydoJobService mydoJobService;
|
||||
@Autowired
|
||||
private IMydoJobDetailService mydoJobDetailService;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getStockListOverview() {
|
||||
@@ -250,4 +258,62 @@ public class TwinServiceImpl implements ITwinService {
|
||||
result.put("monthOutStock", monthOutStock);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getCargo(String cargoSpaceName) {
|
||||
BasStock basStock = new BasStock();
|
||||
basStock.setCargoSpaceId(cargoSpaceName);
|
||||
List<BasStock> list = basStockService.selectBasStockList(basStock);
|
||||
List<Map<String, String>> dataList = new ArrayList<>();
|
||||
for (BasStock stock : list) {
|
||||
Map<String, String> dataMap = new HashMap<>();
|
||||
dataMap.put("productId", stock.getProductId());
|
||||
dataMap.put("productName", stock.getProductName());
|
||||
dataMap.put("quantity", stock.getQuantity());
|
||||
dataMap.put("trayCode", stock.getTrayCode());
|
||||
dataList.add(dataMap);
|
||||
}
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("data", dataList);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getTaskCargo(String taskNo) {
|
||||
MydoJob mydoJob = new MydoJob();
|
||||
mydoJob.setTaskNo(taskNo);
|
||||
List<MydoJob> jobList = mydoJobService.selectMydoJobList(mydoJob);
|
||||
List<Map<String, String>> dataList = new ArrayList<>();
|
||||
if (jobList != null && !jobList.isEmpty()) {
|
||||
MydoJob job = jobList.get(0);
|
||||
String jobId = job.getJobId();
|
||||
String inOrOutStr = job.getInOrOut();
|
||||
int inOrOut = 0;
|
||||
try {
|
||||
inOrOut = Integer.parseInt(inOrOutStr);
|
||||
} catch (Exception e) {
|
||||
// Ignore parse error
|
||||
}
|
||||
|
||||
List<MydoJobDetail> details = mydoJobDetailService.selectMydoJobDetailListByJobId(jobId);
|
||||
for (MydoJobDetail detail : details) {
|
||||
Map<String, String> dataMap = new HashMap<>();
|
||||
dataMap.put("productId", detail.getProductId());
|
||||
dataMap.put("productName", detail.getProductName());
|
||||
|
||||
String quantity = "0";
|
||||
if (inOrOut < 20) {
|
||||
quantity = detail.getInQuantity();
|
||||
} else {
|
||||
quantity = detail.getOutQuantity();
|
||||
}
|
||||
dataMap.put("quantity", quantity);
|
||||
dataMap.put("trayCode", detail.getTrayCode());
|
||||
dataList.add(dataMap);
|
||||
}
|
||||
}
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("data", dataList);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,6 +71,7 @@ public class BasTraycodeController extends BaseController
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody BasTraycode basTraycode)
|
||||
{
|
||||
|
||||
return toAjax(basTraycodeService.insertBasTraycode(basTraycode));
|
||||
}
|
||||
|
||||
|
||||
@@ -16,16 +16,16 @@ public class BasTraycode extends BaseEntity
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** id */
|
||||
@Excel(name = "${bas.Traycode.id}")
|
||||
// @Excel(name = "${bas.Traycode.id}")
|
||||
private Long id;
|
||||
|
||||
/** 条码类型id */
|
||||
@Excel(name = "${bas.Traycode.formatId}")
|
||||
// @Excel(name = "${bas.Traycode.formatId}")
|
||||
private Long formatId;
|
||||
private String formatName;
|
||||
|
||||
/** 条码 */
|
||||
@Excel(name = "${bas.Traycode.trayCode}")
|
||||
@Excel(name = "条码")
|
||||
private String trayCode;
|
||||
|
||||
/** 备用字段1 */
|
||||
@@ -33,7 +33,7 @@ public class BasTraycode extends BaseEntity
|
||||
private String spare1;
|
||||
|
||||
/** 备用字段2 */
|
||||
// @Excel(name = "${bas.Traycode.spare2}")
|
||||
@Excel(name = "是否可用",dictType = "sys_yes_no")
|
||||
private String spare2;
|
||||
|
||||
/** 备用字段3 */
|
||||
|
||||
@@ -61,4 +61,6 @@ public interface BasTraycodeMapper
|
||||
public int deleteBasTraycodeByIds(Long[] ids);
|
||||
|
||||
void insertBasTraycodeList(List<BasTraycode> list);
|
||||
|
||||
Integer selectBasTrayCodeMax();
|
||||
}
|
||||
|
||||
@@ -61,4 +61,6 @@ public interface IBasTraycodeService
|
||||
public int deleteBasTraycodeById(Long id);
|
||||
|
||||
void insertBasTraycodeList(List<BasTraycode> traycodeList);
|
||||
|
||||
Integer selectBasTrayCodeMax();
|
||||
}
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package com.ruoyi.bas.traycode.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import com.ruoyi.bas.traycode.domain.BasTraycode;
|
||||
import com.ruoyi.bas.traycode.mapper.BasTraycodeMapper;
|
||||
import com.ruoyi.bas.traycode.service.IBasTraycodeService;
|
||||
import com.ruoyi.bas.traycodeformat.domain.BasTraycodeFormat;
|
||||
import com.ruoyi.bas.traycodeformat.service.IBasTraycodeFormatService;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -21,6 +24,8 @@ public class BasTraycodeServiceImpl implements IBasTraycodeService
|
||||
{
|
||||
@Autowired
|
||||
private BasTraycodeMapper basTraycodeMapper;
|
||||
@Autowired
|
||||
private IBasTraycodeFormatService basTraycodeFormatService;
|
||||
|
||||
/**
|
||||
* 查询条码信息
|
||||
@@ -55,8 +60,33 @@ public class BasTraycodeServiceImpl implements IBasTraycodeService
|
||||
@Override
|
||||
public int insertBasTraycode(BasTraycode basTraycode)
|
||||
{
|
||||
try {
|
||||
BasTraycodeFormat basTraycodeFormat = basTraycodeFormatService.selectBasTraycodeFormatById(basTraycode.getFormatId());
|
||||
|
||||
|
||||
int i1 = Integer.parseInt(basTraycode.getSpare1());
|
||||
//如果i<4位数,前面补0
|
||||
String code = "";
|
||||
for (int j = 0; j < i1; j++) {
|
||||
code = String.format("%07d",Convert.toInt( basTraycodeFormat.getSerialRule()) + 1 + j);
|
||||
if(basTraycodeFormat.getMaxNum() < Convert.toLong( code)){
|
||||
throw new RuntimeException("已生成最大值");
|
||||
}
|
||||
String finalCode = basTraycodeFormat.getBarcodeFormat()+code;
|
||||
basTraycode.setTrayCode(finalCode);
|
||||
basTraycode.setSpare1(null);
|
||||
basTraycode.setCreateTime(DateUtils.getNowDate());
|
||||
return basTraycodeMapper.insertBasTraycode(basTraycode);
|
||||
basTraycode.setSpare2("Y");
|
||||
basTraycodeMapper.insertBasTraycode(basTraycode);
|
||||
|
||||
|
||||
}
|
||||
basTraycodeFormat.setSerialRule(Convert.toLong( code).toString());
|
||||
basTraycodeFormatService.updateBasTraycodeFormat(basTraycodeFormat);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,4 +133,9 @@ public class BasTraycodeServiceImpl implements IBasTraycodeService
|
||||
basTraycodeMapper.insertBasTraycodeList(list);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer selectBasTrayCodeMax() {
|
||||
return basTraycodeMapper.selectBasTrayCodeMax();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
package com.ruoyi.bas.traycodeformat.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.ruoyi.bas.traycode.domain.BasTraycode;
|
||||
import com.ruoyi.bas.traycode.service.IBasTraycodeService;
|
||||
import com.ruoyi.bas.traycodeformat.domain.BasTraycodeFormat;
|
||||
import com.ruoyi.bas.traycodeformat.mapper.BasTraycodeFormatMapper;
|
||||
import com.ruoyi.bas.traycodeformat.service.IBasTraycodeFormatService;
|
||||
import com.ruoyi.common.core.text.Convert;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -79,20 +75,7 @@ public class BasTraycodeFormatServiceImpl implements IBasTraycodeFormatService
|
||||
public int updateBasTraycodeFormat(BasTraycodeFormat basTraycodeFormat)
|
||||
{
|
||||
BasTraycodeFormat old = selectBasTraycodeFormatById(basTraycodeFormat.getId());
|
||||
int oldSerialRule = Convert.toInt(old.getSerialRule());
|
||||
int newSerialRule = Convert.toInt(basTraycodeFormat.getSerialRule());
|
||||
|
||||
List<BasTraycode> traycodeList = new ArrayList<>();
|
||||
for (int i = oldSerialRule; i < newSerialRule; i++) {
|
||||
BasTraycode basTraycode = new BasTraycode();
|
||||
basTraycode.setFormatId(basTraycodeFormat.getId());
|
||||
String traycode = old.getBarcodeFormat()+ StrUtil.padPre(Convert.toStr(i),5,'0');
|
||||
basTraycode.setTrayCode(traycode);
|
||||
traycodeList.add(basTraycode);
|
||||
}
|
||||
basTraycodeFormat.setUpdateTime(DateUtils.getNowDate());
|
||||
//插入条码信息
|
||||
basTraycodeService.insertBasTraycodeList(traycodeList);
|
||||
return basTraycodeFormatMapper.updateBasTraycodeFormat(basTraycodeFormat);
|
||||
}
|
||||
|
||||
|
||||
@@ -182,8 +182,8 @@ public class CheckStockinServiceImpl implements ICheckStockinService {
|
||||
CheckStockinDetail checkStockinDetail = detailList.get(i);
|
||||
checkStockinDetail.setStockCheckDetailId(stockCheckId + "-" + (i + 1));
|
||||
checkStockinDetail.setStockCheckId(stockCheckId);
|
||||
BasProduct basProduct = productService.selectBasProductByProductId(checkStockinDetail.getProductId());
|
||||
checkStockinDetail.setProductGuid(basProduct.getProductGuid());
|
||||
// BasProduct basProduct = productService.selectBasProductByProductId(checkStockinDetail.getProductId());
|
||||
// checkStockinDetail.setProductGuid(basProduct.getProductGuid());
|
||||
checkStockinDetail.setStockCheckGuid(checkStockin.getStockGuid());
|
||||
checkStockinDetail.setScanNum("0");
|
||||
checkStockinDetail.setAssignNum("0");
|
||||
@@ -229,7 +229,7 @@ public class CheckStockinServiceImpl implements ICheckStockinService {
|
||||
checkStockinMapper.autoAllot(map);
|
||||
builder.append("行明细:" + checkStockinDetail.getStockCheckDetailId() + ",分配结果:" + map.get("v_resultmsg") + "<br />");
|
||||
}
|
||||
iToWcsService.pushOutMydoJob();
|
||||
//iToWcsService.pushOutMydoJob();
|
||||
|
||||
return AjaxResult.success(builder.toString());
|
||||
|
||||
|
||||
@@ -60,4 +60,6 @@ public interface AgvContainerTaskMapper
|
||||
public int deleteAgvContainerTaskByIds(Long[] ids);
|
||||
|
||||
void insertHistory(Long id);
|
||||
|
||||
void deleteAgvJobByOrder(String order);
|
||||
}
|
||||
|
||||
@@ -60,4 +60,6 @@ public interface IAgvContainerTaskService
|
||||
public int deleteAgvContainerTaskById(Long id);
|
||||
|
||||
void insertHistory(Long id);
|
||||
|
||||
void deleteAgvJobByOrder(String order);
|
||||
}
|
||||
|
||||
@@ -97,4 +97,9 @@ public class AgvContainerTaskServiceImpl implements IAgvContainerTaskService
|
||||
public void insertHistory(Long id) {
|
||||
agvContainerTaskMapper.insertHistory(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAgvJobByOrder(String order) {
|
||||
agvContainerTaskMapper.deleteAgvJobByOrder(order);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,8 +102,54 @@ public class InStockin extends BaseEntity
|
||||
|
||||
private String lotNo;
|
||||
private String materialDesc;
|
||||
private String productId;
|
||||
private String startDate;
|
||||
|
||||
private String companyShortName;
|
||||
private String accountSetNo;
|
||||
private String cargoNo;
|
||||
private String stockinDetailId;
|
||||
|
||||
public String getProductId() {
|
||||
return productId;
|
||||
}
|
||||
|
||||
public void setProductId(String productId) {
|
||||
this.productId = productId;
|
||||
}
|
||||
|
||||
public String getStockinDetailId() {
|
||||
return stockinDetailId;
|
||||
}
|
||||
|
||||
public void setStockinDetailId(String stockinDetailId) {
|
||||
this.stockinDetailId = stockinDetailId;
|
||||
}
|
||||
|
||||
public String getCargoNo() {
|
||||
return cargoNo;
|
||||
}
|
||||
|
||||
public void setCargoNo(String cargoNo) {
|
||||
this.cargoNo = cargoNo;
|
||||
}
|
||||
|
||||
public String getCompanyShortName() {
|
||||
return companyShortName;
|
||||
}
|
||||
|
||||
public void setCompanyShortName(String companyShortName) {
|
||||
this.companyShortName = companyShortName;
|
||||
}
|
||||
|
||||
public String getAccountSetNo() {
|
||||
return accountSetNo;
|
||||
}
|
||||
|
||||
public void setAccountSetNo(String accountSetNo) {
|
||||
this.accountSetNo = accountSetNo;
|
||||
}
|
||||
|
||||
private List<String> typeData;
|
||||
|
||||
public String getStartDate() {
|
||||
|
||||
@@ -66,4 +66,6 @@ public interface InStockinMapper
|
||||
void insertInStockinHistory(InStockin inStockin);
|
||||
|
||||
List<InStockin> selectStockinByDetail(String stockinDetailId);
|
||||
|
||||
List<InStockin> selectInStockinListBill(InStockin param);
|
||||
}
|
||||
|
||||
@@ -73,4 +73,6 @@ public interface IInStockinService
|
||||
public int deleteInStockinByStockinGuid(String stockinGuid);
|
||||
|
||||
public List<InStockin> selectStockinByDetail(String stockinDetailId);
|
||||
|
||||
List<InStockin> selectInStockinListBill(InStockin param);
|
||||
}
|
||||
|
||||
@@ -255,4 +255,9 @@ public class InStockinServiceImpl implements IInStockinService
|
||||
public List<InStockin> selectStockinByDetail(String stockinDetailId) {
|
||||
return inStockinMapper.selectStockinByDetail(stockinDetailId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<InStockin> selectInStockinListBill(InStockin param) {
|
||||
return inStockinMapper.selectInStockinListBill(param);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,6 +95,24 @@ public class InStockinBack extends BaseEntity
|
||||
private String sendTime;
|
||||
|
||||
private String msg;
|
||||
private String companyShortName;
|
||||
private String accountSetNo;
|
||||
|
||||
public String getCompanyShortName() {
|
||||
return companyShortName;
|
||||
}
|
||||
|
||||
public void setCompanyShortName(String companyShortName) {
|
||||
this.companyShortName = companyShortName;
|
||||
}
|
||||
|
||||
public String getAccountSetNo() {
|
||||
return accountSetNo;
|
||||
}
|
||||
|
||||
public void setAccountSetNo(String accountSetNo) {
|
||||
this.accountSetNo = accountSetNo;
|
||||
}
|
||||
|
||||
public String getSendStatus() {
|
||||
return sendStatus;
|
||||
|
||||
@@ -152,6 +152,44 @@ public class InStockinDetailBack extends BaseEntity
|
||||
|
||||
private String msg;
|
||||
|
||||
|
||||
private String sourceLineId;
|
||||
private String barCode;
|
||||
private String isBatchManage;
|
||||
private String oldProjectNo;
|
||||
|
||||
public String getSourceLineId() {
|
||||
return sourceLineId;
|
||||
}
|
||||
|
||||
public void setSourceLineId(String sourceLineId) {
|
||||
this.sourceLineId = sourceLineId;
|
||||
}
|
||||
|
||||
public String getBarCode() {
|
||||
return barCode;
|
||||
}
|
||||
|
||||
public void setBarCode(String barCode) {
|
||||
this.barCode = barCode;
|
||||
}
|
||||
|
||||
public String getIsBatchManage() {
|
||||
return isBatchManage;
|
||||
}
|
||||
|
||||
public void setIsBatchManage(String isBatchManage) {
|
||||
this.isBatchManage = isBatchManage;
|
||||
}
|
||||
|
||||
public String getOldProjectNo() {
|
||||
return oldProjectNo;
|
||||
}
|
||||
|
||||
public void setOldProjectNo(String oldProjectNo) {
|
||||
this.oldProjectNo = oldProjectNo;
|
||||
}
|
||||
|
||||
public String getSendStatus() {
|
||||
return sendStatus;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.List;
|
||||
|
||||
import com.ruoyi.in.stockin.domain.InStockin;
|
||||
import com.ruoyi.in.stockindeatilback.domain.InStockinDetailBack;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 入库单据子信息Mapper接口
|
||||
@@ -61,4 +62,8 @@ public interface InStockinDetailBackMapper
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteInStockinDetailBackByStockinDetailIds(String[] stockinDetailIds);
|
||||
|
||||
void insertInStockInDetailBackFinish(@Param("list") List<InStockinDetailBack> inStockinDetailParam);
|
||||
|
||||
void deleteInStockInDetailList(@Param("idList") List<InStockinDetailBack> inStockinDetails);
|
||||
}
|
||||
|
||||
@@ -58,4 +58,8 @@ public interface IInStockinDetailBackService
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteInStockinDetailBackByStockinDetailId(String stockinDetailId);
|
||||
|
||||
void insertInStockInDetailBackFinish(List<InStockinDetailBack> inStockinDetails);
|
||||
|
||||
void deleteInStockInDetailList(List<InStockinDetailBack> inStockinDetails);
|
||||
}
|
||||
|
||||
@@ -90,4 +90,14 @@ public class InStockinDetailBackServiceImpl implements IInStockinDetailBackServi
|
||||
{
|
||||
return inStockinDetailBackMapper.deleteInStockinDetailBackByStockinDetailId(stockinDetailId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertInStockInDetailBackFinish(List<InStockinDetailBack> inStockinDetails) {
|
||||
inStockinDetailBackMapper.insertInStockInDetailBackFinish(inStockinDetails);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteInStockInDetailList(List<InStockinDetailBack> inStockinDetails) {
|
||||
inStockinDetailBackMapper.deleteInStockInDetailList(inStockinDetails);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,9 +143,13 @@ public class InStockinDetail extends BaseEntity
|
||||
private String status;
|
||||
|
||||
private ExtraField extraField;
|
||||
private String erpBill;
|
||||
|
||||
private String warehouseName;
|
||||
|
||||
private String warehouseId;
|
||||
|
||||
private String sourceLineId;
|
||||
private String barCode;
|
||||
private String isBatchManage;
|
||||
private String oldProjectNo;
|
||||
}
|
||||
|
||||
@@ -69,4 +69,6 @@ public interface InStockinDetailMapper
|
||||
void deleteInStockinDetailByStockinGuid(String stockinGuid);
|
||||
|
||||
InStockinDetail selectStockinByDetailById(InStockinDetail inStockinDetail);
|
||||
|
||||
List<InStockinDetail> selectStockInByDetailByBarCode(String barCode);
|
||||
}
|
||||
|
||||
@@ -81,4 +81,6 @@ public interface IInStockinDetailService
|
||||
|
||||
|
||||
public InStockinDetail selectStockinByDetailById(InStockinDetail inStockinDetail);
|
||||
|
||||
List<InStockinDetail> selectStockInByDetailByBarCode(String barCode);
|
||||
}
|
||||
|
||||
@@ -127,4 +127,9 @@ public class InStockinDetailServiceImpl implements IInStockinDetailService
|
||||
return inStockinDetailMapper.selectStockinByDetailById(inStockinDetail);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<InStockinDetail> selectStockInByDetailByBarCode(String barCode) {
|
||||
return inStockinDetailMapper.selectStockInByDetailByBarCode(barCode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,6 +89,15 @@ public class InStockinFinish extends BaseEntity
|
||||
/** 备用字段5 */
|
||||
@Excel(name = "备用字段5")
|
||||
private String spare5;
|
||||
private String stockinDetailId;
|
||||
|
||||
public String getStockinDetailId() {
|
||||
return stockinDetailId;
|
||||
}
|
||||
|
||||
public void setStockinDetailId(String stockinDetailId) {
|
||||
this.stockinDetailId = stockinDetailId;
|
||||
}
|
||||
|
||||
public void setStockinGuid(String stockinGuid)
|
||||
{
|
||||
|
||||
@@ -102,7 +102,7 @@ public class InStockinFinishServiceImpl implements IInStockinFinishService
|
||||
}
|
||||
|
||||
@Override
|
||||
@DataScope(warehouseAlias = "is2")
|
||||
// @DataScope(warehouseAlias = "is2")
|
||||
public List<InStockin> selectInStockinFinishListByInStockin(InStockin inStockin) {
|
||||
return inStockinFinishMapper.selectInStockinFinishListByInStockin(inStockin);
|
||||
}
|
||||
|
||||
@@ -124,6 +124,9 @@ public class MydoJob extends BaseEntity
|
||||
/** 重分标记 */
|
||||
@Excel(name = "重分标记")
|
||||
private String faultFlag;
|
||||
private String endPoint;
|
||||
|
||||
|
||||
|
||||
private String inOut;
|
||||
|
||||
@@ -133,6 +136,23 @@ public class MydoJob extends BaseEntity
|
||||
private String createRightTime;
|
||||
|
||||
private String productId;
|
||||
private String stockinDetailId;
|
||||
|
||||
public String getEndPoint() {
|
||||
return endPoint;
|
||||
}
|
||||
|
||||
public void setEndPoint(String endPoint) {
|
||||
this.endPoint = endPoint;
|
||||
}
|
||||
|
||||
public String getStockinDetailId() {
|
||||
return stockinDetailId;
|
||||
}
|
||||
|
||||
public void setStockinDetailId(String stockinDetailId) {
|
||||
this.stockinDetailId = stockinDetailId;
|
||||
}
|
||||
|
||||
public String getProductId() {
|
||||
return productId;
|
||||
|
||||
@@ -82,5 +82,14 @@ public interface MydoJobMapper
|
||||
|
||||
MydoJob selectInJobByTrayCode(@Param("trayCode") String trayCode);
|
||||
|
||||
MydoJob selectInJobByTaskNo(@Param("taskNo") String taskNo);
|
||||
|
||||
|
||||
void allotInJobSpace(HashMap<String, Object> map);
|
||||
|
||||
void ykCompleted(HashMap<String, Object> map);
|
||||
|
||||
void updateLed(HashMap<String, Object> map);
|
||||
|
||||
void updateLedError(HashMap<String, Object> map);
|
||||
}
|
||||
|
||||
@@ -109,4 +109,6 @@ public interface IMydoJobService
|
||||
MydoJob selectMydoJobByEntranceId(MydoJob mydoJob);
|
||||
|
||||
List<MydoJob> getInJobBySerial(String serial);
|
||||
|
||||
void ykCompleted(MydoJob outJob);
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ public class MydoJobServiceImpl implements IMydoJobService {
|
||||
List<MydoJobDetail> mydoJobDetails = mydoJobDetailService.selectMydoJobDetailList(param);
|
||||
|
||||
for (MydoJobDetail mydoJobDetail : mydoJobDetails) {
|
||||
String inOrOutDId = mydoJobDetail.getInOrOutDId();
|
||||
String inOrOutDId = mydoJobDetail.getStockinDetailId();
|
||||
InStockinDetail inStockinDetail = inStockinDetailService.selectInStockinDetailByStockinDetailId(inOrOutDId);
|
||||
BigDecimal stockInNum = Convert.toBigDecimal(inStockinDetail.getScanNum());
|
||||
BigDecimal jobInNum = Convert.toBigDecimal(mydoJobDetail.getInQuantity());
|
||||
@@ -506,7 +506,7 @@ public class MydoJobServiceImpl implements IMydoJobService {
|
||||
msg = map.get("v_resultmsg").toString();
|
||||
builder.append("托盘:" + basStock.getTrayCode() + ",分配结果:" + msg + "<br/>");
|
||||
}
|
||||
iToWcsService.pushOutMydoJob();
|
||||
//iToWcsService.pushOutMydoJob();
|
||||
if (!StrUtil.isEmpty(builder)) {
|
||||
return AjaxResult.warn(builder.toString());
|
||||
}
|
||||
@@ -527,4 +527,17 @@ public class MydoJobServiceImpl implements IMydoJobService {
|
||||
public List<MydoJob> getInJobBySerial(String trayCode) {
|
||||
return mydoJobMapper.getInJobBySerial(trayCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ykCompleted(MydoJob outJob) {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("v_job_id", outJob.getJobId());
|
||||
map.put("v_result", null);
|
||||
mydoJobMapper.ykCompleted(map);
|
||||
if (!"10".equals(map.get("v_result").toString())) {
|
||||
log.error("移库任务处理异常 异常代码{}", map.get("v_result"));
|
||||
}else{
|
||||
log.info("移库任务处理成功 jobId:[{}] trayCode:[{}]", outJob.getJobId(), outJob.getTrayCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.ruoyi.job.mydojobdetail.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class PkDetail implements Serializable {
|
||||
private String stockinDetailId;
|
||||
private String quantity;
|
||||
|
||||
|
||||
public String getStockinDetailId() {
|
||||
return stockinDetailId;
|
||||
}
|
||||
|
||||
public void setStockinDetailId(String stockinDetailId) {
|
||||
this.stockinDetailId = stockinDetailId;
|
||||
}
|
||||
|
||||
public String getQuantity() {
|
||||
return quantity;
|
||||
}
|
||||
|
||||
public void setQuantity(String quantity) {
|
||||
this.quantity = quantity;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -85,6 +85,34 @@ public class RequestLogController extends BaseController
|
||||
return toAjax(requestLogService.updateRequestLog(requestLog));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@GetMapping("/getMethod")
|
||||
public AjaxResult getMethod()
|
||||
{
|
||||
List<String> strings=requestLogService.getMethod();
|
||||
return AjaxResult.success(requestLogService.getMethod());
|
||||
}
|
||||
|
||||
// 获取原系统
|
||||
@GetMapping("/getSource")
|
||||
public AjaxResult getSource()
|
||||
{
|
||||
List<String> strings=requestLogService.getSource();
|
||||
return AjaxResult.success(requestLogService.getSource());
|
||||
}
|
||||
// 获取目标系统
|
||||
@GetMapping("/getTarget")
|
||||
public AjaxResult getTarget()
|
||||
{
|
||||
List<String> strings=requestLogService.getTarget();
|
||||
return AjaxResult.success(requestLogService.getTarget());
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 删除接口记录
|
||||
*/
|
||||
|
||||
@@ -59,4 +59,10 @@ public interface RequestLogMapper
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteRequestLogByRequestIds(Long[] requestIds);
|
||||
|
||||
List<String> getMethod();
|
||||
|
||||
List<String> getSource();
|
||||
|
||||
List<String> getTarget();
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@ public interface IRequestLogService
|
||||
* @return
|
||||
*/
|
||||
public RequestLog getRequestLog(String url, String param, String remark,String source,String target);
|
||||
public RequestLog getRequestLog(String url, String param, String remark,String source,String target,String billType,String ciccid);
|
||||
/**
|
||||
* 接收接口记录
|
||||
*
|
||||
@@ -77,4 +78,12 @@ public interface IRequestLogService
|
||||
* @return
|
||||
*/
|
||||
public RequestLog getRequestLog(String param, String remark, AjaxResult ajaxResult);
|
||||
|
||||
public RequestLog getRequestLogERP(String param, String remark, AjaxResult ajaxResult);
|
||||
|
||||
List<String> getMethod();
|
||||
|
||||
List<String> getSource();
|
||||
|
||||
List<String> getTarget();
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.ruoyi.log.service.impl;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateUnit;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.net.URLEncodeUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
@@ -122,8 +124,10 @@ public class RequestLogServiceImpl implements IRequestLogService
|
||||
requestLog.setRequestBody(param);
|
||||
requestLog.setRequestUrl(url);
|
||||
try {
|
||||
String resStr = HttpUtil.post(url, param);
|
||||
// String resStr = HttpRequest.post(url).contentType("application/x-www-from-urlencoded").timeout(2000).body(param).execute().body();
|
||||
|
||||
String resStr = HttpUtil.post(url, param);
|
||||
requestLog.setResponseBody(resStr);
|
||||
// 判断resStr的状态码,如果不是200抛出异常让catch捕获
|
||||
if (!JSONUtil.isJsonObj(resStr)) {
|
||||
throw new RuntimeException("返回结果不是有效的JSON对象");
|
||||
@@ -133,7 +137,6 @@ public class RequestLogServiceImpl implements IRequestLogService
|
||||
if (codeObj == null || !codeObj.toString().equals("200")) {
|
||||
throw new RuntimeException("请求失败,状态码: " + (codeObj != null ? codeObj.toString() : "null"));
|
||||
}
|
||||
requestLog.setResponseBody(resStr);
|
||||
requestLog.setResponseTime(DateUtil.formatDateTime(new Date()));
|
||||
requestLog.setResponseStatus("1");
|
||||
requestLog.setDuration(Convert.toStr(DateUtil.between(Convert.toDate(requestLog.getRequestTime()), Convert.toDate(requestLog.getResponseTime()), DateUnit.MS)));
|
||||
@@ -148,6 +151,53 @@ public class RequestLogServiceImpl implements IRequestLogService
|
||||
return requestLog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RequestLog getRequestLog(String url, String param, String remark, String source, String target, String billType, String ciccid) {
|
||||
String body = "datajson=" + param
|
||||
+ "&ibilltype=" + URLEncodeUtil.encodeAll(billType)
|
||||
+ "&cacc_id=" + URLEncodeUtil.encodeAll(ciccid);
|
||||
|
||||
RequestLog requestLog = new RequestLog();
|
||||
requestLog.setRequestTime(DateUtil.formatDateTime(new Date()));
|
||||
requestLog.setSourceSystem(source);
|
||||
requestLog.setTargetSystem(target);
|
||||
requestLog.setEndpoint(remark);
|
||||
requestLog.setRequestMethod("post");
|
||||
requestLog.setRequestHeaders(null);
|
||||
requestLog.setRequestBody(body);
|
||||
requestLog.setRequestUrl(url);
|
||||
try {
|
||||
String resStr = HttpRequest.post(url)
|
||||
.contentType("application/x-www-form-urlencoded;charset=UTF-8")
|
||||
.body(body)
|
||||
.execute().body();
|
||||
|
||||
requestLog.setResponseBody(resStr);
|
||||
// 判断resStr的状态码,如果不是200抛出异常让catch捕获
|
||||
if (!JSONUtil.isJsonObj(resStr)) {
|
||||
throw new RuntimeException("返回结果不是有效的JSON对象");
|
||||
}
|
||||
cn.hutool.json.JSONObject jsonObject = JSONUtil.parseObj(resStr);
|
||||
Object codeObj = jsonObject.get("ErrCode");
|
||||
if (codeObj == null || !codeObj.toString().equals("0")) {
|
||||
throw new RuntimeException("请求失败,状态码: " + (codeObj != null ? codeObj.toString() : "null"));
|
||||
}
|
||||
requestLog.setResponseTime(DateUtil.formatDateTime(new Date()));
|
||||
requestLog.setResponseStatus("1");
|
||||
requestLog.setDuration(Convert.toStr(DateUtil.between(Convert.toDate(requestLog.getRequestTime()), Convert.toDate(requestLog.getResponseTime()), DateUnit.MS)));
|
||||
requestLog.setIsSuccessful("1");
|
||||
} catch (Exception e) {
|
||||
requestLog.setErrorDetails(e.getMessage());
|
||||
requestLog.setIsSuccessful("0");
|
||||
requestLog.setResponseStatus("0");
|
||||
} finally {
|
||||
insertRequestLog(requestLog);
|
||||
}
|
||||
return requestLog;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 插入请求日志
|
||||
*
|
||||
@@ -173,4 +223,46 @@ public class RequestLogServiceImpl implements IRequestLogService
|
||||
requestLog.setResponseBody(Convert.toStr(ajaxResult.get("msg")));
|
||||
return requestLog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RequestLog getRequestLogERP(String param, String remark, AjaxResult ajaxResult) {
|
||||
RequestLog requestLog = new RequestLog();
|
||||
requestLog.setRequestTime(DateUtil.formatDateTime(new Date()));
|
||||
requestLog.setRequestBody(param);
|
||||
requestLog.setSourceSystem("erp");
|
||||
requestLog.setTargetSystem("wms");
|
||||
requestLog.setEndpoint(remark);
|
||||
requestLog.setRequestMethod("post");
|
||||
requestLog.setResponseTime(DateUtil.formatDateTime(new Date()));
|
||||
requestLog.setDuration(Convert.toStr(DateUtil.between(Convert.toDate(requestLog.getRequestTime()), Convert.toDate(requestLog.getResponseTime()), DateUnit.MS)));
|
||||
requestLog.setResponseStatus("1");
|
||||
if (ajaxResult.isSuccess()){
|
||||
requestLog.setIsSuccessful("1");
|
||||
}else {
|
||||
requestLog.setIsSuccessful("0");
|
||||
}
|
||||
requestLog.setResponseBody(Convert.toStr(ajaxResult.get("msg")));
|
||||
return requestLog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getMethod() {
|
||||
|
||||
return requestLogMapper.getMethod();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSource() {
|
||||
return requestLogMapper.getSource();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTarget() {
|
||||
return requestLogMapper.getTarget();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String aa = "{\"code\":\"200,\"success\":true,\"msg\":\"请求成功\"}";
|
||||
System.out.println(JSONUtil.isJsonObj(aa));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,9 @@ public class ViewHandAllotStockController extends BaseController
|
||||
public TableDataInfo list(ViewHandAllotStock viewHandAllotStock)
|
||||
{
|
||||
startPage();
|
||||
if (viewHandAllotStock.getWarehouseCode()==null||viewHandAllotStock.getWarehouseCode().equals("")){
|
||||
viewHandAllotStock.setWarehouseCode("1");
|
||||
}
|
||||
List<ViewHandAllotStock> list = viewHandAllotStockService.selectViewHandAllotStockList(viewHandAllotStock);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import org.springframework.data.annotation.Transient;
|
||||
|
||||
/**
|
||||
* 手动分配库存对象 view_hand_allot_stock
|
||||
@@ -187,6 +188,37 @@ public class ViewHandAllotStock extends BaseEntity
|
||||
@Excel(name = "货位锁")
|
||||
private String locked;
|
||||
|
||||
@Transient
|
||||
private String ktpType;
|
||||
@Transient
|
||||
private String productType;
|
||||
@Transient
|
||||
private String warehouseCode;
|
||||
|
||||
public String getWarehouseCode() {
|
||||
return warehouseCode;
|
||||
}
|
||||
|
||||
public void setWarehouseCode(String warehouseCode) {
|
||||
this.warehouseCode = warehouseCode;
|
||||
}
|
||||
|
||||
public String getKtpType() {
|
||||
return ktpType;
|
||||
}
|
||||
|
||||
public void setKtpType(String ktpType) {
|
||||
this.ktpType = ktpType;
|
||||
}
|
||||
|
||||
public String getProductType() {
|
||||
return productType;
|
||||
}
|
||||
|
||||
public void setProductType(String productType) {
|
||||
this.productType = productType;
|
||||
}
|
||||
|
||||
public void setStockId(String stockId)
|
||||
{
|
||||
this.stockId = stockId;
|
||||
|
||||
@@ -35,7 +35,7 @@ public class OutStockoutController extends BaseController {
|
||||
/**
|
||||
* 查询出库主单列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('out:outStockout:list')")
|
||||
// @PreAuthorize("@ss.hasPermi('out:outStockout:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(OutStockout outStockout) {
|
||||
startPage();
|
||||
@@ -51,7 +51,7 @@ public class OutStockoutController extends BaseController {
|
||||
/**
|
||||
* 导出出库主单列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('out:outStockout:export')")
|
||||
// @PreAuthorize("@ss.hasPermi('out:outStockout:export')")
|
||||
@Log(title = "出库主单", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, OutStockout outStockout) {
|
||||
@@ -63,7 +63,7 @@ public class OutStockoutController extends BaseController {
|
||||
/**
|
||||
* 获取出库主单详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('out:outStockout:query')")
|
||||
// @PreAuthorize("@ss.hasPermi('out:outStockout:query')")
|
||||
@GetMapping(value = "/{stockoutGuid}")
|
||||
public AjaxResult getInfo(@PathVariable("stockoutGuid") String stockoutGuid) {
|
||||
return success(outStockoutService.selectOutStockoutByStockoutGuid(stockoutGuid));
|
||||
@@ -72,7 +72,7 @@ public class OutStockoutController extends BaseController {
|
||||
/**
|
||||
* 新增出库主单
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('out:outStockout:add')")
|
||||
// @PreAuthorize("@ss.hasPermi('out:outStockout:add')")
|
||||
@Log(title = "出库主单", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody OutStockout outStockout) {
|
||||
@@ -82,7 +82,7 @@ public class OutStockoutController extends BaseController {
|
||||
/**
|
||||
* 修改出库主单
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('out:outStockout:edit')")
|
||||
// @PreAuthorize("@ss.hasPermi('out:outStockout:edit')")
|
||||
@Log(title = "出库主单", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody OutStockout outStockout) {
|
||||
@@ -92,7 +92,7 @@ public class OutStockoutController extends BaseController {
|
||||
/**
|
||||
* 删除出库主单
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('out:outStockout:remove')")
|
||||
// @PreAuthorize("@ss.hasPermi('out:outStockout:remove')")
|
||||
@Log(title = "出库主单", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{stockoutGuids}")
|
||||
public AjaxResult remove(@PathVariable String[] stockoutGuids) {
|
||||
@@ -107,7 +107,7 @@ public class OutStockoutController extends BaseController {
|
||||
*/
|
||||
@Log(title = "出库主单保存", businessType = BusinessType.OTHER)
|
||||
@PostMapping("/saveBill")
|
||||
@PreAuthorize("@ss.hasPermi('out:outStockout:saveBill')")
|
||||
// @PreAuthorize("@ss.hasPermi('out:outStockout:saveBill')")
|
||||
@ResponseBody
|
||||
public AjaxResult saveBill(@RequestBody OutStockoutVo outStockoutVo) {
|
||||
String stockOutId = outStockoutService.saveBill(outStockoutVo);
|
||||
@@ -117,7 +117,7 @@ public class OutStockoutController extends BaseController {
|
||||
/**
|
||||
* 出库单据状态改变
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('out:outStockout:changeStatus')")
|
||||
// @PreAuthorize("@ss.hasPermi('out:outStockout:changeStatus')")
|
||||
@Log(title = "出库主单状态改变", businessType = BusinessType.OTHER)
|
||||
@RequestMapping("/changeStatus")
|
||||
@ResponseBody
|
||||
@@ -132,17 +132,24 @@ public class OutStockoutController extends BaseController {
|
||||
* @param stockoutId
|
||||
* @return
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('out:outStockout:autoAllot')")
|
||||
// @PreAuthorize("@ss.hasPermi('out:outStockout:autoAllot')")
|
||||
@Log(title = "出库单自动分配", businessType = BusinessType.OTHER)
|
||||
@GetMapping("/autoAllot")
|
||||
public AjaxResult autoAllot(@RequestParam("stockoutId") String stockoutId) {
|
||||
// 修改出库方向
|
||||
// OutStockout outStockout = new OutStockout();
|
||||
// outStockout.setStockoutId(stockoutId);
|
||||
// outStockout.setSpare8(spare8);
|
||||
// outStockoutService.updateOutStockout(outStockout);
|
||||
System.out.println(stockoutId);
|
||||
// System.out.println(spare8);
|
||||
return outStockoutService.autoAllot(stockoutId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 手动分配
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('out:outStockout:manualAllot')")
|
||||
// @PreAuthorize("@ss.hasPermi('out:outStockout:manualAllot')")
|
||||
@Log(title = "出库单手动分配", businessType = BusinessType.OTHER)
|
||||
@GetMapping("/manualAllot")
|
||||
public AjaxResult manualAllot(@RequestParam("stockList") String[] stockList, @RequestParam("stockoutDetailId") String stockoutDetailId) {
|
||||
|
||||
@@ -91,6 +91,9 @@ public class OutStockout extends BaseEntity
|
||||
private String spare4;
|
||||
|
||||
private String spare5;
|
||||
private String spare6;
|
||||
private String spare7;
|
||||
private String spare8;
|
||||
|
||||
private String customerName;
|
||||
|
||||
@@ -99,9 +102,51 @@ public class OutStockout extends BaseEntity
|
||||
private String productId;
|
||||
|
||||
private String productName;
|
||||
private String companyShortName;
|
||||
private String accountSetNo;
|
||||
|
||||
public String getCompanyShortName() {
|
||||
return companyShortName;
|
||||
}
|
||||
|
||||
public void setCompanyShortName(String companyShortName) {
|
||||
this.companyShortName = companyShortName;
|
||||
}
|
||||
|
||||
public String getAccountSetNo() {
|
||||
return accountSetNo;
|
||||
}
|
||||
|
||||
public void setAccountSetNo(String accountSetNo) {
|
||||
this.accountSetNo = accountSetNo;
|
||||
}
|
||||
|
||||
private List<String> typeData;
|
||||
|
||||
public String getSpare6() {
|
||||
return spare6;
|
||||
}
|
||||
|
||||
public void setSpare6(String spare6) {
|
||||
this.spare6 = spare6;
|
||||
}
|
||||
|
||||
public String getSpare7() {
|
||||
return spare7;
|
||||
}
|
||||
|
||||
public void setSpare7(String spare7) {
|
||||
this.spare7 = spare7;
|
||||
}
|
||||
|
||||
public String getSpare8() {
|
||||
return spare8;
|
||||
}
|
||||
|
||||
public void setSpare8(String spare8) {
|
||||
this.spare8 = spare8;
|
||||
}
|
||||
|
||||
public List<String> getTypeData() {
|
||||
return typeData;
|
||||
}
|
||||
|
||||
@@ -68,4 +68,6 @@ public interface OutStockoutMapper
|
||||
OutStockout selectOutStockoutByStockoutId(String stockoutId);
|
||||
|
||||
void manualAllot(HashMap<String, String> map);
|
||||
|
||||
void updateOutStockouts(OutStockout mainOut);
|
||||
}
|
||||
|
||||
@@ -73,4 +73,6 @@ public interface IOutStockoutService
|
||||
List<OutStockout> selectOutStockoutListApi(OutStockout outStockoutParam);
|
||||
|
||||
AjaxResult manualAllot(String[] stockList,String stockoutDetailId);
|
||||
|
||||
void updateOutStockouts(OutStockout mainOut);
|
||||
}
|
||||
|
||||
@@ -180,10 +180,11 @@ public class OutStockoutServiceImpl implements IOutStockoutService
|
||||
for (OutStockoutDetail detail : outStockoutDetails) {
|
||||
if (detail.getAllotQuantity().compareTo(detail.getQuantity()) < 0){
|
||||
map.put("v_stockout_detail_id", detail.getStockoutDetailId());
|
||||
map.put("v_result", null);
|
||||
map.put("v_resultmsg", null);
|
||||
outStockoutMapper.autoAllot(map);
|
||||
toWcsService.pushOutMydoJob();
|
||||
if (!"10".equals(map.get("v_result"))){
|
||||
stringBuilder.append(",").append(detail.getStockoutDetailId()+map.get("v_resultString"));
|
||||
stringBuilder.append(",").append(detail.getStockoutDetailId()+map.get("v_resultmsg"));
|
||||
}
|
||||
}else{
|
||||
stringBuilder.append(",").append(detail.getStockoutDetailId()+"单据已分配完成");
|
||||
@@ -209,7 +210,7 @@ public class OutStockoutServiceImpl implements IOutStockoutService
|
||||
map.put("v_stockout_detail_id", stockoutDetailId);
|
||||
map.put("v_stock_id", stock);
|
||||
outStockoutMapper.manualAllot(map);
|
||||
toWcsService.pushOutMydoJob();
|
||||
//toWcsService.pushOutMydoJob();
|
||||
if (!"10".equals(map.get("v_result"))){
|
||||
stringBuilder.append(",").append(stockoutDetailId+map.get("v_resultString"));
|
||||
}
|
||||
@@ -219,4 +220,9 @@ public class OutStockoutServiceImpl implements IOutStockoutService
|
||||
}
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateOutStockouts(OutStockout mainOut) {
|
||||
outStockoutMapper.updateOutStockouts(mainOut);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class OutStockoutDetail extends BaseEntity
|
||||
|
||||
/** 计划数量(箱) */
|
||||
@Excel(name = "计划数量", readConverterExp = "箱=")
|
||||
private BigDecimal quantityX;
|
||||
private String quantityX;
|
||||
|
||||
/** 计划数量(件) */
|
||||
@Excel(name = "计划数量", readConverterExp = "件=")
|
||||
@@ -200,6 +200,42 @@ public class OutStockoutDetail extends BaseEntity
|
||||
|
||||
private String spare9;
|
||||
|
||||
private String sourceLineId;
|
||||
private String barCode;
|
||||
private String isBatchManage;
|
||||
private String oldProjectNo;
|
||||
|
||||
public String getSourceLineId() {
|
||||
return sourceLineId;
|
||||
}
|
||||
|
||||
public void setSourceLineId(String sourceLineId) {
|
||||
this.sourceLineId = sourceLineId;
|
||||
}
|
||||
|
||||
public String getBarCode() {
|
||||
return barCode;
|
||||
}
|
||||
|
||||
public void setBarCode(String barCode) {
|
||||
this.barCode = barCode;
|
||||
}
|
||||
|
||||
public String getIsBatchManage() {
|
||||
return isBatchManage;
|
||||
}
|
||||
|
||||
public void setIsBatchManage(String isBatchManage) {
|
||||
this.isBatchManage = isBatchManage;
|
||||
}
|
||||
|
||||
public String getOldProjectNo() {
|
||||
return oldProjectNo;
|
||||
}
|
||||
|
||||
public void setOldProjectNo(String oldProjectNo) {
|
||||
this.oldProjectNo = oldProjectNo;
|
||||
}
|
||||
|
||||
public String getSpare1() {
|
||||
return spare1;
|
||||
@@ -407,14 +443,12 @@ public class OutStockoutDetail extends BaseEntity
|
||||
return quantity;
|
||||
}
|
||||
|
||||
public void setQuantityX(BigDecimal quantityX)
|
||||
{
|
||||
this.quantityX = quantityX;
|
||||
public String getQuantityX() {
|
||||
return quantityX;
|
||||
}
|
||||
|
||||
public BigDecimal getQuantityX()
|
||||
{
|
||||
return quantityX;
|
||||
public void setQuantityX(String quantityX) {
|
||||
this.quantityX = quantityX;
|
||||
}
|
||||
|
||||
public void setQuantityJ(BigDecimal quantityJ)
|
||||
|
||||
@@ -35,7 +35,7 @@ public class ViewProductAndStockController extends BaseController
|
||||
private IViewProductAndStockService viewProductAndStockService;
|
||||
|
||||
/**
|
||||
* 查询库存物资列表
|
||||
// * 查询库存物资列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('productAndStock:productAndStock:list')")
|
||||
@GetMapping("/list")
|
||||
|
||||
@@ -2,26 +2,42 @@ package com.ruoyi.pda.controller;
|
||||
|
||||
import com.ruoyi.api.domain.RequestEnter;
|
||||
import com.ruoyi.api.domain.WcsPort;
|
||||
import com.ruoyi.bas.agvPoint.domain.AgvPoint;
|
||||
import com.ruoyi.bas.agvPoint.domain.AgvTask;
|
||||
import com.ruoyi.bas.agvPoint.service.impl.AgvPointServiceImpl;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.device.agv.domain.AgvContainerTask;
|
||||
import com.ruoyi.device.agv.service.IAgvContainerTaskService;
|
||||
import com.ruoyi.in.stockindetail.domain.InStockinDetail;
|
||||
import com.ruoyi.in.stockindetail.service.IInStockinDetailService;
|
||||
import com.ruoyi.job.mydojob.domain.MydoJob;
|
||||
import com.ruoyi.job.mydojob.service.IMydoJobService;
|
||||
import com.ruoyi.job.mydojobdetail.domain.MydoJobDetail;
|
||||
import com.ruoyi.out.outStockout.domain.OutStockout;
|
||||
import com.ruoyi.out.outStockout.service.impl.OutStockoutServiceImpl;
|
||||
import com.ruoyi.out.outStockoutDetail.domain.OutStockoutDetail;
|
||||
import com.ruoyi.out.outStockoutDetail.service.impl.OutStockoutDetailServiceImpl;
|
||||
import com.ruoyi.pda.domain.TrayCodeMakeSure;
|
||||
import com.ruoyi.pda.domain.TrayCodeMsg;
|
||||
import com.ruoyi.pda.mapper.PdaMapper;
|
||||
import com.ruoyi.pda.service.PdaService;
|
||||
import com.ruoyi.stock.stock.domain.BasStock;
|
||||
import com.ruoyi.stock.stock.service.IBasStockService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/pda")
|
||||
@@ -32,6 +48,20 @@ public class PdaController extends BaseController {
|
||||
private PdaService pdaService;
|
||||
@Autowired
|
||||
private IInStockinDetailService iInStockinDetailService;
|
||||
@Autowired
|
||||
private OutStockoutServiceImpl outStockoutService;
|
||||
@Autowired
|
||||
private OutStockoutDetailServiceImpl outStockoutDetailService;
|
||||
@Autowired
|
||||
private AgvPointServiceImpl agvPointService;
|
||||
@Autowired
|
||||
private IAgvContainerTaskService agvContainerTaskService;
|
||||
@Autowired
|
||||
private PdaMapper pdaMapper;
|
||||
@Autowired
|
||||
private IMydoJobService mydoJobService;
|
||||
@Autowired
|
||||
private IBasStockService basStockService;
|
||||
|
||||
/**
|
||||
* 查询是否有半满托盘
|
||||
@@ -46,11 +76,11 @@ public class PdaController extends BaseController {
|
||||
/**
|
||||
* 通过单据码查询物料详情
|
||||
*/
|
||||
@RequestMapping("/selectDetailById")
|
||||
@RequestMapping("/selectDetailByIds")
|
||||
@ResponseBody
|
||||
public AjaxResult selectDetailById(String inStockinDetailId) {
|
||||
public AjaxResult selectDetailByIds(String inStockinDetailId) {
|
||||
InStockinDetail inStockinDetail = iInStockinDetailService.selectInStockinDetailByStockinDetailId(inStockinDetailId);
|
||||
if(inStockinDetail != null) {
|
||||
if (inStockinDetail != null) {
|
||||
inStockinDetail.setQuantity(String.valueOf(Integer.valueOf(inStockinDetail.getQuantity()) - Integer.valueOf(inStockinDetail.getScanNum())));
|
||||
}
|
||||
return AjaxResult.success(inStockinDetail);
|
||||
@@ -67,6 +97,22 @@ public class PdaController extends BaseController {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过单据码查询物料详情 TODO 修改单据码为barCode 前端需同步修改
|
||||
*/
|
||||
@RequestMapping("/selectDetailById")
|
||||
@ResponseBody
|
||||
public AjaxResult selectDetailById(String barCode) {
|
||||
List<InStockinDetail> stockinDetails = iInStockinDetailService.selectStockInByDetailByBarCode(barCode);
|
||||
stockinDetails.stream().forEach(inStockinDetail -> {
|
||||
Integer quantity = StringUtils.hasText(inStockinDetail.getQuantity()) ? Integer.valueOf(inStockinDetail.getQuantity()) : 0;
|
||||
Integer scanNum = StringUtils.hasText(inStockinDetail.getScanNum()) ? Integer.valueOf(inStockinDetail.getScanNum()) : 0;
|
||||
inStockinDetail.setQuantity(String.valueOf(quantity - scanNum));
|
||||
});
|
||||
return AjaxResult.success(stockinDetails);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过托盘码查询作业或trayMsg
|
||||
*/
|
||||
@@ -85,13 +131,20 @@ public class PdaController extends BaseController {
|
||||
return pdaService.bindTray(trayCodeMakeSure);
|
||||
}
|
||||
|
||||
@RequestMapping("/bindTray2")
|
||||
@ResponseBody
|
||||
public AjaxResult bindTray2(@RequestBody TrayCodeMakeSure trayCodeMakeSure) {
|
||||
return pdaService.bindTray2(trayCodeMakeSure);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 空托盘入库
|
||||
*/
|
||||
@RequestMapping("/tpIn")
|
||||
@ResponseBody
|
||||
public AjaxResult tpIn(@RequestBody TrayCodeMsg trayCodeMsg) {
|
||||
return pdaService.tpIn(trayCodeMsg.getTrayCode());
|
||||
return pdaService.tpIn(trayCodeMsg);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -105,12 +158,13 @@ public class PdaController extends BaseController {
|
||||
|
||||
/**
|
||||
* 出库确认查询子作业信息
|
||||
*
|
||||
* @param trayCodeMsg
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/selectJobDetailByTray")
|
||||
@ResponseBody
|
||||
public AjaxResult selectJobDetailByTray(@RequestBody TrayCodeMsg trayCodeMsg){
|
||||
public AjaxResult selectJobDetailByTray(@RequestBody TrayCodeMsg trayCodeMsg) {
|
||||
return pdaService.selectJobDetailByTray(trayCodeMsg);
|
||||
}
|
||||
|
||||
@@ -129,9 +183,6 @@ public class PdaController extends BaseController {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 入库扫码生成作业
|
||||
*/
|
||||
@@ -142,7 +193,6 @@ public class PdaController extends BaseController {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@RequestMapping("/selectDetailByPDTray")
|
||||
@ResponseBody
|
||||
public AjaxResult selectDetailByPDTray(@RequestBody TrayCodeMakeSure trayCodeMakeSure) {
|
||||
@@ -150,9 +200,6 @@ public class PdaController extends BaseController {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 盘点出库确认
|
||||
*
|
||||
@@ -161,7 +208,7 @@ public class PdaController extends BaseController {
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('pda:check:checkMakeSure')")
|
||||
@PostMapping("/checkMakeSure")
|
||||
@Log(title = "手持机盘点出库确认", businessType = BusinessType.INSERT)
|
||||
@Log(title = "手持机盘点出库确认", businessType = BusinessType.OTHER)
|
||||
@ResponseBody
|
||||
public AjaxResult checkMakeSure(@RequestBody TrayCodeMakeSure trayCodeMakeSure) {
|
||||
return pdaService.checkMakeSure(trayCodeMakeSure);
|
||||
@@ -179,6 +226,245 @@ public class PdaController extends BaseController {
|
||||
return pdaService.updateWcsPort(wcsPort);
|
||||
}
|
||||
|
||||
@RequestMapping("/hcoutMakesure")
|
||||
@ResponseBody
|
||||
@Log(title = "手持机缓存出库确认", businessType = BusinessType.OTHER)
|
||||
public AjaxResult hcoutMakesure(String trayCode) {
|
||||
|
||||
return pdaService.hcoutMakesure(trayCode);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 平库入库
|
||||
*/
|
||||
@RequestMapping("/inStockPk")
|
||||
@ResponseBody
|
||||
public AjaxResult inStockPk(@RequestBody TrayCodeMakeSure trayCodeMakeSure) {
|
||||
return pdaService.completeInPk(trayCodeMakeSure);
|
||||
}
|
||||
|
||||
/**
|
||||
* 库存查询(平库扫码查询托盘入库信息)
|
||||
*/
|
||||
@RequestMapping("/searchStock")
|
||||
@ResponseBody
|
||||
public AjaxResult searchStock(@RequestBody TrayCodeMakeSure trayCodeMakeSure) {
|
||||
|
||||
return pdaService.selectBasStockHc(trayCodeMakeSure.getTrayCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* 立库出库信息校验
|
||||
*
|
||||
* @param trayCodeMakeSure
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/verifyMaterial")
|
||||
@ResponseBody
|
||||
public AjaxResult verifyMaterial(@RequestBody TrayCodeMakeSure trayCodeMakeSure) {
|
||||
String trayCode = trayCodeMakeSure.getTrayCode();
|
||||
List<MydoJobDetail> mydoJobDetailList = trayCodeMakeSure.getMydoJobDetailList();
|
||||
for (MydoJobDetail m : mydoJobDetailList) {
|
||||
Integer count = pdaService.selectByTrayCodeAndProduct(trayCode, m.getProductId());
|
||||
if (count == 0) {
|
||||
return AjaxResult.error(m.getProductId() + ",物料不是出库物料");
|
||||
}
|
||||
}
|
||||
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 平库出库确认
|
||||
*
|
||||
* @param trayCodeMakeSure
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/completeOutPk")
|
||||
@ResponseBody
|
||||
@Async
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult completeOutPk(@RequestBody TrayCodeMakeSure trayCodeMakeSure) {
|
||||
try {
|
||||
String trayCode = trayCodeMakeSure.getTrayCode();
|
||||
List<MydoJobDetail> mydoJobDetailList = trayCodeMakeSure.getMydoJobDetailList();
|
||||
for (MydoJobDetail m : mydoJobDetailList) {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("v_tray_code", trayCode);
|
||||
map.put("v_out_stockout_detail_id", trayCodeMakeSure.getStockoutDetailId());
|
||||
map.put("v_quantity", m.getOutQuantity());
|
||||
map.put("v_stock_id", m.getStockId());
|
||||
pdaService.completeOutPk(map);
|
||||
Integer vResult = (Integer) map.get("v_result");
|
||||
if (vResult != 10) {
|
||||
System.err.println(map.get("v_result_msg").toString());
|
||||
return AjaxResult.error(map.get("v_result_msg").toString());
|
||||
}
|
||||
}
|
||||
return AjaxResult.success();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询平库出库主单 建议参数(erpStockOutId U8单据号作为查询条件传到后台)
|
||||
*
|
||||
* @param outStockout
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/OutFillPk")
|
||||
@ResponseBody
|
||||
|
||||
public AjaxResult OutFillPk() {
|
||||
OutStockout outStockout = new OutStockout();
|
||||
outStockout.setWarehouseId("2");
|
||||
outStockoutService.selectOutStockoutList(outStockout);
|
||||
return AjaxResult.success(outStockoutService.selectOutStockoutList(outStockout));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查出平库出库子单 参数: stockoutId 作为参数传递到后台
|
||||
*
|
||||
* @param outStockout
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/OutFillPkDetail")
|
||||
@ResponseBody
|
||||
public AjaxResult OutFillPkDetail(@RequestBody OutStockout outStockout) {
|
||||
|
||||
List<OutStockout> outStockouts = outStockoutService.selectOutStockoutList(outStockout);
|
||||
|
||||
return AjaxResult.success(outStockoutDetailService.selectOutStockoutDetailByStockoutGuid(outStockouts.get(0).getStockoutGuid()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询平库出库子单对应信息 在平库中是否存在
|
||||
* 参数:trayCode 托盘码
|
||||
* 参数:stockinDetailId 子单据号
|
||||
*
|
||||
* @param trayCodeMsg
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/queryBasStockHc")
|
||||
@ResponseBody
|
||||
public AjaxResult queryBasStockHc(@RequestBody TrayCodeMsg trayCodeMsg) {
|
||||
return pdaService.selectBasStockHcs(trayCodeMsg.getTrayCode(), trayCodeMsg.getStockoutDetailId());
|
||||
}
|
||||
|
||||
// 立库扫码规则校验
|
||||
@RequestMapping("/validateMaterial")
|
||||
@ResponseBody
|
||||
public AjaxResult validateMaterial(@RequestBody TrayCodeMakeSure trayCodeMakeSure) {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("v_tray_code", trayCodeMakeSure.getTrayCode());
|
||||
map.put("v_stockin_detail_id", trayCodeMakeSure.getInStockinDetailId());
|
||||
map.put("v_is_bound_accord", trayCodeMakeSure.getIsBoundByAccord());
|
||||
map.put("v_quantity", trayCodeMakeSure.getQuantity());
|
||||
pdaMapper.bindTray(map);
|
||||
if (!"10".equals(map.get("v_result").toString())) {
|
||||
return AjaxResult.error(map.get("v_result").toString());
|
||||
} else {
|
||||
return AjaxResult.success(map.get("v_result").toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 平库出库信息校验
|
||||
*
|
||||
* @param trayCodeMakeSure TODO 要校验项目号,批号,以及其他条件,要复合查询,待修改
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/verifypkTrayMaterials")
|
||||
@ResponseBody
|
||||
public AjaxResult verifypkTrayMaterials(@RequestBody TrayCodeMakeSure trayCodeMakeSure) {
|
||||
String trayCode = trayCodeMakeSure.getTrayCode();
|
||||
List<MydoJobDetail> mydoJobDetailList = trayCodeMakeSure.getMydoJobDetailList();
|
||||
for (MydoJobDetail m : mydoJobDetailList) {
|
||||
String productId = m.getProductId();
|
||||
Integer integer = pdaService.selectBasStockHcCount(trayCode, productId);
|
||||
if (integer == 0) {
|
||||
return AjaxResult.error(m.getProductId() + ",物料不是出库物料");
|
||||
}
|
||||
}
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
||||
// 查询AGV的起点和终点
|
||||
@RequestMapping("/selectAgvPointByType")
|
||||
@ResponseBody
|
||||
public AjaxResult selectAgvPointByType(String type) {
|
||||
AgvPoint agvPoint = new AgvPoint();
|
||||
agvPoint.setType(type);
|
||||
List<AgvPoint> agvPoints = agvPointService.selectAgvPointList(agvPoint);
|
||||
return AjaxResult.success(agvPoints);
|
||||
}
|
||||
|
||||
// 保存agv执行队列
|
||||
@RequestMapping("/insertAgvJob")
|
||||
@ResponseBody
|
||||
public AjaxResult insertAgvJob(@RequestBody AgvTask agvTask) {
|
||||
AgvPoint agvPoint = new AgvPoint();
|
||||
agvPoint.setStation(agvTask.getEndPoint());
|
||||
List<AgvPoint> agvPoints = agvPointService.selectAgvPointList(agvPoint);
|
||||
if (!agvPoints.get(0).getStation().equals("K1-1") && !agvPoints.get(0).getStation().equals("K2-1") && agvPoints.get(0).getSpare1().equals("2")) {
|
||||
return AjaxResult.error("该点位被占用,请检查!");
|
||||
}
|
||||
AgvContainerTask agvContainerTask = new AgvContainerTask();
|
||||
agvContainerTask.setContainer(UUID.randomUUID().toString());
|
||||
agvContainerTask.setEndPoint(agvTask.getEndPoint());
|
||||
agvContainerTask.setStartPoint(agvTask.getStartPoint());
|
||||
agvContainerTask.setSpare1(agvTask.getType());
|
||||
agvContainerTask.setSpare2(agvTask.getTrayCode());
|
||||
agvContainerTask.setStatus("0");
|
||||
agvContainerTaskService.insertAgvContainerTask(agvContainerTask);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
||||
// 保存agv执行队列
|
||||
@GetMapping("/selectAgvPointByType")
|
||||
@ResponseBody
|
||||
public AjaxResult selectAgvPointByType(String type, String position) {
|
||||
System.out.println(type + " " + position);
|
||||
AgvPoint agvPoint = new AgvPoint();
|
||||
// agvPoint.setType(type);
|
||||
agvPoint.setStation(position);
|
||||
List<AgvPoint> agvPoints = agvPointService.selectAgvPointList(agvPoint);
|
||||
|
||||
|
||||
return AjaxResult.success(agvPoints);
|
||||
}
|
||||
|
||||
|
||||
// // 查询子单据的明细信息
|
||||
// @RequestMapping("/selectDetailById")
|
||||
// public AjaxResult selectDetailById(@RequestBody TrayCodeMakeSure trayCodeMakeSure) {
|
||||
// String inStockinDetailId = trayCodeMakeSure.getInStockinDetailId();
|
||||
// InStockinDetail inStockinDetail = iInStockinDetailService.selectInStockinDetailByStockinDetailId(inStockinDetailId);
|
||||
// return AjaxResult.success(inStockinDetail);
|
||||
//
|
||||
// }
|
||||
|
||||
@RequestMapping("/selectByTrayCode")
|
||||
public AjaxResult selectByTrayCode(@RequestBody TrayCodeMakeSure trayCodeMakeSure) {
|
||||
MydoJob mydoJob = mydoJobService.selectMydoJobByTrayCode(trayCodeMakeSure.getTrayCode());
|
||||
if (mydoJob != null && mydoJob.getInOrOut().equals("26")) {
|
||||
BasStock basStock = basStockService.selectBasStockListTopOne(trayCodeMakeSure.getTrayCode());
|
||||
return AjaxResult.success(basStock);
|
||||
} else {
|
||||
return AjaxResult.error("该托盘无盘任务");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.ruoyi.pda.domain;
|
||||
|
||||
import com.ruoyi.job.mydojobdetail.domain.MydoJobDetail;
|
||||
import com.ruoyi.job.mydojobdetail.domain.PkDetail;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -22,10 +23,18 @@ public class TrayCodeMakeSure {
|
||||
|
||||
private String exitId;
|
||||
private String isFull;
|
||||
// 选中传1 没选中传0
|
||||
private String isBoundByAccord;
|
||||
//拣选详情列表
|
||||
private List<MydoJobDetail> mydoJobDetailList;
|
||||
//盘点详情列表
|
||||
private List<MydoJobDetail> materials;
|
||||
//异常详情列表
|
||||
private List<MydoJobDetail> materialDetails;
|
||||
private List<PkDetail> pkDetailList;
|
||||
private String quantity;
|
||||
private String stockinDetailId;
|
||||
private String inStockinDetailId;
|
||||
private String stockoutDetailId;
|
||||
private String cargoSpaceId;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.ruoyi.pda.domain;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TrayCodeMsg {
|
||||
|
||||
private String trayCode;
|
||||
@@ -18,6 +20,26 @@ private String stockinDetailId;
|
||||
|
||||
private String inOut;
|
||||
private String status;
|
||||
private String stockoutDetailId;
|
||||
|
||||
|
||||
public String getStockoutDetailId() {
|
||||
return stockoutDetailId;
|
||||
}
|
||||
|
||||
public void setStockoutDetailId(String stockoutDetailId) {
|
||||
this.stockoutDetailId = stockoutDetailId;
|
||||
}
|
||||
|
||||
private String trayType;
|
||||
|
||||
public String getTrayType() {
|
||||
return trayType;
|
||||
}
|
||||
|
||||
public void setTrayType(String trayType) {
|
||||
this.trayType = trayType;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
|
||||
@@ -38,4 +38,18 @@ public interface PdaMapper {
|
||||
void pkOut(HashMap<String, Object> map);
|
||||
|
||||
void outMakeSureException(HashMap<String, Object> map);
|
||||
|
||||
void hcoutMakesure(HashMap<String, Object> map);
|
||||
|
||||
Integer selectByTrayCodeAndProduct(String trayCode, String productId);
|
||||
|
||||
void completeOutPk(HashMap<String, Object> map);
|
||||
|
||||
void completeInPk(HashMap<String, Object> map);
|
||||
|
||||
void FillFinishAllot(HashMap<String, Object> map);
|
||||
|
||||
void FillFinishAllotOut(HashMap<String, Object> map);
|
||||
|
||||
void bindTrayCheck(HashMap<String, Object> map);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.ruoyi.pda.domain.TrayCodeMakeSure;
|
||||
import com.ruoyi.pda.domain.TrayCodeMsg;
|
||||
import com.ruoyi.stock.stock.domain.BasStock;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@@ -28,7 +29,7 @@ public interface PdaService {
|
||||
|
||||
AjaxResult bindTray(TrayCodeMakeSure trayCodeMakeSure);
|
||||
|
||||
AjaxResult tpIn(String trayCode);
|
||||
AjaxResult tpIn(TrayCodeMsg trayCodeMsg);
|
||||
|
||||
AjaxResult tpOut(TrayCodeMsg trayCodeMsg);
|
||||
|
||||
@@ -56,4 +57,19 @@ public interface PdaService {
|
||||
AjaxResult updateWcsPort(WcsPort wcsport);
|
||||
|
||||
|
||||
AjaxResult hcoutMakesure(String trayCode);
|
||||
|
||||
AjaxResult completeInPk(TrayCodeMakeSure trayCodeMakeSure);
|
||||
|
||||
AjaxResult selectBasStockHc(String trayCode);
|
||||
|
||||
Integer selectByTrayCodeAndProduct(String trayCode, String productId);
|
||||
|
||||
void completeOutPk(HashMap<String, Object> map);
|
||||
|
||||
Integer selectBasStockHcCount(String trayCode, String productId);
|
||||
|
||||
AjaxResult selectBasStockHcs(String trayCode, String stockoutDetailId);
|
||||
|
||||
AjaxResult bindTray2(TrayCodeMakeSure trayCodeMakeSure);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user