| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using AutoMapper; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Common.TaskEnum; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.BaseRepository; |
| | | using WIDESEA_Core.BaseServices; |
| | | using WIDESEA_Core.Helper; |
| | | using WIDESEA_IBasicRepository; |
| | | using WIDESEA_IOutboundRepository; |
| | | using WIDESEA_IOutboundService; |
| | | using WIDESEA_Model.Models; |
| | | |
| | | namespace WIDESEA_OutboundService |
| | | { |
| | | public class OutLineViewService : ServiceBase<Dt_OutLineView, IOutLineViewRepository>, IOutLineViewService |
| | | { |
| | | public IOutLineViewRepository Repository => BaseDal; |
| | | private IBasicRepository _basicRepository; |
| | | private readonly IMapper _mapper; |
| | | private readonly IUnitOfWorkManage _unitOfWorkManage; |
| | | |
| | | public OutLineViewService(IOutLineViewRepository BaseDal, IBasicRepository basicRepository, IMapper mapper, IUnitOfWorkManage unitOfWorkManage) : base(BaseDal) |
| | | { |
| | | _basicRepository = basicRepository; |
| | | _mapper = mapper; |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | | } |
| | | /// <summary> |
| | | /// è·å线ä½å纸 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public WebResponseContent GetOutLineView() |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | //è·åæ°æ® |
| | | List<Dt_OutLineView> lineViews = BaseDal.QueryData().OrderBy(x=>x.CreateDate).ToList(); |
| | | int taskCount = BaseDal.Db.Queryable<Dt_Task>().Where(x=>x.TaskType==TaskTypeEnum.OldYLOutbound.ObjToInt() && x.TaskStatus==TaskStatusEnum.Line_Executing.ObjToInt()).Count(); |
| | | content.OK($"{taskCount}", lineViews); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | /// <summary> |
| | | /// åå
¥ææ°çåºåºçº¸å·ä¿¡æ¯ |
| | | /// </summary> |
| | | /// <param name="outStockLockInfos"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent SaveLineView(List<Dt_OutStockLockInfo> outStockLockInfos) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | //è·åå½åèåç¼åææçº¸å·ä¿¡æ¯ |
| | | List<Dt_OutLineView> outLineViews = BaseDal.QueryData(); |
| | | //è·åå½å纸å·ä¸ªæ° |
| | | int? outLineCount = outLineViews?.Select(x => x.PalletCode).Distinct().Count(); |
| | | if (outLineViews==null || outLineViews.Count<=0 || outLineCount<=2) |
| | | { |
| | | List<Dt_OutLineView> outLineViewsAdd = outStockLockInfos.Select(x => _mapper.Map<Dt_OutLineView>(x)).ToList(); |
| | | BaseDal.AddData(outLineViewsAdd); |
| | | } |
| | | else |
| | | { |
| | | //è·åææ©ç纸å·ä¿¡æ¯ |
| | | string? code= outLineViews.FirstOrDefault()?.PalletCode; |
| | | List<Dt_OutLineView> outLineViewsDel = outLineViews.Where(x=>x.PalletCode==code).ToList(); |
| | | List<Dt_OutLineView> outLineViewsAdd = outStockLockInfos.Select(x => _mapper.Map<Dt_OutLineView>(x)).ToList(); |
| | | BaseDal.DeleteData(outLineViewsDel); |
| | | BaseDal.AddData(outLineViewsAdd); |
| | | } |
| | | content.OK("æå"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | } |
| | | } |