- 新增 PayRoll(工资)、Wms(仓储)、Prod(车速/缫丝/考勤/丝片检测/丝片台账/纤检日报/质量日报) 模块 - 新增对应 Domain 实体、Application DTO/Service、Api Controller 与前端页面 - 移除旧 Attendance 考勤模块(Controller/Service/Entity/DTO 及 5 个前端页面),由 Prod/Kaoqin 取代 - 调整路由、仪表盘、Lsjl 流丝记录实体与服务 - 更新业务种子数据与 DbSeeder - 补充工作进度文档 14-27
226 lines
9.0 KiB
C#
226 lines
9.0 KiB
C#
using F9WebAiTest.Application.Common;
|
|
using F9WebAiTest.Application.Dtos.PayRoll;
|
|
using F9WebAiTest.Domain.Common;
|
|
using F9WebAiTest.Domain.Entities.PayRoll;
|
|
using SysDept = F9WebAiTest.Domain.Entities.SYS.Departments;
|
|
using SysEmp = F9WebAiTest.Domain.Entities.SYS.Employees;
|
|
using SysWt = F9WebAiTest.Domain.Entities.SYS.WorkTypes;
|
|
|
|
namespace F9WebAiTest.Application.Services.PayRoll;
|
|
|
|
/// <summary>薪资配置-账期(CONFZQ):考勤统计的「前缫出勤天数」来源</summary>
|
|
public interface IConfZqService
|
|
{
|
|
Task<List<ConfZqDto>> GetListAsync(int? year);
|
|
Task<ConfZqDto> GetByYearMonthAsync(int year, int month);
|
|
Task<long> SaveAsync(ConfZqDto dto);
|
|
Task DeleteAsync(long id);
|
|
}
|
|
|
|
/// <summary>薪资配置-职工(CONFEMPLOYEE):法定假小时数 / 是否学工</summary>
|
|
public interface IConfEmployeeService
|
|
{
|
|
Task<List<ConfEmployeeDto>> GetListAsync(long? employeeId, long? worktypeId);
|
|
Task<long> SaveAsync(ConfEmployeeDto dto);
|
|
Task DeleteAsync(long id);
|
|
}
|
|
|
|
/// <summary>岗位胜任考核:考核结果决定加班费单价档位</summary>
|
|
public interface IGwsrkhService
|
|
{
|
|
Task<List<GwsrkhDto>> GetListAsync(int year, int month, long depId);
|
|
Task<long> SaveAsync(GwsrkhDto dto);
|
|
Task DeleteAsync(long id);
|
|
}
|
|
|
|
public class ConfZqService : IConfZqService
|
|
{
|
|
private readonly IRepository<ConfZq> _repo;
|
|
public ConfZqService(IRepository<ConfZq> repo) => _repo = repo;
|
|
|
|
public async Task<List<ConfZqDto>> GetListAsync(int? year)
|
|
{
|
|
var all = await _repo.GetAllAsync();
|
|
var q = all.AsQueryable();
|
|
if (year.HasValue) q = q.Where(x => x.Year == year.Value);
|
|
return q.ToList().OrderByDescending(x => x.Year).ThenByDescending(x => x.Month)
|
|
.Select(x => new ConfZqDto
|
|
{
|
|
Id = x.Id, Year = x.Year, Month = x.Month,
|
|
QsQuanqinDays = x.QsQuanqinDays, Memo = x.Memo ?? ""
|
|
}).ToList();
|
|
}
|
|
|
|
public async Task<ConfZqDto> GetByYearMonthAsync(int year, int month)
|
|
{
|
|
var hit = await _repo.FirstOrDefaultAsync(x => x.Year == year && x.Month == month);
|
|
return hit == null
|
|
? new ConfZqDto { Year = year, Month = month }
|
|
: new ConfZqDto { Id = hit.Id, Year = hit.Year, Month = hit.Month, QsQuanqinDays = hit.QsQuanqinDays, Memo = hit.Memo ?? "" };
|
|
}
|
|
|
|
public async Task<long> SaveAsync(ConfZqDto dto)
|
|
{
|
|
if (dto.Year <= 0 || dto.Month <= 0) throw new ServiceException("请填写年度与月份");
|
|
var exist = await _repo.FirstOrDefaultAsync(x => x.Year == dto.Year && x.Month == dto.Month && x.Id != dto.Id);
|
|
if (exist != null) throw new ServiceException($"{dto.Year} 年 {dto.Month} 月的账期薪资配置已存在");
|
|
|
|
ConfZq entity;
|
|
if (dto.Id > 0)
|
|
{
|
|
entity = await _repo.GetByIdAsync(dto.Id);
|
|
if (entity == null) throw new ServiceException("配置不存在", 404);
|
|
}
|
|
else entity = new ConfZq();
|
|
|
|
entity.Year = dto.Year;
|
|
entity.Month = dto.Month;
|
|
entity.QsQuanqinDays = dto.QsQuanqinDays;
|
|
entity.Memo = dto.Memo ?? "";
|
|
|
|
if (dto.Id > 0) await _repo.UpdateAsync(entity); else await _repo.AddAsync(entity);
|
|
return entity.Id;
|
|
}
|
|
|
|
public async Task DeleteAsync(long id)
|
|
{
|
|
var e = await _repo.GetByIdAsync(id);
|
|
if (e == null) throw new ServiceException("配置不存在", 404);
|
|
await _repo.DeleteAsync(e);
|
|
}
|
|
}
|
|
|
|
public class ConfEmployeeService : IConfEmployeeService
|
|
{
|
|
private readonly IRepository<ConfEmployee> _repo;
|
|
private readonly IRepository<SysEmp.Employee> _empRepo;
|
|
private readonly IRepository<SysWt.WorkType> _wtRepo;
|
|
|
|
public ConfEmployeeService(IRepository<ConfEmployee> repo, IRepository<SysEmp.Employee> empRepo,
|
|
IRepository<SysWt.WorkType> wtRepo)
|
|
{
|
|
_repo = repo; _empRepo = empRepo; _wtRepo = wtRepo;
|
|
}
|
|
|
|
public async Task<List<ConfEmployeeDto>> GetListAsync(long? employeeId, long? worktypeId)
|
|
{
|
|
var all = await _repo.GetAllAsync();
|
|
var q = all.AsQueryable();
|
|
if (employeeId.HasValue && employeeId.Value > 0) q = q.Where(x => x.EmployeeId == employeeId.Value);
|
|
if (worktypeId.HasValue && worktypeId.Value > 0) q = q.Where(x => x.WorktypeId == worktypeId.Value);
|
|
var emps = (await _empRepo.GetAllAsync()).ToDictionary(e => e.Id);
|
|
var wts = (await _wtRepo.GetAllAsync()).ToDictionary(w => w.Id, w => w.WorkName);
|
|
return q.ToList().OrderBy(x => x.EmployeeId).Select(x => new ConfEmployeeDto
|
|
{
|
|
Id = x.Id,
|
|
EmployeeId = x.EmployeeId,
|
|
EmployeeCode = emps.TryGetValue(x.EmployeeId, out var e) ? (e.Code ?? "") : "",
|
|
EmployeeName = emps.TryGetValue(x.EmployeeId, out var e2) ? (e2.Name ?? "") : "",
|
|
WorktypeId = x.WorktypeId,
|
|
WorktypeName = wts.TryGetValue(x.WorktypeId, out var wn) ? wn : "",
|
|
HoursFadingBz = x.HoursFadingBz,
|
|
HoursFadingGz = x.HoursFadingGz,
|
|
IsXuegong = x.IsXuegong,
|
|
Memo = x.Memo ?? ""
|
|
}).ToList();
|
|
}
|
|
|
|
public async Task<long> SaveAsync(ConfEmployeeDto dto)
|
|
{
|
|
if (dto.EmployeeId <= 0) throw new ServiceException("请选择职工");
|
|
var exist = await _repo.FirstOrDefaultAsync(x => x.EmployeeId == dto.EmployeeId && x.WorktypeId == dto.WorktypeId && x.Id != dto.Id);
|
|
if (exist != null) throw new ServiceException("该职工该工种的薪资配置已存在");
|
|
|
|
ConfEmployee entity;
|
|
if (dto.Id > 0)
|
|
{
|
|
entity = await _repo.GetByIdAsync(dto.Id);
|
|
if (entity == null) throw new ServiceException("配置不存在", 404);
|
|
}
|
|
else entity = new ConfEmployee();
|
|
|
|
entity.EmployeeId = dto.EmployeeId;
|
|
entity.WorktypeId = dto.WorktypeId;
|
|
entity.HoursFadingBz = dto.HoursFadingBz;
|
|
entity.HoursFadingGz = dto.HoursFadingGz;
|
|
entity.IsXuegong = dto.IsXuegong;
|
|
entity.Memo = dto.Memo ?? "";
|
|
|
|
if (dto.Id > 0) await _repo.UpdateAsync(entity); else await _repo.AddAsync(entity);
|
|
return entity.Id;
|
|
}
|
|
|
|
public async Task DeleteAsync(long id)
|
|
{
|
|
var e = await _repo.GetByIdAsync(id);
|
|
if (e == null) throw new ServiceException("配置不存在", 404);
|
|
await _repo.DeleteAsync(e);
|
|
}
|
|
}
|
|
|
|
public class GwsrkhService : IGwsrkhService
|
|
{
|
|
private readonly IRepository<Gwsrkh> _repo;
|
|
private readonly IRepository<SysDept.Department> _depRepo;
|
|
private readonly IRepository<SysEmp.Employee> _empRepo;
|
|
|
|
public GwsrkhService(IRepository<Gwsrkh> repo, IRepository<SysDept.Department> depRepo,
|
|
IRepository<SysEmp.Employee> empRepo)
|
|
{
|
|
_repo = repo; _depRepo = depRepo; _empRepo = empRepo;
|
|
}
|
|
|
|
public async Task<List<GwsrkhDto>> GetListAsync(int year, int month, long depId)
|
|
{
|
|
var all = await _repo.GetAllAsync();
|
|
var q = all.AsQueryable().Where(x => x.Year == year && x.Month == month);
|
|
if (depId > 0) q = q.Where(x => x.DepId == depId);
|
|
var depts = (await _depRepo.GetAllAsync()).ToDictionary(d => d.Id, d => d.Name);
|
|
var emps = (await _empRepo.GetAllAsync()).ToDictionary(e => e.Id);
|
|
return q.ToList().OrderBy(x => x.EmployeeId).Select(x => new GwsrkhDto
|
|
{
|
|
Id = x.Id, Year = x.Year, Month = x.Month,
|
|
DepId = x.DepId, DepName = depts.TryGetValue(x.DepId, out var dn) ? dn : "",
|
|
EmployeeId = x.EmployeeId,
|
|
EmployeeCode = emps.TryGetValue(x.EmployeeId, out var e) ? (e.Code ?? "") : "",
|
|
EmployeeName = emps.TryGetValue(x.EmployeeId, out var e2) ? (e2.Name ?? "") : "",
|
|
KhJieguo = x.KhJieguo ?? "",
|
|
Memo = x.Memo ?? ""
|
|
}).ToList();
|
|
}
|
|
|
|
public async Task<long> SaveAsync(GwsrkhDto dto)
|
|
{
|
|
if (dto.EmployeeId <= 0) throw new ServiceException("请选择职工");
|
|
if (string.IsNullOrWhiteSpace(dto.KhJieguo)) throw new ServiceException("请选择考核结果");
|
|
var exist = await _repo.FirstOrDefaultAsync(x => x.Year == dto.Year && x.Month == dto.Month
|
|
&& x.EmployeeId == dto.EmployeeId && x.Id != dto.Id);
|
|
if (exist != null) throw new ServiceException("该职工本月考核结果已存在");
|
|
|
|
Gwsrkh entity;
|
|
if (dto.Id > 0)
|
|
{
|
|
entity = await _repo.GetByIdAsync(dto.Id);
|
|
if (entity == null) throw new ServiceException("记录不存在", 404);
|
|
}
|
|
else entity = new Gwsrkh();
|
|
|
|
entity.Year = dto.Year;
|
|
entity.Month = dto.Month;
|
|
entity.DepId = dto.DepId;
|
|
entity.EmployeeId = dto.EmployeeId;
|
|
entity.KhJieguo = dto.KhJieguo.Trim();
|
|
entity.Memo = dto.Memo ?? "";
|
|
|
|
if (dto.Id > 0) await _repo.UpdateAsync(entity); else await _repo.AddAsync(entity);
|
|
return entity.Id;
|
|
}
|
|
|
|
public async Task DeleteAsync(long id)
|
|
{
|
|
var e = await _repo.GetByIdAsync(id);
|
|
if (e == null) throw new ServiceException("记录不存在", 404);
|
|
await _repo.DeleteAsync(e);
|
|
}
|
|
}
|