|
|
using MaterialTraceability.Business;
|
|
|
using MaterialTraceability.Entity.DAO;
|
|
|
using MaterialTraceability.Entity.DTO;
|
|
|
using MaterialTraceability.Entity.UpLoad;
|
|
|
using MaterialTraceability.SqlSugar;
|
|
|
using MaterialTraceability.SqlSugar.ServiceImpl;
|
|
|
using MaterialTraceability.WebService;
|
|
|
using MaterialTraceability.WebService.MachineIntegrationServiceService;
|
|
|
using MaterialTraceability.WebService.Param;
|
|
|
using MaterialTraceabilityUI.Common;
|
|
|
using SqlSugar;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Data;
|
|
|
using System.Linq;
|
|
|
using System.Linq.Expressions;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
using System.Windows;
|
|
|
using System.Windows.Controls;
|
|
|
using System.Windows.Data;
|
|
|
using System.Windows.Documents;
|
|
|
using System.Windows.Input;
|
|
|
using System.Windows.Media;
|
|
|
using System.Windows.Media.Imaging;
|
|
|
using System.Windows.Navigation;
|
|
|
using System.Windows.Shapes;
|
|
|
|
|
|
namespace MaterialTraceabilityUI
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// ShaftInfoControl.xaml 的交互逻辑
|
|
|
/// </summary>
|
|
|
public partial class ShaftInfoControl : UserControl
|
|
|
{
|
|
|
private IBaseServices<ProShaftInfo> baseServices = new BaseServices<ProShaftInfo>();
|
|
|
private UpLoadBusiness upLoadBusiness = UpLoadBusiness.Instance;
|
|
|
private IBaseServices<ProDownRecord> downRecordServices = new BaseServices<ProDownRecord>();
|
|
|
//上料记录
|
|
|
private IBaseServices<ProUpRecord> upRecordServices = new BaseServices<ProUpRecord>();
|
|
|
|
|
|
private UpLoadBusiness loadBusiness = UpLoadBusiness.Instance;
|
|
|
private AppConfigDto appConfig = AppConfigDto.Instance;
|
|
|
/// <summary>
|
|
|
/// Mes WebService接口
|
|
|
/// </summary>
|
|
|
private IMesWebServices MesWebServices = new MesWebServicesImpl();
|
|
|
|
|
|
public ShaftInfoControl()
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
}
|
|
|
|
|
|
private void Seach_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
Refresh();
|
|
|
}
|
|
|
|
|
|
private void Refresh()
|
|
|
{
|
|
|
Expression<Func<ProShaftInfo, bool>> exp = s1 => true;
|
|
|
exp = exp.And(x => x.processId.Equals(appConfig.processId));
|
|
|
|
|
|
List<ProShaftInfo> recordLogInfos = baseServices.Query(exp).Result;
|
|
|
|
|
|
foreach(var x in recordLogInfos)
|
|
|
{
|
|
|
x.processId = x.endFlag == 1 ? "是" : "否";
|
|
|
if (appConfig.machineId == 4)
|
|
|
{
|
|
|
if (x.shaftName.Contains("左"))
|
|
|
{
|
|
|
x.shaftName = x.shaftName.Replace("左", "右");
|
|
|
continue;
|
|
|
}
|
|
|
if (x.shaftName.Contains("右"))
|
|
|
{
|
|
|
x.shaftName = x.shaftName.Replace("右", "左");
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
this.ReadRecordDataGrid.ItemsSource = recordLogInfos;
|
|
|
}
|
|
|
|
|
|
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
//if(appConfig.processId.Contains("MQ"))
|
|
|
//{
|
|
|
// this.save.Visibility = Visibility.Visible;
|
|
|
//}
|
|
|
|
|
|
//if (!appConfig.processId.Contains("TB") && loadBusiness.JudgeResourceIsUplpadData())
|
|
|
//{
|
|
|
// this.sfcLabel.Visibility = Visibility.Visible;
|
|
|
// this.sfcStr.Visibility = Visibility.Visible;
|
|
|
// this.upLoad.Visibility = Visibility.Visible;
|
|
|
//}
|
|
|
|
|
|
Refresh();
|
|
|
}
|
|
|
|
|
|
private void Save_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
if (!"1".Equals(ConfigHelper.GetConfig("roleId")) && !"2".Equals(ConfigHelper.GetConfig("roleId")))
|
|
|
{
|
|
|
System.Windows.MessageBox.Show("请登录系统管理账号进行操作");
|
|
|
}
|
|
|
try
|
|
|
{
|
|
|
ProShaftInfo shaftInfo = (ProShaftInfo)this.ReadRecordDataGrid.SelectedItem;
|
|
|
|
|
|
if (shaftInfo == null)
|
|
|
{
|
|
|
MessageBox.Show("未选择绑定信息");
|
|
|
return;
|
|
|
}
|
|
|
LogHelperBusiness.LogInfo("手动修改绑定信息:"+JsonChange.ModeToJson(shaftInfo));
|
|
|
Expression<Func<ProShaftInfo, bool>> exp = s1 => true;
|
|
|
exp = exp.And(x => x.processId == appConfig.processId && x.positionId == shaftInfo.positionId);
|
|
|
Expression<Func<ProShaftInfo, object>> order = s1 => s1.bindTime;
|
|
|
ProShaftInfo info = baseServices.QueryFirst(exp, order, false).Result;
|
|
|
if (info == null)
|
|
|
{
|
|
|
MessageBox.Show("绑定信息为空");
|
|
|
return;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
info.bindRfid = shaftInfo.bindRfid;
|
|
|
info.bindSfc = shaftInfo.bindSfc;
|
|
|
info.bindEaValue = shaftInfo.bindEaValue;
|
|
|
bool result = baseServices.Update(info).Result;
|
|
|
if (result)
|
|
|
{
|
|
|
MessageBox.Show("保存成功");
|
|
|
Refresh();
|
|
|
|
|
|
if(Convert.ToInt32(shaftInfo.positionId) < 4)
|
|
|
{
|
|
|
//添加下料记录
|
|
|
downRecordServices.Add(new ProDownRecord()
|
|
|
{
|
|
|
Id = System.Guid.NewGuid().ToString("N"),
|
|
|
MachineId = appConfig.machineId,
|
|
|
PositionId = Convert.ToInt32(shaftInfo.positionId),
|
|
|
Rfid = shaftInfo.bindRfid,
|
|
|
Sfc = shaftInfo.bindSfc,
|
|
|
IsProduction = 0,
|
|
|
beginTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
|
|
|
RecordTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
|
|
|
});
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//添加上料记录
|
|
|
upRecordServices.Add(new ProUpRecord()
|
|
|
{
|
|
|
Id = System.Guid.NewGuid().ToString(),
|
|
|
MachineId = appConfig.machineId,
|
|
|
PositionId = Convert.ToInt32(shaftInfo.positionId),
|
|
|
Rfid = shaftInfo.bindRfid,
|
|
|
IsProduction = 0,
|
|
|
Sfc = shaftInfo.bindSfc,
|
|
|
eaValue = Convert.ToInt32(shaftInfo.bindEaValue),
|
|
|
RecordTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
|
|
|
beginTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
MessageBox.Show("保存失败");
|
|
|
}
|
|
|
}
|
|
|
}catch(Exception ex)
|
|
|
{
|
|
|
LogHelperBusiness.LogError("保存绑定信息异常",ex);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 上传数据并完工
|
|
|
/// </summary>
|
|
|
/// <param name="sender"></param>
|
|
|
/// <param name="e"></param>
|
|
|
private void UpLoad_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
//通过服务器获取膜卷号绑定的数据
|
|
|
ProShaftInfo shaftInfo = (ProShaftInfo)this.ReadRecordDataGrid.SelectedItem;
|
|
|
|
|
|
if (shaftInfo == null)
|
|
|
{
|
|
|
MessageBox.Show("未选择绑定信息");
|
|
|
return;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
MachineIntegrationServiceParam machineIntegrationServiceParam = new MachineIntegrationServiceParam();
|
|
|
|
|
|
if(appConfig.processId.Contains("MQ"))
|
|
|
{
|
|
|
MqUpLoad mqUpLoad = GetMqUpLoad(shaftInfo);
|
|
|
machineIntegrationParametricData[] data = {
|
|
|
new machineIntegrationParametricData() {name ="MQ_FJFX",dataType=ParameterDataType.TEXT, value= StringExtension.IsBlank(mqUpLoad.upDirection) ? "0" : mqUpLoad.upDirection},
|
|
|
new machineIntegrationParametricData() {name ="MQ_SJFX",dataType=ParameterDataType.TEXT, value= StringExtension.IsBlank(mqUpLoad.downDirection) ? "0" :mqUpLoad.downDirection},
|
|
|
new machineIntegrationParametricData() {name ="MQ_SJZ",dataType=ParameterDataType.TEXT, value= StringExtension.IsBlank(mqUpLoad.downPosition) ? "0" :mqUpLoad.downPosition},
|
|
|
new machineIntegrationParametricData() {name ="FIRST ARTICLE",dataType=ParameterDataType.TEXT, value= mqUpLoad.firstArticle},
|
|
|
new machineIntegrationParametricData() {name ="MQ_WLMX",dataType=ParameterDataType.TEXT, value= StringExtension.IsBlank(mqUpLoad.mqMaterialFace) ? "0" :mqUpLoad.mqMaterialFace},
|
|
|
new machineIntegrationParametricData() {name ="MQ_JRLLFX",dataType=ParameterDataType.TEXT, value= StringExtension.IsBlank(mqUpLoad.jrDirection) ? "0" :mqUpLoad.jrDirection},
|
|
|
new machineIntegrationParametricData() {name ="S_CW",dataType=ParameterDataType.TEXT, value=StringExtension.IsBlank(mqUpLoad.scw) ? "0" : mqUpLoad.scw},
|
|
|
new machineIntegrationParametricData() {name ="B_CW",dataType=ParameterDataType.TEXT, value=StringExtension.IsBlank(mqUpLoad.bcw) ? "0" : mqUpLoad.bcw},
|
|
|
};
|
|
|
|
|
|
machineIntegrationServiceParam = new MachineIntegrationServiceParam()
|
|
|
{
|
|
|
url = "http://lymesa.catlbattery.com:8103/atlmeswebservice/MachineIntegrationServiceService?wsdl",
|
|
|
site = "2100",
|
|
|
// sfc = this.sfcStr.Text.ToString(), //将数据上传至拆分后的膜卷号
|
|
|
operation = mqUpLoad.operation,
|
|
|
operationRevision = "#",
|
|
|
activityId = "EAP_WS",
|
|
|
resource = mqUpLoad.resource,
|
|
|
dcGroup = mqUpLoad.dcGroup,
|
|
|
dcGroupRevision = "#",
|
|
|
parametricArray = data,
|
|
|
modeProcessSfc = MaterialTraceability.WebService.MachineIntegrationServiceService.ModeProcessSfc.MODE_COMPLETE_SFC_POST_DC
|
|
|
};
|
|
|
}
|
|
|
if (appConfig.processId.Contains("LY"))
|
|
|
{
|
|
|
LyUpLoad lyUpLoad = GetLyUpLoad(shaftInfo);
|
|
|
machineIntegrationParametricData[] data = {
|
|
|
new machineIntegrationParametricData() {name ="LY_FJFX",dataType=ParameterDataType.TEXT, value=string.IsNullOrEmpty(lyUpLoad.upDirection)?"0":lyUpLoad.upDirection},
|
|
|
new machineIntegrationParametricData() {name ="LY_SJFX",dataType=ParameterDataType.TEXT, value=string.IsNullOrEmpty(lyUpLoad.downDirection)?"0":lyUpLoad.downDirection},
|
|
|
new machineIntegrationParametricData() {name ="LY_SJZ",dataType=ParameterDataType.TEXT, value=string.IsNullOrEmpty(lyUpLoad.downPosition)?"0":lyUpLoad.downPosition},
|
|
|
new machineIntegrationParametricData() {name ="LY_HXMQ",dataType=ParameterDataType.TEXT, value=string.IsNullOrEmpty(lyUpLoad.crosswiseArea)?"0":lyUpLoad.crosswiseArea},
|
|
|
new machineIntegrationParametricData() {name ="LY_ZXMQ",dataType=ParameterDataType.TEXT, value=string.IsNullOrEmpty(lyUpLoad.erectArea)?"0":lyUpLoad.erectArea},
|
|
|
new machineIntegrationParametricData() {name ="LY_WLMX",dataType=ParameterDataType.TEXT, value=string.IsNullOrEmpty(lyUpLoad.materialFace)?"0":lyUpLoad.materialFace},
|
|
|
new machineIntegrationParametricData() {name ="LY_S_X01",dataType=ParameterDataType.TEXT, value=string.IsNullOrEmpty(lyUpLoad.sx01)?"0":lyUpLoad.sx01},
|
|
|
new machineIntegrationParametricData() {name ="LY_S_X02",dataType=ParameterDataType.TEXT, value=string.IsNullOrEmpty(lyUpLoad.sx02)?"0":lyUpLoad.sx02},
|
|
|
new machineIntegrationParametricData() {name ="LY_B_X01",dataType=ParameterDataType.TEXT, value=string.IsNullOrEmpty(lyUpLoad.bx01)?"0":lyUpLoad.bx01},
|
|
|
new machineIntegrationParametricData() {name ="LY_B_X02",dataType=ParameterDataType.TEXT, value=string.IsNullOrEmpty(lyUpLoad.bx02)?"0":lyUpLoad.bx02},
|
|
|
};
|
|
|
|
|
|
machineIntegrationServiceParam = new MachineIntegrationServiceParam()
|
|
|
{
|
|
|
url = "http://lymesa.catlbattery.com:8103/atlmeswebservice/MachineIntegrationServiceService?wsdl",
|
|
|
site = "2100",
|
|
|
//sfc = this.sfcStr.Text.ToString(), //将数据上传至拆分后的膜卷号
|
|
|
operation = lyUpLoad.operation,
|
|
|
operationRevision = "#",
|
|
|
activityId = "EAP_WS",
|
|
|
resource = lyUpLoad.resource,
|
|
|
dcGroup = lyUpLoad.dcGroup,
|
|
|
dcGroupRevision = "#",
|
|
|
parametricArray = data,
|
|
|
modeProcessSfc = MaterialTraceability.WebService.MachineIntegrationServiceService.ModeProcessSfc.MODE_COMPLETE_SFC_POST_DC
|
|
|
};
|
|
|
}
|
|
|
|
|
|
LogHelperBusiness.LogInfo("上传MES数据接口请求参数:" + JsonChange.ModeToJson(machineIntegrationServiceParam));
|
|
|
var dataCollectForSfcExResponse = MesWebServices.machineIntegration(machineIntegrationServiceParam);
|
|
|
var dataCollectForSfcExResponseResult = dataCollectForSfcExResponse.@return;
|
|
|
if(dataCollectForSfcExResponseResult.code > 0)
|
|
|
{
|
|
|
MessageBox.Show("数据上传完工失败:"+ upLoadBusiness.GetMesMessage(dataCollectForSfcExResponseResult.code, dataCollectForSfcExResponseResult.message));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
MessageBox.Show("数据上传完工成功");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取冷压膜卷号绑定的特征数据
|
|
|
/// </summary>
|
|
|
/// <param name="sfcStrParam"></param>
|
|
|
/// <returns></returns>
|
|
|
private LyUpLoad GetLyUpLoad(ProShaftInfo shaftInfo)
|
|
|
{
|
|
|
LyUpLoad lyUpLoad = new LyUpLoad();
|
|
|
SqlSugarClient _db = SqlGenerator.GetMySqlInstance();
|
|
|
if (StringExtension.IsNotBlank(shaftInfo.bindSfc))
|
|
|
{
|
|
|
DataTable info = _db.Queryable<LyUpLoad>().Where(x => x.sfcStr == shaftInfo.bindSfc && x.positionId == Convert.ToInt32(shaftInfo.positionId)).ToDataTable();
|
|
|
if (info.Rows.Count > 0)
|
|
|
{
|
|
|
DataRow dataRow = info.Rows[0];
|
|
|
lyUpLoad.id = Convert.ToInt32(dataRow["id"]);
|
|
|
lyUpLoad.sfcStr = dataRow["sfcStr"].ToString();
|
|
|
lyUpLoad.clientId = dataRow["clientId"].ToString();
|
|
|
lyUpLoad.resource = dataRow["resource"].ToString();
|
|
|
lyUpLoad.operation = dataRow["operation"].ToString();
|
|
|
lyUpLoad.dcGroup = dataRow["dcGroup"].ToString();
|
|
|
lyUpLoad.upDirection = dataRow["upDirection"].ToString();
|
|
|
lyUpLoad.downDirection = dataRow["downDirection"].ToString();
|
|
|
lyUpLoad.downPosition = dataRow["downPosition"].ToString();
|
|
|
lyUpLoad.crosswiseArea = dataRow["crosswiseArea"].ToString();
|
|
|
lyUpLoad.erectArea = dataRow["erectArea"].ToString();
|
|
|
lyUpLoad.materialFace = dataRow["materialFace"].ToString();
|
|
|
lyUpLoad.sx01 = dataRow["sx01"].ToString();
|
|
|
lyUpLoad.sx02 = dataRow["sx02"].ToString();
|
|
|
lyUpLoad.bx01 = dataRow["bx01"].ToString();
|
|
|
lyUpLoad.bx02 = dataRow["bx02"].ToString();
|
|
|
lyUpLoad.is_success = Convert.ToInt32(dataRow["is_success"]);
|
|
|
lyUpLoad.mesReturnInfo = dataRow["mesReturnInfo"].ToString();
|
|
|
lyUpLoad.recordTime = dataRow["recordTime"].ToString();
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
MessageBox.Show("请在绑定信息中输入放卷位膜卷号");
|
|
|
}
|
|
|
return lyUpLoad;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取模切膜卷号绑定的特征数据
|
|
|
/// </summary>
|
|
|
/// <param name="sfcStrParam"></param>
|
|
|
/// <returns></returns>
|
|
|
private MqUpLoad GetMqUpLoad(ProShaftInfo shaftInfo)
|
|
|
{
|
|
|
|
|
|
MqUpLoad mqUpLoad = new MqUpLoad();
|
|
|
SqlSugarClient _db = SqlGenerator.GetMySqlInstance();
|
|
|
if (StringExtension.IsNotBlank(shaftInfo.bindSfc)){
|
|
|
DataTable info = _db.Queryable<MqUpLoad>().Where(x => x.sfcStr == shaftInfo.bindSfc && x.positionId == Convert.ToInt32(shaftInfo.positionId)).ToDataTable();
|
|
|
if(info.Rows.Count > 0)
|
|
|
{
|
|
|
DataRow dataRow = info.Rows[0];
|
|
|
mqUpLoad.id = Convert.ToInt32(dataRow["id"]);
|
|
|
mqUpLoad.clientId = dataRow["clientId"].ToString();
|
|
|
mqUpLoad.resource = dataRow["resource"].ToString();
|
|
|
mqUpLoad.sfcStr = dataRow["sfcStr"].ToString();
|
|
|
mqUpLoad.operation = dataRow["operation"].ToString();
|
|
|
mqUpLoad.dcGroup = dataRow["dcGroup"].ToString();
|
|
|
mqUpLoad.upDirection = dataRow["upDirection"].ToString();
|
|
|
mqUpLoad.downDirection = dataRow["downDirection"].ToString();
|
|
|
|
|
|
mqUpLoad.downPosition = dataRow["downPosition"].ToString();
|
|
|
mqUpLoad.firstArticle = dataRow["firstArticle"].ToString();
|
|
|
mqUpLoad.mqMaterialFace = dataRow["mqMaterialFace"].ToString();
|
|
|
|
|
|
mqUpLoad.jrDirection = dataRow["jrDirection"].ToString();
|
|
|
mqUpLoad.scw = dataRow["scw"].ToString();
|
|
|
mqUpLoad.bcw = dataRow["bcw"].ToString();
|
|
|
|
|
|
mqUpLoad.is_success = Convert.ToInt32(dataRow["is_success"]);
|
|
|
mqUpLoad.mesReturnInfo = dataRow["mesReturnInfo"].ToString();
|
|
|
mqUpLoad.recordTime = dataRow["recordTime"].ToString();
|
|
|
}
|
|
|
}
|
|
|
LogHelperBusiness.LogInfo("手动上传重量特征数据:" + JsonChange.ModeToJson(mqUpLoad));
|
|
|
return mqUpLoad;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|