Browse Source

单位营业额

master
wxd 3 months ago
parent
commit
68f9b78882
  1. 22
      src/Shentun.Peis.Application.Contracts/CustomerReports/GetCustomerOrgPhysicalExaminationStatisticsDto.cs
  2. 5
      src/Shentun.Peis.Application.Contracts/CustomerReports/GetCustomerOrgPhysicalExaminationStatisticsInputDto.cs
  3. 62
      src/Shentun.Peis.Application/CustomerReports/CustomerReportAppService.cs
  4. 16487
      src/Shentun.Peis.EntityFrameworkCore/Migrations/20260108034622_update_asbitem_add_is_discount.Designer.cs
  5. 27
      src/Shentun.Peis.EntityFrameworkCore/Migrations/20260108034622_update_asbitem_add_is_discount.cs
  6. 7
      src/Shentun.Peis.EntityFrameworkCore/Migrations/PeisDbContextModelSnapshot.cs
  7. 27
      src/Shentun.Peis.HttpApi.Host/Controllers/AiMessageWsController.cs

22
src/Shentun.Peis.Application.Contracts/CustomerReports/GetCustomerOrgPhysicalExaminationStatisticsDto.cs

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json.Serialization;
namespace Shentun.Peis.CustomerReports
{
@ -12,9 +13,21 @@ namespace Shentun.Peis.CustomerReports
public string CustomerOrgName { get; set; }
/// <summary>
/// 单位Id
/// 部门名称
/// </summary>
public Guid CustomerOrgId { get; set; }
public string DepartmentName { get; set; }
///// <summary>
///// 单位Id
///// </summary>
//[JsonIgnore]
//public Guid CustomerOrgId { get; set; }
///// <summary>
///// 部门Id
///// </summary>
//[JsonIgnore]
//public Guid DepartmentId { get; set; }
/// <summary>
/// 人次 登记人数
@ -73,6 +86,11 @@ namespace Shentun.Peis.CustomerReports
/// </summary>
public Guid CustomerOrgId { get; set; }
/// <summary>
/// 部门Id
/// </summary>
public Guid DepartmentId { get; set; }
/// <summary>
/// 标准
/// </summary>

5
src/Shentun.Peis.Application.Contracts/CustomerReports/GetCustomerOrgPhysicalExaminationStatisticsInputDto.cs

@ -32,5 +32,10 @@ namespace Shentun.Peis.CustomerReports
/// 是否需要统计预登记 默认为N 不统计 需要统计传Y
/// </summary>
public char IsPreRegistration { get; set; }= 'N';
/// <summary>
/// 是否显示子级单位数据 Y-显示子级(按部门汇总) N-不显示子级(按一级单位分组) 默认Y
/// </summary>
public char IsChild { get; set; } = 'Y';
}
}

62
src/Shentun.Peis.Application/CustomerReports/CustomerReportAppService.cs

