一、前言
工厂订单及出入库业务的趋势是客户要求越来越高,客户需要快捷、方便、简单、一站式的出入库手续。因此,货物出入库管理信息系统要简化出入库手续,减轻人员作业量,提高工作效率,助力企业数字信息化转型。
之前整理过该系统的完整解决方案,有兴趣的参考文章:https://blog.csdn.net/lildkdkdkjf/article/details/117841646
二、整体架构设计
开发语言:
- Golang:Go 极其地快。其性能与 Java 或 C++相似。在我们的使用中,Go 一般比 Python 要快 30 倍。
- Vue: 轻量级框架, 大小只有几十kb, 国人开发,中文文档,不存在语言障碍,易于理解和学习。运行速度更快,相比较与react而言,同样都是操作虚拟dom,就性能而言,vue存在很大的优势。
部署方式:
- 服务器系统:基于免安装可执行程序:支持Windows、Linux,Centos,Ubuntu操作系统;
- 数据库类型:目前已支持PostgreSQL、MySQL、Oracle、Microsoft SQL Server、SQLite等,还可以定制其它类型数据库。
- 热数据缓存服务:基于Key-Value 的Redis 数据库,关键热活数据存储在Redis服务中,提高响应速率。
- 主备双活服务器:确保稳定性,如果主服务器故障,自动切换到备服务器。热数据
- 数据库备份:定时增量备份,定期全量备份。
三、编码实现 (基于篇幅及可读性考虑,此处展示部分关键代码)
1、模块截图
2、Go 关键代码
func (c *OrderController) Post() {
if c.CheckToken() < 0 {
return
}
act := c.GetString("Act")
writelog.WriteDebug("||||||||||||||||||||||||||||||-----------> %+v ", act)
ret := common.RetOK
if act == common.ActAddOrder {
OrderID := c.GetString("OrderID")
ProductID, _ := c.GetInt("ProductID")
ProductTotal, _ := c.GetInt("ProductTotal")
NumberPerBox, _ := c.GetInt("NumberPerBox")
OriOrderID := c.GetString("OriOrderID")
BoxTotal := 0
order, _ := models.GetOrderById(OrderID)
if order != nil {
ret = common.RetErrorOrderAddRepeat
c.jsonStandardResult(ret, "", order.OrderID)
return
}
var m models.Order
m.CreateTime = time.Now().Unix()
m.OrderID = OrderID
m.BoxTotal = int(BoxTotal)
m.NumberPerBox = NumberPerBox
m.ProductID = ProductID
m.ProductTotal = ProductTotal
m.OriOrderID = OriOrderID
models.AddOrder(&m)
// 添加成功id也为0
c.jsonStandardResult(ret, "", m.OrderID)
p, _ := models.GetProductByProductID(ProductID)
log := fmt.Sprintf("创建订单: 订单号[%s], 产品名称[%s], 产品总数[%d], 每箱产品数[%d]", OrderID, p.ProductBriefName, ProductTotal, NumberPerBox)
models.AddSystemLogByToken(c.GetString("Token"), common.LogType_Add, log)
return
}
if act == common.ActDelOrder {
OrderID := c.GetString("OrderID")
_, err := models.DelOrder(OrderID)
if err != nil {
ret = common.RetErrorOrderDel
c.jsonStandardResult(ret, "", 0)
return
}
// 删除Distribute
numDistribute, err := models.DelDistributeByOrderID(OrderID)
// 删除Distribute_file
_, err = models.DelDistributeFileByOrderID(OrderID)
// 删除recipient
numRecipient, err := models.DelRecipientByOrderID(OrderID)
// 删除box
numBox, err := models.DelBoxByOrderID(OrderID)
// 删除sn
numSn, err := models.DelSnByOrderID(OrderID)
c.jsonStandardResult(ret, "", 0)
log := fmt.Sprintf("删除订单[%s]: 发货申请单数[%d],收件人数[%d],箱数[%d],SN数[%d]", OrderID, numDistribute, numRecipient, numBox, numSn)
models.AddSystemLogByToken(c.GetString("Token"), common.LogType_Del, log)
return
}
if act == common.ActEditOrder {
OrderID := c.GetString("OrderID")
ProductID, _ := c.GetInt("ProductID")
ProductTotal, _ := c.GetInt("ProductTotal")
NumberPerBox, _ := c.GetInt("NumberPerBox")
BoxTotal := ProductTotal / NumberPerBox
num, err := models.EditOrder(OrderID, ProductID, ProductTotal, NumberPerBox, BoxTotal)
if err != nil {
ret = common.RetErrorOrderEdit
c.jsonStandardResult(ret, err.Error(), num)
return
}
if num == 0 {
ret = common.RetErrorNoDataChanged
c.jsonStandardResult(ret, common.GetErrMsg(ret), num)
return
} else {
ret = common.RetOK
p, _ := models.GetProductByProductID(ProductID)
log := fmt.Sprintf("编辑订单: 订单号[%s], 产品名称[%s], 产品总数[%d], 产品数/每箱[%d]", OrderID, p.ProductBriefName, ProductTotal, NumberPerBox)
models.AddSystemLogByToken(c.GetString("Token"), common.LogType_Update, log)
}
c.jsonStandardResult(ret, "", num)
return
}
if act == common.ActGetOrderList {
StartTime, _ := c.GetInt64("StartTime")
EndTime, _ := c.GetInt64("EndTime")
OrderID := c.GetString("OrderID")
ProductID, _ := c.GetInt64("ProductID")
StatusBox, _ := c.GetInt("StatusBox")
StatusPrepare, _ := c.GetInt("StatusPrepare")
StatusQc, _ := c.GetInt("StatusQc")
Page, _ := c.GetInt("Page")
RowNum, _ := c.GetInt("RowNum")
recordcount, _, r, err, sql := models.GetOrderList(StartTime, EndTime, OrderID, ProductID, StatusBox, StatusPrepare, StatusQc, Page, RowNum)
if err != nil {
ret = common.RetErrorGetOrderList
c.jsonStandardResult(ret, common.GetErrMsg(ret), sql)
return
}
fmt.Println(fmt.Sprintf("%+v", r))
type Order2 struct {
models.Order
RecipientSnTotal int
}
var L []Order2
var tmp Order2
for _, v := range r {
tmp.BoxTotal = v.BoxTotal
tmp.NumberPerBox = v.NumberPerBox
tmp.ProductTotal = v.ProductTotal
tmp.SnTotal = v.SnTotal
tmp.OrderID = v.OrderID
tmp.StatusBox = v.StatusBox
tmp.StatusPrepare = v.StatusPrepare
tmp.StatusQc = v.StatusQc
tmp.CreateTime = v.CreateTime
tmp.ProductID = v.ProductID
tmp.RecipientTotal = v.RecipientTotal
tmp.OriOrderID = v.OriOrderID
tmp.RecipientSnTotal,_ = models.SumRecipientSnTotalByOrderID(v.OrderID)
L = append(L, tmp)
}
c.Data["json"] = struct {
Ret int
Msg string
Recordcount int64
Data interface{}
}{
Ret: common.RetOK,
Msg: common.GetErrMsg(common.RetOK),
Recordcount: recordcount,
Data: L,
}
c.ServeJSON()
return
}
c.jsonStandardResult(common.RetErrorAct, "act错误", 52)
return
}
3、vue代码
<template>
<div class="page-container">
<div class="search-wrapper">
<div class="block">
<span class="label">开始时间</span>
<el-date-picker
v-model="searchForm.startTime"
type="date"
:clearable="true"
format="yyyy-MM-dd 00:00:00"
placeholder="选择日期">
</el-date-picker>
</div>
<div class="block">
<span class="label">结束时间</span>
<el-date-picker
v-model="searchForm.endTime"
type="date"
:clearable="true"
format="yyyy-MM-dd 23:59:59"
placeholder="选择日期">
</el-date-picker>
</div>
<div class="block">
<div class="label">订单号</div>
<el-input v-model="searchForm.orderId"></el-input>
</div>
<div class="block">
<div class="label" v-if="$route.path=='/choice'">仓库备货状态</div>
<div class="label" v-else>品管状态</div>
<el-select v-model="searchForm.status" placeholder="请选择">
<el-option
v-for="item in status"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</div>
<div class="operates">
<el-button type="primary" @click="searchClick">查询</el-button>
<el-button type="primary" @click="resetClick">重置</el-button>
</div>
</div>
<el-table
:data="tableData"
style="width:100%">
<el-table-column
prop="OrderID"
label="订单号"
>
</el-table-column>
<el-table-column
prop="RecipientCompany"
label="客户名称"
>
</el-table-column>
<el-table-column
prop="ExpressID"
label="快运单号">
</el-table-column>
<el-table-column
prop="RecipientName"
label="收件人"
>
</el-table-column>
<el-table-column
prop="RecipientPhone"
label="收件人电话"
>
</el-table-column>
<el-table-column
prop="SnBox"
label="发货SN号段及箱号"
width="240">
<template slot-scope="scope" v-if="scope.row.SnBox!=''">
<div v-for="(item,index) in scope.row.SnBox" :key="index">
<div>{{item.SnStart}}至{{item.SnEnd}}</div>
<div>{{item.BoxStart}}~{{item.BoxEnd}}号箱</div>
</div>
</template>
</el-table-column>
<el-table-column
prop="CreateTime"
label="创建时间"
>
</el-table-column>
<el-table-column
prop="StatusPrepare"
:label="path=='/choice'?'备货状态':'品管状态'"
>
<template slot-scope="scope">
<div v-if="scope.row.StatusPrepare==0">无</div>
<div v-if="scope.row.StatusPrepare==1">正确</div>
<div v-if="scope.row.StatusPrepare==2">异常</div>
<div v-if="scope.row.StatusPrepare==3">进行中</div>
</template>
</el-table-column>
<el-table-column
prop="address"
label="操作">
<template slot-scope="scope">
<template v-if="path=='/choice'">
<a @click="confirmTypeByEyes(scope.row)">目测备货</a>
<a @click="gotoPrepare(scope.row)">扫码备货</a>
</template>
<template v-if="path=='/qc'">
<a @click="confirmTypeByEyes(scope.row)">目测品管</a>
<a @click="gotoPrepare(scope.row)">扫码品管</a>
</template>
</template>
</el-table-column>
</el-table>
<el-pagination
@current-change="handleCurrentChange"
:current-page.sync="pageData.Page"
:page-size="pageData.RowNum"
layout="total, prev, pager, next"
:total="RowNum">
</el-pagination>
</div>
</template>
<script>
import {RECIPIENT_API_PATH} from "../../service/api"
let StatusDefinite = [{
id:0,
name:"全部"
},{
id:1,
name:"正确"
},{
id:2,
name:"异常"
},{
id:3,
name:"进行中"
}]
export default{
data(){
return{
status:StatusDefinite,
searchForm:{
orderId:"",
status:0,
startTime:new Date(new Date().toLocaleDateString()),
endTime:new Date(new Date().toLocaleDateString()),
},
RowNum:0,
pageData:{
Page:1,
RowNum:20
},
tableData:[],
path:""
}
},
created(){
this.path = this.$route.path
this.getRecipientList()
},
watch: {
$route: {
handler: function(val, oldVal){
this.getRecipientList()
this.path = this.$route.path
this.resetClick()
},
// 深度观察监听
deep: true
}
},
methods:{
handleCurrentChange(){
this.getRecipientList()
},
getRecipientList(){
let formData = new FormData()
formData.append("Token",sessionStorage.getItem("token"))
formData.append("Act","GetRecipientList")
let startTime = this.moment(this.searchForm.startTime).format("YYYY-MM-DD 00:00:00")
let endTime = this.moment(this.searchForm.endTime).format("YYYY-MM-DD 23:59:59")
formData.append("StartTime",new Date(startTime).getTime()/1000)
formData.append("EndTime",new Date(endTime).getTime()/1000)
formData.append("Page",this.pageData.Page-1)
formData.append("RowNum",this.pageData.RowNum)
formData.append("OrderID",this.searchForm.orderId)
if(this.$route.path == '/choice'){
formData.append("StatusPrepare",this.searchForm.status)
}else{
formData.append("StatusQc",this.searchForm.status)
}
this.$axios.post(RECIPIENT_API_PATH,formData).then(res=>{
if(res.data.Ret == 0){
res.data.Data = res.data.Data?res.data.Data:[]
res.data.Data.map(v=>{
v.SnBox = v.SnBox&&v.SnBox!=""?JSON.parse(v.SnBox):""
v.CreateTime = this.moment(v.CreateTime*1000).format("YYYY-MM-DD HH:mm:ss")
})
this.tableData = res.data.Data
this.RowNum = res.data.Recordcount
}
})
},
resetClick(){
this.searchForm = {
boxNum:"",
startTime:new Date(new Date().toLocaleDateString()),
endTime:new Date(new Date().toLocaleDateString()),
status:0
}
},
searchClick(){
this.getRecipientList()
},
confirmTypeByEyes(item){
let tip = this.path == '/choice'?"确认备货?":"确认品管?"
this.$confirm(tip, '', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
let formData = new FormData()
formData.append("Token",sessionStorage.getItem("token"))
if(this.path=='/choice'){
formData.append("Act","SetStatusPrepareByExpressID")
}else{
formData.append("Act","SetStatusQcByExpressID")
}
formData.append("ExpressID",item.ExpressID)
formData.append("ConfirmType",1)
this.$axios.post(RECIPIENT_API_PATH,formData).then(res=>{
if(res.data.Ret == 0){
if(this.path=='/choice'){
this.$message({
message:"确认目测备货",
type:"success",
duration:3000
});
}else{
this.$message({
message:"确认目测品管",
type:"success",
duration:3000
});
}
this.getRecipientList()
}else{
this.$message({
message:res.data.Msg,
type:"error",
duration:3000
});
}
})
})
},
gotoPrepare(item){
let param = this.path == '/choice'?'choice':'qc'
this.$router.push({
name:"Prepare",
query:{
type:param,
}
})
}
}
}
</script>
<style scoped>
.search-wrapper{
display:flex;
justy-content:flex-start;
flex-wrap:wrap;
}
td a{
margin:10px 0;
display:block;
}
</style>
四、结语
本次分享结束,欢迎来撩!
完整方案介绍:https://blog.csdn.net/lildkdkdkjf/article/details/117841646
系统演示网址:http://47.113.115.218:81 演示密码:123456
微信:6550523