| | |
| | | package com.zy.asrs.wms.utils; |
| | | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.zy.asrs.framework.common.Cools; |
| | | import com.zy.asrs.wms.asrs.entity.dto.MatUniqueObjDto; |
| | | import com.zy.asrs.wms.asrs.entity.param.FieldParam; |
| | | import com.zy.asrs.wms.common.constant.Constants; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | import java.util.*; |
| | | import java.util.function.BiConsumer; |
| | | import java.util.function.Function; |
| | | |
| | |
| | | * Created by vincent on 2023/3/14 |
| | | */ |
| | | public class Utils { |
| | | |
| | | public static final String _LINK = "-"; |
| | | |
| | | public static String getMatUniqueKey(String matnr, String batch, List<FieldParam> params) { |
| | | MatUniqueObjDto dto = new MatUniqueObjDto(); |
| | | dto.setMatnr(matnr); |
| | | dto.setBatch(batch); |
| | | |
| | | ArrayList<FieldParam> list = new ArrayList<>(); |
| | | for (FieldParam param : params) { |
| | | FieldParam fieldParam = new FieldParam(); |
| | | list.add(fieldParam); |
| | | |
| | | String value = ""; |
| | | if (!Cools.isEmpty(param.getValue())) { |
| | | value = param.getValue().toString(); |
| | | } |
| | | |
| | | fieldParam.setName(param.getName()); |
| | | fieldParam.setType(param.getType()); |
| | | fieldParam.setValue(value); |
| | | } |
| | | dto.setParams(list); |
| | | String encode = Base64.getEncoder().encodeToString(JSON.toJSONString(dto).getBytes()); |
| | | return encode; |
| | | } |
| | | |
| | | public static MatUniqueObjDto getMatUniqueObj(String matUniqueKey) { |
| | | byte[] decode = Base64.getDecoder().decode(matUniqueKey); |
| | | String decodeStr = new String(decode); |
| | | MatUniqueObjDto dto = JSON.parseObject(decodeStr, MatUniqueObjDto.class); |
| | | return dto; |
| | | } |
| | | |
| | | public static boolean checkMatSame(String matnr1, String batch1, List<FieldParam> params1, String matnr2, String batch2, List<FieldParam> params2) { |
| | | if (!matnr1.equals(matnr2)) { |
| | | return false; |
| | | } |
| | | |
| | | if (batch1 != null && batch2 != null) { |
| | | if(!batch1.equals(batch2)) { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | boolean check = true; |
| | | if(params1 != null && params2 != null) { |
| | | if(params1.size() != params2.size()) { |
| | | return false; |
| | | } |
| | | |
| | | for (int i = 0; i < params1.size(); i++) { |
| | | FieldParam param1 = params1.get(i); |
| | | FieldParam param2 = params2.get(i); |
| | | |
| | | if (!param1.getName().equals(param2.getName())) { |
| | | check = false; |
| | | break; |
| | | } |
| | | |
| | | if(Cools.isEmpty(param1.getValue()) && Cools.isEmpty(param2.getValue())) { |
| | | continue; |
| | | } |
| | | |
| | | if(!param1.getValue().equals(param2.getValue())) { |
| | | check = false; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | return check; |
| | | } |
| | | |
| | | /** |
| | | * 通过库位号获取 排 |
| | | */ |
| | | public static int getRow(String locNo) { |
| | | if (!Cools.isEmpty(locNo)) { |
| | | String[] split = locNo.split(_LINK); |
| | | return Integer.parseInt(split[0]); |
| | | } |
| | | throw new RuntimeException("库位解析异常"); |
| | | } |
| | | |
| | | /** |
| | | * 通过库位号获取 列 |
| | | */ |
| | | public static int getBay(String locNo) { |
| | | if (!Cools.isEmpty(locNo)) { |
| | | String[] split = locNo.split(_LINK); |
| | | return Integer.parseInt(split[1]); |
| | | } |
| | | throw new RuntimeException("库位解析异常"); |
| | | } |
| | | |
| | | /** |
| | | * 通过库位号获取 层 |
| | | */ |
| | | public static int getLev(String locNo) { |
| | | if (!Cools.isEmpty(locNo)) { |
| | | String[] split = locNo.split(_LINK); |
| | | return Integer.parseInt(split[2]); |
| | | } |
| | | throw new RuntimeException("库位解析异常"); |
| | | } |
| | | |
| | | public static String getLocNo(Number row, Number bay, Number lev) { |
| | | return row + _LINK + bay + _LINK + lev; |
| | | } |
| | | |
| | | /** |
| | | * List转为树形结构 |
| | |
| | | sb.append(c); |
| | | } |
| | | |
| | | return sb.toString(); |
| | | return "`" + sb.toString() + "`"; |
| | | } |
| | | } |
| | | |