学 赵 1 year ago
parent
commit
a22e53efa6
  1. 51
      code/WebApp/vanilla/components/form/form-item.js
  2. 28
      code/WebApp/vanilla/components/list/index.js
  3. 4
      code/WebApp/vanilla/config/settings.js
  4. 1
      code/WebApp/vanilla/index.html
  5. 8
      code/WebApp/vanilla/lib/async-validator/index.min.js
  6. 56029
      code/WebApp/vanilla/lib/element-plus/index.full.mjs
  7. 62
      code/WebApp/vanilla/models/code-setting.js
  8. 11
      code/WebApp/vanilla/models/login.js
  9. 38
      code/WebApp/vanilla/models/user.js
  10. 2
      code/WebApp/vanilla/router/routes.js
  11. 53
      code/WebApp/vanilla/utils/validation.js
  12. 3
      code/src/AuthServer/AuthServer.Host/appsettings.json
  13. 1
      code/src/Modules/BaseService/BaseService.EntityFrameworkCore/EntityFrameworkCore/BaseServiceEntityFrameworkCoreModule.cs
  14. 2
      code/src/Modules/BaseService/BaseService.Host/BaseService.Host.csproj
  15. 2
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/.gitignore
  16. 255
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/AuthServer/AuthServerDataSeeder.cs
  17. 125
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/AuthServer/AuthServerHostModule.cs
  18. 22
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/AuthServer/EntityFrameworkCore/AuthServerDbContext.cs
  19. 29
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/AuthServer/EntityFrameworkCore/AuthServerDbContextFactory.cs
  20. 274
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/BaseServiceHostModule.cs
  21. 34
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/SettleAccount.HttpApi.Host.csproj
  22. 88
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/SettleAccountHttpApiHostModule.cs
  23. 123
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/appsettings.Development.json
  24. 5
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/appsettings.json
  25. 1
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/tempkey.jwk
  26. 66
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_SA_DTO.cs
  27. 46
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs
  28. 3
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/CodeSettingTables/CodeSettingAppService.cs
  29. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs
  30. 14
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/SettleAccount.EntityFrameworkCore.csproj
  31. 29
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/appsettings.json
  32. 22
      code/src/SettleAccount.sln
  33. 7
      docs/demo/src/WTA.Application/Identity/Data/IdentityDbSeed.cs
  34. 2
      docs/demo/src/WTA.Application/Identity/Entities/SystemManagement/BOM.cs
  35. 2
      docs/demo/src/WTA.Application/Identity/Entities/SystemManagement/CentralizedControl.cs
  36. 2
      docs/demo/src/WTA.Application/Identity/Entities/SystemManagement/PURCHASE_PRICE.cs
  37. 2
      docs/demo/src/WTA.Application/Identity/Entities/SystemManagement/TB_PRICE_LIST.cs

51
code/WebApp/vanilla/components/form/form-item.js

