#
Junjie
2024-01-03 63db319f978f21dde1c7d9150244b2dca44f0a6a
#
2个文件已添加
3个文件已修改
517 ■■■■■ 已修改文件
zy-asrs-openapi/src/main/java/com/zy/asrs/openapi/controller/ApiController.java 22 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-openapi/src/main/webapp/views/generatePakIn.html 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-openapi/src/main/webapp/views/getOrderType.html 219 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-openapi/src/main/webapp/views/index.html 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-openapi/src/main/webapp/views/md/getOrderType.md 274 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-openapi/src/main/java/com/zy/asrs/openapi/controller/ApiController.java
@@ -7,6 +7,8 @@
import com.zy.asrs.common.openapi.entity.param.GenerateOrderPakInParam;
import com.zy.asrs.common.openapi.service.HostKeyService;
import com.zy.asrs.common.web.BaseController;
import com.zy.asrs.common.wms.entity.DocType;
import com.zy.asrs.common.wms.service.DocTypeService;
import com.zy.asrs.framework.common.BaseRes;
import com.zy.asrs.framework.common.Cools;
import com.zy.asrs.framework.common.R;
@@ -16,6 +18,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
@Slf4j
@@ -25,11 +28,13 @@
    @Autowired
    private HostKeyService hostKeyService;
    @Autowired
    private DocTypeService docTypeService;
    @PostMapping("/generateOrderPakIn")
    public synchronized R pakinOrderCreate(@RequestHeader(required = false) String appkey,
    public synchronized R generateOrderPakIn(@RequestHeader(required = false) String appkey,
                                           @RequestBody GenerateOrderPakInParam param) {
        auth(appkey, param);
        auth(appkey, param, true);
        if (Cools.isEmpty(param)) {
            return R.parse(BaseRes.PARAM);
        }
@@ -46,7 +51,14 @@
        return R.ok();
    }
    private void auth(String appkey, Object obj) {
    @PostMapping("/getOrderType")
    public synchronized R getOrderType(@RequestHeader(required = false) String appkey) {
        auth(appkey, null, false);
        List<DocType> list = docTypeService.list();
        return R.ok().add(list);
    }
    private HostKey auth(String appkey, Object obj, boolean signCheck) {
        if (Cools.isEmpty(appkey)) {
            throw new CoolException("认证失败,请确认appKey无误!");
        }
@@ -56,7 +68,7 @@
            throw new CoolException("认证失败,请确认appKey无误!");
        }
        if (hostKey.getSignStatus() == 1) {
        if (hostKey.getSignStatus() == 1 && signCheck) {
            //需要进行签名校验
            //创建自然排序map
            JSONObject param = new JSONObject(true);
@@ -72,6 +84,8 @@
                throw new CoolException("签名校验失败");
            }
        }
        return hostKey;
    }
}
zy-asrs-openapi/src/main/webapp/views/generatePakIn.html
@@ -22,6 +22,7 @@
            <div><el-button type="text" @click="switchPage('reportCompleted.html')">库存上报</el-button></div>
            <div><el-button type="text" @click="switchPage('reportApiManage.html')">上报API管理</el-button></div>
            <el-divider></el-divider>
            <div><el-button type="text" @click="switchPage('getOrderType.html')">获取订单类型</el-button></div>
            <div><el-button type="text" @click="switchPage('generatePakIn.html')">生成入库订单</el-button></div>
            <el-divider></el-divider>
            <div><el-button type="text" @click="keyList()">密钥管理</el-button></div>
zy-asrs-openapi/src/main/webapp/views/getOrderType.html
New file
@@ -0,0 +1,219 @@
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>API开放平台 - 获取订单类型</title>
    <link rel="stylesheet" href="../static/css/element.css">
    <link rel="stylesheet" href="../static/css/common.css">
    <script type="text/javascript" src="../static/js/jquery/jquery-3.3.1.min.js"></script>
    <script type="text/javascript" src="../static/js/vue.min.js"></script>
    <script type="text/javascript" src="../static/js/showdown.min.js"></script>
    <script type="text/javascript" src="../static/js/common.js"></script>
    <script type="text/javascript" src="../static/js/element.js"></script>
