Browse Source

添加库存汇总

master
wanggang 1 year ago
parent
commit
f5bc4c6aa2
  1. 4
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/list/index.js
  2. 3
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/base-data/code-setting.js
  3. 2
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/base-data/ke-hu.js
  4. 1
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/base-data/role.js
  5. 4
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/base-data/user.js
  6. 4
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/base-data/version.js
  7. 1
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/input/edi.js
  8. 3
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/settle/cost.js
  9. 132
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/vmi/sum.js
  10. 4
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/router/business.js
  11. 44
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/vmi/sum.js
  12. 62
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs

4
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/list/index.js

@ -91,7 +91,7 @@ export default {
</el-table-column>
</template>
<template v-else>
<template v-if="showColumn(item,key)">
<template v-if="!item.hideForList&&showColumn(item,key)">
<el-table-column :prop="key" sortable="custom" :sort-orders="['descending', 'ascending', null]" :filters="getFilters(item,key)">
<template #header="scope">{{item.title}}</template>
<template #default="scope">
@ -411,7 +411,7 @@ export default {
const getColumns = (schema) => {
Object.keys(schema.properties).forEach((propertyName) => {
const property = schema.properties[propertyName];
if (property.showForList || (property.type !== "object" && property.type !== "array" && !property.hidden)) {
if (!property.hideForList || (property.type !== "object" && property.type !== "array" && !property.hidden)) {
columns.value.push({ name: propertyName, title: property.title, checked: true });
}
});

3
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/base-data/code-setting.js

@ -6,7 +6,6 @@ const schema = {
title: "项目",
type: "string",
readOnly: true,
showForList: true,
rules: [
{
required: true,
@ -17,7 +16,6 @@ const schema = {
title: "值",
type: "string",
readOnly: true,
showForList: true,
rules: [
{
required: true,
@ -28,7 +26,6 @@ const schema = {
title: "描述",
type: "string",
input: "textarea",
showForList: true,
rules: [
{
required: true,

2
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/base-data/ke-hu.js

@ -6,7 +6,6 @@ const schema = {
title: "业务类别",
type: "string",
readOnly: true,
showForList: true,
rules: [
{
required: true,
@ -17,7 +16,6 @@ const schema = {
title: "库位",
type: "string",
readOnly: true,
showForList: true,
rules: [
{
required: true,

1
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/base-data/role.js

@ -6,7 +6,6 @@ const schema = {
name: {
title: "角色名",
type: "string",
showForList: true,
readOnly: true,
rules: [
{

4
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/base-data/user.js

@ -7,7 +7,6 @@ const schema = {
title: "用户名",
type: "string",
readOnly: true,
showForList: true,
rules: [
{
required: true,
@ -37,7 +36,6 @@ const schema = {
name: {
title: "姓名",
type: "string",
showForList: true,
rules: [
{
required: true,
@ -48,7 +46,6 @@ const schema = {
phoneNumber: {
title: "电话",
type: "string",
showForList: true,
rules: [
{
required: true,
@ -59,7 +56,6 @@ const schema = {
email: {
title: "邮箱",
type: "string",
showForList: true,
rules: [{ required: true }, { pattern: "^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z]{2,4})+$", message: "%s必须是正确的格式" }],
},
roleNames: {

4
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/base-data/version.js

@ -6,7 +6,6 @@ const schema = {
title: "年度",
type: "string",
hidden: true,
showForList: true,
rules: [
{
required: true,
@ -17,7 +16,6 @@ const schema = {
title: "期间",
type: "string",
hidden: true,
showForList: true,
rules: [
{
required: true,
@ -29,7 +27,6 @@ const schema = {
type: "string",
input: "month",
format: "YYYYMM",
showForList: true,
watch: "(model,value)=>{model.year=value.substr(0,4);model.period=value.substr(4,2);}",
rules: [
{
@ -41,7 +38,6 @@ const schema = {
state: {
title: "状态",
type: "boolean",
showForList: true,
default: true,
rules: [
{

1
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/input/edi.js

@ -41,7 +41,6 @@ const schema = {
id: {
type: "string",
hidden: true,
showForList: false,
},
},
};

3
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/settle/cost.js

@ -6,7 +6,6 @@ const schema = {
title: "项目",
type: "string",
readOnly: true,
showForList: true,
rules: [
{
required: true,
@ -17,7 +16,6 @@ const schema = {
title: "值",
type: "string",
readOnly: true,
showForList: true,
rules: [
{
required: true,
@ -28,7 +26,6 @@ const schema = {
title: "描述",
type: "string",
input: "textarea",
showForList: true,
rules: [
{
required: true,

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

@ -0,0 +1,132 @@
import useVmi from "./vmi.js";
const schema = Object.assign({}, useVmi());
Object.keys(schema.properties).forEach((o) => {
if (o !== "erpToLoc" && o !== "realPartCode" && o !== "qty") {
schema.properties[o].hideForList = true;
}
});
const baseUrl = "settleaccount/vmi";
const queryUrl = `${baseUrl}/balance-sum`;
const exportUrl = `${baseUrl}/balance-sum-export`;
const queryMethod = "POST";
const exportMethod = "POST";
export default function () {
return {
query: {
url: queryUrl,
method: queryMethod,
hasFilter: true,
schema: {
title: "寄售库存",
type: "object",
properties: {
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: "billTime",
action: "biggerThanOrEqual",
value: null,
readOnly: true,
title: "发运开始",
},
{
logic: "and",
column: "billTime",
action: "smallThan",
value: null,
readOnly: true,
title: "发运结束",
},
{
logic: "and",
column: "erpToLoc",
action: "like",
value: null,
readOnly: true,
},
{
logic: "and",
column: "realPartCode",
action: "like",
value: null,
readOnly: true,
},
{
logic: "and",
column: "custPartCode",
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,
},
},
},
},
table: {
schema: schema,
},
edit: {
exportUrl,
exportMethod,
schema: schema,
},
};
}

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

@ -404,6 +404,10 @@ export default [
...createPage("balance", "title=库存余额查询"),
children: [createButton("query", "title=查询&isTop=true"), createButton("export", "title=导出&isTop=true&pattern=paged")],
},
{
...createPage("sum", "title=库存余额汇总"),
children: [createButton("query", "title=查询&isTop=true"), createButton("export", "title=导出&isTop=true&pattern=paged")],
},
{
...createPage("backup", "title=时点库存余额查询"),
children: [

44
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/vmi/sum.js

@ -0,0 +1,44 @@
import AppList from "../../components/list/index.js";
import html from "html";
import { ref, onMounted, onUnmounted } from "vue";
import { useRoute } from "vue-router";
import { ElNotification } from "element-plus";
import request from "../../request/index.js";
export default {
components: { AppList },
template: html`<app-list v-if="config" :config="config" @command="onCommand" />`,
setup() {
const config = ref(null);
const route = useRoute();
const onCommand = async (item, rows) => {
console.log(item.path, item, rows);
};
const showMessage = async (data) => {
await ElNotification.closeAll();
ElNotification({
position: "bottom-right",
title: "提示",
message: `待同步库存数量: ${data}`,
duration: 0,
});
};
const event = "VmiBalance";
onMounted(async () => {
const model = "vmi/sum";
const useConfig = (await import(`../../models/${model}.js`)).default;
config.value = useConfig(route.meta?.businessType, route.meta);
const result = await request("settleaccount/vmi-async-message/get-message-count", null, { method: "POST" });
if (!result.errors) {
showMessage(result.data);
}
PubSub.subscribe(event, async (_, data) => {
if (route.path === "/vmi/sum") {
showMessage(data);
}
});
});
onUnmounted(() => PubSub.unsubscribe(event));
return { config, onCommand };
},
};

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

@ -37,6 +37,7 @@ using Volo.Abp.Users;
using Volo.Abp.Validation;
using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.BQ.Syncs;
using Win.Sfs.SettleAccount.Entities.BQ.Vmi;
using Win.Sfs.Shared;
using Win.Sfs.Shared.Filter;
@ -169,7 +170,55 @@ public class VmiAppService : Controller, IApplicationService, IJobService, ITran
{
var entities = await _balanceRepository.GetListByFilterAsync(input.Filters).ConfigureAwait(false);
var fileName = $"库存余额_{DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss")}.xlsx";
var content = this.GetContent(entities, "库存备份");
var content = this.GetContent(entities, "库存余额");
await _fileContainer.SaveAsync(fileName, content, true).ConfigureAwait(false);
return fileName;
}
/// <summary>
/// 1.2库存余额汇总查询
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
public async Task<PagedResultDto<VmiBalanceSumDto>> BalanceSum(RequestDto input)
{
var connectionString = this._serviceProvider.GetRequiredService<IConfiguration>().GetConnectionString("SettleAccountService");
var options = new DbContextOptionsBuilder<SettleAccountDbContext>().UseSqlServer(connectionString).Options;
using var db = new SettleAccountDbContext(options);
var query = db.Set<VmiBalance>().FromSqlRaw("select * from Set_VmiBalance");
var filters = input.Filters.ToLambda<VmiBalance>();
if (input.Filters.Count > 0)
{
query = query.Where(input.Filters.ToLambda<VmiBalance>());
}
query = string.IsNullOrEmpty(input.Sorting) ? query : DynamicQueryableExtensions.OrderBy(query, input.Sorting);
var query2 = query.GroupBy(o => new { o.ErpToLoc, o.RealPartCode }).Select(o => new VmiBalanceSumDto { ErpToLoc = o.Key.ErpToLoc,RealPartCode = o.Key.RealPartCode, Qty = o.Sum(o => o.Qty) });
var totalCount = query2.Count();
var entities = await query2.PageBy(input.SkipCount, input.MaxResultCount).ToListAsync().ConfigureAwait(false);
return new PagedResultDto<VmiBalanceSumDto>(totalCount, entities);
}
/// <summary>
/// 1.2库存余额汇总导出
/// </summary>
[HttpPost]
public async Task<string> BalanceSumExport(RequestDto input)
{
var connectionString = this._serviceProvider.GetRequiredService<IConfiguration>().GetConnectionString("SettleAccountService");
var options = new DbContextOptionsBuilder<SettleAccountDbContext>().UseSqlServer(connectionString).Options;
using var db = new SettleAccountDbContext(options);
var query = db.Set<VmiBalance>().FromSqlRaw("select * from Set_VmiBalance");
var filters = input.Filters.ToLambda<VmiBalance>();
if (input.Filters.Count > 0)
{
query = query.Where(input.Filters.ToLambda<VmiBalance>());
}
query = string.IsNullOrEmpty(input.Sorting) ? query : DynamicQueryableExtensions.OrderBy(query, input.Sorting);
var query2 = query.GroupBy(o => new { o.ErpToLoc, o.RealPartCode }).Select(o => new VmiBalanceSumDto { ErpToLoc = o.Key.ErpToLoc, RealPartCode = o.Key.RealPartCode, Qty = o.Sum(o => o.Qty) });
var totalCount = query2.Count();
var entities = await query2.PageBy(input.SkipCount, input.MaxResultCount).ToListAsync().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);
return fileName;
}
@ -602,3 +651,14 @@ public class LogRequestDto : RequestDto
{
public List<VmiLogType> LogTypes { get; set; } = new List<VmiLogType>();
}
public class VmiBalanceSumDto
{
[Display(Name = "ERP库位", Order = 13)]
public string ErpToLoc { get; set; }
[Display(Name = "厂内零件号", Order = 6)]
public string RealPartCode { get; set; }//原始
[Display(Name = "数量", Order = 10)]
public decimal Qty { get; set; }
}

Loading…
Cancel
Save