private void btn确定_Click(object sender, EventArgs e) { if (m_cm.SaveCurrent()) { m_zjrw.时间要求始 = (DateTime)m_cm.DisplayManager.DataControls["时间要求始"].SelectedDataValue; m_zjrw.时间要求止 = (DateTime)m_cm.DisplayManager.DataControls["时间要求止"].SelectedDataValue; m_zjrw.区域编号 = (string)m_cm.DisplayManager.DataControls["区域编号"].SelectedDataValue; m_zjrw.缓急程度 = (int)m_cm.DisplayManager.DataControls["缓急程度"].SelectedDataValue; // 静态紧急下达 if (m_rw == null) { m_专家任务Dao.下达专家任务(m_zjrw, System.DateTime.Now); } // 动态调度 else { m_zjrw = m_专家任务Dao.生成专家任务(m_zjrw, m_rw, m_xz); } } else { this.DialogResult = System.Windows.Forms.DialogResult.None; } }
//private 专家任务Dao 专家任务Dao //{ // get // { // if (m_专家任务dao == null) // { // m_专家任务dao = new 专家任务Dao(); // } // return m_专家任务dao; // } //} /// <summary> /// 专家任务.车辆作业 = null,Delete(车辆作业) /// </summary> /// <param name="clzy"></param> public void 撤销车辆作业(车辆作业 clzy) { if (clzy == null) { return; } using (IRepository rep = this.GenerateRepository()) { try { rep.BeginTransaction(); 专家任务 zjrw = clzy.专家任务; zjrw.车辆作业 = null; m_专家任务dao.Update(rep, zjrw); base.Delete(rep, clzy); rep.CommitTransaction(); } catch (Exception) { rep.RollbackTransaction(); throw; } } }
static bool 撤销Validation(专家任务 zjrw, 撤销专家任务 cx) { switch (cx) { case 撤销专家任务.撤销监控: if (zjrw.车辆作业.结束时间 != null) { MessageForm.ShowWarning("专家任务的车辆作业已结束,无法撤销"); return false; } break; case 撤销专家任务.撤销车辆作业: if (zjrw.车辆作业.开始时间 != null) { MessageForm.ShowWarning("专家任务的车辆作业已开始监控,无法撤销"); return false; } break; case 撤销专家任务.撤销任务下达: if (zjrw.车辆作业 != null) { MessageForm.ShowWarning("专家任务已安排车辆作业,无法撤销"); return false; } break; default: throw new ArgumentOutOfRangeException("撤销任务 out of range"); } return true; }
private bool 是否能组合(专家任务 x, 车辆 y, int 后续作业计划) { if (后续作业计划 < 1) { return true; } return false; }
public 紧急下达(专家任务 zjrw) { m_zjrw = zjrw; InitializeComponent(); m_cm = AssociateDataControlsInControlManager(new Control[] { pnl区域编号, pnl时间要求始, pnl时间要求止, pnl缓急程度}, m_gridName); }
/// <summary> /// 保存并返回车辆作业 /// </summary> /// <param name="cl"></param> /// <param name="zjrw"></param> /// <param name="bz"></param> /// <returns></returns> public 车辆作业 生成车辆作业(车辆 cl, 专家任务 zjrw, string bz) { if (cl == null || zjrw == null) { return(null); } using (IRepository rep = this.GenerateRepository()) { try { rep.BeginTransaction(); 车辆作业 clzy = new 车辆作业(); clzy.车辆 = cl; clzy.专家任务 = zjrw; clzy.IsActive = true; clzy.作业号 = 生成作业号(zjrw.新任务号); clzy.备注 = bz; base.Save(rep, clzy); zjrw.车辆作业 = clzy; m_专家任务dao.Update(rep, zjrw); 作业监控状态 entity = new 作业监控状态(); entity.IsActive = true; entity.车辆作业 = clzy; entity.时间 = System.DateTime.Now; 作业监控Dao.更新作业监控状态(rep, entity, clzy.最新作业状态, null, null); //var route = m_作业监控Dao.GetDefaultRoute(clzy); //if (route != null && route.Time.HasValue) //{ // entity.预计到达时间 = System.DateTime.Now.AddMinutes(route.Time.Value); //} m_作业监控Dao.Save(rep, entity); rep.CommitTransaction(); return(clzy); } catch (Exception) { rep.RollbackTransaction(); throw; } } }
public static string Get任务状态(专家任务 zjrw, out int[] taskIdx, out string[] importantAreas, out string[] importantTaskStatus, out string[] importantWorkStatus) { IList <任务> tasks = zjrw.任务; taskIdx = null; importantAreas = null; importantTaskStatus = null; importantWorkStatus = null; string workTitle = null; // Color: Blue, Gray, ControlText switch (zjrw.任务性质) { case 专家任务性质.静态优化套箱: case 专家任务性质.动态优化套箱: { System.Diagnostics.Debug.Assert(tasks.Count == 2); System.Diagnostics.Debug.Assert(tasks[0].任务性质 == 任务性质.进口拆箱); System.Diagnostics.Debug.Assert(tasks[1].任务性质 == 任务性质.出口装箱); if (!zjrw.任务[0].转关箱标志.HasValue || zjrw.任务[0].转关箱标志.Value == 转关箱标志.非转关) { workTitle = "套箱(清关箱)"; taskIdx = new int[] { 0, 0, 1, 1 }; importantAreas = new string[] { tasks[0].提箱点编号, tasks[0].卸货地编号, tasks[1].装货地编号, tasks[1].还箱进港点编号 }; importantTaskStatus = new string[] { "0/进口拆箱-2/ 出口装箱", "0/进口拆箱-2/ 出口装箱", "1/进口拆箱-0/ 出口装箱", "1/进口拆箱-0/ 出口装箱" }; importantWorkStatus = new string[] { "港区提箱", "卸货", "出口装货", "进港" }; } else { workTitle = "套箱(转关箱)"; taskIdx = new int[] { 0, 0, 0, 0, 1, 1 }; importantAreas = new string[] { tasks[0].提箱点编号, Feng.Utils.NameValueControlHelper.GetMultiString("港区指运地_施封地", tasks[0].提箱点编号), Feng.Utils.NameValueControlHelper.GetMultiString("港区指运地_验封地", tasks[0].卸货地编号), tasks[0].卸货地编号, tasks[1].装货地编号, tasks[1].还箱进港点编号 }; importantTaskStatus = new string[] { "0/进口拆箱-2/ 出口装箱", "0/进口拆箱-2/ 出口装箱", "0/进口拆箱-2/ 出口装箱", "0/进口拆箱-2/ 出口装箱", "1/进口拆箱-0/ 出口装箱", "1/进口拆箱-0/ 出口装箱" }; importantWorkStatus = new string[] { "港区提箱", "施关封", "验关封", "卸货", "出口装货", "进港" }; } } break; case 专家任务性质.静态优化进口箱带货: case 专家任务性质.动态优化进口箱带货: { System.Diagnostics.Debug.Assert(tasks.Count == 2); System.Diagnostics.Debug.Assert(tasks[0].任务性质 == 任务性质.进口拆箱); System.Diagnostics.Debug.Assert(tasks[1].任务性质 == 任务性质.I带货); if (!zjrw.任务[0].转关箱标志.HasValue || zjrw.任务[0].转关箱标志.Value == 转关箱标志.非转关) { workTitle = "进口箱带货(清关箱)"; taskIdx = new int[] { 0, 0, 1, 1, 0 }; importantAreas = new string[] { tasks[0].提箱点编号, tasks[0].卸货地编号, tasks[1].装货地编号, tasks[1].卸货地编号, tasks[0].还箱进港点编号 }; importantTaskStatus = new string[] { "0/进口拆箱-2/ I带货", "0/进口拆箱-2/ I带货", "2/进口拆箱-0/ I带货", "2/进口拆箱-0/ I带货", "0/进口拆箱-1/ I带货" }; importantWorkStatus = new string[] { "港区提箱", "卸货", "带货装货", "带货卸货", "还箱" }; } else { workTitle = "进口箱带货(转关箱)"; taskIdx = new int[] { 0, 0, 0, 0, 1, 1, 0 }; importantAreas = new string[] { tasks[0].提箱点编号, Feng.Utils.NameValueControlHelper.GetMultiString("港区指运地_施封地", tasks[0].提箱点编号), Feng.Utils.NameValueControlHelper.GetMultiString("港区指运地_验封地", tasks[0].卸货地编号), tasks[0].卸货地编号, tasks[1].装货地编号, tasks[1].卸货地编号, tasks[0].还箱进港点编号 }; importantTaskStatus = new string[] { "0/进口拆箱-2/ I带货", "0/进口拆箱-2/ I带货", "0/进口拆箱-2/ I带货", "0/进口拆箱-2/ I带货", "2/进口拆箱-0/ I带货", "2/进口拆箱-0/ I带货", "0/进口拆箱-1/ I带货" }; importantWorkStatus = new string[] { "港区提箱", "施关封", "验关封", "卸货", "带货装货", "带货卸货", "还箱" }; } } break; case 专家任务性质.静态优化出口箱带货: case 专家任务性质.动态优化出口箱带货: { System.Diagnostics.Debug.Assert(tasks.Count == 2); System.Diagnostics.Debug.Assert(tasks[0].任务性质 == 任务性质.出口装箱); System.Diagnostics.Debug.Assert(tasks[1].任务性质 == 任务性质.E带货); workTitle = "出口箱带货"; taskIdx = new int[] { 0, 1, 1, 0, 0 }; importantAreas = new string[] { tasks[0].提箱点编号, tasks[1].装货地编号, tasks[1].卸货地编号, tasks[0].装货地编号, tasks[0].还箱进港点编号 }; importantTaskStatus = new string[] { "0/出口装箱-2/ E带货", "2/出口装箱-0/ E带货", "2/出口装箱-0/ E带货", "0/出口装箱-1/ E带货", "0/出口装箱-1/ E带货" }; importantWorkStatus = new string[] { "堆场提箱", "带货装货", "带货卸货", "装货", "进港" }; } break; case 专家任务性质.静态优化进口箱对箱: case 专家任务性质.动态优化进口箱对箱: { workTitle = "进口箱对箱"; System.Diagnostics.Debug.Assert(tasks.Count == 2); System.Diagnostics.Debug.Assert(tasks[0].任务性质 == 任务性质.进口拆箱); System.Diagnostics.Debug.Assert(tasks[1].任务性质 == 任务性质.进口拆箱); taskIdx = new int[] { 0, 1, 0, 1, 0, 1 }; importantAreas = new string[] { tasks[0].提箱点编号, tasks[1].提箱点编号, tasks[0].卸货地编号, tasks[1].卸货地编号, tasks[0].还箱进港点编号, tasks[1].还箱进港点编号 }; importantTaskStatus = new string[] { "0/进口拆箱-2/ 进口拆箱", "2/进口拆箱-0/ 进口拆箱", "0/进口拆箱-2/ 进口拆箱", "2/进口拆箱-0/ 进口拆箱", "0/进口拆箱-2/ 进口拆箱", "2/进口拆箱-0/ 进口拆箱" }; importantWorkStatus = new string[] { "港区提箱1", "港区提箱2", "卸货1", "卸货2", "还箱1", "还箱2" }; } break; case 专家任务性质.静态优化出口箱对箱: case 专家任务性质.动态优化出口箱对箱: { System.Diagnostics.Debug.Assert(tasks.Count == 2); System.Diagnostics.Debug.Assert(tasks[0].任务性质 == 任务性质.出口装箱); System.Diagnostics.Debug.Assert(tasks[1].任务性质 == 任务性质.出口装箱); workTitle = "出口箱对箱"; taskIdx = new int[] { 0, 1, 0, 1, 0, 1 }; importantAreas = new string[] { tasks[0].提箱点编号, tasks[1].提箱点编号, tasks[0].装货地编号, tasks[1].装货地编号, tasks[0].还箱进港点编号, tasks[1].还箱进港点编号 }; importantTaskStatus = new string[] { "0/出口装箱-2/ 出口装箱", "2/出口装箱-0/ 出口装箱", "0/出口装箱-2/ 出口装箱", "2/出口装箱-0/ 出口装箱", "0/出口装箱-2/ 出口装箱", "2/出口装箱-0/ 出口装箱" }; importantWorkStatus = new string[] { "堆场提箱1", "堆场提箱2", "装货1", "装货2", "进港1", "进港2" }; } break; case 专家任务性质.静态优化进出口对箱: case 专家任务性质.动态优化进出口对箱: { System.Diagnostics.Debug.Assert(tasks.Count == 2); System.Diagnostics.Debug.Assert(tasks[0].任务性质 == 任务性质.进口拆箱); System.Diagnostics.Debug.Assert(tasks[1].任务性质 == 任务性质.出口装箱); workTitle = "进出口箱对箱"; taskIdx = new int[] { 0, 1, 0, 1, 0, 1 }; importantAreas = new string[] { tasks[0].提箱点编号, tasks[1].提箱点编号, tasks[0].卸货地编号, tasks[1].装货地编号, tasks[0].还箱进港点编号, tasks[1].还箱进港点编号 }; importantTaskStatus = new string[] { "0/进口拆箱-2/ 出口装箱", "2/进口拆箱-0/ 出口装箱", "0/进口拆箱-2/ 出口装箱", "2/进口拆箱-0/ 出口装箱", "0/进口拆箱-2/ 出口装箱", "2/进口拆箱-0/ 出口装箱" }; importantWorkStatus = new string[] { "港区提箱", "堆场提箱", "卸货", "装货", "还箱", "进港" }; } break; case 专家任务性质.无优化进口拆箱: { System.Diagnostics.Debug.Assert(tasks.Count == 1); System.Diagnostics.Debug.Assert(tasks[0].任务性质 == 任务性质.进口拆箱); if (!zjrw.任务[0].转关箱标志.HasValue || zjrw.任务[0].转关箱标志.Value == 转关箱标志.非转关) { workTitle = "进口拆箱(清关箱)"; taskIdx = new int[] { 0, 0, 0 }; importantAreas = new string[] { tasks[0].提箱点编号, tasks[0].卸货地编号, tasks[0].还箱进港点编号 }; importantTaskStatus = new string[] { "0/进口拆箱", "0/进口拆箱", "0/进口拆箱" }; importantWorkStatus = new string[] { "港区提箱", "卸货", "还箱" }; } else { workTitle = "进口拆箱(转关箱)"; taskIdx = new int[] { 0, 0, 0, 0, 0 }; importantAreas = new string[] { tasks[0].提箱点编号, Feng.Utils.NameValueControlHelper.GetMultiString("港区指运地_施封地", tasks[0].提箱点编号), Feng.Utils.NameValueControlHelper.GetMultiString("港区指运地_验封地", tasks[0].卸货地编号), tasks[0].卸货地编号, tasks[0].还箱进港点编号 }; importantTaskStatus = new string[] { "0/进口拆箱", "0/进口拆箱", "0/进口拆箱", "0/进口拆箱", "0/进口拆箱" }; importantWorkStatus = new string[] { "港区提箱", "施关封", "验关封", "卸货", "还箱" }; } } break; case 专家任务性质.无优化出口装箱: { System.Diagnostics.Debug.Assert(tasks.Count == 1); System.Diagnostics.Debug.Assert(tasks[0].任务性质 == 任务性质.出口装箱); workTitle = "出口装箱"; taskIdx = new int[] { 0, 0, 0 }; importantAreas = new string[] { tasks[0].提箱点编号, tasks[0].装货地编号, tasks[0].还箱进港点编号 }; importantTaskStatus = new string[] { "0/出口装箱", "0/出口装箱", "0/出口装箱" }; importantWorkStatus = new string[] { "堆场提箱", "装货", "进港" }; } break; case 专家任务性质.无优化I带货: { System.Diagnostics.Debug.Assert(tasks.Count == 1); System.Diagnostics.Debug.Assert(tasks[0].任务性质 == 任务性质.I带货); workTitle = "I带货"; taskIdx = new int[] { 0, 0 }; importantAreas = new string[] { tasks[0].装货地编号, tasks[0].卸货地编号 }; importantTaskStatus = new string[] { "0/I带货", "0/I带货" }; importantWorkStatus = new string[] { "装货", "卸货" }; } break; case 专家任务性质.无优化E带货: { System.Diagnostics.Debug.Assert(tasks.Count == 1); System.Diagnostics.Debug.Assert(tasks[0].任务性质 == 任务性质.E带货); workTitle = "E带货"; taskIdx = new int[] { 0, 0 }; importantAreas = new string[] { tasks[0].装货地编号, tasks[0].卸货地编号 }; importantTaskStatus = new string[] { "0/E带货", "0/E带货" }; importantWorkStatus = new string[] { "装货", "卸货" }; } break; default: throw new InvalidOperationException("不合理的专家任务性质!"); } System.Diagnostics.Debug.Assert(importantAreas.Length == importantTaskStatus.Length && importantTaskStatus.Length == importantWorkStatus.Length, "important字段程度必须一致!"); System.Diagnostics.Debug.Assert(!string.IsNullOrEmpty(workTitle), "必须设置作业标题。"); return(workTitle); }
private static void 撤销专家任务的车辆作业监控(专家任务 entity) { if (entity.车辆作业 == null || entity.车辆作业.开始时间 == null) return; if (撤销Validation(entity, 撤销专家任务.撤销监控)) { m_车辆作业dao.撤销监控(entity.车辆作业); } }
private static void 撤销专家任务的车辆作业(专家任务 entity) { if (entity.车辆作业 == null) return; if (撤销Validation(entity, 撤销专家任务.撤销车辆作业)) { m_车辆作业dao.撤销车辆作业(entity.车辆作业); } }
private static void 撤销专家任务下达(专家任务 entity) { if (!entity.下达时间.HasValue) return; if (撤销Validation(entity, 撤销专家任务.撤销任务下达)) { entity.下达时间 = null; m_专家任务dao.Update(entity); } }
// 动态调度-下达 public 紧急下达(专家任务 zjrw, 任务 rw, 专家任务性质? xz) : this(zjrw) { m_rw = rw; m_xz = xz; }