Ubuntu 20.04安装minio并设置自启动

https://blog.csdn.net/qq_42327090/article/details/139657438

一、下载

将minio软件下载安装到指定文件/usr/local/Minio/minio,并赋予可执行的权限

wget -O /usr/local/Minio/minio https://dl.minio.io/server/minio/release/linux-amd64/minio
 
sudo chmod +x /usr/local/Minio/minio

二、运行minio

 创建minio的存储文件夹

sudo mkdir /minio

执行命令,启动minio服务

    cd /usr/local/Minio
     
    sudo ./minio server /minio

浏览器中访问:http://127.0.0.1:9000,并输入用户名:minioadmin,密码:minioadmin,即可成功登录。 此时可能已经发现网页上的地址重定向到了http://127.0.0.1:42575/login 如果我们不想每次启动都要重定向一个随即的端口,那么我们启动的时候需要指定webUI的端口,将刚才启动的服务停掉,ctrl+c即可,然后执行如下命令

sudo ./minio server --address :9000 --console-address :9001  /minio

此时,我们指定了控制台的端口为9001,此时再访问http://127.0.0.1:9000 或者访问http://127.0.0.1:9001 都可以访问。

三、配置自启动

如果不配置自启动,每次我们关机重启之后都要手动的去执行启动命令,就比较麻烦,所以我们就需要将Minio配置为系统服务,这样在系统重启的时候就会自动启动。

1、编写配置文件

为了统一管理minio的配置参数,我们可以将参数配置在一个文件中方便管理。在/etc/default文件夹下创建minio配置文件

sudo gedit /etc/default/minio

将如下内容粘贴进去,并保存。

# 指定数据存储目录(注意:这个目录要存在且拥有相对应的权限)
# MINIO_VOLUMES="/minio"
 
# 监听端口
# MINIO_OPTS="--address :9000 --console-address :9001"
 
# 默认的用户名和密码
MINIO_ROOT_USER="minioadmin"
MINIO_ROOT_PASSWORD="minioadmin"
 
# 区域值,标准格式是“国家-区域-编号”,
MINIO_REGION="cn-north-1"

2、编写服务文件

创建minio.service服务文件,并写入配置信息

sudo gedit /usr/lib/systemd/system/minio.service

    将如下内容粘贴进去:

[Unit]
Description=MinIO
Documentation=https://docs.min.io
Wants=network-online.target
After=network-online.target
AssertFileIsExecutable=/usr/local/Minio/minio
[Service]
WorkingDirectory=/usr/local/
 
#ProtectProc=invisible
 
# 指向3.1节中的配置文件
EnvironmentFile=/etc/default/minio
 
# ExecStartPre=/bin/bash -c "if [ -z \"${MINIO_VOLUMES}\" ]; then echo \"Variable MINIO_VOLUMES not set in /etc/default/minio\"; exit 1; fi"
ExecStart=/usr/local/Minio/minio server --address :9000 --console-address :9001 /minio
 
# Let systemd restart this service always
Restart=always
 
# Specifies the maximum (1M) file descriptor number that can be opened by this process
LimitNOFILE=1048576
 
# Specifies the maximum number of threads this process can create
TasksMax=infinity
 
# Disable timeout logic and wait until process is stopped
TimeoutStopSec=infinity
SendSIGKILL=no
SuccessExitStatus=0
 
[Install]
WantedBy=multi-user.target
Alias=minio.service

保存即可。

3、刷新配置,使服务生效

# 重新加载服务配置文件,使服务生效
sudo systemctl daemon-reload
 
# 将服务设置为开机启动
sudo systemctl enable minio
 
# 服务立即启动
sudo systemctl start minio
 
# 查看minio服务当前状态
systemctl status minio

执行上面之后,显示结果如下

如此,就算系统关机重启,minio也会随系统自动启动,不需要手动启动了。

订单状态实现状态机机制

package com.honghan.trade.statemachine;

import com.honghan.common.core.enums.OrderStatus;
import com.honghan.trade.enums.PaymentMethod;

import java.util.HashMap;
import java.util.Map;

public class OrderStateMachine {
    private final Map<PaymentMethod, Map<OrderStatus, OrderStatus>> transitions;
    private OrderStatus currentStatus;

    public OrderStateMachine() {
        this.transitions = new HashMap<>();
        initializeTransitions();
    }

//这里规定好订单的每步状态流向
    private void initializeTransitions() {
        // 先款后货状态转换
        Map<OrderStatus, OrderStatus> prepayTransitions = new HashMap<>();
        prepayTransitions.put(OrderStatus.WAIT_TALK, OrderStatus.CONFIRMED);
        prepayTransitions.put(OrderStatus.CONFIRMED, OrderStatus.OFFLINE_CONFIRMED);
        prepayTransitions.put(OrderStatus.OFFLINE_CONFIRMED, OrderStatus.PAYED);
        prepayTransitions.put(OrderStatus.PAYED, OrderStatus.SENDING);
        prepayTransitions.put(OrderStatus.SENDING, OrderStatus.RECEIVE);
        prepayTransitions.put(OrderStatus.RECEIVE, OrderStatus.COUNT);
        transitions.put(PaymentMethod.PREPAY, prepayTransitions);

        // 先付订金后付尾款状态转换 / 多次付款状态转换
        Map<OrderStatus, OrderStatus> depositTransitions = new HashMap<>();
        depositTransitions.put(OrderStatus.WAIT_TALK, OrderStatus.CONFIRMED);
        depositTransitions.put(OrderStatus.CONFIRMED, OrderStatus.OFFLINE_CONFIRMED);
        depositTransitions.put(OrderStatus.OFFLINE_CONFIRMED, OrderStatus.PAYED);
        depositTransitions.put(OrderStatus.PAYED, OrderStatus.SENDING);
        depositTransitions.put(OrderStatus.SENDING, OrderStatus.RECEIVE);
        depositTransitions.put(OrderStatus.RECEIVE, OrderStatus.COUNT);
        transitions.put(PaymentMethod.DEPOSIT, depositTransitions);
        transitions.put(PaymentMethod.MULTI_PAY, depositTransitions);

        // 先货后款状态转换
        Map<OrderStatus, OrderStatus> postpayTransitions = new HashMap<>();
        postpayTransitions.put(OrderStatus.WAIT_TALK, OrderStatus.PARTIAL_SHIPMENTS);
        postpayTransitions.put(OrderStatus.PARTIAL_SHIPMENTS, OrderStatus.COUNT);
        transitions.put(PaymentMethod.POSTPAY, postpayTransitions);
    }

    public OrderStatus getNextStatus(OrderStatus currentStatus, PaymentMethod method) {
        return getNextStatus(currentStatus, method, false); // 如果没有找到对应的状态转换
    }

    public OrderStatus getNextStatus(OrderStatus currentStatus, PaymentMethod method, boolean userWantsToCompleteOrder) {
        if (currentStatus == OrderStatus.RECEIVE) {
            return userWantsToCompleteOrder ? OrderStatus.COUNT : OrderStatus.REFUNDING;
        }

        Map<OrderStatus, OrderStatus> methodTransitions = transitions.get(method);
        if (methodTransitions != null) {
            return methodTransitions.get(currentStatus);
        }
        return null; // 如果没有找到对应的状态转换
    }

    public OrderStatus getCurrentStatus() {
        return currentStatus;
    }

    public void setCurrentStatus(OrderStatus newStatus) {
        this.currentStatus = newStatus;
    }
}
package com.honghan.common.core.enums;

/**
 * @Description 平台通用订单枚举
 * @author °DJ°
 * @date 2023/3/17 18:22
 * @Motto ^V^你们都要好好的^V^
 */
public enum OrderStatus {


    CREATE(1, "待确认"),    //提货单、3发货单,4退货单
    CONFIRMED(2, "待付款"),
    SENDING(3, "待收货"),
    RECEIVE(4, "已收货"),
    WAIT_TALK(50, "待询价"),
    OFFLINE_CONFIRMED(60, "付款待确认"),//线下打款待确认-确认生成对账单
    BILL(70, "已结算"),//
    PAYED(80, "待发货"),//
    PART_PAYED(81,"部分付款"),
    BILL_APPLY(82,"可提货"),
    //PICK_UP(81, "备货中"),
    COUNT(90, "已完成"),//
    FINISH_ORDER(91, "已对账"),//已对账 目前用这个
    REFUSE(98, "已驳回"),
    CANCEL(99, "已取消"),
    CANCELLED(130,"已关闭"),
    PARTIAL_SHIPMENTS(140,"分批发货中"),

    /*售后的状态*/
    REFUNDING(7, "退款中"),
    REFUND(120, "退款完成"); //已退款统一用这个值

    private Integer value;

    private String name;

    OrderStatus(int value, String name) {
        this.value = value;
        this.name = name;
    }

    public static boolean contains(int value) {
        for (OrderStatus anEnum : OrderStatus.values()) {
            if (anEnum.value == value) {
                return true;
            }
        }
        return false;
    }
    public static String getDesc(int value) {
        for (OrderStatus anEnum : OrderStatus.values()) {
            if (anEnum.value == value) {
                return anEnum.getName();
            }
        }
        return "";
    }
    public static String getNameByValue(Integer value){
        for(OrderStatus k : OrderStatus.values()){
            if(value.equals(k.getValue())){
                return k.name;
            }
        }
        return null;
    }

