using Newtonsoft.Json;
|
using System;
|
using System.Collections.Generic;
|
using System.Threading.Tasks;
|
using WIDESEA_Comm;
|
using WIDESEA_Comm.LogInfo;
|
using WIDESEA_Comm.MES_Info;
|
using WIDESEA_Comm.MES_Info.Request;
|
using WIDESEA_Common;
|
using WIDESEA_Core.EFDbContext;
|
using WIDESEA_Core.ManageUser;
|
using WIDESEA_Core.Utilities;
|
using WIDESEA_Entity.DomainModels;
|
using WIDESEA_Entity.DomainModels.Mes;
|
using WIDESEA_WMS.Common;
|
using WIDESEA_WMS.IRepositories;
|
using WIDESEA_WMS.Repositories;
|
using static WIDESEA_Comm.MES_Info.BasicSN;
|
|
namespace WIDESEA_WMS
|
{
|
public partial class ToMesServer
|
{
|
/// <summary>
|
/// 空盘操作 (外协空盘入库,空盘补送)
|
/// </summary>
|
/// <param name="saveModel"></param>
|
/// <returns></returns>
|
public WebResponseContent SendEpmtyTask(SaveModel saveModel)
|
{
|
WebResponseContent content = new WebResponseContent();
|
try
|
{
|
string cacheNo = saveModel.MainData["cacheNo"].ToString(); //缓存架编号
|
string user = saveModel.MainData["creator"].ToString();
|
string type = saveModel.MainData["radio"].ToString(); //1为空盘入库 2为空盘出库
|
int number = Convert.ToInt32(saveModel.MainData["number"].ToString());
|
return content.Error($"{user}无操作权限!");
|
if (type == "1") //空盘入库
|
{
|
//寻找空盘库位
|
dt_stationinfo emptyLocation = GetEmptyLocation();
|
|
dt_agvtask agvtask = new dt_agvtask
|
{
|
//agv_barcode = cacheNo,
|
//agv_code = user,
|
agv_createtime = DateTime.Now,
|
agv_fromaddress = cacheNo,
|
agv_qty = number,
|
agv_grade = 1,
|
agv_tasktype = AGVTaskTypeEnum.TaskType_Inbound.ToString(),
|
agv_taskstate = AGVTaskStateEnum.Create.ToString(),
|
agv_toaddress = emptyLocation.stationCode,
|
};
|
freeDB.Add(agvtask);
|
}
|
else
|
{
|
//根据库存查询空盘库存信息
|
dt_inventory inventory = freeDB.Select<dt_inventory>().Where(x => x.area == "11").OrderByDescending(x => x.OnlineTime).First(); //取最晚的入库车轮
|
|
//数量?
|
//var stationinfo = freeDB.Select<dt_stationinfo>().Where(x => x.stationCode == inventory.stationCode).First();
|
//int num = Convert.ToInt16(stationinfo.quantity);
|
|
|
dt_agvtask agvtask = new dt_agvtask
|
{
|
//agv_barcode = cacheNo,
|
//agv_code = user,
|
agv_createtime = DateTime.Now,
|
agv_fromaddress = inventory.stationCode,
|
agv_qty = 5, //inventory., //告诉AGV取第几个车轮?
|
agv_grade = 1,
|
agv_tasktype = AGVTaskTypeEnum.TaskType_Inbound.ToString(),
|
agv_taskstate = AGVTaskStateEnum.Create.ToString(),
|
agv_toaddress = cacheNo,
|
};
|
freeDB.Add(agvtask);
|
}
|
|
return content.OK();
|
}
|
catch (Exception ex)
|
{
|
return content.Error($"呼叫AGV失败:{ ex.Message}");
|
}
|
}
|
|
private dt_stationinfo GetEmptyLocation()
|
{
|
VOLContext context = new VOLContext();
|
Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(context);
|
var station = stationinfoRepository.Find(x => x.line == 9 && x.location_state == LocationStateEnum.Empty.ToString() && x.area == "11").FirstOrDefault();
|
|
// todo区分大小托盘
|
|
if (station != null)
|
{
|
return station;
|
}
|
else
|
{
|
throw new Exception("空盘库位已满,无法入库!");
|
}
|
|
}
|
}
|
}
|