#
Junjie
2024-01-08 8d530a2bc48f5f28937e0b4507b7deccf9e34e92
#
12个文件已添加
1 文件已重命名
1个文件已删除
13个文件已修改
1614 ■■■■ 已修改文件
zy-asrs-common/pom.xml 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-common/src/main/java/com/zy/asrs/common/domain/enums/ApiType.java 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-common/src/main/java/com/zy/asrs/common/domain/enums/OrderSettleType.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-common/src/main/java/com/zy/asrs/common/openapi/entity/ApiList.java 123 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-common/src/main/java/com/zy/asrs/common/openapi/mapper/ApiListMapper.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-common/src/main/java/com/zy/asrs/common/openapi/service/ApiListService.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-common/src/main/java/com/zy/asrs/common/openapi/service/impl/ApiListServiceImpl.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-common/src/main/java/com/zy/asrs/common/utils/HttpHandler.java 212 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-common/src/main/resources/mapper/openapi/ApiListMapper.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-openapi/src/main/java/com/zy/asrs/openapi/controller/ApiController.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-openapi/src/main/java/com/zy/asrs/openapi/controller/ApiListController.java 127 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-openapi/src/main/java/com/zy/asrs/openapi/controller/ApiLogController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-openapi/src/main/java/com/zy/asrs/openapi/controller/HostKeyController.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-openapi/src/main/java/com/zy/asrs/openapi/task/ReportApiScheduler.java 171 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-openapi/src/main/webapp/views/apiManage.html 146 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-openapi/src/main/webapp/views/createMat.html 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-openapi/src/main/webapp/views/generateOrderPakIn.html 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-openapi/src/main/webapp/views/generateOrderPakOut.html 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-openapi/src/main/webapp/views/getOrderList.html 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-openapi/src/main/webapp/views/getOrderStatus.html 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-openapi/src/main/webapp/views/getOrderType.html 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-openapi/src/main/webapp/views/index.html 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-openapi/src/main/webapp/views/md/reportCancel.md 85 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-openapi/src/main/webapp/views/md/reportCompleted.md 85 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-openapi/src/main/webapp/views/reportApiManage.html 268 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-openapi/src/main/webapp/views/reportCancel.html 223 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-openapi/src/main/webapp/views/reportCompleted.html 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-common/pom.xml
@@ -66,6 +66,12 @@
            <artifactId>easyexcel</artifactId>
            <version>2.2.6</version>
        </dependency>
        <!-- okHttp3 -->
        <dependency>
            <groupId>com.squareup.okhttp3</groupId>
            <artifactId>okhttp</artifactId>
            <version>3.10.0</version>
        </dependency>
    </dependencies>
    <build>
zy-asrs-common/src/main/java/com/zy/asrs/common/domain/enums/ApiType.java
New file
@@ -0,0 +1,41 @@
package com.zy.asrs.common.domain.enums;
public enum ApiType {
    ORDER_COMPLETE("order_complete", "订单完成"),
    ORDER_CANCEL("order_cancel", "订单取消"),
    REPORT_STOCK("report_stock", "库存上报"),
    ;
    public String type;
    public String desc;
    ApiType(String type, String desc) {
        this.type = type;
        this.desc = desc;
    }
    public static ApiType get(String id) {
        if (null == id) {
            return null;
        }
        for (ApiType type : ApiType.values()) {
            if (type.type.equals(id)) {
                return type;
            }
        }
        return null;
    }
    public static ApiType get(ApiType type) {
        if (null == type) {
            return null;
        }
        for (ApiType type1 : ApiType.values()) {
            if (type1 == type) {
                return type1;
            }
        }
        return null;
    }
}
zy-asrs-common/src/main/java/com/zy/asrs/common/domain/enums/OrderSettleType.java
@@ -11,8 +11,8 @@
    REPORT_COMPLETE(6, "上报完成")
    ;
    private Integer id;
    private String desc;
    public Integer id;
    public String desc;
    OrderSettleType(Integer id, String desc) {
        this.id = id;
zy-asrs-common/src/main/java/com/zy/asrs/common/openapi/entity/ApiList.java
New file
@@ -0,0 +1,123 @@
package com.zy.asrs.common.openapi.entity;
import java.text.SimpleDateFormat;
import java.util.Date;
import com.zy.asrs.common.domain.enums.ApiType;
import org.springframework.format.annotation.DateTimeFormat;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import com.zy.asrs.framework.common.Cools;
import com.zy.asrs.framework.common.SpringUtils;
import com.zy.asrs.common.sys.entity.User;
import com.zy.asrs.common.sys.entity.Host;
import com.zy.asrs.common.sys.service.UserService;
import com.zy.asrs.common.sys.service.HostService;
import java.io.Serializable;
import java.util.Date;
@Data
@TableName("openapi_api_list")
public class ApiList implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * ID
     */
    @ApiModelProperty(value= "ID")
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    /**
     * 上报URL
     */
    @ApiModelProperty(value= "上报URL")
    private String url;
    /**
     * 上报类型
     */
    @ApiModelProperty(value= "上报类型")
    private String type;
    /**
     * 是否开启 0: 关闭  1: 开启
     */
    @ApiModelProperty(value= "是否开启 0: 关闭  1: 开启  ")
    private Integer status;
    /**
     * 授权商户
     */
    @ApiModelProperty(value= "授权商户")
    private Long hostId;
    /**
     * 创建时间
     */
    @ApiModelProperty(value= "创建时间")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private Date createTime;
    public ApiList() {}
    public ApiList(String url,String type,Integer status,Long hostId,Date createTime) {
        this.url = url;
        this.type = type;
        this.status = status;
        this.hostId = hostId;
        this.createTime = createTime;
    }
//    ApiList apiList = new ApiList(
//            null,    // 上报URL
//            null,    // 上报类型
//            null,    // 是否开启
//            null,    // 授权商户
//            null    // 创建时间
//    );
    public String getStatus$(){
        if (null == this.status){ return null; }
        switch (this.status){
            case 0:
                return "关闭";
            case 1:
                return "开启";
            default:
                return String.valueOf(this.status);
        }
    }
    public String getHostId$(){
        HostService service = SpringUtils.getBean(HostService.class);
        Host host = service.getById(this.hostId);
        if (!Cools.isEmpty(host)){
            return String.valueOf(host.getName());
        }
        return null;
    }
    public String getCreateTime$(){
        if (Cools.isEmpty(this.createTime)){
            return "";
        }
        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this.createTime);
    }
    public String getType$() {
        if (this.type == null) {
            return "";
        }
        return ApiType.get(this.type).desc;
    }
}
zy-asrs-common/src/main/java/com/zy/asrs/common/openapi/mapper/ApiListMapper.java
New file
@@ -0,0 +1,12 @@
package com.zy.asrs.common.openapi.mapper;
import com.zy.asrs.common.openapi.entity.ApiList;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
@Mapper
@Repository
public interface ApiListMapper extends BaseMapper<ApiList> {
}
zy-asrs-common/src/main/java/com/zy/asrs/common/openapi/service/ApiListService.java
New file
@@ -0,0 +1,8 @@
package com.zy.asrs.common.openapi.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zy.asrs.common.openapi.entity.ApiList;
public interface ApiListService extends IService<ApiList> {
}
zy-asrs-common/src/main/java/com/zy/asrs/common/openapi/service/impl/ApiListServiceImpl.java
New file
@@ -0,0 +1,12 @@
package com.zy.asrs.common.openapi.service.impl;
import com.zy.asrs.common.openapi.mapper.ApiListMapper;
import com.zy.asrs.common.openapi.entity.ApiList;
import com.zy.asrs.common.openapi.service.ApiListService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
@Service("apiListService")
public class ApiListServiceImpl extends ServiceImpl<ApiListMapper, ApiList> implements ApiListService {
}
zy-asrs-common/src/main/java/com/zy/asrs/common/utils/HttpHandler.java
New file
@@ -0,0 +1,212 @@
package com.zy.asrs.common.utils;
import okhttp3.*;
import java.io.IOException;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
/**
 * Http协议客户端
 * @author luxiaotao
 * @date 2018-9-27
 */
