Commit f540783c authored by liudong1993's avatar liudong1993

物料有效期+重新入库

parent ed60c2a7
using System;
using VT.FW.DB;
using Mall.Common.Plugin;
namespace Mall.Model.Entity.Property
{
/// <summary>
/// 耗材有效期实体
/// </summary>
[Serializable]
[DB(ConnectionName = "PropertyConnection")]
public class RB_Supplies_StockInValidity
{
/// <summary>
/// Id
/// </summary>
public int Id { get; set; }
/// <summary>
/// 入库单id
/// </summary>
public int StockinId { get; set; }
/// <summary>
/// 入库单明细id
/// </summary>
public int StockinDetailId { get; set; }
/// <summary>
/// 有效日期
/// </summary>
public DateTime ExpirationDate { get; set; }
/// <summary>
/// 是否出库 1是 2否
/// </summary>
public int IsOut { get; set; }
/// <summary>
/// 出库单id
/// </summary>
public int StockoutId { get; set; }
/// <summary>
/// 状态 0正常 1删除
/// </summary>
public int Status { get; set; }
/// <summary>
/// 集团
/// </summary>
public int RB_Group_Id { get; set; }
/// <summary>
/// CreateBy
/// </summary>
public int CreateBy { get; set; }
/// <summary>
/// CreateDate
/// </summary>
public DateTime CreateDate { get; set; }
}
}
\ No newline at end of file
......@@ -141,5 +141,10 @@ namespace Mall.Model.Entity.Property
/// 成本价
/// </summary>
public decimal? CostMoney { get; set; }
/// <summary>
/// 商品有效期id
/// </summary>
public int ValidityId { get; set; }
}
}
......@@ -39,6 +39,11 @@ namespace Mall.Model.Extend.Property
/// </summary>
public int InStockNum { get; set; }
/// <summary>
/// 物料有效期
/// </summary>
public List<RB_Supplies_StockInValidity_Extend> ValidityList { get; set; }
/// <summary>
/// 条形码
/// </summary>
......
using System;
using System.Collections.Generic;
using Mall.Model.Entity.Property;
using VT.FW.DB;
......@@ -43,5 +44,10 @@ namespace Mall.Model.Extend.Property
/// 踱等Id
/// </summary>
public string StockInIdStr { get; set; }
/// <summary>
/// 昜蹋衄虴
/// </summary>
public List<RB_Supplies_StockInValidity_Extend> ValidityList { get; set; }
}
}
\ No newline at end of file
using System;
using Mall.Model.Entity.Property;
using VT.FW.DB;
namespace Mall.Model.Extend.Property
{
/// <summary>
/// 物料有效期扩展实体
/// </summary>
[Serializable]
[DB(ConnectionName = "PropertyConnection")]
public class RB_Supplies_StockInValidity_Extend : RB_Supplies_StockInValidity
{
/// <summary>
/// 入库ids
/// </summary>
public string StockInIdStr { get; set; }
/// <summary>
/// 有效期ids
/// </summary>
public string ValidityIds { get; set; }
}
}
\ No newline at end of file
......@@ -20,6 +20,11 @@ namespace Mall.Model.Extend.Property
/// </summary>
public string WarehouseOutIds { get; set; }
/// <summary>
/// 有效期ids
/// </summary>
public string ValidityIds { get; set; }
/// <summary>
/// 订单号
/// </summary>
......
......@@ -8409,6 +8409,10 @@ namespace Mall.Module.Product
//剑鱼兄需求 2020=07-30 再查询一次商品表
string GoodsIds = string.Join(",", dlist.Select(x => x.GoodsId).Distinct());
var GList = goodsRepository.GetSingleListForGoodsSubName(new RB_Goods_Extend() { TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId, GoodsIds = GoodsIds }, true);
#region 查询商品申请售后
string OrderDetialIds = string.Join(",", dlist.Select(x => x.Id));
var afterSaleList = goods_OrderAfterSaleRepository.GetList(new RB_Goods_OrderAfterSale_Extend() { OrderDetailIds = OrderDetialIds, Type = 1, MallBaseId = demodel.MallBaseId, TenantId = demodel.TenantId });
#endregion
foreach (var item in dlist)
{
item.CoverImagePath = item.CoverImage;
......@@ -8417,6 +8421,12 @@ namespace Mall.Module.Product
item.GoodsSubName = GList.Where(x => x.Id == item.GoodsId).FirstOrDefault()?.SubName ?? "";
item.FinanceList = flist.Where(x => x.ECOrderDetailId == item.Id).ToList();// 2020-08-19 新增财务单据列表
#region 是否申请售后
item.IsApplyForAfterSale = 2;
if (afterSaleList.Where(x => x.OrderDetialId == item.Id).Any()) {
item.IsApplyForAfterSale = 1;
}
#endregion
}
}
string areaIds1 = string.Join(",", list.Select(x => x.Province ?? 0).Distinct());
......
......@@ -140,6 +140,10 @@ namespace Mall.Module.Property
/// 重新入库
/// </summary>
private readonly RB_Warehouseout_InventoryRepository warehouseout_InventoryRepository = new RB_Warehouseout_InventoryRepository();
/// <summary>
/// 物料有效期
/// </summary>
private readonly RB_Supplies_StockInValidityRepository supplies_StockInValidityRepository = new RB_Supplies_StockInValidityRepository();
#region 获取采购单
......@@ -701,7 +705,8 @@ namespace Mall.Module.Property
StockInId = 0,
UnitPrice = (dModel.CostMoney ?? 0),
UpdateBy = eRPEmpId,
UpdateDate = DateTime.Now
UpdateDate = DateTime.Now,
ValidityList = item.ValidityList
});
}
......@@ -790,7 +795,7 @@ namespace Mall.Module.Property
//新增明细
foreach (var item in demodel.DetailList)
{
supplies_StockInDetailRepository.Insert(new RB_Supplies_StockInDetail()
int detailId = supplies_StockInDetailRepository.Insert(new RB_Supplies_StockInDetail()
{
CreateBy = demodel.CreateBy,
CreateDate = demodel.CreateDate,
......@@ -875,6 +880,26 @@ namespace Mall.Module.Property
}
}
}
#region 物料有效期
if (item.ValidityList != null && item.ValidityList.Any()) {
foreach (var qitem in item.ValidityList) {
supplies_StockInValidityRepository.Insert(new RB_Supplies_StockInValidity()
{
Id = 0,
CreateBy = demodel.CreateBy ?? 0,
CreateDate = DateTime.Now,
ExpirationDate = qitem.ExpirationDate,
IsOut = 2,
RB_Group_Id = demodel.RB_Group_Id ?? 0,
Status = 0,
StockoutId = 0,
StockinId = Id,
StockinDetailId = detailId
});
}
}
#endregion
}
#region 新增耗材入库流程
......@@ -983,6 +1008,9 @@ namespace Mall.Module.Property
{
string siIds = string.Join(",", siList.Where(x => x.StockInState == 1).Select(x => x.Id));
var sidList = supplies_StockInDetailRepository.GetList(new RB_Supplies_StockInDetail_Extend() { RB_Group_Id = eRPGroupId, StockInIdStr = siIds });
#region 查询有效期
var validityList = supplies_StockInValidityRepository.GetList(new RB_Supplies_StockInValidity_Extend() { RB_Group_Id = eRPGroupId, StockInIdStr = siIds });
#endregion
List<RB_Supplies_Material_Extend> materialList = new List<RB_Supplies_Material_Extend>();
List<Model.Extend.Property.RB_Employee_Extend> empList = new List<Model.Extend.Property.RB_Employee_Extend>();
List<RB_Goods_Extend> GList = new List<RB_Goods_Extend>();
......@@ -1000,7 +1028,6 @@ namespace Mall.Module.Property
}
foreach (var item in sidList)
{
var siModel = siList.Where(x => x.Id == item.StockInId).FirstOrDefault();
var materialModel = materialList.Where(x => x.Id == item.SuppliesId).FirstOrDefault();
if (materialModel == null) { continue; }
......@@ -1012,6 +1039,59 @@ namespace Mall.Module.Property
}
var empModel = empList.Where(x => x.EmployeeId == item.CreateBy).FirstOrDefault();
var vList = validityList.Where(x => x.StockinDetailId == item.Id).ToList();
if (vList.Any())
{
var gmodel = GList.Where(x => x.Id == (materialModel.GoodsId ?? 0)).FirstOrDefault();
string SubName = gmodel?.SubName ?? "";
//直接根据有效期id 来生成二维码
foreach (var qitem in vList)
{
string QRCode = "D-" + (siModel.WarehouseId ?? 0) + "-" + procurementId + "-" + (item.SuppliesId ?? 0) + "-" + (item.StockInId ?? 0) + "-" + qitem.Id;
string TQRCode = "DA" + (siModel.WarehouseId ?? 0) + "A" + procurementId + "A" + (item.SuppliesId ?? 0) + "A" + (item.StockInId ?? 0) + "A" + qitem.Id;
#region 生成二维码 + 条形码
string QRName = "QR-" + DateTime.Now.ToString("yyyyMMdd") + "-" + procurementId + "-" + (item.SuppliesId ?? 0) + "-" + qitem.Id + ".jpg";
string TQRName = "TQR-" + DateTime.Now.ToString("yyyyMMdd") + "-" + procurementId + "-" + (item.SuppliesId ?? 0) + "A" + qitem.Id + ".jpg";
string basepath = AppContext.BaseDirectory;
string QRPath = basepath + "\\upfile\\code\\" + QRName;
string QRImage = "/upfile/code/" + QRName;
string TQRPath = basepath + "\\upfile\\code\\" + TQRName;
string TQRImage = "/upfile/code/" + TQRName;
//验证文件是否存在, 存在的话就不用生成了
if (!File.Exists(QRPath))
{
QRCodeHelper.CreateQRCode(QRCode, 5, "", QRPath, ImageFormat.Jpeg);
}
//条形码暂不生成 2021-03-30 ld
//if (!File.Exists(TQRPath))
//{
// int width = 340;
// if (TQRCode.Length > 30)
// {
// width = 370;
// }
// QRCodeHelper.CreateTQRCode(TQRCode, TQRPath, ImageFormat.Jpeg, width, 50);
//}
#endregion
RObj.Add(new
{
materialModel.GoodsId,
GoodsName = SubName == "" ? materialModel.Name : SubName,
SpecificationList = spList,
CreateDate = item.CreateDate.HasValue ? item.CreateDate.Value.ToString("yyyy-MM-dd") : "",
EmName = empModel?.EmName ?? "",
siModel.WareHouseName,
CostMoney = item.UnitPrice,
QRImage,
TQRImage,
TQRCode,
ExpirationDate = qitem.ExpirationDate.ToString("yyyy-MM-dd")
});
}
}
else
{
string QRCode = "D-" + (siModel.WarehouseId ?? 0) + "-" + procurementId + "-" + (item.SuppliesId ?? 0) + "-" + (item.StockInId ?? 0);
string TQRCode = "DA" + (siModel.WarehouseId ?? 0) + "A" + procurementId + "A" + (item.SuppliesId ?? 0) + "A" + (item.StockInId ?? 0);
#region 生成二维码 + 条形码
......@@ -1027,15 +1107,16 @@ namespace Mall.Module.Property
{
QRCodeHelper.CreateQRCode(QRCode, 5, "", QRPath, ImageFormat.Jpeg);
}
if (!File.Exists(TQRPath))
{
int width = 340;
if (TQRCode.Length > 30)
{
width = 370;
}
QRCodeHelper.CreateTQRCode(TQRCode, TQRPath, ImageFormat.Jpeg, width, 50);
}
//条形码暂不生成 2021-03-30 ld
//if (!File.Exists(TQRPath))
//{
// int width = 340;
// if (TQRCode.Length > 30)
// {
// width = 370;
// }
// QRCodeHelper.CreateTQRCode(TQRCode, TQRPath, ImageFormat.Jpeg, width, 50);
//}
#endregion
var gmodel = GList.Where(x => x.Id == (materialModel.GoodsId ?? 0)).FirstOrDefault();
......@@ -1053,10 +1134,12 @@ namespace Mall.Module.Property
CostMoney = item.UnitPrice,
QRImage,
TQRImage,
TQRCode
TQRCode,
ExpirationDate = ""
});
}
}
}
}
return RObj;
......@@ -1168,6 +1251,44 @@ namespace Mall.Module.Property
OrderNo = item.OrderNo
}, trans);
IList.Add(Id);
if (!string.IsNullOrEmpty(item.ValidityIds)) {
List<int> ValidityIdList = JsonConvert.DeserializeObject<List<int>>("[" + item.ValidityIds + "]");
if (item.Number == item.InventoryNum)
{
//全部重新入库
foreach (var qitem in ValidityIdList.Where(x => x > 0))
{
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Supplies_StockInValidity_Extend.IsOut),2}
};
List<WhereHelper> whereHelpers = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Supplies_StockInValidity_Extend.Id),
FiledValue= qitem,
OperatorEnum=OperatorEnum.Equal
}
};
supplies_StockInValidityRepository.Update(keyValues, whereHelpers, trans);
}
}
else {
var vlist = supplies_StockInValidityRepository.GetList(new RB_Supplies_StockInValidity_Extend() { RB_Group_Id = eRPGroupId, ValidityIds = item.ValidityIds });
vlist = vlist.OrderByDescending(x => x.ExpirationDate).Take(item.InventoryNum).ToList();
foreach (var qitem in vlist) {
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Supplies_StockInValidity_Extend.IsOut),2}
};
List<WhereHelper> whereHelpers = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Supplies_StockInValidity_Extend.Id),
FiledValue= qitem.Id,
OperatorEnum=OperatorEnum.Equal
}
};
supplies_StockInValidityRepository.Update(keyValues, whereHelpers, trans);
}
}
}
}
if (IList.Any())
{
......
using Mall.Model.Entity.Property;
using Mall.Model.Extend.Property;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Mall.Repository.Property
{
/// <summary>
/// 物料有效期仓储类
/// </summary>
public partial class RB_Supplies_StockInValidityRepository : BaseRepository<RB_Supplies_StockInValidity>
{
/// <summary>
/// 获取分页数据
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="dmodel"></param>
/// <param name="count"></param>
/// <returns></returns>
public List<RB_Supplies_StockInValidity_Extend> GetPageList(int pageIndex, int pageSize, RB_Supplies_StockInValidity_Extend dmodel, out long count)
{
string where = " where 1=1 ";
where += string.Format(" AND {0}={1}", nameof(RB_Supplies_StockInValidity_Extend.Status), 0);
where += $@" and RB_Group_Id={dmodel.RB_Group_Id}";
if (dmodel.StockinId > 0)
{
where += " and " + nameof(RB_Supplies_StockInValidity_Extend.StockinId) + $" ={dmodel.StockinId}";
}
if (dmodel.StockinDetailId > 0)
{
where += " and " + nameof(RB_Supplies_StockInValidity_Extend.StockinDetailId) + $" ={dmodel.StockinDetailId}";
}
if (dmodel.IsOut > 0)
{
where += " and " + nameof(RB_Supplies_StockInValidity_Extend.IsOut) + $" ={dmodel.IsOut}";
}
if (dmodel.StockoutId > 0)
{
where += " and " + nameof(RB_Supplies_StockInValidity_Extend.StockoutId) + $" ={dmodel.StockoutId}";
}
string sql = $@" select * from RB_Supplies_StockInValidity {where} order by Id desc";
return GetPage<RB_Supplies_StockInValidity_Extend>(pageIndex, pageSize, out count, sql).ToList();
}
/// <summary>
/// 获取列表
/// </summary>
/// <param name="dmodel"></param>
/// <returns></returns>
public List<RB_Supplies_StockInValidity_Extend> GetList(RB_Supplies_StockInValidity_Extend dmodel)
{
string where = " where 1=1 ";
where += string.Format(" AND {0}={1}", nameof(RB_Supplies_StockInValidity_Extend.Status), 0);
where += $@" and RB_Group_Id={dmodel.RB_Group_Id}";
if (!string.IsNullOrEmpty(dmodel.ValidityIds))
{
where += " and " + nameof(RB_Supplies_StockInValidity_Extend.Id) + $" in({dmodel.ValidityIds})";
}
if (dmodel.StockinId > 0)
{
where += " and " + nameof(RB_Supplies_StockInValidity_Extend.StockinId) + $" ={dmodel.StockinId}";
}
if (!string.IsNullOrEmpty(dmodel.StockInIdStr))
{
where += " and " + nameof(RB_Supplies_StockInValidity_Extend.StockinId) + $" in({dmodel.StockInIdStr})";
}
if (dmodel.StockinDetailId > 0)
{
where += " and " + nameof(RB_Supplies_StockInValidity_Extend.StockinDetailId) + $" ={dmodel.StockinDetailId}";
}
if (dmodel.IsOut > 0)
{
where += " and " + nameof(RB_Supplies_StockInValidity_Extend.IsOut) + $" ={dmodel.IsOut}";
}
if (dmodel.StockoutId > 0)
{
where += " and " + nameof(RB_Supplies_StockInValidity_Extend.StockoutId) + $" ={dmodel.StockoutId}";
}
string sql = $@" select * from RB_Supplies_StockInValidity {where} order by Id desc";
return Get<RB_Supplies_StockInValidity_Extend>(sql).ToList();
}
}
}
......@@ -103,7 +103,7 @@ namespace Mall.Repository.Property
StringBuilder builder = new StringBuilder();
builder.Append($@"SELECT a.*,i.InventoryNum,i.CreateDate as StockInDate FROM(
SELECT gd.OrderId,gd.OrderGoodsId,gd.GoodsId,gd.StockOutId,gd.MaterialId,gd.GoodsName
,gd.Specification,gd.CostMoney,gd.ProductCode,gd.WarehouseId,s.StockOutDate,w.`Name` as WarehouseName,COUNT(0) AS Number
,gd.Specification,gd.CostMoney,gd.ProductCode,gd.WarehouseId,s.StockOutDate,w.`Name` as WarehouseName,GROUP_CONCAT(gd.ValidityId) as ValidityIds,COUNT(0) AS Number
FROM rb_warehouseout_goodsdetail gd
LEFT JOIN rb_supplies_stockout s on gd.StockOutId = s.Id and s.`Status`=0 and s.StockOutState =1
LEFT JOIN rb_supplies_warehouse w on gd.WarehouseId =w.Id
......
......@@ -139,6 +139,7 @@ namespace Mall.WebApi.Controllers.MallBase
IntegralMoney = y.IntegralMoney ?? 0,
IntegralNumber = y.IntegralNumber ?? 0,
DeductionCommission = y.DeductionCommission ?? 0,
y.IsApplyForAfterSale,
SFinanceList = y.FinanceList.Where(z => z.Type == 1).Select(z => new
{
z.FrID,
......
......@@ -292,6 +292,13 @@ namespace Mall.WebApi.Controllers.MallBase
{
return ApiResult.ParamIsNull("请输入入库数量");
}
if (item.ValidityList != null && item.ValidityList.Count() > 0)
{
if (item.ValidityList.Count() != item.InStockNum)
{
return ApiResult.ParamIsNull("有效期数量与入库数量不匹配");
}
}
}
//判断当前仓库是否在盘点中2020-07-28 Add By:W
......@@ -408,6 +415,7 @@ namespace Mall.WebApi.Controllers.MallBase
x.WarehouseId,
x.WarehouseName,
x.Number,
x.ValidityIds,
StockOutDate = x.StockOutDate.HasValue ? x.StockOutDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
StockInDate = x.StockInDate.HasValue ? x.StockInDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
x.InventoryNum
......@@ -448,8 +456,11 @@ namespace Mall.WebApi.Controllers.MallBase
if (item.WarehouseId <= 0) {
return ApiResult.ParamIsNull("请传递仓库id");
}
if (item.Number <= 0){
return ApiResult.ParamIsNull("请传递出库数量");
}
if (item.InventoryNum <= 0) {
return ApiResult.ParamIsNull("请传递入库数量");
return ApiResult.ParamIsNull("请传递重新入库数量");
}
if (string.IsNullOrEmpty(item.GoodsName))
{
......
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