学 赵 1 year ago
parent
commit
6a934a4967
  1. 2
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Startup.cs
  2. 4
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/form/form-input.js
  3. 2
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/form/form-item.js
  4. 4
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/settle/detail.js
  5. 68
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/vmi/adjust.js
  6. 155
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/vmi/backup.js
  7. 19
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/vmi/balance.js
  8. 69
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/vmi/inventory.js
  9. 40
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/vmi/log.js
  10. 52
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/vmi/vmi.js
  11. 13
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/request/index.js
  12. 10
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/router/business.js
  13. 6
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/styles/site.css
  14. 54
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/settle/_check.js
  15. 26
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/vmi/backup.js
  16. 25
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeEdiCompareAppService.cs
  17. 18
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeEdiCompareAppService.cs
  18. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeSyncBaseAppService.cs
  19. 250
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs
  20. 29
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAsyncBalanceService.cs
  21. 116
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAsyncMessageService.cs
  22. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Domain.Shared/SettleAccount.Domain.Shared.csproj
  23. 33
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/VmiAsyncTask.cs
  24. 12
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/VmiShardingRecord.cs
  25. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/JisBBACEidSeCompareReport.cs
  26. 216
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/SaSeEdiCompareDiff.cs
  27. 6
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/SettleAccount.Domain.csproj
  28. 20
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContextModelCreatingExtensions.cs
  29. 5803
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230828042700_vmi18.Designer.cs
  30. 186
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230828042700_vmi18.cs
  31. 109
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/SettleAccountDbContextModelSnapshot.cs
  32. 93
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisBBACSaSeEdiCompareExportService.cs
  33. 16
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisBBACSeEdiCompareExportService.cs
  34. 97
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisHBPOSaSeEdiCompareExportService.cs
  35. 14
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisHBPOSeEdiCompareExportService.cs
  36. 48
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/PubSaSeCompareExportService.cs
  37. 50
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeCompareExportBaseService.cs
  38. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeEdiCompareExportBaseService.cs
  39. 12
      code/src/Shared/Win.Sfs.Shared/Win.Sfs.Shared.csproj
  40. 2
      code/src/Shared/Win.Utils/Win.Utils.csproj

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

@ -55,7 +55,7 @@ public class Startup
services.AddSignalR(o => o.EnableDetailedErrors = true);
JobHostdService.AddService(services);
services.AddSingleton<JobHostdService>();
//services.AddHostedService(o => o.GetRequiredService<JobHostdService>());
services.AddHostedService(o => o.GetRequiredService<JobHostdService>());
services.AddRouting(options => options.ConstraintMap["slugify"] = typeof(SlugifyParameterTransformer));
services.AddMvc(options => options.Conventions.Add(new RouteTokenTransformerConvention(new SlugifyParameterTransformer())));
services.AddApplication<SettleAccountHttpApiHostModule>();

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

@ -15,7 +15,7 @@ export default {
<template v-else-if="schema.input==='datetime'">{{dayjs(model[prop]).format('YYYY-MM-DD HH:mm:ss')}}</template>
<template v-else-if="schema.input==='password'">******</template>
<template v-else-if="schema.input==='select'||schema.input==='tabs'">{{options.find(o=>o.value==model[prop])?.label??model[prop]}}</template>
<template v-else>{{model[prop]}}</template>
<template v-else><pre>{{model[prop]}}</pre></template>
</template>
</template>
<template v-else>
@ -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" />

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

@ -8,7 +8,7 @@ export default {
AppFormInput: defineAsyncComponent(() => import("./form-input.js")),
},
template: html`
<template v-if="!schema.hidden">
<template v-if="!schema.hidden&&showItem()">
<template v-if="schema.type==='object'"></template>
<template v-else-if="schema.type!=='array'||schema.items?.type!=='array'">
<el-form-item

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: {

68
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();
@ -18,14 +19,39 @@ const deleteMethod = "POST";
const importMethod = "POST";
const exportMethod = "POST";
const keys = [
"changedTime",
"realPartCode",
"custPartCode",
"custPartCode",
"codeType",
"deliverBillType",
"changedQty",
"billTime",
"changedNumber",
"assembleData",
"erpToLoc",
"orderNum",
"deliverSubBillType",
"vinCode",
"reMark",
];
export default function () {
return {
const editSchema = Object.assign({}, schema);
Object.keys(editSchema.properties).forEach((key) => {
if (!keys.some((o) => o === key)) {
delete editSchema.properties[key];
}
});
const result = {
query: {
url: queryUrl,
method: queryMethod,
hasFilter: true,
schema: {
title: "通用代码",
title: "人工库存调整",
type: "object",
properties: {
logTypes: { type: "array", hidden: true, default: ["Type500", "Type600"] },
@ -51,6 +77,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 +139,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: {
@ -139,7 +171,9 @@ export default function () {
deleteMethod,
importMethod,
exportMethod,
schema: schema,
schema: editSchema,
},
};
return result;
}

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

@ -1,139 +1,26 @@
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.disableQueryOnLoad = true;
//result.query.autoSubmit = true;
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
);
result.query.url = "settleaccount/vmi/backup";
result.edit.exportUrl = "settleaccount/vmi/backup-export";
result.edit.backupUrl = "settleaccount/vmi/vmi-backup/invoke";
return result;
}

19
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,24 @@ 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"),
},
{
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"),
},
{
logic: "and",
column: "erpToLoc",

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

@ -1,69 +0,0 @@
const options1 = [
{ value: 0, label: "无" },
{ value: 1, label: "JIS件" },
{ value: 2, label: "JIT直供件" },
{ value: 3, label: "印度件" },
{ value: 4, label: "北汽4S备件" },
];
const options2 = [
{ value: "01", label: "前保" },
{ value: " 02", label: "后保" },
{ value: "03", label: " 左门槛" },
{ value: "04", label: "右门槛" },
{ value: "05", label: "扰流板" },
{ value: "06", label: "前左轮眉" },
{ value: "07", label: "前右轮眉 " },
{ value: "08", label: "后左轮眉" },
{ value: "09", label: "后右轮眉" },
];
const options3 = [
{ value: 0, label: "无" },
{ value: 1, label: "保险杠BBAC" },
{ value: 2, label: "保险杠HBPO" },
{ value: 3, label: "买单件保险杠BBAC" },
{ value: 4, label: "买单件保险杠HBPO" },
{ value: 5, label: "买单件小件BBAC" },
{ value: 6, label: "买单件小件HBPO" },
{ value: 7, label: "小件BBAC" },
{ value: 8, label: "小件HBPO" },
{ value: 9, label: "JIT直供件BBAC" },
{ value: 10, label: "JIT直供件HBPO" },
];
const billType = {
title: "发货类型",
type: "number",
input: "select",
options: options1,
clearable: true,
rules: [
{
required: true,
},
],
};
const codeType = {
title: "生产码类型",
type: "string",
input: "select",
options: options2,
clearable: true,
rules: [
{
required: true,
},
],
};
const subBillType = {
title: "发货子类型",
type: "number",
input: "select",
options: options3,
clearable: true,
rules: [
{
required: true,
},
],
};
export { billType, codeType, subBillType };

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: {

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

@ -8,21 +8,38 @@ function useSchema() {
realPartCode: {
title: "LU零件号",
type: "string",
rules: [
{
required: true,
},
],
},
custPartCode: {
title: "客户零件号",
type: "string",
rules: [
{
required: true,
},
],
},
codeType,
deliverBillType,
qty: {
title: "数量",
type: "string",
input: "number",
},
rules: [
{
required: true,
},
],
billTime: {
title: "发运日期",
type: "string",
input: "datetime",
clearable: true,
},
assembleData: {
title: "订单日期",
@ -32,6 +49,11 @@ function useSchema() {
erpToLoc: {
title: "ERP库位",
type: "string",
rules: [
{
required: true,
},
],
},
seq: {
title: "EDI顺序号",
@ -40,6 +62,11 @@ function useSchema() {
orderNum: {
title: "客户订单号",
type: "string",
rules: [
{
required: true,
},
],
},
uniqueCode: {
title: "塑件唯一码",
@ -69,26 +96,40 @@ function useSchema() {
vinCode: {
title: "EDI订单生产码",
type: "string",
rules: [
{
required: true,
},
],
},
reMark: {
title: "备注",
type: "string",
input: "textarea",
},
},
};
}
function useLogSchema() {
return Object.assign(
const result = useSchema();
result.properties = Object.assign(
{
changedNumber: {
title: "变动单号",
type: "string",
rules: [
{
required: true,
},
],
},
changedTime: {
title: "变动时间",
type: "string",
input: "datetime",
clearable: false,
readOnly: true,
},
changedType: {
title: "变动类型",
@ -110,6 +151,12 @@ function useLogSchema() {
changedQty: {
title: "变动数量",
type: "string",
input: "number",
rules: [
{
required: true,
},
],
},
isReplenished: {
type: "boolean",
@ -124,8 +171,9 @@ function useLogSchema() {
type: "string",
},
},
useSchema()
result.properties
);
return result;
}
export default useSchema;

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

@ -29,6 +29,7 @@ async function getResult(response) {
[204, "无返回值"],
[400, "请求参数错误"],
[401, "未登录"],
[415, "不支持的内容类型"],
[403, "权限不足"],
[500, "服务器异常"],
[503, "服务不可用"],
@ -37,8 +38,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 +50,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 ?? result.status;
}
}
return result;
}
@ -91,7 +97,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"),
],
},
{

6
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/styles/site.css

@ -124,8 +124,10 @@ a.logo {
}
.el-select,
.el-input-number {
/* width: 100%; */
.el-input-number,
.el-date-editor.el-input,
.el-date-editor.el-input__wrapper {
width: 100%;
}
/* markdown component */

54
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/settle/_check.js

@ -13,32 +13,28 @@ export default {
components: { AppForm, AppTable },
template: html`<el-drawer v-if="refreshRef" v-model="show" destroy-on-close size="50%" class="page-drawer" :close-on-click-modal="false">
<template #header> <span class="el-dialog__title"> 结算明细 </span> </template>
<el-row style="height:calc(100% - 160px);" v-loading="loading">
<el-col>
<el-tabs>
<el-tab-pane :label="columns1.title" v-if="model.invoicE_MAP_GROUP.length">
<el-scrollbar>
<app-table :data="model.invoicE_MAP_GROUP" :columns="columns1" />
</el-scrollbar>
</el-tab-pane>
<el-tab-pane :label="columns2.title" v-if="model.invoicE_WAIT_DETAIL.length">
<el-scrollbar>
<app-table :data="model.invoicE_WAIT_DETAIL" :columns="columns2" />
</el-scrollbar>
</el-tab-pane>
<el-tab-pane :label="columns3.title" v-if="model.invoicE_NOT_SETTLE.length">
<el-scrollbar>
<app-table :data="model.invoicE_NOT_SETTLE" :columns="columns3" />
</el-scrollbar>
</el-tab-pane>
<el-tab-pane :label="columns4.title" v-if="model.adJ_DETAIL.length">
<el-scrollbar>
<app-table :data="model.adJ_DETAIL" :columns="columns4" />
</el-scrollbar>
</el-tab-pane>
</el-tabs>
</el-col>
</el-row>
<el-tabs style="height:100%;">
<el-tab-pane :label="columns1.title" v-if="model.invoicE_MAP_GROUP.length">
<el-scrollbar style="height:100%;">
<app-table :data="model.invoicE_MAP_GROUP" :columns="columns1" />
</el-scrollbar>
</el-tab-pane>
<el-tab-pane :label="columns2.title" v-if="model.invoicE_WAIT_DETAIL.length">
<el-scrollbar>
<app-table :data="model.invoicE_WAIT_DETAIL" :columns="columns2" />
</el-scrollbar>
</el-tab-pane>
<el-tab-pane :label="columns3.title" v-if="model.invoicE_NOT_SETTLE.length">
<el-scrollbar>
<app-table :data="model.invoicE_NOT_SETTLE" :columns="columns3" />
</el-scrollbar>
</el-tab-pane>
<el-tab-pane :label="columns4.title" v-if="model.adJ_DETAIL.length">
<el-scrollbar>
<app-table :data="model.adJ_DETAIL" :columns="columns4" />
</el-scrollbar>
</el-tab-pane>
</el-tabs>
<template #footer>
<span class="dialog-footer">
<el-button type="primary" @click="show=false"> 返回 </el-button>
@ -155,14 +151,18 @@ export default {
</template>
</el-dialog>`,
styles: html` <style>
.page-drawer .el-tabs,
.page-drawer .el-tab-pane {
height: 100%;
}
.page-drawer .el-tabs__content {
width: 100%;
height: calc(100% - 160px);
}
.page-drawer .el-tabs__content,
.page-drawer .el-scrollbar {
width: 100%;
height: calc(100% - 160px - 40px);
height: calc(100% - 40px);
}
.re-open .el-dialog__footer {
display: flex;

26
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/vmi/backup.js

@ -1,15 +1,35 @@
import AppList from "../../../components/list/index.js";
import html from "html";
import { ref, nextTick } from "vue";
import useConfig from "../../../models/vmi/backup.js";
import { useAppStore } from "../../store/index.js";
import request from "../../request/index.js";
export default {
components: { AppList },
template: html`<app-list :config="config" @command="onCommand" />`,
template: html`<app-list ref="appListRef" :config="config" @command="onCommand" />`,
setup() {
const appListRef = ref(null);
const config = useConfig();
const appStore = useAppStore();
const onCommand = async (item, rows) => {
console.log(item.path, item, rows);
if (item.path === "invoke") {
const url = config.edit.backupUrl;
await appListRef.value.onClick(
async () => {
const result = await request(url, null, { method: "POST" }, true);
if (!result.errors) {
appStore.isRefreshing = true;
nextTick(() => {
appStore.isRefreshing = false;
});
}
},
`是否手动进行备份?`,
false
);
}
};
return { config, onCommand };
return { appListRef, config, onCommand };
},
};

25
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeEdiCompareAppService.cs

@ -69,31 +69,6 @@ public class JisBBACSeEdiCompareAppService : ApplicationService, IInvocable
db.BulkUpdate<BBAC_SE_EDI>(ediDetails);
}
db.SaveChanges();
//var keyCodes = seDetailGroup.Join(ediDetailGroup, a => new { a.PN, a.LU }, b => new { b.PN, b.LU }, (se, edi) => new { se.PN, se.LU }).Take(1000).ToList();
//if (keyCodes.Any())
//{
// var pnLus = keyCodes.GroupBy(t => t.PN).Select(t => new { t.Key, Lus = t.Where(p => p.PN == t.Key).Select(t => t.LU) });
// pnLus.ForEach(pnLu =>
// {
// var pn = pnLu.Key;
// var lus = pnLu.Lus;
// var seDetails = db.Set<BBAC_SE_DETAIL>().Where(t => t.PN == pn && lus.Contains(t.CustomerPartCodeNoSpace));
// var ediDetails = db.Set<BBAC_SE_EDI>().Where(t => t.PN == pn && lus.Contains(t.LU));
// if (seDetails.Any())
// {
// seDetails.ForEach(t => t.IsHaveEdiData = true);
// db.Set<BBAC_SE_DETAIL>().UpdateRange(seDetails);
// }
// if (ediDetails.Any())
// {
// ediDetails.ForEach(t => t.IsHaveSeData = true);
// db.Set<BBAC_SE_EDI>().UpdateRange(ediDetails);
// }
// });
// db.SaveChanges();
//}
}
}
catch (Exception)

