add - 添加投料记录

master
wenjy 9 months ago
parent d46983697c
commit 67e24ac95f

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise">
<file url="file://$PROJECT_DIR$/SlnMesnac/Program.cs" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/SlnMesnac/Program.cs" charset="GBK" />
</component>
</project>

@ -0,0 +1,92 @@
using System;
using System.Runtime.Serialization;
using SqlSugar;
namespace SlnMesnac.Model.domain
{
/// <summary>
/// CWSS投料记录
/// </summary>
[SugarTable("Record_CwssInput"), TenantAttribute("mesApi")]
[DataContract(Name = "CwssInputRecord CWSS 投料记录")]
public class CwssInputRecord
{
/// <summary>
/// 标识
/// </summary>
[SugarColumn(ColumnName="obj_id" ,IsPrimaryKey = true ,IsIdentity = true )]
public int ObjId { get; set; }
/// <summary>
/// 机台编号预留可传0
/// </summary>
[SugarColumn(ColumnName="equip_id" )]
public int EquipId { get; set; }
/// <summary>
/// 料罐编号
/// </summary>
[SugarColumn(ColumnName="can_number" )]
public string CanNumber { get; set; }
/// <summary>
/// 物料条码
/// </summary>
[SugarColumn(ColumnName="material_barcode" )]
public string MaterialBarcode { get; set; }
/// <summary>
/// 投入数量
/// </summary>
[SugarColumn(ColumnName="input_quantity" )]
public int InputQuantity { get; set; }
/// <summary>
/// 投入重量
/// </summary>
[SugarColumn(ColumnName="input_weight" )]
public double InputWeight { get; set; }
/// <summary>
/// 是否余料
/// </summary>
[SugarColumn(ColumnName="is_remainder" )]
public bool IsRemainder { get; set; }
/// <summary>
/// 余料数量
/// </summary>
[SugarColumn(ColumnName="remainder_quantity" )]
public int RemainderQuantity { get; set; }
/// <summary>
/// 余料重量
/// </summary>
[SugarColumn(ColumnName="remainder_weight" )]
public double RemainderWeight { get; set; }
/// <summary>
/// 是否开仓1-开仓2-只保存
/// </summary>
[SugarColumn(ColumnName="is_open" )]
public int IsOpen { get; set; }
/// <summary>
/// 投料结果1-成功0-失败
/// </summary>
[SugarColumn(ColumnName="is_flag" )]
public int IsFlag { get; set; }
/// <summary>
/// 备注信息
/// </summary>
[SugarColumn(ColumnName="remark" )]
public string Remark { get; set; }
/// <summary>
/// 记录时间
/// </summary>
[SugarColumn(ColumnName="record_time" )]
public DateTime RecordTime { get; set; }
}
}

@ -0,0 +1,92 @@
using System;
using System.Runtime.Serialization;
using SqlSugar;
namespace SlnMesnac.Model.domain
{
/// <summary>
/// Mcs投料记录
/// </summary>
[SugarTable("Record_McsInput"), TenantAttribute("mesApi")]
[DataContract(Name = "McsInputRecord MCS 投料记录")]
public class McsInputRecord
{
/// <summary>
/// 标识
/// </summary>
[SugarColumn(ColumnName="obj_id" ,IsPrimaryKey = true ,IsIdentity = true )]
public int ObjId { get; set; }
/// <summary>
/// 机台编号预留可传0
/// </summary>
[SugarColumn(ColumnName="equip_id" )]
public int EquipId { get; set; }
/// <summary>
/// 料罐编号
/// </summary>
[SugarColumn(ColumnName="can_number" )]
public string CanNumber { get; set; }
/// <summary>
/// 物料条码
/// </summary>
[SugarColumn(ColumnName="material_barcode" )]
public string MaterialBarcode { get; set; }
/// <summary>
/// 投入数量
/// </summary>
[SugarColumn(ColumnName="input_quantity" )]
public int InputQuantity { get; set; }
/// <summary>
/// 投入重量
/// </summary>
[SugarColumn(ColumnName="input_weight" )]
public double InputWeight { get; set; }
/// <summary>
/// 是否余料
/// </summary>
[SugarColumn(ColumnName="is_remainder" )]
public bool IsRemainder { get; set; }
/// <summary>
/// 余料数量
/// </summary>
[SugarColumn(ColumnName="remainder_quantity" )]
public int RemainderQuantity { get; set; }
/// <summary>
/// 余料重量
/// </summary>
[SugarColumn(ColumnName="remainder_weight" )]
public double RemainderWeight { get; set; }
/// <summary>
/// 是否开仓1-开仓2-只保存
/// </summary>
[SugarColumn(ColumnName="is_open" )]
public int IsOpen { get; set; }
/// <summary>
/// 投料结果1-成功0-失败
/// </summary>
[SugarColumn(ColumnName="is_flag" )]
public int IsFlag { get; set; }
/// <summary>
/// 备注信息
/// </summary>
[SugarColumn(ColumnName="remark" )]
public string Remark { get; set; }
/// <summary>
/// 记录时间
/// </summary>
[SugarColumn(ColumnName="record_time" )]
public DateTime RecordTime { get; set; }
}
}

