Compare commits
6 Commits
2ec2b6a628
...
20260519-3
| Author | SHA1 | Date | |
|---|---|---|---|
| 3bce685f3a | |||
| c54d54b40f | |||
|
|
a9b3720446 | ||
|
|
73a22b5ed9 | ||
| 372dc10be2 | |||
| 816af5df6e |
282
docs/QH-MES部署与热部署方案.md
Normal file
282
docs/QH-MES部署与热部署方案.md
Normal file
@@ -0,0 +1,282 @@
|
|||||||
|
# QH-MES 部署与热部署方案
|
||||||
|
|
||||||
|
> 本文档记录 QH-MES(jeecg-boot 3.9.2)在 Windows Server 上的部署方案,包含后端、前端的一键发版流程、关键配置、踩过的坑,以及未来上线客户正式服务器的规划。
|
||||||
|
> 最后更新:2026-06-17
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 一、环境概况
|
||||||
|
|
||||||
|
### 测试服务器(当前)
|
||||||
|
- **系统**:Windows Server 2016 Standard
|
||||||
|
- **JDK**:17.0.11(`C:\Program Files\Java\jdk-17`,注意 `JAVA_HOME` 要指根目录,**不能带 `\bin`**)
|
||||||
|
- **Maven**:3.9.8(`D:\apache-maven-3.9.8`,从本地 Win11 拷过去的,因服务器网络受限无法在线下载)
|
||||||
|
- **Git**:已装在 `C:\Program Files\Git`,但不在 PATH(用完整路径 `"C:\Program Files\Git\cmd\git.exe"` 调用)
|
||||||
|
- **Gitea**:跑在**同一台机器**,裸仓库在 `D:\gitea\data\gitea-repositories\chenx\qhmes.git`,Web 地址 `http://27.223.88.102:33000/chenx/qhmes`
|
||||||
|
- **Nginx**:1.30.1,装在 `D:\qhmes\nginx-1.30.1\`,前端文件目录 `D:\qhmes\nginx-1.30.1\html\jeecg\`
|
||||||
|
- **Node/pnpm/npm**:**服务器上没装**(前端不在服务器构建)
|
||||||
|
|
||||||
|
### 关键路径
|
||||||
|
| 用途 | 路径 |
|
||||||
|
|------|------|
|
||||||
|
| 后端运行目录(jar + WinSW 服务) | `D:\qhmes\` |
|
||||||
|
| 后端运行 jar | `D:\qhmes\jeecg-system-start-3.9.2.jar` |
|
||||||
|
| 服务器源码工作副本 | `D:\qhmes-src\`(从本地裸仓库 clone,分支 `main`) |
|
||||||
|
| 前端 nginx 目录 | `D:\qhmes\nginx-1.30.1\html\jeecg\` |
|
||||||
|
| WinSW 服务程序/配置 | `D:\qhmes\qhmes-service.exe` / `qhmes-service.xml` |
|
||||||
|
| 后端发版脚本 | `D:\deploy-server.bat`(放源码目录外,避免 git pull 自我覆盖) |
|
||||||
|
|
||||||
|
### 本地开发机(Win11)
|
||||||
|
- 项目路径:`D:\XSL-PROJECT\QH-MES\qhmes`
|
||||||
|
- 后端模块:`jeecg-boot/`,前端:`jeecgboot-vue3/`(同一个 git 仓库)
|
||||||
|
- 传文件到服务器的方式:**向日葵远程传输**(只能手动,不能脚本化)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 二、后端部署(已跑通 ✅)
|
||||||
|
|
||||||
|
### 2.1 后端做成 Windows 服务(WinSW)
|
||||||
|
后端不再手动 `java -jar`(关窗口/断 RDP 就掉),改用 **WinSW** 注册成 Windows 服务,开机自启、崩溃自动重启。
|
||||||
|
|
||||||
|
- 服务 id:`qhmes`,名称:`QH-MES Backend`
|
||||||
|
- 配置文件 `D:\qhmes\qhmes-service.xml` 关键内容:
|
||||||
|
```xml
|
||||||
|
<executable>java</executable>
|
||||||
|
<arguments>-Xms1g -Xmx2g -jar "D:\qhmes\jeecg-system-start-3.9.2.jar"</arguments>
|
||||||
|
<workingdirectory>D:\qhmes</workingdirectory>
|
||||||
|
<logpath>D:\qhmes\logs</logpath>
|
||||||
|
<onfailure action="restart" delay="10 sec"/>
|
||||||
|
```
|
||||||
|
- **注意**:`<arguments>` 里**不加** `--spring.profiles.active`,因为 profile 已在打包时烤进 jar(见第四节)。
|
||||||
|
- 常用命令(管理员):
|
||||||
|
```
|
||||||
|
D:\qhmes\qhmes-service.exe install # 安装服务(一次性)
|
||||||
|
D:\qhmes\qhmes-service.exe start # 启动
|
||||||
|
D:\qhmes\qhmes-service.exe stop # 停止
|
||||||
|
```
|
||||||
|
- 查日志:
|
||||||
|
```powershell
|
||||||
|
Get-Content D:\qhmes\logs\qhmes-service.out.log -Wait -Tail 60
|
||||||
|
```
|
||||||
|
启动成功标志:`Started JeecgSystemApplication in xx seconds`,Tomcat 监听 8888。
|
||||||
|
|
||||||
|
### 2.2 一键发版脚本 `D:\deploy-server.bat`
|
||||||
|
流程:`git pull → mvn 打包(prod) → 停服务 → 换 jar → 启服务`。脚本自带 `git pull`,**双击即自动拉最新代码**。
|
||||||
|
|
||||||
|
```bat
|
||||||
|
@echo off
|
||||||
|
setlocal
|
||||||
|
set SRC=D:\qhmes-src
|
||||||
|
set GIT="C:\Program Files\Git\cmd\git.exe"
|
||||||
|
set DEPLOY_DIR=D:\qhmes
|
||||||
|
set JAR_NAME=jeecg-system-start-3.9.2.jar
|
||||||
|
set SVC=D:\qhmes\qhmes-service.exe
|
||||||
|
set BUILT_JAR=%SRC%\jeecg-boot\jeecg-module-system\jeecg-system-start\target\%JAR_NAME%
|
||||||
|
|
||||||
|
echo [1/5] git pull ...
|
||||||
|
cd /d %SRC%
|
||||||
|
%GIT% pull
|
||||||
|
if errorlevel 1 ( echo [ERROR] git pull failed & pause & exit /b 1 )
|
||||||
|
|
||||||
|
echo [2/5] maven package with prod profile ...
|
||||||
|
cd /d %SRC%\jeecg-boot
|
||||||
|
call mvn clean package -pl jeecg-module-system/jeecg-system-start -am -DskipTests -P prod -T 1C
|
||||||
|
if errorlevel 1 ( echo [ERROR] build failed & pause & exit /b 1 )
|
||||||
|
if not exist "%BUILT_JAR%" ( echo [ERROR] built jar not found & pause & exit /b 1 )
|
||||||
|
|
||||||
|
echo [3/5] stop service ...
|
||||||
|
"%SVC%" stop
|
||||||
|
timeout /t 6 /nobreak >nul
|
||||||
|
|
||||||
|
echo [4/5] copy new jar ...
|
||||||
|
copy /Y "%BUILT_JAR%" "%DEPLOY_DIR%\%JAR_NAME%"
|
||||||
|
if errorlevel 1 ( echo [ERROR] copy failed, jar locked? & pause & exit /b 1 )
|
||||||
|
|
||||||
|
echo [5/5] start service ...
|
||||||
|
"%SVC%" start
|
||||||
|
echo ===== DEPLOY DONE =====
|
||||||
|
endlocal
|
||||||
|
pause
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2.3 后端发版流程
|
||||||
|
1. 本地改代码 → `git push`(推到 `main`)
|
||||||
|
2. RDP/向日葵到服务器 → 双击 `D:\deploy-server.bat`
|
||||||
|
3. 看日志确认 `Started ... in xx seconds`
|
||||||
|
|
||||||
|
> 首次构建会下载几百 MB 依赖(约 8 分钟),缓存在 `D:\maven-repo`,之后每次只需 1~3 分钟。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 三、前端部署(脚本已就绪)
|
||||||
|
|
||||||
|
前端 `jeecgboot-vue3` 用 **pnpm** 构建,产物 `dist/`,放到 nginx 的 `html\jeecg\`。
|
||||||
|
因服务器没 Node 且网络受限,**前端不在服务器构建**,而是:**本地构建 → dist 走 git → 服务器拉取替换**。
|
||||||
|
|
||||||
|
> `jeecgboot-vue3/dist` 被 `.gitignore` 忽略,所以构建后复制到根目录 **`web-dist`** 文件夹(未被忽略)再提交。
|
||||||
|
|
||||||
|
### 3.1 本地构建脚本 `build-frontend.bat`(本地 Win11 双击)
|
||||||
|
核心构建步骤与官网一致:`pnpm install` + `pnpm run build`,之后自动复制 dist 到 web-dist 并 git push。
|
||||||
|
|
||||||
|
```bat
|
||||||
|
@echo off
|
||||||
|
setlocal
|
||||||
|
set REPO=%~dp0
|
||||||
|
set WEBDIST=%REPO%web-dist
|
||||||
|
|
||||||
|
echo [1/4] build frontend (pnpm install + build) ...
|
||||||
|
cd /d %REPO%jeecgboot-vue3
|
||||||
|
call pnpm install
|
||||||
|
if errorlevel 1 ( echo [ERROR] pnpm install failed & pause & exit /b 1 )
|
||||||
|
call pnpm run build
|
||||||
|
if errorlevel 1 ( echo [ERROR] frontend build failed & pause & exit /b 1 )
|
||||||
|
if not exist "%REPO%jeecgboot-vue3\dist\index.html" ( echo [ERROR] dist/index.html not found & pause & exit /b 1 )
|
||||||
|
|
||||||
|
echo [2/4] refresh web-dist folder ...
|
||||||
|
if exist "%WEBDIST%" rmdir /S /Q "%WEBDIST%"
|
||||||
|
mkdir "%WEBDIST%"
|
||||||
|
xcopy "%REPO%jeecgboot-vue3\dist\*" "%WEBDIST%\" /E /Y /I >nul
|
||||||
|
|
||||||
|
echo [3/4] git add and commit web-dist ...
|
||||||
|
cd /d %REPO%
|
||||||
|
git add web-dist
|
||||||
|
git commit -m "frontend build dist update"
|
||||||
|
|
||||||
|
echo [4/4] git push ...
|
||||||
|
git push
|
||||||
|
if errorlevel 1 ( echo [ERROR] git push failed & pause & exit /b 1 )
|
||||||
|
echo ===== FRONTEND BUILT AND PUSHED =====
|
||||||
|
endlocal
|
||||||
|
pause
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3.2 服务器部署脚本 `D:\deploy-frontend.bat`(服务器双击)
|
||||||
|
```bat
|
||||||
|
@echo off
|
||||||
|
setlocal
|
||||||
|
set SRC=D:\qhmes-src
|
||||||
|
set GIT="C:\Program Files\Git\cmd\git.exe"
|
||||||
|
set WEB=D:\qhmes\nginx-1.30.1\html\jeecg
|
||||||
|
set NGINX_DIR=D:\qhmes\nginx-1.30.1
|
||||||
|
|
||||||
|
echo [1/3] git pull ...
|
||||||
|
cd /d %SRC%
|
||||||
|
%GIT% pull
|
||||||
|
if errorlevel 1 ( echo [ERROR] git pull failed & pause & exit /b 1 )
|
||||||
|
if not exist "%SRC%\web-dist\index.html" ( echo [ERROR] web-dist not found, run build-frontend.bat first & pause & exit /b 1 )
|
||||||
|
|
||||||
|
echo [2/3] replace nginx frontend files ...
|
||||||
|
if exist "%WEB%" rmdir /S /Q "%WEB%"
|
||||||
|
mkdir "%WEB%"
|
||||||
|
xcopy "%SRC%\web-dist\*" "%WEB%\" /E /Y /I >nul
|
||||||
|
if errorlevel 1 ( echo [ERROR] copy failed & pause & exit /b 1 )
|
||||||
|
|
||||||
|
echo [3/3] reload nginx (ignore error if not running) ...
|
||||||
|
cd /d %NGINX_DIR%
|
||||||
|
nginx.exe -s reload
|
||||||
|
echo ===== FRONTEND DEPLOY DONE =====
|
||||||
|
endlocal
|
||||||
|
pause
|
||||||
|
```
|
||||||
|
> **nginx 不用重启**:静态文件替换后自动生效。`nginx -s reload` 是平滑重载,**不要直接跑 `nginx.exe`**(会报端口占用)。
|
||||||
|
|
||||||
|
### 3.3 前端发版流程(两步双击)
|
||||||
|
1. 本地双击 `build-frontend.bat`(构建 + 推送 web-dist)
|
||||||
|
2. 服务器双击 `D:\deploy-frontend.bat`(拉取 + 替换 + reload)
|
||||||
|
3. 刷新浏览器
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 四、配置(profile)说明 —— 重点
|
||||||
|
|
||||||
|
### 4.1 哪个配置生效,由打包时的 Maven `-P` 决定
|
||||||
|
`application.yml` 里 `spring.profiles.active: '@profile.name@'` 是 Maven 占位符,打包时填入:
|
||||||
|
|
||||||
|
| 打包命令 | 生效配置 |
|
||||||
|
|---------|---------|
|
||||||
|
| `mvn package`(不带 -P) | **dev**(默认,`<activeByDefault>` 在 dev 上) |
|
||||||
|
| `mvn package -P prod` | **prod** |
|
||||||
|
| `mvn package -P test` | test |
|
||||||
|
|
||||||
|
> 发版脚本用的是 **`-P prod`**,所以烤进 jar 的是 prod 配置,运行时无需再加 `--spring.profiles.active`。
|
||||||
|
|
||||||
|
### 4.2 判断一个 jar 用的哪个配置
|
||||||
|
- 看启动日志:`The following 1 profile is active: "prod"`
|
||||||
|
- 解压 jar 看 `BOOT-INF/classes/application.yml` 里 `active` 的实际值
|
||||||
|
- 运行时 `--spring.profiles.active=xxx` 可强制覆盖
|
||||||
|
|
||||||
|
### 4.3 dev vs prod 的区别(本项目)
|
||||||
|
| 项 | dev | prod(当前测试服务器用) |
|
||||||
|
|----|-----|------|
|
||||||
|
| 端口 | 8888 | 8888(已改成与现网一致) |
|
||||||
|
| MySQL | `xsl.qdxsl.top:50768`(公网绕一圈) | `127.0.0.1:3306`(本机直连) |
|
||||||
|
| MySQL 密码 | 123456 | 123456(已改,原为 root) |
|
||||||
|
|
||||||
|
> **重要事实**:`xsl.qdxsl.top:50768` 与本机 `127.0.0.1:3306` 是**同一个生产库**(公网域名+端口转发到本机)。prod 走本机直连更快更稳。
|
||||||
|
> prod 配置的修改在 `application-prod.yml`,已带 `update-begin/update-end` 痕迹注释。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 五、踩过的坑(避免重复)
|
||||||
|
|
||||||
|
1. **bat 文件乱码/无法执行**:bat 里写中文 + 存成 UTF-8,cmd 按 GBK 读会乱码,连 `@echo off` 都坏。→ **bat 只用英文 ASCII,不带 BOM**。
|
||||||
|
2. **WinSW 报 `Invalid character in encoding`**:xml 里中文存成了 ANSI/GBK。→ 用 UTF-8 保存,或描述改英文。
|
||||||
|
3. **服务用 prod 启动报 `Access denied for user 'root'`**:prod 密码原写的 `root`,实际应为 `123456`。
|
||||||
|
4. **PowerShell 下载报 `未能创建 SSL/TLS 安全通道`**:Server 2016 默认 TLS 1.0。→ 先 `[Net.ServicePointManager]::SecurityProtocol = ... -bor 3072` 开启 TLS 1.2。
|
||||||
|
5. **服务器下载被 `127.0.0.1:10080` 的本机 Apache 拦截 404**:服务器网络有本机代理/DNS 劫持,外网下载不通。→ Maven/Node 等**在本地下好,向日葵拷过去**。
|
||||||
|
6. **`mvn` 报 `JAVA_HOME not defined correctly`**:`JAVA_HOME` 误设成了 `...\jdk-17\bin`。→ 应为根目录 `...\jdk-17`。
|
||||||
|
7. **`git clone D:\gitea\...qhmes.git` 拿到的没有源码**:那是 Gitea 裸仓库(只有 git 底层数据)。→ `git clone` 它到 `D:\qhmes-src` 得到工作副本。
|
||||||
|
8. **cmd 里 `cd D:\xxx` 不切盘**:要用 `cd /d D:\xxx`;`&` 是 PowerShell 语法,cmd 里不能用。
|
||||||
|
9. **PowerShell 粘贴 here-string 卡在 `>>`**:终止符 `'@` 没识别。→ 大段内容改用**记事本**另存为(All Files + ANSI),或写进 git 拉取。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 六、未来上线客户正式服务器的规划(待落地)
|
||||||
|
|
||||||
|
**核心原则:测试服务器可以 git 拉源码+构建;客户正式服务器只部署"已构建的成品",不放源码、不装构建工具、不依赖我方 gitea。**
|
||||||
|
|
||||||
|
### 6.1 目标流程
|
||||||
|
```
|
||||||
|
我方(测试服务器/开发机):打包出成品(jar + 前端dist)并测好
|
||||||
|
↓ 向日葵/U盘/网盘 传过去
|
||||||
|
客户正式服务器:双击 deploy.bat → 停服务 → 换jar → 换前端 → 启服务
|
||||||
|
```
|
||||||
|
|
||||||
|
### 6.2 必做改造:配置外置(同一 jar 走天下)
|
||||||
|
现在 prod 配置(数据库/IP/密码)烤死在 jar 里,是测试服务器的。客户的库不同,需把配置挪到 jar 外:
|
||||||
|
```
|
||||||
|
D:\qhmes\
|
||||||
|
├── jeecg-system-start-3.9.2.jar ← 所有环境通用,不用为每个客户重打
|
||||||
|
└── config\
|
||||||
|
└── application-prod.yml ← 本机专属:客户的数据库/IP/密码
|
||||||
|
```
|
||||||
|
Spring Boot 自动优先读 jar 同级 `config\` 目录的配置(外部 > jar 内 classpath)。
|
||||||
|
|
||||||
|
### 6.3 待办(上线时找 Claude 做)
|
||||||
|
1. 把 prod 配置从 jar 内挪到外部 `config\`,jar 变环境无关
|
||||||
|
2. 写"打 release 包"脚本:一键产出 `jar + 前端dist + deploy.bat` 发布包
|
||||||
|
3. 写客户服务器 `deploy.bat`:只"换文件+重启",不构建、不拉源码
|
||||||
|
4. (建议)测试服务器也提前切到外置配置,与客户环境保持一致,上线零改动
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 七、快速命令速查
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
# 后端发版
|
||||||
|
D:\deploy-server.bat # 服务器双击
|
||||||
|
|
||||||
|
# 前端发版
|
||||||
|
build-frontend.bat # 本地 Win11 双击
|
||||||
|
D:\deploy-frontend.bat # 服务器双击
|
||||||
|
|
||||||
|
# 看后端日志
|
||||||
|
Get-Content D:\qhmes\logs\qhmes-service.out.log -Wait -Tail 60
|
||||||
|
|
||||||
|
# 后端服务控制(管理员)
|
||||||
|
D:\qhmes\qhmes-service.exe stop|start|status
|
||||||
|
|
||||||
|
# nginx 平滑重载(在 nginx 目录下)
|
||||||
|
cd /d D:\qhmes\nginx-1.30.1
|
||||||
|
nginx.exe -s reload
|
||||||
|
```
|
||||||
@@ -1110,3 +1110,73 @@ jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/
|
|||||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslDesktopAnonController.java
|
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslDesktopAnonController.java
|
||||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslRubberQuickTestStdServiceImpl.java
|
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslRubberQuickTestStdServiceImpl.java
|
||||||
yy-admin-master/YY.Admin.Services/Service/RubberQuickTestStd/RubberQuickTestStdService.cs
|
yy-admin-master/YY.Admin.Services/Service/RubberQuickTestStd/RubberQuickTestStdService.cs
|
||||||
|
|
||||||
|
-- author:GHT---date:20260617--for: 【MES上辅机】密炼动作秒级采集 + 通用中间表采集配置 ---
|
||||||
|
需求:密炼机动作维护数据从中间表 MCSToMES_MixAct 秒级采集(机台名称→设备名称、动作名称→动作名称、动作地址→动作代号),
|
||||||
|
在「密炼动作」页支持 启动/停止采集与设置时间间隔(默认1秒);采集配置落库为通用配置表(mes_xsl_mcs_sync_config)供后续功能复用。
|
||||||
|
设计:新增通用采集配置表 + McsSyncHandler 扩展点 + McsSyncScheduler(ThreadPoolTaskScheduler 动态重排+启动加载);
|
||||||
|
MixActSyncHandler 增量 Upsert(按机台编号+动作代号唯一),保留手动维护数据;密炼机动作维护补全 equip_id/equip_type 字段,
|
||||||
|
唯一性由全局唯一改为(设备+动作代号)同设备内唯一,equipment_id 允许为空(采集未匹配台账时)。
|
||||||
|
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_153__mes_xsl_mcs_sync_config.sql
|
||||||
|
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mcs/entity/MesXslMcsSyncConfig.java
|
||||||
|
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mcs/mapper/MesXslMcsSyncConfigMapper.java
|
||||||
|
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mcs/service/IMesXslMcsSyncConfigService.java
|
||||||
|
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mcs/service/impl/MesXslMcsSyncConfigServiceImpl.java
|
||||||
|
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mcs/controller/MesXslMcsSyncConfigController.java
|
||||||
|
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mcs/sync/McsSyncHandler.java
|
||||||
|
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mcs/sync/McsSyncScheduler.java
|
||||||
|
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mcs/sync/handler/MixActSyncHandler.java
|
||||||
|
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslMixerAction.java
|
||||||
|
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslMixerActionService.java
|
||||||
|
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslMixerActionServiceImpl.java
|
||||||
|
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslMixerActionController.java
|
||||||
|
jeecgboot-vue3/src/views/xslmesMcs/mcsToMesMixAct/index.vue
|
||||||
|
jeecgboot-vue3/src/views/xslmesMcs/mcsToMesMixAct/McsToMesMixAct.api.ts
|
||||||
|
jeecgboot-vue3/src/views/xslmes/mesXslMixerAction/MesXslMixerAction.data.ts
|
||||||
|
jeecgboot-vue3/src/views/xslmes/mesXslMixerAction/MesXslMixerAction.api.ts
|
||||||
|
-- author:GHT---date:20260617--for: 【MES上辅机】密炼动作秒级采集 + 通用中间表采集配置 ---
|
||||||
|
|
||||||
|
-- author:GHT---date:20260617--for: 【MES上辅机】采集配置:通用表/字段绑定 + 配置驱动采集 ---
|
||||||
|
需求:在「MES上辅机数据」下新增「采集配置」,左选中间库表、右选MES表(mes_xsl_前缀),下方左带出中间库字段、右由用户选MES接收字段;
|
||||||
|
采集操作改为弹窗(是否采集+采集间隔),密炼动作页同样改为弹窗。
|
||||||
|
设计:统一为配置驱动——删除硬编码 MixActSyncHandler/McsSyncHandler,新增 GenericMcsSyncEngine(JdbcTemplate跨库读源表→按"匹配键"Upsert写MES表,
|
||||||
|
自动填充 id/时间/租户/del_flag,纯字段拷贝);McsSyncScheduler 改为按 configId 调度;新增字段映射表 mes_xsl_mcs_sync_field 与配置头扩展(target_table/config_name等);
|
||||||
|
密炼动作(MIX_ACT)改造为预置配置+字段映射;新增 McsMetaMapper 查询SQLServer/MySQL表与字段元数据;采集配置CRUD/详情/采集操作接口。
|
||||||
|
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_154__mes_xsl_mcs_sync_field.sql
|
||||||
|
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mcs/entity/MesXslMcsSyncConfig.java
|
||||||
|
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mcs/entity/MesXslMcsSyncField.java
|
||||||
|
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mcs/mapper/MesXslMcsSyncFieldMapper.java
|
||||||
|
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mcs/mapper/McsMetaMapper.java
|
||||||
|
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mcs/sync/GenericMcsSyncEngine.java
|
||||||
|
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mcs/sync/McsSyncScheduler.java
|
||||||
|
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mcs/service/IMesXslMcsSyncConfigService.java
|
||||||
|
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mcs/service/impl/MesXslMcsSyncConfigServiceImpl.java
|
||||||
|
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mcs/controller/MesXslMcsSyncConfigController.java
|
||||||
|
(删除)jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mcs/sync/McsSyncHandler.java
|
||||||
|
(删除)jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mcs/sync/handler/MixActSyncHandler.java
|
||||||
|
jeecgboot-vue3/src/views/xslmesMcs/mcsSyncConfig/index.vue
|
||||||
|
jeecgboot-vue3/src/views/xslmesMcs/mcsSyncConfig/mcsSyncConfig.api.ts
|
||||||
|
jeecgboot-vue3/src/views/xslmesMcs/mcsSyncConfig/mcsSyncConfig.data.ts
|
||||||
|
jeecgboot-vue3/src/views/xslmesMcs/mcsSyncConfig/components/SyncConfigModal.vue
|
||||||
|
jeecgboot-vue3/src/views/xslmesMcs/mcsSyncConfig/components/CollectModal.vue
|
||||||
|
jeecgboot-vue3/src/views/xslmesMcs/mcsToMesMixAct/index.vue
|
||||||
|
jeecgboot-vue3/src/views/xslmesMcs/mcsToMesMixAct/McsToMesMixAct.api.ts
|
||||||
|
-- author:GHT---date:20260617--for: 【MES上辅机】采集配置:通用表/字段绑定 + 配置驱动采集 ---
|
||||||
|
|
||||||
|
-- author:GHT---date:20260617--for: 【MES上辅机】采集模式:全量/时间/增量 + 批量增量写入(应对大表) ---
|
||||||
|
背景:原通用引擎每周期全表读源+全表读目标逐行Upsert,autocommit逐行往返,大表(上万~数十万)采集慢。
|
||||||
|
优化:GenericMcsSyncEngine 改为「一次读现有建索引+内存比对+变更检测+batchUpdate分批」;并新增三种采集模式(采集操作弹窗可配):
|
||||||
|
FULL全量匹配(小表全量Upsert)、TIME时间匹配(按时间列取当天/最近七天再Upsert,目标侧按窗口匹配键定向IN读取)、
|
||||||
|
INCR增量匹配(按增量列高水位>last_watermark、ORDER BY ASC取TOP N,仅追加并推进水位)。调度器落库 last_watermark。
|
||||||
|
mes_xsl_mcs_sync_config 增加 sync_mode/incr_column/time_window/batch_limit/last_watermark。
|
||||||
|
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_155__mes_xsl_mcs_sync_mode.sql
|
||||||
|
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mcs/entity/MesXslMcsSyncConfig.java
|
||||||
|
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mcs/sync/GenericMcsSyncEngine.java
|
||||||
|
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mcs/sync/McsSyncScheduler.java
|
||||||
|
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mcs/service/IMesXslMcsSyncConfigService.java
|
||||||
|
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mcs/service/impl/MesXslMcsSyncConfigServiceImpl.java
|
||||||
|
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mcs/controller/MesXslMcsSyncConfigController.java
|
||||||
|
jeecgboot-vue3/src/views/xslmesMcs/mcsSyncConfig/components/CollectModal.vue
|
||||||
|
jeecgboot-vue3/src/views/xslmesMcs/mcsSyncConfig/mcsSyncConfig.api.ts
|
||||||
|
jeecgboot-vue3/src/views/xslmesMcs/mcsSyncConfig/mcsSyncConfig.data.ts
|
||||||
|
-- author:GHT---date:20260617--for: 【MES上辅机】采集模式:全量/时间/增量 + 批量增量写入(应对大表) ---
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import org.jeecg.modules.xslmes.entity.MesXslVehicle;
|
|||||||
import org.jeecg.modules.xslmes.entity.MesXslWarehouse;
|
import org.jeecg.modules.xslmes.entity.MesXslWarehouse;
|
||||||
import org.jeecg.modules.xslmes.entity.MesXslWarehouseArea;
|
import org.jeecg.modules.xslmes.entity.MesXslWarehouseArea;
|
||||||
import org.jeecg.modules.xslmes.entity.MesXslMixingProductionPlan;
|
import org.jeecg.modules.xslmes.entity.MesXslMixingProductionPlan;
|
||||||
|
import org.jeecg.modules.xslmes.entity.MesXslRubberQuickTestMethod;
|
||||||
import org.jeecg.modules.xslmes.entity.MesXslRubberQuickTestRecord;
|
import org.jeecg.modules.xslmes.entity.MesXslRubberQuickTestRecord;
|
||||||
import org.jeecg.modules.xslmes.entity.MesXslRubberQuickTestRecordLine;
|
import org.jeecg.modules.xslmes.entity.MesXslRubberQuickTestRecordLine;
|
||||||
import org.jeecg.modules.xslmes.entity.MesXslRubberQuickTestStd;
|
import org.jeecg.modules.xslmes.entity.MesXslRubberQuickTestStd;
|
||||||
@@ -50,6 +51,7 @@ import org.jeecg.modules.xslmes.service.IMesXslVehicleService;
|
|||||||
import org.jeecg.modules.xslmes.service.IMesXslWarehouseAreaService;
|
import org.jeecg.modules.xslmes.service.IMesXslWarehouseAreaService;
|
||||||
import org.jeecg.modules.xslmes.service.IMesXslWarehouseService;
|
import org.jeecg.modules.xslmes.service.IMesXslWarehouseService;
|
||||||
import org.jeecg.modules.xslmes.service.IMesXslMixingProductionPlanService;
|
import org.jeecg.modules.xslmes.service.IMesXslMixingProductionPlanService;
|
||||||
|
import org.jeecg.modules.xslmes.service.IMesXslRubberQuickTestMethodService;
|
||||||
import org.jeecg.modules.xslmes.service.IMesXslRubberQuickTestRecordService;
|
import org.jeecg.modules.xslmes.service.IMesXslRubberQuickTestRecordService;
|
||||||
import org.jeecg.modules.xslmes.service.IMesXslRubberQuickTestStdService;
|
import org.jeecg.modules.xslmes.service.IMesXslRubberQuickTestStdService;
|
||||||
import org.jeecg.modules.xslmes.service.IMesXslWeightRecordService;
|
import org.jeecg.modules.xslmes.service.IMesXslWeightRecordService;
|
||||||
@@ -100,6 +102,7 @@ public class MesXslDesktopAnonController {
|
|||||||
private final IMesXslMixingProductionPlanService mixingProductionPlanService;
|
private final IMesXslMixingProductionPlanService mixingProductionPlanService;
|
||||||
private final IMesXslRubberQuickTestStdService rubberQuickTestStdService;
|
private final IMesXslRubberQuickTestStdService rubberQuickTestStdService;
|
||||||
private final IMesXslRubberQuickTestRecordService rubberQuickTestRecordService;
|
private final IMesXslRubberQuickTestRecordService rubberQuickTestRecordService;
|
||||||
|
private final IMesXslRubberQuickTestMethodService rubberQuickTestMethodService;
|
||||||
|
|
||||||
// ═══════════════════════════ 车辆管理 ═══════════════════════════
|
// ═══════════════════════════ 车辆管理 ═══════════════════════════
|
||||||
|
|
||||||
@@ -965,6 +968,9 @@ public class MesXslDesktopAnonController {
|
|||||||
QueryWrapper<MesXslRubberQuickTestStd> qw = QueryGenerator.initQueryWrapper(model, req.getParameterMap());
|
QueryWrapper<MesXslRubberQuickTestStd> qw = QueryGenerator.initQueryWrapper(model, req.getParameterMap());
|
||||||
qw.orderByDesc("create_time");
|
qw.orderByDesc("create_time");
|
||||||
IPage<MesXslRubberQuickTestStd> page = rubberQuickTestStdService.page(new Page<>(pageNo, pageSize), qw);
|
IPage<MesXslRubberQuickTestStd> page = rubberQuickTestStdService.page(new Page<>(pageNo, pageSize), qw);
|
||||||
|
if (page.getRecords() != null) {
|
||||||
|
page.getRecords().forEach(this::fillStdQuickTestTypeFromMethod);
|
||||||
|
}
|
||||||
return Result.OK(page);
|
return Result.OK(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -976,6 +982,7 @@ public class MesXslDesktopAnonController {
|
|||||||
return Result.error("未找到对应数据");
|
return Result.error("未找到对应数据");
|
||||||
}
|
}
|
||||||
entity.setLineList(rubberQuickTestStdService.selectLinesByStdId(id));
|
entity.setLineList(rubberQuickTestStdService.selectLinesByStdId(id));
|
||||||
|
fillStdQuickTestTypeFromMethod(entity);
|
||||||
return Result.OK(entity);
|
return Result.OK(entity);
|
||||||
}
|
}
|
||||||
//update-end---author:jiangxh ---date:2026-06-17 for:【快检实验标准】桌面端只读列表与详情-----------
|
//update-end---author:jiangxh ---date:2026-06-17 for:【快检实验标准】桌面端只读列表与详情-----------
|
||||||
@@ -1001,6 +1008,7 @@ public class MesXslDesktopAnonController {
|
|||||||
return Result.error("未找到胶料「" + name + "」对应的使用中且已批准的快检实验标准");
|
return Result.error("未找到胶料「" + name + "」对应的使用中且已批准的快检实验标准");
|
||||||
}
|
}
|
||||||
std.setLineList(rubberQuickTestStdService.selectLinesByStdId(std.getId()));
|
std.setLineList(rubberQuickTestStdService.selectLinesByStdId(std.getId()));
|
||||||
|
fillStdQuickTestTypeFromMethod(std);
|
||||||
return Result.OK(std);
|
return Result.OK(std);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1027,9 +1035,13 @@ public class MesXslDesktopAnonController {
|
|||||||
return Result.error("请维护检验明细");
|
return Result.error("请维护检验明细");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
if (oConvertUtils.isEmpty(record.getRecordNo())) {
|
||||||
|
record.setRecordNo(rubberQuickTestRecordService.generateDesktopRecordNo(record));
|
||||||
|
}
|
||||||
|
rubberQuickTestRecordService.fillQuickTestTypeForRecord(record);
|
||||||
rubberQuickTestRecordService.saveMain(record, lineList);
|
rubberQuickTestRecordService.saveMain(record, lineList);
|
||||||
stompNotify.publishRubberQuickTestRecordChanged("add", record.getId());
|
stompNotify.publishRubberQuickTestRecordChanged("add", record.getId());
|
||||||
return Result.OK("添加成功!");
|
return Result.OK(record.getRecordNo());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
return Result.error(e.getMessage());
|
return Result.error(e.getMessage());
|
||||||
@@ -1037,6 +1049,20 @@ public class MesXslDesktopAnonController {
|
|||||||
}
|
}
|
||||||
//update-end---author:jiangxh ---date:2026-06-17 for:【快检记录】桌面端胶料快检记录保存-----------
|
//update-end---author:jiangxh ---date:2026-06-17 for:【快检记录】桌面端胶料快检记录保存-----------
|
||||||
|
|
||||||
|
//update-begin---author:jiangxh ---date:20260618 for:【快检实验标准】桌面端回填实验方法关联实验类型-----------
|
||||||
|
private void fillStdQuickTestTypeFromMethod(MesXslRubberQuickTestStd std) {
|
||||||
|
if (std == null || oConvertUtils.isEmpty(std.getTestMethodId())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MesXslRubberQuickTestMethod method = rubberQuickTestMethodService.getById(std.getTestMethodId());
|
||||||
|
if (method == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
std.setQuickTestTypeId(method.getQuickTestTypeId());
|
||||||
|
std.setQuickTestTypeName(method.getQuickTestTypeName());
|
||||||
|
}
|
||||||
|
//update-end---author:jiangxh ---date:20260618 for:【快检实验标准】桌面端回填实验方法关联实验类型-----------
|
||||||
|
|
||||||
// ─────────────────────────── 车辆私有辅助 ────────────────────────────
|
// ─────────────────────────── 车辆私有辅助 ────────────────────────────
|
||||||
|
|
||||||
private void applyWeightNetAndBillType(MesXslWeightRecord record) {
|
private void applyWeightNetAndBillType(MesXslWeightRecord record) {
|
||||||
|
|||||||
@@ -112,13 +112,14 @@ public class MesXslMixerActionController extends JeecgController<MesXslMixerActi
|
|||||||
@Operation(summary = "校验动作名称是否重复")
|
@Operation(summary = "校验动作名称是否重复")
|
||||||
@GetMapping("/checkActionName")
|
@GetMapping("/checkActionName")
|
||||||
public Result<String> checkActionName(
|
public Result<String> checkActionName(
|
||||||
|
@RequestParam(name = "equipmentId", required = false) String equipmentId,
|
||||||
@RequestParam(name = "actionName", required = true) String actionName,
|
@RequestParam(name = "actionName", required = true) String actionName,
|
||||||
@RequestParam(name = "dataId", required = false) String dataId) {
|
@RequestParam(name = "dataId", required = false) String dataId) {
|
||||||
if (oConvertUtils.isEmpty(actionName) || actionName.trim().isEmpty()) {
|
if (oConvertUtils.isEmpty(actionName) || actionName.trim().isEmpty()) {
|
||||||
return Result.OK("该值可用!");
|
return Result.OK("该值可用!");
|
||||||
}
|
}
|
||||||
if (mesXslMixerActionService.isActionNameDuplicated(actionName, dataId)) {
|
if (mesXslMixerActionService.isActionNameDuplicated(equipmentId, actionName, dataId)) {
|
||||||
return Result.error("动作名称不能重复");
|
return Result.error("同一设备下动作名称不能重复");
|
||||||
}
|
}
|
||||||
return Result.OK("该值可用!");
|
return Result.OK("该值可用!");
|
||||||
}
|
}
|
||||||
@@ -126,13 +127,14 @@ public class MesXslMixerActionController extends JeecgController<MesXslMixerActi
|
|||||||
@Operation(summary = "校验动作代号是否重复")
|
@Operation(summary = "校验动作代号是否重复")
|
||||||
@GetMapping("/checkActionCode")
|
@GetMapping("/checkActionCode")
|
||||||
public Result<String> checkActionCode(
|
public Result<String> checkActionCode(
|
||||||
|
@RequestParam(name = "equipmentId", required = false) String equipmentId,
|
||||||
@RequestParam(name = "actionCode", required = true) String actionCode,
|
@RequestParam(name = "actionCode", required = true) String actionCode,
|
||||||
@RequestParam(name = "dataId", required = false) String dataId) {
|
@RequestParam(name = "dataId", required = false) String dataId) {
|
||||||
if (oConvertUtils.isEmpty(actionCode) || actionCode.trim().isEmpty()) {
|
if (oConvertUtils.isEmpty(actionCode) || actionCode.trim().isEmpty()) {
|
||||||
return Result.OK("该值可用!");
|
return Result.OK("该值可用!");
|
||||||
}
|
}
|
||||||
if (mesXslMixerActionService.isActionCodeDuplicated(actionCode, dataId)) {
|
if (mesXslMixerActionService.isActionCodeDuplicated(equipmentId, actionCode, dataId)) {
|
||||||
return Result.error("动作代号不能重复");
|
return Result.error("同一设备下动作代号不能重复");
|
||||||
}
|
}
|
||||||
return Result.OK("该值可用!");
|
return Result.OK("该值可用!");
|
||||||
}
|
}
|
||||||
@@ -152,15 +154,15 @@ public class MesXslMixerActionController extends JeecgController<MesXslMixerActi
|
|||||||
return "动作名称不能为空";
|
return "动作名称不能为空";
|
||||||
}
|
}
|
||||||
model.setActionName(model.getActionName().trim());
|
model.setActionName(model.getActionName().trim());
|
||||||
if (mesXslMixerActionService.isActionNameDuplicated(model.getActionName(), excludeId)) {
|
if (mesXslMixerActionService.isActionNameDuplicated(model.getEquipmentId(), model.getActionName(), excludeId)) {
|
||||||
return "动作名称不能重复";
|
return "同一设备下动作名称不能重复";
|
||||||
}
|
}
|
||||||
if (oConvertUtils.isEmpty(model.getActionCode()) || StringUtils.isBlank(model.getActionCode())) {
|
if (oConvertUtils.isEmpty(model.getActionCode()) || StringUtils.isBlank(model.getActionCode())) {
|
||||||
return "动作代号不能为空";
|
return "动作代号不能为空";
|
||||||
}
|
}
|
||||||
model.setActionCode(model.getActionCode().trim());
|
model.setActionCode(model.getActionCode().trim());
|
||||||
if (mesXslMixerActionService.isActionCodeDuplicated(model.getActionCode(), excludeId)) {
|
if (mesXslMixerActionService.isActionCodeDuplicated(model.getEquipmentId(), model.getActionCode(), excludeId)) {
|
||||||
return "动作代号不能重复";
|
return "同一设备下动作代号不能重复";
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import org.jeecg.common.system.base.controller.JeecgController;
|
|||||||
import org.jeecg.common.system.query.QueryGenerator;
|
import org.jeecg.common.system.query.QueryGenerator;
|
||||||
import org.jeecg.modules.xslmes.entity.MesXslMixingProductionPlan;
|
import org.jeecg.modules.xslmes.entity.MesXslMixingProductionPlan;
|
||||||
import org.jeecg.modules.xslmes.service.IMesXslMixingProductionPlanService;
|
import org.jeecg.modules.xslmes.service.IMesXslMixingProductionPlanService;
|
||||||
|
import org.jeecg.modules.xslmes.service.MesXslStompNotifyService;
|
||||||
import org.jeecg.modules.xslmes.vo.MesXslMixingProductionPlanOrderOptionVO;
|
import org.jeecg.modules.xslmes.vo.MesXslMixingProductionPlanOrderOptionVO;
|
||||||
import org.jeecg.modules.xslmes.vo.MesXslMixingProductionPlanSaveAllVO;
|
import org.jeecg.modules.xslmes.vo.MesXslMixingProductionPlanSaveAllVO;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
@@ -29,10 +30,13 @@ public class MesXslMixingProductionPlanController
|
|||||||
extends JeecgController<MesXslMixingProductionPlan, IMesXslMixingProductionPlanService> {
|
extends JeecgController<MesXslMixingProductionPlan, IMesXslMixingProductionPlanService> {
|
||||||
|
|
||||||
private final IMesXslMixingProductionPlanService mixingProductionPlanService;
|
private final IMesXslMixingProductionPlanService mixingProductionPlanService;
|
||||||
|
private final MesXslStompNotifyService stompNotify;
|
||||||
|
|
||||||
public MesXslMixingProductionPlanController(
|
public MesXslMixingProductionPlanController(
|
||||||
IMesXslMixingProductionPlanService mixingProductionPlanService) {
|
IMesXslMixingProductionPlanService mixingProductionPlanService,
|
||||||
|
MesXslStompNotifyService stompNotify) {
|
||||||
this.mixingProductionPlanService = mixingProductionPlanService;
|
this.mixingProductionPlanService = mixingProductionPlanService;
|
||||||
|
this.stompNotify = stompNotify;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "密炼生产计划维护-分页列表查询")
|
@Operation(summary = "密炼生产计划维护-分页列表查询")
|
||||||
@@ -56,6 +60,9 @@ public class MesXslMixingProductionPlanController
|
|||||||
@PostMapping("/saveAll")
|
@PostMapping("/saveAll")
|
||||||
public Result<String> saveAll(@RequestBody MesXslMixingProductionPlanSaveAllVO req) {
|
public Result<String> saveAll(@RequestBody MesXslMixingProductionPlanSaveAllVO req) {
|
||||||
mixingProductionPlanService.saveAllRows(req == null ? null : req.getRows());
|
mixingProductionPlanService.saveAllRows(req == null ? null : req.getRows());
|
||||||
|
//update-begin---author:jiangxh ---date:20260617 for:【密炼计划】整表保存后广播桌面端同步-----------
|
||||||
|
stompNotify.publishMixingProductionPlanChanged("saveAll", null);
|
||||||
|
//update-end---author:jiangxh ---date:20260617 for:【密炼计划】整表保存后广播桌面端同步-----------
|
||||||
return Result.OK("保存成功");
|
return Result.OK("保存成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,16 @@ public class MesXslMixerAction implements Serializable {
|
|||||||
@Schema(description = "设备名称冗余")
|
@Schema(description = "设备名称冗余")
|
||||||
private String equipmentName;
|
private String equipmentName;
|
||||||
|
|
||||||
|
//update-begin---author:GHT ---date:20260617 for:【MES上辅机】密炼动作秒级采集-补全机台字段-----------
|
||||||
|
@Excel(name = "机台编号", width = 15)
|
||||||
|
@Schema(description = "机台编号(采集自中间表 EquipID)")
|
||||||
|
private String equipId;
|
||||||
|
|
||||||
|
@Excel(name = "机台类型", width = 15)
|
||||||
|
@Schema(description = "机台类型(采集自中间表 EquipType)")
|
||||||
|
private String equipType;
|
||||||
|
//update-end---author:GHT ---date:20260617 for:【MES上辅机】密炼动作秒级采集-补全机台字段-----------
|
||||||
|
|
||||||
@Excel(name = "动作名称", width = 20)
|
@Excel(name = "动作名称", width = 20)
|
||||||
@Schema(description = "动作名称")
|
@Schema(description = "动作名称")
|
||||||
private String actionName;
|
private String actionName;
|
||||||
|
|||||||
@@ -43,91 +43,47 @@ public class MesXslMixingProductionPlan implements Serializable {
|
|||||||
@Schema(description = "机台名称")
|
@Schema(description = "机台名称")
|
||||||
private String machineName;
|
private String machineName;
|
||||||
|
|
||||||
|
@Excel(name = "班次标识", width = 10)
|
||||||
|
@Schema(description = "班次标识:1早班 2中班 3晚班")
|
||||||
|
private Integer shiftFlag;
|
||||||
|
|
||||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||||
@Schema(description = "计划日期(保存时写入当前日期)")
|
@Schema(description = "计划日期(保存时写入当前日期)")
|
||||||
private Date planDate;
|
private Date planDate;
|
||||||
|
@Schema(description = "计划号(yyyyMMddA三位流水)")
|
||||||
|
private String planNo;
|
||||||
|
|
||||||
@Schema(description = "早班计划ID")
|
@Schema(description = "计划ID(母胶/终胶计划)")
|
||||||
private String morningPlanId;
|
private String planId;
|
||||||
@Schema(description = "早班计划类型 M母胶/F终胶")
|
@Schema(description = "计划类型 M母胶/F终胶")
|
||||||
private String morningPlanType;
|
private String planType;
|
||||||
@Schema(description = "早班生产订单ID")
|
@Schema(description = "生产订单ID")
|
||||||
private String morningSourceOrderId;
|
private String sourceOrderId;
|
||||||
@Excel(name = "早班生产订单", width = 20)
|
@Schema(description = "胶料ID(取母胶/终胶计划materialCode)")
|
||||||
private String morningOrderNo;
|
private String materialId;
|
||||||
|
@Schema(description = "胶料名称(取母胶/终胶计划mesMaterialName)")
|
||||||
|
private String materialName;
|
||||||
|
@Excel(name = "生产订单", width = 20)
|
||||||
|
private String orderNo;
|
||||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||||
@Schema(description = "早班订单日期")
|
@Schema(description = "订单日期")
|
||||||
private Date morningOrderDate;
|
private Date orderDate;
|
||||||
@Excel(name = "早班配方名称", width = 20)
|
@Excel(name = "配方名称", width = 20)
|
||||||
private String morningFormulaName;
|
private String formulaName;
|
||||||
@Excel(name = "早班计划重量", width = 15)
|
@Excel(name = "计划重量", width = 15)
|
||||||
private BigDecimal morningPlanWeight;
|
private BigDecimal planWeight;
|
||||||
@Excel(name = "早班计划车数", width = 12)
|
@Excel(name = "计划车数", width = 12)
|
||||||
private Integer morningPlannedCarCount;
|
private Integer plannedCarCount;
|
||||||
@Excel(name = "早班已排产车数", width = 12)
|
@Excel(name = "已排产车数", width = 12)
|
||||||
private Integer morningScheduledCarCount;
|
private Integer scheduledCarCount;
|
||||||
@Excel(name = "早班完成车数", width = 12)
|
@Excel(name = "完成车数", width = 12)
|
||||||
private Integer morningFinishedCarCount;
|
private Integer finishedCarCount;
|
||||||
@Excel(name = "早班计划", width = 12)
|
@Excel(name = "计划", width = 12)
|
||||||
private Integer morningPlanCount;
|
private Integer planCount;
|
||||||
@Excel(name = "早班备注", width = 20)
|
@Excel(name = "备注", width = 20)
|
||||||
private String morningRemark;
|
private String remark;
|
||||||
|
|
||||||
@Schema(description = "中班计划ID")
|
|
||||||
private String noonPlanId;
|
|
||||||
@Schema(description = "中班计划类型 M母胶/F终胶")
|
|
||||||
private String noonPlanType;
|
|
||||||
@Schema(description = "中班生产订单ID")
|
|
||||||
private String noonSourceOrderId;
|
|
||||||
@Excel(name = "中班生产订单", width = 20)
|
|
||||||
private String noonOrderNo;
|
|
||||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
|
||||||
@Schema(description = "中班订单日期")
|
|
||||||
private Date noonOrderDate;
|
|
||||||
@Excel(name = "中班配方名称", width = 20)
|
|
||||||
private String noonFormulaName;
|
|
||||||
@Excel(name = "中班计划重量", width = 15)
|
|
||||||
private BigDecimal noonPlanWeight;
|
|
||||||
@Excel(name = "中班计划车数", width = 12)
|
|
||||||
private Integer noonPlannedCarCount;
|
|
||||||
@Excel(name = "中班已排产车数", width = 12)
|
|
||||||
private Integer noonScheduledCarCount;
|
|
||||||
@Excel(name = "中班完成车数", width = 12)
|
|
||||||
private Integer noonFinishedCarCount;
|
|
||||||
@Excel(name = "中班计划", width = 12)
|
|
||||||
private Integer noonPlanCount;
|
|
||||||
@Excel(name = "中班备注", width = 20)
|
|
||||||
private String noonRemark;
|
|
||||||
|
|
||||||
@Schema(description = "晚班计划ID")
|
|
||||||
private String nightPlanId;
|
|
||||||
@Schema(description = "晚班计划类型 M母胶/F终胶")
|
|
||||||
private String nightPlanType;
|
|
||||||
@Schema(description = "晚班生产订单ID")
|
|
||||||
private String nightSourceOrderId;
|
|
||||||
@Excel(name = "晚班生产订单", width = 20)
|
|
||||||
private String nightOrderNo;
|
|
||||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
|
||||||
@Schema(description = "晚班订单日期")
|
|
||||||
private Date nightOrderDate;
|
|
||||||
@Excel(name = "晚班配方名称", width = 20)
|
|
||||||
private String nightFormulaName;
|
|
||||||
@Excel(name = "晚班计划重量", width = 15)
|
|
||||||
private BigDecimal nightPlanWeight;
|
|
||||||
@Excel(name = "晚班计划车数", width = 12)
|
|
||||||
private Integer nightPlannedCarCount;
|
|
||||||
@Excel(name = "晚班已排产车数", width = 12)
|
|
||||||
private Integer nightScheduledCarCount;
|
|
||||||
@Excel(name = "晚班完成车数", width = 12)
|
|
||||||
private Integer nightFinishedCarCount;
|
|
||||||
@Excel(name = "晚班计划", width = 12)
|
|
||||||
private Integer nightPlanCount;
|
|
||||||
@Excel(name = "晚班备注", width = 20)
|
|
||||||
private String nightRemark;
|
|
||||||
|
|
||||||
private Integer tenantId;
|
private Integer tenantId;
|
||||||
private String sysOrgCode;
|
private String sysOrgCode;
|
||||||
|
|||||||
@@ -106,4 +106,12 @@ public class MesXslRubberQuickTestStd implements Serializable {
|
|||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
@Schema(description = "标准明细")
|
@Schema(description = "标准明细")
|
||||||
private List<MesXslRubberQuickTestStdLine> lineList;
|
private List<MesXslRubberQuickTestStdLine> lineList;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
@Schema(description = "实验类型ID(来自实验方法,桌面端展示)")
|
||||||
|
private String quickTestTypeId;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
@Schema(description = "实验类型名称(来自实验方法,桌面端展示)")
|
||||||
|
private String quickTestTypeName;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,150 @@
|
|||||||
|
package org.jeecg.modules.xslmes.mcs.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
|
import org.jeecg.common.api.vo.Result;
|
||||||
|
import org.jeecg.modules.xslmes.mcs.datasource.McsDataSourceManager;
|
||||||
|
import org.jeecg.modules.xslmes.mcs.entity.MesXslMcsSyncConfig;
|
||||||
|
import org.jeecg.modules.xslmes.mcs.mapper.McsMetaMapper;
|
||||||
|
import org.jeecg.modules.xslmes.mcs.service.IMesXslMcsSyncConfigService;
|
||||||
|
import org.jeecg.modules.xslmes.mcs.sync.McsSyncScheduler;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MES上辅机 中间表采集配置(表/字段绑定 + 采集操作 + 元数据)
|
||||||
|
*
|
||||||
|
* @author GHT
|
||||||
|
* @date 2026-06-17 for:【MES上辅机】采集配置-表与字段绑定
|
||||||
|
*/
|
||||||
|
@Tag(name = "MES上辅机采集配置")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/xslmes/mcs/syncConfig")
|
||||||
|
public class MesXslMcsSyncConfigController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IMesXslMcsSyncConfigService syncConfigService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private McsSyncScheduler syncScheduler;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private McsMetaMapper metaMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private McsDataSourceManager mcsDataSourceManager;
|
||||||
|
|
||||||
|
@Operation(summary = "采集配置-分页列表")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public Result<IPage<MesXslMcsSyncConfig>> list(MesXslMcsSyncConfig query,
|
||||||
|
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||||
|
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
|
||||||
|
LambdaQueryWrapper<MesXslMcsSyncConfig> qw = new LambdaQueryWrapper<MesXslMcsSyncConfig>()
|
||||||
|
.eq(MesXslMcsSyncConfig::getDelFlag, 0)
|
||||||
|
.like(StringUtils.isNotBlank(query.getConfigName()), MesXslMcsSyncConfig::getConfigName, query.getConfigName())
|
||||||
|
.like(StringUtils.isNotBlank(query.getSourceTable()), MesXslMcsSyncConfig::getSourceTable, query.getSourceTable())
|
||||||
|
.orderByDesc(MesXslMcsSyncConfig::getUpdateTime);
|
||||||
|
IPage<MesXslMcsSyncConfig> page = syncConfigService.page(new Page<>(pageNo, pageSize), qw);
|
||||||
|
page.getRecords().forEach(c -> c.setRunning(syncScheduler.isRunning(c.getId())));
|
||||||
|
return Result.OK(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "采集配置-详情(含字段映射)")
|
||||||
|
@GetMapping("/queryById")
|
||||||
|
public Result<MesXslMcsSyncConfig> queryById(@RequestParam("id") String id) {
|
||||||
|
MesXslMcsSyncConfig cfg = syncConfigService.getDetail(id);
|
||||||
|
if (cfg == null) {
|
||||||
|
return Result.error("配置不存在");
|
||||||
|
}
|
||||||
|
cfg.setRunning(syncScheduler.isRunning(id));
|
||||||
|
return Result.OK(cfg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "采集配置-按业务类型获取(密炼动作页用)")
|
||||||
|
@GetMapping("/getByBizType")
|
||||||
|
public Result<MesXslMcsSyncConfig> getByBizType(@RequestParam(name = "bizType", defaultValue = "MIX_ACT") String bizType) {
|
||||||
|
MesXslMcsSyncConfig cfg = syncConfigService.getByBizType(bizType);
|
||||||
|
if (cfg != null) {
|
||||||
|
cfg.setRunning(syncScheduler.isRunning(cfg.getId()));
|
||||||
|
}
|
||||||
|
return Result.OK(cfg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "采集配置-新增")
|
||||||
|
@RequiresPermissions("xslmes:mcsSyncConfig:add")
|
||||||
|
@PostMapping("/add")
|
||||||
|
public Result<String> add(@RequestBody MesXslMcsSyncConfig config) {
|
||||||
|
config.setId(null);
|
||||||
|
return syncConfigService.saveConfig(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "采集配置-编辑")
|
||||||
|
@RequiresPermissions("xslmes:mcsSyncConfig:edit")
|
||||||
|
@PostMapping("/edit")
|
||||||
|
public Result<String> edit(@RequestBody MesXslMcsSyncConfig config) {
|
||||||
|
if (StringUtils.isBlank(config.getId())) {
|
||||||
|
return Result.error("缺少配置ID");
|
||||||
|
}
|
||||||
|
return syncConfigService.saveConfig(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "采集配置-删除")
|
||||||
|
@RequiresPermissions("xslmes:mcsSyncConfig:delete")
|
||||||
|
@DeleteMapping("/delete")
|
||||||
|
public Result<String> delete(@RequestParam("id") String id) {
|
||||||
|
return syncConfigService.deleteConfig(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "采集操作-是否采集+采集间隔")
|
||||||
|
@RequiresPermissions("xslmes:mcsSyncConfig:setting")
|
||||||
|
@PostMapping("/saveCollect")
|
||||||
|
public Result<String> saveCollect(@RequestBody MesXslMcsSyncConfig body) {
|
||||||
|
return syncConfigService.saveCollect(body);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===================== 元数据 =====================
|
||||||
|
|
||||||
|
@Operation(summary = "元数据-中间库表清单")
|
||||||
|
@GetMapping("/meta/sourceTables")
|
||||||
|
public Result<List<Map<String, Object>>> sourceTables() {
|
||||||
|
if (!mcsDataSourceManager.isDbConfigActive()) {
|
||||||
|
return Result.error("中间库未连接,请先在「中间库连接配置」中启用");
|
||||||
|
}
|
||||||
|
return Result.OK(metaMapper.listSourceTables());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "元数据-中间库表字段")
|
||||||
|
@GetMapping("/meta/sourceColumns")
|
||||||
|
public Result<List<Map<String, Object>>> sourceColumns(@RequestParam("table") String table) {
|
||||||
|
if (!mcsDataSourceManager.isDbConfigActive()) {
|
||||||
|
return Result.error("中间库未连接,请先在「中间库连接配置」中启用");
|
||||||
|
}
|
||||||
|
if (!table.matches("^[A-Za-z0-9_]+$")) {
|
||||||
|
return Result.error("非法表名");
|
||||||
|
}
|
||||||
|
return Result.OK(metaMapper.listSourceColumns(table));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "元数据-MES业务表清单(mes_xsl_前缀)")
|
||||||
|
@GetMapping("/meta/targetTables")
|
||||||
|
public Result<List<Map<String, Object>>> targetTables() {
|
||||||
|
return Result.OK(metaMapper.listTargetTables());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "元数据-MES表字段")
|
||||||
|
@GetMapping("/meta/targetColumns")
|
||||||
|
public Result<List<Map<String, Object>>> targetColumns(@RequestParam("table") String table) {
|
||||||
|
if (!table.matches("^[A-Za-z0-9_]+$")) {
|
||||||
|
return Result.error("非法表名");
|
||||||
|
}
|
||||||
|
return Result.OK(metaMapper.listTargetColumns(table));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,126 @@
|
|||||||
|
package org.jeecg.modules.xslmes.mcs.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MES上辅机 中间表采集配置(通用)
|
||||||
|
* <p>按 bizType 区分不同业务(密炼动作/报警/配方等),供秒级定时采集统一复用</p>
|
||||||
|
*
|
||||||
|
* @author GHT
|
||||||
|
* @date 2026-06-17 for:【MES上辅机】密炼动作秒级采集
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("mes_xsl_mcs_sync_config")
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@Schema(description = "MES上辅机中间表采集配置")
|
||||||
|
public class MesXslMcsSyncConfig implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@TableId(type = IdType.ASSIGN_ID)
|
||||||
|
@Schema(description = "主键")
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@Schema(description = "业务类型(采集任务唯一标识,如 MIX_ACT 密炼动作;通用配置可为空)")
|
||||||
|
private String bizType;
|
||||||
|
|
||||||
|
@Schema(description = "配置名称")
|
||||||
|
private String configName;
|
||||||
|
|
||||||
|
@Schema(description = "业务名称")
|
||||||
|
private String bizName;
|
||||||
|
|
||||||
|
@Schema(description = "源中间表名")
|
||||||
|
private String sourceTable;
|
||||||
|
|
||||||
|
@Schema(description = "源中间表注释")
|
||||||
|
private String sourceTableComment;
|
||||||
|
|
||||||
|
@Schema(description = "MES目标表名")
|
||||||
|
private String targetTable;
|
||||||
|
|
||||||
|
@Schema(description = "MES目标表注释")
|
||||||
|
private String targetTableComment;
|
||||||
|
|
||||||
|
@Schema(description = "采集时间间隔(秒),默认1秒")
|
||||||
|
private Integer intervalSeconds;
|
||||||
|
|
||||||
|
@Schema(description = "采集状态(0停止,1运行)")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
@Schema(description = "采集模式(FULL全量匹配,TIME时间匹配,INCR增量匹配-标记位回写)")
|
||||||
|
private String syncMode;
|
||||||
|
|
||||||
|
@Schema(description = "时间列/标记列(源表列名)。TIME模式=时间列;INCR模式=同步标记列(为空表示未采集,采集后回写'1')")
|
||||||
|
private String incrColumn;
|
||||||
|
|
||||||
|
@Schema(description = "时间范围(TODAY当天,LAST7最近七天)")
|
||||||
|
private String timeWindow;
|
||||||
|
|
||||||
|
@Schema(description = "每轮最大采集行数(INCR模式TOP N)")
|
||||||
|
private Integer batchLimit;
|
||||||
|
|
||||||
|
@Schema(description = "增量采集高水位(INCR模式自动维护)")
|
||||||
|
private String lastWatermark;
|
||||||
|
|
||||||
|
@Schema(description = "增量标记采集条件(IS_NULL为空,EQ_EMPTY等于匹配值,NE_EMPTY不等于匹配值),INCR模式用")
|
||||||
|
private String flagCondition;
|
||||||
|
|
||||||
|
//update-begin---author:GHT ---date:20260617 for:【MES上辅机】增量采集条件等于/不等于支持自定义匹配值-----------
|
||||||
|
@Schema(description = "增量标记采集条件比较值(EQ_EMPTY/NE_EMPTY 用,留空表示空字符串),INCR模式用")
|
||||||
|
private String flagMatchValue;
|
||||||
|
//update-end---author:GHT ---date:20260617 for:【MES上辅机】增量采集条件等于/不等于支持自定义匹配值-----------
|
||||||
|
|
||||||
|
@Schema(description = "增量标记采集完成后回写值(默认1),INCR模式用")
|
||||||
|
private String flagWriteValue;
|
||||||
|
|
||||||
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@Schema(description = "最近一次采集时间")
|
||||||
|
private Date lastSyncTime;
|
||||||
|
|
||||||
|
@Schema(description = "最近一次采集结果")
|
||||||
|
private String lastSyncResult;
|
||||||
|
|
||||||
|
@Schema(description = "备注")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
@Schema(description = "租户ID")
|
||||||
|
private Integer tenantId;
|
||||||
|
|
||||||
|
private String createBy;
|
||||||
|
|
||||||
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
private String updateBy;
|
||||||
|
|
||||||
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
private Integer delFlag;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
@Schema(description = "字段映射明细(主子保存/详情用)")
|
||||||
|
private List<MesXslMcsSyncField> fieldList;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
@Schema(description = "采集任务是否运行中(运行态由调度器实时给出)")
|
||||||
|
private Boolean running;
|
||||||
|
}
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
package org.jeecg.modules.xslmes.mcs.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MES上辅机 采集字段映射(中间库源字段 → MES目标字段)
|
||||||
|
*
|
||||||
|
* @author GHT
|
||||||
|
* @date 2026-06-17 for:【MES上辅机】采集配置-表与字段绑定
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("mes_xsl_mcs_sync_field")
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@Schema(description = "MES上辅机采集字段映射")
|
||||||
|
public class MesXslMcsSyncField implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@TableId(type = IdType.ASSIGN_ID)
|
||||||
|
@Schema(description = "主键")
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@Schema(description = "采集配置ID")
|
||||||
|
private String configId;
|
||||||
|
|
||||||
|
@Schema(description = "中间库源字段名")
|
||||||
|
private String sourceField;
|
||||||
|
|
||||||
|
@Schema(description = "源字段注释")
|
||||||
|
private String sourceFieldComment;
|
||||||
|
|
||||||
|
@Schema(description = "源字段类型")
|
||||||
|
private String sourceFieldType;
|
||||||
|
|
||||||
|
@Schema(description = "MES目标字段名(接收字段)")
|
||||||
|
private String targetField;
|
||||||
|
|
||||||
|
@Schema(description = "MES目标字段注释")
|
||||||
|
private String targetFieldComment;
|
||||||
|
|
||||||
|
@Schema(description = "是否匹配键(0否,1是)")
|
||||||
|
private String matchKey;
|
||||||
|
|
||||||
|
@Schema(description = "排序")
|
||||||
|
private Integer sortNo;
|
||||||
|
|
||||||
|
@Schema(description = "租户ID")
|
||||||
|
private Integer tenantId;
|
||||||
|
|
||||||
|
private String createBy;
|
||||||
|
|
||||||
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
private String updateBy;
|
||||||
|
|
||||||
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
private Integer delFlag;
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
package org.jeecg.modules.xslmes.mcs.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 中间库(SQL Server) / MES(MySQL) 表与字段元数据查询。
|
||||||
|
* <p>源表元数据走 sqlserver_mcs 数据源,目标表元数据走默认 MES 库。</p>
|
||||||
|
*
|
||||||
|
* @author GHT
|
||||||
|
* @date 2026-06-17 for:【MES上辅机】采集配置-表与字段绑定
|
||||||
|
*/
|
||||||
|
public interface McsMetaMapper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 中间库表清单(含表注释 MS_Description)
|
||||||
|
*/
|
||||||
|
@DS("sqlserver_mcs")
|
||||||
|
@Select("SELECT t.name AS tableName, CAST(ep.value AS NVARCHAR(200)) AS tableComment "
|
||||||
|
+ "FROM sys.tables t "
|
||||||
|
+ "LEFT JOIN sys.extended_properties ep ON ep.major_id = t.object_id AND ep.minor_id = 0 AND ep.name = 'MS_Description' "
|
||||||
|
+ "ORDER BY t.name")
|
||||||
|
List<Map<String, Object>> listSourceTables();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 中间库表字段清单(含字段注释、类型)
|
||||||
|
*/
|
||||||
|
@DS("sqlserver_mcs")
|
||||||
|
@Select("SELECT c.name AS columnName, ty.name AS dataType, CAST(ep.value AS NVARCHAR(200)) AS columnComment "
|
||||||
|
+ "FROM sys.columns c "
|
||||||
|
+ "JOIN sys.types ty ON c.user_type_id = ty.user_type_id "
|
||||||
|
+ "LEFT JOIN sys.extended_properties ep ON ep.major_id = c.object_id AND ep.minor_id = c.column_id AND ep.name = 'MS_Description' "
|
||||||
|
+ "WHERE c.object_id = OBJECT_ID(#{table}) "
|
||||||
|
+ "ORDER BY c.column_id")
|
||||||
|
List<Map<String, Object>> listSourceColumns(@Param("table") String table);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MES 业务表清单(仅 mes_xsl_ 前缀)
|
||||||
|
*/
|
||||||
|
@Select("SELECT table_name AS tableName, table_comment AS tableComment "
|
||||||
|
+ "FROM information_schema.tables "
|
||||||
|
+ "WHERE table_schema = (SELECT DATABASE()) AND table_name LIKE 'mes\\_xsl\\_%' "
|
||||||
|
+ "ORDER BY table_name")
|
||||||
|
List<Map<String, Object>> listTargetTables();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MES 表字段清单(含字段注释、类型)
|
||||||
|
*/
|
||||||
|
@Select("SELECT column_name AS columnName, data_type AS dataType, column_comment AS columnComment "
|
||||||
|
+ "FROM information_schema.columns "
|
||||||
|
+ "WHERE table_schema = (SELECT DATABASE()) AND table_name = #{table} "
|
||||||
|
+ "ORDER BY ordinal_position")
|
||||||
|
List<Map<String, Object>> listTargetColumns(@Param("table") String table);
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package org.jeecg.modules.xslmes.mcs.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.jeecg.modules.xslmes.mcs.entity.MesXslMcsSyncConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MES上辅机 中间表采集配置 Mapper
|
||||||
|
*
|
||||||
|
* @author GHT
|
||||||
|
* @date 2026-06-17 for:【MES上辅机】密炼动作秒级采集
|
||||||
|
*/
|
||||||
|
public interface MesXslMcsSyncConfigMapper extends BaseMapper<MesXslMcsSyncConfig> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package org.jeecg.modules.xslmes.mcs.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.jeecg.modules.xslmes.mcs.entity.MesXslMcsSyncField;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MES上辅机 采集字段映射 Mapper
|
||||||
|
*
|
||||||
|
* @author GHT
|
||||||
|
* @date 2026-06-17 for:【MES上辅机】采集配置-表与字段绑定
|
||||||
|
*/
|
||||||
|
public interface MesXslMcsSyncFieldMapper extends BaseMapper<MesXslMcsSyncField> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package org.jeecg.modules.xslmes.mcs.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import org.jeecg.common.api.vo.Result;
|
||||||
|
import org.jeecg.modules.xslmes.mcs.entity.MesXslMcsSyncConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MES上辅机 中间表采集配置 Service(配置驱动:表/字段绑定 + 采集操作)
|
||||||
|
*
|
||||||
|
* @author GHT
|
||||||
|
* @date 2026-06-17 for:【MES上辅机】采集配置-表与字段绑定
|
||||||
|
*/
|
||||||
|
public interface IMesXslMcsSyncConfigService extends IService<MesXslMcsSyncConfig> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取配置详情(含字段映射明细 fieldList)
|
||||||
|
*/
|
||||||
|
MesXslMcsSyncConfig getDetail(String id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按业务类型获取最近配置(密炼动作页用,bizType=MIX_ACT)
|
||||||
|
*/
|
||||||
|
MesXslMcsSyncConfig getByBizType(String bizType);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存配置(头 + 字段映射明细,主子整存)
|
||||||
|
*/
|
||||||
|
Result<String> saveConfig(MesXslMcsSyncConfig config);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除配置及其字段映射,并停止采集
|
||||||
|
*/
|
||||||
|
Result<String> deleteConfig(String id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 采集操作:维护是否采集、采集间隔、采集模式(全量/时间/增量)及其参数。
|
||||||
|
* status='1' 启动并按间隔重排,'0' 停止。
|
||||||
|
*/
|
||||||
|
Result<String> saveCollect(MesXslMcsSyncConfig body);
|
||||||
|
}
|
||||||
@@ -0,0 +1,223 @@
|
|||||||
|
package org.jeecg.modules.xslmes.mcs.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.shiro.SecurityUtils;
|
||||||
|
import org.jeecg.common.api.vo.Result;
|
||||||
|
import org.jeecg.common.system.vo.LoginUser;
|
||||||
|
import org.jeecg.modules.xslmes.mcs.entity.MesXslMcsSyncConfig;
|
||||||
|
import org.jeecg.modules.xslmes.mcs.entity.MesXslMcsSyncField;
|
||||||
|
import org.jeecg.modules.xslmes.mcs.mapper.MesXslMcsSyncConfigMapper;
|
||||||
|
import org.jeecg.modules.xslmes.mcs.mapper.MesXslMcsSyncFieldMapper;
|
||||||
|
import org.jeecg.modules.xslmes.mcs.service.IMesXslMcsSyncConfigService;
|
||||||
|
import org.jeecg.modules.xslmes.mcs.sync.McsSyncScheduler;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MES上辅机 中间表采集配置 Service 实现
|
||||||
|
*
|
||||||
|
* @author GHT
|
||||||
|
* @date 2026-06-17 for:【MES上辅机】采集配置-表与字段绑定
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class MesXslMcsSyncConfigServiceImpl extends ServiceImpl<MesXslMcsSyncConfigMapper, MesXslMcsSyncConfig>
|
||||||
|
implements IMesXslMcsSyncConfigService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MesXslMcsSyncFieldMapper syncFieldMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private McsSyncScheduler syncScheduler;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MesXslMcsSyncConfig getDetail(String id) {
|
||||||
|
MesXslMcsSyncConfig cfg = getById(id);
|
||||||
|
if (cfg == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
cfg.setFieldList(listFields(id));
|
||||||
|
return cfg;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MesXslMcsSyncConfig getByBizType(String bizType) {
|
||||||
|
return getOne(new LambdaQueryWrapper<MesXslMcsSyncConfig>()
|
||||||
|
.eq(MesXslMcsSyncConfig::getBizType, bizType)
|
||||||
|
.eq(MesXslMcsSyncConfig::getDelFlag, 0)
|
||||||
|
.orderByDesc(MesXslMcsSyncConfig::getUpdateTime)
|
||||||
|
.last("LIMIT 1"), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public Result<String> saveConfig(MesXslMcsSyncConfig config) {
|
||||||
|
if (config == null) {
|
||||||
|
return Result.error("配置不能为空");
|
||||||
|
}
|
||||||
|
if (StringUtils.isBlank(config.getSourceTable())) {
|
||||||
|
return Result.error("请选择中间库源表");
|
||||||
|
}
|
||||||
|
if (StringUtils.isBlank(config.getTargetTable())) {
|
||||||
|
return Result.error("请选择MES目标表");
|
||||||
|
}
|
||||||
|
List<MesXslMcsSyncField> fields = config.getFieldList() != null ? config.getFieldList() : new ArrayList<>();
|
||||||
|
// 至少一个有效映射
|
||||||
|
boolean hasValid = fields.stream().anyMatch(f -> StringUtils.isNotBlank(f.getSourceField())
|
||||||
|
&& StringUtils.isNotBlank(f.getTargetField()));
|
||||||
|
if (!hasValid) {
|
||||||
|
return Result.error("请至少配置一个字段映射(源字段+接收字段)");
|
||||||
|
}
|
||||||
|
|
||||||
|
String username = currentUsername();
|
||||||
|
Date now = new Date();
|
||||||
|
if (config.getIntervalSeconds() == null || config.getIntervalSeconds() < 1) {
|
||||||
|
config.setIntervalSeconds(1);
|
||||||
|
}
|
||||||
|
if (config.getTenantId() == null) {
|
||||||
|
config.setTenantId(0);
|
||||||
|
}
|
||||||
|
config.setDelFlag(0);
|
||||||
|
config.setUpdateBy(username);
|
||||||
|
config.setUpdateTime(now);
|
||||||
|
|
||||||
|
boolean isUpdate = StringUtils.isNotBlank(config.getId());
|
||||||
|
if (isUpdate) {
|
||||||
|
MesXslMcsSyncConfig old = getById(config.getId());
|
||||||
|
if (old == null) {
|
||||||
|
return Result.error("配置不存在");
|
||||||
|
}
|
||||||
|
// 状态由采集操作维护,保存配置不改变运行状态
|
||||||
|
config.setStatus(old.getStatus());
|
||||||
|
updateById(config);
|
||||||
|
} else {
|
||||||
|
if (StringUtils.isBlank(config.getStatus())) {
|
||||||
|
config.setStatus("0");
|
||||||
|
}
|
||||||
|
config.setCreateBy(username);
|
||||||
|
config.setCreateTime(now);
|
||||||
|
save(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 整存字段映射:先物理删除旧映射再插入
|
||||||
|
syncFieldMapper.delete(new LambdaQueryWrapper<MesXslMcsSyncField>()
|
||||||
|
.eq(MesXslMcsSyncField::getConfigId, config.getId()));
|
||||||
|
int sort = 0;
|
||||||
|
for (MesXslMcsSyncField f : fields) {
|
||||||
|
if (StringUtils.isBlank(f.getSourceField())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
f.setId(null);
|
||||||
|
f.setConfigId(config.getId());
|
||||||
|
f.setSortNo(sort++);
|
||||||
|
f.setTenantId(config.getTenantId());
|
||||||
|
f.setDelFlag(0);
|
||||||
|
f.setCreateBy(username);
|
||||||
|
f.setCreateTime(now);
|
||||||
|
f.setUpdateBy(username);
|
||||||
|
f.setUpdateTime(now);
|
||||||
|
syncFieldMapper.insert(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 运行中则按新配置重排(间隔/映射即时生效)
|
||||||
|
if ("1".equals(config.getStatus())) {
|
||||||
|
syncScheduler.scheduleTask(getById(config.getId()));
|
||||||
|
}
|
||||||
|
return Result.OK(isUpdate ? "保存成功" : "新增成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public Result<String> deleteConfig(String id) {
|
||||||
|
MesXslMcsSyncConfig cfg = getById(id);
|
||||||
|
if (cfg == null) {
|
||||||
|
return Result.error("配置不存在");
|
||||||
|
}
|
||||||
|
syncScheduler.cancelTask(id);
|
||||||
|
syncFieldMapper.delete(new LambdaQueryWrapper<MesXslMcsSyncField>()
|
||||||
|
.eq(MesXslMcsSyncField::getConfigId, id));
|
||||||
|
removeById(id);
|
||||||
|
return Result.OK("删除成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<String> saveCollect(MesXslMcsSyncConfig body) {
|
||||||
|
if (body == null || StringUtils.isBlank(body.getId())) {
|
||||||
|
return Result.error("缺少配置ID");
|
||||||
|
}
|
||||||
|
MesXslMcsSyncConfig cfg = getById(body.getId());
|
||||||
|
if (cfg == null) {
|
||||||
|
return Result.error("配置不存在");
|
||||||
|
}
|
||||||
|
if (body.getIntervalSeconds() != null) {
|
||||||
|
if (body.getIntervalSeconds() < 1) {
|
||||||
|
return Result.error("采集间隔不能小于1秒");
|
||||||
|
}
|
||||||
|
cfg.setIntervalSeconds(body.getIntervalSeconds());
|
||||||
|
}
|
||||||
|
// 采集模式及参数
|
||||||
|
String mode = StringUtils.isBlank(body.getSyncMode()) ? "FULL" : body.getSyncMode().trim().toUpperCase();
|
||||||
|
cfg.setSyncMode(mode);
|
||||||
|
cfg.setIncrColumn(StringUtils.trimToNull(body.getIncrColumn()));
|
||||||
|
cfg.setTimeWindow(StringUtils.isBlank(body.getTimeWindow()) ? "TODAY" : body.getTimeWindow());
|
||||||
|
if (body.getBatchLimit() != null && body.getBatchLimit() > 0) {
|
||||||
|
cfg.setBatchLimit(body.getBatchLimit());
|
||||||
|
}
|
||||||
|
// INCR(标记回写):采集条件 + 回写值(可视化配置,回写值默认"1")
|
||||||
|
cfg.setFlagCondition(StringUtils.isBlank(body.getFlagCondition()) ? "IS_NULL" : body.getFlagCondition().trim().toUpperCase());
|
||||||
|
//update-begin---author:GHT ---date:20260617 for:【MES上辅机】增量采集条件等于/不等于支持自定义匹配值-----------
|
||||||
|
cfg.setFlagMatchValue(body.getFlagMatchValue());
|
||||||
|
//update-end---author:GHT ---date:20260617 for:【MES上辅机】增量采集条件等于/不等于支持自定义匹配值-----------
|
||||||
|
cfg.setFlagWriteValue(StringUtils.isBlank(body.getFlagWriteValue()) ? "1" : body.getFlagWriteValue());
|
||||||
|
if (("TIME".equals(mode) || "INCR".equals(mode)) && StringUtils.isBlank(cfg.getIncrColumn())) {
|
||||||
|
return Result.error("时间匹配/增量匹配需选择" + ("TIME".equals(mode) ? "时间列" : "标记列"));
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean on = "1".equals(body.getStatus());
|
||||||
|
cfg.setStatus(on ? "1" : "0");
|
||||||
|
cfg.setUpdateBy(currentUsername());
|
||||||
|
cfg.setUpdateTime(new Date());
|
||||||
|
updateById(cfg);
|
||||||
|
if (on) {
|
||||||
|
syncScheduler.scheduleTask(cfg);
|
||||||
|
return Result.OK("已启动采集(" + modeText(mode) + "),间隔 " + cfg.getIntervalSeconds() + " 秒");
|
||||||
|
}
|
||||||
|
syncScheduler.cancelTask(cfg.getId());
|
||||||
|
return Result.OK("已停止采集");
|
||||||
|
}
|
||||||
|
|
||||||
|
private String modeText(String mode) {
|
||||||
|
switch (mode) {
|
||||||
|
case "TIME":
|
||||||
|
return "时间匹配";
|
||||||
|
case "INCR":
|
||||||
|
return "增量匹配";
|
||||||
|
default:
|
||||||
|
return "全量匹配";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<MesXslMcsSyncField> listFields(String configId) {
|
||||||
|
return syncFieldMapper.selectList(new LambdaQueryWrapper<MesXslMcsSyncField>()
|
||||||
|
.eq(MesXslMcsSyncField::getConfigId, configId)
|
||||||
|
.eq(MesXslMcsSyncField::getDelFlag, 0)
|
||||||
|
.orderByAsc(MesXslMcsSyncField::getSortNo));
|
||||||
|
}
|
||||||
|
|
||||||
|
private String currentUsername() {
|
||||||
|
try {
|
||||||
|
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||||
|
return user != null ? user.getUsername() : "system";
|
||||||
|
} catch (Exception e) {
|
||||||
|
return "system";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,524 @@
|
|||||||
|
package org.jeecg.modules.xslmes.mcs.sync;
|
||||||
|
|
||||||
|
import com.baomidou.dynamic.datasource.DynamicRoutingDataSource;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.jeecg.modules.xslmes.mcs.datasource.McsDataSourceManager;
|
||||||
|
import org.jeecg.modules.xslmes.mcs.entity.MesXslMcsSyncConfig;
|
||||||
|
import org.jeecg.modules.xslmes.mcs.entity.MesXslMcsSyncField;
|
||||||
|
import org.jeecg.modules.xslmes.mcs.mapper.McsMetaMapper;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用中间表采集引擎(配置驱动,纯字段拷贝)。
|
||||||
|
* <p>支持三种采集模式,应对中间库不同规模的表:</p>
|
||||||
|
* <ul>
|
||||||
|
* <li><b>FULL 全量匹配</b>:全表读源+全表读目标→按匹配键 Upsert,仅写新增/变化行。适合小状态表、以更新为主。</li>
|
||||||
|
* <li><b>TIME 时间匹配</b>:按时间列只取窗口内数据(当天/最近七天)→按匹配键 Upsert,目标侧按窗口匹配键定向读取。避免全表扫描。</li>
|
||||||
|
* <li><b>INCR 增量匹配(标记位回写)</b>:源表选一「同步标记列」,仅采集该列为空(NULL/'')的行(TOP N 限流),
|
||||||
|
* 按匹配键 Upsert 到 MES 后,回写源表该列为 {@code '1'},下轮不再重复采集。适合带 GUID 主键、无可靠递增列的流水表。</li>
|
||||||
|
* </ul>
|
||||||
|
*
|
||||||
|
* @author GHT
|
||||||
|
* @date 2026-06-17 for:【MES上辅机】采集配置-表与字段绑定
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class GenericMcsSyncEngine {
|
||||||
|
|
||||||
|
public static final String MODE_FULL = "FULL";
|
||||||
|
public static final String MODE_TIME = "TIME";
|
||||||
|
public static final String MODE_INCR = "INCR";
|
||||||
|
|
||||||
|
/** 合法标识符(表名/列名),防止 SQL 注入 */
|
||||||
|
private static final Pattern IDENT = Pattern.compile("^[A-Za-z0-9_]+$");
|
||||||
|
|
||||||
|
/** 批量写入分批大小 */
|
||||||
|
private static final int BATCH_SIZE = 500;
|
||||||
|
/** IN 查询分块大小 */
|
||||||
|
private static final int IN_CHUNK = 1000;
|
||||||
|
/** INCR 默认每轮行数 */
|
||||||
|
private static final int DEFAULT_BATCH_LIMIT = 2000;
|
||||||
|
/** INCR 标记位回写后的已同步标识值 */
|
||||||
|
private static final String FLAG_SYNCED = "1";
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DataSource dataSource;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private McsMetaMapper metaMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private org.jeecg.modules.xslmes.mcs.datasource.McsDataSourceManager mcsDataSourceManager;
|
||||||
|
|
||||||
|
//update-begin---author:GHT ---date:20260617 for:【MES上辅机】采集模式 全量/时间/增量-----------
|
||||||
|
public String sync(MesXslMcsSyncConfig cfg, List<MesXslMcsSyncField> fields) {
|
||||||
|
String sourceTable = trim(cfg.getSourceTable());
|
||||||
|
String targetTable = trim(cfg.getTargetTable());
|
||||||
|
if (StringUtils.isBlank(sourceTable) || StringUtils.isBlank(targetTable)) {
|
||||||
|
return "未配置源表或目标表,跳过";
|
||||||
|
}
|
||||||
|
validateIdent(sourceTable);
|
||||||
|
validateIdent(targetTable);
|
||||||
|
|
||||||
|
List<MesXslMcsSyncField> maps = fields == null ? List.of() : fields.stream()
|
||||||
|
.filter(f -> StringUtils.isNotBlank(f.getSourceField()) && StringUtils.isNotBlank(f.getTargetField()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
if (maps.isEmpty()) {
|
||||||
|
return "无有效字段映射,跳过";
|
||||||
|
}
|
||||||
|
for (MesXslMcsSyncField f : maps) {
|
||||||
|
validateIdent(f.getSourceField());
|
||||||
|
validateIdent(f.getTargetField());
|
||||||
|
}
|
||||||
|
|
||||||
|
String mode = StringUtils.isBlank(cfg.getSyncMode()) ? MODE_FULL : cfg.getSyncMode().trim().toUpperCase();
|
||||||
|
JdbcTemplate sourceJt = new JdbcTemplate(getSourceDataSource());
|
||||||
|
JdbcTemplate targetJt = new JdbcTemplate(dataSource);
|
||||||
|
|
||||||
|
// 目标表标准字段探测 + 自动填充列
|
||||||
|
Set<String> targetCols = metaMapper.listTargetColumns(targetTable).stream()
|
||||||
|
.map(m -> String.valueOf(m.get("columnName")).toLowerCase())
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
boolean hasDel = targetCols.contains("del_flag");
|
||||||
|
|
||||||
|
List<MesXslMcsSyncField> keyMaps = maps.stream().filter(f -> "1".equals(f.getMatchKey())).collect(Collectors.toList());
|
||||||
|
Set<String> keyTargetsLower = keyMaps.stream().map(k -> k.getTargetField().toLowerCase()).collect(Collectors.toSet());
|
||||||
|
List<MesXslMcsSyncField> nonKeyMaps = maps.stream()
|
||||||
|
.filter(f -> !keyTargetsLower.contains(f.getTargetField().toLowerCase()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
int tenantId = cfg.getTenantId() != null ? cfg.getTenantId() : 0;
|
||||||
|
Timestamp now = new Timestamp(System.currentTimeMillis());
|
||||||
|
|
||||||
|
AutoCols auto = buildAutoCols(targetCols, maps, tenantId, now);
|
||||||
|
|
||||||
|
// 1. 按模式读源数据
|
||||||
|
LinkedHashSet<String> srcCols = maps.stream().map(MesXslMcsSyncField::getSourceField)
|
||||||
|
.collect(Collectors.toCollection(LinkedHashSet::new));
|
||||||
|
List<Map<String, Object>> rows;
|
||||||
|
|
||||||
|
//update-begin---author:GHT ---date:20260617 for:【MES上辅机】增量匹配改为标记位回写-----------
|
||||||
|
// INCR(标记回写)模式:仅采集「标记列」为空的行,采完回写"1",下轮不再重复采集
|
||||||
|
String flagCol = null;
|
||||||
|
boolean flagMode = MODE_INCR.equals(mode);
|
||||||
|
|
||||||
|
if (flagMode) {
|
||||||
|
flagCol = requireIncrColumn(cfg);
|
||||||
|
if (keyMaps.isEmpty()) {
|
||||||
|
return "增量(标记)采集需在字段映射中勾选至少一个匹配键作为回写主键(如 GUID)";
|
||||||
|
}
|
||||||
|
if (!mcsDataSourceManager.isWriteEnabled()) {
|
||||||
|
return "增量(标记)采集需开启中间库写入开关以回写同步标记,请在「中间库连接配置」开启写入";
|
||||||
|
}
|
||||||
|
srcCols.add(flagCol);
|
||||||
|
int limit = cfg.getBatchLimit() != null && cfg.getBatchLimit() > 0 ? cfg.getBatchLimit() : DEFAULT_BATCH_LIMIT;
|
||||||
|
String predicate = flagPredicate(flagCol, cfg.getFlagCondition(), cfg.getFlagMatchValue());
|
||||||
|
String sql = "SELECT TOP " + limit + " " + colList(srcCols) + " FROM [" + sourceTable + "]"
|
||||||
|
+ " WHERE (" + predicate + ")";
|
||||||
|
rows = sourceJt.queryForList(sql);
|
||||||
|
if (rows.isEmpty()) {
|
||||||
|
return "增量采集:无待采集数据";
|
||||||
|
}
|
||||||
|
} else if (MODE_TIME.equals(mode)) {
|
||||||
|
String incrCol = requireIncrColumn(cfg);
|
||||||
|
Timestamp[] window = timeWindow(cfg.getTimeWindow(), now);
|
||||||
|
StringBuilder sql = new StringBuilder("SELECT ").append(colList(srcCols))
|
||||||
|
.append(" FROM [").append(sourceTable).append("] WHERE [").append(incrCol).append("] >= ?");
|
||||||
|
List<Object> args = new ArrayList<>();
|
||||||
|
args.add(window[0]);
|
||||||
|
if (window[1] != null) {
|
||||||
|
sql.append(" AND [").append(incrCol).append("] < ?");
|
||||||
|
args.add(window[1]);
|
||||||
|
}
|
||||||
|
rows = sourceJt.queryForList(sql.toString(), args.toArray());
|
||||||
|
} else {
|
||||||
|
// FULL
|
||||||
|
rows = sourceJt.queryForList("SELECT " + colList(srcCols) + " FROM [" + sourceTable + "]");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rows.isEmpty()) {
|
||||||
|
return ("TIME".equals(mode) ? "时间匹配" : "全量匹配") + ":窗口/源表无数据,未更新";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 无匹配键 → 整批追加
|
||||||
|
if (keyMaps.isEmpty()) {
|
||||||
|
int ins = appendInsert(targetJt, targetTable, maps, auto, rows);
|
||||||
|
return String.format("采集完成(无匹配键,追加):新增%d,源%d条", ins, rows.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 加载现有目标数据(FULL 全量;TIME/INCR 仅按本批匹配键定向读取)
|
||||||
|
LinkedHashSet<String> existCols = new LinkedHashSet<>();
|
||||||
|
keyMaps.forEach(k -> existCols.add(k.getTargetField()));
|
||||||
|
maps.forEach(m -> existCols.add(m.getTargetField()));
|
||||||
|
Map<String, Map<String, Object>> existingByKey = (MODE_TIME.equals(mode) || flagMode)
|
||||||
|
? loadExistingByKeys(targetJt, targetTable, existCols, keyMaps, hasDel, rows)
|
||||||
|
: loadExistingAll(targetJt, targetTable, existCols, keyMaps, hasDel);
|
||||||
|
|
||||||
|
// 3. 比对 → 批量 Upsert
|
||||||
|
List<String> updateSetCols = nonKeyMaps.stream().map(MesXslMcsSyncField::getTargetField).collect(Collectors.toList());
|
||||||
|
boolean updTime = targetCols.contains("update_time") && !mappedContains(maps, "update_time");
|
||||||
|
boolean updBy = targetCols.contains("update_by") && !mappedContains(maps, "update_by");
|
||||||
|
String updateSql = buildUpdateSql(targetTable, updateSetCols, keyMaps, updTime, updBy, hasDel);
|
||||||
|
String insertSql = buildInsertSql(targetTable, maps, auto);
|
||||||
|
|
||||||
|
List<Object[]> insertArgs = new ArrayList<>();
|
||||||
|
List<Object[]> updateArgs = new ArrayList<>();
|
||||||
|
Set<String> handled = new HashSet<>();
|
||||||
|
int unchanged = 0;
|
||||||
|
|
||||||
|
for (Map<String, Object> row : rows) {
|
||||||
|
Map<String, Object> rci = ci(row);
|
||||||
|
String key = buildKeyFromSource(keyMaps, rci);
|
||||||
|
if (!handled.add(key)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Map<String, Object> existing = existingByKey.get(key);
|
||||||
|
if (existing == null) {
|
||||||
|
insertArgs.add(buildInsertArgs(maps, rci, auto));
|
||||||
|
} else if (updateSetCols.isEmpty()) {
|
||||||
|
unchanged++;
|
||||||
|
} else if (isChanged(nonKeyMaps, rci, existing)) {
|
||||||
|
updateArgs.add(buildUpdateArgs(nonKeyMaps, keyMaps, rci, updTime, updBy, now));
|
||||||
|
} else {
|
||||||
|
unchanged++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int ins = batch(targetJt, insertSql, insertArgs);
|
||||||
|
int upd = updateSetCols.isEmpty() ? 0 : batch(targetJt, updateSql, updateArgs);
|
||||||
|
|
||||||
|
// INCR(标记回写):对本批所有源行回写标记值,下轮不再采集
|
||||||
|
if (flagMode) {
|
||||||
|
String writeValue = StringUtils.isBlank(cfg.getFlagWriteValue()) ? FLAG_SYNCED : cfg.getFlagWriteValue();
|
||||||
|
int marked = writeBackFlag(sourceJt, sourceTable, flagCol, cfg.getFlagCondition(), cfg.getFlagMatchValue(), writeValue, keyMaps, rows);
|
||||||
|
return String.format("增量采集:新增%d,更新%d,未变%d,回写标记%d,源%d条",
|
||||||
|
ins, upd, unchanged, marked, rows.size());
|
||||||
|
}
|
||||||
|
return String.format("%s:新增%d,更新%d,未变%d,源%d条",
|
||||||
|
"TIME".equals(mode) ? "时间匹配" : "全量匹配", ins, upd, unchanged, rows.size());
|
||||||
|
//update-end---author:GHT ---date:20260617 for:【MES上辅机】增量匹配改为标记位回写-----------
|
||||||
|
}
|
||||||
|
|
||||||
|
//update-begin---author:GHT ---date:20260617 for:【MES上辅机】增量匹配改为标记位回写-----------
|
||||||
|
/**
|
||||||
|
* INCR 标记采集条件:根据配置构造源表标记列的判定谓词(SELECT 取数 + 回写守卫共用)。
|
||||||
|
* <ul>
|
||||||
|
* <li>{@code IS_NULL} 为空:{@code [col] IS NULL}</li>
|
||||||
|
* <li>{@code EQ_EMPTY} 等于:{@code [col] = '<匹配值>'}(匹配值留空时退化为等于空串)</li>
|
||||||
|
* <li>{@code NE_EMPTY} 不等于:{@code [col] <> '<匹配值>'}(匹配值留空时退化为不等于空串)</li>
|
||||||
|
* </ul>
|
||||||
|
* @param matchValue EQ_EMPTY/NE_EMPTY 的比较值,由用户填写,留空表示空字符串
|
||||||
|
*/
|
||||||
|
private String flagPredicate(String flagCol, String condition, String matchValue) {
|
||||||
|
String c = StringUtils.isBlank(condition) ? "IS_NULL" : condition.trim().toUpperCase();
|
||||||
|
switch (c) {
|
||||||
|
case "EQ_EMPTY":
|
||||||
|
return "[" + flagCol + "] = '" + sqlLiteral(matchValue) + "'";
|
||||||
|
case "NE_EMPTY":
|
||||||
|
return "[" + flagCol + "] <> '" + sqlLiteral(matchValue) + "'";
|
||||||
|
case "IS_NULL":
|
||||||
|
default:
|
||||||
|
return "[" + flagCol + "] IS NULL";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 将用户填写的匹配值转义为 SQL 字符串字面量内容(单引号翻倍),防止注入。 */
|
||||||
|
private String sqlLiteral(String value) {
|
||||||
|
return value == null ? "" : value.replace("'", "''");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* INCR 标记回写:把本批读到的源行该标记列回写为配置的回写值。
|
||||||
|
* <p>仅按匹配键精确定位本批读到的行(而非整列条件批量更新),
|
||||||
|
* 避免误标在本轮 SELECT 之后才进入中间库、尚未采集的新数据;
|
||||||
|
* 并以采集条件谓词做守卫,避开本轮已被其他进程改动的行。</p>
|
||||||
|
*/
|
||||||
|
private int writeBackFlag(JdbcTemplate sourceJt, String sourceTable, String flagCol, String condition,
|
||||||
|
String matchValue, String writeValue, List<MesXslMcsSyncField> keyMaps, List<Map<String, Object>> rows) {
|
||||||
|
validateIdent(flagCol);
|
||||||
|
StringBuilder sql = new StringBuilder("UPDATE [").append(sourceTable).append("] SET [")
|
||||||
|
.append(flagCol).append("] = ? WHERE ");
|
||||||
|
sql.append(keyMaps.stream().map(k -> "[" + k.getSourceField() + "] = ?").collect(Collectors.joining(" AND ")));
|
||||||
|
sql.append(" AND (").append(flagPredicate(flagCol, condition, matchValue)).append(")");
|
||||||
|
List<Object[]> argsList = new ArrayList<>();
|
||||||
|
Set<String> handled = new HashSet<>();
|
||||||
|
for (Map<String, Object> row : rows) {
|
||||||
|
Map<String, Object> rci = ci(row);
|
||||||
|
String key = buildKeyFromSource(keyMaps, rci);
|
||||||
|
if (!handled.add(key)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
List<Object> args = new ArrayList<>(keyMaps.size() + 1);
|
||||||
|
args.add(writeValue);
|
||||||
|
for (MesXslMcsSyncField k : keyMaps) {
|
||||||
|
args.add(rci.get(k.getSourceField()));
|
||||||
|
}
|
||||||
|
argsList.add(args.toArray());
|
||||||
|
}
|
||||||
|
return batch(sourceJt, sql.toString(), argsList);
|
||||||
|
}
|
||||||
|
//update-end---author:GHT ---date:20260617 for:【MES上辅机】增量匹配改为标记位回写-----------
|
||||||
|
|
||||||
|
// ---------------- 现有数据加载 ----------------
|
||||||
|
|
||||||
|
private Map<String, Map<String, Object>> loadExistingAll(JdbcTemplate jt, String table, LinkedHashSet<String> existCols,
|
||||||
|
List<MesXslMcsSyncField> keyMaps, boolean hasDel) {
|
||||||
|
String sql = "SELECT " + colListBt(existCols) + " FROM `" + table + "`" + (hasDel ? " WHERE `del_flag` = 0" : "");
|
||||||
|
Map<String, Map<String, Object>> map = new HashMap<>();
|
||||||
|
for (Map<String, Object> er : jt.queryForList(sql)) {
|
||||||
|
Map<String, Object> eci = ci(er);
|
||||||
|
map.put(buildKeyFromTarget(keyMaps, eci), eci);
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, Map<String, Object>> loadExistingByKeys(JdbcTemplate jt, String table, LinkedHashSet<String> existCols,
|
||||||
|
List<MesXslMcsSyncField> keyMaps, boolean hasDel,
|
||||||
|
List<Map<String, Object>> rows) {
|
||||||
|
Map<String, Map<String, Object>> map = new HashMap<>();
|
||||||
|
MesXslMcsSyncField firstKey = keyMaps.get(0);
|
||||||
|
// 收集窗口内首匹配键去重值
|
||||||
|
LinkedHashSet<Object> values = new LinkedHashSet<>();
|
||||||
|
for (Map<String, Object> row : rows) {
|
||||||
|
Object v = ci(row).get(firstKey.getSourceField());
|
||||||
|
if (v != null) {
|
||||||
|
values.add(v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (values.isEmpty()) {
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
List<Object> valueList = new ArrayList<>(values);
|
||||||
|
for (int i = 0; i < valueList.size(); i += IN_CHUNK) {
|
||||||
|
List<Object> part = valueList.subList(i, Math.min(i + IN_CHUNK, valueList.size()));
|
||||||
|
String ph = part.stream().map(x -> "?").collect(Collectors.joining(","));
|
||||||
|
String sql = "SELECT " + colListBt(existCols) + " FROM `" + table + "` WHERE `"
|
||||||
|
+ firstKey.getTargetField() + "` IN (" + ph + ")" + (hasDel ? " AND `del_flag` = 0" : "");
|
||||||
|
for (Map<String, Object> er : jt.queryForList(sql, part.toArray())) {
|
||||||
|
Map<String, Object> eci = ci(er);
|
||||||
|
map.put(buildKeyFromTarget(keyMaps, eci), eci);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------- 追加写入 ----------------
|
||||||
|
|
||||||
|
private int appendInsert(JdbcTemplate jt, String table, List<MesXslMcsSyncField> maps, AutoCols auto,
|
||||||
|
List<Map<String, Object>> rows) {
|
||||||
|
List<Object[]> insertArgs = new ArrayList<>();
|
||||||
|
for (Map<String, Object> row : rows) {
|
||||||
|
insertArgs.add(buildInsertArgs(maps, ci(row), auto));
|
||||||
|
}
|
||||||
|
return batch(jt, buildInsertSql(table, maps, auto), insertArgs);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------- SQL 构建 ----------------
|
||||||
|
|
||||||
|
private String buildInsertSql(String table, List<MesXslMcsSyncField> maps, AutoCols auto) {
|
||||||
|
List<String> cols = new ArrayList<>();
|
||||||
|
maps.forEach(m -> cols.add(m.getTargetField()));
|
||||||
|
if (auto.id) {
|
||||||
|
cols.add("id");
|
||||||
|
}
|
||||||
|
cols.addAll(auto.cols);
|
||||||
|
String colSql = cols.stream().map(c -> "`" + c + "`").collect(Collectors.joining(","));
|
||||||
|
String ph = cols.stream().map(c -> "?").collect(Collectors.joining(","));
|
||||||
|
return "INSERT INTO `" + table + "` (" + colSql + ") VALUES (" + ph + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object[] buildInsertArgs(List<MesXslMcsSyncField> maps, Map<String, Object> ci, AutoCols auto) {
|
||||||
|
List<Object> args = new ArrayList<>(maps.size() + auto.vals.size() + 1);
|
||||||
|
for (MesXslMcsSyncField m : maps) {
|
||||||
|
args.add(ci.get(m.getSourceField()));
|
||||||
|
}
|
||||||
|
if (auto.id) {
|
||||||
|
args.add(IdWorker.getIdStr());
|
||||||
|
}
|
||||||
|
args.addAll(auto.vals);
|
||||||
|
return args.toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildUpdateSql(String table, List<String> setCols, List<MesXslMcsSyncField> keyMaps,
|
||||||
|
boolean updTime, boolean updBy, boolean hasDel) {
|
||||||
|
if (setCols.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
StringBuilder sql = new StringBuilder("UPDATE `").append(table).append("` SET ");
|
||||||
|
sql.append(setCols.stream().map(c -> "`" + c + "` = ?").collect(Collectors.joining(",")));
|
||||||
|
if (updTime) {
|
||||||
|
sql.append(", `update_time` = ?");
|
||||||
|
}
|
||||||
|
if (updBy) {
|
||||||
|
sql.append(", `update_by` = ?");
|
||||||
|
}
|
||||||
|
sql.append(" WHERE ");
|
||||||
|
sql.append(keyMaps.stream().map(k -> "`" + k.getTargetField() + "` = ?").collect(Collectors.joining(" AND ")));
|
||||||
|
if (hasDel) {
|
||||||
|
sql.append(" AND `del_flag` = 0");
|
||||||
|
}
|
||||||
|
return sql.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object[] buildUpdateArgs(List<MesXslMcsSyncField> nonKeyMaps, List<MesXslMcsSyncField> keyMaps,
|
||||||
|
Map<String, Object> ci, boolean updTime, boolean updBy, Timestamp now) {
|
||||||
|
List<Object> args = new ArrayList<>();
|
||||||
|
for (MesXslMcsSyncField m : nonKeyMaps) {
|
||||||
|
args.add(ci.get(m.getSourceField()));
|
||||||
|
}
|
||||||
|
if (updTime) {
|
||||||
|
args.add(now);
|
||||||
|
}
|
||||||
|
if (updBy) {
|
||||||
|
args.add("mcs-sync");
|
||||||
|
}
|
||||||
|
for (MesXslMcsSyncField k : keyMaps) {
|
||||||
|
args.add(ci.get(k.getSourceField()));
|
||||||
|
}
|
||||||
|
return args.toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------- 工具 ----------------
|
||||||
|
|
||||||
|
/** 自动填充列汇总(id 单独标记,因每行不同) */
|
||||||
|
private static class AutoCols {
|
||||||
|
boolean id;
|
||||||
|
final List<String> cols = new ArrayList<>();
|
||||||
|
final List<Object> vals = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
private AutoCols buildAutoCols(Set<String> targetCols, List<MesXslMcsSyncField> maps, int tenantId, Timestamp now) {
|
||||||
|
AutoCols a = new AutoCols();
|
||||||
|
a.id = targetCols.contains("id") && !mappedContains(maps, "id");
|
||||||
|
addAuto(a, targetCols, maps, "create_time", now);
|
||||||
|
addAuto(a, targetCols, maps, "update_time", now);
|
||||||
|
addAuto(a, targetCols, maps, "create_by", "mcs-sync");
|
||||||
|
addAuto(a, targetCols, maps, "update_by", "mcs-sync");
|
||||||
|
addAuto(a, targetCols, maps, "tenant_id", tenantId);
|
||||||
|
addAuto(a, targetCols, maps, "del_flag", 0);
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addAuto(AutoCols a, Set<String> targetCols, List<MesXslMcsSyncField> maps, String col, Object val) {
|
||||||
|
if (targetCols.contains(col) && !mappedContains(maps, col)) {
|
||||||
|
a.cols.add(col);
|
||||||
|
a.vals.add(val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 返回 [start, end],end 可为 null */
|
||||||
|
private Timestamp[] timeWindow(String window, Timestamp now) {
|
||||||
|
String w = StringUtils.isBlank(window) ? "TODAY" : window.trim().toUpperCase();
|
||||||
|
if ("LAST7".equals(w)) {
|
||||||
|
return new Timestamp[]{Timestamp.valueOf(LocalDateTime.now().minusDays(7)), null};
|
||||||
|
}
|
||||||
|
// 默认当天
|
||||||
|
Timestamp start = Timestamp.valueOf(LocalDate.now().atStartOfDay());
|
||||||
|
Timestamp end = Timestamp.valueOf(LocalDate.now().plusDays(1).atStartOfDay());
|
||||||
|
return new Timestamp[]{start, end};
|
||||||
|
}
|
||||||
|
|
||||||
|
private String requireIncrColumn(MesXslMcsSyncConfig cfg) {
|
||||||
|
String col = trim(cfg.getIncrColumn());
|
||||||
|
if (StringUtils.isBlank(col)) {
|
||||||
|
throw new IllegalArgumentException("当前采集模式需指定标记列/时间列,请在采集操作中配置");
|
||||||
|
}
|
||||||
|
validateIdent(col);
|
||||||
|
return col;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int batch(JdbcTemplate jt, String sql, List<Object[]> argsList) {
|
||||||
|
if (sql == null || argsList.isEmpty()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int total = 0;
|
||||||
|
for (int i = 0; i < argsList.size(); i += BATCH_SIZE) {
|
||||||
|
List<Object[]> part = argsList.subList(i, Math.min(i + BATCH_SIZE, argsList.size()));
|
||||||
|
jt.batchUpdate(sql, part);
|
||||||
|
total += part.size();
|
||||||
|
}
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isChanged(List<MesXslMcsSyncField> nonKeyMaps, Map<String, Object> ci, Map<String, Object> existing) {
|
||||||
|
for (MesXslMcsSyncField m : nonKeyMaps) {
|
||||||
|
if (!normVal(ci.get(m.getSourceField())).equals(normVal(existing.get(m.getTargetField())))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildKeyFromSource(List<MesXslMcsSyncField> keyMaps, Map<String, Object> ci) {
|
||||||
|
return keyMaps.stream().map(k -> normKey(ci.get(k.getSourceField()))).collect(Collectors.joining("||"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildKeyFromTarget(List<MesXslMcsSyncField> keyMaps, Map<String, Object> eci) {
|
||||||
|
return keyMaps.stream().map(k -> normKey(eci.get(k.getTargetField()))).collect(Collectors.joining("||"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, Object> ci(Map<String, Object> row) {
|
||||||
|
Map<String, Object> m = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
||||||
|
m.putAll(row);
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String colList(LinkedHashSet<String> cols) {
|
||||||
|
return cols.stream().map(c -> "[" + c + "]").collect(Collectors.joining(","));
|
||||||
|
}
|
||||||
|
|
||||||
|
private String colListBt(LinkedHashSet<String> cols) {
|
||||||
|
return cols.stream().map(c -> "`" + c + "`").collect(Collectors.joining(","));
|
||||||
|
}
|
||||||
|
|
||||||
|
private String normKey(Object v) {
|
||||||
|
return v == null ? "" : String.valueOf(v).trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String normVal(Object v) {
|
||||||
|
return v == null ? " " : String.valueOf(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean mappedContains(List<MesXslMcsSyncField> maps, String targetCol) {
|
||||||
|
return maps.stream().anyMatch(m -> m.getTargetField() != null && m.getTargetField().equalsIgnoreCase(targetCol));
|
||||||
|
}
|
||||||
|
|
||||||
|
private DataSource getSourceDataSource() {
|
||||||
|
DynamicRoutingDataSource routing = (DynamicRoutingDataSource) dataSource;
|
||||||
|
DataSource src = routing.getDataSources().get(McsDataSourceManager.DS_KEY);
|
||||||
|
if (src == null) {
|
||||||
|
throw new IllegalStateException("中间库数据源 " + McsDataSourceManager.DS_KEY + " 未注册");
|
||||||
|
}
|
||||||
|
return src;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateIdent(String name) {
|
||||||
|
if (name == null || !IDENT.matcher(name).matches()) {
|
||||||
|
throw new IllegalArgumentException("非法的表名或字段名: " + name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String trim(String s) {
|
||||||
|
return s == null ? null : s.trim();
|
||||||
|
}
|
||||||
|
//update-end---author:GHT ---date:20260617 for:【MES上辅机】采集模式 全量/时间/增量-----------
|
||||||
|
}
|
||||||
@@ -0,0 +1,162 @@
|
|||||||
|
package org.jeecg.modules.xslmes.mcs.sync;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.jeecg.modules.xslmes.mcs.datasource.McsDataSourceManager;
|
||||||
|
import org.jeecg.modules.xslmes.mcs.entity.MesXslMcsSyncConfig;
|
||||||
|
import org.jeecg.modules.xslmes.mcs.entity.MesXslMcsSyncField;
|
||||||
|
import org.jeecg.modules.xslmes.mcs.mapper.MesXslMcsSyncConfigMapper;
|
||||||
|
import org.jeecg.modules.xslmes.mcs.mapper.MesXslMcsSyncFieldMapper;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||||
|
import org.springframework.context.event.EventListener;
|
||||||
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import jakarta.annotation.PostConstruct;
|
||||||
|
import jakarta.annotation.PreDestroy;
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 中间表采集调度器(通用,配置驱动)。
|
||||||
|
* <p>基于 {@link ThreadPoolTaskScheduler} 为每个运行中的采集配置维护一个可重排的定时任务,
|
||||||
|
* 支持秒级间隔、运行时改间隔、启动/停止。每次触发调用 {@link GenericMcsSyncEngine} 执行采集。</p>
|
||||||
|
*
|
||||||
|
* @author GHT
|
||||||
|
* @date 2026-06-17 for:【MES上辅机】采集配置-表与字段绑定
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class McsSyncScheduler {
|
||||||
|
|
||||||
|
private static final String LOG_TAG = "[MCS采集]";
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MesXslMcsSyncConfigMapper syncConfigMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MesXslMcsSyncFieldMapper syncFieldMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private McsDataSourceManager mcsDataSourceManager;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private GenericMcsSyncEngine syncEngine;
|
||||||
|
|
||||||
|
/** 运行中的定时任务,configId -> future */
|
||||||
|
private final Map<String, ScheduledFuture<?>> runningTasks = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
private ThreadPoolTaskScheduler taskScheduler;
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public void init() {
|
||||||
|
taskScheduler = new ThreadPoolTaskScheduler();
|
||||||
|
taskScheduler.setPoolSize(4);
|
||||||
|
taskScheduler.setThreadNamePrefix("mcs-sync-");
|
||||||
|
taskScheduler.setWaitForTasksToCompleteOnShutdown(true);
|
||||||
|
taskScheduler.setAwaitTerminationSeconds(10);
|
||||||
|
taskScheduler.initialize();
|
||||||
|
log.info("{} 采集调度器初始化完成", LOG_TAG);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PreDestroy
|
||||||
|
public void destroy() {
|
||||||
|
runningTasks.values().forEach(f -> f.cancel(false));
|
||||||
|
runningTasks.clear();
|
||||||
|
if (taskScheduler != null) {
|
||||||
|
taskScheduler.shutdown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应用启动后,加载所有 status=1 的采集配置并启动定时任务
|
||||||
|
*/
|
||||||
|
@EventListener(ApplicationReadyEvent.class)
|
||||||
|
public void loadOnStartup() {
|
||||||
|
try {
|
||||||
|
List<MesXslMcsSyncConfig> configs = syncConfigMapper.selectList(
|
||||||
|
new LambdaQueryWrapper<MesXslMcsSyncConfig>()
|
||||||
|
.eq(MesXslMcsSyncConfig::getDelFlag, 0)
|
||||||
|
.eq(MesXslMcsSyncConfig::getStatus, "1"));
|
||||||
|
configs.forEach(this::scheduleTask);
|
||||||
|
log.info("{} 启动加载采集任务完成,已启动={}", LOG_TAG, configs.size());
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("{} 启动加载采集任务失败: {}", LOG_TAG, e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRunning(String configId) {
|
||||||
|
ScheduledFuture<?> f = runningTasks.get(configId);
|
||||||
|
return f != null && !f.isCancelled();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (重新)按配置的间隔调度采集任务。已存在则先取消再重排,实现运行时改间隔。
|
||||||
|
*/
|
||||||
|
public synchronized void scheduleTask(MesXslMcsSyncConfig config) {
|
||||||
|
if (config == null || config.getId() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cancelTask(config.getId());
|
||||||
|
long seconds = config.getIntervalSeconds() != null && config.getIntervalSeconds() > 0
|
||||||
|
? config.getIntervalSeconds() : 1L;
|
||||||
|
String configId = config.getId();
|
||||||
|
ScheduledFuture<?> future = taskScheduler.scheduleWithFixedDelay(
|
||||||
|
() -> runOnce(configId), Duration.ofSeconds(seconds));
|
||||||
|
runningTasks.put(configId, future);
|
||||||
|
log.info("{} 采集任务已启动 configId={} 间隔={}s", LOG_TAG, configId, seconds);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取消采集任务(仅停内存定时,不改库)
|
||||||
|
*/
|
||||||
|
public synchronized void cancelTask(String configId) {
|
||||||
|
ScheduledFuture<?> old = runningTasks.remove(configId);
|
||||||
|
if (old != null) {
|
||||||
|
old.cancel(false);
|
||||||
|
log.info("{} 采集任务已停止 configId={}", LOG_TAG, configId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单次采集执行:连接/读取开关守卫 + 调用通用引擎 + 落库结果
|
||||||
|
*/
|
||||||
|
private void runOnce(String configId) {
|
||||||
|
MesXslMcsSyncConfig cfg = syncConfigMapper.selectById(configId);
|
||||||
|
if (cfg == null || cfg.getDelFlag() != null && cfg.getDelFlag() == 1 || !"1".equals(cfg.getStatus())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 中间库未启用或读取开关关闭时安静跳过
|
||||||
|
if (!mcsDataSourceManager.isDbConfigActive() || !mcsDataSourceManager.isReadEnabled()) {
|
||||||
|
log.debug("{} 中间库未就绪或读取关闭,跳过 configId={}", LOG_TAG, configId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
List<MesXslMcsSyncField> fields = syncFieldMapper.selectList(
|
||||||
|
new LambdaQueryWrapper<MesXslMcsSyncField>()
|
||||||
|
.eq(MesXslMcsSyncField::getConfigId, configId)
|
||||||
|
.eq(MesXslMcsSyncField::getDelFlag, 0)
|
||||||
|
.orderByAsc(MesXslMcsSyncField::getSortNo));
|
||||||
|
String result = syncEngine.sync(cfg, fields);
|
||||||
|
// INCR 改为标记位回写后不再维护高水位,仅落库采集结果
|
||||||
|
updateSyncResult(configId, result, null);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("{} 采集异常 configId={}: {}", LOG_TAG, configId, e.getMessage(), e);
|
||||||
|
updateSyncResult(configId, "采集失败:" + e.getMessage(), null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateSyncResult(String id, String result, String watermark) {
|
||||||
|
MesXslMcsSyncConfig update = new MesXslMcsSyncConfig();
|
||||||
|
update.setId(id);
|
||||||
|
update.setLastSyncTime(new Date());
|
||||||
|
update.setLastSyncResult(result != null && result.length() > 480 ? result.substring(0, 480) : result);
|
||||||
|
update.setLastWatermark(watermark);
|
||||||
|
syncConfigMapper.updateById(update);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,9 +5,9 @@ import org.jeecg.modules.xslmes.entity.MesXslMixerAction;
|
|||||||
|
|
||||||
public interface IMesXslMixerActionService extends IService<MesXslMixerAction> {
|
public interface IMesXslMixerActionService extends IService<MesXslMixerAction> {
|
||||||
|
|
||||||
boolean isActionNameDuplicated(String actionName, String excludeId);
|
boolean isActionNameDuplicated(String equipmentId, String actionName, String excludeId);
|
||||||
|
|
||||||
boolean isActionCodeDuplicated(String actionCode, String excludeId);
|
boolean isActionCodeDuplicated(String equipmentId, String actionCode, String excludeId);
|
||||||
|
|
||||||
void fillEquipmentName(MesXslMixerAction model);
|
void fillEquipmentName(MesXslMixerAction model);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,5 +25,13 @@ public interface IMesXslRubberQuickTestRecordService extends IService<MesXslRubb
|
|||||||
|
|
||||||
String generateRecordNo(MesXslRubberQuickTestRecord context);
|
String generateRecordNo(MesXslRubberQuickTestRecord context);
|
||||||
|
|
||||||
|
//update-begin---author:jiangxh ---date:20260618 for:【快检记录】桌面端快检记录号生成-----------
|
||||||
|
/** 桌面端快检记录号:yyyyMMdd + 4位流水 + 胶料名称,如 202606180001SA889 */
|
||||||
|
String generateDesktopRecordNo(MesXslRubberQuickTestRecord context);
|
||||||
|
|
||||||
|
/** 桌面端保存前:按实验标准关联实验方法回填检验类型 */
|
||||||
|
void fillQuickTestTypeForRecord(MesXslRubberQuickTestRecord record);
|
||||||
|
//update-end---author:jiangxh ---date:20260618 for:【快检记录】桌面端快检记录号生成-----------
|
||||||
|
|
||||||
List<String> batchFromMaterial(MesXslRubberQuickTestRecordBatchFromMaterialVO vo);
|
List<String> batchFromMaterial(MesXslRubberQuickTestRecordBatchFromMaterialVO vo);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,6 +99,14 @@ public class MesXslStompNotifyService {
|
|||||||
}
|
}
|
||||||
//update-end---author:jiangxh ---date:20260617 for:【快检实验标准】桌面端只读同步 STOMP-----------
|
//update-end---author:jiangxh ---date:20260617 for:【快检实验标准】桌面端只读同步 STOMP-----------
|
||||||
|
|
||||||
|
//update-begin---author:jiangxh ---date:20260617 for:【密炼计划】桌面端只读同步 STOMP-----------
|
||||||
|
/** 广播密炼生产计划变更事件到 /topic/sync/mes-mixing-production-plans */
|
||||||
|
public void publishMixingProductionPlanChanged(String action, String mixingProductionPlanId) {
|
||||||
|
publish("/topic/sync/mes-mixing-production-plans", "MIXING_PRODUCTION_PLAN_CHANGED",
|
||||||
|
"mixingProductionPlanId", mixingProductionPlanId, action);
|
||||||
|
}
|
||||||
|
//update-end---author:jiangxh ---date:20260617 for:【密炼计划】桌面端只读同步 STOMP-----------
|
||||||
|
|
||||||
// ─────────────────────────── 私有辅助 ────────────────────────────
|
// ─────────────────────────── 私有辅助 ────────────────────────────
|
||||||
|
|
||||||
private void publish(String topic, String cmd, String idKey, String idValue, String action) {
|
private void publish(String topic, String cmd, String idKey, String idValue, String action) {
|
||||||
|
|||||||
@@ -17,13 +17,16 @@ public class MesXslMixerActionServiceImpl extends ServiceImpl<MesXslMixerActionM
|
|||||||
|
|
||||||
@Autowired private MesXslEquipmentLedgerMapper equipmentLedgerMapper;
|
@Autowired private MesXslEquipmentLedgerMapper equipmentLedgerMapper;
|
||||||
|
|
||||||
|
//update-begin---author:GHT ---date:20260617 for:【MES上辅机】密炼动作秒级采集-唯一性改为(设备+动作代号)同设备内唯一-----------
|
||||||
@Override
|
@Override
|
||||||
public boolean isActionNameDuplicated(String actionName, String excludeId) {
|
public boolean isActionNameDuplicated(String equipmentId, String actionName, String excludeId) {
|
||||||
if (StringUtils.isBlank(actionName)) {
|
if (StringUtils.isBlank(actionName) || StringUtils.isBlank(equipmentId)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
LambdaQueryWrapper<MesXslMixerAction> wrapper =
|
LambdaQueryWrapper<MesXslMixerAction> wrapper =
|
||||||
new LambdaQueryWrapper<MesXslMixerAction>().eq(MesXslMixerAction::getActionName, actionName.trim());
|
new LambdaQueryWrapper<MesXslMixerAction>()
|
||||||
|
.eq(MesXslMixerAction::getEquipmentId, equipmentId.trim())
|
||||||
|
.eq(MesXslMixerAction::getActionName, actionName.trim());
|
||||||
if (StringUtils.isNotBlank(excludeId)) {
|
if (StringUtils.isNotBlank(excludeId)) {
|
||||||
wrapper.ne(MesXslMixerAction::getId, excludeId.trim());
|
wrapper.ne(MesXslMixerAction::getId, excludeId.trim());
|
||||||
}
|
}
|
||||||
@@ -31,17 +34,20 @@ public class MesXslMixerActionServiceImpl extends ServiceImpl<MesXslMixerActionM
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isActionCodeDuplicated(String actionCode, String excludeId) {
|
public boolean isActionCodeDuplicated(String equipmentId, String actionCode, String excludeId) {
|
||||||
if (StringUtils.isBlank(actionCode)) {
|
if (StringUtils.isBlank(actionCode) || StringUtils.isBlank(equipmentId)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
LambdaQueryWrapper<MesXslMixerAction> wrapper =
|
LambdaQueryWrapper<MesXslMixerAction> wrapper =
|
||||||
new LambdaQueryWrapper<MesXslMixerAction>().eq(MesXslMixerAction::getActionCode, actionCode.trim());
|
new LambdaQueryWrapper<MesXslMixerAction>()
|
||||||
|
.eq(MesXslMixerAction::getEquipmentId, equipmentId.trim())
|
||||||
|
.eq(MesXslMixerAction::getActionCode, actionCode.trim());
|
||||||
if (StringUtils.isNotBlank(excludeId)) {
|
if (StringUtils.isNotBlank(excludeId)) {
|
||||||
wrapper.ne(MesXslMixerAction::getId, excludeId.trim());
|
wrapper.ne(MesXslMixerAction::getId, excludeId.trim());
|
||||||
}
|
}
|
||||||
return this.count(wrapper) > 0;
|
return this.count(wrapper) > 0;
|
||||||
}
|
}
|
||||||
|
//update-end---author:GHT ---date:20260617 for:【MES上辅机】密炼动作秒级采集-唯一性改为(设备+动作代号)同设备内唯一-----------
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fillEquipmentName(MesXslMixerAction model) {
|
public void fillEquipmentName(MesXslMixerAction model) {
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
@@ -15,6 +17,8 @@ import java.util.Objects;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.jeecg.common.constant.CommonConstant;
|
import org.jeecg.common.constant.CommonConstant;
|
||||||
|
import org.jeecg.modules.mes.material.entity.MesMaterial;
|
||||||
|
import org.jeecg.modules.mes.material.mapper.MesMaterialMapper;
|
||||||
import org.jeecg.modules.xslmes.entity.MesXslEquipmentLedger;
|
import org.jeecg.modules.xslmes.entity.MesXslEquipmentLedger;
|
||||||
import org.jeecg.modules.xslmes.entity.MesXslFinalBatchPlan;
|
import org.jeecg.modules.xslmes.entity.MesXslFinalBatchPlan;
|
||||||
import org.jeecg.modules.xslmes.entity.MesXslMasterBatchPlan;
|
import org.jeecg.modules.xslmes.entity.MesXslMasterBatchPlan;
|
||||||
@@ -35,21 +39,25 @@ import org.springframework.util.CollectionUtils;
|
|||||||
public class MesXslMixingProductionPlanServiceImpl
|
public class MesXslMixingProductionPlanServiceImpl
|
||||||
extends ServiceImpl<MesXslMixingProductionPlanMapper, MesXslMixingProductionPlan>
|
extends ServiceImpl<MesXslMixingProductionPlanMapper, MesXslMixingProductionPlan>
|
||||||
implements IMesXslMixingProductionPlanService {
|
implements IMesXslMixingProductionPlanService {
|
||||||
|
private static final DateTimeFormatter PLAN_NO_DATE_FMT = DateTimeFormatter.BASIC_ISO_DATE;
|
||||||
|
|
||||||
private final MesXslEquipmentLedgerMapper equipmentLedgerMapper;
|
private final MesXslEquipmentLedgerMapper equipmentLedgerMapper;
|
||||||
private final MesXslMasterBatchPlanMapper masterBatchPlanMapper;
|
private final MesXslMasterBatchPlanMapper masterBatchPlanMapper;
|
||||||
private final MesXslFinalBatchPlanMapper finalBatchPlanMapper;
|
private final MesXslFinalBatchPlanMapper finalBatchPlanMapper;
|
||||||
private final MesXslMixingSpecMapper mixingSpecMapper;
|
private final MesXslMixingSpecMapper mixingSpecMapper;
|
||||||
|
private final MesMaterialMapper mesMaterialMapper;
|
||||||
|
|
||||||
public MesXslMixingProductionPlanServiceImpl(
|
public MesXslMixingProductionPlanServiceImpl(
|
||||||
MesXslEquipmentLedgerMapper equipmentLedgerMapper,
|
MesXslEquipmentLedgerMapper equipmentLedgerMapper,
|
||||||
MesXslMasterBatchPlanMapper masterBatchPlanMapper,
|
MesXslMasterBatchPlanMapper masterBatchPlanMapper,
|
||||||
MesXslFinalBatchPlanMapper finalBatchPlanMapper,
|
MesXslFinalBatchPlanMapper finalBatchPlanMapper,
|
||||||
MesXslMixingSpecMapper mixingSpecMapper) {
|
MesXslMixingSpecMapper mixingSpecMapper,
|
||||||
|
MesMaterialMapper mesMaterialMapper) {
|
||||||
this.equipmentLedgerMapper = equipmentLedgerMapper;
|
this.equipmentLedgerMapper = equipmentLedgerMapper;
|
||||||
this.masterBatchPlanMapper = masterBatchPlanMapper;
|
this.masterBatchPlanMapper = masterBatchPlanMapper;
|
||||||
this.finalBatchPlanMapper = finalBatchPlanMapper;
|
this.finalBatchPlanMapper = finalBatchPlanMapper;
|
||||||
this.mixingSpecMapper = mixingSpecMapper;
|
this.mixingSpecMapper = mixingSpecMapper;
|
||||||
|
this.mesMaterialMapper = mesMaterialMapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -60,13 +68,14 @@ public class MesXslMixingProductionPlanServiceImpl
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Map<String, String> machineNameCache = new HashMap<>();
|
Map<String, String> machineNameCache = new HashMap<>();
|
||||||
|
Map<String, Integer> dailyPlanNoCounter = new HashMap<>();
|
||||||
List<MesXslMixingProductionPlan> saveList = new ArrayList<>();
|
List<MesXslMixingProductionPlan> saveList = new ArrayList<>();
|
||||||
int sort = 1;
|
int sort = 1;
|
||||||
for (MesXslMixingProductionPlan row : rows) {
|
for (MesXslMixingProductionPlan row : rows) {
|
||||||
if (row == null || !hasBusinessData(row)) {
|
if (row == null || !hasBusinessData(row)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
normalizeRow(row, machineNameCache);
|
normalizeRow(row, machineNameCache, dailyPlanNoCounter);
|
||||||
row.setSortNo(sort++);
|
row.setSortNo(sort++);
|
||||||
saveList.add(row);
|
saveList.add(row);
|
||||||
}
|
}
|
||||||
@@ -77,26 +86,27 @@ public class MesXslMixingProductionPlanServiceImpl
|
|||||||
|
|
||||||
private boolean hasBusinessData(MesXslMixingProductionPlan row) {
|
private boolean hasBusinessData(MesXslMixingProductionPlan row) {
|
||||||
return StringUtils.isNotBlank(row.getMachineId())
|
return StringUtils.isNotBlank(row.getMachineId())
|
||||||
|| StringUtils.isNotBlank(row.getMorningPlanId())
|
|| StringUtils.isNotBlank(row.getPlanId())
|
||||||
|| StringUtils.isNotBlank(row.getNoonPlanId())
|
|| StringUtils.isNotBlank(row.getRemark())
|
||||||
|| StringUtils.isNotBlank(row.getNightPlanId())
|
|| row.getPlanCount() != null;
|
||||||
|| StringUtils.isNotBlank(row.getMorningRemark())
|
|
||||||
|| StringUtils.isNotBlank(row.getNoonRemark())
|
|
||||||
|| StringUtils.isNotBlank(row.getNightRemark())
|
|
||||||
|| row.getMorningPlanCount() != null
|
|
||||||
|| row.getNoonPlanCount() != null
|
|
||||||
|| row.getNightPlanCount() != null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void normalizeRow(
|
private void normalizeRow(
|
||||||
MesXslMixingProductionPlan row, Map<String, String> machineNameCache) {
|
MesXslMixingProductionPlan row,
|
||||||
|
Map<String, String> machineNameCache,
|
||||||
|
Map<String, Integer> dailyPlanNoCounter) {
|
||||||
row.setId(null);
|
row.setId(null);
|
||||||
row.setMachineId(StringUtils.trimToNull(row.getMachineId()));
|
row.setMachineId(StringUtils.trimToNull(row.getMachineId()));
|
||||||
row.setMachineName(resolveMachineName(row.getMachineId(), machineNameCache));
|
row.setMachineName(resolveMachineName(row.getMachineId(), machineNameCache));
|
||||||
|
Integer shiftFlag = row.getShiftFlag();
|
||||||
|
if (shiftFlag == null || shiftFlag < 1 || shiftFlag > 3) {
|
||||||
|
row.setShiftFlag(1);
|
||||||
|
}
|
||||||
|
row.setPlanId(StringUtils.trimToNull(row.getPlanId()));
|
||||||
|
row.setPlanType(StringUtils.upperCase(StringUtils.trimToNull(row.getPlanType())));
|
||||||
row.setPlanDate(new Date());
|
row.setPlanDate(new Date());
|
||||||
fillShiftFromPlan(row, "morning");
|
row.setPlanNo(generatePlanNo(row.getPlanDate(), dailyPlanNoCounter));
|
||||||
fillShiftFromPlan(row, "noon");
|
fillFromPlan(row);
|
||||||
fillShiftFromPlan(row, "night");
|
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
if (row.getCreateTime() == null) {
|
if (row.getCreateTime() == null) {
|
||||||
row.setCreateTime(now);
|
row.setCreateTime(now);
|
||||||
@@ -107,6 +117,14 @@ public class MesXslMixingProductionPlanServiceImpl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String generatePlanNo(Date planDate, Map<String, Integer> dailyPlanNoCounter) {
|
||||||
|
String datePart = planDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate().format(PLAN_NO_DATE_FMT);
|
||||||
|
Integer current = dailyPlanNoCounter.get(datePart);
|
||||||
|
int next = current == null ? 1 : current + 1;
|
||||||
|
dailyPlanNoCounter.put(datePart, next);
|
||||||
|
return datePart + "A" + String.format("%03d", next);
|
||||||
|
}
|
||||||
|
|
||||||
private String resolveMachineName(String machineId, Map<String, String> cache) {
|
private String resolveMachineName(String machineId, Map<String, String> cache) {
|
||||||
if (StringUtils.isBlank(machineId)) {
|
if (StringUtils.isBlank(machineId)) {
|
||||||
return null;
|
return null;
|
||||||
@@ -119,171 +137,118 @@ public class MesXslMixingProductionPlanServiceImpl
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fillShiftFromPlan(MesXslMixingProductionPlan row, String shift) {
|
private void fillFromPlan(MesXslMixingProductionPlan row) {
|
||||||
String planId = getPlanId(row, shift);
|
String planId = row.getPlanId();
|
||||||
String planType = StringUtils.upperCase(StringUtils.trimToEmpty(getPlanType(row, shift)));
|
String planType = StringUtils.upperCase(StringUtils.trimToEmpty(row.getPlanType()));
|
||||||
if (StringUtils.isBlank(planId)) {
|
if (StringUtils.isBlank(planId)) {
|
||||||
clearShiftPlanFields(row, shift);
|
clearPlanFields(row);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ("M".equals(planType)) {
|
if ("M".equals(planType)) {
|
||||||
MesXslMasterBatchPlan plan = masterBatchPlanMapper.selectById(planId);
|
MesXslMasterBatchPlan plan = masterBatchPlanMapper.selectById(planId);
|
||||||
if (plan == null) {
|
if (plan == null) {
|
||||||
clearShiftPlanFields(row, shift);
|
clearPlanFields(row);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setShiftFromMasterPlan(row, shift, plan);
|
setFromMasterPlan(row, plan);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MesXslFinalBatchPlan finalPlan = finalBatchPlanMapper.selectById(planId);
|
MesXslFinalBatchPlan finalPlan = finalBatchPlanMapper.selectById(planId);
|
||||||
if (finalPlan == null) {
|
if (finalPlan == null) {
|
||||||
clearShiftPlanFields(row, shift);
|
clearPlanFields(row);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setShiftFromFinalPlan(row, shift, finalPlan);
|
setFromFinalPlan(row, finalPlan);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getPlanId(MesXslMixingProductionPlan row, String shift) {
|
private void setFromMasterPlan(MesXslMixingProductionPlan row, MesXslMasterBatchPlan plan) {
|
||||||
return switch (shift) {
|
row.setPlanType("M");
|
||||||
case "morning" -> StringUtils.trimToNull(row.getMorningPlanId());
|
row.setSourceOrderId(plan.getSourceOrderId());
|
||||||
case "noon" -> StringUtils.trimToNull(row.getNoonPlanId());
|
row.setMaterialId(resolveMesMaterialId(plan.getMesMaterialName(), plan.getMaterialCode()));
|
||||||
default -> StringUtils.trimToNull(row.getNightPlanId());
|
row.setMaterialName(plan.getMesMaterialName());
|
||||||
};
|
row.setOrderNo(plan.getOrderNo());
|
||||||
}
|
row.setOrderDate(plan.getOrderDate());
|
||||||
|
row.setFormulaName(
|
||||||
private String getPlanType(MesXslMixingProductionPlan row, String shift) {
|
|
||||||
return switch (shift) {
|
|
||||||
case "morning" -> row.getMorningPlanType();
|
|
||||||
case "noon" -> row.getNoonPlanType();
|
|
||||||
default -> row.getNightPlanType();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setShiftFromMasterPlan(
|
|
||||||
MesXslMixingProductionPlan row, String shift, MesXslMasterBatchPlan plan) {
|
|
||||||
setShiftPlanType(row, shift, "M");
|
|
||||||
setShiftSourceOrderId(row, shift, plan.getSourceOrderId());
|
|
||||||
setShiftOrderNo(row, shift, plan.getOrderNo());
|
|
||||||
setShiftOrderDate(row, shift, plan.getOrderDate());
|
|
||||||
setShiftFormulaName(
|
|
||||||
row,
|
|
||||||
shift,
|
|
||||||
resolveFormulaNameByMachineAndMaterial(
|
resolveFormulaNameByMachineAndMaterial(
|
||||||
row.getMachineId(),
|
row.getMachineId(),
|
||||||
row.getMachineName(),
|
row.getMachineName(),
|
||||||
plan.getMaterialCode(),
|
plan.getMaterialCode(),
|
||||||
plan.getMesMaterialName(),
|
plan.getMesMaterialName(),
|
||||||
true));
|
true));
|
||||||
setShiftPlanWeight(row, shift, plan.getPlanWeight());
|
row.setPlanWeight(plan.getPlanWeight());
|
||||||
setShiftPlannedCarCount(row, shift, plan.getPlannedCarCount());
|
row.setPlannedCarCount(plan.getPlannedCarCount());
|
||||||
setShiftScheduledCarCount(row, shift, plan.getScheduledCarCount());
|
row.setScheduledCarCount(plan.getScheduledCarCount());
|
||||||
setShiftFinishedCarCount(row, shift, plan.getFinishedCarCount());
|
row.setFinishedCarCount(plan.getFinishedCarCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setShiftFromFinalPlan(
|
private void setFromFinalPlan(MesXslMixingProductionPlan row, MesXslFinalBatchPlan plan) {
|
||||||
MesXslMixingProductionPlan row, String shift, MesXslFinalBatchPlan plan) {
|
row.setPlanType("F");
|
||||||
setShiftPlanType(row, shift, "F");
|
row.setSourceOrderId(plan.getSourceOrderId());
|
||||||
setShiftSourceOrderId(row, shift, plan.getSourceOrderId());
|
row.setMaterialId(resolveMesMaterialId(plan.getMesMaterialName(), plan.getMaterialCode()));
|
||||||
setShiftOrderNo(row, shift, plan.getOrderNo());
|
row.setMaterialName(plan.getMesMaterialName());
|
||||||
setShiftOrderDate(row, shift, plan.getOrderDate());
|
row.setOrderNo(plan.getOrderNo());
|
||||||
setShiftFormulaName(
|
row.setOrderDate(plan.getOrderDate());
|
||||||
row,
|
row.setFormulaName(
|
||||||
shift,
|
|
||||||
resolveFormulaNameByMachineAndMaterial(
|
resolveFormulaNameByMachineAndMaterial(
|
||||||
row.getMachineId(),
|
row.getMachineId(),
|
||||||
row.getMachineName(),
|
row.getMachineName(),
|
||||||
plan.getMaterialCode(),
|
plan.getMaterialCode(),
|
||||||
plan.getMesMaterialName(),
|
plan.getMesMaterialName(),
|
||||||
true));
|
true));
|
||||||
setShiftPlanWeight(row, shift, plan.getPlanWeight());
|
row.setPlanWeight(plan.getPlanWeight());
|
||||||
setShiftPlannedCarCount(row, shift, plan.getPlannedCarCount());
|
row.setPlannedCarCount(plan.getPlannedCarCount());
|
||||||
setShiftScheduledCarCount(row, shift, plan.getScheduledCarCount());
|
row.setScheduledCarCount(plan.getScheduledCarCount());
|
||||||
setShiftFinishedCarCount(row, shift, plan.getFinishedCarCount());
|
row.setFinishedCarCount(plan.getFinishedCarCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clearShiftPlanFields(MesXslMixingProductionPlan row, String shift) {
|
private void clearPlanFields(MesXslMixingProductionPlan row) {
|
||||||
setShiftPlanType(row, shift, null);
|
row.setPlanType(null);
|
||||||
setShiftSourceOrderId(row, shift, null);
|
row.setSourceOrderId(null);
|
||||||
setShiftOrderNo(row, shift, null);
|
row.setMaterialId(null);
|
||||||
setShiftOrderDate(row, shift, null);
|
row.setMaterialName(null);
|
||||||
setShiftFormulaName(row, shift, null);
|
row.setOrderNo(null);
|
||||||
setShiftPlanWeight(row, shift, null);
|
row.setOrderDate(null);
|
||||||
setShiftPlannedCarCount(row, shift, null);
|
row.setFormulaName(null);
|
||||||
setShiftScheduledCarCount(row, shift, null);
|
row.setPlanWeight(null);
|
||||||
setShiftFinishedCarCount(row, shift, null);
|
row.setPlannedCarCount(null);
|
||||||
|
row.setScheduledCarCount(null);
|
||||||
|
row.setFinishedCarCount(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setShiftPlanType(MesXslMixingProductionPlan row, String shift, String value) {
|
private String resolveMesMaterialId(String mesMaterialName, String materialCode) {
|
||||||
switch (shift) {
|
String name = StringUtils.trimToNull(mesMaterialName);
|
||||||
case "morning" -> row.setMorningPlanType(value);
|
String code = StringUtils.trimToNull(materialCode);
|
||||||
case "noon" -> row.setNoonPlanType(value);
|
LambdaQueryWrapper<MesMaterial> byNameWrapper =
|
||||||
default -> row.setNightPlanType(value);
|
new LambdaQueryWrapper<MesMaterial>()
|
||||||
|
.eq(name != null, MesMaterial::getMaterialName, name)
|
||||||
|
.and(
|
||||||
|
w ->
|
||||||
|
w.eq(MesMaterial::getDelFlag, CommonConstant.DEL_FLAG_0)
|
||||||
|
.or()
|
||||||
|
.isNull(MesMaterial::getDelFlag))
|
||||||
|
.orderByDesc(MesMaterial::getUpdateTime)
|
||||||
|
.orderByDesc(MesMaterial::getCreateTime)
|
||||||
|
.last("LIMIT 1");
|
||||||
|
MesMaterial byName = mesMaterialMapper.selectOne(byNameWrapper);
|
||||||
|
if (byName != null) {
|
||||||
|
return byName.getId();
|
||||||
}
|
}
|
||||||
}
|
if (code == null) {
|
||||||
|
return null;
|
||||||
private void setShiftSourceOrderId(MesXslMixingProductionPlan row, String shift, String value) {
|
|
||||||
switch (shift) {
|
|
||||||
case "morning" -> row.setMorningSourceOrderId(value);
|
|
||||||
case "noon" -> row.setNoonSourceOrderId(value);
|
|
||||||
default -> row.setNightSourceOrderId(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setShiftOrderNo(MesXslMixingProductionPlan row, String shift, String value) {
|
|
||||||
switch (shift) {
|
|
||||||
case "morning" -> row.setMorningOrderNo(value);
|
|
||||||
case "noon" -> row.setNoonOrderNo(value);
|
|
||||||
default -> row.setNightOrderNo(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setShiftOrderDate(MesXslMixingProductionPlan row, String shift, Date value) {
|
|
||||||
switch (shift) {
|
|
||||||
case "morning" -> row.setMorningOrderDate(value);
|
|
||||||
case "noon" -> row.setNoonOrderDate(value);
|
|
||||||
default -> row.setNightOrderDate(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setShiftFormulaName(MesXslMixingProductionPlan row, String shift, String value) {
|
|
||||||
switch (shift) {
|
|
||||||
case "morning" -> row.setMorningFormulaName(value);
|
|
||||||
case "noon" -> row.setNoonFormulaName(value);
|
|
||||||
default -> row.setNightFormulaName(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setShiftPlanWeight(
|
|
||||||
MesXslMixingProductionPlan row, String shift, java.math.BigDecimal value) {
|
|
||||||
switch (shift) {
|
|
||||||
case "morning" -> row.setMorningPlanWeight(value);
|
|
||||||
case "noon" -> row.setNoonPlanWeight(value);
|
|
||||||
default -> row.setNightPlanWeight(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setShiftPlannedCarCount(MesXslMixingProductionPlan row, String shift, Integer value) {
|
|
||||||
switch (shift) {
|
|
||||||
case "morning" -> row.setMorningPlannedCarCount(value);
|
|
||||||
case "noon" -> row.setNoonPlannedCarCount(value);
|
|
||||||
default -> row.setNightPlannedCarCount(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setShiftScheduledCarCount(MesXslMixingProductionPlan row, String shift, Integer value) {
|
|
||||||
switch (shift) {
|
|
||||||
case "morning" -> row.setMorningScheduledCarCount(value);
|
|
||||||
case "noon" -> row.setNoonScheduledCarCount(value);
|
|
||||||
default -> row.setNightScheduledCarCount(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setShiftFinishedCarCount(MesXslMixingProductionPlan row, String shift, Integer value) {
|
|
||||||
switch (shift) {
|
|
||||||
case "morning" -> row.setMorningFinishedCarCount(value);
|
|
||||||
case "noon" -> row.setNoonFinishedCarCount(value);
|
|
||||||
default -> row.setNightFinishedCarCount(value);
|
|
||||||
}
|
}
|
||||||
|
LambdaQueryWrapper<MesMaterial> byCodeWrapper =
|
||||||
|
new LambdaQueryWrapper<MesMaterial>()
|
||||||
|
.eq(MesMaterial::getMaterialCode, code)
|
||||||
|
.and(
|
||||||
|
w ->
|
||||||
|
w.eq(MesMaterial::getDelFlag, CommonConstant.DEL_FLAG_0)
|
||||||
|
.or()
|
||||||
|
.isNull(MesMaterial::getDelFlag))
|
||||||
|
.orderByDesc(MesMaterial::getUpdateTime)
|
||||||
|
.orderByDesc(MesMaterial::getCreateTime)
|
||||||
|
.last("LIMIT 1");
|
||||||
|
MesMaterial byCode = mesMaterialMapper.selectOne(byCodeWrapper);
|
||||||
|
return byCode == null ? null : byCode.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -216,6 +216,66 @@ public class MesXslRubberQuickTestRecordServiceImpl
|
|||||||
}
|
}
|
||||||
//update-end---author:jiangxh ---date:20260528 for:【MES】胶料快检记录单号JL+日期+4位流水自动生成-----------
|
//update-end---author:jiangxh ---date:20260528 for:【MES】胶料快检记录单号JL+日期+4位流水自动生成-----------
|
||||||
|
|
||||||
|
//update-begin---author:jiangxh ---date:20260618 for:【快检记录】桌面端快检记录号 yyyyMMdd+流水+胶料号-----------
|
||||||
|
@Override
|
||||||
|
public String generateDesktopRecordNo(MesXslRubberQuickTestRecord context) {
|
||||||
|
String dateStr = new SimpleDateFormat("yyyyMMdd").format(new Date());
|
||||||
|
if (context == null || oConvertUtils.isEmpty(context.getRubberMaterialName())) {
|
||||||
|
throw new JeecgBootException("胶料名称不能为空,无法生成快检记录号");
|
||||||
|
}
|
||||||
|
String material = context.getRubberMaterialName().trim();
|
||||||
|
int expectedLen = dateStr.length() + 4 + material.length();
|
||||||
|
Integer tenantId = resolveTenantId(context);
|
||||||
|
|
||||||
|
LambdaQueryWrapper<MesXslRubberQuickTestRecord> qw = new LambdaQueryWrapper<>();
|
||||||
|
qw.likeRight(MesXslRubberQuickTestRecord::getRecordNo, dateStr);
|
||||||
|
qw.and(q -> q.eq(MesXslRubberQuickTestRecord::getDelFlag, CommonConstant.DEL_FLAG_0).or().isNull(MesXslRubberQuickTestRecord::getDelFlag));
|
||||||
|
if (tenantId != null) {
|
||||||
|
qw.eq(MesXslRubberQuickTestRecord::getTenantId, tenantId);
|
||||||
|
}
|
||||||
|
qw.select(MesXslRubberQuickTestRecord::getRecordNo);
|
||||||
|
|
||||||
|
int maxSeq = 0;
|
||||||
|
for (MesXslRubberQuickTestRecord row : this.list(qw)) {
|
||||||
|
String no = row.getRecordNo();
|
||||||
|
if (oConvertUtils.isEmpty(no) || no.length() != expectedLen) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!no.startsWith(dateStr) || !no.endsWith(material)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String seqPart = no.substring(dateStr.length(), dateStr.length() + 4);
|
||||||
|
try {
|
||||||
|
maxSeq = Math.max(maxSeq, Integer.parseInt(seqPart));
|
||||||
|
} catch (NumberFormatException ignored) {
|
||||||
|
// ignore malformed historical numbers
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dateStr + String.format("%04d", maxSeq + 1) + material;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fillQuickTestTypeForRecord(MesXslRubberQuickTestRecord record) {
|
||||||
|
if (record == null || oConvertUtils.isNotEmpty(record.getQuickTestTypeId())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String testMethodId = null;
|
||||||
|
if (oConvertUtils.isNotEmpty(record.getStdId())) {
|
||||||
|
MesXslRubberQuickTestStd std = mesXslRubberQuickTestStdService.getById(record.getStdId());
|
||||||
|
if (std != null) {
|
||||||
|
testMethodId = std.getTestMethodId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (oConvertUtils.isEmpty(testMethodId)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MesXslRubberQuickTestMethod method = mesXslRubberQuickTestMethodService.getById(testMethodId);
|
||||||
|
if (method != null && oConvertUtils.isNotEmpty(method.getQuickTestTypeId())) {
|
||||||
|
fillQuickTestType(record, method.getQuickTestTypeId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//update-end---author:jiangxh ---date:20260618 for:【快检记录】桌面端快检记录号 yyyyMMdd+流水+胶料号-----------
|
||||||
|
|
||||||
//update-begin---author:jiangxh ---date:20260525 for:【MES】胶料信息多选按实验标准批量生成快检记录-----------
|
//update-begin---author:jiangxh ---date:20260525 for:【MES】胶料信息多选按实验标准批量生成快检记录-----------
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
-- 密炼生产计划维护:早中晚共用字段 + 班次标识
|
||||||
|
SET NAMES utf8mb4;
|
||||||
|
|
||||||
|
ALTER TABLE `mes_xsl_mixing_production_plan`
|
||||||
|
ADD COLUMN IF NOT EXISTS `shift_flag` int DEFAULT NULL COMMENT '班次标识:1早班 2中班 3晚班' AFTER `machine_name`,
|
||||||
|
ADD COLUMN IF NOT EXISTS `plan_id` varchar(32) DEFAULT NULL COMMENT '计划ID(母胶/终胶计划)' AFTER `plan_date`,
|
||||||
|
ADD COLUMN IF NOT EXISTS `plan_type` varchar(2) DEFAULT NULL COMMENT '计划类型:M母胶/F终胶' AFTER `plan_id`,
|
||||||
|
ADD COLUMN IF NOT EXISTS `source_order_id` varchar(32) DEFAULT NULL COMMENT '生产订单ID' AFTER `plan_type`,
|
||||||
|
ADD COLUMN IF NOT EXISTS `order_no` varchar(64) DEFAULT NULL COMMENT '生产订单号' AFTER `source_order_id`,
|
||||||
|
ADD COLUMN IF NOT EXISTS `order_date` date DEFAULT NULL COMMENT '订单日期' AFTER `order_no`,
|
||||||
|
ADD COLUMN IF NOT EXISTS `formula_name` varchar(128) DEFAULT NULL COMMENT '配方名称' AFTER `order_date`,
|
||||||
|
ADD COLUMN IF NOT EXISTS `plan_weight` decimal(18,6) DEFAULT NULL COMMENT '计划重量' AFTER `formula_name`,
|
||||||
|
ADD COLUMN IF NOT EXISTS `planned_car_count` int DEFAULT NULL COMMENT '计划车数' AFTER `plan_weight`,
|
||||||
|
ADD COLUMN IF NOT EXISTS `scheduled_car_count` int DEFAULT NULL COMMENT '已排产车数' AFTER `planned_car_count`,
|
||||||
|
ADD COLUMN IF NOT EXISTS `finished_car_count` int DEFAULT NULL COMMENT '完成车数' AFTER `scheduled_car_count`,
|
||||||
|
ADD COLUMN IF NOT EXISTS `plan_count` int DEFAULT NULL COMMENT '计划' AFTER `finished_car_count`,
|
||||||
|
ADD COLUMN IF NOT EXISTS `remark` varchar(500) DEFAULT NULL COMMENT '备注' AFTER `plan_count`;
|
||||||
|
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
-- 密炼生产计划维护:删除早/中/晚冗余字段,保留共用字段 + 班次标识
|
||||||
|
SET NAMES utf8mb4;
|
||||||
|
|
||||||
|
SET @drop_sql = (
|
||||||
|
SELECT IFNULL(
|
||||||
|
CONCAT(
|
||||||
|
'ALTER TABLE `mes_xsl_mixing_production_plan` ',
|
||||||
|
GROUP_CONCAT(CONCAT('DROP COLUMN `', column_name, '`') ORDER BY ordinal_position SEPARATOR ', ')
|
||||||
|
),
|
||||||
|
'SELECT 1'
|
||||||
|
)
|
||||||
|
FROM information_schema.COLUMNS
|
||||||
|
WHERE TABLE_SCHEMA = DATABASE()
|
||||||
|
AND TABLE_NAME = 'mes_xsl_mixing_production_plan'
|
||||||
|
AND COLUMN_NAME IN (
|
||||||
|
'morning_plan_id', 'morning_plan_type', 'morning_source_order_id', 'morning_order_no', 'morning_order_date',
|
||||||
|
'morning_formula_name', 'morning_plan_weight', 'morning_planned_car_count', 'morning_scheduled_car_count',
|
||||||
|
'morning_finished_car_count', 'morning_plan_count', 'morning_remark',
|
||||||
|
'noon_plan_id', 'noon_plan_type', 'noon_source_order_id', 'noon_order_no', 'noon_order_date',
|
||||||
|
'noon_formula_name', 'noon_plan_weight', 'noon_planned_car_count', 'noon_scheduled_car_count',
|
||||||
|
'noon_finished_car_count', 'noon_plan_count', 'noon_remark',
|
||||||
|
'night_plan_id', 'night_plan_type', 'night_source_order_id', 'night_order_no', 'night_order_date',
|
||||||
|
'night_formula_name', 'night_plan_weight', 'night_planned_car_count', 'night_scheduled_car_count',
|
||||||
|
'night_finished_car_count', 'night_plan_count', 'night_remark'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
PREPARE stmt FROM @drop_sql;
|
||||||
|
EXECUTE stmt;
|
||||||
|
DEALLOCATE PREPARE stmt;
|
||||||
|
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
-- 密炼生产计划维护:删表重建(注意:会清空原表数据)
|
||||||
|
SET NAMES utf8mb4;
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `mes_xsl_mixing_production_plan`;
|
||||||
|
|
||||||
|
CREATE TABLE `mes_xsl_mixing_production_plan` (
|
||||||
|
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||||
|
`sort_no` int DEFAULT NULL COMMENT '排序号',
|
||||||
|
`machine_id` varchar(32) DEFAULT NULL COMMENT '机台ID(mes_xsl_equipment_ledger.id)',
|
||||||
|
`machine_name` varchar(128) DEFAULT NULL COMMENT '机台名称冗余',
|
||||||
|
`shift_flag` int DEFAULT NULL COMMENT '班次标识:1早班 2中班 3晚班',
|
||||||
|
`plan_date` date DEFAULT NULL COMMENT '计划日期(保存时写入当前日期)',
|
||||||
|
`plan_no` varchar(32) DEFAULT NULL COMMENT '计划号(yyyyMMddA三位流水)',
|
||||||
|
`plan_id` varchar(32) DEFAULT NULL COMMENT '计划ID(母胶/终胶计划)',
|
||||||
|
`plan_type` varchar(2) DEFAULT NULL COMMENT '计划类型:M母胶/F终胶',
|
||||||
|
`source_order_id` varchar(32) DEFAULT NULL COMMENT '生产订单ID',
|
||||||
|
`material_id` varchar(32) DEFAULT NULL COMMENT '胶料ID(mes_material.id)',
|
||||||
|
`material_name` varchar(128) DEFAULT NULL COMMENT '胶料名称(取母胶/终胶计划mesMaterialName)',
|
||||||
|
`order_no` varchar(64) DEFAULT NULL COMMENT '生产订单号',
|
||||||
|
`order_date` date DEFAULT NULL COMMENT '订单日期',
|
||||||
|
`formula_name` varchar(128) DEFAULT NULL COMMENT '配方名称',
|
||||||
|
`plan_weight` decimal(18,6) DEFAULT NULL COMMENT '计划重量',
|
||||||
|
`planned_car_count` int DEFAULT NULL COMMENT '计划车数',
|
||||||
|
`scheduled_car_count` int DEFAULT NULL COMMENT '已排产车数',
|
||||||
|
`finished_car_count` int DEFAULT NULL COMMENT '完成车数',
|
||||||
|
`plan_count` int DEFAULT NULL COMMENT '计划',
|
||||||
|
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
|
||||||
|
`tenant_id` int DEFAULT NULL COMMENT '租户',
|
||||||
|
`sys_org_code` varchar(64) DEFAULT NULL COMMENT '部门编码',
|
||||||
|
`create_by` varchar(32) DEFAULT NULL COMMENT '创建人',
|
||||||
|
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||||
|
`update_by` varchar(32) DEFAULT NULL COMMENT '更新人',
|
||||||
|
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||||
|
`del_flag` int DEFAULT '0' COMMENT '删除标记(0正常1删除)',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `idx_mxmp_machine` (`machine_id`),
|
||||||
|
KEY `idx_mxmp_plan_date` (`plan_date`),
|
||||||
|
KEY `idx_mxmp_plan_no` (`plan_no`),
|
||||||
|
KEY `idx_mxmp_shift_flag` (`shift_flag`),
|
||||||
|
KEY `idx_mxmp_plan_id` (`plan_id`),
|
||||||
|
KEY `idx_mxmp_sort` (`sort_no`),
|
||||||
|
KEY `idx_mxmp_tenant` (`tenant_id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES密炼生产计划维护';
|
||||||
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
-- 密炼生产计划维护:新增胶料ID和胶料名称字段
|
||||||
|
SET NAMES utf8mb4;
|
||||||
|
|
||||||
|
ALTER TABLE `mes_xsl_mixing_production_plan`
|
||||||
|
ADD COLUMN IF NOT EXISTS `material_id` varchar(32) DEFAULT NULL COMMENT '胶料ID(mes_material.id)' AFTER `source_order_id`,
|
||||||
|
ADD COLUMN IF NOT EXISTS `material_name` varchar(128) DEFAULT NULL COMMENT '胶料名称(取母胶/终胶计划mesMaterialName)' AFTER `material_id`;
|
||||||
|
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
-- 密炼生产计划维护:修正胶料ID字段定义为mes_material主键ID
|
||||||
|
SET NAMES utf8mb4;
|
||||||
|
|
||||||
|
ALTER TABLE `mes_xsl_mixing_production_plan`
|
||||||
|
MODIFY COLUMN `material_id` varchar(32) DEFAULT NULL COMMENT '胶料ID(mes_material.id)';
|
||||||
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
-- 密炼生产计划维护:新增计划号字段
|
||||||
|
SET NAMES utf8mb4;
|
||||||
|
|
||||||
|
ALTER TABLE `mes_xsl_mixing_production_plan`
|
||||||
|
ADD COLUMN IF NOT EXISTS `plan_no` varchar(32) DEFAULT NULL COMMENT '计划号(yyyyMMddA三位流水)' AFTER `plan_date`,
|
||||||
|
ADD INDEX `idx_mxmp_plan_no` (`plan_no`);
|
||||||
|
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
-- 【MES上辅机】密炼动作秒级采集
|
||||||
|
-- 1. 通用中间表采集配置表(可被密炼动作/报警/配方等多功能复用,按 biz_type 区分)
|
||||||
|
-- 2. 密炼机动作维护表补全机台字段、放开台账关联、调整唯一键为(设备+动作代号)
|
||||||
|
-- 3. 密炼动作菜单下新增 启动采集/停止采集/采集设置 按钮权限
|
||||||
|
|
||||||
|
-- ===================== 1. 通用采集配置表 =====================
|
||||||
|
CREATE TABLE IF NOT EXISTS `mes_xsl_mcs_sync_config` (
|
||||||
|
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||||
|
`biz_type` varchar(50) NOT NULL COMMENT '业务类型(采集任务唯一标识,如 MIX_ACT 密炼动作)',
|
||||||
|
`biz_name` varchar(100) DEFAULT NULL COMMENT '业务名称',
|
||||||
|
`source_table` varchar(100) DEFAULT NULL COMMENT '源中间表名',
|
||||||
|
`interval_seconds` int NOT NULL DEFAULT '1' COMMENT '采集时间间隔(秒),默认1秒',
|
||||||
|
`status` varchar(1) NOT NULL DEFAULT '0' COMMENT '采集状态(0停止,1运行)',
|
||||||
|
`last_sync_time` datetime DEFAULT NULL COMMENT '最近一次采集时间',
|
||||||
|
`last_sync_result` varchar(500) DEFAULT NULL COMMENT '最近一次采集结果',
|
||||||
|
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
|
||||||
|
`tenant_id` int DEFAULT '0' COMMENT '租户',
|
||||||
|
`create_by` varchar(100) DEFAULT NULL COMMENT '创建人',
|
||||||
|
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||||
|
`update_by` varchar(100) DEFAULT NULL COMMENT '更新人',
|
||||||
|
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||||
|
`del_flag` int DEFAULT '0' COMMENT '删除标记(0正常,1删除)',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `idx_mscfg_biz` (`biz_type`, `tenant_id`, `del_flag`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES上辅机中间表采集配置(通用)';
|
||||||
|
|
||||||
|
-- 初始化密炼动作采集配置(默认间隔1秒、默认停止)
|
||||||
|
INSERT INTO `mes_xsl_mcs_sync_config`
|
||||||
|
(`id`, `biz_type`, `biz_name`, `source_table`, `interval_seconds`, `status`, `remark`, `tenant_id`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`)
|
||||||
|
SELECT '1900000000000000860', 'MIX_ACT', '密炼机动作', 'MCSToMES_MixAct', 1, '0', '密炼机动作维护数据采集', 0, 'admin', NOW(), 'admin', NOW(), 0
|
||||||
|
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `mes_xsl_mcs_sync_config` WHERE `biz_type` = 'MIX_ACT' AND `tenant_id` = 0);
|
||||||
|
|
||||||
|
-- ===================== 2. 密炼机动作维护表补全字段 =====================
|
||||||
|
-- 机台编号、机台类型(采集自中间表 EquipID/EquipType)
|
||||||
|
ALTER TABLE `mes_xsl_mixer_action`
|
||||||
|
ADD COLUMN `equip_id` varchar(50) DEFAULT NULL COMMENT '机台编号(采集自中间表 EquipID)' AFTER `equipment_name`,
|
||||||
|
ADD COLUMN `equip_type` varchar(50) DEFAULT NULL COMMENT '机台类型(采集自中间表 EquipType)' AFTER `equip_id`;
|
||||||
|
|
||||||
|
-- 采集未匹配到台账时 equipment_id 允许为空
|
||||||
|
ALTER TABLE `mes_xsl_mixer_action`
|
||||||
|
MODIFY COLUMN `equipment_id` varchar(32) DEFAULT NULL COMMENT '设备台账ID(mes_xsl_equipment_ledger.id),采集未匹配时为空';
|
||||||
|
|
||||||
|
-- 唯一性改为(设备+动作代号):按机台编号+动作代号建索引,便于采集 upsert
|
||||||
|
ALTER TABLE `mes_xsl_mixer_action`
|
||||||
|
ADD KEY `idx_mxma_equip_code` (`tenant_id`, `equip_id`, `action_code`, `del_flag`);
|
||||||
|
|
||||||
|
-- ===================== 3. 密炼动作菜单按钮权限 =====================
|
||||||
|
-- 父菜单:密炼动作 1900000000000000835
|
||||||
|
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`)
|
||||||
|
SELECT '1900000000000000861', '1900000000000000835', '启动采集', NULL, NULL, 0, NULL, NULL, 2, 'xslmes:mcsSyncConfig:start', '1', 1.00, 0, NULL, 1, 0, 0, 0, NULL, 'admin', NOW(), 'admin', NOW(), 0, 0, '1', 0
|
||||||
|
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = '1900000000000000861');
|
||||||
|
|
||||||
|
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`)
|
||||||
|
SELECT '1900000000000000862', '1900000000000000835', '停止采集', NULL, NULL, 0, NULL, NULL, 2, 'xslmes:mcsSyncConfig:stop', '1', 2.00, 0, NULL, 1, 0, 0, 0, NULL, 'admin', NOW(), 'admin', NOW(), 0, 0, '1', 0
|
||||||
|
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = '1900000000000000862');
|
||||||
|
|
||||||
|
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`)
|
||||||
|
SELECT '1900000000000000863', '1900000000000000835', '采集设置', NULL, NULL, 0, NULL, NULL, 2, 'xslmes:mcsSyncConfig:setting', '1', 3.00, 0, NULL, 1, 0, 0, 0, NULL, 'admin', NOW(), 'admin', NOW(), 0, 0, '1', 0
|
||||||
|
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = '1900000000000000863');
|
||||||
|
|
||||||
|
-- admin 角色授权
|
||||||
|
INSERT INTO `sys_role_permission` (`id`, `role_id`, `permission_id`, `data_rule_ids`, `operate_date`, `operate_ip`)
|
||||||
|
SELECT REPLACE(UUID(), '-', ''), r.id, p.id, NULL, NOW(), '127.0.0.1'
|
||||||
|
FROM `sys_role` r
|
||||||
|
JOIN (
|
||||||
|
SELECT id FROM `sys_permission`
|
||||||
|
WHERE id IN ('1900000000000000861','1900000000000000862','1900000000000000863')
|
||||||
|
) p ON 1 = 1
|
||||||
|
WHERE r.`role_code` = 'admin'
|
||||||
|
AND NOT EXISTS (
|
||||||
|
SELECT 1 FROM `sys_role_permission` rp
|
||||||
|
WHERE rp.`role_id` = r.id AND rp.`permission_id` = p.id
|
||||||
|
);
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
-- 【MES上辅机】采集配置:通用表+字段映射(中间库表 ↔ MES表,配置驱动)
|
||||||
|
-- 1. 扩展采集配置头:目标表、配置名称、表注释
|
||||||
|
-- 2. 新建字段映射表 mes_xsl_mcs_sync_field
|
||||||
|
-- 3. 将密炼动作(MIX_ACT)改造为配置驱动:补目标表+预置字段映射
|
||||||
|
-- 4. 新增"采集配置"菜单及按钮权限
|
||||||
|
|
||||||
|
-- ===================== 1. 采集配置头扩展 =====================
|
||||||
|
ALTER TABLE `mes_xsl_mcs_sync_config`
|
||||||
|
ADD COLUMN `config_name` varchar(100) DEFAULT NULL COMMENT '配置名称' AFTER `biz_type`,
|
||||||
|
ADD COLUMN `source_table_comment` varchar(200) DEFAULT NULL COMMENT '源中间表注释' AFTER `source_table`,
|
||||||
|
ADD COLUMN `target_table` varchar(100) DEFAULT NULL COMMENT 'MES目标表名' AFTER `source_table_comment`,
|
||||||
|
ADD COLUMN `target_table_comment` varchar(200) DEFAULT NULL COMMENT 'MES目标表注释' AFTER `target_table`;
|
||||||
|
|
||||||
|
-- 密炼动作改造为配置驱动
|
||||||
|
UPDATE `mes_xsl_mcs_sync_config`
|
||||||
|
SET `config_name` = '密炼机动作采集',
|
||||||
|
`source_table_comment` = '密炼机实时动作',
|
||||||
|
`target_table` = 'mes_xsl_mixer_action',
|
||||||
|
`target_table_comment` = 'MES密炼机动作维护'
|
||||||
|
WHERE `biz_type` = 'MIX_ACT';
|
||||||
|
|
||||||
|
-- ===================== 2. 字段映射表 =====================
|
||||||
|
CREATE TABLE IF NOT EXISTS `mes_xsl_mcs_sync_field` (
|
||||||
|
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||||
|
`config_id` varchar(32) NOT NULL COMMENT '采集配置ID(mes_xsl_mcs_sync_config.id)',
|
||||||
|
`source_field` varchar(100) NOT NULL COMMENT '中间库源字段名',
|
||||||
|
`source_field_comment` varchar(200) DEFAULT NULL COMMENT '源字段注释',
|
||||||
|
`source_field_type` varchar(50) DEFAULT NULL COMMENT '源字段类型',
|
||||||
|
`target_field` varchar(100) DEFAULT NULL COMMENT 'MES目标字段名(接收字段)',
|
||||||
|
`target_field_comment` varchar(200) DEFAULT NULL COMMENT 'MES目标字段注释',
|
||||||
|
`match_key` varchar(1) DEFAULT '0' COMMENT '是否匹配键(0否,1是),作为Upsert唯一键',
|
||||||
|
`sort_no` int DEFAULT '0' COMMENT '排序',
|
||||||
|
`tenant_id` int DEFAULT '0' COMMENT '租户',
|
||||||
|
`create_by` varchar(100) DEFAULT NULL COMMENT '创建人',
|
||||||
|
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||||
|
`update_by` varchar(100) DEFAULT NULL COMMENT '更新人',
|
||||||
|
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||||
|
`del_flag` int DEFAULT '0' COMMENT '删除标记(0正常,1删除)',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `idx_msf_config` (`config_id`, `del_flag`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES上辅机采集字段映射';
|
||||||
|
|
||||||
|
-- 预置密炼动作字段映射(EquipName→equipment_name 等;匹配键=机台编号+动作代号)
|
||||||
|
INSERT INTO `mes_xsl_mcs_sync_field`
|
||||||
|
(`id`, `config_id`, `source_field`, `source_field_comment`, `source_field_type`, `target_field`, `target_field_comment`, `match_key`, `sort_no`, `tenant_id`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`)
|
||||||
|
SELECT * FROM (
|
||||||
|
SELECT '1900000000000000870' id, '1900000000000000860' config_id, 'EquipName' sf, '机台名称' sfc, 'nvarchar' sft, 'equipment_name' tf, '设备名称' tfc, '0' mk, 1 sn, 0 tid, 'admin' cb, NOW() ct, 'admin' ub, NOW() ut, 0 df
|
||||||
|
UNION ALL SELECT '1900000000000000871', '1900000000000000860', 'EquipID', '机台编号', 'varchar', 'equip_id', '机台编号', '1', 2, 0, 'admin', NOW(), 'admin', NOW(), 0
|
||||||
|
UNION ALL SELECT '1900000000000000872', '1900000000000000860', 'EquipType', '机台类型', 'nvarchar', 'equip_type', '机台类型', '0', 3, 0, 'admin', NOW(), 'admin', NOW(), 0
|
||||||
|
UNION ALL SELECT '1900000000000000873', '1900000000000000860', 'MixActName', '动作名称', 'nvarchar', 'action_name', '动作名称', '0', 4, 0, 'admin', NOW(), 'admin', NOW(), 0
|
||||||
|
UNION ALL SELECT '1900000000000000874', '1900000000000000860', 'MixActAddress', '动作地址', 'int', 'action_code', '动作代号', '1', 5, 0, 'admin', NOW(), 'admin', NOW(), 0
|
||||||
|
) t
|
||||||
|
WHERE NOT EXISTS (SELECT 1 FROM `mes_xsl_mcs_sync_field` WHERE `config_id` = '1900000000000000860');
|
||||||
|
|
||||||
|
-- ===================== 3. 采集配置菜单 + 按钮权限 =====================
|
||||||
|
-- 父菜单:MES上辅机数据 1900000000000000830
|
||||||
|
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`)
|
||||||
|
SELECT '1900000000000000865', '1900000000000000830', '采集配置', '/xslmesMcs/mcsSyncConfig', 'xslmesMcs/mcsSyncConfig/index', 1, NULL, NULL, 0, NULL, '0', 0.50, 0, 'ant-design:sync-outlined', 1, 1, 0, 0, '中间表→MES表 采集配置与字段映射', 'admin', NOW(), 'admin', NOW(), 0, 0, '1', 0
|
||||||
|
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = '1900000000000000865');
|
||||||
|
|
||||||
|
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`)
|
||||||
|
SELECT '1900000000000000866', '1900000000000000865', '新增', NULL, NULL, 0, NULL, NULL, 2, 'xslmes:mcsSyncConfig:add', '1', 1.00, 0, NULL, 1, 0, 0, 0, NULL, 'admin', NOW(), 'admin', NOW(), 0, 0, '1', 0
|
||||||
|
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = '1900000000000000866');
|
||||||
|
|
||||||
|
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`)
|
||||||
|
SELECT '1900000000000000867', '1900000000000000865', '编辑', NULL, NULL, 0, NULL, NULL, 2, 'xslmes:mcsSyncConfig:edit', '1', 2.00, 0, NULL, 1, 0, 0, 0, NULL, 'admin', NOW(), 'admin', NOW(), 0, 0, '1', 0
|
||||||
|
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = '1900000000000000867');
|
||||||
|
|
||||||
|
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`)
|
||||||
|
SELECT '1900000000000000868', '1900000000000000865', '删除', NULL, NULL, 0, NULL, NULL, 2, 'xslmes:mcsSyncConfig:delete', '1', 3.00, 0, NULL, 1, 0, 0, 0, NULL, 'admin', NOW(), 'admin', NOW(), 0, 0, '1', 0
|
||||||
|
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = '1900000000000000868');
|
||||||
|
|
||||||
|
-- admin 授权
|
||||||
|
INSERT INTO `sys_role_permission` (`id`, `role_id`, `permission_id`, `data_rule_ids`, `operate_date`, `operate_ip`)
|
||||||
|
SELECT REPLACE(UUID(), '-', ''), r.id, p.id, NULL, NOW(), '127.0.0.1'
|
||||||
|
FROM `sys_role` r
|
||||||
|
JOIN (
|
||||||
|
SELECT id FROM `sys_permission`
|
||||||
|
WHERE id IN ('1900000000000000865','1900000000000000866','1900000000000000867','1900000000000000868')
|
||||||
|
) p ON 1 = 1
|
||||||
|
WHERE r.`role_code` = 'admin'
|
||||||
|
AND NOT EXISTS (
|
||||||
|
SELECT 1 FROM `sys_role_permission` rp
|
||||||
|
WHERE rp.`role_id` = r.id AND rp.`permission_id` = p.id
|
||||||
|
);
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
-- 【MES上辅机】采集模式:全量匹配/时间匹配/增量匹配(应对中间库大表)
|
||||||
|
ALTER TABLE `mes_xsl_mcs_sync_config`
|
||||||
|
ADD COLUMN `sync_mode` varchar(20) NOT NULL DEFAULT 'FULL' COMMENT '采集模式(FULL全量匹配,TIME时间匹配,INCR增量匹配)' AFTER `status`,
|
||||||
|
ADD COLUMN `incr_column` varchar(100) DEFAULT NULL COMMENT '增量/时间列(源表列名,TIME/INCR模式用)' AFTER `sync_mode`,
|
||||||
|
ADD COLUMN `time_window` varchar(20) DEFAULT 'TODAY' COMMENT '时间范围(TODAY当天,LAST7最近七天),TIME模式用' AFTER `incr_column`,
|
||||||
|
ADD COLUMN `batch_limit` int DEFAULT '2000' COMMENT '每轮最大采集行数(INCR模式TOP N限流)' AFTER `time_window`,
|
||||||
|
ADD COLUMN `last_watermark` varchar(64) DEFAULT NULL COMMENT '增量采集已处理到的高水位(INCR模式自动维护)' AFTER `batch_limit`;
|
||||||
|
|
||||||
|
-- 密炼动作为小状态表,保持全量匹配
|
||||||
|
UPDATE `mes_xsl_mcs_sync_config` SET `sync_mode` = 'FULL' WHERE `biz_type` = 'MIX_ACT';
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
-- 【MES上辅机】增量匹配改为标记位回写:可视化采集条件 + 可配置回写值
|
||||||
|
ALTER TABLE `mes_xsl_mcs_sync_config`
|
||||||
|
ADD COLUMN `flag_condition` varchar(20) DEFAULT 'IS_NULL' COMMENT '增量标记采集条件(IS_NULL为空,EQ_EMPTY等于空串,NE_EMPTY不等于空串)' AFTER `last_watermark`,
|
||||||
|
ADD COLUMN `flag_write_value` varchar(64) DEFAULT '1' COMMENT '增量标记采集完成后回写值(默认1)' AFTER `flag_condition`;
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
-- 【MES上辅机】增量采集条件「等于/不等于」支持自定义匹配值(留空时退化为空字符串)
|
||||||
|
ALTER TABLE `mes_xsl_mcs_sync_config`
|
||||||
|
ADD COLUMN `flag_match_value` varchar(255) DEFAULT NULL COMMENT '增量标记采集条件比较值(EQ_EMPTY/NE_EMPTY用,留空表示空字符串)' AFTER `flag_condition`;
|
||||||
374
jeecg-boot/scan_mixing_plan.json
Normal file
374
jeecg-boot/scan_mixing_plan.json
Normal file
@@ -0,0 +1,374 @@
|
|||||||
|
{
|
||||||
|
"scanKeyword": "MesXslMixingProductionPlan",
|
||||||
|
"entityClass": "MesXslMixingProductionPlan",
|
||||||
|
"tableName": "mes_xsl_mixing_production_plan",
|
||||||
|
"javaEntityFile": "jeecg-boot\\jeecg-boot-module\\jeecg-module-xslmes\\src\\main\\java\\org\\jeecg\\modules\\xslmes\\entity\\MesXslMixingProductionPlan.java",
|
||||||
|
"hasIzEnable": false,
|
||||||
|
"hasCodeUniqueness": false,
|
||||||
|
"uniquenessFields": [],
|
||||||
|
"backendArch": {
|
||||||
|
"unifiedAnonCtrl": "jeecg-boot\\jeecg-boot-module\\jeecg-module-xslmes\\src\\main\\java\\org\\jeecg\\modules\\xslmes\\controller\\MesXslDesktopAnonController.java",
|
||||||
|
"registeredInAnonCtrl": true,
|
||||||
|
"anonEndpoints": [
|
||||||
|
"list"
|
||||||
|
],
|
||||||
|
"stompNotifySvc": "jeecg-boot\\jeecg-boot-module\\jeecg-module-xslmes\\src\\main\\java\\org\\jeecg\\modules\\xslmes\\service\\MesXslStompNotifyService.java",
|
||||||
|
"registeredInStompSvc": false,
|
||||||
|
"bizCtrlFile": "jeecg-boot\\jeecg-boot-module\\jeecg-module-xslmes\\src\\main\\java\\org\\jeecg\\modules\\xslmes\\controller\\MesXslMixingProductionPlanController.java",
|
||||||
|
"bizCtrlUsesSharedNotify": false,
|
||||||
|
"bizCtrlHasPrivatePublish": false
|
||||||
|
},
|
||||||
|
"wpfRegistrationStatus": {
|
||||||
|
"syncModuleService": false,
|
||||||
|
"syncModuleCoordinator": false,
|
||||||
|
"navigationView": false,
|
||||||
|
"stompSubscribe": false,
|
||||||
|
"menuRegistered": false,
|
||||||
|
"tenantMenuRegistered": false,
|
||||||
|
"syncModuleFilePath": "yy-admin-master\\YY.Admin\\Module\\SyncModule.cs",
|
||||||
|
"navExtFilePath": "yy-admin-master\\YY.Admin\\Module\\NavigationExtensions.cs",
|
||||||
|
"stompWsFilePath": "yy-admin-master\\YY.Admin\\Infrastructure\\Hubs\\StompWebSocketService.cs",
|
||||||
|
"menuSeedFilePath": "yy-admin-master\\YY.Admin.Core\\SeedData\\SysMenuSeedData.cs",
|
||||||
|
"summary": "✗ 待完成: SyncModule服务注册, SyncModule协调器注册, NavigationExtensions视图注册, STOMP订阅, 菜单注册"
|
||||||
|
},
|
||||||
|
"menuSuggestion": {
|
||||||
|
"parentMenuId": 1300150000101,
|
||||||
|
"parentMenuTitle": "基础资料",
|
||||||
|
"nextMenuId": 1300150011401,
|
||||||
|
"nextOrderNo": 113,
|
||||||
|
"menuIdPattern": "130015001{N}01,N 每次 +1(1→101,2→201...)",
|
||||||
|
"alreadyExists": false,
|
||||||
|
"existingMenuId": null
|
||||||
|
},
|
||||||
|
"apiPrefix": "/xslmes/mesXslMixingProductionPlan",
|
||||||
|
"stompCmd": "MIXING_PRODUCTION_PLAN_CHANGED",
|
||||||
|
"stompTopic": "/topic/sync/mes-mixing-production-plans",
|
||||||
|
"stompSubscriptionId": "sub-mes-xsl-mixing-production-plan",
|
||||||
|
"syncMode": "B",
|
||||||
|
"syncModeReason": "有/anon/免密端点,适合模式B",
|
||||||
|
"filterFields": [
|
||||||
|
"machineId",
|
||||||
|
"machineName",
|
||||||
|
"planNo",
|
||||||
|
"planType",
|
||||||
|
"materialName"
|
||||||
|
],
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"javaName": "sortNo",
|
||||||
|
"csName": "SortNo",
|
||||||
|
"sqlName": "sort_no",
|
||||||
|
"javaType": "Integer",
|
||||||
|
"csType": "int?",
|
||||||
|
"comment": "",
|
||||||
|
"isPk": false,
|
||||||
|
"isAudit": false,
|
||||||
|
"isIzEnable": false,
|
||||||
|
"required": false,
|
||||||
|
"dictCode": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"javaName": "machineId",
|
||||||
|
"csName": "MachineId",
|
||||||
|
"sqlName": "machine_id",
|
||||||
|
"javaType": "String",
|
||||||
|
"csType": "string?",
|
||||||
|
"comment": "",
|
||||||
|
"isPk": false,
|
||||||
|
"isAudit": false,
|
||||||
|
"isIzEnable": false,
|
||||||
|
"required": false,
|
||||||
|
"dictCode": "id"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"javaName": "machineName",
|
||||||
|
"csName": "MachineName",
|
||||||
|
"sqlName": "machine_name",
|
||||||
|
"javaType": "String",
|
||||||
|
"csType": "string?",
|
||||||
|
"comment": "",
|
||||||
|
"isPk": false,
|
||||||
|
"isAudit": false,
|
||||||
|
"isIzEnable": false,
|
||||||
|
"required": false,
|
||||||
|
"dictCode": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"javaName": "shiftFlag",
|
||||||
|
"csName": "ShiftFlag",
|
||||||
|
"sqlName": "shift_flag",
|
||||||
|
"javaType": "Integer",
|
||||||
|
"csType": "int?",
|
||||||
|
"comment": "",
|
||||||
|
"isPk": false,
|
||||||
|
"isAudit": false,
|
||||||
|
"isIzEnable": false,
|
||||||
|
"required": false,
|
||||||
|
"dictCode": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"javaName": "planDate",
|
||||||
|
"csName": "PlanDate",
|
||||||
|
"sqlName": "plan_date",
|
||||||
|
"javaType": "Date",
|
||||||
|
"csType": "DateTime?",
|
||||||
|
"comment": "",
|
||||||
|
"isPk": false,
|
||||||
|
"isAudit": false,
|
||||||
|
"isIzEnable": false,
|
||||||
|
"required": false,
|
||||||
|
"dictCode": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"javaName": "planNo",
|
||||||
|
"csName": "PlanNo",
|
||||||
|
"sqlName": "plan_no",
|
||||||
|
"javaType": "String",
|
||||||
|
"csType": "string?",
|
||||||
|
"comment": "",
|
||||||
|
"isPk": false,
|
||||||
|
"isAudit": false,
|
||||||
|
"isIzEnable": false,
|
||||||
|
"required": false,
|
||||||
|
"dictCode": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"javaName": "planId",
|
||||||
|
"csName": "PlanId",
|
||||||
|
"sqlName": "plan_id",
|
||||||
|
"javaType": "String",
|
||||||
|
"csType": "string?",
|
||||||
|
"comment": "",
|
||||||
|
"isPk": false,
|
||||||
|
"isAudit": false,
|
||||||
|
"isIzEnable": false,
|
||||||
|
"required": false,
|
||||||
|
"dictCode": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"javaName": "planType",
|
||||||
|
"csName": "PlanType",
|
||||||
|
"sqlName": "plan_type",
|
||||||
|
"javaType": "String",
|
||||||
|
"csType": "string?",
|
||||||
|
"comment": "",
|
||||||
|
"isPk": false,
|
||||||
|
"isAudit": false,
|
||||||
|
"isIzEnable": false,
|
||||||
|
"required": false,
|
||||||
|
"dictCode": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"javaName": "sourceOrderId",
|
||||||
|
"csName": "SourceOrderId",
|
||||||
|
"sqlName": "source_order_id",
|
||||||
|
"javaType": "String",
|
||||||
|
"csType": "string?",
|
||||||
|
"comment": "",
|
||||||
|
"isPk": false,
|
||||||
|
"isAudit": false,
|
||||||
|
"isIzEnable": false,
|
||||||
|
"required": false,
|
||||||
|
"dictCode": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"javaName": "materialId",
|
||||||
|
"csName": "MaterialId",
|
||||||
|
"sqlName": "material_id",
|
||||||
|
"javaType": "String",
|
||||||
|
"csType": "string?",
|
||||||
|
"comment": "",
|
||||||
|
"isPk": false,
|
||||||
|
"isAudit": false,
|
||||||
|
"isIzEnable": false,
|
||||||
|
"required": false,
|
||||||
|
"dictCode": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"javaName": "materialName",
|
||||||
|
"csName": "MaterialName",
|
||||||
|
"sqlName": "material_name",
|
||||||
|
"javaType": "String",
|
||||||
|
"csType": "string?",
|
||||||
|
"comment": "",
|
||||||
|
"isPk": false,
|
||||||
|
"isAudit": false,
|
||||||
|
"isIzEnable": false,
|
||||||
|
"required": false,
|
||||||
|
"dictCode": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"javaName": "orderNo",
|
||||||
|
"csName": "OrderNo",
|
||||||
|
"sqlName": "order_no",
|
||||||
|
"javaType": "String",
|
||||||
|
"csType": "string?",
|
||||||
|
"comment": "",
|
||||||
|
"isPk": false,
|
||||||
|
"isAudit": false,
|
||||||
|
"isIzEnable": false,
|
||||||
|
"required": false,
|
||||||
|
"dictCode": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"javaName": "orderDate",
|
||||||
|
"csName": "OrderDate",
|
||||||
|
"sqlName": "order_date",
|
||||||
|
"javaType": "Date",
|
||||||
|
"csType": "DateTime?",
|
||||||
|
"comment": "",
|
||||||
|
"isPk": false,
|
||||||
|
"isAudit": false,
|
||||||
|
"isIzEnable": false,
|
||||||
|
"required": false,
|
||||||
|
"dictCode": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"javaName": "formulaName",
|
||||||
|
"csName": "FormulaName",
|
||||||
|
"sqlName": "formula_name",
|
||||||
|
"javaType": "String",
|
||||||
|
"csType": "string?",
|
||||||
|
"comment": "",
|
||||||
|
"isPk": false,
|
||||||
|
"isAudit": false,
|
||||||
|
"isIzEnable": false,
|
||||||
|
"required": false,
|
||||||
|
"dictCode": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"javaName": "planWeight",
|
||||||
|
"csName": "PlanWeight",
|
||||||
|
"sqlName": "plan_weight",
|
||||||
|
"javaType": "BigDecimal",
|
||||||
|
"csType": "double?",
|
||||||
|
"comment": "",
|
||||||
|
"isPk": false,
|
||||||
|
"isAudit": false,
|
||||||
|
"isIzEnable": false,
|
||||||
|
"required": false,
|
||||||
|
"dictCode": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"javaName": "plannedCarCount",
|
||||||
|
"csName": "PlannedCarCount",
|
||||||
|
"sqlName": "planned_car_count",
|
||||||
|
"javaType": "Integer",
|
||||||
|
"csType": "int?",
|
||||||
|
"comment": "",
|
||||||
|
"isPk": false,
|
||||||
|
"isAudit": false,
|
||||||
|
"isIzEnable": false,
|
||||||
|
"required": false,
|
||||||
|
"dictCode": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"javaName": "scheduledCarCount",
|
||||||
|
"csName": "ScheduledCarCount",
|
||||||
|
"sqlName": "scheduled_car_count",
|
||||||
|
"javaType": "Integer",
|
||||||
|
"csType": "int?",
|
||||||
|
"comment": "",
|
||||||
|
"isPk": false,
|
||||||
|
"isAudit": false,
|
||||||
|
"isIzEnable": false,
|
||||||
|
"required": false,
|
||||||
|
"dictCode": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"javaName": "finishedCarCount",
|
||||||
|
"csName": "FinishedCarCount",
|
||||||
|
"sqlName": "finished_car_count",
|
||||||
|
"javaType": "Integer",
|
||||||
|
"csType": "int?",
|
||||||
|
"comment": "",
|
||||||
|
"isPk": false,
|
||||||
|
"isAudit": false,
|
||||||
|
"isIzEnable": false,
|
||||||
|
"required": false,
|
||||||
|
"dictCode": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"javaName": "planCount",
|
||||||
|
"csName": "PlanCount",
|
||||||
|
"sqlName": "plan_count",
|
||||||
|
"javaType": "Integer",
|
||||||
|
"csType": "int?",
|
||||||
|
"comment": "",
|
||||||
|
"isPk": false,
|
||||||
|
"isAudit": false,
|
||||||
|
"isIzEnable": false,
|
||||||
|
"required": false,
|
||||||
|
"dictCode": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"javaName": "remark",
|
||||||
|
"csName": "Remark",
|
||||||
|
"sqlName": "remark",
|
||||||
|
"javaType": "String",
|
||||||
|
"csType": "string?",
|
||||||
|
"comment": "",
|
||||||
|
"isPk": false,
|
||||||
|
"isAudit": false,
|
||||||
|
"isIzEnable": false,
|
||||||
|
"required": false,
|
||||||
|
"dictCode": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"pkField": {
|
||||||
|
"javaName": "id",
|
||||||
|
"csName": "Id",
|
||||||
|
"sqlName": "id",
|
||||||
|
"javaType": "String",
|
||||||
|
"csType": "string?",
|
||||||
|
"comment": "",
|
||||||
|
"isPk": true,
|
||||||
|
"isAudit": false,
|
||||||
|
"isIzEnable": false,
|
||||||
|
"required": false,
|
||||||
|
"dictCode": null
|
||||||
|
},
|
||||||
|
"auditFields": [
|
||||||
|
"TenantId",
|
||||||
|
"SysOrgCode",
|
||||||
|
"CreateBy",
|
||||||
|
"CreateTime",
|
||||||
|
"UpdateBy",
|
||||||
|
"UpdateTime",
|
||||||
|
"DelFlag"
|
||||||
|
],
|
||||||
|
"dbConfig": {
|
||||||
|
"url": "jdbc:mysql://localhost:3306/jeecg-boot-dev?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai",
|
||||||
|
"username": "root",
|
||||||
|
"configFile": "jeecg-boot\\jeecg-boot-module\\jeecg-boot-module-airag\\src\\main\\resources\\application.yml"
|
||||||
|
},
|
||||||
|
"dbColumns": [],
|
||||||
|
"csEntityStub": "public class MesXslMixingProductionPlan\n{\n public string? Id { get; set; }\n public int? SortNo { get; set; }\n public string? MachineId { get; set; } [Dict:id]\n public string? MachineName { get; set; }\n public int? ShiftFlag { get; set; }\n public DateTime? PlanDate { get; set; }\n public string? PlanNo { get; set; }\n public string? PlanId { get; set; }\n public string? PlanType { get; set; }\n public string? SourceOrderId { get; set; }\n public string? MaterialId { get; set; }\n public string? MaterialName { get; set; }\n public string? OrderNo { get; set; }\n public DateTime? OrderDate { get; set; }\n public string? FormulaName { get; set; }\n public double? PlanWeight { get; set; }\n public int? PlannedCarCount { get; set; }\n public int? ScheduledCarCount { get; set; }\n public int? FinishedCarCount { get; set; }\n public int? PlanCount { get; set; }\n public string? Remark { get; set; }\n public int? TenantId { get; set; }\n public string? SysOrgCode { get; set; }\n public string? CreateBy { get; set; }\n public DateTime? CreateTime { get; set; }\n public string? UpdateBy { get; set; }\n public DateTime? UpdateTime { get; set; }\n public int? DelFlag { get; set; }\n // 只读显示属性:\n // public string StatusText => Status == \"1\" ? \"停用\" : \"启用\";\n}",
|
||||||
|
"generationHints": {
|
||||||
|
"eventClassName": "MesXslMixingProductionPlanChangedEvent",
|
||||||
|
"serviceInterface": "IMixingProductionPlanService",
|
||||||
|
"serviceImpl": "MixingProductionPlanService",
|
||||||
|
"syncCoordinator": "MixingProductionPlanSyncCoordinator",
|
||||||
|
"listViewModel": "MixingProductionPlanListViewModel",
|
||||||
|
"editDialogViewModel": "MixingProductionPlanEditDialogViewModel",
|
||||||
|
"listView": "MixingProductionPlanListView",
|
||||||
|
"editDialogView": "MixingProductionPlanEditDialogView",
|
||||||
|
"pendingOpsFile": "mes-xsl-mixing-production-plan-pending-ops.json",
|
||||||
|
"cacheFile": "mes-xsl-mixing-production-plan-cache.json",
|
||||||
|
"nextMenuId": 1300150011401,
|
||||||
|
"nextMenuOrderNo": 113,
|
||||||
|
"backendFilesToModify": [
|
||||||
|
"jeecg-boot\\jeecg-boot-module\\jeecg-module-xslmes\\src\\main\\java\\org\\jeecg\\modules\\xslmes\\controller\\MesXslDesktopAnonController.java",
|
||||||
|
"jeecg-boot\\jeecg-boot-module\\jeecg-module-xslmes\\src\\main\\java\\org\\jeecg\\modules\\xslmes\\service\\MesXslStompNotifyService.java",
|
||||||
|
"jeecg-boot\\jeecg-boot-module\\jeecg-module-xslmes\\src\\main\\java\\org\\jeecg\\modules\\xslmes\\controller\\MesXslMixingProductionPlanController.java",
|
||||||
|
"jeecg-boot-base-core/.../ShiroConfig.java"
|
||||||
|
],
|
||||||
|
"wpfFilesToModify": [
|
||||||
|
"yy-admin-master\\YY.Admin\\Module\\SyncModule.cs",
|
||||||
|
"yy-admin-master\\YY.Admin\\Module\\NavigationExtensions.cs",
|
||||||
|
"yy-admin-master\\YY.Admin\\Infrastructure\\Hubs\\StompWebSocketService.cs",
|
||||||
|
"yy-admin-master\\YY.Admin.Core\\SeedData\\SysMenuSeedData.cs",
|
||||||
|
"YY.Admin.Core/SeedData/SysTenantMenuSeedData.cs"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,10 +14,10 @@ enum Api {
|
|||||||
|
|
||||||
export const list = (params) => defHttp.get({ url: Api.list, params });
|
export const list = (params) => defHttp.get({ url: Api.list, params });
|
||||||
|
|
||||||
export const checkActionName = (params: { actionName: string; dataId?: string }) =>
|
export const checkActionName = (params: { equipmentId?: string; actionName: string; dataId?: string }) =>
|
||||||
defHttp.get({ url: Api.checkActionName, params }, { successMessageMode: 'none', errorMessageMode: 'none' });
|
defHttp.get({ url: Api.checkActionName, params }, { successMessageMode: 'none', errorMessageMode: 'none' });
|
||||||
|
|
||||||
export const checkActionCode = (params: { actionCode: string; dataId?: string }) =>
|
export const checkActionCode = (params: { equipmentId?: string; actionCode: string; dataId?: string }) =>
|
||||||
defHttp.get({ url: Api.checkActionCode, params }, { successMessageMode: 'none', errorMessageMode: 'none' });
|
defHttp.get({ url: Api.checkActionCode, params }, { successMessageMode: 'none', errorMessageMode: 'none' });
|
||||||
|
|
||||||
export const deleteOne = (params, handleSuccess) =>
|
export const deleteOne = (params, handleSuccess) =>
|
||||||
|
|||||||
@@ -2,9 +2,11 @@ import { BasicColumn, FormSchema } from '/@/components/Table';
|
|||||||
import { checkActionCode, checkActionName } from './MesXslMixerAction.api';
|
import { checkActionCode, checkActionName } from './MesXslMixerAction.api';
|
||||||
|
|
||||||
export const columns: BasicColumn[] = [
|
export const columns: BasicColumn[] = [
|
||||||
{ title: '设备名称', align: 'center', dataIndex: 'equipmentId_dictText', width: 180 },
|
{ title: '设备名称', align: 'center', dataIndex: 'equipmentName', width: 180 },
|
||||||
|
{ title: '机台编号', align: 'center', dataIndex: 'equipId', width: 110 },
|
||||||
|
{ title: '机台类型', align: 'center', dataIndex: 'equipType', width: 110 },
|
||||||
{ title: '动作名称', align: 'center', dataIndex: 'actionName', width: 180 },
|
{ title: '动作名称', align: 'center', dataIndex: 'actionName', width: 180 },
|
||||||
{ title: '动作代号', align: 'center', dataIndex: 'actionCode', width: 160 },
|
{ title: '动作代号', align: 'center', dataIndex: 'actionCode', width: 120 },
|
||||||
{ title: '创建时间', align: 'center', dataIndex: 'createTime', width: 170 },
|
{ title: '创建时间', align: 'center', dataIndex: 'createTime', width: 170 },
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -16,6 +18,7 @@ export const searchFormSchema: FormSchema[] = [
|
|||||||
componentProps: { dictCode: 'mes_xsl_equipment_ledger,equipment_name,id' },
|
componentProps: { dictCode: 'mes_xsl_equipment_ledger,equipment_name,id' },
|
||||||
colProps: { span: 6 },
|
colProps: { span: 6 },
|
||||||
},
|
},
|
||||||
|
{ label: '机台编号', field: 'equipId', component: 'Input', colProps: { span: 6 } },
|
||||||
{ label: '动作名称', field: 'actionName', component: 'Input', colProps: { span: 6 } },
|
{ label: '动作名称', field: 'actionName', component: 'Input', colProps: { span: 6 } },
|
||||||
{ label: '动作代号', field: 'actionCode', component: 'Input', colProps: { span: 6 } },
|
{ label: '动作代号', field: 'actionCode', component: 'Input', colProps: { span: 6 } },
|
||||||
];
|
];
|
||||||
@@ -29,6 +32,21 @@ export const formSchema: FormSchema[] = [
|
|||||||
required: true,
|
required: true,
|
||||||
componentProps: { dictCode: 'mes_xsl_equipment_ledger,equipment_name,id', placeholder: '请选择设备台账中的设备' },
|
componentProps: { dictCode: 'mes_xsl_equipment_ledger,equipment_name,id', placeholder: '请选择设备台账中的设备' },
|
||||||
},
|
},
|
||||||
|
// 采集冗余字段:仅采集数据有值,只读展示
|
||||||
|
{
|
||||||
|
label: '机台编号',
|
||||||
|
field: 'equipId',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: { disabled: true },
|
||||||
|
ifShow: ({ values }) => !!values.equipId,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '机台类型',
|
||||||
|
field: 'equipType',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: { disabled: true },
|
||||||
|
ifShow: ({ values }) => !!values.equipType,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: '动作名称',
|
label: '动作名称',
|
||||||
field: 'actionName',
|
field: 'actionName',
|
||||||
@@ -41,10 +59,10 @@ export const formSchema: FormSchema[] = [
|
|||||||
const v = value == null ? '' : String(value).trim();
|
const v = value == null ? '' : String(value).trim();
|
||||||
if (!v) return Promise.resolve();
|
if (!v) return Promise.resolve();
|
||||||
try {
|
try {
|
||||||
await checkActionName({ actionName: v, dataId: model?.id });
|
await checkActionName({ equipmentId: model?.equipmentId, actionName: v, dataId: model?.id });
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
return Promise.reject(e?.response?.data?.message || e?.message || '动作名称不能重复');
|
return Promise.reject(e?.response?.data?.message || e?.message || '同一设备下动作名称不能重复');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
trigger: 'blur',
|
trigger: 'blur',
|
||||||
@@ -63,10 +81,10 @@ export const formSchema: FormSchema[] = [
|
|||||||
const v = value == null ? '' : String(value).trim();
|
const v = value == null ? '' : String(value).trim();
|
||||||
if (!v) return Promise.resolve();
|
if (!v) return Promise.resolve();
|
||||||
try {
|
try {
|
||||||
await checkActionCode({ actionCode: v, dataId: model?.id });
|
await checkActionCode({ equipmentId: model?.equipmentId, actionCode: v, dataId: model?.id });
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
return Promise.reject(e?.response?.data?.message || e?.message || '动作代号不能重复');
|
return Promise.reject(e?.response?.data?.message || e?.message || '同一设备下动作代号不能重复');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
trigger: 'blur',
|
trigger: 'blur',
|
||||||
|
|||||||
@@ -14,15 +14,7 @@
|
|||||||
<a-button preIcon="ant-design:reload-outlined" :loading="refreshing" :disabled="saving" @click="handleRefresh">刷新</a-button>
|
<a-button preIcon="ant-design:reload-outlined" :loading="refreshing" :disabled="saving" @click="handleRefresh">刷新</a-button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<a-table
|
<a-table :columns="columns" :data-source="rows" :pagination="false" :scroll="{ x: 1560 }" row-key="_rowKey" size="small" bordered>
|
||||||
:columns="columns"
|
|
||||||
:data-source="rows"
|
|
||||||
:pagination="false"
|
|
||||||
:scroll="{ x: 1560 }"
|
|
||||||
row-key="_rowKey"
|
|
||||||
size="small"
|
|
||||||
bordered
|
|
||||||
>
|
|
||||||
<template #bodyCell="{ column, record, index }">
|
<template #bodyCell="{ column, record, index }">
|
||||||
<template v-if="column.dataIndex === 'machineName'">
|
<template v-if="column.dataIndex === 'machineName'">
|
||||||
<a-input
|
<a-input
|
||||||
@@ -108,13 +100,15 @@
|
|||||||
import MesXslMixingPlanOrderSelectModal from './components/MesXslMixingPlanOrderSelectModal.vue';
|
import MesXslMixingPlanOrderSelectModal from './components/MesXslMixingPlanOrderSelectModal.vue';
|
||||||
import { list, saveAll } from './MesXslMixingProductionPlan.api';
|
import { list, saveAll } from './MesXslMixingProductionPlan.api';
|
||||||
|
|
||||||
|
type ShiftKey = 'morning' | 'noon' | 'night';
|
||||||
|
|
||||||
const { createMessage } = useMessage();
|
const { createMessage } = useMessage();
|
||||||
const saving = ref(false);
|
const saving = ref(false);
|
||||||
const refreshing = ref(false);
|
const refreshing = ref(false);
|
||||||
const querying = ref(false);
|
const querying = ref(false);
|
||||||
const queryPlanDate = ref<string>('');
|
const queryPlanDate = ref<string>('');
|
||||||
const rows = ref<Recordable[]>([]);
|
const rows = ref<Recordable[]>([]);
|
||||||
const pickerContext = ref<{ rowIndex: number; shift?: 'morning' | 'noon' | 'night' } | null>(null);
|
const pickerContext = ref<{ rowIndex: number; shift?: ShiftKey } | null>(null);
|
||||||
|
|
||||||
const [registerEquipmentModal, { openModal: openEquipmentModal }] = useModal();
|
const [registerEquipmentModal, { openModal: openEquipmentModal }] = useModal();
|
||||||
const [registerOrderModal, { openModal: openOrderModal }] = useModal();
|
const [registerOrderModal, { openModal: openOrderModal }] = useModal();
|
||||||
@@ -158,11 +152,14 @@
|
|||||||
function createEmptyRow(): Recordable {
|
function createEmptyRow(): Recordable {
|
||||||
return {
|
return {
|
||||||
_rowKey: buildUUID(),
|
_rowKey: buildUUID(),
|
||||||
id: '',
|
planDate: queryPlanDate.value || '',
|
||||||
machineId: '',
|
machineId: '',
|
||||||
machineName: '',
|
machineName: '',
|
||||||
|
morningId: '',
|
||||||
|
morningShiftFlag: 1,
|
||||||
morningPlanId: '',
|
morningPlanId: '',
|
||||||
morningPlanType: '',
|
morningPlanType: '',
|
||||||
|
morningSourceOrderId: '',
|
||||||
morningOrderNo: '',
|
morningOrderNo: '',
|
||||||
morningOrderDate: '',
|
morningOrderDate: '',
|
||||||
morningFormulaName: '',
|
morningFormulaName: '',
|
||||||
@@ -172,8 +169,11 @@
|
|||||||
morningFinishedCarCount: null,
|
morningFinishedCarCount: null,
|
||||||
morningPlanCount: null,
|
morningPlanCount: null,
|
||||||
morningRemark: '',
|
morningRemark: '',
|
||||||
|
noonId: '',
|
||||||
|
noonShiftFlag: 2,
|
||||||
noonPlanId: '',
|
noonPlanId: '',
|
||||||
noonPlanType: '',
|
noonPlanType: '',
|
||||||
|
noonSourceOrderId: '',
|
||||||
noonOrderNo: '',
|
noonOrderNo: '',
|
||||||
noonOrderDate: '',
|
noonOrderDate: '',
|
||||||
noonFormulaName: '',
|
noonFormulaName: '',
|
||||||
@@ -183,8 +183,11 @@
|
|||||||
noonFinishedCarCount: null,
|
noonFinishedCarCount: null,
|
||||||
noonPlanCount: null,
|
noonPlanCount: null,
|
||||||
noonRemark: '',
|
noonRemark: '',
|
||||||
|
nightId: '',
|
||||||
|
nightShiftFlag: 3,
|
||||||
nightPlanId: '',
|
nightPlanId: '',
|
||||||
nightPlanType: '',
|
nightPlanType: '',
|
||||||
|
nightSourceOrderId: '',
|
||||||
nightOrderNo: '',
|
nightOrderNo: '',
|
||||||
nightOrderDate: '',
|
nightOrderDate: '',
|
||||||
nightFormulaName: '',
|
nightFormulaName: '',
|
||||||
@@ -197,7 +200,7 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function shiftByOrderField(field: string): 'morning' | 'noon' | 'night' {
|
function shiftByOrderField(field: string): ShiftKey {
|
||||||
if (field.startsWith('morning')) return 'morning';
|
if (field.startsWith('morning')) return 'morning';
|
||||||
if (field.startsWith('noon')) return 'noon';
|
if (field.startsWith('noon')) return 'noon';
|
||||||
return 'night';
|
return 'night';
|
||||||
@@ -240,7 +243,7 @@
|
|||||||
pickerContext.value = null;
|
pickerContext.value = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function openOrderPicker(rowIndex: number, shift: 'morning' | 'noon' | 'night') {
|
function openOrderPicker(rowIndex: number, shift: ShiftKey) {
|
||||||
const row = rows.value[rowIndex];
|
const row = rows.value[rowIndex];
|
||||||
if (!row?.machineId && !row?.machineName) {
|
if (!row?.machineId && !row?.machineName) {
|
||||||
createMessage.warning('请先选择机台信息');
|
createMessage.warning('请先选择机台信息');
|
||||||
@@ -283,6 +286,102 @@
|
|||||||
return Math.max(0, remain);
|
return Math.max(0, remain);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function applyShiftRecord(row: Recordable, shift: ShiftKey, record: Recordable) {
|
||||||
|
if (!record) return;
|
||||||
|
row[`${shift}Id`] = record.id || '';
|
||||||
|
row[`${shift}ShiftFlag`] = record.shiftFlag ?? (shift === 'morning' ? 1 : shift === 'noon' ? 2 : 3);
|
||||||
|
row[`${shift}PlanId`] = record.planId || '';
|
||||||
|
row[`${shift}PlanType`] = record.planType || '';
|
||||||
|
row[`${shift}SourceOrderId`] = record.sourceOrderId || '';
|
||||||
|
row[`${shift}OrderNo`] = record.orderNo || '';
|
||||||
|
row[`${shift}OrderDate`] = record.orderDate || '';
|
||||||
|
row[`${shift}FormulaName`] = record.formulaName || '';
|
||||||
|
row[`${shift}PlanWeight`] = record.planWeight ?? null;
|
||||||
|
row[`${shift}PlannedCarCount`] = record.plannedCarCount ?? null;
|
||||||
|
row[`${shift}ScheduledCarCount`] = record.scheduledCarCount ?? null;
|
||||||
|
row[`${shift}FinishedCarCount`] = record.finishedCarCount ?? null;
|
||||||
|
row[`${shift}PlanCount`] = record.planCount ?? null;
|
||||||
|
row[`${shift}Remark`] = record.remark || '';
|
||||||
|
}
|
||||||
|
|
||||||
|
function convertSharedRecordsToDisplayRows(records: Recordable[]) {
|
||||||
|
const groupMap = new Map<string, { machineId: string; machineName: string; planDate: string; morning: Recordable[]; noon: Recordable[]; night: Recordable[] }>();
|
||||||
|
(records || []).forEach((rec) => {
|
||||||
|
const machineId = rec.machineId || '';
|
||||||
|
const machineName = rec.machineName || '';
|
||||||
|
const planDate = rec.planDate || '';
|
||||||
|
const key = `${planDate}__${machineId}__${machineName}`;
|
||||||
|
if (!groupMap.has(key)) {
|
||||||
|
groupMap.set(key, {
|
||||||
|
machineId,
|
||||||
|
machineName,
|
||||||
|
planDate,
|
||||||
|
morning: [],
|
||||||
|
noon: [],
|
||||||
|
night: [],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const group = groupMap.get(key)!;
|
||||||
|
const flag = Number(rec.shiftFlag);
|
||||||
|
if (flag === 1) group.morning.push(rec);
|
||||||
|
else if (flag === 2) group.noon.push(rec);
|
||||||
|
else group.night.push(rec);
|
||||||
|
});
|
||||||
|
|
||||||
|
const result: Recordable[] = [];
|
||||||
|
Array.from(groupMap.values()).forEach((group) => {
|
||||||
|
const maxLen = Math.max(group.morning.length, group.noon.length, group.night.length);
|
||||||
|
for (let i = 0; i < maxLen; i++) {
|
||||||
|
const row = createEmptyRow();
|
||||||
|
row._rowKey = buildUUID();
|
||||||
|
row.planDate = group.planDate;
|
||||||
|
row.machineId = group.machineId;
|
||||||
|
row.machineName = group.machineName;
|
||||||
|
applyShiftRecord(row, 'morning', group.morning[i]);
|
||||||
|
applyShiftRecord(row, 'noon', group.noon[i]);
|
||||||
|
applyShiftRecord(row, 'night', group.night[i]);
|
||||||
|
result.push(row);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function hasShiftData(row: Recordable, shift: ShiftKey) {
|
||||||
|
return !!(
|
||||||
|
row?.[`${shift}PlanId`] ||
|
||||||
|
row?.[`${shift}OrderNo`] ||
|
||||||
|
row?.[`${shift}FormulaName`] ||
|
||||||
|
row?.[`${shift}PlanCount`] != null ||
|
||||||
|
row?.[`${shift}Remark`]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildSharedShiftRecord(row: Recordable, shift: ShiftKey): Recordable | null {
|
||||||
|
if (!hasShiftData(row, shift) || (!row?.machineId && !row?.machineName)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const shiftFlag = shift === 'morning' ? 1 : shift === 'noon' ? 2 : 3;
|
||||||
|
return {
|
||||||
|
id: row?.[`${shift}Id`] || '',
|
||||||
|
planDate: row?.planDate || queryPlanDate.value || '',
|
||||||
|
machineId: row?.machineId || '',
|
||||||
|
machineName: row?.machineName || '',
|
||||||
|
shiftFlag,
|
||||||
|
planId: row?.[`${shift}PlanId`] || '',
|
||||||
|
planType: row?.[`${shift}PlanType`] || '',
|
||||||
|
sourceOrderId: row?.[`${shift}SourceOrderId`] || '',
|
||||||
|
orderNo: row?.[`${shift}OrderNo`] || '',
|
||||||
|
orderDate: row?.[`${shift}OrderDate`] || '',
|
||||||
|
formulaName: row?.[`${shift}FormulaName`] || '',
|
||||||
|
planWeight: row?.[`${shift}PlanWeight`] ?? null,
|
||||||
|
plannedCarCount: row?.[`${shift}PlannedCarCount`] ?? null,
|
||||||
|
scheduledCarCount: row?.[`${shift}ScheduledCarCount`] ?? null,
|
||||||
|
finishedCarCount: row?.[`${shift}FinishedCarCount`] ?? null,
|
||||||
|
planCount: row?.[`${shift}PlanCount`] ?? null,
|
||||||
|
remark: row?.[`${shift}Remark`] || '',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
async function loadRows() {
|
async function loadRows() {
|
||||||
const res = await list({
|
const res = await list({
|
||||||
pageNo: 1,
|
pageNo: 1,
|
||||||
@@ -290,18 +389,29 @@
|
|||||||
planDate: queryPlanDate.value || undefined,
|
planDate: queryPlanDate.value || undefined,
|
||||||
});
|
});
|
||||||
const records = (res?.records || res?.result?.records || []) as Recordable[];
|
const records = (res?.records || res?.result?.records || []) as Recordable[];
|
||||||
rows.value = (records || []).map((item) => ({ ...createEmptyRow(), ...item, _rowKey: item.id || buildUUID() }));
|
rows.value = convertSharedRecordsToDisplayRows(records);
|
||||||
|
const minRows = 20;
|
||||||
if (!rows.value.length) {
|
if (!rows.value.length) {
|
||||||
rows.value = createBlankRows();
|
rows.value = createBlankRows(minRows);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (rows.value.length < minRows) {
|
||||||
|
rows.value.push(...createBlankRows(minRows - rows.value.length));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleSaveAll() {
|
async function handleSaveAll() {
|
||||||
saving.value = true;
|
saving.value = true;
|
||||||
try {
|
try {
|
||||||
const payload = rows.value.map((r) => {
|
const payload = rows.value.flatMap((row) => {
|
||||||
const { _rowKey, ...rest } = r;
|
const list: Recordable[] = [];
|
||||||
return rest;
|
const morning = buildSharedShiftRecord(row, 'morning');
|
||||||
|
const noon = buildSharedShiftRecord(row, 'noon');
|
||||||
|
const night = buildSharedShiftRecord(row, 'night');
|
||||||
|
if (morning) list.push(morning);
|
||||||
|
if (noon) list.push(noon);
|
||||||
|
if (night) list.push(night);
|
||||||
|
return list;
|
||||||
});
|
});
|
||||||
await saveAll({ rows: payload });
|
await saveAll({ rows: payload });
|
||||||
createMessage.success('保存成功');
|
createMessage.success('保存成功');
|
||||||
|
|||||||
@@ -0,0 +1,201 @@
|
|||||||
|
<template>
|
||||||
|
<BasicModal v-bind="$attrs" @register="registerModal" title="采集操作" :width="560" @ok="handleOk">
|
||||||
|
<a-spin :spinning="loading">
|
||||||
|
<a-form :labelCol="{ span: 7 }" :wrapperCol="{ span: 16 }">
|
||||||
|
<a-form-item label="采集配置">
|
||||||
|
<span>{{ configName || '-' }}</span>
|
||||||
|
<span v-if="sourceTable" style="color: #999"> (源表:{{ sourceTable }})</span>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="是否采集">
|
||||||
|
<a-switch v-model:checked="enabled" checkedChildren="采集中" unCheckedChildren="已停止" />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="采集间隔">
|
||||||
|
<a-input-number v-model:value="intervalSeconds" :min="1" :precision="0" addonAfter="秒" style="width: 100%" />
|
||||||
|
</a-form-item>
|
||||||
|
|
||||||
|
<a-form-item label="采集模式">
|
||||||
|
<a-radio-group v-model:value="syncMode" button-style="solid">
|
||||||
|
<a-radio-button value="FULL">全量匹配</a-radio-button>
|
||||||
|
<a-radio-button value="TIME">时间匹配</a-radio-button>
|
||||||
|
<a-radio-button value="INCR">增量匹配</a-radio-button>
|
||||||
|
</a-radio-group>
|
||||||
|
<div style="color: #999; font-size: 12px; margin-top: 4px">{{ modeHint }}</div>
|
||||||
|
</a-form-item>
|
||||||
|
|
||||||
|
<template v-if="syncMode === 'TIME'">
|
||||||
|
<a-form-item label="时间列" required>
|
||||||
|
<a-select v-model:value="incrColumn" :options="sourceColumnOptions" showSearch allowClear placeholder="选择源表的时间列(如 WriteTime)" />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="时间范围">
|
||||||
|
<a-radio-group v-model:value="timeWindow">
|
||||||
|
<a-radio value="TODAY">当天</a-radio>
|
||||||
|
<a-radio value="LAST7">最近七天</a-radio>
|
||||||
|
</a-radio-group>
|
||||||
|
</a-form-item>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template v-else-if="syncMode === 'INCR'">
|
||||||
|
<a-form-item label="标记列" required>
|
||||||
|
<a-select v-model:value="incrColumn" :options="sourceColumnOptions" showSearch allowClear placeholder="选择源表用于标记是否已采集的列" />
|
||||||
|
<div style="color: #999; font-size: 12px">需在字段映射中勾选匹配键(如 GUID)作为回写主键,并开启中间库写入开关。</div>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="采集条件" required>
|
||||||
|
<a-radio-group v-model:value="flagCondition" button-style="solid">
|
||||||
|
<a-radio-button value="IS_NULL">为空</a-radio-button>
|
||||||
|
<a-radio-button value="EQ_EMPTY">等于</a-radio-button>
|
||||||
|
<a-radio-button value="NE_EMPTY">不等于</a-radio-button>
|
||||||
|
</a-radio-group>
|
||||||
|
<!-- update-begin---author:GHT ---date:20260617 for:【MES上辅机】等于/不等于支持自定义匹配值----------- -->
|
||||||
|
<a-input
|
||||||
|
v-if="flagCondition === 'EQ_EMPTY' || flagCondition === 'NE_EMPTY'"
|
||||||
|
v-model:value="flagMatchValue"
|
||||||
|
:placeholder="`填写要${flagCondition === 'EQ_EMPTY' ? '等于' : '不等于'}的值(留空表示空字符串“”)`"
|
||||||
|
allowClear
|
||||||
|
style="width: 100%; margin-top: 6px"
|
||||||
|
/>
|
||||||
|
<!-- update-end---author:GHT ---date:20260617 for:【MES上辅机】等于/不等于支持自定义匹配值----------- -->
|
||||||
|
<div style="color: #999; font-size: 12px">仅采集“标记列”满足此条件的行。</div>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="回写值">
|
||||||
|
<a-input v-model:value="flagWriteValue" placeholder="采集完成后写回标记列的值,默认 1" allowClear style="width: 100%" />
|
||||||
|
<div style="color: #999; font-size: 12px">采集完成后把标记列回写成该值,使这些行不再满足上面的采集条件(默认“1”)。</div>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="每轮最大行数">
|
||||||
|
<a-input-number v-model:value="batchLimit" :min="100" :step="500" :precision="0" addonAfter="行" style="width: 100%" />
|
||||||
|
<div style="color: #999; font-size: 12px">每个采集周期最多取这么多行,分批吃完历史未采集数据。</div>
|
||||||
|
</a-form-item>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<a-form-item v-if="lastSyncResult" label="最近采集">
|
||||||
|
<span style="color: #999">{{ lastSyncResult }}</span>
|
||||||
|
</a-form-item>
|
||||||
|
</a-form>
|
||||||
|
</a-spin>
|
||||||
|
</BasicModal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { computed, ref } from 'vue';
|
||||||
|
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||||
|
import { useMessage } from '/@/hooks/web/useMessage';
|
||||||
|
import { queryById, getByBizType, saveCollect, getSourceColumns } from '../mcsSyncConfig.api';
|
||||||
|
|
||||||
|
const emit = defineEmits(['register', 'success']);
|
||||||
|
const { createMessage } = useMessage();
|
||||||
|
|
||||||
|
const loading = ref(false);
|
||||||
|
const configId = ref('');
|
||||||
|
const configName = ref('');
|
||||||
|
const sourceTable = ref('');
|
||||||
|
const enabled = ref(false);
|
||||||
|
const intervalSeconds = ref(1);
|
||||||
|
const syncMode = ref('FULL');
|
||||||
|
const incrColumn = ref<string | undefined>(undefined);
|
||||||
|
const timeWindow = ref('TODAY');
|
||||||
|
const batchLimit = ref(2000);
|
||||||
|
const flagCondition = ref('IS_NULL');
|
||||||
|
const flagMatchValue = ref('');
|
||||||
|
const flagWriteValue = ref('1');
|
||||||
|
const lastWatermark = ref('');
|
||||||
|
const lastSyncResult = ref('');
|
||||||
|
const sourceColumnOptions = ref<any[]>([]);
|
||||||
|
|
||||||
|
const modeHint = computed(() => {
|
||||||
|
if (syncMode.value === 'TIME') return '只采集时间列在所选范围内的数据,再按匹配键更新/新增。适合中大型表只关注近期数据。';
|
||||||
|
if (syncMode.value === 'INCR') return '标记位回写:只采集“标记列”为空的行,采完回写“1”,下轮不再重复。适合带 GUID 主键、无可靠递增列的流水表。';
|
||||||
|
return '全表读取并按匹配键更新/新增。适合数据量小、以更新为主的表。';
|
||||||
|
});
|
||||||
|
|
||||||
|
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||||
|
setModalProps({ confirmLoading: false });
|
||||||
|
loading.value = true;
|
||||||
|
try {
|
||||||
|
reset();
|
||||||
|
const cfg: any = data?.id ? await queryById(data.id) : await getByBizType(data?.bizType || 'MIX_ACT');
|
||||||
|
if (!cfg || !cfg.id) {
|
||||||
|
createMessage.warning('未找到采集配置,请先在「采集配置」中新增');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
configId.value = cfg.id;
|
||||||
|
configName.value = cfg.configName || cfg.bizName || cfg.sourceTable;
|
||||||
|
sourceTable.value = cfg.sourceTable || '';
|
||||||
|
enabled.value = cfg.running === true || cfg.status === '1';
|
||||||
|
intervalSeconds.value = cfg.intervalSeconds || 1;
|
||||||
|
syncMode.value = cfg.syncMode || 'FULL';
|
||||||
|
incrColumn.value = cfg.incrColumn || undefined;
|
||||||
|
timeWindow.value = cfg.timeWindow || 'TODAY';
|
||||||
|
batchLimit.value = cfg.batchLimit || 2000;
|
||||||
|
flagCondition.value = cfg.flagCondition || 'IS_NULL';
|
||||||
|
flagMatchValue.value = cfg.flagMatchValue ?? '';
|
||||||
|
flagWriteValue.value = cfg.flagWriteValue ?? '1';
|
||||||
|
lastWatermark.value = cfg.lastWatermark || '';
|
||||||
|
lastSyncResult.value = cfg.lastSyncResult || '';
|
||||||
|
// 载入源表列供时间列/增量列选择(中间库未连接时静默忽略)
|
||||||
|
if (sourceTable.value) {
|
||||||
|
try {
|
||||||
|
const cols: any = await getSourceColumns(sourceTable.value);
|
||||||
|
sourceColumnOptions.value = (cols || []).map((c: any) => ({
|
||||||
|
label: c.columnName + (c.columnComment ? ` - ${c.columnComment}` : '') + (c.dataType ? ` (${c.dataType})` : ''),
|
||||||
|
value: c.columnName,
|
||||||
|
}));
|
||||||
|
} catch (e) {
|
||||||
|
sourceColumnOptions.value = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function reset() {
|
||||||
|
configId.value = '';
|
||||||
|
configName.value = '';
|
||||||
|
sourceTable.value = '';
|
||||||
|
enabled.value = false;
|
||||||
|
intervalSeconds.value = 1;
|
||||||
|
syncMode.value = 'FULL';
|
||||||
|
incrColumn.value = undefined;
|
||||||
|
timeWindow.value = 'TODAY';
|
||||||
|
batchLimit.value = 2000;
|
||||||
|
flagCondition.value = 'IS_NULL';
|
||||||
|
flagMatchValue.value = '';
|
||||||
|
flagWriteValue.value = '1';
|
||||||
|
lastWatermark.value = '';
|
||||||
|
lastSyncResult.value = '';
|
||||||
|
sourceColumnOptions.value = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleOk() {
|
||||||
|
if (!configId.value) {
|
||||||
|
closeModal();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!intervalSeconds.value || intervalSeconds.value < 1) {
|
||||||
|
createMessage.warning('采集间隔不能小于1秒');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ((syncMode.value === 'TIME' || syncMode.value === 'INCR') && !incrColumn.value) {
|
||||||
|
createMessage.warning(syncMode.value === 'TIME' ? '请选择时间列' : '请选择标记列');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setModalProps({ confirmLoading: true });
|
||||||
|
try {
|
||||||
|
await saveCollect({
|
||||||
|
id: configId.value,
|
||||||
|
status: enabled.value ? '1' : '0',
|
||||||
|
intervalSeconds: intervalSeconds.value,
|
||||||
|
syncMode: syncMode.value,
|
||||||
|
incrColumn: incrColumn.value,
|
||||||
|
timeWindow: timeWindow.value,
|
||||||
|
batchLimit: batchLimit.value,
|
||||||
|
flagCondition: flagCondition.value,
|
||||||
|
flagMatchValue: flagMatchValue.value,
|
||||||
|
flagWriteValue: flagWriteValue.value,
|
||||||
|
});
|
||||||
|
closeModal();
|
||||||
|
emit('success');
|
||||||
|
} finally {
|
||||||
|
setModalProps({ confirmLoading: false });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,267 @@
|
|||||||
|
<template>
|
||||||
|
<BasicModal v-bind="$attrs" @register="registerModal" :title="title" :width="960" @ok="handleSubmit" :confirmLoading="confirmLoading">
|
||||||
|
<a-spin :spinning="loading">
|
||||||
|
<a-form :model="form" :labelCol="{ span: 6 }" :wrapperCol="{ span: 16 }">
|
||||||
|
<a-row>
|
||||||
|
<a-col :span="12">
|
||||||
|
<a-form-item label="配置名称" required>
|
||||||
|
<a-input v-model:value="form.configName" placeholder="如:密炼机动作采集" />
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="12">
|
||||||
|
<a-form-item label="采集间隔">
|
||||||
|
<a-input-number v-model:value="form.intervalSeconds" :min="1" :precision="0" addonAfter="秒" style="width: 100%" />
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
</a-row>
|
||||||
|
<a-row>
|
||||||
|
<a-col :span="12">
|
||||||
|
<a-form-item label="中间库源表" required>
|
||||||
|
<a-select
|
||||||
|
v-model:value="form.sourceTable"
|
||||||
|
:options="sourceTableOptions"
|
||||||
|
showSearch
|
||||||
|
placeholder="选择中间库的表"
|
||||||
|
style="width: 100%"
|
||||||
|
@change="onSourceTableChange"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="12">
|
||||||
|
<a-form-item label="MES目标表" required>
|
||||||
|
<a-select
|
||||||
|
v-model:value="form.targetTable"
|
||||||
|
:options="targetTableOptions"
|
||||||
|
showSearch
|
||||||
|
placeholder="选择MES的表(mes_xsl_)"
|
||||||
|
style="width: 100%"
|
||||||
|
@change="onTargetTableChange"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
</a-row>
|
||||||
|
</a-form>
|
||||||
|
|
||||||
|
<a-divider style="margin: 8px 0">字段映射(左:中间库字段 / 右:MES接收字段;勾选匹配键作为去重Upsert唯一键)</a-divider>
|
||||||
|
|
||||||
|
<a-table
|
||||||
|
:columns="mappingColumns"
|
||||||
|
:dataSource="mappingRows"
|
||||||
|
:pagination="false"
|
||||||
|
size="small"
|
||||||
|
rowKey="sourceField"
|
||||||
|
:scroll="{ y: 360 }"
|
||||||
|
>
|
||||||
|
<template #bodyCell="{ column, record }">
|
||||||
|
<template v-if="column.dataIndex === 'sourceField'">
|
||||||
|
<div>{{ record.sourceField }}</div>
|
||||||
|
<div style="color: #999; font-size: 12px">{{ record.sourceFieldComment }}</div>
|
||||||
|
</template>
|
||||||
|
<template v-else-if="column.dataIndex === 'targetField'">
|
||||||
|
<a-select
|
||||||
|
v-model:value="record.targetField"
|
||||||
|
:options="targetColumnOptions"
|
||||||
|
allowClear
|
||||||
|
showSearch
|
||||||
|
placeholder="选择MES接收字段"
|
||||||
|
style="width: 100%"
|
||||||
|
:disabled="!form.targetTable"
|
||||||
|
@change="(v) => onTargetFieldChange(record, v)"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template v-else-if="column.dataIndex === 'matchKey'">
|
||||||
|
<a-checkbox v-model:checked="record.matchKey" />
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
|
</a-table>
|
||||||
|
<div v-if="mappingRows.length === 0" style="text-align: center; color: #999; padding: 16px">请选择中间库源表以载入字段</div>
|
||||||
|
</a-spin>
|
||||||
|
</BasicModal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { computed, reactive, ref } from 'vue';
|
||||||
|
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||||
|
import { useMessage } from '/@/hooks/web/useMessage';
|
||||||
|
import { queryById, saveOrUpdate, getSourceTables, getSourceColumns, getTargetTables, getTargetColumns } from '../mcsSyncConfig.api';
|
||||||
|
|
||||||
|
const emit = defineEmits(['register', 'success']);
|
||||||
|
const { createMessage } = useMessage();
|
||||||
|
|
||||||
|
const isUpdate = ref(false);
|
||||||
|
const loading = ref(false);
|
||||||
|
const confirmLoading = ref(false);
|
||||||
|
|
||||||
|
const form = reactive<any>({
|
||||||
|
id: undefined,
|
||||||
|
configName: '',
|
||||||
|
bizType: '',
|
||||||
|
sourceTable: undefined,
|
||||||
|
sourceTableComment: '',
|
||||||
|
targetTable: undefined,
|
||||||
|
targetTableComment: '',
|
||||||
|
intervalSeconds: 1,
|
||||||
|
});
|
||||||
|
|
||||||
|
const sourceTableOptions = ref<any[]>([]);
|
||||||
|
const targetTableOptions = ref<any[]>([]);
|
||||||
|
const targetColumnOptions = ref<any[]>([]);
|
||||||
|
const mappingRows = ref<any[]>([]);
|
||||||
|
|
||||||
|
const title = computed(() => (isUpdate.value ? '编辑采集配置' : '新增采集配置'));
|
||||||
|
|
||||||
|
const mappingColumns = [
|
||||||
|
{ title: '中间库字段', dataIndex: 'sourceField', width: 240 },
|
||||||
|
{ title: '类型', dataIndex: 'sourceFieldType', width: 90 },
|
||||||
|
{ title: 'MES接收字段', dataIndex: 'targetField' },
|
||||||
|
{ title: '匹配键', dataIndex: 'matchKey', width: 70, align: 'center' },
|
||||||
|
];
|
||||||
|
|
||||||
|
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||||
|
setModalProps({ confirmLoading: false });
|
||||||
|
loading.value = true;
|
||||||
|
try {
|
||||||
|
resetForm();
|
||||||
|
isUpdate.value = !!data?.isUpdate;
|
||||||
|
// 表清单
|
||||||
|
const [srcTables, tgtTables] = await Promise.all([safeGet(getSourceTables), getTargetTables()]);
|
||||||
|
sourceTableOptions.value = (srcTables || []).map((t: any) => ({
|
||||||
|
label: t.tableName + (t.tableComment ? ` - ${t.tableComment}` : ''),
|
||||||
|
value: t.tableName,
|
||||||
|
comment: t.tableComment,
|
||||||
|
}));
|
||||||
|
targetTableOptions.value = (tgtTables || []).map((t: any) => ({
|
||||||
|
label: t.tableName + (t.tableComment ? ` - ${t.tableComment}` : ''),
|
||||||
|
value: t.tableName,
|
||||||
|
comment: t.tableComment,
|
||||||
|
}));
|
||||||
|
|
||||||
|
if (isUpdate.value && data?.record?.id) {
|
||||||
|
const cfg: any = await queryById(data.record.id);
|
||||||
|
Object.assign(form, {
|
||||||
|
id: cfg.id,
|
||||||
|
configName: cfg.configName,
|
||||||
|
bizType: cfg.bizType,
|
||||||
|
sourceTable: cfg.sourceTable,
|
||||||
|
sourceTableComment: cfg.sourceTableComment,
|
||||||
|
targetTable: cfg.targetTable,
|
||||||
|
targetTableComment: cfg.targetTableComment,
|
||||||
|
intervalSeconds: cfg.intervalSeconds || 1,
|
||||||
|
});
|
||||||
|
// 载入目标字段选项
|
||||||
|
if (cfg.targetTable) {
|
||||||
|
targetColumnOptions.value = buildColumnOptions(await getTargetColumns(cfg.targetTable));
|
||||||
|
}
|
||||||
|
// 字段映射来自已存配置
|
||||||
|
mappingRows.value = (cfg.fieldList || []).map((f: any) => ({
|
||||||
|
sourceField: f.sourceField,
|
||||||
|
sourceFieldComment: f.sourceFieldComment,
|
||||||
|
sourceFieldType: f.sourceFieldType,
|
||||||
|
targetField: f.targetField,
|
||||||
|
targetFieldComment: f.targetFieldComment,
|
||||||
|
matchKey: f.matchKey === '1',
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function resetForm() {
|
||||||
|
Object.assign(form, {
|
||||||
|
id: undefined,
|
||||||
|
configName: '',
|
||||||
|
bizType: '',
|
||||||
|
sourceTable: undefined,
|
||||||
|
sourceTableComment: '',
|
||||||
|
targetTable: undefined,
|
||||||
|
targetTableComment: '',
|
||||||
|
intervalSeconds: 1,
|
||||||
|
});
|
||||||
|
targetColumnOptions.value = [];
|
||||||
|
mappingRows.value = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
async function safeGet(fn: () => Promise<any>) {
|
||||||
|
try {
|
||||||
|
return await fn();
|
||||||
|
} catch (e) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildColumnOptions(cols: any[]) {
|
||||||
|
return (cols || []).map((c: any) => ({
|
||||||
|
label: c.columnName + (c.columnComment ? ` - ${c.columnComment}` : ''),
|
||||||
|
value: c.columnName,
|
||||||
|
comment: c.columnComment,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
async function onSourceTableChange(val: string) {
|
||||||
|
const opt = sourceTableOptions.value.find((o) => o.value === val);
|
||||||
|
form.sourceTableComment = opt?.comment || '';
|
||||||
|
if (!val) {
|
||||||
|
mappingRows.value = [];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const cols = await getSourceColumns(val);
|
||||||
|
mappingRows.value = (cols || []).map((c: any) => {
|
||||||
|
// 同名自动匹配 MES 字段
|
||||||
|
const guess = targetColumnOptions.value.find((o) => o.value.toLowerCase() === String(c.columnName).toLowerCase());
|
||||||
|
return {
|
||||||
|
sourceField: c.columnName,
|
||||||
|
sourceFieldComment: c.columnComment,
|
||||||
|
sourceFieldType: c.dataType,
|
||||||
|
targetField: guess ? guess.value : undefined,
|
||||||
|
targetFieldComment: guess ? guess.comment : '',
|
||||||
|
matchKey: false,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function onTargetTableChange(val: string) {
|
||||||
|
const opt = targetTableOptions.value.find((o) => o.value === val);
|
||||||
|
form.targetTableComment = opt?.comment || '';
|
||||||
|
targetColumnOptions.value = val ? buildColumnOptions(await getTargetColumns(val)) : [];
|
||||||
|
}
|
||||||
|
|
||||||
|
function onTargetFieldChange(record: any, val: string) {
|
||||||
|
const opt = targetColumnOptions.value.find((o) => o.value === val);
|
||||||
|
record.targetFieldComment = opt?.comment || '';
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleSubmit() {
|
||||||
|
if (!form.configName) {
|
||||||
|
createMessage.warning('请填写配置名称');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!form.sourceTable || !form.targetTable) {
|
||||||
|
createMessage.warning('请选择中间库源表与MES目标表');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const fieldList = mappingRows.value
|
||||||
|
.filter((r) => r.targetField)
|
||||||
|
.map((r, idx) => ({
|
||||||
|
sourceField: r.sourceField,
|
||||||
|
sourceFieldComment: r.sourceFieldComment,
|
||||||
|
sourceFieldType: r.sourceFieldType,
|
||||||
|
targetField: r.targetField,
|
||||||
|
targetFieldComment: r.targetFieldComment,
|
||||||
|
matchKey: r.matchKey ? '1' : '0',
|
||||||
|
sortNo: idx,
|
||||||
|
}));
|
||||||
|
if (fieldList.length === 0) {
|
||||||
|
createMessage.warning('请至少为一个中间库字段选择 MES 接收字段');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
confirmLoading.value = true;
|
||||||
|
try {
|
||||||
|
await saveOrUpdate({ ...form, fieldList }, isUpdate.value);
|
||||||
|
closeModal();
|
||||||
|
emit('success');
|
||||||
|
} finally {
|
||||||
|
confirmLoading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
64
jeecgboot-vue3/src/views/xslmesMcs/mcsSyncConfig/index.vue
Normal file
64
jeecgboot-vue3/src/views/xslmesMcs/mcsSyncConfig/index.vue
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<BasicTable @register="registerTable">
|
||||||
|
<template #tableTitle>
|
||||||
|
<a-button type="primary" v-auth="'xslmes:mcsSyncConfig:add'" preIcon="ant-design:plus-outlined" @click="handleAdd">新增采集配置</a-button>
|
||||||
|
</template>
|
||||||
|
<template #action="{ record }">
|
||||||
|
<TableAction :actions="getTableAction(record)" />
|
||||||
|
</template>
|
||||||
|
</BasicTable>
|
||||||
|
<SyncConfigModal @register="registerEditModal" @success="reload" />
|
||||||
|
<CollectModal @register="registerCollectModal" @success="reload" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" name="xslmes-mcs-mcsSyncConfig" setup>
|
||||||
|
import { BasicTable, TableAction } from '/@/components/Table';
|
||||||
|
import { useModal } from '/@/components/Modal';
|
||||||
|
import { useListPage } from '/@/hooks/system/useListPage';
|
||||||
|
import SyncConfigModal from './components/SyncConfigModal.vue';
|
||||||
|
import CollectModal from './components/CollectModal.vue';
|
||||||
|
import { columns, searchFormSchema } from './mcsSyncConfig.data';
|
||||||
|
import { list, deleteOne } from './mcsSyncConfig.api';
|
||||||
|
|
||||||
|
const [registerEditModal, { openModal: openEditModal }] = useModal();
|
||||||
|
const [registerCollectModal, { openModal: openCollectModal }] = useModal();
|
||||||
|
|
||||||
|
const { tableContext } = useListPage({
|
||||||
|
tableProps: {
|
||||||
|
title: '采集配置',
|
||||||
|
api: list,
|
||||||
|
columns,
|
||||||
|
canResize: true,
|
||||||
|
formConfig: { labelWidth: 100, schemas: searchFormSchema, autoSubmitOnEnter: true },
|
||||||
|
actionColumn: { width: 200, fixed: 'right' },
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const [registerTable, { reload }] = tableContext;
|
||||||
|
|
||||||
|
function handleAdd() {
|
||||||
|
openEditModal(true, { isUpdate: false });
|
||||||
|
}
|
||||||
|
function handleEdit(record) {
|
||||||
|
openEditModal(true, { isUpdate: true, record });
|
||||||
|
}
|
||||||
|
function handleCollect(record) {
|
||||||
|
openCollectModal(true, { id: record.id });
|
||||||
|
}
|
||||||
|
async function handleDelete(record) {
|
||||||
|
await deleteOne(record.id, reload);
|
||||||
|
}
|
||||||
|
function getTableAction(record) {
|
||||||
|
return [
|
||||||
|
{ label: '编辑', onClick: handleEdit.bind(null, record), auth: 'xslmes:mcsSyncConfig:edit' },
|
||||||
|
{ label: '采集操作', onClick: handleCollect.bind(null, record), auth: 'xslmes:mcsSyncConfig:setting' },
|
||||||
|
{
|
||||||
|
label: '删除',
|
||||||
|
color: 'error',
|
||||||
|
popConfirm: { title: '确认删除该采集配置?', confirm: handleDelete.bind(null, record) },
|
||||||
|
auth: 'xslmes:mcsSyncConfig:delete',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
import { defHttp } from '/@/utils/http/axios';
|
||||||
|
|
||||||
|
enum Api {
|
||||||
|
list = '/xslmes/mcs/syncConfig/list',
|
||||||
|
queryById = '/xslmes/mcs/syncConfig/queryById',
|
||||||
|
getByBizType = '/xslmes/mcs/syncConfig/getByBizType',
|
||||||
|
add = '/xslmes/mcs/syncConfig/add',
|
||||||
|
edit = '/xslmes/mcs/syncConfig/edit',
|
||||||
|
deleteOne = '/xslmes/mcs/syncConfig/delete',
|
||||||
|
saveCollect = '/xslmes/mcs/syncConfig/saveCollect',
|
||||||
|
sourceTables = '/xslmes/mcs/syncConfig/meta/sourceTables',
|
||||||
|
sourceColumns = '/xslmes/mcs/syncConfig/meta/sourceColumns',
|
||||||
|
targetTables = '/xslmes/mcs/syncConfig/meta/targetTables',
|
||||||
|
targetColumns = '/xslmes/mcs/syncConfig/meta/targetColumns',
|
||||||
|
}
|
||||||
|
|
||||||
|
export const list = (params) => defHttp.get({ url: Api.list, params });
|
||||||
|
|
||||||
|
export const queryById = (id: string) => defHttp.get({ url: Api.queryById, params: { id } });
|
||||||
|
|
||||||
|
export const getByBizType = (bizType = 'MIX_ACT') => defHttp.get({ url: Api.getByBizType, params: { bizType } });
|
||||||
|
|
||||||
|
export const saveOrUpdate = (params, isUpdate: boolean) => defHttp.post({ url: isUpdate ? Api.edit : Api.add, params });
|
||||||
|
|
||||||
|
export const deleteOne = (id: string, handleSuccess) =>
|
||||||
|
defHttp.delete({ url: Api.deleteOne, params: { id } }, { joinParamsToUrl: true }).then(() => handleSuccess());
|
||||||
|
|
||||||
|
// 采集操作:status '1'/'0' 表示是否采集;syncMode FULL/TIME/INCR
|
||||||
|
export const saveCollect = (params: {
|
||||||
|
id: string;
|
||||||
|
status: string;
|
||||||
|
intervalSeconds: number;
|
||||||
|
syncMode?: string;
|
||||||
|
incrColumn?: string;
|
||||||
|
timeWindow?: string;
|
||||||
|
batchLimit?: number;
|
||||||
|
flagCondition?: string;
|
||||||
|
flagWriteValue?: string;
|
||||||
|
}) => defHttp.post({ url: Api.saveCollect, params });
|
||||||
|
|
||||||
|
export const getSourceTables = () => defHttp.get({ url: Api.sourceTables }, { errorMessageMode: 'message' });
|
||||||
|
export const getSourceColumns = (table: string) => defHttp.get({ url: Api.sourceColumns, params: { table } }, { errorMessageMode: 'message' });
|
||||||
|
export const getTargetTables = () => defHttp.get({ url: Api.targetTables });
|
||||||
|
export const getTargetColumns = (table: string) => defHttp.get({ url: Api.targetColumns, params: { table } });
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
import { BasicColumn, FormSchema } from '/@/components/Table';
|
||||||
|
|
||||||
|
export const columns: BasicColumn[] = [
|
||||||
|
{ title: '配置名称', align: 'center', dataIndex: 'configName', width: 160 },
|
||||||
|
{
|
||||||
|
title: '中间库源表',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'sourceTable',
|
||||||
|
width: 200,
|
||||||
|
customRender: ({ record }) => (record.sourceTableComment ? `${record.sourceTable}(${record.sourceTableComment})` : record.sourceTable),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'MES目标表',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'targetTable',
|
||||||
|
width: 200,
|
||||||
|
customRender: ({ record }) => (record.targetTableComment ? `${record.targetTable}(${record.targetTableComment})` : record.targetTable),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '采集模式',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'syncMode',
|
||||||
|
width: 100,
|
||||||
|
customRender: ({ record }) => ({ FULL: '全量匹配', TIME: '时间匹配', INCR: '增量匹配' }[record.syncMode] || '全量匹配'),
|
||||||
|
},
|
||||||
|
{ title: '采集间隔(秒)', align: 'center', dataIndex: 'intervalSeconds', width: 100 },
|
||||||
|
{
|
||||||
|
title: '状态',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'running',
|
||||||
|
width: 90,
|
||||||
|
customRender: ({ record }) => (record.running ? '采集中' : '已停止'),
|
||||||
|
},
|
||||||
|
{ title: '最近采集时间', align: 'center', dataIndex: 'lastSyncTime', width: 160 },
|
||||||
|
{ title: '最近采集结果', align: 'center', dataIndex: 'lastSyncResult', width: 200 },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const searchFormSchema: FormSchema[] = [
|
||||||
|
{ label: '配置名称', field: 'configName', component: 'Input', colProps: { span: 6 } },
|
||||||
|
{ label: '中间库源表', field: 'sourceTable', component: 'Input', colProps: { span: 6 } },
|
||||||
|
];
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<BasicTable @register="registerTable">
|
<BasicTable @register="registerTable">
|
||||||
<template #tableTitle>
|
<template #tableTitle>
|
||||||
<a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
|
<a-button type="primary" v-auth="'xslmes:mcsSyncConfig:setting'" preIcon="ant-design:sync-outlined" @click="openCollect"> 采集操作 </a-button>
|
||||||
|
<a-button type="link" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
|
||||||
<super-query :config="superQueryConfig" @search="handleSuperQuery" />
|
<super-query :config="superQueryConfig" @search="handleSuperQuery" />
|
||||||
</template>
|
</template>
|
||||||
<template #action="{ record }">
|
<template #action="{ record }">
|
||||||
@@ -10,6 +11,7 @@
|
|||||||
</template>
|
</template>
|
||||||
</BasicTable>
|
</BasicTable>
|
||||||
<McsToMesMixActModal @register="registerModal" />
|
<McsToMesMixActModal @register="registerModal" />
|
||||||
|
<CollectModal @register="registerCollectModal" @success="reload" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -19,11 +21,13 @@
|
|||||||
import { useModal } from '/@/components/Modal';
|
import { useModal } from '/@/components/Modal';
|
||||||
import { useListPage } from '/@/hooks/system/useListPage';
|
import { useListPage } from '/@/hooks/system/useListPage';
|
||||||
import McsToMesMixActModal from './components/McsToMesMixActModal.vue';
|
import McsToMesMixActModal from './components/McsToMesMixActModal.vue';
|
||||||
|
import CollectModal from '../mcsSyncConfig/components/CollectModal.vue';
|
||||||
import { columns, searchFormSchema } from './McsToMesMixAct.data';
|
import { columns, searchFormSchema } from './McsToMesMixAct.data';
|
||||||
import { list, getExportUrl } from './McsToMesMixAct.api';
|
import { list, getExportUrl } from './McsToMesMixAct.api';
|
||||||
|
|
||||||
const queryParam = reactive<any>({});
|
const queryParam = reactive<any>({});
|
||||||
const [registerModal, { openModal }] = useModal();
|
const [registerModal, { openModal }] = useModal();
|
||||||
|
const [registerCollectModal, { openModal: openCollectModal }] = useModal();
|
||||||
|
|
||||||
const { tableContext, onExportXls } = useListPage({
|
const { tableContext, onExportXls } = useListPage({
|
||||||
tableProps: {
|
tableProps: {
|
||||||
@@ -49,8 +53,15 @@
|
|||||||
const [registerTable, { reload }] = tableContext;
|
const [registerTable, { reload }] = tableContext;
|
||||||
const superQueryConfig = reactive({});
|
const superQueryConfig = reactive({});
|
||||||
|
|
||||||
|
// 采集操作:弹窗维护是否采集 + 采集间隔(绑定密炼动作采集配置 MIX_ACT)
|
||||||
|
function openCollect() {
|
||||||
|
openCollectModal(true, { bizType: 'MIX_ACT' });
|
||||||
|
}
|
||||||
|
|
||||||
function handleSuperQuery(params) {
|
function handleSuperQuery(params) {
|
||||||
Object.keys(params).map((k) => { queryParam[k] = params[k]; });
|
Object.keys(params).map((k) => {
|
||||||
|
queryParam[k] = params[k];
|
||||||
|
});
|
||||||
reload();
|
reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
using Prism.Events;
|
||||||
|
|
||||||
|
namespace YY.Admin.Core.Events;
|
||||||
|
|
||||||
|
public class MixingProductionPlanChangedPayload
|
||||||
|
{
|
||||||
|
public string Action { get; set; } = string.Empty;
|
||||||
|
public string? MixingProductionPlanId { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MixingProductionPlanChangedEvent : PubSubEvent<MixingProductionPlanChangedPayload> { }
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
using YY.Admin.Core.Entity;
|
||||||
|
|
||||||
|
namespace YY.Admin.Core.Services;
|
||||||
|
|
||||||
|
/// <summary>密炼生产计划(MES 只读同步)</summary>
|
||||||
|
public interface IMixingProductionPlanService
|
||||||
|
{
|
||||||
|
Task<MixingProductionPlanPageResult> PageAsync(
|
||||||
|
int pageNo, int pageSize,
|
||||||
|
DateTime? planDateFrom = null,
|
||||||
|
DateTime? planDateTo = null,
|
||||||
|
string? machineName = null,
|
||||||
|
int? shiftFlag = null,
|
||||||
|
string? planNo = null,
|
||||||
|
string? materialName = null,
|
||||||
|
CancellationToken ct = default);
|
||||||
|
|
||||||
|
Task<List<MesXslMixingProductionPlan>> GetAllCachedAsync(CancellationToken ct = default);
|
||||||
|
|
||||||
|
/// <returns>本地缓存是否有变更(有差异才写入)</returns>
|
||||||
|
Task<bool> SyncFromRemoteAsync(CancellationToken ct = default);
|
||||||
|
}
|
||||||
|
|
||||||
|
public record MixingProductionPlanPageResult(
|
||||||
|
List<MesXslMixingProductionPlan> Records,
|
||||||
|
long Total,
|
||||||
|
int PageNo,
|
||||||
|
int PageSize);
|
||||||
@@ -2,12 +2,8 @@ using YY.Admin.Core.Entity;
|
|||||||
|
|
||||||
namespace YY.Admin.Core.Services;
|
namespace YY.Admin.Core.Services;
|
||||||
|
|
||||||
/// <summary>胶料快检记录操作台:密炼计划筛选、实验标准匹配、记录保存</summary>
|
/// <summary>胶料快检记录操作台:保存至 MES</summary>
|
||||||
public interface IRubberQuickTestOperationService
|
public interface IRubberQuickTestOperationService
|
||||||
{
|
{
|
||||||
Task<List<MesXslMixingProductionPlan>> GetMixingProductionPlansAsync(CancellationToken ct = default);
|
|
||||||
|
|
||||||
Task<MesXslRubberQuickTestStd?> GetStdByRubberMaterialNameAsync(string rubberMaterialName, CancellationToken ct = default);
|
|
||||||
|
|
||||||
Task<string?> SaveRecordAsync(MesXslRubberQuickTestRecord record, CancellationToken ct = default);
|
Task<string?> SaveRecordAsync(MesXslRubberQuickTestRecord record, CancellationToken ct = default);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,15 @@ public interface IRubberQuickTestStdService
|
|||||||
|
|
||||||
Task<MesXslRubberQuickTestStd?> GetByIdAsync(string id, CancellationToken ct = default);
|
Task<MesXslRubberQuickTestStd?> GetByIdAsync(string id, CancellationToken ct = default);
|
||||||
|
|
||||||
Task SyncFromRemoteAsync(CancellationToken ct = default);
|
Task<List<MesXslRubberQuickTestStd>> GetAllCachedAsync(CancellationToken ct = default);
|
||||||
|
|
||||||
|
Task<MesXslRubberQuickTestStd?> GetCachedByIdAsync(string id, CancellationToken ct = default);
|
||||||
|
|
||||||
|
/// <summary>优先读本地缓存;无明细时联网拉取详情并回写缓存</summary>
|
||||||
|
Task<MesXslRubberQuickTestStd?> GetWithLinesAsync(string id, CancellationToken ct = default);
|
||||||
|
|
||||||
|
/// <returns>本地缓存是否有变更(有差异才写入)</returns>
|
||||||
|
Task<bool> SyncFromRemoteAsync(CancellationToken ct = default);
|
||||||
}
|
}
|
||||||
|
|
||||||
public record RubberQuickTestStdPageResult(
|
public record RubberQuickTestStdPageResult(
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
namespace YY.Admin.Core.Entity;
|
namespace YY.Admin.Core.Entity;
|
||||||
|
|
||||||
/// <summary>密炼生产计划维护(桌面端快检记录筛选用)</summary>
|
/// <summary>密炼生产计划维护(MES 数据源,桌面端只读同步)</summary>
|
||||||
public class MesXslMixingProductionPlan
|
public class MesXslMixingProductionPlan
|
||||||
{
|
{
|
||||||
public string? Id { get; set; }
|
public string? Id { get; set; }
|
||||||
@@ -8,21 +8,57 @@ public class MesXslMixingProductionPlan
|
|||||||
public string? MachineId { get; set; }
|
public string? MachineId { get; set; }
|
||||||
public string? MachineName { get; set; }
|
public string? MachineName { get; set; }
|
||||||
|
|
||||||
public string? MorningPlanId { get; set; }
|
/// <summary>班次标识:1早班 2中班 3晚班</summary>
|
||||||
public string? MorningPlanType { get; set; }
|
public int? ShiftFlag { get; set; }
|
||||||
public string? MorningOrderNo { get; set; }
|
|
||||||
public DateTime? MorningOrderDate { get; set; }
|
|
||||||
public string? MorningFormulaName { get; set; }
|
|
||||||
|
|
||||||
public string? NoonPlanId { get; set; }
|
/// <summary>计划日期(密炼日期)</summary>
|
||||||
public string? NoonPlanType { get; set; }
|
public DateTime? PlanDate { get; set; }
|
||||||
public string? NoonOrderNo { get; set; }
|
|
||||||
public DateTime? NoonOrderDate { get; set; }
|
|
||||||
public string? NoonFormulaName { get; set; }
|
|
||||||
|
|
||||||
public string? NightPlanId { get; set; }
|
public string? PlanNo { get; set; }
|
||||||
public string? NightPlanType { get; set; }
|
public string? PlanId { get; set; }
|
||||||
public string? NightOrderNo { get; set; }
|
public string? PlanType { get; set; }
|
||||||
public DateTime? NightOrderDate { get; set; }
|
public string? SourceOrderId { get; set; }
|
||||||
public string? NightFormulaName { get; set; }
|
public string? MaterialId { get; set; }
|
||||||
|
public string? MaterialName { get; set; }
|
||||||
|
public string? OrderNo { get; set; }
|
||||||
|
public DateTime? OrderDate { get; set; }
|
||||||
|
public string? FormulaName { get; set; }
|
||||||
|
public double? PlanWeight { get; set; }
|
||||||
|
public int? PlannedCarCount { get; set; }
|
||||||
|
public int? ScheduledCarCount { get; set; }
|
||||||
|
public int? FinishedCarCount { get; set; }
|
||||||
|
/// <summary>计划数量(MES plan_count)</summary>
|
||||||
|
public int? PlanCount { get; set; }
|
||||||
|
public string? Remark { get; set; }
|
||||||
|
public int? TenantId { get; set; }
|
||||||
|
public string? SysOrgCode { get; set; }
|
||||||
|
public string? CreateBy { get; set; }
|
||||||
|
public DateTime? CreateTime { get; set; }
|
||||||
|
public string? UpdateBy { get; set; }
|
||||||
|
public DateTime? UpdateTime { get; set; }
|
||||||
|
public int? DelFlag { get; set; }
|
||||||
|
|
||||||
|
public string ShiftFlagText => ShiftFlag switch
|
||||||
|
{
|
||||||
|
1 => "早班",
|
||||||
|
2 => "中班",
|
||||||
|
3 => "晚班",
|
||||||
|
_ => ShiftFlag?.ToString() ?? string.Empty
|
||||||
|
};
|
||||||
|
|
||||||
|
public string PlanDateText => PlanDate?.ToString("yyyy-MM-dd") ?? string.Empty;
|
||||||
|
|
||||||
|
/// <summary>计划+胶料号:计划号_胶料名称,如 SA0001_HB10001</summary>
|
||||||
|
public string PlanMaterialNo
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var planNo = PlanNo?.Trim();
|
||||||
|
var materialName = MaterialName?.Trim();
|
||||||
|
if (string.IsNullOrEmpty(planNo) && string.IsNullOrEmpty(materialName)) return string.Empty;
|
||||||
|
if (string.IsNullOrEmpty(planNo)) return materialName ?? string.Empty;
|
||||||
|
if (string.IsNullOrEmpty(materialName)) return planNo;
|
||||||
|
return $"{planNo}_{materialName}";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ public class MesXslRubberQuickTestStd
|
|||||||
public string? StdName { get; set; }
|
public string? StdName { get; set; }
|
||||||
public string? TestMethodId { get; set; }
|
public string? TestMethodId { get; set; }
|
||||||
public string? TestMethodName { get; set; }
|
public string? TestMethodName { get; set; }
|
||||||
|
/// <summary>实验类型(来自实验方法,MES 回填)</summary>
|
||||||
|
public string? QuickTestTypeId { get; set; }
|
||||||
|
public string? QuickTestTypeName { get; set; }
|
||||||
public string? MixerType { get; set; }
|
public string? MixerType { get; set; }
|
||||||
public string? RubberMaterialId { get; set; }
|
public string? RubberMaterialId { get; set; }
|
||||||
public string? RubberMaterialName { get; set; }
|
public string? RubberMaterialName { get; set; }
|
||||||
|
|||||||
@@ -0,0 +1,66 @@
|
|||||||
|
namespace YY.Admin.Core.Helper;
|
||||||
|
|
||||||
|
/// <summary>MES 只读数据:远端列表与本地缓存按 Id 对比合并</summary>
|
||||||
|
public static class MesReadOnlyCacheMergeHelper
|
||||||
|
{
|
||||||
|
public sealed record MergeResult(int Added, int Updated, int Removed)
|
||||||
|
{
|
||||||
|
public bool HasChanges => Added > 0 || Updated > 0 || Removed > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 对比远端与本地,返回合并后的列表及变更统计。
|
||||||
|
/// 内容相同则保留本地副本;<paramref name="mergeUpdated"/> 可定制变更行的合并策略(如保留本地子表)。
|
||||||
|
/// </summary>
|
||||||
|
public static (List<T> Merged, MergeResult Stats) Merge<T>(
|
||||||
|
IReadOnlyList<T> local,
|
||||||
|
IReadOnlyList<T> remote,
|
||||||
|
Func<T, string?> getId,
|
||||||
|
Func<T, T, bool> isContentEqual,
|
||||||
|
Func<T, T> clone,
|
||||||
|
Func<T, T, T>? mergeUpdated = null)
|
||||||
|
{
|
||||||
|
var localById = new Dictionary<string, T>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
foreach (var item in local)
|
||||||
|
{
|
||||||
|
var id = getId(item);
|
||||||
|
if (!string.IsNullOrWhiteSpace(id))
|
||||||
|
localById[id] = item;
|
||||||
|
}
|
||||||
|
|
||||||
|
var remoteIds = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
var merged = new List<T>(remote.Count);
|
||||||
|
int added = 0, updated = 0;
|
||||||
|
|
||||||
|
foreach (var remoteItem in remote)
|
||||||
|
{
|
||||||
|
var id = getId(remoteItem);
|
||||||
|
if (string.IsNullOrWhiteSpace(id))
|
||||||
|
{
|
||||||
|
merged.Add(clone(remoteItem));
|
||||||
|
added++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
remoteIds.Add(id);
|
||||||
|
|
||||||
|
if (!localById.TryGetValue(id, out var localItem))
|
||||||
|
{
|
||||||
|
merged.Add(clone(remoteItem));
|
||||||
|
added++;
|
||||||
|
}
|
||||||
|
else if (!isContentEqual(localItem, remoteItem))
|
||||||
|
{
|
||||||
|
merged.Add(mergeUpdated != null ? mergeUpdated(localItem, remoteItem) : clone(remoteItem));
|
||||||
|
updated++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
merged.Add(clone(localItem));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int removed = localById.Keys.Count(id => !remoteIds.Contains(id));
|
||||||
|
return (merged, new MergeResult(added, updated, removed));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -48,10 +48,12 @@ public class SysMenuSeedData : ISqlSugarEntitySeedData<SysMenu>
|
|||||||
new SysMenu{ Id=1300150011001, Pid=1300150000101, Title="库区管理", Path="/xslmes/mesXslWarehouseArea", Name="mesXslWarehouseArea", Component="WarehouseAreaListView", Icon="", Type=MenuTypeEnum.Menu, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=109 },
|
new SysMenu{ Id=1300150011001, Pid=1300150000101, Title="库区管理", Path="/xslmes/mesXslWarehouseArea", Name="mesXslWarehouseArea", Component="WarehouseAreaListView", Icon="", Type=MenuTypeEnum.Menu, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=109 },
|
||||||
// 密炼物料皮重策略
|
// 密炼物料皮重策略
|
||||||
new SysMenu{ Id=1300150011101, Pid=1300150000101, Title="密炼物料皮重策略", Path="/xslmes/mesXslMixerMaterialTareStrategy", Name="mesXslMixerMaterialTareStrategy", Component="MixerMaterialTareStrategyListView", Icon="", Type=MenuTypeEnum.Menu, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=110 },
|
new SysMenu{ Id=1300150011101, Pid=1300150000101, Title="密炼物料皮重策略", Path="/xslmes/mesXslMixerMaterialTareStrategy", Name="mesXslMixerMaterialTareStrategy", Component="MixerMaterialTareStrategyListView", Icon="", Type=MenuTypeEnum.Menu, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=110 },
|
||||||
// 快检记录
|
|
||||||
new SysMenu{ Id=1300150011201, Pid=1300150000101, Title="快检记录", Path="/xslmes/rubberQuickTestOperation", Name="rubberQuickTestOperation", Component="RubberQuickTestOperationView", Icon="", Type=MenuTypeEnum.Menu, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=111 },
|
|
||||||
// 胶料快检实验标准(桌面端只读)
|
// 胶料快检实验标准(桌面端只读)
|
||||||
new SysMenu{ Id=1300150011301, Pid=1300150000101, Title="胶料快检实验标准", Path="/xslmes/mesXslRubberQuickTestStd", Name="mesXslRubberQuickTestStd", Component="RubberQuickTestStdListView", Icon="", Type=MenuTypeEnum.Menu, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=112 },
|
new SysMenu{ Id=1300150011301, Pid=1300150000101, Title="胶料快检实验标准", Path="/xslmes/mesXslRubberQuickTestStd", Name="mesXslRubberQuickTestStd", Component="RubberQuickTestStdListView", Icon="", Type=MenuTypeEnum.Menu, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=112 },
|
||||||
|
// 胶料快检记录(紧接实验标准之后)
|
||||||
|
new SysMenu{ Id=1300150011201, Pid=1300150000101, Title="胶料快检记录", Path="/xslmes/rubberQuickTestOperation", Name="rubberQuickTestOperation", Component="RubberQuickTestOperationView", Icon="", Type=MenuTypeEnum.Menu, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=113 },
|
||||||
|
// 密炼计划
|
||||||
|
new SysMenu{ Id=1300150011401, Pid=1300150000101, Title="密炼计划", Path="/xslmes/mesXslMixingProductionPlan", Name="mesXslMixingProductionPlan", Component="MixingProductionPlanListView", Icon="", Type=MenuTypeEnum.Menu, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=114 },
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ public class SysTenantMenuSeedData : ISqlSugarEntitySeedData<SysTenantMenu>
|
|||||||
new SysTenantMenu(){ TenantId=1300000000001,MenuId=1300150011101},
|
new SysTenantMenu(){ TenantId=1300000000001,MenuId=1300150011101},
|
||||||
new SysTenantMenu(){ TenantId=1300000000001,MenuId=1300150011201},
|
new SysTenantMenu(){ TenantId=1300000000001,MenuId=1300150011201},
|
||||||
new SysTenantMenu(){ TenantId=1300000000001,MenuId=1300150011301},
|
new SysTenantMenu(){ TenantId=1300000000001,MenuId=1300150011301},
|
||||||
|
new SysTenantMenu(){ TenantId=1300000000001,MenuId=1300150011401},
|
||||||
new SysTenantMenu(){ TenantId=1300000000001,MenuId=1300200012101},
|
new SysTenantMenu(){ TenantId=1300000000001,MenuId=1300200012101},
|
||||||
new SysTenantMenu(){ TenantId=1300000000001,MenuId=1300200012111},
|
new SysTenantMenu(){ TenantId=1300000000001,MenuId=1300200012111},
|
||||||
new SysTenantMenu(){ TenantId=1300000000001,MenuId=1300200012121},
|
new SysTenantMenu(){ TenantId=1300000000001,MenuId=1300200012121},
|
||||||
|
|||||||
@@ -270,6 +270,8 @@ namespace YY.Admin.Core.SqlSugar
|
|||||||
EnsureBaselineSysMenuSeed(db, config);
|
EnsureBaselineSysMenuSeed(db, config);
|
||||||
// 旧库升级:按种子补全缺失菜单及租户/角色授权(仅插入缺失项)
|
// 旧库升级:按种子补全缺失菜单及租户/角色授权(仅插入缺失项)
|
||||||
EnsureIncrementalDesktopMenuSeed(db, config);
|
EnsureIncrementalDesktopMenuSeed(db, config);
|
||||||
|
// 旧库升级:胶料快检记录菜单名称与排序
|
||||||
|
EnsureRubberQuickTestRecordMenuPatch(db, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -494,6 +496,43 @@ namespace YY.Admin.Core.SqlSugar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 旧库升级:胶料快检记录改名为「胶料快检记录」,排序置于胶料快检实验标准之后。
|
||||||
|
/// </summary>
|
||||||
|
private static void EnsureRubberQuickTestRecordMenuPatch(SqlSugarScope db, DbConnectionConfig config)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!string.Equals(config.ConfigId.ToString(), SqlSugarConst.MainConfigId, StringComparison.Ordinal))
|
||||||
|
return;
|
||||||
|
if (config.DbType != DbType.Sqlite)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var dbProvider = db.GetConnectionScope(config.ConfigId);
|
||||||
|
var menuEntityInfo = dbProvider.EntityMaintenance.GetEntityInfo(typeof(SysMenu));
|
||||||
|
if (!dbProvider.DbMaintenance.IsAnyTable(menuEntityInfo.DbTableName, false))
|
||||||
|
return;
|
||||||
|
|
||||||
|
const long quickTestRecordMenuId = 1300150011201;
|
||||||
|
const long mixingPlanMenuId = 1300150011401;
|
||||||
|
|
||||||
|
dbProvider.Updateable<SysMenu>()
|
||||||
|
.SetColumns(m => m.Title == "胶料快检记录")
|
||||||
|
.SetColumns(m => m.OrderNo == 113)
|
||||||
|
.Where(m => m.Id == quickTestRecordMenuId)
|
||||||
|
.ExecuteCommand();
|
||||||
|
|
||||||
|
dbProvider.Updateable<SysMenu>()
|
||||||
|
.SetColumns(m => m.OrderNo == 114)
|
||||||
|
.Where(m => m.Id == mixingPlanMenuId)
|
||||||
|
.ExecuteCommand();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// 启动阶段不因菜单补丁失败而阻断
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 兼容旧库:补齐桌面端「登录设置」所需的 sys_config 配置项(升级前库可能缺少这些 code)
|
/// 兼容旧库:补齐桌面端「登录设置」所需的 sys_config 配置项(升级前库可能缺少这些 code)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -0,0 +1,326 @@
|
|||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Prism.Events;
|
||||||
|
using System.IO;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
using System.Web;
|
||||||
|
using YY.Admin.Core;
|
||||||
|
using YY.Admin.Core.Entity;
|
||||||
|
using YY.Admin.Core.Events;
|
||||||
|
using YY.Admin.Core.Helper;
|
||||||
|
using YY.Admin.Core.Services;
|
||||||
|
namespace YY.Admin.Services.Service.MixingProductionPlan;
|
||||||
|
|
||||||
|
/// <summary>密炼生产计划:MES 只读拉取 + 本地缓存,断网读缓存,联网刷新</summary>
|
||||||
|
public class MixingProductionPlanService : IMixingProductionPlanService, ISingletonDependency
|
||||||
|
{
|
||||||
|
private readonly IHttpClientFactory _httpClientFactory;
|
||||||
|
private readonly IConfiguration _configuration;
|
||||||
|
private readonly INetworkMonitor _networkMonitor;
|
||||||
|
private readonly IEventAggregator _eventAggregator;
|
||||||
|
private readonly ILoggerService _logger;
|
||||||
|
private readonly SemaphoreSlim _syncLock = new(1, 1);
|
||||||
|
private readonly object _cacheLock = new();
|
||||||
|
private readonly string _cacheFilePath;
|
||||||
|
private List<MesXslMixingProductionPlan> _localCache = new();
|
||||||
|
|
||||||
|
private static readonly JsonSerializerOptions _jsonOpts = new()
|
||||||
|
{
|
||||||
|
PropertyNameCaseInsensitive = true,
|
||||||
|
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
|
||||||
|
Converters = { new NullableDateTimeJsonConverter() }
|
||||||
|
};
|
||||||
|
|
||||||
|
public MixingProductionPlanService(
|
||||||
|
IHttpClientFactory httpClientFactory,
|
||||||
|
IConfiguration configuration,
|
||||||
|
INetworkMonitor networkMonitor,
|
||||||
|
IEventAggregator eventAggregator,
|
||||||
|
ILoggerService logger)
|
||||||
|
{
|
||||||
|
_httpClientFactory = httpClientFactory;
|
||||||
|
_configuration = configuration;
|
||||||
|
_networkMonitor = networkMonitor;
|
||||||
|
_eventAggregator = eventAggregator;
|
||||||
|
_logger = logger;
|
||||||
|
|
||||||
|
var appDataDir = Path.Combine(
|
||||||
|
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
|
||||||
|
"YY.Admin", "sync-cache");
|
||||||
|
Directory.CreateDirectory(appDataDir);
|
||||||
|
_cacheFilePath = Path.Combine(appDataDir, "mes-xsl-mixing-production-plan-cache.json");
|
||||||
|
|
||||||
|
LoadCacheFromDisk();
|
||||||
|
_logger.Information($"[密炼计划] 服务初始化,缓存={_localCache.Count},在线={_networkMonitor.IsOnline}");
|
||||||
|
|
||||||
|
_networkMonitor.StatusChanged += OnNetworkStatusChanged;
|
||||||
|
if (_networkMonitor.IsOnline)
|
||||||
|
_ = Task.Run(() => SyncFromRemoteAsync(CancellationToken.None));
|
||||||
|
}
|
||||||
|
|
||||||
|
private string BaseUrl => (_configuration.GetValue<string>("JeecgIntegration:BaseUrl") ?? "http://localhost:8080/jeecg-boot").TrimEnd('/');
|
||||||
|
private int DefaultTenantId => (int?)_configuration.GetValue<long?>("JeecgIntegration:DefaultTenantId") ?? 1002;
|
||||||
|
private HttpClient CreateClient() => _httpClientFactory.CreateClient("JeecgApi");
|
||||||
|
|
||||||
|
public async Task<MixingProductionPlanPageResult> PageAsync(
|
||||||
|
int pageNo, int pageSize,
|
||||||
|
DateTime? planDateFrom = null,
|
||||||
|
DateTime? planDateTo = null,
|
||||||
|
string? machineName = null,
|
||||||
|
int? shiftFlag = null,
|
||||||
|
string? planNo = null,
|
||||||
|
string? materialName = null,
|
||||||
|
CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
if (_networkMonitor.IsOnline)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await SyncFromRemoteAsync(ct).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.Warning($"[密炼计划] 列表拉取失败,使用本地缓存:{ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<MesXslMixingProductionPlan> source;
|
||||||
|
lock (_cacheLock)
|
||||||
|
source = _localCache.Select(Clone).ToList();
|
||||||
|
|
||||||
|
var filtered = ApplyFilters(source, planDateFrom, planDateTo, machineName, shiftFlag, planNo, materialName);
|
||||||
|
var total = filtered.Count;
|
||||||
|
var records = filtered
|
||||||
|
.Skip(Math.Max(0, (pageNo - 1) * pageSize))
|
||||||
|
.Take(pageSize)
|
||||||
|
.ToList();
|
||||||
|
return new MixingProductionPlanPageResult(records, total, pageNo, pageSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<MesXslMixingProductionPlan>> GetAllCachedAsync(CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
if (_networkMonitor.IsOnline)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await SyncFromRemoteAsync(ct).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.Warning($"[密炼计划] 全量拉取失败,使用本地缓存:{ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lock (_cacheLock)
|
||||||
|
return _localCache.Select(Clone).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> SyncFromRemoteAsync(CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
await _syncLock.WaitAsync(ct).ConfigureAwait(false);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!_networkMonitor.IsOnline)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
var all = new List<MesXslMixingProductionPlan>();
|
||||||
|
int pageNo = 1;
|
||||||
|
const int pageSize = 500;
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
var query = HttpUtility.ParseQueryString(string.Empty);
|
||||||
|
query["pageNo"] = pageNo.ToString();
|
||||||
|
query["pageSize"] = pageSize.ToString();
|
||||||
|
query["tenantId"] = DefaultTenantId.ToString();
|
||||||
|
var url = $"{BaseUrl}/xslmes/mesXslMixingProductionPlan/anon/list?{query}";
|
||||||
|
|
||||||
|
using var client = CreateClient();
|
||||||
|
var resp = await client.GetAsync(url, ct).ConfigureAwait(false);
|
||||||
|
resp.EnsureSuccessStatusCode();
|
||||||
|
|
||||||
|
var json = await resp.Content.ReadAsStringAsync(ct).ConfigureAwait(false);
|
||||||
|
using var doc = JsonDocument.Parse(json);
|
||||||
|
if (!doc.RootElement.TryGetProperty("result", out var resultEl)) break;
|
||||||
|
|
||||||
|
var page = resultEl.GetProperty("records")
|
||||||
|
.Deserialize<List<MesXslMixingProductionPlan>>(_jsonOpts) ?? new();
|
||||||
|
all.AddRange(page);
|
||||||
|
|
||||||
|
long total = 0;
|
||||||
|
if (resultEl.TryGetProperty("total", out var totalEl)) total = totalEl.GetInt64();
|
||||||
|
if (all.Count >= total || page.Count < pageSize) break;
|
||||||
|
pageNo++;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<MesXslMixingProductionPlan> localSnapshot;
|
||||||
|
lock (_cacheLock)
|
||||||
|
localSnapshot = _localCache.Select(Clone).ToList();
|
||||||
|
|
||||||
|
var (merged, stats) = MesReadOnlyCacheMergeHelper.Merge(
|
||||||
|
localSnapshot,
|
||||||
|
all,
|
||||||
|
x => x.Id,
|
||||||
|
IsPlanContentEqual,
|
||||||
|
Clone);
|
||||||
|
|
||||||
|
if (!stats.HasChanges)
|
||||||
|
{
|
||||||
|
_logger.Information($"[密炼计划] 与 MES 对比无差异,跳过更新 count={merged.Count}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
lock (_cacheLock)
|
||||||
|
{
|
||||||
|
_localCache = merged;
|
||||||
|
SaveCacheToDiskUnsafe();
|
||||||
|
}
|
||||||
|
_logger.Information(
|
||||||
|
$"[密炼计划] 差异同步完成 total={merged.Count} 新增={stats.Added} 变更={stats.Updated} 删除={stats.Removed}");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.Warning($"[密炼计划] 远程同步失败:{ex.Message}");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_syncLock.Release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnNetworkStatusChanged(bool isOnline)
|
||||||
|
{
|
||||||
|
if (!isOnline) return;
|
||||||
|
_ = Task.Run(async () =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!await SyncFromRemoteAsync(CancellationToken.None).ConfigureAwait(false))
|
||||||
|
return;
|
||||||
|
_eventAggregator.GetEvent<MixingProductionPlanChangedEvent>()
|
||||||
|
.Publish(new MixingProductionPlanChangedPayload { Action = "reconnect" });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.Warning($"[密炼计划] 重连同步失败:{ex.Message}");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool IsPlanContentEqual(MesXslMixingProductionPlan a, MesXslMixingProductionPlan b) =>
|
||||||
|
string.Equals(GetPlanFingerprint(a), GetPlanFingerprint(b), StringComparison.Ordinal);
|
||||||
|
|
||||||
|
private static string GetPlanFingerprint(MesXslMixingProductionPlan x) =>
|
||||||
|
JsonSerializer.Serialize(Clone(x), _jsonOpts);
|
||||||
|
private static List<MesXslMixingProductionPlan> ApplyFilters(
|
||||||
|
List<MesXslMixingProductionPlan> source,
|
||||||
|
DateTime? planDateFrom,
|
||||||
|
DateTime? planDateTo,
|
||||||
|
string? machineName,
|
||||||
|
int? shiftFlag,
|
||||||
|
string? planNo,
|
||||||
|
string? materialName)
|
||||||
|
{
|
||||||
|
IEnumerable<MesXslMixingProductionPlan> q = source;
|
||||||
|
if (planDateFrom.HasValue)
|
||||||
|
q = q.Where(x => x.PlanDate?.Date >= planDateFrom.Value.Date);
|
||||||
|
if (planDateTo.HasValue)
|
||||||
|
q = q.Where(x => x.PlanDate?.Date <= planDateTo.Value.Date);
|
||||||
|
if (!string.IsNullOrWhiteSpace(machineName))
|
||||||
|
q = q.Where(x => (x.MachineName ?? "").Contains(machineName.Trim(), StringComparison.OrdinalIgnoreCase));
|
||||||
|
if (shiftFlag.HasValue && shiftFlag.Value > 0)
|
||||||
|
q = q.Where(x => x.ShiftFlag == shiftFlag.Value);
|
||||||
|
if (!string.IsNullOrWhiteSpace(planNo))
|
||||||
|
q = q.Where(x => (x.PlanNo ?? "").Contains(planNo.Trim(), StringComparison.OrdinalIgnoreCase));
|
||||||
|
if (!string.IsNullOrWhiteSpace(materialName))
|
||||||
|
q = q.Where(x => (x.MaterialName ?? "").Contains(materialName.Trim(), StringComparison.OrdinalIgnoreCase));
|
||||||
|
|
||||||
|
return q
|
||||||
|
.OrderByDescending(x => x.PlanDate ?? DateTime.MinValue)
|
||||||
|
.ThenBy(x => x.SortNo ?? int.MaxValue)
|
||||||
|
.ThenBy(x => x.MachineName)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadCacheFromDisk()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!File.Exists(_cacheFilePath)) return;
|
||||||
|
_localCache = JsonSerializer.Deserialize<List<MesXslMixingProductionPlan>>(
|
||||||
|
File.ReadAllText(_cacheFilePath), _jsonOpts) ?? new();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
_localCache = new();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveCacheToDiskUnsafe() =>
|
||||||
|
File.WriteAllText(_cacheFilePath, JsonSerializer.Serialize(_localCache, _jsonOpts));
|
||||||
|
|
||||||
|
private static MesXslMixingProductionPlan Clone(MesXslMixingProductionPlan x) => new()
|
||||||
|
{
|
||||||
|
Id = x.Id,
|
||||||
|
SortNo = x.SortNo,
|
||||||
|
MachineId = x.MachineId,
|
||||||
|
MachineName = x.MachineName,
|
||||||
|
ShiftFlag = x.ShiftFlag,
|
||||||
|
PlanDate = x.PlanDate,
|
||||||
|
PlanNo = x.PlanNo,
|
||||||
|
PlanId = x.PlanId,
|
||||||
|
PlanType = x.PlanType,
|
||||||
|
SourceOrderId = x.SourceOrderId,
|
||||||
|
MaterialId = x.MaterialId,
|
||||||
|
MaterialName = x.MaterialName,
|
||||||
|
OrderNo = x.OrderNo,
|
||||||
|
OrderDate = x.OrderDate,
|
||||||
|
FormulaName = x.FormulaName,
|
||||||
|
PlanWeight = x.PlanWeight,
|
||||||
|
PlannedCarCount = x.PlannedCarCount,
|
||||||
|
ScheduledCarCount = x.ScheduledCarCount,
|
||||||
|
FinishedCarCount = x.FinishedCarCount,
|
||||||
|
PlanCount = x.PlanCount,
|
||||||
|
Remark = x.Remark,
|
||||||
|
TenantId = x.TenantId,
|
||||||
|
SysOrgCode = x.SysOrgCode,
|
||||||
|
CreateBy = x.CreateBy,
|
||||||
|
CreateTime = x.CreateTime,
|
||||||
|
UpdateBy = x.UpdateBy,
|
||||||
|
UpdateTime = x.UpdateTime,
|
||||||
|
DelFlag = x.DelFlag
|
||||||
|
};
|
||||||
|
|
||||||
|
private sealed class NullableDateTimeJsonConverter : JsonConverter<DateTime?>
|
||||||
|
{
|
||||||
|
private static readonly string[] Formats =
|
||||||
|
[
|
||||||
|
"yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm:ss.fff",
|
||||||
|
"yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mm:ss.fff",
|
||||||
|
"yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ss.fffZ",
|
||||||
|
"yyyy-MM-dd"
|
||||||
|
];
|
||||||
|
|
||||||
|
public override DateTime? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||||
|
{
|
||||||
|
if (reader.TokenType == JsonTokenType.Null) return null;
|
||||||
|
if (reader.TokenType == JsonTokenType.String)
|
||||||
|
{
|
||||||
|
var raw = reader.GetString();
|
||||||
|
if (string.IsNullOrWhiteSpace(raw)) return null;
|
||||||
|
if (DateTime.TryParseExact(raw, Formats, System.Globalization.CultureInfo.InvariantCulture,
|
||||||
|
System.Globalization.DateTimeStyles.AssumeLocal, out var dt)) return dt;
|
||||||
|
if (DateTime.TryParse(raw, out var fb)) return fb;
|
||||||
|
}
|
||||||
|
throw new JsonException($"无法转换为 DateTime?,token={reader.TokenType}");
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Write(Utf8JsonWriter writer, DateTime? value, JsonSerializerOptions options)
|
||||||
|
{
|
||||||
|
if (value.HasValue) writer.WriteStringValue(value.Value.ToString("yyyy-MM-dd HH:mm:ss"));
|
||||||
|
else writer.WriteNullValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
using Prism.Events;
|
||||||
|
using System.Text.Json;
|
||||||
|
using YY.Admin.Core;
|
||||||
|
using YY.Admin.Core.Events;
|
||||||
|
using YY.Admin.Core.Services;
|
||||||
|
|
||||||
|
namespace YY.Admin.Services.Service.MixingProductionPlan;
|
||||||
|
|
||||||
|
public class MixingProductionPlanSyncCoordinator : ISingletonDependency
|
||||||
|
{
|
||||||
|
private readonly IEventAggregator _eventAggregator;
|
||||||
|
private readonly ILoggerService _logger;
|
||||||
|
|
||||||
|
public MixingProductionPlanSyncCoordinator(
|
||||||
|
IEventAggregator eventAggregator,
|
||||||
|
SyncPollManager pollManager,
|
||||||
|
ILoggerService logger)
|
||||||
|
{
|
||||||
|
_eventAggregator = eventAggregator;
|
||||||
|
_logger = logger;
|
||||||
|
|
||||||
|
_eventAggregator.GetEvent<RemoteCommandReceivedEvent>()
|
||||||
|
.Subscribe(OnRemoteCommand, ThreadOption.BackgroundThread);
|
||||||
|
|
||||||
|
pollManager.Register("密炼计划", () =>
|
||||||
|
{
|
||||||
|
_eventAggregator.GetEvent<MixingProductionPlanChangedEvent>()
|
||||||
|
.Publish(new MixingProductionPlanChangedPayload { Action = "poll" });
|
||||||
|
return Task.CompletedTask;
|
||||||
|
});
|
||||||
|
|
||||||
|
_logger.Information("[密炼计划] MixingProductionPlanSyncCoordinator 已启动");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnRemoteCommand(RemoteCommandPayload payload)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var json = payload.CommandJson ?? string.Empty;
|
||||||
|
if (string.IsNullOrWhiteSpace(json)) return;
|
||||||
|
|
||||||
|
using var doc = JsonDocument.Parse(json);
|
||||||
|
if (!doc.RootElement.TryGetProperty("cmd", out var cmdEl)) return;
|
||||||
|
if (!cmdEl.GetString()?.Equals("MIXING_PRODUCTION_PLAN_CHANGED", StringComparison.OrdinalIgnoreCase) ?? true)
|
||||||
|
return;
|
||||||
|
|
||||||
|
doc.RootElement.TryGetProperty("action", out var actionEl);
|
||||||
|
doc.RootElement.TryGetProperty("mixingProductionPlanId", out var idEl);
|
||||||
|
|
||||||
|
var changed = new MixingProductionPlanChangedPayload
|
||||||
|
{
|
||||||
|
Action = actionEl.GetString() ?? string.Empty,
|
||||||
|
MixingProductionPlanId = idEl.ValueKind == JsonValueKind.String ? idEl.GetString() : null
|
||||||
|
};
|
||||||
|
_logger.Information($"[密炼计划] STOMP action={changed.Action}, id={changed.MixingProductionPlanId}");
|
||||||
|
_eventAggregator.GetEvent<MixingProductionPlanChangedEvent>().Publish(changed);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.Warning($"[密炼计划] 处理 STOMP 命令失败:{ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -36,68 +36,11 @@ public class RubberQuickTestOperationService : IRubberQuickTestOperationService,
|
|||||||
}
|
}
|
||||||
|
|
||||||
private string BaseUrl => (_configuration.GetValue<string>("JeecgIntegration:BaseUrl") ?? "http://localhost:8080/jeecg-boot").TrimEnd('/');
|
private string BaseUrl => (_configuration.GetValue<string>("JeecgIntegration:BaseUrl") ?? "http://localhost:8080/jeecg-boot").TrimEnd('/');
|
||||||
private int DefaultTenantId => (int?)_configuration.GetValue<long?>("JeecgIntegration:DefaultTenantId") ?? 1002;
|
|
||||||
|
|
||||||
public async Task<List<MesXslMixingProductionPlan>> GetMixingProductionPlansAsync(CancellationToken ct = default)
|
|
||||||
{
|
|
||||||
if (!_networkMonitor.IsOnline)
|
|
||||||
throw new InvalidOperationException("网络未连接,无法加载密炼生产计划");
|
|
||||||
|
|
||||||
var result = new List<MesXslMixingProductionPlan>();
|
|
||||||
int pageNo = 1;
|
|
||||||
const int pageSize = 500;
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
var url = $"{BaseUrl}/xslmes/mesXslMixingProductionPlan/anon/list?pageNo={pageNo}&pageSize={pageSize}&tenantId={DefaultTenantId}";
|
|
||||||
using var client = _httpClientFactory.CreateClient("JeecgApi");
|
|
||||||
var resp = await client.GetAsync(url, ct).ConfigureAwait(false);
|
|
||||||
resp.EnsureSuccessStatusCode();
|
|
||||||
var json = await resp.Content.ReadAsStringAsync(ct).ConfigureAwait(false);
|
|
||||||
using var doc = JsonDocument.Parse(json);
|
|
||||||
if (!doc.RootElement.TryGetProperty("result", out var resultEl)) break;
|
|
||||||
if (resultEl.TryGetProperty("records", out var recordsEl))
|
|
||||||
{
|
|
||||||
var page = recordsEl.Deserialize<List<MesXslMixingProductionPlan>>(_jsonOpts);
|
|
||||||
if (page != null) result.AddRange(page);
|
|
||||||
}
|
|
||||||
long total = 0;
|
|
||||||
if (resultEl.TryGetProperty("total", out var totalEl)) total = totalEl.GetInt64();
|
|
||||||
if (result.Count >= total || (resultEl.TryGetProperty("records", out var r2) && r2.GetArrayLength() < pageSize)) break;
|
|
||||||
pageNo++;
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.Information($"[快检记录] 加载密炼生产计划 {result.Count} 条");
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<MesXslRubberQuickTestStd?> GetStdByRubberMaterialNameAsync(string rubberMaterialName, CancellationToken ct = default)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrWhiteSpace(rubberMaterialName))
|
|
||||||
return null;
|
|
||||||
if (!_networkMonitor.IsOnline)
|
|
||||||
throw new InvalidOperationException("网络未连接,无法加载实验标准");
|
|
||||||
|
|
||||||
var encoded = Uri.EscapeDataString(rubberMaterialName.Trim());
|
|
||||||
var url = $"{BaseUrl}/xslmes/mesXslRubberQuickTestStd/anon/queryByRubberMaterialName?rubberMaterialName={encoded}";
|
|
||||||
using var client = _httpClientFactory.CreateClient("JeecgApi");
|
|
||||||
var resp = await client.GetAsync(url, ct).ConfigureAwait(false);
|
|
||||||
var json = await resp.Content.ReadAsStringAsync(ct).ConfigureAwait(false);
|
|
||||||
using var doc = JsonDocument.Parse(json);
|
|
||||||
if (!doc.RootElement.TryGetProperty("success", out var successEl) || !successEl.GetBoolean())
|
|
||||||
{
|
|
||||||
var msg = doc.RootElement.TryGetProperty("message", out var msgEl) ? msgEl.GetString() : "查询实验标准失败";
|
|
||||||
_logger.Warning($"[快检记录] 实验标准查询失败: {msg}");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (!doc.RootElement.TryGetProperty("result", out var resultEl) || resultEl.ValueKind == JsonValueKind.Null)
|
|
||||||
return null;
|
|
||||||
return resultEl.Deserialize<MesXslRubberQuickTestStd>(_jsonOpts);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<string?> SaveRecordAsync(MesXslRubberQuickTestRecord record, CancellationToken ct = default)
|
public async Task<string?> SaveRecordAsync(MesXslRubberQuickTestRecord record, CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
if (!_networkMonitor.IsOnline)
|
if (!_networkMonitor.IsOnline)
|
||||||
throw new InvalidOperationException("网络未连接,无法保存快检记录");
|
throw new InvalidOperationException("网络未连接,无法保存胶料快检记录");
|
||||||
|
|
||||||
var url = $"{BaseUrl}/xslmes/mesXslRubberQuickTestRecord/anon/add";
|
var url = $"{BaseUrl}/xslmes/mesXslRubberQuickTestRecord/anon/add";
|
||||||
using var client = _httpClientFactory.CreateClient("JeecgApi");
|
using var client = _httpClientFactory.CreateClient("JeecgApi");
|
||||||
@@ -111,7 +54,19 @@ public class RubberQuickTestOperationService : IRubberQuickTestOperationService,
|
|||||||
var msg = doc.RootElement.TryGetProperty("message", out var msgEl) ? msgEl.GetString() : "保存失败";
|
var msg = doc.RootElement.TryGetProperty("message", out var msgEl) ? msgEl.GetString() : "保存失败";
|
||||||
throw new InvalidOperationException(msg ?? "保存失败");
|
throw new InvalidOperationException(msg ?? "保存失败");
|
||||||
}
|
}
|
||||||
_logger.Information($"[快检记录] 保存成功 recordNo={record.RecordNo}");
|
|
||||||
return doc.RootElement.TryGetProperty("message", out var m) ? m.GetString() : "保存成功";
|
string? recordNo = null;
|
||||||
|
if (doc.RootElement.TryGetProperty("result", out var resultEl))
|
||||||
|
{
|
||||||
|
if (resultEl.ValueKind == JsonValueKind.String)
|
||||||
|
recordNo = resultEl.GetString();
|
||||||
|
else if (resultEl.ValueKind == JsonValueKind.Object
|
||||||
|
&& resultEl.TryGetProperty("recordNo", out var noEl))
|
||||||
|
recordNo = noEl.GetString();
|
||||||
|
}
|
||||||
|
recordNo ??= record.RecordNo;
|
||||||
|
record.RecordNo = recordNo;
|
||||||
|
_logger.Information($"[胶料快检记录] 保存成功 recordNo={recordNo}");
|
||||||
|
return recordNo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ using System.Web;
|
|||||||
using YY.Admin.Core;
|
using YY.Admin.Core;
|
||||||
using YY.Admin.Core.Entity;
|
using YY.Admin.Core.Entity;
|
||||||
using YY.Admin.Core.Events;
|
using YY.Admin.Core.Events;
|
||||||
|
using YY.Admin.Core.Helper;
|
||||||
using YY.Admin.Core.Services;
|
using YY.Admin.Core.Services;
|
||||||
|
|
||||||
namespace YY.Admin.Services.Service.RubberQuickTestStd;
|
namespace YY.Admin.Services.Service.RubberQuickTestStd;
|
||||||
@@ -115,7 +116,7 @@ public class RubberQuickTestStdService : IRubberQuickTestStdService, ISingletonD
|
|||||||
var entity = resultEl.Deserialize<MesXslRubberQuickTestStd>(_jsonOpts);
|
var entity = resultEl.Deserialize<MesXslRubberQuickTestStd>(_jsonOpts);
|
||||||
if (entity != null)
|
if (entity != null)
|
||||||
{
|
{
|
||||||
UpsertLocalCacheMain(entity);
|
UpsertIfChanged(entity);
|
||||||
return CloneMain(entity);
|
return CloneMain(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -134,14 +135,50 @@ public class RubberQuickTestStdService : IRubberQuickTestStdService, ISingletonD
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task SyncFromRemoteAsync(CancellationToken ct = default)
|
public Task<List<MesXslRubberQuickTestStd>> GetAllCachedAsync(CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
ct.ThrowIfCancellationRequested();
|
||||||
|
lock (_cacheLock)
|
||||||
|
return Task.FromResult(_localCache.Select(CloneMain).ToList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<MesXslRubberQuickTestStd?> GetCachedByIdAsync(string id, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
ct.ThrowIfCancellationRequested();
|
||||||
|
if (string.IsNullOrWhiteSpace(id)) return Task.FromResult<MesXslRubberQuickTestStd?>(null);
|
||||||
|
lock (_cacheLock)
|
||||||
|
{
|
||||||
|
var found = _localCache.FirstOrDefault(x => string.Equals(x.Id, id, StringComparison.OrdinalIgnoreCase));
|
||||||
|
return Task.FromResult(found != null ? CloneMain(found) : null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<MesXslRubberQuickTestStd?> GetWithLinesAsync(string id, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(id)) return null;
|
||||||
|
|
||||||
|
var cached = await GetCachedByIdAsync(id, ct).ConfigureAwait(false);
|
||||||
|
if (cached?.LineList is { Count: > 0 })
|
||||||
|
return cached;
|
||||||
|
|
||||||
|
if (_networkMonitor.IsOnline)
|
||||||
|
{
|
||||||
|
var detail = await GetByIdAsync(id, ct).ConfigureAwait(false);
|
||||||
|
if (detail != null)
|
||||||
|
return detail;
|
||||||
|
}
|
||||||
|
|
||||||
|
return cached;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> SyncFromRemoteAsync(CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
await _syncLock.WaitAsync(ct).ConfigureAwait(false);
|
await _syncLock.WaitAsync(ct).ConfigureAwait(false);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!_networkMonitor.IsOnline)
|
if (!_networkMonitor.IsOnline)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
var query = HttpUtility.ParseQueryString(string.Empty);
|
var query = HttpUtility.ParseQueryString(string.Empty);
|
||||||
query["pageNo"] = "1";
|
query["pageNo"] = "1";
|
||||||
@@ -158,16 +195,37 @@ public class RubberQuickTestStdService : IRubberQuickTestStdService, ISingletonD
|
|||||||
var records = doc.RootElement.GetProperty("result").GetProperty("records")
|
var records = doc.RootElement.GetProperty("result").GetProperty("records")
|
||||||
.Deserialize<List<MesXslRubberQuickTestStd>>(_jsonOpts) ?? new();
|
.Deserialize<List<MesXslRubberQuickTestStd>>(_jsonOpts) ?? new();
|
||||||
|
|
||||||
|
List<MesXslRubberQuickTestStd> localSnapshot;
|
||||||
|
lock (_cacheLock)
|
||||||
|
localSnapshot = _localCache.Select(CloneMain).ToList();
|
||||||
|
|
||||||
|
var (merged, stats) = MesReadOnlyCacheMergeHelper.Merge(
|
||||||
|
localSnapshot,
|
||||||
|
records,
|
||||||
|
x => x.Id,
|
||||||
|
IsStdListContentEqual,
|
||||||
|
CloneMain,
|
||||||
|
MergeStdUpdated);
|
||||||
|
|
||||||
|
if (!stats.HasChanges)
|
||||||
|
{
|
||||||
|
_logger.Information($"[快检实验标准] 与 MES 对比无差异,跳过更新 count={merged.Count}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
lock (_cacheLock)
|
lock (_cacheLock)
|
||||||
{
|
{
|
||||||
_localCache = records.Select(CloneMain).ToList();
|
_localCache = merged;
|
||||||
SaveCacheToDiskUnsafe();
|
SaveCacheToDiskUnsafe();
|
||||||
}
|
}
|
||||||
_logger.Information($"[快检实验标准] 同步完成 count={records.Count}");
|
_logger.Information(
|
||||||
|
$"[快检实验标准] 差异同步完成 total={merged.Count} 新增={stats.Added} 变更={stats.Updated} 删除={stats.Removed}");
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Warning($"[快检实验标准] 远程同步失败:{ex.Message}");
|
_logger.Warning($"[快检实验标准] 远程同步失败:{ex.Message}");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -180,7 +238,8 @@ public class RubberQuickTestStdService : IRubberQuickTestStdService, ISingletonD
|
|||||||
if (!isOnline) return;
|
if (!isOnline) return;
|
||||||
_ = Task.Run(async () =>
|
_ = Task.Run(async () =>
|
||||||
{
|
{
|
||||||
await SyncFromRemoteAsync(CancellationToken.None).ConfigureAwait(false);
|
if (!await SyncFromRemoteAsync(CancellationToken.None).ConfigureAwait(false))
|
||||||
|
return;
|
||||||
_eventAggregator.GetEvent<RubberQuickTestStdChangedEvent>()
|
_eventAggregator.GetEvent<RubberQuickTestStdChangedEvent>()
|
||||||
.Publish(new RubberQuickTestStdChangedPayload { Action = "reconnect" });
|
.Publish(new RubberQuickTestStdChangedPayload { Action = "reconnect" });
|
||||||
});
|
});
|
||||||
@@ -202,19 +261,67 @@ public class RubberQuickTestStdService : IRubberQuickTestStdService, ISingletonD
|
|||||||
return q.OrderByDescending(x => x.CreateTime ?? DateTime.MinValue).ToList();
|
return q.OrderByDescending(x => x.CreateTime ?? DateTime.MinValue).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpsertLocalCacheMain(MesXslRubberQuickTestStd entity)
|
private bool UpsertIfChanged(MesXslRubberQuickTestStd entity)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(entity.Id)) return;
|
if (string.IsNullOrWhiteSpace(entity.Id)) return false;
|
||||||
lock (_cacheLock)
|
lock (_cacheLock)
|
||||||
{
|
{
|
||||||
var idx = _localCache.FindIndex(x => string.Equals(x.Id, entity.Id, StringComparison.OrdinalIgnoreCase));
|
var idx = _localCache.FindIndex(x => string.Equals(x.Id, entity.Id, StringComparison.OrdinalIgnoreCase));
|
||||||
var copy = CloneMain(entity);
|
if (idx >= 0)
|
||||||
if (idx >= 0) _localCache[idx] = copy;
|
{
|
||||||
else _localCache.Insert(0, copy);
|
if (IsStdDetailContentEqual(_localCache[idx], entity))
|
||||||
|
return false;
|
||||||
|
_localCache[idx] = CloneMain(entity);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_localCache.Insert(0, CloneMain(entity));
|
||||||
|
}
|
||||||
SaveCacheToDiskUnsafe();
|
SaveCacheToDiskUnsafe();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool IsStdListContentEqual(MesXslRubberQuickTestStd a, MesXslRubberQuickTestStd b) =>
|
||||||
|
string.Equals(GetStdListFingerprint(a), GetStdListFingerprint(b), StringComparison.Ordinal);
|
||||||
|
|
||||||
|
private static bool IsStdDetailContentEqual(MesXslRubberQuickTestStd a, MesXslRubberQuickTestStd b) =>
|
||||||
|
string.Equals(GetStdDetailFingerprint(a), GetStdDetailFingerprint(b), StringComparison.Ordinal);
|
||||||
|
|
||||||
|
private static string GetStdListFingerprint(MesXslRubberQuickTestStd x)
|
||||||
|
{
|
||||||
|
var snap = CloneMain(x);
|
||||||
|
snap.LineList = null;
|
||||||
|
return JsonSerializer.Serialize(snap, _jsonOpts);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetStdDetailFingerprint(MesXslRubberQuickTestStd x) =>
|
||||||
|
JsonSerializer.Serialize(CloneMain(x), _jsonOpts);
|
||||||
|
|
||||||
|
private static MesXslRubberQuickTestStd MergeStdUpdated(MesXslRubberQuickTestStd local, MesXslRubberQuickTestStd remote)
|
||||||
|
{
|
||||||
|
var copy = CloneMain(remote);
|
||||||
|
if ((copy.LineList == null || copy.LineList.Count == 0) && local.LineList is { Count: > 0 })
|
||||||
|
{
|
||||||
|
copy.LineList = local.LineList.Select(l => new MesXslRubberQuickTestStdLine
|
||||||
|
{
|
||||||
|
Id = l.Id,
|
||||||
|
StdId = l.StdId,
|
||||||
|
DataPointId = l.DataPointId,
|
||||||
|
PointName = l.PointName,
|
||||||
|
LowerLimit = l.LowerLimit,
|
||||||
|
UpperLimit = l.UpperLimit,
|
||||||
|
LowerWarn = l.LowerWarn,
|
||||||
|
UpperWarn = l.UpperWarn,
|
||||||
|
TargetValue = l.TargetValue,
|
||||||
|
SortNo = l.SortNo
|
||||||
|
}).ToList();
|
||||||
|
}
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpsertLocalCacheMain(MesXslRubberQuickTestStd entity) => UpsertIfChanged(entity);
|
||||||
|
|
||||||
private void LoadCacheFromDisk()
|
private void LoadCacheFromDisk()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -238,6 +345,8 @@ public class RubberQuickTestStdService : IRubberQuickTestStdService, ISingletonD
|
|||||||
StdName = x.StdName,
|
StdName = x.StdName,
|
||||||
TestMethodId = x.TestMethodId,
|
TestMethodId = x.TestMethodId,
|
||||||
TestMethodName = x.TestMethodName,
|
TestMethodName = x.TestMethodName,
|
||||||
|
QuickTestTypeId = x.QuickTestTypeId,
|
||||||
|
QuickTestTypeName = x.QuickTestTypeName,
|
||||||
MixerType = x.MixerType,
|
MixerType = x.MixerType,
|
||||||
RubberMaterialId = x.RubberMaterialId,
|
RubberMaterialId = x.RubberMaterialId,
|
||||||
RubberMaterialName = x.RubberMaterialName,
|
RubberMaterialName = x.RubberMaterialName,
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ using Prism.Events;
|
|||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using YY.Admin.Core;
|
using YY.Admin.Core;
|
||||||
using YY.Admin.Core.Events;
|
using YY.Admin.Core.Events;
|
||||||
using YY.Admin.Core.Events;
|
|
||||||
|
|
||||||
namespace YY.Admin.Services.Service.RubberQuickTestStd;
|
namespace YY.Admin.Services.Service.RubberQuickTestStd;
|
||||||
|
|
||||||
@@ -21,8 +20,6 @@ public class RubberQuickTestStdSyncCoordinator : ISingletonDependency
|
|||||||
|
|
||||||
_eventAggregator.GetEvent<RemoteCommandReceivedEvent>()
|
_eventAggregator.GetEvent<RemoteCommandReceivedEvent>()
|
||||||
.Subscribe(OnRemoteCommand, ThreadOption.BackgroundThread);
|
.Subscribe(OnRemoteCommand, ThreadOption.BackgroundThread);
|
||||||
_eventAggregator.GetEvent<NetworkStatusChangedEvent>()
|
|
||||||
.Subscribe(OnNetworkStatusChanged, ThreadOption.BackgroundThread);
|
|
||||||
|
|
||||||
pollManager.Register("胶料快检实验标准", () =>
|
pollManager.Register("胶料快检实验标准", () =>
|
||||||
{
|
{
|
||||||
@@ -34,14 +31,6 @@ public class RubberQuickTestStdSyncCoordinator : ISingletonDependency
|
|||||||
_logger.Information("[快检实验标准] RubberQuickTestStdSyncCoordinator 已启动");
|
_logger.Information("[快检实验标准] RubberQuickTestStdSyncCoordinator 已启动");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnNetworkStatusChanged(NetworkStatusChangedPayload payload)
|
|
||||||
{
|
|
||||||
if (!payload.IsOnline) return;
|
|
||||||
_logger.Information("[快检实验标准] 网络恢复,触发补偿刷新");
|
|
||||||
_eventAggregator.GetEvent<RubberQuickTestStdChangedEvent>()
|
|
||||||
.Publish(new RubberQuickTestStdChangedPayload { Action = "reconnect" });
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnRemoteCommand(RemoteCommandPayload payload)
|
private void OnRemoteCommand(RemoteCommandPayload payload)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -178,6 +178,10 @@ public class StompWebSocketService : ISignalRService
|
|||||||
await SendFrameAsync(
|
await SendFrameAsync(
|
||||||
BuildSubscribeFrame("sub-mes-rubber-quick-test-stds", "/topic/sync/mes-rubber-quick-test-stds"),
|
BuildSubscribeFrame("sub-mes-rubber-quick-test-stds", "/topic/sync/mes-rubber-quick-test-stds"),
|
||||||
cancellationToken).ConfigureAwait(false);
|
cancellationToken).ConfigureAwait(false);
|
||||||
|
// 密炼生产计划变更:订阅 /topic/sync/mes-mixing-production-plans
|
||||||
|
await SendFrameAsync(
|
||||||
|
BuildSubscribeFrame("sub-mes-xsl-mixing-production-plan", "/topic/sync/mes-mixing-production-plans"),
|
||||||
|
cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
// 订阅服务端 PONG 回复(应用层假在线检测)
|
// 订阅服务端 PONG 回复(应用层假在线检测)
|
||||||
await SendFrameAsync(
|
await SendFrameAsync(
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ using YY.Admin.Views.Print;
|
|||||||
using YY.Admin.Views.MixerMaterialTareStrategy;
|
using YY.Admin.Views.MixerMaterialTareStrategy;
|
||||||
using YY.Admin.Views.RubberQuickTest;
|
using YY.Admin.Views.RubberQuickTest;
|
||||||
using YY.Admin.Views.RubberQuickTestStd;
|
using YY.Admin.Views.RubberQuickTestStd;
|
||||||
|
using YY.Admin.Views.MixingProductionPlan;
|
||||||
|
|
||||||
namespace YY.Admin
|
namespace YY.Admin
|
||||||
{
|
{
|
||||||
@@ -97,10 +98,12 @@ namespace YY.Admin
|
|||||||
containerRegistry.RegisterForNavigation<WarehouseAreaListView>();
|
containerRegistry.RegisterForNavigation<WarehouseAreaListView>();
|
||||||
// 密炼物料皮重策略
|
// 密炼物料皮重策略
|
||||||
containerRegistry.RegisterForNavigation<MixerMaterialTareStrategyListView>();
|
containerRegistry.RegisterForNavigation<MixerMaterialTareStrategyListView>();
|
||||||
// 快检记录操作台
|
// 胶料快检记录操作台
|
||||||
containerRegistry.RegisterForNavigation<RubberQuickTestOperationView>();
|
containerRegistry.RegisterForNavigation<RubberQuickTestOperationView>();
|
||||||
// 胶料快检实验标准(只读)
|
// 胶料快检实验标准(只读)
|
||||||
containerRegistry.RegisterForNavigation<RubberQuickTestStdListView>();
|
containerRegistry.RegisterForNavigation<RubberQuickTestStdListView>();
|
||||||
|
// 密炼计划(只读)
|
||||||
|
containerRegistry.RegisterForNavigation<MixingProductionPlanListView>();
|
||||||
// 打印设置
|
// 打印设置
|
||||||
containerRegistry.RegisterForNavigation<PrintSettingsView>();
|
containerRegistry.RegisterForNavigation<PrintSettingsView>();
|
||||||
// 打印模板列表
|
// 打印模板列表
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ using YY.Admin.Services.Service.WeightRecord;
|
|||||||
using YY.Admin.Services.Service.Print;
|
using YY.Admin.Services.Service.Print;
|
||||||
using YY.Admin.Services.Service.RubberQuickTest;
|
using YY.Admin.Services.Service.RubberQuickTest;
|
||||||
using YY.Admin.Services.Service.RubberQuickTestStd;
|
using YY.Admin.Services.Service.RubberQuickTestStd;
|
||||||
|
using YY.Admin.Services.Service.MixingProductionPlan;
|
||||||
|
|
||||||
namespace YY.Admin.Module;
|
namespace YY.Admin.Module;
|
||||||
|
|
||||||
@@ -95,6 +96,10 @@ public class SyncModule : IModule
|
|||||||
containerRegistry.RegisterSingleton<IRubberQuickTestStdService, RubberQuickTestStdService>();
|
containerRegistry.RegisterSingleton<IRubberQuickTestStdService, RubberQuickTestStdService>();
|
||||||
containerRegistry.RegisterSingleton<RubberQuickTestStdSyncCoordinator>();
|
containerRegistry.RegisterSingleton<RubberQuickTestStdSyncCoordinator>();
|
||||||
|
|
||||||
|
// 密炼计划(MES 只读同步)
|
||||||
|
containerRegistry.RegisterSingleton<IMixingProductionPlanService, MixingProductionPlanService>();
|
||||||
|
containerRegistry.RegisterSingleton<MixingProductionPlanSyncCoordinator>();
|
||||||
|
|
||||||
var serviceCollection = new ServiceCollection();
|
var serviceCollection = new ServiceCollection();
|
||||||
serviceCollection.AddTransient<DisconnectGuardHandler>();
|
serviceCollection.AddTransient<DisconnectGuardHandler>();
|
||||||
serviceCollection.AddHttpClient("JeecgApi", (sp, client) =>
|
serviceCollection.AddHttpClient("JeecgApi", (sp, client) =>
|
||||||
@@ -167,6 +172,8 @@ public class SyncModule : IModule
|
|||||||
_ = containerProvider.Resolve<PrintBizTemplateBindSyncCoordinator>();
|
_ = containerProvider.Resolve<PrintBizTemplateBindSyncCoordinator>();
|
||||||
// 胶料快检实验标准只读同步协调器
|
// 胶料快检实验标准只读同步协调器
|
||||||
_ = containerProvider.Resolve<RubberQuickTestStdSyncCoordinator>();
|
_ = containerProvider.Resolve<RubberQuickTestStdSyncCoordinator>();
|
||||||
|
// 密炼计划只读同步协调器
|
||||||
|
_ = containerProvider.Resolve<MixingProductionPlanSyncCoordinator>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IAsyncPolicy<HttpResponseMessage> GetRetryPolicy()
|
private static IAsyncPolicy<HttpResponseMessage> GetRetryPolicy()
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ namespace YY.Admin.ViewModels.Control
|
|||||||
["/xslmes/mesXslMixerMaterialTareStrategy"] = "MixerMaterialTareStrategyListView",
|
["/xslmes/mesXslMixerMaterialTareStrategy"] = "MixerMaterialTareStrategyListView",
|
||||||
["mesXslMixerMaterialTareStrategy"] = "MixerMaterialTareStrategyListView",
|
["mesXslMixerMaterialTareStrategy"] = "MixerMaterialTareStrategyListView",
|
||||||
|
|
||||||
// 已实现页面:快检记录操作台
|
// 已实现页面:胶料快检记录操作台
|
||||||
["RubberQuickTestOperationView"] = "RubberQuickTestOperationView",
|
["RubberQuickTestOperationView"] = "RubberQuickTestOperationView",
|
||||||
["/xslmes/rubberQuickTestOperation"] = "RubberQuickTestOperationView",
|
["/xslmes/rubberQuickTestOperation"] = "RubberQuickTestOperationView",
|
||||||
["rubberQuickTestOperation"] = "RubberQuickTestOperationView",
|
["rubberQuickTestOperation"] = "RubberQuickTestOperationView",
|
||||||
@@ -162,6 +162,11 @@ namespace YY.Admin.ViewModels.Control
|
|||||||
["/xslmes/mesXslRubberQuickTestStd"] = "RubberQuickTestStdListView",
|
["/xslmes/mesXslRubberQuickTestStd"] = "RubberQuickTestStdListView",
|
||||||
["mesXslRubberQuickTestStd"] = "RubberQuickTestStdListView",
|
["mesXslRubberQuickTestStd"] = "RubberQuickTestStdListView",
|
||||||
|
|
||||||
|
// 已实现页面:密炼计划(只读)
|
||||||
|
["MixingProductionPlanListView"] = "MixingProductionPlanListView",
|
||||||
|
["/xslmes/mesXslMixingProductionPlan"] = "MixingProductionPlanListView",
|
||||||
|
["mesXslMixingProductionPlan"] = "MixingProductionPlanListView",
|
||||||
|
|
||||||
// 已实现页面:打印设置
|
// 已实现页面:打印设置
|
||||||
["PrintSettingsView"] = "PrintSettingsView",
|
["PrintSettingsView"] = "PrintSettingsView",
|
||||||
["/system/printSettings"] = "PrintSettingsView",
|
["/system/printSettings"] = "PrintSettingsView",
|
||||||
|
|||||||
@@ -0,0 +1,139 @@
|
|||||||
|
using HandyControl.Controls;
|
||||||
|
using Prism.Events;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using YY.Admin.Core;
|
||||||
|
using YY.Admin.Core.Entity;
|
||||||
|
using YY.Admin.Core.Events;
|
||||||
|
using YY.Admin.Core.Helper;
|
||||||
|
using YY.Admin.Core.Services;
|
||||||
|
using YY.Admin.Services.Service;
|
||||||
|
|
||||||
|
namespace YY.Admin.ViewModels.MixingProductionPlan;
|
||||||
|
|
||||||
|
public class MixingProductionPlanListViewModel : BaseViewModel
|
||||||
|
{
|
||||||
|
private readonly IMixingProductionPlanService _planService;
|
||||||
|
private SubscriptionToken? _changedToken;
|
||||||
|
|
||||||
|
private ObservableCollection<MesXslMixingProductionPlan> _items = new();
|
||||||
|
public ObservableCollection<MesXslMixingProductionPlan> Items
|
||||||
|
{
|
||||||
|
get => _items;
|
||||||
|
set => SetProperty(ref _items, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private long _total;
|
||||||
|
public long Total { get => _total; set => SetProperty(ref _total, value); }
|
||||||
|
|
||||||
|
private int _pageNo = 1;
|
||||||
|
public int PageNo { get => _pageNo; set => SetProperty(ref _pageNo, value); }
|
||||||
|
|
||||||
|
private int _pageSize = 20;
|
||||||
|
public int PageSize { get => _pageSize; set => SetProperty(ref _pageSize, value); }
|
||||||
|
|
||||||
|
private DateTime? _filterPlanDateFrom;
|
||||||
|
public DateTime? FilterPlanDateFrom { get => _filterPlanDateFrom; set => SetProperty(ref _filterPlanDateFrom, value); }
|
||||||
|
|
||||||
|
private DateTime? _filterPlanDateTo;
|
||||||
|
public DateTime? FilterPlanDateTo { get => _filterPlanDateTo; set => SetProperty(ref _filterPlanDateTo, value); }
|
||||||
|
|
||||||
|
private string? _filterMachineName;
|
||||||
|
public string? FilterMachineName { get => _filterMachineName; set => SetProperty(ref _filterMachineName, value); }
|
||||||
|
|
||||||
|
private int? _filterShiftFlag;
|
||||||
|
public int? FilterShiftFlag { get => _filterShiftFlag; set => SetProperty(ref _filterShiftFlag, value); }
|
||||||
|
|
||||||
|
private string? _filterPlanNo;
|
||||||
|
public string? FilterPlanNo { get => _filterPlanNo; set => SetProperty(ref _filterPlanNo, value); }
|
||||||
|
|
||||||
|
private string? _filterMaterialName;
|
||||||
|
public string? FilterMaterialName { get => _filterMaterialName; set => SetProperty(ref _filterMaterialName, value); }
|
||||||
|
|
||||||
|
public ObservableCollection<KeyValuePair<string, int?>> ShiftOptions { get; } = new()
|
||||||
|
{
|
||||||
|
new KeyValuePair<string, int?>("全部", null),
|
||||||
|
new KeyValuePair<string, int?>("早班", 1),
|
||||||
|
new KeyValuePair<string, int?>("中班", 2),
|
||||||
|
new KeyValuePair<string, int?>("晚班", 3)
|
||||||
|
};
|
||||||
|
|
||||||
|
public DelegateCommand SearchCommand { get; }
|
||||||
|
public DelegateCommand ResetCommand { get; }
|
||||||
|
public DelegateCommand PrevPageCommand { get; }
|
||||||
|
public DelegateCommand NextPageCommand { get; }
|
||||||
|
|
||||||
|
public MixingProductionPlanListViewModel(
|
||||||
|
IMixingProductionPlanService planService,
|
||||||
|
IContainerExtension container,
|
||||||
|
IRegionManager regionManager) : base(container, regionManager)
|
||||||
|
{
|
||||||
|
_planService = planService;
|
||||||
|
|
||||||
|
SearchCommand = new DelegateCommand(async () => { PageNo = 1; await LoadAsync(); });
|
||||||
|
ResetCommand = new DelegateCommand(async () =>
|
||||||
|
{
|
||||||
|
FilterPlanDateFrom = null;
|
||||||
|
FilterPlanDateTo = null;
|
||||||
|
FilterMachineName = null;
|
||||||
|
FilterShiftFlag = null;
|
||||||
|
FilterPlanNo = null;
|
||||||
|
FilterMaterialName = null;
|
||||||
|
PageNo = 1;
|
||||||
|
await LoadAsync();
|
||||||
|
});
|
||||||
|
PrevPageCommand = new DelegateCommand(async () => { if (PageNo > 1) { PageNo--; await LoadAsync(); } });
|
||||||
|
NextPageCommand = new DelegateCommand(async () => { if ((long)PageNo * PageSize < Total) { PageNo++; await LoadAsync(); } });
|
||||||
|
|
||||||
|
_changedToken = _eventAggregator.GetEvent<MixingProductionPlanChangedEvent>()
|
||||||
|
.Subscribe(async _ => await LoadAsync(), ThreadOption.UIThread);
|
||||||
|
|
||||||
|
_ = InitializeAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task InitializeAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await UIHelper.WaitForRenderAsync();
|
||||||
|
await LoadAsync();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Debug.WriteLine($"密炼计划列表初始化失败: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task LoadAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
IsLoading = true;
|
||||||
|
var result = await _planService.PageAsync(
|
||||||
|
PageNo, PageSize,
|
||||||
|
FilterPlanDateFrom, FilterPlanDateTo,
|
||||||
|
FilterMachineName, FilterShiftFlag,
|
||||||
|
FilterPlanNo, FilterMaterialName);
|
||||||
|
Items = new ObservableCollection<MesXslMixingProductionPlan>(result.Records);
|
||||||
|
Total = result.Total;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Growl.Error($"加载密炼计划失败:{ex.Message}");
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
IsLoading = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void CleanUp()
|
||||||
|
{
|
||||||
|
base.CleanUp();
|
||||||
|
if (_changedToken != null)
|
||||||
|
{
|
||||||
|
_eventAggregator.GetEvent<MixingProductionPlanChangedEvent>().Unsubscribe(_changedToken);
|
||||||
|
_changedToken = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,135 @@
|
|||||||
|
<UserControl x:Class="YY.Admin.Views.MixingProductionPlan.MixingProductionPlanListView"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||||
|
xmlns:md="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||||
|
xmlns:prism="http://prismlibrary.com/"
|
||||||
|
prism:ViewModelLocator.AutoWireViewModel="True"
|
||||||
|
mc:Ignorable="d">
|
||||||
|
|
||||||
|
<Grid Style="{StaticResource BaseViewStyle}">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<Border Grid.Row="0" CornerRadius="4" Margin="0 0 -10 0">
|
||||||
|
<hc:Row>
|
||||||
|
<hc:Col Layout="{hc:ColLayout Xs=12, Sm=8, Md=6, Lg=6, Xl=4}">
|
||||||
|
<hc:DatePicker SelectedDate="{Binding FilterPlanDateFrom}"
|
||||||
|
Margin="0 0 10 10"
|
||||||
|
hc:InfoElement.Title="密炼日期起"
|
||||||
|
hc:InfoElement.TitlePlacement="Left"
|
||||||
|
hc:InfoElement.TitleWidth="80"
|
||||||
|
hc:InfoElement.Placeholder="开始日期"/>
|
||||||
|
</hc:Col>
|
||||||
|
<hc:Col Layout="{hc:ColLayout Xs=12, Sm=8, Md=6, Lg=6, Xl=4}">
|
||||||
|
<hc:DatePicker SelectedDate="{Binding FilterPlanDateTo}"
|
||||||
|
Margin="0 0 10 10"
|
||||||
|
hc:InfoElement.Title="密炼日期止"
|
||||||
|
hc:InfoElement.TitlePlacement="Left"
|
||||||
|
hc:InfoElement.TitleWidth="80"
|
||||||
|
hc:InfoElement.Placeholder="结束日期"/>
|
||||||
|
</hc:Col>
|
||||||
|
<hc:Col Layout="{hc:ColLayout Xs=12, Sm=8, Md=6, Lg=6, Xl=4}">
|
||||||
|
<hc:TextBox Text="{Binding FilterMachineName, UpdateSourceTrigger=PropertyChanged}"
|
||||||
|
Margin="0 0 10 10"
|
||||||
|
hc:InfoElement.Title="机台名称"
|
||||||
|
hc:InfoElement.TitlePlacement="Left"
|
||||||
|
hc:InfoElement.TitleWidth="80"
|
||||||
|
hc:InfoElement.Placeholder="机台名称"
|
||||||
|
hc:InfoElement.ShowClearButton="True"/>
|
||||||
|
</hc:Col>
|
||||||
|
<hc:Col Layout="{hc:ColLayout Xs=12, Sm=8, Md=6, Lg=6, Xl=4}">
|
||||||
|
<hc:ComboBox SelectedValuePath="Value"
|
||||||
|
DisplayMemberPath="Key"
|
||||||
|
ItemsSource="{Binding ShiftOptions}"
|
||||||
|
SelectedValue="{Binding FilterShiftFlag}"
|
||||||
|
Margin="0 0 10 10"
|
||||||
|
hc:InfoElement.Title="班次"
|
||||||
|
hc:InfoElement.TitlePlacement="Left"
|
||||||
|
hc:InfoElement.TitleWidth="80"
|
||||||
|
hc:InfoElement.Placeholder="全部"/>
|
||||||
|
</hc:Col>
|
||||||
|
<hc:Col Layout="{hc:ColLayout Xs=12, Sm=8, Md=6, Lg=6, Xl=4}">
|
||||||
|
<hc:TextBox Text="{Binding FilterPlanNo, UpdateSourceTrigger=PropertyChanged}"
|
||||||
|
Margin="0 0 10 10"
|
||||||
|
hc:InfoElement.Title="计划号"
|
||||||
|
hc:InfoElement.TitlePlacement="Left"
|
||||||
|
hc:InfoElement.TitleWidth="80"
|
||||||
|
hc:InfoElement.Placeholder="计划号"
|
||||||
|
hc:InfoElement.ShowClearButton="True"/>
|
||||||
|
</hc:Col>
|
||||||
|
<hc:Col Layout="{hc:ColLayout Xs=12, Sm=8, Md=6, Lg=6, Xl=4}">
|
||||||
|
<hc:TextBox Text="{Binding FilterMaterialName, UpdateSourceTrigger=PropertyChanged}"
|
||||||
|
Margin="0 0 10 10"
|
||||||
|
hc:InfoElement.Title="胶料名称"
|
||||||
|
hc:InfoElement.TitlePlacement="Left"
|
||||||
|
hc:InfoElement.TitleWidth="80"
|
||||||
|
hc:InfoElement.Placeholder="胶料名称"
|
||||||
|
hc:InfoElement.ShowClearButton="True"/>
|
||||||
|
</hc:Col>
|
||||||
|
</hc:Row>
|
||||||
|
</Border>
|
||||||
|
|
||||||
|
<Border Grid.Row="1" Margin="0,10">
|
||||||
|
<hc:UniformSpacingPanel Spacing="10">
|
||||||
|
<Button Style="{StaticResource ButtonPrimary}" Command="{Binding SearchCommand}">
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<md:PackIcon Kind="Search"/>
|
||||||
|
<TextBlock Text="搜索" Style="{StaticResource IconButtonStyle}"/>
|
||||||
|
</StackPanel>
|
||||||
|
</Button>
|
||||||
|
<Button Style="{StaticResource ButtonDefault}" Command="{Binding ResetCommand}">
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<md:PackIcon Kind="Refresh"/>
|
||||||
|
<TextBlock Text="重置" Style="{StaticResource IconButtonStyle}"/>
|
||||||
|
</StackPanel>
|
||||||
|
</Button>
|
||||||
|
<TextBlock Text="数据来自 MES 密炼生产计划维护,桌面端只读;断网时显示本地缓存,联网后自动刷新"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Foreground="{DynamicResource SecondaryTextBrush}"
|
||||||
|
FontSize="12"/>
|
||||||
|
</hc:UniformSpacingPanel>
|
||||||
|
</Border>
|
||||||
|
|
||||||
|
<DataGrid Grid.Row="2"
|
||||||
|
ItemsSource="{Binding Items}"
|
||||||
|
AutoGenerateColumns="False"
|
||||||
|
IsReadOnly="True"
|
||||||
|
CanUserAddRows="False"
|
||||||
|
SelectionMode="Single"
|
||||||
|
GridLinesVisibility="Horizontal"
|
||||||
|
HorizontalGridLinesBrush="#FFEDEDED"
|
||||||
|
VerticalGridLinesBrush="Transparent"
|
||||||
|
HeadersVisibility="All"
|
||||||
|
ColumnHeaderStyle="{StaticResource CusDataGridColumnHeaderStyle}"
|
||||||
|
Style="{StaticResource CusDataGridStyle}"
|
||||||
|
VerticalScrollBarVisibility="Auto"
|
||||||
|
HorizontalScrollBarVisibility="Auto">
|
||||||
|
<DataGrid.Columns>
|
||||||
|
<!-- 固定列宽合计约 920px,宽屏右侧留白 -->
|
||||||
|
<DataGridTextColumn Header="密炼日期" Binding="{Binding PlanDateText}" CellStyle="{StaticResource CusDataGridCellStyle}" Width="100"/>
|
||||||
|
<DataGridTextColumn Header="机台名称" Binding="{Binding MachineName}" CellStyle="{StaticResource CusDataGridCellStyle}" Width="120"/>
|
||||||
|
<DataGridTextColumn Header="班次" Binding="{Binding ShiftFlagText}" CellStyle="{StaticResource CusDataGridCellStyle}" Width="68"/>
|
||||||
|
<DataGridTextColumn Header="计划号" Binding="{Binding PlanNo}" CellStyle="{StaticResource CusDataGridCellStyle}" Width="160"/>
|
||||||
|
<DataGridTextColumn Header="胶料名称" Binding="{Binding MaterialName}" CellStyle="{StaticResource CusDataGridCellStyle}" Width="120"/>
|
||||||
|
<DataGridTextColumn Header="计划+胶料号" Binding="{Binding PlanMaterialNo}" CellStyle="{StaticResource CusDataGridCellStyle}" Width="240"/>
|
||||||
|
<DataGridTextColumn Header="计划数量" Binding="{Binding PlanCount}" CellStyle="{StaticResource CusDataGridCellStyle}" Width="76"/>
|
||||||
|
</DataGrid.Columns>
|
||||||
|
</DataGrid>
|
||||||
|
|
||||||
|
<StackPanel Grid.Row="3" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,10,0,0">
|
||||||
|
<TextBlock Text="{Binding Total, StringFormat=共 {0} 条}" VerticalAlignment="Center" Margin="0,0,16,0"
|
||||||
|
Foreground="{DynamicResource SecondaryTextBrush}"/>
|
||||||
|
<Button Content="上一页" Command="{Binding PrevPageCommand}" Style="{StaticResource ButtonDefault}" Margin="0,0,4,0" Width="80"/>
|
||||||
|
<TextBlock Text="{Binding PageNo, StringFormat=第 {0} 页}" VerticalAlignment="Center" Margin="8,0"
|
||||||
|
Foreground="{DynamicResource PrimaryTextBrush}"/>
|
||||||
|
<Button Content="下一页" Command="{Binding NextPageCommand}" Style="{StaticResource ButtonDefault}" Width="80"/>
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
using System.Windows.Controls;
|
||||||
|
|
||||||
|
namespace YY.Admin.Views.MixingProductionPlan;
|
||||||
|
|
||||||
|
public partial class MixingProductionPlanListView : UserControl
|
||||||
|
{
|
||||||
|
public MixingProductionPlanListView()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
<Grid Margin="12">
|
<Grid Margin="12">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="64"/>
|
<RowDefinition Height="80"/>
|
||||||
<RowDefinition Height="*"/>
|
<RowDefinition Height="*"/>
|
||||||
<RowDefinition Height="56"/>
|
<RowDefinition Height="56"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
@@ -40,19 +40,19 @@
|
|||||||
<Border Width="40" Height="40" CornerRadius="8" Background="{DynamicResource PrimaryBrush}" Margin="0,0,12,0">
|
<Border Width="40" Height="40" CornerRadius="8" Background="{DynamicResource PrimaryBrush}" Margin="0,0,12,0">
|
||||||
<md:PackIcon Kind="Flask" Width="22" Height="22" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
<md:PackIcon Kind="Flask" Width="22" Height="22" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||||
</Border>
|
</Border>
|
||||||
<StackPanel>
|
<StackPanel VerticalAlignment="Center">
|
||||||
<TextBlock Text="快检记录" FontSize="18" FontWeight="Bold"/>
|
<TextBlock Text="无转子流变仪 MDR S3L" FontSize="24" FontWeight="Bold"/>
|
||||||
<TextBlock Text="密炼快检试验操作台" FontSize="12" Foreground="{DynamicResource SecondaryTextBrush}"/>
|
<TextBlock Text="胶料快检记录 · 密炼快检试验操作台" FontSize="12" Foreground="{DynamicResource SecondaryTextBrush}" Margin="0,4,0,0"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
<!-- 主体 2:1 -->
|
<!-- 主体 3:2 -->
|
||||||
<Grid Grid.Row="1">
|
<Grid Grid.Row="1">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="2*"/>
|
<ColumnDefinition Width="3*"/>
|
||||||
<ColumnDefinition Width="12"/>
|
<ColumnDefinition Width="12"/>
|
||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="2*"/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
<!-- 左侧:曲线 + 试验结果 -->
|
<!-- 左侧:曲线 + 试验结果 -->
|
||||||
@@ -62,7 +62,7 @@
|
|||||||
<StackPanel>
|
<StackPanel>
|
||||||
<StackPanel Orientation="Horizontal" Margin="0,0,0,8">
|
<StackPanel Orientation="Horizontal" Margin="0,0,0,8">
|
||||||
<Border Width="4" Height="18" CornerRadius="2" Background="#1890ff"/>
|
<Border Width="4" Height="18" CornerRadius="2" Background="#1890ff"/>
|
||||||
<TextBlock Text="温度(℃)曲线" Style="{StaticResource SectionTitleStyle}"/>
|
<TextBlock Text="温度(℃)曲线图" Style="{StaticResource SectionTitleStyle}"/>
|
||||||
<Button Content="刷新演示" Command="{Binding RefreshChartDemoCommand}" Style="{StaticResource ButtonDefault}" Height="28" Padding="10,0" Margin="12,0,0,0"/>
|
<Button Content="刷新演示" Command="{Binding RefreshChartDemoCommand}" Style="{StaticResource ButtonDefault}" Height="28" Padding="10,0" Margin="12,0,0,0"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<TextBlock Text="{Binding ChartDemoHint}" FontSize="11" Foreground="{DynamicResource SecondaryTextBrush}" Margin="0,0,0,6"/>
|
<TextBlock Text="{Binding ChartDemoHint}" FontSize="11" Foreground="{DynamicResource SecondaryTextBrush}" Margin="0,0,0,6"/>
|
||||||
@@ -79,7 +79,7 @@
|
|||||||
<StackPanel>
|
<StackPanel>
|
||||||
<StackPanel Orientation="Horizontal" Margin="0,0,0,8">
|
<StackPanel Orientation="Horizontal" Margin="0,0,0,8">
|
||||||
<Border Width="4" Height="18" CornerRadius="2" Background="#1890ff"/>
|
<Border Width="4" Height="18" CornerRadius="2" Background="#1890ff"/>
|
||||||
<TextBlock Text="S'(dNm)曲线" Style="{StaticResource SectionTitleStyle}"/>
|
<TextBlock Text="S'(dNm)曲线图" Style="{StaticResource SectionTitleStyle}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<Border Height="200" CornerRadius="4">
|
<Border Height="200" CornerRadius="4">
|
||||||
<lvc:CartesianChart Series="{Binding TorqueSeries}"
|
<lvc:CartesianChart Series="{Binding TorqueSeries}"
|
||||||
@@ -157,11 +157,24 @@
|
|||||||
<Border Width="4" Height="18" CornerRadius="2" Background="#1890ff"/>
|
<Border Width="4" Height="18" CornerRadius="2" Background="#1890ff"/>
|
||||||
<TextBlock Text="试验信息" Style="{StaticResource SectionTitleStyle}"/>
|
<TextBlock Text="试验信息" Style="{StaticResource SectionTitleStyle}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<Button Content="刷新计划" Command="{Binding RefreshPlansCommand}"
|
<Button Content="刷新本地数据" Command="{Binding RefreshPlansCommand}"
|
||||||
Style="{StaticResource ButtonDefault}" Height="26" Padding="8,0"
|
Style="{StaticResource ButtonDefault}" Height="26" Padding="8,0"
|
||||||
HorizontalAlignment="Right" VerticalAlignment="Center"/>
|
HorizontalAlignment="Right" VerticalAlignment="Center"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
<hc:Row Gutter="10">
|
||||||
|
<!-- 快检记录号(保存后生成,单独一行) -->
|
||||||
|
<hc:Col Span="24">
|
||||||
|
<hc:TextBox Text="{Binding RecordNo, Mode=OneWay}"
|
||||||
|
IsReadOnly="True"
|
||||||
|
hc:InfoElement.Title="快检记录号"
|
||||||
|
hc:InfoElement.TitleWidth="90"
|
||||||
|
hc:InfoElement.TitlePlacement="Left"
|
||||||
|
hc:InfoElement.Placeholder="保存后自动生成"
|
||||||
|
Margin="0,0,0,8"/>
|
||||||
|
</hc:Col>
|
||||||
|
</hc:Row>
|
||||||
|
|
||||||
<hc:Row Gutter="10">
|
<hc:Row Gutter="10">
|
||||||
<!-- 密炼日期 -->
|
<!-- 密炼日期 -->
|
||||||
<hc:Col Span="12">
|
<hc:Col Span="12">
|
||||||
@@ -198,11 +211,11 @@
|
|||||||
hc:InfoElement.Symbol="*"
|
hc:InfoElement.Symbol="*"
|
||||||
Margin="0,0,0,8"/>
|
Margin="0,0,0,8"/>
|
||||||
</hc:Col>
|
</hc:Col>
|
||||||
<!-- 密炼生产计划 -->
|
<!-- 密炼计划(计划+胶料号) -->
|
||||||
<hc:Col Span="24">
|
<hc:Col Span="24">
|
||||||
<hc:ComboBox ItemsSource="{Binding PlanOptions}"
|
<hc:ComboBox ItemsSource="{Binding PlanOptions}"
|
||||||
SelectedItem="{Binding SelectedPlan}"
|
SelectedItem="{Binding SelectedPlan}"
|
||||||
DisplayMemberPath="DisplayText"
|
DisplayMemberPath="PlanMaterialNo"
|
||||||
hc:InfoElement.Title="密炼计划"
|
hc:InfoElement.Title="密炼计划"
|
||||||
hc:InfoElement.TitleWidth="90"
|
hc:InfoElement.TitleWidth="90"
|
||||||
hc:InfoElement.TitlePlacement="Left"
|
hc:InfoElement.TitlePlacement="Left"
|
||||||
@@ -211,18 +224,6 @@
|
|||||||
hc:InfoElement.Symbol="*"
|
hc:InfoElement.Symbol="*"
|
||||||
Margin="0,0,0,8"/>
|
Margin="0,0,0,8"/>
|
||||||
</hc:Col>
|
</hc:Col>
|
||||||
<!-- 生产订单号 -->
|
|
||||||
<hc:Col Span="12">
|
|
||||||
<hc:TextBox Text="{Binding ProductionOrderNo, Mode=OneWay}"
|
|
||||||
IsReadOnly="True"
|
|
||||||
hc:InfoElement.Title="生产订单号"
|
|
||||||
hc:InfoElement.TitleWidth="90"
|
|
||||||
hc:InfoElement.TitlePlacement="Left"
|
|
||||||
hc:InfoElement.Placeholder="选择计划后自动带出"
|
|
||||||
hc:InfoElement.Necessary="True"
|
|
||||||
hc:InfoElement.Symbol="*"
|
|
||||||
Margin="0,0,0,8"/>
|
|
||||||
</hc:Col>
|
|
||||||
<!-- 胶料名称 -->
|
<!-- 胶料名称 -->
|
||||||
<hc:Col Span="12">
|
<hc:Col Span="12">
|
||||||
<hc:TextBox Text="{Binding RubberMaterialName, Mode=OneWay}"
|
<hc:TextBox Text="{Binding RubberMaterialName, Mode=OneWay}"
|
||||||
@@ -233,6 +234,29 @@
|
|||||||
hc:InfoElement.Placeholder="选择计划后自动带出"
|
hc:InfoElement.Placeholder="选择计划后自动带出"
|
||||||
Margin="0,0,0,8"/>
|
Margin="0,0,0,8"/>
|
||||||
</hc:Col>
|
</hc:Col>
|
||||||
|
<!-- 实验标准 -->
|
||||||
|
<hc:Col Span="12">
|
||||||
|
<hc:ComboBox ItemsSource="{Binding StdOptions}"
|
||||||
|
SelectedItem="{Binding SelectedStd}"
|
||||||
|
DisplayMemberPath="StdName"
|
||||||
|
hc:InfoElement.Title="实验标准"
|
||||||
|
hc:InfoElement.TitleWidth="90"
|
||||||
|
hc:InfoElement.TitlePlacement="Left"
|
||||||
|
hc:InfoElement.Placeholder="按胶料名称筛选后选择"
|
||||||
|
hc:InfoElement.Necessary="True"
|
||||||
|
hc:InfoElement.Symbol="*"
|
||||||
|
Margin="0,0,0,8"/>
|
||||||
|
</hc:Col>
|
||||||
|
<!-- 实验方法 -->
|
||||||
|
<hc:Col Span="12">
|
||||||
|
<hc:TextBox Text="{Binding TestMethodName, Mode=OneWay}"
|
||||||
|
IsReadOnly="True"
|
||||||
|
hc:InfoElement.Title="实验方法"
|
||||||
|
hc:InfoElement.TitleWidth="90"
|
||||||
|
hc:InfoElement.TitlePlacement="Left"
|
||||||
|
hc:InfoElement.Placeholder="选择标准后自动带出"
|
||||||
|
Margin="0,0,0,8"/>
|
||||||
|
</hc:Col>
|
||||||
<!-- 车次 -->
|
<!-- 车次 -->
|
||||||
<hc:Col Span="12">
|
<hc:Col Span="12">
|
||||||
<hc:TextBox Text="{Binding TrainNo, UpdateSourceTrigger=PropertyChanged}"
|
<hc:TextBox Text="{Binding TrainNo, UpdateSourceTrigger=PropertyChanged}"
|
||||||
@@ -255,11 +279,31 @@
|
|||||||
hc:InfoElement.Necessary="True"
|
hc:InfoElement.Necessary="True"
|
||||||
hc:InfoElement.Symbol="*"
|
hc:InfoElement.Symbol="*"
|
||||||
hc:InfoElement.ShowClearButton="True"
|
hc:InfoElement.ShowClearButton="True"
|
||||||
|
Margin="0,0,0,8"/>
|
||||||
|
</hc:Col>
|
||||||
|
<!-- 检验结果(由试验结果区域自动判定,只读) -->
|
||||||
|
<hc:Col Span="12">
|
||||||
|
<hc:TextBox Text="{Binding OverallInspectResultDisplay, Mode=OneWay}"
|
||||||
|
IsReadOnly="True"
|
||||||
|
hc:InfoElement.Title="检验结果"
|
||||||
|
hc:InfoElement.TitleWidth="90"
|
||||||
|
hc:InfoElement.TitlePlacement="Left"
|
||||||
|
hc:InfoElement.Placeholder="自动判定"
|
||||||
|
Margin="0,0,0,8"/>
|
||||||
|
</hc:Col>
|
||||||
|
<!-- 检验人(当前登录用户,只读) -->
|
||||||
|
<hc:Col Span="24">
|
||||||
|
<hc:TextBox Text="{Binding InspectorDisplay, Mode=OneWay}"
|
||||||
|
IsReadOnly="True"
|
||||||
|
hc:InfoElement.Title="检验人"
|
||||||
|
hc:InfoElement.TitleWidth="90"
|
||||||
|
hc:InfoElement.TitlePlacement="Left"
|
||||||
|
hc:InfoElement.Placeholder="当前登录用户"
|
||||||
Margin="0,0,0,0"/>
|
Margin="0,0,0,0"/>
|
||||||
</hc:Col>
|
</hc:Col>
|
||||||
</hc:Row>
|
</hc:Row>
|
||||||
|
|
||||||
<TextBlock Text="按密炼日期 → 机台 → 班次筛选生产计划;胶料名称用于匹配快检实验标准"
|
<TextBlock Text="密炼计划、实验标准均来自桌面端本地缓存;按密炼日期筛选计划,再按胶料名称选择实验标准"
|
||||||
FontSize="11"
|
FontSize="11"
|
||||||
Foreground="{DynamicResource SecondaryTextBrush}"
|
Foreground="{DynamicResource SecondaryTextBrush}"
|
||||||
Margin="0,8,0,0"
|
Margin="0,8,0,0"
|
||||||
@@ -278,11 +322,24 @@
|
|||||||
AutoGenerateColumns="False"
|
AutoGenerateColumns="False"
|
||||||
IsReadOnly="True"
|
IsReadOnly="True"
|
||||||
HeadersVisibility="Column"
|
HeadersVisibility="Column"
|
||||||
MaxHeight="240">
|
MaxHeight="240"
|
||||||
|
ColumnWidth="*">
|
||||||
<DataGrid.Columns>
|
<DataGrid.Columns>
|
||||||
<DataGridTextColumn Header="数据点" Binding="{Binding PointName}" Width="*"/>
|
<DataGridTextColumn Header="数据点" Binding="{Binding PointName}" Width="5*"/>
|
||||||
<DataGridTextColumn Header="下限值" Binding="{Binding LowerLimit}" Width="70"/>
|
<DataGridTextColumn Header="下限值" Binding="{Binding LowerLimit}" Width="2.5*">
|
||||||
<DataGridTextColumn Header="上限值" Binding="{Binding UpperLimit}" Width="70"/>
|
<DataGridTextColumn.ElementStyle>
|
||||||
|
<Style TargetType="TextBlock">
|
||||||
|
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||||
|
</Style>
|
||||||
|
</DataGridTextColumn.ElementStyle>
|
||||||
|
</DataGridTextColumn>
|
||||||
|
<DataGridTextColumn Header="上限值" Binding="{Binding UpperLimit}" Width="2.5*">
|
||||||
|
<DataGridTextColumn.ElementStyle>
|
||||||
|
<Style TargetType="TextBlock">
|
||||||
|
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||||
|
</Style>
|
||||||
|
</DataGridTextColumn.ElementStyle>
|
||||||
|
</DataGridTextColumn>
|
||||||
</DataGrid.Columns>
|
</DataGrid.Columns>
|
||||||
</DataGrid>
|
</DataGrid>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
@@ -294,7 +351,7 @@
|
|||||||
<!-- 底部操作 -->
|
<!-- 底部操作 -->
|
||||||
<Border Grid.Row="2" Background="{DynamicResource RegionBrush}" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="0,1,0,0" Margin="-12,8,-12,-12">
|
<Border Grid.Row="2" Background="{DynamicResource RegionBrush}" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="0,1,0,0" Margin="-12,8,-12,-12">
|
||||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="20,0">
|
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="20,0">
|
||||||
<Button Content="保存快检记录" Command="{Binding SaveCommand}" Style="{StaticResource ButtonPrimary}" Height="36" Width="140"/>
|
<Button Content="保存胶料快检记录" Command="{Binding SaveCommand}" Style="{StaticResource ButtonPrimary}" Height="36" Width="160"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Border>
|
</Border>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@@ -1,72 +1,118 @@
|
|||||||
|
using System.Collections.Specialized;
|
||||||
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
using YY.Admin.ViewModels.RubberQuickTest;
|
using YY.Admin.ViewModels.RubberQuickTest;
|
||||||
|
|
||||||
namespace YY.Admin.Views.RubberQuickTest;
|
namespace YY.Admin.Views.RubberQuickTest;
|
||||||
|
|
||||||
public partial class RubberQuickTestOperationView : UserControl
|
public partial class RubberQuickTestOperationView : UserControl
|
||||||
{
|
{
|
||||||
private RubberQuickTestOperationViewModel? _vm;
|
private RubberQuickTestOperationViewModel? _vm;
|
||||||
|
|
||||||
public RubberQuickTestOperationView()
|
public RubberQuickTestOperationView()
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
DataContextChanged += OnDataContextChanged;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnDataContextChanged(object sender, System.Windows.DependencyPropertyChangedEventArgs e)
|
|
||||||
{
|
|
||||||
if (_vm != null)
|
|
||||||
_vm.InspectColumnsChanged -= RebuildInspectColumns;
|
|
||||||
_vm = DataContext as RubberQuickTestOperationViewModel;
|
|
||||||
if (_vm != null)
|
|
||||||
{
|
{
|
||||||
_vm.InspectColumnsChanged += RebuildInspectColumns;
|
InitializeComponent();
|
||||||
RebuildInspectColumns();
|
Loaded += OnLoaded;
|
||||||
}
|
DataContextChanged += OnDataContextChanged;
|
||||||
}
|
Unloaded += (_, _) => DetachViewModel();
|
||||||
|
|
||||||
private void RebuildInspectColumns()
|
|
||||||
{
|
|
||||||
if (_vm == null) return;
|
|
||||||
|
|
||||||
InspectResultGrid.Columns.Clear();
|
|
||||||
InspectResultGrid.Columns.Add(new DataGridTextColumn
|
|
||||||
{
|
|
||||||
Header = "编号",
|
|
||||||
Binding = new System.Windows.Data.Binding("RowNo"),
|
|
||||||
IsReadOnly = true,
|
|
||||||
Width = 80
|
|
||||||
});
|
|
||||||
|
|
||||||
for (int i = 0; i < _vm.DataPointColumns.Count; i++)
|
|
||||||
{
|
|
||||||
var col = _vm.DataPointColumns[i];
|
|
||||||
var binding = new System.Windows.Data.Binding($"Cells[{i}].Value")
|
|
||||||
{
|
|
||||||
UpdateSourceTrigger = System.Windows.Data.UpdateSourceTrigger.PropertyChanged,
|
|
||||||
Mode = System.Windows.Data.BindingMode.TwoWay
|
|
||||||
};
|
|
||||||
InspectResultGrid.Columns.Add(new DataGridTextColumn
|
|
||||||
{
|
|
||||||
Header = col.PointName ?? $"点{i + 1}",
|
|
||||||
Binding = binding,
|
|
||||||
Width = 90,
|
|
||||||
IsReadOnly = false
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
InspectResultGrid.Columns.Add(new DataGridTextColumn
|
private void OnLoaded(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
Header = "实验结果",
|
// 兜底:AutoWireViewModel 可能在构造函数订阅 DataContextChanged 之前就设置了 DataContext
|
||||||
Binding = new System.Windows.Data.Binding("InspectResultText"),
|
AttachViewModel(DataContext as RubberQuickTestOperationViewModel);
|
||||||
IsReadOnly = true,
|
}
|
||||||
Width = 90
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void InspectResultGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
private void OnDataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (_vm == null) return;
|
DetachViewModel();
|
||||||
_vm.SelectedInspectRow = InspectResultGrid.SelectedItem as QuickTestInspectRowViewModel;
|
AttachViewModel(DataContext as RubberQuickTestOperationViewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void AttachViewModel(RubberQuickTestOperationViewModel? vm)
|
||||||
|
{
|
||||||
|
if (vm == null || ReferenceEquals(_vm, vm)) return;
|
||||||
|
|
||||||
|
_vm = vm;
|
||||||
|
_vm.InspectColumnsChanged += RebuildInspectColumns;
|
||||||
|
_vm.DataPointColumns.CollectionChanged += OnDataPointColumnsChanged;
|
||||||
|
RebuildInspectColumns();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DetachViewModel()
|
||||||
|
{
|
||||||
|
if (_vm == null) return;
|
||||||
|
_vm.InspectColumnsChanged -= RebuildInspectColumns;
|
||||||
|
_vm.DataPointColumns.CollectionChanged -= OnDataPointColumnsChanged;
|
||||||
|
_vm = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDataPointColumnsChanged(object? sender, NotifyCollectionChangedEventArgs e)
|
||||||
|
=> RebuildInspectColumns();
|
||||||
|
|
||||||
|
private void RebuildInspectColumns()
|
||||||
|
{
|
||||||
|
if (!Dispatcher.CheckAccess())
|
||||||
|
{
|
||||||
|
Dispatcher.Invoke(RebuildInspectColumns);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var vm = _vm ?? DataContext as RubberQuickTestOperationViewModel;
|
||||||
|
if (vm == null) return;
|
||||||
|
|
||||||
|
InspectResultGrid.Columns.Clear();
|
||||||
|
|
||||||
|
InspectResultGrid.Columns.Add(new DataGridTextColumn
|
||||||
|
{
|
||||||
|
Header = "编号",
|
||||||
|
Binding = new Binding(nameof(QuickTestInspectRowViewModel.RowNo))
|
||||||
|
{
|
||||||
|
Mode = BindingMode.OneWay
|
||||||
|
},
|
||||||
|
IsReadOnly = true,
|
||||||
|
Width = 80
|
||||||
|
});
|
||||||
|
|
||||||
|
for (int i = 0; i < vm.DataPointColumns.Count; i++)
|
||||||
|
{
|
||||||
|
var col = vm.DataPointColumns[i];
|
||||||
|
var columnIndex = i;
|
||||||
|
var header = string.IsNullOrWhiteSpace(col.PointName)
|
||||||
|
? $"数据点{columnIndex + 1}"
|
||||||
|
: col.PointName;
|
||||||
|
|
||||||
|
InspectResultGrid.Columns.Add(new DataGridTextColumn
|
||||||
|
{
|
||||||
|
Header = header,
|
||||||
|
Binding = new Binding($"Cells[{columnIndex}].Value")
|
||||||
|
{
|
||||||
|
UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
|
||||||
|
Mode = BindingMode.TwoWay,
|
||||||
|
TargetNullValue = string.Empty
|
||||||
|
},
|
||||||
|
Width = 100,
|
||||||
|
IsReadOnly = false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
InspectResultGrid.Columns.Add(new DataGridTextColumn
|
||||||
|
{
|
||||||
|
Header = "实验结果",
|
||||||
|
Binding = new Binding(nameof(QuickTestInspectRowViewModel.InspectResultText))
|
||||||
|
{
|
||||||
|
Mode = BindingMode.OneWay
|
||||||
|
},
|
||||||
|
IsReadOnly = true,
|
||||||
|
Width = 90
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InspectResultGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
var vm = _vm ?? DataContext as RubberQuickTestOperationViewModel;
|
||||||
|
if (vm == null) return;
|
||||||
|
vm.SelectedInspectRow = InspectResultGrid.SelectedItem as QuickTestInspectRowViewModel;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,11 @@
|
|||||||
hc:InfoElement.Title="实验方法" hc:InfoElement.TitleWidth="90" hc:InfoElement.TitlePlacement="Left"
|
hc:InfoElement.Title="实验方法" hc:InfoElement.TitleWidth="90" hc:InfoElement.TitlePlacement="Left"
|
||||||
Margin="0,0,0,12"/>
|
Margin="0,0,0,12"/>
|
||||||
</hc:Col>
|
</hc:Col>
|
||||||
|
<hc:Col Span="12">
|
||||||
|
<hc:TextBox Text="{Binding Std.QuickTestTypeName, Mode=OneWay}" IsReadOnly="True"
|
||||||
|
hc:InfoElement.Title="实验类型" hc:InfoElement.TitleWidth="90" hc:InfoElement.TitlePlacement="Left"
|
||||||
|
Margin="0,0,0,12"/>
|
||||||
|
</hc:Col>
|
||||||
<hc:Col Span="12">
|
<hc:Col Span="12">
|
||||||
<hc:TextBox Text="{Binding Std.RubberMaterialName, Mode=OneWay}" IsReadOnly="True"
|
<hc:TextBox Text="{Binding Std.RubberMaterialName, Mode=OneWay}" IsReadOnly="True"
|
||||||
hc:InfoElement.Title="胶料名称" hc:InfoElement.TitleWidth="90" hc:InfoElement.TitlePlacement="Left"
|
hc:InfoElement.Title="胶料名称" hc:InfoElement.TitleWidth="90" hc:InfoElement.TitlePlacement="Left"
|
||||||
|
|||||||
@@ -88,9 +88,10 @@
|
|||||||
VerticalScrollBarVisibility="Auto"
|
VerticalScrollBarVisibility="Auto"
|
||||||
HorizontalScrollBarVisibility="Auto">
|
HorizontalScrollBarVisibility="Auto">
|
||||||
<DataGrid.Columns>
|
<DataGrid.Columns>
|
||||||
<DataGridTextColumn Header="实验标准名称" Binding="{Binding StdName}" CellStyle="{StaticResource CusDataGridCellStyle}" Width="180"/>
|
<DataGridTextColumn Header="实验标准名称" Binding="{Binding StdName}" CellStyle="{StaticResource CusDataGridCellStyle}" Width="160"/>
|
||||||
<DataGridTextColumn Header="实验方法" Binding="{Binding TestMethodName}" CellStyle="{StaticResource CusDataGridCellStyle}" Width="140"/>
|
<DataGridTextColumn Header="实验方法" Binding="{Binding TestMethodName}" CellStyle="{StaticResource CusDataGridCellStyle}" Width="120"/>
|
||||||
<DataGridTextColumn Header="胶料名称" Binding="{Binding RubberMaterialName}" CellStyle="{StaticResource CusDataGridCellStyle}" Width="140"/>
|
<DataGridTextColumn Header="实验类型" Binding="{Binding QuickTestTypeName}" CellStyle="{StaticResource CusDataGridCellStyle}" Width="100"/>
|
||||||
|
<DataGridTextColumn Header="胶料名称" Binding="{Binding RubberMaterialName}" CellStyle="{StaticResource CusDataGridCellStyle}" Width="120"/>
|
||||||
<DataGridTextColumn Header="发行编号" Binding="{Binding IssueNumber}" CellStyle="{StaticResource CusDataGridCellStyle}" Width="120"/>
|
<DataGridTextColumn Header="发行编号" Binding="{Binding IssueNumber}" CellStyle="{StaticResource CusDataGridCellStyle}" Width="120"/>
|
||||||
<DataGridTextColumn Header="发行部门" Binding="{Binding IssueDeptName}" CellStyle="{StaticResource CusDataGridCellStyle}" Width="120"/>
|
<DataGridTextColumn Header="发行部门" Binding="{Binding IssueDeptName}" CellStyle="{StaticResource CusDataGridCellStyle}" Width="120"/>
|
||||||
<DataGridTextColumn Header="启用状态" Binding="{Binding EnableStatusText}" CellStyle="{StaticResource CusDataGridCellStyle}" Width="90"/>
|
<DataGridTextColumn Header="启用状态" Binding="{Binding EnableStatusText}" CellStyle="{StaticResource CusDataGridCellStyle}" Width="90"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user