@ -2885,7 +2885,7 @@ namespace Shentun.Peis.CustomerReports
}).ToList();
entDto.AddItems = addItems;
}
return entDto;
@ -3406,32 +3406,60 @@ namespace Shentun.Peis.CustomerReports
StandardPrice = s.Sum(ss => ss.registerCheckAsbitem.StandardPrice * ss.registerCheckAsbitem.Amount),
ChargePrice = s.Sum(ss => ss.registerCheckAsbitem.ChargePrice * ss.registerCheckAsbitem.Amount),
ReceivedPrice = s.Where(m => m.registerCheckAsbitem.IsCharge == 'Y').Sum(ss => ss.registerCheckAsbitem.ChargePrice * ss.registerCheckAsbitem.Amount),
CustomerOrgId = s.First().customerOrg.Id,
CustomerOrgName = "",
CustomerOrgId = _cacheService.GetTopCustomerOrgAsync(s.First().customerOrg.Id).GetAwaiter().GetResult().Id,
DepartmentId = s.First().customerOrg.Id
//CustomerOrgId = _cacheService.GetTopCustomerOrgAsync(s.First().customerOrg.Id).GetAwaiter().GetResult().Id,
//CustomerOrgName = _cacheService.GetTopCustomerOrgAsync(s.First().customerOrg.Id).GetAwaiter().GetResult().DisplayName,
}).ToList();
var customerOrgGroup = patientRegisterGroupList.GroupBy(g => g.CustomerOrgId);
var customerOrgGrouplist = customerOrgGroup.Select(s => new GetCustomerOrgPhysicalExaminationStatisticsDto
if (input.IsChild == 'Y')
{
CustomerOrgId = _cacheService.GetTopCustomerOrgAsync(s.First().CustomerOrgId).GetAwaiter().GetResult().Id,
CustomerOrgName = _cacheService.GetTopCustomerOrgAsync(s.First().CustomerOrgId).GetAwaiter().GetResult().DisplayName,
PartCheckCount = s.Where(m => m.CompleteFlag == PatientRegisterCompleteFlag.PartCheck).Count(),
CheckCount = s.Where(m => m.CompleteFlag == PatientRegisterCompleteFlag.SumCheck).Count(),
RegisterCount = s.Count(),
AvgChargePrice = Math.Round(s.Average(v => v.ChargePrice), 2),
AvgStandardPrice = Math.Round(s.Average(v => v.StandardPrice), 2),
SumChargePrice = Math.Round(s.Sum(v => v.ChargePrice), 2),
SumReceivedPrice = Math.Round(s.Sum(v => v.ReceivedPrice), 2),
SumStandardPrice = Math.Round(s.Sum(v => v.StandardPrice), 2)
}).OrderByDescending(o => o.RegisterCount).ToList();
//按部门
var customerOrgGroup = patientRegisterGroupList.GroupBy(g => g.DepartmentId);
var customerOrgGrouplist = customerOrgGroup.Select(s => new GetCustomerOrgPhysicalExaminationStatisticsDto
{
DepartmentName = _cacheService.GetCustomerOrgNameAsync(s.First().DepartmentId).GetAwaiter().GetResult(),
CustomerOrgName = _cacheService.GetCustomerOrgNameAsync(s.First().CustomerOrgId).GetAwaiter().GetResult(),
PartCheckCount = s.Where(m => m.CompleteFlag == PatientRegisterCompleteFlag.PartCheck).Count(),
CheckCount = s.Where(m => m.CompleteFlag == PatientRegisterCompleteFlag.SumCheck).Count(),
RegisterCount = s.Count(),
AvgChargePrice = Math.Round(s.Average(v => v.ChargePrice), 2),
AvgStandardPrice = Math.Round(s.Average(v => v.StandardPrice), 2),
SumChargePrice = Math.Round(s.Sum(v => v.ChargePrice), 2),
SumReceivedPrice = Math.Round(s.Sum(v => v.ReceivedPrice), 2),
SumStandardPrice = Math.Round(s.Sum(v => v.StandardPrice), 2)
}).OrderByDescending(o => o.RegisterCount).ToList();
return customerOrgGrouplist;
return customerOrgGrouplist;
}
else
{
//按一级单位
var customerOrgGroup = patientRegisterGroupList.GroupBy(g => g.CustomerOrgId);
var customerOrgGrouplist = customerOrgGroup.Select(s => new GetCustomerOrgPhysicalExaminationStatisticsDto
{
DepartmentName = _cacheService.GetCustomerOrgNameAsync(s.First().DepartmentId).GetAwaiter().GetResult(),
CustomerOrgName = _cacheService.GetCustomerOrgNameAsync(s.First().CustomerOrgId).GetAwaiter().GetResult(),
PartCheckCount = s.Where(m => m.CompleteFlag == PatientRegisterCompleteFlag.PartCheck).Count(),
CheckCount = s.Where(m => m.CompleteFlag == PatientRegisterCompleteFlag.SumCheck).Count(),
RegisterCount = s.Count(),
AvgChargePrice = Math.Round(s.Average(v => v.ChargePrice), 2),
AvgStandardPrice = Math.Round(s.Average(v => v.StandardPrice), 2),
SumChargePrice = Math.Round(s.Sum(v => v.ChargePrice), 2),
SumReceivedPrice = Math.Round(s.Sum(v => v.ReceivedPrice), 2),
SumStandardPrice = Math.Round(s.Sum(v => v.StandardPrice), 2)
}).OrderByDescending(o => o.RegisterCount).ToList();
return customerOrgGrouplist;
}
}