@ -0,0 +1,20 @@
using System;
using System.Runtime.Serialization;
namespace SlnMesnac.Model.dto
{
/// <summary>
/// 接口请求参数
/// </summary>
[DataContract(Name = "ApiRequestParam 接口请求参数")]
public class ApiRequestParam
{
public string MaterialBarcode{ get; set; }
public string CanNumber{ get; set; }
public string beginTime{ get; set; }
public string endTime { get; set; }
}
}

@ -60,6 +60,7 @@ namespace SlnMesnac.Repository
services.AddSingleton<IMcsMaterialInfoService, McsMaterialInfoServiceImpl>();
services.AddSingleton<ICwssBinToMaterService, CwssBinToMaterServiceImpl>();
services.AddSingleton<ICwssMaterialInfoService, CwssMaterialInfoServiceImpl>();
services.AddSingleton<IInputRecordService, InputRecordServiceImpl>();
}
}
}

@ -0,0 +1,35 @@
using System.Collections.Generic;
using SlnMesnac.Model.domain;
namespace SlnMesnac.Repository.service
{
public interface IInputRecordService
{
/// <summary>
/// 获取Mcs投料记录
/// </summary>
/// <returns></returns>
List<McsInputRecord> GetMcsInputRecordList();
/// <summary>
/// 保存Mcs投料记录
/// </summary>
/// <param name="mcsInputRecord"></param>
/// <returns></returns>
bool SaveMcsInputRecord(McsInputRecord mcsInputRecord);
/// <summary>
/// 获取Cwss投料记录
/// </summary>
/// <returns></returns>
List<CwssInputRecord> GetCwssInputRecordList();
/// <summary>
/// 保存Cwss投料记录
/// </summary>
/// <param name="cwssInputRecord"></param>
/// <returns></returns>
bool SaveCwssInputRecord(CwssInputRecord cwssInputRecord);
}
}

@ -0,0 +1,98 @@
using System;
using System.Collections.Generic;
using SlnMesnac.Model.domain;
namespace SlnMesnac.Repository.service.Impl
{
public class InputRecordServiceImpl:IInputRecordService
{
private readonly Repository<McsInputRecord> _mcsRep;
private readonly Repository<CwssInputRecord> _cwssRep;
public InputRecordServiceImpl(Repository<McsInputRecord> mcsRep,Repository<CwssInputRecord> cwssRep)
{
_mcsRep = mcsRep;
_cwssRep = cwssRep;
}
/// <summary>
/// 获取Mcs投料记录
/// </summary>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public List<McsInputRecord> GetMcsInputRecordList()
{
List<McsInputRecord> result = null;
try
{
result = _mcsRep.GetList();
}
catch (Exception e)
{
new InvalidOperationException($"获取Mcs投料记录异常:{e.Message}");
}
return result;
}
/// <summary>
/// 保存Mcs投料记录
/// </summary>
/// <param name="mcsInputRecord"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public bool SaveMcsInputRecord(McsInputRecord mcsInputRecord)
{
bool result = false;
try
{
result = _mcsRep.Insert(mcsInputRecord);
}
catch (Exception e)
{
new InvalidOperationException($"保存Mcs投料记录异常:{e.Message}");
}
return result;
}
/// <summary>
/// 获取Cwss投料记录
/// </summary>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public List<CwssInputRecord> GetCwssInputRecordList()
{
List<CwssInputRecord> result = null;
try
{
result = _cwssRep.GetList();
}
catch (Exception e)
{
new InvalidOperationException($"获取Cwss投料记录异常:{e.Message}");
}
return result;
}
/// <summary>
/// 保存Cwss投料记录
/// </summary>
/// <param name="cwssInputRecord"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public bool SaveCwssInputRecord(CwssInputRecord cwssInputRecord)
{
bool result = false;
try
{
result = _cwssRep.Insert(cwssInputRecord);
}
catch (Exception e)
{
new InvalidOperationException($"保存Mcs投料记录异常:{e.Message}");
}
return result;
}
}
}

