BIP异常信息接口:采购订单删除,修改接口
This commit is contained in:
@@ -2025,10 +2025,10 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
PrdMo mo = await _db.Queryable<PrdMo>().SingleAsync(x => x.id == prdMoTask.mo_id);
|
||||
|
||||
#region 注塑生产任务提报时,如果起始库位( 当前设备的下料点)已经存在业务类型为配送申请,并且实际开始配送时间为空的任务执行,则不能提报,并提示
|
||||
#region 注塑生产任务提报时,如果起始库位( 当前设备的下料点)已经存在业务类型为配送申请,并且实际开始配送时间为空,并且任务状态不是取消的任务执行,则不能提报,并提示
|
||||
if (mo.mo_type == DictConst.PrdMoTypeZS)
|
||||
{
|
||||
var wmsDistaskHs = _db.Queryable<WmsDistaskH>().Where(r => r.startlocation_id == equip.downmat_location_id && r.biz_type == WmsWareHouseConst.BIZTYPE_WMSDELIVERY_ID && !r.act_start_date.HasValue);
|
||||
var wmsDistaskHs = _db.Queryable<WmsDistaskH>().Where(r => r.startlocation_id == equip.downmat_location_id && r.biz_type == WmsWareHouseConst.BIZTYPE_WMSDELIVERY_ID && !r.act_start_date.HasValue && r.status!=WmsWareHouseConst.TASK_BILL_STATUS_CANCEL_ID);
|
||||
if (wmsDistaskHs != null && wmsDistaskHs.Count() > 0)
|
||||
throw Oops.Bah("请等待AGV配送完成后提报");
|
||||
}
|
||||
|
||||
@@ -101,4 +101,50 @@ namespace Tnb.WarehouseMgr.Entities.Dto.ErpInputs
|
||||
/// </summary>
|
||||
public string? production_unit { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除采购订单
|
||||
/// </summary>
|
||||
public class PurchaseOrderDeleteInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 主表pk
|
||||
/// </summary>
|
||||
public string? erp_pk { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 修改采购订单
|
||||
/// </summary>
|
||||
public class PurchaseOrderUpdateInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 主表pk
|
||||
/// </summary>
|
||||
public string? erp_pk { get; set; }
|
||||
|
||||
public List<PurchaseOrderUpdateDetail> details { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改采购订单子表
|
||||
/// </summary>
|
||||
public class PurchaseOrderUpdateDetail
|
||||
{
|
||||
/// <summary>
|
||||
/// 行号
|
||||
/// </summary>
|
||||
public string erp_line_pk { get;set; }
|
||||
/// <summary>
|
||||
/// 净价
|
||||
/// </summary>
|
||||
public string net_price { get; set; }
|
||||
/// <summary>
|
||||
/// 采购数量
|
||||
/// </summary>
|
||||
public decimal? purchase_quantity { get; set; }
|
||||
/// <summary>
|
||||
/// 实收数量
|
||||
/// </summary>
|
||||
public decimal? actual_quantity { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -546,6 +546,128 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 删除采购订单
|
||||
/// </summary>
|
||||
[HttpPost, NonUnify, AllowAnonymous]
|
||||
public async Task<Entities.Dto.Outputs.Result> DeletePurchaseOrder(PurchaseOrderDeleteInput input)
|
||||
{
|
||||
LoggerErp2Mes.LogInformation($"【PurchaseOrderDeleteInput】ERP传入数据:{JsonConvert.SerializeObject(input)}");
|
||||
var db = _repository.AsSugarClient();
|
||||
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(input.erp_pk))
|
||||
{
|
||||
_LoggerErp2Mes.LogWarning($"【PurchaseOrderDeleteInput】主表主键不能为空!");
|
||||
throw new AppFriendlyException($@"主表主键不能为空!", 500);
|
||||
}
|
||||
|
||||
await db.Ado.BeginTranAsync();
|
||||
|
||||
// 判断采购订单是否存在
|
||||
WmsPurchaseOrderH wmsPurchaseOrderRep = await db.Queryable<WmsPurchaseOrderH>().Where(r => r.erp_pk == input.erp_pk).FirstAsync();
|
||||
if (wmsPurchaseOrderRep != null)
|
||||
{
|
||||
// 判断收货单是否已经生成
|
||||
WmsPurchaseH wmsPurchaseH = await db.Queryable<WmsPurchaseH>().Where(r => r.source_id == wmsPurchaseOrderRep.id).FirstAsync();
|
||||
if (wmsPurchaseH != null)
|
||||
{
|
||||
_LoggerErp2Mes.LogWarning($@"【PurchaseOrderDeleteInput】wms已创建收货单{wmsPurchaseH.bill_code}!");
|
||||
throw new AppFriendlyException($@"wms已创建收货单{wmsPurchaseH.bill_code}!", 500);
|
||||
}
|
||||
else // 删除数据重新插入
|
||||
{
|
||||
await db.Deleteable<WmsPurchaseOrderH>().Where(r => r.id == wmsPurchaseOrderRep.id).ExecuteCommandAsync();
|
||||
await db.Deleteable<WmsPurchaseOrderD>().Where(r => r.fk_wms_purchase_order_id == wmsPurchaseOrderRep.id).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
await db.Ado.CommitTranAsync();
|
||||
|
||||
return await ToApiResult(HttpStatusCode.OK, "成功");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LoggerErp2Mes.LogError($"【PurchaseOrderDeleteInput】{ex.Message}");
|
||||
LoggerErp2Mes.LogError($"【PurchaseOrderDeleteInput】{ex.StackTrace}");
|
||||
await db.Ado.RollbackTranAsync();
|
||||
return await ToApiResult(HttpStatusCode.InternalServerError, ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 修改采购订单
|
||||
/// </summary>
|
||||
[HttpPost, NonUnify, AllowAnonymous]
|
||||
public async Task<Entities.Dto.Outputs.Result> UpdatePurchaseOrder(PurchaseOrderUpdateInput input)
|
||||
{
|
||||
LoggerErp2Mes.LogInformation($"【PurchaseOrderUpdateInput】ERP传入数据:{JsonConvert.SerializeObject(input)}");
|
||||
var db = _repository.AsSugarClient();
|
||||
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(input.erp_pk))
|
||||
{
|
||||
_LoggerErp2Mes.LogWarning($"【PurchaseOrderUpdateInput】主表主键不能为空!");
|
||||
throw new AppFriendlyException($@"主表主键不能为空!", 500);
|
||||
}
|
||||
|
||||
await db.Ado.BeginTranAsync();
|
||||
|
||||
// 判断采购订单是否存在
|
||||
WmsPurchaseOrderH wmsPurchaseOrderH = await db.Queryable<WmsPurchaseOrderH>().Where(r => r.erp_pk == input.erp_pk).FirstAsync();
|
||||
|
||||
if(wmsPurchaseOrderH == null)
|
||||
{
|
||||
_LoggerErp2Mes.LogWarning($"【PurchaseOrderUpdateInput】未找到采购订单,erp_pk:{input.erp_pk}");
|
||||
throw new AppFriendlyException($@"未找到采购订单,erp_pk:{input.erp_pk}!", 500);
|
||||
}
|
||||
|
||||
if(input.details!=null && input.details.Count > 0)
|
||||
{
|
||||
foreach(var item in input.details)
|
||||
{
|
||||
WmsPurchaseOrderD wmsPurchaseOrderD = await db.Queryable<WmsPurchaseOrderD>().Where(r => r.fk_wms_purchase_order_id == wmsPurchaseOrderH.id && r.erp_line_pk == item.erp_line_pk).FirstAsync();
|
||||
if(wmsPurchaseOrderD==null)
|
||||
{
|
||||
_LoggerErp2Mes.LogWarning($"【PurchaseOrderUpdateInput】未找到采购订单明细数据,erp_pk:{input.erp_pk},erp_line_pk:{item.erp_line_pk}");
|
||||
throw new AppFriendlyException($@"未找到采购订单明细数据,erp_pk:{input.erp_pk},erp_line_pk{item.erp_line_pk}!", 500);
|
||||
}
|
||||
else
|
||||
{
|
||||
await db.Updateable<WmsPurchaseOrderD>()
|
||||
.SetColumns(r => r.net_price == item.net_price)
|
||||
.SetColumns(r => r.purchase_quantity == item.purchase_quantity)
|
||||
.SetColumns(r => r.actual_quantity == item.actual_quantity)
|
||||
.Where(r => r.id == wmsPurchaseOrderD.id).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
await db.Ado.CommitTranAsync();
|
||||
|
||||
return await ToApiResult(HttpStatusCode.OK, "成功");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LoggerErp2Mes.LogError($"【PurchaseOrderUpdateInput】{ex.Message}");
|
||||
LoggerErp2Mes.LogError($"【PurchaseOrderUpdateInput】{ex.StackTrace}");
|
||||
await db.Ado.RollbackTranAsync();
|
||||
return await ToApiResult(HttpStatusCode.InternalServerError, ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 委外订单
|
||||
/// </summary>
|
||||
|
||||
@@ -147,7 +147,8 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
DictionaryDataEntity tranType = await _db.Queryable<DictionaryDataEntity>().Where(x=>x.DictionaryTypeId=="25043925951909" && x.EnCode== wmsOutsourceH.transaction_type).FirstAsync();
|
||||
string tranTypeId = tranType?.Id ?? "";
|
||||
string supplierId = wmsPurchaseOrderH?.supplier_id ?? "";
|
||||
//string supplierId = wmsPurchaseOrderH?.supplier_id ?? "";
|
||||
string supplierId = wmsOutsourceH?.supplier_id ?? "";
|
||||
List<string> tableIds = new List<string>();
|
||||
// tableIds.Add(_userManager.UserId);
|
||||
// tableIds.Add(wmsPurchaseH.create_id);
|
||||
@@ -305,7 +306,7 @@ namespace Tnb.WarehouseMgr
|
||||
["csourcetype"] = item.source_type ?? null, //来源单据类型
|
||||
["csourcetranstype"] = erpExtendFields.Find(x => x.table_id == tranTypeId)?.transaction_type_id ?? null, //来源单据交易类型
|
||||
["vsourcebillcode"] = wmsOutsourceH?.outsource_order ?? null, //来源单据号
|
||||
["vsourcerowno"] = null, //来源单据行号
|
||||
["vsourcerowno"] = (allInstockDetails.FindIndex(x => x.id == item.id) + 1) * 10, //来源单据行号
|
||||
["nnum"] = item.qty, //实收主数量
|
||||
|
||||
["nshouldnum"] = item.pr_qty, //应收主数量
|
||||
|
||||
Reference in New Issue
Block a user