You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
809 lines
29 KiB
809 lines
29 KiB
4 years ago
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Configuration;
|
||
|
using System.IO;
|
||
|
using System.Linq;
|
||
|
using System.Windows.Forms;
|
||
|
using QMAPP.Entity;
|
||
|
using QMAPP.FJC.BLL.FwMark;
|
||
|
using QMAPP.FJC.Entity;
|
||
|
using QMAPP.FJC.Entity.Andon;
|
||
|
using QMAPP.FJC.Entity.Basic;
|
||
|
using QMAPP.MD.Entity;
|
||
|
using QMAPP.ServicesAgent;
|
||
|
using QMAPP.WinForm.Common;
|
||
|
using QMAPP.WinForm.Forms.Andon.Enum;
|
||
|
using QMAPP.WinForm.Forms.Operation;
|
||
|
|
||
|
namespace QMAPP.WinForm.Forms.Andon
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// 作 用:Andon呼叫管理
|
||
|
/// 作 者:周晓东
|
||
|
/// 编写日期:2017年11月01日
|
||
|
///</summary>
|
||
|
public partial class CallManageForm : Form
|
||
|
{
|
||
|
#region 变量
|
||
|
|
||
|
private int interval = 1000;
|
||
|
private ServiceAgent _agent;
|
||
|
//呼叫类型
|
||
|
private string _callType = "";
|
||
|
//选择的呼叫类型
|
||
|
//private string _selectCallType = "";
|
||
|
private string _selectCallTypeCode = "";
|
||
|
//选中的原因
|
||
|
private string _selectReason = "";
|
||
|
//呼叫原因
|
||
|
private string _callReason = "";
|
||
|
//呼叫时间
|
||
|
private string _callTime = "";
|
||
|
//工厂编码
|
||
|
private string _factoryCode = "";
|
||
|
//工位编码
|
||
|
private string _worklocCode = "";
|
||
|
//工位编码
|
||
|
private string _worklocCodeV = "";
|
||
|
//工序编码
|
||
|
private string _workcellCode = "";
|
||
|
//工作中心
|
||
|
private string _workcenterCode = "";
|
||
|
//工作中心
|
||
|
private string _workcenterCodeV = "";
|
||
|
//设备编码
|
||
|
private string _machineCode = "";
|
||
|
//配置表类型
|
||
|
private string _mainTypeCode = "CALL_TYPE";
|
||
|
//处理人
|
||
|
//private string _handler = "";
|
||
|
//班次编码
|
||
|
//private string _shiftCode = "";
|
||
|
//班组编码
|
||
|
//private string _teamCode = "";
|
||
|
//负责人
|
||
|
//private string _keeper = "";
|
||
|
//语言类型
|
||
|
//private string _language = "";
|
||
|
//消息模版
|
||
|
//private string _template = "";
|
||
|
//呼叫等级
|
||
|
//private int _callLevel;
|
||
|
//pid
|
||
|
private string _pid = "";
|
||
|
//呼叫状态
|
||
|
private string _callState = "";
|
||
|
//解锁文件路径
|
||
|
private string _filepath = "";
|
||
|
|
||
|
//当前页面列表
|
||
|
private List<CallLogEntity> _callLogList;
|
||
|
|
||
|
public MainForm mainForm = null;
|
||
|
|
||
|
string workCenter_code = "";
|
||
|
|
||
|
string workcell_code = "";
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region 私有方法
|
||
|
|
||
|
/// <summary>
|
||
|
/// 获得工位,工厂,班次等信息
|
||
|
/// </summary>
|
||
|
public void Init()
|
||
|
{
|
||
|
//根据配置文件获得工位,工序
|
||
|
string locationfile = System.Configuration.ConfigurationManager.AppSettings["loactionfile"];
|
||
|
if (System.IO.File.Exists(locationfile))
|
||
|
{
|
||
|
_machineCode = System.IO.File.ReadAllText(locationfile);
|
||
|
if (!string.IsNullOrEmpty(_machineCode))
|
||
|
{
|
||
|
//设置ip
|
||
|
MachineInfo machoneInofModel = new MachineInfo { MACHINECODDE = _machineCode };
|
||
|
var list = _agent.InvokeServiceFunction<List<MachineInfo>>("MachineInfoBLL_GetAllList", machoneInofModel);
|
||
|
if (list.Count > 0)
|
||
|
{
|
||
|
_worklocCode = list[0].WORKLOC_CODE;
|
||
|
_workcellCode = list[0].WORKCELL_CODE;
|
||
|
//根据工序获得工作中心
|
||
|
WorkCell workCellModel = new WorkCell {WORKCELL_CODE = _workcellCode};
|
||
|
var resultWorkCell = _agent.InvokeServiceFunction<DataResult<WorkCell>>("WorkCellBLL_Get", workCellModel);
|
||
|
if (resultWorkCell != null)
|
||
|
{
|
||
|
_workcenterCode = resultWorkCell.Result.WORKCENTER_CODE;
|
||
|
//根据工作中心获得工厂编码
|
||
|
var workCenterModel = new MD.Entity.WorkCenter {WORKCENTER_CODE = _workcenterCode};
|
||
|
var resultWorkCenter = _agent.InvokeServiceFunction<DataResult<MD.Entity.WorkCenter>>("WorkCenterBLL_Get", workCenterModel);
|
||
|
if (resultWorkCenter != null)
|
||
|
{
|
||
|
_factoryCode = resultWorkCenter.Result.FACTORY_CODE;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 获取列表呼叫记录的数据并生成CallLogList
|
||
|
/// </summary>
|
||
|
/// <param name="factoryCode"></param>
|
||
|
/// <param name="worklocCode"></param>
|
||
|
public void GetCallLogList(string factoryCode, string worklocCode)
|
||
|
{
|
||
|
CallLogEntity model = new CallLogEntity
|
||
|
{
|
||
|
FACTORY_CODE = factoryCode,
|
||
|
WORKLOC_CODE = worklocCode,
|
||
|
};
|
||
|
_callLogList = _agent.InvokeServiceFunction<List<CallLogEntity>>("AndonCallBLL_GetCallLogList", model);
|
||
|
//只显示列表字段
|
||
|
DGView.AutoGenerateColumns = false;
|
||
|
DGView.DataSource = _callLogList;
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 获取工作中心下是否还有0125状态下的呼叫记录
|
||
|
/// </summary>
|
||
|
/// <param name="workcenterCode"></param>
|
||
|
public bool GetWorkcenterCode(string workcenterCode)
|
||
|
{
|
||
|
CallLogEntity model = new CallLogEntity
|
||
|
{
|
||
|
WORKCENTER_CODE = workcenterCode,
|
||
|
};
|
||
|
_callLogList = _agent.InvokeServiceFunction<List<CallLogEntity>>("AndonCallBLL_GetCallLogList", model);
|
||
|
if (_callLogList != null && _callLogList.Count>0)
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 获取呼叫原因List数据
|
||
|
/// </summary>
|
||
|
/// <param name="callType"></param>
|
||
|
/// <returns></returns>
|
||
|
public List<ConfigDetail> GetCallReasonList(string PID)
|
||
|
{
|
||
|
//CallReasonEntity model = new CallReasonEntity
|
||
|
//{
|
||
|
// CALL_TYPE = callType
|
||
|
//};
|
||
|
//List<CallReasonEntity> callReasonList = _agent.InvokeServiceFunction<List<CallReasonEntity>>("AndonCallBLL_GetCallReasonList", model);
|
||
|
|
||
|
List<ConfigDetail> callReasonList = _agent.InvokeServiceFunction<List<ConfigDetail>>("ConfigDetailBLL_GetSecondList", _mainTypeCode, PID);
|
||
|
//是否带空项填充返回值
|
||
|
//callReasonList.Insert(0, new CallReasonEntity());
|
||
|
return callReasonList;
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 获取维护班组成员的数据
|
||
|
/// </summary>
|
||
|
/// <param name="callType"></param>
|
||
|
/// <returns></returns>
|
||
|
public List<TeamMemberEntity> GetTeamMemberList(string callType)
|
||
|
{
|
||
|
TeamMemberEntity model = new TeamMemberEntity
|
||
|
{
|
||
|
WORKCELL_CODE = comWorkCenter.SelectedValue + "",
|
||
|
TEAMTYPE = callType
|
||
|
};
|
||
|
List<TeamMemberEntity> teamMemberList = _agent.InvokeServiceFunction<List<TeamMemberEntity>>("TeamMemberBLL_GetAllTeamMember", model);
|
||
|
//pid查询
|
||
|
//var v = _agent.InvokeServiceFunction<DataResult<TeamMemberEntity>>("TeamMemberBLL_Get", model).Result;
|
||
|
|
||
|
//是否带空项填充返回值
|
||
|
//callReasonList.Insert(0, new CallReasonEntity());
|
||
|
return teamMemberList;
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 初始化label
|
||
|
/// </summary>
|
||
|
public void PanelInit()
|
||
|
{
|
||
|
panelHandler.Visible = false;
|
||
|
labCallTime.Text = AndonEnum.labCallTime;
|
||
|
labCallReason.Text = AndonEnum.labCallReason;
|
||
|
labWaitTime.Text = AndonEnum.labWaitTime;
|
||
|
labAnswerTime.Text = AndonEnum.labAnswerTime;
|
||
|
labHandleTime.Text = AndonEnum.labHandleTime;
|
||
|
ButtenInit();
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 初始化butten
|
||
|
/// </summary>
|
||
|
public void ButtenInit()
|
||
|
{
|
||
|
butConfirm.Enabled = false;
|
||
|
butCancel.Enabled = false;
|
||
|
butEnd.Enabled = false;
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 根据呼叫状态初始化按钮显示状态
|
||
|
/// </summary>
|
||
|
/// <param name="callState"></param>
|
||
|
public void StateInit(string callState)
|
||
|
{
|
||
|
//buttenInit();
|
||
|
switch (callState)
|
||
|
{
|
||
|
case "0":
|
||
|
//正在呼叫
|
||
|
butConfirm.Enabled = true;
|
||
|
butCancel.Enabled = true;
|
||
|
butEnd.Enabled = false;
|
||
|
break;
|
||
|
case "1":
|
||
|
//已应答
|
||
|
butConfirm.Enabled = false;
|
||
|
butCancel.Enabled = false;
|
||
|
butEnd.Enabled = false;
|
||
|
break;
|
||
|
case "2":
|
||
|
//开始处理
|
||
|
butConfirm.Enabled = false;
|
||
|
butCancel.Enabled = false;
|
||
|
butEnd.Enabled = true;
|
||
|
break;
|
||
|
case "5":
|
||
|
//呼叫升级
|
||
|
//正在呼叫
|
||
|
butConfirm.Enabled = true;
|
||
|
butCancel.Enabled = true;
|
||
|
butEnd.Enabled = false;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
/// <summary>
|
||
|
/// 由菜单调用呼叫功能
|
||
|
/// </summary>
|
||
|
public CallManageForm()
|
||
|
{
|
||
|
InitializeComponent();
|
||
|
butReturn.Visible = false;
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 由加工工位调用安东呼叫界面
|
||
|
/// </summary>
|
||
|
/// <param name="workCenter_code">工作中心</param>
|
||
|
/// <param name="workLoc_code">工位号</param>
|
||
|
/// <param name="machineCode">设备编号</param>
|
||
|
public CallManageForm(string workCenter_code, string workLoc_code, string machineCode)
|
||
|
{
|
||
|
InitializeComponent();
|
||
|
this._workcenterCode = workCenter_code;
|
||
|
this._worklocCode = workLoc_code;
|
||
|
this._machineCode = machineCode;
|
||
|
butReturn.Visible = true;
|
||
|
}
|
||
|
|
||
|
private void CallManageForm_Load(object sender, EventArgs e)
|
||
|
{
|
||
|
_callLogList = new List<CallLogEntity>();
|
||
|
|
||
|
//初始化
|
||
|
_agent = ClientContext.GetServiceAgent();
|
||
|
//获取变量值
|
||
|
//Init();
|
||
|
//初始化控件
|
||
|
PanelInit();
|
||
|
|
||
|
//当工作中心为空时表示由菜单调用的呼叫界面
|
||
|
if (string.IsNullOrEmpty(_workcenterCode))
|
||
|
{
|
||
|
//读取当前界面的配置信息
|
||
|
_filepath = ConfigurationManager.AppSettings["SaveFilePath"];
|
||
|
_filepath = string.Format("{0}AndonViewSetting.txt", _filepath);
|
||
|
if (System.IO.File.Exists(_filepath))
|
||
|
{
|
||
|
// 打开文件准备读取数据
|
||
|
StreamReader rd = File.OpenText(_filepath);
|
||
|
this._workcenterCode = rd.ReadLine();
|
||
|
this._worklocCode = rd.ReadLine();
|
||
|
rd.Close();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//获得呼叫类型
|
||
|
#region 绑定下拉列表
|
||
|
BasicData basicData = new BasicData();
|
||
|
//返修类别
|
||
|
var callTypeList =
|
||
|
basicData.GetConfigDetailComboxSource(_mainTypeCode, false);
|
||
|
|
||
|
listBox1.DataSource = callTypeList;
|
||
|
listBox1.DisplayMember = "DetailTypeName";
|
||
|
listBox1.ValueMember = "DetailTypeCode";
|
||
|
//工作中心
|
||
|
var workCenterList = basicData.GetFactoryWorkCenterComboxSource(_factoryCode);
|
||
|
|
||
|
comWorkCenter.DataSource = workCenterList;
|
||
|
comWorkCenter.DisplayMember = "WORKCENTER_NAME";
|
||
|
comWorkCenter.ValueMember = "WORKCENTER_CODE";
|
||
|
comWorkCenter.SelectedValue = this._workcenterCode;
|
||
|
|
||
|
comWorkLoc.DisplayMember = "WORKLOC_NAME";
|
||
|
comWorkLoc.ValueMember = "WORKLOC_CODE";
|
||
|
|
||
|
ddlMachine.DisplayMember = "MACHINENAME";
|
||
|
ddlMachine.ValueMember = "MACHINECODDE";
|
||
|
|
||
|
if (string.IsNullOrEmpty(this._workcenterCode) == false)
|
||
|
{
|
||
|
comWorkLoc.DataSource = basicData.GetWorkLocComboxSource(_workcenterCode);
|
||
|
|
||
|
comWorkLoc.SelectedValue = _worklocCode;
|
||
|
comWorkLoc.Enabled = false;
|
||
|
comWorkCenter.Enabled = false;
|
||
|
|
||
|
}
|
||
|
|
||
|
//工位不为空的情况下
|
||
|
if (string.IsNullOrEmpty(this._worklocCode) == false)
|
||
|
{
|
||
|
//获取设备信息
|
||
|
List<MachineInfo> machinelist =
|
||
|
_agent.InvokeServiceFunction<List<MachineInfo>>("MachineInfoBLL_GetAllList", new MachineInfo())
|
||
|
.ToList<MachineInfo>().Where(o => o.WORKLOC_CODE == _worklocCode).ToList<MachineInfo>();
|
||
|
machinelist.Insert(0, new MachineInfo() { MACHINENAME = "", MACHINECODDE = "" });
|
||
|
ddlMachine.DataSource = machinelist;
|
||
|
|
||
|
ddlMachine.SelectedValue = _machineCode;
|
||
|
if (string.IsNullOrEmpty(_machineCode) == false)
|
||
|
{
|
||
|
ddlMachine.Enabled = false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
|
||
|
//启动轮训
|
||
|
timer1.Interval = interval;
|
||
|
timer1.Enabled = true;
|
||
|
//判断配置文件是否存在--是否解锁下拉框
|
||
|
|
||
|
|
||
|
//if (string.IsNullOrEmpty(workcell_code) == false)
|
||
|
//{
|
||
|
// comWorkCenter.SelectedValue = workCenter_code;
|
||
|
// comWorkCenter.Enabled = false;
|
||
|
// comWorkLoc.SelectedValue = workcell_code;
|
||
|
// comWorkLoc.Enabled = false;
|
||
|
//}
|
||
|
//else
|
||
|
//{
|
||
|
// butReturn.Visible = false;
|
||
|
//}
|
||
|
|
||
|
if (string.IsNullOrEmpty(_workcenterCode) == false && string.IsNullOrEmpty(_worklocCode) == false)
|
||
|
{
|
||
|
GetCallLogList(_factoryCode, _worklocCode);
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
private void listBox1_SelectedValueChanged(object sender, EventArgs e)
|
||
|
{
|
||
|
listBox2.DataSource = null;
|
||
|
if (listBox1.SelectedValue != null)
|
||
|
{
|
||
|
var configDetail = listBox1.SelectedItem as ConfigDetail;
|
||
|
//加载下拉列表
|
||
|
_callType = configDetail.DetailTypeCode;
|
||
|
listBox2.DataSource = GetCallReasonList(configDetail.PID);
|
||
|
listBox2.DisplayMember = "DetailTypeName";
|
||
|
listBox2.ValueMember = "DetailTypeCode";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void listBox2_SelectedValueChanged(object sender, EventArgs e)
|
||
|
{
|
||
|
comboBox2.DataSource = null;
|
||
|
if (listBox2.SelectedItem!=null)
|
||
|
{
|
||
|
var configDetail = listBox2.SelectedItem as ConfigDetail;
|
||
|
//赋值
|
||
|
_selectReason = configDetail.DetailTypeName;
|
||
|
//加载下拉列表
|
||
|
comboBox2.DataSource = GetCallReasonList(configDetail.PID);
|
||
|
comboBox2.DisplayMember = "DetailTypeName";
|
||
|
comboBox2.ValueMember = "DetailTypeCode";
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 呼叫操作
|
||
|
/// </summary>
|
||
|
/// <param name="sender"></param>
|
||
|
/// <param name="e"></param>
|
||
|
private void btnCall_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
if (string.IsNullOrEmpty(_selectReason))
|
||
|
{
|
||
|
MessageBox.Show(@"请选择呼叫原因!");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (string.IsNullOrEmpty(comWorkLoc.Text.ToString()))
|
||
|
{
|
||
|
MessageBox.Show(@"请选择工位信息!");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (string.IsNullOrEmpty(ddlMachine.Text.ToString()))
|
||
|
{
|
||
|
MessageBox.Show(@"请选择设备编号!");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
if (MessageBox.Show(@"呼叫原因:" + _selectReason, @"确认呼叫", MessageBoxButtons.OKCancel) != DialogResult.OK)
|
||
|
return;
|
||
|
|
||
|
//注塑机赋值
|
||
|
if (string.IsNullOrEmpty(_workcenterCode))
|
||
|
{
|
||
|
if (!string.IsNullOrEmpty(_workcenterCodeV))
|
||
|
{
|
||
|
_workcenterCode = _workcenterCodeV;
|
||
|
}
|
||
|
}
|
||
|
if (string.IsNullOrEmpty(_worklocCode))
|
||
|
{
|
||
|
if (!string.IsNullOrEmpty(_worklocCodeV))
|
||
|
{
|
||
|
_worklocCode = _worklocCodeV;
|
||
|
}
|
||
|
}
|
||
|
var model = new CallLogEntity
|
||
|
{
|
||
|
PID = Guid.NewGuid().ToString(),
|
||
|
CALL_TYPE = _callType,
|
||
|
CALL_REASION = _selectReason,
|
||
|
FACTORY_CODE = _factoryCode,
|
||
|
WORKLOC_CODE = comWorkLoc.SelectedValue.ToString(),
|
||
|
WORKCENTER_CODE = comWorkCenter.SelectedValue.ToString(),
|
||
|
CALL_TIME = DateTime.Now,
|
||
|
CALL_STATE = "0",
|
||
|
CALL_LEVEL = 1, //初始化是1级
|
||
|
MACHINECODDE = ddlMachine.SelectedValue.ToString()
|
||
|
};
|
||
|
|
||
|
DataResult<int> result =
|
||
|
_agent.InvokeServiceFunction<DataResult<int>>("AndonCallBLL_InsertCallLogAndMessageQueue",
|
||
|
model);
|
||
|
|
||
|
if (result.IsSuccess)
|
||
|
{
|
||
|
//创建是否显示的配置文件
|
||
|
if (!string.IsNullOrEmpty(comWorkCenter.SelectedValue.ToString()) && !string.IsNullOrEmpty(comWorkLoc.SelectedValue.ToString())
|
||
|
&& comWorkCenter.Enabled == true && comWorkLoc.Enabled == true)
|
||
|
{
|
||
|
FileStream fs1 = new FileStream(_filepath, FileMode.Create, FileAccess.Write);//创建写入文件
|
||
|
StreamWriter sw = new StreamWriter(fs1);
|
||
|
sw.WriteLine(comWorkCenter.SelectedValue.ToString());//开始写入值
|
||
|
sw.WriteLine(comWorkLoc.SelectedValue.ToString());//开始写入值
|
||
|
sw.Close();
|
||
|
fs1.Close();
|
||
|
}
|
||
|
|
||
|
|
||
|
//Action act = new Action(() =>
|
||
|
//{
|
||
|
// try
|
||
|
// {
|
||
|
// //点亮报警灯
|
||
|
// _agent.InvokeServiceFunction<bool>("AndonCallBLL_ADSendtoLight", _workcenterCode);
|
||
|
// //重新查询
|
||
|
// }
|
||
|
// catch
|
||
|
// {
|
||
|
|
||
|
// }
|
||
|
//});
|
||
|
//act.BeginInvoke(null, null);
|
||
|
GetCallLogList(_factoryCode, comWorkLoc.SelectedValue.ToString());
|
||
|
|
||
|
if (comWorkCenter.Enabled == true)
|
||
|
{
|
||
|
comWorkCenter.Enabled = false;
|
||
|
comWorkLoc.Enabled = false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
private void DGView_CellClick(object sender, DataGridViewCellEventArgs e)
|
||
|
{
|
||
|
|
||
|
}
|
||
|
//确认
|
||
|
private void butConfirm_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
var memberlist = GetTeamMemberList(_selectCallTypeCode);
|
||
|
if (memberlist != null)
|
||
|
{
|
||
|
comboBox1.DataSource = memberlist.OrderBy(p => p.MEMBER_NAME).ToList();
|
||
|
comboBox1.DisplayMember = "MEMBER_NAME";
|
||
|
comboBox1.ValueMember = "MEMBER_CODE";
|
||
|
}
|
||
|
panelHandler.Visible = true;
|
||
|
|
||
|
}
|
||
|
|
||
|
private void butCancel_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
CallLogEntity model = _callLogList.FirstOrDefault(x => x.PID == _pid);
|
||
|
//MessageBox.Show(model.CALL_REASION);
|
||
|
//更新状态
|
||
|
if (model != null)
|
||
|
{
|
||
|
//呼叫取消
|
||
|
model.CALL_STATE = "4";
|
||
|
DataResult<int> result = _agent.InvokeServiceFunction<DataResult<int>>("AndonCallBLL_UpdateCallLog",
|
||
|
model);
|
||
|
|
||
|
if (result.IsSuccess)
|
||
|
{
|
||
|
//if (GetWorkcenterCode(model.WORKCENTER_CODE))
|
||
|
//{
|
||
|
// //关闭报警灯
|
||
|
// var dl = _agent.InvokeServiceFunction<bool>("AndonCallBLL_ADCloseLight", model.WORKCENTER_CODE);
|
||
|
//}
|
||
|
//重新查询
|
||
|
GetCallLogList(_factoryCode, comWorkLoc.SelectedValue.ToString());
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
//取消应答直接开始处理
|
||
|
private void butStart_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
//CallLogEntity model = _callLogList.FirstOrDefault(x => x.PID == _pid);
|
||
|
//MessageBox.Show(model.CALL_REASION);
|
||
|
//更新状态
|
||
|
//if (model != null)
|
||
|
//{
|
||
|
// //开始处理
|
||
|
// model.CALL_STATE = "2";
|
||
|
// model.START_TIME = DateTime.Now;
|
||
|
// DataResult<int> result = _agent.InvokeServiceFunction<DataResult<int>>("AndonCallBLL_UpdateCallLog",
|
||
|
// model);
|
||
|
|
||
|
// if (result.IsSuccess)
|
||
|
// {
|
||
|
// //重新查询
|
||
|
// GetCallLogList(_factoryCode, _worklocCode);
|
||
|
// }
|
||
|
//}
|
||
|
}
|
||
|
|
||
|
private void butEnd_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
CallLogEntity model = _callLogList.FirstOrDefault(x => x.PID == _pid);
|
||
|
//MessageBox.Show(model.CALL_REASION);
|
||
|
//更新状态
|
||
|
if (model != null)
|
||
|
{
|
||
|
//处理完成
|
||
|
model.CALL_STATE = "3";
|
||
|
model.COMPLETE_TIME = DateTime.Now;
|
||
|
DataResult<int> result = _agent.InvokeServiceFunction<DataResult<int>>("AndonCallBLL_UpdateCallLog",
|
||
|
model);
|
||
|
|
||
|
//if (result.IsSuccess)
|
||
|
//{
|
||
|
//if (GetWorkcenterCode(model.WORKCENTER_CODE))
|
||
|
//{
|
||
|
// //关闭报警灯
|
||
|
// var dl = _agent.InvokeServiceFunction<bool>("AndonCallBLL_ADCloseLight", model.WORKCENTER_CODE);
|
||
|
//}
|
||
|
//重新查询
|
||
|
GetCallLogList(_factoryCode, comWorkLoc.SelectedValue.ToString());
|
||
|
//}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void timer1_Tick(object sender, EventArgs e)
|
||
|
{
|
||
|
//timer1.Enabled = false;
|
||
|
var item = _callLogList.FirstOrDefault(p=>p.PID==_pid);
|
||
|
if (item!=null)
|
||
|
{
|
||
|
TimeSpan span=new TimeSpan();
|
||
|
//计算等待时间
|
||
|
if (item.ANSWER_TIME.HasValue)
|
||
|
{
|
||
|
span = item.ANSWER_TIME.Value.Subtract(item.CALL_TIME);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
span = DateTime.Now.Subtract(item.CALL_TIME);
|
||
|
}
|
||
|
labWaitTime.Text = AndonEnum.labWaitTime + string.Format(span.Days > 0 ? "{0:d\\.hh\\:mm\\:ss}" : "{0:hh\\:mm\\:ss}", span);
|
||
|
|
||
|
//计算处理时间
|
||
|
if (item.ANSWER_TIME.HasValue)
|
||
|
{
|
||
|
if (item.COMPLETE_TIME.HasValue)
|
||
|
{
|
||
|
span = item.COMPLETE_TIME.Value.Subtract(item.ANSWER_TIME.Value);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
span = DateTime.Now.Subtract(item.ANSWER_TIME.Value);
|
||
|
}
|
||
|
labHandleTime.Text = AndonEnum.labHandleTime + string.Format(span.Days > 0 ? "{0:d\\.hh\\:mm\\:ss}" : "{0:hh\\:mm\\:ss}", span);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
labHandleTime.Text = AndonEnum.labHandleTime;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
//timer1.Enabled = true;
|
||
|
}
|
||
|
|
||
|
private void CallManageForm_FormClosed(object sender, FormClosedEventArgs e)
|
||
|
{
|
||
|
timer1.Enabled = false;
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 处理确认
|
||
|
/// </summary>
|
||
|
/// <param name="sender"></param>
|
||
|
/// <param name="e"></param>
|
||
|
private void button4_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
if (comboBox1.SelectedValue == null)
|
||
|
{
|
||
|
MessageBox.Show("请选择处理人.");
|
||
|
return;
|
||
|
}
|
||
|
CallLogEntity model = _callLogList.FirstOrDefault(x => x.PID == _pid);
|
||
|
//MessageBox.Show(model.CALL_REASION);
|
||
|
//更新状态
|
||
|
if (model != null)
|
||
|
{
|
||
|
//已应答--改为开始处理。20180523
|
||
|
model.HANDLER = comboBox1.SelectedValue.ToString();
|
||
|
model.CALL_PROBLEM = comboBox2.Text;
|
||
|
model.CALL_STATE = "2";
|
||
|
//应答时间
|
||
|
model.ANSWER_TIME = DateTime.Now;
|
||
|
//开始时间
|
||
|
model.START_TIME = DateTime.Now;
|
||
|
DataResult<int> result = _agent.InvokeServiceFunction<DataResult<int>>("AndonCallBLL_UpdateCallLog",
|
||
|
model);
|
||
|
|
||
|
//if (result.IsSuccess)
|
||
|
//{
|
||
|
//重新查询
|
||
|
GetCallLogList(_factoryCode, comWorkLoc.SelectedValue.ToString());
|
||
|
panelHandler.Visible = false;
|
||
|
|
||
|
//}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void button3_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
panelHandler.Visible = false;
|
||
|
}
|
||
|
|
||
|
private void DGView_SelectionChanged(object sender, EventArgs e)
|
||
|
{
|
||
|
if (DGView.SelectedRows.Count > 0)
|
||
|
{
|
||
|
_pid = DGView.SelectedRows[0].Cells["pid"].Value.ToString();
|
||
|
_callState = DGView.SelectedRows[0].Cells["callStates"].Value.ToString();
|
||
|
//_callLevel = (int)DGView.SelectedRows[0].Cells["callLEVEL"].Value;
|
||
|
_callReason = DGView.SelectedRows[0].Cells["callReason"].Value.ToString();
|
||
|
//_selectCallType = DGView.SelectedRows[0].Cells["CallType"].Value.ToString();
|
||
|
_selectCallTypeCode = DGView.SelectedRows[0].Cells["callTypeCode"].Value.ToString();
|
||
|
_callTime = DGView.SelectedRows[0].Cells["callTIME"].Value.ToString();
|
||
|
labCallReason.Text = AndonEnum.labCallReason + _callReason;
|
||
|
labCallTime.Text = AndonEnum.labCallTime + _callTime;
|
||
|
labAnswerTime.Text = AndonEnum.labAnswerTime + DGView.SelectedRows[0].Cells["answerTIME"].Value;
|
||
|
labHandleTime.Text = AndonEnum.labHandleTime;// +DGView.SelectedRows[0].Cells["startTime"].Value;
|
||
|
StateInit(_callState);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
PanelInit();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void butReturn_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
Form f = Application.OpenForms["OperationForm"]; //查找是否打开过Form1窗体
|
||
|
if (f == null) //没打开过
|
||
|
{
|
||
|
OperationForm form = new OperationForm();
|
||
|
//new KeyEvent().SetKeyToTxt(form);
|
||
|
//ClientContext.SetUserAuth(form);
|
||
|
form.MdiParent = this.MdiParent;
|
||
|
form.Show(); //重新new一个Show出来
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
f.WindowState = FormWindowState.Normal;
|
||
|
f.Focus(); //打开过就让其获得焦点
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void comWorkCenter_SelectedIndexChanged(object sender, EventArgs e)
|
||
|
{
|
||
|
comWorkLoc.DataSource = new List<WorkLoc>();
|
||
|
ddlMachine.DataSource = new List<MachineInfo>();
|
||
|
ddlMachine.Text = "";
|
||
|
|
||
|
if (comWorkCenter.SelectedValue != null)
|
||
|
{
|
||
|
//加载下拉列表
|
||
|
var workCenter = comWorkCenter.SelectedItem as WorkCenter;
|
||
|
string selectVC = workCenter.WORKCENTER_CODE;
|
||
|
BasicData basicData = new BasicData();
|
||
|
List<WorkLoc> locList = basicData.GetWorkLocComboxSource(selectVC);
|
||
|
locList.Insert(0, new WorkLoc() { WORKLOC_CODE = "", WORKLOC_NAME = "" });
|
||
|
comWorkLoc.DataSource = locList;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void comWorkLoc_SelectedIndexChanged(object sender, EventArgs e)
|
||
|
{
|
||
|
ddlMachine.DataSource = new List<MachineInfo>();
|
||
|
if (comWorkLoc.SelectedValue != null && string.IsNullOrEmpty(comWorkLoc.SelectedValue.ToString()) == false)
|
||
|
{
|
||
|
//加载下拉列表
|
||
|
var workLoc = comWorkLoc.SelectedItem as WorkLoc;
|
||
|
string selectLoc = workLoc.WORKLOC_CODE;
|
||
|
|
||
|
//获取设备信息
|
||
|
List<MachineInfo> machinelist =
|
||
|
_agent.InvokeServiceFunction<List<MachineInfo>>("MachineInfoBLL_GetAllList", new MachineInfo())
|
||
|
.ToList<MachineInfo>().Where(o => o.WORKLOC_CODE == selectLoc).ToList<MachineInfo>();
|
||
|
machinelist.Insert(0, new MachineInfo() { MACHINENAME = "", MACHINECODDE = "" });
|
||
|
ddlMachine.DataSource = machinelist;
|
||
|
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void chkINJECT_CheckedChanged(object sender, EventArgs e)
|
||
|
{
|
||
|
//panINJECT.Visible = chkINJECT.Checked;
|
||
|
}
|
||
|
|
||
|
private void label3_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
}
|