姜旭之 1 year ago
parent
commit
ac700aa40e
  1. 2
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/SettleAccountHttpApiHostModule.cs
  2. 1
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/assets/docs/home.md
  3. BIN
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/assets/导入模版.zip
  4. 4
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/list/index.js
  5. 91
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/material-relationship.js
  6. 99
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/material.js
  7. 2
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/router/base-date.js
  8. 15
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/base-data/material-relationship.js
  9. 8
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/home.js
  10. 7
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_SA_DTO.cs
  11. 1
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/SettleAccount.Application.Contracts.csproj
  12. 105
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs
  13. 5
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/MaterialRelationships/MaterialRelationshipAppService.cs

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

@ -336,7 +336,7 @@ namespace Win.Sfs.SettleAccount
xmlapppath = Path.Combine(AppContext.BaseDirectory, "SettleAccount.Application.Contracts.xml");
if (File.Exists(xmlapppath))
{
options.IncludeXmlComments(xmlapppath);
options.IncludeXmlComments(xmlapppath, true);
}
options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
{

1
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/assets/docs/home.md

@ -0,0 +1 @@
[导入模板下载](/assets/导入模版.zip)

BIN
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/assets/导入模版.zip

Binary file not shown.

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

@ -238,9 +238,9 @@ export default {
</template>
<template v-else-if="editFormMode==='import'">
<el-form :model="importModel" style="height:100%;">
<el-form-item :label="$t('导入模板')">
<!-- <el-form-item :label="$t('导入模板')">
<el-link type="primary" @click="getImportTemplate">{{$t('下载')}}</el-link>
</el-form-item>
</el-form-item> -->
<el-form-item label="选择工厂" label-width="80px">
<el-select v-model="importModel.version">
<el-option v-for="item in versions" :value="item.value" :label="item.label" />

91
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/material-relationship.js

@ -0,0 +1,91 @@
const schema = {
title: "物料主数据",
type: "object",
properties: {
erpMaterialCode: {
title: "厂内零件号",
type: "string",
},
settleMaterialCode: {
title: "客户零件号",
type: "string",
},
materialDesc: {
title: "物料描述",
type: "string",
},
},
};
const baseUrl = "settleaccount/material-relationship";
const queryUrl = `${baseUrl}/get-list`;
const exportUrl = `${baseUrl}/export`;
const queryMethod = "POST";
const exportMethod = "POST";
export default function () {
return {
baseUrl,
query: {
url: queryUrl,
method: queryMethod,
schema: {
title: "物料主数据",
type: "object",
properties: {
filters: {
type: "array",
hidden: true,
items: {
type: "object",
properties: {
logic: {
type: "int",
},
column: {
type: "string",
},
action: {
type: "int",
},
value: {
type: "string",
},
},
},
default: [
{
logic: "and",
column: "erpMaterialCode",
action: "like",
value: null,
readOnly: true,
},
],
},
skipCount: {
hidden: true,
default: 0,
},
maxResultCount: {
hidden: true,
default: 10,
},
sorting: {
hidden: true,
},
},
},
},
table: {
schema: schema,
},
edit: {
queryUrl,
exportUrl,
queryMethod,
exportMethod,
schema: schema,
},
};
}

99
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/material.js

@ -0,0 +1,99 @@
const schema = {
title: "物料主数据",
type: "object",
properties: {
factory: {
title: "客户物料号",
type: "string",
},
materialCode: {
title: "厂内物料号",
type: "string",
},
materialDesc: {
title: "物料描述",
type: "string",
},
unit: {
title: "基本计量单位",
type: "string",
},
estimateType: {
title: "产品类型",
type: "string",
},
},
};
const baseUrl = "settleaccount/material";
const queryUrl = `${baseUrl}/get-list`;
const exportUrl = `${baseUrl}/export`;
const queryMethod = "POST";
const exportMethod = "POST";
export default function () {
return {
baseUrl,
query: {
url: queryUrl,
method: queryMethod,
schema: {
title: "物料主数据",
type: "object",
properties: {
filters: {
type: "array",
hidden: true,
items: {
type: "object",
properties: {
logic: {
type: "int",
},
column: {
type: "string",
},
action: {
type: "int",
},
value: {
type: "string",
},
},
},
default: [
{
logic: "and",
column: "materialCode",
action: "like",
value: null,
readOnly: true,
},
],
},
skipCount: {
hidden: true,
default: 0,
},
maxResultCount: {
hidden: true,
default: 10,
},
sorting: {
hidden: true,
},
},
},
},
table: {
schema: schema,
},
edit: {
queryUrl,
exportUrl,
queryMethod,
exportMethod,
schema: schema,
},
};
}

2
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/router/base-date.js

@ -126,7 +126,7 @@ export default [
},
},
{
path: "query",
path: "export",
meta: {
type: "button",
title: "导出",

15
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/base-data/material-relationship.js

@ -0,0 +1,15 @@
import AppList from "../../components/list/index.js";
import html from "html";
import useConfig from "../../models/material-relationship.js";
export default {
components: { AppList },
template: html`<app-list :config="config" @command="onCommand" />`,
setup() {
const config = useConfig();
const onCommand = async (item, rows) => {
console.log(item.path, item, rows);
};
return { config, onCommand };
},
};

8
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/home.js

@ -1,7 +1,7 @@
import html from 'html';
import Md from '../components/markdown/index.js'
import html from "html";
import Md from "../components/markdown/index.js";
export default {
components: { Md },
template: html`Home <md name="test"></md>`
}
template: html`<md name="home" />`,
};

7
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_SA_DTO.cs

@ -52,7 +52,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
/// <summary>
/// 结算日期
/// </summary>
[Display(Name = "结算日期")]
[ImporterHeader(Name = "Pstng Date")]
[Required(ErrorMessage = "{0}不能为空")]
public DateTime SettleDate { set; get; }
/// <summary>
@ -66,7 +68,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
/// <summary>
/// 生产号
/// </summary>
[Display(Name = "生产号")]
[ImporterHeader(Name = "External Delivery ID")]
[Required(ErrorMessage = "{0}不能为空")]
public string PN { get; set; }
///// <summary>
@ -80,13 +84,16 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
///// <summary>
/// 数量
/// </summary>
[Display(Name = "数量")]
[ImporterHeader(Name = "Quantity")]
public decimal Qty { get; set; }
/// <summary>
/// 结算分组号
/// </summary>
[Display(Name = "结算分组号")]
[ImporterHeader(Name = "Delivery")]
[Required(ErrorMessage = "{0}不能为空")]
public string GroupNum { get; set; }
/////// <summary>

1
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/SettleAccount.Application.Contracts.csproj

@ -7,6 +7,7 @@
<RootNamespace>Win.Sfs.SettleAccount</RootNamespace>
<Version>1.0.25</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">

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

@ -22,6 +22,8 @@ using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.Prices;
using Win.Sfs.SettleAccount.ExcelImporter;
using Win.Sfs.SettleAccount.ExportReports;
using Win.Sfs.SettleAccount.MaterialRelationships;
using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ
@ -63,6 +65,16 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
/// </summary>
private readonly INormalEfCoreRepository<PriceList, Guid> _priceListRepository;
/// <summary>
/// 客户零件关系仓储
/// </summary>
private readonly INormalEfCoreRepository<MaterialRelationship, Guid> _materialRelationshipRepository;
/// <summary>
/// 替换件关系仓储
/// </summary>
private readonly INormalEfCoreRepository<TB_RePartsRelationship, Guid> _tbRePartsRelationshipRepository;
/// <summary>
/// 构造
/// </summary>
@ -97,8 +109,37 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
[HttpPost]
public async Task<string> ZGJImportAsync([FromForm] IFormFileCollection files)
{
//数据校验
var checkList = new List<ErrorExportDto>();
//类型(直供件)
EnumBusinessType businessType = EnumBusinessType.ZhiGongJian;
var businessType = EnumBusinessType.ZhiGongJian;
//结算单号
var pubSaBillNum = OrderNumberGenerator.GenerateOrderNumber("SA");
//结算主表
var pubSa = new PUB_SA()
{
BillNum = pubSaBillNum,
State = "1"
};
//结算明细
var pubSaDetails = new List<PUB_SA_DETAIL>();
//可算单号
var pubCanSaBillNum = OrderNumberGenerator.GenerateOrderNumber("C");
//可算主表
var pubCanSa = new PUB_CAN_SA()
{
BillNum = pubCanSaBillNum,
SettleBillNum = pubSaBillNum,
State = SettleBillState.,
BusinessType = businessType
};
//可结算明细
var pubCanSaDetails = new List<PUB_CAN_SA_DETAIL>();
//不可结算明细
var pubNotSaDetails = new List<PUB_NOT_SA_DETAIL>();
#region 导入数据转换、数据校验
ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.UploadExcelImport<ZGJ_PUB_SA_DETAIL_IMPORT_DTO>(files, _excelImportService);
var importPubSaDetails = ObjectMapper.Map<List<ZGJ_PUB_SA_DETAIL_IMPORT_DTO>, List<PUB_SA_DETAIL>>(result);
@ -106,15 +147,27 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
//结算分组号
var pubSaGroupNums = importPubSaDetails.Select(t => t.GroupNum).Distinct();
//销售价格
var priceListEntitys = await _priceListRepository.GetAllAsync();
//已存在的结算分组号
var havPubSaGroupNums = (await _pubSaDetailRepository.GetListAsync(t => pubSaGroupNums.Contains(t.GroupNum))).Select(t => t.GroupNum).Distinct();
if (havPubSaGroupNums.Any() == true)
{
foreach (var item in havPubSaGroupNums)
{
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"结算分组号{item}已存在", string.Empty));
}
//throw new UserFriendlyException($"导入失败,结算分组号({string.Join(",", havPubSaGroupNums)})已存在", "400");
}
var pubSaBillNum = OrderNumberGenerator.GenerateOrderNumber("SA");
var pubSa = new PUB_SA()
if (checkList.Count > 0)
{
BillNum = pubSaBillNum,
State = "1"
};
return await ExportErrorReportAsync(checkList);
}
#endregion
#region 处理结算数据
//销售价格
var priceListEntitys = await _priceListRepository.GetAllAsync();
importPubSaDetails.ForEach(importPubSaDetail =>
{
@ -136,28 +189,30 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
importPubSaDetail.Price = priceListEntity?.Price ?? 0;
});
//可结算
var pubCanSaBillNum = OrderNumberGenerator.GenerateOrderNumber("C");
var pubCanSa = new PUB_CAN_SA()
{
BillNum = pubCanSaBillNum,
SettleBillNum = pubSaBillNum,
State = SettleBillState.,
BusinessType = businessType
};
////导入的零件号集合
//var importPubSaLUs = importPubSaDetails.Select(t => t.LU).Distinct();
//_materialRelationshipRepository.GetListAsync(t => t.)
#endregion
#region 入库数据赋值
//结算明细
pubSaDetails = importPubSaDetails;
//不可结算 结算分组号码(根据价格区分结算、不可结算)
var pubNotSaGroupNums = importPubSaDetails.FindAll(t => t.Price == default(decimal)).Select(t => t.GroupNum).Distinct();
var pubSaDetailsCanSes = importPubSaDetails.FindAll(t => pubNotSaGroupNums.Contains(t.GroupNum) == false);
var pubSaDetailsNotCanSes = importPubSaDetails.FindAll(t => pubNotSaGroupNums.Contains(t.GroupNum) == true);
//可结算
var pubCanSaDetails = ObjectMapper.Map<List<PUB_SA_DETAIL>, List<PUB_CAN_SA_DETAIL>>(pubSaDetailsCanSes);
//不可结算
var pubNotSaDetails = ObjectMapper.Map<List<PUB_SA_DETAIL>, List<PUB_NOT_SA_DETAIL>>(pubSaDetailsNotCanSes);
//可结算明细
pubCanSaDetails = ObjectMapper.Map<List<PUB_SA_DETAIL>, List<PUB_CAN_SA_DETAIL>>(pubSaDetailsCanSes);
//不可结算明细
pubNotSaDetails = ObjectMapper.Map<List<PUB_SA_DETAIL>, List<PUB_NOT_SA_DETAIL>>(pubSaDetailsNotCanSes);
#endregion
//添加入库
#region 添加入库
await _repository.InsertAsync(pubSa);
await _pubSaDetailRepository.InsertManyAsync(importPubSaDetails);
if (pubCanSaDetails.Count > 0)
@ -181,7 +236,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
});
await _pubNotSaDetailRepository.InsertManyAsync(pubNotSaDetails);
}
}
#endregion
return ApplicationConsts.SuccessStr;
}
@ -245,7 +302,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
//验证可结算主表状态
if (pubCanSaDelEntitys.Any(t => t.State != SettleBillState.))
{
throw new UserFriendlyException($"该单据可结算单状态无法删除!");
throw new UserFriendlyException($"该单据可结算单状态无法删除!", "400");
}
pubSaDetailDelEntitys = await _pubSaDetailRepository.GetListAsync(t => t.BillNum == pubSaBillNum);

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

@ -12,6 +12,7 @@ using Win.Abp.Snowflakes;
using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.CommonManagers;
using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.ExcelImporter;
using Win.Sfs.SettleAccount.ExportReports;
using Win.Sfs.SettleAccount.MaterialRelationships;
@ -96,7 +97,7 @@ namespace Win.Sfs.SettleAccount.Entities.MaterialRelationships
/// 导出
/// </summary>
[HttpPost]
public async Task<string> ExportAsync(RequestDtoBase input)
public async Task<string> ExportAsync(RequestDto input)
{
string fileName = $"客户零件关系_{Guid.NewGuid()}.xlsx";
var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true);
@ -116,7 +117,7 @@ namespace Win.Sfs.SettleAccount.Entities.MaterialRelationships
/// 获取列表
/// </summary>
[HttpPost]
public async Task<PagedResultDto<MaterialRelationshipDto>> GetListAsync(RequestDtoBase input)
public async Task<PagedResultDto<MaterialRelationshipDto>> GetListAsync(RequestDto input)
{
var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount, true);
var totalCount = await _repository.GetCountByFilterAsync(input.Filters);

Loading…
Cancel
Save