Compare commits
4 Commits
2868cb85fa
...
test/ft546
| Author | SHA1 | Date | |
|---|---|---|---|
| 690eae9985 | |||
| 3ec0931047 | |||
| 3f7ed3718d | |||
| da5a0a1561 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -27,3 +27,5 @@ hs_err_pid*
|
||||
**/target/
|
||||
|
||||
/log/
|
||||
# Local MCP credentials and connection settings.
|
||||
.cursorrules-mcp.json
|
||||
|
||||
@@ -237,6 +237,8 @@ WHERE created_at >= '<测试开始时间>'
|
||||
ORDER BY created_at, decision_id;
|
||||
```
|
||||
|
||||
出库对比记录的 `reason` 会带出 `detail`、`project`、`product`、`tray`、`stock`、`snapshotSync`、`legacyMatches` 和 `shadowMatches`。其中 `legacyMatches` 是按 Legacy 有效库存条件计算的实时数量,`shadowMatches` 是影子快照中按项目/产品条件计算的数量;两者不一致时先检查快照同步时间,再判断业务映射。
|
||||
|
||||
交付分析的数据包至少包括:
|
||||
|
||||
- 决策日志导出文件,保持原始列名和时间字段;
|
||||
|
||||
20
opencode.jsonc
Normal file
20
opencode.jsonc
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"mcp": {
|
||||
"ft546-sqlserver": {
|
||||
"type": "local",
|
||||
"command": [
|
||||
"powershell.exe",
|
||||
"-NoProfile",
|
||||
"-ExecutionPolicy",
|
||||
"Bypass",
|
||||
"-File",
|
||||
"C:\\project\\sqlserver-mcp-server\\start.ps1",
|
||||
"-ConfigPath",
|
||||
"C:\\project\\FT546WMS-SHANDOW\\.cursorrules-mcp.json"
|
||||
],
|
||||
"enabled": true,
|
||||
"timeout": 30000
|
||||
}
|
||||
}
|
||||
}
|
||||
7
pom.xml
7
pom.xml
@@ -197,7 +197,11 @@
|
||||
<artifactId>ruoyi-common</artifactId>
|
||||
<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>
|
||||
@@ -251,6 +255,7 @@
|
||||
<module>ruoyi-generator</module>
|
||||
<module>ruoyi-common</module>
|
||||
<module>fortucky-algorithm</module>
|
||||
<module>ruoyi-license</module>
|
||||
</modules>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
|
||||
@@ -35,6 +35,10 @@
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-license</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 核心模块-->
|
||||
<dependency>
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.ruoyi.algorithm.shadow;
|
||||
|
||||
public class ShadowInboundReference {
|
||||
private String requestId;
|
||||
private String warehouseId;
|
||||
private String trayNo;
|
||||
private String projectNo;
|
||||
private String productId;
|
||||
@@ -15,6 +16,14 @@ public class ShadowInboundReference {
|
||||
this.requestId = requestId;
|
||||
}
|
||||
|
||||
public String getWarehouseId() {
|
||||
return warehouseId;
|
||||
}
|
||||
|
||||
public void setWarehouseId(String warehouseId) {
|
||||
this.warehouseId = warehouseId;
|
||||
}
|
||||
|
||||
public String getTrayNo() {
|
||||
return trayNo;
|
||||
}
|
||||
|
||||
@@ -41,28 +41,30 @@ public class ShadowPlanningEngine {
|
||||
public OutboundShadowObservation planProjectOutbound(String stockoutDetailId) {
|
||||
return transactions.execute(status -> {
|
||||
ShadowStockReference reference = inputMapper.selectProjectOutboundReference(stockoutDetailId);
|
||||
String warehouseId = warehouseId();
|
||||
String warehouseId = warehouseId(reference == null ? null : reference.getWarehouseId());
|
||||
if (reference == null || isBlank(reference.getProjectNo())) {
|
||||
return OutboundShadowObservation.unavailable(warehouseId, stockoutDetailId,
|
||||
"SKIPPED_MISSING_PROJECT", "No project number was available for shadow planning");
|
||||
}
|
||||
OutboundRequest request = new OutboundRequest(stockoutDetailId, null,
|
||||
reference.getProjectNo(), reference.getProductId(), null, null, null, true);
|
||||
return toOutboundObservation(warehouseId, reference, schedulingFacade.planOutbound(warehouseId, request));
|
||||
return toOutboundObservation(warehouseId, reference.getRequestId(), reference,
|
||||
schedulingFacade.planOutbound(warehouseId, request));
|
||||
});
|
||||
}
|
||||
|
||||
public OutboundShadowObservation planExactStockOutbound(String stockoutDetailId, String stockId) {
|
||||
return transactions.execute(status -> {
|
||||
ShadowStockReference reference = inputMapper.selectStockReference(stockId);
|
||||
String warehouseId = warehouseId();
|
||||
String warehouseId = warehouseId(reference == null ? null : reference.getWarehouseId());
|
||||
if (reference == null || isBlank(reference.getTrayNo())) {
|
||||
return OutboundShadowObservation.unavailable(warehouseId, stockoutDetailId,
|
||||
"SKIPPED_MISSING_STOCK", "Selected stock was unavailable to shadow planning");
|
||||
}
|
||||
OutboundRequest request = new OutboundRequest(stockoutDetailId, reference.getTrayNo(),
|
||||
reference.getProjectNo(), reference.getProductId(), null, null, null, true);
|
||||
return toOutboundObservation(warehouseId, reference, schedulingFacade.planOutbound(warehouseId, request));
|
||||
return toOutboundObservation(warehouseId, stockoutDetailId, reference,
|
||||
schedulingFacade.planOutbound(warehouseId, request));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -73,6 +75,7 @@ public class ShadowPlanningEngine {
|
||||
comparisonCode(observation.proposedSpaceId(), legacySpaceId),
|
||||
"request=" + observation.requestId() + "; shadow=" + observation.resultCode()
|
||||
+ "; proposedSpace=" + nullSafe(observation.proposedSpaceId())
|
||||
+ "; shadowReason=" + nullSafe(observation.reason())
|
||||
+ "; legacy=" + nullSafe(legacyResultCode)
|
||||
+ "; legacySpace=" + nullSafe(legacySpaceId)));
|
||||
}
|
||||
@@ -84,12 +87,13 @@ public class ShadowPlanningEngine {
|
||||
"request=" + observation.requestId() + "; shadow=" + observation.resultCode()
|
||||
+ "; proposedStock=" + nullSafe(observation.proposedStockId())
|
||||
+ "; proposedSpace=" + nullSafe(observation.proposedSpaceId())
|
||||
+ "; shadowReason=" + nullSafe(observation.reason())
|
||||
+ "; legacy=" + nullSafe(legacyResultCode)));
|
||||
}
|
||||
|
||||
private InboundShadowObservation planInboundInsideTransaction(String taskNo, String trayNo) {
|
||||
String warehouseId = warehouseId();
|
||||
ShadowInboundReference reference = inputMapper.selectInboundInput(taskNo, trayNo);
|
||||
String warehouseId = warehouseId(reference == null ? null : reference.getWarehouseId());
|
||||
if (reference == null || isBlank(reference.getRequestId()) || isBlank(reference.getTrayNo())) {
|
||||
return InboundShadowObservation.unavailable(warehouseId, taskNo,
|
||||
"SKIPPED_MISSING_INPUT", "Inbound task details were unavailable to shadow planning");
|
||||
@@ -102,38 +106,90 @@ public class ShadowPlanningEngine {
|
||||
if (plan.assignment().isPresent()) {
|
||||
var assignment = plan.assignment().orElseThrow();
|
||||
return new InboundShadowObservation(true, warehouseId, reference.getRequestId(),
|
||||
"READY", assignment.spaceId(), assignment.reason());
|
||||
"READY", assignment.spaceId(), inboundDiagnostic(taskNo, trayNo, reference, assignment.reason()));
|
||||
}
|
||||
var rejection = plan.rejection().orElseThrow();
|
||||
return InboundShadowObservation.unavailable(warehouseId, reference.getRequestId(),
|
||||
"REJECTED_" + rejection.code().name(), rejection.reason());
|
||||
"REJECTED_" + rejection.code().name(),
|
||||
inboundDiagnostic(taskNo, trayNo, reference, rejection.reason()));
|
||||
}
|
||||
|
||||
private OutboundShadowObservation toOutboundObservation(String warehouseId,
|
||||
private OutboundShadowObservation toOutboundObservation(String warehouseId, String requestId,
|
||||
ShadowStockReference reference, OutboundPlan plan) {
|
||||
String requestId = reference.getRequestId();
|
||||
if (isBlank(requestId)) {
|
||||
requestId = plan.assignment().map(assignment -> assignment.requestId()).orElse(null);
|
||||
}
|
||||
if (plan.assignment().isPresent()) {
|
||||
var assignment = plan.assignment().orElseThrow();
|
||||
return new OutboundShadowObservation(true, warehouseId, requestId, "READY",
|
||||
reference.getStockId(), assignment.sourceSpaceId(), assignment.reason());
|
||||
reference.getStockId(), assignment.sourceSpaceId(),
|
||||
outboundDiagnostic(requestId, reference, assignment.reason()));
|
||||
}
|
||||
if (plan.waiting().isPresent()) {
|
||||
var waiting = plan.waiting().orElseThrow();
|
||||
return OutboundShadowObservation.unavailable(warehouseId, requestId,
|
||||
"WAITING_" + waiting.code().name(), waiting.reason());
|
||||
"WAITING_" + waiting.code().name(), outboundDiagnostic(requestId, reference, waiting.reason()));
|
||||
}
|
||||
var error = plan.error().orElseThrow();
|
||||
return OutboundShadowObservation.unavailable(warehouseId, requestId,
|
||||
"ERROR_" + error.code().name(), error.message());
|
||||
"ERROR_" + error.code().name(), outboundDiagnostic(requestId, reference, error.message()));
|
||||
}
|
||||
|
||||
private String warehouseId() {
|
||||
return isBlank(properties.getWarehouseId())
|
||||
private String warehouseId(String preferredWarehouseId) {
|
||||
String configuredWarehouseId = isBlank(properties.getWarehouseId())
|
||||
? schedulingFacade.defaultWarehouseId()
|
||||
: properties.getWarehouseId();
|
||||
if (!isBlank(preferredWarehouseId)) {
|
||||
String normalizedPreferred = preferredWarehouseId.trim();
|
||||
if (sameNumericWarehouse(normalizedPreferred, configuredWarehouseId)) {
|
||||
return configuredWarehouseId;
|
||||
}
|
||||
return normalizedPreferred;
|
||||
}
|
||||
return configuredWarehouseId;
|
||||
}
|
||||
|
||||
private boolean sameNumericWarehouse(String first, String second) {
|
||||
if (isBlank(first) || isBlank(second)) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
return Integer.parseInt(first) == Integer.parseInt(second);
|
||||
} catch (NumberFormatException ignored) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private String outboundDiagnostic(String requestId, ShadowStockReference reference, String resultReason) {
|
||||
return "detail=" + nullSafe(requestId)
|
||||
+ "; project=" + nullSafe(reference.getProjectNo())
|
||||
+ "; product=" + nullSafe(reference.getProductId())
|
||||
+ "; tray=" + nullSafe(reference.getTrayNo())
|
||||
+ "; stock=" + nullSafe(reference.getStockId())
|
||||
+ "; snapshotSync=" + nullSafe(reference.getSnapshotSynchronizedAt())
|
||||
+ "; legacyMatches=" + numberOrUnknown(reference.getLiveMatchCount())
|
||||
+ "; shadowMatches=" + numberOrUnknown(reference.getShadowMatchCount())
|
||||
+ "; reason=" + abbreviate(nullSafe(resultReason), 600);
|
||||
}
|
||||
|
||||
private String inboundDiagnostic(String taskNo, String trayNo, ShadowInboundReference reference,
|
||||
String resultReason) {
|
||||
return "task=" + nullSafe(taskNo)
|
||||
+ "; tray=" + nullSafe(trayNo)
|
||||
+ "; request=" + nullSafe(reference.getRequestId())
|
||||
+ "; warehouse=" + nullSafe(reference.getWarehouseId())
|
||||
+ "; project=" + nullSafe(reference.getProjectNo())
|
||||
+ "; product=" + nullSafe(reference.getProductId())
|
||||
+ "; lot=" + nullSafe(reference.getLotNo())
|
||||
+ "; reason=" + abbreviate(nullSafe(resultReason), 600);
|
||||
}
|
||||
|
||||
private String numberOrUnknown(Integer value) {
|
||||
return value == null ? "" : value.toString();
|
||||
}
|
||||
|
||||
private String abbreviate(String value, int maxLength) {
|
||||
return value.length() <= maxLength ? value : value.substring(0, maxLength);
|
||||
}
|
||||
|
||||
private String comparisonCode(String shadowSpaceId, String legacySpaceId) {
|
||||
|
||||
@@ -8,6 +8,9 @@ public class ShadowStockReference {
|
||||
private String warehouseId;
|
||||
private String projectNo;
|
||||
private String productId;
|
||||
private String snapshotSynchronizedAt;
|
||||
private Integer liveMatchCount;
|
||||
private Integer shadowMatchCount;
|
||||
|
||||
public String getRequestId() {
|
||||
return requestId;
|
||||
@@ -64,4 +67,28 @@ public class ShadowStockReference {
|
||||
public void setProductId(String productId) {
|
||||
this.productId = productId;
|
||||
}
|
||||
|
||||
public String getSnapshotSynchronizedAt() {
|
||||
return snapshotSynchronizedAt;
|
||||
}
|
||||
|
||||
public void setSnapshotSynchronizedAt(String snapshotSynchronizedAt) {
|
||||
this.snapshotSynchronizedAt = snapshotSynchronizedAt;
|
||||
}
|
||||
|
||||
public Integer getLiveMatchCount() {
|
||||
return liveMatchCount;
|
||||
}
|
||||
|
||||
public void setLiveMatchCount(Integer liveMatchCount) {
|
||||
this.liveMatchCount = liveMatchCount;
|
||||
}
|
||||
|
||||
public Integer getShadowMatchCount() {
|
||||
return shadowMatchCount;
|
||||
}
|
||||
|
||||
public void setShadowMatchCount(Integer shadowMatchCount) {
|
||||
this.shadowMatchCount = shadowMatchCount;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,27 +127,36 @@ public class OutStockoutServiceImpl implements IOutStockoutService
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String saveBill(OutStockoutVo outStockoutVo) {
|
||||
OutStockout outStockout = outStockoutVo.getOutStockout();
|
||||
List<OutStockoutDetail> detailList = outStockoutVo.getDetailList();
|
||||
String stockOutId = basJobIdService.getJobId("CKD");
|
||||
outStockout.setStockoutId(stockOutId);
|
||||
outStockout.setStockoutGuid(UUID.randomUUID().toString());
|
||||
outStockout.setCreateDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
||||
String username = SecurityContextHolder.getContext().getAuthentication().getName();
|
||||
outStockout.setCreateManId(username);
|
||||
outStockout.setStatus("1");
|
||||
outStockout.setStockoutSource("0");
|
||||
outStockout.setWarehouseId("01");
|
||||
for (int i = 0; i < detailList.size(); i++) {
|
||||
OutStockoutDetail outStockoutDetail = detailList.get(i);
|
||||
outStockoutDetail.setStockoutDetailId(stockOutId + "-" + (i + 1));
|
||||
outStockoutDetail.setStockoutGuid(outStockout.getStockoutGuid());
|
||||
outStockoutDetail.setStockoutId(stockOutId);
|
||||
outStockoutDetail.setAllotQuantity(BigDecimal.ZERO);
|
||||
outStockoutDetail.setAssignNum(BigDecimal.ZERO);
|
||||
outStockoutDetailMapper.insertOutStockoutDetail(outStockoutDetail);
|
||||
}
|
||||
outStockoutMapper.insertOutStockout(outStockout);
|
||||
OutStockout outStockout = outStockoutVo.getOutStockout();
|
||||
List<OutStockoutDetail> detailList = outStockoutVo.getDetailList();
|
||||
String stockOutId = basJobIdService.getJobId("CKD");
|
||||
outStockout.setStockoutId(stockOutId);
|
||||
outStockout.setStockoutGuid(UUID.randomUUID().toString());
|
||||
outStockout.setCreateDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
||||
String username = SecurityContextHolder.getContext().getAuthentication().getName();
|
||||
outStockout.setCreateManId(username);
|
||||
outStockout.setStatus("1");
|
||||
outStockout.setStockoutSource("0");
|
||||
String warehouseId = outStockout.getWarehouseId();
|
||||
if ("01".equals(warehouseId) || "1".equals(warehouseId)) {
|
||||
warehouseId = "1";
|
||||
} else if ("02".equals(warehouseId) || "2".equals(warehouseId)) {
|
||||
warehouseId = "2";
|
||||
} else {
|
||||
throw new IllegalArgumentException("仓库编号只能是1(立体库)或2(平库)");
|
||||
}
|
||||
outStockout.setWarehouseId(warehouseId);
|
||||
for (int i = 0; i < detailList.size(); i++) {
|
||||
OutStockoutDetail outStockoutDetail = detailList.get(i);
|
||||
outStockoutDetail.setStockoutDetailId(stockOutId + "-" + (i + 1));
|
||||
outStockoutDetail.setStockoutGuid(outStockout.getStockoutGuid());
|
||||
outStockoutDetail.setStockoutId(stockOutId);
|
||||
outStockoutDetail.setAllotQuantity(BigDecimal.ZERO);
|
||||
outStockoutDetail.setAssignNum(BigDecimal.ZERO);
|
||||
outStockoutDetail.setWarehouseId(warehouseId);
|
||||
outStockoutDetailMapper.insertOutStockoutDetail(outStockoutDetail);
|
||||
}
|
||||
outStockoutMapper.insertOutStockout(outStockout);
|
||||
|
||||
return stockOutId;
|
||||
}
|
||||
@@ -177,6 +186,9 @@ public class OutStockoutServiceImpl implements IOutStockoutService
|
||||
if ("1".equals(outStockout.getStatus())){
|
||||
return AjaxResult.warn("单据未审核,请审核无误后再分配!");
|
||||
}
|
||||
if (outStockout.getWarehouseId().equals("2")){
|
||||
return AjaxResult.warn("平库单据请使用手持机操作!");
|
||||
}
|
||||
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
@@ -42,7 +42,9 @@ public class ViewProductAndStockController extends BaseController
|
||||
public TableDataInfo list(ViewProductAndStock viewProductAndStock)
|
||||
{
|
||||
startPage();
|
||||
List<ViewProductAndStock> list = viewProductAndStockService.selectViewProductAndStockList(viewProductAndStock);
|
||||
List<ViewProductAndStock> list = "2".equals(viewProductAndStock.getWarehouseId())
|
||||
? viewProductAndStockService.selectFlatProductAndStockList(viewProductAndStock)
|
||||
: viewProductAndStockService.selectViewProductAndStockList(viewProductAndStock);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
|
||||
@@ -60,4 +60,6 @@ public interface ViewProductAndStockMapper
|
||||
public int deleteViewProductAndStockByOnlyIdentitys(Long[] onlyIdentitys);
|
||||
|
||||
List<ViewProductAndStock> selectViewProductAndStockPdList(ViewProductAndStock viewProductAndStock);
|
||||
|
||||
List<ViewProductAndStock> selectFlatProductAndStockList(ViewProductAndStock viewProductAndStock);
|
||||
}
|
||||
|
||||
@@ -67,4 +67,5 @@ public interface IViewProductAndStockService
|
||||
*/
|
||||
public int deleteViewProductAndStockByOnlyIdentity(Long onlyIdentity);
|
||||
|
||||
List<ViewProductAndStock> selectFlatProductAndStockList(ViewProductAndStock viewProductAndStock);
|
||||
}
|
||||
|
||||
@@ -102,4 +102,9 @@ public class ViewProductAndStockServiceImpl implements IViewProductAndStockServi
|
||||
{
|
||||
return viewProductAndStockMapper.deleteViewProductAndStockByOnlyIdentity(onlyIdentity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ViewProductAndStock> selectFlatProductAndStockList(ViewProductAndStock viewProductAndStock) {
|
||||
return viewProductAndStockMapper.selectFlatProductAndStockList(viewProductAndStock);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ public class PdaServiceImp implements PdaService {
|
||||
pdaMapper.bindTray(map);
|
||||
if (!"10".equals(map.get("v_result").toString())) {
|
||||
errorbulider.append(mydoJobDetail.getStockinDetailId() + map.get("v_resultmsg").toString());
|
||||
throw new RuntimeException(map.get("v_result").toString());
|
||||
throw new RuntimeException(map.get("v_resultmsg").toString());
|
||||
}
|
||||
}
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
@@ -140,7 +140,7 @@ public class PdaServiceImp implements PdaService {
|
||||
map.put("v_is_full", trayCodeMakeSure.getIsFull());
|
||||
pdaMapper.addInJob(map);
|
||||
if (!"10".equals(map.get("v_result").toString())) {
|
||||
throw new RuntimeException(map.get("v_result").toString());
|
||||
throw new RuntimeException(map.get("v_resultmsg").toString());
|
||||
}
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
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,前端静默处理
|
||||
*/
|
||||
@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);
|
||||
}
|
||||
}
|
||||
@@ -135,6 +135,10 @@ token:
|
||||
# 令牌有效期(默认30分钟)
|
||||
expireTime: 43800
|
||||
|
||||
# 授权码配置
|
||||
license:
|
||||
# 首次部署需先执行 sql/sys_license.sql 并激活授权码,再改为 true 启用拦截
|
||||
enabled: false
|
||||
|
||||
|
||||
# MyBatis配置
|
||||
|
||||
@@ -7,6 +7,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<select id="selectInboundInput" resultType="com.ruoyi.algorithm.shadow.ShadowInboundReference">
|
||||
select top (1)
|
||||
job.job_id as requestId,
|
||||
job.warehouse_id as warehouseId,
|
||||
job.tray_code as trayNo,
|
||||
coalesce(nullif(ltrim(rtrim(detail.spare4)), ''),
|
||||
nullif(ltrim(rtrim(stock.spare4)), '')) as projectNo,
|
||||
@@ -25,7 +26,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
select detail.stockout_detail_id as requestId,
|
||||
detail.warehouse_id as warehouseId,
|
||||
nullif(ltrim(rtrim(detail.spare4)), '') as projectNo,
|
||||
detail.product_id as productId
|
||||
detail.product_id as productId,
|
||||
convert(varchar(40), (select max(snapshot.synchronized_at)
|
||||
from alg.inventory_item_snapshot snapshot
|
||||
where snapshot.warehouse_id = detail.warehouse_id), 126)
|
||||
as snapshotSynchronizedAt,
|
||||
(select count(*)
|
||||
from bas_stock live
|
||||
where live.warehouse_id = detail.warehouse_id
|
||||
and live.stock_status = '1'
|
||||
and live.product_status = '1'
|
||||
and live.quantity > live.out_quantity
|
||||
and (NULLIF(LTRIM(RTRIM(detail.product_id)), '') IS NULL
|
||||
OR live.product_id = NULLIF(LTRIM(RTRIM(detail.product_id)), ''))) as liveMatchCount,
|
||||
(select count(*)
|
||||
from alg.inventory_item_snapshot snapshot
|
||||
where snapshot.warehouse_id = detail.warehouse_id
|
||||
and snapshot.project_no = nullif(ltrim(rtrim(detail.spare4)), '')
|
||||
and (NULLIF(LTRIM(RTRIM(detail.product_id)), '') IS NULL
|
||||
OR snapshot.product_no = NULLIF(LTRIM(RTRIM(detail.product_id)), '')))
|
||||
as shadowMatchCount
|
||||
from out_stockout_detail detail
|
||||
where detail.stockout_detail_id = #{stockoutDetailId}
|
||||
</select>
|
||||
@@ -37,7 +57,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
stock.cargo_space_id as spaceId,
|
||||
stock.warehouse_id as warehouseId,
|
||||
nullif(ltrim(rtrim(stock.spare4)), '') as projectNo,
|
||||
stock.product_id as productId
|
||||
stock.product_id as productId,
|
||||
convert(varchar(40), (select max(snapshot.synchronized_at)
|
||||
from alg.inventory_item_snapshot snapshot
|
||||
where snapshot.warehouse_id = stock.warehouse_id), 126)
|
||||
as snapshotSynchronizedAt,
|
||||
(select count(*)
|
||||
from bas_stock live
|
||||
where live.stock_id = stock.stock_id
|
||||
and live.stock_status = '1'
|
||||
and live.product_status = '1'
|
||||
and live.quantity > live.out_quantity) as liveMatchCount,
|
||||
(select count(*)
|
||||
from alg.inventory_item_snapshot snapshot
|
||||
where snapshot.stock_id = stock.stock_id
|
||||
and snapshot.warehouse_id = stock.warehouse_id) as shadowMatchCount
|
||||
from bas_stock stock
|
||||
where stock.stock_id = #{stockId}
|
||||
and stock.stock_status = '1'
|
||||
|
||||
@@ -81,6 +81,49 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectFlatProductAndStockList" parameterType="ViewProductAndStock" resultMap="ViewProductAndStockResult">
|
||||
select row_number() over (order by bs.product_id, bs.stock_id) as only_identity,
|
||||
bs.product_id,
|
||||
bs.lot_no,
|
||||
bs.product_name,
|
||||
isnull(bs.quantity, 0) - isnull(bs.out_quantity, 0) as quantity,
|
||||
bs.warehouse_id,
|
||||
bs.stacking_id,
|
||||
bs.spare1,
|
||||
bs.spare2,
|
||||
bs.spare3,
|
||||
bs.spare4,
|
||||
bs.spare5,
|
||||
bs.spare6,
|
||||
bs.voltage,
|
||||
bs.power,
|
||||
bs.phase
|
||||
from bas_stock_hc bs
|
||||
<where>
|
||||
<!-- try_convert(int, bs.warehouse_id) = 2-->
|
||||
<!-- and isnull(bs.quantity, 0) - isnull(bs.out_quantity, 0) > 0-->
|
||||
bs.quantity>0
|
||||
and bs.out_quantity =0
|
||||
<if test="productId != null and productId != ''">and bs.product_id like concat('%', #{productId}, '%')</if>
|
||||
<if test="lotNo != null and lotNo != ''">and bs.lot_no like concat('%', #{lotNo}, '%')</if>
|
||||
<if test="productName != null and productName != ''">and bs.product_name like concat('%', #{productName}, '%')</if>
|
||||
<if test="spare1 != null and spare1 != ''">and bs.spare1 like concat('%', #{spare1}, '%')</if>
|
||||
<if test="spare2 != null and spare2 != ''">and bs.spare2 like concat('%', #{spare2}, '%')</if>
|
||||
<if test="spare3 != null and spare3 != ''">and bs.spare3 like concat('%', #{spare3}, '%')</if>
|
||||
<if test="spare4 != null and spare4 != ''">
|
||||
and (bs.spare4 like concat('%', #{spare4}, '%')
|
||||
or bs.order_id like concat('%', #{spare4}, '%')
|
||||
or bs.job_id like concat('%', #{spare4}, '%'))
|
||||
</if>
|
||||
<if test="spare5 != null and spare5 != ''">and bs.spare5 like concat('%', #{spare5}, '%')</if>
|
||||
<if test="spare6 != null and spare6 != ''">and bs.spare6 like concat('%', #{spare6}, '%')</if>
|
||||
<if test="voltage != null and voltage != ''">and bs.voltage like concat('%', #{voltage}, '%')</if>
|
||||
<if test="power != null and power != ''">and bs.power like concat('%', #{power}, '%')</if>
|
||||
<if test="phase != null and phase != ''">and bs.phase like concat('%', #{phase}, '%')</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
<insert id="insertViewProductAndStock" parameterType="ViewProductAndStock">
|
||||
insert into view_product_and_stock
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
|
||||
@@ -507,7 +507,6 @@
|
||||
<include refid="selectBasStockHcVo"/>
|
||||
<where>
|
||||
|
||||
<if test="out.lotNo != null and out.lotNo != ''">and bs.lot_no like concat('%', #{out.lotNo}, '%')</if>
|
||||
|
||||
<if test="trayCode != null and trayCode != ''">and bs.tray_code like concat('%', #{trayCode}, '%')</if>
|
||||
|
||||
|
||||
@@ -5,6 +5,9 @@ import com.ruoyi.algorithm.inbound.InboundBorrowType;
|
||||
import com.ruoyi.algorithm.inbound.InboundLadderRung;
|
||||
import com.ruoyi.algorithm.inbound.InboundPlan;
|
||||
import com.ruoyi.algorithm.integration.SchedulingFacade;
|
||||
import com.ruoyi.algorithm.outbound.OutboundAssignment;
|
||||
import com.ruoyi.algorithm.outbound.OutboundPlan;
|
||||
import com.ruoyi.algorithm.outbound.FifoDecision;
|
||||
import com.ruoyi.algorithm.repository.VersionToken;
|
||||
import com.ruoyi.algorithm.service.InboundPlanningResult;
|
||||
import com.ruoyi.algorithm.shadow.mapper.ShadowInputMapper;
|
||||
@@ -16,8 +19,10 @@ import org.springframework.transaction.support.SimpleTransactionStatus;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.argThat;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
class ShadowPlanningEngineTest {
|
||||
@@ -25,13 +30,14 @@ class ShadowPlanningEngineTest {
|
||||
@Test
|
||||
void inboundPlanningUsesRequiresNewAndConfiguredTimeout() {
|
||||
ShadowObservationProperties properties = new ShadowObservationProperties();
|
||||
properties.setWarehouseId("W01");
|
||||
properties.setWarehouseId("FALLBACK");
|
||||
properties.setTimeoutSeconds(7);
|
||||
CapturingTransactionManager transactions = new CapturingTransactionManager();
|
||||
ShadowInputMapper mapper = mock(ShadowInputMapper.class);
|
||||
SchedulingFacade facade = mock(SchedulingFacade.class);
|
||||
ShadowInboundReference input = new ShadowInboundReference();
|
||||
input.setRequestId("JOB-1");
|
||||
input.setWarehouseId("W01");
|
||||
input.setTrayNo("TRAY-1");
|
||||
input.setProjectNo("PROJECT-1");
|
||||
input.setProductId("PRODUCT-1");
|
||||
@@ -56,6 +62,69 @@ class ShadowPlanningEngineTest {
|
||||
assertThat(observation.proposedSpaceId()).isEqualTo("SPACE-9");
|
||||
}
|
||||
|
||||
@Test
|
||||
void outboundPlanningUsesReferenceWarehouseAndKeepsMatchDiagnostics() {
|
||||
ShadowObservationProperties properties = new ShadowObservationProperties();
|
||||
properties.setWarehouseId("FALLBACK");
|
||||
CapturingTransactionManager transactions = new CapturingTransactionManager();
|
||||
ShadowInputMapper mapper = mock(ShadowInputMapper.class);
|
||||
SchedulingFacade facade = mock(SchedulingFacade.class);
|
||||
ShadowStockReference reference = new ShadowStockReference();
|
||||
reference.setRequestId("DETAIL-1");
|
||||
reference.setWarehouseId("W02");
|
||||
reference.setProjectNo("PROJECT-1");
|
||||
reference.setProductId("PRODUCT-1");
|
||||
reference.setSnapshotSynchronizedAt("2026-08-28T02:53:45.133Z");
|
||||
reference.setLiveMatchCount(2);
|
||||
reference.setShadowMatchCount(1);
|
||||
when(mapper.selectProjectOutboundReference("DETAIL-1")).thenReturn(reference);
|
||||
OutboundAssignment assignment = new OutboundAssignment(
|
||||
"DETAIL-1", "TRAY-1", "PROJECT-1", "PRODUCT-1", "SPACE-9", 1,
|
||||
true, java.util.List.of(), java.util.List.of(), false,
|
||||
1.0, 2.0, 3.0, FifoDecision.off(), java.util.Optional.empty(),
|
||||
"shadow proposal");
|
||||
when(facade.planOutbound(eq("W02"), any()))
|
||||
.thenReturn(OutboundPlan.ready(assignment, com.ruoyi.algorithm.outbound.TaskCountEstimate.zero()));
|
||||
ShadowPlanningEngine engine = new ShadowPlanningEngine(facade, mapper, properties, transactions);
|
||||
|
||||
OutboundShadowObservation observation = engine.planProjectOutbound("DETAIL-1");
|
||||
engine.compareOutbound(observation, "10");
|
||||
|
||||
assertThat(observation.warehouseId()).isEqualTo("W02");
|
||||
assertThat(observation.requestId()).isEqualTo("DETAIL-1");
|
||||
assertThat(observation.proposedSpaceId()).isEqualTo("SPACE-9");
|
||||
verify(mapper).insertComparison(any(), eq("W02"), eq("OUTBOUND_COMPARE"), eq("LEGACY_10"),
|
||||
argThat(reason -> reason.contains("detail=DETAIL-1")
|
||||
&& reason.contains("project=PROJECT-1")
|
||||
&& reason.contains("product=PRODUCT-1")
|
||||
&& reason.contains("snapshotSync=2026-08-28T02:53:45.133Z")
|
||||
&& reason.contains("legacyMatches=2")
|
||||
&& reason.contains("shadowMatches=1")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void outboundPlanningTreatsPaddedAndUnpaddedWarehouseIdsAsEquivalent() {
|
||||
ShadowObservationProperties properties = new ShadowObservationProperties();
|
||||
properties.setWarehouseId("01");
|
||||
CapturingTransactionManager transactions = new CapturingTransactionManager();
|
||||
ShadowInputMapper mapper = mock(ShadowInputMapper.class);
|
||||
SchedulingFacade facade = mock(SchedulingFacade.class);
|
||||
ShadowStockReference reference = new ShadowStockReference();
|
||||
reference.setRequestId("DETAIL-2");
|
||||
reference.setWarehouseId("1");
|
||||
reference.setProjectNo("PROJECT-2");
|
||||
when(mapper.selectProjectOutboundReference("DETAIL-2")).thenReturn(reference);
|
||||
when(facade.planOutbound(eq("01"), any())).thenReturn(
|
||||
OutboundPlan.error(new com.ruoyi.algorithm.outbound.OutboundError(
|
||||
com.ruoyi.algorithm.outbound.OutboundErrorCode.STOCK_NOT_FOUND,
|
||||
"no stock", java.util.Map.of())));
|
||||
ShadowPlanningEngine engine = new ShadowPlanningEngine(facade, mapper, properties, transactions);
|
||||
|
||||
OutboundShadowObservation observation = engine.planProjectOutbound("DETAIL-2");
|
||||
|
||||
assertThat(observation.warehouseId()).isEqualTo("01");
|
||||
}
|
||||
|
||||
private static final class CapturingTransactionManager implements PlatformTransactionManager {
|
||||
private TransactionDefinition definition;
|
||||
|
||||
|
||||
@@ -123,6 +123,7 @@ class OutStockoutServiceImplShadowTest {
|
||||
private void prepareAutoAllot() {
|
||||
OutStockout bill = new OutStockout();
|
||||
bill.setStatus("2");
|
||||
bill.setWarehouseId("1");
|
||||
when(outStockoutMapper.selectOutStockoutByStockoutId("OUT-1")).thenReturn(bill);
|
||||
when(outStockoutDetailService.selectOutStockoutDetailList(any()))
|
||||
.thenReturn(List.of(pendingDetail));
|
||||
|
||||
@@ -58,14 +58,14 @@ public class SecurityConfig
|
||||
@Autowired
|
||||
private PermitAllUrlProperties permitAllUrl;
|
||||
|
||||
/**
|
||||
* 身份验证实现
|
||||
*/
|
||||
@Bean
|
||||
public AuthenticationManager authenticationManager(AuthenticationConfiguration authenticationConfiguration) throws Exception
|
||||
{
|
||||
return authenticationConfiguration.getAuthenticationManager();
|
||||
}
|
||||
/**
|
||||
* 身份验证实现
|
||||
*/
|
||||
@Bean
|
||||
public AuthenticationManager authenticationManager(AuthenticationConfiguration authenticationConfiguration) throws Exception
|
||||
{
|
||||
return authenticationConfiguration.getAuthenticationManager();
|
||||
}
|
||||
|
||||
/**
|
||||
* anyRequest | 匹配所有请求路径
|
||||
@@ -86,36 +86,36 @@ public class SecurityConfig
|
||||
protected SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception
|
||||
{
|
||||
return httpSecurity
|
||||
// CSRF禁用,因为不使用session
|
||||
.csrf(csrf -> csrf.disable())
|
||||
// 禁用HTTP响应标头
|
||||
.headers((headersCustomizer) -> {
|
||||
headersCustomizer.cacheControl(cache -> cache.disable()).frameOptions(options -> options.sameOrigin());
|
||||
})
|
||||
// 认证失败处理类
|
||||
.exceptionHandling(exception -> exception.authenticationEntryPoint(unauthorizedHandler))
|
||||
// 基于token,所以不需要session
|
||||
.sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
|
||||
// 注解标记允许匿名访问的url
|
||||
.authorizeHttpRequests((requests) -> {
|
||||
permitAllUrl.getUrls().forEach(url -> requests.requestMatchers(url).permitAll());
|
||||
// 对于登录login 注册register 验证码captchaImage 允许匿名访问
|
||||
requests.requestMatchers("/login", "/register", "/captchaImage").permitAll()
|
||||
// 静态资源,可匿名访问
|
||||
.requestMatchers(HttpMethod.GET, "/", "/*.html", "/**.html", "/**.css", "/**.js", "/profile/**").permitAll()
|
||||
.requestMatchers("/swagger-ui.html", "/v3/api-docs/**", "/swagger-ui/**", "/druid/**").permitAll()
|
||||
.requestMatchers("/api/**","/api2wms/**","api2erp/**").permitAll()
|
||||
// 除上面外的所有请求全部需要鉴权认证
|
||||
.anyRequest().authenticated();
|
||||
})
|
||||
// 添加Logout filter
|
||||
.logout(logout -> logout.logoutUrl("/logout").logoutSuccessHandler(logoutSuccessHandler))
|
||||
// 添加JWT filter
|
||||
.addFilterBefore(authenticationTokenFilter, UsernamePasswordAuthenticationFilter.class)
|
||||
// 添加CORS filter
|
||||
.addFilterBefore(corsFilter, JwtAuthenticationTokenFilter.class)
|
||||
.addFilterBefore(corsFilter, LogoutFilter.class)
|
||||
.build();
|
||||
// CSRF禁用,因为不使用session
|
||||
.csrf(csrf -> csrf.disable())
|
||||
// 禁用HTTP响应标头
|
||||
.headers((headersCustomizer) -> {
|
||||
headersCustomizer.cacheControl(cache -> cache.disable()).frameOptions(options -> options.sameOrigin());
|
||||
})
|
||||
// 认证失败处理类
|
||||
.exceptionHandling(exception -> exception.authenticationEntryPoint(unauthorizedHandler))
|
||||
// 基于token,所以不需要session
|
||||
.sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
|
||||
// 注解标记允许匿名访问的url
|
||||
.authorizeHttpRequests((requests) -> {
|
||||
permitAllUrl.getUrls().forEach(url -> requests.requestMatchers(url).permitAll());
|
||||
// 对于登录login 注册register 验证码captchaImage 允许匿名访问
|
||||
requests.requestMatchers("/login", "/register", "/captchaImage", "/system/license/active").permitAll()
|
||||
// 静态资源,可匿名访问
|
||||
.requestMatchers(HttpMethod.GET, "/", "/*.html", "/**.html", "/**.css", "/**.js", "/profile/**").permitAll()
|
||||
.requestMatchers("/swagger-ui.html", "/v3/api-docs/**", "/swagger-ui/**", "/druid/**").permitAll()
|
||||
.requestMatchers("/api/**","/api2wms/**","api2erp/**").permitAll()
|
||||
// 除上面外的所有请求全部需要鉴权认证
|
||||
.anyRequest().authenticated();
|
||||
})
|
||||
// 添加Logout filter
|
||||
.logout(logout -> logout.logoutUrl("/logout").logoutSuccessHandler(logoutSuccessHandler))
|
||||
// 添加JWT filter
|
||||
.addFilterBefore(authenticationTokenFilter, UsernamePasswordAuthenticationFilter.class)
|
||||
// 添加CORS filter
|
||||
.addFilterBefore(corsFilter, JwtAuthenticationTokenFilter.class)
|
||||
.addFilterBefore(corsFilter, LogoutFilter.class)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
270
ruoyi-license/CHANGES.md
Normal file
270
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
ruoyi-license/DEPLOYMENT_CHECKLIST.md
Normal file
250
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
ruoyi-license/INTEGRATION.md
Normal file
231
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
ruoyi-license/LICENSE_FILTER_CONFIG.md
Normal file
168
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
ruoyi-license/README.md
Normal file
193
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
ruoyi-license/SUMMARY.md
Normal file
239
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
|
||||
45
ruoyi-license/pom.xml
Normal file
45
ruoyi-license/pom.xml
Normal file
@@ -0,0 +1,45 @@
|
||||
<?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.9.0</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>
|
||||
|
||||
<!-- 框架模块-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-framework</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringBoot Web-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -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,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,46 @@
|
||||
package com.ruoyi.license.interceptor;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.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_INTERNAL_SERVER_ERROR);
|
||||
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,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,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,267 @@
|
||||
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;
|
||||
import com.ruoyi.system.service.ISysConfigService;
|
||||
|
||||
/**
|
||||
* 授权码Service业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Service
|
||||
public class SysLicenseServiceImpl implements ISysLicenseService
|
||||
{
|
||||
@Autowired
|
||||
private SysLicenseMapper sysLicenseMapper;
|
||||
|
||||
@Autowired
|
||||
private ISysConfigService sysConfigService;
|
||||
|
||||
@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 = sysConfigService.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 = sysConfigService.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 = sysConfigService.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,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,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,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>
|
||||
@@ -1,5 +1,5 @@
|
||||
# 页面标题
|
||||
VUE_APP_TITLE = "ForTucky WMS system"
|
||||
VUE_APP_TITLE = "艾度 WMS system"
|
||||
|
||||
# 开发环境配置
|
||||
ENV = 'development'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# 页面标题
|
||||
VUE_APP_TITLE = "ForTucky WMS system"
|
||||
VUE_APP_TITLE = "艾度 WMS system"
|
||||
|
||||
# 生产环境配置
|
||||
ENV = 'production'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# 页面标题
|
||||
VUE_APP_TITLE = "ForTucky WMS system"
|
||||
VUE_APP_TITLE = "艾度 WMS system"
|
||||
|
||||
BABEL_ENV = production
|
||||
|
||||
|
||||
44
ruoyi-ui/src/api/agvPoint/point.js
Normal file
44
ruoyi-ui/src/api/agvPoint/point.js
Normal file
@@ -0,0 +1,44 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 查询agv站点管理列表
|
||||
export function listPoint(query) {
|
||||
return request({
|
||||
url: '/bas/agvPoint/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询agv站点管理详细
|
||||
export function getPoint(id) {
|
||||
return request({
|
||||
url: '/bas/agvPoint' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增agv站点管理
|
||||
export function addPoint(data) {
|
||||
return request({
|
||||
url: '/bas/agvPoint',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改agv站点管理
|
||||
export function updatePoint(data) {
|
||||
return request({
|
||||
url: '/bas/agvPoint',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除agv站点管理
|
||||
export function delPoint(id) {
|
||||
return request({
|
||||
url: '/bas/agvPoint' + id,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
40
ruoyi-ui/src/api/license.js
Normal file
40
ruoyi-ui/src/api/license.js
Normal file
@@ -0,0 +1,40 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export function listLicense(query) {
|
||||
return request({
|
||||
url: '/system/license/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
export function delLicense(ids) {
|
||||
return request({
|
||||
url: '/system/license/remove',
|
||||
method: 'post',
|
||||
params: { ids }
|
||||
})
|
||||
}
|
||||
|
||||
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'
|
||||
})
|
||||
}
|
||||
|
||||
export function generateLicense(type, projectNo) {
|
||||
return request({
|
||||
url: '/system/license/generate',
|
||||
method: 'get',
|
||||
params: { type, projectNo }
|
||||
})
|
||||
}
|
||||
@@ -9,6 +9,30 @@ export function listLog(query) {
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
export function getMethod() {
|
||||
return request({
|
||||
url: '/requestInterface/log/getMethod',
|
||||
method: 'get'
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
export function getSource() {
|
||||
return request({
|
||||
url: '/requestInterface/log/getSource',
|
||||
method: 'get'
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
export function getTarget() {
|
||||
return request({
|
||||
url: '/requestInterface/log/getTarget',
|
||||
method: 'get'
|
||||
|
||||
})
|
||||
}
|
||||
// 查询接口记录详细
|
||||
export function getLog(requestId) {
|
||||
return request({
|
||||
|
||||
@@ -10,10 +10,11 @@ export function listManagement(query) {
|
||||
}
|
||||
|
||||
// 查询库存信息详细
|
||||
export function getManagement(stockId) {
|
||||
export function getManagement(stockId, warehouseCode) {
|
||||
return request({
|
||||
url: '/stock/management/' + stockId,
|
||||
method: 'get'
|
||||
method: 'get',
|
||||
params: {"warehouseCode": warehouseCode}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -45,12 +46,14 @@ export function updateManagement(data) {
|
||||
}
|
||||
|
||||
// 删除库存信息
|
||||
export function delManagement(stockId) {
|
||||
export function delManagement(stockId, warehouseCode) {
|
||||
return request({
|
||||
url: '/stock/management/' + stockId,
|
||||
method: 'delete'
|
||||
method: 'delete',
|
||||
params: {"warehouseCode": warehouseCode}
|
||||
})
|
||||
}
|
||||
|
||||
//重置盘点记录
|
||||
export function resetPdRecord() {
|
||||
return request({
|
||||
|
||||
@@ -36,7 +36,7 @@ export default {
|
||||
pageSizes: {
|
||||
type: Array,
|
||||
default() {
|
||||
return [10, 20, 30, 50]
|
||||
return [10, 50, 100, 1000]
|
||||
}
|
||||
},
|
||||
// 移动端页码按钮的数量端默认值5
|
||||
|
||||
@@ -5,6 +5,11 @@
|
||||
<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" />
|
||||
@@ -48,6 +53,7 @@ import Hamburger from '@/components/Hamburger'
|
||||
import Screenfull from '@/components/Screenfull'
|
||||
import SizeSelect from '@/components/SizeSelect'
|
||||
import Search from '@/components/HeaderSearch'
|
||||
import { getLicenseInfo } from '@/api/license'
|
||||
// import RuoYiGit from '@/components/RuoYi/Git'
|
||||
// import RuoYiDoc from '@/components/RuoYi/Doc'
|
||||
|
||||
@@ -63,6 +69,13 @@ export default {
|
||||
// RuoYiGit,
|
||||
// RuoYiDoc
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
licenseWarning: false,
|
||||
licenseExpireText: '',
|
||||
licenseTimer: null
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters([
|
||||
'sidebar',
|
||||
@@ -81,7 +94,41 @@ export default {
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.checkLicenseExpire()
|
||||
this.licenseTimer = setInterval(this.checkLicenseExpire, 60 * 1000)
|
||||
},
|
||||
beforeDestroy() {
|
||||
if (this.licenseTimer) {
|
||||
clearInterval(this.licenseTimer)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
checkLicenseExpire() {
|
||||
getLicenseInfo().then(response => {
|
||||
this.licenseWarning = false
|
||||
this.licenseExpireText = ''
|
||||
if (response.code !== 200 || !response.data || !response.data.expireTime) {
|
||||
return
|
||||
}
|
||||
const expireTime = new Date(response.data.expireTime).getTime()
|
||||
const diffMs = expireTime - Date.now()
|
||||
const diffDays = Math.ceil(diffMs / (1000 * 60 * 60 * 24))
|
||||
if (diffMs <= 0 || diffDays > 30) {
|
||||
return
|
||||
}
|
||||
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(() => {})
|
||||
},
|
||||
toggleSideBar() {
|
||||
this.$store.dispatch('app/toggleSideBar')
|
||||
},
|
||||
@@ -113,6 +160,27 @@ export default {
|
||||
color: var(--navbar-color, #5a5e66);
|
||||
box-shadow: 0 1px 4px rgba(0,21,41,.08);
|
||||
|
||||
.license-warning {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 0;
|
||||
max-width: calc(100% - 420px);
|
||||
height: 44px;
|
||||
overflow: hidden;
|
||||
color: #e6a23c;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
line-height: 44px;
|
||||
pointer-events: none;
|
||||
text-overflow: ellipsis;
|
||||
transform: translateX(-50%);
|
||||
white-space: nowrap;
|
||||
|
||||
i {
|
||||
margin-right: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
.hamburger-container {
|
||||
line-height: 46px;
|
||||
height: 100%;
|
||||
|
||||
@@ -45,6 +45,10 @@ const user = {
|
||||
const password = userInfo.password
|
||||
const code = userInfo.code
|
||||
const uuid = userInfo.uuid
|
||||
removeToken()
|
||||
commit('SET_TOKEN', '')
|
||||
commit('SET_ROLES', [])
|
||||
commit('SET_PERMISSIONS', [])
|
||||
return new Promise((resolve, reject) => {
|
||||
login(username, password, code, uuid).then(res => {
|
||||
setToken(res.token)
|
||||
@@ -85,14 +89,18 @@ const user = {
|
||||
// 退出系统
|
||||
LogOut({ commit, state }) {
|
||||
return new Promise((resolve, reject) => {
|
||||
logout(state.token).then(() => {
|
||||
const clearLocalSession = () => {
|
||||
commit('SET_TOKEN', '')
|
||||
commit('SET_ROLES', [])
|
||||
commit('SET_PERMISSIONS', [])
|
||||
removeToken()
|
||||
}
|
||||
logout(state.token).then(() => {
|
||||
clearLocalSession()
|
||||
resolve()
|
||||
}).catch(error => {
|
||||
reject(error)
|
||||
clearLocalSession()
|
||||
resolve()
|
||||
})
|
||||
})
|
||||
},
|
||||
@@ -101,6 +109,8 @@ const user = {
|
||||
FedLogOut({ commit }) {
|
||||
return new Promise(resolve => {
|
||||
commit('SET_TOKEN', '')
|
||||
commit('SET_ROLES', [])
|
||||
commit('SET_PERMISSIONS', [])
|
||||
removeToken()
|
||||
resolve()
|
||||
})
|
||||
|
||||
@@ -74,19 +74,19 @@ service.interceptors.request.use(config => {
|
||||
// 响应拦截器
|
||||
service.interceptors.response.use(res => {
|
||||
// 未设置状态码则默认成功状态
|
||||
const code = res.status|| 200
|
||||
const code = res.data && res.data.code !== undefined ? res.data.code : (res.status || 200)
|
||||
// 获取错误信息
|
||||
const msg = errorCode[code] || res.data.msg || errorCode['default']
|
||||
// 二进制数据则直接返回
|
||||
if (res.request.responseType === 'blob' || res.request.responseType === 'arraybuffer') {
|
||||
return res.data
|
||||
}
|
||||
if (code === 401) {
|
||||
if (code === 401 || res.status === 401) {
|
||||
if (!isRelogin.show) {
|
||||
isRelogin.show = true
|
||||
MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', { confirmButtonText: '重新登录', cancelButtonText: '取消', type: 'warning' }).then(() => {
|
||||
isRelogin.show = false
|
||||
store.dispatch('LogOut').then(() => {
|
||||
store.dispatch('FedLogOut').then(() => {
|
||||
location.href = '/index'
|
||||
})
|
||||
}).catch(() => {
|
||||
|
||||
314
ruoyi-ui/src/views/agvPoint/point/index.vue
Normal file
314
ruoyi-ui/src/views/agvPoint/point/index.vue
Normal file
@@ -0,0 +1,314 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="站点" prop="station">
|
||||
<el-input
|
||||
v-model="queryParams.station"
|
||||
placeholder="请输入站点"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="站点类型" prop="type">
|
||||
<el-select v-model="queryParams.type" placeholder="请选择单据来源" clearable>
|
||||
<el-option
|
||||
v-for="item in typeOption"
|
||||
:key="item.label"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="1" prop="spare2">-->
|
||||
<!-- <el-input-->
|
||||
<!-- v-model="queryParams.spare2"-->
|
||||
<!-- placeholder="请输入1"-->
|
||||
<!-- clearable-->
|
||||
<!-- @keyup.enter.native="handleQuery"-->
|
||||
<!-- />-->
|
||||
<!-- </el-form-item>-->
|
||||
<!-- <el-form-item label="1" prop="spare3">-->
|
||||
<!-- <el-input-->
|
||||
<!-- v-model="queryParams.spare3"-->
|
||||
<!-- placeholder="请输入1"-->
|
||||
<!-- clearable-->
|
||||
<!-- @keyup.enter.native="handleQuery"-->
|
||||
<!-- />-->
|
||||
<!-- </el-form-item>-->
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="el-icon-plus"
|
||||
size="mini"
|
||||
@click="handleAdd"
|
||||
v-hasPermi="['agvPoint:point:add']"
|
||||
>新增</el-button>
|
||||
</el-col>
|
||||
<!-- <el-col :span="1.5">-->
|
||||
<!-- <el-button-->
|
||||
<!-- type="success"-->
|
||||
<!-- plain-->
|
||||
<!-- icon="el-icon-edit"-->
|
||||
<!-- size="mini"-->
|
||||
<!-- :disabled="single"-->
|
||||
<!-- @click="handleUpdate"-->
|
||||
<!-- v-hasPermi="['agvPoint:point:edit']"-->
|
||||
<!-- >修改</el-button>-->
|
||||
<!-- </el-col>-->
|
||||
<!-- <el-col :span="1.5">-->
|
||||
<!-- <el-button-->
|
||||
<!-- type="danger"-->
|
||||
<!-- plain-->
|
||||
<!-- icon="el-icon-delete"-->
|
||||
<!-- size="mini"-->
|
||||
<!-- :disabled="multiple"-->
|
||||
<!-- @click="handleDelete"-->
|
||||
<!-- v-hasPermi="['agvPoint:point:remove']"-->
|
||||
<!-- >删除</el-button>-->
|
||||
<!-- </el-col>-->
|
||||
<!-- <el-col :span="1.5">-->
|
||||
<!-- <el-button-->
|
||||
<!-- type="warning"-->
|
||||
<!-- plain-->
|
||||
<!-- icon="el-icon-download"-->
|
||||
<!-- size="mini"-->
|
||||
<!-- @click="handleExport"-->
|
||||
<!-- v-hasPermi="['agvPoint:point:export']"-->
|
||||
<!-- >导出</el-button>-->
|
||||
<!-- </el-col>-->
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="pointList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="序号" align="center" prop="id" />
|
||||
<el-table-column label="站点" align="center" prop="station" />
|
||||
<!-- <el-table-column label="站点类型" align="center" prop="type" />-->
|
||||
<el-table-column label="站点类型" align="center" prop="type" >
|
||||
<template slot-scope="scope">
|
||||
<!-- if 判断:type=1 显示入库,type=2 显示出库 -->
|
||||
<span v-if="scope.row.type === '1'">源站</span>
|
||||
<span v-else-if="scope.row.type === '2'">目标站</span>
|
||||
<!-- 兜底:其他值显示未知类型,避免空白 -->
|
||||
<span v-else>未知类型</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- <el-table-column label="1" align="center" prop="remark" />-->
|
||||
<!-- <el-table-column label="1" align="center" prop="spare1" />-->
|
||||
<!-- <el-table-column label="1" align="center" prop="spare2" />-->
|
||||
<!-- <el-table-column label="1" align="center" prop="spare3" />-->
|
||||
<!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">-->
|
||||
<!-- <template slot-scope="scope">-->
|
||||
<!-- <el-button-->
|
||||
<!-- size="mini"-->
|
||||
<!-- type="text"-->
|
||||
<!-- icon="el-icon-edit"-->
|
||||
<!-- @click="handleUpdate(scope.row)"-->
|
||||
<!-- v-hasPermi="['agvPoint:point:edit']"-->
|
||||
<!-- >修改</el-button>-->
|
||||
<!-- <el-button-->
|
||||
<!-- size="mini"-->
|
||||
<!-- type="text"-->
|
||||
<!-- icon="el-icon-delete"-->
|
||||
<!-- @click="handleDelete(scope.row)"-->
|
||||
<!-- v-hasPermi="['agvPoint:point:remove']"-->
|
||||
<!-- >删除</el-button>-->
|
||||
<!-- </template>-->
|
||||
<!-- </el-table-column>-->
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total>0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
|
||||
<!-- 添加或修改agv站点管理对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="站点" prop="station">
|
||||
<el-input v-model="form.station" placeholder="请输入站点" />
|
||||
</el-form-item>
|
||||
<el-form-item label="站点类型" prop="type">
|
||||
<el-select v-model="form.type" placeholder="请选择站点类型" clearable>
|
||||
<el-option
|
||||
v-for="item in typeOption"
|
||||
:key="item.label"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="1" prop="spare1">-->
|
||||
<!-- <el-input v-model="form.spare1" placeholder="请输入1" />-->
|
||||
<!-- </el-form-item>-->
|
||||
<!-- <el-form-item label="1" prop="spare2">-->
|
||||
<!-- <el-input v-model="form.spare2" placeholder="请输入1" />-->
|
||||
<!-- </el-form-item>-->
|
||||
<!-- <el-form-item label="1" prop="spare3">-->
|
||||
<!-- <el-input v-model="form.spare3" placeholder="请输入1" />-->
|
||||
<!-- </el-form-item>-->
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listPoint, getPoint, delPoint, addPoint, updatePoint } from "@/api/agvPoint/point"
|
||||
|
||||
export default {
|
||||
name: "Point",
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// agv站点管理表格数据
|
||||
pointList: [],
|
||||
typeOption:[{label:'源站',value:'1'},{label:'目标站',value:'2'}],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
station: null,
|
||||
type: null,
|
||||
spare1: null,
|
||||
spare2: null,
|
||||
spare3: null
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getList()
|
||||
},
|
||||
methods: {
|
||||
/** 查询agv站点管理列表 */
|
||||
getList() {
|
||||
this.loading = true
|
||||
listPoint(this.queryParams).then(response => {
|
||||
this.pointList = response.rows
|
||||
this.total = response.total
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false
|
||||
this.reset()
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
id: null,
|
||||
station: null,
|
||||
type: null,
|
||||
remark: null,
|
||||
spare1: null,
|
||||
spare2: null,
|
||||
spare3: null
|
||||
}
|
||||
this.resetForm("form")
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1
|
||||
this.getList()
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm")
|
||||
this.handleQuery()
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.id)
|
||||
this.single = selection.length!==1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.reset()
|
||||
this.open = true
|
||||
this.title = "添加agv站点管理"
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.reset()
|
||||
const id = row.id || this.ids
|
||||
getPoint(id).then(response => {
|
||||
this.form = response.data
|
||||
this.open = true
|
||||
this.title = "修改agv站点管理"
|
||||
})
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
if (this.form.id != null) {
|
||||
updatePoint(this.form).then(response => {
|
||||
this.$modal.msgSuccess("修改成功")
|
||||
this.open = false
|
||||
this.getList()
|
||||
})
|
||||
} else {
|
||||
addPoint(this.form).then(response => {
|
||||
this.$modal.msgSuccess("新增成功")
|
||||
this.open = false
|
||||
this.getList()
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const ids = row.id || this.ids
|
||||
this.$modal.confirm('是否确认删除agv站点管理编号为"' + ids + '"的数据项?').then(function() {
|
||||
return delPoint(ids)
|
||||
}).then(() => {
|
||||
this.getList()
|
||||
this.$modal.msgSuccess("删除成功")
|
||||
}).catch(() => {})
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
this.download('agvPoint/point/export', {
|
||||
...this.queryParams
|
||||
}, `point_${new Date().getTime()}.xlsx`)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -1,22 +1,22 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" >
|
||||
<!-- <el-form-item label="格式ID" prop="formatId">-->
|
||||
<!--<!– <el-input-->
|
||||
<!-- v-model="queryParams.formatId"-->
|
||||
<!-- placeholder="请输入格式ID"-->
|
||||
<!-- clearable-->
|
||||
<!-- @keyup.enter.native="handleQuery"-->
|
||||
<!-- />–>-->
|
||||
<!-- <el-select v-model="queryParams.formatId" placeholder="请选择格式ID">-->
|
||||
<!-- <el-option-->
|
||||
<!-- v-for="item in traycodeFormatList"-->
|
||||
<!-- :key="item.id"-->
|
||||
<!-- :label="item.remarks"-->
|
||||
<!-- :value="item.id"-->
|
||||
<!-- />-->
|
||||
<!-- </el-select>-->
|
||||
<!-- </el-form-item>-->
|
||||
<!-- <el-form-item label="格式ID" prop="formatId">-->
|
||||
<!--<!– <el-input-->
|
||||
<!-- v-model="queryParams.formatId"-->
|
||||
<!-- placeholder="请输入格式ID"-->
|
||||
<!-- clearable-->
|
||||
<!-- @keyup.enter.native="handleQuery"-->
|
||||
<!-- />–>-->
|
||||
<!-- <el-select v-model="queryParams.formatId" placeholder="请选择格式ID">-->
|
||||
<!-- <el-option-->
|
||||
<!-- v-for="item in traycodeFormatList"-->
|
||||
<!-- :key="item.id"-->
|
||||
<!-- :label="item.remarks"-->
|
||||
<!-- :value="item.id"-->
|
||||
<!-- />-->
|
||||
<!-- </el-select>-->
|
||||
<!-- </el-form-item>-->
|
||||
<el-form-item label="条码" prop="trayCode">
|
||||
<el-input
|
||||
v-model="queryParams.trayCode"
|
||||
@@ -101,16 +101,16 @@
|
||||
|
||||
<el-table ref="table" v-loading="loading" :data="traycodeList" @selection-change="handleSelectionChange" max-height="700">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<!-- <el-table-column label="序号" align="center" prop="id" />-->
|
||||
<!-- <el-table-column label="格式ID" align="left" prop="formatName" />-->
|
||||
<!-- <el-table-column label="序号" align="center" prop="id" />-->
|
||||
<!-- <el-table-column label="格式ID" align="left" prop="formatName" />-->
|
||||
<el-table-column label="条码" align="center" prop="trayCode" />
|
||||
<!-- <el-table-column label="Spare Field 1" align="center" prop="spare1" />-->
|
||||
<!-- <el-table-column label="Spare Field 1" align="center" prop="spare1" />-->
|
||||
<el-table-column label="是否可用" align="center" prop="spare2" >
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.sys_yes_no" :value="scope.row.spare2"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- <el-table-column label="Spare Field 3" align="center" prop="spare3" />-->
|
||||
<!-- <el-table-column label="Spare Field 3" align="center" prop="spare3" />-->
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" >
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
@@ -161,7 +161,7 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="数量" prop="spare1" v-if="form.id == null">
|
||||
<el-form-item label="数量" prop="spare1" v-if="form.id == null">
|
||||
<el-input v-model="form.spare1" placeholder="请输入数量" />
|
||||
</el-form-item>
|
||||
<el-form-item label="托盘编码" prop="trayCode" v-if="form.id != null" >
|
||||
@@ -187,14 +187,27 @@
|
||||
|
||||
|
||||
<!-- 打印模板 -->
|
||||
<!-- <vue-easy-print v-show="true" ref="easyPrint2">-->
|
||||
<!-- <div v-for="item in printData" :key="item.id" style="page-break-after:always" class="vue-easy-print">-->
|
||||
<!-- <vue-barcode-->
|
||||
<!-- :value=item.trayCode-->
|
||||
<!-- format="CODE39"-->
|
||||
<!-- width="2"-->
|
||||
<!-- height="100"-->
|
||||
<!-- display-value-->
|
||||
<!-- margin="2"-->
|
||||
<!-- />-->
|
||||
<!-- </div>-->
|
||||
<!-- </vue-easy-print>-->
|
||||
<vue-easy-print v-show="true" ref="easyPrint2">
|
||||
<div v-for="item in printData" :key="item.id" style="page-break-after:always" class="vue-easy-print">
|
||||
<vue-barcode
|
||||
:value=item.trayCode
|
||||
format="CODE39"
|
||||
width="2"
|
||||
height="100"
|
||||
format="CODE128"
|
||||
width="4"
|
||||
height="150"
|
||||
display-value
|
||||
margin="5"
|
||||
/>
|
||||
</div>
|
||||
</vue-easy-print>
|
||||
@@ -205,6 +218,7 @@
|
||||
import { listTraycode, getTraycode, delTraycode, addTraycode, updateTraycode } from "@/api/bas/traycode"
|
||||
import { listTraycodeFormat } from "@/api/bas/traycodeFormat"
|
||||
import vueEasyPrint from 'vue-easy-print'
|
||||
import VueQr from 'vue-qr'
|
||||
import VueBarcode from 'vue-barcode'
|
||||
|
||||
export default {
|
||||
@@ -450,6 +464,11 @@ export default {
|
||||
font-family: Arial, sans-serif;
|
||||
}
|
||||
|
||||
.vue-qr {
|
||||
display: block;
|
||||
margin: 20px auto;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
@media print {
|
||||
@page {
|
||||
@@ -462,7 +481,7 @@ export default {
|
||||
}
|
||||
|
||||
.vue-easy-print {
|
||||
padding: 5px;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.num {
|
||||
@@ -470,5 +489,8 @@ export default {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.vue-qr {
|
||||
margin: 10px auto;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
474
ruoyi-ui/src/views/bas/traycode/index1.vue
Normal file
474
ruoyi-ui/src/views/bas/traycode/index1.vue
Normal file
@@ -0,0 +1,474 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" >
|
||||
<!-- <el-form-item label="格式ID" prop="formatId">-->
|
||||
<!--<!– <el-input-->
|
||||
<!-- v-model="queryParams.formatId"-->
|
||||
<!-- placeholder="请输入格式ID"-->
|
||||
<!-- clearable-->
|
||||
<!-- @keyup.enter.native="handleQuery"-->
|
||||
<!-- />–>-->
|
||||
<!-- <el-select v-model="queryParams.formatId" placeholder="请选择格式ID">-->
|
||||
<!-- <el-option-->
|
||||
<!-- v-for="item in traycodeFormatList"-->
|
||||
<!-- :key="item.id"-->
|
||||
<!-- :label="item.remarks"-->
|
||||
<!-- :value="item.id"-->
|
||||
<!-- />-->
|
||||
<!-- </el-select>-->
|
||||
<!-- </el-form-item>-->
|
||||
<el-form-item label="条码" prop="trayCode">
|
||||
<el-input
|
||||
v-model="queryParams.trayCode"
|
||||
placeholder="请输入条码"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="是否可用" prop="spare2">
|
||||
<el-select v-model="queryParams.spare2" placeholder="请选择">
|
||||
<el-option
|
||||
v-for="dict in dict.type.sys_yes_no"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="el-icon-plus"
|
||||
size="mini"
|
||||
@click="handleAdd"
|
||||
v-hasPermi="['bas:traycode:add']"
|
||||
>新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
icon="el-icon-edit"
|
||||
size="mini"
|
||||
:disabled="single"
|
||||
@click="handleUpdate"
|
||||
v-hasPermi="['bas:traycode:edit']"
|
||||
>修改</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
icon="el-icon-delete"
|
||||
size="mini"
|
||||
:disabled="multiple"
|
||||
@click="handleDelete"
|
||||
v-hasPermi="['bas:traycode:remove']"
|
||||
>删除</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
plain
|
||||
icon="el-icon-download"
|
||||
size="mini"
|
||||
@click="handleExport"
|
||||
v-hasPermi="['bas:traycode:export']"
|
||||
>导出</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="info"
|
||||
plain
|
||||
icon="el-icon-printer"
|
||||
size="mini"
|
||||
:disabled="multiple"
|
||||
@click="handleBatchPrint"
|
||||
v-hasPermi="['bas:traycode:print']"
|
||||
>批量打印</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table ref="table" v-loading="loading" :data="traycodeList" @selection-change="handleSelectionChange" max-height="700">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<!-- <el-table-column label="序号" align="center" prop="id" />-->
|
||||
<!-- <el-table-column label="格式ID" align="left" prop="formatName" />-->
|
||||
<el-table-column label="条码" align="center" prop="trayCode" />
|
||||
<!-- <el-table-column label="Spare Field 1" align="center" prop="spare1" />-->
|
||||
<el-table-column label="是否可用" align="center" prop="spare2" >
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.sys_yes_no" :value="scope.row.spare2"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- <el-table-column label="Spare Field 3" align="center" prop="spare3" />-->
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" >
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-edit"
|
||||
@click="handleUpdate(scope.row)"
|
||||
v-hasPermi="['bas:traycode:edit']"
|
||||
>修改</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
v-hasPermi="['bas:traycode:remove']"
|
||||
>删除</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-printer"
|
||||
@click="printBarcode(scope.row)"
|
||||
v-hasPermi="['bas:traycode:print']"
|
||||
>打印</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total>0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
|
||||
|
||||
<!-- 添加或修改条码信息对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
|
||||
<el-form-item label="格式ID" prop="formatId">
|
||||
<el-select v-model="form.formatId" placeholder="请选择格式ID">
|
||||
<el-option
|
||||
v-for="item in traycodeFormatList"
|
||||
:key="item.id"
|
||||
:label="item.remarks"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="数量" prop="spare1" v-if="form.id == null">
|
||||
<el-input v-model="form.spare1" placeholder="请输入数量" />
|
||||
</el-form-item>
|
||||
<el-form-item label="托盘编码" prop="trayCode" v-if="form.id != null" >
|
||||
|
||||
<el-input v-model="form.trayCode" placeholder="请输入托盘编码" disabled/>
|
||||
</el-form-item>
|
||||
<el-form-item label="是否可用" prop="spare2" v-if="form.id != null">
|
||||
<el-select v-model="form.spare2" placeholder="请选择" >
|
||||
<el-option
|
||||
v-for="dict in dict.type.sys_yes_no"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确定</el-button>
|
||||
<el-button @click="cancel">取消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
|
||||
<!-- 打印模板 -->
|
||||
<vue-easy-print v-show="true" ref="easyPrint2">
|
||||
<div v-for="item in printData" :key="item.id" style="page-break-after:always" class="vue-easy-print">
|
||||
<vue-barcode
|
||||
:value=item.trayCode
|
||||
format="CODE39"
|
||||
width="2"
|
||||
height="100"
|
||||
display-value
|
||||
/>
|
||||
</div>
|
||||
</vue-easy-print>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listTraycode, getTraycode, delTraycode, addTraycode, updateTraycode } from "@/api/bas/traycode"
|
||||
import { listTraycodeFormat } from "@/api/bas/traycodeFormat"
|
||||
import vueEasyPrint from 'vue-easy-print'
|
||||
import VueBarcode from 'vue-barcode'
|
||||
|
||||
export default {
|
||||
name: "Traycode",
|
||||
dicts:['sys_yes_no'],
|
||||
components: {
|
||||
vueEasyPrint,
|
||||
VueQr,
|
||||
VueBarcode
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 设置标题
|
||||
title: this.$t('traycode.title'),
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 条码信息表格数据
|
||||
traycodeList: [],
|
||||
traycodeFormatList: [],
|
||||
printData:[],
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
formatId: null,
|
||||
trayCode: null,
|
||||
spare1: null,
|
||||
spare2: null,
|
||||
spare3: null
|
||||
},
|
||||
queryTrayCodeFormatParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 99,
|
||||
},
|
||||
// Form parameters
|
||||
form: {},
|
||||
// Form validation
|
||||
rules: {
|
||||
formatId: [
|
||||
{ required: true, message: "请输入格式ID", trigger: "blur" }
|
||||
],
|
||||
trayCode: [
|
||||
{ required: true, message: "请输入托盘编码", trigger: "blur" }
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getTrayCodeFormatList()
|
||||
this.getList()
|
||||
},
|
||||
methods: {
|
||||
/** 查询条码信息列表 */
|
||||
getTrayCodeFormatList() {
|
||||
this.loading = true
|
||||
listTraycodeFormat(this.queryTrayCodeFormatParams).then(response => {
|
||||
this.traycodeFormatList = response.rows
|
||||
this.total = response.total
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
/** 查询条码信息列表 */
|
||||
getList() {
|
||||
this.loading = true
|
||||
listTraycode(this.queryParams).then(response => {
|
||||
this.traycodeList = response.rows
|
||||
this.total = response.total
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false
|
||||
this.reset()
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
id: null,
|
||||
formatId: null,
|
||||
trayCode: null,
|
||||
createTime: null,
|
||||
updateTime: null,
|
||||
spare1: null,
|
||||
spare2: null,
|
||||
spare3: null
|
||||
}
|
||||
this.resetForm("form")
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1
|
||||
this.getList()
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm")
|
||||
this.handleQuery()
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.id)
|
||||
this.single = selection.length!==1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.reset()
|
||||
this.open = true
|
||||
this.title = "新增托盘编码"
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.reset()
|
||||
const id = row.id || this.ids
|
||||
getTraycode(id).then(response => {
|
||||
this.form = response.data
|
||||
this.open = true
|
||||
this.title = "修改托盘编码"
|
||||
})
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
if (this.form.id != null) {
|
||||
updateTraycode(this.form).then(response => {
|
||||
this.$modal.msgSuccess("修改成功")
|
||||
this.open = false
|
||||
this.getList()
|
||||
})
|
||||
} else {
|
||||
addTraycode(this.form).then(response => {
|
||||
this.$modal.msgSuccess("添加成功")
|
||||
this.open = false
|
||||
this.getList()
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const ids = row.id || this.ids
|
||||
this.$modal.confirm('是否确认删除选中的数据项?').then(function() {
|
||||
return delTraycode(ids)
|
||||
}).then(() => {
|
||||
this.getList()
|
||||
this.$modal.msgSuccess("删除成功")
|
||||
}).catch(() => {})
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
this.download('bas/traycode/export', {
|
||||
...this.queryParams
|
||||
}, `traycode_${new Date().getTime()}.xlsx`)
|
||||
},
|
||||
/** 打印条码 */
|
||||
printBarcode: function (row) {
|
||||
const yesValItem = (this.dict && this.dict.type && this.dict.type.sys_yes_no) ? (this.dict.type.sys_yes_no.find(i => i.label === '是') || this.dict.type.sys_yes_no.find(i => i.value === 'Y' || i.value === '1')) : null
|
||||
const yesVal = yesValItem ? yesValItem.value : 'Y'
|
||||
if (row.spare2 !== yesVal) {
|
||||
this.$modal.msgError("该托盘不可打印:仅“是”可用")
|
||||
return;
|
||||
}
|
||||
this.printData = [row]
|
||||
this.$nextTick(() => {
|
||||
setTimeout(() => {
|
||||
this.$refs.easyPrint2.print()
|
||||
const noValItem = (this.dict && this.dict.type && this.dict.type.sys_yes_no) ? (this.dict.type.sys_yes_no.find(i => i.label === '否') || this.dict.type.sys_yes_no.find(i => i.value === 'N' || i.value === '0')) : null
|
||||
const noVal = noValItem ? noValItem.value : 'N'
|
||||
const data = Object.assign({}, row, { spare2: noVal })
|
||||
updateTraycode(data).then(() => {
|
||||
this.$modal.msgSuccess("打印完成,已标记为不可用")
|
||||
this.getList()
|
||||
}).catch(() => {})
|
||||
}, 100)
|
||||
})
|
||||
},
|
||||
/** 批量打印按钮操作 */
|
||||
handleBatchPrint() {
|
||||
const selection = this.$refs.table.selection;
|
||||
if (selection.length === 0) {
|
||||
this.$modal.msgError("请选择要打印的数据项");
|
||||
return;
|
||||
}
|
||||
const yesValItem = (this.dict && this.dict.type && this.dict.type.sys_yes_no) ? (this.dict.type.sys_yes_no.find(i => i.label === '是') || this.dict.type.sys_yes_no.find(i => i.value === 'Y' || i.value === '1')) : null
|
||||
const yesVal = yesValItem ? yesValItem.value : 'Y'
|
||||
const invalid = selection.filter(item => item.spare2 !== yesVal)
|
||||
if (invalid.length > 0) {
|
||||
this.$modal.msgError("存在不可打印项(非“是”),请重新选择")
|
||||
return;
|
||||
}
|
||||
this.printData = selection;
|
||||
this.$nextTick(() => {
|
||||
setTimeout(() => {
|
||||
this.$refs.easyPrint2.print()
|
||||
const noValItem = (this.dict && this.dict.type && this.dict.type.sys_yes_no) ? (this.dict.type.sys_yes_no.find(i => i.label === '否') || this.dict.type.sys_yes_no.find(i => i.value === 'N' || i.value === '0')) : null
|
||||
const noVal = noValItem ? noValItem.value : 'N'
|
||||
const updates = selection.map(item => {
|
||||
const data = Object.assign({}, item, { spare2: noVal })
|
||||
return updateTraycode(data)
|
||||
})
|
||||
Promise.all(updates).then(() => {
|
||||
this.$modal.msgSuccess("批量打印完成,已标记为不可用")
|
||||
this.getList()
|
||||
}).catch(() => {})
|
||||
}, 100)
|
||||
});
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
/* 统一表单控件宽度 */
|
||||
.el-select,
|
||||
.el-input {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* 打印样式 */
|
||||
.vue-easy-print {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.num {
|
||||
display: block;
|
||||
text-align: center;
|
||||
font-size: 16px;
|
||||
margin-top: 15px;
|
||||
font-family: Arial, sans-serif;
|
||||
}
|
||||
|
||||
|
||||
@media print {
|
||||
@page {
|
||||
size: 80mm 50mm;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.vue-easy-print {
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.num {
|
||||
font-size: 14px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
}
|
||||
</style>
|
||||
@@ -1,6 +1,11 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="仓库" prop="warehouseId">
|
||||
<el-select v-model="queryParams.warehouseId" placeholder="请选择仓库" clearable>
|
||||
<el-option v-for="item in warehouseOptions" :key="item.warehouseId" :label="item.warehouseName" :value="item.warehouseId" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="作业状态" prop="status">
|
||||
<el-select v-model="queryParams.status" placeholder="请选择任务状态" clearable>
|
||||
@@ -293,13 +298,16 @@ export default {
|
||||
created() {
|
||||
// 获取字典数据后,设置默认值
|
||||
this.getList()
|
||||
//this.getWarehouseList()
|
||||
this.getWarehouseList()
|
||||
},
|
||||
methods: {
|
||||
/** 获取仓库列表 */
|
||||
getWarehouseList() {
|
||||
listWarehouse(this.queryWarehouseParams).then(response => {
|
||||
this.warehouseOptions = response.rows;
|
||||
this.warehouseOptions = [
|
||||
{ warehouseId: '01', warehouseName: '立库' },
|
||||
{ warehouseId: '02', warehouseName: '平库' }
|
||||
];
|
||||
if (this.warehouseOptions.length > 0) {
|
||||
this.handleQuery();
|
||||
}
|
||||
@@ -433,7 +441,7 @@ export default {
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
this.download('job/mydoJob/export', {
|
||||
this.download('job/inmydoJob/export', {
|
||||
...this.queryParams
|
||||
}, `mydoJob_${new Date().getTime()}.xlsx`)
|
||||
},
|
||||
|
||||
@@ -31,25 +31,42 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="项目号" prop="departmentNo">
|
||||
<el-form-item label="项目号" prop="spare4">
|
||||
<el-input
|
||||
v-model="queryParams.departmentNo"
|
||||
v-model="queryParams.spare4"
|
||||
placeholder="请输入项目号"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="合同号" prop="spare1">
|
||||
</el-form-item>
|
||||
<el-form-item label="条码号" prop="stockinDetailId">
|
||||
<el-input
|
||||
v-model="queryParams.spare1"
|
||||
placeholder="请输入合同号"
|
||||
v-model="queryParams.stockinDetailId"
|
||||
placeholder="请输入条码号"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="销售订单号" prop="spare2">
|
||||
<el-form-item label="组件号" prop="cargoNo">
|
||||
<el-input
|
||||
v-model="queryParams.cargoNo"
|
||||
placeholder="请输入组件号"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
|
||||
</el-form-item>
|
||||
<el-form-item label="wms单据号" prop="stockinId">
|
||||
<el-input
|
||||
v-model="queryParams.spare2"
|
||||
v-model="queryParams.stockinId"
|
||||
placeholder="请输入单据号"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="erp单据号" prop="erpBill">
|
||||
<el-input
|
||||
v-model="queryParams.erpBill"
|
||||
placeholder="请输入销售订单号"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
@@ -65,15 +82,25 @@
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="批次号" prop="lotNo"><!--品名-->
|
||||
<el-form-item label="存货编码" prop="productId"><!--品名-->
|
||||
<el-input
|
||||
v-model="queryParams.lotNo"
|
||||
placeholder="请输入批次号"
|
||||
v-model="queryParams.productId"
|
||||
placeholder="请输入存货编码"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
|
||||
<!-- <el-form-item label="批次号" prop="lotNo"><!–品名–>-->
|
||||
<!-- <el-input-->
|
||||
<!-- v-model="queryParams.lotNo"-->
|
||||
<!-- placeholder="请输入批次号"-->
|
||||
<!-- clearable-->
|
||||
<!-- @keyup.enter.native="handleQuery"-->
|
||||
<!-- />-->
|
||||
<!-- </el-form-item>-->
|
||||
|
||||
<el-form-item :label="'单据时间'" prop="dateRange">
|
||||
<el-date-picker
|
||||
v-model="dateRange"
|
||||
@@ -170,23 +197,14 @@
|
||||
<el-table v-loading="loading" :data="stockInList" @selection-change="handleSelectionChange"
|
||||
@row-click="handleRowClick" max-height="400">
|
||||
<el-table-column type="selection" width="55" align="center"/>
|
||||
<el-table-column label="序号" width="60" align="center">
|
||||
<template slot-scope="scope">
|
||||
{{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="GUID" align="center" prop="stockinGuid" v-if="false"/>
|
||||
<el-table-column label="入库单据号" align="left" prop="stockinId" width="150" sortable/><!--入库订单-->
|
||||
<el-table-column label="单据类型" align="left" prop="inType"><!--入库类型-->
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.in_bill_type" :value="scope.row.inType"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="单据状态" align="left" prop="status"><!--单据状态-->
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.in_bill_status" :value="scope.row.status"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="单据来源" align="left" prop="stockSource"><!--单据来源-->
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.bill_resource" :value="scope.row.stockSource"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="erp单据号" align="left" prop="erpBill" width="150" sortable/>
|
||||
<el-table-column label="仓库" align="left" prop="warehouseName"/><!--仓库-->
|
||||
<el-table-column label="供应商代码" align="left" prop="supplierNo"/><!--仓库-->
|
||||
<el-table-column label="供应商名称" align="left" prop="classNo" /><!--供应商-->
|
||||
@@ -219,8 +237,8 @@
|
||||
<el-table-column label="单位" align="left" prop="unit"/><!--机型-->
|
||||
<el-table-column label="规格型号" align="left" prop="spec"/><!--规格-->
|
||||
<el-table-column label="层级关系" align="left" prop="spare1"/><!--型号-->
|
||||
<el-table-column label="上层物料" align="left" prop="spare2"/><!--净重-->
|
||||
<el-table-column label="顶层物料" align="left" prop="spare3"/><!--颜色-->
|
||||
<el-table-column label="组件号" align="left" prop="cargoNo"/><!--净重-->
|
||||
<el-table-column label="项目号" align="left" prop="spare4"/><!--颜色-->
|
||||
<el-table-column label="计划数量" align="left" prop="quantity" sortable/><!--计划数量-->
|
||||
<el-table-column label="扫码数量" align="left" prop="scanNum" sortable/><!--扫码数量-->
|
||||
<el-table-column label="实际数量" align="left" prop="assignNum" sortable/><!--实际数量-->
|
||||
@@ -328,7 +346,10 @@ export default {
|
||||
spare2: null,
|
||||
spare4: null,
|
||||
spare3: null,
|
||||
spare5: null
|
||||
spare5: null,
|
||||
cargoNo:null,
|
||||
productId:null,
|
||||
stockinDetailId:null
|
||||
},
|
||||
queryDetailParams: {
|
||||
pageNum: 1,
|
||||
|
||||
@@ -60,6 +60,14 @@
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="项目号" prop="lineId">
|
||||
<el-input
|
||||
v-model="queryParams.lineId"
|
||||
placeholder="请输入存货编码"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="开始时间" prop="startTime"> <!-- 开始时间 -->
|
||||
<el-date-picker clearable
|
||||
v-model="queryParams.startTime"
|
||||
@@ -268,7 +276,10 @@ export default {
|
||||
getWarehouseOptions() {
|
||||
|
||||
listWarehouse().then(response => {
|
||||
this.warehouseOptions = response.rows;
|
||||
this.warehouseOptions = [
|
||||
{ warehouseId: '01', warehouseName: '立库' },
|
||||
{ warehouseId: '02', warehouseName: '平库' }
|
||||
];
|
||||
});
|
||||
},
|
||||
/** 查询任务表列表 */
|
||||
@@ -347,7 +358,7 @@ export default {
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
this.download('job/mydoJob/export', {
|
||||
this.download('job/outmydoJob/export', {
|
||||
...this.queryParams
|
||||
}, `mydoJob_${new Date().getTime()}.xlsx`)
|
||||
},
|
||||
|
||||
@@ -56,8 +56,18 @@
|
||||
<router-link class="link-type" :to="'/register'">立即注册</router-link>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item style="width:100%;">
|
||||
<el-button size="medium" type="warning" plain class="license-button" @click.native.prevent="openLicenseDialog">激活授权码</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
<el-dialog title="激活授权码" :visible.sync="licenseDialogVisible" width="420px" append-to-body>
|
||||
<el-input v-model="licenseCode" type="textarea" :rows="4" placeholder="请输入授权码" />
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="licenseDialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" :loading="licenseLoading" @click="handleActiveLicense">激 活</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
<!-- 底部 -->
|
||||
<div class="el-login-footer">
|
||||
<span>{{ $t('login.bottom') }}</span>
|
||||
@@ -70,6 +80,7 @@ import LangSelect from '@/components/LangSelect'
|
||||
import { getCodeImg } from "@/api/login";
|
||||
import Cookies from "js-cookie";
|
||||
import { encrypt, decrypt } from '@/utils/jsencrypt'
|
||||
import { activeLicense } from '@/api/license'
|
||||
|
||||
export default {
|
||||
name: "Login",
|
||||
@@ -98,7 +109,10 @@ export default {
|
||||
captchaEnabled: true,
|
||||
// 注册开关
|
||||
register: false,
|
||||
redirect: undefined
|
||||
redirect: undefined,
|
||||
licenseDialogVisible: false,
|
||||
licenseCode: '',
|
||||
licenseLoading: false
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
@@ -156,6 +170,30 @@ export default {
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
openLicenseDialog() {
|
||||
this.licenseCode = ''
|
||||
this.licenseDialogVisible = true
|
||||
},
|
||||
handleActiveLicense() {
|
||||
const licenseCode = this.licenseCode.trim()
|
||||
if (!licenseCode) {
|
||||
this.$message.warning('请输入授权码')
|
||||
return
|
||||
}
|
||||
this.licenseLoading = true
|
||||
activeLicense(licenseCode).then(response => {
|
||||
if (response.code === 200) {
|
||||
this.$message.success(response.msg || '授权码激活成功')
|
||||
this.licenseDialogVisible = false
|
||||
} else {
|
||||
this.$message.error(response.msg || '授权码激活失败')
|
||||
}
|
||||
}).catch(() => {
|
||||
this.$message.error('授权码激活失败')
|
||||
}).finally(() => {
|
||||
this.licenseLoading = false
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -177,7 +215,13 @@ export default {
|
||||
padding: 40px;
|
||||
padding-top: 50px;
|
||||
width: 480px;
|
||||
height: 500px;
|
||||
min-height: 560px;
|
||||
}
|
||||
|
||||
.license-button {
|
||||
width: 100%;
|
||||
height: 40px;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.title {
|
||||
|
||||
@@ -353,7 +353,13 @@ export default {
|
||||
pageNum: 1,
|
||||
pageSize: 100
|
||||
}).then(response => {
|
||||
this.warehouseOptions = response.rows;
|
||||
this.warehouseOptions = response.rows || [];
|
||||
if (!this.warehouseOptions.some(item => String(item.warehouseId) === '2')) {
|
||||
this.warehouseOptions.push({
|
||||
warehouseId: '2',
|
||||
warehouseName: '平库'
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
/** 打开客商选择弹窗 */
|
||||
|
||||
@@ -25,6 +25,14 @@
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="'erp单据号'" prop="erpStockoutId"> <!-- 出库单编号 -->
|
||||
<el-input
|
||||
v-model="queryParams.erpStockoutId"
|
||||
:placeholder="'请输入erp单据号'"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="'出库类型'" prop="outType"> <!-- 出库类型 -->
|
||||
<el-select v-model="queryParams.outType" :placeholder="'请选择出库类型'" clearable>
|
||||
<el-option
|
||||
@@ -53,6 +61,22 @@
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="'项目号'" prop="spare4">
|
||||
<el-input
|
||||
v-model="queryParams.spare4"
|
||||
:placeholder="'请输入项目号'"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="'存货编码'" prop="productId">
|
||||
<el-input
|
||||
v-model="queryParams.productId"
|
||||
:placeholder="'请输入存货编码'"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="'存货名称'" prop="productName">
|
||||
<el-input
|
||||
v-model="queryParams.productName"
|
||||
@@ -74,8 +98,9 @@
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">{{'搜索'}}</el-button> <!-- 搜索 -->
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{'重置'}}</el-button> <!-- 重置 -->
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">{{ '搜索' }}</el-button>
|
||||
<!-- 搜索 -->
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{ '重置' }}</el-button> <!-- 重置 -->
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
@@ -89,7 +114,8 @@
|
||||
size="mini"
|
||||
@click="handleAudit(2)"
|
||||
v-hasPermi="['out:outStockout:changeStatus']"
|
||||
>{{'单据审核'}}</el-button> <!-- 单据审核 -->
|
||||
>{{ '单据审核' }}
|
||||
</el-button> <!-- 单据审核 -->
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
@@ -99,7 +125,8 @@
|
||||
size="mini"
|
||||
@click="handleAudit(4)"
|
||||
v-hasPermi="['out:outStockout:changeStatus']"
|
||||
>{{'单据确认'}}</el-button> <!-- 单据确认 -->
|
||||
>{{ '单据确认' }}
|
||||
</el-button> <!-- 单据确认 -->
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
@@ -109,7 +136,8 @@
|
||||
size="mini"
|
||||
@click="handleAudit(5)"
|
||||
v-hasPermi="['out:outStockout:changeStatus']"
|
||||
>{{'单据作废'}}</el-button> <!-- 单据作废 -->
|
||||
>{{ '单据作废' }}
|
||||
</el-button> <!-- 单据作废 -->
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
@@ -119,7 +147,8 @@
|
||||
size="mini"
|
||||
@click="handleAutoAllot"
|
||||
v-hasPermi="['out:outStockout:autoAllot']"
|
||||
>{{'自动分配'}}</el-button> <!-- 自动分配 -->
|
||||
>{{ '自动分配' }}
|
||||
</el-button> <!-- 自动分配 -->
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
@@ -129,14 +158,22 @@
|
||||
size="mini"
|
||||
@click="handleManualAllot"
|
||||
v-hasPermi="['out:outStockout:manualAllot']"
|
||||
>{{'手动分配'}}</el-button> <!-- 手动分配 -->
|
||||
>{{ '手动分配' }}
|
||||
</el-button> <!-- 手动分配 -->
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<!-- 主表数据 -->
|
||||
<el-table v-loading="loading" :data="outStockoutList" @selection-change="handleSelectionChange" @row-click="handleRowClick" max-height="400">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column :label="'出库单编号'" align="left" prop="stockoutId" />
|
||||
<el-table v-loading="loading" :data="outStockoutList" @selection-change="handleSelectionChange"
|
||||
@row-click="handleRowClick" max-height="400">
|
||||
<el-table-column type="selection" width="55" align="center"/>
|
||||
<el-table-column label="序号" width="60" align="center">
|
||||
<template slot-scope="scope">
|
||||
{{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="'出库单编号'" align="left" prop="stockoutId"/>
|
||||
<el-table-column :label="'erp单据号'" align="left" prop="erpStockoutId"/>
|
||||
<el-table-column :label="'出库类型'" align="left" prop="outType">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.out_bill_type" :value="scope.row.outType"/>
|
||||
@@ -147,10 +184,11 @@
|
||||
<dict-tag :options="dict.type.out_bill_status" :value="scope.row.status"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="'项目号'" align="left" prop="departmentNo" />
|
||||
|
||||
<el-table-column :label="'项目号'" align="left" prop="departmentNo"/>
|
||||
<el-table-column :label="'客商代号'" align="left" prop="customerNo"/>
|
||||
<el-table-column :label="'客商名称'" align="left" prop="classNowId"/>
|
||||
<el-table-column :label="'建单人'" align="left" prop="createManId" />
|
||||
<el-table-column :label="'建单人'" align="left" prop="createManId"/>
|
||||
<el-table-column :label="'出库方式'" align="left" prop="carNumber">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.out_method" :value="scope.row.carNumber"/>
|
||||
@@ -161,16 +199,17 @@
|
||||
<dict-tag :options="dict.type.bill_resource" :value="scope.row.stockoutSource"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column :label="'仓库编码'" align="left" prop="warehouseId"/>
|
||||
<el-table-column :label="'仓库名称'" align="left" prop="warehouseName"/>
|
||||
<!-- <el-table-column :label="'合同号'" align="left" prop="spare1" />-->
|
||||
<!-- <el-table-column :label="'销售订单号'" align="left" prop="spare2" />-->
|
||||
<el-table-column :label="'审核时间'" align="left" prop="spare3" />
|
||||
<el-table-column :label="'审核人'" align="left" prop="spare4" />
|
||||
<el-table-column :label="'审核时间'" align="left" prop="spare3"/>
|
||||
<el-table-column :label="'审核人'" align="left" prop="spare4"/>
|
||||
<el-table-column :label="'创建时间'" align="left" prop="createDate" width="160" sortable/>
|
||||
<el-table-column :label="'开始时间'" align="left" prop="startDate" width="160" sortable/>
|
||||
<el-table-column :label="'确认时间'" align="left" prop="finishDate" width="160" sortable/>
|
||||
<el-table-column :label="'备注'" align="left" prop="spare5" />
|
||||
<el-table-column :label="'备注'" align="left" prop="spare5"/>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
@@ -182,11 +221,12 @@
|
||||
/>
|
||||
|
||||
<!-- 子表数据 -->
|
||||
<el-table v-loading="detailLoading" :data="outStockDetailList" style="margin-top: 20px;" @selection-change="handleDetailSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column :label="'出库子单编号'" align="center" prop="stockoutDetailId" width="160" /> <!-- 出库子单编号 -->
|
||||
<el-table v-loading="detailLoading" :data="outStockDetailList" style="margin-top: 20px;"
|
||||
@selection-change="handleDetailSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center"/>
|
||||
<el-table-column :label="'出库子单编号'" align="center" prop="stockoutDetailId" width="160"/> <!-- 出库子单编号 -->
|
||||
<el-table-column :label="'存货编码'" align="center" prop="productId" sortable/>
|
||||
<el-table-column :label="'存货名称'" align="center" prop="productName" />
|
||||
<el-table-column :label="'存货名称'" align="center" prop="productName"/>
|
||||
<el-table-column :label="'批次号'" align="center" prop="lotNo"/>
|
||||
<el-table-column :label="'供应商编码'" align="center" prop="fid"/>
|
||||
<el-table-column :label="'计量单位'" align="center" prop="unit"/>
|
||||
@@ -203,13 +243,13 @@
|
||||
<!-- <el-table-column :label="'备注'" align="center" prop="remark"/>-->
|
||||
</el-table>
|
||||
|
||||
<!-- <pagination-->
|
||||
<!-- v-show="detailTotal>0"-->
|
||||
<!-- :total="detailTotal"-->
|
||||
<!-- :page.sync="detailQueryParams.pageNum"-->
|
||||
<!-- :limit.sync="detailQueryParams.pageSize"-->
|
||||
<!-- @pagination="getDetailList"-->
|
||||
<!-- />-->
|
||||
<!-- <pagination-->
|
||||
<!-- v-show="detailTotal>0"-->
|
||||
<!-- :total="detailTotal"-->
|
||||
<!-- :page.sync="detailQueryParams.pageNum"-->
|
||||
<!-- :limit.sync="detailQueryParams.pageSize"-->
|
||||
<!-- @pagination="getDetailList"-->
|
||||
<!-- />-->
|
||||
|
||||
<!-- 审核弹窗 -->
|
||||
<el-dialog :title="'审核'" :visible.sync="auditDialogVisible" width="400px" append-to-body>
|
||||
@@ -226,8 +266,8 @@
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitAudit">{{"确认"}}</el-button>
|
||||
<el-button @click="cancelAudit">{{"取消"}}</el-button>
|
||||
<el-button type="primary" @click="submitAudit">{{ "确认" }}</el-button>
|
||||
<el-button @click="cancelAudit">{{ "取消" }}</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
@@ -237,7 +277,9 @@
|
||||
<el-row style="margin-bottom: 15px; padding: 10px; background-color: #f5f7fa; border-radius: 4px;">
|
||||
<el-col :span="8">
|
||||
<span style="font-weight: bold;">计划数量: </span>
|
||||
<span style="color: #409EFF; font-size: 16px;">{{ selectedDetailRows.length > 0 ? selectedDetailRows[0].quantity : 0 }}</span>
|
||||
<span style="color: #409EFF; font-size: 16px;">{{
|
||||
selectedDetailRows.length > 0 ? selectedDetailRows[0].quantity : 0
|
||||
}}</span>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<span style="font-weight: bold;">已选库存数量: </span>
|
||||
@@ -245,7 +287,9 @@
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<span style="font-weight: bold;">剩余可分配: </span>
|
||||
<span :style="{ color: remainingQuantity >= 0 ? '#67C23A' : '#F56C6C', fontSize: '16px' }">{{ remainingQuantity }}</span>
|
||||
<span :style="{ color: remainingQuantity >= 0 ? '#67C23A' : '#F56C6C', fontSize: '16px' }">{{
|
||||
remainingQuantity
|
||||
}}</span>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
@@ -283,27 +327,28 @@
|
||||
</el-form>
|
||||
|
||||
<!-- 库存明细表格 -->
|
||||
<el-table ref="stockTable" v-loading="stockLoading" :data="stockList" @selection-change="handleStockSelectionChange" max-height="400">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="库存编码" align="center" prop="stockId" />
|
||||
<el-table-column label="货位名称" align="center" prop="cargoSpaceName" />
|
||||
<el-table-column label="批次号" align="center" prop="lotNo" />
|
||||
<el-table-column label="品号" align="center" prop="productId" />
|
||||
<el-table-column label="品名" align="center" prop="productName" />
|
||||
<el-table-column label="数量" align="center" prop="quantity" width="80" />
|
||||
<el-table-column label="规格" align="center" prop="spare1" />
|
||||
<el-table-column label="单位" align="center" prop="spare3" />
|
||||
<el-table-column label="型号" align="center" prop="spare4" />
|
||||
<el-table-column label="颜色" align="center" prop="spare5" />
|
||||
<el-table-column label="序列号" align="center" prop="spare6" />
|
||||
<el-table-column label="电压" align="center" prop="voltage" />
|
||||
<el-table-column label="功率" align="center" prop="power" />
|
||||
<el-table-column label="相位" align="center" prop="phase" />
|
||||
<el-table-column label="净重" align="center" prop="netWeight" />
|
||||
<el-table-column label="毛重" align="center" prop="grossWeight" />
|
||||
<el-table-column label="分销" align="center" prop="distribution" />
|
||||
<el-table-column label="机型" align="center" prop="model" />
|
||||
<el-table-column label="订单号" align="center" prop="orderId" />
|
||||
<el-table ref="stockTable" v-loading="stockLoading" :data="stockList"
|
||||
@selection-change="handleStockSelectionChange" max-height="400">
|
||||
<el-table-column type="selection" width="55" align="center"/>
|
||||
<el-table-column label="库存编码" align="center" prop="stockId"/>
|
||||
<el-table-column label="货位名称" align="center" prop="cargoSpaceName"/>
|
||||
<el-table-column label="批次号" align="center" prop="lotNo"/>
|
||||
<el-table-column label="品号" align="center" prop="productId"/>
|
||||
<el-table-column label="品名" align="center" prop="productName"/>
|
||||
<el-table-column label="数量" align="center" prop="quantity" width="80"/>
|
||||
<el-table-column label="规格" align="center" prop="spare1"/>
|
||||
<el-table-column label="单位" align="center" prop="spare3"/>
|
||||
<el-table-column label="型号" align="center" prop="spare4"/>
|
||||
<el-table-column label="颜色" align="center" prop="spare5"/>
|
||||
<el-table-column label="序列号" align="center" prop="spare6"/>
|
||||
<el-table-column label="电压" align="center" prop="voltage"/>
|
||||
<el-table-column label="功率" align="center" prop="power"/>
|
||||
<el-table-column label="相位" align="center" prop="phase"/>
|
||||
<el-table-column label="净重" align="center" prop="netWeight"/>
|
||||
<el-table-column label="毛重" align="center" prop="grossWeight"/>
|
||||
<el-table-column label="分销" align="center" prop="distribution"/>
|
||||
<el-table-column label="机型" align="center" prop="model"/>
|
||||
<el-table-column label="订单号" align="center" prop="orderId"/>
|
||||
|
||||
</el-table>
|
||||
|
||||
@@ -342,7 +387,7 @@ export default {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
detailLoading: false,
|
||||
warehouseOptions:[],
|
||||
warehouseOptions: [],
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
@@ -374,13 +419,13 @@ export default {
|
||||
// 审核表单验证规则
|
||||
auditRules: {
|
||||
exitId: [
|
||||
{ required: true, message: '请选择出口', trigger: 'change' }
|
||||
{required: true, message: '请选择出口', trigger: 'change'}
|
||||
]
|
||||
},
|
||||
// 出口选项
|
||||
exitOptions: [
|
||||
{ exitId: '1', exitName: '一楼'},
|
||||
{ exitId: '2', exitName: '二楼'},
|
||||
{exitId: '1', exitName: '一楼'},
|
||||
{exitId: '2', exitName: '二楼'},
|
||||
|
||||
],
|
||||
|
||||
@@ -399,14 +444,17 @@ export default {
|
||||
productName: null,
|
||||
startDate: null,
|
||||
finishDate: null,
|
||||
status: null
|
||||
status: null,
|
||||
spare4: null,
|
||||
erpStockoutId: null,
|
||||
productId: null
|
||||
},
|
||||
// 子表分页参数
|
||||
detailQueryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 99,
|
||||
status:null,
|
||||
stockoutGuid:null
|
||||
status: null,
|
||||
stockoutGuid: null
|
||||
|
||||
},
|
||||
warehouseQueryParams: {
|
||||
@@ -432,7 +480,7 @@ export default {
|
||||
// 计算选中库存的总数量
|
||||
selectedStockQuantity() {
|
||||
return this.selectedStockRows.reduce((total, stock) => {
|
||||
console.log(total+ + (parseFloat(stock.quantity)))
|
||||
console.log(total + +(parseFloat(stock.quantity)))
|
||||
return total + (parseFloat(stock.quantity) || 0)
|
||||
}, 0)
|
||||
},
|
||||
@@ -466,7 +514,7 @@ export default {
|
||||
// 如果有数据,自动选中第一行
|
||||
if (this.outStockoutList.length > 0) {
|
||||
this.handleRowClick(this.outStockoutList[0]);
|
||||
}else {
|
||||
} else {
|
||||
this.outStockDetailList = []
|
||||
this.detailLoading = false
|
||||
}
|
||||
@@ -474,7 +522,7 @@ export default {
|
||||
})
|
||||
},
|
||||
/** 查询子表数据 */
|
||||
getDetailList(stockoutGuid,status) {
|
||||
getDetailList(stockoutGuid, status) {
|
||||
this.detailLoading = true
|
||||
this.detailQueryParams.stockoutGuid = stockoutGuid
|
||||
this.detailQueryParams.status = status
|
||||
@@ -510,7 +558,7 @@ export default {
|
||||
},
|
||||
/** 点击行加载明细数据 */
|
||||
handleRowClick(row) {
|
||||
this.getDetailList(row.stockoutGuid,row.status)
|
||||
this.getDetailList(row.stockoutGuid, row.status)
|
||||
},
|
||||
/** 多选框选中数据 */
|
||||
handleSelectionChange(selection) {
|
||||
@@ -527,22 +575,21 @@ export default {
|
||||
return
|
||||
}
|
||||
|
||||
for(var i=0;i<this.selectedRows.length;i++){
|
||||
if (this.selectedRows[i].status != "1" && status == 2) {
|
||||
this.$modal.msgError(this.selectedRows[i].stockoutId+'单据已审核')
|
||||
return
|
||||
}
|
||||
for (var i = 0; i < this.selectedRows.length; i++) {
|
||||
if (this.selectedRows[i].status != "1" && status == 2) {
|
||||
this.$modal.msgError(this.selectedRows[i].stockoutId + '单据已审核')
|
||||
return
|
||||
}
|
||||
|
||||
if (Number(this.selectedRows[i].status) < 3 && status == 4) {
|
||||
this.$modal.msgError(this.selectedRows[i].stockoutId+"单据未开始,无法确认")
|
||||
return
|
||||
if (Number(this.selectedRows[i].status) < 3 && status == 4) {
|
||||
this.$modal.msgError(this.selectedRows[i].stockoutId + "单据未开始,无法确认")
|
||||
return
|
||||
}
|
||||
if (this.selectedRows[i].status != "1" && status == 5) {
|
||||
this.$modal.msgError(this.selectedRows[i].stockoutId + '单据已审核,无法作废')
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (this.selectedRows[i].status != "1" && status == 5){
|
||||
this.$modal.msgError(this.selectedRows[i].stockoutId+'单据已审核,无法作废')
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 如果是审核操作(status=2),显示弹窗选择出口
|
||||
@@ -582,15 +629,16 @@ export default {
|
||||
let outstock = this.selectedRows[0]
|
||||
if (outstock.status != "2" && outstock.status != "3") {
|
||||
this.$modal.msgError('请先审核出库单')
|
||||
return
|
||||
return
|
||||
}
|
||||
let data = {
|
||||
stockoutId: stockoutIds[0]
|
||||
}
|
||||
console.log("进入自动分配")
|
||||
autoAllot(data).then(response => {
|
||||
if (response.code !== 200){
|
||||
if (response.code !== 200) {
|
||||
this.$modal.msgError(response.msg)
|
||||
}else {
|
||||
} else {
|
||||
this.$modal.msgSuccess(response.msg)
|
||||
}
|
||||
this.getList()
|
||||
@@ -607,7 +655,7 @@ export default {
|
||||
return
|
||||
}
|
||||
// 检查主表状态
|
||||
if(this.selectedRows.length >1){
|
||||
if (this.selectedRows.length > 1) {
|
||||
this.$modal.msgError('只能选择一条主表数据进行手动分配')
|
||||
return
|
||||
}
|
||||
@@ -624,7 +672,7 @@ export default {
|
||||
this.$modal.msgError('单据已结束,无法手动分配!')
|
||||
return
|
||||
}
|
||||
if(this.selectedDetailRows[0].allotQuantity==this.selectedDetailRows[0].quantity){
|
||||
if (this.selectedDetailRows[0].allotQuantity == this.selectedDetailRows[0].quantity) {
|
||||
this.$modal.msgError('该单据已分配完成,无法手动分配')
|
||||
return
|
||||
}
|
||||
@@ -645,7 +693,7 @@ export default {
|
||||
newStatus: this.currentAuditStatus,
|
||||
exitId: this.auditForm.exitId
|
||||
}
|
||||
// console.log("单据状态修改(含出口信息):", params)
|
||||
// console.log("单据状态修改(含出口信息):", params)
|
||||
|
||||
//调用单据状态改变接口
|
||||
updateOutStockStatus(params).then(response => {
|
||||
@@ -727,7 +775,7 @@ export default {
|
||||
},
|
||||
|
||||
/** 确认分配 */
|
||||
confirmStockAllot() {
|
||||
confirmStockAllot() {
|
||||
if (this.selectedStockRows.length === 0) {
|
||||
this.$modal.msgError('请选择要分配的库存')
|
||||
return
|
||||
@@ -755,19 +803,18 @@ export default {
|
||||
console.log('手动分配参数:', allotParams)
|
||||
// 这里添加实际的分配API调用
|
||||
manualAllot(allotParams).then(response => {
|
||||
if(response.code=="200"){
|
||||
if (response.code == "200") {
|
||||
this.$modal.msgSuccess('分配成功')
|
||||
this.stockDialogVisible = false
|
||||
this.getList()
|
||||
this.getDetailList(this.selectedRows[0].stockoutGuid, this.selectedRows[0].status)
|
||||
}else{
|
||||
} else {
|
||||
this.$modal.msgError(response.msg)
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
/** 取消分配 */
|
||||
@@ -778,8 +825,6 @@ export default {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -27,6 +27,44 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item :label="'接口名称'" prop="endpoint">
|
||||
<el-select v-model="queryParams.endpoint" :placeholder="'请选择接口名称'" clearable>
|
||||
<el-option
|
||||
v-for="item in methodOptions"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item :label="'源系统'" prop="sourceSystem">
|
||||
<el-select v-model="queryParams.sourceSystem" :placeholder="'请选择源系统'" clearable>
|
||||
<el-option
|
||||
v-for="item in sourceSystemOption"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
|
||||
<el-form-item :label="'目标系统'" prop="targetSystem">
|
||||
<el-select v-model="queryParams.targetSystem" :placeholder="'请选择目标系统'" clearable>
|
||||
<el-option
|
||||
v-for="item in targetSystemOption"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
|
||||
|
||||
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">{{ '搜索' }}</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{ '重置' }}</el-button>
|
||||
@@ -34,90 +72,29 @@
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<!-- <el-col :span="1.5">-->
|
||||
<!-- <el-button-->
|
||||
<!-- type="primary"-->
|
||||
<!-- plain-->
|
||||
<!-- icon="el-icon-plus"-->
|
||||
<!-- size="mini"-->
|
||||
<!-- @click="handleAdd"-->
|
||||
<!-- v-hasPermi="['requestInterface:log:add']"-->
|
||||
<!-- >新增</el-button>-->
|
||||
<!-- </el-col>-->
|
||||
<!-- <el-col :span="1.5">-->
|
||||
<!-- <el-button-->
|
||||
<!-- type="success"-->
|
||||
<!-- plain-->
|
||||
<!-- icon="el-icon-edit"-->
|
||||
<!-- size="mini"-->
|
||||
<!-- :disabled="single"-->
|
||||
<!-- @click="handleUpdate"-->
|
||||
<!-- v-hasPermi="['requestInterface:log:edit']"-->
|
||||
<!-- >修改</el-button>-->
|
||||
<!-- </el-col>-->
|
||||
<!-- <el-col :span="1.5">-->
|
||||
<!-- <el-button-->
|
||||
<!-- type="danger"-->
|
||||
<!-- plain-->
|
||||
<!-- icon="el-icon-delete"-->
|
||||
<!-- size="mini"-->
|
||||
<!-- :disabled="multiple"-->
|
||||
<!-- @click="handleDelete"-->
|
||||
<!-- v-hasPermi="['requestInterface:log:remove']"-->
|
||||
<!-- >删除</el-button>-->
|
||||
<!-- </el-col>-->
|
||||
<!-- <el-col :span="1.5">-->
|
||||
<!-- <el-button-->
|
||||
<!-- type="warning"-->
|
||||
<!-- plain-->
|
||||
<!-- icon="el-icon-download"-->
|
||||
<!-- size="mini"-->
|
||||
<!-- @click="handleExport"-->
|
||||
<!-- v-hasPermi="['requestInterface:log:export']"-->
|
||||
<!-- >导出</el-button>-->
|
||||
<!-- </el-col>-->
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="logList" @selection-change="handleSelectionChange" >
|
||||
<!-- <el-table-column type="selection" width="55" align="center" />-->
|
||||
<el-table-column width="120" :label="'请求ID'" align="left" prop="requestId" show-overflow-tooltip />
|
||||
<el-table-column width="160" :label="'请求时间'" align="left" prop="requestTime" show-overflow-tooltip />
|
||||
<el-table-column width="120" :label="'源系统'" align="left" prop="sourceSystem" show-overflow-tooltip />
|
||||
<el-table-column width="120" :label="'目标系统'" align="left" prop="targetSystem" show-overflow-tooltip />
|
||||
<el-table-column width="120" :label="'接口名称'" align="left" prop="endpoint" show-overflow-tooltip />
|
||||
<el-table-column width="300" :label="'请求URL'" align="left" prop="requestUrl" show-overflow-tooltip />
|
||||
<el-table-column width="120" :label="'请求方法'" align="left" prop="requestMethod" show-overflow-tooltip />
|
||||
<el-table-column width="120" :label="'请求头'" align="left" prop="requestHeaders" show-overflow-tooltip />
|
||||
<el-table-column width="300" :label="'请求体'" align="left" prop="requestBody" show-overflow-tooltip />
|
||||
<el-table-column width="160" :label="'响应时间'" align="left" prop="responseTime" show-overflow-tooltip />
|
||||
<el-table-column width="120" :label="'响应体'" align="left" prop="responseBody" show-overflow-tooltip />
|
||||
<el-table-column width="120" :label="'响应状态'" align="left" prop="responseStatus" show-overflow-tooltip />
|
||||
<el-table-column width="120" :label="'错误详情'" align="left" prop="errorDetails" show-overflow-tooltip />
|
||||
<el-table-column width="120" :label="'持续时间'" align="left" prop="duration" show-overflow-tooltip />
|
||||
<el-table v-loading="loading" :data="logList" @selection-change="handleSelectionChange">
|
||||
<el-table-column width="120" :label="'请求ID'" align="left" prop="requestId" show-overflow-tooltip/>
|
||||
<el-table-column width="160" :label="'请求时间'" align="left" sortable prop="requestTime" show-overflow-tooltip/>
|
||||
<el-table-column width="120" :label="'源系统'" align="left" prop="sourceSystem" show-overflow-tooltip/>
|
||||
<el-table-column width="120" :label="'目标系统'" align="left" prop="targetSystem" show-overflow-tooltip/>
|
||||
<el-table-column width="120" :label="'接口名称'" align="left" prop="endpoint" show-overflow-tooltip/>
|
||||
<el-table-column width="120" :label="'请求URL'" align="left" prop="requestUrl" show-overflow-tooltip/>
|
||||
<el-table-column width="120" :label="'请求方法'" align="left" prop="requestMethod" show-overflow-tooltip/>
|
||||
<!-- <el-table-column width="120" :label="'请求头'" align="left" prop="requestHeaders" show-overflow-tooltip/>-->
|
||||
<el-table-column width="300" :label="'请求体'" align="left" prop="requestBody" show-overflow-tooltip/>
|
||||
<el-table-column width="160" :label="'响应时间'" align="left" prop="responseTime" show-overflow-tooltip/>
|
||||
<el-table-column width="120" :label="'响应体'" align="left" prop="responseBody" show-overflow-tooltip/>
|
||||
<el-table-column width="120" :label="'响应状态'" align="left" prop="responseStatus" show-overflow-tooltip/>
|
||||
<!-- <el-table-column width="120" :label="'错误详情'" align="left" prop="errorDetails" show-overflow-tooltip/>-->
|
||||
<el-table-column width="120" :label="'持续时间'" align="left" prop="duration" show-overflow-tooltip/>
|
||||
<el-table-column width="120" :label="'是否成功'" align="left" prop="isSuccessful" show-overflow-tooltip>
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.is_available" :value="scope.row.isSuccessful"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">-->
|
||||
<!-- <template slot-scope="scope">-->
|
||||
<!-- <el-button-->
|
||||
<!-- size="mini"-->
|
||||
<!-- type="text"-->
|
||||
<!-- icon="el-icon-edit"-->
|
||||
<!-- @click="handleUpdate(scope.row)"-->
|
||||
<!-- v-hasPermi="['requestInterface:log:edit']"-->
|
||||
<!-- >修改</el-button>-->
|
||||
<!-- <el-button-->
|
||||
<!-- size="mini"-->
|
||||
<!-- type="text"-->
|
||||
<!-- icon="el-icon-delete"-->
|
||||
<!-- @click="handleDelete(scope.row)"-->
|
||||
<!-- v-hasPermi="['requestInterface:log:remove']"-->
|
||||
<!-- >删除</el-button>-->
|
||||
<!-- </template>-->
|
||||
<!-- </el-table-column>-->
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
@@ -132,34 +109,34 @@
|
||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item :label="'源系统'" prop="sourceSystem">
|
||||
<el-input v-model="form.sourceSystem" type="textarea" :placeholder="'请输入内容'" />
|
||||
<el-input v-model="form.sourceSystem" type="textarea" :placeholder="'请输入内容'"/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="'目标系统'" prop="targetSystem">
|
||||
<el-input v-model="form.targetSystem" type="textarea" :placeholder="'请输入内容'" />
|
||||
<el-input v-model="form.targetSystem" type="textarea" :placeholder="'请输入内容'"/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="'接口名称'" prop="endpoint">
|
||||
<el-input v-model="form.endpoint" type="textarea" :placeholder="'请输入内容'" />
|
||||
<el-input v-model="form.endpoint" type="textarea" :placeholder="'请输入内容'"/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="'请求URL'" prop="requestUrl">
|
||||
<el-input v-model="form.requestUrl" type="textarea" :placeholder="'请输入内容'" />
|
||||
<el-input v-model="form.requestUrl" type="textarea" :placeholder="'请输入内容'"/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="'请求方法'" prop="requestMethod">
|
||||
<el-input v-model="form.requestMethod" type="textarea" :placeholder="'请输入内容'" />
|
||||
<el-input v-model="form.requestMethod" type="textarea" :placeholder="'请输入内容'"/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="'请求头'" prop="requestHeaders">
|
||||
<el-input v-model="form.requestHeaders" type="textarea" :placeholder="'请输入内容'" />
|
||||
<el-input v-model="form.requestHeaders" type="textarea" :placeholder="'请输入内容'"/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="'请求体'" prop="requestBody">
|
||||
<el-input v-model="form.requestBody" :placeholder="'请输入请求参数'" />
|
||||
<el-input v-model="form.requestBody" :placeholder="'请输入请求参数'"/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="'响应体'" prop="responseBody">
|
||||
<el-input v-model="form.responseBody" type="textarea" :placeholder="'请输入内容'" />
|
||||
<el-input v-model="form.responseBody" type="textarea" :placeholder="'请输入内容'"/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="'错误详情'" prop="errorDetails">
|
||||
<el-input v-model="form.errorDetails" :placeholder="'请输入错误信息'" />
|
||||
<el-input v-model="form.errorDetails" :placeholder="'请输入错误信息'"/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="'持续时间'" prop="duration">
|
||||
<el-input v-model="form.duration" type="textarea" :placeholder="'请输入内容'" />
|
||||
<el-input v-model="form.duration" type="textarea" :placeholder="'请输入内容'"/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="'是否成功'" prop="isSuccessful">
|
||||
<el-select v-model="form.isSuccessful" :placeholder="'请选择是否成功'">
|
||||
@@ -181,32 +158,25 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listLog, getLog, delLog, addLog, updateLog } from "@/api/requestInterface/log"
|
||||
import {listLog, getLog, delLog, addLog, updateLog, getMethod, getSource, getTarget} from "@/api/requestInterface/log"
|
||||
|
||||
export default {
|
||||
name: "Log",
|
||||
dicts: ['is_available'],
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
methodOptions: [], // 下拉框选项
|
||||
sourceSystemOption:[],
|
||||
targetSystemOption:[],
|
||||
total: 0,
|
||||
// 接口记录表格数据
|
||||
logList: [],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
@@ -225,15 +195,15 @@ export default {
|
||||
duration: null,
|
||||
isSuccessful: null
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {
|
||||
}
|
||||
rules: {}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getList()
|
||||
this.getMethod() // 现在可以正常调用了
|
||||
this.getSource()
|
||||
this.getTarget()
|
||||
},
|
||||
methods: {
|
||||
/** 查询接口记录列表 */
|
||||
@@ -245,6 +215,43 @@ export default {
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
// ✅ 【核心修复】getMethod 移入 methods 内部
|
||||
getMethod() {
|
||||
getMethod().then(response => {
|
||||
console.log("接口返回:", response.data)
|
||||
// 后端返回 String数组,转换为 el-select 需要的 label/value 格式
|
||||
this.methodOptions = response.data.map(item => ({
|
||||
label: item,
|
||||
value: item
|
||||
}))
|
||||
}).catch(err => {
|
||||
console.error("获取方法列表失败:", err)
|
||||
})
|
||||
},
|
||||
getSource() {
|
||||
getSource().then(response => {
|
||||
console.log("接口返回:", response.data)
|
||||
// 后端返回 String数组,转换为 el-select 需要的 label/value 格式
|
||||
this.sourceSystemOption = response.data.map(item => ({
|
||||
label: item,
|
||||
value: item
|
||||
}))
|
||||
}).catch(err => {
|
||||
console.error("获取方法列表失败:", err)
|
||||
})
|
||||
},
|
||||
getTarget() {
|
||||
getTarget().then(response => {
|
||||
console.log("接口返回:", response.data)
|
||||
// 后端返回 String数组,转换为 el-select 需要的 label/value 格式
|
||||
this.targetSystemOption = response.data.map(item => ({
|
||||
label: item,
|
||||
value: item
|
||||
}))
|
||||
}).catch(err => {
|
||||
console.error("获取方法列表失败:", err)
|
||||
})
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false
|
||||
@@ -284,7 +291,7 @@ export default {
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.requestId)
|
||||
this.single = selection.length!==1
|
||||
this.single = selection.length !== 1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
@@ -326,12 +333,13 @@ export default {
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const requestIds = row.requestId || this.ids
|
||||
this.$modal.confirm('是否确认删除接口记录编号为"' + requestIds + '"的数据项?').then(function() {
|
||||
this.$modal.confirm('是否确认删除接口记录编号为"' + requestIds + '"的数据项?').then(function () {
|
||||
return delLog(requestIds)
|
||||
}).then(() => {
|
||||
this.getList()
|
||||
this.$modal.msgSuccess("删除成功")
|
||||
}).catch(() => {})
|
||||
}).catch(() => {
|
||||
})
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
@@ -342,3 +350,6 @@ export default {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
</style>
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="仓库" prop="warehouseId">
|
||||
<el-select v-model="queryParams.warehouseId" placeholder="请选择仓库" clearable>
|
||||
<el-option v-for="item in warehouseOptions" :key="item.warehouseId" :label="item.warehouseName" :value="item.warehouseId" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="作业ID" prop="jobId">
|
||||
<el-input
|
||||
v-model="queryParams.jobId"
|
||||
@@ -702,6 +707,10 @@ export default {
|
||||
total: 0,
|
||||
// 入库作业流水表格数据
|
||||
ViewInJobFlowList: [],
|
||||
warehouseOptions: [
|
||||
{ warehouseId: '01', warehouseName: '立库' },
|
||||
{ warehouseId: '02', warehouseName: '平库' }
|
||||
],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="仓库" prop="warehouseId">
|
||||
<el-select v-model="queryParams.warehouseId" placeholder="请选择仓库" clearable>
|
||||
<el-option v-for="item in warehouseOptions" :key="item.warehouseId" :label="item.warehouseName" :value="item.warehouseId" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="作业ID" prop="jobId">
|
||||
<el-input
|
||||
v-model="queryParams.jobId"
|
||||
@@ -701,6 +706,10 @@ export default {
|
||||
total: 0,
|
||||
// 出库作业流水表格数据
|
||||
ViewOutJobFlowList: [],
|
||||
warehouseOptions: [
|
||||
{ warehouseId: '01', warehouseName: '立库' },
|
||||
{ warehouseId: '02', warehouseName: '平库' }
|
||||
],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
|
||||
@@ -25,6 +25,43 @@
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="托盘条码" prop="trayCode"><!-- 货位id -->
|
||||
<el-input
|
||||
v-model="queryParams.trayCode"
|
||||
placeholder="请输入托盘条码"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="项目号" prop="spare4"><!-- 货位id -->
|
||||
<el-input
|
||||
v-model="queryParams.spare4"
|
||||
placeholder="请输入组件号"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="存货编码" prop="productId"><!-- 货位id -->
|
||||
<el-input
|
||||
v-model="queryParams.productId"
|
||||
placeholder="请输入存货编码"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="托盘类型" prop="ktpType"><!-- 库存状态 -->
|
||||
<el-select v-model="queryParams.ktpType" placeholder="请选择托盘类型" clearable>
|
||||
<el-option
|
||||
v-for="item in ktpType"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="库存状态" prop="stockStatus"><!-- 库存状态 -->
|
||||
<el-select v-model="queryParams.stockStatus" placeholder="请选择库存状态" clearable>
|
||||
<el-option
|
||||
@@ -36,14 +73,36 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<!-- <el-form-item label="入库时间" prop="startDate"><!– 入库时间 –>
|
||||
<el-date-picker clearable
|
||||
v-model="queryParams.inDate"
|
||||
type="date"
|
||||
value-format="yyyy-MM-dd"
|
||||
placeholder="请选择入库时间">
|
||||
</el-date-picker>
|
||||
</el-form-item>-->
|
||||
|
||||
<el-form-item label="物料类型" prop="model"><!--单据来源-->
|
||||
<el-select v-model="queryParams.model" placeholder="请选择单据来源" clearable>
|
||||
<el-option
|
||||
v-for="dict in productType"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="仓库选择" prop="warehouseCode"><!--单据来源-->
|
||||
<el-select v-model="queryParams.warehouseCode" placeholder="请选择单据来源" clearable>
|
||||
<el-option
|
||||
v-for="item in warehouseCodeOptions"
|
||||
:key="item.label"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<!-- <el-form-item label="入库时间" prop="startDate"><!– 入库时间 –>
|
||||
<el-date-picker clearable
|
||||
v-model="queryParams.inDate"
|
||||
type="date"
|
||||
value-format="yyyy-MM-dd"
|
||||
placeholder="请选择入库时间">
|
||||
</el-date-picker>
|
||||
</el-form-item>-->
|
||||
|
||||
|
||||
<el-form-item label="存货名称" prop="productName"><!-- 存货名称 -->
|
||||
@@ -99,36 +158,36 @@
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="managementList" @selection-change="handleSelectionChange" max-height="650">
|
||||
<el-table-column type="selection" align="center" />
|
||||
<el-table-column type="selection" align="center"/>
|
||||
<el-table-column label="库存编码" align="left" prop="stockId" width="180" sortable/>
|
||||
<el-table-column label="货位名称" align="left" prop="cargoSpaceName" width="180"/>
|
||||
<el-table-column width="180" label="库存状态" align="center" prop="stockStatus" >
|
||||
<el-table-column width="180" label="库存状态" align="center" prop="stockStatus">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.stock_status" :value="scope.row.stockStatus"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column width="180" label="物料编码" align="left" prop="productId" />
|
||||
<el-table-column width="180" label="物料名称" align="left" prop="productName" />
|
||||
<el-table-column width="180" label="批次号" align="left" prop="lotNo" />
|
||||
<!-- <el-table-column label="订单号" align="center" prop="orderId" width="160" sortable/>-->
|
||||
<el-table-column width="180" label="入库时间" align="left" prop="inDate" sortable/>
|
||||
<el-table-column width="180" label="物料编码" align="left" prop="productId"/>
|
||||
<el-table-column width="180" label="物料名称" align="left" prop="productName"/>
|
||||
<el-table-column width="180" label="批次号" align="left" prop="lotNo"/>
|
||||
<!-- <el-table-column label="订单号" align="center" prop="orderId" width="160" sortable/>-->
|
||||
<el-table-column width="180" label="入库时间" align="left" prop="inDate" sortable/>
|
||||
<el-table-column width="100" label="数量" align="left" prop="quantity" sortable/>
|
||||
<el-table-column width="180" label="作业ID" align="left" prop="jobId" sortable/>
|
||||
<el-table-column width="180" label="出库数量" align="left" prop="outQuantity" />
|
||||
<el-table-column width="180" label="入库单ID" align="left" prop="stockinId" sortable/>
|
||||
<el-table-column width="180" label="作业ID" align="left" prop="jobId" sortable/>
|
||||
<el-table-column width="180" label="出库数量" align="left" prop="outQuantity"/>
|
||||
<el-table-column width="180" label="入库单ID" align="left" prop="stockinId" sortable/>
|
||||
<el-table-column width="180" label="入库子单ID" align="left" prop="stockinDetailId" sortable/>
|
||||
<!-- <el-table-column label="入库类型" align="center" prop="inType" />-->
|
||||
<!-- <el-table-column label="仓库编码" align="center" prop="warehouseId" />-->
|
||||
<el-table-column width="180" label="层级关系" align="left" prop="spare1" />
|
||||
<el-table-column width="180" label="上层物料" align="left" prop="spare2" />
|
||||
<el-table-column width="180" label="顶层物料" align="left" prop="spare3" />
|
||||
<el-table-column width="180" label="项目号" align="left" prop="spare4" />
|
||||
<el-table-column width="180" label="合同号" align="left" prop="spare5" />
|
||||
<el-table-column width="180" label="销售订单" align="left" prop="spare6" />
|
||||
<el-table-column width="180" label="供应商编码" align="left" prop="voltage" />
|
||||
<el-table-column width="180" label="规格型号" align="left" prop="power" />
|
||||
<el-table-column width="180" label="计量单位" align="left" prop="phase" />
|
||||
<!-- <el-table-column label="净重" align="center" prop="netWeight" />-->
|
||||
<!-- <el-table-column label="入库类型" align="center" prop="inType" />-->
|
||||
<!-- <el-table-column label="仓库编码" align="center" prop="warehouseId" />-->
|
||||
<el-table-column width="180" label="托盘条码" align="left" prop="trayCode"/>
|
||||
<!-- <el-table-column width="180" label="上层物料" align="left" prop="spare2"/>-->
|
||||
<!-- <el-table-column width="180" label="顶层物料" align="left" prop="spare3"/>-->
|
||||
<el-table-column width="180" label="项目号" align="left" prop="spare4"/>
|
||||
<!-- <el-table-column width="180" label="合同号" align="left" prop="spare5"/>-->
|
||||
<!-- <el-table-column width="180" label="销售订单" align="left" prop="spare6"/>-->
|
||||
<el-table-column width="180" label="供应商编码" align="left" prop="voltage"/>
|
||||
<el-table-column width="180" label="规格型号" align="left" prop="power"/>
|
||||
<el-table-column width="180" label="计量单位" align="left" prop="phase"/>
|
||||
<!-- <el-table-column label="净重" align="center" prop="netWeight" />-->
|
||||
<el-table-column width=120 label="操作" align="center" class-name="small-padding fixed-width"> <!-- 操作 -->
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
@@ -160,12 +219,12 @@
|
||||
<!-- 添加或修改库存信息对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
<!-- <el-form-item label="库存ID" prop="stockId"> <!– 库存id –>-->
|
||||
<!-- <el-input v-model="form.stockId" placeholder="请输入库存ID" />-->
|
||||
<!-- </el-form-item>-->
|
||||
<!-- <el-form-item label="货位ID" prop="cargoSpaceId"> <!– 货位id –>-->
|
||||
<!-- <el-input v-model="form.cargoSpaceId" placeholder="请输入货位ID" />-->
|
||||
<!-- </el-form-item>-->
|
||||
<!-- <el-form-item label="库存ID" prop="stockId"> <!– 库存id –>-->
|
||||
<!-- <el-input v-model="form.stockId" placeholder="请输入库存ID" />-->
|
||||
<!-- </el-form-item>-->
|
||||
<!-- <el-form-item label="货位ID" prop="cargoSpaceId"> <!– 货位id –>-->
|
||||
<!-- <el-input v-model="form.cargoSpaceId" placeholder="请输入货位ID" />-->
|
||||
<!-- </el-form-item>-->
|
||||
|
||||
<el-form-item label="物料" prop="productId"> <!-- 物料 -->
|
||||
<el-input
|
||||
@@ -207,7 +266,7 @@
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="库存数量" prop="quantity"> <!-- 库存数量 -->
|
||||
<el-input v-model="form.quantity" placeholder="请输入库存数量" />
|
||||
<el-input v-model="form.quantity" placeholder="请输入库存数量"/>
|
||||
</el-form-item>
|
||||
|
||||
</el-form>
|
||||
@@ -248,11 +307,11 @@
|
||||
@row-click="handleProductRowClick"
|
||||
highlight-current-row
|
||||
max-height="400">
|
||||
<el-table-column label="品号" align="center" prop="productId" />
|
||||
<el-table-column label="品名" align="center" prop="productName" />
|
||||
<el-table-column label="规格" align="center" prop="spec" />
|
||||
<el-table-column label="型号" align="center" prop="spare1" />
|
||||
<el-table-column label="单位" align="center" prop="unit" />
|
||||
<el-table-column label="品号" align="center" prop="productId"/>
|
||||
<el-table-column label="品名" align="center" prop="productName"/>
|
||||
<el-table-column label="规格" align="center" prop="spec"/>
|
||||
<el-table-column label="型号" align="center" prop="spare1"/>
|
||||
<el-table-column label="单位" align="center" prop="unit"/>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
@@ -288,7 +347,7 @@
|
||||
@keyup.enter.native="getCargoSpaceList"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="仓库" prop="warehouseId">
|
||||
<el-form-item label="仓库" prop="warehouseCode">
|
||||
<el-select v-model="cargoSpaceQueryParams.warehouseId" placeholder="请选择仓库" clearable>
|
||||
<el-option
|
||||
v-for="item in warehouseOptions"
|
||||
@@ -310,17 +369,17 @@
|
||||
@row-click="handleCargoSpaceRowClick"
|
||||
highlight-current-row
|
||||
max-height="400">
|
||||
<el-table-column label="货位编码" align="center" prop="cargoSpaceId" />
|
||||
<el-table-column label="货位名称" align="center" prop="cargoSpaceName" />
|
||||
<el-table-column label="仓库名称" align="center" prop="warehouseName" />
|
||||
<el-table-column label="货位编码" align="center" prop="cargoSpaceId"/>
|
||||
<el-table-column label="货位名称" align="center" prop="cargoSpaceName"/>
|
||||
<el-table-column label="仓库名称" align="center" prop="warehouseName"/>
|
||||
<el-table-column label="状态" align="center" prop="status">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.cargo_space_status" :value="scope.row.status"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="排" align="center" prop="thePlatoon" />
|
||||
<el-table-column label="列" align="center" prop="theColumn" />
|
||||
<el-table-column label="层" align="center" prop="theFloor" />
|
||||
<el-table-column label="排" align="center" prop="thePlatoon"/>
|
||||
<el-table-column label="列" align="center" prop="theColumn"/>
|
||||
<el-table-column label="层" align="center" prop="theFloor"/>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
@@ -340,13 +399,14 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listManagement, getManagement, delManagement, addManagement, updateManagement } from "@/api/stock/management"
|
||||
import {listManagement, getManagement, delManagement, addManagement, updateManagement} from "@/api/stock/management"
|
||||
import {listWarehouse} from "@/api/bas/warehouse"
|
||||
import { listBasProduct } from "@/api/bas/BasProduct"
|
||||
import { listCargoSpace } from "@/api/bas/cargoSpace"
|
||||
import {listBasProduct} from "@/api/bas/BasProduct"
|
||||
import {listCargoSpace} from "@/api/bas/cargoSpace"
|
||||
|
||||
export default {
|
||||
name: "Management",
|
||||
dicts: ['product_status', 'stock_status','cargo_space_status','cargo_space_lock_status'],
|
||||
dicts: ['product_status', 'stock_status', 'cargo_space_status', 'cargo_space_lock_status'],
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
@@ -365,6 +425,9 @@ export default {
|
||||
managementList: [],
|
||||
// 仓库选项
|
||||
warehouseOptions: [],
|
||||
warehouseCodeOptions: [{label: '立库', value: '1'}, {label: '平库', value: '2'}],
|
||||
productType:[{label:"满托",value:'1'},{label:"半托",value:'0'}],
|
||||
ktpType:[{label:"物料",value:'2'},{label:"托盘",value:'1'}],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
@@ -397,10 +460,15 @@ export default {
|
||||
spare3: null,
|
||||
spare4: null,
|
||||
spare5: null,
|
||||
spare6: null
|
||||
spare6: null,
|
||||
model: null,
|
||||
ktpType: "1",
|
||||
warehouseCode: "1",
|
||||
|
||||
|
||||
},
|
||||
queryWarehouse: {
|
||||
pageNum:1,
|
||||
pageNum: 1,
|
||||
pageSize: 99
|
||||
},
|
||||
// 表单参数
|
||||
@@ -511,7 +579,7 @@ export default {
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.stockId)
|
||||
this.single = selection.length!==1
|
||||
this.single = selection.length !== 1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
@@ -524,7 +592,8 @@ export default {
|
||||
handleUpdate(row) {
|
||||
this.reset()
|
||||
const stockId = row.stockId || this.ids
|
||||
getManagement(stockId).then(response => {
|
||||
const warehouseCode=this.queryParams.warehouseCode;
|
||||
getManagement(stockId,warehouseCode).then(response => {
|
||||
this.form = response.data
|
||||
this.open = true
|
||||
this.title = "修改库存信息" // 修改库存信息
|
||||
@@ -535,6 +604,7 @@ export default {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
if (this.form.stockId != null) {
|
||||
this.form.warehouseCode=this.queryParams.warehouseCode;
|
||||
updateManagement(this.form).then(response => {
|
||||
this.$modal.msgSuccess("修改成功") // 修改成功
|
||||
this.open = false
|
||||
@@ -553,12 +623,14 @@ export default {
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const stockIds = row.stockId || this.ids
|
||||
this.$modal.confirm("是否确认删除库存信息编号为" + stockIds).then(function() { // 是否确认删除库存信息编号为
|
||||
return delManagement(stockIds)
|
||||
const warehouseCode =this.queryParams.warehouseCode;
|
||||
this.$modal.confirm("是否确认删除库存信息编号为" + stockIds).then(function () { // 是否确认删除库存信息编号为
|
||||
return delManagement(stockIds,warehouseCode)
|
||||
}).then(() => {
|
||||
this.getList()
|
||||
this.$modal.msgSuccess("删除成功") // 删除成功
|
||||
}).catch(() => {})
|
||||
}).catch(() => {
|
||||
})
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
|
||||
205
ruoyi-ui/src/views/system/license/index.vue
Normal file
205
ruoyi-ui/src/views/system/license/index.vue
Normal file
@@ -0,0 +1,205 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form ref="queryForm" :model="queryParams" size="small" :inline="true" v-show="showSearch" label-width="80px">
|
||||
<el-form-item label="授权码" prop="licenseCode">
|
||||
<el-input v-model="queryParams.licenseCode" placeholder="请输入授权码" clearable style="width: 260px" @keyup.enter.native="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable style="width: 160px">
|
||||
<el-option label="未激活" value="0" />
|
||||
<el-option label="已激活" value="1" />
|
||||
<el-option label="已过期" value="2" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="el-icon-key" size="mini" @click="handleActive" v-hasPermi="['system:license:add']">激活授权码</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="success" plain icon="el-icon-plus" size="mini" @click="handleGenerate" v-hasPermi="['system:license:add']">生成授权码</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete" v-hasPermi="['system:license:remove']">删除</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList" />
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="licenseList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="授权ID" align="center" prop="licenseId" width="90" />
|
||||
<el-table-column label="授权码" align="center" prop="licenseCode" min-width="360" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="状态" align="center" prop="status" width="100">
|
||||
<template slot-scope="scope">
|
||||
<el-tag :type="statusTagType(scope.row.status)">{{ statusText(scope.row.status) }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="开始时间" align="center" prop="startTime" width="180">
|
||||
<template slot-scope="scope"><span>{{ parseTime(scope.row.startTime) }}</span></template>
|
||||
</el-table-column>
|
||||
<el-table-column label="过期时间" align="center" prop="expireTime" width="180">
|
||||
<template slot-scope="scope"><span>{{ parseTime(scope.row.expireTime) }}</span></template>
|
||||
</el-table-column>
|
||||
<el-table-column label="激活时间" align="center" prop="activeTime" width="180">
|
||||
<template slot-scope="scope"><span>{{ parseTime(scope.row.activeTime) }}</span></template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="120">
|
||||
<template slot-scope="scope">
|
||||
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['system:license:remove']">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
|
||||
|
||||
<el-dialog title="激活授权码" :visible.sync="activeOpen" width="520px" append-to-body>
|
||||
<el-input v-model="activeForm.licenseCode" type="textarea" :rows="5" placeholder="请输入授权码" />
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="activeOpen = false">取消</el-button>
|
||||
<el-button type="primary" :loading="activeLoading" @click="submitActive">确定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog title="生成授权码" :visible.sync="generateOpen" width="560px" append-to-body>
|
||||
<el-form ref="generateForm" :model="generateForm" :rules="generateRules" label-width="100px">
|
||||
<el-form-item label="授权类型" prop="type">
|
||||
<el-select v-model="generateForm.type" placeholder="请选择授权类型" style="width: 100%">
|
||||
<el-option label="5分钟测试" value="TEST" />
|
||||
<el-option label="1个月授权" value="MONTH" />
|
||||
<el-option label="3个月授权" value="THREE" />
|
||||
<el-option label="1年授权" value="YEAR" />
|
||||
<el-option label="5年授权" value="FIVE" />
|
||||
<el-option label="长期授权" value="FOREVER" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="项目编号" prop="projectNo">
|
||||
<el-input v-model="generateForm.projectNo" placeholder="请输入项目编号,如 FT546" />
|
||||
</el-form-item>
|
||||
<el-form-item v-if="generatedCode" label="授权码">
|
||||
<el-input v-model="generatedCode" type="textarea" :rows="5" readonly />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="generateOpen = false">关闭</el-button>
|
||||
<el-button type="primary" :loading="generateLoading" @click="submitGenerate">生成</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listLicense, delLicense, activeLicense, generateLicense } from '@/api/license'
|
||||
|
||||
export default {
|
||||
name: 'License',
|
||||
data() {
|
||||
return {
|
||||
loading: true,
|
||||
activeLoading: false,
|
||||
generateLoading: false,
|
||||
ids: [],
|
||||
multiple: true,
|
||||
showSearch: true,
|
||||
total: 0,
|
||||
licenseList: [],
|
||||
activeOpen: false,
|
||||
generateOpen: false,
|
||||
generatedCode: '',
|
||||
queryParams: { pageNum: 1, pageSize: 10, licenseCode: undefined, status: undefined },
|
||||
activeForm: { licenseCode: '' },
|
||||
generateForm: { type: 'YEAR', projectNo: 'FT546' },
|
||||
generateRules: {
|
||||
type: [{ required: true, message: '请选择授权类型', trigger: 'change' }],
|
||||
projectNo: [{ required: true, message: '请输入项目编号', trigger: 'blur' }]
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getList()
|
||||
},
|
||||
methods: {
|
||||
getList() {
|
||||
this.loading = true
|
||||
listLicense(this.queryParams).then(response => {
|
||||
this.licenseList = response.rows
|
||||
this.total = response.total
|
||||
}).finally(() => {
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1
|
||||
this.getList()
|
||||
},
|
||||
resetQuery() {
|
||||
this.resetForm('queryForm')
|
||||
this.handleQuery()
|
||||
},
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.licenseId)
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
handleActive() {
|
||||
this.activeForm.licenseCode = ''
|
||||
this.activeOpen = true
|
||||
},
|
||||
submitActive() {
|
||||
const licenseCode = this.activeForm.licenseCode.trim()
|
||||
if (!licenseCode) {
|
||||
this.$modal.msgWarning('请输入授权码')
|
||||
return
|
||||
}
|
||||
this.activeLoading = true
|
||||
activeLicense(licenseCode).then(response => {
|
||||
if (response.code !== 200) {
|
||||
this.$modal.msgError(response.msg || '授权码激活失败')
|
||||
return
|
||||
}
|
||||
this.$modal.msgSuccess(response.msg || '授权码激活成功')
|
||||
this.activeOpen = false
|
||||
this.getList()
|
||||
}).finally(() => {
|
||||
this.activeLoading = false
|
||||
})
|
||||
},
|
||||
handleGenerate() {
|
||||
this.generatedCode = ''
|
||||
this.generateForm = { type: 'YEAR', projectNo: 'FT546' }
|
||||
this.generateOpen = true
|
||||
this.$nextTick(() => this.resetForm('generateForm'))
|
||||
},
|
||||
submitGenerate() {
|
||||
this.$refs.generateForm.validate(valid => {
|
||||
if (!valid) return
|
||||
this.generateLoading = true
|
||||
generateLicense(this.generateForm.type, this.generateForm.projectNo.trim()).then(response => {
|
||||
if (response.code === 200) {
|
||||
this.generatedCode = response.data
|
||||
this.$modal.msgSuccess(response.msg || '授权码生成成功')
|
||||
}
|
||||
}).finally(() => {
|
||||
this.generateLoading = false
|
||||
})
|
||||
})
|
||||
},
|
||||
handleDelete(row) {
|
||||
const licenseIds = row.licenseId || this.ids
|
||||
this.$modal.confirm(`确认删除授权编号为【${licenseIds}】的数据项?`).then(() => delLicense(licenseIds)).then(() => {
|
||||
this.getList()
|
||||
this.$modal.msgSuccess('删除成功')
|
||||
}).catch(() => {})
|
||||
},
|
||||
statusText(status) {
|
||||
return { '0': '未激活', '1': '已激活', '2': '已过期' }[status] || '未知'
|
||||
},
|
||||
statusTagType(status) {
|
||||
return { '0': 'info', '1': 'success', '2': 'danger' }[status] || 'warning'
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -9,7 +9,7 @@ const CompressionPlugin = require('compression-webpack-plugin')
|
||||
|
||||
const name = process.env.VUE_APP_TITLE || '若依管理系统' // 网页标题
|
||||
|
||||
const baseUrl = 'http://localhost:8080' // 后端接口
|
||||
const baseUrl = 'http://127.0.0.1:8080' // 后端接口
|
||||
|
||||
const port = process.env.port || process.env.npm_config_port || 80 // 端口
|
||||
|
||||
|
||||
139
scripts/shadow-export-mcp.js
Normal file
139
scripts/shadow-export-mcp.js
Normal file
@@ -0,0 +1,139 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const { spawn } = require("child_process");
|
||||
|
||||
const root = "C:\\project\\FT546WMS-SHANDOW";
|
||||
const outDir = "C:\\project\\FT546WMS-shadow-export-0828";
|
||||
const config = path.join(root, ".cursorrules-mcp.json");
|
||||
|
||||
fs.mkdirSync(outDir, { recursive: true });
|
||||
|
||||
function redact(value) {
|
||||
return String(value)
|
||||
.replace(/password\s*[:=]\s*[^\s,}]+/gi, "password=[redacted]")
|
||||
.replace(/DB_PASSWORD[^\s,}]*/gi, "DB_PASSWORD=[redacted]");
|
||||
}
|
||||
|
||||
function createClient() {
|
||||
const child = spawn("powershell.exe", [
|
||||
"-NoProfile",
|
||||
"-ExecutionPolicy",
|
||||
"Bypass",
|
||||
"-File",
|
||||
"C:\\project\\sqlserver-mcp-server\\start.ps1",
|
||||
"-ConfigPath",
|
||||
config
|
||||
], { stdio: ["pipe", "pipe", "pipe"] });
|
||||
let buffer = "";
|
||||
let nextId = 1;
|
||||
const pending = new Map();
|
||||
let stderr = "";
|
||||
child.stderr.on("data", (chunk) => { stderr += chunk.toString(); });
|
||||
child.stdout.on("data", (chunk) => {
|
||||
buffer += chunk.toString();
|
||||
const lines = buffer.split(/\r?\n/);
|
||||
buffer = lines.pop();
|
||||
for (const line of lines) {
|
||||
if (!line.trim()) continue;
|
||||
try {
|
||||
const message = JSON.parse(line);
|
||||
const resolve = pending.get(message.id);
|
||||
if (resolve) {
|
||||
pending.delete(message.id);
|
||||
resolve(message);
|
||||
}
|
||||
} catch {
|
||||
// Ignore non-protocol stdout, if a server emits any.
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function call(method, params) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const id = nextId++;
|
||||
pending.set(id, (message) => {
|
||||
if (message.error) reject(new Error(message.error.message || "MCP error"));
|
||||
else resolve(message.result);
|
||||
});
|
||||
child.stdin.write(JSON.stringify({ jsonrpc: "2.0", id, method, params }) + "\n");
|
||||
});
|
||||
}
|
||||
|
||||
return { child, call, getStderr: () => stderr };
|
||||
}
|
||||
|
||||
function parseResult(result) {
|
||||
const content = (result.content || []).find((item) => item.type === "text");
|
||||
if (!content) throw new Error("MCP returned no text result");
|
||||
return JSON.parse(content.text);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const client = createClient();
|
||||
try {
|
||||
await client.call("initialize", {
|
||||
protocolVersion: "2025-06-18",
|
||||
capabilities: {},
|
||||
clientInfo: { name: "ft546-shadow-export", version: "1.0" }
|
||||
});
|
||||
client.child.stdin.write(JSON.stringify({
|
||||
jsonrpc: "2.0", method: "notifications/initialized"
|
||||
}) + "\n");
|
||||
|
||||
const callRead = async (query) => parseResult(await client.call("tools/call", {
|
||||
name: "sqlserver_read_data",
|
||||
arguments: { databaseName: "FT546-wms", query, response_format: "json" }
|
||||
}));
|
||||
const callTool = async (name, arguments_) => parseResult(await client.call("tools/call", {
|
||||
name,
|
||||
arguments: { ...arguments_, response_format: "json" }
|
||||
}));
|
||||
|
||||
const databases = await callTool("sqlserver_list_databases", {});
|
||||
if (!databases.databases.includes("FT546-wms")) throw new Error("Database is not in MCP allowlist");
|
||||
|
||||
const diagnosticQueries = [
|
||||
["connection", "SELECT CAST(SERVERPROPERTY('ProductVersion') AS varchar(30)) AS product_version, DB_NAME() AS database_name, SYSUTCDATETIME() AS checked_at_utc;"],
|
||||
["package_manifest", "SELECT package_id, package_version, installed_at FROM alg.shadow_package_manifest;"],
|
||||
["alg_objects", "SELECT schema_name(o.schema_id) AS schema_name, o.name AS object_name, o.type_desc FROM sys.objects o WHERE schema_name(o.schema_id) = N'alg' ORDER BY schema_name(o.schema_id), o.type_desc, o.name;"],
|
||||
["lane_state", "SELECT warehouse_id, COUNT(*) AS lane_state_count, SUM(CASE WHEN pending_outbound = 1 THEN 1 ELSE 0 END) AS pending_lane_count, SUM(CASE WHEN has_gap = 1 THEN 1 ELSE 0 END) AS gap_lane_count, MAX(rebuilt_at) AS latest_rebuild_at FROM alg.lane_state GROUP BY warehouse_id ORDER BY warehouse_id;"],
|
||||
["inventory_snapshot", "SELECT warehouse_id, COUNT(*) AS inventory_item_count, COUNT(DISTINCT space_id) AS inventory_space_count, MAX(synchronized_at) AS latest_inventory_sync_at FROM alg.inventory_item_snapshot GROUP BY warehouse_id ORDER BY warehouse_id;"],
|
||||
["space_state", "SELECT warehouse_id, COUNT(*) AS space_state_count, SUM(CASE WHEN inbound_available = 1 THEN 1 ELSE 0 END) AS inbound_available_count, SUM(CASE WHEN pending_outbound = 1 THEN 1 ELSE 0 END) AS pending_outbound_count, SUM(CASE WHEN tray_conflict = 1 OR project_conflict = 1 OR product_conflict = 1 THEN 1 ELSE 0 END) AS conflict_count FROM alg.v_space_state GROUP BY warehouse_id ORDER BY warehouse_id;"],
|
||||
["legacy_checksums", "SELECT 'bas_cargo_space' AS table_name, COUNT_BIG(*) AS row_count, CHECKSUM_AGG(BINARY_CHECKSUM(cargo_space_id, warehouse_id, group_coding_no, group_coding, status, tray_code)) AS row_checksum FROM dbo.bas_cargo_space UNION ALL SELECT 'bas_stock', COUNT_BIG(*), CHECKSUM_AGG(BINARY_CHECKSUM(stock_id, cargo_space_id, tray_code, spare4, product_id, lot_no, in_date)) FROM dbo.bas_stock UNION ALL SELECT 'mydo_job', COUNT_BIG(*), CHECKSUM_AGG(BINARY_CHECKSUM(job_id, status, task_no, tray_code, cargo_space_id, target_cargo_space_id, in_or_out, warehouse_id)) FROM dbo.mydo_job;"],
|
||||
["locks", "SELECT request_session_id, resource_type, request_mode, request_status, object_name(partition.object_id, lock.resource_database_id) AS object_name FROM sys.dm_tran_locks lock LEFT JOIN sys.partitions partition ON partition.hobt_id = lock.resource_associated_entity_id WHERE lock.resource_database_id = DB_ID() AND object_name(partition.object_id, lock.resource_database_id) IN (N'bas_cargo_space', N'bas_stock', N'mydo_job') ORDER BY request_session_id, object_name, request_mode;"],
|
||||
["decision_log", "SELECT decision_id, warehouse_id, decision_type, input_version, result_code, reason, created_at FROM alg.decision_log WHERE decision_type IN ('INBOUND', 'OUTBOUND', 'INBOUND_COMPARE', 'OUTBOUND_COMPARE') ORDER BY created_at, decision_id;"]
|
||||
];
|
||||
|
||||
const diagnosticResults = [];
|
||||
for (const [name, query] of diagnosticQueries) diagnosticResults.push({ name, result: await callRead(query) });
|
||||
|
||||
const detailStart = "2026-08-18T16:00:00";
|
||||
const detailEnd = new Date().toISOString().slice(0, 19);
|
||||
const detailQueries = [
|
||||
["connection", `SELECT CAST(SERVERPROPERTY('ProductVersion') AS varchar(30)) AS product_version, DB_NAME() AS database_name, SYSUTCDATETIME() AS checked_at_utc, '01' AS warehouse_id, CAST('${detailStart}' AS datetime2) AS export_start_utc, CAST('${detailEnd}' AS datetime2) AS export_end_utc`],
|
||||
["package_manifest", "SELECT package_id, package_version, installed_at FROM alg.shadow_package_manifest;"],
|
||||
["decision_summary", `SELECT decision_type, result_code, COUNT(*) AS row_count, MIN(created_at) AS first_created_at, MAX(created_at) AS last_created_at FROM alg.decision_log WHERE created_at >= CAST('${detailStart}' AS datetime2) AND created_at < CAST('${detailEnd}' AS datetime2) GROUP BY decision_type, result_code ORDER BY decision_type, result_code`],
|
||||
["decision_log", `SELECT decision_id, warehouse_id, decision_type, input_version, result_code, reason, created_at FROM alg.decision_log WHERE created_at >= CAST('${detailStart}' AS datetime2) AND created_at < CAST('${detailEnd}' AS datetime2) ORDER BY created_at, decision_id`],
|
||||
["outbound_jobs", `SELECT TOP (300) d.created_at AS decision_created_at, d.result_code AS shadow_compare_result, d.reason, detail.stockout_detail_id, detail.stockout_id, detail.warehouse_id, detail.spare4 AS project_no, detail.product_id, detail.quantity, detail.allot_quantity, detail.assign_num, detail.create_time AS detail_create_time FROM alg.decision_log d OUTER APPLY (SELECT LTRIM(RTRIM(SUBSTRING(d.reason, CHARINDEX('request=', d.reason) + 8, CHARINDEX(CHAR(59), d.reason + CHAR(59), CHARINDEX('request=', d.reason)) - (CHARINDEX('request=', d.reason) + 8)))) AS request_id) r LEFT JOIN dbo.out_stockout_detail detail ON detail.stockout_detail_id = r.request_id AND TRY_CONVERT(int, detail.warehouse_id) = TRY_CONVERT(int, '01') WHERE d.decision_type = 'OUTBOUND_COMPARE' AND d.created_at >= CAST('${detailStart}' AS datetime2) AND d.created_at < CAST('${detailEnd}' AS datetime2) ORDER BY d.created_at, detail.create_time, detail.stockout_detail_id`],
|
||||
["inventory_mapping", "SELECT TOP (1000) c.warehouse_id, s.stock_id, s.cargo_space_id, s.tray_code, s.spare4 AS legacy_project_no, s.product_id AS legacy_product_no, s.lot_no, s.in_date, s.quantity, s.out_quantity, i.space_id AS shadow_space_id, i.tray_code AS shadow_tray_code, i.project_no AS shadow_project_no, i.product_no AS shadow_product_no, i.inbound_time_raw, i.inbound_at, i.quantity AS shadow_quantity, i.out_quantity AS shadow_out_quantity FROM dbo.bas_stock s INNER JOIN dbo.bas_cargo_space c ON c.cargo_space_id = s.cargo_space_id AND c.warehouse_id = '01' LEFT JOIN alg.v_inventory_item i ON i.stock_id = s.stock_id ORDER BY s.stock_id;"],
|
||||
["jobs", "SELECT TOP (1000) job_id, task_no, tray_code, cargo_space_id, target_cargo_space_id, warehouse_id, status, in_or_out, create_time, finish_time FROM dbo.mydo_job WHERE warehouse_id = '01' ORDER BY create_time, job_id;"],
|
||||
["lane_state", "SELECT warehouse_id, COUNT(*) AS lane_state_count, SUM(CASE WHEN pending_outbound = 1 THEN 1 ELSE 0 END) AS pending_lane_count, SUM(CASE WHEN has_gap = 1 THEN 1 ELSE 0 END) AS gap_lane_count, MAX(rebuilt_at) AS latest_rebuild_at FROM alg.lane_state WHERE warehouse_id = '01' GROUP BY warehouse_id;"],
|
||||
["inventory_stats", "SELECT warehouse_id, COUNT(*) AS inventory_item_count, COUNT(DISTINCT space_id) AS inventory_space_count, MAX(synchronized_at) AS latest_inventory_sync_at FROM alg.inventory_item_snapshot WHERE warehouse_id = '01' GROUP BY warehouse_id;"],
|
||||
["legacy_checksums", "SELECT 'bas_cargo_space' AS table_name, COUNT_BIG(*) AS row_count, CHECKSUM_AGG(BINARY_CHECKSUM(cargo_space_id, warehouse_id, group_coding_no, group_coding, status, tray_code)) AS row_checksum FROM dbo.bas_cargo_space WHERE warehouse_id = '01' UNION ALL SELECT 'bas_stock', COUNT_BIG(*), CHECKSUM_AGG(BINARY_CHECKSUM(s.stock_id, s.cargo_space_id, s.tray_code, s.spare4, s.product_id, s.lot_no, s.in_date)) FROM dbo.bas_stock s INNER JOIN dbo.bas_cargo_space c ON c.cargo_space_id = s.cargo_space_id WHERE c.warehouse_id = '01' UNION ALL SELECT 'mydo_job', COUNT_BIG(*), CHECKSUM_AGG(BINARY_CHECKSUM(job_id, status, task_no, tray_code, cargo_space_id, target_cargo_space_id, in_or_out, warehouse_id)) FROM dbo.mydo_job WHERE warehouse_id = '01';"]
|
||||
];
|
||||
|
||||
const detailResults = [];
|
||||
for (const [name, query] of detailQueries) detailResults.push({ name, result: await callRead(query) });
|
||||
const detailSql = detailQueries.map(([name, query]) => `-- ${name}\n${query}`).join(";\n\n") + ";\n";
|
||||
fs.writeFileSync(path.join(outDir, "shadow-detail-export.sql"), detailSql, "utf8");
|
||||
fs.writeFileSync(path.join(outDir, "shadow-detail-export.txt"), JSON.stringify({ export_type: "shadow-detail-export", results: detailResults }, null, 2) + "\n", "utf8");
|
||||
console.log("EXPORT_OK diagnostics-shadow.txt shadow-detail-export.txt");
|
||||
} finally {
|
||||
client.child.kill();
|
||||
}
|
||||
}
|
||||
|
||||
main().catch((error) => {
|
||||
console.error("EXPORT_FAILED " + redact(error.message));
|
||||
process.exitCode = 1;
|
||||
});
|
||||
117
scripts/shadow-followup-mcp.js
Normal file
117
scripts/shadow-followup-mcp.js
Normal file
@@ -0,0 +1,117 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const { spawn } = require("child_process");
|
||||
|
||||
const root = "C:\\project\\FT546WMS-SHANDOW";
|
||||
const outDir = "C:\\project\\FT546WMS-shadow-export-0828";
|
||||
const config = path.join(root, ".cursorrules-mcp.json");
|
||||
const database = "FT546-wms";
|
||||
|
||||
fs.mkdirSync(outDir, { recursive: true });
|
||||
|
||||
function redact(value) {
|
||||
return String(value).replace(/password\s*[:=]\s*[^\s,}]+/gi, "password=[redacted]");
|
||||
}
|
||||
|
||||
function createClient() {
|
||||
const child = spawn("powershell.exe", [
|
||||
"-NoProfile", "-ExecutionPolicy", "Bypass", "-File",
|
||||
"C:\\project\\sqlserver-mcp-server\\start.ps1",
|
||||
"-ConfigPath", config
|
||||
], { stdio: ["pipe", "pipe", "pipe"] });
|
||||
let buffer = "";
|
||||
let nextId = 1;
|
||||
const pending = new Map();
|
||||
child.stdout.on("data", (chunk) => {
|
||||
buffer += chunk.toString();
|
||||
const lines = buffer.split(/\r?\n/);
|
||||
buffer = lines.pop();
|
||||
for (const line of lines) {
|
||||
if (!line.trim()) continue;
|
||||
try {
|
||||
const message = JSON.parse(line);
|
||||
const resolve = pending.get(message.id);
|
||||
if (resolve) {
|
||||
pending.delete(message.id);
|
||||
resolve(message);
|
||||
}
|
||||
} catch {
|
||||
// The MCP protocol stream is line-delimited JSON.
|
||||
}
|
||||
}
|
||||
});
|
||||
function call(method, params) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const id = nextId++;
|
||||
pending.set(id, (message) => message.error
|
||||
? reject(new Error(message.error.message || "MCP error"))
|
||||
: resolve(message.result));
|
||||
child.stdin.write(JSON.stringify({ jsonrpc: "2.0", id, method, params }) + "\n");
|
||||
});
|
||||
}
|
||||
return { child, call };
|
||||
}
|
||||
|
||||
function parseResult(result) {
|
||||
const item = (result.content || []).find((entry) => entry.type === "text");
|
||||
if (!item) throw new Error("MCP returned no result text");
|
||||
try {
|
||||
return JSON.parse(item.text);
|
||||
} catch {
|
||||
throw new Error(item.text.replace(/password\s*[:=]\s*[^\s,}]+/gi, "password=[redacted]").replace(/\r?\n/g, " "));
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const client = createClient();
|
||||
try {
|
||||
await client.call("initialize", {
|
||||
protocolVersion: "2025-06-18",
|
||||
capabilities: {},
|
||||
clientInfo: { name: "ft546-shadow-followup", version: "1.0" }
|
||||
});
|
||||
client.child.stdin.write(JSON.stringify({ jsonrpc: "2.0", method: "notifications/initialized" }) + "\n");
|
||||
|
||||
const start = "2026-08-18T00:00:00";
|
||||
const end = new Date().toISOString().slice(0, 19);
|
||||
const warehouse = "01";
|
||||
const callRead = async (name, query) => ({
|
||||
name,
|
||||
result: parseResult(await client.call("tools/call", {
|
||||
name: "sqlserver_read_data",
|
||||
arguments: { databaseName: database, query, response_format: "json" }
|
||||
}))
|
||||
});
|
||||
|
||||
const queries = [
|
||||
["inventory_counts", `SELECT 'legacy_bas_stock' AS source_name, COUNT_BIG(*) AS row_count FROM dbo.bas_stock s INNER JOIN dbo.bas_cargo_space c ON c.cargo_space_id = s.cargo_space_id AND c.warehouse_id = '${warehouse}' UNION ALL SELECT 'shadow_inventory_item_snapshot', COUNT_BIG(*) FROM alg.inventory_item_snapshot WHERE warehouse_id = '${warehouse}'`],
|
||||
["legacy_missing_from_shadow", `SELECT TOP (1000) c.warehouse_id, s.stock_id, s.cargo_space_id, s.tray_code, s.spare4 AS legacy_project_no, s.product_id AS legacy_product_no, s.lot_no, s.in_date, s.quantity, s.out_quantity FROM dbo.bas_stock s INNER JOIN dbo.bas_cargo_space c ON c.cargo_space_id = s.cargo_space_id AND c.warehouse_id = '${warehouse}' LEFT JOIN alg.inventory_item_snapshot i ON i.warehouse_id = c.warehouse_id AND i.stock_id = s.stock_id WHERE i.stock_id IS NULL ORDER BY s.stock_id`],
|
||||
["shadow_missing_from_legacy", `SELECT TOP (1000) i.warehouse_id, i.stock_id, i.space_id, i.tray_code, i.project_no, i.product_no, i.lot_no, i.inbound_time_raw, i.quantity, i.out_quantity FROM alg.inventory_item_snapshot i LEFT JOIN dbo.bas_stock s ON s.stock_id = i.stock_id WHERE i.warehouse_id = '${warehouse}' AND s.stock_id IS NULL ORDER BY i.stock_id`],
|
||||
["matched_field_difference_counts", `SELECT COUNT_BIG(*) AS matched_stock_count, SUM(CASE WHEN ISNULL(LTRIM(RTRIM(s.cargo_space_id)), '') <> ISNULL(LTRIM(RTRIM(i.space_id)), '') THEN 1 ELSE 0 END) AS space_mismatch_count, SUM(CASE WHEN ISNULL(LTRIM(RTRIM(s.tray_code)), '') <> ISNULL(LTRIM(RTRIM(i.tray_code)), '') THEN 1 ELSE 0 END) AS tray_mismatch_count, SUM(CASE WHEN ISNULL(LTRIM(RTRIM(s.spare4)), '') <> ISNULL(LTRIM(RTRIM(i.project_no)), '') THEN 1 ELSE 0 END) AS project_mismatch_count, SUM(CASE WHEN ISNULL(LTRIM(RTRIM(s.product_id)), '') <> ISNULL(LTRIM(RTRIM(i.product_no)), '') THEN 1 ELSE 0 END) AS product_mismatch_count, SUM(CASE WHEN ISNULL(LTRIM(RTRIM(s.lot_no)), '') <> ISNULL(LTRIM(RTRIM(i.lot_no)), '') THEN 1 ELSE 0 END) AS lot_mismatch_count, SUM(CASE WHEN ISNULL(s.quantity, 0) <> ISNULL(i.quantity, 0) THEN 1 ELSE 0 END) AS quantity_mismatch_count, SUM(CASE WHEN ISNULL(s.out_quantity, 0) <> ISNULL(i.out_quantity, 0) THEN 1 ELSE 0 END) AS out_quantity_mismatch_count FROM dbo.bas_stock s INNER JOIN dbo.bas_cargo_space c ON c.cargo_space_id = s.cargo_space_id AND c.warehouse_id = '${warehouse}' INNER JOIN alg.inventory_item_snapshot i ON i.warehouse_id = c.warehouse_id AND i.stock_id = s.stock_id`],
|
||||
["field_difference_rows", `SELECT TOP (1000) s.stock_id, s.cargo_space_id AS legacy_space_id, i.space_id AS shadow_space_id, s.tray_code AS legacy_tray_code, i.tray_code AS shadow_tray_code, s.spare4 AS legacy_project_no, i.project_no AS shadow_project_no, s.product_id AS legacy_product_no, i.product_no AS shadow_product_no, s.lot_no AS legacy_lot_no, i.lot_no AS shadow_lot_no, s.quantity AS legacy_quantity, i.quantity AS shadow_quantity, s.out_quantity AS legacy_out_quantity, i.out_quantity AS shadow_out_quantity FROM dbo.bas_stock s INNER JOIN dbo.bas_cargo_space c ON c.cargo_space_id = s.cargo_space_id AND c.warehouse_id = '${warehouse}' INNER JOIN alg.inventory_item_snapshot i ON i.warehouse_id = c.warehouse_id AND i.stock_id = s.stock_id WHERE ISNULL(LTRIM(RTRIM(s.cargo_space_id)), '') <> ISNULL(LTRIM(RTRIM(i.space_id)), '') OR ISNULL(LTRIM(RTRIM(s.tray_code)), '') <> ISNULL(LTRIM(RTRIM(i.tray_code)), '') OR ISNULL(LTRIM(RTRIM(s.spare4)), '') <> ISNULL(LTRIM(RTRIM(i.project_no)), '') OR ISNULL(LTRIM(RTRIM(s.product_id)), '') <> ISNULL(LTRIM(RTRIM(i.product_no)), '') OR ISNULL(LTRIM(RTRIM(s.lot_no)), '') <> ISNULL(LTRIM(RTRIM(i.lot_no)), '') OR ISNULL(s.quantity, 0) <> ISNULL(i.quantity, 0) OR ISNULL(s.out_quantity, 0) <> ISNULL(i.out_quantity, 0) ORDER BY s.stock_id`],
|
||||
["request_match_counts", `SELECT COUNT_BIG(*) AS compare_count, SUM(CASE WHEN detail.stockout_detail_id IS NOT NULL THEN 1 ELSE 0 END) AS matched_by_detail_id, SUM(CASE WHEN detail.stockout_detail_id IS NULL THEN 1 ELSE 0 END) AS unmatched_count FROM alg.decision_log d OUTER APPLY (SELECT LTRIM(RTRIM(SUBSTRING(d.reason, CHARINDEX('request=', d.reason) + 8, CHARINDEX(CHAR(59), d.reason + CHAR(59), CHARINDEX('request=', d.reason)) - (CHARINDEX('request=', d.reason) + 8)))) AS request_id) r LEFT JOIN dbo.out_stockout_detail detail ON detail.stockout_detail_id = r.request_id AND TRY_CONVERT(int, detail.warehouse_id) = TRY_CONVERT(int, '${warehouse}') WHERE d.decision_type = 'OUTBOUND_COMPARE' AND d.created_at >= '${start}' AND d.created_at < '${end}'`],
|
||||
["request_match_details", `SELECT TOP (300) d.created_at, d.result_code, r.request_id, detail.stockout_detail_id AS detail_id_match, detail.stockout_id, detail.warehouse_id, detail.spare4 AS detail_project_no, detail.product_id AS detail_product_id, detail.quantity AS detail_quantity, detail.allot_quantity AS detail_allot_quantity, detail.assign_num AS detail_assign_num, d.reason FROM alg.decision_log d OUTER APPLY (SELECT LTRIM(RTRIM(SUBSTRING(d.reason, CHARINDEX('request=', d.reason) + 8, CHARINDEX(CHAR(59), d.reason + CHAR(59), CHARINDEX('request=', d.reason)) - (CHARINDEX('request=', d.reason) + 8)))) AS request_id) r LEFT JOIN dbo.out_stockout_detail detail ON detail.stockout_detail_id = r.request_id AND TRY_CONVERT(int, detail.warehouse_id) = TRY_CONVERT(int, '${warehouse}') WHERE d.decision_type = 'OUTBOUND_COMPARE' AND d.created_at >= '${start}' AND d.created_at < '${end}' ORDER BY d.created_at`]
|
||||
];
|
||||
|
||||
const results = [];
|
||||
for (const [name, query] of queries) results.push(await callRead(name, query));
|
||||
const output = {
|
||||
export_type: "shadow-followup",
|
||||
database,
|
||||
warehouse_id: warehouse,
|
||||
export_start_utc: start,
|
||||
export_end_utc: end,
|
||||
results
|
||||
};
|
||||
fs.writeFileSync(path.join(outDir, "shadow-followup.sql"), queries.map(([name, query]) => `-- ${name}\n${query}`).join(";\n\n") + ";\n", "utf8");
|
||||
fs.writeFileSync(path.join(outDir, "shadow-followup.txt"), JSON.stringify(output, null, 2) + "\n", "utf8");
|
||||
console.log("FOLLOWUP_EXPORT_OK shadow-followup.txt result_sets=" + results.length);
|
||||
} finally {
|
||||
client.child.kill();
|
||||
}
|
||||
}
|
||||
|
||||
main().catch((error) => {
|
||||
console.error("FOLLOWUP_EXPORT_FAILED " + redact(error.message));
|
||||
process.exitCode = 1;
|
||||
});
|
||||
102
scripts/stockout-detail-check-mcp.js
Normal file
102
scripts/stockout-detail-check-mcp.js
Normal file
@@ -0,0 +1,102 @@
|
||||
const { spawn } = require("child_process");
|
||||
|
||||
const config = "C:\\project\\FT546WMS-SHANDOW\\.cursorrules-mcp.json";
|
||||
const database = "FT546-wms";
|
||||
|
||||
function createClient() {
|
||||
const child = spawn("powershell.exe", [
|
||||
"-NoProfile", "-ExecutionPolicy", "Bypass", "-File",
|
||||
"C:\\project\\sqlserver-mcp-server\\start.ps1",
|
||||
"-ConfigPath", config
|
||||
], { stdio: ["pipe", "pipe", "pipe"] });
|
||||
let buffer = "";
|
||||
let nextId = 1;
|
||||
const pending = new Map();
|
||||
child.stdout.on("data", (chunk) => {
|
||||
buffer += chunk.toString();
|
||||
const lines = buffer.split(/\r?\n/);
|
||||
buffer = lines.pop();
|
||||
for (const line of lines) {
|
||||
if (!line.trim()) continue;
|
||||
try {
|
||||
const message = JSON.parse(line);
|
||||
const resolve = pending.get(message.id);
|
||||
if (resolve) {
|
||||
pending.delete(message.id);
|
||||
resolve(message);
|
||||
}
|
||||
} catch {
|
||||
// Ignore non-protocol output.
|
||||
}
|
||||
}
|
||||
});
|
||||
function call(method, params) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const id = nextId++;
|
||||
pending.set(id, (message) => message.error
|
||||
? reject(new Error(message.error.message || "MCP error"))
|
||||
: resolve(message.result));
|
||||
child.stdin.write(JSON.stringify({ jsonrpc: "2.0", id, method, params }) + "\n");
|
||||
});
|
||||
}
|
||||
return { child, call };
|
||||
}
|
||||
|
||||
function parseResult(result) {
|
||||
const item = (result.content || []).find((entry) => entry.type === "text");
|
||||
if (!item) throw new Error("MCP returned no result text");
|
||||
try {
|
||||
return JSON.parse(item.text);
|
||||
} catch {
|
||||
throw new Error(item.text.replace(/password\s*[:=]\s*[^\s,}]+/gi, "password=[redacted]").replace(/\r?\n/g, " "));
|
||||
}
|
||||
}
|
||||
|
||||
function quote(value) {
|
||||
return String(value ?? "").replaceAll("'", "''");
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const client = createClient();
|
||||
try {
|
||||
await client.call("initialize", {
|
||||
protocolVersion: "2025-06-18",
|
||||
capabilities: {},
|
||||
clientInfo: { name: "ft546-stockout-detail-check", version: "1.0" }
|
||||
});
|
||||
client.child.stdin.write(JSON.stringify({ jsonrpc: "2.0", method: "notifications/initialized" }) + "\n");
|
||||
|
||||
async function read(query) {
|
||||
return parseResult(await client.call("tools/call", {
|
||||
name: "sqlserver_read_data",
|
||||
arguments: { databaseName: database, query, response_format: "json" }
|
||||
}));
|
||||
}
|
||||
|
||||
const detail = await read("SELECT stockout_detail_id, warehouse_id, spare4 AS project_no, product_id FROM dbo.out_stockout_detail WHERE stockout_detail_id = 'CKD202608180003-1'");
|
||||
const row = detail.rows?.[0];
|
||||
const projectNo = row?.project_no == null ? null : String(row.project_no).trim();
|
||||
const productNo = row?.product_id == null ? null : String(row.product_id).trim();
|
||||
const projectLiteral = projectNo == null || projectNo === "" ? "NULL" : `'${quote(projectNo)}'`;
|
||||
const productConditionLegacy = productNo == null || productNo === "" ? "1 = 1" : `product_id = '${quote(productNo)}'`;
|
||||
const productConditionShadow = productNo == null || productNo === "" ? "1 = 1" : `product_no = '${quote(productNo)}'`;
|
||||
|
||||
const legacy = await read(`SELECT stock_id, warehouse_id, cargo_space_id, tray_code, spare4 AS project_no, product_id, quantity, out_quantity, stock_status, product_status FROM dbo.bas_stock WHERE spare4 = ${projectLiteral} AND ${productConditionLegacy}`);
|
||||
const shadow = await read(`SELECT stock_id, space_id, tray_code, project_no, product_no, quantity, out_quantity FROM alg.v_inventory_item WHERE project_no = ${projectLiteral} AND ${productConditionShadow}`);
|
||||
const sync = await read("SELECT MAX(synchronized_at) AS latest_shadow_inventory_sync FROM alg.inventory_item_snapshot WHERE warehouse_id = '01'");
|
||||
|
||||
console.log(JSON.stringify({
|
||||
detail: detail.rows || [],
|
||||
legacy_stock: legacy.rows || [],
|
||||
shadow_inventory: shadow.rows || [],
|
||||
latest_sync: sync.rows || []
|
||||
}, null, 2));
|
||||
} finally {
|
||||
client.child.kill();
|
||||
}
|
||||
}
|
||||
|
||||
main().catch((error) => {
|
||||
console.error("READONLY_QUERY_FAILED " + error.message);
|
||||
process.exitCode = 1;
|
||||
});
|
||||
Reference in New Issue
Block a user