自动化立体仓库 - WMS系统
#
Junjie
2025-06-18 e2566299e61924731b9ffc0de9d4afd72cdf683b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package com.zy.asrs.utils;
 
import com.core.common.Cools;
import com.core.common.SpringUtils;
import com.core.exception.CoolException;
import com.zy.asrs.entity.Mat;
import com.zy.asrs.service.MatService;
import lombok.extern.slf4j.Slf4j;
 
import java.math.BigDecimal;
 
/**
 * Created by vincent on 2022/4/23
 */
@Slf4j
public class MatUtils {
 
    //
    public static Mat analyseMat(String uuid) {
        try {
            String[] split = uuid.split("-");
            String matnr = split[0] + "-" + split[1];
            String serial = split[2];
            Mat mat = new Mat();
            mat.setMatnr(matnr);
            mat.setBarcode(serial);
            mat.setModel(split[0]);
            return mat;
        } catch (Exception e) {
            log.error("", e);
            throw new CoolException(uuid + "条码打包上线错误");
        }
    }
 
    public static Double calcWeight(String matnr, Double anfme) {
        MatService matService = SpringUtils.getBean(MatService.class);
        //更新辅料
        Mat mat = matService.selectByMatnr(matnr);
        if (mat == null) {
            throw new CoolException("物料信息不存在");
        }
 
        //转换关系
        String origin = mat.getOrigin();
        if (Cools.isEmpty(origin)) {
            throw new CoolException("主辅数量转换公式不存在");
        }
        String[] split = origin.split("/");
        //辅单位
 
        BigDecimal anfmeBigDecimal = BigDecimal.valueOf(anfme);
        BigDecimal origin1 = new BigDecimal(split[1]);
        BigDecimal origin0 = new BigDecimal(split[0]);
 
        BigDecimal divideResult1 = anfmeBigDecimal.divide(origin1);
        BigDecimal weightBigDecimal = divideResult1.divide(origin0);
        return weightBigDecimal.doubleValue();
    }
 
}