diff --git a/PDA/PDA/pages/queryBindList/queryBindList.vue b/PDA/PDA/pages/queryBindList/queryBindList.vue index fb5e58a..8eed02d 100644 --- a/PDA/PDA/pages/queryBindList/queryBindList.vue +++ b/PDA/PDA/pages/queryBindList/queryBindList.vue @@ -2,6 +2,9 @@ + + + {{fixedInfo.matCode}} @@ -17,10 +20,10 @@ - + - + @@ -237,13 +240,77 @@ }); }; + const deleteData = () => { + console.log('123'); + var serverIPAndPort = getServerIPAndPort(); + //调用接口进行数量的修改 + uni.request({ + url: 'http://' + serverIPAndPort + + '/matDetailCurrenInfo/deleteMatDetailCurrentInfo', // 请求的接口地址 + method: 'POST', // 设置请求方式为 POST + data: { + "needDeleteIds":[fixedInfo.infoId], + "userName": getConfig('userName', 'admin'), + "deviceType": "PDA" + }, + header: { + 'Content-Type': 'application/json', // 如果需要以JSON格式发送数据 + }, + success: (res) => { + // 请求成功的回调函数 + if (res.statusCode === 200) { + //接口返回数据为200 表示获取成功! + if (res.data.code == 200) { + hidePopup(); + uni.showToast({ + title: '删除成功!', + icon: 'none', + duration: 2000 + }); + + proxy.queryMatList(); + } else { + uni.showToast({ + title: '删除失败:' + res.data.message, + icon: 'none', + duration: 2500 + }); + } + + } else { + uni.showToast({ + title: '服务器返回错误状态码' + res.statusCode, + icon: 'none', + duration: 2500 + }); + } + }, + fail: (err) => { + // 请求失败的回调函数 + uni.showToast({ + title: '请求失败' + err, + icon: 'none', + duration: 2500 + }); + + this.clear(); + }, + complete: (event) => { + // 请求完成的回调函数(无论成功或失败都会调用) + + } + }); + }; + + return { fixedInfo, popup, inputValue, showPopup, hidePopup, - saveData + saveData, + deleteData, }; }, data() { diff --git a/PDA/PDA/unpackage/dist/dev/app-plus/app-service.js b/PDA/PDA/unpackage/dist/dev/app-plus/app-service.js index 8ec5370..03e951a 100644 --- a/PDA/PDA/unpackage/dist/dev/app-plus/app-service.js +++ b/PDA/PDA/unpackage/dist/dev/app-plus/app-service.js @@ -2593,13 +2593,68 @@ if (uni.restoreGlobal) { } }); }; + const deleteData = () => { + formatAppLog("log", "at pages/queryBindList/queryBindList.vue:244", "123"); + var serverIPAndPort = getServerIPAndPort(); + uni.request({ + url: "http://" + serverIPAndPort + "/matDetailCurrenInfo/deleteMatDetailCurrentInfo", + // 请求的接口地址 + method: "POST", + // 设置请求方式为 POST + data: { + "needDeleteIds": [fixedInfo.infoId], + "userName": getConfig("userName", "admin"), + "deviceType": "PDA" + }, + header: { + "Content-Type": "application/json" + // 如果需要以JSON格式发送数据 + }, + success: (res) => { + if (res.statusCode === 200) { + if (res.data.code == 200) { + hidePopup(); + uni.showToast({ + title: "删除成功!", + icon: "none", + duration: 2e3 + }); + proxy.queryMatList(); + } else { + uni.showToast({ + title: "删除失败:" + res.data.message, + icon: "none", + duration: 2500 + }); + } + } else { + uni.showToast({ + title: "服务器返回错误状态码" + res.statusCode, + icon: "none", + duration: 2500 + }); + } + }, + fail: (err) => { + uni.showToast({ + title: "请求失败" + err, + icon: "none", + duration: 2500 + }); + this.clear(); + }, + complete: (event) => { + } + }); + }; return { fixedInfo, popup, inputValue, showPopup, hidePopup, - saveData + saveData, + deleteData }; }, data() { @@ -2626,10 +2681,10 @@ if (uni.restoreGlobal) { this.userName = getConfig("userName", "admin"); const self = this; recive(function(res) { - formatAppLog("log", "at pages/queryBindList/queryBindList.vue:274", "Success:" + res.data); + formatAppLog("log", "at pages/queryBindList/queryBindList.vue:341", "Success:" + res.data); self.analysisScanCode(res.data); }, function(err) { - formatAppLog("log", "at pages/queryBindList/queryBindList.vue:277", "Error:", JSON.stringify(err)); + formatAppLog("log", "at pages/queryBindList/queryBindList.vue:344", "Error:", JSON.stringify(err)); }); }, methods: { @@ -2698,7 +2753,7 @@ if (uni.restoreGlobal) { this.clear(); }, complete: (event) => { - formatAppLog("log", "at pages/queryBindList/queryBindList.vue:369", "请求完成", event); + formatAppLog("log", "at pages/queryBindList/queryBindList.vue:436", "请求完成", event); } }); }, @@ -2773,7 +2828,7 @@ if (uni.restoreGlobal) { this.clear(); }, complete: (event) => { - formatAppLog("log", "at pages/queryBindList/queryBindList.vue:454", "请求完成", event); + formatAppLog("log", "at pages/queryBindList/queryBindList.vue:521", "请求完成", event); } }); }, @@ -2817,6 +2872,12 @@ if (uni.restoreGlobal) { { default: vue.withCtx(() => [ vue.createElementVNode("view", { class: "popup-content" }, [ + vue.createElementVNode("view", null, [ + vue.createElementVNode("button", { + style: { "background-color": "firebrick", "margin-bottom": "10rpx", "color": "white" }, + onClick: _cache[0] || (_cache[0] = (...args) => $setup.deleteData && $setup.deleteData(...args)) + }, "删除数据") + ]), vue.createElementVNode("view", { class: "info-item" }, [ vue.createElementVNode("label", null, "物料编码:"), vue.createElementVNode( @@ -2856,7 +2917,7 @@ if (uni.restoreGlobal) { "input", { ref: "inputRef", - "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => $setup.inputValue = $event), + "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => $setup.inputValue = $event), type: "number", placeholder: "输入数量" }, @@ -2874,11 +2935,11 @@ if (uni.restoreGlobal) { ]), vue.createElementVNode("view", { class: "button-group" }, [ vue.createElementVNode("button", { - onClick: _cache[1] || (_cache[1] = (...args) => $setup.hidePopup && $setup.hidePopup(...args)) + onClick: _cache[2] || (_cache[2] = (...args) => $setup.hidePopup && $setup.hidePopup(...args)) }, "取消"), vue.createElementVNode("button", { - onClick: _cache[2] || (_cache[2] = (...args) => $setup.saveData && $setup.saveData(...args)) - }, "保存") + onClick: _cache[3] || (_cache[3] = (...args) => $setup.saveData && $setup.saveData(...args)) + }, "修改") ]) ]) ]), @@ -2912,8 +2973,8 @@ if (uni.restoreGlobal) { class: "uni-input", style: { "font-size": "50rpx", "padding": "10rpx" }, placeholder: $data.placeholderText, - "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => $data.matCodeCondition = $event), - onBlur: _cache[4] || (_cache[4] = (...args) => $options.queryMatList && $options.queryMatList(...args)) + "onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => $data.matCodeCondition = $event), + onBlur: _cache[5] || (_cache[5] = (...args) => $options.queryMatList && $options.queryMatList(...args)) }, null, 40, ["placeholder"]), [ [vue.vModelText, $data.matCodeCondition] ]) @@ -2921,7 +2982,7 @@ if (uni.restoreGlobal) { vue.createElementVNode("view", { style: { "flex": "3" } }), vue.createElementVNode("view", { style: { "flex": "30" } }, [ vue.createElementVNode("button", { - onClick: _cache[5] || (_cache[5] = (...args) => $options.queryMatList && $options.queryMatList(...args)) + onClick: _cache[6] || (_cache[6] = (...args) => $options.queryMatList && $options.queryMatList(...args)) }, "查询") ]) ]) @@ -2967,8 +3028,8 @@ if (uni.restoreGlobal) { vue.renderList($data.cardData, (item, index) => { return vue.openBlock(), vue.createElementBlock("view", { key: index, - onTouchstart: _cache[6] || (_cache[6] = (...args) => $options.cardTouchStart && $options.cardTouchStart(...args)), - onTouchmove: _cache[7] || (_cache[7] = (...args) => $options.cardTouchMove && $options.cardTouchMove(...args)), + onTouchstart: _cache[7] || (_cache[7] = (...args) => $options.cardTouchStart && $options.cardTouchStart(...args)), + onTouchmove: _cache[8] || (_cache[8] = (...args) => $options.cardTouchMove && $options.cardTouchMove(...args)), onLongpress: ($event) => $options.longpress(item) }, [ vue.createVNode(_component_Card, { diff --git a/WCS.BLL/Services/Service/MatDetailCurrentInfoService.cs b/WCS.BLL/Services/Service/MatDetailCurrentInfoService.cs index 7afe0fc..b71958a 100644 --- a/WCS.BLL/Services/Service/MatDetailCurrentInfoService.cs +++ b/WCS.BLL/Services/Service/MatDetailCurrentInfoService.cs @@ -135,7 +135,7 @@ namespace WCS.BLL.Services.Service ModifyTime = DateTime.Now, ModifyUser = request.UserName, RecordType = RecordTypeEnum.修改, - FunctionType = FunctionTypeEnum.客户端货架存量, + FunctionType = request.DeviceType == "PDA" ? FunctionTypeEnum.PDA绑定查询 : FunctionTypeEnum.客户端货架存量, }; await DbHelp.db.Insertable(historyInfo).ExecuteCommandAsync(); //更新货架存量数据 @@ -210,7 +210,7 @@ namespace WCS.BLL.Services.Service ModifyTime = DateTime.Now, ModifyUser = request.UserName, RecordType = RecordTypeEnum.删除, - FunctionType = FunctionTypeEnum.客户端货架存量, + FunctionType = request.DeviceType == "PDA" ? FunctionTypeEnum.PDA绑定查询 : FunctionTypeEnum.客户端货架存量, }; await DbHelp.db.Insertable(historyInfo).ExecuteCommandAsync(); } diff --git a/WCS.BLL/Services/Service/StockTakingService.cs b/WCS.BLL/Services/Service/StockTakingService.cs index 392ee0e..12546c3 100644 --- a/WCS.BLL/Services/Service/StockTakingService.cs +++ b/WCS.BLL/Services/Service/StockTakingService.cs @@ -8,6 +8,7 @@ using WCS.Model; using WCS.Model.ApiModel.InOutRecord; using WCS.Model.ApiModel.MatBaseInfo; using WCS.Model.ApiModel.MatDetailCurrentInfo; +using WCS.Model.ApiModel.MatDetailHistoryInfo; using WCS.Model.ApiModel.Stocktaking; using WCS.Model.WebSocketModel; @@ -1397,18 +1398,61 @@ namespace WCS.BLL.Services.Service { continue; } - if (stocktakingInfo.StocktakingQty != 0) + if (stocktakingInfo.StocktakingQty != 0 && stocktakingInfo.StocktakingQty != matCurrentInfo.MatQty) { - //TO DO 形成数据更新记录 + //库存修改记录 + var historyInfo = new MatDetailHistoryInfo() + { + ShlefId = matCurrentInfo.ShelfId, + ShelfType = matCurrentInfo.ShelfType, + ShelfCode = matCurrentInfo.ShelfCode, + + MatCode = matCurrentInfo.MatCode, + MatName = matCurrentInfo.MatName, + MatSpec = matCurrentInfo.MatSpec, + MatCustomer = matCurrentInfo?.MatCustomer, + MatSupplier = matCurrentInfo?.MatSupplier, + + BeforeQty = matCurrentInfo.MatQty, + AfterQty = stocktakingInfo.StocktakingQty, + + ModifyTime = DateTime.Now, + ModifyUser = request.UserName, + RecordType = RecordTypeEnum.修改, + FunctionType = FunctionTypeEnum.库存盘点, + }; + DbHelp.db.Insertable(historyInfo).ExecuteCommand(); + matCurrentInfo.MatQty = stocktakingInfo.StocktakingQty; matCurrentInfo.ModifyUser = request.UserName; matCurrentInfo.ModifyTime = DateTime.Now; DbHelp.db.Updateable(matCurrentInfo).ExecuteCommand(); } - else + else if(stocktakingInfo.StocktakingQty == 0) { - //TO DO 形成数据更新记录 + //库存修改记录 + var historyInfo = new MatDetailHistoryInfo() + { + ShlefId = matCurrentInfo.ShelfId, + ShelfType = matCurrentInfo.ShelfType, + ShelfCode = matCurrentInfo.ShelfCode, + + MatCode = matCurrentInfo.MatCode, + MatName = matCurrentInfo.MatName, + MatSpec = matCurrentInfo.MatSpec, + MatCustomer = matCurrentInfo?.MatCustomer, + MatSupplier = matCurrentInfo?.MatSupplier, + + BeforeQty = matCurrentInfo.MatQty, + AfterQty = 0, + + ModifyTime = DateTime.Now, + ModifyUser = request.UserName, + RecordType = RecordTypeEnum.删除, + FunctionType = FunctionTypeEnum.库存盘点, + }; + DbHelp.db.Insertable(historyInfo).ExecuteCommand(); DbHelp.db.Deleteable(matCurrentInfo).ExecuteCommand(); } diff --git a/WCS.WebApi/Controllers/PDAMatBindController.cs b/WCS.WebApi/Controllers/PDAMatBindController.cs index b12a4b9..ce532ec 100644 --- a/WCS.WebApi/Controllers/PDAMatBindController.cs +++ b/WCS.WebApi/Controllers/PDAMatBindController.cs @@ -6,6 +6,7 @@ using WCS.DAL.Db; using WCS.DAL.DbModels; using WCS.Model; using WCS.Model.ApiModel; +using WCS.Model.ApiModel.MatDetailHistoryInfo; using WCS.Model.ApiModel.PDAMatBind; using WCS.Model.ApiModel.User; using WCS.Model.WebSocketModel; @@ -324,32 +325,64 @@ namespace WCS.WebApi.Controllers } #endregion - //校验合格 进行保存 - var matDetailCurrentInfo = new MatDetailCurrentInfo() + try { - ShelfId = shelf.Id, - ShelfCode = shelf.ShelfCode, - ShelfType = shelf.ShelfTypeName, - //ShelfArea = shelf.ShelfArea, + DbHelp.db.BeginTran(); + //校验合格 进行保存 + var matDetailCurrentInfo = new MatDetailCurrentInfo() + { + ShelfId = shelf.Id, + ShelfCode = shelf.ShelfCode, + ShelfType = shelf.ShelfTypeName, + //ShelfArea = shelf.ShelfArea, - MatCode = matBaseInfo.MatCode, - MatName = matBaseInfo.MatName, - MatSupplier = matBaseInfo.MatSupplier, - MatCustomer = matBaseInfo.MatCustomer, - MatSpec = matBaseInfo.MatSpec, - MatUnit = matBaseInfo.MatUnit, - MatQty = request.Qty, + MatCode = matBaseInfo.MatCode, + MatName = matBaseInfo.MatName, + MatSupplier = matBaseInfo.MatSupplier, + MatCustomer = matBaseInfo.MatCustomer, + MatSpec = matBaseInfo.MatSpec, + MatUnit = matBaseInfo.MatUnit, + MatQty = request.Qty, - ModifyUser = request.UserName, - }; - DbHelp.db.Insertable(matDetailCurrentInfo).ExecuteCommand(); + ModifyUser = request.UserName, + }; + //新增数据修改记录表 + var historyInfo = new MatDetailHistoryInfo() + { + ShlefId = matDetailCurrentInfo.ShelfId, + ShelfType = matDetailCurrentInfo.ShelfType, + ShelfCode = matDetailCurrentInfo.ShelfCode, - return new ResponseCommon() + MatCode = matDetailCurrentInfo.MatCode, + MatName = matDetailCurrentInfo.MatName, + MatSpec = matDetailCurrentInfo.MatSpec, + MatCustomer = matDetailCurrentInfo?.MatCustomer, + MatSupplier = matDetailCurrentInfo?.MatSupplier, + + BeforeQty = 0, + AfterQty = matDetailCurrentInfo.MatQty, + + ModifyTime = DateTime.Now, + ModifyUser = request.UserName, + RecordType = RecordTypeEnum.新增, + FunctionType = FunctionTypeEnum.PDA物料绑定, + }; + DbHelp.db.Insertable(matDetailCurrentInfo).ExecuteCommand(); + DbHelp.db.Insertable(historyInfo).ExecuteCommand(); + + DbHelp.db.CommitTran(); + return new ResponseCommon() + { + Code = 200, + Message = "success", + Data = null, + }; + } + catch (Exception ex) { - Code = 200, - Message = "success", - Data = null, - }; + DbHelp.db.RollbackTran(); + throw ex; + } } catch (Exception ex) { diff --git a/WCS.WebApi/Controllers/PDAProductionLineCallOutController.cs b/WCS.WebApi/Controllers/PDAProductionLineCallOutController.cs index d24b13a..22f6c19 100644 --- a/WCS.WebApi/Controllers/PDAProductionLineCallOutController.cs +++ b/WCS.WebApi/Controllers/PDAProductionLineCallOutController.cs @@ -8,6 +8,7 @@ using WCS.Model; using WCS.Model.ApiModel.LocationInfo; using WCS.Model.ApiModel.MatBaseInfo; using WCS.Model.ApiModel.MatDetailCurrentInfo; +using WCS.Model.ApiModel.MatDetailHistoryInfo; using WCS.Model.ApiModel.PDAProductionLineCallIn; using WCS.Model.ApiModel.PDAProductionLineCallOut; using WCS.Model.ApiModel.PDAShelfLocationBindUnbind; @@ -155,14 +156,37 @@ namespace WCS.WebApi.Controllers Data = null }; } + DbHelp.db.BeginTran(); + //新增数据修改记录表 + var historyInfo = new MatDetailHistoryInfo() + { + ShlefId = matDetailCurrentInfo.ShelfId, + ShelfType = matDetailCurrentInfo.ShelfType, + ShelfCode = matDetailCurrentInfo.ShelfCode, + MatCode = matDetailCurrentInfo.MatCode, + MatName = matDetailCurrentInfo.MatName, + MatSpec = matDetailCurrentInfo.MatSpec, + MatCustomer = matDetailCurrentInfo?.MatCustomer, + MatSupplier = matDetailCurrentInfo?.MatSupplier, + + BeforeQty = matDetailCurrentInfo.MatQty, + AfterQty = request.MatQty, + + ModifyTime = DateTime.Now, + ModifyUser = request.UserName, + RecordType = RecordTypeEnum.修改, + FunctionType = FunctionTypeEnum.PDA货架送回, + }; + await DbHelp.db.Insertable(historyInfo).ExecuteCommandAsync(); + //更新货架存量数据 matDetailCurrentInfo.MatQty = request.MatQty; matDetailCurrentInfo.ModifyUser = request.UserName; matDetailCurrentInfo.ModifyTime = DateTime.Now; - var rowNum = await DbHelp.db.Updateable(matDetailCurrentInfo).ExecuteCommandAsync(); if (rowNum == 0) { + DbHelp.db.RollbackTran(); return new ResponseCommon { Code = 201, @@ -172,6 +196,7 @@ namespace WCS.WebApi.Controllers } else { + DbHelp.db.CommitTran(); return new ResponseCommon { Code = 200, @@ -182,6 +207,7 @@ namespace WCS.WebApi.Controllers } catch (Exception ex) { + DbHelp.db.RollbackTran(); var response = new ResponseCommon { Code = 300, @@ -282,10 +308,54 @@ namespace WCS.WebApi.Controllers var matCurrentInfos = await DbHelp.db.Queryable() .Where(t => t.ShelfId == shelfInfo.Id) .ToListAsync(); - //To Do库存更新记录 + //库存更新记录 - //全部删除 - DbHelp.db.Deleteable(matCurrentInfos).ExecuteCommand(); + ////全部删除 + //DbHelp.db.Deleteable(matCurrentInfos).ExecuteCommand(); + + //执行删除 + try + { + DbHelp.db.BeginTran(); + //新增数据删除记录 + foreach (var matDetailCurrentInfo in matCurrentInfos) + { + var historyInfo = new MatDetailHistoryInfo() + { + ShlefId = matDetailCurrentInfo.ShelfId, + ShelfType = matDetailCurrentInfo.ShelfType, + ShelfCode = matDetailCurrentInfo.ShelfCode, + + MatCode = matDetailCurrentInfo.MatCode, + MatName = matDetailCurrentInfo.MatName, + MatSpec = matDetailCurrentInfo.MatSpec, + MatCustomer = matDetailCurrentInfo?.MatCustomer, + MatSupplier = matDetailCurrentInfo?.MatSupplier, + + BeforeQty = matDetailCurrentInfo.MatQty, + AfterQty = 0,//删除数据 为0 + + ModifyTime = DateTime.Now, + ModifyUser = request.UserName, + RecordType = RecordTypeEnum.清空, + FunctionType = FunctionTypeEnum.PDA货架送回, + }; + await DbHelp.db.Insertable(historyInfo).ExecuteCommandAsync(); + } + DbHelp.db.Deleteable(matCurrentInfos).ExecuteCommand(); + DbHelp.db.CommitTran(); + } + catch (Exception ex) + { + DbHelp.db.RollbackTran(); + var response = new ResponseCommon + { + Code = 300, + Message = $"操作失败:{ex.Message}", + Data = null + }; + return response; + } } //如果不是非空货架 那么就清除数量为0的库存 else @@ -294,9 +364,8 @@ namespace WCS.WebApi.Controllers .Where(t => t.ShelfId == shelfInfo.Id) .Where(t => t.MatQty == 0) .ToListAsync(); - //数量为0的不用更新修改记录 修改数据时更新 - - //全部删除 + //库存更新记录 + //全部删除 删除数量为0的 DbHelp.db.Deleteable(matCurrentInfos).ExecuteCommand(); } #endregion