- 新增 PayRoll(工资)、Wms(仓储)、Prod(车速/缫丝/考勤/丝片检测/丝片台账/纤检日报/质量日报) 模块 - 新增对应 Domain 实体、Application DTO/Service、Api Controller 与前端页面 - 移除旧 Attendance 考勤模块(Controller/Service/Entity/DTO 及 5 个前端页面),由 Prod/Kaoqin 取代 - 调整路由、仪表盘、Lsjl 流丝记录实体与服务 - 更新业务种子数据与 DbSeeder - 补充工作进度文档 14-27
144 lines
5.6 KiB
C#
144 lines
5.6 KiB
C#
using F9WebAiTest.Application.Common;
|
|
using F9WebAiTest.Application.Dtos.Prod;
|
|
using F9WebAiTest.Application.Services.Prod;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace F9WebAiTest.Api.Controllers.Prod;
|
|
|
|
/// <summary>
|
|
/// 生产-选剥茧(对应 F9 WinClient\F9.Business.Prod\XBJ):
|
|
/// 选茧日报(含盈亏 / 联统率)、选茧计划及其明细、选茧班组与班组职工。
|
|
/// </summary>
|
|
[ApiController]
|
|
[Route("api/prod/xjrb")]
|
|
[Authorize]
|
|
public class XjrbController : ControllerBase
|
|
{
|
|
private readonly IXjrbService _svc;
|
|
public XjrbController(IXjrbService svc) => _svc = svc;
|
|
|
|
private IActionResult Fail(ServiceException ex) => StatusCode(ex.Code, ApiResult<object>.Fail(ex.Message, ex.Code));
|
|
|
|
// ==================== 选茧日报 ====================
|
|
|
|
[HttpGet("")]
|
|
public async Task<IActionResult> List([FromQuery] DateTime? start = null, [FromQuery] DateTime? end = null,
|
|
[FromQuery] string like = "", [FromQuery] int pageIndex = 1, [FromQuery] int pageSize = 20)
|
|
=> Ok(ApiResult<PageResult<XjrbListDto>>.Ok(await _svc.GetPagedAsync(start, end, like ?? "", pageIndex, pageSize)));
|
|
|
|
[HttpGet("{id:long}")]
|
|
public async Task<IActionResult> Get(long id)
|
|
=> Ok(ApiResult<XjrbSaveDto>.Ok(await _svc.GetByIdAsync(id)));
|
|
|
|
[HttpPost("")]
|
|
public async Task<IActionResult> Save([FromBody] XjrbSaveDto dto)
|
|
{
|
|
try { return Ok(ApiResult<object>.Ok(new { id = await _svc.SaveAsync(dto) }, "保存成功")); }
|
|
catch (ServiceException ex) { return Fail(ex); }
|
|
}
|
|
|
|
[HttpDelete("{id:long}")]
|
|
public async Task<IActionResult> Delete(long id)
|
|
{
|
|
try
|
|
{
|
|
await _svc.DeleteAsync(id);
|
|
return Ok(ApiResult<object>.Ok(null, "删除成功"));
|
|
}
|
|
catch (ServiceException ex) { return Fail(ex); }
|
|
}
|
|
|
|
/// <summary>计算盈亏 / 联统率(前端保存前调用,把结果写入表单)</summary>
|
|
[HttpPost("count-yingkui")]
|
|
public async Task<IActionResult> CountYingkui([FromBody] XjrbSaveDto dto)
|
|
{
|
|
try { return Ok(ApiResult<XjrbYingkuiDto>.Ok(await _svc.CountYingkuiAsync(dto))); }
|
|
catch (ServiceException ex) { return Fail(ex); }
|
|
}
|
|
|
|
// ==================== 选茧计划 ====================
|
|
|
|
[HttpGet("plan")]
|
|
public async Task<IActionResult> PlanList([FromQuery] DateTime? start = null, [FromQuery] DateTime? end = null,
|
|
[FromQuery] string like = "", [FromQuery] int pageIndex = 1, [FromQuery] int pageSize = 20)
|
|
=> Ok(ApiResult<PageResult<XjrbPlanListDto>>.Ok(await _svc.GetPlanPagedAsync(start, end, like ?? "", pageIndex, pageSize)));
|
|
|
|
[HttpGet("plan/{id:long}")]
|
|
public async Task<IActionResult> PlanGet(long id)
|
|
=> Ok(ApiResult<XjrbPlanSaveDto>.Ok(await _svc.GetPlanByIdAsync(id)));
|
|
|
|
[HttpPost("plan")]
|
|
public async Task<IActionResult> PlanSave([FromBody] XjrbPlanSaveDto dto)
|
|
{
|
|
try { return Ok(ApiResult<object>.Ok(new { id = await _svc.SavePlanAsync(dto) }, "保存成功")); }
|
|
catch (ServiceException ex) { return Fail(ex); }
|
|
}
|
|
|
|
[HttpDelete("plan/{id:long}")]
|
|
public async Task<IActionResult> PlanDelete(long id)
|
|
{
|
|
try
|
|
{
|
|
await _svc.DeletePlanAsync(id);
|
|
return Ok(ApiResult<object>.Ok(null, "删除成功"));
|
|
}
|
|
catch (ServiceException ex) { return Fail(ex); }
|
|
}
|
|
|
|
// ==================== 选茧计划明细 ====================
|
|
|
|
[HttpGet("plan/{planId:long}/items")]
|
|
public async Task<IActionResult> PlanItems(long planId)
|
|
=> Ok(ApiResult<List<XjrbItemDto>>.Ok(await _svc.GetPlanItemsAsync(planId)));
|
|
|
|
[HttpPost("plan/item")]
|
|
public async Task<IActionResult> PlanItemSave([FromBody] XjrbItemSaveDto dto)
|
|
{
|
|
try { return Ok(ApiResult<object>.Ok(new { id = await _svc.SavePlanItemAsync(dto) }, "保存成功")); }
|
|
catch (ServiceException ex) { return Fail(ex); }
|
|
}
|
|
|
|
[HttpDelete("plan/item/{id:long}")]
|
|
public async Task<IActionResult> PlanItemDelete(long id)
|
|
{
|
|
try
|
|
{
|
|
await _svc.DeletePlanItemAsync(id);
|
|
return Ok(ApiResult<object>.Ok(null, "删除成功"));
|
|
}
|
|
catch (ServiceException ex) { return Fail(ex); }
|
|
}
|
|
|
|
/// <summary>计划维度盈亏(联统率按包数口径)</summary>
|
|
[HttpPost("plan/count-yingkui")]
|
|
public async Task<IActionResult> PlanCountYingkui([FromBody] XjrbItemSaveDto dto)
|
|
{
|
|
try { return Ok(ApiResult<XjrbYingkuiDto>.Ok(await _svc.CountPlanYingkuiAsync(dto))); }
|
|
catch (ServiceException ex) { return Fail(ex); }
|
|
}
|
|
|
|
// ==================== 选茧班组 ====================
|
|
|
|
[HttpGet("banzu")]
|
|
public async Task<IActionResult> BanzuList([FromQuery] string banci = "", [FromQuery] int? zu = null,
|
|
[FromQuery] int pageIndex = 1, [FromQuery] int pageSize = 20)
|
|
=> Ok(ApiResult<PageResult<XjpbBanzuDto>>.Ok(await _svc.GetBanzuPagedAsync(banci ?? "", zu, pageIndex, pageSize)));
|
|
|
|
[HttpGet("banzu/{id:long}/zhigong")]
|
|
public async Task<IActionResult> BanzuZhigong(long id)
|
|
=> Ok(ApiResult<List<XjpbBanzuZhigongDto>>.Ok(await _svc.GetBanzuZhigongAsync(id)));
|
|
|
|
/// <summary>班组「编辑录入」:按班次整体覆盖保存职工与组别</summary>
|
|
[HttpPost("banzu/zhigong")]
|
|
public async Task<IActionResult> BanzuZhigongSave([FromBody] List<XjpbBanzuZhigongSaveDto> dtos)
|
|
{
|
|
try
|
|
{
|
|
await _svc.SaveBanzuZhigongAsync(dtos ?? new List<XjpbBanzuZhigongSaveDto>());
|
|
return Ok(ApiResult<object>.Ok(null, "保存成功"));
|
|
}
|
|
catch (ServiceException ex) { return Fail(ex); }
|
|
}
|
|
}
|