1.出库单据、生成出库单据、计算物料时增加货架类型用于区分信息化货架和智能货架的物料 实现分开出

This commit is contained in:
hehaibing-1996
2024-05-21 10:32:52 +08:00
parent 649e22b4ce
commit b2f9c7cc22
48 changed files with 976 additions and 125 deletions

View File

@ -27,6 +27,12 @@ namespace WCS.DAL.DbModels
[SugarColumn(ColumnName = "module_code", Length = 50, IsNullable = false, ColumnDescription = "模组编码")]
public string ModuleCode { get; set; }
/// <summary>
/// 货架类型Id
/// </summary>
[SugarColumn(ColumnName = "shelf_type_id", IsNullable = false,DefaultValue ="0", ColumnDescription = "货架类型Id")]
public int ShelfTypeId { get; set; }
/// <summary>
/// 货架Id
/// </summary>

View File

@ -49,15 +49,19 @@ namespace WCS.BLL.DbModels
/// <summary>
/// 单据同步类型
/// </summary>
[SugarColumn(ColumnName = "sync_type",IsNullable = false, ColumnDescription = "单据同步类型ByMatCode,ByMatSn")]
[SugarColumn(ColumnName = "sync_type", IsNullable = false, ColumnDescription = "单据同步类型ByMatCode,ByMatSn")]
public SyncTypeEnum SyncType { get; set; }
/// <summary>
/// 单据货架类型 单灯单据还是货架单据
/// </summary>
[SugarColumn(ColumnName = "shelf_type", IsNullable = false, ColumnDescription = "货架类型 是信息化货架还是智能货架")]
public ShelfTypeEnum ShelfType { get; set; }
/// 货架类型名称
/// </summary>
[SugarColumn(ColumnName = "shelf_type_name", Length = 50, IsNullable = false, ColumnDescription = "货架类型名称")]
public string ShelfTypeName { get; set; }
/// <summary>
/// 货架类型Id
/// </summary>
[SugarColumn(ColumnName = "shelf_type_id", IsNullable = false, DefaultValue = "0", ColumnDescription = "货架类型Id")]
public int ShelfTypeId { get; set; } = 0;
/// <summary>
/// 创建时间

View File

@ -21,12 +21,16 @@ namespace WCS.DAL.DbModels
/// </summary>
[SugarColumn(ColumnName = "store_code", Length = 50, IsNullable = false, ColumnDescription = "库位编码")]
public string StoreCode { get; set; }
/// <summary>
/// 货架类型Id
/// </summary>
[SugarColumn(ColumnName = "shelf_type_id", IsNullable = false, DefaultValue = "0", ColumnDescription = "货架类型Id")]
public int ShelfTypeId { get; set; }
/// <summary>
/// 模组Id
/// </summary>
[SugarColumn(ColumnName = "module_id", IsNullable = false, ColumnDescription = "模组Id")]
public int ModuleId { get; set; }
public int ModuleId { get; set; }
/// <summary>
/// 模组编号

View File

@ -43,6 +43,7 @@ namespace WCS.BLL.Manager
}
var data = e.ByteBlock.Buffer.Take((int)e.ByteBlock.Length).ToArray();
Logs.Write($"【接收】{BitConverter.ToString(data)}",LogsType.Instructions);
e.ByteBlock.Clear();
var len = data.Length;
for (int index = 0; index < data.Length - TcpCleint.PreFixLength; index++)
@ -52,18 +53,16 @@ namespace WCS.BLL.Manager
var isEqual = prefixInData.SequenceEqual(TcpCleint.Prefix);
if (isEqual)
{
Logs.Write("协议处理1");
var dataTemp = data.Skip(index).Take(TcpCleint.PreFixLength + TcpCleint.DataLength).ToArray();
if (dataTemp.Length < TcpCleint.PreFixLength + TcpCleint.DataLength)//拆包后不满足一条指令的长度
{
continue;
}
Logs.Write($"【处理单条指令 开始】{BitConverter.ToString(dataTemp)}", LogsType.Instructions);
index += (TcpCleint.PreFixLength + TcpCleint.DataLength - 1);//每次循环index会+1 所以这里-1
//获取板子ID
var boardId = (dataTemp[TcpCleint.PreFixLength + 0] << 8) + dataTemp[TcpCleint.PreFixLength + 1];
var lightNumber = Convert.ToInt32(dataTemp[TcpCleint.PreFixLength + 3]);
Logs.Write("协议处理2");
//报警灯
if (dataTemp[TcpCleint.PreFixLength + 2] == 0x20)
{
@ -76,18 +75,16 @@ namespace WCS.BLL.Manager
//!= 0x20 货架类型协议返回
else
{
Logs.Write("协议处理3");
var shelf = ShelfManager.Shelves
.Where(t => t.ClientIp == clientIpHost)
.Where(t => t.ModuleIds.Contains(boardId))
.FirstOrDefault();
var smartShelf = shelf as SmartShelf;
smartShelf?.ProtocolProcess(dataTemp, boardId, lightNumber);
}
Logs.Write($"【处理单条指令 结束】{BitConverter.ToString(dataTemp)}", LogsType.Instructions);
}
}
Logs.Write("协议处理完毕!");
return EasyTask.CompletedTask;
};
//配置首次连接后复位操作

View File

@ -16,6 +16,7 @@ namespace WCS.BLL.Manager
public static object flag = new object();
public static void InitWebSocket()
{
Console.WriteLine("【启动WebSocket】开始");
Logs.Write("【启动WebSocket】开始", LogsType.StartBoot);
service = new HttpService();
service.Setup(new TouchSocketConfig()//加载配置
@ -33,6 +34,7 @@ namespace WCS.BLL.Manager
}));
service.Start();
Console.WriteLine("【启动WebSocket】结束");
Logs.Write("【启动WebSocket】结束", LogsType.StartBoot);
}

View File

