strSql.Append(@"SELECT A.OUTID AS STUPHONE,A.CUSTOMERID AS YKTNO,round(A.OPFARE/100,2) AS MONEY,round(A.ODDFARE/100,2) AS BALANCE,A.OPDT AS HAPPENTIME,A.DSCRP AS SUBJECT,B.TERMNAME,C.StuNo,C.StuName,d.DeptName,e.ClassName,c.identityno as IdentityCardNo, f.MajorName,c.GenderNo
strSql.Append(@"select * from (
SELECT A.OUTID AS STUPHONE,A.CUSTOMERID AS YKTNO,round(A.OPFARE/100,2) AS MONEY,round(A.ODDFARE/100,2) AS BALANCE,A.OPDT AS HAPPENTIME,A.DSCRP AS SUBJECT,B.TERMNAME,C.StuNo,C.StuName,d.DeptNo,d.DeptName,e.ClassNo,e.ClassName,c.identityno as IdentityCardNo, f.MajorName,c.GenderNo
FROM M_REC_CONSUME@ykt A LEFT JOIN M_BASE_TERM@ykt B ON A.TERMID = B.TERMID
left join ds_stuinfo C on A.OUTID = C.mobile
left join ds_dept d on c.deptno = d.deptno
left join ds_classinfo e on c.classno = e.classno
left join ds_major f on c.majorno=f.majorno
where 1=1 and stuno is not null ");
where stuno is not null
union all
SELECT A.OUTID AS STUPHONE,A.CUSTOMERID AS YKTNO,round(A.OPFARE/100,2) AS MONEY,round(A.ODDFARE/100,2) AS BALANCE,A.OPDT AS HAPPENTIME,A.DSCRP AS SUBJECT,B.TERMNAME,C.StuNo,C.StuName,d.DeptNo,d.DeptName,e.ClassNo,e.ClassName,c.identityno as IdentityCardNo, f.MajorName,c.GenderNo
FROM M_REC_CONSUME@ykt A LEFT JOIN M_BASE_TERM@ykt B ON A.TERMID = B.TERMID
left join ds_stuinfo C on A.OUTID = C.stuno
left join ds_dept d on c.deptno = d.deptno
left join ds_classinfo e on c.classno = e.classno
left join ds_major f on c.majorno=f.majorno
where stuno is not null ) aa where 1=1");
if (!queryParam["StuNo"].IsEmpty())
{
strSql.Append($" AND C.StuNo like '%{queryParam["StuNo"].ToString()}%' ");
strSql.Append($" AND StuNo like '%{queryParam["StuNo"].ToString()}%' ");
}
if (!queryParam["StuName"].IsEmpty())
{
strSql.Append($" AND C.StuName like '%{queryParam["StuName"].ToString()}%' ");
strSql.Append($" AND StuName like '%{queryParam["StuName"].ToString()}%' ");
}
if (!queryParam["DeptNo"].IsEmpty())
{
strSql.Append($" AND C.DeptNo='{queryParam["DeptNo"].ToString()}' ");
strSql.Append($" AND DeptNo='{queryParam["DeptNo"].ToString()}' ");
}
if (!queryParam["ClassNo"].IsEmpty())
{
strSql.Append($" AND C.ClassNo ='{queryParam["ClassNo"].ToString()}' ");
strSql.Append($" AND ClassNo ='{queryParam["ClassNo"].ToString()}' ");
}
if (!queryParam["YKTNO"].IsEmpty())
{
strSql.Append($" AND a.CUSTOMERID like '%{queryParam["CUSTOMERID"].ToString()}%' ");
strSql.Append($" AND YKTNO like '%{queryParam["YKTNO"].ToString()}%' ");
}
if (!queryParam["StartDate"].IsEmpty() && !queryParam["EndDate"].IsEmpty())
{
strSql.Append(" and (A.OPDT>=to_date('" + queryParam["StartDate"] + "','yyyy-mm-dd hh24:mi:ss') and A.OPDT<=to_date('" + queryParam["EndDate"] + "','yyyy-mm-dd hh24:mi:ss'))");
strSql.Append(" and (HAPPENTIME>=to_date('" + queryParam["StartDate"] + "','yyyy-mm-dd hh24:mi:ss') and HAPPENTIME<=to_date('" + queryParam["EndDate"] + "','yyyy-mm-dd hh24:mi:ss'))");
@"SELECT C.StuNo,C.StuName,c.GenderNo,d.DeptName,f.MajorName,e.ClassName,c.identityno as IdentityCardNo, sum(round(A.OPFARE/100,2)) AS MONEY,count(stuno) as PayTimes,round(sum(round(A.OPFARE/100,2))/count(stuno),2) as PerMoney
@"select StuNo,StuName,GenderNo,DeptName,MajorName,ClassName,identityno as IdentityCardNo, sum(round(OPFARE/100,2)) AS MONEY,count(stuno) as PayTimes,round(sum(round(OPFARE/100,2))/count(stuno),2) as PerMoney
strSql.Append(@"SELECT A.OUTID AS STUPHONE,A.CUSTOMERID AS YKTNO,round(A.OPFARE/100,2) AS MONEY,round(A.ODDFARE/100,2) AS BALANCE,A.OPDT AS HAPPENTIME,A.DSCRP AS SUBJECT,
B.TERMNAME,c.EmpNo,c.EmpName,d.Name as DepartmentName,c.identityno as IdentityCardNo,c.GenderNo
strSql.Append(@"select * from (SELECT A.OUTID AS STUPHONE,A.CUSTOMERID AS YKTNO,round(A.OPFARE/100,2) AS MONEY,round(A.ODDFARE/100,2) AS BALANCE,A.OPDT AS HAPPENTIME,A.DSCRP AS SUBJECT,
B.TERMNAME,c.EmpNo,c.EmpName,c.DepartmentId,d.Name as DepartmentName,c.identityno as IdentityCardNo,c.GenderNo
FROM M_REC_CONSUME@ykt A LEFT JOIN M_BASE_TERM@ykt B ON A.TERMID = B.TERMID
left join ds_empinfo C on A.OUTID = C.mobile
left join ds_department d on c.departmentid=d.id
where 1=1 and EmpNo is not null");
where EmpNo is not null
union all
SELECT A.OUTID AS STUPHONE,A.CUSTOMERID AS YKTNO,round(A.OPFARE/100,2) AS MONEY,round(A.ODDFARE/100,2) AS BALANCE,A.OPDT AS HAPPENTIME,A.DSCRP AS SUBJECT,
B.TERMNAME,c.EmpNo,c.EmpName,c.DepartmentId,d.Name as DepartmentName,c.identityno as IdentityCardNo,c.GenderNo
FROM M_REC_CONSUME@ykt A LEFT JOIN M_BASE_TERM@ykt B ON A.TERMID = B.TERMID
left join ds_empinfo C on A.OUTID = C.empno
left join ds_department d on c.departmentid=d.id
where EmpNo is not null ) aa where 1=1");
if (!queryParam["EmpNo"].IsEmpty())
{
strSql.Append($" AND C.EmpNo like '%{queryParam["EmpNo"].ToString()}%' ");
strSql.Append($" AND EmpNo like '%{queryParam["EmpNo"].ToString()}%' ");
}
if (!queryParam["EmpName"].IsEmpty())
{
strSql.Append($" AND C.EmpName like '%{queryParam["EmpName"].ToString()}%' ");
strSql.Append($" AND EmpName like '%{queryParam["EmpName"].ToString()}%' ");
}
if (!queryParam["DepartmentId"].IsEmpty())
{
strSql.Append($" AND C.DepartmentId='{queryParam["DepartmentId"].ToString()}' ");
strSql.Append($" AND DepartmentId='{queryParam["DepartmentId"].ToString()}' ");
}
if (!queryParam["YKTNO"].IsEmpty())
{
strSql.Append($" AND a.CUSTOMERID like '%{queryParam["CUSTOMERID"].ToString()}%' ");
strSql.Append($" AND YKTNO like '%{queryParam["YKTNO"].ToString()}%' ");
}
if (!queryParam["StartDate"].IsEmpty() && !queryParam["EndDate"].IsEmpty())
{
strSql.Append(" and (A.OPDT>=to_date('" + queryParam["StartDate"] + "','yyyy-mm-dd hh24:mi:ss') and A.OPDT<=to_date('" + queryParam["EndDate"] + "','yyyy-mm-dd hh24:mi:ss'))");
strSql.Append(" and (HAPPENTIME>=to_date('" + queryParam["StartDate"] + "','yyyy-mm-dd hh24:mi:ss') and HAPPENTIME<=to_date('" + queryParam["EndDate"] + "','yyyy-mm-dd hh24:mi:ss'))");