Commit 3bbdec0b authored by 吴春's avatar 吴春
parents 5e35908e 4b43f936
......@@ -131,5 +131,9 @@ namespace Property.Model.Entity
get;
set;
}
/// <summary>
/// 采购单id
/// </summary>
public int? ProcurementId { get; set; }
}
}
\ No newline at end of file
......@@ -1803,6 +1803,118 @@ namespace Property.Module.FixedAssets
return pmodel;
}
/// <summary>
/// 获取扫码采购商品信息
/// </summary>
/// <param name="code"></param>
/// <param name="wareHouseId"></param>
/// <param name="userInfo"></param>
/// <returns></returns>
public object GetProcurementGoodsInfo(string code, int wareHouseId, UserInfo userInfo)
{
code = code.Replace("A", "-");
string[] codeArr = code.Split('-');
if (codeArr.Length != 5) {
return new
{
Status = 1,
Msg = "编码格式不正确"
};
}
if (codeArr[0] != "D") {
return new
{
Status = 1,
Msg = "编码格式不正确"
};
}
int WarehouseId = Convert.ToInt32(codeArr[1]);
int ProcurementId = Convert.ToInt32(codeArr[2]);
int SuppliesId = Convert.ToInt32(codeArr[3]);
int StockInId = Convert.ToInt32(codeArr[4]);
if (WarehouseId != wareHouseId) {
return new
{
Status = 1,
Msg = "商品仓库不正确"
};
}
var materialModel = supplies_MaterialRepository.GetEntity(SuppliesId);
if (materialModel == null) {
return new
{
Status = 1,
Msg = "物料档案不存在"
};
}
List<string> SpecificationList = new List<string>();
List<string> ImageList = new List<string>();
if (!string.IsNullOrEmpty(materialModel.SpecificationName) && materialModel.SpecificationName != "[]") {
SpecificationList = JsonConvert.DeserializeObject<List<string>>(materialModel.SpecificationName);
}
if (!string.IsNullOrEmpty(materialModel.Images) && materialModel.Images != "[]") {
ImageList = JsonConvert.DeserializeObject<List<string>>(materialModel.Images);
}
#region 库存验证
var ilist = supplies_InventoryRepository.GetList(new RB_Supplies_Inventory_Extend() { RB_Group_Id = userInfo.RB_Group_id, WarehouseId = WarehouseId, SuppliesId = SuppliesId });
if (ilist.Any())
{
var iModel = ilist.FirstOrDefault();
if (iModel.Number <= 0)
{
return new
{
Status = 1,
Msg = "该物料库存不足"
};
}
}
#endregion
var stockInList = supplies_StockInRepository.GetList(new RB_Supplies_StockIn_Extend() { RB_Group_Id = userInfo.RB_Group_id, Id = StockInId, ProcurementId = ProcurementId });
if (!stockInList.Any()) {
return new
{
Status = 1,
Msg = "该商品未入库"
};
}
var stockInModel = stockInList.FirstOrDefault();
var stockInDetailList = supplies_StockInDetailRepository.GetList(new RB_Supplies_StockInDetail_Extend() { RB_Group_Id = userInfo.RB_Group_id, SuppliesId = SuppliesId, StockInId = StockInId });
if (!stockInDetailList.Any()) {
return new
{
Status = 1,
Msg = "该商品未入库"
};
}
var detModel = stockInDetailList.FirstOrDefault();
return new
{
Status = 0,
Msg="查询成功",
GoodsModel = new {
WarehouseId,
SuppliesId,
materialModel.GoodsId,
materialModel.Name,
materialModel.SuppliesNum,
materialModel.SpecificationKey,
SpecificationList,
ImageList,
materialModel.Units,
StockInId,
stockInModel.StockInNum,
StockInDate = stockInModel.StockInDate.HasValue? stockInModel.StockInDate.Value.ToString("yyyy-MM-dd"):"",
detModel.UnitPrice
}
};
}
#endregion
}
}
......@@ -25,6 +25,9 @@ namespace Property.Repository
if (dmodel.StockInId > 0) {
where += " and ssd." + nameof(RB_Supplies_StockInDetail_Extend.StockInId) + "=" + dmodel.StockInId;
}
if (dmodel.SuppliesId > 0) {
where += " and ssd." + nameof(RB_Supplies_StockInDetail_Extend.SuppliesId) + "=" + dmodel.SuppliesId;
}
if (!string.IsNullOrEmpty(dmodel.StockInIdStr)) {
where += " and ssd." + nameof(RB_Supplies_StockInDetail_Extend.StockInId) + " in(" + dmodel.StockInIdStr + ")";
}
......
......@@ -62,6 +62,51 @@ left join rb_supplies_material sm on ssd.SuppliesId=sm.Id
return GetPage<RB_Supplies_StockIn_Extend>(pageIndex, pageSize, out count, sql).ToList();
}
/// <summary>
/// 获取耗材分页数据
/// </summary>
/// <param name="dmodel"></param>
/// <returns></returns>
public List<RB_Supplies_StockIn_Extend> GetList(RB_Supplies_StockIn_Extend dmodel)
{
string where = " where 1=1 ";
where += string.Format(" AND ss.{0}={1}", nameof(RB_Supplies_StockIn_Extend.Status), 0);
where += $@" and ss.RB_Group_Id={dmodel.RB_Group_Id}";
if (!string.IsNullOrWhiteSpace(dmodel.StartTime))
{
where += $@" and ss.{nameof(RB_Supplies_StockIn_Extend.StockInDate)} >='{dmodel.StartTime}'";
}
if (!string.IsNullOrWhiteSpace(dmodel.EndTime))
{
where += $@" and ss.{nameof(RB_Supplies_StockIn_Extend.StockInDate)} <='{dmodel.EndTime + " 23:59:59"}'";
}
if (!string.IsNullOrWhiteSpace(dmodel.StockInNum))
{
where += " and ss." + nameof(RB_Supplies_StockIn_Extend.StockInNum) + " like '%" + dmodel.StockInNum + "%'";
}
if (!string.IsNullOrWhiteSpace(dmodel.SupplierName))
{
where += " and ss." + nameof(RB_Supplies_StockIn_Extend.SupplierName) + " like '%" + dmodel.SupplierName.Trim() + "%'";
}
if (dmodel.Id > 0)
{
where += " and ss." + nameof(RB_Supplies_StockIn_Extend.Id) + "=" + dmodel.Id;
}
if (dmodel.WarehouseId > 0)
{
where += " and ss." + nameof(RB_Supplies_StockIn_Extend.WarehouseId) + "=" + dmodel.WarehouseId;
}
if (dmodel.ProcurementId > 0)
{
where += " and ss." + nameof(RB_Supplies_StockIn_Extend.ProcurementId) + "=" + dmodel.ProcurementId;
}
string sql = $@" select ss.*,sw.Name as WareHouseName from RB_Supplies_StockIn ss
left join rb_supplies_warehouse sw on ss.WarehouseId=sw.Id
{where} order by ss.Id desc";
return Get<RB_Supplies_StockIn_Extend>(sql).ToList();
}
/// <summary>
/// 获取耗材入库出库情况
......
......@@ -1500,5 +1500,30 @@ namespace Property.WebApi.Controllers.User
#endregion
#region 根据二维码标识 获取商品信息
/// <summary>
/// 获取物料信息
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetProcurementGoodsInfo() {
var requestParm = GetRequestParm();
UserInfo userInfo = CacheManager.User.UserReidsCache.GetUserLoginInfo(requestParm.uid);
JObject parms = JObject.Parse(requestParm.msg.ToString());
string Code = parms.GetStringValue("Code");
int WareHouseId = parms.GetInt("WareHouseId", 0);
if (string.IsNullOrEmpty(Code))
{
return ApiResult.ParamIsNull("请传递参数");
}
if (WareHouseId <= 0) {
return ApiResult.ParamIsNull("请传递仓库id");
}
var obj = suppliesModule.GetProcurementGoodsInfo(Code, WareHouseId, userInfo);
return ApiResult.Success("", obj);
}
#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