学 赵 1 year ago
parent
commit
6301a5014d
  1. 41
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Program.cs
  2. 39
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Startup.cs
  3. 1
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/bbac-edi-se-compare.js
  4. 93
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/inventory/backup.js
  5. 105
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/inventory/balance.js
  6. 70
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/inventory/log.js
  7. 88
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/inventory/vmi.js
  8. 2
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/router/business.js
  9. 2
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/inventory/log.js
  10. 44
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/HBPO_SA_DTO.cs
  11. 15
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_SA_SERVICE.cs
  12. 82
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/JobItemAppService.cs
  13. 11
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs
  14. 284
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs
  15. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/MaterialRelationships/MaterialRelationshipAppService.cs
  16. 7
      code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.csproj
  17. 92
      code/src/Modules/SettleAccount/src/SettleAccount.Application/influxdb/InfluxHelper.cs
  18. 28
      code/src/Modules/SettleAccount/src/SettleAccount.Application/influxdb/InfluxQueryResult.cs
  19. 1
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/JobItem.cs
  20. 57
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/VmiBalance.cs
  21. 63
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/VmiLog.cs
  22. 26
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContextModelCreatingExtensions.cs
  23. 4683
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230726065932_vmi4.Designer.cs
  24. 202
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230726065932_vmi4.cs
  25. 4966
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230727005325_vmi5.Designer.cs
  26. 24
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230727005325_vmi5.cs
  27. 71
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/SettleAccountDbContextModelSnapshot.cs

41
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Program.cs

@ -1,11 +1,9 @@
using System;
using System.IO;
using Magicodes.ExporterAndImporter.Excel.Utility.TemplateExport;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Serilog;
using Serilog.Events;
using Win.Sfs.SettleAccount.influxdb;
namespace Win.Sfs.SettleAccount
{
@ -13,37 +11,24 @@ namespace Win.Sfs.SettleAccount
{
public static int Main(string[] args)
{
// Log.Logger = new LoggerConfiguration()
//#if DEBUG
// .MinimumLevel.Debug()
//#else
// .MinimumLevel.Information()
//#endif
// .MinimumLevel.Override("Microsoft", LogEventLevel.Information)
// .Enrich.FromLogContext()
// .WriteTo.Async(c => c.File("Logs/logs.txt"))
//#if DEBUG
// .WriteTo.Async(c => c.Console())
//#endif
// .CreateLogger();
var configuration = new ConfigurationBuilder()
//#if DEBUG
// .AddJsonFile("appsettings.Development.json")
//#else
// .AddJsonFile("appsettings.json")
//#endif
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")}.json", optional: true, reloadOnChange: true)
.Build();
try
{
new InfluxHelper(configuration).Start().Query("create database vmi").Wait();
}
catch (Exception ex)
{
throw new Exception("influxdb 启动失败", ex);
}
Log.Logger = new LoggerConfiguration()
.ReadFrom.Configuration(configuration)
.WriteTo.Async(c => c.Console())
.CreateLogger();
try
{
Log.Information("Starting web host.");
@ -67,12 +52,10 @@ namespace Win.Sfs.SettleAccount
{
webBuilder.ConfigureKestrel((context, options) =>
{
//设置应用服务器Kestrel请求体最大为50MB
options.Limits.MaxRequestBodySize = 5242880000;
options.Limits.MaxRequestBufferSize = 302768;
options.Limits.MaxRequestLineSize = 302768;
options.Limits.MaxRequestLineSize = 302768;
});
webBuilder.UseStartup<Startup>();
})

39
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Startup.cs

@ -20,7 +20,7 @@ public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddSignalR(o => o.EnableDetailedErrors=true);
services.AddSignalR(o => o.EnableDetailedErrors = true);
AppDomain.CurrentDomain.GetAssemblies().SelectMany(o => o.GetTypes())
.Where(o => o.IsClass && !o.IsAbstract && o.IsAssignableTo(typeof(IJobService)))
.ForEach(o => services.AddTransient(o));
@ -65,25 +65,28 @@ public class Startup
var jobItemRepository = db.Set<JobItem>();
var jobLogRepository = db.Set<JobLog>();
var jobItem = jobItemRepository.FirstOrDefault(o => o.Id == jobId);
jobItem.IsRunning = true;
db.SaveChanges();
var jobLog = new JobLog { JobId = jobId, Start = DateTime.Now };
try
if (!jobItem.IsDisabled)
{
jobService.Invoke();
jobLog.Success = true;
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
jobLog.Exception = ex.ToString();
}
finally
{
jobLog.End = DateTime.Now;
jobLogRepository.Add(jobLog);
jobItem.IsRunning = false;
jobItem.IsRunning = true;
db.SaveChanges();
var jobLog = new JobLog { JobId = jobId, Start = DateTime.Now };
try
{
jobService.Invoke();
jobLog.Success = true;
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
jobLog.Exception = ex.ToString();
}
finally
{
jobLog.End = DateTime.Now;
jobLogRepository.Add(jobLog);
jobItem.IsRunning = false;
db.SaveChanges();
}
}
}).Cron(job.Cron);
}

1
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/bbac-edi-se-compare.js

