add - 添加投料记录保存上传至MES

master
wenjy 8 months ago
parent 67e24ac95f
commit 43ff109153

@ -0,0 +1,150 @@
using System;
using SqlSugar;
namespace SlnMesnac.Model.domain
{
/// <summary>
/// Mes投料记录
/// </summary>
[SugarTable("Pstmminjar"), TenantAttribute("mes")]
public class Pstmminjar
{
/// <summary>
///
///</summary>
[SugarColumn(ColumnName="JarID" ,IsPrimaryKey = true ,IsIdentity = true )]
public long JarID { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName="Materbarcode" )]
public string Materbarcode { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName="StoragePlaceID" )]
public string StoragePlaceID { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName="StockDate" )]
public DateTime? StockDate { get; set; }
/// <summary>
///
/// 默认值: (' ')
///</summary>
[SugarColumn(ColumnName="MaterCode" )]
public string MaterCode { get; set; }
/// <summary>
///
/// 默认值: (' ')
///</summary>
[SugarColumn(ColumnName="EquipCode" )]
public string EquipCode { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName="ShiftDate" )]
public DateTime? ShiftDate { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName="ShiftID" )]
public short? ShiftID { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName="InTime" )]
public DateTime? InTime { get; set; }
/// <summary>
///
/// 默认值: ((0))
///</summary>
[SugarColumn(ColumnName="RealNum" )]
public int? RealNum { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName="RealWeight" )]
public decimal? RealWeight { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName="handLename" )]
public string HandLename { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName="Usedweigh" )]
public decimal? Usedweigh { get; set; }
/// <summary>
///
/// 默认值: ('1')
///</summary>
[SugarColumn(ColumnName="UsedFlag" )]
public string UsedFlag { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName="ClearFlag" )]
public string ClearFlag { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName="AuditFlag" )]
public int? AuditFlag { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName="InaccountDuration" )]
public string InaccountDuration { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName="InaccountFlag" )]
public string InaccountFlag { get; set; }
/// <summary>
///
/// 默认值: ((0))
///</summary>
[SugarColumn(ColumnName="DeleteFlag" )]
public string DeleteFlag { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName="StorageID" )]
public string StorageID { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName="OldMaterCode" )]
public string OldMaterCode { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName="KCSIGN" )]
public string Kcsign { get; set; }
/// <summary>
///
/// 默认值: ('')
///</summary>
[SugarColumn(ColumnName="FeedPosition" )]
public string FeedPosition { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName="FeedJarNo" )]
public string FeedJarNo { get; set; }
/// <summary>
///
/// 默认值: (getdate())
///</summary>
[SugarColumn(ColumnName="BDSaveTime" )]
public DateTime? BDSaveTime { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName="RationMaterCd" )]
public string RationMaterCd { get; set; }
}
}

@ -0,0 +1,81 @@
using System;
using SqlSugar;
namespace SlnMesnac.Model.domain
{
[SugarTable("Record_MaterialInput"), TenantAttribute("mes")]
public class RecordMaterialInput
{
/// <summary>
/// 标识
///</summary>
[SugarColumn(ColumnName="obj_id" ,IsPrimaryKey = true ,IsIdentity = true )]
public int obj_id { get; set; }
/// <summary>
/// 设备编号
///</summary>
[SugarColumn(ColumnName="equip_id" )]
public string equip_id { get; set; }
/// <summary>
/// 料罐编号
///</summary>
[SugarColumn(ColumnName="can_number" )]
public string can_number { get; set; }
/// <summary>
/// 设备类型
///</summary>
[SugarColumn(ColumnName="equip_type" )]
public string equip_type { get; set; }
/// <summary>
/// 物料条码
///</summary>
[SugarColumn(ColumnName="material_barcode" )]
public string material_barcode { get; set; }
/// <summary>
/// 投入数量
///</summary>
[SugarColumn(ColumnName="input_quantity" )]
public int? input_quantity { get; set; }
/// <summary>
/// 投入重量
///</summary>
[SugarColumn(ColumnName="input_weight" )]
public decimal? input_weight { get; set; }
/// <summary>
/// 是否余料
///</summary>
[SugarColumn(ColumnName="is_remainder" )]
public bool? is_remainder { get; set; }
/// <summary>
/// 余料数量
///</summary>
[SugarColumn(ColumnName="remainder_quantity" )]
public int? remainder_quantity { get; set; }
/// <summary>
/// 余料重量
///</summary>
[SugarColumn(ColumnName="remainder_weight" )]
public decimal? remainder_weight { get; set; }
/// <summary>
/// 是否开仓1-开仓2-只保存
///</summary>
[SugarColumn(ColumnName="is_open" )]
public int? is_open { get; set; }
/// <summary>
/// 投料结果1-成功0-失败
///</summary>
[SugarColumn(ColumnName="is_flag" )]
public int? is_flag { get; set; }
/// <summary>
/// 备注
///</summary>
[SugarColumn(ColumnName="remark" )]
public string remark { get; set; }
/// <summary>
/// 记录时间
///</summary>
[SugarColumn(ColumnName="record_time" )]
public DateTime? record_time { get; set; }
}
}

@ -11,10 +11,13 @@ namespace SlnMesnac.Repository.service.Impl
private readonly Repository<CwssInputRecord> _cwssRep; private readonly Repository<CwssInputRecord> _cwssRep;
public InputRecordServiceImpl(Repository<McsInputRecord> mcsRep,Repository<CwssInputRecord> cwssRep) private readonly Repository<RecordMaterialInput> _mesRep;
public InputRecordServiceImpl(Repository<McsInputRecord> mcsRep,Repository<CwssInputRecord> cwssRep, Repository<RecordMaterialInput> mesRep)
{ {
_mcsRep = mcsRep; _mcsRep = mcsRep;
_cwssRep = cwssRep; _cwssRep = cwssRep;
_mesRep = mesRep;
} }
/// <summary> /// <summary>
@ -48,6 +51,7 @@ namespace SlnMesnac.Repository.service.Impl
try try
{ {
result = _mcsRep.Insert(mcsInputRecord); result = _mcsRep.Insert(mcsInputRecord);
SaveMesInputRecord(mcsInputRecord, null, out result);
} }
catch (Exception e) catch (Exception e)
{ {
@ -87,6 +91,8 @@ namespace SlnMesnac.Repository.service.Impl
try try
{ {
result = _cwssRep.Insert(cwssInputRecord); result = _cwssRep.Insert(cwssInputRecord);
SaveMesInputRecord(null, cwssInputRecord, out result);
} }
catch (Exception e) catch (Exception e)
{ {
@ -94,5 +100,86 @@ namespace SlnMesnac.Repository.service.Impl
} }
return result; return result;
} }
/// <summary>
/// 保存Mes投料记录
/// </summary>
/// <param name="mcsInputRecord"></param>
/// <param name="cwssInputRecord"></param>
/// <param name="result"></param>
private void SaveMesInputRecord(McsInputRecord mcsInputRecord,CwssInputRecord cwssInputRecord,out bool result)
{
result = false;
try
{
RecordMaterialInput recordMaterialInput = null;
if (mcsInputRecord != null)
{
/*Pstmminjar pstmminjar = new Pstmminjar()
{
Materbarcode = mcsInputRecord.MaterialBarcode,
EquipCode = "01001",
ShiftDate = DateTime.Now,
InTime = mcsInputRecord.RecordTime,
RealNum = mcsInputRecord.InputQuantity,
RealWeight = Convert.ToDecimal(mcsInputRecord.InputWeight),
BDSaveTime = DateTime.Now
};*/
recordMaterialInput = new RecordMaterialInput()
{
equip_id = mcsInputRecord.EquipId.ToString(),
can_number = mcsInputRecord.CanNumber,
equip_type = "mcs",
input_quantity = mcsInputRecord.InputQuantity,
input_weight = mcsInputRecord.InputQuantity,
is_remainder = mcsInputRecord.IsRemainder,
remainder_quantity = mcsInputRecord.RemainderQuantity,
remainder_weight = Convert.ToDecimal(mcsInputRecord.RemainderWeight),
is_open = mcsInputRecord.IsOpen,
is_flag = mcsInputRecord.IsFlag,
remark = mcsInputRecord.Remark,
record_time = mcsInputRecord.RecordTime
};
}
if (cwssInputRecord != null)
{
/*Pstmminjar pstmminjar = new Pstmminjar()
{
Materbarcode = cwssInputRecord.MaterialBarcode,
EquipCode = "0200"+cwssInputRecord.CanNumber,
ShiftDate = DateTime.Now,
InTime = cwssInputRecord.RecordTime,
RealNum = cwssInputRecord.InputQuantity,
RealWeight = Convert.ToDecimal(cwssInputRecord.InputWeight),
BDSaveTime = DateTime.Now
};*/
recordMaterialInput = new RecordMaterialInput()
{
equip_id = cwssInputRecord.EquipId.ToString(),
can_number = cwssInputRecord.CanNumber,
equip_type = "cwss",
input_quantity = cwssInputRecord.InputQuantity,
input_weight = cwssInputRecord.InputQuantity,
is_remainder = cwssInputRecord.IsRemainder,
remainder_quantity = cwssInputRecord.RemainderQuantity,
remainder_weight = Convert.ToDecimal(cwssInputRecord.RemainderWeight),
is_open = cwssInputRecord.IsOpen,
is_flag = cwssInputRecord.IsFlag,
remark = cwssInputRecord.Remark,
record_time = cwssInputRecord.RecordTime
};
}
if (recordMaterialInput != null)
{
result = _mesRep.Insert(recordMaterialInput);
}
}
catch (Exception e)
{
new InvalidOperationException($"保存Mes投料记录异常:{e.Message}");
}
}
} }
} }

@ -33,6 +33,11 @@
"configId": "mesApi", "configId": "mesApi",
"dbType": 2, "dbType": 2,
"connStr": "DataSource=E:\\桌面\\杜肯密炼MES项目\\程序设计\\Durk.SlnMesnac\\SlnMesnac\\bin\\Debug\\net6.0\\data\\data.db" "connStr": "DataSource=E:\\桌面\\杜肯密炼MES项目\\程序设计\\Durk.SlnMesnac\\SlnMesnac\\bin\\Debug\\net6.0\\data\\data.db"
},
{
"configId": "mes",
"dbType": 1,
"connStr": "server=123.60.55.13,39711;uid=sa;pwd=MeS@2024?;database=Mes"
} }
], ],
"PlcConfig": [ "PlcConfig": [

Loading…
Cancel
Save