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.
202 lines
7.1 KiB
202 lines
7.1 KiB
using JHReport.DAL;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Globalization;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Net.Http;
|
|
using System.Reflection;
|
|
using System.Web.Http;
|
|
using Warehouse.DAL.Report;
|
|
|
|
namespace Warehouse.WebApi.NewReport
|
|
{
|
|
public class FragmentRateReportController : ApiController
|
|
{
|
|
GregorianCalendar gc = new GregorianCalendar();
|
|
ReportDal report = new ReportDal();
|
|
static DbUtility dbhelp = new DbUtility(System.Configuration.ConfigurationManager.ConnectionStrings["mesConn"].ToString(), DbProviderType.SqlServer);
|
|
|
|
[Route("api/FragmentRateReport/FragmentRateReport")]
|
|
[HttpPost]
|
|
public IHttpActionResult FragmentRateReport(dynamic para)
|
|
{
|
|
string area = para.workshop;
|
|
string Year = para.year;
|
|
string Month = para.month;
|
|
|
|
DateTime DT_MonthFristDay = DateTime.Parse(Year + "-" + Month + "-01");
|
|
|
|
int MonthFristDay_WeekInYear = gc.GetWeekOfYear(DT_MonthFristDay, CalendarWeekRule.FirstDay, DayOfWeek.Saturday);
|
|
|
|
string bt = DT_MonthFristDay.ToString();
|
|
|
|
string et = DT_MonthFristDay.AddMonths(1).ToString();
|
|
|
|
//List<dynamic> res = DT.FragmentRateReport(bt, et, area);
|
|
|
|
DataTable res = dbhelp.ExecuteDataTable(report.FragmentRateReportSql(bt, et, area), null);
|
|
DataTable Copy = new DataTable();
|
|
|
|
DataTable Insert = res.Copy();
|
|
|
|
DataRow InsertRow = Insert.NewRow();
|
|
|
|
int WeeekCount = 0;
|
|
|
|
int DayOfWeek_Cp = 0;
|
|
|
|
int DayOfWeek_In = MonthFristDay_WeekInYear;
|
|
|
|
///插入周
|
|
for (int i = 0; i < res.Rows.Count; i++)
|
|
{
|
|
DayOfWeek_In = gc.GetWeekOfYear(DateTime.Parse(res.Rows[i]["YYMMDD"].ToString()), CalendarWeekRule.FirstDay, DayOfWeek.Sunday);
|
|
|
|
if (i == 0)
|
|
{
|
|
DayOfWeek_Cp = DayOfWeek_In;
|
|
}
|
|
|
|
if (DayOfWeek_Cp == DayOfWeek_In)
|
|
{
|
|
for (int j = 1; j < 14; j++)
|
|
{
|
|
double d = 0;
|
|
InsertRow[0] = "第" + DayOfWeek_In + "周";
|
|
if (!string.IsNullOrEmpty(InsertRow[j].ToString()))
|
|
{
|
|
d = Convert.ToDouble(InsertRow[j]);
|
|
}
|
|
if (j == 4 || j == 6)
|
|
{
|
|
d = Convert.ToDouble(res.Rows[i][j]);
|
|
}
|
|
else if (j == 5)
|
|
{
|
|
d = Convert.ToDouble(InsertRow[2]) / Convert.ToDouble(InsertRow[1]) * 1000;
|
|
}
|
|
else if (j == 7)
|
|
{
|
|
d = Convert.ToDouble(InsertRow[3]) / Convert.ToDouble(InsertRow[1]) * 1000;
|
|
}
|
|
else if (j == 12)
|
|
{
|
|
if (Convert.ToDouble(InsertRow[8]) == 0)
|
|
{
|
|
d = 0;
|
|
}
|
|
else
|
|
{
|
|
d = Convert.ToDouble(InsertRow[9]) / Convert.ToDouble(InsertRow[8]) * 1000;
|
|
}
|
|
}
|
|
else if (j == 13)
|
|
{
|
|
if (Convert.ToDouble(InsertRow[10]) == 0)
|
|
{
|
|
d = 0;
|
|
}
|
|
else
|
|
{
|
|
d = Convert.ToDouble(InsertRow[11]) / Convert.ToDouble(InsertRow[10]) * 1000;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
d += Convert.ToDouble(res.Rows[i][j]);
|
|
}
|
|
InsertRow[j] = d;
|
|
}
|
|
|
|
if (i == res.Rows.Count - 1)
|
|
{
|
|
Insert.Rows.InsertAt(InsertRow, i + WeeekCount + 1);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//插入
|
|
WeeekCount++;
|
|
Insert.Rows.InsertAt(InsertRow, i - 1 + WeeekCount);
|
|
InsertRow = Insert.NewRow();
|
|
DayOfWeek_Cp = DayOfWeek_In;
|
|
for (int j = 1; j < 14; j++)
|
|
{
|
|
double d = 0;
|
|
InsertRow[0] = "第" + DayOfWeek_In + "周";
|
|
if (!string.IsNullOrEmpty(InsertRow[j].ToString()))
|
|
{
|
|
d = Convert.ToDouble(InsertRow[j]);
|
|
}
|
|
if (j == 4 || j == 6)
|
|
{
|
|
d = Convert.ToDouble(res.Rows[i][j]);
|
|
}
|
|
else if (j == 5)
|
|
{
|
|
d = Convert.ToDouble(InsertRow[2]) / Convert.ToDouble(InsertRow[1]) * 1000;
|
|
}
|
|
else if (j == 7)
|
|
{
|
|
d = Convert.ToDouble(InsertRow[3]) / Convert.ToDouble(InsertRow[1]) * 1000;
|
|
}
|
|
else if (j == 12)
|
|
{
|
|
if (Convert.ToDouble(InsertRow[8]) == 0)
|
|
{
|
|
d = 0;
|
|
}
|
|
else
|
|
{
|
|
d = Convert.ToDouble(InsertRow[9]) / Convert.ToDouble(InsertRow[8]) * 1000;
|
|
}
|
|
}
|
|
else if (j == 13)
|
|
{
|
|
if (Convert.ToDouble(InsertRow[10]) == 0)
|
|
{
|
|
d = 0;
|
|
}
|
|
else
|
|
{
|
|
d = Convert.ToDouble(InsertRow[11]) / Convert.ToDouble(InsertRow[10]) * 1000;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
d += Convert.ToDouble(res.Rows[i][j]);
|
|
}
|
|
InsertRow[j] = d;
|
|
}
|
|
}
|
|
}
|
|
|
|
for (int i = 0; i < Insert.Rows.Count; i++)
|
|
{
|
|
Copy.Columns.Add(Insert.Rows[i]["YYMMDD"].ToString());
|
|
}
|
|
|
|
///翻转
|
|
for (int i = 0; i < 14; i++)
|
|
{
|
|
DataRow dataRow = Copy.NewRow();
|
|
for (int j = 0; j < Insert.Rows.Count; j++)
|
|
{
|
|
|
|
dataRow[j] = Insert.Rows[j][i];
|
|
}
|
|
Copy.Rows.Add(dataRow);
|
|
}
|
|
|
|
Copy.Rows.RemoveAt(0);
|
|
|
|
return Json(Copy);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|