@ -4,12 +4,14 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WCS.Model;
using WCS.Model.ApiModel.MatInventoryDetail;
using WCS.Model.ApiModel.OutStore;
namespace WCS.BLL.Services.IService
{
public interface IOutstoreService
{
public Task<ResponseCommon<List<MatInventorySummaryModel>>> importMat(List<OutImportMatModel> list);
public Task<ResponseBase> SysOutOrderByMatCode(SysOutOrderByMatCodeRequest request);
public Task<ResponseBase> SysOutOrderByMatSn(SysOutOrderByMatSnRequest request);
@ -22,7 +24,7 @@ namespace WCS.BLL.Services.IService
public Task<ResponseBase> GetOutOrderMatDetail(GetOutOrderDetailRequest request);
public Task<ResponseBase> GoInOutstore(GetOutOrderDetailRequest request);
public Task<ResponseBase> GoInOutstore(GetOutOrderDetailRequest request);
public Task<ResponseBase> GoOutOutstore(GetOutOrderDetailRequest request);

View File

@ -130,7 +130,7 @@ namespace WCS.BLL.Services.Service
}
IShelfBase shelf = null;
if (!request.IsSingleLightIn)
if (!request.SingleLightIn)
{
//获取货架
shelf = ShelfManager.Shelves.Where(t => t.ShelfCode == request.ShelfCode).FirstOrDefault();
@ -164,13 +164,13 @@ namespace WCS.BLL.Services.Service
{
materialBar = request.MatSn
};
var Result = ApiHelp.GetDataFromHttp<ResponseCommon<List<queryByBarResponse>>>("http://192.168.2.23:9213/integrate/instock/queryBybar", body, "POST");
var Result = ApiHelp.GetDataFromHttp<ResponseCommon<List<queryByBarResponse>>>("http://192.168.2.23:9213/integrate/instock/queryBybar", body, "POST", true);
//查询到物料信息
if (Result != null && Result.Code == 200 && Result.Data != null && Result.Data.Count > 0)
{
var data = Result.Data.First();
if (!request.IsSingleLightIn && shelf != null)
if (!request.SingleLightIn && shelf != null)
shelf.InStoreData = new MatInfoResponse()
{
materialBar = data.materialBar,
@ -239,7 +239,7 @@ namespace WCS.BLL.Services.Service
if (matInfo != null)
{
//TODO 改成wcs的实体
if (!request.IsSingleLightIn && shelf != null)
if (!request.SingleLightIn && shelf != null)
shelf.InStoreData = new MatInfoResponse()
{
materialBar = matInfo.MatSn,
@ -468,7 +468,7 @@ namespace WCS.BLL.Services.Service
data1[5] = 0x03;
data1[6] = 0x02;
data1[7] = 0x02;
byte[] senddata1 = Tool.Helper.Crc16(data1,data1.Length,false);
byte[] senddata1 = Tool.Helper.Crc16(data1, data1.Length, false);
tCPClient.Send(senddata1); //报警灯短亮一次
byte[] data2 = new byte[8];
@ -489,7 +489,7 @@ namespace WCS.BLL.Services.Service
Message = $"入库成功!",
Data = rcs.Data,
};
}
}
}

View File

@ -128,16 +128,16 @@ namespace WCS.BLL.Services.Service
var inventortyDetails = await DbHelp.db.Queryable<InventoryDetail>()
.WhereIF(!string.IsNullOrEmpty(request.MatName), t => t.MatName.Contains(request.MatName))
.WhereIF(!string.IsNullOrEmpty(request.MatCode), t => t.MatCode.Contains(request.MatCode))
.WhereIF(!string.IsNullOrEmpty(request.MatBatch), t => t.MatBatch.Contains(request.MatBatch))
.Where(t => t.StoreInfo.ShelfTypeId == request.ShelfTypeId)
.GroupBy(t => t.MatCode)
.GroupBy(t => t.MatBatch)
.Select(t => new MatInventorySummaryModel
{
MatCode = t.MatCode,
MatName = t.MatName,
MatBatch = t.MatBatch,
MatSpec = t.MatSpec,
MatCustomer = t.MatCustomer,
MatSupplier = t.MatSupplier,
MatBatch = t.MatBatch,
TotalQty = SqlFunc.AggregateSum(t.MatQty)
})
.ToListAsync();

View File

@ -1,19 +1,12 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using TouchSocket.Sockets;
using WCS.BLL.Config;
using WCS.BLL.DbModels;
using WCS.BLL.Manager;
using WCS.BLL.Services.IService;
using WCS.DAL.Db;
using WCS.DAL.DbModels;
using WCS.Model;
using WCS.Model.ApiModel.InOutRecord;
using WCS.Model.ApiModel.MatInventoryDetail;
using WCS.Model.ApiModel.OutStore;
namespace WCS.BLL.Services.Service
@ -23,6 +16,53 @@ namespace WCS.BLL.Services.Service
public OutstoreService()
{
}
public async Task<ResponseCommon<List<MatInventorySummaryModel>>> importMat(List<OutImportMatModel> list)
{
//数据校验
if (list == null || list.Count == 0)
{
return new ResponseCommon<List<MatInventorySummaryModel>>()
{
Code = 201,
Message = "导入失败:导入文件中没有内容!"
};
}
//需求数量
var errorCount = list.Where(t => t. <= 0).ToList();
if (errorCount != null && errorCount.Count > 0)
{
return new ResponseCommon<List<MatInventorySummaryModel>>()
{
Code = 201,
Message = "导入失败需求数量需要大于0"
};
}
//每一个物料进行搜索库存
var returnList = new List<MatInventorySummaryModel>();
foreach (var item in list)
{
var inventoryCount = await DbHelp.db.Queryable<InventoryDetail>()
.Where(t => t.MatCode == item.)
.Where(t => t.MatBatch == item.)
.Where(t => t.IsLocked == false)
.SumAsync(t => t.MatQty);
var info = inventoryCount < item. ? "库存数量小于需求数量" : string.Empty;
returnList.Add(new MatInventorySummaryModel()
{
MatCode = item.,
MatName = item.,
MatBatch = item.,
NeedQty = item.,
TotalQty = inventoryCount,
Info = info
});
}
return new ResponseCommon<List<MatInventorySummaryModel>>()
{
Code = 200,
Data = returnList
};
}
public async Task<ResponseBase> SysOutOrderByMatCode(SysOutOrderByMatCodeRequest request)
{
@ -35,6 +75,24 @@ namespace WCS.BLL.Services.Service
Message = "出库单据同步失败:缺少需要出库的物料类型!"
};
}
//补齐货架类型名称
if (string.IsNullOrEmpty(request.ShelfTypeName))
{
var shelfType = await DbHelp.db.Queryable<ShelfTypeInfo>()
.Where(t => t.Id == request.ShelfTypeId)
.FirstAsync();
if (shelfType == null)
{
return new ResponseBase()
{
Code = 201,
Message = $"出库单据同步失败缺少必要参数ShelfTypeId"
};
}
else
request.ShelfTypeName = shelfType.ShelfTypeName;
}
//保存数据
await DbHelp.db.BeginTranAsync();
try
@ -44,6 +102,8 @@ namespace WCS.BLL.Services.Service
OrderNumber = request.OrderNumber,
OrderSource = request.OrderSource,
OrderType = request.OrderType,
ShelfTypeId = request.ShelfTypeId,
ShelfTypeName = request.ShelfTypeName,
SyncType = SyncTypeEnum.ByMatCode,
CreateUser = request.UserName,
};
@ -645,7 +705,8 @@ namespace WCS.BLL.Services.Service
.Where(t => t.MatCode == outOrderDetail.MatCode)
.WhereIF(!string.IsNullOrEmpty(outOrderDetail.MatBatch), t => t.MatBatch == outOrderDetail.MatBatch)
.Where(t => t.IsLocked == false)//未锁定的物料
.OrderBy(t => t.MatBatch)//先进先出
.Where(t => t.StoreInfo.ShelfTypeId == order.ShelfTypeId)
.OrderBy(t => t.MatBatch)//按批次先进先出
//(t => t.MatQty)//零散料先出
.ToList();
@ -873,7 +934,7 @@ namespace WCS.BLL.Services.Service
}
DbHelp.db.Updateable<OrderLight>().SetColumns(it => it.OrderNumber == null).Where(it => it.OrderNumber == request.OrderNumber).ExecuteCommand();
//灭灯
return new ResponseCommon()
{
Code = 200,
@ -911,11 +972,11 @@ namespace WCS.BLL.Services.Service
ior.OperateUser = request.userName;
ior.OperateTime = DateTime.Now;
//保存出库记录
int count= DbHelp.db.Insertable(ior).ExecuteCommand();
int count = DbHelp.db.Insertable(ior).ExecuteCommand();
//删除库存
DbHelp.db.Deleteable<InventoryDetail>().Where(it => it.MatSN == request.MatSn).ExecuteCommand();
//更新需求表
List<OutOrderDetail> odd = DbHelp.db.Queryable<OutOrderDetail>().Where(it => it.OrderNumber == request.orderNumber).Where(it=>it.MatCode==request.MatCode).ToList();
List<OutOrderDetail> odd = DbHelp.db.Queryable<OutOrderDetail>().Where(it => it.OrderNumber == request.orderNumber).Where(it => it.MatCode == request.MatCode).ToList();
odd[0].OutQty += request.Qty;
DbHelp.db.Updateable(odd[0]).ExecuteCommand();
@ -926,5 +987,7 @@ namespace WCS.BLL.Services.Service
Data = null
};
}
}
}

View File

@ -25,8 +25,18 @@ namespace WCS.BLL
/// 启动信息
/// </summary>
StartBoot,
Api
/// <summary>
/// 调用外部Api的接口
/// </summary>
Api,
/// <summary>
/// 指令发送接收
/// </summary>
Instructions,
/// <summary>
/// 指令重发
/// </summary>
InstructionResend
}
/// <summary>

View File

@ -79,36 +79,38 @@ namespace WCS.BLL
tcpClient.Received += (client, e) =>
{
var data = e.ByteBlock.Buffer.Take((int)e.ByteBlock.Length).ToArray();
Logs.Write($"校验发送接收,收到数据" + BitConverter.ToString(data));
var len = data.Length;
for (int index = 0; index < data.Length - PreFixLength; index++)
Task.Run(() =>
{
//协议拆包 通过前缀校验是否为完整数据包
var prefixInData = data.Skip(index).Take(PreFixLength);
var isEqual = prefixInData.SequenceEqual(Prefix);
if (isEqual)
Logs.Write($"【校验发送接收 开始】" + BitConverter.ToString(data), LogsType.InstructionResend);
var len = data.Length;
for (int index = 0; index < data.Length - PreFixLength; index++)
{
var dataTemp = data.Skip(index).Take(PreFixLength + DataLength).ToArray();
if (dataTemp.Length < PreFixLength + DataLength)//拆包后不满足一条指令的长度
//协议拆包 通过前缀校验是否为完整数据包
var prefixInData = data.Skip(index).Take(PreFixLength);
var isEqual = prefixInData.SequenceEqual(Prefix);
if (isEqual)
{
continue;
var dataTemp = data.Skip(index).Take(PreFixLength + DataLength).ToArray();
if (dataTemp.Length < PreFixLength + DataLength)//拆包后不满足一条指令的长度
{
continue;
}
//获取返回指令的板子ID
var boardId = (dataTemp[PreFixLength + 0] << 8) + dataTemp[PreFixLength + 1];
//查询当前板子是否有待验证的指令
var message = new MessageDto();
MessageList.TryGetValue(boardId, out message);
//功能位校验 功能位相同视为已响应指令 删除对应的指令
if (message?.Message[PreFixLength + 2] == dataTemp[PreFixLength + 2])
{
MessageList.TryRemove(boardId, out message);
}
index += (PreFixLength + DataLength - 2);//每次循环index会+1 所以这里-1
}
//获取返回指令的板子ID
var boardId = (dataTemp[PreFixLength + 0] << 8) + dataTemp[PreFixLength + 1];
//查询当前板子是否有待验证的指令
var message = new MessageDto();
MessageList.TryGetValue(boardId, out message);
//功能位校验 功能位相同视为已响应指令 删除对应的指令
if (message?.Message[PreFixLength + 2] == dataTemp[PreFixLength + 2])
{
MessageList.TryRemove(boardId, out message);
}
index += (PreFixLength + DataLength - 2);//每次循环index会+1 所以这里-1
}
}
Logs.Write($"校验发送接收处理完毕" + BitConverter.ToString(data));
Logs.Write($"【校验发送接收 结束】" + BitConverter.ToString(data), LogsType.InstructionResend);
});
return null;
};
tcpClient.Connected += (client, e) =>
@ -138,17 +140,18 @@ namespace WCS.BLL
.ToList();
foreach (var message in failedMessage)
{
Logs.Write(BitConverter.ToString(message.Value.Message) + "指令超时1s未响应");
Logs.Write("【指令重发】" + BitConverter.ToString(message.Value.Message) + "指令超时1s未响应", LogsType.InstructionResend);
}
MessageList.RemoveWhen(t => t.Value.SendTimes >= 2);
foreach (var item in MessageList)
{
if (item.Value.LastSendTime < DateTime.Now.AddSeconds(-1))
{
Send(item.Value.Message);
item.Value.SendTimes++;
item.Value.LastSendTime = DateTime.Now;
await Task.Delay(10);
Logs.Write("【指令重发】" + BitConverter.ToString(item.Value.Message) + "已进行重发", LogsType.InstructionResend);
}
}
}
@ -175,12 +178,14 @@ namespace WCS.BLL
try
{
var boardId = (message[3] << 8) + message[4];
if (boardId != 2047 && IsReSend == false)
{
MessageList.TryAdd(boardId, new MessageDto()
{
ID = boardId,
Message = message,
SendTimes = 1
});
}
@ -190,6 +195,8 @@ namespace WCS.BLL
//发送自带8ms间隔
Thread.Sleep(8);
}
}
catch (Exception ex)
{

View File

@ -11,7 +11,6 @@ namespace WCS.Model
public string MatSn { get; set; } = string.Empty;
public string ShelfCode { get; set; } = string.Empty;
public string IpAddress { get; set; } = string.Empty;
public bool IsSingleLightIn { get; set; } = false;
public bool SingleLightIn { get; set; } = false;
}
}

View File

@ -10,12 +10,10 @@ namespace WCS.Model.ApiModel.MatInventoryDetail
public string MatName { get; set; }
public string MatSpec { get; set; }
public string MatBatch { get; set; }
public string MatSupplier { get; set; }
public string MatCustomer { get; set; }
public int ShelfTypeId { get; set; }
}
}

View File

@ -5,7 +5,7 @@ using System.Text;
namespace WCS.Model.ApiModel.MatInventoryDetail
{
public class MatInventorySummaryModel: INotifyPropertyChanged
public class MatInventorySummaryModel : INotifyPropertyChanged
{
public string MatCode { get; set; }
@ -33,6 +33,9 @@ namespace WCS.Model.ApiModel.MatInventoryDetail
}
}
public string Info { get; set; }
public bool IsSelected
{

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace WCS.Model.ApiModel.OutStore
{
public class OutImportMatModel
{
public string { get; set; }
public string { get; set; }
public string { get; set; }
public int { get; set; }
}
}

View File

@ -17,6 +17,15 @@ namespace WCS.Model
/// </summary>
public string OrderType { get; set; }
/// <summary>
/// 货架类型Id
/// </summary>
public int ShelfTypeId { get; set; } = 0;
/// <summary>
/// 货架类型名称
/// </summary>
public string ShelfTypeName { get; set; } = string.Empty;
public List<MatCodeItemList> ItemList { get; set; }
}

View File

