|
|
|
@ -7,6 +7,7 @@ using HighWayIot.Winform.Business;
|
|
|
|
|
using HighWayIot.Winform.MainForm;
|
|
|
|
|
using HighWayIot.Winform.UserControlPages.RecipeConfigPages;
|
|
|
|
|
using HighWayIot.Winform.UserControlPages.SysConfigPages;
|
|
|
|
|
using HslCommunication.Profinet.Siemens.S7PlusHelper;
|
|
|
|
|
using Models;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections;
|
|
|
|
@ -127,7 +128,7 @@ namespace HighWayIot.Winform.UserControlPages
|
|
|
|
|
|
|
|
|
|
NowRecipeCode = RecipeDataGridView.Rows[0].Cells["RecipeCode"].Value.ToString();
|
|
|
|
|
InitPositionEntities();
|
|
|
|
|
if(PlcConnect.IsConnect1 == true)
|
|
|
|
|
if (PlcConnect.IsConnect1 == true)
|
|
|
|
|
{
|
|
|
|
|
//读取SPEC编号
|
|
|
|
|
PlcSpecNoLabel.Text = PlcConnect.ReadUInt321("D206").ToString();
|
|
|
|
@ -139,6 +140,68 @@ namespace HighWayIot.Winform.UserControlPages
|
|
|
|
|
|
|
|
|
|
#region 配方信息
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 所选配方内容更改事件
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void RecipeDataGridView_SelectionChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
int a = RecipeDataGridView.CurrentRow.Index;
|
|
|
|
|
NowRecipeCode = RecipeDataGridView.Rows[a].Cells["RecipeCode"].Value.ToString();
|
|
|
|
|
SpecNoLabel.Text = RecipeDataGridView.Rows[a].Cells["RecipeSpecCode"].Value.ToString();
|
|
|
|
|
SpecNameLabel.Text = RecipeDataGridView.Rows[a].Cells["RecipeSpecName"].Value.ToString();
|
|
|
|
|
|
|
|
|
|
//初始化工位参数类
|
|
|
|
|
InitPositionEntities();
|
|
|
|
|
|
|
|
|
|
WeightLists = zxWeightService.GetWeightInfos(NowRecipeCode);
|
|
|
|
|
|
|
|
|
|
//WeightToDataSource();
|
|
|
|
|
|
|
|
|
|
WeightDataGridView.DataSource = null;
|
|
|
|
|
WeightDataGridView.DataSource = WeightLists;
|
|
|
|
|
|
|
|
|
|
//设置参数
|
|
|
|
|
var paraData = zxRecipeParaService.GetRecipeParaInfoByRecipeCode(NowRecipeCode);
|
|
|
|
|
int flag = GetSelectIndex();
|
|
|
|
|
var positionParaData = zxRecipePositionParaService.GetRecipePositionParaInfos(x => x.RecipeCode == NowRecipeCode);
|
|
|
|
|
|
|
|
|
|
//没有就全0
|
|
|
|
|
if (paraData.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
SetPublicParaValue(new ZxRecipeParaEntity());
|
|
|
|
|
zxRecipeParaEntity = new ZxRecipeParaEntity();
|
|
|
|
|
}
|
|
|
|
|
//有就显示
|
|
|
|
|
else if (paraData.Count == 1)
|
|
|
|
|
{
|
|
|
|
|
SetPublicParaValue(paraData[0]);
|
|
|
|
|
zxRecipeParaEntity = paraData[0];
|
|
|
|
|
}
|
|
|
|
|
//有多条设为第一条
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("存在多条未删除的相同公共配方字段信息!将设置为第一条。点击清除脏数据");
|
|
|
|
|
SetPublicParaValue(paraData[0]);
|
|
|
|
|
zxRecipeParaEntity = paraData[0];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//没有就全0
|
|
|
|
|
if (positionParaData.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
SetPrivateParaValue(new ZxRecipePositionParaEntity());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
foreach (var item in positionParaData)
|
|
|
|
|
{
|
|
|
|
|
ChangePositionEntities(item);
|
|
|
|
|
}
|
|
|
|
|
SetPrivateParaValue(zxRecipePositionParaEntity.Where(x => x.Position == flag).FirstOrDefault());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 添加配方信息
|
|
|
|
|
/// </summary>
|
|
|
|
@ -459,68 +522,6 @@ namespace HighWayIot.Winform.UserControlPages
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 所选配方内容更改事件
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void RecipeDataGridView_SelectionChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
int a = RecipeDataGridView.CurrentRow.Index;
|
|
|
|
|
NowRecipeCode = RecipeDataGridView.Rows[a].Cells["RecipeCode"].Value.ToString();
|
|
|
|
|
SpecNoLabel.Text = RecipeDataGridView.Rows[a].Cells["RecipeSpecCode"].Value.ToString();
|
|
|
|
|
SpecNameLabel.Text = RecipeDataGridView.Rows[a].Cells["RecipeSpecName"].Value.ToString();
|
|
|
|
|
|
|
|
|
|
//初始化工位参数类
|
|
|
|
|
InitPositionEntities();
|
|
|
|
|
|
|
|
|
|
WeightLists = zxWeightService.GetWeightInfos(NowRecipeCode);
|
|
|
|
|
|
|
|
|
|
//WeightToDataSource();
|
|
|
|
|
|
|
|
|
|
WeightDataGridView.DataSource = null;
|
|
|
|
|
WeightDataGridView.DataSource = WeightLists;
|
|
|
|
|
|
|
|
|
|
//设置参数
|
|
|
|
|
var paraData = zxRecipeParaService.GetRecipeParaInfoByRecipeCode(NowRecipeCode);
|
|
|
|
|
int flag = GetSelectIndex();
|
|
|
|
|
var positionParaData = zxRecipePositionParaService.GetRecipePositionParaInfos(x => x.RecipeCode == NowRecipeCode);
|
|
|
|
|
|
|
|
|
|
//没有就全0
|
|
|
|
|
if (paraData.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
SetPublicParaValue(new ZxRecipeParaEntity());
|
|
|
|
|
zxRecipeParaEntity = new ZxRecipeParaEntity();
|
|
|
|
|
}
|
|
|
|
|
//有就显示
|
|
|
|
|
else if (paraData.Count == 1)
|
|
|
|
|
{
|
|
|
|
|
SetPublicParaValue(paraData[0]);
|
|
|
|
|
zxRecipeParaEntity = paraData[0];
|
|
|
|
|
}
|
|
|
|
|
//有多条设为第一条
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("存在多条未删除的相同公共配方字段信息!将设置为第一条。点击清除脏数据");
|
|
|
|
|
SetPublicParaValue(paraData[0]);
|
|
|
|
|
zxRecipeParaEntity = paraData[0];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//没有就全0
|
|
|
|
|
if (positionParaData.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
SetPrivateParaValue(new ZxRecipePositionParaEntity());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
foreach (var item in positionParaData)
|
|
|
|
|
{
|
|
|
|
|
ChangePositionEntities(item);
|
|
|
|
|
}
|
|
|
|
|
SetPrivateParaValue(zxRecipePositionParaEntity.Where(x => x.Position == flag).FirstOrDefault());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 参数设置
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -1012,6 +1013,8 @@ namespace HighWayIot.Winform.UserControlPages
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 配方数据同步
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 同步数据按钮
|
|
|
|
|
/// </summary>
|
|
|
|
@ -1019,32 +1022,39 @@ namespace HighWayIot.Winform.UserControlPages
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void SyncDataButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (zxMesPlanTransferService.GetFlagState())
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("正在同步数据,请稍后");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (zxMesPlanTransferService.SetFlagTrue())
|
|
|
|
|
{
|
|
|
|
|
Task.Run(() => {
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
if (!zxMesPlanTransferService.GetFlagState())
|
|
|
|
|
{
|
|
|
|
|
RecipeDataSync(zxMesPlanTransferService.GetRecipeInfos(x => x.Uuid != "syncsignal"));
|
|
|
|
|
}
|
|
|
|
|
Task.Delay(1000);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
RecipeDataSync(zxMesPlanTransferService.GetRecipeInfos(x => x.Uuid != "syncsignal"));
|
|
|
|
|
//if (zxMesPlanTransferService.GetFlagState())
|
|
|
|
|
//{
|
|
|
|
|
// MessageBox.Show("正在同步数据,请稍后");
|
|
|
|
|
// return;
|
|
|
|
|
//}
|
|
|
|
|
//if (zxMesPlanTransferService.SetFlagTrue())
|
|
|
|
|
//{
|
|
|
|
|
// Task.Run(() =>
|
|
|
|
|
// {
|
|
|
|
|
// while (true)
|
|
|
|
|
// {
|
|
|
|
|
// if (!zxMesPlanTransferService.GetFlagState())
|
|
|
|
|
// {
|
|
|
|
|
// RecipeDataSync(zxMesPlanTransferService.GetRecipeInfos(x => x.Uuid != "syncsignal"));
|
|
|
|
|
// MessageBox.Show("同步完成");
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
// Task.Delay(1000);
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 配方数据同步类
|
|
|
|
|
/// 配方数据同步方法
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void RecipeDataSync(List<ZxMesPlanTransferEntity> sourceEntity)
|
|
|
|
|
{
|
|
|
|
|
foreach(var newRecipes in sourceEntity)
|
|
|
|
|
ZxOpenMixMaterialService zxOpenMixMaterialService = new ZxOpenMixMaterialService();
|
|
|
|
|
var openMixConfig = zxOpenMixMaterialService.GetInfos();
|
|
|
|
|
|
|
|
|
|
foreach (var newRecipes in sourceEntity)
|
|
|
|
|
{
|
|
|
|
|
//////////////////////////////更新配方表/////////////////////////////////
|
|
|
|
|
var newEneitys = RecipeLists.Where(x => x.RecipeName == newRecipes.RecipeName).ToList();
|
|
|
|
@ -1082,7 +1092,7 @@ namespace HighWayIot.Winform.UserControlPages
|
|
|
|
|
var material2 = zxMaterialService.GetMaterialInfoByMaterialName(newRecipes.MaterialName2);
|
|
|
|
|
var material3 = zxMaterialService.GetMaterialInfoByMaterialName(newRecipes.MaterialName3);
|
|
|
|
|
//物料1
|
|
|
|
|
if (string.IsNullOrEmpty(newRecipes.MaterialName1))
|
|
|
|
|
if (!string.IsNullOrEmpty(newRecipes.MaterialName1))
|
|
|
|
|
{
|
|
|
|
|
if (material1 != null) //有这个物料
|
|
|
|
|
{
|
|
|
|
@ -1090,7 +1100,7 @@ namespace HighWayIot.Winform.UserControlPages
|
|
|
|
|
var weightInfo = zxWeightService.GetWeightInfos(recipeCode, material1.MaterialCode, "基部胶");
|
|
|
|
|
if (weightInfo == null)
|
|
|
|
|
{
|
|
|
|
|
zxWeightService.InsertWeightInfo(new ZxWeightEntity()
|
|
|
|
|
bool a = zxWeightService.InsertWeightInfo(new ZxWeightEntity()
|
|
|
|
|
{
|
|
|
|
|
RecipeCode = recipeCode,
|
|
|
|
|
MaterialCode = material1.MaterialCode,
|
|
|
|
@ -1114,7 +1124,7 @@ namespace HighWayIot.Winform.UserControlPages
|
|
|
|
|
else //没这个物料
|
|
|
|
|
{
|
|
|
|
|
//先添加物料
|
|
|
|
|
ZxMaterialEntity newMaterialEntity = new ZxMaterialEntity()
|
|
|
|
|
material1 = new ZxMaterialEntity()
|
|
|
|
|
{
|
|
|
|
|
MaterialCode = DateTime.Now.ToString("yyyyMMddHHmmssffff"),
|
|
|
|
|
MaterialName = newRecipes.MaterialName1,
|
|
|
|
@ -1122,16 +1132,16 @@ namespace HighWayIot.Winform.UserControlPages
|
|
|
|
|
IsDeleted = false,
|
|
|
|
|
IsUse = true
|
|
|
|
|
};
|
|
|
|
|
zxMaterialService.InsertMaterialInfo(newMaterialEntity);
|
|
|
|
|
zxMaterialService.InsertMaterialInfo(material1);
|
|
|
|
|
//查询是否有这个配方这个物料的称量 有更改 没有添加
|
|
|
|
|
var weightInfo = zxWeightService.GetWeightInfos(recipeCode, newMaterialEntity.MaterialCode, "基部胶");
|
|
|
|
|
var weightInfo = zxWeightService.GetWeightInfos(recipeCode, material1.MaterialCode, "基部胶");
|
|
|
|
|
if (weightInfo == null) //没有配方数据
|
|
|
|
|
{
|
|
|
|
|
zxWeightService.InsertWeightInfo(new ZxWeightEntity()
|
|
|
|
|
{
|
|
|
|
|
RecipeCode = recipeCode,
|
|
|
|
|
MaterialCode = newMaterialEntity.MaterialCode,
|
|
|
|
|
MaterialName = newMaterialEntity.MaterialName,
|
|
|
|
|
MaterialCode = material1.MaterialCode,
|
|
|
|
|
MaterialName = material1.MaterialName,
|
|
|
|
|
MaterialType = "基部胶",
|
|
|
|
|
SetWidth = (decimal?)newRecipes.MaterialWidth1,
|
|
|
|
|
SetWeight = (decimal?)newRecipes.MaterialWeight1,
|
|
|
|
@ -1150,20 +1160,20 @@ namespace HighWayIot.Winform.UserControlPages
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//物料2
|
|
|
|
|
if (string.IsNullOrEmpty(newRecipes.MaterialName2))
|
|
|
|
|
if (!string.IsNullOrEmpty(newRecipes.MaterialName2))
|
|
|
|
|
{
|
|
|
|
|
if (material2 != null) //有这个物料
|
|
|
|
|
{
|
|
|
|
|
//查询是否有这个配方这个物料的称量 有更改 没有添加
|
|
|
|
|
var weightInfo = zxWeightService.GetWeightInfos(recipeCode, material2.MaterialCode, "基部胶");
|
|
|
|
|
var weightInfo = zxWeightService.GetWeightInfos(recipeCode, material2.MaterialCode, "缓冲胶");
|
|
|
|
|
if (weightInfo == null)
|
|
|
|
|
{
|
|
|
|
|
zxWeightService.InsertWeightInfo(new ZxWeightEntity()
|
|
|
|
|
bool a = zxWeightService.InsertWeightInfo(new ZxWeightEntity()
|
|
|
|
|
{
|
|
|
|
|
RecipeCode = recipeCode,
|
|
|
|
|
MaterialCode = material1.MaterialCode,
|
|
|
|
|
MaterialName = material1.MaterialName,
|
|
|
|
|
MaterialType = "基部胶",
|
|
|
|
|
MaterialType = "缓冲胶",
|
|
|
|
|
SetWidth = (decimal?)newRecipes.MaterialWidth2,
|
|
|
|
|
SetWeight = (decimal?)newRecipes.MaterialWeight2,
|
|
|
|
|
SetLayer = newRecipes.MaterialLayers2,
|
|
|
|
@ -1182,7 +1192,7 @@ namespace HighWayIot.Winform.UserControlPages
|
|
|
|
|
else //没这个物料
|
|
|
|
|
{
|
|
|
|
|
//先添加物料
|
|
|
|
|
ZxMaterialEntity newMaterialEntity = new ZxMaterialEntity()
|
|
|
|
|
material2 = new ZxMaterialEntity()
|
|
|
|
|
{
|
|
|
|
|
MaterialCode = DateTime.Now.ToString("yyyyMMddHHmmssffff"),
|
|
|
|
|
MaterialName = newRecipes.MaterialName2,
|
|
|
|
@ -1190,17 +1200,17 @@ namespace HighWayIot.Winform.UserControlPages
|
|
|
|
|
IsDeleted = false,
|
|
|
|
|
IsUse = true
|
|
|
|
|
};
|
|
|
|
|
zxMaterialService.InsertMaterialInfo(newMaterialEntity);
|
|
|
|
|
zxMaterialService.InsertMaterialInfo(material2);
|
|
|
|
|
//查询是否有这个配方这个物料的称量 有更改 没有添加
|
|
|
|
|
var weightInfo = zxWeightService.GetWeightInfos(recipeCode, newMaterialEntity.MaterialCode, "基部胶");
|
|
|
|
|
var weightInfo = zxWeightService.GetWeightInfos(recipeCode, material2.MaterialCode, "缓冲胶");
|
|
|
|
|
if (weightInfo == null) //没有配方数据
|
|
|
|
|
{
|
|
|
|
|
zxWeightService.InsertWeightInfo(new ZxWeightEntity()
|
|
|
|
|
{
|
|
|
|
|
RecipeCode = recipeCode,
|
|
|
|
|
MaterialCode = newMaterialEntity.MaterialCode,
|
|
|
|
|
MaterialName = newMaterialEntity.MaterialName,
|
|
|
|
|
MaterialType = "基部胶",
|
|
|
|
|
MaterialCode = material2.MaterialCode,
|
|
|
|
|
MaterialName = material2.MaterialName,
|
|
|
|
|
MaterialType = "缓冲胶",
|
|
|
|
|
SetWidth = (decimal?)newRecipes.MaterialWidth2,
|
|
|
|
|
SetWeight = (decimal?)newRecipes.MaterialWeight2,
|
|
|
|
|
SetLayer = newRecipes.MaterialLayers2,
|
|
|
|
@ -1219,20 +1229,20 @@ namespace HighWayIot.Winform.UserControlPages
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//物料3
|
|
|
|
|
if (string.IsNullOrEmpty(newRecipes.MaterialName3))
|
|
|
|
|
if (!string.IsNullOrEmpty(newRecipes.MaterialName3))
|
|
|
|
|
{
|
|
|
|
|
if (material3 != null) //有这个物料
|
|
|
|
|
{
|
|
|
|
|
//查询是否有这个配方这个物料的称量 有更改 没有添加
|
|
|
|
|
var weightInfo = zxWeightService.GetWeightInfos(recipeCode, material3.MaterialCode, "基部胶");
|
|
|
|
|
var weightInfo = zxWeightService.GetWeightInfos(recipeCode, material3.MaterialCode, "胎面胶");
|
|
|
|
|
if (weightInfo == null)
|
|
|
|
|
{
|
|
|
|
|
zxWeightService.InsertWeightInfo(new ZxWeightEntity()
|
|
|
|
|
bool a = zxWeightService.InsertWeightInfo(new ZxWeightEntity()
|
|
|
|
|
{
|
|
|
|
|
RecipeCode = recipeCode,
|
|
|
|
|
MaterialCode = material3.MaterialCode,
|
|
|
|
|
MaterialName = material3.MaterialName,
|
|
|
|
|
MaterialType = "基部胶",
|
|
|
|
|
MaterialType = "胎面胶",
|
|
|
|
|
SetWidth = (decimal?)newRecipes.MaterialWidth3,
|
|
|
|
|
SetWeight = (decimal?)newRecipes.MaterialWeight3,
|
|
|
|
|
SetLayer = newRecipes.MaterialLayers3,
|
|
|
|
@ -1251,7 +1261,7 @@ namespace HighWayIot.Winform.UserControlPages
|
|
|
|
|
else //没这个物料
|
|
|
|
|
{
|
|
|
|
|
//先添加物料
|
|
|
|
|
ZxMaterialEntity newMaterialEntity = new ZxMaterialEntity()
|
|
|
|
|
material3 = new ZxMaterialEntity()
|
|
|
|
|
{
|
|
|
|
|
MaterialCode = DateTime.Now.ToString("yyyyMMddHHmmssffff"),
|
|
|
|
|
MaterialName = newRecipes.MaterialName3,
|
|
|
|
@ -1259,17 +1269,17 @@ namespace HighWayIot.Winform.UserControlPages
|
|
|
|
|
IsDeleted = false,
|
|
|
|
|
IsUse = true
|
|
|
|
|
};
|
|
|
|
|
zxMaterialService.InsertMaterialInfo(newMaterialEntity);
|
|
|
|
|
zxMaterialService.InsertMaterialInfo(material3);
|
|
|
|
|
//查询是否有这个配方这个物料的称量 有更改 没有添加
|
|
|
|
|
var weightInfo = zxWeightService.GetWeightInfos(recipeCode, newMaterialEntity.MaterialCode, "基部胶");
|
|
|
|
|
var weightInfo = zxWeightService.GetWeightInfos(recipeCode, material3.MaterialCode, "胎面胶");
|
|
|
|
|
if (weightInfo == null) //没有配方数据
|
|
|
|
|
{
|
|
|
|
|
zxWeightService.InsertWeightInfo(new ZxWeightEntity()
|
|
|
|
|
{
|
|
|
|
|
RecipeCode = recipeCode,
|
|
|
|
|
MaterialCode = newMaterialEntity.MaterialCode,
|
|
|
|
|
MaterialName = newMaterialEntity.MaterialName,
|
|
|
|
|
MaterialType = "基部胶",
|
|
|
|
|
MaterialCode = material3.MaterialCode,
|
|
|
|
|
MaterialName = material3.MaterialName,
|
|
|
|
|
MaterialType = "胎面胶",
|
|
|
|
|
SetWidth = (decimal?)newRecipes.MaterialWidth3,
|
|
|
|
|
SetWeight = (decimal?)newRecipes.MaterialWeight3,
|
|
|
|
|
SetLayer = newRecipes.MaterialLayers3,
|
|
|
|
@ -1286,7 +1296,157 @@ namespace HighWayIot.Winform.UserControlPages
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////更新配方参数//////////////////////////////////////
|
|
|
|
|
ZxRecipeParaEntity recipePara = zxRecipeParaService.GetRecipeParaInfoByRecipeCode(recipeCode).FirstOrDefault();
|
|
|
|
|
if (recipePara == null) //不存早
|
|
|
|
|
{
|
|
|
|
|
recipePara = new ZxRecipeParaEntity()
|
|
|
|
|
{
|
|
|
|
|
SpecName = newRecipes.SpecName,
|
|
|
|
|
SpecCode = newRecipes.SpecCode,
|
|
|
|
|
RimInch = newRecipes.RimInch,
|
|
|
|
|
LightWidth = newRecipes.FixRubWidth,
|
|
|
|
|
TireWeight = newRecipes.TireWeight,
|
|
|
|
|
RecipeCode = recipeCode
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
foreach (var config in openMixConfig)
|
|
|
|
|
{
|
|
|
|
|
if (config.MaterialName == material1.MaterialName
|
|
|
|
|
|| config.MaterialName == material2.MaterialName
|
|
|
|
|
|| config.MaterialName == material3.MaterialName)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var prop = recipePara.GetType().GetProperty($"S{config.StationNo + 1}");
|
|
|
|
|
prop.SetValue(recipePara, true);
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
zxRecipeParaService.InsertRecipeParaInfo(recipePara);
|
|
|
|
|
}
|
|
|
|
|
else //存在
|
|
|
|
|
{
|
|
|
|
|
recipePara.SpecName = newRecipes.SpecName;
|
|
|
|
|
recipePara.SpecCode = newRecipes.SpecCode;
|
|
|
|
|
recipePara.RimInch = newRecipes.RimInch;
|
|
|
|
|
recipePara.LightWidth = newRecipes.FixRubWidth;
|
|
|
|
|
recipePara.TireWeight = newRecipes.TireWeight;
|
|
|
|
|
|
|
|
|
|
foreach (var config in openMixConfig)
|
|
|
|
|
{
|
|
|
|
|
if (config.MaterialName == material1.MaterialName
|
|
|
|
|
|| config.MaterialName == material2.MaterialName
|
|
|
|
|
|| config.MaterialName == material3.MaterialName)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var prop = recipePara.GetType().GetProperty($"S{config.StationNo + 1}");
|
|
|
|
|
prop.SetValue(recipePara, true);
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
zxRecipeParaService.UpdateRecipeParaInfo(recipePara);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////更新配方工位参数//////////////////////////////////////
|
|
|
|
|
List<ZxRecipePositionParaEntity> positionParaEntities = zxRecipePositionParaService.GetRecipePositionParaInfoByRecipeCode(recipeCode);
|
|
|
|
|
|
|
|
|
|
int position = 1;
|
|
|
|
|
for (int i = 0; i < 5; i++)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var prop = recipePara.GetType().GetProperty($"S{i + 2}");
|
|
|
|
|
object value = prop.GetValue(recipePara);
|
|
|
|
|
// 处理可空类型的null值情况
|
|
|
|
|
if (value == null)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
bool positionValue;
|
|
|
|
|
positionValue = Convert.ToBoolean(value);
|
|
|
|
|
if(positionValue == true)
|
|
|
|
|
{
|
|
|
|
|
ZxRecipePositionParaEntity positionPara = positionParaEntities.Where(x => x.Position == (i + 1)).FirstOrDefault();
|
|
|
|
|
if (position == 1)
|
|
|
|
|
{
|
|
|
|
|
if (positionPara == null)//没工位参数
|
|
|
|
|
{
|
|
|
|
|
positionPara = new ZxRecipePositionParaEntity()
|
|
|
|
|
{
|
|
|
|
|
RecipeCode = recipeCode,
|
|
|
|
|
Position = i + 1,
|
|
|
|
|
E5 = newRecipes.MaterialLayers1
|
|
|
|
|
};
|
|
|
|
|
zxRecipePositionParaService.InsertRecipePositionParaInfo(positionPara);
|
|
|
|
|
}
|
|
|
|
|
else//有工位参数
|
|
|
|
|
{
|
|
|
|
|
positionPara.E5 = newRecipes.MaterialLayers1;
|
|
|
|
|
zxRecipePositionParaService.UpdateRecipePositionParaInfo(positionPara);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (position == 2)
|
|
|
|
|
{
|
|
|
|
|
if (positionPara == null)//没工位参数
|
|
|
|
|
{
|
|
|
|
|
positionPara = new ZxRecipePositionParaEntity()
|
|
|
|
|
{
|
|
|
|
|
RecipeCode = recipeCode,
|
|
|
|
|
Position = i + 1,
|
|
|
|
|
E5 = newRecipes.MaterialLayers2
|
|
|
|
|
};
|
|
|
|
|
zxRecipePositionParaService.InsertRecipePositionParaInfo(positionPara);
|
|
|
|
|
}
|
|
|
|
|
else//有工位参数
|
|
|
|
|
{
|
|
|
|
|
positionPara.E5 = newRecipes.MaterialLayers2;
|
|
|
|
|
zxRecipePositionParaService.UpdateRecipePositionParaInfo(positionPara);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (positionPara == null)//没工位参数
|
|
|
|
|
{
|
|
|
|
|
positionPara = new ZxRecipePositionParaEntity()
|
|
|
|
|
{
|
|
|
|
|
RecipeCode = recipeCode,
|
|
|
|
|
Position = i + 1,
|
|
|
|
|
E5 = newRecipes.MaterialLayers3
|
|
|
|
|
};
|
|
|
|
|
zxRecipePositionParaService.InsertRecipePositionParaInfo(positionPara);
|
|
|
|
|
}
|
|
|
|
|
else//有工位参数
|
|
|
|
|
{
|
|
|
|
|
positionPara.E5 = newRecipes.MaterialLayers3;
|
|
|
|
|
zxRecipePositionParaService.UpdateRecipePositionParaInfo(positionPara);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
position++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|