Commit e4765c6a by Seniorious

1

parent cda74cdc
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
public string id { get; set; } public string id { get; set; }
} }
public class PictureReq public class PictureReq
{ {
public string policeId { get; set; } public string policeId { get; set; }
...@@ -23,7 +22,13 @@ ...@@ -23,7 +22,13 @@
public class GetLogPictureReq public class GetLogPictureReq
{ {
public string logId { get; set;} public string pid { get; set;}
} }
public class LogPictureReq
{
public IFormFile picture { get; set; }
public string fileName { get; set; }//文件名
public string directoy { get; set; }//文件夹
}
} }
...@@ -71,6 +71,8 @@ namespace APIs ...@@ -71,6 +71,8 @@ namespace APIs
services.AddScoped<IThisInfoService, ThisInfoService>(); services.AddScoped<IThisInfoService, ThisInfoService>();
services.AddScoped<IDevService, DevService>(); services.AddScoped<IDevService, DevService>();
services.AddScoped<IDevHistoryService, DevHistoryService>(); services.AddScoped<IDevHistoryService, DevHistoryService>();
services.AddScoped<IWarehouseService, WarehouseService>();
services.AddScoped<ISupplierService, SupplierService>();
#endregion #endregion
#region Repository #region Repository
...@@ -91,6 +93,8 @@ namespace APIs ...@@ -91,6 +93,8 @@ namespace APIs
services.AddScoped<IThisInfoRepository, ThisInfoRepository>(); services.AddScoped<IThisInfoRepository, ThisInfoRepository>();
services.AddScoped<IDevRepository, DevRepository>(); services.AddScoped<IDevRepository, DevRepository>();
services.AddScoped<IDevHistoryRepository, DevHistoryRepository>(); services.AddScoped<IDevHistoryRepository, DevHistoryRepository>();
services.AddScoped<IWarehouseRepository, WarehouseRepository>();
services.AddScoped<ISupplierRepository, SupplierRepository>();
#endregion #endregion
#region 注册RabbitMQ消费者 #region 注册RabbitMQ消费者
......
...@@ -55,6 +55,13 @@ namespace Common.Utility.Model ...@@ -55,6 +55,13 @@ namespace Common.Utility.Model
public String equipments { get; set; } public String equipments { get; set; }
[AllowNull] [AllowNull]
public List<EquipmentList>? equipmentList { get; set; } public List<EquipmentList>? equipmentList { get; set; }
// }
public class ChannelLogReq
{
public List<string> Epc { get; set; }
public int? state { get; set; }
public string warehouseId { get; set; }
public string picture { get; set; }
} }
} }
...@@ -15,20 +15,20 @@ namespace Models.Table ...@@ -15,20 +15,20 @@ namespace Models.Table
{ {
[SugarColumn(IsIdentity = true, IsPrimaryKey = true)] [SugarColumn(IsIdentity = true, IsPrimaryKey = true)]
public String id { get; set; } public string id { get; set; }
public String code { get; set; } public string code { get; set; }
[SugarColumn(ColumnName = "type_id")] [SugarColumn(ColumnName = "type_id")]
public String? typeId { get; set; } public string typeId { get; set; }
[SugarColumn(ColumnName = "name")] [SugarColumn(ColumnName = "name")]
public String? name { get; set; } public string name { get; set; }
public String? note { get; set; } public string note { get; set; }
public String? price { get; set; } public string price { get; set; }
public String? state { get; set; } public string state { get; set; }
} }
......
using SqlSugar; using Models.SqlModel;
using SqlSugar;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Security.Principal; using System.Security.Principal;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using static Dm.net.buffer.ByteArrayBuffer;
namespace Models.Table namespace Models.Table
{ {
...@@ -12,54 +14,73 @@ namespace Models.Table ...@@ -12,54 +14,73 @@ namespace Models.Table
public class Inventory : BaseTable public class Inventory : BaseTable
{ {
[SugarColumn(IsIdentity = true, IsPrimaryKey = true)] [SugarColumn(IsIdentity = true, IsPrimaryKey = true)]
public String id { get; set; } public string id { get; set; }
[SugarColumn(ColumnName = "type_id")] [SugarColumn(ColumnName = "type_id")]
public String typeId { get; set; } public string typeId { get; set; }
[SugarColumn(ColumnName = "size_id")] [SugarColumn(ColumnName = "size_id")]
public String sizeId { get; set; } public string sizeId { get; set; }
[SugarColumn(ColumnName = "supplier_id")] [SugarColumn(ColumnName = "supplier_id")]
public String supplierId { get; set; } public string supplierId { get; set; }
public String epc { get; set; } public string epc { get; set; }
[SugarColumn(ColumnName = "org_id")] [SugarColumn(ColumnName = "org_id")]
public String orgId { get; set; } public long? orgId { get; set; }
public String state { get; set; } public string state { get; set; }
[SugarColumn(ColumnName = "bussiness_state")] [SugarColumn(ColumnName = "bussiness_state")]
public String bussinessState { get; set; } public string bussinessState { get; set; }
[SugarColumn(ColumnName = "equ_state")]
public string equState { get; set; }
[SugarColumn(ColumnName = "production_date")] [SugarColumn(ColumnName = "production_date")]
public DateTime? productionDate { get; set; } public DateTime? productionDate { get; set; }
[SugarColumn(ColumnName = "warranty_period")] [SugarColumn(ColumnName = "warranty_period")]
public String warrantyPeriod { get; set; } public string warrantyPeriod { get; set; }
[SugarColumn(ColumnName = "maintenance_period")] [SugarColumn(ColumnName = "maintenance_period")]
public String maintenancePeriod { get; set; } public string maintenancePeriod { get; set; }
[SugarColumn(ColumnName = "fix_count")] [SugarColumn(ColumnName = "fix_count")]
public String fixCount { get; set; } public string fixCount { get; set; }
[SugarColumn(ColumnName = "location_id")] [SugarColumn(ColumnName = "location_id")]
public String locationId { get; set; } public string locationId { get; set; }
[SugarColumn(ColumnName = "location_name")]
public string locationName { get; set; }
[SugarColumn(ColumnName = "location_type")] [SugarColumn(ColumnName = "location_type")]
public String locationType { get; set; } public string locationType { get; set; }
[SugarColumn(ColumnName = "lost_flag")] [SugarColumn(ColumnName = "lost_flag")]
public String lostFlag { get; set; } public string lostFlag { get; set; }
[SugarColumn(ColumnName = "note")]
public string note { get; set; }
[SugarColumn(ColumnName = "equipment_type")]
public string equipmentType { get; set; }
public String price { get; set; } public decimal? price { get; set; }
[SugarColumn(ColumnName = "type_name")] [SugarColumn(ColumnName = "type_name")]
public String typeName { get; set; } public string typeName { get; set; }
[SugarColumn(ColumnName = "size_name")] [SugarColumn(ColumnName = "size_name")]
public String sizeName { get; set; } public string sizeName { get; set; }
[SugarColumn(ColumnName = "supplier_name")]
public string supplierName { get; set; }
[SugarColumn(ColumnName = "package_id")]
public string packageId { get; set; }
} }
} }
...@@ -15,24 +15,24 @@ namespace Models.Table ...@@ -15,24 +15,24 @@ namespace Models.Table
public int id { get; set; } public int id { get; set; }
[SugarColumn(ColumnName = "inventory_id")] [SugarColumn(ColumnName = "inventory_id")]
public int inventoryId { get; set; } public string inventoryId { get; set; }
[SugarColumn(ColumnName = "summary_id")] [SugarColumn(ColumnName = "summary_id")]
public int summaryId { get; set; } public int summaryId { get; set; }
public String epc { get; set; } public string epc { get; set; }
[SugarColumn(ColumnName = "equipment_name")] [SugarColumn(ColumnName = "equipment_name")]
public String? equipmentName { get; set; } public string equipmentName { get; set; }
[SugarColumn(ColumnName = "equipment_size")] [SugarColumn(ColumnName = "equipment_size")]
public String? equipmentSize { get; set; } public string equipmentSize { get; set; }
[SugarColumn(ColumnName = "equipment_type_id")] [SugarColumn(ColumnName = "equipment_type_id")]
public String? equipmentTypeId { get; set; } public string equipmentTypeId { get; set; }
[SugarColumn(ColumnName = "equipment_size_id")] [SugarColumn(ColumnName = "equipment_size_id")]
public String? equipmentSizeId { get; set; } public string equipmentSizeId { get; set; }
[SugarColumn(ColumnName = "error_state")] [SugarColumn(ColumnName = "error_state")]
public int? errorState { get; set; } public int? errorState { get; set; }
...@@ -43,16 +43,16 @@ namespace Models.Table ...@@ -43,16 +43,16 @@ namespace Models.Table
public int? carid { get; set; } public int? carid { get; set; }
[SugarColumn(ColumnName = "order_id")] [SugarColumn(ColumnName = "order_id")]
public String? orderId { get; set; } public string orderId { get; set; }
[SugarColumn(ColumnName = "order_code")] [SugarColumn(ColumnName = "order_code")]
public String? orderCode { get; set; } public string orderCode { get; set; }
[SugarColumn(ColumnName = "supplier_id")] [SugarColumn(ColumnName = "supplier_id")]
public String? supplierId { get; set; } public string supplierId { get; set; }
[SugarColumn(ColumnName = "supplier_name")] [SugarColumn(ColumnName = "supplier_name")]
public String? supplierName { get; set; } public string supplierName { get; set; }
[SugarColumn(ColumnName = "equipment_type")] [SugarColumn(ColumnName = "equipment_type")]
public int? equipmentType { get; set; } public int? equipmentType { get; set; }
......
...@@ -41,7 +41,7 @@ namespace Models.Table ...@@ -41,7 +41,7 @@ namespace Models.Table
public String? device { get; set; } public String? device { get; set; }
[SugarColumn(ColumnName = "device_type")] [SugarColumn(ColumnName = "device_type")]
public int? device_type { get; set; } public int? deviceType { get; set; }
[SugarColumn(ColumnName = "location_id")] [SugarColumn(ColumnName = "location_id")]
public String? locationId { get; set; } public String? locationId { get; set; }
...@@ -63,5 +63,6 @@ namespace Models.Table ...@@ -63,5 +63,6 @@ namespace Models.Table
[Navigate(NavigateType.OneToMany, nameof(LogDetail.summaryId))] [Navigate(NavigateType.OneToMany, nameof(LogDetail.summaryId))]
public List<LogDetail> DetailList { get; set; } = new List<LogDetail>(); public List<LogDetail> DetailList { get; set; } = new List<LogDetail>();
} }
} }
...@@ -41,5 +41,11 @@ namespace Models.Table ...@@ -41,5 +41,11 @@ namespace Models.Table
public int? actualNum { get; set; } public int? actualNum { get; set; }
public decimal? price { get; set; } public decimal? price { get; set; }
[SugarColumn(ColumnName = "warehouse_id")]
public string warehouseId { get; set; }
[SugarColumn(ColumnName = "warehouse_name")]
public string warehouseName { get; set; }
} }
} }
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;
using static Dm.net.buffer.ByteArrayBuffer;
namespace Models.Table
{
[SugarTable("base_supplier")]
public class Supplier : BaseTable
{
[SugarColumn(IsPrimaryKey = true)]
public string id { get; set; }
public string name { get; set; }
public string code { get; set; }
[SugarColumn(ColumnName = "short_name")]
public string shortName { get; set; }
public string contacts { get; set; }
public string phone { get; set; }
[SugarColumn(ColumnName = "create_user")]
public string createUser { get; set; }
[SugarColumn(ColumnName = "update_user")]
public string updateUser { get; set; }
public string state { get; set; }
}
}
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Models.Table
{
[SugarTable("base_warehouse")]
public class Warehouse : BaseTable
{
[SugarColumn(IsPrimaryKey = true)]
public string id { get; set; }
public string name { get; set; }
public string location { get; set; }
public string phone { get; set; }
[SugarColumn(ColumnName = "is_locked")]
public int? isLocked { get; set; }
[SugarColumn(ColumnName = "org_id")]
public string orgId { get; set; }
public int? sum { get; set; }
[SugarColumn(ColumnName = "out_sum")]
public int? outSum { get; set; }
[SugarColumn(ColumnName = "in_sum")]
public int? inSum { get; set; }
[SugarColumn(ColumnName = "price_total")]
public decimal? priceTotal { get; set; }
public int? state { get; set; }
}
}
...@@ -15,5 +15,7 @@ namespace Repositories.IRepository.IBussiness ...@@ -15,5 +15,7 @@ namespace Repositories.IRepository.IBussiness
Task<bool> AddHandLogs(LogSummary model, List<Inventory> invs); Task<bool> AddHandLogs(LogSummary model, List<Inventory> invs);
Task<bool> AddChannelLog(OrderMain? myOrder, LogSummary summary, List<Inventory> newInvs, Tuple<string, string> inv_states);
} }
} }
using Models.Table;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Repositories.IRepository.IBussiness
{
public interface ISupplierRepository : IBaseRepository<Supplier>
{
}
}
using Models.Table;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Repositories.IRepository.IBussiness
{
public interface IWarehouseRepository : IBaseRepository<Warehouse>
{
}
}
...@@ -21,6 +21,92 @@ namespace Repositories.Repository.Bussiness ...@@ -21,6 +21,92 @@ namespace Repositories.Repository.Bussiness
_suger = sugarUnitOfWork; _suger = sugarUnitOfWork;
} }
public async Task<bool> AddChannelLog(OrderMain? myOrder, LogSummary summary, List<Inventory> newInvs, Tuple<string,string> inv_states)
{
using (var context = _suger.GetDbClient())
{
try
{
context.BeginTran();
if(newInvs != null && newInvs.Count() > 0)
{
var inv_rs = context.Insertable(newInvs).ExecuteCommand();
summary.DetailList.ForEach(s =>
{
s.inventoryId = context.Queryable<Inventory>().First(n => n.epc.Equals(s.epc))?.id;
});
}
var logrs = context.InsertNav(summary).Include(z1 => z1.DetailList).ExecuteCommand();
//更新库存状态
var invIds = summary.DetailList.Select(a => a.inventoryId).ToList();
context.Updateable<Inventory>().Where(s => invIds.Contains(s.id))
.SetColumns(i => new Inventory()
{
state = newInvs != null && newInvs.Count() > 0 ? "2" : summary.outInState.Equals("out") ? "1" : "0",
bussinessState = inv_states.Item1,
equState = inv_states.Item2,
updateTime = DateTime.Now
}).ExecuteCommand();
//更新单据
if (myOrder != null)
{
//子表
List<LogDetail> details = new List<LogDetail>();
context.Queryable<LogSummary>()
.Where(s => s.orderId.Equals(myOrder.id))
.Select(s => s.DetailList)
.ForEach(s =>
{
details.AddRange(s);
});
var detailSumDic = details
.GroupBy(s => new { s.equipmentSizeId, s.epc })
.Select(s => new { size = s.Key.equipmentSizeId, epc = s.Key.epc })
.GroupBy(s => s.size)
.Select(s => new { size = s.Key, count = s.Count() })
.ToDictionary(s => s.size, s => s.count);
foreach (var item in myOrder.DetailList)
{
if (detailSumDic.ContainsKey(item.equipmentSize))
{
item.actualNum = detailSumDic[item.equipmentSize];
}
}
//主表
decimal sumPrice = Convert.ToDecimal(myOrder.DetailList.Select(s => s.actualNum * s.price).Sum());
myOrder.actualQuantity = summary.number;
myOrder.price = sumPrice;
myOrder.isUpload = 1;
myOrder.orderState = 0;
myOrder.updateTime = DateTime.Now;
var orderrs = context.UpdateNav(myOrder).Include(z1 => z1.DetailList).ExecuteCommand();
//调拨出库删除装备
if (inv_states.Item1.Equals("transfer"))
{
context.Deleteable<Inventory>().Where(s => invIds.Contains(s.id)).ExecuteCommand();
}
}
context.CommitTran();
}
catch (Exception e)
{
return false;
}
}
return true;
}
public async Task<bool> AddHandLogs(LogSummary model, List<Inventory> inv) public async Task<bool> AddHandLogs(LogSummary model, List<Inventory> inv)
{ {
using (var context = _suger.GetDbClient()) using (var context = _suger.GetDbClient())
......
using Models.Table;
using Repositories.IRepository.IBussiness;
using Repositories.IRepository.IUnitOfWork;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Repositories.Repository.Bussiness
{
public class SupplierRepository : BaseRepository<Supplier>, ISupplierRepository
{
public SupplierRepository(ILocalSugarUnitOfWork sugarUnitOfWork) : base(sugarUnitOfWork)
{
}
}
}
using Models.Table;
using Repositories.IRepository.IBussiness;
using Repositories.IRepository.IUnitOfWork;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Repositories.Repository.Bussiness
{
public class WarehouseRepository : BaseRepository<Warehouse>, IWarehouseRepository
{
public WarehouseRepository(ILocalSugarUnitOfWork sugarUnitOfWork) : base(sugarUnitOfWork)
{
}
}
}
...@@ -18,5 +18,7 @@ namespace Services.Interface ...@@ -18,5 +18,7 @@ namespace Services.Interface
/// <returns></returns> /// <returns></returns>
Task<bool> AddLogs(RecordsReq model); Task<bool> AddLogs(RecordsReq model);
Task<bool> AddHandLogs(HandRecordsReq model); Task<bool> AddHandLogs(HandRecordsReq model);
Task<bool> AddChannelLog(OrderMain? myOrder, LogSummary summary, List<Inventory> newInvs);
} }
} }
using Models.Table;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Services.Interface
{
public interface ISupplierService : IBaseServices<Supplier>
{
}
}
using Models.Table;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Services.Interface
{
public interface IWarehouseService : IBaseServices<Warehouse>
{
}
}
...@@ -28,6 +28,44 @@ namespace Services ...@@ -28,6 +28,44 @@ namespace Services
mapper = _mapper; mapper = _mapper;
} }
public Task<bool> AddChannelLog(OrderMain? myOrder, LogSummary summary, List<Inventory> newInvs)
{
var rs1 = "normal";//bussiness_state
var rs2 = "normal";//equ_state
if (myOrder != null)
{
if (myOrder.orderType.Equals("out"))//获取装备应设为的状态
{
switch (myOrder.bussinessType)
{
case "allocate":
rs1 = "transfer";
break;
case "use":
rs1 = "take";
break;
case "remove":
rs1 = "remove";
break;
case "destruction":
rs1 = "destruction";
rs2 = "destory";
break;
case "repair":
rs1 = "repair";
rs2 = "fix";
break;
default:
break;
}
}
}
var inv_states = new Tuple<string, string>(rs1,rs2);
return _logSummaryRepository.AddChannelLog(myOrder, summary, newInvs, inv_states);
}
public Task<bool> AddHandLogs(HandRecordsReq model) public Task<bool> AddHandLogs(HandRecordsReq model)
{ {
LogSummary log = mapper.Map<LogSummary>(model); LogSummary log = mapper.Map<LogSummary>(model);
......
using Models.Table;
using Repositories.IRepository.IBussiness;
using Services.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Services
{
public class SupplierService : BaseService<Supplier>, ISupplierService
{
private readonly ISupplierRepository _supplierRepository;
public SupplierService(ISupplierRepository supplierRepository)
{
base.BaseDal = supplierRepository;
_supplierRepository = supplierRepository;
}
}
}
using Models.Table;
using Repositories.IRepository.IBussiness;
using Services.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Services
{
public class WarehouseService : BaseService<Warehouse>, IWarehouseService
{
private readonly IWarehouseRepository _WarehouseRepository;
public WarehouseService(IWarehouseRepository WarehouseRepository)
{
base.BaseDal = WarehouseRepository;
_WarehouseRepository = WarehouseRepository;
}
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论