@ -21,13 +21,15 @@ public class CwssIngCheckController
private IWmsTaskOutService _wmsTaskOutService;
private ICwssBinToMaterService _cwssBinToMaterService;
private ICwssMaterialInfoService _cwssMaterialInfoService;
private IInputRecordService _inputRecordService;
public CwssIngCheckController(ILogger<CwssIngCheckController> logger,
AppConfig appConfig,
IWmsTaskOutService wmsTaskOutService,
PlcPool plcPool,
ICwssBinToMaterService cwssBinToMaterService,
ICwssMaterialInfoService cwssMaterialInfoService)
ICwssMaterialInfoService cwssMaterialInfoService,
IInputRecordService inputRecordService)
{
_logger = logger;
_appConfig = appConfig;
@ -35,6 +37,7 @@ public class CwssIngCheckController
_plcPool = plcPool;
_cwssBinToMaterService = cwssBinToMaterService;
_cwssMaterialInfoService = cwssMaterialInfoService;
_inputRecordService = inputRecordService;
}
/// <summary>
@ -138,8 +141,8 @@ public class CwssIngCheckController
break;
}
}
//保存数据
SaveInputRecord(ingredientInfo, 1, "");
} while (false);
}
@ -152,6 +155,48 @@ public class CwssIngCheckController
return result;
}
/// <summary>
/// 获取Cwss投料记录
/// </summary>
/// <param name="apiRequestParam"></param>
/// <returns></returns>
[HttpPost("GetCwssInputRecord")]
public ApiResponse GetCwssInputRecord(ApiRequestParam? apiRequestParam)
{
var result = new ApiResponse();
try
{
do
{
var cwssInputRecordList = _inputRecordService.GetCwssInputRecordList();
if (cwssInputRecordList != null)
{
if (!string.IsNullOrEmpty(apiRequestParam.MaterialBarcode))
cwssInputRecordList = cwssInputRecordList.Where(x => x.MaterialBarcode == apiRequestParam.MaterialBarcode)
.ToList();
if (!string.IsNullOrEmpty(apiRequestParam.CanNumber))
cwssInputRecordList = cwssInputRecordList.Where(x => x.CanNumber == apiRequestParam.CanNumber).ToList();
if (!string.IsNullOrEmpty(apiRequestParam.beginTime))
cwssInputRecordList = cwssInputRecordList.Where(x => x.RecordTime >= Convert.ToDateTime(apiRequestParam.beginTime)).ToList();
if (!string.IsNullOrEmpty(apiRequestParam.endTime))
cwssInputRecordList = cwssInputRecordList.Where(x => x.RecordTime <= Convert.ToDateTime(apiRequestParam.endTime)).ToList();
}
string matStr = JsonSerializer.Serialize(cwssInputRecordList);
result.SetSuccess(matStr);
_logger.LogInformation($"获取Cwss投料记录成功{matStr},时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
} while (false);
}
catch(Exception e)
{
result.SetException(e, "获取Cwss投料记录异常");
_logger.LogError($"获取Cwss投料记录异常:{e.Message}");
}
return result;
}
/// <summary>
/// 下发Cwss开仓指令
/// </summary>
@ -201,4 +246,44 @@ public class CwssIngCheckController
}
return result;
}
/// <summary>
/// 保存投料记录
/// </summary>
private void SaveInputRecord(IngredientInfo info,int isFlag,string remark)
{
try
{
CwssInputRecord cwssInputRecord = new CwssInputRecord()
{
MaterialBarcode = info.MaterialBarcode,
CanNumber = info.CanNumber,
EquipId = info.EquipId,
InputQuantity = info.InputQuantity,
InputWeight = info.InputWeight,
IsRemainder = info.IsRemainder,
RemainderQuantity = info.RemainderQuantity,
RemainderWeight = info.RemainderWeight,
IsOpen = info.IsOpen,
IsFlag = isFlag,
Remark = remark,
RecordTime = DateTime.Now
};
bool result = _inputRecordService.SaveCwssInputRecord(cwssInputRecord);
if (result)
{
_logger.LogInformation($"投料记录:{JsonSerializer.Serialize(cwssInputRecord)}保存成功");
}
else
{
_logger.LogInformation($"投料记录:{JsonSerializer.Serialize(cwssInputRecord)}保存失败");
}
}
catch (Exception ex)
{
_logger.LogError($"投料记录保存异常:{ex.Message}");
}
}
}

