2025-03-27 15:05:14 +08:00

326 lines
15 KiB
C#

using System;
using System.Configuration;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
using SuperMap.RealEstate.CoreFrameWork;
using SuperMap.RealEstate.ServiceModel;
using SuperMap.RealEstate.Utility;
using SuperMap.RealEstate.Web.UI;
using SuperMap.RealEstate.Web.UI.WebControls;
using SuperMap.RealEstate.Web.Utility;
using SuperMap.RealEstate.ExchangeData.Business;
using Business = SuperMap.RealEstate.HighWay.Storage.Business;
namespace SuperMap.RealEstate.HighWay.Modules.ServerPartMachine
{
public partial class VersionCompare : BasePage
{
protected string _serverpart_id = ConfigurationManager.AppSettings["UmiformCommodity"].ToString().Split('|')[0];
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack) return;
BindingTreeView();
//StartDate.Text = DateTime.Now.ToShortDateString();
//EndDate.Text = DateTime.Now.ToShortDateString();
SERVERPART_ID.Clear();
SERVERPART_ID.Items.Add(new ListItemEx("全部", "1=1"));
SERVERPART_ID.SelectedValue = "1=1";
foreach (DataRow _DataRow in new Business.SERVERPART(Transaction).ExecuteDataTable(
"SELECT DISTINCT SERVERPART_ID,SERVERPART_INDEX,SERVERPARTCODE,SERVERPART_NAME FROM HIGHWAY_STORAGE.V_CONNECTPOINT" +
(string.IsNullOrEmpty(DataType.SelectedValue) || DataType.SelectedValue == "1=1" ? "" : " WHERE STATISTIC_TYPE = " +
DataType.SelectedValue) + " ORDER BY SERVERPART_INDEX,SERVERPARTCODE,SERVERPART_NAME").Rows)
{
ListItemEx _ListItemEx = new ListItemEx();
_ListItemEx.Text = _DataRow["SERVERPART_NAME"].ToString();
_ListItemEx.Value = _DataRow["SERVERPART_ID"].ToString();
_ListItemEx.Level = 1;
SERVERPART_ID.Items.Add(_ListItemEx);
}
Version_Num.Items.Clear();
Version_Num.Items.Add(new ListItemEx("全部", "1=1"));
foreach (DataRow _DataRow in new Business.SERVERPARTSHOP(Transaction).ExecuteDataTable(
@"SELECT DISTINCT SUBSTR(CONTENT,INSTR(CONTENT,'YSv'),LENGTH(CONTENT)) FROM HIGHWAY_STORAGE.V_CONNECTPOINT
WHERE CONTENT LIKE '%YSv%' ORDER BY SUBSTR(CONTENT,INSTR(CONTENT,'YSv'),LENGTH(CONTENT)) DESC").Rows)
{
ListItemEx _ListItemEx = new ListItemEx();
_ListItemEx.Level = 1;
_ListItemEx.Text = _DataRow[0].ToString();
_ListItemEx.Value = _DataRow[0].ToString();
Version_Num.Items.Add(_ListItemEx);
}
Version_Num.SelectedValue = "1=1";
//设置回车焦点按钮
SetControlClientAction(ButtonSearch);
//初始化并加载列表
//GridViewEx1.SelectingWithInit<Business.SERVERPARTSHOP>(ObjectDataSource1, GridPageEx1);
}
#region ->
protected void ButtonStatistics_Click(object sender, EventArgs e)
{
//查询数据
GridViewEx1.SelectingWithInit<Business.SERVERPARTSHOP>(ObjectDataSource1, GridPageEx1);
GridViewEx1.Visible = true;
HideClientMask("正在查询...");
}
#endregion
//查询
protected void ButtonSearch_CallBackClick(object sender, ClientSetEventArgs e)
{
GridViewEx1.Selecting<Business.SERVERPARTSHOP>(ObjectDataSource1, GridPageEx1);
//设置UI变化
e.SetValue(GridViewEx1);
e.SetValue(GridPageEx1);
}
//翻页事件
protected void GridPageEx1_CallBackPageChanged(object src, ClientSetEventArgs e)
{
GridViewEx1.Pagging<Business.SERVERPARTSHOP>(ObjectDataSource1, GridPageEx1);
//设置UI变化
e.SetValue(GridViewEx1);
}
//查询SQL设置
protected void GridViewEx1_SelectMethodParameters(object sender, SelectMethodParametersArgs e)
{
if (DataType.SelectedValue != "1=1" && !string.IsNullOrEmpty(DataType.SelectedValue))
{
e.AddAndParams("STATISTIC_TYPE", DataType.SelectedValue);
}
if (SERVERPART_ID.SelectedValue != "1=1" && !string.IsNullOrEmpty(SERVERPART_ID.SelectedValue))
{
e.AddAndParams("SERVERPART_ID", SERVERPART_ID.SelectedValue);
}
if (!string.IsNullOrEmpty(Version_Num.SelectedValue) && Version_Num.SelectedValue != "1=1")
{
e.SetOtherUserCustomWhereSqlString = "CONTENT" + (IsContain.SelectedValue == "1" ? "" : " NOT") +
" LIKE '%" + Version_Num.SelectedValue + "'";
}
if (!string.IsNullOrEmpty(StartDate.Text.Trim()))
{
e.SetOtherUserCustomWhereSqlString += (e.SetOtherUserCustomWhereSqlString == "" ? "" : " AND ") +
"CONNECT_DATE >= TO_DATE('" + StartDate.Text.Trim() + "','YYYY/MM/DD')";
}
if (!string.IsNullOrEmpty(EndDate.Text.Trim()))
{
e.SetOtherUserCustomWhereSqlString += (e.SetOtherUserCustomWhereSqlString == "" ? "" : " AND ") +
"CONNECT_DATE < TO_DATE('" + EndDate.Text.Trim() + "','YYYY/MM/DD') + 1";
}
if (!string.IsNullOrEmpty(GetVersion_Num()))
{
e.SetOtherUserCustomWhereSqlString += (e.SetOtherUserCustomWhereSqlString == "" ? "" : " AND ") +
"VERSION_NUM IN (" + GetVersion_Num() + ")";
}
//且搜索条件
//e.AddAndParams(字段名, 值);
//或搜索条件
//e.AddOrParams(字段名, 值);
//排序
e.AddOrderByParams("SERVERPART_INDEX,SERVERPARTCODE,SERVERPART_NAME,SHOPREGION,SHOPTRADE,SHOPCODE,SHOPNAME", false);
}
#region
protected void GridViewEx1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Business.COMMODITY _COMMODITY = new Business.COMMODITY(this.Transaction);
//服务区内码
string _SERVERPART_ID = GridViewEx1.DataKeys[e.Row.RowIndex].Values["SERVERPART_ID"].ToString();
string _SERVERPARTCODE = GridViewEx1.DataKeys[e.Row.RowIndex].Values["SERVERPARTCODE"].ToEncrypt();
string _SHOPCODE = GridViewEx1.DataKeys[e.Row.RowIndex].Values["SHOPCODE"].ToString();
string _MACHINECODE = GridViewEx1.DataKeys[e.Row.RowIndex].Values["MACHINECODE"].ToString();
string _PROVINCE_CODE = GridViewEx1.DataKeys[e.Row.RowIndex]["PROVINCE_CODE"].ToString();
string AllString = GridViewEx1.DataKeys[e.Row.RowIndex]["CONTENT"].ToString();
string CommCountSqlString = @"select count(1) from HIGHWAY_STORAGE.T_COMMODITY where EXISTS (
SELECT 1 FROM HIGHWAY_STORAGE.T_SERVERPARTSHOP WHERE SERVERPART_ID = " + _SERVERPART_ID +
" AND SHOPTRADE LIKE '%' || BUSINESSTYPE || '%' AND SHOPCODE = '" + _SHOPCODE +
"') AND SERVERPART_ID IN (" + _serverpart_id + "," + _SERVERPART_ID + ") AND PROVINCE_CODE = " +
_PROVINCE_CODE + " AND COMMODITY_STATE = 1 AND BUSINESSTYPE IS NOT NULL";
if (AllString.Contains("YSv"))
{
e.Row.Cells[1].Text = "YSv" + AllString.Split("YSv")[1];
}
try
{
if (new MACHINEPOINT(_COMMODITY).GetCount("WHERE SERVERPARTCODE = '" + _SERVERPARTCODE.ToDecrypt() +
"' AND SHOPCODE = '" + _SHOPCODE + "' AND MACHINENAME = '" + e.Row.Cells[7].Text + "'") > 0)
{
e.Row.Attributes["onclick"] = GridViewEx1.GetOpenPopDialogClientScript(
"MACHINEPOINTPage.aspx?SERVERPARTCODE=" + _SERVERPARTCODE + "&SHOPCODE=" +
_SHOPCODE.ToEncrypt() + "&MACHINENAME=" + e.Row.Cells[7].Text.ToEncrypt(), 1000, 600);
}
else
{
e.Row.Attributes["onclick"] = "";
}
}
catch
{
e.Row.Attributes["onclick"] = "";
}
DataTable _DataTable_PassComm = _COMMODITY.ExecuteDataTable(CommCountSqlString);
//审批通过商品数量
string PassCommCount = _DataTable_PassComm.Rows[0][0].ToString();
if (e.Row.Cells[6].Text != PassCommCount)
{
e.Row.Cells[6].ForeColor = System.Drawing.Color.IndianRed;
}
e.Row.Cells[6].Text = PassCommCount + "/" + e.Row.Cells[6].Text;
//状态
try
{
//回传时间
System.TimeSpan _TimeSpan_Back = System.DateTime.Now - DateTime.Parse(e.Row.Cells[5].Text);
if (_TimeSpan_Back.TotalMinutes > 10)
{
//5分钟无反馈数据 找不到日结 网络断开中。。橙色
//5分钟无反馈数据 具有日结,已经结账下班 灰色
//查询日结
e.Row.Cells[2].Text = "网络未连接";
e.Row.Cells[2].ForeColor = System.Drawing.Color.MediumVioletRed;
string EndAccountSql = "select count(*) from HIGHWAY_SELLDATA.T_ENDACCOUNT where SERVERPART_ID = '" +
_SERVERPART_ID + "' AND SHOPCODE = '" + _SHOPCODE + "' AND MACHINECODE='" + _MACHINECODE +
"' AND TO_DATE('" + e.Row.Cells[5].Text +
"','YYYY/MM/DD HH24:MI:SS') - ENDACCOUNT_DATE BETWEEN 0 AND 1/24";
if (int.Parse(_COMMODITY.ExecuteDataTable(EndAccountSql).Rows[0][0].ToString()) > 0)
{
e.Row.Cells[2].Text = "已经结账下班";
e.Row.Cells[2].ForeColor = System.Drawing.Color.DimGray;
try
{
if (DateTime.Parse(e.Row.Cells[5].Text) < DateTime.Now.Date)
{
e.Row.Cells[5].ForeColor = System.Drawing.Color.DimGray;
}
}
catch { }
}
}
else
{
//5分钟之内无客单 等待上班中。。绿色
//5分钟之内有客单 收银状态正常 蓝色
try
{
System.TimeSpan _TimeSpan_Bill = System.DateTime.Now - DateTime.Parse(AllString.Split('|')[1]);
if (_TimeSpan_Bill.TotalMinutes < 10)
{
//检测到客单
e.Row.Cells[2].Text = "收银状态正常";
e.Row.Cells[2].ForeColor = System.Drawing.Color.DeepSkyBlue;
}
else
{
//检测到客单
e.Row.Cells[2].Text = "收银状态正常";
e.Row.Cells[2].ForeColor = System.Drawing.Color.DeepSkyBlue;
}
}
catch
{
e.Row.Cells[2].Text = "收银状态正常";
e.Row.Cells[2].ForeColor = System.Drawing.Color.DeepSkyBlue;
}
}
//当前时间与最后订单
}
catch
{
e.Row.Cells[2].Text = "网络未连接";
e.Row.Cells[2].ForeColor = System.Drawing.Color.MediumVioletRed;
}
}
}
#endregion
private string FormatString(string str, int _Length = 10)
{
if (str.Length >= _Length)
{
return str.Substring(0, _Length) + "...";
}
return str;
}
protected void BindingTreeView()
{
MyTreeView.Nodes.Clear();
TreeNode _TreeNodeAll = new TreeNode();
_TreeNodeAll.NavigateUrl = "#";
_TreeNodeAll.Text = "所有版本";
_TreeNodeAll.Value = "1=1";
MyTreeView.Nodes.Add(_TreeNodeAll);
foreach (DataRow _DataRow in new Business.SERVERPARTSHOP(Transaction).ExecuteDataTable(
"SELECT DISTINCT VERSION_NUM FROM HIGHWAY_STORAGE.V_CONNECTPOINT WHERE VERSION_NUM IS NOT NULL ORDER BY VERSION_NUM DESC").Rows)
{
TreeNode _TreeNode = new TreeNode();
_TreeNode.NavigateUrl = "#";
_TreeNode.Text = _DataRow[0].ToString();
_TreeNode.Value = _DataRow[0].ToString();
_TreeNodeAll.ChildNodes.Add(_TreeNode);
}
MyTreeView.ExpandAll();
}
protected void MyTreeView_TreeNodeCheckChanged(object sender, TreeNodeEventArgs e)
{
treeView_Checked(e.Node.ChildNodes, e.Node.Checked);
}
private void treeView_Checked(TreeNodeCollection nodes, bool Checked)
{
foreach (TreeNode treeNode in nodes)
{
treeNode.Checked = Checked;
treeView_Checked(treeNode.ChildNodes, Checked);
}
}
#region ->
private string GetVersion_Num()
{
string OutTypeString = "";
//if (MyTreeView.Nodes[0].Checked)
// return "";
foreach (TreeNode _FormatTreeNode in MyTreeView.Nodes[0].ChildNodes)
{
if (_FormatTreeNode.Checked)
{
OutTypeString += OutTypeString == "" ? "'" + _FormatTreeNode.Value + "'" : ",'" + _FormatTreeNode.Value + "'";
}
}
return OutTypeString;
}
#endregion
protected void DataType_CallBackSetControl(object sender, ClientSetEventArgs e)
{
SERVERPART_ID.Clear();
SERVERPART_ID.Items.Add(new ListItemEx("全部", "1=1"));
SERVERPART_ID.SelectedValue = "1=1";
foreach (Business.SERVERPART _SERVERPART in new Business.SERVERPART(Transaction).FillCollection(
"WHERE SERVERPART_ID IN (SELECT SERVERPART_ID FROM HIGHWAY_STORAGE.V_CONNECTPOINT) " +
(string.IsNullOrEmpty(DataType.SelectedValue) || DataType.SelectedValue == "1=1" ? "" : " AND STATISTIC_TYPE = " +
DataType.SelectedValue) + "ORDER BY SERVERPART_INDEX,SERVERPART_CODE,SERVERPART_NAME"))
{
ListItemEx _ListItemEx = new ListItemEx();
_ListItemEx.Text = _SERVERPART.SERVERPART_NAME;
_ListItemEx.Value = _SERVERPART.SERVERPART_ID.ToString();
_ListItemEx.Level = 1;
SERVERPART_ID.Items.Add(_ListItemEx);
}
e.SetDropDownListEx(SERVERPART_ID);
}
}
}