using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Reflection; using System.Data; using SiaSun.LMS.Model; namespace SiaSun.LMS.Implement { public class ManageOut:ManageBase { /// /// 生成无计划出库任务 /// 调用界面 ManageOut.XAML /// /// /// /// /// public bool ManageCreate(SiaSun.LMS.Model.MANAGE_MAIN mMANAGE_MAIN, List lsMANAGE_LIST, out string sResult) { bool bResult = true; string ssResult = string.Empty; SiaSun.LMS.Common.Log log = new Common.Log(); sResult = string.Empty; string requestJson = string.Empty; try { this._P_Base_House.BeginTransaction(true); #region 校验是否为暂存区库存 Model.WH_CELL mSTART_WH_CELL = this._P_WH_CELL.GetModel(mMANAGE_MAIN.START_CELL_ID); if (mSTART_WH_CELL == null) { bResult = false; sResult = string.Format("起始货位索引[{0}]不存在", mMANAGE_MAIN.START_CELL_ID); return bResult; } Model.WH_AREA mSTART_WH_AREA = this._P_WH_AREA.GetModel(mSTART_WH_CELL.AREA_ID); if (mSTART_WH_AREA == null) { bResult = false; sResult = string.Format("起始货位库区索引[{0}]不存在", mSTART_WH_CELL.AREA_ID); return bResult; } if (!mSTART_WH_AREA.AREA_TYPE.Equals(Enum.AREA_TYPE.XuNiKu.ToString())) { bResult = false; sResult = string.Format("起始货位库区类型[{0}]不合法", mSTART_WH_AREA.AREA_TYPE); return bResult; } DataTable dt = this.GetList(string.Format("select goods_property1 from v_storage_list where goods_id={0} order by goods_property1", lsMANAGE_LIST[0].GOODS_ID)); //if (Convert.ToInt32( dt.Rows[0]["goods_property1"].ToString())< Convert.ToUInt32(lsMANAGE_LIST[0].GOODS_PROPERTY1)) //{ // bResult = false; // sResult = string.Format("该种类物料有批次更早的物料,请将批次[{0}]优先出库", dt.Rows[0]["goods_property1"].ToString()); // return bResult; //} // Model.STORAGE_LIST slst = this._P_STORAGE_LIST.GetModel(lsMANAGE_LIST[0].STORAGE_LIST_ID); //if (slst. == null) //{ // bResult = false; // sResult = string.Format("起始货位索引[{0}]不存在", mMANAGE_MAIN.START_CELL_ID); // return bResult; //} #endregion bResult = base.ManageCreate(mMANAGE_MAIN, lsMANAGE_LIST, false, false, out sResult); if (!bResult) { return bResult; } bResult = this.ManageComplete(mMANAGE_MAIN.MANAGE_ID, false, out sResult); // bResult = true; if (!bResult) { return bResult; } //else //{ // //新增接口生成库存后,插入新表数据,传明细和新表ID,出库再回传ID和明细 // S_ERPService erp = new S_ERPService(); // MES_INTERFACE mMES_INTERFACE = new MES_INTERFACE(); // //流水号 // mMES_INTERFACE.STOCK_BARCODE = mMANAGE_MAIN.STOCK_BARCODE; // mMES_INTERFACE.INOUT = "1"; // //批次号 // mMES_INTERFACE.BATCH = lsMANAGE_LIST[0].GOODS_PROPERTY1; // // //型号不传 // mMES_INTERFACE.SPECIFICATION = ""; // mMES_INTERFACE.GOODS_CODE = "1"; // mMES_INTERFACE.GOODS_NAME = "1"; // //供应商 // mMES_INTERFACE.SUPPLY = lsMANAGE_LIST[0].GOODS_PROPERTY3; // //零件号 // mMES_INTERFACE.PART_NO = lsMANAGE_LIST[0].GOODS_PROPERTY4; // mMES_INTERFACE.UNIT = "1"; // mMES_INTERFACE.QUANTITY = lsMANAGE_LIST[0].MANAGE_LIST_QUANTITY; // mMES_INTERFACE.UPDATE_TIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); // mMES_INTERFACE.OUT_TIME = ""; // mMES_INTERFACE.PRODUCT_TIME = ""; // requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(mMES_INTERFACE); // mMES_INTERFACE.WMS_INFO = requestJson; // mMES_INTERFACE.MES_INFO = ""; // //// 插入新表 调用接口 // //this._P_MES_INTERFACE.Add(mMES_INTERFACE); // ////判断数据是否重复 // //Model.MES_INTERFACE tmes = this._P_MES_INTERFACE.GetModelStockbarcode(mMANAGE_MAIN.STOCK_BARCODE); // //if (tmes != null) // //{ // // sResult = "入库上报时发现已经有该流水号接口数据,先处理数据再进行入库"; // // return false; // //} // //调用MES接口 // //向MES上报入库完成 // bResult = erp.HttpPost(requestJson, out sResult); // sResult = "调用接口:" + sResult; // #region // ////接口调用失败重发 // //if (!bResult) // //{ // // sResult = "ERRORMSG:虚拟出库接口调用失败,联系MES维护人员查看二维条码是否有问题:MES消息:" + sResult; // // log.SaveLog(sResult); // // Model.MES_INTERFACE_RETRY mMES_INTERFACE_RETRY = new Model.MES_INTERFACE_RETRY(); // // mMES_INTERFACE_RETRY.BIZ_TYPE = "ManageOut"; // // mMES_INTERFACE_RETRY.WHO = "MESRetry"; // // mMES_INTERFACE_RETRY.MESSAGE = requestJson; // // // mMES_INTERFACE_RETRY. = Common.StringUtil.GetDateTime(); // // this._P_MES_INTERFACE_RETRY.Add(mMES_INTERFACE_RETRY); // //} // #endregion // #region 日志 // //Model.MES_INTERFACE_LOG mMES_INTERFACE_LOG = new Model.MES_INTERFACE_LOG(); // //mMES_INTERFACE_LOG.INTERFACE = "ManageOut"; // //mMES_INTERFACE_LOG.IN_MESSAGE = requestJson; // //mMES_INTERFACE_LOG.OUT_MESSAGE = sResult; // //mMES_INTERFACE_LOG.SENDER = "WMS"; // //mMES_INTERFACE_LOG.RECEIVER = "MES"; // //mMES_INTERFACE_LOG.TIME_STAMP = Common.StringUtil.GetDateTime(); // //this._P_MES_INTERFACE_LOG.Add(mMES_INTERFACE_LOG); // #endregion //} } catch (Exception ex) { bResult = false; sResult = ex.Message; this._log.Fatal(string.Format("调用方法{0}发生异常。", MethodBase.GetCurrentMethod().Name), ex); } finally { if (bResult) { this._P_Base_House.CommitTransaction(true); } else { this._P_Base_House.RollBackTransaction(true); ////接口调用失败重发 //if (sResult.Contains("调用接口")) //{ // sResult = "ERRORMSG:虚拟出库接口调用失败,联系MES维护人员查看二维条码是否有问题:MES消息:" + sResult; // log.SaveLog(sResult); // Model.MES_INTERFACE_RETRY mMES_INTERFACE_RETRY = new Model.MES_INTERFACE_RETRY(); // mMES_INTERFACE_RETRY.BIZ_TYPE = "ManageOut"; // mMES_INTERFACE_RETRY.WHO = "MESRetry"; // mMES_INTERFACE_RETRY.MESSAGE = requestJson; // // mMES_INTERFACE_RETRY. = Common.StringUtil.GetDateTime(); // this._P_MES_INTERFACE_RETRY.Add(mMES_INTERFACE_RETRY); // #region 日志 // Model.MES_INTERFACE_LOG mMES_INTERFACE_LOG = new Model.MES_INTERFACE_LOG(); // mMES_INTERFACE_LOG.INTERFACE = "ManageOut"; // mMES_INTERFACE_LOG.IN_MESSAGE = requestJson; // mMES_INTERFACE_LOG.OUT_MESSAGE = sResult; // mMES_INTERFACE_LOG.SENDER = "WMS"; // mMES_INTERFACE_LOG.RECEIVER = "MES"; // mMES_INTERFACE_LOG.TIME_STAMP = Common.StringUtil.GetDateTime(); // this._P_MES_INTERFACE_LOG.Add(mMES_INTERFACE_LOG); // #endregion //} } } return bResult; } /// /// 生成按计划【出库】任务 /// 调用界面 ManagePlanDown_Out.XAML /// /// /// /// /// /// /// /// /// public bool ManageCreate(SiaSun.LMS.Model.MANAGE_MAIN mMANAGE_MAIN, List lsPLAN_LIST, List lsMANAGE_LIST, bool bTrans, bool bAutoSendControl, out string sResult) { bool bResult = true; sResult = string.Empty; try { this._P_Base_House.BeginTransaction(true); #region 校验 #region 校验是否为暂存区库存 //Model.WH_CELL mSTART_WH_CELL = this._P_WH_CELL.GetModel(mMANAGE_MAIN.START_CELL_ID); //if (mSTART_WH_CELL == null) //{ // bResult = false; // sResult = string.Format("起始货位索引[{0}]不存在", mMANAGE_MAIN.START_CELL_ID); // return bResult; //} //Model.WH_AREA mSTART_WH_AREA = this._P_WH_AREA.GetModel(mSTART_WH_CELL.AREA_ID); //if (mSTART_WH_AREA == null) //{ // bResult = false; // sResult = string.Format("起始货位库区索引[{0}]不存在", mSTART_WH_CELL.AREA_ID); // return bResult; //} //if (!mSTART_WH_AREA.AREA_TYPE.Equals(Enum.AREA_TYPE.XuNiKu.ToString())) //{ // bResult = false; // sResult = string.Format("起始货位库区类型[{0}]不合法", mSTART_WH_AREA.AREA_TYPE); // return bResult; //} #endregion #region 校验计划 SiaSun.LMS.Model.PLAN_MAIN mPLAN_MAIN = null; SiaSun.LMS.Model.PLAN_LIST mPLAN_LIST = null; if (lsPLAN_LIST != null && lsPLAN_LIST.Count > 0) { mPLAN_LIST = this._P_PLAN_LIST.GetModel(lsPLAN_LIST[0].PLAN_LIST_ID); mPLAN_MAIN = this._P_PLAN_MAIN.GetModel(mPLAN_LIST.PLAN_ID); } else { bResult = false; sResult = string.Format("请选择【出库】的计划明细"); return bResult; } #endregion #endregion #region 匹配任务明细与计划明细 foreach (SiaSun.LMS.Model.MANAGE_LIST mMANAGE_LIST in lsMANAGE_LIST) { foreach (SiaSun.LMS.Model.PLAN_LIST temp_mPLAN_LIST in lsPLAN_LIST) { if (mMANAGE_LIST.GOODS_ID == temp_mPLAN_LIST.GOODS_ID) { bResult = _S_GoodsService.GoodsPropertybEqual(mMANAGE_LIST.GOODS_ID, temp_mPLAN_LIST, mMANAGE_LIST, out sResult); if (!bResult) { continue; } //跳过已完成的计划明细 if (temp_mPLAN_LIST.PLAN_LIST_QUANTITY == temp_mPLAN_LIST.PLAN_LIST_ORDERED_QUANTITY) { continue; } if (temp_mPLAN_LIST.PLAN_LIST_ORDERED_QUANTITY + mMANAGE_LIST.MANAGE_LIST_QUANTITY > temp_mPLAN_LIST.PLAN_LIST_QUANTITY) { bResult = false; sResult = string.Format("出库数量[{0}]不能大于计划未完成数量[{1}-{2}={3}]!", mMANAGE_LIST.MANAGE_LIST_QUANTITY, temp_mPLAN_LIST.PLAN_LIST_QUANTITY, temp_mPLAN_LIST.PLAN_LIST_ORDERED_QUANTITY, temp_mPLAN_LIST.PLAN_LIST_QUANTITY - temp_mPLAN_LIST.PLAN_LIST_ORDERED_QUANTITY); return bResult; } mMANAGE_LIST.PLAN_LIST_ID = temp_mPLAN_LIST.PLAN_LIST_ID; break; } } if (mMANAGE_LIST.PLAN_LIST_ID == null || mMANAGE_LIST.PLAN_LIST_ID == 0) { bResult = false; sResult = string.Format("物料索引[{0}]任务明细未找到对应计划明细", mMANAGE_LIST.GOODS_ID); return bResult; } } mMANAGE_MAIN.PLAN_ID = mPLAN_MAIN.PLAN_ID; mMANAGE_MAIN.PLAN_TYPE_CODE = mPLAN_MAIN.PLAN_TYPE_CODE; #endregion #region 下达任务 bResult = base.ManageCreate(mMANAGE_MAIN, lsMANAGE_LIST, bAutoSendControl, false, out sResult); if (bResult) { /// this.updateLedText(mMANAGE_MAIN.START_CELL_ID, 1, "任务类型:出库"); ///this.updateLedText(mMANAGE_MAIN.START_CELL_ID, 2, "条码:" + mMANAGE_MAIN.STOCK_BARCODE); //this.updateLedText(mMANAGE_MAIN.START_CELL_ID, 3, "货位:" + mMANAGE_MAIN.START_CELL_ID.ToString()); SiaSun.LMS.Model.WH_CELL wh_cell = this._P_WH_CELL.GetModel(mMANAGE_MAIN.START_CELL_ID); //if (wh_cell != null) //{ // this.updateLedText(mMANAGE_MAIN.START_CELL_ID, 3, "货位:" + wh_cell.CELL_CODE); //} //else //{ // this.updateLedText(mMANAGE_MAIN.START_CELL_ID, 3, "货位:" + "未找到货位"); //} } if ((!bAutoSendControl) && bResult) { bResult = this.ManageComplete(mMANAGE_MAIN.MANAGE_ID, false, out sResult); } #endregion } catch (Exception ex) { bResult = false; sResult = ex.Message; this._log.Fatal(string.Format("调用方法{0}发生异常。", MethodBase.GetCurrentMethod().Name), ex); } finally { if (bResult) { this._P_Base_House.CommitTransaction(true); } else { this._P_Base_House.RollBackTransaction(true); } } return bResult; } public bool ManageCreate(SiaSun.LMS.Model.MANAGE_MAIN mMANAGE_MAIN, List lsMANAGE_LIST, bool bTrans, bool bAutoSendControl, bool bComplete, out string sResult) { bool bResult = true; sResult = string.Empty; try { this._P_Base_House.BeginTransaction(bTrans); #region 下达任务 bResult = base.ManageCreate(mMANAGE_MAIN, lsMANAGE_LIST, bAutoSendControl, false, out sResult); if (bComplete) { bResult = this.ManageComplete(mMANAGE_MAIN.MANAGE_ID, false, out sResult); ////新增接口生成库存后,插入新表数据,传明细和新表ID,出库再回传ID和明细 //if (bResult) //{ // S_ERPService erp = new S_ERPService(); // //SiaSun.LMS.Model.GOODS_MAIN mGOODS_MAIN = this._P_GOODS_MAIN.GetModel(lsMANAGE_LIST[0].GOODS_ID); // ////if (mGOODS_MAIN == null) // ////{ // //// bResult = false; // //// sResult = string.Format("该物料[{0}]不存在,请到物料维护中维护后再入库", STOCK_BARCODE); // //// return bResult; // ////} // MES_INTERFACE mMES_INTERFACE = new MES_INTERFACE(); // //流水号 // mMES_INTERFACE.STOCK_BARCODE = mMANAGE_MAIN.STOCK_BARCODE; // mMES_INTERFACE.INOUT = "1"; // //批次号 // mMES_INTERFACE.BATCH = lsMANAGE_LIST[0].GOODS_PROPERTY1; // // //型号不传 // mMES_INTERFACE.SPECIFICATION = ""; // mMES_INTERFACE.GOODS_CODE = "1"; // mMES_INTERFACE.GOODS_NAME = "1"; // //供应商 // mMES_INTERFACE.SUPPLY = lsMANAGE_LIST[0].GOODS_PROPERTY3; // //零件号 // mMES_INTERFACE.PART_NO = lsMANAGE_LIST[0].GOODS_PROPERTY4; // mMES_INTERFACE.UNIT = "1"; // mMES_INTERFACE.QUANTITY = lsMANAGE_LIST[0].MANAGE_LIST_QUANTITY; // mMES_INTERFACE.UPDATE_TIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); // mMES_INTERFACE.OUT_TIME = ""; // mMES_INTERFACE.PRODUCT_TIME = ""; // string requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(mMES_INTERFACE); // mMES_INTERFACE.WMS_INFO = requestJson; // mMES_INTERFACE.MES_INFO = sResult; // // 插入新表 调用接口 // this._P_MES_INTERFACE.Add(mMES_INTERFACE); // //判断数据是否重复 // Model.MES_INTERFACE tmes = this._P_MES_INTERFACE.GetModelStockbarcode(mMANAGE_MAIN.STOCK_BARCODE); // if (tmes != null) // { // sResult = "入库上报时发现已经有该流水号接口数据,先处理数据再进行入库"; // return false; // } // //调用MES接口 // //向MES上报入库完成 // bool bBResult = erp.HttpPost(requestJson, out ssResult); // //接口调用失败重发 // if (!bBResult) // { // ssResult = "ERRORMSG:接口调用失败,联系MES维护人员查看条码是否有问题" + ssResult; // log.SaveLog(ssResult); // Model.MES_INTERFACE_RETRY mMES_INTERFACE_RETRY = new Model.MES_INTERFACE_RETRY(); // mMES_INTERFACE_RETRY.BIZ_TYPE = "ManageIn"; // mMES_INTERFACE_RETRY.WHO = "MESRetry"; // mMES_INTERFACE_RETRY.MESSAGE = requestJson; // // mMES_INTERFACE_RETRY. = Common.StringUtil.GetDateTime(); // this._P_MES_INTERFACE_RETRY.Add(mMES_INTERFACE_RETRY); // } // #region 日志 // Model.MES_INTERFACE_LOG mMES_INTERFACE_LOG = new Model.MES_INTERFACE_LOG(); // mMES_INTERFACE_LOG.INTERFACE = "ManageIn"; // mMES_INTERFACE_LOG.IN_MESSAGE = requestJson; // mMES_INTERFACE_LOG.OUT_MESSAGE = ssResult; // mMES_INTERFACE_LOG.SENDER = "WMS"; // mMES_INTERFACE_LOG.RECEIVER = "MES"; // mMES_INTERFACE_LOG.TIME_STAMP = Common.StringUtil.GetDateTime(); // this._P_MES_INTERFACE_LOG.Add(mMES_INTERFACE_LOG); // #endregion //} } #endregion } catch (Exception ex) { bResult = false; sResult = ex.Message; this._log.Fatal(string.Format("调用方法{0}发生异常。", MethodBase.GetCurrentMethod().Name), ex); } finally { if (bResult) { this._P_Base_House.CommitTransaction(true); } else { this._P_Base_House.RollBackTransaction(true); } } return bResult; } /// /// 完成 /// /// /// 是否独立事务 /// /// public new bool ManageComplete(int MANAGE_ID, bool bTrans, out string sResult) { bool bResult = true; sResult = string.Empty; try { this._P_Base_House.BeginTransaction(bTrans); #region 校验 SiaSun.LMS.Model.MANAGE_MAIN mMANAGE_MAIN = this._P_MANAGE_MAIN.GetModel(MANAGE_ID); bResult = null != mMANAGE_MAIN; if (!bResult) { sResult = string.Format("管理任务索引[{0}]不存在", MANAGE_ID); return bResult; } #endregion #region 删除库存 bResult = this._S_StorageService.StorageDelete(MANAGE_ID, out sResult); if (!bResult) { return bResult; } #endregion #region 更新货位状态ljc #region 更新货位 SiaSun.LMS.Model.WH_CELL wH_CELL_Start = this._P_WH_CELL.GetModel(mMANAGE_MAIN.START_CELL_ID); if (wH_CELL_Start != null) { bResult = this._S_CellService.CellUpdateStatus(mMANAGE_MAIN.START_CELL_ID, string.Empty, SiaSun.LMS.Enum.RUN_STATUS.Enable.ToString(), out sResult); if (!bResult) { return bResult; } } SiaSun.LMS.Model.WH_CELL wH_CELL_End = this._P_WH_CELL.GetModel(mMANAGE_MAIN.END_CELL_ID); if (wH_CELL_End != null) { bResult = this._S_CellService.CellUpdateStatus(mMANAGE_MAIN.END_CELL_ID, string.Empty, SiaSun.LMS.Enum.RUN_STATUS.Enable.ToString(), out sResult); if (!bResult) { return bResult; } } #endregion //SiaSun.LMS.Model.WH_CELL mSTART_WH_CELL = this._P_WH_CELL.GetModel(mMANAGE_MAIN.START_CELL_ID); //if (null == mSTART_WH_CELL) //{ // bResult = false; // sResult = string.Format("起始位置索引[{0}]不存在", mMANAGE_MAIN.START_CELL_ID); // return bResult; //} //SiaSun.LMS.Model.WH_CELL mEND_WH_CELL = this._P_WH_CELL.GetModel(mMANAGE_MAIN.END_CELL_ID); //if (null == mEND_WH_CELL) //{ // bResult = false; // sResult = string.Format("终止位置索引[{0}]不存在", mMANAGE_MAIN.END_CELL_ID); // return bResult; //} //if (!this._P_WH_AREA.GetModel(mSTART_WH_CELL.AREA_ID).AREA_TYPE.Equals(SiaSun.LMS.Enum.AREA_TYPE.XuNiKu.ToString())) //{ // string CELL_STATUS = SiaSun.LMS.Enum.CELL_STATUS.Nohave.ToString(); // bResult = this._S_CellService.CellUpdateStatus(mMANAGE_MAIN.START_CELL_ID, CELL_STATUS, SiaSun.LMS.Enum.RUN_STATUS.Enable.ToString(), out sResult); // if (!bResult) // { // return bResult; // } //} //if (!this._P_WH_AREA.GetModel(mEND_WH_CELL.AREA_ID).AREA_TYPE.Equals(SiaSun.LMS.Enum.AREA_TYPE.XuNiKu.ToString())) //{ // // string CELL_STATUS = mMANAGE_MAIN.FULL_FLAG == "1" ? SiaSun.LMS.Enum.CELL_STATUS.Full.ToString() : SiaSun.LMS.Enum.CELL_STATUS.Have.ToString(); // string CELL_STATUS = SiaSun.LMS.Enum.CELL_STATUS.Full.ToString(); // bResult = this._S_CellService.CellUpdateStatus(mMANAGE_MAIN.END_CELL_ID, CELL_STATUS, SiaSun.LMS.Enum.RUN_STATUS.Enable.ToString(), out sResult); // if (!bResult) // { // return bResult; // } //} #endregion #region 调用基类完成方法 bResult = base.ManageComplete(mMANAGE_MAIN.MANAGE_ID, false, out sResult); if (!bResult) { return bResult; } //// this.updateLedText(mMANAGE_MAIN.START_CELL_ID, 1, "出库完成"); // this.updateLedText(mMANAGE_MAIN.START_CELL_ID, 2, "条码:" + mMANAGE_MAIN.STOCK_BARCODE); //this.updateLedText(mMANAGE_MAIN.START_CELL_ID, 3, "货位:" + mMANAGE_MAIN.START_CELL_ID.ToString()); #endregion #region 删除任务信息 this._P_IO_CONTROL.DeleteManageID(MANAGE_ID); this._P_MANAGE_DETAIL.DeleteManageID(MANAGE_ID); this._P_MANAGE_LIST.DeleteManageID(MANAGE_ID); this._P_MANAGE_MAIN.Delete(MANAGE_ID); #endregion } catch (Exception ex) { bResult = false; sResult = ex.Message; this._log.Fatal(string.Format("调用方法{0}发生异常。", MethodBase.GetCurrentMethod().Name), ex); } finally { if (bResult) { this._P_Base_House.CommitTransaction(bTrans); } else { this._P_Base_House.RollBackTransaction(bTrans); } } return bResult; } /// /// 出库确认完成 /// /// /// 是否独立事务 /// /// public bool ManageConfirm(int MANAGE_ID, bool bTrans, out string sResult) { bool bResult = true; sResult = string.Empty; try { this._P_Base_House.BeginTransaction(bTrans); #region 校验 SiaSun.LMS.Model.MANAGE_MAIN mMANAGE_MAIN = this._P_MANAGE_MAIN.GetModel(MANAGE_ID); bResult = null != mMANAGE_MAIN; if (!bResult) { sResult = string.Format("管理任务索引[{0}]不存在", MANAGE_ID.ToString()); return bResult; } SiaSun.LMS.Model.IO_CONTROL mIO_CONTROL = this._P_IO_CONTROL.GetModelManageID(MANAGE_ID); if ((null != mIO_CONTROL) && (!mIO_CONTROL.CONTROL_STATUS.Equals(999))) { bResult = false; sResult = string.Format("控制任务索引[{0}]的控制任务未完成", mIO_CONTROL.CONTROL_ID); return bResult; } SiaSun.LMS.Model.WH_CELL mSTART_WH_CELL = this._P_WH_CELL.GetModel(mMANAGE_MAIN.START_CELL_ID); if (null == mSTART_WH_CELL) { bResult = false; sResult = string.Format("起始位置索引[{0}]不存在", mMANAGE_MAIN.START_CELL_ID); return bResult; } SiaSun.LMS.Model.WH_CELL mEND_WH_CELL = this._P_WH_CELL.GetModel(mMANAGE_MAIN.END_CELL_ID); if (null == mEND_WH_CELL) { bResult = false; sResult = string.Format("终止位置索引[{0}]不存在", mMANAGE_MAIN.END_CELL_ID); return bResult; } #endregion bResult = this.ManageComplete(mMANAGE_MAIN.MANAGE_ID, false, out sResult); } catch (Exception ex) { bResult = false; sResult = ex.Message; this._log.Fatal(string.Format("调用方法{0}发生异常。", MethodBase.GetCurrentMethod().Name), ex); } finally { if (bResult) { this._P_Base_House.CommitTransaction(bTrans); } else { this._P_Base_House.RollBackTransaction(bTrans); } } return bResult; } /// /// 取消确认出库 /// /// /// /// /// public bool ManageCancelConfirm(int MANAGE_ID, bool bTrans, out string sResult) { bool bResult = true; sResult = string.Empty; SiaSun.LMS.Model.MANAGE_MAIN mMANAGE_MAIN = null; try { this._P_Base_House.BeginTransaction(bTrans); mMANAGE_MAIN = this._P_MANAGE_MAIN.GetModel(MANAGE_ID); if (null == mMANAGE_MAIN) { bResult = false; sResult = string.Format("管理任务索引[{0}]不存在", MANAGE_ID); return bResult; } SiaSun.LMS.Model.IO_CONTROL mIO_CONTROL = this._P_IO_CONTROL.GetModelManageID(mMANAGE_MAIN.MANAGE_ID); if ((null != mIO_CONTROL) && (!mIO_CONTROL.CONTROL_STATUS.Equals(900))) { bResult = false; sResult = string.Format("关联的控制任务未删除,索引[{0}]", mIO_CONTROL.CONTROL_ID); return bResult; } bResult = this._S_CellService.CellUpdateStatus(mMANAGE_MAIN.START_CELL_ID, string.Empty, SiaSun.LMS.Enum.RUN_STATUS.Enable.ToString(), out sResult); if (!bResult) { return bResult; } bResult = this._S_CellService.CellUpdateStatus(mMANAGE_MAIN.END_CELL_ID, string.Empty, SiaSun.LMS.Enum.RUN_STATUS.Enable.ToString(), out sResult); if (!bResult) { return bResult; } foreach (SiaSun.LMS.Model.MANAGE_LIST mMANAGE_LIST in this._P_MANAGE_LIST.GetListManageID(MANAGE_ID)) { SiaSun.LMS.Model.PLAN_LIST mPLAN_LIST = this._P_PLAN_LIST.GetModel(mMANAGE_LIST.PLAN_LIST_ID); if (null != mPLAN_LIST) { mPLAN_LIST.PLAN_LIST_ORDERED_QUANTITY -= mMANAGE_LIST.MANAGE_LIST_QUANTITY; this._P_PLAN_LIST.Update(mPLAN_LIST); } } this._P_IO_CONTROL.DeleteManageID(MANAGE_ID); this._P_MANAGE_DETAIL.DeleteManageID(MANAGE_ID); this._P_MANAGE_LIST.DeleteManageID(MANAGE_ID); this._P_MANAGE_MAIN.Delete(MANAGE_ID); } catch (Exception ex) { bResult = false; sResult = ex.Message; this._log.Fatal(string.Format("调用方法{0}发生异常。", MethodBase.GetCurrentMethod().Name), ex); } finally { if (bResult) { this._P_Base_House.CommitTransaction(bTrans); #region 生成系统日志 SiaSun.LMS.Model.WH_CELL mSTART_WH_CELL = this._P_WH_CELL.GetModel(mMANAGE_MAIN.START_CELL_ID); SiaSun.LMS.Model.WH_CELL mEND_WH_CELL = this._P_WH_CELL.GetModel(mMANAGE_MAIN.END_CELL_ID); string MESSAGE = string.Format("任务索引[{0}],起始位置[{1}],终止位置[{2}],容器条码[{3}]", MANAGE_ID, mSTART_WH_CELL.CELL_NAME, mEND_WH_CELL.CELL_NAME, mMANAGE_MAIN.STOCK_BARCODE.ToString()); this.CreateSYS_LOG("取消出库", "SYS", "1", MESSAGE); #endregion } else { this._P_Base_House.RollBackTransaction(bTrans); } } return bResult; } } }