using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Estsh.Core.Base; using Estsh.Core.Wms.IRepositories; using Estsh.Core.Wms.IServices; using Estsh.Core.Model.Result; using Estsh.Core.Services; using Estsh.Core.Repositories; using Estsh.Core.Models; using Newtonsoft.Json.Linq; using Estsh.Core.Model.EnumUtil; namespace Estsh.Core.Wms.Services { public class FinishDeliveryService : BaseService, IFinishDeliveryService { private readonly IFinishDeliveryRepository repository; public FinishDeliveryService(IFinishDeliveryRepository _repository) : base(_repository) { repository = _repository; } public SetObjectDetail GetCustomer(string cartonNo, string loginId) { SetObjectDetail det = new SetObjectDetail(); List SysCustomers = repository.GetCustomer(cartonNo); if (SysCustomers.Count == 0) { det.type = "NO"; det.message = "[" + cartonNo + "]:客户编号不存在,请检查!"; return det; } if (SysCustomers[0].Enabled.Equals("N")) { det.type = "NO"; det.message = "[" + cartonNo + "]:客户编号已被冻结,请检查!"; return det; } det.type = "PASS"; det.wmsObjectDetail = SysCustomers.ConvertAll(s => (object)s); return det; } public SetObjectDetail ProductionCode(string cartonNo, string loginId, string customer, string isComplete, string deliveryNo) { SetObjectDetail det = new SetObjectDetail(); List getOutStock = repository.GetOutStock(deliveryNo); if (getOutStock.Count > 0) { if (getOutStock[0].OrderStatus == 40) { det.type = "NO"; det.message = "[" + deliveryNo + "]:此订单已关闭!"; return det; } } List SysCustomers = repository.ProductionCode(cartonNo, loginId, customer, isComplete); if (SysCustomers.Count == 0) { det.type = "NO"; det.message = "[" + cartonNo + "]:成品条码不存在,请检查!"; return det; } SysCustomers = SysCustomers.Where(a => a.Enabled == "Y").ToList(); if (SysCustomers.Count == 0) { det.type = "NO"; det.message = "[" + cartonNo + "]:成品条码已被冻结,请检查!"; return det; } if (SysCustomers[0].Status != 50) { List sysEnum = repository.GetEnums(SysCustomers[0].Status); det.type = "NO"; det.message = "[" + cartonNo + "]:成品条码为" + sysEnum[0].EnumName + "状态,请检查!"; return det; } SetObjectDetail sysStocks = repository.ProductionDelivery(SysCustomers, loginId, customer, deliveryNo); return sysStocks; } public SetObjectDetail GetFinishDeliveryOrderList(string orderNo) { SetObjectDetail rfInfo = new SetObjectDetail(); List wmsMoves = repository.GetFinishDeliveryOrderList(orderNo); if (wmsMoves.Count > 0) { rfInfo.type = "PASS"; rfInfo.message = "成功"; rfInfo.wmsObjectDetail = wmsMoves.ConvertAll(s => (object)s); } else { rfInfo.type = "FAIL"; rfInfo.message = "未查询到数据,请检查!"; } return rfInfo; } public SetObjectDetail SetFinishDeliveryOrderNoSubmit(string orderNo, string loginId) { SetObjectDetail rfInfo = new SetObjectDetail(); bool istrue = repository.SetFinishDeliveryOrderNoSubmit(orderNo, loginId); if (istrue) { rfInfo.type = "PASS"; rfInfo.message = "成功"; } else { rfInfo.type = "FAIL"; rfInfo.message = "未查询到数据,请检查!"; } return rfInfo; } public SetObjectDetail GetFinishDeliveryOrderListByOrderNo(string orderNo) { SetObjectDetail rfInfo = new SetObjectDetail(); List wmsMoves = repository.GetFinishDeliveryOrderListByOrderNo(orderNo); if (wmsMoves.Count > 0) { rfInfo.type = "PASS"; rfInfo.message = "成功"; rfInfo.wmsObjectDetail = wmsMoves.ConvertAll(s => (object)s); } else { rfInfo.type = "FAIL"; rfInfo.message = "未查询到数据,请检查!"; } return rfInfo; } } }