完善机组车台功能,并导入机组车台 / 车间班次数据
一、机组车台功能完善 - 车间下拉改为只取「前缫」职责类型的部门(新增接口 /api/jizuchetai/qianxian-deps) - 补齐校验:车间、机组号、开始车台号必填;结束车台号不得小于开始车台号;同车间同机组不可重复 - 前端页面同步调整:车间改为下拉选择、增加必填提示、表格加 row-key 二、数据导入(新增 ProdSeedData,幂等导入器) - biz_prod_qs_jzct:机组车台 35 条(其中 11 条已删除)→ 有效 24 条 - biz_prod_qs_cjbc:车间班次 7 条(其中 1 条已删除)→ 有效 6 条 - F9 的部门 Id 通过部门名称映射到本系统部门;已删除的数据不导入; 已存在且一致的数据不重复写入,缺失的自动补回
This commit is contained in:
@@ -84,3 +84,10 @@ public class JizuChetaiDto
|
||||
public int ChetaiStart { get; set; }
|
||||
public int ChetaiEnd { get; set; }
|
||||
}
|
||||
|
||||
// ---- 部门下拉项(机组车台等模块选用车间)----
|
||||
public class DeptOptionDto
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public string Name { get; set; } = "";
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ using F9WebAiTest.Application.Dtos.Base;
|
||||
using F9WebAiTest.Domain.Common;
|
||||
using F9WebAiTest.Domain.Entities;
|
||||
using F9WebAiTest.Domain.Entities.Base;
|
||||
using F9WebAiTest.Domain.Enums.SYS.Departments;
|
||||
using SysDept = F9WebAiTest.Domain.Entities.SYS.Departments;
|
||||
|
||||
namespace F9WebAiTest.Application.Services.Base;
|
||||
@@ -251,6 +252,9 @@ public interface IJizuChetaiService
|
||||
Task<JizuChetaiDto> CreateAsync(JizuChetaiDto dto);
|
||||
Task<JizuChetaiDto> UpdateAsync(long id, JizuChetaiDto dto);
|
||||
Task DeleteAsync(long id);
|
||||
|
||||
/// <summary>车间下拉:只取职责类型为「前缫」的部门</summary>
|
||||
Task<List<DeptOptionDto>> GetQianxianDepsAsync();
|
||||
}
|
||||
|
||||
public class JizuChetaiService : IJizuChetaiService
|
||||
@@ -296,6 +300,7 @@ public class JizuChetaiService : IJizuChetaiService
|
||||
|
||||
public async Task<JizuChetaiDto> CreateAsync(JizuChetaiDto dto)
|
||||
{
|
||||
await ValidateAsync(dto, 0);
|
||||
var e = new JizuChetai { DepartmentId = dto.DepartmentId, Jizu = dto.Jizu, ChetaiStart = dto.ChetaiStart, ChetaiEnd = dto.ChetaiEnd };
|
||||
await _repo.AddAsync(e);
|
||||
await _repo.SaveChangesAsync();
|
||||
@@ -306,12 +311,36 @@ public class JizuChetaiService : IJizuChetaiService
|
||||
{
|
||||
var e = await _repo.GetByIdAsync(id);
|
||||
if (e == null) throw new ServiceException("记录不存在", 404);
|
||||
await ValidateAsync(dto, id);
|
||||
e.DepartmentId = dto.DepartmentId; e.Jizu = dto.Jizu; e.ChetaiStart = dto.ChetaiStart; e.ChetaiEnd = dto.ChetaiEnd;
|
||||
await _repo.UpdateAsync(e);
|
||||
await _repo.SaveChangesAsync();
|
||||
return await GetDto(e);
|
||||
}
|
||||
|
||||
/// <summary>校验:车间、机组号、车台范围必填且合理,同一车间的机组不可重复</summary>
|
||||
private async Task ValidateAsync(JizuChetaiDto dto, long excludeId)
|
||||
{
|
||||
if (dto.DepartmentId <= 0) throw new ServiceException("请选择车间");
|
||||
if (dto.Jizu <= 0) throw new ServiceException("机组号必须大于 0");
|
||||
if (dto.ChetaiStart <= 0) throw new ServiceException("开始车台号必须大于 0");
|
||||
if (dto.ChetaiEnd < dto.ChetaiStart) throw new ServiceException("结束车台号不能小于开始车台号");
|
||||
|
||||
var all = await _repo.GetAllAsync();
|
||||
if (all.Any(x => x.Id != excludeId && x.DepartmentId == dto.DepartmentId && x.Jizu == dto.Jizu))
|
||||
throw new ServiceException("该车间的此机组已存在,请勿重复配置");
|
||||
}
|
||||
|
||||
public async Task<List<DeptOptionDto>> GetQianxianDepsAsync()
|
||||
{
|
||||
var depts = await _deptRepo.GetAllAsync();
|
||||
return depts
|
||||
.Where(d => d.DutyType == Department_DutyType_Enum.前缫)
|
||||
.OrderBy(d => d.SortOrder).ThenBy(d => d.Id)
|
||||
.Select(d => new DeptOptionDto { Id = d.Id, Name = d.Name })
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public async Task DeleteAsync(long id)
|
||||
{
|
||||
var e = await _repo.GetByIdAsync(id);
|
||||
|
||||
Reference in New Issue
Block a user