/*
|
*所有关于Bill_group_stock类的业务代码应在此处编写
|
*可使用repository.调用常用方法,获取EF/Dapper等信息
|
*如果需要事务请使用repository.DbContextBeginTransaction
|
*也可使用DBServerProvider.手动获取数据库相关信息
|
*用户信息、权限、角色等使用UserContext.Current操作
|
*Bill_group_stockService对增、删、改查、导入、导出、审核业务代码扩展参照ServiceFunFilter
|
*/
|
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.AspNetCore.Http;
|
using WIDESEA_Services.IRepositories;
|
using WIDESEA_Core.Utilities;
|
using WIDESEA_Services.Repositories;
|
using WIDESEA_Entity.DomainModels;
|
using System;
|
|
namespace WIDESEA_Services.Services
|
{
|
public partial class VV_StockLocationService
|
{
|
public WebResponseContent DelStock(DeleteStockRequest request)
|
{
|
WebResponseContent content = new WebResponseContent();
|
try
|
{
|
content = bill_group_stockRepository.Instance.DbContextBeginTransaction(() =>
|
{
|
bill_group_stock stock = bill_group_stockRepository.Instance.FindFirst(x => x.stock_id == request.stock_id);
|
var location = base_ware_locationRepository.Instance.FindFirst(f => f.id == stock.location_id);
|
var task = new dt_agvtask();
|
if (location == null) { task = dt_agvtaskRepository.Instance.FindFirst(f => f.agv_materbarcode == stock.BarCode); }
|
else
|
{
|
task = dt_agvtaskRepository.Instance.FindFirst(f => f.agv_materbarcode == stock.BarCode && (f.agv_fromaddress == location.upper_code || f.agv_fromaddress == location.down_code || f.agv_toaddress == location.upper_code || f.agv_toaddress == location.down_code));
|
}
|
if (task != null) { return WebResponseContent.Instance.Error($"该条码已经有任务,任务号是:{task.agv_tasknum}"); }
|
if (stock == null)
|
{
|
return WebResponseContent.Instance.Error($"未找到该数据,stock_id:{request.stock_id}");
|
}
|
else
|
{
|
WebResponseContent responseContent = new WebResponseContent();
|
try
|
{
|
bill_group_stockRepository.Instance.Delete(stock, true);
|
}
|
catch (Exception ex)
|
{
|
throw new Exception($"{ex.Message}");
|
}
|
}
|
content.Code = "0";
|
return WebResponseContent.Instance.OK("删除成功");
|
});
|
}
|
catch (Exception ex)
|
{
|
content = WebResponseContent.Instance.Error($"库存删除失败,错误消息:{ex.Message}");
|
}
|
return content;
|
}
|
}
|
}
|