Browse Source

所有接口修改事务问题

master
mahao 2 years ago
parent
commit
18a6f6d9d7
  1. 2776
      host/WmsWebApi.HttpApi.Host/Logs/logs20230227.txt
  2. 51
      src/WmsWebApi.Application/Boms/BomService.cs
  3. 43
      src/WmsWebApi.Application/PPlan/PPlanService.cs
  4. 61
      src/WmsWebApi.Application/ProductRecieve/ProductRecieveService.cs
  5. 44
      src/WmsWebApi.Application/Purchase/PurchaseService.cs
  6. 53
      src/WmsWebApi.Application/StockMove/StockMoveService.cs
  7. 52
      src/WmsWebApi.Application/TbParts/PartService.cs
  8. 2
      src/WmsWebApi.Application/ZlldcjLogs/ZlldcjLogAppService.cs
  9. 4
      src/WmsWebApi.Domain/StockMove/StockMoveManager.cs
  10. 22
      src/WmsWebApi.EntityFrameworkCore/EntityFrameworkCore/WmsWebApiDbContextModelCreatingExtensions.cs

2776
host/WmsWebApi.HttpApi.Host/Logs/logs20230227.txt

File diff suppressed because it is too large

51
src/WmsWebApi.Application/Boms/BomService.cs

@ -8,6 +8,7 @@ using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories; using Volo.Abp.Domain.Repositories;
using Volo.Abp.Uow; using Volo.Abp.Uow;
using WmsWebApi.EntityFrameworkCore; using WmsWebApi.EntityFrameworkCore;
using WmsWebApi.OtherZll;
using WmsWebApi.Wms; using WmsWebApi.Wms;
namespace WmsWebApi.Boms; namespace WmsWebApi.Boms;
@ -20,19 +21,22 @@ public class BomService : ApplicationService, IBomService
private readonly ITaPartRepository _taPartRepository; private readonly ITaPartRepository _taPartRepository;
private readonly IBomManager _bomDtoRepository; private readonly IBomManager _bomDtoRepository;
private readonly TmPgWmsUpdate _tmPgWmsUpdate; private readonly TmPgWmsUpdate _tmPgWmsUpdate;
private readonly Volo.Abp.Uow.IUnitOfWorkManager _unitOfWorkManager;
public BomService(ITmPgPartgroupRepository tmPgPartgroupRepository, public BomService(ITmPgPartgroupRepository tmPgPartgroupRepository,
ITaBomRepository taBomRepository, ITaBomRepository taBomRepository,
ITaPartRepository taPartRepository, ITaPartRepository taPartRepository,
IBomManager bomDtoRepository, IBomManager bomDtoRepository,
TmPgWmsUpdate tmPgWmsUpdate) TmPgWmsUpdate tmPgWmsUpdate
, Volo.Abp.Uow.IUnitOfWorkManager unitOfWorkManager)
{ {
_tmPgPartgroupRepository = tmPgPartgroupRepository; _tmPgPartgroupRepository = tmPgPartgroupRepository;
_taBomRepository = taBomRepository; _taBomRepository = taBomRepository;
_taPartRepository = taPartRepository; _taPartRepository = taPartRepository;
_bomDtoRepository = bomDtoRepository; _bomDtoRepository = bomDtoRepository;
_tmPgWmsUpdate = tmPgWmsUpdate; _tmPgWmsUpdate = tmPgWmsUpdate;
} _unitOfWorkManager = unitOfWorkManager;
}
[HttpPost("add")] [HttpPost("add")]
//[UnitOfWork(false)] //[UnitOfWork(false)]
@ -51,16 +55,20 @@ public class BomService : ApplicationService, IBomService
result.MESSAGE = "Json格式不正确,详细信息:" + ex.Message; result.MESSAGE = "Json格式不正确,详细信息:" + ex.Message;
return result; return result;
} }
if (string.IsNullOrEmpty(_bom.MATNR))
{
result.TYPE = 'E';
result.MESSAGE = "物料号不能为空";
return result;
}
try try
{ {
var _remark = DateTime.Now.ToString("yyyy-MM-dd") + "!" + Guid.NewGuid(); var _remark = DateTime.Now.ToString("yyyy-MM-dd") + "!" + Guid.NewGuid();
if (_bom.WERKS == "1000") if (_bom.WERKS == "1000")
{ {
var partgrouplist = _tmPgPartgroupRepository.Where(p => p.IsBom == true); var partgrouplist = _tmPgPartgroupRepository.Where(p => p.IsBom == true);
if (string.IsNullOrEmpty(_bom.MATNR))
throw new Exception($"物料号不能为空!");
var part = _taPartRepository.FirstOrDefault(p => p.PartCode == _bom.MATNR); var part = _taPartRepository.FirstOrDefault(p => p.PartCode == _bom.MATNR);
if (part == null) if (part == null)
{ {
@ -162,14 +170,21 @@ public class BomService : ApplicationService, IBomService
#endregion #endregion
} }
} }
} }
else else
{ {
bOtherWork = true; bOtherWork = true;
result.MESSAGE = "非长春工厂数据!"; result.MESSAGE = "非长春工厂数据!";
} }
//var pParts = boms.Select(p => p.MATNR).ToList().ToString(); }
catch (Exception ex)
{
result.TYPE = 'E';
result.MESSAGE = ex.GetBaseException().Message;
throw new Exception($"接口异常,请稍后重试:{ex.GetBaseException().Message}", ex);
}
finally
{
WmsWebApiBOMDTO bomdto = new WmsWebApiBOMDTO() WmsWebApiBOMDTO bomdto = new WmsWebApiBOMDTO()
{ {
MATNR = _bom.MATNR, MATNR = _bom.MATNR,
@ -196,24 +211,28 @@ public class BomService : ApplicationService, IBomService
{ {
bomdto.ITYPE = "非长春工厂数据!"; bomdto.ITYPE = "非长春工厂数据!";
} }
if(bPartGroup) if (bPartGroup)
{ {
bomdto.ITYPE = "没有对应物料组数据!"; bomdto.ITYPE = "没有对应物料组数据!";
} }
if(bDel) if (bDel)
{ {
bomdto.ITYPE += "删除!"; bomdto.ITYPE += "删除!";
} }
await _bomDtoRepository.AddAsync(bomdto); await _bomDtoRepository.AddAsync(bomdto);
} }
catch(Exception ex)
{
result.TYPE = 'E';
result.MESSAGE = ex.Message;
}
return result; return result;
} }
private async Task AddWmsWebApiBOMDtoNowUnitOfWorkAsync(WmsWebApiBOMDTO wmsWebApiBOMDTO)
{
if (wmsWebApiBOMDTO == null) { return; }
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: false))
{
await _bomDtoRepository.AddAsync(wmsWebApiBOMDTO);
await uow.SaveChangesAsync();
}
}
} }

