自动化立体仓库 - WCS系统
#
luxiaotao1123
2022-12-20 c0cfe836fba8c4fd03b21ad66d77aa984c210117
#
13个文件已添加
4个文件已修改
1699 ■■■■■ 已修改文件
src/main/java/com/zy/asrs/entity/Order.java 441 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/entity/OrderDetl.java 451 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/mapper/OrderDetlMapper.java 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/mapper/OrderMapper.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/model/MatDto.java 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/service/erp/ErpDbProperties.java 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/service/erp/ErpService.java 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/service/erp/ErpSqlServer.java 236 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/service/erp/dto/VoucherDto.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/service/erp/entity/Goods.java 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/service/erp/entity/Voucher.java 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/service/erp/entity/VoucherDetail.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/LedThread.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application.yml 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/OrderDetlMapper.xml 215 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/OrderMapper.xml 72 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/entity/Order.java
New file
@@ -0,0 +1,441 @@
package com.zy.asrs.entity;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import com.core.common.Cools;
import com.core.common.SpringUtils;
import com.zy.asrs.service.DocTypeService;
import com.zy.asrs.service.OrderSettleService;
import com.zy.system.entity.User;
import com.zy.system.service.UserService;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;
@Data
@TableName("man_order")
public class Order implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * ID
     */
    @ApiModelProperty(value= "ID")
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    /**
     * 编号
     */
    @ApiModelProperty(value= "编号")
    private String uuid;
    /**
     * 订单编号
     */
    @ApiModelProperty(value= "订单编号")
    @TableField("order_no")
    private String orderNo;
    /**
     * 单据日期
     */
    @ApiModelProperty(value= "单据日期")
    @TableField("order_time")
    private String orderTime;
    /**
     * 单据类型
     */
    @ApiModelProperty(value= "单据类型")
    @TableField("doc_type")
    private Long docType;
    /**
     * 项目编号
     */
    @ApiModelProperty(value= "项目编号")
    @TableField("item_id")
    private Long itemId;
    @ApiModelProperty(value= "")
    @TableField("item_name")
    private String itemName;
    /**
     * 调拨项目编号
     */
    @ApiModelProperty(value= "调拨项目编号")
    @TableField("allot_item_id")
    private Long allotItemId;
    /**
     * 初始票据号
     */
    @ApiModelProperty(value= "初始票据号")
    @TableField("def_number")
    private String defNumber;
    /**
     * 票据号
     */
    @ApiModelProperty(value= "票据号")
    private String number;
    /**
     * 客户编号
     */
    @ApiModelProperty(value= "客户编号")
    private Long cstmr;
    /**
     * 客户
     */
    @ApiModelProperty(value= "客户")
    @TableField("cstmr_name")
    private String cstmrName;
    /**
     * 联系方式
     */
    @ApiModelProperty(value= "联系方式")
    private String tel;
    /**
     * 操作人员
     */
    @ApiModelProperty(value= "操作人员")
    @TableField("oper_memb")
    private String operMemb;
    /**
     * 合计金额
     */
    @ApiModelProperty(value= "合计金额")
    @TableField("total_fee")
    private Double totalFee;
    /**
     * 优惠率
     */
    @ApiModelProperty(value= "优惠率")
    private Double discount;
    /**
     * 优惠金额
     */
    @ApiModelProperty(value= "优惠金额")
    @TableField("discount_fee")
    private Double discountFee;
    /**
     * 销售或采购费用合计
     */
    @ApiModelProperty(value= "销售或采购费用合计")
    @TableField("other_fee")
    private Double otherFee;
    /**
     * 实付金额
     */
    @ApiModelProperty(value= "实付金额")
    @TableField("act_fee")
    private Double actFee;
    /**
     * 付款类型 1: 现金  2: 记账
     */
    @ApiModelProperty(value= "付款类型 1: 现金  2: 记账  ")
    @TableField("pay_type")
    private Integer payType;
    /**
     * 业务员
     */
    @ApiModelProperty(value= "业务员")
    private String salesman;
    /**
     * 结算天数
     */
    @ApiModelProperty(value= "结算天数")
    @TableField("account_day")
    private Integer accountDay;
    /**
     * 邮费支付类型 1: 在线支付  2: 货到付款
     */
    @ApiModelProperty(value= "邮费支付类型 1: 在线支付  2: 货到付款  ")
    @TableField("post_fee_type")
    private Integer postFeeType;
    /**
     * 邮费
     */
    @ApiModelProperty(value= "邮费")
    @TableField("post_fee")
    private Double postFee;
    /**
     * 付款时间
     */
    @ApiModelProperty(value= "付款时间")
    @TableField("pay_time")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private Date payTime;
    /**
     * 发货时间
     */
    @ApiModelProperty(value= "发货时间")
    @TableField("send_time")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private Date sendTime;
    /**
     * 物流名称
     */
    @ApiModelProperty(value= "物流名称")
    @TableField("ship_name")
    private String shipName;
    /**
     * 物流单号
     */
    @ApiModelProperty(value= "物流单号")
    @TableField("ship_code")
    private String shipCode;
    /**
     * 订单状态
     */
    @ApiModelProperty(value= "订单状态")
    private Long settle;
    /**
     * 状态 1: 正常  0: 禁用
     */
    @ApiModelProperty(value= "状态 1: 正常  0: 禁用  ")
    private Integer status;
    /**
     * 添加人员
     */
    @ApiModelProperty(value= "添加人员")
    @TableField("create_by")
    private Long createBy;
    /**
     * 添加时间
     */
    @ApiModelProperty(value= "添加时间")
    @TableField("create_time")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private Date createTime;
    /**
     * 修改人员
     */
    @ApiModelProperty(value= "修改人员")
    @TableField("update_by")
    private Long updateBy;
    /**
     * 修改时间
     */
    @ApiModelProperty(value= "修改时间")
    @TableField("update_time")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private Date updateTime;
    /**
     * 备注
     */
    @ApiModelProperty(value= "备注")
    private String memo;
    public Order() {}
    public Order(String uuid,String orderNo,String orderTime,Long docType,Long itemId,String itemName,Long allotItemId,String defNumber,String number,Long cstmr,String cstmrName,String tel,String operMemb,Double totalFee,Double discount,Double discountFee,Double otherFee,Double actFee,Integer payType,String salesman,Integer accountDay,Integer postFeeType,Double postFee,Date payTime,Date sendTime,String shipName,String shipCode,Long settle,Integer status,Long createBy,Date createTime,Long updateBy,Date updateTime,String memo) {
        this.uuid = uuid;
        this.orderNo = orderNo;
        this.orderTime = orderTime;
        this.docType = docType;
        this.itemId = itemId;
        this.itemName = itemName;
        this.allotItemId = allotItemId;
        this.defNumber = defNumber;
        this.number = number;
        this.cstmr = cstmr;
        this.cstmrName = cstmrName;
        this.tel = tel;
        this.operMemb = operMemb;
        this.totalFee = totalFee;
        this.discount = discount;
        this.discountFee = discountFee;
        this.otherFee = otherFee;
        this.actFee = actFee;
        this.payType = payType;
        this.salesman = salesman;
        this.accountDay = accountDay;
        this.postFeeType = postFeeType;
        this.postFee = postFee;
        this.payTime = payTime;
        this.sendTime = sendTime;
        this.shipName = shipName;
        this.shipCode = shipCode;
        this.settle = settle;
        this.status = status;
        this.createBy = createBy;
        this.createTime = createTime;
        this.updateBy = updateBy;
        this.updateTime = updateTime;
        this.memo = memo;
    }
//    Order order = new Order(
//            null,    // 编号[非空]
//            null,    // 订单编号
//            null,    // 单据日期
//            null,    // 单据类型
//            null,    // 项目编号
//            null,    //
//            null,    // 调拨项目编号
//            null,    // 初始票据号
//            null,    // 票据号
//            null,    // 客户编号
//            null,    // 客户
//            null,    // 联系方式
//            null,    // 操作人员
//            null,    // 合计金额
//            null,    // 优惠率
//            null,    // 优惠金额
//            null,    // 销售或采购费用合计
//            null,    // 实付金额
//            null,    // 付款类型
//            null,    // 业务员
//            null,    // 结算天数
//            null,    // 邮费支付类型
//            null,    // 邮费
//            null,    // 付款时间
//            null,    // 发货时间
//            null,    // 物流名称
//            null,    // 物流单号
//            null,    // 订单状态
//            null,    // 状态
//            null,    // 添加人员
//            null,    // 添加时间
//            null,    // 修改人员
//            null,    // 修改时间
//            null    // 备注
//    );
    public String getDocType$(){
        DocTypeService service = SpringUtils.getBean(DocTypeService.class);
        DocType docType = service.selectById(this.docType);
        if (!Cools.isEmpty(docType)){
            return String.valueOf(docType.getDocName());
        }
        return null;
    }
    public String getPayType$(){
        if (null == this.payType){ return null; }
        switch (this.payType){
            case 1:
                return "现金";
            case 2:
                return "记账";
            default:
                return String.valueOf(this.payType);
        }
    }
    public String getPostFeeType$(){
        if (null == this.postFeeType){ return null; }
        switch (this.postFeeType){
            case 1:
                return "在线支付";
            case 2:
                return "货到付款";
            default:
                return String.valueOf(this.postFeeType);
        }
    }
    public String getPayTime$(){
        if (Cools.isEmpty(this.payTime)){
            return "";
        }
        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this.payTime);
    }
    public String getSendTime$(){
        if (Cools.isEmpty(this.sendTime)){
            return "";
        }
        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this.sendTime);
    }
    public String getSettle$(){
        OrderSettleService service = SpringUtils.getBean(OrderSettleService.class);
        OrderSettle orderSettle = service.selectById(this.settle);
        if (!Cools.isEmpty(orderSettle)){
            return String.valueOf(orderSettle.getSettleName());
        }
        return null;
    }
    public String getStatus$(){
        if (null == this.status){ return null; }
        switch (this.status){
            case 1:
                return "正常";
            case 0:
                return "禁用";
            default:
                return String.valueOf(this.status);
        }
    }
    public String getCreateBy$(){
        UserService service = SpringUtils.getBean(UserService.class);
        User user = service.selectById(this.createBy);
        if (!Cools.isEmpty(user)){
            return String.valueOf(user.getUsername());
        }
        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 getUpdateBy$(){
        UserService service = SpringUtils.getBean(UserService.class);
        User user = service.selectById(this.updateBy);
        if (!Cools.isEmpty(user)){
            return String.valueOf(user.getUsername());
        }
        return null;
    }
    public String getUpdateTime$(){
        if (Cools.isEmpty(this.updateTime)){
            return "";
        }
        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this.updateTime);
    }
}
src/main/java/com/zy/asrs/entity/OrderDetl.java
New file
@@ -0,0 +1,451 @@
package com.zy.asrs.entity;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import com.core.common.Cools;
import com.core.common.SpringUtils;
import com.zy.asrs.service.OrderService;
import com.zy.common.utils.Synchro;
import com.zy.system.entity.User;
import com.zy.system.service.UserService;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;
@Data
@TableName("man_order_detl")
public class OrderDetl implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * ID
     */
    @ApiModelProperty(value= "ID")
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    /**
     * 订单内码
     */
    @ApiModelProperty(value= "订单内码")
    @TableField("order_id")
    private Long orderId;
    /**
     * 单据编号
     */
    @ApiModelProperty(value= "单据编号")
    @TableField("order_no")
    private String orderNo;
    /**
     * 数量
     */
    @ApiModelProperty(value= "数量")
    private Double anfme;
    /**
     * 作业数量
     *
     *  1. 入库 : qty 👆
     *  1. 出库 : qty 👆
     */
    @ApiModelProperty(value= "作业数量")
    private Double qty;
    /**
     * 物料号
     */
    @ApiModelProperty(value= "物料号")
    private String matnr;
    /**
     * 物料号
     */
    @ApiModelProperty(value= "物料号")
    private String maktx;
    /**
     * 序列码
     */
    @ApiModelProperty(value= "序列码")
    private String batch;
    /**
     * 规格
     */
    @ApiModelProperty(value= "规格")
    private String specs;
    /**
     * 批次
     */
    @ApiModelProperty(value= "批次")
    private String model;
    /**
     * 颜色
     */
    @ApiModelProperty(value= "颜色")
    private String color;
    /**
     * 品牌
     */
    @ApiModelProperty(value= "品牌")
    private String brand;
    /**
     * 单位
     */
    @ApiModelProperty(value= "单位")
    private String unit;
    /**
     * 单价
     */
    @ApiModelProperty(value= "单价")
    private Double price;
    /**
     * sku
     */
    @ApiModelProperty(value= "sku")
    private String sku;
    /**
     * 包数
     */
    @ApiModelProperty(value= "包数")
    private Double units;
    /**
     * 条码
     */
    @ApiModelProperty(value= "条码")
    private String barcode;
    /**
     * 物料状态
     */
    @ApiModelProperty(value= "物料状态")
    private String origin;
    /**
     * 厂家
     */
    @ApiModelProperty(value= "厂家")
    private String manu;
    /**
     * 单据时间
     */
    @ApiModelProperty(value= "单据时间")
    @TableField("manu_date")
    private String manuDate;
    /**
     * 品项数
     */
    @ApiModelProperty(value= "品项数")
    @TableField("item_num")
    private String itemNum;
    /**
     * 安全库存量
     */
    @ApiModelProperty(value= "安全库存量")
    @TableField("safe_qty")
    private Double safeQty;
    /**
     * 重量
     */
    @ApiModelProperty(value= "重量")
    private Double weight;
    /**
     * 长度
     */
    @ApiModelProperty(value= "长度")
    private Double length;
    /**
     * 体积
     */
    @ApiModelProperty(value= "体积")
    private Double volume;
    /**
     * 三方编码
     */
    @ApiModelProperty(value= "三方编码")
    @TableField("three_code")
    private String threeCode;
    /**
     * 供应商
     */
    @ApiModelProperty(value= "供应商")
    private String supp;
    /**
     * 供应商编码
     */
    @ApiModelProperty(value= "供应商编码")
    @TableField("supp_code")
    private String suppCode;
    /**
     * 是否批次 1: 是  0: 否
     */
    @ApiModelProperty(value= "是否批次 1: 是  0: 否  ")
    @TableField("be_batch")
    private Integer beBatch;
    /**
     * 保质期
     */
    @ApiModelProperty(value= "保质期")
    @TableField("dead_time")
    private String deadTime;
    /**
     * 预警天数
     */
    @ApiModelProperty(value= "预警天数")
    @TableField("dead_warn")
    private Integer deadWarn;
    /**
     * 制购 1: 制造  2: 采购  3: 外协
     */
    @ApiModelProperty(value= "制购 1: 制造  2: 采购  3: 外协  ")
    private Integer source;
    /**
     * 要求检验 1: 是  0: 否
     */
    @ApiModelProperty(value= "要求检验 1: 是  0: 否  ")
    private Integer inspect;
    /**
     * 危险品 1: 是  0: 否
     */
    @ApiModelProperty(value= "危险品 1: 是  0: 否  ")
    private Integer danger;
    /**
     * 状态 1: 正常  0: 禁用
     */
    @ApiModelProperty(value= "状态 1: 正常  0: 禁用  ")
    private Integer status;
    /**
     * 添加人员
     */
    @ApiModelProperty(value= "添加人员")
    @TableField("create_by")
    private Long createBy;
    /**
     * 添加时间
     */
    @ApiModelProperty(value= "添加时间")
    @TableField("create_time")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private Date createTime;
    /**
     * 修改人员
     */
    @ApiModelProperty(value= "修改人员")
    @TableField("update_by")
    private Long updateBy;
    /**
     * 修改时间
     */
    @ApiModelProperty(value= "修改时间")
    @TableField("update_time")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private Date updateTime;
    /**
     * 备注
     */
    @ApiModelProperty(value= "备注")
    private String memo;
    public OrderDetl() {}
    public OrderDetl(Long orderId, String orderNo, Double anfme, Double qty, String matnr, String maktx, String batch, String specs, String model, String color, String brand, String unit, Double price, String sku, Double units, String barcode, String origin, String manu, String manuDate, String itemNum, Double safeQty, Double weight, Double length, Double volume, String threeCode, String supp, String suppCode, Integer beBatch, String deadTime, Integer deadWarn, Integer source, Integer inspect, Integer danger, Integer status, Long createBy, Date createTime, Long updateBy, Date updateTime, String memo) {
        this.orderId = orderId;
        this.orderNo = orderNo;
        this.anfme = anfme;
        this.qty = qty;
        this.matnr = matnr;
        this.maktx = maktx;
        this.batch = batch;
        this.specs = specs;
        this.model = model;
        this.color = color;
        this.brand = brand;
        this.unit = unit;
        this.price = price;
        this.sku = sku;
        this.units = units;
        this.barcode = barcode;
        this.origin = origin;
        this.manu = manu;
        this.manuDate = manuDate;
        this.itemNum = itemNum;
        this.safeQty = safeQty;
        this.weight = weight;
        this.length = length;
        this.volume = volume;
        this.threeCode = threeCode;
        this.supp = supp;
        this.suppCode = suppCode;
        this.beBatch = beBatch;
        this.deadTime = deadTime;
        this.deadWarn = deadWarn;
        this.source = source;
        this.inspect = inspect;
        this.danger = danger;
        this.status = status;
        this.createBy = createBy;
        this.createTime = createTime;
        this.updateBy = updateBy;
        this.updateTime = updateTime;
        this.memo = memo;
    }
    public String getOrderId$(){
        OrderService service = SpringUtils.getBean(OrderService.class);
        Order order = service.selectById(this.orderId);
        if (!Cools.isEmpty(order)){
            return String.valueOf(order.getId());
        }
        return null;
    }
    public String getBeBatch$(){
        if (null == this.beBatch){ return null; }
        switch (this.beBatch){
            case 1:
                return "是";
            case 0:
                return "否";
            default:
                return String.valueOf(this.beBatch);
        }
    }
    public String getSource$(){
        if (null == this.source){ return null; }
        switch (this.source){
            case 1:
                return "制造";
            case 2:
                return "采购";
            case 3:
                return "外协";
            default:
                return String.valueOf(this.source);
        }
    }
    public String getInspect$(){
        if (null == this.inspect){ return null; }
        switch (this.inspect){
            case 1:
                return "是";
            case 0:
                return "否";
            default:
                return String.valueOf(this.inspect);
        }
    }
    public String getDanger$(){
        if (null == this.danger){ return null; }
        switch (this.danger){
            case 1:
                return "是";
            case 0:
                return "否";
            default:
                return String.valueOf(this.danger);
        }
    }
    public String getStatus$(){
        if (null == this.status){ return null; }
        switch (this.status){
            case 1:
                return "正常";
            case 0:
                return "禁用";
            default:
                return String.valueOf(this.status);
        }
    }
    public String getCreateBy$(){
        UserService service = SpringUtils.getBean(UserService.class);
        User user = service.selectById(this.createBy);
        if (!Cools.isEmpty(user)){
            return String.valueOf(user.getUsername());
        }
        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 getUpdateBy$(){
        UserService service = SpringUtils.getBean(UserService.class);
        User user = service.selectById(this.updateBy);
        if (!Cools.isEmpty(user)){
            return String.valueOf(user.getUsername());
        }
        return null;
    }
    public String getUpdateTime$(){
        if (Cools.isEmpty(this.updateTime)){
            return "";
        }
        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this.updateTime);
    }
    public Double getEnableQty() {
        Double enableQty = null;
        if (null != this.anfme && this.qty != null) {
            enableQty = this.anfme - this.qty;
            if (enableQty < 0) {
                enableQty = 0.0D;
            }
//            return this.anfme - this.qty;
        }
        return enableQty;
    }
    public void sync(Object source) {
        Synchro.Copy(source, this);
    }
}
src/main/java/com/zy/asrs/mapper/OrderDetlMapper.java
New file
@@ -0,0 +1,42 @@
package com.zy.asrs.mapper;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.zy.asrs.entity.OrderDetl;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
@Mapper
@Repository
public interface OrderDetlMapper extends BaseMapper<OrderDetl> {
    OrderDetl selectItem(@Param("orderId") Long orderId, @Param("matnr") String matnr, @Param("batch") String batch);
    OrderDetl selectItemByOrderNo(@Param("orderNo") String orderNo, @Param("matnr") String matnr, @Param("batch") String batch);
    OrderDetl selectItemNoneOfBatch(@Param("orderNo")String orderNo, @Param("matnr")String matnr);
    OrderDetl selectItemOfBatch(@Param("matnr")String matnr, @Param("batch")String batch);
    List<OrderDetl> selectWorkingDetls(Long orderId);
    List<OrderDetl> getPakoutPage(Map<String, Object> map);
    Integer getPakoutPageCount(Map<String, Object> map);
    int increaseAnfme(@Param("orderId")Long orderId, @Param("matnr")String matnr, @Param("batch")String batch, @Param("qty")Double qty);
    int increase(@Param("orderId")Long orderId, @Param("matnr")String matnr, @Param("batch")String batch, @Param("qty")Double qty);
    int decrease(@Param("orderNo")String orderNo, @Param("matnr")String matnr, @Param("batch")String batch, @Param("qty")Double qty);
    int modifyStatus(@Param("orderId") Long orderId, @Param("status")Integer status);
    List<OrderDetl> selectRemainder(@Param("orderId") Long orderId);
    List<OrderDetl> selectByMatnr(@Param("matnr") String matnr);
}
src/main/java/com/zy/asrs/mapper/OrderMapper.java
New file
@@ -0,0 +1,21 @@
package com.zy.asrs.mapper;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.zy.asrs.entity.Order;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@Mapper
@Repository
public interface OrderMapper extends BaseMapper<Order> {
    Order selectByOrderNo(@Param("orderNo") String orderNo);
    int updateSettle(@Param("orderId")Long orderId, @Param("settle")Long settle, @Param("userId")Long userId);
    List<Order> selectComplete();
}
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -6,9 +6,7 @@
import com.core.common.Cools;
import com.core.exception.CoolException;
import com.zy.asrs.entity.*;
import com.zy.asrs.mapper.BasCrnErrorMapper;
import com.zy.asrs.mapper.WrkChargeMapper;
import com.zy.asrs.mapper.WrkMastMapper;
import com.zy.asrs.mapper.*;
import com.zy.asrs.service.*;
import com.zy.asrs.utils.Utils;
import com.zy.common.model.LocTypeDto;
@@ -17,6 +15,7 @@
import com.zy.common.model.StartupDto;
import com.zy.common.model.enums.WrkChargeType;
import com.zy.common.service.CommonService;
import com.zy.common.service.erp.ErpService;
import com.zy.common.utils.CollectionUtils;
import com.zy.common.utils.HttpHandler;
import com.zy.core.CrnThread;
@@ -92,6 +91,12 @@
    private CommonService commonService;
    @Autowired
    private WrkChargeMapper wrkChargeMapper;
    @Autowired
    private ErpService erpService;
    @Autowired
    private OrderMapper orderMapper;
    @Autowired
    private OrderDetlMapper orderDetlMapper;
    /**
     * 组托
@@ -2484,14 +2489,13 @@
                ledCommand.setStaNo(wrkMast.getStaNo());
                if (wrkMast.getIoType() != 110) {
                    List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkMast.getWrkNo());
                    wrkDetls.forEach(wrkDetl -> {
                        if (wrkMast.getIoType() == 101) {
                            ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getBatch(), wrkDetl.getAnfme()));
                        }
                        if (wrkMast.getIoType() == 103 && (null == wrkDetl.getInspect() || 0 == wrkDetl.getInspect())) {
                            ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getBatch(), wrkDetl.getAnfme()));
                        }
                    });
                    try {
                        WrkDetl wrkDetl = wrkDetls.get(0);
                        OrderDetl orderDetl = orderDetlMapper.selectItemNoneOfBatch(wrkDetl.getOrderNo(), wrkDetl.getMatnr());
                        ledCommand.getMatDtos().add(new MatDto(orderDetl));
                    } catch (Exception e) {
                        log.error("led execute fail", e);
                    }
                }
                commands.add(ledCommand);
            }
src/main/java/com/zy/common/model/MatDto.java
@@ -1,5 +1,6 @@
package com.zy.common.model;
import com.zy.asrs.entity.OrderDetl;
import lombok.Data;
/**
@@ -12,20 +13,29 @@
    private String matnr;
    // 物料名称
    private String maknx;
    private String model;
    // 条码
    private String batch;
    // 物料数量
    // 订单编号
    private String orderNo;
    // 已出
    private Double count;
    // 总数量
    private Double total;
    public MatDto() {
    }
    public MatDto(String matnr, String maknx, String batch, Double count) {
        this.matnr = matnr;
        this.maknx = maknx;
        this.batch = batch;
        this.count = count;
    public MatDto(OrderDetl orderDetl) {
        this.matnr = orderDetl.getMatnr();
        this.model = orderDetl.getModel();
        this.batch = orderDetl.getBatch();
        this.orderNo = orderDetl.getOrderNo();
        this.count = orderDetl.getQty() + orderDetl.getWeight();
        this.total = orderDetl.getAnfme();
    }
}
src/main/java/com/zy/common/service/erp/ErpDbProperties.java
New file
@@ -0,0 +1,30 @@
package com.zy.common.service.erp;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
/**
 * Created by vincent on 2020/11/26
 */
