222
This commit is contained in:
parent
7d3a84e9b0
commit
da57cd5e5c
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using MyCode.Project.Domain.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@ -16,6 +17,24 @@ namespace MyCode.Project.Domain.Message.Response.InvoiceOrder
|
||||
/// <summary>
|
||||
/// 对应的条码数组
|
||||
/// </summary>
|
||||
public List<string> BarCodeList { get; set; }
|
||||
public List<TiaoMaList> BarCodeList { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class TiaoMaList: TiaoMa
|
||||
{
|
||||
/// <summary>
|
||||
/// Desc:供应商ID
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string SupplierId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:供应商名称
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string SupplierName { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ using MyCode.Project.Domain.Message.Response.PurchaseOrder;
|
||||
using MyCode.Project.Domain.Model;
|
||||
using MyCode.Project.Domain.Repositories;
|
||||
using MyCode.Project.Infrastructure.Common;
|
||||
using MyCode.Project.Infrastructure.Extensions;
|
||||
using MyCode.Project.Infrastructure.Search;
|
||||
using MyCode.Project.Repositories.Common;
|
||||
using System;
|
||||
@ -98,6 +99,8 @@ namespace MyCode.Project.Repositories
|
||||
}
|
||||
t.TiaoMa = $@"{t.MaterialCode}*{t.Qty.Value.ToString("F2")}*{t.FBillNo}*{t.FSupplierLot}";
|
||||
fid = t.FormId;
|
||||
if (t.CuseQty == 0)
|
||||
t.CuseQty = t.Qty.SafeValue();
|
||||
});
|
||||
|
||||
return list;
|
||||
|
@ -81,6 +81,9 @@ namespace MyCode.Project.Services.Implementation
|
||||
var orderItems = _invoiceOrderItemRepository.Queryable().Where(t => t.Id == act.Id).ToList();
|
||||
Guid pid = orderItems.Select(t => t.InvoiceOrderId.Value).FirstOrDefault();
|
||||
var orderHead = _invoiceOrderRepository.Queryable().Where(t => t.SupplierId == loginInfo.SupplierId && t.Id == pid).First();
|
||||
var ids = orderItems.Select(t => t.Id).ToList();
|
||||
var OrderItemIds= orderItems.Select(t => t.PurchaseOrderItemId).ToList();
|
||||
|
||||
if (orderHead == null)
|
||||
{
|
||||
throw new BaseException("订单数据不正确");
|
||||
@ -90,9 +93,22 @@ namespace MyCode.Project.Services.Implementation
|
||||
try
|
||||
{
|
||||
var result = _kingDeeService.Delete("PUR_ReceiveBill", billDelete);
|
||||
LogHelper.Info(result);
|
||||
//LogHelper.Info(result);
|
||||
_invoiceOrderItemRepository.Delete(t => t.Id == act.Id);
|
||||
_invoiceOrderRepository.Delete(t=>t.Id== orderHead.Id);
|
||||
|
||||
var purchaseItem = _purchaseOrderItemRepository.Queryable().Where(t => OrderItemIds.Contains(t.Id)).ToList();
|
||||
purchaseItem.ForEach(t =>
|
||||
{
|
||||
var temp = orderItems.FirstOrDefault(h => h.PurchaseOrderItemId == t.Id);
|
||||
if (temp != null)
|
||||
{
|
||||
t.FRemainReceiveQty = t.FRemainReceiveQty + temp.Qty;
|
||||
t.FReceiveQty = t.FReceiveQty - temp.Qty;
|
||||
}
|
||||
});
|
||||
_purchaseOrderItemRepository.Update(purchaseItem);
|
||||
_tiaoMaRepository.Delete(t => ids.Contains(t.InvoceOrderItemId.Value));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -234,24 +250,36 @@ namespace MyCode.Project.Services.Implementation
|
||||
{
|
||||
throw new BaseException("每包数量必须大于0");
|
||||
}
|
||||
_tiaoMaRepository.Delete(t => t.InvoceOrderItemId == act.Id);
|
||||
//_tiaoMaRepository.Delete(t => t.InvoceOrderItemId == act.Id);
|
||||
var orderItem = _invoiceOrderItemRepository.Queryable().Where(t => t.Id == act.Id).First();
|
||||
if (orderItem == null)
|
||||
{
|
||||
throw new BaseException("不正确的ID值");
|
||||
}
|
||||
List<TiaoMa> addList = new List<TiaoMa>();
|
||||
var order = _invoiceOrderRepository.Queryable().Where(t => t.Id == orderItem.InvoiceOrderId).First();
|
||||
if (order == null)
|
||||
{
|
||||
throw new BaseException("不正确的ID数据");
|
||||
}
|
||||
List<TiaoMaList> addList = new List<TiaoMaList>();
|
||||
if (orderItem.CuseQty == act.CuseQty)
|
||||
{
|
||||
var barcodeList = _tiaoMaRepository.Queryable().Where(t => t.InvoceOrderItemId == orderItem.Id).ToList();
|
||||
addList = barcodeList;
|
||||
addList =AutoMapperHelper.AutoMappToList<TiaoMaList,TiaoMa>( barcodeList);
|
||||
addList.ForEach(t =>
|
||||
{
|
||||
t.SupplierId = order.SupplierId;
|
||||
t.SupplierName = order.SupplierName;
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
if(addList.Count==0)
|
||||
{
|
||||
_tiaoMaRepository.Delete(t=>t.InvoceOrderItemId== orderItem.Id);
|
||||
orderItem.CuseQty = act.CuseQty;
|
||||
_invoiceOrderItemRepository.Update(orderItem);
|
||||
var order = _invoiceOrderRepository.Queryable().Where(t => t.Id == orderItem.InvoiceOrderId).First();
|
||||
|
||||
|
||||
decimal zongQty = orderItem.Qty.SafeValue();
|
||||
int yu = (int)Math.Ceiling(zongQty % act.CuseQty);
|
||||
@ -263,31 +291,38 @@ namespace MyCode.Project.Services.Implementation
|
||||
{
|
||||
|
||||
string FBarCode = $@"{orderItem.MaterialCode}*{act.CuseQty.ToString("F2")}*{orderItem.FBillNo}*{orderItem.FSupplierLot}";
|
||||
TiaoMa tiaoMa = new TiaoMa();
|
||||
tiaoMa = AutoMapperHelper.AutoMappToSingle<TiaoMa, InvoiceOrderItem>(orderItem);
|
||||
TiaoMaList tiaoMa = new TiaoMaList();
|
||||
tiaoMa = AutoMapperHelper.AutoMappToSingle<TiaoMaList, InvoiceOrderItem>(orderItem);
|
||||
tiaoMa.Id = Guid.NewGuid();
|
||||
tiaoMa.FBarCode = FBarCode;
|
||||
tiaoMa.Qty = act.CuseQty;
|
||||
tiaoMa.SortNum = i + 1;
|
||||
tiaoMa.PurchaseBillNo = orderItem.FBillNo;
|
||||
tiaoMa.FBillNo = order.FBillNo;
|
||||
tiaoMa.SupplierId = order.SupplierId;
|
||||
tiaoMa.SupplierName = order.SupplierName;
|
||||
addList.Add(tiaoMa);
|
||||
}
|
||||
if (yu > 0)
|
||||
{
|
||||
string FBarCode = $@"{orderItem.MaterialCode}*{decimal.Parse(yu.ToString()).ToString("F2")}*{orderItem.FBillNo}*{orderItem.FSupplierLot}";
|
||||
TiaoMa tiaoMa = new TiaoMa();
|
||||
tiaoMa = AutoMapperHelper.AutoMappToSingle<TiaoMa, InvoiceOrderItem>(orderItem);
|
||||
TiaoMaList tiaoMa = new TiaoMaList();
|
||||
tiaoMa = AutoMapperHelper.AutoMappToSingle<TiaoMaList, InvoiceOrderItem>(orderItem);
|
||||
tiaoMa.Id = Guid.NewGuid();
|
||||
tiaoMa.FBarCode = FBarCode;
|
||||
tiaoMa.Qty = yu;
|
||||
tiaoMa.SortNum = baoShu + 1;
|
||||
tiaoMa.PurchaseBillNo = orderItem.FBillNo;
|
||||
tiaoMa.FBillNo = order.FBillNo;
|
||||
tiaoMa.SupplierId = order.SupplierId;
|
||||
tiaoMa.SupplierName = order.SupplierName;
|
||||
addList.Add(tiaoMa);
|
||||
}
|
||||
|
||||
_tiaoMaRepository.Add(addList);
|
||||
if (addList.Count > 0)
|
||||
{
|
||||
var addtemp = AutoMapperHelper.AutoMappToList<TiaoMa, TiaoMaList>(addList);
|
||||
_tiaoMaRepository.Add(addtemp);
|
||||
}
|
||||
|
||||
List<AddTiaoMa> addTiaoMas = new List<AddTiaoMa>();
|
||||
addTiaoMas = addList.Select(t => new AddTiaoMa
|
||||
@ -304,7 +339,7 @@ namespace MyCode.Project.Services.Implementation
|
||||
}
|
||||
TiaoMaResp result = new TiaoMaResp();
|
||||
result.Id = orderItem.Id;
|
||||
result.BarCodeList = addList.Select(t => t.FBarCode).ToList();
|
||||
result.BarCodeList = addList;
|
||||
return result;
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user