@ -1,7 +1,6 @@
import html from "html"; import html from "html";
import { defineAsyncComponent, ref, reactive, watch } from "vue"; import { defineAsyncComponent, ref, reactive, watch } from "vue";
import { format } from "../../utils/index.js"; import { getRules } from "../../utils/validation.js";
import { messages } from "../../utils/validation.js";
export default { export default {
name: "formItem", name: "formItem",
@ -14,7 +13,7 @@ export default {
:title="prop" :title="prop"
:label="schema.title" :label="schema.title"
:prop="getProp(prop)" :prop="getProp(prop)"
:rules="getRules(parentSchema,schema,model)" :rules="getDisabled()?[]:getRules(parentSchema,schema,model)"
:error="mode==='query'?null:getError(prop)" :error="mode==='query'?null:getError(prop)"
> >
<app-form-input :schema="schema" :prop="prop" v-model="model" :mode="mode" /> <app-form-input :schema="schema" :prop="prop" v-model="model" :mode="mode" />
@ -39,6 +38,15 @@ export default {
} }
return true; return true;
}; };
const getDisabled = () => {
if (props.mode === "details") {
return true;
}
if (props.mode === "update" && props.schema.readOnly) {
return true;
}
return false;
};
// //
const getProp = (prop) => { const getProp = (prop) => {
return prop; return prop;
@ -47,48 +55,13 @@ export default {
const getError = (prop) => { const getError = (prop) => {
return props.errors[prop]; return props.errors[prop];
}; };
//
const getRules = (parentSchema, property, data) => {
if (props.mode === "query" || props.mode === "details" || !property.rules) {
return null;
}
const rules = [...(Array.isArray(property.rules) ? property.rules : [property.rules])].map((o) =>
JSON.parse(JSON.stringify(o))
);
Object.values(rules).forEach((rule) => {
rule.data = data;
rule.schema = parentSchema;
rule.title = rule.title ?? property.title;
rule.type = property.type;
if (rule.validator) {
rule.validator = validators[rule.validator];
}
if (!rule.message) {
if (rule.required) {
rule.message = format(messages.required, property.title);
} else if (rule.pattern) {
rule.message = format(messages.pattern, property.title);
} else if (property.type === "string" || property.type === "number" || property.type === "array") {
if (rule.len) {
rule.message = format(messages[property.type].len, property.title, rule.len);
} else if (rule.min) {
rule.message = format(messages[property.type].min, property.title, rule.min);
} else if (rule.max) {
rule.message = format(messages[property.type].max, property.title, rule.max);
} else if (rule.range) {
rule.message = format(messages[property.type].range, property.title, rule.range);
}
}
}
});
return rules;
};
/*end*/ /*end*/
return { return {
model, model,
showItem, showItem,
getProp, getProp,
getError, getError,
getDisabled,
getRules, getRules,
}; };
}, },

28
code/WebApp/vanilla/components/list/index.js

@ -3,11 +3,12 @@ import request, { get, post } from "../../request/index.js";
import { defineAsyncComponent, ref, reactive, onMounted } from "vue"; import { defineAsyncComponent, ref, reactive, onMounted } from "vue";
import { useRoute, useRouter } from "vue-router"; import { useRoute, useRouter } from "vue-router";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import { listToTree, schemaToModel, importFunction } from "../../utils/index.js"; import { listToTree, schemaToModel, importFunction, format } from "../../utils/index.js";
import qs from "../../lib/qs/shim.js"; import qs from "../../lib/qs/shim.js";
import VueOfficeExcel from "@vue-office/excel"; import VueOfficeExcel from "@vue-office/excel";
import { camelCase, capitalize } from "lodash"; import { camelCase, capitalize } from "lodash";
import { useAppStore } from "../../store/index.js"; import { useAppStore } from "../../store/index.js";
import { ElMessage, ElMessageBox } from "element-plus";
export default { export default {
name: "AppList", name: "AppList",
@ -477,8 +478,8 @@ export default {
if (item.path === "create") { if (item.path === "create") {
editFormModel.value = schemaToModel(config.edit.schema); editFormModel.value = schemaToModel(config.edit.schema);
} else { } else {
const url = `${config.edit.updateUrl ?? config.query.url}/${rows[0].id}`; const url = format(config.edit.detailsUrl, rows[0].id);
editFormModel.value = (await request(url, null, { method: "GET" })).data; editFormModel.value = (await request(url, null, { method: config.edit.detailsMethod })).data;
editFormModel.value.id = rows[0].id; editFormModel.value.id = rows[0].id;
} }
editFormTitle.value = `${t(item.path)}${config.edit.schema.title}`; editFormTitle.value = `${t(item.path)}${config.edit.schema.title}`;
@ -490,6 +491,25 @@ export default {
return; return;
} else { } else {
// 单个删除 // 单个删除
const url = format(config.edit.deleteUrl, rows[0].id);
try {
await ElMessageBox.confirm("删除", "提示", {
type: "warning",
message: format("确认删除当前行数据吗?", rows[0]),
});
await request(url, null, { method: config.edit.deleteMethod });
ElMessage({
type: "info",
message: "操作完毕",
});
} catch (error) {
if (error === "cancel") {
ElMessage({
type: "info",
message: "删除取消",
});
}
}
} }
const url = `${baseUrl}/${item.path}`; const url = `${baseUrl}/${item.path}`;
// await post( // await post(
@ -522,7 +542,7 @@ export default {
let url = let url =
(editFormMode.value === "create" ? config.edit.createUrl : config.edit.updateUrl) ?? config.query.url; (editFormMode.value === "create" ? config.edit.createUrl : config.edit.updateUrl) ?? config.query.url;
if (editFormMode.value === "update") { if (editFormMode.value === "update") {
url = `${url}/${editFormModel.value.id}`; url = format(url, editFormModel.value.id);
} }
const method = editFormMode.value === "create" ? config.edit.createMethod : config.edit.updateMethod; const method = editFormMode.value === "create" ? config.edit.createMethod : config.edit.updateMethod;
const result = await request(url, editFormModel.value, { method }); const result = await request(url, editFormModel.value, { method });

4
code/WebApp/vanilla/config/settings.js

@ -1,5 +1,5 @@
export default { export default {
enableLocale: false, enableLocale: false,
baseURL: "http://dev.ccwin-in.com:10582/api", //baseURL: "http://dev.ccwin-in.com:10582/api",
//baseURL: "http://localhost:10130/api", baseURL: "http://localhost:44378/api",
}; };

1
code/WebApp/vanilla/index.html

@ -58,6 +58,7 @@
"@microsoft/signalr": "./lib/@microsoft/signalr/signalr.esm.js", "@microsoft/signalr": "./lib/@microsoft/signalr/signalr.esm.js",
"@vueuse/shared": "./lib/@vueuse/shared/index.mjs", "@vueuse/shared": "./lib/@vueuse/shared/index.mjs",
"@vueuse/core": "./lib/@vueuse/core/index.mjs", "@vueuse/core": "./lib/@vueuse/core/index.mjs",
"async-validator": "./lib/async-validator/index.min.js",
"element-plus": "./lib/element-plus/index.full.min.mjs", "element-plus": "./lib/element-plus/index.full.min.mjs",
"@element-plus/icons-vue":"./lib/@element-plus/icons-vue/index.js", "@element-plus/icons-vue":"./lib/@element-plus/icons-vue/index.js",
"nprogress": "./lib/nprogress/nprogress.vite-esm.js", "nprogress": "./lib/nprogress/nprogress.vite-esm.js",

8
code/WebApp/vanilla/lib/async-validator/index.min.js

File diff suppressed because one or more lines are too long

56029
code/WebApp/vanilla/lib/element-plus/index.full.mjs

File diff suppressed because one or more lines are too long

62
code/WebApp/vanilla/models/code-setting.js

@ -2,7 +2,7 @@ const schema = {
title: "通用代码", title: "通用代码",
type: "object", type: "object",
properties: { properties: {
userName: { project: {
title: "项目", title: "项目",
type: "string", type: "string",
readOnly: true, readOnly: true,
@ -13,7 +13,7 @@ const schema = {
}, },
], ],
}, },
userName: { value: {
title: "值", title: "值",
type: "string", type: "string",
readOnly: true, readOnly: true,
@ -24,7 +24,7 @@ const schema = {
}, },
], ],
}, },
name: { description: {
title: "描述", title: "描述",
type: "string", type: "string",
showForList: true, showForList: true,
@ -37,28 +37,57 @@ const schema = {
}, },
}; };
const url = "base/code-settings"; const baseUrl = "settleaccount/code-setting";
const createUrl = url; const queryUrl = `${baseUrl}/get-list`;
const updateUrl = url; const detailsUrl = `${baseUrl}/GET/%s`;
const deleteUrl = url; const createUrl = `${baseUrl}/Create`;
const method = "GET"; const updateUrl = `${baseUrl}/Update/%s`;
const deleteUrl = `${baseUrl}/DeleteList`;
const queryMethod = "POST";
const detailsMethod = "POST";
const createMethod = "POST"; const createMethod = "POST";
const updateMethod = "PUT"; const updateMethod = "POST";
const deleteMethod = "DELETE"; const deleteMethod = "POST";
export default function () { export default function () {
return { return {
query: { query: {
url, url: queryUrl,
method, method: queryMethod,
schema: { schema: {
title: "通用代码", title: "通用代码",
type: "object", type: "object",
properties: { properties: {
filter: { project: {
title: "项目", type: "string",
},
value: {
type: "string",
},
description: {
type: "string", type: "string",
}, },
filters: {
title: "项目",
type: "array",
items: {
type: "object",
properties: {
logic: {
type: "int",
},
column: {
type: "string",
},
action: {
type: "int",
},
value: {
type: "string",
},
},
},
},
skipCount: { skipCount: {
hidden: true, hidden: true,
default: 0, default: 0,
@ -67,6 +96,9 @@ export default function () {
hidden: true, hidden: true,
default: 10, default: 10,
}, },
sorting: {
hidden: true,
},
}, },
}, },
}, },
@ -74,9 +106,11 @@ export default function () {
schema: schema, schema: schema,
}, },
edit: { edit: {
detailsUrl,
createUrl, createUrl,
updateUrl, updateUrl,
deleteUrl, deleteUrl,
detailsMethod,
createMethod, createMethod,
updateMethod, updateMethod,
deleteMethod, deleteMethod,

11
code/WebApp/vanilla/models/login.js

@ -11,10 +11,6 @@ export default function () {
required: true, required: true,
message: "用户名不能为空", message: "用户名不能为空",
}, },
{
max: 64,
message: "用户名的最大长度为 64",
},
], ],
}, },
password: { password: {
@ -26,13 +22,6 @@ export default function () {
required: true, required: true,
message: "密码不能为空", message: "密码不能为空",
}, },
{
max: 64,
message: "密码的最大长度为 64",
},
{
message: "DataTypeAttribute",
},
], ],
}, },
client_id: { client_id: {

38
code/WebApp/vanilla/models/user.js

@ -13,7 +13,9 @@ const schema = {
}, },
{ {
max: 64, max: 64,
message: "用户名的最大长度为 64", },
{
min: 4,
}, },
], ],
}, },
@ -22,6 +24,14 @@ const schema = {
type: "string", type: "string",
readOnly: true, readOnly: true,
input: "password", input: "password",
rules: [
{
required: true,
},
{
min: 6,
},
],
}, },
name: { name: {
title: "姓名", title: "姓名",
@ -31,6 +41,7 @@ const schema = {
{ {
required: true, required: true,
}, },
{ pattern: "^[\u4e00-\u9fa5]+$", message: "%s必须是正确的格式" },
], ],
}, },
phoneNumber: { phoneNumber: {
@ -41,6 +52,7 @@ const schema = {
{ {
required: true, required: true,
}, },
{ pattern: "^\\d{11}$", message: "%s必须是正确的格式" },
], ],
}, },
email: { email: {
@ -48,9 +60,8 @@ const schema = {
type: "string", type: "string",
showForList: true, showForList: true,
rules: [ rules: [
{ { required: true },
required: true, { pattern: "^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+.[a-zA-Z0-9_-]+$", message: "%s必须是正确的格式" },
},
], ],
}, },
// roleNames: { // roleNames: {
@ -68,11 +79,14 @@ const schema = {
}, },
}; };
const url = "base/user"; const baseUrl = "base/user";
const createUrl = url; const queryUrl = `${baseUrl}`;
const updateUrl = url; const detailsUrl = `${baseUrl}/%s`;
const deleteUrl = "api/identity/users"; const createUrl = `${baseUrl}`;
const method = "GET"; const updateUrl = `${baseUrl}/%s`;
const deleteUrl = "identity/users/%s";
const queryMethod = "GET";
const detailsMethod = "GET";
const createMethod = "POST"; const createMethod = "POST";
const updateMethod = "PUT"; const updateMethod = "PUT";
const deleteMethod = "DELETE"; const deleteMethod = "DELETE";
@ -80,8 +94,8 @@ const deleteMethod = "DELETE";
export default function () { export default function () {
return { return {
query: { query: {
url, url: queryUrl,
method, method: queryMethod,
schema: { schema: {
title: "用户", title: "用户",
type: "object", type: "object",
@ -106,9 +120,11 @@ export default function () {
selectable: (o) => o.name !== "admin", selectable: (o) => o.name !== "admin",
}, },
edit: { edit: {
detailsUrl,
createUrl, createUrl,
updateUrl, updateUrl,
deleteUrl, deleteUrl,
detailsMethod,
createMethod, createMethod,
updateMethod, updateMethod,
deleteMethod, deleteMethod,

2
code/WebApp/vanilla/router/routes.js

@ -52,7 +52,7 @@ export default [
title: "删除", title: "删除",
icon: "file", icon: "file",
permission: "AbpIdentity.Users.Delete", permission: "AbpIdentity.Users.Delete",
isTop: true, disabled: "o=>o.userName==='admin'",
}, },
}, },
{ {

53
code/WebApp/vanilla/utils/validation.js

@ -1,3 +1,6 @@
import { format } from "./index.js";
//import { Schema } from "element-plus";
const messages = { const messages = {
default: "%s验证失败", default: "%s验证失败",
required: "%s是必填项", required: "%s是必填项",
@ -42,7 +45,7 @@ const messages = {
range: "%s的数量必须在%s和%s之间", range: "%s的数量必须在%s和%s之间",
}, },
pattern: { pattern: {
mismatch: "%s的值 %s 不匹配模式 %s", mismatch: "%s的值必须是正确的格式",
}, },
clone: function clone() { clone: function clone() {
const cloned = JSON.parse(JSON.stringify(this)); const cloned = JSON.parse(JSON.stringify(this));
@ -110,4 +113,50 @@ const validators = {
}, },
}; };
export { messages }; //
const getRules = (parentSchema, property, data) => {
if (!property.rules) {
return null;
}
const rules = [...(Array.isArray(property.rules) ? property.rules : [property.rules])].map((o) =>
JSON.parse(JSON.stringify(o))
);
Object.values(rules).forEach((rule) => {
rule.data = data;
rule.schema = parentSchema;
rule.title ??= property.title;
if (!rule.type && property.type !== "object") {
rule.type = property.type;
}
if (rule.validator) {
rule.validator = validators[rule.validator];
}
if (!rule.message) {
if (rule.required) {
rule.message = format(messages.required, property.title);
} else if (rule.type === "email") {
rule.message = format(messages.types.email, property.title);
} else if (rule.pattern) {
rule.message = format(messages.pattern.mismatch, property.title);
} else if (property.type === "string" || property.type === "number" || property.type === "array") {
if (rule.len) {
rule.message = format(messages[property.type].len, property.title, rule.len);
} else if (rule.min) {
rule.message = format(messages[property.type].min, property.title, rule.min);
} else if (rule.max) {
rule.message = format(messages[property.type].max, property.title, rule.max);
} else if (rule.range) {
rule.message = format(messages[property.type].range, property.title, rule.range);
}
}
} else {
rule.message = format(rule.message, property.title);
}
});
return rules;
};
//Object.assign(Schema.messages, messages);
//Object.assign(Schema.validators, validators);
export { getRules };

3
code/src/AuthServer/AuthServer.Host/appsettings.json

@ -1,6 +1,7 @@
{ {
"ConnectionStrings": { "ConnectionStrings": {
"Default": "Server=localhost;Database=BJABP;User ID=sa;Password=aA123456!;Trusted_Connection=False;TrustServerCertificate=True" "Default": "Server=dev.ccwin-in.com,13319;Database=BJABP;User ID=ccwin-in;Password=Microsoft@2022;Trusted_Connection=False;TrustServerCertificate=True"
//"Default": "Server=localhost;Database=BJABP;User ID=sa;Password=aA123456!;Trusted_Connection=False;TrustServerCertificate=True"
}, },
"CorsOrigins": "http://localhost:9527,http://dev.ccwin-in.com:10588,http://localhost:44307", "CorsOrigins": "http://localhost:9527,http://dev.ccwin-in.com:10588,http://localhost:44307",
"ElasticSearch": { "ElasticSearch": {

1
code/src/Modules/BaseService/BaseService.EntityFrameworkCore/EntityFrameworkCore/BaseServiceEntityFrameworkCoreModule.cs

@ -39,6 +39,7 @@ namespace BaseService.EntityFrameworkCore
private void ConfigureDbContext() private void ConfigureDbContext()
{ {
Configure<AbpDbContextOptions>(options => { options.UseSqlServer(); }); Configure<AbpDbContextOptions>(options => { options.UseSqlServer(); });
} }
} }

2
code/src/Modules/BaseService/BaseService.Host/BaseService.Host.csproj

@ -21,7 +21,7 @@
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="3.0.1" /> <PackageReference Include="IdentityServer4.AccessTokenValidation" Version="3.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.1" /> <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.1" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="5.0.1" /> <PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="5.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.1"> <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.8">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>

2
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/.gitignore

@ -0,0 +1,2 @@
wwwroot/files/
appsettings.Development.json

255
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/AuthServer/AuthServerDataSeeder.cs

@ -0,0 +1,255 @@
using IdentityServer4.Models;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp.Authorization.Permissions;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Guids;
using Volo.Abp.Identity;
using Volo.Abp.IdentityServer.ApiResources;
using Volo.Abp.IdentityServer.ApiScopes;
using Volo.Abp.IdentityServer.Clients;
using Volo.Abp.IdentityServer.IdentityResources;
using Volo.Abp.PermissionManagement;
using Volo.Abp.Uow;
using ApiResource = Volo.Abp.IdentityServer.ApiResources.ApiResource;
using ApiScope = Volo.Abp.IdentityServer.ApiScopes.ApiScope;
using Client = Volo.Abp.IdentityServer.Clients.Client;
namespace AuthServer.Host
{
public class AuthServerDataSeeder : IDataSeedContributor, ITransientDependency
{
private readonly IApiResourceRepository _apiResourceRepository;
private readonly IApiScopeRepository _apiScopeRepository;
private readonly IClientRepository _clientRepository;
private readonly IIdentityResourceDataSeeder _identityResourceDataSeeder;
private readonly IGuidGenerator _guidGenerator;
private readonly IPermissionDataSeeder _permissionDataSeeder;
public AuthServerDataSeeder(
IClientRepository clientRepository,
IApiResourceRepository apiResourceRepository,
IApiScopeRepository apiScopeRepository,
IIdentityResourceDataSeeder identityResourceDataSeeder,
IGuidGenerator guidGenerator,
IPermissionDataSeeder permissionDataSeeder)
{
_clientRepository = clientRepository;
_apiResourceRepository = apiResourceRepository;
_apiScopeRepository = apiScopeRepository;
_identityResourceDataSeeder = identityResourceDataSeeder;
_guidGenerator = guidGenerator;
_permissionDataSeeder = permissionDataSeeder;
}
[UnitOfWork]
public virtual async Task SeedAsync(DataSeedContext context)
{
await _identityResourceDataSeeder.CreateStandardResourcesAsync();
await CreateApiResourcesAsync();
await CreateApiScopesAsync();
await CreateClientsAsync();
}
private async Task CreateApiScopesAsync()
{
await CreateApiScopeAsync("BaseService");
await CreateApiScopeAsync("InternalGateway");
await CreateApiScopeAsync("WebAppGateway");
await CreateApiScopeAsync("TenantService");
await CreateApiScopeAsync("BusinessService");
await CreateApiScopeAsync("FileStorageService");
await CreateApiScopeAsync("IdentityService");
await CreateApiScopeAsync("SettleAccount");
}
private async Task CreateApiResourcesAsync()
{
var commonApiUserClaims = new[]
{
"email",
"email_verified",
"name",
"user_name",
"phone_number",
"phone_number_verified",
"role"
};
await CreateApiResourceAsync("IdentityService", commonApiUserClaims);
await CreateApiResourceAsync("BaseService", commonApiUserClaims);
await CreateApiResourceAsync("InternalGateway", commonApiUserClaims);
await CreateApiResourceAsync("WebAppGateway", commonApiUserClaims);
await CreateApiResourceAsync("TenantService", commonApiUserClaims);
await CreateApiResourceAsync("BusinessService", commonApiUserClaims);
await CreateApiResourceAsync("FileStorageService", commonApiUserClaims);
await CreateApiResourceAsync("SettleAccount", commonApiUserClaims);
}
private async Task<ApiResource> CreateApiResourceAsync(string name, IEnumerable<string> claims)
{
var apiResource = await _apiResourceRepository.FindByNameAsync(name);
if (apiResource == null)
{
apiResource = await _apiResourceRepository.InsertAsync(
new ApiResource(
_guidGenerator.Create(),
name,
name + " API"
),
autoSave: true
);
}
foreach (var claim in claims)
{
if (apiResource.FindClaim(claim) == null)
{
apiResource.AddUserClaim(claim);
}
}
return await _apiResourceRepository.UpdateAsync(apiResource);
}
private async Task<ApiScope> CreateApiScopeAsync(string name)
{
var apiScope = await _apiScopeRepository.GetByNameAsync(name);
if (apiScope == null)
{
apiScope = await _apiScopeRepository.InsertAsync(
new ApiScope(
_guidGenerator.Create(),
name,
name + " API"
),
autoSave: true
);
}
return apiScope;
}
private async Task CreateClientsAsync()
{
var commonScopes = new[]
{
"email",
"username",
"name",
"openid",
"profile",
"role",
"phone",
"address"
};
await CreateClientAsync(
"basic-web",
new[] { "IdentityService", "BaseService", "WebAppGateway", "FileStorageService", "TenantService", "BusinessService", "SettleAccount" },
new[] { "password" },
"1q2w3e*".Sha256()
);
//BaseDataService
await CreateClientAsync(
"business-app",
new[] { "InternalGateway", "IdentityService", "BaseService", "FileStorageService", "SettleAccount" },
new[] { "client_credentials" },
"1q2w3e*".Sha256(),
permissions: new[] { IdentityPermissions.Users.Default }
);
//FileStorge
await CreateClientAsync(
"file-app",
new[] { "InternalGateway", "IdentityService", "BaseService", "BaseDataService", "BusinessService" },
new[] { "client_credentials" },
"1q2w3e*".Sha256(),
permissions: new[] { IdentityPermissions.Users.Default }
);
}
private async Task<Client> CreateClientAsync(
string name,
IEnumerable<string> scopes,
IEnumerable<string> grantTypes,
string secret,
string redirectUri = null,
string postLogoutRedirectUri = null,
IEnumerable<string> permissions = null)
{
var client = await _clientRepository.FindByClientIdAsync(name);
if (client == null)
{
client = await _clientRepository.InsertAsync(
new Client(
_guidGenerator.Create(),
name
)
{
ClientName = name,
ProtocolType = "oidc",
Description = name,
AlwaysIncludeUserClaimsInIdToken = true,
AllowOfflineAccess = true,
AbsoluteRefreshTokenLifetime = 31536000, //365 days
AccessTokenLifetime = 31536000, //365 days
AuthorizationCodeLifetime = 300,
IdentityTokenLifetime = 300,
RequireConsent = false
},
autoSave: true
);
}
foreach (var scope in scopes)
{
if (client.FindScope(scope) == null)
{
client.AddScope(scope);
}
}
foreach (var grantType in grantTypes)
{
if (client.FindGrantType(grantType) == null)
{
client.AddGrantType(grantType);
}
}
if (client.FindSecret(secret) == null)
{
client.AddSecret(secret);
}
if (redirectUri != null)
{
if (client.FindRedirectUri(redirectUri) == null)
{
client.AddRedirectUri(redirectUri);
}
}
if (postLogoutRedirectUri != null)
{
if (client.FindPostLogoutRedirectUri(postLogoutRedirectUri) == null)
{
client.AddPostLogoutRedirectUri(postLogoutRedirectUri);
}
}
if (permissions != null)
{
await _permissionDataSeeder.SeedAsync(
ClientPermissionValueProvider.ProviderName,
name,
permissions
);
}
return await _clientRepository.UpdateAsync(client);
}
}
}

125
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/AuthServer/AuthServerHostModule.cs

@ -0,0 +1,125 @@
using AuthServer.Host.EntityFrameworkCore;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.Extensions.DependencyInjection;
using StackExchange.Redis;
using System;
using System.Linq;
using Volo.Abp;
using Volo.Abp.Account;
using Volo.Abp.Account.Web;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic;
using Volo.Abp.Auditing;
using Volo.Abp.AuditLogging.EntityFrameworkCore;
using Volo.Abp.Autofac;
using Volo.Abp.Data;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore.SqlServer;
using Volo.Abp.Identity.EntityFrameworkCore;
using Volo.Abp.IdentityServer.EntityFrameworkCore;
using Volo.Abp.Localization;
using Volo.Abp.Modularity;
using Volo.Abp.PermissionManagement.EntityFrameworkCore;
using Volo.Abp.SettingManagement.EntityFrameworkCore;
using Volo.Abp.TenantManagement.EntityFrameworkCore;
using Volo.Abp.Threading;
namespace AuthServer.Host
{
[DependsOn(
typeof(AbpAutofacModule),
typeof(AbpPermissionManagementEntityFrameworkCoreModule),
typeof(AbpAuditLoggingEntityFrameworkCoreModule),
typeof(AbpSettingManagementEntityFrameworkCoreModule),
typeof(AbpIdentityEntityFrameworkCoreModule),
typeof(AbpIdentityServerEntityFrameworkCoreModule),
typeof(AbpTenantManagementEntityFrameworkCoreModule),
typeof(AbpEntityFrameworkCoreSqlServerModule),
typeof(AbpAccountWebIdentityServerModule),
typeof(AbpAccountApplicationModule),
typeof(AbpAspNetCoreMvcUiBasicThemeModule)
)]
public class AuthServerHostModule : AbpModule
{
private const string DefaultCorsPolicyName = "Default";
public override void ConfigureServices(ServiceConfigurationContext context)
{
var configuration = context.Services.GetConfiguration();
context.Services.AddAbpDbContext<AuthServerDbContext>(options =>
{
options.AddDefaultRepositories();
});
Configure<AbpDbContextOptions>(options =>
{
options.UseSqlServer();
});
Configure<AbpLocalizationOptions>(options =>
{
options.Languages.Add(new LanguageInfo("en", "en", "English"));
});
context.Services.AddStackExchangeRedisCache(options =>
{
options.Configuration = configuration["Redis:Configuration"];
});
context.Services.AddCors(options =>
{
options.AddPolicy(DefaultCorsPolicyName,
builder =>
{
builder.WithOrigins(configuration["App:CorsOrigins"]
.Split(",", StringSplitOptions.RemoveEmptyEntries)
.Select(o => o.RemovePostFix("/"))
.ToArray())
.WithAbpExposedHeaders()
.SetIsOriginAllowedToAllowWildcardSubdomains()
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
});
});
Configure<AbpAuditingOptions>(options =>
{
options.IsEnabledForGetRequests = true;
options.ApplicationName = "AuthServer";
});
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]);
context.Services.AddDataProtection()
.PersistKeysToStackExchangeRedis(redis, "DataProtection-Keys");
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
app.UseCorrelationId();
app.UseVirtualFiles();
app.UseRouting();
app.UseCors(DefaultCorsPolicyName);
app.UseAuthentication();
app.UseMultiTenancy();
app.UseIdentityServer();
app.UseAuthorization();
app.UseAbpRequestLocalization();
app.UseAuditing();
AsyncHelper.RunSync(async () =>
{
using (var scope = context.ServiceProvider.CreateScope())
{
await scope.ServiceProvider
.GetRequiredService<IDataSeeder>()
.SeedAsync();
}
});
}
}
}

22
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/AuthServer/EntityFrameworkCore/AuthServerDbContext.cs

@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.IdentityServer.EntityFrameworkCore;
namespace AuthServer.Host.EntityFrameworkCore
{
public class AuthServerDbContext : AbpDbContext<AuthServerDbContext>
{
public AuthServerDbContext(DbContextOptions<AuthServerDbContext> options)
: base(options)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.ConfigureIdentityServer();
}
}
}

29
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/AuthServer/EntityFrameworkCore/AuthServerDbContextFactory.cs

@ -0,0 +1,29 @@
using System.IO;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Configuration;
namespace AuthServer.Host.EntityFrameworkCore
{
public class AuthServerDbContextFactory : IDesignTimeDbContextFactory<AuthServerDbContext>
{
public AuthServerDbContext CreateDbContext(string[] args)
{
var configuration = BuildConfiguration();
var builder = new DbContextOptionsBuilder<AuthServerDbContext>()
.UseSqlServer(configuration.GetConnectionString("Default"));
return new AuthServerDbContext(builder.Options);
}
private static IConfigurationRoot BuildConfiguration()
{
var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false);
return builder.Build();
}
}
}

274
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/BaseServiceHostModule.cs

@ -0,0 +1,274 @@
using BaseService.EntityFrameworkCore;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.OpenApi.Models;
using StackExchange.Redis;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using Volo.Abp;
using Volo.Abp.AspNetCore.MultiTenancy;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc.AntiForgery;
using Volo.Abp.AspNetCore.Serilog;
using Volo.Abp.Auditing;
using Volo.Abp.Autofac;
using Volo.Abp.Data;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.Identity;
using Volo.Abp.Localization;
using Volo.Abp.Modularity;
using Volo.Abp.MultiTenancy;
using Volo.Abp.PermissionManagement.HttpApi;
using Volo.Abp.Security.Claims;
using Volo.Abp.TenantManagement;
using Volo.Abp.Threading;
//using Win.Sfs.SettleAccount;
//using Win.Sfs.BaseData;
//using BaseData;
namespace BaseService
{
[DependsOn(
typeof(AbpAutofacModule),
typeof(BaseServiceApplicationModule),
typeof(BaseServiceEntityFrameworkCoreModule),
typeof(BaseServiceHttpApiModule),
typeof(AbpAspNetCoreMultiTenancyModule),
typeof(AbpPermissionManagementHttpApiModule),
typeof(AbpTenantManagementHttpApiModule),
typeof(AbpIdentityHttpApiModule),
// typeof(BaseDataHttpApiModule),
//typeof(BaseDataApplicationContractsModule),
//typeof(SettleAccountHttpApiModule),
typeof(AbpAspNetCoreSerilogModule)
)]
public class BaseServiceHostModule : AbpModule
{
private const string DefaultCorsPolicyName = "Default";
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddHttpClient();
Configure<AbpAntiForgeryOptions>(O => O.AutoValidate = false);
var configuration = context.Services.GetConfiguration();
ConfigureConventionalControllers();
ConfigureMultiTenancy();
ConfigureJwt(context, configuration);
//ConfigureSwagger(context);
ConfigureDbContext();
ConfigureRedis(context, configuration);
ConfigureAuditing();
//ConfigureCros(context, configuration);
ConfigureLocalization();
ConfigurePasswordSet(context);
}
private void ConfigureLocalization()
{
Configure<AbpLocalizationOptions>(options =>
{
options.Languages.Add(new LanguageInfo("en", "en", "English"));
options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文"));
});
}
/// <summary>
/// 设置密码强度
/// </summary>
/// <param name="context"></param>
private void ConfigurePasswordSet(ServiceConfigurationContext context)
{
context.Services.Configure<IdentityOptions>(options =>
{
options.User.RequireUniqueEmail = true;
//options.Lockout.AllowedForNewUsers = true;
//options.Lockout.MaxFailedAccessAttempts = 2;
options.Password.RequireDigit = false;
options.Password.RequireLowercase = false;
options.Password.RequireNonAlphanumeric = false;
options.Password.RequireUppercase = false;
options.Password.RequiredLength = 6;
});
}
private static void ConfigureCros(ServiceConfigurationContext context, IConfiguration configuration)
{
context.Services.AddCors(options =>
{
options.AddPolicy(DefaultCorsPolicyName, builder =>
{
builder
.WithOrigins(
configuration["App:CorsOrigins"]
.Split(",", StringSplitOptions.RemoveEmptyEntries)
.Select(o => o.RemovePostFix("/"))
.ToArray()
)
.WithAbpExposedHeaders()
.SetIsOriginAllowedToAllowWildcardSubdomains()
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
});
});
}
private void ConfigureAuditing()
{
Configure<AbpAuditingOptions>(options =>
{
options.IsEnabledForGetRequests = true;
options.ApplicationName = "BaseService";
});
}
private static void ConfigureRedis(ServiceConfigurationContext context, IConfiguration configuration)
{
context.Services.AddStackExchangeRedisCache(options =>
{
options.Configuration = configuration["Redis:Configuration"];
});
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]);
context.Services.AddDataProtection()
.PersistKeysToStackExchangeRedis(redis, "DataProtection-Keys");
}
private void ConfigureDbContext()
{
Configure<AbpDbContextOptions>(options => { options.UseSqlServer(); });
}
private static void ConfigureSwagger(ServiceConfigurationContext context)
{
context.Services.AddSwaggerGen(options =>
{
options.SwaggerDoc("v1", new OpenApiInfo { Title = "BaseService Service API", Version = "v1" });
options.DocInclusionPredicate((docName, description) => true);
options.CustomSchemaIds(type => type.FullName);
options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
{
Description = "请输入 JWT Token",
Name = "Authorization",
In = ParameterLocation.Header,
Type = SecuritySchemeType.Http,
Scheme = "Bearer"
});
options.AddSecurityRequirement(new OpenApiSecurityRequirement()
{
{
new OpenApiSecurityScheme
{
Reference = new OpenApiReference {Type = ReferenceType.SecurityScheme, Id = "Bearer"}
},
new string[] { }
}
});
});
}
private static void ConfigureJwt(ServiceConfigurationContext context, IConfiguration configuration)
{
//context.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
// .AddJwtBearer(options =>
// {
// options.Authority = configuration["AuthServer:Authority"];
// options.RequireHttpsMetadata = false;
// options.Audience = "BaseService";
// });
}
private void ConfigureMultiTenancy()
{
Configure<AbpMultiTenancyOptions>(options => { options.IsEnabled = true; });
}
private void ConfigureConventionalControllers()
{
//Configure<AbpAspNetCoreMvcOptions>(options =>
//{
// options.ConventionalControllers.Create(typeof(BaseServiceApplicationModule).Assembly);
//});
Configure<AbpAspNetCoreMvcOptions>(options =>
{
options
.ConventionalControllers
.Create(typeof(BaseServiceApplicationModule).Assembly, opts
=>
{ opts.RootPath = "base"; })
;
});
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
app.UseCorrelationId();
app.UseVirtualFiles();
app.UseRouting();
app.UseCors(DefaultCorsPolicyName);
app.UseAuthentication();
app.UseMultiTenancy();
app.Use(async (ctx, next) =>
{
var currentPrincipalAccessor = ctx.RequestServices.GetRequiredService<ICurrentPrincipalAccessor>();
var map = new Dictionary<string, string>()
{
{ "sub", AbpClaimTypes.UserId },
{ "role", AbpClaimTypes.Role },
{ "email", AbpClaimTypes.Email },
{ "name", AbpClaimTypes.UserName },
};
var mapClaims = currentPrincipalAccessor.Principal.Claims.Where(p => map.Keys.Contains(p.Type)).ToList();
currentPrincipalAccessor.Principal.AddIdentity(new ClaimsIdentity(mapClaims.Select(p => new Claim(map[p.Type], p.Value, p.ValueType, p.Issuer))));
await next();
});
app.UseAbpRequestLocalization();
app.UseAuthorization();
app.UseSwagger();
app.UseSwaggerUI(options =>
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Identity Service API");
});
app.UseAuditing();
app.UseAbpSerilogEnrichers();
app.UseConfiguredEndpoints();
AsyncHelper.RunSync(async () =>
{
using (var scope = context.ServiceProvider.CreateScope())
{
await scope.ServiceProvider
.GetRequiredService<IDataSeeder>()
.SeedAsync();
}
});
}
}
}

34
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/SettleAccount.HttpApi.Host.csproj

@ -1,4 +1,4 @@

<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<Import Project="..\..\common.props" /> <Import Project="..\..\common.props" />
@ -24,7 +24,7 @@
<PackageReference Include="Hangfire.SqlServer" Version="1.7.24" /> <PackageReference Include="Hangfire.SqlServer" Version="1.7.24" />
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="3.0.1" /> <PackageReference Include="IdentityServer4.AccessTokenValidation" Version="3.0.1" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="5.0.7" /> <PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="5.0.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.7"> <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.8">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
@ -44,25 +44,49 @@
<PackageReference Include="Volo.Abp.BlobStoring.FileSystem" Version="4.3.3" /> <PackageReference Include="Volo.Abp.BlobStoring.FileSystem" Version="4.3.3" />
<PackageReference Include="Volo.Abp.Caching" Version="4.3.3" /> <PackageReference Include="Volo.Abp.Caching" Version="4.3.3" />
<PackageReference Include="Volo.Abp.HangFire" Version="4.3.3" /> <PackageReference Include="Volo.Abp.HangFire" Version="4.3.3" />
<PackageReference Include="Volo.Abp.Identity.HttpApi" Version="4.3.3" />
<PackageReference Include="Volo.Abp.PermissionManagement.Application" Version="4.3.3" />
<PackageReference Include="Volo.Abp.PermissionManagement.EntityFrameworkCore" Version="4.3.3" />
<PackageReference Include="Volo.Abp.PermissionManagement.HttpApi" Version="4.3.3" />
<PackageReference Include="Volo.Abp.SettingManagement.EntityFrameworkCore" Version="4.3.3" />
<PackageReference Include="Volo.Abp.Settings" Version="4.3.3" />
<PackageReference Include="Volo.Abp.TenantManagement.Application" Version="4.3.3" />
<PackageReference Include="Volo.Abp.TenantManagement.EntityFrameworkCore" Version="4.3.3" />
<PackageReference Include="Volo.Abp.TenantManagement.HttpApi" Version="4.3.3" />
<PackageReference Include="Volo.Abp.Identity.EntityFrameworkCore" Version="4.3.3" />
<PackageReference Include="Volo.Abp.Account.Application" Version="4.3.3" />
<PackageReference Include="Volo.Abp.Account.Web.IdentityServer" Version="4.3.3" />
<PackageReference Include="Volo.Abp.IdentityServer.EntityFrameworkCore" Version="4.3.3" />
<PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic" Version="4.3.3" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\BaseService\BaseService.Application\BaseService.Application.csproj" />
<ProjectReference Include="..\..\..\BaseService\BaseService.EntityFrameworkCore\BaseService.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\..\BaseService\BaseService.HttpApi\BaseService.HttpApi.csproj" />
<ProjectReference Include="..\..\src\SettleAccount.HttpApi\SettleAccount.HttpApi.csproj" /> <ProjectReference Include="..\..\src\SettleAccount.HttpApi\SettleAccount.HttpApi.csproj" />
<ProjectReference Include="..\..\src\SettleAccount.Application\SettleAccount.Application.csproj" /> <ProjectReference Include="..\..\src\SettleAccount.Application\SettleAccount.Application.csproj" />
<ProjectReference Include="..\..\src\SettleAccount.EntityFrameworkCore\SettleAccount.EntityFrameworkCore.csproj" /> <ProjectReference Include="..\..\src\SettleAccount.EntityFrameworkCore\SettleAccount.EntityFrameworkCore.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Remove="EntityFrameworkCore\**" />
<Compile Remove="Logs\**" /> <Compile Remove="Logs\**" />
<Compile Remove="Migrations\**" />
<Content Remove="EntityFrameworkCore\**" />
<Content Remove="Logs\**" /> <Content Remove="Logs\**" />
<Content Remove="Migrations\**" />
<EmbeddedResource Remove="EntityFrameworkCore\**" />
<EmbeddedResource Remove="Logs\**" /> <EmbeddedResource Remove="Logs\**" />
<EmbeddedResource Remove="Migrations\**" />
<None Remove="EntityFrameworkCore\**" />
<None Remove="Logs\**" /> <None Remove="Logs\**" />
<None Remove="Migrations\**" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="EntityFrameworkCore\" /> <Folder Include="wwwroot\" />
<Folder Include="Migrations\" />
<Folder Include="wwwroot\files\host\my-file-container\" />
</ItemGroup> </ItemGroup>
<ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JsonSchema="" /></VisualStudio></ProjectExtensions> <ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>

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

@ -1,67 +1,56 @@
using System; using AuthServer.Host;
using System.Collections.Generic; using BaseService;
using System.IO; using Hangfire;
using System.Linq;
using IdentityModel;
using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Cors; using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using StackExchange.Redis;
using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models;
using StackExchange.Redis;
using Swashbuckle.AspNetCore.SwaggerUI;
using System;
using System.IO;
using System.Linq;
using System.Text.Json;
using Volo.Abp; using Volo.Abp;
using Volo.Abp.AspNetCore.ExceptionHandling;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Serilog; using Volo.Abp.AspNetCore.Serilog;
using Volo.Abp.AuditLogging.EntityFrameworkCore; using Volo.Abp.AuditLogging.EntityFrameworkCore;
using Volo.Abp.Autofac; using Volo.Abp.Autofac;
using Volo.Abp.BackgroundJobs.Hangfire;
using Volo.Abp.BlobStoring;
using Volo.Abp.BlobStoring.FileSystem;
using Volo.Abp.Caching; using Volo.Abp.Caching;
using Volo.Abp.Data;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore.SqlServer; using Volo.Abp.EntityFrameworkCore.SqlServer;
using Volo.Abp.Localization; using Volo.Abp.Localization;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
using Volo.Abp.MultiTenancy; using Volo.Abp.MultiTenancy;
using Volo.Abp.PermissionManagement.EntityFrameworkCore; using Volo.Abp.PermissionManagement.EntityFrameworkCore;
using Volo.Abp.Security.Claims;
using Volo.Abp.SettingManagement.EntityFrameworkCore; using Volo.Abp.SettingManagement.EntityFrameworkCore;
using Volo.Abp.Threading;
using Volo.Abp.VirtualFileSystem; using Volo.Abp.VirtualFileSystem;
using Win.Utils;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.ExceptionHandling;
using Swashbuckle.AspNetCore.SwaggerUI;
using Win.Sfs.Shared.Constant;
using Volo.Abp.BlobStoring;
using Volo.Abp.BlobStoring.FileSystem;
using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.BaseData.ImportExcelCommon;
using Microsoft.AspNetCore.Http.Features;
using System.Text.Encodings.Web;
using System.Text.Unicode;
using Newtonsoft.Json.Serialization;
using System.Text.Json;
using Volo.Abp.Threading;
using Volo.Abp.Data;
using Hangfire;
using Volo.Abp.BackgroundJobs.Hangfire;
using Volo.Abp.Hangfire;
using Win.Sfs.SettleAccount.ImportExcelCommon; using Win.Sfs.SettleAccount.ImportExcelCommon;
using Volo.Abp.RabbitMQ; using Win.Sfs.Shared.Constant;
using Volo.Abp.EventBus.RabbitMq; using Win.Utils;
using Volo.Abp.AspNetCore.Mvc.ExceptionHandling;
namespace Win.Sfs.SettleAccount namespace Win.Sfs.SettleAccount
{ {
[DependsOn( [DependsOn(
typeof(AbpAutofacModule),
typeof(AuthServerHostModule),
typeof(BaseServiceHostModule),
typeof(SettleAccountApplicationModule), typeof(SettleAccountApplicationModule),
typeof(SettleAccountEntityFrameworkCoreModule), typeof(SettleAccountEntityFrameworkCoreModule),
typeof(SettleAccountHttpApiModule), typeof(SettleAccountHttpApiModule),
//typeof(AbpAspNetCoreMvcUiMultiTenancyModule), //typeof(AbpAspNetCoreMvcUiMultiTenancyModule),
typeof(AbpAutofacModule),
//typeof(AbpCachingStackExchangeRedisModule), //typeof(AbpCachingStackExchangeRedisModule),
typeof(AbpEntityFrameworkCoreSqlServerModule), typeof(AbpEntityFrameworkCoreSqlServerModule),
typeof(AbpAuditLoggingEntityFrameworkCoreModule), typeof(AbpAuditLoggingEntityFrameworkCoreModule),
@ -73,8 +62,6 @@ namespace Win.Sfs.SettleAccount
typeof(AbpBackgroundJobsHangfireModule) typeof(AbpBackgroundJobsHangfireModule)
//typeof(AbpEventBusRabbitMqModule) //typeof(AbpEventBusRabbitMqModule)
//typeof(AbpHangfireModule) //typeof(AbpHangfireModule)
//typeof(AbpSwashbuckleModule) //typeof(AbpSwashbuckleModule)
@ -103,7 +90,7 @@ namespace Win.Sfs.SettleAccount
//配置Redis //配置Redis
ConfigureRedis(context, configuration); ConfigureRedis(context, configuration);
//配置跨域资源共享 //配置跨域资源共享
ConfigureCors(context, configuration); //ConfigureCors(context, configuration);
//配置Swagger //配置Swagger
ConfigureSwaggerServices(context, configuration); ConfigureSwaggerServices(context, configuration);
//null: DTO的属性首字母保持大写 //null: DTO的属性首字母保持大写
@ -120,14 +107,10 @@ namespace Win.Sfs.SettleAccount
ConfigureBLOBTSecSummaryServices(configuration); ConfigureBLOBTSecSummaryServices(configuration);
ConfigureHangfire(context, configuration); ConfigureHangfire(context, configuration);
//context.Services.Configure<AbpExceptionHttpStatusCodeOptions>(options => //context.Services.Configure<AbpExceptionHttpStatusCodeOptions>(options =>
//{ //{
// options.Map("Volo.Qa:010002", System.Net.HttpStatusCode.Conflict); // options.Map("Volo.Qa:010002", System.Net.HttpStatusCode.Conflict);
//}); //});
//context.Services.Configure<AbpExceptionHandlingOptions>(options => //context.Services.Configure<AbpExceptionHandlingOptions>(options =>
//{ //{
@ -144,16 +127,13 @@ namespace Win.Sfs.SettleAccount
}); });
*/ */
//Configure<AbpRabbitMqEventBusOptions>(options => //Configure<AbpRabbitMqEventBusOptions>(options =>
//{ //{
// options.ClientName = "SettleAccount"; // options.ClientName = "SettleAccount";
// options.ExchangeName = "TestMessages"; // options.ExchangeName = "TestMessages";
//}); //});
//Configure<AbpBackgroundJobWorkerOptions>(options => //Configure<AbpBackgroundJobWorkerOptions>(options =>
//{ //{
// options.DefaultTimeout = 864000; //10 days (as seconds) // options.DefaultTimeout = 864000; //10 days (as seconds)
@ -165,10 +145,8 @@ namespace Win.Sfs.SettleAccount
x.MultipartBodyLengthLimit = int.MaxValue; x.MultipartBodyLengthLimit = int.MaxValue;
x.MemoryBufferThreshold = int.MaxValue; x.MemoryBufferThreshold = int.MaxValue;
}); });
} }
private void ConfigureBodyLengthLimit(ServiceConfigurationContext context) private void ConfigureBodyLengthLimit(ServiceConfigurationContext context)
{ {
context.Services.Configure<FormOptions>(options => context.Services.Configure<FormOptions>(options =>
@ -177,8 +155,6 @@ namespace Win.Sfs.SettleAccount
options.MultipartBodyLengthLimit = int.MaxValue; options.MultipartBodyLengthLimit = int.MaxValue;
options.MultipartHeadersLengthLimit = int.MaxValue; options.MultipartHeadersLengthLimit = int.MaxValue;
}); });
} }
@ -204,6 +180,7 @@ namespace Win.Sfs.SettleAccount
}); });
}); });
} }
/// <summary> /// <summary>
/// 大众-存储二配实际输出表 /// 大众-存储二配实际输出表
/// </summary> /// </summary>
@ -226,6 +203,7 @@ namespace Win.Sfs.SettleAccount
}); });
}); });
} }
/// <summary> /// <summary>
/// 奔腾-二配实际输出打印表的保存路径 /// 奔腾-二配实际输出打印表的保存路径
/// </summary> /// </summary>
@ -258,7 +236,6 @@ namespace Win.Sfs.SettleAccount
opt.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase; opt.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
//opt.JsonSerializerOptions.Converters.Add(new DatetimeJsonConverter()); //opt.JsonSerializerOptions.Converters.Add(new DatetimeJsonConverter());
}); });
} }
private void ConfigureException() private void ConfigureException()
@ -285,11 +262,8 @@ namespace Win.Sfs.SettleAccount
=> =>
{ opts.RootPath = "settleaccount"; }); { opts.RootPath = "settleaccount"; });
}); });
} }
private void ConfigureCache(IConfiguration configuration) private void ConfigureCache(IConfiguration configuration)
{ {
Configure<AbpDistributedCacheOptions>(options => Configure<AbpDistributedCacheOptions>(options =>
@ -331,7 +305,6 @@ namespace Win.Sfs.SettleAccount
// options.ApiName = "SettleAccount"; // options.ApiName = "SettleAccount";
// }); // });
context.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) context.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options => .AddJwtBearer(options =>
{ {
@ -339,7 +312,6 @@ namespace Win.Sfs.SettleAccount
options.RequireHttpsMetadata = false; options.RequireHttpsMetadata = false;
options.Audience = "SettleAccount"; options.Audience = "SettleAccount";
}); });
} }
} }
@ -417,16 +389,17 @@ namespace Win.Sfs.SettleAccount
} }
} }
private void ConfigureHangfire(ServiceConfigurationContext context, IConfiguration configuration) private void ConfigureHangfire(ServiceConfigurationContext context, IConfiguration configuration)
{ {
context.Services.AddHangfire(config => context.Services.AddHangfire(config =>
{ {
config.UseSqlServerStorage(configuration.GetConnectionString("SettleAccountService")); config.UseSqlServerStorage(configuration.GetConnectionString("SettleAccountService"), new Hangfire.SqlServer.SqlServerStorageOptions
{
PrepareSchemaIfNecessary = true
});
}); });
} }
private void ConfigureCors(ServiceConfigurationContext context, IConfiguration configuration) private void ConfigureCors(ServiceConfigurationContext context, IConfiguration configuration)
{ {
context.Services.AddCors(options => context.Services.AddCors(options =>
@ -449,7 +422,6 @@ namespace Win.Sfs.SettleAccount
}); });
} }
public override void OnApplicationInitialization(ApplicationInitializationContext context) public override void OnApplicationInitialization(ApplicationInitializationContext context)
{ {
var app = context.GetApplicationBuilder(); var app = context.GetApplicationBuilder();

123
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/appsettings.Development.json

@ -1,123 +0,0 @@
{
"App": {
"CorsOrigins": "https://*.abc.com,http://localhost:9528,http://149.223.116.5:8088"
},
//"ConnectionStrings": {
// "Default": "Server=LAPTOP-V3U07C2O;Database=ABP;user id=sa;Password=1q2w!@#",
// "SettleAccountService": "Server=LAPTOP-V3U07C2O;Database=SettleAccountService1;user id=sa;Password=1q2w!@#;"
//},
"ConnectionStrings": {
"Default": "Server=dev.ccwin-in.com,13319;Database=BJABP;User ID=ccwin-in;Password=Microsoft@2022;Trusted_Connection=False;TrustServerCertificate=True",
"SettleAccountService": "Server=dev.ccwin-in.com,13319;Database=BQ_SA;User ID=ccwin-in;Password=Microsoft@2022;Trusted_Connection=False;TrustServerCertificate=True;"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"Serilog": {
"Using": [],
"MinumumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Warning",
"System": "Warning"
}
},
"Settings": {
"Abp.Mailing.Smtp.Host": "149.223.116.5",
"Abp.Mailing.Smtp.Port": "25",
"Abp.Mailing.Smtp.UserName": "",
"Abp.Mailing.Smtp.Password": "",
"Abp.Mailing.Smtp.Domain": "",
"Abp.Mailing.Smtp.EnableSsl": "false",
"Abp.Mailing.Smtp.UseDefaultCredentials": "true",
"Abp.Mailing.DefaultFromAddress": "noreply@abp.io",
"Abp.Mailing.DefaultFromDisplayName": "ABP application"
},
"WriteTo": [
{ "Name": "Console" },
{
"Name": "File",
"Args": {
"path": ".\\Logs\\log-.txt",
"rollingInterval": "Day", // Not currently in use.
"rollOnFileSizeLimit": true,
"fileSizeLimitBytes": 10000000,
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff G} {Message}{NewLine:1}{Exception:1}"
}
},
{
"Name": "MSSqlServer",
"Args": {
"connectionString": "Default",
"tableName": "Logs",
"autoCreateSqlTable": true,
"restrictedToMinimumLevel": "Information",
"batchPostingLimit": 1000,
"period": "0.00:00:30"
}
}
]
},
"RabbitMQ": {
"Connections": {
"Default": {
"HostName": "149.223.116.5"
}
},
"EventBus": {
"ClientName": "MyClientName",
"ExchangeName": "MyExchangeName"
}
},
"AuthServer": {
"Authority": "http://149.223.116.5:8066",
"AlwaysAllowAuthorization": false
},
"Redis": {
"Configuration": "127.0.0.1"
},
"DefaultBranchId": "3FA85F64-5717-4562-B3FC-2C963F66AFA6",
"AllowedHosts": "*",
"ElasticSearch": {
"Url": "http://localhost:9200"
},
"RemoteServices": {
"Default": {
"BaseUrl": "http://149.223.116.5:8091/",
"UseCurrentAccessToken": "true"
}
},
"IdentityClients": {
"Default": {
"GrantType": "client_credentials",
"ClientId": "business-app",
"ClientSecret": "1q2w3e*",
"Authority": "http://149.223.116.5:8066",
"Scope": "InternalGateway IdentityService SettleAccount"
}
}
}

5
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/appsettings.json

@ -6,7 +6,6 @@
"Default": "Server=dev.ccwin-in.com,13319;Database=BJABP;User ID=ccwin-in;Password=Microsoft@2022;Trusted_Connection=False;TrustServerCertificate=True", "Default": "Server=dev.ccwin-in.com,13319;Database=BJABP;User ID=ccwin-in;Password=Microsoft@2022;Trusted_Connection=False;TrustServerCertificate=True",
"SettleAccountService": "Server=dev.ccwin-in.com,13319;Database=BQ_SA;User ID=ccwin-in;Password=Microsoft@2022;Trusted_Connection=False;TrustServerCertificate=True;" "SettleAccountService": "Server=dev.ccwin-in.com,13319;Database=BQ_SA;User ID=ccwin-in;Password=Microsoft@2022;Trusted_Connection=False;TrustServerCertificate=True;"
}, },
"Serilog": { "Serilog": {
"Using": [], "Using": [],
"MinumumLevel": { "MinumumLevel": {
@ -70,7 +69,9 @@
"AuthServer": { "AuthServer": {
"Authority": "http://dev.ccwin-in.com:10580", "Authority": "http://dev.ccwin-in.com:10580",
"AlwaysAllowAuthorization": false //"Authority": "http://localhost:10130",
"ClientId": "basic-web",
"ClientSecret": "1q2w3e*"
}, },
"Redis": { "Redis": {

1
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/tempkey.jwk

@ -0,0 +1 @@
{"AdditionalData":{},"Alg":"RS256","Crv":null,"D":"mkeKcDJDeFxfcUlsAiiqTRAVA5uIhEFm8ZSnSZgYdWCTNs1Yz6fmGcB9rHzoCAhVn3Z3okacYYrQgKTYRr_33iAepQTtwC9IYDOrrBpbKgHI1pYEu7nJGeeYCW_tnUuADV6s8qt5UPUg0HpluP1scZFmWYKVsD9JSAOEX53lZWAF4gANuR9N_w5S7wb5-qsUcrD7Mb3AecREKAFBJ1aNHlPNoZdU0fCRSLA2dwPVl8Bf-2BQdB4Wgec0ZBUw-t40QALzSc-gLWa8oL6E4cFtHjguguK_abXuqX0he6qSszLpVyHOpF5dReJ22UgRLI5BPaGRn_1Ppen1uLWBtKvdmQ","DP":"4Ud2MTnS6rD1_mhmvvSSH_koj7DU3Eu03ornkzbtYtxKEsr1jQYot5kn3Tz82kiOfz6EqCq9avBhzWFGqacNv9rnoSZDQoBgn_hwtYQuhQnZizMIBsfu2YMvuWpSOqXsiJKMOY2voVj2MCcrKzkzO2emjnCgSgGLgnTpPNMeZZk","DQ":"j9N4UFrWXFrnN8ueV5BvCFPVR3rCkQM5VtYbVuNr4Hg_vZ7q4BfChC6cOoVzu8mdbEhUZStNjWw-qDfUU4g5UfIyy8Wd5PPaaoR71eMpY1sUeDpmwUzcXnhaiouaBjmkEdRbFqpPcEKdvM9lgI9shGPBuGigK_BnCBUTKMDa4EM","E":"AQAB","K":null,"KeyId":"22FA1AC0DC170A29CAA724FD239AEF60","Kid":"22FA1AC0DC170A29CAA724FD239AEF60","Kty":"RSA","N":"xwskHLqkzp8bt0X3P8tUKM_2laM7dKz5X3UdJm27WSziqA_2oaccYY8XMnBdZeRPlXbHMAnUmZocOAbRcUKvymtTl47OGpLlazEdcKUDDklzcC9jf_zMi2C4Fy6M_j3kh1YT0oZqUSEUHbBtHRgbP7gyIM1eUyM7-jf2GRFzvC5zZYGaqKAqXDvQ1ew9Juk_QEndRgIpiEU9_-QlIrVBrUqTdxWf3SsbsBpOZgYKsE88TNUHFCBpFmQtyoEDKtmz-k3JkruBLJlZIztOqtgnDWddUvIrzM_NZ-zjzd72JGDiTZ0EHqQL66-LXSXtf_LB4Db-Hy-FceePOckN7BlRiQ","Oth":null,"P":"4-IwXgK0CpLFiIlWb-pRu1q1k2QM4scvKAi_ri9zPoRXnxnoCfjY11cR3ptHzRCVO9fepTorjO2S5v4COW2DYs1Xd59qMxDYWHuZ02qfk3tK068W0HkXcfL7MpHNqeSPAFQKWlnn4IyyoxHTaBiGHHYK3ddgBzbp95_zC-MWvy8","Q":"35oGpIH5mCZzVuB6DxC43IisMmeaSnnSsnPlF13liLGq-smVnDcVkHLy7pyPG4xnr9M2AKqKn2wwGX8mazzAbLNfGzob3Zb_OyL2ocMJXIKdAK3raUteKtFcWtzMneQ2aMh7Ui4OlAgTrCc-l6TjzYACgMUzSdfNxL30EmmzjMc","QI":"1-5k_RJIlPsfG-thor9IHAlyj1l_aiOcE9zgpsGurna7XhqfHFFGMjoCcqZi9-zPX4ZyTbCJtwsgIy2cwjZJ3kMDc4Fxf4WmB4okZcMPTq0EkOa6D251hv6rjJW0JWNWtEwrk-87aCi4BtlBFIG3TiXWKGtUC-PsDEiGtDlQAxM","Use":null,"X":null,"X5t":null,"X5tS256":null,"X5u":null,"Y":null,"KeySize":2048,"HasPrivateKey":true,"CryptoProviderFactory":{"CryptoProviderCache":{},"CustomCryptoProvider":null,"CacheSignatureProviders":true,"SignatureProviderObjectPoolCacheSize":48}}

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

@ -1,9 +1,6 @@
using System; using Magicodes.ExporterAndImporter.Core;
using System.Collections.Generic; using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
@ -35,9 +32,66 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
/// <summary> /// <summary>
/// 导入 /// 导入
/// </summary> /// </summary>
public class PUB_SA_IMPORT_DTO public class ZGJ_PUB_SA_DETAIL_IMPORT_DTO
{ {
///// <summary>
///// 期间
///// </summary>
//public int Version { set; get; }
///// <summary>
///// 单价
///// </summary>
//public decimal Price { set; get; }
///// <summary>
///// 结算单
///// </summary>
//public string BillNum { set; get; }
/// <summary>
/// 结算日期
/// </summary>
[ImporterHeader(Name = "Pstng Date")]
public DateTime SettleDate { set; get; }
/// <summary>
/// 零件号
/// </summary>
[ImporterHeader(Name = "Material")]
public string LU { get; set; }
/// <summary>
/// 生产号
/// </summary>
[ImporterHeader(Name = "External Delivery ID")]
public string PN { get; set; }
///// <summary>
///// 组合键值(LU+PN)
///// </summary>
//public string KeyCode
//{
// get => LU + PN;
//}
///// <summary>
/// 数量
/// </summary>
[ImporterHeader(Name = "Quantity")]
public decimal Qty { get; set; }
/// <summary>
/// 结算分组号
/// </summary>
[ImporterHeader(Name = "Delivery")]
public string GroupNum { get; set; }
/////// <summary>
/////// 工厂地点
/////// </summary>
////[Display(Name = "工厂地点")]
////public string Site { get; set; }
} }
/// <summary> /// <summary>

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

@ -1,10 +1,12 @@
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using NPOI.Util;
using SettleAccount.Domain.BQ; using SettleAccount.Domain.BQ;
using Shouldly; using Shouldly;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Caching; using Volo.Abp.Caching;
@ -23,37 +25,69 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
/// </summary> /// </summary>
[AllowAnonymous] [AllowAnonymous]
[Route("api/settleaccount/[controller]/[action]")] [Route("api/settleaccount/[controller]/[action]")]
public class PUB_SA_SERVICE : SettleAccountApplicationBase<TB_RePartsRelationship> public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
{ {
/// <summary> /// <summary>
/// PUB结算仓储 /// PUB结算仓储
/// </summary> /// </summary>
private readonly INormalEfCoreRepository<PUB_SA, Guid> _repository; private readonly INormalEfCoreRepository<PUB_SA, Guid> _repository;
/// <summary>
/// PUB结算明细仓储
/// </summary>
private readonly INormalEfCoreRepository<PUB_SA_DETAIL, Guid> _pubSaDetailRepository;
/// <summary> /// <summary>
/// 构造 /// 构造
/// </summary> /// </summary>
public PUB_SA_SERVICE(INormalEfCoreRepository<PUB_SA, Guid> repository, public PUB_SA_SERVICE(INormalEfCoreRepository<PUB_SA, Guid> repository,
IDistributedCache<TB_RePartsRelationship> cache, INormalEfCoreRepository<PUB_SA_DETAIL, Guid> pubSaDetailRepository,
IDistributedCache<PUB_SA> cache,
IExcelImportAppService excelImportService, IExcelImportAppService excelImportService,
ISnowflakeIdGenerator snowflakeIdGenerator, ISnowflakeIdGenerator snowflakeIdGenerator,
ICommonManager commonManager ICommonManager commonManager
) : base(cache, excelImportService, snowflakeIdGenerator, commonManager) ) : base(cache, excelImportService, snowflakeIdGenerator, commonManager)
{ {
_repository = repository; _repository = repository;
_pubSaDetailRepository = pubSaDetailRepository;
} }
#region 直供件
#endregion
#region 导入、导出 #region 导入、导出
/// <summary> /// <summary>
/// 导入 /// 导入
/// </summary> /// </summary>
[HttpPost] [HttpPost]
public async Task<string> ImportAsync([FromForm] IFormFileCollection files) public async Task<string> ZGJImportAsync([FromForm] IFormFileCollection files)
{ {
ExportImporter _exportImporter = new ExportImporter(); ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.UploadExcelImport<PUB_SA_IMPORT_DTO>(files, _excelImportService); var result = await _exportImporter.UploadExcelImport<ZGJ_PUB_SA_DETAIL_IMPORT_DTO>(files, _excelImportService);
var _ls = ObjectMapper.Map<List<PUB_SA_IMPORT_DTO>, List<PUB_SA>>(result); var _ls = ObjectMapper.Map<List<ZGJ_PUB_SA_DETAIL_IMPORT_DTO>, List<PUB_SA_DETAIL>>(result);
await _repository.InsertManyAsync(_ls);
var billNum = GuidGenerator.Create().ToString();
var pubSa = new PUB_SA()
{
BillNum = billNum,
State = "1"
};
_ls.ForEach(s =>
{
string[] luArr = s.LU.Split(" ");
var lus = luArr.Reverse();
var result = lus.Aggregate(" ", (current, index) => current + index);
//s.LU = s.LU.Replace(" ", "").Replace(" ", " ");
s.BillNum = billNum;
s.Site = "直供件";
s.KeyCode = s.LU + s.PN;
});
//await _repository.InsertAsync(pubSa);
//await _pubSaDetailRepository.InsertManyAsync(_ls);
return ApplicationConsts.SuccessStr; return ApplicationConsts.SuccessStr;
} }

3
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/CodeSettingTables/CodeSettingAppService.cs

@ -93,6 +93,7 @@ namespace Win.Sfs.SettleAccount.Entities.CodeSettingTables
/// 按ID获取唯一实体 /// 按ID获取唯一实体
/// </summary> /// </summary>
[HttpPost] [HttpPost]
[Route("{id}")]
virtual public async Task<CodeSettingDto> GetAsync(Guid id) virtual public async Task<CodeSettingDto> GetAsync(Guid id)
{ {
var result = await _repository.GetAsync(id); var result = await _repository.GetAsync(id);
@ -193,6 +194,7 @@ namespace Win.Sfs.SettleAccount.Entities.CodeSettingTables
/// <param name="input">修改实体DTO</param> /// <param name="input">修改实体DTO</param>
/// <returns>实体DTO</returns> /// <returns>实体DTO</returns>
[HttpPost] [HttpPost]
[Route("{id}")]
virtual public async Task<CodeSettingDto> UpdateAsync(Guid id, CodeSettingUpdateDto input) virtual public async Task<CodeSettingDto> UpdateAsync(Guid id, CodeSettingUpdateDto input)
{ {
var _first = _repository.Where(p => p.Project == input.Project && p.Value == input.Value).FirstOrDefault(); var _first = _repository.Where(p => p.Project == input.Project && p.Value == input.Value).FirstOrDefault();
@ -216,6 +218,7 @@ namespace Win.Sfs.SettleAccount.Entities.CodeSettingTables
/// <param name="id">ID</param> /// <param name="id">ID</param>
/// <returns>无</returns> /// <returns>无</returns>
[HttpPost] [HttpPost]
[Route("{id}")]
virtual public async Task DeleteAsync(Guid id) virtual public async Task DeleteAsync(Guid id)
{ {
var entity = await GetFromCacheAsync(id); var entity = await GetFromCacheAsync(id);

2
code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs

@ -819,6 +819,8 @@ namespace Win.Sfs.SettleAccount
private void CreateMapPUB_SA() private void CreateMapPUB_SA()
{ {
CreateMap<PUB_SA, PUB_SA_DTO>(); CreateMap<PUB_SA, PUB_SA_DTO>();
CreateMap<ZGJ_PUB_SA_DETAIL_IMPORT_DTO, PUB_SA_DETAIL>();
} }
} }

14
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/SettleAccount.EntityFrameworkCore.csproj

@ -12,9 +12,21 @@
<OutputPath>..\..\OutPut</OutputPath> <OutputPath>..\..\OutPut</OutputPath>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<None Remove="appsettings.json" />
</ItemGroup>
<ItemGroup>
<Content Include="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="FlexLabs.EntityFrameworkCore.Upsert" Version="5.0.0" /> <PackageReference Include="FlexLabs.EntityFrameworkCore.Upsert" Version="5.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.7"> <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.8">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>

29
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/appsettings.json

@ -0,0 +1,29 @@
{
"AuthServer": {
"Authority": "http://dev.ccwin-in.com:10580",
//"Authority": "http://localhost:10130",
"ClientId": "basic-web",
"ClientSecret": "1q2w3e*"
},
"App": {
"CorsOrigins": "http://localhost:9527,http://dev.ccwin-in.com:10588,http://localhost:44307"
},
"ConnectionStrings": {
"SettleAccountService": "Server=localhost;Database=BJABP;User ID=sa;Password=aA123456!;Trusted_Connection=False;TrustServerCertificate=True",
"Default": "Server=localhost;Database=BQ_SA;User ID=sa;Password=aA123456!;Trusted_Connection=False;TrustServerCertificate=True"
},
"ElasticSearch": {
"Url": "http://localhost:9200"
},
"Redis": {
"Configuration": "127.0.0.1"
},
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"AllowedHosts": "*",
"RePassword": "111111"
}

22
code/src/SettleAccount.sln

@ -1,19 +1,11 @@
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16 # Visual Studio Version 17
VisualStudioVersion = 16.0.29728.190 VisualStudioVersion = 17.6.33717.318
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Gateways", "Gateways", "{593B8559-1521-4E54-A7DF-7F58E5F6EA86}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{61F21377-02D4-40C5-80B3-F0C2999CE6B7}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{61F21377-02D4-40C5-80B3-F0C2999CE6B7}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Modules", "Modules", "{A6179011-0C7F-440A-A559-B9C90BB0229A}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Modules", "Modules", "{A6179011-0C7F-440A-A559-B9C90BB0229A}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Applications", "Applications", "{BD0465F1-50F8-4913-8B01-7C2E44CEED27}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebAppGateway.Host", "Gateways\WebAppGateway\WebAppGateway.Host\WebAppGateway.Host.csproj", "{E2CC3E8A-924B-47AC-BDEC-C12B4BC9B7DD}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InternalGateway.Host", "Gateways\InternalGateway\InternalGateway.Host\InternalGateway.Host.csproj", "{165D6706-6E02-4506-94D6-823412C5412C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MicroServices", "MicroServices", "{1C1B27DC-DEDF-4067-9791-660302A09C66}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MicroServices", "MicroServices", "{1C1B27DC-DEDF-4067-9791-660302A09C66}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Win.Abp", "Win.Abp", "{1853A9CF-DB6D-4612-A6EA-8815E011F2C9}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Win.Abp", "Win.Abp", "{1853A9CF-DB6D-4612-A6EA-8815E011F2C9}"
@ -70,14 +62,6 @@ Global
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E2CC3E8A-924B-47AC-BDEC-C12B4BC9B7DD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E2CC3E8A-924B-47AC-BDEC-C12B4BC9B7DD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E2CC3E8A-924B-47AC-BDEC-C12B4BC9B7DD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E2CC3E8A-924B-47AC-BDEC-C12B4BC9B7DD}.Release|Any CPU.Build.0 = Release|Any CPU
{165D6706-6E02-4506-94D6-823412C5412C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{165D6706-6E02-4506-94D6-823412C5412C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{165D6706-6E02-4506-94D6-823412C5412C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{165D6706-6E02-4506-94D6-823412C5412C}.Release|Any CPU.Build.0 = Release|Any CPU
{7E3E3AEB-C7C4-495D-B963-8A3B4DB0CB3B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {7E3E3AEB-C7C4-495D-B963-8A3B4DB0CB3B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7E3E3AEB-C7C4-495D-B963-8A3B4DB0CB3B}.Debug|Any CPU.Build.0 = Debug|Any CPU {7E3E3AEB-C7C4-495D-B963-8A3B4DB0CB3B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7E3E3AEB-C7C4-495D-B963-8A3B4DB0CB3B}.Release|Any CPU.ActiveCfg = Release|Any CPU {7E3E3AEB-C7C4-495D-B963-8A3B4DB0CB3B}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -159,8 +143,6 @@ Global
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
GlobalSection(NestedProjects) = preSolution GlobalSection(NestedProjects) = preSolution
{E2CC3E8A-924B-47AC-BDEC-C12B4BC9B7DD} = {593B8559-1521-4E54-A7DF-7F58E5F6EA86}
{165D6706-6E02-4506-94D6-823412C5412C} = {593B8559-1521-4E54-A7DF-7F58E5F6EA86}
{1853A9CF-DB6D-4612-A6EA-8815E011F2C9} = {61F21377-02D4-40C5-80B3-F0C2999CE6B7} {1853A9CF-DB6D-4612-A6EA-8815E011F2C9} = {61F21377-02D4-40C5-80B3-F0C2999CE6B7}
{7E3E3AEB-C7C4-495D-B963-8A3B4DB0CB3B} = {5E5C6DAB-A70E-44A9-93C9-4A2C4AE837A7} {7E3E3AEB-C7C4-495D-B963-8A3B4DB0CB3B} = {5E5C6DAB-A70E-44A9-93C9-4A2C4AE837A7}
{9B9733F4-F13E-428E-AA4A-BA68432FE3B8} = {61F21377-02D4-40C5-80B3-F0C2999CE6B7} {9B9733F4-F13E-428E-AA4A-BA68432FE3B8} = {61F21377-02D4-40C5-80B3-F0C2999CE6B7}

7
docs/demo/src/WTA.Application/Identity/Data/IdentityDbSeed.cs

@ -176,16 +176,9 @@ public class IdentityDbSeed : IDbSeed<IdentityDbContext>
context.Set<PUB_SA>().Add(new PUB_SA { Version = "测试数据", State = "测试数据", BillNum = "1号测试数据" }); context.Set<PUB_SA>().Add(new PUB_SA { Version = "测试数据", State = "测试数据", BillNum = "1号测试数据" });
context.Set<PUB_SA>().Add(new PUB_SA { Version = "测试数据", State = "测试数据", BillNum = "2号测试数据" }); context.Set<PUB_SA>().Add(new PUB_SA { Version = "测试数据", State = "测试数据", BillNum = "2号测试数据" });
context.Set<PUB_SA>().Add(new PUB_SA { Version = "测试数据", State = "测试数据", BillNum = "3号测试数据" }); context.Set<PUB_SA>().Add(new PUB_SA { Version = "测试数据", State = "测试数据", BillNum = "3号测试数据" });
context.Set<PUB_SA>().Add(new PUB_SA { Version = "测试数据", State = "测试数据", BillNum = "一号测试数据" });
context.Set<PUB_SA>().Add(new PUB_SA { Version = "测试数据", State = "测试数据", BillNum = "二号测试数据" });
context.Set<PUB_SA>().Add(new PUB_SA { Version = "测试数据", State = "测试数据", BillNum = "三号测试数据" });
context.Set<PUB_SA_DETAIL>().Add(new PUB_SA_DETAIL { KeyCode = "测试数据", Version = "测试数据", BillNum = "1号测试数据", LU = "测试数据", PN = "测试数据", Site = "测试数据", InvGroupNum = "测试数据", SettleDate = new DateTime(), Extend1 = "测试数据", Extend2 = "测试数据", Extend3 = "测试数据", GroupNum = "测试数据" }); context.Set<PUB_SA_DETAIL>().Add(new PUB_SA_DETAIL { KeyCode = "测试数据", Version = "测试数据", BillNum = "1号测试数据", LU = "测试数据", PN = "测试数据", Site = "测试数据", InvGroupNum = "测试数据", SettleDate = new DateTime(), Extend1 = "测试数据", Extend2 = "测试数据", Extend3 = "测试数据", GroupNum = "测试数据" });
context.Set<PUB_SA_DETAIL>().Add(new PUB_SA_DETAIL { KeyCode = "测试数据", Version = "测试数据", BillNum = "2号测试数据", LU = "测试数据", PN = "测试数据", Site = "测试数据", InvGroupNum = "测试数据", SettleDate = new DateTime(), Extend1 = "测试数据", Extend2 = "测试数据", Extend3 = "测试数据", GroupNum = "测试数据" }); context.Set<PUB_SA_DETAIL>().Add(new PUB_SA_DETAIL { KeyCode = "测试数据", Version = "测试数据", BillNum = "2号测试数据", LU = "测试数据", PN = "测试数据", Site = "测试数据", InvGroupNum = "测试数据", SettleDate = new DateTime(), Extend1 = "测试数据", Extend2 = "测试数据", Extend3 = "测试数据", GroupNum = "测试数据" });
context.Set<PUB_SA_DETAIL>().Add(new PUB_SA_DETAIL { KeyCode = "测试数据", Version = "测试数据", BillNum = "3号测试数据", LU = "测试数据", PN = "测试数据", Site = "测试数据", InvGroupNum = "测试数据", SettleDate = new DateTime(), Extend1 = "测试数据", Extend2 = "测试数据", Extend3 = "测试数据", GroupNum = "测试数据" }); context.Set<PUB_SA_DETAIL>().Add(new PUB_SA_DETAIL { KeyCode = "测试数据", Version = "测试数据", BillNum = "3号测试数据", LU = "测试数据", PN = "测试数据", Site = "测试数据", InvGroupNum = "测试数据", SettleDate = new DateTime(), Extend1 = "测试数据", Extend2 = "测试数据", Extend3 = "测试数据", GroupNum = "测试数据" });
context.Set<PUB_SA_DETAIL>().Add(new PUB_SA_DETAIL { KeyCode = "测试数据", Version = "测试数据", BillNum = "一号测试数据", LU = "测试数据", PN = "测试数据", Site = "测试数据", InvGroupNum = "测试数据", SettleDate = new DateTime(), Extend1 = "测试数据", Extend2 = "测试数据", Extend3 = "测试数据", GroupNum = "测试数据" });
context.Set<PUB_SA_DETAIL>().Add(new PUB_SA_DETAIL { KeyCode = "测试数据", Version = "测试数据", BillNum = "二号测试数据", LU = "测试数据", PN = "测试数据", Site = "测试数据", InvGroupNum = "测试数据", SettleDate = new DateTime(), Extend1 = "测试数据", Extend2 = "测试数据", Extend3 = "测试数据", GroupNum = "测试数据" });
context.Set<PUB_SA_DETAIL>().Add(new PUB_SA_DETAIL { KeyCode = "测试数据", Version = "测试数据", BillNum = "三号测试数据", LU = "测试数据", PN = "测试数据", Site = "测试数据", InvGroupNum = "测试数据", SettleDate = new DateTime(), Extend1 = "测试数据", Extend2 = "测试数据", Extend3 = "测试数据", GroupNum = "测试数据" });
} }
private static void InitDictionaries(DbContext context) private static void InitDictionaries(DbContext context)

2
docs/demo/src/WTA.Application/Identity/Entities/SystemManagement/BOM.cs

@ -6,7 +6,7 @@ namespace WTA.Application.Identity.Entities.SystemManagement;
[SystemManagement] [SystemManagement]
[Display(Name = "BOM结构")] [Display(Name = "BOM结构")]
[Order(9)] [Order(11)]
public class BOM : BaseEntity public class BOM : BaseEntity
{ {
} }

2
docs/demo/src/WTA.Application/Identity/Entities/SystemManagement/CentralizedControl.cs

@ -4,7 +4,7 @@ using WTA.Shared.Domain;
namespace WTA.Application.Identity.Entities.SystemManagement; namespace WTA.Application.Identity.Entities.SystemManagement;
[Order(11)] [Order(9)]
[SystemManagement] [SystemManagement]
[Display(Name = "期间设置")] [Display(Name = "期间设置")]
public class CentralizedControl : BaseEntity public class CentralizedControl : BaseEntity

2
docs/demo/src/WTA.Application/Identity/Entities/SystemManagement/PURCHASE_PRICE.cs

@ -5,7 +5,7 @@ using WTA.Shared.Domain;
namespace WTA.Application.Identity.Entities.SystemManagement; namespace WTA.Application.Identity.Entities.SystemManagement;
[SystemManagement] [SystemManagement]
[Display(Name = "采购价格单")] [Display(Name = "采购价格单")]
[Order(14)] [Order(12)]
public class PURCHASE_PRICE : BaseEntity public class PURCHASE_PRICE : BaseEntity
{ {
} }

2
docs/demo/src/WTA.Application/Identity/Entities/SystemManagement/TB_PRICE_LIST.cs

@ -4,7 +4,7 @@ using WTA.Shared.Domain;
namespace WTA.Application.Identity.Entities.SystemManagement; namespace WTA.Application.Identity.Entities.SystemManagement;
[Order(12)] [Order(14)]
[SystemManagement] [SystemManagement]
[Display(Name = "销售价格单")] [Display(Name = "销售价格单")]
public class TB_PRICE_LIST : BaseEntity public class TB_PRICE_LIST : BaseEntity

Loading…
Cancel
Save