公司员工新增领导与普通员工之分

This commit is contained in:
fuenmao
2026-04-02 13:56:25 +08:00
parent 589dd0305b
commit aa50e569f0
4 changed files with 78 additions and 24 deletions
+3
View File
@@ -39,5 +39,8 @@ namespace SimpleAdmin.Application.Entity
/// <summary>单位 cm,保留两位小数</summary>
[SugarColumn(ColumnDescription = "身高(cm)", IsNullable = true)]
public decimal? Height { get; set; }
[SugarColumn(ColumnDescription = "1领导,2普通员工,3其他", IsNullable = true)]
public int? Type { get; set; }
}
}
@@ -1,4 +1,4 @@
// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
//
// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
// 1.请不要删除和修改根目录下的LICENSE文件。
@@ -44,6 +44,7 @@ namespace SimpleAdmin.Application.Services.Prescription.Dto
public DateTime CreateTime { get; set; }
public decimal TotalMedicineCost { get; set; }
public int? Type { get; set; }
}
// 辅助类:存储FIFO计算所需的入库记录信息
@@ -89,6 +90,7 @@ namespace SimpleAdmin.Application.Services.Prescription.Dto
public string EmployeeName { get; set; }
public long? RelationShip { get; set; }
public string RelationShipName { get; set; }
public int? Type { get; set; }
}
// 处方药材DTO
@@ -131,6 +133,7 @@ namespace SimpleAdmin.Application.Services.Prescription.Dto
/// 当 EmployeeIsTemp 为 true 或者前端直接传了员工名字时,后端可用此字段创建员工
/// </summary>
public string EmployeeName { get; set; }
public int? Type { get; set; }
}
// 处方药材输入DTO
public class PrescriptionHerbInputDto
@@ -150,6 +153,7 @@ namespace SimpleAdmin.Application.Services.Prescription.Dto
public decimal? Height { get; set; }
public long? RelationShip { get; set; }
public int? Type { get; set; }
}
// 关系类型DTO
@@ -1,4 +1,4 @@
// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
//
// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
// 1.请不要删除和修改根目录下的LICENSE文件。
@@ -213,7 +213,8 @@ public class PrescriptionService : DbRepository<Prescription>, IPrescriptionServ
CreateTime = p.CreateTime.Value,
EmployeeName = emp.Name,
CanEdit = false,
TotalMedicineCost = 0
TotalMedicineCost = 0,
Type = pe.Type
}).ToPagedListAsync(input.PageNum, input.PageSize);
if (!prescriptionPage.List.Any()) return prescriptionPage;
// 获取当前页所有处方的 Id
@@ -294,8 +295,8 @@ public class PrescriptionService : DbRepository<Prescription>, IPrescriptionServ
item.CanEdit = true;
}
//all += item.TotalMedicineCost;
// 家属加价 10%
if (item.PersonType == PersonType.Relative)
// 家属和普通员工加价 10%
if (item.PersonType == PersonType.Relative || item.Type == 2)
{
item.TotalMedicineCost = Math.Round(item.TotalMedicineCost * 1.1m, 2, MidpointRounding.AwayFromZero);
}
@@ -369,13 +370,14 @@ public class PrescriptionService : DbRepository<Prescription>, IPrescriptionServ
.Select((p, pe) => new
{
Id = p.Id,
IsRelative = pe.EmployeeId != null
IsRelative = pe.EmployeeId != null,
Type = pe.Type
})
.ToListAsync();
// 明确转换 key 为 long(处理 nullable)
var personInfoDict = personTmp
.ToDictionary(x => Convert.ToInt64(x.Id), x => x.IsRelative);
.ToDictionary(x => Convert.ToInt64(x.Id), x => new { x.IsRelative, x.Type });
// 7) FIFO 成本计算(按时间顺序已由 allIdsLong 保持)
foreach (var pidObj in allIdsLong)
@@ -402,9 +404,11 @@ public class PrescriptionService : DbRepository<Prescription>, IPrescriptionServ
// 处方级别保留 4 位小数
presCost = Math.Round(presCost, 4, MidpointRounding.AwayFromZero);
// 家属加价 10%(若字典缺失,默认不是家属)
var isRelative = personInfoDict.TryGetValue(pid, out var rel) && rel;
if (isRelative)
// 家属和普通员工加价 10%
personInfoDict.TryGetValue(pid, out var personInfo);
var isRelative = personInfo?.IsRelative ?? false;
var isOrdinary = personInfo?.Type == 2;
if (isRelative || isOrdinary)
{
presCost = Math.Round(presCost * 1.1m, 2, MidpointRounding.AwayFromZero);
}
@@ -554,7 +558,8 @@ public class PrescriptionService : DbRepository<Prescription>, IPrescriptionServ
EmployeeId = person.EmployeeId,
EmployeeName = employee?.Name,
RelationShip = person.RelationShip,
RelationShipName = RelationShipName.FirstOrDefault(t => t.Id == person.RelationShip)?.Name
RelationShipName = RelationShipName.FirstOrDefault(t => t.Id == person.RelationShip)?.Name,
Type = person.Type
},
DiagnosisResult = prescription.DiagnosisResult,
UserMedicinaAdvice = prescription.UserMedicinaAdvice,
@@ -689,16 +694,38 @@ public class PrescriptionService : DbRepository<Prescription>, IPrescriptionServ
if (input.Person.IsEmployee)
mappedEmployeeId = null;
var person = new Person
var dbPerson = await Context.Queryable<Person>().FirstAsync(p => p.Id == personId);
if (dbPerson != null)
{
Id = personId,
Name = input.Person?.Name,
Birthday = input.Person?.Birthday,
Height = input.Person?.Height,
RelationShip = input.Person?.RelationShip,
EmployeeId = mappedEmployeeId
};
await Context.Storageable(person).ExecuteCommandAsync();
dbPerson.Name = input.Person?.Name ?? dbPerson.Name;
dbPerson.Birthday = input.Person?.Birthday ?? dbPerson.Birthday;
dbPerson.Height = input.Person?.Height ?? dbPerson.Height;
dbPerson.RelationShip = input.Person?.RelationShip ?? dbPerson.RelationShip;
dbPerson.EmployeeId = mappedEmployeeId;
if (input.Person != null && input.Person.IsEmployee)
{
dbPerson.Type = input.Person?.Type;
}
else
{
dbPerson.Type = null;
}
await Context.Updateable(dbPerson).ExecuteCommandAsync();
}
else
{
var person = new Person
{
Id = personId,
Name = input.Person?.Name,
Birthday = input.Person?.Birthday,
Height = input.Person?.Height,
RelationShip = input.Person?.RelationShip,
EmployeeId = mappedEmployeeId,
Type = input.Person.IsEmployee ? input.Person?.Type : null
};
await Context.Insertable(person).ExecuteCommandAsync();
}
// ---------- 4. 处方保存/编辑逻辑----------
Prescription prescription;
@@ -831,7 +858,8 @@ public class PrescriptionService : DbRepository<Prescription>, IPrescriptionServ
Name = pe.Name,
Birthday = pe.Birthday,
Height = pe.Height,
RelationShip = pe.RelationShip
RelationShip = pe.RelationShip,
Type = pe.Type
}).ToListAsync();
}
/// <summary>
@@ -28,7 +28,8 @@ public class StatisticsService : DbRepository<Prescription>, IStatisticsService
{
p.Id,
p.PersonId,
IsRelative = pe.EmployeeId != null
IsRelative = pe.EmployeeId != null,
Type = pe.Type
})
.ToListAsync();
@@ -75,6 +76,11 @@ public class StatisticsService : DbRepository<Prescription>, IStatisticsService
familyCost += Math.Round(cost * 1.1m, 2, MidpointRounding.AwayFromZero);
familyQty++;
}
else if (pInfo.Type == 2)
{
staffCost += Math.Round(cost * 1.1m, 2, MidpointRounding.AwayFromZero);
staffQty++;
}
else
{
staffCost += Math.Round(cost, 2, MidpointRounding.AwayFromZero);
@@ -176,7 +182,8 @@ public class StatisticsService : DbRepository<Prescription>, IStatisticsService
p.Id,
p.VisitDate,
p.CreateTime,
IsRelative = pe.EmployeeId != null
IsRelative = pe.EmployeeId != null,
Type = pe.Type
})
.ToListAsync();
@@ -276,6 +283,12 @@ public class StatisticsService : DbRepository<Prescription>, IStatisticsService
monthlyFamilyCost[month] += cost;
monthlyFamilyQty[month]++;
}
else if (pInfo.Type == 2)
{
cost = Math.Round(cost * 1.1m, 2, MidpointRounding.AwayFromZero);
monthlyStaffCost[month] += cost;
monthlyStaffQty[month]++;
}
else
{
cost = Math.Round(cost, 2, MidpointRounding.AwayFromZero);
@@ -337,7 +350,8 @@ public class StatisticsService : DbRepository<Prescription>, IStatisticsService
{
p.Id,
p.PersonId,
IsRelative = pe.EmployeeId != null
IsRelative = pe.EmployeeId != null,
Type = pe.Type
})
.ToListAsync();
@@ -418,6 +432,11 @@ public class StatisticsService : DbRepository<Prescription>, IStatisticsService
familyCost += Math.Round(cost * 1.1m, 2, MidpointRounding.AwayFromZero);
familyQty++;
}
else if (pInfo.Type == 2)
{
staffCost += Math.Round(cost * 1.1m, 2, MidpointRounding.AwayFromZero);
staffQty++;
}
else
{
staffCost += Math.Round(cost, 2, MidpointRounding.AwayFromZero);