!提交代码
This commit is contained in:
261
.gitignore
vendored
Normal file
261
.gitignore
vendored
Normal file
@ -0,0 +1,261 @@
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
|
||||
# User-specific files
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
|
||||
# Visual Studio 2015 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUNIT
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# DNX
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_i.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*.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
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# JustCode is a .NET coding add-in
|
||||
.JustCode
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# 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
|
||||
# TODO: 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
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/packages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/packages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/packages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignoreable 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
|
||||
|
||||
# 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
|
||||
node_modules/
|
||||
orleans.codegen.cs
|
||||
|
||||
# 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
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# 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/
|
||||
|
||||
# JetBrains Rider
|
||||
.idea/
|
||||
*.sln.iml
|
||||
|
||||
# CodeRush
|
||||
.cr/
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
105
WCS.BLL/Config/LocalFile.cs
Normal file
105
WCS.BLL/Config/LocalFile.cs
Normal file
@ -0,0 +1,105 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WCS.BLL.Config
|
||||
{
|
||||
/// <summary>
|
||||
/// 本地文件
|
||||
/// </summary>
|
||||
public class LocalFile
|
||||
{
|
||||
/// <summary>
|
||||
/// 程序运行名称(BaseUi.exe)
|
||||
/// </summary>
|
||||
public static readonly string AppName = AppDomain.CurrentDomain.FriendlyName;
|
||||
/// <summary>
|
||||
/// 程序运行目录
|
||||
/// </summary>
|
||||
public static readonly string AppDir = AppDomain.CurrentDomain.BaseDirectory;
|
||||
/// <summary>
|
||||
/// 数据目录
|
||||
/// </summary>
|
||||
public static readonly string DataDir = Path.Combine(AppDir, "data");
|
||||
/// <summary>
|
||||
/// 日志目录
|
||||
/// </summary>
|
||||
public static readonly string LogDir = Path.Combine(AppDir, "logs");
|
||||
/// <summary>
|
||||
/// 运行主程序
|
||||
/// </summary>
|
||||
public static readonly string AppPath = Path.Combine(AppDir, AppDomain.CurrentDomain.FriendlyName);
|
||||
/// <summary>
|
||||
/// 配置文件路径
|
||||
/// </summary>
|
||||
public static readonly string ConfigPath = Path.Combine(DataDir, "jsconfig.json");
|
||||
/// <summary>
|
||||
/// 货架模组编码正则表达式
|
||||
/// </summary>
|
||||
public static readonly string ModuleCodePattern = "^[ABCD][0-9]{2}-R[0-9]{1,2}C[0-9]{1,2}$";
|
||||
|
||||
static object lockConfig = new object();
|
||||
|
||||
//static JsConfig config;
|
||||
///// <summary>
|
||||
///// 配置信息
|
||||
///// </summary>
|
||||
//public static JsConfig Config
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// if (config != null)
|
||||
// return config;
|
||||
// else
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// if (File.Exists(ConfigPath))
|
||||
// lock (lockConfig)
|
||||
// config = JsonConvert.DeserializeObject<JsConfig>(File.ReadAllText(ConfigPath, Encoding.UTF8));
|
||||
// else
|
||||
// config = null;
|
||||
// }
|
||||
// catch (Exception)
|
||||
// {
|
||||
// config = null;
|
||||
// }
|
||||
// }
|
||||
// return config ?? new JsConfig();
|
||||
// }
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// 刷新配置信息。将本地的配置信息重新加载到内存中
|
||||
///// </summary>
|
||||
//public static void UpdateConfig()
|
||||
//{
|
||||
// if (File.Exists(ConfigPath))
|
||||
// lock (lockConfig)
|
||||
// config = JsonConvert.DeserializeObject<JsConfig>(File.ReadAllText(ConfigPath, Encoding.UTF8));
|
||||
// else
|
||||
// config = null;
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// 保存配置信息。将内存中的配置信息保存到本地
|
||||
///// </summary>
|
||||
//public static void SaveConfig()
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// lock (lockConfig)
|
||||
// File.WriteAllText(ConfigPath, JsonConvert.SerializeObject(Config, Formatting.Indented), Encoding.UTF8);
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// UpdateConfig();
|
||||
// throw ex;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
117
WCS.BLL/DbModels/InventoryDetail.cs
Normal file
117
WCS.BLL/DbModels/InventoryDetail.cs
Normal file
@ -0,0 +1,117 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WCS.DAL.DbModels;
|
||||
|
||||
namespace WCS.BLL.DbModels
|
||||
{
|
||||
/// <summary>
|
||||
/// 库存明细表
|
||||
/// </summary>
|
||||
[SugarTable("inventory_detail")]
|
||||
public class InventoryDetail
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键 自增Id
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsNullable = false, IsIdentity = true)]
|
||||
public int Id { get; set; }
|
||||
|
||||
#region 库位属性
|
||||
/// <summary>
|
||||
/// 入库的库位表ID
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "store_id", IsNullable = false, ColumnDescription = "库位ID")]
|
||||
public int StoreId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 入库的库位编码
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "store_code", Length = 50, IsNullable = false, ColumnDescription = "库位编码")]
|
||||
public string StoreCode { get; set; }
|
||||
|
||||
[Navigate(NavigateType.OneToOne, nameof(StoreId))]
|
||||
public StoreInfo StoreInfo { get; set; }
|
||||
#endregion
|
||||
|
||||
#region 物料属性
|
||||
/// <summary>
|
||||
/// 物料编码(SN)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "mat_sn", Length = 200, IsNullable = false, ColumnDescription = "物料SN")]
|
||||
public string MatSN { get; set; }
|
||||
/// <summary>
|
||||
/// 物料编码
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "mat_code", Length = 100, IsNullable = true, ColumnDescription = "物料编号")]
|
||||
public string MatCode { get; set; }
|
||||
/// <summary>
|
||||
/// 物料名称
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "mat_name", Length = 150, IsNullable = true, ColumnDescription = "物料名称")]
|
||||
public string MatName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料规格
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "mat_spec", Length = 150, IsNullable = true, ColumnDescription = "物料规格")]
|
||||
public string MatSpec { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料批次
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "mat_batch", Length = 150, IsNullable = true, ColumnDescription = "物料批次")]
|
||||
public string MatBatch { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料数量
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "mat_qty", IsNullable = false, ColumnDescription = "物料数量")]
|
||||
public int MatQty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料供应商
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "mat_supplier", Length = 150, IsNullable = true, ColumnDescription = "物料供应商")]
|
||||
public string? MatSupplier { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料客户
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "mat_customer", Length = 150, IsNullable = true, ColumnDescription = "物料客户")]
|
||||
public string? MatCustomer { get; set; }
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 入库时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "instore_time", IsNullable = false, ColumnDescription = "入库时间")]
|
||||
public DateTime InstoreTime { get; set; } = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// 入库操作人
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "instore_user", Length = 100, IsNullable = true, ColumnDescription = "操作员")]
|
||||
public string InstoreUser { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料是否已被锁定
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "is_locked", IsNullable = false, ColumnDescription = "物料是否已被锁定")]
|
||||
public bool IsLocked { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 序号
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public int RowNumber { get; set; }
|
||||
/// <summary>
|
||||
/// 是否已经选择
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public bool IsSelected { get; set; }
|
||||
}
|
||||
}
|
121
WCS.BLL/DbModels/MatBaseInfo.cs
Normal file
121
WCS.BLL/DbModels/MatBaseInfo.cs
Normal file
@ -0,0 +1,121 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WCS.BLL.DbModels
|
||||
{
|
||||
///<summary>
|
||||
///物料基础信息
|
||||
///</summary>
|
||||
[SugarTable("mat_base_info")]
|
||||
public partial class MatBaseInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Desc:
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsNullable = false, IsIdentity = true)]
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料编码
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "mat_code", Length = 100, IsNullable = false, ColumnDescription = "物料编号")]
|
||||
public string MatCode { get; set; }
|
||||
/// <summary>
|
||||
/// 物料名称
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "mat_name", Length = 150, IsNullable = false, ColumnDescription = "物料名称")]
|
||||
public string MatName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料规格
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "mat_spec", Length = 150, IsNullable = true, ColumnDescription = "物料规格")]
|
||||
public string? MatSpec { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:物料单位
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "mat_unit", Length = 100, IsNullable = true, ColumnDescription = "物料单位")]
|
||||
public string? MatUnit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料批次
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "mat_batch", Length = 150, IsNullable = true, ColumnDescription = "物料批次")]
|
||||
public string? MatBatch { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料供应商
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "mat_supplier", Length = 150, IsNullable = true, ColumnDescription = "物料供应商")]
|
||||
public string? MatSupplier { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料客户
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "mat_customer", Length = 150, IsNullable = true, ColumnDescription = "物料客户")]
|
||||
public string? MatCustomer { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料数量
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "mat_qty", IsNullable = false, ColumnDescription = "物料数量")]
|
||||
public int MatQty { get; set; } = 100;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Desc:更新人
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "modify_user", IsNullable = true, Length = 50, ColumnDescription = "更新人")]
|
||||
public string? ModifyUser { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:更新时间
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "modify_time", IsNullable = true, ColumnDescription = "更新时间")]
|
||||
public DateTime? ModifyTime { get; set; } = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "is_enable", ColumnDescription = "是否启用")]
|
||||
public bool IsEnable { get; set; } = true;
|
||||
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public string IsEnableStr
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsEnable)
|
||||
return "启用";
|
||||
else
|
||||
return "禁用";
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 用于绑定DataGrid中是否选择
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public bool IsSelected { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 用于绑定中显示序号
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public int RowNumber { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
94
WCS.BLL/DbModels/MatInfo.cs
Normal file
94
WCS.BLL/DbModels/MatInfo.cs
Normal file
@ -0,0 +1,94 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WCS.BLL.DbModels
|
||||
{
|
||||
///<summary>
|
||||
///物料信息表
|
||||
///</summary>
|
||||
[SugarTable("mat_info")]
|
||||
public class MatInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键 Id 自增
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsNullable = false, IsIdentity = true)]
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料编码
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "mat_Sn", Length = 200, IsNullable = false, ColumnDescription = "物料唯一码")]
|
||||
public string MatSn { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料编码
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "mat_code", Length = 100, IsNullable = false, ColumnDescription = "物料编号")]
|
||||
public string MatCode { get; set; }
|
||||
/// <summary>
|
||||
/// 物料名称
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "mat_name", Length = 150, IsNullable = false, ColumnDescription = "物料名称")]
|
||||
public string MatName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料规格
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "mat_spec", Length = 150, IsNullable = true, ColumnDescription = "物料规格")]
|
||||
public string? MatSpec { get; set; }
|
||||
|
||||
|
||||
[SugarColumn(ColumnName = "mat_unit", Length = 100, IsNullable = true, ColumnDescription = "物料单位")]
|
||||
public string? MatUnit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料批次
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "mat_batch", Length = 150, IsNullable = true, ColumnDescription = "物料批次")]
|
||||
public string? MatBatch { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料供应商
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "mat_supplier", Length = 150, IsNullable = true, ColumnDescription = "物料供应商")]
|
||||
public string? MatSupplier { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料客户
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "mat_customer", Length = 150, IsNullable = true, ColumnDescription = "物料客户")]
|
||||
public string? MatCustomer { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料数量
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "mat_qty", IsNullable = false, ColumnDescription = "物料数量")]
|
||||
public int MatQty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "is_printed", ColumnDescription = "是否已打印")]
|
||||
public bool IsPrinted { get; set; } = true;
|
||||
/// <summary>
|
||||
/// Desc:更新人
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "modify_user", IsNullable = true, Length = 50, ColumnDescription = "更新人")]
|
||||
public string? ModifyUser { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:更新时间
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "modify_time", IsNullable = true, ColumnDescription = "更新时间")]
|
||||
public DateTime? ModifyTime { get; set; } = DateTime.Now;
|
||||
}
|
||||
}
|
71
WCS.BLL/DbModels/ModuleInfo.cs
Normal file
71
WCS.BLL/DbModels/ModuleInfo.cs
Normal file
@ -0,0 +1,71 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WCS.BLL.HardWare;
|
||||
|
||||
namespace WCS.DAL.DbModels
|
||||
{
|
||||
public partial class ModuleInfo
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 模组Id
|
||||
/// </summary>
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 模组编码
|
||||
/// </summary>
|
||||
public string ModuleCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架Id
|
||||
/// </summary>
|
||||
public int ShelfId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架编码
|
||||
/// </summary>
|
||||
public string ShelfCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 板子的Id
|
||||
/// </summary>
|
||||
public int BoardId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 板子上有几个灯
|
||||
/// </summary>
|
||||
public int LightCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 板子所连接模块的Ip
|
||||
/// </summary>
|
||||
public string CleintIp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 第几行
|
||||
/// </summary>
|
||||
public string R { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 第几列
|
||||
/// </summary>
|
||||
public string C { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 串联后大货架编码;大货架编码:未串联时是与货架编码是一对一的关系;串联后与货架编码是一对多
|
||||
/// </summary>
|
||||
public string Bigshelfcode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否被禁用
|
||||
/// </summary>
|
||||
public bool IsEnable { get; set; }
|
||||
|
||||
|
||||
public Mode CurentMode { get; set; } = Mode.待机模式;
|
||||
}
|
||||
}
|
61
WCS.BLL/DbModels/OutOrder.cs
Normal file
61
WCS.BLL/DbModels/OutOrder.cs
Normal file
@ -0,0 +1,61 @@
|
||||
using SqlSugar;
|
||||
|
||||
namespace WCS.BLL.DbModels
|
||||
{
|
||||
/// <summary>
|
||||
/// 出库单据
|
||||
/// </summary>
|
||||
[SugarTable("out_order")]
|
||||
public class OutOrder
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键 自增Id
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsNullable = false, IsIdentity = true)]
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 出库单据号
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "order_number", Length = 50, IsNullable = false, ColumnDescription = "出库单据号")]
|
||||
public string OrderNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单据状态
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "order_status", IsNullable = false, ColumnDescription = "单据状态")]
|
||||
public OutOrderStatus OrderStatus { get; set; } = OutOrderStatus.未出库;
|
||||
|
||||
/// <summary>
|
||||
/// 单据来源
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "order_source", Length = 50, IsNullable = true, ColumnDescription = "单据来源")]
|
||||
public string OrderSource { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单据类型
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "order_type", Length = 50, IsNullable = true, ColumnDescription = "单据类型")]
|
||||
public string OrderType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "create_time", IsNullable = false, ColumnDescription = "入库时间")]
|
||||
public DateTime CreateTime { get; set; } = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// 创建人
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "create_user", Length = 100, IsNullable = true, ColumnDescription = "操作员")]
|
||||
public string CreateUser { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public enum OutOrderStatus
|
||||
{
|
||||
未出库 = 0,
|
||||
部分出库 = 1,
|
||||
全部出库 = 2
|
||||
}
|
||||
}
|
60
WCS.BLL/DbModels/OutOrderDetail.cs
Normal file
60
WCS.BLL/DbModels/OutOrderDetail.cs
Normal file
@ -0,0 +1,60 @@
|
||||
using SqlSugar;
|
||||
|
||||
|
||||
namespace WCS.BLL.DbModels
|
||||
{
|
||||
/// <summary>
|
||||
/// 出库单据明细表
|
||||
/// </summary>
|
||||
[SugarTable("out_order_detail")]
|
||||
public class OutOrderDetail
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键 自增Id
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsNullable = false, IsIdentity = true)]
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 出库单据的主键ID
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "order_id", IsNullable = false)]
|
||||
public int OrderId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 出库单据号
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "order_number", Length = 50, IsNullable = false, ColumnDescription = "出库单据号")]
|
||||
public string OrderNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料编码
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "mat_code", Length = 100, IsNullable = true, ColumnDescription = "物料编号")]
|
||||
public string MatCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料批次
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "mat_batch", Length = 150, IsNullable = true, ColumnDescription = "物料批次")]
|
||||
public string MatBatch { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料需求数量
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "req_qty", IsNullable = false, ColumnDescription = "物料需求数量")]
|
||||
public int ReqQty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "create_time", IsNullable = false, ColumnDescription = "入库时间")]
|
||||
public DateTime CreateTime { get; set; } = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// 创建人
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "create_user", Length = 100, IsNullable = true, ColumnDescription = "操作员")]
|
||||
public string CreateUser { get; set; }
|
||||
}
|
||||
}
|
130
WCS.BLL/DbModels/OutOrderMatDetail.cs
Normal file
130
WCS.BLL/DbModels/OutOrderMatDetail.cs
Normal file
@ -0,0 +1,130 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WCS.DAL.DbModels;
|
||||
|
||||
namespace WCS.BLL.DbModels
|
||||
{
|
||||
/// <summary>
|
||||
/// 出库物料明细(库存数据加锁后缓存对应的数据并记录状态)
|
||||
/// </summary>
|
||||
[SugarTable("out_order_mat_detail")]
|
||||
public class OutOrderMatDetail
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键 自增Id
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsNullable = false, IsIdentity = true)]
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 出库单据的主键ID
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "order_id", IsNullable = false)]
|
||||
public int OrderId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 出库单据号
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "order_number", Length = 50, IsNullable = false, ColumnDescription = "出库单据号")]
|
||||
public string OrderNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 出库单据明细的ID
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "out_order_detail_id", IsNullable = true)]
|
||||
public int OutOrderDetailId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 库存的ID
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "inventory_detail_id", IsNullable = true)]
|
||||
public int InventoryDetailId { get; set; }
|
||||
|
||||
#region 库位属性
|
||||
/// <summary>
|
||||
/// 入库的库位表ID
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "store_id", IsNullable = false, ColumnDescription = "库位ID")]
|
||||
public int StoreId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 入库的库位编码
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "store_code", Length = 50, IsNullable = false, ColumnDescription = "库位编码")]
|
||||
public string StoreCode { get; set; }
|
||||
|
||||
[Navigate(NavigateType.OneToOne, nameof(StoreId))]
|
||||
public StoreInfo StoreInfo { get; set; }
|
||||
#endregion
|
||||
|
||||
#region 物料属性
|
||||
/// <summary>
|
||||
/// 物料编码(SN)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "mat_sn", Length = 200, IsNullable = false, ColumnDescription = "物料SN")]
|
||||
public string MatSN { get; set; }
|
||||
/// <summary>
|
||||
/// 物料编码
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "mat_code", Length = 100, IsNullable = true, ColumnDescription = "物料编号")]
|
||||
public string MatCode { get; set; }
|
||||
/// <summary>
|
||||
/// 物料名称
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "mat_name", Length = 150, IsNullable = true, ColumnDescription = "物料名称")]
|
||||
public string MatName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料规格
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "mat_spec", Length = 150, IsNullable = true, ColumnDescription = "物料规格")]
|
||||
public string MatSpec { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料批次
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "mat_batch", Length = 150, IsNullable = true, ColumnDescription = "物料批次")]
|
||||
public string MatBatch { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料数量
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "mat_qty", IsNullable = false, ColumnDescription = "物料数量")]
|
||||
public int MatQty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料供应商
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "mat_supplier", Length = 150, IsNullable = true, ColumnDescription = "物料供应商")]
|
||||
public string? MatSupplier { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料客户
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "mat_customer", Length = 150, IsNullable = true, ColumnDescription = "物料客户")]
|
||||
public string? MatCustomer { get; set; }
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 该物料是否已出库
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "is_sended", IsNullable = false, ColumnDescription = "该物料是否已出库")]
|
||||
public bool IsSended { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "create_time", IsNullable = false, ColumnDescription = "入库时间")]
|
||||
public DateTime CreateTime { get; set; } = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// 创建人
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "create_user", Length = 100, IsNullable = true, ColumnDescription = "操作员")]
|
||||
public string CreateUser { get; set; }
|
||||
}
|
||||
}
|
99
WCS.BLL/DbModels/ShelfInfo.cs
Normal file
99
WCS.BLL/DbModels/ShelfInfo.cs
Normal file
@ -0,0 +1,99 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WCS.BLL.HardWare;
|
||||
|
||||
namespace WCS.DAL.DbModels
|
||||
{
|
||||
[SugarTable("shelf_info")]
|
||||
public class ShelfInfo
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 主键 自增Id
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsNullable = false, IsIdentity = true)]
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架编码;货架一般按照报警灯来区分 一个报警灯指示的是一个货架
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "shelf_code", Length = 50, IsNullable = false, ColumnDescription = "货架编码;货架一般按照报警灯来区分 一个报警灯指示的是一个货架")]
|
||||
public string ShelfCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架类型Id
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "shelf_type_id", IsNullable = false, ColumnDescription = "货架类型Id")]
|
||||
public int ShelfTypeId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架类型名称
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "shelf_type_name", Length = 50, IsNullable = false, ColumnDescription = "货架类型名称")]
|
||||
public string ShelfTypeName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架当前状态
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "current_mode", IsNullable = false, ColumnDescription = "货架当前状态")]
|
||||
public Mode CurrentMode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架行数
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "row_counts", IsNullable = false, ColumnDescription = "货架行数")]
|
||||
public int Rowcounts { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架列数
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "column_counts", IsNullable = false, ColumnDescription = "货架列数")]
|
||||
public int Columncounts { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架对应警示灯的Id
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "light_id", IsNullable = false, ColumnDescription = "货架对应警示灯的Id")]
|
||||
public int LightId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架对应Can模块的Ip
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "client_ip", Length = 50, IsNullable = false, ColumnDescription = "货架对应Can模块的Ip")]
|
||||
public string ClientIp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架的组别、区域(区分单个软件管哪些货架的,前端的配置文件配置一个组别,查询时只显示当前组别的货架)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "group_name", Length = 50, IsNullable = false, ColumnDescription = "货架的组别、区域(区分单个软件管哪些货架的,前端的配置文件配置一个组别,查询时只显示当前组别的货架)")]
|
||||
public string GroupName { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 是否串联绑定
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "is_bind", IsNullable = false, ColumnDescription = "是否串联绑定")]
|
||||
public bool IsBind { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 串联绑定后的大货架编码
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Bind_shelf_code", IsNullable = true, ColumnDescription = "串联绑定后的大货架编码")]
|
||||
public string? BindShelfCode { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 序号
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public int RowNumber { get; set; }
|
||||
/// <summary>
|
||||
/// 是否已经选择
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public bool IsSelected { get; set; }
|
||||
}
|
||||
}
|
22
WCS.BLL/DbModels/ShelfTypeInfo.cs
Normal file
22
WCS.BLL/DbModels/ShelfTypeInfo.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WCS.BLL.DbModels
|
||||
{
|
||||
/// <summary>
|
||||
/// 货架类型
|
||||
/// </summary>
|
||||
[SugarTable("shelf_type")]
|
||||
public class ShelfTypeInfo
|
||||
{
|
||||
[SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsNullable = false, IsIdentity = true)]
|
||||
public int Id { get; set; }
|
||||
|
||||
[SugarColumn(ColumnName = "shelf_type_name", Length = 50, IsNullable = true, ColumnDescription = "货架类型名称")]
|
||||
public string ShelfTypeName { get; set; }
|
||||
}
|
||||
}
|
77
WCS.BLL/DbModels/StoreInfo.cs
Normal file
77
WCS.BLL/DbModels/StoreInfo.cs
Normal file
@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WCS.DAL.DbModels
|
||||
{
|
||||
public partial class StoreInfo
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 库位Id
|
||||
/// </summary>
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 库位编码
|
||||
/// </summary>
|
||||
public string StoreCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 模组Id
|
||||
/// </summary>
|
||||
public int ModuleId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 模组编号
|
||||
/// </summary>
|
||||
public string ModuleCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架Id
|
||||
/// </summary>
|
||||
public int ShelfId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架号
|
||||
/// </summary>
|
||||
public string ShelfCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 板子的Id
|
||||
/// </summary>
|
||||
public int BoardId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 板子上第几个灯
|
||||
/// </summary>
|
||||
public int LightNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 优先级;为钢网柜推荐库位预留
|
||||
/// </summary>
|
||||
public int Priority { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当前物料;货架这种一对一且带检测的就给这个赋值,方便出入库时的查询
|
||||
/// </summary>
|
||||
public string CurrentMatSn { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当前电压;当前电压,调试排查问题用
|
||||
/// </summary>
|
||||
public decimal CurrentVoltage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 标准电压;标准电压,调试排查问题用
|
||||
/// </summary>
|
||||
public decimal StandardVoltage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 偏差电压;偏差电压,调试排查问题用
|
||||
/// </summary>
|
||||
public decimal OffsetVoltage { get; set; }
|
||||
}
|
||||
}
|
102
WCS.BLL/DbModels/SystemApiLogRecord.cs
Normal file
102
WCS.BLL/DbModels/SystemApiLogRecord.cs
Normal file
@ -0,0 +1,102 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WCS.BLL.DbModels
|
||||
{
|
||||
/// <summary>
|
||||
/// 系统接口日志记录
|
||||
/// </summary>
|
||||
[SugarTable("system_api_log_record")]
|
||||
public class SystemApiLogRecord
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键Id
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsNullable = false, IsIdentity = true)]
|
||||
public int Id { get; set; }
|
||||
|
||||
[SugarColumn(ColumnName = "request_type", IsNullable = false, ColumnDescription = "调用/被调用 0 = 被调用,1 = 调用")]
|
||||
/// <summary>
|
||||
/// 调用/被调用 0 = 被调用 1 = 调用
|
||||
/// </summary>
|
||||
public string RequestType { get; set; } = "被调用";
|
||||
|
||||
/// <summary>
|
||||
/// 用户名称
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "user_name", IsNullable = true, ColumnDescription = "用户名称")]
|
||||
public string UserName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设备类型
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "device_type", IsNullable = true, ColumnDescription = "用户名称")]
|
||||
public string DeviceType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设备Ip
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "device_ip", IsNullable = true, ColumnDescription = "设备Ip")]
|
||||
public string DeviceIp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 请求地址
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "request_url", IsNullable = true, ColumnDescription = "请求地址")]
|
||||
public string RequestUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 请求Body
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "request_body", IsNullable = true, ColumnDescription = "请求Body")]
|
||||
public string RequestBody { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 请求Body
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "query_string", IsNullable = true, ColumnDescription = "请求Body")]
|
||||
public string QueryString { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否响应
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "is_response", IsNullable = true, ColumnDescription = "是否响应")]
|
||||
public bool IsResponse { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 响应返回内容
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "response_json", IsNullable = true, ColumnDescription = "响应返回内容")]
|
||||
public string ResponseJson { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 开始请求时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "request_time", IsNullable = true, ColumnDescription = "开始请求时间")]
|
||||
public DateTime RequestTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 响应时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "response_time", IsNullable = true, ColumnDescription = "响应时间")]
|
||||
public DateTime ResponseTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 请求处理时长(ms)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "execution_time", IsNullable = true, ColumnDescription = "请求处理时长(ms)")]
|
||||
public long ExecutionTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 序号
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public int RowNumber { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
31
WCS.BLL/HardWare/IModuleBase.cs
Normal file
31
WCS.BLL/HardWare/IModuleBase.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WCS.BLL.HardWare
|
||||
{
|
||||
public interface IModuleBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 模组Id
|
||||
/// </summary>
|
||||
int ModuleId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用
|
||||
/// </summary>
|
||||
bool IsEnable { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当前模式
|
||||
/// </summary>
|
||||
Mode CurrentMode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设置当前模式
|
||||
/// </summary>
|
||||
void SetCurrentMode();
|
||||
}
|
||||
}
|
108
WCS.BLL/HardWare/IShelfBase.cs
Normal file
108
WCS.BLL/HardWare/IShelfBase.cs
Normal file
@ -0,0 +1,108 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WCS.Model;
|
||||
|
||||
namespace WCS.BLL.HardWare
|
||||
{
|
||||
/// <summary>
|
||||
/// 货架基类
|
||||
/// </summary>
|
||||
public interface IShelfBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 货架ID 数据库中那个
|
||||
/// </summary>
|
||||
public int ShelfId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架编码
|
||||
/// </summary>
|
||||
public string ShelfCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架模组行数
|
||||
/// </summary>
|
||||
public int RowCounts { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架模组列数
|
||||
/// </summary>
|
||||
public int ColumnCounts { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架当前模式
|
||||
/// </summary>
|
||||
public Mode CurentMode { get; set; }
|
||||
|
||||
public MatInfoModel InStoreData { get; set; }
|
||||
|
||||
public string OutOrderNumber { get; set; }//出库模式中的单据
|
||||
|
||||
public string ModulesStr { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架组别
|
||||
/// </summary>
|
||||
public string GroupName { get; set; }
|
||||
/// <summary>
|
||||
/// 模组
|
||||
/// </summary>
|
||||
//public List<IModuleBase> Modules { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设置货架模式
|
||||
/// </summary>
|
||||
public void SetCurrentMode();
|
||||
|
||||
/// <summary>
|
||||
/// 货架进入入库模式
|
||||
/// </summary>
|
||||
public void GoInInstore(string? IPAdress);
|
||||
|
||||
/// <summary>
|
||||
/// 货架退出入库模式
|
||||
/// </summary>
|
||||
public void GoOutInstore();
|
||||
|
||||
/// <summary>
|
||||
/// 货架进入出库模式
|
||||
/// </summary>
|
||||
public void GoInOutstore();
|
||||
|
||||
/// <summary>
|
||||
/// 货架退出出库模式
|
||||
/// </summary>
|
||||
public void GoOutOutstore();
|
||||
|
||||
/// <summary>
|
||||
/// 货架进入盘点模式
|
||||
/// </summary>
|
||||
public void GoInStocktaking();
|
||||
|
||||
/// <summary>
|
||||
/// 货架退出盘点模式
|
||||
/// </summary>
|
||||
public void GoOutStocktaking();
|
||||
|
||||
/// <summary>
|
||||
/// 货架报警
|
||||
/// </summary>
|
||||
public void Warning();
|
||||
|
||||
/// <summary>
|
||||
/// 货架复位
|
||||
/// </summary>
|
||||
public void Reset();
|
||||
}
|
||||
|
||||
public enum Mode
|
||||
{
|
||||
待机模式 = 0,
|
||||
入库模式 = 1,
|
||||
出库模式 = 2,
|
||||
盘点模式 = 3
|
||||
}
|
||||
}
|
13
WCS.BLL/HardWare/IWarningLightBase.cs
Normal file
13
WCS.BLL/HardWare/IWarningLightBase.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WCS.BLL.HardWare
|
||||
{
|
||||
public interface IWarningLightBase
|
||||
{
|
||||
public void BlueLight();
|
||||
}
|
||||
}
|
68
WCS.BLL/HardWare/SingleLightShelf.cs
Normal file
68
WCS.BLL/HardWare/SingleLightShelf.cs
Normal file
@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WCS.Model;
|
||||
|
||||
namespace WCS.BLL.HardWare
|
||||
{
|
||||
public class SingleLightShelf : IShelfBase
|
||||
{
|
||||
public int ShelfId { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
public string ShelfCode { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
public int RowCounts { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
public int ColumnCounts { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
public Mode CurentMode { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
public string ModulesStr { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
public string GroupName { get; set; }
|
||||
public MatInfoModel InStoreData { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
|
||||
public string OutOrderNumber { get; set; }
|
||||
|
||||
public void GoInInstore(string IPAdress)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void GoInOutstore()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void GoInStocktaking()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void GoOutInstore()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void GoOutOutstore()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void GoOutStocktaking()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetCurrentMode()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Warning()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
210
WCS.BLL/HardWare/SmartShelf.cs
Normal file
210
WCS.BLL/HardWare/SmartShelf.cs
Normal file
@ -0,0 +1,210 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TouchSocket.Core;
|
||||
using WCS.DAL;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.DAL.DbModels;
|
||||
using WCS.Model;
|
||||
|
||||
namespace WCS.BLL.HardWare
|
||||
{
|
||||
/// <summary>
|
||||
/// 智能货架
|
||||
/// </summary>
|
||||
public class SmartShelf : IShelfBase
|
||||
{
|
||||
public SmartShelf(ShelfInfo shelfInfo)
|
||||
{
|
||||
ShelfId = shelfInfo.Id;
|
||||
ShelfCode = shelfInfo.ShelfCode;
|
||||
RowCounts = shelfInfo.Rowcounts;
|
||||
ColumnCounts = shelfInfo.Columncounts;
|
||||
CurentMode = shelfInfo.CurrentMode;
|
||||
|
||||
//初始化Module
|
||||
Task.Run(() =>
|
||||
{
|
||||
var modules = DbHelp.db.Queryable<ModuleInfo>().Where(t => t.ShelfId == ShelfId).ToList();
|
||||
foreach (var module in modules)
|
||||
{
|
||||
Modules.Add(new SmartShelfModule()
|
||||
{
|
||||
ModuleId = module.Id,
|
||||
ModuleCode = module.ModuleCode,
|
||||
IsEnable = module.IsEnable,
|
||||
CurrentMode = module.CurentMode
|
||||
});
|
||||
}
|
||||
ModulesStr = string.Join(";", Modules.Select(t => t.ModuleCode));
|
||||
});
|
||||
|
||||
//初始化TCPCleint
|
||||
TcpCleint = new TCPClient("127.0.0.1:20002", "127.0.0.1:20003");
|
||||
TcpCleint.Connect();
|
||||
TcpCleint.tcpClient.Received += (client, e) =>
|
||||
{
|
||||
var data = e.ByteBlock.Buffer.Take((int)e.ByteBlock.Length).ToArray();
|
||||
e.ByteBlock.Clear();
|
||||
var len = data.Length;
|
||||
for (int index = 0; index < data.Length - TcpCleint.PreFixLength; index++)
|
||||
{
|
||||
//协议拆包 通过前缀校验是否为完整数据包
|
||||
var prefixInData = data.Skip(index).Take(TcpCleint.PreFixLength);
|
||||
var isEqual = prefixInData.SequenceEqual(TcpCleint.Prefix);
|
||||
if (isEqual)
|
||||
{
|
||||
var dataTemp = data.Skip(index).Take(TcpCleint.PreFixLength + TcpCleint.DataLength).ToArray();
|
||||
if (dataTemp.Length < TcpCleint.PreFixLength + TcpCleint.DataLength)//拆包后不满足一条指令的长度
|
||||
{
|
||||
continue;
|
||||
}
|
||||
index += (TcpCleint.PreFixLength + TcpCleint.DataLength - 1);//每次循环index会+1 所以这里-1
|
||||
//获取板子ID
|
||||
var boardId = (data[TcpCleint.PreFixLength + 0] << 8) + data[TcpCleint.PreFixLength + 1];
|
||||
//协议处理 判断功能位
|
||||
switch (dataTemp[TcpCleint.PreFixLength + 2])
|
||||
{
|
||||
case 0x01:
|
||||
;
|
||||
break;
|
||||
default:
|
||||
;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return EasyTask.CompletedTask;
|
||||
};
|
||||
}
|
||||
|
||||
public int ShelfId { get; set; }
|
||||
public string ShelfCode { get; set; }
|
||||
public int RowCounts { get; set; }
|
||||
public int ColumnCounts { get; set; }
|
||||
public Mode CurentMode { get; set; }
|
||||
public string ModulesStr { get; set; }//当前货架所有模组的Str
|
||||
public string GroupName { get; set; }
|
||||
public List<SmartShelfModule> Modules { get; set; } = new List<SmartShelfModule>();
|
||||
public TCPClient TcpCleint { get; set; }
|
||||
|
||||
public IWarningLightBase WarningLight { get; set; }
|
||||
public List<string> ExceptionMessages { get; set; } = new List<string>();
|
||||
|
||||
public string? InstoreIpAddress { get; set; } = string.Empty;
|
||||
|
||||
public MatInfoModel InStoreData { get; set; }
|
||||
|
||||
public string OutOrderNumber { get; set; }
|
||||
|
||||
public void GoInInstore(string? IPAddress)
|
||||
{
|
||||
//判断当前模式是否为待机模式
|
||||
if (this.CurentMode != Mode.待机模式)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.CurentMode = Mode.入库模式;
|
||||
}
|
||||
//货架所有模组发送指令进入入库模式
|
||||
foreach (var module in Modules.Where(t => t.IsEnable).ToList())
|
||||
{
|
||||
module.GoInInstoreMode(TcpCleint);
|
||||
}
|
||||
//延时获取异常
|
||||
var timeOut = 3000;
|
||||
var timeSpan = TimeSpan.FromMilliseconds(0);
|
||||
var beginTime = DateTime.Now;
|
||||
while (timeSpan <= TimeSpan.FromMilliseconds(timeOut))
|
||||
{
|
||||
timeSpan = DateTime.Now - beginTime;
|
||||
//接收到第一个异常就不继续循环了
|
||||
if (ExceptionMessages.Count() > 0)
|
||||
{
|
||||
var deficientTime = timeOut - (int)timeSpan.TotalMilliseconds;
|
||||
if (deficientTime > 0)
|
||||
Thread.Sleep(deficientTime);
|
||||
//出现异常的未进入入库模式,有红灯进行指引
|
||||
//未出现异常的需要退出入库模式
|
||||
GoOutInstore();
|
||||
return;
|
||||
}
|
||||
//延时处理
|
||||
Thread.Sleep(50);
|
||||
}
|
||||
//警示灯亮起
|
||||
//WarningLight.BlueLight();
|
||||
//绑定当前入库PDA的IP
|
||||
InstoreIpAddress = IPAddress;
|
||||
//返回成功
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
public void GoInInstoreReturn()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void GoOutInstore()
|
||||
{
|
||||
//看货架是否为入库模式
|
||||
if (CurentMode != Mode.入库模式)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.CurentMode = Mode.待机模式;
|
||||
}
|
||||
//货架所有模组发送指令退出入库模式
|
||||
foreach (var module in Modules.Where(t => t.IsEnable)
|
||||
.Where(t => t.CurrentMode == Mode.入库模式)
|
||||
.ToList())
|
||||
{
|
||||
module.GoOutInstoreMode(TcpCleint);
|
||||
}
|
||||
}
|
||||
|
||||
public void GoInOutstore()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void GoInStocktaking()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
public void GoOutOutstore()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void GoOutStocktaking()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
void IShelfBase.Reset()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
void IShelfBase.SetCurrentMode()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
void IShelfBase.Warning()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
79
WCS.BLL/HardWare/SmartShelfModule.cs
Normal file
79
WCS.BLL/HardWare/SmartShelfModule.cs
Normal file
@ -0,0 +1,79 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.DAL.DbModels;
|
||||
|
||||
namespace WCS.BLL.HardWare
|
||||
{
|
||||
public class SmartShelfModule : IModuleBase
|
||||
{
|
||||
#region 协议明细
|
||||
/// <summary>
|
||||
/// 进入入库模式
|
||||
/// </summary>
|
||||
public byte[] GoInInstoreData = { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
/// <summary>
|
||||
/// 退出入库模式
|
||||
/// </summary>
|
||||
public byte[] GoOutInstoreData = { 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
#endregion
|
||||
public int ModuleId { get; set; }
|
||||
public string ModuleCode { get; set; }
|
||||
public bool IsEnable { get; set; }
|
||||
public Mode CurrentMode { get; set; }
|
||||
|
||||
public void SetCurrentMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void GoInInstoreMode(TCPClient tcpCleint)
|
||||
{
|
||||
|
||||
if (CurrentMode != Mode.待机模式)
|
||||
{
|
||||
//退出对应的模式 然后再发送进入入库模式
|
||||
}
|
||||
|
||||
var storeInfos = DbHelp.db.Queryable<StoreInfo>()
|
||||
.Where(t => t.BoardId == ModuleId)
|
||||
.OrderBy(t => t.LightNumber)
|
||||
.ToList();
|
||||
char[] data = "0000000000000000".ToCharArray();
|
||||
var boardStoreNumber = storeInfos.Count();
|
||||
foreach (var storeInfo in storeInfos)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(storeInfo.CurrentMatSn) && storeInfo.LightNumber > 0 && storeInfo.LightNumber <= boardStoreNumber)
|
||||
{
|
||||
data[storeInfo.LightNumber - 1] = '1';
|
||||
}
|
||||
}
|
||||
var dataStr = string.Join("", data.Reverse());
|
||||
var data1 = dataStr.Substring(8, 8);
|
||||
var data2 = dataStr.Substring(0, 8);
|
||||
GoInInstoreData[1] = Convert.ToByte(data1, 2);
|
||||
GoInInstoreData[2] = Convert.ToByte(data2, 2);
|
||||
|
||||
tcpCleint.Send(tcpCleint.GenerateMessage(ModuleId, GoInInstoreData));
|
||||
}
|
||||
|
||||
public void GoOutInstoreMode(TCPClient tcpCleint)
|
||||
{
|
||||
if (CurrentMode == Mode.入库模式)
|
||||
{
|
||||
tcpCleint.Send(tcpCleint.GenerateMessage(ModuleId, GoOutInstoreData));
|
||||
}
|
||||
else
|
||||
{
|
||||
//退出对应的模式 回到待机状态 并记录对应的状态日志(这个分支肯定是异常了)
|
||||
//记录错误日志
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
59
WCS.BLL/Manager/ShelfManager.cs
Normal file
59
WCS.BLL/Manager/ShelfManager.cs
Normal file
@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.HardWare;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.DAL.DbModels;
|
||||
|
||||
namespace WCS.BLL.Manager
|
||||
{
|
||||
public static class ShelfManager
|
||||
{
|
||||
public static List<IShelfBase> Shelves { get; set; } = new List<IShelfBase>();
|
||||
static ShelfManager()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static void InitShelves()
|
||||
{
|
||||
DbHelp.db.CodeFirst.InitTables(typeof(ModuleInfo), typeof(ShelfInfo), typeof(StoreInfo)
|
||||
, typeof(InventoryDetail), typeof(OutOrder), typeof(OutOrderDetail), typeof(OutOrderMatDetail)
|
||||
, typeof(ShelfTypeInfo), typeof(MatBaseInfo), typeof(MatInfo)
|
||||
);
|
||||
|
||||
DbHelp.dbLog.CodeFirst.InitTables(typeof(SystemApiLogRecord));
|
||||
|
||||
var shelvesInDb = DbHelp.db.Queryable<ShelfInfo>().ToList();
|
||||
foreach (var shelfInDb in shelvesInDb)
|
||||
{
|
||||
Shelves.Add(InitShelf(shelfInDb));
|
||||
}
|
||||
}
|
||||
|
||||
public static IShelfBase InitShelf(ShelfInfo shelfInDb)
|
||||
{
|
||||
switch (shelfInDb.ShelfTypeId)
|
||||
{
|
||||
case 1:
|
||||
return new SmartShelf(shelfInDb)
|
||||
{
|
||||
ShelfId = shelfInDb.Id,
|
||||
ShelfCode = shelfInDb.ShelfCode,
|
||||
GroupName = shelfInDb.GroupName,
|
||||
};
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void GoInInstore()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
8
WCS.BLL/Services/IService/IHomerService.cs
Normal file
8
WCS.BLL/Services/IService/IHomerService.cs
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
namespace WCS.BLL.Services.IService
|
||||
{
|
||||
public interface IHomerService
|
||||
{
|
||||
|
||||
}
|
||||
}
|
17
WCS.BLL/Services/IService/IInstoreService.cs
Normal file
17
WCS.BLL/Services/IService/IInstoreService.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WCS.Model;
|
||||
|
||||
namespace WCS.BLL.Services.IService
|
||||
{
|
||||
public interface IInstoreService
|
||||
{
|
||||
public ResponseBase shelfGoInInStore(ShelfGoInInstoreRequest request);
|
||||
public ResponseBase shelfGoOutInStore(ShelfGoOutInStoreRequest request);
|
||||
public ResponseBase queryByMatSn(QueryByMatSnRequest request);
|
||||
public Task<ResponseBase> queryInstoreStatus(QueryByMatSnRequest request);
|
||||
}
|
||||
}
|
17
WCS.BLL/Services/IService/IInterfaceRecordService.cs
Normal file
17
WCS.BLL/Services/IService/IInterfaceRecordService.cs
Normal file
@ -0,0 +1,17 @@
|
||||
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.DAL.AuthDbModel;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel;
|
||||
using WCS.Model.ApiModel.User;
|
||||
|
||||
namespace WCS.BLL.Services.IService
|
||||
{
|
||||
|
||||
public interface IInterfaceRecordService
|
||||
{
|
||||
public Task<PageQueryResponse<SystemApiLogRecord>> getInterfaceRecord(GetInterfaceRecordsRequest request);
|
||||
|
||||
public Task<PageQueryResponse<SystemApiLogRecord>> exportInterfaceRecord(GetInterfaceRecordsRequest request);
|
||||
}
|
||||
}
|
26
WCS.BLL/Services/IService/IMatBaseInfoService.cs
Normal file
26
WCS.BLL/Services/IService/IMatBaseInfoService.cs
Normal file
@ -0,0 +1,26 @@
|
||||
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.DAL.AuthDbModel;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel;
|
||||
using WCS.Model.ApiModel.MatBaseInfo;
|
||||
using WCS.Model.ApiModel.User;
|
||||
|
||||
namespace WCS.BLL.Services.IService
|
||||
{
|
||||
|
||||
public interface IMatBaseInfoService
|
||||
{
|
||||
public Task<PageQueryResponse<MatBaseInfo>> getMatBaseInfo(GetMatBaseInfoRequest request);
|
||||
|
||||
public Task<PageQueryResponse<MatBaseInfo>> exportMatBaseInfo(GetMatBaseInfoRequest request);
|
||||
|
||||
public Task<ResponseCommon<List<string>>> importMatBaseInfo(List<MatBaseInfoImportModel> lists,string userName,string deviceType);
|
||||
|
||||
public Task<ResponseCommon<object>> addOrUpdateMatBaseInfo(AddMatBaseInfoRequest<MatBaseInfo> request);
|
||||
|
||||
public Task<ResponseCommon<object>> deleteMatBaseInfo(DeleteMatBaseInfosRequest request);
|
||||
|
||||
public Task<ResponseCommon<List<string>>> getMatCodeList(GetMatCodeListRequest request);
|
||||
}
|
||||
}
|
18
WCS.BLL/Services/IService/IMatInventoryDetailService.cs
Normal file
18
WCS.BLL/Services/IService/IMatInventoryDetailService.cs
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.DAL.AuthDbModel;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel;
|
||||
using WCS.Model.ApiModel.MatInventoryDetail;
|
||||
using WCS.Model.ApiModel.User;
|
||||
|
||||
namespace WCS.BLL.Services.IService
|
||||
{
|
||||
|
||||
public interface IMatInventoryDetailService
|
||||
{
|
||||
public Task<PageQueryResponse<InventoryDetail>> getMatInventoryDetail(GetMatInventoryDetailRequest request);
|
||||
|
||||
public Task<PageQueryResponse<InventoryDetail>> exportMatInventoryDetail(GetMatInventoryDetailRequest request);
|
||||
}
|
||||
}
|
24
WCS.BLL/Services/IService/IOutstoreService.cs
Normal file
24
WCS.BLL/Services/IService/IOutstoreService.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WCS.Model;
|
||||
|
||||
namespace WCS.BLL.Services.IService
|
||||
{
|
||||
public interface IOutstoreService
|
||||
{
|
||||
public Task<ResponseBase> SysOutOrderByMatCode(SysOutOrderByMatCodeRequest request);
|
||||
|
||||
public Task<ResponseBase> SysOutOrderByMatSn(SysOutOrderByMatSnRequest request);
|
||||
|
||||
public Task<ResponseBase> GetOutOrderList(GetOutOrderListRequest request);
|
||||
|
||||
public Task<ResponseBase> GetOutOrderDetail(GetOutOrderDetailRequest request);
|
||||
|
||||
public Task<ResponseBase> GoInOutstore(GetOutOrderDetailRequest request);
|
||||
|
||||
public Task<ResponseBase> GoOutOutstore(GetOutOrderDetailRequest request);
|
||||
}
|
||||
}
|
31
WCS.BLL/Services/IService/IStoreInfoService.cs
Normal file
31
WCS.BLL/Services/IService/IStoreInfoService.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WCS.DAL.AuthDbModel;
|
||||
using WCS.Model.ApiModel.User;
|
||||
using WCS.Model;
|
||||
using WCS.DAL.DbModels;
|
||||
using WCS.Model.ApiModel.StoreInfo;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.Model.ApiModel.MatBaseInfo;
|
||||
|
||||
namespace WCS.BLL.Services.IService
|
||||
{
|
||||
public interface IStoreInfoService
|
||||
{
|
||||
/// <summary>
|
||||
/// 查询货架列表
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
public Task<PageQueryResponse<ShelfInfo>> GetShelves(GetShelvesRequest request);
|
||||
/// <summary>
|
||||
/// 添加、更新、删除货架
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
public Task<ResponseCommon<object>> addOrUpdateShelfInfo(AddShelfInfoRequest<ShelfInfo> request);
|
||||
}
|
||||
}
|
29
WCS.BLL/Services/IService/IUserService.cs
Normal file
29
WCS.BLL/Services/IService/IUserService.cs
Normal file
@ -0,0 +1,29 @@
|
||||
|
||||
using WCS.DAL.AuthDbModel;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel;
|
||||
using WCS.Model.ApiModel.User;
|
||||
|
||||
namespace WCS.BLL.Services.IService
|
||||
{
|
||||
/// <summary>
|
||||
/// 权限用户所有的后台处理方法
|
||||
/// </summary>
|
||||
public interface IUserService
|
||||
{
|
||||
/// <summary>
|
||||
/// 模糊查询用户列表
|
||||
/// </summary>
|
||||
/// <param name="info"></param>
|
||||
/// <returns></returns>
|
||||
public Task<ResponseCommon<List<UserBase>>> GetUsers(GetUsersRequest request);
|
||||
|
||||
public Task<ResponseCommon<object>> AddUser(AddUserRequest<UserModel> request);
|
||||
|
||||
public Task<ResponseCommon<UserBase>> UserLogin(UserLoginRequest request);
|
||||
|
||||
public Task<ResponseCommon<List<RoleBase>>> GetRoles(GetUsersRequest request);
|
||||
|
||||
public Task<ResponseCommon<object>> AddRole(AddRoleRequest<RoleModel> request);
|
||||
}
|
||||
}
|
14
WCS.BLL/Services/Service/HomerService.cs
Normal file
14
WCS.BLL/Services/Service/HomerService.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WCS.BLL.Services.IService;
|
||||
|
||||
namespace WCS.BLL.Services.Service
|
||||
{
|
||||
public class HomerService: IHomerService
|
||||
{
|
||||
public HomerService() { }
|
||||
}
|
||||
}
|
170
WCS.BLL/Services/Service/InstoreService.cs
Normal file
170
WCS.BLL/Services/Service/InstoreService.cs
Normal file
@ -0,0 +1,170 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using WCS.BLL.Config;
|
||||
using WCS.BLL.HardWare;
|
||||
using WCS.BLL.Manager;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.Model;
|
||||
|
||||
namespace WCS.BLL.Services.Service
|
||||
{
|
||||
public class InstoreService : IInstoreService
|
||||
{
|
||||
public InstoreService() { }
|
||||
|
||||
public ResponseBase shelfGoInInStore(ShelfGoInInstoreRequest request)
|
||||
{
|
||||
//校验货架编码规则
|
||||
bool isValid = Regex.IsMatch(request.ModuleCode, LocalFile.ModuleCodePattern);
|
||||
if (!isValid)
|
||||
{
|
||||
return new ResponseBase()
|
||||
{
|
||||
Code = 202,
|
||||
Message = $"模组编码{request.ModuleCode}不满足模组编码规则!",
|
||||
};
|
||||
}
|
||||
//找到模组对应的货架
|
||||
var shelf = ShelfManager.Shelves.Where(t => t.ModulesStr.Contains(request.ModuleCode)).FirstOrDefault();
|
||||
if (shelf == null)//未找到
|
||||
{
|
||||
return new ResponseBase()
|
||||
{
|
||||
Code = 201,
|
||||
Message = "未找到模组对应的货架",
|
||||
};
|
||||
}
|
||||
//已找到模组对应货架
|
||||
shelf.GoInInstore(request.IpAdress);
|
||||
|
||||
//成功进入入库模式
|
||||
return new ShelfGoInInstoreResponse()
|
||||
{
|
||||
Code = 200,
|
||||
Message = "货架进入入库模式成功!",
|
||||
Data = new ShelfGoInInstoreDto()
|
||||
{
|
||||
ShelfCode = shelf.ShelfCode,
|
||||
ModulesStr = shelf.ModulesStr,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public ResponseBase shelfGoOutInStore(ShelfGoOutInStoreRequest request)
|
||||
{
|
||||
//获取货架
|
||||
var shelf = ShelfManager.Shelves.Where(t => t.ShelfCode == request.ShelfCode).FirstOrDefault();
|
||||
if (shelf == null)//货架不存在
|
||||
{
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"退出入库模式失败:货架[{request.ShelfCode}]不存在!",
|
||||
};
|
||||
}
|
||||
//TO DO 判断扫码枪 是否被其他扫码枪所占用 如果占用 直接退出入库模式 不发指令
|
||||
//两个扫码枪互相占用入库会有问题
|
||||
shelf.GoOutInstore();
|
||||
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"货架[{request.ShelfCode}]已退出入库模式!",
|
||||
};
|
||||
}
|
||||
|
||||
public ResponseBase queryByMatSn(QueryByMatSnRequest request)
|
||||
{
|
||||
//获取货架
|
||||
var shelf = ShelfManager.Shelves.Where(t => t.ShelfCode == request.ShelfCode).FirstOrDefault();
|
||||
if (shelf == null)//货架不存在
|
||||
{
|
||||
return new QueryByMatSnResponse()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"操作失败:货架[{request.ShelfCode}]不存在!",
|
||||
};
|
||||
}
|
||||
//判断当前是否是入库模式
|
||||
if (shelf.CurentMode != Mode.入库模式)
|
||||
{
|
||||
return new QueryByMatSnResponse()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"操作失败:货架[{request.ShelfCode}]不在入库模式!\r\n当前为{shelf.CurentMode}",
|
||||
};
|
||||
}
|
||||
//调用接口或者直接查询数据库
|
||||
if (1 == 1)
|
||||
{
|
||||
|
||||
}
|
||||
//查询数据库
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
return new QueryByMatSnResponse()
|
||||
{
|
||||
Code = 200,
|
||||
Data = new MatInfoModel(),
|
||||
Message = "success"
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<ResponseBase> queryInstoreStatus(QueryByMatSnRequest request)
|
||||
{
|
||||
//获取货架
|
||||
var shelf = ShelfManager.Shelves.Where(t => t.ShelfCode == request.ShelfCode).FirstOrDefault();
|
||||
if (shelf == null)//货架不存在
|
||||
{
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"操作失败:货架[{request.ShelfCode}]不存在!",
|
||||
};
|
||||
}
|
||||
//判断当前是否是入库模式
|
||||
if (shelf.CurentMode != Mode.入库模式)
|
||||
{
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"操作失败:货架[{request.ShelfCode}]不在入库模式!\r\n当前为{shelf.CurentMode}",
|
||||
};
|
||||
}
|
||||
//这个时间相当于需要入库扫码后需要等待的时间
|
||||
var timeOut = 5000;
|
||||
var timeSpan = TimeSpan.FromMilliseconds(0);
|
||||
var beginTime = DateTime.Now;
|
||||
while (timeSpan <= TimeSpan.FromMilliseconds(timeOut))
|
||||
{
|
||||
timeSpan = DateTime.Now - beginTime;
|
||||
//已入库当前扫码的物料时 查询数据库
|
||||
if (shelf.InStoreData == null || (shelf.InStoreData as object) == null)
|
||||
{
|
||||
await Task.Delay(50);
|
||||
//var inventoryDetail = DbHelp.db.Queryable<InventoryDetail>().Where(t => t.MatSN == dto.matSn).First();
|
||||
//if (inventoryDetail != null)
|
||||
//{
|
||||
// return Json(HttpResponseCommon.GetSuccessResponse($"{inventoryDetail.StoreCode}", null));
|
||||
//}
|
||||
}
|
||||
//延时处理
|
||||
Thread.Sleep(50);
|
||||
}
|
||||
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"success",
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
128
WCS.BLL/Services/Service/InterfaceRecordService.cs
Normal file
128
WCS.BLL/Services/Service/InterfaceRecordService.cs
Normal file
@ -0,0 +1,128 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using TouchSocket.Core;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.DAL;
|
||||
using WCS.DAL.AuthDbModel;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel;
|
||||
using WCS.Model.ApiModel.User;
|
||||
|
||||
namespace WCS.BLL.Services.Service
|
||||
{
|
||||
public class InterfaceRecordService : IInterfaceRecordService
|
||||
{
|
||||
public InterfaceRecordService() { }
|
||||
|
||||
public async Task<PageQueryResponse<SystemApiLogRecord>> getInterfaceRecord(GetInterfaceRecordsRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
var recordsQueryable = DbHelp.dbLog.Queryable<SystemApiLogRecord>()
|
||||
.WhereIF(!string.IsNullOrEmpty(request.RequestType), t => t.RequestType == request.RequestType)
|
||||
.WhereIF(!string.IsNullOrEmpty(request.RequestUrl), t => t.RequestUrl.Contains(request.RequestUrl))
|
||||
.WhereIF(!string.IsNullOrEmpty(request.RequestBody), t => t.RequestBody.Contains(request.RequestBody));
|
||||
if (request.TimeType == TimeType.请求时间)
|
||||
{
|
||||
recordsQueryable = recordsQueryable.WhereIF(request.StartTime != null, t => request.StartTime <= t.RequestTime);
|
||||
recordsQueryable = recordsQueryable.WhereIF(request.StartTime != null, t => request.EndTime >= t.RequestTime);
|
||||
}
|
||||
else if (request.TimeType == TimeType.响应时间)
|
||||
{
|
||||
recordsQueryable = recordsQueryable.WhereIF(request.StartTime != null, t => request.StartTime <= t.ResponseTime);
|
||||
recordsQueryable = recordsQueryable.WhereIF(request.StartTime != null, t => request.EndTime >= t.ResponseTime);
|
||||
}
|
||||
var totalCount = await recordsQueryable.CountAsync();
|
||||
var records = await recordsQueryable
|
||||
.Skip((request.PageNumber - 1) * request.PageSize).Take(request.PageSize)
|
||||
.ToListAsync();
|
||||
//生成序号
|
||||
for (int i = 0; i < records.Count; i++)
|
||||
{
|
||||
records[i].RowNumber = (request.PageNumber - 1) * 10 + i + 1;
|
||||
}
|
||||
//Task.WaitAll(new Task[] { recordsTask, totalCountTask });
|
||||
|
||||
//var records = recordsTask.Result;
|
||||
//var totalCount = totalCountTask.Result;
|
||||
|
||||
return new PageQueryResponse<SystemApiLogRecord>()
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"success",
|
||||
Data = new PageQueryResponseData<SystemApiLogRecord>()
|
||||
{
|
||||
TotalCount = totalCount,
|
||||
MaxPage = request.PageSize == 0 ? 0 : (int)Math.Ceiling((decimal)totalCount / request.PageSize),
|
||||
Count = records.Count,
|
||||
Lists = records.ToList()
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new PageQueryResponse<SystemApiLogRecord>()
|
||||
{
|
||||
Code = 300,
|
||||
Message = $"操作失败:{ex.Message}",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<PageQueryResponse<SystemApiLogRecord>> exportInterfaceRecord(GetInterfaceRecordsRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
var recordsQueryable = DbHelp.dbLog.Queryable<SystemApiLogRecord>()
|
||||
.WhereIF(!string.IsNullOrEmpty(request.RequestType), t => t.RequestType == request.RequestType)
|
||||
.WhereIF(!string.IsNullOrEmpty(request.RequestUrl), t => t.RequestUrl.Contains(request.RequestUrl))
|
||||
.WhereIF(!string.IsNullOrEmpty(request.RequestBody), t => t.RequestBody.Contains(request.RequestBody));
|
||||
if (request.TimeType == TimeType.请求时间)
|
||||
{
|
||||
recordsQueryable = recordsQueryable.WhereIF(request.StartTime != null, t => request.StartTime <= t.RequestTime);
|
||||
recordsQueryable = recordsQueryable.WhereIF(request.StartTime != null, t => request.EndTime >= t.RequestTime);
|
||||
}
|
||||
else if (request.TimeType == TimeType.响应时间)
|
||||
{
|
||||
recordsQueryable = recordsQueryable.WhereIF(request.StartTime != null, t => request.StartTime <= t.ResponseTime);
|
||||
recordsQueryable = recordsQueryable.WhereIF(request.StartTime != null, t => request.EndTime >= t.ResponseTime);
|
||||
}
|
||||
var records = await recordsQueryable.ToListAsync();
|
||||
//生成序号
|
||||
var index = 1;
|
||||
records.ForEach(r =>
|
||||
{
|
||||
r.RowNumber = index++;
|
||||
});
|
||||
return new PageQueryResponse<SystemApiLogRecord>()
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"success",
|
||||
Data = new PageQueryResponseData<SystemApiLogRecord>()
|
||||
{
|
||||
Lists = records
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new PageQueryResponse<SystemApiLogRecord>()
|
||||
{
|
||||
Code = 300,
|
||||
Message = $"操作失败:{ex.Message}",
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
416
WCS.BLL/Services/Service/MatBaseInfoService.cs
Normal file
416
WCS.BLL/Services/Service/MatBaseInfoService.cs
Normal file
@ -0,0 +1,416 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using TouchSocket.Core;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.DAL;
|
||||
using WCS.DAL.AuthDbModel;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel;
|
||||
using WCS.Model.ApiModel.MatBaseInfo;
|
||||
using WCS.Model.ApiModel.User;
|
||||
|
||||
namespace WCS.BLL.Services.Service
|
||||
{
|
||||
/// <summary>
|
||||
/// 物料基础信息
|
||||
/// </summary>
|
||||
public class MatBaseInfoService : IMatBaseInfoService
|
||||
{
|
||||
public MatBaseInfoService() { }
|
||||
|
||||
public async Task<PageQueryResponse<MatBaseInfo>> getMatBaseInfo(GetMatBaseInfoRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
var recordsQueryable = DbHelp.db.Queryable<MatBaseInfo>()
|
||||
.WhereIF(!string.IsNullOrEmpty(request.MatCode), t => t.MatCode.Contains(request.MatCode))
|
||||
.WhereIF(!string.IsNullOrEmpty(request.MatName), t => t.MatName.Contains(request.MatName))
|
||||
.WhereIF(!string.IsNullOrEmpty(request.MatSpec), t => t.MatSpec.Contains(request.MatSpec))
|
||||
.WhereIF(request.IsEnable != null, t => t.IsEnable == request.IsEnable.GetValueOrDefault());
|
||||
|
||||
var totalCount = await recordsQueryable.CountAsync();
|
||||
var records = await recordsQueryable
|
||||
.Skip((request.PageNumber - 1) * request.PageSize).Take(request.PageSize)
|
||||
.ToListAsync();
|
||||
//生成序号
|
||||
for (int i = 0; i < records.Count; i++)
|
||||
{
|
||||
records[i].RowNumber = (request.PageNumber - 1) * 10 + i + 1;
|
||||
}
|
||||
|
||||
return new PageQueryResponse<MatBaseInfo>()
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"success",
|
||||
Data = new PageQueryResponseData<MatBaseInfo>()
|
||||
{
|
||||
TotalCount = totalCount,
|
||||
MaxPage = request.PageSize == 0 ? 0 : (int)Math.Ceiling((decimal)totalCount / request.PageSize),
|
||||
Count = records.Count,
|
||||
Lists = records.ToList()
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new PageQueryResponse<MatBaseInfo>()
|
||||
{
|
||||
Code = 300,
|
||||
Message = $"操作失败:{ex.Message}",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<PageQueryResponse<MatBaseInfo>> exportMatBaseInfo(GetMatBaseInfoRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
var recordsQueryable = DbHelp.db.Queryable<MatBaseInfo>()
|
||||
.WhereIF(!string.IsNullOrEmpty(request.MatCode), t => t.MatCode.Contains(request.MatCode))
|
||||
.WhereIF(!string.IsNullOrEmpty(request.MatName), t => t.MatName.Contains(request.MatName))
|
||||
.WhereIF(!string.IsNullOrEmpty(request.MatSpec), t => t.MatSpec.Contains(request.MatSpec))
|
||||
.WhereIF(request.IsEnable != null, t => t.IsEnable == request.IsEnable.GetValueOrDefault());
|
||||
var records = await recordsQueryable.ToListAsync();
|
||||
//生成序号
|
||||
var index = 1;
|
||||
records.ForEach(r =>
|
||||
{
|
||||
r.RowNumber = index++;
|
||||
});
|
||||
return new PageQueryResponse<MatBaseInfo>()
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"success",
|
||||
Data = new PageQueryResponseData<MatBaseInfo>()
|
||||
{
|
||||
Lists = records
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new PageQueryResponse<MatBaseInfo>()
|
||||
{
|
||||
Code = 300,
|
||||
Message = $"操作失败:{ex.Message}",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ResponseCommon<List<string>>> importMatBaseInfo(List<MatBaseInfoImportModel> lists, string userName, string deviceType)
|
||||
{
|
||||
|
||||
//获取数据
|
||||
#region 校验导入的编号是否重复
|
||||
var matCodes = lists.Select(t => t.物料编码)
|
||||
.ToList();
|
||||
var duplicates = matCodes.GroupBy(x => x)
|
||||
.Where(g => g.Count() > 1)
|
||||
.Select(g => g.Key).ToList();
|
||||
//有重复的情况
|
||||
if (duplicates.Count > 0)
|
||||
{
|
||||
return new ResponseCommon<List<string>>()
|
||||
{
|
||||
Code = 201,
|
||||
Message = "导入失败:文件中存在物料编码重复",
|
||||
Data = duplicates
|
||||
};
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 校验导入数据与数据库中数据是否有重复数据
|
||||
duplicates = await DbHelp.db.Queryable<MatBaseInfo>()
|
||||
.Where(t => matCodes.Contains(t.MatCode))
|
||||
.Select(t => t.MatCode)
|
||||
.ToListAsync();
|
||||
|
||||
//有重复的情况
|
||||
if (duplicates.Count > 0)
|
||||
{
|
||||
return new ResponseCommon<List<string>>()
|
||||
{
|
||||
Code = 201,
|
||||
Message = "导入失败:以下物料编码已存在",
|
||||
Data = duplicates
|
||||
};
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 导入数据
|
||||
try
|
||||
{
|
||||
await DbHelp.db.BeginTranAsync();
|
||||
foreach (var mat in lists)
|
||||
{
|
||||
var matBaseInfo = new MatBaseInfo()
|
||||
{
|
||||
MatCode = mat.物料编码,
|
||||
MatName = mat.名称,
|
||||
MatSpec = mat.规格,
|
||||
MatUnit = mat.单位,
|
||||
MatCustomer = mat.客户,
|
||||
IsEnable = mat.状态 == "启用" ? true : false,
|
||||
};
|
||||
await DbHelp.db.Insertable(matBaseInfo).ExecuteCommandAsync();
|
||||
}
|
||||
await DbHelp.db.CommitTranAsync();
|
||||
return new ResponseCommon<List<string>>()
|
||||
{
|
||||
Code = 200,
|
||||
Message = "导入数据成功",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await DbHelp.db.RollbackTranAsync();
|
||||
var ErrList = new List<string>
|
||||
{
|
||||
ex.Message
|
||||
};
|
||||
return new ResponseCommon<List<string>>()
|
||||
{
|
||||
Code = 200,
|
||||
Message = "导入失败",
|
||||
Data = ErrList
|
||||
};
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
public async Task<ResponseCommon<object>> addOrUpdateMatBaseInfo(AddMatBaseInfoRequest<MatBaseInfo> request)
|
||||
{
|
||||
try
|
||||
{
|
||||
var matBaseInfo = await DbHelp.db.Queryable<MatBaseInfo>()
|
||||
.Where(t => t.MatCode == request.MatBaseInfo.MatCode)
|
||||
.FirstAsync();
|
||||
//修改物料基础数据
|
||||
if (request.AddOrUpdate == AddOrUpdate.Update)
|
||||
{
|
||||
if (matBaseInfo == null)
|
||||
{
|
||||
return new ResponseCommon<Object>
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"更新物料基础数据失败:物料{request.MatBaseInfo}不存在!",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
matBaseInfo.MatName = request.MatBaseInfo.MatName;
|
||||
matBaseInfo.MatSpec = request.MatBaseInfo.MatSpec;
|
||||
matBaseInfo.MatUnit = request.MatBaseInfo.MatUnit;
|
||||
matBaseInfo.MatCustomer = request.MatBaseInfo.MatCustomer;
|
||||
matBaseInfo.IsEnable = request.MatBaseInfo.IsEnable;
|
||||
|
||||
|
||||
matBaseInfo.ModifyTime = request.MatBaseInfo.ModifyTime;
|
||||
matBaseInfo.ModifyUser = request.MatBaseInfo.ModifyUser;
|
||||
|
||||
var rowNum = await DbHelp.db.Updateable(matBaseInfo).ExecuteCommandAsync();
|
||||
if (rowNum == 0)
|
||||
{
|
||||
return new ResponseCommon<Object>
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"更新物料基础数据失败:请重试!",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ResponseCommon<Object>
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"更新物料基础数据成功!",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if (request.AddOrUpdate == AddOrUpdate.Add)
|
||||
{
|
||||
if (matBaseInfo != null)
|
||||
{
|
||||
return new ResponseCommon<Object>
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"物料基础数据失败:物料{request.MatBaseInfo.MatCode}已存在",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
var newMatBaseInfo = new MatBaseInfo()
|
||||
{
|
||||
MatCode = request.MatBaseInfo.MatCode,
|
||||
MatName = request.MatBaseInfo.MatName,
|
||||
MatSpec = request.MatBaseInfo.MatSpec,
|
||||
MatUnit = request.MatBaseInfo.MatUnit,
|
||||
MatCustomer = request.MatBaseInfo.MatCustomer,
|
||||
IsEnable = request.MatBaseInfo.IsEnable,
|
||||
|
||||
ModifyTime = request.MatBaseInfo.ModifyTime,
|
||||
ModifyUser = request.MatBaseInfo.ModifyUser,
|
||||
};
|
||||
var rowNum = await DbHelp.db.Insertable(newMatBaseInfo).ExecuteCommandAsync();
|
||||
if (rowNum == 0)
|
||||
{
|
||||
return new ResponseCommon<Object>
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"添加物料基础数据失败:请重试!",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ResponseCommon<Object>
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"添加物料基础数据成功!",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
//else if (request.AddOrUpdate == AddOrUpdate.Delete)
|
||||
//{
|
||||
// if (matBaseInfo == null)
|
||||
// {
|
||||
// return new ResponseCommon<Object>
|
||||
// {
|
||||
// Code = 201,
|
||||
// Message = $"删除物料基础数据失败:物料{request.MatBaseInfo}不存在!",
|
||||
// Data = null
|
||||
// };
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// var rowNum = await AuthDbHelp.db.Deleteable(matBaseInfo).ExecuteCommandAsync();
|
||||
// if (rowNum == 0)
|
||||
// {
|
||||
// return new ResponseCommon<Object>
|
||||
// {
|
||||
// Code = 201,
|
||||
// Message = $"删除物料基础数据失败:请重试!",
|
||||
// Data = null
|
||||
// };
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return new ResponseCommon<Object>
|
||||
// {
|
||||
// Code = 200,
|
||||
// Message = $"删除物料基础数据成功!",
|
||||
// Data = null
|
||||
// };
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
else
|
||||
{
|
||||
var response = new ResponseCommon<Object>
|
||||
{
|
||||
Code = 300,
|
||||
Message = "不支持的操作!",
|
||||
Data = null
|
||||
};
|
||||
return response;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var response = new ResponseCommon<Object>
|
||||
{
|
||||
Code = 300,
|
||||
Message = $"操作失败:{ex.Message}",
|
||||
Data = null
|
||||
};
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ResponseCommon<object>> deleteMatBaseInfo(DeleteMatBaseInfosRequest request)
|
||||
{
|
||||
//先查询出具体的Id
|
||||
var matBaseInfos = await DbHelp.db.Queryable<MatBaseInfo>()
|
||||
.Where(t => request.MatBaseInfoIds.Contains(t.Id))
|
||||
.ToListAsync();
|
||||
//执行删除
|
||||
try
|
||||
{
|
||||
var deleteRows = await DbHelp.db.Deleteable(matBaseInfos).ExecuteCommandAsync();
|
||||
return new ResponseCommon<Object>
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"已删除{deleteRows}条数据!",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var response = new ResponseCommon<Object>
|
||||
{
|
||||
Code = 300,
|
||||
Message = $"操作失败:{ex.Message}",
|
||||
Data = null
|
||||
};
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ResponseCommon<List<string>>> getMatCodeList(GetMatCodeListRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
|
||||
List<string> matCodeList = null;
|
||||
if (request.IsFromBaseData)
|
||||
{
|
||||
matCodeList = await DbHelp.db.Queryable<MatBaseInfo>()
|
||||
.Select(t => t.MatCode)
|
||||
.Distinct()
|
||||
.ToListAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
matCodeList = await DbHelp.db.Queryable<InventoryDetail>()
|
||||
.Select(t => t.MatCode)
|
||||
.Distinct()
|
||||
.ToListAsync();
|
||||
}
|
||||
return new ResponseCommon<List<string>>()
|
||||
{
|
||||
Code = 200,
|
||||
Message = "success",
|
||||
Data = matCodeList
|
||||
};
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return new ResponseCommon<List<string>>()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"获取失败:{e.Message}",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
126
WCS.BLL/Services/Service/MatInventoryDetailService.cs
Normal file
126
WCS.BLL/Services/Service/MatInventoryDetailService.cs
Normal file
@ -0,0 +1,126 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using TouchSocket.Core;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.DAL;
|
||||
using WCS.DAL.AuthDbModel;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.DAL.DbModels;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel;
|
||||
using WCS.Model.ApiModel.MatInventoryDetail;
|
||||
using WCS.Model.ApiModel.User;
|
||||
|
||||
namespace WCS.BLL.Services.Service
|
||||
{
|
||||
public class MatInventoryDetailService : IMatInventoryDetailService
|
||||
{
|
||||
public async Task<PageQueryResponse<InventoryDetail>> getMatInventoryDetail(GetMatInventoryDetailRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
var recordsQueryable = DbHelp.db.Queryable<InventoryDetail>()
|
||||
.LeftJoin<StoreInfo>((id, si) => id.StoreId == si.Id)
|
||||
.WhereIF(!string.IsNullOrEmpty(request.MatSN), (id, si) => id.MatSN.Contains(request.MatSN))
|
||||
.WhereIF(!string.IsNullOrEmpty(request.MatCode), (id, si) => id.MatCode.Contains(request.MatCode))
|
||||
.WhereIF(!string.IsNullOrEmpty(request.MatName), (id, si) => id.MatName.Contains(request.MatName))
|
||||
.WhereIF(!string.IsNullOrEmpty(request.MatBatch), (id, si) => id.MatBatch.Contains(request.MatBatch))
|
||||
.WhereIF(!string.IsNullOrEmpty(request.MatSpec), (id, si) => id.MatSpec.Contains(request.MatSpec))
|
||||
.WhereIF(!string.IsNullOrEmpty(request.MatSupplier), (id, si) => id.MatSpec.Contains(request.MatSupplier))
|
||||
.WhereIF(!string.IsNullOrEmpty(request.MatCustomer), (id, si) => id.MatSpec.Contains(request.MatCustomer))
|
||||
|
||||
|
||||
.WhereIF(request.StoreId != 0, (id, si) => id.StoreId == request.StoreId)
|
||||
.WhereIF(!string.IsNullOrEmpty(request.StoreCode), (id, si) => id.StoreCode.Contains(request.StoreCode))
|
||||
;
|
||||
|
||||
var totalCount = await recordsQueryable.CountAsync();
|
||||
var records = await recordsQueryable
|
||||
.Skip((request.PageNumber - 1) * request.PageSize).Take(request.PageSize)
|
||||
.Select<InventoryDetail>()
|
||||
.ToListAsync();
|
||||
//生成序号
|
||||
for (int i = 0; i < records.Count; i++)
|
||||
{
|
||||
records[i].RowNumber = (request.PageNumber - 1) * 10 + i + 1;
|
||||
}
|
||||
|
||||
return new PageQueryResponse<InventoryDetail>()
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"success",
|
||||
Data = new PageQueryResponseData<InventoryDetail>()
|
||||
{
|
||||
TotalCount = totalCount,
|
||||
MaxPage = request.PageSize == 0 ? 0 : (int)Math.Ceiling((decimal)totalCount / request.PageSize),
|
||||
Count = records.Count,
|
||||
Lists = records.ToList()
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new PageQueryResponse<InventoryDetail>()
|
||||
{
|
||||
Code = 300,
|
||||
Message = $"操作失败:{ex.Message}",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<PageQueryResponse<InventoryDetail>> exportMatInventoryDetail(GetMatInventoryDetailRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
var recordsQueryable = DbHelp.db.Queryable<InventoryDetail>()
|
||||
.LeftJoin<StoreInfo>((id, si) => id.StoreId == si.Id)
|
||||
.WhereIF(!string.IsNullOrEmpty(request.MatSN), (id, si) => id.MatSN.Contains(request.MatSN))
|
||||
.WhereIF(!string.IsNullOrEmpty(request.MatCode), (id, si) => id.MatCode.Contains(request.MatCode))
|
||||
.WhereIF(!string.IsNullOrEmpty(request.MatName), (id, si) => id.MatName.Contains(request.MatName))
|
||||
.WhereIF(!string.IsNullOrEmpty(request.MatBatch), (id, si) => id.MatBatch.Contains(request.MatBatch))
|
||||
.WhereIF(!string.IsNullOrEmpty(request.MatSpec), (id, si) => id.MatSpec.Contains(request.MatSpec))
|
||||
.WhereIF(!string.IsNullOrEmpty(request.MatSupplier), (id, si) => id.MatSpec.Contains(request.MatSupplier))
|
||||
.WhereIF(!string.IsNullOrEmpty(request.MatCustomer), (id, si) => id.MatSpec.Contains(request.MatCustomer))
|
||||
|
||||
|
||||
.WhereIF(request.StoreId != 0, (id, si) => id.StoreId == request.StoreId)
|
||||
.WhereIF(!string.IsNullOrEmpty(request.StoreCode), (id, si) => id.StoreCode.Contains(request.StoreCode))
|
||||
;
|
||||
var records = await recordsQueryable
|
||||
.Skip((request.PageNumber - 1) * request.PageSize).Take(request.PageSize)
|
||||
.Select<InventoryDetail>()
|
||||
.ToListAsync();
|
||||
//生成序号
|
||||
var index = 1;
|
||||
records.ForEach(r =>
|
||||
{
|
||||
r.RowNumber = index++;
|
||||
});
|
||||
return new PageQueryResponse<InventoryDetail>()
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"success",
|
||||
Data = new PageQueryResponseData<InventoryDetail>()
|
||||
{
|
||||
Lists = records
|
||||
}
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new PageQueryResponse<InventoryDetail>()
|
||||
{
|
||||
Code = 300,
|
||||
Message = $"操作失败:{ex.Message}",
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
328
WCS.BLL/Services/Service/OutstoreService.cs
Normal file
328
WCS.BLL/Services/Service/OutstoreService.cs
Normal file
@ -0,0 +1,328 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.Manager;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.Model;
|
||||
|
||||
namespace WCS.BLL.Services.Service
|
||||
{
|
||||
public class OutstoreService : IOutstoreService
|
||||
{
|
||||
public OutstoreService()
|
||||
{
|
||||
|
||||
}
|
||||
public async Task<ResponseBase> SysOutOrderByMatCode(SysOutOrderByMatCodeRequest request)
|
||||
{
|
||||
//参数合法性校验
|
||||
if (request.ItemList == null || request.ItemList.Count == 0)
|
||||
{
|
||||
return new ResponseBase()
|
||||
{
|
||||
Code = 201,
|
||||
Message = "单据同步失败:缺少需要出库的物料类型!"
|
||||
};
|
||||
}
|
||||
//判断是否有单据号 没有单据号系统自动生成一个
|
||||
if (string.IsNullOrEmpty(request.OrderNumber))
|
||||
{
|
||||
request.OrderNumber = GetOrderNumber();
|
||||
}
|
||||
Console.WriteLine(DateTime.Now);
|
||||
//保存数据
|
||||
await DbHelp.db.BeginTranAsync();
|
||||
try
|
||||
{
|
||||
var order = new OutOrder()
|
||||
{
|
||||
OrderNumber = request.OrderNumber,
|
||||
OrderSource = request.OrderSource,
|
||||
OrderType = request.OrderType,
|
||||
CreateUser = request.UserName,
|
||||
};
|
||||
order.Id = await DbHelp.db.Insertable(order).ExecuteReturnIdentityAsync();
|
||||
request.ItemList.ForEach(async item =>
|
||||
{
|
||||
var orderDetail = new OutOrderDetail()
|
||||
{
|
||||
OrderId = order.Id,
|
||||
OrderNumber = order.OrderNumber,
|
||||
MatCode = item.MatCode,
|
||||
MatBatch = item.MatBatch,
|
||||
ReqQty = item.ReqQty,
|
||||
CreateUser = request.UserName
|
||||
};
|
||||
await DbHelp.db.Insertable(orderDetail).ExecuteCommandAsync();
|
||||
});
|
||||
await DbHelp.db.CommitTranAsync();
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 200,
|
||||
Message = "单据同步成功!"
|
||||
}; ;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await DbHelp.db.RollbackTranAsync();
|
||||
Console.WriteLine(ex.Message);
|
||||
return new ResponseBase()
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"单据同步失败:{ex.Message}"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ResponseBase> SysOutOrderByMatSn(SysOutOrderByMatSnRequest request)
|
||||
{
|
||||
|
||||
//参数合法性校验
|
||||
if (request.SnList == null || request.SnList.Count == 0)
|
||||
{
|
||||
return new ResponseBase()
|
||||
{
|
||||
Code = 201,
|
||||
Message = "单据同步失败:缺少物料明细!"
|
||||
};
|
||||
}
|
||||
//库存有无校验 & 库存已锁校验
|
||||
try
|
||||
{
|
||||
await DbHelp.db.BeginTranAsync();
|
||||
var inventoryDetails = await DbHelp.db.Queryable<InventoryDetail>()
|
||||
.Where(t => request.SnList.Contains(t.MatSN))
|
||||
.TranLock(DbLockType.Wait)
|
||||
.ToListAsync();
|
||||
if (inventoryDetails.Count < request.SnList.Count)//库存的物料少于需求的物料数量
|
||||
{
|
||||
var existsSns = inventoryDetails.Select(t => t.MatSN).ToList();
|
||||
request.SnList.RemoveAll(t => existsSns.Contains(t));
|
||||
await DbHelp.db.RollbackTranAsync();
|
||||
//返回提示哪些物料库存不存在
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 201,
|
||||
Message = "单据同步失败:存在物料不在库存中!",
|
||||
Data = request.SnList
|
||||
|
||||
};
|
||||
}
|
||||
else if (inventoryDetails.Where(t => t.IsLocked).Any())
|
||||
{
|
||||
await DbHelp.db.RollbackTranAsync();
|
||||
//返回提示哪些物料库存已被锁定
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 201,
|
||||
Message = "单据同步失败:存在物料被锁定!",
|
||||
Data = inventoryDetails.Where(t => t.IsLocked).Select(t => t.MatSN).ToList()
|
||||
};
|
||||
}
|
||||
|
||||
//判断是否有单据号 没有单据号系统自动生成一个
|
||||
if (string.IsNullOrEmpty(request.OrderNumber))
|
||||
{
|
||||
request.OrderNumber = GetOrderNumber();
|
||||
}
|
||||
|
||||
#region 保存数据
|
||||
|
||||
//锁库存
|
||||
inventoryDetails.ForEach(t =>
|
||||
{
|
||||
t.IsLocked = false;
|
||||
});
|
||||
var lockTask = DbHelp.db.Updateable(inventoryDetails).ExecuteCommandAsync();
|
||||
|
||||
//保存数据
|
||||
var order = new OutOrder()
|
||||
{
|
||||
OrderNumber = request.OrderNumber,
|
||||
OrderSource = request.OrderSource,
|
||||
OrderType = request.OrderType,
|
||||
CreateUser = request.UserName,
|
||||
};
|
||||
order.Id = await DbHelp.db.Insertable(order).ExecuteReturnIdentityAsync();
|
||||
|
||||
//通过库存数据保存出库物料明细表
|
||||
var matDetailTasks = inventoryDetails.Select(async t =>
|
||||
{
|
||||
var orderMatDetail = new OutOrderMatDetail()
|
||||
{
|
||||
OrderId = order.Id,
|
||||
OrderNumber = order.OrderNumber,
|
||||
InventoryDetailId = t.Id,
|
||||
StoreId = t.StoreId,
|
||||
StoreCode = t.StoreCode,
|
||||
MatSN = t.MatSN,
|
||||
MatCode = t.MatCode,
|
||||
MatName = t.MatName,
|
||||
MatSpec = t.MatSpec,
|
||||
MatBatch = t.MatBatch,
|
||||
MatQty = t.MatQty,
|
||||
MatSupplier = t.MatSupplier,
|
||||
MatCustomer = t.MatCustomer,
|
||||
CreateUser = request.UserName
|
||||
};
|
||||
await DbHelp.db.Insertable(orderMatDetail).ExecuteCommandAsync();
|
||||
}).ToList();
|
||||
|
||||
await lockTask;
|
||||
await Task.WhenAll(matDetailTasks);
|
||||
|
||||
await DbHelp.db.CommitTranAsync();
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"单据同步成功!",
|
||||
Data = order.Id
|
||||
};
|
||||
#endregion
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await DbHelp.db.RollbackTranAsync();
|
||||
return new ResponseBase()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"单据同步失败:{ex.Message}"
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public async Task<ResponseBase> GetOutOrderList(GetOutOrderListRequest request)
|
||||
{
|
||||
//直接查询
|
||||
var outOrderList = await DbHelp.db.Queryable<OutOrder>()
|
||||
.WhereIF(!string.IsNullOrEmpty(request.OrderNumber), t => t.OrderNumber.Contains(request.OrderNumber))
|
||||
.Skip((request.PageNumber - 1) * request.PageSize).Take(request.PageSize)
|
||||
.ToListAsync();
|
||||
return new PageQueryResponse<OutOrder>()
|
||||
{
|
||||
Code = 200,
|
||||
Message = "success",
|
||||
Data = new PageQueryResponseData<OutOrder>()
|
||||
{
|
||||
Lists = outOrderList,
|
||||
Count = outOrderList.Count
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<ResponseBase> GetOutOrderDetail(GetOutOrderDetailRequest request)
|
||||
{
|
||||
OutOrder outOrder = null;
|
||||
|
||||
#region 查询出库单
|
||||
if (request.OrderId != 0)
|
||||
{
|
||||
outOrder = await DbHelp.db.Queryable<OutOrder>().Where(t => t.Id == request.OrderId).FirstAsync();
|
||||
if (outOrder == null)
|
||||
{
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"查询失败:不存在Id为{request.OrderId}的出库单!",
|
||||
};
|
||||
}
|
||||
}
|
||||
else if (string.IsNullOrEmpty(request.OrderNumber))
|
||||
{
|
||||
outOrder = await DbHelp.db.Queryable<OutOrder>().Where(t => t.OrderNumber == request.OrderNumber)
|
||||
.FirstAsync();
|
||||
if (outOrder == null)
|
||||
{
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"查询失败:不存在单据号为{request.OrderNumber}的出库单!",
|
||||
};
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"查询失败:缺少必要参数!",
|
||||
};
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 查询出库单明细
|
||||
var orderDetailTask = DbHelp.db.Queryable<OutOrderDetail>()
|
||||
.Where(t => t.OrderId == outOrder.Id)
|
||||
.ToListAsync();
|
||||
#endregion
|
||||
|
||||
#region 出库物料明细
|
||||
var orderMatDetailTask = DbHelp.db.Queryable<OutOrderMatDetail>()
|
||||
.Where(t => t.OrderId == outOrder.Id)
|
||||
.ToListAsync();
|
||||
#endregion
|
||||
var orderDetail = await orderDetailTask;
|
||||
var orderMatDetail = await orderMatDetailTask;
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 200,
|
||||
Message = "Success",
|
||||
Data = new
|
||||
{
|
||||
OrderDetailLists = orderDetail,
|
||||
OrderMatDetailLists = orderMatDetail,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
private string GetOrderNumber()
|
||||
{
|
||||
var orderNumber = "PD" + DateTime.Now.ToString("yyyyMMddHHmmss");
|
||||
return orderNumber;
|
||||
}
|
||||
|
||||
public async Task<ResponseBase> GoInOutstore(GetOutOrderDetailRequest request)
|
||||
{
|
||||
//先找到所有物料
|
||||
|
||||
//分组 按物料找到对应得货架编码
|
||||
|
||||
//对应的货架进入出库模式 亮灯
|
||||
|
||||
//返回
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 200,
|
||||
Message = "Success",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<ResponseBase> GoOutOutstore(GetOutOrderDetailRequest request)
|
||||
{
|
||||
//找到出库单号一致的货架列表
|
||||
var shelves = ShelfManager.Shelves.Where(t => t.OutOrderNumber == request.OrderNumber)
|
||||
.ToList();
|
||||
//退出出库模式
|
||||
shelves.ForEach(t =>
|
||||
{
|
||||
t.GoOutOutstore();
|
||||
});
|
||||
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 200,
|
||||
Message = "Success",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
240
WCS.BLL/Services/Service/StoreInfoService.cs
Normal file
240
WCS.BLL/Services/Service/StoreInfoService.cs
Normal file
@ -0,0 +1,240 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using TouchSocket.Core;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.DAL;
|
||||
using WCS.DAL.AuthDbModel;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.DAL.DbModels;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel;
|
||||
using WCS.Model.ApiModel.StoreInfo;
|
||||
using WCS.Model.ApiModel.User;
|
||||
|
||||
namespace WCS.BLL.Services.Service
|
||||
{
|
||||
public class StoreInfoService : IStoreInfoService
|
||||
{
|
||||
public StoreInfoService() { }
|
||||
|
||||
public async Task<PageQueryResponse<ShelfInfo>> GetShelves(GetShelvesRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
var recordsQueryable = DbHelp.db.Queryable<ShelfInfo>()
|
||||
.WhereIF(request.ShelfTypeId != 0, t => t.ShelfTypeId == request.ShelfTypeId)
|
||||
.WhereIF(!string.IsNullOrEmpty(request.ShelfCode), t => t.ShelfCode.Contains(request.ShelfCode));
|
||||
|
||||
var totalCount = await recordsQueryable.CountAsync();
|
||||
var records = await recordsQueryable
|
||||
.Skip((request.PageNumber - 1) * request.PageSize).Take(request.PageSize)
|
||||
.ToListAsync();
|
||||
//生成序号
|
||||
for (int i = 0; i < records.Count; i++)
|
||||
{
|
||||
records[i].RowNumber = (request.PageNumber - 1) * 10 + i + 1;
|
||||
}
|
||||
return new PageQueryResponse<ShelfInfo>()
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"success",
|
||||
Data = new PageQueryResponseData<ShelfInfo>()
|
||||
{
|
||||
TotalCount = totalCount,
|
||||
MaxPage = request.PageSize == 0 ? 0 : (int)Math.Ceiling((decimal)totalCount / request.PageSize),
|
||||
Count = records.Count,
|
||||
Lists = records.ToList()
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new PageQueryResponse<ShelfInfo>()
|
||||
{
|
||||
Code = 300,
|
||||
Message = $"操作失败:{ex.Message}",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ResponseCommon<object>> addOrUpdateShelfInfo(AddShelfInfoRequest<ShelfInfo> request)
|
||||
{
|
||||
try
|
||||
{
|
||||
var shelfnfo = await DbHelp.db.Queryable<ShelfInfo>()
|
||||
.Where(t => t.ShelfCode == request.ShelfInfo.ShelfCode)
|
||||
.FirstAsync();
|
||||
//修改货架信息
|
||||
if (request.AddOrUpdate == AddOrUpdate.Update)
|
||||
{
|
||||
var existId = shelfnfo == null ? 0 : shelfnfo.Id;
|
||||
|
||||
shelfnfo = await DbHelp.db.Queryable<ShelfInfo>()
|
||||
.Where(t => t.Id == request.ShelfInfo.Id)
|
||||
.FirstAsync();
|
||||
if (shelfnfo == null)
|
||||
{
|
||||
return new ResponseCommon<Object>
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"更新货架信息失败:货架{request.ShelfInfo.ShelfCode}不存在!",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
else if (existId != shelfnfo.Id)
|
||||
{
|
||||
return new ResponseCommon<Object>
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"更新货架信息失败:已存在货架编码{request.ShelfInfo.ShelfCode}!",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
shelfnfo.ShelfCode = request.ShelfInfo.ShelfCode;
|
||||
shelfnfo.ShelfTypeId = request.ShelfInfo.ShelfTypeId;
|
||||
shelfnfo.ShelfTypeName = request.ShelfInfo.ShelfTypeName;
|
||||
shelfnfo.Rowcounts = request.ShelfInfo.Rowcounts;
|
||||
shelfnfo.Columncounts = request.ShelfInfo.Columncounts;
|
||||
shelfnfo.LightId = request.ShelfInfo.LightId;
|
||||
shelfnfo.ClientIp = request.ShelfInfo.ClientIp;
|
||||
shelfnfo.GroupName = request.ShelfInfo.GroupName;
|
||||
shelfnfo.IsBind = request.ShelfInfo.IsBind;
|
||||
shelfnfo.BindShelfCode = request.ShelfInfo.BindShelfCode;
|
||||
|
||||
var rowNum = await DbHelp.db.Updateable(shelfnfo).ExecuteCommandAsync();
|
||||
if (rowNum == 0)
|
||||
{
|
||||
return new ResponseCommon<Object>
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"更新货架信息失败:请重试!",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ResponseCommon<Object>
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"更新货架信息成功!",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (request.AddOrUpdate == AddOrUpdate.Add)
|
||||
{
|
||||
if (shelfnfo != null)
|
||||
{
|
||||
return new ResponseCommon<Object>
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"货架信息失败:货架{request.ShelfInfo.ShelfCode}已存在!",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
var newShelfInfo = new ShelfInfo()
|
||||
{
|
||||
ShelfCode = request.ShelfInfo.ShelfCode,
|
||||
ShelfTypeId = request.ShelfInfo.ShelfTypeId,
|
||||
ShelfTypeName = request.ShelfInfo.ShelfTypeName,
|
||||
Rowcounts = request.ShelfInfo.Rowcounts,
|
||||
Columncounts = request.ShelfInfo.Columncounts,
|
||||
LightId = request.ShelfInfo.LightId,
|
||||
ClientIp = request.ShelfInfo.ClientIp,
|
||||
GroupName = request.ShelfInfo.GroupName,
|
||||
IsBind = request.ShelfInfo.IsBind,
|
||||
BindShelfCode = request.ShelfInfo.BindShelfCode,
|
||||
};
|
||||
var rowNum = await DbHelp.db.Insertable(newShelfInfo).ExecuteCommandAsync();
|
||||
if (rowNum == 0)
|
||||
{
|
||||
return new ResponseCommon<Object>
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"添加货架信息失败:请重试!",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ResponseCommon<Object>
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"添加货架信息成功!",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (request.AddOrUpdate == AddOrUpdate.Delete)
|
||||
{
|
||||
shelfnfo = await DbHelp.db.Queryable<ShelfInfo>()
|
||||
.Where(t => t.Id == request.ShelfInfo.Id)
|
||||
.FirstAsync();
|
||||
if (shelfnfo == null)
|
||||
{
|
||||
return new ResponseCommon<Object>
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"删除货架信息失败:货架{request.ShelfInfo}不存在!",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
var rowNum = await DbHelp.db.Deleteable(shelfnfo).ExecuteCommandAsync();
|
||||
if (rowNum == 0)
|
||||
{
|
||||
return new ResponseCommon<Object>
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"删除货架信息失败:请重试!",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ResponseCommon<Object>
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"删除货架信息成功!",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var response = new ResponseCommon<Object>
|
||||
{
|
||||
Code = 300,
|
||||
Message = "不支持的操作!",
|
||||
Data = null
|
||||
};
|
||||
return response;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var response = new ResponseCommon<Object>
|
||||
{
|
||||
Code = 300,
|
||||
Message = $"操作失败:{ex.Message}",
|
||||
Data = null
|
||||
};
|
||||
return response;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
464
WCS.BLL/Services/Service/UserService.cs
Normal file
464
WCS.BLL/Services/Service/UserService.cs
Normal file
@ -0,0 +1,464 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using TouchSocket.Core;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.DAL;
|
||||
using WCS.DAL.AuthDbModel;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel;
|
||||
using WCS.Model.ApiModel.User;
|
||||
|
||||
namespace WCS.BLL.Services.Service
|
||||
{
|
||||
public class UserService : IUserService
|
||||
{
|
||||
public UserService() { }
|
||||
|
||||
public async Task<ResponseCommon<List<UserBase>>> GetUsers(GetUsersRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
var users = await AuthDbHelp.db.Queryable<UserBase>()
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(request.Info), o => o.LoginName.Contains(request.Info.Trim()))
|
||||
.OrderBy(o => o.Id)
|
||||
.ToListAsync();
|
||||
//返回内容密码处理
|
||||
if (users != null && users.Count > 0)
|
||||
{
|
||||
users.ForEach(t =>
|
||||
{
|
||||
t.Password = "******";
|
||||
});
|
||||
}
|
||||
var response = new ResponseCommon<List<UserBase>>()
|
||||
{
|
||||
Code = 200,
|
||||
Message = "success",
|
||||
Data = users
|
||||
};
|
||||
return response;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var response = new ResponseCommon<List<UserBase>>()
|
||||
{
|
||||
Code = 200,
|
||||
Message = "success",
|
||||
Data = null
|
||||
};
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ResponseCommon<object>> AddUser(AddUserRequest<UserModel> request)
|
||||
{
|
||||
try
|
||||
{
|
||||
var user = await AuthDbHelp.db.Queryable<UserBase>()
|
||||
.Where(t => t.LoginName == request.User.LoginName)
|
||||
.FirstAsync();
|
||||
if (request.AddOrUpdate == AddOrUpdate.Update)
|
||||
{
|
||||
if (user == null)
|
||||
{
|
||||
return new ResponseCommon<Object>
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"更新用户信息失败:用户{user.LoginName}不存在!",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
user.Password = request.User.Password;
|
||||
user.LoginName = request.User.LoginName;
|
||||
user.RoleIds = request.User.RoleIds;
|
||||
var rowNum = await AuthDbHelp.db.Updateable(user).ExecuteCommandAsync();
|
||||
if (rowNum == 0)
|
||||
{
|
||||
return new ResponseCommon<Object>
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"更新用户信息失败:请重试!",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ResponseCommon<Object>
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"更新用户信息成功!",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if (request.AddOrUpdate == AddOrUpdate.Add)
|
||||
{
|
||||
if (user != null)
|
||||
{
|
||||
return new ResponseCommon<Object>
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"添加用户失败:用户{request.User.LoginName}已存在",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
var newUser = new UserBase()
|
||||
{
|
||||
LoginName = request.User.LoginName,
|
||||
Password = request.User.Password,
|
||||
RoleIds = request.User.RoleIds,
|
||||
IsAdmin = request.User.IsAdmin,
|
||||
Time = request.User.Time
|
||||
};
|
||||
var rowNum = await AuthDbHelp.db.Insertable(newUser).ExecuteCommandAsync();
|
||||
if (rowNum == 0)
|
||||
{
|
||||
return new ResponseCommon<Object>
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"添加用户失败:请重试!",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ResponseCommon<Object>
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"添加用户成功!",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (request.AddOrUpdate == AddOrUpdate.Delete)
|
||||
{
|
||||
if (user == null)
|
||||
{
|
||||
return new ResponseCommon<Object>
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"删除用户失败:用户{request.User.LoginName}不存在",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
var rowNum = await AuthDbHelp.db.Deleteable(user).ExecuteCommandAsync();
|
||||
if (rowNum == 0)
|
||||
{
|
||||
return new ResponseCommon<Object>
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"删除用户失败:请重试!",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ResponseCommon<Object>
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"删除用户成功!",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var response = new ResponseCommon<Object>
|
||||
{
|
||||
Code = 300,
|
||||
Message = "不支持的操作!",
|
||||
Data = null
|
||||
};
|
||||
return response;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var response = new ResponseCommon<Object>
|
||||
{
|
||||
Code = 300,
|
||||
Message = $"操作失败:{ex.Message}",
|
||||
Data = null
|
||||
};
|
||||
return response;
|
||||
}
|
||||
}
|
||||
public async Task<ResponseCommon<List<RoleBase>>> GetRoles(GetUsersRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
var users = await AuthDbHelp.db.Queryable<RoleBase>()
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(request.Info), o => o.Name.Contains(request.Info.Trim()))
|
||||
.OrderBy(o => o.Id)
|
||||
.ToListAsync();
|
||||
var response = new ResponseCommon<List<RoleBase>>()
|
||||
{
|
||||
Code = 200,
|
||||
Message = "success",
|
||||
Data = users
|
||||
};
|
||||
return response;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var response = new ResponseCommon<List<RoleBase>>()
|
||||
{
|
||||
Code = 200,
|
||||
Message = "success",
|
||||
Data = null
|
||||
};
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ResponseCommon<object>> AddRole(AddRoleRequest<RoleModel> request)
|
||||
{
|
||||
try
|
||||
{
|
||||
var Role = await AuthDbHelp.db.Queryable<RoleBase>()
|
||||
.Where(t => t.Name == request.Role.Name)
|
||||
.FirstAsync();
|
||||
if (request.AddOrUpdate == AddOrUpdate.Update)
|
||||
{
|
||||
if (Role == null)
|
||||
{
|
||||
return new ResponseCommon<Object>
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"更新角色信息失败:角色{Role.Name}不存在!",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
Role.IsAdmin = request.Role.IsAdmin;
|
||||
Role.Name = request.Role.Name;
|
||||
Role.Auths = request.Role.Auths;
|
||||
Role.Time = request.Role.Time;
|
||||
var rowNum = await AuthDbHelp.db.Updateable(Role).ExecuteCommandAsync();
|
||||
if (rowNum == 0)
|
||||
{
|
||||
return new ResponseCommon<Object>
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"更新角色信息失败:请重试!",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ResponseCommon<Object>
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"更新角色信息成功!",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if (request.AddOrUpdate == AddOrUpdate.Add)
|
||||
{
|
||||
if (Role != null)
|
||||
{
|
||||
return new ResponseCommon<Object>
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"添加角色失败:角色{request.Role.Name}已存在",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
var newRole = new RoleBase()
|
||||
{
|
||||
Name = request.Role.Name,
|
||||
Auths = request.Role.Auths,
|
||||
IsAdmin = request.Role.IsAdmin,
|
||||
Time = request.Role.Time
|
||||
};
|
||||
var rowNum = await AuthDbHelp.db.Insertable(newRole).ExecuteCommandAsync();
|
||||
if (rowNum == 0)
|
||||
{
|
||||
return new ResponseCommon<Object>
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"添加角色失败:请重试!",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ResponseCommon<Object>
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"添加角色成功!",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (request.AddOrUpdate == AddOrUpdate.Delete)
|
||||
{
|
||||
if (Role == null)
|
||||
{
|
||||
return new ResponseCommon<Object>
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"删除角色失败:角色{request.Role.Name}不存在",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
var isContains = AuthDbHelp.db.Queryable<UserBase>().Select(o => o.RoleIds).ToList().SelectMany(o => o).Contains(Role.Id);
|
||||
if (isContains)
|
||||
{
|
||||
return new ResponseCommon<Object>
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"删除角色失败:角色{request.Role.Name}已被用户使用!",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
var rowNum = await AuthDbHelp.db.Deleteable(Role).ExecuteCommandAsync();
|
||||
if (rowNum == 0)
|
||||
{
|
||||
return new ResponseCommon<Object>
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"删除角色失败:请重试!",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ResponseCommon<Object>
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"删除角色成功!",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var response = new ResponseCommon<Object>
|
||||
{
|
||||
Code = 300,
|
||||
Message = "不支持的操作!",
|
||||
Data = null
|
||||
};
|
||||
return response;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var response = new ResponseCommon<Object>
|
||||
{
|
||||
Code = 300,
|
||||
Message = $"操作失败:{ex.Message}",
|
||||
Data = null
|
||||
};
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ResponseCommon<UserBase>> UserLogin(UserLoginRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
UserBase user = null;
|
||||
|
||||
if (request.IsNoLogin)//不登录模式 不校验密码
|
||||
{
|
||||
user = await AuthDbHelp.db.Queryable<UserBase>()
|
||||
.Where(t => t.LoginName == "admin")
|
||||
.FirstAsync();
|
||||
}
|
||||
else//登录模式需要校验密码
|
||||
{
|
||||
user = await AuthDbHelp.db.Queryable<UserBase>()
|
||||
.Where(t => t.LoginName == request.UserName)
|
||||
.FirstAsync();
|
||||
if (user == null)
|
||||
{
|
||||
return new ResponseCommon<UserBase>()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"登录失败:用户名[{request.UserName}]不存在!",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
else if (user.Password != request.PassWord)
|
||||
{
|
||||
return new ResponseCommon<UserBase>()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"登录失败:密码错误!",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
//加载用户的权限
|
||||
if (user != null)
|
||||
{
|
||||
if (user.IsAdmin)
|
||||
{
|
||||
user.GetRoles = await AuthDbHelp.db.Queryable<RoleBase>()
|
||||
.OrderBy(o => o.Id)
|
||||
.ToListAsync();
|
||||
}
|
||||
else if (user.RoleIds == null || !user.RoleIds.Any())
|
||||
{
|
||||
user.GetRoles = new List<RoleBase>();
|
||||
}
|
||||
else
|
||||
{
|
||||
user.GetRoles = await AuthDbHelp.db.Queryable<RoleBase>()
|
||||
.Where(t => user.RoleIds.Contains(t.Id))
|
||||
.OrderBy(o => o.Id)
|
||||
.ToListAsync();
|
||||
}
|
||||
}
|
||||
|
||||
//返回字串不返回密码
|
||||
user.Password = "***";
|
||||
|
||||
var response = new ResponseCommon<UserBase>()
|
||||
{
|
||||
Code = 200,
|
||||
Message = "success",
|
||||
Data = user
|
||||
};
|
||||
return response;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var response = new ResponseCommon<UserBase>()
|
||||
{
|
||||
Code = 300,
|
||||
Message = $"登录失败:{ex.Message}",
|
||||
Data = null
|
||||
};
|
||||
return response;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
182
WCS.BLL/Tool/Api/ApiHelp.cs
Normal file
182
WCS.BLL/Tool/Api/ApiHelp.cs
Normal file
@ -0,0 +1,182 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using WCS.BLL.Tool.Api.Models;
|
||||
|
||||
namespace WCS.BLL.Tool.Api
|
||||
{
|
||||
public static class ApiHelp
|
||||
{
|
||||
public static HttpClient httpClient;
|
||||
static ApiHelp()
|
||||
{
|
||||
httpClient = new HttpClient();
|
||||
httpClient.Timeout = TimeSpan.FromSeconds(5);
|
||||
httpClient.DefaultRequestHeaders.Add("User-Agent", "Chrome/95.0.4638.69 Safari/537.36");
|
||||
//ServicePointManager.Expect100Continue = false;
|
||||
}
|
||||
|
||||
public static ApiResult Get(string uri, object? query = null, object? body = null)
|
||||
{
|
||||
return Send(HttpMethod.Get, uri, query, body);
|
||||
}
|
||||
|
||||
public static ApiResult Get(IEnumerable<object> uri, object? query = null, object? body = null)
|
||||
{
|
||||
return Send(HttpMethod.Get, uri, query, body);
|
||||
}
|
||||
|
||||
public static ApiResult<T> Get<T>(string uri, object? query = null, object? body = null)
|
||||
{
|
||||
return Send<T>(HttpMethod.Get, uri, query, body);
|
||||
}
|
||||
|
||||
public static ApiResult<T> Get<T>(IEnumerable<object> uri, object? query = null, object? body = null)
|
||||
{
|
||||
return Send<T>(HttpMethod.Get, uri, query, body);
|
||||
}
|
||||
|
||||
public static ApiResult Post(string uri, object? body = null, object? query = null)
|
||||
{
|
||||
return Send(HttpMethod.Post, uri, query, body);
|
||||
}
|
||||
|
||||
public static ApiResult Post(IEnumerable<object> uri, object? body = null, object? query = null)
|
||||
{
|
||||
return Send(HttpMethod.Post, uri, query, body);
|
||||
}
|
||||
|
||||
public static ApiResult<T> Post<T>(string uri, object? body = null, object? query = null)
|
||||
{
|
||||
return Send<T>(HttpMethod.Post, uri, query, body);
|
||||
}
|
||||
|
||||
public static ApiResult<T> Post<T>(IEnumerable<object> uri, object? body = null, object? query = null)
|
||||
{
|
||||
return Send<T>(HttpMethod.Post, uri, query, body);
|
||||
}
|
||||
|
||||
public static ApiResult Send(HttpMethod method, string uri, object? query = null, object? body = null)
|
||||
{
|
||||
return Send(method, new string[] { uri }, query, body);
|
||||
}
|
||||
|
||||
public static ApiResult Send(HttpMethod method, IEnumerable<object> uri, object? query = null, object? body = null)
|
||||
{
|
||||
HttpRequestMessage httpRequestMessage = new HttpRequestMessage(method, "".AppendPathSegments(uri).SetQueryParams(query));
|
||||
|
||||
if (body != null)
|
||||
{
|
||||
var content = new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json");
|
||||
httpRequestMessage.Content = content;
|
||||
}
|
||||
|
||||
var re = httpClient.SendAsync(httpRequestMessage).Result;
|
||||
if (!re.IsSuccessStatusCode)
|
||||
return new ApiResult() { Code = ((int)re.StatusCode).ToString() };
|
||||
|
||||
var con = re.Content.ReadAsStringAsync().Result;
|
||||
return JsonConvert.DeserializeObject<ApiResult>(con) ?? new ApiResult();
|
||||
}
|
||||
|
||||
public static ApiResult<T> Send<T>(HttpMethod method, string uri, object? query = null, object? body = null)
|
||||
{
|
||||
return Send<T>(method, new string[] { uri }, query, body);
|
||||
}
|
||||
|
||||
public static ApiResult<T> Send<T>(HttpMethod method, IEnumerable<object> uri, object? query = null, object? body = null)
|
||||
{
|
||||
HttpRequestMessage httpRequestMessage = new HttpRequestMessage(method, "".AppendPathSegments(uri).SetQueryParams(query));
|
||||
|
||||
if (body != null)
|
||||
{
|
||||
var content = new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json");
|
||||
httpRequestMessage.Content = content;
|
||||
}
|
||||
|
||||
var re = httpClient.SendAsync(httpRequestMessage).Result;
|
||||
if (!re.IsSuccessStatusCode)
|
||||
return new ApiResult<T>() { Code = ((int)re.StatusCode).ToString() };
|
||||
|
||||
var con = re.Content.ReadAsStringAsync().Result;
|
||||
return JsonConvert.DeserializeObject<ApiResult<T>>(con) ?? new ApiResult<T>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 追加路径片段(有更高要求可以使用Flurl库)
|
||||
/// </summary>
|
||||
/// <param name="url">地址,如 https://www.baidu.com</param>
|
||||
/// <param name="segments">路径片段</param>
|
||||
/// <returns>地址</returns>
|
||||
public static string AppendPathSegments(this string url, IEnumerable<object> segments)
|
||||
{
|
||||
string urlStr = url;
|
||||
foreach (var segment in segments)
|
||||
{
|
||||
var val = segment?.ToString();
|
||||
if (string.IsNullOrWhiteSpace(val))
|
||||
continue;
|
||||
|
||||
if (urlStr.EndsWith("/"))
|
||||
urlStr = urlStr.Substring(0, urlStr.Length - 1);
|
||||
|
||||
urlStr += val!.StartsWith("/") ? val : $"/{val}";
|
||||
}
|
||||
return urlStr;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置Query参数(有更高要求可以使用Flurl库)
|
||||
/// </summary>
|
||||
/// <param name="url">地址,如 https://www.baidu.com/s</param>
|
||||
/// <param name="values">参数,支持字典和对象</param>
|
||||
/// <returns>地址</returns>
|
||||
public static string SetQueryParams(this string url, object? values)
|
||||
{
|
||||
string urlStr = url;
|
||||
if (values == null)
|
||||
return urlStr;
|
||||
|
||||
List<string> kv = new List<string>();
|
||||
if (values is IEnumerable jh)
|
||||
{
|
||||
if (jh is IDictionary dict)
|
||||
{
|
||||
foreach (DictionaryEntry item in dict)
|
||||
kv.Add($"{item.Key?.ToString()}={item.Value?.ToString()}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var item in values.GetType().GetProperties())
|
||||
{
|
||||
if (item.CanRead)
|
||||
kv.Add($"{item.Name}={item.GetValue(values)?.ToString()}");
|
||||
}
|
||||
}
|
||||
|
||||
if (kv.Any())
|
||||
{
|
||||
if (!urlStr.Contains("?"))
|
||||
urlStr += "?";
|
||||
else
|
||||
{
|
||||
if (!urlStr.EndsWith("&"))
|
||||
urlStr += "&";
|
||||
}
|
||||
|
||||
urlStr += string.Join("&", kv);
|
||||
}
|
||||
|
||||
return urlStr;
|
||||
}
|
||||
}
|
||||
}
|
19
WCS.BLL/Tool/Api/Models/ApiResult.cs
Normal file
19
WCS.BLL/Tool/Api/Models/ApiResult.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WCS.BLL.Tool.Api.Models
|
||||
{
|
||||
public class ApiResult
|
||||
{
|
||||
public string Code { get; set; }
|
||||
public string Message { get; set; }
|
||||
}
|
||||
|
||||
public class ApiResult<T> : ApiResult
|
||||
{
|
||||
public T Data { get; set; }
|
||||
}
|
||||
}
|
161
WCS.BLL/Tool/Logs.cs
Normal file
161
WCS.BLL/Tool/Logs.cs
Normal file
@ -0,0 +1,161 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WCS.BLL.Config;
|
||||
using WCS.DAL;
|
||||
using WCS.Model;
|
||||
|
||||
namespace WCS.BLL
|
||||
{
|
||||
/// <summary>
|
||||
/// 日志类型
|
||||
/// </summary>
|
||||
public enum LogsType
|
||||
{
|
||||
/// <summary>
|
||||
/// 信息
|
||||
/// </summary>
|
||||
Info,
|
||||
/// <summary>
|
||||
/// 警告
|
||||
/// </summary>
|
||||
Warning,
|
||||
/// <summary>
|
||||
/// 错误
|
||||
/// </summary>
|
||||
Err,
|
||||
/// <summary>
|
||||
/// 数据库错误
|
||||
/// </summary>
|
||||
DbErr,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 日志
|
||||
/// </summary>
|
||||
public static class Logs
|
||||
{
|
||||
static object obj = new object();
|
||||
const string logExtension = ".log";
|
||||
/// <summary>
|
||||
/// 写入日志失败
|
||||
/// </summary>
|
||||
public static Action<IEnumerable<string>, DateTime, LogsType, Exception> WriteErr = null;
|
||||
|
||||
/// <summary>
|
||||
/// 写入日志
|
||||
/// </summary>
|
||||
/// <param name="content">内容</param>
|
||||
/// <param name="type">类型</param>
|
||||
/// <returns>是否写入成功</returns>
|
||||
public static void Write(IEnumerable<string> content, LogsType type = LogsType.Info)
|
||||
{
|
||||
if (content == null || !content.Any())
|
||||
return;
|
||||
|
||||
var dt = DateTime.Now;
|
||||
string hms = dt.ToString("HH:mm:ss.fff");
|
||||
List<string> lines = new List<string>(content.Count());
|
||||
|
||||
try
|
||||
{
|
||||
string path = Path.Combine(Config.LocalFile.LogDir, type.ToString(), $"{(dt.ToString("yyyyMMdd"))}{logExtension}");
|
||||
foreach (var item in content)
|
||||
lines.AddRange($"[{hms}]{item}".Split(new string[] { Environment.NewLine }, StringSplitOptions.None));
|
||||
|
||||
lock (obj)
|
||||
{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
||||
File.AppendAllLines(path, lines, Encoding.UTF8);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
WriteErr?.Invoke(content, dt, type, ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 写入日志
|
||||
/// </summary>
|
||||
/// <param name="content">内容对象</param>
|
||||
/// <param name="type">类型</param>
|
||||
/// <returns>是否写入成功</returns>
|
||||
public static void Write(string content, LogsType type = LogsType.Info)
|
||||
{
|
||||
Write(new string[] { content }, type);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 写入日志
|
||||
/// </summary>
|
||||
/// <param name="content">内容对象</param>
|
||||
/// <param name="type">类型</param>
|
||||
/// <returns>是否写入成功</returns>
|
||||
public static void Write(object content, LogsType type = LogsType.Info)
|
||||
{
|
||||
Write(JsonConvert.SerializeObject(content), type);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 写入日志
|
||||
/// </summary>
|
||||
/// <param name="content">内容</param>
|
||||
/// <param name="contentTitle">内容标题</param>
|
||||
/// <param name="type">类型</param>
|
||||
/// <returns>是否写入成功</returns>
|
||||
public static void Write(object content, string contentTitle, LogsType type = LogsType.Info)
|
||||
{
|
||||
Write($"{contentTitle} {JsonConvert.SerializeObject(content)}", type);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 写入日志
|
||||
/// </summary>
|
||||
/// <param name="ex">错误</param>
|
||||
/// <returns>是否写入成功</returns>
|
||||
public static void Write(Exception ex, LogsType type = LogsType.Err)
|
||||
{
|
||||
Write(ex.ToString(), type);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清除日志
|
||||
/// </summary>
|
||||
/// <param name="time">保留时间</param>
|
||||
/// <returns>清理的大小(字节)</returns>
|
||||
public static long Clear(TimeSpan time)
|
||||
{
|
||||
long size = 0;
|
||||
var rs = EnumHelps.GetEnumList(typeof(LogsType));
|
||||
foreach (var item in rs)
|
||||
{
|
||||
try
|
||||
{
|
||||
var path = Path.Combine(Config.LocalFile.LogDir, item);
|
||||
DirectoryInfo directoryInfo = new DirectoryInfo(path);
|
||||
if (!directoryInfo.Exists)
|
||||
continue;
|
||||
|
||||
var files = directoryInfo.GetFiles($"**{logExtension}", SearchOption.TopDirectoryOnly);
|
||||
var fileDel = files.Where(o => o.CreationTime < (DateTime.Now - time));
|
||||
foreach (var item2 in fileDel)
|
||||
{
|
||||
size += item2.Length;
|
||||
item2.Delete();
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
return size;
|
||||
}
|
||||
}
|
||||
}
|
223
WCS.BLL/Tool/TCPClient.cs
Normal file
223
WCS.BLL/Tool/TCPClient.cs
Normal file
@ -0,0 +1,223 @@
|
||||
using System.Collections.Concurrent;
|
||||
using System.Text;
|
||||
using TouchSocket.Core;
|
||||
using TouchSocket.Sockets;
|
||||
|
||||
|
||||
namespace WCS.BLL
|
||||
{
|
||||
/// <summary>
|
||||
/// 对TouchSocket的封装 主要完成TCP的连接 状态更新 发送接收通信
|
||||
/// </summary>
|
||||
public class TCPClient
|
||||
{
|
||||
public string RemoteIPHost { get; set; } = "127.0.0.1:20002";
|
||||
|
||||
public string BindIPHost { get; set; } = "127.0.0.1:20003";
|
||||
|
||||
public bool IsOnline { get; set; } = false;
|
||||
|
||||
//can模块协议前缀
|
||||
public readonly byte[] Prefix = new byte[] { 0x08, 0x00, 0x00 };
|
||||
//can模块协议前缀长度
|
||||
public readonly int PreFixLength = 3;
|
||||
//协议数据部分长度
|
||||
public readonly int DataLength = 10;
|
||||
|
||||
public ConcurrentDictionary<int, MessageDto> MessageList { get; set; } = new ConcurrentDictionary<int, MessageDto>();
|
||||
|
||||
public TcpClient tcpClient { get; set; }
|
||||
|
||||
public object receivdLockObject = new object();
|
||||
public object sendLockObject = new object();
|
||||
|
||||
public bool Connect()
|
||||
{
|
||||
try
|
||||
{
|
||||
tcpClient.Connect();//调用连接,当连接不成功时,会抛出异常。
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//连接失败
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化配置连接
|
||||
/// </summary>
|
||||
/// <param name="remoteIPHost"></param>
|
||||
public TCPClient(string remoteIPHost, string bindIPHost)
|
||||
{
|
||||
try
|
||||
{
|
||||
RemoteIPHost = remoteIPHost;
|
||||
BindIPHost = bindIPHost;
|
||||
|
||||
tcpClient = new TcpClient();
|
||||
//载入配置
|
||||
tcpClient.Setup(new TouchSocketConfig()
|
||||
.SetRemoteIPHost(RemoteIPHost)
|
||||
.SetBindIPHost(BindIPHost)
|
||||
.ConfigurePlugins(a =>
|
||||
{
|
||||
//配置断线重连
|
||||
a.UseReconnection(-1, true, 1000);
|
||||
})
|
||||
.ConfigureContainer(a =>
|
||||
{
|
||||
//添加控制台日志注入
|
||||
a.AddConsoleLogger();
|
||||
}));
|
||||
|
||||
//添加接收事件 匹配已发送的指令
|
||||
tcpClient.Received += (client, e) =>
|
||||
{
|
||||
var data = e.ByteBlock.Buffer.Take((int)e.ByteBlock.Length).ToArray();
|
||||
e.ByteBlock.Clear();
|
||||
var len = data.Length;
|
||||
for (int index = 0; index < data.Length - PreFixLength; index++)
|
||||
{
|
||||
//协议拆包 通过前缀校验是否为完整数据包
|
||||
var prefixInData = data.Skip(index).Take(PreFixLength);
|
||||
var isEqual = prefixInData.SequenceEqual(Prefix);
|
||||
if (isEqual)
|
||||
{
|
||||
var dataTemp = data.Skip(index).Take(PreFixLength + DataLength).ToArray();
|
||||
if (dataTemp.Length < PreFixLength + DataLength)//拆包后不满足一条指令的长度
|
||||
{
|
||||
continue;
|
||||
}
|
||||
//获取返回指令的板子ID
|
||||
var boardId = (data[PreFixLength + 0] << 8) + data[PreFixLength + 1];
|
||||
//查询当前板子是否有待验证的指令
|
||||
var message = new MessageDto();
|
||||
MessageList.TryGetValue(boardId, out message);
|
||||
//功能位校验 功能位相同视为已响应指令 删除对应的指令
|
||||
if (message?.Message[PreFixLength + 2] == dataTemp[PreFixLength + 2])
|
||||
{
|
||||
MessageList.TryRemove(boardId, out message);
|
||||
}
|
||||
index += (PreFixLength + DataLength - 1);//每次循环index会+1 所以这里-1
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
tcpClient.Connected += (client, e) =>
|
||||
{
|
||||
this.IsOnline = true;
|
||||
return EasyTask.CompletedTask;
|
||||
};
|
||||
|
||||
tcpClient.Disconnected += (client, e) =>
|
||||
{
|
||||
this.IsOnline = false;
|
||||
return EasyTask.CompletedTask;
|
||||
};
|
||||
|
||||
//配置数据重发机制
|
||||
Task.Run(async () =>
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
try
|
||||
{
|
||||
//TO DO如果指令未回应n次 则取消重发
|
||||
Console.WriteLine(Thread.CurrentThread.ManagedThreadId);
|
||||
await Task.Delay(3000);
|
||||
if (MessageList.Count > 0)
|
||||
{
|
||||
Console.WriteLine(Thread.CurrentThread.ManagedThreadId);
|
||||
foreach (var item in MessageList)
|
||||
{
|
||||
if (item.Value.LastSendTime < DateTime.Now.AddSeconds(3))
|
||||
{
|
||||
tcpClient.Send(item.Value.Message);
|
||||
item.Value.SendTimes++;
|
||||
item.Value.LastSendTime = DateTime.Now;
|
||||
await Task.Delay(10);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public void Send(byte[] message)
|
||||
{
|
||||
var boardId = (message[3] << 8) + message[4];
|
||||
//记录发送指令 用于通信校验 同Id只校验最后一个指令
|
||||
////MessageList.AddOrUpdate(boardId, new MessageDto()
|
||||
////{
|
||||
//// ID = boardId,
|
||||
//// Message = message,
|
||||
////}, (key, oldValue) => oldValue = new MessageDto()
|
||||
////{
|
||||
//// ID = boardId,
|
||||
//// Message = message,
|
||||
////});
|
||||
lock (sendLockObject)
|
||||
{
|
||||
tcpClient.Send(message);
|
||||
//发送自带10ms间隔
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
}
|
||||
|
||||
//生成协议明细
|
||||
public byte[] GenerateMessage(int boardId, byte[] data)
|
||||
{
|
||||
var message = new byte[Prefix.Length + 2 + data.Length];
|
||||
var boardIdData = BitConverter.GetBytes(unchecked((short)boardId));
|
||||
// 检查是否需要交换字节
|
||||
if (BitConverter.IsLittleEndian)
|
||||
{
|
||||
// 如果是小端序系统,则交换字节
|
||||
byte temp = boardIdData[0];
|
||||
boardIdData[0] = boardIdData[1];
|
||||
boardIdData[1] = temp;
|
||||
}
|
||||
|
||||
Buffer.BlockCopy(Prefix, 0, message, 0, Prefix.Length);
|
||||
Buffer.BlockCopy(boardIdData, 0, message, Prefix.Length, boardIdData.Length);
|
||||
Buffer.BlockCopy(data, 0, message, Prefix.Length + boardIdData.Length, data.Length);
|
||||
return message;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//发送指令的记录
|
||||
public class MessageDto
|
||||
{
|
||||
public int ID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最后一次发送时间
|
||||
/// </summary>
|
||||
public DateTime LastSendTime { get; set; } = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// 发送内容
|
||||
/// </summary>
|
||||
public byte[] Message { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 发送次数
|
||||
/// </summary>
|
||||
public int SendTimes { get; set; } = 0;//第几次发送
|
||||
}
|
||||
|
||||
}
|
18
WCS.BLL/WCS.BLL.csproj
Normal file
18
WCS.BLL/WCS.BLL.csproj
Normal file
@ -0,0 +1,18 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="TouchSocket" Version="2.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\WCS.DAL\WCS.DAL.csproj" />
|
||||
<ProjectReference Include="..\WCS.Model\WCS.Model.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
83
WCS.DAL/AuthDbModel/AuthModels.cs
Normal file
83
WCS.DAL/AuthDbModel/AuthModels.cs
Normal file
@ -0,0 +1,83 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.Model;
|
||||
|
||||
namespace WCS.DAL.AuthDbModel
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户
|
||||
/// </summary>
|
||||
[SugarTable("User")]
|
||||
public class UserBase
|
||||
{
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||
public int Id { get; set; }
|
||||
/// <summary>
|
||||
/// 登录名
|
||||
/// </summary>
|
||||
public string LoginName { get; set; }
|
||||
/// <summary>
|
||||
/// 密码
|
||||
/// </summary>
|
||||
public string Password { get; set; }
|
||||
/// <summary>
|
||||
/// 角色id(json)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = StaticConfig.CodeFirst_BigString, IsJson = true)]
|
||||
public List<int> RoleIds { get; set; } = new List<int>();
|
||||
/// <summary>
|
||||
/// 角色名称
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public List<string> RoleNames { get => (RoleIds == null || !RoleIds.Any()) ? new List<string>() : AuthDbHelp.db.Queryable<RoleBase>().Where(o => RoleIds.Contains(o.Id)).Select(o => o.Name).ToList(); }
|
||||
/// <summary>
|
||||
/// 是否最大权限
|
||||
/// </summary>
|
||||
public bool IsAdmin { get; set; }
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime Time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 用户所属角色
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public List<RoleBase> GetRoles { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 角色
|
||||
/// </summary>
|
||||
[SugarTable("Role")]
|
||||
public class RoleBase
|
||||
{
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||
public int Id { get; set; }
|
||||
/// <summary>
|
||||
/// 角色名
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
/// <summary>
|
||||
/// 认证模块(json)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = StaticConfig.CodeFirst_BigString, IsJson = true)]
|
||||
public List<int> Auths { get; set; } = new List<int>();
|
||||
/// <summary>
|
||||
/// 认证模块名称
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public List<string> AuthNames { get => (Auths == null || !Auths.Any()) ? new List<string>() : EnumHelps.GetEnumDescriptionList(typeof(AuthEnum), true).Where(o => Auths.Contains(o.Item1)).Select(o => o.Item3).ToList(); }
|
||||
/// <summary>
|
||||
/// 是否最大权限
|
||||
/// </summary>
|
||||
public bool IsAdmin { get; set; }
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime Time { get; set; }
|
||||
}
|
||||
}
|
91
WCS.DAL/Db/AuthEnum/AuthDbHelp.cs
Normal file
91
WCS.DAL/Db/AuthEnum/AuthDbHelp.cs
Normal file
@ -0,0 +1,91 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WCS.DAL.AuthDbModel;
|
||||
|
||||
namespace WCS.DAL
|
||||
{
|
||||
/// <summary>
|
||||
/// 权限数据库
|
||||
/// </summary>
|
||||
public static class AuthDbHelp
|
||||
{
|
||||
public static SqlSugarScope db = new SqlSugarScope(new ConnectionConfig()
|
||||
{
|
||||
ConnectionString = $"Data Source={LocalFile.AuthDbPath};",
|
||||
DbType = DbType.Sqlite,//[Sqlite]安装[System.Data.SQLite.Core];
|
||||
IsAutoCloseConnection = true
|
||||
}, db =>
|
||||
{
|
||||
db.Aop.OnError = ex =>
|
||||
{
|
||||
//Logs.Write($@"{nameof(AuthDbHelp)}{Environment.NewLine}SQL:{ex?.Sql}{Environment.NewLine}Parametres:{JsonConvert.SerializeObject(ex?.Parametres)}{Environment.NewLine}InnerException:{ex?.InnerException?.ToString()}{Environment.NewLine}Exception:{ex?.ToString()}{Environment.NewLine}", LogsType.DbErr);
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 初始化数据
|
||||
/// </summary>
|
||||
public static void InitDb()
|
||||
{
|
||||
//不存在创建数据库,存在不会创建
|
||||
db.DbMaintenance.CreateDatabase();
|
||||
//创建表根据实体类
|
||||
db.CodeFirst.InitTables(typeof(UserBase), typeof(RoleBase));
|
||||
//初始化数据
|
||||
if (!db.Queryable<UserBase>().Any())
|
||||
{
|
||||
var dt = db.GetDate();
|
||||
var userBases = new List<UserBase>()
|
||||
{
|
||||
new UserBase ()
|
||||
{
|
||||
Id = 1,
|
||||
LoginName = "admin",
|
||||
Password = "",
|
||||
RoleIds = new List<int> () { 1 },
|
||||
IsAdmin = true,
|
||||
Time = dt,
|
||||
},
|
||||
new UserBase ()
|
||||
{
|
||||
Id = 2,
|
||||
LoginName = "czy",
|
||||
Password = "",
|
||||
RoleIds = new List<int> () { 2 },
|
||||
IsAdmin = false,
|
||||
Time = dt,
|
||||
},
|
||||
};
|
||||
var roleBases = new List<RoleBase>()
|
||||
{
|
||||
new RoleBase ()
|
||||
{
|
||||
Id = 1,
|
||||
Name = "管理员",
|
||||
Auths = new List<int> () { },
|
||||
IsAdmin = true,
|
||||
Time = dt,
|
||||
},
|
||||
new RoleBase ()
|
||||
{
|
||||
Id = 2,
|
||||
Name = "操作员",
|
||||
Auths = new List<int> () { },
|
||||
IsAdmin = false,
|
||||
Time = dt,
|
||||
},
|
||||
};
|
||||
|
||||
db.Insertable(userBases).ExecuteCommand();
|
||||
db.Insertable(roleBases).ExecuteCommand();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
58
WCS.DAL/Db/AuthEnum/AuthEnum.cs
Normal file
58
WCS.DAL/Db/AuthEnum/AuthEnum.cs
Normal file
@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WCS.DAL
|
||||
{
|
||||
/// <summary>
|
||||
/// 认证项
|
||||
/// </summary>
|
||||
public enum AuthEnum
|
||||
{
|
||||
/* 注意:枚举的值必须大于0 */
|
||||
查询 = 1000,
|
||||
权限 = 2000,
|
||||
//[Description("用户")]
|
||||
//[EnumTree(权限, new[] { 用户新增, 用户删除, 用户修改 })]
|
||||
//用户管理 = 3100, 用户新增 = 3110, 用户删除, 用户修改,
|
||||
//[Description("角色")]
|
||||
//[EnumTree(权限, new[] { 角色新增, 角色删除, 角色修改 })]
|
||||
//角色管理 = 3200, 角色新增 = 3210, 角色删除, 角色修改,
|
||||
设置 = 3000,
|
||||
调试 = 4000,
|
||||
}
|
||||
|
||||
public class EnumTreeAttribute : Attribute
|
||||
{
|
||||
public EnumTreeAttribute() { }
|
||||
|
||||
public EnumTreeAttribute(AuthEnum parent)
|
||||
{
|
||||
Parent = parent;
|
||||
}
|
||||
|
||||
public EnumTreeAttribute(AuthEnum[] childs)
|
||||
{
|
||||
Childs = childs;
|
||||
}
|
||||
|
||||
public EnumTreeAttribute(AuthEnum parent, AuthEnum[] childs)
|
||||
{
|
||||
Parent = parent;
|
||||
Childs = childs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 父级
|
||||
/// </summary>
|
||||
public AuthEnum? Parent { get; set; } = null;
|
||||
/// <summary>
|
||||
/// 子级
|
||||
/// </summary>
|
||||
public AuthEnum[]? Childs { get; set; } = null;
|
||||
}
|
||||
}
|
68
WCS.DAL/Db/AuthEnum/EnumHelps.cs
Normal file
68
WCS.DAL/Db/AuthEnum/EnumHelps.cs
Normal file
@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
namespace WCS.DAL
|
||||
{
|
||||
public static class EnumHelps
|
||||
{
|
||||
public static List<string> GetEnumList(Type type)
|
||||
{
|
||||
List<string> strings = new List<string>();
|
||||
if (type.IsEnum)
|
||||
{
|
||||
var fields = type.GetFields(BindingFlags.Static | BindingFlags.Public) ?? new FieldInfo[] { };
|
||||
foreach (var field in fields)
|
||||
{
|
||||
strings.Add(field.Name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return strings;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 得到枚举详情
|
||||
/// </summary>
|
||||
/// <param name="type">枚举</param>
|
||||
/// <param name="isDescriptionNullInName">描述为空时,是否采用名称值</param>
|
||||
/// <returns>枚举值,名称,描述</returns>
|
||||
public static List<Tuple<int, string, string>> GetEnumDescriptionList(Type type, bool isDescriptionNullInName = false)
|
||||
{
|
||||
var strings = new List<Tuple<int, string, string>>();
|
||||
if (type.IsEnum)
|
||||
{
|
||||
var fields = type.GetFields(BindingFlags.Static | BindingFlags.Public);
|
||||
if (fields == null)
|
||||
return strings;
|
||||
|
||||
foreach (var field in fields)
|
||||
{
|
||||
int enumValue = Convert.ToInt32(field.GetRawConstantValue());
|
||||
string enumName = field.Name;
|
||||
string description = string.Empty;
|
||||
|
||||
var descriptionAttribute = field.GetCustomAttribute<DescriptionAttribute>(false);
|
||||
if (descriptionAttribute != null)
|
||||
description = descriptionAttribute.Description;
|
||||
else if (isDescriptionNullInName)
|
||||
description = enumName;
|
||||
|
||||
strings.Add(new Tuple<int, string, string>(enumValue, enumName, description));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return strings;
|
||||
}
|
||||
}
|
||||
}
|
60
WCS.DAL/Db/DbHelp.cs
Normal file
60
WCS.DAL/Db/DbHelp.cs
Normal file
@ -0,0 +1,60 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WCS.DAL.Db
|
||||
{
|
||||
public static class DbHelp
|
||||
{
|
||||
/// <summary>
|
||||
/// 业务数据库
|
||||
/// </summary>
|
||||
public static SqlSugarScope db = new SqlSugarScope(new ConnectionConfig()
|
||||
{
|
||||
ConnectionString = $"Data Source={LocalFile.DataDbPath};",
|
||||
DbType = DbType.Sqlite,//[Sqlite]安装[System.Data.SQLite];
|
||||
IsAutoCloseConnection = true
|
||||
}, db =>
|
||||
{
|
||||
db.Aop.OnError = ex =>
|
||||
{
|
||||
//TO DO LOG
|
||||
//Logs.Write($@"{nameof(db)}{Environment.NewLine}SQL:{ex?.Sql}{Environment.NewLine}Parametres:{JsonConvert.SerializeObject(ex?.Parametres)}{Environment.NewLine}InnerException:{ex?.InnerException?.ToString()}{Environment.NewLine}Exception:{ex?.ToString()}{Environment.NewLine}", LogsType.DbErr);
|
||||
};
|
||||
});
|
||||
|
||||
/// <summary>
|
||||
/// 日志数据库
|
||||
/// </summary>
|
||||
public static SqlSugarScope dbLog = new SqlSugarScope(new ConnectionConfig()
|
||||
{
|
||||
ConnectionString = $"Data Source={LocalFile.LogDbPath};",
|
||||
DbType = DbType.Sqlite,//[Sqlite]安装[System.Data.SQLite];
|
||||
IsAutoCloseConnection = true
|
||||
}, db =>
|
||||
{
|
||||
db.Aop.OnError = ex =>
|
||||
{
|
||||
//TO DO LOG
|
||||
//Logs.Write($@"{nameof(dbAuth)}{Environment.NewLine}SQL:{ex?.Sql}{Environment.NewLine}Parametres:{JsonConvert.SerializeObject(ex?.Parametres)}{Environment.NewLine}InnerException:{ex?.InnerException?.ToString()}{Environment.NewLine}Exception:{ex?.ToString()}{Environment.NewLine}", LogsType.DbErr);
|
||||
};
|
||||
});
|
||||
|
||||
public static void InitDb()
|
||||
{
|
||||
//#region 初始化业务数据库
|
||||
////不存在创建数据库,存在不会创建
|
||||
//db.DbMaintenance.CreateDatabase();
|
||||
////创建表根据实体类
|
||||
//db.CodeFirst.InitTables(typeof(ModuleInfo), typeof(ShelfInfo), typeof(StoreInfo));
|
||||
//#endregion
|
||||
|
||||
//#region 初始化日志数据库
|
||||
//dbLog.DbMaintenance.CreateDatabase();
|
||||
//#endregion
|
||||
}
|
||||
}
|
||||
}
|
19
WCS.DAL/LocalFile.cs
Normal file
19
WCS.DAL/LocalFile.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WCS.DAL
|
||||
{
|
||||
public static class LocalFile
|
||||
{
|
||||
public static readonly string AppDir = AppDomain.CurrentDomain.BaseDirectory;
|
||||
|
||||
public static readonly string LogDbPath = Path.Combine(AppDir, "data\\log.db3");
|
||||
|
||||
public static readonly string DataDbPath = Path.Combine(AppDir, "data\\data.db3");
|
||||
|
||||
public static readonly string AuthDbPath = Path.Combine(AppDir, "data\\auth.db3");
|
||||
}
|
||||
}
|
16
WCS.DAL/WCS.DAL.csproj
Normal file
16
WCS.DAL/WCS.DAL.csproj
Normal file
@ -0,0 +1,16 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SqlSugarCore" Version="5.1.4.149" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\WCS.Model\WCS.Model.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
15
WCS.Model/ApiModel/Home/GetShelfStatusRequest.cs
Normal file
15
WCS.Model/ApiModel/Home/GetShelfStatusRequest.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WCS.Model
|
||||
{
|
||||
public class GetShelfStatusRequest : RequestBase
|
||||
{
|
||||
public int ShelfTypeId { get; set; }
|
||||
public string? ShelfTypeName { get; set; } = string.Empty;
|
||||
public List<string> GroupNames { get; set; }
|
||||
}
|
||||
}
|
37
WCS.Model/ApiModel/Home/GetShelfStatusResponse.cs
Normal file
37
WCS.Model/ApiModel/Home/GetShelfStatusResponse.cs
Normal file
@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WCS.Model
|
||||
{
|
||||
public class GetShelfStatusResponse : ResponseBase
|
||||
{
|
||||
public List<Shelf> Data { get; set; }
|
||||
}
|
||||
|
||||
public class Shelf
|
||||
{
|
||||
public int ShelfId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架编码
|
||||
/// </summary>
|
||||
public string ShelfCode { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 货架当前模式
|
||||
/// </summary>
|
||||
public int CurentMode { get; set; }
|
||||
|
||||
|
||||
public string ModulesStr { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架组别
|
||||
/// </summary>
|
||||
public string GroupName { get; set; }
|
||||
}
|
||||
}
|
13
WCS.Model/ApiModel/Home/ShelfTypeModel.cs
Normal file
13
WCS.Model/ApiModel/Home/ShelfTypeModel.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace WCS.Model.ApiModel.Home
|
||||
{
|
||||
public class ShelfTypeModel()
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string ShelfTypeName { get; set; }
|
||||
|
||||
}
|
||||
}
|
16
WCS.Model/ApiModel/InStore/QueryByMatSnRequest.cs
Normal file
16
WCS.Model/ApiModel/InStore/QueryByMatSnRequest.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WCS.Model
|
||||
{
|
||||
public class QueryByMatSnRequest : RequestBase
|
||||
{
|
||||
public string MatSn { get; set; } = string.Empty;
|
||||
public string ShelfCode { get; set; } = string.Empty;
|
||||
|
||||
public string IpAddress { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
32
WCS.Model/ApiModel/InStore/QueryByMatSnResponse.cs
Normal file
32
WCS.Model/ApiModel/InStore/QueryByMatSnResponse.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WCS.Model
|
||||
{
|
||||
public class QueryByMatSnResponse : ResponseBase
|
||||
{
|
||||
public MatInfoModel Data { get; set; }
|
||||
}
|
||||
|
||||
public class MatInfoModel
|
||||
{
|
||||
public string materialBar { get; set; }
|
||||
|
||||
public string materialCode { get; set; }
|
||||
|
||||
public string materialName { get; set; }
|
||||
|
||||
public string materialSpec { get; set; }
|
||||
|
||||
public double materialQty { get; set; }
|
||||
|
||||
public string batchNo { get; set; }
|
||||
|
||||
public string supplier { get; set; }
|
||||
|
||||
public string customer { get; set; }
|
||||
}
|
||||
}
|
9
WCS.Model/ApiModel/InStore/ShelfGoInInstoreRequest.cs
Normal file
9
WCS.Model/ApiModel/InStore/ShelfGoInInstoreRequest.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace WCS.Model
|
||||
{
|
||||
public class ShelfGoInInstoreRequest : RequestBase
|
||||
{
|
||||
public string ModuleCode { get; set; }
|
||||
|
||||
public string? IpAdress { get; set; }//调用设备的Ip地址
|
||||
}
|
||||
}
|
13
WCS.Model/ApiModel/InStore/ShelfGoInInstoreResponse.cs
Normal file
13
WCS.Model/ApiModel/InStore/ShelfGoInInstoreResponse.cs
Normal file
@ -0,0 +1,13 @@
|
||||
namespace WCS.Model
|
||||
{
|
||||
public class ShelfGoInInstoreResponse : ResponseBase
|
||||
{
|
||||
public ShelfGoInInstoreDto? Data { get; set; }
|
||||
}
|
||||
public class ShelfGoInInstoreDto
|
||||
{
|
||||
public string ShelfCode { get; set; } = string.Empty;
|
||||
|
||||
public string ModulesStr { get; set;} = string.Empty;
|
||||
}
|
||||
}
|
15
WCS.Model/ApiModel/InStore/ShelfGoOutInStoreRequest.cs
Normal file
15
WCS.Model/ApiModel/InStore/ShelfGoOutInStoreRequest.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WCS.Model
|
||||
{
|
||||
public class ShelfGoOutInStoreRequest : RequestBase
|
||||
{
|
||||
public string ShelfCode { get; set; } = string.Empty;
|
||||
|
||||
public string IPAdress { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace WCS.Model.ApiModel
|
||||
{
|
||||
public class GetInterfaceRecordsRequest : PageQueryRequestBase
|
||||
{
|
||||
public string RequestType { get; set; }
|
||||
|
||||
public string RequestUrl { get; set; }
|
||||
|
||||
public string RequestBody { get; set; }
|
||||
|
||||
public TimeType TimeType { get; set; }
|
||||
|
||||
public DateTime? StartTime { get; set; }
|
||||
|
||||
public DateTime? EndTime { get; set; }
|
||||
}
|
||||
|
||||
public enum TimeType
|
||||
{
|
||||
请求时间 = 0,
|
||||
响应时间 = 1
|
||||
}
|
||||
}
|
36
WCS.Model/ApiModel/InterfaceRecord/SystemApiLogModel.cs
Normal file
36
WCS.Model/ApiModel/InterfaceRecord/SystemApiLogModel.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System;
|
||||
|
||||
namespace WCS.Model.ApiModel.InterfaceRecord
|
||||
{
|
||||
public class SystemApiLogModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string Type { get; set; }
|
||||
|
||||
public string UserName { get; set; }
|
||||
|
||||
public string DeviceType { get; set; }
|
||||
|
||||
public string DeviceIp { get; set; }
|
||||
|
||||
public string RequestUrl { get; set; }
|
||||
|
||||
public string RequestBody { get; set; }
|
||||
|
||||
public string QueryString { get; set; }
|
||||
|
||||
public bool IsResponse { get; set; }
|
||||
|
||||
public string ResponseJson { get; set; }
|
||||
|
||||
public DateTime RequestTime { get; set; }
|
||||
|
||||
public DateTime ResponseTime { get; set; }
|
||||
|
||||
public long ExecutionTime { get; set; }
|
||||
|
||||
public int RowNumber { get; set; }
|
||||
}
|
||||
}
|
||||
|
14
WCS.Model/ApiModel/MatBaseInfo/AddMatBaseInfoRequest.cs
Normal file
14
WCS.Model/ApiModel/MatBaseInfo/AddMatBaseInfoRequest.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using WCS.Model.ApiModel.User;
|
||||
|
||||
namespace WCS.Model.ApiModel.MatBaseInfo
|
||||
{
|
||||
public class AddMatBaseInfoRequest<T> : RequestBase
|
||||
{
|
||||
public T MatBaseInfo { get; set; }
|
||||
public AddOrUpdate AddOrUpdate { get; set; }
|
||||
}
|
||||
|
||||
}
|
13
WCS.Model/ApiModel/MatBaseInfo/DeleteMatBaseInfosRequest.cs
Normal file
13
WCS.Model/ApiModel/MatBaseInfo/DeleteMatBaseInfosRequest.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using WCS.Model.ApiModel.User;
|
||||
|
||||
namespace WCS.Model.ApiModel.MatBaseInfo
|
||||
{
|
||||
public class DeleteMatBaseInfosRequest : RequestBase
|
||||
{
|
||||
public List<int> MatBaseInfoIds { get; set; }
|
||||
}
|
||||
|
||||
}
|
17
WCS.Model/ApiModel/MatBaseInfo/GetMatBaseInfoRequest.cs
Normal file
17
WCS.Model/ApiModel/MatBaseInfo/GetMatBaseInfoRequest.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace WCS.Model.ApiModel.MatBaseInfo
|
||||
{
|
||||
public class GetMatBaseInfoRequest : PageQueryRequestBase
|
||||
{
|
||||
public string MatCode { get; set; }
|
||||
|
||||
public string MatName { get; set; }
|
||||
|
||||
public string MatSpec { get; set; }
|
||||
|
||||
public bool? IsEnable { get; set; } = null;
|
||||
}
|
||||
}
|
12
WCS.Model/ApiModel/MatBaseInfo/GetMatCodeListRequest.cs
Normal file
12
WCS.Model/ApiModel/MatBaseInfo/GetMatCodeListRequest.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace WCS.Model.ApiModel.MatBaseInfo
|
||||
{
|
||||
public class GetMatCodeListRequest : RequestBase
|
||||
{
|
||||
//是否是从基础数据返回 如果为false 从库存数据返回
|
||||
public bool IsFromBaseData { get; set; }
|
||||
}
|
||||
}
|
16
WCS.Model/ApiModel/MatBaseInfo/MatBaseInfoImportModel.cs
Normal file
16
WCS.Model/ApiModel/MatBaseInfo/MatBaseInfoImportModel.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace WCS.Model.ApiModel.MatBaseInfo
|
||||
{
|
||||
public class MatBaseInfoImportModel
|
||||
{
|
||||
public string 物料编码 { get; set; }
|
||||
public string 名称 { get; set; }
|
||||
public string 规格 { get; set; }
|
||||
public string 单位 { get; set; }
|
||||
public string 客户 { get; set; }
|
||||
public string 状态 { get; set; }
|
||||
}
|
||||
}
|
64
WCS.Model/ApiModel/MatBaseInfo/MatBaseInfoModel.cs
Normal file
64
WCS.Model/ApiModel/MatBaseInfo/MatBaseInfoModel.cs
Normal file
@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace WCS.BLL.DbModels
|
||||
{
|
||||
///<summary>
|
||||
///物料基础信息
|
||||
///</summary>
|
||||
public partial class MatBaseInfoModel: INotifyPropertyChanged
|
||||
{
|
||||
|
||||
public int Id { get; set; }
|
||||
|
||||
public string MatCode { get; set; }
|
||||
|
||||
public string MatName { get; set; }
|
||||
|
||||
public string MatSpec { get; set; }
|
||||
|
||||
public string MatUnit { get; set; }
|
||||
|
||||
public string MatBatch { get; set; }
|
||||
|
||||
public string MatSupplier { get; set; }
|
||||
|
||||
public string MatCustomer { get; set; }
|
||||
|
||||
public string ModifyUser { get; set; }
|
||||
|
||||
public DateTime? ModifyTime { get; set; } = DateTime.Now;
|
||||
|
||||
public bool IsEnable { get; set; } = true;
|
||||
|
||||
public string IsEnableStr
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsEnable)
|
||||
return "启用";
|
||||
else
|
||||
return "禁用";
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsSelected
|
||||
{
|
||||
get { return isSelected; }
|
||||
set
|
||||
{
|
||||
isSelected = value;
|
||||
OnPropertyChanged(nameof(IsSelected));
|
||||
}
|
||||
}
|
||||
public bool isSelected;
|
||||
|
||||
public int RowNumber { get; set; }
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
protected virtual void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace WCS.Model.ApiModel.MatInventoryDetail
|
||||
{
|
||||
public class GetMatInventoryDetailRequest : PageQueryRequestBase
|
||||
{
|
||||
#region 物料属性
|
||||
public string MatSN { get; set; }
|
||||
|
||||
public string MatCode { get; set; }
|
||||
|
||||
public string MatName { get; set; }
|
||||
|
||||
public string MatSpec { get; set; }
|
||||
|
||||
public string MatBatch { get; set; }
|
||||
|
||||
public string MatSupplier { get; set; }
|
||||
|
||||
public string MatCustomer { get; set; }
|
||||
#endregion
|
||||
|
||||
#region 库位属性
|
||||
public List<int> ShelfTypeId { get; set; }
|
||||
public List<int> ShelfId { get; set; }
|
||||
public int StoreId { get; set; }
|
||||
public string StoreCode { get; set; }
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace WCS.Model.ApiModel.MatInventoryDetail
|
||||
{
|
||||
public class MatInventoryDetailModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
#region 库位属性
|
||||
public int StoreId { get; set; }
|
||||
public string StoreCode { get; set; }
|
||||
//public StoreInfo StoreInfo { get; set; }
|
||||
#endregion
|
||||
|
||||
#region 物料属性
|
||||
public string MatSN { get; set; }
|
||||
public string MatCode { get; set; }
|
||||
public string MatName { get; set; }
|
||||
public string MatSpec { get; set; }
|
||||
public string MatBatch { get; set; }
|
||||
public int MatQty { get; set; }
|
||||
public string? MatSupplier { get; set; }
|
||||
public string? MatCustomer { get; set; }
|
||||
#endregion
|
||||
|
||||
public DateTime InstoreTime { get; set; } = DateTime.Now;
|
||||
public string InstoreUser { get; set; }
|
||||
public bool IsLocked { get; set; } = false;
|
||||
public int RowNumber { get; set; }
|
||||
public bool IsSelected { get; set; }
|
||||
}
|
||||
}
|
15
WCS.Model/ApiModel/OutStore/GetOutOrderDetailRequest.cs
Normal file
15
WCS.Model/ApiModel/OutStore/GetOutOrderDetailRequest.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WCS.Model
|
||||
{
|
||||
public class GetOutOrderDetailRequest : ResponseBase
|
||||
{
|
||||
public int OrderId { get; set; }
|
||||
public string OrderNumber { get; set; }
|
||||
|
||||
}
|
||||
}
|
19
WCS.Model/ApiModel/OutStore/GetOutOrderListRequest.cs
Normal file
19
WCS.Model/ApiModel/OutStore/GetOutOrderListRequest.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WCS.Model
|
||||
{
|
||||
public class GetOutOrderListRequest : PageQueryRequestBase
|
||||
{
|
||||
public string OrderNumber { get; set; }
|
||||
|
||||
public int OrderStatus { get; set; }
|
||||
|
||||
//public int PageNumber { get; set; }
|
||||
|
||||
//public int PageSize { get; set; }
|
||||
}
|
||||
}
|
30
WCS.Model/ApiModel/OutStore/SysOutOrderByMatCodeRequest.cs
Normal file
30
WCS.Model/ApiModel/OutStore/SysOutOrderByMatCodeRequest.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace WCS.Model
|
||||
{
|
||||
public class SysOutOrderByMatCodeRequest : RequestBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 单据编号
|
||||
/// </summary>
|
||||
public string OrderNumber { get; set; }
|
||||
/// <summary>
|
||||
/// 单据来源
|
||||
/// </summary>
|
||||
public string OrderSource { get; set; }
|
||||
/// <summary>
|
||||
/// 单据类型
|
||||
/// </summary>
|
||||
public string OrderType { get; set; }
|
||||
|
||||
public List<MatCodeItemList> ItemList { get; set; }
|
||||
|
||||
}
|
||||
public class MatCodeItemList
|
||||
{
|
||||
public string MatCode { get; set; }
|
||||
public string MatBatch { get; set; }
|
||||
public int ReqQty { get; set; }
|
||||
|
||||
}
|
||||
}
|
22
WCS.Model/ApiModel/OutStore/SysOutOrderByMatSnRequest.cs
Normal file
22
WCS.Model/ApiModel/OutStore/SysOutOrderByMatSnRequest.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace WCS.Model
|
||||
{
|
||||
public class SysOutOrderByMatSnRequest : RequestBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 单据编号
|
||||
/// </summary>
|
||||
public string OrderNumber { get; set; }
|
||||
/// <summary>
|
||||
/// 单据来源
|
||||
/// </summary>
|
||||
public string OrderSource { get; set; }
|
||||
/// <summary>
|
||||
/// 单据类型
|
||||
/// </summary>
|
||||
public string OrderType { get; set; }
|
||||
|
||||
public List<string> SnList { get; set; }
|
||||
}
|
||||
}
|
21
WCS.Model/ApiModel/PageQuery/PageQueryResponse.cs
Normal file
21
WCS.Model/ApiModel/PageQuery/PageQueryResponse.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WCS.Model
|
||||
{
|
||||
public class PageQueryResponse<T> : ResponseCommon
|
||||
{
|
||||
public PageQueryResponseData<T> Data { get; set; }
|
||||
}
|
||||
public class PageQueryResponseData<T>
|
||||
{
|
||||
public int Count { get; set; }
|
||||
public int MaxPage { get; set; }
|
||||
public int TotalCount { get; set; }
|
||||
public List<T> Lists { get; set; }
|
||||
}
|
||||
}
|
22
WCS.Model/ApiModel/RequestBase.cs
Normal file
22
WCS.Model/ApiModel/RequestBase.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WCS.Model
|
||||
{
|
||||
public class RequestBase
|
||||
{
|
||||
public string UserName { get; set; }
|
||||
|
||||
public string DeviceType { get; set; }
|
||||
}
|
||||
|
||||
public class PageQueryRequestBase: RequestBase
|
||||
{
|
||||
public int PageNumber { get; set; }
|
||||
|
||||
public int PageSize { get; set; }
|
||||
}
|
||||
}
|
30
WCS.Model/ApiModel/ResponseBase.cs
Normal file
30
WCS.Model/ApiModel/ResponseBase.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WCS.Model
|
||||
{
|
||||
public class ResponseBase
|
||||
{
|
||||
public int Code { get; set; }
|
||||
|
||||
public string Message { get; set; }
|
||||
}
|
||||
|
||||
public class ResponseBase<T> : ResponseBase
|
||||
{
|
||||
public T Data { get; set; }
|
||||
}
|
||||
|
||||
public class ResponseCommon : ResponseBase
|
||||
{
|
||||
public object Data { get; set; }
|
||||
}
|
||||
|
||||
public class ResponseCommon<T> : ResponseBase
|
||||
{
|
||||
public T Data { get; set; }
|
||||
}
|
||||
}
|
13
WCS.Model/ApiModel/StoreInfo/AddShelfInfoRequest.cs
Normal file
13
WCS.Model/ApiModel/StoreInfo/AddShelfInfoRequest.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using WCS.Model.ApiModel.User;
|
||||
|
||||
namespace WCS.Model.ApiModel.StoreInfo
|
||||
{
|
||||
public class AddShelfInfoRequest<T> : RequestBase
|
||||
{
|
||||
public T ShelfInfo { get; set; }
|
||||
public AddOrUpdate AddOrUpdate { get; set; }
|
||||
}
|
||||
}
|
12
WCS.Model/ApiModel/StoreInfo/GetShelvesRequest.cs
Normal file
12
WCS.Model/ApiModel/StoreInfo/GetShelvesRequest.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace WCS.Model.ApiModel.StoreInfo
|
||||
{
|
||||
public class GetShelvesRequest : PageQueryRequestBase
|
||||
{
|
||||
public int ShelfTypeId { get; set; }
|
||||
public string ShelfCode { get; set; }
|
||||
}
|
||||
}
|
74
WCS.Model/ApiModel/StoreInfo/ShelfInfoModel.cs
Normal file
74
WCS.Model/ApiModel/StoreInfo/ShelfInfoModel.cs
Normal file
@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Text;
|
||||
|
||||
namespace WCS.Model.ApiModel.StoreInfo
|
||||
{
|
||||
public class ShelfInfoModel : INotifyPropertyChanged
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string ShelfCode { get; set; }
|
||||
public int ShelfTypeId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架类型名称
|
||||
/// </summary>
|
||||
public string ShelfTypeName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架当前状态
|
||||
/// </summary>
|
||||
public int CurrentMode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架行数
|
||||
/// </summary>
|
||||
public int Rowcounts { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架列数
|
||||
/// </summary>
|
||||
public int Columncounts { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架对应警示灯的Id
|
||||
/// </summary>
|
||||
public int LightId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架对应Can模块的Ip
|
||||
/// </summary>
|
||||
public string ClientIp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架的组别、区域(区分单个软件管哪些货架的,前端的配置文件配置一个组别,查询时只显示当前组别的货架)
|
||||
/// </summary>
|
||||
public string GroupName { get; set; }
|
||||
|
||||
public bool IsBind { get; set; }
|
||||
|
||||
public string BindShelfCode { get; set; } = string.Empty;
|
||||
|
||||
|
||||
public int RowNumber { get; set; }
|
||||
|
||||
public bool IsSelected
|
||||
{
|
||||
get { return isSelected; }
|
||||
set
|
||||
{
|
||||
isSelected = value;
|
||||
OnPropertyChanged(nameof(IsSelected));
|
||||
}
|
||||
}
|
||||
public bool isSelected;
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
protected virtual void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
12
WCS.Model/ApiModel/User/AddRoleRequest.cs
Normal file
12
WCS.Model/ApiModel/User/AddRoleRequest.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace WCS.Model.ApiModel.User
|
||||
{
|
||||
public class AddRoleRequest<T> : RequestBase
|
||||
{
|
||||
public T Role { get; set; }
|
||||
public AddOrUpdate AddOrUpdate { get; set; }
|
||||
}
|
||||
}
|
19
WCS.Model/ApiModel/User/AddUserRequest.cs
Normal file
19
WCS.Model/ApiModel/User/AddUserRequest.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace WCS.Model.ApiModel.User
|
||||
{
|
||||
public class AddUserRequest<T> : RequestBase
|
||||
{
|
||||
public T User { get; set; }
|
||||
public AddOrUpdate AddOrUpdate { get; set; }
|
||||
}
|
||||
|
||||
public enum AddOrUpdate
|
||||
{
|
||||
Add = 0,
|
||||
Update = 1,
|
||||
Delete = 2
|
||||
}
|
||||
}
|
58
WCS.Model/ApiModel/User/AuthEnum.cs
Normal file
58
WCS.Model/ApiModel/User/AuthEnum.cs
Normal file
@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WCS.Model.ApiModel
|
||||
{
|
||||
/// <summary>
|
||||
/// 认证项
|
||||
/// </summary>
|
||||
public enum AuthEnum
|
||||
{
|
||||
/* 注意:枚举的值必须大于0 */
|
||||
查询 = 1000,
|
||||
权限 = 2000,
|
||||
//[Description("用户")]
|
||||
//[EnumTree(权限, new[] { 用户新增, 用户删除, 用户修改 })]
|
||||
//用户管理 = 3100, 用户新增 = 3110, 用户删除, 用户修改,
|
||||
//[Description("角色")]
|
||||
//[EnumTree(权限, new[] { 角色新增, 角色删除, 角色修改 })]
|
||||
//角色管理 = 3200, 角色新增 = 3210, 角色删除, 角色修改,
|
||||
设置 = 3000,
|
||||
调试 = 4000,
|
||||
}
|
||||
|
||||
public class EnumTreeAttribute : Attribute
|
||||
{
|
||||
public EnumTreeAttribute() { }
|
||||
|
||||
public EnumTreeAttribute(AuthEnum parent)
|
||||
{
|
||||
Parent = parent;
|
||||
}
|
||||
|
||||
public EnumTreeAttribute(AuthEnum[] childs)
|
||||
{
|
||||
Childs = childs;
|
||||
}
|
||||
|
||||
public EnumTreeAttribute(AuthEnum parent, AuthEnum[] childs)
|
||||
{
|
||||
Parent = parent;
|
||||
Childs = childs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 父级
|
||||
/// </summary>
|
||||
public AuthEnum? Parent { get; set; } = null;
|
||||
/// <summary>
|
||||
/// 子级
|
||||
/// </summary>
|
||||
public AuthEnum[]? Childs { get; set; } = null;
|
||||
}
|
||||
}
|
59
WCS.Model/ApiModel/User/AuthModels.cs
Normal file
59
WCS.Model/ApiModel/User/AuthModels.cs
Normal file
@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace WCS.Model.ApiModel
|
||||
{
|
||||
|
||||
public class UserModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
/// <summary>
|
||||
/// 登录名
|
||||
/// </summary>
|
||||
public string LoginName { get; set; }
|
||||
/// <summary>
|
||||
/// 密码
|
||||
/// </summary>
|
||||
public string Password { get; set; }
|
||||
|
||||
public List<int> RoleIds { get; set; } = new List<int>();
|
||||
|
||||
public List<string> RoleNames { get; set; }
|
||||
/// <summary>
|
||||
/// 是否最大权限
|
||||
/// </summary>
|
||||
public bool IsAdmin { get; set; }
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime Time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 用户拥有的权限
|
||||
/// </summary>
|
||||
public List<RoleModel> GetRoles { get; set; }
|
||||
}
|
||||
public class RoleModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
/// <summary>
|
||||
/// 角色名
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
public List<int> Auths { get; set; } = new List<int>();
|
||||
|
||||
public List<string> AuthNames { get => (Auths == null || !Auths.Any()) ? new List<string>() : EnumHelps.GetEnumDescriptionList(typeof(AuthEnum), true).Where(o => Auths.Contains(o.Item1)).Select(o => o.Item3).ToList(); }
|
||||
/// <summary>
|
||||
/// 是否最大权限
|
||||
/// </summary>
|
||||
public bool IsAdmin { get; set; }
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime Time { get; set; }
|
||||
}
|
||||
|
||||
}
|
68
WCS.Model/ApiModel/User/EnumHelps.cs
Normal file
68
WCS.Model/ApiModel/User/EnumHelps.cs
Normal file
@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
namespace WCS.Model.ApiModel
|
||||
{
|
||||
public static class EnumHelps
|
||||
{
|
||||
public static List<string> GetEnumList(Type type)
|
||||
{
|
||||
List<string> strings = new List<string>();
|
||||
if (type.IsEnum)
|
||||
{
|
||||
var fields = type.GetFields(BindingFlags.Static | BindingFlags.Public) ?? new FieldInfo[] { };
|
||||
foreach (var field in fields)
|
||||
{
|
||||
strings.Add(field.Name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return strings;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 得到枚举详情
|
||||
/// </summary>
|
||||
/// <param name="type">枚举</param>
|
||||
/// <param name="isDescriptionNullInName">描述为空时,是否采用名称值</param>
|
||||
/// <returns>枚举值,名称,描述</returns>
|
||||
public static List<Tuple<int, string, string>> GetEnumDescriptionList(Type type, bool isDescriptionNullInName = false)
|
||||
{
|
||||
var strings = new List<Tuple<int, string, string>>();
|
||||
if (type.IsEnum)
|
||||
{
|
||||
var fields = type.GetFields(BindingFlags.Static | BindingFlags.Public);
|
||||
if (fields == null)
|
||||
return strings;
|
||||
|
||||
foreach (var field in fields)
|
||||
{
|
||||
int enumValue = Convert.ToInt32(field.GetRawConstantValue());
|
||||
string enumName = field.Name;
|
||||
string description = string.Empty;
|
||||
|
||||
var descriptionAttribute = field.GetCustomAttribute<DescriptionAttribute>(false);
|
||||
if (descriptionAttribute != null)
|
||||
description = descriptionAttribute.Description;
|
||||
else if (isDescriptionNullInName)
|
||||
description = enumName;
|
||||
|
||||
strings.Add(new Tuple<int, string, string>(enumValue, enumName, description));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return strings;
|
||||
}
|
||||
}
|
||||
}
|
11
WCS.Model/ApiModel/User/GetUsersRequest.cs
Normal file
11
WCS.Model/ApiModel/User/GetUsersRequest.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace WCS.Model.ApiModel.User
|
||||
{
|
||||
public class GetUsersRequest : RequestBase
|
||||
{
|
||||
public string Info { get; set; }
|
||||
}
|
||||
}
|
18
WCS.Model/ApiModel/User/UserLoginRequest.cs
Normal file
18
WCS.Model/ApiModel/User/UserLoginRequest.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace WCS.Model.ApiModel.User
|
||||
{
|
||||
public class UserLoginRequest : RequestBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 密码
|
||||
/// </summary>
|
||||
public string PassWord { get; set; }
|
||||
/// <summary>
|
||||
/// 是否配置为不登陆(如果不登陆 直接获取admin 且不验证密码了)
|
||||
/// </summary>
|
||||
public bool IsNoLogin { get; set; } = false;
|
||||
}
|
||||
}
|
6
WCS.Model/WCS.Model.csproj
Normal file
6
WCS.Model/WCS.Model.csproj
Normal file
@ -0,0 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<LangVersion>latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
12
WCS.WebApi/.config/dotnet-tools.json
Normal file
12
WCS.WebApi/.config/dotnet-tools.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"version": 1,
|
||||
"isRoot": true,
|
||||
"tools": {
|
||||
"dotnet-ef": {
|
||||
"version": "8.0.2",
|
||||
"commands": [
|
||||
"dotnet-ef"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
93
WCS.WebApi/Controllers/HomeController.cs
Normal file
93
WCS.WebApi/Controllers/HomeController.cs
Normal file
@ -0,0 +1,93 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.Manager;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.BLL.Services.Service;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel.Home;
|
||||
|
||||
namespace WCS.WebApi.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 主页面的接口
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class HomeController : ControllerBase
|
||||
{
|
||||
public IHomerService _homerService { get; set; }
|
||||
|
||||
public HomeController(IHomerService homerService)
|
||||
{
|
||||
_homerService = homerService;
|
||||
}
|
||||
|
||||
[Route("getShelfTypes")]
|
||||
[HttpPost(Name = "getShelfTypes")]
|
||||
public async Task<ResponseBase> getShelfTypes(RequestBase request)
|
||||
{
|
||||
try
|
||||
{
|
||||
//直接获取当前所有货架类型并返回
|
||||
var shelfTypes = DbHelp.db.Queryable<ShelfTypeInfo>()
|
||||
.Select(t => new ShelfTypeModel()
|
||||
{
|
||||
Id = t.Id,
|
||||
ShelfTypeName = t.ShelfTypeName
|
||||
})
|
||||
.ToList();
|
||||
return new PageQueryResponse<ShelfTypeModel>()
|
||||
{
|
||||
Code = 200,
|
||||
Message = "success",
|
||||
Data = new PageQueryResponseData<ShelfTypeModel>
|
||||
{
|
||||
Lists = shelfTypes,
|
||||
Count = shelfTypes.Count
|
||||
}
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new PageQueryResponse<ShelfTypeModel>()
|
||||
{
|
||||
Code = 300,
|
||||
Message = $"查询失败:{ex.Message}",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
[Route("getShelfStatus")]
|
||||
[HttpPost(Name = "getShelfStatus")]
|
||||
public async Task<ResponseBase> getShelfStatus(GetShelfStatusRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
var shelfs = ShelfManager.Shelves
|
||||
.WhereIF(request.GroupNames?.Count > 0, t => request.GroupNames!.Contains(t.GroupName))
|
||||
.ToList();
|
||||
//直接返回当前内存中缓存的货架和状态
|
||||
return new GetShelfStatusResponse()
|
||||
{
|
||||
Code = 200,
|
||||
Message = "success",
|
||||
Data = shelfs.Select(t => new Shelf
|
||||
{
|
||||
ShelfId = t.ShelfId,
|
||||
ShelfCode = t.ShelfCode,
|
||||
CurentMode = (int)t.CurentMode,
|
||||
ModulesStr = t.ModulesStr,
|
||||
GroupName = t.GroupName
|
||||
}).ToList(),
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
117
WCS.WebApi/Controllers/InstoreController.cs
Normal file
117
WCS.WebApi/Controllers/InstoreController.cs
Normal file
@ -0,0 +1,117 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WCS.BLL.HardWare;
|
||||
using WCS.BLL.Manager;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.Model;
|
||||
|
||||
namespace WebApi.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class InstoreController : ControllerBase
|
||||
{
|
||||
|
||||
private readonly ILogger<InstoreController> _logger;
|
||||
private readonly IInstoreService _instoreService;
|
||||
|
||||
public InstoreController(ILogger<InstoreController> logger, IInstoreService instoreService)
|
||||
{
|
||||
_logger = logger;
|
||||
_instoreService = instoreService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[Route("shelfGoInInStore")]
|
||||
[HttpPost(Name = "shelfGoInInStore")]
|
||||
public async Task<ResponseBase> shelfGoInInStore(ShelfGoInInstoreRequest request)
|
||||
{
|
||||
string content = string.Empty;
|
||||
try
|
||||
{
|
||||
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8>IP<49><50>ַ
|
||||
var IPAdress = HttpContext?.Connection?.RemoteIpAddress?.ToString();
|
||||
if (string.IsNullOrEmpty(IPAdress))
|
||||
{
|
||||
//δ<><CEB4>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8>IP<49><50>ַ TO DO <20><>¼<EFBFBD><C2BC>־δ<D6BE><CEB4>ȡ<EFBFBD><C8A1>IP
|
||||
}
|
||||
else
|
||||
{
|
||||
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8>Ip<49><70>ַ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>request
|
||||
request.IpAdress = IPAdress;
|
||||
}
|
||||
return _instoreService.shelfGoInInStore(request);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ShelfGoInInstoreResponse()
|
||||
{
|
||||
Code = 300,
|
||||
Message = "<22><><EFBFBD>ܽ<EFBFBD><DCBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽʧ<CABD>ܣ<EFBFBD>" + ex.Message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD>ģʽ
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[Route("shelfGoOutInStore")]
|
||||
[HttpPost(Name = "shelfGoOutInStore")]
|
||||
public async Task<ResponseBase> shelfGoOutInStore(ShelfGoOutInStoreRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _instoreService.shelfGoOutInStore(request);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 300,
|
||||
Message = $"<22><><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD>ģʽʧ<CABD><CAA7>:{ex.Message}",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ɨ<><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϸ
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[Route("queryByMatSn")]
|
||||
[HttpPost(Name = "queryByMatSn")]
|
||||
public async Task<ResponseBase> queryByMatSn(QueryByMatSnRequest request)
|
||||
{
|
||||
return _instoreService.queryByMatSn(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>״̬
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[Route("queryInstoreStatus")]
|
||||
[HttpPost(Name = "queryInstoreStatus")]
|
||||
public async Task<ResponseBase> queryInstoreStatus(QueryByMatSnRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await _instoreService.queryInstoreStatus(request);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 300,
|
||||
Message = $"<22><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>:{ex.Message}",
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
82
WCS.WebApi/Controllers/InterfaceRecordController.cs
Normal file
82
WCS.WebApi/Controllers/InterfaceRecordController.cs
Normal file
@ -0,0 +1,82 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using MiniExcelLibs;
|
||||
using NPOI.SS.UserModel;
|
||||
using SqlSugar;
|
||||
using System.Xml.Linq;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.Manager;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.BLL.Services.Service;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel;
|
||||
using WCS.WebApi.Helper;
|
||||
|
||||
namespace WCS.WebApi.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 接口记录
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class InterfaceRecordController : ControllerBase
|
||||
{
|
||||
public IInterfaceRecordService _interfaceRecordService { get; set; }
|
||||
|
||||
public InterfaceRecordController(IInterfaceRecordService interfaceRecordService)
|
||||
{
|
||||
_interfaceRecordService = interfaceRecordService;
|
||||
}
|
||||
|
||||
[Route("getInterfaceRecord")]
|
||||
[HttpPost(Name = "getInterfaceRecord")]
|
||||
public async Task<ResponseBase> getInterfaceRecord(GetInterfaceRecordsRequest request)
|
||||
{
|
||||
return await _interfaceRecordService.getInterfaceRecord(request);
|
||||
}
|
||||
|
||||
[HttpPost("exportInterfaceRecord")]
|
||||
public async Task<IActionResult> exportInterfaceRecord([FromBody] GetInterfaceRecordsRequest request)
|
||||
{
|
||||
var result = await _interfaceRecordService.exportInterfaceRecord(request);
|
||||
var data = result.Data?.Lists;
|
||||
var columns = new[]
|
||||
{
|
||||
new ExportableColumn("序号","RowNumber"),
|
||||
new ExportableColumn("接口地址","RequestUrl"),
|
||||
new ExportableColumn("设备IP","DeviceIp"),
|
||||
new ExportableColumn("请求参数","RequestBody"),
|
||||
new ExportableColumn("QueryString","QueryString"),
|
||||
new ExportableColumn("请求时间","RequestTime"),
|
||||
new ExportableColumn("返回参数","ResponseJson"),
|
||||
new ExportableColumn("返回时间","ResponseTime"),
|
||||
new ExportableColumn("耗时(ms)", "ExecutionTime"),
|
||||
};
|
||||
if (data == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
return ExportExcelHelper.Export("导出数据", columns, data);
|
||||
|
||||
// 导出到Excel
|
||||
//using (var stream = new MemoryStream())
|
||||
//{
|
||||
// // 获取当前工作目录
|
||||
// string currentPath = Directory.GetCurrentDirectory();
|
||||
// // 创建文件路径
|
||||
// string filePath = Path.Combine(currentPath, "data.xlsx");
|
||||
// //MiniExcel.SaveAs(filePath, data);
|
||||
// MiniExcel.SaveAs(stream, data);
|
||||
// // 重置位置
|
||||
// //stream.Position = 0;
|
||||
// //// 通过接口下载文件
|
||||
// //return File(stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "data.xlsx");
|
||||
// var isXlsx = true;
|
||||
// var saveAsFileName = string.Format("{0}-{1:d}.{2}", "测试", DateTime.Now, (isXlsx ? "xlsx" : "xls")).Replace("/", "-");
|
||||
// var contentType = isXlsx ? "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" : "application/vnd.ms-excel";
|
||||
// return new FileContentResult(stream.ToArray(), contentType) { FileDownloadName = saveAsFileName };
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
104
WCS.WebApi/Controllers/MatBaseInfoController.cs
Normal file
104
WCS.WebApi/Controllers/MatBaseInfoController.cs
Normal file
@ -0,0 +1,104 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using MiniExcelLibs;
|
||||
using NPOI.SS.UserModel;
|
||||
using SqlSugar;
|
||||
using System.Xml.Linq;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.Manager;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.BLL.Services.Service;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel;
|
||||
using WCS.Model.ApiModel.MatBaseInfo;
|
||||
using WCS.WebApi.Helper;
|
||||
|
||||
namespace WCS.WebApi.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 接口记录
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class MatBaseInfoController : ControllerBase
|
||||
{
|
||||
public IMatBaseInfoService _matBaseInfoService { get; set; }
|
||||
|
||||
public MatBaseInfoController(IMatBaseInfoService matBaseInfoService)
|
||||
{
|
||||
_matBaseInfoService = matBaseInfoService;
|
||||
}
|
||||
|
||||
[Route("getMatBaseInfo")]
|
||||
[HttpPost(Name = "getMatBaseInfo")]
|
||||
public async Task<ResponseBase> getMatBaseInfo(GetMatBaseInfoRequest request)
|
||||
{
|
||||
return await _matBaseInfoService.getMatBaseInfo(request);
|
||||
}
|
||||
|
||||
[HttpPost("exportMatBaseInfo")]
|
||||
public async Task<IActionResult> exportMatBaseInfo(GetMatBaseInfoRequest request)
|
||||
{
|
||||
var result = await _matBaseInfoService.exportMatBaseInfo(request);
|
||||
var data = result.Data?.Lists;
|
||||
var columns = new[]
|
||||
{
|
||||
new ExportableColumn("序号","RowNumber"),
|
||||
new ExportableColumn("物料编码","MatCode"),
|
||||
new ExportableColumn("名称","MatName"),
|
||||
new ExportableColumn("规格","MatSpec"),
|
||||
new ExportableColumn("单位","MatUnit"),
|
||||
new ExportableColumn("客户","MatCustomer"),
|
||||
new ExportableColumn("状态","IsEnableStr"),
|
||||
new ExportableColumn("更新人","ModifyUser"),
|
||||
new ExportableColumn("更新时间", "ModifyTime"),
|
||||
};
|
||||
if (data == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
return ExportExcelHelper.Export("导出数据", columns, data);
|
||||
}
|
||||
|
||||
[HttpPost("importMatBaseInfo")]
|
||||
public async Task<ResponseBase> importMatBaseInfo([FromForm] IFormFile excelFile, [FromForm] string userName, [FromForm] string deviceType)
|
||||
{
|
||||
//文件校验
|
||||
if (excelFile == null || excelFile.Length == 0)
|
||||
{
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 201,
|
||||
Message = "导入失败:文件无有效内容!"
|
||||
};
|
||||
}
|
||||
//
|
||||
using (var stream = new MemoryStream())
|
||||
{
|
||||
await excelFile.CopyToAsync(stream);
|
||||
stream.Position = 0;
|
||||
var list = MiniExcelLibs.MiniExcel.Query<MatBaseInfoImportModel>(stream, "物料管理", ExcelType.XLSX).ToList();
|
||||
return await _matBaseInfoService.importMatBaseInfo(list, userName, deviceType);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost("addOrUpdateMatBaseInfo")]
|
||||
public async Task<ResponseCommon<object>> addOrUpdateMatBaseInfo(AddMatBaseInfoRequest<MatBaseInfo> request)
|
||||
{
|
||||
return await _matBaseInfoService.addOrUpdateMatBaseInfo(request);
|
||||
}
|
||||
|
||||
[HttpPost("deleteMatBaseInfo")]
|
||||
public async Task<ResponseCommon<object>> deleteMatBaseInfo(DeleteMatBaseInfosRequest request)
|
||||
{
|
||||
return await _matBaseInfoService.deleteMatBaseInfo(request);
|
||||
}
|
||||
|
||||
[HttpPost("getMatCodeList")]
|
||||
public async Task<ResponseCommon<List<string>>> getMatCodeList(GetMatCodeListRequest request)
|
||||
{
|
||||
return await _matBaseInfoService.getMatCodeList(request);
|
||||
}
|
||||
}
|
||||
}
|
84
WCS.WebApi/Controllers/MatInventoryDetailController.cs
Normal file
84
WCS.WebApi/Controllers/MatInventoryDetailController.cs
Normal file
@ -0,0 +1,84 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using MiniExcelLibs;
|
||||
using NPOI.SS.UserModel;
|
||||
using SqlSugar;
|
||||
using System.Xml.Linq;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.Manager;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.BLL.Services.Service;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel;
|
||||
using WCS.Model.ApiModel.MatInventoryDetail;
|
||||
using WCS.WebApi.Helper;
|
||||
|
||||
namespace WCS.WebApi.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 接口记录
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class MatInventoryDetailController : ControllerBase
|
||||
{
|
||||
public IMatInventoryDetailService _matInventoryDetailService { get; set; }
|
||||
|
||||
public MatInventoryDetailController(IMatInventoryDetailService matInventoryDetailService)
|
||||
{
|
||||
_matInventoryDetailService = matInventoryDetailService;
|
||||
}
|
||||
|
||||
[Route("getMatInventoryDetail")]
|
||||
[HttpPost(Name = "getMatInventoryDetail")]
|
||||
public async Task<ResponseBase> getMatInventoryDetail(GetMatInventoryDetailRequest request)
|
||||
{
|
||||
return await _matInventoryDetailService.getMatInventoryDetail(request);
|
||||
}
|
||||
|
||||
[HttpPost("exportMatInventoryDetail")]
|
||||
public async Task<IActionResult> exportMatInventoryDetail([FromBody] GetMatInventoryDetailRequest request)
|
||||
{
|
||||
var result = await _matInventoryDetailService.exportMatInventoryDetail(request);
|
||||
var data = result.Data?.Lists;
|
||||
var columns = new[]
|
||||
{
|
||||
new ExportableColumn("序号","RowNumber"),
|
||||
new ExportableColumn("物料编码","MatCode"),
|
||||
new ExportableColumn("物料名称","MatName"),
|
||||
new ExportableColumn("规格","MatSpec"),
|
||||
new ExportableColumn("批次","MatBatch"),
|
||||
new ExportableColumn("数量","MatQty"),
|
||||
new ExportableColumn("库位","StoreCode"),
|
||||
new ExportableColumn("入库时间","InstoreTime"),
|
||||
new ExportableColumn("物料SN", "MatSN"),
|
||||
};
|
||||
if (data == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
return ExportExcelHelper.Export("导出数据", columns, data);
|
||||
|
||||
// 导出到Excel
|
||||
//using (var stream = new MemoryStream())
|
||||
//{
|
||||
// // 获取当前工作目录
|
||||
// string currentPath = Directory.GetCurrentDirectory();
|
||||
// // 创建文件路径
|
||||
// string filePath = Path.Combine(currentPath, "data.xlsx");
|
||||
// //MiniExcel.SaveAs(filePath, data);
|
||||
// MiniExcel.SaveAs(stream, data);
|
||||
// // 重置位置
|
||||
// //stream.Position = 0;
|
||||
// //// 通过接口下载文件
|
||||
// //return File(stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "data.xlsx");
|
||||
// var isXlsx = true;
|
||||
// var saveAsFileName = string.Format("{0}-{1:d}.{2}", "测试", DateTime.Now, (isXlsx ? "xlsx" : "xls")).Replace("/", "-");
|
||||
// var contentType = isXlsx ? "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" : "application/vnd.ms-excel";
|
||||
// return new FileContentResult(stream.ToArray(), contentType) { FileDownloadName = saveAsFileName };
|
||||
//}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
162
WCS.WebApi/Controllers/OutstoreController.cs
Normal file
162
WCS.WebApi/Controllers/OutstoreController.cs
Normal file
@ -0,0 +1,162 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WCS.BLL.HardWare;
|
||||
using WCS.BLL.Manager;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.BLL.Services.Service;
|
||||
using WCS.Model;
|
||||
|
||||
namespace WebApi.Controllers
|
||||
{
|
||||
//[ServiceFilter(typeof(LogActionFilter))]
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class OutstoreController : ControllerBase
|
||||
{
|
||||
private readonly IOutstoreService _outstoreService;
|
||||
|
||||
public OutstoreController(IOutstoreService outstoreService)
|
||||
{
|
||||
_outstoreService = outstoreService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD><CFB1><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[Route("sysOutOrderByMatCode")]
|
||||
[HttpPost(Name = "sysOutOrderByMatCode")]
|
||||
public async Task<ResponseBase> sysOutOrderByMatCode(SysOutOrderByMatCodeRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await _outstoreService.SysOutOrderByMatCode(request);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ShelfGoInInstoreResponse()
|
||||
{
|
||||
Code = 300,
|
||||
Message = "ͬ<><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>" + ex.Message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϸͬ<CFB8><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[Route("sysOutOrderByMatSn")]
|
||||
[HttpPost(Name = "sysOutOrderByMatSn")]
|
||||
public async Task<ResponseBase> sysOutOrderByMatSn(SysOutOrderByMatSnRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await _outstoreService.SysOutOrderByMatSn(request);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ShelfGoInInstoreResponse()
|
||||
{
|
||||
Code = 300,
|
||||
Message = "ͬ<><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>" + ex.Message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <20><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD>ⵥ<EFBFBD>б<EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[Route("getOutOrderList")]
|
||||
[HttpPost(Name = "getOutOrderList")]
|
||||
public async Task<ResponseBase> getOutOrderList(GetOutOrderListRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await _outstoreService.GetOutOrderList(request);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ShelfGoInInstoreResponse()
|
||||
{
|
||||
Code = 300,
|
||||
Message = "<22><>ѯʧ<D1AF>ܣ<EFBFBD>" + ex.Message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><>ȡ<EFBFBD><C8A1><EFBFBD>ⵥ<EFBFBD>ij<EFBFBD><C4B3><EFBFBD><EFBFBD><EFBFBD>ϸ
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[Route("getOutOrderDetail")]
|
||||
[HttpPost(Name = "getOutOrderDetail")]
|
||||
public async Task<ResponseBase> getOutOrderDetail(GetOutOrderDetailRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await _outstoreService.GetOutOrderDetail(request);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ShelfGoInInstoreResponse()
|
||||
{
|
||||
Code = 300,
|
||||
Message = "<22><>ѯʧ<D1AF>ܣ<EFBFBD>" + ex.Message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD>ⵥ<EFBFBD>ݺſ<DDBA>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[Route("goInOutstore")]
|
||||
[HttpPost(Name = "goInOutstore")]
|
||||
public async Task<ResponseBase> goInOutstore(GetOutOrderDetailRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await _outstoreService.GetOutOrderDetail(request);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ShelfGoInInstoreResponse()
|
||||
{
|
||||
Code = 300,
|
||||
Message = "<22><>ѯʧ<D1AF>ܣ<EFBFBD>" + ex.Message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD>ⵥ<EFBFBD>ݺ<EFBFBD><DDBA>˳<EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[Route("goOutOutstore")]
|
||||
[HttpPost(Name = "goOutOutstore")]
|
||||
public async Task<ResponseBase> goOutOutstore(GetOutOrderDetailRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await _outstoreService.GetOutOrderDetail(request);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ShelfGoInInstoreResponse()
|
||||
{
|
||||
Code = 300,
|
||||
Message = "<22><>ѯʧ<D1AF>ܣ<EFBFBD>" + ex.Message,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
94
WCS.WebApi/Controllers/RequestResponseLoggingMiddleware.cs
Normal file
94
WCS.WebApi/Controllers/RequestResponseLoggingMiddleware.cs
Normal file
@ -0,0 +1,94 @@
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using WCS.BLL;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.DAL.Db;
|
||||
|
||||
namespace WCS.WebApi.Controllers
|
||||
{
|
||||
public class RequestResponseLoggingMiddleware
|
||||
{
|
||||
private readonly RequestDelegate _next;
|
||||
|
||||
public RequestResponseLoggingMiddleware(RequestDelegate next)
|
||||
{
|
||||
_next = next;
|
||||
}
|
||||
|
||||
public async Task InvokeAsync(HttpContext context)
|
||||
{
|
||||
var stopwatch = Stopwatch.StartNew();
|
||||
|
||||
var requestBody = string.Empty;
|
||||
var responseBody = string.Empty;
|
||||
var originalRequestBody = context.Request.Body;
|
||||
var requestTime = DateTime.Now;
|
||||
|
||||
// 可以选择只记录特定的Content-RequestType //只记录json类型的请求
|
||||
if (context.Request.ContentType != null && !context.Request.ContentType.Contains("application/json", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
;
|
||||
}
|
||||
try
|
||||
{
|
||||
////读取Request Body
|
||||
//// 保存原始的Request Body
|
||||
var requestBodyStream = new MemoryStream();
|
||||
await originalRequestBody.CopyToAsync(requestBodyStream);
|
||||
originalRequestBody.Dispose();
|
||||
requestBodyStream.Position = 0; // 将流的位置重置回开始处
|
||||
requestBody = await new StreamReader(requestBodyStream).ReadToEndAsync();
|
||||
// 替换Request.Body以便后续中间件可以读取
|
||||
requestBodyStream.Position = 0;// 将流的位置重置回开始处
|
||||
context.Request.Body = requestBodyStream;
|
||||
|
||||
|
||||
// 保存原始的Response Body
|
||||
var originalResponseBodyStream = context.Response.Body;
|
||||
using (var memStream = new MemoryStream())
|
||||
{
|
||||
context.Response.Body = memStream;
|
||||
|
||||
// 继续处理请求
|
||||
await _next(context);
|
||||
|
||||
memStream.Seek(0, SeekOrigin.Begin);
|
||||
responseBody = await new StreamReader(memStream).ReadToEndAsync();
|
||||
|
||||
memStream.Seek(0, SeekOrigin.Begin);
|
||||
await memStream.CopyToAsync(originalResponseBodyStream);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//Logs.Write(e.Message);
|
||||
}
|
||||
|
||||
finally
|
||||
{
|
||||
//TO DO如何将记日志的 和不记日志的分开 解耦
|
||||
if (!context.Request.Path.ToString().Contains("getInterfaceRecord"))
|
||||
try
|
||||
{
|
||||
var logRecord = new SystemApiLogRecord()
|
||||
{
|
||||
DeviceIp = context?.Connection?.RemoteIpAddress?.ToString(),
|
||||
RequestUrl = context.Request.Path,
|
||||
RequestBody = requestBody,
|
||||
QueryString = context.Request.QueryString.ToString(),
|
||||
IsResponse = true,
|
||||
ResponseJson = responseBody,
|
||||
RequestTime = requestTime,
|
||||
ResponseTime = DateTime.Now,
|
||||
ExecutionTime = stopwatch.ElapsedMilliseconds
|
||||
};
|
||||
await DbHelp.dbLog.Insertable(logRecord).ExecuteCommandAsync();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//TO DO txt记录失败的日志和响应实体
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
39
WCS.WebApi/Controllers/StoreInfoController.cs
Normal file
39
WCS.WebApi/Controllers/StoreInfoController.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.BLL.Services.Service;
|
||||
using WCS.Model.ApiModel.MatInventoryDetail;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel.StoreInfo;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.Model.ApiModel.MatBaseInfo;
|
||||
using WCS.DAL.DbModels;
|
||||
|
||||
namespace WCS.WebApi.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 货架\、库位管理的页面
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class StoreInfoController : ControllerBase
|
||||
{
|
||||
public IStoreInfoService _storeInfoService { get; set; }
|
||||
public StoreInfoController(IStoreInfoService storeInfoService)
|
||||
{
|
||||
_storeInfoService = storeInfoService;
|
||||
}
|
||||
|
||||
[Route("getShelves")]
|
||||
[HttpPost(Name = "getShelves")]
|
||||
public async Task<ResponseBase> getShelves(GetShelvesRequest request)
|
||||
{
|
||||
return await _storeInfoService.GetShelves(request);
|
||||
}
|
||||
|
||||
[HttpPost("addOrUpdateShelfInfo")]
|
||||
public async Task<ResponseCommon<object>> addOrUpdateShelfInfo(AddShelfInfoRequest<ShelfInfo> request)
|
||||
{
|
||||
return await _storeInfoService.addOrUpdateShelfInfo(request);
|
||||
}
|
||||
}
|
||||
}
|
58
WCS.WebApi/Controllers/UserController.cs
Normal file
58
WCS.WebApi/Controllers/UserController.cs
Normal file
@ -0,0 +1,58 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel;
|
||||
using WCS.Model.ApiModel.User;
|
||||
|
||||
namespace WCS.WebApi.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 权限/用户界面的接口
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class UserController : ControllerBase
|
||||
{
|
||||
public IUserService _userService { get; set; }
|
||||
|
||||
public UserController(IUserService userService)
|
||||
{
|
||||
_userService = userService;
|
||||
}
|
||||
|
||||
[Route("getUsers")]
|
||||
[HttpPost(Name = "getUsers")]
|
||||
public async Task<ResponseBase> getUsers(GetUsersRequest request)
|
||||
{
|
||||
return await _userService.GetUsers(request);
|
||||
}
|
||||
|
||||
[Route("addUser")]
|
||||
[HttpPost(Name = "addUser")]
|
||||
public async Task<ResponseBase> addUser(AddUserRequest<UserModel> request)
|
||||
{
|
||||
return await _userService.AddUser(request);
|
||||
}
|
||||
|
||||
[Route("getRoles")]
|
||||
[HttpPost(Name = "getRoles")]
|
||||
public async Task<ResponseBase> getRoles(GetUsersRequest request)
|
||||
{
|
||||
return await _userService.GetRoles(request);
|
||||
}
|
||||
|
||||
[Route("addRole")]
|
||||
[HttpPost(Name = "addRole")]
|
||||
public async Task<ResponseBase> addRole(AddRoleRequest<RoleModel> request)
|
||||
{
|
||||
return await _userService.AddRole(request);
|
||||
}
|
||||
|
||||
[Route("userLogin")]
|
||||
[HttpPost(Name = "userLogin")]
|
||||
public async Task<ResponseBase> userLogin(UserLoginRequest request)
|
||||
{
|
||||
return await _userService.UserLogin(request);
|
||||
}
|
||||
}
|
||||
}
|
249
WCS.WebApi/Helper/ExportExcelHelper.cs
Normal file
249
WCS.WebApi/Helper/ExportExcelHelper.cs
Normal file
@ -0,0 +1,249 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NPOI.HSSF.UserModel;
|
||||
using NPOI.SS.UserModel;
|
||||
using NPOI.XSSF.UserModel;
|
||||
using System.Data;
|
||||
using System.Dynamic;
|
||||
|
||||
namespace WCS.WebApi.Helper
|
||||
{
|
||||
public class ExportExcelHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
/// <param name="sheetName">文件名</param>
|
||||
/// <param name="columns">标题行</param>
|
||||
/// <param name="results">数据源</param>
|
||||
/// <returns></returns>
|
||||
public static ActionResult ExportExcel(string sheetName, List<ExportableColumn> columns, IList<dynamic> results)
|
||||
{
|
||||
var isXlsx = false;
|
||||
IWorkbook workbook = new HSSFWorkbook();
|
||||
if (results.Count + 1 > 65536)// 包括一行标题行 .xls文件最大行数
|
||||
{
|
||||
workbook = new XSSFWorkbook();
|
||||
isXlsx = true;
|
||||
}
|
||||
workbook.CreateSheet(sheetName);
|
||||
|
||||
var rowIndex = 0;
|
||||
AddHeader(workbook, rowIndex, columns);
|
||||
|
||||
rowIndex++;
|
||||
workbook = AddData(workbook, rowIndex, columns, results);
|
||||
|
||||
// Save the Excel spreadsheet to a MemoryStream and return it to the client
|
||||
using (var exportData = new MemoryStream())
|
||||
{
|
||||
workbook.Write(exportData);
|
||||
var saveAsFileName = string.Format("{0}-{1:d}.{2}", sheetName, DateTime.Now, (isXlsx ? "xlsx" : "xls")).Replace("/", "-");
|
||||
var contentType = isXlsx ? "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" : "application/vnd.ms-excel";
|
||||
return new FileContentResult(exportData.ToArray(), contentType) { FileDownloadName = saveAsFileName };
|
||||
}
|
||||
}
|
||||
|
||||
public static ActionResult Export<T>(string sheetName, IList<ExportableColumn> columns, IEnumerable<T> results)
|
||||
{
|
||||
var isXlsx = false;
|
||||
IWorkbook workbook = new HSSFWorkbook();
|
||||
if (results.Count() + 1 > 65536)// 包括一行标题行 .xls文件最大行数
|
||||
{
|
||||
workbook = new XSSFWorkbook();
|
||||
isXlsx = true;
|
||||
}
|
||||
workbook.CreateSheet(sheetName);
|
||||
var rowIndex = 0;
|
||||
|
||||
AddHeader(workbook, rowIndex, columns);
|
||||
|
||||
rowIndex++;
|
||||
workbook = AddData(workbook, rowIndex, columns, results);
|
||||
|
||||
// Save the Excel spreadsheet to a MemoryStream and return it to the client
|
||||
using (var exportData = new MemoryStream())
|
||||
{
|
||||
workbook.Write(exportData);
|
||||
var saveAsFileName = string.Format("{0}-{1:d}.{2}", sheetName, DateTime.Now, (isXlsx ? "xlsx" : "xls")).Replace("/", "-");
|
||||
var contentType = isXlsx ? "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" : "application/vnd.ms-excel";
|
||||
return new FileContentResult(exportData.ToArray(), contentType) { FileDownloadName = saveAsFileName };
|
||||
}
|
||||
}
|
||||
|
||||
public static ActionResult Export<T>(
|
||||
string sheetName,
|
||||
string firstData,
|
||||
IList<ExportableColumn> columns,
|
||||
IEnumerable<T> results
|
||||
)
|
||||
{
|
||||
IWorkbook workbook = new HSSFWorkbook();
|
||||
var sheet = workbook.CreateSheet(sheetName);
|
||||
var rowIndex = 0;
|
||||
|
||||
// first row data
|
||||
var firstRow = sheet.CreateRow(rowIndex);
|
||||
firstRow.CreateCell(0).SetCellValue(firstData);
|
||||
rowIndex++;
|
||||
|
||||
AddHeader(workbook, rowIndex, columns);
|
||||
|
||||
rowIndex++;
|
||||
workbook = AddData(workbook, rowIndex, columns, results);
|
||||
|
||||
// Save the Excel spreadsheet to a MemoryStream and return it to the client
|
||||
using (var exportData = new MemoryStream())
|
||||
{
|
||||
workbook.Write(exportData);
|
||||
string saveAsFileName = string.Format("{0}-{1:d}.xls", sheetName, DateTime.Now).Replace("/", "-");
|
||||
return new FileContentResult(exportData.ToArray(), "application/vnd.ms-excel") { FileDownloadName = saveAsFileName };
|
||||
}
|
||||
}
|
||||
|
||||
#region 数据操作
|
||||
public static IWorkbook AddData(IWorkbook workbook, int rowIndex, List<ExportableColumn> columns, IList<dynamic> results)
|
||||
{
|
||||
const int MaxRowCount = 1048575; //.xlsx文件最大行数1048576
|
||||
var sheet = workbook.GetSheetAt(0);
|
||||
|
||||
// Add data rows
|
||||
foreach (var viewModel in results)
|
||||
{
|
||||
var row = sheet.CreateRow(rowIndex);
|
||||
if (rowIndex >= MaxRowCount)
|
||||
{
|
||||
row.CreateCell(0).SetCellValue("数据行数已超出Excel文件支持的最大行数!");
|
||||
break;
|
||||
}
|
||||
|
||||
for (var index = 0; index < columns.Count; index++)
|
||||
{
|
||||
var propertyName = columns[index].Name.Trim();
|
||||
var cell = row.CreateCell(index);
|
||||
var propertyDictionary = (IDictionary<string, object>)viewModel;
|
||||
if (propertyDictionary.ContainsKey(propertyName))
|
||||
{
|
||||
var value = propertyDictionary[propertyName];
|
||||
cell.SetCellValue(value == null ? "" : value.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
rowIndex++;
|
||||
}
|
||||
|
||||
return workbook;
|
||||
}
|
||||
|
||||
public static IWorkbook AddData<T>(IWorkbook workbook, int rowIndex, IList<ExportableColumn> columns, IEnumerable<T> results)
|
||||
{
|
||||
const int MaxRowCount = 1048575; //.xlsx文件最大行数1048576
|
||||
var sheet = workbook.GetSheetAt(0);
|
||||
|
||||
// Add data rows
|
||||
foreach (var viewModel in results)
|
||||
{
|
||||
var row = sheet.CreateRow(rowIndex);
|
||||
if (rowIndex >= MaxRowCount)
|
||||
{
|
||||
row.CreateCell(0).SetCellValue("数据行数已超出Excel文件支持的最大行数!");
|
||||
break;
|
||||
}
|
||||
|
||||
for (int index = 0; index < columns.Count; index++)
|
||||
{
|
||||
var cell = row.CreateCell(index);
|
||||
var dr = viewModel as DataRow;
|
||||
var value = (dr != null) ? dr[columns[index].Name]
|
||||
: viewModel.GetType().GetProperty(columns[index].Name)?.GetValue(viewModel, null);
|
||||
|
||||
if (value == null)
|
||||
{
|
||||
var item = viewModel as ExpandoObject;
|
||||
if (item != null)
|
||||
{
|
||||
if (item.Any(w => w.Key == columns[index].Name))
|
||||
{
|
||||
var keyValue = item.FirstOrDefault(w => w.Key == columns[index].Name);
|
||||
value = keyValue.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (value == null)
|
||||
{
|
||||
var item = viewModel as JObject;
|
||||
if (item != null)
|
||||
{
|
||||
value = item[columns[index].Name];
|
||||
}
|
||||
}
|
||||
|
||||
cell.SetCellValue(value == null ? "" : value.ToString());
|
||||
}
|
||||
|
||||
rowIndex++;
|
||||
}
|
||||
|
||||
return workbook;
|
||||
}
|
||||
|
||||
public static void AddHeader(IWorkbook workbook, int rowIndex, IList<ExportableColumn> columns)
|
||||
{
|
||||
var sheet = workbook.GetSheetAt(0);
|
||||
var format = workbook.CreateDataFormat();
|
||||
|
||||
// Add header labels
|
||||
var headerRow = sheet.CreateRow(rowIndex);
|
||||
for (int index = 0; index < columns.Count; index++)
|
||||
{
|
||||
headerRow.CreateCell(index).SetCellValue(columns[index].Caption);
|
||||
if (!string.IsNullOrEmpty(columns[index].Format))
|
||||
{
|
||||
var columnStyle = workbook.CreateCellStyle();
|
||||
columnStyle.DataFormat = format.GetFormat(columns[index].Format);
|
||||
sheet.SetDefaultColumnStyle(index, columnStyle);
|
||||
}
|
||||
if (columns[index].ColumnWidth.HasValue && columns[index].ColumnWidth.Value > 0)
|
||||
{
|
||||
var columnWidth = columns[index].ColumnWidth.Value;
|
||||
sheet.SetColumnWidth(index, columnWidth * 256 / 7);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class ExportableColumn
|
||||
{
|
||||
public ExportableColumn(string caption, string name) : this(caption, name, null)
|
||||
{
|
||||
}
|
||||
|
||||
public ExportableColumn(string caption, string name, string format)
|
||||
{
|
||||
Format = format;
|
||||
Caption = caption;
|
||||
Name = name;
|
||||
}
|
||||
|
||||
public ExportableColumn(string caption, string name, string format, int? width)
|
||||
: this(caption, name, format)
|
||||
{
|
||||
ColumnWidth = width;
|
||||
}
|
||||
|
||||
public string Name { get; }
|
||||
public string Caption { get; }
|
||||
public string Format { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 单位:像素,为空时使用默认值
|
||||
/// </summary>
|
||||
public int? ColumnWidth { get; private set; }
|
||||
|
||||
public ExportableColumn Width(int? width)
|
||||
{
|
||||
ColumnWidth = width;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
9
WCS.WebApi/LocalStatic.cs
Normal file
9
WCS.WebApi/LocalStatic.cs
Normal file
@ -0,0 +1,9 @@
|
||||
using WCS.BLL;
|
||||
|
||||
namespace WCS.WebApi
|
||||
{
|
||||
public static class LocalStatic
|
||||
{
|
||||
|
||||
}
|
||||
}
|
81
WCS.WebApi/Program.cs
Normal file
81
WCS.WebApi/Program.cs
Normal file
@ -0,0 +1,81 @@
|
||||
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Core;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using TouchSocket.Core;
|
||||
using TouchSocket.Sockets;
|
||||
using WCS.BLL.Manager;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.BLL.Services.Service;
|
||||
using WCS.DAL;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.WebApi;
|
||||
using WCS.WebApi.Controllers;
|
||||
using TcpClient = TouchSocket.Sockets.TcpClient;
|
||||
|
||||
namespace WebApi
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
|
||||
|
||||
//LocalStatic.wCSTcpCleint = new WCS.BLL.TCPClient("127.0.0.1:20002");
|
||||
//LocalStatic.wCSTcpCleint.Send(new byte[] { 0x08, 0x00, 0x00, 0x11, 0x12, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });
|
||||
|
||||
DbHelp.InitDb();
|
||||
AuthDbHelp.InitDb();
|
||||
|
||||
ShelfManager.InitShelves();
|
||||
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
//// <20><><EFBFBD><EFBFBD>Kestrel
|
||||
//builder.WebHost.ConfigureKestrel((context, options) =>
|
||||
//{
|
||||
// // <20><><EFBFBD>ü<EFBFBD><C3BC><EFBFBD><EFBFBD>˿<EFBFBD>
|
||||
// options.Listen(IPAddress.Any, 8888); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IP<49><50>ַ<EFBFBD><D6B7>5001<30>˿<EFBFBD>
|
||||
|
||||
// // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// options.Limits.MaxRequestBodySize = 10 * 1024 * 1024; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>СΪ10MB
|
||||
// options.Limits.MaxConcurrentConnections = 1000; // <20><><EFBFBD><EFBFBD><F3B2A2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// options.Limits.MinRequestBodyDataRate = new MinDataRate(bytesPerSecond: 100, gracePeriod: TimeSpan.FromSeconds(10)); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
// // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>SSL/TLS<4C><53><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӵ<EFBFBD><D3B4><EFBFBD>
|
||||
// // <20><><EFBFBD><EFBFBD>: options.Listen(IPAddress.Any, 5000, listenOptions => { listenOptions.UseHttps("path_to_certificate.pfx", "certificate_password"); });
|
||||
//});
|
||||
// Add services to the container.
|
||||
builder.Services.AddControllers();
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
|
||||
builder.Services.AddScoped<IInstoreService, InstoreService>();
|
||||
builder.Services.AddScoped<IOutstoreService, OutstoreService>();
|
||||
builder.Services.AddScoped<IHomerService, HomerService>();
|
||||
builder.Services.AddScoped<IUserService, UserService>();
|
||||
builder.Services.AddScoped<IInterfaceRecordService, InterfaceRecordService>();
|
||||
builder.Services.AddScoped<IMatBaseInfoService, MatBaseInfoService>();
|
||||
builder.Services.AddScoped<IMatInventoryDetailService, MatInventoryDetailService>();
|
||||
builder.Services.AddScoped<IStoreInfoService, StoreInfoService>();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
app.UseMiddleware<RequestResponseLoggingMiddleware>();
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
}
|
||||
|
||||
app.UseAuthorization();
|
||||
app.MapControllers();
|
||||
app.Run("http://+:8888");
|
||||
}
|
||||
}
|
||||
}
|
22
WCS.WebApi/Properties/PublishProfiles/FolderProfile.pubxml
Normal file
22
WCS.WebApi/Properties/PublishProfiles/FolderProfile.pubxml
Normal file
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
-->
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<DeleteExistingFiles>false</DeleteExistingFiles>
|
||||
<ExcludeApp_Data>false</ExcludeApp_Data>
|
||||
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
|
||||
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
|
||||
<LastUsedPlatform>Any CPU</LastUsedPlatform>
|
||||
<PublishProvider>FileSystem</PublishProvider>
|
||||
<PublishUrl>bin\Release\net6.0\publish\</PublishUrl>
|
||||
<WebPublishMethod>FileSystem</WebPublishMethod>
|
||||
<_TargetId>Folder</_TargetId>
|
||||
<SiteUrlToLaunchAfterPublish />
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||
<ProjectGuid>118d453b-1693-4c00-8378-20ecbfcf2700</ProjectGuid>
|
||||
<SelfContained>false</SelfContained>
|
||||
</PropertyGroup>
|
||||
</Project>
|
31
WCS.WebApi/Properties/launchSettings.json
Normal file
31
WCS.WebApi/Properties/launchSettings.json
Normal file
@ -0,0 +1,31 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:60772",
|
||||
"sslPort": 0
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"WCS.WebApi": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"applicationUrl": "http://localhost:5055",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
22
WCS.WebApi/WCS.WebApi.csproj
Normal file
22
WCS.WebApi/WCS.WebApi.csproj
Normal file
@ -0,0 +1,22 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
|
||||
<PackageReference Include="MiniExcel" Version="1.31.3" />
|
||||
<PackageReference Include="NPOI" Version="2.7.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
|
||||
<PackageReference Include="TouchSocket" Version="2.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\WCS.BLL\WCS.BLL.csproj" />
|
||||
<ProjectReference Include="..\WCS.Model\WCS.Model.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user