📄 querydb.cs
字号:
// {
// m_fEntryWeightErrorEnd=float.Parse("-9.98");
// }
// else
// {
// m_fEntryWeightErrorEnd=fEntryWeightErrorEnd;
// }
m_fEntryWeightErrorEnd=fEntryWeightErrorEnd;
return true;
}
//舱单误差起始点
public float GetBillWeightErrorStart()
{
return m_fBillWeightErrorStart;
}
public bool SetBillWeightErrorStart(float fBillWeightErrorStart)
{
// if(fBillWeightErrorStart==float.Parse("-9.99"))
// {
// m_fBillWeightErrorStart=float.Parse("-9.98");
// }
// else
// {
// m_fBillWeightErrorStart=fBillWeightErrorStart;
// }
m_fBillWeightErrorStart=fBillWeightErrorStart;
return true;
}
//舱单误差结束点
public float GetBillWeightErrorEnd()
{
return m_fBillWeightErrorEnd;
}
public bool SetBillWeightErrorEnd(float fBillWeightErrorEnd)
{
// if(fBillWeightErrorEnd==float.Parse("-9.99"))
// {
// m_fBillWeightErrorEnd=float.Parse("-9.98");
// }
// else
// {
// m_fBillWeightErrorEnd=fBillWeightErrorEnd;
// }
m_fBillWeightErrorEnd=fBillWeightErrorEnd;
return true;
}
public void InitVar()
{
m_nGateCrossState=-1;
m_strGoodsBillRalation="";
m_strShipName="";
m_strVoyageNo="";
m_strBillNo="";
m_strContaNo="";
m_strEntryID="";
m_strVehi_No="";
m_nPlaceID=-1;
m_nUserID=-1;
m_nCheckType=-1;
m_nCheckFlag=-1;
m_strGoodsType="";
m_strQueryCondition="";
m_strCarryContaBegintime="";//提箱起始时间
m_strCarryContaEndtime="";//提箱结束时间
m_fEntryWeightErrorStart=float.Parse("-9.19");//报关误差起始点
m_fEntryWeightErrorEnd=float.Parse("-9.19");//报关误差结束点
m_fBillWeightErrorStart=float.Parse("-9.19");//舱单误差起始点
m_fBillWeightErrorEnd=float.Parse("-9.19");//舱单误差结束点
m_strOutEntryID="";
m_nEntryType=2;
// m_strQueryConditionEntry=new StringBuilder(1048);
// m_strQueryConditionTurnEntry=new StringBuilder(1048);
// m_strQueryConditionBoth=new StringBuilder(2048);
// m_strTurnEntryCrossGateSQL=new StringBuilder(1048);
// m_strTurnEntryUnCrossGateSQL=new StringBuilder(1048);
// m_strTurnEntryBothSQL=new StringBuilder(1048);
// entry;
m_strEntryComm.Append(" from sMANIFEST_Conta_REL as a ");
m_strEntryComm.Append(" inner join sENTRY_HEAD as c ");
m_strEntryComm.Append(" on a.VOYAGE_NO=c.VOYAGE_NO and a.BILL_NO=c.BILL_NO and a.Ship_Name_En=c.TRAF_Name ");
m_strEntryComm.Append(" left join mBarConta as d ");
m_strEntryComm.Append(" on a.VOYAGE_NO=d.VoyAge_No and a.SHIP_Name_En=d.SHIP_Name_En and a.Bill_No=d.Bill_No and a.CONTA_ID=d.ContaNo ");
m_strEntryComm.Append(" left join mBarWeight as e ");
m_strEntryComm.Append(" on d.ConnectID=e.ConnectID ");
m_strEntryComm.Append(" left join mCheckInfo as f ");
m_strEntryComm.Append(" on d.ConnectID=f.ConnectID and f.placeid between 100 and 200 ");
m_strEntryComm.Append(" left join mContaBillRetaType as g ");
m_strEntryComm.Append(" on d.ContaBillRelaID=g.ContaBillRelaID ");
m_strEntryComm.Append(" left join mPerFetchEntry as h ");
m_strEntryComm.Append(" on h.VOYAGE_NO=a.VoyAge_No and a.Ship_Id=h.Ship_Id and h.Bill_No=a.Bill_No ");
m_strEntryComm.Append(" left join mGoodsType as i ");
m_strEntryComm.Append(" on i.GoodsType=h.GoodsType ");
m_strEntryComm.Append(" left join mPlaceName as j ");
m_strEntryComm.Append(" on j.PlaceId=f.PlaceId ");
//turn entry
m_strTurnEntryComm.Remove(0,m_strTurnEntryComm.Length);
m_strTurnEntryComm.Append(" from sMANIFEST_Conta_REL as a ");
m_strTurnEntryComm.Append(" inner join sIM_TRANS_LIST_REL as n ");
m_strTurnEntryComm.Append(" on a.Bill_No=n.Bill_No and a.Voyage_No=n.Voyage_No and a.Ship_Name_En=n.Ship_Name_En ");
m_strTurnEntryComm.Append(" inner join sIM_DECL_CUR_HEAD as b ");
m_strTurnEntryComm.Append(" on n.PRE_NO=b.PRE_NO ");
m_strTurnEntryComm.Append(" left join mBarConta as d ");
m_strTurnEntryComm.Append(" on a.VOYAGE_NO=d.VoyAge_No and a.Ship_Name_En=d.Ship_Name_En and a.Bill_No=d.Bill_No and a.Conta_id=d.ContaNo ");
m_strTurnEntryComm.Append(" left join mBarWeight as e ");
m_strTurnEntryComm.Append(" on d.ConnectID=e.ConnectID ");
m_strTurnEntryComm.Append(" left join mCheckInfo as f ");
m_strTurnEntryComm.Append(" on f.ConnectID=d.ConnectID and f.placeid between 100 and 200 ");
m_strTurnEntryComm.Append(" left join mContaBillRetaType as g ");
m_strTurnEntryComm.Append(" on d.ContaBillRelaID=g.ContaBillRelaID ");
m_strTurnEntryComm.Append(" left join mPerFetchEntry as h ");
m_strTurnEntryComm.Append(" on h.VOYAGE_NO=d.VoyAge_No and a.Ship_Id=h.Ship_Id and h.Bill_No=d.Bill_No ");
m_strTurnEntryComm.Append(" left join mGoodsType as i ");
m_strTurnEntryComm.Append(" on i.GoodsType=h.GoodsType ");
m_strTurnEntryComm.Append(" left join mPlaceName as j ");
m_strTurnEntryComm.Append(" on j.PlaceId=f.PlaceId " );
m_iOptionCondition=0;
}
public void GetMainQueryCondtion(int m_nGateCrossState)
{
m_strQueryConditionEntry.Remove(0,m_strQueryConditionEntry.Length);
m_strQueryConditionTurnEntry.Remove(0,m_strQueryConditionTurnEntry.Length);
if(m_nGateCrossState==0)
{
m_strQueryConditionEntry.Append(" Select distinct a.CONTA_ID as Conta_No,e.Vehi_No,e.D_WT,e.VehiCurWeight, e.CurrGoodsNetWT,e.GoodsTotalWT, ");
m_strQueryConditionEntry.Append(" d.CurEmptyWT,avg(a.Conta_WT) as Conta_WT,str(100*d.Entry_Error)+'%' as Entry_Error,str(100*d.MftError)+'%' as MftError ");
m_strQueryConditionEntry.Append(" ,min(h.PER_TIME) as Per_time,f.ArriveTime,j.PlaceName,GoodsTypeName ,ContaBillRelaName ,d.connectid ");
m_strQueryConditionEntry.Append(m_strEntryComm.ToString());
//限制为过卡口
m_strQueryConditionEntry.Append(" where exists ( select a.CONTA_ID,a.SHIP_Name_En,a.Voyage_No,a.Bill_No from mBarConta where a.CONTA_ID=mBarConta.ContaNo and a.Ship_Name_En=mBarConta.Ship_Name_En and a.Bill_No=mBarConta.BILL_NO and a.Voyage_No=mBarConta.Voyage_No ) ");
m_strQueryConditionTurnEntry.Append(" select distinct a.CONTA_ID as Conta_No ,e.Vehi_No,e.D_WT,e.VehiCurWeight,e.CurrGoodsNetWT,e.GoodsTotalWT,d.CurEmptyWT, ");
m_strQueryConditionTurnEntry.Append(" avg(a.Conta_WT) as Conta_WT ,str(100*d.Entry_Error)+'%' as Entry_Error,str(100*d.MftError)+'%' as MftError,min(h.PER_TIME) as Per_time ,f.ArriveTime , ");
m_strQueryConditionTurnEntry.Append("j.PlaceName,i.GoodsTypeName ,g.ContaBillRelaName ,d.connectid ");
m_strQueryConditionTurnEntry.Append(m_strTurnEntryComm.ToString());
m_strQueryConditionTurnEntry.Append(" where exists ( select a.CONTA_ID,a.SHIP_Name_En,a.Voyage_No,a.Bill_No from mBarConta where a.CONTA_ID=mBarConta.ContaNo and a.Ship_Name_En=mBarConta.Ship_Name_En and a.Bill_No=mBarConta.BILL_NO and a.Voyage_No=mBarConta.Voyage_No ) ");
m_iOptionCondition=1;
}
else if(m_nGateCrossState==1)
{
//entry
m_strQueryConditionEntry.Append(" Select distinct c.Entry_ID,a.Ship_Name_En,a.Voyage_No,a.BILL_NO,a.CONTA_ID as Conta_No, h.PER_TIME, h.GoodsType ");
m_strQueryConditionEntry.Append(" from sMANIFEST_Conta_REL as a ");
m_strQueryConditionEntry.Append(" inner join sENTRY_HEAD as c on a.VOYAGE_NO=c.VOYAGE_NO and a.BILL_NO=c.BILL_NO and a.Ship_Name_En=c.TRAF_Name ");
m_strQueryConditionEntry.Append(" left join mPerFetchEntry as h on h.VOYAGE_NO=a.VoyAge_No and a.Ship_Id=h.Ship_Id and h.Bill_No=a.Bill_No ");
//限制为不过卡口
m_strQueryConditionEntry.Append(" where not exists ( select a.CONTA_ID,a.SHIP_Name_En,a.Voyage_No,a.Bill_No from mBarConta where a.CONTA_ID=mBarConta.ContaNo and a.Ship_Name_En=mBarConta.Ship_Name_En and a.Bill_No=mBarConta.BILL_NO and a.Voyage_No=mBarConta.Voyage_No ) ");
//turn entry
m_strQueryConditionTurnEntry.Append(" select distinct b.TURN_NO as Entry_ID,a.Ship_Name_En,a.Voyage_No ,a.BILL_NO,a.CONTA_ID as Conta_No,h.PER_TIME,h.GoodsType ");
m_strQueryConditionTurnEntry.Append(" from sMANIFEST_Conta_REL as a ");
m_strQueryConditionTurnEntry.Append(" inner join sIM_TRANS_LIST_REL as n ");
m_strQueryConditionTurnEntry.Append(" on a.Bill_No=n.Bill_No and a.Voyage_No=n.Voyage_No and a.Ship_Name_En=n.Ship_Name_En ");
m_strQueryConditionTurnEntry.Append(" inner join sIM_DECL_CUR_HEAD as b ");
m_strQueryConditionTurnEntry.Append(" on n.PRE_NO=b.PRE_NO ");
m_strQueryConditionTurnEntry.Append(" left join mPerFetchEntry as h on h.VOYAGE_NO=a.VoyAge_No and a.Ship_Id=h.Ship_Id and h.Bill_No=a.Bill_No ");
//限制为不过卡口
m_strQueryConditionTurnEntry.Append(" where not exists ( select a.CONTA_ID,a.SHIP_Name_En,a.Voyage_No,a.Bill_No from mBarConta where a.CONTA_ID=mBarConta.ContaNo and a.Ship_Name_En=mBarConta.Ship_Name_En and a.Bill_No=mBarConta.BILL_NO and a.Voyage_No=mBarConta.Voyage_No ) ");
m_iOptionCondition=1;
}
else if(m_nGateCrossState==2)
{
m_strQueryConditionEntry.Append(" Select distinct c.Entry_ID,a.Ship_Name_En,a.Voyage_No,a.BILL_NO,a.CONTA_ID as Conta_No,e.Vehi_No, GoodsTypeName ");
m_strQueryConditionEntry.Append(" ,min(f.ArriveTime) as ArriveTime ,min(h.PER_TIME) as PER_TIME,j.PlaceName,ContaBillRelaName ");
m_strQueryConditionEntry.Append(m_strEntryComm.ToString());
m_strQueryConditionTurnEntry.Append(" select distinct b.TURN_NO as Entry_ID,a.Ship_Name_En,a.Voyage_No ,a.BILL_NO,a.CONTA_ID as Conta_No,e.Vehi_No,i.GoodsTypeName ");
m_strQueryConditionTurnEntry.Append(" ,min(f.ArriveTime) as ArriveTime ,min(h.PER_TIME) as PER_TIME,j.PlaceName,g.ContaBillRelaName ");
m_strQueryConditionTurnEntry.Append(m_strTurnEntryComm.ToString());
m_iOptionCondition=0;
}
}
public string GetQueryCondition()
{
System.DateTime myDateTime1,myDateTime2;
GetMainQueryCondtion(m_nGateCrossState);
string str;
if(m_strOutEntryID=="")
{
switch(m_nGateCrossState)
{
case 0:
m_iOptionCondition=1;
str=GetQueryPara(" e.Vehi_No " ," = ",m_strVehi_No);//车牌号
m_strQueryConditionEntry.Append(str);
str=GetQueryPara(" f.PlaceId " ," = ",m_nPlaceID); //卡口
m_strQueryConditionEntry.Append(str);
myDateTime1=System.DateTime.Parse(m_strBeginTime);
str=GetQueryPara(" f.ArriveTime " ," >= ",m_strBeginTime) ;
m_strQueryConditionEntry.Append(str);
str=GetQueryPara(" f.ArriveTime " ," <= ",m_strEndTime);
m_strQueryConditionEntry.Append(str);
str=GetQueryPara(" h.PER_TIME " ," >= ",m_strCarryContaBegintime);//提箱时间
m_strQueryConditionEntry.Append(str);
str=GetQueryPara(" h.PER_TIME " ," <= ",m_strCarryContaEndtime);
m_strQueryConditionEntry.Append(str);
str=GetQueryPara(" d.Entry_Error" ," >= ",m_fEntryWeightErrorStart);//报关误差
m_strQueryConditionEntry.Append(str);
str=GetQueryPara(" d.Entry_Error" ," <= ",m_fEntryWeightErrorEnd);
m_strQueryConditionEntry.Append(str);
str=GetQueryPara(" d.mftError" ," >= ",m_fBillWeightErrorStart);//舱单误差
m_strQueryConditionEntry.Append(str);
// str=GetQueryPara(" f.UserID" ," = ",m_nUserID);//检查人员 暂时不用
// m_strQueryConditionEntry.Append(str);
str=GetQueryPara(" d.mftError" ," <= ",m_fBillWeightErrorEnd);
m_strQueryConditionEntry.Append(str);
if(m_nCheckType!=-1) //检查方式
{
str=GetQueryPara(" f.PlaceID " ," >= ",m_nCheckType);
m_strQueryConditionEntry.Append(str);
str=GetQueryPara(" f.PlaceID " ," <= ",m_nCheckType+100);
m_strQueryConditionEntry.Append(str);
}
str=GetQueryPara(" i.GoodsTypeName " ," = ",m_strGoodsType);//货物类型
m_strQueryConditionEntry.Append(str);
//m_strQueryCondition+=GetQueryPara(" e.CurCheckFlag " ," = ",m_nCheckFlag);//放行方式
str=GetQueryPara(" f.CurCheckFlag " ," = ",m_nCheckFlag);//放行方式
m_strQueryConditionEntry.Append(str);
str=GetQueryPara(" g.ContaBillRelaName " ," = ",m_strGoodsBillRalation);//货单关系
m_strQueryConditionEntry.Append(str);
break;
case 1:
m_iOptionCondition=1;
break;
case 2:
m_iOptionCondition=0;
break;
}
str=GetQueryPara(" a.CONTA_ID " ," = ",m_strContaNo);
m_strQueryConditionEntry.Append(str);
str=GetQueryPara(" a.Ship_Name_En " ," = ",m_strShipName);
m_strQueryConditionEntry.Append(str);
str=GetQueryPara(" a.Voyage_No " ," = ",m_strVoyageNo);
m_strQueryConditionEntry.Append(str);
str=GetQueryPara(" a.Bill_No " ," = ",m_strBillNo);
m_strQueryConditionEntry.Append(str);
str=GetQueryPara(" c.Entry_ID " ," = ",m_strEntryID);
m_strQueryConditionEntry.Append(str);
if(m_nGateCrossState==0)
{
m_strQueryConditionEntry.Append(" group by a.conta_id,e.vehi_no,e.d_wt,e.vehicurweight,e.currgoodsnetwt,e.goodstotalwt,d.curemptywt,entry_error,mfterror,f.ArriveTime,j.PlaceName,GoodsTypeName ,ContaBillRelaName ,d.connectid ");
}
else if(m_nGateCrossState==2)
{
m_strQueryConditionEntry.Append(" group by c.Entry_ID,a.Ship_Name_En,a.Voyage_No,a.BILL_NO,a.CONTA_ID ,e.Vehi_No, GoodsTypeName ,j.PlaceName,ContaBillRelaName ");
}
m_strQueryConditionBoth.Remove(0,m_strQueryConditionBoth.Length);
m_strQueryConditionBoth.Append(m_strQueryConditionEntry.ToString());
}
//转关
if(m_strEntryID=="")
{
m_iOptionCondition=0;
switch(m_nGateCrossState)
{
case 0:
m_iOptionCondition=1;
str=GetQueryPara(" e.Vehi_No " ," = ",m_strVehi_No);//车牌号
m_strQueryConditionTurnEntry.Append(str);
str=GetQueryPara(" f.PlaceId " ," = ",m_nPlaceID); //卡口
m_strQueryConditionTurnEntry.Append(str);
str=GetQueryPara(" f.ArriveTime " ," >= ",m_strBeginTime);//到达卡口时间
m_strQueryConditionTurnEntry.Append(str);
str=GetQueryPara(" f.ArriveTime " ," <= ",m_strEndTime);
m_strQueryConditionTurnEntry.Append(str);
str=GetQueryPara(" h.PER_TIME " ," >= ",m_strCarryContaBegintime);//提箱时间
m_strQueryConditionTurnEntry.Append(str);
str=GetQueryPara(" h.PER_TIME " ," <= ",m_strCarryContaEndtime);
m_strQueryConditionTurnEntry.Append(str);
str=GetQueryPara(" d.Entry_Error" ," >= ",m_fEntryWeightErrorStart);//报关误差
m_strQueryConditionTurnEntry.Append(str);
str=GetQueryPara(" d.Entry_Error" ," <= ",m_fEntryWeightErrorEnd);
m_strQueryConditionTurnEntry.Append(str);
str=GetQueryPara(" d.mftError" ," >= ",m_fBillWeightErrorStart);//舱单误差
m_strQueryConditionTurnEntry.Append(str);
str=GetQueryPara(" d.mftError" ," <= ",m_fBillWeightErrorEnd);
m_strQueryConditionTurnEntry.Append(str);
if(m_nCheckType!=-1) //检查方式
{
str=GetQueryPara(" f.PlaceID " ," >= ",m_nCheckType);
m_strQueryConditionTurnEntry.Append(str);
str=GetQueryPara("f.PlaceID " ," <= ",m_nCheckType+100);
m_strQueryConditionTurnEntry.Append(str);
}
str=GetQueryPara(" i.GoodsTypeName " ," = ",m_strGoodsType);//货物类型
m_strQueryConditionTurnEntry.Append(str);
//m_strQueryCondition+=GetQueryPara(" e.CurCheckFlag " ," = ",m_nCheckFlag);//放行方式
str=GetQueryPara(" f.CurCheckFlag " ," = ",m_nCheckFlag);//放行方式
m_strQueryConditionTurnEntry.Append(str);
str=GetQueryPara(" g.ContaBillRelaName " ," = ",m_strGoodsBillRalation);//货单关系
m_strQueryConditionTurnEntry.Append(str);
break;
case 1:
m_iOptionCondition=1;
break;
case 2:
m_iOptionCondition=0;
break;
default:
break;
}
str=GetQueryPara(" a.CONTA_ID " ," = ",m_strContaNo);//箱号
m_strQueryConditionTurnEntry.Append(str);
str=GetQueryPara(" a.Ship_Name_En " ," = ",m_strShipName);
m_strQueryConditionTurnEntry.Append(str);
str=GetQueryPara(" a.Voyage_No " ," = ",m_strVoyageNo);
m_strQueryConditionTurnEntry.Append(str);
str=GetQueryPara(" a.Bill_No " ," = ",m_strBillNo);
m_strQueryConditionTurnEntry.Append(str);
str=GetQueryPara(" b.Turn_No " ," = ",m_strOutEntryID);
m_strQueryConditionTurnEntry.Append(str);
if(m_nGateCrossState==0)
{
m_strQueryConditionTurnEntry.Append(" group by a.conta_id,e.vehi_no,e.d_wt,e.vehicurweight,e.currgoodsnetwt,e.goodstotalwt,d.curemptywt,entry_error,mfterror,f.ArriveTime,j.PlaceName,GoodsTypeName ,ContaBillRelaName ,d.connectid ");
}
else if(m_nGateCrossState==2)
{
m_strQueryConditionTurnEntry.Append(" group by b.TURN_NO ,a.Ship_Name_En,a.Voyage_No ,a.BILL_NO,a.CONTA_ID ,e.Vehi_No,i.GoodsTypeName,j.PlaceName,g.ContaBillRelaName ");
}
m_strQueryConditionBoth.Remove(0,m_strQueryConditionBoth.Length);
m_strQueryConditionBoth.Append(m_strQueryConditionTurnEntry.ToString());
}
if((m_strOutEntryID=="") && (m_strEntryID=="") )
{
m_strQueryConditionBoth.Remove(0,m_strQueryConditionBoth.Length);
m_strQueryConditionBoth.Append(m_strQueryConditionEntry.ToString());
m_strQueryConditionBoth.Append(" union ");
m_strQueryConditionBoth.Append(m_strQueryConditionTurnEntry.ToString());
}
if(m_nGateCrossState==0)
{
//排序
m_strQueryConditionBoth.Append(" order by f.ArriveTime, a.Conta_ID ");
}
else if(m_nGateCrossState==1)
{
//排序
m_strQueryConditionBoth.Append(" order by a.bill_no,h.PER_TIME, a.Conta_ID ");
}
else if(m_nGateCrossState==2)
{
//排序
m_strQueryConditionBoth.Append(" order by a.bill_no,f.ArriveTime, a.Conta_ID ");
}
for(int i=0;i<m_strQueryConditionBoth.Length;i++)
{
if(m_strQueryConditionBoth[i]=='\t' )
{
m_strQueryConditionBoth[i]=' ';
}
}
m_strQueryCondition=m_strQueryConditionBoth.ToString();
return m_strQueryCondition;
}
public string GetQueryPara(string strLeft ,string strOperator ,string strRight)
{
string strQueryPara="";
string a,b;
a=(" where " +strLeft +strOperator) + " '" +strRight +"' ";
b=(" and " +strLeft +strOperator ) + " '" +strRight +"' ";
if(m_nGateCrossState!=1)
{
if(m_iOptionCondition==0)
{
if(strRight!="")
{
strQueryPara=a;
m_iOptionCondition++;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -