diff --git a/Reportapi/MyCode.Project.Domain/Message/Act/AdminReport/PrdReport/YearAndMonth.cs b/Reportapi/MyCode.Project.Domain/Message/Act/AdminReport/PrdReport/YearAndMonth.cs new file mode 100644 index 0000000..c5504b8 --- /dev/null +++ b/Reportapi/MyCode.Project.Domain/Message/Act/AdminReport/PrdReport/YearAndMonth.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MyCode.Project.Domain.Message.Act.AdminReport.PrdReport +{ + public class YearAndMonth + { + public int Year { get; set; } + public int Month { get; set; } + } +} diff --git a/Reportapi/MyCode.Project.Domain/Message/Response/LxmZHMDReport/MaterialAndQty.cs b/Reportapi/MyCode.Project.Domain/Message/Response/LxmZHMDReport/MaterialAndQty.cs new file mode 100644 index 0000000..eb1f697 --- /dev/null +++ b/Reportapi/MyCode.Project.Domain/Message/Response/LxmZHMDReport/MaterialAndQty.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MyCode.Project.Domain.Message.Response.LxmZHMDReport +{ + public class MaterialAndQty + { + public string MaterialMasterId { get; set; } + + public string MaterialNumber { get; set; } + public string MaterialName { get; set; } + public decimal Qty { get; set; } + } +} diff --git a/Reportapi/MyCode.Project.Domain/Message/Response/LxmZHMDReport/PrdReportHead.cs b/Reportapi/MyCode.Project.Domain/Message/Response/LxmZHMDReport/PrdReportHead.cs new file mode 100644 index 0000000..8edd435 --- /dev/null +++ b/Reportapi/MyCode.Project.Domain/Message/Response/LxmZHMDReport/PrdReportHead.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MyCode.Project.Domain.Message.Response.LxmZHMDReport +{ + public class PrdReportHead + { + public decimal YearPrdQty { get; set; } + public decimal YearInStockQty { get; set; } + public decimal MonthPrdQty { get; set; } + public decimal MonthInStockQty { get; set; } + public decimal StockQty { get; set; } + public DateTime dateTime { get; set; } + } +} diff --git a/Reportapi/MyCode.Project.Domain/MyCode.Project.Domain.csproj b/Reportapi/MyCode.Project.Domain/MyCode.Project.Domain.csproj index a0f71e2..c554dd4 100644 --- a/Reportapi/MyCode.Project.Domain/MyCode.Project.Domain.csproj +++ b/Reportapi/MyCode.Project.Domain/MyCode.Project.Domain.csproj @@ -56,6 +56,7 @@ + @@ -76,9 +77,11 @@ + + @@ -125,9 +128,7 @@ MyCode.Project.Infrastructure - - - + diff --git a/Reportapi/MyCode.Project.Domain/Repositories/IMOOrdersRepository.cs b/Reportapi/MyCode.Project.Domain/Repositories/IMOOrdersRepository.cs index 7a21e00..03f3c24 100644 --- a/Reportapi/MyCode.Project.Domain/Repositories/IMOOrdersRepository.cs +++ b/Reportapi/MyCode.Project.Domain/Repositories/IMOOrdersRepository.cs @@ -1,5 +1,6 @@ using MyCode.Project.Domain; using MyCode.Project.Domain.Message; +using MyCode.Project.Domain.Message.Act.AdminReport.PrdReport; using MyCode.Project.Domain.Message.Act.Common; using MyCode.Project.Domain.Message.Response.LxmZHMDReport; using MyCode.Project.Domain.Model; @@ -31,5 +32,9 @@ namespace MyCode.Project.Domain.Repositories /// /// PageResult GetPrdMoEntryPageList(PagedSearch search); + PrdReportHead GetMoDataChartHeadByYearAndMonth(YearAndMonth yearAndMonth); + List GetPrdInStockGroupByMaterial(YearAndMonth yearAndMonth); + List GetPrdMoGroupByMaterial(YearAndMonth yearAndMonth); + List GetInventoryGroupByMaterial(); } } diff --git a/Reportapi/MyCode.Project.Repositories/MOOrdersRepository.cs b/Reportapi/MyCode.Project.Repositories/MOOrdersRepository.cs index 63d5768..7f30c9c 100644 --- a/Reportapi/MyCode.Project.Repositories/MOOrdersRepository.cs +++ b/Reportapi/MyCode.Project.Repositories/MOOrdersRepository.cs @@ -1,4 +1,5 @@ using MyCode.Project.Domain.Message; +using MyCode.Project.Domain.Message.Act.AdminReport.PrdReport; using MyCode.Project.Domain.Message.Act.Common; using MyCode.Project.Domain.Message.Response.LxmZHMDReport; using MyCode.Project.Domain.Model; @@ -72,7 +73,6 @@ FROM { SearchCondition where = new SearchCondition(); where.AddSqlCondition("1=1 ", true); - string sql = $@" SELECT * @@ -106,6 +106,166 @@ FROM return list; } + /// + /// 获取看板头数据 + /// + /// + /// + public PrdReportHead GetMoDataChartHeadByYearAndMonth(YearAndMonth yearAndMonth) + { + var yearStartDate = new DateTime(yearAndMonth.Year, 1, 1); + var yearEndDate = yearStartDate.AddYears(1); + var monthStartDate = new DateTime(yearAndMonth.Year, yearAndMonth.Month, 1); + var monthEndDate = monthStartDate.AddMonths(1); + string sql = $@" +SELECT + ( + SELECT + SUM(t1e.FQTY) YearPrdQty + FROM + T_PRD_MO t1 + INNER JOIN T_PRD_MOENTRY t1e ON t1.FID = t1e.FID + WHERE + 1 = 1 + AND t1.FDATE >= {yearStartDate.ToString("yyyy-MM-dd")} + AND t1.FDATE < {yearEndDate.ToString("yyyy-MM-dd")} + AND t1.FDOCUMENTSTATUS = 'C' + ) YearPrdQty, + ( + SELECT + SUM(t1e.FQTY) MonthPrdQty + FROM + T_PRD_MO t1 + INNER JOIN T_PRD_MOENTRY t1e ON t1.FID = t1e.FID + WHERE + 1 = 1 + AND t1.FDATE >= {monthStartDate.ToString("yyyy-MM-dd")} + AND t1.FDATE < {monthEndDate.ToString("yyyy-MM-dd")} + AND t1.FDOCUMENTSTATUS = 'C' + ) MonthPrdQty, + ( + SELECT + SUM(t1e.FREALQTY) InStockQty + FROM + T_PRD_INSTOCK t1 + INNER JOIN T_PRD_INSTOCKENTRY t1e ON t1.FID = t1e.FID + WHERE + 1 = 1 + AND t1.FDATE >= {yearStartDate.ToString("yyyy-MM-dd")} + AND t1.FDATE < {yearEndDate.ToString("yyyy-MM-dd")} + AND t1.FDOCUMENTSTATUS = 'C' + ) YearInStockQty, + ( + SELECT + SUM(t1e.FREALQTY) InStockQty + FROM + T_PRD_INSTOCK t1 + INNER JOIN T_PRD_INSTOCKENTRY t1e ON t1.FID = t1e.FID + WHERE + 1 = 1 + AND t1.FDATE >= {monthStartDate.ToString("yyyy-MM-dd")} + AND t1.FDATE < {monthEndDate.ToString("yyyy-MM-dd")} + AND t1.FDOCUMENTSTATUS = 'C' + ) MonthPrdQty, + ( + SELECT + SUM(t1.FQTY) StockQty + FROM + T_STK_INVENTORY t1 + ) StockQty + +"; + var result = this.SelectFirst(sql); + result.dateTime = monthEndDate.AddDays(-1); + return result; + } + public List GetPrdInStockGroupByMaterial(YearAndMonth yearAndMonth) + { + var yearStartDate = new DateTime(yearAndMonth.Year, 1, 1); + var yearEndDate = yearStartDate.AddYears(1); + var monthStartDate = new DateTime(yearAndMonth.Year, yearAndMonth.Month, 1); + var monthEndDate = monthStartDate.AddMonths(1); + var sql = $@" +SELECT + tm.FMASTERID MaterialMasterId, + tm.FNUMBER MaterialNumber, + tm_l.FNAME MaterialName, + SUM(t1e.FREALQTY) Qty +FROM + T_PRD_INSTOCK t1 + INNER JOIN T_PRD_INSTOCKENTRY t1e ON t1.FID = t1e.FID + INNER JOIN T_BD_MATERIAL tm ON t1e.FMATERIALID = tm.FMATERIALID + LEFT JOIN T_BD_MATERIAL_L tm_l ON tm.FMATERIALID = tm_l.FMATERIALID + AND tm_l.FLOCALEID = 2052 +WHERE + 1 = 1 + AND t1.FDATE >= {yearStartDate.ToString("yyyy-MM-dd")} + AND t1.FDATE < {yearEndDate.ToString("yyyy-MM-dd")} + AND t1.FDOCUMENTSTATUS = 'C' +GROUP BY + tm.FMASTERID, + tm.FNUMBER, + tm_l.FNAME +"; + var result = this.SelectList(sql); + return result; + } + + public List GetPrdMoGroupByMaterial(YearAndMonth yearAndMonth) + { + var yearStartDate = new DateTime(yearAndMonth.Year, 1, 1); + var yearEndDate = yearStartDate.AddYears(1); + var monthStartDate = new DateTime(yearAndMonth.Year, yearAndMonth.Month, 1); + var monthEndDate = monthStartDate.AddMonths(1); + var sql = $@" +SELECT + tm.FMASTERID MaterialMasterId, + tm.FNUMBER MaterialNumber, + tm_l.FNAME MaterialName, + SUM(t1e.FQTY) Qty +FROM + T_PRD_MO t1 + INNER JOIN T_PRD_MOENTRY t1e ON t1.FID = t1e.FID + INNER JOIN T_BD_MATERIAL tm ON t1e.FMATERIALID = tm.FMATERIALID + LEFT JOIN T_BD_MATERIAL_L tm_l ON tm.FMATERIALID = tm_l.FMATERIALID + AND tm_l.FLOCALEID = 2052 +WHERE + 1 = 1 + AND t1.FDATE >= {yearStartDate.ToString("yyyy-MM-dd")} + AND t1.FDATE < {yearEndDate.ToString("yyyy-MM-dd")} + AND t1.FDOCUMENTSTATUS = 'C' +GROUP BY + tm.FMASTERID, + tm.FNUMBER, + tm_l.FNAME +"; + var result = this.SelectList(sql); + return result; + } + + public List GetInventoryGroupByMaterial() + { + var sql = $@" +SELECT + tm.FMASTERID MaterialMasterId, + tm.FNUMBER MaterialNumber, + tm_l.FNAME MaterialName, + SUM(t1e.FQTY) Qty +FROM + T_STK_INVENTORY t1e + INNER JOIN T_BD_MATERIAL tm ON t1e.FMATERIALID = tm.FMATERIALID + LEFT JOIN T_BD_MATERIAL_L tm_l ON tm.FMATERIALID = tm_l.FMATERIALID + AND tm_l.FLOCALEID = 2052 +WHERE + 1 = 1 +GROUP BY + tm.FMASTERID, + tm.FNUMBER, + tm_l.FNAME +"; + var result = this.SelectList(sql); + return result; + } } } \ No newline at end of file diff --git a/Reportapi/MyCode.Project.Services/IServices/IPrdOrderService.cs b/Reportapi/MyCode.Project.Services/IServices/IPrdOrderService.cs index 81aa762..bd22b62 100644 --- a/Reportapi/MyCode.Project.Services/IServices/IPrdOrderService.cs +++ b/Reportapi/MyCode.Project.Services/IServices/IPrdOrderService.cs @@ -1,7 +1,9 @@ -using MyCode.Project.Domain.Message.Act.Common; +using MyCode.Project.Domain.Message.Act.AdminReport.PrdReport; +using MyCode.Project.Domain.Message.Act.Common; using MyCode.Project.Domain.Message.Response.LxmZHMDReport; using MyCode.Project.Infrastructure.Common; using MyCode.Project.Infrastructure.JackYun; +using System.Collections.Generic; namespace MyCode.Project.Services { @@ -27,5 +29,22 @@ namespace MyCode.Project.Services /// /// PageResult GetMoExecuteSumRespData(PagedSearch search); + + /// + /// 获取报表头 + /// + /// + /// + PrdReportHead GetMoDataChartHeadByYearAndMonth(YearAndMonth yearAndMonth); + + /// + /// 获取看板折现图 + /// + /// + /// + List GetMoDataChartByYearAndMonth(YearAndMonth yearAndMonth); + List GetPrdInStockGroupByMaterial(YearAndMonth yearAndMonth); + List GetPrdMoGroupByMaterial(YearAndMonth yearAndMonth); + List GetInventoryGroupByMaterial(); } } diff --git a/Reportapi/MyCode.Project.Services/Implementation/PrdOrderService.cs b/Reportapi/MyCode.Project.Services/Implementation/PrdOrderService.cs index d19f1dd..bcdfa5e 100644 --- a/Reportapi/MyCode.Project.Services/Implementation/PrdOrderService.cs +++ b/Reportapi/MyCode.Project.Services/Implementation/PrdOrderService.cs @@ -1,4 +1,5 @@ -using MyCode.Project.Domain.Message.Act.Common; +using MyCode.Project.Domain.Message.Act.AdminReport.PrdReport; +using MyCode.Project.Domain.Message.Act.Common; using MyCode.Project.Domain.Message.Request.JackYun; using MyCode.Project.Domain.Message.Request.K3Cloud; using MyCode.Project.Domain.Message.Response.K3Cloud; @@ -115,5 +116,56 @@ namespace MyCode.Project.Services.Implementation } + + + + /// + /// 获取报表头 + /// + /// + /// + public PrdReportHead GetMoDataChartHeadByYearAndMonth(YearAndMonth yearAndMonth) + { + return _MOOrdersRepository.GetMoDataChartHeadByYearAndMonth(yearAndMonth); + } + + /// + /// 获取报表折线图,获取往期12个月的数据 + /// + /// + /// + /// + public List GetMoDataChartByYearAndMonth(YearAndMonth yearAndMonth) + { + List result = new List(); + var datetime = new DateTime(yearAndMonth.Year, yearAndMonth.Month, 1); + for (int i = 0; i < 12; i++) + { + var datetimeTemp = datetime.AddMonths(-i); + YearAndMonth yearAndMonthTemp = new YearAndMonth() + { + Year = datetimeTemp.Year, + Month = datetimeTemp.Month, + }; + result.Add(_MOOrdersRepository.GetMoDataChartHeadByYearAndMonth(yearAndMonth)); + } + return result; + } + + public List GetPrdInStockGroupByMaterial(YearAndMonth yearAndMonth) + { + return _MOOrdersRepository.GetPrdInStockGroupByMaterial(yearAndMonth); + } + + public List GetPrdMoGroupByMaterial(YearAndMonth yearAndMonth) + { + return _MOOrdersRepository.GetPrdMoGroupByMaterial(yearAndMonth); + + } + + public List GetInventoryGroupByMaterial() + { + return _MOOrdersRepository.GetInventoryGroupByMaterial(); + } } } diff --git a/Reportapi/MyCode.Project.WebApi/Areas/Admin/Controllers/DataChartController.cs b/Reportapi/MyCode.Project.WebApi/Areas/Admin/Controllers/DataChartController.cs index a675d72..e905576 100644 --- a/Reportapi/MyCode.Project.WebApi/Areas/Admin/Controllers/DataChartController.cs +++ b/Reportapi/MyCode.Project.WebApi/Areas/Admin/Controllers/DataChartController.cs @@ -82,35 +82,6 @@ namespace MyCode.Project.WebApi.Areas.Admin.Controllers return _PurOrderService.GetPurDetil(search); } - /// - /// 获取生产订单 - /// - [AllowAnonymous] - [HttpPost] - public PageResult GetMoRespData(PagedSearch pagedSearch) - { - return _prdOrderService.GetPrdMoPageList(pagedSearch); - } - - /// - /// 获取生产订单详情 - /// - [AllowAnonymous] - [HttpPost] - - public PageResult GetMoEntryRespData(PagedSearch search) - { - return _prdOrderService.GetPrdMoEntryPageList(search); - } - - /// - /// 获取生产订单执行汇总报表数据 - /// - [AllowAnonymous] - [HttpPost] - public PageResult GetMoExecuteSumRespData(PagedSearch pagedSearch) - { - return _prdOrderService.GetMoExecuteSumRespData(pagedSearch); - } + } } diff --git a/Reportapi/MyCode.Project.WebApi/Areas/Admin/Controllers/PrdDataChartController.cs b/Reportapi/MyCode.Project.WebApi/Areas/Admin/Controllers/PrdDataChartController.cs new file mode 100644 index 0000000..93b985b --- /dev/null +++ b/Reportapi/MyCode.Project.WebApi/Areas/Admin/Controllers/PrdDataChartController.cs @@ -0,0 +1,120 @@ +using MyCode.Project.Domain.Message.Act.AdminReport.PrdReport; +using MyCode.Project.Domain.Message.Act.Common; +using MyCode.Project.Domain.Message.Response.LxmZHMDReport; +using MyCode.Project.Infrastructure.Common; +using MyCode.Project.Services; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Mvc; + +namespace MyCode.Project.WebApi.Areas.Admin.Controllers +{ + /// + /// 生产看板控制器 + /// + public class PrdDataChartController : BaseAdminController + { + private IPrdOrderService _prdOrderService; + + /// + /// 生产订单服务 + /// + /// + public PrdDataChartController(IPrdOrderService prdOrderService) + { + _prdOrderService = prdOrderService; + } + + /// + /// 获取生产订单 + /// + [AllowAnonymous] + [HttpPost] + public PageResult GetMoRespData(PagedSearch pagedSearch) + { + return _prdOrderService.GetPrdMoPageList(pagedSearch); + } + + /// + /// 获取生产订单详情 + /// + [AllowAnonymous] + [HttpPost] + + public PageResult GetMoEntryRespData(PagedSearch search) + { + return _prdOrderService.GetPrdMoEntryPageList(search); + } + + /// + /// 获取生产订单执行汇总报表数据 + /// + [AllowAnonymous] + [HttpPost] + public PageResult GetMoExecuteSumRespData(PagedSearch pagedSearch) + { + return _prdOrderService.GetMoExecuteSumRespData(pagedSearch); + } + + /// + /// 获取生产看板头数据 + /// + /// + /// + [AllowAnonymous] + [HttpPost] + public PrdReportHead GetMoDataChartHeadByYearAndMonth(YearAndMonth yearAndMonth) + { + return _prdOrderService.GetMoDataChartHeadByYearAndMonth(yearAndMonth); + } + + /// + /// 获取生产看板折线数据 + /// + /// + /// + [AllowAnonymous] + [HttpPost] + public List GetMoDataChartByYearAndMonth(YearAndMonth yearAndMonth) + { + return _prdOrderService.GetMoDataChartByYearAndMonth(yearAndMonth); + } + + /// + /// 获取生产入库数据,主要用作饼图,展示各物料生产入库数量(完工数量) + /// + /// + /// + [AllowAnonymous] + [HttpPost] + public List GetPrdInStockGroupByMaterial(YearAndMonth yearAndMonth) + { + return _prdOrderService.GetPrdInStockGroupByMaterial(yearAndMonth); + } + + /// + /// 获取生产订单数据,主要用作饼图,展示各物料生产订单数量(生产数量) + /// + /// + /// + [AllowAnonymous] + [HttpPost] + public List GetPrdMoGroupByMaterial(YearAndMonth yearAndMonth) + { + return _prdOrderService.GetPrdMoGroupByMaterial(yearAndMonth); + } + + /// + /// 获取即时库存数据,主要用作饼图,展示各物料库存数量(库存数量) + /// + /// + [AllowAnonymous] + [HttpPost] + public List GetInventoryGroupByMaterial() + { + return _prdOrderService.GetInventoryGroupByMaterial(); + } + } +} \ No newline at end of file diff --git a/Reportapi/MyCode.Project.WebApi/MyCode.Project.WebApi.csproj b/Reportapi/MyCode.Project.WebApi/MyCode.Project.WebApi.csproj index 38cfb04..4ae8e65 100644 --- a/Reportapi/MyCode.Project.WebApi/MyCode.Project.WebApi.csproj +++ b/Reportapi/MyCode.Project.WebApi/MyCode.Project.WebApi.csproj @@ -204,6 +204,7 @@ + @@ -1674,6 +1675,7 @@ +