| | |
| | | using WIDESEA_Core.FreeDB; |
| | | using WIDESEA_Entity.DomainModels; |
| | | using WIDESEA_Comm; |
| | | using static System.Collections.Specialized.BitVector32; |
| | | |
| | | namespace WIDESEA_WCS.JobsPart.Common |
| | | { |
| | |
| | | foreach (var item in stationinfos) |
| | | { |
| | | //æ ¹æ®ä¸æå£çç»å®ä¿¡æ¯æ¥è¯¢å¯¹åºå·¥åï¼æ£æµæ¤å·¥åæ¯å¦å·²å®æ 宿å³å¯å°å
¶éå
¥åº |
| | | dt_Workinfo workinfo = workinfoRepository.FindFirst(x => x.WorkNumber == item.Number); |
| | | int CompeletedNum = Convert.ToInt32(workinfo.PlannedQuantity) - Convert.ToInt32(workinfo.QuantityCompletion); |
| | | |
| | | dt_mes_head mesinfo = freeDB.Select<dt_mes_head>().Where(x => x.jobID == item.Number).First(); |
| | | int CompeletedNum = Convert.ToInt32(mesinfo.quantity) - Convert.ToInt32(mesinfo.finishNum); |
| | | |
| | | //å¤å®ä»»å¡æ¯å¦å·²å建//å¦å·²åå¨ |
| | | if (freeDB.Select<dt_agvtask>().Where(x => x.agv_fromaddress == item.stationCode).Count() > 0) |
| | |
| | | |
| | | if (item.quantity == 5 || CompeletedNum == 0) //循ç¯è¯»å车轮æ°ä¸º5æè
订å已宿æ°éçä¸æå£ âå·¥å人工å
³éçå·¥å |
| | | { |
| | | dt_stationinfo TargetLocation = GetEmptyLocation(stationinfoRepository, workinfo, item); |
| | | if (mesinfo.quantity <= 50) //å°äº50ä»¶ç´æ¥åºåº |
| | | { |
| | | //todo 寻æ¾å¯æ¾è´§å¤åæ¾è´§å° |
| | | dt_agvtask agvtask = new dt_agvtask() |
| | | { |
| | | agv_fromaddress = item.stationCode, |
| | | agv_id = Guid.NewGuid(), |
| | | agv_grade = 0, |
| | | agv_barcode = "", |
| | | agv_createtime = DateTime.Now, |
| | | agv_taskstate = TaskStatus.Created.ToString(), |
| | | //agv_toaddress = , |
| | | |
| | | }; |
| | | freeDB.Add(agvtask); |
| | | } |
| | | else |
| | | { |
| | | dt_stationinfo TargetLocation = GetEmptyLocation(stationinfoRepository, mesinfo, item); |
| | | |
| | | if (TargetLocation != null) |
| | | { |
| | |
| | | agv_createtime = DateTime.Now, |
| | | agv_taskstate = TaskStatus.Created.ToString(), |
| | | agv_toaddress = TargetLocation.stationCode, |
| | | |
| | | }; |
| | | |
| | | freeDB.Add(agvtask); |
| | |
| | | freeDB.Update(TargetLocation); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | /// <param name="workinfo">订å</param> |
| | | /// <param name="stationinfo">䏿å£ä¿¡æ¯</param> |
| | | /// <returns></returns> |
| | | private dt_stationinfo GetEmptyLocation(Idt_stationinfoRepository stationinfoRepository, dt_Workinfo workinfo, dt_stationinfo stationinfo) |
| | | private dt_stationinfo GetEmptyLocation(Idt_stationinfoRepository stationinfoRepository, dt_mes_head mesinfo, dt_stationinfo stationinfo) |
| | | { |
| | | //æ¾è´§ä½ |
| | | dt_stationinfo TargetLocation = null; |
| | | |
| | | //æ ¹æ®è®¢åæ°éæ¥å¯»æ¾å¯¹åºåºåºä¸åç©æç±»ååºä½ |
| | | |
| | | if (workinfo.PlannedQuantity < 50) //åºåº1 ç©æç±»åå¤ |
| | | { |
| | | dt_stationinfo station = stationinfoRepository.Find(x => x.stationType == stationinfo.stationType && x.area == "1").OrderByDescending(x => x.lastUpdateTime).FirstOrDefault(); |
| | | if (station != null) |
| | | { |
| | | //å¦åå¨åç©æç±»åä¸å¨1è¡çåºååæ°å
¥åºçç©ææ¾è³åå ä¸åå¨åå¯»æ¾æ°è¡åºä½ |
| | | if (station.line == 1) |
| | | { |
| | | TargetLocation = stationinfoRepository.Find(x => x.area == station.area && x.location_state == LocationStateEnum.Empty.ToString() && x.column == station.column && x.enable).OrderBy(x => x.line).ThenBy(x => x.column).FirstOrDefault(); |
| | | } |
| | | TargetLocation = stationinfoRepository.Find(x => x.area == station.area && x.location_state == LocationStateEnum.Empty.ToString() && x.line == 1 && x.enable).OrderBy(x => x.line).ThenBy(x => x.column).FirstOrDefault(); |
| | | } |
| | | else |
| | | { |
| | | TargetLocation = stationinfoRepository.Find(x => x.area == "1" && x.location_state == LocationStateEnum.Empty.ToString() && x.line == 1 && x.enable).OrderBy(x => x.line).ThenBy(x => x.column).FirstOrDefault(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | #region æ ¹æ®è®¢åæ°éæ¥å¯»æ¾å¯¹åºåºåºä¸åç©æç±»ååºä½ |
| | | //if (workinfo.PlannedQuantity < 50) //åºåº1 ç©æç±»åå¤ |
| | | //{ |
| | | // dt_stationinfo station = stationinfoRepository.Find(x => x.stationType == stationinfo.stationType && x.area == "1").OrderByDescending(x => x.lastUpdateTime).FirstOrDefault(); |
| | | // if (station != null) |
| | | // { |
| | | // //å¦åå¨åç©æç±»åä¸å¨1è¡çåºååæ°å
¥åºçç©ææ¾è³åå ä¸åå¨åå¯»æ¾æ°è¡åºä½ |
| | | // if (station.line == 1) |
| | | // { |
| | | // TargetLocation = stationinfoRepository.Find(x => x.area == station.area && x.location_state == LocationStateEnum.Empty.ToString() && x.column == station.column && x.enable).OrderBy(x => x.line).ThenBy(x => x.column).FirstOrDefault(); |
| | | // } |
| | | // TargetLocation = stationinfoRepository.Find(x => x.area == station.area && x.location_state == LocationStateEnum.Empty.ToString() && x.line == 1 && x.enable).OrderBy(x => x.line).ThenBy(x => x.column).FirstOrDefault(); |
| | | // } |
| | | // else |
| | | // { |
| | | // TargetLocation = stationinfoRepository.Find(x => x.area == "1" && x.location_state == LocationStateEnum.Empty.ToString() && x.line == 1 && x.enable).OrderBy(x => x.line).ThenBy(x => x.column).FirstOrDefault(); |
| | | // } |
| | | //} |
| | | //else |
| | | //{ |
| | | //int quantity = Convert.ToInt32(workinfo.PlannedQuantity); |
| | | //string area = GetArea(quantity); |
| | | |
| | | dt_materielinfo materielinfo = freeDB.Select<dt_materielinfo>().Where(x => x.materiel_id == stationinfo.stationType).First(); |
| | | //dt_materielinfo materielinfo = freeDB.Select<dt_materielinfo>().Where(x => x.materiel_id == stationinfo.stationType).First(); |
| | | |
| | | if (materielinfo == null) |
| | | throw new Exception($"æ æ¤ç©æç±»å{stationinfo.stationType}åºåº"); |
| | | //if (materielinfo == null) |
| | | // throw new Exception($"æ æ¤ç©æç±»å{stationinfo.stationType}åºåº"); |
| | | |
| | | string area = materielinfo.materiel_areaid.ToString(); |
| | | //string area = materielinfo.materiel_areaid.ToString(); |
| | | |
| | | //å¦åå¨åç±»åç©æåæ¾ç½®åè¡åºä½ ä¸åå¨åæ¾ç½®æ°è¡ç第ä¸åä¸ |
| | | dt_stationinfo station = stationinfoRepository.Find(x => x.stationType == stationinfo.stationType && x.area == area).OrderBy(x => x.lastUpdateTime).FirstOrDefault(); |
| | | if (station != null) |
| | | { |
| | | TargetLocation = stationinfoRepository.Find(x => x.area == station.area && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.line == station.line).OrderBy(x => x.column).FirstOrDefault(); |
| | | if (TargetLocation == null) |
| | | { |
| | | TargetLocation = stationinfoRepository.Find(x => x.area == area && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.column == '1').OrderBy(x => x.line).FirstOrDefault(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | TargetLocation = stationinfoRepository.Find(x => x.area == area && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.column == '1').OrderBy(x => x.line).FirstOrDefault(); |
| | | } |
| | | //dt_stationinfo station = stationinfoRepository.Find(x => x.stationType == stationinfo.stationType && x.area == area).OrderBy(x => x.lastUpdateTime).FirstOrDefault(); |
| | | //if (station != null) |
| | | //{ |
| | | // TargetLocation = stationinfoRepository.Find(x => x.area == station.area && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.line == station.line).OrderBy(x => x.column).FirstOrDefault(); |
| | | // if (TargetLocation == null) |
| | | // { |
| | | // TargetLocation = stationinfoRepository.Find(x => x.area == area && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.column == '1').OrderBy(x => x.line).FirstOrDefault(); |
| | | // } |
| | | //} |
| | | //else |
| | | //{ |
| | | // TargetLocation = stationinfoRepository.Find(x => x.area == area && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.column == '1').OrderBy(x => x.line).FirstOrDefault(); |
| | | //} |
| | | |
| | | //todo å¦ç©æå·²æ»¡åæ¾ç½®å
¶ä»åºåº |
| | | //if (TargetLocation == null) |
| | | //{ |
| | | // stationinfoRepository.Find(x => x.area == area && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.column == '1').OrderBy(x => x.line).FirstOrDefault(); |
| | | //} |
| | | } |
| | | |
| | | if (TargetLocation == null) |
| | | { |
| | | throw new Exception("åºä½å·²æ»¡"); |
| | | } |
| | | //} |
| | | //if (TargetLocation == null) |
| | | //{ |
| | | // throw new Exception("åºä½å·²æ»¡"); |
| | | //} |
| | | |
| | | //else if (workinfo.PlannedQuantity >= 50 && workinfo.PlannedQuantity < 110) //åºåº2 |
| | | //{ |
| | |
| | | //{ |
| | | |
| | | //} |
| | | #endregion |
| | | |
| | | //æ ¹æ®è®¢åçå·/å·¥åå·/ç±»å |
| | | if (mesinfo.quantity >= 180) |
| | | { |
| | | //æ¥è¯¢åºåè®°å½ä¸æ¯å¦åå¨åç±»å/å·¥å/çå·çè®°å½ å¦æåæ¾ç½®åä¸è¡ï¼æ åå¯»æ¾æ°åºä½ |
| | | var detail = freeDB.Select<dt_mes_detail>().Where(x => x.jobID == mesinfo.jobID).First(); |
| | | var inventory = freeDB.Select<dt_inventory>().Where(x => x.HeatNumber == detail.heatID /*&& x.*/).First(); |
| | | if (inventory != null) |
| | | { |
| | | int line = Convert.ToInt16(inventory.stationCode.Split("-")[0]); |
| | | TargetLocation = stationinfoRepository.Find(x => x.line == line && x.location_state == LocationStateEnum.Empty.ToString() && x.area == inventory.area).FirstOrDefault(); |
| | | } |
| | | else |
| | | { |
| | | TargetLocation = stationinfoRepository.Find(x => x.area == "2" && x.location_state == LocationStateEnum.Empty.ToString() && x.enable).OrderBy(x => x.line).ThenBy(x => x.column).FirstOrDefault(); |
| | | } |
| | | } |
| | | |
| | | if (TargetLocation == null) |
| | | { |
| | | throw new Exception("åºä½å·²æ»¡"); |
| | | } |
| | | return TargetLocation; |
| | | } |
| | | |