123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- using DbCommon.BusinessCore.BaseCore;
- using DbCommon.Enties.DbModels;
- using ProjectManagementSystem.Common.Config;
- using ProjectManagementSystem.Common.Extenions;
- using ProjectManagementSystem.Common.Logger;
- using ProjectManagementSystem.Common.Models;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using ProjectManagementSystem.Common.Core;
- using ProjectManagementSystem.Common.Service;
- using ProjectManagementSystem.Common.Models.Crms;
- namespace ProjectManagementSystem.Common.TaskBookEvent
- {
- public class TaskBookBehavior_63008 : BaseTaskBookBehaviorV2
- {
- //LocationPropertyManager locationManager = new LocationPropertyManager();
- public TaskBookBehavior_63008() : base(63008, "续接任务")
- {
- }
- public override bool TaskBookOperator(TaskData taskDetailInfo, StepData stepInfo)
- {
- try
- {
- var nextLocation = stepInfo.WareHouseID.GetLocationMember("续接取货位置");
- if (string.IsNullOrEmpty(nextLocation))
- {
- Log(taskDetailInfo, stepInfo, $"未配置续接取货位置");
- return false;
- }
- if (stepInfo.WareHouseID == "上料人工")
- {
- if (PackControl.Instance.StationDictionary.TryGetValue(stepInfo.WareHouseID, out var packStation)
- && packStation != null
- && packStation.PackPlcToAgv != null)
- {
- var ret = packStation.PackPlcToAgv.ReleaseAgv(packStation.routeConfig, out string msg);
- if (ret != 20000)
- {
- Log(taskDetailInfo, stepInfo, $"等待放行 {msg}");
- return false;
- }
- }
- }
- PmsTaskInfoDto data = new PmsTaskInfoDto();
- data.LocationCode = nextLocation;
- data.TargetLocationCode = "模组A";
- data.ParentTaskId = taskDetailInfo.TaskID;
- data.Carrier = taskDetailInfo.Carrier;
- var result = Crms.PmsTaskService.TaskAddNoCheck(data, new string[] { });
- return result.code == 20000;
- }
- catch (Exception ex)
- {
- LogException(ex);
- }
- return false;
- }
- //public override bool TaskBookOperator(TaskData taskDetailInfo, StepData stepInfo)
- //{
- // try
- // {
- // var startWarehouse = stepInfo.WareHouseID.GetLocationMember("续接取货仓库");
- // var startLocation = stepInfo.WareHouseID.GetLocationMember("续接取货仓位");
- // var startMaterial = stepInfo.WareHouseID.GetLocationMember("续接取货物料");
- // var endWarehouse = stepInfo.WareHouseID.GetLocationMember("续接放货仓库");
- // var endLocation = stepInfo.WareHouseID.GetLocationMember("续接放货仓位");
- // if (string.IsNullOrWhiteSpace(startWarehouse) && string.IsNullOrWhiteSpace(startLocation))
- // {
- // Log(taskDetailInfo, stepInfo, $"续接取货仓库和续接取货仓位都为空,不需要续接");
- // return true;
- // }
- // if (string.IsNullOrWhiteSpace(endWarehouse) && string.IsNullOrWhiteSpace(endLocation))
- // {
- // Log(taskDetailInfo, stepInfo, $"续接放货仓库和续接放货仓位都为空,不需要续接");
- // return true;
- // }
- // if (!string.IsNullOrWhiteSpace(startLocation) && !string.IsNullOrWhiteSpace(startMaterial))
- // {
- // //起点物料修改
- // var locationStock = Crms.SWmsApi.GetLocationStockByLocationId(startLocation);
- // if (locationStock == null)
- // {
- // Log(taskDetailInfo, stepInfo, $"获取起点库位信息失败 {startLocation}");
- // return false;
- // }
- // if (locationStock.Stock?.goodsCode != startMaterial)
- // {
- // var res2 = Crms.PmsTaskService.UpdateLocationProperty(new LocationPropertyUpdateDto()
- // {
- // LocationCode = startLocation,
- // Status = LocationStatus.Filled,
- // MaterialId = startMaterial
- // });
- // if (res2.code != 20000)
- // {
- // Log(taskDetailInfo, stepInfo, $"设置起点库位物料失败 {startLocation} {startMaterial}");
- // return false;
- // }
- // }
- // }
- // PmsTaskInfoDto data = new PmsTaskInfoDto();
- // data.WareHouseCode = startWarehouse;
- // data.LocationCode = startLocation;
- // data.MaterialId = startMaterial;
- // data.TargetWareHouseCode = endWarehouse;
- // data.TargetLocationCode = endLocation;
- // data.ParentTaskId = taskDetailInfo.TaskID;
- // data.Carrier = taskDetailInfo.Carrier;
- // var res = Crms.PmsTaskService.TaskAdd(data);
- // var result = res.code == 20000;
- // Log(taskDetailInfo, stepInfo, $"续接任务{result.ToChineseString()} {res.message}");
- // return result;
- // }
- // catch (Exception ex)
- // {
- // LogException(ex);
- // }
- // return false;
- //}
- }
- }
|