删除有问题的TCP旧代码, 优化事务处理和ERP数据模型
| | |
| | | using System.Web.Http; |
| | | using Microsoft.Owin; |
| | | using Newtonsoft.Json; |
| | | |
| | | using Owin; |
| | | using Swashbuckle.Application; |
| | | |
| | |
| | | /// <summary> |
| | | /// Swagger 显示控制器的描述 |
| | | /// </summary> |
| | | public class SwaggerCacheProvider : ISwaggerProvider |
| | | { |
| | | public class SwaggerCacheProvider : ISwaggerProvider { |
| | | private readonly ISwaggerProvider _swaggerProvider; |
| | | private static ConcurrentDictionary<string, SwaggerDocument> _cache = new ConcurrentDictionary<string, SwaggerDocument>(); |
| | | private readonly string _xmlPath; |
| | |
| | | /// <summary></summary> |
| | | /// <param name="swaggerProvider"></param> |
| | | /// <param name="xmlpath">xml文档路径</param> |
| | | public SwaggerCacheProvider(ISwaggerProvider swaggerProvider, string xmlpath) |
| | | { |
| | | public SwaggerCacheProvider(ISwaggerProvider swaggerProvider, string xmlpath) { |
| | | _swaggerProvider = swaggerProvider; |
| | | _xmlPath = xmlpath; |
| | | } |
| | | |
| | | public SwaggerDocument GetSwagger(string rootUrl, string apiVersion) |
| | | { |
| | | public SwaggerDocument GetSwagger(string rootUrl, string apiVersion) { |
| | | var cacheKey = string.Format("{0}_{1}", rootUrl, apiVersion); |
| | | // 只读取一次 |
| | | if (!_cache.TryGetValue(cacheKey, out SwaggerDocument srcDoc)) |
| | | { |
| | | if (!_cache.TryGetValue(cacheKey, out SwaggerDocument srcDoc)) { |
| | | srcDoc = _swaggerProvider.GetSwagger(rootUrl, apiVersion); |
| | | |
| | | srcDoc.vendorExtensions = new Dictionary<string, object> { |
| | |
| | | /// 从API文档中读取控制器描述 |
| | | /// </summary> |
| | | /// <returns>所有控制器描述</returns> |
| | | public ConcurrentDictionary<string, string> GetControllerDesc() |
| | | { |
| | | public ConcurrentDictionary<string, string> GetControllerDesc() { |
| | | ConcurrentDictionary<string, string> controllerDescDict = new ConcurrentDictionary<string, string>(); |
| | | if (File.Exists(_xmlPath)) |
| | | { |
| | | if (File.Exists(_xmlPath)) { |
| | | XmlDocument xmldoc = new XmlDocument(); |
| | | xmldoc.Load(_xmlPath); |
| | | |
| | | string[] arrPath; |
| | | int cCount = "Controller".Length; |
| | | foreach (XmlNode node in xmldoc.SelectNodes("//member")) |
| | | { |
| | | foreach (XmlNode node in xmldoc.SelectNodes("//member")) { |
| | | string type = node.Attributes["name"].Value; |
| | | if (type.StartsWith("T:")) |
| | | { |
| | | if (type.StartsWith("T:")) { |
| | | arrPath = type.Split('.'); |
| | | string controllerName = arrPath[arrPath.Length - 1]; |
| | | if (controllerName.EndsWith("Controller")) // 控制器 |
| | |
| | | // 获取控制器注释 |
| | | XmlNode summaryNode = node.SelectSingleNode("summary"); |
| | | string key = controllerName.Remove(controllerName.Length - cCount, cCount); |
| | | if (summaryNode != null && !string.IsNullOrEmpty(summaryNode.InnerText) && !controllerDescDict.ContainsKey(key)) |
| | | { |
| | | if (summaryNode != null && !string.IsNullOrEmpty(summaryNode.InnerText) && !controllerDescDict.ContainsKey(key)) { |
| | | controllerDescDict.TryAdd(key, summaryNode.InnerText.Trim()); |
| | | } |
| | | } |
| | |
| | | <Compile Include="api\ApiModel.cs" /> |
| | | <Compile Include="api\DebugController.cs" /> |
| | | <Compile Include="api\ErpController.cs" /> |
| | | <Compile Include="api\ErpModel.CreateTaskReturnErpInfo.cs" /> |
| | | <Compile Include="api\ErpModel.ErpSendOutboundPlanInfo.cs" /> |
| | | <Compile Include="api\ErpModel.PickUpReturnErpInfo.cs" /> |
| | | <Compile Include="api\ForceController.cs" /> |
| | | <Compile Include="api\MesController.cs" /> |
| | | <Compile Include="api\MoboxController.cs" /> |
| | |
| | | <Compile Include="device\ProductionLineDevice.cs" /> |
| | | <Compile Include="device\ModbusHelper.cs" /> |
| | | <Compile Include="device\OpcUaHelper.cs" /> |
| | | <Compile Include="device\PlcHelper.cs" /> |
| | | <Compile Include="device\S7Helper.cs" /> |
| | | <Compile Include="device\TcpClient.cs" /> |
| | | <Compile Include="device\TcpServer.cs" /> |
| | | <Compile Include="dispatch\GZRobot.cs" /> |
| | | <Compile Include="dispatch\HanAo.cs" /> |
| | | <Compile Include="dispatch\NDC.cs" /> |
| | |
| | | <Compile Include="models\TN_Loc_Container.cs" /> |
| | | <Compile Include="models\TN_Task.cs" /> |
| | | <Compile Include="models\TN_Task_Action.cs" /> |
| | | <Compile Include="process\DeviceProcess.cs" /> |
| | | <Compile Include="api\WMSController.cs" /> |
| | | <Compile Include="dispatch\HostToAGV.cs" /> |
| | | <Compile Include="util\LogHelper.cs" /> |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Security.Cryptography; |
| | | |
| | | using HH.WCS.Mobox3.DSZSH.core; |
| | | using HH.WCS.Mobox3.DSZSH.models; |
| | | using HH.WCS.Mobox3.DSZSH.util; |
| | | using HH.WCS.Mobox3.DSZSH.wms; |
| | | |
| | | using Newtonsoft.Json; |
| | | |
| | | using SqlSugar; |
| | | |
| | | using Swashbuckle.Swagger; |
| | | |
| | | using static HH.WCS.Mobox3.DSZSH.api.ApiModel; |
| | | using static HH.WCS.Mobox3.DSZSH.api.OtherModel; |
| | | |
| | |
| | | var (ok, msg) = (false, string.Empty); |
| | | var obj = new CreateTaskObj(); |
| | | |
| | | var taskInfo = ETask.M满箱下线入库.Info(); |
| | | var tInfo = ETask.M满箱下线入库.Info(); |
| | | const string preLog = "API:满箱下线入库:"; |
| | | const string cntrType = "好运箱"; |
| | | |
| | |
| | | } |
| | | |
| | | // 检查货品容器表:是否已经存在贴标机传递的待入库物料信息 |
| | | // TODO:数量,规格是否也参与比对? |
| | | // QES:数量,规格是否也参与比对? |
| | | var cgDetail = db.Queryable<TN_CG_Detail>() |
| | | .Where(d => d.S_ITEM_CODE == model.ItemCode && d.S_BATCH_NO == model.BatchNo |
| | | && d.N_ITEM_STATE == 1 && d.S_ITEM_STATE == "待检").First(); |
| | |
| | | $"请检查:PDA扫码物料信息与贴标机传递的信息是否一致!!"); |
| | | } |
| | | |
| | | var startLoc = db.Queryable<TN_Location>().Where(DbExpr.StartLocUnbind(model.StartLoc, taskInfo.StartAreas)).First(); |
| | | // 查询起点货位(绑定前) |
| | | var startLoc = db.Queryable<TN_Location>().Where(DbExpr.StartLocUnbind(model.StartLoc, tInfo.StartAreas)).First(); |
| | | if (startLoc == null) { |
| | | return NewSimpleResult(2, preLog + LogMsg.StartLocUnbindNotFound(model.StartLoc, taskInfo.StartAreas)); |
| | | return NewSimpleResult(2, preLog + LogMsg.StartLocUnbindNotFound(model.StartLoc, tInfo.StartAreas)); |
| | | } |
| | | |
| | | // 和满托下线入库的逻辑一致,由于容器移动不会更改绑定信息,所以必须删除旧数据 |
| | | WMSHelper.FindCntrOldInfo(obj, cgDetail.S_CNTR_CODE, skipCgDetail: true); |
| | | WMSHelper.FindOldCntrInfo(obj, cgDetail.S_CNTR_CODE, skipCgDetail: true); |
| | | |
| | | // 绑定货位容器 |
| | | var locCntrRel = WMSHelper.BindLocCntr(obj, startLoc, cgDetail.S_CNTR_CODE, cntrType); |
| | | |
| | | var endLoc = db.Queryable<TN_Location>().Where(DbExpr.EndLoc(areas: taskInfo.EndAreas)) |
| | | // 查询终点货位 |
| | | // Order:优先选择低层货架 |
| | | var endLoc = db.Queryable<TN_Location>().Where(DbExpr.EndLoc(areas: tInfo.EndAreas)) |
| | | .OrderBy(l => new { l.N_LAYER }).First(); |
| | | if (endLoc == null) { |
| | | return NewSimpleResult(3, preLog + LogMsg.EndLocNotFound(areas: taskInfo.EndAreas)); |
| | | return NewSimpleResult(3, preLog + LogMsg.EndLocNotFound(areas: tInfo.EndAreas)); |
| | | } |
| | | |
| | | WMSHelper.CreateTask(obj, startLoc, endLoc, locCntrRel.S_CNTR_CODE, taskInfo.TaskName); |
| | | // 起点终点上锁,创建任务 |
| | | WMSHelper.CreateTask(obj, startLoc, endLoc, locCntrRel.S_CNTR_CODE, tInfo.TaskName); |
| | | (ok, msg) = DbTran.CreateTask(obj); |
| | | return NewSimpleResult(ok ? 0 : 500, preLog + msg); |
| | | } |
| | |
| | | public static SimpleResult EmptyInboundPallet(EmptyInboundInfo model) { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | var (ok, msg) = (false, string.Empty); |
| | | var obj = new CreateTaskObj(); |
| | | |
| | | var taskInfo = ETask.K空托入库.Info(); |
| | | var tInfo = ETask.K空托入库.Info(); |
| | | const string preLog = "API:空托入库:"; |
| | | const string cntrType = "托盘"; |
| | | |
| | | try { |
| | | // 查询起点货位:数量=0 |
| | | var startLoc = db.Queryable<TN_Location>().Where(DbExpr.StartLocUnbind(model.StartLoc, taskInfo.StartAreas)).First(); |
| | | if (startLoc == null) { |
| | | return NewSimpleResult(2, preLog + LogMsg.StartLocUnbindNotFound(model.StartLoc, taskInfo.StartAreas)); |
| | | } |
| | | |
| | | // 查询容器表:容器类型字段 |
| | | (ok, msg) = WMSHelper.CheckCntrType(model.CntrCode, cntrType, out var cntr); |
| | | if (!ok) { |
| | | return NewSimpleResult(3, preLog + msg); |
| | | return NewSimpleResult(1, preLog + msg); |
| | | } |
| | | |
| | | |
| | | // 查询起点货位(绑定前) |
| | | var startLoc = db.Queryable<TN_Location>().Where(DbExpr.StartLocUnbind(model.StartLoc, tInfo.StartAreas)).First(); |
| | | if (startLoc == null) { |
| | | return NewSimpleResult(2, preLog + LogMsg.StartLocUnbindNotFound(model.StartLoc, tInfo.StartAreas)); |
| | | } |
| | | |
| | | // 空箱入库时,如果存在旧的绑定数据,删除 |
| | | var old = WCSHelper.GetLocCntrCg(model.CntrCode); |
| | | WMSHelper.FindOldCntrInfo(obj, model.CntrCode); |
| | | |
| | | // 绑定货位容器 |
| | | var locCntrRel = WCSHelper.BindLocCntr(startLoc, cntr.S_CODE); |
| | | locCntrRel.S_CNTR_TYPE = cntrType; |
| | | var locCntrRel = WMSHelper.BindLocCntr(obj, startLoc, cntr.S_CODE, cntrType); |
| | | |
| | | // 查询终点货位 |
| | | // Order:层数从低到高,行,列 |
| | | var endLoc = db.Queryable<TN_Location>().Where(DbExpr.EndLoc(areas: taskInfo.EndAreas)) |
| | | var endLoc = db.Queryable<TN_Location>().Where(DbExpr.EndLoc(areas: tInfo.EndAreas)) |
| | | .OrderBy(l => new { l.N_LAYER, l.N_ROW, l.N_COL }).First(); |
| | | if (endLoc == null) { |
| | | return NewSimpleResult(3, preLog + LogMsg.EndLocNotFound(areas: taskInfo.EndAreas)); |
| | | return NewSimpleResult(3, preLog + LogMsg.EndLocNotFound(areas: tInfo.EndAreas)); |
| | | } |
| | | |
| | | // 起点终点上锁,创建任务 |
| | | var task = WCSHelper.BuildTaskWithLocLock(startLoc, endLoc, locCntrRel.S_CNTR_CODE, taskInfo.TaskName); |
| | | |
| | | (ok, msg) = DbTran.CreateTask(new CreateTaskObj { |
| | | Old = old, |
| | | New = new LocCntrCg { LocCntrRel = locCntrRel }, |
| | | StartLocToUpdate = startLoc, |
| | | EndLocToUpdate = endLoc, |
| | | TaskToInsert = task, |
| | | }); |
| | | WMSHelper.CreateTask(obj, startLoc, endLoc, locCntrRel.S_CNTR_CODE, tInfo.TaskName); |
| | | (ok, msg) = DbTran.CreateTask(obj); |
| | | return NewSimpleResult(ok ? 0 : 500, preLog + msg); |
| | | } |
| | | catch (Exception ex) { |
| | |
| | | public static SimpleResult EmptyInboundGoodpack(EmptyInboundInfo model) { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | var (ok, msg) = (false, string.Empty); |
| | | var obj = new CreateTaskObj(); |
| | | |
| | | var taskInfo = ETask.K空箱入库.Info(); |
| | | var tInfo = ETask.K空箱入库.Info(); |
| | | const string preLog = "API:空箱入库:"; |
| | | const string cntrType = "好运箱"; |
| | | |
| | | try { |
| | | var startLoc = db.Queryable<TN_Location>().Where(DbExpr.StartLocUnbind(model.StartLoc, taskInfo.StartAreas)).First(); |
| | | // 查询起点货位(绑定前) |
| | | var startLoc = db.Queryable<TN_Location>().Where(DbExpr.StartLocUnbind(model.StartLoc, tInfo.StartAreas)).First(); |
| | | if (startLoc == null) { |
| | | return NewSimpleResult(2, preLog + LogMsg.StartLocUnbindNotFound(model.StartLoc, taskInfo.StartAreas)); |
| | | return NewSimpleResult(1, preLog + LogMsg.StartLocUnbindNotFound(model.StartLoc, tInfo.StartAreas)); |
| | | } |
| | | |
| | | // 查询容器表:容器类型字段 |
| | | (ok, msg) = WMSHelper.CheckCntrType(model.CntrCode, cntrType, out var cntr); |
| | | if (!ok) { |
| | | return NewSimpleResult(3, preLog + msg); |
| | | return NewSimpleResult(2, preLog + msg); |
| | | } |
| | | |
| | | // 空箱入库时,如果存在旧的绑定数据,删除 |
| | | var old = WCSHelper.GetLocCntrCg(model.CntrCode); |
| | | WMSHelper.FindOldCntrInfo(obj, model.CntrCode); |
| | | |
| | | var locCntrRel = WCSHelper.BindLocCntr(startLoc, model.CntrCode); |
| | | locCntrRel.S_CNTR_TYPE = cntrType; |
| | | var locCntrRel = WMSHelper.BindLocCntr(obj, startLoc, model.CntrCode, cntrType); |
| | | |
| | | var endLoc = db.Queryable<TN_Location>().Where(DbExpr.EndLoc(areas: taskInfo.EndAreas)) |
| | | var endLoc = db.Queryable<TN_Location>().Where(DbExpr.EndLoc(areas: tInfo.EndAreas)) |
| | | .OrderBy(l => new { l.N_LAYER, l.N_ROW, l.N_COL }).First(); |
| | | if (endLoc == null) { |
| | | return NewSimpleResult(3, preLog + LogMsg.EndLocNotFound(areas: taskInfo.EndAreas)); |
| | | return NewSimpleResult(3, preLog + LogMsg.EndLocNotFound(areas: tInfo.EndAreas)); |
| | | } |
| | | |
| | | var task = WCSHelper.BuildTaskWithLocLock(startLoc, endLoc, locCntrRel.S_CNTR_CODE, taskInfo.TaskName); |
| | | |
| | | (ok, msg) = DbTran.CreateTask(new CreateTaskObj { |
| | | Old = old, |
| | | New = new LocCntrCg { LocCntrRel = locCntrRel }, |
| | | StartLocToUpdate = startLoc, |
| | | EndLocToUpdate = endLoc, |
| | | TaskToInsert = task, |
| | | }); |
| | | // 起点终点上锁,创建任务 |
| | | WMSHelper.CreateTask(obj, startLoc, endLoc, locCntrRel.S_CNTR_CODE, tInfo.TaskName); |
| | | (ok, msg) = DbTran.CreateTask(obj); |
| | | return NewSimpleResult(ok ? 0 : 500, preLog + msg); |
| | | } |
| | | catch (Exception ex) { |
| | |
| | | public static SimpleResult EmptyOnlinePallet(EmptyOnlinePalletInfo model) { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | var (ok, msg) = (false, string.Empty); |
| | | var obj = new CreateTaskObj(); |
| | | |
| | | var taskInfo = ETask.K空托上线出库.Info(); |
| | | var tInfo = ETask.K空托上线出库.Info(); |
| | | const string preLog = "API:空托上线出库:"; |
| | | const string cntrType = "托盘"; |
| | | |
| | |
| | | return NewSimpleResult(1, preLog + msg); |
| | | } |
| | | |
| | | // 检查容器表:容器规格(物料编码) |
| | | var needUpdateContainer = false; |
| | | if (string.IsNullOrEmpty(cntr.S_SPEC)) { |
| | | // TEMP 目前流程:如果容器表中规格 (物料编码) 为空,根据流程的物料信息写入 |
| | | // 待定:后面可能会更改流程,或者用其他信息 (如物料类型/规格) 作为容器的规格 |
| | | |
| | | // 目前流程:如果容器表中规格 (物料编码) 为空,根据流程的物料信息写入 |
| | | // TEMP:后面可能会更改流程,或者用其他信息 (如物料类型/规格) 作为容器的规格 |
| | | needUpdateContainer = true; |
| | | cntr.S_SPEC = model.ItemCode; |
| | | LogHelper.Info($"容器'{model.CntId}'在[容器表]中[规格(物料编码)]为空,将物料编码'{model.ItemCode}'写入容器的规格"); |
| | |
| | | return NewSimpleResult(3, $"容器'{model.CntId}'已经与物料类型'{cntr.S_SPEC}'绑定,无法用于装载物料'{model.ItemCode}'!"); |
| | | } |
| | | |
| | | // 查询起点货位 |
| | | var startLoc = db.Queryable<TN_Location>().LeftJoin<TN_Loc_Container>((l, c) => l.S_CODE == c.S_LOC_CODE) |
| | | .Where(DbExpr.StartLoc(areas: taskInfo.StartAreas)) |
| | | .Where(DbExpr.StartLoc(areas: tInfo.StartAreas)) |
| | | .Where((l, c) => c.S_CNTR_CODE == model.CntId && c.S_CNTR_TYPE == cntrType).First(); |
| | | if (startLoc == null) { |
| | | return NewSimpleResult(3, preLog + LogMsg.StartLocNotFound(areas: taskInfo.StartAreas) + |
| | | return NewSimpleResult(3, preLog + LogMsg.StartLocNotFound(areas: tInfo.StartAreas) + |
| | | $"绑定容器编码='{model.CntId}';绑定容器类型='{cntrType}';"); |
| | | } |
| | | |
| | | var endLoc = db.Queryable<TN_Location>().Where(DbExpr.EndLoc(areas: taskInfo.EndAreas)).First(); |
| | | // 查询终点货位 |
| | | var endLoc = db.Queryable<TN_Location>().Where(DbExpr.EndLoc(areas: tInfo.EndAreas)).First(); |
| | | if (endLoc == null) { |
| | | return NewSimpleResult(5, preLog + LogMsg.EndLocNotFound(areas: taskInfo.EndAreas)); |
| | | return NewSimpleResult(5, preLog + LogMsg.EndLocNotFound(areas: tInfo.EndAreas)); |
| | | } |
| | | |
| | | var task = WCSHelper.BuildTaskWithLocLock(startLoc, endLoc, model.CntId, taskInfo.TaskName); |
| | | // 起点终点上锁,创建任务 |
| | | var task = WMSHelper.CreateTask(obj, startLoc, endLoc, model.CntId, tInfo.TaskName); |
| | | |
| | | cntr.S_SOURCE = task.S_CODE; // 用任务号作为容器更新的依据 |
| | | cntr.T_MODIFY = DateTime.Now; |
| | | obj.ContainerToUpdate = needUpdateContainer ? cntr : null; // 如果需要更新[容器表]规格,写入obj |
| | | |
| | | (ok, msg) = DbTran.CreateTask(new CreateTaskObj { |
| | | ContainerToUpdate = needUpdateContainer ? cntr : null, |
| | | StartLocToUpdate = startLoc, |
| | | EndLocToUpdate = endLoc, |
| | | TaskToInsert = task, |
| | | }); |
| | | (ok, msg) = DbTran.CreateTask(obj); |
| | | return NewSimpleResult(ok ? 0 : 500, preLog + msg); |
| | | } |
| | | catch (Exception ex) { |
| | |
| | | public static SimpleResult EmptyOnlineGoodpack(EmptyOnlineGoodpackInfo model) { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | var (ok, msg) = (false, string.Empty); |
| | | var obj = new CreateTaskObj(); |
| | | |
| | | var taskInfo = ETask.K空箱上线出库.Info(); |
| | | var tInfo = ETask.K空箱上线出库.Info(); |
| | | const string preLog = "API:空箱上线出库:"; |
| | | const string cntrType = "好运箱"; |
| | | |
| | |
| | | } |
| | | |
| | | var startLoc = db.Queryable<TN_Location>().LeftJoin<TN_Loc_Container>((l, c) => l.S_CODE == c.S_LOC_CODE) |
| | | .Where(DbExpr.StartLoc(areas: taskInfo.StartAreas)) |
| | | .Where(DbExpr.StartLoc(areas: tInfo.StartAreas)) |
| | | .Where((l, c) => c.S_CNTR_CODE == model.CntId && c.S_CNTR_TYPE == cntrType).First(); |
| | | if (startLoc == null) { |
| | | return NewSimpleResult(2, preLog + preLog + LogMsg.StartLocNotFound(areas: taskInfo.StartAreas) + |
| | | return NewSimpleResult(2, preLog + preLog + LogMsg.StartLocNotFound(areas: tInfo.StartAreas) + |
| | | $"绑定容器编码='{model.CntId}';绑定容器类型='{cntrType}';"); |
| | | } |
| | | |
| | | var endLoc = db.Queryable<TN_Location>().Where(l => l.N_LOCK_STATE == 0 && l.S_LOCK_STATE == "无" && l.C_ENABLE == "Y") |
| | | .Where(l => taskInfo.EndAreas.Contains(l.S_AREA_CODE) && l.N_CURRENT_NUM == 0).First(); |
| | | var endLoc = db.Queryable<TN_Location>().Where(DbExpr.EndLoc(areas: tInfo.EndAreas)).First(); |
| | | if (endLoc == null) { |
| | | return NewSimpleResult(3, preLog + LogMsg.EndLocNotFound(areas: taskInfo.EndAreas)); |
| | | return NewSimpleResult(3, preLog + LogMsg.EndLocNotFound(areas: tInfo.EndAreas)); |
| | | } |
| | | |
| | | var task = WCSHelper.BuildTaskWithLocLock(startLoc, endLoc, model.CntId, taskInfo.TaskName); |
| | | |
| | | (ok, msg) = DbTran.CreateTask(new CreateTaskObj { |
| | | StartLocToUpdate = startLoc, |
| | | EndLocToUpdate = endLoc, |
| | | TaskToInsert = task, |
| | | }); |
| | | // 起点终点上锁,创建任务 |
| | | WMSHelper.CreateTask(obj, startLoc, endLoc, model.CntId, tInfo.TaskName); |
| | | (ok, msg) = DbTran.CreateTask(obj); |
| | | return NewSimpleResult(ok ? 0 : 500, preLog + msg); |
| | | } |
| | | catch (Exception ex) { |
| | |
| | | public static SimpleResult QualifiedBack(QualifiedBackInfo model) { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | var (ok, msg) = (false, string.Empty); |
| | | var obj = new CreateTaskObj(); |
| | | |
| | | var taskInfo = ETask.C抽检合格回库.Info(); |
| | | const string preLog = "API:抽检合格回库"; |
| | | var tInfo = ETask.C抽检合格回库.Info(); |
| | | const string preLog = "API:抽检合格回库:"; |
| | | |
| | | try { |
| | | var cgDetail = db.Queryable<TN_CG_Detail>() |
| | | .Where(d => d.S_ITEM_CODE == model.ItemCode && d.S_CNTR_CODE == model.CntrCode).First(); |
| | | if (cgDetail == null) { |
| | | return NewSimpleResult(2, preLog + LogMsg.CgDetailNotFound(item: model.ItemCode, cntr: model.CntrCode)); |
| | | return NewSimpleResult(1, preLog + LogMsg.CgDetailNotFound(item: model.ItemCode, cntr: model.CntrCode)); |
| | | } |
| | | |
| | | var locCntrRel = db.Queryable<TN_Loc_Container>().Where(c => c.S_CNTR_CODE == cgDetail.S_CNTR_CODE).First(); |
| | | if (locCntrRel == null) { |
| | | return NewSimpleResult(3, preLog + LogMsg.LocCntrRelNotFound(cntr: cgDetail.S_CNTR_CODE)); |
| | | return NewSimpleResult(2, preLog + LogMsg.LocCntrRelNotFound(cntr: cgDetail.S_CNTR_CODE)); |
| | | } |
| | | |
| | | var startLoc = db.Queryable<TN_Location>().Where(DbExpr.StartLoc(locCntrRel.S_LOC_CODE, taskInfo.StartAreas)).First(); |
| | | var startLoc = db.Queryable<TN_Location>().Where(DbExpr.StartLoc(locCntrRel.S_LOC_CODE, tInfo.StartAreas)).First(); |
| | | if (startLoc == null) { |
| | | return NewSimpleResult(4, preLog + LogMsg.StartLocNotFound(locCntrRel.S_LOC_CODE, taskInfo.StartAreas)); |
| | | return NewSimpleResult(3, preLog + LogMsg.StartLocNotFound(locCntrRel.S_LOC_CODE, tInfo.StartAreas)); |
| | | } |
| | | |
| | | var endAreas = locCntrRel.S_CNTR_CODE == "托盘" ? taskInfo.EndAreas_Pallet : taskInfo.EndAreas_Goodpack; |
| | | var endAreas = locCntrRel.S_CNTR_CODE == "托盘" ? tInfo.EndAreas_Pallet : tInfo.EndAreas_Goodpack; |
| | | var endLoc = db.Queryable<TN_Location>().Where(DbExpr.EndLoc(areas: endAreas)).First(); |
| | | if (endLoc == null) { |
| | | return NewSimpleResult(3, preLog + LogMsg.EndLocNotFound(areas: endAreas)); |
| | | return NewSimpleResult(4, preLog + LogMsg.EndLocNotFound(areas: endAreas)); |
| | | } |
| | | |
| | | //修改物料状态为[合格] |
| | | cgDetail.N_ITEM_STATE = 0; |
| | | cgDetail.S_ITEM_STATE = "合格"; |
| | | cgDetail.T_MODIFY = DateTime.Now; |
| | | obj.CgDetailToUpdate = cgDetail; |
| | | |
| | | var task = WCSHelper.BuildTaskWithLocLock(startLoc, endLoc, locCntrRel.S_CNTR_CODE, taskInfo.TaskName); |
| | | |
| | | (ok, msg) = DbTran.CreateTask(new CreateTaskObj { |
| | | CgDetailToUpdate = cgDetail, |
| | | StartLocToUpdate = startLoc, |
| | | EndLocToUpdate = endLoc, |
| | | TaskToInsert = task, |
| | | }); |
| | | // 起点终点上锁,创建任务 |
| | | WMSHelper.CreateTask(obj, startLoc, endLoc, locCntrRel.S_CNTR_CODE, tInfo.TaskName); |
| | | (ok, msg) = DbTran.CreateTask(obj); |
| | | return NewSimpleResult(ok ? 0 : 500, preLog + msg); |
| | | } |
| | | catch (Exception ex) { |
| | |
| | | public static SimpleResult UnqualifiedShift(UnqualifiedShiftInfo model) { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | var (ok, msg) = (false, string.Empty); |
| | | var obj = new CreateTaskObj(); |
| | | |
| | | var taskInfo = ETask.C抽检不合格移库.Info(); |
| | | var tInfo = ETask.C抽检不合格移库.Info(); |
| | | const string preLog = "API:抽检不合格移库:"; |
| | | |
| | | try { |
| | | if (!taskInfo.EndAreas.Contains(model.EndArea)) { |
| | | return NewSimpleResult(1, preLog + $"终点库区'{model.EndArea}'不满足条件!需要:货区={LogObject(taskInfo.EndAreas)}"); |
| | | if (!tInfo.EndAreas.Contains(model.EndArea)) { |
| | | return NewSimpleResult(1, preLog + $"终点库区'{model.EndArea}'不满足条件!需要:货区={LogObject(tInfo.EndAreas)}"); |
| | | } |
| | | |
| | | var cgDetail = db.Queryable<TN_CG_Detail>() |
| | |
| | | return NewSimpleResult(3, preLog + LogMsg.LocCntrRelNotFound(cntr: cgDetail.S_CNTR_CODE)); |
| | | } |
| | | |
| | | var startLoc = db.Queryable<TN_Location>().Where(DbExpr.StartLoc(locCntrRel.S_LOC_CODE, taskInfo.StartAreas)).First(); |
| | | var startLoc = db.Queryable<TN_Location>().Where(DbExpr.StartLoc(locCntrRel.S_LOC_CODE, tInfo.StartAreas)).First(); |
| | | if (startLoc == null) { |
| | | return NewSimpleResult(1, preLog + LogMsg.StartLocNotFound(locCntrRel.S_LOC_CODE, taskInfo.StartAreas)); |
| | | return NewSimpleResult(4, preLog + LogMsg.StartLocNotFound(locCntrRel.S_LOC_CODE, tInfo.StartAreas)); |
| | | } |
| | | |
| | | var endLoc = db.Queryable<TN_Location>().Where(DbExpr.EndLoc(areas: new List<string> { model.EndArea })).First(); |
| | | if (endLoc == null) { |
| | | return NewSimpleResult(3, preLog + LogMsg.EndLocNotFound(areas: new List<string> { model.EndArea })); |
| | | return NewSimpleResult(5, preLog + LogMsg.EndLocNotFound(areas: new List<string> { model.EndArea })); |
| | | } |
| | | |
| | | cgDetail.N_ITEM_STATE = 2; |
| | | cgDetail.S_ITEM_STATE = "不合格"; |
| | | cgDetail.T_MODIFY = DateTime.Now; |
| | | obj.CgDetailToUpdate = cgDetail; |
| | | |
| | | var task = WCSHelper.BuildTaskWithLocLock(startLoc, endLoc, locCntrRel.S_CNTR_CODE, taskInfo.TaskName); |
| | | |
| | | (ok, msg) = DbTran.CreateTask(new CreateTaskObj { |
| | | CgDetailToUpdate = cgDetail, |
| | | StartLocToUpdate = startLoc, |
| | | EndLocToUpdate = endLoc, |
| | | TaskToInsert = task, |
| | | }); |
| | | // 起点终点上锁,创建任务 |
| | | WMSHelper.CreateTask(obj, startLoc, endLoc, locCntrRel.S_CNTR_CODE, tInfo.TaskName); |
| | | (ok, msg) = DbTran.CreateTask(obj); |
| | | return NewSimpleResult(ok ? 0 : 500, preLog + msg); |
| | | } |
| | | catch (Exception ex) { |
| | |
| | | public static SimpleResult RestBack(RestBackInfo model) { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | var (ok, msg) = (false, string.Empty); |
| | | var obj = new CreateTaskObj(); |
| | | |
| | | var taskInfo = ETask.W尾料回库.Info(); |
| | | var tInfo = ETask.W尾料回库.Info(); |
| | | const string preLog = "API:尾料回库:"; |
| | | |
| | | try { |
| | |
| | | return NewSimpleResult(3, preLog + LogMsg.LocCntrRelNotFound(loc: model.StartLoc)); |
| | | } |
| | | |
| | | var endAreas = locCntrRel.S_CNTR_CODE == "托盘" ? taskInfo.EndAreas_Pallet : taskInfo.EndAreas_Goodpack; |
| | | var endAreas = locCntrRel.S_CNTR_CODE == "托盘" ? tInfo.EndAreas_Pallet : tInfo.EndAreas_Goodpack; |
| | | var endLoc = db.Queryable<TN_Location>().Where(DbExpr.EndLoc(areas: endAreas)).First(); |
| | | if (endLoc == null) { |
| | | return NewSimpleResult(3, preLog + LogMsg.EndLocNotFound(areas: endAreas)); |
| | | } |
| | | |
| | | var task = WCSHelper.BuildTaskWithLocLock(startLoc, endLoc, locCntrRel.S_CNTR_CODE, taskInfo.TaskName); |
| | | |
| | | (ok, msg) = DbTran.CreateTask(new CreateTaskObj { |
| | | StartLocToUpdate = startLoc, |
| | | EndLocToUpdate = endLoc, |
| | | TaskToInsert = task, |
| | | }); |
| | | // 起点终点上锁,创建任务 |
| | | WMSHelper.CreateTask(obj, startLoc, endLoc, locCntrRel.S_CNTR_CODE, tInfo.TaskName); |
| | | (ok, msg) = DbTran.CreateTask(obj); |
| | | return NewSimpleResult(ok ? 0 : 500, preLog + msg); |
| | | } |
| | | catch (Exception ex) { |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 成品胶出库(PDA) 待定,暂时不需要此功能 |
| | | /// 生成出库单号,私有 |
| | | /// </summary> |
| | | /// <param name="snType"></param> |
| | | /// <param name="prefix"></param> |
| | | /// <returns></returns> |
| | | private static string GenerateOrderNo(string snType, string prefix) { |
| | | //var id = SYSHelper.GetSerialNumberResetByDay(snType, prefix); |
| | | //var date = DateTime.Now.ToString("yyMMdd"); |
| | | //return $"{prefix}{date}-{id.ToString().PadLeft(4, '0')}"; |
| | | return SYSHelper.GenerateSN(snType, prefix, "yyMMdd"); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 成品胶出库(搁置) |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | var (ok, msg) = (false, string.Empty); |
| | | |
| | | var taskInfo = ETask.C成品胶出库.Info(); |
| | | var tInfo = ETask.C成品胶出库.Info(); |
| | | const string preLog = "API:成品胶出库:"; |
| | | |
| | | try { |
| | |
| | | using (var tran = db.Ado.UseTran()) { |
| | | if (db.Insertable(order).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | return NewSimpleResult(2, preLog + "生成出库单失败:" + LogObject(order)); |
| | | return NewSimpleResult(500, preLog + "生成出库单失败:" + LogObject(order)); |
| | | } |
| | | |
| | | if (db.Insertable(detailList).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | return NewSimpleResult(4, preLog + "生成出库单明细失败:" + LogObject(detailList)); |
| | | return NewSimpleResult(500, preLog + "生成出库单明细失败:" + LogObject(detailList)); |
| | | } |
| | | |
| | | tran.CommitTran(); |
| | |
| | | return result; |
| | | } |
| | | |
| | | // NOTE 根据总量选detail时,是否需要考虑货位的高低? |
| | | // NOTE 根据总量选detail时,是否需要考虑货位的高低? |
| | | |
| | | var sortedMaterials = new List<TN_CG_Detail>(); |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | private static string GenerateOrderNo(string snType, string prefix) { |
| | | //var id = SYSHelper.GetSerialNumberResetByDay(snType, prefix); |
| | | //var date = DateTime.Now.ToString("yyMMdd"); |
| | | //return $"{prefix}{date}-{id.ToString().PadLeft(4, '0')}"; |
| | | return SYSHelper.GenerateSN(snType, prefix, "yyMMdd"); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 博实物料信息下发同步 (只针对好运箱) |
| | |
| | | } |
| | | catch (Exception ex) { |
| | | return NewMesResult(-1, preLog + $"发生了异常:{ex.Message}\n\n{ex.StackTrace}\n"); |
| | | } |
| | | } |
| | | |
| | | public static ErpResult ErpSendOutboundPlan(ErpSendOutboundPlanInfo model) { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | var orderNo = GenerateOrderNo("出库单号", "CKD"); |
| | | const string preLog = "API:ERP下发出库计划单:"; |
| | | try { |
| | | if (model.pzjs <= 0) { |
| | | return NewErpResult(400, preLog + $"物料数量(pzjs)'{model.pzjs}'不合法!要求:物料数量>0"); |
| | | } |
| | | |
| | | var outboundPlan = db.Queryable<TN_Outbound_Plan>() |
| | | .Where(p => p.JHDH == model.jhdh).First(); |
| | | if (outboundPlan != null) { |
| | | return NewErpResult(1, preLog + $"计划单号'{model.jhdh}'已在[出库计划单]中存在!"); |
| | | } |
| | | |
| | | outboundPlan = new TN_Outbound_Plan { |
| | | JHDH = model.jhdh, // 计划单号 (唯一标识) |
| | | CKZT = model.ckzt, // 出库状态 (需要返回) |
| | | JHLB = model.jhlb, // 计划类别 |
| | | CKDH = model.ckdh, // 参考单号 |
| | | CPH = model.cph, // 车牌号 |
| | | YSFS = model.ysfs, // 运输方式 |
| | | CPZT = model.cpzt, // 产品状态 |
| | | MDDW = model.mddw, // 买断单位 |
| | | CPDM = model.cpdm, // 产品代码 |
| | | CPLB = model.cplb, // 产品类别 |
| | | CPLBMX = model.cplbmx, // 产品类别明细 |
| | | PP = model.pp, // 品牌 |
| | | DJ = model.dj, // 等级 (需要返回) |
| | | GH = model.gh, // 罐号 |
| | | PH = model.ph, // 批号 (需要返回) |
| | | BZLX = model.bzlx, // 包装类型 |
| | | PZDH = model.pzdh, // 派装单号 |
| | | PZD_DW = model.pzd_dw, // 派装单单位 |
| | | PZD_DYBH = model.pzd_dybh, // 派装单调运编号 |
| | | PZJS = model.pzjs, // 派装件数 |
| | | PZSL = model.pzsl, // 派装数量 |
| | | PZ_RQ = model.pz_rq, // 派装日期(yyyy-mm-dd) |
| | | PZ_CZRQ = model.pz_czrq, // 派装操作日期 |
| | | PZ_ZFBJ = model.pz_zfbj, // 派装作废标记 |
| | | PZ_ZFRQ = model.pz_zfrq, // 派装作废日期 |
| | | PZ_BZ = model.pz_bz, // 派装备注 |
| | | CKDBH = model.ckdbh, // 出库单编号 |
| | | SFJS = model.sfjs, // 实发件数 (需要返回) |
| | | SFSL = model.sfsl, // 实发数量 (需要返回) |
| | | SFCS = model.sfcs, // 实发车数 (需要返回) |
| | | ZCSJ = model.zcsj, // 装车时间 (需要返回) |
| | | JLDW = model.jldw, // 计量单位 (需要返回) |
| | | FHRQ = model.fhrq, // 发货日期 (需要返回) |
| | | CKDM = model.ckdm, // 仓库代码 (需要返回) |
| | | FHR = model.fhr, // 发货人 (需要返回) |
| | | CZYDM = model.czydm, // 操作员 (需要返回) |
| | | SHR_USERNAME = model.shr_username, // 审核人 |
| | | SHRQ = model.shrq, // 审核日期 |
| | | ZFBJ = model.zfbj, // 作废标记 |
| | | ZFRQ = model.zfrq, // 作废日期 |
| | | JSDW = model.jsdw, // 结算单位 |
| | | SHDW = model.shdw, // 收货单位 |
| | | YSDW = model.ysdw, // 运输单位 |
| | | LXR = model.lxr, // 联系人 |
| | | RY_ZXG = model.ry_zxg, // 装卸工 (需要返回) |
| | | RY_CCSJ = model.ry_ccsj, // 叉车司机 (需要返回) |
| | | ERPHX_JHDH = model.erphx_jhdh, // erp交货单号 |
| | | ERPHX_WLBM = model.erphx_wlbm, // erp物料编码 |
| | | ERPHX_WLMC = model.erphx_wlmc, // erp物料名称 |
| | | ERPHX_CJRQ = model.erphx_cjrq, // erp创建日期 |
| | | HW = model.hw, // 货位 (需要返回) |
| | | HWZT = model.hwzt // 货位状态 (需要返回) |
| | | }; |
| | | |
| | | //var cgDetailList = SelectCgByTotalQty( |
| | | // qty: (int)model.pzsl, |
| | | // itemCode: model.cpdm, |
| | | // batchNo: model.ph |
| | | // ); |
| | | |
| | | //if (cgDetailList.Count == 0) { |
| | | // info = "没有合适的物料可以出库"; |
| | | // LogHelper.Info(info); |
| | | // return NewErpResult(3, info); |
| | | //} |
| | | |
| | | var cgDetail = db.Queryable<TN_CG_Detail>().Where(d => d.S_ITEM_CODE == model.cpdm && d.N_ITEM_NUM >= model.pzjs).First(); |
| | | if (cgDetail == null ) { |
| | | return NewErpResult(2, preLog + $"在[货品明细表]中没有找到合适的物料!要求:物料编码='{model.cpdm}',物料数量>={model.pzjs}"); |
| | | } |
| | | |
| | | var order = new TN_Outbound_Order { |
| | | S_NO = orderNo, |
| | | //S_ITEM_CODE = model.cpdm, |
| | | //S_BATCH = model.ph, |
| | | //N_END_NUM = (int)model.pzsl, |
| | | S_ITEM_CODE = model.cpdm, |
| | | S_BATCH = cgDetail.S_BATCH_NO, |
| | | N_END_NUM = (int)model.pzjs, |
| | | S_END_AREA = "QCCKQ", // ERP下发出库任务为汽车出库区 |
| | | S_BS_NO = model.jhdh, |
| | | S_BS_TYPE = "ERP", |
| | | }; |
| | | |
| | | var detailList = new List<TN_Outbound_Detail>(); |
| | | //foreach (var cgDetail in cgDetailList) { |
| | | // var detail = new TN_Outbound_Detail { |
| | | // S_OO_NO = orderNo, |
| | | // S_ITEM_CODE = cgDetail.S_ITEM_CODE, |
| | | // S_BATCH_NO = cgDetail.S_BATCH_NO, |
| | | // S_CNTR_CODE = cgDetail.S_CNTR_CODE, |
| | | // N_COUNT = cgDetail.N_ITEM_NUM, |
| | | // S_END_AREA = order.S_END_AREA, // order为detail的每一个货位设置终点值 |
| | | // S_BS_NO = order.S_BS_NO, |
| | | // S_BS_TYPE= order.S_BS_TYPE, |
| | | // }; |
| | | // detailList.Add(detail); |
| | | //} |
| | | var detail = new TN_Outbound_Detail { |
| | | S_OO_NO = orderNo, |
| | | S_ITEM_CODE = cgDetail.S_ITEM_CODE, |
| | | S_BATCH_NO = cgDetail.S_BATCH_NO, |
| | | S_CNTR_CODE = cgDetail.S_CNTR_CODE, |
| | | N_COUNT = cgDetail.N_ITEM_NUM, |
| | | S_END_AREA = order.S_END_AREA, // order为detail的每一个货位设置终点值 |
| | | S_BS_NO = order.S_BS_NO, |
| | | S_BS_TYPE = order.S_BS_TYPE, |
| | | }; |
| | | detailList.Add(detail); |
| | | |
| | | using (var tran = db.Ado.UseTran()) { |
| | | if (db.Insertable(order).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | return NewErpResult(500, preLog + $"生成[出库单]失败!数据:{LogObject(order)}"); |
| | | } |
| | | |
| | | if (db.Insertable(detailList).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | return NewErpResult(500, preLog + $"生成[出库单明细]失败!数据:{LogObject(detailList)}"); |
| | | } |
| | | |
| | | if (db.Insertable(outboundPlan).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | return NewErpResult(500, preLog + $"生成[出库单计划记录表]失败!数据:{LogObject(outboundPlan)}"); |
| | | } |
| | | |
| | | tran.CommitTran(); |
| | | return NewErpResult(0, preLog + $"生成[出库单]成功!出库单:{LogObject(order)}\n出库单明细:{LogObject(detail)}"); |
| | | } |
| | | } |
| | | catch (Exception ex) { |
| | | return NewErpResult(1, preLog + $"发生了异常:{ex.Message}\n\n{ex.StackTrace}\n"); |
| | | } |
| | | } |
| | | |
| | |
| | | Data = message, |
| | | }; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 反馈 ERP 的数据类型 |
| | | /// </summary> |
| | | public class ErpResult { |
| | | [JsonProperty("code")] |
| | | public int Code { get; set; } |
| | | [JsonProperty("message")] |
| | | public string Message { get; set; } |
| | | } |
| | | |
| | | public static ErpResult NewErpResult(int code, string message, bool log = true) { |
| | | if (log) { LogHelper.Info(message); } |
| | | return new ErpResult { Code = code, Message = message }; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// ERP 下发出库任务的数据类型 |
| | | /// </summary> |
| | | public class ErpSendOutboundPlanInfo { |
| | | /// <summary> |
| | | /// 计划单号 (唯一标识) |
| | | /// </summary> |
| | | public string jhdh { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 出库状态 |
| | | /// </summary> |
| | | public string ckzt { get; set; } = string.Empty;// 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 计划类别 |
| | | /// </summary> |
| | | public string jhlb { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 参考单号 |
| | | /// </summary> |
| | | public string ckdh { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 车牌号 |
| | | /// </summary> |
| | | public string cph { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 运输方式 |
| | | /// </summary> |
| | | public string ysfs { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 产品状态 |
| | | /// </summary> |
| | | public string cpzt { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 买断单位 |
| | | /// </summary> |
| | | public string mddw { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 产品代码 |
| | | /// </summary> |
| | | public string cpdm { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 产品类别 |
| | | /// </summary> |
| | | public string cplb { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 产品类别明细 |
| | | /// </summary> |
| | | public string cplbmx { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 品牌 |
| | | /// </summary> |
| | | public string pp { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 等级 |
| | | /// </summary> |
| | | public string dj { get; set; } = string.Empty;// 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 罐号 |
| | | /// </summary> |
| | | public string gh { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 批号 |
| | | /// </summary> |
| | | public string ph { get; set; } = string.Empty;// 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 包装类型 |
| | | /// </summary> |
| | | public string bzlx { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 派装单号 |
| | | /// </summary> |
| | | public string pzdh { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 派装单单位 |
| | | /// </summary> |
| | | public string pzd_dw { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 派装单调运编号 |
| | | /// </summary> |
| | | public string pzd_dybh { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 派装件数 |
| | | /// </summary> |
| | | public double pzjs { get; set; } = 0; |
| | | |
| | | /// <summary> |
| | | /// 派装数量 |
| | | /// </summary> |
| | | public decimal pzsl { get; set; } = 0; |
| | | |
| | | /// <summary> |
| | | /// 派装日期(yyyy-mm-dd) |
| | | /// </summary> |
| | | public string pz_rq { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 派装操作日期 |
| | | /// </summary> |
| | | public long pz_czrq { get; set; } = 0; |
| | | |
| | | /// <summary> |
| | | /// 派装作废标记 |
| | | /// </summary> |
| | | public int pz_zfbj { get; set; } = 0; |
| | | |
| | | /// <summary> |
| | | /// 派装作废日期 |
| | | /// </summary> |
| | | public long pz_zfrq { get; set; } = 0; |
| | | |
| | | /// <summary> |
| | | /// 派装备注 |
| | | /// </summary> |
| | | public string pz_bz { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 出库单编号 |
| | | /// </summary> |
| | | public string ckdbh { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 实发件数 |
| | | /// </summary> |
| | | public double sfjs { get; set; } = 0; // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 实发数量 |
| | | /// </summary> |
| | | public decimal sfsl { get; set; } = 0; // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 实发车数 |
| | | /// </summary> |
| | | public int sfcs { get; set; } = 0; // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 装车时间 |
| | | /// </summary> |
| | | public string zcsj { get; set; } = string.Empty; // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 计量单位 |
| | | /// </summary> |
| | | public string jldw { get; set; } = string.Empty;// 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 发货日期 |
| | | /// </summary> |
| | | public long fhrq { get; set; } = 0; // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 仓库代码 |
| | | /// </summary> |
| | | public string ckdm { get; set; } = string.Empty; // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 发货人 |
| | | /// </summary> |
| | | public string fhr { get; set; } = string.Empty; // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 操作员 |
| | | /// </summary> |
| | | public string czydm { get; set; } = string.Empty; // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 审核人 |
| | | /// </summary> |
| | | public string shr_username { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 审核日期 |
| | | /// </summary> |
| | | public long shrq { get; set; } = 0; |
| | | |
| | | /// <summary> |
| | | /// 作废标记 |
| | | /// </summary> |
| | | public long zfbj { get; set; } = 0; |
| | | |
| | | /// <summary> |
| | | /// 作废日期 |
| | | /// </summary> |
| | | public long zfrq { get; set; } = 0; |
| | | |
| | | /// <summary> |
| | | /// 结算单位 |
| | | /// </summary> |
| | | public string jsdw { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 收货单位 |
| | | /// </summary> |
| | | public string shdw { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 运输单位 |
| | | /// </summary> |
| | | public string ysdw { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 联系人 |
| | | /// </summary> |
| | | public string lxr { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 装卸工 |
| | | /// </summary> |
| | | public string ry_zxg { get; set; } = string.Empty; // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 叉车司机 |
| | | /// </summary> |
| | | public string ry_ccsj { get; set; } = string.Empty; // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// erp交货单号 |
| | | /// </summary> |
| | | public string erphx_jhdh { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// erp物料编码 |
| | | /// </summary> |
| | | public string erphx_wlbm { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// erp物料名称 |
| | | /// </summary> |
| | | public string erphx_wlmc { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// erp创建日期 |
| | | /// </summary> |
| | | public string erphx_cjrq { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 货位 |
| | | /// </summary> |
| | | public string hw { get; set; } = string.Empty; // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 货位状态 |
| | | /// </summary> |
| | | public string hwzt { get; set; } = string.Empty; // 需要返回 |
| | | } |
| | | |
| | | public class PickUpReturnErpInfo { |
| | | /// <summary> |
| | | /// 计划单号 (唯一标识) |
| | | /// </summary> |
| | | public string jhdh { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 出库状态 |
| | | /// </summary> |
| | | public string ckzt { get; set; } // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 计划类别 |
| | | /// </summary> |
| | | public string jhlb { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 参考单号 |
| | | /// </summary> |
| | | public string ckdh { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 车牌号 |
| | | /// </summary> |
| | | public string cph { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 运输方式 |
| | | /// </summary> |
| | | public string ysfs { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 产品状态 |
| | | /// </summary> |
| | | public string cpzt { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 买断单位 |
| | | /// </summary> |
| | | public string mddw { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 产品代码 |
| | | /// </summary> |
| | | public string cpdm { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 产品类别 |
| | | /// </summary> |
| | | public string cplb { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 产品类别明细 |
| | | /// </summary> |
| | | public string cplbmx { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 品牌 |
| | | /// </summary> |
| | | public string pp { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 等级 |
| | | /// </summary> |
| | | public string dj { get; set; } // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 罐号 |
| | | /// </summary> |
| | | public string gh { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 批号 |
| | | /// </summary> |
| | | public string ph { get; set; } // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 包装类型 |
| | | /// </summary> |
| | | public string bzlx { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 派装单号 |
| | | /// </summary> |
| | | public string pzdh { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 派装单单位 |
| | | /// </summary> |
| | | public string pzd_dw { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 派装单调运编号 |
| | | /// </summary> |
| | | public string pzd_dybh { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 派装件数 |
| | | /// </summary> |
| | | public double pzjs { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 派装数量 |
| | | /// </summary> |
| | | public decimal pzsl { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 派装日期(yyyy-mm-dd) |
| | | /// </summary> |
| | | public string pz_rq { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 派装操作日期 |
| | | /// </summary> |
| | | public long pz_czrq { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 派装作废标记 |
| | | /// </summary> |
| | | public int pz_zfbj { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 派装作废日期 |
| | | /// </summary> |
| | | public long pz_zfrq { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 派装备注 |
| | | /// </summary> |
| | | public string pz_bz { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 出库单编号 |
| | | /// </summary> |
| | | public string ckdbh { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 实发件数 |
| | | /// </summary> |
| | | public double sfjs { get; set; } // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 实发数量 |
| | | /// </summary> |
| | | public decimal sfsl { get; set; } // 需要返回 |
| | | |
| | | ///// <summary> |
| | | ///// 实发车数 |
| | | ///// </summary> |
| | | //public int sfcs { get; set; } // 需要返回 |
| | | |
| | | ///// <summary> |
| | | ///// 装车时间 |
| | | ///// </summary> |
| | | //public string zcsj { get; set; } // 需要返回 |
| | | |
| | | ///// <summary> |
| | | ///// 计量单位 |
| | | ///// </summary> |
| | | //public string jldw { get; set; } // 需要返回 |
| | | |
| | | ///// <summary> |
| | | ///// 发货日期 |
| | | ///// </summary> |
| | | //public long fhrq { get; set; } // 需要返回 |
| | | |
| | | ///// <summary> |
| | | ///// 仓库代码 |
| | | ///// </summary> |
| | | //public string ckdm { get; set; } // 需要返回 |
| | | |
| | | ///// <summary> |
| | | ///// 发货人 |
| | | ///// </summary> |
| | | //public string fhr { get; set; } // 需要返回 |
| | | |
| | | ///// <summary> |
| | | ///// 操作员 |
| | | ///// </summary> |
| | | //public string czydm { get; set; } // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 审核人 |
| | | /// </summary> |
| | | public string shr_username { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 审核日期 |
| | | /// </summary> |
| | | public long shrq { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 作废标记 |
| | | /// </summary> |
| | | public long zfbj { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 作废日期 |
| | | /// </summary> |
| | | public long zfrq { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 结算单位 |
| | | /// </summary> |
| | | public string jsdw { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 收货单位 |
| | | /// </summary> |
| | | public string shdw { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 运输单位 |
| | | /// </summary> |
| | | public string ysdw { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 联系人 |
| | | /// </summary> |
| | | public string lxr { get; set; } |
| | | |
| | | ///// <summary> |
| | | ///// 装卸工 |
| | | ///// </summary> |
| | | //public string ry_zxg { get; set; } // 需要返回 |
| | | |
| | | ///// <summary> |
| | | ///// 叉车司机 |
| | | ///// </summary> |
| | | //public string ry_ccsj { get; set; } // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// erp交货单号 |
| | | /// </summary> |
| | | public string erphx_jhdh { get; set; } |
| | | |
| | | /// <summary> |
| | | /// erp物料编码 |
| | | /// </summary> |
| | | public string erphx_wlbm { get; set; } |
| | | |
| | | /// <summary> |
| | | /// erp物料名称 |
| | | /// </summary> |
| | | public string erphx_wlmc { get; set; } |
| | | |
| | | /// <summary> |
| | | /// erp创建日期 |
| | | /// </summary> |
| | | public string erphx_cjrq { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 货位 |
| | | /// </summary> |
| | | public string hw { get; set; } // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 货位状态 |
| | | /// </summary> |
| | | public string hwzt { get; set; } // 需要返回 |
| | | } |
| | | |
| | | public class CreateTaskReturnErpInfo { |
| | | /// <summary> |
| | | /// 计划单号 (唯一标识) |
| | | /// </summary> |
| | | public string jhdh { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 出库状态 |
| | | /// </summary> |
| | | public string ckzt { get; set; } // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 计划类别 |
| | | /// </summary> |
| | | public string jhlb { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 参考单号 |
| | | /// </summary> |
| | | public string ckdh { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 车牌号 |
| | | /// </summary> |
| | | public string cph { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 运输方式 |
| | | /// </summary> |
| | | public string ysfs { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 产品状态 |
| | | /// </summary> |
| | | public string cpzt { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 买断单位 |
| | | /// </summary> |
| | | public string mddw { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 产品代码 |
| | | /// </summary> |
| | | public string cpdm { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 产品类别 |
| | | /// </summary> |
| | | public string cplb { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 产品类别明细 |
| | | /// </summary> |
| | | public string cplbmx { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 品牌 |
| | | /// </summary> |
| | | public string pp { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 等级 |
| | | /// </summary> |
| | | public string dj { get; set; } // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 罐号 |
| | | /// </summary> |
| | | public string gh { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 批号 |
| | | /// </summary> |
| | | public string ph { get; set; } // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 包装类型 |
| | | /// </summary> |
| | | public string bzlx { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 派装单号 |
| | | /// </summary> |
| | | public string pzdh { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 派装单单位 |
| | | /// </summary> |
| | | public string pzd_dw { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 派装单调运编号 |
| | | /// </summary> |
| | | public string pzd_dybh { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 派装件数 |
| | | /// </summary> |
| | | public double pzjs { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 派装数量 |
| | | /// </summary> |
| | | public decimal pzsl { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 派装日期(yyyy-mm-dd) |
| | | /// </summary> |
| | | public string pz_rq { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 派装操作日期 |
| | | /// </summary> |
| | | public long pz_czrq { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 派装作废标记 |
| | | /// </summary> |
| | | public int pz_zfbj { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 派装作废日期 |
| | | /// </summary> |
| | | public long pz_zfrq { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 派装备注 |
| | | /// </summary> |
| | | public string pz_bz { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 出库单编号 |
| | | /// </summary> |
| | | public string ckdbh { get; set; } |
| | | |
| | | ///// <summary> |
| | | ///// 实发件数 |
| | | ///// </summary> |
| | | //public double sfjs { get; set; } // 需要返回 |
| | | |
| | | ///// <summary> |
| | | ///// 实发数量 |
| | | ///// </summary> |
| | | //public decimal sfsl { get; set; } // 需要返回 |
| | | |
| | | ///// <summary> |
| | | ///// 实发车数 |
| | | ///// </summary> |
| | | //public int sfcs { get; set; } // 需要返回 |
| | | |
| | | ///// <summary> |
| | | ///// 装车时间 |
| | | ///// </summary> |
| | | //public string zcsj { get; set; } // 需要返回 |
| | | |
| | | ///// <summary> |
| | | ///// 计量单位 |
| | | ///// </summary> |
| | | //public string jldw { get; set; } // 需要返回 |
| | | |
| | | ///// <summary> |
| | | ///// 发货日期 |
| | | ///// </summary> |
| | | //public long fhrq { get; set; } // 需要返回 |
| | | |
| | | ///// <summary> |
| | | ///// 仓库代码 |
| | | ///// </summary> |
| | | //public string ckdm { get; set; } // 需要返回 |
| | | |
| | | ///// <summary> |
| | | ///// 发货人 |
| | | ///// </summary> |
| | | //public string fhr { get; set; } // 需要返回 |
| | | |
| | | ///// <summary> |
| | | ///// 操作员 |
| | | ///// </summary> |
| | | //public string czydm { get; set; } // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 审核人 |
| | | /// </summary> |
| | | public string shr_username { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 审核日期 |
| | | /// </summary> |
| | | public long shrq { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 作废标记 |
| | | /// </summary> |
| | | public long zfbj { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 作废日期 |
| | | /// </summary> |
| | | public long zfrq { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 结算单位 |
| | | /// </summary> |
| | | public string jsdw { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 收货单位 |
| | | /// </summary> |
| | | public string shdw { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 运输单位 |
| | | /// </summary> |
| | | public string ysdw { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 联系人 |
| | | /// </summary> |
| | | public string lxr { get; set; } |
| | | |
| | | ///// <summary> |
| | | ///// 装卸工 |
| | | ///// </summary> |
| | | //public string ry_zxg { get; set; } // 需要返回 |
| | | |
| | | ///// <summary> |
| | | ///// 叉车司机 |
| | | ///// </summary> |
| | | //public string ry_ccsj { get; set; } // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// erp交货单号 |
| | | /// </summary> |
| | | public string erphx_jhdh { get; set; } |
| | | |
| | | /// <summary> |
| | | /// erp物料编码 |
| | | /// </summary> |
| | | public string erphx_wlbm { get; set; } |
| | | |
| | | /// <summary> |
| | | /// erp物料名称 |
| | | /// </summary> |
| | | public string erphx_wlmc { get; set; } |
| | | |
| | | /// <summary> |
| | | /// erp创建日期 |
| | | /// </summary> |
| | | public string erphx_cjrq { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 货位 |
| | | /// </summary> |
| | | public string hw { get; set; } // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 货位状态 |
| | | /// </summary> |
| | | public string hwzt { get; set; } // 需要返回 |
| | | } |
| | | } |
| | | } |
| | |
| | | using System.IO; |
| | | using System.Runtime.ConstrainedExecution; |
| | | using System.Web.Http; |
| | | |
| | | using HH.WCS.Mobox3.DSZSH.core; |
| | | using HH.WCS.Mobox3.DSZSH.device; |
| | | using HH.WCS.Mobox3.DSZSH.models; |
| | | using HH.WCS.Mobox3.DSZSH.util; |
| | | using HH.WCS.Mobox3.DSZSH.wms; |
| | | |
| | | using Newtonsoft.Json; |
| | | |
| | | using SqlSugar; |
| | | |
| | | using static HH.WCS.Mobox3.DSZSH.api.ApiModel; |
| | | using static HH.WCS.Mobox3.DSZSH.api.OtherModel; |
| | | using static HH.WCS.Mobox3.DSZSH.core.Monitor; |
| | |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Route("TestErpSendOutboundPlan")] |
| | | public ErpResult TestErpSendOutboundPlan(TestErpSendOutboundPlanInfo model) { |
| | | public ErpModel.ErpResult TestErpSendOutboundPlan(TestErpSendOutboundPlanInfo model) { |
| | | var apiName = "ERP下发出库计划单"; |
| | | //LogHelper.InfoApi(apiName, model); |
| | | |
| | | var erpModel = new ErpSendOutboundPlanInfo(); |
| | | var erpModel = new ErpModel.ErpSendOutboundPlanInfo(); |
| | | erpModel.jhdh = model.PlanNo; |
| | | erpModel.cpdm = model.ItemCode; |
| | | erpModel.pzjs = model.ItemNum; |
| | | |
| | | LogHelper.InfoApi(apiName, erpModel); |
| | | |
| | | return ApiHelper.ErpSendOutboundPlan(erpModel); |
| | | return ErpService.ErpSendOutboundPlan(erpModel); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Route("PickUpReturn")] |
| | | public TestErpResult PickUpReturn(PickUpReturnErpInfo model) { |
| | | public TestErpResult PickUpReturn(ErpModel.PickUpReturnErpInfo model) { |
| | | if (model.sfjs == 0) { |
| | | return new TestErpResult { |
| | | code = 1, |
| | |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Route("CreateTaskReturn")] |
| | | public TestErpResult CreateTaskReturn(CreateTaskReturnErpInfo model) { |
| | | public TestErpResult CreateTaskReturn(ErpModel.CreateTaskReturnErpInfo model) { |
| | | if (model.hw == "") { |
| | | return new TestErpResult { |
| | | code = 1, |
| | |
| | | using System.Web.Http; |
| | | using static HH.WCS.Mobox3.DSZSH.api.OtherModel; |
| | | using HH.WCS.Mobox3.DSZSH.util; |
| | | using HH.WCS.Mobox3.DSZSH.models; |
| | | using HH.WCS.Mobox3.DSZSH.wms; |
| | | using static HH.WCS.Mobox3.DSZSH.api.ApiModel; |
| | | using static HH.WCS.Mobox3.DSZSH.api.ErpModel; |
| | | |
| | | namespace HH.WCS.Mobox3.DSZSH.api { |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Route("ErpSendOutboundPlan")] |
| | | public ErpResult ErpSendOutboundPlan(ErpSendOutboundPlanInfo model) { |
| | | public ErpResult ErpSendOutboundPlan(ErpModel.ErpSendOutboundPlanInfo model) { |
| | | LogHelper.InfoApi("ERP下发出库计划单", model); |
| | | return ApiHelper.ErpSendOutboundPlan(model); |
| | | return ErpService.ErpSendOutboundPlan(model); |
| | | } |
| | | } |
| | | |
| | | public class ErpService { |
| | | public static ErpResult ErpSendOutboundPlan(ErpModel.ErpSendOutboundPlanInfo model) { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | var orderNo = SYSHelper.GenerateSN("出库单号", "CKD", "yyMMdd"); |
| | | const string preLog = "API:ERP下发出库计划单:"; |
| | | try { |
| | | if (model.pzjs <= 0) { |
| | | return NewErpResult(400, preLog + $"物料数量(pzjs)'{model.pzjs}'不合法!!要求:物料数量>0"); |
| | | } |
| | | |
| | | var outboundPlan = db.Queryable<TN_Outbound_Plan>() |
| | | .Where(p => p.JHDH == model.jhdh).First(); |
| | | if (outboundPlan != null) { |
| | | return NewErpResult(1, preLog + $"计划单号'{model.jhdh}'已在[出库计划单]中存在!!"); |
| | | } |
| | | |
| | | outboundPlan = new TN_Outbound_Plan { |
| | | JHDH = model.jhdh, // 计划单号 (唯一标识) |
| | | CKZT = model.ckzt, // 出库状态 (需要返回) |
| | | JHLB = model.jhlb, // 计划类别 |
| | | CKDH = model.ckdh, // 参考单号 |
| | | CPH = model.cph, // 车牌号 |
| | | YSFS = model.ysfs, // 运输方式 |
| | | CPZT = model.cpzt, // 产品状态 |
| | | MDDW = model.mddw, // 买断单位 |
| | | CPDM = model.cpdm, // 产品代码 |
| | | CPLB = model.cplb, // 产品类别 |
| | | CPLBMX = model.cplbmx, // 产品类别明细 |
| | | PP = model.pp, // 品牌 |
| | | DJ = model.dj, // 等级 (需要返回) |
| | | GH = model.gh, // 罐号 |
| | | PH = model.ph, // 批号 (需要返回) |
| | | BZLX = model.bzlx, // 包装类型 |
| | | PZDH = model.pzdh, // 派装单号 |
| | | PZD_DW = model.pzd_dw, // 派装单单位 |
| | | PZD_DYBH = model.pzd_dybh, // 派装单调运编号 |
| | | PZJS = model.pzjs, // 派装件数 |
| | | PZSL = model.pzsl, // 派装数量 |
| | | PZ_RQ = model.pz_rq, // 派装日期(yyyy-mm-dd) |
| | | PZ_CZRQ = model.pz_czrq, // 派装操作日期 |
| | | PZ_ZFBJ = model.pz_zfbj, // 派装作废标记 |
| | | PZ_ZFRQ = model.pz_zfrq, // 派装作废日期 |
| | | PZ_BZ = model.pz_bz, // 派装备注 |
| | | CKDBH = model.ckdbh, // 出库单编号 |
| | | SFJS = model.sfjs, // 实发件数 (需要返回) |
| | | SFSL = model.sfsl, // 实发数量 (需要返回) |
| | | SFCS = model.sfcs, // 实发车数 (需要返回) |
| | | ZCSJ = model.zcsj, // 装车时间 (需要返回) |
| | | JLDW = model.jldw, // 计量单位 (需要返回) |
| | | FHRQ = model.fhrq, // 发货日期 (需要返回) |
| | | CKDM = model.ckdm, // 仓库代码 (需要返回) |
| | | FHR = model.fhr, // 发货人 (需要返回) |
| | | CZYDM = model.czydm, // 操作员 (需要返回) |
| | | SHR_USERNAME = model.shr_username, // 审核人 |
| | | SHRQ = model.shrq, // 审核日期 |
| | | ZFBJ = model.zfbj, // 作废标记 |
| | | ZFRQ = model.zfrq, // 作废日期 |
| | | JSDW = model.jsdw, // 结算单位 |
| | | SHDW = model.shdw, // 收货单位 |
| | | YSDW = model.ysdw, // 运输单位 |
| | | LXR = model.lxr, // 联系人 |
| | | RY_ZXG = model.ry_zxg, // 装卸工 (需要返回) |
| | | RY_CCSJ = model.ry_ccsj, // 叉车司机 (需要返回) |
| | | ERPHX_JHDH = model.erphx_jhdh, // erp交货单号 |
| | | ERPHX_WLBM = model.erphx_wlbm, // erp物料编码 |
| | | ERPHX_WLMC = model.erphx_wlmc, // erp物料名称 |
| | | ERPHX_CJRQ = model.erphx_cjrq, // erp创建日期 |
| | | HW = model.hw, // 货位 (需要返回) |
| | | HWZT = model.hwzt // 货位状态 (需要返回) |
| | | }; |
| | | |
| | | var cgDetail = db.Queryable<TN_CG_Detail>().Where(d => d.S_ITEM_CODE == model.cpdm && d.N_ITEM_NUM >= model.pzjs).First(); |
| | | if (cgDetail == null) { |
| | | return NewErpResult(2, preLog + $"在[货品明细表]中没有找到合适的物料!要求:物料编码='{model.cpdm}',物料数量>={model.pzjs}"); |
| | | } |
| | | |
| | | var order = new TN_Outbound_Order { |
| | | S_NO = orderNo, |
| | | //S_ITEM_CODE = model.cpdm, |
| | | //S_BATCH = model.ph, |
| | | //N_END_NUM = (int)model.pzsl, |
| | | S_ITEM_CODE = model.cpdm, |
| | | S_BATCH = cgDetail.S_BATCH_NO, |
| | | N_END_NUM = (int)model.pzjs, |
| | | S_END_AREA = "QCCKQ", // ERP下发出库任务为汽车出库区 |
| | | S_BS_NO = model.jhdh, |
| | | S_BS_TYPE = "ERP", |
| | | }; |
| | | |
| | | var detailList = new List<TN_Outbound_Detail>(); |
| | | var detail = new TN_Outbound_Detail { |
| | | S_OO_NO = orderNo, |
| | | S_ITEM_CODE = cgDetail.S_ITEM_CODE, |
| | | S_BATCH_NO = cgDetail.S_BATCH_NO, |
| | | S_CNTR_CODE = cgDetail.S_CNTR_CODE, |
| | | N_COUNT = cgDetail.N_ITEM_NUM, |
| | | S_END_AREA = order.S_END_AREA, // order为detail的每一个货位设置终点值 |
| | | S_BS_NO = order.S_BS_NO, |
| | | S_BS_TYPE = order.S_BS_TYPE, |
| | | }; |
| | | detailList.Add(detail); |
| | | |
| | | using (var tran = db.Ado.UseTran()) { |
| | | if (db.Insertable(order).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | return NewErpResult(500, preLog + $"生成[出库单]失败!!数据:\n\n{JsonConvert.SerializeObject(order)}\n"); |
| | | } |
| | | |
| | | if (db.Insertable(detailList).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | return NewErpResult(500, preLog + $"生成[出库单明细]失败!!数据:\n\n{JsonConvert.SerializeObject(detailList)}\n"); |
| | | } |
| | | |
| | | if (db.Insertable(outboundPlan).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | return NewErpResult(500, preLog + $"插入[出库计划记录表]失败!!数据:\n\n{JsonConvert.SerializeObject(outboundPlan)}\n"); |
| | | } |
| | | |
| | | tran.CommitTran(); |
| | | return NewErpResult(0, preLog + $"生成[出库单]成功!!\n\n出库单:{JsonConvert.SerializeObject(order)}\n出库单明细:{JsonConvert.SerializeObject(detailList)}\n"); |
| | | } |
| | | } |
| | | catch (Exception ex) { |
| | | return NewErpResult(1, preLog + $"发生了异常:{ex.Message}\n\n{ex.StackTrace}\n"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public partial class ErpModel { |
| | | /// <summary> |
| | | /// 反馈 ERP 的数据类型 |
| | | /// </summary> |
| | | public class ErpResult { |
| | | [JsonProperty("code")] |
| | | public int Code { get; set; } |
| | | [JsonProperty("message")] |
| | | public string Message { get; set; } |
| | | } |
| | | |
| | | public static ErpResult NewErpResult(int code, string message, string name = "") { |
| | | LogHelper.Info(message, name); |
| | | return new ErpResult { Code = code, Message = message }; |
| | | } |
| | | |
| | | public static ErpResult NewErpResult(Exception ex, string preLog = "", int errCode = -1) { |
| | | LogHelper.InfoEx(ex, preLog); |
| | | return new ErpResult { Code = errCode, Message = $"发生了[异常]:{ex.Message}" }; |
| | | } |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | |
| | | namespace HH.WCS.Mobox3.DSZSH.api { |
| | | public partial class ErpModel { |
| | | public class CreateTaskReturnErpInfo { |
| | | /// <summary> |
| | | /// 计划单号 (唯一标识) |
| | | /// </summary> |
| | | public string jhdh { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 出库状态 |
| | | /// </summary> |
| | | public string ckzt { get; set; } // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 计划类别 |
| | | /// </summary> |
| | | public string jhlb { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 参考单号 |
| | | /// </summary> |
| | | public string ckdh { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 车牌号 |
| | | /// </summary> |
| | | public string cph { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 运输方式 |
| | | /// </summary> |
| | | public string ysfs { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 产品状态 |
| | | /// </summary> |
| | | public string cpzt { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 买断单位 |
| | | /// </summary> |
| | | public string mddw { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 产品代码 |
| | | /// </summary> |
| | | public string cpdm { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 产品类别 |
| | | /// </summary> |
| | | public string cplb { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 产品类别明细 |
| | | /// </summary> |
| | | public string cplbmx { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 品牌 |
| | | /// </summary> |
| | | public string pp { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 等级 |
| | | /// </summary> |
| | | public string dj { get; set; } // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 罐号 |
| | | /// </summary> |
| | | public string gh { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 批号 |
| | | /// </summary> |
| | | public string ph { get; set; } // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 包装类型 |
| | | /// </summary> |
| | | public string bzlx { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 派装单号 |
| | | /// </summary> |
| | | public string pzdh { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 派装单单位 |
| | | /// </summary> |
| | | public string pzd_dw { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 派装单调运编号 |
| | | /// </summary> |
| | | public string pzd_dybh { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 派装件数 |
| | | /// </summary> |
| | | public double pzjs { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 派装数量 |
| | | /// </summary> |
| | | public decimal pzsl { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 派装日期(yyyy-mm-dd) |
| | | /// </summary> |
| | | public string pz_rq { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 派装操作日期 |
| | | /// </summary> |
| | | public long pz_czrq { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 派装作废标记 |
| | | /// </summary> |
| | | public int pz_zfbj { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 派装作废日期 |
| | | /// </summary> |
| | | public long pz_zfrq { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 派装备注 |
| | | /// </summary> |
| | | public string pz_bz { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 出库单编号 |
| | | /// </summary> |
| | | public string ckdbh { get; set; } |
| | | |
| | | ///// <summary> |
| | | ///// 实发件数 |
| | | ///// </summary> |
| | | //public double sfjs { get; set; } // 需要返回 |
| | | |
| | | ///// <summary> |
| | | ///// 实发数量 |
| | | ///// </summary> |
| | | //public decimal sfsl { get; set; } // 需要返回 |
| | | |
| | | ///// <summary> |
| | | ///// 实发车数 |
| | | ///// </summary> |
| | | //public int sfcs { get; set; } // 需要返回 |
| | | |
| | | ///// <summary> |
| | | ///// 装车时间 |
| | | ///// </summary> |
| | | //public string zcsj { get; set; } // 需要返回 |
| | | |
| | | ///// <summary> |
| | | ///// 计量单位 |
| | | ///// </summary> |
| | | //public string jldw { get; set; } // 需要返回 |
| | | |
| | | ///// <summary> |
| | | ///// 发货日期 |
| | | ///// </summary> |
| | | //public long fhrq { get; set; } // 需要返回 |
| | | |
| | | ///// <summary> |
| | | ///// 仓库代码 |
| | | ///// </summary> |
| | | //public string ckdm { get; set; } // 需要返回 |
| | | |
| | | ///// <summary> |
| | | ///// 发货人 |
| | | ///// </summary> |
| | | //public string fhr { get; set; } // 需要返回 |
| | | |
| | | ///// <summary> |
| | | ///// 操作员 |
| | | ///// </summary> |
| | | //public string czydm { get; set; } // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 审核人 |
| | | /// </summary> |
| | | public string shr_username { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 审核日期 |
| | | /// </summary> |
| | | public long shrq { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 作废标记 |
| | | /// </summary> |
| | | public long zfbj { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 作废日期 |
| | | /// </summary> |
| | | public long zfrq { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 结算单位 |
| | | /// </summary> |
| | | public string jsdw { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 收货单位 |
| | | /// </summary> |
| | | public string shdw { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 运输单位 |
| | | /// </summary> |
| | | public string ysdw { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 联系人 |
| | | /// </summary> |
| | | public string lxr { get; set; } |
| | | |
| | | ///// <summary> |
| | | ///// 装卸工 |
| | | ///// </summary> |
| | | //public string ry_zxg { get; set; } // 需要返回 |
| | | |
| | | ///// <summary> |
| | | ///// 叉车司机 |
| | | ///// </summary> |
| | | //public string ry_ccsj { get; set; } // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// erp交货单号 |
| | | /// </summary> |
| | | public string erphx_jhdh { get; set; } |
| | | |
| | | /// <summary> |
| | | /// erp物料编码 |
| | | /// </summary> |
| | | public string erphx_wlbm { get; set; } |
| | | |
| | | /// <summary> |
| | | /// erp物料名称 |
| | | /// </summary> |
| | | public string erphx_wlmc { get; set; } |
| | | |
| | | /// <summary> |
| | | /// erp创建日期 |
| | | /// </summary> |
| | | public string erphx_cjrq { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 货位 |
| | | /// </summary> |
| | | public string hw { get; set; } // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 货位状态 |
| | | /// </summary> |
| | | public string hwzt { get; set; } // 需要返回 |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using HH.WCS.Mobox3.DSZSH.util; |
| | | using Newtonsoft.Json; |
| | | |
| | | namespace HH.WCS.Mobox3.DSZSH.api { |
| | | public partial class ErpModel { |
| | | /// <summary> |
| | | /// ERP 下发出库任务的数据类型 |
| | | /// </summary> |
| | | public class ErpSendOutboundPlanInfo { |
| | | /// <summary> |
| | | /// 计划单号 (唯一标识) |
| | | /// </summary> |
| | | public string jhdh { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 出库状态 |
| | | /// </summary> |
| | | public string ckzt { get; set; } = string.Empty;// 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 计划类别 |
| | | /// </summary> |
| | | public string jhlb { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 参考单号 |
| | | /// </summary> |
| | | public string ckdh { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 车牌号 |
| | | /// </summary> |
| | | public string cph { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 运输方式 |
| | | /// </summary> |
| | | public string ysfs { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 产品状态 |
| | | /// </summary> |
| | | public string cpzt { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 买断单位 |
| | | /// </summary> |
| | | public string mddw { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 产品代码 |
| | | /// </summary> |
| | | public string cpdm { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 产品类别 |
| | | /// </summary> |
| | | public string cplb { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 产品类别明细 |
| | | /// </summary> |
| | | public string cplbmx { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 品牌 |
| | | /// </summary> |
| | | public string pp { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 等级 |
| | | /// </summary> |
| | | public string dj { get; set; } = string.Empty;// 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 罐号 |
| | | /// </summary> |
| | | public string gh { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 批号 |
| | | /// </summary> |
| | | public string ph { get; set; } = string.Empty;// 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 包装类型 |
| | | /// </summary> |
| | | public string bzlx { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 派装单号 |
| | | /// </summary> |
| | | public string pzdh { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 派装单单位 |
| | | /// </summary> |
| | | public string pzd_dw { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 派装单调运编号 |
| | | /// </summary> |
| | | public string pzd_dybh { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 派装件数 |
| | | /// </summary> |
| | | public double pzjs { get; set; } = 0; |
| | | |
| | | /// <summary> |
| | | /// 派装数量 |
| | | /// </summary> |
| | | public decimal pzsl { get; set; } = 0; |
| | | |
| | | /// <summary> |
| | | /// 派装日期(yyyy-mm-dd) |
| | | /// </summary> |
| | | public string pz_rq { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 派装操作日期 |
| | | /// </summary> |
| | | public long pz_czrq { get; set; } = 0; |
| | | |
| | | /// <summary> |
| | | /// 派装作废标记 |
| | | /// </summary> |
| | | public int pz_zfbj { get; set; } = 0; |
| | | |
| | | /// <summary> |
| | | /// 派装作废日期 |
| | | /// </summary> |
| | | public long pz_zfrq { get; set; } = 0; |
| | | |
| | | /// <summary> |
| | | /// 派装备注 |
| | | /// </summary> |
| | | public string pz_bz { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 出库单编号 |
| | | /// </summary> |
| | | public string ckdbh { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 实发件数 |
| | | /// </summary> |
| | | public double sfjs { get; set; } = 0; // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 实发数量 |
| | | /// </summary> |
| | | public decimal sfsl { get; set; } = 0; // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 实发车数 |
| | | /// </summary> |
| | | public int sfcs { get; set; } = 0; // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 装车时间 |
| | | /// </summary> |
| | | public string zcsj { get; set; } = string.Empty; // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 计量单位 |
| | | /// </summary> |
| | | public string jldw { get; set; } = string.Empty;// 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 发货日期 |
| | | /// </summary> |
| | | public long fhrq { get; set; } = 0; // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 仓库代码 |
| | | /// </summary> |
| | | public string ckdm { get; set; } = string.Empty; // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 发货人 |
| | | /// </summary> |
| | | public string fhr { get; set; } = string.Empty; // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 操作员 |
| | | /// </summary> |
| | | public string czydm { get; set; } = string.Empty; // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 审核人 |
| | | /// </summary> |
| | | public string shr_username { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 审核日期 |
| | | /// </summary> |
| | | public long shrq { get; set; } = 0; |
| | | |
| | | /// <summary> |
| | | /// 作废标记 |
| | | /// </summary> |
| | | public long zfbj { get; set; } = 0; |
| | | |
| | | /// <summary> |
| | | /// 作废日期 |
| | | /// </summary> |
| | | public long zfrq { get; set; } = 0; |
| | | |
| | | /// <summary> |
| | | /// 结算单位 |
| | | /// </summary> |
| | | public string jsdw { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 收货单位 |
| | | /// </summary> |
| | | public string shdw { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 运输单位 |
| | | /// </summary> |
| | | public string ysdw { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 联系人 |
| | | /// </summary> |
| | | public string lxr { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 装卸工 |
| | | /// </summary> |
| | | public string ry_zxg { get; set; } = string.Empty; // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 叉车司机 |
| | | /// </summary> |
| | | public string ry_ccsj { get; set; } = string.Empty; // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// erp交货单号 |
| | | /// </summary> |
| | | public string erphx_jhdh { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// erp物料编码 |
| | | /// </summary> |
| | | public string erphx_wlbm { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// erp物料名称 |
| | | /// </summary> |
| | | public string erphx_wlmc { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// erp创建日期 |
| | | /// </summary> |
| | | public string erphx_cjrq { get; set; } = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 货位 |
| | | /// </summary> |
| | | public string hw { get; set; } = string.Empty; // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 货位状态 |
| | | /// </summary> |
| | | public string hwzt { get; set; } = string.Empty; // 需要返回 |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | |
| | | namespace HH.WCS.Mobox3.DSZSH.api { |
| | | public partial class ErpModel { |
| | | public class PickUpReturnErpInfo { |
| | | /// <summary> |
| | | /// 计划单号 (唯一标识) |
| | | /// </summary> |
| | | public string jhdh { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 出库状态 |
| | | /// </summary> |
| | | public string ckzt { get; set; } // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 计划类别 |
| | | /// </summary> |
| | | public string jhlb { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 参考单号 |
| | | /// </summary> |
| | | public string ckdh { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 车牌号 |
| | | /// </summary> |
| | | public string cph { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 运输方式 |
| | | /// </summary> |
| | | public string ysfs { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 产品状态 |
| | | /// </summary> |
| | | public string cpzt { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 买断单位 |
| | | /// </summary> |
| | | public string mddw { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 产品代码 |
| | | /// </summary> |
| | | public string cpdm { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 产品类别 |
| | | /// </summary> |
| | | public string cplb { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 产品类别明细 |
| | | /// </summary> |
| | | public string cplbmx { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 品牌 |
| | | /// </summary> |
| | | public string pp { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 等级 |
| | | /// </summary> |
| | | public string dj { get; set; } // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 罐号 |
| | | /// </summary> |
| | | public string gh { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 批号 |
| | | /// </summary> |
| | | public string ph { get; set; } // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 包装类型 |
| | | /// </summary> |
| | | public string bzlx { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 派装单号 |
| | | /// </summary> |
| | | public string pzdh { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 派装单单位 |
| | | /// </summary> |
| | | public string pzd_dw { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 派装单调运编号 |
| | | /// </summary> |
| | | public string pzd_dybh { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 派装件数 |
| | | /// </summary> |
| | | public double pzjs { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 派装数量 |
| | | /// </summary> |
| | | public decimal pzsl { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 派装日期(yyyy-mm-dd) |
| | | /// </summary> |
| | | public string pz_rq { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 派装操作日期 |
| | | /// </summary> |
| | | public long pz_czrq { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 派装作废标记 |
| | | /// </summary> |
| | | public int pz_zfbj { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 派装作废日期 |
| | | /// </summary> |
| | | public long pz_zfrq { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 派装备注 |
| | | /// </summary> |
| | | public string pz_bz { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 出库单编号 |
| | | /// </summary> |
| | | public string ckdbh { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 实发件数 |
| | | /// </summary> |
| | | public double sfjs { get; set; } // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 实发数量 |
| | | /// </summary> |
| | | public decimal sfsl { get; set; } // 需要返回 |
| | | |
| | | ///// <summary> |
| | | ///// 实发车数 |
| | | ///// </summary> |
| | | //public int sfcs { get; set; } // 需要返回 |
| | | |
| | | ///// <summary> |
| | | ///// 装车时间 |
| | | ///// </summary> |
| | | //public string zcsj { get; set; } // 需要返回 |
| | | |
| | | ///// <summary> |
| | | ///// 计量单位 |
| | | ///// </summary> |
| | | //public string jldw { get; set; } // 需要返回 |
| | | |
| | | ///// <summary> |
| | | ///// 发货日期 |
| | | ///// </summary> |
| | | //public long fhrq { get; set; } // 需要返回 |
| | | |
| | | ///// <summary> |
| | | ///// 仓库代码 |
| | | ///// </summary> |
| | | //public string ckdm { get; set; } // 需要返回 |
| | | |
| | | ///// <summary> |
| | | ///// 发货人 |
| | | ///// </summary> |
| | | //public string fhr { get; set; } // 需要返回 |
| | | |
| | | ///// <summary> |
| | | ///// 操作员 |
| | | ///// </summary> |
| | | //public string czydm { get; set; } // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 审核人 |
| | | /// </summary> |
| | | public string shr_username { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 审核日期 |
| | | /// </summary> |
| | | public long shrq { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 作废标记 |
| | | /// </summary> |
| | | public long zfbj { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 作废日期 |
| | | /// </summary> |
| | | public long zfrq { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 结算单位 |
| | | /// </summary> |
| | | public string jsdw { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 收货单位 |
| | | /// </summary> |
| | | public string shdw { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 运输单位 |
| | | /// </summary> |
| | | public string ysdw { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 联系人 |
| | | /// </summary> |
| | | public string lxr { get; set; } |
| | | |
| | | ///// <summary> |
| | | ///// 装卸工 |
| | | ///// </summary> |
| | | //public string ry_zxg { get; set; } // 需要返回 |
| | | |
| | | ///// <summary> |
| | | ///// 叉车司机 |
| | | ///// </summary> |
| | | //public string ry_ccsj { get; set; } // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// erp交货单号 |
| | | /// </summary> |
| | | public string erphx_jhdh { get; set; } |
| | | |
| | | /// <summary> |
| | | /// erp物料编码 |
| | | /// </summary> |
| | | public string erphx_wlbm { get; set; } |
| | | |
| | | /// <summary> |
| | | /// erp物料名称 |
| | | /// </summary> |
| | | public string erphx_wlmc { get; set; } |
| | | |
| | | /// <summary> |
| | | /// erp创建日期 |
| | | /// </summary> |
| | | public string erphx_cjrq { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 货位 |
| | | /// </summary> |
| | | public string hw { get; set; } // 需要返回 |
| | | |
| | | /// <summary> |
| | | /// 货位状态 |
| | | /// </summary> |
| | | public string hwzt { get; set; } // 需要返回 |
| | | } |
| | | } |
| | | } |
| | |
| | | return NewSimpleResult(3, preLog + LogMsg.EndLocNotFound(model.EndLoc, null, -1)); |
| | | } |
| | | |
| | | var task = WCSHelper.BuildTaskWithLocLock(startLoc, endLoc, model.CntId, taskInfo.TaskName); |
| | | var task = WCSHelper.BuildTaskAndLockLoc(startLoc, endLoc, model.CntId, taskInfo.TaskName); |
| | | |
| | | (ok, msg) = DbTran.CreateTask(new CreateTaskObj { |
| | | StartLocToUpdate = startLoc, |
| | |
| | | return ApiHelper.FinishedOutbound(model); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | |
| | | |
| | | public static void CheckOutboundOrder() { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | var taskInfo = Settings.GetTaskInfo(ETask.C成品胶出库); |
| | | var (ok, msg) = (false, string.Empty); |
| | | |
| | | var taskInfo = ETask.C成品胶出库.Info(); |
| | | var taskName = "出库"; |
| | | const string preLog = "轮询:出库:"; |
| | | |
| | |
| | | } |
| | | |
| | | detail.N_B_STATE = 2; |
| | | detail.T_MODIFY = DateTime.Now; |
| | | |
| | | var cntId = detail.S_CNTR_CODE; |
| | | |
| | | var task = WCSHelper.BuildTaskWithLocLock(startLoc, endLoc, cntId, taskName); |
| | | var task = WCSHelper.BuildTaskAndLockLoc(startLoc, endLoc, detail.S_CNTR_CODE, taskName); |
| | | task.S_OP_CODE = detail.S_OO_NO; |
| | | if (string.IsNullOrEmpty(detail.S_BS_NO)) { |
| | | task.S_BS_NO = detail.S_BS_NO; |
| | | task.S_BS_TYPE = "ERP"; |
| | | } |
| | | |
| | | using (var tran = db.Ado.UseTran()) { |
| | | if (db.Updateable(detail).UpdateColumns(it => it.N_B_STATE).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | LogHelper.Info($"轮询:{taskName}:修改明细表状态为完成--失败!"); |
| | | continue; |
| | | } |
| | | |
| | | // 更新[起点/终点]锁状态,创建任务 |
| | | if (db.Updateable(startLoc).UpdateColumns(it => new { it.N_LOCK_STATE, it.S_LOCK_STATE, it.S_LOCK_OP, it.T_MODIFY, it.N_CURRENT_NUM, }).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | LogHelper.Info(preLog + $"更新[起点货位锁状态]失败!起点='{startLoc.S_CODE}',锁状态=>'出库锁'"); |
| | | } |
| | | if (db.Updateable(endLoc).UpdateColumns(it => new { it.N_LOCK_STATE, it.S_LOCK_STATE, it.S_LOCK_OP, it.T_MODIFY, }).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | LogHelper.Info(preLog + $"更新[终点货位锁状态]失败!终点='{endLoc.S_CODE}',锁状态=>'入库锁'"); |
| | | } |
| | | if (db.Insertable(task).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | LogHelper.Info(preLog + $"生成任务'{task.S_TYPE}'失败!任务号={task.S_CODE},容器号={task.S_CNTR_CODE},起点={task.S_START_LOC},终点={task.S_END_LOC}"); |
| | | } |
| | | |
| | | // 提交数据库更改 |
| | | tran.CommitTran(); |
| | | LogHelper.Info(preLog + $"生成任务'{task.S_TYPE}'成功!任务号={task.S_CODE},容器号={task.S_CNTR_CODE},起点={task.S_START_LOC},终点={task.S_END_LOC}"); |
| | | } |
| | | (ok, msg) = DbTran.CreateTaskOrderObj(new CreateTaskOrderObj { |
| | | OutboundDetailToUpdate = detail, |
| | | StartLocToUpdate = startLoc, |
| | | EndLocToUpdate = endLoc, |
| | | TaskToInsert = task, |
| | | }); |
| | | LogHelper.Info(preLog + msg); |
| | | |
| | | // 如果当前出库单明细是ERP下发的,任务创建完成反馈货位信息 |
| | | if (detail.S_BS_TYPE == "ERP") { |
| | |
| | | |
| | | public static void CheckCheckOrder() { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | var taskInfo = Settings.GetTaskInfo(ETask.C抽检出库); |
| | | var (ok, msg) = (false, string.Empty); |
| | | |
| | | var taskInfo = ETask.C抽检出库.Info(); |
| | | var taskName = taskInfo.TaskName; |
| | | const string preLog = "轮询:抽检:"; |
| | | |
| | |
| | | } |
| | | |
| | | detail.N_B_STATE = 2; |
| | | detail.T_MODIFY = DateTime.Now; |
| | | |
| | | var cntId = detail.S_CNTR_CODE; |
| | | var task = WCSHelper.BuildTaskWithLocLock(startLoc, endLoc, cntId, taskName); |
| | | var task = WCSHelper.BuildTaskAndLockLoc(startLoc, endLoc, cntId, taskName); |
| | | task.S_OP_CODE = detail.S_OO_NO; |
| | | |
| | | using (var tran = db.Ado.UseTran()) { |
| | | if (db.Updateable(detail).UpdateColumns(it => it.N_B_STATE).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | LogHelper.Info(preLog + $"修改{taskName}单明细表状态为完成--失败!"); |
| | | continue; |
| | | } |
| | | |
| | | if (db.Updateable(startLoc).UpdateColumns(it => new { it.N_LOCK_STATE, it.S_LOCK_STATE, it.S_LOCK_OP, it.T_MODIFY, it.N_CURRENT_NUM, }).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | LogHelper.Info(preLog + $"更新[起点货位锁状态]失败!起点='{startLoc.S_CODE}',锁状态=>'出库锁'"); |
| | | continue; |
| | | } |
| | | |
| | | if (db.Updateable(endLoc).UpdateColumns(it => new { it.N_LOCK_STATE, it.S_LOCK_STATE, it.S_LOCK_OP, it.T_MODIFY, }).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | LogHelper.Info(preLog + $"更新[终点货位锁状态]失败!终点='{endLoc.S_CODE}',锁状态=>'入库锁'"); |
| | | continue; |
| | | } |
| | | |
| | | if (db.Insertable(task).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | LogHelper.Info(preLog + $"生成任务'{taskName}'失败,任务号={task.S_CODE},容器号={cntId},起点={startLoc.S_CODE},终点={endLoc.S_CODE}"); |
| | | continue; |
| | | } |
| | | |
| | | tran.CommitTran(); |
| | | LogHelper.Info(preLog + $"生成任务'{taskName}'成功,任务号={task.S_CODE},容器号={cntId},起点={startLoc.S_CODE},终点={endLoc.S_CODE}"); |
| | | continue; |
| | | } |
| | | (ok, msg) = DbTran.CreateTaskOrderObj(new CreateTaskOrderObj { |
| | | SpotCheckDetailToUpdate = detail, |
| | | StartLocToUpdate = startLoc, |
| | | EndLocToUpdate = endLoc, |
| | | TaskToInsert = task, |
| | | }); |
| | | LogHelper.Info(preLog + msg); |
| | | } |
| | | } |
| | | catch (Exception ex) { |
| | |
| | | |
| | | public static void CheckShiftOrder() { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | var taskInfo = Settings.GetTaskInfo(ETask.Y移库); |
| | | var (ok, msg) = (false, string.Empty); |
| | | |
| | | var taskInfo = ETask.Y移库.Info(); |
| | | var taskName = taskInfo.TaskName; |
| | | const string preLog = "轮询:移库:"; |
| | | |
| | |
| | | } |
| | | |
| | | foreach (var detail in detailList) { |
| | | var startLoc = db.Queryable<TN_Location>() |
| | | .LeftJoin<TN_Loc_Container>((l, c) => l.S_CODE == c.S_LOC_CODE) |
| | | .Where((l, c) => c.S_CNTR_CODE == detail.S_CNTR_CODE) |
| | | .Where(l => l.N_LOCK_STATE == 0 && l.S_LOCK_STATE == "无" && l.C_ENABLE == "Y") // 筛选:未上锁 |
| | | .Where(l => l.N_CURRENT_NUM == 1) |
| | | .First(); |
| | | var startLoc = db.Queryable<TN_Location>().LeftJoin<TN_Loc_Container>((l, c) => l.S_CODE == c.S_LOC_CODE) |
| | | .Where(DbExpr.StartLoc()).Where((l, c) => c.S_CNTR_CODE == detail.S_CNTR_CODE).First(); |
| | | |
| | | if (startLoc == null) { |
| | | LogHelper.Info(preLog + $"没有找到终点货位={detail.S_END_AREA}的终点货位!需要满足:未上锁,当前容器数量=0"); |
| | | LogHelper.Info(preLog + LogMsg.StartLocNotFound() + $"绑定容器='{detail.S_CNTR_CODE}'"); |
| | | continue; |
| | | } |
| | | |
| | | var endLoc = db.Queryable<TN_Location>() |
| | | .Where(l => l.S_AREA_CODE == detail.S_END_AREA) |
| | | .Where(a => a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "无" && a.C_ENABLE == "Y") // 筛选:未上锁 |
| | | .Where(a => a.N_CURRENT_NUM == 0).First(); |
| | | |
| | | .Where(DbExpr.EndLoc(areas: new List<string> { detail.S_END_AREA })).First(); |
| | | if (endLoc == null) { |
| | | LogHelper.Info(preLog + $"没有找到终点货位={detail.S_END_AREA}的终点货位!需要满足:未上锁,当前容器数量=0"); |
| | | LogHelper.Info(preLog + LogMsg.EndLocNotFound(areas: new List<string> { detail.S_END_AREA })); |
| | | continue; |
| | | } |
| | | |
| | | detail.N_B_STATE = 2; |
| | | detail.T_MODIFY = DateTime.Now; |
| | | |
| | | var cntId = detail.S_CNTR_CODE; |
| | | var task = WCSHelper.BuildTaskWithLocLock(startLoc, endLoc, cntId, taskName); |
| | | var task = WCSHelper.BuildTaskAndLockLoc(startLoc, endLoc, cntId, taskName); |
| | | task.S_OP_CODE = detail.S_OO_NO; |
| | | |
| | | using (var tran = db.Ado.UseTran()) { |
| | | if (db.Updateable(detail).UpdateColumns(it => it.N_B_STATE).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | LogHelper.Info($"轮询:{taskName}:修改{taskName}单明细表状态为完成--失败!"); |
| | | continue; |
| | | } |
| | | |
| | | if (db.Updateable(startLoc).UpdateColumns(it => new { it.N_LOCK_STATE, it.S_LOCK_STATE, it.S_LOCK_OP, it.T_MODIFY, it.N_CURRENT_NUM, }).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | LogHelper.Info(preLog + $"更新[起点货位锁状态]失败!起点='{startLoc.S_CODE}',锁状态=>'出库锁'"); |
| | | continue; |
| | | } |
| | | |
| | | if (db.Updateable(endLoc).UpdateColumns(it => new { it.N_LOCK_STATE, it.S_LOCK_STATE, it.S_LOCK_OP, it.T_MODIFY, }).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | LogHelper.Info(preLog + $"更新[终点货位锁状态]失败!终点='{endLoc.S_CODE}',锁状态=>'入库锁'"); |
| | | continue; |
| | | } |
| | | |
| | | if (db.Insertable(task).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | LogHelper.Info(preLog + $"生成任务'{taskName}'失败,任务号={task.S_CODE},容器号={cntId},起点={startLoc.S_CODE},终点={endLoc.S_CODE}"); |
| | | continue; |
| | | } |
| | | |
| | | tran.CommitTran(); |
| | | LogHelper.Info(preLog + $"生成任务'{taskName}'成功,任务号={task.S_CODE},容器号={cntId},起点={startLoc.S_CODE},终点={endLoc.S_CODE}"); |
| | | continue; |
| | | } |
| | | (ok, msg) = DbTran.CreateTaskOrderObj(new CreateTaskOrderObj { |
| | | RelocationDetailToUpdate = detail, |
| | | StartLocToUpdate = startLoc, |
| | | EndLocToUpdate = endLoc, |
| | | TaskToInsert = task, |
| | | }); |
| | | LogHelper.Info(preLog + msg); |
| | | } |
| | | } |
| | | catch (Exception ex) { |
| | |
| | | LogHelper.Info($"计划单号{task.S_BS_NO}不存在!"); |
| | | } |
| | | |
| | | var model = new OtherModel.CreateTaskReturnErpInfo { |
| | | var model = new ErpModel.CreateTaskReturnErpInfo { |
| | | jhdh = plan.JHDH , // 计划单号 (唯一标识) |
| | | ckzt = plan.CKZT , // 出库状态 (需要返回) |
| | | jhlb = plan.JHLB , // 计划类别 |
| | |
| | | try { |
| | | ModbusHelper.Relink(); |
| | | |
| | | var BZQ = Settings.GetTaskInfo(ETask.M满托下线入库).StartAreas; |
| | | var BZQ = ETask.M满托下线入库.StartAreas(); |
| | | var loc = db.Queryable<TN_Location>() |
| | | .Where(l => BZQ.Contains(l.S_AREA_CODE) && l.S_AGV_SITE == model.station_name).First(); |
| | | |
| | |
| | | LogHelper.Info($"物料编码不存在!"); |
| | | } |
| | | |
| | | var model = new OtherModel.PickUpReturnErpInfo { |
| | | var model = new ErpModel.PickUpReturnErpInfo { |
| | | jhdh = plan.JHDH, // 计划单号 (唯一标识) |
| | | ckzt = plan.CKZT, // 出库状态 (需要返回) |
| | | jhlb = plan.JHLB, // 计划类别 |
| | |
| | | public static (bool, string) CreateInboundTask(string startLocCode, string cntrCode) { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | |
| | | var taskInfo = Settings.GetTaskInfo(ETask.M满托下线入库); |
| | | var taskName = taskInfo.TaskName; |
| | | var startAreas = taskInfo.StartAreas; |
| | | var endAreas = taskInfo.EndAreas; |
| | | var tInfo = ETask.M满托下线入库.Info(); |
| | | var taskName = tInfo.TaskName; |
| | | var startAreas = tInfo.StartAreas; |
| | | var endAreas = tInfo.EndAreas; |
| | | const string cntrType = "托盘"; |
| | | |
| | | try { |
| | |
| | | } |
| | | |
| | | var cntId = locCntrRel.S_CNTR_CODE; |
| | | var task = WCSHelper.BuildTaskWithLocLock(startLoc, endLoc, cntId, taskName); |
| | | var task = WCSHelper.BuildTaskAndLockLoc(startLoc, endLoc, cntId, taskName); |
| | | |
| | | using (var tran = db.Ado.UseTran()) { |
| | | if (locCntrRelOld != null) { |
| | |
| | | using Org.BouncyCastle.Utilities.Net; |
| | | using System.Web.UI.WebControls.WebParts; |
| | | using System.Linq; |
| | | |
| | | using TcpClient = System.Net.Sockets.TcpClient; |
| | | using System.IO; |
| | | using HH.WCS.Mobox3.DSZSH.util; |
| | |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | |
| | | using EasyModbus; |
| | | |
| | | using HH.WCS.Mobox3.DSZSH.util; |
| | | |
| | | namespace HH.WCS.Mobox3.DSZSH.device { |
| | |
| | | using Opc.Ua.Configuration; |
| | | using HH.WCS.Mobox3.DSZSH.util; |
| | | |
| | | |
| | | namespace HH.WCS.Mobox3.DSZSH.device |
| | | { |
| | | internal class OpcUaHelper |
| | | { |
| | | namespace HH.WCS.Mobox3.DSZSH.device { |
| | | internal class OpcUaHelper { |
| | | private static Opc.Ua.Client.Session session; |
| | | |
| | | static OpcUaHelper() |
| | | { |
| | | static OpcUaHelper() { |
| | | CreateUpcSession(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 连接OPC服务 |
| | | /// </summary> |
| | | internal static async void CreateUpcSession() |
| | | { |
| | | try |
| | | { |
| | | internal static async void CreateUpcSession() { |
| | | try { |
| | | // 创建一个应用配置对象,用于设置应用名称,唯一标识,类型,证书和安全策略 |
| | | var config = new ApplicationConfiguration() |
| | | { |
| | | var config = new ApplicationConfiguration() { |
| | | ApplicationName = "MyClient", |
| | | ApplicationUri = Utils.Format(@"urn:{0}:MyClient", System.Net.Dns.GetHostName()), |
| | | ApplicationType = ApplicationType.Client, |
| | | SecurityConfiguration = new SecurityConfiguration |
| | | { |
| | | SecurityConfiguration = new SecurityConfiguration { |
| | | ApplicationCertificate = new CertificateIdentifier { StoreType = @"Directory", StorePath = @"%CommonApplicationData%\OPC Foundation\CertificateStores\MachineDefault", SubjectName = "MyClientSubjectName" }, |
| | | TrustedIssuerCertificates = new CertificateTrustList { StoreType = @"Directory", StorePath = @"%CommonApplicationData%\OPC Foundation\CertificateStores\UA Certificate Authorities" }, |
| | | TrustedPeerCertificates = new CertificateTrustList { StoreType = @"Directory", StorePath = @"%CommonApplicationData%\OPC Foundation\CertificateStores\UA Applications" }, |
| | |
| | | await config.Validate(ApplicationType.Client); |
| | | |
| | | // 设置证书验证事件,用于自动接受不受信任的证书 |
| | | if (config.SecurityConfiguration.AutoAcceptUntrustedCertificates) |
| | | { |
| | | if (config.SecurityConfiguration.AutoAcceptUntrustedCertificates) { |
| | | config.CertificateValidator.CertificateValidation += (s, e) => { e.Accept = (e.Error.StatusCode == StatusCodes.BadCertificateUntrusted); }; |
| | | } |
| | | |
| | |
| | | EndpointConfiguration endpointConfiguration = EndpointConfiguration.Create(config); |
| | | ConfiguredEndpoint endpoint = new ConfiguredEndpoint(null, endpointDescription, endpointConfiguration); |
| | | session = await Session.Create(config, endpoint, false, false, "DataCollector", 60000, new UserIdentity(), null); |
| | | if (session != null && session.Connected) |
| | | { |
| | | if (session != null && session.Connected) { |
| | | Console.WriteLine("The session is connected to the OPC UA server."); |
| | | LogHelper.Info($"创建OPC连接成功", "OPC"); |
| | | } |
| | | else |
| | | { |
| | | else { |
| | | Console.WriteLine("The session is not connected to the OPC UA server."); |
| | | LogHelper.Info($"创建OPC连接失败", "OPC"); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | catch (Exception e) { |
| | | LogHelper.Info($"连接OPC服务异常" + e.Message, "OPC"); |
| | | } |
| | | } |
| | |
| | | /// 读取OPC节点数据 |
| | | /// </summary> |
| | | /// <param name="nodeId"></param> |
| | | internal static object ReadOpcValue(string nodeId) |
| | | { |
| | | try |
| | | { |
| | | if (session != null && session.Connected) |
| | | { |
| | | internal static object ReadOpcValue(string nodeId) { |
| | | try { |
| | | if (session != null && session.Connected) { |
| | | // 读取数据节点 |
| | | DataValue item = session.ReadValue(nodeId: nodeId); |
| | | LogHelper.Info($"OPC读取:nodeid:{nodeId},value:{item.Value}", "OPC"); |
| | | return item.Value; |
| | | } |
| | | else |
| | | { |
| | | else { |
| | | Console.WriteLine("The session is not connected to the OPC UA server."); |
| | | LogHelper.Info($"OPC连接失败", "OPC"); |
| | | CreateUpcSession(); |
| | | } |
| | | |
| | | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | catch (Exception e) { |
| | | |
| | | LogHelper.Info($"读取OPC数据异常" + e.Message, "OPC"); |
| | | } |
| | |
| | | /// </summary> |
| | | /// <param name="nodeId"></param> |
| | | /// <param name="val"></param> |
| | | internal static void WriteOpcValue(string nodeId,bool val) |
| | | { |
| | | try |
| | | { |
| | | if (session != null && session.Connected) |
| | | { |
| | | internal static void WriteOpcValue(string nodeId, bool val) { |
| | | try { |
| | | if (session != null && session.Connected) { |
| | | // 写入数据到节点 |
| | | WriteValue writeValue = new WriteValue |
| | | { |
| | | WriteValue writeValue = new WriteValue { |
| | | NodeId = new NodeId(nodeId), |
| | | AttributeId = Attributes.Value, |
| | | Value = new DataValue(val) |
| | |
| | | Console.WriteLine($"Write Status for {nodeId}: {results[0]}"); |
| | | LogHelper.Info($"OPC写入:nodeid:{nodeId},value:{val}", "OPC"); |
| | | } |
| | | else |
| | | { |
| | | else { |
| | | Console.WriteLine("The session is not connected to the OPC UA server."); |
| | | LogHelper.Info($"OPC连接失败", "OPC"); |
| | | CreateUpcSession(); |
| | | } |
| | | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | catch (Exception e) { |
| | | LogHelper.Info($"写入OPC数据异常" + e.Message, "OPC"); |
| | | } |
| | | } |
| | |
| | | /// </summary> |
| | | /// <param name="nodeId"></param> |
| | | /// <param name="val"></param> |
| | | internal static void WriteOpcValue(string nodeId, int val) |
| | | { |
| | | try |
| | | { |
| | | if (session != null && session.Connected) |
| | | { |
| | | internal static void WriteOpcValue(string nodeId, int val) { |
| | | try { |
| | | if (session != null && session.Connected) { |
| | | // 写入数据到节点 |
| | | WriteValue writeValue = new WriteValue |
| | | { |
| | | WriteValue writeValue = new WriteValue { |
| | | NodeId = new NodeId(nodeId), |
| | | AttributeId = Attributes.Value, |
| | | Value = new DataValue(val) |
| | |
| | | Console.WriteLine($"Write Status for {nodeId}: {results[0]}"); |
| | | LogHelper.Info($"OPC写入:nodeid:{nodeId},value:{val}", "OPC"); |
| | | } |
| | | else |
| | | { |
| | | else { |
| | | Console.WriteLine("The session is not connected to the OPC UA server."); |
| | | LogHelper.Info($"OPC连接失败", "OPC"); |
| | | CreateUpcSession(); |
| | | } |
| | | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | catch (Exception e) { |
| | | LogHelper.Info($"写入OPC数据异常" + e.Message, "OPC"); |
| | | } |
| | | } |
| | |
| | | using System.Collections.Generic; |
| | | using System.Web.Caching; |
| | | using HH.WCS.Mobox3.DSZSH.models; |
| | | |
| | | using HH.WCS.Mobox3.DSZSH.util; |
| | | using static HH.WCS.Mobox3.DSZSH.api.ApiModel; |
| | | |
| | |
| | | using HH.WCS.Mobox3.DSZSH.util; |
| | | |
| | | using Newtonsoft.Json; |
| | | using System; |
| | | using System.Collections.Generic; |
| | |
| | | using HH.WCS.Mobox3.DSZSH.util; |
| | | |
| | | using Newtonsoft.Json; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Text; |
| | | using System.Xml; |
| | | |
| | | namespace HH.WCS.Mobox3.DSZSH.dispatch |
| | | { |
| | | public class NDC |
| | | { |
| | | namespace HH.WCS.Mobox3.DSZSH.dispatch { |
| | | public class NDC { |
| | | private static HostToAGV callClient = null; |
| | | static NDC() { |
| | | callClient = new HostToAGV(); |
| | |
| | | sb.Append("/></Req>"); |
| | | return sb.ToString(); |
| | | } |
| | | public static AGVResult AddNewOrder(int ts, Dictionary<string, string> param) |
| | | { |
| | | public static AGVResult AddNewOrder(int ts, Dictionary<string, string> param) { |
| | | //< Req >< Order TS = '1' Pri = '1' No = 'TN2302020001' Ext1 = '' Ext2 = '' N_CNTR_COUNT = '' >< Param Name = 'From' Value = '2' />< Param Name = 'To' Value = '1' /></ Order ></ Req > |
| | | |
| | | var bufin = GetReqStr(ts, param); |
| | |
| | | var json = JsonConvert.SerializeXmlNode(xml); |
| | | return JsonConvert.DeserializeObject<AGVResult>(json); |
| | | } |
| | | public class AGVResult |
| | | { |
| | | public class AGVResult { |
| | | public Res Res { get; set; } |
| | | } |
| | | public class Res |
| | | { |
| | | public class Res { |
| | | public int ErrCode { get; set; } |
| | | public string ErrInfo { get; set; } |
| | | } |
| | |
| | | using HH.WCS.Mobox3.DSZSH; |
| | | using HH.WCS.Mobox3.DSZSH.util; |
| | | |
| | | using Newtonsoft.Json; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Text; |
| | | using System.Xml; |
| | | |
| | | namespace HH.WCS.Mobox3.DSZSH.dispatch |
| | | { |
| | | namespace HH.WCS.Mobox3.DSZSH.dispatch { |
| | | /// <summary> |
| | | /// NDC的API接口,用于替代原NDC,NDCHelper和HostToAGV模块 |
| | | /// </summary> |
| | | public class NDCApi |
| | | { |
| | | public class NDCApi { |
| | | public static string NDCApiUrl { set; get; } |
| | | static NDCApi() |
| | | { |
| | | static NDCApi() { |
| | | NDCApiUrl = Settings.NdcApiUrl; |
| | | } |
| | | |
| | | |
| | | public static AgvApiResult AddOrderNew(int ts, int pri, string taskNo, List<param> param) |
| | | { |
| | | public static AgvApiResult AddOrderNew(int ts, int pri, string taskNo, List<param> param) { |
| | | var httpH = new HttpHelper(); |
| | | var agvApiResult = new AgvApiResult(); |
| | | var model = new AddOrderNewModel(); |
| | |
| | | model.pri = pri; |
| | | model.task_no = taskNo; |
| | | model.param = param; |
| | | try |
| | | { |
| | | try { |
| | | string jsonInfo = JsonConvert.SerializeObject(model); |
| | | LogHelper.Info($"NDC任务下发:{taskNo}\n\n{jsonInfo}\n", "NDC"); |
| | | var result = httpH.WebPost(NDCApiUrl + "Add", jsonInfo); |
| | |
| | | agvApiResult = JsonConvert.DeserializeObject<AgvApiResult>(result); |
| | | return agvApiResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | catch (Exception e) { |
| | | LogHelper.Info($"任务下发失败:res='{e.Message}'", "NDC"); |
| | | agvApiResult.err_code = -1; |
| | | agvApiResult.err_msg = e.Message; |
| | |
| | | } |
| | | } |
| | | |
| | | public static AgvApiResult AddOrderNew(AddOrderNewModel model) |
| | | { |
| | | public static AgvApiResult AddOrderNew(AddOrderNewModel model) { |
| | | var httpH = new HttpHelper(); |
| | | var agvApiResult = new AgvApiResult(); |
| | | |
| | | try |
| | | { |
| | | try { |
| | | string jsonInfo = JsonConvert.SerializeObject(model); |
| | | LogHelper.Info($"任务{model.task_no}下发,{jsonInfo}", "NDC"); |
| | | |
| | |
| | | agvApiResult = JsonConvert.DeserializeObject<AgvApiResult>(result); |
| | | return agvApiResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | catch (Exception e) { |
| | | LogHelper.Info($"任务下发失败 res={e.Message}", "NDC"); |
| | | agvApiResult.err_code = -1; |
| | | agvApiResult.err_msg = e.Message; |
| | |
| | | } |
| | | } |
| | | |
| | | public static AgvApiResult CancelOrder(string tsNo, bool is_force = true) |
| | | { |
| | | public static AgvApiResult CancelOrder(string tsNo, bool is_force = true) { |
| | | var httpH = new HttpHelper(); |
| | | var agvApiResult = new AgvApiResult(); |
| | | var model = new CancelOrderModel(); |
| | | model.task_no = tsNo; |
| | | model.is_force = is_force; |
| | | try |
| | | { |
| | | try { |
| | | string jsonInfo = JsonConvert.SerializeObject(model); |
| | | LogHelper.Info($"任务{model.task_no}取消,{jsonInfo}", "NDC"); |
| | | |
| | |
| | | agvApiResult = JsonConvert.DeserializeObject<AgvApiResult>(result); |
| | | return agvApiResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | catch (Exception e) { |
| | | LogHelper.Info($"CancelOrder res={e.Message}", "NDC"); |
| | | agvApiResult.err_code = -1; |
| | | agvApiResult.err_msg = e.Message; |
| | |
| | | } |
| | | } |
| | | |
| | | public static AgvApiResult CancelOrder(CancelOrderModel model) |
| | | { |
| | | public static AgvApiResult CancelOrder(CancelOrderModel model) { |
| | | var httpH = new HttpHelper(); |
| | | var agvApiResult = new AgvApiResult(); |
| | | try |
| | | { |
| | | try { |
| | | string jsonInfo = JsonConvert.SerializeObject(model); |
| | | LogHelper.Info($"任务{model.task_no}取消,{jsonInfo}", "NDC"); |
| | | |
| | |
| | | agvApiResult = JsonConvert.DeserializeObject<AgvApiResult>(result); |
| | | return agvApiResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | catch (Exception e) { |
| | | LogHelper.Info($"CancelOrder res={e.Message}", "NDC"); |
| | | agvApiResult.err_code = -1; |
| | | agvApiResult.err_msg = e.Message; |
| | |
| | | |
| | | } |
| | | |
| | | public static AgvApiResult ChangeOrderPri(string taskNo, int newPri) |
| | | { |
| | | public static AgvApiResult ChangeOrderPri(string taskNo, int newPri) { |
| | | var httpH = new HttpHelper(); |
| | | var agvApiResult = new AgvApiResult(); |
| | | var model = new ChangePriModel(); |
| | | model.task_no = taskNo; |
| | | model.pri = newPri; |
| | | try |
| | | { |
| | | try { |
| | | string jsonInfo = JsonConvert.SerializeObject(model); |
| | | LogHelper.Info($"任务{model.task_no}优先级更改,{jsonInfo}", "NDC"); |
| | | |
| | |
| | | agvApiResult = JsonConvert.DeserializeObject<AgvApiResult>(result); |
| | | return agvApiResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | catch (Exception e) { |
| | | LogHelper.Info($"ChangeOrderPri res={e.Message}", "NDC"); |
| | | agvApiResult.err_code = -1; |
| | | agvApiResult.err_msg = e.Message; |
| | |
| | | } |
| | | } |
| | | |
| | | public static AgvApiResult ChangeOrderPri(ChangePriModel model) |
| | | { |
| | | public static AgvApiResult ChangeOrderPri(ChangePriModel model) { |
| | | var httpH = new HttpHelper(); |
| | | var agvApiResult = new AgvApiResult(); |
| | | try |
| | | { |
| | | try { |
| | | string jsonInfo = JsonConvert.SerializeObject(model); |
| | | LogHelper.Info($"任务{model.task_no}优先级更改,{jsonInfo}", "NDC"); |
| | | |
| | |
| | | agvApiResult = JsonConvert.DeserializeObject<AgvApiResult>(result); |
| | | return agvApiResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | catch (Exception e) { |
| | | LogHelper.Info($"ChangeOrderPri res={e.Message}", "NDC"); |
| | | agvApiResult.err_code = -1; |
| | | agvApiResult.err_msg = e.Message; |
| | |
| | | } |
| | | } |
| | | |
| | | public static AgvApiResult ChangeOrderParam(string taskNo, int paramNo, string paramStr) |
| | | { |
| | | public static AgvApiResult ChangeOrderParam(string taskNo, int paramNo, string paramStr) { |
| | | var httpH = new HttpHelper(); |
| | | var agvApiResult = new AgvApiResult(); |
| | | var model = new ChangeParamModel(); |
| | | model.task_no = taskNo; |
| | | model.param_no = paramNo; |
| | | model.param = paramStr; |
| | | try |
| | | { |
| | | try { |
| | | string jsonInfo = JsonConvert.SerializeObject(model); |
| | | LogHelper.Info($"任务{model.task_no}参数更改,{jsonInfo}", "NDC"); |
| | | |
| | |
| | | agvApiResult = JsonConvert.DeserializeObject<AgvApiResult>(result); |
| | | return agvApiResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | catch (Exception e) { |
| | | LogHelper.Info($"ChangeOrderParam res={e.Message}", "NDC"); |
| | | agvApiResult.err_code = -1; |
| | | agvApiResult.err_msg = e.Message; |
| | |
| | | } |
| | | } |
| | | |
| | | public static AgvApiResult ChangeOrderParam(ChangeParamModel model) |
| | | { |
| | | public static AgvApiResult ChangeOrderParam(ChangeParamModel model) { |
| | | var httpH = new HttpHelper(); |
| | | var agvApiResult = new AgvApiResult(); |
| | | try |
| | | { |
| | | try { |
| | | string jsonInfo = JsonConvert.SerializeObject(model); |
| | | LogHelper.Info($"任务{model.task_no}参数更改,{jsonInfo}", "NDC"); |
| | | |
| | |
| | | agvApiResult = JsonConvert.DeserializeObject<AgvApiResult>(result); |
| | | return agvApiResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | catch (Exception e) { |
| | | LogHelper.Info($"ChangeOrderParam res={e.Message}", "NDC"); |
| | | agvApiResult.err_code = -1; |
| | | agvApiResult.err_msg = e.Message; |
| | |
| | | /// <summary> |
| | | /// 返回信息Model |
| | | /// </summary> |
| | | public class AgvApiResult |
| | | { |
| | | public class AgvApiResult { |
| | | public int err_code { set; get; }//异常码:0 - 正常,其它值为异常错误码 |
| | | public string err_msg { set; get; }//返回的错误描述,在 err_code <> 0 时返回 |
| | | public object result { set; get; }//正确返回的结果内容,在 err_code = 0 且有返回内容时 |
| | | } |
| | | |
| | | public class AddOrderNewModel |
| | | { |
| | | public class AddOrderNewModel { |
| | | public int ts_no { set; get; }//TS 号,必须有值 |
| | | public int pri { set; get; }//优先级 |
| | | public string task_no { set; get; }//上游任务编码,如果 no_feedback = 1 时,可以为空 |
| | |
| | | } |
| | | |
| | | |
| | | public class param |
| | | { |
| | | public class param { |
| | | public string name { set; get; }//参数名 |
| | | public string value { set; get; }//参数值 |
| | | } |
| | | |
| | | public class CancelOrderModel |
| | | { |
| | | public class CancelOrderModel { |
| | | public string task_no { set; get; }//上游任务编码 |
| | | public bool is_force { set; get; } = true;//是否强制取消,1 – 强制 |
| | | } |
| | | |
| | | public class ChangeParamModel |
| | | { |
| | | public class ChangeParamModel { |
| | | public string task_no { set; get; }//上游任务编码 |
| | | public int param_no { set; get; }//参数号 |
| | | public string param { set; get; }//参数内容,多个参数以英文分号(;)分隔 |
| | | } |
| | | |
| | | public class ChangePriModel |
| | | { |
| | | public class ChangePriModel { |
| | | public string task_no { set; get; }//上游任务编码 |
| | | public int pri { set; get; }//新优先级 |
| | | } |
| | |
| | | using System.Collections.Generic; |
| | | using System.Text; |
| | | |
| | | namespace HH.WCS.Mobox3.DSZSH.dispatch |
| | | { |
| | | public class NDCHelper |
| | | { |
| | | namespace HH.WCS.Mobox3.DSZSH.dispatch { |
| | | public class NDCHelper { |
| | | public static void Test() { |
| | | //dic.Add("Ext1", ""); dic.Add("Ext2", ""); dic.Add("N_CNTR_COUNT", ""); |
| | | //var r = callClient.AddNewOrderAsync(new AddNewOrderRequest() { bufin = "<Req><Order Pri='1' TS='1' From='1' To='2' No='123471118_1' Ext1='1' Ext2='CALLADDAGV' N_CNTR_COUNT='' /></Req>" }); |
| | |
| | | public static void Init() { |
| | | // 加载配置文件 |
| | | LoadJson(); |
| | | |
| | | LoadProdLines(); |
| | | } |
| | | |
| | | private static void LoadJson() { |
| | | LogHelper.Info("加载配置文件信息 开始"); |
| | | LogHelper.Info("加载配置文件信息:开始!!"); |
| | | // JSON 文件路径 |
| | | string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "./config/config.json"); |
| | | |
| | |
| | | // 反序列化为 Config 对象 |
| | | var root = JsonConvert.DeserializeObject<Config.Root>(jsonContent); |
| | | |
| | | #region Config.Root 赋值字段部分 |
| | | WebApiUrl = root.WebApiUrl; |
| | | NdcApiUrl = root.NdcApiUrl; |
| | | ErpApiUrl = root.ErpApiUrl; |
| | | ErpRoute = root.ErpRoute; |
| | | TcpServerPort= root.TcpServerPort; |
| | | TcpServerPort = root.TcpServerPort; |
| | | DbConn = root.SqlServer; |
| | | //TcpServerIp = root.TcpServerIp; |
| | | //TcpServerPort = root.TcpServerPort; |
| | | ProductionLines = root.ProductionLines; |
| | | TaskInfos = root.TaskInfos; |
| | | |
| | | for (var i = 0; i < ProductionLines.Count; i++) { |
| | | if (ProductionLines[i].OnLoc == null) continue; |
| | | foreach (var onLoc in ProductionLines[i].OnLoc) { |
| | | LocProdIdMap.Add(onLoc, int.Parse(ProductionLines[i].Id)); |
| | | } |
| | | foreach (var offLoc in ProductionLines[i].OffLoc) { |
| | | LocProdIdMap.Add(offLoc, int.Parse(ProductionLines[i].Id)); |
| | | } |
| | | } |
| | | #endregion |
| | | } |
| | | catch (FileNotFoundException) { |
| | | LogHelper.Info("JSON 文件未找到"); |
| | | LogHelper.Info("JSON文件未找到!!", "Exception"); |
| | | } |
| | | catch (JsonException ex) { |
| | | LogHelper.Info($"JSON 解析错误: {ex.Message}"); |
| | | LogHelper.Info($"JSON解析错误!!Error:{ex.Message}\n\n{ex.StackTrace}\n", "Exception"); |
| | | } |
| | | catch (Exception ex) { |
| | | LogHelper.Info($"发生错误: {ex.Message}"); |
| | | LogHelper.InfoEx(ex, "Settings:"); |
| | | } |
| | | LogHelper.Info("加载配置文件信息 完成"); |
| | | LogHelper.Info("加载配置文件信息:完成!!"); |
| | | } |
| | | |
| | | private static void LoadProdLines() { |
| | | //var db = new SqlHelper<object>().GetInstance(); |
| | | //for (int i = 0; i < ProductionLines.Count; i++) { |
| | | // var line = ProductionLines[i]; |
| | | // // 通过OnLoc OffLoc找到AGVsite然后写入字典 |
| | | //} |
| | | } |
| | | |
| | | public static Config.TaskInfo GetTaskInfo(ETask eTask) { |
| | | return TaskInfos[(int)eTask]; |
| | | for (var i = 0; i < ProductionLines.Count; i++) { |
| | | if (ProductionLines[i].OnLoc == null) continue; |
| | | foreach (var onLoc in ProductionLines[i].OnLoc) { |
| | | LocProdIdMap.Add(onLoc, int.Parse(ProductionLines[i].Id)); |
| | | } |
| | | foreach (var offLoc in ProductionLines[i].OffLoc) { |
| | | LocProdIdMap.Add(offLoc, int.Parse(ProductionLines[i].Id)); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | return (true, $"生成任务'{obj.TaskToInsert.S_TYPE}'成功!!任务号='{obj.TaskToInsert.S_CODE}',容器号='{obj.TaskToInsert.S_CNTR_CODE}',起点='{obj.TaskToInsert.S_START_LOC}',终点='{obj.TaskToInsert.S_END_LOC}'"); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 数据库事务 : 涉及单据明细更新的任务创建 |
| | | /// </summary> |
| | | /// <param name="obj"></param> |
| | | /// <remarks><b>[ 要求 ]</b> obj ≠ null ; obj.TaskToInsert ≠ null</remarks> |
| | | /// <returns></returns> |
| | | /// <exception cref="ArgumentException"></exception> |
| | | public static (bool, string) CreateTaskOrderObj(CreateTaskOrderObj obj) { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | |
| | | using (var tran = db.Ado.UseTran()) { |
| | | |
| | | if (obj.OutboundDetailToUpdate != null && db.Updateable(obj.OutboundDetailToUpdate).UpdateColumns(it => new { it.N_B_STATE, it.T_MODIFY }).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | return (false, $"更新[明细表][状态]为[完成]失败!!数据:\n\n{JsonConvert.SerializeObject(obj.OutboundDetailToUpdate)}\n"); |
| | | } |
| | | |
| | | if (obj.SpotCheckDetailToUpdate != null && db.Updateable(obj.SpotCheckDetailToUpdate).UpdateColumns(it => new { it.N_B_STATE, it.T_MODIFY }).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | return (false, $"更新[明细表][状态]为[完成]失败!!数据:\n\n{JsonConvert.SerializeObject(obj.SpotCheckDetailToUpdate)}\n"); |
| | | } |
| | | |
| | | if (obj.RelocationDetailToUpdate != null && db.Updateable(obj.RelocationDetailToUpdate).UpdateColumns(it => new { it.N_B_STATE, it.T_MODIFY }).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | return (false, $"更新[明细表][状态]为[完成]失败!!数据:\n\n{JsonConvert.SerializeObject(obj.RelocationDetailToUpdate)}\n"); |
| | | } |
| | | |
| | | #region 创建任务 + 货位锁 |
| | | if (obj.StartLocToUpdate != null && db.Updateable(obj.StartLocToUpdate).UpdateColumns(it => new { it.N_LOCK_STATE, it.S_LOCK_STATE, it.S_LOCK_OP, it.T_MODIFY, it.N_CURRENT_NUM, }).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | return (false, $"更新[起点货位][锁状态]失败!!起点='{obj.StartLocToUpdate.S_CODE}',锁状态=>'{obj.StartLocToUpdate.S_LOCK_STATE}'"); |
| | | } |
| | | if (obj.EndLocToUpdate != null && db.Updateable(obj.EndLocToUpdate).UpdateColumns(it => new { it.N_LOCK_STATE, it.S_LOCK_STATE, it.S_LOCK_OP, it.T_MODIFY, }).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | return (false, $"更新[终点货位][锁状态]失败!!终点='{obj.EndLocToUpdate.S_CODE}',锁状态=>'{obj.EndLocToUpdate.S_LOCK_STATE}'"); |
| | | } |
| | | if (obj.TaskToInsert == null) { |
| | | tran.RollbackTran(); |
| | | throw new ArgumentException("数据库事务处理:待插入的[任务]为空!!"); // 待插入的任务不存在,直接抛出异常 |
| | | } |
| | | if (db.Insertable(obj.TaskToInsert).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | return (false, $"生成任务'{obj.TaskToInsert.S_TYPE}'失败!!任务号='{obj.TaskToInsert.S_CODE}',容器号='{obj.TaskToInsert.S_CNTR_CODE}',起点='{obj.TaskToInsert.S_START_LOC}',终点='{obj.TaskToInsert.S_END_LOC}'"); |
| | | } |
| | | #endregion |
| | | |
| | | // 提交数据库更改 |
| | | tran.CommitTran(); |
| | | return (true, $"生成任务'{obj.TaskToInsert.S_TYPE}'成功!!任务号='{obj.TaskToInsert.S_CODE}',容器号='{obj.TaskToInsert.S_CNTR_CODE}',起点='{obj.TaskToInsert.S_START_LOC}',终点='{obj.TaskToInsert.S_END_LOC}'"); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | public class CreateTaskObj { |
| | |
| | | public TN_CG_Detail CgDetailToUpdate { get; set; } = null; |
| | | } |
| | | |
| | | public class DbTranObj { |
| | | public List<TN_Location> LocListToUpdate { get; set; } |
| | | public class CreateTaskOrderObj { |
| | | |
| | | #region 起点货位 / 终点货位 / 任务 |
| | | public TN_Location StartLocToUpdate { get; set; } = null; |
| | | public TN_Location EndLocToUpdate { get; set; } = null; |
| | | public TN_Task TaskToInsert { get; set; } = null; |
| | | #endregion |
| | | |
| | | public TN_Outbound_Detail OutboundDetailToUpdate { get; set; } = null; |
| | | public TN_SpotCheck_Detail SpotCheckDetailToUpdate { get; set; } = null; |
| | | public TN_RelocationList_Detail RelocationDetailToUpdate { get; set; } = null; |
| | | } |
| | | |
| | | } |
| | |
| | | using System.Linq.Expressions; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | |
| | | using HH.WCS.Mobox3.DSZSH.models; |
| | | |
| | | using Newtonsoft.Json; |
| | | |
| | | namespace HH.WCS.Mobox3.DSZSH.util { |
| | | namespace HH.WCS.Mobox3.DSZSH.wms { |
| | | /// <summary> |
| | | /// [ 日志信息 ] 构造类 |
| | | /// </summary> |
| | |
| | | return loc == null ? "0" : loc.S_AGV_SITE; |
| | | } |
| | | #endregion |
| | | |
| | | #region 任务创建 / 下发 / 查询 |
| | | internal static string GenerateTaskNo() { |
| | | //var id = SYSHelper.GetSerialNumber("任务号", "TN"); |
| | | //var date = DateTime.Now.ToString("yyMMdd"); |
| | | //return $"TN{date}{id.ToString().PadLeft(4, '0')}"; |
| | | return SYSHelper.GenerateSN("任务号", "TN", "yyMMdd"); |
| | | } |
| | | |
| | | internal static bool UpdateTaskState(TN_Task task, string state) { |
| | | var res = false; |
| | | var db = new SqlHelper<TN_Task>().GetInstance(); |
| | | task.S_B_STATE = state; |
| | | res = db.Updateable(task).UpdateColumns(it => new { it.S_B_STATE }).ExecuteCommand() > 0; |
| | | return res; |
| | | } |
| | | |
| | | internal static bool UpdateTaskState(TN_Task task) { |
| | | var res = false; |
| | | var db = new SqlHelper<TN_Task>().GetInstance(); |
| | | task.S_B_STATE = TN_Task.GetStateStr(task.N_B_STATE); |
| | | task.T_MODIFY = DateTime.Now; |
| | | res = db.Updateable(task).UpdateColumns(it => new { it.N_B_STATE, it.S_B_STATE, it.T_MODIFY }).ExecuteCommand() > 0; |
| | | return res; |
| | | } |
| | | |
| | | internal static bool UpdateEqTaskNo(TN_Task task) { |
| | | var res = false; |
| | | var db = new SqlHelper<TN_Task>().GetInstance(); |
| | | task.T_MODIFY = DateTime.Now; |
| | | res = db.Updateable(task).UpdateColumns(it => new { it.S_EQ_TASK_CODE, it.T_MODIFY }).ExecuteCommand() > 0; |
| | | return res; |
| | | } |
| | | |
| | | internal static TN_Task GetTask(string taskNo) { |
| | | var db = new SqlHelper<TN_Task>().GetInstance(); |
| | | var task = db.Queryable<TN_Task>().Where(a => a.S_CODE == taskNo).First(); |
| | | return task; |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | private const bool __容器查询绑定模块__ = false; // 仅用于分段,没有实质意义 |
| | | #region 容器相关信息 查询 / 绑定 |
| | | /// <summary> |
| | | /// 根据 [ 容器号 ] , 查询当前容器关联的 [ 货位 ] [ 货位容器 ] [ 容器货品 ] 信息 ( 只查询 1 条 ) |
| | |
| | | loc.T_MODIFY = DateTime.Now; |
| | | |
| | | return locCntrRel; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | private const bool __创建任务模块__ = false; // 仅用于分段,没有实质意义 |
| | | #region 起点 / 终点货位锁 + 创建任务 |
| | | /// <summary> |
| | | /// 起点出库锁 |
| | |
| | | loc.T_MODIFY = System.DateTime.Now; |
| | | |
| | | LogHelper.Info($"终点入库锁:终点货位='{loc.S_CODE}',来源='{lockSource}'"); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 生成任务号(通常只被BuildTask使用,故设为私有) |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | private static string GenerateTaskNo() { |
| | | //var id = SYSHelper.GetSerialNumber("任务号", "TN"); |
| | | //var date = DateTime.Now.ToString("yyMMdd"); |
| | | //return $"TN{date}{id.ToString().PadLeft(4, '0')}"; |
| | | return SYSHelper.GenerateSN("任务号", "TN", "yyMMdd"); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <param name="pri">优先级</param> |
| | | /// <param name="agv">AGV 类型</param> |
| | | /// <returns></returns> |
| | | public static TN_Task BuildTaskWithLocLock(TN_Location startLoc, TN_Location endLoc, string cntId, string type, |
| | | public static TN_Task BuildTaskAndLockLoc(TN_Location startLoc, TN_Location endLoc, string cntId, string type, |
| | | int pri = 3, int agv = 1) { |
| | | |
| | | var task = BuildTask(startLoc, endLoc, cntId, type, pri); |
| | |
| | | |
| | | return task; |
| | | } |
| | | |
| | | |
| | | #endregion |
| | | |
| | | private const bool __任务分发处理模块__ = false; // 仅用于分段,没有实质意义 |
| | | #region 任务分发 / 执行 / 记录 |
| | | internal static bool CheckActionRecordExist(string no, int code) { |
| | | var db = new SqlHelper<TN_Task_Action>().GetInstance(); |
| | | return db.Queryable<TN_Task_Action>().Count(a => a.S_TASK_CODE == no && a.N_ACTION_CODE == code) > 0; |
| | | } |
| | | |
| | | internal static bool UpdateTaskState(TN_Task task, string state) { |
| | | var res = false; |
| | | var db = new SqlHelper<TN_Task>().GetInstance(); |
| | | task.S_B_STATE = state; |
| | | res = db.Updateable(task).UpdateColumns(it => new { it.S_B_STATE }).ExecuteCommand() > 0; |
| | | return res; |
| | | } |
| | | |
| | | internal static bool UpdateTaskState(TN_Task task) { |
| | | var res = false; |
| | | var db = new SqlHelper<TN_Task>().GetInstance(); |
| | | task.S_B_STATE = TN_Task.GetStateStr(task.N_B_STATE); |
| | | task.T_MODIFY = DateTime.Now; |
| | | res = db.Updateable(task).UpdateColumns(it => new { it.N_B_STATE, it.S_B_STATE, it.T_MODIFY }).ExecuteCommand() > 0; |
| | | return res; |
| | | } |
| | | |
| | | internal static bool UpdateEqTaskNo(TN_Task task) { |
| | | var res = false; |
| | | var db = new SqlHelper<TN_Task>().GetInstance(); |
| | | task.T_MODIFY = DateTime.Now; |
| | | res = db.Updateable(task).UpdateColumns(it => new { it.S_EQ_TASK_CODE, it.T_MODIFY }).ExecuteCommand() > 0; |
| | | return res; |
| | | } |
| | | |
| | | internal static TN_Task GetTask(string taskNo) { |
| | | var db = new SqlHelper<TN_Task>().GetInstance(); |
| | | var task = db.Queryable<TN_Task>().Where(a => a.S_CODE == taskNo).First(); |
| | | return task; |
| | | } |
| | | |
| | | internal static void SetTaskBegin(TN_Task task, string forklift_no) { |
| | |
| | | internal static void SetTaskFail(TN_Task task) { |
| | | var db = new SqlHelper<TN_Task>().GetInstance(); |
| | | if (task != null) { |
| | | //判断有没有取货完成,没有就变成失败。有取货完成默认完成了 (跟据项目而定,有些项目人工拉走了也没有放到终点) 。 |
| | | //判断有没有取货完成,没有就变成失败.有取货完成默认完成了 (跟据项目而定,有些项目人工拉走了也没有放到终点) |
| | | task.N_B_STATE = 4; |
| | | task.S_B_STATE = TN_Task.GetStateStr(task.N_B_STATE); |
| | | db.Updateable(task).UpdateColumns(it => new { it.N_B_STATE, it.S_B_STATE }).ExecuteCommand(); |
| | |
| | | /// </summary> |
| | | public class WMSHelper { |
| | | /// <summary> |
| | | /// 检查容器类型 |
| | | /// 检查容器类型 ( 容器表 不存在 / 类型不匹配 时 , 返回 false ) |
| | | /// </summary> |
| | | /// <param name="cntrCode"></param> |
| | | /// <param name="cntrType"></param> |
| | |
| | | return (true, "检查容器类型成功!!"); |
| | | } |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="locCode"></param> |
| | | /// <param name="areas"></param> |
| | | /// <param name="startLoc"></param> |
| | | /// <returns></returns> |
| | | public static (bool, string) FindStartLocUnbind(string locCode, List<string> areas, out TN_Location startLoc) { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | startLoc = db.Queryable<TN_Location>().Where(DbExpr.StartLocUnbind(locCode, areas)).First(); |
| | | if (startLoc == null) { |
| | | return (false, LogMsg.StartLocUnbindNotFound(locCode, areas)); |
| | | } |
| | | return (true, ""); |
| | | } |
| | | /// <summary> |
| | | /// 根据容器号 , 查找旧的货位 / 货位绑定 / 物料信息 ( 将待删除 / 更新数据写入 obj ) |
| | | /// </summary> |
| | | /// <remarks><code><![CDATA[obj.Old = oldLocCntrCg;]]></code></remarks> |
| | |
| | | /// <param name="cntrCode"></param> |
| | | /// <param name="skipCgDetail"></param> |
| | | /// <returns></returns> |
| | | public static LocCntrCg FindCntrOldInfo(CreateTaskObj obj, string cntrCode, bool skipCgDetail = true) { |
| | | public static LocCntrCg FindOldCntrInfo(CreateTaskObj obj, string cntrCode, bool skipCgDetail = true) { |
| | | var oldLocCntrCg = WCSHelper.GetLocCntrCg(cntrCode, skipCgDetail); |
| | | obj.Old = oldLocCntrCg; |
| | | return oldLocCntrCg; |
| | | } |
| | | /// <summary> |
| | | /// 绑定货位容器 ( 修改 [ 货位容器表 ] [ 货位类型 ] = cntrType ; 将 [ 待插入 ] 货位容器关系 加入到 obj 中 ) |
| | | /// 绑定货位容器 ( 修改 [ 货位容器表 ] [ 货位类型 ] = cntrType ; 将 [ 待插入 ] 货位容器关系 加入到 obj 中 )<br/> |
| | | /// 调用 <see cref="WCSHelper.BindLocCntr"/> 设置 loc.N_CURRENT_NUM = 1 |
| | | /// </summary> |
| | | /// <remarks><code><![CDATA[obj.New = new LocCntrCg { LocCntrRel = locCntrRel };]]></code></remarks> |
| | | /// <param name="obj"></param> |
| | |
| | | |
| | | return task; |
| | | } |
| | | |
| | | private const bool __查询语句封装__ = false; // 仅用于分段,没有实质意义(VS2022 v17.4.3 文档大纲) |
| | | #region 查询语句(搁置,设为私有,查询需求变更多,封装不够灵活) |
| | | /// <summary> |
| | | /// 查询 [ 绑定前 ] 的起点货位 |
| | | /// </summary> |
| | | /// <example><code><![CDATA[ |
| | | /// (ok, msg) = WMSHelper.FindStartLocUnbind(model.StartLoc, taskInfo.StartAreas, out var startLoc); |
| | | /// if (!ok) return NewSimpleResult(2, preLog + msg); |
| | | /// ]]></code></example> |
| | | /// <param name="locCode"></param> |
| | | /// <param name="areas"></param> |
| | | /// <param name="startLoc"></param> |
| | | /// <returns></returns> |
| | | private static (bool, string) FindStartLocUnbind(string locCode, List<string> areas, out TN_Location startLoc) { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | startLoc = db.Queryable<TN_Location>().Where(DbExpr.StartLocUnbind(locCode, areas)).First(); |
| | | if (startLoc == null) { |
| | | return (false, LogMsg.StartLocUnbindNotFound(locCode, areas)); |
| | | } |
| | | return (true, ""); |
| | | } |
| | | /// <summary> |
| | | /// 查询 [ 绑定后 ] 的起点货位 |
| | | /// </summary> |
| | | /// <example><code><![CDATA[ |
| | | /// (ok, msg) = WMSHelper.FindStartLoc(model.StartLoc, taskInfo.StartAreas, out var startLoc); |
| | | /// if (!ok) return NewSimpleResult(2, preLog + msg); |
| | | /// ]]></code></example> |
| | | /// <param name="locCode"></param> |
| | | /// <param name="areas"></param> |
| | | /// <param name="startLoc"></param> |
| | | /// <returns></returns> |
| | | private static (bool, string) FindStartLoc(string locCode, List<string> areas, out TN_Location startLoc) { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | startLoc = db.Queryable<TN_Location>().Where(DbExpr.StartLoc(locCode, areas)).First(); |
| | | if (startLoc == null) { |
| | | return (false, LogMsg.StartLocNotFound(locCode, areas)); |
| | | } |
| | | return (true, ""); |
| | | } |
| | | /// <summary> |
| | | /// 查询终点货位 |
| | | /// </summary> |
| | | /// <example><code><![CDATA[ |
| | | /// (ok, msg) = WMSHelper.FindEndLoc(areas: taskInfo.EndAreas, out var endLoc); |
| | | /// if (!ok) return NewSimpleResult(3, preLog + msg); |
| | | /// ]]></code></example> |
| | | /// <param name="locCode"></param> |
| | | /// <param name="areas"></param> |
| | | /// <param name="endLoc"></param> |
| | | /// <returns></returns> |
| | | private static (bool, string) FindEndLoc(string locCode, List<string> areas, out TN_Location endLoc) { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | endLoc = db.Queryable<TN_Location>().Where(DbExpr.EndLoc(locCode, areas)).First(); |
| | | if (endLoc == null) { |
| | | return (false, LogMsg.EndLocNotFound(locCode, areas)); |
| | | } |
| | | return (true, ""); |
| | | } |
| | | #endregion |
| | | } |
| | | } |