43
src/WmsWebApi.Application/PPlan/PPlanService.cs

@ -7,6 +7,7 @@ using Newtonsoft.Json;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories; using Volo.Abp.Domain.Repositories;
using Volo.Abp.Uow; using Volo.Abp.Uow;
using WmsWebApi.Boms;
using WmsWebApi.EntityFrameworkCore; using WmsWebApi.EntityFrameworkCore;
using WmsWebApi.Wms; using WmsWebApi.Wms;
@ -21,13 +22,15 @@ public class PPlanService : ApplicationService, IPPlanService
private readonly ITaPartRepository _taPartRepository; private readonly ITaPartRepository _taPartRepository;
private readonly IPPlanManager _pplanDtoRepository; private readonly IPPlanManager _pplanDtoRepository;
private readonly TmPgWmsUpdate _tmPgWmsUpdate; private readonly TmPgWmsUpdate _tmPgWmsUpdate;
private readonly Volo.Abp.Uow.IUnitOfWorkManager _unitOfWorkManager;
public PPlanService(ITmPgPartgroupRepository tmPgPartgroupRepository, public PPlanService(ITmPgPartgroupRepository tmPgPartgroupRepository,
ITmPgPlanRepository tmPgPlanRepository, ITmPgPlanRepository tmPgPlanRepository,
ITbBillRepository tbBillRepository, ITbBillRepository tbBillRepository,
ITaPartRepository taPartRepository, ITaPartRepository taPartRepository,
IPPlanManager pplanDtoRepository, IPPlanManager pplanDtoRepository,
TmPgWmsUpdate tmPgWmsUpdate) TmPgWmsUpdate tmPgWmsUpdate
, Volo.Abp.Uow.IUnitOfWorkManager unitOfWorkManager)
{ {
_tmPgPartgroupRepository = tmPgPartgroupRepository; _tmPgPartgroupRepository = tmPgPartgroupRepository;
_tmPgPlanRepository = tmPgPlanRepository; _tmPgPlanRepository = tmPgPlanRepository;
@ -35,6 +38,7 @@ public class PPlanService : ApplicationService, IPPlanService
_taPartRepository = taPartRepository; _taPartRepository = taPartRepository;
_pplanDtoRepository = pplanDtoRepository; _pplanDtoRepository = pplanDtoRepository;
_tmPgWmsUpdate = tmPgWmsUpdate; _tmPgWmsUpdate = tmPgWmsUpdate;
_unitOfWorkManager = unitOfWorkManager;
} }
[HttpPost("add")] [HttpPost("add")]
@ -54,7 +58,7 @@ public class PPlanService : ApplicationService, IPPlanService
result.MESSAGE = "Json格式不正确,详细信息:" + ex.Message; result.MESSAGE = "Json格式不正确,详细信息:" + ex.Message;
return result; return result;
} }
try try
{ {
if (_planDto.WERKS != "1000") if (_planDto.WERKS != "1000")
@ -64,7 +68,7 @@ public class PPlanService : ApplicationService, IPPlanService
} }
else else
{ {
if (string.IsNullOrEmpty(_planDto.PEDTR) || string.IsNullOrEmpty(_planDto.SCHGRUP) || if (string.IsNullOrEmpty(_planDto.PEDTR) || string.IsNullOrEmpty(_planDto.SCHGRUP) ||
string.IsNullOrEmpty(_planDto.KAPTPROG) || string.IsNullOrEmpty(_planDto.MATNR)) string.IsNullOrEmpty(_planDto.KAPTPROG) || string.IsNullOrEmpty(_planDto.MATNR))
throw new Exception($"计划中 订单日期、分组、班次、物料号均不能为空!"); throw new Exception($"计划中 订单日期、分组、班次、物料号均不能为空!");
//var part = _taPartRepository.FirstOrDefault(p => p.PartCode == _planDto.MATNR); //var part = _taPartRepository.FirstOrDefault(p => p.PartCode == _planDto.MATNR);
@ -72,8 +76,6 @@ public class PPlanService : ApplicationService, IPPlanService
// throw new Exception($"没有找到物料号!{_planDto.MATNR}"); // throw new Exception($"没有找到物料号!{_planDto.MATNR}");
if (_planDto.MATNR.StartsWith("3")) if (_planDto.MATNR.StartsWith("3"))
{ {
// 查找是否有该计划 // 查找是否有该计划
var _billnum = _planDto.PEDTR + "-" + _planDto.SCHGRUP + "-" + _planDto.KAPTPROG; var _billnum = _planDto.PEDTR + "-" + _planDto.SCHGRUP + "-" + _planDto.KAPTPROG;
var bill = await _tbBillRepository.FirstOrDefaultAsync(p => p.BillNum == _billnum); var bill = await _tbBillRepository.FirstOrDefaultAsync(p => p.BillNum == _billnum);
@ -132,7 +134,16 @@ public class PPlanService : ApplicationService, IPPlanService
result.MESSAGE = $"非WinWMS使用的物料号!{_planDto.MATNR}"; result.MESSAGE = $"非WinWMS使用的物料号!{_planDto.MATNR}";
} }
} }
//var pParts = boms.Select(p => p.MATNR).ToList().ToString(); }
catch (Exception ex)
{
bErr = true;
result.TYPE = 'E';
result.MESSAGE = ex.GetBaseException().Message;
throw new Exception($"接口异常,请稍后重试:{ex.GetBaseException().Message}", ex);
}
finally
{
WmsWebApiPPLANDTO dto = new WmsWebApiPPLANDTO() WmsWebApiPPLANDTO dto = new WmsWebApiPPLANDTO()
{ {
PEDTR = _planDto.PEDTR, PEDTR = _planDto.PEDTR,
@ -154,7 +165,6 @@ public class PPlanService : ApplicationService, IPPlanService
JSON = content.ToString() JSON = content.ToString()
}; };
dto.SetId(GuidGenerator); dto.SetId(GuidGenerator);
if (bUpdate) if (bUpdate)
{ {
dto.ITYPE = "更新!"; dto.ITYPE = "更新!";
@ -163,19 +173,24 @@ public class PPlanService : ApplicationService, IPPlanService
{ {
dto.ITYPE = "非长春工厂数据!"; dto.ITYPE = "非长春工厂数据!";
} }
if(bErr) if (bErr)
{ {
dto.ITYPE = result.MESSAGE; dto.ITYPE = result.MESSAGE;
} }
await _pplanDtoRepository.AddAsync(dto); await AddWmsWebApiPPLANDTONowUnitOfWorkAsync(dto);
}
catch(Exception ex)
{
result.TYPE = 'E';
result.MESSAGE = ex.Message;
} }
return result; return result;
} }
private async Task AddWmsWebApiPPLANDTONowUnitOfWorkAsync(WmsWebApiPPLANDTO wmsWebApiPPLANDTO)
{
if (wmsWebApiPPLANDTO == null) { return; }
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: false))
{
await _pplanDtoRepository.AddAsync(wmsWebApiPPLANDTO);
await uow.SaveChangesAsync();
}
}
} }