public class HttpHandler {
    private static final Integer DEFAULT_TIMEOUT_SECONDS = 5;
    private static final MediaType MEDIA_TYPE = MediaType.parse("application/json;charset=utf-8");
    private String uri;
    private String path;
    private String json;
    private Map<String, Object> params;
    private Map<String, Object> headers;
    private boolean https;
    private Integer timeout;
    private TimeUnit timeUnit;
    public HttpHandler(Builder builder){
        this.uri = builder.uri;
        this.path = builder.path;
        this.json = builder.json;
        this.params = builder.params;
        this.headers = builder.headers;
        this.https = builder.https;
        this.timeout = builder.timeout;
        this.timeUnit = builder.timeUnit;
    }
    /**
     * GET请求执行
     * @return the HttpHandler response
     */
    public String doGet() throws IOException {
        String url = paramsToUrl(uri, path, params, https);
        Request.Builder headerBuilder = new Request.Builder();
        if (headers != null && headers.size()>0){
            for (Map.Entry<String, Object> entry : headers.entrySet()){
                headerBuilder.addHeader(entry.getKey(), String.valueOf(entry.getValue()));
            }
        }
        Request request = headerBuilder.url(url).build();
        Response response = getClient(timeout, timeUnit).newCall(request).execute();
        return response.isSuccessful() ? response.body().string() : null;
    }
    /**
     * POST请求执行
     * @return the HttpHandler response
     */
    public String doPost() throws IOException {
        Request request;
        Request.Builder headerBuilder = new Request.Builder();
        if (headers != null && headers.size()>0){
            for (Map.Entry<String, Object> entry : headers.entrySet()){
                headerBuilder.addHeader(entry.getKey(), String.valueOf(entry.getValue()));
            }
        }
        if (json == null || "".equals(json)){
            FormBody.Builder builder = new FormBody.Builder();
            for (Map.Entry<String, Object> entry : params.entrySet()){
                builder.add(entry.getKey(), String.valueOf(entry.getValue()));
            }
            FormBody body = builder.build();
            request = headerBuilder
                    .url((https?"https://":"http://")+uri+path)
                    .post(body)
                    .build();
        } else {
            RequestBody body = RequestBody.create(MEDIA_TYPE, json);
            Request.Builder builder = headerBuilder.url((https?"https://":"http://")+uri+path);
            builder.header("Content-Type", "application/json;charset=UTF-8");
            request = builder.post(body).build();
        }
        Call call = getClient(timeout, timeUnit).newCall(request);
        Response response = call.execute();
        return response.body().string();
    }
    /**
     * get请求参数拼接方法
     * @return 请求行
     */
    private String paramsToUrl(String uri, String path, Map<String, Object> params, boolean isHttps) {
        StringBuilder res = new StringBuilder();
        res.append(isHttps ? "https://" : "http://");
        res.append(uri);
        if (path.length() > 0 && !(path.charAt(0) == '/')){
            res.append("/");
        }
        res.append(path);
        Optional.ofNullable(params).ifPresent(
                args -> {
                    res.append("?");
                    args.forEach((key, value) -> {
                        res.append(key);
                        res.append("=");
                        res.append(value);
                        res.append("&");
                    });
                }
        );
        String url = res.toString();
        if ("&".equals(url.substring(url.length()-1, url.length()))){
            url = url.substring(0, url.length()-1);
        }
        return url;
    }
    /**
     * 获取 okHttpClient
     * @return the HttpHandler instance
     */
    private OkHttpClient getClient(Integer timeout, TimeUnit timeUnit){
        return new OkHttpClient
                .Builder()
                .connectTimeout(timeout, timeUnit)
                .readTimeout(timeout, timeUnit)
                .build();
    }
    /**
     * Http协议报文建造者
     */
    public static class Builder {
        private String uri;
        private String path;
        private String json;
        private Map<String, Object> params;
        private Map<String, Object> headers;
        private boolean https;
        private Integer timeout;
        private TimeUnit timeUnit;
        {
            // 默认5s超时
            timeout = DEFAULT_TIMEOUT_SECONDS;
            timeUnit = TimeUnit.SECONDS;
            path = "";
        }
        /**
         * 建造器
         * @return the HttpHandler instance
         */
        public HttpHandler build(){
            if (null == this.uri || "".equals(this.uri)){
                throw new RuntimeException("uri is null");
            }
            if (this.uri.startsWith("http://")){
                this.uri = this.uri.substring(6,uri.length());
            } else if (this.uri.startsWith("https://")){
                this.uri = this.uri.substring(7,uri.length());
            }
            return new HttpHandler(this);
        }
        public Builder setUri(String uri) {
            this.uri = uri;
            return this;
        }
        public Builder setPath(String path) {
            if (!path.startsWith("/")){
                path = "/" + path;
            }
            this.path = path;
            return this;
        }
        public Builder setTimeout(Integer timeout, TimeUnit timeUnit) {
            this.timeout = timeout;
            this.timeUnit = timeUnit;
            return this;
        }
        public Builder setParams(Map<String, Object> params) {
            this.params = params;
            return this;
        }
        public Builder setHeaders(Map<String, Object> headers) {
            this.headers = headers;
            return this;
        }
        public Builder setHttps(boolean https) {
            this.https = https;
            return this;
        }
        public Builder setJson(String json) {
            this.json = json;
            return this;
        }
    }
}
zy-asrs-common/src/main/resources/mapper/openapi/ApiListMapper.xml
New file
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zy.asrs.common.openapi.mapper.ApiListMapper">
</mapper>
zy-asrs-openapi/src/main/java/com/zy/asrs/openapi/controller/ApiController.java
@@ -38,6 +38,11 @@
    @Autowired
    private ApiService apiService;
    @PostMapping("/test")
    public R test() {
        return R.ok();
    }
    /**
     * 生成入库订单
     */
zy-asrs-openapi/src/main/java/com/zy/asrs/openapi/controller/ApiListController.java
New file
@@ -0,0 +1,127 @@
package com.zy.asrs.openapi.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zy.asrs.common.openapi.entity.ApiList;
import com.zy.asrs.common.openapi.service.ApiListService;
import com.zy.asrs.framework.annotations.ManagerAuth;
import com.zy.asrs.framework.common.Cools;
import com.zy.asrs.framework.common.R;
import com.zy.asrs.framework.domain.KeyValueVo;
import com.zy.asrs.framework.common.DateUtils;
import com.zy.asrs.common.web.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.*;
@RestController
public class ApiListController extends BaseController {
    @Autowired
    private ApiListService apiListService;
    @RequestMapping(value = "/apiList/{id}/auth")
    @ManagerAuth
    public R get(@PathVariable("id") String id) {
        return R.ok(apiListService.getById(String.valueOf(id)));
    }
    @RequestMapping(value = "/apiList/page/auth")
    @ManagerAuth
    public R page(@RequestParam(defaultValue = "1") Integer curr,
                  @RequestParam(defaultValue = "10") Integer limit,
                  @RequestParam(required = false) String condition,
                  @RequestParam(required = false) String timeRange,
                  @RequestParam Map<String, Object> param) {
        LambdaQueryWrapper<ApiList> wrapper = new LambdaQueryWrapper<>();
        if (!Cools.isEmpty(condition)) {
            wrapper.like(ApiList::getId, condition);
        }
        if (!Cools.isEmpty(timeRange)) {
            String[] range = timeRange.split(RANGE_TIME_LINK);
            wrapper.ge(ApiList::getCreateTime, DateUtils.convert(range[0]));
            wrapper.le(ApiList::getCreateTime, DateUtils.convert(range[1]));
        }
        if (!Cools.isEmpty(param.get("url"))) {
            wrapper.eq(ApiList::getUrl, param.get("url"));
        }
        if (!Cools.isEmpty(param.get("type"))) {
            wrapper.eq(ApiList::getType, param.get("type"));
        }
        if (!Cools.isEmpty(param.get("status"))) {
            wrapper.eq(ApiList::getStatus, param.get("status"));
        }
        if (!Cools.isEmpty(param.get("hostId"))) {
            wrapper.eq(ApiList::getHostId, param.get("hostId"));
        }
        return R.ok(apiListService.page(new Page<>(curr, limit), wrapper));
    }
    @RequestMapping(value = "/apiList/add/auth")
    @ManagerAuth
    public R add(ApiList apiList) {
        ApiList one = apiListService.getOne(new LambdaQueryWrapper<ApiList>()
                .eq(ApiList::getUrl, apiList.getUrl())
                .eq(ApiList::getType, apiList.getType())
                .eq(ApiList::getHostId, apiList.getHostId()));
        if (one != null) {
            apiListService.removeById(one.getId());
        }
        apiList.setCreateTime(new Date());
        apiListService.save(apiList);
        return R.ok();
    }
    @RequestMapping(value = "/apiList/update/auth")
    @ManagerAuth
    public R update(ApiList apiList){
        if (Cools.isEmpty(apiList) || null==apiList.getId()){
            return R.error();
        }
        apiList.setCreateTime(new Date());
        apiListService.updateById(apiList);
        return R.ok();
    }
    @RequestMapping(value = "/apiList/delete/auth")
    @ManagerAuth
    public R delete(@RequestParam(value="ids[]") Long[] ids){
         for (Long id : ids){
            apiListService.removeById(id);
        }
        return R.ok();
    }
    @RequestMapping(value = "/apiListQuery/auth")
    @ManagerAuth
    public R query(String condition) {
        LambdaQueryWrapper<ApiList> wrapper = new LambdaQueryWrapper<>();
        wrapper.like(ApiList::getId, condition);
        Page<ApiList> page = apiListService.page(new Page<>(0, 10), wrapper);
        List<Map<String, Object>> result = new ArrayList<>();
        for (ApiList apiList : page.getRecords()){
            Map<String, Object> map = new HashMap<>();
            map.put("id", apiList.getId());
            map.put("value", apiList.getId());
            result.add(map);
        }
        return R.ok(result);
    }
    @RequestMapping("/apiList/all/get/kv")
    @ManagerAuth
    public R getDataKV(@RequestParam(required = false) String condition) {
        List<KeyValueVo> vos = new ArrayList<>();
        LambdaQueryWrapper<ApiList> wrapper = new LambdaQueryWrapper<>();
        if (!Cools.isEmpty(condition)) {
            wrapper.like(ApiList::getId, condition);
        }
        apiListService.page(new Page<>(1, 30), wrapper).getRecords().forEach(item -> vos.add(new KeyValueVo(String.valueOf(item.getId()), item.getId())));
        return R.ok().add(vos);
    }
}
zy-asrs-openapi/src/main/java/com/zy/asrs/openapi/controller/ApiLogController.java
File was renamed from zy-asrs-common/src/main/java/com/zy/asrs/common/openapi/controller/ApiLogController.java
@@ -1,4 +1,4 @@
package com.zy.asrs.common.openapi.controller;
package com.zy.asrs.openapi.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
zy-asrs-openapi/src/main/java/com/zy/asrs/openapi/controller/HostKeyController.java
@@ -6,6 +6,7 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zy.asrs.common.openapi.entity.HostKey;
import com.zy.asrs.common.openapi.service.HostKeyService;
import com.zy.asrs.common.sys.service.HostService;
import com.zy.asrs.common.utils.Utils;
import com.zy.asrs.framework.annotations.ManagerAuth;
import com.zy.asrs.framework.common.Cools;
@@ -24,6 +25,8 @@
    @Autowired
    private HostKeyService hostKeyService;
    @Autowired
    private HostService hostService;
    @RequestMapping(value = "/hostKey/{id}/auth")
    @ManagerAuth