    public static OrderStatus getOrderStatusEnum(Integer value) {
        for (OrderStatus orderStatusEnum: OrderStatus.values()) {
            if (orderStatusEnum.value.equals(value)) {
                return orderStatusEnum;
            }
        }
        return null;
    }


    public Integer getValue() {
        return value;
    }

    public void setValue(int value) {
        this.value = value;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
package com.honghan.trade.enums;

public enum PaymentMethod {
    PREPAY(1, "先款后货"),
    DEPOSIT(2, "先付订金后付尾款"),
    POSTPAY(3, "先货后款"),
    MULTI_PAY(4, "多次付款");

    private final int value;
    private final String description;

    PaymentMethod(int value, String description) {
        this.value = value;
        this.description = description;
    }

    public int getValue() {
        return value;
    }

    public String getDescription() {
        return description;
    }

    public static PaymentMethod fromValue(int value) {
        for (PaymentMethod method : PaymentMethod.values()) {
            if (method.value == value) {
                return method;
            }
        }
        return null;
    }
}
package com.honghan.trade.enums;

public enum PaymentMethod {
    PREPAY(1, "先款后货"),
    DEPOSIT(2, "先付订金后付尾款"),
    POSTPAY(3, "先货后款"),
    MULTI_PAY(4, "多次付款");

    private final int value;
    private final String description;

    PaymentMethod(int value, String description) {
        this.value = value;
        this.description = description;
    }

    public int getValue() {
        return value;
    }

    public String getDescription() {
        return description;
    }

    public static PaymentMethod fromValue(int value) {
        for (PaymentMethod method : PaymentMethod.values()) {
            if (method.value == value) {
                return method;
            }
        }
        return null;
    }
}
package com.honghan.trade.util;

import com.honghan.common.core.enums.OrderStatus;
import com.honghan.trade.api.domain.TradeOrder;
import com.honghan.trade.enums.PaymentMethod;
import com.honghan.trade.statemachine.OrderStateMachine;

/**
 * 订单状态机工具类
 */
public class OrderStateMachineUtil {

    private static OrderStateMachine orderStateMachine = new OrderStateMachine();


    public static void updateOrderStatus(TradeOrder tradeOrder) {
        OrderStatus currentStatus = OrderStatus.getOrderStatusEnum(tradeOrder.getStatus());
        PaymentMethod paymentMethod = PaymentMethod.fromValue(tradeOrder.getSettlePayType());
        OrderStatus nextStatus = orderStateMachine.getNextStatus(currentStatus, paymentMethod, false);
        tradeOrder.setStatus(nextStatus.getValue());
    }

    public static void updateOrderStatus(TradeOrder tradeOrder, OrderStatus currentStatus) {
        tradeOrder.setStatus(currentStatus.getValue());
    }

    public static void updateOrderNextStatus(TradeOrder tradeOrder, OrderStatus currentStatus) {
        PaymentMethod paymentMethod = PaymentMethod.fromValue(tradeOrder.getSettlePayType());
        OrderStatus nextStatus = orderStateMachine.getNextStatus(currentStatus, paymentMethod, false);
        tradeOrder.setStatus(currentStatus.getValue());
    }

}

【投诉】皇家美素佳儿2段奶粉里面有异物

【投诉】皇家美素佳儿2段奶粉里面有异物

京东自营店购买的

喝了一年的爱他美卓傲奶粉都没这问题
想着给换成皇家奶粉

谁知道喝了三分之二 发现有异物

垃圾皇家

投诉到底!!!





word转xml的方法

和大佬学的

先把你需要的模版文档弄好成docx格式,再把后缀改成.zip格式 获取里面的document.xml文件,在xml中把你要替换的参数写成表达式如:${productName},在项目中通过代码填充productName参数,进行测试)

也可以把表达式先写到docx文件中,在改后缀。。。亲测

easyexcel导出风格

//设置Excel head高度
@HeadRowHeight(30)
//设置Excel默认列宽
@ColumnWidth(14)
//设置Excel 正文字体样式
@ContentFontStyle(fontName = "宋体", fontHeightInPoints = 12)

链接:https://blog.csdn.net/pbl13071138970/article/details/119082481

导出去除不必要的字段,只导出注解的字段

@ExcelIgnoreUnannotated
 //这里再次设置列宽会覆盖上面设置的默认列宽
    @ColumnWidth(23)
    @ExcelProperty(value = "订单编号", order = 1)
    private String identifier;