61
src/WmsWebApi.Application/ProductRecieve/ProductRecieveService.cs

@ -10,6 +10,7 @@ using Volo.Abp.Domain.Repositories;
using Volo.Abp.Uow; using Volo.Abp.Uow;
using WmsWebApi.Domain; using WmsWebApi.Domain;
using WmsWebApi.EntityFrameworkCore; using WmsWebApi.EntityFrameworkCore;
using WmsWebApi.PPlan;
using WmsWebApi.ProductRecieve; using WmsWebApi.ProductRecieve;
using WmsWebApi.Wms; using WmsWebApi.Wms;
@ -27,6 +28,7 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService
private readonly ITaPartRepository _taPartRepository; private readonly ITaPartRepository _taPartRepository;
private readonly ITaStoreLocationRepository _taStoreLocationRepository; private readonly ITaStoreLocationRepository _taStoreLocationRepository;
private readonly IConfiguration _configuration; private readonly IConfiguration _configuration;
private readonly Volo.Abp.Uow.IUnitOfWorkManager _unitOfWorkManager;
public ProductRecieveService(ITsStockDetailRepository tsStockDetailRepository, public ProductRecieveService(ITsStockDetailRepository tsStockDetailRepository,
ITbProductReceiveRepository tbProductReceiveRepository, ITbProductReceiveRepository tbProductReceiveRepository,
@ -36,7 +38,8 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService
ITLTransactionRepository tlTransactionRepository, ITLTransactionRepository tlTransactionRepository,
IProductRecieveManager productRecieveManager, IProductRecieveManager productRecieveManager,
TmPgWmsUpdate tmPgWmsUpdate, TmPgWmsUpdate tmPgWmsUpdate,
IConfiguration configuration) IConfiguration configuration,
IUnitOfWorkManager unitOfWorkManager)
{ {
_tsStockDetailRepository = tsStockDetailRepository; _tsStockDetailRepository = tsStockDetailRepository;
_tbProductReceiveRepository = tbProductReceiveRepository; _tbProductReceiveRepository = tbProductReceiveRepository;
@ -47,26 +50,28 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService
_productRecieveManager = productRecieveManager; _productRecieveManager = productRecieveManager;
_tmPgWmsUpdate = tmPgWmsUpdate; _tmPgWmsUpdate = tmPgWmsUpdate;
_configuration = configuration; _configuration = configuration;
_unitOfWorkManager = unitOfWorkManager;
} }
[HttpPost("add")] [HttpPost("add")]
public async Task<ReturnResult> AddAsync([FromBody] object content) public async Task<ReturnResult> AddAsync([FromBody] object content)
{ {
var result = new ReturnResult(); var result = new ReturnResult();
result.MESSAGE = "";
PRDto _PRDto; PRDto _PRDto;
//bool bUpdate = false,bOtherWork = false, bDel = false,bNotFind = false, bPartGroup = false; //bool bUpdate = false,bOtherWork = false, bDel = false,bNotFind = false, bPartGroup = false;
bool bErr = false; bool bErr = false;
try try
{ {
_PRDto = JsonConvert.DeserializeObject<PRDto>(content.ToString()); _PRDto = JsonConvert.DeserializeObject<PRDto>(content.ToString());
} }
catch (Exception ex) catch (Exception ex)
{ {
result.TYPE = 'E'; result.TYPE = 'E';
result.MESSAGE = "Json格式不正确,详细信息:" + ex.Message; result.MESSAGE = "Json格式不正确,详细信息:" + ex.Message;
return result; return result;
} }
try try
{ {
List<TB_BILL> _billList = new List<TB_BILL>(); List<TB_BILL> _billList = new List<TB_BILL>();
@ -89,9 +94,16 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService
BillType = 201, BillType = 201,
SubBillType = 10100, SubBillType = 10100,
State = 2, State = 2,
Remark = "AGVProductRecieve", Remark = "AGVProductRecieve"
AccountDate = DateTime.ParseExact(_PRDto.AccountDate, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture)
}; };
try
{
tbBill.AccountDate = DateTime.ParseExact(_PRDto.AccountDate, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);
}
catch (Exception)
{
tbBill.AccountDate = DateTime.Parse(_PRDto.AccountDate);
}
_billList.Add(tbBill); _billList.Add(tbBill);
#endregion #endregion
@ -171,8 +183,8 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService
var stock = await _tsStockDetailRepository.FirstOrDefaultAsync(p => p.BarCode == _barcode var stock = await _tsStockDetailRepository.FirstOrDefaultAsync(p => p.BarCode == _barcode
&& p.LocCode == part.DefaultReceiveLocCode && p.LocCode == part.DefaultReceiveLocCode
&& p.State == EnumStockState.); && p.State == EnumStockState.);
if (stock == null) if (stock == null)
{ {
_stockList.Add(tsStock); _stockList.Add(tsStock);
@ -181,7 +193,7 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService
{ {
_stockUpdateList.Add(tsStock); _stockUpdateList.Add(tsStock);
} }
//插入tl_transaction //插入tl_transaction
var tlTrans = new TL_TRANSACTION var tlTrans = new TL_TRANSACTION
{ {
@ -214,9 +226,17 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService
if (_stockUpdateList != null && _stockUpdateList.Count() > 0) if (_stockUpdateList != null && _stockUpdateList.Count() > 0)
await _tmPgWmsUpdate.UpdateTsStock(_stockUpdateList); await _tmPgWmsUpdate.UpdateTsStock(_stockUpdateList);
await _tlTransactionRepository.AddAsync(_transList); await _tlTransactionRepository.AddAsync(_transList);
} }
}
//var pParts = boms.Select(p => p.MATNR).ToList().ToString(); catch (Exception ex)
{
bErr = true;
result.TYPE = 'E';
result.MESSAGE = ex.Message;
throw new Exception($"接口异常,请稍后重试:{ex.GetBaseException().Message}", ex);
}
finally
{
WmsWebApiProductRecieveDTO apiPRdto = new WmsWebApiProductRecieveDTO() WmsWebApiProductRecieveDTO apiPRdto = new WmsWebApiProductRecieveDTO()
{ {
AccountDate = _PRDto.AccountDate, AccountDate = _PRDto.AccountDate,
@ -234,15 +254,24 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService
result.TYPE = 'E'; result.TYPE = 'E';
apiPRdto.ITYPE = result.MESSAGE; apiPRdto.ITYPE = result.MESSAGE;
} }
await _productRecieveManager.AddAsync(apiPRdto); await AddWmsWebApiProductRecieveDTONowUnitOfWorkAsync(apiPRdto);
} }
catch(Exception ex)
if (bErr == false)
{ {
result.TYPE = 'E'; result.MESSAGE = "接收成功!";
result.MESSAGE = ex.Message;
} }
return result; return result;
} }
private async Task AddWmsWebApiProductRecieveDTONowUnitOfWorkAsync(WmsWebApiProductRecieveDTO wmsWebApiProductRecieveDTO)
{
if (wmsWebApiProductRecieveDTO == null) { return; }
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: false))
{
await _productRecieveManager.AddAsync(wmsWebApiProductRecieveDTO);
await uow.SaveChangesAsync();
}
}
} }

44
src/WmsWebApi.Application/Purchase/PurchaseService.cs

@ -7,6 +7,7 @@ using Newtonsoft.Json;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories; using Volo.Abp.Domain.Repositories;
using Volo.Abp.Uow; using Volo.Abp.Uow;
using WmsWebApi.Domain;
using WmsWebApi.EntityFrameworkCore; using WmsWebApi.EntityFrameworkCore;
using WmsWebApi.Purchase; using WmsWebApi.Purchase;
using WmsWebApi.Wms; using WmsWebApi.Wms;
@ -24,6 +25,7 @@ public class PurchaseService : ApplicationService, IPPlanService
private readonly IPurchaseManager _purchaseManager; private readonly IPurchaseManager _purchaseManager;
private readonly ITLTransactionRepository _tlTransactionRepository; private readonly ITLTransactionRepository _tlTransactionRepository;
private readonly TmPgWmsUpdate _tmPgWmsUpdate; private readonly TmPgWmsUpdate _tmPgWmsUpdate;
private readonly Volo.Abp.Uow.IUnitOfWorkManager _unitOfWorkManager;
public PurchaseService(ITsStockDetailRepository tsStockDetailRepository, public PurchaseService(ITsStockDetailRepository tsStockDetailRepository,
ITbProductReceiveRepository tbProductReceiveRepository, ITbProductReceiveRepository tbProductReceiveRepository,
@ -32,7 +34,8 @@ public class PurchaseService : ApplicationService, IPPlanService
ITaStoreLocationRepository taStoreLocationRepository, ITaStoreLocationRepository taStoreLocationRepository,
IPurchaseManager purchaseManager, IPurchaseManager purchaseManager,
ITLTransactionRepository tlTransactionRepository, ITLTransactionRepository tlTransactionRepository,
TmPgWmsUpdate tmPgWmsUpdate) TmPgWmsUpdate tmPgWmsUpdate,
IUnitOfWorkManager unitOfWorkManager)
{ {
_tsStockDetailRepository = tsStockDetailRepository; _tsStockDetailRepository = tsStockDetailRepository;
_tbProductReceiveRepository = tbProductReceiveRepository; _tbProductReceiveRepository = tbProductReceiveRepository;
@ -42,6 +45,7 @@ public class PurchaseService : ApplicationService, IPPlanService
_purchaseManager = purchaseManager; _purchaseManager = purchaseManager;
_tlTransactionRepository = tlTransactionRepository; _tlTransactionRepository = tlTransactionRepository;
_tmPgWmsUpdate = tmPgWmsUpdate; _tmPgWmsUpdate = tmPgWmsUpdate;
_unitOfWorkManager = unitOfWorkManager;
} }
[HttpPost("add")] [HttpPost("add")]
@ -55,7 +59,7 @@ public class PurchaseService : ApplicationService, IPPlanService
try try
{ {
_purchaseDto = JsonConvert.DeserializeObject<PurchaseDto>(content.ToString()); _purchaseDto = JsonConvert.DeserializeObject<PurchaseDto>(content.ToString());
} }
catch (Exception ex) catch (Exception ex)
{ {
result.TYPE = 'E'; result.TYPE = 'E';
@ -319,18 +323,27 @@ public class PurchaseService : ApplicationService, IPPlanService
bUpdate = true; bUpdate = true;
result.MESSAGE = $"err:单据 {_purchaseDto.MBLNR} 已存在"; result.MESSAGE = $"err:单据 {_purchaseDto.MBLNR} 已存在";
} }
} }
//var pParts = boms.Select(p => p.MATNR).ToList().ToString(); }
catch(Exception ex)
{
bErr = true;
result.TYPE = 'E';
result.MESSAGE = ex.GetBaseException().Message;
throw new Exception($"接口异常,请稍后重试:{ex.GetBaseException().Message}", ex);
}
finally
{
WmsWebApiPURCHASEDTO dto = new WmsWebApiPURCHASEDTO() WmsWebApiPURCHASEDTO dto = new WmsWebApiPURCHASEDTO()
{ {
MBLNR = _purchaseDto.MBLNR, MBLNR = _purchaseDto.MBLNR,
MJAHR = _purchaseDto.MJAHR, MJAHR = _purchaseDto.MJAHR,
BUDAT = _purchaseDto.BUDAT, BUDAT = _purchaseDto.BUDAT,
JSON = content.ToString() JSON = content.ToString()
}; };
dto.SetId(GuidGenerator); dto.SetId(GuidGenerator);
if (bUpdate) if (bUpdate)
{ {
dto.ITYPE = $"err:单据 {_purchaseDto.MBLNR} 已存在!"; dto.ITYPE = $"err:单据 {_purchaseDto.MBLNR} 已存在!";
@ -339,19 +352,24 @@ public class PurchaseService : ApplicationService, IPPlanService
{ {
dto.ITYPE = "非长春工厂数据!"; dto.ITYPE = "非长春工厂数据!";
} }
if(bErr || bTypeErr) if (bErr || bTypeErr)
{ {
dto.ITYPE = result.MESSAGE; dto.ITYPE = result.MESSAGE;
} }
await _purchaseManager.AddAsync(dto); await AddWmsWebApiPURCHASEDTONowUnitOfWorkAsync(dto);
}
catch(Exception ex)
{
result.TYPE = 'E';
result.MESSAGE = ex.Message;
} }
return result; return result;
} }
private async Task AddWmsWebApiPURCHASEDTONowUnitOfWorkAsync(WmsWebApiPURCHASEDTO wmsWebApiPURCHASEDTO)
{
if (wmsWebApiPURCHASEDTO == null) { return; }
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: false))
{
await _purchaseManager.AddAsync(wmsWebApiPURCHASEDTO);
await uow.SaveChangesAsync();
}
}
} }

53
src/WmsWebApi.Application/StockMove/StockMoveService.cs

@ -27,6 +27,7 @@ public class StockMoveService : ApplicationService, IStockMoveService
private readonly ITaPartRepository _taPartRepository; private readonly ITaPartRepository _taPartRepository;
private readonly ITaStoreLocationRepository _taStoreLocationRepository; private readonly ITaStoreLocationRepository _taStoreLocationRepository;
private readonly IConfiguration _configuration; private readonly IConfiguration _configuration;
private readonly Volo.Abp.Uow.IUnitOfWorkManager _unitOfWorkManager;
public StockMoveService(ITsStockDetailRepository tsStockDetailRepository, public StockMoveService(ITsStockDetailRepository tsStockDetailRepository,
ITbStockMoveRepository tbStockMoveRepository, ITbStockMoveRepository tbStockMoveRepository,
@ -36,7 +37,8 @@ public class StockMoveService : ApplicationService, IStockMoveService
ITLTransactionRepository tlTransactionRepository, ITLTransactionRepository tlTransactionRepository,
IStockMoveManager stockMoveManager, IStockMoveManager stockMoveManager,
TmPgWmsUpdate tmPgWmsUpdate, TmPgWmsUpdate tmPgWmsUpdate,
IConfiguration configuration) IConfiguration configuration,
IUnitOfWorkManager unitOfWorkManager)
{ {
_tsStockDetailRepository = tsStockDetailRepository; _tsStockDetailRepository = tsStockDetailRepository;
_tbStockMoveRepository = tbStockMoveRepository; _tbStockMoveRepository = tbStockMoveRepository;
@ -47,6 +49,7 @@ public class StockMoveService : ApplicationService, IStockMoveService
_stockMoveManager = stockMoveManager; _stockMoveManager = stockMoveManager;
_tmPgWmsUpdate = tmPgWmsUpdate; _tmPgWmsUpdate = tmPgWmsUpdate;
_configuration = configuration; _configuration = configuration;
_unitOfWorkManager = unitOfWorkManager;
} }
[HttpPost("add")] [HttpPost("add")]
@ -66,7 +69,7 @@ public class StockMoveService : ApplicationService, IStockMoveService
result.MESSAGE = "Json格式不正确,详细信息:" + ex.Message; result.MESSAGE = "Json格式不正确,详细信息:" + ex.Message;
return result; return result;
} }
try try
{ {
List<TB_BILL> _billList = new List<TB_BILL>(); List<TB_BILL> _billList = new List<TB_BILL>();
@ -89,9 +92,16 @@ public class StockMoveService : ApplicationService, IStockMoveService
BillType = 302, BillType = 302,
SubBillType = 30201, SubBillType = 30201,
State = 2, State = 2,
Remark = "AGVMove", Remark = "AGVMove"
AccountDate = DateTime.ParseExact(_SSDto.AccountDate, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture)
}; };
try
{
tbBill.AccountDate = DateTime.ParseExact(_SSDto.AccountDate, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);
}
catch (Exception)
{
tbBill.AccountDate = DateTime.Parse(_SSDto.AccountDate);
}
_billList.Add(tbBill); _billList.Add(tbBill);
#endregion #endregion
var agvloc = _configuration.GetConnectionString("AgvInLoc"); var agvloc = _configuration.GetConnectionString("AgvInLoc");
@ -140,12 +150,12 @@ public class StockMoveService : ApplicationService, IStockMoveService
ToState = EnumStockState. ToState = EnumStockState.
}; };
if(_SSDto.BillType == "902")//从WMS移库到AGV if (_SSDto.BillType == "902")//从WMS移库到AGV
{ {
tbStockMove.FromLocCode = wmsloc; tbStockMove.FromLocCode = wmsloc;
tbStockMove.ToLocCode = agvloc; tbStockMove.ToLocCode = agvloc;
} }
else if(_SSDto.BillType == "903") else if (_SSDto.BillType == "903")
{ {
tbStockMove.FromLocCode = agvloc; tbStockMove.FromLocCode = agvloc;
tbStockMove.ToLocCode = wmsloc; tbStockMove.ToLocCode = wmsloc;
@ -328,7 +338,7 @@ public class StockMoveService : ApplicationService, IStockMoveService
_transList.Add(tlTrans1); _transList.Add(tlTrans1);
_transList.Add(tlTrans2); _transList.Add(tlTrans2);
} }
#endregion #endregion
} }
@ -347,8 +357,16 @@ public class StockMoveService : ApplicationService, IStockMoveService
await _tmPgWmsUpdate.DeleteTsStock(_stockDelList); await _tmPgWmsUpdate.DeleteTsStock(_stockDelList);
await _tlTransactionRepository.AddAsync(_transList); await _tlTransactionRepository.AddAsync(_transList);
} }
}
//var pParts = boms.Select(p => p.MATNR).ToList().ToString(); catch (Exception ex)
{
bErr = true;
result.TYPE = 'E';
result.MESSAGE = ex.Message;
throw new Exception($"接口异常,请稍后重试:{ex.GetBaseException().Message}", ex);
}
finally
{
WmsWebApiStockMoveDTO apiSSdto = new WmsWebApiStockMoveDTO() WmsWebApiStockMoveDTO apiSSdto = new WmsWebApiStockMoveDTO()
{ {
AccountDate = _SSDto.AccountDate, AccountDate = _SSDto.AccountDate,
@ -366,15 +384,20 @@ public class StockMoveService : ApplicationService, IStockMoveService
result.TYPE = 'E'; result.TYPE = 'E';
apiSSdto.ITYPE = result.MESSAGE; apiSSdto.ITYPE = result.MESSAGE;
} }
await _stockMoveManager.AddAsync(apiSSdto); await AddWmsWebApiStockMoveDTONowUnitOfWorkAsync(apiSSdto);
}
catch(Exception ex)
{
result.TYPE = 'E';
result.MESSAGE = ex.Message;
} }
return result; return result;
} }
private async Task AddWmsWebApiStockMoveDTONowUnitOfWorkAsync(WmsWebApiStockMoveDTO wmsWebApiStockMoveDTO)
{
if (wmsWebApiStockMoveDTO == null) { return; }
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: false))
{
await _stockMoveManager.AddAsync(wmsWebApiStockMoveDTO);
await uow.SaveChangesAsync();
}
}
} }

52
src/WmsWebApi.Application/TbParts/PartService.cs

@ -7,6 +7,7 @@ using Newtonsoft.Json;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories; using Volo.Abp.Domain.Repositories;
using Volo.Abp.Uow; using Volo.Abp.Uow;
using WmsWebApi.Domain;
using WmsWebApi.EntityFrameworkCore; using WmsWebApi.EntityFrameworkCore;
using WmsWebApi.Wms; using WmsWebApi.Wms;
@ -20,17 +21,20 @@ public class PartService : ApplicationService, IPartService
private readonly ITaCustPartRepository _taCustPartRepository; private readonly ITaCustPartRepository _taCustPartRepository;
private readonly IPartManager _partDtoRepository; private readonly IPartManager _partDtoRepository;
private readonly TmPgWmsUpdate _tmPgWmsUpdate; private readonly TmPgWmsUpdate _tmPgWmsUpdate;
private readonly Volo.Abp.Uow.IUnitOfWorkManager _unitOfWorkManager;
public PartService(ITmPgPartgroupRepository tmPgPartgroupRepository, ITaPartRepository taPartRepository, public PartService(ITmPgPartgroupRepository tmPgPartgroupRepository, ITaPartRepository taPartRepository,
ITaCustPartRepository taCustPartRepository, ITaCustPartRepository taCustPartRepository,
IPartManager partDtoRepository, IPartManager partDtoRepository,
TmPgWmsUpdate tmPgWmsUpdate) TmPgWmsUpdate tmPgWmsUpdate,
IUnitOfWorkManager unitOfWorkManager)
{ {
_tmPgPartgroupRepository = tmPgPartgroupRepository; _tmPgPartgroupRepository = tmPgPartgroupRepository;
_taPartRepository = taPartRepository; _taPartRepository = taPartRepository;
_taCustPartRepository = taCustPartRepository; _taCustPartRepository = taCustPartRepository;
_partDtoRepository = partDtoRepository; _partDtoRepository = partDtoRepository;
_tmPgWmsUpdate = tmPgWmsUpdate; _tmPgWmsUpdate = tmPgWmsUpdate;
_unitOfWorkManager = unitOfWorkManager;
} }
[HttpPost("add")] [HttpPost("add")]
@ -50,7 +54,13 @@ public class PartService : ApplicationService, IPartService
result.MESSAGE = "Json格式不正确,详细信息:" + ex.Message; result.MESSAGE = "Json格式不正确,详细信息:" + ex.Message;
return result; return result;
} }
if (string.IsNullOrEmpty(_part.MATNR))
{
result.TYPE = 'E';
result.MESSAGE = "物料号不能为空!";
return result;
}
try try
{ {
//判断是否是长春工厂 //判断是否是长春工厂
@ -61,9 +71,6 @@ public class PartService : ApplicationService, IPartService
} }
else else
{ {
if (string.IsNullOrEmpty(_part.MATNR))
throw new Exception($"物料号不能为空!");
if (_part.MATNR.Trim().StartsWith("1") || _part.MATNR.Trim().StartsWith("2") || _part.MATNR.Trim().StartsWith("3") || _part.MATNR.Trim().StartsWith("7")) if (_part.MATNR.Trim().StartsWith("1") || _part.MATNR.Trim().StartsWith("2") || _part.MATNR.Trim().StartsWith("3") || _part.MATNR.Trim().StartsWith("7"))
{ {
#region part信息更新 #region part信息更新
@ -96,7 +103,7 @@ public class PartService : ApplicationService, IPartService
//[DisplayName("状态")] //[DisplayName("状态")]
part.State = "A"; part.State = "A";
if(_part.MMSTA.Trim().ToUpper() == "Z2") if (_part.MMSTA.Trim().ToUpper() == "Z2")
part.State = "H"; part.State = "H";
//[DisplayName("管理类型")] --判断物料组属性 //[DisplayName("管理类型")] --判断物料组属性
@ -230,10 +237,19 @@ public class PartService : ApplicationService, IPartService
else else
{ {
bErr = true; bErr = true;
result.MESSAGE = $"非WinWMS使用的物料号!{_part.MATNR.Trim()}"; result.MESSAGE = $"非WinWMS使用的物料号!{_part.MATNR.Trim()}";
} }
} }
}
catch (Exception ex)
{
bErr = true;
result.TYPE = 'E';
result.MESSAGE = ex.GetBaseException().Message;
throw new Exception($"接口异常,请稍后重试:{ex.GetBaseException().Message}", ex);
}
finally
{
WmsWebApiPARTDTO partdto = new WmsWebApiPARTDTO() WmsWebApiPARTDTO partdto = new WmsWebApiPARTDTO()
{ {
MATNR = _part.MATNR, MATNR = _part.MATNR,
@ -259,19 +275,25 @@ public class PartService : ApplicationService, IPartService
{ {
partdto.ITYPE = "非长春工厂数据"; partdto.ITYPE = "非长春工厂数据";
} }
if(bErr) if (bErr)
{ {
partdto.ITYPE = result.MESSAGE; partdto.ITYPE = result.MESSAGE;
} }
await _partDtoRepository.AddAsync(partdto); await AddWmsWebApiPARTDTONowUnitOfWorkAsync(partdto);
}
catch(Exception ex)
{
result.TYPE = 'E';
result.MESSAGE = ex.Message;
} }
return result; return result;
} }
private async Task AddWmsWebApiPARTDTONowUnitOfWorkAsync(WmsWebApiPARTDTO wmsWebApiPARTDTO)
{
if (wmsWebApiPARTDTO == null) { return; }
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: false))
{
await _partDtoRepository.AddAsync(wmsWebApiPARTDTO);
await uow.SaveChangesAsync();
}
}
} }

