pda上设计数据更新的功能 增加修改记录

This commit is contained in:
hehaibing-1996
2025-02-24 16:32:09 +08:00
parent dd25815c03
commit e29e3737aa
6 changed files with 325 additions and 51 deletions

View File

@ -2,6 +2,9 @@
<view class="bg-image">
<uni-popup ref="popup" type="dialog">
<view class="popup-content">
<view>
<button style="background-color: firebrick;margin-bottom: 10rpx;color: white;" @click="deleteData">删除数据</button>
</view>
<view class="info-item">
<label>物料编码</label>
<text>{{fixedInfo.matCode}}</text>
@ -20,7 +23,7 @@
</view>
<view class="button-group">
<button @click="hidePopup">取消</button>
<button @click="saveData">保存</button>
<button @click="saveData">修改</button>
</view>
</view>
</uni-popup>
@ -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() {

View File

@ -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, {

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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,6 +325,9 @@ namespace WCS.WebApi.Controllers
}
#endregion
try
{
DbHelp.db.BeginTran();
//校验合格 进行保存
var matDetailCurrentInfo = new MatDetailCurrentInfo()
{
@ -342,8 +346,31 @@ namespace WCS.WebApi.Controllers
ModifyUser = request.UserName,
};
DbHelp.db.Insertable(matDetailCurrentInfo).ExecuteCommand();
//新增数据修改记录表
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 = 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,
@ -352,6 +379,12 @@ namespace WCS.WebApi.Controllers
};
}
catch (Exception ex)
{
DbHelp.db.RollbackTran();
throw ex;
}
}
catch (Exception ex)
{
return new ResponseCommon()
{

View File

@ -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<Object>
{
Code = 201,
@ -172,6 +196,7 @@ namespace WCS.WebApi.Controllers
}
else
{
DbHelp.db.CommitTran();
return new ResponseCommon<Object>
{
Code = 200,
@ -182,6 +207,7 @@ namespace WCS.WebApi.Controllers
}
catch (Exception ex)
{
DbHelp.db.RollbackTran();
var response = new ResponseCommon<Object>
{
Code = 300,
@ -282,10 +308,54 @@ namespace WCS.WebApi.Controllers
var matCurrentInfos = await DbHelp.db.Queryable<MatDetailCurrentInfo>()
.Where(t => t.ShelfId == shelfInfo.Id)
.ToListAsync();
//To Do库存更新记录
//库存更新记录
//全部删除
////全部删除
//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