@ -54,7 +54,6 @@ export default function () {
query: {
url: queryUrl,
method: queryMethod,
autoSubmit: true,
disableQueryOnLoad: true,
schema: {

93
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/inventory/backup.js

@ -1,52 +1,15 @@
const schema = {
title: "通用代码",
type: "object",
properties: {
project: {
title: "项目",
type: "string",
readOnly: true,
showForList: true,
rules: [
{
required: true,
},
],
},
value: {
title: "值",
type: "string",
readOnly: true,
showForList: true,
rules: [
{
required: true,
},
],
},
description: {
title: "描述",
type: "string",
input: "textarea",
showForList: true,
rules: [
{
required: true,
},
{ max: 60 },
],
},
},
};
import useVmi from "./vmi.js";
const baseUrl = "settleaccount/code-setting";
const queryUrl = `${baseUrl}/get-list`;
const schema = useVmi();
const baseUrl = "settleaccount/vmi";
const queryUrl = `${baseUrl}/backup`;
const detailsUrl = `${baseUrl}/get/%s`;
const createUrl = `${baseUrl}/create`;
const updateUrl = `${baseUrl}/update/%s`;
const deleteUrl = `${baseUrl}/delete-list`;
const importUrl = `${baseUrl}/code-setting-upload-excel-import`;
const exportUrl = `${baseUrl}/export`;
const exportUrl = `${baseUrl}/backup-export`;
const queryMethod = "POST";
const detailsMethod = "POST";
const createMethod = "POST";
@ -61,10 +24,22 @@ export default function () {
url: queryUrl,
method: queryMethod,
hasFilter: true,
autoSubmit: true,
disableQueryOnLoad: true,
schema: {
title: "通用代码",
title: "时点库存余额查询",
type: "object",
properties: {
name: {
title: "时间",
type: "string",
input: "select",
url: "settleaccount/vmi/snapshot",
value: "name",
label: "name",
defaultSelected: true,
clearable: false,
},
filters: {
title: "项目",
type: "array",
@ -89,7 +64,35 @@ export default function () {
default: [
{
logic: "and",
column: "project",
column: "erpToLoc",
action: "like",
value: null,
readOnly: true,
},
{
logic: "and",
column: "lu",
action: "like",
value: null,
readOnly: true,
},
{
logic: "and",
column: "vinCode",
action: "like",
value: null,
readOnly: true,
},
{
logic: "and",
column: "codeType",
action: "like",
value: null,
readOnly: true,
},
{
logic: "and",
column: "proType",
action: "like",
value: null,
readOnly: true,

105
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/inventory/balance.js

@ -1,75 +1,6 @@
const schema = {
title: "寄售库存",
type: "object",
properties: {
id: {
type: "string",
hidden: true,
},
erpToLoc: {
title: "ERP库位",
type: "string",
},
lu: {
title: "LU零件号",
type: "string",
},
partCode: {
title: "客户零件号",
type: "string",
},
vinCode: {
title: "生产码",
type: "string",
},
codeType: {
title: "生产码类型",
type: "string",
},
proType: {
title: "发货类型",
type: "string",
},
qty: {
title: "数量",
type: "string",
},
shippingDate: {
title: "发运日期",
type: "string",
input: "date",
},
creationTime: {
title: "订单日期",
type: "string",
input: "date",
},
seqNumber: {
title: "EDI顺序号",
type: "string",
},
tmpe4: {
title: "客户订单号",
type: "string",
},
uniqueCode: {
title: "塑件唯一码",
type: "string",
},
matchNumber: {
title: "EDI总成号",
type: "string",
},
pjsNum: {
title: "PJIS生产顺序号",
type: "string",
},
desc: {
title: "备注",
type: "string",
},
},
};
import useVmi from "./vmi.js";
const schema = useVmi();
const baseUrl = "settleaccount/vmi";
const queryUrl = `${baseUrl}/balance`;
@ -78,7 +9,7 @@ const createUrl = `${baseUrl}/create`;
const updateUrl = `${baseUrl}/update/%s`;
const deleteUrl = `${baseUrl}/delete-list`;
const importUrl = `${baseUrl}/code-setting-upload-excel-import`;
const exportUrl = `${baseUrl}/export`;
const exportUrl = `${baseUrl}/balance-export`;
const queryMethod = "POST";
const detailsMethod = "POST";
const createMethod = "POST";
@ -126,6 +57,34 @@ export default function () {
value: null,
readOnly: true,
},
{
logic: "and",
column: "lu",
action: "like",
value: null,
readOnly: true,
},
{
logic: "and",
column: "vinCode",
action: "like",
value: null,
readOnly: true,
},
{
logic: "and",
column: "codeType",
action: "like",
value: null,
readOnly: true,
},
{
logic: "and",
column: "proType",
action: "like",
value: null,
readOnly: true,
},
],
},
skipCount: {

70
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/inventory/record.js → code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/inventory/log.js

@ -1,46 +1,52 @@
//变动单据号、发生时间、生产码类型、、订单号、库位、变动数、EDI顺序号、备注、变动类型(In、Out标识)、发货类型(JIS\JIT\买单件\备件等)、
//实扣LU零件号、实扣客户零件号、结算LU零件号、结算客户零件号、实扣生产码、结算生产码
//库位、开始结束时间段、发货类型、生产码、生产码类型、LU零件号、订单号
const schema = {
title: "通用代码",
title: "库存事务日志",
type: "object",
properties: {
project: {
title: "项目",
orderNumber: {
title: "变动单号",
type: "string",
readOnly: true,
showForList: true,
rules: [
{
required: true,
},
],
},
value: {
title: "",
CreatedDate: {
title: "发生时间",
type: "string",
readOnly: true,
showForList: true,
rules: [
{
required: true,
},
],
},
description: {
title: "描述",
CodeType: {
title: "生产码类型",
type: "string",
},
Tmpe4: {
title: "订单号",
type: "string",
},
ErpToLoc: {
title: "库位",
type: "string",
},
Count: {
title: "变动数",
type: "number",
},
ProType: {
title: "变动单号",
type: "发货类型",
},
VinCode: {
title: "生产码",
type: "string",
},
LU: {
title: "LU零件号",
type: "string",
input: "textarea",
showForList: true,
rules: [
{
required: true,
},
{ max: 60 },
],
},
},
};
const baseUrl = "settleaccount/code-setting";
const queryUrl = `${baseUrl}/get-list`;
const baseUrl = "settleaccount/vmi";
const queryUrl = `${baseUrl}/log`;
const detailsUrl = `${baseUrl}/get/%s`;
const createUrl = `${baseUrl}/create`;
const updateUrl = `${baseUrl}/update/%s`;
@ -89,7 +95,7 @@ export default function () {
default: [
{
logic: "and",
column: "project",
column: "erpToLoc",
action: "like",
value: null,
readOnly: true,

88
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/inventory/vmi.js

@ -0,0 +1,88 @@
export default function () {
return {
title: "寄售库存",
type: "object",
properties: {
// id: {
// type: "string",
// hidden: true,
// showForList: false,
// },
erpToLoc: {
title: "ERP库位",
type: "string",
},
lu: {
title: "LU零件号",
type: "string",
},
partCode: {
title: "客户零件号",
type: "string",
},
vinCode: {
title: "生产码",
type: "string",
},
codeType: {
title: "生产码类型",
type: "string",
input: "select",
options: [
{ value: "01", label: "前保" },
{ value: "02", label: "后保" },
{ value: "03", label: "门槛" },
],
},
proType: {
title: "发货类型",
type: "string",
input: "select",
options: [
{ value: "JIS", label: "JIS" },
{ value: "JIT", label: "JIT" },
{ value: "买单件", label: "买单件" },
{ value: "备件", label: "备件" },
],
},
qty: {
title: "数量",
type: "string",
},
shippingDate: {
title: "发运日期",
type: "string",
input: "date",
},
creationTime: {
title: "订单日期",
type: "string",
input: "date",
},
seqNumber: {
title: "EDI顺序号",
type: "string",
},
tmpe4: {
title: "客户订单号",
type: "string",
},
uniqueCode: {
title: "塑件唯一码",
type: "string",
},
matchNumber: {
title: "EDI总成号",
type: "string",
},
pjsNum: {
title: "PJIS生产顺序号",
type: "string",
},
desc: {
title: "备注",
type: "string",
},
},
};
}

2
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/router/business.js

@ -2865,7 +2865,7 @@ export default [
],
},
{
path: "record",
path: "log",
meta: {
type: "page",
title: "库存事物查询",

2
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/inventory/record.js → code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/inventory/log.js

@ -1,6 +1,6 @@
import AppList from "../../../components/list/index.js";
import html from "html";
import useConfig from "../../../models/inventory/record.js";
import useConfig from "../../../models/inventory/log.js";
export default {
components: { AppList },

44
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/HBPO_SA_DTO.cs

@ -61,45 +61,53 @@ public class HBPO_SA_DETAIL_IMPORT_DTO
/// 结算日期
/// </summary>
[Display(Name = "结算日期")]
[ImporterHeader(Name = "ReceiveDate", Format = "yyyy/MM/dd")]
[ImporterHeader(Name = "ReceiveDate", Format = "yyyy/MM/dd HH:mm:ss")]
public DateTime SettleDate { set; get; }
/// <summary>
/// 零件
/// 结算分组
/// </summary>
[Display(Name = "零件号")]
[Display(Name = "DeliveryNode")]
[Required(ErrorMessage = "{0}不能为空")]
[ImporterHeader(Name = "PartNumber")]
public string LU { get; set; }
[ImporterHeader(Name = "DeliveryNode")]
public string GroupNum { get; set; }
/// <summary>
/// 生产号
/// 到货日期
/// </summary>
[Display(Name = "生产号")]
[ImporterHeader(Name = "productionNumber")]
[Display(Name = "DeliveryDate")]
[Required(ErrorMessage = "{0}不能为空")]
public string PN { get; set; }
[ImporterHeader(Name = "DeliveryDate", Format = "MM/yyyy/dd HH:mm:ss")]
public DateTime? DeliveryDate { get; set; }
/// <summary>
/// 客户零件号
/// </summary>
[Display(Name = "PartNumber")]
[Required(ErrorMessage = "{0}不能为空")]
[ImporterHeader(Name = "PartNumber")]
public string LU { get; set; }
/// <summary>
/// 数量
/// </summary>
[Display(Name = "数量")]
[Display(Name = "结算数量")]
[ImporterHeader(Name = "Qty")]
public decimal Qty { get; set; }
/// <summary>
/// 结算分组号
/// 工厂地点
/// </summary>
[Display(Name = "结算分组号")]
[ImporterHeader(Name = "DeliveryNode")]
[Display(Name = "filename")]
[Required(ErrorMessage = "{0}不能为空")]
public string GroupNum { get; set; }
[ImporterHeader(Name = "filename")]
public string Site { get; set; }
/// <summary>
/// 工厂地点
/// 生产号
/// </summary>
[Display(Name = "工厂地点")]
[ImporterHeader(Name = "filename")]
[Display(Name = "productionNumber")]
[Required(ErrorMessage = "{0}不能为空")]
public string Site { get; set; }
[ImporterHeader(Name = "productionNumber")]
public string PN { get; set; }
}

15
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_SA_SERVICE.cs

@ -17,11 +17,12 @@ using Win.Sfs.Shared.RepositoryBase;
using System;
using System.Linq;
using Microsoft.AspNetCore.Http;
using NUglify.Helpers;
using Win.Sfs.SettleAccount.Bases;
using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.ExcelImporter;
using Win.Sfs.SettleAccount.ExportReports;
using OfficeOpenXml;
using OfficeOpenXml.Core;
namespace Win.Sfs.SettleAccount.Entities.BQ;
@ -143,6 +144,8 @@ public class HBPO_SA_SERVICE : SettleAccountApplicationBase<HBPO_SA>
var result = await _exportImporter.UploadExcelImport<HBPO_SA_DETAIL_IMPORT_DTO>(files, _excelImportService);
var importPubSaDetails = ObjectMapper.Map<List<HBPO_SA_DETAIL_IMPORT_DTO>, List<HBPO_SA_DETAIL>>(result);
return "";
//结算分组号
var hbpoSaGroupNums = importPubSaDetails.Select(t => t.GroupNum).Distinct();
@ -208,7 +211,6 @@ public class HBPO_SA_SERVICE : SettleAccountApplicationBase<HBPO_SA>
});
#endregion
#region 入库数据赋值
//结算明细
hbpoSaDetails = importPubSaDetails;
@ -243,7 +245,6 @@ public class HBPO_SA_SERVICE : SettleAccountApplicationBase<HBPO_SA>
{
hbpoNotSaDetails.ForEach(hbpoNotSaDetail =>
{
hbpoNotSaDetail.InvGroupNum = hbpoCanSaBillNum;
hbpoNotSaDetail.BusinessType = businessType;
});
@ -310,19 +311,19 @@ public class HBPO_SA_SERVICE : SettleAccountApplicationBase<HBPO_SA>
//删除
await _hbpoSaRepository.DeleteAsync(hbpoSaDelEntity);
if (hbpoSaDetailDelEntitys != null)
if (hbpoSaDetailDelEntitys.Any())
{
await _hbpoSaDetailRepository.DeleteManyAsync(hbpoSaDetailDelEntitys);
}
if (hbpoCanSaDelEntitys != null)
if (hbpoCanSaDelEntitys.Any())
{
await _hbpoCanSaRepository.DeleteManyAsync(hbpoCanSaDelEntitys);
}
if (hbpoCanSaDetailDelEntitys != null)
if (hbpoCanSaDetailDelEntitys.Any())
{
await _hbpoCanSaDetailRepository.DeleteManyAsync(hbpoCanSaDetailDelEntitys);
}
if (hbpoNotSaDetailDelEntitys != null)
if (hbpoNotSaDetailDelEntitys.Any())
{
await _hbpoNotSaDetailRepository.DeleteManyAsync(hbpoNotSaDetailDelEntitys);
}

82
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/JobItemAppService.cs

@ -0,0 +1,82 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Dynamic.Core;
using System.Threading.Tasks;
using EFCore.BulkExtensions;
using Microsoft.AspNetCore.Mvc;
using Omu.ValueInjecter;
using Volo.Abp.Application.Dtos;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.BQ.Vmi;
using Win.Sfs.SettleAccount.Entities.Materials;
using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ;
[Route("api/settleaccount/[controller]/[action]")]
public class JobItemAppService : SettleAccountApplicationBase<Material>
{
private readonly INormalEfCoreRepository<JobItem, Guid> _repository;
public JobItemAppService(INormalEfCoreRepository<JobItem, Guid> repository)
{
this._repository = repository;
}
[HttpPost]
public async Task<PagedResultDto<JobItem>> GetListAsync(RequestDto input)
{
var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount,
input.SkipCount, true).ConfigureAwait(false);
var totalCount = await _repository.GetCountByFilterAsync(input.Filters).ConfigureAwait(false);
return new PagedResultDto<JobItem>(totalCount, entities);
}
[HttpPost]
public async Task<JobItem> CreateAsync(JobItem input)
{
await _repository.InsertAsync(input).ConfigureAwait(false);
return input;
}
[HttpPost("{id}")]
public async Task<JobItem> UpdateAsync(Guid id, JobItem input)
{
var entity = await _repository.FindAsync(id).ConfigureAwait(false);
if (entity != null)
{
entity.InjectFrom(input);
}
await _repository.UpdateAsync(entity).ConfigureAwait(false);
return input;
}
[HttpPost]
public async Task<bool> DeleteListAsync(List<Guid> ids)
{
var _query = _repository.Where(p => ids.Contains(p.Id));
int i = await _query.BatchDeleteAsync().ConfigureAwait(false);
return i == 0;
}
}
[Route("api/settleaccount/[controller]/[action]")]
public class JobLogAppService : SettleAccountApplicationBase<Material>
{
private readonly INormalEfCoreRepository<JobLog, Guid> _repository;
public JobLogAppService(INormalEfCoreRepository<JobLog, Guid> repository)
{
this._repository = repository;
}
[HttpPost]
public async Task<PagedResultDto<JobLog>> GetListAsync(RequestDto input)
{
var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount,
input.SkipCount, true).ConfigureAwait(false);
var totalCount = await _repository.GetCountByFilterAsync(input.Filters).ConfigureAwait(false);
return new PagedResultDto<JobLog>(totalCount, entities);
}
}

11
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs

@ -6,7 +6,6 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using NUglify.Helpers;
using SettleAccount.Domain.BQ;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
@ -140,7 +139,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
//不可结算
List<PUB_NOT_SA_DETAIL> pubNotSaDetailDelEntitys;
pubSaDelEntity = await _repository.FindAsync(id);
if (pubSaDelEntity == null) return;
//结算单据
@ -160,19 +158,19 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
//删除
await _repository.DeleteAsync(pubSaDelEntity);
if (pubSaDetailDelEntitys != null)
if (pubSaDetailDelEntitys.Any())
{
await _pubSaDetailRepository.DeleteManyAsync(pubSaDetailDelEntitys);
}
if (pubCanSaDelEntitys != null)
if (pubCanSaDelEntitys.Any())
{
await _pubCanSaRepository.DeleteManyAsync(pubCanSaDelEntitys);
}
if (pubCanSaDetailDelEntitys != null)
if (pubCanSaDetailDelEntitys.Any())
{
await _pubCanSaDetailRepository.DeleteManyAsync(pubCanSaDetailDelEntitys);
}
if (pubNotSaDetailDelEntitys != null)
if (pubNotSaDetailDelEntitys.Any())
{
await _pubNotSaDetailRepository.DeleteManyAsync(pubNotSaDetailDelEntitys);
}
@ -321,7 +319,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{
pubNotSaDetails.ForEach(pubNotSaDetail =>
{
pubNotSaDetail.InvGroupNum = pubCanSaBillNum;
pubNotSaDetail.BusinessType = businessType;
});

284
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs

@ -1,24 +1,34 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Dynamic.Core;
using System.Reflection;
using System.Threading.Tasks;
using ClosedXML.Excel;
using InfluxDB.LineProtocol.Client;
using Magicodes.ExporterAndImporter.Core.Extension;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage;
using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime;
using Microsoft.Extensions.Configuration;
using Microsoft.OpenApi.Extensions;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.AspNetCore.Uow;
using Volo.Abp.BlobStoring;
using Volo.Abp.DependencyInjection;
using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.BQ.Vmi;
using Win.Sfs.SettleAccount.EntityFrameworkCore;
using Win.Sfs.SettleAccount.influxdb;
using Win.Sfs.Shared.Filter;
using Win.Sfs.Shared.RepositoryBase;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
namespace Win.Sfs.SettleAccount.Entities.BQ;
@ -29,23 +39,28 @@ public interface IVmiService : IApplicationService, ITransientDependency, IJobSe
void Out(VmiCategory category, string erpToLoc, string partCode, string lu, decimal count, object message);
void Run(string logGroupId, VmiType type);
}
}
[AllowAnonymous]
[Route("api/settleaccount/[controller]/[action]")]
public class VmiAppService : ApplicationService, IVmiService, IJobService, ITransientDependency
{
private readonly IConfiguration _cfg;
private readonly INormalEfCoreRepository<VmiBalance, Guid> _balanceRepository;
private readonly INormalEfCoreRepository<VmiLog, Guid> _logRepository;
private readonly INormalEfCoreRepository<VmiSnapshot, Guid> _snapshotRepository;
private readonly IBlobContainer<MyFileContainer> _fileContainer;
public VmiAppService(INormalEfCoreRepository<VmiBalance, Guid> balanceRepository,
public VmiAppService(IConfiguration cfg, INormalEfCoreRepository<VmiBalance, Guid> balanceRepository,
INormalEfCoreRepository<VmiLog, Guid> logRepository,
INormalEfCoreRepository<VmiSnapshot, Guid> snapshotRepository)
INormalEfCoreRepository<VmiSnapshot, Guid> snapshotRepository,
IBlobContainer<MyFileContainer> fileContainer)
{
this._cfg = cfg;
this._balanceRepository = balanceRepository;
this._logRepository = logRepository;
this._snapshotRepository = snapshotRepository;
this._fileContainer = fileContainer;
}
/// <summary>
@ -60,15 +75,16 @@ public class VmiAppService : ApplicationService, IVmiService, IJobService, ITran
using var dbContext = new VmiSqliteContext(connectionString);
if (!dbContext.GetService<IRelationalDatabaseCreator>().Exists() && dbContext.Database.EnsureCreated())
{
this._balanceRepository.AsNoTracking().ForEachAsync(o =>
var list = this._balanceRepository.AsNoTracking().ToList();
foreach (var item in list)
{
dbContext.Set<VmiBalance>().Add(o);
});
dbContext.Set<VmiBalance>().Add(item);
}
dbContext.SaveChanges();
var snapshot = new VmiSnapshot { Name = date, Path = connectionString };
this._snapshotRepository.InsertAsync(snapshot).Wait();
}
Console.WriteLine($"{nameof(VmiAppService)}:{DateTime.Now}");
Debug.WriteLine($"{nameof(VmiAppService)}:{DateTime.Now}");
}
/// <summary>
@ -76,7 +92,7 @@ public class VmiAppService : ApplicationService, IVmiService, IJobService, ITran
/// </summary>
[HttpPost]
public void In(VmiCategory category, string erpToLoc, string partCode, string lu, decimal count, object message)
{
{
}
/// <summary>
@ -84,7 +100,7 @@ public class VmiAppService : ApplicationService, IVmiService, IJobService, ITran
/// </summary>
[HttpPost]
public void Out(VmiCategory category, string erpToLoc, string partCode, string lu, decimal count, object message)
{
{
}
/// <summary>
@ -107,8 +123,21 @@ public class VmiAppService : ApplicationService, IVmiService, IJobService, ITran
{
var entities = await _balanceRepository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount, true).ConfigureAwait(false);
var totalCount = await _balanceRepository.GetCountByFilterAsync(input.Filters).ConfigureAwait(false);
//var dtos = ObjectMapper.Map<List<CodeSetting>, List<CodeSettingDto>>(entities);
return new PagedResultDto<VmiBalance>(totalCount, entities);
return new PagedResultDto<VmiBalance>(totalCount, entities);
}
/// <summary>
/// 库存余额导出
/// </summary>
[HttpPost]
public async Task<string> BalanceExport(RequestDto input)
{
var entities = await _balanceRepository.WhereIf(input.Filters?.Count != 0, input.Filters.ToLambda<VmiBalance>())
.ToListAsync().ConfigureAwait(false);
var fileName = $"库存余额_{DateTime.Now.ToString("yyyy-MM-dd_HH:mm:ss")}.xlsx";
var content = this.GetContent<VmiBalance>(entities, "库存备份");
await _fileContainer.SaveAsync(fileName, content, true).ConfigureAwait(false);
return fileName;
}
/// <summary>
@ -119,27 +148,230 @@ public class VmiAppService : ApplicationService, IVmiService, IJobService, ITran
[HttpPost]
public async Task<PagedResultDto<VmiLog>> Log(RequestDto input)
{
var entities = await _logRepository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount, true).ConfigureAwait(false);
var totalCount = await _logRepository.GetCountByFilterAsync(input.Filters).ConfigureAwait(false);
//var dtos = ObjectMapper.Map<List<CodeSetting>, List<CodeSettingDto>>(entities);
return new PagedResultDto<VmiLog>(totalCount, entities);
}
var type = typeof(VmiLog);
var querySql = $"select * from {typeof(VmiLog).Name} where 1=1";
var countSql = $"select count(*) from {typeof(VmiLog).Name} where 1=1";
var where = "";
if (input.Filters.Any())
{
foreach (var item in input.Filters)
{
var property = type.GetProperties().FirstOrDefault(p => p.Name.ToLowerInvariant() == item.Column.ToLowerInvariant());
if (property != null)
{
var @operator = GetOperator(item.Action);
var value = GetValue(property, item.Value);
where += $" and {property.Name}{string.Format(GetOperator(item.Action), item.Value)}";
}
}
}
var herlper = new InfluxHelper(_cfg);
var countResult = await herlper.Query(countSql + where).ConfigureAwait(false);
var count = Convert.ToInt32(countResult.results.FirstOrDefault().series.FirstOrDefault().values.FirstOrDefault().LastOrDefault());
var result = await herlper.Query(querySql + where).ConfigureAwait(false);
var entities = new List<VmiLog>();
result.results.FirstOrDefault().series.FirstOrDefault().values.ForEach(v =>
{
var entity = Activator.CreateInstance<VmiLog>();
entities.Add(entity);
var i = 0;
result.results.FirstOrDefault().series.FirstOrDefault().columns.ForEach(c =>
{
var property = type.GetProperty(c);
if (property != null)
{
this.SetPropertyValue(property, entity, v[i]);
i++;
}
});
});
return new PagedResultDto<VmiLog>(count, entities);
}
/// <summary>
/// 快照列表
/// </summary>
[HttpPost]
public async Task<ListResultDto<VmiSnapshot>> Snapshot()
{
var list = await _snapshotRepository.GetListAsync().ConfigureAwait(false);
return new ListResultDto<VmiSnapshot>(list);
}
/// <summary>
/// 时点库存查询
/// </summary>
/// <param name="name">备份名称</param>
/// <returns></returns>
[HttpPost("{name}")]
public async Task<PagedResultDto<VmiBalance>> Backup(string name, RequestDto input)
[HttpPost]
public async Task<PagedResultDto<VmiBalance>> Backup(BackupListRequest input)
{
var connectionString = $"Data Source=wwwroot/files/vmi/{name}.db";
var connectionString = $"Data Source=wwwroot/files/vmi/{input.Name}.db";
using var dbContext = new VmiSqliteContext(connectionString);
var repo = dbContext.Set<VmiBalance>();
var filters = input.Filters.ToLambda<VmiBalance>();
var query = (input.Filters.Count > 0 ? repo.Where(input.Filters.ToLambda<VmiBalance>()) : repo);
var totalCount = query.Count();
var entities = await query.PageBy(input.SkipCount, input.MaxResultCount).ToListAsync();
query = string.IsNullOrEmpty(input.Sorting) ? query : DynamicQueryableExtensions.OrderBy(query, input.Sorting);
var entities = await query.PageBy(input.SkipCount, input.MaxResultCount).ToListAsync().ConfigureAwait(false);
return new PagedResultDto<VmiBalance>(totalCount, entities);
}
/// <summary>
/// 时点库存导出
/// </summary>
[HttpPost]
public async Task<string> BackupExport(BackupListRequest input)
{
var connectionString = $"Data Source=wwwroot/files/vmi/{input.Name}.db";
using var dbContext = new VmiSqliteContext(connectionString);
var repo = dbContext.Set<VmiBalance>();
var filters = input.Filters.ToLambda<VmiBalance>();
var query = (input.Filters.Count > 0 ? repo.Where(input.Filters.ToLambda<VmiBalance>()) : repo);
query = string.IsNullOrEmpty(input.Sorting) ? query : DynamicQueryableExtensions.OrderBy(query, input.Sorting);
var entities = await query.ToListAsync().ConfigureAwait(false);
var fileName = $"库存备份_{input.Name}.xlsx";
var content = this.GetContent(entities, "库存备份");
await _fileContainer.SaveAsync(fileName, content, true).ConfigureAwait(false);
return fileName;
}
private byte[] GetContent<TExport>(List<TExport> entities, string name = "sheet1")
{
using var workbook = new XLWorkbook();
var ws = workbook.Worksheets.Add(name);
var type = typeof(TExport);
var properties = type.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetProperty)
.Where(o => o.GetAttributes<DisplayAttribute>().Any())
.ToList();
var rowIndex = 1;
for (var i = 0; i < properties.Count; i++)
{
var property = properties[i];
var columnIndex = i + 1;
var cell = ws.Cell(1, columnIndex);
cell.Value = property.GetAttributes<DisplayAttribute>().Any() ? property.GetAttribute<DisplayAttribute>().Name : property.Name;
}
foreach (var item in entities)
{
rowIndex++;
for (var i = 0; i < properties.Count; i++)
{
var property = properties[i];
var columnIndex = i + 1;
var cell = ws.Cell(rowIndex, columnIndex);
SetCell(item, cell, property);
}
}
ws.RangeUsed().Style.Border.TopBorder =
ws.RangeUsed().Style.Border.RightBorder =
ws.RangeUsed().Style.Border.BottomBorder =
ws.RangeUsed().Style.Border.LeftBorder = XLBorderStyleValues.Thin;
ws.RangeUsed().Style.Border.TopBorderColor =
ws.RangeUsed().Style.Border.RightBorderColor =
ws.RangeUsed().Style.Border.BottomBorderColor =
ws.RangeUsed().Style.Border.LeftBorderColor = XLColor.Black;
ws.RangeUsed().SetAutoFilter();
ws.ColumnsUsed().AdjustToContents();
ws.RowsUsed().AdjustToContents();
using var stream = new MemoryStream();
workbook.SaveAs(stream);
stream.Seek(0, SeekOrigin.Begin);
return stream.ToArray();
}
[HttpGet]
public async Task<InfluxQueryResult> InfluxQueryTest(string q)
{
return await new InfluxHelper(_cfg).Query(q).ConfigureAwait(false);
}
[HttpGet]
public List<VmiLog> InfluxQueryTest2()
{
var sql = this._logRepository.Where(o => o.Category == null || o.Category == "").ToQueryString();
return new InfluxHelper(_cfg).Query<VmiLog>(out long total, 1, 10, o => o.Category == null || o.Category == "");
}
[HttpGet]
public async Task<LineProtocolWriteResult> InfluxInsertTest(string q)
{
return await new InfluxHelper(_cfg).Insert(new VmiLog()).ConfigureAwait(false);
}
private static void SetCell<TExportModel>(TExportModel? model, IXLCell cell, PropertyInfo property)
{
var propertyType = property.PropertyType;
var value = property.GetValue(model)?.ToString()?.Trim();
if (string.IsNullOrEmpty(value))
{
return;
}
if (propertyType == typeof(bool))
{
cell.Value = (bool)property.GetValue(model)! ? "是" : "否";
}
else if (propertyType.IsEnum)
{
cell.Value = (Enum.Parse(propertyType, value) as Enum)?.GetDisplayName();
}
else if (propertyType == typeof(DateTime))
{
cell.Value = ((DateTime)property.GetValue(model)!).ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
}
else
{
cell.Value = value;
}
}
private void SetPropertyValue(PropertyInfo property, VmiLog entity, string value)
{
try
{
object propertyValue = null;
if (!string.IsNullOrEmpty(value))
{
propertyValue = Convert.ChangeType(value, property.PropertyType);
}
property.SetValue(entity, propertyValue, null);
}
catch (Exception)
{
throw;
}
}
private string GetOperator(EnumFilterAction action)
{
var dictonary = new Dictionary<EnumFilterAction, string>() {
{EnumFilterAction.Equal,"={0}"},
{EnumFilterAction.NotEqual,"!={0}"},
{EnumFilterAction.SmallThanOrEqual,"<={0}"},
{EnumFilterAction.Like,"~/{0}/"},
{EnumFilterAction.NotLike,"!~/{0}/"},
{EnumFilterAction.BiggerThan,">{0}"},
{EnumFilterAction.BiggerThanOrEqual,">={0}"},
{EnumFilterAction.SmallThan,"<{0}"},
};
return dictonary[action];
}
private object GetValue(PropertyInfo property, string value)
{
if (property.PropertyType == typeof(int) ||
property.PropertyType == typeof(long) ||
property.PropertyType == typeof(float) ||
property.PropertyType == typeof(double) ||
property.PropertyType == typeof(decimal) ||
property.PropertyType == typeof(bool))
{
return value;
}
return $"'{value}'";
}
}
public class BackupListRequest : RequestDto
{
[Required]
public string Name { get; set; }
}

4
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/MaterialRelationships/MaterialRelationshipAppService.cs

@ -41,7 +41,7 @@ public class MaterialRelationshipAppService : SettleAccountApplicationBase<Mater
IExcelImportAppService excelImportService,
ISnowflakeIdGenerator snowflakeIdGenerator,
ICommonManager commonManager
) : base(cache,excelImportService,snowflakeIdGenerator,commonManager)
) : base(cache, excelImportService, snowflakeIdGenerator, commonManager)
{
_repository = repository;
}
@ -51,7 +51,7 @@ public class MaterialRelationshipAppService : SettleAccountApplicationBase<Mater
/// 导入
/// </summary>
[HttpPost]
public async Task<string> ImportAsync(MaterialRelationshipImportRequestDto materialRelationshipImportRequestDto)
public async Task<string> ImportAsync([FromForm] MaterialRelationshipImportRequestDto materialRelationshipImportRequestDto)
{
ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.UploadExcelImport<MaterialRelationshipImportDto>(materialRelationshipImportRequestDto.Files, _excelImportService);

7
code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.csproj

@ -116,10 +116,17 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="ClosedXML" Version="0.102.0" />
<PackageReference Include="EFCore.BulkExtensions" Version="5.3.0" />
<PackageReference Include="Flurl" Version="3.0.7" />
<PackageReference Include="Flurl.Http" Version="3.2.4" />
<PackageReference Include="InfluxDB.Collector" Version="1.1.1" />
<PackageReference Include="InfluxDB.LineProtocol" Version="1.1.1" />
<PackageReference Include="NPOI" Version="2.5.4" />
<PackageReference Include="Riven.CodeArts.Db.Influx17x" Version="0.1.0" />
<PackageReference Include="Shouldly" Version="4.0.3" />
<PackageReference Include="System.IO.Compression.ZipFile" Version="4.3.0" />
<PackageReference Include="ValueInjecter" Version="3.2.0" />
<PackageReference Include="Volo.Abp.AspNetCore.Mvc" Version="4.3.3" />
<PackageReference Include="Volo.Abp.AutoMapper" Version="4.3.3" />
<PackageReference Include="Volo.Abp.BackgroundJobs.Abstractions" Version="4.3.3" />

92
code/src/Modules/SettleAccount/src/SettleAccount.Application/influxdb/InfluxHelper.cs

@ -0,0 +1,92 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Dynamic.Core;
using System.Reflection;
using System.Threading.Tasks;
using CodeArts.Db;
using Flurl.Http;
using InfluxDB.LineProtocol.Client;
using InfluxDB.LineProtocol.Payload;
using Microsoft.Extensions.Configuration;
namespace Win.Sfs.SettleAccount.influxdb;
public class InfluxHelper
{
private readonly IConfiguration _configuration;
private readonly string _database = "vmi";
public InfluxHelper(IConfiguration configuration)
{
this._configuration = configuration;
}
public InfluxHelper Start()
{
if (!Process.GetProcessesByName("influxd").Any())
{
var influxPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "influxdb");
var process = new Process();
process.StartInfo = new ProcessStartInfo
{
UseShellExecute = false,
CreateNoWindow = true,
WorkingDirectory = influxPath,
FileName = Path.Combine(influxPath, "influxd.exe"),
Arguments = $"-config {Path.Combine(influxPath, "influxdb.conf")}",
};
process.Start();
}
return this;
}
public async Task<InfluxQueryResult> Query(string q)
{
var influxUrl = GetUrl();
var response = await $"{influxUrl}/query".PostUrlEncodedAsync(new { q, db = this._database }).ConfigureAwait(false);
if (response.StatusCode == 200)
{
var result = await response.GetJsonAsync<InfluxQueryResult>().ConfigureAwait(false);
return result;
}
throw new Exception($"StatusCode:{response.StatusCode}");
}
private string GetUrl()
{
return (_configuration.GetConnectionString("influxdb") ?? "http://localhost:8086").TrimEnd('/');
}
public async Task<LineProtocolWriteResult> Insert<T>(T data)
{
var influxUrl = GetUrl();
var client = new LineProtocolClient(new Uri(influxUrl), this._database);
var table = typeof(T).Name;
var payload = new LineProtocolPayload();
var dictonary = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)
.ToDictionary(o => o.Name, o => o.GetValue(data, null));
payload.Add(new LineProtocolPoint(table, dictonary));
var result = await client.WriteAsync(payload).ConfigureAwait(false);
return result;
}
public List<T> Query<T>(out long total, int pageIndex, int pageSize, Func<T, bool> where) where T : class, new()
{
var influxOptions = new InfluxOptions(GetUrl(), _database, string.Empty, string.Empty);
var influxDbClient = influxOptions.CreateSampleInfluxClient();
var connectionConfig = new Influx17xConnectionConfig(influxDbClient);
CodeArtsHelper.InitializeBasic();
Influx17xHelper.InitializeCodeArts();
Influx17xHelper.InitializeDefaultConnectionConfig(connectionConfig);
var query = Influx17xHelper.CreateQuery<T>(connectionConfig, null);
//.Where(where);
//total = query.LongCount();
Debug.WriteLine(query.ToString());
total = 10;
var result = query.Skip(0).Take(10).ToList();
return result;
}
}

28
code/src/Modules/SettleAccount/src/SettleAccount.Application/influxdb/InfluxQueryResult.cs

@ -0,0 +1,28 @@
using System.Collections.Generic;
namespace Win.Sfs.SettleAccount.influxdb;
public class InfluxQueryResult
{
public List<InfluxResult> results { get; set; } = new List<InfluxResult>();
}
public class InfluxResult
{
public string statement_id { get; set; }
public List<InfluxMessage> messages { get; set;} = new List<InfluxMessage>();
public List<InfluxSeries> series { get; set; } = new List<InfluxSeries>();
}
public class InfluxMessage
{
public string level { get; set; }
public string text { get; set; }
}
public class InfluxSeries
{
public string name { get; set; }
public List<string> columns { get; set; } = new List<string>();
public List<List<string>> values { get; set; } = new List<List<string>>();
}

1
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/JobItem.cs

@ -10,6 +10,7 @@ public class JobItem : Entity<Guid>, IHasConcurrencyStamp
this.Id = id;
}
public bool IsDisabled { get; set; }
public string Name { get; set; }
public string Cron { get; set; }
public string Service { get; set; }

57
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/VmiBalance.cs

@ -15,74 +15,55 @@ public class VmiBalance : Entity<Guid>
}
/// <summary>
/// Erp目标库位
/// key
/// </summary>
[Display(Name ="ERP库位")]
public string ErpToLoc { get; set; }
/// <summary>
/// LU零件号
/// key
/// </summary>
[Display(Name = "LU零件号")]
public string LU { get; set; }
/// <summary>
/// 客户零件号
/// </summary>
[Display(Name = "客户零件号")]
public string PartCode { get; set; }
/// <summary>
/// 生产码
/// key
/// </summary>
[Display(Name = "", Description = "Key")]
[Display(Name = "生产码")]
public string VinCode { get; set; }
/// <summary>
/// 生产码类型
/// </summary>
[Display(Name = "客户零件号")]
public string CodeType { get; set; }
/// <summary>
/// 发货类型
/// </summary>
[Display(Name = "发货类型")]
public string ProType { get; set; }
/// <summary>
/// 数量
/// </summary>
[Display(Name = "数量")]
public decimal Qty { get; set; }
/// <summary>
/// 发运日期
/// </summary>
[Display(Name = "发运日期")]
public DateTime ShippingDate { get; set; }
/// <summary>
/// 订单日期
/// </summary>
[Display(Name = "订单日期")]
public DateTime CreationTime { get; set; }
/// <summary>
/// EDI顺序号
/// </summary>
[Display(Name = "EDI顺序号")]
public string SeqNumber { get; set; }
/// <summary>
/// 客户订单号
/// </summary>
public string Tmpe4 { get; set; }
[Display(Name = "客户订单号")]
public string CustomOrderNumber { get; set; }
/// <summary>
/// 塑件唯一码
/// </summary>
[Display(Name = "塑件唯一码")]
public string UniqueCode { get; set; }
/// <summary>
/// EDI总成号
/// </summary>
[Display(Name = "EDI总成号")]
public string MatchNumber { get; set; }
/// <summary>
/// PJIS生产顺序号
/// </summary>
[Display(Name = "PJIS生产顺序号")]
public string PjsNum { get; set; }
[Display(Name = "备注")]

63
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/VmiLog.cs

@ -20,16 +20,31 @@ public class VmiLog : Entity<Guid>
public VmiLogType VmiType { get; set; }
/// <summary>
/// 库存事务分类
/// 库存事务分类Number
/// </summary>
public Guid CategoryId { get; set; }
public string Category { get; set; }
/// <summary>
/// 库存Id
/// 库存变动
/// </summary>
public Guid BalanceId { get; set; }
public decimal Count { get; set; }
#region 库存备份
/// <summary>
/// 变动时间
/// </summary>
public DateTime CreatedDate { get; set; } = DateTime.Now;
/// <summary>
/// 便动人
/// </summary>
public string CreatedBy { get; set; }
/// <summary>
/// 变动单号
/// </summary>
public string OrderNumber { get; set; }
#region 变动前库存
/// <summary>
/// Erp目标库位
@ -82,11 +97,6 @@ public class VmiLog : Entity<Guid>
/// </summary>
public string SeqNumber { get; set; }
/// <summary>
/// 客户订单号
/// </summary>
public string Tmpe4 { get; set; }
/// <summary>
/// 塑件唯一码
/// </summary>
@ -107,27 +117,23 @@ public class VmiLog : Entity<Guid>
/// </summary>
public string BalanceDesc { get; set; }
#endregion 库存备份
/// <summary>
/// 变动单号
/// 备注
/// </summary>
public string OrderNumber { get; set; }
public string Desc { get; set; }
/// <summary>
/// 变动时间
/// </summary>
public DateTime CreatedDate { get; set; } = DateTime.Now;
#endregion 变动前库存
/// <summary>
/// 变动类型
/// </summary>
public string D2 { get; set; }
#region 入库附加信息
/// <summary>
/// 便动人
/// 客户订单号
/// </summary>
public string CreatedBy { get; set; }
public string Tmpe4 { get; set; }
#endregion 入库附加信息
#region 出库附加信息
/// <summary>
/// 实扣LU零件号
@ -159,12 +165,5 @@ public class VmiLog : Entity<Guid>
/// </summary>
public string K2 { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Desc { get; set; }
public VmiType Type { get; set; }
public VmiCategory Category { get; set; }
public VmiBalance Balance { get; set; }
#endregion 出库附加信息
}

26
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContextModelCreatingExtensions.cs

@ -101,7 +101,6 @@ namespace Win.Sfs.SettleAccount
builder.ConfigureHBPO_SEC_DETAIL(options);
builder.ConfigureBBAC_SEC_DETAIL(options);
builder.ConfigurePUB_ADJ_DETAIL(options);
builder.ConfigureBBAC_ADJ_DETAIL(options);
builder.ConfigureHBPO_ADJ_DETAIL(options);
@ -1157,10 +1156,8 @@ namespace Win.Sfs.SettleAccount
private static void ConfigurePUB_ADJ_DETAIL(this ModelBuilder builder, SettleAccountModelBuilderConfigurationOptions options)
{
builder.Entity<PUB_ADJ_DETAIL>(b =>
{
b.ToTable($"{options.TablePrefix}_PUB_ADJ_DETAIL", options.Schema);
b.ConfigureByConvention();
@ -1180,10 +1177,8 @@ namespace Win.Sfs.SettleAccount
private static void ConfigureHBPO_ADJ_DETAIL(this ModelBuilder builder, SettleAccountModelBuilderConfigurationOptions options)
{
builder.Entity<HBPO_ADJ_DETAIL>(b =>
{
b.ToTable($"{options.TablePrefix}_HBPO_ADJ_DETAIL", options.Schema);
b.ConfigureByConvention();
@ -1199,12 +1194,11 @@ namespace Win.Sfs.SettleAccount
b.Property(x => x.ConcurrencyStamp).HasMaxLength(50);
});
}
private static void ConfigureBBAC_ADJ_DETAIL(this ModelBuilder builder, SettleAccountModelBuilderConfigurationOptions options)
{
builder.Entity<BBAC_ADJ_DETAIL>(b =>
{
b.ToTable($"{options.TablePrefix}_BBAC_ADJ_DETAIL", options.Schema);
b.ConfigureByConvention();
@ -1223,7 +1217,6 @@ namespace Win.Sfs.SettleAccount
});
}
private static void ConfigureVmi(this ModelBuilder builder, SettleAccountModelBuilderConfigurationOptions options)
{
builder.Entity<JobItem>(b =>
@ -1273,24 +1266,15 @@ namespace Win.Sfs.SettleAccount
b.ConfigureByConvention();
});
//seed
builder.Entity<JobItem>().HasData(new JobItem("vmi".ToGuid()) { Name = "库存快照", Cron = "0 0 8 26 *", Service = "Win.Sfs.SettleAccount.Entities.BQ.VmiService" });
builder.Entity<VmiCategory>().HasData(new VmiCategory("发运".ToGuid()) { Type = VmiType.In, Name = "发运", Number = "100" });
builder.Entity<VmiCategory>().HasData(new VmiCategory("结算".ToGuid()) { Type = VmiType.Out, Name = "结算", Number = "200" });
builder.Entity<VmiCategory>().HasData(new VmiCategory("发运入库".ToGuid()) { Type = VmiType.In, Name = "发运入库", Number = "100" });
builder.Entity<VmiCategory>().HasData(new VmiCategory("结算出库".ToGuid()) { Type = VmiType.Out, Name = "结算出库", Number = "200" });
builder.Entity<VmiCategory>().HasData(new VmiCategory("客户退货".ToGuid()) { Type = VmiType.Out, Name = "客户退货", Number = "300" });
builder.Entity<VmiCategory>().HasData(new VmiCategory("调整入库".ToGuid()) { Type = VmiType.In, Name = "调整入库", Number = "400" });
builder.Entity<VmiCategory>().HasData(new VmiCategory("调整出库".ToGuid()) { Type = VmiType.Out, Name = "调整出库", Number = "500" });
builder.Entity<VmiCategory>().HasData(new VmiCategory("漏发补货".ToGuid()) { Type = VmiType.In, Name = "漏发补货", Number = "600" });
builder.Entity<VmiCategory>().HasData(new VmiCategory("负库存补货".ToGuid()) { Type = VmiType.In, Name = "负库存补货", Number = "700" });
//builder.Entity<VmiCategory>().HasData(new VmiCategory("漏发补货".ToGuid()) { Type = VmiType.In, Name = "漏发补货", Number = "600" });
//builder.Entity<VmiCategory>().HasData(new VmiCategory("负库存补货".ToGuid()) { Type = VmiType.In, Name = "负库存补货", Number = "700" });
}
}

4683
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230726065932_vmi4.Designer.cs

File diff suppressed because it is too large

202
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230726065932_vmi4.cs

@ -0,0 +1,202 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Win.Sfs.SettleAccount.Migrations
{
public partial class vmi4 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Set_VmiLog_Set_VmiBalance_BalanceId",
table: "Set_VmiLog");
migrationBuilder.DropForeignKey(
name: "FK_Set_VmiLog_Set_VmiCategory_CategoryId",
table: "Set_VmiLog");
migrationBuilder.DropIndex(
name: "IX_Set_VmiLog_BalanceId",
table: "Set_VmiLog");
migrationBuilder.DropIndex(
name: "IX_Set_VmiLog_CategoryId",
table: "Set_VmiLog");
migrationBuilder.DeleteData(
table: "Set_VmiCategory",
keyColumn: "Id",
keyValue: new Guid("27b1609e-05af-cef7-f5f4-dd598c31b4de"));
migrationBuilder.DeleteData(
table: "Set_VmiCategory",
keyColumn: "Id",
keyValue: new Guid("3e0655a6-2532-a861-344f-b9c53c809c64"));
migrationBuilder.DeleteData(
table: "Set_VmiCategory",
keyColumn: "Id",
keyValue: new Guid("869f1589-9063-a545-719e-a83b6dca03c3"));
migrationBuilder.DeleteData(
table: "Set_VmiCategory",
keyColumn: "Id",
keyValue: new Guid("a6462ee4-6e2c-bc8b-b1cb-5203c8dcaea8"));
migrationBuilder.DropColumn(
name: "BalanceId",
table: "Set_VmiLog");
migrationBuilder.DropColumn(
name: "CategoryId",
table: "Set_VmiLog");
migrationBuilder.DropColumn(
name: "Type",
table: "Set_VmiLog");
migrationBuilder.RenameColumn(
name: "D2",
table: "Set_VmiLog",
newName: "Category");
migrationBuilder.RenameColumn(
name: "Tmpe4",
table: "Set_VmiBalance",
newName: "CustomOrderNumber");
migrationBuilder.AddColumn<decimal>(
name: "Count",
table: "Set_VmiLog",
type: "decimal(18,2)",
nullable: false,
defaultValue: 0m);
migrationBuilder.AddColumn<Guid>(
name: "VmiCategoryId",
table: "Set_VmiLog",
type: "uniqueidentifier",
nullable: true);
migrationBuilder.InsertData(
table: "Set_VmiCategory",
columns: new[] { "Id", "Name", "Number", "Type" },
values: new object[] { new Guid("b3b321dd-5e0e-55b0-5548-70a742e9a4db"), "发运入库", "100", 0 });
migrationBuilder.InsertData(
table: "Set_VmiCategory",
columns: new[] { "Id", "Name", "Number", "Type" },
values: new object[] { new Guid("a04d00ac-0e9c-064d-b7ce-af0b4d7c8c6b"), "结算出库", "200", 1 });
migrationBuilder.CreateIndex(
name: "IX_Set_VmiLog_VmiCategoryId",
table: "Set_VmiLog",
column: "VmiCategoryId");
migrationBuilder.AddForeignKey(
name: "FK_Set_VmiLog_Set_VmiCategory_VmiCategoryId",
table: "Set_VmiLog",
column: "VmiCategoryId",
principalTable: "Set_VmiCategory",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Set_VmiLog_Set_VmiCategory_VmiCategoryId",
table: "Set_VmiLog");
migrationBuilder.DropIndex(
name: "IX_Set_VmiLog_VmiCategoryId",
table: "Set_VmiLog");
migrationBuilder.DeleteData(
table: "Set_VmiCategory",
keyColumn: "Id",
keyValue: new Guid("a04d00ac-0e9c-064d-b7ce-af0b4d7c8c6b"));
migrationBuilder.DeleteData(
table: "Set_VmiCategory",
keyColumn: "Id",
keyValue: new Guid("b3b321dd-5e0e-55b0-5548-70a742e9a4db"));
migrationBuilder.DropColumn(
name: "Count",
table: "Set_VmiLog");
migrationBuilder.DropColumn(
name: "VmiCategoryId",
table: "Set_VmiLog");
migrationBuilder.RenameColumn(
name: "Category",
table: "Set_VmiLog",
newName: "D2");
migrationBuilder.RenameColumn(
name: "CustomOrderNumber",
table: "Set_VmiBalance",
newName: "Tmpe4");
migrationBuilder.AddColumn<Guid>(
name: "BalanceId",
table: "Set_VmiLog",
type: "uniqueidentifier",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.AddColumn<Guid>(
name: "CategoryId",
table: "Set_VmiLog",
type: "uniqueidentifier",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.AddColumn<int>(
name: "Type",
table: "Set_VmiLog",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.InsertData(
table: "Set_VmiCategory",
columns: new[] { "Id", "Name", "Number", "Type" },
values: new object[,]
{
{ new Guid("a6462ee4-6e2c-bc8b-b1cb-5203c8dcaea8"), "发运", "100", 0 },
{ new Guid("869f1589-9063-a545-719e-a83b6dca03c3"), "结算", "200", 1 },
{ new Guid("3e0655a6-2532-a861-344f-b9c53c809c64"), "漏发补货", "600", 0 },
{ new Guid("27b1609e-05af-cef7-f5f4-dd598c31b4de"), "负库存补货", "700", 0 }
});
migrationBuilder.CreateIndex(
name: "IX_Set_VmiLog_BalanceId",
table: "Set_VmiLog",
column: "BalanceId");
migrationBuilder.CreateIndex(
name: "IX_Set_VmiLog_CategoryId",
table: "Set_VmiLog",
column: "CategoryId");
migrationBuilder.AddForeignKey(
name: "FK_Set_VmiLog_Set_VmiBalance_BalanceId",
table: "Set_VmiLog",
column: "BalanceId",
principalTable: "Set_VmiBalance",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Set_VmiLog_Set_VmiCategory_CategoryId",
table: "Set_VmiLog",
column: "CategoryId",
principalTable: "Set_VmiCategory",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}

4966
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230727005325_vmi5.Designer.cs

File diff suppressed because it is too large

24
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230727005325_vmi5.cs

@ -0,0 +1,24 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace Win.Sfs.SettleAccount.Migrations
{
public partial class vmi5 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "IsDisabled",
table: "Set_JobItem",
type: "bit",
nullable: false,
defaultValue: false);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "IsDisabled",
table: "Set_JobItem");
}
}
}

71
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/SettleAccountDbContextModelSnapshot.cs

@ -3746,6 +3746,9 @@ namespace Win.Sfs.SettleAccount.Migrations
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<bool>("IsDisabled")
.HasColumnType("bit");
b.Property<bool>("IsRunning")
.HasColumnType("bit");
@ -3771,6 +3774,7 @@ namespace Win.Sfs.SettleAccount.Migrations
{
Id = new Guid("ef3d8e8a-a88e-ca1f-e615-714c6bc48824"),
Cron = "0 0 8 26 *",
IsDisabled = false,
IsRunning = false,
Name = "库存快照",
Service = "Win.Sfs.SettleAccount.Entities.BQ.VmiService"
@ -3817,6 +3821,9 @@ namespace Win.Sfs.SettleAccount.Migrations
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime2");
b.Property<string>("CustomOrderNumber")
.HasColumnType("nvarchar(max)");
b.Property<string>("Desc")
.HasColumnType("nvarchar(max)");
@ -3850,9 +3857,6 @@ namespace Win.Sfs.SettleAccount.Migrations
b.Property<DateTime>("ShippingDate")
.HasColumnType("datetime2");
b.Property<string>("Tmpe4")
.HasColumnType("nvarchar(max)");
b.Property<string>("UniqueCode")
.HasColumnType("nvarchar(max)");
@ -3911,15 +3915,15 @@ namespace Win.Sfs.SettleAccount.Migrations
b.HasData(
new
{
Id = new Guid("a6462ee4-6e2c-bc8b-b1cb-5203c8dcaea8"),
Name = "发运",
Id = new Guid("b3b321dd-5e0e-55b0-5548-70a742e9a4db"),
Name = "发运入库",
Number = "100",
Type = 0
},
new
{
Id = new Guid("869f1589-9063-a545-719e-a83b6dca03c3"),
Name = "结算",
Id = new Guid("a04d00ac-0e9c-064d-b7ce-af0b4d7c8c6b"),
Name = "结算出库",
Number = "200",
Type = 1
},
@ -3943,20 +3947,6 @@ namespace Win.Sfs.SettleAccount.Migrations
Name = "调整出库",
Number = "500",
Type = 1
},
new
{
Id = new Guid("3e0655a6-2532-a861-344f-b9c53c809c64"),
Name = "漏发补货",
Number = "600",
Type = 0
},
new
{
Id = new Guid("27b1609e-05af-cef7-f5f4-dd598c31b4de"),
Name = "负库存补货",
Number = "700",
Type = 0
});
});
@ -3969,15 +3959,15 @@ namespace Win.Sfs.SettleAccount.Migrations
b.Property<string>("BalanceDesc")
.HasColumnType("nvarchar(max)");
b.Property<Guid>("BalanceId")
.HasColumnType("uniqueidentifier");
b.Property<Guid>("CategoryId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Category")
.HasColumnType("nvarchar(max)");
b.Property<string>("CodeType")
.HasColumnType("nvarchar(max)");
b.Property<decimal>("Count")
.HasColumnType("decimal(18,2)");
b.Property<string>("CreatedBy")
.HasColumnType("nvarchar(max)");
@ -3987,9 +3977,6 @@ namespace Win.Sfs.SettleAccount.Migrations
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime2");
b.Property<string>("D2")
.HasColumnType("nvarchar(max)");
b.Property<string>("Desc")
.HasColumnType("nvarchar(max)");
@ -4047,23 +4034,21 @@ namespace Win.Sfs.SettleAccount.Migrations
b.Property<string>("Tmpe4")
.HasColumnType("nvarchar(max)");
b.Property<int>("Type")
.HasColumnType("int");
b.Property<string>("UniqueCode")
.HasColumnType("nvarchar(max)");
b.Property<string>("VinCode")
.HasColumnType("nvarchar(max)");
b.Property<Guid?>("VmiCategoryId")
.HasColumnType("uniqueidentifier");
b.Property<int>("VmiType")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("BalanceId");
b.HasIndex("CategoryId");
b.HasIndex("VmiCategoryId");
b.ToTable("Set_VmiLog");
});
@ -4962,21 +4947,9 @@ namespace Win.Sfs.SettleAccount.Migrations
modelBuilder.Entity("Win.Sfs.SettleAccount.Entities.BQ.Vmi.VmiLog", b =>
{
b.HasOne("Win.Sfs.SettleAccount.Entities.BQ.Vmi.VmiBalance", "Balance")
.WithMany()
.HasForeignKey("BalanceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Win.Sfs.SettleAccount.Entities.BQ.Vmi.VmiCategory", "Category")
b.HasOne("Win.Sfs.SettleAccount.Entities.BQ.Vmi.VmiCategory", null)
.WithMany("Logs")
.HasForeignKey("CategoryId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Balance");
b.Navigation("Category");
.HasForeignKey("VmiCategoryId");
});
modelBuilder.Entity("Win.Sfs.SettleAccount.Entities.BQ.Vmi.VmiCategory", b =>

Loading…
Cancel
Save