Esempio n. 1
0
        /// <summary>
        /// 自动入库
        /// </summary>
        /// <returns></returns>
        public string RFID_In()
        {
            logger.Info("RFID_In:入库处RFID读取");
            var data = My.RFIDs[EnumPSite.S7_Up].Read();

            if (data == null)
            {
                logger.Warn("RFID_In:RFID信息读取失败");
                return(SvResult.RFIDReadFail);
            }
            try
            {
                #region 修改订单明细,增加完成数量
                var pc = My.BLL.TWorkpieceProcess.GetModel(Tool.CreateDict("ID", data.Guid.ToString()));
                pc.State = "完成"; //EnumHelper.GetName(TWorkpieceProcess.EnumState.完成);
                My.BLL.TWorkpieceProcess.Update(pc, My.AdminID);
                if (data.IsRough)
                {
                    throw new Exception("当前入库的工件是毛坯" + Enum.GetName(typeof(EnumWorkpiece), data.Workpiece));
                }
                var order = GetExecOrder();
                if (order == null)
                {
                    logger.Warn("RFID_In:未查询到相关订单");
                    return(SvResult.OrderNullError);
                }
                foreach (var detail in My.BLL.TOrderDetail.GetList(Tool.CreateDict("OrderID", order.ID)))
                {
                    if (My.WorkpieceIDs[data.Workpiece] == detail.WorkpieceID &&
                        detail.QuantityCompletion < detail.QuantityDemanded)
                    {
                        detail.EndTime = DateTime.Now;
                        detail.QuantityCompletion++;
                        My.BLL.TOrderDetail.Update(detail, My.AdminID);
                        break;
                    }
                }
                #endregion
                #region 检查订单是否已完成
                var allFinish = true;
                foreach (var detail in My.BLL.TOrderDetail.GetList(Tool.CreateDict("OrderID", order.ID)))
                {
                    if (detail.QuantityCompletion < detail.QuantityDemanded)
                    {
                        allFinish = false;
                        break;
                    }
                }
                if (allFinish)
                {
                    order.State   = "完成"; //EnumHelper.GetName(TOrder.EnumState.完成);
                    order.EndTime = DateTime.Now;
                    My.BLL.TOrder.Update(order, My.AdminID);
                }
                #endregion
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
            }
            Task.Run(() =>
            {
                var wmsData = new WMSData();
                if (data.Workpiece == EnumWorkpiece.E)
                {
                    wmsData.code     = "E";
                    wmsData.quantity = data.Assemble == EnumAssemble.Successed ? 1 : 0;
                }
                else
                {
                    //毛坯的name为A,半成品的name为A1
                    wmsData.code = Enum.GetName(typeof(EnumWorkpiece), data.Workpiece);
                    if (data.Assemble == EnumAssemble.Unwanted)
                    {
                        wmsData.code    += (data.IsRough ? "" : "1");
                        wmsData.quantity = 1;
                    }
                    else
                    {
                        wmsData.quantity = 0;
                    }
                    wmsData.trayId = data.Guid.ToString();
                    logger.Info("请求入库:" + wmsData.ToString());
                }
                My.Work_WMS.In(wmsData);
            });
            My.Work_Simulation.Send(new RKX(data, RKX.EnumActionType.入库检测位转移物料至入库位));
            logger.Info("RFID_In:入库处RFID读取完成");
            return(SvResult.OK);
        }
Esempio n. 2
0
 /// <summary>
 /// 入库
 /// </summary>
 /// <param name="json"></param>
 /// <returns></returns>
 public WMSResult In(WMSData data)
 {
     return(WMSPost(WMSUpUri, JsonConvert.SerializeObject(data), 10 * 60));
 }