| | |
| | | |
| | | |
| | | import java.text.DecimalFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.Instant; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * Created by vincent on 2020/8/27 |
| | |
| | | } |
| | | return msgBuilder.toString(); |
| | | } |
| | | } |
| | | |
| | | public static boolean isValidFormat(String dateStr, String format) { |
| | | SimpleDateFormat sdf = new SimpleDateFormat(format); |
| | | sdf.setLenient(false); // 严格模式,必须完全匹配格式 |
| | | try { |
| | | sdf.parse(dateStr); |
| | | return true; |
| | | } catch (ParseException e) { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | public static Date getFormateDate(String datestr) { |
| | | //字符串转日期 |
| | | DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | LocalDateTime parse = LocalDateTime.parse(datestr, dateTimeFormatter); |
| | | Instant instant = parse.atZone(ZoneId.systemDefault()).toInstant(); |
| | | Date date = Date.from(instant); |
| | | return date; |
| | | } |
| | | |
| | | /** |
| | |
| | | return Integer.parseInt(locNo.substring(0, 2)); |
| | | } |
| | | throw new RuntimeException("库位解析异常"); |
| | | } |
| | | |
| | | /** |
| | | * 将 1-1-1 格式的库位转换为 0100101 格式 (排-列-层) |
| | | * 兼容 1-11-1 -> 0101101 |
| | | * @param locStr 1-1-1 |
| | | * @return 0100101 |
| | | */ |
| | | public static String convertLocFormat(String locStr) { |
| | | if (Cools.isEmpty(locStr)) { |
| | | return null; |
| | | } |
| | | String[] split = locStr.split("-"); |
| | | if (split.length != 3) { |
| | | return locStr; |
| | | } |
| | | return zerofill(split[0].trim(), 2) + zerofill(split[1].trim(), 3) + zerofill(split[2].trim(), 2); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | if ((curRow - sRow) % 4 == 0) { |
| | | necessaryParameters[1] = curRow; //curRow 最深库位排 |
| | | necessaryParameters[2] = (curRow - sRow + 2) / 4 + sCrnNo - 1; //crnNo 堆垛机号 |
| | | necessaryParameters[2] = (curRow - sRow + 2) / 4 + sCrnNo; //crnNo 堆垛机号 |
| | | necessaryParameters[3] = curRow + 1; //nearRow 最浅库位排 |
| | | } else if ((curRow - sRow + 1) % 4 == 0) { |
| | | necessaryParameters[1] = curRow; //curRow 最深库位排 |
| | |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 日期转换为字符串 |
| | | * @param date 日期 |
| | | * @param format 格式 |
| | | * @return 字符串 |
| | | */ |
| | | public static String dateToStr(Date date, String format) { |
| | | SimpleDateFormat sdf = new SimpleDateFormat(format); |
| | | return sdf.format(date); |
| | | } |
| | | |
| | | |
| | | //将wms库位号转换成wcs库位号 |
| | | public static String WMSLocToWCSLoc(String locNo) { |
| | | String row = locNo.substring(0, 2); |
| | | int i = 0; |
| | | for (char c : row.toCharArray()) { |
| | | if (c == '0') { |
| | | i++; |
| | | }else { |
| | | break; |
| | | } |
| | | } |
| | | row = row.substring(i); |
| | | int j = 0; |
| | | String boy = locNo.substring(2, 5); |
| | | for (char c : boy.toCharArray()) { |
| | | if (c == '0') { |
| | | j++; |
| | | }else { |
| | | break; |
| | | } |
| | | } |
| | | boy = boy.substring(j); |
| | | int k = 0; |
| | | String lev = locNo.substring(5); |
| | | for (char c : lev.toCharArray()) { |
| | | if (c == '0') { |
| | | k++; |
| | | }else { |
| | | break; |
| | | } |
| | | } |
| | | lev = lev.substring(k); |
| | | return row + "-" + boy + "-" + lev; |
| | | } |
| | | |
| | | } |