Commit 37b80b2b authored by liudong1993's avatar liudong1993
parents 6eb421db e172e9ce
......@@ -18,6 +18,11 @@ namespace Property.Model.Extend.Mall
/// </summary>
public string OrderGoodsIds { get; set; }
/// <summary>
/// 申请idS
/// </summary>
public string ApplyIds { get; set; }
/// <summary>
/// 仓库id
/// </summary>
......
......@@ -29,5 +29,39 @@ namespace Property.Model.Extend
/// 耗材
/// </summary>
public RB_Supplies_Material_Extend SModel { get; set; }
/// <summary>
/// 变更类型
/// </summary>
public int Type { get; set; }
/// <summary>
/// 变更数量
/// </summary>
public int DetailNum { get; set; }
/// <summary>
/// 变更操作人
/// </summary>
public int DetailBy { get; set; }
/// <summary>
///变更时间
/// </summary>
public DateTime DetailDate { get; set; }
/// <summary>
/// 操作开始时间
/// </summary>
public string StartTime { get; set; }
/// <summary>
/// 操作结束时间
/// </summary>
public string EndTime { get; set; }
}
}
\ No newline at end of file
......@@ -3060,6 +3060,106 @@ namespace Property.Module.FixedAssets
}
}
#endregion
#region 库存操作记录
/// <summary>
/// 获取库存分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="demodel"></param>
/// <param name="count"></param>
/// <returns></returns>
public List<RB_Supplies_Inventory_Extend> GetSuppliesInventoryPageList(int pageIndex, int pageSize, RB_Supplies_Inventory_Extend demodel, out long count)
{
var list = supplies_InventoryRepository.GetSuppliesInventoryPageList(pageIndex, pageSize, demodel, out count);
if (list.Any())
{
string wstr = string.Join(",", list.Select(x => x.WarehouseId ?? 0).Distinct());
string sstr = string.Join(",", list.Select(x => x.SuppliesId ?? 0).Distinct());
//查询仓库
var wlist = supplies_WareHouseRepository.GetList(new RB_Supplies_WareHouse_Extend() { RB_Group_Id = demodel.RB_Group_Id, WareHouseIdStr = wstr });
//查询耗材
var mlist = supplies_MaterialRepository.GetList(new RB_Supplies_Material_Extend() { RB_Group_Id = demodel.RB_Group_Id, SuppliesIdStr = sstr }, true);
foreach (var item in list)
{
item.WModel = wlist.Where(x => x.Id == item.WarehouseId).FirstOrDefault();
item.SModel = mlist.Where(x => x.Id == item.SuppliesId).FirstOrDefault();
if (item.WModel == null)
{
item.WModel = new RB_Supplies_WareHouse_Extend();
}
if (item.SModel == null)
{
item.SModel = new RB_Supplies_Material_Extend();
}
item.SModel.GoodsSpecificationList = new List<string>();
item.SModel.GoodsCategoryList = new List<string>();
if (!string.IsNullOrEmpty(item.SModel.SpecificationName))
{
item.SModel.GoodsSpecificationList = JsonConvert.DeserializeObject<List<string>>(item.SModel.SpecificationName);
}
if (!string.IsNullOrEmpty(item.SModel.GoodsCategoryName))
{
item.SModel.GoodsCategoryList = JsonConvert.DeserializeObject<List<string>>(item.SModel.GoodsCategoryName);
}
}
}
return list;
}
/// <summary>
/// 获取库存分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="demodel"></param>
/// <param name="count"></param>
/// <returns></returns>
public List<RB_Supplies_Inventory_Extend> GetSuppliesInventoryEXCELList(RB_Supplies_Inventory_Extend demodel)
{
var list = supplies_InventoryRepository.GetSuppliesInventoryEXCELList(demodel);
if (list.Any())
{
string wstr = string.Join(",", list.Select(x => x.WarehouseId ?? 0).Distinct());
string sstr = string.Join(",", list.Select(x => x.SuppliesId ?? 0).Distinct());
//查询仓库
var wlist = supplies_WareHouseRepository.GetList(new RB_Supplies_WareHouse_Extend() { RB_Group_Id = demodel.RB_Group_Id, WareHouseIdStr = wstr });
//查询耗材
var mlist = supplies_MaterialRepository.GetList(new RB_Supplies_Material_Extend() { RB_Group_Id = demodel.RB_Group_Id, SuppliesIdStr = sstr }, true);
foreach (var item in list)
{
item.WModel = wlist.Where(x => x.Id == item.WarehouseId).FirstOrDefault();
item.SModel = mlist.Where(x => x.Id == item.SuppliesId).FirstOrDefault();
if (item.WModel == null)
{
item.WModel = new RB_Supplies_WareHouse_Extend();
}
if (item.SModel == null)
{
item.SModel = new RB_Supplies_Material_Extend();
}
item.SModel.GoodsSpecificationList = new List<string>();
item.SModel.GoodsCategoryList = new List<string>();
if (!string.IsNullOrEmpty(item.SModel.SpecificationName))
{
item.SModel.GoodsSpecificationList = JsonConvert.DeserializeObject<List<string>>(item.SModel.SpecificationName);
}
if (!string.IsNullOrEmpty(item.SModel.GoodsCategoryName))
{
item.SModel.GoodsCategoryList = JsonConvert.DeserializeObject<List<string>>(item.SModel.GoodsCategoryName);
}
}
}
return list;
}
#endregion
#region 耗材入库流程
......
......@@ -167,6 +167,13 @@ namespace Property.Module.Mall
}
}
var outGoodsList = warehouseOutRepository.GetWarehouseOutList(new RB_WarehouseOut_Goods_Extend { TenantId = query.TenantId, MallBaseId = query.MallBaseId, ApplyIds = string.Join(",", list.Select(x => x.ID)) });
foreach (var item in list)
{
item.WarehouseOutGoodsList = new List<RB_WarehouseOut_Goods_Extend>();
item.WarehouseOutGoodsList = outGoodsList.Where(x => x.ApplyId == item.ID).ToList();
}
}
return list;
}
......@@ -295,7 +302,8 @@ namespace Property.Module.Mall
#region 生成财务单据
#region 关联财务订单
List<object> ECList = new List<object>();
foreach (var item in applyModel.WarehouseOutGoodsList) {
foreach (var item in applyModel.WarehouseOutGoodsList)
{
ECList.Add(new
{
ECOrderId = item.OrderId,
......
......@@ -24,11 +24,7 @@ namespace Property.Repository.Mall
public List<RB_WarehouseOut_Apply_Extend> GetApplyPageList(int pageIndex, int pageSize, out long rowCount, RB_WarehouseOut_Apply_Extend query)
{
StringBuilder builder = new StringBuilder();
builder.Append(@$" select a.*,b.NotOutStock,c.Delivered from {TableName} as a
LEFT JOIN (SELECT ApplyId,COUNT(*) as NotOutStock from rb_warehouseout_goods where `IsOut`=0 and Status=0 GROUP BY ApplyId) as b on a.ID=b.ApplyId
LEFT JOIN (SELECT ApplyId,COUNT(*) as Delivered from rb_warehouseout_goods where `IsOut`=1 and Status=0 GROUP BY ApplyId) as c on a.ID=c.ApplyId
LEFT JOIN rb_warehouseout_goods as d on a.ID=d.ApplyId
where a.Status=0 ");
string goodsWhere = "";
if (query != null)
{
if (query.ID > 0)
......@@ -61,16 +57,21 @@ LEFT JOIN rb_warehouseout_goods as d on a.ID=d.ApplyId
}
if (!string.IsNullOrWhiteSpace(query.GoodsName))
{
builder.Append($" AND d.{nameof(RB_WarehouseOut_Goods.GoodsName)} like '%{query.GoodsName}%'");
goodsWhere += $" AND ({nameof(RB_WarehouseOut_Goods.GoodsName)} like '%{query.GoodsName}%' or {nameof(RB_WarehouseOut_Goods.NewGoodsName)} like '%{query.GoodsName}%')";
}
if (!string.IsNullOrWhiteSpace(query.OrderNo))
{
builder.Append($" AND d.{nameof(RB_WarehouseOut_Goods.OrderNo)} like '%{query.OrderNo}%'");
goodsWhere += $" AND {nameof(RB_WarehouseOut_Goods.OrderNo)} like '%{query.OrderNo}%'";
}
}
builder.Append($" order by a.{nameof(RB_WarehouseOut_Apply_Extend.ID)} desc");
return GetPage<RB_WarehouseOut_Apply_Extend>(pageIndex, pageSize, out rowCount, builder.ToString()).ToList();
string sql = @$" select a.*,b.NotOutStock,c.Delivered from {TableName} as a
LEFT JOIN (SELECT ApplyId,COUNT(*) as NotOutStock from rb_warehouseout_goods where `IsOut`=0 and Status=0 GROUP BY ApplyId) as b on a.ID=b.ApplyId
LEFT JOIN (SELECT ApplyId,COUNT(*) as Delivered from rb_warehouseout_goods where `IsOut`=1 and Status=0 GROUP BY ApplyId) as c on a.ID=c.ApplyId
INNER JOIN (SELECT ApplyId from rb_warehouseout_goods where 1=1 and `Status`=0 {goodsWhere} GROUP BY ApplyId) as d on a.ID=d.ApplyId
where a.Status=0 {builder.ToString()}";
return GetPage<RB_WarehouseOut_Apply_Extend>(pageIndex, pageSize, out rowCount, sql).ToList();
}
......
......@@ -98,6 +98,10 @@ namespace Property.Repository.Mall
{
builder.Append($" AND a.{nameof(RB_WarehouseOut_Goods_Extend.GoodsName)} like '%{query.GoodsName}%'");
}
if (!string.IsNullOrWhiteSpace(query.ApplyIds))
{
builder.Append($" AND a.{nameof(RB_WarehouseOut_Goods_Extend.ApplyId)} in ({query.ApplyIds}) ");
}
if (query.StockInId > 0)
{
builder.Append($" AND a.{nameof(RB_WarehouseOut_Goods_Extend.StockInId)}={query.StockInId}");
......
......@@ -114,5 +114,78 @@ left join rb_supplies_inventorydetail sid on si.Id=sid.InventoryId
{where} order by sid.Id desc";
return GetPage<RB_Supplies_InventoryDetail_Extend>(pageIndex, pageSize, out count, sql).ToList();
}
/// <summary>
/// 获取耗材仓库库存分页数据
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="dmodel"></param>
/// <param name="count"></param>
/// <returns></returns>
public List<RB_Supplies_Inventory_Extend> GetSuppliesInventoryPageList(int pageIndex, int pageSize, RB_Supplies_Inventory_Extend dmodel, out long count)
{
string where = " where 1=1 ";
where += string.Format(" AND a.{0}={1}", nameof(RB_Supplies_Inventory_Extend.Status), 0);
where += $@" and b.RB_Group_Id={dmodel.RB_Group_Id}";
if (dmodel.WarehouseId > 0)
{
where += " and b." + nameof(RB_Supplies_Inventory_Extend.WarehouseId) + $" ={dmodel.WarehouseId}";
}
if (dmodel.SuppliesId > 0)
{
where += " and b." + nameof(RB_Supplies_Inventory_Extend.SuppliesId) + $" ={dmodel.SuppliesId}";
}
if (!string.IsNullOrEmpty(dmodel.StartTime))
{
where += " and a." + nameof(RB_Supplies_InventoryDetail_Extend.CreateDate) + " >='" + dmodel.StartTime + "'";
}
if (!string.IsNullOrEmpty(dmodel.EndTime))
{
where += " and a." + nameof(RB_Supplies_InventoryDetail_Extend.CreateDate) + " <='" + dmodel.EndTime + "'";
}
string sql = $@" select b.*,a.Number as DetailNum,a.Type,a.CreateBy as DetailBy,a.CreateDate as DetailDate from rb_supplies_inventorydetail as a LEFT JOIN RB_Supplies_Inventory as b on a.InventoryId=b.Id {where} order by a.Id desc";
return GetPage<RB_Supplies_Inventory_Extend>(pageIndex, pageSize, out count, sql).ToList();
}
/// <summary>
/// 获取耗材仓库库存分页数据
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="dmodel"></param>
/// <param name="count"></param>
/// <returns></returns>
public List<RB_Supplies_Inventory_Extend> GetSuppliesInventoryEXCELList( RB_Supplies_Inventory_Extend dmodel)
{
string where = " where 1=1 ";
where += string.Format(" AND a.{0}={1}", nameof(RB_Supplies_Inventory_Extend.Status), 0);
where += $@" and b.RB_Group_Id={dmodel.RB_Group_Id}";
if (dmodel.WarehouseId > 0)
{
where += " and b." + nameof(RB_Supplies_Inventory_Extend.WarehouseId) + $" ={dmodel.WarehouseId}";
}
if (dmodel.SuppliesId > 0)
{
where += " and b." + nameof(RB_Supplies_Inventory_Extend.SuppliesId) + $" ={dmodel.SuppliesId}";
}
if (!string.IsNullOrEmpty(dmodel.StartTime))
{
where += " and a." + nameof(RB_Supplies_InventoryDetail_Extend.CreateDate) + " >='" + dmodel.StartTime + "'";
}
if (!string.IsNullOrEmpty(dmodel.EndTime))
{
where += " and a." + nameof(RB_Supplies_InventoryDetail_Extend.CreateDate) + " <='" + dmodel.EndTime + "'";
}
string sql = $@" select b.*,a.Number as DetailNum,a.Type,a.CreateBy as DetailBy,a.CreateDate as DetailDate from rb_supplies_inventorydetail as a LEFT JOIN RB_Supplies_Inventory as b on a.InventoryId=b.Id {where} order by a.Id desc";
return Get<RB_Supplies_Inventory_Extend>(sql).ToList();
}
}
}
......@@ -54,7 +54,17 @@ namespace Property.WebApi.Controllers.Mall
x.NotOutStock,
x.OutStatus,
CreateByName = CacheManager.User.UserReidsCache.GetUserLoginInfo(x.CreateBy.ToString())?.emName,
CreateDateStr = x.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss")
CreateDateStr = x.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss"),
WarehouseOutGoodsList = x.WarehouseOutGoodsList.Select(x => new
{
x.GoodsName,
x.Specification,
x.Number,
x.NewGoodsName,
x.NewSpecification,
x.NewNumber,
x.OrderNo
})
});
return ApiResult.Success("", pagelist);
}
......@@ -473,7 +483,7 @@ namespace Property.WebApi.Controllers.Mall
#region 组装财务单据需要的数据
List<RB_WarehouseOut_Goods_Extend> financeList = new List<RB_WarehouseOut_Goods_Extend>();
foreach (var item in applyModel.WarehouseOutGoodsDetailList.GroupBy(x => new { x.OrderGoodsId, x.CostMoney,x.GoodsId,x.SpecificationSort }))
foreach (var item in applyModel.WarehouseOutGoodsDetailList.GroupBy(x => new { x.OrderGoodsId, x.CostMoney, x.GoodsId, x.SpecificationSort }))
{
RB_WarehouseOut_Goods_Extend warehouseOutModel = new RB_WarehouseOut_Goods_Extend
{
......@@ -486,7 +496,7 @@ namespace Property.WebApi.Controllers.Mall
IsOut = 1,
OrderGoodsId = item.Key.OrderGoodsId,
OrderNo = oldModel.WarehouseOutGoodsList.Where(x => x.OrderGoodsId == item.Key.OrderGoodsId && x.NewSpecificationSort == item.Key.SpecificationSort && x.NewGoodsId == item.Key.GoodsId).FirstOrDefault()?.OrderNo ?? "",
GoodsName = oldModel.WarehouseOutGoodsList.Where(x => x.OrderGoodsId == item.Key.OrderGoodsId&&x.NewSpecificationSort== item.Key.SpecificationSort && x.NewGoodsId == item.Key.GoodsId).FirstOrDefault()?.GoodsName,
GoodsName = oldModel.WarehouseOutGoodsList.Where(x => x.OrderGoodsId == item.Key.OrderGoodsId && x.NewSpecificationSort == item.Key.SpecificationSort && x.NewGoodsId == item.Key.GoodsId).FirstOrDefault()?.GoodsName,
Specification = oldModel.WarehouseOutGoodsList.Where(x => x.OrderGoodsId == item.Key.OrderGoodsId && x.NewSpecificationSort == item.Key.SpecificationSort && x.NewGoodsId == item.Key.GoodsId).FirstOrDefault()?.Specification,
SpecificationSort = oldModel.WarehouseOutGoodsList.Where(x => x.OrderGoodsId == item.Key.OrderGoodsId && x.NewSpecificationSort == item.Key.SpecificationSort && x.NewGoodsId == item.Key.GoodsId).FirstOrDefault()?.SpecificationSort,
NewGoodsName = oldModel.WarehouseOutGoodsList.Where(x => x.OrderGoodsId == item.Key.OrderGoodsId && x.NewSpecificationSort == item.Key.SpecificationSort && x.NewGoodsId == item.Key.GoodsId).FirstOrDefault()?.NewGoodsName,
......
......@@ -2640,5 +2640,134 @@ namespace Property.WebApi.Controllers.User
}
}
#endregion
#region
/// <summary>
/// 获取库存分页列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetSuppliesInventoryPageList()
{
var requestParm = GetRequestParm();
UserInfo userInfo = CacheManager.User.UserReidsCache.GetUserLoginInfo(requestParm.uid);
ResultPageModel pagelist = JsonConvert.DeserializeObject<ResultPageModel>(requestParm.msg.ToString());
RB_Supplies_Inventory_Extend demodel = JsonConvert.DeserializeObject<RB_Supplies_Inventory_Extend>(requestParm.msg.ToString());
demodel.RB_Group_Id = userInfo.RB_Group_id;
var list = suppliesModule.GetSuppliesInventoryPageList(pagelist.pageIndex, pagelist.pageSize, demodel, out long count);
pagelist.count = Convert.ToInt32(count);
pagelist.pageData = list.Select(x => new
{
x.Id,
x.Number,
x.Money,
UnitPrice = x.Number == 0 ? 0 : Math.Round((x.Money ?? 0) / (x.Number ?? 1), 2, MidpointRounding.AwayFromZero),
SuppliesName = x.SModel.Name,
x.SuppliesId,
x.WarehouseId,
x.SModel.SuppliesNum,
x.SModel.CategoryName,
x.SModel.SuppliesModel,
x.SModel.BrandName,
x.SModel.Units,
x.SModel.SafetyStock,
x.SModel.ReservedStock,
x.SModel.GoodsSpecificationList,
x.SModel.GoodsCategoryList,
WareHouseName = x.WModel.Name,
TypeName = x.Type == 1 ? "增加" : "减少",
x.DetailNum,
UpdateBy = CacheManager.User.UserReidsCache.GetEmployee(x.DetailBy)?.EmName ?? "",
UpdateDate = x.DetailDate.ToString("yyyy-MM-dd HH:mm:ss")
});
return ApiResult.Success("", pagelist);
}
/// <summary>
/// 库存操作记录导出 excel
/// </summary>
[HttpPost]
public FileContentResult GetSuppliesInventoryToExcel()
{
var requestParm = GetRequestParm();
UserInfo userInfo = CacheManager.User.UserReidsCache.GetUserLoginInfo(requestParm.uid);
RB_Supplies_Inventory_Extend demodel = JsonConvert.DeserializeObject<RB_Supplies_Inventory_Extend>(requestParm.msg.ToString());
List<ExcelDataSource> slist = new List<ExcelDataSource>();
ExcelDataSource header = new ExcelDataSource()
{
ExcelRows = new List<ExcelColumn>(30) {
new ExcelColumn(value:"耗材编码"){CellWidth=15,HAlignmentEnum= HAlignmentEnum.CENTER,VAlignmentEnum= VAlignmentEnum.CENTER },
new ExcelColumn(value:"耗材名称"){CellWidth=15,HAlignmentEnum= HAlignmentEnum.CENTER,VAlignmentEnum= VAlignmentEnum.CENTER },
new ExcelColumn(value:"规格"){CellWidth=15,HAlignmentEnum= HAlignmentEnum.CENTER,VAlignmentEnum= VAlignmentEnum.CENTER },
new ExcelColumn(value:"分类名称"){CellWidth=25,HAlignmentEnum= HAlignmentEnum.CENTER,VAlignmentEnum= VAlignmentEnum.CENTER },
new ExcelColumn(value:"仓库名称"){CellWidth=25,HAlignmentEnum= HAlignmentEnum.CENTER,VAlignmentEnum= VAlignmentEnum.CENTER },
new ExcelColumn(value:"品牌"){CellWidth=25,HAlignmentEnum= HAlignmentEnum.CENTER,VAlignmentEnum= VAlignmentEnum.CENTER },
new ExcelColumn(value:"变更说明"){CellWidth=15,HAlignmentEnum= HAlignmentEnum.CENTER,VAlignmentEnum= VAlignmentEnum.CENTER },
new ExcelColumn(value:"变更时间"){CellWidth=20,HAlignmentEnum= HAlignmentEnum.CENTER,VAlignmentEnum= VAlignmentEnum.CENTER },
new ExcelColumn(value:"操作人"){CellWidth=15,HAlignmentEnum= HAlignmentEnum.CENTER,VAlignmentEnum= VAlignmentEnum.CENTER },
},
};
slist.Add(header);
try
{
demodel.RB_Group_Id = userInfo.RB_Group_id;
var list = suppliesModule.GetSuppliesInventoryEXCELList(demodel);
#region 组装数据
int TotalNum = 0;
foreach (var item in list)
{
TotalNum += (item.Number ?? 0);
ExcelDataSource datarow = new ExcelDataSource()
{
ExcelRows = new List<ExcelColumn>(30) {
new ExcelColumn(value:item.SModel.SuppliesNum){ },
new ExcelColumn(value:item.SModel.Name){ },
new ExcelColumn(value:string.Join(",",item.SModel.GoodsSpecificationList.Select(x=>x))){ },
new ExcelColumn(value:item.SModel.CategoryName){ },
new ExcelColumn(value:item.WModel.Name){ },
new ExcelColumn(value:item.SModel.BrandName){ },
new ExcelColumn(value:((item.Type == 1 ? "增加" : "减少")+item.DetailNum+item.SModel.Units)){ },
new ExcelColumn(value:( CacheManager.User.UserReidsCache.GetEmployee(item.DetailBy)?.EmName ?? "")){ },
new ExcelColumn(value:item.DetailDate.ToString("yyyy-MM-dd HH:mm:ss")){ },
}
};
slist.Add(datarow);
}
#endregion
ExcelDataSource Total = new ExcelDataSource()
{
ExcelRows = new List<ExcelColumn>(30) {
new ExcelColumn(value:"合计(共"+list.Count()+"条)"){ Colspan=10},
new ExcelColumn(value:TotalNum.ToString("#0")){},
},
};
slist.Add(Total);
var byteData = ExcelTempLateHelper.ToExcelExtend(slist);
return File(byteData, "application/octet-stream", "物料库存变更统计.xls");
}
catch (Exception ex)
{
LogHelper.Write(ex, string.Format("GetFileFromWebApi_requestData: {0}", JsonHelper.Serialize(requestParm)));
var byteData1 = ExcelTempLateHelper.ToExcelExtend(slist);
return File(byteData1, "application/octet-stream", "物料库存变更统计.xls");
}
}
#endregion
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment