2025-05-07 08:20:08 +08:00
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
using ZR.Admin.WebApi.Extensions;
|
|
|
|
|
|
using ZR.Admin.WebApi.Filters;
|
|
|
|
|
|
using ZR.Model.Business;
|
|
|
|
|
|
using ZR.Model.Dto;
|
|
|
|
|
|
using ZR.Service.Business.IBusinessService;
|
|
|
|
|
|
|
|
|
|
|
|
//创建时间:2025-01-02
|
|
|
|
|
|
namespace ZR.Admin.WebApi.Controllers
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 质量BackEnd统计报表业务模块
|
|
|
|
|
|
/// </summary>
|
2025-08-28 10:10:15 +08:00
|
|
|
|
//[Verify]
|
2025-05-07 08:20:08 +08:00
|
|
|
|
[Route("/mes/qc/BackEnd/QcBackEndServiceStatistics")]
|
|
|
|
|
|
public class QcBackEndServiceStatisticsController : BaseController
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 质量BackEnd统计报表业务模块接口
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private readonly IQcBackEndServiceStatisticsService _QcBackEndServiceStatisticsService;
|
|
|
|
|
|
|
|
|
|
|
|
public QcBackEndServiceStatisticsController(
|
|
|
|
|
|
IQcBackEndServiceStatisticsService QcBackEndServiceStatisticsService
|
|
|
|
|
|
)
|
|
|
|
|
|
{
|
|
|
|
|
|
_QcBackEndServiceStatisticsService = QcBackEndServiceStatisticsService;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 查询质量BackEnd统计报表业务模块列表
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="parm"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpGet("list")]
|
|
|
|
|
|
public IActionResult QueryQcBackEndServiceStatistics(
|
|
|
|
|
|
[FromQuery] QcBackEndServiceStatisticsQueryDto parm
|
|
|
|
|
|
)
|
|
|
|
|
|
{
|
|
|
|
|
|
var response = _QcBackEndServiceStatisticsService.GetList(parm);
|
|
|
|
|
|
return SUCCESS(response);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 查询质量BackEnd统计报表业务模块列表
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="parm"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpPost("GetReviseList")]
|
|
|
|
|
|
[AllowAnonymous]
|
|
|
|
|
|
public IActionResult GetReviseList([FromBody] QcBackEndServiceStatisticsQueryDto parm)
|
|
|
|
|
|
{
|
|
|
|
|
|
var response = _QcBackEndServiceStatisticsService.GetReviseList(parm);
|
|
|
|
|
|
|
|
|
|
|
|
// 初始化统计数据
|
|
|
|
|
|
int totalRequireNumber = 0;
|
|
|
|
|
|
int totalQualifiedNumber = 0;
|
|
|
|
|
|
int totalPolishNumber = 0;
|
|
|
|
|
|
int totalDamoNumber = 0;
|
|
|
|
|
|
int totalBaofeiNumber = 0;
|
|
|
|
|
|
int totalListCount = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// 将动态属性转换为字典并合并到主对象中,并计算统计数据
|
|
|
|
|
|
var resultWithDefects = response
|
|
|
|
|
|
.Select(item =>
|
|
|
|
|
|
{
|
|
|
|
|
|
var itemDict = new Dictionary<string, object>();
|
|
|
|
|
|
foreach (var prop in typeof(QcBackEndServiceStatisticsDto).GetProperties())
|
|
|
|
|
|
{
|
|
|
|
|
|
itemDict[prop.Name] = prop.GetValue(item);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 添加动态属性
|
|
|
|
|
|
foreach (var dynamicProp in item.DynamicProperties)
|
|
|
|
|
|
{
|
|
|
|
|
|
itemDict[dynamicProp.Key] = dynamicProp.Value;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 累加统计数据
|
|
|
|
|
|
totalRequireNumber += Convert.ToInt32(item.RequireNumber);
|
|
|
|
|
|
totalQualifiedNumber += Convert.ToInt32(item.QualifiedNumber);
|
|
|
|
|
|
totalPolishNumber += Convert.ToInt32(item.PolishNumber);
|
|
|
|
|
|
totalDamoNumber += Convert.ToInt32(item.DamoNumber);
|
|
|
|
|
|
totalBaofeiNumber += Convert.ToInt32(item.BaofeiNumber);
|
|
|
|
|
|
totalListCount += 1;
|
|
|
|
|
|
|
|
|
|
|
|
// 移除不要的属性
|
|
|
|
|
|
itemDict["DynamicProperties"] = null;
|
|
|
|
|
|
itemDict["GroupDefectJson"] = "";
|
|
|
|
|
|
return itemDict;
|
|
|
|
|
|
})
|
|
|
|
|
|
.ToList();
|
|
|
|
|
|
// 数据除三
|
|
|
|
|
|
totalRequireNumber = totalRequireNumber / 3;
|
|
|
|
|
|
totalQualifiedNumber = totalQualifiedNumber / 3;
|
|
|
|
|
|
totalPolishNumber = totalPolishNumber / 3;
|
|
|
|
|
|
totalDamoNumber = totalDamoNumber / 3;
|
|
|
|
|
|
totalBaofeiNumber = totalBaofeiNumber / 3;
|
|
|
|
|
|
totalListCount = totalListCount / 3;
|
|
|
|
|
|
// 计算合格率
|
|
|
|
|
|
double qualifiedRate = 0.0;
|
|
|
|
|
|
if (totalRequireNumber > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
qualifiedRate = (double)totalQualifiedNumber / totalRequireNumber * 100;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
qualifiedRate = 0.0;
|
|
|
|
|
|
}
|
|
|
|
|
|
// 创建统计数据字典
|
|
|
|
|
|
var statistics = new Dictionary<string, object>
|
|
|
|
|
|
{
|
|
|
|
|
|
{ "TotalRequireNumber", totalRequireNumber },
|
|
|
|
|
|
{ "TotalQualifiedNumber", totalQualifiedNumber },
|
|
|
|
|
|
{ "QualifiedRate", $"{qualifiedRate:F1}%" },
|
|
|
|
|
|
{ "TotalPolishNumber", totalPolishNumber },
|
|
|
|
|
|
{ "TotalDamoNumber", totalDamoNumber },
|
|
|
|
|
|
{ "TotalBaofeiNumber", totalBaofeiNumber },
|
|
|
|
|
|
{ "TotalListCount", totalListCount }
|
|
|
|
|
|
};
|
|
|
|
|
|
// 创建分页结果
|
|
|
|
|
|
var pageList = resultWithDefects.Skip((parm.PageNum - 1) * parm.PageSize).Take(parm.PageSize).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
// 返回包含数据和统计数据的对象
|
2025-07-28 15:40:59 +08:00
|
|
|
|
var result = new { statistics = statistics, pageList, total = resultWithDefects.Count };
|
2025-05-07 08:20:08 +08:00
|
|
|
|
|
|
|
|
|
|
return SUCCESS(result);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 查询质量BackEnd统计报表业务模块详情
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="Id"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpGet("{Id}")]
|
|
|
|
|
|
public IActionResult GetQcBackEndServiceStatistics(string Id)
|
|
|
|
|
|
{
|
|
|
|
|
|
var response = _QcBackEndServiceStatisticsService.GetInfo(Id);
|
|
|
|
|
|
|
|
|
|
|
|
var info = response.Adapt<QcBackEndServiceStatistics>();
|
|
|
|
|
|
return SUCCESS(info);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 添加质量BackEnd统计报表业务模块
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
|
[Log(Title = "质量BackEnd统计报表业务模块", BusinessType = BusinessType.INSERT)]
|
|
|
|
|
|
public IActionResult AddQcBackEndServiceStatistics([FromBody] QcBackEndServiceStatisticsDto parm)
|
|
|
|
|
|
{
|
|
|
|
|
|
var modal = parm.Adapt<QcBackEndServiceStatistics>().ToCreate(HttpContext);
|
|
|
|
|
|
|
|
|
|
|
|
var response = _QcBackEndServiceStatisticsService.AddQcBackEndServiceStatistics(modal);
|
|
|
|
|
|
|
|
|
|
|
|
return SUCCESS(response);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 更新质量BackEnd统计报表业务模块
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpPut]
|
|
|
|
|
|
[Log(Title = "质量BackEnd统计报表业务模块", BusinessType = BusinessType.UPDATE)]
|
|
|
|
|
|
public IActionResult UpdateQcBackEndServiceStatistics(
|
|
|
|
|
|
[FromBody] QcBackEndServiceStatisticsDto parm
|
|
|
|
|
|
)
|
|
|
|
|
|
{
|
|
|
|
|
|
var modal = parm.Adapt<QcBackEndServiceStatistics>().ToUpdate(HttpContext);
|
|
|
|
|
|
var response = _QcBackEndServiceStatisticsService.UpdateQcBackEndServiceStatistics(modal);
|
|
|
|
|
|
|
|
|
|
|
|
return ToResponse(response);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 删除质量BackEnd统计报表业务模块
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpDelete("{ids}")]
|
|
|
|
|
|
[Log(Title = "质量BackEnd统计报表业务模块", BusinessType = BusinessType.DELETE)]
|
|
|
|
|
|
public IActionResult DeleteQcBackEndServiceStatistics(string ids)
|
|
|
|
|
|
{
|
|
|
|
|
|
int[] idsArr = Tools.SpitIntArrary(ids);
|
|
|
|
|
|
if (idsArr.Length <= 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
return ToResponse(ApiResult.Error($"删除失败Id 不能为空"));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var response = _QcBackEndServiceStatisticsService.Delete(idsArr);
|
|
|
|
|
|
|
|
|
|
|
|
return ToResponse(response);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|