| | |
| | | using System; |
| | | using Autofac.Core; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_Common; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.BaseRepository; |
| | | using WIDESEAWCS_Core.BaseServices; |
| | | using WIDESEAWCS_Core.Helper; |
| | | using WIDESEAWCS_IBasicInfoService; |
| | | using WIDESEAWCS_Model.Models; |
| | | |
| | | namespace WIDESEAWCS_BasicInfoService |
| | | { |
| | | public class BoxingService : ServiceBase<Dt_Boxing, IRepository<Dt_Boxing>>, IBoxingService |
| | | { |
| | | public BoxingService(IRepository<Dt_Boxing> BaseDal) : base(BaseDal) |
| | | private readonly IProcessInfoService _processInfoService; |
| | | // ç´æ¥æ³¨å
¥ BoxingDetail çä»å¨ï¼æ¿ä»£æ³¨å
¥ BoxingDetailService |
| | | private readonly IRepository<Dt_BoxingDetail> _boxingDetailRepo; |
| | | |
| | | public BoxingService( |
| | | IRepository<Dt_Boxing> BaseDal, |
| | | IProcessInfoService processInfoService, |
| | | // æ°å¢æ³¨å
¥ BoxingDetail ä»å¨ |
| | | IRepository<Dt_BoxingDetail> boxingDetailRepo |
| | | ) : base(BaseDal) |
| | | { |
| | | _processInfoService = processInfoService; |
| | | _boxingDetailRepo = boxingDetailRepo; // èµå¼ |
| | | } |
| | | |
| | | public IRepository<Dt_Boxing> Repository => BaseDal; |
| | | |
| | | //å é¤å½åæç |
| | | public WebResponseContent DeleteCurrentTray() |
| | | { |
| | | try |
| | | { |
| | | var PalletCode = TcpClientExample.Start("192.168.2.120", 2001); |
| | | if (!PalletCode.IsNotEmptyOrNull() || PalletCode == "NoRead") |
| | | { |
| | | return WebResponseContent.Instance.Error("æçç æªæ«å°ï¼è¯·éè¯"); |
| | | } |
| | | Db.Ado.BeginTran(); |
| | | |
| | | // 1. å é¤ Boxing ä¸»è¡¨æ°æ® |
| | | Dt_Boxing dt_Boxing = BaseDal.QueryFirst(x => x.PalletCode == PalletCode); |
| | | if (dt_Boxing != null) |
| | | { |
| | | BaseDal.DeleteData(dt_Boxing); |
| | | |
| | | // 2. ç´æ¥éè¿ä»å¨å é¤ BoxingDetail æ°æ®ï¼æ ¸å¿ä¿®æ¹ï¼ |
| | | Dt_BoxingDetail dt_BoxingDetail = _boxingDetailRepo.QueryFirst(x => x.BoxingId == dt_Boxing.Id); |
| | | if (dt_BoxingDetail != null) |
| | | { |
| | | _boxingDetailRepo.DeleteData(dt_BoxingDetail); |
| | | } |
| | | } |
| | | |
| | | // 3. å é¤ ProcessInfo æ°æ® |
| | | Dt_ProcessInfo dt_ProcessInfo = _processInfoService.Repository.QueryFirst(x => x.PalletCode == PalletCode); |
| | | if (dt_ProcessInfo != null) |
| | | { |
| | | _processInfoService.Repository.DeleteData(dt_ProcessInfo); |
| | | } |
| | | |
| | | Db.Ado.CommitTran(); |
| | | return WebResponseContent.Instance.OK("å 餿å"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Db.Ado.RollbackTran(); |
| | | throw new Exception(ex.Message); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |