Merge branch 'htq20251215' of http://115.159.85.185:8098/r/ZhongRui/ALDbanyunxiangmu into htq20251215
| | |
| | | type: 'warning', |
| | | onClick: function () { |
| | | } |
| | | },{ |
| | | name: "åºåååºåç§»åº", |
| | | icon: '', |
| | | class: '', |
| | | value: 'SelectStockAreaOut', |
| | | type: 'danger', |
| | | onClick: function () { |
| | | } |
| | | } |
| | | ] |
| | | |
| | |
| | | }) |
| | | |
| | | let SelectTake = this.buttons.find(x => x.value == 'SelectStockTake'); |
| | | if (SelectTake) { |
| | | // æ¹ä¸ºç®å¤´å½æ°ç¡®ä¿thisæåVueç»ä»¶å®ä¾ |
| | | SelectTake.onClick = async () => { |
| | | // è·åé䏿°æ®ï¼ä¸åé»è¾ä¸è´ï¼ç¡®ä¿æ¯æ°ç»æ ¼å¼ï¼ |
| | | let stockViews = this.$refs.table.getSelected(); |
| | | |
| | | // æ°æ®æ ¡éªï¼è³å°éæ©ä¸æ¡æ°æ® |
| | | if (stockViews.length === 0) return ElMessage.error("è¯·éæ©éè¦æä½çæ°æ®!"); |
| | | |
| | | // ç«å°é项ï¼å¯æ ¹æ®å®é
ä¸å¡è°æ´é项å¼ï¼ |
| | | const stationOptions = [ |
| | | { label: "ç«å°2", value: "2-1" }, |
| | | { label: "ç«å°3", value: "3-1" }, |
| | | { label: "ç«å°4", value: "4-1" }, |
| | | ]; |
| | | |
| | | // åå»ºå¼¹çªæè½½èç¹ |
| | | const mountNode = document.createElement("div"); |
| | | document.body.appendChild(mountNode); |
| | | |
| | | // è¡¨åæ°æ®ï¼ç»å®éä¸çç«å°ï¼ |
| | | const formData = reactive({ |
| | | outStation: stationOptions[0].value, // é»è®¤éä¸ç¬¬ä¸ä¸ªç«å° |
| | | }); |
| | | |
| | | // å建弹çªVNode |
| | | const vnode = createVNode( |
| | | ElDialog, |
| | | { |
| | | title: "åºåæä½ - éæ©åºåºç«å°", |
| | | width: "500px", |
| | | modelValue: true, |
| | | appendToBody: true, |
| | | "onUpdate:modelValue": (isVisible) => { |
| | | if (!isVisible) { |
| | | render(null, mountNode); |
| | | document.body.removeChild(mountNode); |
| | | } |
| | | }, |
| | | style: { |
| | | padding: "20px 0", |
| | | borderRadius: "8px", |
| | | }, |
| | | }, |
| | | { |
| | | default: () => |
| | | h( |
| | | ElForm, |
| | | if (SelectTake) { |
| | | // æ¹ä¸ºç®å¤´å½æ°ç¡®ä¿thisæåVueç»ä»¶å®ä¾ |
| | | SelectTake.onClick = async () => { |
| | | // è·åé䏿°æ®ï¼ä¸åé»è¾ä¸è´ï¼ç¡®ä¿æ¯æ°ç»æ ¼å¼ï¼ |
| | | let stockViews = this.$refs.table.getSelected(); |
| | | |
| | | // æ°æ®æ ¡éªï¼è³å°éæ©ä¸æ¡æ°æ® |
| | | if (stockViews.length === 0) return ElMessage.error("è¯·éæ©éè¦æä½çæ°æ®!"); |
| | | |
| | | // ç«å°é项ï¼å¯æ ¹æ®å®é
ä¸å¡è°æ´é项å¼ï¼ |
| | | const stationOptions = [ |
| | | { label: "ç«å°2", value: "2-1" }, |
| | | { label: "ç«å°3", value: "3-1" }, |
| | | { label: "ç«å°4", value: "4-1" }, |
| | | ]; |
| | | |
| | | // åå»ºå¼¹çªæè½½èç¹ |
| | | const mountNode = document.createElement("div"); |
| | | document.body.appendChild(mountNode); |
| | | |
| | | // è¡¨åæ°æ®ï¼ç»å®éä¸çç«å°ï¼ |
| | | const formData = reactive({ |
| | | outStation: stationOptions[0].value, // é»è®¤éä¸ç¬¬ä¸ä¸ªç«å° |
| | | }); |
| | | |
| | | // å建弹çªVNode |
| | | const vnode = createVNode( |
| | | ElDialog, |
| | | { |
| | | model: formData, |
| | | rules: { |
| | | outStation: [ |
| | | { required: true, message: "è¯·éæ©åºåºç«å°", trigger: "change" }, |
| | | ], |
| | | title: "åºåæä½ - éæ©åºåºç«å°", |
| | | width: "500px", |
| | | modelValue: true, |
| | | appendToBody: true, |
| | | "onUpdate:modelValue": (isVisible) => { |
| | | if (!isVisible) { |
| | | render(null, mountNode); |
| | | document.body.removeChild(mountNode); |
| | | } |
| | | }, |
| | | ref: "stockTakeForm", // 表årefæ è¯ |
| | | labelWidth: "100px", |
| | | style: { |
| | | padding: "0 30px", |
| | | padding: "20px 0", |
| | | borderRadius: "8px", |
| | | }, |
| | | }, |
| | | [ |
| | | // ç«å°éæ©ä¸ææ¡ |
| | | h(ElFormItem, { |
| | | label: "åºåºç«å°", |
| | | prop: "outStation", |
| | | style: { marginBottom: "24px" }, |
| | | }, [ |
| | | h(ElSelect, { |
| | | placeholder: "è¯·éæ©åºåºç«å°", |
| | | modelValue: formData.outStation, |
| | | "onUpdate:modelValue": (val) => { |
| | | formData.outStation = val; |
| | | { |
| | | default: () => |
| | | h( |
| | | ElForm, |
| | | { |
| | | model: formData, |
| | | rules: { |
| | | outStation: [ |
| | | { required: true, message: "è¯·éæ©åºåºç«å°", trigger: "change" }, |
| | | ], |
| | | }, |
| | | ref: "stockTakeForm", // 表årefæ è¯ |
| | | labelWidth: "100px", |
| | | style: { |
| | | padding: "0 30px", |
| | | }, |
| | | }, |
| | | style: { |
| | | width: "100%", |
| | | height: "40px", |
| | | borderRadius: "4px", |
| | | borderColor: "#dcdfe6", |
| | | }, |
| | | }, stationOptions.map((station) => |
| | | h(ElOption, { label: station.label, value: station.value }) |
| | | )), |
| | | ]), |
| | | // åºé¨æé®åºå |
| | | h("div", { |
| | | style: { |
| | | textAlign: "right", |
| | | marginTop: "8px", |
| | | paddingRight: "4px", |
| | | }, |
| | | }, [ |
| | | // åæ¶æé® |
| | | h(ElButton, { |
| | | type: "text", |
| | | onClick: () => { |
| | | render(null, mountNode); |
| | | document.body.removeChild(mountNode); |
| | | ElMessage.info("åæ¶åºåæä½"); |
| | | }, |
| | | style: { marginRight: "8px", color: "#606266" }, |
| | | }, "åæ¶"), |
| | | // ç¡®å®æé® |
| | | h(ElButton, { |
| | | type: "primary", |
| | | onClick: async () => { |
| | | // ç¡®ä¿è¡¨årefå·²æè½½ |
| | | await this.$nextTick(); |
| | | const formRef = vnode.component.refs.stockTakeForm; |
| | | [ |
| | | // ç«å°éæ©ä¸ææ¡ |
| | | h(ElFormItem, { |
| | | label: "åºåºç«å°", |
| | | prop: "outStation", |
| | | style: { marginBottom: "24px" }, |
| | | }, [ |
| | | h(ElSelect, { |
| | | placeholder: "è¯·éæ©åºåºç«å°", |
| | | modelValue: formData.outStation, |
| | | "onUpdate:modelValue": (val) => { |
| | | formData.outStation = val; |
| | | }, |
| | | style: { |
| | | width: "100%", |
| | | height: "40px", |
| | | borderRadius: "4px", |
| | | borderColor: "#dcdfe6", |
| | | }, |
| | | }, stationOptions.map((station) => |
| | | h(ElOption, { label: station.label, value: station.value }) |
| | | )), |
| | | ]), |
| | | // åºé¨æé®åºå |
| | | h("div", { |
| | | style: { |
| | | textAlign: "right", |
| | | marginTop: "8px", |
| | | paddingRight: "4px", |
| | | }, |
| | | }, [ |
| | | // åæ¶æé® |
| | | h(ElButton, { |
| | | type: "text", |
| | | onClick: () => { |
| | | render(null, mountNode); |
| | | document.body.removeChild(mountNode); |
| | | ElMessage.info("åæ¶åºåæä½"); |
| | | }, |
| | | style: { marginRight: "8px", color: "#606266" }, |
| | | }, "åæ¶"), |
| | | // ç¡®å®æé® |
| | | h(ElButton, { |
| | | type: "primary", |
| | | onClick: async () => { |
| | | // ç¡®ä¿è¡¨årefå·²æè½½ |
| | | await this.$nextTick(); |
| | | const formRef = vnode.component.refs.stockTakeForm; |
| | | |
| | | if (!formRef) { |
| | | ElMessage.error("表ååå§å失败ï¼è¯·éè¯"); |
| | | return; |
| | | } |
| | | if (!formRef) { |
| | | ElMessage.error("表ååå§å失败ï¼è¯·éè¯"); |
| | | return; |
| | | } |
| | | |
| | | // 表åéªè¯ |
| | | try { |
| | | await formRef.validate(); |
| | | } catch (err) { |
| | | return; |
| | | } |
| | | // 表åéªè¯ |
| | | try { |
| | | await formRef.validate(); |
| | | } catch (err) { |
| | | return; |
| | | } |
| | | |
| | | const requestBody = stockViews; |
| | | const outStation = formData.outStation; |
| | | const requestBody = stockViews; |
| | | const outStation = formData.outStation; |
| | | |
| | | try { |
| | | try { |
| | | |
| | | const url = `api/Task/TakeOutbound?outStation=${encodeURIComponent(outStation)}`; |
| | | |
| | | const x = await this.http.post( |
| | | url, // 带æ¥è¯¢åæ°çURL |
| | | requestBody, // 请æ±ä½ï¼stockViewsæ°ç» |
| | | "æ°æ®å¤çä¸" |
| | | ); |
| | | const url = `api/Task/TakeOutbound?outStation=${encodeURIComponent(outStation)}`; |
| | | |
| | | const x = await this.http.post( |
| | | url, // 带æ¥è¯¢åæ°çURL |
| | | requestBody, // 请æ±ä½ï¼stockViewsæ°ç» |
| | | "æ°æ®å¤çä¸" |
| | | ); |
| | | |
| | | if (!x.status) { |
| | | ElMessage.error(x.message || "åºåæä½å¤±è´¥"); |
| | | return; |
| | | } |
| | | if (!x.status) { |
| | | ElMessage.error(x.message || "åºåæä½å¤±è´¥"); |
| | | return; |
| | | } |
| | | |
| | | ElMessage.success("æä½æå"); |
| | | this.refresh(); // åå·æ°é»è¾ä¿ç |
| | | } catch (error) { |
| | | console.error("åºåæ¥å£è¯·æ±å¤±è´¥ï¼", error); |
| | | ElMessage.error("请æ±å¤±è´¥ï¼è¯·ç¨åéè¯"); |
| | | } finally { |
| | | // æ 论æå失败ï¼å
³éå¼¹çª |
| | | render(null, mountNode); |
| | | document.body.removeChild(mountNode); |
| | | } |
| | | }, |
| | | style: { borderRadius: "4px", padding: "8px 20px" }, |
| | | }, "ç¡®å®æä½"), |
| | | ]), |
| | | ]), |
| | | ElMessage.success("æä½æå"); |
| | | this.refresh(); // åå·æ°é»è¾ä¿ç |
| | | } catch (error) { |
| | | console.error("åºåæ¥å£è¯·æ±å¤±è´¥ï¼", error); |
| | | ElMessage.error("请æ±å¤±è´¥ï¼è¯·ç¨åéè¯"); |
| | | } finally { |
| | | // æ 论æå失败ï¼å
³éå¼¹çª |
| | | render(null, mountNode); |
| | | document.body.removeChild(mountNode); |
| | | } |
| | | }, |
| | | style: { borderRadius: "4px", padding: "8px 20px" }, |
| | | }, "ç¡®å®æä½"), |
| | | ]), |
| | | ]), |
| | | } |
| | | ); |
| | | |
| | | // ç»å®appä¸ä¸æï¼ç¡®ä¿å¼¹çªå
ç»ä»¶æ£å¸¸å·¥ä½ï¼ |
| | | vnode.appContext = this.$.appContext; |
| | | render(vnode, mountNode); |
| | | }; |
| | | } |
| | | ); |
| | | |
| | | // ç»å®appä¸ä¸æï¼ç¡®ä¿å¼¹çªå
ç»ä»¶æ£å¸¸å·¥ä½ï¼ |
| | | vnode.appContext = this.$.appContext; |
| | | render(vnode, mountNode); |
| | | }; |
| | | } |
| | | let SelectTakeArea = this.buttons.find(x => x.value == 'SelectStockAreaOut'); |
| | | if (SelectTakeArea) { |
| | | SelectTakeArea.onClick = function () { |
| | | let stockViews = this.$refs.table.getSelected(); |
| | | this.http |
| | | .post("api/Task/AreaOutbound",stockViews, "æ°æ®å¤çä¸") |
| | | .then((x) => { |
| | | if (!x.status) return this.$message.error(x.message); |
| | | this.$message.success("æä½æå"); |
| | | this.refresh(); |
| | | }); |
| | | } |
| | | } |
| | | }, |
| | | onInited() { |
| | | //æ¡æ¶åå§åé
ç½®å |
| | |
| | | { nameof(Dt_LocationInfo.Row),OrderByType.Asc }, |
| | | { nameof(Dt_LocationInfo.Column),OrderByType.Asc }, |
| | | { nameof(Dt_LocationInfo.Depth),OrderByType.Desc }, |
| | | |
| | | }; |
| | | |
| | | |
| | |
| | | /// å··éå
ç§»åº |
| | | /// </summary> |
| | | [Description("å··éå
ç§»åº")] |
| | | Relocation = 900 |
| | | |
| | | Relocation = 900, |
| | | |
| | | /// <summary> |
| | | /// ååºåç§»åº |
| | | /// </summary> |
| | | [Description("ååºåç§»åº")] |
| | | AreaRelocation = 910 |
| | | |
| | | } |
| | | |
| | | public enum TaskTypeGroup |
| | |
| | | Task<WebResponseContent> HandCompleteTask(string TaskNum); |
| | | |
| | | Task<WebResponseContent> TaskCancel(List<int> taskCodes); |
| | | |
| | | Task<WebResponseContent> AreaOutbound(List<StockViewDTO> stockViews); |
| | | } |
| | | } |
| | |
| | | |
| | | Func<Dt_OutStockLockInfo, bool> wareWhere = x => string.IsNullOrEmpty(outboundOrderDetails.First().WarehouseCode) ? true : x.WarehouseCode == outboundOrderDetails.First().WarehouseCode; |
| | | |
| | | var idStr = outboundOrderDetails.First().Id.ToString(); |
| | | |
| | | var stockLockInfos = _outboundLockInfoRepository.QueryData(x => |
| | | (x.OrderDetailIds == idStr || |
| | | x.OrderDetailIds.StartsWith(idStr + ",") || |
| | | x.OrderDetailIds.EndsWith("," + idStr) || |
| | | x.OrderDetailIds.Contains("," + idStr + ",")) && |
| | | x.OrderDetailIds == lockInfo.OrderDetailIds && |
| | | x.OrderNo == request.OrderNo && |
| | | x.MaterielCode == stockInfoDetail.MaterielCode) |
| | | .Where(supWhere) |
| | |
| | | |
| | | Func<Dt_OutStockLockInfo, bool> wareWhere = x => string.IsNullOrEmpty(outboundOrderDetails.First().WarehouseCode) ? true : x.WarehouseCode == outboundOrderDetails.First().WarehouseCode; |
| | | |
| | | var idStr = outboundOrderDetails.First().Id.ToString(); |
| | | |
| | | var stockLockInfos = _outboundLockInfoRepository.QueryData(x => |
| | | (x.OrderDetailIds == idStr || |
| | | x.OrderDetailIds.StartsWith(idStr + ",") || |
| | | x.OrderDetailIds.EndsWith("," + idStr) || |
| | | x.OrderDetailIds.Contains("," + idStr + ",")) && |
| | | x.OrderDetailIds == lockInfo.OrderDetailIds && |
| | | x.OrderNo == request.OrderNo && |
| | | x.MaterielCode == stockDetail.MaterielCode) |
| | | .Where(supWhere) |
| | |
| | | return WebResponseContent.Instance.Error($"ä»»å¡åæ¶å¤±è´¥ï¼{ex.Message}"); |
| | | } |
| | | } |
| | | |
| | | public async Task<WebResponseContent> AreaRelocationTaskCompleted(Dt_Task task) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | if (task == null || string.IsNullOrEmpty(task.PalletCode) || string.IsNullOrEmpty(task.TargetAddress)) |
| | | { |
| | | return WebResponseContent.Instance.Error("ç§»åºä»»å¡ä¿¡æ¯ä¸å®æ´ï¼æçå·/ç®æ è´§ä½ä¸ºç©ºï¼"); |
| | | } |
| | | |
| | | // 2. æ¥è¯¢æçåºåä¿¡æ¯ |
| | | Dt_StockInfo stockInfo = await _stockRepository.Db.Queryable<Dt_StockInfo>() |
| | | .Includes(x => x.Details) |
| | | .Where(x => x.PalletCode == task.PalletCode) |
| | | .FirstAsync(); |
| | | |
| | | if (stockInfo == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°æç[{task.PalletCode}]对åºçç»çä¿¡æ¯"); |
| | | } |
| | | |
| | | // é空æçå¿
é¡»ææç» |
| | | if (stockInfo.Details.Count == 0 && stockInfo.PalletType != PalletTypeEnum.Empty.ObjToInt()) |
| | | { |
| | | _logger.LogInformation($"TaskService RelocationTaskCompleted: æªæ¾å°è¯¥æçåºåæç»ä¿¡æ¯.{task.TaskNum}"); |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°è¯¥æç[{task.PalletCode}]åºåæç»ä¿¡æ¯"); |
| | | } |
| | | |
| | | // 3. æ¥è¯¢ç®æ è´§ä½+åè´§ä½ä¿¡æ¯ |
| | | Dt_LocationInfo targetLocationInfo = _locationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress); |
| | | if (targetLocationInfo == null) |
| | | { |
| | | return content.Error($"æªæ¾å°å¯¹åºçç»ç¹è´§ä½[{task.TargetAddress}]ä¿¡æ¯"); |
| | | } |
| | | |
| | | // åè´§ä½ä¿¡æ¯ |
| | | Dt_LocationInfo oldLocationInfo = null; |
| | | if (!string.IsNullOrEmpty(stockInfo.LocationCode)) |
| | | { |
| | | oldLocationInfo = _locationInfoService.Repository.QueryFirst(x => x.LocationCode == stockInfo.LocationCode); |
| | | if (oldLocationInfo == null) |
| | | { |
| | | return content.Error($"æªæ¾å°åè´§ä½[{stockInfo.LocationCode}]ä¿¡æ¯"); |
| | | } |
| | | } |
| | | |
| | | // 4. è´§ä½ç¶ææ ¡éª |
| | | if (targetLocationInfo.LocationStatus == LocationStatusEnum.InStock.ObjToInt()) |
| | | { |
| | | return WebResponseContent.Instance.Error($"ç®æ è´§ä½[{task.TargetAddress}]ç¶æä¸æ£ç¡®ï¼å½å为已å ç¨ï¼"); |
| | | } |
| | | |
| | | // 5. å¼å¯äºå¡å¤çæ ¸å¿é»è¾ |
| | | _unitOfWorkManage.BeginTran(); |
| | | |
| | | // 5.1 è®°å½ç®æ è´§ä½åç¶æï¼æ´æ°ä¸ºå ç¨ |
| | | var beforeTargetLocationStatus = targetLocationInfo.LocationStatus; |
| | | targetLocationInfo.LocationStatus = stockInfo.PalletType == PalletTypeEnum.Empty.ObjToInt() |
| | | ? LocationStatusEnum.Pallet.ObjToInt() |
| | | : LocationStatusEnum.InStock.ObjToInt(); |
| | | _locationInfoService.Repository.UpdateData(targetLocationInfo); |
| | | |
| | | // 5.2 éæ¾åè´§ä½ |
| | | int beforeOldLocationStatus = 0; |
| | | if (oldLocationInfo != null) |
| | | { |
| | | beforeOldLocationStatus = oldLocationInfo.LocationStatus; |
| | | // åè´§ä½æ¢å¤ä¸ºç©ºé² |
| | | oldLocationInfo.LocationStatus = LocationStatusEnum.Free.ObjToInt(); |
| | | _locationInfoService.Repository.UpdateData(oldLocationInfo); |
| | | } |
| | | // 5.4 æ´æ°åºå主信æ¯ï¼ç»å®æ°è´§ä½ï¼ |
| | | string oldLocationCode = stockInfo.LocationCode; // è®°å½åè´§ä½ |
| | | stockInfo.LocationCode = targetLocationInfo.LocationCode; // ç»å®ç®æ è´§ä½ |
| | | stockInfo.PalletCode = task.PalletCode; |
| | | stockInfo.StockStatus = StockStatusEmun.å
¥åºå®æ.ObjToInt(); |
| | | |
| | | _stockRepository.UpdateData(stockInfo); |
| | | |
| | | // 5.5 æ´æ°ä»»å¡ç¶æä¸ºå®æ |
| | | task.TaskStatus = TaskStatusEnum.Finish.ObjToInt(); |
| | | var result = _task_HtyService.DeleteAndMoveIntoHty(task, OperateTypeEnum.èªå¨å®æ); |
| | | |
| | | // æäº¤äºå¡ |
| | | _unitOfWorkManage.CommitTran(); |
| | | |
| | | // ä»»å¡å½æ¡£å¤±è´¥åç´æ¥å é¤ |
| | | if (!result) |
| | | { |
| | | await Db.Deleteable(task).ExecuteCommandAsync(); |
| | | } |
| | | try |
| | | { |
| | | // è®°å½ç®æ è´§ä½ç¶æåæ´ |
| | | _locationStatusChangeRecordService.AddLocationStatusChangeRecord( |
| | | targetLocationInfo, |
| | | beforeTargetLocationStatus, |
| | | StockChangeType.Inbound.ObjToInt(), |
| | | $"ç§»åºå
¥åºï¼åè´§ä½ï¼{oldLocationCode}ï¼", |
| | | task.TaskNum); |
| | | |
| | | // è®°å½åè´§ä½ç¶æåæ´ï¼è¥æï¼ |
| | | if (oldLocationInfo != null) |
| | | { |
| | | _locationStatusChangeRecordService.AddLocationStatusChangeRecord( |
| | | oldLocationInfo, |
| | | beforeOldLocationStatus, |
| | | StockChangeType.Outbound.ObjToInt(), |
| | | $"ç§»åºåºåºï¼ç®æ è´§ä½ï¼{targetLocationInfo.LocationCode}ï¼", |
| | | task.TaskNum); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _logger.LogInformation($"RelocationTaskCompleted AddLocationStatusChangeRecord : {ex.Message} "); |
| | | } |
| | | |
| | | return content.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | // äºå¡åæ» |
| | | _unitOfWorkManage.RollbackTran(); |
| | | _logger.LogError($"RelocationTaskCompleted å¤ç失败ï¼{ex.Message}", ex); |
| | | return await Task.FromResult(WebResponseContent.Instance.Error($"ç§»åºä»»å¡å¤ç失败ï¼{ex.Message}")); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using System.Transactions; |
| | | using WIDESEA_BasicService; |
| | | using WIDESEA_Common.CommonEnum; |
| | | using WIDESEA_Common.LocationEnum; |
| | |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | return await Task.FromResult(WebResponseContent.Instance.Error(ex.Message)); |
| | | } |
| | | return content; |
| | | } |
| | |
| | | return code; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// éå®åºåååºåç§»åº |
| | | /// </summary> |
| | | /// <param name="id"></param> |
| | | /// <returns></returns> |
| | | public async Task<WebResponseContent> AreaOutbound(List<StockViewDTO> stockViews) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | List<int> ids = stockViews.Select(x => x.StockId).ToList(); |
| | | //è·ååºå |
| | | List<Dt_StockInfo> stockInfos = _stockRepository.Db.Queryable<Dt_StockInfo>().Where(x => ids.Contains(x.Id)).Includes(x => x.Details).ToList(); |
| | | if (stockInfos.Count != stockViews.Count) |
| | | { |
| | | StockViewDTO? stockViewDTO = stockViews.FirstOrDefault(x => !stockInfos.Select(x => x.PalletCode).ToList().Contains(x.PalletCode)); |
| | | return content.Error($"æªæ¾å°{stockViewDTO?.PalletCode}åºå"); |
| | | } |
| | | //è·åè´§ä½ |
| | | List<string> locStrs = stockInfos.Select(x => x.LocationCode).ToList(); |
| | | List<Dt_LocationInfo> locationInfos = _locationInfoService.Db.Queryable<Dt_LocationInfo>().Where(x => locStrs.Contains(x.LocationCode)).ToList(); |
| | | if (stockInfos.Count != locationInfos.Count) |
| | | { |
| | | string? locStr = locStrs.FirstOrDefault(x => !locationInfos.Select(x => x.LocationCode).ToList().Contains(x)); |
| | | return content.Error($"æªæ¾å°{locStr}è´§ä½æ°æ®"); |
| | | } |
| | | |
| | | foreach (var item in stockInfos) |
| | | { |
| | | Dt_LocationInfo? locationInfo = locationInfos.FirstOrDefault(x => x.LocationCode == item.LocationCode); |
| | | if (locationInfo == null || (locationInfo.EnableStatus == EnableStatusEnum.Disable.ObjToInt() || locationInfo.EnableStatus != EnableStatusEnum.Normal.ObjToInt()) || item.StockStatus != StockStatusEmun.å
¥åºå®æ.ObjToInt()) |
| | | { |
| | | return content.Error($"{item.PalletCode}è´§ä½æåºåç¶æä¸æ»¡è¶³åºåºæ¡ä»¶"); |
| | | } |
| | | } |
| | | List<Dt_Task> tasks = AreaGetTasks(stockInfos, TaskTypeEnum.AreaRelocation); |
| | | if (tasks == null || tasks.Count <= 0) |
| | | { |
| | | return content.Error($"çæä»»å¡å¤±è´¥"); |
| | | } |
| | | stockInfos.ForEach(x => |
| | | { |
| | | x.StockStatus = StockStatusEmun.åºåºéå®.ObjToInt(); |
| | | }); |
| | | tasks.ForEach(x => |
| | | { |
| | | x.OrderNo = "æ åæ®ç§»åº"; |
| | | }); |
| | | locationInfos.ForEach(x => |
| | | { |
| | | x.LocationStatus = LocationStatusEnum.Lock.ObjToInt(); |
| | | }); |
| | | _unitOfWorkManage.BeginTran(); |
| | | //æ´æ°åºåç¶æ |
| | | _stockRepository.UpdateData(stockInfos); |
| | | //æ°å»ºä»»å¡ |
| | | BaseDal.AddData(tasks); |
| | | _locationInfoService.UpdateData(locationInfos); |
| | | _unitOfWorkManage.CommitTran(); |
| | | content.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return await Task.FromResult(WebResponseContent.Instance.Error(ex.Message)); |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | public List<Dt_Task> AreaGetTasks(List<Dt_StockInfo> stockInfos, TaskTypeEnum taskType) |
| | | { |
| | | // ä½¿ç¨ TransactionScope å
裹æ´ä¸ªæä½ï¼ç¡®ä¿æææ°æ®åºæä½å¨åä¸äºå¡ä¸ |
| | | using (var scope = new TransactionScope(TransactionScopeOption.Required, |
| | | new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted })) |
| | | { |
| | | try |
| | | { |
| | | List<Dt_Task> tasks = new List<Dt_Task>(); |
| | | List<Dt_LocationInfo> locationInfos = _locationInfoService.Repository.QueryData( |
| | | x => stockInfos.Select(x => x.LocationCode).Contains(x.LocationCode)); |
| | | |
| | | for (int i = 0; i < stockInfos.Count; i++) |
| | | { |
| | | Dt_StockInfo stockInfo = stockInfos[i]; |
| | | |
| | | if (stockInfo != null) |
| | | { |
| | | Dt_LocationInfo? locationInfo = locationInfos.FirstOrDefault(x => x.LocationCode == stockInfo.LocationCode); |
| | | var newLocation = _locationInfoService.AssignLocation(stockInfo.LocationType); |
| | | |
| | | if (newLocation == null) |
| | | { |
| | | throw new Exception($"å¨{stockInfo.PalletCode}æ¶æ²¡æç©ºé²åºä½å¯è¿è¡ååºåç§»åºï¼è¯·æ£æ¥æåå°ç§»åºæç®±"); |
| | | } |
| | | |
| | | 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 = newLocation.LocationCode, |
| | | TaskStatus = TaskStatusEnum.New.ObjToInt(), |
| | | TaskType = taskType.ObjToInt(), |
| | | PalletType = stockInfo.PalletType, |
| | | WarehouseId = stockInfo.WarehouseId, |
| | | }; |
| | | tasks.Add(task); |
| | | } |
| | | |
| | | newLocation.LocationStatus = LocationStatusEnum.Lock.ObjToInt(); |
| | | _locationInfoService.UpdateData(newLocation); |
| | | } |
| | | } |
| | | |
| | | // æäº¤äºå¡ |
| | | scope.Complete(); |
| | | return tasks; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | // TransactionScope ä¼èªå¨åæ»äºå¡ï¼æ éæå¨ Rollback |
| | | throw new Exception(ex.Message); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | { |
| | | return await Service.TaskCancel(taskCancel); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// çç¹åºååºåº |
| | | /// </summary> |
| | | /// <param name="stockViews"></param> |
| | | /// <param name="outStation"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, HttpGet, Route("AreaOutbound"), AllowAnonymous] |
| | | public async Task<WebResponseContent> AreaOutbound([FromBody] List<StockViewDTO> stockViews) |
| | | { |
| | | return await Service.AreaOutbound(stockViews); |
| | | } |
| | | } |
| | | } |