using Newtonsoft.Json;
|
using System;
|
using System.Collections.Generic;
|
using System.IO;
|
using System.Linq;
|
using System.Reflection;
|
using System.Security.Policy;
|
using System.Text;
|
using System.Threading;
|
using WIDESEA_Common;
|
using WIDESEA_Common.LoctionEnum;
|
using WIDESEA_Common.Tools;
|
using WIDESEA_Core.EFDbContext;
|
using WIDESEA_Core.Utilities;
|
using WIDESEA_Entity.DomainModels;
|
using WIDESEA_Entity.DomainModels.CacheTask;
|
using WIDESEA_Entity.DomainModels.CacheTask.WIDESEA_Entity.DomainModels;
|
using WIDESEA_Entity.materielinfo;
|
using WIDESEA_Services.IRepositories;
|
using WIDESEA_Services.Repositories;
|
namespace WIDESEA_Services.Services
|
{
|
|
public class PdaWorkService
|
{
|
/// <summary>
|
/// pda入库
|
/// </summary>
|
public static WebResponseContent Warehousing(SaveModel saveModel)
|
{
|
|
#region MyRegion
|
WebResponseContent content = new WebResponseContent();
|
VOLContext Context = new VOLContext();
|
Ibase_pda_locationRepository pdaloctionRepository = new base_pda_locationRepository(Context);
|
Idt_containerRepository containerRepository = new dt_containerRepository(Context);
|
IVV_ContainerInfoRepository VV_ContainerInfoRepository = new VV_ContainerInfoRepository(Context);
|
Idt_materielinfoRepository materielinfoRepository = new dt_materielinfoRepository(Context);
|
Idt_agvtaskRepository agvRepository = new dt_agvtaskRepository(Context);
|
Ibase_routing_tableRepository routingRepository = new base_routing_tableRepository(Context);
|
Ibase_ware_locationRepository ibase_Ware_Location = new base_ware_locationRepository(Context);
|
try
|
{
|
//File.ReadAllText(Environment.CurrentDirectory); 表示获取当前
|
|
var hcgnmmjsondata = File.ReadAllText(Directory.GetCurrentDirectory() + @"/Database/HcgNumdata.json");
|
List<HCGNumeData> HCGNUM = JsonConvert.DeserializeObject<List<HCGNumeData>>(hcgnmmjsondata);
|
string csn = saveModel.MainData["csn"].ToString();
|
HCGNumeData NUMJSON = HCGNUM.Where(d => d.num == csn).FirstOrDefault();
|
if (NUMJSON == null)
|
{
|
return content.Error($"缓存柜编号中不存在:{csn},无法入库,请检查");
|
}
|
VV_ContainerInfo containerInfo = VV_ContainerInfoRepository.FindFirst(d => d.container_sn == saveModel.MainData["csn"].ToString());
|
if (containerInfo != null)
|
{
|
return content.Error($"当前缓存柜:{containerInfo.container_sn},已入库在货位地标:{containerInfo.L_Code}");
|
}
|
VV_ContainerInfo containerInfo2 = VV_ContainerInfoRepository.FindFirst(d => d.L_Code == saveModel.MainData["cnum"].ToString());
|
if (containerInfo2 != null)
|
{
|
return content.Error($"当前货位地标:{containerInfo2.L_Code},已被缓存柜:{containerInfo2.container_sn} 占用");
|
}
|
string code = saveModel.MainData["cnum"].ToString();
|
base_pda_location pda_Location = pdaloctionRepository.FindFirst(d => d.L_Code == code);
|
if (pda_Location != null)
|
{
|
if (pda_Location.L_Type != "1F-QJHCG")
|
{
|
if (pda_Location.L_state == LoctionStateEnum.LocationState_Empty.ToString())
|
{
|
|
if (pda_Location.L_Task == 1)
|
{
|
return content.Error($"当前货位地标:{saveModel.MainData["cnum"].ToString()},已存在任务,请检查");
|
}
|
dt_materielinfo materielinfo = materielinfoRepository.FindFirst(d => d.materiel_id == saveModel.MainData["ctype"].ToString());
|
if (materielinfo != null)
|
{
|
dt_container dt_Container = new dt_container()
|
{
|
container_id = Guid.NewGuid(),
|
container_sn = saveModel.MainData["csn"].ToString(),
|
container_barcode = saveModel.MainData["cnum"].ToString(),
|
container_materielid = saveModel.MainData["ctype"].ToString(),
|
container_state = saveModel.MainData["cstate"].ToString(),
|
container_creator = "WCS",
|
container_createtime = DateTime.Now
|
};
|
containerRepository.Add(dt_Container, true);
|
pda_Location.L_state = LoctionStateEnum.LocationState_Stored.ToString();
|
ibase_Ware_Location.Update(pda_Location, true);
|
return content.OK($"缓存柜【{saveModel.MainData["csn"]}】入库完成");
|
}
|
}
|
else
|
{
|
return content.Error($"当前货位地标:{pda_Location.L_Code},货位状态不是空货位,无法入库,请检查");
|
}
|
|
}
|
else
|
{
|
//扫描的货位地标编号异常,不是二楼辅材的货位地标,无法入库
|
return content.Error($"当前货位地标:{pda_Location.L_Code},不是二楼辅材库货位,无法入库");
|
}
|
}
|
|
else
|
{
|
return content.Error($"系统未找到pda扫码的货位地标:{saveModel.MainData["cnum"]},请检查");
|
}
|
return content;
|
}
|
catch (Exception ex)
|
{
|
|
return content.Error(ex.Message);
|
}
|
#endregion
|
}
|
|
|
|
/// <summary>
|
/// 回流呼叫
|
/// </summary>
|
/// <param name="saveModel"></param>
|
/// <returns></returns>
|
public static WebResponseContent RefluxCall(SaveModel saveModel)
|
{
|
WebResponseContent content = new WebResponseContent();
|
VOLContext Context = new VOLContext();
|
Ibase_pda_locationRepository pdaloctionRepository = new base_pda_locationRepository(Context);
|
Idt_containerRepository containerRepository = new dt_containerRepository(Context);
|
IVV_ContainerInfoRepository VV_ContainerInfoRepository = new VV_ContainerInfoRepository(Context);
|
Idt_materielinfoRepository materielinfoRepository = new dt_materielinfoRepository(Context);
|
Idt_agvtaskRepository agvRepository = new dt_agvtaskRepository(Context);
|
Ibase_routing_tableRepository routingRepository = new base_routing_tableRepository(Context);
|
Ibase_ware_locationRepository ibase_Ware_Location = new base_ware_locationRepository(Context);
|
try
|
{
|
//Console.WriteLine(AppContext.BaseDirectory);
|
var hcgnmmjsondata = File.ReadAllText(AppContext.BaseDirectory + "/Database/HcgNumdata.json", Encoding.UTF8);
|
// var hcgnmmjsondata = File.ReadAllText(Directory.GetCurrentDirectory() + @"/Database/HcgNumdata.json");
|
List<HCGNumeData> HCGNUM = JsonConvert.DeserializeObject<List<HCGNumeData>>(hcgnmmjsondata);
|
string csn = saveModel.MainData["csn"].ToString();
|
HCGNumeData NUMJSON = HCGNUM.Where(d => d.num == csn).FirstOrDefault();
|
if (NUMJSON == null)
|
{
|
return content.Error($"缓存柜编号中不存在:{csn},无法回流,请检查");
|
}
|
|
VV_ContainerInfo containerInfo = VV_ContainerInfoRepository.FindFirst(d => d.L_Code == csn);
|
if (containerInfo != null)
|
{
|
return content.Error($"当前缓存柜:{csn},存在库存,请检查");
|
|
}
|
base_pda_location pda_Location = pdaloctionRepository.FindFirst(d => d.L_Code == saveModel.MainData["cnum"].ToString());
|
if (pda_Location != null)
|
{
|
string QJHCG = "1F-QJHCG";
|
string RKFCHCG = "1F-RKFCHCG";
|
if (pda_Location.L_Type == QJHCG || pda_Location.L_Type == RKFCHCG)
|
//if (pda_Location.L_Type == "1F-GMHCG1" || pda_Location.L_Type == "1F-QJHCG2" || pda_Location.L_Type == "1F-GMHCG3")
|
{
|
if (pda_Location.L_state == LoctionStateEnum.LocationState_Stored.ToString())
|
{
|
if (pda_Location.L_Task == 2)
|
{
|
dt_agvtask agvtaskfind = agvRepository.FindFirst(d => d.agv_fromaddress == saveModel.MainData["cnum"].ToString() || d.agv_toaddress == saveModel.MainData["cnum"].ToString());
|
if (agvtaskfind != null)
|
{
|
return content.Error($"当前货位地标:{pda_Location.L_Code},已存在任务,请检查");
|
}
|
base_pda_location pda_Location2 = pdaloctionRepository.FindFirst(d => d.L_state == LoctionStateEnum.LocationState_Empty.ToString() && d.L_Type == "2F-FLKHCG" && d.L_Status == 1 && d.L_Task == 2);
|
if (pda_Location2 == null)
|
{
|
return content.Error($"二楼库房空柜区没有空位了,无法回流,请检查");
|
}
|
//生成空箱回流任务
|
dt_agvtask agvtask = new dt_agvtask()
|
{
|
agv_id = Guid.NewGuid(),
|
agv_tasknum = "KH-" + IdenxManager.GetTaskNo(),
|
agv_fromaddress = pda_Location.L_Code,//以设备未起点
|
agv_toaddress = pda_Location2.L_Code,
|
agv_code = "组装AGV调度",
|
agv_remark = "PDA回流任务",
|
agv_taskstate = AGVTaskStateEnum.Create.ToString(),
|
agv_tasktype = AGVTaskTypeEnum.TaskType_Outbound.ToString(),
|
agv_worktype = 1,//工作类型
|
agv_materielid = "",
|
agv_qty = 1,
|
agv_createtime = DateTime.Now,
|
agv_grade = 0,//任务优先级
|
agv_userid = "WCS",
|
agv_barcode = csn,
|
};
|
agvRepository.Add(agvtask, true);
|
|
pda_Location2.L_Task = 1;
|
ibase_Ware_Location.Update(pda_Location2, true);
|
pda_Location.L_Task = 1;
|
ibase_Ware_Location.Update(pda_Location, true);
|
return content.OK($"回流成功");
|
}
|
else
|
{
|
return content.Error($"当前货位地标:{pda_Location.L_Code},货位存在任务:{pda_Location.L_Task},无法叫料,请检查");
|
}
|
|
}
|
else
|
{
|
return content.Error($"当前货位地标:{pda_Location.L_Code},货位状态不是有货位,无法回流,请检查");
|
}
|
}
|
else
|
{
|
//扫描的货位地标编号异常,不是二楼辅材的货位地标,无法入库
|
return content.Error($"当前货位地标:{pda_Location.L_Code},不是切卷机缓存柜货位,无法回流");
|
}
|
}
|
else
|
{
|
return content.Error($"系统未找到pda扫码的货位地标:{saveModel.MainData["cnum"]},请检查");
|
}
|
|
|
return content;
|
}
|
catch (Exception ex)
|
{
|
|
return content.Error(ex.Message);
|
}
|
}
|
|
/// <summary>
|
/// 产线叫料
|
/// </summary>
|
/// <param name="saveModel"></param>
|
/// <returns></returns>
|
public static WebResponseContent ProductCall(SaveModel saveModel)
|
{
|
WebResponseContent content = new WebResponseContent();
|
VOLContext Context = new VOLContext();
|
Ibase_pda_locationRepository pdaloctionRepository = new base_pda_locationRepository(Context);
|
Idt_containerRepository containerRepository = new dt_containerRepository(Context);
|
IVV_ContainerInfoRepository VV_ContainerInfoRepository = new VV_ContainerInfoRepository(Context);
|
Idt_materielinfoRepository materielinfoRepository = new dt_materielinfoRepository(Context);
|
Idt_agvtaskRepository agvRepository = new dt_agvtaskRepository(Context);
|
Ibase_ware_locationRepository ibase_Ware_Location = new base_ware_locationRepository(Context);
|
try
|
{
|
//产线边是否有缓存柜
|
VV_ContainerInfo containerInfo = VV_ContainerInfoRepository.FindFirst(d => d.L_Code == saveModel.MainData["cnum"].ToString());
|
if (containerInfo != null)
|
{
|
return content.Error($"当前货位地标:{containerInfo.L_Code},已被缓存柜:{containerInfo.container_sn} 占用,请检查");
|
}
|
|
base_pda_location pda_Location = pdaloctionRepository.FindFirst(d => d.L_Code == saveModel.MainData["cnum"].ToString());
|
if (pda_Location != null)
|
{
|
string QJHCG = "1F-QJHCG";
|
string RKFCHCG = "1F-RKFCHCG";
|
if (pda_Location.L_Type == QJHCG || pda_Location.L_Type == RKFCHCG)
|
{
|
|
if (pda_Location.L_state == LoctionStateEnum.LocationState_Empty.ToString())
|
{
|
if (pda_Location.L_Task == 2)
|
{
|
dt_materielinfo materielinfo = materielinfoRepository.FindFirst(d => d.materiel_id == saveModel.MainData["ctype"].ToString());
|
|
if (materielinfo != null)
|
{
|
VV_ContainerInfo containerInfo2 = VV_ContainerInfoRepository.FindFirst(d => d.materiel_id == saveModel.MainData["ctype"].ToString() && d.L_Type == saveModel.MainData["ckf"].ToString() && d.L_Task == 2 && d.L_state == LoctionStateEnum.LocationState_Stored.ToString() && d.L_Status == 1);
|
|
if (containerInfo2 == null)
|
{
|
return content.Error($"您当前选择的库房没有库存了");
|
}
|
|
//生成产线叫料任务
|
dt_agvtask agvtask = new dt_agvtask()
|
{
|
agv_id = Guid.NewGuid(),
|
agv_tasknum = "KH-" + IdenxManager.GetTaskNo(),
|
agv_fromaddress = containerInfo2.L_Code,//以设备未起点
|
agv_toaddress = pda_Location.L_Code,
|
agv_code = "组装AGV调度",
|
agv_remark = "PDA产线叫料任务",
|
agv_taskstate = AGVTaskStateEnum.Create.ToString(),
|
agv_tasktype = AGVTaskTypeEnum.TaskType_Outbound.ToString(),
|
agv_worktype = 1,//工作类型
|
agv_materielid = materielinfo.materiel_id,
|
agv_qty = 1,
|
agv_createtime = DateTime.Now,
|
agv_grade = 0,//任务优先级
|
agv_userid = "WCS",
|
agv_barcode = containerInfo2.container_sn,
|
};
|
|
agvRepository.Add(agvtask, true);
|
base_pda_location pda_LocationTo = pdaloctionRepository.FindFirst(d => d.L_Code == containerInfo2.L_Code);
|
if (pda_LocationTo == null)
|
{
|
|
throw new NotImplementedException();
|
}
|
pda_LocationTo.L_Task = 1;
|
ibase_Ware_Location.Update(pda_LocationTo, true);
|
pda_Location.L_Task = 1;
|
ibase_Ware_Location.Update(pda_Location, true);
|
return content.OK($"叫料成功");
|
}
|
else {
|
return content.Error($"当前pda输入的物料类型:{saveModel.MainData["ctype"].ToString()},WCS后台物料管理中不存在,请检查");
|
}
|
}
|
else
|
{
|
return content.Error($"当前货位地标:{pda_Location.L_Code},货位存在任务:{pda_Location.L_Task},无法叫料,请检查");
|
}
|
|
}
|
else
|
{
|
return content.Error($"当前货位地标:{pda_Location.L_Code},货位状态不是空货位,无法入库,请检查");
|
}
|
|
}
|
else
|
{
|
//扫描的货位地标编号异常,不是二楼辅材的货位地标,无法入库
|
return content.Error($"当前货位地标:{pda_Location.L_Code},不是产线叫料地标区货位,无法产线叫料");
|
}
|
}
|
else
|
{
|
return content.Error($"系统未找到pda扫码的货位地标:{saveModel.MainData["cnum"]},请检查");
|
}
|
|
|
|
}
|
catch (Exception ex)
|
{
|
|
return content.Error(ex.Message);
|
}
|
}
|
|
/// <summary>
|
/// 库房叫料
|
/// </summary>
|
/// <param name="saveModel"></param>
|
/// <returns></returns>
|
public static WebResponseContent StoreroomCall(SaveModel saveModel)
|
{
|
WebResponseContent content = new WebResponseContent();
|
VOLContext Context = new VOLContext();
|
Ibase_pda_locationRepository pdaloctionRepository = new base_pda_locationRepository(Context);
|
Idt_containerRepository containerRepository = new dt_containerRepository(Context);
|
IVV_ContainerInfoRepository VV_ContainerInfoRepository = new VV_ContainerInfoRepository(Context);
|
Idt_materielinfoRepository materielinfoRepository = new dt_materielinfoRepository(Context);
|
Idt_agvtaskRepository agvRepository = new dt_agvtaskRepository(Context);
|
|
try
|
{
|
string cnum = saveModel.MainData["cnum"].ToString();//货物二维码(货位编号)
|
VV_ContainerInfo containerInfo = VV_ContainerInfoRepository.FindFirst(d => d.L_Code == saveModel.MainData["cnum"].ToString());
|
if (containerInfo != null)
|
{
|
return content.Error($"当前货位地标:{containerInfo.L_Code},已被缓存柜:{containerInfo.container_sn} 占用,请检查");
|
|
}
|
|
|
base_pda_location pda_Location = pdaloctionRepository.FindFirst(d => d.L_Code == saveModel.MainData["cnum"].ToString());
|
if (pda_Location != null)
|
{
|
if (pda_Location.L_Type == "1F-GMHCG1" || pda_Location.L_Type == "1F-GMHCG2" || pda_Location.L_Type == "1F-GMHCG3")
|
{
|
if (pda_Location.L_state == LoctionStateEnum.LocationState_Empty.ToString())
|
{
|
if (pda_Location.L_Task == 2)
|
{
|
dt_agvtask agvtaskfind = agvRepository.FindFirst(d => d.agv_fromaddress == saveModel.MainData["cnum"].ToString() || d.agv_toaddress == saveModel.MainData["cnum"].ToString());
|
if (agvtaskfind != null)
|
{
|
return content.Error($"当前货位地标:{containerInfo.L_Code},已存在任务,请检查");
|
}
|
dt_materielinfo materielinfo = materielinfoRepository.FindFirst(d => d.materiel_id == saveModel.MainData["ctype"].ToString());
|
if (materielinfo != null)
|
{
|
VV_ContainerInfo containerInfo2 = VV_ContainerInfoRepository.FindFirst(d => d.materiel_id == saveModel.MainData["ctype"].ToString() && d.L_Type == "2F-FLHCG" && d.L_Task == 2 && d.L_state == LoctionStateEnum.LocationState_Stored.ToString() && d.L_Status == 1);
|
if (containerInfo2 == null)
|
{
|
return content.Error($"二楼库房没有库存了");
|
}
|
|
//生成库房叫料任务
|
dt_agvtask agvtask = new dt_agvtask()
|
{
|
agv_id = Guid.NewGuid(),
|
agv_tasknum = "KH-" + IdenxManager.GetTaskNo(),
|
agv_fromaddress = containerInfo2.L_Code,//以设备未起点
|
agv_toaddress = pda_Location.L_Code,
|
agv_code = "组装AGV调度",
|
agv_remark = "PDA库房叫料任务",
|
agv_taskstate = AGVTaskStateEnum.Create.ToString(),
|
agv_tasktype = AGVTaskTypeEnum.TaskType_Outbound.ToString(),
|
agv_worktype = 1,//工作类型
|
agv_materielid = materielinfo.materiel_id,
|
agv_qty = 1,
|
agv_createtime = DateTime.Now,
|
agv_grade = 0,//任务优先级
|
agv_userid = "WCS",
|
agv_barcode = containerInfo2.container_sn,
|
};
|
agvRepository.Add(agvtask, true);
|
base_pda_location pda_LocationTo = pdaloctionRepository.FindFirst(d => d.L_Code == containerInfo2.L_Code);
|
if (pda_LocationTo == null)
|
{
|
throw new NotImplementedException();
|
}
|
pda_LocationTo.L_Task = 1;
|
pdaloctionRepository.Update(pda_LocationTo, true);
|
pda_Location.L_Task = 1;
|
pdaloctionRepository.Update(pda_Location, true);
|
return content.OK($"叫料完成");
|
}
|
else
|
{
|
return content.Error($"当前pda输入的物料类型:{saveModel.MainData["ctype"].ToString()},WCS后台物料管理中不存在,请检查");
|
}
|
}
|
else
|
{
|
return content.Error($"当前货位地标:{pda_Location.L_Code},货位存在任务:{pda_Location.L_Task},无法叫料,请检查");
|
}
|
|
}
|
else
|
{
|
return content.Error($"当前货位地标:{pda_Location.L_Code},货位状态不是空货位,无法入库,请检查");
|
}
|
|
}
|
else
|
{
|
//扫描的货位地标编号异常,不是二楼辅材的货位地标,无法入库
|
return content.Error($"当前货位地标:{pda_Location.L_Code},不是二楼辅材库货位,无法入库");
|
}
|
}
|
else
|
{
|
return content.Error($"系统未找到pda扫码的货位地标:{saveModel.MainData["cnum"]},请检查");
|
}
|
return content;
|
}
|
catch (Exception ex)
|
{
|
|
return content.Error(ex.Message);
|
}
|
}
|
|
|
/// <summary>
|
/// 库存解绑
|
/// </summary>
|
/// <param name="saveModel"></param>
|
/// <returns></returns>
|
public static WebResponseContent ReleaseStock(SaveModel saveModel)
|
{
|
WebResponseContent content = new WebResponseContent();
|
VOLContext Context = new VOLContext();
|
Ibase_pda_locationRepository pdaloctionRepository = new base_pda_locationRepository(Context);
|
Idt_containerRepository containerRepository = new dt_containerRepository(Context);
|
IVV_ContainerInfoRepository VV_ContainerInfoRepository = new VV_ContainerInfoRepository(Context);
|
Idt_materielinfoRepository materielinfoRepository = new dt_materielinfoRepository(Context);
|
Idt_agvtaskRepository agvRepository = new dt_agvtaskRepository(Context);
|
try
|
{
|
//var hcgnmmjsondata = File.ReadAllText(Directory.GetCurrentDirectory() + @"/Database/HcgNumdata.json");
|
Console.WriteLine(AppContext.BaseDirectory);
|
string hcgnmmjsondata = File.ReadAllText(AppContext.BaseDirectory + "/Database/HcgNumdata.json", Encoding.UTF8);
|
|
List<HCGNumeData> HCGNUM = JsonConvert.DeserializeObject<List<HCGNumeData>>(hcgnmmjsondata);
|
|
string csn = saveModel.MainData["barcode"].ToString();
|
|
HCGNumeData NUMJSON = HCGNUM.Where(d => d.num == csn).FirstOrDefault();
|
|
if (NUMJSON == null)
|
{
|
return content.Error($"缓存柜编号中不存在:{csn},无法解绑,请检查");
|
}
|
VV_ContainerInfo containerInfo = VV_ContainerInfoRepository.FindFirst(d => d.container_sn == saveModel.MainData["barcode"].ToString());
|
|
if (containerInfo == null)
|
{
|
return content.Error($"未找到缓存柜条码【{saveModel.MainData["barcode"].ToString()}】的库存,请检查");
|
}
|
dt_container dt_Container = containerRepository.FindFirst(d => d.container_id == Guid.Parse(containerInfo.container_id.ToString()));
|
|
if (dt_Container == null)
|
{
|
return content.Error($"库存查询异常");
|
}
|
base_pda_location pda_Location = pdaloctionRepository.FindFirst(d => d.L_Code == containerInfo.container_barcode);
|
if (pda_Location == null)
|
{
|
return content.Error($"当前库存的货位地标【{containerInfo.container_barcode}】 在PDA货位列表中不存在,数据异常,请检查");
|
}
|
if (pda_Location.L_Task == 1)
|
{
|
return content.Error($"当前库存存在AGV任务,无法解绑,请检查");
|
}
|
if (pda_Location.L_Type.Contains("2F-FL") )
|
{
|
pda_Location.L_state = LoctionStateEnum.LocationState_Empty.ToString();
|
int a = pdaloctionRepository.Update(pda_Location,d=>new { d.L_state }, true);
|
if (a != 1)
|
{
|
return content.Error($"库存货位初始化失败");
|
}
|
containerRepository.Delete(dt_Container, true);
|
}
|
else
|
{
|
//pda_Location.L_state = LoctionStateEnum.LocationState_Stored.ToString();
|
//int a = pdaloctionRepository.Update(pda_Location, true);
|
//if (a != 1)
|
//{
|
return content.Error($"当前货位地标【{pda_Location.L_Code}】不是2F的货位,无法解绑,请检查");
|
//}
|
}
|
|
|
|
return content.OK($"缓存柜【{saveModel.MainData["barcode"]}】解绑成功");
|
}
|
catch (Exception ex)
|
{
|
|
return content.Error(ex.Message);
|
}
|
}
|
|
/// <summary>
|
/// 物料档位设置
|
/// </summary>
|
/// <param name="saveModel"></param>
|
/// <returns></returns>
|
public static WebResponseContent Gearsetting(SaveModel saveModel)
|
{
|
WebResponseContent content = new WebResponseContent();
|
VOLContext Context = new VOLContext();
|
Idt_agvtaskRepository agvRepository = new dt_agvtaskRepository(Context);
|
Ibase_ware_locationRepository locationRepository = new base_ware_locationRepository(Context);
|
try
|
{
|
base_ware_location location = locationRepository.FindFirst(d => d.upper_code == saveModel.MainData["locde"].ToString());
|
if (location == null)
|
{
|
return content.Error($"未找到【{saveModel.MainData["locde"].ToString()}】的货位,请检查");
|
}
|
dt_agvtask agvtask = agvRepository.FindFirst(d => d.agv_fromaddress == location.upper_code || d.agv_toaddress == location.upper_code);
|
if (agvtask != null)
|
{
|
return content.Error($"【{saveModel.MainData["locde"].ToString()}】的货位,有任务存在,无法操作此功能进行设置,请检查");
|
}
|
|
if (string.IsNullOrEmpty(saveModel.MainData["gtype"].ToString()))
|
{
|
return content.Error($"客户端传入物料档位数据错误,传入值:【{saveModel.MainData["gtype"].ToString()}】,请检查");
|
}
|
if (location.geartype == saveModel.MainData["gtype"].ToString())
|
{
|
return content.Error($"货架:【{location.upper_code}】已是 {location.geartype}类,无需设置");
|
}
|
location.geartype = saveModel.MainData["gtype"].ToString();
|
int up = locationRepository.Update(location, d => d.geartype, true);
|
if (up == 1)
|
{
|
return content.OK($"设置成功");
|
}
|
else
|
{
|
return content.Error($"设置失败,修改异常【{up}】");
|
}
|
}
|
catch (Exception ex)
|
{
|
|
return content.Error($"{ex.Message}");
|
}
|
}
|
|
/// <summary>
|
/// pda货位编辑
|
/// </summary>
|
/// <param name="saveModel"></param>
|
/// <returns></returns>
|
public static WebResponseContent LoctionUpdate(SaveModel saveModel)
|
{
|
WebResponseContent content = new WebResponseContent();
|
VOLContext Context = new VOLContext();
|
Idt_agvtaskRepository agvRepository = new dt_agvtaskRepository(Context);
|
Ibase_pda_locationRepository pdaloctionRepository = new base_pda_locationRepository(Context);
|
Idt_containerRepository containerRepository = new dt_containerRepository(Context);
|
IVV_ContainerInfoRepository VV_ContainerInfoRepository = new VV_ContainerInfoRepository(Context);
|
Idt_materielinfoRepository materielinfoRepository = new dt_materielinfoRepository(Context);
|
try
|
{
|
dt_agvtask agvtask= agvRepository.FindFirst(d=>d.agv_toaddress== saveModel.MainData["barcode"].ToString());
|
if (agvtask!=null)
|
{
|
return content.Error($"当前货位:【{saveModel.MainData["barcode"].ToString()}】,存在AGV任务列表中,任务编号:【{agvtask.agv_tasknum}】,无法编辑,请检查");
|
}
|
VV_ContainerInfo containerInfo = VV_ContainerInfoRepository.FindFirst(d => d.L_Code == saveModel.MainData["barcode"].ToString());
|
if (containerInfo != null)
|
{
|
return content.Error($"当前货位有【{saveModel.MainData["barcode"].ToString()}】的库存,无法解绑为空货位,请检查");
|
}
|
base_pda_location pda_Location= pdaloctionRepository.FindFirst(d => d.L_Code == saveModel.MainData["barcode"].ToString());
|
if (pda_Location==null)
|
{
|
return content.Error($"当前PDA货位列表中不存在【{saveModel.MainData["barcode"].ToString()}】货位,请检查");
|
}
|
pda_Location.L_state = LoctionStateEnum.LocationState_Empty.ToString();
|
pda_Location.L_Task = 2;
|
int x= pdaloctionRepository.Update(pda_Location,true);
|
if (x!=1)
|
{
|
return content.Error($"解绑空货位失败,反馈值:{x},请检查");
|
}
|
else
|
{
|
return content.OK($"解绑空货位成功");
|
}
|
}
|
catch (Exception ex)
|
{
|
|
return content.Error($"解绑空货位失败,异常内容:{ex.Message}");
|
}
|
}
|
private static int _lock = 0;
|
/// <summary>
|
/// PDA货位一键解绑
|
/// </summary>
|
/// <param name="saveModel"></param>
|
/// <returns></returns>
|
public static WebResponseContent LoctionOneclickUpdate(SaveModel saveModel)
|
{
|
|
WebResponseContent content = new WebResponseContent();
|
VOLContext Context = new VOLContext();
|
Idt_agvtaskRepository agvRepository = new dt_agvtaskRepository(Context);
|
Ibase_pda_locationRepository pdaloctionRepository = new base_pda_locationRepository(Context);
|
try
|
{
|
List<base_pda_location> pda_Location = pdaloctionRepository.Find(d => d.L_region == saveModel.MainData["region"].ToString());
|
if (pda_Location.Count < 0)
|
{
|
return content.Error($"当前PDA货位列表中不存在【{saveModel.MainData["region"].ToString()}】区货位,请检查");
|
}
|
foreach (var item in pda_Location)
|
{
|
dt_agvtask agvtask1 = agvRepository.FindFirst(d => d.agv_toaddress == item.L_Code);
|
if (agvtask1 != null)
|
{
|
return content.Error($"当前【{saveModel.MainData["region"].ToString()}】区货位有【{item.L_Code}】存在任务,无法一键解绑,请检查");
|
}
|
}
|
pdaloctionRepository.DbContextBeginTransaction(() =>
|
{
|
foreach (var item in pda_Location)
|
{
|
base_pda_location Location = pdaloctionRepository.FindFirst(d => d.L_Code == item.L_Code);
|
if (Location == null)
|
{
|
return content.Error($"当前PDA货位列表中不存在【{saveModel.MainData["barcode"].ToString()}】货位,请检查");
|
}
|
Location.L_state = LoctionStateEnum.LocationState_Empty.ToString();
|
|
Location.L_Task = 2;
|
int x = pdaloctionRepository.Update(Location, true);
|
if (x != 1)
|
{
|
return content.Error($"货位编辑失败,反馈值:{x},请检查");
|
}
|
else
|
{
|
content.OK($"一键成功");
|
}
|
}
|
return content;
|
});
|
return content;
|
}
|
catch (Exception ex)
|
{
|
|
return content.Error($"编辑失败,异常内容:{ex.Message}");
|
}
|
|
|
|
|
}
|
|
|
|
public class HCGNumeData
|
{
|
public string num { get; set; }
|
|
}
|
}
|
}
|