234 lines
11 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Learun.Application.Report;
using Learun.Util;
using System.Web.Mvc;
using System;
namespace Learun.Application.Web.Areas.LR_ReportModule.Controllers
{
/// <summary>
/// 版 本 PIT-ADMS V7.0.3 敏捷开发框架
/// Copyright (c) 2013-2018 Hexagon PPM
/// 创 建:超级管理员
/// 日 期2017-07-12 09:57
/// 描 述:报表管理
/// </summary>
public class ReportManageController : MvcControllerBase
{
private ReportTempIBLL reportTempIBLL = new ReportTempBLL();
#region
/// <summary>
/// 管理页面
/// </summary>
/// <returns></returns>
[HttpGet]
public ActionResult Index()
{
return View();
}
/// <summary>
/// 表单页面
/// </summary>
/// <returns></returns>
[HttpGet]
public ActionResult Form()
{
return View();
}
/// <summary>
/// 浏览页面
/// </summary>
/// <returns></returns>
[HttpGet]
public ActionResult Preview()
{
return View();
}
#endregion
#region
/// <summary>
/// 获取分页数据
/// </summary>
/// <param name="pagination">分页参数</param>
/// <param name="keyword">关键词</param>
/// <returns></returns>
[HttpGet]
public ActionResult GetPageList(string pagination, string keyword)
{
Pagination paginationobj = pagination.ToObject<Pagination>();
var data = reportTempIBLL.GetPageList(paginationobj, keyword);
var jsonData = new
{
rows = data,
total = paginationobj.total,
page = paginationobj.page,
records = paginationobj.records,
};
return Success(jsonData);
}
/// <summary>
/// 获取实体数据
/// </summary>
/// <param name="keyValue">主键</param>
/// <returns></returns>
[HttpGet]
public ActionResult GetEntity(string keyValue)
{
var data = reportTempIBLL.GetEntity(keyValue);
return Success(data);
}
/// <summary>
/// 获取报表数据
/// </summary>
/// <param name="reportId">报表主键</param>
/// <returns></returns>
[HttpGet]
public ActionResult GetReportData(string reportId)
{
ReportTempEntity reportEntity = reportTempIBLL.GetEntity(reportId);
dynamic paramJson = reportEntity.F_ParamJson.ToJson();
var data = new
{
tempStyle = reportEntity.F_TempStyle,
chartType = reportEntity.F_TempType,
chartData = reportTempIBLL.GetReportData(paramJson.F_DataSourceId.ToString(), paramJson.F_ChartSqlString.ToString()),
listData = reportTempIBLL.GetReportData(paramJson.F_DataSourceId.ToString(), paramJson.F_ListSqlString.ToString())
};
return Content(data.ToJson());
}
#endregion
#region
/// <summary>
/// 保存表单数据
/// </summary>
/// <param name="keyValue">主键</param>
/// <param name="entity">实体</param>
/// <returns></returns>
[HttpPost, ValidateAntiForgeryToken, AjaxOnly]
public ActionResult SaveForm(string keyValue, ReportTempEntity entity)
{
reportTempIBLL.SaveEntity(keyValue, entity);
return Success("保存成功!");
}
/// <summary>
/// 删除表单数据
/// </summary>
/// <param name="keyValue">主键</param>
/// <returns></returns>
[HttpPost]
[AjaxOnly]
public ActionResult DeleteForm(string keyValue)
{
reportTempIBLL.DeleteEntity(keyValue);
return Success("删除成功!");
}
#endregion
#region
/// <summary>
/// 看板查询获取数据
/// </summary>
/// <param name="InputData">入参,多参数以~分开例如入参2个就是2019-01-01~2019-02-02入参一个2019-01-01~,入参为空则~</param>
/// <param name="Type">类型</param>
/// <param name="SourceId">数据源Id默认systemdb本地数据库</param>
/// <returns></returns>
[HttpGet]
public ActionResult GetKanBanData(string InputData, string Type,string SourceId= "systemdb")
{
var keys = new string[0];
if (!InputData.IsEmpty())
keys = InputData.Split('~');
string sql = "";
#region
if (Type == "MmsLendData")
{
sql = "select a.*,b.实际借出数量 from ( "
+ "select year(PlanLendDate) as 年,month(PlanLendDate) as 月,count(*) as 计划借出数量 "
+ "from MES_Mms_MouldUsingStatus where PlanLendDate is not null and Enable = 1 "
+ "group by year(PlanLendDate),month(PlanLendDate) ) as a "
+ "left join( "
+ "select year(ActiveLendDate) as 年,month(ActiveLendDate) as 月,count(*) as 实际借出数量 "
+ "from MES_Mms_MouldUsingStatus where Enable = 1 and ActiveLendDate is not null "
+ "group by year(ActiveLendDate),month(ActiveLendDate) ) as b on a.年 = b.年 and a.月 = b.月 and a.年=" + Convert.ToInt32(keys[0]);
}
#endregion
#region
else if (Type == "MmsReturnData")
{
sql = "select a.*,b.实际归还数量 from ( "
+ "select year(PlanReturnDate) as 年,month(PlanReturnDate) as 月,count(*) as 计划归还数量 "
+ "from MES_Mms_MouldUsingStatus where PlanReturnDate is not null and Enable=1 "
+ "group by year(PlanReturnDate),month(PlanReturnDate) ) as a "
+ "left join ( "
+ "select year(ActiveReturnDate) as 年,month(ActiveReturnDate) as 月,count(*) as 实际归还数量 "
+ "from MES_Mms_MouldUsingStatus where ActiveReturnDate is not null and Enable=1 "
+ "group by year(ActiveReturnDate),month(ActiveReturnDate) ) as b on a.年=b.年 and a.月= b.月 and a.年=" + Convert.ToInt32(keys[0]);
}
#endregion
#region
else if (Type == "MmsTodayToBeLend")
{
sql = "select a.AccountCode as 模具编码,b.Description as 模具描述,a.PlanLendDate as 计划领用时间, "
+ "a.availabledate as 可领用时间,a.Users as 借出人,a.Groups as 占用产线,a.UsingStatus as 状态 "
+ "from MES_Mms_MouldUsingStatus a "
+ "left join MES_Mms_MouldAccount b on a.AccountCode=b.AccountCode "
+ "where datediff(dd,a.PlanLendDate,GETDATE())=0 and a.UsingStatus='ToBeLent' and a.Enable=1 and a.groups='" + keys[0] + "'";
}
#endregion
#region
else if (Type == "MmsTodayToBeLend")
{
sql = "select a.AccountCode as 模具编码,b.Description as 模具描述,a.PlanLendDate as 计划领用时间, "
+ "a.availabledate as 可领用时间,a.Users as 归还人,a.Groups as 占用产线,a.UsingStatus as 状态 "
+ "from MES_Mms_MouldUsingStatus a "
+ "left join MES_Mms_MouldAccount b on a.AccountCode=b.AccountCode "
+ "where datediff(dd,a.PlanLendDate,GETDATE())=0 and a.UsingStatus='ToBeReturn' and a.Enable=1 and a.groups='" + keys[0] + "'";
}
#endregion
#region
else if (Type == "AmsTotal")
{
sql = "select 天数='000-001',count(*) as '数量' from Ams_AnomalAccount "
+ "where ProcessStatus!='Processed' and DateDiff(dd,ReportingTime,getdate())<=1 and DateDiff(dd,ReportingTime,getdate())>0 "
+ "union select 天数 = '001-003', count(*) as '数量' from Ams_AnomalAccount "
+ "where ProcessStatus!='Processed' and DateDiff(dd,ReportingTime,getdate())<=3 and DateDiff(dd,ReportingTime,getdate())>1 "
+ "union select 天数 = '003-007', count(*) as '数量' from Ams_AnomalAccount "
+ "where ProcessStatus!='Processed' and DateDiff(dd,ReportingTime,getdate())<=7 and DateDiff(dd,ReportingTime,getdate())>3 "
+ "union select 天数 = '007-014', count(*) as '数量' from Ams_AnomalAccount "
+ "where ProcessStatus!='Processed' and DateDiff(dd,ReportingTime,getdate())<=14 and DateDiff(dd,ReportingTime,getdate())>7 "
+ "union select 天数 = '014-030', count(*) as '数量' from Ams_AnomalAccount "
+ "where ProcessStatus!='Processed' and DateDiff(dd,ReportingTime,getdate())<=30 and DateDiff(dd,ReportingTime,getdate())>14 "
+ "union select 天数 = '030-090', count(*) as '数量' from Ams_AnomalAccount "
+ "where ProcessStatus!='Processed' and DateDiff(dd,ReportingTime,getdate())<=90 and DateDiff(dd,ReportingTime,getdate())>30 "
+ "union select 天数 = '090-180', count(*) as '数量' from Ams_AnomalAccount "
+ "where ProcessStatus!='Processed' and DateDiff(dd,ReportingTime,getdate())<=180 and DateDiff(dd,ReportingTime,getdate())>90 "
+ "union select 天数 = '180-~', count(*) as '数量' from Ams_AnomalAccount "
+ "where ProcessStatus!='Processed' and DateDiff(dd,ReportingTime,getdate())>180";
}
#endregion
#region
else if (Type == "AmsTypeTotal")
{
sql = "select a.ResponsibleDept,count(a.ResponsibleDept) as '数量' from Ams_AnomalAccount a "
+ "where a.ProcessStatus!='Processed' and DateDiff(dd,a.ReportingTime,getdate())>=7 group by a.ResponsibleDept";
}
#endregion
#region
else if (Type == "AmsTypeTotal")
{
sql = "select b.TypeName,count(b.TypeName) as '数量' from Ams_AnomalAccount a "
+ "left join Ams_AnomalyType b on a.AbnormalType=b.Id "
+ "where a.ProcessStatus!='Processed' and a.ReportingTime >="+keys[0]+ "and a.ReportingTime <=" + keys[1]+ "and a.ResponsibleDept ='" + keys[2]+"'"
+ " group by b.TypeName";
}
#endregion
#region
#endregion
var data = reportTempIBLL.GetReportData(SourceId, sql);
return Success(data.ToJson());
}
#endregion
}
}