@ -0,0 +1,83 @@
using Microsoft.AspNetCore.Mvc;
using NPOI.HPSF;
using WCS.BLL.Services.IService;
using WCS.Model;
using WCS.Model.ApiModel;
using WCS.Model.ApiModel.User;
using WCS.Model.WebSocketModel;
namespace WCS.WebApi.Controllers
{
/// <summary>
/// 文件下载
/// </summary>
[ApiController]
[Route("[controller]")]
public class FileDownLoadController : ControllerBase
{
public FileDownLoadController()
{
}
[HttpGet("downloadApp")]
public IActionResult downloadApp(string fileName)
{
// 这里是文件的物理路径,你需要根据实际情况提供
var filePath = Path.Combine(Directory.GetCurrentDirectory(), $"Files/{fileName}");
// 检查文件是否存在
if (!System.IO.File.Exists(filePath))
{
return NotFound();
}
// 获取文件流
var stream = System.IO.File.OpenRead(filePath);
// 设置HTTP响应头使浏览器知道这是一个附件应该下载而不是打开
Response.Headers.Add("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
// 返回文件流作为FileResult
return File(stream, "application/octet-stream", fileName);
}
[HttpGet("getLatestAppName")]
public ResponseCommon<string> getLatestAppName()
{
string directoryPath = Path.Combine(Directory.GetCurrentDirectory(), $"Files");
// 获取目录下的所有文件信息
FileInfo[] files = Directory.GetFiles(directoryPath, "*.app")
.Select(file => new FileInfo(file))
.ToArray();
if (files == null || files.Length == 0)
{
return new ResponseCommon<string>()
{
Code = 201,
Message = "服务器不存在App安装包"
};
}
//获取最后修改的一个
FileInfo lastModifiedFile = files.OrderByDescending(f => f.LastWriteTime).First();
if (lastModifiedFile != null)
{
return new ResponseCommon<string>()
{
Code = 200,
Data = lastModifiedFile.Name
};
}
else
{
return new ResponseCommon<string>()
{
Code = 201,
Message = "服务器不存在App安装包"
};
}
}
}
}

View File

@ -1,9 +1,11 @@
using Microsoft.AspNetCore.Mvc;
using MiniExcelLibs;
using WCS.BLL.HardWare;
using WCS.BLL.Manager;
using WCS.BLL.Services.IService;
using WCS.BLL.Services.Service;
using WCS.Model;
using WCS.Model.ApiModel.MatBaseInfo;
using WCS.Model.ApiModel.OutStore;
namespace WebApi.Controllers
@ -15,12 +17,54 @@ namespace WebApi.Controllers
private readonly IOutstoreService _outstoreService;
private readonly IGenerateService _generateService;
public OutstoreController(IOutstoreService outstoreService,IGenerateService generateService)
public OutstoreController(IOutstoreService outstoreService, IGenerateService generateService)
{
_outstoreService = outstoreService;
_generateService = generateService;
}
/// <summary>
/// <20><><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD>ͱȶ<CDB1>
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("importMat")]
[HttpPost(Name = "importMat")]
public async Task<ResponseBase> importMat([FromForm] IFormFile excelFile, [FromForm] string userName, [FromForm] string deviceType)
{
try
{
//<2F>ļ<EFBFBD>У<EFBFBD><D0A3>
if (excelFile == null || excelFile.Length == 0)
{
return new ResponseCommon()
{
Code = 201,
Message = "<22><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>:<3A>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD>ݣ<EFBFBD>"
};
}
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>
using (var stream = new MemoryStream())
{
await excelFile.CopyToAsync(stream);
stream.Position = 0;
var list = MiniExcelLibs.MiniExcel.Query<OutImportMatModel>(stream, "<22><><EFBFBD><EFBFBD><E2B5BC>ģ<EFBFBD><C4A3>", ExcelType.XLSX).ToList();
return await _outstoreService.importMat(list);
}
}
catch (Exception ex)
{
return new ResponseBase()
{
Code = 201,
Message = "<22><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>" + ex.Message,
};
}
}
/// <summary>
/// <20><><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD><CFB1><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/// </summary>
@ -33,7 +77,7 @@ namespace WebApi.Controllers
try
{
if (string.IsNullOrEmpty(request.OrderNumber))
{
{
request.OrderNumber = await _generateService.generateOutOrderNumber();
}
return await _outstoreService.SysOutOrderByMatCode(request);

View File

@ -7,9 +7,6 @@ using WCS.Model.WebSocketModel;
namespace WCS.WebApi.Controllers
{
/// <summary>
/// 权限/用户界面的接口
/// </summary>
[ApiController]
[Route("[controller]")]
public class WarningController : ControllerBase

0
WCS.WebApi/Files/APP.app Normal file
View File

View File

@ -18,4 +18,14 @@
<ProjectReference Include="..\WCS.Model\WCS.Model.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Files\" />
</ItemGroup>
<ItemGroup>
<None Update="Files\APP.app">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View File

@ -282,11 +282,11 @@ namespace 货架标准上位机.Api
public static T GetDataFromHttp<T>(string url, object dataObj, string httpMethod, bool isSaveLog = false)
{
Guid guid = Guid.NewGuid();
var data = JsonConvert.SerializeObject(dataObj);
var data = dataObj == null ? string.Empty : JsonConvert.SerializeObject(dataObj);
try
{
if (isSaveLog)
Logs.Write($"【{guid}】开始请求调用接口 url{url} 请求方式:{httpMethod} 数据:{data}",LogsType.Api);
Logs.Write($"【{guid}】开始请求调用接口 url{url} 请求方式:{httpMethod} 数据:{data}", LogsType.Api);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = httpMethod;
request.ContentType = "application/json";

Binary file not shown.

View File

@ -19,6 +19,10 @@ namespace 货架标准上位机
/// 货架服务器的Ip和端口号
/// </summary>
public string ApiIpHost { get; set; }
/// <summary>
/// WebSocket服务器的地址
/// </summary>
public string WebSocketUrl { get; set; }
public List<string> GroupName { get; set; }

View File

@ -276,7 +276,7 @@ namespace 货架标准上位机.ViewModel
var Result = ApiHelp.GetDataFromHttp<ResponseCommon<MatInfoModel>>(LocalFile.Config.ApiIpHost + "instore/queryInstoreStatus", body, "POST");
if (Result != null && !string.IsNullOrEmpty(Result.Message))
{
TextBoxLog.AddLog(Result.Message, "InstoreLog", DateTime.Now);
TextBoxLog.AddLog($"物料[{scanner.MatSn}]" + Result.Message, "InstoreLog", DateTime.Now);
scanner.MatSn = string.Empty;
scanner.ScannerDisplayControl.RefreshValues(scanner.ShelfCode, scanner.MatSn);
}

View File

@ -227,18 +227,6 @@ namespace 货架标准上位机.ViewModel
//已经选择文件 调用接口进行导入数据
string path = ofd.FileName;
var body = new GetMatBaseInfoRequest()
{
MatCode = MatCode,
MatName = MatName,
MatSpec = MatSpec,
IsEnable = IsEnable,
UserName = LocalStatic.CurrentUser,
DeviceType = LocalFile.Config.DeviceType,
PageNumber = CurrentPage,
PageSize = 65535,
};
var result = await ApiHelp.PostImportFileAsync<ResponseCommon<List<string>>>(path, System.Net.Http.HttpMethod.Post,
LocalFile.Config.ApiIpHost + "matBaseInfo/importMatBaseInfo", LocalStatic.CurrentUser, LocalFile.Config.DeviceType);
if (result.Code == 200)

View File

@ -33,14 +33,7 @@ namespace 货架标准上位机.ViewModel
{
public MatInventoryDetailViewModel()
{
//获取物料编码列表
//matCodes = DbHelp.db.Queryable<InventoryDetail>()
// .Select(t => new DataModel()
// {
// MatCode = t.MatCode
// })
// .Distinct()
// .ToList();
}
public void InitMatCode()

View File

@ -4,10 +4,12 @@ using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using WCS.BLL.DbModels;
using WCS.Model;
using WCS.Model.ApiModel.Home;
using WCS.Model.ApiModel.MatInventoryDetail;
using .Api;
@ -35,6 +37,71 @@ namespace 货架标准上位机.ViewModels
SetProperty(ref selectedItemSource, value);
}
}
private List<ShelfTypeModel> shelfTypeItems;
public List<ShelfTypeModel> ShelfTypeItems
{
get { return shelfTypeItems; }
set
{
SetProperty(ref shelfTypeItems, value);
}
}
public void InitShelfTypeItems()
{
//调用接口更新!
Task.Run(() =>
{
var body = new RequestBase()
{
UserName = LocalStatic.CurrentUser,
DeviceType = LocalFile.Config.DeviceType,
};
var Result = ApiHelp.GetDataFromHttp<PageQueryResponse<ShelfTypeModel>>(LocalFile.Config.ApiIpHost + "home/getShelfTypes", body, "POST");
if (Result != null && Result.Data != null && Result.Data.Lists.Count() > 0)
{
ShelfTypeItems = Result.Data.Lists;
SelectedShelfTypeItem = Result.Data.Lists.First();
}
});
}
private ShelfTypeModel selectedShelfTypeItem;
public ShelfTypeModel SelectedShelfTypeItem
{
get { return selectedShelfTypeItem; }
set
{
SetProperty(ref selectedShelfTypeItem, value);
}
}
private int selectedTypeCount = 0;
public int SelectedTypeCount
{
get => selectedTypeCount;
set
{
SetProperty(ref selectedTypeCount, value);
if (selectedTypeCount == 0)
{
ShelfTypeIsEnabled = true;
}
else
{
ShelfTypeIsEnabled = false;
}
}
}
private bool shelfTypeIsEnabled = true;
public bool ShelfTypeIsEnabled
{
get => shelfTypeIsEnabled; set { SetProperty(ref shelfTypeIsEnabled, value); }
}
#endregion
#region Command
@ -44,7 +111,11 @@ namespace 货架标准上位机.ViewModels
public ICommand BtnAddCommand { get => new DelegateCommand(BtnAdd); }
public void BtnAdd()
{
var window = new OutInventoryAddMatView();
if (SelectedShelfTypeItem == null)
{
HandyControl.Controls.MessageBox.Show("请选择货架类型!");
}
var window = new OutInventoryAddMatView(SelectedShelfTypeItem.Id);
window.Owner = Application.Current.MainWindow;
var result = window.ShowDialog();
if (result == true)
@ -52,6 +123,7 @@ namespace 货架标准上位机.ViewModels
if (DataGridItemSource == null)
DataGridItemSource = new ObservableCollection<MatInventorySummaryModel>();
DataGridItemSource.Add(window.inventorySummary);
SelectedTypeCount = DataGridItemSource.Count;
}
else
{
@ -66,11 +138,12 @@ namespace 货架标准上位机.ViewModels
{
DataGridItemSource.Remove(obj);
;
SelectedTypeCount = DataGridItemSource.Count;
}
catch (Exception ex)
{
Growl.Info(ex.Message);
Logs.Write($"删除物料时发生异常", LogsType.Err);
}
}
@ -117,6 +190,8 @@ namespace 货架标准上位机.ViewModels
{
OrderType = "出库",
OrderSource = "WCS前端",
ShelfTypeId = SelectedShelfTypeItem.Id,
ShelfTypeName = SelectedShelfTypeItem.ShelfTypeName,
ItemList = DataGridItemSource.Select(t => new MatCodeItemList()
{
MatCode = t.MatCode,

View File

@ -58,6 +58,14 @@ namespace 货架标准上位机.ViewModels
SetProperty(ref matName, value);
}
}
private int shelfTypeId;
public int ShelfTypeId
{
get => shelfTypeId;
set { SetProperty(ref shelfTypeId, value); }
}
#endregion
#region Command
@ -74,6 +82,7 @@ namespace 货架标准上位机.ViewModels
{
MatName = MatName,
MatCode = MatCode,
ShelfTypeId = ShelfTypeId,
};
var Result = ApiHelp.GetDataFromHttp<ResponseCommon<List<MatInventorySummaryModel>>>(LocalFile.Config.ApiIpHost + "matInventoryDetail/getMatInventorySummary", body, "POST");
if (Result != null && Result.Data != null)

View File

@ -144,6 +144,17 @@ namespace 货架标准上位机.ViewModels
BtnSearch(true);
}
//导入出库
public ICommand BtnImportDocumentCommand { get => new DelegateCommand(BtnImportDocument); }
public void BtnImportDocument()
{
var window = new OutInventoryImportDucumentView();
window.Owner = Application.Current.MainWindow;
var result = window.ShowDialog();
if (result == true)
BtnSearch(true);
}
public ICommand BtnOrderDetailCommand { get => new DelegateCommand(BtnOrderDetail); }
public void BtnOrderDetail()
{

View File

@ -0,0 +1,212 @@
using HandyControl.Controls;
using Ping9719.WpfEx.Mvvm;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Input;
using WCS.BLL.DbModels;
using WCS.Model;
using WCS.Model.ApiModel.MatBaseInfo;
using WCS.Model.ApiModel.MatInventoryDetail;
using .Api;
namespace .ViewModels
{
public class OutInventoryImportDucumentViewModel : BindableBase
{
#region Property
private ObservableCollection<MatInventorySummaryModel> dataGridItemSource;
public ObservableCollection<MatInventorySummaryModel> DataGridItemSource
{
get { return dataGridItemSource; }
set
{
SetProperty(ref dataGridItemSource, value);
}
}
private MatInventorySummaryModel selectedItemSource;
public MatInventorySummaryModel SelectedItemSource
{
get { return selectedItemSource; }
set
{
SetProperty(ref selectedItemSource, value);
}
}
#endregion
#region Command
public ICommand BtnDownloadExcelCommand { get => new DelegateCommand(BtnDownloadExcel); }
public async void BtnDownloadExcel()
{
try
{
#region
Microsoft.Win32.SaveFileDialog sfd = new Microsoft.Win32.SaveFileDialog();
sfd.Filter = ".xlsx文件(*.xlsx)|*.xlsx";
sfd.FileName = "出库导入模板";
sfd.Title = "请选择文件保存地址";
sfd.OverwritePrompt = true;
if (sfd.ShowDialog() != true)
{
return;
}
string path = sfd.FileName;
#endregion
#region
string sourceFile = System.Environment.CurrentDirectory + "\\Excel\\出库单据导入模板.xlsx"; // 源文件路径
string destinationFile = path; // 目标文件路径
try
{
File.Copy(sourceFile, destinationFile, true); // true表示如果目标文件存在则覆盖它
Growl.Success("文件下载成功!");
}
catch (IOException ioEx)
{
Growl.Success("文件下载失败: " + ioEx.Message);
}
catch (Exception ex)
{
Growl.Success("文件下载失败: " + ex.Message);
}
#endregion
}
catch (Exception ex)
{
Growl.Error("导出失败:" + ex.Message);
}
}
public ICommand BtnImportCommand { get => new DelegateCommand(BtnImport); }
public async void BtnImport()
{
try
{
#region
Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog();
ofd.Title = "选择模板";
ofd.Filter = ".xlsx文件(*.xlsx)|*.xlsx";
ofd.Multiselect = false;
if (ofd.ShowDialog() != true)
{
return;
}
#endregion
//已经选择文件 调用接口进行导入数据
string path = ofd.FileName;
#region
var result = await ApiHelp.PostImportFileAsync<ResponseCommon<List<MatInventorySummaryModel>>>(path, System.Net.Http.HttpMethod.Post,
LocalFile.Config.ApiIpHost + "outstore/importMat", LocalStatic.CurrentUser, LocalFile.Config.DeviceType);
if (result.Code == 200)
{
DataGridItemSource = new ObservableCollection<MatInventorySummaryModel>(result.Data);
}
else
{
if (result != null && !string.IsNullOrEmpty(result.Message))
HandyControl.Controls.MessageBox.Show(result.Message);
else
{
HandyControl.Controls.MessageBox.Show("导入失败,请重试!");
}
}
#endregion
}
catch (Exception ex)
{
Growl.Warning("导入失败:" + ex.Message);
}
}
public ICommand DelCommand { get => new DelegateCommand<MatInventorySummaryModel>(Del); }
public void Del(MatInventorySummaryModel obj)
{
try
{
DataGridItemSource.Remove(obj);
;
}
catch (Exception ex)
{
}
}
// 定义一个事件,当需要关闭窗口时触发
public event Action TrueClose;
public event Action FalseClose;
// 一个方法,当满足某些条件时调用,以触发关闭窗口
protected virtual void OnRequestClose(bool IsTrue)
{
if (IsTrue)
TrueClose?.Invoke();
else
FalseClose?.Invoke();
}
public ICommand GenerateOutOrderCommand { get => new DelegateCommand(GenerateOutOrder); }
public void GenerateOutOrder()
{
//数据校验
if (DataGridItemSource == null || DataGridItemSource.Count == 0)
{
HandyControl.Controls.MessageBox.Show("选择的物料为空无法生成出库单!");
return;
}
foreach (var itemSource in DataGridItemSource)
{
if (itemSource.NeedQty == 0)
{
Growl.Warning("需求数量未填!");
SelectedItemSource = itemSource;
return;
}
}
#region
try
{
var body = new SysOutOrderByMatCodeRequest()
{
OrderType = "出库",
OrderSource = "WCS前端",
ItemList = DataGridItemSource.Select(t => new MatCodeItemList()
{
MatCode = t.MatCode,
MatName = t.MatName,
MatBatch = t.MatBatch,
ReqQty = t.NeedQty,
}).ToList(),
DeviceType = LocalFile.Config.DeviceType,
UserName = LocalStatic.CurrentUser
};
var Result = ApiHelp.GetDataFromHttp<ResponseCommon>(LocalFile.Config.ApiIpHost + "outstore/sysOutOrderByMatCode", body, "POST");
if (Result != null && Result.Code == 200)
{
Growl.Success(Result.Message);
OnRequestClose(true);
}
else if (Result != null)
{
Growl.Warning(Result.Message);
return;
}
}
catch (Exception ex)
{
Growl.Error("加载数据失败:" + ex.Message);
}
finally
{
}
#endregion
}
#endregion
}
}

View File

@ -1,15 +1,26 @@
using HandyControl.Controls;
using HandyControl.Tools.Extension;
using Microsoft.Win32;
using Ping9719.WpfEx.Mvvm;
using QRCoder;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.IO.Ports;
using System.Linq;
using System.Reflection.Emit;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media.Imaging;
using WCS.Model;
using .Api;
using .Views.Controls;
using static System.Net.WebRequestMethods;
namespace .ViewModel
{
@ -215,5 +226,61 @@ namespace 货架标准上位机.ViewModel
{
}
}
public ICommand AppQRCodeCommand { get => new DelegateCommand(AppQRCode); }
public void AppQRCode()
{
try
{
#region App名称
var Result = ApiHelp.GetDataFromHttp<ResponseCommon>(LocalFile.Config.ApiIpHost + "fileDownload/getLatestAppName", null, "GET");
if (Result != null && Result.Code == 200)
{
//拼凑url
var downLoadUrl = LocalFile.Config.ApiIpHost + $"fileDownload/downloadApp?fileName={Result.Data}";
//生成二维码
var qrCodeImage = GenerateQRCode(downLoadUrl);
//展示二维码
Dialog.Show(new ImageDialog(qrCodeImage));
}
else if (Result != null)
{
Growl.Warning(Result.Message);
}
else
{
Growl.Warning("调用接口失败!");
}
#endregion
}
catch
{
}
}
public BitmapImage GenerateQRCode(string data)
{
QRCodeGenerator qrGenerator = new QRCodeGenerator();
QRCodeData qrCodeData = qrGenerator.CreateQrCode(data, QRCodeGenerator.ECCLevel.Q);
QRCode qrCode = new QRCode(qrCodeData);
Bitmap qrCodeImage = qrCode.GetGraphic(20, Color.Black, Color.White, true);
// 将System.Drawing.Bitmap转换为System.Windows.Media.Imaging.BitmapImage
using (var memoryStream = new MemoryStream())
{
// 假设Bitmap的Save方法支持Png格式通常是这样
qrCodeImage.Save(memoryStream, ImageFormat.Png);
memoryStream.Position = 0;
var bitmapImage = new BitmapImage();
bitmapImage.BeginInit();
bitmapImage.StreamSource = memoryStream;
bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
bitmapImage.EndInit();
// 返回BitmapImage
return bitmapImage;
}
}
}
}

View File

@ -0,0 +1,15 @@
<Border x:Class="货架标准上位机.Views.Controls.ImageDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:hc="https://handyorg.github.io/handycontrol"
CornerRadius="10"
Width="300"
Height="186"
Background="{DynamicResource RegionBrush}">
<hc:SimplePanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<Image Name="image1"> </Image>
</StackPanel>
<Button Width="22" Height="22" Command="hc:ControlCommands.Close" Style="{StaticResource ButtonIcon}" Foreground="{DynamicResource PrimaryBrush}" hc:IconElement.Geometry="{StaticResource ErrorGeometry}" Padding="0" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,4,4,0"/>
</hc:SimplePanel>
</Border>

View File

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
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;
namespace .Views.Controls
{
/// <summary>
/// TextDialog.xaml 的交互逻辑
/// </summary>
public partial class ImageDialog
{
public ImageDialog(BitmapImage image)
{
InitializeComponent();
this.image1.Source = image;
}
}
}

View File

@ -113,9 +113,9 @@
</Button>
<Button MinHeight="40" FontSize="18" Margin="5"
Content="&#xe866;导 入" FontFamily="{StaticResource IconFont}"
Content="&#xe613;导 入" FontFamily="{StaticResource IconFont}"
Command="{Binding BtnImportCommand}"
Foreground="WhiteSmoke"
Foreground="WhiteSmoke"
Background="Green"
>
</Button>
@ -129,7 +129,7 @@
<Button MinHeight="40" FontSize="18" Margin="5"
Content="&#xe866;打 印" FontFamily="{StaticResource IconFont}"
Content="&#xe7f8;生成&amp;打印" FontFamily="{StaticResource IconFont}"
Command="{Binding BtnPrintCommand}"
Foreground="WhiteSmoke"
Background="DarkOrange"

View File

@ -116,7 +116,7 @@
<StackPanel Grid.Row="0" Orientation="Horizontal">
<Button MinHeight="40" FontSize="18" Margin="4" hc:BorderElement.CornerRadius="6"
Content="&#xe866;打印/补打" FontFamily="{StaticResource IconFont}"
Content="&#xe7f8;打印/补打" FontFamily="{StaticResource IconFont}"
Command="{Binding BtnPrintCommand}"
Foreground="WhiteSmoke"
Background="DarkOrange">

View File

@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:hc="https://handyorg.github.io/handycontrol"
Height="500" Width="850" WindowStyle="None" Background="{x:Null}" BorderThickness="0" AllowsTransparency="True" WindowStartupLocation="CenterScreen" Opacity="1">
Height="500" Width="850" WindowStyle="None" Background="{x:Null}" BorderThickness="0" AllowsTransparency="True" WindowStartupLocation="CenterScreen" Opacity="1" Loaded="Window_Loaded">
<hc:Window.Resources>
<ResourceDictionary>
<Style TargetType="Button" BasedOn="{StaticResource ButtonDefault}">
@ -34,6 +34,19 @@
<Border Background="AliceBlue" Padding="0">
<Grid >
<StackPanel Margin="3" Orientation="Horizontal">
<StackPanel Margin="3" Grid.Row="3" Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center">
<TextBlock VerticalAlignment="Center"
Text="货架类型:" FontSize="22" >
</TextBlock>
<ComboBox
IsEnabled="{Binding ShelfTypeIsEnabled}"
VerticalAlignment="Center"
DisplayMemberPath="ShelfTypeName"
ItemsSource="{Binding ShelfTypeItems}"
SelectedItem="{Binding SelectedShelfTypeItem}"
FontSize="22"
IsEditable="False"/>
</StackPanel>
<Button MinHeight="40" FontSize="18"
Content="&#xe604;增加物料" FontFamily="{StaticResource IconFont}"
Foreground="WhiteSmoke"
@ -76,15 +89,15 @@
</Grid>
<StackPanel Grid.Row="3" HorizontalAlignment="Right" Orientation="Horizontal">
<TextBlock FontSize="20" Text="已选物料:"></TextBlock>
<TextBlock FontSize="20" Text="{Binding SelectedTypeCount}"></TextBlock>
<TextBlock FontSize="20" Text="种"></TextBlock>
<TextBlock FontSize="22" Text="已选物料:"></TextBlock>
<TextBlock FontSize="22" Text="{Binding SelectedTypeCount}"></TextBlock>
<TextBlock FontSize="22" Text="种"></TextBlock>
</StackPanel>
<StackPanel Margin="3" x:Name="spacingPanel" Grid.Row="4" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<Button Margin="0" Content="生成出库单" Background="ForestGreen" Foreground="White" MinHeight="40" FontSize="20"
Command="{Binding GenerateOutOrderCommand}"/>
<TextBlock Margin="20" Text=""></TextBlock>
<TextBlock Margin="16" Text=""></TextBlock>
<Button Margin="0" Content="取消" Background="IndianRed" Foreground="White" MinHeight="40" FontSize="20" Click="closeClick"/>
</StackPanel>

View File

@ -59,5 +59,10 @@ namespace 货架标准上位机
this.DialogResult = false;
this.Close();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
viewModel.InitShelfTypeItems();
}
}
}

