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.Uow;
using WmsWebApi.EntityFrameworkCore;
using WmsWebApi.OtherZll;
using WmsWebApi.Wms;
namespace WmsWebApi.Boms;
@ -20,19 +21,22 @@ public class BomService : ApplicationService, IBomService
private readonly ITaPartRepository _taPartRepository;
private readonly IBomManager _bomDtoRepository;
private readonly TmPgWmsUpdate _tmPgWmsUpdate;
private readonly Volo.Abp.Uow.IUnitOfWorkManager _unitOfWorkManager;
public BomService(ITmPgPartgroupRepository tmPgPartgroupRepository,
ITaBomRepository taBomRepository,
ITaPartRepository taPartRepository,
IBomManager bomDtoRepository,
TmPgWmsUpdate tmPgWmsUpdate)
TmPgWmsUpdate tmPgWmsUpdate
, Volo.Abp.Uow.IUnitOfWorkManager unitOfWorkManager)
{
_tmPgPartgroupRepository = tmPgPartgroupRepository;
_taBomRepository = taBomRepository;
_taPartRepository = taPartRepository;
_bomDtoRepository = bomDtoRepository;
_tmPgWmsUpdate = tmPgWmsUpdate;
}
_unitOfWorkManager = unitOfWorkManager;
}
[HttpPost("add")]
//[UnitOfWork(false)]
@ -51,16 +55,20 @@ public class BomService : ApplicationService, IBomService
result.MESSAGE = "Json格式不正确,详细信息:" + ex.Message;
return result;
}
if (string.IsNullOrEmpty(_bom.MATNR))
{
result.TYPE = 'E';
result.MESSAGE = "物料号不能为空";
return result;
}
try
{
var _remark = DateTime.Now.ToString("yyyy-MM-dd") + "!" + Guid.NewGuid();
if (_bom.WERKS == "1000")
{
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);
if (part == null)
{
@ -162,14 +170,21 @@ public class BomService : ApplicationService, IBomService
#endregion
}
}
}
else
{
bOtherWork = true;
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()
{
MATNR = _bom.MATNR,
@ -196,24 +211,28 @@ public class BomService : ApplicationService, IBomService
{
bomdto.ITYPE = "非长春工厂数据!";
}
if(bPartGroup)
if (bPartGroup)
{
bomdto.ITYPE = "没有对应物料组数据!";
}
if(bDel)
if (bDel)
{
bomdto.ITYPE += "删除!";
}
await _bomDtoRepository.AddAsync(bomdto);
}
catch(Exception ex)
{
result.TYPE = 'E';
result.MESSAGE = ex.Message;
}
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.Domain.Repositories;
using Volo.Abp.Uow;
using WmsWebApi.Boms;
using WmsWebApi.EntityFrameworkCore;
using WmsWebApi.Wms;
@ -21,13 +22,15 @@ public class PPlanService : ApplicationService, IPPlanService
private readonly ITaPartRepository _taPartRepository;
private readonly IPPlanManager _pplanDtoRepository;
private readonly TmPgWmsUpdate _tmPgWmsUpdate;
private readonly Volo.Abp.Uow.IUnitOfWorkManager _unitOfWorkManager;
public PPlanService(ITmPgPartgroupRepository tmPgPartgroupRepository,
ITmPgPlanRepository tmPgPlanRepository,
ITbBillRepository tbBillRepository,
ITaPartRepository taPartRepository,
IPPlanManager pplanDtoRepository,
TmPgWmsUpdate tmPgWmsUpdate)
TmPgWmsUpdate tmPgWmsUpdate
, Volo.Abp.Uow.IUnitOfWorkManager unitOfWorkManager)
{
_tmPgPartgroupRepository = tmPgPartgroupRepository;
_tmPgPlanRepository = tmPgPlanRepository;
@ -35,6 +38,7 @@ public class PPlanService : ApplicationService, IPPlanService
_taPartRepository = taPartRepository;
_pplanDtoRepository = pplanDtoRepository;
_tmPgWmsUpdate = tmPgWmsUpdate;
_unitOfWorkManager = unitOfWorkManager;
}
[HttpPost("add")]
@ -54,7 +58,7 @@ public class PPlanService : ApplicationService, IPPlanService
result.MESSAGE = "Json格式不正确,详细信息:" + ex.Message;
return result;
}
try
{
if (_planDto.WERKS != "1000")
@ -64,7 +68,7 @@ public class PPlanService : ApplicationService, IPPlanService
}
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))
throw new Exception($"计划中 订单日期、分组、班次、物料号均不能为空!");
//var part = _taPartRepository.FirstOrDefault(p => p.PartCode == _planDto.MATNR);
@ -72,8 +76,6 @@ public class PPlanService : ApplicationService, IPPlanService
// throw new Exception($"没有找到物料号!{_planDto.MATNR}");
if (_planDto.MATNR.StartsWith("3"))
{
// 查找是否有该计划
var _billnum = _planDto.PEDTR + "-" + _planDto.SCHGRUP + "-" + _planDto.KAPTPROG;
var bill = await _tbBillRepository.FirstOrDefaultAsync(p => p.BillNum == _billnum);
@ -132,7 +134,16 @@ public class PPlanService : ApplicationService, IPPlanService
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()
{
PEDTR = _planDto.PEDTR,
@ -154,7 +165,6 @@ public class PPlanService : ApplicationService, IPPlanService
JSON = content.ToString()
};
dto.SetId(GuidGenerator);
if (bUpdate)
{
dto.ITYPE = "更新!";
@ -163,19 +173,24 @@ public class PPlanService : ApplicationService, IPPlanService
{
dto.ITYPE = "非长春工厂数据!";
}
if(bErr)
if (bErr)
{
dto.ITYPE = result.MESSAGE;
}
await _pplanDtoRepository.AddAsync(dto);
}
catch(Exception ex)
{
result.TYPE = 'E';
result.MESSAGE = ex.Message;
await AddWmsWebApiPPLANDTONowUnitOfWorkAsync(dto);
}
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 WmsWebApi.Domain;
using WmsWebApi.EntityFrameworkCore;
using WmsWebApi.PPlan;
using WmsWebApi.ProductRecieve;
using WmsWebApi.Wms;
@ -27,6 +28,7 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService
private readonly ITaPartRepository _taPartRepository;
private readonly ITaStoreLocationRepository _taStoreLocationRepository;
private readonly IConfiguration _configuration;
private readonly Volo.Abp.Uow.IUnitOfWorkManager _unitOfWorkManager;
public ProductRecieveService(ITsStockDetailRepository tsStockDetailRepository,
ITbProductReceiveRepository tbProductReceiveRepository,
@ -36,7 +38,8 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService
ITLTransactionRepository tlTransactionRepository,
IProductRecieveManager productRecieveManager,
TmPgWmsUpdate tmPgWmsUpdate,
IConfiguration configuration)
IConfiguration configuration,
IUnitOfWorkManager unitOfWorkManager)
{
_tsStockDetailRepository = tsStockDetailRepository;
_tbProductReceiveRepository = tbProductReceiveRepository;
@ -47,26 +50,28 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService
_productRecieveManager = productRecieveManager;
_tmPgWmsUpdate = tmPgWmsUpdate;
_configuration = configuration;
_unitOfWorkManager = unitOfWorkManager;
}
[HttpPost("add")]
public async Task<ReturnResult> AddAsync([FromBody] object content)
{
var result = new ReturnResult();
result.MESSAGE = "";
PRDto _PRDto;
//bool bUpdate = false,bOtherWork = false, bDel = false,bNotFind = false, bPartGroup = false;
bool bErr = false;
try
{
_PRDto = JsonConvert.DeserializeObject<PRDto>(content.ToString());
}
}
catch (Exception ex)
{
result.TYPE = 'E';
result.MESSAGE = "Json格式不正确,详细信息:" + ex.Message;
return result;
}
try
{
List<TB_BILL> _billList = new List<TB_BILL>();
@ -89,9 +94,16 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService
BillType = 201,
SubBillType = 10100,
State = 2,
Remark = "AGVProductRecieve",
AccountDate = DateTime.ParseExact(_PRDto.AccountDate, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture)
Remark = "AGVProductRecieve"
};
try
{
tbBill.AccountDate = DateTime.ParseExact(_PRDto.AccountDate, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);
}
catch (Exception)
{
tbBill.AccountDate = DateTime.Parse(_PRDto.AccountDate);
}
_billList.Add(tbBill);
#endregion
@ -171,8 +183,8 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService
var stock = await _tsStockDetailRepository.FirstOrDefaultAsync(p => p.BarCode == _barcode
&& p.LocCode == part.DefaultReceiveLocCode
&& p.State == EnumStockState.);
&& p.State == EnumStockState.);
if (stock == null)
{
_stockList.Add(tsStock);
@ -181,7 +193,7 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService
{
_stockUpdateList.Add(tsStock);
}
//插入tl_transaction
var tlTrans = new TL_TRANSACTION
{
@ -214,9 +226,17 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService
if (_stockUpdateList != null && _stockUpdateList.Count() > 0)
await _tmPgWmsUpdate.UpdateTsStock(_stockUpdateList);
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()
{
AccountDate = _PRDto.AccountDate,
@ -234,15 +254,24 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService
result.TYPE = 'E';
apiPRdto.ITYPE = result.MESSAGE;
}
await _productRecieveManager.AddAsync(apiPRdto);
await AddWmsWebApiProductRecieveDTONowUnitOfWorkAsync(apiPRdto);
}
catch(Exception ex)
if (bErr == false)
{
result.TYPE = 'E';
result.MESSAGE = ex.Message;
result.MESSAGE = "接收成功!";
}
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.Domain.Repositories;
using Volo.Abp.Uow;
using WmsWebApi.Domain;
using WmsWebApi.EntityFrameworkCore;
using WmsWebApi.Purchase;
using WmsWebApi.Wms;
@ -24,6 +25,7 @@ public class PurchaseService : ApplicationService, IPPlanService
private readonly IPurchaseManager _purchaseManager;
private readonly ITLTransactionRepository _tlTransactionRepository;
private readonly TmPgWmsUpdate _tmPgWmsUpdate;
private readonly Volo.Abp.Uow.IUnitOfWorkManager _unitOfWorkManager;
public PurchaseService(ITsStockDetailRepository tsStockDetailRepository,
ITbProductReceiveRepository tbProductReceiveRepository,
@ -32,7 +34,8 @@ public class PurchaseService : ApplicationService, IPPlanService
ITaStoreLocationRepository taStoreLocationRepository,
IPurchaseManager purchaseManager,
ITLTransactionRepository tlTransactionRepository,
TmPgWmsUpdate tmPgWmsUpdate)
TmPgWmsUpdate tmPgWmsUpdate,
IUnitOfWorkManager unitOfWorkManager)
{
_tsStockDetailRepository = tsStockDetailRepository;
_tbProductReceiveRepository = tbProductReceiveRepository;
@ -42,6 +45,7 @@ public class PurchaseService : ApplicationService, IPPlanService
_purchaseManager = purchaseManager;
_tlTransactionRepository = tlTransactionRepository;
_tmPgWmsUpdate = tmPgWmsUpdate;
_unitOfWorkManager = unitOfWorkManager;
}
[HttpPost("add")]
@ -55,7 +59,7 @@ public class PurchaseService : ApplicationService, IPPlanService
try
{
_purchaseDto = JsonConvert.DeserializeObject<PurchaseDto>(content.ToString());
}
}
catch (Exception ex)
{
result.TYPE = 'E';
@ -319,18 +323,27 @@ public class PurchaseService : ApplicationService, IPPlanService
bUpdate = true;
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()
{
MBLNR = _purchaseDto.MBLNR,
MJAHR = _purchaseDto.MJAHR,
BUDAT = _purchaseDto.BUDAT,
JSON = content.ToString()
};
dto.SetId(GuidGenerator);
if (bUpdate)
{
dto.ITYPE = $"err:单据 {_purchaseDto.MBLNR} 已存在!";
@ -339,19 +352,24 @@ public class PurchaseService : ApplicationService, IPPlanService
{
dto.ITYPE = "非长春工厂数据!";
}
if(bErr || bTypeErr)
if (bErr || bTypeErr)
{
dto.ITYPE = result.MESSAGE;
}
await _purchaseManager.AddAsync(dto);
}
catch(Exception ex)
{
result.TYPE = 'E';
result.MESSAGE = ex.Message;
await AddWmsWebApiPURCHASEDTONowUnitOfWorkAsync(dto);
}
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 ITaStoreLocationRepository _taStoreLocationRepository;
private readonly IConfiguration _configuration;
private readonly Volo.Abp.Uow.IUnitOfWorkManager _unitOfWorkManager;
public StockMoveService(ITsStockDetailRepository tsStockDetailRepository,
ITbStockMoveRepository tbStockMoveRepository,
@ -36,7 +37,8 @@ public class StockMoveService : ApplicationService, IStockMoveService
ITLTransactionRepository tlTransactionRepository,
IStockMoveManager stockMoveManager,
TmPgWmsUpdate tmPgWmsUpdate,
IConfiguration configuration)
IConfiguration configuration,
IUnitOfWorkManager unitOfWorkManager)
{
_tsStockDetailRepository = tsStockDetailRepository;
_tbStockMoveRepository = tbStockMoveRepository;
@ -47,6 +49,7 @@ public class StockMoveService : ApplicationService, IStockMoveService
_stockMoveManager = stockMoveManager;
_tmPgWmsUpdate = tmPgWmsUpdate;
_configuration = configuration;
_unitOfWorkManager = unitOfWorkManager;
}
[HttpPost("add")]
@ -66,7 +69,7 @@ public class StockMoveService : ApplicationService, IStockMoveService
result.MESSAGE = "Json格式不正确,详细信息:" + ex.Message;
return result;
}
try
{
List<TB_BILL> _billList = new List<TB_BILL>();
@ -89,9 +92,16 @@ public class StockMoveService : ApplicationService, IStockMoveService
BillType = 302,
SubBillType = 30201,
State = 2,
Remark = "AGVMove",
AccountDate = DateTime.ParseExact(_SSDto.AccountDate, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture)
Remark = "AGVMove"
};
try
{
tbBill.AccountDate = DateTime.ParseExact(_SSDto.AccountDate, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);
}
catch (Exception)
{
tbBill.AccountDate = DateTime.Parse(_SSDto.AccountDate);
}
_billList.Add(tbBill);
#endregion
var agvloc = _configuration.GetConnectionString("AgvInLoc");
@ -140,12 +150,12 @@ public class StockMoveService : ApplicationService, IStockMoveService
ToState = EnumStockState.
};
if(_SSDto.BillType == "902")//从WMS移库到AGV
if (_SSDto.BillType == "902")//从WMS移库到AGV
{
tbStockMove.FromLocCode = wmsloc;
tbStockMove.ToLocCode = agvloc;
}
else if(_SSDto.BillType == "903")
else if (_SSDto.BillType == "903")
{
tbStockMove.FromLocCode = agvloc;
tbStockMove.ToLocCode = wmsloc;
@ -328,7 +338,7 @@ public class StockMoveService : ApplicationService, IStockMoveService
_transList.Add(tlTrans1);
_transList.Add(tlTrans2);
}
#endregion
}
@ -347,8 +357,16 @@ public class StockMoveService : ApplicationService, IStockMoveService
await _tmPgWmsUpdate.DeleteTsStock(_stockDelList);
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()
{
AccountDate = _SSDto.AccountDate,
@ -366,15 +384,20 @@ public class StockMoveService : ApplicationService, IStockMoveService
result.TYPE = 'E';
apiSSdto.ITYPE = result.MESSAGE;
}
await _stockMoveManager.AddAsync(apiSSdto);
}
catch(Exception ex)
{
result.TYPE = 'E';
result.MESSAGE = ex.Message;
await AddWmsWebApiStockMoveDTONowUnitOfWorkAsync(apiSSdto);
}
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.Domain.Repositories;
using Volo.Abp.Uow;
using WmsWebApi.Domain;
using WmsWebApi.EntityFrameworkCore;
using WmsWebApi.Wms;
@ -20,17 +21,20 @@ public class PartService : ApplicationService, IPartService
private readonly ITaCustPartRepository _taCustPartRepository;
private readonly IPartManager _partDtoRepository;
private readonly TmPgWmsUpdate _tmPgWmsUpdate;
private readonly Volo.Abp.Uow.IUnitOfWorkManager _unitOfWorkManager;
public PartService(ITmPgPartgroupRepository tmPgPartgroupRepository, ITaPartRepository taPartRepository,
ITaCustPartRepository taCustPartRepository,
IPartManager partDtoRepository,
TmPgWmsUpdate tmPgWmsUpdate)
TmPgWmsUpdate tmPgWmsUpdate,
IUnitOfWorkManager unitOfWorkManager)
{
_tmPgPartgroupRepository = tmPgPartgroupRepository;
_taPartRepository = taPartRepository;
_taCustPartRepository = taCustPartRepository;
_partDtoRepository = partDtoRepository;
_tmPgWmsUpdate = tmPgWmsUpdate;
_unitOfWorkManager = unitOfWorkManager;
}
[HttpPost("add")]
@ -50,7 +54,13 @@ public class PartService : ApplicationService, IPartService
result.MESSAGE = "Json格式不正确,详细信息:" + ex.Message;
return result;
}
if (string.IsNullOrEmpty(_part.MATNR))
{
result.TYPE = 'E';
result.MESSAGE = "物料号不能为空!";
return result;
}
try
{
//判断是否是长春工厂
@ -61,9 +71,6 @@ public class PartService : ApplicationService, IPartService
}
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"))
{
#region part信息更新
@ -96,7 +103,7 @@ public class PartService : ApplicationService, IPartService
//[DisplayName("状态")]
part.State = "A";
if(_part.MMSTA.Trim().ToUpper() == "Z2")
if (_part.MMSTA.Trim().ToUpper() == "Z2")
part.State = "H";
//[DisplayName("管理类型")] --判断物料组属性
@ -230,10 +237,19 @@ public class PartService : ApplicationService, IPartService
else
{
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()
{
MATNR = _part.MATNR,
@ -259,19 +275,25 @@ public class PartService : ApplicationService, IPartService
{
partdto.ITYPE = "非长春工厂数据";
}
if(bErr)
if (bErr)
{
partdto.ITYPE = result.MESSAGE;
}
await _partDtoRepository.AddAsync(partdto);
}
catch(Exception ex)
{
result.TYPE = 'E';
result.MESSAGE = ex.Message;
await AddWmsWebApiPARTDTONowUnitOfWorkAsync(partdto);
}
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.MESSAGE = ex.Message;
throw new Exception(ex.Message, ex);
}
return result;
@ -354,6 +355,7 @@ public class ZlldcjLogAppService : ApplicationService, IZlldcjLogAppService
{
result.TYPE = 'E';
result.MESSAGE = ex.Message;
throw new Exception($"接口异常,请稍后重试:{ex.GetBaseException().Message}", ex);
}
return result;
}

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

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

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

@ -3,6 +3,7 @@ using Microsoft.EntityFrameworkCore;
using Volo.Abp;
using Volo.Abp.EntityFrameworkCore.Modeling;
using WmsWebApi.Boms;
using WmsWebApi.Domain;
using WmsWebApi.OtherZll;
using WmsWebApi.Parts;
using WmsWebApi.PPlan;
@ -82,6 +83,9 @@ namespace WmsWebApi.EntityFrameworkCore
//其他领料
ConfigureOtherDllDto(builder);
ConfigureProductRecieve(builder);
ConfigureWmsWebApiStockMove(builder);
}
private static void ConfigureTbOrder(ModelBuilder builder)
@ -641,5 +645,23 @@ namespace WmsWebApi.EntityFrameworkCore
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