18
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeEdiCompareAppService.cs

@ -11,6 +11,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using SettleAccount.Domain.BQ;
using Volo.Abp.Application.Services;
using Volo.Abp.Uow;
using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs;
@ -28,19 +29,25 @@ public class JisHBPOSeEdiCompareAppService : ApplicationService, IInvocable
/// HBPO发运数据仓储
/// </summary>
private readonly INormalEfCoreRepository<HBPO_SE_DETAIL, Guid> _hbpoSeDetailRepository;
/// <summary>
/// HBPOEDI数据仓储
/// </summary>
private readonly INormalEfCoreRepository<HBPO_SE_EDI, Guid> _hbpoSeEdiRepository;
/// <summary>
/// UnitOfWork
/// </summary>
private readonly IUnitOfWorkManager _unitOfWorkManager;
public JisHBPOSeEdiCompareAppService(
IServiceProvider serviceProvider,
INormalEfCoreRepository<HBPO_SE_DETAIL, Guid> hbpoSeDetailRepository, INormalEfCoreRepository<HBPO_SE_EDI, Guid> hbpoSeEdiRepository)
INormalEfCoreRepository<HBPO_SE_DETAIL, Guid> hbpoSeDetailRepository,
INormalEfCoreRepository<HBPO_SE_EDI, Guid> hbpoSeEdiRepository,
IUnitOfWorkManager unitOfWorkManager)
{
_serviceProvider = serviceProvider;
_hbpoSeDetailRepository = hbpoSeDetailRepository;
_hbpoSeEdiRepository = hbpoSeEdiRepository;
_unitOfWorkManager = unitOfWorkManager;
}
/// <summary>
@ -54,7 +61,8 @@ public class JisHBPOSeEdiCompareAppService : ApplicationService, IInvocable
var db = serviceScope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
await HandDelEdiDataAsync().ConfigureAwait(false);
lock (_lockObj)
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: false))
{
var seDetailGroup = db.Set<HBPO_SE_DETAIL>().Where(t => t.IsHaveEdiData == false).GroupBy(t => new { t.PN, t.CustomerPartCodeNoSpace }).Select(t => new { t.Key.PN, LU = t.Key.CustomerPartCodeNoSpace });
var ediDetailGroup = db.Set<HBPO_SE_EDI>().Where(t => t.IsDeleted == false && t.IsHaveSeData == false).GroupBy(t => new { t.PN, t.LU }).Select(t => new { t.Key.PN, t.Key.LU });
@ -74,7 +82,6 @@ public class JisHBPOSeEdiCompareAppService : ApplicationService, IInvocable
var seDetails = seDetailsQuery.Take(5000).ToList();
var ediDetails = ediDetailsQuery.Take(5000).ToList();
if (seDetails.Any())
{
seDetails.ForEach(t => t.IsHaveEdiData = true);
@ -85,7 +92,8 @@ public class JisHBPOSeEdiCompareAppService : ApplicationService, IInvocable
ediDetails.ForEach(t => t.IsHaveSeData = true);
db.BulkUpdate<HBPO_SE_EDI>(ediDetails);
}
db.SaveChanges();
await uow.SaveChangesAsync().ConfigureAwait(false);
//db.SaveChanges();
}
}
catch (Exception)

2
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeSyncBaseAppService.cs

@ -126,7 +126,7 @@ public class JisHBPOSeSyncBaseAppService : ApplicationService, IInvocable
t.KeyCode = t.PN + t.LU;
if (t.BillTime != null)
{
t.Version = int.Parse(t.BillTime?.ToString("YYYYMM"));
t.Version = int.Parse(t.BillTime?.ToString("yyyyMM"));
}
});
await _settleAccountDbContext.BulkInsertAsync(jisSeDetails).ConfigureAwait(false);

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