@Data
@ConfigurationProperties(prefix = "erp.db")
@Component
public class ErpDbProperties {
    private String driver_class_name;
    private String ur;
    private String username;
    private String password;
//    {
//        driver_class_name = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
//        ur = "jdbc:sqlserver://127.0.0.1:1433;databasename=byrk";
//        username = "sa";
//        password = "sa@123";
//    }
}
src/main/java/com/zy/common/service/erp/ErpService.java
Binary files differ
src/main/java/com/zy/common/service/erp/ErpSqlServer.java
New file
@@ -0,0 +1,236 @@
package com.zy.common.service.erp;
import com.core.common.Cools;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.sql.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 简单持久层框架
 * Created by vincent on 2020/11/26
 */
@Slf4j
@Service
public class ErpSqlServer {
    // 数据库连接
//    private Connection conn;
    // 创建预编译语句对象,一般都是用这个而不用Statement
    private PreparedStatement pstm = null;
    // 创建一个结果集对象
    private ResultSet rs = null;
    @Autowired
    private ErpDbProperties erpDbProperties;
    /*****************************************************************************/
    /**********************************   封装   **********************************/
    /*****************************************************************************/
    /**
     * 查询
     */
    public <T> List<T> select(String sql, Class<T> cls) {
        List<Map<String, Object>> result = executeQuery(sql);
        List<T> list = new ArrayList<>();
        if (null != result) {
            for (Map<String, Object> entity : result) {
                list.add(Cools.conver(entity, cls));
            }
        }
        return list;
    }
    public List<Map<String, Object>> select(String sql) {
        return executeQuery(sql);
    }
    /**
     * 修改
     */
    public int update(String sql) {
        return executeUpdate(sql);
    }
    /*****************************************************************************/
    /*********************************   核心层   *********************************/
    /*****************************************************************************/
    /**
     * map 转 对象
     */
    private List<Map<String, Object>> executeQuery(String sql) {
        Connection conn = null;
        try {
            conn = getConn();
            pstm = conn.prepareStatement(sql);
            rs = pstm.executeQuery();
//            List<Map<String, Object>> maps = convertList(rs);
            return convertList(rs);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        } finally {
            release();
            if (conn != null) {
                try {
                    conn.close();
                    conn = null;
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
        }
    }
    public Number executeQueryCount(String sql, String column) {
        Number value = 0;
        Connection conn = null;
        try {
            conn = getConn();
            pstm = conn.prepareStatement(sql);
            rs = pstm.executeQuery();
//            ResultSetMetaData metaData = rs.getMetaData();
            while (rs.next()) {
                value = (Number) rs.getInt(column);
            }
            return value;
        } catch (Exception e) {
            e.printStackTrace();
            return 0;
        } finally {
            release();
            if (conn != null) {
                try {
                    conn.close();
                    conn = null;
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
        }
    }
    private int executeUpdate(String sql) {
        Connection conn = null;
        try {
            conn = getConn();
            if(null != conn)
            {
                pstm = conn.prepareStatement(sql);
            } else {
                log.error("更新ERP中间表失败===>>数据库连接conn为空");
                log.error("更新ERP中间表失败===>>" + sql);
            }
            return pstm.executeUpdate();
        } catch (Exception e) {
            e.printStackTrace();
            log.error("更新ERP中间表失败===>>" + sql);
            log.error("更新ERP中间表失败===>>" + e);
            return 0;
        } finally {
            release();
            if (conn != null) {
                try {
                    conn.close();
                    conn = null;
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
        }
    }
    private static List<Map<String, Object>> convertList(ResultSet rs) throws SQLException {
        List<Map<String, Object>> list = new ArrayList<>();
        ResultSetMetaData md = rs.getMetaData();
        int columnCount = md.getColumnCount();
        while (rs.next()) {
            Map<String, Object> rowData = new HashMap<>();
            for (int i = 1; i <= columnCount; i++) {
                rowData.put(md.getColumnName(i), rs.getObject(i));
            }
            list.add(rowData);
        }
        return list;
    }
    //synchronized
    public Connection getConn() throws SQLException {
        Connection conn = null;
        try {
            Class.forName(erpDbProperties.getDriver_class_name()).newInstance();
            conn = DriverManager.getConnection(erpDbProperties.getUr(), erpDbProperties.getUsername(), erpDbProperties.getPassword());
        } catch (Exception e) {
            log.error("获取ERP数据库连接失败");
            e.printStackTrace();
            throw new RuntimeException("获取ERP数据库连接失败");
        }
        return conn;
//        if (null == this.conn || this.conn.isClosed()) {
//            try {
//                Class.forName(erpDbProperties.getDriver_class_name()).newInstance();
//                this.conn = DriverManager.getConnection(erpDbProperties.getUr(), erpDbProperties.getUsername(), erpDbProperties.getPassword());
//            } catch (Exception e) {
//                log.error("获取ERP数据库连接失败");
//                e.printStackTrace();
//                throw new RuntimeException("获取ERP数据库连接失败");
//            }
//        }
//        return this.conn;
    }
    private void release() {
        if (rs != null) {
            try {
                rs.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        if (pstm != null) {
            try {
                pstm.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
//        if (conn != null) {
//            try {
//                conn.close();
//                conn = null;
//            } catch (SQLException e) {
//                e.printStackTrace();
//            }
//        }
    }
    /**
     * 深拷贝
     */
    public ArrayList deepClone(List list) throws Exception {
        // 序列化
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(bos);
        oos.writeObject(list);
        // 反序列化
        ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
        ObjectInputStream ois = new ObjectInputStream(bis);
        return (ArrayList) ois.readObject();
    }
}
src/main/java/com/zy/common/service/erp/dto/VoucherDto.java
New file
@@ -0,0 +1,20 @@
package com.zy.common.service.erp.dto;
import com.zy.common.service.erp.entity.Voucher;
import com.zy.common.service.erp.entity.VoucherDetail;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/**
 * Created by vincent on 2022/12/8
 */
@Data
public class VoucherDto {
    private Voucher voucher;
    private List<VoucherDetail> details = new ArrayList<>();
}
src/main/java/com/zy/common/service/erp/entity/Goods.java
New file
@@ -0,0 +1,45 @@
package com.zy.common.service.erp.entity;
import lombok.Data;
/**
 * Created by vincent on 2022/12/8
 */
@Data
public class Goods {
    private String BarCode;
    private String MaterialNO;
    private String ProdSpec;
    private Integer NumOfBobbins;
    private Double NWT; // 净重
    private Double GWT; // 毛重
    private String ProdDate;
    private String LINE;
    private String GRADE;
    private String GRADES;
    private String Chip;
    private String Batch;
    private String PACKING_TYPE;
    private String PACKING_DATE;
    private String LastUpdatedDate;
    private Integer State;
    private String location;
}
src/main/java/com/zy/common/service/erp/entity/Voucher.java
New file
@@ -0,0 +1,45 @@
package com.zy.common.service.erp.entity;
import lombok.Data;
/**
 * Created by vincent on 2022/12/8
 */
@Data
public class Voucher {
    private String VoucherID;
    private String MT;
    private String MaterialNO;
    private String CenterID;
    private String Plant;
    private String Loc;
    private String Batch;
    private Double TotalNum;
    private Integer TotalCount;
    private String AccDate;
    private String VBELN;
    private String Customer;
    private Double ExpectedWeight;
    private String Container;
    private String TruckNO;
    private String LastUpdatedDate;
    private Integer State;
}
src/main/java/com/zy/common/service/erp/entity/VoucherDetail.java
New file
@@ -0,0 +1,19 @@
package com.zy.common.service.erp.entity;
import lombok.Data;
/**
 * Created by vincent on 2022/12/8
 */
@Data
public class VoucherDetail {
    private String VoucherID;
    private String Barcode;
    private String PickID;
    private String LastUpdatedDate;
}
src/main/java/com/zy/core/thread/LedThread.java
@@ -78,7 +78,10 @@
            sb.append("目标站:").append(command.getStaNo()).append("\n");
            if (!command.isEmptyMk()) {
                for (MatDto matDto : command.getMatDtos()) {
                    sb.append(matDto.getMatnr()).append("-").append(matDto.getBatch()).append("\n");
                    sb.append(matDto.getOrderNo()).append("\n");
                    sb.append(matDto.getMatnr()).append("\n");
                    sb.append(matDto.getModel()).append("\n");
                    sb.append(matDto.getTotal()).append("/").append(matDto.getCount()).append("\n");
                }
            }
            sb.append("\n");
src/main/resources/application.yml
@@ -38,6 +38,13 @@
wms:
  url: 10.10.10.201:8080/ynwms
erp:
  db:
    driver_class_name: com.microsoft.sqlserver.jdbc.SQLServerDriver
    ur: jdbc:sqlserver://10.20.46.23:1433;databasename=POY_ASRS
    username: poy-asrs
    password: Poy@2022
# 下位机配置
wcs-slave:
  # 双深
src/main/resources/mapper/OrderDetlMapper.xml
New file
@@ -0,0 +1,215 @@
<?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.mapper.OrderDetlMapper">
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.zy.asrs.entity.OrderDetl">
        <id column="id" property="id" />
        <result column="order_id" property="orderId" />
        <result column="order_no" property="orderNo" />
        <result column="anfme" property="anfme" />
        <result column="qty" property="qty" />
        <result column="matnr" property="matnr" />
        <result column="maktx" property="maktx" />
        <result column="batch" property="batch" />
        <result column="specs" property="specs" />
        <result column="model" property="model" />
        <result column="color" property="color" />
        <result column="brand" property="brand" />
        <result column="unit" property="unit" />
        <result column="price" property="price" />
        <result column="sku" property="sku" />
        <result column="units" property="units" />
        <result column="barcode" property="barcode" />
        <result column="origin" property="origin" />
        <result column="manu" property="manu" />
        <result column="manu_date" property="manuDate" />
        <result column="item_num" property="itemNum" />
        <result column="safe_qty" property="safeQty" />
        <result column="weight" property="weight" />
        <result column="length" property="length" />
        <result column="volume" property="volume" />
        <result column="three_code" property="threeCode" />
        <result column="supp" property="supp" />
        <result column="supp_code" property="suppCode" />
        <result column="be_batch" property="beBatch" />
        <result column="dead_time" property="deadTime" />
        <result column="dead_warn" property="deadWarn" />
        <result column="source" property="source" />
        <result column="inspect" property="inspect" />
        <result column="danger" property="danger" />
        <result column="status" property="status" />
        <result column="create_by" property="createBy" />
        <result column="create_time" property="createTime" />
        <result column="update_by" property="updateBy" />
        <result column="update_time" property="updateTime" />
        <result column="memo" property="memo" />
    </resultMap>
    <select id="selectItem" resultMap="BaseResultMap">
        select * from man_order_detl
        where 1=1
        and order_id = #{orderId}
        and matnr = #{matnr}
        <choose>
            <when test="batch != null and batch != ''">
                and batch = #{batch}
            </when>
            <otherwise>
                and (batch IS NULL OR batch = '')
            </otherwise>
        </choose>
    </select>
    <select id="selectItemByOrderNo" resultMap="BaseResultMap">
        select * from man_order_detl
        where 1=1
        and order_no = #{orderNo}
        and matnr = #{matnr}
        <if test="batch!=null and batch!='' ">
            and batch = #{batch}
        </if>
    </select>
    <select id="selectItemNoneOfBatch" resultMap="BaseResultMap">
        select top 1 * from man_order_detl
        where 1=1
        and order_no = #{orderNo}
        and matnr = #{matnr}
    </select>
    <select id="selectItemOfBatch" resultMap="BaseResultMap">
        select top 1 * from man_order_detl
        where 1=1
        and matnr = #{matnr}
        and batch = #{batch}
    </select>
    <select id="selectWorkingDetls" resultMap="BaseResultMap">
        select * from man_order_detl
        where 1=1
        and order_id = #{orderId}
        and qty &lt; anfme
    </select>
    <sql id="pakOutPageCondition">
        <if test="order_id!=null and order_id!='' ">
            and mod.order_id = #{order_id}
        </if>
        <if test="matnr!=null and matnr!='' ">
            and mod.matnr like '%' + #{matnr} + '%'
        </if>
        <if test="maktx!=null and maktx!='' ">
            and mod.maktx like '%' + #{maktx} + '%'
        </if>
        <if test="batch!=null and batch!='' ">
            and mod.batch like '%' + #{batch} + '%'
        </if>
    </sql>
    <select id="getPakoutPage" resultMap="BaseResultMap">
        select * from
        (
            select
            ROW_NUMBER() over (order by mo.create_time desc) as row,
            mod.*
            from man_order_detl mod
            inner join man_order mo on mod.order_id = mo.id
            inner join man_doc_type mdt on mo.doc_type = mdt.doc_id
            where 1=1
            and mo.settle &lt;= 2
            and mo.status = 1
            and mdt.pakout = 1
            <include refid="pakOutPageCondition"></include>
        ) t where t.row between ((#{pageNumber}-1)*#{pageSize}+1) and (#{pageNumber}*#{pageSize})
    </select>
    <select id="getPakoutPageCount" parameterType="java.util.Map" resultType="java.lang.Integer">
        select
        count(1)
        from man_order_detl mod
        inner join man_order mo on mod.order_id = mo.id
        inner join man_doc_type mdt on mo.doc_type = mdt.doc_id
        where 1=1
        and mo.settle &lt;= 2
        and mo.status = 1
        and mdt.pakout = 1
        <include refid="pakOutPageCondition"></include>
    </select>
    <update id="increaseAnfme">
        update man_order_detl
        set anfme = anfme + #{qty}
        where 1=1
        and order_id = #{orderId}
        and matnr = #{matnr}
        <choose>
            <when test="batch != null and batch != ''">
                and batch = #{batch}
            </when>
            <otherwise>
                and (batch IS NULL OR batch = '')
            </otherwise>
        </choose>
    </update>
    <update id="increase">
        update man_order_detl
        set qty = qty + #{qty}
        where 1=1
        and order_id = #{orderId}
        and matnr = #{matnr}
        <choose>
            <when test="batch != null and batch != ''">
                and batch = #{batch}
            </when>
            <otherwise>
                and (batch IS NULL OR batch = '')
            </otherwise>
        </choose>
    </update>
    <update id="decrease">
        update man_order_detl
        set qty = qty - #{qty}
        where 1=1
        and order_no = #{orderNo}
        and matnr = #{matnr}
        <choose>
            <when test="batch != null and batch != ''">
                and batch = #{batch}
            </when>
            <otherwise>
                and (batch IS NULL OR batch = '')
            </otherwise>
        </choose>
    </update>
    <update id="modifyStatus">
        update man_order_detl
        set status = #{status}
        where 1=1
        and order_id = #{orderId}
    </update>
    <select id="selectRemainder" resultMap="BaseResultMap">
        select
        *
        from man_order_detl
        where 1=1
        and anfme > qty
        and order_id = #{orderId}
    </select>
    <select id="selectByMatnr" resultMap="BaseResultMap">
        select
        *
        from man_order_detl
        where 1=1
        and matnr = #{matnr}
    </select>
</mapper>
src/main/resources/mapper/OrderMapper.xml
New file
@@ -0,0 +1,72 @@
<?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.mapper.OrderMapper">
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.zy.asrs.entity.Order">
        <id column="id" property="id" />
        <result column="uuid" property="uuid" />
        <result column="order_no" property="orderNo" />
        <result column="order_time" property="orderTime" />
        <result column="doc_type" property="docType" />
        <result column="item_id" property="itemId" />
        <result column="item_name" property="itemName" />
        <result column="allot_item_id" property="allotItemId" />
        <result column="def_number" property="defNumber" />
        <result column="number" property="number" />
        <result column="cstmr" property="cstmr" />
        <result column="cstmr_name" property="cstmrName" />
        <result column="tel" property="tel" />
        <result column="oper_memb" property="operMemb" />
        <result column="total_fee" property="totalFee" />
        <result column="discount" property="discount" />
        <result column="discount_fee" property="discountFee" />
        <result column="other_fee" property="otherFee" />
        <result column="act_fee" property="actFee" />
        <result column="pay_type" property="payType" />
        <result column="salesman" property="salesman" />
        <result column="account_day" property="accountDay" />
        <result column="post_fee_type" property="postFeeType" />
        <result column="post_fee" property="postFee" />
        <result column="pay_time" property="payTime" />
        <result column="send_time" property="sendTime" />
        <result column="ship_name" property="shipName" />
        <result column="ship_code" property="shipCode" />
        <result column="settle" property="settle" />
        <result column="status" property="status" />
        <result column="create_by" property="createBy" />
        <result column="create_time" property="createTime" />
        <result column="update_by" property="updateBy" />
        <result column="update_time" property="updateTime" />
        <result column="memo" property="memo" />
    </resultMap>
    <select id="selectByOrderNo" resultMap="BaseResultMap">
        select top 1 *
        from man_order
        where 1=1
        and order_no = #{orderNo}
    </select>
    <update id="updateSettle">
        update man_order
        set settle = #{settle}
        ,update_time = getdate()
        <if test="userId != null">
            ,update_by = #{userId}
        </if>
        where 1=1
        and id = #{orderId}
    </update>
    <select id="selectComplete" resultMap="BaseResultMap">
        select top 5 *
        from man_order
        where 1=1
        and settle = 4
        and status = 1
        order by create_time asc
    </select>
</mapper>