Compare commits

...

No commits in common. "ldeyun" and "master" have entirely different histories.

57 changed files with 5112 additions and 464 deletions

View File

@ -217,6 +217,12 @@
<artifactId>ruoyi-common</artifactId>
<version>${ruoyi.version}</version>
</dependency>
<!-- 天然气计量计算工具-->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-ngtools</artifactId>
<version>${ruoyi.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

View File

@ -68,8 +68,18 @@
<artifactId>ruoyi-generator</artifactId>
</dependency>
<!-- 天然气工具-->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-ngtools</artifactId>
<version> ${ruoyi.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>

View File

@ -1,9 +1,14 @@
package com.ruoyi;
import org.apache.catalina.connector.Connector;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.core.env.Environment;
import java.net.InetAddress;
@ -18,15 +23,42 @@ import java.net.UnknownHostException;
public class RuoYiApplication
{
public static void main(String[] args) throws UnknownHostException {
// System.setProperty("spring.devtools.restart.enabled", "false");
// SpringApplication.run(RuoYiApplication.class, args);
ConfigurableApplicationContext application = SpringApplication.run(RuoYiApplication.class, args);
Environment env = application.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");
String path = env.getProperty("server.servlet.context-path");
// 获取 HTTPS 端口
String httpsport = env.getProperty("server.port");
// 获取 HTTP 端口
String httpport = env.getProperty("server.http.port");
String path = env.getProperty("server.servlet.context-path", "/");
if (httpsport == null) {
httpsport = "未配置";
}
if (httpport == null) {
httpport = "未配置";
}
System.out.println("(♥◠‿◠)ノ゙ 若依启动成功 ლ(´ڡ`ლ)゙ \n\t" +
"Local: \thttp://localhost:" + port + path + "\n\t" +
"NetWork: \thttp://"+ip+":" + port + path + "\n\t" );
"Local: \thttps://localhost:" + httpsport + path + "\n\t" +
"NetWork: \thttps://" + ip + ":" + httpsport + path + "\n\t" +
"Local: \thttp://localhost:" + httpport + path + "\n\t" +
"NetWork: \thttp://" + ip + ":" + httpport + path + "\n\t");
}
@Value("${server.http.port}")
private int httpPort;
@Bean
public ServletWebServerFactory servletContainer() {
TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
tomcat.addAdditionalTomcatConnectors(createStandardConnector());
return tomcat;
}
private Connector createStandardConnector() {
Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
connector.setPort(httpPort);
return connector;
}
}

View File

@ -2,12 +2,14 @@
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: org.mariadb.jdbc.Driver
# driverClassName: org.mariadb.jdbc.Driver
driverClassName: com.mysql.cj.jdbc.Driver
druid:
# 主库数据源 String url = "jdbc:mariadb://192.168.3.154:3306/ry-vue?user=yourUsername&password=yourPassword
master:
url: jdbc:mariadb://192.168.3.154:3306/ry-vue?useSSL=false&characterEncoding=utf8&serverTimezone=UTC"
username: root
url: jdbc:mysql://192.168.3.246:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
# url: jdbc:mariadb://192.168.3.154:3306/ry-vue?useSSL=false&characterEncoding=utf8&serverTimezone=Asia/Shanghai
username: yjly
password: 4877017Ldy
# 从库数据源
slave:

View File

@ -13,23 +13,25 @@ ruoyi:
# 验证码类型 math 数字计算 char 字符验证
captchaType: math
# 开发环境配置
server:
# 服务器的HTTP端口默认为8080
port: 9090
port: 8443 # HTTPS 端口
servlet:
# 应用的访问路径
context-path: /
tomcat:
# tomcat的URI编码
uri-encoding: UTF-8
# 连接数满后的排队数默认为100
accept-count: 1000
threads:
# tomcat最大线程数默认为200
max: 800
# Tomcat启动初始化的线程数默认值10
min-spare: 100
ssl:
enabled: true
key-store: classpath:ngtools.cn.jks
key-store-password: kvp09gai
key-store-type: JKS
protocol: TLS
# 配置 HTTP 连接器
http:
port: 9090 # HTTP 端口
# 日志配置
logging:
@ -68,13 +70,13 @@ spring:
# redis 配置
redis:
# 地址
host: 192.168.3.154
host: 192.168.3.246
# 端口默认为6379
port: 6379
# 数据库索引
database: 0
# 密码
password:
password: 4877017Ldy
# 连接超时时间
timeout: 10s
lettuce:

Binary file not shown.

View File

@ -20,6 +20,16 @@
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common</artifactId>
<version>${ruoyi.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-system</artifactId>
</dependency>
</dependencies>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,176 @@
package com.ruoyi.ngCalTools.controller;
// GasController.java
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.ngCalTools.model.GasProps;
import com.ruoyi.ngCalTools.model.FlowProps;
import com.ruoyi.ngCalTools.service.DetailService;
import com.ruoyi.ngCalTools.service.GBT11062Service;
import com.ruoyi.ngCalTools.service.ThermService;
import com.ruoyi.ngCalTools.utils.GasConstants;
import com.ruoyi.system.controller.SysUnitConvertController;
import com.ruoyi.system.controller.UnitConvert;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/NGCalcTools")
public class GasController {
private final UnitConvert unitConvert;
public ThermService thermService;
public DetailService detailService;
public GBT11062Service gbt11062Service;
public GasController(UnitConvert unitConvert) {
this.unitConvert = unitConvert;
}
@PostMapping ("/ngCalc")
public AjaxResult ngCalc(@RequestBody FlowProps flowProps) {
thermService = new ThermService();
detailService = new DetailService();
gbt11062Service = new GBT11062Service();
GasProps gasProps = new GasProps();
//大气压力转换成Pa
double tempPatm = unitConvert.ConvertUniter("pressure", flowProps.getdPatm(), flowProps.getdPatmUnit(), 0);
//压力转换成Pa
double tempPf = unitConvert.ConvertUniter("pressure", flowProps.getdPf(), flowProps.getdPfUnit(), 0);
//温度转换成K
double tempTf = unitConvert.ConvertUniter("temperature", flowProps.getdTf(), flowProps.getdTfUnit(), 2);
if (flowProps.getdPfType() == 0) //0是表压
{
gasProps.dPf = tempPatm + tempPf;
} else {
gasProps.dPf = tempPf;
}
gasProps.dTf = tempTf;
gasProps.dCbtj = flowProps.getdCbtj();
String[] stringArray = flowProps.getdngComponents().split("_");
double[] doubleArray = new double[stringArray.length]; // 遍历字符串数组将每个元素转换为 double 类型
for (int i = 0; i < stringArray.length; i++) {
try {
doubleArray[i] = Double.parseDouble(stringArray[i]) / 100;
} catch (NumberFormatException e) {
// 处理转换异常
System.err.println("无法将字符串 " + stringArray[i] + " 转换为 double 类型: " + e.getMessage());
}
}
gasProps.adMixture = doubleArray;
Crit(gasProps, 0); //计算临界流函数所有参数都计算了
return AjaxResult.success(gasProps);
}
public void ngCalcVoid( FlowProps flowProps,GasProps gasProps) {
thermService = new ThermService();
detailService = new DetailService();
gbt11062Service = new GBT11062Service();
Crit(gasProps, 0); //计算临界流函数所有参数都计算了
}
public int NG_Cal_Init() {
//create object for calculating density
if (null == (detailService=new DetailService())) {
return GasConstants.MEMORY_ALLOCATION_ERROR;
}
//create object for calculating thermodynamic properties
if (null == (thermService=new ThermService())) {
return GasConstants.MEMORY_ALLOCATION_ERROR;
}
return GasConstants.NG_Cal_INITIALIZED;
}// NG_Cal_Init
public int NG_Cal_UnInit() {
// delete the objects (if they exist)
detailService = null;
thermService = null;
return 0;
}
public double Crit(GasProps gasProps, double dPlenumVelocity)
{
//variables local to function
double DH, DDH, S, H;
double tolerance = 1.0;
double R, P, T, Z;
int i;
//check objects for readiness; try to initialize if not
if (null == detailService || null == thermService)
{
NG_Cal_UnInit();
if (GasConstants.NG_Cal_INITIALIZED != NG_Cal_Init())
{
gasProps.lStatus =GasConstants. MEMORY_ALLOCATION_ERROR; return 0.0;
}
}
switch (gasProps.dCbtj)
{
case 2:
gasProps.dPb = 101325;
gasProps.dTb = 273.15;
break;
case 1:
gasProps.dPb = 101325;
gasProps.dTb = 288.15;
break;
case 0:
gasProps.dPb = 101325;
gasProps.dTb = 293.15;
break;
}
//begin by calculating densities and thermodynamic properties
thermService.Run(gasProps, detailService);
//DH is enthalpy change from plenum to throat; this is our initial guess
DH = (gasProps.dSOS * gasProps.dSOS - dPlenumVelocity * dPlenumVelocity) / 2.0;
//trap plenum conditions before we alter the data stucture's contents
S = gasProps.dS;
H = gasProps.dH;
R = gasProps.dRhof;
P = gasProps.dPf;
Z = gasProps.dZf;
T = gasProps.dTf;
DDH = 10.0;
for (i = 1; i < GasConstants.MAX_NUM_OF_ITERATIONS; i++)
{
thermService.HS_Mode( gasProps, detailService, H - DH, S, true);
thermService.Run( gasProps, detailService);
DDH = DH;
DH = (gasProps.dSOS * gasProps.dSOS - dPlenumVelocity * dPlenumVelocity) / 2.0;
if (Math.abs(DDH - DH) < tolerance) break;
}
gasProps.dCstar = (gasProps.dRhof * gasProps.dSOS) / Math.sqrt(R * P * Z);
gasProps.dPf = P;
gasProps.dTf = T;
thermService.Run(gasProps, detailService);
gbt11062Service.Run(gasProps );
return gasProps.dCstar;
}
}

View File

@ -0,0 +1,7 @@
package com.ruoyi.ngCalTools.enums;
public enum GasComponent {
XiC1, XiN2, XiCO2, XiC2, XiC3,
XiH2O, XiH2S, XiH2, XiCO, XiO2, XiIC4, XiNC4,
XiIC5, XiNC5, XiNC6, XiNC7, XiNC8, XiNC9, XiNC10, XiHe, XiAr
}

View File

@ -0,0 +1,592 @@
package com.ruoyi.ngCalTools.model;
public class FlowProps {
// 流量计算输入参数信息
private int dFlowCalbz; // 流量计算标准
public int getdZcalbz() {
return dZcalbz;
}
public void setdZcalbz(int dZcalbz) {
this.dZcalbz = dZcalbz;
}
public int getdFlowCalbz() {
return dFlowCalbz;
}
public void setdFlowCalbz(int dFlowCalbz) {
this.dFlowCalbz = dFlowCalbz;
}
public int getdCbtj() {
return dCbtj;
}
public void setdCbtj(int dCbtj) {
this.dCbtj = dCbtj;
}
public double getdPb_M() {
return dPb_M;
}
public void setdPb_M(double dPb_M) {
this.dPb_M = dPb_M;
}
public double getdTb_M() {
return dTb_M;
}
public void setdTb_M(double dTb_M) {
this.dTb_M = dTb_M;
}
public double getdPb_E() {
return dPb_E;
}
public void setdPb_E(double dPb_E) {
this.dPb_E = dPb_E;
}
public double getdTb_E() {
return dTb_E;
}
public void setdTb_E(double dTb_E) {
this.dTb_E = dTb_E;
}
public double getdPatm() {
return dPatm;
}
public void setdPatm(double dPatm) {
this.dPatm = dPatm;
}
public int getdPatmUnit() {
return dPatmUnit;
}
public void setdPatmUnit(int dPatmUnit) {
this.dPatmUnit = dPatmUnit;
}
public String getdngComponents() {
return dngComponents;
}
public void setdngComponents(String dngComponents) {
this.dngComponents = dngComponents;
}
public int getdMeterType() {
return dMeterType;
}
public void setdMeterType(int dMeterType) {
this.dMeterType = dMeterType;
}
public int getdCoreType() {
return dCoreType;
}
public void setdCoreType(int dCoreType) {
this.dCoreType = dCoreType;
}
public int getdPtmode() {
return dPtmode;
}
public void setdPtmode(int dPtmode) {
this.dPtmode = dPtmode;
}
public int getdPipeType() {
return dPipeType;
}
public void setdPipeType(int dPipeType) {
this.dPipeType = dPipeType;
}
public double getdPipeD() {
return dPipeD;
}
public void setdPipeD(double dPipeD) {
this.dPipeD = dPipeD;
}
public int getdLenUnit() {
return dLenUnit;
}
public void setdLenUnit(int dLenUnit) {
this.dLenUnit = dLenUnit;
}
public double getdPipeDtemp() {
return dPipeDtemp;
}
public void setdPipeDtemp(double dPipeDtemp) {
this.dPipeDtemp = dPipeDtemp;
}
public int getdPileDtempUint() {
return dPileDtempUint;
}
public void setdPileDtempUint(int dPileDtempUint) {
this.dPileDtempUint = dPileDtempUint;
}
public double getdPipeMaterial() {
return dPipeMaterial;
}
public void setdPipeMaterial(double dPipeMaterial) {
this.dPipeMaterial = dPipeMaterial;
}
public double getdOrificeD() {
return dOrificeD;
}
public void setdOrificeD(double dOrificeD) {
this.dOrificeD = dOrificeD;
}
public int getdOrificeUnit() {
return dOrificeUnit;
}
public void setdOrificeUnit(int dOrificeUnit) {
this.dOrificeUnit = dOrificeUnit;
}
public double getdOrificeDtemp() {
return dOrificeDtemp;
}
public void setdOrificeDtemp(double dOrificeDtemp) {
this.dOrificeDtemp = dOrificeDtemp;
}
public int getdOrificeDtempUnit() {
return dOrificeDtempUnit;
}
public void setdOrificeDtempUnit(int dOrificeDtempUnit) {
this.dOrificeDtempUnit = dOrificeDtempUnit;
}
public double getdOrificeMaterial() {
return dOrificeMaterial;
}
public void setdOrificeMaterial(double dOrificeMaterial) {
this.dOrificeMaterial = dOrificeMaterial;
}
public int getdOrificeSharpness() {
return dOrificeSharpness;
}
public void setdOrificeSharpness(int dOrificeSharpness) {
this.dOrificeSharpness = dOrificeSharpness;
}
public double getdOrificeRk() {
return dOrificeRk;
}
public void setdOrificeRk(double dOrificeRk) {
this.dOrificeRk = dOrificeRk;
}
public int getdOrificeRkLenUint() {
return dOrificeRkLenUint;
}
public void setdOrificeRkLenUint(int dOrificeRkLenUint) {
this.dOrificeRkLenUint = dOrificeRkLenUint;
}
public double getdPf() {
return dPf;
}
public void setdPf(double dPf) {
this.dPf = dPf;
}
public int getdPfUnit() {
return dPfUnit;
}
public void setdPfUnit(int dPfUnit) {
this.dPfUnit = dPfUnit;
}
public int getdPfType() {
return dPfType;
}
public void setdPfType(int dPfType) {
this.dPfType = dPfType;
}
public double getdTf() {
return dTf;
}
public void setdTf(double dTf) {
this.dTf = dTf;
}
public int getdTfUnit() {
return dTfUnit;
}
public void setdTfUnit(int dTfUnit) {
this.dTfUnit = dTfUnit;
}
public double getdDp() {
return dDp;
}
public void setdDp(double dDp) {
this.dDp = dDp;
}
public int getdDpUnit() {
return dDpUnit;
}
public void setdDpUnit(int dDpUnit) {
this.dDpUnit = dDpUnit;
}
public int getdVFlowUnit() {
return dVFlowUnit;
}
public void setdVFlowUnit(int dVFlowUnit) {
this.dVFlowUnit = dVFlowUnit;
}
public int getdMFlowUnit() {
return dMFlowUnit;
}
public void setdMFlowUnit(int dMFlowUnit) {
this.dMFlowUnit = dMFlowUnit;
}
public int getdEFlowUnit() {
return dEFlowUnit;
}
public void setdEFlowUnit(int dEFlowUnit) {
this.dEFlowUnit = dEFlowUnit;
}
public double getdCd() {
return dCd;
}
public void setdCd(double dCd) {
this.dCd = dCd;
}
public double getdMeterFactor() {
return dMeterFactor;
}
public void setdMeterFactor(double dMeterFactor) {
this.dMeterFactor = dMeterFactor;
}
public double getdPulseNum() {
return dPulseNum;
}
public void setdPulseNum(double dPulseNum) {
this.dPulseNum = dPulseNum;
}
public double getdVFlowMax() {
return dVFlowMax;
}
public void setdVFlowMax(double dVFlowMax) {
this.dVFlowMax = dVFlowMax;
}
public double getdVFlowMin() {
return dVFlowMin;
}
public void setdVFlowMin(double dVFlowMin) {
this.dVFlowMin = dVFlowMin;
}
public double getdVFlowCon() {
return dVFlowCon;
}
public void setdVFlowCon(double dVFlowCon) {
this.dVFlowCon = dVFlowCon;
}
public double getdPfRange() {
return dPfRange;
}
public void setdPfRange(double dPfRange) {
this.dPfRange = dPfRange;
}
public double getdDpRange() {
return dDpRange;
}
public void setdDpRange(double dDpRange) {
this.dDpRange = dDpRange;
}
public double getdTfRange() {
return dTfRange;
}
public void setdTfRange(double dTfRange) {
this.dTfRange = dTfRange;
}
public double getdE() {
return dE;
}
public void setdE(double dE) {
this.dE = dE;
}
public double getdFG() {
return dFG;
}
public void setdFG(double dFG) {
this.dFG = dFG;
}
public double getdFT() {
return dFT;
}
public void setdFT(double dFT) {
this.dFT = dFT;
}
public double getdDViscosity() {
return dDViscosity;
}
public void setdDViscosity(double dDViscosity) {
this.dDViscosity = dDViscosity;
}
public double getdDExpCoefficient() {
return dDExpCoefficient;
}
public void setdDExpCoefficient(double dDExpCoefficient) {
this.dDExpCoefficient = dDExpCoefficient;
}
public double getdRnPipe() {
return dRnPipe;
}
public void setdRnPipe(double dRnPipe) {
this.dRnPipe = dRnPipe;
}
public double getdBk() {
return dBk;
}
public void setdBk(double dBk) {
this.dBk = dBk;
}
public double getdRoughNessPipe() {
return dRoughNessPipe;
}
public void setdRoughNessPipe(double dRoughNessPipe) {
this.dRoughNessPipe = dRoughNessPipe;
}
public double getdCdCorrect() {
return dCdCorrect;
}
public void setdCdCorrect(double dCdCorrect) {
this.dCdCorrect = dCdCorrect;
}
public double getdCdNozell() {
return dCdNozell;
}
public void setdCdNozell(double dCdNozell) {
this.dCdNozell = dCdNozell;
}
public double getdVFlowb() {
return dVFlowb;
}
public void setdVFlowb(double dVFlowb) {
this.dVFlowb = dVFlowb;
}
public double getdVFlowf() {
return dVFlowf;
}
public void setdVFlowf(double dVFlowf) {
this.dVFlowf = dVFlowf;
}
public double getdMFlowb() {
return dMFlowb;
}
public void setdMFlowb(double dMFlowb) {
this.dMFlowb = dMFlowb;
}
public double getdEFlowb() {
return dEFlowb;
}
public void setdEFlowb(double dEFlowb) {
this.dEFlowb = dEFlowb;
}
public double getdVelocityFlow() {
return dVelocityFlow;
}
public void setdVelocityFlow(double dVelocityFlow) {
this.dVelocityFlow = dVelocityFlow;
}
public double getdPressLost() {
return dPressLost;
}
public void setdPressLost(double dPressLost) {
this.dPressLost = dPressLost;
}
public double getdBeta() {
return dBeta;
}
public void setdBeta(double dBeta) {
this.dBeta = dBeta;
}
public double getdKappa() {
return dKappa;
}
public void setdKappa(double dKappa) {
this.dKappa = dKappa;
}
private int dZcalbz; // 压缩因子计算标准
private int dCbtj; // 计量参比条件压力
private double dPb_M; // 计量参比条件压力
private double dTb_M; // 计量参比条件温度
private double dPb_E; // 燃烧参比条件压力
private double dTb_E; // 燃烧参比条件温度
private double dPatm; // 当地大气压
private int dPatmUnit; // 当地大气压单位
private String dngComponents; // 天然气组分
private int dMeterType; // 流量计类别
private int dCoreType; // 节流装置类型
private int dPtmode; // 取压方式
private int dPipeType; // 管道类型
private double dPipeD; // 管道内径
private int dLenUnit; // 长度单位
private double dPipeDtemp; // 管道内径参考温度
private int dPileDtempUint; // 温度单位
private double dPipeMaterial; // 管道材料
private double dOrificeD; // 孔板孔径
private int dOrificeUnit; // 长度单位
private double dOrificeDtemp; // 孔板内径参考温度
private int dOrificeDtempUnit; // 温度单位
private double dOrificeMaterial; // 孔板材料
private int dOrificeSharpness; // 锐利度系数计算方法
private double dOrificeRk; // 孔板入口圆弧半径
private int dOrificeRkLenUint; // 长度单位
private double dPf; // 输入压力
private int dPfUnit; // 压力单位
private int dPfType; // 压力类型
private double dTf; // 输入温度
private int dTfUnit; // 温度单位
private double dDp; // 输入差压
private int dDpUnit; // 压力单位
private int dVFlowUnit; // 体积流量单位
private int dMFlowUnit; // 质量流量单位
private int dEFlowUnit; // 能量流量单位
private double dCd; // 流出系数
private double dMeterFactor; // 仪表系数
private double dPulseNum; // 脉冲数
private double dVFlowMax; // 最大体积流量
private double dVFlowMin; // 最小体积流量
private double dVFlowCon; // 常用流量
private double dPfRange; // 压力量程
private double dDpRange; // 差压量程
private double dTfRange; // 温度计量程
// 流量计算输出参数
private double dE; // 求渐近速度系数 E
private double dFG; // 求相对密度系数 FG
private double dFT; // 求流动温度系数 FT
private double dDViscosity; // 求动力粘度 dlnd
private double dDExpCoefficient; // 求可膨胀系数
private double dRnPipe; // 管道雷诺数
private double dBk; // 孔板锐利度系数Bk
private double dRoughNessPipe; // 管道粗糙度系数 Gme
private double dCdCorrect; // 修正后的流出系数
private double dCdNozell; // 喷嘴的流出系数
private double dVFlowb; // 标况体积流量 m³s
private double dVFlowf; // 工况体积流量
private double dMFlowb; // 标况质量流量
private double dEFlowb; // 标况能量流量
private double dVelocityFlow; // 管道内天然气流速
private double dPressLost; // 压力损失
private double dBeta; // 直径比
private double dKappa; // 等熵指数
// Getters and Setters
}

View File

@ -0,0 +1,513 @@
package com.ruoyi.ngCalTools.model;
public class GasProps {
// corresponds to the control group in meter classes
public int lStatus; // calculation status 计算状态
public boolean bForceUpdate; // 执行全部计算的标志 signal to perform full calculation
public double[] adMixture; // 气体摩尔组成 Composition in mole fraction
public double[] adMixtureV; // 气体体积组成 Composition in mole fraction
public double[] getAdMixtureD() {
return adMixtureD;
}
public void setAdMixtureD(double[] adMixtureD) {
this.adMixtureD = adMixtureD;
}
public int getlStatus() {
return lStatus;
}
public void setlStatus(int lStatus) {
this.lStatus = lStatus;
}
public boolean isbForceUpdate() {
return bForceUpdate;
}
public void setbForceUpdate(boolean bForceUpdate) {
this.bForceUpdate = bForceUpdate;
}
public double[] getAdMixture() {
return adMixture;
}
public void setAdMixture(double[] adMixture) {
this.adMixture = adMixture;
}
public double[] getAdMixtureV() {
return adMixtureV;
}
public void setAdMixtureV(double[] adMixtureV) {
this.adMixtureV = adMixtureV;
}
public int getdCbtj() {
return dCbtj;
}
public void setdCbtj(int dCbtj) {
this.dCbtj = dCbtj;
}
public double getdPb() {
return dPb;
}
public void setdPb(double dPb) {
this.dPb = dPb;
}
public double getdTb() {
return dTb;
}
public void setdTb(double dTb) {
this.dTb = dTb;
}
public double getdPf() {
return dPf;
}
public void setdPf(double dPf) {
this.dPf = dPf;
}
public double getdTf() {
return dTf;
}
public void setdTf(double dTf) {
this.dTf = dTf;
}
public double getdMrx() {
return dMrx;
}
public void setdMrx(double dMrx) {
this.dMrx = dMrx;
}
public double getdZb() {
return dZb;
}
public void setdZb(double dZb) {
this.dZb = dZb;
}
public double getdZf() {
return dZf;
}
public void setdZf(double dZf) {
this.dZf = dZf;
}
public double getdFpv() {
return dFpv;
}
public void setdFpv(double dFpv) {
this.dFpv = dFpv;
}
public double getdDb() {
return dDb;
}
public void setdDb(double dDb) {
this.dDb = dDb;
}
public double getdDf() {
return dDf;
}
public void setdDf(double dDf) {
this.dDf = dDf;
}
public double getdRhob() {
return dRhob;
}
public void setdRhob(double dRhob) {
this.dRhob = dRhob;
}
public double getdRhof() {
return dRhof;
}
public void setdRhof(double dRhof) {
this.dRhof = dRhof;
}
public double getdRD_Ideal() {
return dRD_Ideal;
}
public void setdRD_Ideal(double dRD_Ideal) {
this.dRD_Ideal = dRD_Ideal;
}
public double getdRD_Real() {
return dRD_Real;
}
public void setdRD_Real(double dRD_Real) {
this.dRD_Real = dRD_Real;
}
public double getdHo() {
return dHo;
}
public void setdHo(double dHo) {
this.dHo = dHo;
}
public double getdH() {
return dH;
}
public void setdH(double dH) {
this.dH = dH;
}
public double getdS() {
return dS;
}
public void setdS(double dS) {
this.dS = dS;
}
public double getdCpi() {
return dCpi;
}
public void setdCpi(double dCpi) {
this.dCpi = dCpi;
}
public double getdCp() {
return dCp;
}
public void setdCp(double dCp) {
this.dCp = dCp;
}
public double getdCv() {
return dCv;
}
public void setdCv(double dCv) {
this.dCv = dCv;
}
public double getDk() {
return dk;
}
public void setDk(double dk) {
this.dk = dk;
}
public double getdKappa() {
return dKappa;
}
public void setdKappa(double dKappa) {
this.dKappa = dKappa;
}
public double getdSOS() {
return dSOS;
}
public void setdSOS(double dSOS) {
this.dSOS = dSOS;
}
public double getdCstar() {
return dCstar;
}
public void setdCstar(double dCstar) {
this.dCstar = dCstar;
}
public double getdHhvMol() {
return dHhvMol;
}
public void setdHhvMol(double dHhvMol) {
this.dHhvMol = dHhvMol;
}
public double getdLhvMol() {
return dLhvMol;
}
public void setdLhvMol(double dLhvMol) {
this.dLhvMol = dLhvMol;
}
public double getdHhvv() {
return dHhvv;
}
public void setdHhvv(double dHhvv) {
this.dHhvv = dHhvv;
}
public double getdLhvv() {
return dLhvv;
}
public void setdLhvv(double dLhvv) {
this.dLhvv = dLhvv;
}
public double getdHhvm() {
return dHhvm;
}
public void setdHhvm(double dHhvm) {
this.dHhvm = dHhvm;
}
public double getdLhvm() {
return dLhvm;
}
public void setdLhvm(double dLhvm) {
this.dLhvm = dLhvm;
}
public double getdZb11062() {
return dZb11062;
}
public void setdZb11062(double dZb11062) {
this.dZb11062 = dZb11062;
}
public double getdRhob11062() {
return dRhob11062;
}
public void setdRhob11062(double dRhob11062) {
this.dRhob11062 = dRhob11062;
}
public double getdRhof11062() {
return dRhof11062;
}
public void setdRhof11062(double dRhof11062) {
this.dRhof11062 = dRhof11062;
}
public double getdRD_Ideal11062() {
return dRD_Ideal11062;
}
public void setdRD_Ideal11062(double dRD_Ideal11062) {
this.dRD_Ideal11062 = dRD_Ideal11062;
}
public double getdRD_Real11062() {
return dRD_Real11062;
}
public void setdRD_Real11062(double dRD_Real11062) {
this.dRD_Real11062 = dRD_Real11062;
}
public double getdWobbeIndex() {
return dWobbeIndex;
}
public void setdWobbeIndex(double dWobbeIndex) {
this.dWobbeIndex = dWobbeIndex;
}
public double getdPc() {
return dPc;
}
public void setdPc(double dPc) {
this.dPc = dPc;
}
public double getdTC() {
return dTC;
}
public void setdTC(double dTC) {
this.dTC = dTC;
}
public double getdBzsx() {
return dBzsx;
}
public void setdBzsx(double dBzsx) {
this.dBzsx = dBzsx;
}
public double getdBzxx() {
return dBzxx;
}
public void setdBzxx(double dBzxx) {
this.dBzxx = dBzxx;
}
public double getdTotalC() {
return dTotalC;
}
public void setdTotalC(double dTotalC) {
this.dTotalC = dTotalC;
}
public double getdC2() {
return dC2;
}
public void setdC2(double dC2) {
this.dC2 = dC2;
}
public double getdC2j() {
return dC2j;
}
public void setdC2j(double dC2j) {
this.dC2j = dC2j;
}
public double getdC3j() {
return dC3j;
}
public void setdC3j(double dC3j) {
this.dC3j = dC3j;
}
public double getdC4j() {
return dC4j;
}
public void setdC4j(double dC4j) {
this.dC4j = dC4j;
}
public double getdC5j() {
return dC5j;
}
public void setdC5j(double dC5j) {
this.dC5j = dC5j;
}
public double getdC6j() {
return dC6j;
}
public void setdC6j(double dC6j) {
this.dC6j = dC6j;
}
public double getdC3C4() {
return dC3C4;
}
public void setdC3C4(double dC3C4) {
this.dC3C4 = dC3C4;
}
public String getDngComponents() {
return dngComponents;
}
public void setDngComponents(String dngComponents) {
this.dngComponents = dngComponents;
}
public double[] adMixtureD; // 气体质量组成 Composition in mole fraction
public int dCbtj; // 参比条件 101325 0,15,20
public double dPb; // 参比压力 Contract base Pressure (Pa)
public double dTb; // 参比温度Contract base temperature (K)
public double dPf; // 绝对压力 Absolute Pressure (Pa)
public double dTf; // 工况温度 Flowing temperature (K)
// basic output from AGA 8 Detail method
public double dMrx; // 分子量 mixture molar mass
public double dZb; // 标况压缩因子compressibility at contract base condition
public double dZf; // 工况压缩因子compressibility at flowing condition
public double dFpv; // 超压缩系数 supercompressibility
public double dDb; // 标况摩尔密度molar density at contract base conditions (moles/dm3)
public double dDf; // 工况摩尔密度 molar density at flowing conditions (moles/dm3)
public double dRhob; // 标况质量密度mass density at contract base conditions (kg/m3)
public double dRhof; // 工况质量密度 mass density at flowing conditions (kg/m3)
public double dRD_Ideal; // 理想气体的相对密度ideal gas relative density
public double dRD_Real; // 真实气体的相对密度real gas relative density
// additional output
public double dHo; // 理想气体的比焓 ideal gas specific enthalpy
public double dH; // 真实气体的焓 real gas specific enthalpy (J/kg)
public double dS; // 真实气体的熵real gas specific entropy (J/kg-mol.K)
public double dCpi; // 理想气体定压热容 ideal gas constant pressure heat capacity (J/kg-mol.K)
public double dCp; // 定压热容real gas constant pressure heat capacity (J/kg-mol.K)
public double dCv; // 定容积热容 real gas constant volume heat capacity (J/kg-mol.K)
public double dk; // 比热比ratio of specific heats
public double dKappa; // 等熵指数 isentropic exponent, denoted with Greek letter kappa
public double dSOS; // 声速speed of sound (m/s)
public double dCstar; // 临界流函数 critical flow factor C*
// 11062 输出
public double dHhvMol; // 摩尔高位发热量
public double dLhvMol; // 摩尔低位发热量
public double dHhvv; // 体积高位发热量
public double dLhvv; // 体积低位发热量
public double dHhvm; // 质量高位发热量
public double dLhvm; // 质量地位发热量
public double dZb11062; // 标况压缩因子
public double dRhob11062; // 标况质量密度mass density at contract base conditions (kg/m3)
public double dRhof11062; // 工况质量密度 mass density at flowing conditions (kg/m3)
public double dRD_Ideal11062; // 理想气体的相对密度ideal gas relative density
public double dRD_Real11062; // 真实气体的相对密度real gas relative density
public double dWobbeIndex; // 真实气体的沃泊指数
public double dPc; // 临界压力
public double dTC; // 临界温度
public double dBzsx; // 爆炸上限
public double dBzxx; // 爆炸下限
public double dTotalC; // 总炭含量 (kg/m3)
public double dC2; // C2组分含量 (kg/m3)
public double dC2j; // C2以上组分含量 (kg/m3)
public double dC3j; // C3以上组分含量 (kg/m3)
public double dC4j; // C4以上组分含量 (kg/m3)
public double dC5j; // C5以上组分含量 (kg/m3)
public double dC6j; // C6以上组分含量 (kg/m3)
public double dC3C4; // C3C4组分含量 (kg/m3)
public String dngComponents; //组分的组合字符串 从前端传过来
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,139 @@
package com.ruoyi.ngCalTools.service;
import com.ruoyi.ngCalTools.model.GasProps;
import com.ruoyi.ngCalTools.utils.GasConstants;
import org.springframework.stereotype.Service;
@Service
public class GBT11062Service {
int iNCC;// number of components
int[] aiCID = new int[21];// component IDs
double[] dXi = new double[21];// mole fraction of component i
// 初始化 adTableMri 数组
double[] adTableMri = { 16.0430, 28.0135, 44.0100, 30.0700, 44.0970, 18.0153, 34.0820, 2.0159, 28.0100, 31.9988, 58.1230, 58.1230, 72.1500, 72.1500, 86.1770, 100.2040, 114.2310, 128.2580, 142.2850, 4.0026, 39.9480 };
// 初始化 adTablePc 数组
double[] adTablePc = { 4.604, 3.399, 7.382, 4.88, 4.249, 22.118, 9.005, 1.297, 3.499, 5.081, 3.648, 3.797, 3.381, 3.369, 3.012, 2.736, 2.486, 0, 0, 0.2275, 4.876 };
// 初始化 adTableTc 数组
double[] adTableTc = { 190.55, 126.1, 304.19, 305.43, 369.82, 647.3, 373.5, 33.2, 132.92, 154.7, 408.13, 425.16, 460.39, 469.6, 507.4, 540.2, 568.76, 0, 0, 5.2, 150.82 };
// 初始化 adTableBzsx 数组
double[] adTableBzsx = { 15, 0, 0, 13, 9.5, 0, 45.5, 74.2, 74.2, 0, 8.4, 8.4, 8.3, 8.3, 7.7, 7.0, 0, 0, 0, 0, 0 };
// 初始化 adTableBzxx 数组
double[] adTableBzxx = { 5.0, 0, 0, 2.9, 2.1, 0, 4.3, 4.0, 12.5, 0, 1.8, 1.8, 1.4, 1.4, 1.2, 1.0, 0.96, 0, 0, 0, 0 };
double[][] adTableZn = {
{0.9976, 0.9995, 0.9933, 0.99, 0.9789, 0.93, 0.99, 1.0006, 0.9993, 0.999, 0.958, 0.9572, 0.9377, 0.918, 0.892, 0.83, 0.742, 0.613, 0.434, 1.0005, 0.999},
{0.998, 0.9997, 0.9944, 0.9915, 0.9821, 0.945, 0.99, 1.0006, 0.9995, 0.9992, 0.968, 0.965, 0.948, 0.937, 0.913, 0.866, 0.802, 0.71, 0.584, 1.0005, 0.9992},
{0.9981, 0.9997, 0.9944, 0.992, 0.9834, 0.952, 0.99, 1.0006, 0.9996, 0.9993, 0.971, 0.9682, 0.953, 0.945, 0.919, 0.876, 0.817, 0.735, 0.623, 1.0005, 0.9993}
};
double[][] adTableSqrtbj = {
{0.049, 0.0224, 0.0819, 0.1, 0.1453, 0.2646, 0.1, -0.004, 0.0265, 0.0316, 0.2049, 0.2069, 0.251, 0.2864, 0.3286, 0.4123, 0.5079, 0.6221, 0.7523, 0.0006, 0.0316},
{0.0447, 0.0173, 0.0748, 0.0922, 0.1338, 0.2345, 0.1, -0.0048, 0.0224, 0.0283, 0.1789, 0.1871, 0.228, 0.251, 0.295, 0.3661, 0.445, 0.5385, 0.645, 0.0002, 0.0283},
{0.0436, 0.0173, 0.0728, 0.0894, 0.1288, 0.2191, 0.1, -0.0051, 0.02, 0.0265, 0.1703, 0.1783, 0.2168, 0.2345, 0.2846, 0.3521, 0.4278, 0.5148, 0.614, 0, 0.0265}
};
double[][] adTableHhvMol = {
{892.97, 0, 0, 1564.34, 2224.01, 45.074, 562.94, 286.63, 282.8, 0, 2874.2, 2883.82, 3535.98, 3542.89, 4203.23, 4862.87, 5522.4, 6182.91, 6842.69, 0, 0},
{891.56, 0, 0, 1562.14, 2221.1, 44.433, 562.38, 286.15, 282.91, 0, 2870.58, 2879.76, 3531.68, 3538.6, 4198.24, 4857.18, 5516.01, 6175.82, 6834.9, 0, 0},
{891.09, 0, 0, 1561.41, 2220.13, 44.224, 562.19, 285.99, 282.95, 0, 2869.38, 2878.57, 3530.24, 3537.17, 4196.58, 4855.29, 5513.88, 6173.46, 6832.31, 0, 0},
{890.63, 0, 0, 1560.69, 2219.17, 44.016, 562.01, 285.83, 282.98, 0, 2868.2, 2877.4, 3528.83, 3535.77, 4194.95, 4853.43, 5511.8, 6171.15, 6829.77, 0, 0}
};
double[][] adTableLhvMol = {
{802.82, 0, 0, 1429.12, 2043.71, 0, 517.87, 241.56, 282.8, 0, 2648.83, 2658.45, 3265.54, 3272.45, 3887.71, 4502.28, 5116.73, 5732.17, 6346.88, 0, 0},
{802.69, 0, 0, 1428.84, 2043.37, 0, 517.95, 241.72, 282.91, 0, 2648.42, 2657.6, 3265.08, 3272, 3887.21, 4501.72, 5116.11, 5731.49, 6346.14, 0, 0},
{802.65, 0, 0, 1428.74, 2043.23, 0, 517.97, 241.76, 282.95, 0, 2648.26, 2657.45, 3264.89, 3271.83, 3887.01, 4501.49, 5115.87, 5731.22, 6345.85, 0, 0},
{802.6, 0, 0, 1428.64, 2043.11, 0, 517.99, 241.81, 282.98, 0, 2648.12, 2657.32, 3264.73, 3271.67, 3886.84, 4501.3, 5115.66, 5730.99, 6345.59, 0, 0}
};
int i;
double dMair = 28.9626;
double dZair = 0;
public void Run(GasProps gasProps) {
for (int i = 0; i < GasConstants.NUMBEROFCOMPONENTS; i++) dXi[i] = 0;
iNCC = -1;
for (i = 0; i < GasConstants.NUMBEROFCOMPONENTS; i++) {
if (gasProps.adMixture[i] > 0.0) {
iNCC = iNCC + 1;
aiCID[iNCC] = i;
dXi[iNCC] = gasProps.adMixture[i];
}
}
iNCC = iNCC + 1;
for (i = 0; i < GasConstants.NUMBEROFCOMPONENTS; i++) {
if (gasProps.adMixture[i] != 0) {
gasProps.dPc += adTablePc[i] * gasProps.adMixture[i];
gasProps.dTC += adTableTc[i] * gasProps.adMixture[i];
if (adTableBzsx[i] != 0) {
gasProps.dBzsx += gasProps.adMixture[i] / adTableBzsx[i];
gasProps.dBzxx += gasProps.adMixture[i] / adTableBzxx[i];
}
if (i >= 10 & i <= 18) {
gasProps.dC4j += gasProps.adMixture[i] * adTableMri[i];
}
if (i >= 12 & i <= 18) {
gasProps.dC5j += gasProps.adMixture[i] * adTableMri[i];
}
if (i >= 14 & i <= 18) {
gasProps.dC6j += gasProps.adMixture[i] * adTableMri[i];
}
if (i == 3) {
gasProps.dC2 += gasProps.adMixture[i] * adTableMri[i];
}
switch (gasProps.dCbtj) {
case 2:
gasProps.dZb11062 += adTableSqrtbj[0][i] * gasProps.adMixture[i];
gasProps.dHhvMol += adTableHhvMol[0][i] * gasProps.adMixture[i];
gasProps.dLhvMol += adTableLhvMol[0][i] * gasProps.adMixture[i];
dZair = 0.99941;
break;
case 1:
gasProps.dZb11062 += adTableSqrtbj[1][i] * gasProps.adMixture[i];
gasProps.dHhvMol += adTableHhvMol[1][i] * gasProps.adMixture[i];
gasProps.dLhvMol += adTableLhvMol[1][i] * gasProps.adMixture[i];
dZair = 0.99958;
break;
case 0:
gasProps.dZb11062 += adTableSqrtbj[2][i] * gasProps.adMixture[i];
gasProps.dHhvMol += adTableHhvMol[2][i] * gasProps.adMixture[i];
gasProps.dLhvMol += adTableLhvMol[2][i] * gasProps.adMixture[i];
dZair = 0.99963;
break;
}
}
}
gasProps.dBzsx = 1 / gasProps.dBzsx;
gasProps.dBzxx = 1 / gasProps.dBzxx;
gasProps.dZb11062 = 1 - gasProps.dZb11062 * gasProps.dZb11062;
gasProps.dHhvm = gasProps.dHhvMol / gasProps.dMrx;
gasProps.dLhvm = gasProps.dLhvMol / gasProps.dMrx;
gasProps.dHhvv = gasProps.dHhvMol * gasProps.dPb / gasProps.dTb / 8314.510 / gasProps.dZb11062;
gasProps.dLhvv = gasProps.dLhvMol * gasProps.dPb / gasProps.dTb / 8314.510 / gasProps.dZb11062;
gasProps.dRD_Ideal11062 = gasProps.dMrx / dMair;
gasProps.dRD_Real11062 = gasProps.dRD_Ideal11062 * dZair / gasProps.dZb11062;
gasProps.dRhob11062 = gasProps.dMrx * gasProps.dPb / 8314.51 / gasProps.dTb / gasProps.dZb11062;
gasProps.dRhof11062 = gasProps.dMrx * gasProps.dPf / 8314.51 / gasProps.dTf / gasProps.dZf;
gasProps.dWobbeIndex = gasProps.dHhvv / Math.sqrt(gasProps.dRD_Real11062);
gasProps.dC3j = gasProps.dC4j + gasProps.adMixture[4] * adTableMri[4];
gasProps.dC2j = gasProps.dC3j + gasProps.adMixture[3] * adTableMri[3];
gasProps.dC3C4 = gasProps.adMixture[4] * adTableMri[4] + gasProps.adMixture[10] * adTableMri[10] + gasProps.adMixture[11] * adTableMri[11];
gasProps.dTotalC = gasProps.dC2j + gasProps.adMixture[0] * adTableMri[0];
gasProps.dTotalC = gasProps.dTotalC * gasProps.dPb / 8314.51 / gasProps.dTb / gasProps.dZb11062;
gasProps.dC2 = gasProps.dC2 * gasProps.dPb / 8314.51 / gasProps.dTb / gasProps.dZb11062;
gasProps.dC3C4 = gasProps.dC3C4 * gasProps.dPb / 8314.51 / gasProps.dTb / gasProps.dZb11062;
gasProps.dC2j = gasProps.dC2j * gasProps.dPb / 8314.51 / gasProps.dTb / gasProps.dZb11062;
gasProps.dC3j = gasProps.dC3j * gasProps.dPb / 8314.51 / gasProps.dTb / gasProps.dZb11062;
gasProps.dC4j = gasProps.dC4j * gasProps.dPb / 8314.51 / gasProps.dTb / gasProps.dZb11062;
gasProps.dC5j = gasProps.dC5j * gasProps.dPb / 8314.51 / gasProps.dTb / gasProps.dZb11062;
gasProps.dC6j = gasProps.dC6j * gasProps.dPb / 8314.51 / gasProps.dTb / gasProps.dZb11062;
}
}

View File

@ -0,0 +1,430 @@
package com.ruoyi.ngCalTools.service;
import com.ruoyi.ngCalTools.model.GasProps;
import com.ruoyi.ngCalTools.utils.GasConstants;
import org.springframework.stereotype.Service;
@Service
public class ThermService {
private static final double CAL_TH = 4.1840;
public int coefA = 0;
public int coefB = 1;
public int coefC = 2;
public int coefD = 3;
public int coefE = 4;
public int coefF = 5;
public int coefG = 6;
public int coefH = 7;
public int coefI = 8;
public int coefJ = 9;
public int coefK = 10;
double dPdD;// partial deriv of P wrt D
double dPdT;// partial deriv of P wrt T
double dSi;// ideal gas specific entropy, kJ/kg.K
double dTold;// temperature previously used
double dMrxold;// mixture molar mass previously used
//set the number of points for quadrature
int GK_points = 5;
// 初始化 GK_root 数组
double[] GK_root = { 0.14887433898163121088, 0.43339539412924719080, 0.67940956829902440263, 0.86506336668898451073, 0.97390652851717172008 };
// 初始化 GK_weight 数组
double[] GK_weight = { 0.29552422471475286217, 0.26926671930999634918, 0.21908636251598204295, 0.14945134915058059038, 0.066671344308688137179 };
private final double[][] ThermConstants = {
{-29776.4, 7.95454, 43.9417, 1037.09, 1.56373, 813.205, -24.9027, 1019.98, -10.1601, 1070.14, -20.0615},
{-3495.34, 6.95587, 0.272892, 662.738, -0.291318, -680.562, 1.78980, 1740.06, 0.0, 100.0, 4.49823},
{20.7307, 6.96237, 2.68645, 500.371, -2.56429, -530.443, 3.91921, 500.198, 2.13290, 2197.22, 5.81381},
{-37524.4, 7.98139, 24.3668, 752.320, 3.53990, 272.846, 8.44724, 1020.13, -13.2732, 869.510, -22.4010},
{-56072.1, 8.14319, 37.0629, 735.402, 9.38159, 247.190, 13.4556, 1454.78, -11.7342, 984.518, -24.0426},
{-13773.1, 7.97183, 6.27078, 2572.63, 2.05010, 1156.72, 0.0, 100.0, 0.0, 100.0, -3.24989},
{-10085.4, 7.94680, -0.08380, 433.801, 2.85539, 843.792, 6.31595, 1481.43, -2.88457, 1102.23, -0.51551},
{-5565.60, 6.66789, 2.33458, 2584.98, 0.749019, 559.656, 0.0, 100.0, 0.0, 100.0, -7.94821},
{-2753.49, 6.95854, 2.02441, 1541.22, 0.096774, 3674.81, 0.0, 100.0, 0.0, 100.0, 6.23387},
{-3497.45, 6.96302, 2.40013, 2522.05, 2.21752, 1154.15, 0.0, 100.0, 0.0, 100.0, 9.19749},
{-72387.0, 17.8143, 58.2062, 1787.39, 40.7621, 808.645, 0.0, 100.0, 0.0, 100.0, -44.1341},
{-72674.8, 18.6383, 57.4178, 1792.73, 38.6599, 814.151, 0.0, 100.0, 0.0, 100.0, -46.1938},
{-91505.5, 21.3861, 74.3410, 1701.58, 47.0587, 775.899, 0.0, 100.0, 0.0, 100.0, -60.2474},
{-83845.2, 22.5012, 69.5789, 1719.58, 46.2164, 802.174, 0.0, 100.0, 0.0, 100.0, -62.2197},
{-94982.5, 26.6225, 80.3819, 1718.49, 55.6598, 802.069, 0.0, 100.0, 0.0, 100.0, -77.5366},
{-103353.0, 30.4029, 90.6941, 1669.32, 63.2028, 786.001, 0.0, 100.0, 0.0, 100.0, -92.0164},
{-109674.0, 34.0847, 100.253, 1611.55, 69.7675, 768.847, 0.0, 100.0, 0.0, 100.0, -106.149},
{-122599.0, 38.5014, 111.446, 1646.48, 80.5015, 781.588, 0.0, 100.0, 0.0, 100.0, -122.444},
{-133564.0, 42.7143, 122.173, 1654.85, 90.2255, 785.564, 0.0, 100.0, 0.0, 100.0, -138.006},
{0.0, 4.9680, 0.0, 100.0, 0.0, 100.0, 0.0, 100.0, 0.0, 100.0, 0.0},
{0.0, 4.9680, 0.0, 100.0, 0.0, 100.0, 0.0, 100.0, 0.0, 100.0, 0.0}
};
public ThermService()
{
// initialize 3 history-sensitive variables
dSi = 0.0;
dTold = 0.0;
dMrxold = 0.0;
}
public void Run(GasProps gasProps, DetailService detailService)
{
//local variables
double c, x, y, z;
//first run basic set of functions within AGA 8 (1994) Detail Method
detailService.run(gasProps);
//find first partial derivative of Z wrt D
detailService.dZdD(gasProps.dDf);
//find real gas cv, cp, specific enthalpy and entropy
CprCvrHS(gasProps, detailService);
//ratio of real gas specific heats
gasProps.dk = gasProps.dCp / gasProps.dCv;
//solve c in three steps, for clarity and ease of debugging
x = gasProps.dk * GasConstants.RGAS * 1000.0 * gasProps.dTf;
y = gasProps.dMrx;
z = gasProps.dZf + gasProps.dDf * detailService.ddZdD;
//calculate c, which is SOS^2
c = (x / y) * z;
//speed of sound
gasProps.dSOS = Math.sqrt(c);
//calculate the real gas isentropic exponent
//using expression functionally equivalent to Equation 3.2
gasProps.dKappa = (c * gasProps.dRhof) / gasProps.dPf;
return;
}
private double CpiMolar(GasProps gasProps) {
double cp = 0.0;
double Cpx;
double DT, FT, HT, JT;
double Dx, Fx, Hx, Jx;
double T;
T = gasProps.dTf;
for (int i = 0; i < GasConstants.NUMBEROFCOMPONENTS; i++) {
if (gasProps.getAdMixture()[i] > 0) {
// 计算每个组分的贡献
Cpx = 0.0;
// calculate species intermediate terms
DT = ThermConstants[i][ coefD] / T;
FT = ThermConstants[i][ coefF] / T;
HT = ThermConstants[i][ coefH] / T;
JT = ThermConstants[i][ coefJ] / T;
// use intermediate terms to avoid redundant calcs
Dx = DT / Math.sinh(DT);
Fx = FT / Math.cosh(FT);
Hx = HT / Math.sinh(HT);
Jx = JT / Math.cosh(JT);
Cpx += ThermConstants[i][ coefB];
Cpx += ThermConstants[i][ coefC] * Dx * Dx;
Cpx += ThermConstants[i][ coefE] * Fx * Fx;
Cpx += ThermConstants[i][ coefG] * Hx * Hx;
Cpx += ThermConstants[i][ coefI] * Jx * Jx;
//use current mole fraction to weight the contribution
Cpx *= gasProps.adMixture[i];
//add this contribution to the sum
cp += Cpx;
}
}
return cp * CAL_TH;
}
// coth 函数实现
private static double coth(double x) {
return 1.0 / Math.tanh(x);
}
// Ho 函数
public double Ho(GasProps gasProps) {
double H = 0.0;
double Hx;
double DT, FT, HT, JT;
double cothDT, tanhFT, cothHT, tanhJT;
double T = gasProps.dTf;
for (int i = 0; i < GasConstants.NUMBEROFCOMPONENTS; i++) {
if (gasProps.adMixture[i] <= 0.0) continue;
Hx = 0.0;
DT = ThermConstants[i][coefD] / T;
FT = ThermConstants[i][coefF] / T;
HT = ThermConstants[i][coefH] / T;
JT = ThermConstants[i][coefJ] / T;
cothDT = coth(DT);
tanhFT = Math.tanh(FT);
cothHT = coth(HT);
tanhJT = Math.tanh(JT);
Hx += ThermConstants[i][coefA];
Hx += ThermConstants[i][coefB] * T;
Hx += ThermConstants[i][coefC] * ThermConstants[i][coefD] * cothDT;
Hx -= ThermConstants[i][coefE] * ThermConstants[i][coefF] * tanhFT;
Hx += ThermConstants[i][coefG] * ThermConstants[i][coefH] * cothHT;
Hx -= ThermConstants[i][coefI] * ThermConstants[i][coefJ] * tanhJT;
Hx *= gasProps.adMixture[i];
H += Hx;
}
H *= CAL_TH;
H /= gasProps.dMrx;
return H * 1000.0;
}
// So 函数
public double So(GasProps gasProps) {
double S = 0.0;
double Sx;
double DT, FT, HT, JT;
double cothDT, tanhFT, cothHT, tanhJT;
double sinhDT, coshFT, sinhHT, coshJT;
double T = gasProps.dTf;
for (int i = 0; i < GasConstants.NUMBEROFCOMPONENTS; i++) {
if (gasProps.adMixture[i] <= 0.0) continue;
Sx = 0.0;
DT = ThermConstants[i][coefD] / T;
FT = ThermConstants[i][coefF] / T;
HT = ThermConstants[i][coefH] / T;
JT = ThermConstants[i][coefJ] / T;
cothDT = coth(DT);
tanhFT = Math.tanh(FT);
cothHT = coth(HT);
tanhJT = Math.tanh(JT);
sinhDT = Math.sinh(DT);
coshFT = Math.cosh(FT);
sinhHT = Math.sinh(HT);
coshJT = Math.cosh(JT);
Sx += ThermConstants[i][coefK];
Sx += ThermConstants[i][coefB] * Math.log(T);
Sx += ThermConstants[i][coefC] * (DT * cothDT - Math.log(sinhDT));
Sx -= ThermConstants[i][coefE] * (FT * tanhFT - Math.log(coshFT));
Sx += ThermConstants[i][coefG] * (HT * cothHT - Math.log(sinhHT));
Sx -= ThermConstants[i][coefI] * (JT * tanhJT - Math.log(coshJT));
Sx *= gasProps.adMixture[i];
S += Sx;
}
S *= CAL_TH;
S /= gasProps.dMrx;
return S * 1000.0;
}
// CprCvrHS 函数
public void CprCvrHS(GasProps gasProps, DetailService detailService) {
double Cvinc = 0.0;
double Cvr, Cpr;
double Hinc = 0.0;
double Sinc = 0.0;
double Smixing = 0.0;
double Cp = CpiMolar(gasProps);
double Si;
gasProps.dHo = Ho(gasProps);
Si = So(gasProps);
gasProps.dCpi = (Cp * 1000.0) / gasProps.dMrx;
for (int i = 0; i < GK_points; i++) {
double x = gasProps.dDf * (1.0 + GK_root[i]) / 2.0;
detailService.zdetail(x);
detailService.dZdT(x);
detailService.d2ZdT2(x);
Hinc += GK_weight[i] * detailService.ddZdT / x;
Cvinc += GK_weight[i] * (2.0 * detailService.ddZdT + gasProps.dTf * detailService.dd2ZdT2) / x;
Sinc += GK_weight[i] * (detailService.dZ + gasProps.dTf * detailService.ddZdT - 1.0) / x;
x = gasProps.dDf * (1.0 - GK_root[i]) / 2.0;
detailService.zdetail(x);
detailService.dZdT(x);
detailService.d2ZdT2(x);
Hinc += GK_weight[i] * detailService.ddZdT / x;
Cvinc += GK_weight[i] * (2.0 * detailService.ddZdT + gasProps.dTf * detailService.dd2ZdT2) / x;
Sinc += GK_weight[i] * (detailService.dZ + gasProps.dTf * detailService.ddZdT - 1.0) / x;
}
detailService.zdetail(gasProps.dDf);
detailService.dZdT(gasProps.dDf);
detailService.d2ZdT2(gasProps.dDf);
Cvr = Cp - GasConstants.RGAS * (1.0 + gasProps.dTf * Cvinc * 0.5 * gasProps.dDf);
double a = (gasProps.dZf + gasProps.dTf * detailService.ddZdT);
double b = (gasProps.dZf + gasProps.dDf * detailService.ddZdD);
double dPdT =GasConstants. RGAS * gasProps.dDf * a;
double dPdD = GasConstants.RGAS * gasProps.dTf * b;
Cpr = Cvr + GasConstants.RGAS * ((a * a) / b);
Cpr /= gasProps.dMrx;
Cvr /= gasProps.dMrx;
gasProps.dCv = Cvr * 1000.0;
gasProps.dCp = Cpr * 1000.0;
gasProps.dH = gasProps.dHo + 1000.0 * GasConstants.RGAS * gasProps.dTf * (gasProps.dZf - 1.0 - gasProps.dTf * Hinc * 0.5 * gasProps.dDf) / gasProps.dMrx;
for (int i = 0; i < GasConstants.NUMBEROFCOMPONENTS; i++) {
if (gasProps.adMixture[i] != 0) Smixing += gasProps.adMixture[i] * Math.log(gasProps.adMixture[i]);
}
Smixing *= GasConstants.RGAS;
gasProps.dS = Si - Smixing - 1000.0 * GasConstants.RGAS * (Math.log(gasProps.dPf / 101325.0) - Math.log(gasProps.dZf) + Sinc * 0.5 * gasProps.dDf) / gasProps.dMrx;
}
// HS_Mode 函数
public void HS_Mode( GasProps gasProps, DetailService detailService, double H, double S, boolean bGuess) {
double s0 = S;
double h0 = H;
double t1, t2, tmin, tmax;
double p1, p2, px, pmin, pmax;
double delta1, delta2;
double tolerance = 0.001;
if (bGuess) {
t1 = gasProps.dTf;
px = gasProps.dPf;
pmax = px * 2.0;
pmin = px * 0.1;
tmax = t1 * 1.5;
tmin = t1 * 0.67;
} else {
t1 = 273.15;
px = 1013250.0;
pmax = GasConstants.P_MAX;
pmin = 10000.0;
tmax = GasConstants.T_MAX;
tmin = GasConstants.T_MIN;
}
t2 = t1 + 10.0;
detailService.run(gasProps);
double h1 = H(gasProps, detailService) - h0;
for (int i = 0; i < GasConstants.MAX_NUM_OF_ITERATIONS; i++) {
gasProps.dTf = t2;
p1 = px;
p2 = px * 0.1;
gasProps.dPf = p1;
detailService.run(gasProps);
double s1 = S(gasProps, detailService) - s0;
for (int j = 0; j < GasConstants.MAX_NUM_OF_ITERATIONS; j++) {
gasProps.dPf = p2;
detailService.run(gasProps);
double s2 = S(gasProps, detailService) - s0;
delta2 = Math.abs(s1 - s2) / s0;
if (delta2 < tolerance) break;
double p0 = p2;
p2 = (p1 * s2 - p2 * s1) / (s2 - s1);
if (p2 <= pmin) p2 = pmin;
if (p2 >= pmax) p2 = pmax;
p1 = p0;
s1 = s2;
}
if (gasProps.lStatus == GasConstants.MAX_NUM_OF_ITERATIONS_EXCEEDED) break;
double h2 = H(gasProps, detailService) - h0;
delta1 = Math.abs(h1 - h2) / h0;
if (delta1 < tolerance && i > 0) break;
double t0 = t2;
t2 = (t1 * h2 - t2 * h1) / (h2 - h1);
if (t2 >= tmax) t2 = tmax;
if (t2 <= tmin) {
t2 = t0 + 10.0;
gasProps.dTf = t2;
detailService.run(gasProps);
h2 = H(gasProps, detailService) - h0;
}
t1 = t0;
h1 = h2;
}
if (gasProps.lStatus == GasConstants.MAX_NUM_OF_ITERATIONS_EXCEEDED) {
gasProps.lStatus = GasConstants.MAX_NUM_OF_ITERATIONS_EXCEEDED;
}
}
// H 函数
public double H(GasProps gasProps, DetailService detailService) {
double Hinc = 0.0;
gasProps.dHo = Ho(gasProps);
for (int i = 0; i < GK_points; i++) {
double x = gasProps.dDf * (1.0 + GK_root[i]) / 2.0;
detailService.zdetail(x);
detailService.dZdT(x);
detailService.d2ZdT2(x);
Hinc += GK_weight[i] * detailService.ddZdT / x;
if (i == 10) break;
x = gasProps.dDf * (1.0 - GK_root[i]) / 2.0;
detailService.zdetail(x);
detailService.dZdT(x);
detailService.d2ZdT2(x);
Hinc += GK_weight[i] * detailService.ddZdT / x;
}
detailService.zdetail(gasProps.dDf);
detailService.dZdT(gasProps.dDf);
detailService.d2ZdT2(gasProps.dDf);
gasProps.dH = gasProps.dHo + 1000.0 * GasConstants.RGAS * gasProps.dTf * (gasProps.dZf - 1.0 - gasProps.dTf * Hinc * 0.5 * gasProps.dDf) / gasProps.dMrx;
return gasProps.dH;
}
double S(GasProps gasProps, DetailService detailService)
{
double Sinc; double Smixing; double x;
int i;
//initialize integral
Sinc = 0.0;
//initialize entropy of mixing
Smixing = 0.0;
//integrate partial derivatives from D=0 to D=D, applying Gauss-Kronrod quadrature
for (i = 0; i <GK_points ; i++)
{
//calculate 1st and 2nd partial derivatives of Z wrt T
x = gasProps.dDf * (1.0 + GK_root[i]) / 2.0; detailService.zdetail(x);
detailService.dZdT(x); detailService.d2ZdT2(x);
Sinc += GK_weight[i] * (detailService.dZ + gasProps.dTf * detailService.ddZdT - 1.0) / x;
if (i == 10) break;
x = gasProps.dDf * (1.0 - GK_root[i]) / 2.0; detailService.zdetail(x);
detailService.dZdT(x); detailService.d2ZdT2(x);
Sinc += GK_weight[i] * (detailService.dZ + gasProps.dTf * detailService.ddZdT - 1.0) / x;
}
//reset Z and partial deivatives dZdT and d2ZdT2
detailService.zdetail(gasProps.dDf);
detailService.dZdT(gasProps.dDf);
detailService.d2ZdT2(gasProps.dDf);
//find ideal gas entropy, but only if temperature or composition have changed
if (gasProps.dTf != dTold || gasProps.dMrx != dMrxold)
{
dSi = So(gasProps); dTold = gasProps.dTf; dMrxold = gasProps.dMrx;
}
//calculate entropy of mixing
for (i = 0; i < GasConstants.NUMBEROFCOMPONENTS; i++)
{
if (gasProps.adMixture[i] != 0) Smixing += gasProps.adMixture[i] * Math.log(gasProps.adMixture[i]);
}
Smixing *= GasConstants.RGAS;
// calculate specific entropy
gasProps.dS = dSi - Smixing - 1000.0 * GasConstants.RGAS * (Math.log(gasProps.dPf / 101325.0) - Math.log(gasProps.dZf) + Sinc * 0.5 * gasProps.dDf) / gasProps.dMrx;
return (gasProps.dS);
}
}

View File

@ -0,0 +1,29 @@
package com.ruoyi.ngCalTools.utils;
public final class GasConstants {
public static final int NORMAL = 9000;
public static final int NG_Cal_INITIALIZED = 9001;
public static final int MEMORY_ALLOCATION_ERROR = 9002;
public static final int GENERAL_CALCULATION_FAILURE = 9003;
public static final int MAX_NUM_OF_ITERATIONS_EXCEEDED = 9004;
public static final int NEGATIVE_DENSITY_DERIVATIVE = 9005;
public static final int MAX_DENSITY_IN_BRAKET_EXCEEDED = 9006;
/* 天然气组分个数 */
public static final int NUMBEROFCOMPONENTS = 21;
/* maximum number of tries within search routines */
public static final int MAX_NUM_OF_ITERATIONS = 100;
/* default tolerance limits */
public static final double P_CHG_TOL = 0.001; /* 0.001 Pa */
public static final double T_CHG_TOL = 0.001; /* 0.001 of a Kelvin */
/* maximum allowable P & T */
public static final double P_MAX = 1.379e8; // maximum pressure (Pa) ~= 20,000 psi
public static final double P_MIN = 0.0; // maximum pressure = 0
public static final double T_MAX = 473.15; // maximum temperature (K) ~= 392 F
public static final double T_MIN = 143.0; // maximum temperature (K) ~= -200 F
/* universal gas constant, in two configurations */
public static final double RGASKJ = 8.314510e-3; /* in kJ mol^-1 K^-1 */
public static final double RGAS = 8.314510; /* in J mol^-1 K^-1 */
/* the main data structure used by this library */
// 其他常量...
}

View File

@ -25,7 +25,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
* 天然气组分Controller
*
* @author ruoyi
* @date 2025-02-07
* @date 2025-02-09
*/
@RestController
@RequestMapping("/ngtools/components")

View File

@ -25,7 +25,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
* 流量计参数Controller
*
* @author ruoyi
* @date 2025-02-06
* @date 2025-02-09
*/
@RestController
@RequestMapping("/ngtools/meterpar")

View File

@ -25,7 +25,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
* 流量计算结果Controller
*
* @author ruoyi
* @date 2025-02-07
* @date 2025-02-09
*/
@RestController
@RequestMapping("/ngtools/meterresult")

View File

@ -25,7 +25,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
* 天然气物性参数Controller
*
* @author ruoyi
* @date 2025-02-07
* @date 2025-02-09
*/
@RestController
@RequestMapping("/ngtools/ngpar")

View File

@ -9,7 +9,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
* 天然气组分对象 ng_components
*
* @author ruoyi
* @date 2025-02-07
* @date 2025-02-09
*/
public class NgComponents extends BaseEntity
{

View File

@ -9,7 +9,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
* 流量计参数对象 ng_meterpar
*
* @author ruoyi
* @date 2025-02-06
* @date 2025-02-09
*/
public class NgMeterpar extends BaseEntity
{

View File

@ -9,7 +9,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
* 流量计算结果对象 ng_meterresult
*
* @author ruoyi
* @date 2025-02-07
* @date 2025-02-09
*/
public class NgMeterresult extends BaseEntity
{

View File

@ -9,7 +9,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
* 天然气物性参数对象 ng_ngpar
*
* @author ruoyi
* @date 2025-02-07
* @date 2025-02-09
*/
public class NgNgpar extends BaseEntity
{

View File

@ -7,7 +7,7 @@ import com.ruoyi.ngtools.domain.NgComponents;
* 天然气组分Mapper接口
*
* @author ruoyi
* @date 2025-02-07
* @date 2025-02-09
*/
public interface NgComponentsMapper
{

View File

@ -7,7 +7,7 @@ import com.ruoyi.ngtools.domain.NgMeterpar;
* 流量计参数Mapper接口
*
* @author ruoyi
* @date 2025-02-06
* @date 2025-02-09
*/
public interface NgMeterparMapper
{

View File

@ -7,7 +7,7 @@ import com.ruoyi.ngtools.domain.NgMeterresult;
* 流量计算结果Mapper接口
*
* @author ruoyi
* @date 2025-02-07
* @date 2025-02-09
*/
public interface NgMeterresultMapper
{

View File

@ -7,7 +7,7 @@ import com.ruoyi.ngtools.domain.NgNgpar;
* 天然气物性参数Mapper接口
*
* @author ruoyi
* @date 2025-02-07
* @date 2025-02-09
*/
public interface NgNgparMapper
{

View File

@ -7,7 +7,7 @@ import com.ruoyi.ngtools.domain.NgComponents;
* 天然气组分Service接口
*
* @author ruoyi
* @date 2025-02-07
* @date 2025-02-09
*/
public interface INgComponentsService
{

View File

@ -7,7 +7,7 @@ import com.ruoyi.ngtools.domain.NgMeterpar;
* 流量计参数Service接口
*
* @author ruoyi
* @date 2025-02-06
* @date 2025-02-09
*/
public interface INgMeterparService
{

View File

@ -7,7 +7,7 @@ import com.ruoyi.ngtools.domain.NgMeterresult;
* 流量计算结果Service接口
*
* @author ruoyi
* @date 2025-02-07
* @date 2025-02-09
*/
public interface INgMeterresultService
{

View File

@ -7,7 +7,7 @@ import com.ruoyi.ngtools.domain.NgNgpar;
* 天然气物性参数Service接口
*
* @author ruoyi
* @date 2025-02-07
* @date 2025-02-09
*/
public interface INgNgparService
{

View File

@ -12,7 +12,7 @@ import com.ruoyi.ngtools.service.INgComponentsService;
* 天然气组分Service业务层处理
*
* @author ruoyi
* @date 2025-02-07
* @date 2025-02-09
*/
@Service
public class NgComponentsServiceImpl implements INgComponentsService

View File

@ -12,7 +12,7 @@ import com.ruoyi.ngtools.service.INgMeterparService;
* 流量计参数Service业务层处理
*
* @author ruoyi
* @date 2025-02-06
* @date 2025-02-09
*/
@Service
public class NgMeterparServiceImpl implements INgMeterparService

View File

@ -12,7 +12,7 @@ import com.ruoyi.ngtools.service.INgMeterresultService;
* 流量计算结果Service业务层处理
*
* @author ruoyi
* @date 2025-02-07
* @date 2025-02-09
*/
@Service
public class NgMeterresultServiceImpl implements INgMeterresultService

View File

@ -12,7 +12,7 @@ import com.ruoyi.ngtools.service.INgNgparService;
* 天然气物性参数Service业务层处理
*
* @author ruoyi
* @date 2025-02-07
* @date 2025-02-09
*/
@Service
public class NgNgparServiceImpl implements INgNgparService

View File

@ -1,9 +1,6 @@
package com.ruoyi.system.controller;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
@ -22,16 +19,15 @@ import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysTreeDict;
import com.ruoyi.system.service.ISysTreeDictService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 树形字典Controller
*
* @author ruoyi
* @date 2025-02-03
* @date 2025-03-05
*/
@RestController
@RequestMapping("/system/dict")
@RequestMapping("/system/treeDict")
public class SysTreeDictController extends BaseController
{
@Autowired
@ -40,19 +36,18 @@ public class SysTreeDictController extends BaseController
/**
* 查询树形字典列表
*/
@PreAuthorize("@ss.hasPermi('system:dict:list')")
@PreAuthorize("@ss.hasPermi('system:treeDict:list')")
@GetMapping("/list")
public TableDataInfo list(SysTreeDict sysTreeDict)
public AjaxResult list(SysTreeDict sysTreeDict)
{
startPage();
List<SysTreeDict> list = sysTreeDictService.selectSysTreeDictList(sysTreeDict);
return getDataTable(list);
return success(list);
}
/**
* 导出树形字典列表
*/
@PreAuthorize("@ss.hasPermi('system:dict:export')")
@PreAuthorize("@ss.hasPermi('system:treeDict:export')")
@Log(title = "树形字典", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, SysTreeDict sysTreeDict)
@ -65,7 +60,7 @@ public class SysTreeDictController extends BaseController
/**
* 获取树形字典详细信息
*/
@PreAuthorize("@ss.hasPermi('system:dict:query')")
@PreAuthorize("@ss.hasPermi('system:treeDict:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
@ -75,7 +70,7 @@ public class SysTreeDictController extends BaseController
/**
* 新增树形字典
*/
@PreAuthorize("@ss.hasPermi('system:dict:add')")
@PreAuthorize("@ss.hasPermi('system:treeDict:add')")
@Log(title = "树形字典", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody SysTreeDict sysTreeDict)
@ -86,7 +81,7 @@ public class SysTreeDictController extends BaseController
/**
* 修改树形字典
*/
@PreAuthorize("@ss.hasPermi('system:dict:edit')")
@PreAuthorize("@ss.hasPermi('system:treeDict:edit')")
@Log(title = "树形字典", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SysTreeDict sysTreeDict)
@ -97,53 +92,11 @@ public class SysTreeDictController extends BaseController
/**
* 删除树形字典
*/
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
@PreAuthorize("@ss.hasPermi('system:treeDict:remove')")
@Log(title = "树形字典", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(sysTreeDictService.deleteSysTreeDictByIds(ids));
}
//生成树形菜单的形式
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
@Log(title = "树形字典", businessType = BusinessType.DELETE)
@GetMapping("/getTree")
public List<SysTreeDict> buildDictTree(List<SysTreeDict> list) {
List<SysTreeDict> returnList = new ArrayList<>();
List<Long> tempList = list.stream().map(SysTreeDict::getId).collect(Collectors.toList());
for (SysTreeDict dict : list) {
if (!tempList.contains(dict.getPid())) {
recursionFn(list, dict);
returnList.add(dict);
}
}
if (returnList.isEmpty()) {
returnList = list;
}
return returnList;
}
private void recursionFn(List<SysTreeDict> list, SysTreeDict dict) {
List<SysTreeDict> childList = getChildList(list, dict);
dict.setChildren(childList);
for (SysTreeDict child : childList) {
if (hasChild(list, child)) {
recursionFn(list, child);
}
}
}
private List<SysTreeDict> getChildList(List<SysTreeDict> list, SysTreeDict dict) {
return list.stream()
.filter(d -> d.getPid() != null && d.getPid().equals(dict.getId()))
.sorted(Comparator.comparingInt(SysTreeDict::getDictSort))
.collect(Collectors.toList());
}
private boolean hasChild(List<SysTreeDict> list, SysTreeDict dict) {
return list.stream().anyMatch(d -> d.getPid() != null && d.getPid().equals(dict.getId()));
}
}

View File

@ -1,7 +1,12 @@
package com.ruoyi.system.controller;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.system.service.impl.SysUnitConvertServiceImpl;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@ -16,8 +21,8 @@ import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.UnitConversion;
import com.ruoyi.system.service.IUnitConversionService;
import com.ruoyi.system.domain.SysUnitConvert;
import com.ruoyi.system.service.ISysUnitConvertService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
@ -25,80 +30,78 @@ import com.ruoyi.common.core.page.TableDataInfo;
* 单位换算Controller
*
* @author ruoyi
* @date 2025-02-04
* @date 2025-02-09
*/
@RestController
@RequestMapping("/system/conversion")
public class UnitConversionController extends BaseController
{
@RequestMapping("/system/sysUnitConvert")
public class SysUnitConvertController extends BaseController {
@Autowired
private IUnitConversionService unitConversionService;
private ISysUnitConvertService sysUnitConvertService;
/**
* 查询单位换算列表
*/
@PreAuthorize("@ss.hasPermi('system:conversion:list')")
@PreAuthorize("@ss.hasPermi('system:sysUnitConvert:list')")
@GetMapping("/list")
public TableDataInfo list(UnitConversion unitConversion)
{
public TableDataInfo list(SysUnitConvert sysUnitConvert) {
startPage();
List<UnitConversion> list = unitConversionService.selectUnitConversionList(unitConversion);
return getDataTable(list);
List<SysUnitConvert> list = sysUnitConvertService.selectSysUnitConvertList(sysUnitConvert);
TableDataInfo tableDataInfo = getDataTable(list);
return tableDataInfo;
}
/**
* 导出单位换算列表
*/
@PreAuthorize("@ss.hasPermi('system:conversion:export')")
@PreAuthorize("@ss.hasPermi('system:sysUnitConvert:export')")
@Log(title = "单位换算", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, UnitConversion unitConversion)
{
List<UnitConversion> list = unitConversionService.selectUnitConversionList(unitConversion);
ExcelUtil<UnitConversion> util = new ExcelUtil<UnitConversion>(UnitConversion.class);
public void export(HttpServletResponse response, SysUnitConvert sysUnitConvert) {
List<SysUnitConvert> list = sysUnitConvertService.selectSysUnitConvertList(sysUnitConvert);
ExcelUtil<SysUnitConvert> util = new ExcelUtil<SysUnitConvert>(SysUnitConvert.class);
util.exportExcel(response, list, "单位换算数据");
}
/**
* 获取单位换算详细信息
*/
@PreAuthorize("@ss.hasPermi('system:conversion:query')")
@PreAuthorize("@ss.hasPermi('system:sysUnitConvert:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(unitConversionService.selectUnitConversionById(id));
public AjaxResult getInfo(@PathVariable("id") Long id) {
return success(sysUnitConvertService.selectSysUnitConvertById(id));
}
/**
* 新增单位换算
*/
@PreAuthorize("@ss.hasPermi('system:conversion:add')")
@PreAuthorize("@ss.hasPermi('system:sysUnitConvert:add')")
@Log(title = "单位换算", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody UnitConversion unitConversion)
public AjaxResult add(@RequestBody SysUnitConvert sysUnitConvert)
{
return toAjax(unitConversionService.insertUnitConversion(unitConversion));
return toAjax(sysUnitConvertService.insertSysUnitConvert(sysUnitConvert));
}
/**
* 修改单位换算
*/
@PreAuthorize("@ss.hasPermi('system:conversion:edit')")
@PreAuthorize("@ss.hasPermi('system:sysUnitConvert:edit')")
@Log(title = "单位换算", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody UnitConversion unitConversion)
public AjaxResult edit(@RequestBody SysUnitConvert sysUnitConvert)
{
return toAjax(unitConversionService.updateUnitConversion(unitConversion));
return toAjax(sysUnitConvertService.updateSysUnitConvert(sysUnitConvert));
}
/**
* 删除单位换算
*/
@PreAuthorize("@ss.hasPermi('system:conversion:remove')")
@PreAuthorize("@ss.hasPermi('system:sysUnitConvert:remove')")
@Log(title = "单位换算", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(unitConversionService.deleteUnitConversionByIds(ids));
return toAjax(sysUnitConvertService.deleteSysUnitConvertByIds(ids));
}
}

View File

@ -0,0 +1,100 @@
package com.ruoyi.system.controller;
import com.ruoyi.system.domain.SysUnitConvert;
import com.ruoyi.system.service.ISysUnitConvertService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.math.RoundingMode;
@Component
public class UnitConvert {
private final ISysUnitConvertService sysUnitConvertService;
@Autowired
public UnitConvert(ISysUnitConvertService sysUnitConvertService) {
this.sysUnitConvertService = sysUnitConvertService;
}
public double ConvertUniter(String unitType, double oldValue, int oldUnit, int newUnit) {
// 查询旧单位信息
if ("temperature".equalsIgnoreCase(unitType)) {
return handleTemperatureConversion(BigDecimal.valueOf(oldValue), (long) oldUnit, (long) newUnit).doubleValue();
} else {
SysUnitConvert tempUnit = new SysUnitConvert();
tempUnit.setUnitType(unitType);
tempUnit.setUnitOrder((long) oldUnit);
SysUnitConvert oldUnitInfo = sysUnitConvertService.selectSysUnitConvertUnitByTypeOrder(tempUnit);
if (oldUnitInfo == null) {
throw new IllegalArgumentException("旧单位 '" + oldUnit + "' 不存在或不可用");
}
tempUnit=new SysUnitConvert();;
tempUnit.setUnitType(unitType);
tempUnit.setBaseUnit("Y");
SysUnitConvert baseUnitInfo = sysUnitConvertService.selectSysUnitConvertUnitByTypeOrder(tempUnit);
if (baseUnitInfo == null) {
throw new IllegalArgumentException("基准单位 不存在或不可用");
}
tempUnit=new SysUnitConvert();
tempUnit.setUnitType(unitType);
tempUnit.setUnitOrder((long) newUnit);
// 查询新单位信息
SysUnitConvert newUnitInfo = sysUnitConvertService.selectSysUnitConvertUnitByTypeOrder(tempUnit);
if (newUnitInfo == null) {
throw new IllegalArgumentException("新单位 '" + newUnit + "' 不存在或不可用");
}
BigDecimal oldFactor = oldUnitInfo.getConversionFactor();
BigDecimal newFactor = newUnitInfo.getConversionFactor();
// 检查旧单位转换因子是否为零
if (oldFactor.compareTo(BigDecimal.ZERO) == 0) {
throw new ArithmeticException("旧单位 '" + oldUnit + "' 的转换因子为零,无法进行转换");
}
// 计算基准值oldValue / oldFactor
int scale = 20; // 设置足够大的精度以避免精度丢失
BigDecimal baseValue = BigDecimal.valueOf(oldValue).divide(oldFactor, scale, RoundingMode.HALF_UP);
// 计算新值baseValue * newFactor
BigDecimal newValue = baseValue.multiply(newFactor);
// 四舍五入到合理的小数位数例如10位
newValue = newValue.setScale(10, RoundingMode.HALF_UP);
return newValue.doubleValue();
}
}
// 温度转换方法
public BigDecimal handleTemperatureConversion(BigDecimal oldValue, Long oldUnit, Long newUnit) {
final BigDecimal THIRTY_TWO = BigDecimal.valueOf(32);
final BigDecimal FIVE = BigDecimal.valueOf(5);
final BigDecimal NINE = BigDecimal.valueOf(9);
final BigDecimal TWO_HUNDRED_SEVENTY_THREE_POINT_ONE_FIVE = BigDecimal.valueOf(273.15);
// 使用原始值计算
BigDecimal celsius;
if (oldUnit == 0) {
celsius = oldValue;
} else if (oldUnit == 1) {
celsius = oldValue.subtract(THIRTY_TWO).multiply(FIVE).divide(NINE, 10, RoundingMode.HALF_UP);
} else if (oldUnit == 2) {
celsius = oldValue.subtract(TWO_HUNDRED_SEVENTY_THREE_POINT_ONE_FIVE);
} else {
throw new IllegalArgumentException("无效温度单位");
}
if (newUnit == 0) {
return celsius;
} else if (newUnit == 1) {
return celsius.multiply(NINE).divide(FIVE, 10, RoundingMode.HALF_UP).add(THIRTY_TWO);
} else if (newUnit == 2) {
return celsius.add(TWO_HUNDRED_SEVENTY_THREE_POINT_ONE_FIVE);
}
throw new IllegalArgumentException("无效温度单位");
}
}

View File

@ -1,26 +1,17 @@
package com.ruoyi.system.domain;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import java.util.ArrayList;
import java.util.List;
import com.ruoyi.common.core.domain.TreeEntity;
/**
* 树形字典对象 sys_tree_dict
*
* @author ruoyi
* @date 2025-02-03
* @date 2025-03-05
*/
@Data
@TableName("sys_tree_dict")
public class SysTreeDict extends BaseEntity
public class SysTreeDict extends TreeEntity
{
private static final long serialVersionUID = 1L;
@ -115,15 +106,6 @@ public class SysTreeDict extends BaseEntity
return status;
}
@TableField(exist = false)
private List<SysTreeDict> children = new ArrayList<>();
// 显式补充 children setter 方法
public void setChildren(List<SysTreeDict> children) {
this.children = children;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

View File

@ -1,43 +1,52 @@
package com.ruoyi.system.domain;
import java.math.BigDecimal;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 单位换算对象 unit_conversion
* 单位换算对象 sys_unit_convert
*
* @author ruoyi
* @date 2025-02-04
* @date 2025-02-09
*/
public class UnitConversion extends BaseEntity
public class SysUnitConvert extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** $column.columnComment */
/** 编号 */
private Long id;
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
/** 单位类型 */
@Excel(name = "单位类型")
private String unitType;
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
/** 单位名称 */
@Excel(name = "单位名称")
private String unitName;
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private Integer baseUnit;
/** 是否基准 */
@Excel(name = "是否基准")
private String baseUnit;
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private String conversionFactor;
/** 换算因子 */
@Excel(name = "换算因子")
private BigDecimal conversionFactor;
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
/** 类型名称 */
@Excel(name = "类型名称")
private String unitTypeName;
/** 状态 */
@Excel(name = "状态")
private String status;
/** 单位序号 */
@Excel(name = "单位序号")
private Long unitOrder;
public void setId(Long id)
{
this.id = id;
@ -65,21 +74,21 @@ public class UnitConversion extends BaseEntity
{
return unitName;
}
public void setBaseUnit(Integer baseUnit)
public void setBaseUnit(String baseUnit)
{
this.baseUnit = baseUnit;
}
public Integer getBaseUnit()
public String getBaseUnit()
{
return baseUnit;
}
public void setConversionFactor(String conversionFactor)
public void setConversionFactor(BigDecimal conversionFactor)
{
this.conversionFactor = conversionFactor;
}
public String getConversionFactor()
public BigDecimal getConversionFactor()
{
return conversionFactor;
}
@ -92,6 +101,24 @@ public class UnitConversion extends BaseEntity
{
return unitTypeName;
}
public void setStatus(String status)
{
this.status = status;
}
public String getStatus()
{
return status;
}
public void setUnitOrder(Long unitOrder)
{
this.unitOrder = unitOrder;
}
public Long getUnitOrder()
{
return unitOrder;
}
@Override
public String toString() {
@ -102,6 +129,8 @@ public class UnitConversion extends BaseEntity
.append("baseUnit", getBaseUnit())
.append("conversionFactor", getConversionFactor())
.append("unitTypeName", getUnitTypeName())
.append("status", getStatus())
.append("unitOrder", getUnitOrder())
.toString();
}
}

View File

@ -7,7 +7,7 @@ import com.ruoyi.system.domain.SysTreeDict;
* 树形字典Mapper接口
*
* @author ruoyi
* @date 2025-02-03
* @date 2025-03-05
*/
public interface SysTreeDictMapper
{

View File

@ -0,0 +1,70 @@
package com.ruoyi.system.mapper;
import java.util.List;
import com.ruoyi.system.domain.SysUnitConvert;
/**
* 单位换算Mapper接口
*
* @author ruoyi
* @date 2025-02-09
*/
public interface SysUnitConvertMapper
{
/**
* 查询单位换算
*
* @param id 单位换算主键
* @return 单位换算
*/
public SysUnitConvert selectSysUnitConvertById(Long id);
/**
* 查询单位换算列表
*
* @param sysUnitConvert 单位换算
* @return 单位换算集合
*/
public List<SysUnitConvert> selectSysUnitConvertList(SysUnitConvert sysUnitConvert);
/**
* 新增单位换算
*
* @param sysUnitConvert 单位换算
* @return 结果
*/
public int insertSysUnitConvert(SysUnitConvert sysUnitConvert);
/**
* 修改单位换算
*
* @param sysUnitConvert 单位换算
* @return 结果
*/
public int updateSysUnitConvert(SysUnitConvert sysUnitConvert);
/**
* 删除单位换算
*
* @param id 单位换算主键
* @return 结果
*/
public int deleteSysUnitConvertById(Long id);
/**
* 批量删除单位换算
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteSysUnitConvertByIds(Long[] ids);
/**
* 查询单位换算
*
* @param sysUnitConvert 需要删除的数据主键集合
* @return 结果
*/
public SysUnitConvert selectSysUnitConvertUnitByTypeOrder(SysUnitConvert sysUnitConvert);
}

View File

@ -1,61 +0,0 @@
package com.ruoyi.system.mapper;
import java.util.List;
import com.ruoyi.system.domain.UnitConversion;
/**
* 单位换算Mapper接口
*
* @author ruoyi
* @date 2025-02-04
*/
public interface UnitConversionMapper
{
/**
* 查询单位换算
*
* @param id 单位换算主键
* @return 单位换算
*/
public UnitConversion selectUnitConversionById(Long id);
/**
* 查询单位换算列表
*
* @param unitConversion 单位换算
* @return 单位换算集合
*/
public List<UnitConversion> selectUnitConversionList(UnitConversion unitConversion);
/**
* 新增单位换算
*
* @param unitConversion 单位换算
* @return 结果
*/
public int insertUnitConversion(UnitConversion unitConversion);
/**
* 修改单位换算
*
* @param unitConversion 单位换算
* @return 结果
*/
public int updateUnitConversion(UnitConversion unitConversion);
/**
* 删除单位换算
*
* @param id 单位换算主键
* @return 结果
*/
public int deleteUnitConversionById(Long id);
/**
* 批量删除单位换算
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteUnitConversionByIds(Long[] ids);
}

View File

@ -7,7 +7,7 @@ import com.ruoyi.system.domain.SysTreeDict;
* 树形字典Service接口
*
* @author ruoyi
* @date 2025-02-03
* @date 2025-03-05
*/
public interface ISysTreeDictService
{

View File

@ -0,0 +1,69 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.system.domain.SysUnitConvert;
/**
* 单位换算Service接口
*
* @author ruoyi
* @date 2025-02-09
*/
public interface ISysUnitConvertService
{
/**
* 查询单位换算
*
* @param id 单位换算主键
* @return 单位换算
*/
public SysUnitConvert selectSysUnitConvertById(Long id);
/**
* 查询单位换算列表
*
* @param sysUnitConvert 单位换算
* @return 单位换算集合
*/
public List<SysUnitConvert> selectSysUnitConvertList(SysUnitConvert sysUnitConvert);
/**
* 查询单位
*
* @param sysUnitConvert 单位换算
* @return 单位换算集合
*/
public SysUnitConvert selectSysUnitConvertUnitByTypeOrder(SysUnitConvert sysUnitConvert);
/**
* 新增单位换算
*
* @param sysUnitConvert 单位换算
* @return 结果
*/
public int insertSysUnitConvert(SysUnitConvert sysUnitConvert);
/**
* 修改单位换算
*
* @param sysUnitConvert 单位换算
* @return 结果
*/
public int updateSysUnitConvert(SysUnitConvert sysUnitConvert);
/**
* 批量删除单位换算
*
* @param ids 需要删除的单位换算主键集合
* @return 结果
*/
public int deleteSysUnitConvertByIds(Long[] ids);
/**
* 删除单位换算信息
*
* @param id 单位换算主键
* @return 结果
*/
public int deleteSysUnitConvertById(Long id);
}

View File

@ -1,61 +0,0 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.system.domain.UnitConversion;
/**
* 单位换算Service接口
*
* @author ruoyi
* @date 2025-02-04
*/
public interface IUnitConversionService
{
/**
* 查询单位换算
*
* @param id 单位换算主键
* @return 单位换算
*/
public UnitConversion selectUnitConversionById(Long id);
/**
* 查询单位换算列表
*
* @param unitConversion 单位换算
* @return 单位换算集合
*/
public List<UnitConversion> selectUnitConversionList(UnitConversion unitConversion);
/**
* 新增单位换算
*
* @param unitConversion 单位换算
* @return 结果
*/
public int insertUnitConversion(UnitConversion unitConversion);
/**
* 修改单位换算
*
* @param unitConversion 单位换算
* @return 结果
*/
public int updateUnitConversion(UnitConversion unitConversion);
/**
* 批量删除单位换算
*
* @param ids 需要删除的单位换算主键集合
* @return 结果
*/
public int deleteUnitConversionByIds(Long[] ids);
/**
* 删除单位换算信息
*
* @param id 单位换算主键
* @return 结果
*/
public int deleteUnitConversionById(Long id);
}

View File

@ -12,7 +12,7 @@ import com.ruoyi.system.service.ISysTreeDictService;
* 树形字典Service业务层处理
*
* @author ruoyi
* @date 2025-02-03
* @date 2025-03-05
*/
@Service
public class SysTreeDictServiceImpl implements ISysTreeDictService

View File

@ -0,0 +1,107 @@
package com.ruoyi.system.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.SysUnitConvertMapper;
import com.ruoyi.system.domain.SysUnitConvert;
import com.ruoyi.system.service.ISysUnitConvertService;
/**
* 单位换算Service业务层处理
*
* @author ruoyi
* @date 2025-02-09
*/
@Service
public class SysUnitConvertServiceImpl implements ISysUnitConvertService
{
@Autowired
private SysUnitConvertMapper sysUnitConvertMapper;
/**
* 查询单位换算
*
* @param id 单位换算主键
* @return 单位换算
*/
@Override
public SysUnitConvert selectSysUnitConvertById(Long id)
{
return sysUnitConvertMapper.selectSysUnitConvertById(id);
}
/**
* 查询单位换算列表
*
* @param sysUnitConvert 单位换算
* @return 单位换算
*/
@Override
public List<SysUnitConvert> selectSysUnitConvertList(SysUnitConvert sysUnitConvert)
{
return sysUnitConvertMapper.selectSysUnitConvertList(sysUnitConvert);
}
/**
* 查询单位换算
*
* @param sysUnitConvert 单位换算
* @return 单位换算
*/
@Override
public SysUnitConvert selectSysUnitConvertUnitByTypeOrder(SysUnitConvert sysUnitConvert) {
return sysUnitConvertMapper.selectSysUnitConvertUnitByTypeOrder(sysUnitConvert);
}
/**
* 新增单位换算
*
* @param sysUnitConvert 单位换算
* @return 结果
*/
@Override
public int insertSysUnitConvert(SysUnitConvert sysUnitConvert)
{
return sysUnitConvertMapper.insertSysUnitConvert(sysUnitConvert);
}
/**
* 修改单位换算
*
* @param sysUnitConvert 单位换算
* @return 结果
*/
@Override
public int updateSysUnitConvert(SysUnitConvert sysUnitConvert)
{
return sysUnitConvertMapper.updateSysUnitConvert(sysUnitConvert);
}
/**
* 批量删除单位换算
*
* @param ids 需要删除的单位换算主键
* @return 结果
*/
@Override
public int deleteSysUnitConvertByIds(Long[] ids)
{
return sysUnitConvertMapper.deleteSysUnitConvertByIds(ids);
}
/**
* 删除单位换算信息
*
* @param id 单位换算主键
* @return 结果
*/
@Override
public int deleteSysUnitConvertById(Long id)
{
return sysUnitConvertMapper.deleteSysUnitConvertById(id);
}
}

View File

@ -1,93 +0,0 @@
package com.ruoyi.system.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.UnitConversionMapper;
import com.ruoyi.system.domain.UnitConversion;
import com.ruoyi.system.service.IUnitConversionService;
/**
* 单位换算Service业务层处理
*
* @author ruoyi
* @date 2025-02-04
*/
@Service
public class UnitConversionServiceImpl implements IUnitConversionService
{
@Autowired
private UnitConversionMapper unitConversionMapper;
/**
* 查询单位换算
*
* @param id 单位换算主键
* @return 单位换算
*/
@Override
public UnitConversion selectUnitConversionById(Long id)
{
return unitConversionMapper.selectUnitConversionById(id);
}
/**
* 查询单位换算列表
*
* @param unitConversion 单位换算
* @return 单位换算
*/
@Override
public List<UnitConversion> selectUnitConversionList(UnitConversion unitConversion)
{
return unitConversionMapper.selectUnitConversionList(unitConversion);
}
/**
* 新增单位换算
*
* @param unitConversion 单位换算
* @return 结果
*/
@Override
public int insertUnitConversion(UnitConversion unitConversion)
{
return unitConversionMapper.insertUnitConversion(unitConversion);
}
/**
* 修改单位换算
*
* @param unitConversion 单位换算
* @return 结果
*/
@Override
public int updateUnitConversion(UnitConversion unitConversion)
{
return unitConversionMapper.updateUnitConversion(unitConversion);
}
/**
* 批量删除单位换算
*
* @param ids 需要删除的单位换算主键
* @return 结果
*/
@Override
public int deleteUnitConversionByIds(Long[] ids)
{
return unitConversionMapper.deleteUnitConversionByIds(ids);
}
/**
* 删除单位换算信息
*
* @param id 单位换算主键
* @return 结果
*/
@Override
public int deleteUnitConversionById(Long id)
{
return unitConversionMapper.deleteUnitConversionById(id);
}
}

View File

@ -0,0 +1,111 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.SysUnitConvertMapper">
<resultMap type="SysUnitConvert" id="SysUnitConvertResult">
<result property="id" column="id"/>
<result property="unitType" column="unit_type"/>
<result property="unitName" column="unit_name"/>
<result property="baseUnit" column="base_unit"/>
<result property="conversionFactor" column="conversion_factor"/>
<result property="unitTypeName" column="unit_type_name"/>
<result property="status" column="status"/>
<result property="unitOrder" column="unit_order"/>
</resultMap>
<sql id="selectSysUnitConvertVo">
select id,
unit_type,
unit_name,
base_unit,
conversion_factor,
unit_type_name,
status,
unit_order
from sys_unit_convert
</sql>
<select id="selectSysUnitConvertList" parameterType="SysUnitConvert" resultMap="SysUnitConvertResult">
<include refid="selectSysUnitConvertVo"/>
<where>
<if test="unitType != null and unitType != ''">and unit_type = #{unitType}</if>
<if test="unitName != null and unitName != ''">and unit_name like concat('%', #{unitName}, '%')</if>
<if test="baseUnit != null and baseUnit != ''">and base_unit = #{baseUnit}</if>
<if test="conversionFactor != null ">and conversion_factor = #{conversionFactor}</if>
<if test="unitTypeName != null and unitTypeName != ''">and unit_type_name like concat('%', #{unitTypeName},
'%')
</if>
<if test="status != null and status != ''">and status = #{status}</if>
<if test="unitOrder != null ">and unit_order = #{unitOrder}</if>
</where>
</select>
<select id="selectSysUnitConvertUnitByTypeOrder" parameterType="SysUnitConvert"
resultMap="SysUnitConvertResult">
<!-- 这里编写具体的 SQL 查询语句 -->
<include refid="selectSysUnitConvertVo"/>
<where>
<if test="unitType != null and unitType != ''">and unit_type = #{unitType}</if>
<if test="unitOrder != null ">and unit_order = #{unitOrder}</if>
<if test="baseUnit != null and baseUnit != ''">and base_unit = #{baseUnit}</if>
</where>
</select>
<select id="selectSysUnitConvertById" parameterType="Long" resultMap="SysUnitConvertResult">
<include refid="selectSysUnitConvertVo"/>
where id = #{id}
</select>
<insert id="insertSysUnitConvert" parameterType="SysUnitConvert" useGeneratedKeys="true" keyProperty="id">
insert into sys_unit_convert
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="unitType != null and unitType != ''">unit_type,</if>
<if test="unitName != null and unitName != ''">unit_name,</if>
<if test="baseUnit != null">base_unit,</if>
<if test="conversionFactor != null">conversion_factor,</if>
<if test="unitTypeName != null and unitTypeName != ''">unit_type_name,</if>
<if test="status != null">status,</if>
<if test="unitOrder != null">unit_order,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="unitType != null and unitType != ''">#{unitType},</if>
<if test="unitName != null and unitName != ''">#{unitName},</if>
<if test="baseUnit != null">#{baseUnit},</if>
<if test="conversionFactor != null">#{conversionFactor},</if>
<if test="unitTypeName != null and unitTypeName != ''">#{unitTypeName},</if>
<if test="status != null">#{status},</if>
<if test="unitOrder != null">#{unitOrder},</if>
</trim>
</insert>
<update id="updateSysUnitConvert" parameterType="SysUnitConvert">
update sys_unit_convert
<trim prefix="SET" suffixOverrides=",">
<if test="unitType != null and unitType != ''">unit_type = #{unitType},</if>
<if test="unitName != null and unitName != ''">unit_name = #{unitName},</if>
<if test="baseUnit != null">base_unit = #{baseUnit},</if>
<if test="conversionFactor != null">conversion_factor = #{conversionFactor},</if>
<if test="unitTypeName != null and unitTypeName != ''">unit_type_name = #{unitTypeName},</if>
<if test="status != null">status = #{status},</if>
<if test="unitOrder != null">unit_order = #{unitOrder},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteSysUnitConvertById" parameterType="Long">
delete
from sys_unit_convert
where id = #{id}
</delete>
<delete id="deleteSysUnitConvertByIds" parameterType="String">
delete from sys_unit_convert where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -1,76 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.UnitConversionMapper">
<resultMap type="UnitConversion" id="UnitConversionResult">
<result property="id" column="id" />
<result property="unitType" column="unit_type" />
<result property="unitName" column="unit_name" />
<result property="baseUnit" column="base_unit" />
<result property="conversionFactor" column="conversion_factor" />
<result property="unitTypeName" column="unit_type_name" />
</resultMap>
<sql id="selectUnitConversionVo">
select id, unit_type, unit_name, base_unit, conversion_factor, unit_type_name from unit_conversion
</sql>
<select id="selectUnitConversionList" parameterType="UnitConversion" resultMap="UnitConversionResult">
<include refid="selectUnitConversionVo"/>
<where>
<if test="unitType != null and unitType != ''"> and unit_type = #{unitType}</if>
<if test="unitName != null and unitName != ''"> and unit_name like concat('%', #{unitName}, '%')</if>
<if test="baseUnit != null "> and base_unit = #{baseUnit}</if>
<if test="conversionFactor != null and conversionFactor != ''"> and conversion_factor = #{conversionFactor}</if>
<if test="unitTypeName != null and unitTypeName != ''"> and unit_type_name like concat('%', #{unitTypeName}, '%')</if>
</where>
</select>
<select id="selectUnitConversionById" parameterType="Long" resultMap="UnitConversionResult">
<include refid="selectUnitConversionVo"/>
where id = #{id}
</select>
<insert id="insertUnitConversion" parameterType="UnitConversion" useGeneratedKeys="true" keyProperty="id">
insert into unit_conversion
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="unitType != null and unitType != ''">unit_type,</if>
<if test="unitName != null and unitName != ''">unit_name,</if>
<if test="baseUnit != null">base_unit,</if>
<if test="conversionFactor != null">conversion_factor,</if>
<if test="unitTypeName != null and unitTypeName != ''">unit_type_name,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="unitType != null and unitType != ''">#{unitType},</if>
<if test="unitName != null and unitName != ''">#{unitName},</if>
<if test="baseUnit != null">#{baseUnit},</if>
<if test="conversionFactor != null">#{conversionFactor},</if>
<if test="unitTypeName != null and unitTypeName != ''">#{unitTypeName},</if>
</trim>
</insert>
<update id="updateUnitConversion" parameterType="UnitConversion">
update unit_conversion
<trim prefix="SET" suffixOverrides=",">
<if test="unitType != null and unitType != ''">unit_type = #{unitType},</if>
<if test="unitName != null and unitName != ''">unit_name = #{unitName},</if>
<if test="baseUnit != null">base_unit = #{baseUnit},</if>
<if test="conversionFactor != null">conversion_factor = #{conversionFactor},</if>
<if test="unitTypeName != null and unitTypeName != ''">unit_type_name = #{unitTypeName},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteUnitConversionById" parameterType="Long">
delete from unit_conversion where id = #{id}
</delete>
<delete id="deleteUnitConversionByIds" parameterType="String">
delete from unit_conversion where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -1,6 +1,6 @@
-- 菜单 SQL
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('天然气组分', '3', '1', 'components', 'ngtools/components/index', 1, 0, 'C', '0', '0', 'ngtools:components:list', '#', 'admin', sysdate(), '', null, '天然气组分菜单');
values('天然气组分', '2067', '1', 'components', 'ngtools/components/index', 1, 0, 'C', '0', '0', 'ngtools:components:list', '#', 'admin', sysdate(), '', null, '天然气组分菜单');
-- 按钮父菜单ID
SELECT @parentId := LAST_INSERT_ID();

View File

@ -1,6 +1,6 @@
-- 菜单 SQL
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('流量计参数', '2024', '1', 'meterpar', 'ngtools/meterpar/index', 1, 0, 'C', '0', '0', 'ngtools:meterpar:list', '#', 'admin', sysdate(), '', null, '流量计参数菜单');
values('流量计参数', '2067', '1', 'meterpar', 'ngtools/meterpar/index', 1, 0, 'C', '0', '0', 'ngtools:meterpar:list', '#', 'admin', sysdate(), '', null, '流量计参数菜单');
-- 按钮父菜单ID
SELECT @parentId := LAST_INSERT_ID();

View File

@ -1,6 +1,6 @@
-- 菜单 SQL
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('流量计算结果', '2024', '1', 'meterresult', 'ngtools/meterresult/index', 1, 0, 'C', '0', '0', 'ngtools:meterresult:list', '#', 'admin', sysdate(), '', null, '流量计算结果菜单');
values('流量计算结果', '2067', '1', 'meterresult', 'ngtools/meterresult/index', 1, 0, 'C', '0', '0', 'ngtools:meterresult:list', '#', 'admin', sysdate(), '', null, '流量计算结果菜单');
-- 按钮父菜单ID
SELECT @parentId := LAST_INSERT_ID();

View File

@ -1,6 +1,6 @@
-- 菜单 SQL
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('天然气物性参数', '2024', '1', 'ngpar', 'ngtools/ngpar/index', 1, 0, 'C', '0', '0', 'ngtools:ngpar:list', '#', 'admin', sysdate(), '', null, '天然气物性参数菜单');
values('天然气物性参数', '2067', '1', 'ngpar', 'ngtools/ngpar/index', 1, 0, 'C', '0', '0', 'ngtools:ngpar:list', '#', 'admin', sysdate(), '', null, '天然气物性参数菜单');
-- 按钮父菜单ID
SELECT @parentId := LAST_INSERT_ID();

View File

@ -0,0 +1,22 @@
-- 菜单 SQL
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('单位换算', '1', '1', 'sysUnitConvert', 'system/sysUnitConvert/index', 1, 0, 'C', '0', '0', 'system:sysUnitConvert:list', '#', 'admin', sysdate(), '', null, '单位换算菜单');
-- 按钮父菜单ID
SELECT @parentId := LAST_INSERT_ID();
-- 按钮 SQL
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('单位换算查询', @parentId, '1', '#', '', 1, 0, 'F', '0', '0', 'system:sysUnitConvert:query', '#', 'admin', sysdate(), '', null, '');
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('单位换算新增', @parentId, '2', '#', '', 1, 0, 'F', '0', '0', 'system:sysUnitConvert:add', '#', 'admin', sysdate(), '', null, '');
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('单位换算修改', @parentId, '3', '#', '', 1, 0, 'F', '0', '0', 'system:sysUnitConvert:edit', '#', 'admin', sysdate(), '', null, '');
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('单位换算删除', @parentId, '4', '#', '', 1, 0, 'F', '0', '0', 'system:sysUnitConvert:remove', '#', 'admin', sysdate(), '', null, '');
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('单位换算导出', @parentId, '5', '#', '', 1, 0, 'F', '0', '0', 'system:sysUnitConvert:export', '#', 'admin', sysdate(), '', null, '');