@ -1,12 +1,14 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Dynamic.Core;
using System.Reflection;
using System.Threading;
using System.Text.Json;
using System.Threading.Tasks;
using ClosedXML.Excel;
using LinqToDB.Data;
@ -42,12 +44,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ;
[Route("api/settleaccount/[controller]/[action]")]
public class VmiAppService : ApplicationService, IJobService, ITransientDependency
{
public static SemaphoreSlim backupLock = new SemaphoreSlim(1);
public static object backupLock = new object();
private readonly IConfiguration _cfg;
private readonly IServiceProvider _serviceProvider;
private readonly INormalEfCoreRepository<VmiBalance, Guid> _balanceRepository;
private readonly INormalEfCoreRepository<VmiLog, Guid> _logRepository;
private readonly INormalEfCoreRepository<VmiSnapshot, Guid> _snapshotRepository;
private readonly IBlobContainer<MyFileContainer> _fileContainer;
private readonly IHubContext<PageHub> _hubContext;
private readonly ICurrentUser _currentUser;
@ -56,7 +57,6 @@ public class VmiAppService : ApplicationService, IJobService, ITransientDependen
IServiceProvider serviceProvider,
INormalEfCoreRepository<VmiBalance, Guid> balanceRepository,
INormalEfCoreRepository<VmiLog, Guid> logRepository,
INormalEfCoreRepository<VmiSnapshot, Guid> snapshotRepository,
IBlobContainer<MyFileContainer> fileContainer,
IHubContext<PageHub> hubContext,
ICurrentUser currentUser)
@ -65,7 +65,6 @@ public class VmiAppService : ApplicationService, IJobService, ITransientDependen
this._serviceProvider = serviceProvider;
this._balanceRepository = balanceRepository;
this._logRepository = logRepository;
this._snapshotRepository = snapshotRepository;
this._fileContainer = fileContainer;
this._hubContext = hubContext;
this._currentUser = currentUser;
@ -138,6 +137,8 @@ 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}_BillTime on {table} (BillTime)");
db.Database.ExecuteSqlRaw($"alter table {table} add constraint PK_{table} primary key (Id);");
snapshot.End = DateTime.Now;
transaction.Commit();
return Task.CompletedTask;
@ -156,25 +157,19 @@ public class VmiAppService : ApplicationService, IJobService, ITransientDependen
/// </summary>
[HttpPost("invoke")]
[DisableValidation]
public virtual async Task<IActionResult> VmiBackup()
public virtual IActionResult VmiBackup()
{
if (backupLock.CurrentCount == 1)
lock (backupLock)
{
return new JsonResult(new { Code = 500, Message = "备份程序正在运行" });
}
await backupLock.WaitAsync().ConfigureAwait(false);
try
{
await Invoke(_serviceProvider).ConfigureAwait(false);
return new JsonResult(new { Code = 200, Message = "备份成功" });
}
catch (Exception ex)
{
return new JsonResult(new { Code = 500, Message = ex.Message, Data = ex.ToString() });
}
finally
{
backupLock.Release();
try
{
Invoke(_serviceProvider).Wait();
return new JsonResult(new { Code = 200, Message = "备份成功" });
}
catch (Exception ex)
{
return new JsonResult(new { Code = 500, Message = ex.Message, Data = ex.ToString() });
}
}
}
@ -192,7 +187,7 @@ public class VmiAppService : ApplicationService, IJobService, ITransientDependen
}
/// <summary>
/// 库存余额导出
/// 1.1库存余额导出
/// </summary>
[HttpPost]
public async Task<string> BalanceExport(RequestDto input)
@ -205,37 +200,111 @@ public class VmiAppService : ApplicationService, IJobService, ITransientDependen
}
/// <summary>
/// 2.库存事务查询
/// 快照列表
/// </summary>
[HttpPost]
public async Task<List<VmiSnapshot>> Snapshot()
{
var connectionString = this._serviceProvider.GetRequiredService<IConfiguration>().GetConnectionString("SettleAccountService");
using var connection = new SqlConnection(connectionString);
connection.Open();
var options = new DbContextOptionsBuilder<SettleAccountDbContext>().UseSqlServer(connection).Options;
using var db = new SettleAccountDbContext(options);
var list = db.Set<VmiSnapshot>().AsNoTracking().OrderByDescending(o => o.Start).ToList();
return list;
}
/// <summary>
/// 2.时点库存查询
/// </summary>
[HttpPost]
public async Task<PagedResultDto<VmiBalance>> Backup(BackupListRequest input)
{
using var scope = this._serviceProvider.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
var name = input.Name;
var sql = $"select * from {name}";
var query = db.Set<VmiBalance>().FromSqlRaw(sql);
var filters = input.Filters.ToLambda<VmiBalance>();
if (input.Filters.Count > 0)
{
query = query.Where(input.Filters.ToLambda<VmiBalance>());
}
var totalCount = query.Count();
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>
/// 2.1时点库存导出
/// </summary>
[HttpPost]
public async Task<string> BackupExport(BackupListRequest input)
{
using var scope = this._serviceProvider.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
var name = input.Name;
var sql = $"select * from {name}";
var query = db.Set<VmiBalance>().FromSqlRaw(sql);
var filters = input.Filters.ToLambda<VmiBalance>();
if (input.Filters.Count > 0)
{
query = query.Where(input.Filters.ToLambda<VmiBalance>());
}
var totalCount = query.Count();
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;
}
/// <summary>
/// 3.库存事务查询
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[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>();
var connectionString = this._serviceProvider.GetRequiredService<IConfiguration>().GetConnectionString("SettleAccountService");
using var connection = new SqlConnection(connectionString);
connection.Open();
for (var time = start; time <= end; time = time.AddMonths(1))
{
var tableName = $"Set_VmiLog_{time.Year}_{(time.Month - 1) / 3 + 1}";
if (!tables.Contains(tableName))
{
tables.Add(tableName);
if (db.Database.ExecuteSqlRaw($"select OBJECT_ID('{tableName}', 'U')") == -1)
var command = connection.CreateCommand();
command.CommandText = $"select OBJECT_ID('{tableName}', 'U')";
var result = command.ExecuteScalar().ToString();
if (result != string.Empty)
{
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();
tables.Add(tableName);
}
else
{
Debug.WriteLine($"{tableName}不存在");
}
}
}
var sql = $"select * from {tables.First()}";
tables.Skip(1).ForEach(o => sql += $" union all select * from ${o}");
var query = db.Set<VmiLog>().FromSqlRaw(sql);
var options = new DbContextOptionsBuilder<SettleAccountDbContext>().UseSqlServer(connection).Options;
using var db = new SettleAccountDbContext(options);
var sql = string.Empty;
if (tables.Any())
{
//生成 union all 的 SQL使用 FromSqlRaw 查询,如果没有分表则使用原始表
sql = $"select * from {tables.First()}";
tables.Skip(1).ForEach(o => sql += $" union all select * from ${o}");
}
var query = string.IsNullOrEmpty(sql) ? db.Set<VmiLog>().AsQueryable() : db.Set<VmiLog>().FromSqlRaw(sql);
var filters = input.Filters.ToLambda<VmiLog>();
if (input.Filters.Count > 0)
{
@ -248,12 +317,12 @@ public class VmiAppService : ApplicationService, IJobService, ITransientDependen
}
/// <summary>
/// 库存事务导出
/// 3.1库存事务导出
/// </summary>
[HttpPost]
public async Task<string> LogExport(RequestDto input)
{
var entities = await _logRepository.GetListByFilterAsync(input.Filters).ConfigureAwait(false);
var entities = await _logRepository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount).ConfigureAwait(false);
var fileName = $"库存事务_{DateTime.Now.ToString("yyyy-MM-dd_HH:mm:ss")}.xlsx";
var content = this.GetContent(entities, "库存事务_");
await _fileContainer.SaveAsync(fileName, content, true).ConfigureAwait(false);
@ -280,22 +349,42 @@ public class VmiAppService : ApplicationService, IJobService, ITransientDependen
/// <param name="log"></param>
/// <returns></returns>
[HttpPost]
public async Task EditBalance(VmiLog log)
public IActionResult EditBalance(VmiLog log)
{
log.SetId(GuidGenerator.Create());
if (log.ChangedQty >= decimal.Zero)
var connectionString = this._serviceProvider.GetRequiredService<IConfiguration>().GetConnectionString("SettleAccountService");
using var connection = new SqlConnection(connectionString);
connection.Open();
using var transaction = connection.BeginTransaction();
try
{
log.Qty = log.ChangedQty;
log.LogType = VmiLogType.Type500;
log.ChangedType = VmiType.In;
var options = new DbContextOptionsBuilder<SettleAccountDbContext>().UseSqlServer(connection).Options;
using var db = new SettleAccountDbContext(options);
log.SetId(GuidGenerator.Create());
if (log.ChangedQty >= decimal.Zero)
{
log.Qty = log.ChangedQty;
log.LogType = VmiLogType.Type500;
log.ChangedType = VmiType.In;
}
else
{
log.Qty = -log.Qty;
log.LogType = VmiLogType.Type600;
log.ChangedType = VmiType.Out;
}
log.ChangedBy = this._currentUser.UserName;
log.ChangedTime = DateTime.Now;
db.Set<VmiLog>().Add(log);
db.Set<VmiMessage>().Add(new VmiMessage(GuidGenerator.Create()) { Message = JsonSerializer.Serialize(log) });
transaction.Commit();
return new OkResult();
}
else
catch (Exception ex)
{
log.Qty = -log.Qty;
log.LogType = VmiLogType.Type600;
log.ChangedType = VmiType.Out;
transaction.Rollback();
Console.WriteLine(ex.ToString());
return new JsonResult(new { code = 400, data = ex.ToString(), message = ex.Message }); ;
}
log.ChangedBy = this._currentUser.UserName;
}
/// <summary>
@ -310,67 +399,10 @@ public class VmiAppService : ApplicationService, IJobService, ITransientDependen
var list = this.ImportInternal<VmiLog>(ms.ToArray());
foreach (var file in list)
{
await EditBalance(file).ConfigureAwait(false);
EditBalance(file);
}
}
/// <summary>
/// 快照列表
/// </summary>
[HttpPost]
public async Task<ListResultDto<VmiSnapshot>> Snapshot()
{
var list = await _snapshotRepository.GetListAsync().ConfigureAwait(false);
return new ListResultDto<VmiSnapshot>(list);
}
/// <summary>
/// 3.时点库存查询
/// </summary>
[HttpPost]
public async Task<PagedResultDto<VmiBalance>> Backup(BackupListRequest input)
{
using var scope = this._serviceProvider.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
var name = input.Name;
var sql = $"select * from {name}";
var query = db.Set<VmiBalance>().FromSqlRaw(sql);
var filters = input.Filters.ToLambda<VmiBalance>();
if (input.Filters.Count > 0)
{
query = query.Where(input.Filters.ToLambda<VmiBalance>());
}
var totalCount = query.Count();
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)
{
using var scope = this._serviceProvider.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
var name = input.Name;
var sql = $"select * from {name}";
var query = db.Set<VmiBalance>().FromSqlRaw(sql);
var filters = input.Filters.ToLambda<VmiBalance>();
if (input.Filters.Count > 0)
{
query = query.Where(input.Filters.ToLambda<VmiBalance>());
}
var totalCount = query.Count();
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 List<T> ImportInternal<T>(byte[] data)
{
var list = new List<T>();

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

@ -1,9 +1,12 @@
using System;
using System.Data.SqlClient;
using System.Linq;
using System.Linq.Dynamic.Core;
using System.Text.Json;
using System.Threading.Tasks;
using Magicodes.ExporterAndImporter.Core.Extension;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Omu.ValueInjecter;
using Volo.Abp.Application.Services;
@ -27,16 +30,36 @@ public class VmiAsyncBalanceService : ApplicationService, IJobService, ITransien
public async Task Invoke(IServiceProvider serviceProvider)
{
using var scope = _serviceProvider.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
using var transaction = db.Database.BeginTransaction();
var connectionString = serviceProvider.GetRequiredService<IConfiguration>().GetConnectionString("SettleAccountService");
using var connection = new SqlConnection(connectionString);
connection.Open();
using var transaction = connection.BeginTransaction();
try
{
var options = new DbContextOptionsBuilder<SettleAccountDbContext>().UseSqlServer(connection).Options;
using var db = new SettleAccountDbContext(options);
var messages = db.Set<VmiMessage>().Where(o => !o.isConsumed).OrderBy(o => o.Number).ToList();
var repo = db.Set<VmiBalance>();
foreach (var message in messages)
{
var log = JsonSerializer.Deserialize<VmiLog>(message.Message);
//插入分表
var table = $"Set_VmiLog_{log.ChangedTime.Year}_{(log.ChangedTime.Month - 1) / 3 + 1}";
var command = connection.CreateCommand();
command.Transaction = transaction;
command.CommandText = $"select OBJECT_ID('{table}', 'U')";
var result = command.ExecuteScalar().ToString();
if (result == string.Empty)
{
command.CommandText = $"select * into {table} from Set_VmiLog where 1=0;";
command.CommandText += $"create clustered index IX_{table}_ChangedTime on {table} (ChangedTime);";
db.Database.ExecuteSqlRaw($"alter table {table} add constraint PK_{table} primary key (Id);");
command.ExecuteNonQuery();
}
//插入到分表
command.CommandText = $"insert into {table} select * from Set_VmiLog where id ='{log.Id}'";
//插入库存
var balance = db.Set<VmiBalance>().FirstOrDefault(
o => o.DeliverBillType == log.DeliverBillType &&
o.CodeType == log.CodeType &&

116
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAsyncMessageService.cs

@ -1,116 +0,0 @@
using System;
using System.Linq;
using System.Linq.Dynamic.Core;
using System.Threading.Tasks;
using EFCore.BulkExtensions;
using Microsoft.AspNetCore.SignalR;
using Microsoft.Extensions.DependencyInjection;
using SettleAccount.Job.SignalR;
using Volo.Abp.Application.Services;
using Volo.Abp.DependencyInjection;
using Win.Sfs.SettleAccount.Entities.BQ.Vmi;
namespace Win.Sfs.SettleAccount.Entities.BQ;
/// <summary>
/// 消息表定时清理
/// </summary>
public class VmiAsyncMessageService : ApplicationService, IJobService, ITransientDependency
{
private readonly IServiceProvider _serviceProvider;
public VmiAsyncMessageService(IServiceProvider serviceProvider)
{
this._serviceProvider = serviceProvider;
}
public Task Invoke(IServiceProvider serviceProvider)
{
using var scope = _serviceProvider.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
db.Set<VmiMessage>().Where(o => o.isConsumed).BatchDelete();
var count = db.Set<VmiMessage>().Where(o => !o.isConsumed).Count();
scope.ServiceProvider.GetService<IHubContext<PageHub>>().Clients.All.ServerToClient("VmiBalance", count.ToString(), "");
return Task.CompletedTask;
}
}
/// <summary>
/// 库存事务定时备份
/// </summary>
public class VmiLogbackupService : ApplicationService, IJobService, ITransientDependency
{
private readonly IServiceProvider _serviceProvider;
public VmiLogbackupService(IServiceProvider serviceProvider)
{
this._serviceProvider = serviceProvider;
}
public Task Invoke(IServiceProvider serviceProvider)
{
using var scope = _serviceProvider.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
using var transaction = db.Database.BeginTransaction();
try
{
var task = db.Set<VmiSyncTask>().FirstOrDefault(o => o.Number == "Set_VmiLog");
if (task != null)
{
var now = DateTime.Now;
task.LastUpdate = now;
var query = db.Set<VmiLog>().Where(o => o.UpdatedTime >= task.LastUpdate && o.UpdatedTime < now);
foreach (var item in query)
{
//同步到questdb
}
}
}
catch
{
transaction.Rollback();
throw;
}
return Task.CompletedTask;
}
}
/// <summary>
/// 库存余额定时备份
/// </summary>
public class VmiLogBalanceService : ApplicationService, IJobService, ITransientDependency
{
private readonly IServiceProvider _serviceProvider;
public VmiLogBalanceService(IServiceProvider serviceProvider)
{
this._serviceProvider = serviceProvider;
}
public Task Invoke(IServiceProvider serviceProvider)
{
using var scope = _serviceProvider.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
using var transaction = db.Database.BeginTransaction();
try
{
var task = db.Set<VmiSyncTask>().FirstOrDefault(o => o.Number == "Set_VmiBalance");
if (task != null)
{
var now = DateTime.Now;
task.LastUpdate = now;
var query = db.Set<VmiBalance>().Where(o => o.UpdatedTime >= task.LastUpdate && o.UpdatedTime < now);
foreach (var item in query)
{
//同步到questdb
}
}
}
catch
{
transaction.Rollback();
throw;
}
return Task.CompletedTask;
}
}

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" />

33
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/VmiAsyncTask.cs

@ -1,33 +0,0 @@
using System;
using Volo.Abp.Domain.Entities;
namespace Win.Sfs.SettleAccount.Entities.BQ.Vmi;
public class VmiSyncTask : Entity<Guid>
{
public VmiSyncTask()
{
ConcurrencyStamp = Guid.NewGuid().ToString("N");
}
public VmiSyncTask(Guid id) : base(id)
{
ConcurrencyStamp = Guid.NewGuid().ToString("N");
}
/// <summary>
/// 任务名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 同步数据时间戳初始起点
/// </summary>
public string Number { get; set; }
/// <summary>
/// 最后同步时间
/// </summary>
public DateTime LastUpdate { get; set; }
public string ConcurrencyStamp { get; set; }
}

12
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/VmiShardingRecord.cs

@ -1,12 +0,0 @@
using System;
using Volo.Abp.Domain.Entities;
namespace Win.Sfs.SettleAccount.Entities.BQ.Vmi;
public class VmiShardingRecord : Entity<Guid>
{
public string MainTable { get; set; }
public string ShardingTable { get; set; }
public DateTime Start { get; set; }
public DateTime End { get; set; }
}

2
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/JisBBACEidSeCompareReport.cs

@ -13,7 +13,7 @@ public class JisBBACEidSeCompareReport
}
/// <summary>
/// JisBBAC Edi发运对比导出
/// JisBBAC Edi发运对比导出
/// </summary>
[ExcelExporter(MaxRowNumberOnASheet = 900000)]
public class JisBBACEidSeCompareExport

216
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/SaSeEdiCompareDiff.cs

@ -42,6 +42,16 @@ public class SaSeEdiCompareDiff
[Display(Name = "客户下线时间")]
public DateTime? CustomerOfflineTime { get; set; }
/// <summary>
/// 小总成号
/// </summary>
[Display(Name = "小总成号")]
public string AssemblyCode { get; set; }
/// <summary>
/// 注塑码
/// </summary>
[Display(Name = "注塑码")]
public string InjectionCode { get; set; }
/// <summary>
/// 结算数量
/// </summary>
[Display(Name = "结算数量")]
@ -198,18 +208,78 @@ public class SaSeEdiCompareDetailExportJisBBAC : SaSeEdiCompareDetailExport, ISa
[ValueMapping("无结算有发运(无EDI数据)", 6)]
public EnumSaSeEdiCompareCategory Category { get; set; }
/// <summary>
/// 零件描述
/// 交货单号
/// </summary>
[Display(Name = "零件描述")]
[Display(Name = "交货单号")]
[ExporterHeader(DisplayName = "交货单号")]
public string WmsBillNum { get; set; }
/// <summary>
/// 发货日期
/// </summary>
[Display(Name = "发货日期")]
[ExporterHeader(DisplayName = "发货日期")]
public DateTime? ShippingDate { get; set; }
/// <summary>
/// 生产码
/// </summary>
[Display(Name = "生产码")]
[ExporterHeader(DisplayName = "订单生产码")]
public string PN { get; set; }
/// <summary>
/// 日顺序号
/// </summary>
[Display(Name = "日顺序号")]
[ExporterHeader(DisplayName = "日顺序号")]
public string SeqNumber { get; set; }
/// <summary>
/// PJIS日顺序号
/// </summary>
[Display(Name = "PJIS日顺序号")]
[ExporterHeader(DisplayName = "PJIS日顺序号")]
public string PJISSeqNumber { get; set; }
/// <summary>
/// 客户物料号
/// </summary>
[Display(Name = "客户物料号")]
[ExporterHeader(DisplayName = "客户物料号")]
public string CustomerPartCode { get; set; }
/// <summary>
/// 物料描述
/// </summary>
[Display(Name = "物料描述")]
[ExporterHeader(DisplayName = "物料描述")]
public string PartCodeDesc { get; set; }
/// <summary>
/// 替换厂内零件号
/// 厂内物料
/// </summary>
[Display(Name = "替换厂内零件号")]
[ExporterHeader(DisplayName = "替换厂内零件号")]
[Display(Name = "厂内物料号")]
[ExporterHeader(DisplayName = "厂内物料号")]
public string FactoryPartCode { get; set; }
/// <summary>
/// 替换厂内物料号
/// </summary>
[Display(Name = "替换厂内物料号")]
[ExporterHeader(DisplayName = "替换厂内物料号")]
public string ReplaceFactoryPartCode { get; set; }
/// <summary>
/// 客户下线时间
/// </summary>
[Display(Name = "客户下线时间")]
[ExporterHeader(DisplayName = "客户下线时间")]
public DateTime? CustomerOfflineTime { get; set; }
/// <summary>
/// 小总成号
/// </summary>
[Display(Name = "小总成号")]
[ExporterHeader(DisplayName = "小总成号")]
public string AssemblyCode { get; set; }
/// <summary>
/// 注塑码
/// </summary>
[Display(Name = "注塑码")]
[ExporterHeader(DisplayName = "注塑码")]
public string InjectionCode { get; set; }
/// <summary>
/// 结算数量
/// </summary>
[Display(Name = "结算数量")]
@ -227,6 +297,39 @@ public class SaSeEdiCompareDetailExportJisBBAC : SaSeEdiCompareDetailExport, ISa
[Display(Name = "Edi数量")]
[ExporterHeader(DisplayName = "Edi数量")]
public decimal EdiQty { get; set; }
/// <summary>
/// 结算与EDI量差
/// </summary>
[ExporterHeader(DisplayName = "结算与EDI量差")]
public decimal SaEdiQty => SAQty - EdiQty;
/// <summary>
/// WMS发货与EDI数量差
/// </summary>
[ExporterHeader(DisplayName = "WMS发货与EDI数量差")]
public decimal SeEdiQty => SEQty - EdiQty;
[Display(Name = "是否完全匹配")]
[ExporterHeader(DisplayName = "是否完全匹配")]
[ValueMapping("是", true)]
[ValueMapping("否", false)]
public bool MateType => SaEdiQty == 0 && SeEdiQty == 0;
/// <summary>
/// 定价
/// </summary>
[Display(Name = "定价")]
[ExporterHeader(DisplayName = "定价")]
public decimal? FixPrice { get; set; }
/// <summary>
/// ERP销售库位
/// </summary>
[Display(Name = "ERP销售库位")]
[ExporterHeader(DisplayName = "ERP销售库位")]
public string ToErpLocCode { get; set; }
/// <summary>
/// WMS发货库位
/// </summary>
[Display(Name = "WMS发货库位")]
[ExporterHeader(DisplayName = "WMS发货库位")]
public string ToLocCode { get; set; }
}
/// <summary>
@ -247,18 +350,78 @@ public class SaSeEdiCompareDetailExportJisHBPO : SaSeEdiCompareDetailExport, ISa
[ValueMapping("无结算有发运(无EDI数据)", 6)]
public EnumSaSeEdiCompareCategory Category { get; set; }
/// <summary>
/// 零件描述
/// 交货单号
/// </summary>
[Display(Name = "零件描述")]
[Display(Name = "交货单号")]
[ExporterHeader(DisplayName = "交货单号")]
public string WmsBillNum { get; set; }
/// <summary>
/// 发货日期
/// </summary>
[Display(Name = "发货日期")]
[ExporterHeader(DisplayName = "发货日期")]
public DateTime? ShippingDate { get; set; }
/// <summary>
/// 生产码
/// </summary>
[Display(Name = "生产码")]
[ExporterHeader(DisplayName = "订单生产码")]
public string PN { get; set; }
/// <summary>
/// 日顺序号
/// </summary>
[Display(Name = "日顺序号")]
[ExporterHeader(DisplayName = "日顺序号")]
public string SeqNumber { get; set; }
/// <summary>
/// PJIS日顺序号
/// </summary>
[Display(Name = "PJIS日顺序号")]
[ExporterHeader(DisplayName = "PJIS日顺序号")]
public string PJISSeqNumber { get; set; }
/// <summary>
/// 客户物料号
/// </summary>
[Display(Name = "客户物料号")]
[ExporterHeader(DisplayName = "客户物料号")]
public string CustomerPartCode { get; set; }
/// <summary>
/// 物料描述
/// </summary>
[Display(Name = "物料描述")]
[ExporterHeader(DisplayName = "物料描述")]
public string PartCodeDesc { get; set; }
/// <summary>
/// 替换厂内零件号
/// 厂内物料
/// </summary>
[Display(Name = "替换厂内零件号")]
[ExporterHeader(DisplayName = "替换厂内零件号")]
[Display(Name = "厂内物料号")]
[ExporterHeader(DisplayName = "厂内物料号")]
public string FactoryPartCode { get; set; }
/// <summary>
/// 替换厂内物料号
/// </summary>
[Display(Name = "替换厂内物料号")]
[ExporterHeader(DisplayName = "替换厂内物料号")]
public string ReplaceFactoryPartCode { get; set; }
/// <summary>
/// 客户下线时间
/// </summary>
[Display(Name = "客户下线时间")]
[ExporterHeader(DisplayName = "客户下线时间")]
public DateTime? CustomerOfflineTime { get; set; }
/// <summary>
/// 小总成号
/// </summary>
[Display(Name = "小总成号")]
[ExporterHeader(DisplayName = "小总成号")]
public string AssemblyCode { get; set; }
/// <summary>
/// 注塑码
/// </summary>
[Display(Name = "注塑码")]
[ExporterHeader(DisplayName = "注塑码")]
public string InjectionCode { get; set; }
/// <summary>
/// 结算数量
/// </summary>
[Display(Name = "结算数量")]
@ -276,6 +439,39 @@ public class SaSeEdiCompareDetailExportJisHBPO : SaSeEdiCompareDetailExport, ISa
[Display(Name = "Edi数量")]
[ExporterHeader(DisplayName = "Edi数量")]
public decimal EdiQty { get; set; }
/// <summary>
/// 结算与EDI量差
/// </summary>
[ExporterHeader(DisplayName = "结算与EDI量差")]
public decimal SaEdiQty => SAQty - EdiQty;
/// <summary>
/// WMS发货与EDI数量差
/// </summary>
[ExporterHeader(DisplayName = "WMS发货与EDI数量差")]
public decimal SeEdiQty => SEQty - EdiQty;
[Display(Name = "是否完全匹配")]
[ExporterHeader(DisplayName = "是否完全匹配")]
[ValueMapping("是", true)]
[ValueMapping("否", false)]
public bool MateType => SaEdiQty == 0 && SeEdiQty == 0;
/// <summary>
/// 定价
/// </summary>
[Display(Name = "定价")]
[ExporterHeader(DisplayName = "定价")]
public decimal? FixPrice { get; set; }
/// <summary>
/// ERP销售库位
/// </summary>
[Display(Name = "ERP销售库位")]
[ExporterHeader(DisplayName = "ERP销售库位")]
public string ToErpLocCode { get; set; }
/// <summary>
/// WMS发货库位
/// </summary>
[Display(Name = "WMS发货库位")]
[ExporterHeader(DisplayName = "WMS发货库位")]
public string ToLocCode { get; set; }
}
/// <summary>

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" />

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

@ -1327,7 +1327,6 @@ namespace Win.Sfs.SettleAccount
o.Configcode
})).IsUnique();
}));
builder.Entity<VmiBalance>().HasData(new VmiBalance(Guid.NewGuid()) { DeliverBillType = EnumDeliverBjBmpBillType.JIS件, RealPartCode = "PartCode", VinCode = "VinCode", ErpToLoc = "ErpToLoc", OrderNum = "OrderNum" });
builder.Entity<VmiLog>(b =>
{
@ -1342,6 +1341,7 @@ namespace Win.Sfs.SettleAccount
{
b.ToTable($"{options.TablePrefix}_VmiReplenished", options.Schema);
b.ConfigureByConvention();
b.HasIndex(o => o.BillTime).IsClustered();
});
builder.Entity<VmiSnapshot>(b =>
@ -1350,22 +1350,10 @@ namespace Win.Sfs.SettleAccount
b.ConfigureByConvention();
});
builder.Entity<VmiSyncTask>(b =>
{
b.ToTable($"{options.TablePrefix}_VmiSyncTask", options.Schema);
b.ConfigureByConvention();
b.Property(o => o.ConcurrencyStamp).HasMaxLength(50).IsConcurrencyToken();
});
//seed
builder.Entity<VmiSyncTask>().HasData(new VmiSyncTask("Set_VmiLog".ToGuid()) { Name = "库存事务备份", Number = "Set_VmiLog", LastUpdate = DateTime.Now.AddDays(-5).Date });
builder.Entity<VmiSyncTask>().HasData(new VmiSyncTask("Set_VmiBalance".ToGuid()) { Name = "库存余额备份", Number = "Set_VmiBalance", LastUpdate = DateTime.Now.AddDays(-5).Date });
builder.Entity<JobItem>().HasData(new JobItem("vmi".ToGuid()) { Name = "库存快照", Cron = "0 0 8 26 *", Service = "Win.Sfs.SettleAccount.Entities.BQ.VmiAppService" });
builder.Entity<JobItem>().HasData(new JobItem("vmi.balance".ToGuid()) { Name = "同步库存", Cron = "0 0/1 * * * ?", Service = "Win.Sfs.SettleAccount.Entities.BQ.VmiAsyncBalanceService" });
builder.Entity<JobItem>().HasData(new JobItem("vmi.message".ToGuid()) { Name = "消息监控", Cron = "0 0/1 * * * ?", Service = "Win.Sfs.SettleAccount.Entities.BQ.VmiAsyncMessageService" });
builder.Entity<JobItem>().HasData(new JobItem("vmi.log.sync".ToGuid()) { Name = "库存事务同步", Cron = "0 0/5 * * * ? *", Service = "Win.Sfs.SettleAccount.Entities.BQ.VmiAsyncMessageService" });
builder.Entity<JobItem>().HasData(new JobItem("vmi.balance.sync".ToGuid()) { Name = "库存余额同步", Cron = "0 0/5 * * * ? *", Service = "Win.Sfs.SettleAccount.Entities.BQ.VmiAsyncMessageService" });
builder.Entity<JobItem>().HasData(new JobItem("vmi".ToGuid()) { Name = "库存快照备份", Cron = "0 0 8 26 *", Service = "Win.Sfs.SettleAccount.Entities.BQ.VmiAppService" });
builder.Entity<JobItem>().HasData(new JobItem("vmi.balance".ToGuid()) { Name = "同步结算库存", Cron = "0 0/1 * * * ?", Service = "Win.Sfs.SettleAccount.Entities.BQ.VmiAsyncBalanceService" });
builder.Entity<JobItem>().HasData(new JobItem("vmi.message".ToGuid()) { Name = "事务消息监控", Cron = "0 0/1 * * * ?", Service = "Win.Sfs.SettleAccount.Entities.BQ.VmiAsyncMessageService" });
builder.Entity<JobItem>().HasData(new JobItem("JisBBACSeSync".ToGuid()) { Name = "JisBBAC发运数据同步", Cron = "0 0/30 * * * ? ", Service = "Win.Sfs.SettleAccount.Entities.BQ.Syncs.JisBBACSeSyncAppService" });
builder.Entity<JobItem>().HasData(new JobItem("JisHBPOSeSync".ToGuid()) { Name = "JisHBPO发运数据同步", Cron = "0 0/30 * * * ? ", Service = "Win.Sfs.SettleAccount.Entities.BQ.Syncs.JisHBPOSeSyncAppService" });
builder.Entity<JobItem>().HasData(new JobItem("MaiDanBBACSeSync".ToGuid()) { Name = "买单件BBAC发运数据同步", Cron = "0 0/30 * * * ? ", Service = "Win.Sfs.SettleAccount.Entities.BQ.Syncs.MaiDanBBACSeSyncAppService" });

