|
|
using MaterialTraceability.Entity.DAO;
|
|
|
using MaterialTraceability.SqlSugar.ServiceImpl;
|
|
|
using MaterialTraceability.SqlSugar;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
using MaterialTraceability.Entity.DTO;
|
|
|
using MaterialTraceability.WebService;
|
|
|
using MaterialTraceability.Common;
|
|
|
using MaterialTraceability.Entity.Enum;
|
|
|
using MaterialTraceability.WebService.GetParametricValueServiceService;
|
|
|
using MaterialTraceability.WebService.MachineIntegrationServiceService;
|
|
|
using MaterialTraceability.WebService.Param;
|
|
|
using System.Linq.Expressions;
|
|
|
using System.Security.Cryptography;
|
|
|
|
|
|
namespace MaterialTraceability.Business
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 物料特征逻辑
|
|
|
/// </summary>
|
|
|
public class MaterialFeatureBusiness
|
|
|
{
|
|
|
//卷轴信息
|
|
|
private IBaseServices<ProShaftInfo> shaftInfoServices = new BaseServices<ProShaftInfo>();
|
|
|
|
|
|
//收卷记录
|
|
|
private IBaseServices<ProDownRecord> downRecordServices = new BaseServices<ProDownRecord>();
|
|
|
|
|
|
//上料记录
|
|
|
private IBaseServices<ProUpRecord> upRecordServices = new BaseServices<ProUpRecord>();
|
|
|
|
|
|
//Mes WebService接口
|
|
|
private IMesWebServices MesWebServices = new MesWebServicesImpl();
|
|
|
|
|
|
private AppConfigDto appConfig = AppConfigDto.Instance;
|
|
|
|
|
|
private INIFile inifile = new INIFile(System.Environment.CurrentDirectory + "/MesConfig/App.InI");
|
|
|
|
|
|
private static readonly Lazy<MaterialFeatureBusiness> lazy = new Lazy<MaterialFeatureBusiness>(() => new MaterialFeatureBusiness());
|
|
|
|
|
|
public static MaterialFeatureBusiness Instance
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return lazy.Value;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private MaterialFeatureBusiness() { }
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取模切物料重量特征
|
|
|
/// </summary>
|
|
|
/// <param name="bindSfc">放卷膜卷号</param>
|
|
|
/// <param name="position">收卷位置</param>
|
|
|
/// <returns></returns>
|
|
|
public async Task<machineIntegrationParametricData[]> GetMQMaterialWeight(string bindSfc, int position,string ccdLableAmount)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
string logStr = this.Which_Mq(position);
|
|
|
//获取放卷方向-放卷开始时读取PLC地址将内容存入绑定信息:false(0)为顺时针,True(1)为逆时针
|
|
|
//根据收卷轴绑定的SFC获取放卷轴
|
|
|
Expression<Func<ProShaftInfo, bool>> exp = s1 => true;
|
|
|
exp = exp.And(x => x.bindSfc == bindSfc);
|
|
|
Expression<Func<ProShaftInfo, object>> order = s1 => s1.bindTime;
|
|
|
ProShaftInfo upShaftInfo = await shaftInfoServices.QueryFirst(exp, order, false);
|
|
|
if (upShaftInfo == null)
|
|
|
{
|
|
|
LogHelper.Info(String.Format("{0}上传数据获取放卷绑定信息为空", logStr));
|
|
|
return null;
|
|
|
}
|
|
|
string upDirection = upShaftInfo.endFlag == 0 ? "顺时针" : "逆时针";
|
|
|
|
|
|
int downDirectionNumber = GetDirections_Mq(StringChange.ParseToInt(upShaftInfo.positionId));
|
|
|
|
|
|
//获取收卷方向-收卷开始时读取PLC地址将内容存入绑定信息
|
|
|
string downDirection = downDirectionNumber == 0 ? "顺时针" : "逆时针";
|
|
|
|
|
|
//是否首检,根据下料记录统计是否为换班后收卷料
|
|
|
bool isFirst = await IsFirstFlag_Mq();
|
|
|
|
|
|
LogHelper.Info(String.Format("{0}收卷结束,当前卷放卷方向:{1};收卷方向:{2};是否首检:{3}", logStr, upDirection, downDirection, isFirst));
|
|
|
//upLoadBusiness.SaveLogRecord(position, String.Format("{0}收卷结束,当前卷放卷方向:{1};收卷方向:{2};是否首检:{3}", logStr, upDirection, downDirection, isFirst));
|
|
|
|
|
|
//根据上料记录获取冷压特征数据
|
|
|
Expression<Func<ProUpRecord, bool>> upExp = s1 => true;
|
|
|
upExp = upExp.And(x => x.Sfc == upShaftInfo.bindSfc);
|
|
|
Expression<Func<ProUpRecord, object>> upOrder = s1 => s1.RecordTime;
|
|
|
ProUpRecord upRecord = await upRecordServices.QueryFirst(upExp, upOrder, false);
|
|
|
if (upRecord == null)
|
|
|
{
|
|
|
LogHelper.Info(String.Format("{0}上传数据获取放卷信息为空", logStr));
|
|
|
//upLoadBusiness.SaveLogRecord(position, String.Format("{0}上传数据获取放卷信息为空", logStr));
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
var lyMaterialCharacter = JsonChange.JsonToMode<TBParametricValueResult>(upRecord.UpMaterialId);
|
|
|
|
|
|
LogHelper.Info("获取冷压重量特征数据:" + lyMaterialCharacter);
|
|
|
//upLoadBusiness.SaveLogRecord(position, "获取冷压重量特征数据:" + lyMaterialCharacter);
|
|
|
|
|
|
//获取冷压重量特征数据,如果数据库中为空则通过MES重新获取并存入数据库 Add by wenjy 2022-11-15
|
|
|
if (lyMaterialCharacter == null)
|
|
|
{
|
|
|
|
|
|
GetParametricValueRequestData[] parametricValueRequestDatas = new GetParametricValueRequestData[] {
|
|
|
new GetParametricValueRequestData { parameter= "LY_WLMX" },
|
|
|
new GetParametricValueRequestData { parameter= "LY_S_X01" },
|
|
|
new GetParametricValueRequestData { parameter= "LY_S_X02" },
|
|
|
new GetParametricValueRequestData { parameter= "LY_B_X01" },
|
|
|
new GetParametricValueRequestData { parameter= "LY_B_X02" },
|
|
|
new GetParametricValueRequestData { parameter= "S_TARGETCW" },
|
|
|
};
|
|
|
lyMaterialCharacter = GetLyMaterialCharacter_Mq(upShaftInfo.bindSfc, parametricValueRequestDatas); //获取冷压特征数据
|
|
|
string lyMaterialCharacterJsonStr = JsonChange.ModeToJson(lyMaterialCharacter);
|
|
|
LogHelper.Info(String.Format("数据库中冷压物料特征数据为空,通过MES获取{0}的物料特征数据:{1}", upShaftInfo.bindSfc, lyMaterialCharacterJsonStr));
|
|
|
//upLoadBusiness.SaveLogRecord(position, String.Format("数据库中冷压物料特征数据为空,通过MES获取{0}的物料特征数据:{1}", upShaftInfo.bindSfc, lyMaterialCharacterJsonStr));
|
|
|
upRecord.UpMaterialId = lyMaterialCharacterJsonStr;
|
|
|
|
|
|
await upRecordServices.Update(upRecord);
|
|
|
}
|
|
|
|
|
|
//物料面向
|
|
|
string mqMaterialFace = "";
|
|
|
string stargetcwStr = "";
|
|
|
var lyMaterialFace = lyMaterialCharacter.paramValues.Where(x => x.parameter == "LY_WLMX").FirstOrDefault();
|
|
|
var S_TARGETCW = lyMaterialCharacter.paramValues.Where(x => x.parameter == "S_TARGETCW").FirstOrDefault();
|
|
|
if (lyMaterialFace != null)
|
|
|
{
|
|
|
mqMaterialFace = MaterialFaceStr_Mq(lyMaterialFace.value, upShaftInfo.endFlag, downDirectionNumber);
|
|
|
}
|
|
|
|
|
|
if(S_TARGETCW != null){
|
|
|
stargetcwStr = S_TARGETCW.value;
|
|
|
}else{
|
|
|
LogHelperBusiness.LogInfo("手动完工获取模切数据S_TARGETCW为null");
|
|
|
}
|
|
|
|
|
|
LogHelper.Info(String.Format("冷压物料面向:{0};模切物料面向:{1}", lyMaterialFace, mqMaterialFace));
|
|
|
|
|
|
//upLoadBusiness.SaveLogRecord(position, String.Format("冷压物料面向:{0};模切物料面向:{1}", lyMaterialFace, mqMaterialFace));
|
|
|
string jrDirection = "";//卷绕理论方向
|
|
|
string S_CW = "";//模切S面某膜区某特征值
|
|
|
string B_CW = "";//模切B面某膜区某特征值
|
|
|
if (position % 2 != 0)
|
|
|
{
|
|
|
jrDirection = downDirection;
|
|
|
|
|
|
var LY_S_X01 = lyMaterialCharacter.paramValues.Where(x => x.parameter == "LY_S_X01").FirstOrDefault();
|
|
|
var LY_B_X01 = lyMaterialCharacter.paramValues.Where(x => x.parameter == "LY_B_X01").FirstOrDefault();
|
|
|
|
|
|
if (LY_S_X01 != null) S_CW = LY_S_X01.value;
|
|
|
if (LY_B_X01 != null) B_CW = LY_B_X01.value;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
jrDirection = downDirectionNumber == 0 ? "逆时针" : "顺时针";
|
|
|
|
|
|
var LY_S_X02 = lyMaterialCharacter.paramValues.Where(x => x.parameter == "LY_S_X02").FirstOrDefault();
|
|
|
var LY_B_X02 = lyMaterialCharacter.paramValues.Where(x => x.parameter == "LY_B_X02").FirstOrDefault();
|
|
|
|
|
|
if (LY_S_X02 != null) S_CW = LY_S_X02.value;
|
|
|
if (LY_B_X02 != null) B_CW = LY_B_X02.value;
|
|
|
}
|
|
|
LogHelper.Info(String.Format("卷绕理论方向:{0};S面特征值:{1};B面特征值:{1}", jrDirection, S_CW, B_CW));
|
|
|
|
|
|
|
|
|
machineIntegrationParametricData[] data = {
|
|
|
new machineIntegrationParametricData() {name ="MQ_FJFX",dataType=ParameterDataType.TEXT, value= StringExtension.IsBlank(upDirection) ? "0" : upDirection},
|
|
|
new machineIntegrationParametricData() {name ="MQ_SJFX",dataType=ParameterDataType.TEXT, value= StringExtension.IsBlank(downDirection) ? "0" :downDirection},
|
|
|
new machineIntegrationParametricData() {name ="MQ_SJZ",dataType=ParameterDataType.TEXT, value= StringExtension.IsBlank(logStr) ? "0" :logStr},
|
|
|
new machineIntegrationParametricData() {name ="FIRST ARTICLE",dataType=ParameterDataType.TEXT, value= isFirst == true ? "OK" : "NG"},
|
|
|
new machineIntegrationParametricData() {name ="MQ_WLMX",dataType=ParameterDataType.TEXT, value= StringExtension.IsBlank(mqMaterialFace) ? "0" :mqMaterialFace},
|
|
|
new machineIntegrationParametricData() {name ="MQ_JRLLFX",dataType=ParameterDataType.TEXT, value= StringExtension.IsBlank(jrDirection) ? "0" :jrDirection},
|
|
|
new machineIntegrationParametricData() {name ="S_CW",dataType=ParameterDataType.TEXT, value=StringExtension.IsBlank(S_CW) ? "0" : S_CW},
|
|
|
new machineIntegrationParametricData() {name ="B_CW",dataType=ParameterDataType.TEXT, value=StringExtension.IsBlank(B_CW) ? "0" : B_CW},
|
|
|
new machineIntegrationParametricData() {name ="CCD",dataType=ParameterDataType.TEXT, value=StringExtension.IsBlank(ccdLableAmount) ? "0" : ccdLableAmount},
|
|
|
new machineIntegrationParametricData() {name ="S_TARGETCW",dataType=ParameterDataType.TEXT, value=StringExtension.IsBlank(stargetcwStr) ? "0" : stargetcwStr},
|
|
|
};
|
|
|
return data;
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogHelper.Info("模切物料特征数据获取异常:" + ex.Message);
|
|
|
LogHelper.Error("模切物料特征数据获取异常",ex);
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#region 模切物料特征数据统计
|
|
|
/// <summary>
|
|
|
/// 获取放卷、收卷运行方向
|
|
|
/// </summary>
|
|
|
/// <param name="position"></param>
|
|
|
private int GetDirections_Mq(int position)
|
|
|
{
|
|
|
string logStr = this.Which_Mq(position);
|
|
|
LogHelper.Info(String.Format("读取{0}轴运行方向", logStr));
|
|
|
//false(0)为顺时针,True(1)为逆时针
|
|
|
int directions = 0;
|
|
|
if (position > 4)
|
|
|
{
|
|
|
directions = Convert.ToInt32(PlcBusiness.readBoolPlc(appConfig.mqAddress.放卷方向));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (position % 2 != 0) //上轴
|
|
|
{
|
|
|
directions = Convert.ToInt32(PlcBusiness.readBoolPlc(appConfig.mqAddress.上轴方向));
|
|
|
}
|
|
|
else //下轴
|
|
|
{
|
|
|
directions = Convert.ToInt32(PlcBusiness.readBoolPlc(appConfig.mqAddress.下轴方向));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return directions;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 是否首件
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
private async Task<bool> IsFirstFlag_Mq()
|
|
|
{
|
|
|
bool result = false;
|
|
|
try
|
|
|
{
|
|
|
DateTime dayShift = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 12:00:00"));
|
|
|
DateTime nightShift = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
|
|
|
LogHelper.Info(String.Format("判断当前物料是否为首件,白班时间{0},夜班时间{1}", dayShift, nightShift));
|
|
|
Expression<Func<ProDownRecord, bool>> exp = s1 => true;
|
|
|
if (DateTime.Now > dayShift && DateTime.Now < nightShift)
|
|
|
{
|
|
|
exp = exp.And(x => Convert.ToDateTime(x.RecordTime) > dayShift);
|
|
|
}
|
|
|
else if (DateTime.Now > nightShift && DateTime.Now < dayShift.AddDays(1))
|
|
|
{
|
|
|
exp = exp.And(x => Convert.ToDateTime(x.RecordTime) > nightShift);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//次日凌晨直接返回
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
List<ProDownRecord> downRecords = await downRecordServices.Query(exp);
|
|
|
|
|
|
if (downRecords.Count < 2)
|
|
|
{
|
|
|
result = true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
result = false;
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogHelper.Info("判断当前物料是否为首件异常:" + ex.Message);
|
|
|
result = false;
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取冷压物料面向
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
private TBParametricValueResult GetLyMaterialCharacter_Mq(string sfc, GetParametricValueRequestData[] parameters)
|
|
|
{
|
|
|
TBDataServiceParam tbServiceParam = new TBDataServiceParam()
|
|
|
{
|
|
|
url = inifile.IniReadValue("TBParametricValueParam", "url"),
|
|
|
site = inifile.IniReadValue("TBParametricValueParam", "site"),
|
|
|
sfc = sfc,
|
|
|
memberlist = parameters
|
|
|
};
|
|
|
|
|
|
var lyresult = MesWebServices.findTBData(tbServiceParam);
|
|
|
|
|
|
return lyresult;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 根据冷压面向、膜区收放卷放卷判断膜区面向
|
|
|
/// </summary>
|
|
|
/// <param name="lyMaterialFace"></param>
|
|
|
/// <param name="upDirections"></param>
|
|
|
/// <param name="downDirections"></param>
|
|
|
/// <returns></returns>
|
|
|
private string MaterialFaceStr_Mq(string lyMaterialFace, int upDirections, int downDirections)
|
|
|
{
|
|
|
string mqMaterialFace = "";
|
|
|
|
|
|
if (StringExtension.IsBlank(lyMaterialFace))
|
|
|
{
|
|
|
return mqMaterialFace;
|
|
|
}
|
|
|
|
|
|
if (lyMaterialFace == "S面")
|
|
|
{
|
|
|
if (upDirections == downDirections)
|
|
|
{
|
|
|
mqMaterialFace = "S面";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
mqMaterialFace = "B面";
|
|
|
}
|
|
|
}
|
|
|
else if (lyMaterialFace == "B面")
|
|
|
{
|
|
|
if (upDirections == downDirections)
|
|
|
{
|
|
|
mqMaterialFace = "B面";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
mqMaterialFace = "S面";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return mqMaterialFace;
|
|
|
}
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
///判断当前是哪个轴
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
private string Which_Mq(int position)
|
|
|
{
|
|
|
string logStr = "";
|
|
|
if (appConfig.machineId == 3)
|
|
|
{
|
|
|
if (position == 3) logStr = "上收卷左";
|
|
|
if (position == 1) logStr = "上收卷右";
|
|
|
if (position == 4) logStr = "下收卷左";
|
|
|
if (position == 2) logStr = "下收卷右";
|
|
|
if (position == 5) logStr = "右放卷";
|
|
|
if (position == 6) logStr = "左放卷";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (position == 1) logStr = "上收卷左";
|
|
|
if (position == 3) logStr = "上收卷右";
|
|
|
if (position == 2) logStr = "下收卷左";
|
|
|
if (position == 4) logStr = "下收卷右";
|
|
|
if (position == 5) logStr = "左放卷";
|
|
|
if (position == 6) logStr = "右放卷";
|
|
|
}
|
|
|
return logStr;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取冷压物料特征数据
|
|
|
/// </summary>
|
|
|
/// <param name="shaftName">收卷轴名称</param>
|
|
|
/// <param name="positionId">收卷轴位置编号</param>
|
|
|
/// <param name="upMaterialSfc">放卷位膜卷号</param>
|
|
|
/// <param name="splitSfc">拆分后的膜卷号</param>
|
|
|
/// <returns></returns>
|
|
|
public async Task<machineIntegrationParametricData[]> GetLYMaterialWeight(string shaftName,string positionId, string upMaterialSfc, string splitSfc)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
string LY_SJFX = string.Empty;//收卷轴方向
|
|
|
string LY_FJFX = string.Empty;//放卷轴方向
|
|
|
string LY_SJZ = shaftName;//收卷轴1A轴小天线
|
|
|
string LY_HXMQ = string.Empty;//横向膜区方向
|
|
|
int LY_ZXMQ = 0;//L2 SFC拆分第几轮
|
|
|
string LY_WLMX = string.Empty;//物料面向 小轴方向
|
|
|
double LY_S_X01 = 0.00;//冷压S面某膜区特征值-01
|
|
|
double LY_S_X02 = 0.00;//冷压S面某膜区特征值-02
|
|
|
double LY_B_X01 = 0.00;//冷压B面某膜区特征值-01
|
|
|
double LY_B_X02 = 0.00;//冷压B面某膜区特征值-02
|
|
|
double S_TARGETCW = 0.00;
|
|
|
|
|
|
//根据放卷位SFC获取放卷记录,取出涂布来料膜卷号
|
|
|
Expression<Func<ProUpRecord, bool>> exp = s1 => true;
|
|
|
exp = exp.And(x => x.Sfc == upMaterialSfc);
|
|
|
Expression<Func<ProUpRecord, object>> order = x => x.RecordTime;
|
|
|
ProUpRecord upRecord = await upRecordServices.QueryFirst(exp, order, false);
|
|
|
|
|
|
if (upRecord != null)
|
|
|
{
|
|
|
upMaterialSfc = upRecord.UpMaterialId;
|
|
|
}
|
|
|
|
|
|
LogHelper.Info($"收卷轴:{LY_SJZ}");
|
|
|
#region 横向膜区
|
|
|
|
|
|
//1、判断轴的方向
|
|
|
LY_FJFX = PlcBusiness.readPlc(appConfig.LyAddress.放卷方向) == 0 ? "顺时针" : "逆时针";
|
|
|
LogHelper.Info($"放卷轴方向:{LY_FJFX}");
|
|
|
|
|
|
if (positionId == "1" || positionId == "2") LY_SJFX = PlcBusiness.readPlc(appConfig.LyAddress.收卷1A方向) == 0 ? "顺时针" : "逆时针";
|
|
|
if (positionId == "3" || positionId == "4") LY_SJFX = PlcBusiness.readPlc(appConfig.LyAddress.收卷1B方向) == 0 ? "顺时针" : "逆时针";
|
|
|
if (positionId == "5" || positionId == "6") LY_SJFX = PlcBusiness.readPlc(appConfig.LyAddress.收卷2A方向) == 0 ? "顺时针" : "逆时针";
|
|
|
if (positionId == "7" || positionId == "8") LY_SJFX = PlcBusiness.readPlc(appConfig.LyAddress.收卷2B方向) == 0 ? "顺时针" : "逆时针";
|
|
|
LogHelper.Info($"收卷轴方向:{LY_SJFX}");
|
|
|
//2、 根据posttion判断料是左中右那个膜区
|
|
|
string tagAmount = ConfigHelper.GetConfig("tagAmount");
|
|
|
if (tagAmount == "3")
|
|
|
{
|
|
|
//顺时针
|
|
|
if (LY_SJFX == "顺时针" && positionId == "1") LY_HXMQ = "右";
|
|
|
if (LY_SJFX == "顺时针" && positionId == "2") LY_HXMQ = "左";
|
|
|
if (LY_SJFX == "顺时针" && positionId == "3") LY_HXMQ = "左";
|
|
|
if (LY_SJFX == "顺时针" && positionId == "4") LY_HXMQ = "右";
|
|
|
if (LY_SJFX == "顺时针" && positionId == "5") LY_HXMQ = "中";
|
|
|
if (LY_SJFX == "顺时针" && positionId == "6") LY_HXMQ = "中";
|
|
|
if (LY_SJFX == "顺时针" && positionId == "7") LY_HXMQ = "中";
|
|
|
if (LY_SJFX == "顺时针" && positionId == "8") LY_HXMQ = "中";
|
|
|
//逆时针
|
|
|
if (LY_SJFX == "逆时针" && positionId == "1") LY_HXMQ = "左";
|
|
|
if (LY_SJFX == "逆时针" && positionId == "2") LY_HXMQ = "右";
|
|
|
if (LY_SJFX == "逆时针" && positionId == "3") LY_HXMQ = "右";
|
|
|
if (LY_SJFX == "逆时针" && positionId == "4") LY_HXMQ = "左";
|
|
|
if (LY_SJFX == "逆时针" && positionId == "5") LY_HXMQ = "中";
|
|
|
if (LY_SJFX == "逆时针" && positionId == "6") LY_HXMQ = "中";
|
|
|
if (LY_SJFX == "逆时针" && positionId == "7") LY_HXMQ = "中";
|
|
|
if (LY_SJFX == "逆时针" && positionId == "8") LY_HXMQ = "中";
|
|
|
LogHelper.Info($"横向膜区:{LY_HXMQ}");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//顺时针
|
|
|
if (LY_SJFX == "顺时针" && positionId == "1") LY_HXMQ = "右";
|
|
|
if (LY_SJFX == "顺时针" && positionId == "2") LY_HXMQ = "左";
|
|
|
if (LY_SJFX == "顺时针" && positionId == "3") LY_HXMQ = "左";
|
|
|
if (LY_SJFX == "顺时针" && positionId == "4") LY_HXMQ = "右";
|
|
|
if (LY_SJFX == "顺时针" && positionId == "5") LY_HXMQ = "右";
|
|
|
if (LY_SJFX == "顺时针" && positionId == "6") LY_HXMQ = "左";
|
|
|
if (LY_SJFX == "顺时针" && positionId == "7") LY_HXMQ = "左";
|
|
|
if (LY_SJFX == "顺时针" && positionId == "8") LY_HXMQ = "右";
|
|
|
//逆时针
|
|
|
if (LY_SJFX == "逆时针" && positionId == "1") LY_HXMQ = "左";
|
|
|
if (LY_SJFX == "逆时针" && positionId == "2") LY_HXMQ = "右";
|
|
|
if (LY_SJFX == "逆时针" && positionId == "3") LY_HXMQ = "右";
|
|
|
if (LY_SJFX == "逆时针" && positionId == "4") LY_HXMQ = "左";
|
|
|
if (LY_SJFX == "逆时针" && positionId == "5") LY_HXMQ = "左";
|
|
|
if (LY_SJFX == "逆时针" && positionId == "6") LY_HXMQ = "右";
|
|
|
if (LY_SJFX == "逆时针" && positionId == "7") LY_HXMQ = "右";
|
|
|
if (LY_SJFX == "逆时针" && positionId == "8") LY_HXMQ = "左";
|
|
|
|
|
|
LogHelper.Info($"膜区:{LY_HXMQ}");
|
|
|
}
|
|
|
|
|
|
//3、物料面向
|
|
|
if (LY_SJFX == "顺时针" && LY_FJFX == "顺时针")
|
|
|
{
|
|
|
LY_WLMX = "S面";
|
|
|
}
|
|
|
if (LY_SJFX == "顺时针" && LY_FJFX == "逆时针")
|
|
|
{
|
|
|
LY_WLMX = "B面";
|
|
|
}
|
|
|
if (LY_SJFX == "逆时针" && LY_FJFX == "顺时针")
|
|
|
{
|
|
|
LY_WLMX = "B面";
|
|
|
}
|
|
|
if (LY_SJFX == "逆时针" && LY_FJFX == "逆时针")
|
|
|
{
|
|
|
LY_WLMX = "S面";
|
|
|
}
|
|
|
LogHelper.Info($"物料面向:{LY_WLMX}");
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 纵向膜区 update by wenjy 2022-11-11
|
|
|
//4、根据膜卷号和配置文件中的tagAmount,再根据膜卷号从数据库中查询条数、与tagAmount比较判断是第几轮
|
|
|
|
|
|
var df = splitSfc.Substring(splitSfc.IndexOf("-") + 1, 2);
|
|
|
|
|
|
int recordAmount = StringChange.ParseToInt(df);
|
|
|
|
|
|
var tag = Convert.ToInt32(ConfigHelper.GetConfig("tagAmount"));
|
|
|
|
|
|
var splitAmount = Math.Ceiling(Convert.ToDouble(recordAmount) / Convert.ToDouble(tag));
|
|
|
|
|
|
LogHelper.Info($"纵向膜区第几轮:{splitAmount}");
|
|
|
|
|
|
LY_ZXMQ = Convert.ToInt32(splitAmount);
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 从mes中获取值
|
|
|
GetParametricValueRequestData[] t = null;
|
|
|
if (LY_HXMQ == "左" && LY_ZXMQ == 1)
|
|
|
{
|
|
|
t = new GetParametricValueRequestData[] {
|
|
|
new GetParametricValueRequestData { parameter= "S_EIGENVALUE_1_1" },
|
|
|
new GetParametricValueRequestData { parameter= "S_EIGENVALUE_1_2" },
|
|
|
new GetParametricValueRequestData { parameter= "B_EIGENVALUE_1_1" },
|
|
|
new GetParametricValueRequestData { parameter= "B_EIGENVALUE_1_2" },
|
|
|
new GetParametricValueRequestData { parameter= "S_TARGETCW" }
|
|
|
};
|
|
|
}
|
|
|
if (LY_HXMQ == "中" && LY_ZXMQ == 1)
|
|
|
{
|
|
|
t = new GetParametricValueRequestData[] {
|
|
|
new GetParametricValueRequestData { parameter= "S_EIGENVALUE_2_1" },
|
|
|
new GetParametricValueRequestData { parameter= "S_EIGENVALUE_2_2" },
|
|
|
new GetParametricValueRequestData { parameter= "B_EIGENVALUE_2_1" },
|
|
|
new GetParametricValueRequestData { parameter= "B_EIGENVALUE_2_2" },
|
|
|
new GetParametricValueRequestData { parameter= "S_TARGETCW" }
|
|
|
};
|
|
|
}
|
|
|
if (LY_HXMQ == "右" && LY_ZXMQ == 1)
|
|
|
{
|
|
|
t = new GetParametricValueRequestData[] {
|
|
|
new GetParametricValueRequestData { parameter= "S_EIGENVALUE_3_1" },
|
|
|
new GetParametricValueRequestData { parameter= "S_EIGENVALUE_3_2" },
|
|
|
new GetParametricValueRequestData { parameter= "B_EIGENVALUE_3_1" },
|
|
|
new GetParametricValueRequestData { parameter= "B_EIGENVALUE_3_2" },
|
|
|
new GetParametricValueRequestData { parameter= "S_TARGETCW" }
|
|
|
};
|
|
|
}
|
|
|
if (LY_HXMQ == "左" && LY_ZXMQ != 1)
|
|
|
{
|
|
|
t = new GetParametricValueRequestData[] {
|
|
|
new GetParametricValueRequestData { parameter= "S_EIGENVALUE_4_1" },
|
|
|
new GetParametricValueRequestData { parameter= "S_EIGENVALUE_4_2" },
|
|
|
new GetParametricValueRequestData { parameter= "B_EIGENVALUE_4_1" },
|
|
|
new GetParametricValueRequestData { parameter= "B_EIGENVALUE_4_2" },
|
|
|
new GetParametricValueRequestData { parameter= "S_TARGETCW" }
|
|
|
};
|
|
|
}
|
|
|
if (LY_HXMQ == "中" && LY_ZXMQ != 1)
|
|
|
{
|
|
|
t = new GetParametricValueRequestData[] {
|
|
|
new GetParametricValueRequestData { parameter= "S_EIGENVALUE_5_1" },
|
|
|
new GetParametricValueRequestData { parameter= "S_EIGENVALUE_5_2" },
|
|
|
new GetParametricValueRequestData { parameter= "B_EIGENVALUE_5_1" },
|
|
|
new GetParametricValueRequestData { parameter= "B_EIGENVALUE_5_2" },
|
|
|
new GetParametricValueRequestData { parameter= "S_TARGETCW" }
|
|
|
};
|
|
|
}
|
|
|
if (LY_HXMQ == "右" && LY_ZXMQ != 1)
|
|
|
{
|
|
|
t = new GetParametricValueRequestData[] {
|
|
|
new GetParametricValueRequestData { parameter= "S_EIGENVALUE_6_1" },
|
|
|
new GetParametricValueRequestData { parameter= "S_EIGENVALUE_6_2" },
|
|
|
new GetParametricValueRequestData { parameter= "B_EIGENVALUE_6_1" },
|
|
|
new GetParametricValueRequestData { parameter= "B_EIGENVALUE_6_2" },
|
|
|
new GetParametricValueRequestData { parameter= "S_TARGETCW" }
|
|
|
};
|
|
|
}
|
|
|
|
|
|
|
|
|
TBDataServiceParam tbServiceParam = new TBDataServiceParam()
|
|
|
{
|
|
|
//url = "http://lymesa.catlbattery.com:8103/atlmeswebservice/GetParametricValueServiceService?wsdl",
|
|
|
//site = "2100",
|
|
|
//sfc = upMaterialSfc, //使用涂布膜卷号获取涂布重量特征数据
|
|
|
//memberlist = t
|
|
|
url = inifile.IniReadValue("TBParametricValueParam", "url"),
|
|
|
site = inifile.IniReadValue("TBParametricValueParam", "site"),
|
|
|
sfc = upMaterialSfc, //使用涂布膜卷号获取涂布重量特征数据
|
|
|
memberlist = t
|
|
|
};
|
|
|
|
|
|
try
|
|
|
{
|
|
|
|
|
|
var tbresult = MesWebServices.findTBData(tbServiceParam);
|
|
|
|
|
|
LogHelper.Info($"从mes中获取涂布数据:{JsonChange.ModeToJson(tbresult)}");
|
|
|
|
|
|
foreach (var item in tbresult.paramValues)
|
|
|
{
|
|
|
if (LY_HXMQ == "左" && LY_ZXMQ == 1)
|
|
|
{
|
|
|
|
|
|
if (item.parameter == "S_EIGENVALUE_1_1") LY_S_X01 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "S_EIGENVALUE_1_2") LY_S_X02 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "B_EIGENVALUE_1_1") LY_B_X01 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "B_EIGENVALUE_1_2") LY_B_X02 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "S_TARGETCW") S_TARGETCW = Convert.ToDouble((item.value));
|
|
|
|
|
|
}
|
|
|
if (LY_HXMQ == "中" && LY_ZXMQ == 1)
|
|
|
{
|
|
|
if (item.parameter == "S_EIGENVALUE_2_1") LY_S_X01 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "S_EIGENVALUE_2_2") LY_S_X02 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "B_EIGENVALUE_2_1") LY_B_X01 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "B_EIGENVALUE_2_2") LY_B_X02 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "S_TARGETCW") S_TARGETCW = Convert.ToDouble((item.value));
|
|
|
}
|
|
|
if (LY_HXMQ == "右" && LY_ZXMQ == 1)
|
|
|
{
|
|
|
if (item.parameter == "S_EIGENVALUE_3_1") LY_S_X01 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "S_EIGENVALUE_3_2") LY_S_X02 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "B_EIGENVALUE_3_1") LY_B_X01 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "B_EIGENVALUE_2_2") LY_B_X02 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "S_TARGETCW") S_TARGETCW = Convert.ToDouble((item.value));
|
|
|
}
|
|
|
if (LY_HXMQ == "左" && LY_ZXMQ != 1)
|
|
|
{
|
|
|
if (item.parameter == "S_EIGENVALUE_4_1") LY_S_X01 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "S_EIGENVALUE_4_2") LY_S_X02 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "B_EIGENVALUE_4_1") LY_B_X01 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "B_EIGENVALUE_4_2") LY_B_X02 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "S_TARGETCW") S_TARGETCW = Convert.ToDouble((item.value));
|
|
|
}
|
|
|
if (LY_HXMQ == "中" && LY_ZXMQ != 1)
|
|
|
{
|
|
|
if (item.parameter == "S_EIGENVALUE_5_1") LY_S_X01 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "S_EIGENVALUE_5_2") LY_S_X02 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "B_EIGENVALUE_5_1") LY_B_X01 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "B_EIGENVALUE_5_2") LY_B_X02 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "S_TARGETCW") S_TARGETCW = Convert.ToDouble((item.value));
|
|
|
}
|
|
|
if (LY_HXMQ == "右" && LY_ZXMQ != 1)
|
|
|
{
|
|
|
if (item.parameter == "S_EIGENVALUE_6_1") LY_S_X01 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "S_EIGENVALUE_6_2") LY_S_X02 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "B_EIGENVALUE_6_1") LY_B_X01 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "B_EIGENVALUE_6_2") LY_B_X02 = Convert.ToDouble((item.value));
|
|
|
if (item.parameter == "S_TARGETCW") S_TARGETCW = Convert.ToDouble((item.value));
|
|
|
}
|
|
|
}
|
|
|
LogHelper.Info(String.Format("涂布特征数据:LY_S_X01:{0};LY_S_X02:{1};LY_B_X01:{2};LY_B_X02:{3},S_TARGETCW:{4}", LY_S_X01, LY_S_X02, LY_B_X01, LY_B_X02, S_TARGETCW));
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogHelper.Info("从mes中获取涂布数据异常:" + ex.Message);
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
LogHelper.Info($"冷压物料特征数据:LY_FJFX:{LY_FJFX}-LY_SJFX:{LY_SJFX}-LY_SJZ:{LY_SJZ}-LY_HXMQ:{LY_HXMQ}-:LY_ZXMQ{LY_ZXMQ}-LY_WLMX:{LY_WLMX}-LY_S_X01:{LY_S_X01}-LY_S_X02:{LY_S_X02}-LY_B_X01:{LY_B_X01}-LY_B_X02:{LY_B_X02}-S_TARGETCW:{S_TARGETCW}");
|
|
|
|
|
|
machineIntegrationParametricData[] data = {
|
|
|
new machineIntegrationParametricData() {name ="LY_FJFX",dataType=ParameterDataType.TEXT, value=string.IsNullOrEmpty(LY_FJFX.ToString())?"0":LY_FJFX.ToString()},
|
|
|
new machineIntegrationParametricData() {name ="LY_SJFX",dataType=ParameterDataType.TEXT, value=string.IsNullOrEmpty(LY_SJFX.ToString())?"0":LY_SJFX.ToString()},
|
|
|
new machineIntegrationParametricData() {name ="LY_SJZ",dataType=ParameterDataType.TEXT, value=string.IsNullOrEmpty(LY_SJZ.ToString())?"0":LY_SJZ.ToString()},
|
|
|
new machineIntegrationParametricData() {name ="LY_HXMQ",dataType=ParameterDataType.TEXT, value=string.IsNullOrEmpty(LY_HXMQ.ToString())?"0":LY_HXMQ.ToString()},
|
|
|
new machineIntegrationParametricData() {name ="LY_ZXMQ",dataType=ParameterDataType.NUMBER, value=LY_ZXMQ.ToString()},
|
|
|
new machineIntegrationParametricData() {name ="LY_WLMX",dataType=ParameterDataType.TEXT, value=string.IsNullOrEmpty(LY_WLMX.ToString())?"0":LY_WLMX.ToString()},
|
|
|
new machineIntegrationParametricData() {name ="LY_S_X01",dataType=ParameterDataType.NUMBER, value=string.IsNullOrEmpty(LY_S_X01.ToString())?"0":LY_S_X01.ToString()},
|
|
|
new machineIntegrationParametricData() {name ="LY_S_X02",dataType=ParameterDataType.NUMBER, value=string.IsNullOrEmpty(LY_S_X02.ToString())?"0":LY_S_X02.ToString()},
|
|
|
new machineIntegrationParametricData() {name ="LY_B_X01",dataType=ParameterDataType.NUMBER, value=string.IsNullOrEmpty(LY_B_X01.ToString())?"0":LY_B_X01.ToString()},
|
|
|
new machineIntegrationParametricData() {name ="LY_B_X02",dataType=ParameterDataType.NUMBER, value=string.IsNullOrEmpty(LY_B_X02.ToString())?"0":LY_B_X02.ToString()},
|
|
|
new machineIntegrationParametricData() {name ="S_TARGETCW",dataType=ParameterDataType.NUMBER, value=string.IsNullOrEmpty(S_TARGETCW.ToString())?"0":S_TARGETCW.ToString()},
|
|
|
};
|
|
|
return data;
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogHelper.Info("冷压物料特征数据获取异常:" + ex.Message);
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|