16487
src/Shentun.Peis.EntityFrameworkCore/Migrations/20260108034622_update_asbitem_add_is_discount.Designer.cs
File diff suppressed because it is too large
View File

27
src/Shentun.Peis.EntityFrameworkCore/Migrations/20260108034622_update_asbitem_add_is_discount.cs

@ -0,0 +1,27 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Shentun.Peis.Migrations
{
public partial class update_asbitem_add_is_discount : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<char>(
name: "is_discount",
table: "asbitem",
type: "character(1)",
nullable: false,
defaultValueSql: "'Y'",
comment: "是否折扣");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "is_discount",
table: "asbitem");
}
}
}

7
src/Shentun.Peis.EntityFrameworkCore/Migrations/PeisDbContextModelSnapshot.cs

@ -567,6 +567,13 @@ namespace Shentun.Peis.Migrations
.HasDefaultValueSql("'N'")
.HasComment("启用诊断函数");
b.Property<char>("IsDiscount")
.ValueGeneratedOnAdd()
.HasColumnType("character(1)")
.HasColumnName("is_discount")
.HasDefaultValueSql("'Y'")
.HasComment("是否折扣");
b.Property<char>("IsFollowUpFunction")
.ValueGeneratedOnAdd()
.HasMaxLength(1)

27
src/Shentun.Peis.HttpApi.Host/Controllers/AiMessageWsController.cs

@ -16,6 +16,9 @@ using System.Net.Http;
using Volo.Abp;
using Newtonsoft.Json;
using System.Linq;
using Microsoft.AspNetCore.Cors;
using Castle.Core.Logging;
using Microsoft.Extensions.Logging;
namespace Shentun.Peis.Controllers
{
@ -24,19 +27,21 @@ namespace Shentun.Peis.Controllers
public class AiMessageWsController : ControllerBase
{
private readonly IRepository<ThirdInterface, Guid> _thirdInterfaceRepository;
private readonly ILogger<AiMessageWsController> _logger;
public AiMessageWsController(
IRepository<ThirdInterface, Guid> thirdInterfaceRepository
)
IRepository<ThirdInterface, Guid> thirdInterfaceRepository,
ILogger<AiMessageWsController> logger)
{
_thirdInterfaceRepository = thirdInterfaceRepository;
// 配置TLS1.2加密协议
System.Net.ServicePointManager.SecurityProtocol =
System.Net.SecurityProtocolType.Tls12;
_logger = logger;
}
/// <summary>
/// 获取Ai回复内容
@ -45,6 +50,7 @@ namespace Shentun.Peis.Controllers
/// <returns></returns>
/// <exception cref="UserFriendlyException"></exception>
[HttpPost("api/app/AiMessageWs/GetAIMessageResult")]
//[EnableCors("AllowAnyOrigin")]
public async Task GetAIMessageResultAsync(GetAIMessageResultInputDto input)
{
@ -111,7 +117,7 @@ namespace Shentun.Peis.Controllers
using var stream = await response.Content.ReadAsStreamAsync();
using var reader = new System.IO.StreamReader(stream);
while (!reader.EndOfStream)
{
var line = await reader.ReadLineAsync();
@ -121,15 +127,18 @@ namespace Shentun.Peis.Controllers
try
{
var streamResponse = JsonConvert.DeserializeObject<Root>(s1);
if (streamResponse?.choices?[0]?.delta?.content != null)
{
var contentPiece = streamResponse.choices[0].delta.content;
_logger.LogInformation($"--{contentPiece}--");
// 实时输出并格式化
contentPiece = FormatAndDisplay(contentPiece);
// contentPiece = FormatAndDisplay(contentPiece);
await Response.WriteAsync($"data: {contentPiece}\n\n");
///await Response.WriteAsync($"data: {contentPiece}");
await Response.WriteAsync(contentPiece);
await Response.Body.FlushAsync();
}
}
@ -155,6 +164,8 @@ namespace Shentun.Peis.Controllers
throw new UserFriendlyException("AI接口类型不正确");
}
await Response.CompleteAsync();
}

Loading…
Cancel
Save