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.
193 lines
7.1 KiB
C#
193 lines
7.1 KiB
C#
using CentralControl.DBDAO;
|
|
using CommonFunc.Tools;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
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;
|
|
using XGL.Models.Model.OrderPrepare;
|
|
using XGL.Thrift;
|
|
|
|
namespace XGL.Views
|
|
{
|
|
/// <summary>
|
|
/// LanJu_Prepare.xaml 的交互逻辑
|
|
/// </summary>
|
|
public partial class LanJu_Prepare : UserControl
|
|
{
|
|
public LanJu_Prepare()
|
|
{
|
|
InitializeComponent();
|
|
|
|
}
|
|
|
|
List<WorkOrder> modelWareHouse = new List<WorkOrder>();
|
|
DBService userDbWareHouse = new DBService();
|
|
WorkOrder list_modelWareHouse = new WorkOrder();
|
|
|
|
List<WetMaterialModel> wetList = new List<WetMaterialModel>();
|
|
WetMaterialModel wet = new WetMaterialModel();
|
|
string messageOrderCode = "";
|
|
DataTable dt;
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 获取主页显示订单
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void GetWorkOrder()
|
|
{
|
|
try
|
|
{
|
|
//modelWareHouse = new List<WorkOrder>();
|
|
//userDbWareHouse = new DBService();
|
|
dt = userDbWareHouse.GetWetPlanInfo();
|
|
if (dt == null) return;
|
|
foreach (DataRow i in dt.Rows)
|
|
{
|
|
wet.id = i["id"].ToString();
|
|
wet.workorder_id = i["workorder_id"].ToString();
|
|
wet.product_name = i["product_name"].ToString();
|
|
|
|
wet.material_code = i["material_code"].ToString();
|
|
wet.plan_time = Convert.ToDateTime(i["plan_time"].ToString());
|
|
wet.bucket_code = i["bucket_code"].ToString();
|
|
wet.shift_desc = i["shift_desc"].ToString();
|
|
wet.prod_line_code = i["prod_line_code"].ToString();
|
|
wetList.Add(wet);
|
|
// list_modelWareHouse.WorkOrderCode = i["WorkOrderCode"].ToString();
|
|
// list_modelWareHouse.OrderCode = i["OrderCode"].ToString();
|
|
// list_modelWareHouse.ProductName = i["ProductName"].ToString();
|
|
// list_modelWareHouse.ProductSpc = i["ProductSpc"].ToString();
|
|
// list_modelWareHouse.QuantitySplit = i["QuantitySplit"].ToString();
|
|
// list_modelWareHouse.BatchCode = i["BatchCode"].ToString();
|
|
// modelWareHouse.Add(list_modelWareHouse);
|
|
}
|
|
this.WorkOrder.ItemsSource = modelWareHouse;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
private void Flow_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
var selectedRow = WorkOrder.SelectedItem as WorkOrder;
|
|
var workordercode = selectedRow.WorkOrderCode;
|
|
|
|
}
|
|
|
|
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
GetWorkOrder();
|
|
}
|
|
private void btnStartOrders_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
|
|
|
|
if (WorkOrder.SelectedItems.Count == 0)
|
|
{
|
|
CustomMessageBox.Show("请选择要开始的工单!", CustomMessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
string orderID = (WorkOrder.SelectedItem as WetMaterialModel).id;
|
|
string material = (WorkOrder.SelectedItem as WetMaterialModel).material_code;
|
|
//获取WMS齐套率
|
|
var wmsState = userDbWareHouse.GetWorkOrderQitaoLv(orderID);
|
|
if (wmsState == null || wmsState.Rows[0][0].Equals("0"))
|
|
{
|
|
CustomMessageBox.Show("该工单未准备好,请稍后再试!", CustomMessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
//获取湿料计划指定的成型机
|
|
var cxjDt = userDbWareHouse.GetCXJList(orderID);
|
|
if (cxjDt == null || cxjDt.Rows.Count == 0)
|
|
{
|
|
CustomMessageBox.Show("该工单未指定成型机,请稍后再试!", CustomMessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
|
|
List<string> cxjList = new List<string>();
|
|
List<string> bucketList = new List<string>();
|
|
//这扯淡的设计,根据湿料计划获取各个工单对应的工序、机台信息,
|
|
for (int i = 0; i < cxjDt.Rows.Count; i++)
|
|
{
|
|
string jsonStrCXJList = cxjDt.Rows[i][0].ToString();
|
|
string bucketNo = cxjDt.Rows[i][1].ToString();
|
|
bucketList.Add(bucketNo);
|
|
// 解析JSON字符串为嵌套的列表结构
|
|
List<List<string>> data = JsonConvert.DeserializeObject<List<List<string>>>(jsonStrCXJList);
|
|
|
|
|
|
// 输出嵌套列表的值
|
|
foreach (var innerList in data)
|
|
{
|
|
if (innerList[0].Equals("GX01"))
|
|
{
|
|
if (innerList[1].Contains("C"))
|
|
{
|
|
//记录成型机列表
|
|
cxjList.Add(innerList[1]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
cxjList = cxjList.Distinct().ToList();//去重
|
|
|
|
//var jsonObject = JsonConvert.DeserializeObject(jsonStrCXJList);
|
|
|
|
string apiUrl = "http://example.com/api/endpoint";
|
|
|
|
|
|
MaterialPlanModel materialPlanModel = new MaterialPlanModel();
|
|
skuInfo sku = new skuInfo();
|
|
List<WetMaterialModel> listWetMaterial = Utils.ToDataList<WetMaterialModel>(dt);
|
|
List<unloadNoInfo> unloadNoInfoList = new List<unloadNoInfo>();
|
|
List<skuInfo> skuInfoList = new List<skuInfo>();
|
|
|
|
materialPlanModel.reqCode = CommonFunc.Common.GetUUID();
|
|
materialPlanModel.reqTime = DateTime.Now.ToString();
|
|
materialPlanModel.planNo = orderID;
|
|
|
|
|
|
foreach (var item in cxjList)
|
|
{
|
|
sku.sku = material;
|
|
sku.loadNo = item;
|
|
unloadNoInfo unloadNoInfo = new unloadNoInfo();
|
|
|
|
foreach (var buckt in bucketList)
|
|
{
|
|
unloadNoInfo.unloadNo = buckt;
|
|
unloadNoInfoList.Add(unloadNoInfo);
|
|
}
|
|
sku.unLoadItems = unloadNoInfoList;
|
|
skuInfoList.Add(sku);
|
|
}
|
|
|
|
materialPlanModel.data = skuInfoList;
|
|
|
|
// 将要发送的数据序列化为JSON格式
|
|
var jsonContent = JsonConvert.SerializeObject(materialPlanModel);
|
|
|
|
RestHelper restClient = new RestHelper();
|
|
var response = restClient.PostAsync(apiUrl, jsonContent);
|
|
|
|
Console.WriteLine(response);
|
|
}
|
|
}
|
|
}
|