Commit 633f8b75 by Seniorious

1

parent 4f23bed8
namespace APIs.Req using Models.Table;
namespace APIs.Req
{ {
public class CommonReq public class CommonReq
{ {
...@@ -25,4 +27,15 @@ ...@@ -25,4 +27,15 @@
{ {
public string warehouseId { get; set; } public string warehouseId { get; set; }
} }
public class GetWarehouseConfigReq
{
public string deviceId { get; set; }
}
public class UpdateFingerReq
{
public string policeId { get; set; }
public List<PoliceFinger> fingerList { get; set; }
}
} }
\ No newline at end of file
...@@ -77,6 +77,7 @@ namespace APIs ...@@ -77,6 +77,7 @@ namespace APIs
services.AddScoped<IPoliceFingerService, PoliceFingerService>(); services.AddScoped<IPoliceFingerService, PoliceFingerService>();
services.AddScoped<IBussinessInventoryService, BussinessInventoryService>(); services.AddScoped<IBussinessInventoryService, BussinessInventoryService>();
services.AddScoped<IBussinessInventoryDetailService, BussinessInventoryDetailService>(); services.AddScoped<IBussinessInventoryDetailService, BussinessInventoryDetailService>();
services.AddScoped<IChannelService, ChannelService>();
#endregion #endregion
#region Repository #region Repository
...@@ -103,6 +104,7 @@ namespace APIs ...@@ -103,6 +104,7 @@ namespace APIs
services.AddScoped<IPoliceFingerRepository, PoliceFingerRepository>(); services.AddScoped<IPoliceFingerRepository, PoliceFingerRepository>();
services.AddScoped<IBussinessInventoryRepository, BussinessInventoryRepository>(); services.AddScoped<IBussinessInventoryRepository, BussinessInventoryRepository>();
services.AddScoped<IBussinessInventoryDetailRepository, BussinessInventoryDetailRepository>(); services.AddScoped<IBussinessInventoryDetailRepository, BussinessInventoryDetailRepository>();
services.AddScoped<IChannelRepository, ChannelRepository>();
#endregion #endregion
#region 注册RabbitMQ消费者 #region 注册RabbitMQ消费者
......
...@@ -64,12 +64,13 @@ namespace Common.Utility.Model ...@@ -64,12 +64,13 @@ namespace Common.Utility.Model
public int? state { get; set; } public int? state { get; set; }
public string warehouseId { get; set; } public string warehouseId { get; set; }
public string picture { get; set; } public string picture { get; set; }
public string policeId { get; set; }
} }
public class HandResultReq public class HandResultReq
{ {
public OrderDetail order { get; set; } public OrderDetail order { get; set; }
public List<LogSummary> logList { get; set; } public List<LogSummary> logList { get; set; }
public List<Inventory>? purchaseList { 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_channel")]
public class Channel : BaseTable
{
[SugarColumn(IsPrimaryKey = true)]
public string id { get; set; }
[SugarColumn(ColumnName = "warehouse_id")]
public string warehouseId { get; set; }
[SugarColumn(ColumnName = "config")]
public string config { get; set; }
}
}
...@@ -30,5 +30,10 @@ namespace Models.Table ...@@ -30,5 +30,10 @@ namespace Models.Table
///</summary> ///</summary>
[SugarColumn(ColumnName="finger_info" )] [SugarColumn(ColumnName="finger_info" )]
public string fingerInfo { get; set; } public string fingerInfo { get; set; }
/// <summary>
/// 指纹编号
///</summary>
[SugarColumn(ColumnName = "finger_num")]
public string fingerNum { get; set; }
} }
} }
...@@ -8,7 +8,7 @@ using System.Threading.Tasks; ...@@ -8,7 +8,7 @@ using System.Threading.Tasks;
namespace Models.Table namespace Models.Table
{ {
[SugarTable("base_warehouse")] [SugarTable("base_warehouse")]
public class Warehouse : BaseTable public class Warehouse
{ {
[SugarColumn(IsPrimaryKey = true)] [SugarColumn(IsPrimaryKey = true)]
public string id { get; set; } public string id { get; set; }
......
...@@ -10,6 +10,6 @@ namespace Repositories.IRepository.IBussiness ...@@ -10,6 +10,6 @@ namespace Repositories.IRepository.IBussiness
public interface IBussinessInventoryRepository : IBaseRepository<BussinessInventory> public interface IBussinessInventoryRepository : IBaseRepository<BussinessInventory>
{ {
Task<BussinessInventory>? GenerateInventoryOrder(BussinessInventory myBIOrder); Task<BussinessInventory>? GenerateInventoryOrder(BussinessInventory myBIOrder);
async Task<bool> OrderRollBack(BussinessInventory myBIOrder); Task<bool> OrderRollBack(BussinessInventory myBIOrder);
} }
} }
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 IChannelRepository : IBaseRepository<Channel>
{
}
}
 
using Common.Utility.Model;
using Models.SqlModel; using Models.SqlModel;
using Models.Table; using Models.Table;
using System; using System;
...@@ -17,5 +18,6 @@ namespace Repositories.IRepository.IBussiness ...@@ -17,5 +18,6 @@ namespace Repositories.IRepository.IBussiness
Task<bool> AddChannelLog(OrderMain? myOrder, LogSummary summary, List<Inventory> newInvs, Tuple<string, string> inv_states); Task<bool> AddChannelLog(OrderMain? myOrder, LogSummary summary, List<Inventory> newInvs, Tuple<string, string> inv_states);
Task<bool> HandUploadResult(long? orgid, HandResultReq req);
} }
} }
...@@ -9,5 +9,6 @@ namespace Repositories.IRepository.IBussiness ...@@ -9,5 +9,6 @@ namespace Repositories.IRepository.IBussiness
{ {
public interface IPoliceFingerRepository : IBaseRepository<PoliceFinger> public interface IPoliceFingerRepository : IBaseRepository<PoliceFinger>
{ {
Task<bool> UpdateFinger(string policeId, List<PoliceFinger> fingers);
} }
} }
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 ChannelRepository : BaseRepository<Channel>, IChannelRepository
{
public ChannelRepository(ILocalSugarUnitOfWork sugarUnitOfWork) : base(sugarUnitOfWork)
{
}
}
}
using AutoMapper; using AutoMapper;
using Common.Utility.Model;
using Models.SqlModel; using Models.SqlModel;
using Models.Table; using Models.Table;
using Repositories.IRepository.IBussiness; using Repositories.IRepository.IBussiness;
...@@ -21,6 +22,176 @@ namespace Repositories.Repository.Bussiness ...@@ -21,6 +22,176 @@ namespace Repositories.Repository.Bussiness
_suger = sugarUnitOfWork; _suger = sugarUnitOfWork;
} }
public async Task<bool> HandUploadResult(long? orgid, HandResultReq req)
{
using (var context = _suger.GetDbClient())
{
try
{
context.BeginTran();
//更新主单
var mainOrder = context.Queryable<OrderMain>().First(x => x.id.Equals(req.order.orderId));
mainOrder.actualQuantity += req.order.actualNum;
mainOrder.price += req.order.price;
mainOrder.updateTime = DateTime.Now;
context.Updateable(mainOrder)
.WhereColumns(s => new { s.actualQuantity, s.price, s.updateTime })
.ExecuteCommand();
//更新子单
req.order.updateTime = DateTime.Now;
context.Updateable(req.order)
.WhereColumns(s => new { s.actualNum, s.price, s.updateTime })
.PublicSetColumns(s => s.price, "+")//price += s.price
.PublicSetColumns(s => s.actualNum, "+")
.ExecuteCommand();
//新装备
bool isNewEqu = false;
bool isPurchase = false;
List<Inventory> newEquList = new List<Inventory>();
List<PrintDetail> periodInfoList = new List<PrintDetail>();//采购装备质保期维保期生产日期等信息
List<string> newEquOrderType = new List<string>() { "purchase", "gift", "allocate" };
if (newEquOrderType.Contains(mainOrder.bussinessType) && mainOrder.orderType.Equals("in"))
{
isNewEqu = true;
periodInfoList = context.Queryable<PrintDetail>().Where(s => s.orderId.Equals(mainOrder.id)).ToList();
if (mainOrder.bussinessType.Equals("purchase"))
{
isPurchase = true;
}
}
List<string> InventoryIds = new List<string>();
//出入库记录
var supplierDic = context.Queryable<Supplier>().ToList();
req.logList.ForEach(s =>
{
s.isUpload = 0;
s.useTime = DateTime.Now;
s.createTime = DateTime.Now;
s.updateTime = DateTime.Now;
s.DetailList.ForEach(c =>
{
var mySup = supplierDic.FirstOrDefault(a => a.code.Equals(c.supplierName));
if (!string.IsNullOrEmpty(c.inventoryId)) InventoryIds.Add(c.inventoryId);
c.createTime = DateTime.Now;
c.updateTime = DateTime.Now;
c.errorState = 0;
c.state = s.outInState == "in" ? 0 : 1;
c.supplierId = mySup?.id;
c.supplierName = mySup?.name;
//新装备
if (isNewEqu)
{
var equ = new Inventory()
{
id = Guid.NewGuid().ToString(),
equipmentType = "0",
typeId = c.equipmentTypeId,
typeName = c.equipmentName,
sizeId = c.equipmentSizeId,
sizeName = c.equipmentSize,
supplierId = mySup?.id,
supplierName = mySup?.name,
epc = c.epc,
orgId = orgid,
state = "0",
lostFlag = "0",
price = c.price,
locationType = "0",
locationId = s.locationId,
equState = "normal",
bussinessState = "normal",
createTime = DateTime.Now,
updateTime = DateTime.Now,
};
c.inventoryId = equ.id;
if (isPurchase)
{
var myperiod = periodInfoList?.FirstOrDefault(b => b.sizeId.Equals(c.equipmentSizeId));
equ.state = "2";
equ.maintenancePeriod = myperiod?.maintenancePeriod?.ToString();
equ.warrantyPeriod = myperiod?.warrantyPeriod?.ToString();
equ.productionDate = myperiod?.productionDate;
}
newEquList.Add(equ);
}
});
});
context.Insertable(req).ExecuteCommand();
if(newEquList != null && newEquList.Count() > 0)
{
context.Insertable(newEquList).ExecuteCommand();
}
#region 更新装备状态
var target_bussinessState = "normal";
var target_equState = "normal";
if (mainOrder.orderType.Equals("out"))//获取装备应设为的状态
{
switch (mainOrder.bussinessType)
{
case "allocate":
target_bussinessState = "transfer";
break;
case "use":
target_bussinessState = "take";
break;
case "remove":
target_bussinessState = "remove";
break;
case "destruction":
target_bussinessState = "destruction";
target_equState = "destory";
break;
case "repair":
target_bussinessState = "repair";
target_equState = "fix";
break;
default:
break;
}
}
if(InventoryIds.Count() > 0)
{
context.Updateable<Inventory>()
.Where(s => InventoryIds.Contains(s.id))
.ReSetValue(it =>
{
it.bussinessState = target_bussinessState;
it.equState = target_equState;
it.updateTime = DateTime.Now;
})
.ExecuteCommand();
}
#endregion
context.CommitTran();
return true;
}
catch (Exception e)
{
return false;
}
}
}
public async Task<bool> AddChannelLog(OrderMain? myOrder, LogSummary summary, List<Inventory> newInvs, Tuple<string,string> inv_states) public async Task<bool> AddChannelLog(OrderMain? myOrder, LogSummary summary, List<Inventory> newInvs, Tuple<string,string> inv_states)
{ {
using (var context = _suger.GetDbClient()) using (var context = _suger.GetDbClient())
...@@ -43,11 +214,12 @@ namespace Repositories.Repository.Bussiness ...@@ -43,11 +214,12 @@ namespace Repositories.Repository.Bussiness
var logrs = context.InsertNav(summary).Include(z1 => z1.DetailList).ExecuteCommand(); var logrs = context.InsertNav(summary).Include(z1 => z1.DetailList).ExecuteCommand();
//更新库存状态 //更新库存状态
var state = newInvs != null && newInvs.Count() > 0 ? "2" : summary.outInState.Equals("out") ? "1" : "0";
var invIds = summary.DetailList.Select(a => a.inventoryId).ToList(); var invIds = summary.DetailList.Select(a => a.inventoryId).ToList();
context.Updateable<Inventory>().Where(s => invIds.Contains(s.id)) context.Updateable<Inventory>().Where(s => invIds.Contains(s.id))
.SetColumns(i => new Inventory() .SetColumns(i => new Inventory()
{ {
state = newInvs != null && newInvs.Count() > 0 ? "2" : summary.outInState.Equals("out") ? "1" : "0", state = state,
bussinessState = inv_states.Item1, bussinessState = inv_states.Item1,
equState = inv_states.Item2, equState = inv_states.Item2,
updateTime = DateTime.Now updateTime = DateTime.Now
...@@ -169,5 +341,6 @@ namespace Repositories.Repository.Bussiness ...@@ -169,5 +341,6 @@ namespace Repositories.Repository.Bussiness
} }
return true; return true;
} }
} }
} }
using Models.Table; using AutoMapper;
using Models.Table;
using Repositories.IRepository.IBussiness; using Repositories.IRepository.IBussiness;
using Repositories.IRepository.IUnitOfWork; using Repositories.IRepository.IUnitOfWork;
using System; using System;
...@@ -11,9 +12,41 @@ namespace Repositories.Repository.Bussiness ...@@ -11,9 +12,41 @@ namespace Repositories.Repository.Bussiness
{ {
public class PoliceFingerRepository : BaseRepository<PoliceFinger>, IPoliceFingerRepository public class PoliceFingerRepository : BaseRepository<PoliceFinger>, IPoliceFingerRepository
{ {
protected readonly ILocalSugarUnitOfWork _suger;
public IMapper mapper;
public PoliceFingerRepository(ILocalSugarUnitOfWork sugarUnitOfWork) : base(sugarUnitOfWork) public PoliceFingerRepository(ILocalSugarUnitOfWork sugarUnitOfWork) : base(sugarUnitOfWork)
{ {
_suger = sugarUnitOfWork;
}
public async Task<bool> UpdateFinger(string policeId, List<PoliceFinger> fingers)
{
using (var context = _suger.GetDbClient())
{
try
{
fingers.ForEach(s =>
{
s.policeId = policeId;
s.createTime = DateTime.Now;
s.updateTime = DateTime.Now;
});
//新增或更新
var x = context.Storageable(fingers).ToStorage();
x.AsInsertable.ExecuteCommand();
x.AsUpdateable.WhereColumns(s => new { s.id, s.fingerNum })//查询字段
.UpdateColumns(s => new { s.fingerInfo, s.updateTime })//更新字段
.IgnoreColumns(s => new { s.policeId, s.fingerNum, s.createTime })//不更新字段
.ExecuteCommand();
return true;
}
catch (Exception e)
{
return false;
}
}
} }
} }
} }
...@@ -29,7 +29,7 @@ namespace Services ...@@ -29,7 +29,7 @@ namespace Services
return _bussinessInventoryRepository.GenerateInventoryOrder(myBIOrder); return _bussinessInventoryRepository.GenerateInventoryOrder(myBIOrder);
} }
public async Task<bool> OrderRollBack(BussinessInventory myBIOrder) public Task<bool> OrderRollBack(BussinessInventory myBIOrder)
{ {
return _bussinessInventoryRepository.OrderRollBack(myBIOrder); return _bussinessInventoryRepository.OrderRollBack(myBIOrder);
} }
......
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 ChannelService : BaseService<Channel>, IChannelService
{
private readonly IChannelRepository _channelRepository;
public ChannelService(IChannelRepository channelRepository)
{
base.BaseDal = channelRepository;
_channelRepository = channelRepository;
}
}
}
...@@ -10,6 +10,6 @@ namespace Services.Interface ...@@ -10,6 +10,6 @@ namespace Services.Interface
public interface IBussinessInventoryService : IBaseServices<BussinessInventory> public interface IBussinessInventoryService : IBaseServices<BussinessInventory>
{ {
Task<BussinessInventory>? GenerateInventoryOrder(BussinessInventory myBIOrder); Task<BussinessInventory>? GenerateInventoryOrder(BussinessInventory myBIOrder);
async Task<bool> OrderRollBack(BussinessInventory myBIOrder); Task<bool> OrderRollBack(BussinessInventory myBIOrder);
} }
} }
using Models.Table;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Services.Interface
{
public interface IChannelService : IBaseServices<Channel>
{
}
}
...@@ -20,5 +20,7 @@ namespace Services.Interface ...@@ -20,5 +20,7 @@ namespace Services.Interface
Task<bool> AddHandLogs(HandRecordsReq model); Task<bool> AddHandLogs(HandRecordsReq model);
Task<bool> AddChannelLog(OrderMain? myOrder, LogSummary summary, List<Inventory> newInvs); Task<bool> AddChannelLog(OrderMain? myOrder, LogSummary summary, List<Inventory> newInvs);
Task<bool> HandUploadResult(long? orgid, HandResultReq req);
} }
} }
...@@ -9,5 +9,6 @@ namespace Services.Interface ...@@ -9,5 +9,6 @@ namespace Services.Interface
{ {
public interface IPoliceFingerService : IBaseServices<PoliceFinger> public interface IPoliceFingerService : IBaseServices<PoliceFinger>
{ {
Task<bool> UpdateFinger(string policeId, List<PoliceFinger> fingers);
} }
} }
...@@ -28,6 +28,11 @@ namespace Services ...@@ -28,6 +28,11 @@ namespace Services
mapper = _mapper; mapper = _mapper;
} }
public Task<bool> HandUploadResult(long? orgid, HandResultReq req)
{
return _logSummaryRepository.HandUploadResult(orgid, req);
}
public Task<bool> AddChannelLog(OrderMain? myOrder, LogSummary summary, List<Inventory> newInvs) public Task<bool> AddChannelLog(OrderMain? myOrder, LogSummary summary, List<Inventory> newInvs)
{ {
var rs1 = "normal";//bussiness_state var rs1 = "normal";//bussiness_state
...@@ -134,5 +139,6 @@ namespace Services ...@@ -134,5 +139,6 @@ namespace Services
}).ToList(); }).ToList();
return _logSummaryRepository.AddLogs(log, inveqList, invCarList); return _logSummaryRepository.AddLogs(log, inveqList, invCarList);
} }
} }
} }
...@@ -18,5 +18,9 @@ namespace Services ...@@ -18,5 +18,9 @@ namespace Services
_policeFingerRepository = policeFingerRepository; _policeFingerRepository = policeFingerRepository;
} }
public Task<bool> UpdateFinger(string policeId, List<PoliceFinger> fingers)
{
return _policeFingerRepository.UpdateFinger(policeId, fingers);
}
} }
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论