Commit 65c58a2c authored by 吴春's avatar 吴春

提交代码

parent 87f6ad82
......@@ -99,6 +99,31 @@ namespace Mall.Model.Entity.Property
/// </summary>
public string SpecificationSort { get; set; }
/// <summary>
/// 规格key(出库的规格),没有修改为
/// </summary>
public string NewSpecificationSort { get; set; }
/// <summary>
/// 规格(出库的规格名称)
/// </summary>
public string NewSpecification
{
get;
set;
}
/// <summary>
/// 规格(出库的数量)
/// </summary>
public int NewNumber
{
get;
set;
}
/// <summary>
/// 货号
/// </summary>
......
......@@ -155,5 +155,30 @@ namespace Mall.Model.Extend.Product
/// </summary>
public int IsSelectAll { get; set; }
/// <summary>
/// 规格key(出库的规格),没有修改为
/// </summary>
public string NewSpecificationSort { get; set; }
/// <summary>
/// 规格(出库的规格名称)
/// </summary>
public string NewSpecification
{
get;
set;
}
/// <summary>
/// 规格(出库的数量)
/// </summary>
public int NewNumber
{
get;
set;
}
}
}
......@@ -120,15 +120,18 @@ namespace Mall.Module.Property
public List<RB_Procurement_Extend> GetProcurementPageList(int pageIndex, int pageSize, RB_Procurement_Extend demodel, out long count)
{
var list = procurementRepository.GetPageList(pageIndex, pageSize, demodel, out count);
if (list.Any()) {
if (list.Any())
{
string procurementIds = string.Join(",", list.Select(x => x.Id));
//查询明细
var pdList = procurement_DetailRepository.GetList(new RB_Procurement_Detail_Extend() { RB_Group_Id = demodel.RB_Group_Id, ProcurementIds = procurementIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
//查询物料
if (pdList.Any()) {
if (pdList.Any())
{
string MaterialIds = string.Join(",", pdList.Select(x => x.MaterialId).Distinct());
var mList = supplies_MaterialRepository.GetList(new RB_Supplies_Material_Extend() { RB_Group_Id = demodel.RB_Group_Id, SuppliesIdStr = MaterialIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
foreach (var item in pdList) {
foreach (var item in pdList)
{
item.MaterialModel = mList.Where(x => x.Id == item.MaterialId).FirstOrDefault();
if (item.MaterialModel != null)
{
......@@ -148,14 +151,16 @@ namespace Mall.Module.Property
}
item.MaterialModel.ImageList = JsonConvert.DeserializeObject<List<string>>(item.MaterialModel.Images);
}
else {
else
{
item.MaterialModel = new RB_Supplies_Material_Extend();
}
}
}
//var elist = employeeRepository.GetEmployeeListRepository(new Model.Entity.User.RB_Employee_Extend() { EmployeeIds = string.Join(",", list.Select(x => x.CreateBy ?? 0).Distinct()) });
var wlist = supplies_WareHouseRepository.GetList(new RB_Supplies_WareHouse_Extend() { RB_Group_Id = demodel.RB_Group_Id, WareHouseIdStr = string.Join(",", list.Select(x => x.WareHouseId ?? 0).Distinct()) });
foreach (var item in list) {
foreach (var item in list)
{
item.DetailList = pdList.Where(x => x.ProcurementId == item.Id).ToList();
//item.CreateByName = elist.Where(x => x.EmpId == item.CreateBy).FirstOrDefault()?.EmpName ?? "";
item.WareHouseName = wlist.Where(x => x.Id == item.WareHouseId).FirstOrDefault()?.Name ?? "";
......@@ -236,7 +241,8 @@ namespace Mall.Module.Property
{
item.SpecificationPriceList = SpecificationPriceList.Where(x => x.GoodsId == item.Id).ToList();
}
else {
else
{
item.SpecificationPriceList = new List<RB_Goods_SpecificationPrice_Extend>();
item.SpecificationPriceList.Add(new RB_Goods_SpecificationPrice_Extend()
{
......@@ -261,7 +267,7 @@ namespace Mall.Module.Property
/// <param name="TenantId"></param>
/// <param name="MallBaseId"></param>
/// <returns></returns>
public RB_Procurement_Extend GetProcurementInfo(int procurementId,int TenantId,int MallBaseId,int ERPGroupId)
public RB_Procurement_Extend GetProcurementInfo(int procurementId, int TenantId, int MallBaseId, int ERPGroupId)
{
var pmodel = procurementRepository.GetEntity<RB_Procurement_Extend>(procurementId);
//查询明细
......@@ -323,14 +329,17 @@ namespace Mall.Module.Property
//核实提交的商品物料里是否存在
string GoodsIds = string.Join(",", demodel.DetailList.Select(x => x.GoodsId).Distinct());
var mList = supplies_MaterialRepository.GetList(new RB_Supplies_Material_Extend() { RB_Group_Id = eRPGroupId, GoodsIds = GoodsIds, TenantId = tenantId, MallBaseId = mallBaseId });
foreach (var item in demodel.DetailList) {
foreach (var item in demodel.DetailList)
{
var mModel = mList.Where(x => x.GoodsId == item.GoodsId && x.SpecificationKey == item.SpecificationKey).FirstOrDefault();
if (mModel == null) {
if (mModel == null)
{
return "商品未找到对应的资产物料档案,商品ID:" + item.GoodsId;
}
item.MaterialId = mModel.Id;
item.GoodsRemark = mModel.Name +"("+ item.GoodsId + ")"+ " ";
if (!string.IsNullOrEmpty(mModel.SpecificationName)) {
item.GoodsRemark = mModel.Name + "(" + item.GoodsId + ")" + " ";
if (!string.IsNullOrEmpty(mModel.SpecificationName))
{
var sList = JsonConvert.DeserializeObject<List<string>>(mModel.SpecificationName);
item.GoodsRemark += string.Join(",", sList);
}
......@@ -409,7 +418,7 @@ namespace Mall.Module.Property
/// </summary>
/// <param name="omodel"></param>
/// <returns></returns>
public bool OrderProcurementFinanceModule(RB_Procurement_Extend demodel, int BankAccountId,int pid,string pRemark)
public bool OrderProcurementFinanceModule(RB_Procurement_Extend demodel, int BankAccountId, int pid, string pRemark)
{
var flag = false;
try
......@@ -520,19 +529,24 @@ namespace Mall.Module.Property
public string SetProcurementStockIn(RB_Procurement_Extend demodel, int eRPEmpId, int eRPBranchId, int eRPGroupId, int tenantId, int mallBaseId, int empId)
{
var pModel = procurementRepository.GetEntity(demodel.Id);
if (pModel == null) {
if (pModel == null)
{
return "未能找到采购单";
}
if (pModel.StockInStatus == 3) {
if (pModel.StockInStatus == 3)
{
return "该采购单已入库完毕";
}
var DetailList = procurement_DetailRepository.GetList(new RB_Procurement_Detail_Extend() { RB_Group_Id = eRPGroupId, ProcurementId = demodel.Id });
if (DetailList.Any()) {
if (DetailList.Any())
{
string materialIds = string.Join(",", DetailList.Select(x => x.MaterialId ?? 0).Distinct());
var materialList = supplies_MaterialRepository.GetList(new RB_Supplies_Material_Extend() { RB_Group_Id = eRPGroupId, SuppliesIdStr = materialIds });
foreach (var item in DetailList) {
foreach (var item in DetailList)
{
var materialModel = materialList.Where(x => x.Id == item.MaterialId).FirstOrDefault();
if (materialModel == null) {
if (materialModel == null)
{
return "未能查询到物料信息";
}
item.GoodsId = materialModel.GoodsId ?? 0;
......@@ -540,19 +554,23 @@ namespace Mall.Module.Property
}
}
//验证已入库数量
foreach (var item in demodel.DetailList) {
foreach (var item in demodel.DetailList)
{
var dModel = DetailList.Where(x => x.GoodsId == item.GoodsId && x.SpecificationKey == item.SpecificationKey).FirstOrDefault();
if (dModel == null) {
if (dModel == null)
{
return "未找到相关商品信息,商品ID:" + item.GoodsId;
}
if ((dModel.Number ?? 0) - (dModel.StockInNum ?? 0) < item.InStockNum) {
if ((dModel.Number ?? 0) - (dModel.StockInNum ?? 0) < item.InStockNum)
{
return "剩余入库数量不足,请核实后再试,商品ID:" + item.GoodsId;
}
dModel.StockInNum = (dModel.StockInNum ?? 0) + item.InStockNum;
}
bool IsComplete = true;
foreach (var item in DetailList) {
foreach (var item in DetailList)
{
if ((item.Number ?? 0) > (item.StockInNum ?? 0))
{
IsComplete = false;//部分入库
......@@ -608,7 +626,8 @@ namespace Mall.Module.Property
stockInModel.SupplierName = pModel.SupplierName;
stockInModel.DetailList = new List<RB_Supplies_StockInDetail_Extend>();
stockInModel.Money = 0;
foreach (var item in demodel.DetailList) {
foreach (var item in demodel.DetailList)
{
var dModel = DetailList.Where(x => x.GoodsId == item.GoodsId && x.SpecificationKey == item.SpecificationKey).FirstOrDefault();
decimal Money = (dModel.CostMoney ?? 0) * item.InStockNum;
stockInModel.Money += Money;
......@@ -632,7 +651,8 @@ namespace Mall.Module.Property
}
bool falg2 = SetStockInInfo(stockInModel, trans);
if (falg2 == false) {
if (falg2 == false)
{
procurementRepository.DBSession.Rollback();
return "资产入库单生成失败";
}
......@@ -809,12 +829,13 @@ namespace Mall.Module.Property
/// <param name="eRPGroupId"></param>
/// <param name="empId"></param>
/// <returns></returns>
public object GetProcurementStockInLableList(int procurementId,int StockInId, int eRPEmpId, int eRPGroupId, int empId)
public object GetProcurementStockInLableList(int procurementId, int StockInId, int eRPEmpId, int eRPGroupId, int empId)
{
List<object> RObj = new List<object>();
var pmodel = procurementRepository.GetEntity(procurementId);
var siList = supplies_StockInRepository.GetList(new RB_Supplies_StockIn_Extend() { RB_Group_Id = eRPGroupId, ProcurementId = procurementId, Id = StockInId });
if (siList.Any()) {
if (siList.Any())
{
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 });
List<RB_Supplies_Material_Extend> materialList = new List<RB_Supplies_Material_Extend>();
......@@ -827,14 +848,16 @@ namespace Mall.Module.Property
string erpEmpIds = string.Join(",", sidList.Select(x => x.CreateBy ?? 0).Distinct());
empList = erpemployeeRepository.GetList(new Model.Extend.Property.RB_Employee_Extend() { RB_Group_id = eRPGroupId, EmployeeIds = erpEmpIds });
}
foreach (var item in sidList) {
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; }
List<string> spList = new List<string>();
if (!string.IsNullOrEmpty(materialModel.SpecificationName) && materialModel.SpecificationName != "[]") {
if (!string.IsNullOrEmpty(materialModel.SpecificationName) && materialModel.SpecificationName != "[]")
{
spList = JsonConvert.DeserializeObject<List<string>>(materialModel.SpecificationName);
}
var empModel = empList.Where(x => x.EmployeeId == item.CreateBy).FirstOrDefault();
......@@ -850,18 +873,22 @@ namespace Mall.Module.Property
string TQRPath = basepath + "\\upfile\\code\\" + TQRName;
string TQRImage = "/upfile/code/" + TQRName;
//验证文件是否存在, 存在的话就不用生成了
if (!File.Exists(QRPath)) {
if (!File.Exists(QRPath))
{
QRCodeHelper.CreateQRCode(QRCode, 5, "", QRPath, ImageFormat.Jpeg);
}
if (!File.Exists(TQRPath)) {
if (!File.Exists(TQRPath))
{
int width = 340;
if (TQRCode.Length > 30) {
if (TQRCode.Length > 30)
{
width = 370;
}
QRCodeHelper.CreateTQRCode(TQRCode, TQRPath, ImageFormat.Jpeg, width, 50);
}
#endregion
for (int i = 0; i < (item.Number ?? 0); i++) {
for (int i = 0; i < (item.Number ?? 0); i++)
{
RObj.Add(new
{
materialModel.GoodsId,
......@@ -935,10 +962,12 @@ namespace Mall.Module.Property
item.InventoryNum = iList.Where(x => x.SuppliesId == item.Id).FirstOrDefault()?.Number ?? 0;
item.GoodsSpecificationList = new List<string>();
item.GoodsCategoryList = new List<string>();
if (!string.IsNullOrEmpty(item.SpecificationName)) {
if (!string.IsNullOrEmpty(item.SpecificationName))
{
item.GoodsSpecificationList = JsonConvert.DeserializeObject<List<string>>(item.SpecificationName);
}
if (!string.IsNullOrEmpty(item.GoodsCategoryName)) {
if (!string.IsNullOrEmpty(item.GoodsCategoryName))
{
item.GoodsCategoryList = JsonConvert.DeserializeObject<List<string>>(item.GoodsCategoryName);
}
}
......@@ -953,12 +982,13 @@ namespace Mall.Module.Property
/// <param name="eRPEmpId"></param>
/// <param name="eRPGroupId"></param>
/// <returns></returns>
public bool SetSyncGoodsToMaterial(int wareHouseId, List<int> categoryIdList, int eRPEmpId,int eRPBranchId, int eRPGroupId, int tenantId, int mallBaseId,int EmpId)
public bool SetSyncGoodsToMaterial(int wareHouseId, List<int> categoryIdList, int eRPEmpId, int eRPBranchId, int eRPGroupId, int tenantId, int mallBaseId, int EmpId)
{
try
{
string CategoryIds = "";
if (categoryIdList.Any()) {
if (categoryIdList.Any())
{
var cateids = string.Join(",", categoryIdList);
var cateList = product_CategoryRepository.GetList(new RB_Product_Category_Extend() { CategoryIds = cateids, TenantId = tenantId, MallBaseId = mallBaseId });
List<int> AllClist = new List<int>();
......@@ -1039,8 +1069,10 @@ namespace Mall.Module.Property
string GoodsCategoryIds = string.Join(",", QGCList.Select(x => x.CategoryId).Distinct());
string GoodsCategoryName = JsonConvert.SerializeObject(QGCList.Select(x => x.CategoryName).Distinct());
var spList = SpecificationPriceList.Where(x => x.GoodsId == item.Id).ToList();
if (spList.Any()) {
foreach (var qitem in spList) {
if (spList.Any())
{
foreach (var qitem in spList)
{
var mModel = mList.Where(x => x.GoodsId == item.Id && x.SpecificationKey == qitem.SpecificationSort).FirstOrDefault();
if (mModel == null)
{
......@@ -1076,7 +1108,8 @@ namespace Mall.Module.Property
TenantId = tenantId,
MallBaseId = mallBaseId
});
if (MaterialId > 0) {
if (MaterialId > 0)
{
//编码自动生成
string BMStr = MaterialId.ToString();
if (BMStr.Length < 5)
......@@ -1106,7 +1139,8 @@ namespace Mall.Module.Property
supplies_MaterialRepository.Update(files, wheres);
}
}
else {
else
{
//修改
Dictionary<string, object> files = new Dictionary<string, object>() {
{ nameof(RB_Supplies_Material_Extend.GoodsCategoryIds),GoodsCategoryIds},
......@@ -1130,7 +1164,8 @@ namespace Mall.Module.Property
}
}
}
else {
else
{
string SpecificationName = "[\"规格:" + item.DefaultSpecificationName + "\"]";
var mModel = mList.Where(x => x.GoodsId == item.Id && x.SpecificationKey == "").FirstOrDefault();
if (mModel == null)
......@@ -1244,6 +1279,16 @@ namespace Mall.Module.Property
}
}
/// <summary>
/// 获取列表
/// </summary>
/// <param name="dmodel"></param>
/// <returns></returns>
public List<RB_Supplies_Material_Extend> GetSuppliesMaterialList(RB_Supplies_Material_Extend dmodel)
{
return supplies_MaterialRepository.GetList(dmodel);
}
#endregion
}
}
......@@ -93,6 +93,10 @@ left join rb_property_category pc on sm.CategoryId=pc.Id
{
where += " and sm." + nameof(RB_Supplies_Material_Extend.CategoryId) + "=" + dmodel.CategoryId;
}
if (dmodel.GoodsId > 0)
{
where += " and sm." + nameof(RB_Supplies_Material_Extend.GoodsId) + "=" + dmodel.GoodsId;
}
if (!string.IsNullOrEmpty(dmodel.SuppliesIdStr)) {
where += " and sm." + nameof(RB_Supplies_Material_Extend.Id) + " in(" + dmodel.SuppliesIdStr + ")";
}
......
......@@ -24,6 +24,7 @@ namespace Mall.WebApi.Controllers.Property
private readonly WarehouseOutModule warehouseOutModule = new WarehouseOutModule();
private readonly OrderModule orderModule = new OrderModule();
private readonly PropertyModule propertyModule = new PropertyModule();
/// <summary>
/// 获取出库申请列表
......@@ -59,6 +60,24 @@ namespace Mall.WebApi.Controllers.Property
/// <summary>
/// 根据商品id获取物料规格信息
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetSuppliesMaterialList()
{
var parms = RequestParm;
// var materialList = propertyModule.GetSuppliesMaterialList(new RB_Supplies_Material_Extend { GoodsIds = goodsIds, RB_Group_Id = requestParm.ERPGroupId, TenantId = requestParm.TenantId, MallBaseId = requestParm.MallBaseId });
RB_Supplies_Material_Extend demodel = JsonConvert.DeserializeObject<RB_Supplies_Material_Extend>(parms.msg.ToString());
demodel.TenantId = parms.TenantId;
demodel.MallBaseId = parms.MallBaseId;
demodel.RB_Group_Id = parms.ERPGroupId;
var list = propertyModule.GetSuppliesMaterialList(demodel);
return ApiResult.Success("", list);
}
/// <summary>
/// 提交出库申请
/// </summary>
......@@ -89,6 +108,7 @@ namespace Mall.WebApi.Controllers.Property
return ApiResult.ParamIsNull("订单商品id未传递");
}
}
//根据订单商品id查询商品信息
var orderGoodsIds = string.Join(",", demodel.WarehouseOutGoodsList.Select(x => x.OrderGoodsId));
var orderGoodsList = orderModule.GetOrderGoodsList(new Model.Extend.Product.RB_Goods_OrderDetail_Extend { TenantId = requestParm.TenantId, MallBaseId = requestParm.MallBaseId, IdList = demodel.WarehouseOutGoodsList.Select(x => x.OrderGoodsId).ToList() });
......@@ -124,9 +144,33 @@ namespace Mall.WebApi.Controllers.Property
return ApiResult.Failed("订单号:" + msg + "的商品已申请出库,请勿重复申请");
}
//获取商品的出库规格物料信息
var goodsIds = string.Join(",", orderGoodsList.Select(x => x.GoodsId));
var materialList = propertyModule.GetSuppliesMaterialList(new RB_Supplies_Material_Extend { GoodsIds = goodsIds, RB_Group_Id = requestParm.ERPGroupId, TenantId = requestParm.TenantId, MallBaseId = requestParm.MallBaseId });
foreach (var item in demodel.WarehouseOutGoodsList)
{
if (item.NewNumber <= 0)
{
return ApiResult.Failed("出库商品数量不能小于0");
}
var orderGoodsDetailModel = orderGoodsList.Where(x => x.Id == item.OrderGoodsId).FirstOrDefault();
if (item.NewSpecificationSort != item.SpecificationSort)//修改了规格的判断新规格是否在物料中存在
{
var materialModel = materialList.Where(x => x.GoodsId == orderGoodsDetailModel.GoodsId && x.SpecificationKey == item.NewSpecificationSort).FirstOrDefault();
if (materialModel == null)
{
return ApiResult.Failed("订单号:" + item.OrderNo + "的商品:" + item.GoodsName + "不存在物料请先同步");
}
item.NewSpecificationSort = materialModel.SpecificationKey;
item.NewSpecification = materialModel.SpecificationName;
}
else//没有就直接等于订单的规格和数量
{
item.NewSpecificationSort = orderGoodsDetailModel.SpecificationSort;
item.NewNumber = orderGoodsDetailModel.Number.Value;
item.NewSpecification = orderGoodsDetailModel.Specification;
}
if (orderGoodsDetailModel != null)
{
item.TenantId = orderGoodsDetailModel.TenantId;
......@@ -188,6 +232,9 @@ namespace Mall.WebApi.Controllers.Property
demodel.TenantId = parms.TenantId;
demodel.MallBaseId = parms.MallBaseId;
var list = orderModule.GetNoOutOrderGoodsList(pagelist.pageIndex, pagelist.pageSize, out long count, demodel);
list.ForEach(x => x.NewSpecificationSort = x.SpecificationSort);
list.ForEach(x => x.NewSpecification = x.Specification);
list.ForEach(x => x.NewNumber = (x.Number ?? 0));
pagelist.count = Convert.ToInt32(count);
pagelist.pageData = list;
return ApiResult.Success("", pagelist);
......
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