View File

@ -25,10 +25,11 @@ namespace 货架标准上位机
public MatInventorySummaryModel inventorySummary = null;
public OutInventoryAddMatView()
public OutInventoryAddMatView(int shelfTypeId)
{
InitializeComponent();
this.DataContext = viewModel;
viewModel.ShelfTypeId = shelfTypeId;
}
private void closeClick(object sender, RoutedEventArgs e)

View File

@ -88,12 +88,18 @@
<Button MinHeight="40" FontSize="18" Margin="5" Command="{Binding BtnPauseCommand}"
Content="&#xe67e;暂停发料" FontFamily="{StaticResource IconFont}" Background="CadetBlue" Foreground="White">
</Button>
<Button hc:BorderElement.CornerRadius="10"
<Button hc:BorderElement.CornerRadius="10" Margin="5"
HorizontalAlignment="Right"
Background="Green" Foreground="White"
Grid.Column="1" MinHeight="40" FontSize="22" Content="&#xe6e2;物料发料" FontFamily="{StaticResource IconFont}"
Grid.Column="1" MinHeight="40" FontSize="22" Content="&#xe6e2;物料发料" FontFamily="{StaticResource IconFont}"
Command="{Binding BtnOutOrderCommand}">
</Button>
<Button hc:BorderElement.CornerRadius="10" Margin="5"
HorizontalAlignment="Right"
Background="Green" Foreground="White"
Grid.Column="1" MinHeight="40" FontSize="22" Content="&#xe6e2;导入发料" FontFamily="{StaticResource IconFont}"
Command="{Binding BtnImportDocumentCommand}">
</Button>
</StackPanel>
<DataGrid Grid.Row="1" SelectedCellsChanged="DataGrid_SelectedCellsChanged"
SelectedItem="{Binding SelectedataGridItem}"

View File

@ -0,0 +1,93 @@
<hc:Window x:Class="货架标准上位机.OutInventoryImportDucumentView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:hc="https://handyorg.github.io/handycontrol"
Height="500" Width="850" WindowStyle="None" Background="{x:Null}" BorderThickness="0" AllowsTransparency="True" WindowStartupLocation="CenterScreen" Opacity="1">
<hc:Window.Resources>
<ResourceDictionary>
<Style TargetType="Button" BasedOn="{StaticResource ButtonDefault}">
<Setter Property="Padding" Value="25,0"></Setter>
</Style>
</ResourceDictionary>
</hc:Window.Resources>
<Border Background="AliceBlue" CornerRadius="10" BorderThickness="1.5" BorderBrush="Black" >
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="1.5*"></RowDefinition>
<RowDefinition Height="10*"></RowDefinition>
<RowDefinition Height="0.8*"></RowDefinition>
<RowDefinition Height="1.5*"></RowDefinition>
</Grid.RowDefinitions>
<Button Margin="-5,-1" Visibility="{Binding IsClose,Converter={StaticResource Boolean2VisibilityConverter}}" Style="{StaticResource ButtonIcon}" hc:IconElement.Geometry="{StaticResource CloseGeometry}" HorizontalAlignment="Right" VerticalAlignment="Top" Click="closeClick"/>
<StackPanel Orientation="Vertical">
<TextBlock FontSize="25" Name="Title" Text="导入出库单据" TextWrapping="Wrap" VerticalAlignment="Top" HorizontalAlignment="Center"/>
<hc:Divider Margin="0"></hc:Divider>
</StackPanel>
<Border Grid.Row="1" Margin="2 2 2 0" Background="AliceBlue" Padding="0">
<Border Background="AliceBlue" Padding="0">
<Grid >
<StackPanel Margin="3" Orientation="Horizontal">
<Button MinHeight="40" FontSize="18" Margin="3"
Content="&#xe613;导入" FontFamily="{StaticResource IconFont}"
Foreground="WhiteSmoke"
Background="Green"
Command="{Binding BtnImportCommand}">
</Button>
<Button MinHeight="40" FontSize="18" Margin="3"
Content="&#xe610;下载模板" FontFamily="{StaticResource IconFont}"
Foreground="WhiteSmoke"
Background="Green"
Command="{Binding BtnDownloadExcelCommand}">
</Button>
</StackPanel>
</Grid>
</Border>
</Border>
<Grid Margin="5,0" Grid.Row="2" >
<DataGrid Grid.Row="1" SelectedCellsChanged="DataGrid_SelectedCellsChanged"
RowHeight="39"
ItemsSource="{Binding DataGridItemSource}"
SelectedItem="{Binding SelectedItemSource, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
AutoGenerateColumns="False" Name="dg1" FontSize="15">
<DataGrid.Columns>
<DataGridTextColumn IsReadOnly="True" Header="物料编码" Binding="{Binding MatCode}"></DataGridTextColumn>
<DataGridTextColumn IsReadOnly="True" Header="物料名称" MaxWidth="150" Binding="{Binding MatName}"></DataGridTextColumn>
<DataGridTextColumn IsReadOnly="True" Header="物料批次" Binding="{Binding MatBatch}"></DataGridTextColumn>
<DataGridTextColumn IsReadOnly="True" Header="库存数量" Binding="{Binding TotalQty}"></DataGridTextColumn>
<DataGridTextColumn IsReadOnly="True" Header="需求数量" Binding="{Binding NeedQty}"></DataGridTextColumn>
<DataGridTextColumn IsReadOnly="True" Header="提示信息" Binding="{Binding Info}"></DataGridTextColumn>
<DataGridTemplateColumn CanUserResize="False" Header="">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Style="{StaticResource ButtonDanger}" Margin="0,0,0,0" IsEnabled="True" Content="删除" Width="60" Command="{Binding DataContext.DelCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}" CommandParameter="{Binding }"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
</Grid>
<StackPanel Grid.Row="3" HorizontalAlignment="Right" Orientation="Horizontal">
<TextBlock FontSize="20" Text="已选物料:"></TextBlock>
<TextBlock FontSize="20" Text="{Binding SelectedTypeCount}"></TextBlock>
<TextBlock FontSize="20" Text="种"></TextBlock>
</StackPanel>
<StackPanel Margin="3" x:Name="spacingPanel" Grid.Row="4" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<Button Margin="0" Content="生成出库单" Background="ForestGreen" Foreground="White" MinHeight="40" FontSize="20"
Command="{Binding GenerateOutOrderCommand}"/>
<TextBlock Margin="20" Text=""></TextBlock>
<Button Margin="0" Content="取消" Background="IndianRed" Foreground="White" MinHeight="40" FontSize="20" Click="closeClick"/>
</StackPanel>
</Grid>
</Border>
</hc:Window>

View File

@ -0,0 +1,63 @@

using HandyControl.Controls;
using HandyControl.Data;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Media;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using .ViewModels;
namespace
{
public partial class OutInventoryImportDucumentView : HandyControl.Controls.Window
{
public OutInventoryImportDucumentViewModel viewModel = new OutInventoryImportDucumentViewModel();
public OutInventoryImportDucumentView()
{
InitializeComponent();
this.DataContext = viewModel;
viewModel.TrueClose += OnTrueClose;
viewModel.FalseClose += OnFalseClose;
}
private void closeClick(object sender, RoutedEventArgs e)
{
this.DialogResult = false;
this.Close();
}
private void DataGrid_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
{
}
private void txtMatQty1_PreviewTextInput(object sender, TextCompositionEventArgs e)
{
if (!Regex.IsMatch(e.Text, "^[0-9]"))
{
e.Handled = true;
}
}
private void OnTrueClose()
{
this.DialogResult = true;
this.Close();
}
private void OnFalseClose()
{
this.DialogResult = false;
this.Close();
}
}
}

View File

@ -127,14 +127,6 @@
ItemsSource="{Binding DataGridItemSource}"
RowHeight="40"
AutoGenerateColumns="False" FontSize="15">
<!--<DataGrid.Resources>
<货架标准上位机:WorkItemBackgroundConverter x:Key="converter"/>
</DataGrid.Resources>
<DataGrid.RowStyle>
<Style TargetType="DataGridRow">
<Setter Property="Background" Value="{Binding Path=IsSended, Converter={StaticResource converter}}"/>
</Style>
</DataGrid.RowStyle>-->
<DataGrid.Columns>
<DataGridTemplateColumn Header="" CanUserResize="False" Width="50">
<DataGridTemplateColumn.CellTemplate>

