已修改36个文件
已删除205个文件
已添加3个文件
| | |
| | | using WIDESEA_Core.Helper; |
| | | using WIDESEA_IApprovalRepository; |
| | | using WIDESEA_IApprovalService; |
| | | using WIDESEA_ICheckRepository; |
| | | using WIDESEA_ISystemRepository; |
| | | using WIDESEA_Model.Models; |
| | | |
| | |
| | | private readonly IUnitOfWorkManage _unitOfWorkManage; |
| | | private readonly IApprovalFlowRepository _approvalFlowRepository; |
| | | private readonly IApprovalNodeRepository _approvalNodeRepository; |
| | | private readonly ICheckOrderRepository _checkOrderRepository; |
| | | private readonly WebSocketServer _webSocketServer; |
| | | private readonly ISys_UserRepository _userRepository; |
| | | |
| | | public IApprovalTaskRepository Repository => BaseDal; |
| | | |
| | | public ApprovalTaskService(IApprovalTaskRepository BaseDal, IUnitOfWorkManage unitOfWorkManage, IApprovalFlowRepository approvalFlowRepository, IApprovalNodeRepository approvalNodeRepository, ICheckOrderRepository checkOrderRepository, WebSocketServer webSocketServer, ISys_UserRepository userRepository) : base(BaseDal) |
| | | public ApprovalTaskService(IApprovalTaskRepository BaseDal, IUnitOfWorkManage unitOfWorkManage, IApprovalFlowRepository approvalFlowRepository, IApprovalNodeRepository approvalNodeRepository, WebSocketServer webSocketServer, ISys_UserRepository userRepository) : base(BaseDal) |
| | | { |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | | _approvalFlowRepository = approvalFlowRepository; |
| | | _approvalNodeRepository = approvalNodeRepository; |
| | | _checkOrderRepository = checkOrderRepository; |
| | | _webSocketServer = webSocketServer; |
| | | _userRepository = userRepository; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 审æ¹åæ |
| | | /// </summary> |
| | | /// <param name="sourceKey">æºä¸»é®</param> |
| | | /// <returns></returns> |
| | | public WebResponseContent AuditAgree(int sourceKey) |
| | | { |
| | | try |
| | | { |
| | | Dt_ApprovalFlow approvalFlow = _approvalFlowRepository.QueryFirst(x => x.FlowCode == "IQC"); |
| | | if (approvalFlow == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªå®ä¹è¯¥å®¡æ¹æµ"); |
| | | } |
| | | List<Dt_ApprovalNode> approvalNodes = _approvalNodeRepository.QueryData(x => x.FlowId == approvalFlow.Id); |
| | | if (approvalNodes == null || approvalNodes.Count <= 0) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªå®ä¹è¯¥å®¡æ¹æµç¨èç¹"); |
| | | } |
| | | |
| | | Dt_ApprovalNode? currentNode = approvalNodes.FirstOrDefault(x => x.ApproverRole == App.User.RoleId); |
| | | if (currentNode == null) |
| | | { |
| | | return WebResponseContent.Instance.OK($"æªæ¾å°å½åè§è²å®¡æ¹èç¹"); |
| | | } |
| | | |
| | | Dt_ApprovalTask approvalTask = BaseDal.QueryFirst(x => x.SourceKey == sourceKey && x.NodeId == currentNode.Id); |
| | | if (approvalTask == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°è¯¥å®¡æ¹æ°æ®"); |
| | | } |
| | | |
| | | if (approvalTask.Status != AuditStatusEnum.Auditing.ObjToInt()) |
| | | { |
| | | return WebResponseContent.Instance.Error($"该审æ¹å·²å®æ"); |
| | | } |
| | | |
| | | Dt_CheckOrder checkOrder = _checkOrderRepository.QueryFirst(x => x.CheckOrderId == sourceKey); |
| | | if (checkOrder == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°æ¥æºæ°æ®(è´¨æ£å)"); |
| | | } |
| | | |
| | | Dt_ApprovalNode? nextNode = approvalNodes.Where(x => x.NodeSequence > currentNode.NodeSequence).OrderBy(x => x.NodeSequence).FirstOrDefault(); |
| | | if (nextNode == null)//å®¡æ¹æµç¨ç»æ |
| | | { |
| | | approvalTask.Status = AuditStatusEnum.Agree.ObjToInt(); |
| | | |
| | | checkOrder.AuditStatus = AuditStatusEnum.Agree.ObjToInt(); |
| | | _unitOfWorkManage.BeginTran(); |
| | | _checkOrderRepository.UpdateData(checkOrder); |
| | | |
| | | BaseDal.UpdateData(approvalTask); |
| | | //BaseDal.DeleteAndMoveIntoHty(approvalTask, WIDESEA_Core.Enums.OperateTypeEnum.èªå¨å®æ); |
| | | |
| | | WebSocketSession? webSocketSession = _webSocketServer.OnlineSessions.FirstOrDefault(x => x.Url.Contains(approvalTask.ApplicantUserName)); |
| | | if (webSocketSession != null) |
| | | { |
| | | _webSocketServer.SendClientPayload(webSocketSession, "åæ"); |
| | | } |
| | | _unitOfWorkManage.CommitTran(); |
| | | } |
| | | else//è¿å
¥ä¸ä¸çº§å®¡æ¹èç¹ |
| | | { |
| | | object obj = new |
| | | { |
| | | title = "IQCè´¨æ£ç»æå®¡æ¹", |
| | | formData = checkOrder, |
| | | tableData = checkOrder.Details, |
| | | message = "æ¨éæµè¯ä¿¡æ¯ä½", |
| | | date = DateTime.Now.ToString(), |
| | | }; |
| | | List<Dt_ApprovalTask> approvalTasks = new List<Dt_ApprovalTask>(); |
| | | List<string> userNames = new List<string>(); |
| | | List<Sys_User> users = _userRepository.QueryData(x => x.RoleId == nextNode.ApproverRole); |
| | | foreach (Sys_User user in users) |
| | | { |
| | | Dt_ApprovalTask newApprovalTask = new Dt_ApprovalTask() |
| | | { |
| | | FlowId = approvalFlow.Id, |
| | | NodeId = nextNode.Id, |
| | | ApplicantUserId = App.User.UserId, |
| | | ApplicantUserName = user.UserName, |
| | | Status = AuditStatusEnum.Auditing.ObjToInt(), |
| | | AuditUser = user.UserName, |
| | | SourceKey = approvalTask.SourceKey |
| | | }; |
| | | approvalTasks.Add(newApprovalTask); |
| | | userNames.Add(user.UserName); |
| | | } |
| | | |
| | | approvalTask.Status = AuditStatusEnum.Agree.ObjToInt(); |
| | | BaseDal.UpdateData(approvalTask); |
| | | BaseDal.AddData(approvalTasks); |
| | | foreach (string userName in userNames) |
| | | { |
| | | WebSocketSession? socketSessions = _webSocketServer.OnlineSessions.FirstOrDefault(x => x.Url.Contains(userName)); |
| | | if (socketSessions != null) |
| | | { |
| | | _webSocketServer.SendClientPayload(socketSessions, obj.Serialize()); |
| | | } |
| | | } |
| | | } |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 审æ¹é©³å |
| | | /// </summary> |
| | | /// <param name="sourceKey">æºä¸»é®</param> |
| | | /// <returns></returns> |
| | | public WebResponseContent AuditReject(int sourceKey) |
| | | { |
| | | try |
| | | { |
| | | Dt_ApprovalFlow approvalFlow = _approvalFlowRepository.QueryFirst(x => x.FlowCode == "IQC"); |
| | | if (approvalFlow == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªå®ä¹è¯¥å®¡æ¹æµ"); |
| | | } |
| | | List<Dt_ApprovalNode> approvalNodes = _approvalNodeRepository.QueryData(x => x.FlowId == approvalFlow.Id); |
| | | if (approvalNodes == null || approvalNodes.Count <= 0) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªå®ä¹è¯¥å®¡æ¹æµç¨èç¹"); |
| | | } |
| | | |
| | | Dt_ApprovalNode? currentNode = approvalNodes.FirstOrDefault(x => x.ApproverRole == App.User.RoleId); |
| | | if (currentNode == null) |
| | | { |
| | | return WebResponseContent.Instance.OK($"æªæ¾å°å½åè§è²å®¡æ¹èç¹"); |
| | | } |
| | | |
| | | Dt_ApprovalTask approvalTask = BaseDal.QueryFirst(x => x.SourceKey == sourceKey); |
| | | if (approvalTask == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°è¯¥å®¡æ¹æ°æ®"); |
| | | } |
| | | |
| | | if (approvalTask.Status != AuditStatusEnum.Auditing.ObjToInt()) |
| | | { |
| | | return WebResponseContent.Instance.Error($"该审æ¹å·²å®æ"); |
| | | } |
| | | |
| | | Dt_CheckOrder checkOrder = _checkOrderRepository.QueryFirst(x => x.CheckOrderId == sourceKey); |
| | | if (checkOrder == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°æ¥æºæ°æ®(è´¨æ£å)"); |
| | | } |
| | | |
| | | approvalTask.Status = AuditStatusEnum.Reject.ObjToInt(); |
| | | |
| | | checkOrder.AuditStatus = AuditStatusEnum.Reject.ObjToInt(); |
| | | _unitOfWorkManage.BeginTran(); |
| | | _checkOrderRepository.UpdateData(checkOrder); |
| | | |
| | | BaseDal.UpdateData(approvalTask); |
| | | //BaseDal.DeleteAndMoveIntoHty(approvalTask, WIDESEA_Core.Enums.OperateTypeEnum.èªå¨å®æ); |
| | | |
| | | WebSocketSession? webSocketSession = _webSocketServer.OnlineSessions.FirstOrDefault(x => x.Url.Contains(approvalTask.ApplicantUserName)); |
| | | if (webSocketSession != null) |
| | | { |
| | | _webSocketServer.SendClientPayload(webSocketSession, "驳å"); |
| | | } |
| | | _unitOfWorkManage.CommitTran(); |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | public IWarehouseRepository WarehouseRepository { get; } |
| | | |
| | | public IPalletTypeInfoRepository PalletTypeInfoRepository { get; } |
| | | public ICustomerInfoRepository CustomerInfoRepository { get; } |
| | | |
| | | public BasicRepository(ILocationInfoRepository locationInfoRepository, IMaterielInfoRepository materielInfoRepository, IWarehouseRepository warehouseRepository, IPalletTypeInfoRepository palletTypeInfoRepository, ICustomerInfoRepository customerInfoRepository) |
| | | public BasicRepository(ILocationInfoRepository locationInfoRepository, IMaterielInfoRepository materielInfoRepository, IWarehouseRepository warehouseRepository, IPalletTypeInfoRepository palletTypeInfoRepository) |
| | | { |
| | | LocationInfoRepository = locationInfoRepository; |
| | | MaterielInfoRepository = materielInfoRepository; |
| | | WarehouseRepository = warehouseRepository; |
| | | PalletTypeInfoRepository = palletTypeInfoRepository; |
| | | CustomerInfoRepository = customerInfoRepository; |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | public class BasicService : IBasicService |
| | | { |
| | | public ICustomerInfoService CustomerInfoService { get; } |
| | | |
| | | public IPalletCodeInfoService PalletCodeInfoService { get; } |
| | | |
| | | public ISupplierInfoService SupplierInfoService { get; } |
| | | |
| | | public IUserInfoService UserInfoService { get; } |
| | | |
| | | public ILocationInfoService LocationInfoService { get; } |
| | | |
| | |
| | | |
| | | public IMaterielCodeInfoService MaterielCodeInfoService { get; } |
| | | |
| | | public BasicService(ILocationInfoService locationInfoService, IMaterielInfoService materielInfoService, IWarehouseService warehouseService, ISupplierInfoService supplierInfoService,ICustomerInfoService customerInfoService,IPalletCodeInfoService palletCodeInfoService, IUserInfoService userInfoService, IMaterielCodeInfoService materielCodeInfoService) |
| | | public BasicService(ILocationInfoService locationInfoService, IMaterielInfoService materielInfoService, IWarehouseService warehouseService,IPalletCodeInfoService palletCodeInfoService, IMaterielCodeInfoService materielCodeInfoService) |
| | | { |
| | | LocationInfoService = locationInfoService; |
| | | MaterielInfoService = materielInfoService; |
| | | WarehouseService = warehouseService; |
| | | SupplierInfoService = supplierInfoService; |
| | | CustomerInfoService = customerInfoService; |
| | | PalletCodeInfoService = palletCodeInfoService; |
| | | UserInfoService = userInfoService; |
| | | MaterielCodeInfoService = materielCodeInfoService; |
| | | } |
| | | } |
| | |
| | | { |
| | | _basicRepository = basicRepository; |
| | | } |
| | | public override WebResponseContent AddData(SaveModel saveModel) |
| | | { |
| | | string? MaterialCode = saveModel.MainData["materielCode"].ToString(); |
| | | Dt_MaterielInfo materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x=>x.MaterielCode== MaterialCode); |
| | | if (materielInfo == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"{MaterialCode}ç©æä¸åå¨"); |
| | | } |
| | | saveModel.MainData.Add(nameof(Dt_MaterielCodeInfo.MaterielName).FirstLetterToLower(), materielInfo.MaterielName); |
| | | string? PurchaseOrderNo = saveModel.MainData["purchaseOrderNo"].ToString(); |
| | | Dt_PurchaseOrder purchaseOrder = BaseDal.Db.Queryable<Dt_PurchaseOrder>().Where(x=>x.PurchaseOrderNo== PurchaseOrderNo).First(); |
| | | if (purchaseOrder == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"{PurchaseOrderNo}éè´åä¸åå¨"); |
| | | } |
| | | saveModel.MainData.Add(nameof(Dt_MaterielCodeInfo.SupplierCode).FirstLetterToLower(), purchaseOrder.SupplierCode); |
| | | return base.AddData(saveModel); |
| | | } |
| | | } |
| | | } |
| | |
| | | public interface IApprovalTaskService : IService<Dt_ApprovalTask> |
| | | { |
| | | IApprovalTaskRepository Repository { get; } |
| | | |
| | | /// <summary> |
| | | /// 审æ¹åæ |
| | | /// </summary> |
| | | /// <param name="sourceKey">æºä¸»é®</param> |
| | | /// <returns></returns> |
| | | WebResponseContent AuditAgree(int sourceKey); |
| | | |
| | | /// <summary> |
| | | /// 审æ¹é©³å |
| | | /// </summary> |
| | | /// <param name="sourceKey">æºä¸»é®</param> |
| | | /// <returns></returns> |
| | | WebResponseContent AuditReject(int sourceKey); |
| | | } |
| | | } |
| | |
| | | IWarehouseRepository WarehouseRepository { get; } |
| | | |
| | | IPalletTypeInfoRepository PalletTypeInfoRepository { get; } |
| | | ICustomerInfoRepository CustomerInfoRepository { get; } |
| | | |
| | | } |
| | | } |
| | |
| | | /// </summary> |
| | | IWarehouseService WarehouseService { get; } |
| | | |
| | | /// <summary> |
| | | /// ä¾åºåä¸å¡å± |
| | | /// </summary> |
| | | ISupplierInfoService SupplierInfoService { get; } |
| | | |
| | | IUserInfoService UserInfoService { get; } |
| | | |
| | | IPalletCodeInfoService PalletCodeInfoService { get; } |
| | | |
| | | ICustomerInfoService CustomerInfoService { get; } |
| | | |
| | | IMaterielCodeInfoService MaterielCodeInfoService { get; } |
| | | } |
| | |
| | | { |
| | | public interface IProStockInfoRepository : IRepository<Dt_ProStockInfo> |
| | | { |
| | | /// <summary> |
| | | /// æ¥æ¾å¯ç¨åºå |
| | | /// </summary> |
| | | List<Dt_ProStockInfo> GetProStocks(Dt_ProOutOrderDetail proOutOrderDetail,List<string> locationInfos); |
| | | /// <summary> |
| | | /// è·åæååºå |
| | | /// </summary> |
| | | List<Dt_ProStockInfo> GetProStocks(Dt_MesRworkOutboundOrder mesRworkOutboundOrder, List<string> locationInfos); |
| | | } |
| | | } |
| | |
| | | /// <param name="proStockInfoDetails"></param> |
| | | /// <returns></returns> |
| | | WebResponseContent UnBindStock(List<Dt_ProStockInfoDetail> proStockInfoDetails); |
| | | /// <summary> |
| | | /// æ¥æ¾å¯ç¨åºå |
| | | /// </summary> |
| | | List<Dt_ProStockInfo> GetUseableStocks(int warehoseId, Dt_ProOutOrderDetail proOutOrderDetail); |
| | | /// <summary> |
| | | /// è·ååºåºåºå |
| | | /// </summary> |
| | | List<Dt_ProStockInfo> GetOutboundStocks(List<Dt_ProStockInfo> stockInfos, Dt_ProOutOrderDetail outOrderDetail, float needQuantity, out float residueQuantity); |
| | | |
| | | /// <summary> |
| | | /// MESæåºå¯ç¨åºå |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public List<Dt_ProStockInfo> GetUseableStocks(Dt_MesRworkOutboundOrder mesRworkOutboundOrder); |
| | | /// <summary> |
| | | /// è·åMESæåºåºå |
| | | /// </summary> |
| | | List<Dt_ProStockInfo> GetOutboundStocks(List<Dt_ProStockInfo> stockInfos, Dt_MesRworkOutboundOrder mesRworkOutboundOrder, float needQuantity, out float residueQuantity); |
| | | } |
| | | } |
| | |
| | | PageGridData<ProStockViewDTO> GetPageData(PageDataOptions options); |
| | | |
| | | object GetDetailPage(PageDataOptions pageData); |
| | | WebResponseContent Export(PageDataOptions options); |
| | | List<ProStockViewDTO> GetProPKSelectStocks(int orderId); |
| | | } |
| | | } |
| | |
| | | public interface IStockInfoService : IService<Dt_StockInfo> |
| | | { |
| | | IStockInfoRepository Repository { get; } |
| | | |
| | | List<StockSelectViewDTO> GetStockSelectViews(int orderId, string materielCode); |
| | | List<StockSelectViewDTO> GetPKStockSelectViews(int orderId, string materielCode); |
| | | |
| | | List<Dt_StockInfo> GetOutboundStocks(List<Dt_StockInfo> stockInfos, string materielCode, float needQuantity, out float residueQuantity); |
| | | |
| | | List<Dt_StockInfo> GetUseableStocks(string materielCode, string batchNo, int warehoseId); |
| | | |
| | | //List<Dt_StockInfo> GetUseableStocks(string materielCode, string batchNo,,string , int warehoseId); |
| | | |
| | | List<Dt_StockInfo> GetUseableStocks(string materielCode, string batchNo, string palletcode, int warehoseId); |
| | | WebResponseContent StockQueryData(SaveModel saveModel); |
| | | } |
| | | } |
| | |
| | | WebResponseContent PushTasksToWCSSingle(int taskNum, string agvDescription = ""); |
| | | |
| | | /// <summary> |
| | | /// ç³è¯·å
¥åºä»»å¡(PDA使ç¨ï¼ä»
æçç»å®å
¥åºç«å°ï¼ä¸åé
è´§ä½) |
| | | /// </summary> |
| | | /// <param name="palletCode">æçå·</param> |
| | | /// <param name="stationCode">ç«å°å·</param> |
| | | /// <returns></returns> |
| | | //WebResponseContent RequestInboundTask(string palletCode, string stationCode); |
| | | WebResponseContent RequestInboundTask(SaveModel saveModel); |
| | | /// <summary> |
| | | /// 空箱å
¥åº |
| | | /// </summary> |
| | | /// <param name="barcode"></param> |
| | |
| | | /// <param name="address">å°å</param> |
| | | /// <returns></returns> |
| | | WebResponseContent OutEmpty(int qty, string address, int WarehouseId, string barcode); |
| | | |
| | | /// <summary> |
| | | /// WCSç³è¯·å
¥åº |
| | | /// </summary> |
| | | /// <param name="stationCode"></param> |
| | | /// <param name="roadwayNo"></param> |
| | | /// <param name="palletCode"></param> |
| | | /// <returns></returns> |
| | | WebResponseContent DeviceRequestInboundTask(string stationCode, string roadwayNo, string palletCode,string materielBoxCode = ""); |
| | | |
| | | /// <summary> |
| | | /// ä»
ç³è¯·ä»»å¡ï¼è®©WCSæ ¹æ®è·¯ç±ç¡®å®ä¸ä¸å°å |
| | | /// </summary> |
| | |
| | | /// <param name="palletCode"></param> |
| | | /// <returns></returns> |
| | | WebResponseContent DeviceRequestInboundTaskSimple(string stationCode, string palletCode); |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="stationCode"></param> |
| | | /// <param name="palletCode"></param> |
| | | /// <param name="roadwayNos"></param> |
| | | /// <param name="heightType"></param> |
| | | /// <returns></returns> |
| | | WebResponseContent DeviceRequestInboundTaskByRoadways(string stationCode, string palletCode, List<string> roadwayNos, int heightType); |
| | | |
| | | /// <summary> |
| | | /// å
¥åºä»»å¡ç³è¯·åé
è´§ä½ |
| | | /// </summary> |
| | |
| | | /// <param name="palletType">æçç±»å</param> |
| | | /// <returns></returns> |
| | | WebResponseContent AssignInboundTaskLocation(int taskNum, string roadwayNo); |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | |
| | | Task<WebResponseContent> TaskCompleted(int taskNum); |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="taskNum"></param> |
| | | /// <returns></returns> |
| | | WebResponseContent InboundTaskCompleted(int taskNum); |
| | | /// <summary> |
| | | /// æµè¯æ¶åºä» |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | MesResponseContent TestToolOut(TestToolOutModel model); |
| | | |
| | | /// <summary> |
| | | /// çæåºåºä»»å¡ |
| | | /// </summary> |
| | | /// <param name="orderDetailId"></param> |
| | | /// <param name="stockSelectViews"></param> |
| | | /// <returns></returns> |
| | | WebResponseContent GenerateOutboundTask(int orderDetailId, List<StockSelectViewDTO> stockSelectViews); |
| | | |
| | | /// <summary> |
| | | /// çæåºåºä»»å¡ |
| | | /// </summary> |
| | | /// <param name="keys"></param> |
| | | /// <returns></returns> |
| | | WebResponseContent GenerateOutboundTasks(int[] keys); |
| | | |
| | | /// <summary> |
| | | /// åºåºä»»å¡å®æ |
| | | /// </summary> |
| | | /// <param name="taskNum">ä»»å¡å·</param> |
| | | /// <returns></returns> |
| | | WebResponseContent OutboundTaskCompleted(int taskNum); |
| | | |
| | | /// <summary> |
| | | /// 夿æ¯å¦éè¦ç§»åº |
| | |
| | | WebResponseContent UploadMesMaterialLotaAcept(MesMaterialLotaAceptModel model); |
| | | |
| | | /// <summary> |
| | | /// åºæ¿åºåº |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | MesResponseContent SubstrateOut(SubstrateOutModel model); |
| | | |
| | | /// <summary> |
| | | /// åºæ¿ä½æéåº |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | MesResponseContent SubstrateBack(SubstrateBackModel model); |
| | | |
| | | /// <summary> |
| | | /// æåè¿å·¥æåº |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | MesResponseContent RworkTask(RworkTaskModel model); |
| | | |
| | | /// <summary> |
| | | /// |
| | |
| | | /// <param name="heightType"></param> |
| | | /// <returns></returns> |
| | | WebResponseContent AssignRoadwayByHeight(List<string> roadwayNos, int taskNum, int heightType = 0); |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="roadwayNos"></param> |
| | | /// <param name="palletCode"></param> |
| | | /// <param name="heightType"></param> |
| | | /// <returns></returns> |
| | | WebResponseContent AssignRoadwayByHeightAndCode(List<string> roadwayNos, string palletCode, int heightType = 0); |
| | | |
| | | /// <summary> |
| | | /// åé
å··é |
| | |
| | | WebResponseContent SingleAssignRoadway(List<string> roadwayNos); |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="orderId"></param> |
| | | /// <returns></returns> |
| | | WebResponseContent HandSubstrateOut(int orderId); |
| | | |
| | | /// <summary> |
| | | /// ä¿®æ¹ä»»å¡ç¶æ |
| | | /// </summary> |
| | | /// <param name="task"></param> |
| | |
| | | /// <param name="task"></param> |
| | | /// <returns></returns> |
| | | WebResponseContent AGVTasks(SaveModel saveModel); |
| | | |
| | | |
| | | WebResponseContent GeneratePKOutboundTask(int orderDetailId, List<StockSelectViewDTO> stockSelectViews); |
| | | /// <summary> |
| | | /// MESæåå
å
ä¿¡æ¯æ¥æ¶ |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | MesResponseContent BagInfoSync(MesBagInfoModel bagInfoModel); |
| | | /// <summary> |
| | | /// MESæåå¤å
ä¿¡æ¯æ¥æ¶ |
| | | /// </summary> |
| | | /// <param name="boxInfoModel"></param> |
| | | /// <returns></returns> |
| | | MesResponseContent BoxStockin(MesBoxInfoModel boxInfoModel); |
| | | /// <summary> |
| | | /// MESæååºåºæ¥å£è°ç¨ |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | WebResponseContent ShipmentOrderSync(MesShipmentOrderSync model); |
| | | /// <summary> |
| | | /// çææååºåºä»»å¡ |
| | | /// </summary> |
| | | /// <param name="ProOutNo">åºåºè®¢åå·</param> |
| | | /// <param name="StationCode">ç«å°å°å</param> |
| | | /// <returns></returns> |
| | | Task<WebResponseContent> OutProductTask(int[] keys, string StationCode, int Grade); |
| | | /// <summary> |
| | | /// æå使éåºå
¥ä» |
| | | /// </summary> |
| | |
| | | /// <param name="startPoint"></param> |
| | | /// <returns></returns> |
| | | WebResponseContent EmptyBackTask(string barCode, string startPoint); |
| | | /// <summary> |
| | | /// äººå·¥éæ©åºå |
| | | /// </summary> |
| | | WebResponseContent OutProductSelect(int orderDetailId, List<ProStockViewDTO> proStockViews); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using SqlSugar; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Core.DB.Models; |
| | | |
| | | namespace WIDESEA_Model.Models |
| | | { |
| | | /// <summary> |
| | | /// æåç åå·¥ä½ |
| | | /// </summary> |
| | | [SugarTable(nameof(Dt_ProCache), "æåç åå·¥ä½ä¸»è¡¨")] |
| | | public class Dt_ProCache : BaseEntity |
| | | { |
| | | /// <summary> |
| | | /// ä¸»é® |
| | | /// </summary> |
| | | [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnDescription = "主é®")] |
| | | public int Id { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ç åå·¥ä½å· |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = false, Length = 50, ColumnDescription = "ç åå·¥ä½å·")] |
| | | public string MdNo { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ç åç©æ<br/> |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = false, Length = 50, ColumnDescription = "ç åç©æ")] |
| | | public string MdMaterial { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ç åç©æç®±å |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = false, Length = 50, ColumnDescription = "ç åç©æç®±å")] |
| | | public string MdBoxMaterial { get; set; } |
| | | |
| | | /// <summary> |
| | | /// å·²ç åç®±æ° |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = false, ColumnDescription = "å·²ç åç®±æ°")] |
| | | public string MdQtys { get; set; } |
| | | |
| | | /// <summary> |
| | | /// åå· |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = true, Length = 30, ColumnDescription = "åå·")] |
| | | public string ShipmentOrder { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ç åç¶æ |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = false, ColumnDescription = "ç åç¶æ")] |
| | | public int MdStatus { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ç åæç» |
| | | /// </summary> |
| | | [Navigate(NavigateType.OneToMany, nameof(Dt_ProStockInfoDetail.ProStockId), nameof(Id))] |
| | | public List<Dt_ProStockInfoDetail> proStockInfoDetails { get; set; } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using SqlSugar; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Core.DB.Models; |
| | | |
| | | namespace WIDESEA_Model.Models |
| | | { |
| | | /// <summary> |
| | | /// æåç åå·¥ä½æç» |
| | | /// </summary> |
| | | [SugarTable(nameof(Dt_ProCacheDetail), "æåç å工使ç»")] |
| | | public class Dt_ProCacheDetail : BaseEntity |
| | | { |
| | | /// <summary> |
| | | /// ä¸»é® |
| | | /// </summary> |
| | | [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnDescription = "主é®")] |
| | | public int Id { get; set; } |
| | | |
| | | /// <summary> |
| | | /// æåç åå·¥ä½ä¸»é® |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = false, ColumnDescription = "æåç åå·¥ä½ä¸»é®")] |
| | | public int ProCacheId { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ç åç®±å· |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = false, Length = 50, ColumnDescription = "ç åç®±å·")] |
| | | public string MdBoxCode { get; set; } |
| | | |
| | | /// <summary> |
| | | /// åç®±æ°é<br/> |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = false, Length = 50, ColumnDescription = "åç®±æ°é")] |
| | | public int BoxQtys { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ç©æåä½ |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = false, Length = 50, ColumnDescription = "ç©æåä½")] |
| | | public string MaterialUnit { get; set; } |
| | | |
| | | } |
| | | } |
| | |
| | | <ProjectReference Include="..\WIDESEA_Core\WIDESEA_Core.csproj" /> |
| | | </ItemGroup> |
| | | |
| | | <ItemGroup> |
| | | <Folder Include="Models\Check\" /> |
| | | <Folder Include="Models\Inbound\" /> |
| | | <Folder Include="Models\Outbound\" /> |
| | | </ItemGroup> |
| | | |
| | | </Project> |
| | |
| | | { |
| | | _basicRepository = basicRepository; |
| | | } |
| | | //æ ¹æ®æç»æ°æ®æ¥æ¾å¯ç¨åºååºå |
| | | public List<Dt_ProStockInfo> GetProStocks(Dt_ProOutOrderDetail proOutOrderDetail,List<string> locationInfos) |
| | | { |
| | | List<Dt_ProStockInfo>? proStockInfos = null; |
| | | bool isCanLot= string.IsNullOrEmpty(proOutOrderDetail.PLot); |
| | | bool isCanDate = string.IsNullOrEmpty(proOutOrderDetail.DateCode); |
| | | bool isCanVer = string.IsNullOrEmpty(proOutOrderDetail.OutSpecifyVer); |
| | | ////夿客æ·åºå
¥è§å |
| | | //Dt_CustomerInfo customerInfo = _basicRepository.CustomerInfoRepository.QueryFirst(x=>x.Code== proOutOrderDetail.Customer); |
| | | //if (customerInfo==null) |
| | | //{ |
| | | // throw new Exception("æªæ¾å°å®¢æ·ä¿¡æ¯"); |
| | | //} |
| | | //if (customerInfo.OutRule==CustomerOutRuleEnum.SaleOrderRule.ObjToInt()) |
| | | //{ |
| | | // proStockInfos = Db.Queryable<Dt_ProStockInfo>().Where(x => locationInfos.Contains(x.LocationCode) && x.ProStockAttribute == ProStockAttributeEnum.æå.ObjToInt()) |
| | | // .Includes(x => x.proStockInfoDetails) |
| | | // .Where(x => x.proStockInfoDetails |
| | | // .Any(v => |
| | | // v.SaleOrder==proOutOrderDetail.SaleOrder |
| | | // && v.ProductCode == proOutOrderDetail.PCode |
| | | // && v.ProductVersion == proOutOrderDetail.PVer |
| | | // && (isCanLot ? isCanLot : v.BagNo == proOutOrderDetail.PLot) |
| | | // && (isCanDate ? isCanDate : v.DateCode == proOutOrderDetail.DateCode) |
| | | // )) |
| | | // .ToList(); |
| | | //} |
| | | //else |
| | | //{ |
| | | proStockInfos = Db.Queryable<Dt_ProStockInfo>().Where(x => locationInfos.Contains(x.LocationCode) && x.ProStockAttribute == ProStockAttributeEnum.æå.ObjToInt()) |
| | | .Includes(x => x.proStockInfoDetails) |
| | | .Where(x => x.proStockInfoDetails |
| | | .Any(v => |
| | | v.ProductCode == proOutOrderDetail.PCode |
| | | && v.ProductVersion.StartsWith(proOutOrderDetail.PVer.Substring(0,1)) |
| | | && (isCanLot ? isCanLot : v.BagNo == proOutOrderDetail.PLot) |
| | | && (isCanDate ? isCanDate : v.DateCode == proOutOrderDetail.DateCode) |
| | | )) |
| | | .ToList(); |
| | | //} |
| | | proStockInfos = proStockInfos?.OrderBy(x => x.proStockInfoDetails.FirstOrDefault()?.DateCode).ThenBy(x=>x.CreateDate).ThenBy(x=>x.proStockInfoDetails.Sum(x=>x.StockPcsQty)).ToList(); |
| | | return proStockInfos; |
| | | } |
| | | /// <summary> |
| | | /// è·åMESæåºåºå(å°¾æ°ä») |
| | | /// </summary> |
| | | /// <param name="mesRworkOutboundOrder"></param> |
| | | /// <param name="locationInfos"></param> |
| | | /// <returns></returns> |
| | | public List<Dt_ProStockInfo> GetProStocks(Dt_MesRworkOutboundOrder mesRworkOutboundOrder, List<string> locationInfos) |
| | | { |
| | | List<Dt_ProStockInfo>? proStockInfos = null; |
| | | bool isCanDate = string.IsNullOrEmpty(mesRworkOutboundOrder.DateCode); |
| | | proStockInfos = Db.Queryable<Dt_ProStockInfo>().Where(x => locationInfos.Contains(x.LocationCode) && x.ProStockAttribute==ProStockAttributeEnum.å°¾æ°.ObjToInt()) |
| | | .Includes(x => x.proStockInfoDetails) |
| | | .Where(x => x.proStockInfoDetails |
| | | .Any(v => v.SaleOrder == mesRworkOutboundOrder.SaleOrder |
| | | && v.ProductCode == mesRworkOutboundOrder.ProductCode |
| | | && v.ProductVersion == mesRworkOutboundOrder.ProductVersion |
| | | && (isCanDate ? isCanDate : v.DateCode == mesRworkOutboundOrder.DateCode) |
| | | )) |
| | | .ToList(); |
| | | proStockInfos = proStockInfos.OrderBy(x => x.proStockInfoDetails.FirstOrDefault()?.DateCode).ThenBy(x => x.proStockInfoDetails.Sum(x => x.StockPcsQty)).ToList(); |
| | | return proStockInfos; |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | return content; |
| | | } |
| | | //æ¥æ¾å¯ç¨åºå |
| | | public List<Dt_ProStockInfo> GetUseableStocks(int warehoseId,Dt_ProOutOrderDetail proOutOrderDetail) |
| | | { |
| | | List<string> locationCodes = _basicRepository.LocationInfoRepository.GetCanOutLocationCodes(warehoseId); |
| | | return BaseDal.GetProStocks(proOutOrderDetail,locationCodes); |
| | | } |
| | | /// <summary> |
| | | /// MESæåºå¯ç¨åºå |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public List<Dt_ProStockInfo> GetUseableStocks(Dt_MesRworkOutboundOrder mesRworkOutboundOrder) |
| | | { |
| | | //è½¬æ¢æ æåä»ä»åºä¿¡æ¯è·åå°¾æ°å±æ§çè´§ä½ |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x=>x.WarehouseCode==WarehouseEnum.HA71.ToString()); |
| | | List<string> locationCodes = _basicRepository.LocationInfoRepository.GetCanOutLocationCodes(warehouse.WarehouseId); |
| | | return BaseDal.GetProStocks(mesRworkOutboundOrder, locationCodes); |
| | | } |
| | | /// <summary> |
| | | /// è·ååºåºåºå |
| | | /// </summary> |
| | | public List<Dt_ProStockInfo> GetOutboundStocks(List<Dt_ProStockInfo> stockInfos, Dt_ProOutOrderDetail outOrderDetail, float needQuantity, out float residueQuantity) |
| | | { |
| | | List<Dt_ProStockInfo> assignOutStocks =new List<Dt_ProStockInfo>(); |
| | | float stockTotalQuantity = stockInfos.Select(x => x.proStockInfoDetails.Sum(v => v.StockPcsQty - v.OutboundQuantity)).Sum(x => x); |
| | | //stockInfos = stockInfos.OrderBy(x => x.Id).ToList(); |
| | | bool isCanLot = string.IsNullOrEmpty(outOrderDetail.PLot); |
| | | bool isCanDate = string.IsNullOrEmpty(outOrderDetail.DateCode); |
| | | if (stockTotalQuantity >= needQuantity)//åºåå¤ |
| | | { |
| | | int index = 0; |
| | | while (needQuantity > 0) |
| | | { |
| | | Dt_ProStockInfo stockInfo = stockInfos[index]; |
| | | float useableStockQuantity = stockInfo.proStockInfoDetails |
| | | .Where(x => x.ProductCode == outOrderDetail.PCode && x.ProductVersion.StartsWith(outOrderDetail.PVer.Substring(0,1)) |
| | | && (isCanLot ? isCanLot : x.BagNo == outOrderDetail.PLot) |
| | | && (isCanDate ? isCanDate : x.DateCode == outOrderDetail.DateCode)) |
| | | .Sum(x => x.StockPcsQty - x.OutboundQuantity); |
| | | if (useableStockQuantity < needQuantity) |
| | | { |
| | | stockInfo.proStockInfoDetails.Where(x => x.ProductCode == outOrderDetail.PCode && x.ProductVersion.StartsWith(outOrderDetail.PVer.Substring(0, 1)) |
| | | && (isCanLot ? isCanLot : x.BagNo == outOrderDetail.PLot) |
| | | && (isCanDate ? isCanDate : x.DateCode == outOrderDetail.DateCode)).ToList().ForEach(x => x.OutboundQuantity = x.StockPcsQty); |
| | | needQuantity -= useableStockQuantity; |
| | | } |
| | | else |
| | | { |
| | | stockInfo.proStockInfoDetails.ForEach(x => |
| | | { |
| | | //满足æ¡ä»¶è¿è¡åé
|
| | | if ((x.StockPcsQty > x.OutboundQuantity) |
| | | && x.ProductCode == outOrderDetail.PCode && x.ProductVersion.StartsWith(outOrderDetail.PVer.Substring(0, 1)) |
| | | && (isCanLot ? isCanLot : x.BagNo == outOrderDetail.PLot) |
| | | && (isCanDate ? isCanDate : x.DateCode == outOrderDetail.DateCode)) |
| | | { |
| | | if (x.StockPcsQty - x.OutboundQuantity >= needQuantity) |
| | | { |
| | | x.OutboundQuantity += needQuantity; |
| | | needQuantity = 0; |
| | | x.OutDetailSaleNo = outOrderDetail.SaleOrder; |
| | | x.OutDetailId = outOrderDetail.Id; |
| | | } |
| | | else |
| | | { |
| | | needQuantity -= (x.StockPcsQty - x.OutboundQuantity); |
| | | x.OutboundQuantity = x.StockPcsQty; |
| | | x.OutDetailSaleNo = outOrderDetail.SaleOrder; |
| | | x.OutDetailId = outOrderDetail.Id; |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | assignOutStocks.Add(stockInfo); |
| | | index++; |
| | | } |
| | | } |
| | | #region æåå¯ç¨åºåä¸è¶³ä¸è¿è¡åé
|
| | | //else |
| | | //{ |
| | | // for (int i = 0; i < stockInfos.Count; i++) |
| | | // { |
| | | // Dt_ProStockInfo stockInfo = stockInfos[i]; |
| | | // float useableStockQuantity = stockInfo.proStockInfoDetails |
| | | // .Where(x => x.ProductCode == outOrderDetail.PCode && x.ProductVersion == outOrderDetail.PVer |
| | | // && (isCanLot ? isCanLot : x.BagNo == outOrderDetail.PLot) |
| | | // && (isCanDate ? isCanDate : x.DateCode == outOrderDetail.DateCode)) |
| | | // .Sum(x => x.StockPcsQty - x.OutboundQuantity); |
| | | // if (useableStockQuantity < needQuantity) |
| | | // { |
| | | // stockInfo.proStockInfoDetails.ForEach(x => x.OutboundQuantity = x.StockPcsQty); |
| | | // needQuantity -= useableStockQuantity; |
| | | // } |
| | | // else |
| | | // { |
| | | // stockInfo.proStockInfoDetails.ForEach(x => |
| | | // { |
| | | // if (x.StockPcsQty > x.OutboundQuantity && x.ProductCode == outOrderDetail.PCode && x.ProductVersion == outOrderDetail.PVer |
| | | // && (isCanLot ? isCanLot : x.BagNo == outOrderDetail.PLot) |
| | | // && (isCanDate ? isCanDate : x.DateCode == outOrderDetail.DateCode)) |
| | | // { |
| | | // if (x.StockPcsQty - x.OutboundQuantity >= needQuantity) |
| | | // { |
| | | // x.OutboundQuantity += needQuantity; |
| | | // needQuantity = 0; |
| | | // } |
| | | // else |
| | | // { |
| | | // needQuantity -= (x.StockPcsQty - x.OutboundQuantity); |
| | | // x.OutboundQuantity = x.StockPcsQty; |
| | | // } |
| | | // } |
| | | // }); |
| | | // } |
| | | // stockInfo.proStockInfoDetails.ForEach(x => |
| | | // { |
| | | // x.OutDetailSaleNo = outOrderDetail.SaleOrder; |
| | | // x.OutDetailId = outOrderDetail.Id; |
| | | // }); |
| | | // assignOutStocks.Add(stockInfo); |
| | | // } |
| | | //} |
| | | #endregion |
| | | residueQuantity = needQuantity; |
| | | return assignOutStocks; |
| | | } |
| | | /// <summary> |
| | | /// è·åMESæåºåºå |
| | | /// </summary> |
| | | public List<Dt_ProStockInfo> GetOutboundStocks(List<Dt_ProStockInfo> stockInfos, Dt_MesRworkOutboundOrder mesRworkOutboundOrder, float needQuantity, out float residueQuantity) |
| | | { |
| | | List<Dt_ProStockInfo> assignOutStocks = new List<Dt_ProStockInfo>(); |
| | | float stockTotalQuantity = stockInfos.Select(x => x.proStockInfoDetails.Sum(v => v.StockPcsQty - v.OutboundQuantity)).Sum(x => x); |
| | | //stockInfos = stockInfos.OrderBy(x => x.Id).ToList(); |
| | | bool isCanDate = string.IsNullOrEmpty(mesRworkOutboundOrder.DateCode); |
| | | if (stockTotalQuantity >= needQuantity)//åºåå¤ |
| | | { |
| | | int index = 0; |
| | | while (needQuantity > 0) |
| | | { |
| | | Dt_ProStockInfo stockInfo = stockInfos[index]; |
| | | float useableStockQuantity = stockInfo.proStockInfoDetails |
| | | .Where(x => x.SaleOrder == mesRworkOutboundOrder.SaleOrder |
| | | && x.ProductCode == mesRworkOutboundOrder.ProductCode |
| | | && x.ProductVersion == mesRworkOutboundOrder.ProductVersion |
| | | && (isCanDate? isCanDate: x.DateCode == mesRworkOutboundOrder.DateCode)) |
| | | .Sum(x => x.StockPcsQty - x.OutboundQuantity); |
| | | if (useableStockQuantity < needQuantity) |
| | | { |
| | | stockInfo.proStockInfoDetails.ForEach(x => x.OutboundQuantity = x.StockPcsQty); |
| | | needQuantity -= useableStockQuantity; |
| | | } |
| | | else |
| | | { |
| | | stockInfo.proStockInfoDetails.ForEach(x => |
| | | { |
| | | if ((x.StockPcsQty > x.OutboundQuantity) && x.SaleOrder == mesRworkOutboundOrder.SaleOrder |
| | | && x.ProductCode == mesRworkOutboundOrder.ProductCode |
| | | && x.ProductVersion == mesRworkOutboundOrder.ProductVersion |
| | | && (isCanDate ? isCanDate : x.DateCode == mesRworkOutboundOrder.DateCode)) |
| | | { |
| | | if (x.StockPcsQty - x.OutboundQuantity >= needQuantity) |
| | | { |
| | | x.OutboundQuantity += needQuantity; |
| | | needQuantity = 0; |
| | | } |
| | | else |
| | | { |
| | | needQuantity -= (x.StockPcsQty - x.OutboundQuantity); |
| | | x.OutboundQuantity = x.StockPcsQty; |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | assignOutStocks.Add(stockInfo); |
| | | index++; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | for (int i = 0; i < stockInfos.Count; i++) |
| | | { |
| | | Dt_ProStockInfo stockInfo = stockInfos[i]; |
| | | float useableStockQuantity = stockInfo.proStockInfoDetails |
| | | .Where(x => x.SaleOrder == mesRworkOutboundOrder.SaleOrder |
| | | && x.ProductCode == mesRworkOutboundOrder.ProductCode |
| | | && x.ProductVersion == mesRworkOutboundOrder.ProductVersion |
| | | && (isCanDate ? isCanDate : x.DateCode == mesRworkOutboundOrder.DateCode)) |
| | | .Sum(x => x.StockPcsQty - x.OutboundQuantity); |
| | | if (useableStockQuantity < needQuantity) |
| | | { |
| | | stockInfo.proStockInfoDetails.ForEach(x => x.OutboundQuantity = x.StockPcsQty); |
| | | needQuantity -= useableStockQuantity; |
| | | } |
| | | else |
| | | { |
| | | stockInfo.proStockInfoDetails.ForEach(x => |
| | | { |
| | | if (x.StockPcsQty > x.OutboundQuantity && x.SaleOrder == mesRworkOutboundOrder.SaleOrder |
| | | && x.ProductCode == mesRworkOutboundOrder.ProductCode |
| | | && x.ProductVersion == mesRworkOutboundOrder.ProductVersion |
| | | && (isCanDate ? isCanDate : x.DateCode == mesRworkOutboundOrder.DateCode)) |
| | | { |
| | | if (x.StockPcsQty - x.OutboundQuantity >= needQuantity) |
| | | { |
| | | x.OutboundQuantity += needQuantity; |
| | | needQuantity = 0; |
| | | } |
| | | else |
| | | { |
| | | needQuantity -= (x.StockPcsQty - x.OutboundQuantity); |
| | | x.OutboundQuantity = x.StockPcsQty; |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | assignOutStocks.Add(stockInfo); |
| | | } |
| | | } |
| | | residueQuantity = needQuantity; |
| | | return assignOutStocks; |
| | | } |
| | | ////å¤çåºåºåºå |
| | | //public (List<Dt_ProStockInfoDetail>?, List<Dt_ProStockInfoDetail>?) HandleOutProStock(Dt_ProStockInfo proStockInfo) |
| | | //{ |
| | | // List<Dt_ProStockInfoDetail>? deleteStockDetails = null; |
| | | // List<Dt_ProStockInfoDetail>? updateStockDetails = null; |
| | | // foreach (var item in proStockInfo.proStockInfoDetails) |
| | | // { |
| | | // if (item.StockPcsQty==item.OutboundQuantity) |
| | | // { |
| | | // item.ProOutDetailStatus = StockStatusEmun.åºåºå®æ.ObjToInt(); |
| | | // deleteStockDetails.Add(item); |
| | | // } |
| | | // else if(item.StockPcsQty> item.OutboundQuantity && item.OutboundQuantity>0) |
| | | // { |
| | | // item.StockPcsQty-=item.OutboundQuantity; |
| | | // updateStockDetails.Add(item); |
| | | // } |
| | | // } |
| | | // return (deleteStockDetails, updateStockDetails); |
| | | //} |
| | | } |
| | | } |
| | |
| | | using Magicodes.ExporterAndImporter.Core; |
| | | using WIDESEA_Core.HostedService; |
| | | using WIDESEA_Core.DB.Models; |
| | | using WIDESEA_IOutboundRepository; |
| | | using WIDESEA_IStockRepository; |
| | | using WIDESEA_Common.StockEnum; |
| | | using WIDESEA_IBasicRepository; |
| | |
| | | { |
| | | private readonly IUnitOfWorkManage _unitOfWorkManage; |
| | | private readonly SqlSugarClient _dbBase; |
| | | private readonly IOutboundRepository _outboundRepository; |
| | | private readonly IStockRepository _stockRepository; |
| | | private readonly IBasicRepository _basicRepository; |
| | | |
| | | public ProStockViewService(IUnitOfWorkManage unitOfWorkManage, IOutboundRepository outboundRepository, IStockRepository stockRepository,IBasicRepository basicRepository) |
| | | public ProStockViewService(IUnitOfWorkManage unitOfWorkManage,IStockRepository stockRepository,IBasicRepository basicRepository) |
| | | { |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | | _dbBase = unitOfWorkManage.GetDbClient(); |
| | | _outboundRepository = outboundRepository; |
| | | _stockRepository = stockRepository; |
| | | _basicRepository = basicRepository; |
| | | } |
| | |
| | | catch (Exception ex) |
| | | { |
| | | throw new Exception($"æ æéï¼{ex.Message}"); |
| | | } |
| | | } |
| | | public List<ProStockViewDTO> GetProPKSelectStocks(int orderId) |
| | | { |
| | | try |
| | | { |
| | | Dt_ProOutOrderDetail outOrderDetail = _outboundRepository.ProOutOrderDetailRepository.QueryFirst(x => x.Id == orderId); |
| | | if (outOrderDetail == null) |
| | | { |
| | | throw new Exception($"æªæ¾å°åºåºåæç»"); |
| | | } |
| | | List<ProStockViewDTO> stockViewDTOs = new List<ProStockViewDTO>(); |
| | | ISugarQueryable<Dt_ProStockInfo> sugarQueryable1 = _dbBase.Queryable<Dt_ProStockInfo>().Includes(x => x.proStockInfoDetails); |
| | | var pklist = sugarQueryable1.Where(b => b.LocationCode == "æåå¾
åè´§åº" && b.StockStatus==StockStatusEmun.å¹³åºå
¥åºå®æ.ObjToInt() && (b.ShipmentOrder==null|| b.ShipmentOrder =="")).Where(x=>x.proStockInfoDetails.Any(v=>v.ProductCode== outOrderDetail.PCode)).Select(b => new ProStockViewDTO |
| | | { |
| | | ProStockAttribute = b.ProStockAttribute, |
| | | LocationCode = b.LocationCode, |
| | | WarehouseId = b.WarehouseId, |
| | | CreateDate = b.CreateDate, |
| | | Creater = b.Creater, |
| | | LocationName = b.LocationCode, |
| | | Modifier = b.Modifier, |
| | | ModifyDate = b.ModifyDate, |
| | | PalletCode = b.PalletCode, |
| | | StockRemark = b.Remark, |
| | | ProStockId = b.Id, |
| | | StockStatus = b.StockStatus, |
| | | Details = b.proStockInfoDetails, |
| | | }); |
| | | stockViewDTOs.AddRange(pklist.ToList()); |
| | | stockViewDTOs.ForEach(x => |
| | | { |
| | | x.ProductCode = string.Join(",", x.Details.Select(x => x.ProductCode).Distinct()); |
| | | x.ProductVersion = string.Join(",", x.Details.Select(x => x.ProductVersion).Distinct()); |
| | | x.SpecifyVer = string.Join(",", x.Details.Select(x => x.SpecifyVer).Distinct()); |
| | | x.DateCode = x.Details.FirstOrDefault()?.DateCode ?? ""; |
| | | x.LotNumber = x.Details.FirstOrDefault()?.LotNumber ?? ""; |
| | | x.ERPOrder = x.Details.FirstOrDefault()?.ERPOrder ?? ""; |
| | | x.SaleOrder = x.Details.FirstOrDefault()?.SaleOrder ?? ""; |
| | | x.MoNumber = x.Details.FirstOrDefault()?.MoNumber ?? ""; |
| | | x.SumStocks = x.Details.Sum(x => x.StockPcsQty); |
| | | } |
| | | ); |
| | | return stockViewDTOs.OrderBy(x => x.DateCode).ThenBy(x => x.CreateDate).ToList(); |
| | | //return _stockRepository.ProStockInfoRepository.QueryTabs<Dt_ProStockInfo, Dt_ProStockInfoDetail, ProStockViewDTO>((a, b) => a.Id == b.ProStockId, (a, b) => new ProStockViewDTO |
| | | //{ |
| | | // LocationCode = a.LocationCode, |
| | | // ProductCode = b.ProductCode, |
| | | // ProStockAttribute = a.ProStockAttribute, |
| | | // ProductVersion=b.ProductVersion, |
| | | // DateCode=b.DateCode, |
| | | // ProStockId=a.Id, |
| | | // SumStocks=b.StockPcsQty, |
| | | // SaleOrder=b.SaleOrder, |
| | | // PalletCode = a.PalletCode, |
| | | // CreateDate=a.CreateDate, |
| | | // ERPOrder=b.ERPOrder, |
| | | // MoNumber=b.MoNumber |
| | | //}, a => a.LocationCode == "æåå¾
åè´§åº", b => b.ProductCode == outOrderDetail.PCode, x => true).GroupBy(x => x.PalletCode).Select(x => new ProStockViewDTO |
| | | //{ |
| | | // LocationCode = x.FirstOrDefault()?.LocationCode ?? "", |
| | | // ProductCode = x.FirstOrDefault()?.ProductCode ?? "", |
| | | // ProductVersion = x.FirstOrDefault()?.ProductVersion ?? "", |
| | | // DateCode = x.FirstOrDefault()?.DateCode ?? "", |
| | | // ProStockId = x.FirstOrDefault().ProStockId, |
| | | // SumStocks=x.FirstOrDefault().SumStocks, |
| | | // SaleOrder = x.FirstOrDefault()?.SaleOrder ?? "", |
| | | // ProStockAttribute=x.FirstOrDefault()?.ProStockAttribute ?? 0, |
| | | // PalletCode = x.Key, |
| | | // ERPOrder=x.FirstOrDefault()?.ERPOrder ?? "", |
| | | // MoNumber=x.FirstOrDefault()?.MoNumber ?? "", |
| | | // CreateDate=x.FirstOrDefault()?.CreateDate ?? new DateTime() |
| | | //}).ToList(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw new Exception(ex.Message); |
| | | } |
| | | } |
| | | } |
| | |
| | | using WIDESEA_Core.Helper; |
| | | using WIDESEA_DTO.Stock; |
| | | using WIDESEA_IBasicRepository; |
| | | using WIDESEA_IOutboundRepository; |
| | | using WIDESEA_IRecordRepository; |
| | | using WIDESEA_IRecordService; |
| | | using WIDESEA_IStockRepository; |
| | |
| | | { |
| | | private readonly IMapper _mapper; |
| | | private readonly IBasicRepository _basicRepository; |
| | | private readonly IOutboundRepository _outboundRepository; |
| | | |
| | | public IStockInfoRepository Repository => BaseDal; |
| | | |
| | | public StockInfoService(IStockInfoRepository BaseDal, IMapper mapper, IBasicRepository basicRepository, IOutboundRepository outboundRepository) : base(BaseDal) |
| | | public StockInfoService(IStockInfoRepository BaseDal, IMapper mapper, IBasicRepository basicRepository) : base(BaseDal) |
| | | { |
| | | _mapper = mapper; |
| | | _basicRepository = basicRepository; |
| | | _outboundRepository = outboundRepository; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ¥è¯¢è®¢åç«åºåºåè§å¾ |
| | | /// </summary> |
| | | /// <param name="orderId"></param> |
| | | /// <param name="materielCode"></param> |
| | | /// <returns></returns> |
| | | public List<StockSelectViewDTO> GetStockSelectViews(int orderId, string materielCode) |
| | | { |
| | | try |
| | | { |
| | | Dt_OutboundOrder outboundOrder = _outboundRepository.OutboundOrderRepository.QueryFirst(x => x.Id == orderId); |
| | | if (outboundOrder == null) |
| | | { |
| | | throw new Exception($"æªæ¾å°åºåºåä¿¡æ¯"); |
| | | } |
| | | |
| | | List<string> locationCodes = _basicRepository.LocationInfoRepository.PPGetCanOutLocationCodes(outboundOrder.WarehouseId); |
| | | |
| | | return BaseDal.QueryTabs<Dt_StockInfo, Dt_StockInfoDetail, StockSelectViewDTO>((a, b) => a.Id == b.StockId, (a, b) => new StockSelectViewDTO |
| | | { |
| | | LocationCode = a.LocationCode, |
| | | MaterielCode = b.MaterielCode, |
| | | MaterielName = b.MaterielName, |
| | | PalletCode = a.PalletCode, |
| | | UseableQuantity = b.StockQuantity - b.OutboundQuantity |
| | | }, a => locationCodes.Contains(a.LocationCode), b => b.StockQuantity > b.OutboundQuantity && b.MaterielCode == materielCode, x => true).GroupBy(x => x.PalletCode).Select(x => new StockSelectViewDTO |
| | | { |
| | | LocationCode = x.FirstOrDefault()?.LocationCode ?? "", |
| | | MaterielCode = x.FirstOrDefault()?.MaterielCode ?? "", |
| | | MaterielName = x.FirstOrDefault()?.MaterielName ?? "", |
| | | PalletCode = x.Key, |
| | | UseableQuantity = x.Sum(x => x.UseableQuantity) |
| | | }).ToList(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | } |
| | | /// <summary> |
| | | /// æ¥è¯¢è®¢åå¹³åºåºåè§å¾ |
| | | /// </summary> |
| | | /// <param name="orderId"></param> |
| | | /// <param name="materielCode"></param> |
| | | /// <returns></returns> |
| | | public List<StockSelectViewDTO> GetPKStockSelectViews(int orderId, string materielCode) |
| | | { |
| | | try |
| | | { |
| | | Dt_OutboundOrder outboundOrder = _outboundRepository.OutboundOrderRepository.QueryFirst(x => x.Id == orderId); |
| | | if (outboundOrder == null) |
| | | { |
| | | throw new Exception($"æªæ¾å°åºåºåä¿¡æ¯"); |
| | | } |
| | | return BaseDal.QueryTabs<Dt_StockInfo, Dt_StockInfoDetail, StockSelectViewDTO>((a, b) => a.Id == b.StockId && a.WarehouseId == outboundOrder.WarehouseId, (a, b) => new StockSelectViewDTO |
| | | { |
| | | LocationCode = a.LocationCode, |
| | | MaterielCode = b.MaterielCode, |
| | | MaterielName = b.MaterielName, |
| | | PalletCode = a.PalletCode, |
| | | UseableQuantity = b.StockQuantity - b.OutboundQuantity |
| | | }, a => a.LocationCode == "å¹³åºä½", b => b.StockQuantity > b.OutboundQuantity && b.MaterielCode == materielCode, x => true).GroupBy(x => x.PalletCode).Select(x => new StockSelectViewDTO |
| | | { |
| | | LocationCode = x.FirstOrDefault()?.LocationCode ?? "", |
| | | MaterielCode = x.FirstOrDefault()?.MaterielCode ?? "", |
| | | MaterielName = x.FirstOrDefault()?.MaterielName ?? "", |
| | | PalletCode = x.Key, |
| | | UseableQuantity = x.Sum(x => x.UseableQuantity) |
| | | }).ToList(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | |
| | | private readonly IUnitOfWorkManage _unitOfWorkManage; |
| | | private readonly ICacheService _cacheService; |
| | | private readonly IBasicRepository _basicRepository; |
| | | private readonly ISupplierInfoRepository _supplierInfoRepository; |
| | | private readonly ISys_RoleDataPermissionRepository _roleDataPermissionRepository; |
| | | |
| | | public Sys_DictionaryService(ISys_DictionaryRepository BaseDal, IUnitOfWorkManage unitOfWorkManage, ICacheService cacheService, IBasicRepository basicRepository, ISys_RoleDataPermissionRepository roleDataPermissionRepository, ISupplierInfoRepository supplierInfoRepository) : base(BaseDal) |
| | | public Sys_DictionaryService(ISys_DictionaryRepository BaseDal, IUnitOfWorkManage unitOfWorkManage, ICacheService cacheService, IBasicRepository basicRepository, ISys_RoleDataPermissionRepository roleDataPermissionRepository) : base(BaseDal) |
| | | { |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | | _cacheService = cacheService; |
| | | _basicRepository = basicRepository; |
| | | _roleDataPermissionRepository = roleDataPermissionRepository; |
| | | _supplierInfoRepository = supplierInfoRepository; |
| | | } |
| | | |
| | | public ISys_DictionaryRepository Repository => BaseDal; |
| | |
| | | foreach (var item in warehouses) |
| | | { |
| | | data.Add(new { key = item.WarehouseId, value = item.WarehouseName }); |
| | | index++; |
| | | } |
| | | } |
| | | |
| | | result = new VueDictionaryDTO { DicNo = key, Config = "", Data = data }; |
| | | } |
| | | break; |
| | | case "suppliers": |
| | | { |
| | | List<object> data = new List<object>(); |
| | | |
| | | { |
| | | List<Dt_SupplierInfo> supplierInfos = _supplierInfoRepository.QueryData(); |
| | | int index = 0; |
| | | foreach (var item in supplierInfos) |
| | | { |
| | | data.Add(new { key = item.SupplierCode, value = item.SupplierCode }); |
| | | index++; |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="roadwayNos"></param> |
| | | /// <param name="palletCode"></param> |
| | | /// <param name="heightType"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent AssignRoadwayByHeightAndCode(List<string> roadwayNos, string palletCode, int heightType = 0) |
| | | { |
| | | try |
| | | { |
| | | if (heightType == 0 || heightType > 3) |
| | | { |
| | | return WebResponseContent.Instance.Error($"é«åº¦é误"); |
| | | } |
| | | if (roadwayNos == null || roadwayNos.Count == 0) |
| | | { |
| | | return WebResponseContent.Instance.Error($"å··éä¸è½ä¸ºç©º"); |
| | | } |
| | | Dt_LocationInfo locationInfo = _basicRepository.LocationInfoRepository.QueryFirst(x => x.RoadwayNo == roadwayNos[0]); |
| | | if (locationInfo == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°å··é对åºè´§ä½"); |
| | | } |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseId == locationInfo.WarehouseId); |
| | | if (warehouse == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°å··é对åºä»åºä¿¡æ¯"); |
| | | } |
| | | |
| | | int palletType = _inboundOrderService.GetPalletType(warehouse, palletCode); |
| | | if (palletType == -1) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æçå·è§£ææçç±»åé误"); |
| | | } |
| | | |
| | | string roadwayNo = ""; |
| | | if (heightType == 1) |
| | | { |
| | | List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => (x.LocationType == palletType || x.LocationType == LocationTypeEnum.Undefined.ObjToInt()) && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && roadwayNos.Contains(x.RoadwayNo) && x.Layer <= 3).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList(); |
| | | roadwayNo = locationCounts.OrderBy(x => x.Count).FirstOrDefault()?.RoadwayNo ?? ""; |
| | | } |
| | | else if (heightType == 2) |
| | | { |
| | | List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => (x.LocationType == palletType || x.LocationType == LocationTypeEnum.Undefined.ObjToInt()) && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && roadwayNos.Contains(x.RoadwayNo) && x.Layer == 4).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList(); |
| | | roadwayNo = locationCounts.OrderBy(x => x.Count).FirstOrDefault()?.RoadwayNo ?? ""; |
| | | } |
| | | else if (heightType == 3) |
| | | { |
| | | List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => (x.LocationType == palletType || x.LocationType == LocationTypeEnum.Undefined.ObjToInt()) && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && roadwayNos.Contains(x.RoadwayNo) && x.Layer == 5).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList(); |
| | | roadwayNo = locationCounts.OrderBy(x => x.Count).FirstOrDefault()?.RoadwayNo ?? ""; |
| | | } |
| | | |
| | | return !string.IsNullOrEmpty(roadwayNo) ? WebResponseContent.Instance.OK(data: roadwayNo) : WebResponseContent.Instance.Error("æªæ¾å°å¯åé
å··é"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | public string AssignRoadwayNo(List<string> roadwayNos, string palletCode, int heightType = 0) |
| | | { |
| | | try |
| | | { |
| | | if (heightType == 0 || heightType > 3) |
| | | { |
| | | throw new Exception($"é«åº¦é误"); |
| | | } |
| | | if (roadwayNos == null || roadwayNos.Count == 0) |
| | | { |
| | | throw new Exception($"å··éä¸è½ä¸ºç©º"); |
| | | } |
| | | Dt_LocationInfo locationInfo = _basicRepository.LocationInfoRepository.QueryFirst(x => x.RoadwayNo == roadwayNos[0]); |
| | | if (locationInfo == null) |
| | | { |
| | | throw new Exception($"æªæ¾å°å··é对åºè´§ä½"); |
| | | } |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseId == locationInfo.WarehouseId); |
| | | if (warehouse == null) |
| | | { |
| | | throw new Exception($"æªæ¾å°å··é对åºä»åºä¿¡æ¯"); |
| | | } |
| | | |
| | | int palletType = _inboundOrderService.GetPalletType(warehouse, palletCode); |
| | | if (palletType == -1) |
| | | { |
| | | throw new Exception($"æçå·è§£ææçç±»åé误"); |
| | | } |
| | | |
| | | string roadwayNo = ""; |
| | | if (heightType == 1) |
| | | { |
| | | List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => (x.LocationType == palletType || x.LocationType == LocationTypeEnum.Undefined.ObjToInt()) && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && roadwayNos.Contains(x.RoadwayNo) && x.Layer <= 3).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList(); |
| | | roadwayNo = locationCounts.OrderBy(x => x.Count).FirstOrDefault()?.RoadwayNo ?? ""; |
| | | } |
| | | else if (heightType == 2) |
| | | { |
| | | List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => (x.LocationType == palletType || x.LocationType == LocationTypeEnum.Undefined.ObjToInt()) && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && roadwayNos.Contains(x.RoadwayNo) && x.Layer == 4).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList(); |
| | | roadwayNo = locationCounts.OrderBy(x => x.Count).FirstOrDefault()?.RoadwayNo ?? ""; |
| | | } |
| | | else if (heightType == 3) |
| | | { |
| | | List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => (x.LocationType == palletType || x.LocationType == LocationTypeEnum.Undefined.ObjToInt()) && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && roadwayNos.Contains(x.RoadwayNo) && x.Layer == 5).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList(); |
| | | roadwayNo = locationCounts.OrderBy(x => x.Count).FirstOrDefault()?.RoadwayNo ?? ""; |
| | | } |
| | | |
| | | return !string.IsNullOrEmpty(roadwayNo) ? ( roadwayNo) : throw new Exception("æªæ¾å°å¯åé
å··é"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | throw new Exception(ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å
¥åºä»»å¡ç³è¯·åé
è´§ä½ |
| | |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | public WebResponseContent HandSubstrateOut(int orderId) |
| | | { |
| | | try |
| | | { |
| | | Dt_MesOutboundOrder mesOutboundOrder = _outboundService.MesOutboundOrderService.Repository.QueryFirst(x => x.Id == orderId); |
| | | if (mesOutboundOrder == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°è¯¥è®¢å"); |
| | | } |
| | | |
| | | if (mesOutboundOrder.OrderStatus != OutOrderStatusEnum.æªå¼å§.ObjToInt()) |
| | | { |
| | | return WebResponseContent.Instance.Error($"该订åä¸å¯ååºåº"); |
| | | } |
| | | |
| | | List<Dt_Task> tasks = new List<Dt_Task>(); |
| | | |
| | | List<Dt_StockInfo>? stockInfos = null; |
| | | List<Dt_OutStockLockInfo>? outStockLockInfos = null; |
| | | List<Dt_LocationInfo>? locationInfos = null; |
| | | { |
| | | (List<Dt_StockInfo>, Dt_MesOutboundOrder, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outboundService.MesOutboundOrderService.AssignStockOutbound(mesOutboundOrder); |
| | | if (result.Item1 != null && result.Item1.Count > 0) |
| | | { |
| | | tasks = GetTasks(result.Item1, TaskTypeEnum.MesOutbound); |
| | | result.Item2.OrderStatus = OrderDetailStatusEnum.Outbound.ObjToInt(); |
| | | result.Item3.ForEach(x => |
| | | { |
| | | x.Status = OutLockStockStatusEnum.åºåºä¸.ObjToInt(); |
| | | }); |
| | | |
| | | stockInfos = result.Item1; |
| | | mesOutboundOrder = result.Item2; |
| | | outStockLockInfos = result.Item3; |
| | | locationInfos = result.Item4; |
| | | } |
| | | else |
| | | { |
| | | throw new Exception("æ åºå"); |
| | | } |
| | | } |
| | | |
| | | tasks.ForEach(x => |
| | | { |
| | | if (mesOutboundOrder.OrderType == MesOutboundOrderTypeEnum.HandSubstrateOut.ObjToInt()) |
| | | { |
| | | x.TaskType = TaskTypeEnum.MesHandOutbound.ObjToInt(); |
| | | } |
| | | else if (mesOutboundOrder.OrderType == MesOutboundOrderTypeEnum.HandSubstrateOutPick.ObjToInt()) |
| | | { |
| | | x.TaskType = TaskTypeEnum.MesHandPickOutbound.ObjToInt(); |
| | | } |
| | | }); |
| | | |
| | | mesOutboundOrder.OrderStatus = OutOrderStatusEnum.åºåºä¸.ObjToInt(); |
| | | |
| | | _unitOfWorkManage.BeginTran(); |
| | | |
| | | int id = BaseDal.AddData(tasks); |
| | | outStockLockInfos.ForEach(x => |
| | | { |
| | | x.OrderNo = mesOutboundOrder.TaskNo; |
| | | x.OrderDetailId = id; |
| | | }); |
| | | _outboundService.MesOutboundOrderService.Repository.UpdateData(mesOutboundOrder); |
| | | if (stockInfos != null && stockInfos.Count > 0 && outStockLockInfos != null && outStockLockInfos.Count > 0 && locationInfos != null && locationInfos.Count > 0) |
| | | { |
| | | WebResponseContent content = _outboundService.MesOutboundOrderService.LockOutboundStockDataUpdate(stockInfos, outStockLockInfos, locationInfos, tasks: tasks); |
| | | |
| | | if (!content.Status) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error(content.Message); |
| | | } |
| | | } |
| | | _unitOfWorkManage.CommitTran(); |
| | | PushTasksToWCS(tasks); |
| | | |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | public class LocationCount |
| | |
| | | public partial class TaskService |
| | | { |
| | | /// <summary> |
| | | /// MESæåå
¥åºåæ¥æ¶ |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public MesResponseContent BagInfoSync(MesBagInfoModel bagInfoModel) |
| | | { |
| | | MesResponseContent content = new MesResponseContent(); |
| | | try |
| | | { |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == bagInfoModel.WarehouseCode); |
| | | if (warehouse == null) |
| | | { |
| | | return content.Error("æªæ¾å°ä»åºä¿¡æ¯"); |
| | | } |
| | | ////éå¶ä»»å¡ |
| | | //Dt_Task task = BaseDal.QueryFirst(x => x.SourceAddress == bagInfoModel.WorkCenter && (x.TaskStatus == TaskStatusEnum.New.ObjToInt() || x.TaskStatus == TaskStatusEnum.Line_Execute.ObjToInt() || x.TaskStatus == TaskStatusEnum.Line_Executing.ObjToInt())); |
| | | //if (task!=null) |
| | | //{ |
| | | // return content.Error($"线ä½åå¨ä»»å¡ææ§è¡ä¸,è¶æ¡å·{task.PalletCode}"); |
| | | //} |
| | | Dt_Warehouse warehouseLocation = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA71.ToString()); |
| | | Dt_LocationInfo locationInfo = _basicRepository.LocationInfoRepository.QueryFirst(x => x.WarehouseId == warehouseLocation.WarehouseId); |
| | | if (locationInfo == null) |
| | | { |
| | | return content.Error($"æªæ¾å°{warehouse.WarehouseCode}è´§ä½ä¿¡æ¯"); |
| | | } |
| | | Dt_ProStockInfo proStockInfoOld = _stockRepository.ProStockInfoRepository.QueryFirst(x=>x.PalletCode==bagInfoModel.BatchNo); |
| | | if (proStockInfoOld != null) |
| | | { |
| | | return content.Error($"è¶æ¡{bagInfoModel.BatchNo}åºåä¿¡æ¯å·²åå¨"); |
| | | } |
| | | //å¤æè¯¥è¶æ¡å·çå
å
ä¿¡æ¯æ¯å¦åå¨ |
| | | Dt_MesProInOrder mesProInOrderOld = BaseDal.Db.Queryable<Dt_MesProInOrder>().Where(x => x.BatchNo == bagInfoModel.BatchNo && x.MesProStatus == InOrderStatusEnum.å
¥åºä¸.ObjToInt()).Includes(x => x.Details).First(); |
| | | if (mesProInOrderOld!=null) |
| | | { |
| | | return content.Error($"è¶æ¡{bagInfoModel.BatchNo}å
å
ä¿¡æ¯æªå®æ"); |
| | | } |
| | | List<string> proDetailsExists = _stockRepository.ProStockInfoDetailRepository.QueryData().Select(x=>x.BagNo).ToList(); |
| | | //å
å
ä¿¡æ¯ç»ç |
| | | List<Dt_MesProInOrderDetail> mesProInOrderDetails = new List<Dt_MesProInOrderDetail>(); |
| | | string palletCode = @"^C\d{5}$"; // æ£åè¡¨è¾¾å¼ |
| | | bool isValid = Regex.IsMatch(bagInfoModel.BatchNo, palletCode); |
| | | if (!isValid && bagInfoModel.BatchNo.Substring(0,3).ToUpper()!= "CPK") |
| | | { |
| | | return content.Error($"æ¡ç æ ¼å¼é误{bagInfoModel.BatchNo}"); |
| | | } |
| | | if (bagInfoModel.BatchNo.Substring(0, 3).ToUpper() == "CPK") |
| | | { |
| | | WebResponseContent inProRespone = InPKProStock(bagInfoModel, proDetailsExists, warehouse); |
| | | if (!inProRespone.Status) |
| | | { |
| | | return content.Error(inProRespone.Message); |
| | | } |
| | | _proInStatisticsService.SaveStatic(bagInfoModel); |
| | | return content.OK(inProRespone.Message); |
| | | } |
| | | |
| | | foreach (var item in bagInfoModel.BagDetails) |
| | | { |
| | | if (proDetailsExists.Contains(item.BagNo)) |
| | | { |
| | | return content.Error($"å
å
{item.BagNo}å·²åå¨"); |
| | | } |
| | | foreach (var child in item.BagItems) |
| | | { |
| | | Dt_MesProInOrderDetail mesProInOrderDetail = new Dt_MesProInOrderDetail() |
| | | { |
| | | BagNo = item.BagNo, |
| | | ProductCode = item.ProductCode, |
| | | ProductVersion = item.ProductVersion, |
| | | SETQty = child.SETQty, |
| | | OKPCSQTY = child.OKPCSQTY, |
| | | DateCode = item.DateCode, |
| | | XQty = child.XQty, |
| | | XSite = child.XSite, |
| | | Weight = item.Weight, |
| | | PackingDate = item.PackingDate, |
| | | LotNumber = child.LotNumber, |
| | | ERPOrder = child.ERPOrder, |
| | | SaleOrder = child.SaleOrder, |
| | | MoNumber = child.MoNumber, |
| | | }; |
| | | mesProInOrderDetails.Add(mesProInOrderDetail); |
| | | } |
| | | } |
| | | List<Dt_ProStockInfoDetail> proStockInfoDetails = new List<Dt_ProStockInfoDetail>(); |
| | | foreach (var item in mesProInOrderDetails) |
| | | { |
| | | proStockInfoDetails.Add(_mapper.Map<Dt_ProStockInfoDetail>(item)); |
| | | } |
| | | Dt_MesProInOrder mesProInOrder = new Dt_MesProInOrder() |
| | | { |
| | | WarehouseId = warehouse.WarehouseId, |
| | | ProInOrderNo = _outboundService.OutboundOrderService.CreateCodeByRule(nameof(RuleCodeEnum.ProInCodeRule)), |
| | | BatchNo = bagInfoModel.BatchNo, |
| | | WorkCenter = bagInfoModel.WorkCenter, |
| | | MesProStatus = InOrderStatusEnum.å
¥åºä¸.ObjToInt(), |
| | | UnPackStock = bagInfoModel.UnPackStock, |
| | | CreateType = OrderCreateTypeEnum.UpperSystemPush.ObjToInt(), |
| | | Details = mesProInOrderDetails |
| | | }; |
| | | ProStockAttributeEnum attributeEnum = new ProStockAttributeEnum(); |
| | | switch (warehouse.WarehouseCode) |
| | | { |
| | | case "HA71": |
| | | attributeEnum = ProStockAttributeEnum.æå; |
| | | break; |
| | | case "HA72": |
| | | attributeEnum = ProStockAttributeEnum.å°¾æ°; |
| | | break; |
| | | case "HA73": |
| | | attributeEnum = ProStockAttributeEnum.ç å; |
| | | break; |
| | | default: |
| | | throw new Exception("æªæ¾å°è¯¥åºå屿§"); |
| | | } |
| | | Dt_ProStockInfo proStockInfo = new Dt_ProStockInfo() |
| | | { |
| | | PalletCode = bagInfoModel.BatchNo, |
| | | PalletType = 1, |
| | | ProStockAttribute= attributeEnum.ObjToInt(), |
| | | WarehouseId = warehouse.WarehouseId, |
| | | StockStatus = StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt(), |
| | | proStockInfoDetails = proStockInfoDetails |
| | | }; |
| | | Dt_Task newTask = new Dt_Task() |
| | | { |
| | | CurrentAddress = bagInfoModel.WorkCenter, |
| | | Grade = 0, |
| | | NextAddress = "", |
| | | PalletCode = proStockInfo.PalletCode, |
| | | Roadway = locationInfo.RoadwayNo, |
| | | SourceAddress = bagInfoModel.WorkCenter, |
| | | TargetAddress = "", |
| | | TaskType = TaskTypeEnum.InProduct.ObjToInt(), |
| | | TaskStatus = TaskStatusEnum.New.ObjToInt(), |
| | | WarehouseId = warehouse.WarehouseId, |
| | | PalletType = proStockInfo.PalletType, |
| | | MaterielCode = proStockInfo.proStockInfoDetails.Where(x => x.ProStockId == proStockInfo.Id).FirstOrDefault()?.ProductCode, |
| | | Quantity = (float)proStockInfo.proStockInfoDetails.Where(x => x.ProStockId == proStockInfo.Id).Sum(x => x.StockPcsQty) |
| | | }; |
| | | _unitOfWorkManage.BeginTran(); |
| | | int taskId = BaseDal.AddData(newTask); |
| | | newTask.TaskId = taskId; |
| | | Db.InsertNav(proStockInfo).Include(x => x.proStockInfoDetails).ExecuteCommand(); |
| | | //ä¸ä¼ ERP |
| | | WebResponseContent responseContent = _inboundOrderService.FeedbackProIn(mesProInOrder); |
| | | _proInStatisticsService.SaveStatic(bagInfoModel); |
| | | if (!responseContent.Status) |
| | | { |
| | | mesProInOrder.UpErpStatus = WhetherEnum.False.ObjToInt(); |
| | | mesProInOrder.Remark = responseContent.Message; |
| | | } |
| | | else |
| | | { |
| | | mesProInOrder.UpErpStatus = WhetherEnum.True.ObjToInt(); |
| | | } |
| | | Db.InsertNav(mesProInOrder).Include(x => x.Details).ExecuteCommand(); |
| | | _unitOfWorkManage.CommitTran(); |
| | | //æ¨éä»»å¡ |
| | | PushTasksToWCS(new List<Dt_Task> { newTask }); |
| | | content.OK("æ¥æ¶æå"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | public WebResponseContent InPKProStock(MesBagInfoModel bagInfoModel, List<string> proDetailsExists,Dt_Warehouse wareSource) |
| | | { |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x=>x.WarehouseCode==WarehouseEnum.HA101.ToString()); |
| | | if (warehouse==null) |
| | | { |
| | | return WebResponseContent.Instance.Error("æªæ¾å°å¹³åºä»åºä¿¡æ¯"); |
| | | } |
| | | //å
å
ä¿¡æ¯ç»ç |
| | | List<Dt_MesProInOrderDetail> mesProInOrderDetails = new List<Dt_MesProInOrderDetail>(); |
| | | foreach (var item in bagInfoModel.BagDetails) |
| | | { |
| | | if (proDetailsExists.Contains(item.BagNo)) |
| | | { |
| | | return WebResponseContent.Instance.Error($"å
å
{item.BagNo}å·²åå¨"); |
| | | } |
| | | foreach (var child in item.BagItems) |
| | | { |
| | | Dt_MesProInOrderDetail mesProInOrderDetail = new Dt_MesProInOrderDetail() |
| | | { |
| | | BagNo = item.BagNo, |
| | | ProductCode = item.ProductCode, |
| | | ProductVersion = item.ProductVersion, |
| | | SETQty = child.SETQty, |
| | | OKPCSQTY = child.OKPCSQTY, |
| | | DateCode = item.DateCode, |
| | | XQty = child.XQty, |
| | | XSite = child.XSite, |
| | | Weight = item.Weight, |
| | | PackingDate = item.PackingDate, |
| | | LotNumber = child.LotNumber, |
| | | ERPOrder = child.ERPOrder, |
| | | SaleOrder = child.SaleOrder, |
| | | MoNumber = child.MoNumber, |
| | | OverInQuantity= child.OKPCSQTY |
| | | }; |
| | | mesProInOrderDetails.Add(mesProInOrderDetail); |
| | | } |
| | | } |
| | | List<Dt_ProStockInfoDetail> proStockInfoDetails = new List<Dt_ProStockInfoDetail>(); |
| | | foreach (var item in mesProInOrderDetails) |
| | | { |
| | | proStockInfoDetails.Add(_mapper.Map<Dt_ProStockInfoDetail>(item)); |
| | | } |
| | | Dt_MesProInOrder mesProInOrder = new Dt_MesProInOrder() |
| | | { |
| | | WarehouseId = warehouse.WarehouseId, |
| | | ProInOrderNo = _outboundService.OutboundOrderService.CreateCodeByRule(nameof(RuleCodeEnum.ProInCodeRule)), |
| | | BatchNo = bagInfoModel.BatchNo, |
| | | WorkCenter = bagInfoModel.WorkCenter, |
| | | MesProStatus = InOrderStatusEnum.å
¥åºå®æ.ObjToInt(), |
| | | UnPackStock = bagInfoModel.UnPackStock, |
| | | CreateType = OrderCreateTypeEnum.UpperSystemPush.ObjToInt(), |
| | | Details = mesProInOrderDetails |
| | | }; |
| | | ProStockAttributeEnum attributeEnum = new ProStockAttributeEnum(); |
| | | switch (wareSource.WarehouseCode) |
| | | { |
| | | case "HA71": |
| | | attributeEnum = ProStockAttributeEnum.æå; |
| | | break; |
| | | case "HA72": |
| | | attributeEnum = ProStockAttributeEnum.å°¾æ°; |
| | | break; |
| | | case "HA73": |
| | | attributeEnum = ProStockAttributeEnum.ç å; |
| | | break; |
| | | default: |
| | | throw new Exception("æªæ¾å°è¯¥åºå屿§"); |
| | | } |
| | | proStockInfoDetails.ForEach(x => |
| | | { |
| | | x.ProOutDetailStatus = StockStatusEmun.å¹³åºå
¥åºå®æ.ObjToInt(); |
| | | }); |
| | | Dt_ProStockInfo proStockInfo = new Dt_ProStockInfo() |
| | | { |
| | | PalletCode = bagInfoModel.BatchNo, |
| | | PalletType = 1, |
| | | LocationCode= "æåå¾
åè´§åº", |
| | | ProStockAttribute = attributeEnum.ObjToInt(), |
| | | WarehouseId = warehouse.WarehouseId, |
| | | StockStatus = StockStatusEmun.å¹³åºå
¥åºå®æ.ObjToInt(), |
| | | proStockInfoDetails = proStockInfoDetails |
| | | }; |
| | | |
| | | _unitOfWorkManage.BeginTran(); |
| | | Db.InsertNav(proStockInfo).Include(x => x.proStockInfoDetails).ExecuteCommand(); |
| | | //ä¸ä¼ ERP |
| | | WebResponseContent responseContent = _inboundOrderService.FeedbackProIn(mesProInOrder); |
| | | if (!responseContent.Status) |
| | | { |
| | | mesProInOrder.UpErpStatus = WhetherEnum.False.ObjToInt(); |
| | | mesProInOrder.Remark = responseContent.Message; |
| | | } |
| | | else |
| | | { |
| | | mesProInOrder.UpErpStatus = WhetherEnum.True.ObjToInt(); |
| | | } |
| | | Db.InsertNav(mesProInOrder).Include(x => x.Details).ExecuteCommand(); |
| | | _unitOfWorkManage.CommitTran(); |
| | | return WebResponseContent.Instance.OK("æ¥æ¶æå"); |
| | | } |
| | | /// <summary> |
| | | /// å¤å
ä¿¡æ¯æ¥æ¶ |
| | | /// </summary> |
| | | public MesResponseContent BoxStockin(MesBoxInfoModel boxInfoModel) |
| | | { |
| | | MesResponseContent content = new MesResponseContent(); |
| | | try |
| | | { |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA101.ToString()); |
| | | //æªååºåºåå· |
| | | string shipmentOrder = boxInfoModel.ShipmentOrder.Substring(0, boxInfoModel.ShipmentOrder.IndexOf("-")); |
| | | //夿MESä¼ å
¥çåºåºåå·æ¯å¦åå¨ |
| | | Dt_ProOutOrder proOutOrder = _outboundRepository.ProOutOrderRepository.Db.Queryable<Dt_ProOutOrder>().Where(x => x.ProOutOrderNo == shipmentOrder).Includes(x => x.Details).First(); |
| | | if (proOutOrder == null) |
| | | { |
| | | return content.Error($"åå·{shipmentOrder}ä¸åå¨"); |
| | | } |
| | | //夿å¤ç®±å·æ¯å¦å·²åå¨ |
| | | Dt_ProStockInfo ProStockOld = _stockRepository.ProStockInfoRepository.QueryFirst(x => x.PalletCode == boxInfoModel.BoxNo); |
| | | if (ProStockOld!=null) |
| | | { |
| | | return content.Error($"å¤ç®±å·{ProStockOld.PalletCode}ååºä¿¡æ¯å·²åå¨"); |
| | | } |
| | | //è·åæææååºåºå
å
ä¿¡æ¯ |
| | | List<Dt_ProStockInfoDetail> dt_ProStockInfos = _stockRepository.ProStockInfoDetailRepository.QueryData(x => x.ProOutDetailStatus == StockStatusEmun.åºåºå®æ.ObjToInt()); |
| | | //è·åMESå
å
ä¿¡æ¯ |
| | | List<Dt_MesProInOrderDetail> mesProInOrderDetails = new List<Dt_MesProInOrderDetail>(); |
| | | foreach (var item in boxInfoModel.Bags) |
| | | { |
| | | foreach (var child in item.BagItems) |
| | | { |
| | | Dt_ProStockInfoDetail? proStockInfoDetail = dt_ProStockInfos.Where(x => x.BagNo == item.BagNo)?.FirstOrDefault(); |
| | | if (proStockInfoDetail == null) |
| | | { |
| | | return content.Error($"å
å
{item.BagNo}è´§ç©ç¶æå¼å¸¸"); |
| | | } |
| | | if (proStockInfoDetail.OutboundQuantity<=0) |
| | | { |
| | | return content.Error($"å
å
{item.BagNo}åºåºæ°éæªåé
"); |
| | | } |
| | | Dt_MesProInOrderDetail mesProInOrderDetail = new Dt_MesProInOrderDetail() |
| | | { |
| | | BagNo = item.BagNo, |
| | | ProductCode = item.ProductCode, |
| | | ProductVersion = item.ProductVersion, |
| | | SETQty = child.SETQty, |
| | | OKPCSQTY = child.OKPCSQTY, |
| | | DateCode = item.DateCode, |
| | | XQty = child.XQty, |
| | | XSite = child.XSite, |
| | | Weight = item.Weight, |
| | | PackingDate = item.PackingDate, |
| | | LotNumber = child.LotNumber, |
| | | ERPOrder = child.ERPOrder, |
| | | SaleOrder = child.SaleOrder, |
| | | MoNumber = child.MoNumber, |
| | | }; |
| | | mesProInOrderDetails.Add(mesProInOrderDetail); |
| | | } |
| | | } |
| | | List<Dt_ProStockInfoDetail> proStockInfoDetails = new List<Dt_ProStockInfoDetail>(); |
| | | foreach (var item in mesProInOrderDetails) |
| | | { |
| | | proStockInfoDetails.Add(_mapper.Map<Dt_ProStockInfoDetail>(item)); |
| | | } |
| | | proStockInfoDetails.ForEach(x => |
| | | { |
| | | x.ProOutDetailStatus = StockStatusEmun.å¹³åºå
¥åºå®æ.ObjToInt(); |
| | | }); |
| | | |
| | | |
| | | _unitOfWorkManage.BeginTran(); |
| | | WebResponseContent UnBindContent = _stockService.ProStockInfoService.UnBindStock(proStockInfoDetails); |
| | | if (!UnBindContent.Status) |
| | | { |
| | | throw new Exception(UnBindContent.Message); |
| | | } |
| | | if (UnBindContent.Data!=null) |
| | | { |
| | | Dt_ProStockInfo proStockInfo = new Dt_ProStockInfo() |
| | | { |
| | | PalletCode = boxInfoModel.BoxNo, |
| | | PalletType = 0, |
| | | LocationCode = "æåå¾
åè´§åº", |
| | | WarehouseId = warehouse.WarehouseId, |
| | | ShipmentOrder = shipmentOrder, |
| | | StockStatus = StockStatusEmun.å¹³åºå
¥åºå®æ.ObjToInt(), |
| | | proStockInfoDetails = UnBindContent.Data as List<Dt_ProStockInfoDetail>, |
| | | ProStockAttribute = ProStockAttributeEnum.æå.ObjToInt() |
| | | }; |
| | | //æ ¹æ®å¤å
ä¿¡æ¯è§£ç»å
å
ä¸è¶æ¡åºåå
³ç³» |
| | | Db.InsertNav(proStockInfo).Include(x => x.proStockInfoDetails).ExecuteCommand(); |
| | | } |
| | | _unitOfWorkManage.CommitTran(); |
| | | return content.OK("å¤å
æ¥æ¶æå"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | /// <summary> |
| | | /// MESæååºåºååæ¥æ°æ®å¤ç |
| | | /// </summary> |
| | | public MesShipmentOrderSync MesOutSync(Dt_OutProStockInfo outProStockInfo, Dt_ProOutOrderDetail proOutOrderDetail,List<Dt_ProStockInfoDetail> proStockInfoDetails) |
| | | { |
| | | List<MesShipOrderDetail> mesShipOrderDetails = new List<MesShipOrderDetail>(); |
| | | //è·ååºåºå |
| | | Dt_ProOutOrder proOutOrder = _outboundService.ProOutOrderService.Repository.QueryFirst(x => x.Id == proOutOrderDetail.ProOrderId); |
| | | //è·åå®¢æ· |
| | | Dt_CustomerInfo customerInfo = _basicRepository.CustomerInfoRepository.QueryFirst(x => x.Code == proOutOrderDetail.EndCustomer); |
| | | List<string> outBags = proStockInfoDetails.Where(x => x.OutboundQuantity > 0).Select(x => x.BagNo).ToList(); |
| | | outBags.ForEach(x => |
| | | { |
| | | x = string.Format($"{0},{1},{2},0,{3}",x,outProStockInfo.PCode,outProStockInfo.DateCode,outProStockInfo.AssignQuantity.ObjToInt()); |
| | | }); |
| | | MesShipOrderDetail orderDetail = new MesShipOrderDetail() |
| | | { |
| | | ProductCode = proOutOrderDetail.PCode, |
| | | ProductVersion = proOutOrderDetail.PVer, |
| | | Qty = outProStockInfo.AssignQuantity, |
| | | DateCode = outProStockInfo.DateCode, |
| | | SaleOrder = proOutOrderDetail.SaleOrder, |
| | | Sequence = outProStockInfo.Id, |
| | | WorkCenter = "SPCK_OUTER-001", |
| | | PlasticBox = new List<PlasticBox> { new PlasticBox() |
| | | { |
| | | PlasticBoxNumber= outProStockInfo.PalletCode, |
| | | Insourcings = outBags |
| | | } |
| | | } |
| | | }; |
| | | mesShipOrderDetails.Add(orderDetail); |
| | | MesShipmentOrderSync shipmentOrderSync = new MesShipmentOrderSync() |
| | | { |
| | | ShipmentOrder = proOutOrder.ProOutOrderNo+"-"+ outProStockInfo.TaskNum, |
| | | PlantShipDate = proOutOrder.PlantShipDate.ToString("yyyy-MM-dd HH:mm:ss"), |
| | | Customer = proOutOrderDetail.EndCustomer, |
| | | FactoryCode = proOutOrderDetail.FactoryCode, |
| | | ShipName = customerInfo.Name, |
| | | ShippingAddress = customerInfo.NickName, |
| | | OrderDetails = mesShipOrderDetails |
| | | }; |
| | | return shipmentOrderSync; |
| | | } |
| | | /// <summary> |
| | | /// WMS忥æååºåºè³MES |
| | | /// </summary> |
| | | public WebResponseContent ShipmentOrderSync(MesShipmentOrderSync model) |
| | |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// MESæåè¿å·¥æåº |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | public MesResponseContent RworkTask(RworkTaskModel model) |
| | | { |
| | | MesResponseContent content = new MesResponseContent(); |
| | | try |
| | | { |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA72.ToString()); |
| | | if (warehouse == null) |
| | | { |
| | | return content.Error($"å°¾æ°ä»ä¿¡æ¯æªé
ç½®"); |
| | | } |
| | | Dt_MesRworkOutboundOrder rworkOutboundOrderOld = _outboundRepository.RworkOutboundOrderRepository.QueryFirst(x => x.TaskNo == model.TaskNo); |
| | | if (rworkOutboundOrderOld != null) |
| | | { |
| | | return content.Error($"æåºä»»å¡å{model.TaskNo}å·²åå¨"); |
| | | } |
| | | Dt_MesRworkOutboundOrder mesRworkOutboundOrder = new Dt_MesRworkOutboundOrder() |
| | | { |
| | | WarehouseId = warehouse.WarehouseId, |
| | | TaskNo = model.TaskNo, |
| | | OrderStatus = OutOrderStatusEnum.æªå¼å§.ObjToInt(), |
| | | CreateType = OrderCreateTypeEnum.UpperSystemPush.ObjToInt(), |
| | | ProductCode = model.ProductCode, |
| | | ProductName = model.ProductName, |
| | | ProductVersion = model.ProductVersion, |
| | | DateCode = model.DateCode, |
| | | RequiredQuantity = model.RequiredQuantity, |
| | | FactoryCode = model.FactoryCode, |
| | | SaleOrder = model.SaleOrder, |
| | | OrderType = model.InventoryType |
| | | }; |
| | | List<Dt_Task> tasks = new List<Dt_Task>(); |
| | | List<Dt_ProStockInfo>? proStockInfos = null; |
| | | List<Dt_OutProStockInfo>? outProStockInfos = null; |
| | | List<Dt_LocationInfo>? locationInfos = null; |
| | | //åé
åºåçææåºä»»å¡ |
| | | (List<Dt_ProStockInfo>?, Dt_MesRworkOutboundOrder?, List<Dt_OutProStockInfo>?, List<Dt_LocationInfo>) result = _outboundService.RworkOutboundOrderService.AssignMesStocks(mesRworkOutboundOrder); |
| | | if (result.Item1 != null && result.Item1.Count > 0) |
| | | { |
| | | tasks = GetTasks(result.Item1, TaskTypeEnum.OutMesRworkProduct); |
| | | result.Item2.OrderStatus = OutOrderStatusEnum.åºåºä¸.ObjToInt(); |
| | | result.Item3.ForEach(x => |
| | | { |
| | | x.Status = OutLockStockStatusEnum.åºåºä¸.ObjToInt(); |
| | | }); |
| | | |
| | | proStockInfos = result.Item1; |
| | | mesRworkOutboundOrder = result.Item2; |
| | | outProStockInfos = result.Item3; |
| | | locationInfos = result.Item4; |
| | | } |
| | | else |
| | | { |
| | | throw new Exception("æ åºååé
"); |
| | | } |
| | | tasks.ForEach(x => |
| | | { |
| | | x.TargetAddress = "5236"; |
| | | x.OrderNo = mesRworkOutboundOrder.TaskNo; |
| | | }); |
| | | _unitOfWorkManage.BeginTran(); |
| | | |
| | | int id = BaseDal.AddData(tasks); |
| | | outProStockInfos.ForEach(x => |
| | | { |
| | | x.OrderNo = mesRworkOutboundOrder.TaskNo; |
| | | x.OrderDetailId = id; |
| | | }); |
| | | if (proStockInfos != null && proStockInfos.Count > 0 && outProStockInfos != null && outProStockInfos.Count > 0 && locationInfos != null && locationInfos.Count > 0) |
| | | { |
| | | WebResponseContent updateContent = _outboundService.RworkOutboundOrderService.LockOutboundStockDataUpdate(proStockInfos, outProStockInfos, locationInfos, tasks: tasks); |
| | | |
| | | if (!updateContent.Status) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return content.Error(updateContent.Message); |
| | | } |
| | | } |
| | | _outboundService.RworkOutboundOrderService.Repository.AddData(mesRworkOutboundOrder); |
| | | _unitOfWorkManage.CommitTran(); |
| | | return content.OK("æä¾è¿åºåæ¥æ¶æå"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | #region å¼ç¨ |
| | | /// <summary> |
| | | /// åºåæ¿æ°æ®è½¬æ¢ |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | //public MesProductOutBound MesProOutBound(Dt_MesRworkOutboundOrder mesRworkOutboundOrder,List<Dt_ProStockInfoDetail> proStockInfoDetails) |
| | | //{ |
| | | // //è·åä»åºä¿¡æ¯ |
| | | // Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseId == mesRworkOutboundOrder.WarehouseId); |
| | | // List<MesInventoryInfo> inventoryInfos = new List<MesInventoryInfo>(); |
| | | // foreach (var item in proStockInfoDetails) |
| | | // { |
| | | // MesInventoryInfo mesInventoryInfo = new MesInventoryInfo() |
| | | // { |
| | | // Warhouseno = warehouse.WarehouseCode, |
| | | // InternalPackageNumber = item.BagNo, |
| | | // SetCount = (int)item.SETQty, |
| | | // EligiblePcsCount = (int)item.StockPcsQty |
| | | // }; |
| | | // inventoryInfos.Add(mesInventoryInfo); |
| | | // } |
| | | // MesProductOutBound mesProductOutBound = new MesProductOutBound() |
| | | // { |
| | | // TaskNo = mesRworkOutboundOrder.TaskNo, |
| | | // ProductCode = mesRworkOutboundOrder.ProductCode, |
| | | // ProductVersion = mesRworkOutboundOrder.ProductVersion, |
| | | // DateCode = mesRworkOutboundOrder.DateCode, |
| | | // SaleOrder = mesRworkOutboundOrder.SaleOrder, |
| | | // InventoryInfo = inventoryInfos |
| | | // }; |
| | | // return mesProductOutBound; |
| | | //} |
| | | #endregion |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// åºæ¿åºåº |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | public MesResponseContent SubstrateOut(SubstrateOutModel model) |
| | | { |
| | | try |
| | | { |
| | | string line = string.Empty; |
| | | if (!model.Line.Contains("SCUTL")) |
| | | { |
| | | line = WarehouseEnum.HA58.ToString(); |
| | | } |
| | | else |
| | | { |
| | | line = WarehouseEnum.HA57.ToString(); |
| | | } |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == line); |
| | | if (warehouse == null) |
| | | { |
| | | return MesResponseContent.Instance.Error($"ä»åºåºç¡ä¿¡æ¯æªé
ç½®"); |
| | | } |
| | | |
| | | Dt_MaterielInfo materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterielCode == model.MaterialCode); |
| | | if (materielInfo == null) |
| | | { |
| | | return MesResponseContent.Instance.Error($"æªæ¾å°è¯¥ç©æä¿¡æ¯"); |
| | | } |
| | | |
| | | Dt_MesOutboundOrder mesOutboundOrder = new Dt_MesOutboundOrder() |
| | | { |
| | | CreateType = OrderCreateTypeEnum.UpperSystemPush.ObjToInt(), |
| | | Line = model.Line, |
| | | MaterialCode = model.MaterialCode, |
| | | MaterialName = model.MaterialName, |
| | | OrderQuantity = model.RequiredQuantity, |
| | | TaskNo = model.TaskNo, |
| | | Unit = model.Unit, |
| | | OrderType = MesOutboundOrderTypeEnum.SubstrateOut.ObjToInt(), |
| | | OrderStatus = OutOrderStatusEnum.æªå¼å§.ObjToInt(), |
| | | WarehouseId = warehouse.WarehouseId |
| | | }; |
| | | |
| | | List<Dt_Task> tasks = new List<Dt_Task>(); |
| | | |
| | | List<Dt_StockInfo>? stockInfos = null; |
| | | List<Dt_OutStockLockInfo>? outStockLockInfos = null; |
| | | List<Dt_LocationInfo>? locationInfos = null; |
| | | { |
| | | (List<Dt_StockInfo>, Dt_MesOutboundOrder, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outboundService.MesOutboundOrderService.AssignStockOutbound(mesOutboundOrder); |
| | | if (result.Item1 != null && result.Item1.Count > 0) |
| | | { |
| | | tasks = GetTasks(result.Item1, TaskTypeEnum.MesOutbound); |
| | | result.Item2.OrderStatus = OrderDetailStatusEnum.Outbound.ObjToInt(); |
| | | result.Item3.ForEach(x => |
| | | { |
| | | x.Status = OutLockStockStatusEnum.åºåºä¸.ObjToInt(); |
| | | }); |
| | | |
| | | stockInfos = result.Item1; |
| | | mesOutboundOrder = result.Item2; |
| | | outStockLockInfos = result.Item3; |
| | | locationInfos = result.Item4; |
| | | } |
| | | else |
| | | { |
| | | throw new Exception("æ åºå"); |
| | | } |
| | | } |
| | | tasks.ForEach(x => |
| | | { |
| | | x.TargetAddress = model.Line; |
| | | x.OrderNo = mesOutboundOrder.TaskNo; |
| | | }); |
| | | _unitOfWorkManage.BeginTran(); |
| | | |
| | | int id = BaseDal.AddData(tasks); |
| | | outStockLockInfos.ForEach(x => |
| | | { |
| | | x.OrderNo = mesOutboundOrder.TaskNo; |
| | | x.OrderDetailId = id; |
| | | }); |
| | | _outboundService.MesOutboundOrderService.Repository.AddData(mesOutboundOrder); |
| | | if (stockInfos != null && stockInfos.Count > 0 && outStockLockInfos != null && outStockLockInfos.Count > 0 && locationInfos != null && locationInfos.Count > 0) |
| | | { |
| | | WebResponseContent content = _outboundService.MesOutboundOrderService.LockOutboundStockDataUpdate(stockInfos, outStockLockInfos, locationInfos, tasks: tasks); |
| | | |
| | | if (!content.Status) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return MesResponseContent.Instance.Error(content.Message); |
| | | } |
| | | } |
| | | _unitOfWorkManage.CommitTran(); |
| | | PushTasksToWCS(tasks); |
| | | |
| | | |
| | | return MesResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return MesResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// åºæ¿ä½æéåº |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | |
| | | using WIDESEA_External.Model; |
| | | using WIDESEA_IBasicRepository; |
| | | using WIDESEA_IBasicService; |
| | | using WIDESEA_IInboundRepository; |
| | | using WIDESEA_IInboundService; |
| | | using WIDESEA_IOutboundRepository; |
| | | using WIDESEA_IOutboundService; |
| | | using WIDESEA_IRecordService; |
| | | using WIDESEA_IStockRepository; |
| | | using WIDESEA_IStockService; |
| | | using WIDESEA_ITaskInfoRepository; |
| | | using WIDESEA_ITaskInfoService; |
| | | using WIDESEA_Model.Models; |
| | | using WIDESEA_OutboundRepository; |
| | | using WIDESEA_TaskInfoRepository; |
| | | |
| | | namespace WIDESEA_TaskInfoService |
| | |
| | | private readonly IStockRepository _stockRepository; |
| | | private readonly IBasicService _basicService; |
| | | private readonly IRecordService _recordService; |
| | | private readonly IOutboundService _outboundService; |
| | | private readonly IStockService _stockService; |
| | | private readonly IBasicRepository _basicRepository; |
| | | private readonly IApiInfoRepository _apiInfoRepository; |
| | | private readonly IInvokeERPService _invokeERPService; |
| | | private readonly IInboundRepository _inboundRepository; |
| | | private readonly IInboundOrderService _inboundOrderService; |
| | | private readonly IPalletTypeInfoRepository _palletTypeInfoRepository; |
| | | private readonly IOutProStockInfoRepository _outProStockInfoRepository; |
| | | private readonly IOutboundRepository _outboundRepository; |
| | | private readonly IProInStatisticsRepository _proInStatisticsRepository; |
| | | private readonly IProInStatisticsService _proInStatisticsService; |
| | | public ITaskRepository Repository => BaseDal; |
| | | |
| | | private Dictionary<string, OrderByType> _taskOrderBy = new() |
| | |
| | | |
| | | public List<int> TaskOutboundTypes => typeof(TaskTypeEnum).GetEnumIndexList(); |
| | | |
| | | public TaskService(ITaskRepository BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IStockRepository stockRepository, IBasicService basicService, IRecordService recordService, IOutboundService outboundService, IStockService stockService, IBasicRepository basicRepository, IApiInfoRepository apiInfoRepository, IInvokeERPService invokeERPService, IInboundRepository inboundRepository, IInboundOrderService inboundOrderService, IPalletTypeInfoRepository palletTypeInfoRepository, IOutProStockInfoRepository outProStockInfoRepository, IOutboundRepository outboundRepository, IProInStatisticsRepository proInStatisticsRepository, IProInStatisticsService proInStatisticsService) : base(BaseDal) |
| | | public TaskService(ITaskRepository BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IStockRepository stockRepository, IBasicService basicService, IRecordService recordService, IStockService stockService, IBasicRepository basicRepository, IApiInfoRepository apiInfoRepository, IInvokeERPService invokeERPService, IPalletTypeInfoRepository palletTypeInfoRepository) : base(BaseDal) |
| | | { |
| | | _mapper = mapper; |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | | _stockRepository = stockRepository; |
| | | _basicService = basicService; |
| | | _recordService = recordService; |
| | | _outboundService = outboundService; |
| | | _stockService = stockService; |
| | | _basicRepository = basicRepository; |
| | | _apiInfoRepository = apiInfoRepository; |
| | | _invokeERPService = invokeERPService; |
| | | _inboundRepository = inboundRepository; |
| | | _inboundOrderService = inboundOrderService; |
| | | _palletTypeInfoRepository = palletTypeInfoRepository; |
| | | _outProStockInfoRepository = outProStockInfoRepository; |
| | | _outboundRepository = outboundRepository; |
| | | _proInStatisticsRepository = proInStatisticsRepository; |
| | | _proInStatisticsService = proInStatisticsService; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å
¥åºä»»å¡å®æ |
| | | /// </summary> |
| | | /// <param name="taskNum">ä»»å¡å·</param> |
| | | /// <returns></returns> |
| | | public WebResponseContent InboundTaskCompleted(int taskNum) |
| | | { |
| | | try |
| | | { |
| | | Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum); |
| | | if (task == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°è¯¥ä»»å¡ä¿¡æ¯"); |
| | | } |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseId == task.WarehouseId); |
| | | if (warehouse.WarehouseType==WarehouseTypEnum.æå.ToString()) |
| | | { |
| | | return InProductCompleted(task); |
| | | } |
| | | Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == task.PalletCode && x.WarehouseId == task.WarehouseId).Includes(x => x.Details).First(); |
| | | if (stockInfo == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°æç对åºçç»çä¿¡æ¯"); |
| | | } |
| | | |
| | | if (!string.IsNullOrEmpty(stockInfo.LocationCode)) |
| | | { |
| | | return WebResponseContent.Instance.Error($"该æçå·²ç»å®è´§ä½"); |
| | | } |
| | | |
| | | if (stockInfo.Details.Count == 0 && stockInfo.PalletType != PalletTypeEnum.Empty.ObjToInt()) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°è¯¥æçåºåæç»ä¿¡æ¯"); |
| | | } |
| | | #region 空æéåº |
| | | if (task.TaskType == TaskTypeEnum.MesPalletLargeReturn.ObjToInt() || task.TaskType == TaskTypeEnum.MesPalletSmallReturn.ObjToInt()) |
| | | { |
| | | task.TaskStatus = TaskStatusEnum.Finish.ObjToInt(); |
| | | _unitOfWorkManage.BeginTran(); |
| | | BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? OperateTypeEnum.äººå·¥å®æ : OperateTypeEnum.èªå¨å®æ); |
| | | _stockService.StockInfoService.Repository.DeleteAndMoveIntoHty(stockInfo, App.User.UserId == 0 ? OperateTypeEnum.èªå¨å®æ : OperateTypeEnum.äººå·¥å®æ); |
| | | _stockService.StockInfoDetailService.Repository.DeleteAndMoveIntoHty(stockInfo.Details, App.User.UserId == 0 ? OperateTypeEnum.èªå¨å®æ : OperateTypeEnum.äººå·¥å®æ); |
| | | _unitOfWorkManage.CommitTran(); |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | #endregion |
| | | Dt_LocationInfo locationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress); |
| | | if (locationInfo == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°ç®æ è´§ä½ä¿¡æ¯"); |
| | | } |
| | | |
| | | if (locationInfo.LocationStatus == LocationStatusEnum.InStock.ObjToInt()) |
| | | { |
| | | return WebResponseContent.Instance.Error($"è´§ä½ç¶æä¸æ£ç¡®"); |
| | | } |
| | | |
| | | LocationStatusEnum lastStatus = (LocationStatusEnum)locationInfo.LocationStatus; |
| | | locationInfo.LocationStatus = LocationStatusEnum.InStock.ObjToInt(); |
| | | |
| | | stockInfo.LocationCode = locationInfo.LocationCode; |
| | | #region 空箱å
¥åº/æ£éååº/çäº§éæ |
| | | if (task.TaskType == TaskTypeEnum.InEmpty.ObjToInt() || task.TaskType == TaskTypeEnum.InPick.ObjToInt() || (task.TaskType == TaskTypeEnum.ProductionReturn.ObjToInt() && warehouse.WarehouseCode == WarehouseEnum.HA64.ToString())) |
| | | { |
| | | stockInfo.StockStatus = StockStatusEmun.å
¥åºå®æ.ObjToInt(); |
| | | task.TaskStatus = TaskStatusEnum.Finish.ObjToInt(); |
| | | stockInfo.Details.ForEach(x => |
| | | { |
| | | x.Status = StockStatusEmun.å
¥åºå®æ.ObjToInt(); |
| | | }); |
| | | _unitOfWorkManage.BeginTran(); |
| | | BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? OperateTypeEnum.äººå·¥å®æ : OperateTypeEnum.èªå¨å®æ); |
| | | _basicService.LocationInfoService.UpdateLocationStatus(locationInfo, stockInfo.PalletType, LocationStatusEnum.InStock, stockInfo.WarehouseId); |
| | | _stockRepository.StockInfoRepository.UpdateData(stockInfo); |
| | | _stockRepository.StockInfoDetailRepository.UpdateData(stockInfo.Details); |
| | | _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, lastStatus, LocationStatusEnum.InStock, LocationChangeType.InboundCompleted); |
| | | _unitOfWorkManage.CommitTran(); |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | #endregion |
| | | |
| | | Dt_InboundOrder? inboundOrder = _inboundRepository.InboundOrderRepository.Db.Queryable<Dt_InboundOrder>().Where(x => x.InboundOrderNo == stockInfo.Details.FirstOrDefault().OrderNo).Includes(x => x.Details).First(); |
| | | Dt_InboundOrderDetail? inboundOrderDetail = null; |
| | | Dt_ReturnOrder? returnOrder = null; |
| | | //æ åå
¥åºæµç¨æ¥æ¾å
¥åºåæ® |
| | | if (inboundOrder != null && stockInfo.StockStatus == StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt()) |
| | | { |
| | | //æ¥è¯¢å宿çå
¥åºæç»æ°é |
| | | int overCount = inboundOrder.Details.Where(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()).ToList().Count; |
| | | inboundOrderDetail = inboundOrder.Details.FirstOrDefault(x => x.RowNo == stockInfo.Details.FirstOrDefault()?.InboundOrderRowNo); |
| | | foreach (var item in stockInfo.Details) |
| | | { |
| | | if (inboundOrderDetail == null) |
| | | { |
| | | continue; |
| | | } |
| | | inboundOrderDetail.OverInQuantity += item.StockQuantity; |
| | | if (inboundOrderDetail.OverInQuantity == inboundOrderDetail.OrderQuantity) |
| | | { |
| | | inboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt(); |
| | | overCount += 1; |
| | | } |
| | | else if (inboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.New.ObjToInt()) |
| | | { |
| | | inboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.Inbounding.ObjToInt(); |
| | | } |
| | | } |
| | | if (inboundOrder.Details.Count == overCount) |
| | | { |
| | | inboundOrder.OrderStatus = InOrderStatusEnum.å
¥åºå®æ.ObjToInt(); |
| | | //夿æ¯å¦ä¸ºéæå
¥åºå |
| | | if (inboundOrder.OrderType == InOrderTypeEnum.Return.ObjToInt()) |
| | | { |
| | | returnOrder = _inboundRepository.ReturnOrderRepository.Db.Queryable<Dt_ReturnOrder>().Where(x => x.OrderNo == inboundOrder.UpperOrderNo).Includes(x => x.Details).First(); |
| | | returnOrder.ReturnOrderStatus = ReturnOrderStatusEnum.Returned.ObjToInt(); |
| | | foreach (var item in inboundOrder.Details) |
| | | { |
| | | Dt_ReturnOrderDetail returnOrderDetail = returnOrder.Details?.FirstOrDefault(x => x.MCode == item.MaterielCode); |
| | | if (returnOrderDetail != null) |
| | | { |
| | | returnOrderDetail.OverReturnQty = item.OverInQuantity; |
| | | returnOrderDetail.OrderDetailStatus = ReturnOrderStatusEnum.Returned.ObjToInt(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | else if (inboundOrder.OrderStatus == InOrderStatusEnum.æªå¼å§.ObjToInt()) |
| | | { |
| | | inboundOrder.OrderStatus = InOrderStatusEnum.å
¥åºä¸.ObjToInt(); |
| | | } |
| | | } |
| | | if ((stockInfo.StockStatus == StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt() || stockInfo.StockStatus == StockStatusEmun.æå¨ç»çå
¥åºç¡®è®¤.ObjToInt()) && warehouse.WarehouseCode == WarehouseEnum.HA64.ToString()) |
| | | { |
| | | foreach (var model in stockInfo.Details) |
| | | { |
| | | TestSynStock(new TestToolSynInfo() { ToolCode = model.BatchNo, MaterialName = model.MaterielName, Life = int.TryParse(model.Remark, out int val) ? val : 1000 }); |
| | | } |
| | | } |
| | | //æµè¯æ¶å
¥åºåºåç¶æ |
| | | if (task.TaskType == TaskTypeEnum.Inbound.ObjToInt() && warehouse.WarehouseCode == WarehouseEnum.HA64.ToString() && stockInfo.StockStatus != StockStatusEmun.æå¨ç»çå
¥åºç¡®è®¤.ObjToInt()) |
| | | { |
| | | stockInfo.StockStatus = StockStatusEmun.å
¥åºå®ææªå»ºåºåºå.ObjToInt(); |
| | | } |
| | | else |
| | | { |
| | | stockInfo.StockStatus = StockStatusEmun.å
¥åºå®æ.ObjToInt(); |
| | | } |
| | | stockInfo.Details.ForEach(x => |
| | | { |
| | | x.Status = StockStatusEmun.å
¥åºå®æ.ObjToInt(); |
| | | }); |
| | | //æ´æ°ä»»å¡ç¶æ |
| | | task.TaskStatus = TaskStatusEnum.Finish.ObjToInt(); |
| | | FeedBackWCSTaskCompleted(taskNum); |
| | | _unitOfWorkManage.BeginTran(); |
| | | BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? OperateTypeEnum.äººå·¥å®æ : OperateTypeEnum.èªå¨å®æ); |
| | | _basicService.LocationInfoService.UpdateLocationStatus(locationInfo, stockInfo.PalletType, LocationStatusEnum.InStock, stockInfo.WarehouseId); |
| | | _stockRepository.StockInfoRepository.UpdateData(stockInfo); |
| | | _stockRepository.StockInfoDetailRepository.UpdateData(stockInfo.Details); |
| | | _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, lastStatus, LocationStatusEnum.InStock, LocationChangeType.InboundCompleted); |
| | | _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, stockInfo.Details, stockInfo.Details.Sum(x => x.StockQuantity), stockInfo.Details.Sum(x => x.StockQuantity), StockChangeTypeEnum.Inbound, taskNum); |
| | | if (inboundOrder != null && inboundOrderDetail != null) |
| | | { |
| | | _inboundRepository.InboundOrderRepository.UpdateData(inboundOrder); |
| | | _inboundRepository.InboundOrderDetailRepository.UpdateData(inboundOrderDetail); |
| | | } |
| | | if (returnOrder != null) |
| | | { |
| | | _inboundRepository.ReturnOrderRepository.UpdateData(returnOrder); |
| | | _inboundRepository.ReturnOrderDetailRepository.UpdateData(returnOrder.Details); |
| | | } |
| | | _unitOfWorkManage.CommitTran(); |
| | | //åå¨å
¥åºåå¹¶ç¶æä¸ºå®æç¶ææ¨éè³ERP |
| | | if (inboundOrder != null && inboundOrder.OrderStatus == InOrderStatusEnum.å
¥åºå®æ.ObjToInt() && inboundOrder.OrderType != InOrderTypeEnum.Allocat.ObjToInt()) |
| | | { |
| | | if (inboundOrder.OrderType == InOrderTypeEnum.Return.ObjToInt() && returnOrder!=null) |
| | | { |
| | | _inboundOrderService.FeedbackReturnOrder(inboundOrder, returnOrder); |
| | | } |
| | | else if(inboundOrderDetail != null) |
| | | { |
| | | _inboundOrderService.FeedbackInboundOrder(inboundOrder.Id); |
| | | } |
| | | } |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// æåä»å
¥åºä»»å¡å®æ |
| | | /// </summary> |
| | | public WebResponseContent InProductCompleted(Dt_Task task) |
| | |
| | | { |
| | | case (int)TaskTypeEnum.EmptyProductBack: |
| | | content = EmptyProBackCompleted(task); |
| | | break; |
| | | case (int)TaskTypeEnum.InProduct: |
| | | content = InProCompleted(task); |
| | | break; |
| | | case (int)TaskTypeEnum.InProductBack: |
| | | content = InProBackCompleted(task); |
| | |
| | | _unitOfWorkManage.BeginTran(); |
| | | BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? OperateTypeEnum.äººå·¥å®æ : OperateTypeEnum.èªå¨å®æ); |
| | | _unitOfWorkManage.CommitTran(); |
| | | content.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | /// <summary> |
| | | /// MESå
å
å
¥åºä»»å¡å®æ |
| | | /// </summary> |
| | | /// <param name="task"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent InProCompleted(Dt_Task task) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | //è·åç»çä¿¡æ¯ |
| | | Dt_ProStockInfo proStockInfo = _stockRepository.ProStockInfoRepository.Db.Queryable<Dt_ProStockInfo>().Where(x => x.PalletCode == task.PalletCode).Includes(x => x.proStockInfoDetails).First(); |
| | | if (proStockInfo == null) |
| | | { |
| | | return content.Error($"æªæ¾å°è¶æ¡ä¸º{task.PalletCode}ç»çä¿¡æ¯"); |
| | | } |
| | | Dt_LocationInfo locationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress); |
| | | if (locationInfo == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°ç®æ è´§ä½ä¿¡æ¯"); |
| | | } |
| | | if (locationInfo.LocationStatus == LocationStatusEnum.InStock.ObjToInt()) |
| | | { |
| | | return WebResponseContent.Instance.Error($"è´§ä½ç¶æä¸æ£ç¡®"); |
| | | } |
| | | LocationStatusEnum lastStatus = (LocationStatusEnum)locationInfo.LocationStatus; |
| | | locationInfo.LocationStatus = LocationStatusEnum.InStock.ObjToInt(); |
| | | proStockInfo.LocationCode = locationInfo.LocationCode; |
| | | //è·åMESå
¥åºåæ® |
| | | Dt_MesProInOrder mesProInOrder = _inboundRepository.MesProInOrderRepository.Db.Queryable<Dt_MesProInOrder>().Where(x => x.BatchNo == task.PalletCode && x.MesProStatus == InOrderStatusEnum.å
¥åºä¸.ObjToInt()).Includes(x => x.Details).OrderByDescending(x => x.Id).First(); |
| | | if (mesProInOrder == null || mesProInOrder.Details == null || mesProInOrder.Details.Count <= 0) |
| | | { |
| | | return content.Error("æªæ¾å°MESå
å
åæ®ä¿¡æ¯"); |
| | | } |
| | | //è¿è¡åæ®å¤ç |
| | | mesProInOrder.MesProStatus = InOrderStatusEnum.å
¥åºå®æ.ObjToInt(); |
| | | mesProInOrder.Details.ForEach(x => |
| | | { |
| | | x.OverInQuantity = x.OKPCSQTY; |
| | | }); |
| | | proStockInfo.StockStatus = StockStatusEmun.å
¥åºå®æ.ObjToInt(); |
| | | proStockInfo.proStockInfoDetails.ForEach(x => |
| | | { |
| | | x.ProOutDetailStatus = StockStatusEmun.å
¥åºå®æ.ObjToInt(); |
| | | }); |
| | | //æ´æ°å
¥åºç¶æ |
| | | task.TaskStatus = TaskStatusEnum.Finish.ObjToInt(); |
| | | _unitOfWorkManage.BeginTran(); |
| | | BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? OperateTypeEnum.äººå·¥å®æ : OperateTypeEnum.èªå¨å®æ); |
| | | _basicService.LocationInfoService.UpdateLocationStatus(locationInfo, proStockInfo.PalletType, LocationStatusEnum.InStock, locationInfo.WarehouseId); |
| | | _stockRepository.ProStockInfoRepository.UpdateData(proStockInfo); |
| | | _stockRepository.ProStockInfoDetailRepository.UpdateData(proStockInfo.proStockInfoDetails); |
| | | _inboundRepository.MesProInOrderRepository.UpdateData(mesProInOrder); |
| | | _inboundRepository.MesProInOrderDetailRepository.UpdateData(mesProInOrder.Details); |
| | | _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, lastStatus, LocationStatusEnum.InStock, LocationChangeType.InboundCompleted); |
| | | _unitOfWorkManage.CommitTran(); |
| | | ////ä¸ä¼ ERP |
| | | //_inboundOrderService.FeedbackProIn(mesProInOrder); |
| | | content.OK(); |
| | | } |
| | | catch (Exception ex) |
| | |
| | | _stockRepository.ProStockInfoRepository.UpdateData(proStockInfo); |
| | | _stockRepository.ProStockInfoDetailRepository.UpdateData(proStockInfo.proStockInfoDetails); |
| | | _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, lastStatus, LocationStatusEnum.InStock, LocationChangeType.InboundCompleted); |
| | | _unitOfWorkManage.CommitTran(); |
| | | content.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | /// <summary> |
| | | /// åºåºä»»å¡å®æ |
| | | /// </summary> |
| | | /// <param name="taskNum">ä»»å¡å·</param> |
| | | /// <returns></returns> |
| | | public WebResponseContent OutboundTaskCompleted(int taskNum) |
| | | { |
| | | try |
| | | { |
| | | Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum); |
| | | if (task == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°ä»»å¡ä¿¡æ¯"); |
| | | } |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseId == task.WarehouseId); |
| | | //æååºåºä»»å¡å®æ |
| | | if (warehouse.WarehouseType==WarehouseTypEnum.æå.ToString()) |
| | | { |
| | | return OutProCompleted(task); |
| | | } |
| | | Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(task.PalletCode); |
| | | |
| | | Dt_LocationInfo locationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.SourceAddress); |
| | | if (stockInfo == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°åºåä¿¡æ¯"); |
| | | } |
| | | if (locationInfo == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°è´§ä½ä¿¡æ¯"); |
| | | } |
| | | List<Dt_OutStockLockInfo> outStockLockInfos = _outboundService.OutboundStockLockInfoService.Repository.QueryData(x => x.TaskNum == taskNum); |
| | | List<Dt_OutboundOrderDetail> outboundOrderDetails = new List<Dt_OutboundOrderDetail>(); |
| | | List<Dt_MesOutboundOrder> mesOutboundOrders = new List<Dt_MesOutboundOrder>(); |
| | | if ((outStockLockInfos == null || outStockLockInfos.Count == 0) && warehouse.WarehouseCode != WarehouseEnum.HA64.ToString() && (task.TaskType != TaskTypeEnum.OutEmpty.ObjToInt())) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°åºåºè¯¦æ
ä¿¡æ¯"); |
| | | } |
| | | else |
| | | { |
| | | foreach (var item in outStockLockInfos) |
| | | { |
| | | if (task.TaskType == TaskTypeEnum.MesOutbound.ObjToInt()) |
| | | { |
| | | Dt_MesOutboundOrder mesOutboundOrder = _outboundService.MesOutboundOrderService.Repository.QueryFirst(x => x.TaskNo == item.OrderNo); |
| | | if (mesOutboundOrder != null) |
| | | { |
| | | mesOutboundOrder.OverOutQuantity = item.AssignQuantity; |
| | | if (mesOutboundOrder.OverOutQuantity == mesOutboundOrder.OrderQuantity) |
| | | { |
| | | mesOutboundOrder.OrderStatus = OrderDetailStatusEnum.Over.ObjToInt(); |
| | | } |
| | | mesOutboundOrders.Add(mesOutboundOrder); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | Dt_OutboundOrderDetail outboundOrderDetail = _outboundService.OutboundOrderDetailService.Repository.QueryFirst(x => x.Id == item.OrderDetailId); |
| | | if (outboundOrderDetail != null) |
| | | { |
| | | outboundOrderDetail.OverOutQuantity += item.AssignQuantity; |
| | | if (outboundOrderDetail.OverOutQuantity == outboundOrderDetail.OrderQuantity) |
| | | { |
| | | outboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt(); |
| | | } |
| | | outboundOrderDetails.Add(outboundOrderDetail); |
| | | } |
| | | } |
| | | item.Status = OutLockStockStatusEnum.åºåºå®æ.ObjToInt(); |
| | | } |
| | | } |
| | | |
| | | task.TaskStatus = TaskStatusEnum.Finish.ObjToInt(); |
| | | FeedBackWCSTaskCompleted(taskNum); |
| | | _unitOfWorkManage.BeginTran(); |
| | | |
| | | if (task.TaskType == TaskTypeEnum.Outbound.ObjToInt() || task.TaskType == TaskTypeEnum.OutAllocate.ObjToInt() || task.TaskType == TaskTypeEnum.MesHandPickOutbound.ObjToInt() || task.TaskType == TaskTypeEnum.MesHandOutbound.ObjToInt()) |
| | | { |
| | | //å¤çåºåºè¯¦æ
|
| | | if (outboundOrderDetails.Count > 0) |
| | | { |
| | | _outboundService.OutboundOrderDetailService.Repository.UpdateData(outboundOrderDetails); |
| | | } |
| | | stockInfo.LocationCode = ""; |
| | | stockInfo.StockStatus = StockStatusEmun.åºåºå®æ.ObjToInt(); |
| | | stockInfo.Details.ForEach(x => |
| | | { |
| | | x.Status = StockStatusEmun.åºåºå®æ.ObjToInt(); |
| | | }); |
| | | if (stockInfo.StockLength>0) |
| | | { |
| | | stockInfo.StockLength = 0; |
| | | } |
| | | _stockRepository.StockInfoRepository.UpdateData(stockInfo); |
| | | _stockRepository.StockInfoDetailRepository.UpdateData(stockInfo.Details); |
| | | } |
| | | else if (task.TaskType == TaskTypeEnum.OutEmpty.ObjToInt()) |
| | | { |
| | | _basicService.LocationInfoService.UpdateLocationStatus(locationInfo, stockInfo.PalletType, LocationStatusEnum.Free, stockInfo.WarehouseId); |
| | | _stockService.StockInfoService.Repository.DeleteAndMoveIntoHty(stockInfo, App.User.UserId == 0 ? OperateTypeEnum.èªå¨å®æ : OperateTypeEnum.äººå·¥å®æ); |
| | | } |
| | | else if (task.TaskType == TaskTypeEnum.MesOutbound.ObjToInt()) |
| | | { |
| | | _outboundService.MesOutboundOrderService.Repository.UpdateData(mesOutboundOrders); |
| | | _stockService.StockInfoService.Repository.DeleteAndMoveIntoHty(stockInfo, App.User.UserId == 0 ? OperateTypeEnum.èªå¨å®æ : OperateTypeEnum.äººå·¥å®æ); |
| | | _stockService.StockInfoDetailService.Repository.DeleteAndMoveIntoHty(stockInfo.Details, App.User.UserId == 0 ? OperateTypeEnum.èªå¨å®æ : OperateTypeEnum.äººå·¥å®æ); |
| | | } |
| | | _outboundService.OutboundStockLockInfoService.Repository.UpdateData(outStockLockInfos); |
| | | |
| | | int beforeStatus = locationInfo.LocationStatus; |
| | | locationInfo.LocationStatus = LocationStatusEnum.Free.ObjToInt(); |
| | | _basicService.LocationInfoService.UpdateLocationStatus(locationInfo, stockInfo.PalletType, LocationStatusEnum.Free, stockInfo.WarehouseId); |
| | | BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.èªå¨å®æ : OperateTypeEnum.äººå·¥å®æ); |
| | | |
| | | _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, (LocationStatusEnum)beforeStatus, LocationStatusEnum.Free, LocationChangeType.OutboundCompleted, stockInfo.Details.FirstOrDefault()?.OrderNo ?? "", task.TaskNum); |
| | | _unitOfWorkManage.CommitTran(); |
| | | |
| | | if (warehouse.WarehouseCode != WarehouseEnum.HA64.ToString() && task.TaskType == TaskTypeEnum.Outbound.ObjToInt()) |
| | | { |
| | | _outboundService.OutboundOrderService.TestOutUpload(outboundOrderDetails.FirstOrDefault().OrderId, outStockLockInfos); |
| | | } |
| | | if (task.TaskType == TaskTypeEnum.MesOutbound.ObjToInt()) |
| | | { |
| | | MesMaterialLotaAceptModel model = GetMesMaterialLotaAceptModel(stockInfo, stockInfo.Details.FirstOrDefault(), mesOutboundOrders.FirstOrDefault().TaskNo, warehouse.WarehouseCode, stockInfo.Details.Where(x => x.MaterielCode == mesOutboundOrders.FirstOrDefault().MaterialCode).Sum(x => x.StockQuantity)); |
| | | UploadMesMaterialLotaAcept(model); |
| | | } |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | //æååºåºä»»å¡å®æ |
| | | public WebResponseContent OutProCompleted(Dt_Task task) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | switch (task.TaskType) |
| | | { |
| | | case (int)TaskTypeEnum.OutProduct: |
| | | content = OutProductCompleted(task); |
| | | break; |
| | | case (int)TaskTypeEnum.OutMesRworkProduct: |
| | | content = OutMesRworkCompleted(task); |
| | | break; |
| | | default: |
| | | content.Error("æªç¥ä»»å¡ç±»å"); |
| | | break; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | //æå订ååºåºä»»å¡å®æ |
| | | public WebResponseContent OutProductCompleted(Dt_Task task) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | //è·åè´§ä½ |
| | | Dt_LocationInfo locationInfo = _basicRepository.LocationInfoRepository.QueryFirst(x => x.LocationCode == task.SourceAddress); |
| | | if (locationInfo == null) |
| | | { |
| | | return content.Error("æªæ¾å°è´§ä½ä¿¡æ¯"); |
| | | } |
| | | //æ ¹æ®ä»»å¡è·åæååºåºè¯¦æ
ä»»å¡åç©æä¿¡æ¯ |
| | | Dt_OutProStockInfo outProStockInfo = _outProStockInfoRepository.QueryFirst(x => x.TaskNum == task.TaskNum); |
| | | if (outProStockInfo == null) |
| | | { |
| | | return content.Error("æªæ¾å°æååºåºè¯¦æ
"); |
| | | } |
| | | //è·åæååºåºè®¢å |
| | | Dt_ProOutOrder proOutOrder = _outboundService.ProOutOrderService.Repository.Db.Queryable<Dt_ProOutOrder>().Where(x => x.ProOutOrderNo == outProStockInfo.OrderNo).Includes(x => x.Details).First(); |
| | | |
| | | if (proOutOrder == null) |
| | | { |
| | | return content.Error("æªæ¾å°æååºåºè®¢å"); |
| | | } |
| | | //è·åæååºå |
| | | Dt_ProStockInfo proStockInfo = _stockRepository.ProStockInfoRepository.Db.Queryable<Dt_ProStockInfo>().Where(x => x.PalletCode == task.PalletCode).Includes(x => x.proStockInfoDetails).First(); |
| | | if (proStockInfo == null) |
| | | { |
| | | return content.Error($"æªæ¾å°{task.PalletCode}æååºåä¿¡æ¯"); |
| | | } |
| | | List<Dt_ProStockInfoDetail> proStockInfoDetails = proStockInfo.proStockInfoDetails; |
| | | if (proStockInfoDetails.Count <= 0) |
| | | { |
| | | return content.Error($"{proStockInfo.PalletCode}æååºåæç»ä¸ºç©º"); |
| | | } |
| | | proStockInfoDetails.ForEach(x => |
| | | { |
| | | x.ProOutDetailStatus = StockStatusEmun.åºåºå®æ.ObjToInt(); |
| | | }); |
| | | //å¤çåºåæ°æ® |
| | | //List<Dt_ProStockInfoDetail>? deleteStockDetails = null; |
| | | //List<Dt_ProStockInfoDetail>? updateStockDetails = null; |
| | | //(List<Dt_ProStockInfoDetail>?, List<Dt_ProStockInfoDetail>?) result = _stockService.ProStockInfoService.HandleOutProStock(proStockInfo); |
| | | //if (result.Item1!=null && result.Item1.Count>0) |
| | | //{ |
| | | // deleteStockDetails.AddRange(result.Item1); |
| | | //} |
| | | //if (result.Item1 != null && result.Item1.Count > 0) |
| | | //{ |
| | | // updateStockDetails.AddRange(updateStockDetails); |
| | | //} |
| | | //è·åæååºåºåæç» |
| | | Dt_ProOutOrderDetail? proOutOrderDetail = proOutOrder.Details.FirstOrDefault(x => x.Id == outProStockInfo.OrderDetailId); |
| | | if (proOutOrderDetail == null) |
| | | { |
| | | return content.Error("æªæ¾å°å¯¹åºä»»å¡æå订åæç»"); |
| | | } |
| | | //if (deleteStockDetails?.Sum(x=>x.StockPcsQty)== proStockInfo.proStockInfoDetails.Sum(x=>x.StockPcsQty)) |
| | | //{ |
| | | proStockInfo.StockStatus = StockStatusEmun.åºåºå®æ.ObjToInt(); |
| | | //è·åæåå¹³åº |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA101.ToString()); |
| | | proStockInfo.WarehouseId = warehouse.WarehouseId; |
| | | proStockInfo.LocationCode = "æåå
è£
æ£è´§åº"; |
| | | //} |
| | | task.TaskStatus = TaskStatusEnum.Finish.ObjToInt(); |
| | | outProStockInfo.Status = OutLockStockStatusEnum.åºåºå®æ.ObjToInt(); |
| | | _unitOfWorkManage.BeginTran(); |
| | | //è´§ä½åå¨è®°å½ |
| | | int beforeStatus = locationInfo.LocationStatus; |
| | | locationInfo.LocationStatus = LocationStatusEnum.Free.ObjToInt(); |
| | | _basicService.LocationInfoService.UpdateLocationStatus(locationInfo, proStockInfo.PalletType, LocationStatusEnum.Free, locationInfo.WarehouseId); |
| | | _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, (LocationStatusEnum)beforeStatus, LocationStatusEnum.Free, LocationChangeType.OutboundCompleted, proOutOrder?.ProOutOrderNo ?? "", task.TaskNum); |
| | | |
| | | //if (deleteStockDetails!=null && deleteStockDetails.Count>0) |
| | | //{ |
| | | // _stockRepository.ProStockInfoDetailRepository.DeleteAndMoveIntoHty(deleteStockDetails, OperateTypeEnum.èªå¨å®æ); |
| | | //} |
| | | //if (updateStockDetails!=null && updateStockDetails.Count>0) |
| | | //{ |
| | | _stockRepository.ProStockInfoRepository.UpdateData(proStockInfo); |
| | | _stockRepository.ProStockInfoDetailRepository.UpdateData(proStockInfoDetails); |
| | | _outProStockInfoRepository.UpdateData(outProStockInfo); |
| | | //} |
| | | //else |
| | | //{ |
| | | //_stockRepository.ProStockInfoRepository.DeleteAndMoveIntoHty(proStockInfo, OperateTypeEnum.èªå¨å®æ); |
| | | //} |
| | | BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.èªå¨å®æ : OperateTypeEnum.äººå·¥å®æ); |
| | | _unitOfWorkManage.CommitTran(); |
| | | //MESæååºåºåæ¥ |
| | | ShipmentOrderSync(MesOutSync(outProStockInfo, proOutOrderDetail, proStockInfoDetails)); |
| | | content.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | /// <summary> |
| | | /// æåMESæåºä»»å¡å®æ |
| | | /// </summary> |
| | | public WebResponseContent OutMesRworkCompleted(Dt_Task task) |
| | | { |
| | | WebResponseContent content=new WebResponseContent(); |
| | | try |
| | | { |
| | | //è·åè´§ä½ |
| | | Dt_LocationInfo locationInfo = _basicRepository.LocationInfoRepository.QueryFirst(x => x.LocationCode == task.SourceAddress); |
| | | if (locationInfo == null) |
| | | { |
| | | return content.Error("æªæ¾å°è´§ä½ä¿¡æ¯"); |
| | | } |
| | | //æ ¹æ®ä»»å¡è·åæååºåºè¯¦æ
ä»»å¡åç©æä¿¡æ¯ |
| | | Dt_OutProStockInfo outProStockInfo = _outProStockInfoRepository.QueryFirst(x => x.TaskNum == task.TaskNum); |
| | | if (outProStockInfo == null) |
| | | { |
| | | return content.Error("æªæ¾å°æååºåºè¯¦æ
"); |
| | | } |
| | | //è·åMESæåºå |
| | | Dt_MesRworkOutboundOrder mesRworkOutboundOrder = _outboundRepository.RworkOutboundOrderRepository.QueryFirst(x=>x.TaskNo==task.OrderNo); |
| | | if (mesRworkOutboundOrder==null) |
| | | { |
| | | return content.Error("æªæ¾å°MESæåæåºå"); |
| | | } |
| | | if (mesRworkOutboundOrder.OrderStatus==OutOrderStatusEnum.åºåºå®æ.ObjToInt()) |
| | | { |
| | | return content.Error($"MESæåæåºå{mesRworkOutboundOrder.TaskNo}已宿"); |
| | | } |
| | | //è·åå½ååºå |
| | | Dt_ProStockInfo proStockInfo = _stockRepository.ProStockInfoRepository.Db.Queryable<Dt_ProStockInfo>().Where(x => x.PalletCode ==task.PalletCode).Includes(x=>x.proStockInfoDetails).First(); |
| | | if (proStockInfo==null) |
| | | { |
| | | return content.Error($"æªæ¾å°{task.PalletCode}åºåä¿¡æ¯"); |
| | | } |
| | | List<Dt_ProStockInfoDetail> proStockInfoDetails = proStockInfo.proStockInfoDetails; |
| | | if (proStockInfoDetails.Count <= 0) |
| | | { |
| | | return content.Error("æååºåæç»ä¸ºç©º"); |
| | | } |
| | | proStockInfoDetails.ForEach(x => |
| | | { |
| | | x.OutboundQuantity = 0; |
| | | x.ProOutDetailStatus = StockStatusEmun.åºåºå®æ.ObjToInt(); |
| | | }); |
| | | proStockInfo.StockStatus = StockStatusEmun.åºåºå®æ.ObjToInt(); |
| | | //è·åæåå¹³åº |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA101.ToString()); |
| | | proStockInfo.WarehouseId = warehouse.WarehouseId; |
| | | proStockInfo.LocationCode = "æåå
è£
æ£è´§åº"; |
| | | task.TaskStatus = TaskStatusEnum.Finish.ObjToInt(); |
| | | outProStockInfo.Status = OutLockStockStatusEnum.åºåºå®æ.ObjToInt(); |
| | | _unitOfWorkManage.BeginTran(); |
| | | //è´§ä½åå¨è®°å½ |
| | | int beforeStatus = locationInfo.LocationStatus; |
| | | locationInfo.LocationStatus = LocationStatusEnum.Free.ObjToInt(); |
| | | _basicService.LocationInfoService.UpdateLocationStatus(locationInfo, proStockInfo.PalletType, LocationStatusEnum.Free, locationInfo.WarehouseId); |
| | | _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, (LocationStatusEnum)beforeStatus, LocationStatusEnum.Free, LocationChangeType.OutboundCompleted, mesRworkOutboundOrder?.TaskNo ?? "", task.TaskNum); |
| | | _stockRepository.ProStockInfoRepository.UpdateData(proStockInfo); |
| | | _stockRepository.ProStockInfoDetailRepository.UpdateData(proStockInfoDetails); |
| | | _outProStockInfoRepository.UpdateData(outProStockInfo); |
| | | BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.èªå¨å®æ : OperateTypeEnum.äººå·¥å®æ); |
| | | //MESæååºåæ¿åºåºåæ¥ |
| | | //WebResponseContent responseContent = ProductOutBoundSync(MesProOutBound(mesRworkOutboundOrder, proStockInfoDetails)); |
| | | //if (!responseContent.Status) |
| | | //{ |
| | | // throw new Exception("忥MESåºåæ¿åºåºå¤±è´¥,é误:"+ responseContent.Message); |
| | | //} |
| | | _unitOfWorkManage.CommitTran(); |
| | | content.OK(); |
| | | } |
| | |
| | | { |
| | | return await Task.FromResult(WebResponseContent.Instance.Error($"æªæ¾å°ä»»å¡ä¿¡æ¯")); |
| | | } |
| | | if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup) |
| | | { |
| | | return await Task.FromResult(InboundTaskCompleted(taskNum)); |
| | | } |
| | | else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) |
| | | { |
| | | return await Task.FromResult(OutboundTaskCompleted(taskNum)); |
| | | } |
| | | else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.RelocationGroup) |
| | | { |
| | | return await Task.FromResult(RelocationTaskCompleted(task)); |
| | |
| | | public partial class TaskService |
| | | { |
| | | /// <summary> |
| | | /// ç³è¯·å
¥åºä»»å¡(PDA使ç¨ï¼ä»
æçç»å®å
¥åºç«å°ï¼ä¸åé
è´§ä½) |
| | | /// </summary> |
| | | /// <param name="saveModel"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent RequestInboundTask(SaveModel saveModel) |
| | | { |
| | | try |
| | | { |
| | | var palletCode = saveModel.MainData["barcode"].ToString(); |
| | | var warehouseId = saveModel.MainData["warehouseId"].ObjToInt(); |
| | | var stationCode = saveModel.MainData["startPoint"].ToString(); |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseId == warehouseId); |
| | | if (warehouse == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°åºåº"); |
| | | } |
| | | |
| | | Dt_Task task = Repository.QueryFirst(x => x.PalletCode == palletCode && x.WarehouseId == warehouseId); |
| | | if (task != null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"该æçå·²çæä»»å¡"); |
| | | } |
| | | |
| | | if (Repository.QueryFirst(x => x.SourceAddress == stationCode && x.TaskStatus == TaskStatusEnum.New.ObjToInt()) != null && warehouse.WarehouseCode != WarehouseEnum.HA60.ToString()) |
| | | { |
| | | return WebResponseContent.Instance.Error($"该ç«ç¹å·²ææªæ§è¡çä»»å¡"); |
| | | } |
| | | |
| | | Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x=>x.PalletCode== palletCode).Includes(x=>x.Details).First(); |
| | | if (stockInfo == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°ç»çä¿¡æ¯"); |
| | | } |
| | | if (stockInfo.StockStatus != StockStatusEmun.ç»çæå.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.æå¨ç»çæå.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.æ£é宿.ObjToInt()) |
| | | { |
| | | return WebResponseContent.Instance.Error($"该æçç¶æä¸æ£ç¡®,ä¸å¯ç³è¯·å
¥åº"); |
| | | } |
| | | if (!string.IsNullOrEmpty(stockInfo.LocationCode)) |
| | | { |
| | | return WebResponseContent.Instance.Error($"该æçå·²ç»å®è´§ä½"); |
| | | } |
| | | if (warehouseId != stockInfo.WarehouseId) |
| | | { |
| | | return WebResponseContent.Instance.Error($"ä»åºä¸æ£ç¡®"); |
| | | } |
| | | if (warehouse.WarehouseCode == WarehouseEnum.HA60.ToString()) |
| | | { |
| | | Dt_LocationInfo locationInfo = _basicRepository.LocationInfoRepository.QueryFirst(x => x.WarehouseId == warehouseId); |
| | | if (locationInfo == null) return WebResponseContent.Instance.Error($"æªæ¾å°å½ååºåºè´§ä½ä¿¡æ¯"); |
| | | return DeviceRequestInboundTask(stationCode, locationInfo.RoadwayNo, palletCode); |
| | | } |
| | | else |
| | | { |
| | | Dt_Task newTask = new Dt_Task() |
| | | { |
| | | CurrentAddress = stationCode, |
| | | Grade = 0, |
| | | NextAddress = "", |
| | | PalletCode = palletCode, |
| | | Roadway = "", |
| | | SourceAddress = stationCode, |
| | | TargetAddress = "", |
| | | TaskType = TaskTypeEnum.Inbound.ObjToInt(), |
| | | TaskStatus = TaskStatusEnum.New.ObjToInt(), |
| | | WarehouseId = stockInfo.WarehouseId, |
| | | PalletType = stockInfo.PalletType, |
| | | MaterielCode = stockInfo.Details.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.MaterielCode, |
| | | Quantity = (float)stockInfo.Details.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.StockQuantity, |
| | | }; |
| | | //è·åæ¯å¦åå¨å
¥åºå |
| | | Dt_InboundOrder? inboundOrder = null; |
| | | if (stockInfo!=null && stockInfo.Details.Count>0) |
| | | { |
| | | string? orderNo = stockInfo.Details.FirstOrDefault()?.OrderNo ?? ""; |
| | | inboundOrder =_inboundOrderService.Repository.QueryFirst(x => x.InboundOrderNo == orderNo && x.OrderStatus < InOrderStatusEnum.å
¥åºå®æ.ObjToInt()); |
| | | if (inboundOrder!=null) |
| | | { |
| | | newTask.OrderNo = inboundOrder.InboundOrderNo; |
| | | } |
| | | } |
| | | |
| | | if (inboundOrder != null) |
| | | { |
| | | if (inboundOrder.OrderType == InOrderTypeEnum.Allocat.ObjToInt()) |
| | | { |
| | | newTask.TaskType = TaskTypeEnum.InAllocate.ObjToInt(); |
| | | newTask.OrderNo = inboundOrder.InboundOrderNo; |
| | | } |
| | | else if (inboundOrder.OrderType == InOrderTypeEnum.Return.ObjToInt()) |
| | | { |
| | | newTask.TaskType = TaskTypeEnum.ProductionReturn.ObjToInt(); |
| | | newTask.OrderNo = inboundOrder.InboundOrderNo; |
| | | } |
| | | } |
| | | if (stockInfo.StockStatus == StockStatusEmun.æå¨ç»çæå.ObjToInt()) |
| | | { |
| | | stockInfo.StockStatus = StockStatusEmun.æå¨ç»çå
¥åºç¡®è®¤.ObjToInt(); |
| | | } |
| | | else if (stockInfo.StockStatus == StockStatusEmun.æ£é宿.ObjToInt()) |
| | | { |
| | | stockInfo.StockStatus = StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt(); |
| | | newTask.TaskType = TaskTypeEnum.InPick.ObjToInt(); |
| | | } |
| | | else |
| | | { |
| | | stockInfo.StockStatus = StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt(); |
| | | } |
| | | |
| | | if (warehouse.WarehouseCode==WarehouseEnum.HA57.ToString()) |
| | | { |
| | | Dt_Task dt_TaskMesReturn = BaseDal.QueryFirst(x=>x.TaskType==TaskTypeEnum.MesMatReturn.ObjToInt() && x.TaskStatus!=TaskStatusEnum.SC_Executing.ObjToInt()); |
| | | if (dt_TaskMesReturn!=null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"éæä»»å¡æ£æ§è¡"); |
| | | } |
| | | } |
| | | _unitOfWorkManage.BeginTran(); |
| | | int taskId = BaseDal.AddData(newTask); |
| | | newTask.TaskId = taskId; |
| | | _stockRepository.StockInfoRepository.UpdateData(stockInfo); |
| | | _unitOfWorkManage.CommitTran(); |
| | | PushTasksToWCS(new List<Dt_Task> { newTask }); |
| | | return WebResponseContent.Instance.OK(data: newTask); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å
¥ç©ºç®± |
| | | /// </summary> |
| | | /// <param name="barcode"></param> |
| | |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="stationCode"></param> |
| | | /// <param name="roadwayNo"></param> |
| | | /// <param name="palletCode"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent DeviceRequestInboundTask(string stationCode, string roadwayNo, string palletCode,string materielBoxCode = "") |
| | | { |
| | | try |
| | | { |
| | | Dt_Task task = Repository.QueryFirst(x => x.PalletCode == palletCode); |
| | | if (task != null) |
| | | { |
| | | PushTasksToWCS(new List<Dt_Task> { task }); |
| | | return WebResponseContent.Instance.OK($"该æçå·²çæä»»å¡", _mapper.Map<WMSTaskDTO>(task)); |
| | | } |
| | | |
| | | if (Repository.QueryFirst(x => x.SourceAddress == stationCode && x.TaskStatus == TaskStatusEnum.New.ObjToInt()) != null && stationCode != "8005")//è¾
æä»ä¸éå¶å
¥åºä»»å¡ |
| | | { |
| | | return WebResponseContent.Instance.Error($"该ç«ç¹å·²ææªæ§è¡çä»»å¡"); |
| | | } |
| | | if (!string.IsNullOrEmpty(materielBoxCode)) |
| | | { |
| | | _unitOfWorkManage.BeginTran(); |
| | | WebResponseContent responseGroup = _inboundOrderService.MaterielPPorGM(materielBoxCode); |
| | | if (!responseGroup.Status) |
| | | { |
| | | return WebResponseContent.Instance.Error($"{responseGroup.Message}"); |
| | | } |
| | | Dt_StockInfo stockInfoPPorGM = responseGroup.Data as Dt_StockInfo ?? null; |
| | | if (stockInfoPPorGM==null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"ç»çæ°æ®è½¬æ¢å¤±è´¥"); |
| | | } |
| | | Dt_LocationInfo? locationInfoPPorGM = _basicService.LocationInfoService.AssignLocation(roadwayNo, stockInfoPPorGM.PalletType, stockInfoPPorGM.WarehouseId); |
| | | if (locationInfoPPorGM == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"è´§ä½åé
失败,æªæ¾å°å¯åé
è´§ä½"); |
| | | } |
| | | Dt_Task newTaskPPorGM = new Dt_Task() |
| | | { |
| | | CurrentAddress = stationCode, |
| | | Grade = 0, |
| | | NextAddress = locationInfoPPorGM.LocationCode, |
| | | PalletCode = stockInfoPPorGM.PalletCode, |
| | | Roadway = roadwayNo, |
| | | SourceAddress = stationCode, |
| | | TargetAddress = locationInfoPPorGM.LocationCode, |
| | | TaskType = TaskTypeEnum.Inbound.ObjToInt(), |
| | | TaskStatus = TaskStatusEnum.New.ObjToInt(), |
| | | WarehouseId = stockInfoPPorGM.WarehouseId, |
| | | PalletType = stockInfoPPorGM.PalletType, |
| | | TaskLength= stockInfoPPorGM.StockLength |
| | | }; |
| | | |
| | | //è·åæ¯å¦åå¨å
¥åºå |
| | | Dt_InboundOrder? inboundOrderPPorGM = null; |
| | | if (stockInfoPPorGM != null && stockInfoPPorGM.Details.Count > 0) |
| | | { |
| | | string? orderNo = stockInfoPPorGM.Details.FirstOrDefault()?.OrderNo ?? ""; |
| | | inboundOrderPPorGM = _inboundOrderService.Repository.QueryFirst(x => x.InboundOrderNo == orderNo && x.OrderStatus < InOrderStatusEnum.å
¥åºå®æ.ObjToInt()); |
| | | } |
| | | |
| | | if (inboundOrderPPorGM != null) |
| | | { |
| | | if (inboundOrderPPorGM.OrderType == InOrderTypeEnum.Allocat.ObjToInt()) |
| | | { |
| | | newTaskPPorGM.TaskType = TaskTypeEnum.InAllocate.ObjToInt(); |
| | | } |
| | | else if (inboundOrderPPorGM.OrderType == InOrderTypeEnum.Return.ObjToInt()) |
| | | { |
| | | newTaskPPorGM.TaskType = TaskTypeEnum.ProductionReturn.ObjToInt(); |
| | | } |
| | | } |
| | | stockInfoPPorGM.StockStatus = StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt(); |
| | | LocationStatusEnum lastStatusPPorGM = (LocationStatusEnum)locationInfoPPorGM.LocationStatus; |
| | | _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfoPPorGM, lastStatusPPorGM, LocationStatusEnum.Lock, LocationChangeType.InboundAssignLocation); |
| | | _basicService.LocationInfoService.UpdateLocationStatus(locationInfoPPorGM, newTaskPPorGM.PalletType, LocationStatusEnum.Lock, newTaskPPorGM.WarehouseId); |
| | | int taskIdPPorGM = BaseDal.AddData(newTaskPPorGM); |
| | | newTaskPPorGM.TaskId = taskIdPPorGM; |
| | | _stockRepository.StockInfoRepository.Db.InsertNav(stockInfoPPorGM).Include(x => x.Details).ExecuteCommand(); |
| | | _unitOfWorkManage.CommitTran(); |
| | | WMSTaskDTO wMSTaskDTOPPorGM = _mapper.Map<WMSTaskDTO>(newTaskPPorGM); |
| | | |
| | | PushTasksToWCS(new List<Dt_Task> { newTaskPPorGM }); |
| | | return WebResponseContent.Instance.OK(data: wMSTaskDTOPPorGM); |
| | | } |
| | | Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == palletCode).Includes(x => x.Details).First(); |
| | | if (stockInfo == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°ç»çä¿¡æ¯"); |
| | | } |
| | | if (stockInfo.StockStatus != StockStatusEmun.ç»çæå.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.æå¨ç»çæå.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.åºåºå®æ.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.æ£é宿.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.éåº.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.MESéåº.ObjToInt()) |
| | | { |
| | | return WebResponseContent.Instance.Error($"该æçç¶æä¸æ£ç¡®,ä¸å¯ç³è¯·å
¥åº"); |
| | | } |
| | | if (!string.IsNullOrEmpty(stockInfo.LocationCode)) |
| | | { |
| | | return WebResponseContent.Instance.Error($"该æçå·²ç»å®è´§ä½"); |
| | | } |
| | | |
| | | Dt_LocationInfo? locationInfo = _basicService.LocationInfoService.AssignLocation(roadwayNo, stockInfo.PalletType, stockInfo.WarehouseId); |
| | | if (locationInfo == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"è´§ä½åé
失败,æªæ¾å°å¯åé
è´§ä½"); |
| | | } |
| | | |
| | | Dt_Task newTask = new Dt_Task() |
| | | { |
| | | CurrentAddress = stationCode, |
| | | Grade = 0, |
| | | NextAddress = locationInfo.LocationCode, |
| | | PalletCode = palletCode, |
| | | Roadway = roadwayNo, |
| | | SourceAddress = stationCode, |
| | | TargetAddress = locationInfo.LocationCode, |
| | | TaskType = TaskTypeEnum.Inbound.ObjToInt(), |
| | | TaskStatus = TaskStatusEnum.New.ObjToInt(), |
| | | WarehouseId = stockInfo.WarehouseId, |
| | | PalletType = stockInfo.PalletType, |
| | | }; |
| | | |
| | | //è·åæ¯å¦åå¨å
¥åºå |
| | | Dt_InboundOrder? inboundOrder = null; |
| | | if (stockInfo != null && stockInfo.Details.Count > 0) |
| | | { |
| | | string? orderNo = stockInfo.Details.FirstOrDefault()?.OrderNo ?? ""; |
| | | inboundOrder = _inboundOrderService.Repository.QueryFirst(x => x.InboundOrderNo == orderNo && x.OrderStatus < InOrderStatusEnum.å
¥åºå®æ.ObjToInt()); |
| | | } |
| | | |
| | | if (inboundOrder != null) |
| | | { |
| | | if (inboundOrder.OrderType == InOrderTypeEnum.Allocat.ObjToInt()) |
| | | { |
| | | newTask.TaskType = TaskTypeEnum.InAllocate.ObjToInt(); |
| | | } |
| | | else if (inboundOrder.OrderType == InOrderTypeEnum.Return.ObjToInt()) |
| | | { |
| | | newTask.TaskType = TaskTypeEnum.ProductionReturn.ObjToInt(); |
| | | } |
| | | } |
| | | if (stockInfo.StockStatus == StockStatusEmun.æå¨ç»çæå.ObjToInt()) |
| | | { |
| | | stockInfo.StockStatus = StockStatusEmun.æå¨ç»çå
¥åºç¡®è®¤.ObjToInt(); |
| | | } |
| | | else if (stockInfo.StockStatus == StockStatusEmun.MESéåº.ObjToInt()) |
| | | { |
| | | newTask.TaskType = TaskTypeEnum.MesMatReturn.ObjToInt(); |
| | | } |
| | | else if (stockInfo.StockStatus == StockStatusEmun.æ£é宿.ObjToInt()) |
| | | { |
| | | newTask.TaskType = TaskTypeEnum.InPick.ObjToInt(); |
| | | } |
| | | else |
| | | { |
| | | stockInfo.StockStatus = StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt(); |
| | | } |
| | | |
| | | LocationStatusEnum lastStatus = (LocationStatusEnum)locationInfo.LocationStatus; |
| | | _unitOfWorkManage.BeginTran(); |
| | | _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, lastStatus, LocationStatusEnum.Lock, LocationChangeType.InboundAssignLocation); |
| | | _basicService.LocationInfoService.UpdateLocationStatus(locationInfo, newTask.PalletType, LocationStatusEnum.Lock, newTask.WarehouseId); |
| | | int taskId = BaseDal.AddData(newTask); |
| | | newTask.TaskId = taskId; |
| | | _stockRepository.StockInfoRepository.UpdateData(stockInfo); |
| | | _unitOfWorkManage.CommitTran(); |
| | | WMSTaskDTO wMSTaskDTO = _mapper.Map<WMSTaskDTO>(newTask); |
| | | |
| | | PushTasksToWCS(new List<Dt_Task> { newTask }); |
| | | if (newTask.WarehouseId == 5) PutFinish(stationCode.ToString(),newTask.PalletCode, newTask.TaskNum.ToString()); |
| | | return WebResponseContent.Instance.OK(data: wMSTaskDTO); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// ä»
ç³è¯·ä»»å¡ï¼è®©WCSæ ¹æ®è·¯ç±ç¡®å®ä¸ä¸å°å |
| | | /// </summary> |
| | |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="stationCode"></param> |
| | | /// <param name="palletCode"></param> |
| | | /// <param name="staions"></param> |
| | | /// <param name="heightType"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent DeviceRequestInboundTaskByRoadways(string stationCode, string palletCode, List<string> staions, int heightType) |
| | | { |
| | | try |
| | | { |
| | | Dt_Task task = Repository.QueryFirst(x => x.PalletCode == palletCode); |
| | | if (task != null) |
| | | { |
| | | PushTasksToWCS(new List<Dt_Task> { task }); |
| | | return WebResponseContent.Instance.OK($"该æçå·²çæä»»å¡", _mapper.Map<WMSTaskDTO>(task)); |
| | | } |
| | | |
| | | if (Repository.QueryFirst(x => x.SourceAddress == stationCode && x.TaskStatus == TaskStatusEnum.New.ObjToInt()) != null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"该ç«ç¹å·²ææªæ§è¡çä»»å¡"); |
| | | } |
| | | |
| | | string roadwayNo = AssignRoadwayNo(staions, palletCode, heightType); |
| | | |
| | | Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == palletCode); |
| | | if (stockInfo == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°ç»çä¿¡æ¯"); |
| | | } |
| | | if (stockInfo.StockStatus != StockStatusEmun.ç»çæå.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.æå¨ç»çæå.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.åºåºå®æ.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.æ£é宿.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.éåº.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.MESéåº.ObjToInt()) |
| | | { |
| | | return WebResponseContent.Instance.Error($"该æçç¶æä¸æ£ç¡®,ä¸å¯ç³è¯·å
¥åº"); |
| | | } |
| | | if (!string.IsNullOrEmpty(stockInfo.LocationCode)) |
| | | { |
| | | return WebResponseContent.Instance.Error($"该æçå·²ç»å®è´§ä½"); |
| | | } |
| | | |
| | | Dt_Task newTask = new Dt_Task() |
| | | { |
| | | CurrentAddress = stationCode, |
| | | Grade = 0, |
| | | NextAddress = "", |
| | | PalletCode = palletCode, |
| | | Roadway = roadwayNo, |
| | | SourceAddress = stationCode, |
| | | TargetAddress = roadwayNo, |
| | | TaskType = TaskTypeEnum.Inbound.ObjToInt(), |
| | | TaskStatus = TaskStatusEnum.New.ObjToInt(), |
| | | WarehouseId = stockInfo.WarehouseId, |
| | | PalletType = stockInfo.PalletType, |
| | | }; |
| | | |
| | | if (stockInfo.StockStatus == StockStatusEmun.æå¨ç»çæå.ObjToInt()) |
| | | { |
| | | stockInfo.StockStatus = StockStatusEmun.æå¨ç»çå
¥åºç¡®è®¤.ObjToInt(); |
| | | } |
| | | else if (stockInfo.StockStatus == StockStatusEmun.MESéåº.ObjToInt()) |
| | | { |
| | | newTask.TaskType = TaskTypeEnum.MesMatReturn.ObjToInt(); |
| | | } |
| | | else |
| | | { |
| | | stockInfo.StockStatus = StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt(); |
| | | } |
| | | |
| | | _unitOfWorkManage.BeginTran(); |
| | | int taskId = BaseDal.AddData(newTask); |
| | | newTask.TaskId = taskId; |
| | | _stockRepository.StockInfoRepository.UpdateData(stockInfo); |
| | | _unitOfWorkManage.CommitTran(); |
| | | WMSTaskDTO wMSTaskDTO = _mapper.Map<WMSTaskDTO>(newTask); |
| | | |
| | | PushTasksToWCS(new List<Dt_Task> { newTask }); |
| | | //if (newTask.WarehouseId == 5) PutFinish(stationCode); |
| | | return WebResponseContent.Instance.OK(data: wMSTaskDTO); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å
¥åºä»»å¡ç³è¯·åé
è´§ä½ |
| | | /// </summary> |
| | |
| | | return content; |
| | | } |
| | | /// <summary> |
| | | /// çææååºåºä»»å¡ |
| | | /// </summary> |
| | | /// <param name="ProOutNo">åºåºè®¢åå·</param> |
| | | /// <param name="StationCode">ç«å°å°å</param> |
| | | /// <returns></returns> |
| | | public async Task<WebResponseContent> OutProductTask(int[] keys, string StationCode, int Grade) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | if (StationCode.IsNullOrEmpty()) |
| | | { |
| | | return await Task.FromResult(content.Error("线ä½è¾å
¥é误")); |
| | | } |
| | | //è·åæååºåºè®¢å |
| | | List<Dt_ProOutOrderDetail> _ProOutOrderDetails = await _outboundRepository.ProOutOrderDetailRepository.QueryDataAsync(x => keys.Contains(x.Id) && x.ProOrderDetailStatus== OrderDetailStatusEnum.New.ObjToInt()); |
| | | if (_ProOutOrderDetails.Count<=0) |
| | | { |
| | | return await Task.FromResult(content.Error("å¾é订åæç»ç¶æä¸ºåºåºä¸")); |
| | | } |
| | | List<Dt_Task> tasks = new List<Dt_Task>(); |
| | | List<StockSelectViewDTO> stockSelectViews = new List<StockSelectViewDTO>(); |
| | | List<Dt_ProStockInfo> proStockInfos = new List<Dt_ProStockInfo>(); |
| | | List<Dt_ProOutOrderDetail> proOutOrderDetails = new List<Dt_ProOutOrderDetail>(); |
| | | List<Dt_OutProStockInfo> outProStockInfos = new List<Dt_OutProStockInfo>(); |
| | | List<Dt_LocationInfo> locationInfos = new List<Dt_LocationInfo>(); |
| | | (List<Dt_Task>, List<Dt_ProStockInfo>?, List<Dt_ProOutOrderDetail>?, List<Dt_OutProStockInfo>?, List<Dt_LocationInfo>?) result = |
| | | OutProductTaskDataHandle(_ProOutOrderDetails); |
| | | if (result.Item2 != null && result.Item2.Count > 0) |
| | | { |
| | | proStockInfos.AddRange(result.Item2); |
| | | } |
| | | if (result.Item3 != null && result.Item3.Count > 0) |
| | | { |
| | | proOutOrderDetails.AddRange(result.Item3); |
| | | } |
| | | if (result.Item4 != null && result.Item4.Count > 0) |
| | | { |
| | | outProStockInfos.AddRange(result.Item4); |
| | | } |
| | | if (result.Item5 != null && result.Item5.Count > 0) |
| | | { |
| | | locationInfos.AddRange(result.Item5); |
| | | } |
| | | if (result.Item1 != null && result.Item1.Count > 0) |
| | | { |
| | | Dt_Task? task = BaseDal.QueryData(x=>x.TaskType==TaskTypeEnum.OutProduct.ObjToInt()).OrderByDescending(x=>x.Grade).FirstOrDefault(); |
| | | //æ´æ°åºåºç®çä½ç½® |
| | | result.Item1.ForEach(x => |
| | | { |
| | | x.TargetAddress = StationCode; |
| | | if (Grade==1 || task==null) |
| | | { |
| | | x.Grade = 127; |
| | | } |
| | | else |
| | | { |
| | | if (task.Grade==0 || task.Grade==1) |
| | | { |
| | | x.Grade = 1; |
| | | } |
| | | else |
| | | { |
| | | x.Grade = task.Grade - 1; |
| | | } |
| | | } |
| | | }); |
| | | tasks.AddRange(result.Item1); |
| | | } |
| | | //å¤çåºåºæ°æ® |
| | | return await Task.FromResult(GenerateOutboundTaskDataUpdate(tasks, proStockInfos, proOutOrderDetails, outProStockInfos, locationInfos)); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | /// <summary> |
| | | /// 人工éå®åºååºåº |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public WebResponseContent OutProductSelect(int orderDetailId,List<ProStockViewDTO> proStockViews) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | //è·ååºåºåæç» |
| | | Dt_ProOutOrderDetail proOutOrderDetail = _outboundRepository.ProOutOrderDetailRepository.QueryFirst(x=>x.Id==orderDetailId); |
| | | if (proOutOrderDetail == null) |
| | | { |
| | | return content.Error("订åæç»ä¸åå¨"); |
| | | } |
| | | if (proOutOrderDetail.ProOrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()) |
| | | { |
| | | return content.Error("å½åçæç»å已宿"); |
| | | } |
| | | //è·ååºåºåæ® |
| | | Dt_ProOutOrder proOutOrder = _outboundRepository.ProOutOrderRepository.Db.Queryable<Dt_ProOutOrder>().Where(x=>x.Id==proOutOrderDetail.ProOrderId).Includes(x => x.Details).First(); |
| | | if (proOutOrder==null) |
| | | { |
| | | return content.Error("åºåºåæ®ä¸åå¨"); |
| | | } |
| | | if (proOutOrder.ProOrderStatus>=OutOrderStatusEnum.åºåºå®æ.ObjToInt()) |
| | | { |
| | | return content.Error($"{proOutOrder.ProOutOrderNo}åºåºå已宿"); |
| | | } |
| | | if ((proOutOrderDetail.QtyPcs-proOutOrderDetail.OverQtyPcs)> proStockViews.Sum(x=>x.SumStocks)) |
| | | { |
| | | return content.Error($"éæ»¡è¶³{proOutOrderDetail.QtyPcs - proOutOrderDetail.OverQtyPcs}åºåºé"); |
| | | } |
| | | //è·åææåºå |
| | | List<Dt_ProStockInfo> proStockInfos = _stockRepository.ProStockInfoRepository.Db.Queryable<Dt_ProStockInfo>().Where(b => b.LocationCode == "æåå¾
åè´§åº" && b.StockStatus == StockStatusEmun.å¹³åºå
¥åºå®æ.ObjToInt() && (b.ShipmentOrder == null || b.ShipmentOrder == "")).Includes(x => x.proStockInfoDetails).Where(x => x.proStockInfoDetails.Any(v => v.ProductCode == proOutOrderDetail.PCode)).ToList(); |
| | | //è·å已宿æ°é |
| | | int OverCount = proOutOrder.Details.Where(x => x.ProOrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()).Count(); |
| | | List<Dt_ProStockInfo> outStockInfos=new List<Dt_ProStockInfo>(); |
| | | List<Dt_ProStockInfoDetail> outStockInfoDetails=new List<Dt_ProStockInfoDetail>(); |
| | | List<StockOutItemsItem> stockOutItems = new List<StockOutItemsItem>(); |
| | | foreach (var item in proStockViews.OrderBy(x => x.SumStocks)) |
| | | { |
| | | //è·åå½ååºå |
| | | Dt_ProStockInfo? proStockInfo = proStockInfos.FirstOrDefault(x => x.Id == item.ProStockId); |
| | | if (proStockInfo!=null && proStockInfo.proStockInfoDetails.Count>0) |
| | | { |
| | | proStockInfo.ShipmentOrder = proOutOrder.ProOutOrderNo; |
| | | proStockInfo.StockStatus = StockStatusEmun.å¹³åºå¾
åè´§.ObjToInt(); |
| | | //å©ä½æ°é |
| | | float Amount = proOutOrderDetail.QtyPcs - proOutOrderDetail.LockQtyPcs; |
| | | if (Amount > item.SumStocks) |
| | | { |
| | | proOutOrderDetail.LockQtyPcs += item.SumStocks; |
| | | Dt_ProStockInfoDetail proStockInfoDetail = proStockInfo.proStockInfoDetails.FirstOrDefault(); |
| | | |
| | | proStockInfoDetail.OutboundQuantity = proStockInfoDetail.StockPcsQty; |
| | | proStockInfoDetail.OutSETQty = proStockInfoDetail.SETQty; |
| | | proStockInfoDetail.OutDetailSaleNo = proOutOrderDetail.SaleOrder; |
| | | outStockInfoDetails.Add(proStockInfoDetail); |
| | | } |
| | | else |
| | | { |
| | | Dt_ProStockInfoDetail proStockInfoDetail = proStockInfo.proStockInfoDetails.FirstOrDefault(); |
| | | float intervalSet = proStockInfoDetail.StockPcsQty / proStockInfoDetail.SETQty; |
| | | proStockInfoDetail.OutboundQuantity += Amount; |
| | | proStockInfoDetail.OutSETQty += (Amount / intervalSet); |
| | | proOutOrderDetail.LockQtyPcs += Amount; |
| | | proStockInfoDetail.OutDetailSaleNo = proOutOrderDetail.SaleOrder; |
| | | outStockInfoDetails.Add(proStockInfoDetail); |
| | | } |
| | | if (proOutOrderDetail.QtyPcs==proOutOrderDetail.LockQtyPcs) |
| | | { |
| | | proOutOrderDetail.ProOrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt(); |
| | | } |
| | | outStockInfos.Add(proStockInfo); |
| | | } |
| | | else |
| | | { |
| | | return content.Error("æªæ¾å°æååºå"); |
| | | } |
| | | } |
| | | List<Dt_ProStockInfo> deleteStocks=new List<Dt_ProStockInfo>(); |
| | | List<Dt_ProStockInfoDetail> deleteStockDetails = new List<Dt_ProStockInfoDetail>(); |
| | | List<Dt_ProStockInfo> updateStocks = new List<Dt_ProStockInfo>(); |
| | | List<Dt_ProStockInfoDetail> updateStockDetails = new List<Dt_ProStockInfoDetail>(); |
| | | if (proOutOrderDetail.ProOrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt() && (OverCount+1)== proOutOrder.Details.Count) |
| | | { |
| | | proOutOrder.ProOrderStatus=OutOrderStatusEnum.åºåºå®æ.ObjToInt(); |
| | | //è·åææå·²æ«ç å¾
åè´§çåºå |
| | | List<Dt_ProStockInfo> AllOutStocks = _stockRepository.ProStockInfoRepository.Db.Queryable<Dt_ProStockInfo>() |
| | | .Where(x => x.ShipmentOrder == proOutOrder.ProOutOrderNo && x.StockStatus == StockStatusEmun.å¹³åºå¾
åè´§.ObjToInt()) |
| | | .Includes(x => x.proStockInfoDetails).ToList(); |
| | | AllOutStocks.ForEach(x => |
| | | { |
| | | outStockInfoDetails.AddRange(x.proStockInfoDetails); |
| | | }); |
| | | outStockInfos.AddRange(AllOutStocks); |
| | | foreach (var item in outStockInfoDetails) |
| | | { |
| | | StockOutItemsItem outItemsItem = new StockOutItemsItem() |
| | | { |
| | | PartNum = item.ProductCode, |
| | | Rev = item.ProductVersion, |
| | | SoNumber = item.OutDetailSaleNo, |
| | | BatchNumber = item.BagNo, |
| | | QtyPcs = item.OutboundQuantity, |
| | | QtySet = item.OutSETQty |
| | | }; |
| | | stockOutItems.Add(outItemsItem); |
| | | if (item.OutboundQuantity == item.StockPcsQty) |
| | | { |
| | | Dt_ProStockInfo proStockInfo = outStockInfos.FirstOrDefault(x => x.Id == item.ProStockId); |
| | | if (proStockInfo != null) |
| | | { |
| | | deleteStocks.Add(proStockInfo); |
| | | deleteStockDetails.Add(item); |
| | | } |
| | | else |
| | | { |
| | | return content.Error("æªæ¾å°ä¸æ¥çåºåæ°æ®"); |
| | | } |
| | | } |
| | | if (item.OutboundQuantity < item.StockPcsQty) |
| | | { |
| | | Dt_ProStockInfo proStockInfo = outStockInfos.FirstOrDefault(x => x.Id == item.ProStockId); |
| | | if (proStockInfo != null) |
| | | { |
| | | proStockInfo.StockStatus = StockStatusEmun.å¹³åºå
¥åºå®æ.ObjToInt(); |
| | | proStockInfo.ShipmentOrder = ""; |
| | | updateStocks.Add(proStockInfo); |
| | | item.StockPcsQty -= item.OutboundQuantity; |
| | | item.OutboundQuantity = 0; |
| | | item.OutSETQty = 0; |
| | | updateStockDetails.Add(item); |
| | | } |
| | | else |
| | | { |
| | | return content.Error("æªæ¾å°ä¸æ¥çåºåæ°æ®"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseId == proOutOrder.WarehouseId); |
| | | _unitOfWorkManage.BeginTran(); |
| | | if (proOutOrder.ProOrderStatus == OutOrderStatusEnum.åºåºå®æ.ObjToInt()) |
| | | { |
| | | //æååºåè®°å½åå¨å¾
å å
¥ |
| | | ERPProOutOrderModel proOutOrderModel = new ERPProOutOrderModel() |
| | | { |
| | | Way = 1, |
| | | StockOutCode = _outboundService.OutboundOrderService.CreateCodeByRule(nameof(RuleCodeEnum.ProOutCOdeRule)), |
| | | ConfirmedUserNo = App.User.UserName, |
| | | AssignUserNo = App.User.UserName, |
| | | WarehouseCode = warehouse.WarehouseCode, |
| | | ShipDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), |
| | | DeliverplanCode = proOutOrder.ProOutOrderNo, |
| | | Remark = proOutOrder.Remark, |
| | | StockOutItems = stockOutItems |
| | | }; |
| | | _stockRepository.ProStockInfoRepository.DeleteAndMoveIntoHty(deleteStocks, OperateTypeEnum.èªå¨å®æ); |
| | | _stockRepository.ProStockInfoDetailRepository.DeleteAndMoveIntoHty(deleteStockDetails, OperateTypeEnum.èªå¨å®æ); |
| | | if (updateStockDetails.Count>0) |
| | | { |
| | | _stockRepository.ProStockInfoRepository.UpdateData(updateStocks); |
| | | updateStockDetails.ForEach(x => |
| | | { |
| | | x.OutDetailSaleNo = ""; |
| | | }); |
| | | _stockRepository.ProStockInfoDetailRepository.UpdateData(updateStockDetails); |
| | | } |
| | | string response = _invokeERPService.InvokeProOutApi(proOutOrderModel); |
| | | ErpRequestContent erpRequestContent = response.DeserializeObject<ErpRequestContent>(); |
| | | if (erpRequestContent.res != 1) |
| | | { |
| | | throw new Exception("忥ERP失败,é误信æ¯:" + erpRequestContent.Data); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | _stockRepository.ProStockInfoRepository.UpdateData(outStockInfos); |
| | | _stockRepository.ProStockInfoDetailRepository.UpdateData(outStockInfoDetails); |
| | | _outboundRepository.ProOutOrderDetailRepository.UpdateData(proOutOrderDetail); |
| | | _outboundRepository.ProOutOrderRepository.UpdateData(proOutOrder); |
| | | } |
| | | _unitOfWorkManage.CommitTran(); |
| | | content.OK("æå"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | /// <summary> |
| | | /// å¤çåºåºæ°æ® |
| | | /// </summary> |
| | | public WebResponseContent GenerateOutboundTaskDataUpdate(List<Dt_Task> tasks, List<Dt_ProStockInfo>? proStockInfos = null, List<Dt_ProOutOrderDetail>? proOutOrderDetails = null, List<Dt_OutProStockInfo>? outProStockInfos = null, List<Dt_LocationInfo>? locationInfos = null) |
| | | { |
| | | try |
| | | { |
| | | _unitOfWorkManage.BeginTran(); |
| | | |
| | | //è·åæååºåºå主表 |
| | | Dt_ProOutOrder proOutOrder = _outboundRepository.ProOutOrderRepository.QueryFirst(x => x.Id == proOutOrderDetails.FirstOrDefault().ProOrderId); |
| | | if (proOutOrder!=null && proOutOrder.ProOrderStatus == OutOrderStatusEnum.æªå¼å§.ObjToInt()) |
| | | { |
| | | proOutOrder.ProOrderStatus = OutOrderStatusEnum.åºåºä¸.ObjToInt(); |
| | | _outboundRepository.ProOutOrderRepository.UpdateData(proOutOrder); |
| | | } |
| | | BaseDal.AddData(tasks); |
| | | if (proStockInfos != null && proStockInfos.Count > 0 && proOutOrderDetails != null && proOutOrderDetails.Count > 0 && outProStockInfos != null && outProStockInfos.Count > 0 && locationInfos != null && locationInfos.Count > 0) |
| | | { |
| | | proStockInfos.ForEach(x => |
| | | { |
| | | x.StockStatus = StockStatusEmun.åºåºéå®.ObjToInt(); |
| | | }); |
| | | WebResponseContent content = _outboundService.ProOutOrderDetailService.LockOutboundStockDataUpdate(proStockInfos, proOutOrderDetails, outProStockInfos, locationInfos, tasks: tasks); |
| | | |
| | | if (!content.Status) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return content; |
| | | } |
| | | } |
| | | else if (proOutOrderDetails != null && proOutOrderDetails.Count > 0) |
| | | { |
| | | proOutOrderDetails.ForEach(x => |
| | | { |
| | | x.ProOrderDetailStatus = OrderDetailStatusEnum.Outbound.ObjToInt(); |
| | | }); |
| | | |
| | | _outboundRepository.ProOutOrderDetailRepository.UpdateData(proOutOrderDetails); |
| | | } |
| | | _unitOfWorkManage.CommitTran(); |
| | | PushTasksToWCS(tasks); |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | |
| | | } |
| | | /// <summary> |
| | | /// å¤çæååºåºæ°æ® |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public (List<Dt_Task>, List<Dt_ProStockInfo>?, List<Dt_ProOutOrderDetail>?, List<Dt_OutProStockInfo>?, List<Dt_LocationInfo>?) OutProductTaskDataHandle(List<Dt_ProOutOrderDetail> proOutOrderDetails) |
| | | { |
| | | List<Dt_Task> tasks = new List<Dt_Task>(); |
| | | List<Dt_ProStockInfo> proStockInfos = new List<Dt_ProStockInfo>(); |
| | | List<Dt_ProOutOrderDetail> assignOutOrderDetails = new List<Dt_ProOutOrderDetail>(); |
| | | List<Dt_OutProStockInfo> outProStockInfos=new List<Dt_OutProStockInfo>(); |
| | | List<Dt_LocationInfo> locationInfos = new List<Dt_LocationInfo>(); |
| | | //åé
åºå |
| | | (List<Dt_ProStockInfo>, List<Dt_ProOutOrderDetail>, List<Dt_OutProStockInfo>, List<Dt_LocationInfo>) result = _outboundService.ProOutOrderDetailService.AssignProStockOut(proOutOrderDetails); |
| | | if (result.Item1!=null&&result.Item1.Count>0) |
| | | { |
| | | //è·åæåå |
| | | Dt_ProOutOrder proOutOrder = _outboundRepository.ProOutOrderRepository.QueryFirst(x => x.Id == proOutOrderDetails.FirstOrDefault().ProOrderId); |
| | | if (proOutOrder==null) |
| | | { |
| | | throw new Exception("æªæ¾å°æå订å"); |
| | | } |
| | | TaskTypeEnum typeEnum = proOutOrder.ProOrderType switch |
| | | { |
| | | (int)OutProTypeEnum.ProOut => TaskTypeEnum.OutProduct, |
| | | (int)OutProTypeEnum.SendProOut => TaskTypeEnum.OutSendProduct, |
| | | _ => new TaskTypeEnum() |
| | | }; |
| | | tasks = GetTasks(result.Item1, typeEnum); |
| | | result.Item2.ForEach(x => |
| | | { |
| | | x.ProOrderDetailStatus = OrderDetailStatusEnum.Outbound.ObjToInt(); |
| | | }); |
| | | result.Item3.ForEach(x => |
| | | { |
| | | x.Status = OutLockStockStatusEnum.åºåºä¸.ObjToInt(); |
| | | }); |
| | | tasks.ForEach(x => x.OrderNo = proOutOrder.ProOutOrderNo); |
| | | proStockInfos = result.Item1; |
| | | proOutOrderDetails = result.Item2; |
| | | outProStockInfos = result.Item3; |
| | | locationInfos = result.Item4; |
| | | } |
| | | else |
| | | { |
| | | throw new Exception("æ å¯åé
åºå"); |
| | | } |
| | | return (tasks, proStockInfos, proOutOrderDetails, outProStockInfos, locationInfos); |
| | | } |
| | | /// <summary> |
| | | /// çæä»»å¡ |
| | | /// </summary> |
| | | /// <param name="stockInfos"></param> |
| | | /// <param name="taskType"></param> |
| | | /// <returns></returns> |
| | | public List<Dt_Task> GetTasks(List<Dt_ProStockInfo> stockInfos, TaskTypeEnum taskType) |
| | | { |
| | | List<Dt_Task> tasks = new List<Dt_Task>(); |
| | | string groupId = DateTime.Now.ToString("yyMMddHHmmss"); |
| | | for (int i = 1; i <= stockInfos.Count; i++) |
| | | { |
| | | Dt_ProStockInfo stockInfo = stockInfos[i-1]; |
| | | if (i%5==0) |
| | | { |
| | | groupId= DateTime.Now.AddSeconds(i).ToString("yyMMddHHmmss"); |
| | | } |
| | | if (stockInfo != null) |
| | | { |
| | | Dt_LocationInfo locationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == stockInfo.LocationCode); |
| | | if (!tasks.Exists(x => x.PalletCode == stockInfo.PalletCode)) |
| | | { |
| | | Dt_Task task = new() |
| | | { |
| | | CurrentAddress = stockInfo.LocationCode, |
| | | Grade = 0, |
| | | PalletCode = stockInfo.PalletCode, |
| | | NextAddress = "", |
| | | Roadway = locationInfo.RoadwayNo, |
| | | SourceAddress = stockInfo.LocationCode, |
| | | TargetAddress = "", |
| | | TaskStatus = TaskStatusEnum.New.ObjToInt(), |
| | | TaskType = taskType.ObjToInt(), |
| | | TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), |
| | | PalletType = stockInfo.PalletType, |
| | | WarehouseId = stockInfo.WarehouseId, |
| | | GroupId= groupId, |
| | | MaterielCode = stockInfo.proStockInfoDetails.Where(x => x.ProStockId == stockInfo.Id).FirstOrDefault()?.ProductCode, |
| | | Quantity = (float)stockInfo.proStockInfoDetails.Where(x => x.ProStockId == stockInfo.Id).Sum(x=> x.StockPcsQty) |
| | | }; |
| | | tasks.Add(task); |
| | | } |
| | | } |
| | | } |
| | | return tasks; |
| | | } |
| | | /// <summary> |
| | | /// åºåæ°æ®è½¬åºåºä»»å¡ |
| | | /// </summary> |
| | | /// <param name="stockInfos"></param> |
| | |
| | | } |
| | | return tasks; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// åºåºä»»å¡æ°æ®å¤ç |
| | | /// </summary> |
| | | /// <param name="orderDetailId"></param> |
| | | /// <param name="stockSelectViews"></param> |
| | | /// <returns></returns> |
| | | /// <exception cref="Exception"></exception> |
| | | public (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) OutboundTaskDataHandle(int orderDetailId, List<StockSelectViewDTO> stockSelectViews) |
| | | { |
| | | List<Dt_Task> tasks = new List<Dt_Task>(); |
| | | Dt_OutboundOrderDetail outboundOrderDetail = _outboundService.OutboundOrderDetailService.Repository.QueryFirst(x => x.Id == orderDetailId); |
| | | |
| | | if (outboundOrderDetail == null) |
| | | { |
| | | throw new Exception("æªæ¾å°åºåºåæç»ä¿¡æ¯"); |
| | | } |
| | | |
| | | if (stockSelectViews.Sum(x => x.UseableQuantity) > outboundOrderDetail.OrderQuantity - outboundOrderDetail.LockQuantity) |
| | | { |
| | | throw new Exception("éæ©æ°éè¶
åºåæ®æ°é"); |
| | | } |
| | | List<Dt_StockInfo>? stockInfos = null; |
| | | Dt_OutboundOrderDetail? orderDetail = null; |
| | | List<Dt_OutStockLockInfo>? outStockLockInfos = null; |
| | | List<Dt_LocationInfo>? locationInfos = null; |
| | | if (outboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.New.ObjToInt()) |
| | | { |
| | | (List<Dt_StockInfo>, Dt_OutboundOrderDetail, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outboundService.OutboundOrderDetailService.AssignStockOutbound(outboundOrderDetail, stockSelectViews); |
| | | if (result.Item1 != null && result.Item1.Count > 0) |
| | | { |
| | | Dt_OutboundOrder outboundOrder = _outboundService.OutboundOrderService.Repository.QueryFirst(x => x.Id == outboundOrderDetail.OrderId); |
| | | TaskTypeEnum typeEnum = outboundOrder.OrderType switch |
| | | { |
| | | (int)OutOrderTypeEnum.Issue => TaskTypeEnum.Outbound, |
| | | (int)OutOrderTypeEnum.Allocate => TaskTypeEnum.OutAllocate, |
| | | (int)OutOrderTypeEnum.Quality => TaskTypeEnum.OutQuality, |
| | | _ => new TaskTypeEnum() |
| | | }; |
| | | tasks = GetTasks(result.Item1, typeEnum); |
| | | result.Item2.OrderDetailStatus = OrderDetailStatusEnum.Outbound.ObjToInt(); |
| | | result.Item3.ForEach(x => |
| | | { |
| | | x.Status = OutLockStockStatusEnum.åºåºä¸.ObjToInt(); |
| | | }); |
| | | |
| | | stockInfos = result.Item1; |
| | | orderDetail = result.Item2; |
| | | outStockLockInfos = result.Item3; |
| | | locationInfos = result.Item4; |
| | | } |
| | | else |
| | | { |
| | | throw new Exception("æ åºå"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | List<Dt_OutStockLockInfo> stockLockInfos = _outboundService.OutboundStockLockInfoService.GetByOrderDetailId(outboundOrderDetail.OrderId, OutLockStockStatusEnum.å·²åé
); |
| | | if (stockLockInfos != null && stockLockInfos.Count > 0) |
| | | { |
| | | List<Dt_StockInfo> stocks = _stockService.StockInfoService.Repository.GetStockInfosByPalletCodes(stockLockInfos.Select(x => x.PalletCode).Distinct().ToList()); |
| | | tasks = GetTasks(stocks, TaskTypeEnum.Outbound); |
| | | } |
| | | } |
| | | |
| | | return (tasks, stockInfos, orderDetail == null ? null : new List<Dt_OutboundOrderDetail> { orderDetail }, outStockLockInfos, locationInfos); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// åºåºä»»å¡æ°æ®å¤ç |
| | | /// </summary> |
| | | /// <param name="orderDetailId"></param> |
| | | /// <param name="stockSelectViews"></param> |
| | | /// <returns></returns> |
| | | /// <exception cref="Exception"></exception> |
| | | public (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) OutboundTaskDataHandle(int[] keys) |
| | | { |
| | | List<Dt_Task> tasks = new List<Dt_Task>(); |
| | | List<Dt_OutboundOrderDetail> outboundOrderDetails = _outboundService.OutboundOrderDetailService.Repository.QueryData(x => keys.Contains(x.Id)); |
| | | |
| | | if (outboundOrderDetails == null || outboundOrderDetails.Count == 0) |
| | | { |
| | | throw new Exception("æªæ¾å°åºåºåæç»ä¿¡æ¯"); |
| | | } |
| | | if (outboundOrderDetails.FirstOrDefault(x => x.OrderDetailStatus > OrderDetailStatusEnum.New.ObjToInt() && x.OrderDetailStatus != OrderDetailStatusEnum.AssignOverPartial.ObjToInt()) != null) |
| | | { |
| | | throw new Exception("æéåºåºåæç»åå¨åºåºä¸æå·²å®æ"); |
| | | } |
| | | List<Dt_StockInfo>? stockInfos = null; |
| | | List<Dt_OutboundOrderDetail>? orderDetails = null; |
| | | List<Dt_OutStockLockInfo>? outStockLockInfos = null; |
| | | List<Dt_LocationInfo>? locationInfos = null; |
| | | //if (outboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.New.ObjToInt()) |
| | | { |
| | | (List<Dt_StockInfo>, List<Dt_OutboundOrderDetail>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outboundService.OutboundOrderDetailService.AssignStockOutbound(outboundOrderDetails); |
| | | if (result.Item1 != null && result.Item1.Count > 0) |
| | | { |
| | | Dt_OutboundOrder outboundOrder =_outboundService.OutboundOrderService.Repository.QueryFirst(x => x.Id == outboundOrderDetails.FirstOrDefault().OrderId); |
| | | TaskTypeEnum typeEnum = outboundOrder.OrderType switch |
| | | { |
| | | (int)OutOrderTypeEnum.Issue => TaskTypeEnum.Outbound, |
| | | (int)OutOrderTypeEnum.Allocate=> TaskTypeEnum.OutAllocate, |
| | | (int)OutOrderTypeEnum.Quality => TaskTypeEnum.OutQuality, |
| | | _ =>new TaskTypeEnum() |
| | | }; |
| | | tasks = GetTasks(result.Item1, typeEnum); |
| | | tasks.ForEach(x => |
| | | { |
| | | x.OrderNo = outboundOrder.UpperOrderNo; |
| | | }); |
| | | result.Item2.ForEach(x => |
| | | { |
| | | x.OrderDetailStatus = OrderDetailStatusEnum.Outbound.ObjToInt(); |
| | | }); |
| | | result.Item3.ForEach(x => |
| | | { |
| | | x.Status = OutLockStockStatusEnum.åºåºä¸.ObjToInt(); |
| | | }); |
| | | |
| | | stockInfos = result.Item1; |
| | | orderDetails = result.Item2; |
| | | outStockLockInfos = result.Item3; |
| | | locationInfos = result.Item4; |
| | | } |
| | | else |
| | | { |
| | | throw new Exception("æ åºå"); |
| | | } |
| | | } |
| | | //else |
| | | //{ |
| | | // List<Dt_OutStockLockInfo> stockLockInfos = _outboundService.OutboundStockLockInfoService.GetByOrderDetailId(outboundOrderDetail.OrderId, OutLockStockStatusEnum.å·²åé
); |
| | | // if (stockLockInfos != null && stockLockInfos.Count > 0) |
| | | // { |
| | | // List<Dt_StockInfo> stocks = _stockService.StockInfoService.Repository.GetStockInfosByPalletCodes(stockLockInfos.Select(x => x.PalletCode).Distinct().ToList()); |
| | | // tasks = GetTasks(stocks); |
| | | // } |
| | | //} |
| | | |
| | | return (tasks, stockInfos, orderDetails, outStockLockInfos, locationInfos); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// çæåºåºä»»å¡ |
| | | /// </summary> |
| | | /// <param name="orderDetailId"></param> |
| | | /// <param name="stockSelectViews"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent GenerateOutboundTask(int orderDetailId, List<StockSelectViewDTO> stockSelectViews) |
| | | { |
| | | try |
| | | { |
| | | (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) result = OutboundTaskDataHandle(orderDetailId, stockSelectViews); |
| | | |
| | | WebResponseContent content = GenerateOutboundTaskDataUpdate(result.Item1, result.Item2, result.Item3, result.Item4, result.Item5); |
| | | |
| | | return content; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å¹³åºç´æ¥åºåº |
| | | /// </summary> |
| | | /// <param name="orderDetailId"></param> |
| | | /// <param name="stockSelectViews"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent GeneratePKOutboundTask(int orderDetailId, List<StockSelectViewDTO> stockSelectViews) |
| | | { |
| | | try |
| | | { |
| | | #region MyRegion |
| | | Dt_OutboundOrderDetail OrderDetail = _outboundService.OutboundOrderDetailService.Repository.QueryFirst(x => x.Id == orderDetailId); |
| | | |
| | | if (OrderDetail == null) |
| | | { |
| | | throw new Exception("æªæ¾å°åºåºåæç»ä¿¡æ¯"); |
| | | } |
| | | if (OrderDetail.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()) |
| | | throw new Exception("åºåºå已宿"); |
| | | Dt_OutboundOrder outboundOrder = BaseDal.Db.Queryable<Dt_OutboundOrder>().Where(x => x.Id == OrderDetail.OrderId).Includes(x => x.Details).First(); |
| | | if (outboundOrder == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°åºåºåä¿¡æ¯"); |
| | | } |
| | | Dt_Warehouse warehouse = _basicService.WarehouseService.Repository.QueryFirst(x => x.WarehouseId == outboundOrder.WarehouseId); |
| | | List<Dt_StockInfo> outStocks = _stockService.StockInfoService.Repository.GetStockInfosByPalletCodes(stockSelectViews.Select(x => x.PalletCode).ToList()); |
| | | if (outStocks.Count < 1) return WebResponseContent.Instance.Error($"åºåä¸è¶³"); |
| | | List<Dt_OutStockLockInfo> outStockLockInfos = new List<Dt_OutStockLockInfo>(); |
| | | List<Dt_StockInfo> upStocks = new List<Dt_StockInfo>(); |
| | | List<Dt_StockInfo> deStocks = new List<Dt_StockInfo>(); |
| | | List<Dt_StockInfoDetail> upstockDetails = new List<Dt_StockInfoDetail>(); |
| | | List<Dt_StockInfoDetail> destockDetails = new List<Dt_StockInfoDetail>(); |
| | | outStocks.ForEach(x => |
| | | { |
| | | x.Details.Where(x => x.MaterielCode == OrderDetail.MaterielCode).ToList().ForEach(v => |
| | | { |
| | | float OriginalQuantity = v.StockQuantity; |
| | | float assignQuantity = 0;//åé
æ°é |
| | | float assignAmount = OrderDetail.OrderQuantity - OrderDetail.OverOutQuantity;//å¾
åºæ°é |
| | | if (assignAmount > 0) |
| | | { |
| | | if (v.StockQuantity >= assignAmount) |
| | | { |
| | | assignQuantity = assignAmount; |
| | | v.StockQuantity -= assignAmount; |
| | | OrderDetail.OverOutQuantity += assignAmount; |
| | | OrderDetail.LockQuantity += assignAmount; |
| | | upstockDetails.Add(v); |
| | | } |
| | | else |
| | | { |
| | | assignQuantity = v.StockQuantity; |
| | | OrderDetail.OverOutQuantity += v.StockQuantity; |
| | | OrderDetail.LockQuantity += v.StockQuantity; |
| | | v.StockQuantity = 0; |
| | | destockDetails.Add(v); |
| | | } |
| | | Dt_OutStockLockInfo outStockLockInfo = new Dt_OutStockLockInfo() |
| | | { |
| | | PalletCode = x.PalletCode, |
| | | AssignQuantity = assignQuantity, |
| | | MaterielCode = OrderDetail.MaterielCode, |
| | | BatchNo = v.BatchNo, |
| | | LocationCode = x.LocationCode, |
| | | MaterielName = v.MaterielName, |
| | | OrderDetailId = OrderDetail.Id, |
| | | OrderNo = outboundOrder.OrderNo, |
| | | OrderType = outboundOrder.OrderType, |
| | | OriginalQuantity = OriginalQuantity, |
| | | Status = OutLockStockStatusEnum.åºåºå®æ.ObjToInt(), |
| | | StockId = x.Id, |
| | | TaskNum = 0, |
| | | OrderQuantity = OrderDetail.OrderQuantity, |
| | | Unit = OrderDetail.Unit, |
| | | ProductionDate = v.ProductionDate, |
| | | EffectiveDate = v.EffectiveDate |
| | | }; |
| | | outStockLockInfos.Add(outStockLockInfo); |
| | | } |
| | | }); |
| | | int overCount = x.Details.Where(x => x.StockQuantity == 0).Count(); |
| | | if (overCount == x.Details.Count) deStocks.Add(x); |
| | | else upStocks.Add(x); |
| | | }); |
| | | outboundOrder.OrderStatus = OutOrderStatusEnum.åºåºä¸.ObjToInt(); |
| | | OrderDetail.OrderDetailStatus = OrderDetail.OrderQuantity > OrderDetail.OverOutQuantity ? OrderDetailStatusEnum.AssignOverPartial.ObjToInt() : OrderDetailStatusEnum.Over.ObjToInt(); |
| | | if (OrderDetail.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()) |
| | | { |
| | | int overCount = outboundOrder.Details.Where(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()).Count(); |
| | | if (outboundOrder.Details.Count - 1 == overCount) |
| | | outboundOrder.OrderStatus = OutOrderStatusEnum.åºåºå®æ.ObjToInt(); |
| | | } |
| | | _unitOfWorkManage.BeginTran(); |
| | | _outboundService.OutboundStockLockInfoService.AddData(outStockLockInfos); |
| | | _outboundService.OutboundOrderService.UpdateData(outboundOrder); |
| | | _outboundService.OutboundOrderDetailService.UpdateData(OrderDetail); |
| | | _stockRepository.StockInfoRepository.UpdateData(upStocks); |
| | | _stockRepository.StockInfoRepository.DeleteData(deStocks); |
| | | _stockRepository.StockInfoDetailRepository.UpdateData(upstockDetails); |
| | | _stockRepository.StockInfoDetailRepository.DeleteData(destockDetails); |
| | | _unitOfWorkManage.CommitTran(); |
| | | #endregion |
| | | |
| | | #region 䏿¥ERP |
| | | if (outboundOrder.OrderStatus == OutOrderStatusEnum.åºåºå®æ.ObjToInt() && outboundOrder.OrderType==OutOrderTypeEnum.Issue.ObjToInt()) |
| | | { |
| | | //List<ERPPickModel> eRPPickModels = new List<ERPPickModel>(); |
| | | //outStockLockInfos.ForEach(x => |
| | | //{ |
| | | // ERPPickItemModel pickItemModel = new ERPPickItemModel() |
| | | // { |
| | | // Lotno = x.BatchNo, |
| | | // Qty = x.AssignQuantity.ToString(), |
| | | // Location = warehouse.WarehouseCode |
| | | // }; |
| | | // ERPPickModel pickModel = new ERPPickModel() |
| | | // { |
| | | // Rowindex = OrderDetail.RowNo, |
| | | // Material = OrderDetail.MaterielCode, |
| | | // Qty = pickItemModel.Qty, |
| | | // Dataitem = new List<ERPPickItemModel> { pickItemModel } |
| | | // }; |
| | | // eRPPickModels.Add(pickModel); |
| | | //}); |
| | | //ERPIssueItemModel issueItemModel = new ERPIssueItemModel() |
| | | //{ |
| | | // Pickcode = outboundOrder.UpperOrderNo, |
| | | // PickList = eRPPickModels |
| | | //}; |
| | | //ERPIssueModel issueModel = new ERPIssueModel() |
| | | //{ |
| | | // UniqueTag = outboundOrder.Id.ToString(), |
| | | // Code = _outboundService.OutboundOrderService.CreateCodeByRule(nameof(RuleCodeEnum.FLCodeRule)), |
| | | // WarehouseCode = warehouse.WarehouseCode, |
| | | // Docremark = "", |
| | | // Deptno = outboundOrder.DepartmentCode, |
| | | // Deptname = outboundOrder.DepartmentName, |
| | | // Createtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), |
| | | // Createuser = App.User.UserName, |
| | | // Issitem = new List<ERPIssueItemModel>() { issueItemModel } |
| | | //}; |
| | | _invokeERPService.InvokeOutStandardsApi(_outboundService.OutboundOrderService.GetERPIssueModel(outboundOrder, warehouse.WarehouseCode)); |
| | | } |
| | | #endregion |
| | | |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// çæåºåºä»»å¡åæ°æ®æ´æ°å°æ°æ®åº |
| | | /// </summary> |
| | | /// <param name="tasks"></param> |
| | | /// <param name="stockInfos"></param> |
| | | /// <param name="outboundOrderDetails"></param> |
| | | /// <param name="outStockLockInfos"></param> |
| | | /// <param name="locationInfos"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent GenerateOutboundTaskDataUpdate(List<Dt_Task> tasks, List<Dt_StockInfo>? stockInfos = null, List<Dt_OutboundOrderDetail>? outboundOrderDetails = null, List<Dt_OutStockLockInfo>? outStockLockInfos = null, List<Dt_LocationInfo>? locationInfos = null) |
| | | { |
| | | try |
| | | { |
| | | _unitOfWorkManage.BeginTran(); |
| | | |
| | | BaseDal.AddData(tasks); |
| | | if (stockInfos != null && stockInfos.Count > 0 && outboundOrderDetails != null && outboundOrderDetails.Count > 0 && outStockLockInfos != null && outStockLockInfos.Count > 0 && locationInfos != null && locationInfos.Count > 0) |
| | | { |
| | | stockInfos.ForEach(x => |
| | | { |
| | | x.StockStatus = StockStatusEmun.åºåºéå®.ObjToInt(); |
| | | }); |
| | | WebResponseContent content = _outboundService.OutboundOrderDetailService.LockOutboundStockDataUpdate(stockInfos, outboundOrderDetails, outStockLockInfos, locationInfos, tasks: tasks); |
| | | |
| | | if (!content.Status) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return content; |
| | | } |
| | | } |
| | | else if (outboundOrderDetails != null && outboundOrderDetails.Count > 0) |
| | | { |
| | | outboundOrderDetails.ForEach(x => |
| | | { |
| | | x.OrderDetailStatus = OrderDetailStatusEnum.Outbound.ObjToInt(); |
| | | }); |
| | | Dt_OutboundOrder outboundOrder = _outboundRepository.OutboundOrderRepository.QueryFirst(x=>x.Id== outboundOrderDetails.FirstOrDefault().OrderId); |
| | | if (outboundOrder.OrderStatus!=OutOrderStatusEnum.åºåºä¸.ObjToInt()) |
| | | { |
| | | _outboundRepository.OutboundOrderRepository.UpdateData(outboundOrder); |
| | | } |
| | | _outboundService.OutboundOrderDetailService.Repository.UpdateData(outboundOrderDetails); |
| | | } |
| | | _unitOfWorkManage.CommitTran(); |
| | | PushTasksToWCS(tasks); |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// çæåºåºä»»å¡ |
| | | /// </summary> |
| | | /// <param name="keys">åºåºåæç»ä¸»é®</param> |
| | | /// <returns></returns> |
| | | public WebResponseContent GenerateOutboundTasks(int[] keys) |
| | | { |
| | | try |
| | | { |
| | | List<Dt_Task> tasks = new List<Dt_Task>(); |
| | | List<StockSelectViewDTO> stockSelectViews = new List<StockSelectViewDTO>(); |
| | | List<Dt_StockInfo> stockInfos = new List<Dt_StockInfo>(); |
| | | List<Dt_OutboundOrderDetail> outboundOrderDetails = new List<Dt_OutboundOrderDetail>(); |
| | | List<Dt_OutStockLockInfo> outStockLockInfos = new List<Dt_OutStockLockInfo>(); |
| | | List<Dt_LocationInfo> locationInfos = new List<Dt_LocationInfo>(); |
| | | |
| | | (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) result = OutboundTaskDataHandle(keys); |
| | | if (result.Item2 != null && result.Item2.Count > 0) |
| | | { |
| | | stockInfos.AddRange(result.Item2); |
| | | } |
| | | if (result.Item3 != null && result.Item3.Count > 0) |
| | | { |
| | | outboundOrderDetails.AddRange(result.Item3); |
| | | } |
| | | if (result.Item4 != null && result.Item4.Count > 0) |
| | | { |
| | | outStockLockInfos.AddRange(result.Item4); |
| | | } |
| | | if (result.Item5 != null && result.Item5.Count > 0) |
| | | { |
| | | locationInfos.AddRange(result.Item5); |
| | | } |
| | | if (result.Item1 != null && result.Item1.Count > 0) |
| | | { |
| | | tasks.AddRange(result.Item1); |
| | | } |
| | | |
| | | WebResponseContent content = GenerateOutboundTaskDataUpdate(tasks, stockInfos, outboundOrderDetails, outStockLockInfos, locationInfos); |
| | | return content; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// çæåºåºä»»å¡ |
| | | /// </summary> |
| | | /// <param name="outboundId">åºåºå主é®</param> |
| | | /// <returns></returns> |
| | | public WebResponseContent GenerateOutboundTaskByHeadId(int outboundId) |
| | | { |
| | | try |
| | | { |
| | | List<int> keys = _outboundService.OutboundOrderDetailService.Repository.QueryData(x => x.Id, x => x.OrderId == outboundId); |
| | | |
| | | return GenerateOutboundTasks(keys.ToArray()); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | #region |
| | | ///// <summary> |
| | | ///// çæåºåºä»»å¡ |
| | | ///// </summary> |
| | | ///// <param name="keys">åºåºåæç»ä¸»é®</param> |
| | | ///// <returns></returns> |
| | | //public WebResponseContent MESPPGenerateOutboundTasks(int[] keys) |
| | | //{ |
| | | // try |
| | | // { |
| | | // List<Dt_Task> tasks = new List<Dt_Task>(); |
| | | // List<StockSelectViewDTO> stockSelectViews = new List<StockSelectViewDTO>(); |
| | | // List<Dt_StockInfo> stockInfos = new List<Dt_StockInfo>(); |
| | | // List<Dt_MesPPOutboundOrderDetail> outboundOrderDetails = new List<Dt_MesPPOutboundOrderDetail>(); |
| | | // List<Dt_OutStockLockInfo> outStockLockInfos = new List<Dt_OutStockLockInfo>(); |
| | | // List<Dt_LocationInfo> locationInfos = new List<Dt_LocationInfo>(); |
| | | |
| | | // (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_MesPPOutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) result = MESPPOutboundTaskDataHandle(keys); |
| | | // if (result.Item2 != null && result.Item2.Count > 0) |
| | | // { |
| | | // stockInfos.AddRange(result.Item2); |
| | | // } |
| | | // if (result.Item3 != null && result.Item3.Count > 0) |
| | | // { |
| | | // outboundOrderDetails.AddRange(result.Item3); |
| | | // } |
| | | // if (result.Item4 != null && result.Item4.Count > 0) |
| | | // { |
| | | // outStockLockInfos.AddRange(result.Item4); |
| | | // } |
| | | // if (result.Item5 != null && result.Item5.Count > 0) |
| | | // { |
| | | // locationInfos.AddRange(result.Item5); |
| | | // } |
| | | // if (result.Item1 != null && result.Item1.Count > 0) |
| | | // { |
| | | // tasks.AddRange(result.Item1); |
| | | // } |
| | | |
| | | // WebResponseContent content = MESPPGenerateOutboundTaskDataUpdate(tasks, stockInfos, outboundOrderDetails, outStockLockInfos, locationInfos); |
| | | // return content; |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // _unitOfWorkManage.RollbackTran(); |
| | | // return WebResponseContent.Instance.Error(ex.Message); |
| | | // } |
| | | //} |
| | | |
| | | ///// <summary> |
| | | ///// åºåºä»»å¡æ°æ®å¤ç |
| | | ///// </summary> |
| | | ///// <param name="orderDetailId"></param> |
| | | ///// <param name="stockSelectViews"></param> |
| | | ///// <returns></returns> |
| | | ///// <exception cref="Exception"></exception> |
| | | //public (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_MesPPOutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) MESPPOutboundTaskDataHandle(int[] keys) |
| | | //{ |
| | | // List<Dt_Task> tasks = new List<Dt_Task>(); |
| | | // List<Dt_MesPPOutboundOrderDetail> outboundOrderDetailss = _outboundService.MesPPOutboundOrderDetailService.Repository.QueryData(x => keys.Contains(x.Id)); |
| | | // List<Dt_MesPPOutboundOrderDetail> outboundOrderDetails = BaseDal.Db.Queryable<Dt_MesPPOutboundOrderDetail>().Where(x => keys.Contains(x.Id)).ToList(); |
| | | // if (outboundOrderDetails == null || outboundOrderDetails.Count == 0) |
| | | // { |
| | | // throw new Exception("æªæ¾å°åºåºåæç»ä¿¡æ¯"); |
| | | // } |
| | | // if (outboundOrderDetails.FirstOrDefault(x => x.OrderDetailStatus > OrderDetailStatusEnum.New.ObjToInt() && x.OrderDetailStatus != OrderDetailStatusEnum.AssignOverPartial.ObjToInt()) != null) |
| | | // { |
| | | // throw new Exception("æéåºåºåæç»åå¨åºåºä¸æå·²å®æ"); |
| | | // } |
| | | // List<Dt_StockInfo>? stockInfos = null; |
| | | // List<Dt_MesPPOutboundOrderDetail>? orderDetails = null; |
| | | // List<Dt_OutStockLockInfo>? outStockLockInfos = null; |
| | | // List<Dt_LocationInfo>? locationInfos = null; |
| | | // //if (outboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.New.ObjToInt()) |
| | | // { |
| | | // (List<Dt_StockInfo>, List<Dt_MesPPOutboundOrderDetail>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outboundService.MesPPOutboundOrderDetailService.AssignStockOutbound(outboundOrderDetails); |
| | | |
| | | // if (result.Item1 != null && result.Item1.Count > 0) |
| | | // { |
| | | // Dt_MesPPOutboundOrder outboundOrder = _outboundService.MesPPOutboundOrderService.Repository.QueryFirst(x => x.Id == outboundOrderDetails.FirstOrDefault().OrderId); |
| | | // TaskTypeEnum typeEnum = outboundOrder.OrderType switch |
| | | // { |
| | | // (int)OutOrderTypeEnum.Issue => TaskTypeEnum.Outbound, |
| | | // (int)OutOrderTypeEnum.Allocate => TaskTypeEnum.OutAllocate, |
| | | // (int)OutOrderTypeEnum.Quality => TaskTypeEnum.OutQuality, |
| | | // _ => new TaskTypeEnum() |
| | | // }; |
| | | // tasks = GetTasks(result.Item1, typeEnum); |
| | | // result.Item2.ForEach(x => |
| | | // { |
| | | // x.OrderDetailStatus = OrderDetailStatusEnum.Outbound.ObjToInt(); |
| | | // }); |
| | | // result.Item3.ForEach(x => |
| | | // { |
| | | // x.Status = OutLockStockStatusEnum.åºåºä¸.ObjToInt(); |
| | | // }); |
| | | |
| | | // stockInfos = result.Item1; |
| | | // orderDetails = result.Item2; |
| | | // outStockLockInfos = result.Item3; |
| | | // locationInfos = result.Item4; |
| | | // } |
| | | // else |
| | | // { |
| | | // throw new Exception("æ åºå"); |
| | | // } |
| | | // } |
| | | // //else |
| | | // //{ |
| | | // // List<Dt_OutStockLockInfo> stockLockInfos = _outboundService.OutboundStockLockInfoService.GetByOrderDetailId(outboundOrderDetail.OrderId, OutLockStockStatusEnum.å·²åé
); |
| | | // // if (stockLockInfos != null && stockLockInfos.Count > 0) |
| | | // // { |
| | | // // List<Dt_StockInfo> stocks = _stockService.StockInfoService.Repository.GetStockInfosByPalletCodes(stockLockInfos.Select(x => x.PalletCode).Distinct().ToList()); |
| | | // // tasks = GetTasks(stocks); |
| | | // // } |
| | | // //} |
| | | |
| | | // return (tasks, stockInfos, orderDetails, outStockLockInfos, locationInfos); |
| | | //} |
| | | |
| | | ///// <summary> |
| | | ///// çæåºåºä»»å¡åæ°æ®æ´æ°å°æ°æ®åº |
| | | ///// </summary> |
| | | ///// <param name="tasks"></param> |
| | | ///// <param name="stockInfos"></param> |
| | | ///// <param name="outboundOrderDetails"></param> |
| | | ///// <param name="outStockLockInfos"></param> |
| | | ///// <param name="locationInfos"></param> |
| | | ///// <returns></returns> |
| | | //public WebResponseContent MESPPGenerateOutboundTaskDataUpdate(List<Dt_Task> tasks, List<Dt_StockInfo>? stockInfos = null, List<Dt_MesPPOutboundOrderDetail>? outboundOrderDetails = null, List<Dt_OutStockLockInfo>? outStockLockInfos = null, List<Dt_LocationInfo>? locationInfos = null) |
| | | //{ |
| | | // try |
| | | // { |
| | | // _unitOfWorkManage.BeginTran(); |
| | | |
| | | // BaseDal.AddData(tasks); |
| | | // if (stockInfos != null && stockInfos.Count > 0 && outboundOrderDetails != null && outboundOrderDetails.Count > 0 && outStockLockInfos != null && outStockLockInfos.Count > 0 && locationInfos != null && locationInfos.Count > 0) |
| | | // { |
| | | // stockInfos.ForEach(x => |
| | | // { |
| | | // x.StockStatus = StockStatusEmun.åºåºéå®.ObjToInt(); |
| | | // }); |
| | | // WebResponseContent content = _outboundService.MesPPOutboundOrderDetailService.LockOutboundStockDataUpdate(stockInfos, outboundOrderDetails, outStockLockInfos, locationInfos, tasks: tasks); |
| | | |
| | | // if (!content.Status) |
| | | // { |
| | | // _unitOfWorkManage.RollbackTran(); |
| | | // return content; |
| | | // } |
| | | // } |
| | | // else if (outboundOrderDetails != null && outboundOrderDetails.Count > 0) |
| | | // { |
| | | // outboundOrderDetails.ForEach(x => |
| | | // { |
| | | // x.OrderDetailStatus = OrderDetailStatusEnum.Outbound.ObjToInt(); |
| | | // }); |
| | | |
| | | // _outboundService.MesPPOutboundOrderDetailService.Repository.UpdateData(outboundOrderDetails); |
| | | // } |
| | | // _unitOfWorkManage.CommitTran(); |
| | | // PushTasksToWCS(tasks); |
| | | // return WebResponseContent.Instance.OK(); |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // _unitOfWorkManage.RollbackTran(); |
| | | // return WebResponseContent.Instance.Error(ex.Message); |
| | | // } |
| | | |
| | | //} |
| | | #endregion |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | } |
| | |
| | | using WIDESEA_DTO.Stock; |
| | | using WIDESEA_IBasicRepository; |
| | | using WIDESEA_IBasicService; |
| | | using WIDESEA_IInboundService; |
| | | using WIDESEA_IOutboundRepository; |
| | | using WIDESEA_IOutboundService; |
| | | using WIDESEA_IRecordService; |
| | | using WIDESEA_IStockRepository; |
| | | using WIDESEA_IStockService; |
| | |
| | | using WIDESEA_Core.BaseController; |
| | | using WIDESEA_Core.Helper; |
| | | using WIDESEA_IApprovalService; |
| | | using WIDESEA_ICheckRepository; |
| | | using WIDESEA_Model.Models; |
| | | |
| | | namespace WIDESEA_WMSServer.Controllers.Approval |
| | |
| | | [ApiController] |
| | | public class ApprovalTaskController : ApiBaseController<IApprovalTaskService, Dt_ApprovalTask> |
| | | { |
| | | private readonly ICheckOrderRepository _checkOrderRepository; |
| | | private readonly WebSocketServer _webSocketServer; |
| | | |
| | | public ApprovalTaskController(IApprovalTaskService service, ICheckOrderRepository checkOrderRepository, WebSocketServer webSocketServer) : base(service) |
| | | public ApprovalTaskController(IApprovalTaskService service, WebSocketServer webSocketServer) : base(service) |
| | | { |
| | | _checkOrderRepository = checkOrderRepository; |
| | | _webSocketServer = webSocketServer; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// åæå®¡æ¹ |
| | | /// </summary> |
| | | /// <param name="sourceKey"></param> |
| | | /// <returns></returns> |
| | | [HttpGet, HttpPost, Route("AuditAgree")] |
| | | public WebResponseContent AuditAgree(int sourceKey) |
| | | { |
| | | return Service.AuditAgree(sourceKey); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 驳åå®¡æ¹ |
| | | /// </summary> |
| | | /// <param name="sourceKey"></param> |
| | | /// <returns></returns> |
| | | [HttpGet, HttpPost, Route("AuditReject")] |
| | | public WebResponseContent AuditReject(int sourceKey) |
| | | { |
| | | return Service.AuditReject(sourceKey); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ¨éæµè¯ |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [HttpGet, HttpPost, Route("PushTest"), AllowAnonymous] |
| | | public WebResponseContent PushTest() |
| | | { |
| | | try |
| | | { |
| | | List<Dt_CheckOrder> checkOrders = _checkOrderRepository.Db.Queryable<Dt_CheckOrder>().Includes(x => x.Details).ToList(); |
| | | |
| | | foreach (var checkOrder in checkOrders) |
| | | { |
| | | object obj = new |
| | | { |
| | | title = "IQCè´¨æ£ç»æå®¡æ¹", |
| | | formData = checkOrder, |
| | | tableData = checkOrder.Details, |
| | | message = "æ¨éæµè¯ä¿¡æ¯ä½", |
| | | date = DateTime.Now.ToString(), |
| | | }; |
| | | JsonSerializerSettings settings = new JsonSerializerSettings() |
| | | { |
| | | ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver() |
| | | }; |
| | | _webSocketServer.PublishAllClientPayload(JsonConvert.SerializeObject(obj, settings)); |
| | | } |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | using WIDESEA_External.Model; |
| | | using WIDESEA_IBasicRepository; |
| | | using WIDESEA_IBasicService; |
| | | using WIDESEA_IInboundRepository; |
| | | using WIDESEA_IInboundService; |
| | | using WIDESEA_InboundService; |
| | | using WIDESEA_IOutboundService; |
| | | using WIDESEA_Model.Models; |
| | | using static WIDESEA_DTO.ErpResponseContent; |
| | | |
| | |
| | | public class ErpController : ControllerBase |
| | | { |
| | | private readonly IBasicService _basicService; |
| | | private readonly IOutboundService _outboundService; |
| | | private readonly IInboundService _inboundService; |
| | | private readonly IInvokeERPService _invokeERPService; |
| | | private readonly IReturnOrderService _returnOrderService; |
| | | |
| | | public ErpController(IBasicService basicService, IOutboundService outboundService, IInboundService inboundService, |
| | | IInvokeERPService invokeERPService, IReturnOrderService returnOrderService) |
| | | public ErpController(IBasicService basicService,IInvokeERPService invokeERPService) |
| | | { |
| | | _basicService = basicService; |
| | | _outboundService = outboundService; |
| | | _inboundService = inboundService; |
| | | _invokeERPService = invokeERPService; |
| | | _returnOrderService = returnOrderService; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ¥æ¶ERPéè´åä¿¡æ¯ |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, Route("ReceivePurchaseOrder"), AllowAnonymous, MethodParamsValidate] |
| | | public ErpResponseContent ReceivePurchaseOrder([FromBody] Root<PurchaseOrderModel> model) |
| | | { |
| | | WebResponseContent content = _inboundService.PurchaseOrderService.ReceivePurchaseOrder(model.Content); |
| | | if (content.Status) return Instance.OK(); |
| | | else return Instance.Error(content.Message); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ¥æ¶ERPä»åºåå·¥åè´¨æ£åå·¥æ°æ® |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, Route("ReceiveUser"), AllowAnonymous, MethodParamsValidate] |
| | | public ErpResponseContent ReceiveUser([FromBody] Root<UserInfoDTO> model) |
| | | { |
| | | WebResponseContent content = _basicService.UserInfoService.ReceiveUser(model.Content); |
| | | if (content.Status) return Instance.OK(); |
| | | else return Instance.Error(content.Message); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ¥æ¶ERPä¾åºåä¿¡æ¯ |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, Route("ReceiveSupplier"), AllowAnonymous, MethodParamsValidate] |
| | | public ErpResponseContent ReceiveSupplier([FromBody] Root<SupplierDTO> model) |
| | | { |
| | | WebResponseContent content = _basicService.SupplierInfoService.ReceiveSupplier(model.Content); |
| | | if (content.Status) return Instance.OK(); |
| | | else return Instance.Error(content.Message); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | public ErpResponseContent ReceiveMaterial([FromBody] Root<MaterielInfoDTO> model) |
| | | { |
| | | WebResponseContent content = _basicService.MaterielInfoService.ReceiveMaterial(model.Content); |
| | | if (content.Status) return Instance.OK(); |
| | | else return Instance.Error(content.Message); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ¥æ¶ERP客æ·ä¿¡æ¯ |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, Route("ReceiveCustomer"), AllowAnonymous, MethodParamsValidate] |
| | | public ErpResponseContent ReceiveCustomer([FromBody] Root<CustomerInfoDTO> model) |
| | | { |
| | | WebResponseContent content = _basicService.CustomerInfoService.ReceiveCustomer(model.Content); |
| | | if (content.Status) return Instance.OK(); |
| | | else return Instance.Error(content.Message); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ¥æ¶ERPåºåºåä¿¡æ¯ |
| | | /// </summary> |
| | | /// <param name="erpOutOrder"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, Route("ReceiveOutOrder"), AllowAnonymous, MethodParamsValidate] |
| | | public ErpResponseContent ReceiveOutOrder([FromBody] Root<ErpOutOrderDTO> erpOutOrder) |
| | | { |
| | | WebResponseContent content = _outboundService.OutboundOrderService.ReceiveOutOrder(erpOutOrder.Content); |
| | | if (content.Status) return Instance.OK(); |
| | | else return Instance.Error(content.Message); |
| | | } |
| | | /// <summary> |
| | | /// æ¥æ¶ERPæååºåºåä¿¡æ¯(订ååºåº/å¯å®åºåº) |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [HttpPost, Route("ProductDeliveryOrder"), AllowAnonymous, MethodParamsValidate] |
| | | public async Task<ErpResponseContent> ProductDeliveryOrder([FromBody] Root<ErpProOutOrderDTO> erpProOutOrder) |
| | | { |
| | | var content = await _outboundService.ProOutOrderService.ProductDeliveryOrder(erpProOutOrder.Content); |
| | | if (content.Status) return Instance.OK(); |
| | | else return Instance.Error(content.Message); |
| | | } |
| | | /// <summary> |
| | | /// æåå¯å®è½¬å
¥/è°æ¨å
¥åº |
| | | /// </summary> |
| | | /// <param name="root"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, Route("ProductWarehousingOrder"), AllowAnonymous, MethodParamsValidate] |
| | | public ErpResponseContent ProductWarehousingOrder([FromBody] Root<ErpProductWarehousingOrderDTO> root) |
| | | { |
| | | WebResponseContent content = _inboundService.ErpProInOrderService.ProductWarehousingOrder(root.Content); |
| | | if (content.Status) return Instance.OK(); |
| | | else return Instance.Error(content.Message); |
| | | } |
| | | /// <summary> |
| | | /// æåè°æ¨åºï¼ç åï¼ |
| | | /// </summary> |
| | | /// <param name="root"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, Route("ProductTransferOrder"), AllowAnonymous, MethodParamsValidate] |
| | | public ErpResponseContent ProductTransferOrder([FromBody] Root<ErpProductTransferOrderDTO> root) |
| | | { |
| | | WebResponseContent content = _outboundService.ErpProTransferOrderService.ProductTransferOrder(root.Content); |
| | | if (content.Status) return Instance.OK(); |
| | | else return Instance.Error(content.Message); |
| | | } |
| | | /// <summary> |
| | | /// æåæ¥åºåºåºåæ¥æ¶ |
| | | /// </summary> |
| | | /// <param name="root"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, Route("ProductScrappedOrder"), AllowAnonymous, MethodParamsValidate] |
| | | public ErpResponseContent ProductScrappedOrder([FromBody] Root<ErpProductScrappedOrderDTO> root) |
| | | { |
| | | return Instance.OK(); |
| | | } |
| | | /// <summary> |
| | | /// æå颿åºåºåæ¥æ¶ |
| | | /// </summary> |
| | | /// <param name="root"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, Route("ProductOutOrder"), AllowAnonymous, MethodParamsValidate] |
| | | public ErpResponseContent ProductOutOrder([FromBody] Root<ErpProOutLingOrder> root) |
| | | { |
| | | return Instance.OK(); |
| | | } |
| | | /// <summary> |
| | | /// éå®ææ´¾åæ¥æ¶ |
| | | /// </summary> |
| | | [HttpPost, Route("ProductSpecifyVer"), AllowAnonymous, MethodParamsValidate] |
| | | public async Task<ErpResponseContent> ProductSpecifyVerAsync([FromBody] Root<ErpProductSpecifyVerDTO> root) |
| | | { |
| | | var content = await _outboundService.ProOutOrderService.ProductSpecifyVer(root.Content); |
| | | if (content.Status) return Instance.OK(); |
| | | else return Instance.Error(content.Message); |
| | | } |
| | | /// <summary> |
| | | /// æ¥æ¶ERPéæåä¿¡æ¯ |
| | | /// </summary> |
| | | [HttpPost, Route("ReturnOrder"), AllowAnonymous, MethodParamsValidate] |
| | | public ErpResponseContent ReturnOrder([FromBody] Root<ErpReturnOrderDTO> model) |
| | | { |
| | | WebResponseContent content = _returnOrderService.ReturnOrder(model.Content); |
| | | if (content.Status) return Instance.OK(); |
| | | else return Instance.Error(content.Message); |
| | | } |
| | | /// <summary> |
| | | /// å
¶ä»å
¥åºåæ¥æ¶(è°æå
¥ä»,客ä¾åæ¶,ç©æéå®éè´§) |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [HttpPost, Route("ReceiveWarehousingOrder"), AllowAnonymous, MethodParamsValidate] |
| | | public ErpResponseContent ReceiveWarehousingOrder([FromBody] Root<ErpInOrderDTO> model) |
| | | { |
| | | WebResponseContent content = _inboundService.InbounOrderService.ReceiveWarehousingOrder(model.Content); |
| | | if (content.Status) return Instance.OK(); |
| | | else return Instance.Error(content.Message); |
| | | } |
| | |
| | | using WIDESEA_Core; |
| | | using WIDESEA_DTO; |
| | | using WIDESEA_IBasicService; |
| | | using WIDESEA_IInboundRepository; |
| | | using WIDESEA_IInboundService; |
| | | using WIDESEA_IOutboundService; |
| | | using WIDESEA_ITaskInfoService; |
| | | using WIDESEA_TaskInfoService; |
| | | using WIDESEA_DTO.ERP; |
| | |
| | | [ApiController] |
| | | public class LargeController : ControllerBase |
| | | { |
| | | private readonly IOutboundService _outboundService; |
| | | private readonly ITaskService _taskService; |
| | | private readonly ITask_HtyService _task_HtyService; |
| | | private readonly IBasicService _basicService; |
| | | private readonly IMesProInOrderService _mesProInOrderService; |
| | | private readonly IOutProStockInfoService _outProStockInfoService; |
| | | private readonly WebSocketServer _webSocketServer; |
| | | private readonly IProStockInfoDetailService _proStockInfoDetailService; |
| | | private readonly IProStockInfoService _proStockInfoService; |
| | | |
| | | public LargeController(IOutboundService outboundService, ITaskService taskService, ITask_HtyService task_HtyService, IBasicService basicService, IMesProInOrderService mesProInOrderService, IOutProStockInfoService outProStockInfoService, IProStockInfoDetailService proStockInfoDetailService, IProStockInfoService proStockInfoService, WebSocketServer webSocketServer) |
| | | public LargeController( ITaskService taskService, ITask_HtyService task_HtyService, IBasicService basicService, IProStockInfoDetailService proStockInfoDetailService, IProStockInfoService proStockInfoService, WebSocketServer webSocketServer) |
| | | { |
| | | _outboundService = outboundService; |
| | | _taskService = taskService; |
| | | _task_HtyService = task_HtyService; |
| | | _basicService = basicService; |
| | | _mesProInOrderService = mesProInOrderService; |
| | | _outProStockInfoService = outProStockInfoService; |
| | | _proStockInfoDetailService = proStockInfoDetailService; |
| | | _proStockInfoService = proStockInfoService; |
| | | _webSocketServer = webSocketServer; |
| | |
| | | } |
| | | return WebResponseContent.Instance.OK(_webSocketServer.OnlineSessions.Select(x=>x.Url).Serialize()); |
| | | } |
| | | ///// <summary> |
| | | ///// æå彿任å¡ç»è®¡ |
| | | ///// </summary> |
| | | ///// <param name="model"></param> |
| | | ///// <returns></returns> |
| | | //[HttpPost, Route("ProMonthTaskStatistics"), AllowAnonymous] |
| | | //public WebResponseContent ProMonthTaskStatistics() |
| | | //{ |
| | | // WebResponseContent content = new WebResponseContent(); |
| | | // try |
| | | // { |
| | | // //è·å彿æåç任塿»é |
| | | // int inboundCount = _taskService.Repository.QueryData(x => x.TaskType == TaskTypeEnum.InProduct.ObjToInt()).Count; |
| | | // int outboundCount = _taskService.Repository.QueryData(x => x.TaskType == TaskTypeEnum.OutProduct.ObjToInt()).Count; |
| | | // int backboundCount = _taskService.Repository.QueryData(x => x.TaskType == TaskTypeEnum.EmptyProductBack.ObjToInt()).Count; |
| | | // int surplusCount = _taskService.Repository.QueryData(x => x.TaskType == TaskTypeEnum.InProductBack.ObjToInt()).Count; |
| | | // content.OK("æå", new { inboundCount, outboundCount, backboundCount, surplusCount }); |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // content.Error(ex.Message); |
| | | // } |
| | | // return content; |
| | | //} |
| | | ///// <summary> |
| | | ///// æåè´§ä½ |
| | | ///// </summary> |
| | | ///// <param name="model"></param> |
| | | ///// <returns></returns> |
| | | //[HttpPost, Route("ProLocationStatistics"), AllowAnonymous] |
| | | //public WebResponseContent ProLocationStatistics(int Id) |
| | | //{ |
| | | // WebResponseContent content = new WebResponseContent(); |
| | | // try |
| | | // { |
| | | // //è·åæåçè´§ä½ |
| | | // int freeCount = _basicService.LocationInfoService.Repository.QueryData(x => x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && x.WarehouseId == Id).Count; |
| | | // int inStockCount = _basicService.LocationInfoService.Repository.QueryData(x => x.LocationStatus == LocationStatusEnum.InStock.ObjToInt() && x.WarehouseId == Id).Count; |
| | | // int lockCount = _basicService.LocationInfoService.Repository.QueryData(x => x.LocationStatus != LocationStatusEnum.Free.ObjToInt() && x.LocationStatus != LocationStatusEnum.InStock.ObjToInt() && x.WarehouseId == Id).Count; |
| | | // content.OK("æå", new { freeCount, inStockCount, lockCount }); |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // content.Error(ex.Message); |
| | | // } |
| | | // return content; |
| | | //} |
| | | ///// <summary> |
| | | ///// æåå
¥åºäº§é |
| | | ///// </summary> |
| | | ///// <param name="model"></param> |
| | | ///// <returns></returns> |
| | | //[HttpPost, Route("Productions"), AllowAnonymous] |
| | | //public WebResponseContent Productions() |
| | | //{ |
| | | // WebResponseContent content = new WebResponseContent(); |
| | | // try |
| | | // { |
| | | // List<Object> list = new List<Object>(); |
| | | // DateTime dateTody = DateTime.Today.AddDays(+1); |
| | | // for (int i = 1; i <= 7; i++) |
| | | // { |
| | | // DateTime date = dateTody.AddDays(-1); |
| | | // List<Dt_MesProInOrder> mesIn = _mesProInOrderService.Repository.Db.Queryable<Dt_MesProInOrder>().Where(x => x.CreateDate < dateTody && x.CreateDate >= date).Includes(x => x.Details).ToList(); |
| | | // int PcsCounts = 0; |
| | | // foreach (var item in mesIn) |
| | | // { |
| | | // PcsCounts+=(int)item.Details.Sum(x=>x.OKPCSQTY); |
| | | // } |
| | | // dateTody = date; |
| | | // list.Add(new { today = date.ToString("MM/dd"), pcsCounts = PcsCounts }); |
| | | // } |
| | | // content.OK("æå", list); |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // content.Error(ex.Message); |
| | | // } |
| | | // return content; |
| | | //} |
| | | ///// <summary> |
| | | ///// æååºåºäº§é |
| | | ///// </summary> |
| | | ///// <param name="model"></param> |
| | | ///// <returns></returns> |
| | | //[HttpPost, Route("ProductionsOut"), AllowAnonymous] |
| | | //public WebResponseContent ProductionsOut() |
| | | //{ |
| | | // WebResponseContent content = new WebResponseContent(); |
| | | // try |
| | | // { |
| | | // List<Object> list = new List<Object>(); |
| | | // DateTime dateTody = DateTime.Today.AddDays(+1); |
| | | // for (int i = 1; i <= 7; i++) |
| | | // { |
| | | // DateTime date = dateTody.AddDays(-1); |
| | | // List<Dt_ProOutOrder> mesIn = _outboundService.ProOutOrderService.Repository.Db.Queryable<Dt_ProOutOrder>().Where(x => x.CreateDate < dateTody && x.CreateDate >= date).Includes(x => x.Details).ToList(); |
| | | // int PcsCounts = 0; |
| | | // foreach (var item in mesIn) |
| | | // { |
| | | // PcsCounts += (int)item.Details.Sum(x => x.QtyPcs); |
| | | // } |
| | | // dateTody = date; |
| | | // list.Add(new { today = date.ToString("MM/dd"), pcsCounts = PcsCounts }); |
| | | // } |
| | | // content.OK("æå", list); |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // content.Error(ex.Message); |
| | | // } |
| | | // return content; |
| | | //} |
| | | ///// <summary> |
| | | ///// æååºåºäº§é |
| | | ///// </summary> |
| | | ///// <param name="model"></param> |
| | | ///// <returns></returns> |
| | | //[HttpPost, Route("ProductionRanking"), AllowAnonymous] |
| | | //public WebResponseContent ProductionRanking() |
| | | //{ |
| | | // WebResponseContent content = new WebResponseContent(); |
| | | // try |
| | | // { |
| | | // var list = _proStockInfoDetailService.Repository.QueryData(x => true).GroupBy(x => x.ProductCode).Select(x => new { pCode = x.Key, qtys = x.Sum(x=>x.StockPcsQty) }).OrderByDescending(x=>x.qtys).Take(5); |
| | | |
| | | // content.OK("æå", list); |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // content.Error(ex.Message); |
| | | // } |
| | | // return content; |
| | | //} |
| | | ///// <summary> |
| | | ///// æååºå |
| | | ///// </summary> |
| | | ///// <param name="model"></param> |
| | | ///// <returns></returns> |
| | | //[HttpPost, Route("ProductionStock"), AllowAnonymous] |
| | | //public WebResponseContent ProductionStock() |
| | | //{ |
| | | // WebResponseContent content = new WebResponseContent(); |
| | | // try |
| | | // { |
| | | // int cpCount = 0; |
| | | // int yfCount = 0; |
| | | // int wsCount = 0; |
| | | // List<Dt_ProStockInfo> cpproStockInfos = _proStockInfoService.Repository.Db.Queryable<Dt_ProStockInfo>().Where(x => x.ProStockAttribute == ProStockAttributeEnum.æå.ObjToInt()).Includes(x => x.proStockInfoDetails).ToList(); |
| | | // List<Dt_ProStockInfo> yfproStockInfos = _proStockInfoService.Repository.Db.Queryable<Dt_ProStockInfo>().Where(x => x.ProStockAttribute == ProStockAttributeEnum.ç å.ObjToInt()).Includes(x => x.proStockInfoDetails).ToList(); |
| | | // List<Dt_ProStockInfo> wsproStockInfos = _proStockInfoService.Repository.Db.Queryable<Dt_ProStockInfo>().Where(x => x.ProStockAttribute == ProStockAttributeEnum.å°¾æ°.ObjToInt()).Includes(x => x.proStockInfoDetails).ToList(); |
| | | // foreach (var item in cpproStockInfos) |
| | | // { |
| | | // cpCount +=(int) item.proStockInfoDetails.Sum(x => x.StockPcsQty); |
| | | // } |
| | | // foreach (var item in yfproStockInfos) |
| | | // { |
| | | // yfCount += (int)item.proStockInfoDetails.Sum(x => x.StockPcsQty); |
| | | // } |
| | | // foreach (var item in wsproStockInfos) |
| | | // { |
| | | // wsCount += (int)item.proStockInfoDetails.Sum(x => x.StockPcsQty); |
| | | // } |
| | | // content.OK("æå", new { cpCount, yfCount, wsCount }); |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // content.Error(ex.Message); |
| | | // } |
| | | // return content; |
| | | //} |
| | | } |
| | | } |
| | |
| | | using WIDESEA_Core; |
| | | using WIDESEA_DTO; |
| | | using WIDESEA_IBasicService; |
| | | using WIDESEA_IInboundRepository; |
| | | using WIDESEA_IInboundService; |
| | | using WIDESEA_IOutboundService; |
| | | using WIDESEA_ITaskInfoService; |
| | | using WIDESEA_TaskInfoService; |
| | | using WIDESEA_DTO.ERP; |
| | |
| | | [ApiController] |
| | | public class MesController : ControllerBase |
| | | { |
| | | private readonly IOutboundService _outboundService; |
| | | private readonly ITaskService _taskService; |
| | | |
| | | public MesController(IOutboundService outboundService, ITaskService taskService) |
| | | public MesController(ITaskService taskService) |
| | | { |
| | | _outboundService = outboundService; |
| | | _taskService = taskService; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// åºæ¿åºåº |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, Route("SubstrateOut"), AllowAnonymous] |
| | | public MesResponseContent SubstrateOut([FromBody] Root<SubstrateOutModel> model) |
| | | { |
| | | return _taskService.SubstrateOut(model.Content); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// åºæ¿ä½æéåº |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | |
| | | { |
| | | return _taskService.UploadMesMaterialLotaAcept(model); |
| | | } |
| | | /// <summary> |
| | | /// MESæåå
å
ä¿¡æ¯æ¥æ¶ |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, Route("BagInfoSync"), AllowAnonymous] |
| | | public MesResponseContent BagInfoSync([FromBody] Root<MesBagInfoModel> model) |
| | | { |
| | | return _taskService.BagInfoSync(model.Content); |
| | | } |
| | | /// <summary> |
| | | /// MESæåå¤å
ä¿¡æ¯æ¥æ¶ |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, Route("BoxStockin"), AllowAnonymous] |
| | | public MesResponseContent BoxStockin([FromBody] Root<MesBoxInfoModel> model) |
| | | { |
| | | return _taskService.BoxStockin(model.Content); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// MESæååºåºæ¥å£è°ç¨ |
| | | /// </summary> |
| | |
| | | public WebResponseContent ShipmentOrderSync([FromBody] MesShipmentOrderSync model) |
| | | { |
| | | return _taskService.ShipmentOrderSync(model); |
| | | } |
| | | /// <summary> |
| | | /// æåè¿å·¥æåº |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | [HttpPost,Route("RworkTask"),AllowAnonymous] |
| | | public MesResponseContent RworkTask([FromBody] Root<RworkTaskModel> model) |
| | | { |
| | | return _taskService.RworkTask(model.Content); |
| | | } |
| | | /// <summary> |
| | | /// åºåæ¿åºåºåæ¥æ¥å£ |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, Route("ProductOutBoundSync"), AllowAnonymous] |
| | | public WebResponseContent ProductOutBoundSync([FromBody] MesProductOutBound model) |
| | | { |
| | | return _outboundService.RworkOutboundOrderService.ProductOutBoundSync(model); |
| | | } |
| | | } |
| | | } |
| | |
| | | using WIDESEA_Core.BaseController; |
| | | using WIDESEA_Core.Helper; |
| | | using WIDESEA_DTO.Inbound; |
| | | using WIDESEA_IInboundService; |
| | | using WIDESEA_IOutboundService; |
| | | using WIDESEA_ITaskInfoService; |
| | | using System.IO; |
| | | using WIDESEA_Model.Models; |
| | |
| | | [Authorize, ApiController] |
| | | public class PDAController : Controller |
| | | { |
| | | private readonly IInboundService _inboundService; |
| | | private readonly IOutboundService _outboundService; |
| | | private readonly ITaskService _taskService; |
| | | |
| | | public PDAController(ITaskService taskService, IInboundService inboundService, IOutboundService outboundService) |
| | | public PDAController(ITaskService taskService) |
| | | { |
| | | _inboundService = inboundService; |
| | | _outboundService = outboundService; |
| | | _taskService = taskService; |
| | | } |
| | | |
| | |
| | | ); |
| | | return Json(result); |
| | | } |
| | | /// <summary> |
| | | /// è·åå¹³åºåºå |
| | | /// </summary> |
| | | [HttpPost, Route("GetProPKSelectStocks"),AllowAnonymous] |
| | | public List<ProStockViewDTO> GetProPKSelectStocks(int orderId) |
| | | { |
| | | return _stockViewService.GetProPKSelectStocks(orderId); |
| | | } |
| | | private object InvokeService(string methodName, object[] parameters) |
| | | { |
| | | Type t = _stockViewService.GetType(); |
| | |
| | | public StockInfoController(IStockInfoService service) : base(service) |
| | | { |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ¥è¯¢è®¢åç«åºåºåè§å¾ |
| | | /// </summary> |
| | | /// <param name="orderId"></param> |
| | | /// <param name="materielCode"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, HttpGet, Route("GetStockSelectViews")] |
| | | public List<StockSelectViewDTO> GetStockSelectViews(int orderId, string materielCode) |
| | | { |
| | | return Service.GetStockSelectViews(orderId, materielCode); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ¥è¯¢è®¢åå¹³åºåºåè§å¾ |
| | | /// </summary> |
| | | /// <param name="orderId"></param> |
| | | /// <param name="materielCode"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, HttpGet, Route("GetPKStockSelectViews")] |
| | | public List<StockSelectViewDTO> GetPKStockSelectViews(int orderId, string materielCode) |
| | | { |
| | | return Service.GetPKStockSelectViews(orderId, materielCode); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ ¹æ®æçååºåºæ¥è¯¢åºåä¿¡æ¯ |
| | | /// </summary> |
| | |
| | | public TaskController(ITaskService service) : base(service) |
| | | { |
| | | } |
| | | |
| | | ///// <summary> |
| | | ///// å°WMS任塿¨éè³WCS |
| | | ///// </summary> |
| | | ///// <returns></returns> |
| | | //[HttpPost, HttpGet, Route("PushTasksToWCS"), AllowAnonymous] |
| | | //public WebResponseContent PushTasksToWCS() |
| | | //{ |
| | | // return Service.PushTasksToWCS(); |
| | | //} |
| | | |
| | | /// <summary> |
| | | /// ç³è¯·å
¥åºä»»å¡ |
| | | /// </summary> |
| | | /// <param name="saveModel"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, HttpGet, Route("RequestInboundTask"), AllowAnonymous] |
| | | public WebResponseContent RequestInboundTask([FromBody] SaveModel saveModel) |
| | | { |
| | | return Service.RequestInboundTask(saveModel); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 空箱å
¥åº |
| | | /// </summary> |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// WCSç³è¯·å
¥åºä»»å¡(åé
è´§ä½) |
| | | /// </summary> |
| | | /// <param name="stationCode"></param> |
| | | /// <param name="roadwayNo"></param> |
| | | /// <param name="palletCode"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, HttpGet, Route("DeviceRequestInboundTask"), AllowAnonymous] |
| | | public WebResponseContent DeviceRequestInboundTask(string stationCode, string roadwayNo, string palletCode,string materielBoxCode = "") |
| | | { |
| | | return Service.DeviceRequestInboundTask(stationCode, roadwayNo, palletCode, materielBoxCode); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// WCSç³è¯·å
¥åºä»»å¡(ä¸åé
è´§ä½) |
| | | /// </summary> |
| | | /// <param name="stationCode"></param> |
| | |
| | | public WebResponseContent DeviceRequestInboundTaskSimple(string stationCode, string palletCode) |
| | | { |
| | | return Service.DeviceRequestInboundTaskSimple(stationCode, palletCode); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="stationCode"></param> |
| | | /// <param name="palletCode"></param> |
| | | /// <param name="roadwayNos"></param> |
| | | /// <param name="heightType"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, HttpGet, Route("DeviceRequestInboundTaskByRoadways"), AllowAnonymous] |
| | | public WebResponseContent DeviceRequestInboundTaskByRoadways(string stationCode, string palletCode, int heightType, [FromBody] List<string> roadwayNos) |
| | | { |
| | | return Service.DeviceRequestInboundTaskByRoadways(stationCode, palletCode, roadwayNos, heightType); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | return Service.AssignInboundTaskLocationByHeight(taskNum, roadwayNo, heightType); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å
¥åºä»»å¡å®æ |
| | | /// </summary> |
| | | /// <param name="taskNum"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, HttpGet, Route("InboundTaskCompleted"), AllowAnonymous] |
| | | public WebResponseContent InboundTaskCompleted(int taskNum) |
| | | { |
| | | return Service.InboundTaskCompleted(taskNum); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// çæåºåºä»»å¡ |
| | | /// </summary> |
| | | /// <param name="orderDetailId"></param> |
| | | /// <param name="stockSelectViews"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, HttpGet, Route("GenerateOutboundTask"), AllowAnonymous] |
| | | public WebResponseContent GenerateOutboundTask(int orderDetailId, [FromBody] List<StockSelectViewDTO> stockSelectViews) |
| | | { |
| | | return Service.GenerateOutboundTask(orderDetailId, stockSelectViews); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å¹³åºç´æ¥åºåº |
| | | /// </summary> |
| | | /// <param name="orderDetailId"></param> |
| | | /// <param name="stockSelectViews"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, HttpGet, Route("GeneratePKOutboundTask"), AllowAnonymous] |
| | | public WebResponseContent GeneratePKOutboundTask(int orderDetailId, [FromBody] List<StockSelectViewDTO> stockSelectViews) |
| | | { |
| | | return Service.GeneratePKOutboundTask(orderDetailId, stockSelectViews); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// çæåºåºä»»å¡ |
| | | /// </summary> |
| | | /// <param name="keys"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, HttpGet, Route("GenerateOutboundTasks"), AllowAnonymous] |
| | | public WebResponseContent GenerateOutboundTasks([FromBody] int[] keys) |
| | | { |
| | | return Service.GenerateOutboundTasks(keys); |
| | | } |
| | | /// <summary> |
| | | /// çææååºåºä»»å¡ |
| | | /// </summary> |
| | | /// <param name="ProOutNo">åºåºè®¢åå·</param> |
| | | /// <param name="StationCode">ç«å°å°å</param> |
| | | /// <returns></returns> |
| | | [HttpPost, HttpGet, Route("OutProductTask"), AllowAnonymous] |
| | | public async Task<WebResponseContent> OutProductTask([FromBody] int[] keys, string StationCode, int Grade) |
| | | { |
| | | return await Service.OutProductTask(keys, StationCode, Grade); |
| | | } |
| | | /// <summary> |
| | | /// æå使éåºå
¥ä» |
| | | /// </summary> |
| | |
| | | public WebResponseContent EmptyBackTask(string barCode, string startPoint) |
| | | { |
| | | return Service.EmptyBackTask(barCode, startPoint); |
| | | } |
| | | /// <summary> |
| | | /// çææåæåºä»»å¡ |
| | | /// </summary> |
| | | [HttpPost, HttpGet, Route("OutProRworkTask"), AllowAnonymous] |
| | | public async Task<WebResponseContent> OutProRworkTask([FromBody] int[] keys, string StationCode, int Grade) |
| | | { |
| | | return await Service.OutProductTask(keys, StationCode, Grade); |
| | | } |
| | | ///// <summary> |
| | | ///// çæMESPPä»å¤§å·åºåºä»»å¡ |
| | | ///// </summary> |
| | | ///// <param name="keys"></param> |
| | | ///// <returns></returns> |
| | | //[HttpPost, HttpGet, Route("MESPPGenerateOutboundTasks"), AllowAnonymous] |
| | | //public WebResponseContent MESPPGenerateOutboundTasks([FromBody] int[] keys) |
| | | //{ |
| | | // return Service.MESPPGenerateOutboundTasks(keys); |
| | | //} |
| | | /// <summary> |
| | | /// åºåºä»»å¡å®æ |
| | | /// </summary> |
| | | /// <param name="taskNum">ä»»å¡å·</param> |
| | | /// <returns></returns> |
| | | [HttpPost, HttpGet, Route("OutboundTaskCompleted"), AllowAnonymous] |
| | | public WebResponseContent OutboundTaskCompleted(int taskNum) |
| | | { |
| | | return Service.OutboundTaskCompleted(taskNum); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="roadwayNos"></param> |
| | | /// <param name="palletCode"></param> |
| | | /// <param name="heightType"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, Route("AssignRoadwayByHeightAndCode"), AllowAnonymous] |
| | | public WebResponseContent AssignRoadwayByHeightAndCode([FromBody] List<string> roadwayNos, string palletCode, int heightType = 0) |
| | | { |
| | | return Service.AssignRoadwayByHeightAndCode(roadwayNos, palletCode, heightType); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// åé
å··é(带任å¡å·) |
| | | /// </summary> |
| | | /// <param name="taskNum"></param> |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="orderId"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, Route("HandSubstrateOut")] |
| | | public WebResponseContent HandSubstrateOut(int orderId) |
| | | { |
| | | return Service.HandSubstrateOut(orderId); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// ä¿®æ¹ä»»å¡ç¶æ |
| | | /// </summary> |
| | | /// <param name="task"></param> |
| | |
| | | public WebResponseContent AGVTasks([FromBody] SaveModel saveModel) |
| | | { |
| | | return Service.AGVTasks(saveModel); |
| | | } |
| | | /// <summary> |
| | | /// æåæå®åºåº |
| | | /// </summary> |
| | | /// <param name="task"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, Route("OutProductSelect"), AllowAnonymous] |
| | | public WebResponseContent OutProductSelect(int orderDetailId,[FromBody] List<ProStockViewDTO> proStockViews) |
| | | { |
| | | return Service.OutProductSelect(orderDetailId, proStockViews); |
| | | } |
| | | } |
| | | } |
| | |
| | | public CustomProfile() |
| | | { |
| | | CreateMap<Sys_Menu, MenuDTO>(); |
| | | CreateMap<InboundOrderDetailAddDTO, Dt_InboundOrderDetail>().ForMember(x => x.OrderDetailStatus, b => b.MapFrom(b => 0)); |
| | | CreateMap<InboundOrderAddDTO, Dt_InboundOrder>(); |
| | | |
| | | CreateMap<Dt_StockInfoDetail, Dt_StockQuantityChangeRecord>().ForMember(x => x.SerilNumber, b => b.MapFrom(b => b.SerialNumber)).ForMember(x => x.StockDetailId, b => b.MapFrom(b => b.Id)); |
| | | CreateMap<OutboundOrderDetailAddDTO, Dt_OutboundOrderDetail>().ForMember(x => x.OrderDetailStatus, b => b.MapFrom(b => 0)); |
| | | CreateMap<OutboundOrderAddDTO, Dt_OutboundOrder>(); |
| | | CreateMap<Dt_ReceiveOrderDetail, Dt_CheckOrder>().ForMember(a => a.ReceivedQuantity, b => b.MapFrom(x => x.ReceivedQuantity)).ForMember(a => a.MaterielCode, b => b.MapFrom(x => x.MaterielCode)).ForMember(a => a.CheckOrderStatus, b => b.MapFrom(x => CheckOrderStatusEnum.NotCheck.ObjToInt())); |
| | | |
| | | CreateMap<Dt_Task, WMSTaskDTO>(); |
| | | CreateMap<MESBagDetail, Dt_MesProInOrderDetail>().ForMember(x => x.OverInQuantity, b => b.MapFrom(b => 0)); |
| | | CreateMap<ErpProOutOrderDetailds, Dt_ProOutOrderDetail>().ForMember(x => x.ProOrderDetailStatus, b => b.MapFrom(b => 0)).ForMember(x => x.OverQtyPcs, b => b.MapFrom(b => 0)); |
| | | CreateMap<Dt_MesProInOrderDetail, Dt_ProStockInfoDetail>().ForMember(x => x.ProOutDetailStatus, b => b.MapFrom(b => StockStatusEmun.ç»çæå.ObjToInt())).ForMember(x => x.OutboundQuantity, b => b.MapFrom(b => 0)).ForMember(x => x.StockPcsQty, b => b.MapFrom(b => b.OKPCSQTY)); |
| | | CreateMap<ErpProductWarehousingOrderDTO, Dt_ErpProInOrder>().ForMember(x => x.ProSaleOrderNo, b => b.MapFrom(b => b.SaleOrder)).ForMember(x => x.Remark, b => b.MapFrom(b => b.Note)).ForMember(x => x.UpperOrderNo, b => b.MapFrom(b => b.TransferNo)).ForMember(x => x.ProStockAttribute, b => b.MapFrom(b => ProStockAttributeEnum.æå.ObjToInt())).ForMember(x => x.ProInStatus, b => b.MapFrom(b => InOrderStatusEnum.æªå¼å§.ObjToInt())); |
| | | CreateMap<ErpProductTransferOrderDTO, Dt_ErpProTransferOrder>().ForMember(x => x.ProSaleOrderNo, b => b.MapFrom(b => b.SaleOrder)).ForMember(x => x.Remark, b => b.MapFrom(b => b.Note)).ForMember(x => x.UpperOrderNo, b => b.MapFrom(b => b.TransferNo)).ForMember(x => x.OrderType, b => b.MapFrom(b => ErpProOutTypeEnum.ProOutAllocat.ObjToInt())).ForMember(x => x.ProStockAttribute, b => b.MapFrom(b => ProStockAttributeEnum.ç å.ObjToInt())); |
| | | } |
| | | } |
| | | } |
| | |
| | | </ItemGroup> |
| | | |
| | | <ItemGroup> |
| | | <Folder Include="Controllers\Check\" /> |
| | | <Folder Include="Controllers\Inbound\" /> |
| | | <Folder Include="Controllers\Outbound\" /> |
| | | <Folder Include="Log\" /> |
| | | </ItemGroup> |
| | | </Project> |