294 lines
6.6 KiB
C#
294 lines
6.6 KiB
C#
using Dapper;
|
|
using MySql.Data.MySqlClient;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace 材料热传导系数
|
|
{
|
|
public class ConductivityTestData
|
|
{
|
|
public int Id { get; set; }
|
|
|
|
/// <summary>
|
|
/// 条码(保留用于兼容性)
|
|
/// </summary>
|
|
public string barcode { get; set; }
|
|
|
|
/// <summary>
|
|
/// 联络单号
|
|
/// </summary>
|
|
public string ContactNumber { get; set; }
|
|
|
|
/// <summary>
|
|
/// 件号
|
|
/// </summary>
|
|
public string ItemNumber { get; set; }
|
|
|
|
/// <summary>
|
|
/// 温度
|
|
/// </summary>
|
|
public double temperature { get; set; }
|
|
|
|
/// <summary>
|
|
/// 初始压力
|
|
/// </summary>
|
|
public double startpressure { get; set; }
|
|
|
|
/// <summary>
|
|
/// 保压时间
|
|
/// </summary>
|
|
public double dwelltime { get; set; }
|
|
|
|
/// <summary>
|
|
/// 压差
|
|
/// </summary>
|
|
public double diffpressure { get; set; }
|
|
|
|
/// <summary>
|
|
/// 结束压力
|
|
/// </summary>
|
|
public double endpressure { get; set; }
|
|
|
|
public DateTime CreateTime { get; set; }
|
|
|
|
/// <summary>
|
|
/// 普通0高温1
|
|
/// </summary>
|
|
public int Type { get; set; }
|
|
|
|
|
|
|
|
|
|
public string kzh { get; set; }
|
|
public DateTime? starttime { get; set; }
|
|
public DateTime? endtime { get; set; }
|
|
public string lldh { get; set; }
|
|
public string jh { get; set; }
|
|
public int quantity { get; set; }
|
|
public decimal? standarderror { get; set; }
|
|
public string testresult { get; set; }
|
|
|
|
|
|
|
|
}
|
|
|
|
public class ScanData
|
|
{
|
|
public int Id { get; set; }
|
|
|
|
/// <summary>
|
|
/// 条码(保留用于兼容性)
|
|
/// </summary>
|
|
public string barcode { get; set; }
|
|
|
|
/// <summary>
|
|
/// 联络单号
|
|
/// </summary>
|
|
public string ContactNumber { get; set; }
|
|
|
|
/// <summary>
|
|
/// 件号
|
|
/// </summary>
|
|
public string ItemNumber { get; set; }
|
|
|
|
/// <summary>
|
|
/// 刻字号
|
|
/// </summary>
|
|
public string EngravingNumber { get; set; }
|
|
|
|
/// <summary>
|
|
/// 数量
|
|
/// </summary>
|
|
public int Quantity { get; set; }
|
|
|
|
/// <summary>
|
|
/// 压力
|
|
/// </summary>
|
|
public float diffpressure { get; set; }
|
|
|
|
/// <summary>
|
|
/// 出口温度
|
|
/// </summary>
|
|
public float exit_temperature { get; set; }
|
|
|
|
/// <summary>
|
|
/// 温度
|
|
/// </summary>
|
|
public float temperature { get; set; }
|
|
|
|
/// <summary>
|
|
/// 保压时间
|
|
/// </summary>
|
|
public float dwelltime { get; set; }
|
|
|
|
/// <summary>
|
|
/// 压差设置
|
|
/// </summary>
|
|
public float PressureDifference { get; set; }
|
|
|
|
/// <summary>
|
|
/// 标准误差
|
|
/// </summary>
|
|
public float StandardError { get; set; }
|
|
|
|
public DateTime CreateTime { get; set; }
|
|
|
|
/// <summary>
|
|
///高温模式 1是0否
|
|
/// </summary>
|
|
public bool IsHighMode { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
///模式选择
|
|
/// </summary>
|
|
public string TemperatureMode { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public string kzh { get; set; }
|
|
|
|
public string lldh { get; set; }
|
|
public string jh { get; set; }
|
|
public int? quantity { get; set; }
|
|
public float? pressuresetting { get; set; }
|
|
public decimal? standarderror { get; set; }
|
|
|
|
}
|
|
|
|
|
|
public class ConductivityRepository
|
|
{
|
|
|
|
public readonly string _connectionString;
|
|
|
|
public ConductivityRepository()
|
|
{
|
|
_connectionString = "Server=localhost;Database=fullautowaterpressure;User=root;Password=123456;port=3306;charset=utf8;";
|
|
}
|
|
|
|
public void InsertReportItems(ConductivityTestData data)
|
|
{
|
|
using (var connection = new MySqlConnection(_connectionString))
|
|
{
|
|
connection.Open();
|
|
var sql = @"INSERT INTO normaltemperature (
|
|
barcode,
|
|
ContactNumber,
|
|
ItemNumber,
|
|
temperature,
|
|
startpressure,
|
|
dwelltime,
|
|
diffpressure,
|
|
endpressure,
|
|
CreateTime,
|
|
type,
|
|
kzh,
|
|
starttime,
|
|
endtime,
|
|
lldh,
|
|
jh,
|
|
quantity,
|
|
standarderror,
|
|
testresult
|
|
)
|
|
VALUES
|
|
(
|
|
@barcode,
|
|
@ContactNumber,
|
|
@ItemNumber,
|
|
@temperature,
|
|
@startpressure,
|
|
@dwelltime,
|
|
@diffpressure,
|
|
@endpressure,
|
|
CURRENT_TIMESTAMP,
|
|
@type, @kzh,
|
|
@starttime,
|
|
@endtime,
|
|
@lldh,
|
|
@jh,
|
|
@quantity,
|
|
@standarderror,
|
|
@testresult )";
|
|
connection.Execute(sql, data);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void InsertScanItems(ScanData data)
|
|
{
|
|
using (var connection = new MySqlConnection(_connectionString))
|
|
{
|
|
connection.Open();
|
|
var sql = @"INSERT INTO scandata
|
|
(barcode, ContactNumber, ItemNumber, diffpressure, exit_temperature, temperature, dwelltime, CreateTime, TemperatureMode,
|
|
kzh,
|
|
lldh,
|
|
jh,
|
|
quantity ,
|
|
pressuresetting ,
|
|
standarderror)
|
|
VALUES
|
|
(@barcode, @ContactNumber, @ItemNumber, @diffpressure, @exit_temperature, @temperature, @dwelltime, CURRENT_TIMESTAMP, @TemperatureMode,
|
|
kzh,
|
|
lldh,
|
|
jh,
|
|
quantity,
|
|
pressuresetting,
|
|
standarderror
|
|
)";
|
|
connection.Execute(sql, data);
|
|
}
|
|
}
|
|
|
|
public void DeleteScanItems(int id)
|
|
{
|
|
using (var connection = new MySqlConnection(_connectionString))
|
|
{
|
|
connection.Open();
|
|
var sql = @"delete from scandata where id=@id
|
|
";
|
|
connection.Execute(sql, new { id });
|
|
}
|
|
}
|
|
|
|
public List<ScanData> GetScanData()
|
|
{
|
|
using (var connection = new MySqlConnection(_connectionString))
|
|
{
|
|
connection.Open();
|
|
var sql = @"SELECT * FROM scandata
|
|
|
|
ORDER BY id asc ";
|
|
return connection.Query<ScanData>(sql).ToList();
|
|
}
|
|
}
|
|
|
|
|
|
public bool TestConnection()
|
|
{
|
|
try
|
|
{
|
|
using (var connection = new MySqlConnection(_connectionString))
|
|
{
|
|
connection.Open();
|
|
return connection.State == ConnectionState.Open;
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|