@@ -144,4 +147,9 @@
        return R.ok().add(vos);
    }
    @RequestMapping("/host/list")
    public R getHostList() {
        return R.ok().add(hostService.list());
    }
}
zy-asrs-openapi/src/main/java/com/zy/asrs/openapi/task/ReportApiScheduler.java
New file
@@ -0,0 +1,171 @@
package com.zy.asrs.openapi.task;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zy.asrs.common.domain.enums.ApiType;
import com.zy.asrs.common.domain.enums.OrderSettleType;
import com.zy.asrs.common.openapi.entity.ApiList;
import com.zy.asrs.common.openapi.entity.HostKey;
import com.zy.asrs.common.openapi.service.ApiListService;
import com.zy.asrs.common.openapi.service.HostKeyService;
import com.zy.asrs.common.utils.HttpHandler;
import com.zy.asrs.common.wms.entity.Order;
import com.zy.asrs.common.wms.entity.OrderDetl;
import com.zy.asrs.common.wms.service.OrderDetlService;
import com.zy.asrs.common.wms.service.OrderService;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Component
public class ReportApiScheduler {
    @Autowired
    private ApiListService apiListService;
    @Autowired
    private OrderService orderService;
    @Autowired
    private OrderDetlService orderDetlService;
    @Autowired
    private HostKeyService hostKeyService;
    @Scheduled(cron = "0/3 * * * * ? ")
    public void orderComplete() {
        //订单完成上报
        //获取已完成订单
        List<Order> list = orderService.list(new LambdaQueryWrapper<Order>()
                .eq(Order::getSettle, OrderSettleType.COMPLETE.id));
        for (Order order : list) {
            //查询是否需要上报
            ApiList apiList = apiListService.getOne(new LambdaQueryWrapper<ApiList>()
                    .eq(ApiList::getType, ApiType.ORDER_COMPLETE.type)
                    .eq(ApiList::getStatus, 1)
                    .eq(ApiList::getHostId,order.getHostId()));
            if (apiList == null) {
                continue;
            }
            //获取订单明细
            List<OrderDetl> orderDetls = orderDetlService.list(new LambdaQueryWrapper<OrderDetl>()
                    .eq(OrderDetl::getOrderId, order.getId()));
            //封装数据
            HashMap<String, Object> data = new HashMap<>();
            data.put("order", order);
            data.put("orderDetls", orderDetls);
            getSign(data, order.getHostId());//获取签名
            try {
                String response = new HttpHandler.Builder()
                        .setUri(apiList.getUrl())
                        .setJson(JSON.toJSONString(data))
                        .build()
                        .doPost();
                JSONObject result = JSON.parseObject(response);
                if (result.getOrDefault("code", 0).equals(200)) {
                    order.setSettle(OrderSettleType.REPORT_COMPLETE.id.longValue());
                    order.setUpdateTime(new Date());
                    orderService.updateById(order);//更新订单状态
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    @Scheduled(cron = "0/3 * * * * ? ")
    public void orderCancel() {
        //订单取消上报
        //获取已取消订单
        List<Order> list = orderService.list(new LambdaQueryWrapper<Order>()
                .eq(Order::getSettle, OrderSettleType.CANCEL.id));
        for (Order order : list) {
            //查询是否需要上报
            ApiList apiList = apiListService.getOne(new LambdaQueryWrapper<ApiList>()
                    .eq(ApiList::getType, ApiType.ORDER_CANCEL.type)
                    .eq(ApiList::getStatus, 1)
                    .eq(ApiList::getHostId,order.getHostId()));
            if (apiList == null) {
                continue;
            }
            //获取订单明细
            List<OrderDetl> orderDetls = orderDetlService.list(new LambdaQueryWrapper<OrderDetl>()
                    .eq(OrderDetl::getOrderId, order.getId()));
            //封装数据
            HashMap<String, Object> data = new HashMap<>();
            data.put("order", order);
            data.put("orderDetls", orderDetls);
            getSign(data, order.getHostId());//获取签名
            try {
                String response = new HttpHandler.Builder()
                        .setUri(apiList.getUrl())
                        .setJson(JSON.toJSONString(data))
                        .build()
                        .doPost();
                JSONObject result = JSON.parseObject(response);
                if (result.getOrDefault("code", 0).equals(200)) {
                    order.setSettle(OrderSettleType.REPORT_COMPLETE.id.longValue());
                    order.setUpdateTime(new Date());
                    orderService.updateById(order);//更新订单状态
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    @Scheduled(cron = "* 30 23 * * ? ")
    public void reportStock() {
        //库存上报
        //每天晚上11点半执行
        //查询是否需要上报
        List<ApiList> list = apiListService.list(new LambdaQueryWrapper<ApiList>()
                .eq(ApiList::getType, ApiType.REPORT_STOCK.type)
                .eq(ApiList::getStatus, 1));
        for (ApiList apiList : list) {
        }
    }
    //获取签名
    public String getSign(HashMap<String, Object> data, Long hostId) {
        HostKey hostKey = hostKeyService.getOne(new LambdaQueryWrapper<HostKey>()
                .eq(HostKey::getHostId, hostId));
        if (hostKey == null) {
            return null;
        }
        if (hostKey.getSignStatus() == 0) {//没有开启签名
            return null;
        }
        //创建自然排序map
        JSONObject param = new JSONObject(true);
        for (Map.Entry<String, Object> entry : data.entrySet()) {
            if (!entry.getKey().equals("sign")) {//剔除sign
                param.put(entry.getKey(), entry.getValue());
            }
        }
        param.put("signKey", hostKey.getSignKey());
        String md5Hex = DigestUtils.md5Hex(param.toJSONString());
        data.put("sign", md5Hex);
        return md5Hex;
    }
}
zy-asrs-openapi/src/main/webapp/views/apiManage.html
File was deleted
zy-asrs-openapi/src/main/webapp/views/createMat.html
@@ -17,9 +17,9 @@
        <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('reportCompleted.html')">订单完成上报</el-button></div>
            <div><el-button type="text" @click="switchPage('reportCancel.html')">订单取消上报</el-button></div>
            <div><el-button type="text" @click="switchPage('reportStock.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>
zy-asrs-openapi/src/main/webapp/views/generateOrderPakIn.html
@@ -17,9 +17,9 @@
        <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('reportCompleted.html')">订单完成上报</el-button></div>
            <div><el-button type="text" @click="switchPage('reportCancel.html')">订单取消上报</el-button></div>
            <div><el-button type="text" @click="switchPage('reportStock.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>
zy-asrs-openapi/src/main/webapp/views/generateOrderPakOut.html
@@ -17,9 +17,9 @@
        <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('reportCompleted.html')">订单完成上报</el-button></div>
            <div><el-button type="text" @click="switchPage('reportCancel.html')">订单取消上报</el-button></div>
            <div><el-button type="text" @click="switchPage('reportStock.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>
zy-asrs-openapi/src/main/webapp/views/getOrderList.html
@@ -17,9 +17,9 @@
        <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('reportCompleted.html')">订单完成上报</el-button></div>
            <div><el-button type="text" @click="switchPage('reportCancel.html')">订单取消上报</el-button></div>
            <div><el-button type="text" @click="switchPage('reportStock.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>
zy-asrs-openapi/src/main/webapp/views/getOrderStatus.html
@@ -17,9 +17,9 @@
        <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('reportCompleted.html')">订单完成上报</el-button></div>
            <div><el-button type="text" @click="switchPage('reportCancel.html')">订单取消上报</el-button></div>
            <div><el-button type="text" @click="switchPage('reportStock.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>
zy-asrs-openapi/src/main/webapp/views/getOrderType.html
@@ -17,9 +17,9 @@
        <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('reportCompleted.html')">订单完成上报</el-button></div>
            <div><el-button type="text" @click="switchPage('reportCancel.html')">订单取消上报</el-button></div>
            <div><el-button type="text" @click="switchPage('reportStock.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>
zy-asrs-openapi/src/main/webapp/views/index.html
@@ -17,9 +17,9 @@
        <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('reportCompleted.html')">订单完成上报</el-button></div>
            <div><el-button type="text" @click="switchPage('reportCancel.html')">订单取消上报</el-button></div>
            <div><el-button type="text" @click="switchPage('reportStock.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>
zy-asrs-openapi/src/main/webapp/views/md/reportCancel.md
New file
@@ -0,0 +1,85 @@
## 订单取消上报
- **接口说明:** 订单取消上报
上报示例:
```
{
    "orderDetls": [
        {
            "anfme": 10,
            "barcode": "",
            "createBy": 9527,
            "createTime": 1704343061787,
            "createTime$": "2024-01-04 12:37:41",
            "enableQty": 0,
            "hostId": 1,
            "hostId$": "中扬储存设备",
            "id": 25,
            "maktx": "尼龙头(灰白)5.2x50",
            "matnr": "LSH90152050",
            "orderId": 11,
            "orderId$": "11",
            "orderNo": "2024010311062542",
            "qty": 10,
            "specs": "17.18",
            "status": 1,
            "status$": "正常",
            "unit": "箱",
            "updateBy": 9527,
            "updateTime": 1704343061787,
            "updateTime$": "2024-01-04 12:37:41"
        }
    ],
    "order": {
        "createBy": 9527,
        "createTime": 1704343061787,
        "createTime$": "2024-01-04 12:37:41",
        "docType": 1,
        "docType$": "采购入库",
        "hostId": 1,
        "hostId$": "中扬储存设备",
        "id": 11,
        "orderNo": "2024010311062542",
        "orderTime": "2024-01-04 12:37:41",
        "payTime$": "",
        "sendTime$": "",
        "settle": 4,
        "settle$": "已完成",
        "status": 1,
        "status$": "正常",
        "updateBy": 26,
        "updateBy$": "root",
        "updateTime": 1704697086580,
        "updateTime$": "2024-01-08 14:58:06",
        "uuid": "1192446758383255552"
    },
    "sign": "8a7036cfe218e12f50f9107e9eb4a437"
}
```
#### 返回结果
系统上报后,请求方必须马上返回以下结果集,否则视为上报失败。
参数名称                        |类型        |出现要求    |描述
:----                        |:---        |:------    |:---
code                        |int        |R            |响应码,代码定义请见“附录A 响应吗说明”
msg                            |string        |R            |&nbsp;
示例:
```
{
    "code":200,
    "msg":"success",
}
```
## 附录A 响应码说明
响应码    |说明
:----    |:---
200        |处理成功
500        |系统内部错误
zy-asrs-openapi/src/main/webapp/views/md/reportCompleted.md
New file
@@ -0,0 +1,85 @@
## 订单完成上报
- **接口说明:** 订单完成上报
上报示例:
```
{
    "orderDetls": [
        {
            "anfme": 10,
            "barcode": "",
            "createBy": 9527,
            "createTime": 1704343061787,
            "createTime$": "2024-01-04 12:37:41",
            "enableQty": 0,
            "hostId": 1,
            "hostId$": "中扬储存设备",
            "id": 25,
            "maktx": "尼龙头(灰白)5.2x50",
            "matnr": "LSH90152050",
            "orderId": 11,
            "orderId$": "11",
            "orderNo": "2024010311062542",
            "qty": 10,
            "specs": "17.18",
            "status": 1,
            "status$": "正常",
            "unit": "箱",
            "updateBy": 9527,
            "updateTime": 1704343061787,
            "updateTime$": "2024-01-04 12:37:41"
        }
    ],
    "order": {
        "createBy": 9527,
        "createTime": 1704343061787,
        "createTime$": "2024-01-04 12:37:41",
        "docType": 1,
        "docType$": "采购入库",
        "hostId": 1,
        "hostId$": "中扬储存设备",
        "id": 11,
        "orderNo": "2024010311062542",
        "orderTime": "2024-01-04 12:37:41",
        "payTime$": "",
        "sendTime$": "",
        "settle": 4,
        "settle$": "已完成",
        "status": 1,
        "status$": "正常",
        "updateBy": 26,
        "updateBy$": "root",
        "updateTime": 1704697086580,
        "updateTime$": "2024-01-08 14:58:06",
        "uuid": "1192446758383255552"
    },
    "sign": "8a7036cfe218e12f50f9107e9eb4a437"
}
```
#### 返回结果
系统上报后,请求方必须马上返回以下结果集,否则视为上报失败。
参数名称                        |类型        |出现要求    |描述
:----                        |:---        |:------    |:---
code                        |int        |R            |响应码,代码定义请见“附录A 响应吗说明”
msg                            |string        |R            |&nbsp;
示例:
```
{
    "code":200,
    "msg":"success",
}
```
## 附录A 响应码说明
响应码    |说明
:----    |:---
200        |处理成功
500        |系统内部错误
zy-asrs-openapi/src/main/webapp/views/reportApiManage.html
@@ -17,39 +17,49 @@
            <el-card class="box-card">
                <el-form :inline="true" :model="tableSearchParam" class="demo-form-inline">
                    <el-form-item label="">
                        <el-input v-model="tableSearchParam.task_no" placeholder="任务号"></el-input>
                        <el-input v-model="tableSearchParam.url" placeholder="URL"></el-input>
                    </el-form-item>
                    <el-form-item label="">
                        <el-select v-model="tableSearchParam.type" placeholder="请选择上报类型">
                            <el-option label="订单完成" value="order_complete"></el-option>
                            <el-option label="订单取消" value="order_cancel"></el-option>
                            <el-option label="库存上报" value="report_stock"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item>
                        <el-select v-model="tableSearchParam.status" placeholder="请选择是否开启">
                            <el-option label="开启" value="1"></el-option>
                            <el-option label="关闭" value="0"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="">
                        <el-select v-model="tableSearchParam.hostId" placeholder="请选择选择仓库">
                            <el-option v-for="item in hostList" :label="item.name" :value="item.id"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" @click="getTableData">查询</el-button>
                        <el-button type="primary" @click="resetParam">重置</el-button>
                        <el-button type="success" @click="showAddApi()">添加接口</el-button>
                    </el-form-item>
                </el-form>
                <el-table ref="singleTable" :data="tableData" style="width: 100%;">
                    <el-table-column property="id" label="#ID">
                    <el-table-column property="url" label="URL">
                    </el-table-column>
                    <el-table-column property="wrkNo" label="工作号">
                    <el-table-column property="type$" label="上报类型">
                    </el-table-column>
                    <el-table-column property="taskNo" label="任务号">
                    <el-table-column property="status$" label="是否开启">
                    </el-table-column>
                    <el-table-column property="commandStatus$" label="指令状态">
                    <el-table-column property="hostId$" label="仓库">
                    </el-table-column>
                    <el-table-column show-overflow-tooltip property="durationTime" label="持续时长">
                    </el-table-column>
                    <el-table-column property="commandType" label="指令类型">
                    </el-table-column>
                    <el-table-column property="device" label="设备">
                    </el-table-column>
                    <el-table-column property="deviceLog" label="设备执行信息">
                    </el-table-column>
                    <el-table-column property="commandDesc" label="命令描述">
                    </el-table-column>
                    <el-table-column show-overflow-tooltip property="startTime$" label="开始时间">
                    </el-table-column>
                    <el-table-column show-overflow-tooltip property="executeTime$" label="执行时间">
                    </el-table-column>
                    <el-table-column show-overflow-tooltip property="completeTime$" label="完成时间">
                    </el-table-column>
                    <el-table-column show-overflow-tooltip property="command" label="命令报文" width="250">
                    <el-table-column
                            fixed="right"
                            label="操作"
                            width="100">
                        <template slot-scope="scope">
                            <el-button @click="showAddApi(scope.row)" type="text" size="small">编辑</el-button>
                            <el-button @click="deleteApi(scope.row)" type="text" size="small">删除</el-button>
                        </template>
                    </el-table-column>
                </el-table>
@@ -62,13 +72,53 @@
            </el-card>
        </div>
        <div style="position: fixed;top: 20px;right: 20px;width: 150px;border-left: 3px solid #f0f0f0;padding-left: 15px;">
        <div class="slider">
            <div><el-button type="text" @click="switchPage('index.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('reportCompleted.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('reportCancel.html')">订单取消上报</el-button></div>
            <div><el-button type="text" @click="switchPage('reportStock.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('getOrderStatus.html')">获取订单状态列表</el-button></div>
            <div><el-button type="text" @click="switchPage('getOrderList.html')">获取订单列表</el-button></div>
            <div><el-button type="text" @click="switchPage('generateOrderPakIn.html')">生成入库订单</el-button></div>
            <div><el-button type="text" @click="switchPage('generateOrderPakOut.html')">生成出库订单</el-button></div>
            <div><el-button type="text" @click="switchPage('createMat.html')">添加物料信息</el-button></div>
            <el-divider></el-divider>
            <div><el-button type="text" @click="keyList()">密钥管理</el-button></div>
        </div>
        <el-dialog title="接口管理" :visible.sync="formVisible">
            <el-form ref="form" :model="formData" label-width="80px">
                <el-form-item label="URL">
                    <el-input v-model="formData.url" placeholder="请输入上报URL"></el-input>
                </el-form-item>
                <el-form-item label="上报类型">
                    <el-select v-model="formData.type" placeholder="请选择上报类型">
                        <el-option label="订单完成" value="order_complete"></el-option>
                        <el-option label="订单取消" value="order_cancel"></el-option>
                        <el-option label="库存上报" value="report_stock"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="是否开启">
                    <el-select v-model="formData.status" placeholder="请选择是否开启">
                        <el-option label="开启" value="1"></el-option>
                        <el-option label="关闭" value="0"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="选择仓库">
                    <el-select v-model="formData.hostId" placeholder="请选择选择仓库">
                        <el-option v-for="item in hostList" :label="item.name" :value="item.id"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item>
                    <el-button v-if="formData.id == null" type="success" @click="addApi()">添加</el-button>
                    <el-button v-else type="primary" @click="updateApi()">更新</el-button>
                </el-form-item>
            </el-form>
        </el-dialog>
    </div>
    <script>
@@ -81,8 +131,21 @@
                pageSize: 16,
                pageTotal: 0,
                tableSearchParam: {
                    task_no: null,
                    url: "",
                    type: "",
                    status: "",
                    hostId: ""
                },
                tableData: [],
                formVisible: false,
                formData: {
                    id: null,
                    url: "",
                    type: "",
                    status: "",
                    hostId: ""
                },
                hostList: []
            },
            created() {
                this.init()
@@ -90,6 +153,7 @@
            methods: {
                init() {
                    this.getTableData()
                    this.getHostList()
                },
                getTableData() {
                    let that = this;
@@ -97,7 +161,7 @@
                    data.curr = this.currentPage
                    data.limit = this.pageSize
                    $.ajax({
                        url: baseUrl + "/commandInfoLog/list/auth",
                        url: baseUrl + "/apiList/page/auth",
                        headers: {
                            'token': localStorage.getItem('token')
                        },
@@ -138,6 +202,154 @@
                },
                switchPage(url) {
                    location.href = url
                },
                showAddApi(data) {
                    this.formVisible = true;
                    if (data != null) {
                        this.formData = {
                            id: data.id,
                            url: data.url,
                            type: data.type,
                            status: "" + data.status,
                            hostId: data.hostId
                        }
                    }else {
                        this.formData = {
                            id: null,
                            url: "",
                            type: "",
                            status: "",
                            hostId: ""
                        }
                    }
                },
                addApi() {
                    let that = this;
                    if(this.formData.url == '' || this.formData.type == '' || this.formData.status == '' || this.formData.hostId == ''){
                        this.$message({
                            message: '参数不能为空',
                            type: 'error'
                        });
                        return;
                    }
                    $.ajax({
                        url: baseUrl + "/apiList/add/auth",
                        headers: {
                            'token': localStorage.getItem('token')
                        },
                        data: this.formData,
                        dataType: 'json',
                        contentType: 'application/json;charset=UTF-8',
                        method: 'GET',
                        success: function(res) {
                            if (res.code == 200) {
                                that.formVisible = false;
                                that.formData = {
                                    id: null,
                                    url: "",
                                    type: "",
                                    status: "",
                                    hostId: ""
                                }
                                that.getTableData()
                                that.$message({
                                    message: '添加成功',
                                    type: 'success'
                                });
                            }else {
                                that.$message({
                                    message: res.msg,
                                    type: 'error'
                                });
                            }
                        }
                    });
                },
                updateApi() {
                    let that = this;
                    if(this.formData.id == null || this.formData.url == '' || this.formData.type == '' || this.formData.status == '' || this.formData.hostId == ''){
                        this.$message({
                            message: '参数不能为空',
                            type: 'error'
                        });
                        return;
                    }
                    $.ajax({
                        url: baseUrl + "/apiList/update/auth",
                        headers: {
                            'token': localStorage.getItem('token')
                        },
                        data: this.formData,
                        dataType: 'json',
                        contentType: 'application/json;charset=UTF-8',
                        method: 'GET',
                        success: function(res) {
                            if (res.code == 200) {
                                that.formVisible = false;
                                that.formData = {
                                    id: null,
                                    url: "",
                                    type: "",
                                    status: "",
                                    hostId: ""
                                }
                                that.getTableData()
                                that.$message({
                                    message: '更新成功',
                                    type: 'success'
                                });
                            }else {
                                that.$message({
                                    message: res.msg,
                                    type: 'error'
                                });
                            }
                        }
                    });
                },
                deleteApi(data) {
                    let that = this;
                    $.ajax({
                        url: baseUrl + "/apiList/delete/auth",
                        headers: {
                            'token': localStorage.getItem('token')
                        },
                        data: {
                            ids: [data.id]
                        },
                        dataType: 'json',
                        contentType: 'application/json;charset=UTF-8',
                        method: 'GET',
                        success: function(res) {
                            if (res.code == 200) {
                                that.getTableData()
                                that.$message({
                                    message: '删除成功',
                                    type: 'success'
                                });
                            }else {
                                that.$message({
                                    message: res.msg,
                                    type: 'error'
                                });
                            }
                        }
                    });
                },
                getHostList() {
                    let that = this;
                    $.ajax({
                        url: baseUrl + "/host/list",
                        headers: {
                            'token': localStorage.getItem('token')
                        },
                        dataType: 'json',
                        contentType: 'application/json;charset=UTF-8',
                        method: 'GET',
                        success: function(res) {
                            that.hostList = res.data
                        }
                    });
                }
            }
        })
zy-asrs-openapi/src/main/webapp/views/reportCancel.html
New file
@@ -0,0 +1,223 @@
<!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('reportCancel.html')">订单取消上报</el-button></div>
            <div><el-button type="text" @click="switchPage('reportStock.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('getOrderStatus.html')">获取订单状态列表</el-button></div>
            <div><el-button type="text" @click="switchPage('getOrderList.html')">获取订单列表</el-button></div>
            <div><el-button type="text" @click="switchPage('generateOrderPakIn.html')">生成入库订单</el-button></div>
            <div><el-button type="text" @click="switchPage('generateOrderPakOut.html')">生成出库订单</el-button></div>
            <div><el-button type="text" @click="switchPage('createMat.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/reportCancel.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/reportCompleted.html
@@ -14,17 +14,22 @@
<body>
    <div id="app">
        <div id="content"></div>
        <div style="position: fixed;top: 20px;right: 20px;width: 100px;">
            <div style="position: fixed;top: 20px;right: 20px;width: 150px;border-left: 3px solid #f0f0f0;padding-left: 15px;">
                <div><el-button type="text" @click="switchPage('index.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('reportCompleted.html')">库存上报</el-button></div>
                <div><el-button type="text" @click="reportApiManage()">上报接口管理</el-button></div>
                <div><el-button type="text" @click="keyList()">密钥管理</el-button></div>
            </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('reportCancel.html')">订单取消上报</el-button></div>
            <div><el-button type="text" @click="switchPage('reportStock.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('getOrderStatus.html')">获取订单状态列表</el-button></div>
            <div><el-button type="text" @click="switchPage('getOrderList.html')">获取订单列表</el-button></div>
            <div><el-button type="text" @click="switchPage('generateOrderPakIn.html')">生成入库订单</el-button></div>
            <div><el-button type="text" @click="switchPage('generateOrderPakOut.html')">生成出库订单</el-button></div>
            <div><el-button type="text" @click="switchPage('createMat.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">
@@ -69,7 +74,7 @@
                },
                introduceClick() {
                    $.ajax({
                        url: "md/introduce.md",
                        url: "md/reportCompleted.md",
                        headers: {'token': localStorage.getItem('token')},
                        method: 'GET',
                        success: function (res) {