@ -21,6 +21,8 @@ public class McsIngCheckController
private IWmsTaskOutService _wmsTaskOutService;
private IMcsBinToMaterService _mcsBinToMaterService;
private IMcsMaterialInfoService _mcsMaterialInfoService;
private IInputRecordService _inputRecordService;
/// <summary>
///
@ -36,7 +38,8 @@ public class McsIngCheckController
AppConfig appConfig,
IWmsTaskOutService wmsTaskOutService,
PlcPool plcPool,
IMcsMaterialInfoService mcsMaterialInfoService)
IMcsMaterialInfoService mcsMaterialInfoService,
IInputRecordService inputRecordService)
{
_logger = logger;
_mcsBinToMaterService = mcsBinToMaterService;
@ -44,6 +47,7 @@ public class McsIngCheckController
_wmsTaskOutService = wmsTaskOutService;
_plcPool = plcPool;
_mcsMaterialInfoService = mcsMaterialInfoService;
_inputRecordService = inputRecordService;
}
@ -150,6 +154,7 @@ public class McsIngCheckController
}
//保存数据
SaveInputRecord(ingredientInfo, 1, "");
} while (false);
}
@ -162,6 +167,48 @@ public class McsIngCheckController
return result;
}
/// <summary>
/// 获取Mcs投料记录
/// </summary>
/// <param name="apiRequestParam"></param>
/// <returns></returns>
[HttpPost("GetMcsInputRecord")]
public ApiResponse GetMcsInputRecord(ApiRequestParam? apiRequestParam)
{
var result = new ApiResponse();
try
{
do
{
var inputRecordList = _inputRecordService.GetMcsInputRecordList();
if (inputRecordList != null)
{
if (!string.IsNullOrEmpty(apiRequestParam.MaterialBarcode))
inputRecordList = inputRecordList.Where(x => x.MaterialBarcode == apiRequestParam.MaterialBarcode)
.ToList();
if (!string.IsNullOrEmpty(apiRequestParam.CanNumber))
inputRecordList = inputRecordList.Where(x => x.CanNumber == apiRequestParam.CanNumber).ToList();
if (!string.IsNullOrEmpty(apiRequestParam.beginTime))
inputRecordList = inputRecordList.Where(x => x.RecordTime >= Convert.ToDateTime(apiRequestParam.beginTime)).ToList();
if (!string.IsNullOrEmpty(apiRequestParam.endTime))
inputRecordList = inputRecordList.Where(x => x.RecordTime <= Convert.ToDateTime(apiRequestParam.endTime)).ToList();
}
string matStr = JsonSerializer.Serialize(inputRecordList);
result.SetSuccess(matStr);
_logger.LogInformation($"获取Mcs投料记录成功{matStr},时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
} while (false);
}
catch(Exception e)
{
result.SetException(e, "获取Cwss投料记录异常");
_logger.LogError($"获取Cwss投料记录异常:{e.Message}");
}
return result;
}
/// <summary>
/// 下发MCS开仓指令
/// </summary>
@ -223,4 +270,44 @@ public class McsIngCheckController
}
return result;
}
/// <summary>
/// 保存投料记录
/// </summary>
private void SaveInputRecord(IngredientInfo info,int isFlag,string remark)
{
try
{
McsInputRecord mcsInputRecord = new McsInputRecord()
{
MaterialBarcode = info.MaterialBarcode,
CanNumber = info.CanNumber,
EquipId = info.EquipId,
InputQuantity = info.InputQuantity,
InputWeight = info.InputWeight,
IsRemainder = info.IsRemainder,
RemainderQuantity = info.RemainderQuantity,
RemainderWeight = info.RemainderWeight,
IsOpen = info.IsOpen,
IsFlag = isFlag,
Remark = remark,
RecordTime = DateTime.Now
};
bool result = _inputRecordService.SaveMcsInputRecord(mcsInputRecord);
if (result)
{
_logger.LogInformation($"投料记录:{JsonSerializer.Serialize(mcsInputRecord)}保存成功");
}
else
{
_logger.LogInformation($"投料记录:{JsonSerializer.Serialize(mcsInputRecord)}保存失败");
}
}
catch (Exception ex)
{
_logger.LogError($"投料记录保存异常:{ex.Message}");
}
}
}

@ -28,6 +28,11 @@
"configId": "cwss",
"dbType": 1,
"connStr": "server=58.63.214.27,23315;uid=dkmes;pwd=Duken123;database=ShareDB_MES"
},
{
"configId": "mesApi",
"dbType": 2,
"connStr": "DataSource=E:\\桌面\\杜肯密炼MES项目\\程序设计\\Durk.SlnMesnac\\SlnMesnac\\bin\\Debug\\net6.0\\data\\data.db"
}
],
"PlcConfig": [

Loading…
Cancel
Save