| | |
| | | using AutoMapper; |
| | | using Microsoft.IdentityModel.Tokens; |
| | | using SqlSugar; |
| | | using System; |
| | | using System.Collections.Generic; |
| | |
| | | if (!result.Item1) return content = WebResponseContent.Instance.Error(result.Item2); |
| | | #endregion |
| | | |
| | | List<string> LocationCodes = orderAddDTO.Details |
| | | .Where(x => !string.IsNullOrEmpty(x.LocationCode)) |
| | | .Select(x => x.LocationCode).ToList(); |
| | | |
| | | Dt_InboundOrder inboundOrder = _mapper.Map<Dt_InboundOrder>(orderAddDTO); |
| | | //inboundOrder.OrderNo = DateTime.Now.ToString("yyMMddHHmmss"); |
| | | inboundOrder.OrderStatus = InboundStatusEnum.æªå¼å§.ObjToInt(); |
| | | bool a = BaseDal.Db.InsertNav(inboundOrder).Include(x => x.Details).ExecuteCommand(); |
| | | Db.Ado.BeginTran(); |
| | | if (LocationCodes.Any()) |
| | | { |
| | | content = _basicService.LocationInfoService.UpdateStatus(LocationCodes, LocationStatusEnum.PalletLock.ObjToInt()); |
| | | if (!content.Status) |
| | | throw new Exception(content.Message); |
| | | } |
| | | |
| | | BaseDal.Db.InsertNav(inboundOrder).Include(x => x.Details).ExecuteCommand(); |
| | | Db.Ado.CommitTran(); |
| | | content = WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Db.Ado.RollbackTran(); |
| | | content = WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | finally |
| | |
| | | return content; |
| | | } |
| | | |
| | | public override WebResponseContent UpdateData(SaveModel saveModel) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | if (saveModel.DetailData == null || saveModel.DetailData.Count == 0) throw new Exception($"å
¥åºåæç»ä¸è½ä¸ºç©º"); |
| | | List<InboundOrderDetailAddDTO> inboundOrderDetail = saveModel.DetailData.DicToIEnumerable<InboundOrderDetailAddDTO>(); |
| | | if (inboundOrderDetail.FirstOrDefault(x => x.OrderDetailStatus > 0) != null) throw new Exception($"订åå·²å¼å§ç»çå
¥åº"); |
| | | var inboundOrderDetails = _inboundOrderDetailService.Db.Queryable<Dt_InboundOrderDetail>().Where(x => saveModel.DelKeys.Contains(x.Id)).ToList(); |
| | | if (inboundOrderDetails.Count > 0) |
| | | { |
| | | if (inboundOrderDetails.FirstOrDefault(x => x.OrderDetailStatus != OrderDetailStatusEnum.New.ObjToInt()) != null) |
| | | throw new Exception($"åå¨å·²ç»çå·¥åï¼å·²å
è§£ç"); |
| | | } |
| | | content = base.UpdateData(saveModel); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | public override WebResponseContent DeleteData(object[] keys) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | var inboundOrders = BaseDal.QueryData(x => keys.Contains(x.Id)); |
| | | if (inboundOrders.FirstOrDefault(x => x.OrderStatus != InboundStatusEnum.æªå¼å§.ObjToInt()) != null) |
| | | throw new Exception($"å
¥åºååå¨ç»çå
¥åºä¿¡æ¯"); |
| | | foreach (var inboundOrder in inboundOrders) |
| | | { |
| | | var inboundOrderDetails = BaseDal.Db.Queryable<Dt_InboundOrder>().Includes(x => x.Details).First(x => x.OrderNo == inboundOrder.OrderNo).Details; |
| | | if (inboundOrderDetails != null || inboundOrderDetails.Count > 0) |
| | | { |
| | | if (inboundOrderDetails.FirstOrDefault(x => x.OrderDetailStatus != OrderDetailStatusEnum.New.ObjToInt()) != null) |
| | | throw new Exception($"å
¥åºåã{inboundOrder.OrderNo}ãåå¨ç»çå
¥åºä¿¡æ¯"); |
| | | } |
| | | } |
| | | content = base.DeleteData(keys); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | /// <summary> |
| | | /// éªè¯åæ®æ·»å DTO对象 |
| | | /// </summary> |