commit 1eaedea85d11516f3d5fae365cf5c6ddeb007a67 Author: 18923810322 <1666941798@qq.com> Date: Wed Apr 30 17:01:05 2025 +0800 添加项目文件。 diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..fe1152b --- /dev/null +++ b/.dockerignore @@ -0,0 +1,30 @@ +**/.classpath +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.project +**/.settings +**/.toolstarget +**/.vs +**/.vscode +**/*.*proj.user +**/*.dbmdl +**/*.jfm +**/azds.yaml +**/bin +**/charts +**/docker-compose* +**/Dockerfile* +**/node_modules +**/npm-debug.log +**/obj +**/secrets.dev.yaml +**/values.dev.yaml +LICENSE +README.md +!**/.gitignore +!.git/HEAD +!.git/config +!.git/packed-refs +!.git/refs/heads/** \ No newline at end of file diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bc1364c --- /dev/null +++ b/.gitignore @@ -0,0 +1,366 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Oo]ut/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd +/BarCode.Web.sln +/src/BarCode.Web.Api/BarCode.Web.Api.csproj +/src/BarCode.Web.Api/BarCode.Web.Api.csproj diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2690cf5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,40 @@ +#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging. +#ĵַ https://github.com/dotnet/dotnet-docker/ +FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base +WORKDIR /app +EXPOSE 8080 +EXPOSE 80 +EXPOSE 443 + +#װapt-get װ libc6-dev , libgdiplus ֧system.drawing ,Ĭubuntu +#RUN apt-get update -qq && apt-get -y install libgdiplus libc6-dev +#װ curl +RUN apt-get update && apt-get install -y curl + +COPY ["src/BarCode.Web.Api/wwwroot/BarCode.Web.Api.xml", "/app/BarCode.Web.Api.xml"] +COPY ["src/BarCode.Web.Api/wwwroot/BarCode.Web.Core.xml", "/app/BarCode.Web.Core.xml"] +COPY ["src/BarCode.Web.Api/wwwroot/BarCode.Web.Domain.xml", "/app/BarCode.Web.Domain.xml"] + +USER app + +#FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +ARG BUILD_CONFIGURATION=Release +WORKDIR /src +COPY ["src/BarCode.Web.Api/BarCode.Web.Api.csproj", "src/BarCode.Web.Api/"] +COPY ["src/BarCode.Web.Repositories/BarCode.Web.Repositories.csproj", "src/BarCode.Web.Repositories/"] +COPY ["src/BarCode.Web.Core/BarCode.Web.Core.csproj", "src/BarCode.Web.Core/"] +COPY ["src/BarCode.Web.Domain/BarCode.Web.Domain.csproj", "src/BarCode.Web.Domain/"] +RUN dotnet restore "./src/BarCode.Web.Api/BarCode.Web.Api.csproj" +COPY . . +WORKDIR "/src/src/BarCode.Web.Api" +RUN dotnet build "./BarCode.Web.Api.csproj" -c $BUILD_CONFIGURATION -o /app/build + +FROM build AS publish +ARG BUILD_CONFIGURATION=Release +RUN dotnet publish "./BarCode.Web.Api.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "BarCode.Web.Api.dll"] \ No newline at end of file diff --git a/src/BarCode.Web.Api/.config/dotnet-tools.json b/src/BarCode.Web.Api/.config/dotnet-tools.json new file mode 100644 index 0000000..305bdb1 --- /dev/null +++ b/src/BarCode.Web.Api/.config/dotnet-tools.json @@ -0,0 +1,12 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "dotnet-ef": { + "version": "9.0.0", + "commands": [ + "dotnet-ef" + ] + } + } +} \ No newline at end of file diff --git a/src/BarCode.Web.Api/Controllers/BoxController.cs b/src/BarCode.Web.Api/Controllers/BoxController.cs new file mode 100644 index 0000000..4ba50c6 --- /dev/null +++ b/src/BarCode.Web.Api/Controllers/BoxController.cs @@ -0,0 +1,199 @@ +using AutoMapper; +using BarCode.Web.Core.Dto; +using BarCode.Web.Core.Dto.Box; +using BarCode.Web.Core.Dto.SerialNumbers; +using BarCode.Web.Core.Internal.Results; +using BarCode.Web.Domain.Infrastructure; +using BarCode.Web.Domain.IService; +using BarCode.Web.Domain.IService.Public; +using BarCode.Web.Domain.Services; +using BarCode.Web.Domain.Values; +using BarCode.Web.Repositories; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using System.Text.RegularExpressions; + +namespace BarCode.Web.Api.Controllers +{ + /// + /// 箱子 + /// + [Route("api/[controller]")] + [ApiController] + public class BoxController : ControllerBase + { + private readonly IBoxRepositories _boxRepositories; + private readonly IMapper _mapper; + private readonly ILoginService _loginService; + private readonly IBoxService _boxService; + public BoxController(IMapper mapper, ILoginService loginService, IBoxRepositories boxRepositories, + IBoxService boxService) + { + _boxRepositories = boxRepositories; + _mapper = mapper; + _loginService = loginService; + _boxService = boxService; + } + + /// + /// 箱信息-列表 + /// + /// + /// + [HttpPost] + [Route("GetList")] + public async Task> GetPagedList([FromBody] BoxQueryRequest dto) + { + var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); + if (loginInfo == null || loginInfo.UserInfo == null) + return ResultPagedList.ReFailure(ResultCodes.Token_Invalid_Error); + + if (!string.IsNullOrEmpty(dto.BoxBeginNo) + && !Regex.Match(dto.BoxBeginNo.ToUpper().Replace("CTN", ""), "^[0-9]*$").Success) + return ResultPagedList.ReFailure(ResultCodes.BoxNO_Invalid_Error); + if (!string.IsNullOrEmpty(dto.BoxEndNo) + && !Regex.Match(dto.BoxEndNo.ToUpper().Replace("CTN", ""), "^[0-9]*$").Success) + return ResultPagedList.ReFailure(ResultCodes.BoxNO_Invalid_Error); + + var (list, count) = await _boxRepositories.GetListAsync(dto, loginInfo); + var result = ResultPagedList.ReSuccess(list, count); + return result; + } + ///// + ///// 获取详情 + ///// + ///// + ///// + //[HttpGet] + //[Route("GetInfo/{id}")] + //public async Task> GetInfo([FromRoute] int id) + //{ + // var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); + // if (loginInfo == null || loginInfo.UserInfo == null) + // return Result.ReFailure(ResultCodes.Token_Invalid_Error); + + // var response = await _repositories.GetInfo(id); + // return Result.ReSuccess(response); + //} + + /// + /// 生成箱码 + /// + /// + /// + [HttpPost] + [Route("Generate")] + public async Task Generate(GenerateBoxRequest dto) + { + var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); + if (loginInfo == null || loginInfo.UserInfo == null) + return Result.ReFailure(ResultCodes.Token_Invalid_Error); + return await _boxService.Generate(dto, loginInfo); + } + + /// + /// 装箱保存 + /// + /// + /// + [HttpPost] + [Route("Save")] + public async Task Save(SaveBoxRequest dto) + { + var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); + if (loginInfo == null || loginInfo.UserInfo == null) + return Result.ReFailure(ResultCodes.Token_Invalid_Error); + + return await _boxService.Save(dto, loginInfo); + } + /// + /// 打印 + /// + /// + /// + [HttpPost] + [Route("Print")] + public async Task Print(OperateRequest dto) + { + var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); + if (loginInfo == null || loginInfo.UserInfo == null) + return Result.ReFailure(ResultCodes.Token_Invalid_Error); + return await _boxService.Print(dto); + } + /// + /// 删除 + /// + /// + /// + [HttpPost] + [Route("Delete")] + public async Task Delete(DeleteBoxSerialNumberRequest dto) + { + var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); + if (loginInfo == null || loginInfo.UserInfo == null) + return Result.ReFailure(ResultCodes.Token_Invalid_Error); + return await _boxService.Delete(dto, loginInfo); + } + /// + /// 清空装箱信息 + /// + /// + /// + [HttpGet] + [Route("Clear")] + public async Task Clear([FromQuery] int boxId) + { + var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); + if (loginInfo == null || loginInfo.UserInfo == null) + return Result.ReFailure(ResultCodes.Token_Invalid_Error); + return await _boxService.Clear(boxId, loginInfo); + } + /// + /// 根据箱号获取箱信息 + /// + /// + /// + [HttpGet] + [Route("GetBoxByNo")] + public async Task> GetBoxByNo([FromQuery] string boxBillNo) + { + var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); + if (loginInfo == null || loginInfo.UserInfo == null) + return Result.ReFailure(ResultCodes.Token_Invalid_Error); + var entity = await _boxRepositories.GetByNo(boxBillNo); + if (entity == null) + return Result.ReFailure(ResultCodes.BoxNoDataError); + + return Result.ReSuccess(_mapper.Map(entity)); + } + /// + /// 重新装箱 + /// + /// + /// + [HttpPost] + [Route("Restart")] + public async Task Restart(OperateRequest dto) + { + var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); + if (loginInfo == null || loginInfo.UserInfo == null) + return Result.ReFailure(ResultCodes.Token_Invalid_Error); + return await _boxService.Restart(dto, loginInfo); + } + /// + /// 开始装箱 + /// + /// + /// + [HttpGet] + [Route("BeginCarton")] + public async Task BeginCarton([FromQuery] int boxId) + { + var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); + if (loginInfo == null || loginInfo.UserInfo == null) + return Result.ReFailure(ResultCodes.Token_Invalid_Error); + return await _boxService.BeginCarton(boxId, loginInfo); + } + + } +} diff --git a/src/BarCode.Web.Api/Controllers/BoxMarkController.cs b/src/BarCode.Web.Api/Controllers/BoxMarkController.cs new file mode 100644 index 0000000..44c4d10 --- /dev/null +++ b/src/BarCode.Web.Api/Controllers/BoxMarkController.cs @@ -0,0 +1,89 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using BarCode.Web.Core.Dto; +using BarCode.Web.Core.Internal.Results; +using BarCode.Web.Domain.Infrastructure; +using BarCode.Web.Domain.IService; +using BarCode.Web.Domain.IService.Public; +using BarCode.Web.Domain.Values; + +namespace BarCode.Web.Api.Controllers +{ + /// + /// 箱唛-接口 + /// + [Route("api/[controller]")] + [ApiController] + public class BoxMarkController : ControllerBase + { + + private readonly ILoginService _loginService; + private readonly IBoxMarkService _boxMarkService; + private readonly IBoxMarkRepositories _boxMarkRepositories; + private readonly IExportExcelService _exportExcelService; + public BoxMarkController( + ILoginService loginService, + IBoxMarkRepositories boxMarkRepositories, + IBoxMarkService boxMarkService, + IExportExcelService exportExcelService) + { + this._loginService = loginService; + this._boxMarkService = boxMarkService; + this._exportExcelService = exportExcelService; + this._boxMarkRepositories = boxMarkRepositories; + } + + /// + /// 箱唛--列表 + /// + /// + /// + [HttpPost] + [Route("GetList")] + public async Task> GetPagedList([FromBody] BoxMarkQueryRequest dto) + { + var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); + if (loginInfo == null || loginInfo.UserInfo == null) + return ResultPagedList.ReFailure(ResultCodes.Token_Invalid_Error); + var (list, count) = await _boxMarkService.GetPagedList(dto, loginInfo); + return ResultPagedList.ReSuccess(list, count); + } + + /// + /// 生成 + /// + /// + /// + [HttpPost] + [Route("generate")] + public async Task> GenerateAsync([FromBody] GenerateBoxMarkDto dto) + { + var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); + if (loginInfo == null || loginInfo.UserInfo == null) + return ResultPagedList.ReFailure(ResultCodes.Token_Invalid_Error); + return await _boxMarkService.Generate(dto, loginInfo); + } + + /// + /// 批量删除 + /// + /// + /// + [HttpPost] + [Route("delete")] + public async Task Delete([FromBody] OperateRequest dto) + { + var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); + if (loginInfo == null || loginInfo.UserInfo == null) + return ResultPagedList.ReFailure(ResultCodes.Token_Invalid_Error); + var isSuccess= await _boxMarkRepositories.DeleteRange(dto.Ids); + if(!isSuccess) + return Result.ReFailure(ResultCodes.DateWriteError); + return Result.ReSuccess(); + } + } +} diff --git a/src/BarCode.Web.Api/Controllers/ClientLogController.cs b/src/BarCode.Web.Api/Controllers/ClientLogController.cs new file mode 100644 index 0000000..cdd40b6 --- /dev/null +++ b/src/BarCode.Web.Api/Controllers/ClientLogController.cs @@ -0,0 +1,82 @@ +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using BarCode.Web.Core.Internal.Results; +using Microsoft.Extensions.Hosting; + +namespace BarCode.Web.Api.Controllers +{ + /// + /// 前端记录日志 + /// + [Route("api/[controller]")] + [ApiController] + public class ClientLogController : ControllerBase + { + private readonly ILogger _Logger; + public IWebHostEnvironment _webHostEnvironment { get; set; } + public ClientLogController(ILogger Logger, IWebHostEnvironment webHostEnvironment) + { + _Logger = Logger; + _webHostEnvironment = webHostEnvironment; + } + /// + /// 前端记录日志 + /// + /// + /// + [HttpGet] + [Route("Log")] + public Task Log([FromQuery] string log) + { + if (!_webHostEnvironment.IsDevelopment()) + _Logger.LogInformation($"前端日志 时间:{DateTime.Now} 内容:{log}"); + + return Task.FromResult(Result.ReSuccess()); + } + + /// + /// 前端记录日志 + /// + /// + /// + [HttpGet] + [Route("test")] + public Task Log() + { + return Task.FromResult(Result.ReSuccess()); + } + + /// + /// 前端记录日志(数组) + /// + /// + /// + [HttpPost] + [Route("Logs")] + public Task Logs(List logs) + { + if (!_webHostEnvironment.IsDevelopment()) + _Logger.LogInformation($"前端日志(数组) 时间:{DateTime.Now} 内容:{JsonConvert.SerializeObject(logs)}"); + + return Task.FromResult(Result.ReSuccess()); + } + } + /// + /// 消息数组 + /// + [Serializable] + public class LogRequest + { + /// + /// 消息内容数组 + /// + public List logs { get; set; } = new List(); + } +} diff --git a/src/BarCode.Web.Api/Controllers/FileDownManagerController.cs b/src/BarCode.Web.Api/Controllers/FileDownManagerController.cs new file mode 100644 index 0000000..b0ad382 --- /dev/null +++ b/src/BarCode.Web.Api/Controllers/FileDownManagerController.cs @@ -0,0 +1,107 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using BarCode.Web.Core; +using BarCode.Web.Core.Dto; +using BarCode.Web.Core.Internal.Results; +using BarCode.Web.Domain.Infrastructure; +using BarCode.Web.Domain.IService.Public; +using BarCode.Web.Domain.Values; +using Microsoft.AspNetCore.StaticFiles; +using NPOI.SS.Formula.Functions; +using Npoi.Mapper; + +namespace BarCode.Web.Api.Controllers +{ + /// + /// 上传下载中心 + /// + [Route("api/[controller]")] + [ApiController] + public class FileDownManagerController : ControllerBase + { + private readonly ILoginService _loginService; + private readonly IFileDownManagerRepositories _repositories; + public FileDownManagerController(ILoginService loginService, IFileDownManagerRepositories repositories) + { + _loginService = loginService; + _repositories = repositories; + } + + /// + /// 获取需要的状态列表 + /// + /// + [HttpGet] + [Route("GetStatus")] + public Task> GetStatus() + { + FileDownManagerStatusResponse response = new FileDownManagerStatusResponse(); + foreach (FileDownLoadOrderType enumv in Enum.GetValues(typeof(FileDownLoadOrderType))) + { + response.Type.Add((int)enumv, enumv.GetRemark()); + } + foreach (ExportStatus enumv in Enum.GetValues(typeof(ExportStatus))) + { + response.Status.Add((int)enumv, enumv.GetRemark()); + } + return Task.FromResult(Result.ReSuccess(response)); + } + + /// + /// 下载导出文件 列表 + /// + /// + /// + [HttpPost] + [Route("FileDownManagerQuery")] + public async Task> FileDownManagerQuery(FileDownManagerRequest dto) + { + var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); + if (loginInfo == null) + return Result.ReFailure(ResultCodes.Token_Invalid_Error); + dto.SupplierId = loginInfo.UserInfo.SupplierId; + + var result = await _repositories.GetList(dto, loginInfo); + return Result.ReSuccess(result); + } + /// + /// 模板(生成序列码) + /// + /// + [HttpGet] + [Route("TemplateExcel")] + public IActionResult TemplateExcel() + { + Mapper mapper = new Mapper(); + + //第一个参数为导出Excel名称 + //第二个参数为Excel数据来源 + //第三个参数为导出的Sheet名称 + //overwrite参数如果是要覆盖已存在的Excel或者新建Excel则为true,如果在原有Excel上追加数据则为false + //xlsx参数是用于区分导出的数据格式为xlsx还是xls + byte[] buffer = null; + using (MemoryStream stream = new MemoryStream()) + { + try + { + List list = new List(); + mapper.Put(list, "sheet1", true); + + mapper.Save(stream); + } + catch (Exception) + { + } + + buffer = stream.ToArray(); + } + // .xlsx文件对应的Mime信息 + var mime = new FileExtensionContentTypeProvider().Mappings[".xlsx"]; + return File(buffer, mime, "批量生成条码模板.xlsx"); + } + } +} diff --git a/src/BarCode.Web.Api/Controllers/HeartController.cs b/src/BarCode.Web.Api/Controllers/HeartController.cs new file mode 100644 index 0000000..66c7130 --- /dev/null +++ b/src/BarCode.Web.Api/Controllers/HeartController.cs @@ -0,0 +1,20 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace BarCode.Web.Api.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class HeartController : ControllerBase + { + [HttpGet] + public Task Heart() + { + return Task.FromResult("Success"); + } + } +} diff --git a/src/BarCode.Web.Api/Controllers/LoginController.cs b/src/BarCode.Web.Api/Controllers/LoginController.cs new file mode 100644 index 0000000..9e3b391 --- /dev/null +++ b/src/BarCode.Web.Api/Controllers/LoginController.cs @@ -0,0 +1,143 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using BarCode.Web.Core.Dto.Login; +using BarCode.Web.Core.Internal.Results; +using BarCode.Web.Domain.IService.Public; +using BarCode.Web.Domain.Values; + +namespace BarCode.Web.Api.Controllers +{ + /// + /// 登录接口 + /// + [Route("api/[controller]")] + [ApiController] + public class LoginController : ControllerBase + { + private readonly ILoginService _loginService; + private readonly ILogger _logger; + public LoginController(ILoginService loginService,ILogger logger) + { + this._logger = logger; + this._loginService = loginService; + + } + + /// + /// 登录 + /// + /// + /// + [HttpGet] + [Route("LoginIn")] + public async Task> LoginIn([FromQuery] string code) + { + //var result = await _loginService.GetUserInfoAsync(code); + var result = await _loginService.GetUserInfoByCode(code); + return result; + } + + /// + /// 登录-APP和小程序 + /// + /// + /// + [HttpPost] + [Route("LoginInPwd")] + public async Task> LoginInPwd([FromBody] LoginRequest dto) + { + var result = await _loginService.GetUserInfo(dto.UserName,dto.Password); + return result; + } + + /// + /// 退出登录 + /// + /// + [HttpPost] + [Route("LoginOut")] + public async Task LoginOut() + { + string authorization = this.HttpContext.Request.Headers["Authorization"]; + //if (string.IsNullOrEmpty(authorization)) + //{ + // return Result.ReFailure(BaseResultCodes.UnAuthorized); + //} + + //if (logininfo == null || logininfo.UserInfo == null) + // return Result.ReFailure(BaseResultCodes.UnAuthorized); + if (!string.IsNullOrEmpty(authorization)) + { + var logininfo = _loginService.GetLoginInfo(authorization); + if (logininfo != null && logininfo.UserInfo != null) + { + var dto = new LoginOutDto() + { + UcId = logininfo.UserInfo.UcId.ToString(), + SessionId = logininfo.UserInfo.SeesionId, + Token = logininfo.TokenInfo.Token, + AccessToken = logininfo.TokenInfo.PhpToken, + RefreshToken=logininfo.TokenInfo.RefreshToken, + ExpiresIn = logininfo.TokenInfo.Expired + }; + var res = await _loginService.LoginOut(dto); + } + } + return Result.ReSuccess(); + } + /// + /// PHP单点退出使用 + /// + /// + [HttpGet] + [Route("LoginOutSingle")] + public async Task LoginOutSingle() + { + this.HttpContext.Request.Cookies.TryGetValue("PHPSESSID", out string value); + if (string.IsNullOrEmpty(value)) + value = string.Empty; + if (!string.IsNullOrEmpty(value)) + await _loginService.LoginOutSingleAsync(value); + return Result.ReSuccess(); + } + + /// + /// 菜单列表 + /// + /// + [HttpGet] + [Route("Menus")] + public async Task>> GetMenuList() + { + var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); + if (loginInfo == null || loginInfo.UserInfo == null) + return Result>.ReFailure(ResultCodes.Token_Invalid_Error); + + _logger.LogInformation($"用户ID:{loginInfo.UserInfo.UcId}"); + var list = await _loginService.GetMenuList(loginInfo.UserInfo.UcId); + _logger.LogInformation($"菜单数量:{list.Count}"); + if (list.Count == 0) + { + //调用单点的退出接口 + var dto = new LoginOutDto() + { + UcId = loginInfo.UserInfo.UcId.ToString(), + SessionId = loginInfo.UserInfo.SeesionId, + Token = loginInfo.TokenInfo.Token, + AccessToken = loginInfo.TokenInfo.PhpToken, + ExpiresIn = loginInfo.TokenInfo.Expired + + }; + await _loginService.LoginOut(dto); + return Result>.ReFailure(ResultCodes.NoRoot); + } + var res = Result>.ReSuccess(list); + return res; + } + } +} diff --git a/src/BarCode.Web.Api/Controllers/MaterialController.cs b/src/BarCode.Web.Api/Controllers/MaterialController.cs new file mode 100644 index 0000000..ee7f664 --- /dev/null +++ b/src/BarCode.Web.Api/Controllers/MaterialController.cs @@ -0,0 +1,118 @@ +using AutoMapper; +using BarCode.Web.Core.Dto.Erp; +using BarCode.Web.Core.Help; +using BarCode.Web.Core.Internal.Results; +using BarCode.Web.Domain.Entitys; +using BarCode.Web.Domain.Infrastructure; +using BarCode.Web.Domain.IService.Public; +using BarCode.Web.Domain.Options; +using BarCode.Web.Domain.Services; +using BarCode.Web.Domain.Services.Public; +using BarCode.Web.Domain.Values; +using BarCode.Web.Repositories; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Caching.Memory; +using Microsoft.Extensions.Options; +using Newtonsoft.Json; + +namespace BarCode.Web.Api.Controllers +{ + /// + /// 物料 + /// + [Route("api/[controller]")] + [ApiController] + public class MaterialController : ControllerBase + { + private IMapper _mapper; + private ILogger _logger; + private IErpService _erpService; + private IMaterialsRepositories _materialsRepositories; + private ErpOptions _erpOptions; + private readonly IMemoryCache _memoryCache; + public MaterialController(IMapper mapper, ILogger logger, IErpService erpService, + IMaterialsRepositories materialsRepositories, IOptions erpOptions, IMemoryCache memoryCache) + { + _mapper = mapper; + _logger = logger; + _erpService = erpService; + _materialsRepositories = materialsRepositories; + this._erpOptions = erpOptions.Value; + this._memoryCache = memoryCache; + } + + /// + /// 刷新物料 69条码或id32进制 + /// + /// 物料编码 + /// 69 条码,id id32进制,other 名字和规格型号 + /// + [HttpGet] + [Route("Refresh/{number}/{type}")] + public async Task Refresh([FromRoute] string number, [FromRoute] string type) + { + if (string.IsNullOrEmpty(number)) + return Result.ReFailure("物料编码不能为空", 556677); + if (string.IsNullOrEmpty(type) || (!type.Equals("69") && !type.Equals("id")&& !type.Equals("other"))) + return Result.ReFailure("类型只能是69或id或other", 556677); + + List numbers = new List(); + numbers.Add(number); + + var list = await _materialsRepositories.GetEntityList(numbers); + if (list.Count() <= 0) return Result.ReFailure(ResultCodes.MateriaNoData); + + var mDtos = await _erpService.BillQueryForMaterialByNumbers(numbers); + if (!mDtos.IsSuccess) return Result.ReFailure(mDtos.Message, mDtos.Status); + if (mDtos.Data.Count() <= 0) return Result.ReFailure(ResultCodes.MateriaNoData); + + var materials = _memoryCache.Get>(_erpOptions.cache_materail_key); + + List update_list = new List(); + foreach (var m in mDtos.Data) + { + var entity = list.FirstOrDefault(f => f.MaterialNumber.Equals(m.MaterialNumber)); + if (entity == null) continue; + if (type.Equals("69")) + { + entity.BarCode = m.BarCode.Trim(); + update_list.Add(entity); + } + if (type.Equals("id")) + { + entity.IdConvertBar = m.IdConvertBar.Trim(); + update_list.Add(entity); + } + if (type.Equals("other")) + { + entity.MaterialName = m.MaterialName; + entity.Specifications = m.Specifications; + update_list.Add(entity); + } + + //修改缓存 + if (materials == null) continue; + var entity_cache = materials.FirstOrDefault(f => f.MaterialNumber.Equals(m.MaterialNumber)); + if (entity_cache == null) continue; + if (type.Equals("69")) + entity_cache.BarCode = m.BarCode.Trim(); + if (type.Equals("id")) + entity_cache.IdConvertBar = m.IdConvertBar.Trim(); + if (type.Equals("other")) + { + entity_cache.MaterialName = m.MaterialName; + entity_cache.Specifications = m.Specifications; + } + + } + //修改缓存 + if (materials != null && materials.Count() > 0) + { + _memoryCache.Set(_erpOptions.cache_materail_key, materials, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromMinutes(DateTimeUtil.GetTotalMinutesTimeSpan()))); + } + await _materialsRepositories.UpdateRange(update_list); + return Result.ReSuccess(); + } + } +} diff --git a/src/BarCode.Web.Api/Controllers/SecurityController.cs b/src/BarCode.Web.Api/Controllers/SecurityController.cs new file mode 100644 index 0000000..2218df0 --- /dev/null +++ b/src/BarCode.Web.Api/Controllers/SecurityController.cs @@ -0,0 +1,59 @@ +using BarCode.Web.Core.Dto.SecurityNumbers; +using BarCode.Web.Core.Dto.SerialNumbers; +using BarCode.Web.Core.Help; +using BarCode.Web.Core.Internal.Results; +using BarCode.Web.Domain.Infrastructure; +using BarCode.Web.Domain.Values; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; +using System.Text.Json.Serialization; +using System.Text.RegularExpressions; + +namespace BarCode.Web.Api.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class SecurityController : ControllerBase + { + public readonly ISecurityNumbersRepositories _securityNumbersRepositories; + public readonly ILogger _logger; + public SecurityController(ISecurityNumbersRepositories securityNumbersRepositories, ILogger logger) + { + _securityNumbersRepositories = securityNumbersRepositories; + _logger = logger; + } + /// + /// 获取序列号信息 + /// + /// 防伪码 + /// + [HttpGet] + [Route("Get")] + public async Task> Get([FromQuery] string security) + { + _logger.LogInformation($"请求防伪码:{security}"); + var zz = "^[0-9A-Za-z]{6,15}$"; + Regex regex = new Regex(zz); + if (!regex.IsMatch(security)) return Result.ReSuccess(new SecurityResponse()); + + var res = await _securityNumbersRepositories.GetEntity(security); + if (res == null) return Result.ReSuccess(new SecurityResponse()); + + res.Get(); + res = await _securityNumbersRepositories.Edit(res); + //为了让前端可以做语言判断 这个接口所有错误都提示500 + if (res == null) return Result.ReFailure(BaseResultCodes.UnknowError); + + var response = new SecurityResponse() + { + Security = res.SecurityNumber, + QueryCount = res.QueryCount, + IsOneQuery = res.QueryCount == 1 ? true : false, + QueryTime = res.QueryTime.DateToStringSeconds() + }; + _logger.LogInformation($"请求防伪码返回:{JsonConvert.SerializeObject(response)}"); + return Result.ReSuccess(response); + } + } +} diff --git a/src/BarCode.Web.Api/Controllers/SecurityNumberController.cs b/src/BarCode.Web.Api/Controllers/SecurityNumberController.cs new file mode 100644 index 0000000..9816bab --- /dev/null +++ b/src/BarCode.Web.Api/Controllers/SecurityNumberController.cs @@ -0,0 +1,189 @@ +using AutoMapper; +using BarCode.Web.Core.Dto.SecurityNumbers; +using BarCode.Web.Core.Dto; +using BarCode.Web.Core.Help; +using BarCode.Web.Core.Internal.Results; +using BarCode.Web.Domain.Infrastructure; +using BarCode.Web.Domain.IService.Public; +using BarCode.Web.Domain.IService; +using BarCode.Web.Domain.Options; +using BarCode.Web.Domain.Values; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Options; +using BarCode.Web.Core.Dto.SerialNumbers; +using BarCode.Web.Domain.Services; +using BarCode.Web.Core; + +namespace BarCode.Web.Api.Controllers +{ + /// + /// 防伪码 + /// + [Route("api/[controller]")] + [ApiController] + public class SecurityNumberController : ControllerBase + { + private readonly IMapper _mapper; + private readonly ILoginService _loginService; + private readonly ISecurityNumbersRepositories _securityNumbersRepositories; + private readonly ISecurityNumberService _securityNumberService; + private readonly IExportExcelService _exportExcelService; + private readonly QiniuOptions _option; + private readonly ISecurityGenerateRecordRepositories _sGenerateRecordRepositories; + public SecurityNumberController(IMapper mapper, ILoginService loginService, ISecurityNumbersRepositories SecurityNumbersRepositories, + ISecurityNumberService SecurityNumberService, IExportExcelService exportExcelService, + IOptions option, ISecurityGenerateRecordRepositories sGenerateRecordRepositories) + { + _mapper = mapper; + _loginService = loginService; + _securityNumbersRepositories = SecurityNumbersRepositories; + _securityNumberService = SecurityNumberService; + _exportExcelService = exportExcelService; + _option = option?.Value; + _sGenerateRecordRepositories = sGenerateRecordRepositories; + } + /// + /// 防伪码生成记录列表 + /// + /// + /// + [HttpPost] + [Route("GetGenerateRecordList")] + public async Task> GetGenerateRecordList([FromBody] SecurityGenerateRecordQueryRequest dto) + { + var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); + if (loginInfo == null || loginInfo.UserInfo == null) + return ResultPagedList.ReFailure(ResultCodes.Token_Invalid_Error); + + var (list, count) = await _sGenerateRecordRepositories.GetListAsync(dto, loginInfo); + var result = ResultPagedList.ReSuccess(list, count); + return result; + } + /// + /// 防伪码列表 + /// + /// + /// + [HttpPost] + [Route("GetList")] + public async Task> GetPagedList([FromBody] SecurityNumberQueryRequest dto) + { + var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); + if (loginInfo == null || loginInfo.UserInfo == null) + return ResultPagedList.ReFailure(ResultCodes.Token_Invalid_Error); + + var (list, count) = await _securityNumbersRepositories.GetListAsync(dto, loginInfo); + var result = ResultPagedList.ReSuccess(list, count); + return result; + } + /// + /// 防伪码生成记录页面-下载条码 + /// + /// + /// + [HttpPost] + [Route("ExportAll")] + public Task> ExportAll(OperateRequest dto) + { + var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); + if (loginInfo == null) + return Task.FromResult(Result.ReFailure(ResultCodes.Token_Invalid_Error)); + + var entityList = _sGenerateRecordRepositories.GetEntityList(dto.Ids).GetAwaiter().GetResult(); + if (entityList.Count < 0)return Task.FromResult(Result.ReFailure(ResultCodes.NoDateError)); + string orgCode = entityList.First().OrgCode; + //反写下载数据 + var resSuccess = this.DownLoad(new OperateSecurityNumberRequest() { GenerateRecordIds = dto.Ids, IsAll = true }).GetAwaiter().GetResult(); + if (!resSuccess.IsSuccess) Task.FromResult(Result.ReFailure(resSuccess.Message, resSuccess.Status)); + + string fileName = FileDownLoadOrderType.SecurityNumbers.GetRemark() + DateTime.Now.DateToStringSecondsNoSpace() + ".xlsx"; + string res = _option.Url + fileName; + + SecurityNumbersExportRequest request = new SecurityNumbersExportRequest(); + request.Ids = dto.Ids; + + Task.Run(async () => + { + await _exportExcelService.ExportList(request, fileName, loginInfo.UserInfo.UcId, loginInfo, FileDownLoadOrderType.SecurityNumbers, orgCode); + }); + + return Task.FromResult(Result.ReSuccess(res)); + } + /// + /// 防伪码页面-条码下载 + /// + /// + /// + [HttpPost] + [Route("Export")] + public Task> Export([FromBody] SecurityNumberQueryRequest dto) + { + var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); + if (loginInfo == null) + return Task.FromResult(Result.ReFailure(ResultCodes.Token_Invalid_Error)); + + var entity = _sGenerateRecordRepositories.GetEntity(dto.GenerateRecordId).GetAwaiter().GetResult(); + if (entity==null) return Task.FromResult(Result.ReFailure(ResultCodes.NoDateError)); + string orgCode = entity.OrgCode; + //反写下载数据 + Result resSuccess; + if (dto.SecurityNumbers.Count() > 0) + { + resSuccess = this.DownLoad(new OperateSecurityNumberRequest() + { + GenerateRecordIds = new List() { dto.GenerateRecordId }, + IsAll = false, + SecurityNumbers = dto.SecurityNumbers + }).GetAwaiter().GetResult(); + } + else + { + resSuccess = this.DownLoad(new OperateSecurityNumberRequest() + { + GenerateRecordIds = new List() { dto.GenerateRecordId }, + IsAll = true + }).GetAwaiter().GetResult(); + } + if (!resSuccess.IsSuccess) return Task.FromResult(Result.ReFailure(resSuccess.Message, resSuccess.Status)); + + string fileName = FileDownLoadOrderType.SecurityNumberInfo.GetRemark() + DateTime.Now.DateToStringSecondsNoSpace() + ".xlsx"; + string res = _option.Url + fileName; + + Task.Run(async () => + { + await _exportExcelService.ExportList(dto, fileName, loginInfo.UserInfo.UcId, loginInfo, FileDownLoadOrderType.SecurityNumberInfo, orgCode); + }); + + return Task.FromResult(Result.ReSuccess(res)); + } + /// + /// 下载(一般后端内部调用) + /// + /// + /// + [HttpPost] + [Route("DownLoad")] + public async Task DownLoad(OperateSecurityNumberRequest dto) + { + var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); + if (loginInfo == null || loginInfo.UserInfo == null) + return Result.ReFailure(ResultCodes.Token_Invalid_Error); + return await _securityNumberService.DownLoad(dto); + } + /// + /// 生成序列号 + /// + /// + /// + [HttpPost] + [Route("Generate")] + public async Task Generate(GenerateSecurityNumberRequest dto) + { + var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); + if (loginInfo == null || loginInfo.UserInfo == null) + return Result.ReFailure(ResultCodes.Token_Invalid_Error); + return await _securityNumberService.Generate(dto, loginInfo); + } + } +} diff --git a/src/BarCode.Web.Api/Controllers/SerialNumberController.cs b/src/BarCode.Web.Api/Controllers/SerialNumberController.cs new file mode 100644 index 0000000..e003ac8 --- /dev/null +++ b/src/BarCode.Web.Api/Controllers/SerialNumberController.cs @@ -0,0 +1,309 @@ +using AutoMapper; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using BarCode.Web.Core.Internal.Results; +using BarCode.Web.Domain.Infrastructure; +using BarCode.Web.Domain.IService.Public; +using BarCode.Web.Domain.Values; +using BarCode.Web.Core.Dto.SerialNumbers; +using BarCode.Web.Repositories; +using BarCode.Web.Core.Dto; +using BarCode.Web.Domain.IService; +using BarCode.Web.Core.Help; +using BarCode.Web.Core; +using BarCode.Web.Domain.Services; +using BarCode.Web.Domain.Options; +using Microsoft.Extensions.Options; +using NPOI.SS.Formula.Functions; +using System.Diagnostics.Eventing.Reader; +using BarCode.Web.Core.Dto.Box; +using System.Text.RegularExpressions; + +namespace BarCode.Web.Api.Controllers +{ + /// + /// 序列号 + /// + [Route("api/[controller]")] + [ApiController] + public class SerialNumberController : ControllerBase + { + private readonly IMapper _mapper; + private readonly ILoginService _loginService; + private readonly ISerialNumbersRepositories _serialNumbersRepositories; + private readonly ISerialNumberService _serialNumberService; + private readonly IExportExcelService _exportExcelService; + private readonly QiniuOptions _option; + private readonly ISGenerateRecordRepositories _sGenerateRecordRepositories; + public SerialNumberController(IMapper mapper, ILoginService loginService, ISerialNumbersRepositories serialNumbersRepositories, + ISerialNumberService serialNumberService, IExportExcelService exportExcelService, + IOptions option, ISGenerateRecordRepositories sGenerateRecordRepositories) + { + _mapper = mapper; + _loginService = loginService; + _serialNumbersRepositories = serialNumbersRepositories; + _serialNumberService = serialNumberService; + _exportExcelService = exportExcelService; + _option = option?.Value; + _sGenerateRecordRepositories = sGenerateRecordRepositories; + } + /// + /// 序列码生成记录列表 + /// + /// + /// + [HttpPost] + [Route("GetGenerateRecordList")] + public async Task> GetGenerateRecordList([FromBody] SGenerateRecordQueryRequest dto) + { + var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); + if (loginInfo == null || loginInfo.UserInfo == null) + return ResultPagedList.ReFailure(ResultCodes.Token_Invalid_Error); + + var (list, count) = await _sGenerateRecordRepositories.GetListAsync(dto, loginInfo); + var result = ResultPagedList.ReSuccess(list, count); + return result; + } + /// + /// 序列码列表 + /// + /// + /// + [HttpPost] + [Route("GetList")] + public async Task> GetPagedList([FromBody] SerialNumberQueryRequest dto) + { + var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); + if (loginInfo == null || loginInfo.UserInfo == null) + return ResultPagedList.ReFailure(ResultCodes.Token_Invalid_Error); + + if (!string.IsNullOrEmpty(dto.NumberCodeBegin) + && (!Regex.Match(dto.NumberCodeBegin, "^[0-9]*$").Success || dto.NumberCodeBegin.Length < 12)) + return ResultPagedList.ReFailure(ResultCodes.NumberCode_Invalid_Error); + if (!string.IsNullOrEmpty(dto.NumberCodeEnd) + && (!Regex.Match(dto.NumberCodeEnd, "^[0-9]*$").Success || dto.NumberCodeEnd.Length < 12)) + return ResultPagedList.ReFailure(ResultCodes.NumberCode_Invalid_Error); + + var (list, count) = await _serialNumbersRepositories.GetListAsync(dto, loginInfo); + var result = ResultPagedList.ReSuccess(list, count); + return result; + } + /// + /// 条码生成记录页面-下载条码 + /// + /// + /// + [HttpPost] + [Route("ExportAll")] + public Task> ExportAll(OperateRequest dto) + { + var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); + if (loginInfo == null) + return Task.FromResult(Result.ReFailure(ResultCodes.Token_Invalid_Error)); + + var entityList = _sGenerateRecordRepositories.GetEntityList(dto.Ids).GetAwaiter().GetResult(); + if (entityList.Count < 0) return Task.FromResult(Result.ReFailure(ResultCodes.NoDateError)); + string orgCode = entityList.First().OrgCode; + + //反写下载数据 + var resSuccess = this.DownLoad(new OperateSerialNumberRequest() { GenerateRecordIds = dto.Ids, IsAll = true }).GetAwaiter().GetResult(); + if (!resSuccess.IsSuccess) Task.FromResult(Result.ReFailure(resSuccess.Message, resSuccess.Status)); + + string fileName = FileDownLoadOrderType.SerialNumbers.GetRemark() + DateTime.Now.DateToStringSecondsNoSpace() + ".xlsx"; + string res = _option.Url + fileName; + + SerialNumbersExportRequest request = new SerialNumbersExportRequest(); + request.Ids = dto.Ids; + + Task.Run(async () => + { + await _exportExcelService.ExportList(request, fileName, loginInfo.UserInfo.UcId, loginInfo, FileDownLoadOrderType.SerialNumbers, orgCode); + }); + + return Task.FromResult(Result.ReSuccess(res)); + } + /// + /// 序列码页面-条码下载 + /// + /// + /// + [HttpPost] + [Route("Export")] + public Task> Export([FromBody] SerialNumberQueryRequest dto) + { + var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); + if (loginInfo == null) + return Task.FromResult(Result.ReFailure(ResultCodes.Token_Invalid_Error)); + + var entity = _sGenerateRecordRepositories.GetEntity(dto.GenerateRecordId).GetAwaiter().GetResult(); + if (entity == null) return Task.FromResult(Result.ReFailure(ResultCodes.NoDateError)); + string orgCode = entity.OrgCode; + + //反写下载数据 + Result resSuccess; + if (dto.SerialNumbers.Count() > 0) + { + resSuccess = this.DownLoad(new OperateSerialNumberRequest() + { + GenerateRecordIds = new List() { dto.GenerateRecordId }, + IsAll = false, + SerialNumbers = dto.SerialNumbers + }).GetAwaiter().GetResult(); + } + else + { + resSuccess = this.DownLoad(new OperateSerialNumberRequest() + { + GenerateRecordIds = new List() { dto.GenerateRecordId }, + IsAll = true + }).GetAwaiter().GetResult(); + } + if (!resSuccess.IsSuccess) return Task.FromResult(Result.ReFailure(resSuccess.Message, resSuccess.Status)); + + string fileName = FileDownLoadOrderType.SerialNumberInfo.GetRemark() + DateTime.Now.DateToStringSecondsNoSpace() + ".xlsx"; + string res = _option.Url + fileName; + + Task.Run(async () => + { + await _exportExcelService.ExportList(dto, fileName, loginInfo.UserInfo.UcId, loginInfo, FileDownLoadOrderType.SerialNumberInfo, orgCode); + }); + + return Task.FromResult(Result.ReSuccess(res)); + } + /// + /// 生成序列号 + /// + /// + /// + [HttpPost] + [Route("Generate")] + public async Task Generate(GenerateSerialNumberRequest dto) + { + var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); + if (loginInfo == null || loginInfo.UserInfo == null) + return Result.ReFailure(ResultCodes.Token_Invalid_Error); + return await _serialNumberService.Generate(dto, loginInfo); + } + + /// + /// 打印 + /// + /// + /// + [HttpPost] + [Route("Print")] + public async Task Print(OperateSerialNumberRequest dto) + { + var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); + if (loginInfo == null || loginInfo.UserInfo == null) + return Result.ReFailure(ResultCodes.Token_Invalid_Error); + return await _serialNumberService.Print(dto); + } + + /// + /// 下载(一般后端内部调用) + /// + /// + /// + [HttpPost] + [Route("DownLoad")] + public async Task DownLoad(OperateSerialNumberRequest dto) + { + var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); + if (loginInfo == null || loginInfo.UserInfo == null) + return Result.ReFailure(ResultCodes.Token_Invalid_Error); + return await _serialNumberService.DownLoad(dto); + } + + + /// + /// 获取序列号信息 + /// + /// 箱Id + /// + [HttpPost] + [Route("GetByBoxId")] + public async Task> GetByBoxId(SerialNumberByBoxIdQueryRequest dto) + { + var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); + if (loginInfo == null || loginInfo.UserInfo == null) + return ResultPagedList.ReFailure(ResultCodes.Token_Invalid_Error); + if (dto.BoxId == 0) + return ResultPagedList.ReFailure(ResultCodes.NoDateError); + + var (list, count) = await _serialNumbersRepositories.GetEntityListByBoxId(dto); + var result = ResultPagedList.ReSuccess(list, count); + return result; + } + + + ///// + ///// 获取序列号信息 + ///// + ///// 序列号 + ///// 组织或供应商编码 + ///// + //[HttpGet] + //[Route("Get")] + //public async Task> Get([FromQuery] string serialNumber, [FromQuery] string orgCode) + //{ + // var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); + // if (loginInfo == null || loginInfo.UserInfo == null) + // return ResultList.ReFailure(ResultCodes.Token_Invalid_Error); + // if (string.IsNullOrEmpty(orgCode)) + // return ResultList.ReFailure(ResultCodes.NoOrgError); + + // var res = await _serialNumbersRepositories.GetEntityList(serialNumber, orgCode, loginInfo); + // // var res = await _serialNumbersRepositories.GetEntityList(serialNumber, orgCode, loginInfo); + // if (res == null) return ResultList.ReFailure(ResultCodes.SerialNumberNoData); + + // // return ResultList.ReSuccess(res); + // return ResultList.ReSuccess(res.ToList()); + //} + + + /// + /// 获取序列号信息 + /// + /// 序列号 + /// 组织或供应商编码 + /// + [HttpGet] + [Route("Get")] + public async Task> Get([FromQuery] string serialNumber, [FromQuery] string orgCode) + { + var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); + if (loginInfo == null || loginInfo.UserInfo == null) + return Result.ReFailure(ResultCodes.Token_Invalid_Error); + if (string.IsNullOrEmpty(orgCode)) + return Result.ReFailure(ResultCodes.NoOrgError); + + var res = await _serialNumbersRepositories.GetEntity(serialNumber, orgCode, loginInfo); + // var res = await _serialNumbersRepositories.GetEntityList(serialNumber, orgCode, loginInfo); + if (res == null) return Result.ReFailure(ResultCodes.SerialNumberNoData); + + // return ResultList.ReSuccess(res); + return Result.ReSuccess(res); + } + + /// + /// 修改序列码物料 + /// + /// + /// + [HttpPost] + [Route("UpdateMaterial")] + public async Task UpdateMaterial(UpdateMaterialRequest dto) + { + var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); + if (loginInfo == null || loginInfo.UserInfo == null) + return Result.ReFailure(ResultCodes.Token_Invalid_Error); + return await _serialNumberService.UpdateMaterial(dto); + } + + } +} diff --git a/src/BarCode.Web.Api/Controllers/SysConfigController.cs b/src/BarCode.Web.Api/Controllers/SysConfigController.cs new file mode 100644 index 0000000..9423ddb --- /dev/null +++ b/src/BarCode.Web.Api/Controllers/SysConfigController.cs @@ -0,0 +1,180 @@ +using AutoMapper; +using BarCode.Web.Core.Dto.Erp; +using BarCode.Web.Core.Dto.Erp.Org; +using BarCode.Web.Core.Dto.Erp.Supplier; +using BarCode.Web.Core.Dto.Login; +using BarCode.Web.Core.Dto.SingleData; +using BarCode.Web.Core.Internal.Results; +using BarCode.Web.Domain.Infrastructure; +using BarCode.Web.Domain.IService.Public; +using BarCode.Web.Domain.Options; +using BarCode.Web.Domain.Values; +using BarCode.Web.Domain.Values.Single; +using BarCode.Web.Repositories; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Caching.Memory; +using Microsoft.Extensions.Options; +using NPOI.POIFS.FileSystem; +using System.ComponentModel.Design; + +namespace BarCode.Web.Api.Controllers +{ + /// + /// 系统配置 + /// + [Route("api/[controller]")] + [ApiController] + public class SysConfigController : ControllerBase + { + private readonly ILoginService _loginService; + private readonly IBasicsRepositories _basicsRepositories; + private readonly IErpService _erpService; + private readonly ISingleDataService _singleDataService; + private readonly IMapper _mapper; + private readonly IErpBasicDataExtendService _erpBasicDataExtendService; + private readonly ILogger _logger; + private ErpOptions _erpOptions; + private readonly IMemoryCache _memoryCache; + + public SysConfigController(ILoginService loginService, IBasicsRepositories basicsRepositories, IOptions erpOptions, IErpService erpService, ISingleDataService singleDataService, IMemoryCache memoryCache, + IMapper mapper, IErpBasicDataExtendService erpBasicDataExtendService, + ILogger logger) + { + this._erpOptions = erpOptions?.Value; + this._memoryCache = memoryCache; + _loginService = loginService; + _basicsRepositories = basicsRepositories; + _erpService = erpService; + _singleDataService = singleDataService; + _mapper = mapper; + _erpBasicDataExtendService = erpBasicDataExtendService; + _logger = logger; + } + /// + /// 获取物料;通过规格型号 + /// + /// + /// + [HttpGet] + [Route("GetMaterialList")] + public async Task> GetMaterialList([FromQuery] string speci) + { + var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); + if (loginInfo == null || loginInfo.UserInfo == null) + return ResultList.ReFailure(ResultCodes.Token_Invalid_Error); + + var materials = _memoryCache.Get>(_erpOptions.cache_materail_key); + if (materials == null) + { + var res = await _erpService.BillQueryForMaterial(); + if (res.IsSuccess) + materials = res.Data.ToList(); + } + if (materials == null) return ResultList.ReFailure(ResultCodes.MateriaNoData); + //没有物料Id 32进制的也过滤掉 + var result = materials.Where(x => x.Specifications.Contains(speci) + && !string.IsNullOrEmpty(x.IdConvertBar.Trim())).Take(30).ToList(); + return ResultList.ReSuccess(result); + } + /// + /// 获取供应商-erp基础数据 + /// 使用code做键 + /// + /// 供应商名字 + /// 组织编码 + /// + [HttpGet] + [Route("GetSupplierOrOrg")] + public async Task> GetSupplierOrOrg([FromQuery] string? name, [FromQuery] string orgCode) + { + var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); + if (loginInfo == null) + return ResultList.ReFailure(ResultCodes.Token_Invalid_Error); + + var result = await _singleDataService.GetSingleDataNoCache, NameRequest, SysConfigAction>( + new NameRequest(name, loginInfo.UserInfo.CompanyId), SysConfigAction.GetSupplierByNameAndCompany, SingleControllerType.SysConfig); + if (!result.IsSuccess) + return ResultList.ReFailure(result.Message, result.Status); + + List suppliers = result.Data.ToList(); + //suppliers = suppliers.Where(w => w.ErpOrgCode.Equals(orgCode)).ToList(); + if (!string.IsNullOrEmpty(name)) + suppliers = suppliers.Where(w => w.Name.Contains(name)).ToList(); + List pullList = new List(); + foreach (var c in suppliers) + { + pullList.Add(new PullDownStrResponse() + { + Id = "s_" + c.Id.ToString(), + Name = c.Name, + Code = "s_" + c.Code + }); + } + + //var org_result = await _erpService.BillQueryForOrg(); + //List orgs = org_result.Data.ToList(); + //if (!string.IsNullOrEmpty(name)) + // orgs = orgs.Where(w => w.Name.Contains(name)).ToList(); + //foreach (var c in orgs) + //{ + // pullList.Add(new PullDownStrResponse() + // { + // Id = "o_" + c.Id.ToString(), + // Name = c.Name, + // Code = "o_" + c.Number + // }); + //} + + return ResultList.ReSuccess(pullList); + } + /// + /// 获取组织-erp基础数据 + /// 使用 code做键 + /// + /// + [HttpGet] + [Route("GetOrg")] + public async Task> GetOrg([FromQuery] string? name) + { + var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); + if (loginInfo == null) + return ResultList.ReFailure(ResultCodes.Token_Invalid_Error); + + List pullList = new List(); + + if (loginInfo.UserInfo.Identity == 2) + { + pullList.Add(new PullDownStrResponse() + { + Id = loginInfo.UserInfo.SupplierId.ToString(), + Name = loginInfo.UserInfo.SupplierName, + Code = "s_" + loginInfo.UserInfo.SupplierCode, + IsDefault = true + }); ; + return ResultList.ReSuccess(pullList); + } + var result = await _singleDataService.GetSingleDataNoCache, UserRequest, SysConfigAction>( + new UserRequest(loginInfo.UserInfo.UcId), SysConfigAction.GetOrgByUser, SingleControllerType.SysConfig); + if (!result.IsSuccess) + return ResultList.ReFailure(result.Message, result.Status); + + List orgs = result.Data.ToList(); + if (!string.IsNullOrEmpty(name)) + orgs = orgs.Where(w => w.Name.Contains(name)).ToList(); + foreach (var c in orgs) + { + pullList.Add(new PullDownStrResponse() + { + Id = c.Id.ToString(), + Name = c.Name, + Code = "o_" + c.ErpOrgCode + }); + } + //默认显示第一个 + pullList.First().IsDefault = true; + + return ResultList.ReSuccess(pullList); + } + } +} diff --git a/src/BarCode.Web.Api/Controllers/TestController.cs b/src/BarCode.Web.Api/Controllers/TestController.cs new file mode 100644 index 0000000..e42223d --- /dev/null +++ b/src/BarCode.Web.Api/Controllers/TestController.cs @@ -0,0 +1,508 @@ +using AutoMapper; +using AutoMapper.Internal.Mappers; +using BarCode.Web.Core.Dto.Box; +using BarCode.Web.Core.Dto.Erp.Org; +using BarCode.Web.Core.Dto.SerialNumbers; +using BarCode.Web.Core.Help; +using BarCode.Web.Core.Internal.Results; +using BarCode.Web.Domain.Entitys; +using BarCode.Web.Domain.Infrastructure; +using BarCode.Web.Domain.IService; +using BarCode.Web.Domain.IService.Public; +using BarCode.Web.Domain.Services; +using BarCode.Web.Domain.Services.Public; +using BarCode.Web.Domain.Values; +using BarCode.Web.Repositories; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore.Storage; +using Newtonsoft.Json; +using NPOI.SS.Formula.Functions; +using StackExchange.Redis; +using System.ComponentModel.Design; +using System.Diagnostics.Eventing.Reader; +using System.Json; +using System.Runtime.InteropServices.JavaScript; +using System.Text.Json.Nodes; +using System.Text.RegularExpressions; + +namespace BarCode.Web.Api.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class TestController : ControllerBase + { + private readonly ILoginService _loginService; + private readonly IFileDownManagerRepositories _repositories; + private readonly IMaterialService _materialService; + private readonly ISerialNumberService _serialNumberService; + private readonly IBoxRepositories _boxRepositories; + private readonly IMapper _mapper; + private readonly ISecurityGenerateRecordRepositories _securityGenerateRecordRepositories; + private IBasicsRepositories _transactionRepositories; + private readonly IBoxService _boxService; + private readonly IErpService _erpService; + private readonly ISGenerateRecordRepositories _sGenerateRecordRepositories; + private readonly ISerialNumbersRepositories _serialNumbersRepositories; + private readonly ISecurityNumbersRepositories _securityNumbersRepositories; + public TestController(ILoginService loginService, IFileDownManagerRepositories repositories, IMaterialService materialService, + ISerialNumberService serialNumberService, IBoxRepositories boxRepositories, IMapper mapper, + ISecurityGenerateRecordRepositories securityGenerateRecordRepositories, IBasicsRepositories transactionRepositories, + IBoxService boxService, IErpService erpService, ISGenerateRecordRepositories sGenerateRecordRepositories, + ISerialNumbersRepositories serialNumbersRepositories, ISecurityNumbersRepositories securityNumbersRepositories) + { + _loginService = loginService; + _repositories = repositories; + _materialService = materialService; + _serialNumberService = serialNumberService; + _boxRepositories = boxRepositories; + _mapper = mapper; + _securityGenerateRecordRepositories = securityGenerateRecordRepositories; + _transactionRepositories = transactionRepositories; + _boxService = boxService; + _erpService = erpService; + _sGenerateRecordRepositories = sGenerateRecordRepositories; + _serialNumbersRepositories = serialNumbersRepositories; + _securityNumbersRepositories = securityNumbersRepositories; + } + [HttpGet] + [Route("Get")] + public async Task Get() + { + //await GetFSer(); + + //Dictionary dic = new Dictionary(); + //dic.Add("ABCD", "1111"); + //dic.Add("ABCE", "2222"); + //dic.Add("ABCF", "3333"); + //dic.Add("BCDD", "4444"); + //var v = from d in dic where d.Value.Equals("2222") select d; + + //var b = v.Select(s => s.Key).ToList(); + + //await _materialService.SyncBar(); + + //await GetSer(); + + //await GetSer(); + //GetBox(); + //await GetBox(); + //string msg = "o_sdf"; + //string s = msg.Substring(0, 2); + //string s2 = msg.Substring(2, msg.Length-2); + + //var supplier_result = await _erpService.BillQueryForSupplier(); + + //DateTime begin = DateTime.Now.AddDays(-1); + //begin = begin.AddHours(-1); + //WmsBoxRequest request = new WmsBoxRequest(begin, DateTime.Now); + //var b = await _boxService.GetCartonListAsync(request); + + // List ids = new List(); + // ids.Add(1);ids.Add(2); + // var bList = await _boxRepositories.GetEntityList(ids); + // foreach(var b in bList) + // { + // //var d= b.Details.FirstOrDefault(f=>f.MaterialNumber=="1"); + // // d.Qty = 2; + // if (b.Id == 1) + // { + // var d = b.Details.FirstOrDefault(f => f.MaterialNumber == "1"); + // d.Qty = 10; + // b.Details.Add(new BoxDetails() + // { + // MaterialNumber = "3", + // Qty = 3 + // }); + // }else + // { + // var d= b.Details.FirstOrDefault(f=>f.MaterialNumber=="2"); + // b.Details.Remove(d); + // } + // } + //var s= await _boxRepositories.EditEntityList(bList); + + + //提交事务 + // var isSuccess = _transactionRepositories.CommitTransaction(true, _transaction); + //var b=await _boxRepositories.Get(1); + + + + //var c=_mapper.Map(b); + //string exclude = "WXYZ"; + //int? FLength = 9; + //for (int i = 1; i < 100; i++) + //{ + // var bc = Radix.ConvertRadix36((ulong)i, exclude.ToCharArray()).PadLeft(FLength ?? 0, '0'); + // Console.WriteLine($"防伪码{i} : {bc}"); + //} + //var b = await _boxRepositories.Get(1); + //GenerateSerialNumberRequest r = new GenerateSerialNumberRequest(); + //r.OrgCode = "101"; + //r.Details = new List(); + ////r.Details.Add(new GenerateSerialNumberInfoRequest() + ////{ + //// MaterialId = 260845, + //// MaterialNumber = "AS-005-000-002", + //// Number = 10 + ////}); + //r.Details.Add(new GenerateSerialNumberInfoRequest() + //{ + // IdConvertBar = "", + // MaterialNumber = "G01-12-005834", + // Number = 3 + //}); + //await _serialNumberService.Generate(r, null); + + // await _materialService.SyncNewMaterials(); + //var s= await _repositories.GetList(new Core.Dto.FileDownManagerRequest(), 0); + return Result.ReSuccess(); + } + + private async Task GetBox() + { + string[] arr = System.IO.File.ReadAllLines("E:\\1\\x.txt"); + var sList = GetS(); + //var sList = new List(); + List boxs = new List(); + int i = 0; + foreach (string str in arr) + { + i++; + Console.WriteLine("操作条数:" + i); + var strarr = str.Split('\t'); + if (strarr[3] == "NULL") + { + Box box = new Box() + { + CompanyId = 1, + Id = Convert.ToInt32(strarr[2].Replace("CTN", "")), + BoxBillNo = strarr[2], + OrgCode = strarr[0].Replace("-", ""), + SupplierCode = strarr[1].Replace("-", ""), + CreateTime = strarr[6] != "-" ? Convert.ToDateTime(strarr[6]) : DateTime.Now + }; + if (string.IsNullOrEmpty(box.OrgCode) && string.IsNullOrEmpty(box.SupplierCode)) + box.OrgCode = "101"; + boxs.Add(box); + } + else + { + var box = boxs.FirstOrDefault(w => w.BoxBillNo.Equals(strarr[2])); + if (box == null) + { + box = new Box() + { + CompanyId = 1, + Id = Convert.ToInt32(strarr[2].Replace("CTN", "")), + BoxBillNo = strarr[2], + OrgCode = strarr[0].Replace("-", ""), + SupplierCode = strarr[1].Replace("-", ""), + CreateTime = strarr[6] != "-" ? Convert.ToDateTime(strarr[6]) : DateTime.Now, + CartonBeginTime = strarr[7] != "-" ? Convert.ToDateTime(strarr[7]) : null, + CartonEndTime = strarr[8] != "-" ? Convert.ToDateTime(strarr[8]) : null, + Status = strarr[8] != "-" ? BoxStatus.Complete : BoxStatus.NoComplete, + PrintNumber = Convert.ToInt32(strarr[10]) + }; + if (string.IsNullOrEmpty(box.OrgCode) && string.IsNullOrEmpty(box.SupplierCode)) + box.OrgCode = "101"; + + var sers = sList.Where(w => w.BoxId == box.Id && w.MaterialNumber == strarr[3]).Select(s => s.SerialNumber).ToList(); + + box.Details.Add(new BoxDetails() + { + MaterialNumber = strarr[3], + Qty = Convert.ToInt32(strarr[4]), + SerialNumbers = sers + }); + boxs.Add(box); + } + else + { + var sers = sList.Where(w => w.BoxId == box.Id && w.MaterialNumber == strarr[3]).Select(s => s.SerialNumber).ToList(); + + box.Details.Add(new BoxDetails() + { + MaterialNumber = strarr[3], + Qty = Convert.ToInt32(strarr[4]), + SerialNumbers = sers + }); + } + } + } + var lis = boxs.GroupBy(g => new { g.OrgCode, g.SupplierCode }).Select(s => s.Key).ToList(); + + var c = boxs.Where(w => w.CreateTime > DateTime.Now.AddHours(-1)).Count(); + var c1 = boxs.Where(w => w.Status == BoxStatus.Complete).Count(); + var c2 = boxs.Where(w => w.Status == BoxStatus.NoComplete).Count(); + + var res = await _boxRepositories.AddRange(boxs); + } + + private List GetS() + { + List serialNumbers = new List(); + + string[] arr_t = System.IO.File.ReadAllLines("E:\\1\\t.txt"); + long number = 200000000; + foreach (var str in arr_t) + { + var strarr = str.Split('\t'); + try + { + number = number - 1; + var s = new SerialNumbers(); + + s.Id = number; + s.SerialNumber = strarr[1]; + s.OrgCode = strarr[2].Replace("-", ""); + s.SupplierCode = strarr[3].Replace("-", ""); + s.MaterialNumber = strarr[5]; + if (string.IsNullOrEmpty(strarr[6]) || strarr[6] == "-") + s.BoxId = 0; + else + s.BoxId = Convert.ToInt32(strarr[6].ToUpper().Replace("CTN", "")); + if (string.IsNullOrEmpty(strarr[6]) || strarr[6] == "-") + s.IsUse = false; + else + s.IsUse = true; + if (!string.IsNullOrEmpty(strarr[7]) && strarr[7] != "-") + s.CreateTime = Convert.ToDateTime(strarr[7]); + if (!string.IsNullOrEmpty(strarr[8]) && strarr[8] != "-") + s.CompleteCartonTime = Convert.ToDateTime(strarr[8]); + s.NumberCode = ""; + + if (string.IsNullOrEmpty(s.OrgCode) && string.IsNullOrEmpty(s.SupplierCode)) + s.OrgCode = "101"; + serialNumbers.Add(s); + } + catch (Exception ex) + { + Console.WriteLine("数据处理错误:" + str); + } + } + return serialNumbers; + //int couont_1 = serialNumbers.Where(w => w.OrgCode == "" && w.SupplierCode == "").Count(); + //int couont_2 = serialNumbers.GroupBy(g =>new { g.MaterialNumber ,g.OrgCode,g.SupplierCode}).Count(); + + //var lis= serialNumbers.GroupBy(g => new { g.OrgCode, g.SupplierCode }).Select(s=>s.Key).ToList(); + } + + private List GetE() + { + List serialNumbers = new List(); + + string[] arr_t = System.IO.File.ReadAllLines("E:\\1\\e.txt"); + long number = 199000000; + foreach (var str in arr_t) + { + var strarr = str.Split('\t'); + try + { + number = number - 1; + var s = new SerialNumbers(); + + s.Id = number; + s.SerialNumber = strarr[5]; + s.OrgCode = "101"; + s.SupplierCode = ""; + s.MaterialNumber = strarr[0]; + s.BoxId = 0; + s.IsUse = false; + s.CreateTime = Convert.ToDateTime("2023-09-06 00:00:05"); + s.NumberCode = ""; + serialNumbers.Add(s); + } + catch (Exception ex) + { + Console.WriteLine("数据处理错误:" + str); + } + } + return serialNumbers; + //int couont_1 = serialNumbers.Where(w => w.OrgCode == "" && w.SupplierCode == "").Count(); + //int couont_2 = serialNumbers.GroupBy(g =>new { g.MaterialNumber ,g.OrgCode,g.SupplierCode}).Count(); + + //var lis= serialNumbers.GroupBy(g => new { g.OrgCode, g.SupplierCode }).Select(s=>s.Key).ToList(); + } + + + private async Task GetSer() + { + IDbContextTransaction _transaction = _transactionRepositories.GetTransaction(); + + Result res_Rollback = Result.ReSuccess(); + bool isSuccess = true; + + // var sList = GetS(); + var sList = GetE(); + var mList = sList.GroupBy(g => new { g.MaterialNumber, g.OrgCode, g.SupplierCode }).Select(s => s.Key).ToList(); + int numberid = 2620; + List records = new List(); + int bid = 0; + foreach (var m in mList) + { + bid++; + Console.WriteLine($"处理生成计划数据{bid}"); + + var scountList = sList.Where(w => w.MaterialNumber == m.MaterialNumber && w.OrgCode == m.OrgCode && w.SupplierCode == m.SupplierCode).ToList(); + var scount = scountList.Count(); + SerialNumberGenerateRecord record = new SerialNumberGenerateRecord() + { + Id = numberid, + MaterialNumber = m.MaterialNumber, + OrgCode = m.OrgCode, + SupplierCode = m.SupplierCode, + CompanyId = 1, + IsGenerateComplete = true, + Number = scount, + GenerateCompleteTime = Convert.ToDateTime("2023-09-06 00:00:05"), + CreateTime = Convert.ToDateTime("2023-09-06 00:00:05") + }; + records.Add(record); + scountList.ForEach(f => f.GenerateRecordId = numberid); + numberid++; + } + var cs = sList.Where(w => w.GenerateRecordId == 0).Count(); + try + { + if (res_Rollback.IsSuccess) + { + var res = await _sGenerateRecordRepositories.AddRange(records, false); + if (!res) res_Rollback = Result.ReFailure(ResultCodes.DateWriteError); + } + if (res_Rollback.IsSuccess) + { + for (int i = 1; i <= 7; i++) + { + Console.WriteLine($"正在处理第{i}页数据"); + var sis = sList.Skip((i - 1) * 100000).Take(100000).ToList(); + if (sis.Count() <= 0) break; + var res = await _serialNumbersRepositories.AddRange(sis, false); + if (!res) + { + res_Rollback = Result.ReFailure(ResultCodes.DateWriteError); + break; + } + } + } + } + catch (Exception ex) + { + + throw ex; + } + + //提交事务An error occurred while saving the entity changes. See the inner exception for details.” + + isSuccess = _transactionRepositories.CommitTransaction(res_Rollback.IsSuccess ? false : true, _transaction); + } + + + + private List GetFE() + { + List serialNumbers = new List(); + + string[] arr_t = System.IO.File.ReadAllLines("E:\\1\\b6.txt"); + + foreach (var str in arr_t) + { + var strarr = str.Split('\t'); + try + { + var s = new SecurityNumbers(); + + s.SecurityNumber = strarr[3]; + s.OrgCode = "101"; + s.SupplierCode = ""; + s.MaterialNumber = strarr[0]; + s.CreateTime = Convert.ToDateTime("2024-06-13 12:10:00"); + serialNumbers.Add(s); + } + catch (Exception ex) + { + Console.WriteLine("数据处理错误:" + str); + } + } + return serialNumbers; + //int couont_1 = serialNumbers.Where(w => w.OrgCode == "" && w.SupplierCode == "").Count(); + //int couont_2 = serialNumbers.GroupBy(g =>new { g.MaterialNumber ,g.OrgCode,g.SupplierCode}).Count(); + + //var lis= serialNumbers.GroupBy(g => new { g.OrgCode, g.SupplierCode }).Select(s=>s.Key).ToList(); + } + + + private async Task GetFSer() + { + IDbContextTransaction _transaction = _transactionRepositories.GetTransaction(); + + Result res_Rollback = Result.ReSuccess(); + bool isSuccess = true; + + // var sList = GetS(); + var sList = GetFE(); + var mList = sList.GroupBy(g => new { g.MaterialNumber }).Select(s => s.Key).ToList(); + int numberid = 30872924; + List records = new List(); + int bid = 0; + foreach (var m in mList) + { + bid++; + Console.WriteLine($"处理生成计划数据{bid}"); + + var scountList = sList.Where(w => w.MaterialNumber == m.MaterialNumber).ToList(); + var scount = scountList.Count(); + SecurityNumberGenerateRecord record = new SecurityNumberGenerateRecord() + { + Id = numberid, + LotNumber = "", + MaterialNumber = m.MaterialNumber, + OrgCode = "101", + SupplierCode = "", + CompanyId = 1, + IsGenerateComplete = true, + Number = scount, + GenerateCompleteTime = Convert.ToDateTime("2024-06-13 12:15:00"), + CreateTime = Convert.ToDateTime("2024-06-13 12:10:00") + }; + records.Add(record); + scountList.ForEach(f => f.GenerateRecordId = numberid); + numberid++; + } + var cs = sList.Where(w => w.GenerateRecordId == 0).Count(); + try + { + if (res_Rollback.IsSuccess) + { + var res = await _securityGenerateRecordRepositories.AddRange(records, false); + if (!res) res_Rollback = Result.ReFailure(ResultCodes.DateWriteError); + } + if (res_Rollback.IsSuccess) + { + for (int i = 1; i <= 7; i++) + { + Console.WriteLine($"正在处理第{i}页数据"); + var sis = sList.Skip((i - 1) * 100000).Take(100000).ToList(); + if (sis.Count() <= 0) break; + var res = await _securityNumbersRepositories.AddRange(sis, false); + if (!res) + { + res_Rollback = Result.ReFailure(ResultCodes.DateWriteError); + break; + } + } + } + } + catch (Exception ex) + { + + throw ex; + } + + //提交事务An error occurred while saving the entity changes. See the inner exception for details.” + + isSuccess = _transactionRepositories.CommitTransaction(res_Rollback.IsSuccess ? false : true, _transaction); + } + } +} diff --git a/src/BarCode.Web.Api/Controllers/WmsBoxController.cs b/src/BarCode.Web.Api/Controllers/WmsBoxController.cs new file mode 100644 index 0000000..0e2c118 --- /dev/null +++ b/src/BarCode.Web.Api/Controllers/WmsBoxController.cs @@ -0,0 +1,150 @@ +using AutoMapper; +using BarCode.Web.Domain.Infrastructure; +using BarCode.Web.Domain.IService.Public; +using BarCode.Web.Domain.IService; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using BarCode.Web.Core.Dto.Box; +using BarCode.Web.Core.Internal.Results; +using BarCode.Web.Domain.Values; +using System.Text.RegularExpressions; +using NPOI.SS.Formula.Functions; +using System.Collections.Generic; +using Newtonsoft.Json; +using BarCode.Web.Core.Dto.SerialNumbers; +using BarCode.Web.Domain.Services.Public; +using BarCode.Web.Domain.Values.Single; +using System.ComponentModel.Design; + +namespace BarCode.Web.Api.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class WmsBoxController : ControllerBase + { + private readonly IBoxRepositories _boxRepositories; + private readonly IMapper _mapper; + private readonly ILoginService _loginService; + private readonly IBoxService _boxService; + private readonly ILogger _logger; + private readonly ISerialNumbersRepositories _serialNumbersRepositories; + private readonly ISingleDataService _singleDataService; + public WmsBoxController(IMapper mapper, ILoginService loginService, IBoxRepositories boxRepositories, + IBoxService boxService, ILogger logger, + ISerialNumbersRepositories serialNumbersRepositories, ISingleDataService singleDataService) + { + _boxRepositories = boxRepositories; + _mapper = mapper; + _loginService = loginService; + _boxService = boxService; + _logger = logger; + _serialNumbersRepositories = serialNumbersRepositories; + _singleDataService = singleDataService; + } + + /// + /// Wms获取箱信息-列表 + /// + /// + /// + [HttpPost] + [Route("GetList")] + public async Task GetList(WmsBoxRequest dto) + { + _logger.LogInformation($"请求消息:{JsonConvert.SerializeObject(dto)}"); + List list = new List(); + int count = 0; + try + { + (list, count) = await _boxService.GetCartonListAsync(dto); + } + catch (Exception ex) + { + _logger.LogError($"wms系统获取箱信息异常:{ex.Message}"); + return new OpsReponse() + { + succeeded = false + }; + } + OpsInfo info = new OpsInfo() + { + date = JsonConvert.SerializeObject(list) + }; + OpsReponse reponse = new OpsReponse() + { + succeeded = true, + data = info + }; + return reponse; + } + /// + /// Wms获取序列号信息 + /// + /// + /// + [HttpPost] + [Route("GetSerialNumber")] + public async Task> GetSerialNumber(SerialNumbersWmsRequest dto) + { + _logger.LogInformation($"wms获取序列码:{JsonConvert.SerializeObject(dto)}"); + + var entity = await _serialNumbersRepositories.GetEntityWms(dto.SerialNumber); + if (entity == null) return Result.ReFailure(ResultCodes.SerialNumberNoData); + if (entity.BoxId > 0) + return Result.ReFailure(ResultCodes.SerialNumberBindBox); + if (entity.IsUse == true) + return Result.ReFailure(ResultCodes.SerialNumberIsUse); + var response = new SerialNumbersWmsResponse() + { + SerialNumber = entity.SerialNumber.Equals(dto.SerialNumber) ? entity.SerialNumber : entity.NumberCode, + MaterialNumber = entity.MaterialNumber, + CreateTime = entity.CreateTime, + Creator = _singleDataService.GetSingleData(SingleAction.Users, 1, entity.CreatorId) + }; + //把查询到的序列码修改成使用 + entity.WmsGet(dto.SerialNumber); + var list = new List(); + list.Add(entity); + var res = await _serialNumbersRepositories.EditEntityList(list); + if (!res) return Result.ReFailure(ResultCodes.DateWriteError); + + _logger.LogInformation($"wms获取序列码返回序列码信息:{JsonConvert.SerializeObject(response)}"); + + return Result.ReSuccess(response); + } + + /// + /// 获取序列号信息 + /// + /// 序列号 + /// + [HttpGet] + [Route("Get/{serialNumber}")] + public async Task> Get([FromRoute] string serialNumber) + { + if (string.IsNullOrEmpty(serialNumber)) + return Result.ReFailure(ResultCodes.SerialNumbersNoData); + + var serial = await _serialNumbersRepositories.GetExternal(serialNumber); + if (serial == null) return Result.ReFailure(ResultCodes.SerialNumbersNoData); + return Result.ReSuccess(serial); + } + } + + public class OpsInfo + { + public int code { get; set; } + public string message { get; set; } + public string date { get; set; } + public string token { get; set; } + } + public class OpsReponse + { + public int statusCode { get; set; } + public bool succeeded { get; set; } + public string errors { get; set; } + public string extras { get; set; } + + public OpsInfo data { get; set; } + } +} diff --git a/src/BarCode.Web.Api/CustomResultFilter .cs b/src/BarCode.Web.Api/CustomResultFilter .cs new file mode 100644 index 0000000..a4f711c --- /dev/null +++ b/src/BarCode.Web.Api/CustomResultFilter .cs @@ -0,0 +1,40 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Filters; +using BarCode.Web.Core.Internal.Results; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace BarCode.Web.Api +{ + /// + /// 错误拦截 + /// + public class CustomResultFilter : ActionFilterAttribute + { + public override void OnResultExecuting(ResultExecutingContext context) + { + if (!context.ModelState.IsValid) + { + var result = new Result(); + + foreach (var item in context.ModelState.Values) + { + foreach (var error in item.Errors) + { + result.Message += error.ErrorMessage + ","; + result.Status = 4204004; + } + } + result.Message = result.Message.TrimEnd(','); + context.Result = new JsonResult(result); + } + } + + public override void OnActionExecuting(ActionExecutingContext context) + { + } + + } +} diff --git a/src/BarCode.Web.Api/Program.cs b/src/BarCode.Web.Api/Program.cs new file mode 100644 index 0000000..43bda42 --- /dev/null +++ b/src/BarCode.Web.Api/Program.cs @@ -0,0 +1,60 @@ +using BarCode.Web.Api; +using BarCode.Web.Domain.Options; +using BarCode.Web.Repositories.DependencyInjection; +using Microsoft.AspNetCore.Hosting; +using Microsoft.EntityFrameworkCore; +using Microsoft.OpenApi.Models; +using Swashbuckle.AspNetCore.SwaggerUI; +using System.Configuration; +using System.IdentityModel.Tokens.Jwt; + +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. +JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear(); +var option = builder.Configuration.GetSection("AppOptions").Get(); +var option_soa = builder.Configuration.GetSection("SoaOptions").Get(); + +var isDevelopment = builder.Configuration.GetSection("IsDevelopment").Get(); +var serverVersion = new MySqlServerVersion(new Version(8, 0, 18)); +//ݿע +builder.Services.AddApp(builder.Configuration, isDevelopment, builder => +{ + builder.AddDbContext( + opt => { opt.UseMySql(option.DBConnectionString, serverVersion); }); +}); + + +builder.Services.AddControllers(options => +{ + options.Filters.Add(); +}); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +// Swaggerм +if (isDevelopment) +{ + app.UseSwagger(); + // SwaggerUI + app.UseSwaggerUI(c => + { + c.SwaggerEndpoint($"/swagger/v1/swagger.json", "BarCode-Api"); + c.RoutePrefix = string.Empty; + c.DocExpansion(DocExpansion.None); + }); +} + +app.UseHttpsRedirection(); +app.UseStaticFiles(); +app.UseCors("AllowAllOrigin"); +//ͳһ쳣м +app.UseMiddleware(); +app.UseMiddleware(); + +//app.UseAuthorization(); + +app.MapControllers(); + +app.Run(); diff --git a/src/BarCode.Web.Api/Properties/launchSettings.json b/src/BarCode.Web.Api/Properties/launchSettings.json new file mode 100644 index 0000000..703b688 --- /dev/null +++ b/src/BarCode.Web.Api/Properties/launchSettings.json @@ -0,0 +1,50 @@ +{ + "profiles": { + "http": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "weatherforecast", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "dotnetRunMessages": true, + "applicationUrl": "http://localhost:5050" + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "weatherforecast", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "Container (Dockerfile)": { + "commandName": "Docker", + "launchBrowser": true, + "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/weatherforecast", + "environmentVariables": { + "ASPNETCORE_HTTP_PORTS": "8080" + }, + "publishAllPorts": true + }, + "WSL": { + "commandName": "WSL2", + "launchBrowser": true, + "launchUrl": "http://localhost:5050/weatherforecast", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development", + "ASPNETCORE_URLS": "http://localhost:5050" + }, + "distributionName": "" + } + }, + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:56505", + "sslPort": 0 + } + } +} \ No newline at end of file diff --git a/src/BarCode.Web.Api/appsettings.Development.json b/src/BarCode.Web.Api/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/src/BarCode.Web.Api/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/src/BarCode.Web.Api/appsettings.json b/src/BarCode.Web.Api/appsettings.json new file mode 100644 index 0000000..0a82c14 --- /dev/null +++ b/src/BarCode.Web.Api/appsettings.json @@ -0,0 +1,100 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*", //允许所有主机 + "IsDevelopment": true, //是否是开发模式 + "AllowedCores": "localhost,http://localhost:8080,http://192.168.1.188:8080",//跨域 + "AppOptions": { + "DBConnectionString": "Server=rm-wz9215skklas0287pwo.mysql.rds.aliyuncs.com; Database=test_barcode_db;User Id=orico_erp;password=Orico2023;port=3306;CharSet=gb2312;Connect Timeout=150;", //数据库连接地址 + "RedisConnectionString": "47.106.232.90:6379,password=orico.2020,DefaultDatabase=7", //redis连接地址 + "RedisIpRateLimitingConnectionString": "47.110.156.96:16379,password=123456,DefaultDatabase=3", //redis连接地址 + "SingleBaseUrl": "http://127.0.0.1:8066/api", //单点服务连接地址 + "DBType": "Mysql", //数据库类型 + "CompanyId": 1, //公司Id + "AllowCache": false, //允许缓存 + "RedisDirectory": "Test" //redis标记 + }, + "SoaOptions": { + "ModuleID": 30,//系统在单点系统的标记 + "AdminUser": [ 1 ],//管理员用户 + "Url_V3": "https://dev.uc.v3.f2b211.com", //正式http://uc.v3.f2b211.com //单点系统的连接地址v3版 + "Url": "http://dev.uc.f2b211.com",//单点系统的连接地址(老版 应该没用了) + "AppId": "100829382855098368",//系统Id + "AppSecret": "d0ebed53e67ec9b0be4e23918bb11792",//系统授权 + "PublicKey": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs7b9r5qLgy4R/caQi2ZwfCULhOOZsfyBwlhqL0Y/nyBI/bFwc0+iIVHp/gq78PYXAUOplQC5YnaLMHsAV4y3pfGPiA7jD5ZmnoEJq1MLIDBCbm7H8JaBdW4b48w7afccTgnkqFQP3vs7JS8VSTkOEO32lyX6LYjP6o32juUsDu4VKZH922BHvaNC0ewt1dOT4v6XHiGPOyJs3dW86yqhCWRDRGZjUPMZDlZfQx1qF3thMc4DObgKWYVS5RWsKvDg5DwbQznUuhneCABHpqZ0ICtkq187K29dHmk8KmCNtsHM8+zwP+j1GU9/zVT4XVw+oGJcO6II0ZTWkA/ESSUTmQIDAQAB",//公钥 + "PrivateKey": "MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQCztv2vmouDLhH9xpCLZnB8JQuE45mx/IHCWGovRj+fIEj9sXBzT6IhUen+Crvw9hcBQ6mVALlidoswewBXjLel8Y+IDuMPlmaegQmrUwsgMEJubsfwloF1bhvjzDtp9xxOCeSoVA/e+zslLxVJOQ4Q7faXJfotiM/qjfaO5SwO7hUpkf3bYEe9o0LR7C3V05Pi/pceIY87Imzd1bzrKqEJZENEZmNQ8xkOVl9DHWoXe2ExzgM5uApZhVLlFawq8ODkPBtDOdS6Gd4IAEempnQgK2SrXzsrb10eaTwqYI22wczz7PA/6PUZT3/NVPhdXD6gYlw7ogjRlNaQD8RJJROZAgMBAAECggEABeEWq4gCyGfZbtPwJp9TTrxnhBFuFcSM+i6qSqGhszL7MFF9vEf+pdhoL0dqnpduaTwtcBJ1/iKiqxNbD4Iq/+LHL0xNYVUqRkUya8hrtMHfan11TQmfcpgHkYw85VqQMn1gXaFiY4kUhkLkD2EudJ9UUd2MMbEoHCRIzKPyrQpO3We/4iwYFh96DW+iSzxRuqjtWE4+rnWaQECPzeOu7TMaktnccqw+dPM49EXPmtGCCqfSwLAAYEewL0q4dcaLgFL4qugABsTM7NQaS8AgE5so2RErcpeGSIy0s1aNgSPmdhJ8Msc+AMVc6xYpkylYYmmSNMKVnnQgVhAJsIrmAQKBgQDSFh/V52LffsYV69ePtgMnNlp+fGeYb1zqSAREKJlPjEB24BTPbbUhPQSrdi9ZFa0W93lEPTPyokWx8Rj/1GnHd5k9QPkPzIejO3ljuCtEXBn0Y+4S24T1gMEgGpiMgOQdmTI1xQ2btifvLFsu+63TDPeYiXJclTjFMtGGHMHw1QKBgQDa/aQmxLV+5/2hzf+ijsklJ4w3DTzzXl1OTdcyQia2oxs6fJ/9YEs0zzVLvcs3JA+evuJtuzteXmexUEv8hH9OGMJFbSiJ2ePwGNJ1JKPN4zRAA2FVtrmVdS4rVwjb/kuVU+4KFxpM98R/YZAnymhD9obepD23kxOdhVFgff0ZtQKBgQCqwBSr9F6mLBGvq3oOce7qJgEzIMXKXWj1egcNprnEr8eNVt9TIGXBWCi9e1dMXpPKQOWtEtlv8XgYAk9BT1GSL6C66l4D+0aa4zHsXLm92+W0fqv3Y7gTGczd3P/z4qaFcAghL8G5tzmJ6VFLRH+pM7bhoYTzvszfakhlamYu6QKBgQCYeoMRe2XkNyQixYx5Y3IqrJ60tkL6MXpGS2zLUcQi5u7OinfbtHCpFJ3HXx9gBXvazI5cWUG9M35/t6kw6hC6EAM01Ayl71EGnEHtztU/RjPbXn8nb1NI/Y5oHvHMPAPktcvIus1VSi9HgmcdTZHLwJun6jQO3hmKVImU5iSVAQKBgQC2xZ9KkzAui1YSadtD6jNtBzdXgEQ0K2MziRBlVslFfxmlJ/0X9r4lIw4RJJmsCS6To9n1h0DGK9uveVwE+oGPLD95ISala+OYj9ewiBnZwbkDD201q0Ui2ji4PCZa462ZNKJw/G8vQ5oc/zu2EBER/85Y5h+RtJfFs3b5TKtNxA=="//私钥 + }, + "ErpOptions": { + "EndpointAddress": "http://erp.orico.com.cn/k3cloud/ERPGW.asmx",//金蝶连接地址 + "UserName": "mes",//金蝶账户名 + "Password": "A1B2C3Dh.",//金蝶密码 + "ErpId": "ce20210909"//金蝶Id + }, + "WmsOptions": { + "Url": "https://api.wms.test.f2b211.com/" //WMS系统的连接地址 + }, + "Qiniu": { + "AccessKey": "dOsTum4a5qvhPTBbZRPX0pIOU7PZWRX7htKjztms",//七牛云账号 + "SecretKey": "KFxsGbnErkALFfeGdMa8QWTdodJbamMX0iznLe-q",//七牛云授权 + "Bucket": "orico-wms-test", //正式 orico-wms //七牛云文件下的文件名 + "Url": "https://wmstestfile.f2b211.com/" //测试 https://wmstestfile.f2b211.com/ 正式 https://wmsfile.f2b211.com/ //访问七牛云文件的链接地址 + }, //定时任务配置项 + "QuartzJobOptions": { + //存储类型:键和值 + "JobStoreTypeKey": "quartz.jobStore.type", + "JobStoreTypeValue": "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz", + + //数据库驱动类型-这里是mysql:键和值 + "JobStoreDriverDelegateTypeKey": "quartz.jobStore.driverDelegateType", + "JobStoreDriverDelegateTypeValue": "Quartz.Impl.AdoJobStore.MySQLDelegate, Quartz", + + //数据库表名前缀:键和值 + "JobStoreTablePrefixKey": "quartz.jobStore.tablePrefix", + "JobStoreTablePrefixValue": "QRTZ_", + + //数据源的名称:键和值 + "JobStoreDataSourceKey": "quartz.jobStore.dataSource", + "JobStoreDataSourceValue": "myDS", + + //连接字符串:键和值 + "JobStoreConnectionStringKey": "quartz.dataSource.myDS.connectionString", + "JobStoreConnectionStringValue": "Server=rm-wz9215skklas0287pwo.mysql.rds.aliyuncs.com; Database=test_barcode_db;User Id=orico_erp;password=Orico2023;port=3306;CharSet=gb2312;Connect Timeout=150;", + + //mysql提供器:键和值 + "JobStoreProviderKey": "quartz.dataSource.myDS.provider", + "JobStoreProviderValue": "MySql", + + //几点开始执行 + "JobStartHour": [ 15, 11, 1, 0, 0, 10 ], + //几分钟开始执行 + "JobStartMinute": [ 30, 39, 30, 20, 5, 5 ], + + //执行Cron表达式:可以是几小时or几分钟or几秒钟or几天or几周; + "JobStartExpre": "0 0 * * * ?", + "JobStartExpreAmount": "0 50 23 * * ?", + "JobStartExpreSend": "0 0 12,16,20 * * ?", + "JobStartExpreMaterial": "0 30 23 * * ?", + "JobStartExpreCenerateData": "0 1 0 * * ?", //凌晨0点1分执行 + + //a.是否启用集群:键和值 + "JobStoreClusteredKey": "quartz.jobStore.clustered", + "JobStoreClusteredValue": true, + + //b.集群中的每个节点都必须有一个唯一的 instanceId + // 通过将“AUTO”设置为该属性的值来完成 + //备注:a属性和b属性配套使用;如果不开启集群这两个属性去掉 + "JobStoreInstanceIdKey": "quartz.scheduler.instanceId", + "JobStoreInstanceIdValue": "AUTO", + + //以下可以自定义配置 + "QuartzJobKey": "OpsJob", + "QuartzJobValue": "OpsJobGroup", + "QuartzJobDescription": "OpsJob", + "QuartzTriggerIdentity": "OpsTrigger", + "QuartzTriggerDescription": "OpsJobTrigger" + } +} diff --git a/src/BarCode.Web.Api/wwwroot/BarCode.Web.Api.xml b/src/BarCode.Web.Api/wwwroot/BarCode.Web.Api.xml new file mode 100644 index 0000000..7dcd7a8 --- /dev/null +++ b/src/BarCode.Web.Api/wwwroot/BarCode.Web.Api.xml @@ -0,0 +1,396 @@ + + + + BarCode.Web.Api + + + + + 箱子 + + + + + 箱信息-列表 + + + + + + + 生成箱码 + + + + + + + 装箱保存 + + + + + + + 打印 + + + + + + + 删除 + + + + + + + 清空装箱信息 + + + + + + + 根据箱号获取箱信息 + + + + + + + 重新装箱 + + + + + + + 开始装箱 + + + + + + + 箱唛-接口 + + + + + 箱唛--列表 + + + + + + + 生成 + + + + + + + 批量删除 + + + + + + + 前端记录日志 + + + + + 前端记录日志 + + + + + + + 前端记录日志 + + + + + + + 前端记录日志(数组) + + + + + + + 消息数组 + + + + + 消息内容数组 + + + + + 上传下载中心 + + + + + 获取需要的状态列表 + + + + + + 下载导出文件 列表 + + + + + + + 模板(生成序列码) + + + + + + 登录接口 + + + + + 登录 + + + + + + + 登录-APP和小程序 + + + + + + + 退出登录 + + + + + + PHP单点退出使用 + + + + + + 菜单列表 + + + + + + 物料 + + + + + 刷新物料 69条码或id32进制 + + 物料编码 + 69 条码,id id32进制,other 名字和规格型号 + + + + + 获取序列号信息 + + 防伪码 + + + + + 防伪码 + + + + + 防伪码生成记录列表 + + + + + + + 防伪码列表 + + + + + + + 防伪码生成记录页面-下载条码 + + + + + + + 防伪码页面-条码下载 + + + + + + + 下载(一般后端内部调用) + + + + + + + 生成序列号 + + + + + + + 序列号 + + + + + 序列码生成记录列表 + + + + + + + 序列码列表 + + + + + + + 条码生成记录页面-下载条码 + + + + + + + 序列码页面-条码下载 + + + + + + + 生成序列号 + + + + + + + 打印 + + + + + + + 下载(一般后端内部调用) + + + + + + + 获取序列号信息 + + 箱Id + + + + + 获取序列号信息 + + 序列号 + 组织或供应商编码 + + + + + 修改序列码物料 + + + + + + + 系统配置 + + + + + 获取物料;通过规格型号 + + + + + + + 获取供应商-erp基础数据 + 使用code做键 + + 供应商名字 + 组织编码 + + + + + 获取组织-erp基础数据 + 使用 code做键 + + + + + + Wms获取箱信息-列表 + + + + + + + Wms获取序列号信息 + + + + + + + 获取序列号信息 + + 序列号 + + + + + 错误拦截 + + + + diff --git a/src/BarCode.Web.Api/wwwroot/BarCode.Web.Core.xml b/src/BarCode.Web.Api/wwwroot/BarCode.Web.Core.xml new file mode 100644 index 0000000..788cabf --- /dev/null +++ b/src/BarCode.Web.Api/wwwroot/BarCode.Web.Core.xml @@ -0,0 +1,4526 @@ + + + + BarCode.Web.Core + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 请求对象 + + + + + 组织Code + + + + + 订单编号集合字符串 + + + + + 物料三件套搜索 + + + + + 开始的箱唛编号 + + + + + 结束的箱唛编号 + + + + + 操作人 + + + + + 生成开始时间 + + + + + 生成结束时间 + + + + + 列表响应对象 + + + + + 唯一ID + + + + + 明细编号ID + + + + + 箱唛编号 + + + + + 订单编号 + + + + + 物料规格型号 + + + + + 物料编码 + + + + + 物料名称 + + + + + 69条码 + + + + + 装箱数量 + + + + + 装箱净重 + + + + + 装箱毛重 + + + + + 尾箱数量 + + + + + 尾箱净重 + + + + + 尾箱毛重 + + + + + 备注 + + + + + 操作人 + + + + + 创建时间(生成时间) + + + + + 是否是尾箱 + + + + + 装箱总数 + + + + + 产品数量 + + + + + 排序 + + + + + 流水号(开始) + + + + + 流水号(结束) + + + + + 生成箱唛dto + + + + + 组织Code + + + + + + 物料 + + + + + 产品数量 + + + + + 装箱数量 + + + + + 装箱净重 + + + + + 装箱毛重 + + + + + 尾箱数量 + + + + + 尾箱净重 + + + + + 尾箱毛重 + + + + + 备注 + + + + + 流水号(开始) + + + + + 流水号(结束) + + + + + 箱明细信息 + + + + + ID + + + + + 物料编码 + + + + + 数量(装箱数量) + + + + + 序列号 + + + + + 箱列表返回信息 + + + + + ID + + + + + 明细Id(可能为0) + + + + + 箱编号 + + + + + 供应商或组织 + + + + + 物料规格型号 + + + + + 物料编码 + + + + + 物料名称 + + + + + 物料条码 + + + + + 序列号 + + + + + 数量(装箱数量) + + + + + 箱状态 + + + + + 装箱开始时间 + + + + + 装箱结束时间(完成装箱时间) + + + + + 装箱人 + + + + + 生成人 + + + + + 创建时间 + + + + + 箱号打印次数 + + + + + 箱信息列表 + + + + + 组织Code + + + + + 箱号(开始) + + + + + 箱号(结束) + + + + + 箱状态 + + + + + 创建时间 + + + + + 创建时间 + + + + + 装箱完成时间 + + + + + 装箱完成时间 + + + + + 物料编码/名称/型号规格 + + + + + 序列号 + + + + + 箱号打印状态 打印 true 未打印false + + + + + 供应商或组织 + + + + + 生成人 + + + + + 箱信息 + + + + + ID + + + + + 箱编号 + + + + + 供应商Code + + + + + 组织Code + + + + + 箱状态 + + + + + 装箱开始时间 + + + + + 装箱结束时间(完成装箱时间) + + + + + 完成装箱用户 + + + + + 箱子创建用户 + + + + + 创建时间 + + + + + 箱号打印次数 + + + + + 最新打印时间 + + + + + 明细 + + + + + 删除箱和序列码绑定 + + + + + 箱Id + + + + + 物料编码 + + + + + 序列号 + + + + + 生成箱码 + + + + + 组织Code + + + + + 生成数量 + + + + + 箱信息明细 + + + + + 物料编码 + + + + + 序列号 + + + + + 保存箱信息(装箱保存,完成装箱) + + + + + 箱Id + + + + + 是否完成装箱(保存 false 完成装箱 true) + + + + + 明细信息 + + + + + 老ops箱信息请求 + + + + + + + + + + + + + + + + + 开始时间 + + + + + 结束时间 + + + + + 箱号 + + + + + 页码 + + + + + 每页条数 + + + + + 老ops箱信息 + + + + + 对应老OPS的箱ID + + + + + 箱编号(老OPS生成的箱号) + + + + + 供应商Id + + + + + 组织Id + + + + + 完成装箱时间 + + + + + 完成装箱用户 + + + + + 箱子创建用户 + + + + + 创建时间(对应老OPS的创建时间) + + + + + 明细 + + + + + 序列号 + + + + + 序列号生成时间 + + + + + 序列号生成用户 + + + + + 物料编码 + + + + + 数量(装箱数量) + + + + + 序列号集 + + + + + 所有枚举信息 + + + + + 出库单类型 + + + + + 移库单类型 + + + + + 盘点结果类型 + + + + + 入库单类型 + + + + + 入库状态 + + + + + 类型:1为入库回退下架,2为出库回退上架 + + + + + 类型:1为入库,2为出库 + + + + + 单据类型 + + + + + 非采购上架方式 + + + + + 下载导出订单类型 + + + + + 下载导出状态 + + + + + 出入库方式:按箱或者按产品 + + + + + 出库状态 + + + + + 同步金蝶状态 + + + + + 客户 + + + + + ID + + + + + 编码 + + + + + 名称 + + + + + ERP:单据查询-dto + + + + + 令牌 + + + + + 参数 + + + + + 参数(保存提交审核formId在外层) + + + + + ERP:单据查询-参数-dto + + + + + 业务对象表单Id(必录) + + + + + 需查询的字段key集合,字符串类型,格式:"key1,key2,..."(必录) 注(查询单据体内码,需加单据体Key和下划线,如:FEntryKey_FEntryId) + + + + + 过滤条件,数组类型,如:[{"Left":"(","FieldName":"Field1","Compare":"=","Value":"111","Right":")","Logic":"AND"},{"Left":"(","FieldName":"Field2","Compare":"=","Value":"222","Right":")","Logic":""}] + + + + + 排序字段,字符串类型(非必录) + + + + + 返回总行数,整型(非必录) + + + + + 开始行索引,整型(非必录) + + + + + 最大行数,整型,不能超过10000(非必录) + + + + + 表单所在的子系统内码,字符串类型(非必录) + + + + + ERP:入库单-统一响应对象 + + + + + 单据编号 + + + + + 组织 + + + + + erp的明细ID + + + + + 组织编码 + + + + + 供应商 + + + + + 物料编码 + + + + + 仓库ID + + + + + 仓库code + + + + + 数量 + + + + + 出厂价 + + + + + 已交数量(对应金蝶的已交数量-对应物料),目前只有采购订单有 + + + + + 明细备注 + + + + + 创建时间 + + + + + 单据类型 + + + + + 销售订单 + + + + + 客户编码 + + + + + 物料编码 + + + + + 组织编码 + + + + + 仓库 + + + + + 子仓库(跟金蝶交互字段) + + + + + 数量 + + + + + 编码 + + + + + 编码 + + + + + 盘点子仓库 + + + + + GD仓 + + + + + HD仓 + + + + + erp 提交和审核 + + + + + 业务对象表单Id(必录) + + + + + 单据编码 + + + + + 修改采购入库单 + + + + + 单据Id + + + + + 明细 + + + + + 明细 + + + + + 明细Id + + + + + 采购订单明细Id + + + + + 数量 + + + + + 批号 + + + + + 批号 + + + + + 批号 + + + + + 下推 + + + + + 业务对象表单Id(必录) + + + + + 分录内码集合,逗号分隔(分录下推时必录) 注(按分录下推时,单据内码和编码不需要填,否则按整单下推) + + + + + 目标单据类型 + + + + + 是否启用默认转换规则,布尔类型,默认false(非必录) + false 需要穿 RuleId true 不需要传RuleId + + + + + 转换规则内码 + + + + + 保存失败时是否暂存,布尔类型,默认false(非必录) 注(暂存的单据是没有编码的) + + + + + Erp同步数据时单据头 + + + + + 业务对象表单Id(必录) + + + + + 单据体 + + + + + 对应金蝶,物料信息 + + + + + 组织ID + + + + + 组织编码 + + + + + 物料ID + + + + + 物料名称 + + + + + 物料编码 + + + + + 物料规格型号 + + + + + 基本单位 + + + + + 基本单位名称 + + + + + 基本单位编码 + + + + + 条码 + + + + + 是否启用批号管理 + + + + + 物料Id 32进制字符串 + + + + + 金蝶组织-基本信息 + + + + + Id + + + + + 编码 + + + + + 名称 + + + + + 发货通知单转出库任务 + + + + + 来源单号 + + + + + 销售订单号 + + + + + 发货组织 + + + + + 组织编码 + + + + + 收货客户 + + + + + 对应金蝶单据明细id(销售出库同步金蝶下推使用) + + + + + 物料编码 + + + + + 仓库ID + + + + + 仓位ID + + + + + 应出库数量 + + + + + 订单明细备注 + + + + + 创建时间(erp那边的创建时间) + + + + + 用来自动构建单据类型 跟OutStockType 一致 + + + + + 出库单同步金蝶 + + + + + 单据编号 + + + + + 单据类型 + + + + + 发货组织 + + + + + 收货客户 + + + + + 创建时间(出库时间) + + + + + 结算币别默认为: 人民币 + + + + + 销售组织取对应发货通知单的销售组织 + + + + + 销售部门取对应发货通知单的销售部门 + + + + + 物料Id + + + + + 仓库ID + + + + + 出库数量 + + + + + 出库数量 + + + + + 应发数量,取对应发货通知单的销售数量 + + + + + 单价 取对应发货通知单对应物料编码行的 单价 + + + + + 含税单价 取对应发货通知单对应物料编码行的 含税单价 + + + + + 修改销售出库单 + + + + + 单据Id + + + + + 明细 + + + + + 明细Id + + + + + 发货通知单明细Id + + + + + 数量 + + + + + key为string 下拉列表对象 + + + + + id + + + + + 编码 + + + + + 名字 + + + + + 是否默认选中 + + + + + 仓库信息 + + + + + id + + + + + 编码 + + + + + 名字 + + + + + 业务组织(使用组织) + + + + + 业务组织(使用组织)编码 + + + + + 子仓库信息 + + + + + id + + + + + 编码 + + + + + 名字 + + + + + 业务组织(使用组织) + + + + + 业务组织(使用组织)编码 + + + + + 仓库编码 + + + + + erp供应商基础数据 + + + + + ID + + + + + 编码 + + + + + 名称 + + + + + 组织编码 + + + + + 盘点单 + + + + + 单据类型(标准盘亏单; 标准盘盈单 PY01_SYS) 盘亏 PK01_SYS + + + + + 库存组织 (取仓库对应的库存组织) + + + + + 货主类型: 默认为业务组织 BD_OwnerOrg + + + + + 单据编号 + + + + + 盘点日期 + + + + + 明细 + + + + + 库存状态 KCZT01_SYS + + + + + 货主类型: 默认为业务组织 BD_OwnerOrg + + + + + 取仓库对应的货主信息 货主: 等于库存组织 + + + + + 保管者类型 + + + + + 保管者 仓库”库存组织” + + + + + 物料ID + + + + + 单位ID + + + + + 仓库ID + + + + + 仓位ID + + + + + 盘点前数量(wms系统数量) + + + + + 盘点实际数量(实际仓库数量) + + + + + 盘盈数量 + + + + + 盘亏数量 + + + + + 备注 + + + + + 上传下载列表 + + + + + 组织Code + + + + + 单据类型(任务类型) + + + + + 状态 + + + + + 下单时间 开始 + + + + + 下单时间 结束 + + + + + 操作人 + + + + + 供应商用户Id + + + + + 上传下载列表 + + + + + 查询列表内容 + + + + + 总条数 + + + + + 上传下载列表 + + + + + 主键 订单编号 + + + + + 日期 + + + + + 单据类型(任务类型) + + + + + 状态(Key) + + + + + 状态 + + + + + 文件地址 + + + + + 操作人 + + + + + 失败原因 + + + + + 任务类型 + + + + + 状态 + + + + + 客户端名称 + + + + + 授权token -- 给前端用的验证token + + + + + 授权token -- 单点给过来的token + + + + + token头标识 + + + + + 刷新token + + + + + 过期时间 + + + + + 登录后要保存的信息 + + + + + 用户信息 + + + + + token信息 + + + + + 登出的dto + + + + + 授权token + + + + + 用户ID + + + + + PHP-session-ID + + + + + PHP登录返回的token + + + + + PHP登录的过期时间 + + + + + ops自己产生的token 给前端验证用的 + + + + + 登录请求对象 + + + + + 账号 + + + + + 密码 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 菜单的请求对象 + + + + + 用户ID(不是人员ID) + + + + + 应用ID + + + + + 菜单响应对象 + + + + + + + + + + 上级菜单 + + + + + 模块ID,对应apps表ID + + + + + 菜单标题 + + + + + 菜单标签 + + + + + 菜单路径 + + + + + 操作,比如 /admin/info + + + + + 图标 + + + + + + + + + + 排序 + + + + + 0为普通按钮/连接,1为左侧菜单 + + + + + 是否显示:0为否,1为是 + + + + + 是否禁用:0为否,1为是 + + + + + 是否禁用:true为禁用,false为启用 + + + + + 子集 + + + + + meta + + + + + 菜单名字 + + + + + 菜单图标 + + + + + 登录后:请求相关全部信息对象 + + + + + 用户ID + + + + + 供应商 + + + + + 客户 + + + + + 登录后:响应相关全部信息对象 + + + + + 人员 + + + + + 公司 + + + + + 供应商 + + + + + 客户 + + + + + 部门 + + + + + 基本信息人员--和单点系统的字段一一对应 + + + + + 用户在单点中维一ID + + + + + 用户编码 + + + + + 用户业务员编码 + + + + + 角色id + + + + + 姓名 + + + + + 头像 + + + + + 用户手机 + + + + + 用户邮件 + + + + + 公司id + + + + + 组织id + + + + + 供应商id + + + + + 客户id + + + + + 创建时间 + + + + + 更新时间 + + + + + 签名(登录)时间 + + + + + 签名(登录)ip + + + + + 关闭状态,0为未关闭 + + + + + 用户类型 1为员工,2为供应商,3为客户 + + + + + 部门 + + + + + 登录后获取的:token 信息-和单点系统的字段一一对应 + + + + + 用户在单点中维一ID + + + + + 单点访问的session id + + + + + 后续与单点通信验证token + + + + + access token过期时间 + + + + + 用于access_token过期后刷新用 + + + + + 加密后的用户数据 + + + + + 登录后获取的:token 信息-和单点系统的字段一一对应 + + + + + 后续与单点通信验证token + + + + + access token过期时间 + + + + + 用于access_token过期后刷新用 + + + + + 加密后的用户数据 + + + + + 用户在单点中维一ID + + + + + 人员ID + + + + + 用户编码 + + + + + 用户业务员编码 + + + + + 头像 + + + + + 是否是admin账户 + + + + + 公司id + + + + + 公司名称 + + + + + 组织id 用户类型为内部员工的时候才有值 + + + + + 供应商id 用户类型为供应商的时候才有值 + + + + + 供应商Code 用户类型为供应商的时候才有值 + + + + + 供应商名称 + + + + + 客户id 用户类型为客户的时候才有值 + + + + + 客户名称 + + + + + 用户类型:1为员工,2为供应商,3为客户 + + + + + 用户在单点中维一ID + + + + + 序列号信息 + + + + + 箱Id + + + + + 箱号 + + + + + 仓位编码(序列号不存在库存的话仓位是"") + + + + + 仓库编码 + + + + + 是否存在于箱库存中 + + + + + 序列号 + + + + + 物料名称 + + + + + 物料编码 + + + + + 物料规格型号 + + + + + 是否是老Ops条码 + + + + + 是否冻结 + + + + + 是否激活过(只有做过 盘点 采购和非采购上架 出库回退上架 才算激活) + + + + + 物料对应的仓位有哪些 + + + + + 物料编码 + + + + + 仓位编码 + + + + + 仓位名称 + + + + + 组织 + + + + + 仓库 + + + + + 操作 Id集合 + + + + + 操作 Id集合 + + + + + 操作 string集合 + + + + + 组织Id(所有列表页都需要 全局) + + + + + 页数 不传默认为1 + + + + + 每页条数 不传默认每页10 条 + + + + + 生成防伪码 + + + + + 组织Code + + + + + 物料编码 + + + + + 数量 + + + + + 防伪码下载 + + + + + 生成记录Id + + + + + 是否全部操作 + + + + + 如果是部分操作(防伪码) 全部操作的话可不传 + + + + + 防伪码生成列表记录 + + + + + 主键 订单编号 + + + + + 防伪码批次 + + + + + 物料规格型号 + + + + + 物料编码 + + + + + 物料名称 + + + + + 物料条码 + + + + + 生成完成 1 生成中 0 + + + + + 生成条码数量 + + + + + 下载数 + + + + + 创建人 + + + + + 生成时间 + + + + + 生成完成时间 + + + + + 防伪码生成列表 + + + + + 组织Code + + + + + 创建时间 + + + + + 创建时间 + + + + + 防伪码集合 + + + + + 防伪码批号 + + + + + 生成完成 true 生成中 false 不搜 null或不传 + + + + + 物料编码 + + + + + 防伪码列表 + + + + + 流水号 + + + + + 生成记录Id + + + + + 防伪码 + + + + + 物料规格型号 + + + + + 数量 + + + + + 生成时间 + + + + + 下载次数 + + + + + 最新下载时间 + + + + + 创建人 + + + + + 防伪码列表 + + + + + 组织Code + + + + + 生成记录Id + + + + + 流水号区间-开始 + + + + + 流水号区间-结束 + + + + + 是否下载 true 下载 false 未下载 + + + + + 下载时间 + + + + + 下载时间 + + + + + 防伪码 + + + + + 防伪码导出 + + + + + 防伪码 + + + + + 物料规格型号 + + + + + 数量 + + + + + 下载次数 + + + + + 最新下载时间 + + + + + 生成记录Ids + + + + + 防伪码信息 + + + + + 防伪码 + + + + + 是否第一次查询 true 第一次 false 不是第一次 + + + + + 查询次数 + + + + + 第一次查询时间 + + + + + 客户编码 + + + + + 客户名称 + + + + + 手机号码 + + + + + 邮箱 + + + + + 邮箱 + + + + + 明细 + + + + + 邮箱 + + + + + 名称 + + + + + 地址 + + + + + 明细 + + + + + 入库明细ID + + + + + 物料名称 + + + + + 物料编码 + + + + + 物料规格型号 + + + + + 数量 + + + + + 生成序列号请求参数 + + + + + 组织Code + + + + + 明细数据 + + + + + 生成序列号请求参数详情 + + + + + 物料Id转32进制 + + + + + 物料编码 + + + + + 规格型号 + + + + + 数量 + + + + + 采购单号 + + + + + 是否套装 + + + + + 操作序列号请求接口(打印 下载) + + + + + 生成记录Id + + + + + 是否全部操作 + + + + + 如果是部分操作(序列号) 全部操作的话可不传 + + + + + 根据箱Id获取序列码信息 + + + + + 箱Id + + + + + 序列号列表搜索返回参数 + + + + + 物料编码 + + + + + 物料名称 + + + + + 物料规格型号 + + + + + 转换前规格型号 + + + + + 物料条码 + + + + + 序列码 + + + + + 数字序列码 + + + + + 序列码流水号 + + + + + 数量 + + + + + 是否使用 + + + + + 是否使用 + + + + + 箱号 + + + + + 创建人 + + + + + 生成时间 + + + + + 打印次数 + + + + + 下载次数 + + + + + 最新打印时间 + + + + + 最新下载时间 + + + + + 是否允许打印(序列码已经被使用 但没有箱号,那么就是被wms系统拉去使用了,不能再被打印) + + + + + 是否为两件装,为了控制后面的变动,设为整数形,0和1看作1,2代表2件装,3代表三件装 alter by yzh + + + + + 第二个序列号 + + + + + 序列号列表搜索请求参数 + + + + + 组织Code + + + + + 生成记录Id + + + + + 打印状态 已打印 true 未打印 false + + + + + 使用状态 已使用 true 未使用 false + + + + + 下载时间 + + + + + 下载时间 + + + + + 打印时间 + + + + + 打印时间 + + + + + 序列号 + + + + + 序号区间-开始 + + + + + 序号区间-结束 + + + + + 是否更改过物料编码 + + + + + 箱号 + + + + + 数字序列号 + + + + + 数字序列码-开始 + + + + + 数字序列码-结束 + + + + + 是否为两件装,为了控制后面的变动,设为整数形,0和1看作1,2代表2件装,3代表三件装 alter by yzh + + + + + 序列码导出数据 + + + + + 供应商或组织 + + + + + 物料编码 + + + + + 物料名称 + + + + + 物料规格型号 + + + + + 物料条码 + + + + + 序列码 + + + + + 数字序列码 + + + + + 数量 + + + + + 序列码导出参数 + + + + + 生成记录Ids + + + + + 序列码信息 + + + + + 序列号 + + + + + 物料名称 + + + + + 物料编码 + + + + + 物料规格型号 + + + + + 生成时间时间 + + + + + 采购单号 + + + + + 供应商 + + + + + 序列号信息 + + + + + 物料规格型号 + + + + + 物料编码 + + + + + 物料名称 + + + + + 物料条码 + + + + + 序列号 + + + + + 数字序列号 + + + + + 箱号 + + + + + 是否已经装箱 true 已经装箱 false 未装箱 + + + + + 是否是已经存在的数据 默认就是true + 前端操作新增加的数据就是false 后端保存到数据库才会变成true + + + + + 是否使用的是数字序列码未使用null,数字序列码true,序列码false + + + + + 是否为两件套产品 + + + + + 套装编码 + + + + + 第二个序列码 + + + + + 获取没有装过箱的序列码 + + + + + 序列号 + + + + + wms系统请求序列码返回 + + + + + 序列号 + + + + + 物料编码 + + + + + 创建人 + + + + + 生成时间 + + + + + 序列号生成记录列表返回参数 + + + + + 主键编号 + + + + + 物料规格型号 + + + + + 物料编码 + + + + + 物料名称 + + + + + 物料条码 + + + + + 采购单号 + + + + + 生成完成 1 生成中 0 + + + + + 生成条码数量 + + + + + 打印数 + + + + + 下载数 + + + + + 使用数 + + + + + 创建人 + + + + + 生成时间 + + + + + 生成完成时间 + + + + + 供应商或组织 + + + + + 是否更改过物料编码 + + + + + 是否两件装 + + + + + 序列号生成记录列表请求参数 + + + + + 组织Code + + + + + 供应商或组织 + + + + + 创建时间 + + + + + 创建时间 + + + + + 序列号集合 + + + + + 生成完成 true 生成中 false 不搜 null或不传 + + + + + 物料编码 + + + + + 采购单号 + + + + + 箱号 + + + + + 数字序列号 + + + + + 生成人 + + + + + 是否更改过物料编码 + + + + + 是否两件装 + + + + + 修改序列号的物料 + + + + + 生成记录Id + + + + + 物料编码 + + + + + 操作(序列号) + + + + + ID请求对象 + + + + + ID + + + + + Id集合 + + + + + 名称请求对象 + + + + + 名称 + + + + + + + + + + 编码 + + + + + erp对应Code + + + + + 名称 + + + + + 组织类型:1为主业务,2为辅业务 3为工厂 + + + + + 本位币名称 + + + + + 本位币id + + + + + 自动排产默认入库仓库 + + + + + 是否禁用:true为禁用,false为启用 + + + + + 单点数据-请求统一对象 + + + + + 公司ID + + + + + 单点数据响应-统一对象 + + + + + ID + + + + + 编码 + + + + + 名称 + + + + + 组织编码对应金蝶 + + + + + 数值 + + + + + 是否禁用:true为禁用,false为启用 + + + + + 仓位 + + + + + 仓库ID + + + + + 供应商信息 + + + + + 供应商Id + + + + + 供应商编码 + + + + + 供应商名字 + + + + + 组织返回对象 + + + + + + + + + + 编码 + + + + + 名称 + + + + + 组织类型:1为主业务,2为辅业务 3为工厂 + + + + + 本位币名称 + + + + + 本位币id + + + + + 自动排产默认入库仓库 + + + + + 是否禁用:true为禁用,false为启用 + + + + + erp对应Code + + + + + 员工响应 + + + + + StaffID + + + + + 名称 + + + + + 部门ID + + + + + 电话 + + + + + 是否禁用:true为禁用,false为启用 + + + + + 系统code获取 + + + + + 系统code + + + + + 仓库名称 + + + + + 仓库响应 + + + + + id + + + + + 名称 + + + + + 编码 + + + + + 对应金蝶的组织编码 + + + + + 是否禁用:true为禁用,false为启用 + + + + + 仓位响应对象 + + + + + id + + + + + 仓库ID + + + + + 仓库名称 + + + + + 仓库code + + + + + 对应的金蝶组织编码 + + + + + 名称 + + + + + 编码 + + + + + 人员请求对象 + + + + + 用户ID + + + + + 请求仓位对象 + + + + + 名称 + + + + + 仓库 + + + + + 组织 + + + + + 生成序列号模板 + + + + + 物料规格型号 + + + + + 物料名称 + + + + + 采购单号 + + + + + 基类 + + + + + Id + + + + + 基类 + + + + + Id + + + + + 定义cache + + + + + 设置cache + + 键 + 值 + + + + 获取cache + + 键 + + + + + 时间转换 + + + + + 时间戳计时开始时间 + + + + + DateTime转换为10位时间戳(单位:秒) + + DateTime + 10位时间戳(单位:秒) + + + + DateTime转换为13位时间戳(单位:毫秒) + + DateTime + 13位时间戳(单位:毫秒) + + + + 10位时间戳(单位:秒)转换为DateTime + + 10位时间戳(单位:秒) + DateTime + + + + 13位时间戳(单位:毫秒)转换为DateTime + + 13位时间戳(单位:毫秒) + DateTime + + + + 转字符串 + + ) + DateTime + + + + 转字符串 + + ) + DateTime + + + + 转字符串(没有空格) + + ) + DateTime + + + + 转字符串(没有空格) + + ) + DateTime + + + + 转字符串 + + ) + DateTime + + + + 转字符串 + + ) + DateTime + + + + 转字符串 + + ) + DateTime + + + + 转字符串 + + ) + DateTime + + + + 两个时间的差:分钟 + + + + + + + + 当前时间和今晚0点之间的时间的差:分钟 + + + + + + 保存单个key value + + 保存的值 + 过期时间 + + + + 获取单个key的值 + + + + + 移除redis + + + + + + + 获取一个key的对象 + + + + + 保存一个对象 + + + + + + 结果对象 + + + + + 返回结果对象 + + + + + 返回结果对象 + + + + + + + 返回结果对象 + + + + + + 执行是否成功 + + + + + 执行是否成功 + + + + + 业务返回码 + + + + + 执行返回消息 + + + + + 转换实体 + + + + + + 转换实体 + + + + + + + 转换实体 + + 结果对象 + + + + 创建返回信息(返回处理失败) + + 结果消息 + 结果状态 + + + + + 创建返回信息(返回处理失败) + + 结果消息 + + + + + 创建返回信息(返回处理失败) + + 结果 + + + + + 创建返回信息(返回处理失败) + + 结果消息 + 结果状态 + + + + + 创建返回信息(返回处理失败) + + 结果消息 + + + + + 创建成功的返回消息 + + + + + + 创建成功的返回消息 + + + + + + 转换为 task + + + + + + 实体结果对象 + + + + + + 实体结果 + + + + + 实体结果 + + + + + + 返回结果对象 + + + + + + + 返回对象 + + + + + 创建成功的返回消息 + + + + + + 创建返回信息(返回处理失败) + + 结果消息 + 结果状态 + + + + + 创建返回信息(返回处理失败) + + 结果消息 + + + + + 创建返回信息(返回处理失败) + + 结果 + + + + + 转换为task + + + + + + 处理成功 + + + + + 错误请求 + + + + + 未授权 + + + + + 拒绝请求 + + + + + 未找到服务 + + + + + 系统错误 + + + + + 请求超时 + + + + + 返回对象扩展 + + + + + 根据替换符进行替换支付 + + 结果对象 + 替换字符 + + + + + 集合结果类 + + + + + + 实体集合结果 + + + + + 实体集合结果 + + 实体集合 + + + + 实体集合结果 + + 实体集合 + 结果状态 + + + + 创建成功的返回消息 + + + + + + 创建成功的返回消息 + + + + + + 创建返回信息(返回处理失败) + + 结果消息 + 结果状态 + + + + + 创建返回信息(返回处理失败) + + 结果消息 + + + + + 创建返回信息(返回处理失败) + + 结果 + + + + + 转换为 task + + + + + + 分页列表结果对象 + + + + + 实体分页集合结果 + + + + + 实体分页集合结果 + + 实体集合 + 总条数 + + + + 实体分页集合结果 + + + + + + + + Total count of Items. + + + + + 创建成功的返回消息 + + 实体集合 + 总条数 + + + + + 创建成功的返回消息 + + + + + + 创建返回信息(返回处理失败) + + 结果消息 + 结果状态 + + + + + 创建返回信息(返回处理失败) + + 结果消息 + + + + + 创建返回信息(返回处理失败) + + 结果 + + + + + 转换为 task + + + + + + 用于签名的私钥 + + + + + 用于验证的公钥 + + + + + 签名 + + 签名内容 + 私钥 + 编码类型 + 加密方式 + 加密密文 + + + + 验证签名 + + 验证签名内容 + 公钥 + 签名密文 + 编码类型 + 加密方式 + 加密密文 + + + + 解密 + + 密文 + 私钥 + 编码 + 明文 + + + + 加密 + + 明文 + 公钥 + 编码 + 密文 + + + + 解密公钥 + + + + + + + + + 私钥解密 + + + + + + + + + Pkcs#8 证书解密 + + + + + + + 获取Integer的大小 + + + + + + + 获取私钥的类型 + + + + + + + php单点登录解析token根据密钥-分段解析 + + + + + + + + 密钥类型枚举 + + + + + 1024 + + + + + 2048 + + + + + 1023 + + + + + 2048 + + + + + 数值处理 + + + + + Decimal 数值精度转换 + + decimal数值 + 精度值 + 舍入类型:1为进位,2为舍位,3为四舍五入 + decimal数值 + + + + Decimal 数值精度转换 + + decimal数值 + 精度值 + 舍入类型:1为进位,2为舍位,3为四舍五入 + decimal数值 + + + + Decimal 去掉后面无效的0 + + + + + + diff --git a/src/BarCode.Web.Api/wwwroot/BarCode.Web.Domain.xml b/src/BarCode.Web.Api/wwwroot/BarCode.Web.Domain.xml new file mode 100644 index 0000000..80207e2 --- /dev/null +++ b/src/BarCode.Web.Api/wwwroot/BarCode.Web.Domain.xml @@ -0,0 +1,4028 @@ + + + + BarCode.Web.Domain + + + + + 箱信息头 + alter table t_barcode_box_details AUTO_INCREMENT=50000; + + + + + ID + + + + + 箱编号 + + + + + 供应商Code + + + + + 组织Code + + + + + 公司Id + + + + + 箱状态 + + + + + 装箱开始时间 + + + + + 装箱结束时间(完成装箱时间) + + + + + 装箱用户 + + + + + 箱子创建用户 + + + + + 创建时间 + + + + + 箱号打印次数 + + + + + 最新打印时间 + + + + + 明细 + + + + + 打印 + + + + + 解绑序列号 + + + + + + + 清空 + + + + + 装箱 + + + + + 开始装箱 + + + + + + + 重置 + + + + + 老ops箱信息明细 + alter table t_barcode_box_details AUTO_INCREMENT=50000; + + + + + ID + + + + + 单据头ID + + + + + 物料编码 + + + + + 数量(装箱数量) + + + + + 序列号 + + + + + 箱唛表 + + + + + ID + + + + + 供应商Code + + + + + 组织Code + + + + + 订单编号 + + + + + 物料编码 + + + + + 产品数量 + + + + + 装箱数量 + + + + + 装箱净重 + + + + + 装箱毛重 + + + + + 尾箱数量 + + + + + 尾箱净重 + + + + + 尾箱毛重 + + + + + 备注 + + + + + 操作人 + + + + + 创建时间(生成时间) + + + + + 流水号(开始) + + + + + 流水号(结束) + + + + + 编号集合 + + + + + 创建 + + + + + + 生成编号 + + + + + + + 箱唛表-编号表 + + + + + ID + + + + + 上级ID + + + + + 箱唛编号 + + + + + 箱唛编号-首位 + + + + + 箱唛编号-末尾序号 + + + + + 是否是尾箱 + + + + + 排序 + + + + + 流水号(开始) + + + + + 流水号(结束) + + + + + 生成编号 + + + + + + + 生成计划管理 + + + + + 主键 订单编号 + + + + + 同步类型 + + + + + 数量 + + + + + 文件下载类型 + + + + + 主键 订单编号 + + + + + 日期 + + + + + 单据类型(任务类型) + + + + + 状态 + + + + + 公司Id + + + + + 组织编码 + + + + + 文件地址 + + + + + 操作人 + + + + + 失败原因 + + + + + 供应商编码 + + + + + 物料 + + + + + ID + + + + + 组织Id + + + + + 组织编码 + + + + + 物料ID + + + + + 物料名称 + + + + + 物料编码 + + + + + 物料规格型号 + + + + + 基本单位 + + + + + 基本单位名称 + + + + + 基本单位编码 + + + + + 条码 + + + + + 是否启用批号管理 + + + + + 物料Id 32进制字符串 + + + + + 防伪码生成记录 + + + + + 主键 订单编号 + + + + + 防伪码批次 + + + + + 物料编码 + + + + + 公司Id + + + + + 组织Id + + + + + 供应商code + + + + + 生成完成 1 生成中 0 + + + + + 生成条码数量 + + + + + 下载数 + + + + + 创建人 + + + + + 生成时间 + + + + + 生成完成时间 + + + + + 生成完成 + + + + + 下载 + + + + + 生成批号 + + + + + 防伪码 + + + + + 主键 订单编号 + + + + + 组织Code + + + + + 供应商code + + + + + 生成记录Id + + + + + 防伪码 + + + + + 物料编码 + + + + + 下载次数 + + + + + 最新下载时间 + + + + + 查询次数 + + + + + 第一次查询时间 + + + + + 创建人 + + + + + 生成时间 + + + + + 下载 + + + + + 生成防伪码 + + + + + 被查询 + + + + + 序列号生成记录 + + + + + 主键 订单编号 + + + + + 物料Id转32进制 + + + + + 物料编码 + + + + + 是否更改过物料编码 + + + + + 采购单号 + + + + + 供应商code + + + + + 公司Id + + + + + 组织Id + + + + + 生成完成 1 生成中 0 + + + + + 生成条码数量 + + + + + 生成条码起始位数量(后端用来做标记) + + + + + 打印数 + + + + + 下载数 + + + + + 使用数 + + + + + 创建人 + + + + + 是否套装,默认是为1,1即为单个,不是套装Alter by yzh + + + + + 生成时间 + + + + + 生成完成时间 + + + + + 生成完成 + + + + + 打印 + + + + + 下载 + + + + + 反写使用数 + + + + + + 标记修改物料 + + + + + 序列号 默认Id从 200000000 起始 + alter table users AUTO_INCREMENT=200000000; + + + + + 主键 订单编号 + + + + + 组织Code + + + + + 供应商code + + + + + 生成记录Id + + + + + 序列号 + + + + + 套装(1代表单套,2代表2套,3代表3套) aLTER BY YZH + + + + + 当次序号,用来记录当次所产生时所处的序列号 + + + + + 序列号 + + + + + 产生第二个 + + + + + 物料Id + + + + + 物料编码 + + + + + 老物料编码(上一次物料编码) + + + + + 箱ID + + + + + 数字序列码 + + + + + 数字序列码(不包含日期) + + + + + 是否使用 + + + + + 创建人 + + + + + 生成时间 + + + + + 完成装箱时间 + + + + + 打印次数 + + + + + 下载次数 + + + + + 最新打印时间 + + + + + 最新下载时间 + + + + + 是否使用的是数字序列码未使用null,数字序列码true,序列码false + + + + + 生成序列码 + + + + + 生成时间序列码 + + + + + 产生套装编码 alter by yzh + + + + + + 产生第二个序列号 + + + + + + 打印 + + + + + 下载 + + + + + 装箱 + + + + + + + 解绑箱 + + + + + wms系统获取序列码后 序列码调整为已使用 + + + + + 修改物料编码 + + + + + + 列表字段导出接口 + + + + + + + + 基础数据 + + + + + 根据用户精确搜索用户 + + + + + + + 获取所有人员-根据主体 + + + + + + + 根据仓库获取子仓库 + + 仓库id + + + + + 获取仓位:根据name模糊,和系统code和公司 + + + + + + + + + 获取仓位详情:根据仓位ID和公司ID + + + + + + + + 获取仓位集合:根据仓位ID集合和公司ID + + + + + + + + 获取仓位详情:根据仓位ID和公司ID + + + + + + + + 获取仓位集合:根据仓位编码集合和公司ID + + + + + + + + 获取仓库 + + + + + + 获取事务 用来处理即时库存 + + + + + + 获取事务 用来处理即时库存 + + + + + + 箱唛-仓储接口 + + + + + 列表分页 + + + + + + + + 添加 + + + + + + + + 详情-根据最新的ID + + + + + + 列表-详情信息列表 + + + + + + + + 获取最新的编号实体 + + + + + + 批量删除 + + + + + + + + 老ops箱信息 + + + + + 获取列表 + + + + + + + + 批量添加 + + + + + + + 查询实体集合 + + + 查询实体集合 + + + + 生成数据管理 + + + + 获取最新一次更新时间 + + + 定时任务执行后更新时间 + + + 定时任务执行后创建 + + + + 保存 + + + + + + + 编辑 + + + + + + + 获取销售列表 + + + + + + 公司Id + + + + + 员工ID + + + + + 登录用户信息 + + + + + 物料仓储接口 + + + + + 物料添加 + + + + + + + + 列表 + + + + + + 物料 + + + + + + + 物料 + + + + + + + + + + + + + + 列表 + + + + + + + + 列表(获取所有没有id32进制的物料) + + + + + + 修改物料 + + + + + + + + 集合 + + + + + + + 防伪码生成记录 + + + + 获取列表 + + + 新增 + + + 编辑 + + + 批量添加 + + + 修改实体集合 + + + 查询实体集合 + + + 查询实体 + + + 获取当天生成记录条数 + + + + 防伪码 + + + + 获取列表 + + + 批量添加 + + + 修改实体集合 + + + 查询实体集合 + + + 根据生成记录id查询序列码 + + + 根据生成记录id查询序列码 + + + 查询实体 + + + 修改实体 + + + + 下载反写 执行sql语句 + + + + + + + 序列码 + + + + + 获取列表 + + + + + + + + 批量添加 + + + + + + + 修改实体集合 + + + 查询实体集合 + + + 查询实体集合 + + + 根据箱Id查询序列码 + + + 根据生成记录id查询序列码 + + + 根据套装码查询序列码 + + + 根据生成记录id查询序列码 + + + 根据箱号查询序列码 + + + 查询实体 + + + 查询实体 + + + WMS查询实体 + + + + 根据序列号搜索信息 + + + + + + + 批量添加 + + + + + + + 修改实体集合 + + + 查询实体集合 + + + 查询实体 + + + + 获取事务 用来处理即时库存 + + + + + + 获取事务 用来处理即时库存 + + + + + + 箱唛-服务接口 + + + + + 生成 + + + + + + + + 列表-分页 + + + + + + + + 箱 + + + + + wms获取已完成装箱箱信息 + + + + + + + + 装箱 + + + + + + + + 生成箱码 + + + + + + + 打印 + + + + 删除 + + + + + + 清空 + + + + + 重新装箱 + + + + 开始装箱 + + + + + + 全字段导出数据 + + + + + + + + + + + + + + + 列表字段导出数据 + + + + + + + + + + + + + + + 列表页导出数据 + + + + + + + + + + + + + + 上传文件 + + + + 是否开启自动删除 如果开启 3天后自动删除 导出的execl文件 + + + + + 防伪码 + + + + + 下载 + + + + + + + 生成防伪码 + + + + + + + + 序列号服务 + + + + + 生成序列号 + + + + + + + + 打印 + + + + + + + 下载 + + + + + + + 装箱后反写使用数 + + + + + + + 修改序列号物料 + + + + + + + erp基础数据:扩展服务接口 + + + + + 获取物料名称 + + + + + + + 获取物料编码 + + + + + + + + 获取物料规格型号 + + + + + + + + 获取物料名称 + + + + + + + 获取物料规格型号 + + + + + + + + 获取物料基本单位名称 + + + + + + + + 获取物料基本单位名称 + + + + + + + + 获取物料的条码 + + + + + + + + 获取物料的条码 + + + + + + + + 获取物料基本单位id + + + + + + + + 获取物料基本单位编码 + + + + + + + + 获取物料基本单位编码 + + + + + + + + 获取组织名称 + + + + + + + + 获取组织名称 + + + + + + + + 获取组织ID + + + + + + + 获取供应商名称 + + + + + + + + 获取供应商名称 + + + + + + + + 获取客户名称 + + + + + + + + 获取仓库名称 + + + + + + + + 获取仓库名称 + + + + + + + + 获取仓库编码 + + + + + + + + 获取子仓库名称 + + + + + + + + 获取单点组织名字 + + + + + + + 查单据类型的值 + + + + + + erp:单据查询-物料集合 + + + + + + 获取物料id32进制 + + + + + + + erp:基础数据-物料信息 + + + + + + + erp:基础数据-物料信息 + + + + + + + + + + + + + + + + + + + + + + + + + + + 供应商 + + + + + + 客户 + + + + + + 获取仓库信息 + + + + + + 获取仓位信息信息 根据仓库编码 + + + + + + 登录服务接口 + + + + + 创建token + + + + + + + + + + + + + + + + 获取单点用户信息 + + + + + + + + 登录退出 + + + + + + + 刷新token + + + + + + + + 单点退出通知token失效 + + + + + + + 获取登录后的信息 + + + + + + + 获取菜单 + + + + + + + 单点数据返回服务接口 + + + + + 获取单点数据:根据方法名和公司ID + + + + + + + + + 获取单点数据:根据方法名和公司ID + + + + + + + + + 获取单点数据:根据方法名和公司ID + + + + + + + + + 获取单点数据:根据方法名和公司ID + + + + + 加上ID防止编码重复 + + + + + 根据名字模糊匹配 + + + + + + + + + 获取单点数据集合:泛型-同步 + + + + + + + + + 获取单点数据集合:泛型-异步 + + + + + + + + + 获取单点数据集合:泛型-异步-无缓存 + + + + + + + + + 单点数据:可对接全部接口 + + 返回对象 + 请求对象 + 方法名称 + 请求对象 + 方法名称 + 控制器名称 + + + + + 单点数据:可对接全部接口-无缓存 + + + + + + + + + + + + 获取单点数据:请求对象和接口方法名 + + + + + + + + + + 获取客户仓库 + + + + + + + + wms重置箱信息 + + + + + 重置wms箱信息 + + + + + + + 物料服务接口 + + + + + 同步金蝶新物料 + + + + + + 同步物料id32进制 + + + + + + mapper映射 + + + + + 箱mapper映射 + + + + + 箱mapper映射 + + + + + 集合映射 + + + + + 映射实体里 集合属性 + + + + + + + + + + + 映射实体里 集合属性 + + + + + + + + + + + 数据库 + + + + + redis + + + + + 单点数据请求地址-后端使用接口地址 + + + + + redis数据目录 + + + + + 数据库类型 + + + + + 是否允许缓存 + + + + + 公司ID + + + + + 邮箱 + + + + + SMTP 服务器地址 + + + + + SMTP 服务器端口号 + + + + + 名称 + + + + + 主题 + + + + + 发件人邮箱地址 + + + + + 发件人邮箱密码 + + + + + erp相关配置文件 + + + + + erp-请求地址 + + + + + 账号 + + + + + 密码 + + + + + erp-Id + + + + + 七牛云 配置 + + + + + 访问key + + + + + 秘钥 + + + + + 区块文件夹 + + + + + 访问域名 + + + + + Quartz定时任务-配置项 + + + + + 存储类型:键 + + + + + 存储类型:值 + + + + + 数据库驱动类型-这里是mysql:键 + + + + + 数据库驱动类型-这里是mysql:值 + + + + + 数据库表名前缀:键 + + + + + 数据库表名前缀:值 + + + + + 数据源的名称:键 + + + + + 数据源的名称:值 + + + + + 连接字符串:键 + + + + + 连接字符串:值 + + + + + mysql提供器:键 + + + + + mysql提供器:值 + + + + + 几点后开始执行 + + + + + 几分钟后开始执行 + + + + + 执行Cron表达式:可以是几小时or几分钟or几秒钟or几天or几周 + + + + + + + + + + 发送通知执行cron表达式:每天12,16,20整点发送 + + + + + 同步新物料执行cron表达式:每天23:30整点同步 + + + + + 同步新物料执行cron表达式:每天0:01执行 + + + + + 是否启用集群:键 + + + + + 是否启用集群:值 + + + + + 节点都必须有一个唯一ID:键 + + + + + 节点都必须有一个唯一ID:值 + + + + + 工作名称:键 + + + + + 工作名称:值 + + + + + 工作描述 + + + + + 触发器身份认证信息 + + + + + 触发器描述 + + + + + 短信配置项 + + + + + 访问凭证ID + + + + + 访问秘钥 + + + + + 短信签名 + + + + + 短信模板编号 + + + + + 单点系统地址 + + + + + 单点系统地址 + + + + + admin账号的Id + + + + + 应用id + + + + + AppId + + + + + AppSecret + + + + + 公钥 + + + + + 私钥 + + + + + 老ops对接 + + + + + 自动生成数据维护 凌晨清空 + + + + + 执行方法 + + + + + + + 执行方法 + + + + + + + 物料同步执行定时任务 + + + + + 执行方法 + + + + + + + 箱唛-服务 + + + + + 生成 + + + + + + + + 列表分页 + + + + + + + + 装箱总数 + + + + + + + + 箱信息 + + + + + 生成箱码 + + + + + + + + + 装箱 + + + + + + + + + 打印 + + + + + + + + 删除 + + + + + + + + 清空装箱信息 + + + + + + + + wms系统调用 获取完成装箱箱信息 + + + + + + + + 重新装箱 + + + + + + + + 开始装箱 + + + + + + + + 列表页导出 + + + + + + + + + + + + + 全字段导出 + + + + + + + + + + + + + + 同步erp基础数据 + + + + + erp基础数据:扩展服务 + + + + + 获取物料名称 + + + + + + + + 获取物料编码 + + + + + + + + 获取物料规格型号 + + + + + + + + 获取物料名称 + + + + + + + + 获取物料编码 + + + + + + + + 获取物料基本单位名称 + + + + + + + + 获取物料基本单位名称 + + + + + + + + 获取物料的条码 + + + + + + + + 获取物料的条码 + + + + + + + + 获取物料基本单位Id + + + + + + + + 获取物料基本单位编码 + + + + + + + + 获取物料基本单位编码 + + + + + + + + 获取组织名称 + + + + + + + + 获取组织名称 + + + + + + + + 获取组织id + + + + + + + + 获取供应商名称 + + + + + + + + 获取供应商名称 + + + + + + + + 获取客户名称 + + + + + + + + 获取仓库名称 + + + + + + + + 获取仓库名称 + + + + + + + + 获取仓库编码 + + + + + + + + 子仓库 + + + + + + + + 获取单点组织名字 + + + + + + + + + erp数据交互服务 + + + + + 初始化ERP:登录到ERP + + + + + + 查单据类型的值 + + + + + + erp:单据查询-物料集合 + + + + + + 获取物料id32进制 + + + + + + + + erp:基础数据-物料信息 + + + + + + + erp:基础数据-物料信息 + + + + + + + erp:基础数据-物料-分页查询 + + + + + + erp:基础数据-物料-ids查询 + + + + + + + erp:基础数据-物料-number查询 + + + + + + + erp:单据查询-组织数据 + + + + + + erp:供应商 + + + + + + 客户 + + + + + + erp:仓库 + + + + + + 根据仓库编码获取仓位 + + + + + + + 同步数据(保存提交审核) + + + + + + + + 提交 + + + + + + + + 审核 + + + + + + + + 反审核 + + + + + + + + 删除 + + + + + + + + 下推 + + + + + + + Get方法 + + + + + + + + + + Get方法 + + + + + + + + + + Post方法 + + + + + + + + + + + Post方法 + + + + + + + + + + 公共http请求 + + + + + + + + + + + + 设置HttpRequestMessage + + + + + + + + + + 设置请求内容 + + + + + + + + 设置请求头和超时时间:返回client + + + + + + + + 创建token + + + + + + + + + 创建token + + + + + + + + + 获取单点登录信息 + + + + + + + 获取单点用户信息 + + + + + + + + 登录退出 + + + + + + + 刷新token + + + + + + + + 单点退出通知token失效 + + 这个是单点传过来的SeesionId + + + + + 缓存退出的token + + + + + + + 获取登录后的信息 + + + + + + + 移除登录后的用户信息 + + + + + + 获取菜单数据 + + + + + + + + + + + + + + + + + + + + + + 进制转换 + + 整形数字 + 排除的字符"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", + "C", "D", "E", "F", "G", "H", "I", "J", "K","L", "M", "N", "O", "P", "Q", "R", "S", + "T", "U", "V", "W", "X", "Y", "Z" + + + + + 保存单个key value + + + + + + + + + 获取单个key的值 + + + + + 移除redis + + + + + + + 获取一个key的对象 + + + + + 保存一个对象 + + + + + + 单点数据返回服务 + + + + + 获取单点数据:根据接口方法名和公司ID + 后端列表查询统一使用 + + + + + + + + 获取单点数据:根据接口方法名和公司ID + 后端列表查询统一使用 + + + + + + + + 获取单点数据:根据接口方法名和公司ID + 后端列表查询统一使用 + + + + + + + + 根据名字模糊匹配 + + + + + + + + + 获取单点数据:根据接口方法名和公司ID + 后端列表查询统一使用 + + + + + + + + 获取单点数据集合:泛型-同步 + + + + + + + + + 获取单点数据集合:泛型-异步 + + + + + + + + + 获取单点数据集合:泛型-异步-无缓存 + + + + + + + + + 单点数据:可对接全部接口 + + 返回对象 + 请求对象 + 方法名称 + 请求对象 + 方法名称 + 控制器名称 + + + + + 单点数据:可对接全部接口 + + 返回对象 + 请求对象 + 方法名称 + 请求对象 + 方法名称 + 控制器名称 + + + + + 获取单点数据:配置项接口 + + + + + + + + + + 请求单点服务接口:同步 + + + + + + + + + 请求单点服务接口:异步 + + + + + + + + + 获取客户仓库 + + + + + + + + ops服务 + + + + + 重置箱信息 + + + + + + + + 物料服务 + + + + + 同步物料32进制 + + + + + + + 同步金蝶新的物料 + + + + + + 上传文件 + + + + + + + + + 防伪码 + + + + + 序列号服务 + + + + + + + + + + + 下载 + + + + + + + + 生成防伪码 + + + + + + + + + 循环生成序列码 + + + + + + 序列号服务 + + + + + 序列号服务 + + + + + + + + + + + + 生成序列号 + + + + + + + + + 循环生成序列码 + + + + + + + 下载 + + + + + + + + 打印 + + + + + + + + 反写使用数 + + + + + + + 修改序列码物料 + + + + + + + + erp基础数据-同步定时任务 + + + + + 箱状态 + + + + + 未使用 + + + + + 未完成 + + + + + 已完成 + + + + + 自动生成数据 序列码和防伪码 + + + + + 序列码生成 + + + + + 业务对象表单Id:对应erp的单据表的名称 + + + + + 采购订单 + + + + + 采购入库单 + + + + + 其他入库单 + + + + + 直接调拨单-里面包含出和入 + + + + + 分步式调入单 + + + + + 组装拆卸单:里面包含出和入 + + + + + 组织 + + + + + 供应商 + + + + + 仓库 + + + + + 盘盈单 + + + + + 盘亏单 + + + + + 物料 + + + + + 销售发货通知单 + + + + + 其他出库单 + + + + + 分布式调出单 + + + + + 客户 + + + + + 销售出库单 + + + + + 即时库存 + + + + + 文件导出状态 + + + + + 正在导出 + + + + + 导出成功 + + + + + 导出失败 + + + + + 导出单据类型 + + + + + 条码下载 + + + + + 条码详情下载 + + + + + 防伪码下载 + + + + + 防伪码详情下载 + + + + + 错误提示信息 + + + + + 无效 + + + + + 数据操作失败 + + + + + 没有菜单权限,无法登录 + + + + + 箱号不符合规则 + + + + + 对接单点的接口方法-枚举 + + + + + 组织集合 + + + + + 用户集合 + + + + + 人员集合 + + + + + 供应商集合 + + + + + 客户集合 + + + + + 收款条件集合 + + + + + 付款条件集合 + + + + + 结算方式集合 + + + + + 结算币别集合 + + + + + 税率集合 + + + + + 汇率集合 + + + + + 仓库集合 + + + + + 单位集合 + + + + + 客户仓库集合 + + + + + 部门集合 + + + + + 仓库211集合 + + + + + 供应商默认联系人集合 + + + + + 菜单集合 + + + + + 仓位集合 + + + + + 仓库:编码与组织编码结合 + + + + + 仓库:编码与组织编码结合 + + + + + 单点-控制器枚举 + + + + + 单点OPS列表数据-控制器 + + + + + 单点配置项数据-控制器 + + + + + 单点登录项数据-控制器 + + + + + 单点公共接口数据-控制器 + + + + + 单点数据接口-登录要使用的数据接口-方法枚举 + + + + + 菜单 + + + + + 人员 + + + + + 公司 + + + + + 供应商 + + + + + 客户 + + + + + 全部信息 + + + + + 公司信息 + + + + + 单点数据:配置项和公共接口的方法枚举值 + + + + + 供应商-根据名称和公司 + + + + + 组织-根据公司 + + + + + 部门-根据组织和公司 + + + + + 人员-根据公司 + + + + + 人员-根据部门和公司 + + + + + 人员-根据组织和公司 + + + + + 客户-根据公司 + + + + + 客户-根据客户和组织和公司 + + + + + 客户信息-根据客户和组织和公司 + + + + + 收款条件-根据公司 + + + + + 付款条件-根据公司 + + + + + 结算方式-根据公司 + + + + + 结算币别-根据公司 + + + + + 单位-根据公司 + + + + + 单位(部分属性)-根据公司 + + + + + 税率-根据公司 + + + + + 仓库-根据名称和公司 + + + + + 仓库-根据组织和公司 + + + + + 仓库(不是调拨中转仓)-根据组织和公司 + + + + + 仓库(211)-根据组织和公司 + + + + + 仓库-根据客户和公司 + + + + + 仓位-根据仓库 + + + + + 仓位-根据- + + + + + 汇率信息-根据原币、目标币和公司 + + + + + 客户仓库-根据客户和组织和公司 + + + + + 付款条件,结算币别,结算方式,采购员,采购部门-根据供应商和组织 + + + + + 获取仓库:根据仓库id + + + + + 获取库存:根据组织和公司 + + + + + 获取客户仓库:根据客户IDS和组织和公司 + + + + + 汇率(所有) + + + + + 供应商选择后获取:付款条件,结算币别,结算方式,采购员,采购部门,根据组织IDS + + + + + 获取客户仓库:根据code集合 + + + + + 供应商:根据ids + + + + + 根据公司搜索所有仓库(计算补货频次) + + + + + 获取仓库:根据codes + + + + + 获取客户仓库:根据codes + + + + + 获取调拨中转仓库:根据公司 + + + + + 获取供应商数据根据ids + + + + + 获取仓库:根据默认补货客户 + + + + + 获取用户(ID和Name):根据公司 + + + + + 全部部门-根据组织和公司:不处理子级 + + + + + 获取全部员工:根据公司和组织 + + + + + 获取仓库::根据管理系统code和仓库名称和公司ID,备注系统code和公司ID是必填 + + + + + 获取仓库::根据管理系统code和仓位名称和公司ID,备注系统code和公司ID是必填 + + + + + 获取仓位详情:根据仓位ID和公司ID + + + + + 获取仓位详情:根据仓位ID集合和公司ID + + + + + 获取仓位详情:根据仓位Code和公司ID + + + + + 获取仓位详情:根据仓位Codes集合和公司ID + + + + + 根据用户获取组织 + + + + + 根据用户获取供应商 + + + + diff --git a/src/BarCode.Web.Core/BarCode.Web.Core.csproj b/src/BarCode.Web.Core/BarCode.Web.Core.csproj new file mode 100644 index 0000000..4eab3ba --- /dev/null +++ b/src/BarCode.Web.Core/BarCode.Web.Core.csproj @@ -0,0 +1,33 @@ + + + + net8.0 + enable + enable + True + ../BarCode.Web.Api/wwwroot/BarCode.Web.Core.xml + true + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/BarCode.Web.Core/Connected Services/ERP/ConnectedService.json b/src/BarCode.Web.Core/Connected Services/ERP/ConnectedService.json new file mode 100644 index 0000000..9e86b81 --- /dev/null +++ b/src/BarCode.Web.Core/Connected Services/ERP/ConnectedService.json @@ -0,0 +1,99 @@ +{ + "ExtendedData": { + "inputs": [ + "http://119.23.206.129/K3cloud/erpgw.asmx?WSDL" + ], + "collectionTypes": [ + "System.Array", + "System.Collections.Generic.Dictionary`2" + ], + "namespaceMappings": [ + "*, ERP" + ], + "references": [ + "BouncyCastle.Cryptography, {BouncyCastle.Cryptography, 2.2.1}", + "Enums.NET, {Enums.NET, 4.0.1}", + "Google.Protobuf, {Google.Protobuf, 3.25.1}", + "ICSharpCode.SharpZipLib, {SharpZipLib, 1.3.3}", + "K4os.Compression.LZ4, {K4os.Compression.LZ4, 1.3.5}", + "K4os.Compression.LZ4.Streams, {K4os.Compression.LZ4.Streams, 1.3.5}", + "K4os.Hash.xxHash, {K4os.Hash.xxHash, 1.0.8}", + "LogicExtensions, {LogicExtensions, 0.0.3}", + "MathNet.Numerics, {MathNet.Numerics.Signed, 4.15.0}", + "Microsoft.EntityFrameworkCore, {Microsoft.EntityFrameworkCore, 8.0.2}", + "Microsoft.EntityFrameworkCore.Abstractions, {Microsoft.EntityFrameworkCore.Abstractions, 8.0.2}", + "Microsoft.EntityFrameworkCore.Relational, {Microsoft.EntityFrameworkCore.Relational, 8.0.2}", + "Microsoft.Extensions.Caching.Abstractions, {Microsoft.Extensions.Caching.Abstractions, 8.0.0}", + "Microsoft.Extensions.Caching.Memory, {Microsoft.Extensions.Caching.Memory, 8.0.0}", + "Microsoft.Extensions.Configuration.Abstractions, {Microsoft.Extensions.Configuration.Abstractions, 8.0.0}", + "Microsoft.Extensions.DependencyInjection, {Microsoft.Extensions.DependencyInjection, 8.0.0}", + "Microsoft.Extensions.DependencyInjection.Abstractions, {Microsoft.Extensions.DependencyInjection.Abstractions, 8.0.0}", + "Microsoft.Extensions.Diagnostics.Abstractions, {Microsoft.Extensions.Diagnostics.Abstractions, 8.0.0}", + "Microsoft.Extensions.Diagnostics.HealthChecks, {Microsoft.Extensions.Diagnostics.HealthChecks, 8.0.0}", + "Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions, {Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions, 8.0.0}", + "Microsoft.Extensions.FileProviders.Abstractions, {Microsoft.Extensions.FileProviders.Abstractions, 8.0.0}", + "Microsoft.Extensions.Hosting.Abstractions, {Microsoft.Extensions.Hosting.Abstractions, 8.0.0}", + "Microsoft.Extensions.Logging, {Microsoft.Extensions.Logging, 8.0.0}", + "Microsoft.Extensions.Logging.Abstractions, {Microsoft.Extensions.Logging.Abstractions, 8.0.0}", + "Microsoft.Extensions.ObjectPool, {Microsoft.Extensions.ObjectPool, 6.0.16}", + "Microsoft.Extensions.Options, {Microsoft.Extensions.Options, 8.0.0}", + "Microsoft.Extensions.Primitives, {Microsoft.Extensions.Primitives, 8.0.0}", + "Microsoft.IdentityModel.Abstractions, {Microsoft.IdentityModel.Abstractions, 7.5.1}", + "Microsoft.IdentityModel.Logging, {Microsoft.IdentityModel.Logging, 7.5.1}", + "Microsoft.IdentityModel.Tokens, {Microsoft.IdentityModel.Tokens, 7.5.1}", + "Microsoft.IO.RecyclableMemoryStream, {Microsoft.IO.RecyclableMemoryStream, 2.3.2}", + "Microsoft.Win32.SystemEvents, {Microsoft.Win32.SystemEvents, 6.0.0}", + "MySql.Data, {MySql.Data, 8.3.0}", + "MySqlConnector, {MySqlConnector, 2.3.5}", + "Newtonsoft.Json, {Newtonsoft.Json, 13.0.3}", + "NPOI.Core, {NPOI, 2.6.2}", + "Npoi.Mapper, {Npoi.Mapper, 6.2.1}", + "NPOI.OOXML, {NPOI, 2.6.2}", + "NPOI.OpenXml4Net, {NPOI, 2.6.2}", + "NPOI.OpenXmlFormats, {NPOI, 2.6.2}", + "Pipelines.Sockets.Unofficial, {Pipelines.Sockets.Unofficial, 2.2.8}", + "Pomelo.EntityFrameworkCore.MySql, {Pomelo.EntityFrameworkCore.MySql, 8.0.2}", + "Quartz, {Quartz, 3.8.1}", + "Quartz.AspNetCore, {Quartz.AspNetCore, 3.8.1}", + "Quartz.Extensions.DependencyInjection, {Quartz.Extensions.DependencyInjection, 3.8.1}", + "Quartz.Extensions.Hosting, {Quartz.Extensions.Hosting, 3.8.1}", + "Quartz.Serialization.Json, {Quartz.Serialization.Json, 3.8.1}", + "SixLabors.Fonts, {SixLabors.Fonts, 1.0.0}", + "SixLabors.ImageSharp, {SixLabors.ImageSharp, 2.1.4}", + "StackExchange.Redis, {StackExchange.Redis, 2.7.33}", + "System.ComponentModel.Annotations, {System.ComponentModel.Annotations, 5.0.0}", + "System.Configuration.ConfigurationManager, {System.Configuration.ConfigurationManager, 6.0.1}", + "System.Diagnostics.DiagnosticSource, {System.Diagnostics.DiagnosticSource, 8.0.0}", + "System.Drawing.Common, {System.Drawing.Common, 6.0.0}", + "System.Formats.Asn1, {System.Formats.Asn1, 6.0.0}", + "System.IO, {System.IO, 4.3.0}", + "System.IO.Pipelines, {System.IO.Pipelines, 6.0.3}", + "System.Json, {System.Json, 4.7.1}", + "System.Reflection, {System.Reflection, 4.3.0}", + "System.Reflection.Primitives, {System.Reflection.Primitives, 4.3.0}", + "System.Runtime, {System.Runtime, 4.3.0}", + "System.Runtime.CompilerServices.Unsafe, {System.Runtime.CompilerServices.Unsafe, 6.0.0}", + "System.Runtime.Loader, {System.Runtime.Loader, 4.3.0}", + "System.Security.AccessControl, {System.Security.AccessControl, 6.0.0}", + "System.Security.Cryptography.Pkcs, {System.Security.Cryptography.Pkcs, 6.0.1}", + "System.Security.Cryptography.ProtectedData, {System.Security.Cryptography.ProtectedData, 6.0.0}", + "System.Security.Cryptography.Xml, {System.Security.Cryptography.Xml, 6.0.1}", + "System.Security.Permissions, {System.Security.Permissions, 6.0.0}", + "System.ServiceModel.Duplex, {System.ServiceModel.Duplex, 6.0.0}", + "System.ServiceModel.Http, {System.ServiceModel.Http, 8.0.0}", + "System.ServiceModel.NetFramingBase, {System.ServiceModel.NetFramingBase, 8.0.0}", + "System.ServiceModel.NetTcp, {System.ServiceModel.NetTcp, 8.0.0}", + "System.ServiceModel.Primitives, {System.ServiceModel.Primitives, 8.0.0}", + "System.ServiceModel.Security, {System.ServiceModel.Security, 6.0.0}", + "System.Text.Encoding, {System.Text.Encoding, 4.3.0}", + "System.Text.Encoding.CodePages, {System.Text.Encoding.CodePages, 5.0.0}", + "System.Text.Encodings.Web, {System.Text.Encodings.Web, 7.0.0}", + "System.Text.Json, {System.Text.Json, 7.0.1}", + "System.Threading.Tasks, {System.Threading.Tasks, 4.3.0}", + "System.Windows.Extensions, {System.Windows.Extensions, 6.0.0}", + "ZstdSharp, {ZstdSharp.Port, 0.7.1}" + ], + "targetFramework": "net8.0", + "typeReuseMode": "All" + } +} \ No newline at end of file diff --git a/src/BarCode.Web.Core/Connected Services/ERP/Reference.cs b/src/BarCode.Web.Core/Connected Services/ERP/Reference.cs new file mode 100644 index 0000000..295b378 --- /dev/null +++ b/src/BarCode.Web.Core/Connected Services/ERP/Reference.cs @@ -0,0 +1,1236 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// +// 对此文件的更改可能导致不正确的行为,并在以下条件下丢失: +// 代码重新生成。 +// +//------------------------------------------------------------------------------ + +namespace ERP +{ + + + [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.2.0-preview1.23462.5")] + [System.ServiceModel.ServiceContractAttribute(ConfigurationName="ERP.ERPGWSoap")] + public interface ERPGWSoap + { + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/Draft", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task DraftAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/Save", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task SaveAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/Submit", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task SubmitAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/Audit", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task AuditAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ExecuteBillQuery", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task ExecuteBillQueryAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/Push", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task PushAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ExecuteOperation", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task ExecuteOperationAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/UnAudit", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task UnAuditAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/Delete", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task DeleteAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/BatchSave", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task BatchSaveAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/WorkflowAudit", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task WorkflowAuditAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/CancelAssign", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task CancelAssignAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/Allocate", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task AllocateAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/CancelAllocate", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task CancelAllocateAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/GroupSave", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task GroupSaveAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/QueryGroupInfo", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task QueryGroupInfoAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/GroupDelete", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task GroupDeleteAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/SaveMaterial", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task SaveMaterialAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/WebApiSale", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task WebApiSaleAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/AR_receivableY", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task AR_receivableYAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/SelMaterial", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task SelMaterialAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/SetJdture", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task SetJdtureAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/Selects", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task SelectsAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/K3Client", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task K3ClientAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/CkZck", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task CkZckAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/SerBom", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task SerBomAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/OricoYG", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task OricoYGAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/OricoBM", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task OricoBMAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/OricoWLFZ", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task OricoWLFZAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IdOricoWLFZ", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task IdOricoWLFZAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/OricoGYS", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task OricoGYSAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/Dw", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task DwAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/Sktj", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task SktjAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/Fktj", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task FktjAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/Jsfs", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task JsfsAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/Jsbb", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task JsbbAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/HL", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task HLAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/SL", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task SLAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/CreateVoucher", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task CreateVoucherAsync(ERP.VoucherInfo[] param); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/CreatePo_InStock", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task CreatePo_InStockAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/CreateStockSearch", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task CreateStockSearchAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/CreateSale", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task CreateSaleAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/CreateShopSale", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task CreateShopSaleAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/CreateSaleMerge", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task CreateSaleMergeAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/CreateSaleShopFH", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task CreateSaleShopFHAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/REQUIREMENTORDER", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task REQUIREMENTORDERAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/Zzjxqd115", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task Zzjxqd115Async(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/PoBill", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task PoBillAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/SaleLock", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task SaleLockAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/Outsource", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task OutsourceAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/SaleReturn", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task SaleReturnAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/Misdelivery", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task MisdeliveryAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/StockCountLoss", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task StockCountLossAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/StockCountGain", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task StockCountGainAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/OtherRecAble", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task OtherRecAbleAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/OUTSTOCK", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task OUTSTOCKAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/Purchase_Rk", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task Purchase_RkAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/PRD_MO_Rk", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task PRD_MO_RkAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/生产订单创建", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task 生产订单创建Async(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/PUR_MRB", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task PUR_MRBAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/Pro_s", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task Pro_sAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/Otsc_s", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task Otsc_sAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/MesFh_Rk", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task MesFh_RkAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/MesSavaTransferDirect", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task MesSavaTransferDirectAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/MesPd", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task MesPdAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/Miscellaneous", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task MiscellaneousAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/LLDel", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task LLDelAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/MesFbsdb", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task MesFbsdbAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/STK_InStock", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task STK_InStockAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/K3Del", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task K3DelAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/K3Lock", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task K3LockAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/RETURNNOTICE", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task RETURNNOTICEAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/K3ProDel", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task K3ProDelAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/Ops_STK_InStock", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task Ops_STK_InStockAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/AP_Payable", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task AP_PayableAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/AR_receivable", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task AR_receivableAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/JstPd", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task JstPdAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/APPAYBILL", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task APPAYBILLAsync(string json); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ValidateSystem", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task ValidateSystemAsync(string userName, string pwd, string ERPid, string id); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ValidateToken", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)] + System.Threading.Tasks.Task ValidateTokenAsync(string token); + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.2.0-preview1.23462.5")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://tempuri.org/")] + public partial class VoucherInfo + { + + private string aCCESSTOKENField; + + private string fVOUCHERBILLField; + + private string fACCOUNTBOOKIDField; + + private string fACCBOOKORGIDField; + + private System.DateTime fDATEField; + + private string fVOUCHERGROUPIDField; + + private string fATTACHMENTSField; + + private string fVOUCHERGROUPNOField; + + private credentialDetail[] vOUCHERDETAILSField; + + /// + [System.Xml.Serialization.XmlElementAttribute(Order=0)] + public string ACCESSTOKEN + { + get + { + return this.aCCESSTOKENField; + } + set + { + this.aCCESSTOKENField = value; + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Order=1)] + public string FVOUCHERBILL + { + get + { + return this.fVOUCHERBILLField; + } + set + { + this.fVOUCHERBILLField = value; + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Order=2)] + public string FACCOUNTBOOKID + { + get + { + return this.fACCOUNTBOOKIDField; + } + set + { + this.fACCOUNTBOOKIDField = value; + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Order=3)] + public string FACCBOOKORGID + { + get + { + return this.fACCBOOKORGIDField; + } + set + { + this.fACCBOOKORGIDField = value; + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Order=4)] + public System.DateTime FDATE + { + get + { + return this.fDATEField; + } + set + { + this.fDATEField = value; + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Order=5)] + public string FVOUCHERGROUPID + { + get + { + return this.fVOUCHERGROUPIDField; + } + set + { + this.fVOUCHERGROUPIDField = value; + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Order=6)] + public string FATTACHMENTS + { + get + { + return this.fATTACHMENTSField; + } + set + { + this.fATTACHMENTSField = value; + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Order=7)] + public string FVOUCHERGROUPNO + { + get + { + return this.fVOUCHERGROUPNOField; + } + set + { + this.fVOUCHERGROUPNOField = value; + } + } + + /// + [System.Xml.Serialization.XmlArrayAttribute(Order=8)] + public credentialDetail[] VOUCHERDETAILS + { + get + { + return this.vOUCHERDETAILSField; + } + set + { + this.vOUCHERDETAILSField = value; + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.2.0-preview1.23462.5")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://tempuri.org/")] + public partial class credentialDetail + { + + private string fEXPLANATIONField; + + private string fSubordinateUnitField; + + private string fBankAccountField; + + private string fACCOUNTIDField; + + private double fDEBITField; + + private double fCREDITField; + + /// + [System.Xml.Serialization.XmlElementAttribute(Order=0)] + public string FEXPLANATION + { + get + { + return this.fEXPLANATIONField; + } + set + { + this.fEXPLANATIONField = value; + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Order=1)] + public string FSubordinateUnit + { + get + { + return this.fSubordinateUnitField; + } + set + { + this.fSubordinateUnitField = value; + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Order=2)] + public string FBankAccount + { + get + { + return this.fBankAccountField; + } + set + { + this.fBankAccountField = value; + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Order=3)] + public string FACCOUNTID + { + get + { + return this.fACCOUNTIDField; + } + set + { + this.fACCOUNTIDField = value; + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Order=4)] + public double FDEBIT + { + get + { + return this.fDEBITField; + } + set + { + this.fDEBITField = value; + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Order=5)] + public double FCREDIT + { + get + { + return this.fCREDITField; + } + set + { + this.fCREDITField = value; + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.2.0-preview1.23462.5")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://tempuri.org/")] + public partial class AccessResulDetail + { + + private string codeField; + + private string messageField; + + private string billNOField; + + private string yidField; + + /// + [System.Xml.Serialization.XmlElementAttribute(Order=0)] + public string Code + { + get + { + return this.codeField; + } + set + { + this.codeField = value; + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Order=1)] + public string Message + { + get + { + return this.messageField; + } + set + { + this.messageField = value; + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Order=2)] + public string BillNO + { + get + { + return this.billNOField; + } + set + { + this.billNOField = value; + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Order=3)] + public string Yid + { + get + { + return this.yidField; + } + set + { + this.yidField = value; + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.2.0-preview1.23462.5")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://tempuri.org/")] + public partial class AccessResult + { + + private string codeField; + + private string messageField; + + private AccessResulDetail[] detailsField; + + private string accessTokenField; + + /// + [System.Xml.Serialization.XmlElementAttribute(Order=0)] + public string Code + { + get + { + return this.codeField; + } + set + { + this.codeField = value; + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Order=1)] + public string Message + { + get + { + return this.messageField; + } + set + { + this.messageField = value; + } + } + + /// + [System.Xml.Serialization.XmlArrayAttribute(Order=2)] + public AccessResulDetail[] Details + { + get + { + return this.detailsField; + } + set + { + this.detailsField = value; + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Order=3)] + public string AccessToken + { + get + { + return this.accessTokenField; + } + set + { + this.accessTokenField = value; + } + } + } + + [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.2.0-preview1.23462.5")] + public interface ERPGWSoapChannel : ERP.ERPGWSoap, System.ServiceModel.IClientChannel + { + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.2.0-preview1.23462.5")] + public partial class ERPGWSoapClient : System.ServiceModel.ClientBase, ERP.ERPGWSoap + { + + /// + /// 实现此分部方法,配置服务终结点。 + /// + /// 要配置的终结点 + /// 客户端凭据 + static partial void ConfigureEndpoint(System.ServiceModel.Description.ServiceEndpoint serviceEndpoint, System.ServiceModel.Description.ClientCredentials clientCredentials); + + public ERPGWSoapClient(EndpointConfiguration endpointConfiguration) : + base(ERPGWSoapClient.GetBindingForEndpoint(endpointConfiguration), ERPGWSoapClient.GetEndpointAddress(endpointConfiguration)) + { + this.Endpoint.Name = endpointConfiguration.ToString(); + ConfigureEndpoint(this.Endpoint, this.ClientCredentials); + } + + public ERPGWSoapClient(EndpointConfiguration endpointConfiguration, string remoteAddress) : + base(ERPGWSoapClient.GetBindingForEndpoint(endpointConfiguration), new System.ServiceModel.EndpointAddress(remoteAddress)) + { + this.Endpoint.Name = endpointConfiguration.ToString(); + ConfigureEndpoint(this.Endpoint, this.ClientCredentials); + } + + public ERPGWSoapClient(EndpointConfiguration endpointConfiguration, System.ServiceModel.EndpointAddress remoteAddress) : + base(ERPGWSoapClient.GetBindingForEndpoint(endpointConfiguration), remoteAddress) + { + this.Endpoint.Name = endpointConfiguration.ToString(); + ConfigureEndpoint(this.Endpoint, this.ClientCredentials); + } + + public ERPGWSoapClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : + base(binding, remoteAddress) + { + } + + public System.Threading.Tasks.Task DraftAsync(string json) + { + return base.Channel.DraftAsync(json); + } + + public System.Threading.Tasks.Task SaveAsync(string json) + { + return base.Channel.SaveAsync(json); + } + + public System.Threading.Tasks.Task SubmitAsync(string json) + { + return base.Channel.SubmitAsync(json); + } + + public System.Threading.Tasks.Task AuditAsync(string json) + { + return base.Channel.AuditAsync(json); + } + + public System.Threading.Tasks.Task ExecuteBillQueryAsync(string json) + { + return base.Channel.ExecuteBillQueryAsync(json); + } + + public System.Threading.Tasks.Task PushAsync(string json) + { + return base.Channel.PushAsync(json); + } + + public System.Threading.Tasks.Task ExecuteOperationAsync(string json) + { + return base.Channel.ExecuteOperationAsync(json); + } + + public System.Threading.Tasks.Task UnAuditAsync(string json) + { + return base.Channel.UnAuditAsync(json); + } + + public System.Threading.Tasks.Task DeleteAsync(string json) + { + return base.Channel.DeleteAsync(json); + } + + public System.Threading.Tasks.Task BatchSaveAsync(string json) + { + return base.Channel.BatchSaveAsync(json); + } + + public System.Threading.Tasks.Task WorkflowAuditAsync(string json) + { + return base.Channel.WorkflowAuditAsync(json); + } + + public System.Threading.Tasks.Task CancelAssignAsync(string json) + { + return base.Channel.CancelAssignAsync(json); + } + + public System.Threading.Tasks.Task AllocateAsync(string json) + { + return base.Channel.AllocateAsync(json); + } + + public System.Threading.Tasks.Task CancelAllocateAsync(string json) + { + return base.Channel.CancelAllocateAsync(json); + } + + public System.Threading.Tasks.Task GroupSaveAsync(string json) + { + return base.Channel.GroupSaveAsync(json); + } + + public System.Threading.Tasks.Task QueryGroupInfoAsync(string json) + { + return base.Channel.QueryGroupInfoAsync(json); + } + + public System.Threading.Tasks.Task GroupDeleteAsync(string json) + { + return base.Channel.GroupDeleteAsync(json); + } + + public System.Threading.Tasks.Task SaveMaterialAsync(string json) + { + return base.Channel.SaveMaterialAsync(json); + } + + public System.Threading.Tasks.Task WebApiSaleAsync(string json) + { + return base.Channel.WebApiSaleAsync(json); + } + + public System.Threading.Tasks.Task AR_receivableYAsync(string json) + { + return base.Channel.AR_receivableYAsync(json); + } + + public System.Threading.Tasks.Task SelMaterialAsync(string json) + { + return base.Channel.SelMaterialAsync(json); + } + + public System.Threading.Tasks.Task SetJdtureAsync(string json) + { + return base.Channel.SetJdtureAsync(json); + } + + public System.Threading.Tasks.Task SelectsAsync(string json) + { + return base.Channel.SelectsAsync(json); + } + + public System.Threading.Tasks.Task K3ClientAsync(string json) + { + return base.Channel.K3ClientAsync(json); + } + + public System.Threading.Tasks.Task CkZckAsync(string json) + { + return base.Channel.CkZckAsync(json); + } + + public System.Threading.Tasks.Task SerBomAsync(string json) + { + return base.Channel.SerBomAsync(json); + } + + public System.Threading.Tasks.Task OricoYGAsync(string json) + { + return base.Channel.OricoYGAsync(json); + } + + public System.Threading.Tasks.Task OricoBMAsync(string json) + { + return base.Channel.OricoBMAsync(json); + } + + public System.Threading.Tasks.Task OricoWLFZAsync(string json) + { + return base.Channel.OricoWLFZAsync(json); + } + + public System.Threading.Tasks.Task IdOricoWLFZAsync(string json) + { + return base.Channel.IdOricoWLFZAsync(json); + } + + public System.Threading.Tasks.Task OricoGYSAsync(string json) + { + return base.Channel.OricoGYSAsync(json); + } + + public System.Threading.Tasks.Task DwAsync(string json) + { + return base.Channel.DwAsync(json); + } + + public System.Threading.Tasks.Task SktjAsync(string json) + { + return base.Channel.SktjAsync(json); + } + + public System.Threading.Tasks.Task FktjAsync(string json) + { + return base.Channel.FktjAsync(json); + } + + public System.Threading.Tasks.Task JsfsAsync(string json) + { + return base.Channel.JsfsAsync(json); + } + + public System.Threading.Tasks.Task JsbbAsync(string json) + { + return base.Channel.JsbbAsync(json); + } + + public System.Threading.Tasks.Task HLAsync(string json) + { + return base.Channel.HLAsync(json); + } + + public System.Threading.Tasks.Task SLAsync(string json) + { + return base.Channel.SLAsync(json); + } + + public System.Threading.Tasks.Task CreateVoucherAsync(ERP.VoucherInfo[] param) + { + return base.Channel.CreateVoucherAsync(param); + } + + public System.Threading.Tasks.Task CreatePo_InStockAsync(string json) + { + return base.Channel.CreatePo_InStockAsync(json); + } + + public System.Threading.Tasks.Task CreateStockSearchAsync(string json) + { + return base.Channel.CreateStockSearchAsync(json); + } + + public System.Threading.Tasks.Task CreateSaleAsync(string json) + { + return base.Channel.CreateSaleAsync(json); + } + + public System.Threading.Tasks.Task CreateShopSaleAsync(string json) + { + return base.Channel.CreateShopSaleAsync(json); + } + + public System.Threading.Tasks.Task CreateSaleMergeAsync(string json) + { + return base.Channel.CreateSaleMergeAsync(json); + } + + public System.Threading.Tasks.Task CreateSaleShopFHAsync(string json) + { + return base.Channel.CreateSaleShopFHAsync(json); + } + + public System.Threading.Tasks.Task REQUIREMENTORDERAsync(string json) + { + return base.Channel.REQUIREMENTORDERAsync(json); + } + + public System.Threading.Tasks.Task Zzjxqd115Async(string json) + { + return base.Channel.Zzjxqd115Async(json); + } + + public System.Threading.Tasks.Task PoBillAsync(string json) + { + return base.Channel.PoBillAsync(json); + } + + public System.Threading.Tasks.Task SaleLockAsync(string json) + { + return base.Channel.SaleLockAsync(json); + } + + public System.Threading.Tasks.Task OutsourceAsync(string json) + { + return base.Channel.OutsourceAsync(json); + } + + public System.Threading.Tasks.Task SaleReturnAsync(string json) + { + return base.Channel.SaleReturnAsync(json); + } + + public System.Threading.Tasks.Task MisdeliveryAsync(string json) + { + return base.Channel.MisdeliveryAsync(json); + } + + public System.Threading.Tasks.Task StockCountLossAsync(string json) + { + return base.Channel.StockCountLossAsync(json); + } + + public System.Threading.Tasks.Task StockCountGainAsync(string json) + { + return base.Channel.StockCountGainAsync(json); + } + + public System.Threading.Tasks.Task OtherRecAbleAsync(string json) + { + return base.Channel.OtherRecAbleAsync(json); + } + + public System.Threading.Tasks.Task OUTSTOCKAsync(string json) + { + return base.Channel.OUTSTOCKAsync(json); + } + + public System.Threading.Tasks.Task Purchase_RkAsync(string json) + { + return base.Channel.Purchase_RkAsync(json); + } + + public System.Threading.Tasks.Task PRD_MO_RkAsync(string json) + { + return base.Channel.PRD_MO_RkAsync(json); + } + + public System.Threading.Tasks.Task 生产订单创建Async(string json) + { + return base.Channel.生产订单创建Async(json); + } + + public System.Threading.Tasks.Task PUR_MRBAsync(string json) + { + return base.Channel.PUR_MRBAsync(json); + } + + public System.Threading.Tasks.Task Pro_sAsync(string json) + { + return base.Channel.Pro_sAsync(json); + } + + public System.Threading.Tasks.Task Otsc_sAsync(string json) + { + return base.Channel.Otsc_sAsync(json); + } + + public System.Threading.Tasks.Task MesFh_RkAsync(string json) + { + return base.Channel.MesFh_RkAsync(json); + } + + public System.Threading.Tasks.Task MesSavaTransferDirectAsync(string json) + { + return base.Channel.MesSavaTransferDirectAsync(json); + } + + public System.Threading.Tasks.Task MesPdAsync(string json) + { + return base.Channel.MesPdAsync(json); + } + + public System.Threading.Tasks.Task MiscellaneousAsync(string json) + { + return base.Channel.MiscellaneousAsync(json); + } + + public System.Threading.Tasks.Task LLDelAsync(string json) + { + return base.Channel.LLDelAsync(json); + } + + public System.Threading.Tasks.Task MesFbsdbAsync(string json) + { + return base.Channel.MesFbsdbAsync(json); + } + + public System.Threading.Tasks.Task STK_InStockAsync(string json) + { + return base.Channel.STK_InStockAsync(json); + } + + public System.Threading.Tasks.Task K3DelAsync(string json) + { + return base.Channel.K3DelAsync(json); + } + + public System.Threading.Tasks.Task K3LockAsync(string json) + { + return base.Channel.K3LockAsync(json); + } + + public System.Threading.Tasks.Task RETURNNOTICEAsync(string json) + { + return base.Channel.RETURNNOTICEAsync(json); + } + + public System.Threading.Tasks.Task K3ProDelAsync(string json) + { + return base.Channel.K3ProDelAsync(json); + } + + public System.Threading.Tasks.Task Ops_STK_InStockAsync(string json) + { + return base.Channel.Ops_STK_InStockAsync(json); + } + + public System.Threading.Tasks.Task AP_PayableAsync(string json) + { + return base.Channel.AP_PayableAsync(json); + } + + public System.Threading.Tasks.Task AR_receivableAsync(string json) + { + return base.Channel.AR_receivableAsync(json); + } + + public System.Threading.Tasks.Task JstPdAsync(string json) + { + return base.Channel.JstPdAsync(json); + } + + public System.Threading.Tasks.Task APPAYBILLAsync(string json) + { + return base.Channel.APPAYBILLAsync(json); + } + + public System.Threading.Tasks.Task ValidateSystemAsync(string userName, string pwd, string ERPid, string id) + { + return base.Channel.ValidateSystemAsync(userName, pwd, ERPid, id); + } + + public System.Threading.Tasks.Task ValidateTokenAsync(string token) + { + return base.Channel.ValidateTokenAsync(token); + } + + public virtual System.Threading.Tasks.Task OpenAsync() + { + return System.Threading.Tasks.Task.Factory.FromAsync(((System.ServiceModel.ICommunicationObject)(this)).BeginOpen(null, null), new System.Action(((System.ServiceModel.ICommunicationObject)(this)).EndOpen)); + } + + private static System.ServiceModel.Channels.Binding GetBindingForEndpoint(EndpointConfiguration endpointConfiguration) + { + if ((endpointConfiguration == EndpointConfiguration.ERPGWSoap)) + { + System.ServiceModel.BasicHttpBinding result = new System.ServiceModel.BasicHttpBinding(); + result.MaxBufferSize = int.MaxValue; + result.ReaderQuotas = System.Xml.XmlDictionaryReaderQuotas.Max; + result.MaxReceivedMessageSize = int.MaxValue; + result.AllowCookies = true; + return result; + } + if ((endpointConfiguration == EndpointConfiguration.ERPGWSoap12)) + { + System.ServiceModel.Channels.CustomBinding result = new System.ServiceModel.Channels.CustomBinding(); + System.ServiceModel.Channels.TextMessageEncodingBindingElement textBindingElement = new System.ServiceModel.Channels.TextMessageEncodingBindingElement(); + textBindingElement.MessageVersion = System.ServiceModel.Channels.MessageVersion.CreateVersion(System.ServiceModel.EnvelopeVersion.Soap12, System.ServiceModel.Channels.AddressingVersion.None); + result.Elements.Add(textBindingElement); + System.ServiceModel.Channels.HttpTransportBindingElement httpBindingElement = new System.ServiceModel.Channels.HttpTransportBindingElement(); + httpBindingElement.AllowCookies = true; + httpBindingElement.MaxBufferSize = int.MaxValue; + httpBindingElement.MaxReceivedMessageSize = int.MaxValue; + result.Elements.Add(httpBindingElement); + return result; + } + throw new System.InvalidOperationException(string.Format("找不到名称为“{0}”的终结点。", endpointConfiguration)); + } + + private static System.ServiceModel.EndpointAddress GetEndpointAddress(EndpointConfiguration endpointConfiguration) + { + if ((endpointConfiguration == EndpointConfiguration.ERPGWSoap)) + { + return new System.ServiceModel.EndpointAddress("http://119.23.206.129/K3cloud/erpgw.asmx"); + } + if ((endpointConfiguration == EndpointConfiguration.ERPGWSoap12)) + { + return new System.ServiceModel.EndpointAddress("http://119.23.206.129/K3cloud/erpgw.asmx"); + } + throw new System.InvalidOperationException(string.Format("找不到名称为“{0}”的终结点。", endpointConfiguration)); + } + + public enum EndpointConfiguration + { + + ERPGWSoap, + + ERPGWSoap12, + } + } +} diff --git a/src/BarCode.Web.Core/Dto/Box/BoxDetailsResponse.cs b/src/BarCode.Web.Core/Dto/Box/BoxDetailsResponse.cs new file mode 100644 index 0000000..bf1c810 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Box/BoxDetailsResponse.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Core.Dto.Box +{ + /// + /// 箱明细信息 + /// + public class BoxDetailsResponse + { + /// + /// ID + /// + public int Id { get; set; } + /// + /// 物料编码 + /// + public string MaterialNumber { get; set; } = ""; + /// + /// 数量(装箱数量) + /// + public decimal Qty { get; set; } = 0; + /// + /// 序列号 + /// + public List SerialNumbers { get; set; } = new List(); + } +} diff --git a/src/BarCode.Web.Core/Dto/Box/BoxInfoResponse.cs b/src/BarCode.Web.Core/Dto/Box/BoxInfoResponse.cs new file mode 100644 index 0000000..83963ed --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Box/BoxInfoResponse.cs @@ -0,0 +1,83 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Core.Dto.Box +{ + /// + /// 箱列表返回信息 + /// + public class BoxInfoResponse + { + /// + /// ID + /// + public int Id { get; set; } + /// + /// 明细Id(可能为0) + /// + public int DetailId { get; set; } = 0; + /// + /// 箱编号 + /// + public string BoxBillNo { get; set; } = string.Empty; + /// + /// 供应商或组织 + /// + public string SupplierOrOrg { get; set; } = string.Empty; + /// + /// 物料规格型号 + /// + public string Specifications { get; set; } = string.Empty; + /// + /// 物料编码 + /// + public string MaterialNumber { get; set; } = string.Empty; + /// + /// 物料名称 + /// + public string MaterialName { get; set; } = string.Empty; + /// + /// 物料条码 + /// + public string BarCode { get; set; } = string.Empty; + /// + /// 序列号 + /// + public string SerialNumbers { get; set; } = string.Empty; + /// + /// 数量(装箱数量) + /// + public decimal Qty { get; set; } = 0; + /// + /// 箱状态 + /// + public string Status { get; set; } = string.Empty; + /// + /// 装箱开始时间 + /// + public string CartonBeginTime { get; set; } = string.Empty; + /// + /// 装箱结束时间(完成装箱时间) + /// + public string CartonEndTime { get; set; } = string.Empty; + /// + /// 装箱人 + /// + public string CartonUser { get; set; } = string.Empty; + /// + /// 生成人 + /// + public string Creator { get; set; } = string.Empty; + /// + /// 创建时间 + /// + public string CreateTime { get; set; } = string.Empty; + /// + /// 箱号打印次数 + /// + public int PrintNumber { get; set; } = 0; + } +} diff --git a/src/BarCode.Web.Core/Dto/Box/BoxQueryRequest.cs b/src/BarCode.Web.Core/Dto/Box/BoxQueryRequest.cs new file mode 100644 index 0000000..82c9a6b --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Box/BoxQueryRequest.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Core.Dto.Box +{ + /// + /// 箱信息列表 + /// + public class BoxQueryRequest : PaginationBaseRequestDto + { + /// + /// 组织Code + /// + [Required(ErrorMessage = "组织不能为空")] + public string OrgCode { get; set; } = ""; + /// + /// 箱号(开始) + /// + public string BoxBeginNo { get; set; } = string.Empty; + /// + /// 箱号(结束) + /// + public string BoxEndNo { get; set; } = string.Empty; + /// + /// 箱状态 + /// + public int? Status { get; set; } + /// + /// 创建时间 + /// + public DateTime? CreateBeginDate { get; set; } = null; + /// + /// 创建时间 + /// + public DateTime? CreateEndDate { get; set; } = null; + /// + /// 装箱完成时间 + /// + public DateTime? CartonBeginDate { get; set; } = null; + /// + /// 装箱完成时间 + /// + public DateTime? CartonEndDate { get; set; } = null; + /// + /// 物料编码/名称/型号规格 + /// + public string MaterialNumber { get; set; } = string.Empty; + /// + /// 序列号 + /// + public List SerialNumbers { get; set; } = new List(); + /// + /// 箱号打印状态 打印 true 未打印false + /// + public bool? BoxPrintStatus { get; set; } = null; + /// + /// 供应商或组织 + /// + public string SupplierOrOrg { get; set; } = string.Empty; + /// + /// 生成人 + /// + public string CreateUser { get; set; } = string.Empty; + } +} diff --git a/src/BarCode.Web.Core/Dto/Box/BoxResponse.cs b/src/BarCode.Web.Core/Dto/Box/BoxResponse.cs new file mode 100644 index 0000000..b1688b1 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Box/BoxResponse.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Core.Dto.Box +{ + /// + /// 箱信息 + /// + public class BoxResponse + { + /// + /// ID + /// + public int Id { get; set; } = 0; + /// + /// 箱编号 + /// + public string BoxBillNo { get; set; } = ""; + /// + /// 供应商Code + /// + public string SupplierCode { get; set; } = ""; + /// + /// 组织Code + /// + public string OrgCode { get; set; } = ""; + /// + /// 箱状态 + /// + public string Status { get; set; } = string.Empty; + /// + /// 装箱开始时间 + /// + public string CartonBeginTime { get; set; } = string.Empty; + /// + /// 装箱结束时间(完成装箱时间) + /// + public string CartonEndTime { get; set; } = string.Empty; + /// + /// 完成装箱用户 + /// + public int CartonUserId { get; set; } = 0; + /// + /// 箱子创建用户 + /// + public int CreatorId { get; set; } = 0; + /// + /// 创建时间 + /// + public string CreateTime { get; set; } = string.Empty; + /// + /// 箱号打印次数 + /// + public int PrintNumber { get; set; } = 0; + /// + /// 最新打印时间 + /// + public string PrintTime { get; set; } + /// + /// 明细 + /// + public List Details { get; set; } = new List(); + } +} diff --git a/src/BarCode.Web.Core/Dto/Box/DeleteBoxSerialNumberRequest.cs b/src/BarCode.Web.Core/Dto/Box/DeleteBoxSerialNumberRequest.cs new file mode 100644 index 0000000..2ee366c --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Box/DeleteBoxSerialNumberRequest.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Core.Dto.Box +{ + /// + /// 删除箱和序列码绑定 + /// + public class DeleteBoxSerialNumberRequest + { + /// + /// 箱Id + /// + [Required(ErrorMessage = "箱不能为空")] + public int BoxId { get; set; } + /// + /// 物料编码 + /// + [Required(ErrorMessage = "物料不能为空")] + public string MaterialNumber { get; set; } = string.Empty; + /// + /// 序列号 + /// + [Required(ErrorMessage = "序列号不能为空")] + public string SerialNumber { get; set; } = string.Empty; + } +} diff --git a/src/BarCode.Web.Core/Dto/Box/GenerateBoxRequest.cs b/src/BarCode.Web.Core/Dto/Box/GenerateBoxRequest.cs new file mode 100644 index 0000000..9403ecb --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Box/GenerateBoxRequest.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Core.Dto.Box +{ + /// + /// 生成箱码 + /// + public class GenerateBoxRequest + { + /// + /// 组织Code + /// + [Required(ErrorMessage = "组织不能为空")] + public string OrgCode { get; set; } = ""; + /// + /// 生成数量 + /// + [Required(ErrorMessage = "数量不能为空")] + [Range(0.0000000001, 10000000000, ErrorMessage = "0<数量<=10000000000")] + public int Number { get; set; } = 0; + } +} diff --git a/src/BarCode.Web.Core/Dto/Box/SaveBoxDetailsRequest.cs b/src/BarCode.Web.Core/Dto/Box/SaveBoxDetailsRequest.cs new file mode 100644 index 0000000..a970df1 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Box/SaveBoxDetailsRequest.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Core.Dto.Box +{ + /// + /// 箱信息明细 + /// + public class SaveBoxDetailsRequest + { + /// + /// 物料编码 + /// + [Required(ErrorMessage = "物料不能为空")] + public string MaterialNumber { get; set; } = string.Empty; + /// + /// 序列号 + /// + [Required(ErrorMessage = "序列号不能为空")] + public string SerialNumber { get; set; } = string.Empty; + } +} diff --git a/src/BarCode.Web.Core/Dto/Box/SaveBoxRequest.cs b/src/BarCode.Web.Core/Dto/Box/SaveBoxRequest.cs new file mode 100644 index 0000000..ac93314 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Box/SaveBoxRequest.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Core.Dto.Box +{ + /// + /// 保存箱信息(装箱保存,完成装箱) + /// + public class SaveBoxRequest + { + /// + /// 箱Id + /// + [Required(ErrorMessage = "箱不能为空")] + public int BoxId { get; set; } = 0; + /// + /// 是否完成装箱(保存 false 完成装箱 true) + /// + [Required(ErrorMessage = "装箱状态不能为空")] + public bool IsCarton { get; set; } = false; + /// + /// 明细信息 + /// + public List Details { get; set; } = new List(); + } +} diff --git a/src/BarCode.Web.Core/Dto/Box/WmsBoxRequest.cs b/src/BarCode.Web.Core/Dto/Box/WmsBoxRequest.cs new file mode 100644 index 0000000..b71c6b5 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Box/WmsBoxRequest.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.Box +{ + /// + /// 老ops箱信息请求 + /// + public class WmsBoxRequest + { + /// + /// + /// + public WmsBoxRequest() { } + /// + /// + /// + /// + /// + public WmsBoxRequest(DateTime strartTime, DateTime endTime) + { + this.StrartTime = strartTime; + this.EndTime = endTime; + } + /// + /// 开始时间 + /// + public DateTime? StrartTime { get; set; } = null; + /// + /// 结束时间 + /// + public DateTime? EndTime { get; set; } = null; + /// + /// 箱号 + /// + public string? BoxBillNo { get; set; } = null; + /// + /// 页码 + /// + public int Page { get; set; } = 1; + /// + /// 每页条数 + /// + public int Limit { get; set; } = 10000000; + } +} diff --git a/src/BarCode.Web.Core/Dto/Box/WmsBoxResponse.cs b/src/BarCode.Web.Core/Dto/Box/WmsBoxResponse.cs new file mode 100644 index 0000000..cd091dc --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Box/WmsBoxResponse.cs @@ -0,0 +1,95 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.Box +{ + /// + /// 老ops箱信息 + /// + public class WmsBoxResponse + { + /// + /// 对应老OPS的箱ID + /// + [JsonProperty("CartonId")] + public int OpsBoxId { get; set; } + /// + /// 箱编号(老OPS生成的箱号) + /// + [JsonProperty("CartonNo")] + public string BoxBillNo { get; set; } + /// + /// 供应商Id + /// + [JsonProperty("GysNo")] + public int? SupplierId { get; set; } + /// + /// 组织Id + /// + [JsonProperty("orgId")] + public int? OrgId { get; set; } + /// + /// 完成装箱时间 + /// + [JsonProperty("CompleteCartonTime")] + public DateTime CompleteCartonTime { get; set; } = DateTime.Now; + /// + /// 完成装箱用户 + /// + [JsonProperty("BoxUser")] + public string CompleteCartonUser { get; set; } + /// + /// 箱子创建用户 + /// + [JsonProperty("Create_user")] + public string CreateUser { get; set; } + /// + /// 创建时间(对应老OPS的创建时间) + /// + [JsonProperty("cartonCreateTime")] + public DateTime CreateTime { get; set; } = DateTime.Now; + /// + /// 明细 + /// + [JsonProperty("BoxReturnDetails")] + public List Details { get; set; } = new List(); + } + public class OpsSerialNumbersResponse + { + /// + /// 序列号 + /// + [JsonProperty("sn")] + public string SerialNumber { get; set; } + /// + /// 序列号生成时间 + /// + [JsonProperty("barCreateTime")] + public DateTime? BarCreateTime { get; set; } = DateTime.Now; + /// + /// 序列号生成用户 + /// + [JsonProperty("barCereateUser")] + public string BarCereateUser { get; set; } + + } + public class OpsBoxDetailsResponse { + /// + /// 物料编码 + /// + [JsonProperty("FMaterialNo")] + public string MaterialNumber { get; set; } + /// + /// 数量(装箱数量) + /// + [JsonProperty("Qty")] + public decimal Qty { get; set; } + /// + /// 序列号集 + /// + [JsonProperty("SerialNumbers")] + public List SerialNumbers { get; set; } = new List(); + } +} diff --git a/src/BarCode.Web.Core/Dto/BoxMark/BoxMarkQueryRequest.cs b/src/BarCode.Web.Core/Dto/BoxMark/BoxMarkQueryRequest.cs new file mode 100644 index 0000000..6598e9f --- /dev/null +++ b/src/BarCode.Web.Core/Dto/BoxMark/BoxMarkQueryRequest.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Text; + +namespace BarCode.Web.Core.Dto +{ + /// + /// 请求对象 + /// + public class BoxMarkQueryRequest : PaginationBaseRequestDto + { + /// + /// 组织Code + /// + [Required(ErrorMessage = "组织不能为空")] + public string OrgCode { get; set; } = ""; + /// + /// 订单编号集合字符串 + /// + public string OrderBillNos { get; set; } = string.Empty; + + /// + /// 物料三件套搜索 + /// + public string Material { get; set; } = string.Empty; + + /// + /// 开始的箱唛编号 + /// + public string BeginBillNo { get; set; } = string.Empty; + + /// + /// 结束的箱唛编号 + /// + public string EndBillNo { get; set; } = string.Empty; + + /// + /// 操作人 + /// + public string Creator { get; set; } = string.Empty; + + /// + /// 生成开始时间 + /// + public DateTime? CreateBeginDate { get; set; } = null; + /// + /// 生成结束时间 + /// + public DateTime? CreateEndDate { get; set; } = null; + } +} diff --git a/src/BarCode.Web.Core/Dto/BoxMark/BoxMarkQueryResponse.cs b/src/BarCode.Web.Core/Dto/BoxMark/BoxMarkQueryResponse.cs new file mode 100644 index 0000000..51fe966 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/BoxMark/BoxMarkQueryResponse.cs @@ -0,0 +1,124 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto +{ + /// + /// 列表响应对象 + /// + public class BoxMarkQueryResponse + { + /// + /// 唯一ID + /// + public int Id { get; set; } + + /// + /// 明细编号ID + /// + public int DetailId { get; set; } + + /// + /// 箱唛编号 + /// + public string BillNo { get; set; } + + /// + /// 订单编号 + /// + public string OrderBillNo { get; set; } + + /// + /// 物料规格型号 + /// + public string Specifications { get; set; } + /// + /// 物料编码 + /// + public string MaterialNumber { get; set; } + + /// + /// 物料名称 + /// + public string MaterialName { get; set; } + + /// + /// 69条码 + /// + public string BarCode { get; set; } + + /// + /// 装箱数量 + /// + public decimal CratingQty { get; set; } + + /// + /// 装箱净重 + /// + public decimal CratingNetWeightQty { get; set; } + + /// + /// 装箱毛重 + /// + public decimal CratingGrossWeightQty { get; set; } + + /// + /// 尾箱数量 + /// + public decimal TailboxQty { get; set; } + + /// + /// 尾箱净重 + /// + public decimal TailboxNetWeightQty { get; set; } + + /// + /// 尾箱毛重 + /// + public decimal TailboxGrossWeightQty { get; set; } + + /// + /// 备注 + /// + public string Remark { get; set; } + + /// + /// 操作人 + /// + public string Creator { get; set; } + + /// + /// 创建时间(生成时间) + /// + public string CreateTime { get; set; } + + /// + /// 是否是尾箱 + /// + public bool IsTail { get; set; } + + /// + /// 装箱总数 + /// + public int BoxSortCount { get; set; } + + /// + /// 产品数量 + /// + public decimal ProductQty { get; set; } + + /// + /// 排序 + /// + public int Sort { get; set; } + /// + /// 流水号(开始) + /// + public Int64? BeginNumber { get; set; } = null; + /// + /// 流水号(结束) + /// + public Int64? EndNumber { get; set; } = null; + } +} diff --git a/src/BarCode.Web.Core/Dto/BoxMark/GenerateBoxMarkDto.cs b/src/BarCode.Web.Core/Dto/BoxMark/GenerateBoxMarkDto.cs new file mode 100644 index 0000000..a11834a --- /dev/null +++ b/src/BarCode.Web.Core/Dto/BoxMark/GenerateBoxMarkDto.cs @@ -0,0 +1,83 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Text; + +namespace BarCode.Web.Core.Dto +{ + /// + /// 生成箱唛dto + /// + public class GenerateBoxMarkDto + { + /// + /// 组织Code + /// + [Required(ErrorMessage = "组织不能为空")] + public string OrgCode { get; set; } = ""; + /// + /// 订单编号 + /// + /// + [Required(ErrorMessage = "订单编号不能为空")] + public string OrderBillNo { get; set; } = string.Empty; + + /// + /// 物料 + /// + [Required(ErrorMessage = "物料不能为空")] + public string MaterialNumber { get; set; } = string.Empty; + + /// + /// 产品数量 + /// + [Required(ErrorMessage = "产品数量不能为空")] + [Range(1, int.MaxValue, ErrorMessage = "产品数量不能为0")] + public decimal ProductQty { get; set; } + + /// + /// 装箱数量 + /// + [Required(ErrorMessage = "装箱数量不能为空")] + [Range(1, int.MaxValue, ErrorMessage = "装箱数量不能为0")] + public decimal CratingQty { get; set; } + + /// + /// 装箱净重 + /// + public decimal CratingNetWeightQty { get; set; } + + /// + /// 装箱毛重 + /// + public decimal CratingGrossWeightQty { get; set; } + + /// + /// 尾箱数量 + /// + public decimal TailboxQty { get; set; } + + /// + /// 尾箱净重 + /// + public decimal TailboxNetWeightQty { get; set; } + + /// + /// 尾箱毛重 + /// + public decimal TailboxGrossWeightQty { get; set; } + + /// + /// 备注 + /// + public string Remark { get; set; } = string.Empty; + /// + /// 流水号(开始) + /// + public Int64? BeginNumber { get; set; } = null; + /// + /// 流水号(结束) + /// + public Int64? EndNumber { get; set; } = null; + } +} diff --git a/src/BarCode.Web.Core/Dto/EnumStatusResponse.cs b/src/BarCode.Web.Core/Dto/EnumStatusResponse.cs new file mode 100644 index 0000000..7b8cd23 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/EnumStatusResponse.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto +{ + /// + /// 所有枚举信息 + /// + public class EnumStatusResponse + { + public EnumStatusResponse() { } + /// + /// 出库单类型 + /// + public Dictionary OutStockType { get; set; } = new Dictionary(); + /// + /// 移库单类型 + /// + public Dictionary MoveBoxType { get; set; } = new Dictionary(); + /// + /// 盘点结果类型 + /// + public Dictionary TakeStockType { get; set; } = new Dictionary(); + /// + /// 入库单类型 + /// + public Dictionary InstockType { get; set; } = new Dictionary(); + /// + /// 入库状态 + /// + public Dictionary InstockStatus { get; set; } = new Dictionary(); + /// + /// 类型:1为入库回退下架,2为出库回退上架 + /// + public Dictionary BackRecordType { get; set; } = new Dictionary(); + /// + /// 类型:1为入库,2为出库 + /// + public Dictionary InventoryInOutType { get; set; } = new Dictionary(); + /// + /// 单据类型 + /// + public Dictionary OrderType { get; set; } = new Dictionary(); + /// + /// 非采购上架方式 + /// + public Dictionary ShelfMethod { get; set; } = new Dictionary(); + /// + /// 下载导出订单类型 + /// + public Dictionary FileDownLoadOrderType { get; set; } = new Dictionary(); + /// + /// 下载导出状态 + /// + public Dictionary ExportStatus { get; set; } = new Dictionary(); + /// + /// 出入库方式:按箱或者按产品 + /// + public Dictionary InventoryInOutMethod { get; set; } = new Dictionary(); + /// + /// 出库状态 + /// + public Dictionary OutStockStatus { get; set; } = new Dictionary(); + /// + /// 同步金蝶状态 + /// + public Dictionary SyncStatus { get; set; } = new Dictionary(); + + } +} diff --git a/src/BarCode.Web.Core/Dto/Erp/Customer/ErpCustomerDto.cs b/src/BarCode.Web.Core/Dto/Erp/Customer/ErpCustomerDto.cs new file mode 100644 index 0000000..419c7bc --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Erp/Customer/ErpCustomerDto.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.Erp.Customer +{ + /// + /// 客户 + /// + public class ErpCustomerDto + { + /// + /// ID + /// + public int Id { get; set; } + + /// + /// 编码 + /// + public string Number { get; set; } + + /// + /// 名称 + /// + public string Name { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/Erp/ErpBaseDto.cs b/src/BarCode.Web.Core/Dto/Erp/ErpBaseDto.cs new file mode 100644 index 0000000..8cf96ed --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Erp/ErpBaseDto.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.Erp +{ + public class ErpBaseDto + { + public string Id { get; set; } + + public string Number { get; set; } + + public string Name { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/Erp/ErpBillQueryDto.cs b/src/BarCode.Web.Core/Dto/Erp/ErpBillQueryDto.cs new file mode 100644 index 0000000..8043889 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Erp/ErpBillQueryDto.cs @@ -0,0 +1,40 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.Erp +{ + /// + /// ERP:单据查询-dto + /// + public class ErpBillQueryDto + { + public ErpBillQueryDto() { } + + public ErpBillQueryDto(string accessToken) + { + this.AccessToken = accessToken; + } + public ErpBillQueryDto(string accessToken,string formid) + { + this.AccessToken = accessToken; + this.FormId = formid; + } + /// + /// 令牌 + /// + [JsonProperty(PropertyName = "ACCESSTOKEN")] + public string AccessToken { get; set; } + /// + /// 参数 + /// + [JsonProperty(PropertyName = "data")] + public string Data { get; set; } + /// + /// 参数(保存提交审核formId在外层) + /// + [JsonProperty(PropertyName = "formid")] + public string FormId { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/Erp/ErpBillQueryParamDto.cs b/src/BarCode.Web.Core/Dto/Erp/ErpBillQueryParamDto.cs new file mode 100644 index 0000000..ccdaa65 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Erp/ErpBillQueryParamDto.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.Erp +{ + /// + /// ERP:单据查询-参数-dto + /// + public class ErpBillQueryParamDto + { + public ErpBillQueryParamDto() { } + + public ErpBillQueryParamDto(string formId) + { + this.FormId = formId; + } + + /// + /// 业务对象表单Id(必录) + /// + public string FormId { get; set; } + /// + /// 需查询的字段key集合,字符串类型,格式:"key1,key2,..."(必录) 注(查询单据体内码,需加单据体Key和下划线,如:FEntryKey_FEntryId) + /// + public string FieldKeys { get; set; } + /// + /// 过滤条件,数组类型,如:[{"Left":"(","FieldName":"Field1","Compare":"=","Value":"111","Right":")","Logic":"AND"},{"Left":"(","FieldName":"Field2","Compare":"=","Value":"222","Right":")","Logic":""}] + /// + public string FilterString { get; set; } + + /// + /// 排序字段,字符串类型(非必录) + /// + public string OrderString { get; set; } + + /// + /// 返回总行数,整型(非必录) + /// + public int TopRowCount { get; set; } + /// + /// 开始行索引,整型(非必录) + /// + public int StartRow { get; set; } = 0; + /// + /// 最大行数,整型,不能超过10000(非必录) + /// + public int Limit { get; set; } = 1; + + /// + /// 表单所在的子系统内码,字符串类型(非必录) + /// + public string SubSystemId { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/Erp/ErpInStockResultDto.cs b/src/BarCode.Web.Core/Dto/Erp/ErpInStockResultDto.cs new file mode 100644 index 0000000..837e613 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Erp/ErpInStockResultDto.cs @@ -0,0 +1,92 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.Erp +{ + /// + /// ERP:入库单-统一响应对象 + /// + public class ErpInStockResultDto + { + /// + /// 单据编号 + /// + public string BillNo { get; set; } + /// + /// 组织 + /// + public int OrgId { get; set; } + + /// + /// erp的明细ID + /// + public int ErpDetailId { get; set; } + + /// + /// 组织编码 + /// + public string OrgCode { get; set; } + + /// + /// 供应商 + /// + public int SupplierId { get; set; } + + /// + /// 物料编码 + /// + public string MaterialNumber { get; set; } + + + /// + /// 仓库ID + /// + public int StockId { get; set; } + + /// + /// 仓库code + /// + public string StockCode { get; set; } + + /// + /// 数量 + /// + public decimal Qty { get; set; } + + /// + /// 出厂价 + /// + public decimal FactoryPrice { get; set; } + + /// + /// 已交数量(对应金蝶的已交数量-对应物料),目前只有采购订单有 + /// + public decimal DeliveredQty { get; set; } + + /// + /// 明细备注 + /// + public string Remark { get; set; } + + /// + /// 创建时间 + /// + public DateTime CreateTime { get; set; } + + /// + /// 单据类型 + /// + public int Type { get; set; } + + /// + /// 销售订单 + /// + public string SaleBillNo { get; set; } + + /// + /// 客户编码 + /// + public string CustomerCode { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/Erp/ErpInventoryDto.cs b/src/BarCode.Web.Core/Dto/Erp/ErpInventoryDto.cs new file mode 100644 index 0000000..db08767 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Erp/ErpInventoryDto.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.Erp +{ + public class ErpInventoryDto + { + /// + /// 物料编码 + /// + public string MaterialNumber { get; set; } + /// + /// 组织编码 + /// + public string OrgCode { get; set; } + /// + /// 仓库 + /// + public string StockCode { get; set; } + /// + /// 子仓库(跟金蝶交互字段) + /// + public int Erp_SubStockId { get; set; } + /// + /// 数量 + /// + public decimal Qty { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/Erp/ErpNumberDto.cs b/src/BarCode.Web.Core/Dto/Erp/ErpNumberDto.cs new file mode 100644 index 0000000..5fde1ba --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Erp/ErpNumberDto.cs @@ -0,0 +1,50 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.Erp +{ + /// + /// 编码 + /// + public class ErpNumberDto + { + public ErpNumberDto() { } + public ErpNumberDto(string number) + { + this.Number = number; + } + /// + /// 编码 + /// + [JsonProperty("FNumber")] + public string Number { get; set; } + } + + /// + /// 盘点子仓库 + /// + public class ErpSubStockDto + { + public ErpSubStockDto() { } + public ErpSubStockDto(string stockCode, string subCode) + { + if (stockCode != null && stockCode.Equals("GD")) + this.GD = new ErpNumberDto(subCode ?? ""); + if (stockCode != null && stockCode.Equals("HD")) + this.HD = new ErpNumberDto(subCode ?? ""); + } + /// + /// GD仓 + /// + [JsonProperty("FSTOCKLOCID__FF100005")] + public ErpNumberDto GD { get; set; } = new ErpNumberDto(""); + + /// + /// HD仓 + /// + [JsonProperty("FSTOCKLOCID__FF100007")] + public ErpNumberDto HD { get; set; } = new ErpNumberDto(""); + } +} diff --git a/src/BarCode.Web.Core/Dto/Erp/ErpOperateDto.cs b/src/BarCode.Web.Core/Dto/Erp/ErpOperateDto.cs new file mode 100644 index 0000000..23fbbf2 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Erp/ErpOperateDto.cs @@ -0,0 +1,28 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.Erp +{ + /// + /// erp 提交和审核 + /// + public class ErpOperateDto + { + public ErpOperateDto(string formId, string number) + { + this.FormId = formId; + this.Numbers =new List() { number }; + } + /// + /// 业务对象表单Id(必录) + /// + [JsonProperty("FormId")] + public string FormId { get; set; } + /// + /// 单据编码 + /// + public List Numbers { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/Erp/ErpPurchaseInStockSaveDto.cs b/src/BarCode.Web.Core/Dto/Erp/ErpPurchaseInStockSaveDto.cs new file mode 100644 index 0000000..df6540d --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Erp/ErpPurchaseInStockSaveDto.cs @@ -0,0 +1,74 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.Erp +{ + /// + /// 修改采购入库单 + /// + public class ErpPurchaseInStockSaveDto + { + public ErpPurchaseInStockSaveDto() { } + public ErpPurchaseInStockSaveDto(string id) + { + this.Id = id; + } + + /// + /// 单据Id + /// + [JsonProperty("FID")] + public string Id { get; set; } + + /// + /// 明细 + /// + [JsonProperty("FInStockEntry")] + public List Details { get; set; } = new List(); + } + + /// + /// 明细 + /// + public class ErpPurchaseInStockDetailsSaveDto + { + /// + /// 明细Id + /// + [JsonProperty("FEntryID")] + public string DetailId { get; set; } + /// + /// 采购订单明细Id + /// + [JsonIgnore] + public string PurchaseDetailId { get; set; } + /// + /// 数量 + /// + [JsonProperty("FRealQty")] + public decimal Qty { get; set; } + + /// + /// 批号 + /// + [JsonProperty("FLot")] + public ErpLotSaveDto Lot { get; set; } + + + + } + + /// + /// 批号 + /// + public class ErpLotSaveDto + { + /// + /// 批号 + /// + [JsonProperty("FNumber")] + public string Number { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/Erp/ErpPushDto.cs b/src/BarCode.Web.Core/Dto/Erp/ErpPushDto.cs new file mode 100644 index 0000000..2a3d6e2 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Erp/ErpPushDto.cs @@ -0,0 +1,62 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.Erp +{ + /// + /// 下推 + /// + public class ErpPushDto + { + public ErpPushDto() { } + + public ErpPushDto(string formId,List detailIds,string targetFormId) + { + this.FormId = formId; + //this.Numbers.Add(number); + this.DetailsId = detailIds.ToString(); + this.TargetFormId = targetFormId; + } + + /// + /// 业务对象表单Id(必录) + /// + [JsonProperty("FormId")] + public string FormId { get; set; } + ///// + ///// 业务对象表单Id(必录) + ///// + //[JsonProperty("Numbers")] + //public List Numbers { get; set; } + /// + /// 分录内码集合,逗号分隔(分录下推时必录) 注(按分录下推时,单据内码和编码不需要填,否则按整单下推) + /// + [JsonProperty("EntryIds")] + public string DetailsId { get; set; } + /// + /// 目标单据类型 + /// + [JsonProperty("TargetFormId")] + public string TargetFormId { get; set; } + /// + /// 是否启用默认转换规则,布尔类型,默认false(非必录) + /// false 需要穿 RuleId true 不需要传RuleId + /// + [JsonProperty("IsEnableDefaultRule")] + public bool IsEnableDefaultRule { get; set; } = false; + /// + /// 转换规则内码 + /// + [JsonProperty("RuleId")] + public string RuleId { get; set; } + + /// + /// 保存失败时是否暂存,布尔类型,默认false(非必录) 注(暂存的单据是没有编码的) + /// + [JsonProperty("IsDraftWhenSaveFail")] + public bool IsDraftWhenSaveFail { get; set; } = false; + + } +} diff --git a/src/BarCode.Web.Core/Dto/Erp/ErpSave.cs b/src/BarCode.Web.Core/Dto/Erp/ErpSave.cs new file mode 100644 index 0000000..76af023 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Erp/ErpSave.cs @@ -0,0 +1,28 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.Erp +{ + /// + /// Erp同步数据时单据头 + /// + public class ErpSave + { + public ErpSave(string formId,T model) + { + this.FormId = formId; + this.Model = model; + } + /// + /// 业务对象表单Id(必录) + /// + [JsonProperty("FormId")] + public string FormId { get; set; } + /// + /// 单据体 + /// + public T Model { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/Erp/Material/ErpMaterialDto.cs b/src/BarCode.Web.Core/Dto/Erp/Material/ErpMaterialDto.cs new file mode 100644 index 0000000..7322c1c --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Erp/Material/ErpMaterialDto.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.Erp +{ + /// + /// 对应金蝶,物料信息 + /// + public class ErpMaterialDto + { + /// + /// 组织ID + /// + public int OrgId { get; set; } + + /// + /// 组织编码 + /// + public string OrgCode { get; set; } + + /// + /// 物料ID + /// + public int MaterialId { get; set; } + + /// + /// 物料名称 + /// + public string MaterialName { get; set; } + /// + /// 物料编码 + /// + public string MaterialNumber { get; set; } + /// + /// 物料规格型号 + /// + public string Specifications { get; set; } + + /// + /// 基本单位 + /// + public int BaseUnitId { get; set; } + + /// + /// 基本单位名称 + /// + public string BaseUnitName { get; set; } + /// + /// 基本单位编码 + /// + public string BaseUnitNumber { get; set; } + + /// + /// 条码 + /// + public string BarCode { get; set; } + + /// + /// 是否启用批号管理 + /// + public bool IsBatchManage { get; set; } + /// + /// 物料Id 32进制字符串 + /// + public string IdConvertBar { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/Erp/Org/ErpOrgDto.cs b/src/BarCode.Web.Core/Dto/Erp/Org/ErpOrgDto.cs new file mode 100644 index 0000000..0c95bb7 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Erp/Org/ErpOrgDto.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.Erp.Org +{ + /// + /// 金蝶组织-基本信息 + /// + public class ErpOrgDto + { + /// + /// Id + /// + public int Id { get; set; } + + /// + /// 编码 + /// + public string Number { get; set; } + + /// + /// 名称 + /// + public string Name { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/Erp/OutStock/ErpDeliveryNoticeOutStockResultDto.cs b/src/BarCode.Web.Core/Dto/Erp/OutStock/ErpDeliveryNoticeOutStockResultDto.cs new file mode 100644 index 0000000..85de10b --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Erp/OutStock/ErpDeliveryNoticeOutStockResultDto.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.Erp.OutStock +{ + /// + /// 发货通知单转出库任务 + /// + public class ErpDeliveryNoticeOutStockResultDto + { + /// + /// 来源单号 + /// + public string SourceBillNo { get; set; } + /// + /// 销售订单号 + /// + public string SaleBillNo { get; set; } + /// + /// 发货组织 + /// + public int DeliveryOrgId { get; set; } + /// + /// 组织编码 + /// + public string OrgCode { get; set; } + /// + /// 收货客户 + /// + public int ReceiptCustomerId { get; set; } + /// + /// 对应金蝶单据明细id(销售出库同步金蝶下推使用) + /// + public int Erp_DetailId { get; set; } = 0; + /// + /// 物料编码 + /// + public string MaterialNumber { get; set; } + /// + /// 仓库ID + /// + public string StockCode { get; set; } + /// + /// 仓位ID + /// + public int? SubStockId { get; set; } + /// + /// 应出库数量 + /// + public decimal AccruedQty { get; set; } + /// + /// 订单明细备注 + /// + public string Remark { get; set; } + /// + /// 创建时间(erp那边的创建时间) + /// + public DateTime? CreateTime { get; set; } + /// + /// 用来自动构建单据类型 跟OutStockType 一致 + /// + public int Type { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/Erp/OutStock/ErpOutStockSaveDto.cs b/src/BarCode.Web.Core/Dto/Erp/OutStock/ErpOutStockSaveDto.cs new file mode 100644 index 0000000..a9456c7 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Erp/OutStock/ErpOutStockSaveDto.cs @@ -0,0 +1,94 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.Erp.OutStock +{ + /// + /// 出库单同步金蝶 + /// + public class ErpOutStockSaveDto + { + /// + /// 单据编号 + /// + [JsonProperty("BillNo")] + public string BillNo { get; set; } + /// + /// 单据类型 + /// + [JsonProperty("BillNo")] + public string Type { get; set; } + /// + /// 发货组织 + /// + [JsonProperty("DeliveryOrgId")] + public int DeliveryOrgId { get; set; } + /// + /// 收货客户 + /// + [JsonProperty("ReceiptCustomerId")] + public int ReceiptCustomerId { get; set; } + /// + /// 创建时间(出库时间) + /// + [JsonProperty("CreateTime")] + public DateTime CreateTime { get; set; } = DateTime.Now; + /// + /// 结算币别默认为: 人民币 + /// + [JsonProperty("Currency")] + public string Currency { get; set; } + /// + /// 销售组织取对应发货通知单的销售组织 + /// + [JsonProperty("Currency")] + public string SalOrg { get; set; } + /// + /// 销售部门取对应发货通知单的销售部门 + /// + [JsonProperty("Currency")] + public string SalDept { get; set; } + + } + + public class ErpOutStockSaveDetailsDto + { + /// + /// 物料Id + /// + [JsonProperty("MaterialId")] + public string MaterialId { get; set; } + /// + /// 仓库ID + /// + [JsonProperty("StockId")] + public string StockId { get; set; } + /// + /// 出库数量 + /// + [JsonProperty("UnitId")] + public string UnitId { get; set; } + /// + /// 出库数量 + /// + [JsonProperty("Qty")] + public decimal Qty { get; set; } + /// + /// 应发数量,取对应发货通知单的销售数量 + /// + [JsonProperty("YFQty")] + public string YFQty { get; set; } + /// + /// 单价 取对应发货通知单对应物料编码行的 单价 + /// + [JsonProperty("Price")] + public string Price { get; set; } + /// + ///含税单价 取对应发货通知单对应物料编码行的 含税单价 + /// + [JsonProperty("HSPrice")] + public string HSPrice { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/Erp/OutStock/ErpSalOutStockSaveDto.cs b/src/BarCode.Web.Core/Dto/Erp/OutStock/ErpSalOutStockSaveDto.cs new file mode 100644 index 0000000..851669a --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Erp/OutStock/ErpSalOutStockSaveDto.cs @@ -0,0 +1,48 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.Erp.OutStock +{ + /// + /// 修改销售出库单 + /// + public class ErpSalOutStockSaveDto + { + public ErpSalOutStockSaveDto() { } + public ErpSalOutStockSaveDto(string id) + { + this.Id = id; + } + /// + /// 单据Id + /// + [JsonProperty("FID")] + public string Id { get; set; } + /// + /// 明细 + /// + [JsonProperty("FEntity")] + public List Details { get; set; } = new List(); + } + public class ErpSalOutStockDetailsSaveDto + { + public ErpSalOutStockDetailsSaveDto(){} + /// + /// 明细Id + /// + [JsonProperty("FENTRYID")] + public string DetailId { get; set; } + /// + /// 发货通知单明细Id + /// + [JsonIgnore] + public string DeliveryNoticeDetailId { get; set; } + /// + /// 数量 + /// + [JsonProperty("FRealQty")] + public decimal Qty { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/Erp/PullDownStrResponse.cs b/src/BarCode.Web.Core/Dto/Erp/PullDownStrResponse.cs new file mode 100644 index 0000000..b147e87 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Erp/PullDownStrResponse.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.Erp +{ + /// + /// key为string 下拉列表对象 + /// + public class PullDownStrResponse + { + /// + /// id + /// + public string Id { get; set; } + /// + /// 编码 + /// + public string Code { get; set; } + /// + /// 名字 + /// + public string Name { get; set; } + /// + /// 是否默认选中 + /// + public bool IsDefault { get; set; } = false; + } +} diff --git a/src/BarCode.Web.Core/Dto/Erp/Stock/ErpStockDto.cs b/src/BarCode.Web.Core/Dto/Erp/Stock/ErpStockDto.cs new file mode 100644 index 0000000..7a4a8eb --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Erp/Stock/ErpStockDto.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.Erp +{ + /// + /// 仓库信息 + /// + public class ErpStockDto + { + /// + /// id + /// + public int Id { get; set; } + /// + /// 编码 + /// + public string Code { get; set; } + /// + /// 名字 + /// + public string Name { get; set; } + /// + /// 业务组织(使用组织) + /// + public int OrgId { get; set; } + /// + /// 业务组织(使用组织)编码 + /// + public string OrgCode { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/Erp/Stock/ErpSubStockDto.cs b/src/BarCode.Web.Core/Dto/Erp/Stock/ErpSubStockDto.cs new file mode 100644 index 0000000..8bfb3da --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Erp/Stock/ErpSubStockDto.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.Erp +{ + /// + /// 子仓库信息 + /// + public class Erp_SubStockDto + { + /// + /// id + /// + public int Id { get; set; } + /// + /// 编码 + /// + public string Code { get; set; } + /// + /// 名字 + /// + public string Name { get; set; } + /// + /// 业务组织(使用组织) + /// + public int OrgId { get; set; } + /// + /// 业务组织(使用组织)编码 + /// + public string OrgCode { get; set; } + /// + /// 仓库编码 + /// + public string StockCode { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/Erp/Supplier/ErpSupplierDto.cs b/src/BarCode.Web.Core/Dto/Erp/Supplier/ErpSupplierDto.cs new file mode 100644 index 0000000..364b35b --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Erp/Supplier/ErpSupplierDto.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.Erp.Supplier +{ + /// + /// erp供应商基础数据 + /// + public class ErpSupplierDto + { + /// + /// ID + /// + public int Id { get; set; } + + /// + /// 编码 + /// + public string Number { get; set; } + + /// + /// 名称 + /// + public string Name { get; set; } + /// + /// 组织编码 + /// + public string OrgCode { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/Erp/TakeStock/ErpTakeStockSaveDto.cs b/src/BarCode.Web.Core/Dto/Erp/TakeStock/ErpTakeStockSaveDto.cs new file mode 100644 index 0000000..2eb2586 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Erp/TakeStock/ErpTakeStockSaveDto.cs @@ -0,0 +1,138 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.Erp.TakeStock +{ + /// + /// 盘点单 + /// + public class ErpTakeStockSaveDto + { + + public ErpTakeStockSaveDto() { } + /* + * 单据编号:FBillNo + 日期:FDate (必填项) + + 库存组织:FStockOrgId (必填项) + 单据类型:FBillTypeID (必填项) + 货主类型:FOwnerTypeIdHead (必填项) BD_OwnerOrg + + 物料编码:FMaterialId (必填项) + 单位:FUnitID (必填项) + 仓库:FStockId (必填项) + 库存状态:FStockStatusId (必填项) + 货主类型:FOwnerTypeId (必填项) BD_OwnerOrg + 货主:FOwnerid (必填项) + 保管者类型:FKeeperTypeId (必填项) BD_KeeperOrg + 保管者:FKeeperId (必填项) + 子仓库:FStockLocId + */ + + /// + /// 单据类型(标准盘亏单; 标准盘盈单 PY01_SYS) 盘亏 PK01_SYS + /// + [JsonProperty("FBillTypeID")] + public ErpNumberDto Type { get; set; } + /// + /// 库存组织 (取仓库对应的库存组织) + /// + [JsonProperty("FStockOrgId")] + public ErpNumberDto StockOrgId { get; set; } + /// + /// 货主类型: 默认为业务组织 BD_OwnerOrg + /// + [JsonProperty("FOwnerTypeIdHead")] + public string FOwnerTypeIdHead { get; set; } = "BD_OwnerOrg"; + /// + /// 单据编号 + /// + [JsonProperty("FBillNo")] + public string BillNo { get; set; } + /// + /// 盘点日期 + /// + [JsonProperty("FDate")] + public DateTime Date { get; set; } + /// + /// 明细 + /// + [JsonProperty("FBillEntry")] + public List Details = new List(); + } + public class ErpTakeStockDetailsSaveDto + { + /// + /// 库存状态 KCZT01_SYS + /// + [JsonProperty("FStockStatusId")] + public ErpNumberDto FStockStatusId { get; set; } = new ErpNumberDto("KCZT01_SYS"); + /// + /// 货主类型: 默认为业务组织 BD_OwnerOrg + /// + [JsonProperty("FOwnerTypeId")] + public string FOwnerTypeId { get; set; } = "BD_OwnerOrg"; + /// + /// 取仓库对应的货主信息 货主: 等于库存组织 + /// + [JsonProperty("FOwnerid")] + public ErpNumberDto FOwnerid { get; set; } + /// + /// 保管者类型 + /// + [JsonProperty("FKeeperTypeId")] + public string FKeeperTypeId { get; set; } = "BD_KeeperOrg"; + /// + /// 保管者 仓库”库存组织” + /// + [JsonProperty("FKeeperId")] + public ErpNumberDto FKeeperId { get; set; } + /// + /// 物料ID + /// + [JsonProperty("FMaterialId")] + public ErpNumberDto MaterialId { get; set; } + /// + /// 单位ID + /// + [JsonProperty("FUnitID")] + public ErpNumberDto UnitId { get; set; } + /// + /// 仓库ID + /// + [JsonProperty("FStockId")] + public ErpNumberDto StockId { get; set; } + /// + /// 仓位ID + /// + [JsonProperty("FStockLocId")] + public ErpSubStockDto SubStockId { get; set; } + /// + /// 盘点前数量(wms系统数量) + /// + [JsonProperty("FAcctQty")] + public decimal BeforeQty { get; set; } + /// + /// 盘点实际数量(实际仓库数量) + /// + [JsonProperty("FCountQty")] + public decimal AfterQty { get; set; } + /// + /// 盘盈数量 + /// + [JsonProperty("FGainQty")] + public decimal FinalQty { get; set; } + /// + /// 盘亏数量 + /// + [JsonProperty("FLossQty")] + public decimal LossQty { get; set; } + /// + /// 备注 + /// + [JsonProperty("Fnote")] + public string Fnote { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/FileDownManagerRequest.cs b/src/BarCode.Web.Core/Dto/FileDownManagerRequest.cs new file mode 100644 index 0000000..0833a1d --- /dev/null +++ b/src/BarCode.Web.Core/Dto/FileDownManagerRequest.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Text; + +namespace BarCode.Web.Core.Dto +{ + /// + /// 上传下载列表 + /// + public class FileDownManagerRequest: PaginationBaseRequestDto + { + /// + /// 组织Code + /// + [Required(ErrorMessage = "组织不能为空")] + public string OrgCode { get; set; } = string.Empty; + /// + /// 单据类型(任务类型) + /// + public int? Type { get; set; } + /// + /// 状态 + /// + public int? Status { get; set; } + /// + /// 下单时间 开始 + /// + public DateTime? BeginDate { get; set; } + /// + /// 下单时间 结束 + /// + public DateTime? EndDate { get; set; } + /// + /// 操作人 + /// + public string User { get; set; } = string.Empty; + /// + /// 供应商用户Id + /// + public int? SupplierId { get; set; } = null; + } +} diff --git a/src/BarCode.Web.Core/Dto/FileDownManagerResponse.cs b/src/BarCode.Web.Core/Dto/FileDownManagerResponse.cs new file mode 100644 index 0000000..1ae3e6a --- /dev/null +++ b/src/BarCode.Web.Core/Dto/FileDownManagerResponse.cs @@ -0,0 +1,73 @@ + +using System; +using System.Collections.Generic; +using System.Text; +using BarCode.Web.Core.Help; + +namespace BarCode.Web.Core.Dto +{ + /// + /// 上传下载列表 + /// + public class FileDownManagerResponse + { + public FileDownManagerResponse(List list, int? total) + { + this.List = list; + this.Total = total; + } + + /// + /// 查询列表内容 + /// + public List List { get; set; } = new List(); + /// + /// 总条数 + /// + public int? Total { get; set; } + } + + /// + /// 上传下载列表 + /// + public class FileDownInfoManagerResponse + { + public FileDownInfoManagerResponse() { } + public FileDownInfoManagerResponse(FileDownInfoManagerResponse response) + { + response.CopyPropertiesToD(this); + } + /// + /// 主键 订单编号 + /// + public int Id { get; set; } + /// + /// 日期 + /// + public string Date { get; set; } + /// + /// 单据类型(任务类型) + /// + public int Type { get; set; } + /// + /// 状态(Key) + /// + public int StatusKey { get; set; } + /// + /// 状态 + /// + public string Status { get; set; } + /// + /// 文件地址 + /// + public string FilePath { get; set; } + /// + /// 操作人 + /// + public string UserName { get; set; } + /// + /// 失败原因 + /// + public string Reason { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/FileDownManagerStatusResponse.cs b/src/BarCode.Web.Core/Dto/FileDownManagerStatusResponse.cs new file mode 100644 index 0000000..6858205 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/FileDownManagerStatusResponse.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto +{ + public class FileDownManagerStatusResponse + { + public FileDownManagerStatusResponse() { } + /// + /// 任务类型 + /// + public Dictionary Type { get; set; } = new Dictionary(); + /// + /// 状态 + /// + public Dictionary Status { get; set; } = new Dictionary(); + } +} diff --git a/src/BarCode.Web.Core/Dto/Login/AccessTokenDto.cs b/src/BarCode.Web.Core/Dto/Login/AccessTokenDto.cs new file mode 100644 index 0000000..f10c00c --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Login/AccessTokenDto.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.Login +{ + public class AccessTokenDto + { + /// + /// 客户端名称 + /// + public string ClientName { get; set; } + + /// + /// 授权token -- 给前端用的验证token + /// + public string Token { get; set; } + + /// + /// 授权token -- 单点给过来的token + /// + public string PhpToken { get; set; } + + /// + /// token头标识 + /// + public string TokenType { get; set; } = "Bearer"; + /// + /// 刷新token + /// + public string RefreshToken { get; set; } + /// + /// 过期时间 + /// + public DateTime Expired { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/Login/DeptInfoDto.cs b/src/BarCode.Web.Core/Dto/Login/DeptInfoDto.cs new file mode 100644 index 0000000..15a8dcf --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Login/DeptInfoDto.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.Login +{ + public class DeptInfoDto + { + public int Id { get; set; } + + public string DeptCode { get; set; } + + public string DeptName { get; set; } + + public int? ManagerId { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/Login/LoginInDto.cs b/src/BarCode.Web.Core/Dto/Login/LoginInDto.cs new file mode 100644 index 0000000..e435d5f --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Login/LoginInDto.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.Login +{ + /// + /// 登录后要保存的信息 + /// + public class LoginInDto + { + + public bool SignedIn { get; set; } + + /// + /// 用户信息 + /// + public UserInfoDto UserInfo { get; set; } + + /// + /// token信息 + /// + public AccessTokenDto TokenInfo { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/Login/LoginOutAuthorizeRequest.cs b/src/BarCode.Web.Core/Dto/Login/LoginOutAuthorizeRequest.cs new file mode 100644 index 0000000..e494e7e --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Login/LoginOutAuthorizeRequest.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.Login +{ + public class LoginOutAuthorizeRequest + { + public string AccessToken { get; set; } + + public string RefreshToken { get; set; } + + } +} diff --git a/src/BarCode.Web.Core/Dto/Login/LoginOutDto.cs b/src/BarCode.Web.Core/Dto/Login/LoginOutDto.cs new file mode 100644 index 0000000..b1f70b9 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Login/LoginOutDto.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.Login +{ + /// + /// 登出的dto + /// + public class LoginOutDto + { + /// + /// 授权token + /// + public string Authorization { get; set; } + + /// + /// 用户ID + /// + public string UcId { get; set; } + + /// + /// PHP-session-ID + /// + public string SessionId { get; set; } + + /// + /// PHP登录返回的token + /// + public string AccessToken { get; set; } + + /// + /// PHP登录的过期时间 + /// + public DateTime ExpiresIn { get; set; } + + /// + ///ops自己产生的token 给前端验证用的 + /// + public string Token { get; set; } + + public string RefreshToken { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/Login/LoginRequest.cs b/src/BarCode.Web.Core/Dto/Login/LoginRequest.cs new file mode 100644 index 0000000..6f9a757 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Login/LoginRequest.cs @@ -0,0 +1,86 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.Login +{ + /// + /// 登录请求对象 + /// + public class LoginRequest + { + /// + /// 账号 + /// + public string UserName { get; set; } + + /// + /// 密码 + /// + public string Password { get; set; } + } + + public class LoginAuthorizeRequest : LoginRequest + { + /// + /// + /// + public string ClientId { get; set; } + + /// + /// + /// + public string ClientSecret { get; set; } + + /// + /// + /// + public string GrantType { get; set; } + + public string Scope { get; set; } + } + + public class LoginAuthorizeCodeRequest + { + /// + /// + /// + public string ClientId { get; set; } + + /// + /// + /// + public string ClientSecret { get; set; } + + /// + /// + /// + public string GrantType { get; set; } + + public string Code { get; set; } + + public string Scope { get; set; } + } + + public class LoginAuthorizeRefreshTokenRequest + { + /// + /// + /// + public string ClientId { get; set; } + + /// + /// + /// + public string ClientSecret { get; set; } + + /// + /// + /// + public string GrantType { get; set; } + + public string RefreshToken { get; set; } + + public string Scope { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/Login/Menu/MenuRequest.cs b/src/BarCode.Web.Core/Dto/Login/Menu/MenuRequest.cs new file mode 100644 index 0000000..8c69996 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Login/Menu/MenuRequest.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.Login +{ + /// + /// 菜单的请求对象 + /// + public class MenuRequest + { + public MenuRequest() { } + public MenuRequest(int userId, int moduleId) + { + this.UserId = userId; + this.ModuleID = moduleId; + } + + /// + /// 用户ID(不是人员ID) + /// + public int UserId { get; set; } + + /// + /// 应用ID + /// + public int ModuleID { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/Login/Menu/MenuResponse.cs b/src/BarCode.Web.Core/Dto/Login/Menu/MenuResponse.cs new file mode 100644 index 0000000..8df83a1 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Login/Menu/MenuResponse.cs @@ -0,0 +1,105 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.Login +{ + /// + /// 菜单响应对象 + /// + public class MenuResponse + { + /// + /// + /// + + public int ID { get; set; } + /// + /// 上级菜单 + /// + + public int? Pid { get; set; } + /// + /// 模块ID,对应apps表ID + /// + + public int? Module { get; set; } + /// + /// 菜单标题 + /// + + public string Title { get; set; } + /// + /// 菜单标签 + /// + + public string Name { get; set; } + /// + /// 菜单路径 + /// + + public string Path { get; set; } + /// + /// 操作,比如 /admin/info + /// + + public string Component { get; set; } + /// + /// 图标 + /// + + public string Icon { get; set; } + /// + /// + /// + + public string Redirect { get; set; } + /// + /// 排序 + /// + + public int? Sort { get; set; } + /// + /// 0为普通按钮/连接,1为左侧菜单 + /// + + public int? Type { get; set; } + /// + /// 是否显示:0为否,1为是 + /// + + public bool Hidden { get; set; } + /// + /// 是否禁用:0为否,1为是 + /// + + public bool Closed { get; set; } + + /// + /// 是否禁用:true为禁用,false为启用 + /// + public bool Disable { get; set; } + + /// + /// 子集 + /// + public List Children { get; set; } + + /// + /// meta + /// + public Meta meta { get; set; } + } + + public class Meta + { + /// + /// 菜单名字 + /// + public string title { get; set; } + /// + /// 菜单图标 + /// + public string icon { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/Login/Single/LoginSingleRequest.cs b/src/BarCode.Web.Core/Dto/Login/Single/LoginSingleRequest.cs new file mode 100644 index 0000000..bc6b02e --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Login/Single/LoginSingleRequest.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.Login +{ + /// + /// 登录后:请求相关全部信息对象 + /// + public class LoginSingleRequest + { + /// + /// 用户ID + /// + public int UserId { get; set; } + + /// + /// 供应商 + /// + public int SupplierId { get; set; } + + /// + /// 客户 + /// + public int CustomerId { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/Login/Single/LoginSingleResponse.cs b/src/BarCode.Web.Core/Dto/Login/Single/LoginSingleResponse.cs new file mode 100644 index 0000000..0f8b349 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Login/Single/LoginSingleResponse.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Text; +using BarCode.Web.Core.Dto.SingleData; + +namespace BarCode.Web.Core.Dto.Login +{ + /// + /// 登录后:响应相关全部信息对象 + /// + public class LoginSingleResponse + { + /// + /// 人员 + /// + public SingleDataResponse Staff { get; set; } + + /// + /// 公司 + /// + public SingleDataResponse Company { get; set; } + + /// + /// 供应商 + /// + public SingleDataResponse Supplier { get; set; } + + /// + /// 客户 + /// + public SingleDataResponse Customer { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/Login/TagInfoDto.cs b/src/BarCode.Web.Core/Dto/Login/TagInfoDto.cs new file mode 100644 index 0000000..382d1a2 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Login/TagInfoDto.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.Login +{ + public class TagInfoDto + { + public int Id { get; set; } + public string Name { get; set; } + public string Code { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/Login/Temp/LoginJsonDeptTempDto.cs b/src/BarCode.Web.Core/Dto/Login/Temp/LoginJsonDeptTempDto.cs new file mode 100644 index 0000000..8c9e7f7 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Login/Temp/LoginJsonDeptTempDto.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.Login.Temp +{ + /// + /// 部门 + /// + public class LoginJsonDeptTempDto + { + public int id { get; set; } + + public string dept_code { get; set; } + public string dept_name { get; set; } + + public int? manager { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/Login/Temp/LoginJsonTokenTempDto.cs b/src/BarCode.Web.Core/Dto/Login/Temp/LoginJsonTokenTempDto.cs new file mode 100644 index 0000000..56bdcc9 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Login/Temp/LoginJsonTokenTempDto.cs @@ -0,0 +1,107 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.Login.Temp +{ + /// + /// 基本信息人员--和单点系统的字段一一对应 + /// + public class LoginJsonTokenTempDto + { + /// + /// 用户在单点中维一ID + /// + public int uc_id { get; set; } + + /// + /// 用户编码 + /// + public string staff_code { get; set; } + + /// + /// 用户业务员编码 + /// + public string business_code { get; set; } + + /// + /// 角色id + /// + public string role_id { get; set; } + + /// + /// 姓名 + /// + public string nickname { get; set; } + + /// + /// 头像 + /// + public string avatar { get; set; } + + /// + /// 用户手机 + /// + public string mobile { get; set; } + + /// + /// 用户邮件 + /// + public string email { get; set; } + + /// + /// 公司id + /// + public int? company_id { get; set; } + + /// + /// 组织id + /// + public int? org_id { get; set; } + + /// + /// 供应商id + /// + public int? supplier_id { get; set; } + + /// + /// 客户id + /// + public int? customer_id { get; set; } + + /// + /// 创建时间 + /// + public string created_at { get; set; } + + /// + /// 更新时间 + /// + public string updated_at { get; set; } + + /// + /// 签名(登录)时间 + /// + public string signin_at { get; set; } + + /// + /// 签名(登录)ip + /// + public string signin_ip { get; set; } + + /// + /// 关闭状态,0为未关闭 + /// + public string closed { get; set; } + + /// + /// 用户类型 1为员工,2为供应商,3为客户 + /// + public int? identity { get; set; } + + /// + /// 部门 + /// + public List depts { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/Login/Temp/LoginTempDto.cs b/src/BarCode.Web.Core/Dto/Login/Temp/LoginTempDto.cs new file mode 100644 index 0000000..d8370bc --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Login/Temp/LoginTempDto.cs @@ -0,0 +1,70 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.Login.Temp +{ + /// + /// 登录后获取的:token 信息-和单点系统的字段一一对应 + /// + public class LoginTempDto + { + /// + /// 用户在单点中维一ID + /// + public int uc_id { get; set; } + + /// + /// 单点访问的session id + /// + public string uc_sessid { get; set; } + + /// + /// 后续与单点通信验证token + /// + public string access_token { get; set; } + + /// + ///access token过期时间 + /// + public int expires_in { get; set; } + + + /// + /// 用于access_token过期后刷新用 + /// + public string refresh_token { get; set; } + + /// + /// 加密后的用户数据 + /// + public string encryptedData { get; set; } + } + + /// + /// 登录后获取的:token 信息-和单点系统的字段一一对应 + /// + public class LoginTempV2Dto + { + /// + /// 后续与单点通信验证token + /// + public string access_token { get; set; } + + /// + ///access token过期时间 + /// + public int access_expired_at { get; set; } + + + /// + /// 用于access_token过期后刷新用 + /// + public string refresh_token { get; set; } + + /// + /// 加密后的用户数据 + /// + public string encrypted_data { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/Login/Temp/v3/LoginJsonCompanyTempDto.cs b/src/BarCode.Web.Core/Dto/Login/Temp/v3/LoginJsonCompanyTempDto.cs new file mode 100644 index 0000000..76c7819 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Login/Temp/v3/LoginJsonCompanyTempDto.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.Login.Temp +{ + public class LoginJsonCompanyTempDto + { + public int company_id { get; set; } + public string company_name { get; set; } + public string company_code { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/Login/Temp/v3/LoginJsonDeptV3TempDto.cs b/src/BarCode.Web.Core/Dto/Login/Temp/v3/LoginJsonDeptV3TempDto.cs new file mode 100644 index 0000000..e6519e9 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Login/Temp/v3/LoginJsonDeptV3TempDto.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.Login.Temp.v3 +{ + public class LoginJsonDeptV3TempDto + { + public int dept_id { get; set; } + public string dept_name { get; set; } + public string dept_code { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/Login/Temp/v3/LoginJsonOrgTempDto.cs b/src/BarCode.Web.Core/Dto/Login/Temp/v3/LoginJsonOrgTempDto.cs new file mode 100644 index 0000000..2ea317a --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Login/Temp/v3/LoginJsonOrgTempDto.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.Login.Temp +{ + public class LoginJsonOrgTempDto + { + public int org_id { get; set; } + public string org_name { get; set; } + public string org_code { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/Login/Temp/v3/LoginJsonRoleTempDto.cs b/src/BarCode.Web.Core/Dto/Login/Temp/v3/LoginJsonRoleTempDto.cs new file mode 100644 index 0000000..be9a736 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Login/Temp/v3/LoginJsonRoleTempDto.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.Login.Temp.v3 +{ + public class LoginJsonRoleTempDto + { + public int role_id { get; set; } + public string role_name { get; set; } + public string role_code { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/Login/Temp/v3/LoginJsonTokenV3TempDto.cs b/src/BarCode.Web.Core/Dto/Login/Temp/v3/LoginJsonTokenV3TempDto.cs new file mode 100644 index 0000000..4ece9ee --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Login/Temp/v3/LoginJsonTokenV3TempDto.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.Login.Temp.v3 +{ + public class LoginJsonTokenV3TempDto + { + /// + /// 用户在单点中维一ID + /// + public int id { get; set; } + + public string dingtalk_uid { get; set; } + + public string dingtalk_unionid { get; set; } + + public string nickname { get; set; } + public string realname { get; set; } + + public string mobile { get; set; } + + public int identity { get; set; } + + public LoginJsonCompanyTempDto company { get; set; } + public List orgs { get; set; } + public List depts { get; set; } + public List roles { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/Login/UserInfoDto.cs b/src/BarCode.Web.Core/Dto/Login/UserInfoDto.cs new file mode 100644 index 0000000..89a0dee --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Login/UserInfoDto.cs @@ -0,0 +1,101 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.Login +{ + public class UserInfoDto + { + public string SeesionId { get; set; } + + public int UcId { get; set; } + + public List Depts { get; set; } + + /// + /// 人员ID + /// + public int StaffId { get; set; } + + /// + /// 用户编码 + /// + public string staff_code { get; set; } + + /// + /// 用户业务员编码 + /// + public string business_code { get; set; } + /// + /// 头像 + /// + public string Avatar { get; set; } + /// + /// 是否是admin账户 + /// + public bool IsAdmin { get; set; } = false; + + public int Closed { get; set; } + + public string CreatedAt { get; set; } + + public string Email { get; set; } + + public string Mobile { get; set; } + + public string Nickname { get; set; } + + public string RoleId { get; set; } + + public string SigninAt { get; set; } + + public string UpdatedAt { get; set; } + + /// + /// 公司id + /// + public int CompanyId { get; set; } + + /// + /// 公司名称 + /// + public string CompanyName { get; set; } + + //org_id, supplier_id ,customer_id, identity: 1为员工,2为供应商,3为客户 + + /// + /// 组织id 用户类型为内部员工的时候才有值 + /// + public int? OrgId { get; set; } + + /// + /// 供应商id 用户类型为供应商的时候才有值 + /// + public int? SupplierId { get; set; } + /// + /// 供应商Code 用户类型为供应商的时候才有值 + /// + public string SupplierCode { get; set; } = ""; + /// + /// 供应商名称 + /// + public string SupplierName { get; set; } = ""; + + /// + /// 客户id 用户类型为客户的时候才有值 + /// + public int? CustomerId { get; set; } + + /// + /// 客户名称 + /// + public string CustomerName { get; set; } + + /// + /// 用户类型:1为员工,2为供应商,3为客户 + /// + public int? Identity { get; set; } + + //public string AuthList { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/Login/UserInfoV3Dto.cs b/src/BarCode.Web.Core/Dto/Login/UserInfoV3Dto.cs new file mode 100644 index 0000000..9d1d1ea --- /dev/null +++ b/src/BarCode.Web.Core/Dto/Login/UserInfoV3Dto.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.Login +{ + public class UserInfoV3Dto + { + /// + /// 用户在单点中维一ID + /// + public int Id { get; set; } + + public string DingtalkUid { get; set; } + + public string DingtalkUnionid { get; set; } + + public string Nickname { get; set; } + public string Realname { get; set; } + + public string Mobile { get; set; } + + public int Identity { get; set; } + + public TagInfoDto Company { get; set; } + public List Orgs { get; set; } = new List(); + public List Depts { get; set; }= new List(); + public List Roles { get; set; }= new List(); + } +} diff --git a/src/BarCode.Web.Core/Dto/MaterialResponse.cs b/src/BarCode.Web.Core/Dto/MaterialResponse.cs new file mode 100644 index 0000000..e86239b --- /dev/null +++ b/src/BarCode.Web.Core/Dto/MaterialResponse.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto +{ + /// + /// 序列号信息 + /// + public class MaterialResponse + { + /// + /// 箱Id + /// + public int BoxId { get; set; } = 0; + /// + /// 箱号 + /// + public string BoxBillNo { get; set; } + ///// + ///// 仓位Id(序列号不存在库存的话仓位是0) + ///// + //public int SubStockId { get; set; } = 0; + /// + /// 仓位编码(序列号不存在库存的话仓位是"") + /// + public string SubStockCode { get; set; } = ""; + /// + /// 仓库编码 + /// + public string StockCode { get; set; } = ""; + /// + /// 是否存在于箱库存中 + /// + public bool IsBoxInventory { get; set; } = false; + /// + /// 序列号 + /// + public string SerialNumber { get; set; } + /// + /// 物料名称 + /// + public string MaterialName { get; set; } + /// + /// 物料编码 + /// + public string MaterialNumber { get; set; } + /// + /// 物料规格型号 + /// + public string Specifications { get; set; } + /// + /// 是否是老Ops条码 + /// + public bool IsOldOps { get; set; } = false; + /// + /// 是否冻结 + /// + public bool IsDelete { get; set; } = false; + /// + /// 是否激活过(只有做过 盘点 采购和非采购上架 出库回退上架 才算激活) + /// + public bool IsActivate { get; set; } = false; + } +} diff --git a/src/BarCode.Web.Core/Dto/MaterialSubStock.cs b/src/BarCode.Web.Core/Dto/MaterialSubStock.cs new file mode 100644 index 0000000..2d26018 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/MaterialSubStock.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto +{ + /// + /// 物料对应的仓位有哪些 + /// + public class MaterialSubStock + { + /// + /// 物料编码 + /// + public string MaterialNumber { get; set; } + + /// + /// 仓位编码 + /// + public string SubStockCode { get; set; } + + /// + /// 仓位名称 + /// + public string SubStock { get; set; } + + /// + /// 组织 + /// + public string OrgCode { get; set; } + + /// + /// 仓库 + /// + public string StockCode { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/OperateRequest.cs b/src/BarCode.Web.Core/Dto/OperateRequest.cs new file mode 100644 index 0000000..0072d13 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/OperateRequest.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto +{ + /// + /// 操作 Id集合 + /// + public class OperateRequest + { + public List Ids { get; set; } = new List(); + } + + /// + /// 操作 Id集合 + /// + public class OperatePagedRequest : PaginationBaseRequestDto + { + public List Ids { get; set; } = new List(); + } + /// + /// 操作 string集合 + /// + public class OperateStrRequest + { + public List Ids { get; set; } = new List(); + } +} diff --git a/src/BarCode.Web.Core/Dto/PaginationRequestDto.cs b/src/BarCode.Web.Core/Dto/PaginationRequestDto.cs new file mode 100644 index 0000000..1fc5cd4 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/PaginationRequestDto.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Text; + +namespace BarCode.Web.Core.Dto +{ + public class PaginationRequestDto: PaginationBaseRequestDto + { + /// + /// 组织Id(所有列表页都需要 全局) + /// + [Required(ErrorMessage = "组织不能为空")] + public virtual int OrgId { get; set; } + } + + public class PaginationBaseRequestDto + { + /// + /// 页数 不传默认为1 + /// + public int PageNo { get; set; } = 1; + /// + /// 每页条数 不传默认每页10 条 + /// + public int PageSize { get; set; } = 10; + } +} diff --git a/src/BarCode.Web.Core/Dto/SecurityNumbers/GenerateSecurityNumberRequest.cs b/src/BarCode.Web.Core/Dto/SecurityNumbers/GenerateSecurityNumberRequest.cs new file mode 100644 index 0000000..4199cfd --- /dev/null +++ b/src/BarCode.Web.Core/Dto/SecurityNumbers/GenerateSecurityNumberRequest.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Core.Dto.SecurityNumbers +{ + /// + /// 生成防伪码 + /// + public class GenerateSecurityNumberRequest + { + /// + /// 组织Code + /// + [Required(ErrorMessage = "组织不能为空")] + public string OrgCode { get; set; } = string.Empty; + /// + /// 物料编码 + /// + public string MaterialNumber { get; set; } = ""; + /// + /// 数量 + /// + [Required(ErrorMessage = "数量不能为空")] + public int Number { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/SecurityNumbers/OperateSecurityNumberRequest.cs b/src/BarCode.Web.Core/Dto/SecurityNumbers/OperateSecurityNumberRequest.cs new file mode 100644 index 0000000..7fbe8bc --- /dev/null +++ b/src/BarCode.Web.Core/Dto/SecurityNumbers/OperateSecurityNumberRequest.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Core.Dto.SecurityNumbers +{ + /// + /// 防伪码下载 + /// + public class OperateSecurityNumberRequest + { + /// + /// 生成记录Id + /// + public List GenerateRecordIds { get; set; } = new List(); + /// + /// 是否全部操作 + /// + public bool IsAll { get; set; } = false; + /// + /// 如果是部分操作(防伪码) 全部操作的话可不传 + /// + public List SecurityNumbers { get; set; } = new List(); + } +} diff --git a/src/BarCode.Web.Core/Dto/SecurityNumbers/SecurityGenerateRecordInfoResponse.cs b/src/BarCode.Web.Core/Dto/SecurityNumbers/SecurityGenerateRecordInfoResponse.cs new file mode 100644 index 0000000..c5d4b84 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/SecurityNumbers/SecurityGenerateRecordInfoResponse.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Core.Dto.SecurityNumbers +{ + /// + /// 防伪码生成列表记录 + /// + public class SecurityGenerateRecordInfoResponse + { + /// + /// 主键 订单编号 + /// + public int Id { get; set; } + /// + /// 防伪码批次 + /// + public string LotNumber { get; set; } = string.Empty; + /// + /// 物料规格型号 + /// + public string Specifications { get; set; } = string.Empty; + /// + /// 物料编码 + /// + public string MaterialNumber { get; set; } = string.Empty; + /// + /// 物料名称 + /// + public string MaterialName { get; set; } = string.Empty; + /// + /// 物料条码 + /// + public string BarCode { get; set; } = string.Empty; + /// + /// 生成完成 1 生成中 0 + /// + public string GenerateComplete { get; set; } = string.Empty; + /// + /// 生成条码数量 + /// + public int Number { get; set; } = 0; + /// + /// 下载数 + /// + public int DownLoadNumber { get; set; } = 0; + /// + /// 创建人 + /// + public string Creator { get; set; } = string.Empty; + /// + /// 生成时间 + /// + public string CreateTime { get; set; } = string.Empty; + /// + /// 生成完成时间 + /// + public string GenerateCompleteTime { get; set; } = string.Empty; + } +} diff --git a/src/BarCode.Web.Core/Dto/SecurityNumbers/SecurityGenerateRecordQueryRequest.cs b/src/BarCode.Web.Core/Dto/SecurityNumbers/SecurityGenerateRecordQueryRequest.cs new file mode 100644 index 0000000..5ac187e --- /dev/null +++ b/src/BarCode.Web.Core/Dto/SecurityNumbers/SecurityGenerateRecordQueryRequest.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Core.Dto.SecurityNumbers +{ + /// + /// 防伪码生成列表 + /// + public class SecurityGenerateRecordQueryRequest : PaginationBaseRequestDto + { + /// + /// 组织Code + /// + [Required(ErrorMessage = "组织不能为空")] + public string OrgCode { get; set; } = ""; + /// + /// 创建时间 + /// + public DateTime? CreateBeginDate { get; set; } = null; + /// + /// 创建时间 + /// + public DateTime? CreateEndDate { get; set; } = null; + /// + /// 防伪码集合 + /// + public List SecurityNumbers { get; set; } = new List(); + /// + /// 防伪码批号 + /// + public List LotNumbers { get; set; } = new List(); + /// + /// 生成完成 true 生成中 false 不搜 null或不传 + /// + public bool? GenerateComplete { get; set; } = null; + /// + /// 物料编码 + /// + public string MaterialNumber { get; set; } = string.Empty; + } +} diff --git a/src/BarCode.Web.Core/Dto/SecurityNumbers/SecurityNumberInfoResponse.cs b/src/BarCode.Web.Core/Dto/SecurityNumbers/SecurityNumberInfoResponse.cs new file mode 100644 index 0000000..e6ef1cd --- /dev/null +++ b/src/BarCode.Web.Core/Dto/SecurityNumbers/SecurityNumberInfoResponse.cs @@ -0,0 +1,62 @@ +using Npoi.Mapper.Attributes; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Core.Dto.SecurityNumbers +{ + /// + /// 防伪码列表 + /// + public class SecurityNumberInfoResponse + { + /// + /// 流水号 + /// + [Column("流水号")] + public long Id { get; set; } + /// + /// 生成记录Id + /// + [Ignore] + public int GenerateRecordId { get; set; } = 0; + /// + /// 防伪码 + /// + [Column("防伪码")] + public string SecurityNumber { get; set; } = string.Empty; + /// + /// 物料规格型号 + /// + [Column("规格型号")] + public string Specifications { get; set; } = string.Empty; + /// + /// 数量 + /// + [Column("数量")] + public int Number { get; set; } = 0; + /// + /// 生成时间 + /// + [Column("生成时间")] + public string CreateTime { get; set; } = string.Empty; + /// + /// 下载次数 + /// + [Column("下载次数")] + public int DownLoadNumber { get; set; } = 0; + /// + /// 最新下载时间 + /// + [Column("最近下载时间")] + public string DownLoadTime { get; set; } = string.Empty; + /// + /// 创建人 + /// + [Ignore] + public string Creator { get; set; } = string.Empty; + + } +} diff --git a/src/BarCode.Web.Core/Dto/SecurityNumbers/SecurityNumberQueryRequest.cs b/src/BarCode.Web.Core/Dto/SecurityNumbers/SecurityNumberQueryRequest.cs new file mode 100644 index 0000000..5885ed9 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/SecurityNumbers/SecurityNumberQueryRequest.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Core.Dto.SecurityNumbers +{ + /// + /// 防伪码列表 + /// + public class SecurityNumberQueryRequest : PaginationBaseRequestDto + { + /// + /// 组织Code + /// + [Required(ErrorMessage = "组织不能为空")] + public string OrgCode { get; set; } = string.Empty; + /// + /// 生成记录Id + /// + [Required(ErrorMessage = "生成记录不能为空")] + public int GenerateRecordId { get; set; } = 0; + /// + /// 流水号区间-开始 + /// + public int? IdBegin { get; set; } = null; + /// + /// 流水号区间-结束 + /// + public int? IdEnd { get; set; } = null; + /// + /// 是否下载 true 下载 false 未下载 + /// + public bool? IsDownLoad { get; set; } = null; + /// + /// 下载时间 + /// + public DateTime? DownLoadBeginDate { get; set; } = null; + /// + /// 下载时间 + /// + public DateTime? DownLoadEndDate { get; set; } = null; + /// + /// 防伪码 + /// + public List SecurityNumbers { get; set; } = new List(); + } +} diff --git a/src/BarCode.Web.Core/Dto/SecurityNumbers/SecurityNumbersExportReponse.cs b/src/BarCode.Web.Core/Dto/SecurityNumbers/SecurityNumbersExportReponse.cs new file mode 100644 index 0000000..2821fcd --- /dev/null +++ b/src/BarCode.Web.Core/Dto/SecurityNumbers/SecurityNumbersExportReponse.cs @@ -0,0 +1,41 @@ +using Npoi.Mapper.Attributes; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Core.Dto.SecurityNumbers +{ + /// + /// 防伪码导出 + /// + public class SecurityNumbersExportReponse + { + /// + /// 防伪码 + /// + [Column("防伪码")] + public string SecurityNumber { get; set; } = string.Empty; + /// + /// 物料规格型号 + /// + [Column("规格型号")] + public string Specifications { get; set; } = string.Empty; + /// + /// 数量 + /// + [Column("数量")] + public int Number { get; set; } = 0; + /// + /// 下载次数 + /// + [Column("下载次数")] + public int DownLoadNumber { get; set; } = 0; + /// + /// 最新下载时间 + /// + [Column("最近下载时间")] + public string DownLoadTime { get; set; } = string.Empty; + } +} diff --git a/src/BarCode.Web.Core/Dto/SecurityNumbers/SecurityNumbersExportRequest.cs b/src/BarCode.Web.Core/Dto/SecurityNumbers/SecurityNumbersExportRequest.cs new file mode 100644 index 0000000..968f8cb --- /dev/null +++ b/src/BarCode.Web.Core/Dto/SecurityNumbers/SecurityNumbersExportRequest.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Core.Dto.SecurityNumbers +{ + public class SecurityNumbersExportRequest : PaginationBaseRequestDto + { + /// + /// 生成记录Ids + /// + public List Ids { get; set; } = new List(); + } +} diff --git a/src/BarCode.Web.Core/Dto/SecurityNumbers/SecurityResponse.cs b/src/BarCode.Web.Core/Dto/SecurityNumbers/SecurityResponse.cs new file mode 100644 index 0000000..a65ef54 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/SecurityNumbers/SecurityResponse.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Core.Dto.SecurityNumbers +{ + /// + /// 防伪码信息 + /// + public class SecurityResponse + { + /// + /// 防伪码 + /// + public string Security { get; set; } = ""; + /// + /// 是否第一次查询 true 第一次 false 不是第一次 + /// + public bool IsOneQuery { get; set; } = false; + /// + /// 查询次数 + /// + public int QueryCount { get; set; } = 0; + /// + /// 第一次查询时间 + /// + public string QueryTime { get; set; } = ""; + } +} diff --git a/src/BarCode.Web.Core/Dto/SendDataDto.cs b/src/BarCode.Web.Core/Dto/SendDataDto.cs new file mode 100644 index 0000000..889adb2 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/SendDataDto.cs @@ -0,0 +1,98 @@ + +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto +{ + public class SendDataDto + { + /// + /// 客户编码 + /// + public string CustomerCode { get; set; } + + /// + /// 客户名称 + /// + public string CustomerName { get; set; } + + /// + /// 手机号码 + /// + public string PhoneNumbers { get; set; } + + /// + /// 邮箱 + /// + public string Emails { get; set; } + + /// + /// 邮箱 + /// + public List EmailList { get; set; } = new List(); + + /// + /// 明细 + /// + public List Details { get; set; } = new List(); + + } + + /// + /// 邮箱 + /// + public class MailAddress + { + public MailAddress(string name,string email) + { + this.Name = name; + this.Email = email; + } + + /// + /// 名称 + /// + public string Name { get; set; } + + /// + /// 地址 + /// + public string Email { get; set; } + } + + /// + /// 明细 + /// + public class SendDataDetailsDto + { + + ///// + ///// 任务明细ID + ///// + //public int TaskDetailId { get; set; } + + /// + /// 入库明细ID + /// + public int InStockDetailId { get; set; } + + /// + /// 物料名称 + /// + public string MaterialName { get; set; } + /// + /// 物料编码 + /// + public string MaterialNumber { get; set; } + /// + /// 物料规格型号 + /// + public string Specifications { get; set; } + + /// + /// 数量 + /// + public decimal Qty { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/SerialNumbers/GenerateSerialNumberRequest.cs b/src/BarCode.Web.Core/Dto/SerialNumbers/GenerateSerialNumberRequest.cs new file mode 100644 index 0000000..f8c03a4 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/SerialNumbers/GenerateSerialNumberRequest.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Core.Dto.SerialNumbers +{ + /// + /// 生成序列号请求参数 + /// + public class GenerateSerialNumberRequest + { + /// + /// 组织Code + /// + [Required(ErrorMessage = "组织不能为空")] + public string OrgCode { get; set; } = ""; + /// + /// 明细数据 + /// + public List Details { get; set; } = new List(); + } + /// + /// 生成序列号请求参数详情 + /// + public class GenerateSerialNumberInfoRequest + { + /// + /// 物料Id转32进制 + /// + public string IdConvertBar { get; set; } = ""; + /// + /// 物料编码 + /// + public string MaterialNumber { get; set; } = ""; + /// + /// 规格型号 + /// + [Required(ErrorMessage = "物料不能为空")] + public string Specifications { get; set; } = ""; + /// + /// 数量 + /// + [Required(ErrorMessage = "数量不能为空")] + public int Number { get; set; } + /// + /// 采购单号 + /// + [Required(ErrorMessage = "采购订单号不能为空")] + public string PurchaseBillNo { get; set; } = ""; + + /// + /// 是否套装 + /// + public int isTwo { get; set; } = 1; + } +} diff --git a/src/BarCode.Web.Core/Dto/SerialNumbers/OperateSerialNumberRequest.cs b/src/BarCode.Web.Core/Dto/SerialNumbers/OperateSerialNumberRequest.cs new file mode 100644 index 0000000..f59c2e1 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/SerialNumbers/OperateSerialNumberRequest.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Core.Dto.SerialNumbers +{ + /// + /// 操作序列号请求接口(打印 下载) + /// + public class OperateSerialNumberRequest + { + /// + /// 生成记录Id + /// + public List GenerateRecordIds { get; set; } = new List(); + /// + /// 是否全部操作 + /// + public bool IsAll { get; set; } = false; + /// + /// 如果是部分操作(序列号) 全部操作的话可不传 + /// + public List SerialNumbers { get; set; } = new List(); + } +} diff --git a/src/BarCode.Web.Core/Dto/SerialNumbers/SGenerateRecordInfoResponse.cs b/src/BarCode.Web.Core/Dto/SerialNumbers/SGenerateRecordInfoResponse.cs new file mode 100644 index 0000000..2facbb3 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/SerialNumbers/SGenerateRecordInfoResponse.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Core.Dto.SerialNumbers +{ + /// + /// 序列号生成记录列表返回参数 + /// + public class SGenerateRecordInfoResponse + { + /// + /// 主键编号 + /// + public int Id { get; set; } + /// + /// 物料规格型号 + /// + public string Specifications { get; set; } = string.Empty; + /// + /// 物料编码 + /// + public string MaterialNumber { get; set; } = string.Empty; + /// + /// 物料名称 + /// + public string MaterialName { get; set; } = string.Empty; + /// + /// 物料条码 + /// + public string BarCode { get; set; } = string.Empty; + /// + /// 采购单号 + /// + public string PurchaseBillNo { get; set; } = string.Empty; + /// + /// 生成完成 1 生成中 0 + /// + public string GenerateComplete { get; set; } = string.Empty; + /// + /// 生成条码数量 + /// + public int Number { get; set; } = 0; + /// + /// 打印数 + /// + public int PrintNumber { get; set; } = 0; + /// + /// 下载数 + /// + public int DownLoadNumber { get; set; } = 0; + /// + /// 使用数 + /// + public int UseNumber { get; set; } = 0; + /// + /// 创建人 + /// + public string Creator { get; set; } = string.Empty; + /// + /// 生成时间 + /// + public string CreateTime { get; set; } = string.Empty; + /// + /// 生成完成时间 + /// + public string GenerateCompleteTime { get; set; } = string.Empty; + /// + /// 供应商或组织 + /// + public string SupplierOrOrg { get; set; } = string.Empty; + /// + /// 是否更改过物料编码 + /// + public bool? IsUpdateMaterial { get; set; } = false; + /// + /// 是否两件装 + /// + public int? IsTwo { get; set; } = 1; + + } +} diff --git a/src/BarCode.Web.Core/Dto/SerialNumbers/SGenerateRecordQueryRequest.cs b/src/BarCode.Web.Core/Dto/SerialNumbers/SGenerateRecordQueryRequest.cs new file mode 100644 index 0000000..189d2f3 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/SerialNumbers/SGenerateRecordQueryRequest.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Core.Dto.SerialNumbers +{ + /// + /// 序列号生成记录列表请求参数 + /// + public class SGenerateRecordQueryRequest : PaginationBaseRequestDto + { + /// + /// 组织Code + /// + [Required(ErrorMessage = "组织不能为空")] + public string OrgCode { get; set; } = ""; + /// + /// 供应商或组织 + /// + public string SupplierOrOrg { get; set; } = ""; + /// + /// 创建时间 + /// + public DateTime? CreateBeginDate { get; set; } = null; + /// + /// 创建时间 + /// + public DateTime? CreateEndDate { get; set; } = null; + /// + /// 序列号集合 + /// + public List SerialNumbers { get; set; } = new List(); + /// + /// 生成完成 true 生成中 false 不搜 null或不传 + /// + public bool? GenerateComplete { get; set; } = null; + /// + /// 物料编码 + /// + public string MaterialNumber { get; set; } = ""; + /// + /// 采购单号 + /// + public List PurchaseBillNos { get; set; } = new List(); + /// + /// 箱号 + /// + public List BoxBillNos { get; set; } = new List(); + /// + /// 数字序列号 + /// + public List NumberCodes { get; set; } = new List(); + /// + /// 生成人 + /// + public string CreateUser { get; set; } = string.Empty; + /// + /// 是否更改过物料编码 + /// + public bool? IsUpdateMaterial { get; set; } = null; + + /// + /// 是否两件装 + /// + public int IsTwo { get; set; } = 0; + + } +} diff --git a/src/BarCode.Web.Core/Dto/SerialNumbers/SerialNumberByBoxIdQueryRequest.cs b/src/BarCode.Web.Core/Dto/SerialNumbers/SerialNumberByBoxIdQueryRequest.cs new file mode 100644 index 0000000..6ca8980 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/SerialNumbers/SerialNumberByBoxIdQueryRequest.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Core.Dto.SerialNumbers +{ + /// + /// 根据箱Id获取序列码信息 + /// + public class SerialNumberByBoxIdQueryRequest : PaginationBaseRequestDto + { + /// + /// 箱Id + /// + [Required(ErrorMessage = "箱不能为空")] + public int BoxId { get; set; } = 0; + } +} diff --git a/src/BarCode.Web.Core/Dto/SerialNumbers/SerialNumberInfoResponse.cs b/src/BarCode.Web.Core/Dto/SerialNumbers/SerialNumberInfoResponse.cs new file mode 100644 index 0000000..4a042a8 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/SerialNumbers/SerialNumberInfoResponse.cs @@ -0,0 +1,121 @@ +using Npoi.Mapper.Attributes; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Core.Dto.SerialNumbers +{ + /// + /// 序列号列表搜索返回参数 + /// + public class SerialNumberInfoResponse + { + /// + /// 物料编码 + /// + [Column("物料编码")] + public string MaterialNumber { get; set; } = string.Empty; + /// + /// 物料名称 + /// + [Column("名称")] + public string MaterialName { get; set; } = string.Empty; + /// + /// 物料规格型号 + /// + [Column("规格型号")] + public string Specifications { get; set; } = string.Empty; + /// + /// 转换前规格型号 + /// + [Column("转换前规格型号")] + public string Old_Specifications { get; set; } = string.Empty; + /// + /// 物料条码 + /// + [Column("条码")] + public string BarCode { get; set; } = string.Empty; + /// + /// 序列码 + /// + [Column("序列码")] + public string SerialNumber { get; set; } = string.Empty; + /// + /// 数字序列码 + /// + [Column("数字序列码")] + public string NumberCode { get; set; } = string.Empty; + /// + /// 序列码流水号 + /// + [Column("序号")] + public long Id { get; set; } + /// + /// 数量 + /// + [Column("数量")] + public int Number { get; set; } = 0; + /// + /// 是否使用 + /// + [Ignore] + public bool IsUse { get; set; } = false; + /// + /// 是否使用 + /// + [Column("是否使用")] + public string IsUseStr { get; set; } = ""; + /// + /// 箱号 + /// + [Column("所在箱号")] + public string Box { get; set; } = string.Empty; + /// + /// 创建人 + /// + [Ignore] + public string Creator { get; set; } = string.Empty; + /// + /// 生成时间 + /// + [Column("生成时间")] + public string CreateTime { get; set; } = string.Empty; + /// + /// 打印次数 + /// + [Column("打印次数")] + public int PrintNumber { get; set; } = 0; + /// + /// 下载次数 + /// + [Column("下载次数")] + public int DownLoadNumber { get; set; } = 0; + /// + /// 最新打印时间 + /// + [Column("最近打印时间")] + public string PrintTime { get; set; } = string.Empty; + /// + /// 最新下载时间 + /// + [Column("最近下载时间")] + public string DownLoadTime { get; set; } = string.Empty; + /// + /// 是否允许打印(序列码已经被使用 但没有箱号,那么就是被wms系统拉去使用了,不能再被打印) + /// + [Ignore] + public bool IsEnablePrint { get; set; } = true; + + /// + /// 是否为两件装,为了控制后面的变动,设为整数形,0和1看作1,2代表2件装,3代表三件装 alter by yzh + /// + public int IsTwo { get; set; } = 1; + /// + /// 第二个序列号 + /// + public string TwoSerialNumber { get; set; } = string.Empty; + + } +} diff --git a/src/BarCode.Web.Core/Dto/SerialNumbers/SerialNumberQueryRequest.cs b/src/BarCode.Web.Core/Dto/SerialNumbers/SerialNumberQueryRequest.cs new file mode 100644 index 0000000..d8aa648 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/SerialNumbers/SerialNumberQueryRequest.cs @@ -0,0 +1,87 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Core.Dto.SerialNumbers +{ + /// + /// 序列号列表搜索请求参数 + /// + public class SerialNumberQueryRequest : PaginationBaseRequestDto + { + /// + /// 组织Code + /// + [Required(ErrorMessage = "组织不能为空")] + public string OrgCode { get; set; } = ""; + /// + /// 生成记录Id + /// + [Required(ErrorMessage = "生成记录不能为空")] + public int GenerateRecordId { get; set; } = 0; + /// + /// 打印状态 已打印 true 未打印 false + /// + public bool? IsPrint { get; set; } = null; + /// + /// 使用状态 已使用 true 未使用 false + /// + public bool? IsUse { get; set; } = null; + /// + /// 下载时间 + /// + public DateTime? DownLoadBeginDate { get; set; } = null; + /// + /// 下载时间 + /// + public DateTime? DownLoadEndDate { get; set; } = null; + /// + /// 打印时间 + /// + public DateTime? PrintBeginDate { get; set; } = null; + /// + /// 打印时间 + /// + public DateTime? PrintEndDate { get; set; } = null; + /// + /// 序列号 + /// + public List SerialNumbers { get; set; } = new List(); + /// + /// 序号区间-开始 + /// + public long? SerialNumberBegin { get; set; } = null; + /// + /// 序号区间-结束 + /// + public long? SerialNumberEnd { get; set; } = null; + /// + /// 是否更改过物料编码 + /// + public bool? IsUpdateMaterial { get; set; } = null; + /// + /// 箱号 + /// + public string BoxBillNo { get; set; } = ""; + /// + /// 数字序列号 + /// + public List NumberCodes { get; set; } = new List(); + /// + /// 数字序列码-开始 + /// + public string NumberCodeBegin { get; set; } = string.Empty; + /// + /// 数字序列码-结束 + /// + public string NumberCodeEnd { get; set; } = string.Empty; + /// + /// 是否为两件装,为了控制后面的变动,设为整数形,0和1看作1,2代表2件装,3代表三件装 alter by yzh + /// + public int isTwo { get; set; } =1; + + } +} diff --git a/src/BarCode.Web.Core/Dto/SerialNumbers/SerialNumbersExportReponse.cs b/src/BarCode.Web.Core/Dto/SerialNumbers/SerialNumbersExportReponse.cs new file mode 100644 index 0000000..bd0c1cb --- /dev/null +++ b/src/BarCode.Web.Core/Dto/SerialNumbers/SerialNumbersExportReponse.cs @@ -0,0 +1,56 @@ +using Npoi.Mapper.Attributes; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Core.Dto.SerialNumbers +{ + /// + /// 序列码导出数据 + /// + public class SerialNumbersExportReponse + { + /// + /// 供应商或组织 + /// + [Column("供应商")] + public string SupplierOrOrg { get; set; } = string.Empty; + /// + /// 物料编码 + /// + [Column("物料编码")] + public string MaterialNumber { get; set; } = string.Empty; + /// + /// 物料名称 + /// + [Column("物料名称")] + public string MaterialName { get; set; } = string.Empty; + /// + /// 物料规格型号 + /// + [Column("规格型号")] + public string Specifications { get; set; } = string.Empty; + /// + /// 物料条码 + /// + [Column("条码")] + public string BarCode { get; set; } = string.Empty; + /// + /// 序列码 + /// + [Column("序列码")] + public string SerialNumber { get; set; } = string.Empty; + /// + /// 数字序列码 + /// + [Column("数字序列码")] + public string NumberCode { get; set; } = string.Empty; + /// + /// 数量 + /// + [Column("数量")] + public int Number { get; set; } = 0; + } +} diff --git a/src/BarCode.Web.Core/Dto/SerialNumbers/SerialNumbersExportRequest.cs b/src/BarCode.Web.Core/Dto/SerialNumbers/SerialNumbersExportRequest.cs new file mode 100644 index 0000000..2a3877d --- /dev/null +++ b/src/BarCode.Web.Core/Dto/SerialNumbers/SerialNumbersExportRequest.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Core.Dto.SerialNumbers +{ + /// + /// 序列码导出参数 + /// + public class SerialNumbersExportRequest : PaginationBaseRequestDto + { + /// + /// 生成记录Ids + /// + public List Ids { get; set; } = new List(); + } +} diff --git a/src/BarCode.Web.Core/Dto/SerialNumbers/SerialNumbersExternalResponse.cs b/src/BarCode.Web.Core/Dto/SerialNumbers/SerialNumbersExternalResponse.cs new file mode 100644 index 0000000..d02bc14 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/SerialNumbers/SerialNumbersExternalResponse.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Core.Dto.SerialNumbers +{ + /// + /// 序列码信息 + /// + public class SerialNumbersExternalResponse + { + /// + /// 序列号 + /// + public string SerialNumber { get; set; } + /// + /// 物料名称 + /// + public string MaterialName { get; set; } + /// + /// 物料编码 + /// + public string MaterialNumber { get; set; } + /// + /// 物料规格型号 + /// + public string Specifications { get; set; } + /// + /// 生成时间时间 + /// + public string CreateTime { get; set; } + /// + /// 采购单号 + /// + public string PurchaseBillNo { get; set; } + /// + /// 供应商 + /// + public string Supplier { get; set; } = ""; + + } +} diff --git a/src/BarCode.Web.Core/Dto/SerialNumbers/SerialNumbersResponse.cs b/src/BarCode.Web.Core/Dto/SerialNumbers/SerialNumbersResponse.cs new file mode 100644 index 0000000..d230dab --- /dev/null +++ b/src/BarCode.Web.Core/Dto/SerialNumbers/SerialNumbersResponse.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Core.Dto.SerialNumbers +{ + /// + /// 序列号信息 + /// + public class SerialNumbersResponse + { + /// + /// 物料规格型号 + /// + public string Specifications { get; set; } = string.Empty; + /// + /// 物料编码 + /// + public string MaterialNumber { get; set; } = string.Empty; + /// + /// 物料名称 + /// + public string MaterialName { get; set; } = string.Empty; + + /// + /// 物料条码 + /// + public string BarCode { get; set; } = string.Empty; + /// + /// 序列号 + /// + public string SerialNumber { get; set; } = string.Empty; + /// + /// 数字序列号 + /// + public string NumberCode { get; set; } = string.Empty; + /// + /// 箱号 + /// + public int BoxId { get; set; } + /// + /// 是否已经装箱 true 已经装箱 false 未装箱 + /// + public bool IsCarton { get; set; } + /// + /// 是否是已经存在的数据 默认就是true + /// 前端操作新增加的数据就是false 后端保存到数据库才会变成true + /// + public bool IsOldData { get; set; } = true; + /// + /// 是否使用的是数字序列码未使用null,数字序列码true,序列码false + /// + public bool? IsUseNumber { get; set; } = null; + /// + /// 是否为两件套产品 + /// + public int IsTwo { get; set; } = 1; + + /// + /// 套装编码 + /// + public string SuitNumber { get; set; } = string.Empty; + + /// + /// 第二个序列码 + /// + public string TwoSerialNumber { get; set; } = string.Empty; + + + } +} diff --git a/src/BarCode.Web.Core/Dto/SerialNumbers/SerialNumbersWmsRequest.cs b/src/BarCode.Web.Core/Dto/SerialNumbers/SerialNumbersWmsRequest.cs new file mode 100644 index 0000000..dd8258c --- /dev/null +++ b/src/BarCode.Web.Core/Dto/SerialNumbers/SerialNumbersWmsRequest.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Core.Dto.SerialNumbers +{ + /// + /// 获取没有装过箱的序列码 + /// + public class SerialNumbersWmsRequest + { + /// + /// 序列号 + /// + public string SerialNumber { get; set; } = string.Empty; + } +} diff --git a/src/BarCode.Web.Core/Dto/SerialNumbers/SerialNumbersWmsResponse.cs b/src/BarCode.Web.Core/Dto/SerialNumbers/SerialNumbersWmsResponse.cs new file mode 100644 index 0000000..069a3f6 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/SerialNumbers/SerialNumbersWmsResponse.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Core.Dto.SerialNumbers +{ + /// + /// wms系统请求序列码返回 + /// + public class SerialNumbersWmsResponse + { + /// + /// 序列号 + /// + public string SerialNumber { get; set; } = string.Empty; + /// + /// 物料编码 + /// + public string MaterialNumber { get; set; } = string.Empty; + /// + /// 创建人 + /// + public string Creator { get; set; } = string.Empty; + /// + /// 生成时间 + /// + public DateTime CreateTime { get; set; } = DateTime.Now; + } +} diff --git a/src/BarCode.Web.Core/Dto/SerialNumbers/UpdateMaterialRequest.cs b/src/BarCode.Web.Core/Dto/SerialNumbers/UpdateMaterialRequest.cs new file mode 100644 index 0000000..a26e362 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/SerialNumbers/UpdateMaterialRequest.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Core.Dto.SerialNumbers +{ + /// + /// 修改序列号的物料 + /// + public class UpdateMaterialRequest + { + /// + /// 生成记录Id + /// + [Required(ErrorMessage = "生成记录不能为空")] + public int GenerateRecordId { get; set; } + /// + /// 物料编码 + /// + [Required(ErrorMessage = "物料编码不能为空")] + public string MaterialNumber { get; set; } = string.Empty; + /// + /// 操作(序列号) + /// + public List SerialNumbers { get; set; } = new List(); + } +} diff --git a/src/BarCode.Web.Core/Dto/SingleData/CodeRequest.cs b/src/BarCode.Web.Core/Dto/SingleData/CodeRequest.cs new file mode 100644 index 0000000..9e5ee41 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/SingleData/CodeRequest.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.SingleData +{ + public class CodeRequest : SingleDataRequest + { + public CodeRequest() { } + + public CodeRequest(string code, int companyId) + { + this.Code = code; + this.CompanyId = companyId; + } + + public string Code { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/SingleData/CodesRequest.cs b/src/BarCode.Web.Core/Dto/SingleData/CodesRequest.cs new file mode 100644 index 0000000..c562c99 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/SingleData/CodesRequest.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.SingleData +{ + public class CodesRequest : SingleDataRequest + { + public CodesRequest() { } + + public CodesRequest(List codes, int companyId) + { + this.Codes = codes; + this.CompanyId = companyId; + } + + public List Codes { get; set; } = new List(); + } +} diff --git a/src/BarCode.Web.Core/Dto/SingleData/IdRequest.cs b/src/BarCode.Web.Core/Dto/SingleData/IdRequest.cs new file mode 100644 index 0000000..a33f451 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/SingleData/IdRequest.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.SingleData +{ + /// + /// ID请求对象 + /// + public class IdRequest:SingleDataRequest + { + public IdRequest() { } + + public IdRequest(int id, int companyId) + { + this.Id = id; + this.CompanyId = companyId; + } + + /// + /// ID + /// + public int Id { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/SingleData/IdsRequest.cs b/src/BarCode.Web.Core/Dto/SingleData/IdsRequest.cs new file mode 100644 index 0000000..8b04534 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/SingleData/IdsRequest.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.SingleData +{ + public class IdsRequest : SingleDataRequest + { + public IdsRequest() { } + + public IdsRequest(List ids,int companyId) + { + this.Ids = ids; + this.CompanyId = companyId; + } + + /// + /// Id集合 + /// + public List Ids { get; set; } = new List(); + } +} diff --git a/src/BarCode.Web.Core/Dto/SingleData/NameRequest.cs b/src/BarCode.Web.Core/Dto/SingleData/NameRequest.cs new file mode 100644 index 0000000..58dc856 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/SingleData/NameRequest.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.SingleData +{ + /// + /// 名称请求对象 + /// + public class NameRequest:SingleDataRequest + { + public NameRequest() { } + + public NameRequest(string name,int companyId) + { + this.Name = name; + this.CompanyId = companyId; + } + + /// + /// 名称 + /// + public string Name { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/SingleData/OrgAllResponse.cs b/src/BarCode.Web.Core/Dto/SingleData/OrgAllResponse.cs new file mode 100644 index 0000000..ae32fa9 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/SingleData/OrgAllResponse.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.SingleData +{ + public class OrgAllResponse + { + /// + /// + /// + public int Id { get; set; } + + /// + /// 编码 + /// + public string OrgCode { get; set; } = string.Empty; + /// + /// erp对应Code + /// + public string ErpOrgCode { get; set; } = string.Empty; + /// + /// 名称 + /// + public string Name { get; set; } = string.Empty; + /// + /// 组织类型:1为主业务,2为辅业务 3为工厂 + /// + public string OrgType { get; set; } = string.Empty; + + /// + /// 本位币名称 + /// + public string StandardCoin { get; set; } = string.Empty; + + /// + /// 本位币id + /// + public int? StandardCoinId { get; set; } + + /// + /// 自动排产默认入库仓库 + /// + public int? AutoDetaultStockId { get; set; } + + /// + /// 是否禁用:true为禁用,false为启用 + /// + public bool Disable { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/SingleData/SingleDataRequest.cs b/src/BarCode.Web.Core/Dto/SingleData/SingleDataRequest.cs new file mode 100644 index 0000000..f56f289 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/SingleData/SingleDataRequest.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.SingleData +{ + /// + /// 单点数据-请求统一对象 + /// + public class SingleDataRequest + { + public SingleDataRequest() { } + + public SingleDataRequest(int companyId) + { + this.CompanyId = companyId; + } + + /// + /// 公司ID + /// + public int CompanyId { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/SingleData/SingleDataResponse.cs b/src/BarCode.Web.Core/Dto/SingleData/SingleDataResponse.cs new file mode 100644 index 0000000..7d7d5f3 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/SingleData/SingleDataResponse.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.SingleData +{ + /// + /// 单点数据响应-统一对象 + /// + public class SingleDataResponse + { + /// + /// ID + /// + public int Id { get; set; } + + /// + /// 编码 + /// + public string Code { get; set; } + + /// + /// 名称 + /// + public string Name { get; set; } + /// + /// 组织编码对应金蝶 + /// + public string ErpOrgCode { get; set; } = ""; + /// + /// 数值 + /// + public decimal Number { get; set; } + + /// + /// 是否禁用:true为禁用,false为启用 + /// + public bool Disable { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/SingleData/SubStockRequest.cs b/src/BarCode.Web.Core/Dto/SingleData/SubStockRequest.cs new file mode 100644 index 0000000..c743fd0 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/SingleData/SubStockRequest.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.SingleData +{ + /// + /// 仓位 + /// + public class SubStockRequest + { + + public SubStockRequest() { } + public SubStockRequest(int stockId) + { + this.StockId = stockId; + } + + /// + /// 仓库ID + /// + public int StockId { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/SingleData/SupplierInfoResponse.cs b/src/BarCode.Web.Core/Dto/SingleData/SupplierInfoResponse.cs new file mode 100644 index 0000000..4036b8b --- /dev/null +++ b/src/BarCode.Web.Core/Dto/SingleData/SupplierInfoResponse.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.SingleData +{ + /// + /// 供应商信息 + /// + public class SupplierInfoResponse + { + /// + /// 供应商Id + /// + public int Id { get; set; } + /// + /// 供应商编码 + /// + public string Code { get; set; } = string.Empty; + /// + /// 供应商名字 + /// + public string Name { get; set; } = string.Empty; + } +} diff --git a/src/BarCode.Web.Core/Dto/SingleData/SysOrgResponse.cs b/src/BarCode.Web.Core/Dto/SingleData/SysOrgResponse.cs new file mode 100644 index 0000000..5f6edf8 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/SingleData/SysOrgResponse.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.SingleData +{ + /// + /// 组织返回对象 + /// + public class SysOrgResponse + { + /// + /// + /// + public int Id { get; set; } + + /// + /// 编码 + /// + public string OrgCode { get; set; } + /// + /// 名称 + /// + public string Name { get; set; } + /// + /// 组织类型:1为主业务,2为辅业务 3为工厂 + /// + public string OrgType { get; set; } + + /// + /// 本位币名称 + /// + public string StandardCoin { get; set; } + + /// + /// 本位币id + /// + public int? StandardCoinId { get; set; } + + /// + /// 自动排产默认入库仓库 + /// + public int? AutoDetaultStockId { get; set; } + + /// + /// 是否禁用:true为禁用,false为启用 + /// + public bool Disable { get; set; } + /// + /// erp对应Code + /// + public string ErpOrgCode { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/SingleData/SysStaffResponse.cs b/src/BarCode.Web.Core/Dto/SingleData/SysStaffResponse.cs new file mode 100644 index 0000000..20b9367 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/SingleData/SysStaffResponse.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.SingleData +{ + /// + /// 员工响应 + /// + public class SysStaffResponse + { + /// + /// StaffID + /// + public int Id { get; set; } + + /// + /// 名称 + /// + public string Name { get; set; } + + /// + /// 部门ID + /// + public int DeptId { get; set; } + + /// + /// 电话 + /// + public string Telephone { get; set; } + + /// + /// 是否禁用:true为禁用,false为启用 + /// + public bool Disable { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/SingleData/SystemCodeRequest.cs b/src/BarCode.Web.Core/Dto/SingleData/SystemCodeRequest.cs new file mode 100644 index 0000000..2bc4d53 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/SingleData/SystemCodeRequest.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Text; + +namespace BarCode.Web.Core.Dto.SingleData +{ + /// + /// 系统code获取 + /// + public class SystemCodeRequest : SingleDataRequest + { + public SystemCodeRequest() { } + + public SystemCodeRequest(string systemCode,string name, int companyId) + { + this.Code = systemCode; + this.Name = name; + this.CompanyId = companyId; + } + /// + /// 系统code + /// + [Required(ErrorMessage = "系统code不能未空")] + public string Code { get; set; } + + /// + /// 仓库名称 + /// + public string Name { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/SingleData/UcStockResponse.cs b/src/BarCode.Web.Core/Dto/SingleData/UcStockResponse.cs new file mode 100644 index 0000000..f7014ae --- /dev/null +++ b/src/BarCode.Web.Core/Dto/SingleData/UcStockResponse.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Text; + +namespace BarCode.Web.Core.Dto.SingleData +{ + /// + /// 仓库响应 + /// + public class UcStockResponse + { + /// + /// id + /// + public int Id { get; set; } + /// + /// 名称 + /// + public string Name { get; set; } + /// + /// 编码 + /// + public string Code { get; set; } + + /// + /// 对应金蝶的组织编码 + /// + public string ErpOrgCode { get; set; } + + /// + /// 是否禁用:true为禁用,false为启用 + /// + public bool Disable { get; set; } + + + } +} diff --git a/src/BarCode.Web.Core/Dto/SingleData/UcSubStockResponse.cs b/src/BarCode.Web.Core/Dto/SingleData/UcSubStockResponse.cs new file mode 100644 index 0000000..8ee7e09 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/SingleData/UcSubStockResponse.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.SingleData +{ + /// + /// 仓位响应对象 + /// + public class UcSubStockResponse + { + /// + /// id + /// + public int Id { get; set; } + + /// + /// 仓库ID + /// + public int StockId { get; set; } + + /// + /// 仓库名称 + /// + public string StockName { get; set; } + + /// + /// 仓库code + /// + public string StockCode { get; set; } + + /// + /// 对应的金蝶组织编码 + /// + public string ErpOrgCode { get; set; } + + + /// + /// 名称 + /// + public string Name { get; set; } + + /// + /// 编码 + /// + public string Code { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/SingleData/UserRequest.cs b/src/BarCode.Web.Core/Dto/SingleData/UserRequest.cs new file mode 100644 index 0000000..83613e2 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/SingleData/UserRequest.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto.SingleData +{ + /// + /// 人员请求对象 + /// + public class UserRequest + { + public UserRequest() + { + } + public UserRequest(int userId) + { + this.UserId = userId; + } + /// + /// 用户ID + /// + public int UserId { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/SubUcStockRequset.cs b/src/BarCode.Web.Core/Dto/SubUcStockRequset.cs new file mode 100644 index 0000000..f32e2e0 --- /dev/null +++ b/src/BarCode.Web.Core/Dto/SubUcStockRequset.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Dto +{ + /// + /// 请求仓位对象 + /// + public class SubUcStockRequset + { + /// + /// 名称 + /// + public string Name { get; set; } + + /// + /// 仓库 + /// + public string StockCode { get; set; } + + /// + /// 组织 + /// + public string OrgCode { get; set; } + } +} diff --git a/src/BarCode.Web.Core/Dto/TemplateExcel.cs b/src/BarCode.Web.Core/Dto/TemplateExcel.cs new file mode 100644 index 0000000..d3cc8aa --- /dev/null +++ b/src/BarCode.Web.Core/Dto/TemplateExcel.cs @@ -0,0 +1,34 @@ +using Npoi.Mapper.Attributes; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Core.Dto +{ + /// + /// 生成序列号模板 + /// + public class TemplateExcel + { + public TemplateExcel() + { + } + /// + /// 物料规格型号 + /// + [Column("规格型号*")] + public string Specifications { get; set; } = string.Empty; + /// + /// 物料名称 + /// + [Column("生成数量*")] + public string Number { get; set; } + /// + /// 采购单号 + /// + [Column("采购订单号*")] + public string PurchaseBillNo { get; set; } = string.Empty; + } +} diff --git a/src/BarCode.Web.Core/EntityBase.cs b/src/BarCode.Web.Core/EntityBase.cs new file mode 100644 index 0000000..79122b0 --- /dev/null +++ b/src/BarCode.Web.Core/EntityBase.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core +{ + /// + /// 基类 + /// + [Serializable] + public class EntityBase + { + /// + /// Id + /// + public virtual int Id { get; set; } + } + /// + /// 基类 + /// + [Serializable] + public class EntityLongBase + { + /// + /// Id + /// + public virtual long Id { get; set; } + } +} diff --git a/src/BarCode.Web.Core/EnumOperate.cs b/src/BarCode.Web.Core/EnumOperate.cs new file mode 100644 index 0000000..53654e7 --- /dev/null +++ b/src/BarCode.Web.Core/EnumOperate.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Text; + +namespace BarCode.Web.Core +{ + public class EnumRemarkAttribute : Attribute + { + public string Remark { get; set; } + public EnumRemarkAttribute(string remark) + { + this.Remark = remark; + } + } + + + public static class EnumOperate + { + public static string GetRemark(this Enum enumInfo) + { + if (enumInfo == null) return ""; + Type type = enumInfo.GetType(); + //获取字段信息 + FieldInfo field = type.GetField(enumInfo.ToString()); + if (field == null) return ""; + //检查字段是否含有指定特性 + if (field.IsDefined(typeof(EnumRemarkAttribute), true)) + { + //获取字段上的自定义特性 + EnumRemarkAttribute remarkAttribute = (EnumRemarkAttribute)field.GetCustomAttribute(typeof(EnumRemarkAttribute)); + return remarkAttribute.Remark; + } + else + { + return enumInfo.ToString(); + } + } + } + + public class PropertyRemarkAttribute : Attribute + { + public string Remark { get; set; } + public PropertyRemarkAttribute(string remark) + { + this.Remark = remark; + } + } +} diff --git a/src/BarCode.Web.Core/Exceptions/WebHttpException.cs b/src/BarCode.Web.Core/Exceptions/WebHttpException.cs new file mode 100644 index 0000000..b0e9578 --- /dev/null +++ b/src/BarCode.Web.Core/Exceptions/WebHttpException.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Exceptions +{ + public class WebHttpException : Exception + { + public string ErrorCode { get; set; } + + public string ErrorMessage { get; set; } + + public WebHttpException() + { + } + + public WebHttpException(string errorCode, string errorMessage) + { + ErrorCode = errorCode; + ErrorMessage = errorMessage; + } + } +} diff --git a/src/BarCode.Web.Core/Help/CacheHelp.cs b/src/BarCode.Web.Core/Help/CacheHelp.cs new file mode 100644 index 0000000..fdfda6e --- /dev/null +++ b/src/BarCode.Web.Core/Help/CacheHelp.cs @@ -0,0 +1,50 @@ +using Microsoft.Extensions.Caching.Memory; +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Help +{ + public class CacheHelp + { + + /// + /// 定义cache + /// + private static MemoryCache cache = new MemoryCache(new MemoryCacheOptions()); + + /// + /// 设置cache + /// + /// 键 + /// 值 + public static void SetCacheValue(string key, object value) + { + if (key != null) + { + cache.Set(key, value, new MemoryCacheEntryOptions + { + //SlidingExpiration = TimeSpan.FromSeconds(10) + }); + } + } + + /// + /// 获取cache + /// + /// 键 + /// + public static object GetCacheValue(string key) + { + object val = null; + if (key != null && cache.TryGetValue(key, out val)) + { + return val; + } + else + { + return default(object); + } + } + } +} diff --git a/src/BarCode.Web.Core/Help/ClassClone.cs b/src/BarCode.Web.Core/Help/ClassClone.cs new file mode 100644 index 0000000..7b5cc03 --- /dev/null +++ b/src/BarCode.Web.Core/Help/ClassClone.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Text; + +namespace BarCode.Web.Core.Help +{ + [Serializable] + public static class ClassClone + { + public static void CopyPropertiesToD(this object s, D d) + { + try + { + var Types = s.GetType();//获得类型 + var Typed = d.GetType(); + foreach (PropertyInfo sp in Types.GetProperties())//获得类型的属性字段 + { + foreach (PropertyInfo dp in Typed.GetProperties()) + { + if (dp.Name == sp.Name)//判断属性名是否相同 + { + dp.SetValue(d, sp.GetValue(s, null), null);//获得s对象属性的值复制给d对象的属性 + } + } + } + } + catch (Exception e) + { + throw e; + } + } + } +} diff --git a/src/BarCode.Web.Core/Help/ClassCopyUtil.cs b/src/BarCode.Web.Core/Help/ClassCopyUtil.cs new file mode 100644 index 0000000..1c76aec --- /dev/null +++ b/src/BarCode.Web.Core/Help/ClassCopyUtil.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq.Expressions; +using System.Runtime.Serialization.Formatters.Binary; +using System.Text; + +namespace BarCode.Web.Core.Help +{ + [Serializable] + public static class ClassCopyUtil + { + ///// + ///// 深度copy + ///// + ///// + ///// + ///// + //public static T Clone(this T t) where T : class + //{ + // if (!typeof(T).IsSerializable) + // { + // throw new ArgumentException("The class type must be serializable.", "source"); + // } + // object retval; + // using (MemoryStream ms = new MemoryStream()) + // { + // BinaryFormatter bf = new BinaryFormatter(); + // //序列化成流 + // bf.Serialize(ms, obj); + // ms.Seek(0, SeekOrigin.Begin); + // //反序列化成对象 + // retval = bf.Deserialize(ms); + // ms.Close(); + // } + // return (T)retval; + //} + private static readonly Func cache = GetFunc(); + private static Func GetFunc() + { + ParameterExpression parameterExpression = Expression.Parameter(typeof(TIn), "p"); + List memberBindingList = new List(); + + foreach (var item in typeof(TOut).GetProperties()) + { + if (!item.CanWrite) continue; + MemberExpression property = Expression.Property(parameterExpression, typeof(TIn).GetProperty(item.Name)); + MemberBinding memberBinding = Expression.Bind(item, property); + memberBindingList.Add(memberBinding); + } + + MemberInitExpression memberInitExpression = Expression.MemberInit(Expression.New(typeof(TOut)), memberBindingList.ToArray()); + Expression> lambda = Expression.Lambda>(memberInitExpression, new ParameterExpression[] { parameterExpression }); + + return lambda.Compile(); + } + + public static TOut Trans(TIn tIn) + { + return cache(tIn); + } + } +} diff --git a/src/BarCode.Web.Core/Help/DateTimeUtil.cs b/src/BarCode.Web.Core/Help/DateTimeUtil.cs new file mode 100644 index 0000000..85e6fb1 --- /dev/null +++ b/src/BarCode.Web.Core/Help/DateTimeUtil.cs @@ -0,0 +1,239 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Help +{ + /// + /// 时间转换 + /// + public static class DateTimeUtil + { + /// + /// 时间戳计时开始时间 + /// + private static DateTime timeStampStartTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); + + /// + /// DateTime转换为10位时间戳(单位:秒) + /// + /// DateTime + /// 10位时间戳(单位:秒) + public static long DateTimeToTimeStamp(this DateTime dateTime) + { + return (long)(dateTime.ToUniversalTime() - timeStampStartTime).TotalSeconds; + } + + /// + /// DateTime转换为13位时间戳(单位:毫秒) + /// + /// DateTime + /// 13位时间戳(单位:毫秒) + public static long DateTimeToLongTimeStamp(this DateTime dateTime) + { + return (long)(dateTime.ToUniversalTime() - timeStampStartTime).TotalMilliseconds; + } + + /// + /// 10位时间戳(单位:秒)转换为DateTime + /// + /// 10位时间戳(单位:秒) + /// DateTime + public static DateTime TimeStampToDateTime(this long timeStamp) + { + return timeStampStartTime.AddSeconds(timeStamp).ToLocalTime(); + } + + /// + /// 13位时间戳(单位:毫秒)转换为DateTime + /// + /// 13位时间戳(单位:毫秒) + /// DateTime + public static DateTime LongTimeStampToDateTime(this long longTimeStamp) + { + return timeStampStartTime.AddMilliseconds(longTimeStamp).ToLocalTime(); + } + + + /// + /// 转字符串 + /// + /// ) + /// DateTime + public static string DateToStringDay(this DateTime? date) + { + if (date == null) return ""; + try + { + DateTime dt = Convert.ToDateTime(date); + return dt.ToString("yyyy-MM-dd"); + } + catch (Exception) + { + return ""; + } + } + /// + /// 转字符串 + /// + /// ) + /// DateTime + public static string DateToStringSeconds(this DateTime? date) + { + if (date == null) return ""; + try + { + DateTime dt = Convert.ToDateTime(date); + return dt.ToString("yyyy-MM-dd HH:mm:ss"); + } + catch (Exception) + { + return ""; + } + } + /// + /// 转字符串(没有空格) + /// + /// ) + /// DateTime + public static string DateToStringSecondsNoSpace(this DateTime? date) + { + if (date == null) return ""; + try + { + DateTime dt = Convert.ToDateTime(date); + return dt.ToString("yyyyMMddHHmmss"); + } + catch (Exception) + { + return ""; + } + } + /// + /// 转字符串(没有空格) + /// + /// ) + /// DateTime + public static string DateToStringSecondsNoSpace(this DateTime date) + { + if (date == null) return ""; + try + { + DateTime dt = Convert.ToDateTime(date); + return dt.ToString("yyyyMMddHHmmssfff"); + } + catch (Exception) + { + return ""; + } + } + /// + /// 转字符串 + /// + /// ) + /// DateTime + public static string DateToStringMonth(this DateTime? date) + { + if (date == null) return ""; + try + { + DateTime dt = Convert.ToDateTime(date); + return dt.ToString("MM年dd月"); + } + catch (Exception) + { + return ""; + } + } + + /// + /// 转字符串 + /// + /// ) + /// DateTime + public static string DateToStringDay(this DateTime date) + { + if (date == null) return ""; + try + { + DateTime dt = Convert.ToDateTime(date); + return dt.ToString("yyyy-MM-dd"); + } + catch (Exception) + { + return ""; + } + } + /// + /// 转字符串 + /// + /// ) + /// DateTime + public static string DateToStringSeconds(this DateTime date) + { + if (date == null) return ""; + try + { + DateTime dt = Convert.ToDateTime(date); + return dt.ToString("yyyy-MM-dd HH:mm:ss"); + } + catch (Exception) + { + return ""; + } + } + /// + /// 转字符串 + /// + /// ) + /// DateTime + public static string DateToStringMonth(this DateTime date) + { + if (date == null) return ""; + try + { + DateTime dt = Convert.ToDateTime(date); + return dt.ToString("MM年dd月"); + } + catch (Exception) + { + return ""; + } + } + + /// + /// 两个时间的差:分钟 + /// + /// + /// + /// + public static double GetTotalMinutesTimeSpan(DateTime beginTime, DateTime endTime) + { + string dateDiff = null;//获取当前时间 + TimeSpan ts1 = new TimeSpan(beginTime.Ticks); + TimeSpan ts2 = new TimeSpan(endTime.Ticks); + //时间比较,得出差值 + TimeSpan ts = ts1.Subtract(ts2).Duration();//结果 + dateDiff = ts.Days.ToString() + "天" + ts.Hours.ToString() + "小时" + ts.Minutes.ToString() + "分钟" + ts.Seconds.ToString() + "秒"; + return ts.TotalMinutes; + } + + /// + /// 当前时间和今晚0点之间的时间的差:分钟 + /// + /// + public static double GetTotalMinutesTimeSpan() + { + string dateDiff = null;//获取当前时间 + DateTime DateTime1 = DateTime.Now; + //第二天的0点00分00秒 + DateTime DateTime2 = DateTime.Now.AddDays(1).Date;//把2个时间转成TimeSpan,方便计算 + TimeSpan ts1 = new TimeSpan(DateTime1.Ticks); + TimeSpan ts2 = new TimeSpan(DateTime2.Ticks); + //时间比较,得出差值 + TimeSpan ts = ts1.Subtract(ts2).Duration();//结果 + dateDiff = ts.Days.ToString() + "天" + ts.Hours.ToString() + "小时" + ts.Minutes.ToString() + "分钟" + ts.Seconds.ToString() + "秒"; + return ts.TotalMinutes; + } + } +} diff --git a/src/BarCode.Web.Core/Help/HttpClientHelp.cs b/src/BarCode.Web.Core/Help/HttpClientHelp.cs new file mode 100644 index 0000000..88cc1ea --- /dev/null +++ b/src/BarCode.Web.Core/Help/HttpClientHelp.cs @@ -0,0 +1,174 @@ +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using System; +using System.Collections.Generic; +using System.IO; +using System.Json; +using System.Net; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Security.Cryptography; +using System.Text; +using System.Threading.Tasks; +using BarCode.Web.Core.Dto.Login; + +namespace BarCode.Web.Core.Help +{ + public class HttpClientHelp + { + private ILogger _logger; + + public HttpClientHelp(ILogger logger) + { + this._logger = logger; + } + + public string PostHttp(string url, LoginAuthorizeRequest reqData) + { + var str = string.Format("client_id={0}&client_secret={1}&grant_type={2}&username={3}&password={4}&scope={5}", + reqData.ClientId, reqData.ClientSecret, reqData.GrantType, reqData.UserName, reqData.Password, reqData.Scope); + ASCIIEncoding encoding = new ASCIIEncoding(); + byte[] byte1 = encoding.GetBytes(str); + HttpContent httpContent = new StringContent(str); + httpContent.Headers.Expires = DateTime.Now; + httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded"); + httpContent.Headers.ContentLength = byte1.Length; + httpContent.Headers.ContentType.CharSet = "utf-8"; + HttpClient httpClient = new HttpClient(); + httpClient.BaseAddress = new Uri(url); + httpClient.Timeout = new TimeSpan(0, 0, 10); + HttpResponseMessage response = httpClient.PostAsync(url, httpContent).Result; + if (response.IsSuccessStatusCode) + { + var resData = response.Content.ReadAsStringAsync().Result; + return resData; + + } + else + { + var resData = response.Content.ReadAsStringAsync().Result; + return resData; + } + + } + + public string PostHttp(string url, LoginAuthorizeCodeRequest reqData) + { + var str = string.Format("client_id={0}&client_secret={1}&grant_type={2}&code={3}&scope={4}", + reqData.ClientId, reqData.ClientSecret, reqData.GrantType, reqData.Code, reqData.Scope); + ASCIIEncoding encoding = new ASCIIEncoding(); + byte[] byte1 = encoding.GetBytes(str); + HttpContent httpContent = new StringContent(str); + httpContent.Headers.Expires = DateTime.Now; + httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded"); + httpContent.Headers.ContentLength = byte1.Length; + httpContent.Headers.ContentType.CharSet = "utf-8"; + HttpClient httpClient = new HttpClient(); + httpClient.BaseAddress = new Uri(url); + httpClient.Timeout = new TimeSpan(0, 0, 10); + HttpResponseMessage response = httpClient.PostAsync(url, httpContent).Result; + if (response.IsSuccessStatusCode) + { + var resData = response.Content.ReadAsStringAsync().Result; + return resData; + + } + else + { + var resData = response.Content.ReadAsStringAsync().Result; + return resData; + } + + } + + public string PostHttp(string url, LoginAuthorizeRefreshTokenRequest reqData) + { + var str = string.Format("client_id={0}&client_secret={1}&grant_type={2}&refresh_token={3}&scope={4}", + reqData.ClientId, reqData.ClientSecret, reqData.GrantType, reqData.RefreshToken, reqData.Scope); + ASCIIEncoding encoding = new ASCIIEncoding(); + byte[] byte1 = encoding.GetBytes(str); + HttpContent httpContent = new StringContent(str); + httpContent.Headers.Expires = DateTime.Now; + httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded"); + httpContent.Headers.ContentLength = byte1.Length; + httpContent.Headers.ContentType.CharSet = "utf-8"; + HttpClient httpClient = new HttpClient(); + httpClient.BaseAddress = new Uri(url); + httpClient.Timeout = new TimeSpan(0, 0, 10); + HttpResponseMessage response = httpClient.PostAsync(url, httpContent).Result; + if (response.IsSuccessStatusCode) + { + var resData = response.Content.ReadAsStringAsync().Result; + return resData; + + } + else + { + var resData = response.Content.ReadAsStringAsync().Result; + return resData; + } + + } + + public async Task PostHttp(string url, string accessToken, string refreshToken) + { + try + { + HttpClient client = new HttpClient(); + //请求头添加其他值 + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + client.DefaultRequestHeaders.Add("Refresh-Authorization", "Bearer " + refreshToken); + client.DefaultRequestHeaders.Connection.Add("Keep-Alive"); + client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); + client.DefaultRequestHeaders.AcceptCharset.Add(new StringWithQualityHeaderValue("utf-8")); + HttpResponseMessage response = await client.PostAsync(url,null); + if (response.IsSuccessStatusCode) + { + var resData = response.Content.ReadAsStringAsync().Result; + return resData; + + } + else + { + var resData = response.Content.ReadAsStringAsync().Result; + return resData; + } + } + catch (Exception ex) + { + return ""; + } + } + + public string GetHttpOut(string url, LoginOutAuthorizeRequest reqData) + { + try + { + HttpClient client = new HttpClient(); + //请求头添加其他值 + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", reqData.AccessToken); + client.DefaultRequestHeaders.Add("Refresh-Authorization", "Bearer " + reqData.RefreshToken); + client.DefaultRequestHeaders.Connection.Add("Keep-Alive"); + client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); + client.DefaultRequestHeaders.AcceptCharset.Add(new StringWithQualityHeaderValue ("utf-8")); + + HttpResponseMessage response = client.GetAsync(url).Result; + if (response.IsSuccessStatusCode) + { + var resData = response.Content.ReadAsStringAsync().Result; + return resData; + + } + else + { + var resData = response.Content.ReadAsStringAsync().Result; + return resData; + } + } + catch (Exception ex) + { + return ""; + } + } + } +} diff --git a/src/BarCode.Web.Core/Help/RedisClient.cs b/src/BarCode.Web.Core/Help/RedisClient.cs new file mode 100644 index 0000000..292d1df --- /dev/null +++ b/src/BarCode.Web.Core/Help/RedisClient.cs @@ -0,0 +1,119 @@ +using Newtonsoft.Json; +using StackExchange.Redis; +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Help +{ + public class RedisClient + { + private static readonly object Locker = new object(); + + private ConnectionMultiplexer redisMultiplexer; + + IDatabase db = null; + + private static RedisClient _redisClient = null; + public static RedisClient redisClient + { + get + { + if (_redisClient == null) + { + lock (Locker) + { + if (_redisClient == null) + { + _redisClient = new RedisClient(); + + } + } + } + return _redisClient; + } + } + + public void InitConnect(string RedisConnection) + { + try + { + redisMultiplexer = ConnectionMultiplexer.Connect(RedisConnection); + db = redisMultiplexer.GetDatabase(); + } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + redisMultiplexer = null; + db = null; + } + } + + public RedisClient() + { + + } + + #region String + /// + /// 保存单个key value + /// + /// 保存的值 + /// 过期时间 + public bool SetStringKey(string key, string value, TimeSpan? expiry = default(TimeSpan?)) + { + return db.StringSet(key, value, expiry); + } + + /// + /// 获取单个key的值 + /// + public RedisValue GetStringKey(string key) + { + return db.StringGet(key); + } + + /// + /// 移除redis + /// + /// + /// + public bool RemoveStringKey(string key) + { + return db.KeyDelete(key); + } + /// + /// 获取一个key的对象 + /// + public T GetStringKey(string key) + { + if (db == null) + { + return default; + } + var value = db.StringGet(key); + if (value.IsNullOrEmpty) + { + return default; + } + return JsonConvert.DeserializeObject(value); + } + + /// + /// 保存一个对象 + /// + /// + public bool SetStringKey(string key, T obj, TimeSpan? expiry = default(TimeSpan?)) + { + if (db == null) + { + return false; + } + string json = JsonConvert.SerializeObject(obj); + return db.StringSet(key, json, expiry); + } + + #endregion + + } +} diff --git a/src/BarCode.Web.Core/Help/ValidatetionHelper.cs b/src/BarCode.Web.Core/Help/ValidatetionHelper.cs new file mode 100644 index 0000000..a3e530e --- /dev/null +++ b/src/BarCode.Web.Core/Help/ValidatetionHelper.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; + +namespace BarCode.Web.Core.Help +{ + public class ValidResult + { + public List ErrorMembers { get; set; } + public bool IsVaild { get; set; } + + public string GetMessage() + { + string msg = ""; + for (int i = 0; i < ErrorMembers.Count(); i++) + { + if (i == 0) + msg = ErrorMembers[i].ErrorMessage; + else + msg += "\r\n" + ErrorMembers[i].ErrorMessage; + } + + return msg; + } + } + + public class ErrorMember + { + public string ErrorMessage { get; set; } + public string ErrorMemberName { get; set; } + } + public static class ValidatetionHelper + { + public static ValidResult IsValid(object value) + { + ValidResult result = new ValidResult(); + try + { + var validationContext = new ValidationContext(value); + var results = new List(); + var isValid = Validator.TryValidateObject(value, validationContext, results, true); + + if (!isValid) + { + result.IsVaild = false; + result.ErrorMembers = new List(); + foreach (var item in results) + { + result.ErrorMembers.Add(new ErrorMember() + { + ErrorMessage = item.ErrorMessage, + ErrorMemberName = item.MemberNames.FirstOrDefault() + }); + } + } + else + { + result.IsVaild = true; + } + } + catch (Exception ex) + { + result.IsVaild = false; + result.ErrorMembers = new List(); + result.ErrorMembers.Add(new ErrorMember() + { + ErrorMessage = ex.Message, + ErrorMemberName = "Internal error" + }); + } + + return result; + } + } +} diff --git a/src/BarCode.Web.Core/Internal/Results/Result.cs b/src/BarCode.Web.Core/Internal/Results/Result.cs new file mode 100644 index 0000000..4b8e50f --- /dev/null +++ b/src/BarCode.Web.Core/Internal/Results/Result.cs @@ -0,0 +1,184 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Core.Internal.Results +{ + /// + /// 结果对象 + /// + public class Result + { + /// + /// 返回结果对象 + /// + public Result() + { + } + + /// + /// 返回结果对象 + /// + /// + /// + public Result(string message, int status) + { + Status = status; + Message = message; + } + + /// + /// 返回结果对象 + /// + /// + public Result(ValueTuple result) + { + Status = result.Item1; + Message = result.Item2; + } + + /// + /// 执行是否成功 + /// + [JsonIgnore] + public bool Success => Status == 200; + + /// + /// 执行是否成功 + /// + [JsonProperty(PropertyName = "isSuccess")] + public bool IsSuccess => Status == 200; + + /// + /// 业务返回码 + /// + [JsonProperty(PropertyName = "status")] + public int Status { get; set; } + + /// + /// 执行返回消息 + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; set; } + + /// + /// 转换实体 + /// + /// + protected void To(Result result) + { + Status = result.Status; + Message = result.Message; + } + + /// + /// 转换实体 + /// + /// + /// + protected void To(string message, int status) + { + Status = status; + Message = message; + } + + /// + /// 转换实体 + /// + /// 结果对象 + protected void To(ValueTuple result) + { + Status = result.Item1; + Message = result.Item2; + } + + /// + /// 创建返回信息(返回处理失败) + /// + /// 结果消息 + /// 结果状态 + /// + public static Result ReFailure(string message, int status) + { + return new Result(message, status); + } + + /// + /// 创建返回信息(返回处理失败) + /// + /// 结果消息 + /// + public static Result ReFailure(ValueTuple result) + { + return new Result(result.Item2, result.Item1); + } + + /// + /// 创建返回信息(返回处理失败) + /// + /// 结果 + /// + public static T ReFailure(Result result) where T : Result, new() + { + var r = new T(); + r.To(result); + return r; + } + + /// + /// 创建返回信息(返回处理失败) + /// + /// 结果消息 + /// 结果状态 + /// + public static T ReFailure(string message, int status) where T : Result, new() + { + var result = new T(); + result.To(message, status); + return result; + } + + /// + /// 创建返回信息(返回处理失败) + /// + /// 结果消息 + /// + public static T ReFailure(ValueTuple result) where T : Result, new() + { + var ret = new T(); + ret.To(result); + return ret; + } + + /// + /// 创建成功的返回消息 + /// + /// + public static Result ReSuccess() + { + return new Result(BaseResultCodes.Success); + } + + /// + /// 创建成功的返回消息 + /// + /// + public static T ReSuccess() where T : Result, new() + { + var result = new T(); + result.To(BaseResultCodes.Success); + return result; + } + + /// + /// 转换为 task + /// + /// + public Task AsTask() + { + return Task.FromResult(this); + } + } +} diff --git a/src/BarCode.Web.Core/Internal/Results/Result2.cs b/src/BarCode.Web.Core/Internal/Results/Result2.cs new file mode 100644 index 0000000..853d0e9 --- /dev/null +++ b/src/BarCode.Web.Core/Internal/Results/Result2.cs @@ -0,0 +1,102 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Core.Internal.Results +{ + /// + /// 实体结果对象 + /// + /// + public class Result : Result + { + /// + /// 实体结果 + /// + public Result() + { + } + + /// + /// 实体结果 + /// + /// + public Result(T data) : base(BaseResultCodes.Success) + { + Data = data; + } + + /// + /// 返回结果对象 + /// + /// + /// + public Result(T data, ValueTuple result) : base(result) + { + Data = data; + } + + /// + /// 返回对象 + /// + [JsonProperty(PropertyName = "data")] + public T Data { get; set; } + + /// + /// 创建成功的返回消息 + /// + /// + public static Result ReSuccess(T data) + { + return new Result(data); + } + + /// + /// 创建返回信息(返回处理失败) + /// + /// 结果消息 + /// 结果状态 + /// + public new static Result ReFailure(string message, int status) + { + var result = new Result(); + result.To(message, status); + return result; + } + + /// + /// 创建返回信息(返回处理失败) + /// + /// 结果消息 + /// + public new static Result ReFailure(ValueTuple result) + { + var res = new Result(); + res.To(result); + return res; + } + + /// + /// 创建返回信息(返回处理失败) + /// + /// 结果 + /// + public static Result ReFailure(Result result) + { + var re = new Result(); + re.To(result); + return re; + } + + /// + /// 转换为task + /// + /// + public new Task> AsTask() + { + return Task.FromResult(this); + } + } +} diff --git a/src/BarCode.Web.Core/Internal/Results/ResultCodes.cs b/src/BarCode.Web.Core/Internal/Results/ResultCodes.cs new file mode 100644 index 0000000..dd3d986 --- /dev/null +++ b/src/BarCode.Web.Core/Internal/Results/ResultCodes.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core.Internal.Results +{ + public class BaseResultCodes + { + /// + /// 处理成功 + /// + public static ValueTuple Success = (200, "Success"); + + /// + /// 错误请求 + /// + public static ValueTuple BadRequest = (400, "{0}"); + + /// + /// 未授权 + /// + public static ValueTuple UnAuthorized = (401, "登录信息已过期,请重新登录"); + + /// + /// 拒绝请求 + /// + public static ValueTuple NotAcceptable = (403, "Not Acceptable"); + + /// + /// 未找到服务 + /// + public static ValueTuple NotFound = (404, "Not Found"); + + /// + /// 系统错误 + /// + public static ValueTuple UnknowError = (500, "Internal Server Error"); + + /// + /// 请求超时 + /// + public static ValueTuple RequestTimeout = (408, "Request Timeout"); + } + + /// + /// 返回对象扩展 + /// + public static class BaseResultCodesExtension + { + /// + /// 根据替换符进行替换支付 + /// + /// 结果对象 + /// 替换字符 + /// + public static ValueTuple ToFormat(this ValueTuple result, params string[] args) + { + result.Item2 = string.Format(result.Item2, args); + return result; + } + } +} diff --git a/src/BarCode.Web.Core/Internal/Results/ResultList.cs b/src/BarCode.Web.Core/Internal/Results/ResultList.cs new file mode 100644 index 0000000..b217678 --- /dev/null +++ b/src/BarCode.Web.Core/Internal/Results/ResultList.cs @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Core.Internal.Results +{ + /// + /// 集合结果类 + /// + /// + public class ResultList : Result> + { + /// + /// 实体集合结果 + /// + public ResultList() + { + } + + /// + /// 实体集合结果 + /// + /// 实体集合 + public ResultList(IList data) : base(data) + { + } + + /// + /// 实体集合结果 + /// + /// 实体集合 + /// 结果状态 + public ResultList(IList data, ValueTuple result) : base(data, result) + { + } + + /// + /// 创建成功的返回消息 + /// + /// + public new static ResultList ReSuccess(IList data) + { + return new ResultList(data); + } + + /// + /// 创建成功的返回消息 + /// + /// + public new static ResultList ReSuccess() + { + return new ResultList(new List()); + } + + /// + /// 创建返回信息(返回处理失败) + /// + /// 结果消息 + /// 结果状态 + /// + public new static ResultList ReFailure(string message, int status) + { + var result = new ResultList(); + result.To(message, status); + return result; + } + + /// + /// 创建返回信息(返回处理失败) + /// + /// 结果消息 + /// + public new static ResultList ReFailure(ValueTuple result) + { + var res = new ResultList(); + res.To(result); + return res; + } + + /// + /// 创建返回信息(返回处理失败) + /// + /// 结果 + /// + public new static ResultList ReFailure(Result result) + { + var re = new ResultList(); + re.To(result); + return re; + } + + /// + /// 转换为 task + /// + /// + public new Task> AsTask() + { + return Task.FromResult(this); + } + } +} diff --git a/src/BarCode.Web.Core/Internal/Results/ResultPagedList.cs b/src/BarCode.Web.Core/Internal/Results/ResultPagedList.cs new file mode 100644 index 0000000..3d5154b --- /dev/null +++ b/src/BarCode.Web.Core/Internal/Results/ResultPagedList.cs @@ -0,0 +1,112 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Core.Internal.Results +{ + /// + /// 分页列表结果对象 + /// + public class ResultPagedList : ResultList + { + /// + /// 实体分页集合结果 + /// + public ResultPagedList() + { + } + + /// + /// 实体分页集合结果 + /// + /// 实体集合 + /// 总条数 + public ResultPagedList(IList data, int totalCount) : base(data) + { + TotalCount = totalCount; + } + + /// + /// 实体分页集合结果 + /// + /// + /// + /// + public ResultPagedList(IList data, int totalCount, ValueTuple result) : base(data, result) + { + TotalCount = totalCount; + } + + /// + /// Total count of Items. + /// + public int TotalCount { get; set; } + + /// + /// 创建成功的返回消息 + /// + /// 实体集合 + /// 总条数 + /// + public static ResultPagedList ReSuccess(IList data, int totalCount) + { + return new ResultPagedList(data, totalCount); + } + + /// + /// 创建成功的返回消息 + /// + /// + public new static ResultPagedList ReSuccess() + { + return new ResultPagedList(new List(), 0); + } + + /// + /// 创建返回信息(返回处理失败) + /// + /// 结果消息 + /// 结果状态 + /// + public new static ResultPagedList ReFailure(string message, int status) + { + var result = new ResultPagedList(); + result.To(message, status); + return result; + } + + /// + /// 创建返回信息(返回处理失败) + /// + /// 结果消息 + /// + public new static ResultPagedList ReFailure(ValueTuple result) + { + var res = new ResultPagedList(); + res.To(result); + return res; + } + + /// + /// 创建返回信息(返回处理失败) + /// + /// 结果 + /// + public new static ResultPagedList ReFailure(Result result) + { + var re = new ResultPagedList(); + re.To(result); + return re; + } + + /// + /// 转换为 task + /// + /// + public new Task> AsTask() + { + return Task.FromResult(this); + } + } +} diff --git a/src/BarCode.Web.Core/Internal/Security/RSA.cs b/src/BarCode.Web.Core/Internal/Security/RSA.cs new file mode 100644 index 0000000..38e33c6 --- /dev/null +++ b/src/BarCode.Web.Core/Internal/Security/RSA.cs @@ -0,0 +1,463 @@ +using Microsoft.IdentityModel.Tokens; +using System; +using System.Collections.Generic; +using System.IO; +using System.Security.Cryptography; +using System.Text; + +namespace BarCode.Web.Core.Internal.Security +{ + public class RSA + { + #region 签名验证使用 + //encoded OID sequence for PKCS #1 rsaEncryption szOID_RSA_RSA = "1.2.840.113549.1.1.1" + private static byte[] SeqOID = { 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00 }; + private static byte[] Seq = new byte[15]; + /// + /// 用于签名的私钥 + /// + public static RsaSecurityKey RSAPrivateKey { get; } + + /// + /// 用于验证的公钥 + /// + public static RsaSecurityKey RSAPublicKey { get; } + + static RSA() + { + using (var rsa = new RSACryptoServiceProvider(2048)) + { + RSAPrivateKey = new RsaSecurityKey(rsa.ExportParameters(true)); + RSAPublicKey = new RsaSecurityKey(rsa.ExportParameters(false)); + rsa.PersistKeyInCsp = false; + } + } + + /// + /// 签名 + /// + /// 签名内容 + /// 私钥 + /// 编码类型 + /// 加密方式 + /// 加密密文 + public static string Sign(string content, string privateKey, Encoding encoding, HashAlgorithmName hashAlgorithm) + { + var rsa = System.Security.Cryptography.RSA.Create(); + rsa.ImportParameters(DecodePkcsPrivateKey(privateKey)); + var contentBytes = encoding.GetBytes(content); + var cipherBytes = rsa.SignData(contentBytes, hashAlgorithm, RSASignaturePadding.Pkcs1); + return Convert.ToBase64String(cipherBytes); + } + /// + /// 验证签名 + /// + /// 验证签名内容 + /// 公钥 + /// 签名密文 + /// 编码类型 + /// 加密方式 + /// 加密密文 + public static bool CheckSign(string content, string publicKey, string sign, Encoding encoding, HashAlgorithmName hashAlgorithm) + { + var rsa = System.Security.Cryptography.RSA.Create(); + rsa.ImportParameters(DecodePkcsPublicKey(publicKey)); + var contentBytes = encoding.GetBytes(content); + var signBytes = Convert.FromBase64String(sign); + return rsa.VerifyData(contentBytes, signBytes, hashAlgorithm, RSASignaturePadding.Pkcs1); + + } + /// + /// 解密 + /// + /// 密文 + /// 私钥 + /// 编码 + /// 明文 + public static string Decrypt(string cipher, string privateKey, Encoding encoding) + { + var rsa = System.Security.Cryptography.RSA.Create(); + rsa.ImportParameters(DecodePkcsPrivateKey(privateKey)); + var cipherBytes = System.Convert.FromBase64String(cipher); + var plainTextBytes = rsa.Decrypt(cipherBytes, RSAEncryptionPadding.Pkcs1); + return encoding.GetString(plainTextBytes); + } + + + public static System.Security.Cryptography.RSA CreateRSA(string privatekey) + { + var rsa = System.Security.Cryptography.RSA.Create(); + rsa.ImportParameters(DecodePkcsPrivateKey(privatekey)); + return rsa; + } + + public static string DecryptToDo(System.Security.Cryptography.RSA rsa, string cipher, Encoding encoding) + { + var cipherBytes = System.Convert.FromBase64String(cipher); + var plainTextBytes = rsa.Decrypt(cipherBytes, RSAEncryptionPadding.Pkcs1); + return encoding.GetString(plainTextBytes); + } + + /// + /// 加密 + /// + /// 明文 + /// 公钥 + /// 编码 + /// 密文 + public static string Encrypt(string plainText, string publicKey, Encoding encoding) + { + var rsa = System.Security.Cryptography.RSA.Create(); + rsa.ImportParameters(DecodePkcsPublicKey(publicKey)); + var plainTextBytes = Encoding.UTF8.GetBytes(plainText); + var cipherBytes = rsa.Encrypt(plainTextBytes, RSAEncryptionPadding.Pkcs1); + return Convert.ToBase64String(cipherBytes); + } + /// + /// 解密公钥 + /// + /// + /// + /// + /// + public static RSAParameters DecodePkcsPublicKey(string publicKey) + { + if (string.IsNullOrEmpty(publicKey)) + throw new ArgumentNullException("publicKey", "This arg cann't be empty."); + + publicKey = publicKey.Replace("-----BEGIN PUBLIC KEY-----", "").Replace("-----END PUBLIC KEY-----", "").Replace("\n", "").Replace("\r", ""); + var publicKeyData = Convert.FromBase64String(publicKey); + //生成RSA参数 + var rsaParams = new RSAParameters(); + + // --------- Set up stream to read the asn.1 encoded SubjectPublicKeyInfo blob ----- + using (BinaryReader binr = new BinaryReader(new MemoryStream(publicKeyData))) + { + byte bt = 0; + ushort twobytes = 0; + + twobytes = binr.ReadUInt16(); + if (twobytes == 0x8130)//data read as little endian order (actual data order for Sequence is 30 81) + binr.ReadByte(); //advance 1 byte + else if (twobytes == 0x8230) + binr.ReadInt16(); //advance 2 bytes + else + throw new ArgumentException("PemToXmlPublicKey Conversion failed"); + + Seq = binr.ReadBytes(15); //read the Sequence OID + if (!CompareBytearrays(Seq, SeqOID)) //make sure Sequence for OID is correct + throw new ArgumentException("PemToXmlPublicKey Conversion failed"); + + twobytes = binr.ReadUInt16(); + if (twobytes == 0x8103) //data read as little endian order (actual data order for Bit String is 03 81) + binr.ReadByte(); //advance 1 byte + else if (twobytes == 0x8203) + binr.ReadInt16(); //advance 2 bytes + else + throw new ArgumentException("PemToXmlPublicKey Conversion failed"); + + bt = binr.ReadByte(); + if (bt != 0x00) //expect null byte next + throw new ArgumentException("PemToXmlPublicKey Conversion failed"); + + twobytes = binr.ReadUInt16(); + if (twobytes == 0x8130) //data read as little endian order (actual data order for Sequence is 30 81) + binr.ReadByte(); //advance 1 byte + else if (twobytes == 0x8230) + binr.ReadInt16(); //advance 2 bytes + else + throw new ArgumentException("PemToXmlPublicKey Conversion failed"); + + twobytes = binr.ReadUInt16(); + byte lowbyte = 0x00; + byte highbyte = 0x00; + + if (twobytes == 0x8102) //data read as little endian order (actual data order for Integer is 02 81) + lowbyte = binr.ReadByte(); // read next bytes which is bytes in modulus + else if (twobytes == 0x8202) + { + highbyte = binr.ReadByte(); //advance 2 bytes + lowbyte = binr.ReadByte(); + } + else + throw new ArgumentException("PemToXmlPublicKey Conversion failed"); + byte[] modint = { lowbyte, highbyte, 0x00, 0x00 }; //reverse byte order since asn.1 key uses big endian order + int modsize = BitConverter.ToInt32(modint, 0); + + int firstbyte = binr.PeekChar(); + if (firstbyte == 0x00) + { //if first byte (highest order) of modulus is zero, don't include it + binr.ReadByte(); //skip this null byte + modsize -= 1; //reduce modulus buffer size by 1 + } + + byte[] modulus = binr.ReadBytes(modsize); //read the modulus bytes + + if (binr.ReadByte() != 0x02) //expect an Integer for the exponent data + throw new ArgumentException("PemToXmlPublicKey Conversion failed"); + int expbytes = (int)binr.ReadByte(); // should only need one byte for actual exponent data (for all useful values) + byte[] exponent = binr.ReadBytes(expbytes); + + // ------- create RSACryptoServiceProvider instance and initialize with public key ----- + rsaParams.Modulus = modulus; + rsaParams.Exponent = exponent; + } + return rsaParams; + } + /// + /// 私钥解密 + /// + /// + /// + /// + /// + public static RSAParameters DecodePkcsPrivateKey(string privateKey) + { + + if (string.IsNullOrEmpty(privateKey)) + { + throw new ArgumentNullException("pemFileConent", "This arg cann't be empty."); + } + try + { + privateKey = privateKey.Replace("-----BEGIN RSA PRIVATE KEY-----", "").Replace("-----END RSA PRIVATE KEY-----", "").Replace("\n", "").Replace("\r", ""); + var privateKeyData = Convert.FromBase64String(privateKey); + + //解析Pkcs证书 + PKCSType type = GetPrivateKeyType(privateKeyData.Length); + if (type == PKCSType.PKCS_8_1024 || type == PKCSType.PKCS_8_2048) + { + //Pkcs#8秘钥需要特殊处理 + privateKeyData = DecodePkcs8PrivateKey(privateKeyData); + } + var rsaParams = new RSAParameters(); + byte bt = 0; + ushort twobytes = 0; + //转换为二进制值 + using (var binr = new BinaryReader(new MemoryStream(privateKeyData))) + { + twobytes = binr.ReadUInt16(); + if (twobytes == 0x8130) + binr.ReadByte(); + else if (twobytes == 0x8230) + binr.ReadInt16(); + else + throw new ArgumentException("Unexpected value read )"); + + twobytes = binr.ReadUInt16(); + if (twobytes != 0x0102) + throw new ArgumentException("Unexpected version"); + + bt = binr.ReadByte(); + if (bt != 0x00) + throw new ArgumentException("Unexpected value read "); + + //转换XML + rsaParams.Modulus = binr.ReadBytes(GetIntegerSize(binr)); + rsaParams.Exponent = binr.ReadBytes(GetIntegerSize(binr)); + rsaParams.D = binr.ReadBytes(GetIntegerSize(binr)); + rsaParams.P = binr.ReadBytes(GetIntegerSize(binr)); + rsaParams.Q = binr.ReadBytes(GetIntegerSize(binr)); + rsaParams.DP = binr.ReadBytes(GetIntegerSize(binr)); + rsaParams.DQ = binr.ReadBytes(GetIntegerSize(binr)); + rsaParams.InverseQ = binr.ReadBytes(GetIntegerSize(binr)); + } + return rsaParams; + } + catch (Exception ex) + { + throw new ArgumentException("此私钥证书无效", ex); + } + } + + /// + /// Pkcs#8 证书解密 + /// + /// + /// + private static byte[] DecodePkcs8PrivateKey(byte[] privateKeyData) + { + byte bt = 0; + ushort twobytes = 0; + MemoryStream mem = new MemoryStream(privateKeyData); + int lenstream = (int)mem.Length; + using (var binr = new BinaryReader(mem)) + { + twobytes = binr.ReadUInt16(); + if (twobytes == 0x8130) //data read as little endian order (actual data order for Sequence is 30 81) + binr.ReadByte(); //advance 1 byte + else if (twobytes == 0x8230) + binr.ReadInt16(); //advance 2 bytes + else + throw new Exception("Unexpected value read"); + + bt = binr.ReadByte(); + if (bt != 0x02) + throw new Exception("Unexpected version"); + + twobytes = binr.ReadUInt16(); + + if (twobytes != 0x0001) + throw new Exception("Unexpected value read"); + + Seq = binr.ReadBytes(15); //read the Sequence OID + if (!CompareBytearrays(Seq, SeqOID)) //make sure Sequence for OID is correct + throw new Exception("Unexpected value read"); + + bt = binr.ReadByte(); + if (bt != 0x04) //expect an Octet string + throw new Exception("Unexpected value read"); + + bt = binr.ReadByte(); //read next byte, or next 2 bytes is 0x81 or 0x82; otherwise bt is the byte count + if (bt == 0x81) + binr.ReadByte(); + else + if (bt == 0x82) + binr.ReadUInt16(); + //------ at this stage, the remaining sequence should be the RSA private key + + return binr.ReadBytes((int)(lenstream - mem.Position)); + } + } + + /// + /// 获取Integer的大小 + /// + /// + /// + private static int GetIntegerSize(BinaryReader binr) + { + byte bt = 0; + byte lowbyte = 0x00; + byte highbyte = 0x00; + int count = 0; + bt = binr.ReadByte(); + if (bt != 0x02) + return 0; + bt = binr.ReadByte(); + + if (bt == 0x81) + count = binr.ReadByte(); + else + if (bt == 0x82) + { + highbyte = binr.ReadByte(); + lowbyte = binr.ReadByte(); + byte[] modint = { lowbyte, highbyte, 0x00, 0x00 }; + count = BitConverter.ToInt32(modint, 0); + } + else + { + count = bt; + } + + while (binr.ReadByte() == 0x00) + { + count -= 1; + } + binr.BaseStream.Seek(-1, SeekOrigin.Current); + return count; + } + private static bool CompareBytearrays(byte[] a, byte[] b) + { + if (a.Length != b.Length) + return false; + int i = 0; + foreach (byte c in a) + { + if (c != b[i]) + return false; + i++; + } + return true; + } + + /// + /// 获取私钥的类型 + /// + /// + /// + private static PKCSType GetPrivateKeyType(int privateKeyLength) + { + if (privateKeyLength >= 630 && privateKeyLength <= 640) + return PKCSType.PKCS_8_1024; + if (privateKeyLength >= 600 && privateKeyLength <= 610) + return PKCSType.PKCS_1_1024; + if (privateKeyLength >= 1210 && privateKeyLength <= 1220) + return PKCSType.PKCS_8_2048; + if (privateKeyLength >= 1190 && privateKeyLength <= 1199) + return PKCSType.PKCS_1_2048; + else + throw new ArgumentException("此私钥证书标准不支持"); + } + + #endregion + + #region 外部使用 + /// + /// php单点登录解析token根据密钥-分段解析 + /// + /// + /// + /// + public static string DecryptSection(string privateKey, List items) + { + string data = ""; + using (var rsa = new RSACryptoServiceProvider()) + { + var para = DecodePkcsPrivateKey(privateKey); + rsa.ImportParameters(para); + + foreach (var item in items) + { + //var aa= "lhIweHzS3fYrnhM0HmmQIJIm9jsCAOAHEZFYRF+96vsoWRxxEwkmZsjESMIy7UXGQmo1/Q3GIs96ItlJ0LbJWY0tBggS3JHQ9bnfWKIzeFY2aMi9wPqJbWujXzwlAvi0div2YUnn+fj5sGPdYPN0RAwGUbVHpuT/XOSMYfHaGJkt/FcD+ihvx7/GP+sxXbTr/4/NwhSVDd8lmzavu+RaQKOBcYZ4AXNSS1CZ9mQ3Fau+o2eJL6byBqVtAtBdD9bki1yMMNTkOdl0LyUc4T2EtZOdYAa4EenVsFV0W7SBq7yqc/WCEThMEOQfu4t/tiRg8UrySrZmWHD1AUJnzSKvMg==Sl0Fnt+sP0pCivX/F+6/TJfIN9gh9E/CfmgUWEZmWJXURSYXIIjA1T8guUwPnmSt7buMlDAWSKByk6q9Qry1kt6DFJM92uPXyRsgYO3/ZkuDVupt22Jmdk5n075gJ+wbQfr1o05Pc84t0SGo2ZwNdsaynLk/4oZzezSiQTKLUqv3XuDBHo9QGe0dlPAk/g+KzwA3RGTX+r8bJFlhjP2kSpPd6aemeAjKElKqHnXXUem4nq1mK1SvIhejrM8m2uA7oFY+yo00ZLp9ZfD8HT1tqbpdisWbkf22vbB9Y0TPITWgAIAOcv13H6oCQJ+UAHpRmcRUpWYph3LyrU6GW9b6uA=="; + + //老的处理方式,反转byte字节(单点返回数据) + //var bty = Convert.FromBase64String(item); + //byte[] DecryptByte = rsa.Decrypt(bty, false); + //Array.Reverse(DecryptByte, 0, DecryptByte.Length); + //data += Encoding.UTF8.GetString(DecryptByte,0, DecryptByte.Length); + + //新的处理方式,反转字符串(单点返回数据-做了其它统一处理) + var bty = Convert.FromBase64String(item); + byte[] DecryptByte = rsa.Decrypt(bty, false); + var result = Encoding.UTF8.GetString(DecryptByte, 0, DecryptByte.Length); + + var chars = result.ToCharArray(); + Array.Reverse(chars, 0, chars.Length); + string reverse = String.Empty; + foreach (var chr in chars) + { + reverse += chr; + } + data += reverse; + } + return data; + } + } + #endregion + } + + /// + /// 密钥类型枚举 + /// + public enum PKCSType + { + /// + /// 1024 + /// + PKCS_1_1024, + /// + /// 2048 + /// + PKCS_1_2048, + /// + /// 1023 + /// + PKCS_8_1024, + /// + /// 2048 + /// + PKCS_8_2048, + } +} diff --git a/src/BarCode.Web.Core/NumericalProcess.cs b/src/BarCode.Web.Core/NumericalProcess.cs new file mode 100644 index 0000000..8094337 --- /dev/null +++ b/src/BarCode.Web.Core/NumericalProcess.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Core +{ + /// + /// 数值处理 + /// + public static class NumericalProcess + { + /// + /// Decimal 数值精度转换 + /// + /// decimal数值 + /// 精度值 + /// 舍入类型:1为进位,2为舍位,3为四舍五入 + /// decimal数值 + public static decimal DecimalPrecision(this decimal? number, int? precision, int? RoundoffType) + { + if (RoundoffType == 1) + return Decimal.Round(number ?? 0, precision ?? 0, MidpointRounding.ToPositiveInfinity); + else if (RoundoffType == 2) + return Decimal.Round(number ?? 0, precision ?? 0, MidpointRounding.ToZero); + else if (RoundoffType == 3) + return Decimal.Round(number ?? 0, precision ?? 0, MidpointRounding.AwayFromZero); + return number ?? 0; + } + + /// + /// Decimal 数值精度转换 + /// + /// decimal数值 + /// 精度值 + /// 舍入类型:1为进位,2为舍位,3为四舍五入 + /// decimal数值 + public static decimal DecimalPrecision(this decimal number, int? precision, int? RoundoffType) + { + if (RoundoffType == 1) + return Decimal.Round(number, precision ?? 0, MidpointRounding.ToPositiveInfinity); + else if (RoundoffType == 2) + return Decimal.Round(number, precision ?? 0, MidpointRounding.ToZero); + else if (RoundoffType == 3) + return Decimal.Round(number, precision ?? 0, MidpointRounding.AwayFromZero); + return number; + } + + /// + /// Decimal 去掉后面无效的0 + /// + /// + /// + public static string DecimalToStringNoZero(this decimal? data) + { + return (data ?? 0).ToString("#0.##########"); + } + + public static string DecimalToStringNoZero(this decimal data) + { + return data.ToString("#0.##########"); + } + } +} diff --git a/src/BarCode.Web.Domain/BarCode.Web.Domain.csproj b/src/BarCode.Web.Domain/BarCode.Web.Domain.csproj new file mode 100644 index 0000000..f64810e --- /dev/null +++ b/src/BarCode.Web.Domain/BarCode.Web.Domain.csproj @@ -0,0 +1,28 @@ + + + + net8.0 + enable + enable + True + ../BarCode.Web.Api/wwwroot/BarCode.Web.Domain.xml + true + + + + + + + + + + + + + + + + + + + diff --git a/src/BarCode.Web.Domain/Entitys/Box.cs b/src/BarCode.Web.Domain/Entitys/Box.cs new file mode 100644 index 0000000..b57d348 --- /dev/null +++ b/src/BarCode.Web.Domain/Entitys/Box.cs @@ -0,0 +1,195 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using BarCode.Web.Core; +using BarCode.Web.Core.Help; +using BarCode.Web.Core.Internal.Results; +using BarCode.Web.Domain.Values; + +namespace BarCode.Web.Domain.Entitys +{ + /// + /// 箱信息头 + /// alter table t_barcode_box_details AUTO_INCREMENT=50000; + /// + + [Serializable] + [Table("t_barcode_box")] + public class Box : EntityBase + { + /// + /// ID + /// + [Column("Id")] + public override int Id { get; set; } + /// + /// 箱编号 + /// + [Column("BoxBillNo")] + public string BoxBillNo { get; set; } = ""; + /// + /// 供应商Code + /// + [Column("SupplierCode")] + public string SupplierCode { get; set; } = ""; + /// + /// 组织Code + /// + [Column("OrgCode")] + public string OrgCode { get; set; } = ""; + /// + /// 公司Id + /// + [Column("CompanyId")] + public int CompanyId { get; set; } = 0; + /// + /// 箱状态 + /// + [Column("Status")] + public BoxStatus Status { get; set; } = BoxStatus.NoUse; + /// + /// 装箱开始时间 + /// + [Column("CartonBeginTime")] + public DateTime? CartonBeginTime { get; set; } + /// + /// 装箱结束时间(完成装箱时间) + /// + [Column("CartonEndTime")] + public DateTime? CartonEndTime { get; set; } + /// + /// 装箱用户 + /// + [Column("CartonUserId")] + public int CartonUserId { get; set; } = 0; + /// + /// 箱子创建用户 + /// + [Column("CreatorId")] + public int CreatorId { get; set; } = 0; + /// + /// 创建时间 + /// + [Column("CreateTime")] + public DateTime CreateTime { get; set; } = DateTime.Now; + /// + /// 箱号打印次数 + /// + [Column("PrintNumber")] + public int PrintNumber { get; set; } = 0; + /// + /// 最新打印时间 + /// + [Column("PrintTime")] + public DateTime? PrintTime { get; set; } + /// + /// 明细 + /// + public List Details { get; set; } = new List(); + + public void GenerateNo() + { + //用户手动输入了 就不自动生成了 + if (!string.IsNullOrEmpty(this.BoxBillNo)) return; + + if (this.Id.ToString().Length >= 8) + { + this.BoxBillNo = "CTN" + this.Id.ToString(); + return; + } + + string idStr = this.Id.ToString(); + while (true) + { + idStr = "0" + idStr; + if (idStr.Length >= 8) break; + } + this.BoxBillNo = "CTN" + idStr; + } + /// + /// 打印 + /// + public void Print() + { + this.PrintNumber++; + this.PrintTime = DateTime.Now; + } + /// + /// 解绑序列号 + /// + /// + /// + public Result UnSerialNumber(string serialNumber, string materialNumber) + { + var detail = this.Details.FirstOrDefault(f => f.MaterialNumber.Equals(materialNumber)); + if (detail == null) + return Result.ReFailure(ResultCodes.BoxMaterialNoDataError); + var serial = detail.SerialNumbers.FirstOrDefault(f => f.Equals(serialNumber)); + if (serial == null) + return Result.ReFailure(ResultCodes.BoxSerialNumberNoDataError); + detail.SerialNumbers.Remove(serialNumber); + detail.Qty = detail.SerialNumbers.Count(); + //如果数量为0了就删除这条明细 + if (detail.SerialNumbers.Count() <= 0) + this.Details.Remove(detail); + //如果没有明细了 就把状态改成未使用 + if (this.Details.Count() <= 0) + this.Status = BoxStatus.NoUse; + + return Result.ReSuccess(); + } + + /// + /// 清空 + /// + public void Clear() + { + this.Details.Clear(); + } + /// + /// 装箱 + /// + public Result Carton(bool isComplete, int cartonUserId) + { + if (this.Status == BoxStatus.Complete) + return Result.ReFailure(ResultCodes.CartonCompleteError); + if (this.CartonBeginTime == null) this.CartonBeginTime = DateTime.Now; + this.CartonUserId = cartonUserId; + if (isComplete == true) + { + //完成装箱 + this.Status = BoxStatus.Complete; + this.CartonEndTime = DateTime.Now; + return Result.ReSuccess(); + } + this.Status = BoxStatus.NoComplete; + return Result.ReSuccess(); + } + /// + /// 开始装箱 + /// + /// + /// + public Result BeginCarton(int cartonUserId) + { + if (this.Status == BoxStatus.Complete) + return Result.ReFailure(ResultCodes.CartonCompleteError); + if (this.CartonBeginTime == null) + this.CartonBeginTime = DateTime.Now; + if (this.CartonUserId == 0) + this.CartonUserId = cartonUserId; + this.Status = BoxStatus.NoComplete; + return Result.ReSuccess(); + } + /// + /// 重置 + /// + public void Restart() + { + this.Status = BoxStatus.NoComplete; + this.CartonEndTime = null; + } + } +} diff --git a/src/BarCode.Web.Domain/Entitys/BoxDetails.cs b/src/BarCode.Web.Domain/Entitys/BoxDetails.cs new file mode 100644 index 0000000..fbc48cd --- /dev/null +++ b/src/BarCode.Web.Domain/Entitys/BoxDetails.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Text; +using BarCode.Web.Core; + +namespace BarCode.Web.Domain.Entitys +{ + /// + /// 老ops箱信息明细 + /// alter table t_barcode_box_details AUTO_INCREMENT=50000; + /// + + [Serializable] + [Table("t_barcode_box_details")] + public class BoxDetails : EntityBase + { + /// + /// ID + /// + [Column("Id")] + public override int Id { get; set; } + /// + /// 单据头ID + /// + [Column("Fid")] + public int Fid { get; set; } + /// + /// 物料编码 + /// + [Column("MaterialNumber")] + public string MaterialNumber { get; set; } = ""; + /// + /// 数量(装箱数量) + /// + [Column("Qty")] + public decimal Qty { get; set; } = 0; + /// + /// 序列号 + /// + [Column("SerialNumbers")] + public List SerialNumbers { get; set; } = new List(); + + } +} diff --git a/src/BarCode.Web.Domain/Entitys/BoxMark.cs b/src/BarCode.Web.Domain/Entitys/BoxMark.cs new file mode 100644 index 0000000..df3a2e3 --- /dev/null +++ b/src/BarCode.Web.Domain/Entitys/BoxMark.cs @@ -0,0 +1,192 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Text; +using BarCode.Web.Core; + +namespace BarCode.Web.Domain.Entitys +{ + /// + /// 箱唛表 + /// + [Serializable] + [Table("t_barcode_box_mark")] + public class BoxMark : EntityBase + { + /// + /// ID + /// + public override int Id { get; set; } + /// + /// 供应商Code + /// + [Column("SupplierCode")] + public string SupplierCode { get; set; } = ""; + /// + /// 组织Code + /// + [Column("OrgCode")] + public string OrgCode { get; set; } = ""; + + /// + /// 订单编号 + /// + public string OrderBillNo { get; set; } + + /// + /// 物料编码 + /// + public string MaterialNumber { get; set; } + + /// + /// 产品数量 + /// + public decimal ProductQty { get; set; } + + /// + /// 装箱数量 + /// + public decimal CratingQty { get; set; } + + /// + /// 装箱净重 + /// + public decimal CratingNetWeightQty { get; set; } + + /// + /// 装箱毛重 + /// + public decimal CratingGrossWeightQty { get; set; } + + /// + /// 尾箱数量 + /// + public decimal TailboxQty { get; set; } + + /// + /// 尾箱净重 + /// + public decimal TailboxNetWeightQty { get; set; } + + /// + /// 尾箱毛重 + /// + public decimal TailboxGrossWeightQty { get; set; } + + /// + /// 备注 + /// + public string Remark { get; set; } + + /// + /// 操作人 + /// + public int CreatorId { get; set; } + + /// + /// 创建时间(生成时间) + /// + public DateTime CreateTime { get; set; } + /// + /// 流水号(开始) + /// + public Int64? BeginNumber { get; set; } = null; + /// + /// 流水号(结束) + /// + public Int64? EndNumber { get; set; } = null; + + /// + /// 编号集合 + /// + public List BillNos { get; set; } = new List(); + + /// + /// 创建 + /// + /// + public void Create(int creatorId) + { + this.CreatorId = creatorId; + this.CreateTime = DateTime.Now; + } + + /// + /// 生成编号 + /// + /// + /// + public void GenerateBillNo(int firstBillNo, int lastBillNo) + { + if (this.BillNos == null) + this.BillNos = new List(); + + //计算要装的箱数量 + var boxCount_tag = this.ProductQty / this.CratingQty; + var boxCount = Convert.ToInt32(boxCount_tag); + + //判断是否存在小数点;true表明有尾箱数,false没有尾箱数 + var hasPart = Math.Floor(boxCount_tag) != boxCount_tag; + + //有小数点向上取整 + if (hasPart) + boxCount = Convert.ToInt32(Math.Ceiling(boxCount_tag)); + + for (int i = 1; i <= boxCount; i++) + { + //添加编号生成 + var bill = new BoxMarkBillNo(); + bill.Sort = i; + if (hasPart && i == boxCount && boxCount > 1) + bill.IsTail = true; + bill.GenerateBillNo(firstBillNo, lastBillNo); + + //用户设置了序列号才计算 + if (this.BeginNumber != null && this.EndNumber != null) + { + //只有一个箱子 就用产品数量 + if (boxCount == 1) + { + //如果是尾箱 + if (bill.IsTail) + { + bill.BeginNumber = this.BeginNumber + Convert.ToInt64((i - 1) * ProductQty); + bill.EndNumber = this.EndNumber; + } + else + { + //不是尾箱 + bill.BeginNumber = this.BeginNumber + Convert.ToInt64((i - 1) * ProductQty); + bill.EndNumber = Convert.ToInt64(bill.BeginNumber + ProductQty) - 1; + } + } + else + { + //如果是尾箱 + if (bill.IsTail) + { + bill.BeginNumber = this.BeginNumber + Convert.ToInt64((i - 1) * CratingQty); + bill.EndNumber = this.EndNumber; + } + else + { + //不是尾箱 + bill.BeginNumber = this.BeginNumber + Convert.ToInt64((i - 1) * CratingQty); + bill.EndNumber = Convert.ToInt64(bill.BeginNumber + CratingQty) - 1; + } + } + } + + this.BillNos.Add(bill); + + //改变前后的billNo值,新的值再一次被使用 + firstBillNo = bill.FirstBillNo; + lastBillNo = bill.LastBillNo; + } + //判断有小数点,那么它就有尾箱,把当前第一条的编号是否是尾箱字段改为true + //if (this.BillNos.Count != 0 && hasPart) + // this.BillNos[0].IsTail = true; + } + + } +} diff --git a/src/BarCode.Web.Domain/Entitys/BoxMarkBillNo.cs b/src/BarCode.Web.Domain/Entitys/BoxMarkBillNo.cs new file mode 100644 index 0000000..a50b266 --- /dev/null +++ b/src/BarCode.Web.Domain/Entitys/BoxMarkBillNo.cs @@ -0,0 +1,87 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Text; +using BarCode.Web.Core; + +namespace BarCode.Web.Domain.Entitys +{ + /// + /// 箱唛表-编号表 + /// + [Serializable] + [Table("t_barcode_box_mark_billno")] + public class BoxMarkBillNo : EntityBase + { + /// + /// ID + /// + public override int Id { get; set; } + + /// + /// 上级ID + /// + public int Fid { get; set; } + + /// + /// 箱唛编号 + /// + public string BillNo { get; set; } + + /// + /// 箱唛编号-首位 + /// + public int FirstBillNo { get; set; } + + /// + /// 箱唛编号-末尾序号 + /// + public int LastBillNo { get; set; } + + /// + /// 是否是尾箱 + /// + public bool IsTail { get; set; } + + /// + /// 排序 + /// + public int Sort { get; set; } + /// + /// 流水号(开始) + /// + public Int64? BeginNumber { get; set; } = null; + /// + /// 流水号(结束) + /// + public Int64? EndNumber { get; set; } = null; + + /// + /// 生成编号 + /// + /// + /// + public void GenerateBillNo(int firstBillNo, int lastBillNo) + { + this.FirstBillNo = Convert.ToInt32(DateTime.Now.ToString("yyMMdd")); + if (this.FirstBillNo == firstBillNo) + this.LastBillNo = lastBillNo + 1; + else + this.LastBillNo = 1; + + if (this.LastBillNo.ToString().Length >= 5) + { + this.BillNo = "XM" + this.FirstBillNo + this.LastBillNo; + return; + } + + string lastStr = this.LastBillNo.ToString(); + while (true) + { + lastStr = "0" + lastStr; + if (lastStr.Length >= 5) break; + } + this.BillNo = "XM" + this.FirstBillNo + lastStr; + } + } +} diff --git a/src/BarCode.Web.Domain/Entitys/CenerateData.cs b/src/BarCode.Web.Domain/Entitys/CenerateData.cs new file mode 100644 index 0000000..e9eb958 --- /dev/null +++ b/src/BarCode.Web.Domain/Entitys/CenerateData.cs @@ -0,0 +1,40 @@ +using BarCode.Web.Core; +using BarCode.Web.Domain.Values; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Domain.Entitys +{ + /// + /// 生成计划管理 + /// + [Serializable] + [Table("t_wms_cenerate_date")] + public class CenerateData : EntityBase + { + public CenerateData() { } + public CenerateData(CenerateDataType type) + { + this.Type = type; + } + /// + /// 主键 订单编号 + /// + [Column("Id")] + public override int Id { get; set; } + /// + /// 同步类型 + /// + [Column("Type")] + public CenerateDataType Type { get; set; } = CenerateDataType.Serial; + /// + /// 数量 + /// + [Column("Number")] + public int Number { get; set; } = 1; + } +} diff --git a/src/BarCode.Web.Domain/Entitys/FileDownManager.cs b/src/BarCode.Web.Domain/Entitys/FileDownManager.cs new file mode 100644 index 0000000..1a7be0d --- /dev/null +++ b/src/BarCode.Web.Domain/Entitys/FileDownManager.cs @@ -0,0 +1,90 @@ + +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Text; +using BarCode.Web.Core; +using BarCode.Web.Domain.Values; + +namespace BarCode.Web.Domain.Entitys +{ + /// + /// 文件下载类型 + /// + [Serializable] + [Table("t_barcode_file_down_manager")] + public class FileDownManager : EntityBase + { + public FileDownManager() { } + public FileDownManager(int userId, int companyId, FileDownLoadOrderType type,string orgCode, string path, string supplierCode) + { + this.UserId = userId; + this.CompanyId = companyId; + this.Type = type; + this.FilePath = path; + this.SupplierCode = supplierCode; + this.OrgCode = orgCode; + } + /// + /// 主键 订单编号 + /// + [Column("Id")] + public override int Id { get; set; } + /// + /// 日期 + /// + [Column("Date")] + public DateTime? Date { get; set; } = DateTime.Now; + /// + /// 单据类型(任务类型) + /// + [Column("Type")] + public FileDownLoadOrderType Type { get; set; } = FileDownLoadOrderType.SerialNumbers; + /// + /// 状态 + /// + [Column("Status")] + public ExportStatus Status { get; set; } = ExportStatus.Ing; + /// + /// 公司Id + /// + [Column("CompanyId")] + public int CompanyId { get; set; } + /// + /// 组织编码 + /// + [Column("OrgCode")] + public string OrgCode { get; set; } = ""; + /// + /// 文件地址 + /// + [Column("FilePath")] + public string FilePath { get; set; } + /// + /// 操作人 + /// + [Column("UserId")] + public int UserId { get; set; } + /// + /// 失败原因 + /// + [Column("Reason")] + public string Reason { get; set; } = ""; + /// + /// 供应商编码 + /// + [Column("SupplierCode")] + public string SupplierCode { get; set; } = ""; + + public void Finish(bool IsSuccess, string reson) + { + if (IsSuccess) + this.Status = ExportStatus.Success; + else + { + this.Status = ExportStatus.Fail; + this.Reason = reson; + } + } + } +} diff --git a/src/BarCode.Web.Domain/Entitys/Materials.cs b/src/BarCode.Web.Domain/Entitys/Materials.cs new file mode 100644 index 0000000..9eae68f --- /dev/null +++ b/src/BarCode.Web.Domain/Entitys/Materials.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Text; +using BarCode.Web.Core; + +namespace BarCode.Web.Domain.Entitys +{ + /// + /// 物料 + /// + [Serializable] + [Table("t_barcode_materials")] + public class Materials : EntityBase + { + /// + /// ID + /// + public override int Id { get; set; } + + /// + /// 组织Id + /// + public int OrgId { get; set; } + + /// + /// 组织编码 + /// + public string OrgCode { get; set; } + + /// + /// 物料ID + /// + public int MaterialId { get; set; } + + /// + /// 物料名称 + /// + public string MaterialName { get; set; } + /// + /// 物料编码 + /// + public string MaterialNumber { get; set; } + /// + /// 物料规格型号 + /// + public string Specifications { get; set; } + + /// + /// 基本单位 + /// + public int BaseUnitId { get; set; } + + /// + /// 基本单位名称 + /// + public string BaseUnitName { get; set; } + /// + /// 基本单位编码 + /// + public string BaseUnitNumber { get; set; } + + /// + /// 条码 + /// + public string BarCode { get; set; } + + /// + /// 是否启用批号管理 + /// + public bool IsBatchManage { get; set; } + /// + /// 物料Id 32进制字符串 + /// + public string IdConvertBar { get; set; } + } +} diff --git a/src/BarCode.Web.Domain/Entitys/SecurityNumberGenerateRecord.cs b/src/BarCode.Web.Domain/Entitys/SecurityNumberGenerateRecord.cs new file mode 100644 index 0000000..a2e7607 --- /dev/null +++ b/src/BarCode.Web.Domain/Entitys/SecurityNumberGenerateRecord.cs @@ -0,0 +1,116 @@ +using BarCode.Web.Core; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Domain.Entitys +{ + /// + /// 防伪码生成记录 + /// + [Serializable] + [Table("t_barcode_securitynumbergeneraterecord")] + public class SecurityNumberGenerateRecord : EntityBase + { + /// + /// 主键 订单编号 + /// + [Column("Id")] + public override int Id { get; set; } + /// + /// 防伪码批次 + /// + [Column("LotNumber")] + public string LotNumber { get; set; } = string.Empty; + /// + /// 物料编码 + /// + [Column("MaterialNumber")] + public string MaterialNumber { get; set; } = string.Empty; + /// + /// 公司Id + /// + [Column("CompanyId")] + public int CompanyId { get; set; } = 0; + /// + /// 组织Id + /// + [Column("OrgCode")] + public string OrgCode { get; set; } = ""; + /// + /// 供应商code + /// + [Column("SupplierCode")] + public string SupplierCode { get; set; } = ""; + /// + /// 生成完成 1 生成中 0 + /// + [Column("IsGenerateComplete")] + public bool IsGenerateComplete { get; set; } = false; + /// + /// 生成条码数量 + /// + [Column("Number")] + public int Number { get; set; } = 0; + /// + /// 下载数 + /// + [Column("DownLoadNumber")] + public int DownLoadNumber { get; set; } = 0; + /// + /// 创建人 + /// + [Column("CreatorId")] + public int CreatorId { get; set; } = 0; + /// + /// 生成时间 + /// + [Column("CreateTime")] + public DateTime CreateTime { get; set; } = DateTime.Now; + /// + /// 生成完成时间 + /// + [Column("GenerateCompleteTime")] + public DateTime? GenerateCompleteTime { get; set; } = null; + /// + /// 生成完成 + /// + public void Complete() + { + this.IsGenerateComplete = true; + this.GenerateCompleteTime = DateTime.Now; + } + /// + /// 下载 + /// + public void DownLoad(int number) + { + this.DownLoadNumber = number; + } + /// + /// 生成批号 + /// + public void GenerateLotNumber(int number) + { + //用户手动输入了 就不自动生成了 + if (!string.IsNullOrEmpty(this.LotNumber)) return; + + if (number.ToString().Length >= 3) + { + this.LotNumber = "FWM" + DateTime.Now.ToString("yyMMdd") + number; + return; + } + + string idStr = number.ToString(); + while (true) + { + idStr = "0" + idStr; + if (idStr.Length >= 3) break; + } + this.LotNumber = "FWM" + DateTime.Now.ToString("yyMMdd") + idStr; + } + } +} diff --git a/src/BarCode.Web.Domain/Entitys/SecurityNumbers.cs b/src/BarCode.Web.Domain/Entitys/SecurityNumbers.cs new file mode 100644 index 0000000..adc830a --- /dev/null +++ b/src/BarCode.Web.Domain/Entitys/SecurityNumbers.cs @@ -0,0 +1,110 @@ +using BarCode.Web.Core; +using BarCode.Web.Domain.Services.Public; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Domain.Entitys +{ + /// + /// 防伪码 + /// + [Serializable] + [Table("t_barcode_securitynumbers")] + public class SecurityNumbers : EntityLongBase + { + /// + /// 主键 订单编号 + /// + [Column("Id")] + public override long Id { get; set; } + /// + /// 组织Code + /// + [Column("OrgCode")] + public string OrgCode { get; set; } = string.Empty; + /// + /// 供应商code + /// + [Column("SupplierCode")] + public string SupplierCode { get; set; } = ""; + /// + /// 生成记录Id + /// + [Column("GenerateRecordId")] + public int GenerateRecordId { get; set; } = 0; + /// + /// 防伪码 + /// + [Column("SecurityNumber")] + public string SecurityNumber { get; set; } = ""; + /// + /// 物料编码 + /// + [Column("MaterialNumber")] + public string MaterialNumber { get; set; } = string.Empty; + /// + /// 下载次数 + /// + [Column("DownLoadNumber")] + public int DownLoadNumber { get; set; } = 0; + /// + /// 最新下载时间 + /// + [Column("DownLoadTime")] + public DateTime? DownLoadTime { get; set; } + /// + /// 查询次数 + /// + [Column("QueryCount")] + public int QueryCount { get; set; } = 0; + /// + /// 第一次查询时间 + /// + [Column("QueryTime")] + public DateTime? QueryTime { get; set; } + /// + /// 创建人 + /// + [Column("CreatorId")] + public int CreatorId { get; set; } = 0; + /// + /// 生成时间 + /// + [Column("CreateTime")] + public DateTime? CreateTime { get; set; } = DateTime.Now; + /// + /// 下载 + /// + public void DownLoad() + { + this.DownLoadNumber++; + this.DownLoadTime = DateTime.Now; + } + /// + /// 生成防伪码 + /// + public void GenerateSecurityNumber() + { + if (!string.IsNullOrEmpty(this.SecurityNumber)) return; + string exclude = "WXYZ"; + int? FLength = 9; + + var idStr = Radix.ConvertRadix36((ulong)this.Id, exclude.ToCharArray()).PadLeft(FLength ?? 0, '0'); + this.SecurityNumber = "A" + idStr; + } + /// + /// 被查询 + /// + public void Get() + { + if (this.QueryCount <= 0) + this.QueryTime = DateTime.Now; + this.QueryCount++; + + } + } +} diff --git a/src/BarCode.Web.Domain/Entitys/SerialNumberGenerateRecord.cs b/src/BarCode.Web.Domain/Entitys/SerialNumberGenerateRecord.cs new file mode 100644 index 0000000..8814ee6 --- /dev/null +++ b/src/BarCode.Web.Domain/Entitys/SerialNumberGenerateRecord.cs @@ -0,0 +1,150 @@ +using BarCode.Web.Core; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Domain.Entitys +{ + /// + /// 序列号生成记录 + /// + [Serializable] + [Table("t_barcode_serialnumbergeneraterecord")] + public class SerialNumberGenerateRecord : EntityBase + { + /// + /// 主键 订单编号 + /// + [Column("Id")] + public override int Id { get; set; } + /// + /// 物料Id转32进制 + /// + [Column("IdConvertBar")] + public string IdConvertBar { get; set; } = ""; + /// + /// 物料编码 + /// + [Column("MaterialNumber")] + public string MaterialNumber { get; set; } = ""; + /// + /// 是否更改过物料编码 + /// + [Column("IsUpdateMaterial")] + public bool? IsUpdateMaterial { get; set; } = false; + /// + /// 采购单号 + /// + [Column("PurchaseBillNo")] + public string PurchaseBillNo { get; set; } = ""; + /// + /// 供应商code + /// + [Column("SupplierCode")] + public string SupplierCode { get; set; } = ""; + /// + /// 公司Id + /// + [Column("CompanyId")] + public int CompanyId { get; set; } = 0; + /// + /// 组织Id + /// + [Column("OrgCode")] + public string OrgCode { get; set; } = ""; + /// + /// 生成完成 1 生成中 0 + /// + [Column("IsGenerateComplete")] + public bool IsGenerateComplete { get; set; } = false; + /// + /// 生成条码数量 + /// + [Column("Number")] + public int Number { get; set; } = 0; + /// + /// 生成条码起始位数量(后端用来做标记) + /// + [Column("BeginNumber")] + public int BeginNumber { get; set; } = 0; + /// + /// 打印数 + /// + [Column("PrintNumber")] + public int PrintNumber { get; set; } = 0; + /// + /// 下载数 + /// + [Column("DownLoadNumber")] + public int DownLoadNumber { get; set; } = 0; + /// + /// 使用数 + /// + [Column("UseNumber")] + public int UseNumber { get; set; } = 0; + /// + /// 创建人 + /// + [Column("CreatorId")] + public int CreatorId { get; set; } = 0; + + /// + /// 是否套装,默认是为1,1即为单个,不是套装Alter by yzh + /// + [Column("IsTwo")] + public int IsTwo { get; set; } = 1; + + + /// + /// 生成时间 + /// + [Column("CreateTime")] + public DateTime CreateTime { get; set; } = DateTime.Now; + /// + /// 生成完成时间 + /// + [Column("GenerateCompleteTime")] + public DateTime? GenerateCompleteTime { get; set; } = null; + /// + /// 生成完成 + /// + public void Complete() + { + this.IsGenerateComplete = true; + this.GenerateCompleteTime = DateTime.Now; + } + /// + /// 打印 + /// + public void Print(int number) + { + this.PrintNumber= number; + } + /// + /// 下载 + /// + public void DownLoad(int number) + { + this.DownLoadNumber= number; + } + /// + /// 反写使用数 + /// + /// + public void Use(int number) + { + this.UseNumber = number; + } + /// + /// 标记修改物料 + /// + public void UpdateMaterial() + { + this.IsUpdateMaterial = true; + } + } +} diff --git a/src/BarCode.Web.Domain/Entitys/SerialNumbers.cs b/src/BarCode.Web.Domain/Entitys/SerialNumbers.cs new file mode 100644 index 0000000..04ae230 --- /dev/null +++ b/src/BarCode.Web.Domain/Entitys/SerialNumbers.cs @@ -0,0 +1,287 @@ +using BarCode.Web.Core; +using BarCode.Web.Core.Help; +using BarCode.Web.Core.Internal.Results; +using BarCode.Web.Domain.Services.Public; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Domain.Entitys +{ + /// + /// 序列号 默认Id从 200000000 起始 + /// alter table users AUTO_INCREMENT=200000000; + /// + [Serializable] + [Table("t_barcode_serialnumbers")] + public class SerialNumbers : EntityLongBase + { + /// + /// 主键 订单编号 + /// + [Column("Id")] + public override long Id { get; set; } + /// + /// 组织Code + /// + [Column("OrgCode")] + public string OrgCode { get; set; } = string.Empty; + /// + /// 供应商code + /// + [Column("SupplierCode")] + public string SupplierCode { get; set; } = ""; + /// + /// 生成记录Id + /// + [Column("GenerateRecordId")] + public int GenerateRecordId { get; set; } = 0; + /// + /// 序列号 + /// + [Column("SerialNumber")] + public string SerialNumber { get; set; } = string.Empty; + + + /// + /// 套装(1代表单套,2代表2套,3代表3套) aLTER BY YZH + /// + [Column("IsTwo")] + public int IsTwo { get; set; } =1; + + /// + ///当次序号,用来记录当次所产生时所处的序列号 + /// + [Column("thisNumber")] + public int thisNumber { get; set; } = 1; + + /// + /// 序列号 + /// + [Column("SuitNumber")] + public string SuitNumber { get; set; } = string.Empty; + /// + /// 产生第二个 + /// + [Column("TwoSerialNumber")] + public string TwoSerialNumber { get; set; } = string.Empty; + /// + /// 物料Id + /// + [Column("MaterialId")] + public int MaterialId { get; set; } = 0; + /// + /// 物料编码 + /// + [Column("MaterialNumber")] + public string MaterialNumber { get; set; } = string.Empty; + /// + /// 老物料编码(上一次物料编码) + /// + [Column("Old_MaterialNumber")] + public string? Old_MaterialNumber { get; set; } = string.Empty; + /// + /// 箱ID + /// + [Column("BoxId")] + public int BoxId { get; set; } = 0; + /// + /// 数字序列码 + /// + [Column("NumberCode")] + public string NumberCode { get; set; } = string.Empty; + /// + /// 数字序列码(不包含日期) + /// + [Column("Number")] + public int Number { get; set; } = 1; + /// + /// 是否使用 + /// + [Column("IsUse")] + public bool IsUse { get; set; } = false; + /// + /// 创建人 + /// + [Column("CreatorId")] + public int CreatorId { get; set; } = 0; + /// + /// 生成时间 + /// + [Column("CreateTime")] + public DateTime CreateTime { get; set; } = DateTime.Now; + /// + /// 完成装箱时间 + /// + [Column("CompleteCartonTime")] + public DateTime? CompleteCartonTime { get; set; } + /// + /// 打印次数 + /// + [Column("PrintNumber")] + public int PrintNumber { get; set; } = 0; + /// + /// 下载次数 + /// + [Column("DownLoadNumber")] + public int DownLoadNumber { get; set; } = 0; + /// + /// 最新打印时间 + /// + [Column("PrintTime")] + public DateTime? PrintTime { get; set; } + /// + /// 最新下载时间 + /// + [Column("DownLoadTime")] + public DateTime? DownLoadTime { get; set; } + /// + /// 是否使用的是数字序列码未使用null,数字序列码true,序列码false + /// + [Column("IsUseNumber")] + public bool? IsUseNumber { get; set; } = null; + /// + /// 生成序列码 + /// + public string GenerateSerialNumber() + { + string exclude = "ISOZ"; + int? FLength = 6; + + var idStr = Radix.ConvertRadix36((ulong)this.Id, exclude.ToCharArray()).PadLeft(FLength ?? 0, '0'); + this.SerialNumber = this.SerialNumber + "-" + idStr; + return this.SerialNumber; + } + + ///// + ///// 生成套装编码 alter by yzh + ///// + //public void GenerateSuitNumber(string sn,) + //{ + + + // string exclude = "ISOZ"; + // int? FLength = 6; + + // var idStr = Radix.ConvertRadix36((ulong)this.Id, exclude.ToCharArray()).PadLeft(FLength ?? 0, '0'); + // this.SerialNumber = this.SerialNumber + "-" + idStr; + //} + + + /// + /// 生成时间序列码 + /// + public void GenerateNumberCode() + { + //用户手动输入了 就不自动生成了 + if (!string.IsNullOrEmpty(this.NumberCode)) return; + + if (this.Number.ToString().Length >= 6) + { + this.NumberCode = this.CreateTime.ToString("yyMMdd") + this.Number.ToString(); + return; + } + + string idStr = this.Number.ToString(); + while (true) + { + idStr = "0" + idStr; + if (idStr.Length >= 6) break; + } + this.NumberCode = this.CreateTime.ToString("yyMMdd") + idStr; + } + /// + /// 产生套装编码 alter by yzh + /// + /// + + public void GenerateSuitNumber(string sn) + { + this.SuitNumber = sn; + + } + /// + /// 产生第二个序列号 + /// + /// + public void GenerateTwoSerialNumber(string sn) + { + this.TwoSerialNumber = sn; + + } + + + + /// + /// 打印 + /// + public void Print() + { + //被wms使用的数据不能被打印 + if (this.BoxId <= 0 && this.IsUse == true) return; + + this.PrintNumber++; + this.PrintTime = DateTime.Now; + } + /// + /// 下载 + /// + public void DownLoad() + { + this.DownLoadNumber++; + this.DownLoadTime = DateTime.Now; + } + /// + /// 装箱 + /// + /// + /// + public void CompleteBox(int boxId, string str) + { + //每个序列码延时1毫秒来装箱 这样到时候获取序列码时就可以来排序 + Thread.Sleep(1); + this.BoxId = boxId; + this.CompleteCartonTime = DateTime.Now; + this.IsUse = true; + this.IsUseNumber = this.NumberCode.Equals(str) ? true : false; + } + /// + /// 解绑箱 + /// + public void UnBox() + { + this.BoxId = 0; + this.CompleteCartonTime = null; + this.IsUse = false; + this.IsUseNumber = null; + } + /// + /// wms系统获取序列码后 序列码调整为已使用 + /// + public void WmsGet(string str) + { + this.BoxId = -1; + this.IsUse = true; + this.IsUseNumber = this.NumberCode.Equals(str) ? true : false; + } + /// + /// 修改物料编码 + /// + /// + public Result UpdateMaterial(string number) + { + if (this.IsUse) + return Result.ReFailure($"序列码 {this.SerialNumber} 已被使用,不允许规格转换", 600007); + if (!this.MaterialNumber.Equals(number)) + { + this.Old_MaterialNumber = this.MaterialNumber; + this.MaterialNumber = number; + } + + return Result.ReSuccess(); + } + } +} diff --git a/src/BarCode.Web.Domain/IService/IBoxMarkService.cs b/src/BarCode.Web.Domain/IService/IBoxMarkService.cs new file mode 100644 index 0000000..6e5fc19 --- /dev/null +++ b/src/BarCode.Web.Domain/IService/IBoxMarkService.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using BarCode.Web.Core.Dto; +using BarCode.Web.Core.Dto.Login; +using BarCode.Web.Core.Internal.Results; + +namespace BarCode.Web.Domain.IService +{ + /// + /// 箱唛-服务接口 + /// + public interface IBoxMarkService + { + /// + /// 生成 + /// + /// + /// + /// + Task> Generate(GenerateBoxMarkDto dto, LoginInDto loginInfo); + + /// + /// 列表-分页 + /// + /// + /// + /// + Task<(List list, int total)> GetPagedList(BoxMarkQueryRequest dto, LoginInDto loginInfo); + } +} diff --git a/src/BarCode.Web.Domain/IService/IBoxService.cs b/src/BarCode.Web.Domain/IService/IBoxService.cs new file mode 100644 index 0000000..b7f6b9d --- /dev/null +++ b/src/BarCode.Web.Domain/IService/IBoxService.cs @@ -0,0 +1,60 @@ +using BarCode.Web.Core.Dto; +using BarCode.Web.Core.Dto.Box; +using BarCode.Web.Core.Dto.Login; +using BarCode.Web.Core.Dto.SerialNumbers; +using BarCode.Web.Core.Internal.Results; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Domain.IService +{ + /// + /// 箱 + /// + public interface IBoxService + { + /// + /// wms获取已完成装箱箱信息 + /// + /// + /// + /// + Task<(List list, int total)> GetCartonListAsync(WmsBoxRequest dto); + /// + /// 装箱 + /// + /// + /// + /// + Task Save(SaveBoxRequest dto, LoginInDto loginInfo); + /// + /// 生成箱码 + /// + /// + /// + /// + Task Generate(GenerateBoxRequest dto, LoginInDto loginInfo); + /// 打印 + Task Print(OperateRequest dto); + /// + /// 删除 + /// + /// + Task Delete(DeleteBoxSerialNumberRequest dto, LoginInDto loginInfo); + /// + /// 清空 + /// + /// + Task Clear(int boxId, LoginInDto loginInfo); + /// 重新装箱 + Task Restart(OperateRequest dto, LoginInDto loginInfo); + /// + /// 开始装箱 + /// + /// + Task BeginCarton(int boxId, LoginInDto loginInfo); + } +} diff --git a/src/BarCode.Web.Domain/IService/IExportExcelService.cs b/src/BarCode.Web.Domain/IService/IExportExcelService.cs new file mode 100644 index 0000000..ae945f3 --- /dev/null +++ b/src/BarCode.Web.Domain/IService/IExportExcelService.cs @@ -0,0 +1,56 @@ +using Npoi.Mapper; +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using BarCode.Web.Core.Dto; +using BarCode.Web.Domain.Values; +using BarCode.Web.Core.Dto.Login; + +namespace BarCode.Web.Domain.IService +{ + public interface IExportExcelService + { + /// + /// 全字段导出数据 + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + Task ExportAll(Request request, string fileName, int userId, LoginInDto loginInfo, FileDownLoadOrderType type, string orgCode, Mapper mapper = null, int? supplierId = null) where Request : PaginationBaseRequestDto; + /// + /// 列表字段导出数据 + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + Task ExportList(Request request, string fileName, int userId, LoginInDto loginInfo, FileDownLoadOrderType type,string orgCode, Mapper mapper = null, int? supplierId = null) where Request : PaginationBaseRequestDto; + /// + /// 列表页导出数据 + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + Task Export(List dataList, string fileName,int userId, LoginInDto loginInfo, FileDownLoadOrderType type, string orgCode, Mapper mapper = null, int? supplierId = null); + } +} diff --git a/src/BarCode.Web.Domain/IService/IQiniuUploadService.cs b/src/BarCode.Web.Domain/IService/IQiniuUploadService.cs new file mode 100644 index 0000000..bde2e4c --- /dev/null +++ b/src/BarCode.Web.Domain/IService/IQiniuUploadService.cs @@ -0,0 +1,22 @@ + +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using System.Threading.Tasks; +using BarCode.Web.Core.Internal.Results; + +namespace BarCode.Web.Domain.IService +{ + public interface IQiniuUploadService + { + /// + /// 上传文件 + /// + /// + /// + /// 是否开启自动删除 如果开启 3天后自动删除 导出的execl文件 + /// + Task> Upload(string fileName, Stream stream,bool isAutoDelte= false); + } +} diff --git a/src/BarCode.Web.Domain/IService/ISecurityNumberService.cs b/src/BarCode.Web.Domain/IService/ISecurityNumberService.cs new file mode 100644 index 0000000..e07766f --- /dev/null +++ b/src/BarCode.Web.Domain/IService/ISecurityNumberService.cs @@ -0,0 +1,32 @@ +using BarCode.Web.Core.Dto.Login; +using BarCode.Web.Core.Dto.SecurityNumbers; +using BarCode.Web.Core.Dto.SerialNumbers; +using BarCode.Web.Core.Internal.Results; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Domain.IService +{ + /// + /// 防伪码 + /// + public interface ISecurityNumberService + { + /// + /// 下载 + /// + /// + /// + Task DownLoad(OperateSecurityNumberRequest dto); + /// + /// 生成防伪码 + /// + /// + /// + /// + Task Generate(GenerateSecurityNumberRequest dto, LoginInDto loginInfo); + } +} diff --git a/src/BarCode.Web.Domain/IService/ISerialNumberService.cs b/src/BarCode.Web.Domain/IService/ISerialNumberService.cs new file mode 100644 index 0000000..170b40c --- /dev/null +++ b/src/BarCode.Web.Domain/IService/ISerialNumberService.cs @@ -0,0 +1,50 @@ +using BarCode.Web.Core.Dto; +using BarCode.Web.Core.Dto.Login; +using BarCode.Web.Core.Dto.SerialNumbers; +using BarCode.Web.Core.Internal.Results; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Domain.IService +{ + /// + /// 序列号服务 + /// + public interface ISerialNumberService + { + /// + /// 生成序列号 + /// + /// + /// + /// + Task Generate(GenerateSerialNumberRequest dto, LoginInDto loginInfo); + /// + /// 打印 + /// + /// + /// + Task Print(OperateSerialNumberRequest dto); + /// + /// 下载 + /// + /// + /// + Task DownLoad(OperateSerialNumberRequest dto); + /// + /// 装箱后反写使用数 + /// + /// + /// + Task Use(List sGIds); + /// + /// 修改序列号物料 + /// + /// + /// + Task UpdateMaterial(UpdateMaterialRequest dto); + } +} diff --git a/src/BarCode.Web.Domain/IService/Public/IErpBasicDataExtendService.cs b/src/BarCode.Web.Domain/IService/Public/IErpBasicDataExtendService.cs new file mode 100644 index 0000000..d529157 --- /dev/null +++ b/src/BarCode.Web.Domain/IService/Public/IErpBasicDataExtendService.cs @@ -0,0 +1,191 @@ +using System; +using System.Collections.Generic; +using System.Text; +using BarCode.Web.Core.Dto.Erp; +using BarCode.Web.Core.Dto.Erp.Customer; +using BarCode.Web.Core.Dto.Erp.Org; +using BarCode.Web.Core.Dto.Erp.Supplier; +using BarCode.Web.Core.Dto.SingleData; + +namespace BarCode.Web.Domain.IService.Public +{ + /// + /// erp基础数据:扩展服务接口 + /// + public interface IErpBasicDataExtendService + { + /// + /// 获取物料名称 + /// + /// + /// + string GetMaterialName(List erpMaterials, int materialId); + + /// + /// 获取物料编码 + /// + /// + /// + /// + string GetMaterialNumber(List erpMaterials, int materialId); + + /// + /// 获取物料规格型号 + /// + /// + /// + /// + string GetMaterialSpecifications(List erpMaterials, int materialId); + + /// + /// 获取物料名称 + /// + /// + /// + string GetMaterialName(List erpMaterials, string materialNumber); + + /// + /// 获取物料规格型号 + /// + /// + /// + /// + string GetMaterialSpecifications(List erpMaterials, string materialNumber); + + /// + /// 获取物料基本单位名称 + /// + /// + /// + /// + string GetMaterialUnitName(List erpMaterials, int materialId); + /// + /// 获取物料基本单位名称 + /// + /// + /// + /// + string GetMaterialUnitName(List erpMaterials, string materialnumber); + + /// + /// 获取物料的条码 + /// + /// + /// + /// + string GetMaterialBarCode(List erpMaterials, int materialId); + + /// + /// 获取物料的条码 + /// + /// + /// + /// + string GetMaterialBarCode(List erpMaterials, string materialNumber); + + /// + /// 获取物料基本单位id + /// + /// + /// + /// + int GetMaterialUnitId(List erpMaterials, int materialId); + /// + /// 获取物料基本单位编码 + /// + /// + /// + /// + string GetMaterialUnitNumber(List erpMaterials, int materialId); + + /// + /// 获取物料基本单位编码 + /// + /// + /// + /// + string GetMaterialUnitNumber(List erpMaterials, string materialNumber); + /// + /// 获取组织名称 + /// + /// + /// + /// + string GetOrgName(List erpOrgs, int orgId); + + /// + /// 获取组织名称 + /// + /// + /// + /// + string GetOrgName(List erpOrgs, string orgCode); + + /// + /// 获取组织ID + /// + /// + /// + int GetOrgId(List erpOrgs, string orgCode); + + /// + /// 获取供应商名称 + /// + /// + /// + /// + string GetSupplierName(List erpSuppliers, int supplierId); + /// + /// 获取供应商名称 + /// + /// + /// + /// + string GetSupplierName(List erpSuppliers, string supplierCode); + /// + /// 获取客户名称 + /// + /// + /// + /// + string GetCustomerName(List erpCustomers, int customerId); + + /// + /// 获取仓库名称 + /// + /// + /// + /// + string GetStockName(List erpStocks, int stockId); + + /// + /// 获取仓库名称 + /// + /// + /// + /// + string GetStockName(List erpStocks, string code); + + /// + /// 获取仓库编码 + /// + /// + /// + /// + string GetStockCode(List erpStocks, int stockId); + + /// + /// 获取子仓库名称 + /// + /// + /// + /// + string GetSubStockName(List erpStocks, string code); + /// + /// 获取单点组织名字 + /// + /// + /// + string GetSingleOrgName(List orgs, string code); + } +} diff --git a/src/BarCode.Web.Domain/IService/Public/IErpService.cs b/src/BarCode.Web.Domain/IService/Public/IErpService.cs new file mode 100644 index 0000000..b3ef88d --- /dev/null +++ b/src/BarCode.Web.Domain/IService/Public/IErpService.cs @@ -0,0 +1,100 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using BarCode.Web.Core.Dto.Erp; +using BarCode.Web.Core.Dto.Erp.Customer; +using BarCode.Web.Core.Dto.Erp.Org; +using BarCode.Web.Core.Dto.Erp.OutStock; +using BarCode.Web.Core.Dto.Erp.Supplier; +using BarCode.Web.Core.Internal.Results; +using BarCode.Web.Domain.Entitys; + +namespace BarCode.Web.Domain.IService.Public +{ + public interface IErpService + { + /// + /// 查单据类型的值 + /// + /// + Task> BillQueryForBillType(); + /// + /// erp:单据查询-物料集合 + /// + /// + Task> BillQueryForMaterial(bool isCache = true); + /// + /// 获取物料id32进制 + /// + /// + /// + Task> BillQueryForMaterialByNumbers(List materialNumbers); + + /// + /// erp:基础数据-物料信息 + /// + /// + /// + Task> BillQueryForMaterial(int id); + /// + /// erp:基础数据-物料信息 + /// + /// + /// + Task> BillQueryForMaterial(string number); + + /// + /// + /// + /// + /// + Task BillQueryForMaterialByNumber(string number); + /// + /// + /// + /// + /// + Task BillQueryForMaterialByNumber(string number, string orgCode); + + /// + /// + /// + /// + Task> BillQueryForOrg(); + + /// + /// 供应商 + /// + /// + Task> BillQueryForSupplier(); + /// + /// 客户 + /// + /// + Task> BillQueryForCustomer(); + /// + /// 获取仓库信息 + /// + /// + Task> BillQueryForStock(); + /// + /// 获取仓位信息信息 根据仓库编码 + /// + /// + Task> BillQueryForSubStock(); + + //同步数据(保存提交审核) + Task> Save(T dto, string formId); + //提交 + Task Submit(ErpOperateDto dto, string formId); + //审核 + Task Audit(ErpOperateDto dto, string formId); + //反审核 + Task NoAudit(ErpOperateDto dto, string formId); + //删除 + Task Delete(ErpOperateDto dto, string formId); + //下推 + Task> Push(ErpPushDto dto); + } +} diff --git a/src/BarCode.Web.Domain/IService/Public/IHttpClientService.cs b/src/BarCode.Web.Domain/IService/Public/IHttpClientService.cs new file mode 100644 index 0000000..404e72b --- /dev/null +++ b/src/BarCode.Web.Domain/IService/Public/IHttpClientService.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Domain.IService.Public +{ + public interface IHttpClientService + { + HttpClient BuildHttpClient(Dictionary dicDefaultHeaders, int? timeoutSecond = 180); + Task GetAsync(string url, int timeoutSecond = 180); + Task GetAsync(string url, Dictionary dicHeaders, int timeoutSecond = 180); + Task PostAsync(string url, string requestBody, int timeoutSecond = 180); + Task PostAsync(string url, string requestBody, Dictionary dicHeaders, int timeoutSecond = 180); + Task ExecuteAsync(string url, HttpMethod method, string requestBody, Dictionary dicHeaders, int timeoutSecond = 180); + } +} diff --git a/src/BarCode.Web.Domain/IService/Public/ILoginService.cs b/src/BarCode.Web.Domain/IService/Public/ILoginService.cs new file mode 100644 index 0000000..e1ab277 --- /dev/null +++ b/src/BarCode.Web.Domain/IService/Public/ILoginService.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using BarCode.Web.Core.Dto.Login; +using BarCode.Web.Core.Dto.Login.Temp; +using BarCode.Web.Core.Internal.Results; + +namespace BarCode.Web.Domain.IService.Public +{ + /// + /// 登录服务接口 + /// + public interface ILoginService + { + + /// + /// 创建token + /// + /// + /// + /// + /// + Task CreateToken(UserInfoDto data, LoginTempDto tempDto, string NewToken); + + /// + /// + /// + /// + /// + Task> GetUserInfoByCode(string code); + + /// + /// 获取单点用户信息 + /// + /// + /// + /// + Task> GetUserInfo(string username, string password); + + /// + /// 登录退出 + /// + /// + /// + Task LoginOut(LoginOutDto dto); + + /// + /// 刷新token + /// + /// + /// + /// + Task> RefreshTokenNew(string Token, string RefreshToken); + + /// + /// 单点退出通知token失效 + /// + /// + /// + Task LoginOutSingleAsync(string SeesionId); + + /// + /// 获取登录后的信息 + /// + /// + /// + LoginInDto GetLoginInfo(string authorization); + + /// + /// 获取菜单 + /// + /// + /// + Task> GetMenuList(int userId); + } +} diff --git a/src/BarCode.Web.Domain/IService/Public/IMaterialService.cs b/src/BarCode.Web.Domain/IService/Public/IMaterialService.cs new file mode 100644 index 0000000..60d9179 --- /dev/null +++ b/src/BarCode.Web.Domain/IService/Public/IMaterialService.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using BarCode.Web.Core.Internal.Results; + +namespace BarCode.Web.Domain.IService +{ + /// + /// 物料服务接口 + /// + public interface IMaterialService + { + /// + /// 同步金蝶新物料 + /// + /// + Task SyncNewMaterials(); + /// + /// 同步物料id32进制 + /// + /// + Task SyncBar(); + } +} diff --git a/src/BarCode.Web.Domain/IService/Public/IRedisConcurrentProcessService.cs b/src/BarCode.Web.Domain/IService/Public/IRedisConcurrentProcessService.cs new file mode 100644 index 0000000..50cdccb --- /dev/null +++ b/src/BarCode.Web.Domain/IService/Public/IRedisConcurrentProcessService.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Domain.IService.Public +{ + public interface IRedisConcurrentProcessService + { + bool CanAccessMethod(string cacheKey); + + bool GetRedisKeyValue(string cacheKey); + + void UpdateAccessStatus(string cacheKey, bool canAccess); + } +} diff --git a/src/BarCode.Web.Domain/IService/Public/ISingleDataService.cs b/src/BarCode.Web.Domain/IService/Public/ISingleDataService.cs new file mode 100644 index 0000000..27adcdb --- /dev/null +++ b/src/BarCode.Web.Domain/IService/Public/ISingleDataService.cs @@ -0,0 +1,128 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using BarCode.Web.Domain.Values.Single; + +namespace BarCode.Web.Domain.IService.Public +{ + /// + /// 单点数据返回服务接口 + /// + public interface ISingleDataService + { + /// + /// 获取单点数据:根据方法名和公司ID + /// + /// + /// + /// + /// + string GetSingleData(SingleAction action, int companyId, int id); + + /// + /// 获取单点数据:根据方法名和公司ID + /// + /// + /// + /// + /// + decimal GetSingleDataNumber(SingleAction action, int companyId, int id); + /// + /// 获取单点数据:根据方法名和公司ID + /// + /// + /// + /// + /// + string GetSingleDataCode(SingleAction action, int companyId, int id); + + /// + /// 获取单点数据:根据方法名和公司ID + /// + /// + /// + /// + /// 加上ID防止编码重复 + /// + string GetSingleData(SingleAction action, int companyId, string code); + /// + /// 根据名字模糊匹配 + /// + /// + /// + /// + /// + List GetIdsBySingleName(SingleAction action, int companyId, string name); + + + /// + /// 获取单点数据集合:泛型-同步 + /// + /// + /// + /// + /// + List GetSingleData(SingleAction action, int companyId) where T : class; + + /// + /// 获取单点数据集合:泛型-异步 + /// + /// + /// + /// + /// + Task> GetSingleDataAsync(SingleAction action, int companyId) where T : class; + + /// + /// 获取单点数据集合:泛型-异步-无缓存 + /// + /// + /// + /// + /// + Task> GetSingleDataNoCacheAsync(SingleAction action, int companyId) where T : class; + + /// + /// 单点数据:可对接全部接口 + /// + /// 返回对象 + /// 请求对象 + /// 方法名称 + /// 请求对象 + /// 方法名称 + /// 控制器名称 + /// + Task GetSingleData(X dto, Y action, SingleControllerType type = SingleControllerType.Single) where T : class; + + /// + /// 单点数据:可对接全部接口-无缓存 + /// + /// + /// + /// + /// + /// + /// + /// + Task GetSingleDataNoCache(X dto, Y action, SingleControllerType type = SingleControllerType.Single) where T : class; + + /// + /// 获取单点数据:请求对象和接口方法名 + /// + /// + /// + /// + /// + /// + Task GetSysConfigData(X dto, SysConfigAction action); + + /// + /// 获取客户仓库 + /// + /// + /// + /// + string GetCustomerStock(int companyId, string customerStockCode); + } +} diff --git a/src/BarCode.Web.Domain/IService/Public/IWmsService.cs b/src/BarCode.Web.Domain/IService/Public/IWmsService.cs new file mode 100644 index 0000000..596419b --- /dev/null +++ b/src/BarCode.Web.Domain/IService/Public/IWmsService.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using BarCode.Web.Core.Dto; +using BarCode.Web.Core.Internal.Results; + +namespace BarCode.Web.Domain.IService.Public +{ + /// + /// wms重置箱信息 + /// + public interface IWmsService + { + /// + /// 重置wms箱信息 + /// + /// + /// + Task>> Restart(List boxBillNos); + } +} diff --git a/src/BarCode.Web.Domain/Infrastructure/IAllFielRepositories.cs b/src/BarCode.Web.Domain/Infrastructure/IAllFielRepositories.cs new file mode 100644 index 0000000..ba81166 --- /dev/null +++ b/src/BarCode.Web.Domain/Infrastructure/IAllFielRepositories.cs @@ -0,0 +1,28 @@ + +using BarCode.Web.Core.Dto.Login; +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Domain.Infrastructure +{ + public interface IAllFielRepositories + { + /// + /// 全字段导出接口 + /// + /// + /// + //Task<(object obj, int total)> GetListAllField(Request dto, int companyId); + + /// + /// 列表字段导出接口 + /// + /// + /// + /// + Task<(object obj, int total)> GetListField(Request dto, LoginInDto loginInfo); + } +} diff --git a/src/BarCode.Web.Domain/Infrastructure/IBasicsRepositories.cs b/src/BarCode.Web.Domain/Infrastructure/IBasicsRepositories.cs new file mode 100644 index 0000000..e235aca --- /dev/null +++ b/src/BarCode.Web.Domain/Infrastructure/IBasicsRepositories.cs @@ -0,0 +1,93 @@ +using Microsoft.EntityFrameworkCore.Storage; +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using BarCode.Web.Core.Dto.SingleData; + +namespace BarCode.Web.Domain.Infrastructure +{ + /// + /// 基础数据 + /// + public interface IBasicsRepositories + { + /// + /// 根据用户精确搜索用户 + /// + /// + /// + Task> GetUserIdsAsync(string name, int companyId); + /// + /// 获取所有人员-根据主体 + /// + /// + /// + Task> GetStaffListAsync(int CompanyId); + /// + /// 根据仓库获取子仓库 + /// + /// 仓库id + /// + Task> GetSubUcStockAsync(int stockId); + + /// + /// 获取仓位:根据name模糊,和系统code和公司 + /// + /// + /// + /// + /// + Task> GetSubUcStockAsync(string systemCode, string name, int companyId); + + /// + /// 获取仓位详情:根据仓位ID和公司ID + /// + /// + /// + /// + Task GetSubUcStockAsync(int id, int companyId); + + /// + /// 获取仓位集合:根据仓位ID集合和公司ID + /// + /// + /// + /// + Task> GetSubUcStockAsync(List ids, int companyId); + + /// + /// 获取仓位详情:根据仓位ID和公司ID + /// + /// + /// + /// + Task GetSubUcStockAsync(string code, int companyId); + + /// + /// 获取仓位集合:根据仓位编码集合和公司ID + /// + /// + /// + /// + Task> GetSubUcStockAsync(List codes, int companyId); + + /// + /// 获取仓库 + /// + /// + Task> GetUcStockAsync(string systemCode,string name, int companyId); + + /// + /// 获取事务 用来处理即时库存 + /// + /// + IDbContextTransaction GetTransaction(); + + /// + /// 获取事务 用来处理即时库存 + /// + /// + bool CommitTransaction(bool isRollback, IDbContextTransaction transaction); + } +} diff --git a/src/BarCode.Web.Domain/Infrastructure/IBoxMarkRepositories.cs b/src/BarCode.Web.Domain/Infrastructure/IBoxMarkRepositories.cs new file mode 100644 index 0000000..7a367ff --- /dev/null +++ b/src/BarCode.Web.Domain/Infrastructure/IBoxMarkRepositories.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using BarCode.Web.Core.Dto; +using BarCode.Web.Core.Dto.Login; +using BarCode.Web.Domain.Entitys; + +namespace BarCode.Web.Domain.Infrastructure +{ + /// + /// 箱唛-仓储接口 + /// + public interface IBoxMarkRepositories + { + /// + /// 列表分页 + /// + /// + /// + /// + Task<(List list, int total)> GetPagedList(BoxMarkQueryRequest dto, LoginInDto loginInfo); + + /// + /// 添加 + /// + /// + /// + /// + Task Add(BoxMark entity, bool isTransaction = true); + + /// + /// 详情-根据最新的ID + /// + /// + Task GetBy(); + + /// + /// 列表-详情信息列表 + /// + /// + /// + /// + Task> GetListInfoBy(int id, int companyId); + + /// + /// 获取最新的编号实体 + /// + /// + Task GetLastBillNo(); + + /// + /// 批量删除 + /// + /// + /// + /// + Task DeleteRange(List ids, bool isTransaction = true); + } +} diff --git a/src/BarCode.Web.Domain/Infrastructure/IBoxRepositories.cs b/src/BarCode.Web.Domain/Infrastructure/IBoxRepositories.cs new file mode 100644 index 0000000..2f39fb2 --- /dev/null +++ b/src/BarCode.Web.Domain/Infrastructure/IBoxRepositories.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using BarCode.Web.Core.Dto; +using BarCode.Web.Core.Dto.Box; +using BarCode.Web.Core.Dto.Login; +using BarCode.Web.Core.Dto.SerialNumbers; +using BarCode.Web.Domain.Entitys; + +namespace BarCode.Web.Domain.Infrastructure +{ + /// + /// 老ops箱信息 + /// + public interface IBoxRepositories + { + /// + /// 获取列表 + /// + /// + /// + /// + Task<(List list, int total)> GetListAsync(BoxQueryRequest dto, LoginInDto loginInfo); + Task Get(int id); + Task GetByNo(string billNo); + //根据箱号搜索 用来比对确定是否箱号信息是否存在 + Task> GetByNos(List billNos); + //编辑 + Task Edit(Box entity, bool isTransaction = true); + //批量修改 + Task EditEntityList(List entitys, bool isTransaction = true); + /// + /// 批量添加 + /// + /// + /// + /// + Task AddRange(List entitys, bool isTransaction = true); + /// 查询实体集合 + Task> GetEntityList(List ids); + + Task> GetEntityListByNos(List billNos); + /// 查询实体集合 + Task<(List, int tota)> GetEntityByWmsList(WmsBoxRequest dto); + } +} diff --git a/src/BarCode.Web.Domain/Infrastructure/ICenerateDataRepositories.cs b/src/BarCode.Web.Domain/Infrastructure/ICenerateDataRepositories.cs new file mode 100644 index 0000000..3590388 --- /dev/null +++ b/src/BarCode.Web.Domain/Infrastructure/ICenerateDataRepositories.cs @@ -0,0 +1,23 @@ +using BarCode.Web.Domain.Entitys; +using BarCode.Web.Domain.Values; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Domain.Infrastructure +{ + /// + /// 生成数据管理 + /// + public interface ICenerateDataRepositories + { + ///获取最新一次更新时间 + Task Get(CenerateDataType type); + ///定时任务执行后更新时间 + Task Edit(CenerateData entity, bool isTransaction = true); + ///定时任务执行后创建 + Task Add(CenerateData entity, bool isTransaction = true); + } +} diff --git a/src/BarCode.Web.Domain/Infrastructure/IFileDownManagerRepositories.cs b/src/BarCode.Web.Domain/Infrastructure/IFileDownManagerRepositories.cs new file mode 100644 index 0000000..f221a34 --- /dev/null +++ b/src/BarCode.Web.Domain/Infrastructure/IFileDownManagerRepositories.cs @@ -0,0 +1,32 @@ + +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using BarCode.Web.Core.Dto; +using BarCode.Web.Core.Dto.Login; +using BarCode.Web.Domain.Entitys; + +namespace BarCode.Web.Domain.Infrastructure +{ + public interface IFileDownManagerRepositories + { + /// + /// 保存 + /// + /// + /// + Task Add(FileDownManager entity); + /// + /// 编辑 + /// + /// + /// + Task Edit(FileDownManager entity); + /// + /// 获取销售列表 + /// + /// + Task GetList(FileDownManagerRequest dto, LoginInDto loginInfo); + } +} diff --git a/src/BarCode.Web.Domain/Infrastructure/ILoginRepositories.cs b/src/BarCode.Web.Domain/Infrastructure/ILoginRepositories.cs new file mode 100644 index 0000000..272367c --- /dev/null +++ b/src/BarCode.Web.Domain/Infrastructure/ILoginRepositories.cs @@ -0,0 +1,24 @@ +using BarCode.Web.Core.Dto.Login; +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Domain.Infrastructure +{ + public interface ILoginRepositories + { + /// + /// 公司Id + /// + int CompanyId { get; set; } + + /// + /// 员工ID + /// + int StaffId { get; set; } + /// + /// 登录用户信息 + /// + LoginInDto loginInfo { get; set; } + } +} diff --git a/src/BarCode.Web.Domain/Infrastructure/IMaterialsRepositories.cs b/src/BarCode.Web.Domain/Infrastructure/IMaterialsRepositories.cs new file mode 100644 index 0000000..f3eba04 --- /dev/null +++ b/src/BarCode.Web.Domain/Infrastructure/IMaterialsRepositories.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using BarCode.Web.Domain.Entitys; + +namespace BarCode.Web.Domain.Infrastructure +{ + /// + /// 物料仓储接口 + /// + public interface IMaterialsRepositories + { + /// + /// 物料添加 + /// + /// + /// + /// + Task AddRange(List entitys, bool isTransaction = true); + + /// + /// 列表 + /// + /// + Task> GetEntityList(int? orgId = null); + + /// + /// 物料 + /// + /// + /// + Task Get(int mid); + + /// + /// 物料 + /// + /// + /// + /// + Task Get(string code, int orgId); + + /// + /// + /// + /// + Task> GetAllNumbers(); + + /// + /// 列表 + /// + /// + /// + /// + Task> GetEntityList(List materNumbers, bool isBatchManage); + + /// + /// 列表(获取所有没有id32进制的物料) + /// + /// + Task> GetEntityListByNoBar(); + + /// + /// 修改物料 + /// + /// + /// + /// + Task UpdateRange(List entitys, bool isTransaction = true); + /// + /// 集合 + /// + /// + /// + Task> GetEntityList(List materNumbers); + } +} diff --git a/src/BarCode.Web.Domain/Infrastructure/ISGenerateRecordRepositories.cs b/src/BarCode.Web.Domain/Infrastructure/ISGenerateRecordRepositories.cs new file mode 100644 index 0000000..5fb4e19 --- /dev/null +++ b/src/BarCode.Web.Domain/Infrastructure/ISGenerateRecordRepositories.cs @@ -0,0 +1,34 @@ +using BarCode.Web.Core.Dto.Login; +using BarCode.Web.Core.Dto.SerialNumbers; +using BarCode.Web.Domain.Entitys; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Domain.Infrastructure +{ + public interface ISGenerateRecordRepositories + { + // 获取列表 + Task<(List list, int total)> GetListAsync(SGenerateRecordQueryRequest dto, LoginInDto loginInfo); + // 新增 + Task Add(SerialNumberGenerateRecord entity, bool isTransaction = true); + //编辑 + Task Edit(SerialNumberGenerateRecord entity, bool isTransaction = true); + /// + /// 批量添加 + /// + /// + /// + /// + Task AddRange(List entitys, bool isTransaction = true); + /// 修改实体集合 + Task EditEntityList(List entitys, bool isTransaction = true); + /// 查询实体集合 + Task> GetEntityList(List ids); + /// 查询实体 + Task GetEntity(int id); + } +} diff --git a/src/BarCode.Web.Domain/Infrastructure/ISecurityGenerateRecordRepositories.cs b/src/BarCode.Web.Domain/Infrastructure/ISecurityGenerateRecordRepositories.cs new file mode 100644 index 0000000..a5ef688 --- /dev/null +++ b/src/BarCode.Web.Domain/Infrastructure/ISecurityGenerateRecordRepositories.cs @@ -0,0 +1,35 @@ +using BarCode.Web.Core.Dto.Login; +using BarCode.Web.Core.Dto.SecurityNumbers; +using BarCode.Web.Core.Dto.SerialNumbers; +using BarCode.Web.Domain.Entitys; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Domain.Infrastructure +{ + /// + /// 防伪码生成记录 + /// + public interface ISecurityGenerateRecordRepositories + { + /// 获取列表 + Task<(List list, int total)> GetListAsync(SecurityGenerateRecordQueryRequest dto, LoginInDto loginInfo); + /// 新增 + Task Add(SecurityNumberGenerateRecord entity, bool isTransaction = true); + ///编辑 + Task Edit(SecurityNumberGenerateRecord entity, bool isTransaction = true); + /// 批量添加 + Task AddRange(List entitys, bool isTransaction = true); + /// 修改实体集合 + Task EditEntityList(List entitys, bool isTransaction = true); + /// 查询实体集合 + Task> GetEntityList(List ids); + /// 查询实体 + Task GetEntity(int id); + /// 获取当天生成记录条数 + Task GetGenerateRecordDayCount(); + } +} diff --git a/src/BarCode.Web.Domain/Infrastructure/ISecurityNumbersRepositories.cs b/src/BarCode.Web.Domain/Infrastructure/ISecurityNumbersRepositories.cs new file mode 100644 index 0000000..f505b4a --- /dev/null +++ b/src/BarCode.Web.Domain/Infrastructure/ISecurityNumbersRepositories.cs @@ -0,0 +1,43 @@ +using BarCode.Web.Core.Dto.Login; +using BarCode.Web.Core.Dto.SecurityNumbers; +using BarCode.Web.Domain.Entitys; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Domain.Infrastructure +{ + /// + /// 防伪码 + /// + public interface ISecurityNumbersRepositories + { + /// 获取列表 + Task<(List list, int total)> GetListAsync(SecurityNumberQueryRequest dto, LoginInDto loginInfo); + + /// 批量添加 + Task AddRange(List entitys, bool isTransaction = true); + /// 修改实体集合 + Task EditEntityList(List entitys, bool isTransaction = true); + /// 查询实体集合 + Task> GetEntityList(List SecurityNumbers); + /// 根据生成记录id查询序列码 + Task> GetEntityListByGRIds(List gRIds); + /// 根据生成记录id查询序列码 + Task> GetEntityListByGRId(int gRId); + /// 查询实体 + Task GetEntity(string securityNumbers); + /// 修改实体 + Task Edit(SecurityNumbers entity, bool isTransaction = true); + + /// + /// 下载反写 执行sql语句 + /// + /// + /// + Task DownLoad(List ids, bool isTransaction = true); + + } +} diff --git a/src/BarCode.Web.Domain/Infrastructure/ISerialNumbersRepositories.cs b/src/BarCode.Web.Domain/Infrastructure/ISerialNumbersRepositories.cs new file mode 100644 index 0000000..dc8c89b --- /dev/null +++ b/src/BarCode.Web.Domain/Infrastructure/ISerialNumbersRepositories.cs @@ -0,0 +1,62 @@ +using BarCode.Web.Core.Dto.Login; +using BarCode.Web.Core.Dto.SerialNumbers; +using BarCode.Web.Domain.Entitys; +using Microsoft.AspNetCore.Mvc; +using Org.BouncyCastle.Bcpg.OpenPgp; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Domain.Infrastructure +{ + /// + /// 序列码 + /// + public interface ISerialNumbersRepositories + { + /// + /// 获取列表 + /// + /// + /// + /// + Task<(List list, int total)> GetListAsync(SerialNumberQueryRequest dto, LoginInDto loginInfo); + /// + /// 批量添加 + /// + /// + /// + /// + Task AddRange(List entitys, bool isTransaction = true); + /// 修改实体集合 + Task EditEntityList(List entitys, bool isTransaction = true); + /// 查询实体集合 + Task> GetEntityList(List serialNumbers); + /// 查询实体集合 + Task> GetEntityListContainNumber(List serialNumbers); + /// 根据箱Id查询序列码 + Task> GetEntityListByBoxIds(List boxIds); + /// 根据生成记录id查询序列码 + Task> GetEntityListBySuitNumber(string suitNumber); + /// 根据套装码查询序列码 + Task> GetEntityListByGRIds(List gRIds); + /// 根据生成记录id查询序列码 + Task> GetEntityListByGRId(int gRId); + /// 根据箱号查询序列码 + Task<(List list, int total)> GetEntityListByBoxId(SerialNumberByBoxIdQueryRequest dto); + /// 查询实体 + Task GetEntity(string serialNumber, string orgCode, LoginInDto loginInfo); + /// 查询实体 + Task> GetEntityList(string serialNumber, string orgCode, LoginInDto loginInfo); + /// WMS查询实体 + Task GetEntityWms(string serialNumbers); + /// + /// 根据序列号搜索信息 + /// + /// + /// + Task GetExternal(string serialNumber); + } +} diff --git a/src/BarCode.Web.Domain/Infrastructure/ITransactionRepositories.cs b/src/BarCode.Web.Domain/Infrastructure/ITransactionRepositories.cs new file mode 100644 index 0000000..1c78776 --- /dev/null +++ b/src/BarCode.Web.Domain/Infrastructure/ITransactionRepositories.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore.Storage; +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Domain.Infrastructure +{ + public interface ITransactionRepositories + { + /// + /// 获取事务 用来处理即时库存 + /// + /// + IDbContextTransaction GetTransaction(); + + /// + /// 获取事务 用来处理即时库存 + /// + /// + bool CommitTransaction(bool isRollback, IDbContextTransaction transaction); + } +} diff --git a/src/BarCode.Web.Domain/Mappers/AppMapper.cs b/src/BarCode.Web.Domain/Mappers/AppMapper.cs new file mode 100644 index 0000000..d88adc9 --- /dev/null +++ b/src/BarCode.Web.Domain/Mappers/AppMapper.cs @@ -0,0 +1,74 @@ +using AutoMapper; +using BarCode.Web.Core.Dto; +using BarCode.Web.Core.Dto.Login; +using BarCode.Web.Core.Dto.Login.Temp; +using BarCode.Web.Core.Dto.Login.Temp.v3; +using BarCode.Web.Core.Help; +using System; +using System.Collections.Generic; +using System.Text; +using BarCode.Web.Domain.Entitys; + +namespace BarCode.Web.Domain.Mappers +{ + /// + /// mapper映射 + /// + public class AppMapper : Profile + { + public AppMapper() + { + //pc端登录的相关dto + CreateMap() + .ForMember(x => x.Email, ops => ops.MapFrom(x => x.email)) + .ForMember(x => x.Avatar, ops => ops.MapFrom(x => x.avatar)) + .ForMember(x => x.RoleId, ops => ops.MapFrom(x => x.role_id)) + .ForMember(x => x.CreatedAt, ops => ops.MapFrom(x => x.created_at)) + .ForMember(x => x.SigninAt, ops => ops.MapFrom(x => x.signin_at)) + .ForMember(x => x.UpdatedAt, ops => ops.MapFrom(x => x.updated_at)) + .ReverseMap(); + + CreateMap() + .ForMember(x => x.Id, ops => ops.MapFrom(x => x.id)) + .ForMember(x => x.DeptCode, ops => ops.MapFrom(x => x.dept_code)) + .ForMember(x => x.DeptName, ops => ops.MapFrom(x => x.dept_name)) + .ForMember(x => x.ManagerId, ops => ops.MapFrom(x => x.manager)).ReverseMap(); + + //app端和小程序端登录的相关dto + + + CreateMap() + .ForMember(x => x.Id, ops => ops.MapFrom(x => x.dept_id)) + .ForMember(x => x.Name, ops => ops.MapFrom(x => x.dept_name)) + .ForMember(x => x.Code, ops => ops.MapFrom(x => x.dept_code)).ReverseMap(); + CreateMap() + .ForMember(x => x.Id, ops => ops.MapFrom(x => x.company_id)) + .ForMember(x => x.Name, ops => ops.MapFrom(x => x.company_name)) + .ForMember(x => x.Code, ops => ops.MapFrom(x => x.company_code)).ReverseMap(); + CreateMap() + .ForMember(x => x.Id, ops => ops.MapFrom(x => x.role_id)) + .ForMember(x => x.Name, ops => ops.MapFrom(x => x.role_name)) + .ForMember(x => x.Code, ops => ops.MapFrom(x => x.role_code)).ReverseMap(); + + CreateMap() + .ForMember(x => x.Id, ops => ops.MapFrom(x => x.id)) + .ForMember(x => x.DingtalkUid, ops => ops.MapFrom(x => x.dingtalk_uid)) + .ForMember(x => x.DingtalkUnionid, ops => ops.MapFrom(x => x.dingtalk_unionid)) + .ForMember(x => x.Nickname, ops => ops.MapFrom(x => x.nickname)) + .ForMember(x => x.Realname, ops => ops.MapFrom(x => x.realname)) + .ForMember(x => x.Mobile, ops => ops.MapFrom(x => x.mobile)) + .ForMember(x => x.Identity, ops => ops.MapFrom(x => x.identity)) + .ForMember(x => x.Company, ops => ops.MapFrom(x => x.company)) + .ForMember(x => x.Orgs, opt => opt.Ignore()) + .ForMember(x => x.Depts, opt => opt.Ignore()) + .ForMember(x => x.Roles, opt => opt.Ignore()).ReverseMap(); + + + CreateMap() + .ForMember(x => x.Date, ops => ops.MapFrom(x => x.Date.DateToStringSeconds())) + //.ForMember(x => x.StatusKey, ops => ops.MapFrom(x => (int)x.Status)) + // .ForMember(x => x.Status, ops => ops.MapFrom(x => x.Status.GetRemark())) + .ForMember(x => x.Type, ops => ops.MapFrom(x => (int)x.Type)); + } + } +} diff --git a/src/BarCode.Web.Domain/Mappers/BoxMapper.cs b/src/BarCode.Web.Domain/Mappers/BoxMapper.cs new file mode 100644 index 0000000..04fe24b --- /dev/null +++ b/src/BarCode.Web.Domain/Mappers/BoxMapper.cs @@ -0,0 +1,36 @@ +using AutoMapper; +using BarCode.Web.Core; +using BarCode.Web.Core.Dto.Box; +using BarCode.Web.Core.Help; +using BarCode.Web.Domain.Entitys; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Domain.Mappers +{ + /// + /// 箱mapper映射 + /// + public class BoxMapper: Profile + { + /// + /// 箱mapper映射 + /// + public BoxMapper() + { + CreateMap().ReverseMap(); + CreateMap().ReverseMap(); + + CreateMap() + .ForMember(x => x.Status, ops => ops.MapFrom(x => x.Status.GetRemark())) + .ForMember(x => x.CreateTime, ops => ops.MapFrom(x => x.CreateTime.DateToStringSeconds())) + .ForMember(x => x.PrintTime, ops => ops.MapFrom(x => x.PrintTime.DateToStringSeconds())) + .ForMember(x => x.CartonEndTime, ops => ops.MapFrom(x => x.CartonEndTime.DateToStringSeconds())) + .ForMember(x => x.CartonBeginTime, ops => ops.MapFrom(x => x.CartonBeginTime.DateToStringSeconds())); + CreateMap(); + } + } +} diff --git a/src/BarCode.Web.Domain/Mappers/BoxMarkMapper.cs b/src/BarCode.Web.Domain/Mappers/BoxMarkMapper.cs new file mode 100644 index 0000000..61d6e85 --- /dev/null +++ b/src/BarCode.Web.Domain/Mappers/BoxMarkMapper.cs @@ -0,0 +1,20 @@ +using AutoMapper; +using System; +using System.Collections.Generic; +using System.Text; +using BarCode.Web.Core.Dto; +using BarCode.Web.Domain.Entitys; + +namespace BarCode.Web.Domain.Mappers +{ + public class BoxMarkMapper : Profile + { + public BoxMarkMapper() + { + CreateMap(); + + CreateMap() + .ForMember(x => x.BillNos, opt => opt.Ignore()); + } + } +} diff --git a/src/BarCode.Web.Domain/Mappers/MapperList.cs b/src/BarCode.Web.Domain/Mappers/MapperList.cs new file mode 100644 index 0000000..dbc6e2c --- /dev/null +++ b/src/BarCode.Web.Domain/Mappers/MapperList.cs @@ -0,0 +1,98 @@ +using AutoMapper; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using BarCode.Web.Core; + +namespace BarCode.Web.Domain.Mappers +{ + /// + /// 集合映射 + /// + public static class MapperList + { + /// + /// 映射实体里 集合属性 + /// + /// + /// + /// + /// + /// + /// + public static List
ToMapList(this IMapper mapper, List sourcList, List
destinationList) + where ST : EntityBase + where DT : EntityBase + { + for (int i = 0; i < destinationList.Count; i++) + { + int id = destinationList[i].Id; + var detail = sourcList.FirstOrDefault(f => f.Id == id); + if (detail == null) + { + destinationList.Remove(destinationList[i]); + i--;//在列表移除掉一条数据后 必须把index回拨一位 因为数据在移除一条后会调整下标 + } + } + + foreach (var st in sourcList) + { + if (st.Id == 0) + destinationList.Add(mapper.Map
(st)); + else + { + var detail = destinationList.FirstOrDefault(f => f.Id == st.Id); + + if (detail != null) + mapper.Map(st, detail); + //如果在目标数据里没找到这条id的数据 则不作处理 + } + } + + return destinationList; + } + + + /// + /// 映射实体里 集合属性 + /// + /// + /// + /// + /// + /// + /// + public static List
ToMapLongList(this IMapper mapper, List sourcList, List
destinationList) + where ST : EntityLongBase + where DT : EntityLongBase + { + for (int i = 0; i < destinationList.Count; i++) + { + long id = destinationList[i].Id; + var detail = sourcList.FirstOrDefault(f => f.Id == id); + if (detail == null) + { + destinationList.Remove(destinationList[i]); + i--;//在列表移除掉一条数据后 必须把index回拨一位 因为数据在移除一条后会调整下标 + } + } + + foreach (var st in sourcList) + { + if (st.Id == 0) + destinationList.Add(mapper.Map
(st)); + else + { + var detail = destinationList.FirstOrDefault(f => f.Id == st.Id); + + if (detail != null) + mapper.Map(st, detail); + //如果在目标数据里没找到这条id的数据 则不作处理 + } + } + + return destinationList; + } + } +} diff --git a/src/BarCode.Web.Domain/Mappers/MaterialMapper.cs b/src/BarCode.Web.Domain/Mappers/MaterialMapper.cs new file mode 100644 index 0000000..e45f918 --- /dev/null +++ b/src/BarCode.Web.Domain/Mappers/MaterialMapper.cs @@ -0,0 +1,21 @@ +using AutoMapper; +using System; +using System.Collections.Generic; +using System.Text; +using BarCode.Web.Core.Dto.Erp; +using BarCode.Web.Domain.Entitys; + +namespace BarCode.Web.Domain.Mappers +{ + public class MaterialMapper : Profile + { + public MaterialMapper() + { + CreateMap() + .ForMember(x => x.IdConvertBar, ops => ops.MapFrom(x => x.IdConvertBar.Trim())) + .ReverseMap(); + + CreateMap(); + } + } +} diff --git a/src/BarCode.Web.Domain/Mappers/SecurityNumberMapper.cs b/src/BarCode.Web.Domain/Mappers/SecurityNumberMapper.cs new file mode 100644 index 0000000..802574f --- /dev/null +++ b/src/BarCode.Web.Domain/Mappers/SecurityNumberMapper.cs @@ -0,0 +1,20 @@ +using AutoMapper; +using BarCode.Web.Domain.Entitys; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Domain.Mappers +{ + public class SecurityNumberMapper: Profile + { + public SecurityNumberMapper() + { + CreateMap().ReverseMap(); + + CreateMap().ReverseMap(); + } + } +} diff --git a/src/BarCode.Web.Domain/Mappers/SerialNumberMapper.cs b/src/BarCode.Web.Domain/Mappers/SerialNumberMapper.cs new file mode 100644 index 0000000..4e08e05 --- /dev/null +++ b/src/BarCode.Web.Domain/Mappers/SerialNumberMapper.cs @@ -0,0 +1,21 @@ +using AutoMapper; +using BarCode.Web.Core.Dto.Erp; +using BarCode.Web.Domain.Entitys; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Domain.Mappers +{ + public class SerialNumberMapper : Profile + { + public SerialNumberMapper() + { + CreateMap().ReverseMap(); + + CreateMap().ReverseMap(); + } + } +} diff --git a/src/BarCode.Web.Domain/Options/AppOptions.cs b/src/BarCode.Web.Domain/Options/AppOptions.cs new file mode 100644 index 0000000..3b1430b --- /dev/null +++ b/src/BarCode.Web.Domain/Options/AppOptions.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Domain.Options +{ + public class AppOptions + { + /// + /// 数据库 + /// + public string DBConnectionString { get; set; } + + /// + /// redis + /// + public string RedisConnectionString { get; set; } + + /// + /// 单点数据请求地址-后端使用接口地址 + /// + public string SingleBaseUrl { get; set; } + + /// + /// redis数据目录 + /// + public string RedisDirectory { get; set; } + + /// + /// 数据库类型 + /// + public string DBType { get; set; } + + /// + /// 是否允许缓存 + /// + public bool AllowCache { get; set; } + + /// + /// 公司ID + /// + public int CompanyId { get; set; } + } +} diff --git a/src/BarCode.Web.Domain/Options/EmailOptions.cs b/src/BarCode.Web.Domain/Options/EmailOptions.cs new file mode 100644 index 0000000..f2eff52 --- /dev/null +++ b/src/BarCode.Web.Domain/Options/EmailOptions.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Domain.Options +{ + /// + /// 邮箱 + /// + public class EmailOptions + { + /// + /// SMTP 服务器地址 + /// + public string SmtpServer { get; set; } + + /// + /// SMTP 服务器端口号 + /// + public int SmtpPort { get; set; } + + /// + /// 名称 + /// + public string SenderName { get; set; } + + /// + /// 主题 + /// + public string SendTitle { get; set; } + + /// + /// 发件人邮箱地址 + /// + public string SenderEmail { get; set; } + + /// + /// 发件人邮箱密码 + /// + public string SenderEmailPwd { get; set; } + } +} diff --git a/src/BarCode.Web.Domain/Options/ErpOptions.cs b/src/BarCode.Web.Domain/Options/ErpOptions.cs new file mode 100644 index 0000000..72afb9e --- /dev/null +++ b/src/BarCode.Web.Domain/Options/ErpOptions.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Domain.Options +{ + /// + /// erp相关配置文件 + /// + public class ErpOptions + { + /// + /// erp-请求地址 + /// + public string EndpointAddress { get; set; } + + /// + /// 账号 + /// + public string UserName { get; set; } + + /// + /// 密码 + /// + public string Password { get; set; } + + /// + /// erp-Id + /// + public string ErpId { get; set; } + public readonly string cache_materail_all_key = "erp_materials_list_all"; + public readonly string cache_materail_key = "erp_materials_list"; + public readonly string cache_org_key = "erp_org_list"; + public readonly string cache_supplier_key = "erp_supplier_list"; + public readonly string cache_customer_key = "erp_customer_list"; + public readonly string cache_stock_key = "erp_stock_list"; + public readonly string cache_substock_key = "erp_substock_list"; + } +} diff --git a/src/BarCode.Web.Domain/Options/QiniuOptions.cs b/src/BarCode.Web.Domain/Options/QiniuOptions.cs new file mode 100644 index 0000000..c7b07e1 --- /dev/null +++ b/src/BarCode.Web.Domain/Options/QiniuOptions.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Domain.Options +{ + /// + /// 七牛云 配置 + /// + public class QiniuOptions + { + /// + /// 访问key + /// + public string AccessKey { get; set; } + /// + /// 秘钥 + /// + public string SecretKey { get; set; } + /// + /// 区块文件夹 + /// + public string Bucket { get; set; } + /// + /// 访问域名 + /// + public string Url { get; set; } + //导出数据一页条数 + public int PageSize { get; set; } = 50000; + } +} diff --git a/src/BarCode.Web.Domain/Options/QuartzJobOptions.cs b/src/BarCode.Web.Domain/Options/QuartzJobOptions.cs new file mode 100644 index 0000000..1b8dd2e --- /dev/null +++ b/src/BarCode.Web.Domain/Options/QuartzJobOptions.cs @@ -0,0 +1,155 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Domain.Options +{ + /// + /// Quartz定时任务-配置项 + /// + public class QuartzJobOptions + { + /// + /// 存储类型:键 + /// + public string JobStoreTypeKey { get; set; } + + /// + /// 存储类型:值 + /// + public string JobStoreTypeValue { get; set; } + + /// + /// 数据库驱动类型-这里是mysql:键 + /// + public string JobStoreDriverDelegateTypeKey { get; set; } + + /// + /// 数据库驱动类型-这里是mysql:值 + /// + public string JobStoreDriverDelegateTypeValue { get; set; } + + /// + /// 数据库表名前缀:键 + /// + public string JobStoreTablePrefixKey { get; set; } + + /// + /// 数据库表名前缀:值 + /// + public string JobStoreTablePrefixValue { get; set; } + + /// + /// 数据源的名称:键 + /// + public string JobStoreDataSourceKey { get; set; } + + /// + /// 数据源的名称:值 + /// + public string JobStoreDataSourceValue { get; set; } + + /// + /// 连接字符串:键 + /// + public string JobStoreConnectionStringKey { get; set; } + + /// + /// 连接字符串:值 + /// + public string JobStoreConnectionStringValue { get; set; } + + /// + /// mysql提供器:键 + /// + public string JobStoreProviderKey { get; set; } + + /// + /// mysql提供器:值 + /// + public string JobStoreProviderValue { get; set; } + + + /// + /// 几点后开始执行 + /// + public List JobStartHour { get; set; } + + /// + /// 几分钟后开始执行 + /// + public List JobStartMinute { get; set; } + + /// + /// 执行Cron表达式:可以是几小时or几分钟or几秒钟or几天or几周 + /// + public string JobStartExpre { get; set; } + + /// + /// + /// + public string JobStartExpreAmount { get; set; } + + /// + /// 发送通知执行cron表达式:每天12,16,20整点发送 + /// + public string JobStartExpreSend { get; set; } + + /// + /// 同步新物料执行cron表达式:每天23:30整点同步 + /// + public string JobStartExpreMaterial { get; set; } + + /// + /// 同步新物料执行cron表达式:每天0:01执行 + /// + public string JobStartExpreCenerateData { get; set; } + + /// + /// 是否启用集群:键 + /// + public string JobStoreClusteredKey { get; set; } + + /// + /// 是否启用集群:值 + /// + public string JobStoreClusteredValue { get; set; } + + /// + /// 节点都必须有一个唯一ID:键 + /// + public string JobStoreInstanceIdKey { get; set; } + + /// + /// 节点都必须有一个唯一ID:值 + /// + public string JobStoreInstanceIdValue { get; set; } + + + /// + /// 工作名称:键 + /// + public string QuartzJobKey { get; set; } + + /// + /// 工作名称:值 + /// + public string QuartzJobValue { get; set; } + + /// + /// 工作描述 + /// + public string QuartzJobDescription { get; set; } + + /// + /// 触发器身份认证信息 + /// + public string QuartzTriggerIdentity { get; set; } + + /// + /// 触发器描述 + /// + public string QuartzTriggerDescription { get; set; } + + } +} diff --git a/src/BarCode.Web.Domain/Options/SmsOptions.cs b/src/BarCode.Web.Domain/Options/SmsOptions.cs new file mode 100644 index 0000000..a1d48ec --- /dev/null +++ b/src/BarCode.Web.Domain/Options/SmsOptions.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Domain.Options +{ + /// + /// 短信配置项 + /// + public class SmsOptions + { + /// + /// 访问凭证ID + /// + public string AccessKeyId { get; set; } + + /// + /// 访问秘钥 + /// + public string AccessKeySecret { get; set; } + + /// + /// 短信签名 + /// + public string SignName { get; set; } + + /// + /// 短信模板编号 + /// + public string TemplateCode { get; set; } + } +} diff --git a/src/BarCode.Web.Domain/Options/SoaOptions.cs b/src/BarCode.Web.Domain/Options/SoaOptions.cs new file mode 100644 index 0000000..f19e5cb --- /dev/null +++ b/src/BarCode.Web.Domain/Options/SoaOptions.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Domain.Options +{ + public class SoaOptions + { + /// + /// 单点系统地址 + /// + public string Url { get; set; } + + /// + /// 单点系统地址 + /// + public string Url_V3 { get; set; } + /// + /// admin账号的Id + /// + public List AdminUser { get; set; } = new List(); + /// + /// 应用id + /// + public int ModuleID { get; set; } + + /// + /// AppId + /// + public string AppId { get; set; } + + /// + /// AppSecret + /// + public string AppSecret { get; set; } + + /// + /// 公钥 + /// + public string PublicKey { get; set; } + + /// + /// 私钥 + /// + public string PrivateKey { get; set; } + } +} diff --git a/src/BarCode.Web.Domain/Options/WmsOptions.cs b/src/BarCode.Web.Domain/Options/WmsOptions.cs new file mode 100644 index 0000000..96e4244 --- /dev/null +++ b/src/BarCode.Web.Domain/Options/WmsOptions.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Domain.Options +{ + /// + /// 老ops对接 + /// + public class WmsOptions + { + public string Url { get; set; } + } +} diff --git a/src/BarCode.Web.Domain/QuartzJob/CenerateDataQuartzJob.cs b/src/BarCode.Web.Domain/QuartzJob/CenerateDataQuartzJob.cs new file mode 100644 index 0000000..75c2271 --- /dev/null +++ b/src/BarCode.Web.Domain/QuartzJob/CenerateDataQuartzJob.cs @@ -0,0 +1,48 @@ +using BarCode.Web.Domain.Infrastructure; +using BarCode.Web.Domain.IService; +using BarCode.Web.Domain.Values; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Quartz; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Domain.QuartzJob +{ + /// + /// 自动生成数据维护 凌晨清空 + /// + public class CenerateDataQuartzJob : IJob + { + private readonly ILogger _logger; + private readonly IServiceScopeFactory _serviceScopeFactory; + private readonly ICenerateDataRepositories _cenerateDataRepositories; + + public CenerateDataQuartzJob(ILogger logger, + IServiceScopeFactory serviceScopeFactory, + IMaterialService materialService, + ICenerateDataRepositories cenerateDataRepositories) + { + this._logger = logger; + _serviceScopeFactory = serviceScopeFactory; + _cenerateDataRepositories = cenerateDataRepositories; + } + + /// + /// 执行方法 + /// + /// + /// + public async Task Execute(IJobExecutionContext context) + { + _logger.LogInformation("定时维护自动生成数据"); + //每天凌晨对数据进行清空 + var entity = await _cenerateDataRepositories.Get(CenerateDataType.Serial); + entity.Number = 1; + await _cenerateDataRepositories.Edit(entity); + } + } +} diff --git a/src/BarCode.Web.Domain/QuartzJob/MaterialsBarQuartzJob.cs b/src/BarCode.Web.Domain/QuartzJob/MaterialsBarQuartzJob.cs new file mode 100644 index 0000000..35141a9 --- /dev/null +++ b/src/BarCode.Web.Domain/QuartzJob/MaterialsBarQuartzJob.cs @@ -0,0 +1,39 @@ +using BarCode.Web.Domain.IService; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Quartz; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Domain.QuartzJob +{ + public class MaterialsBarQuartzJob:IJob + { + private readonly ILogger _logger; + private readonly IServiceScopeFactory _serviceScopeFactory; + private readonly IMaterialService _materialService; + + public MaterialsBarQuartzJob(ILogger logger, + IServiceScopeFactory serviceScopeFactory, + IMaterialService materialService) + { + this._logger = logger; + _serviceScopeFactory = serviceScopeFactory; + _materialService = materialService; + } + + /// + /// 执行方法 + /// + /// + /// + public async Task Execute(IJobExecutionContext context) + { + _logger.LogInformation("定时维护物料id32进制"); + await _materialService.SyncBar(); + } + } +} diff --git a/src/BarCode.Web.Domain/QuartzJob/MaterialsQuartzJob.cs b/src/BarCode.Web.Domain/QuartzJob/MaterialsQuartzJob.cs new file mode 100644 index 0000000..bcccab0 --- /dev/null +++ b/src/BarCode.Web.Domain/QuartzJob/MaterialsQuartzJob.cs @@ -0,0 +1,42 @@ +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Quartz; +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using BarCode.Web.Domain.IService; +using Quartz.Logging; + +namespace BarCode.Web.Domain.QuartzJob +{ + /// + /// 物料同步执行定时任务 + /// + public class MaterialsQuartzJob : IJob + { + private readonly ILogger _logger; + private readonly IServiceScopeFactory _serviceScopeFactory; + private readonly IMaterialService _materialService; + + public MaterialsQuartzJob(ILogger logger, + IServiceScopeFactory serviceScopeFactory, + IMaterialService materialService) + { + this._logger = logger; + _serviceScopeFactory = serviceScopeFactory; + _materialService = materialService; + } + + /// + /// 执行方法 + /// + /// + /// + public async Task Execute(IJobExecutionContext context) + { + _logger.LogInformation("定时维护物料数据"); + await _materialService.SyncNewMaterials(); + } + } +} diff --git a/src/BarCode.Web.Domain/Services/BoxMarkService.cs b/src/BarCode.Web.Domain/Services/BoxMarkService.cs new file mode 100644 index 0000000..acc66d5 --- /dev/null +++ b/src/BarCode.Web.Domain/Services/BoxMarkService.cs @@ -0,0 +1,131 @@ +using AutoMapper; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using BarCode.Web.Core.Dto; +using BarCode.Web.Core.Dto.Login; +using BarCode.Web.Core.Internal.Results; +using BarCode.Web.Domain.Entitys; +using BarCode.Web.Domain.Infrastructure; +using BarCode.Web.Domain.IService; +using BarCode.Web.Domain.IService.Public; +using BarCode.Web.Domain.Values; + +namespace BarCode.Web.Domain.Services +{ + /// + /// 箱唛-服务 + /// + public class BoxMarkService : IBoxMarkService + { + private readonly IMapper _mapper; + public readonly IBasicsRepositories _transactionRepositories; + private readonly IBoxMarkRepositories _boxMarkRepositories; + private readonly ILogger _logger; + public BoxMarkService(IMapper mapper, ILogger logger, + IBasicsRepositories transactionRepositories, + IBoxMarkRepositories boxMarkRepositories) + { + _mapper = mapper; + _logger = logger; + _transactionRepositories = transactionRepositories; + _boxMarkRepositories = boxMarkRepositories; + } + + /// + /// 生成 + /// + /// + /// + /// + public async Task> Generate(GenerateBoxMarkDto dto, LoginInDto loginInfo) + { + _logger.LogInformation($"箱唛生成:{JsonConvert.SerializeObject(dto)} 操作人:{loginInfo.UserInfo.UcId + loginInfo.UserInfo.Nickname}"); + string supplierCode = ""; + string orgCode = ""; + if (dto.OrgCode.Substring(0, 1).Equals("s")) + supplierCode = dto.OrgCode.Substring(2, dto.OrgCode.Length - 2); + else + orgCode = dto.OrgCode.Substring(2, dto.OrgCode.Length - 2); + //1.获取最新的箱唛信息 + var billNo_new = await _boxMarkRepositories.GetLastBillNo(); + + //2.dto映射实体 + var entity = new BoxMark(); + entity= _mapper.Map(dto, entity); + entity.Create(loginInfo.UserInfo.UcId); + entity.SupplierCode = supplierCode; + entity.OrgCode = orgCode; + int new_firstBillNo = billNo_new == null ? 0 : billNo_new.FirstBillNo; + int new_lastBillNo = billNo_new == null ? 0 : billNo_new.LastBillNo; + entity.GenerateBillNo(new_firstBillNo, new_lastBillNo); + + //添加 + var model = await _boxMarkRepositories.Add(entity); + if (model==null) + return ResultList.ReFailure(ResultCodes.DateWriteError); + + //返回列表-对应刚刚生成的数据和编号集合 + var list= await _boxMarkRepositories.GetListInfoBy(model.Id, loginInfo.UserInfo.CompanyId); + + if (list != null && list.Count != 0) + { + //处理-总数量 + list.ForEach(x => + { + x.BoxSortCount = this.GetSortCount(x.ProductQty, x.CratingQty); + + }); + } + + return ResultList.ReSuccess(list); + } + + /// + /// 列表分页 + /// + /// + /// + /// + public async Task<(List list, int total)> GetPagedList(BoxMarkQueryRequest dto, LoginInDto loginInfo) + { + var (list, count) = await _boxMarkRepositories.GetPagedList(dto, loginInfo); + + if (list != null && list.Count != 0) + { + list.ForEach(x => + { + x.BoxSortCount = this.GetSortCount(x.ProductQty, x.CratingQty); + }); + } + + return (list, count); + } + + /// + /// 装箱总数 + /// + /// + /// + /// + private int GetSortCount(decimal productQty, decimal cratingQty) + { + //计算要装的箱数量 + var boxCount_tag = productQty / cratingQty; + var boxCount = Convert.ToInt32(boxCount_tag); + //判断是否存在小数点;true表明有尾箱数,false没有尾箱数 + var hasPart = Math.Floor(boxCount_tag) != boxCount_tag; + + //有小数点向上取整 + if (hasPart) + boxCount = Convert.ToInt32(Math.Ceiling(boxCount_tag)); + return boxCount; + } + + + } +} diff --git a/src/BarCode.Web.Domain/Services/BoxService.cs b/src/BarCode.Web.Domain/Services/BoxService.cs new file mode 100644 index 0000000..1a5a0ff --- /dev/null +++ b/src/BarCode.Web.Domain/Services/BoxService.cs @@ -0,0 +1,459 @@ +using BarCode.Web.Core.Dto; +using BarCode.Web.Core.Dto.Box; +using BarCode.Web.Core.Dto.Erp.Org; +using BarCode.Web.Core.Dto.Erp.Supplier; +using BarCode.Web.Core.Dto.Login; +using BarCode.Web.Core.Dto.SingleData; +using BarCode.Web.Core.Internal.Results; +using BarCode.Web.Domain.Entitys; +using BarCode.Web.Domain.Infrastructure; +using BarCode.Web.Domain.IService; +using BarCode.Web.Domain.IService.Public; +using BarCode.Web.Domain.Services.Public; +using BarCode.Web.Domain.Values; +using BarCode.Web.Domain.Values.Single; +using Microsoft.EntityFrameworkCore.Storage; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; +using Npoi.Mapper; +using NPOI.SS.Formula.Functions; +using System; +using System.Collections.Generic; +using System.ComponentModel.Design; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Domain.Services +{ + /// + /// 箱信息 + /// + public class BoxService : IBoxService + { + private readonly ILogger _logger; + private IBasicsRepositories _transactionRepositories; + private readonly IBoxRepositories _boxRepositories; + private readonly ISingleDataService _singleDataService; + private readonly ISerialNumbersRepositories _serialNumbersRepositories; + private readonly IErpService _erpService; + private readonly IWmsService _wmsService; + private readonly ISerialNumberService _serialNumberService; + public BoxService(ILogger logger, IBasicsRepositories transactionRepositories, + IBoxRepositories boxRepositories, ISingleDataService singleDataService, ISerialNumbersRepositories serialNumbersRepositories, + IErpService erpService, IWmsService wmsService, ISerialNumberService serialNumberService) + { + _logger = logger; + _transactionRepositories = transactionRepositories; + _boxRepositories = boxRepositories; + _singleDataService = singleDataService; + _serialNumbersRepositories = serialNumbersRepositories; + _erpService = erpService; + _wmsService = wmsService; + _serialNumberService = serialNumberService; + } + /// + /// 生成箱码 + /// + /// + /// + /// + /// + public async Task Generate(GenerateBoxRequest dto, LoginInDto loginInfo) + { + _logger.LogInformation($"生成箱码:{JsonConvert.SerializeObject(dto)},用户:{loginInfo.UserInfo.Nickname}"); + string supplierCode = ""; + string orgCode = ""; + if (dto.OrgCode.Substring(0, 1).Equals("s")) + supplierCode = dto.OrgCode.Substring(2, dto.OrgCode.Length - 2); + else + orgCode = dto.OrgCode.Substring(2, dto.OrgCode.Length - 2); + + List boxs = new List(); + for (int i = 1; i <= dto.Number; i++) + { + Box b = new Box() + { + CreatorId = loginInfo.UserInfo.UcId, + OrgCode = orgCode, + SupplierCode = supplierCode, + CompanyId = loginInfo.UserInfo.CompanyId + }; + boxs.Add(b); + } + var res = await _boxRepositories.AddRange(boxs); + if (!res) return Result.ReFailure(ResultCodes.DateWriteError); + return Result.ReSuccess(); + } + /// + /// 装箱 + /// + /// + /// + /// + /// + public async Task Save(SaveBoxRequest dto, LoginInDto loginInfo) + { + _logger.LogInformation($"装箱:{JsonConvert.SerializeObject(dto)},用户:{loginInfo.UserInfo.Nickname}"); + var box = await _boxRepositories.Get(dto.BoxId); + if (box == null) + return Result.ReFailure(ResultCodes.NoDateError); + if (box.Status == BoxStatus.Complete) + return Result.ReFailure(ResultCodes.CartonCompleteError); + //去重 + dto.Details = dto.Details.Distinct().ToList(); + var sAll = dto.Details.Select(s => s.SerialNumber).ToList(); + var serialNumberList = await _serialNumbersRepositories.GetEntityListContainNumber(sAll); + List serialList; + if (serialNumberList.Count() != sAll.Count()) + return Result.ReFailure(ResultCodes.SerialNumberNoDateError); + if (serialNumberList.Where(w => w.BoxId != 0 || w.IsUse == true).Any()) + return Result.ReFailure(ResultCodes.SerialNumberBindBox); + //新的序列号以存在于箱中 + var bs = box.Details.SelectMany(s => s.SerialNumbers).ToList(); + var jj = sAll.Intersect(bs); + if (jj.Count() > 0) + return Result.ReFailure(ResultCodes.SerialNumberBindBox); + //装箱状态 + var resCarton = box.Carton(dto.IsCarton, loginInfo.UserInfo.UcId); + if (!resCarton.IsSuccess) return resCarton; + + var materialNumbers = dto.Details.GroupBy(g => g.MaterialNumber).Select(s => s.Key).ToList(); + foreach (var m in materialNumbers) + { + var detail = box.Details.FirstOrDefault(f => f.MaterialNumber.Equals(m)); + var serialNumbers = dto.Details.Where(w => w.MaterialNumber.Equals(m)).Select(s => s.SerialNumber).ToList(); + if (detail == null) + { + detail = new BoxDetails() + { + MaterialNumber = m, + Qty = serialNumbers.Count(), + SerialNumbers = serialNumbers + }; + box.Details.Add(detail); + } + else + { + detail.Qty += serialNumbers.Count(); + detail.SerialNumbers.AddRange(serialNumbers); + } + } + IDbContextTransaction _transaction = _transactionRepositories.GetTransaction(); + bool res_Rollback = false; + bool isSuccess = true; + //装箱 + foreach (var d in dto.Details.Select(s => s.SerialNumber).Reverse()) + { + ////原来的 + //var serial = serialNumberList.FirstOrDefault(f => f.SerialNumber.Equals(d) + //|| f.NumberCode.Equals(d)); + //if (serial == null) return Result.ReFailure(ResultCodes.SerialNumberNoDateError); + //serial.CompleteBox(box.Id, d); + ////原来的到此 + + + serialList = await _serialNumbersRepositories.GetEntityListBySuitNumber(d); + + + if (serialList == null) return Result.ReFailure(ResultCodes.SerialNumberNoDateError); + if (serialList.Count == 0) return Result.ReFailure(ResultCodes.SerialNumberNoDateError); + + + + for (int i = 0; i < serialList.Count; i++) + { + if(serialList[i].SerialNumber.ToString() == d) + { + serialList[i].CompleteBox(box.Id, d); + } + else + { + serialList[i].CompleteBox(0, d); + } + + } + if (!res_Rollback) + { + isSuccess = await _serialNumbersRepositories.EditEntityList(serialList, false); + if (!isSuccess) res_Rollback = true; + } + + + } + + + var res = await _boxRepositories.Edit(box, false); + if (res == null) res_Rollback = true; + //if (!res_Rollback) + //{ + // isSuccess = await _serialNumbersRepositories.EditEntityList(serialNumberList, false); + // if (!isSuccess) res_Rollback = true; + //} + + + if (!res_Rollback) + { + var ids = serialNumberList.Select(s => s.GenerateRecordId).ToList(); + var resUse = await _serialNumberService.Use(ids); + if (!resUse.IsSuccess) res_Rollback = true; + } + //提交事务 + isSuccess = _transactionRepositories.CommitTransaction(res_Rollback, _transaction); + + if (res_Rollback || !isSuccess) + return Result.ReFailure(ResultCodes.DateWriteError); + return Result.ReSuccess(); + } + /// + /// 打印 + /// + /// + /// + /// + public async Task Print(OperateRequest dto) + { + var boxs = await _boxRepositories.GetEntityList(dto.Ids); + boxs.ForEach(f => f.Print()); + var res = await _boxRepositories.EditEntityList(boxs); + if (!res) return Result.ReFailure(ResultCodes.DateWriteError); + return Result.ReSuccess(); + } + /// + /// 删除 + /// + /// + /// + /// + public async Task Delete(DeleteBoxSerialNumberRequest dto, LoginInDto loginInfo) + { + _logger.LogInformation($"删除箱物料:{JsonConvert.SerializeObject(dto)},用户:{loginInfo.UserInfo.Nickname}"); + var box = await _boxRepositories.Get(dto.BoxId); + if (box == null) + return Result.ReFailure(ResultCodes.BoxNoDataError); + if (box.Status == BoxStatus.Complete) + return Result.ReFailure(ResultCodes.CartonCompleteError); + + var sList = await _serialNumbersRepositories.GetEntityList(new List() { dto.SerialNumber }); + var s = sList.FirstOrDefault(f => f.SerialNumber.Equals(dto.SerialNumber)); + if (s == null) + return Result.ReFailure(ResultCodes.SerialNumberNoDateError); + //判断使用的是数字序列码还是序列码 + var sStr = s.IsUseNumber == true ? s.NumberCode : s.SerialNumber; + + var resUn = box.UnSerialNumber(sStr, dto.MaterialNumber); + if (!resUn.IsSuccess) return resUn; + + //var sList = await _serialNumbersRepositories.GetEntityListContainNumber(new List() { dto.SerialNumber }); + //sList.ForEach(f => f.UnBox()); + s.UnBox();//解绑 + + IDbContextTransaction _transaction = _transactionRepositories.GetTransaction(); + bool res_Rollback = false; + bool isSuccess = true; + var res = await _boxRepositories.Edit(box, false); + if (res == null) res_Rollback = true; + if (!res_Rollback) + { + isSuccess = await _serialNumbersRepositories.EditEntityList(sList, false); + if (!isSuccess) res_Rollback = true; + } + if (!res_Rollback) + { + var ids = sList.Select(s => s.GenerateRecordId).ToList(); + var resUse = await _serialNumberService.Use(ids); + if (!resUse.IsSuccess) res_Rollback = true; + } + //提交事务 + isSuccess = _transactionRepositories.CommitTransaction(res_Rollback, _transaction); + + if (res_Rollback || !isSuccess) + return Result.ReFailure(ResultCodes.DateWriteError); + return Result.ReSuccess(); + } + /// + /// 清空装箱信息 + /// + /// + /// + /// + public async Task Clear(int boxId, LoginInDto loginInfo) + { + _logger.LogInformation($"清空装箱信息:{boxId},用户:{loginInfo.UserInfo.Nickname}"); + var box = await _boxRepositories.Get(boxId); + if (box == null) + return Result.ReFailure(ResultCodes.BoxNoDataError); + + var s = box.Details.SelectMany(s => s.SerialNumbers).ToList(); + box.Details.Clear(); + + IDbContextTransaction _transaction = _transactionRepositories.GetTransaction(); + bool res_Rollback = false; + bool isSuccess = true; + var sList = await _serialNumbersRepositories.GetEntityListByBoxIds(new List() { boxId }); + foreach (var f in sList) + { + if( f.IsTwo>1) + { + //说明是两件装的产品,那么要分别清除 + var sList2 = await _serialNumbersRepositories.GetEntityListBySuitNumber(f.SerialNumber); + for(int i=0;i f.UnBox()); + + + var res = await _boxRepositories.Edit(box, false); + if (res == null) res_Rollback = true; + if (!res_Rollback) + { + isSuccess = await _serialNumbersRepositories.EditEntityList(sList, false); + if (!isSuccess) res_Rollback = true; + } + if (!res_Rollback) + { + var ids = sList.Select(s => s.GenerateRecordId).ToList(); + var resUse = await _serialNumberService.Use(ids); + if (!resUse.IsSuccess) res_Rollback = true; + } + //提交事务 + isSuccess = _transactionRepositories.CommitTransaction(res_Rollback, _transaction); + + if (res_Rollback || !isSuccess) + return Result.ReFailure(ResultCodes.DateWriteError); + return Result.ReSuccess(); + } + /// + /// wms系统调用 获取完成装箱箱信息 + /// + /// + /// + /// + public async Task<(List list, int total)> GetCartonListAsync(WmsBoxRequest dto) + { + var org_result = await _erpService.BillQueryForOrg(); + List orgs = new List(); + if (org_result.IsSuccess) + orgs = org_result.Data.ToList(); + + var supplier_result = await _erpService.BillQueryForSupplier(); + List suppliers = new List(); + if (supplier_result.IsSuccess) + suppliers = supplier_result.Data.ToList(); + + var (list, count) = await _boxRepositories.GetEntityByWmsList(dto); + var ids = list.Select(s => s.Id).ToList(); + var serialList = await _serialNumbersRepositories.GetEntityListByBoxIds(ids); + List response = new List(); + foreach (var box in list) + { + WmsBoxResponse res = new WmsBoxResponse() + { + BoxBillNo = box.BoxBillNo, + OpsBoxId = box.Id, + CompleteCartonTime = box.CartonEndTime ?? DateTime.Now, + CompleteCartonUser = _singleDataService.GetSingleData(SingleAction.Users, box.CompanyId, box.CartonUserId), + CreateTime = box.CreateTime, + OrgId = orgs.FirstOrDefault(f => f.Number.Equals(box.OrgCode))?.Id ?? 0, + SupplierId = suppliers.FirstOrDefault(f => f.Number.Equals(box.SupplierCode))?.Id ?? 0, + CreateUser = _singleDataService.GetSingleData(SingleAction.Users, box.CompanyId, box.CreatorId), + }; + + foreach (var bd in box.Details) + { + //var bdsList = serialList.Where(w => w.BoxId == box.Id && w.MaterialNumber.Equals(bd.MaterialNumber)).ToList(); + var bdsList = bd.SerialNumbers; + List sList = new List(); + foreach (var s in bdsList) + { + var sentity = serialList.FirstOrDefault(f => f.SerialNumber.Equals(s) || f.NumberCode.Equals(s)); + sList.Add(new Core.Dto.Box.OpsSerialNumbersResponse() + { + SerialNumber = s, + BarCereateUser = _singleDataService.GetSingleData(SingleAction.Users, box.CompanyId, sentity == null ? 0 : sentity.CreatorId), + BarCreateTime = sentity == null ? null : sentity.CreateTime + }); + } + Core.Dto.Box.OpsBoxDetailsResponse Detail = new Core.Dto.Box.OpsBoxDetailsResponse() + { + MaterialNumber = bd.MaterialNumber, + Qty = bd.Qty, + SerialNumbers = sList + }; + res.Details.Add(Detail); + } + + response.Add(res); + } + return (response, count); + } + /// + /// 重新装箱 + /// + /// + /// + /// + public async Task Restart(OperateRequest dto, LoginInDto loginInfo) + { + _logger.LogInformation($"重新装箱的箱:{JsonConvert.SerializeObject(dto.Ids)} 操作人:{loginInfo.UserInfo.Nickname}"); + var boxList = await _boxRepositories.GetEntityList(dto.Ids); + if (boxList.Where(w => w.Status != BoxStatus.Complete).Any()) + return Result.ReFailure(ResultCodes.BoxNoComplete); + var nos = boxList.Select(s => s.BoxBillNo).ToList(); + + List failBox = new List(); + var res = await _wmsService.Restart(nos); + if (!res.IsSuccess) + return res; + //已收货的箱返回在数据里带过来 + failBox = res.Data; + //把已收货的箱排除出去 然后重置 + boxList.Where(w => !failBox.Contains(w.BoxBillNo)).ForEach(f => f.Restart()); + var isSuccess = await _boxRepositories.EditEntityList(boxList); + if (!isSuccess) return Result.ReFailure(ResultCodes.DateWriteError); + if (failBox.Count() > 0) + { + return Result.ReFailure($"箱号:{string.Join(",", failBox)} 已收货,不允许重新装箱,请和仓库人员沟通", 3433535); + } + + return Result.ReSuccess(); + } + /// + /// 开始装箱 + /// + /// + /// + /// + public async Task BeginCarton(int boxId, LoginInDto loginInfo) + { + _logger.LogInformation($"开始装箱:{boxId},用户:{loginInfo.UserInfo.Nickname}"); + var box = await _boxRepositories.Get(boxId); + if (box == null) + return Result.ReFailure(ResultCodes.BoxNoDataError); + if (box.Status == BoxStatus.Complete) + return Result.ReFailure(ResultCodes.CartonCompleteError); + var res = box.BeginCarton(loginInfo.UserInfo.UcId); + if (!res.IsSuccess) + return res; + var res_box = await _boxRepositories.Edit(box, true); + if (res_box == null) return Result.ReFailure(ResultCodes.DateWriteError); + return Result.ReSuccess(); + } + } +} diff --git a/src/BarCode.Web.Domain/Services/ExportExcelService.cs b/src/BarCode.Web.Domain/Services/ExportExcelService.cs new file mode 100644 index 0000000..4424253 --- /dev/null +++ b/src/BarCode.Web.Domain/Services/ExportExcelService.cs @@ -0,0 +1,229 @@ + +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using Npoi.Mapper; +using System.IO; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using BarCode.Web.Domain.IService; +using BarCode.Web.Domain.Options; +using BarCode.Web.Domain.Entitys; +using BarCode.Web.Domain.Values; +using BarCode.Web.Domain.Infrastructure; +using BarCode.Web.Core.Dto; +using BarCode.Web.Core.Dto.Login; + +namespace BarCode.Web.Domain.Services +{ + public class ExportExcelService : IExportExcelService + { + private readonly IQiniuUploadService _qiniuUploadService; + private readonly IServiceScopeFactory _serviceScopeFactory; + private readonly ILogger _logger; + private readonly QiniuOptions _option; + public ExportExcelService(IQiniuUploadService qiniuUploadService, IServiceScopeFactory serviceScopeFactory, + ILogger logger, IOptions option) + { + _qiniuUploadService = qiniuUploadService; + _serviceScopeFactory = serviceScopeFactory; + _logger = logger; + _option = option?.Value; + } + /// + /// 列表页导出 + /// + /// + /// + /// + /// + /// + /// + /// + /// + public async Task Export(List dataList, string fileName, int userId, LoginInDto loginInfo, FileDownLoadOrderType type, string orgCode, Mapper mapper = null, int? supplierId = null) + { + FileDownManager entity = new FileDownManager(userId, loginInfo.UserInfo.CompanyId, type,orgCode, _option.Url + fileName, loginInfo.UserInfo.SupplierCode); + using (var scope = _serviceScopeFactory.CreateScope()) + { + var _fileDownManagerService = scope.ServiceProvider.GetRequiredService(); + entity = await _fileDownManagerService.Add(entity); + List> listz = new List>(); + listz.Add(dataList); + + string msg = await Upload(listz, fileName, userId, type); + + entity.Finish(string.IsNullOrEmpty(msg) == true ? true : false, msg); + await _fileDownManagerService.Edit(entity); + return; + } + } + /// + /// 全字段导出 + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public Task ExportAll(Request request, string fileName, int userId, LoginInDto loginInfo, FileDownLoadOrderType type, string orgCode, Mapper mapper = null, int? supplierId = null) where Request : PaginationBaseRequestDto + { + return Task.CompletedTask; + //FileDownManager entity = new FileDownManager(userId, companyId, type, _option.Url + fileName, supplierId); + + //request.PageNo = 1; + //request.PageSize = _option.PageSize; + //List> listz = new List>(); + //string msg = ""; + //using (var scope = _serviceScopeFactory.CreateScope()) + //{ + // var _fileDownManagerService = scope.ServiceProvider.GetRequiredService(); + // entity = await _fileDownManagerService.Add(entity); + // try + // { + // var _service = scope.ServiceProvider.GetRequiredService>(); + // _logger.LogInformation($"{DateTime.Now}--开始访问数据"); + // var (obj, total) = await _service.GetListAllField(request, companyId); + // var list = (List)obj; + // var page = Math.Ceiling(Convert.ToDecimal(total) / _option.PageSize); + + // listz.Add(list); + // for (int i = 1; i < page; i++) + // { + // request.PageNo++; + // var (obj_f, total_f) = await _service.GetListAllField(request, companyId); + // var list_f = (List)obj_f; + // listz.Add(list_f); + // } + // _logger.LogInformation($"{DateTime.Now}--访问数据成功 总数:{total}"); + // } + // catch (Exception ex) + // { + // msg = $"未找到数据 {ex.ToString()}"; + // _logger.LogError($"导出异常:{ex.ToString()}"); + // } + + // if (!string.IsNullOrEmpty(msg)) + // { + // entity.Finish(false, msg); + // await _fileDownManagerService.Edit(entity); + // return; + // } + + // msg = await Upload(listz, fileName, userId, type); + + // entity.Finish(string.IsNullOrEmpty(msg) == true ? true : false, msg); + // await _fileDownManagerService.Edit(entity); + // return; + //} + } + + public async Task ExportList(Request request, string fileName, int userId, LoginInDto loginInfo, FileDownLoadOrderType type, string orgCode, Mapper mapper = null, int? supplierId = null) where Request : PaginationBaseRequestDto + { + FileDownManager entity = new FileDownManager(userId, loginInfo.UserInfo.CompanyId, type,orgCode, _option.Url + fileName, loginInfo.UserInfo.SupplierCode); + + request.PageNo = 1; + request.PageSize = _option.PageSize; + List> listz = new List>(); + string msg = ""; + using (var scope = _serviceScopeFactory.CreateScope()) + { + var _fileDownManagerService = scope.ServiceProvider.GetRequiredService(); + entity = await _fileDownManagerService.Add(entity); + try + { + var _service = scope.ServiceProvider.GetRequiredService>(); + _logger.LogInformation($"{DateTime.Now}--开始访问数据"); + var (obj, total) = await _service.GetListField(request, loginInfo); + var list = (List)obj; + var page = Math.Ceiling(Convert.ToDecimal(total) / _option.PageSize); + + listz.Add(list); + for (int i = 1; i < page; i++) + { + request.PageNo++; + var (obj_f, total_f) = await _service.GetListField(request, loginInfo); + var list_f = (List)obj_f; + listz.Add(list_f); + } + _logger.LogInformation($"{DateTime.Now}--访问数据成功 总数:{total}"); + } + catch (Exception ex) + { + msg = "未找到数据"; + _logger.LogError($"导出数据查询异常 {ex.ToString()}"); + } + + if (listz.Count <= 0) + { + entity.Finish(false, msg); + await _fileDownManagerService.Edit(entity); + return; + } + + msg = await Upload(listz, fileName, userId, type); + + entity.Finish(string.IsNullOrEmpty(msg) == true ? true : false, msg); + await _fileDownManagerService.Edit(entity); + return; + } + } + + private async Task Upload(List> dataList, string fileName, int userId, FileDownLoadOrderType type, Mapper mapper = null) + { + if (mapper == null) + mapper = new Mapper(); + + //第一个参数为导出Excel名称 + //第二个参数为Excel数据来源 + //第三个参数为导出的Sheet名称 + //overwrite参数如果是要覆盖已存在的Excel或者新建Excel则为true,如果在原有Excel上追加数据则为false + //xlsx参数是用于区分导出的数据格式为xlsx还是xls + MemoryStream stream = new MemoryStream(); + try + { + for (int i = 0; i < dataList.Count; i++) + { + mapper.Put(dataList[i], "sheet" + (i + 1), true); + } + mapper.Save(stream); + } + catch (Exception) + { + return "数据导入Execl异常"; + } + + + //mapper.Save(stream, dataList, "sheet1", overwrite: true, xlsx: true); + //,但是这里也踩到了一个坑,不过这个是 Npoi 的坑并不是 Npoi.Mapper 的坑, + // 那就是 Workbook.Write(stream)的时候会将 stream 关闭,如果继续操作这个 Stream 会报流已关闭的错误 + //所以这里 是把流先转成byte[] 再转回使用的流 + try + { + var middleByte = stream.ToArray(); + using (MemoryStream streamUpload = new MemoryStream(middleByte)) + { + var res = await _qiniuUploadService.Upload(fileName, streamUpload, true); + if (!res.Success) + { + _logger.LogError($"{DateTime.Now}--上传千牛云失败 原因:{res.Message}"); + return res.Message; + } + } + } + catch (Exception) + { + return "数据上传云端异常"; + } + + _logger.LogInformation($"{DateTime.Now}--导出成功"); + return ""; + } + } +} diff --git a/src/BarCode.Web.Domain/Services/Public/ErpBaseDataSync.cs b/src/BarCode.Web.Domain/Services/Public/ErpBaseDataSync.cs new file mode 100644 index 0000000..0f6a55b --- /dev/null +++ b/src/BarCode.Web.Domain/Services/Public/ErpBaseDataSync.cs @@ -0,0 +1,83 @@ +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using BarCode.Web.Domain.IService.Public; + +namespace BarCode.Web.Domain.Services.Public +{ + /// + /// 同步erp基础数据 + /// + public static class ErpBaseDataSync + { + public static Task Sync(IServiceProvider serviceProvider) + { + var sercice = serviceProvider.GetRequiredService(); + //Task.Run(() => + //{ + // //异步-同步下物料数据 + // sercice.BillQueryForMaterial().GetAwaiter().GetResult(); + //}); + + Task.Run(() => + { + //异步-同步下组织数据 + sercice.BillQueryForOrg().GetAwaiter().GetResult(); + }); + + Task.Run(() => + { + //异步-同步下客户数据 + sercice.BillQueryForCustomer().GetAwaiter().GetResult(); + }); + + Task.Run(() => + { + //异步-同步下供应商数据 + sercice.BillQueryForSupplier().GetAwaiter().GetResult(); + + }); + return Task.CompletedTask; + } + + public static Task SyncMaterial(IErpService sercice) + { + Task.Run(() => + { + //异步-同步下物料数据 + sercice.BillQueryForMaterial().GetAwaiter().GetResult(); + }); + return Task.CompletedTask; + } + public static Task SyncOrg(IErpService sercice) + { + Task.Run(() => + { + //异步-同步下组织数据 + sercice.BillQueryForOrg().GetAwaiter().GetResult(); + }); + return Task.CompletedTask; + } + public static Task SyncCustomer(IErpService sercice) + { + Task.Run(() => + { + //异步-同步下客户数据 + sercice.BillQueryForCustomer().GetAwaiter().GetResult(); + }); + return Task.CompletedTask; + } + public static Task SyncSupplier(IErpService sercice) + { + Task.Run(() => + { + //异步-同步下供应商数据 + sercice.BillQueryForSupplier().GetAwaiter().GetResult(); + + }); + return Task.CompletedTask; + } + } +} diff --git a/src/BarCode.Web.Domain/Services/Public/ErpBasicDataExtendService.cs b/src/BarCode.Web.Domain/Services/Public/ErpBasicDataExtendService.cs new file mode 100644 index 0000000..d587a18 --- /dev/null +++ b/src/BarCode.Web.Domain/Services/Public/ErpBasicDataExtendService.cs @@ -0,0 +1,442 @@ +using AutoMapper; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using BarCode.Web.Core.Dto.Erp; +using BarCode.Web.Core.Dto.Erp.Customer; +using BarCode.Web.Core.Dto.Erp.Org; +using BarCode.Web.Core.Dto.Erp.Supplier; +using BarCode.Web.Domain.Infrastructure; +using BarCode.Web.Domain.IService.Public; +using BarCode.Web.Core.Dto.SingleData; + +namespace BarCode.Web.Domain.Services.Public +{ + /// + /// erp基础数据:扩展服务 + /// + public class ErpBasicDataExtendService: IErpBasicDataExtendService + { + private readonly IMapper _mapper; + private readonly IErpService _erpService; + private readonly ILoginService _loginService; + private readonly IBasicsRepositories _basicsRepositories; + + public ErpBasicDataExtendService(IMapper mapper, ILoginService loginService, IErpService erpService, + IBasicsRepositories basicsRepositories) + { + _mapper = mapper; + _erpService = erpService; + _loginService = loginService; + _basicsRepositories = basicsRepositories; + + } + + /// + /// 获取物料名称 + /// + /// + /// + /// + public string GetMaterialName(List erpMaterials,int materialId) + { + if (erpMaterials == null || erpMaterials.Count == 0) + return ""; + + var mat= erpMaterials.Where(x => x.MaterialId == materialId).FirstOrDefault(); + if (mat == null) + { + var result= _erpService.BillQueryForMaterial(materialId).GetAwaiter().GetResult(); + + if (!result.IsSuccess) + return ""; + return result.Data == null ? "" : result.Data.MaterialName; + } + return mat.MaterialName; + } + + /// + /// 获取物料编码 + /// + /// + /// + /// + public string GetMaterialNumber(List erpMaterials, int materialId) + { + if (erpMaterials == null || erpMaterials.Count == 0) + return ""; + var mat = erpMaterials.Where(x => x.MaterialId == materialId).FirstOrDefault(); + if (mat == null) + { + var result = _erpService.BillQueryForMaterial(materialId).GetAwaiter().GetResult(); + if (!result.IsSuccess) + return ""; + return result.Data == null ? "" : result.Data.MaterialNumber; + } + return mat.MaterialNumber; + } + + /// + /// 获取物料规格型号 + /// + /// + /// + /// + public string GetMaterialSpecifications(List erpMaterials, int materialId) + { + if (erpMaterials == null || erpMaterials.Count == 0) + return ""; + var mat = erpMaterials.Where(x => x.MaterialId == materialId).FirstOrDefault(); + if (mat == null) + { + var result = _erpService.BillQueryForMaterial(materialId).GetAwaiter().GetResult(); + if (!result.IsSuccess) + return ""; + return result.Data == null ? "" : result.Data.Specifications; + } + return mat.Specifications; + } + + /// + /// 获取物料名称 + /// + /// + /// + /// + public string GetMaterialName(List erpMaterials, string materialNumber) + { + if (string.IsNullOrEmpty(materialNumber)) return ""; + if (erpMaterials == null || erpMaterials.Count == 0) + return ""; + + var mat = erpMaterials.Where(x => x.MaterialNumber == materialNumber).FirstOrDefault(); + if (mat == null) + { + var result = _erpService.BillQueryForMaterial(materialNumber).GetAwaiter().GetResult(); + + if (!result.IsSuccess) + return ""; + return result.Data == null ? "" : result.Data.MaterialName; + } + return mat.MaterialName; + } + /// + /// 获取物料编码 + /// + /// + /// + /// + public string GetMaterialSpecifications(List erpMaterials, string materialNumber) + { + if (string.IsNullOrEmpty(materialNumber)) return ""; + if (erpMaterials == null || erpMaterials.Count == 0) + return ""; + var mat = erpMaterials.Where(x => x.MaterialNumber == materialNumber).FirstOrDefault(); + if (mat == null) + { + var result = _erpService.BillQueryForMaterial(materialNumber).GetAwaiter().GetResult(); + if (!result.IsSuccess) + return ""; + return result.Data == null ? "" : result.Data.Specifications; + } + return mat.Specifications; + } + + + /// + /// 获取物料基本单位名称 + /// + /// + /// + /// + public string GetMaterialUnitName(List erpMaterials, int materialId) + { + if (erpMaterials == null || erpMaterials.Count == 0) + return ""; + var mat = erpMaterials.Where(x => x.MaterialId == materialId).FirstOrDefault(); + if (mat == null) + { + var result = _erpService.BillQueryForMaterial(materialId).GetAwaiter().GetResult(); + if (!result.IsSuccess) + return ""; + return result.Data == null ? "" : result.Data.BaseUnitName; + } + return mat.BaseUnitName; + } + /// + /// 获取物料基本单位名称 + /// + /// + /// + /// + public string GetMaterialUnitName(List erpMaterials, string materialNumber) + { + if (erpMaterials == null || erpMaterials.Count == 0) + return ""; + var mat = erpMaterials.Where(x => x.MaterialNumber == materialNumber).FirstOrDefault(); + if (mat == null) + { + var result = _erpService.BillQueryForMaterial(materialNumber).GetAwaiter().GetResult(); + if (!result.IsSuccess) + return ""; + return result.Data == null ? "" : result.Data.BaseUnitName; + } + return mat.BaseUnitName; + } + + /// + /// 获取物料的条码 + /// + /// + /// + /// + public string GetMaterialBarCode(List erpMaterials, int materialId) + { + if (erpMaterials == null || erpMaterials.Count == 0) + return ""; + var mat = erpMaterials.Where(x => x.MaterialId == materialId).FirstOrDefault(); + if (mat == null) + { + var result = _erpService.BillQueryForMaterial(materialId).GetAwaiter().GetResult(); + if (!result.IsSuccess) + return ""; + return result.Data == null ? "" : result.Data.BarCode; + } + return mat.BarCode; + } + + /// + /// 获取物料的条码 + /// + /// + /// + /// + public string GetMaterialBarCode(List erpMaterials, string materialNumber) + { + if (string.IsNullOrEmpty(materialNumber)) return ""; + if (erpMaterials == null || erpMaterials.Count == 0) + return ""; + var mat = erpMaterials.Where(x => x.MaterialNumber == materialNumber).FirstOrDefault(); + if (mat == null) + { + var result = _erpService.BillQueryForMaterial(materialNumber).GetAwaiter().GetResult(); + if (!result.IsSuccess) + return ""; + return result.Data == null ? "" : result.Data.BarCode; + } + return mat.BarCode; + } + + /// + /// 获取物料基本单位Id + /// + /// + /// + /// + public int GetMaterialUnitId(List erpMaterials, int materialId) + { + if (erpMaterials == null || erpMaterials.Count == 0) + return 0; + var mat = erpMaterials.Where(x => x.MaterialId == materialId).FirstOrDefault(); + if (mat == null) + { + var result = _erpService.BillQueryForMaterial(materialId).GetAwaiter().GetResult(); + if (!result.IsSuccess) + return 0; + return result.Data == null ? 0 : result.Data.BaseUnitId; + } + return mat.BaseUnitId; + } + /// + /// 获取物料基本单位编码 + /// + /// + /// + /// + public string GetMaterialUnitNumber(List erpMaterials, int materialId) + { + if (erpMaterials == null || erpMaterials.Count == 0) + return ""; + var mat = erpMaterials.Where(x => x.MaterialId == materialId).FirstOrDefault(); + if (mat == null) + { + var result = _erpService.BillQueryForMaterial(materialId).GetAwaiter().GetResult(); + if (!result.IsSuccess) + return ""; + return result.Data == null ? "" : result.Data.BaseUnitNumber; + } + return mat.BaseUnitNumber; + } + /// + /// 获取物料基本单位编码 + /// + /// + /// + /// + public string GetMaterialUnitNumber(List erpMaterials, string materialNumber) + { + if (erpMaterials == null || erpMaterials.Count == 0) + return ""; + var mat = erpMaterials.Where(x => x.MaterialNumber == materialNumber).FirstOrDefault(); + if (mat == null) + { + var result = _erpService.BillQueryForMaterial(materialNumber).GetAwaiter().GetResult(); + if (!result.IsSuccess) + return ""; + return result.Data == null ? "" : result.Data.BaseUnitNumber; + } + return mat.BaseUnitNumber; + } + /// + /// 获取组织名称 + /// + /// + /// + /// + public string GetOrgName(List erpOrgs, int orgId) + { + if (erpOrgs == null || erpOrgs.Count == 0) + return ""; + var org = erpOrgs.Where(x => x.Id == orgId).FirstOrDefault(); + return org == null ? "" : org.Name; + } + + /// + /// 获取组织名称 + /// + /// + /// + /// + public string GetOrgName(List erpOrgs, string orgCode) + { + if (erpOrgs == null || erpOrgs.Count == 0) + return ""; + var org = erpOrgs.Where(x => x.Number == orgCode).FirstOrDefault(); + return org == null ? "" : org.Name; + } + + /// + /// 获取组织id + /// + /// + /// + /// + public int GetOrgId(List erpOrgs, string orgCode) + { + if (erpOrgs == null || erpOrgs.Count == 0) + return 0; + var org = erpOrgs.Where(x => x.Number == orgCode).FirstOrDefault(); + return org == null ? 0 : org.Id; + } + + /// + /// 获取供应商名称 + /// + /// + /// + /// + public string GetSupplierName(List erpSuppliers, int supplierId) + { + if (erpSuppliers == null || erpSuppliers.Count == 0) + return ""; + var supplier = erpSuppliers.Where(x => x.Id == supplierId).FirstOrDefault(); + return supplier == null ? "" : supplier.Name; + } + /// + /// 获取供应商名称 + /// + /// + /// + /// + public string GetSupplierName(List erpSuppliers, string supplierCode) + { + if (erpSuppliers == null || erpSuppliers.Count == 0) + return ""; + var supplier = erpSuppliers.Where(x => x.Number.Equals(supplierCode)).FirstOrDefault(); + return supplier == null ? "" : supplier.Name; + } + /// + /// 获取客户名称 + /// + /// + /// + /// + public string GetCustomerName(List erpCustomers, int customerId) + { + if (erpCustomers == null || erpCustomers.Count == 0) + return ""; + var supplier = erpCustomers.Where(x => x.Id == customerId).FirstOrDefault(); + return supplier == null ? "" : supplier.Name; + } + + /// + /// 获取仓库名称 + /// + /// + /// + /// + public string GetStockName(List erpStocks, int stockId) + { + if (erpStocks == null || erpStocks.Count == 0) + return ""; + var stock = erpStocks.Where(x => x.Id == stockId).FirstOrDefault(); + return stock == null ? "" : stock.Name; + } + + /// + /// 获取仓库名称 + /// + /// + /// + /// + public string GetStockName(List erpStocks, string code) + { + if (erpStocks == null || erpStocks.Count == 0) + return ""; + var stock = erpStocks.Where(x => x.Code == code).FirstOrDefault(); + return stock == null ? "" : stock.Name; + } + + /// + /// 获取仓库编码 + /// + /// + /// + /// + public string GetStockCode(List erpStocks, int stockId) + { + if (erpStocks == null || erpStocks.Count == 0) + return ""; + var stock = erpStocks.Where(x => x.Id == stockId).FirstOrDefault(); + return stock == null ? "" : stock.Code; + } + /// + /// 子仓库 + /// + /// + /// + /// + public string GetSubStockName(List erpStocks, string code) + { + if (erpStocks == null || erpStocks.Count == 0) + return ""; + var stock = erpStocks.Where(x => x.Code == code).FirstOrDefault(); + return stock == null ? "" : stock.Name; + } + /// + /// 获取单点组织名字 + /// + /// + /// + /// + /// + public string GetSingleOrgName(List orgs, string code) + { + if (orgs == null || orgs.Count == 0) + return ""; + var org = orgs.Where(x => x.ErpOrgCode == code).FirstOrDefault(); + return org == null ? "" : org.Name; + } + } +} diff --git a/src/BarCode.Web.Domain/Services/Public/ErpService.cs b/src/BarCode.Web.Domain/Services/Public/ErpService.cs new file mode 100644 index 0000000..18f33bb --- /dev/null +++ b/src/BarCode.Web.Domain/Services/Public/ErpService.cs @@ -0,0 +1,1207 @@ +using AutoMapper; +using ERP; +using Microsoft.EntityFrameworkCore.Storage; +using Microsoft.Extensions.Caching.Memory; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.Linq; +using System.ServiceModel; +using System.Text; +using System.Threading.Tasks; +using BarCode.Web.Core.Dto.Erp; +using BarCode.Web.Core.Dto.Erp.Customer; +using BarCode.Web.Core.Dto.Erp.Org; +using BarCode.Web.Core.Dto.Erp.OutStock; +using BarCode.Web.Core.Dto.Erp.Supplier; +using BarCode.Web.Core.Dto.Erp.TakeStock; +using BarCode.Web.Core.Help; +using BarCode.Web.Core.Internal.Results; +using BarCode.Web.Domain.Entitys; +using BarCode.Web.Domain.Infrastructure; +using BarCode.Web.Domain.IService.Public; +using BarCode.Web.Domain.Options; +using BarCode.Web.Domain.Values; +using BarCode.Web.Domain.Values.Erp; +using BarCode.Web.Domain.Values.Single; +using System.Text.Json.Nodes; +using Quartz.Logging; +using NPOI.SS.UserModel; + +namespace BarCode.Web.Domain.Services.Public +{ + /// + /// erp数据交互服务 + /// + public class ErpService : IErpService + { + private IMapper _mapper; + private AppOptions _appOptions; + private ErpOptions _erpOptions; + private ILogger _logger; + private ERPGWSoapClient _client; + private readonly IMemoryCache _memoryCache; + private readonly IBasicsRepositories _basicsRepositories; + private readonly IMaterialsRepositories _materialsRepositories; + private readonly IServiceProvider _serviceProvider; + public ErpService( + IMapper mapper, + IOptions erpOptions, + IOptions appOptions, IServiceProvider serviceProvider, + ILogger logger, IMaterialsRepositories materialsRepositories, + IMemoryCache memoryCache, IBasicsRepositories basicsRepositories) + { + _serviceProvider = serviceProvider; + this._materialsRepositories = materialsRepositories; + this._basicsRepositories = basicsRepositories; + this._erpOptions = erpOptions?.Value; + this._appOptions = appOptions?.Value; + this._mapper = mapper; + this._logger = logger; + this._memoryCache = memoryCache; + } + + /// + /// 初始化ERP:登录到ERP + /// + /// + public async Task> Init() + { + BasicHttpBinding binding = new BasicHttpBinding(); + binding.MaxReceivedMessageSize = int.MaxValue; + binding.SendTimeout = new TimeSpan(int.MaxValue); + EndpointAddress address = new EndpointAddress(this._erpOptions.EndpointAddress); + this._client = new ERPGWSoapClient(binding, address); + try + { + var result = await this._client.ValidateSystemAsync(this._erpOptions.UserName, this._erpOptions.Password, this._erpOptions.ErpId, ""); + if (result == null || result.AccessToken == null) + { + _logger.LogError($"金蝶Token获取失败: {result?.Message}"); + return Result.ReFailure(ResultCodes.Erp_Login_Error); + } + return Result.ReSuccess(result.AccessToken); + } + catch (Exception ex) + { + _logger.LogError($"金蝶Token获取异常: {ex.Message}"); + return Result.ReFailure(ResultCodes.Erp_Login_Error); + } + } + + public async Task> Init1() + { + BasicHttpBinding binding = new BasicHttpBinding(); + binding.MaxReceivedMessageSize = int.MaxValue; + binding.SendTimeout = new TimeSpan(int.MaxValue); + EndpointAddress address = new EndpointAddress(this._erpOptions.EndpointAddress); + this._client = new ERPGWSoapClient(binding, address); + try + { + var result = await this._client.ValidateSystemAsync(this._erpOptions.UserName, this._erpOptions.Password, "Orico", ""); + if (result == null) + return Result.ReFailure(ResultCodes.Erp_Login_Error); + return Result.ReSuccess(result.AccessToken); + } + catch (Exception ex) + { + return Result.ReFailure(ResultCodes.Erp_Login_Error); + } + } + + /// + /// 查单据类型的值 + /// + /// + public async Task> BillQueryForBillType() + { + try + { + //1.先登录金蝶-拿到token + var token_result = await this.Init1(); + if (!token_result.IsSuccess) + return ResultList.ReFailure(token_result); + + //2.时间条件:可能还有其它条件 + var beginTime = DateTime.Now.AddDays(-2).ToString("yyyy-MM-dd 00:00:00"); + var endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + //3.获取金蝶采购订单:拼接参数和条件 + var query = new ErpBillQueryDto(token_result.Data); + var param = new ErpBillQueryParamDto("BOS_BillType"); + param.FieldKeys = "FBILLTYPEID,FNumber,FName"; + param.Limit = 10000; + param.FilterString = ""; + query.Data = JsonConvert.SerializeObject(param); + var json = JsonConvert.SerializeObject(query); + + //4.请求查询接口 + var result_json = await _client.ExecuteBillQueryAsync(json); + var result = JsonConvert.DeserializeObject>>(result_json); + + //5.返回数据的组装 + var erp_list = new List(); + foreach (var item in result) + { + var lis = new ErpBaseDto(); + lis.Id = item[0]; + lis.Number = item[1]; + lis.Name = item[2]; + + erp_list.Add(lis); + } + return ResultList.ReSuccess(erp_list); + } + catch (Exception ex) + { + return ResultList.ReFailure(ResultCodes.Erp_BillQuery_Error); + } + } + + /// + /// erp:单据查询-物料集合 + /// + /// + public async Task> BillQueryForMaterial(bool isCache = true) + { + try + { + if (isCache) + { + //1.获取缓存中的物料数据; + var materials = _memoryCache.Get>(_erpOptions.cache_materail_key); + if (materials == null || materials.Count == 0) + { + var mats = await _materialsRepositories.GetEntityList(); + if (mats == null || mats.Count == 0) + return await this.BillQueryForMaterialPagedList(); + else + { + var beginTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); + _logger.LogInformation($"物料拉取-开始时间:{beginTime}"); + //组装dto + var erp_materials_list = mats.Select(x => _mapper.Map(x)).ToList(); + _memoryCache.Set(_erpOptions.cache_materail_key, erp_materials_list, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromMinutes(DateTimeUtil.GetTotalMinutesTimeSpan()))); + var endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); + _logger.LogInformation($"物料拉取-结束时间:{endTime}"); + return ResultList.ReSuccess(erp_materials_list); + } + + } + else + return ResultList.ReSuccess(materials); + } + else + return await this.BillQueryForMaterialPagedList(); + } + catch (Exception ex) + { + _logger.LogInformation($"物料拉取-> 错误信息:" + ex.Message); + return ResultList.ReFailure(ResultCodes.ErpMaterialError); + } + + + } + /// + /// 获取物料id32进制 + /// + /// + /// + /// + public async Task> BillQueryForMaterialByNumbers(List materialNumbers) + { + //2.先登录金蝶-拿到token + var token_result = await this.Init(); + if (!token_result.IsSuccess) + return ResultList.ReFailure(token_result); + + + //3.获取金蝶物料:拼接参数和条件 + var query = new ErpBillQueryDto(token_result.Data); + var param = new ErpBillQueryParamDto(FormIdParam.BD_MATERIAL.ToString()); + param.FieldKeys = "FMATERIALID,FName,FNumber,FSpecification,FBaseUnitId,FBaseUnitId.FName,FBaseUnitId.FNumber,FBARCODE,FUseOrgId,FUseOrgId.FNumber,FIsBatchManage,FProductIDS"; + param.Limit = 10000; + + //查询条件:备注其中的条件值以金蝶的值为准!!! + //1.审核状态:已审核 + //2.禁用状态:A否,B是 + //3.使用组织:只查询“深圳市元创时代科技有限公司”这个组织;组织ID=100008--固定值查询(测试端和正式是一样的) + //param.FilterString = "FDocumentStatus='C' and FForbidStatus='A' and (FUseOrgId=19162897 or FUseOrgId=100008)"; + + + param.OrderString = "FCreateDate ASC"; + + //4.循环拿金蝶数据 + var erp_materials_list = new List(); + var error_josn = ""; + decimal d_count = Convert.ToDecimal(materialNumbers.Count()) / Convert.ToDecimal(100); + int count = (int)Math.Ceiling(d_count); + try + { + for(int i=1;i<= count;i++) + { + param.FilterString = "FDocumentStatus='C' and FForbidStatus='A' and FUseOrgId=100008"; + + var list = materialNumbers.Skip((i - 1) * 100).Take(100); + string numbers = JsonConvert.SerializeObject(list); + numbers = numbers.Replace("[", "").Replace("]", "").Replace("\"", "'"); + param.FilterString += $" and FNumber in ({numbers}) and (FProductIDS<>'' or FProductIDS<>' ')"; + + + //4.2.参数json化 + query.Data = JsonConvert.SerializeObject(param); + var json = JsonConvert.SerializeObject(query); + + //4.3.请求查询接口并返回数据 + var result_json = await _client.ExecuteBillQueryAsync(json); + error_josn = result_json; + var result = JsonConvert.DeserializeObject>>(result_json); + //4.4.判断数据是否全部拉取完成:并停止循环的条件 + if (result == null || result.Count == 0) + break; + //4.5.拼装 + foreach (var item in result) + { + var lis = new ErpMaterialDto(); + lis.MaterialId = Convert.ToInt32(item[0]); + lis.MaterialName = item[1]; + lis.MaterialNumber = item[2]; + lis.Specifications = item[3]; + lis.BaseUnitId = Convert.ToInt32(item[4]); + lis.BaseUnitName = item[5]; + lis.BaseUnitNumber = item[6]; + lis.BarCode = item[7]; + lis.OrgId = Convert.ToInt32(item[8]); + lis.OrgCode = item[9]; + lis.IsBatchManage = Convert.ToBoolean(item[10]); + lis.IdConvertBar = item[11].Trim(); + erp_materials_list.Add(lis); + } + } + return ResultList.ReSuccess(erp_materials_list); + } + catch (Exception ex) + { + _logger.LogInformation("物料拉取->失败:" + ex.Message + " " + error_josn); + return ResultList.ReFailure(ResultCodes.ErpSynsError); + } + } + /// + /// erp:基础数据-物料信息 + /// + /// + /// + public async Task> BillQueryForMaterial(int id) + { + //1.获取缓存中的物料数据 + var materials = _memoryCache.Get>(_erpOptions.cache_materail_key); + if (materials == null || materials.Count == 0) + return Result.ReSuccess(null); + //2.通过ID取当前物料列表中的 + var mater = materials.Where(x => x.MaterialId == id).FirstOrDefault(); + if (mater == null) + { + //2.1没有的话:去金蝶取 + mater = await this.BillQueryForMaterialById(id); + if (mater != null) + { + //把取到的数据放集合中并重新给缓存 + materials.Add(mater); + _memoryCache.Set(_erpOptions.cache_materail_key, materials, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromMinutes(DateTimeUtil.GetTotalMinutesTimeSpan()))); + return Result.ReSuccess(mater); + + } + else + return Result.ReSuccess(null); + } + return Result.ReSuccess(mater); + + } + /// + /// erp:基础数据-物料信息 + /// + /// + /// + public async Task> BillQueryForMaterial(string number) + { + //1.获取缓存中的物料数据 + var materials = _memoryCache.Get>(_erpOptions.cache_materail_key); + if (materials == null || materials.Count == 0) + return Result.ReSuccess(null); + //2.通过ID取当前物料列表中的 + var mater = materials.Where(x => x.MaterialNumber == number).FirstOrDefault(); + if (mater == null) + { + //2.1没有的话:去金蝶取 + mater = await this.BillQueryForMaterialByNumber(number); + if (mater != null) + { + //把取到的数据放集合中并重新给缓存 + materials.Add(mater); + _memoryCache.Set(_erpOptions.cache_materail_key, materials, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromMinutes(DateTimeUtil.GetTotalMinutesTimeSpan()))); + return Result.ReSuccess(mater); + + } + else + return Result.ReSuccess(null); + } + return Result.ReSuccess(mater); + } + /// + /// erp:基础数据-物料-分页查询 + /// + /// + private async Task> BillQueryForMaterialPagedList() + { + //2.先登录金蝶-拿到token + var token_result = await this.Init(); + if (!token_result.IsSuccess) + return ResultList.ReFailure(token_result); + + //3.获取金蝶物料:拼接参数和条件 + var query = new ErpBillQueryDto(token_result.Data); + var param = new ErpBillQueryParamDto(FormIdParam.BD_MATERIAL.ToString()); + param.FieldKeys = "FMATERIALID,FName,FNumber,FSpecification,FBaseUnitId,FBaseUnitId.FName,FBaseUnitId.FNumber,FBARCODE,FUseOrgId,FUseOrgId.FNumber,FIsBatchManage,FProductIDS"; + param.Limit = 10000; + + //查询条件:备注其中的条件值以金蝶的值为准!!! + //1.审核状态:已审核 + //2.禁用状态:A否,B是 + //3.使用组织:只查询“深圳市元创时代科技有限公司”这个组织;组织ID=100008--固定值查询(测试端和正式是一样的) + //param.FilterString = "FDocumentStatus='C' and FForbidStatus='A' and (FUseOrgId=19162897 or FUseOrgId=100008)"; + param.FilterString = "FDocumentStatus='C' and FForbidStatus='A' and FUseOrgId=100008"; + param.OrderString = "FCreateDate ASC"; + + //4.循环拿金蝶数据 + bool isHave = true; + var erp_materials_list = new List(); + int skip = 0; + var beginTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); + _logger.LogInformation($"物料拉取-开始时间:{beginTime}"); + var error_josn = ""; + try + { + while (isHave) + { + //4.1.页码:页码按照金蝶的要求从0开始 + param.StartRow = (Convert.ToInt32(skip) * param.Limit); + //4.2.参数json化 + query.Data = JsonConvert.SerializeObject(param); + var json = JsonConvert.SerializeObject(query); + + //4.3.请求查询接口并返回数据 + var result_json = await _client.ExecuteBillQueryAsync(json); + error_josn = result_json; + var result = JsonConvert.DeserializeObject>>(result_json); + //4.4.判断数据是否全部拉取完成:并停止循环的条件 + if (result == null || result.Count == 0) + isHave = false; + //4.5.拼装 + foreach (var item in result) + { + var lis = new ErpMaterialDto(); + lis.MaterialId = Convert.ToInt32(item[0]); + lis.MaterialName = item[1]; + lis.MaterialNumber = item[2]; + lis.Specifications = item[3]; + lis.BaseUnitId = Convert.ToInt32(item[4]); + lis.BaseUnitName = item[5]; + lis.BaseUnitNumber = item[6]; + lis.BarCode = item[7]; + lis.OrgId = Convert.ToInt32(item[8]); + lis.OrgCode = item[9]; + lis.IsBatchManage = Convert.ToBoolean(item[10]); + lis.IdConvertBar = item[11].Trim(); + erp_materials_list.Add(lis); + } + //4.6页面的叠加 + skip++; + } + var endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); + _logger.LogInformation($"物料拉取-结束时间:{endTime}"); + //5.物料集合进行缓存-当前缓存时间到当天晚上的0点,后面定时任务执行重新放入缓存 + _memoryCache.Set(_erpOptions.cache_materail_key, erp_materials_list, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromMinutes(DateTimeUtil.GetTotalMinutesTimeSpan()))); + _logger.LogInformation($"物料拉取-总条数:{erp_materials_list.Count}"); + return ResultList.ReSuccess(erp_materials_list); + } + catch (Exception ex) + { + _logger.LogInformation("物料拉取->失败:" + ex.Message + " " + error_josn); + return ResultList.ReFailure(ResultCodes.ErpSynsError); + } + + + } + + /// + /// erp:基础数据-物料-ids查询 + /// + /// + /// + private async Task BillQueryForMaterialById(int id) + { + //2.先登录金蝶-拿到token + var token_result = await this.Init(); + if (!token_result.IsSuccess) + return null; + + //3.获取金蝶物料:拼接参数和条件 + var query = new ErpBillQueryDto(token_result.Data); + var param = new ErpBillQueryParamDto(FormIdParam.BD_MATERIAL.ToString()); + param.FieldKeys = "FMATERIALID,FName,FNumber,FSpecification,FBaseUnitId,FBaseUnitId.FName,FBaseUnitId.FNumber,FBARCODE,FUseOrgId,FUseOrgId.FNumber,FIsBatchManage,FProductIDS"; + param.Limit = 10000; + + //查询条件:备注其中的条件值以金蝶的值为准!!! + //1.审核状态:已审核 + //2.禁用状态:A否,B是 + //3.使用组织:只查询“深圳市元创时代科技有限公司”这个组织;组织ID=100008--固定值查询(测试端和正式是一样的)---按ID查询就不需要固定组织条件了 + param.FilterString = "FDocumentStatus='C' and FForbidStatus='A'"; + param.OrderString = "FCreateDate ASC"; + + //根据物料ID查询 + param.FilterString = param.FilterString + $" and FMATERIALID={id}"; + + //4.循环拿金蝶数据 + var erp_materials_list = new List(); + + //4.2.参数json化 + query.Data = JsonConvert.SerializeObject(param); + var json = JsonConvert.SerializeObject(query); + + var error_josn = ""; + try + { + //4.3.请求查询接口并返回数据 + var result_json = await _client.ExecuteBillQueryAsync(json); + error_josn = result_json; + var result = JsonConvert.DeserializeObject>>(result_json); + //4.5.拼装 + foreach (var item in result) + { + var lis = new ErpMaterialDto(); + lis.MaterialId = Convert.ToInt32(item[0]); + lis.MaterialName = item[1]; + lis.MaterialNumber = item[2]; + lis.Specifications = item[3]; + lis.BaseUnitId = Convert.ToInt32(item[4]); + lis.BaseUnitName = item[5]; + lis.BaseUnitNumber = item[6]; + lis.BarCode = item[7]; + lis.OrgId = Convert.ToInt32(item[8]); + lis.OrgCode = item[9]; + lis.IsBatchManage = Convert.ToBoolean(item[10]); + lis.IdConvertBar = item[11].Trim(); + erp_materials_list.Add(lis); + } + if (erp_materials_list.Count == 0) + return null; + else + return erp_materials_list.FirstOrDefault(); + } + catch (Exception) + { + _logger.LogInformation("物料拉取按ID->错误的Json:" + error_josn); + return null; + } + + } + /// + /// erp:基础数据-物料-number查询 + /// + /// + /// + public async Task BillQueryForMaterialByNumber(string number) + { + if (string.IsNullOrEmpty(number)) return null; + //2.先登录金蝶-拿到token + var token_result = await this.Init(); + if (!token_result.IsSuccess) + return null; + + //3.获取金蝶物料:拼接参数和条件 + var query = new ErpBillQueryDto(token_result.Data); + var param = new ErpBillQueryParamDto(FormIdParam.BD_MATERIAL.ToString()); + param.FieldKeys = "FMATERIALID,FName,FNumber,FSpecification,FBaseUnitId,FBaseUnitId.FName,FBaseUnitId.FNumber,FBARCODE,FUseOrgId,FUseOrgId.FNumber,FIsBatchManage,FProductIDS"; + param.Limit = 10000; + + //查询条件:备注其中的条件值以金蝶的值为准!!! + //1.审核状态:已审核 + //2.禁用状态:A否,B是 + //3.使用组织:只查询“深圳市元创时代科技有限公司”这个组织;组织ID=100008--固定值查询(测试端和正式是一样的)---按ID查询就不需要固定组织条件了 + param.FilterString = "FDocumentStatus='C' and FForbidStatus='A'"; + param.OrderString = "FCreateDate ASC"; + + //根据物料ID查询 + param.FilterString = param.FilterString + $" and FNumber='{number}'"; + + //4.循环拿金蝶数据 + var erp_materials_list = new List(); + + //4.2.参数json化 + query.Data = JsonConvert.SerializeObject(param); + var json = JsonConvert.SerializeObject(query); + + var error_josn = ""; + try + { + //4.3.请求查询接口并返回数据 + var result_json = await _client.ExecuteBillQueryAsync(json); + error_josn = result_json; + var result = JsonConvert.DeserializeObject>>(result_json); + //4.5.拼装 + foreach (var item in result) + { + var lis = new ErpMaterialDto(); + lis.MaterialId = Convert.ToInt32(item[0]); + lis.MaterialName = item[1]; + lis.MaterialNumber = item[2]; + lis.Specifications = item[3]; + lis.BaseUnitId = Convert.ToInt32(item[4]); + lis.BaseUnitName = item[5]; + lis.BaseUnitNumber = item[6]; + lis.BarCode = item[7]; + lis.OrgId = Convert.ToInt32(item[8]); + lis.OrgCode = item[9]; + lis.IsBatchManage = Convert.ToBoolean(item[10]); + lis.IdConvertBar = item[11].Trim(); + erp_materials_list.Add(lis); + } + if (erp_materials_list.Count == 0) + return null; + else + return erp_materials_list.FirstOrDefault(); + } + catch (Exception) + { + _logger.LogInformation("物料拉取按Number->错误的Json:" + error_josn + ";参数:" + json); + return null; + } + + } + + public async Task BillQueryForMaterialByNumber(string number, string orgCode) + { + if (string.IsNullOrEmpty(number)) return null; + //2.先登录金蝶-拿到token + var token_result = await this.Init(); + if (!token_result.IsSuccess) + return null; + + //3.获取金蝶物料:拼接参数和条件 + var query = new ErpBillQueryDto(token_result.Data); + var param = new ErpBillQueryParamDto(FormIdParam.BD_MATERIAL.ToString()); + param.FieldKeys = "FMATERIALID,FName,FNumber,FSpecification,FBaseUnitId,FBaseUnitId.FName,FBaseUnitId.FNumber,FBARCODE,FUseOrgId,FUseOrgId.FNumber,FIsBatchManage,FProductIDS"; + param.Limit = 10000; + + //查询条件:备注其中的条件值以金蝶的值为准!!! + //1.审核状态:已审核 + //2.禁用状态:A否,B是 + //3.使用组织:只查询“深圳市元创时代科技有限公司”这个组织;组织ID=100008--固定值查询(测试端和正式是一样的)---按ID查询就不需要固定组织条件了 + param.FilterString = "FDocumentStatus='C' and FForbidStatus='A'"; + param.OrderString = "FCreateDate ASC"; + + //根据物料ID查询 + param.FilterString = param.FilterString + $" and FNumber='{number}' and FUseOrgId.FNumber='{orgCode}'"; + + //4.循环拿金蝶数据 + var erp_materials_list = new List(); + + //4.2.参数json化 + query.Data = JsonConvert.SerializeObject(param); + var json = JsonConvert.SerializeObject(query); + + var error_josn = ""; + try + { + //4.3.请求查询接口并返回数据 + var result_json = await _client.ExecuteBillQueryAsync(json); + error_josn = result_json; + var result = JsonConvert.DeserializeObject>>(result_json); + //4.5.拼装 + foreach (var item in result) + { + var lis = new ErpMaterialDto(); + lis.MaterialId = Convert.ToInt32(item[0]); + lis.MaterialName = item[1]; + lis.MaterialNumber = item[2]; + lis.Specifications = item[3]; + lis.BaseUnitId = Convert.ToInt32(item[4]); + lis.BaseUnitName = item[5]; + lis.BaseUnitNumber = item[6]; + lis.BarCode = item[7]; + lis.OrgId = Convert.ToInt32(item[8]); + lis.OrgCode = item[9]; + lis.IsBatchManage = Convert.ToBoolean(item[10]); + lis.IdConvertBar = item[11].Trim(); + erp_materials_list.Add(lis); + } + if (erp_materials_list.Count == 0) + return null; + else + return erp_materials_list.FirstOrDefault(); + } + catch (Exception ex) + { + _logger.LogInformation($"物料拉取按Number->错误的Json:" + error_josn + ";参数:" + json + " 错误信息:" + ex.Message); + return null; + } + + } + + /// + /// erp:单据查询-组织数据 + /// + /// + public async Task> BillQueryForOrg() + { + string result_json = ""; + try + { + //1.获取缓存中的组织数据; + var orgs = _memoryCache.Get>(_erpOptions.cache_org_key); + if (orgs == null || orgs.Count == 0) + { + + //2.先登录金蝶-拿到token + var token_result = await this.Init(); + if (!token_result.IsSuccess) + return ResultList.ReFailure(token_result); + + //3.获取金蝶组织:拼接参数和条件 + var query = new ErpBillQueryDto(token_result.Data); + var param = new ErpBillQueryParamDto(FormIdParam.ORG_Organizations.ToString()); + param.FieldKeys = "FOrgID,FNumber,FName"; + param.Limit = 10000; + //查询条件:备注其中的条件值以金蝶的值为准!!! + param.FilterString = ""; + + //备注:因为组织数据不是很多,就不能和获取物料一样循环获取;组织这里就获取10000条数据就行了 + var beginTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); + _logger.LogInformation($"组织拉取-开始时间yzh:{beginTime}"); + //4.参数json化 + query.Data = JsonConvert.SerializeObject(param); + var json = JsonConvert.SerializeObject(query); + + //5.请求查询接口并返回数据 + result_json = await _client.ExecuteBillQueryAsync(json); + var result = JsonConvert.DeserializeObject>>(result_json); + + var endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); + _logger.LogInformation($"组织拉取-结束时间yzh20250418(2):{endTime}"); + //6.拼装 + var list = new List(); + foreach (var item in result) + { + var lis = new ErpOrgDto(); + lis.Id = int.Parse(item[0]); + lis.Number = item[1]; + lis.Name = item[2]; + list.Add(lis); + + } + //5.组织集合进行缓存 + _memoryCache.Set(_erpOptions.cache_org_key, list, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromMinutes(DateTimeUtil.GetTotalMinutesTimeSpan()))); + + return ResultList.ReSuccess(list); + + } + else + { + return ResultList.ReSuccess(orgs); + } + + } + catch (Exception ex) + { + _logger.LogError($"金蝶组织拉取异常yzh{ex.Message}{result_json}"); + return ResultList.ReFailure(ResultCodes.ErpOrgError); + } + } + + /// + /// erp:供应商 + /// + /// + public async Task> BillQueryForSupplier() + { + string result_json = ""; + try + { + //1.获取缓存中的供应商数据; + var suppliers = _memoryCache.Get>(_erpOptions.cache_supplier_key); + if (suppliers == null || suppliers.Count == 0) + { + + //2.先登录金蝶-拿到token + var token_result = await this.Init(); + if (!token_result.IsSuccess) + return ResultList.ReFailure(token_result); + + //3.获取金蝶供应商:拼接参数和条件 + var query = new ErpBillQueryDto(token_result.Data); + var param = new ErpBillQueryParamDto(FormIdParam.BD_Supplier.ToString()); + param.FieldKeys = "FSupplierId,FNumber,FName,FUseOrgId.FNumber"; + + int skip = 1; + param.Limit = 10000; + var list = new List(); + while (true) + { + param.StartRow = (Convert.ToInt32(skip) * param.Limit); + //查询条件:备注其中的条件值以金蝶的值为准!!! + //param.FilterString = "FUseOrgId=100008"; + //param.FilterString = "(FUseOrgId = 100008 or FUseOrgId = 19162897)"; + + //备注:因为供应商数据不是很多,就不能和获取物料一样循环获取;组织这里就获取10000条数据就行了 + var beginTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); + _logger.LogInformation($"供应商拉取-开始时间yzh:{beginTime}"); + //4.参数json化 + query.Data = JsonConvert.SerializeObject(param); + var json = JsonConvert.SerializeObject(query); + + //5.请求查询接口并返回数据 + result_json = await _client.ExecuteBillQueryAsync(json); + var result = JsonConvert.DeserializeObject>>(result_json); + //4.4.判断数据是否全部拉取完成:并停止循环的条件 + if (result == null || result.Count == 0) + break; + var endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); + _logger.LogInformation($"供应商拉取-结束时间yzh:{endTime}"); + + foreach (var item in result) + { + var lis = new ErpSupplierDto(); + lis.Id = int.Parse(item[0]); + lis.Number = item[1]; + lis.Name = item[2]; + lis.OrgCode = item[3]; + list.Add(lis); + + } + skip++; + } + //5.供应商集合进行缓存 + _memoryCache.Set(_erpOptions.cache_supplier_key, list, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromMinutes(DateTimeUtil.GetTotalMinutesTimeSpan()))); + + return ResultList.ReSuccess(list); + + } + else + { + return ResultList.ReSuccess(suppliers); + } + + } + catch (Exception ex) + { + _logger.LogError($"金蝶供应商拉取异常{ex.Message} {result_json}"); + return ResultList.ReFailure(ResultCodes.ErpSupplierError); + } + } + /// + /// 客户 + /// + /// + public async Task> BillQueryForCustomer() + { + try + { + //1.获取缓存中的供应商数据; + var customers = _memoryCache.Get>(_erpOptions.cache_customer_key); + if (customers == null || customers.Count == 0) + { + + //2.先登录金蝶-拿到token + var token_result = await this.Init(); + if (!token_result.IsSuccess) + return ResultList.ReFailure(token_result); + + //3.获取金蝶供应商:拼接参数和条件 + var query = new ErpBillQueryDto(token_result.Data); + var param = new ErpBillQueryParamDto(FormIdParam.BD_Customer.ToString()); + param.FieldKeys = "FCUSTID,FNumber,FName"; + param.Limit = 10000; + //查询条件:备注其中的条件值以金蝶的值为准!!! + param.FilterString = ""; + var list = new List(); + //备注:因为供应商数据不是很多,就不能和获取物料一样循环获取;组织这里就获取10000条数据就行了 + var beginTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); + _logger.LogInformation($"客户拉取-开始时间yzh:{beginTime}"); + int skip = 0; + //4.参数json化 + while (true) + { + //4.1.页码:页码按照金蝶的要求从0开始 + param.StartRow = (Convert.ToInt32(skip) * param.Limit); + + query.Data = JsonConvert.SerializeObject(param); + var json = JsonConvert.SerializeObject(query); + + //5.请求查询接口并返回数据 + var result_json = await _client.ExecuteBillQueryAsync(json); + var result = JsonConvert.DeserializeObject>>(result_json); + + if (result == null || result.Count == 0) + break; + + //6.拼装 + foreach (var item in result) + { + var lis = new ErpCustomerDto(); + lis.Id = int.Parse(item[0]); + lis.Number = item[1]; + lis.Name = item[2]; + list.Add(lis); + + } + //4.6页面的叠加 + skip++; + } + var endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); + _logger.LogInformation($"客户拉取-结束时间yzh:{endTime}"); + //5.供应商集合进行缓存 + _memoryCache.Set(_erpOptions.cache_customer_key, list, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromMinutes(DateTimeUtil.GetTotalMinutesTimeSpan()))); + _logger.LogInformation($"客户拉取-总条数yzh:{list.Count}"); + return ResultList.ReSuccess(list); + + } + else + { + return ResultList.ReSuccess(customers); + } + + } + catch (Exception) + { + return ResultList.ReFailure(ResultCodes.ErpSupplierError); + } + } + /// + /// erp:仓库 + /// + /// + public async Task> BillQueryForStock() + { + try + { + //1.获取缓存中的仓库数据; + var stocks = _memoryCache.Get>(_erpOptions.cache_stock_key); + if (stocks == null || stocks.Count == 0) + { + //2.先登录金蝶-拿到token + var token_result = await this.Init(); + if (!token_result.IsSuccess) + return ResultList.ReFailure(token_result); + //3.获取金蝶仓库:拼接参数和条件 + var query = new ErpBillQueryDto(token_result.Data); + var param = new ErpBillQueryParamDto(FormIdParam.BD_STOCK.ToString()); + param.FieldKeys = "FStockId,FName,FNumber,FUseOrgId,FUseOrgId.FNumber"; + param.Limit = 10000; + //查询条件:备注其中的条件值以金蝶的值为准!!! + param.FilterString = ""; + //备注:因为供应商数据不是很多,就不能和获取物料一样循环获取;组织这里就获取10000条数据就行了 + var beginTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); + _logger.LogInformation($"仓库拉取-开始时间yzh:{beginTime}"); + //4.参数json化 + query.Data = JsonConvert.SerializeObject(param); + var json = JsonConvert.SerializeObject(query); + //5.请求查询接口并返回数据 + var result_json = await _client.ExecuteBillQueryAsync(json); + var result = JsonConvert.DeserializeObject>>(result_json); + //6.拼装 + var list = new List(); + foreach (var item in result) + { + var lis = new ErpStockDto(); + lis.Id = int.Parse(item[0]); + lis.Name = item[1]; + lis.Code = item[2]; + lis.OrgId = Convert.ToInt32(item[3]); + lis.OrgCode = item[4]; + list.Add(lis); + + } + //5.供应商集合进行缓存 + _memoryCache.Set(_erpOptions.cache_stock_key, list, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromDays(3))); + _logger.LogInformation($"仓库拉取-总条数yzh:{list.Count}"); + return ResultList.ReSuccess(list); + } + else + { + return ResultList.ReSuccess(stocks); + } + + } + catch (Exception) + { + return ResultList.ReFailure(ResultCodes.ErpStockError); + } + } + /// + /// 根据仓库编码获取仓位 + /// + /// + /// + public async Task> BillQueryForSubStock() + { + try + { + //1.获取缓存中的仓库数据; + var stocks = _memoryCache.Get>(_erpOptions.cache_substock_key); + if (stocks == null || stocks.Count == 0) + { + var token_result = await this.Init(); + if (!token_result.IsSuccess) + return ResultList.ReFailure(token_result); + var query = new ErpBillQueryDto(token_result.Data); + var param = new ErpBillQueryParamDto(FormIdParam.BD_STOCK.ToString()); + param.FieldKeys = "FStockFlexDetail_FDetailID,FFlexEntryName,FFlexEntryId.FNumber,FUseOrgId.FNumber,FNumber"; + param.Limit = 100000; + param.FilterString = $"FNumber='HD' or FNumber='GD'";//FNumber='C' + query.Data = JsonConvert.SerializeObject(param); + var json = JsonConvert.SerializeObject(query); + + var result_json = await _client.ExecuteBillQueryAsync(json); + var result = JsonConvert.DeserializeObject>>(result_json); + + var list = new List(); + foreach (var item in result) + { + var lis = new Erp_SubStockDto(); + if (item[0] == "0") continue; + lis.Id = int.Parse(item[0]); + lis.Name = item[1]; + lis.Code = item[2]; + lis.OrgCode = item[3]; + lis.StockCode = item[4]; + list.Add(lis); + + } + //5.供应商集合进行缓存 只有查询全部的时候才缓存 + _memoryCache.Set(_erpOptions.cache_substock_key, list, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromDays(3))); + _logger.LogInformation($"子仓库拉取-总条数:{list.Count}"); + return ResultList.ReSuccess(list); + } + else + { + return ResultList.ReSuccess(stocks); + } + } + catch (Exception) + { + return ResultList.ReFailure(ResultCodes.ErpSubStockError); + } + } + + #region 金蝶操作交互 + /// + /// 同步数据(保存提交审核) + /// + /// + /// + /// + public async Task> Save(T dto, string formId) + { + try + { + var token_result = await this.Init(); + if (!token_result.IsSuccess) + return Result.ReFailure(token_result.Message, token_result.Status); + var query = new ErpBillQueryDto(token_result.Data, formId); + var param = new ErpSave(formId, dto); + query.Data = JsonConvert.SerializeObject(param); + + //保存 + var result_json = await _client.SaveAsync(JsonConvert.SerializeObject(query)); + + _logger.LogInformation("入库单->开始同步金蝶:保存参数" + JsonConvert.SerializeObject(query) + " 结果->" + result_json); + + JObject jobject = (JObject)JsonConvert.DeserializeObject(result_json); + + if (jobject["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToLower() == "true") + { + //保存成功后返回number 后续操作根据Id操作 + string number = jobject["Result"]["ResponseStatus"]["SuccessEntitys"][0]["Number"].ToString(); + return Result.ReSuccess(number); + } + + var msg = jobject["Result"]["ResponseStatus"]["Errors"][0]["Message"].ToString(); + return Result.ReFailure(msg, 10002); + } + catch (Exception ex) + { + return Result.ReFailure(ex.ToString(), 10002); + } + } + /// + /// 提交 + /// + /// + /// + /// + public async Task Submit(ErpOperateDto dto, string formId) + { + try + { + var token_result = await this.Init(); + if (!token_result.IsSuccess) + return token_result; + var query = new ErpBillQueryDto(token_result.Data, formId); + + //提交 + query.Data = JsonConvert.SerializeObject(dto); + var result_json = await _client.SubmitAsync(JsonConvert.SerializeObject(query)); + _logger.LogInformation("入库单->开始同步金蝶:提交参数" + JsonConvert.SerializeObject(query) + " 结果->" + result_json); + JObject jobject = (JObject)JsonConvert.DeserializeObject(result_json); + + if (jobject["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToLower() == "true") + return Result.ReSuccess(); + + var msg = jobject["Result"]["ResponseStatus"]["Errors"][0]["Message"].ToString(); + return Result.ReFailure(msg, 10002); + } + catch (Exception ex) + { + return Result.ReFailure(ex.ToString(), 10002); + } + } + /// + /// 审核 + /// + /// + /// + /// + public async Task Audit(ErpOperateDto dto, string formId) + { + try + { + var token_result = await this.Init(); + if (!token_result.IsSuccess) + return token_result; + var query = new ErpBillQueryDto(token_result.Data, formId); + + //提交 + query.Data = JsonConvert.SerializeObject(dto); + var result_json = await _client.AuditAsync(JsonConvert.SerializeObject(query)); + _logger.LogInformation("入库单->开始同步金蝶:审核参数" + JsonConvert.SerializeObject(query) + " 结果->" + result_json); + JObject jobject = (JObject)JsonConvert.DeserializeObject(result_json); + + if (jobject["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToLower() == "true") + return Result.ReSuccess(); + + var msg = jobject["Result"]["ResponseStatus"]["Errors"][0]["Message"].ToString(); + return Result.ReFailure(msg, 10002); + } + catch (Exception ex) + { + return Result.ReFailure(ex.ToString(), 10002); + } + } + /// + /// 反审核 + /// + /// + /// + /// + public async Task NoAudit(ErpOperateDto dto, string formId) + { + try + { + var token_result = await this.Init(); + if (!token_result.IsSuccess) + return token_result; + var query = new ErpBillQueryDto(token_result.Data); + + //提交 + query.Data = JsonConvert.SerializeObject(dto); + var result_json = await _client.UnAuditAsync(JsonConvert.SerializeObject(query)); + JObject jobject = (JObject)JsonConvert.DeserializeObject(result_json); + var isSuccess = jobject["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToLower(); + + if (jobject["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToLower() == "true") + return Result.ReSuccess(); + + var msg = jobject["Result"]["ResponseStatus"]["Errors"][0]["Message"].ToString(); + return Result.ReFailure(msg, 10002); + } + catch (Exception ex) + { + return Result.ReFailure(ex.ToString(), 10002); + } + } + /// + /// 删除 + /// + /// + /// + /// + public async Task Delete(ErpOperateDto dto, string formId) + { + try + { + var token_result = await this.Init(); + if (!token_result.IsSuccess) + return token_result; + var query = new ErpBillQueryDto(token_result.Data); + + //提交 + query.Data = JsonConvert.SerializeObject(dto); + var result_json = await _client.DeleteAsync(JsonConvert.SerializeObject(query)); + JObject jobject = (JObject)JsonConvert.DeserializeObject(result_json); + var isSuccess = jobject["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToLower(); + + if (jobject["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToLower() == "true") + return Result.ReSuccess(); + + var msg = jobject["Result"]["ResponseStatus"]["Errors"][0]["Message"].ToString(); + return Result.ReFailure(msg, 10002); + } + catch (Exception ex) + { + return Result.ReFailure(ex.ToString(), 10002); + } + } + /// + /// 下推 + /// + /// + /// + public async Task> Push(ErpPushDto dto) + { + try + { + var token_result = await this.Init(); + if (!token_result.IsSuccess) + return token_result; + var query = new ErpBillQueryDto(token_result.Data, dto.FormId); + query.Data = JsonConvert.SerializeObject(dto); + //下推 + string json = JsonConvert.SerializeObject(query); + var result_json = await _client.PushAsync(json); + _logger.LogInformation("入库单->开始同步金蝶:下推参数" + json + " 结果->" + result_json); + JObject jobject = (JObject)JsonConvert.DeserializeObject(result_json); + var isSuccess = jobject["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToLower(); + + if (jobject["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToLower() == "true") + { + //保存成功后返回Id 后续操作根据Id操作 + string id = jobject["Result"]["ResponseStatus"]["SuccessEntitys"][0]["Id"].ToString(); + return Result.ReSuccess(id); + } + + var msg = jobject["Result"]["ResponseStatus"]["Errors"][0]["Message"].ToString(); + return Result.ReFailure(msg, 10002); + } + catch (Exception ex) + { + return Result.ReFailure(ex.ToString(), 10002); + } + } + #endregion + + + } +} diff --git a/src/BarCode.Web.Domain/Services/Public/HostedService.cs b/src/BarCode.Web.Domain/Services/Public/HostedService.cs new file mode 100644 index 0000000..d97b8a5 --- /dev/null +++ b/src/BarCode.Web.Domain/Services/Public/HostedService.cs @@ -0,0 +1,55 @@ +using BarCode.Web.Domain.IService.Public; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Domain.Services.Public +{ + public class HostedService : IHostedService + { + private readonly IServiceProvider _serviceProvider; + private readonly IErpService _erpService; + private readonly IServiceScopeFactory _serviceScopeFactory; + public HostedService(IServiceProvider serviceProvider, IServiceScopeFactory serviceScopeFactory) + { + _serviceProvider = serviceProvider; + _serviceScopeFactory = serviceScopeFactory; + } + public Task StartAsync(CancellationToken cancellationToken) + { + var scope = _serviceScopeFactory.CreateScope(); + var sercice = scope.ServiceProvider.GetRequiredService(); + Console.WriteLine("开始加载初始数据..."); + Task.Run(() => + { + //异步-同步下物料数据 + sercice.BillQueryForMaterial().GetAwaiter().GetResult(); + Console.WriteLine("物料加载完成"); + }); + + Task.Run(() => + { + //异步-同步下组织数据 + sercice.BillQueryForOrg().GetAwaiter().GetResult(); + Console.WriteLine("组织加载完成"); + }); + + Task.Run(() => + { + //异步-同步下供应商数据 + sercice.BillQueryForSupplier().GetAwaiter().GetResult(); + Console.WriteLine("供应商加载完成"); + }); + return Task.CompletedTask; + } + + public Task StopAsync(CancellationToken cancellationToken) + { + throw new NotImplementedException(); + } + } +} diff --git a/src/BarCode.Web.Domain/Services/Public/HttpClientService.cs b/src/BarCode.Web.Domain/Services/Public/HttpClientService.cs new file mode 100644 index 0000000..b90d533 --- /dev/null +++ b/src/BarCode.Web.Domain/Services/Public/HttpClientService.cs @@ -0,0 +1,230 @@ +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Text; +using System.Text.Json; +using System.Threading.Tasks; +using BarCode.Web.Core.Exceptions; +using BarCode.Web.Domain.IService.Public; + +namespace BarCode.Web.Domain.Services.Public +{ + public class HttpClientService : IHttpClientService + { + private readonly IHttpClientFactory _clientFactory; + private readonly ILogger _logger; + private Dictionary headers; + private Dictionary contentHeaders; + public HttpClientService(IHttpClientFactory clientFactory, ILogger logger) + { + _clientFactory = clientFactory; + _logger = logger; + headers = new Dictionary(); + headers.Add("Accept", "application/json"); + headers.Add("User-Agent", "HttpClientFactory-Sample"); + + contentHeaders = new Dictionary(); + contentHeaders.Add("Content-Type", "application/json; charset=utf-8"); + + } + + /// + /// Get方法 + /// + /// + /// + /// + /// + /// + public async Task GetAsync(string url, int timeoutSecond = 180) + { + try + { + var client = BuildHttpClient(headers, timeoutSecond); + var response = await client.GetAsync(url); + //var responseContent = await response.Content.ReadAsStreamAsync();//1.相比ReadAsString这个方法返回要快点,效率高 + var responseContent = await response.Content.ReadAsStringAsync(); //2.当前使用这里是为了迎合错误信息观看 + if (response.IsSuccessStatusCode) + { + var t = JsonSerializer.Deserialize(responseContent, new JsonSerializerOptions { PropertyNameCaseInsensitive = true }); + //var t = await JsonSerializer.DeserializeAsync(responseContent, new JsonSerializerOptions { PropertyNameCaseInsensitive = true });//3.配合1的ReadAsStream使用 + return t; + } + + throw new WebHttpException(response.StatusCode.ToString(), "请求出错"); + } + catch (Exception ex) + { + _logger.LogError($"HttpGet:{url} Error:{ex.Message}"); + throw new Exception($"HttpGet:{url} Error", ex); + } + } + + /// + /// Get方法 + /// + /// + /// + /// + /// + /// + public async Task GetAsync(string url, Dictionary dicHeaders, int timeoutSecond = 180) + { + try + { + var client = BuildHttpClient(dicHeaders, timeoutSecond); + var response = await client.GetAsync(url); + //var responseContent = await response.Content.ReadAsStreamAsync();//1.相比ReadAsString这个方法返回要快点,效率高 + var responseContent = await response.Content.ReadAsStringAsync(); //2.当前使用这里是为了迎合错误信息观看 + if (response.IsSuccessStatusCode) + { + var t = JsonSerializer.Deserialize(responseContent, new JsonSerializerOptions { PropertyNameCaseInsensitive = true }); + //var t = await JsonSerializer.DeserializeAsync(responseContent, new JsonSerializerOptions { PropertyNameCaseInsensitive = true });//3.配合1的ReadAsStream使用 + return t; + } + + throw new WebHttpException(response.StatusCode.ToString(), "请求出错"); + } + catch (Exception ex) + { + _logger.LogError($"HttpGet:{url} Error:{ex.Message}"); + throw new Exception($"HttpGet:{url} Error", ex); + } + } + + /// + /// Post方法 + /// + /// + /// + /// + /// + /// + /// + public async Task PostAsync(string url, string requestBody, Dictionary dicHeaders, int timeoutSecond = 180) + { + var client = BuildHttpClient(dicHeaders, timeoutSecond); + var requestContent = GenerateStringContent(requestBody, contentHeaders); + var response = await client.PostAsync(url, requestContent); + var responseContent = await response.Content.ReadAsStringAsync(); + if (response.IsSuccessStatusCode) + { + var t = JsonSerializer.Deserialize(responseContent, new JsonSerializerOptions { PropertyNameCaseInsensitive = true }); + return t; + } + + _logger.LogError($"HttpGet:{url} Error:{responseContent}"); + throw new WebHttpException(response.StatusCode.ToString(), responseContent); + } + + /// + /// Post方法 + /// + /// + /// + /// + /// + /// + public async Task PostAsync(string url, string requestBody, int timeoutSecond = 180) + { + var client = BuildHttpClient(null, timeoutSecond); + var requestContent = GenerateStringContent(requestBody, contentHeaders); + var response = await client.PostAsync(url, requestContent); + var responseContent = await response.Content.ReadAsStringAsync(); + if (response.IsSuccessStatusCode) + { + var t = JsonSerializer.Deserialize(responseContent, new JsonSerializerOptions { PropertyNameCaseInsensitive = true }); + if (t == null) + _logger.LogInformation($"获取单点数据为空---{responseContent}"); + return t; + } + + _logger.LogError($"HttpGet:{url} Error:{responseContent}"); + throw new WebHttpException(response.StatusCode.ToString(), responseContent); + } + + /// + /// 公共http请求 + /// + /// + /// + /// + /// + /// + /// + /// + public async Task ExecuteAsync(string url, HttpMethod method, string requestBody, Dictionary dicHeaders, int timeoutSecond = 180) + { + var client = BuildHttpClient(null, timeoutSecond); + var request = GenerateHttpRequestMessage(url, requestBody, method, dicHeaders); + var response = await client.SendAsync(request); + var responseContent = await response.Content.ReadAsStringAsync(); + if (response.IsSuccessStatusCode) + { + var t = JsonSerializer.Deserialize(responseContent, new JsonSerializerOptions { PropertyNameCaseInsensitive = true }); + + return t; + } + + throw new WebHttpException(response.StatusCode.ToString(), responseContent); + } + + + /// + /// 设置HttpRequestMessage + /// + /// + /// + /// + /// + /// + private HttpRequestMessage GenerateHttpRequestMessage(string url, string requestBody, HttpMethod method, Dictionary dicHeaders) + { + var request = new HttpRequestMessage(method, url); + if (!string.IsNullOrEmpty(requestBody)) request.Content = new StringContent(requestBody); + if (dicHeaders != null) + foreach (var headerItme in dicHeaders) + request.Headers.Add(headerItme.Key, headerItme.Value); + return request; + } + + /// + /// 设置请求内容 + /// + /// + /// + /// + private StringContent GenerateStringContent(string requestBody, Dictionary dicHeaders) + { + var content = new StringContent(requestBody); + if (dicHeaders != null) + content.Headers.Remove("content-type"); + foreach (var headerItme in dicHeaders) + content.Headers.Add(headerItme.Key, headerItme.Value); + return content; + } + + + /// + /// 设置请求头和超时时间:返回client + /// + /// + /// + /// + public HttpClient BuildHttpClient(Dictionary dicDefaultHeaders, int? timeoutSecond=180) + { + var httpClient = _clientFactory.CreateClient("ops_client"); + httpClient.DefaultRequestHeaders.Clear(); //为了使客户端不受最后一个请求的影响,它需要清除DefaultRequestHeaders + httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); + if (dicDefaultHeaders != null) + foreach (var headItem in dicDefaultHeaders) + if (!httpClient.DefaultRequestHeaders.Contains(headItem.Key)) + httpClient.DefaultRequestHeaders.Add(headItem.Key, headItem.Value); + + if (timeoutSecond != null) httpClient.Timeout = TimeSpan.FromSeconds(timeoutSecond.Value); + return httpClient; + } + } +} diff --git a/src/BarCode.Web.Domain/Services/Public/LoginService.cs b/src/BarCode.Web.Domain/Services/Public/LoginService.cs new file mode 100644 index 0000000..ef6acff --- /dev/null +++ b/src/BarCode.Web.Domain/Services/Public/LoginService.cs @@ -0,0 +1,567 @@ +using AutoMapper; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Json; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using BarCode.Web.Core.Dto.Login; +using BarCode.Web.Core.Dto.Login.Temp; +using BarCode.Web.Core.Dto.Login.Temp.v3; +using BarCode.Web.Core.Dto.SingleData; +using BarCode.Web.Core.Help; +using BarCode.Web.Core.Internal.Results; +using BarCode.Web.Core.Internal.Security; +using BarCode.Web.Domain.IService.Public; +using BarCode.Web.Domain.Options; +using BarCode.Web.Domain.Values.Single; +using BarCode.Web.Core.Dto.Erp; + +namespace BarCode.Web.Domain.Services.Public +{ + public class LoginService : ILoginService + { + private IMapper _mapper; + private SoaOptions _soaOptions; + private ILogger _logger; + private HttpClientHelp _httpClientHelp; + private readonly ISingleDataService _singleDataService; + private readonly RedisClientService _redisClientService; + public LoginService( + IMapper mapper, + IOptions soaOptions, + ILogger logger, + HttpClientHelp httpClientHelp, + ISingleDataService singleDataService, + RedisClientService redisClientService) + { + this._redisClientService = redisClientService; + this._singleDataService = singleDataService; + this._soaOptions = soaOptions?.Value; + this._mapper = mapper; + this._logger = logger; + this._httpClientHelp = httpClientHelp; + } + + /// + /// 创建token + /// + /// + /// + /// + /// + public async Task CreateToken(UserInfoDto data, LoginTempDto tempDto, string NewToken) + { + return await Task.Run(() => + { + + DateTime expires_time = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)).AddSeconds(tempDto.expires_in); + AccessTokenDto accessToken = new AccessTokenDto() + { + Token = NewToken, + PhpToken = tempDto.access_token, + RefreshToken = tempDto.refresh_token, + Expired = expires_time + }; + return accessToken; + }); + } + + /// + /// 创建token + /// + /// + /// + /// + /// + private async Task CreateToken(UserInfoDto data, LoginTempV2Dto tempDto, string NewToken) + { + return await Task.Run(() => + { + + DateTime expires_time = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)).AddSeconds(tempDto.access_expired_at); + AccessTokenDto accessToken = new AccessTokenDto() + { + Token = NewToken, + PhpToken = tempDto.access_token, + RefreshToken = tempDto.refresh_token, + Expired = expires_time + }; + return accessToken; + }); + } + + /// + /// 获取单点登录信息 + /// + /// + /// + public async Task> GetUserInfoByCode(string code) + { + var reqData = new LoginAuthorizeCodeRequest(); + reqData.ClientId = _soaOptions.AppId; + reqData.ClientSecret = _soaOptions.AppSecret; + reqData.GrantType = "authorization_code"; + reqData.Code = code; + reqData.Scope = "credentials"; + + //这个是登录的时候给前端验证的token,以及传给php单点那边的一个session值,用于单点退出时,通知ops退出 + string NewToken = Guid.NewGuid().ToString("N"); + try + { + string result = _httpClientHelp.PostHttp(_soaOptions.Url_V3 + "/uc/authorize", reqData); + var jObject = JsonObject.Parse(result); + LoginInDto r = new LoginInDto(); + r.UserInfo = new UserInfoDto(); + r.TokenInfo = new AccessTokenDto(); + var login_result = jObject["code"] == 0 ? "成功" : "失败"; + + if (jObject["code"] == 0) + { + string datajson = jObject["data"].ToString(); + var _loginDto = JsonConvert.DeserializeObject(datajson); + + #region 解码 + string enptStr = _loginDto.encrypted_data; + List enptlist = enptStr.Trim().Split(',').ToList(); + string str = RSA.DecryptSection(_soaOptions.PrivateKey, enptlist); + var entity = JsonConvert.DeserializeObject(str); + #endregion + + //映射登录信息 + var userInfo_v3 = _mapper.Map(entity); + _logger.LogInformation($"登录信息:用户ID->{entity.id}"); + _logger.LogInformation($"登录信息->{str}"); + //HTTP请求获取登录信息:人员,客户,供应商,公司 + var loginRequest = new LoginSingleRequest() + { + UserId = entity.id, + + }; + var loginResponse_result = await _singleDataService.GetSingleDataNoCache, LoginSingleRequest, SingleLoginAction> + (loginRequest, SingleLoginAction.Staff, type: SingleControllerType.Login); + + //绑定返回对象的登录信息 + var staffName = "Null"; + var token = await CreateToken(r.UserInfo, _loginDto, NewToken); + r.TokenInfo = token; + if (loginResponse_result.Success && loginResponse_result.Data != null) + { + var loginResponse = loginResponse_result.Data; + if (loginResponse != null) + { + r.UserInfo.StaffId = loginResponse.Id; + staffName = loginResponse.Name; + } + } + r.UserInfo.CompanyId = userInfo_v3.Company.Id; + r.UserInfo.CompanyName = userInfo_v3.Company.Name; + r.UserInfo.UcId = userInfo_v3.Id; + r.UserInfo.SeesionId = "";//app和程序类型登录授权没有这个字段 + r.UserInfo.Nickname = userInfo_v3.Nickname; + r.UserInfo.Mobile = userInfo_v3.Mobile; + r.UserInfo.Identity = userInfo_v3.Identity;//1.组织 2.供应商 3.客户 + r.UserInfo.CustomerId = null; + r.UserInfo.SupplierId = null; + r.SignedIn = true; + if (entity != null && entity.orgs != null) + r.UserInfo.OrgId = entity.orgs.FirstOrDefault()?.org_id; + + if (userInfo_v3.Identity == 2) + {//供应商获取供应商信息 + var result_supplier = await _singleDataService.GetSingleDataNoCache, UserRequest, SysConfigAction>( + new UserRequest(loginRequest.UserId), SysConfigAction.GetSupplierByUser, SingleControllerType.SysConfig); + if (!result_supplier.IsSuccess) + return Result.ReFailure("授权失败,请重新登录", 401); + if (result_supplier.Data.Count() <= 0) + return Result.ReFailure("授权失败,用户没有对应供应商", 401); + SupplierInfoResponse supplier = result_supplier.Data.First(); + + r.UserInfo.SupplierId = supplier.Id; + r.UserInfo.SupplierName = supplier.Name; + r.UserInfo.SupplierCode = supplier.Code; + } + //判断是否是管理员账号 + var isAdmin = _soaOptions.AdminUser.Exists(f => f == r.UserInfo.UcId); + if (isAdmin) + r.UserInfo.IsAdmin = true; + + + //登录后缓存登录的用户信息和token信息 + var loginInfo = new LoginInDto(); + loginInfo.UserInfo = r.UserInfo; + loginInfo.TokenInfo = token; + loginInfo.TokenInfo.ClientName = "PC"; + + var ops_login_time = token.Expired.AddDays(1) - DateTime.Now;//用于正式 + //var ops_login_time = token.Expired - DateTime.Now;//用于正式 + _redisClientService.SetStringKey($"wms_login_{token.Token}", loginInfo, ops_login_time); + + _logger.LogInformation($"登录信息:用户人员信息->{staffName}({r.UserInfo.StaffId}),公司名称->{r.UserInfo.CompanyName}" + ",过期时间:" + token.Expired.ToString("yyyy-MM-dd HH:mm:ss")); + + //登录成功移出对应的用户token黑名单:应为新的token产生,移除登录的信息 + string blacktoken = _redisClientService.GetStringKey($"wms_black_token_{r.UserInfo.UcId}"); + if (!string.IsNullOrEmpty(blacktoken)) + { + this.RemoveLoginInfo(blacktoken); + _redisClientService.RemoveStringKey($"wms_black_token_{r.UserInfo.UcId}"); + } + if (r == null || r.UserInfo == null || r.TokenInfo == null) + return Result.ReFailure("授权失败,请重新登录", 401); + return Result.ReSuccess(r); + } + else + { + var errno_text = "登录失败:" + jObject["message"]; + _logger.LogInformation("登陆失败:" + errno_text); + return Result.ReFailure(errno_text, 401); + } + } + catch (Exception ex) + { + _logger.LogInformation("登录错误信息:" + ex.Message); + return Result.ReFailure("授权失败,请重新登录", 401); + } + } + + /// + /// 获取单点用户信息 + /// + /// + /// + /// + public async Task> GetUserInfo(string username, string password) + { + var reqData = new LoginAuthorizeRequest(); + reqData.ClientId = _soaOptions.AppId; + reqData.ClientSecret = _soaOptions.AppSecret; + reqData.GrantType = "password"; + reqData.UserName = username; + reqData.Scope = "credentials"; + _logger.LogInformation($"username:" + username + ";password:" + password); + var md5 = System.Security.Cryptography.MD5.Create(); + var md5Pwd = BitConverter.ToString(md5.ComputeHash(Encoding.Default.GetBytes(password))); + md5Pwd = md5Pwd.Replace("-", string.Empty); + reqData.Password = md5Pwd.ToLower(); + + //这个是登录的时候给前端验证的token,以及传给php单点那边的一个session值,用于单点退出时,通知ops退出 + string NewToken = Guid.NewGuid().ToString("N"); + try + { + string result = _httpClientHelp.PostHttp(_soaOptions.Url_V3 + "/uc/authorize", reqData); + var jObject = JsonObject.Parse(result); + LoginInDto r = new LoginInDto(); + r.UserInfo = new UserInfoDto(); + r.TokenInfo = new AccessTokenDto(); + var login_result = jObject["code"] == 0 ? "成功" : "失败"; + + if (jObject["code"] == 0) + { + string datajson = jObject["data"].ToString(); + var _loginDto = JsonConvert.DeserializeObject(datajson); + + #region 解码 + string enptStr = _loginDto.encrypted_data; + List enptlist = enptStr.Trim().Split(',').ToList(); + string str = RSA.DecryptSection(_soaOptions.PrivateKey, enptlist); + var entity = JsonConvert.DeserializeObject(str); + #endregion + + //映射登录信息 + var userInfo_v3 = _mapper.Map(entity); + _logger.LogInformation($"登录信息:用户ID->{entity.id}"); + //HTTP请求获取登录信息:人员,客户,供应商,公司 + var loginRequest = new LoginSingleRequest() + { + UserId = entity.id, + + }; + var loginResponse_result = await _singleDataService.GetSingleDataNoCache, LoginSingleRequest, SingleLoginAction> + (loginRequest, SingleLoginAction.Staff, type: SingleControllerType.Login); + + //绑定返回对象的登录信息 + var staffName = "Null"; + var token = await CreateToken(r.UserInfo, _loginDto, NewToken); + r.TokenInfo = token; + if (loginResponse_result.Success && loginResponse_result.Data != null) + { + var loginResponse = loginResponse_result.Data; + if (loginResponse != null) + { + r.UserInfo.StaffId = loginResponse.Id; + staffName = loginResponse.Name; + } + } + r.UserInfo.CompanyId = userInfo_v3.Company.Id; + r.UserInfo.CompanyName = userInfo_v3.Company.Name; + r.UserInfo.UcId = userInfo_v3.Id; + r.UserInfo.SeesionId = "";//app和程序类型登录授权没有这个字段 + r.UserInfo.Nickname = userInfo_v3.Nickname; + r.UserInfo.Mobile = userInfo_v3.Mobile; + r.UserInfo.Identity = userInfo_v3.Identity; + r.UserInfo.OrgId = entity.orgs.FirstOrDefault()?.org_id; + r.UserInfo.CustomerId = null; + r.UserInfo.SupplierId = null; + r.SignedIn = true; + _logger.LogInformation($"登录信息:用户人员信息->{staffName}({r.UserInfo.StaffId}),公司名称->{r.UserInfo.CompanyName}"); + + //登录后缓存登录的用户信息和token信息 + var loginInfo = new LoginInDto(); + loginInfo.UserInfo = r.UserInfo; + loginInfo.TokenInfo = token; + loginInfo.TokenInfo.ClientName = "PDA"; + + var ops_login_time = token.Expired.AddDays(1) - DateTime.Now;//用于正式 + //var ops_login_time = token.Expired - DateTime.Now;//用于正式 + _redisClientService.SetStringKey($"wms_login_{token.Token}", loginInfo, ops_login_time); + + //登录成功移出对应的用户token黑名单:应为新的token产生,移除登录的信息 + string blacktoken = _redisClientService.GetStringKey($"wms_black_token_{r.UserInfo.UcId}"); + if (!string.IsNullOrEmpty(blacktoken)) + { + this.RemoveLoginInfo(blacktoken); + _redisClientService.RemoveStringKey($"wms_black_token_{r.UserInfo.UcId}"); + } + if (r == null || r.UserInfo == null || r.TokenInfo == null) + return Result.ReFailure("授权失败,请重新登录", 401); + return Result.ReSuccess(r); + } + else + { + var errno_text = "登录失败:" + jObject["message"]; + _logger.LogInformation("登陆失败:" + errno_text); + return Result.ReFailure(errno_text, 4001); + //r.SignedIn = false; + //string datajson_sessid = jObject["data"]["uc_sessid"]; + ////调用单点的退出接口 + //result = _httpClientHelp.GetHttp(_soaOptions.Url + "/uc/authorize/signin_out", true, cookieValue: datajson_sessid); + //jObject = JsonObject.Parse(result); + //if (jObject["errno"] == 0) + //{ + // return Result.ReFailure("拒绝用户证书试图访问此web站点,请与站点管理员联系以建立用户证书权限", 403); + //} + //else + //{ + // return Result.ReFailure(jObject["errmsg"], jObject["errno"]); + //} + } + } + catch (Exception ex) + { + _logger.LogInformation("登录错误信息:" + ex.Message); + return Result.ReFailure("授权失败,请重新登录", 401); + } + } + + /// + /// 登录退出 + /// + /// + /// + public async Task LoginOut(LoginOutDto dto) + { + //2.请求PHP单点登出接口 + var reqData = new LoginOutAuthorizeRequest(); + reqData.AccessToken = dto.AccessToken; + reqData.RefreshToken = dto.RefreshToken; + string result = _httpClientHelp.GetHttpOut(_soaOptions.Url_V3 + "/uc/logout", reqData); + _logger.LogInformation($"退出参数:{JsonConvert.SerializeObject(dto)}->退出登录单点返回:" + result); + var jObject = JsonObject.Parse(result); + if (jObject["code"] == 0) + { + //设置本地token的缓存:为黑名单的token做存储 + await CacheOutToken(dto); + return Result.ReSuccess(); + } + else + { + return Result.ReFailure(BaseResultCodes.UnAuthorized); + } + } + + /// + /// 刷新token + /// + /// + /// + /// + public async Task> RefreshTokenNew(string oldToken, string RefreshToken) + { + + //1.根据旧token 找到登录对象 + var loginInfo = _redisClientService.GetStringKey($"wms_login_{oldToken}"); + var reqData = new LoginAuthorizeRefreshTokenRequest(); + reqData.ClientId = _soaOptions.AppId; + reqData.ClientSecret = _soaOptions.AppSecret; + reqData.GrantType = "refresh_token"; + reqData.RefreshToken = RefreshToken; + reqData.Scope = "credentials"; + + var clientName = loginInfo?.TokenInfo?.ClientName; + var oldExpired = loginInfo?.TokenInfo?.Expired.ToString("yyyy-MM-dd HH:mm:ss"); + try + { + string result = _httpClientHelp.PostHttp(_soaOptions.Url_V3 + "/uc/authorize", reqData); + var jObject = JsonObject.Parse(result); + + LoginInDto r = new LoginInDto(); + r.UserInfo = new UserInfoDto(); + r.TokenInfo = new AccessTokenDto(); + + if (jObject["code"] == 0) + { + string datajson = jObject["data"].ToString(); + var _loginDto = JsonConvert.DeserializeObject(datajson); + + r.UserInfo = loginInfo.UserInfo; + r.SignedIn = true; + //string NewToken = Guid.NewGuid().ToString("N"); + var token = await CreateToken(loginInfo.UserInfo, _loginDto, oldToken); + r.TokenInfo = token; + loginInfo.TokenInfo = token; + loginInfo.TokenInfo.ClientName = clientName; + //_logger.LogInformation("RefreshToken:我在刷新登录:刷新后的过期时间-1>" + token.Expired.ToString()); + var ops_login_time = token.Expired.AddDays(1) - DateTime.Now;//用于正式 + //var ops_login_time = token.Expired - DateTime.Now;//用于正式 + _redisClientService.SetStringKey($"wms_login_{token.Token}", loginInfo, ops_login_time); + _logger.LogInformation($"刷新Token->用户信息:{JsonConvert.SerializeObject(loginInfo)}->老时间->" + $"{oldExpired}" + ",新时间->" + $"wms_login_{token.Token}->过期时间:{token.Expired.ToString("yyyy-MM-dd HH:mm:ss")}"); + //移除老的redis缓存 + //_redisClientService.RemoveStringKey($"wms_login_{oldToken}"); + //_logger.LogInformation("RefreshToken:我在刷新登录:刷新后的过期时间-小时->" + ops_login_time.Hours); + return Result.ReSuccess(r); + } + else + { + //失败了1:就把登录的token清除 2: ucid添加到黑名单 + var time = new TimeSpan(r.TokenInfo.Expired.Day, r.TokenInfo.Expired.Hour, r.TokenInfo.Expired.Minute, r.TokenInfo.Expired.Second, r.TokenInfo.Expired.Millisecond); + _redisClientService.SetStringKey($"wms_black_token_{r.UserInfo.UcId}", r.TokenInfo.Token, time); + this.RemoveLoginInfo(r.TokenInfo.Token); + r.SignedIn = false; + return Result.ReFailure(jObject["message"], jObject["code"]); + } + } + catch (Exception ex) + { + _logger.LogInformation("RefreshTokenNew:" + _soaOptions.Url_V3 + "/uc/authorize" + ":Data:" + JsonConvert.SerializeObject(reqData)); + _logger.LogInformation("RefreshTokenNew:Error" + ex.Message); + return Result.ReFailure(ex.Message, 50001); + } + } + + /// + /// 单点退出通知token失效 + /// + /// 这个是单点传过来的SeesionId + /// + public async Task LoginOutSingleAsync(string SeesionId) + { + var logininfo = _redisClientService.GetStringKey($"wms_login_{SeesionId}"); + await Task.Run(() => + { + if (logininfo != null) + { + var cache_token = _redisClientService.GetStringKey($"wms_black_token_{logininfo.UserInfo.UcId}"); + if (string.IsNullOrEmpty(cache_token)) + { + DateTime expires_time = logininfo.TokenInfo.Expired; + var time = new TimeSpan(expires_time.Day, expires_time.Hour, expires_time.Minute, expires_time.Second, expires_time.Millisecond); + _redisClientService.SetStringKey($"wms_black_token_{logininfo.UserInfo.UcId}", logininfo.TokenInfo.Token, time); + this.RemoveLoginInfo(logininfo.TokenInfo.Token); + } + } + }); + } + + /// + /// 缓存退出的token + /// + /// + /// + private async Task CacheOutToken(LoginOutDto dto) + { + await Task.Run(() => + { + if (!string.IsNullOrEmpty(dto.AccessToken)) + { + var time = new TimeSpan(dto.ExpiresIn.Day, dto.ExpiresIn.Hour, dto.ExpiresIn.Minute, dto.ExpiresIn.Second, dto.ExpiresIn.Millisecond); + _redisClientService.SetStringKey($"wms_black_token_{dto.UcId}", dto.AccessToken, time); + this.RemoveLoginInfo(dto.Token); + + } + }); + } + + /// + /// 获取登录后的信息 + /// + /// + /// + public LoginInDto GetLoginInfo(string authorization) + { + string token = string.Empty; + if (authorization.StartsWith("Bearer ", StringComparison.OrdinalIgnoreCase)) + { + token = authorization.Substring("Bearer ".Length).Trim(); + } + var logininfo = _redisClientService.GetStringKey($"wms_login_{token}"); + return logininfo; + } + + /// + /// 移除登录后的用户信息 + /// + /// + private void RemoveLoginInfo(string token) + { + if (!string.IsNullOrEmpty(token)) + { + var info = _redisClientService.GetStringKey($"wms_login_{token}"); + if (info != null) + { + _redisClientService.RemoveStringKey($"wms_login_{token}"); + } + } + } + + /// + /// 获取菜单数据 + /// + /// + public async Task> GetMenuList(int userId) + { + int module = _soaOptions.ModuleID; + var result = await _singleDataService.GetSingleDataNoCache, MenuRequest, SingleLoginAction> + (new MenuRequest(userId, module), SingleLoginAction.Menus, type: SingleControllerType.Login); + if (result.Success) + return result.Data.ToList(); + return null; + } + + /// + /// + /// + /// + /// + /// + public async Task Online(string accessToken, string refreshToken) + { + string result = await _httpClientHelp.PostHttp(_soaOptions.Url_V3 + "/uc/online", accessToken, refreshToken); + return Result.ReSuccess(); + } + + /// + /// + /// + /// + /// + /// + public async Task Offline(string accessToken, string refreshToken) + { + string result = await _httpClientHelp.PostHttp(_soaOptions.Url_V3 + "/uc/offline", accessToken, refreshToken); + return Result.ReSuccess(); + } + } +} diff --git a/src/BarCode.Web.Domain/Services/Public/MaterialService.cs b/src/BarCode.Web.Domain/Services/Public/MaterialService.cs new file mode 100644 index 0000000..77e8aa4 --- /dev/null +++ b/src/BarCode.Web.Domain/Services/Public/MaterialService.cs @@ -0,0 +1,150 @@ +using AutoMapper; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using BarCode.Web.Core.Dto.Erp; +using BarCode.Web.Core.Internal.Results; +using BarCode.Web.Domain.Entitys; +using BarCode.Web.Domain.Infrastructure; +using BarCode.Web.Domain.IService; +using BarCode.Web.Domain.IService.Public; +using BarCode.Web.Domain.Values; +using NPOI.OpenXmlFormats.Spreadsheet; +using Newtonsoft.Json; +using BarCode.Web.Domain.Options; +using Microsoft.Extensions.Caching.Memory; +using BarCode.Web.Domain.Services.Public; +using ERP; +using Microsoft.AspNetCore.Builder.Extensions; +using Microsoft.Extensions.Options; +using BarCode.Web.Core.Help; + +namespace BarCode.Web.Domain.Services +{ + /// + /// 物料服务 + /// + public class MaterialService : IMaterialService + { + private IMapper _mapper; + private ILogger _logger; + private IErpService _erpService; + private IMaterialsRepositories _materialsRepositories; + private ErpOptions _erpOptions; + private readonly IMemoryCache _memoryCache; + public MaterialService(IMapper mapper, ILogger logger, IErpService erpService, + IMaterialsRepositories materialsRepositories, IOptions erpOptions, IMemoryCache memoryCache) + { + _mapper = mapper; + _logger = logger; + _erpService = erpService; + _materialsRepositories = materialsRepositories; + this._erpOptions = erpOptions.Value; + this._memoryCache = memoryCache; + } + /// + /// 同步物料32进制 + /// + /// + /// + public async Task SyncBar() + { + var list = await _materialsRepositories.GetEntityListByNoBar(); + if (list.Count() <= 0) return Result.ReSuccess(); + var numbers = list.Select(s => s.MaterialNumber).ToList(); + var mDtos = await _erpService.BillQueryForMaterialByNumbers(numbers); + if (!mDtos.IsSuccess) return Result.ReFailure(mDtos.Message, mDtos.Status); + if (mDtos.Data.Count() <= 0) return Result.ReSuccess(); + _logger.LogInformation($"物料更新id32进制:{JsonConvert.SerializeObject(mDtos.Data)}"); + + var materials = _memoryCache.Get>(_erpOptions.cache_materail_key); + + + List update_list = new List(); + foreach (var m in mDtos.Data) + { + var entity = list.FirstOrDefault(f => f.MaterialNumber.Equals(m.MaterialNumber)); + if (entity == null) continue; + entity.IdConvertBar = m.IdConvertBar.Trim(); + update_list.Add(entity); + + //修改缓存 + if (materials == null) continue; + var entity_cache = materials.FirstOrDefault(f => f.MaterialNumber.Equals(m.MaterialNumber)); + if (entity_cache == null) continue; + entity_cache.IdConvertBar = m.IdConvertBar.Trim(); + } + //修改缓存 + if (materials != null && materials.Count() > 0) + { + _logger.LogInformation($"物料缓存总数:{materials.Count()}"); + _memoryCache.Set(_erpOptions.cache_materail_key, materials, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromMinutes(DateTimeUtil.GetTotalMinutesTimeSpan()))); + } + await _materialsRepositories.UpdateRange(update_list); + return Result.ReSuccess(); + } + + /// + /// 同步金蝶新的物料 + /// + /// + public async Task SyncNewMaterials() + { + try + { + _logger.LogInformation("同步金蝶新物料:开始->" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); + //1.获取全部物料编码 + var materialNumbers = await _materialsRepositories.GetAllNumbers(); + //1.1通过hash处理 + var materialNumberSet = new HashSet(materialNumbers); + + //2.获取金蝶物料:不取缓存的 + var mats_result = await _erpService.BillQueryForMaterial(false); + var mats = new List(); + if (mats_result.IsSuccess) + mats = mats_result.Data.ToList(); + + //3.通过hash,更快的时间内判断元素是否存在于集合中,提高性能(10W数据十几毫秒级别) + var entitys = mats + .Where(item => !materialNumberSet.Contains(item.MaterialNumber)) + .Select(item => _mapper.Map(item)) + .ToList(); + + //4.添加数据库 + if (entitys.Count != 0) + { + var isSuccess = await _materialsRepositories.AddRange(entitys); + if (!isSuccess) + return Result.ReFailure(ResultCodes.DateWriteError); + } + //5.修改物料数据 + if (mats.Count != 0) + { + var isBatchManageMatNumbs = mats.Where(x => x.IsBatchManage == true).Select(x => x.MaterialNumber).ToList(); + //取:金蝶拉取的已启用批号管理的物料并且本地数据库中的未启用批号管理的物料;来更新批号管理修改为true + var updateList = await _materialsRepositories.GetEntityList(isBatchManageMatNumbs, false); + if (updateList.Count != 0) + { + updateList.ForEach(x => { x.IsBatchManage = true; }); + var isSuccess = await _materialsRepositories.UpdateRange(updateList); + if (!isSuccess) + _logger.LogInformation("同步金蝶新物料-修改物料:失败"); + else + _logger.LogInformation("同步金蝶新物料-修改物料:成功->" + updateList.Count + "条"); + } + } + + _logger.LogInformation("同步金蝶新物料:结束->" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->添加数量:" + entitys.Count); + return Result.ReSuccess(); + } + catch (Exception ex) + { + _logger.LogInformation("同步金蝶新物料:失败->" + ex.Message); + return Result.ReFailure(ex.Message, ex.HResult); + } + } + } +} diff --git a/src/BarCode.Web.Domain/Services/Public/Radix.cs b/src/BarCode.Web.Domain/Services/Public/Radix.cs new file mode 100644 index 0000000..fec4746 --- /dev/null +++ b/src/BarCode.Web.Domain/Services/Public/Radix.cs @@ -0,0 +1,344 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Domain.Services.Public +{ + // string exclude = "ISOZ";//ISOZ + // streamNo = Radix.ConvertRadix36((ulong)decstreamNo, exclude.ToCharArray()).PadLeft(FLength ?? 0, '0'); + public static class Radix + { + //36进制 + static string[] radixs = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", + + "I", "J", "K","L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" }; + + /// + /// 进制转换 + /// + /// 整形数字 + /// 排除的字符"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", + /// "C", "D", "E", "F", "G", "H", "I", "J", "K","L", "M", "N", "O", "P", "Q", "R", "S", + /// "T", "U", "V", "W", "X", "Y", "Z" + /// + public static string ConvertRadix(ulong lg, string[] excepts) + + { + + var data = new List(); + + foreach (var rd in radixs) + + { + + var isexists = false; + + foreach (var ex in excepts) + + { + + if (rd.Equals(ex.ToUpper())) + + { + + isexists = true; + + break; + + } + + } + + if (isexists) + + { + + data.Add(rd); + + } + + } + + + + var rds = data.ToArray(); + + + + //进制 + + uint radix = (uint)rds.Length; + + //long lg = 800000000853; + + + + var s1 = lg / radix; + + var s2 = lg % radix; + + var rt = rds[radix]; + + while (s1 > 0) + + { + + var temp = s1; + + s1 = temp / radix; + + s2 = temp % radix; + + rt = rds[s2] + rt; + + } + + //Q91VEGTN + + //Console.WriteLine(rt); + + return rt; + + } + + public static string ConvertRadix36(ulong val, char[] excepts) + + { + + string BaseChar = "0123456789ABCDEFGHIJKLMNPQRSTUVWXYZ"; + + foreach (var v in excepts) + + { + + BaseChar = BaseChar.Replace(v.ToString().ToUpper(), ""); + + } + + List r = new List(); + + do + + { + + ulong y = val % (ulong)BaseChar.Length; + + r.Add(BaseChar[Convert.ToInt32(y)].ToString()); + + val = Convert.ToUInt64(Math.Floor(val / (decimal)BaseChar.Length)); + + } while (val > 0); + + r.Reverse(); + + return string.Join("", r.ToArray()); + + } + + public static string Main(long lg) + + { + + string[] data = new string[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", + + "A", "B", "C", "D", "E", "F","G", "H", "J", "K", "L", "M", "N", "Q", "R", "T", "U", "V", "W", "X", "Y" }; + + var s1 = lg / 32; + + var s2 = lg % 32; + + var rt = data[s2]; + + while (s1 > 0) + + { + + var temp = s1; + + s1 = temp / 32; + + s2 = temp % 32; + + rt = data[s2] + rt; + + } + + //Q91VEGTN + + return rt; + + } + + public static string IntToi32(long xx) + + { + + string a = ""; + + while (xx >= 1) + + { + + int index = Convert.ToInt16(xx - (xx / 32) * 32); + + a = Base64Code[index] + a; + + xx = xx / 32; + + } + + return a; + + } + + public static long i32ToInt(string xx) + + { + + long a = 0; + + int power = xx.Length - 1; + + + + for (int i = 0; i <= power; i++) + + { + + a += _Base64Code[xx[power - i].ToString()] * Convert.ToInt64(Math.Pow(32, i)); + + } + + + + return a; + + } + + public static string IntToi64(long xx) + + { + + string a = ""; + + while (xx >= 1) + + { + + int index = Convert.ToInt16(xx - (xx / 64) * 64); + + a = Base64Code[index] + a; + + xx = xx / 64; + + } + + return a; + + } + + public static long i64ToInt(string xx) + + { + + long a = 0; + + int power = xx.Length - 1; + + + + for (int i = 0; i <= power; i++) + + { + + a += _Base64Code[xx[power - i].ToString()] * Convert.ToInt64(Math.Pow(64, i)); + + } + + + + return a; + + } + + public static Dictionary Base64Code = new Dictionary() { + + { 0 ,"z"}, { 1 ,"1"}, { 2 ,"2"}, { 3 ,"3"}, { 4 ,"4"}, { 5 ,"5"}, { 6 ,"6"}, { 7 ,"7"}, { 8 ,"8"}, { 9 ,"9"}, + + { 10 ,"a"}, { 11 ,"b"}, { 12 ,"c"}, { 13 ,"d"}, { 14 ,"e"}, { 15 ,"f"}, { 16 ,"g"}, { 17 ,"h"}, { 18 ,"i"}, { 19 ,"j"}, + + { 20 ,"k"}, { 21 ,"x"}, { 22 ,"m"}, { 23 ,"n"}, { 24 ,"y"}, { 25 ,"p"}, { 26 ,"q"}, { 27 ,"r"}, { 28 ,"s"}, { 29 ,"t"}, + + { 30 ,"u"}, { 31 ,"v"}, { 32 ,"w"}, { 33 ,"x"}, { 34 ,"y"}, { 35 ,"z"}, { 36 ,"A"}, { 37 ,"B"}, { 38 ,"C"}, { 39 ,"D"}, + + { 40 ,"E"}, { 41 ,"F"}, { 42 ,"G"}, { 43 ,"H"}, { 44 ,"I"}, { 45 ,"J"}, { 46 ,"K"}, { 47 ,"L"}, { 48 ,"M"}, { 49 ,"N"}, + + { 50 ,"O"}, { 51 ,"P"}, { 52 ,"Q"}, { 53 ,"R"}, { 54 ,"S"}, { 55 ,"T"}, { 56 ,"U"}, { 57 ,"V"}, { 58 ,"W"}, { 59 ,"X"}, + + { 60 ,"Y"}, { 61 ,"Z"}, { 62 ,"-"}, { 63 ,"_"}, + + }; + + public static Dictionary _Base64Code + + { + + get + + { + + return Enumerable.Range(0, Base64Code.Count()).ToDictionary(i => Base64Code[i], i => i); + + } + + } + + //36进制转10进制 + public static int int32Convert10(string str) + + { + + int d = 0; + + int b; + + char[] ch = str.ToCharArray(); + + int j = 0; + + for (int i = ch.Length - 1; i >= 0; i--) + + { + + char c = ch[i]; + + b = 1; + + for (int t = 0; t < j; t++) + + b = b * 32; + + j++; + + int cc; + + if (c >= '0' && c <= '9') + + cc = Convert.ToInt32(c) - 48; + + else + + cc = Convert.ToInt32(c) - 65 + 10; + + d += cc * b; + + } + + return d; + + } + + } +} diff --git a/src/BarCode.Web.Domain/Services/Public/RedisClientService.cs b/src/BarCode.Web.Domain/Services/Public/RedisClientService.cs new file mode 100644 index 0000000..46fcafb --- /dev/null +++ b/src/BarCode.Web.Domain/Services/Public/RedisClientService.cs @@ -0,0 +1,93 @@ +using Microsoft.Extensions.Options; +using Newtonsoft.Json; +using StackExchange.Redis; +using System; +using System.Collections.Generic; +using System.Text; +using BarCode.Web.Domain.Options; + +namespace BarCode.Web.Domain.Services.Public +{ + public class RedisClientService + { + private static readonly object Locker = new object(); + + private ConnectionMultiplexer redisMultiplexer; + IDatabase db = null; + private readonly AppOptions _options; + public RedisClientService(IOptions options) + { + _options = options?.Value; + redisMultiplexer = ConnectionMultiplexer.Connect(_options.RedisConnectionString); + db = redisMultiplexer.GetDatabase(); + } + + #region String + /// + /// 保存单个key value + /// + /// + /// + /// + /// + public bool SetStringKey(string key, string value, TimeSpan? expiry = default(TimeSpan?)) + { + var lastKey = _options.RedisDirectory + ":" + key; + return db.StringSet(lastKey, value, expiry); + } + + /// + /// 获取单个key的值 + /// + public RedisValue GetStringKey(string key) + { + var lastKey = _options.RedisDirectory + ":" + key; + return db.StringGet(lastKey); + } + + /// + /// 移除redis + /// + /// + /// + public bool RemoveStringKey(string key) + { + var lastKey = _options.RedisDirectory + ":" + key; + return db.KeyDelete(lastKey); + } + /// + /// 获取一个key的对象 + /// + public T GetStringKey(string key) + { + if (db == null) + { + return default; + } + var lastKey = _options.RedisDirectory + ":" + key; + var value = db.StringGet(lastKey); + if (value.IsNullOrEmpty) + { + return default; + } + return JsonConvert.DeserializeObject(value); + } + + /// + /// 保存一个对象 + /// + /// + public bool SetStringKey(string key, T obj, TimeSpan? expiry = default(TimeSpan?)) + { + if (db == null) + { + return false; + } + var lastKey = _options.RedisDirectory + ":" + key; + string json = JsonConvert.SerializeObject(obj); + return db.StringSet(lastKey, json, expiry); + } + + #endregion + } +} diff --git a/src/BarCode.Web.Domain/Services/Public/RedisConcurrentProcessService.cs b/src/BarCode.Web.Domain/Services/Public/RedisConcurrentProcessService.cs new file mode 100644 index 0000000..ccd2461 --- /dev/null +++ b/src/BarCode.Web.Domain/Services/Public/RedisConcurrentProcessService.cs @@ -0,0 +1,37 @@ +using StackExchange.Redis; +using System; +using System.Collections.Generic; +using System.Text; +using BarCode.Web.Domain.IService.Public; + +namespace BarCode.Web.Domain.Services.Public +{ + public class RedisConcurrentProcessService: IRedisConcurrentProcessService + { + private readonly RedisClientService _redisClientService; + public RedisConcurrentProcessService(RedisClientService redisClientService) + { + this._redisClientService = redisClientService; + } + + public bool CanAccessMethod(string cacheKey) + { + // 使用 Redis 来存储并发控制标记 + return _redisClientService.SetStringKey(cacheKey, true, TimeSpan.FromMinutes(1)); + } + + + public bool GetRedisKeyValue(string cacheKey) + { + // 使用 Redis 来存储并发控制标记 + var isSuccess= _redisClientService.GetStringKey(cacheKey); + return isSuccess; + } + + public void UpdateAccessStatus(string cacheKey, bool canAccess) + { + // 更新 Redis 缓存项的值 + _redisClientService.SetStringKey(cacheKey, canAccess, TimeSpan.FromMinutes(1)); + } + } +} diff --git a/src/BarCode.Web.Domain/Services/Public/SingleDataService.cs b/src/BarCode.Web.Domain/Services/Public/SingleDataService.cs new file mode 100644 index 0000000..99dc4cc --- /dev/null +++ b/src/BarCode.Web.Domain/Services/Public/SingleDataService.cs @@ -0,0 +1,476 @@ +using Microsoft.Extensions.Caching.Memory; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using System; +using System.Collections.Generic; +using System.IdentityModel.Tokens.Jwt; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using BarCode.Web.Core.Dto.SingleData; +using BarCode.Web.Core.Internal.Results; +using BarCode.Web.Domain.IService.Public; +using BarCode.Web.Domain.Options; +using BarCode.Web.Domain.Values.Single; +using Newtonsoft.Json; + +namespace BarCode.Web.Domain.Services.Public +{ + /// + /// 单点数据返回服务 + /// + public class SingleDataService : ISingleDataService + { + private readonly AppOptions _options; + private readonly IHttpClientService _httpClientService; + private readonly ILogger _logger; + private readonly IMemoryCache _memoryCache; + private int hours = 10;//过期时间 默认10小时 + + public SingleDataService(IOptions options, IHttpClientService httpClientService, ILogger logger, IMemoryCache memoryCache) + { + this._memoryCache = memoryCache; + this._options = options?.Value; + this._httpClientService = httpClientService; + this._logger = logger; + } + + /// + /// 获取单点数据:根据接口方法名和公司ID + /// 后端列表查询统一使用 + /// + /// + /// + /// + public string GetSingleData(SingleAction action, int companyId, int id) + { + try + { + if (id == 0) + return ""; + + var cache_key = action + "_" + companyId + "_IdGetName"; + var dic = _memoryCache.Get>(cache_key); + if (dic == null || dic.Count <= 0 || !dic.ContainsKey(id)) + { + if (dic != null) + { + + string no_data_key = cache_key + "_NoData"; + var cache_id = _memoryCache.Get(no_data_key); + if (cache_id == true) return ""; + //未找到数据请求 + if (!dic.ContainsKey(id)) + { + _memoryCache.Set(no_data_key, true, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromMinutes(30))); + } + } + var list = SingleDataPost(action, companyId, cache_key); + if (list.Count() <= 0) return ""; + dic = list.ToDictionary(s => s.Id, s => s.Name); + _memoryCache.Set(cache_key, dic, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromHours(hours))); + } + if (!dic.ContainsKey(id)) return ""; + return dic[id]; + } + catch (Exception ex) + { + _logger.LogError($"请求单点数据错误:Action->{action.ToString()},CompanyeId->{companyId},Id->{id},(错误原因)=>{ex.Message}"); + return ""; + } + } + + /// + /// 获取单点数据:根据接口方法名和公司ID + /// 后端列表查询统一使用 + /// + /// + /// + /// + public decimal GetSingleDataNumber(SingleAction action, int companyId, int id) + { + try + { + if (id == 0) + return 0; + + var cache_key = action + "_" + companyId + "_IdGetNumber"; + var dic = _memoryCache.Get>(cache_key); + if (dic == null || dic.Count <= 0 || !dic.ContainsKey(id)) + { + if (dic != null) + { + string no_data_key = cache_key + "_NoData"; + var cache_id = _memoryCache.Get(no_data_key); + if (cache_id == true) return 0; + //未找到数据请求 + if (!dic.ContainsKey(id)) + { + _memoryCache.Set(no_data_key, true, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromMinutes(30))); + } + } + + var list = SingleDataPost(action, companyId, cache_key); + if (list.Count() <= 0) return 0; + + dic = list.ToDictionary(s => s.Id, s => s.Number); + _memoryCache.Set(cache_key, dic, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromHours(hours))); + } + + if (!dic.ContainsKey(id)) return 0; + return dic[id]; + } + catch (Exception ex) + { + _logger.LogError($"请求单点数据错误:{action.ToString()}=>{ex.Message}"); + return 0; + } + } + + /// + /// 获取单点数据:根据接口方法名和公司ID + /// 后端列表查询统一使用 + /// + /// + /// + /// + public string GetSingleDataCode(SingleAction action, int companyId, int id) + { + try + { + if (id == 0) + return ""; + + var cache_key = action + "_" + companyId + "_IdGetCode"; + var dic = _memoryCache.Get>(cache_key); + if (dic == null || dic.Count <= 0 || !dic.ContainsKey(id)) + { + if (dic != null) + { + string no_data_key = cache_key + "_NoData"; + var cache_id = _memoryCache.Get(no_data_key); + if (cache_id == true) return ""; + //未找到数据请求 + if (!dic.ContainsKey(id)) + { + _memoryCache.Set(no_data_key, true, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromMinutes(30))); + } + } + + var list = SingleDataPost(action, companyId, cache_key); + if (list.Count() <= 0) return ""; + + dic = list.ToDictionary(s => s.Id, s => s.Code); + _memoryCache.Set(cache_key, dic, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromHours(hours))); + } + + if (!dic.ContainsKey(id)) return ""; + return dic[id]; + } + catch (Exception ex) + { + _logger.LogError($"请求单点数据错误:{action.ToString()}=>{ex.Message}"); + return ""; + } + } + + /// + /// 根据名字模糊匹配 + /// + /// + /// + /// + /// + public List GetIdsBySingleName(SingleAction action, int companyId, string name) + { + try + { + var cache_key = action + "_" + companyId + "_NameGetIds"; + var dic = _memoryCache.Get>(cache_key); + if (dic == null || dic.Count <= 0) + { + var list = SingleDataPost(action, companyId, cache_key); + if (list.Count() <= 0) return new List(); + + dic = list.ToDictionary(s => s.Id, s => s.Name); + _memoryCache.Set(cache_key, dic, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromHours(hours))); + } + var res = from d in dic where d.Value.Contains(name) select d; + return res.Select(s => s.Key).ToList(); + } + catch (Exception ex) + { + _logger.LogError($"请求单点数据错误:{action.ToString()}=>{ex.Message}"); + return new List(); + } + } + + /// + /// 获取单点数据:根据接口方法名和公司ID + /// 后端列表查询统一使用 + /// + /// + /// + /// + public string GetSingleData(SingleAction action, int companyId, string code) + { + try + { + if (string.IsNullOrEmpty(code)) + return ""; + + var cache_key = action + "_" + companyId + "_CodeGetName"; + var dic = _memoryCache.Get>(cache_key); + //仓库和客户仓库 不能为空了就重新请求 应为 这里是从仓库和客户仓库取值 有一个必然取不到 + if (dic == null || dic.Count <= 0) + { + if (dic != null) + { + string no_data_key = cache_key + "_NoData"; + var cache_id = _memoryCache.Get(no_data_key); + if (cache_id == true) return ""; + //未找到数据请求 + if (!dic.ContainsKey(code)) + { + _memoryCache.Set(no_data_key, true, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromMinutes(30))); + } + } + + var list = SingleDataPost(action, companyId, cache_key); + + var json = JsonConvert.SerializeObject(list); + if (list.Count() <= 0) return ""; + + dic = list.ToDictionary(s => s.Code, s => s.Name); + _memoryCache.Set(cache_key, dic, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromHours(hours))); + } + + if (!dic.ContainsKey(code)) return ""; + var name = dic[code]; + return dic[code]; + } + catch (Exception ex) + { + _logger.LogError($"请求单点数据错误:{action.ToString()}=>{ex.Message}"); + return ""; + } + } + + /// + /// 获取单点数据集合:泛型-同步 + /// + /// + /// + /// + /// + public List GetSingleData(SingleAction action, int companyId) where T : class + { + try + { + var cache_key = action + "_list_" + companyId; + var list = _memoryCache.Get>(cache_key); + if (list == null || list.Count <= 0) + list = SingleDataPost(action, companyId, cache_key); + + return list; + } + catch (Exception ex) + { + _logger.LogError($"请求单点数据错误:{action.ToString()}=>{ex.Message}"); + return null; + } + } + + /// + /// 获取单点数据集合:泛型-异步 + /// + /// + /// + /// + /// + public async Task> GetSingleDataAsync(SingleAction action, int companyId) where T : class + { + try + { + var cache_key = action + "_list_" + companyId; + var list = _memoryCache.Get>(cache_key); + if (list == null || list.Count <= 0) + list = await SingleDataPostAsync(action, companyId, cache_key); + + return list; + } + catch (Exception ex) + { + _logger.LogError($"请求单点数据错误:{action.ToString()}=>{ex.Message}"); + return null; + } + } + + /// + /// 获取单点数据集合:泛型-异步-无缓存 + /// + /// + /// + /// + /// + public async Task> GetSingleDataNoCacheAsync(SingleAction action, int companyId) where T : class + { + try + { + var list = await SingleDataPostAsync(action, companyId, ""); + return list; + } + catch (Exception ex) + { + _logger.LogError($"请求单点数据错误:{action.ToString()}=>{ex.Message}"); + return null; + } + } + + /// + /// 单点数据:可对接全部接口 + /// + /// 返回对象 + /// 请求对象 + /// 方法名称 + /// 请求对象 + /// 方法名称 + /// 控制器名称 + /// + public async Task GetSingleData(X dto, Y action, SingleControllerType type = SingleControllerType.Single) where T : class + { + try + { + var para = JsonConvert.SerializeObject(dto); + var cache_key = action + "_list_" + type + "_" + para; + var list = _memoryCache.Get(cache_key); + if (list == null) + { + var url = _options.SingleBaseUrl + "/" + type.ToString() + "/" + action.ToString(); + var result = await _httpClientService.PostAsync(url, para); + _memoryCache.Set(cache_key, result, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromHours(hours))); + } + return _memoryCache.Get(cache_key); + } + catch (Exception ex) + { + _logger.LogError($"请求单点数据错误:{action.ToString()}=>{ex.Message}"); + return default(T); + } + } + + /// + /// 单点数据:可对接全部接口 + /// + /// 返回对象 + /// 请求对象 + /// 方法名称 + /// 请求对象 + /// 方法名称 + /// 控制器名称 + /// + public async Task GetSingleDataNoCache(X dto, Y action, SingleControllerType type = SingleControllerType.Single) where T : class + { + try + { + var para = JsonConvert.SerializeObject(dto); + var url = _options.SingleBaseUrl + "/" + type.ToString() + "/" + action.ToString(); + var result = await _httpClientService.PostAsync(url, para); + return result; + } + catch (Exception ex) + { + _logger.LogError($"请求单点数据错误:{action.ToString()}=>{ex.Message}"); + return default(T); + } + } + + /// + /// 获取单点数据:配置项接口 + /// + /// + /// + /// + /// + /// + public async Task GetSysConfigData(X dto, SysConfigAction action) + { + try + { + var para = JsonConvert.SerializeObject(dto); + var url = _options.SingleBaseUrl + "/" + SingleControllerType.SysConfig.ToString() + "/" + action.ToString(); + var result = await _httpClientService.PostAsync(url, para); + return result; + } + catch (Exception ex) + { + _logger.LogError($"请求单点数据错误:{action.ToString()}=>{ex.Message}"); + return default(T); + } + } + + + #region 私有方法 + + /// + /// 请求单点服务接口:同步 + /// + /// + /// + /// + /// + private List SingleDataPost(SingleAction action, int companyId, string cache_key) + { + var dto = new SingleDataRequest(companyId); + //var para = JsonExtensions.SerializeToJson(dto); + var para = JsonConvert.SerializeObject(dto); + var url = _options.SingleBaseUrl + "/" + SingleControllerType.Single.ToString() + "/" + action.ToString(); + var result = _httpClientService.PostAsync>(url, para).GetAwaiter().GetResult(); + if (!result.Success) + return new List(); + return result.Data.ToList(); + } + + /// + /// 请求单点服务接口:异步 + /// + /// + /// + /// + /// + private async Task> SingleDataPostAsync(SingleAction action, int companyId, string cache_key) + { + var dto = new SingleDataRequest(companyId); + var para = JsonConvert.SerializeObject(dto); + var url = _options.SingleBaseUrl + "/" + SingleControllerType.Single.ToString() + "/" + action.ToString(); + var result = await _httpClientService.PostAsync>(url, para); + if (result.Success) + { + if (!string.IsNullOrEmpty(cache_key)) + { + _memoryCache.Set(cache_key, result.Data.ToList(), new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromHours(hours))); + return _memoryCache.Get>(cache_key); + } + return result.Data.ToList(); + } + return null; + } + + + + #endregion + /// + /// 获取客户仓库 + /// + /// + /// + /// + public string GetCustomerStock(int companyId, string customerStockCode) + { + return string.IsNullOrEmpty(this.GetSingleData(SingleAction.CustomerStocks, companyId, customerStockCode)) ? + this.GetSingleData(SingleAction.Stocks, companyId, customerStockCode) : + this.GetSingleData(SingleAction.CustomerStocks, companyId, customerStockCode); + } + + } +} diff --git a/src/BarCode.Web.Domain/Services/Public/WmsService.cs b/src/BarCode.Web.Domain/Services/Public/WmsService.cs new file mode 100644 index 0000000..735b851 --- /dev/null +++ b/src/BarCode.Web.Domain/Services/Public/WmsService.cs @@ -0,0 +1,57 @@ +using Microsoft.Extensions.Caching.Memory; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using BarCode.Web.Core.Dto; +using BarCode.Web.Domain.IService.Public; +using BarCode.Web.Domain.Options; +using BarCode.Web.Core.Internal.Results; +using BarCode.Web.Core.Dto.Box; +using Org.BouncyCastle.Asn1.Ocsp; +using BarCode.Web.Domain.Values; + +namespace BarCode.Web.Domain.Services.Public +{ + /// + /// ops服务 + /// + public class WmsService : IWmsService + { + private readonly IHttpClientService _httpClientService; + private readonly ILogger _logger; + private readonly IMemoryCache _memoryCache; + private int hours = 10;//过期时间 默认10小时 + private readonly WmsOptions _option; + + public WmsService(IHttpClientService httpClientService, ILogger logger, + IMemoryCache memoryCache, IOptions option) + { + this._memoryCache = memoryCache; + this._httpClientService = httpClientService; + this._logger = logger; + _option = option.Value; + } + /// + /// 重置箱信息 + /// + /// + /// + /// + public async Task>> Restart(List boxBillNos) + { + OperateStrRequest request = new OperateStrRequest() + { + Ids = boxBillNos + }; + + _logger.LogInformation($"重置箱 请求参数:{JsonConvert.SerializeObject(request)}"); + var res = await _httpClientService.PostAsync>>(_option.Url + "api/BarCode/Restart", JsonConvert.SerializeObject(request)); + _logger.LogInformation($"重置箱 返回参数:{JsonConvert.SerializeObject(res)}"); + return res; + } + } +} diff --git a/src/BarCode.Web.Domain/Services/QiniuUploadService.cs b/src/BarCode.Web.Domain/Services/QiniuUploadService.cs new file mode 100644 index 0000000..236967a --- /dev/null +++ b/src/BarCode.Web.Domain/Services/QiniuUploadService.cs @@ -0,0 +1,73 @@ +using Microsoft.Extensions.Options; +using Newtonsoft.Json; +using Qiniu.Http; +using Qiniu.Storage; +using Qiniu.Util; +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using System.Threading.Tasks; +using BarCode.Web.Core.Internal.Results; +using BarCode.Web.Domain.IService; +using BarCode.Web.Domain.Options; + +namespace BarCode.Web.Domain.Services +{ + public class QiniuUploadService : IQiniuUploadService + { + private readonly QiniuOptions _option; + public QiniuUploadService(IOptions option) + { + _option = option?.Value; + } + /// + /// 上传文件 + /// + /// + /// + /// + /// + public Task> Upload(string fileName, Stream stream, bool isAutoDelte = false) + { + // 生成(上传)凭证时需要使用此Mac + // 这个示例单独使用了一个Settings类,其中包含AccessKey和SecretKey + // 实际应用中,请自行设置您的AccessKey和SecretKey + Mac mac = new Mac(_option.AccessKey, _option.SecretKey); + + PutPolicy putPolicy = new PutPolicy(); + // 如果需要设置为"覆盖"上传(如果云端已有同名文件则覆盖),请使用 SCOPE = "BUCKET:KEY" + putPolicy.Scope = _option.Bucket + ":" + fileName; + // putPolicy.Scope = bucket; + // 上传策略有效期(对应于生成的凭证的有效期) + putPolicy.SetExpires(3600); + // 上传到云端多少天后自动删除该文件,如果不设置(即保持默认默认)则不删除 + if (isAutoDelte) + putPolicy.DeleteAfterDays = 7; + string jstr = putPolicy.ToJsonString(); + string token = Auth.CreateUploadToken(mac, jstr); + + Config config = new Config(); + // 空间对应的机房 华 东 ZONE_CN_East 华 北 ZONE_CN_North 华 南 ZONE_CN_Sout 北 美 ZONE_US_North 东南亚 ZONE_AS_Singapore + config.Zone = Zone.ZONE_CN_South; + // 是否使用https域名 + config.UseHttps = true; + // 上传是否使用cdn加速 + config.UseCdnDomains = true; + HttpResult result = null; + try + { + FormUploader fu = new FormUploader(config); + result = fu.UploadStream(stream, fileName, token, null); + if (result.Code == 200) + return Task.FromResult(Result.ReSuccess(_option.Url + fileName)); + } + catch (Exception ex) + { + Console.WriteLine(ex); + return Task.FromResult(Result.ReFailure("上传文件失败" + ex.ToString(), 0)); + } + return Task.FromResult(Result.ReFailure("上传文件失败" + JsonConvert.SerializeObject(result), 0)); + } + } +} diff --git a/src/BarCode.Web.Domain/Services/SecurityNumberService.cs b/src/BarCode.Web.Domain/Services/SecurityNumberService.cs new file mode 100644 index 0000000..57b2122 --- /dev/null +++ b/src/BarCode.Web.Domain/Services/SecurityNumberService.cs @@ -0,0 +1,234 @@ +using BarCode.Web.Core.Dto.Login; +using BarCode.Web.Core.Dto.SecurityNumbers; +using BarCode.Web.Core.Internal.Results; +using BarCode.Web.Domain.Entitys; +using BarCode.Web.Domain.Infrastructure; +using BarCode.Web.Domain.IService; +using BarCode.Web.Domain.IService.Public; +using BarCode.Web.Domain.Services.Public; +using BarCode.Web.Domain.Values; +using BarCode.Web.Domain.Values.Single; +using Microsoft.EntityFrameworkCore.Storage; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Domain.Services +{ + /// + /// 防伪码 + /// + public class SecurityNumberService : ISecurityNumberService + { + private readonly ISecurityNumbersRepositories _securityNumbersRepositories; + private readonly ISecurityGenerateRecordRepositories _sGenerateRecordRepositories; + private readonly RedisClientService _redisClientService; + private readonly IServiceScopeFactory _serviceScopeFactory; + private readonly ILogger _logger; + private IBasicsRepositories _transactionRepositories; + private readonly ISingleDataService _singleDataService; + /// + /// 序列号服务 + /// + /// + /// + /// + /// + /// + /// + public SecurityNumberService(ISecurityNumbersRepositories securityNumbersRepositories, + ISecurityGenerateRecordRepositories sGenerateRecordRepositories, + RedisClientService redisClientService, + IServiceScopeFactory serviceScopeFactory, + ILogger logger, IBasicsRepositories transactionRepositories, + ISingleDataService singleDataService) + { + _securityNumbersRepositories = securityNumbersRepositories; + _sGenerateRecordRepositories = sGenerateRecordRepositories; + _redisClientService = redisClientService; + _serviceScopeFactory = serviceScopeFactory; + _logger = logger; + _transactionRepositories = transactionRepositories; + _singleDataService = singleDataService; + } + /// + /// 下载 + /// + /// + /// + /// + public async Task DownLoad(OperateSecurityNumberRequest dto) + { + //取出所有的生成记录 + var generateRecords = await _sGenerateRecordRepositories.GetEntityList(dto.GenerateRecordIds); + if (generateRecords.Count() != dto.GenerateRecordIds.Count()) + return Result.ReFailure(ResultCodes.NoDateError); + var snGRList = await _securityNumbersRepositories.GetEntityListByGRIds(dto.GenerateRecordIds); + //修改序列号下载数 + List olist = new List(); + if (dto.IsAll) + olist = snGRList; + else + { + olist = snGRList.Where(w => dto.SecurityNumbers.Contains(w.SecurityNumber)).ToList(); + } + olist.ForEach(f => f.DownLoad()); + + + foreach (var g in generateRecords) + { + int downLoad = snGRList.Where(w => w.GenerateRecordId == g.Id && w.DownLoadNumber > 0).Count(); + g.DownLoad(downLoad); + } + + IDbContextTransaction _transaction = _transactionRepositories.GetTransaction(); + bool res_Rollback = false; + bool isSuccess = true; + if (dto.IsAll) + { + //为了增加速度 执行所有时直接执行sql语句 + isSuccess = await _securityNumbersRepositories.DownLoad(dto.GenerateRecordIds, false); + if (!isSuccess) res_Rollback = true; + } + else + { + isSuccess = await _securityNumbersRepositories.EditEntityList(olist, false); + if (!isSuccess) res_Rollback = true; + } + if (!res_Rollback) + { + var res = await _sGenerateRecordRepositories.EditEntityList(generateRecords, false); + if (!res) res_Rollback = true; + } + isSuccess = _transactionRepositories.CommitTransaction(res_Rollback, _transaction); + if (!isSuccess) return Result.ReFailure(ResultCodes.DateWriteError); + return Result.ReSuccess(); + } + /// + /// 生成防伪码 + /// + /// + /// + /// + /// + public Task Generate(GenerateSecurityNumberRequest dto, LoginInDto loginInfo) + { + _logger.LogInformation($"生成防伪码:{JsonConvert.SerializeObject(dto)},用户:{loginInfo.UserInfo.Nickname}"); + var info = _redisClientService.GetStringKey($"barcode_cenerate_security"); + if (info == true) return Task.FromResult(Result.ReFailure(ResultCodes.SecurityNumberG)); + _redisClientService.SetStringKey($"barcode_cenerate_security", true, TimeSpan.FromMinutes(5)); + + string supplierCode = ""; + string orgCode = ""; + if (dto.OrgCode.Substring(0, 1).Equals("s")) + supplierCode = dto.OrgCode.Substring(2, dto.OrgCode.Length - 2); + else + orgCode = dto.OrgCode.Substring(2, dto.OrgCode.Length - 2); + + var number = _sGenerateRecordRepositories.GetGenerateRecordDayCount().GetAwaiter().GetResult(); + number = number + 1;//从1开始 + SecurityNumberGenerateRecord sg = new SecurityNumberGenerateRecord() + { + CompanyId = loginInfo.UserInfo.CompanyId, + CreateTime = DateTime.Now, + CreatorId = loginInfo.UserInfo.UcId, + OrgCode = orgCode, + SupplierCode = supplierCode, + MaterialNumber = dto.MaterialNumber, + Number = dto.Number + }; + sg.GenerateLotNumber(number); + var isRes = _sGenerateRecordRepositories.Add(sg).GetAwaiter().GetResult(); + if (isRes == null) Task.FromResult(Result.ReFailure(ResultCodes.DateWriteError)); + + Task.Run(async () => + { + await GenerateSecurityNumber(new List() { sg }); + }); + + _redisClientService.SetStringKey($"barcode_cenerate_security", false, TimeSpan.FromMinutes(5)); + return Task.FromResult(Result.ReSuccess()); + } + + /// + /// 循环生成序列码 + /// + /// + private async Task GenerateSecurityNumber(List sgList) + { + try + { + var info = _redisClientService.GetStringKey($"cenerate_security_exec"); + if (info == true) + { + //如果当前有在生成的计划 则挂起 等生成完成 + while (true) + { + Thread.Sleep(5000); + info = _redisClientService.GetStringKey($"cenerate_security_exec"); + if (info != true) + break; + } + } + _redisClientService.SetStringKey($"cenerate_security_exec", true, TimeSpan.FromMinutes(30)); + _logger.LogInformation($"生成防伪码开始:{DateTime.Now}-{JsonConvert.SerializeObject(sgList)}"); + using (var scope = _serviceScopeFactory.CreateScope()) + { + bool isSuccess = true; + bool res_Rollback = false; + var _snRepositories = scope.ServiceProvider.GetRequiredService(); + var _sgRepositories = scope.ServiceProvider.GetRequiredService(); + _transactionRepositories = scope.ServiceProvider.GetRequiredService(); + + foreach (var sg in sgList) + { + List sList = new List(); + for (int i = 1; i <= sg.Number; i++) + { + SecurityNumbers s = new SecurityNumbers() + { + CreateTime = DateTime.Now, + CreatorId = sg.CreatorId, + OrgCode = sg.OrgCode, + SupplierCode = sg.SupplierCode, + MaterialNumber = sg.MaterialNumber, + GenerateRecordId = sg.Id + }; + sList.Add(s); + } + + //一个生成记录一个事物,这样能一条条记录对应的生成下去 成功一个是一个 + IDbContextTransaction _transaction = _transactionRepositories.GetTransaction(); + var isRes = await _snRepositories.AddRange(sList, false); + if (!isRes) + res_Rollback = true; + + if (!res_Rollback) + { + sg.Complete();//生成完成 + var sg_entity = await _sgRepositories.Edit(sg, false); + if (sg_entity == null) + res_Rollback = true; + } + //提交事务 + isSuccess = _transactionRepositories.CommitTransaction(res_Rollback, _transaction); + + if (res_Rollback || !isSuccess) + _logger.LogError("生成防伪码数据操作失败"); + } + } + _redisClientService.SetStringKey($"cenerate_security_exec", false, TimeSpan.FromMinutes(30)); + _logger.LogInformation($"生成防伪码结束 {DateTime.Now}"); + } + catch (Exception ex) + { + _logger.LogError($" 生成防伪码异常:{ex.ToString} {JsonConvert.SerializeObject(sgList)}"); + } + } + } +} diff --git a/src/BarCode.Web.Domain/Services/SerialNumberService.cs b/src/BarCode.Web.Domain/Services/SerialNumberService.cs new file mode 100644 index 0000000..ddbc339 --- /dev/null +++ b/src/BarCode.Web.Domain/Services/SerialNumberService.cs @@ -0,0 +1,423 @@ +using BarCode.Web.Core.Dto; +using BarCode.Web.Core.Dto.Erp; +using BarCode.Web.Core.Dto.Login; +using BarCode.Web.Core.Dto.SerialNumbers; +using BarCode.Web.Core.Internal.Results; +using BarCode.Web.Domain.Entitys; +using BarCode.Web.Domain.Infrastructure; +using BarCode.Web.Domain.IService; +using BarCode.Web.Domain.IService.Public; +using BarCode.Web.Domain.Services.Public; +using BarCode.Web.Domain.Values; +using BarCode.Web.Domain.Values.Single; +using Microsoft.EntityFrameworkCore.Storage; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; +using NPOI.HPSF; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Domain.Services +{ + /// + /// 序列号服务 + /// + public class SerialNumberService : ISerialNumberService + { + private readonly ISerialNumbersRepositories _serialNumbersRepositories; + private readonly ISGenerateRecordRepositories _sGenerateRecordRepositories; + private readonly RedisClientService _redisClientService; + private readonly IServiceScopeFactory _serviceScopeFactory; + private readonly ILogger _logger; + private IBasicsRepositories _transactionRepositories; + private ICenerateDataRepositories _cenerateDataRepositories; + private readonly ISingleDataService _singleDataService; + private readonly IErpService _erpService; + /// + /// 序列号服务 + /// + /// + /// + /// + /// + /// + /// + /// + public SerialNumberService(ISerialNumbersRepositories serialNumbersRepositories, + ISGenerateRecordRepositories sGenerateRecordRepositories, + RedisClientService redisClientService, + IServiceScopeFactory serviceScopeFactory, + ILogger logger, IBasicsRepositories transactionRepositories, + ICenerateDataRepositories cenerateDataRepositories, ISingleDataService singleDataService, IErpService erpService) + { + _serialNumbersRepositories = serialNumbersRepositories; + _sGenerateRecordRepositories = sGenerateRecordRepositories; + _redisClientService = redisClientService; + _serviceScopeFactory = serviceScopeFactory; + _logger = logger; + _transactionRepositories = transactionRepositories; + _cenerateDataRepositories = cenerateDataRepositories; + _singleDataService = singleDataService; + _erpService = erpService; + } + + /// + /// 生成序列号 + /// + /// + /// + /// + /// + public Task Generate(GenerateSerialNumberRequest dto, LoginInDto loginInfo) + { + if (dto.Details.Count() == 0) return Task.FromResult(Result.ReSuccess()); + //if (dto.Details.Count() > 1000) return Task.FromResult(Result.ReFailure(ResultCodes.SerialGenerateBigNumber)); + + _logger.LogInformation($"生成序列号:{JsonConvert.SerializeObject(dto)},用户:{loginInfo.UserInfo.Nickname}"); + var info = _redisClientService.GetStringKey($"barcode_cenerate_serial"); + if (info == true) return Task.FromResult(Result.ReFailure(ResultCodes.SerialNumberG)); + _redisClientService.SetStringKey($"barcode_cenerate_serial", true, TimeSpan.FromMinutes(5)); + + var materials_result = _erpService.BillQueryForMaterial().GetAwaiter().GetResult(); + List materials = new List(); + if (materials_result.IsSuccess) + materials = materials_result.Data.ToList(); + + + + var cList = dto.Details.GroupBy(g => g.Specifications).Select(s => s.Key).ToList(); + foreach (var s in cList) + { + var m = materials.FirstOrDefault(w => w.Specifications.Equals(s)); + var details = dto.Details.Where(w => w.Specifications.Equals(s)).ToList(); + if (m == null) + { + details.ForEach(f => dto.Details.Remove(f)); + } + else + { + foreach (var de in details) + { + de.MaterialNumber = m.MaterialNumber; + de.IdConvertBar = m.IdConvertBar; + + } + } + } + + string supplierCode = ""; + string orgCode = ""; + if (dto.OrgCode.Substring(0, 1).Equals("s")) + supplierCode = dto.OrgCode.Substring(2, dto.OrgCode.Length - 2); + else + orgCode = dto.OrgCode.Substring(2, dto.OrgCode.Length - 2); + + + + var dataEntity = _cenerateDataRepositories.Get(CenerateDataType.Serial).GetAwaiter().GetResult(); + int beginNumber = dataEntity.Number; + if (beginNumber == 0) + dataEntity.Number = dto.Details.Sum(s => s.Number); + else + dataEntity.Number += dto.Details.Sum(s => s.Number); + + + List sgList = new List(); + foreach (var d in dto.Details) + { + if (d.isTwo == 0)//如果套装数为0,那么自动变成1 + { + d.isTwo = 1; + } + else if(d.isTwo==2) + { + int result = d.Number % d.isTwo; + + if (result !=0)// + { + return Task.FromResult(Result.ReFailure(ResultCodes.IsTwoError)); + } + } + else if(d.isTwo>2) + { + return Task.FromResult(Result.ReFailure(ResultCodes.IsTwoError)); + } + + SerialNumberGenerateRecord sg = new SerialNumberGenerateRecord() + { + CompanyId = loginInfo.UserInfo.CompanyId, + CreateTime = DateTime.Now, + CreatorId = loginInfo.UserInfo.UcId, + OrgCode = orgCode, + IdConvertBar = d.IdConvertBar, + MaterialNumber = d.MaterialNumber, + Number = d.Number, + BeginNumber = beginNumber, + PurchaseBillNo = d.PurchaseBillNo, + SupplierCode = supplierCode, + IsTwo=d.isTwo//alter by yzh + + }; + //下一个物料开始数量要重新赋值 + beginNumber = beginNumber + d.Number; + sgList.Add(sg); + } + IDbContextTransaction _transaction = _transactionRepositories.GetTransaction(); + bool res_Rollback = false; + + var isSuccess = _sGenerateRecordRepositories.AddRange(sgList, false).GetAwaiter().GetResult(); + if (!isSuccess) res_Rollback = true; + + if (!res_Rollback) + { + var entity = _cenerateDataRepositories.Edit(dataEntity, false).GetAwaiter().GetResult(); + if (entity == null) res_Rollback = true; + } + isSuccess = _transactionRepositories.CommitTransaction(res_Rollback, _transaction); + if (!isSuccess) return Task.FromResult(Result.ReFailure(ResultCodes.DateWriteError)); + + Task.Run(async () => + { + await GenerateSerialNumber(sgList); + }); + + _redisClientService.SetStringKey($"barcode_cenerate_serial", false, TimeSpan.FromMinutes(5)); + return Task.FromResult(Result.ReSuccess()); + } + + /// + /// 循环生成序列码 + /// + /// + /// + private async Task GenerateSerialNumber(List sgList) + { + try + { + var info = _redisClientService.GetStringKey($"cenerate_serial_exec"); + if (info == true) + { + //如果当前有在生成的计划 则挂起 等生成完成 + while (true) + { + Thread.Sleep(5000); + info = _redisClientService.GetStringKey($"cenerate_serial_exec"); + if (info != true) + break; + } + } + _redisClientService.SetStringKey($"cenerate_serial_exec", true, TimeSpan.FromMinutes(30)); + + _logger.LogInformation($"生成序列码开始:{DateTime.Now}-{JsonConvert.SerializeObject(sgList)}"); + using (var scope = _serviceScopeFactory.CreateScope()) + { + bool isSuccess = true; + bool res_Rollback = false; + var _snRepositories = scope.ServiceProvider.GetRequiredService(); + var _sgRepositories = scope.ServiceProvider.GetRequiredService(); + _transactionRepositories = scope.ServiceProvider.GetRequiredService(); + + foreach (var sg in sgList) + { + List sList = new List(); + for (int i = 0; i < sg.Number; i++) + { + SerialNumbers s = new SerialNumbers() + { + CreateTime = DateTime.Now, + CreatorId = sg.CreatorId, + OrgCode = sg.OrgCode, + SupplierCode = sg.SupplierCode, + SerialNumber = sg.IdConvertBar, + MaterialNumber = sg.MaterialNumber, + Number = sg.BeginNumber + i, + IsTwo = sg.IsTwo, + thisNumber = i+1,//alter by yzh + GenerateRecordId = sg.Id + }; + sList.Add(s); + } + + //一个生成记录一个事物,这样能一条条记录对应的生成下去 成功一个是一个 + IDbContextTransaction _transaction = _transactionRepositories.GetTransaction(); + var isRes = await _snRepositories.AddRange(sList, false); + if (!isRes) + res_Rollback = true; + + if (!res_Rollback) + { + sg.Complete();//生成完成 + var sg_entity = await _sgRepositories.Edit(sg, false); + if (sg_entity == null) + res_Rollback = true; + } + //提交事务 + isSuccess = _transactionRepositories.CommitTransaction(res_Rollback, _transaction); + + if (res_Rollback || !isSuccess) + _logger.LogError("生成序列码数据操作失败"); + } + } + _redisClientService.SetStringKey($"cenerate_serial_exec", false, TimeSpan.FromMinutes(30)); + _logger.LogInformation($"生成序列码结束{DateTime.Now}"); + } + catch (Exception ex) + { + _logger.LogError($"生成序列码异常:{ex.ToString}"); + } + } + /// + /// 下载 + /// + /// + /// + /// + public async Task DownLoad(OperateSerialNumberRequest dto) + { + //取出所有的生成记录 + var generateRecords = await _sGenerateRecordRepositories.GetEntityList(dto.GenerateRecordIds); + if (generateRecords.Count() != dto.GenerateRecordIds.Count()) + return Result.ReFailure(ResultCodes.NoDateError); + var snGRList = await _serialNumbersRepositories.GetEntityListByGRIds(dto.GenerateRecordIds); + //修改序列号下载数 + List olist = new List(); + if (dto.IsAll) + olist = snGRList; + else + { + olist = snGRList.Where(w => dto.SerialNumbers.Contains(w.SerialNumber)).ToList(); + } + olist.ForEach(f => f.DownLoad()); + + + foreach (var g in generateRecords) + { + int downLoad = snGRList.Where(w => w.GenerateRecordId == g.Id && w.DownLoadNumber > 0).Count(); + g.DownLoad(downLoad); + } + + IDbContextTransaction _transaction = _transactionRepositories.GetTransaction(); + bool res_Rollback = false; + + var isSuccess = await _serialNumbersRepositories.EditEntityList(olist, false); + if (!isSuccess) res_Rollback = true; + if (!res_Rollback) + { + var res = await _sGenerateRecordRepositories.EditEntityList(generateRecords, false); + if (!res) res_Rollback = true; + } + isSuccess = _transactionRepositories.CommitTransaction(res_Rollback, _transaction); + if (!isSuccess) return Result.ReFailure(ResultCodes.DateWriteError); + return Result.ReSuccess(); + } + /// + /// 打印 + /// + /// + /// + /// + public async Task Print(OperateSerialNumberRequest dto) + { + //取出所有的生成记录 + var generateRecords = await _sGenerateRecordRepositories.GetEntityList(dto.GenerateRecordIds); + if (generateRecords.Count() != dto.GenerateRecordIds.Count()) + return Result.ReFailure(ResultCodes.NoDateError); + var snGRList = await _serialNumbersRepositories.GetEntityListByGRIds(dto.GenerateRecordIds); + //修改序列号下载数 + List olist = new List(); + if (dto.IsAll) + olist = snGRList; + else + { + olist = snGRList.Where(w => dto.SerialNumbers.Contains(w.SerialNumber)).ToList(); + } + olist.ForEach(f => f.Print()); + + foreach (var g in generateRecords) + { + int printNumber = snGRList.Where(w => w.GenerateRecordId == g.Id && w.PrintNumber > 0).Count(); + g.Print(printNumber); + + } + + IDbContextTransaction _transaction = _transactionRepositories.GetTransaction(); + bool res_Rollback = false; + + var isSuccess = await _serialNumbersRepositories.EditEntityList(olist, false); + if (!isSuccess) res_Rollback = true; + if (!res_Rollback) + { + var res = await _sGenerateRecordRepositories.EditEntityList(generateRecords, false); + if (!res) res_Rollback = true; + } + isSuccess = _transactionRepositories.CommitTransaction(res_Rollback, _transaction); + if (!isSuccess) return Result.ReFailure(ResultCodes.DateWriteError); + return Result.ReSuccess(); + } + /// + /// 反写使用数 + /// + /// + /// + public async Task Use(List sGIds) + { + var sGList = await _sGenerateRecordRepositories.GetEntityList(sGIds); + var sGSNumberList = await _serialNumbersRepositories.GetEntityListByGRIds(sGIds); + + foreach (var sg in sGList) + { + int number = sGSNumberList.Where(w => w.GenerateRecordId == sg.Id && w.BoxId > 0).Count(); + sg.Use(number); + } + + var isSuccess = await _sGenerateRecordRepositories.EditEntityList(sGList, false); + if (!isSuccess) return Result.ReFailure(ResultCodes.DateWriteError); + return Result.ReSuccess(); + } + /// + /// 修改序列码物料 + /// + /// + /// + /// + public async Task UpdateMaterial(UpdateMaterialRequest dto) + { + //取出所有的生成记录 + var generateRecord = await _sGenerateRecordRepositories.GetEntity(dto.GenerateRecordId); + if (generateRecord == null) + return Result.ReFailure(ResultCodes.NoDateError); + var serialNumbers = await _serialNumbersRepositories.GetEntityList(dto.SerialNumbers); + + var exec_m = serialNumbers.Where(w => w.MaterialNumber == dto.MaterialNumber).Select(s => s.MaterialNumber).ToList(); + if (exec_m.Count() > 0) + return Result.ReFailure($"序列号{string.Join(",", exec_m)}对应物料跟需要修改的物料一致", 611007); + + //修改物料 + foreach (var s in serialNumbers) + { + var res = s.UpdateMaterial(dto.MaterialNumber); + if (!res.IsSuccess) return res; + } + generateRecord.UpdateMaterial(); + + IDbContextTransaction _transaction = _transactionRepositories.GetTransaction(); + bool res_Rollback = false; + + var isSuccess = await _serialNumbersRepositories.EditEntityList(serialNumbers, false); + if (!isSuccess) res_Rollback = true; + if (!res_Rollback) + { + var res = await _sGenerateRecordRepositories.Edit(generateRecord, false); + if (res == null) res_Rollback = true; + } + isSuccess = _transactionRepositories.CommitTransaction(res_Rollback, _transaction); + if (!isSuccess) return Result.ReFailure(ResultCodes.DateWriteError); + return Result.ReSuccess(); + } + } +} diff --git a/src/BarCode.Web.Domain/TimedJob/ErpBaseDataSyncJob.cs b/src/BarCode.Web.Domain/TimedJob/ErpBaseDataSyncJob.cs new file mode 100644 index 0000000..007e774 --- /dev/null +++ b/src/BarCode.Web.Domain/TimedJob/ErpBaseDataSyncJob.cs @@ -0,0 +1,76 @@ +using BarCode.Web.Core.Dto.Erp; +using Microsoft.Extensions.Caching.Memory; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using Pomelo.AspNetCore.TimedJob; +using System; +using System.Collections.Generic; +using System.Text; +using BarCode.Web.Core.Dto.Erp; +using BarCode.Web.Core.Dto.Erp.Customer; +using BarCode.Web.Core.Dto.Erp.Org; +using BarCode.Web.Core.Dto.Erp.Supplier; +using BarCode.Web.Domain.IService.Public; +using BarCode.Web.Domain.Options; +using BarCode.Web.Domain.Services.Public; + +namespace BarCode.Web.Domain.TimedJob +{ + /// + /// erp基础数据-同步定时任务 + /// + public class ErpBaseDataSyncJob : Job + { + private readonly IMemoryCache _memoryCache; + private readonly ErpOptions _erpOptions; + private ILogger _logger; + private readonly IServiceProvider _serviceProvider; + public ErpBaseDataSyncJob(IServiceProvider serviceProvider,IMemoryCache memoryCache, IOptions erpOptions, ILogger logger) + { + _serviceProvider = serviceProvider; + _memoryCache = memoryCache; + this._erpOptions = erpOptions?.Value; + this._logger = logger; + } + + //[Invoke(Begin = "2022-03-02 01:01", Interval = 1000 * 60 * 60 * 24, SkipWhileExecuting = true)] + //30分钟执行一次 + [Invoke(Begin = "2024-01-15 17:43", Interval = 1000 * 60 * 30, SkipWhileExecuting = true)] + public void Run() + { + //this.SyscErpBaseData(); + } + + public void SyscErpBaseData() + { + string tip = ""; + _logger.LogInformation($"----------异步:定时任务拉取---------"); + var sercice = _serviceProvider.GetRequiredService(); + var materials = _memoryCache.Get>(_erpOptions.cache_materail_key); + if (materials == null || materials.Count == 0) + ErpBaseDataSync.SyncMaterial(sercice); + else + tip = tip + "物料缓存未失效;"; + + var orgs = _memoryCache.Get>(_erpOptions.cache_org_key); + if (orgs == null || orgs.Count == 0) + ErpBaseDataSync.SyncOrg(sercice); + else + tip = tip + "组织缓存未失效;"; + var suppliers = _memoryCache.Get>(_erpOptions.cache_supplier_key); + if (suppliers == null || suppliers.Count == 0) + ErpBaseDataSync.SyncSupplier(sercice); + else + tip = tip + "供应商缓存未失效;"; + var customers = _memoryCache.Get>(_erpOptions.cache_customer_key); + if (customers == null || customers.Count == 0) + ErpBaseDataSync.SyncCustomer(sercice); + else + tip = tip + "客户缓存未失效;"; + + if (!string.IsNullOrEmpty(tip)) + _logger.LogInformation($"异步:定时任务拉取-->" + tip); + } + } +} diff --git a/src/BarCode.Web.Domain/Values/BoxStatus.cs b/src/BarCode.Web.Domain/Values/BoxStatus.cs new file mode 100644 index 0000000..f19be58 --- /dev/null +++ b/src/BarCode.Web.Domain/Values/BoxStatus.cs @@ -0,0 +1,32 @@ +using BarCode.Web.Core; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Domain.Values +{ + /// + /// 箱状态 + /// + public enum BoxStatus + { + /// + /// 未使用 + /// + [EnumRemark("未使用")] + NoUse = 0, + /// + /// 未完成 + /// + [EnumRemark("未完成")] + NoComplete = 1, + /// + /// 已完成 + /// + [EnumRemark("已完成")] + Complete = 2, + + } +} diff --git a/src/BarCode.Web.Domain/Values/CenerateDataType.cs b/src/BarCode.Web.Domain/Values/CenerateDataType.cs new file mode 100644 index 0000000..8540c41 --- /dev/null +++ b/src/BarCode.Web.Domain/Values/CenerateDataType.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Text; +using BarCode.Web.Core; + +namespace BarCode.Web.Domain.Values +{ + /// + /// 自动生成数据 序列码和防伪码 + /// + public enum CenerateDataType + { + /// + /// 序列码生成 + /// + [EnumRemark("序列码生成")] + Serial = 1 + } +} diff --git a/src/BarCode.Web.Domain/Values/Erp/FormIdParam.cs b/src/BarCode.Web.Domain/Values/Erp/FormIdParam.cs new file mode 100644 index 0000000..38c7ba2 --- /dev/null +++ b/src/BarCode.Web.Domain/Values/Erp/FormIdParam.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Domain.Values.Erp +{ + /// + /// 业务对象表单Id:对应erp的单据表的名称 + /// + public enum FormIdParam + { + /// + /// 采购订单 + /// + PUR_PurchaseOrder = 1, + /// + /// 采购入库单 + /// + STK_InStock = 2, + /// + /// 其他入库单 + /// + STK_MISCELLANEOUS = 3, + /// + /// 直接调拨单-里面包含出和入 + /// + STK_TransferDirect = 4, + /// + /// 分步式调入单 + /// + STK_TRANSFERIN = 5, + /// + /// 组装拆卸单:里面包含出和入 + /// + STK_AssembledApp = 6, + /// + /// 组织 + /// + ORG_Organizations = 7, + /// + /// 供应商 + /// + BD_Supplier = 8, + /// + /// 仓库 + /// + BD_STOCK = 9, + /// + /// 盘盈单 + /// + STK_StockCountGain = 10, + /// + /// 盘亏单 + /// + STK_StockCountLoss = 11, + /// + /// 物料 + /// + BD_MATERIAL = 12, + /// + /// 销售发货通知单 + /// + SAL_DELIVERYNOTICE = 13, + /// + /// 其他出库单 + /// + STK_MisDelivery = 14, + /// + /// 分布式调出单 + /// + STK_TRANSFEROUT = 15, + /// + /// 客户 + /// + BD_Customer = 16, + /// + /// 销售出库单 + /// + SAL_OUTSTOCK = 17, + /// + /// 即时库存 + /// + STK_Inventory = 18 + } +} diff --git a/src/BarCode.Web.Domain/Values/ExportStatus.cs b/src/BarCode.Web.Domain/Values/ExportStatus.cs new file mode 100644 index 0000000..ae884f0 --- /dev/null +++ b/src/BarCode.Web.Domain/Values/ExportStatus.cs @@ -0,0 +1,30 @@ + +using System; +using System.Collections.Generic; +using System.Text; +using BarCode.Web.Core; + +namespace BarCode.Web.Domain.Values +{ + /// + /// 文件导出状态 + /// + public enum ExportStatus + { + /// + /// 正在导出 + /// + [EnumRemark("正在导出")] + Ing = 0, + /// + /// 导出成功 + /// + [EnumRemark("导出成功")] + Success = 1, + /// + /// 导出失败 + /// + [EnumRemark("导出失败")] + Fail = 2 + } +} diff --git a/src/BarCode.Web.Domain/Values/FileDownLoadOrderType.cs b/src/BarCode.Web.Domain/Values/FileDownLoadOrderType.cs new file mode 100644 index 0000000..4315804 --- /dev/null +++ b/src/BarCode.Web.Domain/Values/FileDownLoadOrderType.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Text; +using BarCode.Web.Core; + +namespace BarCode.Web.Domain.Values +{ + /// + /// 导出单据类型 + /// + public enum FileDownLoadOrderType + { + /// + /// 条码下载 + /// + [EnumRemark("条码下载")] + SerialNumbers = 1, + /// + /// 条码详情下载 + /// + [EnumRemark("条码详情下载")] + SerialNumberInfo = 2, + /// + /// 防伪码下载 + /// + [EnumRemark("防伪码下载")] + SecurityNumbers = 3, + /// + /// 防伪码详情下载 + /// + [EnumRemark("防伪码详情下载")] + SecurityNumberInfo = 4 + } +} diff --git a/src/BarCode.Web.Domain/Values/ResultCodes.cs b/src/BarCode.Web.Domain/Values/ResultCodes.cs new file mode 100644 index 0000000..0333a6b --- /dev/null +++ b/src/BarCode.Web.Domain/Values/ResultCodes.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Domain.Values +{ + /// + /// 错误提示信息 + /// + public partial class ResultCodes + { + public static ValueTuple Erp_Login_Error = (1001, "同步金蝶登录错误,请稍候再试"); + + public static ValueTuple Erp_BillQuery_Error = (1002, "同步金蝶数据出错,请稍等再试"); + public static ValueTuple Erp_Inventory_Error = (1003, "获取金蝶即时库存数据出错,请稍等再试"); + /// + /// 无效 + /// + public static ValueTuple Token_Invalid_Error = (401, "验证Token无效,请重新登录"); + /// + /// 数据操作失败 + /// + public static ValueTuple DateWriteError = (40004, "数据操作失败"); + public static ValueTuple NoDateError = (40005, "数据不存在"); + public static ValueTuple NoOrgError = (40006, "组织信息不存在"); + public static ValueTuple IsTwoError = (70001, "两件装产品,数量需填双数"); + + /// + /// 没有菜单权限,无法登录 + /// + public static ValueTuple NoRoot = (40005, "没有菜单权限,无法登录"); + public static ValueTuple ErpSyns = (40006, "正在同步金蝶数据,请稍候再试!"); + public static ValueTuple ErpSynsError = (40006, "同步金蝶数据失败!"); + public static ValueTuple ErpOrgError = (80004, "获取Erp相关组织数据失败,请稍候再试!"); + public static ValueTuple ErpSupplierError = (80005, "获取Erp相关供应商数据失败,请稍候再试!"); + public static ValueTuple ErpStockError = (80006, "获取Erp相关仓库数据失败,请稍候再试!"); + public static ValueTuple ErpSubStockError = (80006, "获取Erp相关子仓库数据失败,请稍候再试!"); + public static ValueTuple ErpMaterialError = (80007, "获取Erp相关物料数据失败,请稍候再试!"); + public static ValueTuple BoxHaveError = (80008, "箱号已收货"); + public static ValueTuple AdjustError = (80009, "与金蝶校准发生错误,请稍候再试!"); + public static ValueTuple MateriaNoData = (800011, "产品信息不存在"); + public static ValueTuple SerialNumberNoDateError = (500001, "序列号数据不存在"); + public static ValueTuple SerialNumberG = (400007, "当前有序列号正在生成,请稍后再试"); + public static ValueTuple SecurityNumberG = (400008, "当前有防伪码正在生成,请稍后再试"); + public static ValueTuple SerialGenerateBigNumber = (400009, "生成条码一次最多不能超过1000个物料"); + public static ValueTuple CartonCompleteError = (600001, "该箱已完成装箱, 需再次装箱请操作重新装箱"); + public static ValueTuple SerialNumberBindBox = (600002, "序列号已装过箱"); + public static ValueTuple SerialNumberIsUse = (600002, "序列号已被扫描使用"); + public static ValueTuple BoxNoDataError = (600003, "请扫描系统存在的箱号"); + public static ValueTuple BoxMaterialNoDataError = (600004, "箱信息不包含该物料"); + public static ValueTuple BoxSerialNumberNoDataError = (600005, "箱信息不包含该序列号"); + public static ValueTuple SerialNumberNoData = (600006, "请扫描系统存在的序列号"); + /// + /// 箱号不符合规则 + /// + public static ValueTuple BoxNO_Invalid_Error = (600006, "箱号只能包含CTN和数字"); + public static ValueTuple BoxNoComplete = (600007, "箱没有完成装箱,不能重新装箱"); + public static ValueTuple SerialNumbersNoData = (610000, "序列号不存在"); + public static ValueTuple NumberCode_Invalid_Error = (600008, "数字序列号必须是大于11位的纯数字"); + + + + } +} diff --git a/src/BarCode.Web.Domain/Values/Single/SingleAction.cs b/src/BarCode.Web.Domain/Values/Single/SingleAction.cs new file mode 100644 index 0000000..03c7c37 --- /dev/null +++ b/src/BarCode.Web.Domain/Values/Single/SingleAction.cs @@ -0,0 +1,122 @@ +using System; +using System.Collections.Generic; +using System.Text; +using BarCode.Web.Core; + +namespace BarCode.Web.Domain.Values.Single +{ + /// + /// 对接单点的接口方法-枚举 + /// + public enum SingleAction + { + /// + /// 组织集合 + /// + [EnumRemark("组织")] + Orgs = 1, + /// + /// 用户集合 + /// + [EnumRemark("用户")] + Users = 2, + /// + /// 人员集合 + /// + [EnumRemark("人员")] + Staffs = 3, + /// + /// 供应商集合 + /// + [EnumRemark("供应商")] + Suppliers = 4, + /// + /// 客户集合 + /// + [EnumRemark("客户")] + Customers = 5, + /// + /// 收款条件集合 + /// + [EnumRemark("收款条件")] + CollectionTerms = 6, + /// + /// 付款条件集合 + /// + [EnumRemark("付款条件")] + PaymentTerms = 7, + /// + /// 结算方式集合 + /// + [EnumRemark("结算方式")] + SettlementMethods = 8, + /// + /// 结算币别集合 + /// + [EnumRemark("结算币别")] + SettlementCurrencys = 9, + /// + /// 税率集合 + /// + [EnumRemark("税率")] + TaxRates = 10, + /// + /// 汇率集合 + /// + [EnumRemark("汇率")] + ExchangeRates = 11, + /// + /// 仓库集合 + /// + [EnumRemark("仓库")] + Stocks = 12, + /// + /// 单位集合 + /// + [EnumRemark("单位")] + Units = 13, + /// + /// 客户仓库集合 + /// + [EnumRemark("客户仓库")] + CustomerStocks = 14, + /// + /// 部门集合 + /// + [EnumRemark("部门")] + Depts = 15, + /// + /// 仓库211集合 + /// + [EnumRemark("仓库211")] + StocksWith211 = 16, + /// + /// 供应商默认联系人集合 + /// + [EnumRemark("供应商默认联系人")] + SuppliersContacts = 17, + /// + /// 菜单集合 + /// + [EnumRemark("菜单")] + Menus = 18, + /// + /// 仓位集合 + /// + [EnumRemark("仓位")] + SubStocks = 19, + + /// + /// 仓库:编码与组织编码结合 + /// + [EnumRemark("仓库")] + StocksJoinOrgCode=20, + + /// + /// 仓库:编码与组织编码结合 + /// + [EnumRemark("仓位与仓库与组织")] + SubStocksJoinOrgCode + + } +} diff --git a/src/BarCode.Web.Domain/Values/Single/SingleControllerType.cs b/src/BarCode.Web.Domain/Values/Single/SingleControllerType.cs new file mode 100644 index 0000000..69f9f1f --- /dev/null +++ b/src/BarCode.Web.Domain/Values/Single/SingleControllerType.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Domain.Values.Single +{ + /// + /// 单点-控制器枚举 + /// + public enum SingleControllerType + { + /// + /// 单点OPS列表数据-控制器 + /// + Single = 1, + /// + /// 单点配置项数据-控制器 + /// + SysConfig = 2, + /// + /// 单点登录项数据-控制器 + /// + Login = 3, + /// + /// 单点公共接口数据-控制器 + /// + Public = 4 + } +} diff --git a/src/BarCode.Web.Domain/Values/Single/SingleLoginAction.cs b/src/BarCode.Web.Domain/Values/Single/SingleLoginAction.cs new file mode 100644 index 0000000..2a0f14e --- /dev/null +++ b/src/BarCode.Web.Domain/Values/Single/SingleLoginAction.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Domain.Values.Single +{ + /// + /// 单点数据接口-登录要使用的数据接口-方法枚举 + /// + public enum SingleLoginAction + { + /// + /// 菜单 + /// + Menus = 1, + /// + /// 人员 + /// + Staff = 2, + /// + /// 公司 + /// + Company = 3, + /// + /// 供应商 + /// + Supplier = 4, + /// + /// 客户 + /// + Customer = 5, + /// + /// 全部信息 + /// + All = 6, + /// + /// 公司信息 + /// + CompanyInfo = 7, + + } +} diff --git a/src/BarCode.Web.Domain/Values/Single/SysConfigAction.cs b/src/BarCode.Web.Domain/Values/Single/SysConfigAction.cs new file mode 100644 index 0000000..17e6369 --- /dev/null +++ b/src/BarCode.Web.Domain/Values/Single/SysConfigAction.cs @@ -0,0 +1,223 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Domain.Values.Single +{ + /// + /// 单点数据:配置项和公共接口的方法枚举值 + /// + public enum SysConfigAction + { + /// + /// 供应商-根据名称和公司 + /// + GetSupplierByNameAndCompany = 1, + /// + /// 组织-根据公司 + /// + GetOrgByCompany = 2, + /// + /// 部门-根据组织和公司 + /// + GetDeptByOrgAndCompany = 3, + /// + /// 人员-根据公司 + /// + GetStaffByCompany = 4, + /// + /// 人员-根据部门和公司 + /// + GetStaffByDeptAndCompany = 5, + /// + /// 人员-根据组织和公司 + /// + GetStaffByOrgAndCompany = 6, + /// + /// 客户-根据公司 + /// + GetCustomerByCompany = 7, + /// + /// 客户-根据客户和组织和公司 + /// + GetCustomerByCustomerAndOrgAndCompany = 8, + /// + /// 客户信息-根据客户和组织和公司 + /// + GetCustomerInfoByCustomerAndOrgAndCompany = 9, + /// + /// 收款条件-根据公司 + /// + GetCollectionTermsByCompany = 10, + /// + /// 付款条件-根据公司 + /// + GetPaymentTermByCompany = 11, + /// + /// 结算方式-根据公司 + /// + GetSettlementMethodByCompany = 12, + /// + /// 结算币别-根据公司 + /// + GetSettlementCurrencyByCompany = 13, + /// + /// 单位-根据公司 + /// + GetUnitByCompany = 14, + /// + /// 单位(部分属性)-根据公司 + /// + GetUnitPropertyByCompany = 15, + /// + /// 税率-根据公司 + /// + GetTaxRateByCompany = 16, + /// + /// 仓库-根据名称和公司 + /// + GetWarehouseByNameAndCompany = 17, + /// + /// 仓库-根据组织和公司 + /// + GetWarehouseByOrgAndCompany = 18, + /// + /// 仓库(不是调拨中转仓)-根据组织和公司 + /// + GetWarehouseByOrgAndCompanyForNotTransfer = 19, + /// + /// 仓库(211)-根据组织和公司 + /// + GetWarehouseByOrgAndCompanyFor211 = 20, + /// + /// 仓库-根据客户和公司 + /// + GetWareouseByCustomerAndCompany = 21, + + /// + /// 仓位-根据仓库 + /// + GetChildWarehouseByPid = 22, + /// + /// 仓位-根据- + /// + GetChildWarehouse = 23, + /// + /// 汇率信息-根据原币、目标币和公司 + /// + GetRateInfoByFromToAndCompany = 24, + /// + /// 客户仓库-根据客户和组织和公司 + /// + GetCustomerStockByCustomerAndOrgAndCompany = 25, + /// + /// 付款条件,结算币别,结算方式,采购员,采购部门-根据供应商和组织 + /// + GetPtAndScAndSmAndBuyerAndDeptBySupplierAndOrg = 26, + /// + /// 获取仓库:根据仓库id + /// + GetWarehouseByIds = 27, + /// + /// 获取库存:根据组织和公司 + /// + GetCustomerByOrgAndCompany = 28, + + /// + /// 获取客户仓库:根据客户IDS和组织和公司 + /// + GetCustomerStockByCustomerListAndOrgAndCompany = 29, + /// + /// 汇率(所有) + /// + GetRateListByFromToAndCompany = 30, + + /// + /// 供应商选择后获取:付款条件,结算币别,结算方式,采购员,采购部门,根据组织IDS + /// + GetPtAndScAndSmAndBuyerAndDeptByOrgs = 31, + /// + /// 获取客户仓库:根据code集合 + /// + GetCustomerStockListByCodes = 32, + /// + /// 供应商:根据ids + /// + GetSupperByIds = 33, + /// + /// 根据公司搜索所有仓库(计算补货频次) + /// + GetWarehouseReplenDatebyCompany = 34, + /// + /// 获取仓库:根据codes + /// + GetWarehouseByCodes = 35, + /// + /// 获取客户仓库:根据codes + /// + GetCustomerStockByCodes = 36, + + /// + /// 获取调拨中转仓库:根据公司 + /// + GetWarehouseTransferByCompany = 37, + /// + /// 获取供应商数据根据ids + /// + GetSupperAbout1ByIds = 38, + /// + /// 获取仓库:根据默认补货客户 + /// + GetWarehouseByDefaultReplenishCustomer = 39, + /// + /// 获取用户(ID和Name):根据公司 + /// + GetUsersByCompany = 40, + /// + /// 全部部门-根据组织和公司:不处理子级 + /// + GetDeptAllByOrgAndCompany = 41, + + /// + /// 获取全部员工:根据公司和组织 + /// + GetStaffAllByOrgAndCompany = 42, + + /// + /// 获取仓库::根据管理系统code和仓库名称和公司ID,备注系统code和公司ID是必填 + /// + GetWmsWarehouseBySystemCodeAndNameAndCompany = 43, + + /// + /// 获取仓库::根据管理系统code和仓位名称和公司ID,备注系统code和公司ID是必填 + /// + GetWmsSubWarehouseBySystemCodeAndNameAndCompany = 44, + + /// + /// 获取仓位详情:根据仓位ID和公司ID + /// + GetWmsSubWarehouseByIdAndCompany = 45, + /// + /// 获取仓位详情:根据仓位ID集合和公司ID + /// + GetWmsSubWarehouseByIdsAndCompany = 46, + + /// + /// 获取仓位详情:根据仓位Code和公司ID + /// + GetWmsSubWarehouseByCodeAndCompany = 47, + + /// + /// 获取仓位详情:根据仓位Codes集合和公司ID + /// + GetWmsSubWarehouseByCodesAndCompany = 48, + /// + /// 根据用户获取组织 + /// + GetOrgByUser = 49, + /// + /// 根据用户获取供应商 + /// + GetSupplierByUser = 50 + } +} diff --git a/src/BarCode.Web.Repositories/BarCode.Web.Repositories.csproj b/src/BarCode.Web.Repositories/BarCode.Web.Repositories.csproj new file mode 100644 index 0000000..6dc3500 --- /dev/null +++ b/src/BarCode.Web.Repositories/BarCode.Web.Repositories.csproj @@ -0,0 +1,30 @@ + + + + net8.0 + enable + enable + true + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/BarCode.Web.Repositories/BasicsRepositories.cs b/src/BarCode.Web.Repositories/BasicsRepositories.cs new file mode 100644 index 0000000..9928314 --- /dev/null +++ b/src/BarCode.Web.Repositories/BasicsRepositories.cs @@ -0,0 +1,197 @@ +using AutoMapper; +using Microsoft.EntityFrameworkCore.Storage; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using BarCode.Web.Core.Dto.SingleData; +using BarCode.Web.Core.Internal.Results; +using BarCode.Web.Domain.Infrastructure; +using BarCode.Web.Domain.IService.Public; +using BarCode.Web.Domain.Values; +using BarCode.Web.Domain.Values.Single; +using BarCode.Web.Repositories.Configuration; +using System.ComponentModel.Design; +using Microsoft.Extensions.Caching.Memory; + +namespace BarCode.Web.Repositories +{ + /// + /// 基础数据 + /// + public class BasicsRepositories : IBasicsRepositories + { + private readonly IMapper _mapper; + private readonly IServiceProvider _serviceProvider; + private RepositoryDbContext _context; + private readonly ILoginRepositories _loginService; + private readonly ISingleDataService _singleDataService; + private readonly IMemoryCache _memoryCache; + + public BasicsRepositories(RepositoryDbContext context, IMapper mapper, IServiceProvider serviceProvider, + ILoginRepositories loginService, ISingleDataService singleDataService, + IMemoryCache memoryCache) + { + _context = context; + _mapper = mapper; + _serviceProvider = serviceProvider; + _loginService = loginService; + _singleDataService = singleDataService; + _memoryCache = memoryCache; + } + /// + /// 获取所有人员 + /// + /// + /// + public async Task> GetStaffListAsync(int CompanyId) + { + var result = await _singleDataService.GetSysConfigData, SingleDataRequest> + (new SingleDataRequest(CompanyId), + SysConfigAction.GetStaffByCompany); + if (!result.Success) + return null; + return result.Data.ToList(); + } + + public async Task> GetSubUcStockAsync(int stockId) + { + var result = await _singleDataService.GetSysConfigData, SubStockRequest> + (new SubStockRequest(stockId), + SysConfigAction.GetChildWarehouseByPid); + if (!result.Success) + return null; + return result.Data.ToList(); + } + + public async Task> GetSubUcStockAsync(string systemCode, string name, int companyId) + { + var result = await _singleDataService.GetSysConfigData, SystemCodeRequest> + (new SystemCodeRequest(systemCode, name, companyId), + SysConfigAction.GetWmsSubWarehouseBySystemCodeAndNameAndCompany); + if (!result.Success) + return null; + return result.Data.ToList(); + } + + /// + /// 获取仓位详情:根据仓位ID和公司ID + /// + /// + /// + /// + public async Task GetSubUcStockAsync(int id, int companyId) + { + var result = await _singleDataService.GetSysConfigData, IdRequest> + (new IdRequest(id, companyId), + SysConfigAction.GetWmsSubWarehouseByIdAndCompany); + if (!result.Success) + return null; + return result.Data; + } + + /// + /// 获取仓位集合:根据仓位ID集合和公司ID + /// + /// + /// + /// + public async Task> GetSubUcStockAsync(List ids, int companyId) + { + var result = await _singleDataService.GetSysConfigData, IdsRequest> + (new IdsRequest(ids, companyId), + SysConfigAction.GetWmsSubWarehouseByIdsAndCompany); + if (!result.Success) + return null; + return result.Data.ToList(); + } + /// + /// 获取仓位详情:根据仓位编码和公司ID + /// + /// + /// + /// + public async Task GetSubUcStockAsync(string code, int companyId) + { + var result = await _singleDataService.GetSysConfigData, CodeRequest> + (new CodeRequest(code, companyId), + SysConfigAction.GetWmsSubWarehouseByCodeAndCompany); + if (!result.Success) + return null; + return result.Data; + } + /// + /// 获取仓位集合:根据仓位编码集合和公司ID + /// + /// + /// + /// + public async Task> GetSubUcStockAsync(List codes, int companyId) + { + var result = await _singleDataService.GetSysConfigData, CodesRequest> + (new CodesRequest(codes, companyId), + SysConfigAction.GetWmsSubWarehouseByCodesAndCompany); + if (!result.Success) + return null; + return result.Data.ToList(); + } + public async Task> GetUcStockAsync(string systemCode, string name, int companyId) + { + var result = await _singleDataService.GetSysConfigData, SystemCodeRequest> + (new SystemCodeRequest(systemCode, name, companyId), + SysConfigAction.GetWmsWarehouseBySystemCodeAndNameAndCompany); + if (!result.Success) + return null; + return result.Data.ToList(); + } + + public IDbContextTransaction GetTransaction() + { + return _context.Database.BeginTransaction(); + } + + public bool CommitTransaction(bool isRollback, IDbContextTransaction transaction) + { + try + { + if (transaction == null) + return true; + + if (isRollback) + { + transaction.Rollback(); + return false; + } + transaction.Commit(); + } + catch (Exception ex) + { + transaction.Rollback(); + return false; + } + return true; + } + /// + /// 根据用户名精确匹配用户 + /// + /// + /// + /// + public Task> GetUserIdsAsync(string name, int companyId) + { + var cache_key = SingleAction.Users + "_" + companyId + "_IdGetName"; + var dic = _memoryCache.Get>(cache_key); + if (dic == null) + { + var str = _singleDataService.GetSingleData(SingleAction.Users, companyId, 0); + dic = _memoryCache.Get>(cache_key); + if (dic == null) + return Task.FromResult(new List()); + } + + var v = from d in dic where d.Value.Equals(name) select d; + return Task.FromResult(v.Select(s => s.Key).ToList()); + } + } +} diff --git a/src/BarCode.Web.Repositories/BoxMarkRepositories.cs b/src/BarCode.Web.Repositories/BoxMarkRepositories.cs new file mode 100644 index 0000000..388c9ce --- /dev/null +++ b/src/BarCode.Web.Repositories/BoxMarkRepositories.cs @@ -0,0 +1,312 @@ +using AutoMapper; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Storage; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using BarCode.Web.Core.Dto; +using BarCode.Web.Core.Dto.Erp; +using BarCode.Web.Domain.Entitys; +using BarCode.Web.Domain.Infrastructure; +using BarCode.Web.Domain.IService.Public; +using BarCode.Web.Domain.Values.Single; +using BarCode.Web.Repositories.Configuration; +using BarCode.Web.Core.Dto.Login; + +namespace BarCode.Web.Repositories +{ + /// + /// 箱唛-仓储 + /// + public class BoxMarkRepositories : IBoxMarkRepositories + { + private readonly ILoginRepositories _loginRepositories; + private readonly RepositoryDbContext _context; + private readonly ISingleDataService _singleDataService; + private readonly IErpService _erpService; + private readonly IErpBasicDataExtendService _erpBasicDataExtendService; + private readonly IBasicsRepositories _basicsRepositories; + + + public BoxMarkRepositories(RepositoryDbContext context, + IErpService erpService, + ILoginRepositories loginRepositories, + ISingleDataService singleDataService, + IBasicsRepositories basicsRepositories, + IErpBasicDataExtendService erpBasicDataExtendService) + { + _context = context; + _erpService = erpService; + _basicsRepositories = basicsRepositories; + _loginRepositories = loginRepositories; + _singleDataService = singleDataService; + _erpBasicDataExtendService = erpBasicDataExtendService; + } + + /// + /// 列表-分页 + /// + /// + /// + public async Task<(List list, int total)> GetPagedList(BoxMarkQueryRequest dto, LoginInDto loginInfo) + { + //1.获取物料集合和组织集合和供应商的集合 + var materials = new List(); + var materials_result = await _erpService.BillQueryForMaterial(); + if (materials_result.IsSuccess) + materials = materials_result.Data.ToList(); + + List materialNumbs = new List(); + + //物料集合;模糊查询后的物料集合 + if (!string.IsNullOrEmpty(dto.Material)) + materialNumbs = materials.Where(w => w.MaterialNumber.Contains(dto.Material) || w.MaterialName.Contains(dto.Material) || w.Specifications.Contains(dto.Material)).Select(x => x.MaterialNumber).ToList(); + + List cr_ids = new List(); + if (!string.IsNullOrEmpty(dto.Creator)) + { + cr_ids = await _basicsRepositories.GetUserIdsAsync(dto.Creator, loginInfo.UserInfo.CompanyId); + } + var query = _context.BoxMarkBillNo + .GroupJoin(_context.BoxMark, detail => detail.Fid, order => order.Id, (detail, orders) => new { detail, orders }) + .SelectMany(x => x.orders.DefaultIfEmpty(), (p, order) => new { p.detail, order }) + .OrderByDescending(x => x.order.Id).ThenByDescending(x => x.detail.FirstBillNo).ThenByDescending(x => x.detail.LastBillNo) + .Where(adv => 1 == 1); + + if (loginInfo.UserInfo.IsAdmin != true && !string.IsNullOrEmpty(dto.OrgCode)) + { + var rec_type = dto.OrgCode.Substring(0, 1); + var rec_code = dto.OrgCode.Substring(2, dto.OrgCode.Length - 2); + + if (rec_type.Equals("s"))//供应商 + query = query.Where(w => rec_code == w.order.SupplierCode); + else//查其他单据(组织) + query = query.Where(w => rec_code == w.order.OrgCode); + } + ////编号查询 + //if (!string.IsNullOrEmpty(dto.BeginBillNo) && + // !string.IsNullOrEmpty(dto.EndBillNo)) + //{ + // if (dto.BeginBillNo.ToString().Length >= 13 && dto.EndBillNo.ToString().Length >= 13) + // { + // var begYMD = Convert.ToInt32(dto.BeginBillNo.Substring(2, 6)); + // var endYMD = Convert.ToInt32(dto.EndBillNo.Substring(2, 6)); + + // var begNo = Convert.ToInt32(dto.BeginBillNo.Substring(8)); + // var endNo = Convert.ToInt32(dto.EndBillNo.Substring(8)); + // query = query.Where(w => w.detail.FirstBillNo >= begYMD && w.detail.FirstBillNo <= endYMD && w.detail.LastBillNo >= begNo && w.detail.LastBillNo <= endNo); + // } + // else + // query = query.Where(w => w.detail.BillNo == dto.BeginBillNo || w.detail.BillNo == dto.EndBillNo); + //} + //else if (!string.IsNullOrEmpty(dto.BeginBillNo)) + // query = query.Where(w => w.detail.BillNo == dto.BeginBillNo); + //else if (!string.IsNullOrEmpty(dto.EndBillNo)) + // query = query.Where(w => w.detail.BillNo == dto.EndBillNo); + if (!string.IsNullOrEmpty(dto.BeginBillNo) && dto.BeginBillNo.ToString().Length >= 13) + { + var begYMD = Convert.ToInt32(dto.BeginBillNo.Substring(2, 6)); + + var begNo = Convert.ToInt32(dto.BeginBillNo.Substring(8)); + + query = query.Where(w => w.detail.FirstBillNo >= begYMD + && w.detail.LastBillNo >= begNo); + } + if (!string.IsNullOrEmpty(dto.EndBillNo) && dto.EndBillNo.ToString().Length >= 13) + { + var endYMD = Convert.ToInt32(dto.EndBillNo.Substring(2, 6)); + var endNo = Convert.ToInt32(dto.EndBillNo.Substring(8)); + + query = query.Where(w => w.detail.FirstBillNo <= endYMD + && w.detail.LastBillNo <= endNo); + } + + + //订单号查询 + if (!string.IsNullOrEmpty(dto.OrderBillNos)) + { + var orderBNS = dto.OrderBillNos.Replace(",", ","); + var orderBillNoList = orderBNS.Split(",").Where(x => !string.IsNullOrEmpty(x)).ToList(); + if (orderBillNoList != null && orderBillNoList.Count != 0) + { + query = query.Where(w => orderBillNoList.Contains(w.order.OrderBillNo)); + } + } + + //物料ID在模糊后的物料 + if (!string.IsNullOrEmpty(dto.Material)) + { + query = query.Where(w => materialNumbs.Contains(w.order.MaterialNumber)); + } + + if (!string.IsNullOrEmpty(dto.Creator)) + query = query.Where(w => cr_ids.Contains(w.order.CreatorId)); + if (dto.CreateBeginDate != null) + query = query.Where(w => w.order.CreateTime.Date >= dto.CreateBeginDate.Value); + if (dto.CreateEndDate != null) + query = query.Where(w => w.order.CreateTime.Date <= dto.CreateEndDate.Value); + + int total = await query.CountAsync(); + var list = await query.Select(s => new BoxMarkQueryResponse() + { + Id = s.order.Id, + DetailId=s.detail.Id, + BillNo = s.detail.BillNo, + OrderBillNo = s.order.OrderBillNo, + MaterialName = _erpBasicDataExtendService.GetMaterialName(materials, s.order.MaterialNumber), + MaterialNumber = s.order.MaterialNumber, + Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, s.order.MaterialNumber), + BarCode = _erpBasicDataExtendService.GetMaterialBarCode(materials, s.order.MaterialNumber), + + CratingQty = s.order.CratingQty, + CratingNetWeightQty = s.order.CratingNetWeightQty, + CratingGrossWeightQty = s.order.CratingGrossWeightQty, + + TailboxQty = s.order.TailboxQty, + TailboxNetWeightQty = s.order.TailboxNetWeightQty, + TailboxGrossWeightQty = s.order.TailboxGrossWeightQty, + IsTail=s.detail.IsTail, + Sort = s.detail.Sort, + Creator = _singleDataService.GetSingleData(SingleAction.Users, loginInfo.UserInfo.CompanyId, s.order.CreatorId), + CreateTime = s.order.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"), + Remark = s.order.Remark, + ProductQty=s.order.ProductQty, + BeginNumber=s.detail.BeginNumber, + EndNumber=s.detail.EndNumber + + }).Skip((dto.PageNo - 1) * dto.PageSize).Take(dto.PageSize).ToListAsync(); + + return (list, total); + } + + /// + /// 新增 + /// + /// + /// + /// + public async Task Add(BoxMark entity, bool isTransaction = true) + { + IDbContextTransaction _transaction = null; + if (isTransaction) + _transaction = _context.Database.BeginTransaction(); + try + { + await _context.BoxMark.AddAsync(entity); + await _context.SaveChangesAsync(); + if (_transaction != null) + _transaction.Commit(); + return entity; + } + catch (Exception ex) + { + if (_transaction != null) + _transaction.Rollback(); + return null; + } + + } + + /// + /// 详情-根据最新的ID + /// + /// + /// + public async Task GetBy() + { + var entity = await _context.BoxMark.OrderByDescending(x => x.Id).FirstOrDefaultAsync(); + return entity; + } + + /// + /// 列表-详情信息列表 + /// + /// + /// + /// + public async Task> GetListInfoBy(int id, int companyId) + { + //1.获取物料集合和组织集合和供应商的集合 + var materials = new List(); + var materials_result = await _erpService.BillQueryForMaterial(); + if (materials_result.IsSuccess) + materials = materials_result.Data.ToList(); + + var query = _context.BoxMarkBillNo + .GroupJoin(_context.BoxMark, detail => detail.Fid, order => order.Id, (detail, orders) => new { detail, orders }) + .SelectMany(x => x.orders.DefaultIfEmpty(), (p, order) => new { p.detail, order }) + .OrderByDescending(x => x.order.Id).ThenByDescending(x => x.detail.FirstBillNo).ThenByDescending(x => x.detail.LastBillNo) + .Where(adv => adv.order.Id == id); + var list = await query.Select(s => new BoxMarkQueryResponse() + { + Id = s.order.Id, + DetailId = s.detail.Id, + BillNo = s.detail.BillNo, + OrderBillNo = s.order.OrderBillNo, + MaterialName = _erpBasicDataExtendService.GetMaterialName(materials, s.order.MaterialNumber), + MaterialNumber = s.order.MaterialNumber, + Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, s.order.MaterialNumber), + BarCode = _erpBasicDataExtendService.GetMaterialBarCode(materials, s.order.MaterialNumber), + + CratingQty = s.order.CratingQty, + CratingNetWeightQty = s.order.CratingNetWeightQty, + CratingGrossWeightQty = s.order.CratingGrossWeightQty, + + TailboxQty = s.order.TailboxQty, + TailboxNetWeightQty = s.order.TailboxNetWeightQty, + TailboxGrossWeightQty = s.order.TailboxGrossWeightQty, + IsTail = s.detail.IsTail, + Sort=s.detail.Sort, + Creator = _singleDataService.GetSingleData(SingleAction.Users, companyId, s.order.CreatorId), + CreateTime = s.order.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"), + Remark = s.order.Remark, + ProductQty = s.order.ProductQty, + BeginNumber = s.detail.BeginNumber, + EndNumber = s.detail.EndNumber + }).ToListAsync(); + + return list; + } + + /// + /// 详情-根据最新的ID + /// + /// + /// + public async Task GetLastBillNo() + { + var entity = await _context.BoxMarkBillNo.OrderByDescending(x => x.Id).FirstOrDefaultAsync(); + return entity; + } + + /// + /// 批量删除 + /// + /// + /// + public async Task DeleteRange(List ids, bool isTransaction = true) + { + IDbContextTransaction _transaction = null; + if (isTransaction) + _transaction = _context.Database.BeginTransaction(); + try + { + var list = await _context.BoxMark.Include(x=>x.BillNos).Where(f => ids.Contains(f.Id)).ToListAsync(); + _context.BoxMark.RemoveRange(list); + await _context.SaveChangesAsync(); + + if (_transaction != null) + _transaction.Commit(); + } + catch (Exception ex) + { + if (_transaction != null) + _transaction.Rollback(); + return false; + } + return true; + } + } +} diff --git a/src/BarCode.Web.Repositories/BoxRepositories.cs b/src/BarCode.Web.Repositories/BoxRepositories.cs new file mode 100644 index 0000000..b3025f4 --- /dev/null +++ b/src/BarCode.Web.Repositories/BoxRepositories.cs @@ -0,0 +1,381 @@ +using AutoMapper; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Storage; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using BarCode.Web.Core.Dto; +using BarCode.Web.Core.Help; +using BarCode.Web.Domain.Entitys; +using BarCode.Web.Domain.Infrastructure; +using BarCode.Web.Domain.IService.Public; +using BarCode.Web.Domain.Mappers; +using BarCode.Web.Repositories.Configuration; +using BarCode.Web.Core.Dto.Box; +using BarCode.Web.Core.Dto.Erp; +using BarCode.Web.Core.Dto.Erp.Supplier; +using BarCode.Web.Core.Dto.Erp.Org; +using BarCode.Web.Core.Dto.SerialNumbers; +using BarCode.Web.Domain.Values.Single; +using BarCode.Web.Core; +using BarCode.Web.Domain.Values; +using NPOI.OpenXmlFormats.Wordprocessing; +using System.Runtime.CompilerServices; +using System.ComponentModel.Design; +using BarCode.Web.Core.Dto.Login; +using BarCode.Web.Core.Dto.SingleData; +using BarCode.Web.Core.Internal.Results; + +namespace BarCode.Web.Repositories +{ + /// + /// 老ops箱信息 + /// + public class BoxRepositories : IBoxRepositories + { + private readonly IMapper _mapper; + private readonly IServiceProvider _serviceProvider; + private readonly RepositoryDbContext _context; + private readonly ISingleDataService _singleDataService; + private readonly ILoginRepositories _loginRepositories; + private readonly IBasicsRepositories _basicsRepositories; + private readonly IErpBasicDataExtendService _erpBasicDataExtendService; + private readonly IErpService _erpService; + public BoxRepositories(RepositoryDbContext context, IMapper mapper, IServiceProvider serviceProvider, + ISingleDataService singleDataService, ILoginRepositories loginRepositories, + IBasicsRepositories basicsRepositories, IErpBasicDataExtendService erpBasicDataExtendService, + IErpService erpServic) + { + _context = context; + _mapper = mapper; + _serviceProvider = serviceProvider; + _singleDataService = singleDataService; + _loginRepositories = loginRepositories; + _basicsRepositories = basicsRepositories; + _erpBasicDataExtendService = erpBasicDataExtendService; + _erpService = erpServic; + } + public async Task Get(int id) + { + return await _context.Box.AsNoTracking() + .Include(x => x.Details) + .FirstOrDefaultAsync(f => f.Id.Equals(id)); + } + + /// + /// 批量修改 + /// + /// + /// + /// + public async Task EditEntityList(List entitys, bool isTransaction = true) + { + IDbContextTransaction _transaction = null; + if (isTransaction) + _transaction = _context.Database.BeginTransaction(); + try + { + List list = entitys.Select(s => s.Id).ToList(); + + var res = await _context.Box + .Include(s => s.Details) + .Where(f => list.Contains(f.Id)).ToListAsync(); + + _mapper.ToMapList(entitys, res); + //_mapper.ToMapList(entitys.SelectMany(s => s.Details).ToList(), res.SelectMany(s => s.Details).ToList()); + + await _context.SaveChangesAsync(); + if (_transaction != null) + _transaction.Commit(); + } + catch (Exception ex) + { + if (_transaction != null) + _transaction.Rollback(); + return false; + } + return true; + + } + + public async Task GetByNo(string billNo) + { + return await _context.Box.AsNoTracking() + .Include(x => x.Details) + .FirstOrDefaultAsync(f => f.BoxBillNo.Equals(billNo)); + } + public async Task> GetEntityListByNos(List billNos) + { + return await _context.Box.AsNoTracking() + .Include(x => x.Details) + .Where(f => billNos.Contains(f.BoxBillNo)).ToListAsync(); + } + //根据箱号搜索 用来比对确定是否箱号信息是否存在 + public async Task> GetByNos(List billNos) + { + return await _context.Box.AsNoTracking() + .Where(w => billNos.Contains(w.BoxBillNo)).Select(s => s.BoxBillNo).ToListAsync(); + } + + public async Task AddRange(List entitys, bool isTransaction = true) + { + IDbContextTransaction _transaction = null; + if (isTransaction) + _transaction = _context.Database.BeginTransaction(); + try + { + if (entitys != null && entitys.Count != 0) + { + await _context.Box.AddRangeAsync(entitys); + await _context.SaveChangesAsync(); + + foreach (var e in entitys) + { + e.GenerateNo(); + } + await _context.SaveChangesAsync(); + } + if (_transaction != null) + _transaction.Commit(); + return true; + } + catch + { + if (_transaction != null) + _transaction.Rollback(); + return false; + } + } + /// + /// 获取箱集合 + /// + /// + /// + public async Task> GetEntityList(List ids) + { + return await _context.Box.AsNoTracking() + .Include(s => s.Details) + .Where(f => ids.Contains(f.Id)) + .ToListAsync(); + } + /// + /// 列表 + /// + /// + /// + /// + /// + public async Task<(List list, int total)> GetListAsync(BoxQueryRequest dto, LoginInDto loginInfo) + { + int companyId = loginInfo.UserInfo.CompanyId; + List mNumber = new List(); + var materials_result = await _erpService.BillQueryForMaterial(); + List materials = new List(); + if (materials_result.IsSuccess) + materials = materials_result.Data.ToList(); + //物料集合;模糊查询后的物料集合 + if (!string.IsNullOrEmpty(dto.MaterialNumber)) + { + if (materials != null) + mNumber = materials.Where(w => w.MaterialNumber.Contains(dto.MaterialNumber) + || w.MaterialName.Contains(dto.MaterialNumber) + || w.Specifications.Contains(dto.MaterialNumber) + ).Select(s => s.MaterialNumber).ToList(); + } + + ////供应商 + //var supplier_result = await _erpService.BillQueryForSupplier(); + //List suppliers = new List(); + //if (supplier_result.IsSuccess) + // suppliers = supplier_result.Data.ToList(); + ////取组织 + //var org_result = await _erpService.BillQueryForOrg(); + //List orgs = new List(); + //if (org_result.IsSuccess) + // orgs = org_result.Data.ToList(); + var result = await _singleDataService.GetSingleData, SingleDataRequest, SysConfigAction>( + new SingleDataRequest(loginInfo.UserInfo.CompanyId), SysConfigAction.GetOrgByCompany, SingleControllerType.SysConfig); + List orgs = new List(); + if (result.IsSuccess) + orgs = result.Data.ToList(); + + List cr_ids = new List(); + if (!string.IsNullOrEmpty(dto.CreateUser)) + { + cr_ids = await _basicsRepositories.GetUserIdsAsync(dto.CreateUser, loginInfo.UserInfo.CompanyId); + } + List s_ids = new List(); + if (dto.SerialNumbers != null && dto.SerialNumbers.Count() > 0) + { + var details = await GetDetailIdBySerialNumbers(dto.SerialNumbers); + s_ids = details.Select(s => s.Id).ToList(); + } + var query = _context.Box + .GroupJoin(_context.BoxDetails, box => box.Id, detail => detail.Fid, (box, detail) => new { box, detail }) + .SelectMany(x => x.detail.DefaultIfEmpty(), (p, detail) => new { p.box, detail }) + .OrderByDescending(o => o.box.Id) + .Where(f => 1 == 1); + + if (loginInfo.UserInfo.IsAdmin != true && !string.IsNullOrEmpty(dto.OrgCode)) + { + var rec_type = dto.OrgCode.Substring(0, 1); + var rec_code = dto.OrgCode.Substring(2, dto.OrgCode.Length - 2); + + if (rec_type.Equals("s"))//供应商 + query = query.Where(w => rec_code == w.box.SupplierCode); + else//查其他单据(组织) + query = query.Where(w => rec_code == w.box.OrgCode); + } + + if (!string.IsNullOrEmpty(dto.SupplierOrOrg)) + { + var rec_type = dto.SupplierOrOrg.Substring(0, 1); + var rec_code = dto.SupplierOrOrg.Substring(2, dto.SupplierOrOrg.Length - 2); + + if (rec_type.Equals("s"))//供应商 + query = query.Where(w => rec_code == w.box.SupplierCode); + else//查其他单据(组织) + query = query.Where(w => rec_code == w.box.OrgCode); + } + if (!string.IsNullOrEmpty(dto.MaterialNumber)) + query = query.Where(w => mNumber.Contains(w.detail.MaterialNumber)); + if (!string.IsNullOrEmpty(dto.BoxBeginNo)) + { + //V01.05.00: 只输入一个框则只查输入值,不做区间查询 + var id = Convert.ToInt32(dto.BoxBeginNo.ToUpper().Replace("CTN", "")); + if (!string.IsNullOrEmpty(dto.BoxEndNo)) + query = query.Where(w => w.box.Id >= id); + else + query = query.Where(w => w.box.Id == id); + } + if (!string.IsNullOrEmpty(dto.BoxEndNo)) + { + //V01.05.00: 只输入一个框则只查输入值,不做区间查询 + var id = Convert.ToInt32(dto.BoxEndNo.ToUpper().Replace("CTN", "")); + if (!string.IsNullOrEmpty(dto.BoxBeginNo)) + query = query.Where(w => w.box.Id <= id); + else + query = query.Where(w => w.box.Id == id); + } + if (dto.Status != null) + query = query.Where(w => w.box.Status == (BoxStatus)dto.Status); + if (dto.CreateBeginDate != null) + query = query.Where(w => w.box.CreateTime >= dto.CreateBeginDate); + if (dto.CreateEndDate != null) + { + DateTime dt_end = ((DateTime)dto.CreateEndDate).AddDays(1); + query = query.Where(w => w.box.CreateTime <= dt_end); + } + if (dto.CartonBeginDate != null) + query = query.Where(w => w.box.CartonEndTime >= dto.CartonBeginDate); + if (dto.CartonEndDate != null) + { + DateTime dt_end = ((DateTime)dto.CartonEndDate).AddDays(1); + query = query.Where(w => w.box.CartonEndTime <= dt_end); + } + + if (dto.SerialNumbers != null && dto.SerialNumbers.Count() > 0) + query = query.Where(w => s_ids.Contains(w.detail.Id)); + if (dto.BoxPrintStatus != null) + query = query.Where(w => dto.BoxPrintStatus == true ? w.box.PrintNumber > 0 : w.box.PrintNumber <= 0); + if (!string.IsNullOrEmpty(dto.CreateUser)) + query = query.Where(w => cr_ids.Contains(w.box.CreatorId)); + + int total = await query.CountAsync(); + var list = await query.Select(s => new BoxInfoResponse() + { + Id = s.box.Id, + DetailId = s.detail == null ? 0 : s.detail.Id, + BoxBillNo = s.box.BoxBillNo, + Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, s.detail == null ? "" : s.detail.MaterialNumber), + MaterialNumber = s.detail == null ? "" : s.detail.MaterialNumber, + MaterialName = _erpBasicDataExtendService.GetMaterialName(materials, s.detail == null ? "" : s.detail.MaterialNumber), + BarCode = _erpBasicDataExtendService.GetMaterialBarCode(materials, s.detail == null ? "" : s.detail.MaterialNumber), + SerialNumbers = s.detail == null ? "" : string.Join(",", s.detail.SerialNumbers), + Qty = s.detail == null ? 0 : s.detail.Qty, + Status = s.box.Status.GetRemark(), + CartonBeginTime = s.box.CartonBeginTime.DateToStringSeconds(), + CartonEndTime = s.box.CartonEndTime.DateToStringSeconds(), + CartonUser = _singleDataService.GetSingleData(SingleAction.Users, companyId, s.box.CartonUserId), + Creator = _singleDataService.GetSingleData(SingleAction.Users, companyId, s.box.CreatorId), + CreateTime = s.box.CreateTime.DateToStringSeconds(), + PrintNumber = s.box.PrintNumber, + SupplierOrOrg = string.IsNullOrEmpty(s.box.SupplierCode) ? _erpBasicDataExtendService.GetSingleOrgName(orgs, s.box.OrgCode) + : _singleDataService.GetSingleData(SingleAction.Suppliers, companyId, s.box.SupplierCode)//供应商取单点的 + }).Skip((dto.PageNo - 1) * dto.PageSize).Take(dto.PageSize).ToListAsync(); + return (list, total); + } + + /// + /// 根据序列号获取明细 + /// + /// + /// + private Task> GetDetailIdBySerialNumbers(List serialNumbers) + { + if (serialNumbers.Count() == 0) Task.FromResult(new List()); + string str = $"select * from t_barcode_box_details where "; + for (int i = 0; i < serialNumbers.Count(); i++) + { + if (i == 0) + str += $"SerialNumbers like '%\"{serialNumbers[i]}\"%'"; + else + str += $" or SerialNumbers like '%\"{serialNumbers[i]}\"%'"; + } + var fs = FormattableStringFactory.Create(str); + var list = _context.Set().FromSqlInterpolated(fs).ToList(); + return Task.FromResult(list); + } + /// + /// 编辑 + /// + /// + /// + /// + public async Task Edit(Box entity, bool isTransaction = true) + { + IDbContextTransaction _transaction = null; + if (isTransaction) + _transaction = _context.Database.BeginTransaction(); + + var res = await _context.Box + .Include(s => s.Details) + .FirstOrDefaultAsync(f => f.Id == entity.Id); + if (res == null) return null; + + _mapper.Map(entity, res); + await _context.SaveChangesAsync(); + + if (_transaction != null) + _transaction.Commit(); + + return res; + + } + /// + /// 获取装箱完成的箱信息 + /// + /// + /// + /// + public async Task<(List, int tota)> GetEntityByWmsList(WmsBoxRequest dto) + { + var query = _context.Box.Include(x => x.Details) + .Where(w => w.Status == BoxStatus.Complete); + + if (!string.IsNullOrEmpty(dto.BoxBillNo)) + query = query.Where(w => w.BoxBillNo.Equals(dto.BoxBillNo)); + if (dto.StrartTime != null) + query = query.Where(w => w.CartonEndTime >= dto.StrartTime); + if (dto.EndTime != null) + query = query.Where(w => w.CartonEndTime <= dto.EndTime); + + + int total = await query.CountAsync(); + var list = await query.Skip((dto.Page - 1) * dto.Limit).Take(dto.Limit).ToListAsync(); + return (list, total); + } + } +} diff --git a/src/BarCode.Web.Repositories/CenerateDataRepositories.cs b/src/BarCode.Web.Repositories/CenerateDataRepositories.cs new file mode 100644 index 0000000..f4829e4 --- /dev/null +++ b/src/BarCode.Web.Repositories/CenerateDataRepositories.cs @@ -0,0 +1,87 @@ +using AutoMapper; +using BarCode.Web.Domain.Entitys; +using BarCode.Web.Domain.Infrastructure; +using BarCode.Web.Domain.Values; +using BarCode.Web.Repositories.Configuration; +using Microsoft.EntityFrameworkCore.Storage; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Repositories +{ + /// + /// + /// + public class CenerateDataRepositories : ICenerateDataRepositories + { + private readonly IMapper _mapper; + private readonly IServiceProvider _serviceProvider; + private readonly RepositoryDbContext _context; + + public CenerateDataRepositories(RepositoryDbContext context, IMapper mapper, IServiceProvider serviceProvider) + { + _context = context; + _mapper = mapper; + _serviceProvider = serviceProvider; + } + /// + /// 添加 + /// + /// + /// + /// + public async Task Add(CenerateData entity, bool isTransaction = true) + { + IDbContextTransaction _transaction = null; + if (isTransaction) + _transaction = _context.Database.BeginTransaction(); + + await _context.CenerateData.AddAsync(entity); + await _context.SaveChangesAsync(); + + if (_transaction != null) + _transaction.Commit(); + return entity; + } + /// + /// 修改 + /// + /// + /// + /// + public async Task Edit(CenerateData entity, bool isTransaction = true) + { + IDbContextTransaction _transaction = null; + if (isTransaction) + _transaction = _context.Database.BeginTransaction(); + + var res = await _context.CenerateData + .FirstOrDefaultAsync(f => f.Id == entity.Id); + if (res == null) return null; + + _mapper.Map(entity, res); + await _context.SaveChangesAsync(); + + if (_transaction != null) + _transaction.Commit(); + + return res; + } + + public async Task Get(CenerateDataType type) + { + var entity = await _context.CenerateData + .FirstOrDefaultAsync(f => f.Type == type); + if (entity == null) + { + entity = await this.Add(new CenerateData(type)); + return entity; + } + return entity; + } + } +} diff --git a/src/BarCode.Web.Repositories/Configuration/DbContextExtensions.cs b/src/BarCode.Web.Repositories/Configuration/DbContextExtensions.cs new file mode 100644 index 0000000..bd32531 --- /dev/null +++ b/src/BarCode.Web.Repositories/Configuration/DbContextExtensions.cs @@ -0,0 +1,225 @@ +using Microsoft.Data.SqlClient; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using System; +using System.Collections.Generic; +using System.Data; +using System.Data.Common; +using System.Linq; +using System.Linq.Expressions; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Repositories.Configuration +{ + /// + /// db上下文扩展类 + /// + public static class DbContextExtensions + { + public static IEnumerable SqlQuery(this DatabaseFacade facade, string sql, bool isAlias = false, params object[] parameters) where T : class, new() + { + var dt = SqlQuery(facade, sql, parameters); + if (isAlias) + return dt.ToEnumerableAlias(); + return dt.ToEnumerable(); + } + + public static async Task> SqlQueryAsync(this DatabaseFacade facade, string sql, bool isAlias = false, params object[] parameters) where T : class, new() + { + return await Task.Run(() => + { + var dt = SqlQuery(facade, sql, parameters); + if (isAlias) + return dt.ToEnumerableAlias(); + return dt.ToEnumerable(); + }); + } + + public static IEnumerable ToEnumerable(this DataTable dt) where T : class, new() + { + var propertyInfos = typeof(T).GetProperties(); + var ts = new T[dt.Rows.Count]; + var i = 0; + foreach (DataRow row in dt.Rows) + { + + try + { + var t = new T(); + foreach (var p in propertyInfos) + if (dt.Columns.IndexOf(p.Name) != -1 && row[p.Name] != DBNull.Value) + p.SetValue(t, row[p.Name], null); + + ts[i] = t; + i++; + } + catch (Exception ex) + { + + throw ex; + } + + + } + + return ts; + } + + /// + /// 对象属性别名的映射关系 + /// + /// + /// + /// + public static IEnumerable ToEnumerableAlias(this DataTable dt) where T : class, new() + { + var propertyInfos = typeof(T).GetProperties(); + var ts = new T[dt.Rows.Count]; + var i = 0; + foreach (DataRow row in dt.Rows) + { + var t = new T(); + foreach (var p in propertyInfos) + { + var attrs = p.GetCustomAttributes(typeof(System.ComponentModel.DataAnnotations.Schema.ColumnAttribute), true); + if (attrs.Length > 0) + { + try + { + var name = ((System.ComponentModel.DataAnnotations.Schema.ColumnAttribute)attrs[0]).Name; + if (dt.Columns.IndexOf(name) != -1 && row[name] != DBNull.Value) + p.SetValue(t, row[name], null); + } + catch (Exception ex) + { + throw ex; + } + + + } + + } + + ts[i] = t; + i++; + } + + return ts; + } + + public static DataTable SqlQuery(this DatabaseFacade facade, string sql, params object[] parameters) + { + var cmd = CreateCommand(facade, sql, out var conn, parameters); + var reader = cmd.ExecuteReader(); + var dt = new DataTable(); + dt.Load(reader); + reader.Close(); + conn.Close(); + return dt; + } + + private static DbCommand CreateCommand(DatabaseFacade facade, string sql, out DbConnection dbConn, params object[] parameters) + { + var conn = facade.GetDbConnection(); + dbConn = conn; + conn.Open(); + var cmd = conn.CreateCommand(); + if (facade.IsMySql()) + { + cmd.CommandText = sql; + CombineParamsMySql(ref cmd, parameters); + } + if (facade.IsSqlServer()) + { + cmd.CommandText = sql; + CombineParams(ref cmd, parameters); + } + + return cmd; + } + + private static void CombineParams(ref DbCommand command, params object[] parameters) + { + if (parameters != null) + foreach (SqlParameter parameter in parameters) + { + if (!parameter.ParameterName.Contains("@")) + parameter.ParameterName = $"@{parameter.ParameterName}"; + command.Parameters.Add(parameter); + } + } + + private static void CombineParamsMySql(ref DbCommand command, params object[] parameters) + { + if (parameters != null) + foreach (MySqlConnector.MySqlParameter parameter in parameters) + { + if (!parameter.ParameterName.Contains("@")) + parameter.ParameterName = $"@{parameter.ParameterName}"; + command.Parameters.Add(parameter); + } + } + + public static bool ExecuteSqlCommand(this DatabaseFacade facade, string sql, params object[] parameters) + { + var cmd = CreateCommand(facade, sql, out var conn, parameters); + try + { + cmd.ExecuteNonQuery(); + return true; + } + catch (Exception ex) + { + var msg = ex.Message; + return false; + } + finally + { + conn.Close(); + } + } + + + public static IQueryable SortBy(this IQueryable source, string sortExpression) + { + if (source == null) + { + throw new ArgumentNullException("source"); + } + + string sortDirection = String.Empty; + string propertyName = String.Empty; + + sortExpression = sortExpression.Trim(); + int spaceIndex = sortExpression.Trim().IndexOf(" "); + if (spaceIndex < 0) + { + propertyName = sortExpression; + sortDirection = "ASC"; + } + else + { + propertyName = sortExpression.Substring(0, spaceIndex); + sortDirection = sortExpression.Substring(spaceIndex + 1).Trim(); + } + + if (String.IsNullOrEmpty(propertyName)) + { + return source; + } + + ParameterExpression parameter = Expression.Parameter(source.ElementType, String.Empty); + MemberExpression property = Expression.Property(parameter, propertyName); + LambdaExpression lambda = Expression.Lambda(property, parameter); + + string methodName = (sortDirection == "ASC") ? "OrderBy" : "OrderByDescending"; + + Expression methodCallExpression = Expression.Call(typeof(Queryable), methodName, + new Type[] { source.ElementType, property.Type }, + source.Expression, Expression.Quote(lambda)); + + return source.Provider.CreateQuery(methodCallExpression); + } + } +} diff --git a/src/BarCode.Web.Repositories/Configuration/EFLog/EFCoreLogger.cs b/src/BarCode.Web.Repositories/Configuration/EFLog/EFCoreLogger.cs new file mode 100644 index 0000000..033306a --- /dev/null +++ b/src/BarCode.Web.Repositories/Configuration/EFLog/EFCoreLogger.cs @@ -0,0 +1,39 @@ +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; + +namespace BarCode.Web.Repositories.Configuration.EFLog +{ + public class EFCoreLogger : ILogger + { + private readonly string categoryName; + + public EFCoreLogger(string categoryName) => this.categoryName = categoryName; + + public bool IsEnabled(LogLevel logLevel) => true; + + public void Log(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func formatter) + { + if (categoryName == "Microsoft.EntityFrameworkCore.Database.Command" && logLevel == LogLevel.Information) + { + var logContent = formatter(state, exception); + var str = logContent.ToLower(); + if ((str.Contains("update") || str.Contains("delete") || str.Contains("insert")) && + (str.Contains("t_sub_ppbom") || str.Contains("t_sub_ppbomentry") || str.Contains("t_sub_ppbomentry_l") + || str.Contains("t_prd_ppbom") || str.Contains("t_prd_ppbomentry") || str.Contains("t_prd_ppbomentry_l") + || str.Contains("t_eng_bom") || str.Contains("t_eng_bomchild"))) + { + if (!Directory.Exists("D:/Logs")) + Directory.CreateDirectory("D:/Logs"); + + logContent = "\r\n\r\n" + DateTime.Now + "--" + logContent; + //没有文件会自动创建,有就追加 + System.IO.File.AppendAllText("D:/Logs/增删改记录.txt", logContent); + } + } + } + public IDisposable BeginScope(TState state) => null; + } +} diff --git a/src/BarCode.Web.Repositories/Configuration/EFLog/EFCoreLoggerProvider.cs b/src/BarCode.Web.Repositories/Configuration/EFLog/EFCoreLoggerProvider.cs new file mode 100644 index 0000000..201cdb1 --- /dev/null +++ b/src/BarCode.Web.Repositories/Configuration/EFLog/EFCoreLoggerProvider.cs @@ -0,0 +1,13 @@ +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarCode.Web.Repositories.Configuration.EFLog +{ + public class EFCoreLoggerProvider : ILoggerProvider + { + public ILogger CreateLogger(string categoryName) => new EFCoreLogger(categoryName); + public void Dispose() { } + } +} diff --git a/src/BarCode.Web.Repositories/Configuration/RepositoryDbContext.cs b/src/BarCode.Web.Repositories/Configuration/RepositoryDbContext.cs new file mode 100644 index 0000000..3ff5fdc --- /dev/null +++ b/src/BarCode.Web.Repositories/Configuration/RepositoryDbContext.cs @@ -0,0 +1,135 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.ChangeTracking; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Debug; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json; +using BarCode.Web.Domain.Entitys; +using BarCode.Web.Repositories.Configuration.EFLog; + +namespace BarCode.Web.Repositories.Configuration +{ + /// + /// db上下文 + /// + public class RepositoryDbContext : DbContext + { + [Obsolete] + public readonly LoggerFactory LoggerFactory = new LoggerFactory(new[] { new DebugLoggerProvider() }); + public RepositoryDbContext(DbContextOptions options) : base(options) + { + } + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + LoggerFactory.AddProvider(new EFCoreLoggerProvider()); + base.OnConfiguring(optionsBuilder); + optionsBuilder.UseLoggerFactory(LoggerFactory).EnableSensitiveDataLogging(); + } + + protected override void OnModelCreating(ModelBuilder builder) + { + builder.Entity(ent => + { + ent.ToTable("t_barcode_file_down_manager"); + ent.HasKey(x => x.Id); + }); + + + //箱唛表 + builder.Entity(ent => + { + ent.ToTable("t_barcode_box_mark"); + ent.HasKey(x => x.Id); + + ent.HasMany(p => p.BillNos) + .WithOne() + .HasForeignKey(p => p.Fid) + .OnDelete(DeleteBehavior.Cascade); + }); + + //箱唛表-编号表 + builder.Entity(ent => + { + ent.ToTable("t_barcode_box_mark_billno"); + ent.HasKey(x => x.Id); + }); + //物料 + builder.Entity(ent => + { + ent.ToTable("t_barcode_materials"); + ent.HasKey(x => x.Id); + }); + + //序列号生成记录 + builder.Entity(ent => + { + ent.ToTable("t_barcode_serialnumbergeneraterecord"); + ent.HasKey(x => x.Id); + }); + + //序列号 + builder.Entity(ent => + { + ent.ToTable("t_barcode_serialnumbers"); + ent.HasKey(x => x.Id); + }); + + //防伪码生成记录 + builder.Entity(ent => + { + ent.ToTable("t_barcode_securitynumbergeneraterecord"); + ent.HasKey(x => x.Id); + }); + + //防伪码 + builder.Entity(ent => + { + ent.ToTable("t_barcode_securitynumbers"); + ent.HasKey(x => x.Id); + }); + + #region 箱信息 + builder.Entity(ent => + { + ent.ToTable("t_barcode_box"); + ent.HasKey(x => x.Id); + + ent.HasMany(p => p.Details) + .WithOne() + .HasForeignKey(p => p.Fid) + .OnDelete(DeleteBehavior.Cascade); + }); + builder.Entity(ent => + { + ent.ToTable("t_barcode_box_details"); + ent.HasKey(x => x.Id); + }); + #endregion + + //生成数据管理 + builder.Entity(ent => + { + ent.ToTable("t_wms_cenerate_date"); + ent.HasKey(x => x.Id); + }); + + base.OnModelCreating(builder); + } + public DbSet Materials { get; set; } + public DbSet BoxMarkBillNo { get; set; } + public DbSet BoxMark { get; set; } + public DbSet FileDownManager { get; set; } + public DbSet SerialNumberGenerateRecord { get; set; } + public DbSet SerialNumbers { get; set; } + public DbSet Box { get; set; } + public DbSet BoxDetails { get; set; } + public DbSet SecurityNumberGenerateRecord { get; set; } + public DbSet SecurityNumbers { get; set; } + public DbSet CenerateData { get; set; } + } +} diff --git a/src/BarCode.Web.Repositories/DependencyInjection/AppBuilder.cs b/src/BarCode.Web.Repositories/DependencyInjection/AppBuilder.cs new file mode 100644 index 0000000..d0f7ba7 --- /dev/null +++ b/src/BarCode.Web.Repositories/DependencyInjection/AppBuilder.cs @@ -0,0 +1,300 @@ +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.OpenApi.Models; +using Newtonsoft.Json.Serialization; +using Quartz; +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using BarCode.Web.Core.Help; +using BarCode.Web.Domain.IService; +using BarCode.Web.Domain.IService.Public; +using BarCode.Web.Domain.Mappers; +using BarCode.Web.Domain.Options; +using BarCode.Web.Domain.QuartzJob; +using BarCode.Web.Domain.Services; +using BarCode.Web.Domain.Services.Public; +using Quartz.AspNetCore; + +namespace BarCode.Web.Repositories.DependencyInjection +{ + /// + /// App服务 + /// + public class AppBuilder + { + /// + /// 服务集合 + /// + public IServiceCollection Services { get; } + + public IConfiguration Configuration { get; } + + public bool _IsDevelopment { get; } + + /// + /// asf 服务 + /// + /// + public AppBuilder(IServiceCollection services, IConfiguration configuration, bool IsDevelopment) + { + Services = services; + Configuration = configuration; + _IsDevelopment = IsDevelopment; + } + + /// + /// 编译服务 + /// + public void Build() + { + this.AddCors(); + this.InitRedis(); + this.AddSwagger(); + this.AddOther(); + this.AddConfigOptions(); + this.AddServiceRepositories(); + this.AddQuartzService(); + } + /// + /// 其它功能注入:AutoMapper等其它 + /// + private void AddOther() + { + Services.AddMvc().AddNewtonsoftJson(opt => + { + //// 忽略循环引用 + //opt.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; + opt.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); + //// 不使用驼峰 + //opt.SerializerSettings.ContractResolver = new DefaultContractResolver(); + }); + + //AutoMapper映射关系 + Services.AddAutoMapper(typeof(AppMapper).Assembly); + } + + /// + /// 跨域注入 + /// + private void AddCors() + { + // 全局跨域注入 + Services.AddCors(opt => + { + string[] urls = Configuration.GetSection("AllowedCores").Value.Split(','); + opt.AddPolicy("AllowAllOrigin", builder => + { + + builder.AllowAnyMethod() + .AllowAnyHeader() + .AllowCredentials() + .WithOrigins(urls); + + }); + }); + } + + /// + /// 初始化redis + /// + private void InitRedis() + { + var option = Configuration.GetSection("AppOptions").Get(); + var option_soa = Configuration.GetSection("SoaOptions").Get(); + //初始化redis + RedisClient.redisClient.InitConnect(option.RedisConnectionString); + Services.AddHttpClient("ops_client", c => + { + c.BaseAddress = new Uri(option_soa.Url); + }); + } + + /// + /// 注册swagger + /// + private void AddSwagger() + { + if (_IsDevelopment) + { + // 注册Swagger服务 + Services.AddSwaggerGen(c => + { + // 添加文档信息 + c.SwaggerDoc("v1", new Microsoft.OpenApi.Models.OpenApiInfo + { + Title = "BarCode", + Version = "v1", + Description = "BarCode-Api" + }); + #region 读取xml信息 + // 使用反射获取xml文件。并构造出文件的路径 + //// 启用xml注释. 该方法第二个参数启用控制器的注释,默认为false. + foreach (var file in Directory.GetFiles(AppContext.BaseDirectory, "BarCode.*.xml")) c.IncludeXmlComments(file, true); + #endregion + + #region 启用swagger验证功能 + //添加一个必须的全局安全信息,和AddSecurityDefinition方法指定的方案名称一致即可,CoreAPI。 + var securit = new OpenApiSecurityRequirement() + { + { + new OpenApiSecurityScheme + { + Reference=new OpenApiReference { Type=ReferenceType.SecurityScheme,Id= "WMSAPI" } + }, + new string[] { } + } + }; + c.AddSecurityRequirement(securit); + c.AddSecurityDefinition("WMSAPI", new OpenApiSecurityScheme + { + Description = "JWT授权(数据将在请求头中进行传输) 在下方输入Bearer {token} 即可", + Name = "Authorization",//jwt默认的参数名称 + In = ParameterLocation.Header,//jwt默认存放Authorization信息的位置(请求头中) + Type = SecuritySchemeType.ApiKey + }); + #endregion + + }); + } + } + + /// + /// 系统配置 + /// + private void AddConfigOptions() + { + //系统配置注册 + Services.AddOptions(); + Services.Configure(Configuration.GetSection("AppOptions")); + Services.AddOptions(); + Services.Configure(Configuration.GetSection("SoaOptions")); + Services.AddOptions(); + Services.Configure(Configuration.GetSection("ErpOptions")); + Services.AddOptions(); + Services.Configure(Configuration.GetSection("WmsOptions")); + Services.AddOptions(); + Services.Configure(Configuration.GetSection("Qiniu")); + //Services.AddOptions(); + //Services.Configure(Configuration.GetSection("EmailOptions")); + //Services.AddOptions(); + //Services.Configure(Configuration.GetSection("SmsOptions")); + + + + } + + /// + /// Quartz定时任务-可分布式集群 + /// + private void AddQuartzService() + { + var options = Configuration.GetSection("QuartzJobOptions").Get(); + + Services.AddTransient();//添加注入定时服务 + Services.AddTransient();//添加注入定时服务 + Services.AddTransient();//添加注入定时服务 + Services.AddQuartz(q => + { + q.UsePersistentStore(x => + { + //存储类型 + x.Properties[options.JobStoreTypeKey] = options.JobStoreTypeValue; + //数据库驱动类型-这里是mysql + x.Properties[options.JobStoreDriverDelegateTypeKey] = options.JobStoreDriverDelegateTypeValue; + //表名前缀 + x.Properties[options.JobStoreTablePrefixKey] = options.JobStoreTablePrefixValue; + //数据源名称 + x.Properties[options.JobStoreDataSourceKey] = options.JobStoreDataSourceValue; + //连接字符串 + x.Properties[options.JobStoreConnectionStringKey] = options.JobStoreConnectionStringValue; + //sqlserver版本 + x.Properties[options.JobStoreProviderKey] = options.JobStoreProviderValue; + //是否启用集群:是 + x.Properties[options.JobStoreClusteredKey] = options.JobStoreClusteredValue; + //集群节点都必须有一个唯一ID + x.Properties[options.JobStoreInstanceIdKey] = options.JobStoreInstanceIdValue; + x.UseProperties = true; + x.UseClustering(); + x.UseJsonSerializer(); + }); + //用于注入 + q.UseMicrosoftDependencyInjectionJobFactory(); + + #region 同步新物料id32进制信息 + var jobKey_materialbar = new JobKey("MaterialsBarQuartzJob", options.QuartzJobValue); + q.AddJob(jobKey_materialbar, j => j.WithDescription("MaterialsBarQuartzJob")); + q.AddTrigger(t => t + .WithIdentity("MaterialsBarQuartzJobTrigger") + .ForJob(jobKey_materialbar) + .StartNow() + .WithCronSchedule(options.JobStartExpre) + //.WithCronSchedule(CronScheduleBuilder.DailyAtHourAndMinute(options.JobStartHour[5], options.JobStartMinute[5])) + .WithDescription("MaterialsBarQuartzJobTriggerDecs")); + #endregion + + #region 同步新物料信息 + var jobKey_material = new JobKey("MaterialsQuartzJob", options.QuartzJobValue); + q.AddJob(jobKey_material, j => j.WithDescription("MaterialsQuartzJob")); + q.AddTrigger(t => t + .WithIdentity("MaterialsQuartzJobTrigger") + .ForJob(jobKey_material) + .StartNow() + .WithCronSchedule(options.JobStartExpreMaterial) + //.WithCronSchedule(CronScheduleBuilder.DailyAtHourAndMinute(options.JobStartHour[5], options.JobStartMinute[5])) + .WithDescription("MaterialsQuartzJobTriggerDecs")); + #endregion + + #region 维护自动生成数据管理 + var jobKey_cenerate = new JobKey("CenerateQuartzJob", options.QuartzJobValue); + q.AddJob(jobKey_cenerate, j => j.WithDescription("CenerateQuartzJob")); + q.AddTrigger(t => t + .WithIdentity("CenerateQuartzJobTrigger") + .ForJob(jobKey_cenerate) + .StartNow() + .WithCronSchedule(options.JobStartExpreCenerateData) + .WithDescription("CenerateQuartzJobTriggerDecs")); + #endregion + }); + //.net core核心托管-添加Quartz服务器 + Services.AddQuartzServer(options => + { + //关闭时,我们希望作业正常完成 + options.WaitForJobsToComplete = false; + }); + + } + + /// + /// 注入服务层 + /// + /// + private void AddServiceRepositories() + { + Services.AddSingleton(); + Services.AddTransient(); + Services.AddHostedService(); + //注入服务 + Services.AddTransient(); + Services.AddTransient(); + Services.AddTransient(); + Services.AddTransient(); + Services.AddTransient(); + + Services.AddTransient(); + Services.AddTransient(); + Services.AddTransient(); + Services.AddTransient(); + Services.AddTransient(); + Services.AddTransient(); + + Services.AddTransient(); + Services.AddTransient(); + Services.AddTransient(); + + } + } +} diff --git a/src/BarCode.Web.Repositories/DependencyInjection/AppBuilderExtensions.cs b/src/BarCode.Web.Repositories/DependencyInjection/AppBuilderExtensions.cs new file mode 100644 index 0000000..6de44a4 --- /dev/null +++ b/src/BarCode.Web.Repositories/DependencyInjection/AppBuilderExtensions.cs @@ -0,0 +1,63 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Text; +using BarCode.Web.Core.Dto; +using BarCode.Web.Domain.Infrastructure; +using BarCode.Web.Repositories; +using BarCode.Web.Repositories.Configuration; +using BarCode.Web.Repositories.DependencyInjection; +using BarCode.Web.Core.Dto.SerialNumbers; +using BarCode.Web.Core.Dto.SecurityNumbers; + +namespace Microsoft.Extensions.DependencyInjection +{ + public static class AppBuilderExtensions + { + /// + /// 配置数据库 + /// + /// + /// + /// + public static AppBuilder AddDbContext(this AppBuilder builder, Action configureDbContext) + { + builder.Services.AddDbContext(configureDbContext); + builder.Services.AddRepositories(); + return builder; + } + + /// + /// 注入仓储层 + /// + /// + private static void AddRepositories(this IServiceCollection services) + { + services.AddHttpContextAccessor(); + services.AddScoped(); + services.AddTransient(); + services.AddTransient(); + + #region 导出 + services.AddTransient, SerialNumbersRepositories>(); + services.AddTransient, SerialNumbersRepositories>(); + services.AddTransient, SecurityNumbersRepositories>(); + services.AddTransient, SecurityNumbersRepositories>(); + #endregion + + + + services.AddTransient(); + + + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + } + } +} diff --git a/src/BarCode.Web.Repositories/DependencyInjection/AuthorizationTokenSecurityPolicy.cs b/src/BarCode.Web.Repositories/DependencyInjection/AuthorizationTokenSecurityPolicy.cs new file mode 100644 index 0000000..3c462e2 --- /dev/null +++ b/src/BarCode.Web.Repositories/DependencyInjection/AuthorizationTokenSecurityPolicy.cs @@ -0,0 +1,198 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Caching.Memory; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using BarCode.Web.Core.Dto.Login; +using BarCode.Web.Domain.IService.Public; +using BarCode.Web.Domain.Services.Public; +using crypto; + +namespace BarCode.Web.Repositories.DependencyInjection +{ + /// + /// token 黑名单中间件 + /// + public class AuthorizationTokenSecurityPolicy + { + private readonly RequestDelegate _next; + private readonly IMemoryCache _cache; + private ILogger _logger; + private DateTime _refreshTime = DateTime.Now.AddYears(-5); + private readonly RedisClientService _redisClientService; + + /// + /// token黑名单中间件 + /// + /// + /// + public AuthorizationTokenSecurityPolicy(RequestDelegate next, ILogger logger, IMemoryCache cache, RedisClientService redisClientService) + { + _next = next; + _cache = cache; + this._logger = logger; + _redisClientService = redisClientService; + } + + /// + /// 事件 + /// + /// + /// + public async Task Invoke(HttpContext context, ILoginService loginService) + { + string authorization = context.Request.Headers["Authorization"]; + string path = context.Request.Path.Value.ToLower(); + string[] pathlist = path.Split('/'); + bool isLogin = pathlist.Where(x => x == "login" || x.ToLower() == "heart" + || x.ToLower() == "test" || x.ToLower() == "swagger" || x.ToLower() == "wmsbox" || x.ToLower() == "security" + || x.ToLower() == "material"||x.ToLower()== "filedownmanager").Any(); + if (isLogin) + { + context.Response.StatusCode = 200; + await _next(context); + return; + } + + if (string.IsNullOrEmpty(authorization)) + { + context.Response.StatusCode = 401; + var result = JsonConvert.SerializeObject(new { status = 401, data = string.Empty, message = "授权失败,请重新登录" }); + context.Response.ContentType = "application/json;charset=utf-8"; + await context.Response.WriteAsync(result); + return; + } + else + { + string token = string.Empty; + if (authorization.StartsWith("Bearer ", StringComparison.OrdinalIgnoreCase)) + { + token = authorization.Substring("Bearer ".Length).Trim(); + } + + //判断前端过来的token + if (string.IsNullOrEmpty(token)) + { + context.Response.StatusCode = 401; + var result = JsonConvert.SerializeObject(new { status = 401, data = string.Empty, message = "授权失败,请重新登录" }); + context.Response.ContentType = "application/json;charset=utf-8"; + await context.Response.WriteAsync(result); + return; + } + + //1.验证是否有登录数据缓存 + var logininfo = _redisClientService.GetStringKey($"wms_login_{token}"); + if (logininfo == null) + { + context.Response.StatusCode = 401; + var result = JsonConvert.SerializeObject(new { status = 401, data = string.Empty, message = "授权失败,请重新登录" }); + context.Response.ContentType = "application/json;charset=utf-8"; + await context.Response.WriteAsync(result); + return; + + } + else + { + //验证响应状态为401的就调用单点退出接口 + if (context.Response.StatusCode == 401 || context.Response.StatusCode == 403) + { + if (logininfo.UserInfo != null && logininfo.TokenInfo != null) + { + //调用单点的退出接口 + var dto = new LoginOutDto() + { + UcId = logininfo.UserInfo.UcId.ToString(), + SessionId = logininfo.UserInfo.SeesionId, + Token = logininfo.TokenInfo.Token, + RefreshToken = logininfo.TokenInfo.RefreshToken, + AccessToken = logininfo.TokenInfo.PhpToken, + ExpiresIn = logininfo.TokenInfo.Expired + + }; + var res = await loginService.LoginOut(dto); + return; + } + } + + DateTime now = DateTime.Now; + TimeSpan jiange_timespan = TimeSpan.Zero; + if (logininfo.TokenInfo.Expired < now) + { + jiange_timespan = now - logininfo.TokenInfo.Expired; + var info = _redisClientService.GetStringKey($"wms_login_{token}"); + + if (info != null) + { + //超过16个小时的,就要移除缓存 + if (jiange_timespan.TotalHours >= 16) + _redisClientService.RemoveStringKey($"wms_login_{token}"); + //超过1个小时的,就要刷新token + else if (!string.IsNullOrEmpty(logininfo.TokenInfo.Token) && jiange_timespan.TotalHours >= 1) + this.RefreshToken(logininfo.TokenInfo.Token, logininfo.TokenInfo.RefreshToken, loginService); + + } + } + //else + //{ + // //刷新token:距离过期时间还有10分钟就进行刷新token + // jiange_timespan = logininfo.TokenInfo.Expired - now; + // if (!string.IsNullOrEmpty(logininfo.TokenInfo.Token) && jiange_timespan.TotalMinutes<=10) + // this.RefreshToken(logininfo.TokenInfo.Token, logininfo.TokenInfo.RefreshToken, loginService); + //} + + //3.验证检查是否有黑名单的token缓存 + string blacktoken = _redisClientService.GetStringKey($"wms_black_token_{logininfo.UserInfo.UcId}"); + if (string.IsNullOrEmpty(blacktoken)) + { + context.Response.StatusCode = 200; + await _next(context); + } + else + { + RemoveRedisLoginInfo(token); + context.Response.StatusCode = 403; + var result = JsonConvert.SerializeObject(new { status = 403, data = string.Empty, message = "拒绝用户证书试图访问此web站点,请与站点管理员联系以建立用户证书权限" }); + context.Response.ContentType = "application/json;charset=utf-8"; + await context.Response.WriteAsync(result); + } + } + + } + } + + /// + /// 过期,或者失效,移出token + /// + /// + private void RemoveRedisLoginInfo(string token) + { + if (!string.IsNullOrEmpty(token)) + { + var info = _redisClientService.GetStringKey($"wms_login_{token}"); + if (info != null) + { + _redisClientService.RemoveStringKey($"wms_login_{token}"); + } + } + } + + + /// + /// 刷新token + /// + /// + /// + private bool RefreshToken(string OldToken, string RefreshToken, ILoginService _loginService) + { + var res = _loginService.RefreshTokenNew(OldToken, RefreshToken); + if (!res.Result.Success) + return false; + else + return true; + } + } +} diff --git a/src/BarCode.Web.Repositories/DependencyInjection/ErrorHandlingMiddleware.cs b/src/BarCode.Web.Repositories/DependencyInjection/ErrorHandlingMiddleware.cs new file mode 100644 index 0000000..f79d5aa --- /dev/null +++ b/src/BarCode.Web.Repositories/DependencyInjection/ErrorHandlingMiddleware.cs @@ -0,0 +1,85 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using System.Threading.Tasks; + +namespace BarCode.Web.Repositories.DependencyInjection +{ + /// + /// 统一全局错误拦截 + /// + public class ErrorHandlingMiddleware + { + private readonly RequestDelegate next; + private readonly ILogger _logger; + + /// + /// 统一错误处理中间件 + /// + public ErrorHandlingMiddleware(RequestDelegate next, ILogger logger) + { + this.next = next; + _logger = logger; + } + private string bodyStr = ""; + /// + /// 激活 + /// + /// + /// + public async Task Invoke(HttpContext context) + { + try + { + //默认 请求body只能读取一次 所以在这里需要手动把他设置成读取多次 并且 不能使用using 释放 + context.Request.EnableBuffering(); + StreamReader requestReader = new StreamReader(context.Request.Body, Encoding.UTF8); + bodyStr = await requestReader.ReadToEndAsync(); + context.Request.Body.Seek(0, SeekOrigin.Begin); + + await next(context); + } + catch (Exception ex) + { + // var statusCode = context.Response.StatusCode; + var statusCode = 500; + if (ex is ArgumentException) statusCode = 200; + + _logger.LogError($"统一拦截异常处理: {ex.Message}, StackTrace:{ex.StackTrace},Path:{context.Request.Path},Parame:{bodyStr}"); + + await HandleExceptionAsync(context, statusCode, "服务器错误,不能执行此请求,请稍后重试,若问题一直存在,请与站点管理员联系"); + // await HandleExceptionAsync(context, statusCode, "服务器错误"); + } + finally + { + var statusCode = context.Response.StatusCode; + var msg = ""; + // if (statusCode == 401) + // { + // msg = "未授权"; + // } + if (statusCode == 404) + msg = "服务器暂无响应,请稍后重试,若问题一直存在,请与站点管理员联系"; + else if (statusCode == 502) msg = "网关出错,请与站点管理员联系"; + // else if (statusCode != 200) + // { + // msg = "未知错误"; + // } + if (!string.IsNullOrWhiteSpace(msg)) await HandleExceptionAsync(context, statusCode, msg); + } + } + + private static Task HandleExceptionAsync(HttpContext context, int statusCode, string msg) + { + string data = null; + var result = JsonConvert.SerializeObject(new { status = statusCode, result = data, message = msg }); + context.Response.StatusCode = statusCode; + context.Response.ContentType = "application/json;charset=utf-8"; + return context.Response.WriteAsync(result); + } + } +} diff --git a/src/BarCode.Web.Repositories/DependencyInjection/PlatformActionMiddleware.cs b/src/BarCode.Web.Repositories/DependencyInjection/PlatformActionMiddleware.cs new file mode 100644 index 0000000..72f02d6 --- /dev/null +++ b/src/BarCode.Web.Repositories/DependencyInjection/PlatformActionMiddleware.cs @@ -0,0 +1,85 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Filters; +using Microsoft.Extensions.Caching.Memory; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Net; +using System.Text; +using BarCode.Web.Core.Internal.Results; +using BarCode.Web.Domain.Services.Public; +using Microsoft.AspNetCore.Http; +using Newtonsoft.Json; +using System.IO; +using System.Threading.Tasks; + +namespace BarCode.Web.Repositories.DependencyInjection +{ + /// + /// 防重复提交 + /// + public class PlatformActionMiddleware + { + private readonly RequestDelegate next; + private readonly ILogger _logger; + private readonly RedisClientService _redisClientService; + /// + /// 统一错误处理中间件 + /// + public PlatformActionMiddleware(RequestDelegate next, ILogger logger, RedisClientService redisClientService) + { + this.next = next; + _logger = logger; + _redisClientService = redisClientService; + } + private string bodyStr = ""; + + /// + /// 激活 + /// + /// + /// + public async Task Invoke(HttpContext context) + { + //默认 请求body只能读取一次 所以在这里需要手动把他设置成读取多次 并且 不能使用using 释放 + context.Request.EnableBuffering(); + StreamReader requestReader = new StreamReader(context.Request.Body, Encoding.UTF8); + bodyStr = await requestReader.ReadToEndAsync(); + context.Request.Body.Seek(0, SeekOrigin.Begin); + + string httpMethod = WebUtility.HtmlEncode(context.Request.Method); + if (httpMethod == "POST") + { + //使用请求路径作为唯一key + string path = context.Request.Path; + string authorization = context.Request.Headers["Authorization"]; + string cacheToken = $"{authorization}_{path}"; + string keyValue = string.IsNullOrEmpty(bodyStr) ? "yc" : bodyStr; + + if (path != null) + { + //var cache = iZen.Utils.Core.iCache.CacheManager.GetCacheValue(cacheToken); + string cv = _redisClientService.GetStringKey(cacheToken); + if (cv == null && bodyStr != cv) + { + //iZen.Utils.Core.iCache.CacheManager.SetChacheValueSeconds(cacheToken, keyValue, 1); + //设置缓存10秒过期 + _redisClientService.SetStringKey(cacheToken, keyValue, TimeSpan.FromSeconds(10)); + + } + else + { + context.Response.StatusCode = 200; + var result = JsonConvert.SerializeObject(new { status = 888888, data = string.Empty, message = "重复提交" }); + context.Response.ContentType = "application/json;charset=utf-8"; + await context.Response.WriteAsync(result); + return; + } + + } + } + await next(context); + + } + } +} diff --git a/src/BarCode.Web.Repositories/DependencyInjection/ServiceCollectionExtensions.cs b/src/BarCode.Web.Repositories/DependencyInjection/ServiceCollectionExtensions.cs new file mode 100644 index 0000000..6405f29 --- /dev/null +++ b/src/BarCode.Web.Repositories/DependencyInjection/ServiceCollectionExtensions.cs @@ -0,0 +1,40 @@ +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using System; +using System.Collections.Generic; +using System.Text; +using BarCode.Web.Repositories.DependencyInjection; + +namespace Microsoft.Extensions.DependencyInjection +{ + public static class ServiceCollectionExtensions + { + /// + /// 添加app框架 + /// + /// + /// + /// + public static IServiceCollection AddApp(this IServiceCollection services, IConfiguration configuration, bool IsDevelopment, Action startupAction) + { + services.AddAppCore(configuration, IsDevelopment, startupAction); + return services; + } + + + /// + /// 添加app核心服务 + /// + /// + /// ASF启动配置函数 + /// + internal static IServiceCollection AddAppCore(this IServiceCollection services, IConfiguration configuration, bool IsDevelopment, Action startupAction) + { + var builder = new AppBuilder(services, configuration, IsDevelopment); + startupAction?.Invoke(builder); + builder.Build(); + return services; + } + + } +} diff --git a/src/BarCode.Web.Repositories/FileDownManagerRepositories.cs b/src/BarCode.Web.Repositories/FileDownManagerRepositories.cs new file mode 100644 index 0000000..3514654 --- /dev/null +++ b/src/BarCode.Web.Repositories/FileDownManagerRepositories.cs @@ -0,0 +1,110 @@ +using AutoMapper; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using BarCode.Web.Core; +using BarCode.Web.Core.Dto; +using BarCode.Web.Domain.Entitys; +using BarCode.Web.Domain.Infrastructure; +using BarCode.Web.Domain.IService.Public; +using BarCode.Web.Domain.Values; +using BarCode.Web.Domain.Values.Single; +using BarCode.Web.Repositories.Configuration; +using static Microsoft.EntityFrameworkCore.DbLoggerCategory; +using BarCode.Web.Core.Dto.Login; + +namespace BarCode.Web.Repositories +{ + public class FileDownManagerRepositories : IFileDownManagerRepositories + { + private readonly IMapper _mapper; + private readonly RepositoryDbContext _context; + private readonly ISingleDataService _singleDataService; + public FileDownManagerRepositories(RepositoryDbContext context, IMapper mapper, ISingleDataService singleDataService) + { + _mapper = mapper; + _context = context; + _singleDataService = singleDataService; + } + + public async Task Add(FileDownManager entity) + { + await _context.FileDownManager.AddAsync(entity); + await _context.SaveChangesAsync(); + + return entity; + } + + public async Task Edit(FileDownManager entity) + { + var res = await _context.FileDownManager + .FirstOrDefaultAsync(f => f.Id == entity.Id); + if (res == null) return null; + + _mapper.Map(entity, res); + + await _context.SaveChangesAsync(); + return res; + } + + public async Task GetList(FileDownManagerRequest dto, LoginInDto loginInfo) + { + List userIds = new List(); + if (!string.IsNullOrEmpty(dto.User)) + userIds = _singleDataService.GetIdsBySingleName(SingleAction.Users, loginInfo.UserInfo.CompanyId, dto.User); + + var res = _context.FileDownManager + //.GroupJoin(_context.UcStaff, manager => manager.UserId, user => user.Id, (manager, user) => new { manager, user }) + // .SelectMany(x => x.user.DefaultIfEmpty(), (d, user) => new { d.manager, user }) + .OrderByDescending(o => o.Date) + .Where(w => w.CompanyId == loginInfo.UserInfo.CompanyId); + + + #region 条件 + if (loginInfo.UserInfo.IsAdmin != true && !string.IsNullOrEmpty(dto.OrgCode)) + { + var rec_type = dto.OrgCode.Substring(0, 1); + var rec_code = dto.OrgCode.Substring(2, dto.OrgCode.Length - 2); + + if (rec_type.Equals("s"))//供应商 + res = res.Where(w => rec_code == w.SupplierCode); + else//查其他单据(组织) + res = res.Where(w => rec_code == w.OrgCode); + } + if (!string.IsNullOrEmpty(dto.User)) + res = res.Where(w => userIds.Contains(w.UserId)); + if (dto.BeginDate != null) + res = res.Where(w => w.Date >= dto.BeginDate); + if (dto.EndDate != null) + res = res.Where(w => w.Date <= (dto.EndDate ?? DateTime.Now).AddHours(23).AddMinutes(59).AddSeconds(59)); + if (dto.Type != null) + res = res.Where(w => w.Type == (FileDownLoadOrderType)dto.Type); + + if (dto.Status != null) + { + if ((ExportStatus)dto.Status == ExportStatus.Ing) + res = res.Where(w => w.Status == ExportStatus.Ing && w.Date >= DateTime.Now.AddHours(-1)); + else if ((ExportStatus)dto.Status == ExportStatus.Fail) + res = res.Where(w => (w.Status == ExportStatus.Fail) || (w.Status == ExportStatus.Ing && w.Date < DateTime.Now.AddHours(-1))); + else + res = res.Where(w => w.Status == (ExportStatus)dto.Status); + } + #endregion + + int total = await res.CountAsync(); + var list = await res.Select(s => new FileDownInfoManagerResponse(_mapper.Map(s)) + { + StatusKey = (s.Status == ExportStatus.Ing && s.Date < DateTime.Now.AddHours(-1)) ? (int)ExportStatus.Fail : (int)s.Status, + Status = (s.Status == ExportStatus.Ing && s.Date < DateTime.Now.AddHours(-1)) ? ExportStatus.Fail.GetRemark() : s.Status.GetRemark(), + UserName = _singleDataService.GetSingleData(SingleAction.Users, loginInfo.UserInfo.CompanyId, s.UserId) + }) + .Skip((dto.PageNo - 1) * dto.PageSize).Take(dto.PageSize) + .ToListAsync(); + + return new FileDownManagerResponse(list, total); + } + } +} diff --git a/src/BarCode.Web.Repositories/LoginRepositories.cs b/src/BarCode.Web.Repositories/LoginRepositories.cs new file mode 100644 index 0000000..471b24e --- /dev/null +++ b/src/BarCode.Web.Repositories/LoginRepositories.cs @@ -0,0 +1,49 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Text; +using BarCode.Web.Core.Dto.Login; +using BarCode.Web.Domain.Infrastructure; +using BarCode.Web.Domain.Services.Public; + +namespace BarCode.Web.Repositories +{ + /// + /// 登录仓储 + /// + public class LoginRepositories:ILoginRepositories + { + public int CompanyId { get; set; } = 0; + public int StaffId { get; set; } = 0; + public LoginInDto loginInfo { get; set; } + private readonly RedisClientService _redisClientService; + public LoginRepositories(ILogger logger, IHttpContextAccessor httpContextAccessor, RedisClientService redisClientService) + { + try + { + string authorization = httpContextAccessor?.HttpContext?.Request?.Headers["Authorization"] ?? ""; + if (string.IsNullOrEmpty(authorization)) return; + + string token = string.Empty; + if (authorization.StartsWith("Bearer ", StringComparison.OrdinalIgnoreCase)) + token = authorization.Substring("Bearer ".Length).Trim(); + if (string.IsNullOrEmpty(token)) + { + this.CompanyId = 0; + this.StaffId = 0; + return; + } + + _redisClientService = redisClientService; + var logininfo = _redisClientService.GetStringKey($"wms_login_{token}"); + this.loginInfo = loginInfo; + this.CompanyId = logininfo == null ? 0 : logininfo.UserInfo.CompanyId; + this.StaffId = logininfo == null ? 0 : logininfo.UserInfo.StaffId; + } + catch (Exception) + { + } + } + } +} diff --git a/src/BarCode.Web.Repositories/MaterialsRepositories.cs b/src/BarCode.Web.Repositories/MaterialsRepositories.cs new file mode 100644 index 0000000..516b417 --- /dev/null +++ b/src/BarCode.Web.Repositories/MaterialsRepositories.cs @@ -0,0 +1,177 @@ +using AutoMapper; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Storage; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using BarCode.Web.Core.Help; +using BarCode.Web.Domain.Entitys; +using BarCode.Web.Domain.Infrastructure; +using BarCode.Web.Domain.IService.Public; +using BarCode.Web.Domain.Mappers; +using BarCode.Web.Repositories.Configuration; + +namespace BarCode.Web.Repositories +{ + /// + /// 物料仓储 + /// + public class MaterialsRepositories : IMaterialsRepositories + { + private readonly IMapper _mapper; + private readonly RepositoryDbContext _context; + private readonly IServiceProvider _serviceProvider; + + public MaterialsRepositories(RepositoryDbContext context, IServiceProvider serviceProvider, + IMapper mapper) + { + _serviceProvider = serviceProvider; + _context = context; + _mapper = mapper; + } + + /// + /// 批量添加 + /// + /// + /// + /// + public async Task AddRange(List entitys, bool isTransaction = true) + { + IDbContextTransaction _transaction = null; + if (isTransaction) + _transaction = _context.Database.BeginTransaction(); + try + { + if (entitys != null && entitys.Count != 0) + { + await _context.Materials.AddRangeAsync(entitys); + await _context.SaveChangesAsync(); + } + if (_transaction != null) + _transaction.Commit(); + return true; + } + catch + { + if (_transaction != null) + _transaction.Rollback(); + return false; + } + } + + /// + /// 获取集合 + /// + /// + /// + public async Task> GetEntityList(int? orgId = null) + { + var query = _context.Materials.AsNoTracking() + .Where(x => 1 == 1); + if (orgId.HasValue) + query = query.Where(x => x.OrgId == orgId.Value); + + return await query.ToListAsync(); + } + + /// + /// 获取 + /// + /// + /// + public async Task Get(int mid) + { + var query = _context.Materials.AsNoTracking().Where(x => 1 == 1); + + query = query.Where(x => x.MaterialId == mid); + + return await query.FirstOrDefaultAsync(); + } + + /// + /// 获取 + /// + /// + /// + public async Task Get(string code, int orgId) + { + var query = _context.Materials.AsNoTracking().Where(x => x.MaterialNumber == code && x.OrgId == orgId); + + return await query.FirstOrDefaultAsync(); + } + + /// + /// 获取全部的物料编码 + /// + /// + public async Task> GetAllNumbers() + { + var numbers = await _context.Materials.AsNoTracking() + .Select(x => x.MaterialNumber).ToListAsync(); + if (numbers.Count() <= 0) return numbers; + + return numbers.Distinct().ToList(); + + } + + /// + /// 获取全部的物料编码 + /// + /// + public async Task> GetEntityList(List materNumbers, bool isBatchManage) + { + var entitys = await _context.Materials.Where(x => materNumbers.Contains(x.MaterialNumber) && x.IsBatchManage == isBatchManage).ToListAsync(); + return entitys; + } + + /// + /// 修改物料 + /// + /// + /// + /// + public async Task UpdateRange(List entitys, bool isTransaction = true) + { + IDbContextTransaction _transaction = null; + if (isTransaction) + _transaction = _context.Database.BeginTransaction(); + { + try + { + List list = entitys.Select(s => s.Id).ToList(); + var res = await _context.Materials.Where(f => list.Contains(f.Id)).ToListAsync(); + _mapper.ToMapList(entitys, res); + await _context.SaveChangesAsync(); + if (_transaction != null) + _transaction.Commit(); + } + catch (Exception ex) + { + if (_transaction != null) + _transaction.Rollback(); + return false; + } + return true; + } + } + /// + /// 获取所有没有id32进制的物料 + /// + /// + public async Task> GetEntityListByNoBar() + { + var entitys = await _context.Materials.AsNoTracking().Where(x =>string.IsNullOrEmpty(x.IdConvertBar.Trim())).ToListAsync(); + return entitys; + } + + public async Task> GetEntityList(List materNumbers) + { + var entitys = await _context.Materials.Where(x => materNumbers.Contains(x.MaterialNumber)).ToListAsync(); + return entitys; + } + } +} diff --git a/src/BarCode.Web.Repositories/MySqlDataAccess.cs b/src/BarCode.Web.Repositories/MySqlDataAccess.cs new file mode 100644 index 0000000..3d7a823 --- /dev/null +++ b/src/BarCode.Web.Repositories/MySqlDataAccess.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using MySqlConnector; +namespace BarCode.Web.Repositories +{ + public class MySqlDataAccess + { + private readonly string _connectionString; + + public MySqlDataAccess(string connectionString) + { + _connectionString = connectionString; + } + + /// + /// 执行查询并返回 DataTable + /// + /// SQL 查询语句 + /// 查询结果的 DataTable + public DataTable ExecuteQuery(string query) + { + using (MySqlConnection connection = new MySqlConnection(_connectionString)) + { + try + { + connection.Open(); + MySqlCommand command = new MySqlCommand(query, connection); + MySqlDataAdapter adapter = new MySqlDataAdapter(command); + DataTable dataTable = new DataTable(); + adapter.Fill(dataTable); + return dataTable; + } + catch (Exception ex) + { + Console.WriteLine($"查询出错: {ex.Message}"); + return null; + } + } + } + + /// + /// 执行非查询操作(如 INSERT、UPDATE、DELETE) + /// + /// SQL 非查询语句 + /// 受影响的行数 + public int ExecuteNonQuery(string query) + { + using (MySqlConnection connection = new MySqlConnection(_connectionString)) + { + try + { + connection.Open(); + MySqlCommand command = new MySqlCommand(query, connection); + return command.ExecuteNonQuery(); + } + catch (Exception ex) + { + Console.WriteLine($"执行非查询操作出错: {ex.Message}"); + return -1; + } + } + } + } +} diff --git a/src/BarCode.Web.Repositories/SGenerateRecordRepositories.cs b/src/BarCode.Web.Repositories/SGenerateRecordRepositories.cs new file mode 100644 index 0000000..84a417d --- /dev/null +++ b/src/BarCode.Web.Repositories/SGenerateRecordRepositories.cs @@ -0,0 +1,339 @@ +using AutoMapper; +using BarCode.Web.Core.Dto.Erp.Org; +using BarCode.Web.Core.Dto.Erp.Supplier; +using BarCode.Web.Core.Dto.Erp; +using BarCode.Web.Core.Dto.SerialNumbers; +using BarCode.Web.Domain.Entitys; +using BarCode.Web.Domain.Infrastructure; +using BarCode.Web.Domain.Mappers; +using BarCode.Web.Repositories.Configuration; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Storage; +using Newtonsoft.Json; +using Org.BouncyCastle.Crypto; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static Microsoft.EntityFrameworkCore.DbLoggerCategory; +using BarCode.Web.Domain.IService.Public; +using BarCode.Web.Core.Dto.Box; +using BarCode.Web.Domain.Services.Public; +using BarCode.Web.Domain.Values.Single; +using System.ComponentModel.Design; +using BarCode.Web.Core.Help; +using NPOI.SS.Formula.Functions; +using Microsoft.AspNetCore.Http.HttpResults; +using BarCode.Web.Core.Dto.Login; +using BarCode.Web.Core.Dto.SingleData; +using BarCode.Web.Core.Internal.Results; + +namespace BarCode.Web.Repositories +{ + /// + /// 序列号生成记录 + /// + public class SGenerateRecordRepositories : ISGenerateRecordRepositories + { + private readonly ILoginRepositories _loginRepositories; + private readonly RepositoryDbContext _context; + private readonly IBasicsRepositories _basicsRepositories; + private readonly IMapper _mapper; + private readonly IErpService _erpService; + private readonly IErpBasicDataExtendService _erpBasicDataExtendService; + private readonly ISingleDataService _singleDataService; + + public SGenerateRecordRepositories(RepositoryDbContext context, + ILoginRepositories loginRepositories, + IBasicsRepositories basicsRepositories, IMapper mapper, IErpService erpService, + IErpBasicDataExtendService erpBasicDataExtendService, ISingleDataService singleDataService) + { + _context = context; + _basicsRepositories = basicsRepositories; + _loginRepositories = loginRepositories; + _mapper = mapper; + _erpService = erpService; + _erpBasicDataExtendService = erpBasicDataExtendService; + _singleDataService = singleDataService; + } + /// + /// 新增 + /// + /// + /// + /// + public async Task Add(SerialNumberGenerateRecord entity, bool isTransaction = true) + { + IDbContextTransaction _transaction = null; + if (isTransaction) + _transaction = _context.Database.BeginTransaction(); + + await _context.SerialNumberGenerateRecord.AddAsync(entity); + await _context.SaveChangesAsync(); + + if (_transaction != null) + _transaction.Commit(); + return entity; + } + /// + /// 批量添加 + /// + /// + /// + /// + public async Task AddRange(List entitys, bool isTransaction = true) + { + IDbContextTransaction _transaction = null; + if (isTransaction) + _transaction = _context.Database.BeginTransaction(); + + if (entitys != null && entitys.Count != 0) + { + await _context.SerialNumberGenerateRecord.AddRangeAsync(entitys); + await _context.SaveChangesAsync(); + } + if (_transaction != null) + _transaction.Commit(); + return true; + } + /// + /// 修改 + /// + /// + /// + /// + public async Task Edit(SerialNumberGenerateRecord entity, bool isTransaction = true) + { + + IDbContextTransaction _transaction = null; + if (isTransaction) + _transaction = _context.Database.BeginTransaction(); + + var res = await _context.SerialNumberGenerateRecord + .FirstOrDefaultAsync(f => f.Id == entity.Id); + if (res == null) return null; + + _mapper.Map(entity, res); + var result = await _context.SaveChangesAsync(); + + if (_transaction != null) + _transaction.Commit(); + + return res; + } + /// + /// 批量修改 + /// + /// + /// + /// + public async Task EditEntityList(List entitys, bool isTransaction = true) + { + IDbContextTransaction _transaction = null; + if (isTransaction) + _transaction = _context.Database.BeginTransaction(); + + List list = entitys.Select(s => s.Id).ToList(); + var res = await _context.SerialNumberGenerateRecord + .Where(f => list.Contains(f.Id)).ToListAsync(); + + _mapper.ToMapList(entitys, res); + await _context.SaveChangesAsync(); + + if (_transaction != null) + _transaction.Commit(); + + return true; + } + /// + /// 查询实体 + /// + /// + /// + public async Task GetEntity(int id) + { + return await _context.SerialNumberGenerateRecord.AsNoTracking() + .FirstOrDefaultAsync(f => f.Id == id); + } + + /// + /// 获取集合 + /// + /// + /// + /// + public async Task> GetEntityList(List ids) + { + return await _context.SerialNumberGenerateRecord.AsNoTracking() + .Where(f => ids.Contains(f.Id)) + .ToListAsync(); + } + + /// + /// 列表 + /// + /// + /// + /// + public async Task<(List list, int total)> GetListAsync(SGenerateRecordQueryRequest dto, LoginInDto loginInfo) + { + int companyId = loginInfo.UserInfo.CompanyId; + + List mNumber = new List(); + var materials_result = await _erpService.BillQueryForMaterial(); + List materials = new List(); + if (materials_result.IsSuccess) + materials = materials_result.Data.ToList(); + //物料集合;模糊查询后的物料集合 + if (!string.IsNullOrEmpty(dto.MaterialNumber)) + { + if (materials != null) + mNumber = materials.Where(w => w.MaterialNumber.Contains(dto.MaterialNumber) + || w.MaterialName.Contains(dto.MaterialNumber) + || w.Specifications.Contains(dto.MaterialNumber) + ).Select(s => s.MaterialNumber).ToList(); + } + List cr_ids = new List(); + if (!string.IsNullOrEmpty(dto.CreateUser)) + { + cr_ids = await _basicsRepositories.GetUserIdsAsync(dto.CreateUser, loginInfo.UserInfo.CompanyId); + } + List sIds = new List(); + if (dto.SerialNumbers != null && dto.SerialNumbers.Count() > 0) + { + sIds = await _context.SerialNumbers.Where(w => dto.SerialNumbers.Contains(w.SerialNumber)) + .GroupBy(g => g.GenerateRecordId).Select(s => s.Key).ToListAsync(); + } + + List nIds = new List(); + if (dto.NumberCodes != null && dto.NumberCodes.Count() > 0) + { + nIds = await _context.SerialNumbers.Where(w => dto.NumberCodes.Contains(w.NumberCode)) + .GroupBy(g => g.GenerateRecordId).Select(s => s.Key).ToListAsync(); + } + + List bIds = new List(); + if (dto.BoxBillNos != null && dto.BoxBillNos.Count() > 0) + { + bIds = await _context.SerialNumbers + .GroupJoin(_context.Box, serial => serial.BoxId, box => box.Id, (serial, box) => new { serial, box }) + .SelectMany(x => x.box.DefaultIfEmpty(), (p, box) => new { p.serial, box }) + .Where(w => dto.BoxBillNos.Contains(w.box.BoxBillNo)) + .Select(s => s.serial.GenerateRecordId) + .ToListAsync(); + } + + + //供应商 + //var supplier_result = await _erpService.BillQueryForSupplier(); + //List suppliers = new List(); + //if (supplier_result.IsSuccess) + // suppliers = supplier_result.Data.ToList(); + //取组织 + //var org_result = await _erpService.BillQueryForOrg(); + //List orgs = new List(); + //if (org_result.IsSuccess) + // orgs = org_result.Data.ToList(); + var result = await _singleDataService.GetSingleData, SingleDataRequest, SysConfigAction>( + new SingleDataRequest(loginInfo.UserInfo.CompanyId), SysConfigAction.GetOrgByCompany, SingleControllerType.SysConfig); + List orgs = new List(); + if (result.IsSuccess) + orgs = result.Data.ToList(); + + var query = _context.SerialNumberGenerateRecord + .OrderByDescending(o => o.Id) + .Where(f => 1 == 1); + if (loginInfo.UserInfo.IsAdmin != true && !string.IsNullOrEmpty(dto.OrgCode)) + { + var rec_type = dto.OrgCode.Substring(0, 1); + var rec_code = dto.OrgCode.Substring(2, dto.OrgCode.Length - 2); + + if (rec_type.Equals("s"))//供应商 + query = query.Where(w => rec_code == w.SupplierCode); + else//查其他单据(组织) + query = query.Where(w => rec_code == w.OrgCode); + } + if (!string.IsNullOrEmpty(dto.SupplierOrOrg)) + { + var rec_type = dto.SupplierOrOrg.Substring(0, 1); + var rec_code = dto.SupplierOrOrg.Substring(2, dto.SupplierOrOrg.Length - 2); + + if (rec_type.Equals("s"))//供应商 + query = query.Where(w => rec_code == w.SupplierCode); + else//查其他单据(组织) + query = query.Where(w => rec_code == w.OrgCode); + } + if (!string.IsNullOrEmpty(dto.MaterialNumber)) + query = query.Where(w => mNumber.Contains(w.MaterialNumber)); + if (dto.CreateBeginDate != null) + query = query.Where(w => w.GenerateCompleteTime >= dto.CreateBeginDate); + if (dto.CreateEndDate != null) + { + DateTime dt_end = ((DateTime)dto.CreateEndDate).AddDays(1); + query = query.Where(w => w.GenerateCompleteTime <= dt_end); + } + if (dto.SerialNumbers != null && dto.SerialNumbers.Count() > 0) + query = query.Where(w => sIds.Contains(w.Id)); + if (dto.NumberCodes != null && dto.NumberCodes.Count() > 0) + query = query.Where(w => nIds.Contains(w.Id)); + if (dto.BoxBillNos != null && dto.BoxBillNos.Count() > 0) + query = query.Where(w => bIds.Contains(w.Id)); + if (dto.PurchaseBillNos != null && dto.PurchaseBillNos.Count() > 0) + query = query.Where(w => dto.PurchaseBillNos.Contains(w.PurchaseBillNo)); + if (dto.GenerateComplete != null) + query = query.Where(w => dto.GenerateComplete == w.IsGenerateComplete); + if (!string.IsNullOrEmpty(dto.CreateUser)) + query = query.Where(w => cr_ids.Contains(w.CreatorId)); + if (dto.IsUpdateMaterial != null) + { + if (dto.IsUpdateMaterial == true) + query = query.Where(w => w.IsUpdateMaterial == true); + else + query = query.Where(w => w.IsUpdateMaterial == false || w.IsUpdateMaterial == null); + } + + if (dto.IsTwo > 1) + { + query = query.Where(w => w.IsTwo > 1); + } + else if (dto.IsTwo == 1) + { + query = query.Where(w => w.IsTwo == 1); + } + else if (dto.IsTwo == 0) + { + } + else + { + //query = query.Where(w => w.IsTwo == 1); + } + + + + int total = await query.CountAsync(); + var list = await query.Select(s => new SGenerateRecordInfoResponse() + { + Id = s.Id, + Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, s.MaterialNumber), + MaterialNumber = s.MaterialNumber, + MaterialName = _erpBasicDataExtendService.GetMaterialName(materials, s.MaterialNumber), + BarCode = _erpBasicDataExtendService.GetMaterialBarCode(materials, s.MaterialNumber), + PurchaseBillNo = s.PurchaseBillNo, + GenerateComplete = s.IsGenerateComplete == true ? "已完成" : "生成中", + Number = s.Number, + DownLoadNumber = s.DownLoadNumber, + UseNumber = s.UseNumber, + IsUpdateMaterial = s.IsUpdateMaterial, + Creator = _singleDataService.GetSingleData(SingleAction.Users, companyId, s.CreatorId), + CreateTime = s.CreateTime.DateToStringSeconds(), + GenerateCompleteTime = s.GenerateCompleteTime.DateToStringSeconds(), + PrintNumber = s.PrintNumber, + IsTwo= s.IsTwo,//add by yzh + SupplierOrOrg = string.IsNullOrEmpty(s.SupplierCode) ? _erpBasicDataExtendService.GetSingleOrgName(orgs, s.OrgCode) + : _singleDataService.GetSingleData(SingleAction.Suppliers, companyId, s.SupplierCode)//供应商取单点的 + }).Skip((dto.PageNo - 1) * dto.PageSize).Take(dto.PageSize).ToListAsync(); + return (list, total); + } + } +} diff --git a/src/BarCode.Web.Repositories/SecurityGenerateRecordRepositories.cs b/src/BarCode.Web.Repositories/SecurityGenerateRecordRepositories.cs new file mode 100644 index 0000000..d16f00d --- /dev/null +++ b/src/BarCode.Web.Repositories/SecurityGenerateRecordRepositories.cs @@ -0,0 +1,275 @@ +using AutoMapper; +using BarCode.Web.Core.Dto.Erp.Org; +using BarCode.Web.Core.Dto.Erp.Supplier; +using BarCode.Web.Core.Dto.Erp; +using BarCode.Web.Core.Dto.SerialNumbers; +using BarCode.Web.Domain.Entitys; +using BarCode.Web.Domain.Infrastructure; +using BarCode.Web.Domain.Mappers; +using BarCode.Web.Repositories.Configuration; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Storage; +using Newtonsoft.Json; +using Org.BouncyCastle.Crypto; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static Microsoft.EntityFrameworkCore.DbLoggerCategory; +using BarCode.Web.Domain.IService.Public; +using BarCode.Web.Core.Dto.Box; +using BarCode.Web.Domain.Services.Public; +using BarCode.Web.Domain.Values.Single; +using System.ComponentModel.Design; +using BarCode.Web.Core.Help; +using NPOI.SS.Formula.Functions; +using Microsoft.AspNetCore.Http.HttpResults; +using BarCode.Web.Core.Dto.SecurityNumbers; +using NPOI.OpenXmlFormats.Wordprocessing; +using BarCode.Web.Core.Dto.Login; + +namespace BarCode.Web.Repositories +{ + /// + /// 防伪码生成记录 + /// + public class SecurityGenerateRecordRepositories : ISecurityGenerateRecordRepositories + { + private readonly ILoginRepositories _loginRepositories; + private readonly RepositoryDbContext _context; + private readonly IBasicsRepositories _basicsRepositories; + private readonly IMapper _mapper; + private readonly IErpService _erpService; + private readonly IErpBasicDataExtendService _erpBasicDataExtendService; + private readonly ISingleDataService _singleDataService; + public SecurityGenerateRecordRepositories(RepositoryDbContext context, + ILoginRepositories loginRepositories, + IBasicsRepositories basicsRepositories, IMapper mapper, IErpService erpService, + IErpBasicDataExtendService erpBasicDataExtendService, ISingleDataService singleDataService) + { + _context = context; + _basicsRepositories = basicsRepositories; + _loginRepositories = loginRepositories; + _mapper = mapper; + _erpService = erpService; + _erpBasicDataExtendService = erpBasicDataExtendService; + _singleDataService = singleDataService; + } + /// + /// 新增 + /// + /// + /// + /// + public async Task Add(SecurityNumberGenerateRecord entity, bool isTransaction = true) + { + IDbContextTransaction _transaction = null; + if (isTransaction) + _transaction = _context.Database.BeginTransaction(); + + await _context.SecurityNumberGenerateRecord.AddAsync(entity); + await _context.SaveChangesAsync(); + + if (_transaction != null) + _transaction.Commit(); + return entity; + } + /// + /// 批量添加 + /// + /// + /// + /// + public async Task AddRange(List entitys, bool isTransaction = true) + { + IDbContextTransaction _transaction = null; + if (isTransaction) + _transaction = _context.Database.BeginTransaction(); + + if (entitys != null && entitys.Count != 0) + { + await _context.SecurityNumberGenerateRecord.AddRangeAsync(entitys); + await _context.SaveChangesAsync(); + } + if (_transaction != null) + _transaction.Commit(); + return true; + } + /// + /// 修改 + /// + /// + /// + /// + public async Task Edit(SecurityNumberGenerateRecord entity, bool isTransaction = true) + { + + IDbContextTransaction _transaction = null; + if (isTransaction) + _transaction = _context.Database.BeginTransaction(); + + var res = await _context.SecurityNumberGenerateRecord + .FirstOrDefaultAsync(f => f.Id == entity.Id); + if (res == null) return null; + + _mapper.Map(entity, res); + var result = await _context.SaveChangesAsync(); + + if (_transaction != null) + _transaction.Commit(); + + return res; + } + /// + /// 批量修改 + /// + /// + /// + /// + public async Task EditEntityList(List entitys, bool isTransaction = true) + { + IDbContextTransaction _transaction = null; + if (isTransaction) + _transaction = _context.Database.BeginTransaction(); + + List list = entitys.Select(s => s.Id).ToList(); + var res = await _context.SecurityNumberGenerateRecord + .Where(f => list.Contains(f.Id)).ToListAsync(); + + _mapper.ToMapList(entitys, res); + await _context.SaveChangesAsync(); + + if (_transaction != null) + _transaction.Commit(); + + return true; + } + /// + /// 查询实体 + /// + /// + /// + public async Task GetEntity(int id) + { + return await _context.SecurityNumberGenerateRecord.AsNoTracking() + .FirstOrDefaultAsync(f => f.Id == id); + } + + /// + /// 获取集合 + /// + /// + /// + /// + public async Task> GetEntityList(List ids) + { + return await _context.SecurityNumberGenerateRecord.AsNoTracking() + .Where(f => ids.Contains(f.Id)) + .ToListAsync(); + } + /// + /// 获取当天生成记录条数 + /// + /// + /// + public async Task GetGenerateRecordDayCount() + { + return await _context.SecurityNumberGenerateRecord.AsNoTracking() + .Where(f => f.CreateTime >= DateTime.Now.Date).CountAsync(); + } + + /// + /// 列表 + /// + /// + /// + /// + public async Task<(List list, int total)> GetListAsync(SecurityGenerateRecordQueryRequest dto, LoginInDto loginInfo) + { + int companyId = loginInfo.UserInfo.CompanyId; + + List mNumber = new List(); + var materials_result = await _erpService.BillQueryForMaterial(); + List materials = new List(); + if (materials_result.IsSuccess) + materials = materials_result.Data.ToList(); + //物料集合;模糊查询后的物料集合 + if (!string.IsNullOrEmpty(dto.MaterialNumber)) + { + if (materials != null) + mNumber = materials.Where(w => w.MaterialNumber.Contains(dto.MaterialNumber) + || w.MaterialName.Contains(dto.MaterialNumber) + || w.Specifications.Contains(dto.MaterialNumber) + ).Select(s => s.MaterialNumber).ToList(); + } + List sIds = new List(); + if (dto.SecurityNumbers != null && dto.SecurityNumbers.Count() > 0) + { + sIds = await _context.SecurityNumbers.Where(w => dto.SecurityNumbers.Contains(w.SecurityNumber)) + .GroupBy(g => g.GenerateRecordId).Select(s => s.Key).ToListAsync(); + } + + ////供应商 + //var supplier_result = await _erpService.BillQueryForSupplier(); + //List suppliers = new List(); + //if (supplier_result.IsSuccess) + // suppliers = supplier_result.Data.ToList(); + ////取组织 + //var org_result = await _erpService.BillQueryForOrg(); + //List orgs = new List(); + //if (org_result.IsSuccess) + // orgs = org_result.Data.ToList(); + + var query = _context.SecurityNumberGenerateRecord + .OrderByDescending(o => o.Id) + .Where(f => 1==1); + if (loginInfo.UserInfo.IsAdmin != true && !string.IsNullOrEmpty(dto.OrgCode)) + { + var rec_type = dto.OrgCode.Substring(0, 1); + var rec_code = dto.OrgCode.Substring(2, dto.OrgCode.Length - 2); + + if (rec_type.Equals("s"))//供应商 + query = query.Where(w => rec_code == w.SupplierCode); + else//查其他单据(组织) + query = query.Where(w => rec_code == w.OrgCode); + } + if (!string.IsNullOrEmpty(dto.MaterialNumber)) + query = query.Where(w => mNumber.Contains(w.MaterialNumber)); + if (dto.CreateBeginDate != null) + query = query.Where(w => w.GenerateCompleteTime >= dto.CreateBeginDate); + if (dto.CreateEndDate != null) + { + DateTime dt_end = ((DateTime)dto.CreateEndDate).AddDays(1); + query = query.Where(w => w.GenerateCompleteTime <= dt_end); + } + if (mNumber.Count() > 0) + query = query.Where(w => mNumber.Contains(w.MaterialNumber)); + if (dto.GenerateComplete != null) + query = query.Where(w => dto.GenerateComplete == w.IsGenerateComplete); + if (dto.LotNumbers != null && dto.LotNumbers.Count() > 0) + query = query.Where(w => dto.LotNumbers.Contains(w.LotNumber)); + if (dto.SecurityNumbers != null && dto.SecurityNumbers.Count() > 0) + query = query.Where(w => sIds.Contains(w.Id)); + + + int total = await query.CountAsync(); + var list = await query.Select(s => new SecurityGenerateRecordInfoResponse() + { + Id = s.Id, + Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, s.MaterialNumber), + MaterialNumber = s.MaterialNumber, + MaterialName = _erpBasicDataExtendService.GetMaterialName(materials, s.MaterialNumber), + BarCode = _erpBasicDataExtendService.GetMaterialBarCode(materials, s.MaterialNumber), + LotNumber = s.LotNumber, + GenerateComplete = s.IsGenerateComplete == true ? "已完成" : "生成中", + Number = s.Number, + DownLoadNumber = s.DownLoadNumber, + Creator = _singleDataService.GetSingleData(SingleAction.Users, companyId, s.CreatorId), + CreateTime = s.CreateTime.DateToStringSeconds(), + GenerateCompleteTime = s.GenerateCompleteTime.DateToStringSeconds() + }).Skip((dto.PageNo - 1) * dto.PageSize).Take(dto.PageSize).ToListAsync(); + return (list, total); + } + } +} diff --git a/src/BarCode.Web.Repositories/SecurityNumbersRepositories.cs b/src/BarCode.Web.Repositories/SecurityNumbersRepositories.cs new file mode 100644 index 0000000..d2c87d1 --- /dev/null +++ b/src/BarCode.Web.Repositories/SecurityNumbersRepositories.cs @@ -0,0 +1,315 @@ +using AutoMapper; +using BarCode.Web.Core.Dto.Erp; +using BarCode.Web.Core.Dto.Erp.Org; +using BarCode.Web.Core.Dto.Erp.Supplier; +using BarCode.Web.Core.Dto.Login; +using BarCode.Web.Core.Dto.SecurityNumbers; +using BarCode.Web.Core.Dto.SerialNumbers; +using BarCode.Web.Core.Help; +using BarCode.Web.Domain.Entitys; +using BarCode.Web.Domain.Infrastructure; +using BarCode.Web.Domain.IService.Public; +using BarCode.Web.Domain.Mappers; +using BarCode.Web.Domain.Services.Public; +using BarCode.Web.Domain.Values.Single; +using BarCode.Web.Repositories.Configuration; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Storage; +using System; +using System.Collections.Generic; +using System.ComponentModel.Design; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static Microsoft.EntityFrameworkCore.DbLoggerCategory; + +namespace BarCode.Web.Repositories +{ + public class SecurityNumbersRepositories : IAllFielRepositories, IAllFielRepositories, ISecurityNumbersRepositories + { + + private readonly ILoginRepositories _loginRepositories; + private readonly RepositoryDbContext _context; + private readonly IBasicsRepositories _basicsRepositories; + private readonly IMapper _mapper; + private readonly IErpService _erpService; + private readonly ISingleDataService _singleDataService; + private readonly IErpBasicDataExtendService _erpBasicDataExtendService; + + public SecurityNumbersRepositories(RepositoryDbContext context, + ILoginRepositories loginRepositories, + IBasicsRepositories basicsRepositories, IMapper mapper, IErpService erpService, + ISingleDataService singleDataService, IErpBasicDataExtendService erpBasicDataExtendService) + { + _context = context; + _basicsRepositories = basicsRepositories; + _loginRepositories = loginRepositories; + _mapper = mapper; + _erpService = erpService; + _singleDataService = singleDataService; + _erpBasicDataExtendService = erpBasicDataExtendService; + } + /// + /// 批量添加 + /// + /// + /// + /// + /// + public async Task AddRange(List entitys, bool isTransaction = true) + { + IDbContextTransaction _transaction = null; + if (isTransaction) + _transaction = _context.Database.BeginTransaction(); + + if (entitys != null && entitys.Count != 0) + { + await _context.SecurityNumbers.AddRangeAsync(entitys); + await _context.SaveChangesAsync(); + foreach (var item in entitys) + { + if (string.IsNullOrEmpty(item.SecurityNumber)) + { + //自动生成序列码 + item.GenerateSecurityNumber(); + //item.GenerateNumberCode(); + } + } + await _context.SaveChangesAsync(); + } + if (_transaction != null) + _transaction.Commit(); + return true; + } + /// + /// 批量修改 + /// + /// + /// + /// + /// + public async Task EditEntityList(List entitys, bool isTransaction = true) + { + IDbContextTransaction _transaction = null; + if (isTransaction) + _transaction = _context.Database.BeginTransaction(); + + List list = entitys.Select(s => s.Id).ToList(); + var res = await _context.SecurityNumbers + .Where(f => list.Contains(f.Id)).ToListAsync(); + + _mapper.ToMapLongList(entitys, res); + await _context.SaveChangesAsync(); + + if (_transaction != null) + _transaction.Commit(); + + return true; + } + /// + /// 获取集合 + /// + /// + /// + /// + public async Task> GetEntityList(List SecurityNumbers) + { + return await _context.SecurityNumbers.AsNoTracking() + .Where(f => SecurityNumbers.Contains(f.SecurityNumber)) + .ToListAsync(); + } + /// + /// 根据生成记录Id查询序列号 + /// + /// + /// + public async Task> GetEntityListByGRIds(List gRIds) + { + return await _context.SecurityNumbers.AsNoTracking() + .Where(f => gRIds.Contains(f.GenerateRecordId)) + .ToListAsync(); + } + /// + /// 根据生成记录Id查询序列号 + /// + /// + /// + public async Task> GetEntityListByGRId(int gRId) + { + return await _context.SecurityNumbers.AsNoTracking() + .Where(f => gRId == f.GenerateRecordId) + .ToListAsync(); + } + + /// + /// 列表 + /// + /// + /// + /// + public async Task<(List list, int total)> GetListAsync(SecurityNumberQueryRequest dto, LoginInDto loginInfo) + { + int companyId = loginInfo.UserInfo.CompanyId; + List mNumber = new List(); + var materials_result = await _erpService.BillQueryForMaterial(); + List materials = new List(); + if (materials_result.IsSuccess) + materials = materials_result.Data.ToList(); + + var query = _context.SecurityNumbers.AsNoTracking() + .GroupJoin(_context.SecurityNumberGenerateRecord, serial => serial.GenerateRecordId, sg => sg.Id, (serial, sg) => new { serial, sg }) + .SelectMany(x => x.sg.DefaultIfEmpty(), (p, sg) => new { p.serial, sg }) + .OrderByDescending(o => o.serial.Id) + .Where(f => dto.GenerateRecordId == f.serial.GenerateRecordId); + if (loginInfo.UserInfo.IsAdmin != true && !string.IsNullOrEmpty(dto.OrgCode)) + { + var rec_type = dto.OrgCode.Substring(0, 1); + var rec_code = dto.OrgCode.Substring(2, dto.OrgCode.Length - 2); + + if (rec_type.Equals("s"))//供应商 + query = query.Where(w => rec_code == w.serial.SupplierCode); + else//查其他单据(组织) + query = query.Where(w => rec_code == w.serial.OrgCode); + } + if (dto.IsDownLoad != null) + query = query.Where(w => dto.IsDownLoad == true ? w.serial.DownLoadNumber > 0 : w.serial.DownLoadNumber <= 0); + if (dto.SecurityNumbers != null && dto.SecurityNumbers.Count() > 0) + query = query.Where(w => dto.SecurityNumbers.Contains(w.serial.SecurityNumber)); + if (dto.IdBegin != null && dto.IdBegin != 0) + query = query.Where(w => w.serial.Id >= dto.IdBegin); + if (dto.IdEnd != null && dto.IdEnd != 0) + query = query.Where(w => w.serial.Id <= dto.IdEnd); + if (dto.DownLoadBeginDate != null) + query = query.Where(w => w.serial.DownLoadTime >= dto.DownLoadBeginDate); + if (dto.DownLoadEndDate != null) + { + DateTime dt_end = ((DateTime)dto.DownLoadEndDate).AddDays(1); + query = query.Where(w => w.serial.DownLoadTime <= dt_end); + } + + int total = await query.CountAsync(); + var list = await query.Select(s => new SecurityNumberInfoResponse() + { + Id = s.serial.Id, + GenerateRecordId = s.serial.GenerateRecordId, + SecurityNumber = s.serial.SecurityNumber, + Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, s.serial.MaterialNumber), + Number = s.sg == null ? 0 : s.sg.Number, + Creator = _singleDataService.GetSingleData(SingleAction.Users, companyId, s.serial.CreatorId), + CreateTime = s.serial.CreateTime.DateToStringSeconds(), + DownLoadNumber = s.serial.DownLoadNumber, + DownLoadTime = s.serial.DownLoadTime.DateToStringSeconds() + }).Skip((dto.PageNo - 1) * dto.PageSize).Take(dto.PageSize).ToListAsync(); + return (list, total); + } + + /// + /// 导出列表 + /// + /// + /// + /// + public async Task<(object obj, int total)> GetListField(SecurityNumbersExportRequest dto, LoginInDto loginInfo) + { + List mNumber = new List(); + var materials_result = await _erpService.BillQueryForMaterial(); + List materials = new List(); + if (materials_result.IsSuccess) + materials = materials_result.Data.ToList(); + + //供应商 + var supplier_result = await _erpService.BillQueryForSupplier(); + List suppliers = new List(); + if (supplier_result.IsSuccess) + suppliers = supplier_result.Data.ToList(); + //取组织 + var org_result = await _erpService.BillQueryForOrg(); + List orgs = new List(); + if (org_result.IsSuccess) + orgs = org_result.Data.ToList(); + + var query = _context.SecurityNumbers.AsNoTracking() + .GroupJoin(_context.SecurityNumberGenerateRecord, serial => serial.GenerateRecordId, sg => sg.Id, (serial, sg) => new { serial, sg }) + .SelectMany(x => x.sg.DefaultIfEmpty(), (p, sg) => new { p.serial, sg }) + .OrderByDescending(o => o.serial.Id) + .Where(f => dto.Ids.Contains(f.serial.GenerateRecordId)); + + int total = await query.CountAsync(); + var list = await query.Select(s => new SecurityNumbersExportReponse() + { + SecurityNumber = s.serial.SecurityNumber, + Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, s.serial.MaterialNumber), + Number = s.sg == null ? 0 : s.sg.Number, + DownLoadNumber = s.serial.DownLoadNumber, + DownLoadTime = s.serial.DownLoadTime.DateToStringSeconds() + }).Skip((dto.PageNo - 1) * dto.PageSize).Take(dto.PageSize).ToListAsync(); + return (list, total); + } + + /// + /// 条码列表导出 + /// + /// + /// + /// + public async Task<(object obj, int total)> GetListField(SecurityNumberQueryRequest dto, LoginInDto loginInfo) + { + return await GetListAsync(dto, loginInfo); + } + /// + /// 获取防伪码 + /// + /// + /// + /// + public async Task GetEntity(string securityNumbers) + { + var entity = await _context.SecurityNumbers.AsNoTracking() + .FirstOrDefaultAsync(f => f.SecurityNumber.Equals(securityNumbers)); + return entity; + } + /// + /// 修改防伪码 + /// + /// + /// + /// + public async Task Edit(SecurityNumbers entity, bool isTransaction = true) + { + IDbContextTransaction _transaction = null; + if (isTransaction) + _transaction = _context.Database.BeginTransaction(); + + var res = await _context.SecurityNumbers + .FirstOrDefaultAsync(f => f.Id == entity.Id); + if (res == null) return null; + + _mapper.Map(entity, res); + var result = await _context.SaveChangesAsync(); + + if (_transaction != null) + _transaction.Commit(); + + return res; + } + + public async Task DownLoad(List ids, bool isTransaction = true) + { + IDbContextTransaction _transaction = null; + if (isTransaction) + _transaction = _context.Database.BeginTransaction(); + + string dt = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); + foreach (var id in ids) + { + FormattableString fs = @$"update t_barcode_securitynumbers set DownLoadNumber=DownLoadNumber+1,DownLoadTime={dt} where GenerateRecordId = {id};"; + var result = _context.Database.ExecuteSqlInterpolated(fs); + } + + if (_transaction != null) + _transaction.Commit(); + + return true; + } + } +} diff --git a/src/BarCode.Web.Repositories/SerialNumbersRepositories.cs b/src/BarCode.Web.Repositories/SerialNumbersRepositories.cs new file mode 100644 index 0000000..2c5cc2d --- /dev/null +++ b/src/BarCode.Web.Repositories/SerialNumbersRepositories.cs @@ -0,0 +1,723 @@ +using AutoMapper; +using BarCode.Web.Core.Dto.Erp; +using BarCode.Web.Core.Dto.Erp.Org; +using BarCode.Web.Core.Dto.Erp.Supplier; +using BarCode.Web.Core.Dto.Login; +using BarCode.Web.Core.Dto.SerialNumbers; +using BarCode.Web.Core.Help; +using BarCode.Web.Domain.Entitys; +using BarCode.Web.Domain.Infrastructure; +using BarCode.Web.Domain.IService.Public; +using BarCode.Web.Domain.Mappers; +using BarCode.Web.Domain.Services.Public; +using BarCode.Web.Domain.Values.Single; +using BarCode.Web.Repositories.Configuration; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Storage; +using Microsoft.Extensions.Logging; +using Npoi.Mapper; +using NPOI.POIFS.FileSystem; +using Quartz.Logging; +using System; +using System.Collections.Generic; +using System.ComponentModel.Design; +using System.Diagnostics.Eventing.Reader; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static Microsoft.EntityFrameworkCore.DbLoggerCategory; + +namespace BarCode.Web.Repositories +{ + /// + /// 序列码 + /// + public class SerialNumbersRepositories : IAllFielRepositories, IAllFielRepositories, ISerialNumbersRepositories + { + private readonly ILoginRepositories _loginRepositories; + private readonly RepositoryDbContext _context; + private readonly IBasicsRepositories _basicsRepositories; + private readonly IMapper _mapper; + private readonly IErpService _erpService; + private readonly ISingleDataService _singleDataService; + private readonly IErpBasicDataExtendService _erpBasicDataExtendService; + + public SerialNumbersRepositories(RepositoryDbContext context, + ILoginRepositories loginRepositories, + IBasicsRepositories basicsRepositories, IMapper mapper, IErpService erpService, + ISingleDataService singleDataService, IErpBasicDataExtendService erpBasicDataExtendService) + { + _context = context; + _basicsRepositories = basicsRepositories; + _loginRepositories = loginRepositories; + _mapper = mapper; + _erpService = erpService; + _singleDataService = singleDataService; + _erpBasicDataExtendService = erpBasicDataExtendService; + } + /// + /// 批量添加 + /// + /// + /// + /// + /// + public async Task AddRange(List entitys, bool isTransaction = true) + { + IDbContextTransaction _transaction = null; + if (isTransaction) + _transaction = _context.Database.BeginTransaction(); + + if (entitys != null && entitys.Count != 0) + { + await _context.SerialNumbers.AddRangeAsync(entitys); + await _context.SaveChangesAsync(); + string newSuitNumber = ""; + string oldSuitNumber = ""; + foreach (var item in entitys) + { + //自动生成序列码 + string sn= item.GenerateSerialNumber();//alter by yzh + item.GenerateNumberCode(); + + + if(item.IsTwo>1)//大于1说明是套装 + { + if (item.thisNumber % item.IsTwo == 0) + { + newSuitNumber = oldSuitNumber; + } + else + { + oldSuitNumber = sn; + newSuitNumber = sn; + } + } + else + { + newSuitNumber = sn; + newSuitNumber = sn; + } + item.GenerateSuitNumber(newSuitNumber); + item.GenerateTwoSerialNumber(newSuitNumber); + } + foreach (var item in entitys) + { + + string s = GetTwoSerialNumber(entitys, item.SuitNumber); + item.GenerateTwoSerialNumber(s); + } + + await _context.SaveChangesAsync(); + + + } + if (_transaction != null) + _transaction.Commit(); + return true; + } + /// + /// 产生套装条码 + /// + /// + /// + public string GetTwoSerialNumber(List entitys, string SuitNumber) + { + string strReturn = ""; + foreach (var item in entitys) + { + + if (item.SuitNumber == SuitNumber) + { + if (strReturn == "") + { + strReturn = item.SerialNumber; + } + else + { + strReturn = strReturn + "," + item.SerialNumber; + } + + } + } + return strReturn; + } + /// + /// 批量修改 + /// + /// + /// + /// + /// + public async Task EditEntityList(List entitys, bool isTransaction = true) + { + IDbContextTransaction _transaction = null; + if (isTransaction) + _transaction = _context.Database.BeginTransaction(); + + List list = entitys.Select(s => s.Id).ToList(); + var res = await _context.SerialNumbers + .Where(f => list.Contains(f.Id)).ToListAsync(); + + _mapper.ToMapLongList(entitys, res); + await _context.SaveChangesAsync(); + + if (_transaction != null) + _transaction.Commit(); + + return true; + } + /// + /// 获取集合 + /// + /// + /// + /// + public async Task> GetEntityList(List serialNumbers) + { + return await _context.SerialNumbers.AsNoTracking() + .Where(f => serialNumbers.Contains(f.SerialNumber)) + .ToListAsync(); + } + /// + /// 根据生成记录Id查询序列号 + /// + /// + /// + public async Task> GetEntityListByGRIds(List gRIds) + { + return await _context.SerialNumbers.AsNoTracking() + .Where(f => gRIds.Contains(f.GenerateRecordId)) + .ToListAsync(); + } + /// + /// 根据生成记录Id查询序列号 + /// + /// + /// + public async Task> GetEntityListByGRId(int gRId) + { + return await _context.SerialNumbers.AsNoTracking() + .Where(f => gRId == f.GenerateRecordId) + .ToListAsync(); + } + + /// + /// 列表 + /// + /// + /// + /// + public async Task<(List list, int total)> GetListAsync(SerialNumberQueryRequest dto, LoginInDto loginInfo) + { + int companyId = loginInfo.UserInfo.CompanyId; + List mNumber = new List(); + var materials_result = await _erpService.BillQueryForMaterial(); + List materials = new List(); + if (materials_result.IsSuccess) + materials = materials_result.Data.ToList(); + + var query = _context.SerialNumbers.AsNoTracking() + .GroupJoin(_context.Box, serial => serial.BoxId, box => box.Id, (serial, box) => new { serial, box }) + .SelectMany(x => x.box.DefaultIfEmpty(), (p, box) => new { p.serial, box }) + .GroupJoin(_context.SerialNumberGenerateRecord, s => s.serial.GenerateRecordId, sg => sg.Id, (serial, sg) => new { serial.serial, serial.box, sg }) + .SelectMany(x => x.sg.DefaultIfEmpty(), (p, sg) => new { p.serial, p.box, sg }) + .OrderByDescending(o => o.serial.Id) + .Where(f => dto.GenerateRecordId == f.serial.GenerateRecordId); + if (loginInfo.UserInfo.IsAdmin != true && !string.IsNullOrEmpty(dto.OrgCode)) + { + var rec_type = dto.OrgCode.Substring(0, 1); + var rec_code = dto.OrgCode.Substring(2, dto.OrgCode.Length - 2); + + if (rec_type.Equals("s"))//供应商 + query = query.Where(w => rec_code == w.serial.SupplierCode); + else//查其他单据(组织) + query = query.Where(w => rec_code == w.serial.OrgCode); + } + if (dto.IsPrint != null) + query = query.Where(w => dto.IsPrint == true ? w.serial.PrintNumber > 0 : w.serial.PrintNumber <= 0); + if (dto.IsUse != null) + query = query.Where(w => w.serial.IsUse == dto.IsUse); + if (dto.SerialNumbers != null && dto.SerialNumbers.Count() > 0) + query = query.Where(w => dto.SerialNumbers.Contains(w.serial.SerialNumber)); + if (dto.NumberCodes != null && dto.NumberCodes.Count() > 0) + query = query.Where(w => dto.NumberCodes.Contains(w.serial.NumberCode)); + if (!string.IsNullOrEmpty(dto.BoxBillNo)) + query = query.Where(w => w.box.BoxBillNo.Equals(dto.BoxBillNo)); + if (dto.SerialNumberBegin != null && dto.SerialNumberBegin != 0) + { + if (dto.SerialNumberEnd != null && dto.SerialNumberEnd != 0) + query = query.Where(w => w.serial.Id >= dto.SerialNumberBegin); + else + query = query.Where(w => w.serial.Id == dto.SerialNumberBegin); + } + if (dto.SerialNumberEnd != null && dto.SerialNumberEnd != 0) + { + if (dto.SerialNumberBegin != null && dto.SerialNumberBegin != 0) + query = query.Where(w => w.serial.Id <= dto.SerialNumberEnd); + else + query = query.Where(w => w.serial.Id == dto.SerialNumberEnd); + } + //V01.05.00: 数字序列号区间查询 + if (!string.IsNullOrEmpty(dto.NumberCodeBegin)) + { + int number = Convert.ToInt32(dto.NumberCodeBegin.Substring(6, dto.NumberCodeBegin.Length - 6)); + if (!string.IsNullOrEmpty(dto.NumberCodeEnd)) + query = query.Where(w => w.serial.Number >= number); + else + query = query.Where(w => w.serial.Number == number); + } + if (!string.IsNullOrEmpty(dto.NumberCodeEnd)) + { + int number = Convert.ToInt32(dto.NumberCodeEnd.Substring(6, dto.NumberCodeEnd.Length - 6)); + if (!string.IsNullOrEmpty(dto.NumberCodeBegin)) + query = query.Where(w => w.serial.Number <= number); + else + query = query.Where(w => w.serial.Number == number); + } + + + if (dto.DownLoadBeginDate != null) + query = query.Where(w => w.serial.DownLoadTime >= dto.DownLoadBeginDate); + if (dto.DownLoadEndDate != null) + { + DateTime dt_end = ((DateTime)dto.DownLoadEndDate).AddDays(1); + query = query.Where(w => w.serial.DownLoadTime <= dt_end); + } + if (dto.PrintBeginDate != null) + query = query.Where(w => w.serial.PrintTime >= dto.PrintBeginDate); + if (dto.PrintEndDate != null) + { + DateTime dt_end = ((DateTime)dto.PrintEndDate).AddDays(1); + query = query.Where(w => w.serial.PrintTime <= dt_end); + } + if (dto.IsUpdateMaterial != null) + { + if (dto.IsUpdateMaterial == true) + query = query.Where(w => !string.IsNullOrEmpty(w.serial.Old_MaterialNumber)); + else + query = query.Where(w => string.IsNullOrEmpty(w.serial.Old_MaterialNumber)); + } + + + if(dto.isTwo>1)//是否为两件装,如果大于1说明为两件装 + { + query = query.Where(w => w.serial.IsTwo>1); + } + + + int total = await query.CountAsync(); + var list = await query.Select(s => new SerialNumberInfoResponse() + { + Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, s.serial.MaterialNumber), + Old_Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, s.serial.Old_MaterialNumber == null ? "" : s.serial.Old_MaterialNumber), + MaterialNumber = s.serial.MaterialNumber, + MaterialName = _erpBasicDataExtendService.GetMaterialName(materials, s.serial.MaterialNumber), + BarCode = _erpBasicDataExtendService.GetMaterialBarCode(materials, s.serial.MaterialNumber), + SerialNumber = s.serial.SerialNumber, + NumberCode = s.serial.NumberCode, + Number = s.sg == null ? 0 : s.sg.Number, + Id = s.serial.Id, + IsUse = s.serial.IsUse, + IsUseStr = s.serial.IsUse == true ? "是" : "否", + //序列码已经被使用 但没有箱号,那么就是被wms系统拉去使用了,不能再被打印 + IsEnablePrint = (s.serial.BoxId <= 0 && s.serial.IsUse == true) ? false : true, + Box = s.box == null ? "" : s.box.BoxBillNo, + Creator = _singleDataService.GetSingleData(SingleAction.Users, companyId, s.serial.CreatorId), + CreateTime = s.serial.CreateTime.DateToStringSeconds(), + PrintNumber = s.serial.PrintNumber, + DownLoadNumber = s.serial.DownLoadNumber, + DownLoadTime = s.serial.DownLoadTime.DateToStringSeconds(), + PrintTime = s.serial.PrintTime.DateToStringSeconds(), + IsTwo=s.serial.IsTwo, + TwoSerialNumber = s.serial.TwoSerialNumber.Replace(s.serial.SerialNumber,"").Replace(",","") + }).Skip((dto.PageNo - 1) * dto.PageSize).Take(dto.PageSize).ToListAsync(); + return (list, total); + } + + /// + /// 导出列表 + /// + /// + /// + /// + public async Task<(object obj, int total)> GetListField(SerialNumbersExportRequest dto, LoginInDto loginInfo) + { + List mNumber = new List(); + var materials_result = await _erpService.BillQueryForMaterial(); + List materials = new List(); + if (materials_result.IsSuccess) + materials = materials_result.Data.ToList(); + + //供应商 + var supplier_result = await _erpService.BillQueryForSupplier(); + List suppliers = new List(); + if (supplier_result.IsSuccess) + suppliers = supplier_result.Data.ToList(); + //取组织 + var org_result = await _erpService.BillQueryForOrg(); + List orgs = new List(); + if (org_result.IsSuccess) + orgs = org_result.Data.ToList(); + + var query = _context.SerialNumbers.AsNoTracking() + .GroupJoin(_context.SerialNumberGenerateRecord, serial => serial.GenerateRecordId, sg => sg.Id, (serial, sg) => new { serial, sg }) + .SelectMany(x => x.sg.DefaultIfEmpty(), (p, sg) => new { p.serial, sg }) + .OrderByDescending(o => o.serial.Id) + .Where(f => dto.Ids.Contains(f.serial.GenerateRecordId)); + + int total = await query.CountAsync(); + var list = await query.Select(s => new SerialNumbersExportReponse() + { + Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, s.serial.MaterialNumber), + MaterialNumber = s.serial.MaterialNumber, + MaterialName = _erpBasicDataExtendService.GetMaterialName(materials, s.serial.MaterialNumber), + BarCode = _erpBasicDataExtendService.GetMaterialBarCode(materials, s.serial.MaterialNumber), + SerialNumber = s.serial.SerialNumber, + NumberCode = s.serial.NumberCode, + Number = s.sg == null ? 0 : s.sg.Number, + SupplierOrOrg = string.IsNullOrEmpty(s.sg.SupplierCode) ? _erpBasicDataExtendService.GetOrgName(orgs, s.sg.OrgCode) + : _erpBasicDataExtendService.GetSupplierName(suppliers, s.sg.SupplierCode) + }).Skip((dto.PageNo - 1) * dto.PageSize).Take(dto.PageSize).ToListAsync(); + return (list, total); + } + /// + /// 根据箱Id来搜索序列号 + /// + /// + /// + /// + public async Task<(List list, int total)> GetEntityListByBoxId(SerialNumberByBoxIdQueryRequest dto) + { + var materials_result = await _erpService.BillQueryForMaterial(); + List materials = new List(); + if (materials_result.IsSuccess) + materials = materials_result.Data.ToList(); + + var query = _context.SerialNumbers.AsNoTracking() + .OrderByDescending(o => o.CompleteCartonTime)//以装箱时间先后排序 + .Where(f => f.BoxId == dto.BoxId); + + int total = await query.CountAsync(); + var list = await query.Select(s => new SerialNumbersResponse() + { + BoxId = s.BoxId, + IsCarton = (s.BoxId > 0 || s.IsUse == true) ? true : false, + IsOldData = true,//扫箱号获取 默认就是老数据 + Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, s.MaterialNumber), + MaterialNumber = s.MaterialNumber, + MaterialName = _erpBasicDataExtendService.GetMaterialName(materials, s.MaterialNumber), + BarCode = _erpBasicDataExtendService.GetMaterialBarCode(materials, s.MaterialNumber), + SerialNumber = s.SerialNumber, + IsUseNumber = s.IsUseNumber, + NumberCode = s.NumberCode, + TwoSerialNumber=s.TwoSerialNumber.Replace(s.SerialNumber,"").Replace(",","") + }).Skip((dto.PageNo - 1) * dto.PageSize).Take(dto.PageSize).ToListAsync(); + return (list, total); + } + + public async Task?> GetEntityList(string serialNumber, string orgCode, LoginInDto loginInfo) + { + var materials_result = await _erpService.BillQueryForMaterial(); + List materials = new List(); + if (materials_result.IsSuccess) + materials = materials_result.Data.ToList(); + + var query = _context.SerialNumbers.AsNoTracking().Where(w => 1 == 1); + + //if (loginInfo.UserInfo.IsAdmin != true && !string.IsNullOrEmpty(orgCode)) + //{ + // var rec_type = orgCode.Substring(0, 1); + // var rec_code = orgCode.Substring(2, orgCode.Length - 2); + + // if (rec_type.Equals("s"))//供应商 + // query = query.Where(w => rec_code == w.SupplierCode); + // else//查其他单据(组织) + // query = query.Where(w => rec_code == w.OrgCode); + //} + + + query = query.Where(f => f.SerialNumber.Equals(serialNumber) + || f.NumberCode.Equals(serialNumber)); + + var entity = await query.FirstOrDefaultAsync(); + if (entity == null) return null; + + ////如果为单套产品,那就直接取就行了。 + if (entity.IsTwo < 2) + { + List list = new List(); + SerialNumbersResponse s=new SerialNumbersResponse(); + s.BoxId = entity.BoxId; + s.IsCarton = (entity.BoxId > 0 || entity.IsUse == true) ? true : false; + s.IsOldData = false;//根据序列号获取 默认是false + s.Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, entity.MaterialNumber); + s.MaterialNumber = entity.MaterialNumber; + s.MaterialName = _erpBasicDataExtendService.GetMaterialName(materials, entity.MaterialNumber); + s.BarCode = _erpBasicDataExtendService.GetMaterialBarCode(materials, entity.MaterialNumber); + s.SerialNumber = entity.SerialNumber; + s.IsUseNumber = entity.IsUseNumber; + s.NumberCode = entity.NumberCode; + s.IsTwo = entity.IsTwo; + s.SuitNumber = entity.SuitNumber; + list.Add(s); + return list; + + //return new SerialNumbersResponse() + //{ + // BoxId = entity.BoxId, + // IsCarton = (entity.BoxId > 0 || entity.IsUse == true) ? true : false, + // IsOldData = false,//根据序列号获取 默认是false + // Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, entity.MaterialNumber), + // MaterialNumber = entity.MaterialNumber, + // MaterialName = _erpBasicDataExtendService.GetMaterialName(materials, entity.MaterialNumber), + // BarCode = _erpBasicDataExtendService.GetMaterialBarCode(materials, entity.MaterialNumber), + // SerialNumber = entity.SerialNumber, + // IsUseNumber = entity.IsUseNumber, + // NumberCode = entity.NumberCode, + // IsTwo = entity.IsTwo, + // SuitNumber = entity.SuitNumber + //}; + } + else//跟据套装去查对应的 + { + string suitNumber = entity.SuitNumber; + + + + var query2 = _context.SerialNumbers.AsNoTracking() + //.OrderByDescending(o => o.CompleteCartonTime)//以装箱时间先后排序 + .Where(f => f.SuitNumber == suitNumber); + + int total = await query.CountAsync(); + var list = await query2.Select(s => new SerialNumbersResponse() + { + BoxId = s.BoxId, + IsCarton = (s.BoxId > 0 || s.IsUse == true) ? true : false, + IsOldData = false,//扫箱号获取 默认就是老数据 + Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, s.MaterialNumber), + MaterialNumber = s.MaterialNumber, + MaterialName = _erpBasicDataExtendService.GetMaterialName(materials, s.MaterialNumber), + BarCode = _erpBasicDataExtendService.GetMaterialBarCode(materials, s.MaterialNumber), + SerialNumber = s.SerialNumber, + IsUseNumber = s.IsUseNumber, + NumberCode = s.NumberCode, + IsTwo = s.IsTwo, + SuitNumber = s.SuitNumber + }).ToListAsync(); + + + return list; + + + // //var query2 = _context.SerialNumbers.AsNoTracking().Where(w => 1 == 1); + // //query2 = query2.Where(f => f.SuitNumber.Equals(suitNumber) + // //); + // //var entity2 = await query2.FirstOrDefaultAsync(); + // //if (entity2 == null) return null; + + // //return new SerialNumbersResponse() + // //{ + // // BoxId = entity2.BoxId, + // // IsCarton = (entity2.BoxId > 0 || entity2.IsUse == true) ? true : false, + // // IsOldData = false,//根据序列号获取 默认是false + // // Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, entity2.MaterialNumber), + // // MaterialNumber = entity2.MaterialNumber, + // // MaterialName = _erpBasicDataExtendService.GetMaterialName(materials, entity2.MaterialNumber), + // // BarCode = _erpBasicDataExtendService.GetMaterialBarCode(materials, entity2.MaterialNumber), + // // SerialNumber = entity2.SerialNumber, + // // IsUseNumber = entity2.IsUseNumber, + // // NumberCode = entity2.NumberCode, + // // IsTwo = entity2.IsTwo, + // // SuitNumber = entity2.SuitNumber + // //}; + + + } + } + + public async Task GetEntity(string serialNumber, string orgCode, LoginInDto loginInfo) + { + var materials_result = await _erpService.BillQueryForMaterial(); + List materials = new List(); + if (materials_result.IsSuccess) + materials = materials_result.Data.ToList(); + + var query = _context.SerialNumbers.AsNoTracking().Where(w => 1 == 1); + + //if (loginInfo.UserInfo.IsAdmin != true && !string.IsNullOrEmpty(orgCode)) + //{ + // var rec_type = orgCode.Substring(0, 1); + // var rec_code = orgCode.Substring(2, orgCode.Length - 2); + + // if (rec_type.Equals("s"))//供应商 + // query = query.Where(w => rec_code == w.SupplierCode); + // else//查其他单据(组织) + // query = query.Where(w => rec_code == w.OrgCode); + //} + + + query = query.Where(f => f.SerialNumber.Equals(serialNumber) + || f.NumberCode.Equals(serialNumber)); + + var entity = await query.FirstOrDefaultAsync(); + if (entity == null) return null; + + ////如果为单套产品,那就直接取就行了。 + //if (entity.IsTwo < 2) + //{ + return new SerialNumbersResponse() + { + BoxId = entity.BoxId, + IsCarton = (entity.BoxId > 0 || entity.IsUse == true) ? true : false, + IsOldData = false,//根据序列号获取 默认是false + Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, entity.MaterialNumber), + MaterialNumber = entity.MaterialNumber, + MaterialName = _erpBasicDataExtendService.GetMaterialName(materials, entity.MaterialNumber), + BarCode = _erpBasicDataExtendService.GetMaterialBarCode(materials, entity.MaterialNumber), + SerialNumber = entity.SerialNumber, + IsUseNumber = entity.IsUseNumber, + NumberCode = entity.NumberCode, + IsTwo = entity.IsTwo, + SuitNumber = entity.SuitNumber, + TwoSerialNumber= entity.TwoSerialNumber.Replace(entity.SerialNumber,"").Replace(",","") + }; + //} + // else//跟据套装去查对应的 + // { + // string suitNumber=entity.SuitNumber; + + + + // var query2 = _context.SerialNumbers.AsNoTracking() + // //.OrderByDescending(o => o.CompleteCartonTime)//以装箱时间先后排序 + //.Where(f => f.SuitNumber == suitNumber); + + // int total = await query.CountAsync(); + // var list = await query2.Select(s => new SerialNumbersResponse() + // { + // BoxId = s.BoxId, + // IsCarton = (s.BoxId > 0 || s.IsUse == true) ? true : false, + // IsOldData = false,//扫箱号获取 默认就是老数据 + // Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, s.MaterialNumber), + // MaterialNumber = s.MaterialNumber, + // MaterialName = _erpBasicDataExtendService.GetMaterialName(materials, s.MaterialNumber), + // BarCode = _erpBasicDataExtendService.GetMaterialBarCode(materials, s.MaterialNumber), + // SerialNumber = s.SerialNumber, + // IsUseNumber = s.IsUseNumber, + // NumberCode = s.NumberCode + // }).ToListAsync(); + + + + + + // //var query2 = _context.SerialNumbers.AsNoTracking().Where(w => 1 == 1); + // //query2 = query2.Where(f => f.SuitNumber.Equals(suitNumber) + // //); + // //var entity2 = await query2.FirstOrDefaultAsync(); + // //if (entity2 == null) return null; + + // //return new SerialNumbersResponse() + // //{ + // // BoxId = entity2.BoxId, + // // IsCarton = (entity2.BoxId > 0 || entity2.IsUse == true) ? true : false, + // // IsOldData = false,//根据序列号获取 默认是false + // // Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, entity2.MaterialNumber), + // // MaterialNumber = entity2.MaterialNumber, + // // MaterialName = _erpBasicDataExtendService.GetMaterialName(materials, entity2.MaterialNumber), + // // BarCode = _erpBasicDataExtendService.GetMaterialBarCode(materials, entity2.MaterialNumber), + // // SerialNumber = entity2.SerialNumber, + // // IsUseNumber = entity2.IsUseNumber, + // // NumberCode = entity2.NumberCode, + // // IsTwo = entity2.IsTwo, + // // SuitNumber = entity2.SuitNumber + // //}; + + + // } + } + /// + /// 条码列表导出 + /// + /// + /// + /// + public async Task<(object obj, int total)> GetListField(SerialNumberQueryRequest dto, LoginInDto loginInfo) + { + return await GetListAsync(dto, loginInfo); + } + /// + /// 根据箱Id获取序列码 + /// + /// + /// + public async Task> GetEntityListByBoxIds(List boxIds) + { + return await _context.SerialNumbers.AsNoTracking() + .Where(f => boxIds.Contains(f.BoxId)) + .ToListAsync(); + } + + /// + /// 根据套装码获取序列码 + /// + /// + /// + public async Task> GetEntityListBySuitNumber(string suitNumber) + { + return await _context.SerialNumbers.AsNoTracking() + .Where(f => f.TwoSerialNumber.Contains(suitNumber)) + .ToListAsync(); + } + + /// + /// wms系统查询序列码 支持数字序列码 + /// + /// + /// + public async Task GetEntityWms(string serialNumbers) + { + var entity = await _context.SerialNumbers.AsNoTracking() + .FirstOrDefaultAsync(f => serialNumbers.Equals(f.SerialNumber) || serialNumbers.Equals(f.NumberCode)); + return entity; + } + + public async Task> GetEntityListContainNumber(List serialNumbers) + { + return await _context.SerialNumbers.AsNoTracking() + // .Where(f => serialNumbers.Contains(f.SerialNumber) || serialNumbers.Contains(f.NumberCode) || serialNumbers.Contains(f.TwoSerialNumber))//alter by yzh + .Where(f => serialNumbers.Contains(f.SerialNumber) || serialNumbers.Contains(f.NumberCode)) + .ToListAsync(); + } + + public async Task GetExternal(string serialNumber) + { + List mNumber = new List(); + var materials_result = await _erpService.BillQueryForMaterial(); + List materials = new List(); + if (materials_result.IsSuccess) + materials = materials_result.Data.ToList(); + + var query = _context.SerialNumbers.AsNoTracking() + .GroupJoin(_context.SerialNumberGenerateRecord, serial => serial.GenerateRecordId, sg => sg.Id, (serial, sg) => new { serial, sg }) + .SelectMany(x => x.sg.DefaultIfEmpty(), (p, sg) => new { p.serial, sg }) + .OrderByDescending(o => o.serial.Id) + .Where(f => serialNumber.Equals(f.serial.SerialNumber) || serialNumber.Equals(f.serial.NumberCode)); + + var res = await query.Select(s => new SerialNumbersExternalResponse() + { + Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, s.serial.MaterialNumber), + MaterialNumber = s.serial.MaterialNumber, + MaterialName = _erpBasicDataExtendService.GetMaterialName(materials, s.serial.MaterialNumber), + CreateTime = s.serial.CreateTime.DateToStringSeconds(), + PurchaseBillNo = s.sg.PurchaseBillNo, + SerialNumber = serialNumber, + Supplier = _singleDataService.GetSingleData(SingleAction.Suppliers, s.sg.CompanyId, s.serial.SupplierCode) + }).FirstOrDefaultAsync(); + + return res; + + } + } +} diff --git a/src/BarCode.Web.Repositories/TransactionRepositories.cs b/src/BarCode.Web.Repositories/TransactionRepositories.cs new file mode 100644 index 0000000..1b003a3 --- /dev/null +++ b/src/BarCode.Web.Repositories/TransactionRepositories.cs @@ -0,0 +1,47 @@ +using Microsoft.EntityFrameworkCore.Storage; +using System; +using System.Collections.Generic; +using System.Text; +using BarCode.Web.Domain.Infrastructure; +using BarCode.Web.Repositories.Configuration; + +namespace BarCode.Web.Repositories +{ + public class TransactionRepositories: ITransactionRepositories + { + private RepositoryDbContext _context; + + + public TransactionRepositories(RepositoryDbContext context) + { + _context = context; + } + public IDbContextTransaction GetTransaction() + { + return _context.Database.BeginTransaction(); + } + + public bool CommitTransaction(bool isRollback, IDbContextTransaction transaction) + { + try + { + if (transaction == null) + return true; + + if (isRollback) + { + transaction.Rollback(); + return false; + } + transaction.Commit(); + } + catch (Exception ex) + { + transaction.Rollback(); + return false; + } + return true; + } + + } +}