You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

188 lines
7.3 KiB
C#

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;
private readonly Repository<RecordMaterialInput> _mesRep;
public InputRecordServiceImpl(Repository<McsInputRecord> mcsRep,Repository<CwssInputRecord> cwssRep, Repository<RecordMaterialInput> mesRep)
{
_mcsRep = mcsRep;
_cwssRep = cwssRep;
_mesRep = mesRep;
}
/// <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);
SaveMesInputRecord(mcsInputRecord, null, out result);
}
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);
SaveMesInputRecord(null, cwssInputRecord, out result);
}
catch (Exception e)
{
new InvalidOperationException($"保存Mcs投料记录异常:{e.Message}");
}
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() == "0" ? "1" :mcsInputRecord.EquipId.ToString(),
can_number = mcsInputRecord.CanNumber,
equip_type = "mcs",
scaleNum = "101",
material_barcode = mcsInputRecord.MaterialBarcode,
input_quantity = mcsInputRecord.InputQuantity,
input_weight = Convert.ToDecimal(mcsInputRecord.InputWeight),
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() == "0" ? "1" :cwssInputRecord.EquipId.ToString(),
can_number = cwssInputRecord.CanNumber,
equip_type = "cwss",
material_barcode = cwssInputRecord.MaterialBarcode,
input_quantity = cwssInputRecord.InputQuantity,
input_weight = Convert.ToDecimal(cwssInputRecord.InputWeight),
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}");
}
}
}
}