Commit 4f23bed8 by Seniorious

1

parent dbc01356
...@@ -14,4 +14,15 @@ ...@@ -14,4 +14,15 @@
{ {
public int hkDevice { get; set; } public int hkDevice { get; set; }
} }
public class UpdateHKPictureReq
{
public string policeId { get; set; }
public string photo { get; set; }
}
public class GetInventoryOrderReq
{
public string warehouseId { get; set; }
}
} }
...@@ -75,6 +75,8 @@ namespace APIs ...@@ -75,6 +75,8 @@ namespace APIs
services.AddScoped<ISupplierService, SupplierService>(); services.AddScoped<ISupplierService, SupplierService>();
services.AddScoped<IPoliceInfoService, PoliceInfoService>(); services.AddScoped<IPoliceInfoService, PoliceInfoService>();
services.AddScoped<IPoliceFingerService, PoliceFingerService>(); services.AddScoped<IPoliceFingerService, PoliceFingerService>();
services.AddScoped<IBussinessInventoryService, BussinessInventoryService>();
services.AddScoped<IBussinessInventoryDetailService, BussinessInventoryDetailService>();
#endregion #endregion
#region Repository #region Repository
...@@ -99,6 +101,8 @@ namespace APIs ...@@ -99,6 +101,8 @@ namespace APIs
services.AddScoped<ISupplierRepository, SupplierRepository>(); services.AddScoped<ISupplierRepository, SupplierRepository>();
services.AddScoped<IPoliceInfoRepository, PoliceInfoRepository>(); services.AddScoped<IPoliceInfoRepository, PoliceInfoRepository>();
services.AddScoped<IPoliceFingerRepository, PoliceFingerRepository>(); services.AddScoped<IPoliceFingerRepository, PoliceFingerRepository>();
services.AddScoped<IBussinessInventoryRepository, BussinessInventoryRepository>();
services.AddScoped<IBussinessInventoryDetailRepository, BussinessInventoryDetailRepository>();
#endregion #endregion
#region 注册RabbitMQ消费者 #region 注册RabbitMQ消费者
...@@ -158,6 +162,11 @@ namespace APIs ...@@ -158,6 +162,11 @@ namespace APIs
rabbits.Password = configuration.GetSection("RabbitMQConfig:Password").Value; rabbits.Password = configuration.GetSection("RabbitMQConfig:Password").Value;
AdminGlobalContext.RabbitMQConfig = rabbits; AdminGlobalContext.RabbitMQConfig = rabbits;
jyzbConfig jyzb = new jyzbConfig();
jyzb.Url = configuration.GetSection("jyzbConfig:Url").Value;
jyzb.OrgId = configuration.GetSection("jyzbConfig:OrgId").Value;
jyzb.OrgName = configuration.GetSection("jyzbConfig:OrgName").Value;
AdminGlobalContext.jyzbConfig = jyzb;
} }
#endregion #endregion
......
...@@ -41,6 +41,13 @@ ...@@ -41,6 +41,13 @@
"QueueName": "cabinet", "QueueName": "cabinet",
//虚拟交换机名称 //虚拟交换机名称
"ExchangeName": "uploadRecords" "ExchangeName": "uploadRecords"
},
"jyzbConfig": {
//3.0平台地址
"Url": "http://192.168.3.188:10030",
//组织机构ID
"OrgId": "1369509498032811869",
//组织机构名称
"OrgName": "宁波市公安局"
} }
} }
...@@ -16,5 +16,7 @@ namespace Common.Global ...@@ -16,5 +16,7 @@ namespace Common.Global
/// RabbitMQ配置 /// RabbitMQ配置
/// </summary> /// </summary>
public static RabbitMQConfig RabbitMQConfig { get; set; } public static RabbitMQConfig RabbitMQConfig { get; set; }
public static jyzbConfig jyzbConfig { get; set; }
} }
} }
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Common.Global
{
public class jyzbConfig
{
public string Url { get; set; }
public string OrgId { get; set; }
public string OrgName { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
namespace Common
{
public class HttpHelper
{
public static string HttpPost(string strUrl, string json = "")
{
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(strUrl);
request.Method = "POST";
if (!string.IsNullOrEmpty(json))
{
request.ContentType = "application/json";
byte[] data = Encoding.UTF8.GetBytes(json);
request.ContentLength = data.Length;
using (Stream reqStream = request.GetRequestStream())
{
reqStream.Write(data, 0, data.Length);
reqStream.Close();
}
}
else { request.ContentLength = 0; }
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream responseStream = response.GetResponseStream();
StreamReader streamReader = new StreamReader(responseStream, Encoding.UTF8);
string retString = streamReader.ReadToEnd();
streamReader.Close();
responseStream.Close();
response.Close();
return retString;
}
catch (Exception ex)
{
return string.Empty;
}
}
public static string HttpGet(string strUrl)
{
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(strUrl);
request.Method = "GET";
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream responseStream = response.GetResponseStream();
StreamReader streamReader = new StreamReader(responseStream, Encoding.UTF8);
string retString = streamReader.ReadToEnd();
streamReader.Close();
responseStream.Close();
response.Close();
return retString;
}
catch (Exception ex)
{
return string.Empty;
}
}
public class res<T> where T : class
{
public string code { get; set; }
public string message { get; set; }
public T data { get; set; }
public string timestamp { get; set; }
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using Models;
using SqlSugar;
namespace Models.Table
{
/// <summary>
///
///</summary>
[SugarTable("bussiness_inventory")]
public class BussinessInventory : BaseTable
{
/// <summary>
///
///</summary>
[SugarColumn(ColumnName="id" ,IsPrimaryKey = true )]
public long id { get; set; }
/// <summary>
/// 订单号
///</summary>
[SugarColumn(ColumnName="order_num" )]
public string orderNum { get; set; }
/// <summary>
/// 年度
///</summary>
[SugarColumn(ColumnName="year" )]
public int? year { get; set; }
/// <summary>
/// 月份
///</summary>
[SugarColumn(ColumnName="month" )]
public int? month { get; set; }
/// <summary>
/// 申请时间
///</summary>
[SugarColumn(ColumnName="apply_time" )]
public DateTime? applyTime { get; set; }
/// <summary>
/// 仓库id
///</summary>
[SugarColumn(ColumnName="warehouse_id" )]
public string warehouseId { get; set; }
/// <summary>
/// 仓库名称
///</summary>
[SugarColumn(ColumnName="warehouse_name" )]
public string warehouseName { get; set; }
/// <summary>
/// 组织机构Id
///</summary>
[SugarColumn(ColumnName="org_id" )]
public long? orgId { get; set; }
/// <summary>
/// 组织机构名称
///</summary>
[SugarColumn(ColumnName="org_name" )]
public string orgName { get; set; }
/// <summary>
/// 盘点状态,waitting等待盘点,running盘点中,finished完成,cancel取消,close结算
///</summary>
[SugarColumn(ColumnName="inventory_state" )]
public string inventoryState { get; set; }
/// <summary>
/// 盘点类型,0全盘,1按类别盘点,2按照号型盘点
///</summary>
[SugarColumn(ColumnName="inventory_type" )]
public string inventoryType { get; set; }
/// <summary>
/// 类别id汇总,用逗号分割
///</summary>
[SugarColumn(ColumnName="rules" )]
public string rules { get; set; }
/// <summary>
/// 展示汇总(不返回)
///</summary>
[SugarColumn(ColumnName="rules_json" )]
public string rulesJson { get; set; }
/// <summary>
/// 应盘总数
///</summary>
[SugarColumn(ColumnName="total_num" )]
public int? totalNum { get; set; }
/// <summary>
/// 实际总数
///</summary>
[SugarColumn(ColumnName="actual_num" )]
public int? actualNum { get; set; }
/// <summary>
/// 亏损总数
///</summary>
[SugarColumn(ColumnName="add_num" )]
public int? addNum { get; set; }
/// <summary>
/// 盈余总数
///</summary>
[SugarColumn(ColumnName="delete_num" )]
public int? deleteNum { get; set; }
/// <summary>
/// 盘点结果,ready未开始,surplus盈余,loss亏损,normal正常,surplus&amp;loss既有盈余,也有亏损
///</summary>
[SugarColumn(ColumnName="result" )]
public string result { get; set; }
/// <summary>
/// 原有epc备份(不返回)
///</summary>
[SugarColumn(ColumnName="epc_back" )]
public string epcBack { get; set; }
/// <summary>
/// 需要更新的epc汇总
///</summary>
[SugarColumn(ColumnName="epc_update" )]
public string epcUpdate { get; set; }
[Navigate(NavigateType.OneToMany, nameof(BussinessInventoryDetail.inventoryId))]
public List<BussinessInventoryDetail> DetailList { get; set; } = new List<BussinessInventoryDetail>();
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using Models;
using SqlSugar;
namespace Models.Table
{
/// <summary>
///
///</summary>
[SugarTable("bussiness_inventory_detail")]
public class BussinessInventoryDetail : BaseTable
{
/// <summary>
///
///</summary>
[SugarColumn(ColumnName="id" ,IsPrimaryKey = true ,IsIdentity = true )]
public long id { get; set; }
/// <summary>
/// 盘点表主键
///</summary>
[SugarColumn(ColumnName="inventory_id" )]
public long? inventoryId { get; set; }
/// <summary>
/// 装备类型id
///</summary>
[SugarColumn(ColumnName="type_id" )]
public string typeId { get; set; }
/// <summary>
/// 装备类型名称
///</summary>
[SugarColumn(ColumnName="type_name" )]
public string typeName { get; set; }
/// <summary>
/// 装备号型id
///</summary>
[SugarColumn(ColumnName="size_id" )]
public string sizeId { get; set; }
/// <summary>
/// 装备号型名称
///</summary>
[SugarColumn(ColumnName="size_name" )]
public string sizeName { get; set; }
/// <summary>
/// 在库数(包含报废区)
///</summary>
[SugarColumn(ColumnName="stock_number" )]
public int? stockNumber { get; set; }
/// <summary>
/// 在库金额(暂不使用)
///</summary>
[SugarColumn(ColumnName="stock_price" )]
public decimal? stockPrice { get; set; }
/// <summary>
/// 修正后的在库数量
///</summary>
[SugarColumn(ColumnName="fix_number" )]
public int? fixNumber { get; set; }
/// <summary>
/// 差距金额
///</summary>
[SugarColumn(ColumnName="fix_price" )]
public decimal? fixPrice { get; set; }
/// <summary>
/// 差距数量
/// 默认值: 0
///</summary>
[SugarColumn(ColumnName="num" )]
public int? num { get; set; }
/// <summary>
/// 状态.0正常,1盈余,2亏损
///</summary>
[SugarColumn(ColumnName="state" )]
public int? state { get; set; }
}
}
...@@ -13,27 +13,28 @@ namespace Models.SqlModel ...@@ -13,27 +13,28 @@ namespace Models.SqlModel
public class EquipmentType : BaseTable public class EquipmentType : BaseTable
{ {
[SugarColumn(IsIdentity = true, IsPrimaryKey = true)] [SugarColumn(IsIdentity = true, IsPrimaryKey = true)]
public string id { get; set; }
public String id { get; set; } public string name { get; set; }
public String name { get; set; } public string unit { get; set; }
public String unit { get; set; }
[SugarColumn(ColumnName = "unit_type")] [SugarColumn(ColumnName = "unit_type")]
public String? unitType { get; set; } public string unitType { get; set; }
public String? code { get; set; } public string code { get; set; }
[SugarColumn(ColumnName = "parent_id")] [SugarColumn(ColumnName = "parent_id")]
public String? parentId { get; set; } public string parentId { get; set; }
[SugarColumn(ColumnName = "parent_ids")] [SugarColumn(ColumnName = "parent_ids")]
public String? parentIds { get; set; } public string parentIds { get; set; }
public string state { get; set; }
public String? state { get; set; } public string note { get; set; }
public String? note { get; set; } public string type { get; set; }
public String? type { get; set; } public decimal? price { get; set; }
} }
} }
......
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 IBussinessInventoryDetailRepository : IBaseRepository<BussinessInventoryDetail>
{
}
}
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 IBussinessInventoryRepository : IBaseRepository<BussinessInventory>
{
Task<BussinessInventory>? GenerateInventoryOrder(BussinessInventory myBIOrder);
async Task<bool> OrderRollBack(BussinessInventory myBIOrder);
}
}
...@@ -42,7 +42,6 @@ namespace Repositories.Repository ...@@ -42,7 +42,6 @@ namespace Repositories.Repository
} }
public async Task<bool> DeleteByIds(int[] ids) public async Task<bool> DeleteByIds(int[] ids)
{ {
using (var context = _db.GetDbClient()) using (var context = _db.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 BussinessInventoryDetailRepository : BaseRepository<BussinessInventoryDetail>, IBussinessInventoryDetailRepository
{
public BussinessInventoryDetailRepository(ILocalSugarUnitOfWork sugarUnitOfWork) : base(sugarUnitOfWork)
{
}
}
}
using AutoMapper;
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 BussinessInventoryRepository : BaseRepository<BussinessInventory>, IBussinessInventoryRepository
{
protected readonly ILocalSugarUnitOfWork _suger;
public IMapper mapper;
public BussinessInventoryRepository(ILocalSugarUnitOfWork sugarUnitOfWork) : base(sugarUnitOfWork)
{
_suger = sugarUnitOfWork;
}
public async Task<BussinessInventory>? GenerateInventoryOrder(BussinessInventory myBIOrder)
{
using (var context = _suger.GetDbClient())
{
try
{
List<Inventory> inventory = new List<Inventory>();
switch (myBIOrder.inventoryType)
{
case "0"://全盘
inventory = await context.Queryable<Inventory>()
.Where(s => s.locationId.Equals(myBIOrder.warehouseId) && !s.bussinessState.Equals("destruction") && !s.equState.Equals("destory"))
.ToListAsync();
break;
case "1"://类别盘点
if (string.IsNullOrEmpty(myBIOrder.rules))
{
return null;
}
List<string> types = myBIOrder.rules.Split(',').ToList();
inventory = await context.Queryable<Inventory>()
.Where(s => s.locationId.Equals(myBIOrder.warehouseId) && !s.bussinessState.Equals("destruction") && !s.equState.Equals("destory")
&& types.Contains(s.typeId))
.ToListAsync();
break;
case "2"://号型盘点
if (string.IsNullOrEmpty(myBIOrder.rules))
{
return null;
}
List<string> sizes = myBIOrder.rules.Split(',').ToList();
inventory = await context.Queryable<Inventory>()
.Where(s => s.locationId.Equals(myBIOrder.warehouseId) && !s.bussinessState.Equals("destruction") && !s.equState.Equals("destory")
&& sizes.Contains(s.sizeId))
.ToListAsync();
break;
default:
return null;
}
List<BussinessInventoryDetail> classifyInventory = inventory
.GroupBy(s => new { s.typeId, s.typeName, s.sizeId, s.sizeName })
.Select(s => new BussinessInventoryDetail
{
inventoryId = myBIOrder.id,
typeId = s.Key.typeId,
typeName = s.Key.typeName,
sizeId = s.Key.sizeId,
sizeName = s.Key.sizeName,
stockNumber = s.Count(),
createTime = DateTime.Now,
updateTime = DateTime.Now,
fixNumber = 0,
fixPrice = 0,
num = 0,
})
.ToList();
context.BeginTran();
context.Insertable(classifyInventory).ExecuteCommand();
myBIOrder.totalNum = classifyInventory.Sum(s => s.stockNumber);
myBIOrder.updateTime = DateTime.Now;
myBIOrder.inventoryState = "running";
context.Updateable(myBIOrder).UpdateColumns(it => new { it.totalNum, it.updateTime, it.inventoryState }).ExecuteCommand();
context.CommitTran();
var rs = myBIOrder;
rs.DetailList = classifyInventory;
return rs;
}
catch (Exception e)
{
return null;
}
}
}
public async Task<bool> OrderRollBack(BussinessInventory myBIOrder)
{
using (var context = _suger.GetDbClient())
{
try
{
context.BeginTran();
myBIOrder.updateTime = DateTime.Now;
myBIOrder.inventoryState = "waitting";
context.Updateable(myBIOrder).UpdateColumns(it => new { it.updateTime, it.inventoryState }).ExecuteCommand();
context.Deleteable<BussinessInventoryDetail>().Where(it => it.inventoryId == myBIOrder.id).ExecuteCommand();
context.CommitTran();
return true;
}
catch (Exception e)
{
return false;
}
}
}
}
}
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 BussinessInventoryDetailService : BaseService<BussinessInventoryDetail>, IBussinessInventoryDetailService
{
private readonly IBussinessInventoryDetailRepository _bussinessInventoryDetailRepository;
public BussinessInventoryDetailService(IBussinessInventoryDetailRepository bussinessInventoryDetailRepository)
{
base.BaseDal = bussinessInventoryDetailRepository;
_bussinessInventoryDetailRepository = bussinessInventoryDetailRepository;
}
}
}
using AutoMapper;
using Models.Table;
using Repositories.IRepository.IBussiness;
using Repositories.Repository.Bussiness;
using Services.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Services
{
public class BussinessInventoryService : BaseService<BussinessInventory>, IBussinessInventoryService
{
private readonly IBussinessInventoryRepository _bussinessInventoryRepository;
private readonly IBussinessInventoryDetailRepository _bussinessInventoryDetailRepository;
public IMapper mapper;
public BussinessInventoryService(IBussinessInventoryRepository bussinessInventoryRepository, IBussinessInventoryDetailRepository bussinessInventoryDetailRepository, IMapper _mapper)
{
base.BaseDal = bussinessInventoryRepository;
_bussinessInventoryRepository = bussinessInventoryRepository;
_bussinessInventoryDetailRepository = bussinessInventoryDetailRepository;
mapper = _mapper;
}
public Task<BussinessInventory>? GenerateInventoryOrder(BussinessInventory myBIOrder)
{
return _bussinessInventoryRepository.GenerateInventoryOrder(myBIOrder);
}
public async Task<bool> OrderRollBack(BussinessInventory myBIOrder)
{
return _bussinessInventoryRepository.OrderRollBack(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 IBussinessInventoryDetailService : IBaseServices<BussinessInventoryDetail>
{
}
}
using Models.Table;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Services.Interface
{
public interface IBussinessInventoryService : IBaseServices<BussinessInventory>
{
Task<BussinessInventory>? GenerateInventoryOrder(BussinessInventory myBIOrder);
async Task<bool> OrderRollBack(BussinessInventory myBIOrder);
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论