</head>
<body>
    <div id="app">
        <div id="content"></div>
        <div class="slider">
            <div><el-button type="text" @click="switchPage('index.html')">规范说明</el-button></div>
            <el-divider></el-divider>
            <div><el-button type="text" @click="switchPage('reportCompleted.html')">任务完成上报</el-button></div>
            <div><el-button type="text" @click="switchPage('reportCompleted.html')">任务取消上报</el-button></div>
            <div><el-button type="text" @click="switchPage('reportCompleted.html')">库存上报</el-button></div>
            <div><el-button type="text" @click="switchPage('reportApiManage.html')">上报API管理</el-button></div>
            <el-divider></el-divider>
            <div><el-button type="text" @click="switchPage('getOrderType.html')">获取订单类型</el-button></div>
            <div><el-button type="text" @click="switchPage('generatePakIn.html')">生成入库订单</el-button></div>
            <el-divider></el-divider>
            <div><el-button type="text" @click="keyList()">密钥管理</el-button></div>
        </div>
        <el-dialog title="密钥管理" :visible.sync="keyTableVisible">
            <el-table :data="keyTableData" v-loading="loading">
                <el-table-column property="hostId$" label="仓库"></el-table-column>
                <el-table-column property="signKey" label="签名密钥" width="150"></el-table-column>
                <el-table-column property="appKey" label="接口请求密钥" width="250"></el-table-column>
                <el-table-column property="createTime$" label="时间" width="200"></el-table-column>
                <el-table-column label="操作" width="400">
                    <template slot-scope="scope">
                        <el-button size="mini" @click="generateSignKey(scope.row.hostId)">签名密钥</el-button>
                        <el-button size="mini" @click="generateAppKey(scope.row.hostId)">接口密钥</el-button>
                        <el-switch
                                v-model="scope.row.signStatus"
                                @change="switchChange(scope.row.hostId,scope.row.signStatus)"
                                active-text="开启签名"
                                inactive-text="关闭签名">
                        </el-switch>
                    </template>
                </el-table-column>
            </el-table>
        </el-dialog>
    </div>
    <script>
        showdown.setOption('tables', true);
        var converter = new showdown.Converter()
        var app = new Vue({
            el: '#app',
            data: {
                keyTableVisible: false,
                keyTableData: [],
                loading: true,
            },
            created() {
                this.init()
            },
            methods: {
                init() {
                    this.introduceClick()
                },
                introduceClick() {
                    $.ajax({
                        url: "md/getOrderType.md",
                        headers: {'token': localStorage.getItem('token')},
                        method: 'GET',
                        success: function (res) {
                            // $("#content").html(marked.parse(res))
                            // console.log(converter.makeHtml(res))
                            $("#content").html(converter.makeHtml(res))
                        }
                    });
                },
                keyList() {
                    let that = this
                    this.keyTableVisible = true
                    $.ajax({
                        url: baseUrl + "/hostKey/list/auth",
                        headers: {'token': localStorage.getItem('token')},
                        data: {},
                        dataType:'json',
                        contentType:'application/json;charset=UTF-8',
                        method: 'POST',
                        success: function (res) {
                            let tmp = []
                            res.data.forEach((item, index) => {
                                item.signStatus = item.signStatus == 1 ? true : false;
                                tmp.push(item)
                            });
                            that.keyTableData = tmp
                            that.loading = false
                        }
                    });
                },
                generateSignKey(hostId) {
                    let that = this
                    this.$confirm('此操作将覆盖原签名密钥, 是否继续?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }).then(() => {
                        $.ajax({
                            url: baseUrl + "/hostKey/generateSignKey/auth",
                            headers: {'token': localStorage.getItem('token')},
                            data: {
                                hostId: hostId
                            },
                            dataType: 'json',
                            contentType: 'application/json;charset=UTF-8',
                            method: 'GET',
                            success: function (res) {
                                if (res.code === 200) {
                                    that.$message({
                                        type: 'success',
                                        message: '生成成功'
                                    });
                                    that.keyTableData.forEach((item, index) => {
                                        if (item.hostId == hostId) {
                                            item.signKey = res.data.signKey
                                        }
                                    });
                                } else {
                                    that.$message({
                                        type: 'error',
                                        message: res.msg
                                    });
                                }
                            }
                        });
                    }).catch(() => {
                        //取消
                    });
                },
                generateAppKey(hostId) {
                    let that = this
                    this.$confirm('此操作将覆盖原接口密钥, 是否继续?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }).then(() => {
                        $.ajax({
                            url: baseUrl + "/hostKey/generateAppKey/auth",
                            headers: {'token': localStorage.getItem('token')},
                            data: {
                                hostId: hostId
                            },
                            dataType: 'json',
                            contentType: 'application/json;charset=UTF-8',
                            method: 'GET',
                            success: function (res) {
                                if (res.code === 200) {
                                    that.$message({
                                        type: 'success',
                                        message: '生成成功'
                                    });
                                    that.keyTableData.forEach((item, index) => {
                                        if (item.hostId == hostId) {
                                            item.appKey = res.data.appKey
                                        }
                                    });
                                } else {
                                    that.$message({
                                        type: 'error',
                                        message: res.msg
                                    });
                                }
                            }
                        });
                    }).catch(() => {
                        //取消
                    });
                },
                switchChange(hostId, signStatus) {
                    let that = this
                    //签名校验开关
                    $.ajax({
                        url: baseUrl + "/hostKey/switchSign/auth",
                        headers: {'token': localStorage.getItem('token')},
                        data: {
                            hostId: hostId,
                            signStatus: signStatus ? 1 : 0,
                        },
                        dataType: 'json',
                        contentType: 'application/json;charset=UTF-8',
                        method: 'GET',
                        success: function (res) {
                            if (res.code === 200) {
                                that.$message({
                                    type: 'success',
                                    message: '切换成功'
                                });
                            } else {
                                that.$message({
                                    type: 'error',
                                    message: res.msg
                                });
                            }
                        }
                    });
                },
                switchPage(url) {
                    location.href = url
                },
            }
        })
    </script>