5803
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230828042700_vmi18.Designer.cs

File diff suppressed because it is too large

186
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230828042700_vmi18.cs

@ -0,0 +1,186 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Win.Sfs.SettleAccount.Migrations
{
public partial class vmi18 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Set_VmiSyncTask");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("185c5968-e02b-267e-db2f-225fccfc9716"),
columns: new[] { "ConcurrencyStamp", "Name" },
values: new object[] { "89413f316dbf4647954b6669de927488", "同步结算库存" });
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("1bb02f67-ed05-6cc1-1507-502e8f6c7a31"),
columns: new[] { "ConcurrencyStamp", "Name" },
values: new object[] { "ebb73d81d23c4ed9a6ae59730d163f4b", "事务消息监控" });
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("49b1da12-418c-544d-fe8b-be7e5b572452"),
column: "ConcurrencyStamp",
value: "e581ee4de97a46b1a1c0ba75a101c064");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("6f68fc8f-b058-c3f4-e07d-722c61f3f7fa"),
column: "ConcurrencyStamp",
value: "a7be915b8a5541c58081c668219edfb7");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("7a0dc087-a859-5863-eb6e-56f588bd779e"),
column: "ConcurrencyStamp",
value: "1fb801f3cbff422082d888ee8b5dab64");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("8f7dc23d-e2e9-3691-cfe9-545bb958e3f2"),
column: "ConcurrencyStamp",
value: "df723d768280494e88d49734cc6e55e5");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("b9b9c79f-4894-474b-4f67-b1ec121c41e5"),
column: "ConcurrencyStamp",
value: "93962cebd40f490b9df08b215b2c7bd2");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("c09c23ea-815f-1b43-4476-2365a8d9a60b"),
column: "ConcurrencyStamp",
value: "1c542463eb8746db949bcda48eabdbd8");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("c1f71240-1b81-0107-8b23-ddc9811a3efe"),
column: "ConcurrencyStamp",
value: "c5b29d7fa18e4b9cb8bc1e354d10c3ac");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("ef3d8e8a-a88e-ca1f-e615-714c6bc48824"),
columns: new[] { "ConcurrencyStamp", "Name" },
values: new object[] { "25ec0d7c647f42d88882c4187af74201", "库存快照备份" });
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("f306b380-47e5-5c01-b902-67ca4113a8f4"),
column: "ConcurrencyStamp",
value: "7bbeaa02b39947c089eda7f4b05babb9");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Set_VmiSyncTask",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
LastUpdate = table.Column<DateTime>(type: "datetime2", nullable: false),
Name = table.Column<string>(type: "nvarchar(max)", nullable: true),
Number = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Set_VmiSyncTask", x => x.Id);
});
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("185c5968-e02b-267e-db2f-225fccfc9716"),
columns: new[] { "ConcurrencyStamp", "Name" },
values: new object[] { "b282d04b720a4453bac838a6d2702c5e", "同步库存" });
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("1bb02f67-ed05-6cc1-1507-502e8f6c7a31"),
columns: new[] { "ConcurrencyStamp", "Name" },
values: new object[] { "af7e13c541954124a384db3d957e96f8", "消息监控" });
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("49b1da12-418c-544d-fe8b-be7e5b572452"),
column: "ConcurrencyStamp",
value: "1c63ae9d135a409da20ef2956f075921");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("6f68fc8f-b058-c3f4-e07d-722c61f3f7fa"),
column: "ConcurrencyStamp",
value: "7d2a76e6327d46f4a93d15d91794de13");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("7a0dc087-a859-5863-eb6e-56f588bd779e"),
column: "ConcurrencyStamp",
value: "448472749b8e4be587a6c8a9079bb4c1");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("8f7dc23d-e2e9-3691-cfe9-545bb958e3f2"),
column: "ConcurrencyStamp",
value: "ffca086d0a884f118ec61e00c1ea11cf");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("b9b9c79f-4894-474b-4f67-b1ec121c41e5"),
column: "ConcurrencyStamp",
value: "9758552b36a24d20bc4fd3efaa2c828a");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("c09c23ea-815f-1b43-4476-2365a8d9a60b"),
column: "ConcurrencyStamp",
value: "7ac5c23ffc254496b3bfeac777aceb78");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("c1f71240-1b81-0107-8b23-ddc9811a3efe"),
column: "ConcurrencyStamp",
value: "a9ef4db8c8c547ff880badc98ecb3fb7");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("ef3d8e8a-a88e-ca1f-e615-714c6bc48824"),
columns: new[] { "ConcurrencyStamp", "Name" },
values: new object[] { "38598fb3653c48be8f63119787de2df8", "库存快照" });
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("f306b380-47e5-5c01-b902-67ca4113a8f4"),
column: "ConcurrencyStamp",
value: "298ad96e7d61427ba492ccdb1db7e900");
}
}
}

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

@ -4445,57 +4445,37 @@ namespace Win.Sfs.SettleAccount.Migrations
new
{
Id = new Guid("ef3d8e8a-a88e-ca1f-e615-714c6bc48824"),
ConcurrencyStamp = "3ed217e9603d4496bdef3a001ab0ebec",
ConcurrencyStamp = "25ec0d7c647f42d88882c4187af74201",
Cron = "0 0 8 26 *",
IsDisabled = false,
IsRunning = false,
Name = "库存快照",
Name = "库存快照备份",
Service = "Win.Sfs.SettleAccount.Entities.BQ.VmiAppService"
},
new
{
Id = new Guid("185c5968-e02b-267e-db2f-225fccfc9716"),
ConcurrencyStamp = "81072f462eba41b9914f4d4aea716611",
ConcurrencyStamp = "89413f316dbf4647954b6669de927488",
Cron = "0 0/1 * * * ?",
IsDisabled = false,
IsRunning = false,
Name = "同步库存",
Name = "同步结算库存",
Service = "Win.Sfs.SettleAccount.Entities.BQ.VmiAsyncBalanceService"
},
new
{
Id = new Guid("1bb02f67-ed05-6cc1-1507-502e8f6c7a31"),
ConcurrencyStamp = "ed944c8844f24f12b7dde63809c8efb4",
ConcurrencyStamp = "ebb73d81d23c4ed9a6ae59730d163f4b",
Cron = "0 0/1 * * * ?",
IsDisabled = false,
IsRunning = false,
Name = "消息监控",
Service = "Win.Sfs.SettleAccount.Entities.BQ.VmiAsyncMessageService"
},
new
{
Id = new Guid("8e1cb5a9-8bcf-17fd-97e3-4c10532a5794"),
ConcurrencyStamp = "7e294c644f7946db8b942f19392c4776",
Cron = "0 0/5 * * * ? *",
IsDisabled = false,
IsRunning = false,
Name = "库存事务同步",
Service = "Win.Sfs.SettleAccount.Entities.BQ.VmiAsyncMessageService"
},
new
{
Id = new Guid("c3fe2b66-28cc-c612-eca6-a362769ae90c"),
ConcurrencyStamp = "da5ea88f24154621ab2f8d9359cfa895",
Cron = "0 0/5 * * * ? *",
IsDisabled = false,
IsRunning = false,
Name = "库存余额同步",
Name = "事务消息监控",
Service = "Win.Sfs.SettleAccount.Entities.BQ.VmiAsyncMessageService"
},
new
{
Id = new Guid("b9b9c79f-4894-474b-4f67-b1ec121c41e5"),
ConcurrencyStamp = "6c6d5badb49649a2a18d3decb6284fce",
ConcurrencyStamp = "93962cebd40f490b9df08b215b2c7bd2",
Cron = "0 0/30 * * * ? ",
IsDisabled = false,
IsRunning = false,
@ -4505,7 +4485,7 @@ namespace Win.Sfs.SettleAccount.Migrations
new
{
Id = new Guid("49b1da12-418c-544d-fe8b-be7e5b572452"),
ConcurrencyStamp = "6ff457ddc814405c9c517c0554d8fa7d",
ConcurrencyStamp = "e581ee4de97a46b1a1c0ba75a101c064",
Cron = "0 0/30 * * * ? ",
IsDisabled = false,
IsRunning = false,
@ -4515,7 +4495,7 @@ namespace Win.Sfs.SettleAccount.Migrations
new
{
Id = new Guid("7a0dc087-a859-5863-eb6e-56f588bd779e"),
ConcurrencyStamp = "b1285c03732a43fd87da115020b75c23",
ConcurrencyStamp = "1fb801f3cbff422082d888ee8b5dab64",
Cron = "0 0/30 * * * ? ",
IsDisabled = false,
IsRunning = false,
@ -4525,7 +4505,7 @@ namespace Win.Sfs.SettleAccount.Migrations
new
{
Id = new Guid("6f68fc8f-b058-c3f4-e07d-722c61f3f7fa"),
ConcurrencyStamp = "7622bd2d62f54b079835ce7a62bf95fe",
ConcurrencyStamp = "a7be915b8a5541c58081c668219edfb7",
Cron = "0 0/30 * * * ? ",
IsDisabled = false,
IsRunning = false,
@ -4535,7 +4515,7 @@ namespace Win.Sfs.SettleAccount.Migrations
new
{
Id = new Guid("f306b380-47e5-5c01-b902-67ca4113a8f4"),
ConcurrencyStamp = "4b3d04cc418647a99b64f9f52a100a87",
ConcurrencyStamp = "7bbeaa02b39947c089eda7f4b05babb9",
Cron = "0 0/30 * * * ? ",
IsDisabled = false,
IsRunning = false,
@ -4545,7 +4525,7 @@ namespace Win.Sfs.SettleAccount.Migrations
new
{
Id = new Guid("8f7dc23d-e2e9-3691-cfe9-545bb958e3f2"),
ConcurrencyStamp = "8c945bdfee354e9c88563c30b9396674",
ConcurrencyStamp = "df723d768280494e88d49734cc6e55e5",
Cron = "0 0/30 * * * ? ",
IsDisabled = false,
IsRunning = false,
@ -4555,7 +4535,7 @@ namespace Win.Sfs.SettleAccount.Migrations
new
{
Id = new Guid("c1f71240-1b81-0107-8b23-ddc9811a3efe"),
ConcurrencyStamp = "f25821caa51d4bbf95187d3fdd95ce74",
ConcurrencyStamp = "c5b29d7fa18e4b9cb8bc1e354d10c3ac",
Cron = "0 0/30 * * * ? ",
IsDisabled = false,
IsRunning = false,
@ -4565,7 +4545,7 @@ namespace Win.Sfs.SettleAccount.Migrations
new
{
Id = new Guid("c09c23ea-815f-1b43-4476-2365a8d9a60b"),
ConcurrencyStamp = "24f4ab4ebe854c7184e77ae0150e9659",
ConcurrencyStamp = "1c542463eb8746db949bcda48eabdbd8",
Cron = "0 0/30 * * * ? ",
IsDisabled = false,
IsRunning = false,
@ -4700,21 +4680,6 @@ namespace Win.Sfs.SettleAccount.Migrations
.HasFilter("[DeliverBillType] IS NOT NULL AND [CodeType] IS NOT NULL AND [RealPartCode] IS NOT NULL AND [VinCode] IS NOT NULL AND [ErpToLoc] IS NOT NULL AND [OrderNum] IS NOT NULL AND [factory] IS NOT NULL AND [Configcode] IS NOT NULL");
b.ToTable("Set_VmiBalance");
b.HasData(
new
{
Id = new Guid("ba5e008b-7d8e-4b5f-b404-9a57092fab41"),
ConcurrencyStamp = "ebb6e4f20f8c42e1862802982fd5331f",
CreatedTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
DeliverBillType = 1,
ErpToLoc = "ErpToLoc",
OrderNum = "OrderNum",
Qty = 0m,
RealPartCode = "PartCode",
UpdatedTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
VinCode = "VinCode"
});
});
modelBuilder.Entity("Win.Sfs.SettleAccount.Entities.BQ.Vmi.VmiLog", b =>
@ -4957,6 +4922,9 @@ namespace Win.Sfs.SettleAccount.Migrations
b.HasKey("Id");
b.HasIndex("BillTime")
.IsClustered();
b.ToTable("Set_VmiReplenished");
});
@ -4983,49 +4951,6 @@ namespace Win.Sfs.SettleAccount.Migrations
b.ToTable("Set_VmiSnapshot");
});
modelBuilder.Entity("Win.Sfs.SettleAccount.Entities.BQ.Vmi.VmiSyncTask", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<DateTime>("LastUpdate")
.HasColumnType("datetime2");
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
b.Property<string>("Number")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Set_VmiSyncTask");
b.HasData(
new
{
Id = new Guid("08de7a37-5ede-f524-cb3d-3c80888fd7d8"),
ConcurrencyStamp = "a3393ee4620443ac9a692157914f162e",
LastUpdate = new DateTime(2023, 8, 21, 0, 0, 0, 0, DateTimeKind.Local),
Name = "库存事务备份",
Number = "Set_VmiLog"
},
new
{
Id = new Guid("b8ba69e3-f5a3-c95e-8f82-c9c2fec960b4"),
ConcurrencyStamp = "b4ffe8f9e39f466a948d4f642593d0e9",
LastUpdate = new DateTime(2023, 8, 21, 0, 0, 0, 0, DateTimeKind.Local),
Name = "库存余额备份",
Number = "Set_VmiBalance"
});
});
modelBuilder.Entity("Win.Sfs.SettleAccount.Entities.Boms.BomVersion", b =>
{
b.Property<Guid>("Id")

93
code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisBBACSaSeEdiCompareExportService.cs

@ -105,12 +105,13 @@ namespace SettleAccount.Job.Services.Report
//结算
var saGroup = from sa in _settleAccountDbContext.Set<BBAC_SA_DETAIL>()
where sa.BusinessType == businessType && sa.Version == version
group sa by new { sa.PN, sa.LU } into groupItem
group sa by new { sa.PN, sa.CustomerPartCodeNoSpace } into groupItem
select new
{
groupItem.Key.PN,
groupItem.Key.LU,
groupItem.Key.CustomerPartCodeNoSpace,
Qty = groupItem.Sum(t => t.Qty),
LU = groupItem.Max(t => t.LU),
Price = groupItem.Max(t => t.Price),
SettleDate = groupItem.Max(t => t.SettleDate),
PartCode = groupItem.Max(t => t.PartCode),
@ -118,59 +119,95 @@ namespace SettleAccount.Job.Services.Report
//发运
var seGroup = from se in _settleAccountDbContext.Set<BBAC_SE_DETAIL>()
where se.BusinessType == businessType && se.BillTime >= seStartDateTime && se.BillTime <= seEndDateTime
group se by new { se.PN, se.LU } into groupItem
group se by new { se.PN, se.CustomerPartCodeNoSpace } into groupItem
select new
{
groupItem.Key.PN,
groupItem.Key.LU,
groupItem.Key.CustomerPartCodeNoSpace,
Qty = groupItem.Sum(t => t.Qty),
LU = groupItem.Max(t => t.LU),
WmsBillNum = groupItem.Max(t => t.WmsBillNum),
ShippingDate = groupItem.Max(t => t.ShippingDate),
FactoryPartCode = groupItem.Max(t => t.FactoryPartCode),
ToLoc = groupItem.Max(t => t.ToLoc),
ErpToLoc = groupItem.Max(t => t.ErpToLoc)
};
//Edi
var ediGroup = from edi in _settleAccountDbContext.Set<BBAC_SE_EDI>()
where edi.IsDeleted == false && edi.IsHaveSeData == true
group edi by new { edi.PN, edi.LU } into groupItem
select new
{
groupItem.Key.PN,
groupItem.Key.LU,
Qty = groupItem.Sum(t => t.Qty)
};
var seEdiGroup = from se in seGroup
join edi in ediGroup
on new { se.PN, se.CustomerPartCodeNoSpace } equals new { edi.PN, CustomerPartCodeNoSpace = edi.LU }
into ediTemp
from edi in ediTemp.DefaultIfEmpty()
select new
{
se.PN,
se.CustomerPartCodeNoSpace,
se.Qty,
se.LU,
se.WmsBillNum,
se.ShippingDate,
se.FactoryPartCode,
se.ToLoc,
se.ErpToLoc,
EdiQty = edi.Qty,
EdiCustomerPartCode = edi.LU
};
var saSeCompareLeft = from sa in saGroup
join se in seGroup
on new { sa.PN, sa.LU } equals new { se.PN, se.LU }
join seEdi in seEdiGroup
on new { sa.PN, sa.CustomerPartCodeNoSpace } equals new { seEdi.PN, seEdi.CustomerPartCodeNoSpace }
into temp
from se in temp.DefaultIfEmpty()
from seEdi in temp.DefaultIfEmpty()
select new SaSeEdiCompareDiff()
{
WmsBillNum = se.WmsBillNum,
ShippingDate = se.ShippingDate,
WmsBillNum = seEdi.WmsBillNum,
ShippingDate = seEdi.ShippingDate,
CustomerOfflineTime = sa.SettleDate,
PN = sa.PN,
SAQty = sa.Qty,
SEQty = se.Qty,
SEQty = seEdi.Qty,
EdiQty = seEdi.EdiQty,
FixPrice = sa.Price,
ToLocCode = se.ToLoc,
ToErpLocCode = se.ErpToLoc,
SeCustomerPartCode = se.LU,
SeFactoryPartCode = se.FactoryPartCode,
SaCustomerPartCode = sa.LU,
SaFactoryPartCode = sa.PartCode
ToLocCode = seEdi.ToLoc,
ToErpLocCode = seEdi.ErpToLoc,
SeCustomerPartCode = seEdi.CustomerPartCodeNoSpace,
SeFactoryPartCode = seEdi.FactoryPartCode,
SaCustomerPartCode = sa.CustomerPartCodeNoSpace,
SaFactoryPartCode = sa.PartCode,
EdiCustomerPartCode = seEdi.EdiCustomerPartCode,
CustomerPartCode = sa.LU
};
var saSeCompareRight = from se in seGroup
var saSeCompareRight = from seEdi in seEdiGroup
join sa in saGroup
on new { se.PN, se.LU } equals new { sa.PN, sa.LU }
on new { seEdi.PN, seEdi.CustomerPartCodeNoSpace } equals new { sa.PN, sa.CustomerPartCodeNoSpace }
into temp
from sa in temp.DefaultIfEmpty()
select new SaSeEdiCompareDiff()
{
WmsBillNum = se.WmsBillNum,
ShippingDate = se.ShippingDate,
WmsBillNum = seEdi.WmsBillNum,
ShippingDate = seEdi.ShippingDate,
CustomerOfflineTime = sa.SettleDate,
PN = se.PN,
PN = seEdi.PN,
SAQty = sa.Qty,
SEQty = se.Qty,
SEQty = seEdi.Qty,
EdiQty = seEdi.EdiQty,
FixPrice = sa.Price,
ToLocCode = se.ToLoc,
ToErpLocCode = se.ErpToLoc,
SeCustomerPartCode = se.LU,
SeFactoryPartCode = se.FactoryPartCode,
SaCustomerPartCode = sa.LU,
SaFactoryPartCode = sa.PartCode
ToLocCode = seEdi.ToLoc,
ToErpLocCode = seEdi.ErpToLoc,
SeCustomerPartCode = seEdi.CustomerPartCodeNoSpace,
SeFactoryPartCode = seEdi.FactoryPartCode,
SaCustomerPartCode = sa.CustomerPartCodeNoSpace,
SaFactoryPartCode = sa.PartCode,
EdiCustomerPartCode = seEdi.EdiCustomerPartCode,
CustomerPartCode = sa.LU ?? seEdi.LU
};
var saSeCompareFullJoin = saSeCompareLeft.Union(saSeCompareRight).ToList();
return saSeCompareFullJoin;

16
code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisBBACSeEdiCompareExportService.cs

@ -75,6 +75,8 @@ namespace SettleAccount.Job.Services.Report
LineStationcode = default,
SequenceNumber = t.Max(t => t.SeqNumber),
ParType = "01",
PN = t.Key.PN,
MaterialNumber = t.Key.LU,
EdiQty = t.Sum(t => t.Qty),
AssemblyDate = default,
MatchNumber = default,
@ -83,7 +85,7 @@ namespace SettleAccount.Job.Services.Report
}).ToList();
//无EDI有发运
var notHaveEdiHaveSeList = _settleAccountDbContext.Set<BBAC_SE_DETAIL>().Where(t => t.IsHaveEdiData == false)
.GroupBy(t => new { t.LU, t.PN })
.GroupBy(t => new { t.CustomerPartCodeNoSpace, t.PN })
.Select(t => new JisBBACEidSeCompareExport()
{
Category = "JIS",
@ -112,13 +114,14 @@ namespace SettleAccount.Job.Services.Report
SeqNumber = groupItem.Max(t => t.SeqNumber)
};
var seGroup = from se in _settleAccountDbContext.Set<BBAC_SE_DETAIL>()
where se.IsHaveEdiData == true && se.AssembleData >= seStartDateTime && se.AssembleData <= seEndDateTime
group se by new { se.PN, se.LU } into groupItem
where se.IsHaveEdiData == true && se.BillTime >= seStartDateTime && se.BillTime <= seEndDateTime
group se by new { se.PN, se.CustomerPartCodeNoSpace } into groupItem
select new
{
groupItem.Key.PN,
groupItem.Key.LU,
groupItem.Key.CustomerPartCodeNoSpace,
Qty = groupItem.Sum(t => t.Qty),
LU = groupItem.Max(t => t.LU),
BillNum = groupItem.Max(t => t.BillNum),
MESConfigCode = groupItem.Max(t => t.MESConfigCode),
BillTime = groupItem.Max(t => t.BillTime),
@ -130,8 +133,7 @@ namespace SettleAccount.Job.Services.Report
};
var haveEdiHaveSeList = (from edi in ediGroup
join se in seGroup
on new { edi.PN, edi.LU } equals new { se.PN, se.LU }
//where edi.IsDeleted == false && edi.IsHaveSeData == true && se.IsHaveEdiData == true
on new { edi.PN, edi.LU } equals new { se.PN, LU = se.CustomerPartCodeNoSpace }
select new JisBBACEidSeCompareExport()
{
Category = "JIS",
@ -157,7 +159,9 @@ namespace SettleAccount.Job.Services.Report
}).ToList();
haveEdiNotHaveSeList.AddRange(haveEdiHaveSeList);
haveEdiNotHaveSeList.Reverse();
notHaveEdiHaveSeList.AddRange(haveEdiHaveSeList);
notHaveEdiHaveSeList.Reverse();
ExcelExporter excelExporter = new ExcelExporter();
excelExporter

97
code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisHBPOSaSeEdiCompareExportService.cs

@ -84,8 +84,8 @@ namespace SettleAccount.Job.Services.Report
}
ediSeSaCompareDiffs = ediSeSaCompareDiffs.OrderBy(t => t.Category).ToList();
var items = _objectMapper.Map<List<SaSeEdiCompareDiff>, List<SaSeEdiCompareDetailExportJisBBAC>>(ediSeSaCompareDiffs);
var excelExporter = BindExcelExporter<SaSeEdiCompareDetailExportJisBBAC>(items, businessTypeDisplayName);
var items = _objectMapper.Map<List<SaSeEdiCompareDiff>, List<SaSeEdiCompareDetailExportJisHBPO>>(ediSeSaCompareDiffs);
var excelExporter = BindExcelExporter<SaSeEdiCompareDetailExportJisHBPO>(items, businessTypeDisplayName);
var result = excelExporter.ExportAppendDataAsByteArray();
result.ShouldNotBeNull();
@ -104,12 +104,13 @@ namespace SettleAccount.Job.Services.Report
//结算
var saGroup = from sa in _settleAccountDbContext.Set<HBPO_SA_DETAIL>()
where sa.BusinessType == businessType && sa.Version == version
group sa by new { sa.PN, sa.LU } into groupItem
group sa by new { sa.PN, sa.CustomerPartCodeNoSpace } into groupItem
select new
{
groupItem.Key.PN,
groupItem.Key.LU,
groupItem.Key.CustomerPartCodeNoSpace,
Qty = groupItem.Sum(t => t.Qty),
LU = groupItem.Max(t => t.LU),
Price = groupItem.Max(t => t.Price),
SettleDate = groupItem.Max(t => t.SettleDate),
PartCode = groupItem.Max(t => t.PartCode),
@ -117,59 +118,95 @@ namespace SettleAccount.Job.Services.Report
//发运
var seGroup = from se in _settleAccountDbContext.Set<HBPO_SE_DETAIL>()
where se.BusinessType == businessType && se.BillTime >= seStartDateTime && se.BillTime <= seEndDateTime
group se by new { se.PN, se.LU } into groupItem
group se by new { se.PN, se.CustomerPartCodeNoSpace } into groupItem
select new
{
groupItem.Key.PN,
groupItem.Key.LU,
groupItem.Key.CustomerPartCodeNoSpace,
Qty = groupItem.Sum(t => t.Qty),
LU = groupItem.Max(t => t.LU),
WmsBillNum = groupItem.Max(t => t.WmsBillNum),
ShippingDate = groupItem.Max(t => t.ShippingDate),
FactoryPartCode = groupItem.Max(t => t.FactoryPartCode),
ToLoc = groupItem.Max(t => t.ToLoc),
ErpToLoc = groupItem.Max(t => t.ErpToLoc)
};
//Edi
var ediGroup = from edi in _settleAccountDbContext.Set<HBPO_SE_EDI>()
where edi.IsDeleted == false && edi.IsHaveSeData == true
group edi by new { edi.PN, edi.LU } into groupItem
select new
{
groupItem.Key.PN,
groupItem.Key.LU,
Qty = groupItem.Sum(t => t.Qty)
};
var seEdiGroup = from se in seGroup
join edi in ediGroup
on new { se.PN, se.CustomerPartCodeNoSpace } equals new { edi.PN, CustomerPartCodeNoSpace = edi.LU }
into ediTemp
from edi in ediTemp.DefaultIfEmpty()
select new
{
se.PN,
se.CustomerPartCodeNoSpace,
se.Qty,
se.LU,
se.WmsBillNum,
se.ShippingDate,
se.FactoryPartCode,
se.ToLoc,
se.ErpToLoc,
EdiQty = edi.Qty,
EdiCustomerPartCode = edi.LU
};
var saSeCompareLeft = from sa in saGroup
join se in seGroup
on new { sa.PN, sa.LU } equals new { se.PN, se.LU }
join seEdi in seEdiGroup
on new { sa.PN, sa.CustomerPartCodeNoSpace } equals new { seEdi.PN, seEdi.CustomerPartCodeNoSpace }
into temp
from se in temp.DefaultIfEmpty()
from seEdi in temp.DefaultIfEmpty()
select new SaSeEdiCompareDiff()
{
WmsBillNum = se.WmsBillNum,
ShippingDate = se.ShippingDate,
WmsBillNum = seEdi.WmsBillNum,
ShippingDate = seEdi.ShippingDate,
CustomerOfflineTime = sa.SettleDate,
PN = sa.PN,
SAQty = sa.Qty,
SEQty = se.Qty,
SEQty = seEdi.Qty,
EdiQty = seEdi.EdiQty,
FixPrice = sa.Price,
ToLocCode = se.ToLoc,
ToErpLocCode = se.ErpToLoc,
SeCustomerPartCode = se.LU,
SeFactoryPartCode = se.FactoryPartCode,
SaCustomerPartCode = sa.LU,
SaFactoryPartCode = sa.PartCode
ToLocCode = seEdi.ToLoc,
ToErpLocCode = seEdi.ErpToLoc,
SeCustomerPartCode = seEdi.CustomerPartCodeNoSpace,
SeFactoryPartCode = seEdi.FactoryPartCode,
SaCustomerPartCode = sa.CustomerPartCodeNoSpace,
SaFactoryPartCode = sa.PartCode,
EdiCustomerPartCode = seEdi.EdiCustomerPartCode,
CustomerPartCode = sa.LU
};
var saSeCompareRight = from se in seGroup
var saSeCompareRight = from seEdi in seEdiGroup
join sa in saGroup
on new { se.PN, se.LU } equals new { sa.PN, sa.LU }
on new { seEdi.PN, seEdi.CustomerPartCodeNoSpace } equals new { sa.PN, sa.CustomerPartCodeNoSpace }
into temp
from sa in temp.DefaultIfEmpty()
select new SaSeEdiCompareDiff()
{
WmsBillNum = se.WmsBillNum,
ShippingDate = se.ShippingDate,
WmsBillNum = seEdi.WmsBillNum,
ShippingDate = seEdi.ShippingDate,
CustomerOfflineTime = sa.SettleDate,
PN = se.PN,
PN = seEdi.PN,
SAQty = sa.Qty,
SEQty = se.Qty,
SEQty = seEdi.Qty,
EdiQty = seEdi.EdiQty,
FixPrice = sa.Price,
ToLocCode = se.ToLoc,
ToErpLocCode = se.ErpToLoc,
SeCustomerPartCode = se.LU,
SeFactoryPartCode = se.FactoryPartCode,
SaCustomerPartCode = sa.LU,
SaFactoryPartCode = sa.PartCode
ToLocCode = seEdi.ToLoc,
ToErpLocCode = seEdi.ErpToLoc,
SeCustomerPartCode = seEdi.CustomerPartCodeNoSpace,
SeFactoryPartCode = seEdi.FactoryPartCode,
SaCustomerPartCode = sa.CustomerPartCodeNoSpace,
SaFactoryPartCode = sa.PartCode,
EdiCustomerPartCode = seEdi.EdiCustomerPartCode,
CustomerPartCode = sa.LU ?? seEdi.LU
};
var saSeCompareFullJoin = saSeCompareLeft.Union(saSeCompareRight).ToList();
return saSeCompareFullJoin;

14
code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisHBPOSeEdiCompareExportService.cs

@ -72,6 +72,8 @@ namespace SettleAccount.Job.Services.Report
LineStationcode = default,
SequenceNumber = t.Max(t => t.SeqNumber),
ParType = "01",
PN = t.Key.PN,
MaterialNumber = t.Key.LU,
EdiQty = t.Sum(t => t.Qty),
AssemblyDate = default,
MatchNumber = default,
@ -80,7 +82,7 @@ namespace SettleAccount.Job.Services.Report
}).ToList();
//无EDI有发运
var notHaveEdiHaveSeList = _settleAccountDbContext.Set<HBPO_SE_DETAIL>().Where(t => t.IsHaveEdiData == false)
.GroupBy(t => new { t.LU, t.PN })
.GroupBy(t => new { t.CustomerPartCodeNoSpace, t.PN })
.Select(t => new JisHBPOEidSeCompareExport()
{
Category = "JIS",
@ -111,12 +113,12 @@ namespace SettleAccount.Job.Services.Report
SeqNumber = groupItem.Max(t => t.SeqNumber)
};
var seGroup = from se in _settleAccountDbContext.Set<HBPO_SE_DETAIL>()
where se.IsHaveEdiData == true && se.AssembleData >= seStartDateTime && se.AssembleData <= seEndDateTime
group se by new { se.PN, se.LU } into groupItem
where se.IsHaveEdiData == true && se.BillTime >= seStartDateTime && se.BillTime <= seEndDateTime
group se by new { se.PN, se.CustomerPartCodeNoSpace } into groupItem
select new
{
groupItem.Key.PN,
groupItem.Key.LU,
groupItem.Key.CustomerPartCodeNoSpace,
Qty = groupItem.Sum(t => t.Qty),
BillNum = groupItem.Max(t => t.BillNum),
MESConfigCode = groupItem.Max(t => t.MESConfigCode),
@ -131,7 +133,7 @@ namespace SettleAccount.Job.Services.Report
};
var haveEdiHaveSeList = (from edi in ediGroup
join se in seGroup
on new { edi.PN, edi.LU } equals new { se.PN, se.LU }
on new { edi.PN, edi.LU } equals new { se.PN, LU = se.CustomerPartCodeNoSpace }
select new JisHBPOEidSeCompareExport()
{
Category = "JIS",
@ -159,7 +161,9 @@ namespace SettleAccount.Job.Services.Report
}).ToList();
haveEdiNotHaveSeList.AddRange(haveEdiHaveSeList);
haveEdiNotHaveSeList.Reverse();
notHaveEdiHaveSeList.AddRange(haveEdiHaveSeList);
notHaveEdiHaveSeList.Reverse();
ExcelExporter excelExporter = new ExcelExporter();
excelExporter

48
code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/PubSaSeCompareExportService.cs

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using EFCore.BulkExtensions;
using Magicodes.ExporterAndImporter.Excel;
using Microsoft.AspNetCore.SignalR;
using Microsoft.OpenApi.Extensions;
@ -85,7 +86,7 @@ namespace SettleAccount.Job.Services.Report
/// </summary>
public string ExportFile(Guid id, List<string> exportName, List<CustomCondition> property)
{
var version = property.Where(p => p.Name == "Version").FirstOrDefault().Value;
var version = int.Parse(property.Where(p => p.Name == "Version").FirstOrDefault().Value);
var strBusinessType = property.Where(t => t.Name == "BusinessType").FirstOrDefault().Value;
var lu = property.Where(p => p.Name == "LU").FirstOrDefault().Value;
var pn = property.Where(p => p.Name == "PN").FirstOrDefault().Value;
@ -101,7 +102,7 @@ namespace SettleAccount.Job.Services.Report
}
var filename = exportName.FirstOrDefault();
//var pubSaSeCompareDiffs = _pubSaSeCompareDapperRepository.GetDetailDiffReportList(strBusinessType, version, seStartDateTime, seEndDateTime);
var pubSaSeCompareDiffs = GetSaSeCompareData(businessType, int.Parse(version), DateTime.Parse(seStartDateTime), DateTime.Parse(seEndDateTime));
var pubSaSeCompareDiffs = GetSaSeCompareData(businessType, version, DateTime.Parse(seStartDateTime), DateTime.Parse(seEndDateTime));
HandlePubSaSeCompareDiffList(pubSaSeCompareDiffs);
@ -117,48 +118,11 @@ namespace SettleAccount.Job.Services.Report
//二次对比比对上的数据入库
var pubSeCDetailEntitys = _objectMapper.Map<List<PubSaSeCompareDiff>, List<PUB_SEC_DETAIL>>(secondMatchHaveSaHaveSes);
_settleAccountDbContext.Set<PUB_SEC_DETAIL>().AddRange(pubSeCDetailEntitys);
//_pubSeCDetailRepository.InsertManyAsync(pubSeCDetailEntitys);
}
#endregion
//var haveSaNotHaveSeFPartCodePNs = haveSaNotHaveSes.Select(t => new { t.ReplaceFactoryPartCode, t.PN });
//var notHaveSaHaveSeFPartCodePNs = notHaveSaHaveSes.Select(t => new { t.ReplaceFactoryPartCode, t.PN });
////二次匹配 匹配上的厂内零件号、PN
//var secondMatchFPartCodePNs = haveSaNotHaveSeFPartCodePNs.Intersect(notHaveSaHaveSeFPartCodePNs);
//if (secondMatchFPartCodePNs.Any() == true)
//{
// pubSaSeCompareDiffs.RemoveAll<PubSaSeCompareDiff>(t => secondMatchFPartCodePNs.Contains(new { t.ReplaceFactoryPartCode, t.PN }));
// foreach (var secondMatchFPartCodePN in secondMatchFPartCodePNs)
// {
// var haveSaNotHaveSe = haveSaNotHaveSes.FirstOrDefault(t => t.ReplaceFactoryPartCode == secondMatchFPartCodePN.ReplaceFactoryPartCode && t.PN == secondMatchFPartCodePN.PN);
// var notHaveSaHaveSe = notHaveSaHaveSes.FirstOrDefault(t => t.ReplaceFactoryPartCode == secondMatchFPartCodePN.ReplaceFactoryPartCode && t.PN == secondMatchFPartCodePN.PN);
// if (haveSaNotHaveSe != null && notHaveSaHaveSe != null)
// {
// }
// secondMatchHaveSaHaveSes.Add(new PubSaSeCompareDiff()
// {
// WmsBillNum = notHaveSaHaveSe.WmsBillNum,
// ShippingDate = notHaveSaHaveSe.ShippingDate,
// SeqNumber = notHaveSaHaveSe.SeqNumber,
// PJISSeqNumber = notHaveSaHaveSe.PJISSeqNumber,
// MaterialNumber = haveSaNotHaveSe.MaterialNumber,
// MaterialDes = haveSaNotHaveSe.MaterialDes,
// CustomerOfflineTime = haveSaNotHaveSe.CustomerOfflineTime,
// SAQty = haveSaNotHaveSe.SAQty,
// SEQty = notHaveSaHaveSe.SEQty,
// MateType = haveSaNotHaveSe.MateType,
// FixPrice = haveSaNotHaveSe.FixPrice,
// PrimitiveLU = haveSaNotHaveSe.PrimitiveLU,
// ReplaceLU = haveSaNotHaveSe.ReplaceLU,
// SeLU = notHaveSaHaveSe.SeLU,
// SaLU = haveSaNotHaveSe.SaLU,
// PN = haveSaNotHaveSe.PN,
// Category = EnumPubSaSeCompareCategory.HaveSaHaveSe,
// IsRemove = false
// });
// }
//}
#region 结算数据处理
HandlSaDetails(pubSaSeCompareDiffs, businessType, version);
#endregion
if (string.IsNullOrEmpty(lu) == false)

50
code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeCompareExportBaseService.cs

@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using EFCore.BulkExtensions;
using Magicodes.ExporterAndImporter.Excel;
using Microsoft.AspNetCore.SignalR;
using SettleAccount.Domain.BQ;
@ -76,18 +77,20 @@ namespace SettleAccount.Job.Services.Report
{
//二次匹配上的记录
var secondMatchHaveSaHaveSes = new List<PubSaSeCompareDiff>();
//有结算无发运 和 无结算有发运
var haveSaNotHaveSeUnionNotHaveSaHaveSes = pubSaSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaNotHaveSe || t.Category == EnumPubSaSeCompareCategory.NotHaveSaHaveSe);
//有结算无发运
var haveSaNotHaveSes = pubSaSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaNotHaveSe);
//无结算有发运
var notHaveSaHaveSes = pubSaSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.NotHaveSaHaveSe);
//二次对比(替换无结算有发运数据的厂内零件号)
var repFactoryPartCodes = notHaveSaHaveSes.Select(t => t.FactoryPartCode).Distinct().ToList();
var tbRePartsRelationships = _settleAccountDbContext.Set<TB_RePartsRelationship>().Where(t => repFactoryPartCodes.Contains(t.LU) && t.BusinessType == businessType).ToList();
//二次对比(替换发运数据的厂内零件号)
var repFactoryPartCodes = haveSaNotHaveSeUnionNotHaveSaHaveSes.Select(t => t.FactoryPartCode).Distinct().ToList();
var tbRePartsRelationships = _settleAccountDbContext.Set<TB_RePartsRelationship>().Where(t => repFactoryPartCodes.Contains(t.LU)).ToList();
tbRePartsRelationships.ForEach(tbRePartsRelationship =>
{
notHaveSaHaveSes.FindAll(t => t.FactoryPartCode == tbRePartsRelationship.LU).ForEach(t =>
haveSaNotHaveSeUnionNotHaveSaHaveSes.FindAll(t => t.FactoryPartCode == tbRePartsRelationship.LU).ForEach(t =>
{
t.ReplaceFactoryPartCode = tbRePartsRelationship.RepLU;
});
@ -123,6 +126,45 @@ namespace SettleAccount.Job.Services.Report
return secondMatchHaveSaHaveSes;
}
/// <summary>
/// 结算数据处理
/// 写入库位、替换零件号
/// </summary>
public virtual void HandlSaDetails(List<PubSaSeCompareDiff> pubSaSeCompareDiffs, EnumBusinessType businessType, int version)
{
//写入库位、替换零件号
var haveSaHaveSes = pubSaSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaHaveSe);
if (haveSaHaveSes.Any())
{
var canSaDetails = (from sa in _settleAccountDbContext.Set<PUB_CAN_SA_DETAIL>()
where sa.BusinessType == businessType && sa.Version == version
select sa).ToList();
if (canSaDetails.Any())
{
var canSaDetailsUpdate = canSaDetails.Join(haveSaHaveSes, o => new { o.PN, o.LU }, i => new { i.PN, LU = i.CustomerPartCode }, (o, i) =>
{
o.ErpLoc = i.ToErpLocCode;
o.RealPartCode = i.ReplaceFactoryPartCode;
return o;
}).ToList();
_settleAccountDbContext.BulkUpdate(canSaDetailsUpdate);
}
var notSaDetails = (from sa in _settleAccountDbContext.Set<PUB_NOT_SA_DETAIL>()
where sa.BusinessType == businessType && sa.Version == version
select sa).ToList();
if (notSaDetails.Any())
{
var notSaDetailsUpdate = notSaDetails.Join(haveSaHaveSes, o => new { o.PN, o.LU }, i => new { i.PN, LU = i.CustomerPartCode }, (o, i) =>
{
o.ErpLoc = i.ToErpLocCode;
o.RealPartCode = i.ReplaceFactoryPartCode;
return o;
}).ToList();
_settleAccountDbContext.BulkUpdate(notSaDetailsUpdate);
}
}
}
/// <summary>
/// 创建导出文件结构
/// </summary>

2
code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeEdiCompareExportBaseService.cs

@ -44,7 +44,6 @@ namespace SettleAccount.Job.Services.Report
case EnumSaSeEdiCompareCategory.HaveSaNotHaveSeHaveEdi:
case EnumSaSeEdiCompareCategory.HaveSaNotHaveSeNotHaveEdi:
{
p.CustomerPartCode = p.SaCustomerPartCode;
p.FactoryPartCode = p.SaFactoryPartCode;
p.ReplaceFactoryPartCode = p.SaFactoryPartCode;
}
@ -52,7 +51,6 @@ namespace SettleAccount.Job.Services.Report
case EnumSaSeEdiCompareCategory.NotHaveSaHaveSeHaveEdi:
case EnumSaSeEdiCompareCategory.NotHaveSaHaveSeNotHaveEdi:
{
p.CustomerPartCode = p.SeCustomerPartCode;
p.FactoryPartCode = p.SeFactoryPartCode;
p.ReplaceFactoryPartCode = p.SeFactoryPartCode;
}

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