View File

@ -59,6 +59,14 @@
</StackPanel>
</GroupBox>
<GroupBox Header="App" Margin="5" Padding="5" Style="{StaticResource GroupBoxTab}" Background="{x:Null}">
<StackPanel>
<StackPanel Orientation="Horizontal">
<Button Margin="5" Command="{Binding AppQRCodeCommand}">下载二维码</Button>
</StackPanel>
</StackPanel>
</GroupBox>
<GroupBox Header="软件" Margin="5" Padding="5" Style="{StaticResource GroupBoxTab}" Background="{x:Null}">
<StackPanel>
<TextBlock>开机启动</TextBlock>

View File

@ -21,7 +21,7 @@ namespace 货架标准上位机
{
client = new WebSocketClient();
client.Setup(new TouchSocketConfig()
.SetRemoteIPHost("ws://127.0.0.1:7789/ws")
.SetRemoteIPHost(LocalFile.Config.WebSocketUrl)
.ConfigureContainer(a =>
{
a.AddConsoleLogger();
@ -97,7 +97,7 @@ namespace 货架标准上位机
}
else
{
Application.Current.Dispatcher.Invoke(() =>
{
WarningManager.AddWarning(warning);
@ -105,7 +105,7 @@ namespace 货架标准上位机
});
}
}
client.Send(e.DataFrame.ToText());
}

View File

@ -3,8 +3,10 @@
"MySql": "server=localhost;Database=db1;Uid=root;Pwd=123456;Convert Zero Datetime=True",
//货架服务器的IP和端口号
"ApiIpHost": "http://localhost:8888/",
//WebSocket的地址
"WebSocketUrl": "ws://127.0.0.1:7789/ws",
//货架分区
"GroupName": [ "13寸智能货架", "7寸智能货架"],
"GroupName": [ "13寸智能货架", "7寸智能货架" ],
//设备类型 可以配置为每个电脑不一样
"DeviceType": "WCS前端",
//货架类型的是否开机自检

View File

@ -51,6 +51,7 @@
<PackageReference Include="MySqlConnector" Version="2.3.5" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Ping9719.WpfEx" Version="0.8.0" />
<PackageReference Include="QRCoder" Version="1.5.1" />
<PackageReference Include="SqlSugar" Version="5.1.4.149" />
<PackageReference Include="SqlSugar.MySqlConnector" Version="5.1.3.42" />
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.118" />
@ -85,6 +86,12 @@
<None Update="data\jsconfig.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Excel\出库单据导入模板.xlsx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Excel\物料管理导入模板.xlsx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Resources\Interop.BarTender.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
@ -102,12 +109,18 @@
</ItemGroup>
<ItemGroup>
<Compile Update="Models\JsConfig.cs">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Compile>
<Compile Update="Views\Controls\ScannerDisplayControl.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Views\Controls\ProcessDialog.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Views\Controls\ImageDialog.xaml.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>