| | |
| | | <Compile Include="dispatch\NDC.cs" /> |
| | | <Compile Include="core\Monitor.cs" /> |
| | | <Compile Include="dispatch\WCSDispatch.cs" /> |
| | | <Compile Include="dispatch\XcDispatch.cs" /> |
| | | <Compile Include="models\AbnormalAreaConfig.cs" /> |
| | | <Compile Include="models\AlarmRecord.cs" /> |
| | | <Compile Include="models\BaseModel.cs" /> |
| | | <Compile Include="models\Area.cs" /> |
| | | <Compile Include="models\LjItem.cs" /> |
| | | <Compile Include="models\LjItemConfig.cs" /> |
| | | <Compile Include="models\LjXcCarrier.cs" /> |
| | | <Compile Include="models\LjLotCarrier.cs" /> |
| | | <Compile Include="models\LjLotOnhand.cs" /> |
| | | <Compile Include="models\LjXcOutTask.cs" /> |
| | |
| | | tasks.Add(GetTask(Monitor.MonitorCXJCallMaterialMesTask)); |
| | | // 监听钢包满料下线任务 |
| | | tasks.Add(GetTask(Monitor.MonitorGBOffLineMesTask)); |
| | | // 监听斜裁出库任务表 |
| | | tasks.Add(GetTask(Monitor.MonitorXcOutTask)); |
| | | // 监听斜裁任务表 |
| | | tasks.Add(GetTask(Monitor.MonitorXcTask)); |
| | | // 自动补充空工装任务 |
| | | tasks.Add(GetTask(Monitor.AutoReplenishEmptyPallet)); |
| | | // 监听托盘物料表、物料表,并更新 |
| | | tasks.Add(GetTask(Monitor.MonitorPalletAndMateral)); |
| | | /* tasks.Add(GetTask(Monitor.MonitorPalletAndMateral));*/ |
| | | // 定时更新库存中间表 |
| | | tasks.Add(GetTask(Monitor.UpdateInventoryRegularly,60000)); |
| | | // 定时批次状态表 |
| | |
| | | LogHelper.Info("AGVCallbackEvent Request:" + JsonConvert.SerializeObject(model), "HosttoagvTask"); |
| | | return new ReturnResult(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// ndc agv车辆状态回报 |
| | | /// </summary> |
| | |
| | | WCSCore.OperateHATaskStatus(model); |
| | | return new ReturnResult(); |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | |
| | | /// <summary> |
| | | /// AGV申请终点 |
| | | /// 顺序 RFID验证 -> RFID与任务号验证 -> 物料合格状态验证 -> 虚拟终点 |
| | | /// 申请类型: 1.虚拟终点 2.RFID与任务不匹配 3.物料状态不合格 |
| | | /// 申请类型: 1.正常 2.异常 |
| | | /// 入库策略:先计算库区的容积率,再计算库区对应的入库站台的任务数,都取最小的 |
| | | /// |
| | | /// 1.确定任务是否在执行中 |
| | |
| | | { |
| | | WMSHelper.addAlarmRecord("系统错误","高", $"AGV申请终点,WMS内部错误,错误原因:{ex.Message}", "AGV"); |
| | | } |
| | | return null; |
| | | LogHelper.Info($"变更AGV终点:{applyDest}", "AGV"); |
| | | return applyDest; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | public static string applyAgvDestXC(string applyType, WMSTask mst, WCSTask cst) |
| | | { |
| | | string destLoc = null; |
| | | Location agvEndLoc = null; |
| | | Location wmsEndLoc = null; |
| | | Location endLoc = null; |
| | | if (applyType == "1") |
| | | { |
| | | if (mst.S_TYPE == "余料/空工装入库") |
| | |
| | | // 取消任务 |
| | | ApiHelper.cancelTask(awaitTask.S_CODE); |
| | | // 修改终点 |
| | | agvEndLoc = LocationHelper.GetLoc(awaitTask.S_END_LOC); |
| | | wmsEndLoc = agvEndLoc; |
| | | endLoc = LocationHelper.GetLoc(awaitTask.S_END_LOC); |
| | | mst.S_TYPE = "叫料出库任务"; |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | if (agvEndLoc == null) |
| | | if (endLoc == null) |
| | | { |
| | | string msg = ""; |
| | | if (applyType == "2" || applyType == "3" || applyType == "4") |
| | | if (applyType == "2") |
| | | { |
| | | cst.S_TYPE = cst.S_TYPE + "【异常】"; |
| | | msg = "工装异常"; |
| | | } |
| | | |
| | | // TODO 反馈斜裁立库异常,请求斜裁入库终点 |
| | | agvEndLoc = null; |
| | | |
| | | string locCode = "XCCRKZTKQ-1-1"; |
| | | endLoc = LocationHelper.GetLoc(locCode); |
| | | } |
| | | |
| | | if (agvEndLoc != null) |
| | | if (endLoc != null) |
| | | { |
| | | destLoc = agvEndLoc.S_CODE; |
| | | |
| | | cst.S_END_LOC = agvEndLoc.S_CODE; |
| | | cst.S_END_AREA = agvEndLoc.S_AREA_CODE; |
| | | cst.S_END_LOC = endLoc.S_CODE; |
| | | cst.S_END_AREA = endLoc.S_AREA_CODE; |
| | | WCSHelper.UpdateEndLoc(cst); |
| | | } |
| | | |
| | | if (wmsEndLoc != null) |
| | | { |
| | | mst.S_END_LOC = wmsEndLoc.S_CODE; |
| | | mst.S_END_AREA = wmsEndLoc.S_AREA_CODE; |
| | | mst.S_END_LOC = endLoc.S_CODE; |
| | | mst.S_END_AREA = endLoc.S_AREA_CODE; |
| | | WMSHelper.UpdateTaskEnd(mst); |
| | | |
| | | return endLoc.S_CODE; |
| | | } |
| | | return destLoc; |
| | | return null; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | return null; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (agvEndLoc != null && wmsEndLoc != null) |
| | | { |
| | | destLoc = agvEndLoc.S_CODE; |
| | | cst.S_END_LOC = agvEndLoc.S_CODE; |
| | | cst.S_END_AREA = agvEndLoc.S_AREA_CODE; |
| | | WCSHelper.UpdateEndLoc(cst); |
| | | |
| | | mst.S_END_LOC = wmsEndLoc.S_CODE; |
| | | mst.S_END_AREA = wmsEndLoc.S_AREA_CODE; |
| | | WMSHelper.UpdateTaskEnd(mst); |
| | | } |
| | | |
| | | // 重新发起新任务 |
| | | if (applyType != "1") |
| | | { |
| | | var mesTask = WMSHelper.GetLjMesTaskByAgvorderId(mst.S_CODE); |
| | | if (mesTask != null) |
| | | if (mesTask != null) |
| | | { |
| | | if (mst.S_TYPE.Contains("叫料出库任务")) |
| | | { |
| | |
| | | var logicConfig = WMSHelper.getLogicConfigByJtCode(mesTask.EQP); |
| | | if (logicConfig != null) |
| | | { |
| | | triggerItemOffLineFlow4(mesTask.POSITION_ID, mst.S_CNTR_CODE, logicConfig ,mesTask); |
| | | triggerItemOffLineFlow4(mesTask.POSITION_ID, mst.S_CNTR_CODE, logicConfig, mesTask); |
| | | } |
| | | else |
| | | { |
| | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (agvEndLoc != null && wmsEndLoc != null) |
| | | { |
| | | destLoc = agvEndLoc.S_CODE; |
| | | cst.S_END_LOC = agvEndLoc.S_CODE; |
| | | cst.S_END_AREA = agvEndLoc.S_AREA_CODE; |
| | | WCSHelper.UpdateEndLoc(cst); |
| | | |
| | | mst.S_END_LOC = wmsEndLoc.S_CODE; |
| | | mst.S_END_AREA = wmsEndLoc.S_AREA_CODE; |
| | | WMSHelper.UpdateTaskEnd(mst); |
| | | } |
| | | return destLoc; |
| | | } |
| | |
| | | if (locCntrRels.Count > 0) |
| | | { |
| | | cntrCode = locCntrRels[0].S_CNTR_CODE; |
| | | middleLoc = WMSHelper.GetTransfeRelevanceLoc(startLoc.S_AREA_CODE, 1, 2); |
| | | middleLoc = WMSHelper.GetTransfeRelevanceLoc(startLoc.S_AREA_CODE, 2, 2); |
| | | if (middleLoc != null) |
| | | { |
| | | // 1.创建成新机叫料作业 |
| | |
| | | /// <param name="mesTaskId"></param> |
| | | public static void callMaterialXC(string materialCode, string endLocCode, int mesTaskId) |
| | | { |
| | | // 1.查询环带库物料库存 |
| | | DateTime inStockTimeXc = DateTime.MinValue; |
| | | List<CntrItemRel> cntrItemRelsXc = new List<CntrItemRel>(); |
| | | if (cntrItemRelsXc.Count > 0) |
| | | { |
| | | inStockTimeXc = cntrItemRelsXc[0].T_INBOUND_TIME; |
| | | } |
| | | |
| | | // 2.查询中转库库存 |
| | | DateTime inStockTime = DateTime.MinValue; |
| | | var cntrItemRels = WMSHelper.getZZKInventoryInfo(materialCode); |
| | | if (cntrItemRels.Count > 0) |
| | | { |
| | | inStockTime = cntrItemRels[0].T_INBOUND_TIME; |
| | | } |
| | | |
| | | // 3.根据先进先出计算出库的物料是环带库 还是中转库 |
| | | var mesTask = WMSHelper.GetLjMesTaskById(mesTaskId); |
| | | if (inStockTime >= inStockTimeXc) |
| | | if (mesTask != null) |
| | | { |
| | | //斜裁物料出库 |
| | | if (cntrItemRelsXc.Count > 0) |
| | | // 1.查询环带库物料库存最早入库时间 |
| | | DateTime inStockTimeXc = DateTime.MinValue; |
| | | |
| | | // 2.查询中转库库存 |
| | | DateTime inStockTime = WMSHelper.getZZKInventoryInfo(materialCode); |
| | | |
| | | // 3.根据先进先出计算出库的物料是环带库 还是中转库 |
| | | if (inStockTime >= inStockTimeXc) |
| | | { |
| | | // 4.将MES任务写入环带库任务中间表 |
| | | WMSHelper.addLjXcTask(mesTask); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //中转库物料出库 |
| | | if (cntrItemRels.Count > 0) |
| | | { |
| | | var cntrItemRel = cntrItemRels[0]; |
| | | var locCntrRel = LocationHelper.GetLocCntrByCntr(cntrItemRel.S_CNTR_CODE); |
| | | if (locCntrRel != null) |
| | | Location endLoc = WMSHelper.getCallMaterialLocCode(mesTask.EQP); |
| | | if (endLoc != null) |
| | | { |
| | | var endLoc = LocationHelper.GetLoc(locCntrRel.S_LOC_CODE); |
| | | if (endLoc != null) |
| | | // 4.创建斜裁-成新机叫料作业 |
| | | var wmsTask = new WMSTask() |
| | | { |
| | | S_CODE = WMSHelper.GenerateTaskNo(), |
| | | S_CNTR_CODE = "", |
| | | S_START_LOC = "虚拟起点", |
| | | S_START_AREA = "虚拟库区", |
| | | S_END_LOC = endLoc.S_CODE, |
| | | S_END_AREA = endLoc.S_AREA_CODE, |
| | | S_TYPE = "叫料出库任务", |
| | | S_OP_DEF_CODE = mesTask.ID.ToString(), |
| | | S_OP_DEF_NAME = "成型机叫料出库任务(斜裁)", |
| | | T_START_TIME = DateTime.Now, |
| | | N_B_STATE = 0 |
| | | }; |
| | | if (WMSHelper.CreateWmsTask(wmsTask)) |
| | | { |
| | | WCSTask wcsTask = new WCSTask() |
| | | { |
| | | S_OP_NAME = wmsTask.S_OP_DEF_NAME, |
| | | S_OP_CODE = wmsTask.S_CODE, |
| | | S_CODE = WCSHelper.GenerateTaskNo(), |
| | | S_CNTR_CODE = wmsTask.S_CNTR_CODE, |
| | | S_TYPE = wmsTask.S_TYPE, |
| | | S_START_LOC = wmsTask.S_START_LOC, |
| | | S_START_AREA = wmsTask.S_START_AREA, |
| | | S_END_LOC = endLoc.S_CODE, |
| | | S_END_AREA = endLoc.S_AREA_CODE, |
| | | S_SCHEDULE_TYPE = "AGV", |
| | | N_PRIORITY = 10, |
| | | T_START_TIME = DateTime.Now, |
| | | N_B_STATE = -1, |
| | | S_B_STATE = "预创建", |
| | | }; |
| | | |
| | | if (WCSHelper.CreateTask(wcsTask)) |
| | | { |
| | | // 起点、终点加锁 |
| | | LocationHelper.LockLoc(wcsTask.S_START_LOC, 2); |
| | | LocationHelper.LockLoc(wcsTask.S_END_LOC, 1); |
| | | |
| | | // 5.将MES任务写入斜裁任务中间表 |
| | | mesTask.AGVORDER_ID = wcsTask.S_CODE; |
| | | WMSHelper.addLjXcTask(mesTask); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //中转库物料出库 |
| | | Location startLoc = WMSHelper.getOutStockStartLoc(null, materialCode); |
| | | if (startLoc != null) |
| | | { |
| | | var locCntrRels = LocationHelper.GetLocCntr(startLoc.S_CODE); |
| | | if (locCntrRels != null && locCntrRels.Count > 0) |
| | | { |
| | | Location middleLoc = null; |
| | | Location startLoc = WMSHelper.getOutStockStartLoc(null, materialCode); |
| | | if (startLoc != null) |
| | | Location endLoc = WMSHelper.getCallMaterialLocCode(mesTask.EQP); |
| | | if (endLoc != null) |
| | | { |
| | | var locCntrRels = LocationHelper.GetLocCntr(startLoc.S_CODE); |
| | | if (locCntrRels.Count > 0) |
| | | middleLoc = WMSHelper.GetTransfeRelevanceLoc(startLoc.S_AREA_CODE, 2, 2); |
| | | if (middleLoc != null) |
| | | { |
| | | var cntrCode = cntrItemRel.S_CNTR_CODE; |
| | | middleLoc = WMSHelper.GetTransfeRelevanceLoc(startLoc.S_AREA_CODE, 1, 2); |
| | | if (middleLoc != null) |
| | | // 1.创建成新机叫料作业 |
| | | var wmsTask = new WMSTask() |
| | | { |
| | | // 1.创建成新机叫料作业 |
| | | var wmsTask = new WMSTask() |
| | | S_CNTR_CODE = locCntrRels[0].S_CNTR_CODE, |
| | | S_CODE = WMSHelper.GenerateTaskNo(), |
| | | S_START_LOC = startLoc.S_CODE, |
| | | S_START_AREA = startLoc.S_AREA_CODE, |
| | | S_END_LOC = endLoc.S_CODE, |
| | | S_END_AREA = endLoc.S_AREA_CODE, |
| | | S_TYPE = "叫料出库任务", |
| | | S_OP_DEF_CODE = mesTaskId.ToString(), |
| | | S_OP_DEF_NAME = "成型机叫料出库任务", |
| | | T_START_TIME = DateTime.Now, |
| | | }; |
| | | if (WMSHelper.CreateWmsTask(wmsTask)) |
| | | { |
| | | WCSTask wcsTask = new WCSTask() |
| | | { |
| | | S_CNTR_CODE = cntrCode, |
| | | S_CODE = WMSHelper.GenerateTaskNo(), |
| | | S_OP_NAME = wmsTask.S_OP_DEF_NAME, |
| | | S_OP_CODE = wmsTask.S_CODE, |
| | | S_CODE = WCSHelper.GenerateTaskNo(), |
| | | S_CNTR_CODE = wmsTask.S_CNTR_CODE, |
| | | S_TYPE = wmsTask.S_TYPE, |
| | | S_START_LOC = startLoc.S_CODE, |
| | | S_START_AREA = startLoc.S_AREA_CODE, |
| | | S_END_LOC = endLoc.S_CODE, |
| | | S_END_AREA = endLoc.S_AREA_CODE, |
| | | S_TYPE = "叫料出库任务", |
| | | S_OP_DEF_CODE = mesTaskId.ToString(), |
| | | S_OP_DEF_NAME = "成型机叫料出库任务", |
| | | S_END_LOC = middleLoc.S_CODE, |
| | | S_END_AREA = middleLoc.S_AREA_CODE, |
| | | S_SCHEDULE_TYPE = "WCS", |
| | | N_PRIORITY = 10, |
| | | T_START_TIME = DateTime.Now, |
| | | }; |
| | | if (WMSHelper.CreateWmsTask(wmsTask)) |
| | | |
| | | if (WCSHelper.CreateTask(wcsTask)) |
| | | { |
| | | WCSTask wcsTask = new WCSTask() |
| | | { |
| | | S_OP_NAME = wmsTask.S_OP_DEF_NAME, |
| | | S_OP_CODE = wmsTask.S_CODE, |
| | | S_CODE = WCSHelper.GenerateTaskNo(), |
| | | S_CNTR_CODE = wmsTask.S_CNTR_CODE, |
| | | S_TYPE = wmsTask.S_TYPE, |
| | | S_START_LOC = startLoc.S_CODE, |
| | | S_START_AREA = startLoc.S_AREA_CODE, |
| | | S_END_LOC = middleLoc.S_CODE, |
| | | S_END_AREA = middleLoc.S_AREA_CODE, |
| | | S_SCHEDULE_TYPE = "WCS", |
| | | N_PRIORITY = 10, |
| | | T_START_TIME = DateTime.Now, |
| | | }; |
| | | // 起点、终点加锁 |
| | | LocationHelper.LockLoc(wcsTask.S_START_LOC, 2); |
| | | LocationHelper.LockLoc(wcsTask.S_END_LOC, 1); |
| | | |
| | | if (WCSHelper.CreateTask(wcsTask)) |
| | | { |
| | | // 起点、终点加锁 |
| | | LocationHelper.LockLoc(wcsTask.S_START_LOC, 2); |
| | | LocationHelper.LockLoc(wcsTask.S_END_LOC, 1); |
| | | |
| | | // 更新作业任务状态 |
| | | wmsTask.N_B_STATE = 1; |
| | | WMSHelper.UpdateTaskState(wmsTask); |
| | | } |
| | | |
| | | // 预创建二段任务 |
| | | WCSTask twoWcsTask = new WCSTask() |
| | | { |
| | | S_OP_NAME = wmsTask.S_OP_DEF_NAME, |
| | | S_OP_CODE = wmsTask.S_CODE, |
| | | S_CODE = WCSHelper.GenerateTaskNo(), |
| | | S_CNTR_CODE = wmsTask.S_CNTR_CODE, |
| | | S_TYPE = wmsTask.S_TYPE, |
| | | S_START_LOC = middleLoc.S_CODE, |
| | | S_START_AREA = middleLoc.S_AREA_CODE, |
| | | S_END_LOC = endLoc.S_CODE, |
| | | S_END_AREA = endLoc.S_AREA_CODE, |
| | | S_SCHEDULE_TYPE = "AGV", |
| | | N_PRIORITY = 10, |
| | | T_START_TIME = DateTime.Now, |
| | | N_B_STATE = -1 |
| | | }; |
| | | WCSHelper.CreateTask(twoWcsTask); |
| | | WMSHelper.readLjMesCallItemTask(wmsTask.S_CODE, mesTaskId); |
| | | // 更新作业任务状态 |
| | | wmsTask.N_B_STATE = 1; |
| | | WMSHelper.UpdateTaskState(wmsTask); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | WMSHelper.addAlarmRecord("流程异常", "高", $"成型机叫料失败,库区{startLoc.S_AREA_CODE}未查询到可用的接驳位"); |
| | | |
| | | // 预创建二段任务 |
| | | WCSTask twoWcsTask = new WCSTask() |
| | | { |
| | | S_OP_NAME = wmsTask.S_OP_DEF_NAME, |
| | | S_OP_CODE = wmsTask.S_CODE, |
| | | S_CODE = WCSHelper.GenerateTaskNo(), |
| | | S_CNTR_CODE = wmsTask.S_CNTR_CODE, |
| | | S_TYPE = wmsTask.S_TYPE, |
| | | S_START_LOC = middleLoc.S_CODE, |
| | | S_START_AREA = middleLoc.S_AREA_CODE, |
| | | S_END_LOC = endLoc.S_CODE, |
| | | S_END_AREA = endLoc.S_AREA_CODE, |
| | | S_SCHEDULE_TYPE = "AGV", |
| | | N_PRIORITY = 10, |
| | | T_START_TIME = DateTime.Now, |
| | | N_B_STATE = -1 |
| | | }; |
| | | WCSHelper.CreateTask(twoWcsTask); |
| | | WMSHelper.readLjMesCallItemTask(wmsTask.S_CODE, mesTaskId); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | WMSHelper.addAlarmRecord("流程异常", "高", $"成型机叫料失败,开始货位:{startLoc.S_CODE}异常,缺少容器信息"); |
| | | WMSHelper.addAlarmRecord("流程异常", "高", $"成型机叫料失败,库区{startLoc.S_AREA_CODE}未查询到可用的接驳位"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | mesTask.AWAIT_MSG = "库存不足"; |
| | | WMSHelper.updateLjMesTask(mesTask); |
| | | WMSHelper.addAlarmRecord("流程异常", "高", $"成型机叫料失败,物料:{materialCode}库存不足"); |
| | | WMSHelper.addAlarmRecord("流程异常", "高", $"成型机叫料失败,开始货位:{startLoc.S_CODE}异常,缺少容器信息"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | mesTask.AWAIT_MSG = "库存不足"; |
| | | WMSHelper.updateLjMesTask(mesTask); |
| | | WMSHelper.addAlarmRecord("流程异常", "高", $"成型机叫料失败,物料:{materialCode}库存不足"); |
| | | } |
| | | } |
| | | } |
| | |
| | | S_START_AREA = startLoc.S_AREA_CODE, |
| | | S_END_LOC = endLoc.S_CODE, |
| | | S_END_AREA = endLoc.S_AREA_CODE, |
| | | S_TYPE = "余料/空工装入库任务" + suffix, |
| | | S_TYPE = "余料/空工装入库任务", |
| | | S_OP_DEF_CODE = mesTask.ID.ToString(), |
| | | S_OP_DEF_NAME = "余料/空工装入库" + suffix, |
| | | T_START_TIME = DateTime.Now |
| | |
| | | S_OP_CODE = mst.S_CODE, |
| | | S_CODE = WCSHelper.GenerateTaskNo(), |
| | | S_CNTR_CODE = cst.S_CNTR_CODE, |
| | | S_TYPE = "不合格品回库", |
| | | S_TYPE = "不合格品入库任务", |
| | | S_START_LOC = startLoc.S_CODE, |
| | | S_START_AREA = startLoc.S_AREA_CODE, |
| | | S_END_LOC = agvEndLoc.S_CODE, |
| | |
| | | S_OP_CODE = mst.S_CODE, |
| | | S_CODE = WCSHelper.GenerateTaskNo(), |
| | | S_CNTR_CODE = cst.S_CNTR_CODE, |
| | | S_TYPE = "不合格品回库", |
| | | S_TYPE = "不合格品入库任务", |
| | | S_START_LOC = startLoc.S_CODE, |
| | | S_START_AREA = startLoc.S_AREA_CODE, |
| | | S_END_LOC = agvEndLoc.S_CODE, |
| | |
| | | S_OP_CODE = mst.S_CODE, |
| | | S_CODE = WCSHelper.GenerateTaskNo(), |
| | | S_CNTR_CODE = cst.S_CNTR_CODE, |
| | | S_TYPE = "不合格品回库", |
| | | S_TYPE = "不合格品入库任务", |
| | | S_START_LOC = agvEndLoc.S_CODE, |
| | | S_START_AREA = agvEndLoc.S_AREA_CODE, |
| | | S_END_LOC = wmsEndLoc.S_CODE, |
| | |
| | | return result; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 斜裁物料出库任务 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | public static ResponseResult createXcItemOutStockTask(XcItemOutStockModel model) |
| | | { |
| | | ResponseResult responseResult = new ResponseResult(); |
| | | Location startLoc = LocationHelper.GetLoc(model.startLoc); |
| | | if (startLoc == null) |
| | | { |
| | | WMSHelper.addAlarmRecord("流程异常", "高", $"成型机叫料出库(斜裁),起点:{model.startLoc}在WMS系统中不存在"); |
| | | responseResult.code = 201; |
| | | responseResult.msg = $"起点:{model.startLoc}在WMS系统中不存在"; |
| | | return responseResult; |
| | | } |
| | | Location endLoc = WMSHelper.getCallMaterialLocCode(model.eqNo); |
| | | if (endLoc != null) |
| | | { |
| | | var wmsTask = WMSHelper.GetWmsTaskByCntr(model.palletId); |
| | | if (wmsTask == null) |
| | | { |
| | | ContainerHelper.AddCntr(model.palletId); |
| | | |
| | | // 1.创建斜裁-成新机叫料作业 |
| | | wmsTask = new WMSTask() |
| | | { |
| | | S_CNTR_CODE = model.palletId, |
| | | S_CODE = WMSHelper.GenerateTaskNo(), |
| | | S_START_LOC = startLoc.S_CODE, |
| | | S_START_AREA = startLoc.S_AREA_CODE, |
| | | S_END_LOC = endLoc.S_CODE, |
| | | S_END_AREA = endLoc.S_AREA_CODE, |
| | | S_TYPE = "叫料出库任务", |
| | | S_OP_DEF_CODE = model.reqId, |
| | | S_OP_DEF_NAME = "成型机叫料出库任务(斜裁)", |
| | | T_START_TIME = DateTime.Now, |
| | | }; |
| | | if (WMSHelper.CreateWmsTask(wmsTask)) |
| | | { |
| | | WCSTask wcsTask = new WCSTask() |
| | | { |
| | | S_OP_NAME = wmsTask.S_OP_DEF_NAME, |
| | | S_OP_CODE = wmsTask.S_CODE, |
| | | S_CODE = WCSHelper.GenerateTaskNo(), |
| | | S_CNTR_CODE = wmsTask.S_CNTR_CODE, |
| | | S_TYPE = wmsTask.S_TYPE, |
| | | S_START_LOC = startLoc.S_CODE, |
| | | S_START_AREA = startLoc.S_AREA_CODE, |
| | | S_END_LOC = endLoc.S_CODE, |
| | | S_END_AREA = endLoc.S_AREA_CODE, |
| | | S_SCHEDULE_TYPE = "AGV", |
| | | N_PRIORITY = 10, |
| | | T_START_TIME = DateTime.Now, |
| | | }; |
| | | |
| | | if (WCSHelper.CreateTask(wcsTask)) |
| | | { |
| | | // 起点、终点加锁 |
| | | LocationHelper.LockLoc(wcsTask.S_START_LOC, 2); |
| | | LocationHelper.LockLoc(wcsTask.S_END_LOC, 1); |
| | | |
| | | // 更新作业任务状态 |
| | | wmsTask.N_B_STATE = 1; |
| | | WMSHelper.UpdateTaskState(wmsTask); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | responseResult.code = 201; |
| | | responseResult.msg = $"成型机机台:{model.eqNo}没有空余的叫料货位"; |
| | | } |
| | | return responseResult; |
| | | } |
| | | |
| | | //---------------------------------------------------------------------------------------------------------------------------- |
| | | public class LocModel |
| | | { |
| | |
| | | [HttpPost] |
| | | public ResponseResult manualStorage(ManualStorageModel model) |
| | | { |
| | | LogHelper.Info("manualStorage Request:" + JsonConvert.SerializeObject(model), "Mobox"); |
| | | LogHelper.Info("人工入库 Request:" + JsonConvert.SerializeObject(model), "Mobox"); |
| | | ResponseResult result = new ResponseResult(); |
| | | result = ApiHelper.manualStorage(model); |
| | | LogHelper.Info("manualStorage response:" + JsonConvert.SerializeObject(model), "Mobox"); |
| | | LogHelper.Info("人工入库 response:" + JsonConvert.SerializeObject(model), "Mobox"); |
| | | return result; |
| | | } |
| | | |
| | |
| | | [HttpPost] |
| | | public ResponseResult manualDelivery(ManualDeliveryModel model) |
| | | { |
| | | LogHelper.Info("manualDelivery Request:" + JsonConvert.SerializeObject(model), "Mobox"); |
| | | LogHelper.Info("人工出库 Request:" + JsonConvert.SerializeObject(model), "Mobox"); |
| | | ResponseResult result = new ResponseResult(); |
| | | result = ApiHelper.manualDelivery(model); |
| | | LogHelper.Info("manualDelivery response:" + JsonConvert.SerializeObject(model), "Mobox"); |
| | | LogHelper.Info("人工出库 response:" + JsonConvert.SerializeObject(model), "Mobox"); |
| | | return result; |
| | | } |
| | | |
| | |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | /* [Route("notifyAlarm")]*/ |
| | | /* [Route("notifyAlarm")] */ |
| | | public ResponseResult unBindingLoc(LocModel model) |
| | | { |
| | | LogHelper.Info("UnBindingLoc 入参:" + JsonConvert.SerializeObject(model), "WMS"); |
| | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | //--------------------------------- 提供给斜裁的接口 -------------------------------- |
| | | |
| | | /// <summary> |
| | | /// 9.斜裁出库任务 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | /* [Route("notifyAlarm")]*/ |
| | | public ResponseResult createXcItemOutStockTask(XcItemOutStockModel model) |
| | | { |
| | | LogHelper.Info("XcItemOutStock 入参:" + JsonConvert.SerializeObject(model), "WMS"); |
| | | ResponseResult result = new ResponseResult(); |
| | | result = ApiHelper.createXcItemOutStockTask(model); |
| | | LogHelper.Info("XcItemOutStock 出参:" + JsonConvert.SerializeObject(result), "WMS"); |
| | | return result; |
| | | } |
| | | |
| | | public class XcItemOutStockModel |
| | | { |
| | | public string reqId { get; set; } |
| | | public string reqTime { get; set; } |
| | | public string startLoc { get; set; } |
| | | public string eqNo { get; set; } // 设备号 |
| | | public string palletId { get; set; } // 托盘号 |
| | | /*public string lotName { get; set; } // 批次条码 |
| | | public string yclBatch { get; set; } // 原材料批次号 |
| | | public string materialCode { get; set; } // 物料编码 |
| | | public float qty { get; set; } // 物料数量 |
| | | public string productionDate { get; set; } // 生产日期(yyyy-MM-dd HH:mm:ss) |
| | | public string qcStatus { get; set; } // 检验状态 0:未检验 1:合格,2:不合格 |
| | | public string shelfLifeDate { get; set; } // 最长停放日期 |
| | | public string minShelfLife_Date { get; set; } // 最小停放日期*/ |
| | | } |
| | | |
| | | public class LocStateFeedBackModel |
| | | { |
| | | public string reqId { get; set; } |
| | |
| | | "areaName": "钢包库(非直连)", |
| | | "cntrType": [ 7 ], |
| | | "type": 2 |
| | | }, |
| | | }, |
| | | { |
| | | "areaCode": "ZZFZLCK", |
| | | "areaName": "中转库(非直连)", |
| | |
| | | if (lineSideLoc != null) |
| | | { |
| | | LogHelper.Info($"成型机叫料任务,MES任务ID:{mesTask.ID}", "WMS"); |
| | | |
| | | // 2.1成新机叫料(斜裁) |
| | | if (mesTask.PALLET_TYPE == "5" || mesTask.PALLET_TYPE == "6") |
| | | { |
| | | // 2.1成新机叫料(斜裁) |
| | | var xcTask = WMSHelper.GetLjXcTaskById(mesTask.ID); |
| | | if (xcTask == null) |
| | | { |
| | | ApiHelper.callMaterialXC(mesTask.MATERIAL_CODE, mesTask.POSITION_ID, mesTask.ID); |
| | | } |
| | | else |
| | | { |
| | | mesTask.RETURN_CODE = xcTask.RETURN_CODE; |
| | | mesTask.RECEIVE_FLAG = xcTask.RECEIVE_FLAG; |
| | | mesTask.RECEIVE_DATE = xcTask.RECEIVE_DATE; |
| | | WMSHelper.updateLjMesTask(mesTask); |
| | | } |
| | | } |
| | | else |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 监听XC出库任务中间表 |
| | | /// 读取斜裁立库出库任务表,查询任务是否执行完成,完成则,触发AGV任务 |
| | | /// 监听任务中间表 |
| | | /// </summary> |
| | | public static void MonitorXcOutTask() |
| | | public static void MonitorXcTask() |
| | | { |
| | | var xcOutTasks = WMSHelper.getLjXcOutTask("PENDING", "2"); |
| | | foreach (var outTask in xcOutTasks) |
| | | var ljMesTasks = WMSHelper.GetLjMesTaskListHD(); |
| | | foreach (var mesTask in ljMesTasks) |
| | | { |
| | | var mesTask = WMSHelper.GetLjMesTaskById(outTask.ID); |
| | | if (mesTask != null && mesTask.RETURN_CODE == "2") |
| | | var xcTask = WMSHelper.GetLjXcTaskById(mesTask.ID); |
| | | if (xcTask != null && xcTask.RETURN_CODE != mesTask.RETURN_CODE) |
| | | { |
| | | Location startLoc = LocationHelper.GetLoc(outTask.POSITION_ID); |
| | | if (startLoc == null) |
| | | if (xcTask.RETURN_CODE == "3") |
| | | { |
| | | WMSHelper.addAlarmRecord("流程异常", "高", $"成型机叫料出库(斜裁),起点:{outTask.POSITION_ID}在WMS系统中不存在"); |
| | | } |
| | | Location endLoc = WMSHelper.getCallMaterialLocCode(mesTask.EQP); |
| | | if (endLoc != null) |
| | | { |
| | | var wmsTask = WMSHelper.GetWmsTaskByCntr(outTask.PALLET_ID); |
| | | if (wmsTask == null) |
| | | var wcsTask = WCSHelper.GetTask(xcTask.AGVORDER_ID); |
| | | if (wcsTask != null) |
| | | { |
| | | // 1.创建斜裁-成新机叫料作业 |
| | | wmsTask = new WMSTask() |
| | | var wmsTask = WMSHelper.GetWmsTask(wcsTask.S_OP_CODE); |
| | | if (wmsTask != null) |
| | | { |
| | | S_CNTR_CODE = outTask.PALLET_ID, |
| | | S_CODE = WMSHelper.GenerateTaskNo(), |
| | | S_START_LOC = startLoc.S_CODE, |
| | | S_START_AREA = startLoc.S_AREA_CODE, |
| | | S_END_LOC = endLoc.S_CODE, |
| | | S_END_AREA = endLoc.S_AREA_CODE, |
| | | S_TYPE = "叫料出库任务", |
| | | S_OP_DEF_CODE = mesTask.ID.ToString(), |
| | | S_OP_DEF_NAME = "成型机叫料出库任务(斜裁)", |
| | | T_START_TIME = DateTime.Now, |
| | | }; |
| | | if (WMSHelper.CreateWmsTask(wmsTask)) |
| | | { |
| | | WCSTask wcsTask = new WCSTask() |
| | | Location startLoc = LocationHelper.GetLoc(xcTask.POSITION_ID); |
| | | if (startLoc != null) |
| | | { |
| | | S_OP_NAME = wmsTask.S_OP_DEF_NAME, |
| | | S_OP_CODE = wmsTask.S_CODE, |
| | | S_CODE = WCSHelper.GenerateTaskNo(), |
| | | S_CNTR_CODE = wmsTask.S_CNTR_CODE, |
| | | S_TYPE = wmsTask.S_TYPE, |
| | | S_START_LOC = startLoc.S_CODE, |
| | | S_START_AREA = startLoc.S_AREA_CODE, |
| | | S_END_LOC = endLoc.S_CODE, |
| | | S_END_AREA = endLoc.S_AREA_CODE, |
| | | S_SCHEDULE_TYPE = "AGV", |
| | | N_PRIORITY = 10, |
| | | T_START_TIME = DateTime.Now, |
| | | }; |
| | | wcsTask.S_CNTR_CODE = xcTask.PALLET_ID; |
| | | wcsTask.S_START_LOC = startLoc.S_CODE; |
| | | wcsTask.S_START_AREA = startLoc.S_AREA_CODE; |
| | | wcsTask.N_B_STATE = 0; |
| | | wcsTask.S_B_STATE = "等待"; |
| | | WCSHelper.UpdateWcsTask(wcsTask); |
| | | |
| | | if (WCSHelper.CreateTask(wcsTask)) |
| | | { |
| | | // 起点、终点加锁 |
| | | LocationHelper.LockLoc(wcsTask.S_START_LOC, 2); |
| | | LocationHelper.LockLoc(wcsTask.S_END_LOC, 1); |
| | | |
| | | // 更新作业任务状态 |
| | | wmsTask.S_CNTR_CODE = xcTask.PALLET_ID; |
| | | wmsTask.S_START_LOC = startLoc.S_CODE; |
| | | wmsTask.S_START_AREA = startLoc.S_AREA_CODE; |
| | | wmsTask.N_B_STATE = 1; |
| | | WMSHelper.UpdateTaskState(wmsTask); |
| | | wmsTask.S_B_STATE = "执行"; |
| | | WMSHelper.UpdateWmsTask(wmsTask); |
| | | |
| | | // 查询托盘物料信息表 |
| | | WMSHelper.updateCarrier(mesTask.PALLET_ID); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | mesTask.POSITION_ID = xcTask.POSITION_ID; |
| | | mesTask.RETURN_CODE = xcTask.RETURN_CODE; |
| | | mesTask.YCL_BATCH = xcTask.YCL_BATCH; |
| | | mesTask.PALLET_ID = xcTask.PALLET_ID; |
| | | WMSHelper.updateLjMesTask(mesTask); |
| | | } |
| | | } |
| | | } |
| | |
| | | WMSHelper.updateMateral(); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 定时更新库存信息 更新频率: 1分钟 |
| | | /// </summary> |
| | |
| | | .Where((a,b) => a.N_CURRENT_NUM > 0 && b.S_CNTR_CODE != null && areaCodeList.Contains(a.S_AREA_CODE) ) |
| | | .ToList(); |
| | | |
| | | // 删除所有库存信息,进行重置 |
| | | db.Deleteable<LjLotOnhand>().ExecuteCommand(); |
| | | |
| | | foreach (var loc in locations) |
| | | { |
| | | var lotOnhand = db.Queryable<LjLotOnhand>().Where(a => a.STORAGE_LOCATION == loc.S_CODE).First(); |
| | | if (lotOnhand != null) { |
| | | db.Deleteable<LjLotOnhand>().Where(a => a.ID == lotOnhand.ID).ExecuteCommand(); |
| | | } |
| | | |
| | | var locCntrRels = LocationHelper.GetLocCntr(loc.S_CODE); |
| | | if (locCntrRels != null && locCntrRels.Count > 0) |
| | | { |
| | |
| | | if (container != null) |
| | | { |
| | | LogHelper.Info($"容器的异常状态为:{container.N_E_STATE}", "AGV"); |
| | | string agvEndLoc = null; |
| | | if (container.N_E_STATE == 0) |
| | | { |
| | | agvEndLoc = ApiHelper.AGVApplyDest(model.No, cst.S_START_LOC, cst.S_CNTR_CODE, "1"); |
| | | ApiHelper.AGVApplyDest(model.No, cst.S_START_LOC, cst.S_CNTR_CODE, "1"); |
| | | } |
| | | else |
| | | { |
| | | agvEndLoc = ApiHelper.AGVApplyDest(model.No, cst.S_START_LOC, cst.S_CNTR_CODE, "2"); |
| | | ApiHelper.AGVApplyDest(model.No, cst.S_START_LOC, cst.S_CNTR_CODE, "2"); |
| | | } |
| | | |
| | | ChangeParamModel paramModel = new ChangeParamModel() |
| | |
| | | param = $"{model.No};{cst.S_START_LOC};{cst.S_END_LOC};4;512;0;1" |
| | | }; |
| | | NDCApi.ChangeOrderParam(paramModel); |
| | | LogHelper.Info($"变更AGV终点:{agvEndLoc}", "AGV"); |
| | | } |
| | | else |
| | | { |
| | |
| | | // 不合格品回库 |
| | | ApiHelper.rejectReturnStock(mst, cst); |
| | | } |
| | | else |
| | | { |
| | | // 如果作业名称为成型机叫料出库任务,则触发余料/空托搬运任务 |
| | | var sideLocConfig = WMSHelper.getReturnMaterialLocCode(mst.S_END_LOC); |
| | | ApiHelper.returnMaterialOrEmptyTray(sideLocConfig.S_RETURN_LOC_CODE, sideLocConfig.EQP); |
| | | } |
| | | } |
| | | |
| | | // 如果作业名称为成型机叫料出库任务,则触发余料/空托搬运任务 |
| | | var sideLocConfig = WMSHelper.getReturnMaterialLocCode(mst.S_END_LOC); |
| | | ApiHelper.returnMaterialOrEmptyTray(sideLocConfig.S_RETURN_LOC_CODE, sideLocConfig.EQP); |
| | | } |
| | | } |
| | | } |
| | |
| | | public string CREATION_DATE { get; set; } //创建日期 |
| | | public string RECEIVE_FLAG { get; set; } //记录状态 PENDING:默认 COMPLETE:读取 |
| | | public string RECEIVE_DATE { get; set; } //读取日期 读取后更新 |
| | | |
| | | /*public int ID { get; set; } //主键 |
| | | public string Material_Code { get; set; } //物料编码 |
| | | public string Material_Name { get; set; } //物料简称 |
| | | public string Spec { get; set; } //规格 |
| | | public string Model { get; set; } //型号 |
| | | public string Unit { get; set; } //单位 |
| | | public string Memo { get; set; } //备注 |
| | | public string creation_date { get; set; } //创建日期 |
| | | public string receive_flag { get; set; } //记录状态 PENDING:默认 COMPLETE:读取 |
| | | public string receive_date { get; set; } //读取日期 读取后更新*/ |
| | | } |
| | | } |
| | |
| | | public string RECEIVE_FLAG { get; set; } //记录状态 PENDING:默认 COMPLETE:读取 |
| | | public DateTime RECEIVE_DATE { get; set; } //读取日期 |
| | | |
| | | /*public int ID { get; set; } //主键 |
| | | public string Material_Code { get; set; } //物料编码 |
| | | public string Material_Name { get; set; } //物料名称 |
| | | public string Pallet_Type { get; set; } //托盘类型 |
| | | public string QTY { get; set; } //安全库存量 工装数量 |
| | | public string Transfer_Flag { get; set; } //转运标记 Y:优先转运 N: |
| | | public DateTime creation_date { get; set; } //创建日期 |
| | | public string receive_flag { get; set; } //记录状态 PENDING:默认 COMPLETE:读取 |
| | | public DateTime receive_date { get; set; } //读取日期*/ |
| | | |
| | | } |
| | | } |
| | |
| | | public string CREATION_DATE { get; set; } //创建日期 |
| | | public string RECEIVE_FLAG { get; set; } //记录状态 PENDING:默认 COMPLETE:读取 |
| | | public string RECEIVE_DATE { get; set; } //读取日期 |
| | | |
| | | |
| | | /*public int ID { get; set; } //主键 |
| | | public string Pallet_Id { get; set; } //托盘号 |
| | | public string lot_name { get; set; } //批次条码 (批次表更新) |
| | | public string YCL_BATCH { get; set; } //原材料批次号 |
| | | public string MaterialCode { get; set; } //物料编码 |
| | | public int QTY { get; set; } //物料数量 |
| | | public string Production_date { get; set; } //生产日期 |
| | | public string QC_Status { get; set; } //检验状态 |
| | | public string ShelfLife_Date { get; set; } //最长停放日期 |
| | | public string MinShelfLife_Date { get; set; } //最小停放日期 |
| | | public string creation_date { get; set; } //创建日期 |
| | | public string receive_flag { get; set; } //记录状态 PENDING:默认 COMPLETE:读取 |
| | | public string receive_date { get; set; } //读取日期*/ |
| | | } |
| | | } |
| | |
| | | public string IN_DATE { get; set; } //入库时间 |
| | | public DateTime CREATION_DATE { get; set; } //创建日期 |
| | | public string WAREHOUSE_TYPE { get; set; } //区分不同厂家(1/思尔特,2/杭叉) |
| | | |
| | | |
| | | |
| | | |
| | | /*public int ID { get; set; } //主键 |
| | | public string Material_Code { get; set; } //物料编码 |
| | | public string lot_name { get; set; } //批次条码 |
| | | public string Pallet_Id { get; set; } //托盘号 |
| | | public string Storage_Location { get; set; } //库位 |
| | | public string QC_Status { get; set; } //状态 |
| | | public string Unit { get; set; } //单位 |
| | | public float QTY { get; set; } //数量 |
| | | public string In_Date { get; set; } //入库时间 |
| | | public DateTime creation_date { get; set; } //创建日期 |
| | | public string warehouse_type { get; set; } //区分不同厂家(1/思尔特,2/杭叉)*/ |
| | | } |
| | | } |
| | |
| | | public string RECEIVE_DATE { get; set; } //读取日期 |
| | | public string TASK_STATUS { get; set; } //任务执行状态 1:执行中,2:完成 3:机台已返回 |
| | | public string EQP { get; set; } //机台编号 |
| | | |
| | | |
| | | /*public int ID { get; set; } //主键 |
| | | public string Material_Code { get; set; } //物料编码 |
| | | public string lot_name { get; set; } //批次条码 |
| | | public string Pallet_Id { get; set; } //托盘号 |
| | | public string Position_Id { get; set; } //点位编号 |
| | | public string QC_Status { get; set; } //状态 |
| | | public string Unit { get; set; } //单位 |
| | | public int QTY { get; set; } //数量 |
| | | public string Out_Date { get; set; } //出库时间 |
| | | public string creation_date { get; set; } //创建日期 |
| | | public string receive_flag { get; set; } //记录状态 PENDING:默认 COMPLETE:读取 |
| | | public string receive_date { get; set; } //读取日期 |
| | | public string Task_Status { get; set; } //任务执行状态 1:执行中,2:完成 3:机台已返回 |
| | | public string EQP { get; set; } //机台编号*/ |
| | | } |
| | | } |
| | |
| | | public DateTime CREATION_DATE { get; set; } //创建日期 |
| | | public string RECEIVE_FLAG { get; set; } //记录状态 PENDING:默认 COMPLETE:读取 |
| | | public DateTime RECEIVE_DATE { get; set; } //读取日期 |
| | | |
| | | |
| | | |
| | | |
| | | /* public int ID { get; set; } //主键 |
| | | public string Material_Code { get; set; } //物料编码 |
| | | public string lot_name { get; set; } //批次条码 |
| | | public string QC_Status { get; set; } //状态 |
| | | public string Unit { get; set; } //单位 |
| | | public string QTY { get; set; } //数量 |
| | | public string ShelfLife_Date { get; set; } //最长停放日期 会变更 |
| | | public string MinShelfLife_Date { get; set; } //最小停放日期 会变更 |
| | | public DateTime creation_date { get; set; } //创建日期 |
| | | public string receive_flag { get; set; } //记录状态 PENDING:默认 COMPLETE:读取 |
| | | public DateTime receive_date { get; set; } //读取日期*/ |
| | | } |
| | | } |
| | |
| | | public string AWAIT_MSG { get; set; } // 等待消息 |
| | | public bool IS_FINISH { get; set; } // 是否完成上料 |
| | | public string RECEIVE_MSG { get; set; } //错误信息 错误时,AGV写入详细错误信息 |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /* public int ID { get; set; } //主键 |
| | | public string Position_Id { get; set; } //点位编号 |
| | | public string Return_Code { get; set; } //反馈标识(AGV系统写入) 0:默认值 1:任务已生成 2:任务运行中 3:任务完成 4:任务失败 5:任务取消 6:其他错误 |
| | | public string Msg_Type { get; set; } //消息类型 0:要料 1:返车 |
| | | public string Pallet_Type { get; set; } //托盘类型 1.胎面;2.胎侧;3.内衬;4.帘布;5.环带;6.冠带;7.钢包 |
| | | public string Material_Name { get; set; } //物料名称 要料时给 |
| | | public string Material_Code { get; set; } //物料编码 要料时用,要料时,如果物料编码为空,代表要空工装 |
| | | public int QTY { get; set; } //数量 返车时用,数量为0代表返空车,数量为1代表返满料,数量为-1代表返余料。 物料信息在【托盘与信息对应表】中 |
| | | public string Ycl_batch { get; set; } //原材料批次号 |
| | | public string Pallet_Id { get; set; } //托盘号 返车时用,根据托盘号查找【托盘与信息对应表】中的信息 |
| | | public string AGVOrder_ID { get; set; } //AGV任务号 MES不用写入,AGV使用 |
| | | public string creation_date { get; set; } //创建日期 |
| | | public string receive_flag { get; set; } //记录状态 PENDING:默认 COMPLETE:读取 |
| | | public string receive_date { get; set; } //读取日期 读取后更新 |
| | | public string EQP { get; set; } //机台编号 |
| | | public string Plan_Id { get; set; } //计划号 |
| | | public string Await_Msg { get; set; } // 等待消息 |
| | | public bool Is_Finish { get; set; } // 是否完成上料 |
| | | public string Receive_Msg { get; set; } //错误信息 错误时,AGV写入详细错误信息*/ |
| | | } |
| | | } |
| | |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Security.Cryptography; |
| | | using static HH.WCS.Mobox3.FJJT.dispatch.XcDispatch; |
| | | |
| | | namespace HH.WCS.Mobox3.FJJT.process { |
| | | internal class TaskProcess { |
| | |
| | | internal static void OperateReq(string no, int state, string forkliftNo, string extData) { |
| | | LogHelper.Info($"开始安全请求,任务号:{no},请求码:{state}", "HosttoagvTask"); |
| | | var cst = WCSHelper.GetTask(no); |
| | | var taskAction = WCSHelper.getActionRecord(no, state); |
| | | if (taskAction != null) |
| | | if (cst != null) |
| | | { |
| | | LogHelper.Info($"再次安全请求,查询设备是否反馈", "HosttoagvTask"); |
| | | if (taskAction.N_S_STATUS == 1) |
| | | var taskAction = WCSHelper.getActionRecord(no, state); |
| | | if (taskAction != null) |
| | | { |
| | | LogHelper.Info($"再次安全请求,设备已反馈", "HosttoagvTask"); |
| | | NDCApi.ChangeOrderParam(no, 8, "1"); |
| | | LogHelper.Info($"再次安全请求,查询设备是否反馈", "HosttoagvTask"); |
| | | if (taskAction.N_S_STATUS == 1) |
| | | { |
| | | LogHelper.Info($"再次安全请求,设备已反馈", "HosttoagvTask"); |
| | | NDCApi.ChangeOrderParam(no, 8, "1"); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | LogHelper.Info($"首次进行安全请求,任务号:{no},请求码:{state}", "HosttoagvTask"); |
| | | bool result = false; |
| | | if (state == 1101) |
| | | else |
| | | { |
| | | result = WCSDispatch.safetyInteraction(cst.S_CODE ,cst.S_START_LOC, "1"); //请求取货, |
| | | } |
| | | if (state == 1102) |
| | | { |
| | | result = WCSDispatch.safetyInteraction(cst.S_CODE, cst.S_START_LOC, "2"); //请求返货 |
| | | } |
| | | if (state == 1103) |
| | | { |
| | | result = WCSDispatch.safetyInteraction(cst.S_CODE, cst.S_START_LOC, "3"); //取货完成允许离开 |
| | | } |
| | | if (state == 1104) |
| | | { |
| | | result = WCSDispatch.safetyInteraction(cst.S_CODE, cst.S_START_LOC, "4"); //放货完成允许离开 |
| | | } |
| | | LogHelper.Info($"首次进行安全请求,任务号:{no},请求码:{state}", "HosttoagvTask"); |
| | | bool result = false; |
| | | if (state == 1101) |
| | | { |
| | | if (cst.S_START_AREA == "") |
| | | { |
| | | result = XcDispatch.CanOut(new SafetyRequest() { stnNo = cst.S_START_LOC, taskNo = cst.S_CODE }); |
| | | if (result) |
| | | { |
| | | NDCApi.ChangeOrderParam(no, 8, "1"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | result = WCSDispatch.safetyInteraction(cst.S_CODE, cst.S_START_LOC, "1"); //请求取货, |
| | | } |
| | | } |
| | | if (state == 1102) |
| | | { |
| | | if (cst.S_START_AREA == "") |
| | | { |
| | | result = XcDispatch.CanIn(new SafetyRequest() { stnNo = cst.S_END_LOC, taskNo = cst.S_CODE }); |
| | | if (result) |
| | | { |
| | | NDCApi.ChangeOrderParam(no, 8, "1"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | result = WCSDispatch.safetyInteraction(cst.S_CODE, cst.S_END_LOC, "2"); //请求放货 |
| | | } |
| | | } |
| | | if (state == 1103) |
| | | { |
| | | if (cst.S_START_AREA == "") |
| | | { |
| | | result = XcDispatch.loadComplete(new SafetyRequest() { stnNo = cst.S_END_LOC, taskNo = cst.S_CODE }); |
| | | if (result) |
| | | { |
| | | NDCApi.ChangeOrderParam(no, 8, "1"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | result = WCSDispatch.safetyInteraction(cst.S_CODE, cst.S_START_LOC, "3"); //取货完成允许离开 |
| | | } |
| | | } |
| | | if (state == 1104) |
| | | { |
| | | if (cst.S_START_AREA == "") |
| | | { |
| | | result = XcDispatch.putComplete(new SafetyRequest() { stnNo = cst.S_END_LOC, taskNo = cst.S_CODE }); |
| | | if (result) |
| | | { |
| | | NDCApi.ChangeOrderParam(no, 8, "1"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | result = WCSDispatch.safetyInteraction(cst.S_CODE, cst.S_END_LOC, "4"); //放货完成允许离开 |
| | | } |
| | | } |
| | | |
| | | // 安全请求发送成功,添加任务动作记录 |
| | | if (result) |
| | | { |
| | | WCSHelper.AddActionRecord(no, state, forkliftNo, extData); |
| | | LogHelper.Info($"首次进行安全请求成功", "HosttoagvTask"); |
| | | // 安全请求发送成功,添加任务动作记录 |
| | | if (result) |
| | | { |
| | | WCSHelper.AddActionRecord(no, state, forkliftNo, extData); |
| | | LogHelper.Info($"首次进行安全请求成功", "HosttoagvTask"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | /// <param name="mst"></param> |
| | | internal static bool SendTask(WCSTask mst) { |
| | | var result = false; |
| | | var start = "0"; var end = "0"; |
| | | if (mst.N_B_STATE == 0) { |
| | | if (mst.S_SCHEDULE_TYPE == "NDC") |
| | | { |
| | | start = LocationHelper.GetAgvSite(mst.S_START_LOC); |
| | | end = LocationHelper.GetAgvSite(mst.S_END_LOC); |
| | | |
| | | var dic = new List<param>(); |
| | | dic.Add( new param() { name = "No" , value = ""}); |
| | | dic.Add( new param() { name = "From", value = ""}); |
| | | dic.Add( new param() { name = "To", value = ""}); |
| | | dic.Add( new param() { name = "3" , value = "4"}); |
| | | dic.Add( new param() { name = "4" , value = "512"}); |
| | | dic.Add( new param() { name = "5" , value = "0"}); |
| | | var res = NDCApi.AddOrderNew(1,mst.N_PRIORITY,mst.S_CODE,dic); |
| | | if (res != null && res.err_code == 0 ) { |
| | | //推送成功,修改任务优先级 |
| | | mst.N_B_STATE = 1; |
| | | WCSHelper.UpdateStatus(mst); |
| | | result = true; |
| | | var startLoc = LocationHelper.GetLoc(mst.S_START_LOC); |
| | | var endLoc = LocationHelper.GetLoc(mst.S_END_LOC); |
| | | if (startLoc != null && endLoc != null) |
| | | { |
| | | var dic = new List<param>(); |
| | | dic.Add(new param() { name = "No", value = mst.S_CODE }); |
| | | dic.Add(new param() { name = "From", value = mst.S_START_LOC }); |
| | | dic.Add(new param() { name = "To", value = mst.S_END_LOC }); |
| | | dic.Add(new param() { name = "3", value = "4" }); |
| | | dic.Add(new param() { name = "4", value = "512" }); |
| | | dic.Add(new param() { name = "5", value = "0" }); |
| | | var res = NDCApi.AddOrderNew(1, mst.N_PRIORITY, mst.S_CODE, dic); |
| | | if (res != null && res.err_code == 0) |
| | | { |
| | | //推送成功,修改任务优先级 |
| | | mst.N_B_STATE = 1; |
| | | WCSHelper.UpdateStatus(mst); |
| | | result = true; |
| | | } |
| | | } |
| | | } |
| | | else if (mst.S_SCHEDULE_TYPE == "WCS") { |
| | |
| | | mst.N_B_STATE = 1; |
| | | WCSHelper.UpdateStatus(mst); |
| | | } |
| | | |
| | | } |
| | | return result; |
| | | } |
| | |
| | | |
| | | db.Aop.OnExecutingChangeSql = (sql, pars) => //可以修改SQL和参数的值 |
| | | { |
| | | if (db.CurrentConnectionConfig.DbType == DbType.Oracle && pars.Any()) |
| | | if (pars != null && db.CurrentConnectionConfig.DbType == DbType.Oracle && pars.Any()) |
| | | { |
| | | var input = sql; |
| | | Stack<int> stack = new Stack<int>(); |
| | |
| | | var date = DateTime.Now.ToString("yyMMdd"); |
| | | return $"TP{date}{id.ToString().PadLeft(4, '0')}"; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// TN_ContainerHelper.test("4L天然水箱装6入", 50, "335ml东方树叶15入", 30); |
| | | /// </summary> |
| | | /// <param name="item1"></param> |
| | | /// <param name="qty1"></param> |
| | | /// <param name="item2"></param> |
| | | /// <param name="qty2"></param> |
| | | //internal static void test(string item1, int qty1, string item2, int qty2) { |
| | | // var db = new SqlHelper<object>().GetInstance(); |
| | | // var cntr = db.Queryable<TN_Container>().Includes(a => a.CntrItemRelList). |
| | | // Where(a => a.CntrItemRelList.Count(b => b.S_ITEM_CODE == item1 && int.Parse(b.F_QTY) > qty1) > 0 |
| | | // && a.CntrItemRelList.Count(b => b.S_ITEM_CODE == item2 && int.Parse(b.F_QTY) > qty2) > 0).First(); |
| | | //} |
| | | |
| | | /// <summary> |
| | | /// 判断容器是否有物料信息 |
| | |
| | | return db.Queryable<LocCntrRel>().Count(a => a.S_LOC_CODE.Trim() == cntr) == 0; |
| | | |
| | | } |
| | | |
| | | /*internal static bool AddCntr(string cntrCode, string itemCode) { |
| | | var res = false; |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | var TN_Container = new Container { S_CODE = cntrCode }; |
| | | var cntrItemRel = new CntrItemRel { S_CNTR_CODE = cntrCode, S_ITEM_CODE = itemCode }; |
| | | try { |
| | | db.BeginTran(); |
| | | |
| | | db.Insertable<Container>(TN_Container).ExecuteCommand(); |
| | | db.Insertable<CntrItemRel>(cntrItemRel).ExecuteCommand(); |
| | | |
| | | db.CommitTran(); |
| | | res = true; |
| | | } |
| | | catch (Exception ex) { |
| | | db.RollbackTran(); |
| | | |
| | | } |
| | | return res; |
| | | }*/ |
| | | |
| | | internal static bool AddCntr(string cntrCode ,int detallCount = 0) |
| | | { |
| | |
| | | return db.Updateable(cntrItem).ExecuteCommand()>0; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 物料信息绑定到满容器上 |
| | | /// </summary> |
| | | /// <param name="cntrCode"></param> |
| | | /// <param name="itemCode"></param> |
| | | /// <param name="batchNo"></param> |
| | | /// <param name="qty"></param> |
| | | /// <returns></returns> |
| | | internal static bool BindCntrItem(Container cntr, string itemCode, string batchNo, float qty) { |
| | | var res = false; |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | try { |
| | | db.BeginTran(); |
| | | //1.查看是否有相同物料批次的信息,如果有要累加,不同批次的可以分开 |
| | | var cir = db.Queryable<CntrItemRel>().Where(a => a.S_CNTR_CODE == cntr.S_CODE && a.S_ITEM_CODE == itemCode && a.S_BATCH_NO == batchNo).First(); |
| | | if (cir != null) { |
| | | cir.F_QTY += qty; |
| | | db.Updateable(cir).UpdateColumns(it => new { it.F_QTY }).ExecuteCommand(); |
| | | } |
| | | else { |
| | | //2.插入新的容器物料信息(容器号不变) |
| | | cir = new CntrItemRel { S_CNTR_CODE = cntr.S_CODE.Trim(), S_BATCH_NO = batchNo, F_QTY = qty, S_ITEM_CODE = itemCode }; |
| | | db.Insertable<CntrItemRel>(cir).ExecuteCommand(); |
| | | } |
| | | var count = db.Queryable<CntrItemRel>().Count(a => a.S_CNTR_CODE == cntr.S_CODE); |
| | | cntr.N_DETAIL_COUNT = count; |
| | | cntr.C_ENABLE = "N";//码盘后将托盘设置为不可用状态,入库后变成可用 |
| | | db.Updateable(cntr).UpdateColumns(it => new { it.N_DETAIL_COUNT, it.C_ENABLE}).ExecuteCommand(); |
| | | |
| | | db.CommitTran(); |
| | | res = true; |
| | | } |
| | | catch (Exception ex) { |
| | | db.RollbackTran(); |
| | | Console.WriteLine(ex.Message); |
| | | } |
| | | |
| | | return res; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | internal static bool UpdateCntr(Container container) |
| | | { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | return db.Updateable(container).ExecuteCommand()>0; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// |
| | |
| | | { |
| | | var res = false; |
| | | var db = new SqlHelper<WCSTask>().GetInstance(); |
| | | task.T_MODIFY = DateTime.Now; |
| | | res = db.Updateable(task).ExecuteCommand() > 0; |
| | | return res; |
| | | } |
| | |
| | | using System.Globalization; |
| | | using System.Linq; |
| | | using System.Linq.Expressions; |
| | | using System.Numerics; |
| | | using System.Reflection; |
| | | using System.Runtime.ConstrainedExecution; |
| | | using System.Threading.Tasks; |
| | |
| | | task.S_B_STATE = WMSTask.GetStateStr(task.N_B_STATE); |
| | | db.Updateable<WMSTask>(task).UpdateColumns(a => new { a.N_TYPE,a.N_B_STATE, a.S_B_STATE, a.T_MODIFY,a.T_END_TIME }).ExecuteCommand(); |
| | | } |
| | | |
| | | |
| | | internal static void UpdateWmsTask(WMSTask task) |
| | | { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | task.T_MODIFY = DateTime.Now; |
| | | db.Updateable<WMSTask>(task).ExecuteCommand(); |
| | | } |
| | | |
| | | internal static bool UpdateTaskEnd(WMSTask a) { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | |
| | | /// </summary> |
| | | /// <param name="itemCode"></param> |
| | | /// <returns></returns> |
| | | public static List<CntrItemRel> getZZKInventoryInfo(string itemCode) |
| | | public static DateTime getZZKInventoryInfo(string itemCode) |
| | | { |
| | | DateTime inboundTime = DateTime.MinValue; |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | List < CntrItemRel > cntrItemRels = new List<CntrItemRel>(); |
| | | string areaCode = Settings.areaPropertyList.Where(a => a.areaName.Contains("中转库")).Select(a => a.areaCode).FirstOrDefault(); |
| | | if (areaCode != null) |
| | | { |
| | | cntrItemRels = db.Queryable<CntrItemRel>() |
| | | inboundTime = db.Queryable<CntrItemRel>() |
| | | .LeftJoin<LocCntrRel>((a, b) => a.S_CNTR_CODE == b.S_CNTR_CODE) |
| | | .LeftJoin<Location>((a, b, c) => b.S_LOC_CODE == c.S_CODE) |
| | | .LeftJoin<Container>((a, b, c, d) => a.S_CNTR_CODE == d.S_CODE) |
| | |
| | | && d.N_E_STATE == 0 // 托盘正常 |
| | | ) |
| | | .OrderBy((a, b, c, d) => a.T_INBOUND_TIME) |
| | | .ToList(); |
| | | .Select((a, b, c, d) => a.T_INBOUND_TIME) |
| | | .First(); |
| | | } |
| | | return cntrItemRels; |
| | | return inboundTime; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | .LeftJoin<CntrItemRel>((a, b, c, d) => c.S_CODE == d.S_CNTR_CODE) |
| | | .Where((a, b, c, d) => a.N_CURRENT_NUM > 0 && a.N_LOCK_STATE == 0 && a.C_ENABLE.Trim() == "Y" ); |
| | | |
| | | if (areaCode != null && areaCode != "") |
| | | if (areaCode != null && areaCode != "") |
| | | { |
| | | queryable = queryable.Where((a, b, c, d ) => a.S_AREA_CODE.Trim() == areaCode); |
| | | queryable = queryable.Where((a, b, c, d) => a.S_AREA_CODE.Trim() == areaCode); |
| | | } |
| | | else |
| | | { |
| | | List<string> areaCodes = Settings.areaPropertyList.Select(a => a.areaCode).ToList(); |
| | | queryable = queryable.Where((a, b, c, d) => areaCodes.Contains(a.S_AREA_CODE.Trim())); |
| | | } |
| | | if (traySatus == 0) |
| | | { |
| | |
| | | return location; |
| | | } |
| | | |
| | | public static bool addAlarmRecord(string alarmType , string alarmLevel ,string alarmMsg ,string logSite = "WMS") { |
| | | public static bool addAlarmRecord(string alarmType , string alarmLevel ,string alarmMsg ,string logSite = "WMS") { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | bool result = true; |
| | | LogHelper.Info(alarmMsg, logSite); |
| | |
| | | /// 1.查询异常区货位 |
| | | /// </summary> |
| | | /// <param name="areaCode">库区</param> |
| | | /// <param name="property">货位属性(1.直连 2.非直连)</param> |
| | | /// <param name="type">动作类型(0.人工接驳位 1.入库接驳位 2.出库接驳位)</param> |
| | | /// <param name="property">货位属性(1.直连 2.非直连)</param> |
| | | /// <returns></returns> |
| | | public static Location GetTransfeRelevanceLoc(string areaCode ,int type ,int property ) |
| | | { |
| | |
| | | |
| | | /// <summary> |
| | | /// 读取MES下料任务 |
| | | /// 1.备份容器物料信息 |
| | | /// 2.更新中间表状态为已读 |
| | | /// 1.读取MES下发任务表 |
| | | /// 2.读取托盘物料信息表 |
| | | /// 3.读取基础物料信息表 |
| | | /// </summary> |
| | | /// <param name="taskNo"></param> |
| | | /// <param name="id"></param> |
| | | /// <returns></returns> |
| | | internal static LjMesTask readLjMesOffItemTask(string taskNo , int id) |
| | | internal static bool readLjMesOffItemTask(string taskNo , int id) |
| | | { |
| | | bool res = true; |
| | | LogHelper.Info($"查询到MES下发WMS任务,mesTaskId:{id},任务号:{taskNo}" , "WMS"); |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | try |
| | | { |
| | | db.BeginTran(); |
| | | // 1.查询MES任务表 |
| | | // 1.读取MES下发任务表 |
| | | var mesTask = db.Queryable<LjMesTask>().Where(a => a.ID == id && a.RECEIVE_FLAG.Trim() == "PENDING" ).OrderByDescending(a => a.T_CREATE).First(); |
| | | if (mesTask != null) |
| | | { |
| | | // 重置空工装信息 |
| | | ContainerHelper.AddContainer(mesTask.PALLET_ID, int.Parse(mesTask.PALLET_TYPE),mesTask.QTY == 0 ? 0 : 1); |
| | | |
| | | mesTask.AGVORDER_ID = taskNo; |
| | | mesTask.RETURN_CODE = "1"; |
| | | mesTask.RECEIVE_FLAG = "COMPLETE"; |
| | | mesTask.RECEIVE_DATE = DateTime.Now.ToString("yyyy-MM-dd"); |
| | | db.Updateable(mesTask).ExecuteCommand(); |
| | | // 2.读取托盘物料信息表 |
| | | res = updateCarrier(mesTask.PALLET_ID); |
| | | if (res) |
| | | { |
| | | mesTask.AGVORDER_ID = taskNo; |
| | | mesTask.RETURN_CODE = "1"; |
| | | mesTask.RECEIVE_FLAG = "COMPLETE"; |
| | | mesTask.RECEIVE_DATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); |
| | | db.Updateable(mesTask).ExecuteCommand(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | LogHelper.Info("未查询到MES下发WMS任务", "WMS"); |
| | | WMSHelper.addAlarmRecord("流程异常", "中", $"未查询到MES下发的任务,MES任务ID:{id}"); |
| | | } |
| | | db.CommitTran(); |
| | | return mesTask; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | res = false; |
| | | db.RollbackTran(); |
| | | LogHelper.Info($"读取MES下发任务失败,错误原因:{ex.Message}" , "WMS"); |
| | | WMSHelper.addAlarmRecord("系统错误", "高", $"读取MES下发任务失败,错误原因:{ex.Message}"); |
| | | } |
| | | return null; |
| | | return res; |
| | | } |
| | | |
| | | public static bool updateCarrier(string palletId) |
| | | { |
| | | bool res = true; |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | var container = ContainerHelper.GetCntr(palletId); |
| | | if (container != null) |
| | | { |
| | | // 1.读取托盘物料信息表 |
| | | var lotCarrier = db.Queryable<LjLotCarrier>().Where(a => a.RECEIVE_FLAG.Trim() == "PENDING" && a.PALLET_ID == palletId).OrderByDescending(a => a.CREATION_DATE).First(); |
| | | if (lotCarrier != null) |
| | | { |
| | | CntrItemRel cntrItemRel = db.Queryable<CntrItemRel>().Where(a => a.S_CNTR_CODE == palletId).First(); |
| | | if (cntrItemRel != null) |
| | | { |
| | | cntrItemRel.S_CNTR_CODE = lotCarrier.PALLET_ID; |
| | | cntrItemRel.S_BATCH_NO = lotCarrier.LOT_NAME; |
| | | cntrItemRel.S_SERIAL_NO = lotCarrier.YCL_BATCH; |
| | | cntrItemRel.S_ITEM_CODE = lotCarrier.MATERIALCODE; |
| | | cntrItemRel.F_QTY = lotCarrier.QTY; |
| | | cntrItemRel.D_PRD_DATE = lotCarrier.PRODUCTION_DATE; |
| | | cntrItemRel.S_ITEM_STATE = lotCarrier.QC_STATUS; |
| | | cntrItemRel.D_EXP_DATE = lotCarrier.SHELFLIFE_DATE; |
| | | cntrItemRel.D_EXP_DATE1 = lotCarrier.MINSHELFLIFE_DATE; |
| | | db.Updateable(cntrItemRel).ExecuteCommand(); |
| | | } |
| | | else |
| | | { |
| | | cntrItemRel = new CntrItemRel() |
| | | { |
| | | S_CNTR_CODE = lotCarrier.PALLET_ID, |
| | | S_BATCH_NO = lotCarrier.LOT_NAME, |
| | | S_SERIAL_NO = lotCarrier.YCL_BATCH, |
| | | S_ITEM_CODE = lotCarrier.MATERIALCODE, |
| | | F_QTY = lotCarrier.QTY, |
| | | D_PRD_DATE = lotCarrier.PRODUCTION_DATE, |
| | | S_ITEM_STATE = lotCarrier.QC_STATUS, |
| | | D_EXP_DATE = lotCarrier.SHELFLIFE_DATE, |
| | | D_EXP_DATE1 = lotCarrier.MINSHELFLIFE_DATE, |
| | | }; |
| | | db.Insertable(cntrItemRel).ExecuteCommand(); |
| | | } |
| | | |
| | | lotCarrier.RECEIVE_FLAG = "COMPLETE"; |
| | | lotCarrier.RECEIVE_DATE = DateTime.Now.ToString("yyyy-MM-dd"); |
| | | db.Updateable(lotCarrier).UpdateColumns(a => new { a.RECEIVE_FLAG, a.RECEIVE_DATE }).ExecuteCommand(); |
| | | |
| | | // 读取基础物料信息表 |
| | | var material = db.Queryable<LjItem>().Where(a => a.RECEIVE_FLAG.Trim() == "PENDING" && a.MATERIAL_CODE == lotCarrier.MATERIALCODE).OrderByDescending(a => a.CREATION_DATE).First(); |
| | | if (material != null) |
| | | { |
| | | TN_Material tn_material = db.Queryable<TN_Material>().Where(a => a.S_ITEM_CODE == material.MATERIAL_CODE).First(); |
| | | |
| | | if (tn_material != null) |
| | | { |
| | | tn_material.S_ITEM_CODE = material.MATERIAL_CODE; |
| | | tn_material.S_ITEM_NAME = material.MATERIAL_NAME; |
| | | tn_material.S_SPEC = material.SPEC; |
| | | tn_material.S_MODEL = material.MODEL; |
| | | tn_material.S_UNIT = material.UNIT; |
| | | tn_material.S_MEMO = material.MEMO; |
| | | db.Updateable(material).ExecuteCommand(); |
| | | } |
| | | else |
| | | { |
| | | tn_material = new TN_Material() |
| | | { |
| | | S_ITEM_CODE = material.MATERIAL_CODE, |
| | | S_ITEM_NAME = material.MATERIAL_NAME, |
| | | S_SPEC = material.SPEC, |
| | | S_MODEL = material.MODEL, |
| | | S_UNIT = material.UNIT, |
| | | S_MEMO = material.MEMO, |
| | | }; |
| | | db.Insertable(material).ExecuteCommand(); |
| | | } |
| | | |
| | | material.RECEIVE_FLAG = "COMPLETE"; |
| | | material.RECEIVE_DATE = DateTime.Now.ToString("yyyy-MM-dd"); |
| | | db.Updateable(material).ExecuteCommand(); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | WMSHelper.addAlarmRecord("流程异常", "中", $"未在WMS系统中查询到容器信息,容器编码:{palletId}"); |
| | | res = false; |
| | | } |
| | | return res; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | var lotCarrierList = db.Queryable<LjLotCarrier>().Where(a => a.RECEIVE_FLAG.Trim() == "PENDING").ToList(); |
| | | foreach (var lotCarrier in lotCarrierList) |
| | | { |
| | | // 写入斜裁托盘物料信息中间表 |
| | | CntrItemRel cntrItemRel = db.Queryable<CntrItemRel>().Where(a => a.S_CNTR_CODE == lotCarrier.PALLET_ID).First(); |
| | | |
| | | if (cntrItemRel != null) |
| | |
| | | /// <returns></returns> |
| | | internal static LjLotCarrier getLjCntrMaterial(string trayNo) |
| | | { |
| | | // 1.查询MES任务表 |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | var lotCarrier = db.Queryable<LjLotCarrier>().Where(a => a.PALLET_ID.Trim() == trayNo).First(); |
| | | return lotCarrier; |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 查询MES任务表(环带) |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static List<LjMesTask> GetLjMesTaskListHD() |
| | | { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | return db.Queryable<LjMesTask>().Where(a => (a.PALLET_TYPE == "5" || a.PALLET_TYPE == "6") && (a.RETURN_CODE.Trim() == "0" || a.RETURN_CODE.Trim() == "1" || a.RETURN_CODE.Trim() == "2")).ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 更新MES任务状态 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static bool updateMesTaskStatus(LjMesTask mesTask) |
| | | { |
| | | bool result = false; |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | result = db.Updateable<LjMesTask>(mesTask).ExecuteCommand() > 0; |
| | | return result; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 更新MES任务状态 |
| | | /// </summary> |
| | | /// <param name="taskNo"></param> |
| | |
| | | |
| | | // -----------------------------------------斜裁中间表---------------------------------------------- |
| | | |
| | | /// <summary> |
| | | /// 更新MES任务状态 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static bool updateXcTaskStatus(LjXcTask xcTask) |
| | | { |
| | | bool result = false; |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | result = db.Updateable<LjXcTask>(xcTask).ExecuteCommand() > 0; |
| | | return result; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 下发XC任务 |
| | | /// 将MES下发任务、托盘物料信息 转发给斜裁 |
| | | /// </summary> |
| | | /// <param name="mesTask"></param> |
| | | /// <returns></returns> |
| | |
| | | bool result = false; |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | if (mesTask != null) { |
| | | if (mesTask.MSG_TYPE == "1") |
| | | { |
| | | // 转发托盘物料信息 |
| | | var ljLotCarrier = db.Queryable<LjLotCarrier>().Where(a => a.PALLET_ID == mesTask.PALLET_ID && a.RECEIVE_FLAG == "PENDING").OrderByDescending(a => a.CREATION_DATE).First(); |
| | | if (ljLotCarrier != null) |
| | | { |
| | | LjXcCarrier ljXcCarrier = new LjXcCarrier() |
| | | { |
| | | ID = ljLotCarrier.ID, |
| | | PALLET_ID = ljLotCarrier.PALLET_ID, |
| | | LOT_NAME = ljLotCarrier.LOT_NAME, |
| | | YCL_BATCH = ljLotCarrier.YCL_BATCH, |
| | | MATERIALCODE = ljLotCarrier.MATERIALCODE, |
| | | QTY = ljLotCarrier.QTY, |
| | | PRODUCTION_DATE = ljLotCarrier.PRODUCTION_DATE, |
| | | QC_STATUS = ljLotCarrier.QC_STATUS, |
| | | SHELFLIFE_DATE = ljLotCarrier.SHELFLIFE_DATE, |
| | | MINSHELFLIFE_DATE = ljLotCarrier.MINSHELFLIFE_DATE, |
| | | CREATION_DATE = ljLotCarrier.CREATION_DATE, |
| | | RECEIVE_FLAG = ljLotCarrier.RECEIVE_FLAG, |
| | | }; |
| | | var bo = db.Insertable<LjXcCarrier>(ljXcCarrier).ExecuteCommand() > 0; |
| | | if (bo) |
| | | { |
| | | ljLotCarrier.RECEIVE_FLAG = "COMPLETE"; |
| | | ljLotCarrier.RECEIVE_DATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); |
| | | db.Updateable<LjLotCarrier>(ljLotCarrier).ExecuteCommand(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | LjXcTask ljXcTask = new LjXcTask() { |
| | | ID = mesTask.ID, |
| | | POSITION_ID = mesTask.POSITION_ID, |
| | |
| | | PLAN_ID = mesTask.PLAN_ID |
| | | }; |
| | | result = db.Insertable<LjXcTask>(ljXcTask).ExecuteCommand() > 0; |
| | | if (result) |
| | | { |
| | | mesTask.RETURN_CODE = "1"; |
| | | mesTask.RECEIVE_FLAG = "COMPLETE"; |
| | | mesTask.RECEIVE_DATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); |
| | | db.Updateable<LjMesTask>(mesTask).ExecuteCommand(); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | |
| | | ContainerHelper.deleteCntrItem(wmsTask.S_CNTR_CODE); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | WCSHelper.Fail(wcsTask); |
| | | LocationHelper.UnLockLoc(wcsTask.S_START_LOC); |
| | |
| | | |
| | | foreach (var item in ApiHelper.cacheInstockInfos) |
| | | { |
| | | LogHelper.Info($"缓存信号处理,缓存IP:{item.Key}", "TSSG"); |
| | | var instockInfo = item.Value; |
| | | var end = WMSHelper.GetInstockEnd(instockInfo.item, instockInfo.endArea); |
| | | LogHelper.Info("终点货位:" + JsonConvert.SerializeObject(end), "TSSG"); |
| | | LogHelper.Info("(缓存信号)终点货位:" + JsonConvert.SerializeObject(end), "TSSG"); |
| | | if (end != null) |
| | | { |
| | | ApiHelper.Instock(instockInfo); |
| | |
| | | var instockInfo = item.Value; |
| | | if (instockInfo.UDID == flag1) { |
| | | if (Settings.BufferArea != null && Settings.BufferArea != "") { |
| | | item.Value.endArea = Settings.BufferArea; |
| | | LogHelper.Info("ip:" + item.Key + "信号等待时间超时,变更终点库区为缓存区", "TSSG"); |
| | | var end = WMSHelper.GetInstockEnd(instockInfo.item, Settings.BufferArea); |
| | | if (end != null) { |
| | | item.Value.endArea = Settings.BufferArea; |
| | | LogHelper.Info("ip:" + item.Key + "信号等待时间超时,变更终点库区为缓存区", "TSSG"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | if (Settings.BufferArea != null && Settings.BufferArea != "") |
| | | { |
| | | item.Value.endArea = Settings.BufferArea; |
| | | LogHelper.Info("ip:" + item.Key + "信号等待时间超时,变更终点库区为缓存区", "TSSG"); |
| | | var end = WMSHelper.GetInstockEnd(instockInfo.item, Settings.BufferArea); |
| | | if (end != null) |
| | | { |
| | | item.Value.endArea = Settings.BufferArea; |
| | | LogHelper.Info("ip:" + item.Key + "信号等待时间超时,变更终点库区为缓存区", "TSSG"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | internal static void Analysis(string data, string ip) { |
| | | |
| | | if (!lastReceiptTime.TryGetValue(ip, out DateTime lastTime)) // 安全获取值 |
| | | // 检查是否需要跳过处理 |
| | | if (lastReceiptTime.TryGetValue(ip, out DateTime lastTime) && |
| | | DateTime.Now < lastTime.AddMinutes(1)) |
| | | { |
| | | lastReceiptTime[ip] = DateTime.Now; // 使用索引器自动添加或更新 |
| | | } |
| | | else if (lastTime < DateTime.Now.AddMinutes(-1)) |
| | | { |
| | | lastReceiptTime[ip] = DateTime.Now; |
| | | } |
| | | else |
| | | { |
| | | return; |
| | | return; // 1分钟内重复请求,跳过 |
| | | } |
| | | |
| | | // 更新接收时间并执行业务逻辑 |
| | | lastReceiptTime[ip] = DateTime.Now; |
| | | |
| | | LogHelper.Info($"下发入库请求,IP:{ip}", "TSSG"); |
| | | if (data.Length >= 6) { |
| | | //去掉消息头3F 00 |
| | | data = data.Substring(4); |
| | |
| | | <Compile Include="dispatch\HanAo.cs" /> |
| | | <Compile Include="dispatch\NDC.cs" /> |
| | | <Compile Include="core\Monitor.cs" /> |
| | | <Compile Include="dispatch\NDCApi.cs" /> |
| | | <Compile Include="dispatch\WCSDispatch.cs" /> |
| | | <Compile Include="models\BaseModel.cs" /> |
| | | <Compile Include="models\Area.cs" /> |
| | |
| | | using System.Reflection; |
| | | using System.Text.RegularExpressions; |
| | | using System.Threading; |
| | | using Ubiety.Dns.Core; |
| | | using static HH.WCS.Mobox3.YNJT_PT.api.ApiModel; |
| | | using static HH.WCS.Mobox3.YNJT_PT.api.OtherModel; |
| | | using static HH.WCS.Mobox3.YNJT_PT.api.WmsController; |
| | | using static HH.WCS.Mobox3.YNJT_PT.dispatch.WCSDispatch; |
| | | using static HH.WCS.Mobox3.YNJT_PT.util.Settings; |
| | | using static HH.WCS.Mobox3.YNJT_PT.wms.WMSHelper; |
| | | using static System.Net.Mime.MediaTypeNames; |
| | |
| | | /// 成型机下线记录 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | public static ResponseResult cxjOffLineRecord(OffLineModel model) |
| | | public static ResponseResult cxjOffLineRecord(NotifyDeviceSignalModel model) |
| | | { |
| | | ResponseResult response = new ResponseResult(); |
| | | var container = ContainerHelper.GetCntr(model.rfid); |
| | | var container = ContainerHelper.GetCntr(model.cntrNo); |
| | | if (container == null) |
| | | { |
| | | ContainerHelper.AddCntr(model.rfid); |
| | | ContainerHelper.AddCntr(model.cntrNo); |
| | | } |
| | | |
| | | try |
| | | { |
| | | OffLineModel extData1 = JsonConvert.DeserializeObject<OffLineModel>(model.extData.ToString()); |
| | | OffLineRecord record = new OffLineRecord() |
| | | { |
| | | S_RFID = model.rfid, |
| | | S_RFID = model.cntrNo, |
| | | S_DEVICE_NO = model.deviceNo, |
| | | N_IS_URGENT = model.isUrgent, |
| | | N_IS_URGENT = extData1.isUrgent, |
| | | T_OFF_TIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), |
| | | N_IS_FULL = model.isFull, |
| | | N_IS_FULL = extData1.isFull, |
| | | N_NEED_PAIR = extData1.needPair, |
| | | S_LOC = model.loc |
| | | }; |
| | | WMSHelper.addOffLineRecord(record); |
| | |
| | | var startLoc = LocationHelper.GetLoc(model.loc); |
| | | if (startLoc != null) |
| | | { |
| | | List<BarcodeModel> extData = model.extData; |
| | | List<BarcodeModel> extData = JsonConvert.DeserializeObject<List<BarcodeModel>>(model.extData.ToString()); |
| | | int dataCount = extData.Count; |
| | | if (dataCount > 0) |
| | | { |
| | |
| | | var offLineRecord = WMSHelper.getOffLineRecord(rfid); |
| | | if (offLineRecord != null) |
| | | { |
| | | if (offLineRecord.N_IS_FULL == 1) |
| | | if (offLineRecord.N_IS_FULL == 1) |
| | | { |
| | | if (ext.barcode.Contains("99999999")) |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | // 记录查询条码信息异常 |
| | | // 记录查询条码信息异常 |
| | | |
| | | } |
| | | } |
| | |
| | | } |
| | | else if (wcsTask.S_TYPE == "胚胎叫料出库任务") |
| | | { |
| | | if (model.cntrNo != wcsTask.S_CNTR_CODE) |
| | | var cntrItemRels = ContainerHelper.GetCntrItemRel(wcsTask.S_CNTR_CODE); |
| | | if (model.cntrNo != wcsTask.S_CNTR_CODE || cntrItemRels.Count == 0 || cntrItemRels.Count > 0 && cntrItemRels[0].S_ITEM_STATE != "OK") |
| | | { |
| | | // 计算排出口 |
| | | endLoc = WMSHelper.getCallOutLoc(endLoc.N_ROW); |
| | |
| | | readCodeFeedbackResponse.verifyResult = false; |
| | | readCodeFeedbackResponse.endLoc = endLoc.S_CODE; |
| | | } |
| | | else |
| | | { |
| | | var cntrItemRels = ContainerHelper.GetCntrItemRel(wcsTask.S_CNTR_CODE); |
| | | if (cntrItemRels.Count > 0) |
| | | { |
| | | if (cntrItemRels[0].S_ITEM_STATE != "OK") |
| | | { |
| | | endLoc = WMSHelper.getMinTaskMiddleLoc(1,endLoc.N_ROADWAY); ; |
| | | |
| | | wcsTask.S_END_LOC = endLoc.S_CODE; |
| | | wcsTask.S_END_AREA = endLoc.S_AREA_CODE; |
| | | WCSHelper.updateTaskEnd(wcsTask); |
| | | |
| | | wmsTask.S_END_LOC = endLoc.S_CODE; |
| | | wmsTask.S_END_AREA = endLoc.S_AREA_CODE; |
| | | WMSHelper.UpdateTaskEnd(wmsTask); |
| | | |
| | | readCodeFeedbackResponse.verifyResult = false; |
| | | readCodeFeedbackResponse.endLoc = endLoc.S_CODE; |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | else |
| | | { |
| | | response.code = 1; |
| | | response.msg = $"任务号:{model.taskNo},未查询到执行中的任务"; |
| | | } |
| | | response.data = readCodeFeedbackResponse; |
| | | return response; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 异常申请(取消任务) |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | public static ResponseResult anomalyRequest(NotifyDeviceSignalModel model) |
| | | { |
| | | ResponseResult response = new ResponseResult(); |
| | | readCodeFeedbackResponse readCodeFeedbackResponse = new readCodeFeedbackResponse() |
| | | { |
| | | verifyResult = true |
| | | }; |
| | | var wcsTask = WCSHelper.GetTask(model.taskNo); |
| | | var wmsTask = WMSHelper.GetWmsTask(wcsTask.S_OP_CODE); |
| | | if (wcsTask != null && wmsTask != null) |
| | | { |
| | | Location endLoc = LocationHelper.GetLoc(wmsTask.S_END_LOC); // 原终点 |
| | | if (wcsTask.S_TYPE == "满料下线入库任务") |
| | | { |
| | | // 查询排出口 |
| | | var middleLoc = WMSHelper.getMinTaskMiddleLoc(1, 0, endLoc.N_ROADWAY); |
| | | wcsTask.S_END_LOC = middleLoc.S_CODE; |
| | | wcsTask.S_END_AREA = middleLoc.S_AREA_CODE; |
| | | WCSHelper.updateTaskEnd(wcsTask); |
| | | readCodeFeedbackResponse.verifyResult = false; |
| | | readCodeFeedbackResponse.endLoc = middleLoc.S_CODE; |
| | | |
| | | // 查询新终点 |
| | | endLoc = WMSHelper.getOnlneLoc(2); |
| | | } |
| | | else if (wcsTask.S_TYPE == "胚胎叫料出库任务") |
| | | { |
| | | endLoc = WMSHelper.getCallOutLoc(endLoc.N_ROW); |
| | | readCodeFeedbackResponse.verifyResult = false; |
| | | readCodeFeedbackResponse.endLoc = endLoc.S_CODE; |
| | | } |
| | | wmsTask.S_END_LOC = endLoc.S_CODE; |
| | | wmsTask.S_END_AREA = endLoc.S_AREA_CODE; |
| | | WMSHelper.UpdateTaskEnd(wmsTask); |
| | | } |
| | | else |
| | | { |
| | | response.code = 1; |
| | | response.msg = $"任务号:{model.taskNo},未查询到执行中的任务"; |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 硫化机呼叫胚胎出库 |
| | | /// 4.硫化机呼叫胚胎出库 |
| | | /// 逻辑: |
| | | /// 1.根据机台号查询【硫化机工单表】、【胚胎已完成的条码中间表】筛选当前班次的生产计划数量是否满足,当预计生产数量 = 实际数+在途数量 ,则停止叫料 |
| | | /// 2.查询机台号在【硫化机工单表】对应的物料编码, |
| | | /// 开始计算(1.巷道不报警、2.物料状态OK、3.小于失效时间 大于等于生效时间 4.加急料先出、5.先入先出(生产时间))出库物料,生成任务 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | public static ResponseResult callItemOutStock(CallItemModel model) |
| | | public static ResponseResult callItemOutStock(NotifyDeviceSignalModel model) |
| | | { |
| | | ResponseResult response = new ResponseResult(); |
| | | |
| | | int locNum = model.locCodes.Count; |
| | | var locCodes = model.loc.Split(',').ToList(); |
| | | |
| | | int locNum = locCodes.Count; |
| | | if (locNum > 0) |
| | | { |
| | | Location prevLoc = null; |
| | | Dictionary<string,Location> outLocDic = new Dictionary<string,Location>(); |
| | | foreach (var mcn in model.locCodes) |
| | | foreach (var mcn in locCodes) |
| | | { |
| | | // 1.一个硫化机工位只能同时存在一个正在执行中的任务 |
| | | var existTask = WCSHelper.GetTaskByEnd(mcn); |
| | |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | public static ResponseResult emptyTrayInStock(EmptyTrayInStockModel model) |
| | | public static ResponseResult emptyTrayInStock(NotifyDeviceSignalModel model) |
| | | { |
| | | ResponseResult response = new ResponseResult(); |
| | | Location startLoc = LocationHelper.GetLoc(model.startLoc); |
| | | var endLocGroup = WMSHelper.getInStockEndLoc(1,null); |
| | | if (endLocGroup.endLocList.Count == 1) |
| | | { |
| | | Location endLoc = endLocGroup.endLocList[0]; |
| | | var wmsTask = new WMSTask() |
| | | { |
| | | S_CNTR_CODE = model.trayCode, |
| | | S_CODE = WMSHelper.GenerateTaskNo(), |
| | | S_START_LOC = startLoc.S_CODE, |
| | | S_START_AREA = startLoc.S_AREA_CODE, |
| | | S_END_LOC = endLoc.S_CODE, |
| | | S_END_AREA = endLoc.S_AREA_CODE, |
| | | S_TYPE = "空托入库任务", |
| | | S_OP_DEF_CODE = model.reqId, |
| | | S_OP_DEF_NAME = "空托盘回库任务", |
| | | N_PRIORITY = 1, |
| | | T_START_TIME = DateTime.Now, |
| | | }; |
| | | if (WMSHelper.CreateWmsTask(wmsTask)) |
| | | { |
| | | // 创建一段入库任务 |
| | | WCSTask wcsTask = new WCSTask() |
| | | { |
| | | S_OP_NAME = wmsTask.S_OP_DEF_NAME, |
| | | S_OP_CODE = wmsTask.S_CODE, |
| | | S_CODE = WCSHelper.GenerateTaskNo(), |
| | | S_CNTR_CODE = wmsTask.S_CNTR_CODE, |
| | | S_TYPE = wmsTask.S_TYPE, |
| | | S_START_LOC = startLoc.S_CODE, |
| | | S_START_AREA = startLoc.S_AREA_CODE, |
| | | S_END_LOC = endLoc.S_CODE, |
| | | S_END_AREA = endLoc.S_AREA_CODE, |
| | | S_SCHEDULE_TYPE = "WCS", |
| | | N_PRIORITY = 1, |
| | | T_START_TIME = DateTime.Now, |
| | | }; |
| | | Location startLoc = LocationHelper.GetLoc(model.loc); |
| | | |
| | | if (WCSHelper.CreateTask(wcsTask)) |
| | | { |
| | | // 起点、接驳点、终点加锁 |
| | | LocationHelper.LockLoc(wcsTask.S_START_LOC, 2); |
| | | LocationHelper.LockLoc(wcsTask.S_END_LOC, 1); |
| | | |
| | | // 更新作业任务状态 |
| | | wmsTask.N_B_STATE = 1; |
| | | WMSHelper.UpdateTaskState(wmsTask); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | var cntrCodeList = model.loc.Split(',').ToList(); |
| | | if (cntrCodeList.Count > 0) |
| | | { |
| | | response.code = 1; |
| | | response.msg = "库区没有可入的空货位"; |
| | | } |
| | | return response; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 呼叫空托出库 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static ResponseResult callEmptyTrayOutStock(CallEmptyTrayOutStockModel model) |
| | | { |
| | | ResponseResult responseResult = new ResponseResult(); |
| | | Location startLoc = WMSHelper.getOutStockStartLoc(null); |
| | | if (startLoc != null) |
| | | { |
| | | Location endLoc = LocationHelper.GetLoc(model.endLoc); |
| | | if (endLoc != null) |
| | | var endLocGroup = WMSHelper.getInStockEndLoc(cntrCodeList.Count, null); |
| | | if (endLocGroup.endLocList.Count > 0) |
| | | { |
| | | var locCntrRels = LocationHelper.GetLocCntr(startLoc.S_CODE); |
| | | if (locCntrRels != null && locCntrRels.Count > 0) |
| | | foreach (var endLoc in endLocGroup.endLocList) |
| | | { |
| | | var wmsTask = new WMSTask() |
| | | { |
| | | S_CNTR_CODE = locCntrRels[0].S_CNTR_CODE, |
| | | S_CNTR_CODE = model.cntrNo, |
| | | S_CODE = WMSHelper.GenerateTaskNo(), |
| | | S_START_LOC = startLoc.S_CODE, |
| | | S_START_AREA = startLoc.S_AREA_CODE, |
| | | S_END_LOC = endLoc.S_CODE, |
| | | S_END_AREA = endLoc.S_AREA_CODE, |
| | | S_TYPE = "呼叫空托出库", |
| | | S_TYPE = "空托入库任务", |
| | | S_OP_DEF_CODE = model.reqId, |
| | | S_OP_DEF_NAME = "呼叫空托出库", |
| | | S_OP_DEF_NAME = "空托盘回库任务", |
| | | N_PRIORITY = 1, |
| | | T_START_TIME = DateTime.Now |
| | | T_START_TIME = DateTime.Now, |
| | | S_GROUP_NO = endLocGroup.groupNo, |
| | | }; |
| | | if (WMSHelper.CreateWmsTask(wmsTask)) |
| | | { |
| | |
| | | } |
| | | } |
| | | } |
| | | else |
| | | else |
| | | { |
| | | responseResult.code = 1; |
| | | responseResult.msg = $"终点货位:{model.endLoc}在WMS系统中不存在"; |
| | | response.code = 1; |
| | | response.msg = "库区没有可入的空货位"; |
| | | } |
| | | } |
| | | else |
| | | |
| | | return response; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 呼叫空托出库 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static ResponseResult callEmptyTrayOutStock(NotifyDeviceSignalModel model) |
| | | { |
| | | ResponseResult responseResult = new ResponseResult(); |
| | | int executeNum = 0; |
| | | string startLocCode = null; |
| | | for (int i = 1; i <= 2; i++) |
| | | { |
| | | Location startLoc = WMSHelper.getOutStockStartLoc(startLocCode); |
| | | if (startLoc != null) |
| | | { |
| | | startLocCode = startLoc.S_CODE; |
| | | Location endLoc = WMSHelper.getMinTaskMiddleLoc(1, 0, startLoc.N_ROADWAY); |
| | | if (endLoc != null) |
| | | { |
| | | var locCntrRels = LocationHelper.GetLocCntr(startLoc.S_CODE); |
| | | if (locCntrRels != null && locCntrRels.Count > 0) |
| | | { |
| | | var wmsTask = new WMSTask() |
| | | { |
| | | S_CNTR_CODE = locCntrRels[0].S_CNTR_CODE, |
| | | S_CODE = WMSHelper.GenerateTaskNo(), |
| | | S_START_LOC = startLoc.S_CODE, |
| | | S_START_AREA = startLoc.S_AREA_CODE, |
| | | S_END_LOC = endLoc.S_CODE, |
| | | S_END_AREA = endLoc.S_AREA_CODE, |
| | | S_TYPE = "呼叫空托出库", |
| | | S_OP_DEF_CODE = model.reqId, |
| | | S_OP_DEF_NAME = "呼叫空托出库", |
| | | N_PRIORITY = 1, |
| | | T_START_TIME = DateTime.Now |
| | | }; |
| | | if (WMSHelper.CreateWmsTask(wmsTask)) |
| | | { |
| | | // 创建一段入库任务 |
| | | WCSTask wcsTask = new WCSTask() |
| | | { |
| | | S_OP_NAME = wmsTask.S_OP_DEF_NAME, |
| | | S_OP_CODE = wmsTask.S_CODE, |
| | | S_CODE = WCSHelper.GenerateTaskNo(), |
| | | S_CNTR_CODE = wmsTask.S_CNTR_CODE, |
| | | S_TYPE = wmsTask.S_TYPE, |
| | | S_START_LOC = startLoc.S_CODE, |
| | | S_START_AREA = startLoc.S_AREA_CODE, |
| | | S_END_LOC = endLoc.S_CODE, |
| | | S_END_AREA = endLoc.S_AREA_CODE, |
| | | S_SCHEDULE_TYPE = "WCS", |
| | | N_PRIORITY = 1, |
| | | T_START_TIME = DateTime.Now, |
| | | }; |
| | | |
| | | if (WCSHelper.CreateTask(wcsTask)) |
| | | { |
| | | // 起点、接驳点、终点加锁 |
| | | LocationHelper.LockLoc(wcsTask.S_START_LOC, 2); |
| | | LocationHelper.LockLoc(wcsTask.S_END_LOC, 1); |
| | | |
| | | // 更新作业任务状态 |
| | | wmsTask.N_B_STATE = 1; |
| | | WMSHelper.UpdateTaskState(wmsTask); |
| | | |
| | | executeNum += 1; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (executeNum < 1) |
| | | { |
| | | responseResult.code = 1; |
| | | responseResult.msg = "库内空托不足"; |
| | | responseResult.msg = "立库内空托盘数量不足"; |
| | | } |
| | | return responseResult; |
| | | } |
| | |
| | | /// 胚胎抽检出库 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static ResponseResult embryoCheckOutStock(EmbryoCheckOutStockModel model) |
| | | public static SimpleResult embryoCheckOutStock(EmbryoCheckOutStockModel model) |
| | | { |
| | | ResponseResult responseResult = new ResponseResult(); |
| | | SimpleResult result = new SimpleResult(); |
| | | var locCntrs = LocationHelper.GetLocCntrRelByCntr(model.trayCode); |
| | | if (locCntrs.Count == 1) |
| | | { |
| | |
| | | } |
| | | } |
| | | } |
| | | return responseResult; |
| | | return result; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | public static ResponseResult anomalyTrayInStock(AnomalyTrayInStockModel model) |
| | | public static ResponseResult anomalyTrayInStock(NotifyDeviceSignalModel model) |
| | | { |
| | | ResponseResult responseResult = new ResponseResult(); |
| | | LocationHelper.UnBindingLoc(model.startLoc, new List<string>() { model.trayCode }); |
| | | ContainerHelper.deleteCntrItemRelByCntr(model.trayCode); |
| | | LocationHelper.UnBindingLoc(model.loc, new List<string>() { model.cntrNo }); |
| | | ContainerHelper.deleteCntrItemRelByCntr(model.cntrNo); |
| | | return responseResult; |
| | | } |
| | | |
| | |
| | | |
| | | public class OffLineModel |
| | | { |
| | | public string loc { get; set; } // 下线位 |
| | | public string rfid { get; set; } // 托盘号 |
| | | public string deviceNo { get; set; } // 机台号 |
| | | public int isUrgent { get; set; } // N_IS_URGENT 是否加急(0.否 1.是) |
| | | public int isFull { get; set; } // 是否满拖 0.否 1.是 |
| | | public int needPair { get; set; } // 0.否 1.是(当前空托盘为配对托盘) |
| | | } |
| | | public class AddTaskModel { |
| | | public string From { get; set; } |
| | |
| | | using System.Web.Http; |
| | | using static HH.WCS.Mobox3.YNJT_PT.api.ApiModel; |
| | | using static HH.WCS.Mobox3.YNJT_PT.api.OtherModel; |
| | | using static HH.WCS.Mobox3.YNJT_PT.api.WmsController; |
| | | |
| | | namespace HH.WCS.Mobox3.YNJT_PT.api { |
| | | /// <summary> |
| | | /// mobox3调用,脚本中调用 |
| | | /// </summary> |
| | | public class MoboxController : System.Web.Http.ApiController { |
| | | |
| | | /// <summary> |
| | | /// 1.胎胚立库抽检出库、人工出库胎胚 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | public SimpleResult embryoCheckOutStock(EmbryoCheckOutStockModel model) |
| | | { |
| | | LogHelper.Info("【1.胎胚立库抽检出库】embryoCheckOutStock 入参:" + JsonConvert.SerializeObject(model), "WMS"); |
| | | SimpleResult result = new SimpleResult(); |
| | | result = ApiHelper.embryoCheckOutStock(model); |
| | | LogHelper.Info("【1.胎胚立库抽检出库】embryoCheckOutStock 出参:" + JsonConvert.SerializeObject(result), "WMS"); |
| | | return result; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 任务取消(目前支持ndc) |
| | | /// </summary> |
| | |
| | | { |
| | | |
| | | /// <summary> |
| | | /// 1.成型机下线记录 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | public ResponseResult cxjOffLineRecord(OffLineModel model) |
| | | { |
| | | LogHelper.Info("【1.成型机下线记录】Request:" + JsonConvert.SerializeObject(model), "WMS"); |
| | | var result = ApiHelper.cxjOffLineRecord(model); |
| | | LogHelper.Info("【1.成型机下线记录】response:" + JsonConvert.SerializeObject(result), "WMS"); |
| | | return result; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 2.设备信号反馈 |
| | | /// 1.设备信号反馈 |
| | | /// 业务场景:WCS反馈成型机胚胎下线入库信号(注:必须两托一起上报,没有两托,则补充一个空托) |
| | | /// 逻辑: |
| | | /// 1.查询成型机下线记录表,判断RFID是否存在,状态是否OK,不存在或NG异常排出 |
| | |
| | | [HttpPost] |
| | | public ResponseResult notifyDeviceSignal(NotifyDeviceSignalModel model) |
| | | { |
| | | LogHelper.Info("【2.设备信号反馈】notifyDeviceSignal 入参:" + JsonConvert.SerializeObject(model), "WMS"); |
| | | LogHelper.Info("【1.设备信号反馈】notifyDeviceSignal 入参:" + JsonConvert.SerializeObject(model), "WMS"); |
| | | ResponseResult responseResult = new ResponseResult(); |
| | | try |
| | | { |
| | | if (model.signalType == 1) |
| | | switch (model.signalType) |
| | | { |
| | | responseResult = ApiHelper.offLineRequest(model); |
| | | } |
| | | else if(model.signalType == 3) |
| | | { |
| | | responseResult = ApiHelper.readCodeRequest(model); |
| | | case 1: |
| | | responseResult = ApiHelper.offLineRequest(model); // 下线请求 |
| | | break; |
| | | case 2: |
| | | responseResult = ApiHelper.callItemOutStock(model); // 叫料请求 |
| | | break; |
| | | case 3: |
| | | responseResult = ApiHelper.readCodeRequest(model); // 读码请求 |
| | | break; |
| | | case 4: |
| | | responseResult = ApiHelper.cxjOffLineRecord(model); // 下线记录 |
| | | break ; |
| | | case 5: |
| | | responseResult = ApiHelper.anomalyRequest(model); // 异常申请 |
| | | break; |
| | | case 6: |
| | | responseResult = ApiHelper.emptyTrayInStock(model); // 空托回库 |
| | | break; |
| | | case 7: |
| | | responseResult = ApiHelper.callEmptyTrayOutStock(model); // 空托出库 |
| | | break; |
| | | case 8: |
| | | responseResult = ApiHelper.anomalyTrayInStock(model); // 空托重置 |
| | | break; |
| | | } |
| | | } |
| | | catch (BusinessException be) |
| | |
| | | responseResult.code = 500; |
| | | responseResult.msg = $"WMS内部错误,请联系开发人员处理"; |
| | | } |
| | | LogHelper.Info("【2.设备信号反馈】notifyDeviceSignal 出参:" + JsonConvert.SerializeObject(responseResult), "WMS"); |
| | | LogHelper.Info("【1.设备信号反馈】notifyDeviceSignal 出参:" + JsonConvert.SerializeObject(responseResult), "WMS"); |
| | | return responseResult; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 2.WCS 任务状态反馈 |
| | | /// 业务场景:WCS在执行任务时,回报任务状态 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | /*[Route("notifyTaskStatus")]*/ |
| | | public ReturnResult notifyTaskStatus(TaskStatusFeedbackModel model) |
| | | { |
| | | LogHelper.Info("【2.WCS任务状态反馈】Request:" + JsonConvert.SerializeObject(model), "WMS"); |
| | | var result = ApiHelper.taskStatusFeedback(model); |
| | | LogHelper.Info("【2.WCS任务状态反馈】response:" + JsonConvert.SerializeObject(result), "WMS"); |
| | | return result; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 4.硫化机呼叫胚胎出库 |
| | | /// 逻辑: |
| | | /// 1.根据机台号查询【硫化机工单表】、【胚胎已完成的条码中间表】筛选当前班次的生产计划数量是否满足,当预计生产数量 = 实际数+在途数量 ,则停止叫料 |
| | | /// 2.查询机台号在【硫化机工单表】对应的物料编码, |
| | | /// 开始计算(1.巷道不报警、2.物料状态OK、3.小于失效时间 大于等于生效时间 4.加急料先出、5.先入先出(生产时间))出库物料,生成任务 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | public ResponseResult callItemOutStock(CallItemModel model ) |
| | | { |
| | | LogHelper.Info("【4.硫化机呼叫胚胎出库】callItemOutStock 入参:" + JsonConvert.SerializeObject(model), "WMS"); |
| | | ResponseResult responseResult = new ResponseResult(); |
| | | responseResult = ApiHelper.callItemOutStock(model); |
| | | LogHelper.Info("【4.硫化机呼叫胚胎出库】callItemOutStock 出参:" + JsonConvert.SerializeObject(responseResult), "WMS"); |
| | | return responseResult; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 5.空托回立库 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | public ResponseResult emptyTrayInStock(EmptyTrayInStockModel model ) |
| | | { |
| | | LogHelper.Info("【5.空托回立库】emptyTrayInStock 入参:" + JsonConvert.SerializeObject(model), "WMS"); |
| | | ResponseResult responseResult = new ResponseResult(); |
| | | responseResult = ApiHelper.emptyTrayInStock(model); |
| | | LogHelper.Info("【5.空托回立库】emptyTrayInStock 出参:" + JsonConvert.SerializeObject(responseResult), "WMS"); |
| | | return responseResult; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 6.成型机呼叫空托 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | public ResponseResult callEmptyTrayOutStock(CallEmptyTrayOutStockModel model) |
| | | { |
| | | LogHelper.Info("【6.成型机呼叫空托】callEmptyTrayOutStock 入参:" + JsonConvert.SerializeObject(model), "WMS"); |
| | | ResponseResult responseResult = new ResponseResult(); |
| | | responseResult = ApiHelper.callEmptyTrayOutStock(model); |
| | | LogHelper.Info("【6.成型机呼叫空托】callEmptyTrayOutStock 出参:" + JsonConvert.SerializeObject(responseResult), "WMS"); |
| | | return responseResult; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 7.胎胚立库抽检出库、人工出库胎胚 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | public ResponseResult embryoCheckOutStock(EmbryoCheckOutStockModel model) |
| | | { |
| | | LogHelper.Info("【7.胎胚立库抽检出库】embryoCheckOutStock 入参:" + JsonConvert.SerializeObject(model), "WMS"); |
| | | ResponseResult responseResult = new ResponseResult(); |
| | | responseResult = ApiHelper.embryoCheckOutStock(model); |
| | | LogHelper.Info("【 7.胎胚立库抽检出库】embryoCheckOutStock 出参:" + JsonConvert.SerializeObject(responseResult), "WMS"); |
| | | return responseResult; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 8.异常回库流程 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | public ResponseResult anomalyTrayInStock(AnomalyTrayInStockModel model) |
| | | { |
| | | LogHelper.Info("【8.异常回库流程】embryoCheckOutStock 入参:" + JsonConvert.SerializeObject(model), "WMS"); |
| | | ResponseResult responseResult = new ResponseResult(); |
| | | responseResult = ApiHelper.anomalyTrayInStock(model); |
| | | LogHelper.Info("【8.异常回库流程】embryoCheckOutStock 出参:" + JsonConvert.SerializeObject(responseResult), "WMS"); |
| | | return responseResult; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 9.WCS 任务状态反馈 |
| | | /// 业务场景:WCS在执行任务时,回报任务状态 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | /*[Route("notifyTaskStatus")]*/ |
| | | public ReturnResult notifyTaskStatus(TaskStatusFeedbackModel model) |
| | | { |
| | | LogHelper.Info("【9.WCS任务状态反馈】Request:" + JsonConvert.SerializeObject(model), "WMS"); |
| | | var result = ApiHelper.taskStatusFeedback(model); |
| | | LogHelper.Info("【9.WCS任务状态反馈】response:" + JsonConvert.SerializeObject(result), "WMS"); |
| | | return result; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 10.空托盘解绑 |
| | | /// 4.空托盘解绑 |
| | | /// 业务场景:空托盘回主线 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | |
| | | [HttpPost] |
| | | public ReturnResult emptyTrayUnBind(EmptyTrayUnBindModel model) |
| | | { |
| | | LogHelper.Info("【10.空托盘解绑】Request:" + JsonConvert.SerializeObject(model), "WMS"); |
| | | LogHelper.Info("【4.空托盘解绑】Request:" + JsonConvert.SerializeObject(model), "WMS"); |
| | | var result = ApiHelper.emptyTrayUnBind(model); |
| | | LogHelper.Info("【10.空托盘解绑】response:" + JsonConvert.SerializeObject(result), "WMS"); |
| | | LogHelper.Info("【4.空托盘解绑】response:" + JsonConvert.SerializeObject(result), "WMS"); |
| | | return result; |
| | | } |
| | | |
| | |
| | | public string taskNo { get; set; } |
| | | public string cntrNo { get; set; } |
| | | public int signalType { get; set; } |
| | | public List<BarcodeModel> extData { get; set; } |
| | | public object extData { get; set; } |
| | | public string deviceNo { get; set; } |
| | | } |
| | | |
| | |
| | | "locCode": "OA1-2-4-1", |
| | | "roadway": 4 |
| | | } |
| | | ], |
| | | |
| | | "DeviceConfig": [ |
| | | { |
| | | "deviceNo": "", |
| | | "deviceName": "", |
| | | "roadway": 1 |
| | | } |
| | | ] |
| | | } |
| | |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using HH.WCS.Mobox3.YNJT_PT.util; |
| | | using HH.WCS.Mobox3.YNJT_PT.wms; |
| | | using Newtonsoft.Json; |
| | | using static HH.WCS.Mobox3.YNJT_PT.api.ApiModel; |
| | | |
| | | namespace HH.WCS.Mobox3.YNJT_PT.dispatch |
| | | { |
| | |
| | | private static readonly HttpHelper apiHelper = new HttpHelper(); |
| | | private static readonly string baseUrl = "http://192.168.1.99:2000/"; |
| | | |
| | | |
| | | internal static string GenerateReqId() |
| | | { |
| | | var id = SYSHelper.GetSerialNumber("请求ID", "RE"); |
| | | var date = DateTime.Now.ToString("yyMMdd"); |
| | | return $"{date}{id.ToString().PadLeft(4, '0')}"; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// WMS向WCS获取设备状态(堆垛机) |
| | | /// 任务下发 |
| | | /// </summary> |
| | | /// <param name="roadway"></param> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | public static List<StackerState> getStackerState(int roadway) |
| | | public static bool sendTask(SendTaskModel model) |
| | | { |
| | | var msg = ""; |
| | | List<StackerState> stackerStates = new List<StackerState>(); |
| | | var data = new StackerStateModel() { req_no = Guid.NewGuid().ToString("D"), roadway = roadway.ToString() }; |
| | | var request = JsonConvert.SerializeObject(data); |
| | | var response = apiHelper.Post(baseUrl + "api/StackerState", request); |
| | | msg = $"WMS向WCS获取设备状态(堆垛机)[StackerState] request={request} response={response}"; |
| | | LogHelper.Info(msg, "WCS"); |
| | | if (response != "") |
| | | var result = false; |
| | | model.reqId = GenerateReqId(); |
| | | model.reqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); |
| | | var request = JsonConvert.SerializeObject(model); |
| | | try |
| | | { |
| | | try |
| | | var response = apiHelper.Post(baseUrl + "/sendTask", request); |
| | | LogHelper.Info($"[WCS-sendTask] request={request} response={response}", "WMS"); |
| | | if (response != null && response != "") |
| | | { |
| | | var dataResult = JsonConvert.DeserializeObject<StackerStateResponseData>(response); |
| | | if (dataResult.result_flag == 0) |
| | | var dataResult = JsonConvert.DeserializeObject<ResponseResult>(response); |
| | | if (dataResult.code == 200) |
| | | { |
| | | stackerStates = dataResult.data; |
| | | result = true; |
| | | } |
| | | else |
| | | else |
| | | { |
| | | LogHelper.Info($"WMS向WCS获取设备状态(堆垛机)失败,WCS反馈错误信息:{dataResult.err_msg}", "WCS"); |
| | | LogHelper.Info($"调用WCS任务下发接口成功,但WCS反馈下发任务失败,失败原因:{dataResult.msg}", "WMS"); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | else |
| | | { |
| | | LogHelper.Info($"WMS向WCS获取设备状态(堆垛机)错误,错误原因:{ex.Message}", "WCS"); |
| | | LogHelper.Info("调用WCS任务下发接口失败", "WMS"); |
| | | } |
| | | } |
| | | else |
| | | catch (Exception ex) |
| | | { |
| | | msg = "[StackerState]WMS向WCS获取设备状态(堆垛机)失败"; |
| | | LogHelper.Info(msg, "WCS"); |
| | | LogHelper.Info($"调用WCS任务下发接口错误,错误原因:{ex.Message}", "WMS"); |
| | | } |
| | | return stackerStates; |
| | | return result; |
| | | } |
| | | |
| | | public class StackerStateResponseData |
| | | /// <summary> |
| | | /// 任务取消(任务执行中不允许取消) |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | public static bool cancelTask(CancelTaskModel model) |
| | | { |
| | | public int result_flag { get; set; } |
| | | public string err_msg { get; set; } |
| | | public List<StackerState> data { get; set; } |
| | | } |
| | | public class StackerState |
| | | { |
| | | public string roadway { get; set; } |
| | | public string roadway_state { get; set; } // 堆垛机状态 1=空闲,2=执行中,3=报警,0=不可用 |
| | | var result = false; |
| | | model.reqId = GenerateReqId(); |
| | | model.reqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); |
| | | var request = JsonConvert.SerializeObject(model); |
| | | try |
| | | { |
| | | var response = apiHelper.Post(baseUrl + "/api/hecWms/produceProcessTracing/trayMaterialUnBind", request); |
| | | LogHelper.Info($"[WCS-cancelTask] request={request} response={response}", "WMS"); |
| | | if (response != null && response != "") |
| | | { |
| | | |
| | | var dataResult = JsonConvert.DeserializeObject<ResponseResult>(response); |
| | | if (dataResult.code == 200) |
| | | { |
| | | result = true; |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | LogHelper.Info("调用WCS任务取消接口失败", "WMS"); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogHelper.Info($"调用WCS任务取消接口错误,错误原因:{ex.Message}", "WMS"); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | public class StackerStateModel |
| | | /// <summary> |
| | | /// 获取设备状态 |
| | | /// </summary> |
| | | /// <param name="deviceNoList"></param> |
| | | /// <returns></returns> |
| | | public static List<DeviceStatusData> getDeviceStatus(List<string> deviceNoList) |
| | | { |
| | | public string req_no { get; set; } |
| | | public string roadway { get; set; } |
| | | List<DeviceStatusData> deviceStatusDatas = new List<DeviceStatusData>(); |
| | | |
| | | DeviceStatusModel model = new DeviceStatusModel() |
| | | { |
| | | reqId = GenerateReqId(), |
| | | reqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), |
| | | deviceNoList = deviceNoList |
| | | }; |
| | | |
| | | var request = JsonConvert.SerializeObject(model); |
| | | try |
| | | { |
| | | var response = apiHelper.Post(baseUrl + "/api/hecWms/produceProcessTracing/trayMaterialUnBind", request); |
| | | LogHelper.Info($"[WCS-getDeviceStatus] request={request} response={response}", "WMS"); |
| | | if (response != null && response != "") |
| | | { |
| | | |
| | | var dataResult = JsonConvert.DeserializeObject<ResponseResult>(response); |
| | | if (dataResult.code == 200) |
| | | { |
| | | deviceStatusDatas = JsonConvert.DeserializeObject<List<DeviceStatusData>>(response); |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | LogHelper.Info("调用WCS获取设备状态接口失败", "WMS"); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogHelper.Info($"调用WCS获取设备状态接口错误,错误原因:{ex.Message}", "WMS"); |
| | | } |
| | | return deviceStatusDatas; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 修改任务优先级 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | public static bool changePriority(ChangePriorityModel model) |
| | | { |
| | | var result = false; |
| | | model.reqId = GenerateReqId(); |
| | | model.reqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); |
| | | var request = JsonConvert.SerializeObject(model); |
| | | try |
| | | { |
| | | var response = apiHelper.Post(baseUrl + "/api/hecWms/produceProcessTracing/trayMaterialUnBind", request); |
| | | LogHelper.Info($"[WCS-changePriority] request={request} response={response}", "WMS"); |
| | | if (response != null && response != "") |
| | | { |
| | | |
| | | var dataResult = JsonConvert.DeserializeObject<ResponseResult>(response); |
| | | if (dataResult.code == 200) |
| | | { |
| | | result = true; |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | LogHelper.Info("调用WCS修改任务优先级接口失败", "WMS"); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogHelper.Info($"调用WCS修改任务优先级接口错误,错误原因:{ex.Message}", "WMS"); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// AGV安全交互 |
| | | /// </summary> |
| | | /// <param name="req_no"></param> |
| | | /// <param name="locCode"></param> |
| | | /// <param name="type"></param> |
| | | /// <returns></returns> |
| | | public static bool safetyInteraction(string req_no, string locCode, string type) |
| | | { |
| | | var result = false; |
| | | LocStateModel model = new LocStateModel() |
| | | { |
| | | req_no = req_no, |
| | | loc_code = locCode, |
| | | type = type |
| | | }; |
| | | |
| | | var request = JsonConvert.SerializeObject(model); |
| | | try |
| | | { |
| | | var response = apiHelper.Post(baseUrl + "/api/hecWms/produceProcessTracing/trayMaterialUnBind", request); |
| | | LogHelper.Info($"[WCS-changePriority] request={request} response={response}", "WMS"); |
| | | if (response != null && response != "") |
| | | { |
| | | |
| | | var dataResult = JsonConvert.DeserializeObject<ResponseResult>(response); |
| | | if (dataResult.code == 200) |
| | | { |
| | | result = true; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | LogHelper.Info("调用WCS安全请求接口失败", "AGV"); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogHelper.Info($"调用WCS安全请求接口错误,错误原因:{ex.Message}", "AGV"); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | |
| | | public class LocStateModel |
| | | { |
| | | public string req_no { get; set; } // 请求id |
| | | public string loc_code { get; set; } // 货位 |
| | | public string type { get; set; } // 货位 1 请求取货 2 请求放货 3 取货完成离开信号 4 放货完成离开信号 |
| | | } |
| | | |
| | | public class ChangePriorityModel |
| | | { |
| | | public string reqId { get; set; } // 请求id |
| | | public string reqTime { get; set; } // 请求时间 |
| | | public string taskNo { get; set; } // 任务号 |
| | | public int priority { get; set; } // 优先级 |
| | | } |
| | | |
| | | public class DeviceStatusData |
| | | { |
| | | public string deviceNo { get; set; } // 设备号 |
| | | public int workStatus { get; set; } // 工作状态 1正常 ,2禁用 ,3故障 |
| | | public int photoStatus { get; set; } // 光电状态 1是空载 ,2是有载 |
| | | public int manualStatus { get; set; } //手动状态 1手动,2自动 |
| | | } |
| | | |
| | | public class DeviceStatusModel |
| | | { |
| | | public string reqId { get; set; } // 请求id |
| | | public string reqTime { get; set; } // 请求时间 |
| | | public List<string> deviceNoList { get; set; } // 设备号 |
| | | } |
| | | |
| | | public class CancelTaskModel |
| | | { |
| | | public string reqId { get; set; } // 请求id |
| | | public string reqTime { get; set; } // 请求时间 |
| | | public string taskNo { get; set; } // 任务号 |
| | | } |
| | | |
| | | public class SendTaskModel |
| | | { |
| | | public string reqId { get; set; } // 请求id |
| | | public string reqTime { get; set; } // 请求时间 |
| | | public string taskNo { get; set; } // 任务号 |
| | | public int groupNo { get; set; } // 任务组 |
| | | public string taskType { get; set; } // 任务类型 1.物料入库 2.物料出库 |
| | | public string from { get; set; } // 起点 |
| | | public string to { get; set; } // 终点 |
| | | public string cntrNo { get; set; } // 容器编码 |
| | | public string cntrType { get; set; } // 容器类型 |
| | | public List<object> extData { get; set; } // |
| | | |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | namespace HH.WCS.Mobox3.YNJT_PT.models |
| | | { |
| | | /// <summary> |
| | | /// 硫化完成记录 |
| | | /// </summary> |
| | | [SugarTable("TN_EmbryoFinishRecord")] |
| | | public class EmbryoFinishRecord : BaseModel |
| | | { |
| | |
| | | public int N_IS_URGENT { get; set; } // N_IS_URGENT 是否加急(0.否 1.是) |
| | | public string T_OFF_TIME { get; set; } // 下线时间 |
| | | public int N_IS_FULL { get; set; } // 是否满拖 0.否 1.是 |
| | | public int N_NEED_PAIR { get; set; } // 是否需要配对 0.否 1.是(当前空托盘为配对托盘) |
| | | |
| | | } |
| | | } |
| | |
| | | using System.Linq; |
| | | using System.Reflection; |
| | | using System.Security.Cryptography; |
| | | using static HH.WCS.Mobox3.YNJT_PT.dispatch.WCSDispatch; |
| | | |
| | | namespace HH.WCS.Mobox3.YNJT_PT.process { |
| | | internal class TaskProcess { |
| | |
| | | var startLoc = LocationHelper.GetLocation(mst.S_START_LOC); |
| | | var endLoc = LocationHelper.GetLocation(mst.S_END_LOC); |
| | | |
| | | if (mst.S_SCHEDULE_TYPE == "NDC") { |
| | | |
| | | } |
| | | else if (mst.S_SCHEDULE_TYPE == "杭奥") { |
| | | //调第三方接口 |
| | | var model = new HanAo.TaskInfoModel |
| | | if (mst.S_SCHEDULE_TYPE == "AGV") |
| | | { |
| | | AddOrderNewModel model = new AddOrderNewModel() |
| | | { |
| | | requestPk = mst.S_CODE, |
| | | frmPos = mst.S_START_LOC, |
| | | toPos = mst.S_END_LOC, |
| | | trkType = mst.S_OP_NAME == "入库" ? "1" : "2", |
| | | contNo = mst.S_CNTR_CODE |
| | | ts_no = 1, |
| | | pri = 1, |
| | | task_no = mst.S_CODE |
| | | }; |
| | | if (HanAo.CreateOrder(model)) { |
| | | List<Param> paramList = new List<Param>(); |
| | | var dic = new Dictionary<string, string>(); |
| | | dic.Add("IKey", mst.S_CODE); |
| | | dic.Add("From", startLoc.S_CODE); |
| | | dic.Add("To", endLoc.S_CODE); |
| | | dic.Add("FUNC", "0"); |
| | | if (mst.S_TYPE.Contains("入库")) |
| | | { |
| | | dic.Add("DATA", "300"); |
| | | } |
| | | else |
| | | { |
| | | dic.Add("DATA", "0"); |
| | | } |
| | | dic.Add("Ctype", "0"); |
| | | foreach (var item in dic) |
| | | { |
| | | Param param = new Param |
| | | { |
| | | name = item.Key, |
| | | value = item.Value, |
| | | }; |
| | | paramList.Add(param); |
| | | } |
| | | model.param = paramList; |
| | | LogHelper.Info($"向AGV下发任务,任务参数:{model}", "WMS"); |
| | | var res = NDCApi.AddOrderNew(model); |
| | | if (res != null && res.err_code == 0 || true) |
| | | { |
| | | //推送成功,修改任务优先级 |
| | | mst.N_B_STATE = 1; |
| | | WCSHelper.UpdateStatus(mst); |
| | | result = true; |
| | | } |
| | | } |
| | | else if (mst.S_SCHEDULE_TYPE == "WCS") |
| | | { |
| | | SendTaskModel sendTask = new SendTaskModel() |
| | | { |
| | | taskNo = mst.S_CODE, |
| | | taskType = mst.S_TYPE.Contains("入库") ? "1" : "2", |
| | | from = mst.S_START_LOC, |
| | | to = mst.S_END_LOC, |
| | | cntrNo = mst.S_CNTR_CODE, |
| | | }; |
| | | LogHelper.Info($"向WCS下发任务,任务参数:{sendTask}", "WMS"); |
| | | var bo = WCSDispatch.sendTask(sendTask); |
| | | if (true || bo) |
| | | { |
| | | //推送成功,修改任务优先级 |
| | | mst.N_B_STATE = 1; |
| | | WCSHelper.UpdateStatus(mst); |
| | | result = true; |
| | | } |
| | | } |
| | | } |
| | |
| | | public static List<ConnectLoc> connectLocList { get; set; } |
| | | public static List<OnLineLoc> onLineLocList { get; set; } |
| | | public static List<CallOutLoc> callOutLocList { get; set; } |
| | | public static List<DeviceConfig> deviceConfigList { get; set; } |
| | | public static int port { get; set; } |
| | | public static string WHCode { get; set; } |
| | | public static string FacCode { get; set; } |
| | |
| | | { |
| | | callOutLocList = JsonConvert.DeserializeObject<List<CallOutLoc>>(keyValue.Value.ToString()); |
| | | } |
| | | if (keyValue.Name == "DeviceConfig") |
| | | { |
| | | deviceConfigList = JsonConvert.DeserializeObject<List<DeviceConfig>>(keyValue.Value.ToString()); |
| | | } |
| | | if (keyValue.Name == "StockArea") |
| | | { |
| | | stockArea = keyValue.Value.ToString(); |
| | |
| | | |
| | | } |
| | | |
| | | public class DeviceConfig |
| | | { |
| | | public string deviceNo { get; set; } |
| | | public string deviceName { get; set; } |
| | | public int roadway { get; set; } |
| | | } |
| | | |
| | | public class ConnectLoc |
| | | { |
| | |
| | | if (task != null) |
| | | { |
| | | task.N_B_STATE = 4; |
| | | if (WCSHelper.CheckActionRecordExist(task.S_CODE, 4)) |
| | | WCSHelper.UpdateStatus(task, "取消"); |
| | | |
| | | var mst = WMSHelper.GetWmsTask(task.S_OP_CODE); |
| | | if (mst != null) |
| | | { |
| | | WCSHelper.UpdateStatus(task, "强制完成"); |
| | | } |
| | | else { |
| | | WCSHelper.UpdateStatus(task, "取消"); |
| | | LocationHelper.UnLockLoc(mst.S_END_LOC); |
| | | |
| | | mst.N_B_STATE = 3; |
| | | mst.S_B_STATE = "取消"; |
| | | WMSHelper.UpdateTaskState(mst); |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | query = query.Where((a, b, c) => c.S_ITEM_CODE == itemCode); |
| | | } |
| | | query = query.OrderByDescending((a, b, c) => a.N_ROADWAY == prevLoc.N_ROADWAY); |
| | | var outLocList = query.ToList(); |
| | | |
| | | if (outLocList.Count > 0) |
| | |
| | | foreach (var loc in outLocList) |
| | | { |
| | | // 查询巷道是否正常,异常跳过 |
| | | var stackerStates = WCSDispatch.getStackerState(loc.N_ROADWAY); |
| | | if ( false /*stackerStates.Count == 0 || stackerStates[0].roadway_state == "0" || stackerStates[0].roadway_state == "3"*/) |
| | | var deviceConfig = Settings.deviceConfigList.Where(a => a.roadway == loc.N_ROADWAY).First(); |
| | | if (deviceConfig != null) |
| | | { |
| | | continue; |
| | | var stackerStates = WCSDispatch.getDeviceStatus(new List<string>() { deviceConfig.deviceNo } ); |
| | | if ( stackerStates.Count == 0 || stackerStates[0].workStatus != 1 || stackerStates[0].manualStatus == 1 ) |
| | | { |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | startLoc = loc; |
| | | break; |
| | | } |
| | |
| | | |
| | | namespace HH.WCS.Mobox3.ZS7412.dispatch { |
| | | /// <summary> |
| | | /// 国自调度辅助类 |
| | | /// 杭奥 |
| | | /// </summary> |
| | | public class HanAo { |
| | | private static readonly HttpHelper apiHelper = new HttpHelper(); |