</body>
</html>
zy-asrs-openapi/src/main/webapp/views/index.html
@@ -22,6 +22,7 @@
            <div><el-button type="text" @click="switchPage('reportCompleted.html')">库存上报</el-button></div>
            <div><el-button type="text" @click="switchPage('reportApiManage.html')">上报API管理</el-button></div>
            <el-divider></el-divider>
            <div><el-button type="text" @click="switchPage('getOrderType.html')">获取订单类型</el-button></div>
            <div><el-button type="text" @click="switchPage('generatePakIn.html')">生成入库订单</el-button></div>
            <el-divider></el-divider>
            <div><el-button type="text" @click="keyList()">密钥管理</el-button></div>
zy-asrs-openapi/src/main/webapp/views/md/getOrderType.md
New file
@@ -0,0 +1,274 @@
## 获取订单类型
- **接口说明:** 获取订单类型
- **接口地址:** /api/getOrderType
#### 请求参数
参数名称                        |类型        |出现要求    |描述
:----                        |:---        |:------    |:---
Header                        |&nbsp;        |必填            |请求报文头
&emsp;appkey                    |string        |必填            |密钥管理中生成appkey
Body                        |&nbsp;        |            |&nbsp;
请求示例:
```
{}
```
#### 返回结果
参数名称                        |类型        |出现要求    |描述
:----                        |:---        |:------    |:---
code                        |int        |必填            |响应码,代码定义请见“附录A 响应吗说明”
msg                            |string        |必填            |&nbsp;
data                        |object        |可选            |&nbsp;
示例:
```
{
    "msg": "操作成功",
    "code": 200,
    "data": [
        {
            "docId": 1,
            "docName": "采购入库",
            "pakin": 1,
            "pakout": 0,
            "status": null,
            "createBy": null,
            "createTime": null,
            "updateBy": null,
            "updateTime": null,
            "memo": "",
            "hostId": null,
            "createTime$": "",
            "hostId$": null,
            "status$": null,
            "updateTime$": "",
            "updateBy$": null,
            "createBy$": null
        },
        {
            "docId": 2,
            "docName": "生产入库",
            "pakin": 1,
            "pakout": 0,
            "status": null,
            "createBy": null,
            "createTime": null,
            "updateBy": null,
            "updateTime": null,
            "memo": "",
            "hostId": null,
            "createTime$": "",
            "hostId$": null,
            "status$": null,
            "updateTime$": "",
            "updateBy$": null,
            "createBy$": null
        },
        {
            "docId": 3,
            "docName": "领料退回入库",
            "pakin": 1,
            "pakout": 0,
            "status": null,
            "createBy": null,
            "createTime": null,
            "updateBy": null,
            "updateTime": null,
            "memo": "",
            "hostId": null,
            "createTime$": "",
            "hostId$": null,
            "status$": null,
            "updateTime$": "",
            "updateBy$": null,
            "createBy$": null
        },
        {
            "docId": 4,
            "docName": "销售退回入库",
            "pakin": 1,
            "pakout": 0,
            "status": null,
            "createBy": null,
            "createTime": null,
            "updateBy": null,
            "updateTime": null,
            "memo": "",
            "hostId": null,
            "createTime$": "",
            "hostId$": null,
            "status$": null,
            "updateTime$": "",
            "updateBy$": null,
            "createBy$": null
        },
        {
            "docId": 5,
            "docName": "调拨入库",
            "pakin": 1,
            "pakout": 0,
            "status": null,
            "createBy": null,
            "createTime": null,
            "updateBy": null,
            "updateTime": null,
            "memo": "",
            "hostId": null,
            "createTime$": "",
            "hostId$": null,
            "status$": null,
            "updateTime$": "",
            "updateBy$": null,
            "createBy$": null
        },
        {
            "docId": 6,
            "docName": "其他入库",
            "pakin": 1,
            "pakout": 0,
            "status": null,
            "createBy": null,
            "createTime": null,
            "updateBy": null,
            "updateTime": null,
            "memo": "",
            "hostId": null,
            "createTime$": "",
            "hostId$": null,
            "status$": null,
            "updateTime$": "",
            "updateBy$": null,
            "createBy$": null
        },
        {
            "docId": 7,
            "docName": "销售出库",
            "pakin": 0,
            "pakout": 1,
            "status": null,
            "createBy": null,
            "createTime": null,
            "updateBy": null,
            "updateTime": null,
            "memo": "",
            "hostId": null,
            "createTime$": "",
            "hostId$": null,
            "status$": null,
            "updateTime$": "",
            "updateBy$": null,
            "createBy$": null
        },
        {
            "docId": 8,
            "docName": "领料出库",
            "pakin": 0,
            "pakout": 1,
            "status": null,
            "createBy": null,
            "createTime": null,
            "updateBy": null,
            "updateTime": null,
            "memo": "",
            "hostId": null,
            "createTime$": "",
            "hostId$": null,
            "status$": null,
            "updateTime$": "",
            "updateBy$": null,
            "createBy$": null
        },
        {
            "docId": 9,
            "docName": "采购退回出库",
            "pakin": 0,
            "pakout": 1,
            "status": null,
            "createBy": null,
            "createTime": null,
            "updateBy": null,
            "updateTime": null,
            "memo": "",
            "hostId": null,
            "createTime$": "",
            "hostId$": null,
            "status$": null,
            "updateTime$": "",
            "updateBy$": null,
            "createBy$": null
        },
        {
            "docId": 10,
            "docName": "调拨出库",
            "pakin": 0,
            "pakout": 1,
            "status": null,
            "createBy": null,
            "createTime": null,
            "updateBy": null,
            "updateTime": null,
            "memo": "",
            "hostId": null,
            "createTime$": "",
            "hostId$": null,
            "status$": null,
            "updateTime$": "",
            "updateBy$": null,
            "createBy$": null
        },
        {
            "docId": 11,
            "docName": "其他出库",
            "pakin": 0,
            "pakout": 1,
            "status": null,
            "createBy": null,
            "createTime": null,
            "updateBy": null,
            "updateTime": null,
            "memo": "",
            "hostId": null,
            "createTime$": "",
            "hostId$": null,
            "status$": null,
            "updateTime$": "",
            "updateBy$": null,
            "createBy$": null
        },
        {
            "docId": 12,
            "docName": "手动出库单",
            "pakin": 0,
            "pakout": 1,
            "status": null,
            "createBy": null,
            "createTime": null,
            "updateBy": null,
            "updateTime": null,
            "memo": "",
            "hostId": null,
            "createTime$": "",
            "hostId$": null,
            "status$": null,
            "updateTime$": "",
            "updateBy$": null,
            "createBy$": null
        }
    ]
}
```
## 附录A 响应码说明
响应码    |说明
:----    |:---
200        |处理成功
500        |系统内部错误