|
|
|
|
|
using CompressorXN_Log;
|
|
|
|
|
|
using CompressorXN_Model;
|
|
|
|
|
|
using CompressorXN_Model.ViewModel.Response;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
|
|
namespace CompressorXN_Service
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 通讯协议报文
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class AgreementMsgService : DbContext
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 根据机型名称查询通讯协议信息
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="productTypeName"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public AgreementMsgVM GetAgreementMsgByProductTypeName(string productTypeName)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
AgreementMsgVM agreementMsgVM = new AgreementMsgVM
|
|
|
|
|
|
{
|
|
|
|
|
|
ReciveDetailRules = new T_Agreement_Detail_Rule()
|
|
|
|
|
|
};
|
|
|
|
|
|
agreementMsgVM = db.Queryable<T_ProductType>()
|
|
|
|
|
|
.InnerJoin<T_Agreement_Config>((a, b) => a.AgreementName == b.AgreementName)
|
|
|
|
|
|
.InnerJoin<T_Agreement_Msg>((a, b, c) => a.ProductTypeName == c.ProductTypeName)
|
|
|
|
|
|
.Where((a, b, c) => a.ProductTypeName == productTypeName)
|
|
|
|
|
|
.Select((a, b, c) => new AgreementMsgVM
|
|
|
|
|
|
{
|
|
|
|
|
|
ProductTypeName = a.ProductTypeName,
|
|
|
|
|
|
AgreementName = a.AgreementName,
|
|
|
|
|
|
StartType = a.StartType,
|
|
|
|
|
|
MsgFormat = b.MsgFormat,
|
|
|
|
|
|
FrameType = b.FrameType,
|
|
|
|
|
|
Bps = b.Bps,
|
|
|
|
|
|
SendPeriod = b.SendPeriod,
|
|
|
|
|
|
SendId = b.SendId,
|
|
|
|
|
|
FrameLen = b.FrameLen,
|
|
|
|
|
|
RecivePeriod = b.RecivePeriod,
|
|
|
|
|
|
ReciveId = b.ReciveId,
|
|
|
|
|
|
ReciveSignalVal = b.ReciveSignalVal,
|
|
|
|
|
|
IdlingSpeed = c.IdlingSpeed,
|
|
|
|
|
|
IdlingHex = c.IdlingHex,
|
|
|
|
|
|
Speed1 = c.Speed1,
|
|
|
|
|
|
Speed1Hex = c.Speed1Hex,
|
|
|
|
|
|
Speed2 = c.Speed2,
|
|
|
|
|
|
Speed2Hex = c.Speed2Hex,
|
|
|
|
|
|
Speed3 = c.Speed3,
|
|
|
|
|
|
Speed3Hex = c.Speed3Hex,
|
|
|
|
|
|
EndoleadSpeed = c.EndoleadSpeed,
|
|
|
|
|
|
EndoleadHex = c.EndoleadHex,
|
|
|
|
|
|
SingleDriverSpeed = c.SingleDriverSpeed,
|
|
|
|
|
|
SingleDriverHex = c.SingleDriverHex
|
|
|
|
|
|
}).First();
|
|
|
|
|
|
|
|
|
|
|
|
agreementMsgVM.ReciveDetailRules = db.Queryable<T_Agreement_Detail_Rule>().First(m => m.AgreementName == agreementMsgVM.AgreementName && m.MsgType == "recive");
|
|
|
|
|
|
agreementMsgVM.SendAdditionalRules = db.Queryable<T_Agreement_Additional_Rule>().First(m => m.AgreementName == agreementMsgVM.AgreementName);
|
|
|
|
|
|
return agreementMsgVM;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
LogHelper.Error(ex, "执行AgreementMsgService下GetAgreementMsgByProductTypeName时异常");
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 保存通讯协议
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="t_Agreement_Msg"></param>
|
|
|
|
|
|
/// <param name="productTypeName">机型名称</param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public bool SaveAgreementMsg(T_Agreement_Msg t_Agreement_Msg, string productTypeName)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
db.Ado.BeginTran();
|
|
|
|
|
|
|
|
|
|
|
|
db.Deleteable<T_Agreement_Msg>().Where(m => m.ProductTypeName == productTypeName).ExecuteCommand();
|
|
|
|
|
|
|
|
|
|
|
|
db.Insertable(t_Agreement_Msg).ExecuteCommand();
|
|
|
|
|
|
|
|
|
|
|
|
db.Ado.CommitTran();
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
db.Ado.RollbackTran();
|
|
|
|
|
|
LogHelper.Error(ex, "执行AgreementMsgService下SaveAgreementMsg时异常");
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|