| | |
| | | /// <param name="barCode"></param> |
| | | /// <param name="startPoint"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent BackProductTask(string barCode, string startPoint) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | string palletCode = @"^C\d{5}$"; // æ£åè¡¨è¾¾å¼ |
| | | bool isValid = Regex.IsMatch(barCode, palletCode); |
| | | if (!isValid) |
| | | { |
| | | return content.Error($"æ¡ç æ ¼å¼é误{barCode}"); |
| | | } |
| | | if (!OutStartPonits.Contains(startPoint)) |
| | | { |
| | | return content.Error($"èµ·ç¹é误{startPoint}"); |
| | | } |
| | | //夿å½åç¹ä½æ¯å¦éå¤ |
| | | Dt_Task taskOldPoint = BaseDal.QueryFirst(x=>x.SourceAddress==startPoint && (x.TaskStatus == TaskStatusEnum.New.ObjToInt()||x.TaskStatus==TaskStatusEnum.Line_Execute.ObjToInt()|| x.TaskStatus == TaskStatusEnum.Line_Executing.ObjToInt() || x.TaskStatus == TaskStatusEnum.AGV_Takeing.ObjToInt())); |
| | | if (taskOldPoint != null) |
| | | { |
| | | return content.Error($"ç«ç¹{startPoint}å·²åå¨ä»»å¡"); |
| | | } |
| | | Dt_Task taskOld = BaseDal.QueryFirst(x => x.PalletCode == barCode); |
| | | if (taskOld != null) |
| | | { |
| | | return content.Error($"è¶æ¡{barCode}ä»»å¡å·²åå¨"); |
| | | } |
| | | //è·åè¶æ¡ä½æ |
| | | Dt_ProStockInfo proStockInfo = _stockRepository.ProStockInfoRepository.Db.Queryable<Dt_ProStockInfo>().Where(x=>x.PalletCode== barCode).Includes(x=>x.proStockInfoDetails).First(); |
| | | if (proStockInfo==null) |
| | | { |
| | | return content.Error($"æªæ¾å°{barCode}è¶æ¡ä¿¡æ¯"); |
| | | } |
| | | if (proStockInfo.proStockInfoDetails==null || proStockInfo.proStockInfoDetails.Count<=0) |
| | | { |
| | | return content.Error($"{barCode}è¶æ¡ä¿¡æ¯ä¸ºç©º"); |
| | | } |
| | | if (proStockInfo.StockStatus!=StockStatusEmun.åºåºå®æ.ObjToInt()) |
| | | { |
| | | return content.Error($"{barCode}è¶æ¡ä¿¡æ¯ç¶æå¼å¸¸"); |
| | | } |
| | | //è·åæåå¹³åº |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA101.ToString()); |
| | | if (proStockInfo.WarehouseId != warehouse.WarehouseId && proStockInfo.LocationCode!= "æåå
è£
æ£è´§åº") |
| | | { |
| | | return content.Error($"{barCode}è¶æ¡ä¿¡æ¯ä¸å¨æ£è´§åº"); |
| | | } |
| | | //è·åå½åçåºå屿§ |
| | | Dt_Warehouse? warePoint = null; |
| | | switch (proStockInfo.ProStockAttribute) |
| | | { |
| | | case (int)ProStockAttributeEnum.æå: |
| | | warePoint = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA71.ToString()); |
| | | break; |
| | | case (int)ProStockAttributeEnum.å°¾æ°: |
| | | warePoint = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA72.ToString()); |
| | | break; |
| | | case (int)ProStockAttributeEnum.ç å: |
| | | warePoint = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA73.ToString()); |
| | | break; |
| | | default: |
| | | throw new Exception($"æªæ¾å°{barCode}è¶æ¡ä¿¡æ¯åºå屿§"); |
| | | } |
| | | 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}è´§ä½ä¿¡æ¯"); |
| | | } |
| | | proStockInfo.StockStatus = StockStatusEmun.æå使ååº.ObjToInt(); |
| | | proStockInfo.proStockInfoDetails.ForEach(x => |
| | | { |
| | | x.ProOutDetailStatus = StockStatusEmun.æå使ååº.ObjToInt(); |
| | | }); |
| | | Dt_Task newTask = new Dt_Task() |
| | | { |
| | | CurrentAddress = startPoint, |
| | | Grade = 0, |
| | | NextAddress = "", |
| | | PalletCode = proStockInfo.PalletCode, |
| | | Roadway = locationInfo.RoadwayNo, |
| | | SourceAddress = startPoint, |
| | | TargetAddress = "", |
| | | TaskType = TaskTypeEnum.InProductBack.ObjToInt(), |
| | | TaskStatus = TaskStatusEnum.New.ObjToInt(), |
| | | WarehouseId = warePoint.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; |
| | | _stockRepository.ProStockInfoRepository.UpdateData(proStockInfo); |
| | | _stockRepository.ProStockInfoDetailRepository.UpdateData(proStockInfo.proStockInfoDetails); |
| | | _unitOfWorkManage.CommitTran(); |
| | | //æ¨éä»»å¡ |
| | | PushTasksToWCS(new List<Dt_Task> { newTask }); |
| | | content.OK("åéæå"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | //public WebResponseContent BackProductTask(string barCode, string startPoint) |
| | | //{ |
| | | // WebResponseContent content = new WebResponseContent(); |
| | | // try |
| | | // { |
| | | // string palletCode = @"^C\d{5}$"; // æ£åè¡¨è¾¾å¼ |
| | | // bool isValid = Regex.IsMatch(barCode, palletCode); |
| | | // if (!isValid) |
| | | // { |
| | | // return content.Error($"æ¡ç æ ¼å¼é误{barCode}"); |
| | | // } |
| | | // if (!OutStartPonits.Contains(startPoint)) |
| | | // { |
| | | // return content.Error($"èµ·ç¹é误{startPoint}"); |
| | | // } |
| | | // //夿å½åç¹ä½æ¯å¦éå¤ |
| | | // Dt_Task taskOldPoint = BaseDal.QueryFirst(x=>x.SourceAddress==startPoint && (x.TaskStatus == TaskStatusEnum.New.ObjToInt()||x.TaskStatus==TaskStatusEnum.Line_Execute.ObjToInt()|| x.TaskStatus == TaskStatusEnum.Line_Executing.ObjToInt() || x.TaskStatus == TaskStatusEnum.AGV_Takeing.ObjToInt())); |
| | | // if (taskOldPoint != null) |
| | | // { |
| | | // return content.Error($"ç«ç¹{startPoint}å·²åå¨ä»»å¡"); |
| | | // } |
| | | // Dt_Task taskOld = BaseDal.QueryFirst(x => x.PalletCode == barCode); |
| | | // if (taskOld != null) |
| | | // { |
| | | // return content.Error($"è¶æ¡{barCode}ä»»å¡å·²åå¨"); |
| | | // } |
| | | // //è·åè¶æ¡ä½æ |
| | | // Dt_ProStockInfo proStockInfo = _stockRepository.ProStockInfoRepository.Db.Queryable<Dt_ProStockInfo>().Where(x=>x.PalletCode== barCode).Includes(x=>x.proStockInfoDetails).First(); |
| | | // if (proStockInfo==null) |
| | | // { |
| | | // return content.Error($"æªæ¾å°{barCode}è¶æ¡ä¿¡æ¯"); |
| | | // } |
| | | // if (proStockInfo.proStockInfoDetails==null || proStockInfo.proStockInfoDetails.Count<=0) |
| | | // { |
| | | // return content.Error($"{barCode}è¶æ¡ä¿¡æ¯ä¸ºç©º"); |
| | | // } |
| | | // if (proStockInfo.StockStatus!=StockStatusEmun.åºåºå®æ.ObjToInt()) |
| | | // { |
| | | // return content.Error($"{barCode}è¶æ¡ä¿¡æ¯ç¶æå¼å¸¸"); |
| | | // } |
| | | // //è·åæåå¹³åº |
| | | // Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA101.ToString()); |
| | | // if (proStockInfo.WarehouseId != warehouse.WarehouseId && proStockInfo.LocationCode!= "æåå
è£
æ£è´§åº") |
| | | // { |
| | | // return content.Error($"{barCode}è¶æ¡ä¿¡æ¯ä¸å¨æ£è´§åº"); |
| | | // } |
| | | // //è·åå½åçåºå屿§ |
| | | // Dt_Warehouse? warePoint = null; |
| | | // switch (proStockInfo.ProStockAttribute) |
| | | // { |
| | | // case (int)ProStockAttributeEnum.æå: |
| | | // warePoint = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA71.ToString()); |
| | | // break; |
| | | // case (int)ProStockAttributeEnum.å°¾æ°: |
| | | // warePoint = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA72.ToString()); |
| | | // break; |
| | | // case (int)ProStockAttributeEnum.ç å: |
| | | // warePoint = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA73.ToString()); |
| | | // break; |
| | | // default: |
| | | // throw new Exception($"æªæ¾å°{barCode}è¶æ¡ä¿¡æ¯åºå屿§"); |
| | | // } |
| | | // 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}è´§ä½ä¿¡æ¯"); |
| | | // } |
| | | // proStockInfo.StockStatus = StockStatusEmun.æå使ååº.ObjToInt(); |
| | | // proStockInfo.proStockInfoDetails.ForEach(x => |
| | | // { |
| | | // x.ProOutDetailStatus = StockStatusEmun.æå使ååº.ObjToInt(); |
| | | // }); |
| | | // Dt_Task newTask = new Dt_Task() |
| | | // { |
| | | // CurrentAddress = startPoint, |
| | | // Grade = 0, |
| | | // NextAddress = "", |
| | | // PalletCode = proStockInfo.PalletCode, |
| | | // Roadway = locationInfo.RoadwayNo, |
| | | // SourceAddress = startPoint, |
| | | // TargetAddress = "", |
| | | // TaskType = TaskTypeEnum.InProductBack.ObjToInt(), |
| | | // TaskStatus = TaskStatusEnum.New.ObjToInt(), |
| | | // WarehouseId = warePoint.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; |
| | | // _stockRepository.ProStockInfoRepository.UpdateData(proStockInfo); |
| | | // _stockRepository.ProStockInfoDetailRepository.UpdateData(proStockInfo.proStockInfoDetails); |
| | | // _unitOfWorkManage.CommitTran(); |
| | | // //æ¨éä»»å¡ |
| | | // PushTasksToWCS(new List<Dt_Task> { newTask }); |
| | | // content.OK("åéæå"); |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // _unitOfWorkManage.RollbackTran(); |
| | | // content.Error(ex.Message); |
| | | // } |
| | | // return content; |
| | | //} |
| | | /// <summary> |
| | | /// 空æ¡ååº |
| | | /// </summary> |