2
src/WmsWebApi.Application/ZlldcjLogs/ZlldcjLogAppService.cs

@ -62,6 +62,7 @@ public class ZlldcjLogAppService : ApplicationService, IZlldcjLogAppService
{ {
result.TYPE = 'E'; result.TYPE = 'E';
result.MESSAGE = ex.Message; result.MESSAGE = ex.Message;
throw new Exception(ex.Message, ex);
} }
return result; return result;
@ -354,6 +355,7 @@ public class ZlldcjLogAppService : ApplicationService, IZlldcjLogAppService
{ {
result.TYPE = 'E'; result.TYPE = 'E';
result.MESSAGE = ex.Message; result.MESSAGE = ex.Message;
throw new Exception($"接口异常,请稍后重试:{ex.GetBaseException().Message}", ex);
} }
return result; return result;
} }

4
src/WmsWebApi.Domain/StockMove/StockMoveManager.cs

@ -11,11 +11,11 @@ using WmsWebApi.Wms;
namespace WmsWebApi.Domain; namespace WmsWebApi.Domain;
public class PartManager : DomainService, IStockMoveManager public class StockMoveManager : DomainService, IStockMoveManager
{ {
private readonly IRepository<WmsWebApiStockMoveDTO, Guid> _partDtoRepository; private readonly IRepository<WmsWebApiStockMoveDTO, Guid> _partDtoRepository;
public PartManager( public StockMoveManager(
IRepository<WmsWebApiStockMoveDTO, Guid> partDtoRepository IRepository<WmsWebApiStockMoveDTO, Guid> partDtoRepository
) )
{ {

22
src/WmsWebApi.EntityFrameworkCore/EntityFrameworkCore/WmsWebApiDbContextModelCreatingExtensions.cs

@ -3,6 +3,7 @@ using Microsoft.EntityFrameworkCore;
using Volo.Abp; using Volo.Abp;
using Volo.Abp.EntityFrameworkCore.Modeling; using Volo.Abp.EntityFrameworkCore.Modeling;
using WmsWebApi.Boms; using WmsWebApi.Boms;
using WmsWebApi.Domain;
using WmsWebApi.OtherZll; using WmsWebApi.OtherZll;
using WmsWebApi.Parts; using WmsWebApi.Parts;
using WmsWebApi.PPlan; using WmsWebApi.PPlan;
@ -82,6 +83,9 @@ namespace WmsWebApi.EntityFrameworkCore
//其他领料 //其他领料
ConfigureOtherDllDto(builder); ConfigureOtherDllDto(builder);
ConfigureProductRecieve(builder);
ConfigureWmsWebApiStockMove(builder);
} }
private static void ConfigureTbOrder(ModelBuilder builder) private static void ConfigureTbOrder(ModelBuilder builder)
@ -641,5 +645,23 @@ namespace WmsWebApi.EntityFrameworkCore
b.Property(q => q.ITYPE); b.Property(q => q.ITYPE);
}); });
} }
private static void ConfigureProductRecieve(ModelBuilder builder)
{
builder.Entity<WmsWebApiProductRecieveDTO>(b =>
{
b.ToTable("WmsWebApiProductRecieveDTO", WmsWebApiDbProperties.DbSchema);
b.ConfigureByConvention();
});
}
private static void ConfigureWmsWebApiStockMove(ModelBuilder builder)
{
builder.Entity<WmsWebApiStockMoveDTO>(b =>
{
b.ToTable("WmsWebApiStockMoveDTO", WmsWebApiDbProperties.DbSchema);
b.ConfigureByConvention();
});
}
} }
} }
Loading…
Cancel
Save