📄 saledeptcustractlist_dest.java
字号:
package com.jobcn.task;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.sql.*;
import com.jobcn.database.DataBase;
import com.jobcn.control.Constant;
import com.jobcn.control.MessageCenter;
/**
*
* @remark:
* @author: Stephen
* @date: 2005-3-21
* @version:
*
* @upd_remark:
* @upd_user:
* @upd_date:
*/
final public class SALEDeptCusTractList_dest extends AbstractCreateHtml {
//constructer1
public SALEDeptCusTractList_dest() {
super(new StringBuffer(1024));
}
//constructer2
public SALEDeptCusTractList_dest(StringBuffer sb) {
super(sb);
}
public void printHeader() {
sb.append("<html>\n");
sb.append("<head>\n");
sb.append(" <title>本月各部目标及进度</title>\n");
sb.append(" <link href=\"/BOSS_CSS/css.css\" rel=\"stylesheet\" type=\"text/css\">\n");
sb.append(" <meta http-equiv=\"content-Type\" content=\"text/html; charset=GBK\">\n");
sb.append("</head>\n");
}
public void printBody() {
//公司月份目标
//[0][1] 表示2000年1月份, [4][5] 表示2004年5月份, [10][12] 表示2009年12月份
/*int[][] ActDestTractMoney = new int[10][13];
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 13; j++) {
ActDestTractMoney[i][j] = 5000000;
}
}
ActDestTractMoney[4][8] = 2000000;
ActDestTractMoney[4][9] = 2000000;
ActDestTractMoney[4][10] = 1850000;
ActDestTractMoney[4][11] = 2200000;
ActDestTractMoney[4][12] = 5000000;
ActDestTractMoney[5][1] = 2000000;
ActDestTractMoney[5][2] = 1000000;
ActDestTractMoney[5][3] = 5000000;
ActDestTractMoney[5][4] = 5000000;
ActDestTractMoney[5][5] = 2000000;*/
java.text.DecimalFormat nf = new java.text.DecimalFormat("###,###"); //整数number
// format
java.text.DecimalFormat Pernf = new java.text.DecimalFormat("###0.00"); //百分比
String strDate = (new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm")).format(new java.util.Date());
String strYear = strDate.substring(0, 4);
String strMonth = strDate.substring(5, 7);
String strDay = strDate.substring(8, 10);
int CurrentDays=Integer.parseInt(strDate.substring(8,10));
String strYearMonth = strDate.substring(0, 7);
String strIMonth = String.valueOf(Integer.parseInt(strMonth));
String strIDay = String.valueOf(Integer.parseInt(strDay));
//本月公司整体销售目标:来源于公司月分目标ActDestTractMoney[][]
//int ComDestTractMoney = ActDestTractMoney[Integer.parseInt(strYear) - 2000][Integer.parseInt(strMonth)];
int ComDestTractMoney=5000000;
DataBase db = new DataBase();
Connection DBConn = null;
Statement stmt = null;
ResultSet RS = null, RS1 = null;
String SQL = "";
//String DepartId = "";
String DepartName = "", PersonName = "", PersonExt = "";
int ManagerDestMoney = 0, TractMoney = 0, TractMoney_Today = 0;
int ManagerDestMoneyTotal = 0, TractMoneyTotal = 0, TractMoney_TodayTotal = 0;
double DestAchieveRate = 0.00, ComDestAchieveRate = 0.00;
int MonthDays=0,WeekSixDays=0,WeekEndDays=0;
String deptChartData = "", deptDayChartData = ""; //图表数据:各部门本月销售统计图和各部门本日销售统计图
String chartData="";
SQL=" select "+
" jobcn_boss.dbo.GetMonthDays('0','"+strDate.substring(0, 4)+"','"+strIMonth+"') as MonthDays, "+
" sum([1]) as Money1, sum([2]) as Money2, sum([3]) as Money3, sum([4]) as Money4, sum([5]) as Money5, sum([6]) as Money6, "+
" sum([7]) as Money7, sum([8]) as Money8, sum([9]) as Money9, sum([10]) as Money10, sum([11]) as Money11, sum([12]) as Money12, "+
" sum([13]) as Money13, sum([14]) as Money14, sum([15]) as Money15, sum([16]) as Money16, sum([17]) as Money17, sum([18]) as Money18, "+
" sum([19]) as Money19, sum([20]) as Money20, sum([21]) as Money21, sum([22]) as Money22, sum([23]) as Money23, sum([24]) as Money24, "+
" sum([25]) as Money25, sum([26]) as Money26, sum([27]) as Money27, sum([28]) as Money28, sum([29]) as Money29, sum([30]) as Money30, "+
" sum([31]) as Money31 "+
" from SaleMoneyDeptState where YearNum='"+strDate.substring(0, 4)+"' and MonthNum='"+strIMonth+"' "+
" group by yearnum,monthnum ";
try {
DBConn = db.connect();
stmt = DBConn.createStatement();
//公司目标
RS = stmt.executeQuery("select SaleDest from SaleMoneyDest_Company_EveryMonth where YearNum='"+strYear+"' and MonthNum='"+strIMonth+"'");
if(RS.next()){
ComDestTractMoney=RS.getInt("SaleDest");
}
RS = stmt.executeQuery(SQL);
//RS = db.getRS(stmt,SQL);
if (RS.next())
{
MonthDays=RS.getInt("MonthDays");
for(int k=1;k<=MonthDays;k++)
{
chartData+=Integer.toString(k)+","+RS.getInt("Money"+k)+",";
}
}
chartData=chartData.substring(0,chartData.length()-1);
//sb.append("<center><img src='//BOSS_IMAGES/20055_Group.jpg'></center>");
sb.append("<table border=0 width='540' align='center' valign='top'>");
sb.append("<tr valign=\"top\">");
sb.append("<td><img src=\"/BOSS_util/chart_java.jsp?TopTitle="+strDate.substring(0, 4)+"年"+strIMonth+"月日签单业绩分布图&BottomTitle=日期&CoordColor=99CC00&chartData="+chartData+"\"></td>");
sb.append("</tr>");
sb.append("</table>");
sb.append("<table border=0 width='100%' align='center'>\n");
sb.append("<tr><td align=\"center\" valign=\"top\">\n");
sb.append("<img id=\"img1\" src=\"\">\n");
sb.append("<img id=\"img2\" src=\"\">\n");
sb.append("</td></tr>\n");
sb.append("</table>\n");
SQL = "select aa.DepartID, aa.DepartName, aa.PersonName, aa.PersonExt, " + "aa.ManagerDestMoney, ISNULL(bb.TractMoney,0) TractMoney, ISNULL(cc.TractMoney_Today,0) TractMoney_Today, jobcn_boss.dbo.GetMonthDays('0','"+strYear+"','"+strIMonth+"') as MonthDays,jobcn_boss.dbo.GetWeekSixDays(dateadd(d,1,getdate()),dateadd(d,-1,convert(varchar(7),dateadd(m,1,getdate()),120)+'-01')) as WeekSixDays ,jobcn_boss.dbo.GetWeekEndDays(dateadd(d,1,getdate()),dateadd(d,-1,convert(varchar(7),dateadd(m,1,getdate()),120)+'-01')) as WeekEndDays,day(getdate()) as CurrentDays, "
+ "(case when aa.ManagerDestMoney=0 then 0.00 else ISNULL(bb.TractMoney,0)/(aa.ManagerDestMoney*1.00) end) DestAchieveRate " + "from(select bd.sequence, sde.DeptID DepartID, sde.DepartName, ISNULL(sde.SaleDest,0) ManagerDestMoney, "
+ "hp.name PersonName, hp.OfficePhone_Ext PersonExt " + "from SaleMoneyDest_Dept_EveryMonth sde, HrPerson hp, BaseDepartment bd " + "where sde.ManagerPerID=hp.ID and sde.DeptID=bd.id and bd.SortID=100 " + "and sde.YearNum='" + strYear + "' " + "and sde.MonthNum='" + strIMonth + "' "
+ ") aa, " + "(select hp.DepartID, SUM(CONVERT(FLOAT,ctr.TractMoney)) TractMoney " + "from FNCusTractRec ctr, HrPerson hp " + "where ctr.PersonID=hp.ID " + "and CONVERT(VARCHAR(7),ctr.TractDate,120)='" + strYearMonth + "' "
+ "group by hp.DepartID " + ") bb, " + "(select hp.DepartID, SUM(CONVERT(FLOAT,ctr.TractMoney)) TractMoney_Today " + "from FNCusTractRec ctr, HrPerson hp " + "where ctr.PersonID=hp.ID "
+ "and CONVERT(VARCHAR(10),ctr.TractDate,120)='" + strDate.substring(0, 10) + "' " + "group by hp.DepartID " + ") cc " + "where aa.DepartID *=bb.DepartID " + "and aa.DepartID *=cc.DepartID ";
//System.out.println(SQL);
RS = stmt.executeQuery(SQL + " order by aa.sequence");
/*
while (RS.next()) {
DepartName = RS.getString("DepartName");
TractMoney = RS.getInt("TractMoney");
TractMoney_Today = RS.getInt("TractMoney_Today");
deptChartData = deptChartData + DepartName.replaceAll("销售", "") + "," + Integer.toString(TractMoney) + ",";
deptDayChartData = deptDayChartData + DepartName.replaceAll("销售", "") + "," + Integer.toString(TractMoney_Today) + ",";
}
deptChartData = deptChartData.substring(0, deptChartData.length() - 1);
deptDayChartData = deptDayChartData.substring(0, deptDayChartData.length() - 1);
//RS.close();
//stmt.close();
sb.append("<body topmargin='0' leftmargin='0' oncontextmenu='return false;' ondragstart='return false;' onsource='return false;' onselectstart='return false;'>\n");
sb.append("<br>\n");
sb.append("<table border='0' >\n");
sb.append("<tr><td width=50> </td><td>\n");
sb.append("<table border=0 width='1000' align='center'>\n");
sb.append("<tr valign=\"top\"><tr><td >\n");
sb.append("<img src=\"/BOSS_util/chart_java.jsp?TopTitle="+strYear+"年"+strIMonth+"月各部签单业绩分布图&BottomTitle=销售部门&CoordColor=FF6600&chartData="+deptChartData+"\" ");
sb.append("border='0' onload='javascript:if(this.width>document.body.clientWidth-230) this.width=document.body.clientWidth-230' onclick='javascript:if(this.width==document.body.clientWidth-230 && this.style.zoom==0) {this.style.zoom=0; this.width=704;} else {this.style.zoom=0; this.width=document.body.clientWidth-230}' onmousewheel='return bb_img_onmousewheel(this)' >\n");
sb.append("<img src=\"/BOSS_util/chart_java.jsp?TopTitle=" + strYear + "年" + strIMonth + "月" + strIDay + "日各部签单业绩分布图&BottomTitle=销售部门&CoordColor=FF6600&chartData=" + deptDayChartData + "\">\n");
sb.append("</td></tr>\n");
sb.append("</table></td></tr>\n");
*/
//end图片
//begin 实际进度
sb.append(" <tr><td width=50> </td>\n");
// sb.append(" <table align='center' cellSpacing='1' cellPadding='4' width='500' bgColor='#cccccc' border='0' >");
// sb.append(" <tr bgColor='#ffffff'>");
// sb.append(" <td align='middle' bgColor='#fae8cc' width='75' ><font size='3' color='red'>备注</font></td>");
// sb.append(" <td ><font size='2' color='blue'>应有进度=当月已过天数/当月整月天数<br>应有进度额=当月目标额×当月已过天数/当月整月天数<br>实际进度=当月实际签单额/当月目标额<br>实际进度额=当月实际签单额<br>进度差额=应有进度额-实际进度额</font></td>");
// sb.append(" </tr>");
// sb.append(" </table>");
//RS.beforeFirst();
while (RS.next())
{
DepartName = RS.getString("DepartName");
//PersonName = RS.getString("PersonName");
//ManagerDestMoney = RS.getInt("ManagerDestMoney");
TractMoney = RS.getInt("TractMoney");
TractMoney_Today = RS.getInt("TractMoney_Today");
//MonthDays=RS.getInt("MonthDays");
//WeekSixDays=RS.getInt("WeekSixDays");
//WeekEndDays=RS.getInt("WeekEndDays");
//CurrentDays=RS.getInt("CurrentDays");
deptChartData = deptChartData + DepartName.replaceAll("销售", "") + "," + Integer.toString(TractMoney) + ",";
deptDayChartData = deptDayChartData + DepartName.replaceAll("销售", "") + "," + Integer.toString(TractMoney_Today) + ",";
/*
if (!DepartName.equals("销售T部"))
{
sb.append(" <table align='center' cellSpacing='1' cellPadding='4' width='600' bgColor='#cccccc' border='0' id='table3' height='40'>");
sb.append(" <tr align='middle' height='30' bgColor='#fae8cc'>");
sb.append(" <td width='90' align='middle' ><b>"+DepartName+"</b></td>");
//sb.append(" <td width='370' ><font size='2' >销售经理:"+PersonName+" 销售目标:<font color='blue'>"+ManagerDestMoney+"</font>元 今日签单:<font color='blue'>"+TractMoney_Today+"</font>元</font></td>");
sb.append(" <td width='370' ><font size='2' >销售经理:"+PersonName+" 销售目标:<font color='blue'>"+ManagerDestMoney+"</font>元</font></td>");
if (ManagerDestMoney*CurrentDays/MonthDays-TractMoney>0)
sb.append(" <td width='140' align='right' nowrap>进度差额:<font color='red' size='3'><b>"+nf.format((double)ManagerDestMoney*CurrentDays/MonthDays-TractMoney)+"</b></font>元</td>");
else
sb.append(" <td width='140' align='right' nowrap>进度差额:<font color='blue'>"+nf.format((double)ManagerDestMoney*CurrentDays/MonthDays-TractMoney)+"</font>元</td>");
sb.append(" </tr>");
sb.append(" <tr bgColor='#ffffff'>");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -