wanggang 1 year ago
parent
commit
9ceb6015e9
  1. 2
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/form/form-input.js
  2. 4
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/settle/detail.js
  3. 35
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/vmi/adjust.js
  4. 150
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/vmi/backup.js
  5. 21
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/vmi/balance.js
  6. 40
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/vmi/log.js
  7. 8
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/vmi/vmi.js
  8. 12
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/request/index.js
  9. 10
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/router/business.js
  10. 36
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs
  11. 3
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAsyncBalanceService.cs
  12. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Domain.Shared/SettleAccount.Domain.Shared.csproj
  13. 6
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/SettleAccount.Domain.csproj
  14. 12
      code/src/Shared/Win.Sfs.Shared/Win.Sfs.Shared.csproj
  15. 2
      code/src/Shared/Win.Utils/Win.Utils.csproj

2
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/form/form-input.js

@ -31,7 +31,7 @@ export default {
</el-tabs>
</template>
<template v-else-if="getInput(schema)==='month'||getInput(schema)==='datetime'||getInput(schema)==='datetimerange'">
<el-date-picker v-model="model[prop]" :type="schema.input" :value-format="schema.format??'YYYY-MM-DD HH:mm:ss'" />
<el-date-picker v-model="model[prop]" :type="schema.input" :value-format="schema.format??'YYYY-MM-DD HH:mm:ss'" :clearable="!!schema.clearable" />
</template>
<template v-else-if="getInput(schema)==='number'">
<el-input :disabled="getDisabled()" :placeholder="schema.placeholder??schema.title" v-model="model[prop]" type="number" />

4
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/settle/detail.js

@ -21,11 +21,11 @@ const schema = {
type: "string",
},
lu: {
title: "厂内零件号",
title: "客户零件号",
type: "string",
},
partCode: {
title: "客户零件号",
title: "厂内零件号",
type: "string",
},
materialDesc: {

35
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/vmi/adjust.js

@ -1,4 +1,5 @@
import { useLogSchema } from "./vmi.js";
import { dayjs } from "element-plus";
const schema = useLogSchema();
@ -51,6 +52,26 @@ export default function () {
},
},
default: [
{
logic: "and",
column: "changedTime",
action: "biggerThanOrEqual",
value: null,
readOnly: true,
title: "发运开始",
default: dayjs().startOf("day").format("YYYY-MM-DD HH:mm:ss"),
clearable: false,
},
{
logic: "and",
column: "changedTime",
action: "smallThan",
value: null,
readOnly: true,
title: "发运结束",
default: dayjs().add(1, "month").startOf("day").format("YYYY-MM-DD HH:mm:ss"),
clearable: false,
},
{
logic: "and",
column: "erpToLoc",
@ -93,20 +114,6 @@ export default function () {
value: null,
readOnly: true,
},
{
logic: "and",
column: "billTime",
action: "biggerThanOrEqual",
value: null,
readOnly: true,
},
{
logic: "and",
column: "billTime",
action: "smallThanOrEqual",
value: null,
readOnly: true,
},
],
},
skipCount: {

150
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/vmi/backup.js

@ -1,139 +1,21 @@
import useVmi from "./vmi.js";
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}/backup-export`;
const invokeUrl = "settleaccount/vmi/invoke";
const queryMethod = "POST";
const detailsMethod = "POST";
const createMethod = "POST";
const updateMethod = "POST";
const deleteMethod = "POST";
const importMethod = "POST";
const exportMethod = "POST";
const invokeMethod = "POST";
import useBalance from "./balance.js";
export default function () {
return {
query: {
url: queryUrl,
method: queryMethod,
hasFilter: true,
autoSubmit: true,
disableQueryOnLoad: true,
schema: {
title: "时点库存余额查询",
type: "object",
properties: {
name: {
title: "时间",
type: "string",
input: "select",
url: "settleaccount/vmi/snapshot",
value: "description",
label: "name",
defaultSelected: true,
clearable: false,
},
filters: {
title: "项目",
type: "array",
hidden: true,
items: {
type: "object",
properties: {
logic: {
type: "int",
},
column: {
type: "string",
},
action: {
type: "int",
},
value: {
type: "string",
},
},
},
default: [
{
logic: "and",
column: "erpToLoc",
action: "like",
value: null,
readOnly: true,
},
{
logic: "and",
column: "realPartCode",
action: "like",
value: null,
readOnly: true,
},
{
logic: "and",
column: "vinCode",
action: "like",
value: null,
readOnly: true,
},
{
logic: "and",
column: "codeType",
action: "equal",
value: null,
readOnly: true,
},
{
logic: "and",
column: "deliverBillType",
action: "equal",
value: null,
readOnly: true,
},
],
},
skipCount: {
hidden: true,
default: 0,
},
maxResultCount: {
hidden: true,
default: 10,
},
sorting: {
hidden: true,
},
},
const result = useBalance();
result.query.schema.properties = Object.assign(
{
name: {
title: "备份时间",
type: "string",
input: "select",
url: "settleaccount/vmi/snapshot",
value: "description",
label: "name",
defaultSelected: true,
clearable: false,
},
},
table: {
schema: schema,
},
edit: {
detailsUrl,
createUrl,
updateUrl,
deleteUrl,
importUrl,
exportUrl,
invokeUrl,
detailsMethod,
createMethod,
updateMethod,
deleteMethod,
importMethod,
exportMethod,
invokeMethod,
schema: schema,
},
};
result.query.schema.properties
);
return result;
}

21
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/vmi/balance.js

@ -1,4 +1,5 @@
import useVmi from "./vmi.js";
import { dayjs } from "element-plus";
const schema = useVmi();
@ -50,6 +51,26 @@ export default function () {
},
},
default: [
{
logic: "and",
column: "billTime",
action: "biggerThanOrEqual",
value: null,
readOnly: true,
title: "发运开始",
default: dayjs().startOf("day").format("YYYY-MM-DD HH:mm:ss"),
clearable: false,
},
{
logic: "and",
column: "billTime",
action: "smallThan",
value: null,
readOnly: true,
title: "发运结束",
default: dayjs().add(1, "month").startOf("day").format("YYYY-MM-DD HH:mm:ss"),
clearable: false,
},
{
logic: "and",
column: "erpToLoc",

40
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/vmi/log.js

@ -53,6 +53,26 @@ export default function () {
},
},
default: [
{
logic: "and",
column: "changedTime",
action: "biggerThanOrEqual",
value: null,
readOnly: true,
title: "事务开始",
default: dayjs().startOf("day").format("YYYY-MM-DD HH:mm:ss"),
clearable: false,
},
{
logic: "and",
column: "changedTime",
action: "smallThan",
value: null,
readOnly: true,
title: "事务结束",
default: dayjs().add(1, "month").startOf("day").format("YYYY-MM-DD HH:mm:ss"),
clearable: false,
},
{
logic: "and",
column: "erpToLoc",
@ -95,26 +115,6 @@ export default function () {
value: null,
readOnly: true,
},
{
logic: "and",
column: "billTime",
action: "biggerThanOrEqual",
value: null,
readOnly: true,
title: "发运开始",
default: dayjs().startOf("day").format("YYYY-MM-DD HH:mm:ss"),
clearable: false,
},
{
logic: "and",
column: "billTime",
action: "smallThan",
value: null,
readOnly: true,
title: "发运结束",
default: dayjs().add(1, "month").startOf("day").format("YYYY-MM-DD HH:mm:ss"),
clearable: false,
},
],
},
skipCount: {

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

@ -23,6 +23,7 @@ function useSchema() {
title: "发运日期",
type: "string",
input: "datetime",
clearable: false,
},
assembleData: {
title: "订单日期",
@ -79,7 +80,8 @@ function useSchema() {
}
function useLogSchema() {
return Object.assign(
const result = useSchema();
result.properties = Object.assign(
{
changedNumber: {
title: "变动单号",
@ -89,6 +91,7 @@ function useLogSchema() {
title: "变动时间",
type: "string",
input: "datetime",
clearable: false,
},
changedType: {
title: "变动类型",
@ -124,8 +127,9 @@ function useLogSchema() {
type: "string",
},
},
useSchema()
result.properties
);
return result;
}
export default useSchema;

12
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/request/index.js

@ -37,8 +37,8 @@ async function getResult(response) {
status: response.status,
message: messages.get(response.status),
};
const contentType = response.headers.get("Content-Type");
if (response.status === 200 || response.status === 201 || response.status === 204) {
const contentType = response.headers.get("Content-Type");
if (contentType?.indexOf("application/json") > -1) {
result.data = await response.json();
} else if (contentType?.indexOf("text/plain") > -1) {
@ -49,11 +49,16 @@ async function getResult(response) {
}
} else {
try {
result.errors = await response.json();
if (contentType?.indexOf("application/json") > -1) {
result.errors = await response.json();
}
} catch (error) {
result.errors = error;
console.log(error);
}
if (!result.errors) {
result.errors = result.message;
}
}
return result;
}
@ -91,7 +96,8 @@ async function request(url, data, options, notify = false) {
result.errors = result.data.message ?? result.data.code;
}
if (result.errors) {
const message = i18n.global.t(result.errors?.error?.message ?? result.errors?.error?.code ?? result.errors ?? "错误");
const key = String(result.errors?.error?.message ?? result.errors?.error?.code ?? result.errors ?? "错误");
const message = i18n.global.t(key);
ElMessageBox({ title: "提示", message, type: "warning" });
} else if (notify && (!result.data?.code || result.data.code === 200)) {
ElMessage({

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

@ -405,20 +405,20 @@ export default [
children: [createButton("query", "title=查询&isTop=true"), createButton("export", "title=导出&isTop=true&pattern=paged")],
},
{
...createPage("log", "title=库存事务查询"),
path: "log",
...createPage("backup", "title=时点库存余额查询"),
children: [
createButton("query", "title=查询&isTop=true"),
createButton("export", "title=导出&isTop=true&pattern=paged"),
createButton("export-replenishment", "title=补货数据导出&isTop=true&pattern=paged"),
createButton("invoke", "title=手动备份&isTop=true"),
],
},
{
...createPage("backup", "title=时点库存余额查询"),
...createPage("log", "title=库存事务查询"),
path: "log",
children: [
createButton("query", "title=查询&isTop=true"),
createButton("export", "title=导出&isTop=true&pattern=paged"),
createButton("invoke", "title=手动备份&isTop=true"),
createButton("export-replenishment", "title=补货数据导出&isTop=true&pattern=paged"),
],
},
{

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

@ -138,6 +138,7 @@ public class VmiAppService : ApplicationService, IJobService, ITransientDependen
db.Set<VmiSnapshot>().Add(snapshot);
db.SaveChanges();
db.Database.ExecuteSqlRaw($"select * into {table} from Set_VmiBalance;");
db.Database.ExecuteSqlRaw($"create clustered index IX_{table} on {table} (BillTime)");
snapshot.End = DateTime.Now;
transaction.Commit();
return Task.CompletedTask;
@ -212,10 +213,9 @@ public class VmiAppService : ApplicationService, IJobService, ITransientDependen
[HttpPost]
public async Task<PagedResultDto<VmiLog>> Log(LogRequestDto input)
{
using var scope = this._serviceProvider.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
var start = DateTime.Parse(input.Filters.FirstOrDefault(o => o.Column == "billTime" && o.Action == EnumFilterAction.BiggerThanOrEqual).Value);
var end = DateTime.Parse(input.Filters.FirstOrDefault(o => o.Column == "billTime" && o.Action == EnumFilterAction.BiggerThanOrEqual).Value);
//按季度计算查询需要 union 的表名
var start = DateTime.Parse(input.Filters.FirstOrDefault(o => o.Column == "changedTime" && o.Action == EnumFilterAction.BiggerThanOrEqual).Value);
var end = DateTime.Parse(input.Filters.FirstOrDefault(o => o.Column == "changedTime" && o.Action == EnumFilterAction.SmallThan).Value);
var tables = new List<string>();
for (var time = start; time <= end; time = time.AddMonths(1))
{
@ -223,18 +223,32 @@ public class VmiAppService : ApplicationService, IJobService, ITransientDependen
if (!tables.Contains(tableName))
{
tables.Add(tableName);
if (db.Database.ExecuteSqlRaw($"select OBJECT_ID('{tableName}', 'U')") == -1)
{
var tran = db.Database.BeginTransaction();
db.Database.ExecuteSqlRaw($"select * into {tableName} from Set_VmiLog");
db.Database.ExecuteSqlRaw($"create clustered index IX_{tableName} on {tableName} (BillTime)");
tran.Commit();
}
}
}
//不存在则创建table
tables.ForEach(tableName =>
{
using var scope = this._serviceProvider.CreateScope();
var context = scope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
using var connection = context.Database.GetDbConnection();
connection.Open();
var cmd = connection.CreateCommand();
cmd.CommandText = $"select OBJECT_ID('{tableName}', 'U')";
var result = cmd.ExecuteScalar().ToString();
if (result == string.Empty)
{
cmd.CommandText = $"select * into {tableName} from Set_VmiLog;create clustered index IX_{tableName} on {tableName} (BillTime);";
cmd.ExecuteNonQuery();
}
});
//生成 union all 的 SQL
var sql = $"select * from {tables.First()}";
tables.Skip(1).ForEach(o => sql += $" union all select * from ${o}");
//使用 FromSqlRaw 查询
using var scope = this._serviceProvider.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
var query = db.Set<VmiLog>().FromSqlRaw(sql);
var filters = input.Filters.ToLambda<VmiLog>();
if (input.Filters.Count > 0)

3
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAsyncBalanceService.cs

@ -37,6 +37,9 @@ public class VmiAsyncBalanceService : ApplicationService, IJobService, ITransien
foreach (var message in messages)
{
var log = JsonSerializer.Deserialize<VmiLog>(message.Message);
//插入分表
//var tableName = $"Set_VmiLog_{log.BillTime.Year}_{(time.Month - 1) / 3 + 1}";
//插入库存
var balance = db.Set<VmiBalance>().FirstOrDefault(
o => o.DeliverBillType == log.DeliverBillType &&
o.CodeType == log.CodeType &&

2
code/src/Modules/SettleAccount/src/SettleAccount.Domain.Shared/SettleAccount.Domain.Shared.csproj

@ -16,7 +16,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Magicodes.IE.Excel" Version="2.5.4.6" />
<PackageReference Include="Magicodes.IE.Excel" Version="2.5.4.8" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
<PackageReference Include="NPOI" Version="2.5.4" />
<PackageReference Include="Shouldly" Version="4.0.3" />

6
code/src/Modules/SettleAccount/src/SettleAccount.Domain/SettleAccount.Domain.csproj

@ -39,9 +39,9 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="EFCore.BulkExtensions" Version="5.2.8" />
<PackageReference Include="Magicodes.IE.Csv" Version="2.5.4.6" />
<PackageReference Include="Magicodes.IE.Excel" Version="2.5.4.6" />
<PackageReference Include="EFCore.BulkExtensions" Version="5.3.0" />
<PackageReference Include="Magicodes.IE.Csv" Version="2.5.4.8" />
<PackageReference Include="Magicodes.IE.Excel" Version="2.5.4.8" />
<PackageReference Include="Volo.Abp.AuditLogging.Domain" Version="4.3.3" />
<PackageReference Include="Volo.Abp.BackgroundJobs.HangFire" Version="4.3.3" />
<PackageReference Include="Volo.Abp.BlobStoring" Version="4.3.3" />

12
code/src/Shared/Win.Sfs.Shared/Win.Sfs.Shared.csproj

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp5</TargetFramework>
@ -13,11 +13,11 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
<PackageReference Include="Volo.Abp.Caching" Version="4.0.0" />
<PackageReference Include="Volo.Abp.Ddd.Application" Version="4.0.0" />
<PackageReference Include="Volo.Abp.Ddd.Application.Contracts" Version="4.0.0" />
<PackageReference Include="Volo.Abp.Ddd.Domain" Version="4.0.0" />
<PackageReference Include="Volo.Abp.EntityFrameworkCore" Version="4.0.0" />
<PackageReference Include="Volo.Abp.Caching" Version="4.3.3" />
<PackageReference Include="Volo.Abp.Ddd.Application" Version="4.3.3" />
<PackageReference Include="Volo.Abp.Ddd.Application.Contracts" Version="4.3.3" />
<PackageReference Include="Volo.Abp.Ddd.Domain" Version="4.3.3" />
<PackageReference Include="Volo.Abp.EntityFrameworkCore" Version="4.3.3" />
</ItemGroup>

2
code/src/Shared/Win.Utils/Win.Utils.csproj

@ -8,7 +8,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NPOI" Version="2.5.2" />
<PackageReference Include="NPOI" Version="2.5.4" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="5.6.3" />
</ItemGroup>

Loading…
Cancel
Save