using Admin.NET.Core.EnterWareHouseModule;
|
using iWareCommon.Utils;
|
using iWareModel;
|
using iWareSql.MyDbContext;
|
using iWareTestForm;
|
using iWareTestForm.Model;
|
using Newtonsoft.Json;
|
using NPOI.SS.Formula.PTG;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Windows.Forms;
|
|
namespace XiGang_iWareTestForm.iWareTest.DialogForm
|
{
|
public partial class TestBatchForm : Form
|
{
|
delegate void Delegate_SetPostResult2(string content);
|
public TestBatchForm()
|
{
|
InitializeComponent();
|
}
|
|
private void LoadItemType()
|
{
|
List<ListItem> itemList = new List<ListItem>();
|
itemList.Add(new ListItem()
|
{
|
Text = "发送机",
|
Value = "1"
|
});
|
itemList.Add(new ListItem()
|
{
|
Text = "托盘",
|
Value = "2"
|
});
|
foreach (var item in itemList)
|
{
|
this.cmbItemType.Items.Add(item);
|
}
|
|
cmbItemType.SelectedIndex = 1;
|
}
|
|
/// <summary>
|
/// 显示请求结果
|
/// </summary>
|
/// <param name="content"></param>
|
private void ShowResult(string content)
|
{
|
|
if (this.tb_Log.InvokeRequired)
|
{
|
Delegate_SetPostResult2 delegate_SetPostResult = new Delegate_SetPostResult2(ShowResult);
|
this.Invoke(delegate_SetPostResult, new object[] { content });
|
}
|
else
|
{
|
//content += "\r\n";
|
this.tb_Log.Text = StringHelper.GetLog(content) + this.tb_Log.Text;
|
}
|
}
|
|
private void button2_Click(object sender, EventArgs e)
|
{
|
//ClearPlace();
|
}
|
|
|
|
private void TestBatchForm_Load(object sender, EventArgs e)
|
{
|
LoadItemType();
|
this.tb_SalverCount.Text = "1";
|
}
|
|
private void button3_Click(object sender, EventArgs e)
|
{
|
//测试打印
|
ShowResult($"开始打印");
|
Dictionary<string, object> data = new Dictionary<string, object>();
|
data.Add("bar", "heihei");
|
data.Add("material", "heihei");
|
data.Add("supplier", "heihei");
|
data.Add("unit", "heihei");
|
data.Add("date", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
//调用打印接口
|
bool isSuccess = false;
|
string errMsg = "";
|
using (iWareTestForm.PrintBaseService.PrintWcfServiceClient client = new iWareTestForm.PrintBaseService.PrintWcfServiceClient())
|
{
|
isSuccess = client.Print3(data, 1, @"D:\打印程序\跟踪码打印模板\跟踪码打印模板_一维码.btw", "ZDesigner ZD888-203dpi ZPL", out errMsg);
|
}
|
if (isSuccess)
|
{
|
ShowResult($"打印成功");
|
}
|
else
|
{
|
ShowResult($"打印失败:" + errMsg);
|
}
|
|
|
}
|
|
/// <summary>
|
/// 生成批次号
|
/// </summary>
|
/// <param name="prefix"></param>
|
/// <returns></returns>
|
public string CreateBatchNo(string prefix)
|
{
|
string BarNo = "WH" + Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")).Ticks.ToString();
|
return BarNo;
|
}
|
|
|
private List<string> GetString()
|
{
|
List<String> list = new List<string>();
|
list.Add("2-01-10-02".Trim());
|
list.Add("1-01-04-01".Trim());
|
|
list.Add("1-01-06-04".Trim());
|
|
return list;
|
}
|
|
private void button1_Click(object sender, EventArgs e)
|
{
|
////零件归还管理增加
|
//List<ware_sorting_details> ware_Sorting_Details = new List<ware_sorting_details>();
|
|
////借用单库存增加
|
//using (MyDbContext dbContext = new MyDbContext())
|
//{
|
|
// //获取所有 借用单的明细
|
// var orders = dbContext.ware_orders.Where(x => x.OrderType == "11" && x.OrderNo == "借用" && (x.IsDeleted == null || x.IsDeleted == false)).ToList();
|
// var ids = orders.Select(y => y.Id).ToList();
|
// var details = dbContext.ware_orders_details.Where(x => ids.Contains(x.OrdersId) && (x.IsDeleted == null || x.IsDeleted == false)).ToList();
|
|
|
|
|
// // 创建分拣订单
|
|
// var sortingOrder = new ware_sorting
|
// {
|
// Id = Yitter.IdGenerator.YitIdHelper.NextId(),
|
// OrderNo = Yitter.IdGenerator.YitIdHelper.NextId().ToString(),
|
// OrderType = "1",//借用取货单
|
// Remarks = "分拣单创建",
|
// OrderStatus = (int)EnumWarehousStatus.Completed,
|
// IsDeleted = false,
|
// Status = 0
|
// };
|
|
// List<string> str = new List<string>();
|
// List<long> str1 = new List<long>();
|
// foreach (var item in details)
|
// {
|
// ware_Sorting_Details.Add(new ware_sorting_details
|
// {
|
// Status = 0,
|
// Id = Yitter.IdGenerator.YitIdHelper.NextId(),
|
// OrdersId = sortingOrder.Id,
|
// WareContainerCode = "",
|
// WareContainerName = "",
|
// WareMaterialCode = item.WareMaterialCode,
|
// WareMaterialName = "",
|
// Unit = "",
|
// CompleteQuantity = item.Quantity,
|
// Quantity = item.Quantity,
|
// OrderStatus = (int)EnumWarehousStatus.Completed,
|
// DeliveryNo = "借用",
|
// IsDeleted = false
|
// });
|
// }
|
|
// dbContext.ware_sorting.Add(sortingOrder);
|
// dbContext.ware_sorting_details.AddRange(ware_Sorting_Details);
|
|
// dbContext.SaveChanges();
|
|
//}
|
|
//ShowResult($"新增{ware_Sorting_Details.Count}条");
|
}
|
|
private void btn_SelectFile_Click(object sender, EventArgs e)
|
{
|
OpenFileDialog fileDialog = new OpenFileDialog();
|
fileDialog.Multiselect = true;
|
fileDialog.Title = "请选择文件";
|
fileDialog.Filter = "所有文件(*xls*)|*.xls*"; //设置要选择的文件的类型
|
if (fileDialog.ShowDialog() == DialogResult.OK)
|
{
|
string file = fileDialog.FileName;//返回文件的完整路径
|
this.tb_FilePath.Text = file;
|
}
|
}
|
|
private void button2_Click_1(object sender, EventArgs e)
|
{
|
// 批量导入 客户寄售区库存
|
// var name = this.tb_KeHuJiShouKuWei.Text;
|
// if (string.IsNullOrEmpty(name))
|
// {
|
// MessageBox.Show("请输入客户寄售区名称!");
|
// return;
|
// }
|
// string filePath = this.tb_FilePath.Text;
|
// if (filePath == string.Empty)
|
// {
|
// MessageBox.Show("请选择Excel!");
|
// return;
|
// }
|
|
// Dictionary<string, string> cellheader = new Dictionary<string, string> {
|
// { "MaterialNo", "零件号" },
|
// { "MaterialName", "名称" },
|
// { "Quntity", "数量" }
|
// };
|
|
// 1.2解析文件,存放到一个List集合里
|
//StringBuilder errorMsg = new StringBuilder(); // 错误信息
|
// string tableDesc = "", tableName = "";
|
// List<MyMaterial> enlist = ExcelHelper.ExcelToEntityListForCreateTable<MyMaterial>(cellheader, filePath, out tableDesc, out tableName, out errorMsg);
|
// if (!string.IsNullOrEmpty(errorMsg.ToString()))
|
// {
|
// MessageBox.Show("错误:" + errorMsg.ToString());
|
// return;
|
// }
|
|
// 汇总数据
|
// List<MyMaterial> inertList = new List<MyMaterial>();
|
// foreach (var item in enlist)
|
// {
|
// if (!string.IsNullOrEmpty(item.MaterialNo))
|
// {
|
// var zz = inertList.Where(x => x.MaterialNo == item.MaterialNo).FirstOrDefault();
|
// if (zz == null)
|
// {
|
// inertList.Add(new MyMaterial()
|
// {
|
// MaterialNo = item.MaterialNo,
|
// MaterialName = item.MaterialName,
|
// Quntity = item.Quntity
|
// });
|
// }
|
// else
|
// {
|
// zz.Quntity += item.Quntity;
|
// }
|
// }
|
// }
|
|
|
// List<ware_container_vs_material> addList = new List<ware_container_vs_material>();
|
// ware_container_vs_material aa = null;
|
// using (MyDbContext dbContext = new MyDbContext())
|
// {
|
// var ddd = dbContext.ware_location_vs_container.Where(x => x.WareContainerCode == name).FirstOrDefault();
|
|
// if (ddd == null)
|
// {
|
// 默认自己写入
|
// ddd = new ware_location_vs_container()
|
// {
|
// Id = Yitter.IdGenerator.YitIdHelper.NextId(),
|
// WareContainerCode = name,
|
// WareContainerName = name,
|
// WareLocationCode = name,
|
// IsEmptyContainer = false,
|
// IsDeleted = false
|
// };
|
// dbContext.ware_location_vs_container.Add(ddd);
|
// }
|
|
// var barno = CreateBatchNo("");
|
// foreach (var item in inertList)
|
// {
|
// aa = new ware_container_vs_material
|
// {
|
// Id = Yitter.IdGenerator.YitIdHelper.NextId(),
|
// locationVsContainerid = ddd.Id,
|
// WareContainerCode = name,
|
// WareMaterialCode = item.MaterialNo,
|
// Quantity = item.Quntity,
|
// PurchaseNo = "",
|
// DeliveryNo = "",
|
// CollectNo = "",
|
// OCCQuantity = 0,
|
// ITEMBATCHNO = "",
|
// OrdersNo = "",//入库单号
|
// Status = 0,
|
// TenantId = null,
|
// CreatedTime = DateTime.Now,
|
// CreatedUserId = CurrentUserInfo.UserId,
|
// CreatedUserName = CurrentUserInfo.Name,
|
// IsLocked = false,
|
// LockRemark = "平库入库,新增物料,初始为false",
|
// DoLockTime = DateTime.Now,
|
|
// IsDeleted = false,
|
// Remarks = "自动插入",
|
// StockStatus = 2,
|
// BarNo = barno,
|
// MaterialType = item.ma,
|
// LocationType = 2,
|
|
// MaterialRegionId = wareRegion.Id,
|
// MaterialRegionCode = wareRegion.Code,
|
// MaterialRegionName = wareRegion.Name
|
// ,
|
// CustomerCode = CustomerCode
|
// ,
|
// MachineToolName = MachineToolName
|
// ,
|
// MachineToolId = MachineToolId,
|
|
// RealWareContainerCode = realWareContainerCode //记录真实的托盘号,用于展示组盘区域中的真实托盘号 [Editby shaocx,2023-01-31]
|
// };
|
// addList.Add(aa);
|
// }
|
|
// dbContext.ware_container_vs_material.AddRange(addList);
|
|
|
// dbContext.SaveChanges();
|
|
// }
|
// ShowResult($"新增{addList.Count}条");
|
}
|
|
private void button4_Click(object sender, EventArgs e)
|
{
|
////采购单明细中没有行号的赋值为有值
|
|
////零件归还管理增加
|
//List<ware_purchase_order_details> orders = new List<ware_purchase_order_details>();
|
|
////借用单库存增加
|
//using (MyDbContext dbContext = new MyDbContext())
|
//{
|
|
// //获取所有 借用单的明细
|
// orders = dbContext.ware_purchase_order_details.Where(x => (x.EBELP == null || x.EBELP == "")).ToList();
|
|
// foreach (var item in orders)
|
// {
|
// item.EBELP = Yitter.IdGenerator.YitIdHelper.NextId().ToString();
|
// }
|
|
// dbContext.SaveChanges();
|
//}
|
|
//ShowResult($"新增{orders.Count}条");
|
}
|
|
private void button5_Click(object sender, EventArgs e)
|
{
|
|
//List<FunRetEntity> errList = new List<FunRetEntity>();
|
//int addCount = 0, updateCount = 0;
|
|
////批量更新容器的栅格数(生产库用)
|
//string filePath = this.tb_FilePath.Text;
|
//if (filePath == string.Empty)
|
//{
|
// MessageBox.Show("请选择Excel!");
|
// return;
|
//}
|
|
//Dictionary<string, string> cellheader = new Dictionary<string, string> {
|
// { "LocationCode", "库位号" },
|
// { "GridNumber", "栅格数" }
|
// };
|
|
//// 1.2解析文件,存放到一个List集合里
|
//StringBuilder errorMsg = new StringBuilder(); // 错误信息
|
//string tableDesc = "", tableName = "";
|
//List<MyLocation> myLocationList = ExcelHelper.ExcelToEntityListForCreateTable<MyLocation>(cellheader, filePath, out tableDesc, out tableName, out errorMsg);
|
//if (!string.IsNullOrEmpty(errorMsg.ToString()))
|
//{
|
// MessageBox.Show("错误:" + errorMsg.ToString());
|
// return;
|
//}
|
|
|
//List<ware_container_vs_material> addList = new List<ware_container_vs_material>();
|
//ware_container_vs_material aa = null;
|
//using (MyDbContext dbContext = new MyDbContext())
|
//{
|
// foreach (var item in myLocationList)
|
// {
|
|
// SimulatorCommonHelper.GetGridNumber(item);
|
|
// var los = dbContext.ware_location.Where(x => x.Code == item.LocationCode && (x.IsDeleted == null || x.IsDeleted == false)).ToList();
|
// if (los == null || los.Count == 0)
|
// {
|
// errList.Add(new FunRetEntity()
|
// {
|
// resData = item.LocationCode,
|
// resMsg = $"{item.LocationCode}库位没有找到"
|
// }); ; ;
|
// }
|
// else if (los.Count > 1)
|
// {
|
// //数据不正确
|
// errList.Add(new FunRetEntity()
|
// {
|
// resData = item.LocationCode,
|
// resMsg = $"{item.LocationCode}库位数超过了1条"
|
// }); ; ;
|
// }
|
|
// var ddds = dbContext.ware_container.Where(x => x.Code == item.LocationCode && (x.IsDeleted == null || x.IsDeleted == false)).ToList();
|
// if (ddds == null || ddds.Count == 0)
|
// {
|
// //新增
|
// var add_container = new ware_container()
|
// {
|
// IsDeleted = false,
|
// IsVirtual = 1,
|
// Id = Yitter.IdGenerator.YitIdHelper.NextId(),
|
// Code = item.LocationCode,
|
// Name = item.LocationCode,
|
// CreatedTime = DateTime.Now,
|
// UpdatedTime = DateTime.Now,
|
// CreatedUserName = "系统初始",
|
// UpdatedUserName = "系统初始",
|
// Status = 0,
|
// GridNumber = Convert.ToInt32(item.GridNumber)
|
// };
|
// //计算已占用栅格数
|
// add_container.UseNumber = ContainerHandler.ReCalcUseNumber(dbContext, item.LocationCode);
|
|
// dbContext.ware_container.Add(add_container);
|
// addCount++;
|
|
// }
|
// else if (ddds.Count > 1)
|
// {
|
// //数据不正确
|
// errList.Add(new FunRetEntity()
|
// {
|
// resData = item.LocationCode,
|
// resMsg = $"{item.LocationCode}容器数超过了1条"
|
// }); ; ;
|
// }
|
// else
|
// {//已存在
|
// var db_container = ddds.FirstOrDefault();
|
// db_container.GridNumber = Convert.ToInt32(item.GridNumber);
|
// //计算已占用栅格数
|
// db_container.UseNumber = ContainerHandler.ReCalcUseNumber(dbContext, item.LocationCode);
|
// updateCount++;
|
// }
|
// }
|
|
|
// dbContext.SaveChanges();
|
|
//}
|
//ShowResult($"新增{addCount}条");
|
//ShowResult($"更新{updateCount}条");
|
//ShowResult($"错误{errList.Count}条," + JsonConvert.SerializeObject(errList));
|
}
|
|
private void button6_Click(object sender, EventArgs e)
|
{
|
this.tb_Yitter.Text = Yitter.IdGenerator.YitIdHelper.NextId().ToString();
|
ShowResult(this.tb_Yitter.Text);
|
}
|
}
|
}
|