| | |
| | | public WebResponseContent ReceiveWeightResultFromWCS(SaveModel saveModel) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | |
| | | try |
| | | { |
| | | string barcode = saveModel.MainData["barcode"].ToString(); |
| | | string weight = saveModel.MainData["weight"].ToString(); |
| | | |
| | | if (weight == null || weight == "0") |
| | | { |
| | | throw new Exception($"æçå·ï¼ã{barcode}ãï¼ééä¸å¯¹ä¸ç¬¦åè§å®"); |
| | | } |
| | | |
| | | Dt_taskinfo taskInfo = Dt_taskinfoRepository.Instance.FindFirst(x => x.task_barcode == barcode); |
| | | if (null == taskInfo) |
| | |
| | | //没æç»çä¿¡æ¯ï¼è¯´æè¯¥ééæ¯ç©ºæççéé |
| | | if (null == boxHead) |
| | | { |
| | | Dt_EmptyPallet dt_Empty= Dt_EmptyPalletRepository.Instance.FindFirst(x => x.EmptyPallet_name == barcode); |
| | | Dt_EmptyPallet dt_Empty = Dt_EmptyPalletRepository.Instance.FindFirst(x => x.EmptyPallet_name == barcode); |
| | | if (null == dt_Empty) |
| | | { |
| | | Dt_EmptyPallet dt_Empty1=new Dt_EmptyPallet(); |
| | | Dt_EmptyPallet dt_Empty1 = new Dt_EmptyPallet(); |
| | | dt_Empty1.EmptyPallet_name = barcode; |
| | | dt_Empty1.EmptyPallet_palletweight = weight; |
| | | dt_Empty1.EmptyPallet_creator = "WMS"; |
| | |
| | | dt_Empty1.EmptyPallet_modifier = "WMS"; |
| | | dt_Empty1.EmptyPallet_modifiertime = DateTime.Now; |
| | | Dt_EmptyPalletRepository.Instance.Add(dt_Empty1,true); |
| | | taskInfo.task_weight = weight; |
| | | } |
| | | else |
| | | { |
| | | taskInfo.task_weight = dt_Empty.EmptyPallet_palletweight; |
| | | } |
| | | |
| | | |
| | | Dt_taskinfoRepository.Instance.Update(taskInfo, true); |
| | | } |
| | | else//æç»çä¿¡æ¯ï¼è¯´æè¯¥ééæ¯è½´æ¿å®æçéé |
| | |
| | | } |
| | | Logger.AddLog(Core.Enums.LoggerType.Edit, saveModel, content, content); |
| | | return content; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è·åå
¥åºåºåååºåºåºåçæ¨¡å¼ |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public WebResponseContent GetInorOutMODELS(SaveModel saveModel) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | return content; |
| | | } |
| | | catch (Exception) |
| | | { |
| | | throw; |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | content = Dt_taskinfoRepository.Instance.DbContextBeginTransaction(() => |
| | | { |
| | | //è·åç©ºè´§ä½ |
| | | Dt_locationinfo emptyLocation = CommonFunction.GetEmptyLocationAction(); |
| | | Dt_locationinfo emptyLocation; |
| | | |
| | | int maxRetries = 20; |
| | | int retryCount = 0; |
| | | bool needRetry; |
| | | do |
| | | { |
| | | needRetry = false; // é»è®¤ä¸éè¦éè¯ |
| | | retryCount++; |
| | | |
| | | //è·åç©ºè´§ä½ |
| | | emptyLocation = CommonFunction.GetEmptyLocationAction(2); |
| | | if (emptyLocation == null) |
| | | { |
| | | return content.Error("æ æ³è·ååºä½"); |
| | | } |
| | | |
| | | // 2. æ£æ¥åºå |
| | | if (IsEmptyPalletLocation(emptyLocation.location_id)) |
| | | { |
| | | needRetry = true; |
| | | continue; // ç´æ¥è¿å
¥ä¸ä¸æ¬¡å¾ªç¯ï¼éè¯ï¼ |
| | | } |
| | | |
| | | // 3. æ£æ¥ä»»å¡ |
| | | if (Dt_taskinfoRepository.Instance.Find(x => x.task_endstation == emptyLocation.location_id).FirstOrDefault() != null) |
| | | { |
| | | needRetry = true; |
| | | continue; |
| | | } |
| | | |
| | | } while (needRetry && retryCount < maxRetries); |
| | | // æ£æ¥æ¯å¦è¶
è¿æå¤§éè¯æ¬¡æ° |
| | | if (retryCount >= maxRetries) |
| | | { |
| | | return content.Error($"æ æ³æ¾å°å¯ç¨åºä½ï¼å·²å°è¯ {retryCount} 次ï¼"); |
| | | } |
| | | |
| | | |
| | | |
| | | LogRecord.WriteLog((int)LogEnum.InBound, $"æçæ¡ç ï¼{barcode},åé
çè´§ä½å·{emptyLocation.location_id}ï¼è´§ä½ç¶æï¼{emptyLocation.location_state}"); |
| | | |
| | | Dt_taskinfo taskinfo = new Dt_taskinfo(); |
| | | taskinfo.task_id = Guid.NewGuid(); |
| | |
| | | return content; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// æ£æ¥æå®è´§ä½æ¯å¦ä¸ºç©ºæçè´§ä½ |
| | | /// </summary> |
| | | /// <param name="locationId">è´§ä½ID</param> |
| | | /// <returns>true: æ¯ç©ºæçè´§ä½, false: 䏿¯ç©ºæçè´§ä½</returns> |
| | | public bool IsEmptyPalletLocation(string locationId) |
| | | { |
| | | try |
| | | { |
| | | // æ¥è¯¢ç©ºæçè´§ä½ä¿¡æ¯ |
| | | var emptyPalletLocation = VV_ContainerInfo_EmptyPalletRepository.Instance |
| | | .Find(x => x.location_id == locationId).FirstOrDefault(); |
| | | |
| | | // æ¥è¯¢è´§ä½ä¸ç容å¨ä¿¡æ¯ |
| | | var containerInfo = VV_ContainerInfoRepository.Instance |
| | | .Find(x => x.location_id == locationId).FirstOrDefault(); |
| | | |
| | | bool isEmptyPallet = emptyPalletLocation != null || containerInfo != null; |
| | | |
| | | return isEmptyPallet; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogRecord.WriteLog((int)LogEnum.Errer, $"æ£æ¥ç©ºæçè´§ä½å¤±è´¥ï¼è´§ä½IDï¼{locationId}ï¼é误ï¼{ex.Message}"); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | } |