package com.zy.asrs.utils;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.common.Arith;
import com.core.common.Cools;
import com.core.common.SpringUtils;
import com.core.exception.CoolException;
import com.zy.asrs.entity.BasCrnp;
import com.zy.asrs.entity.BasDevp;
import com.zy.asrs.entity.LocMast;
import com.zy.asrs.entity.RowLastno;
import com.zy.asrs.service.BasCrnpService;
import com.zy.asrs.service.BasDevpService;
import com.zy.asrs.service.LocMastService;
import com.zy.asrs.service.RowLastnoService;
import com.zy.common.CodeBuilder;
import com.zy.common.entity.Parameter;
import com.zy.common.model.LocDetlDto;
import com.zy.common.properties.SlaveProperties;
import com.zy.common.service.CommonService;
import com.zy.system.service.UserService;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Locale;
/**
* Created by vincent on 2020/8/27
*/
public class Utils {
private static final DecimalFormat fmt = new DecimalFormat("##0.00");
public static float scale(Float f) {
if (f == null || f == 0f || Float.isNaN(f)) {
return 0f;
}
return (float) Arith.multiplys(2, f, 1);
}
public static int armStaNo(int armNo,int staNo) {
switch (armNo){
case 1:
switch (staNo){
case 0:
return 7;
case 1:
return 8;
case 2:
return 101;
case 3:
return 102;
default:
return 0;
}
case 2:
switch (staNo){
case 0:
return 5;
case 1:
return 6;
case 2:
return 101;
case 3:
return 102;
default:
return 0;
}
case 3:
switch (staNo){
case 0:
return 3;
case 1:
return 4;
case 2:
return 101;
case 3:
return 102;
default:
return 0;
}
case 4:
switch (staNo){
case 0:
return 1;
case 1:
return 2;
case 2:
return 101;
case 3:
return 102;
default:
return 0;
}
case 5:
switch (staNo){
case 0:
return 11;
case 1:
return 12;
case 2:
return 101;
case 3:
return 102;
default:
return 0;
}
case 6:
switch (staNo){
case 0:
return 13;
case 1:
return 14;
case 2:
return 101;
case 3:
return 102;
default:
return 0;
}
default:
return 0;
}
}
public static Integer getStationStorageArea(Integer stationId) {
if (stationId == null || stationId <= 0) {
return null;
}
BasDevpService basDevpService = SpringUtils.getBean(BasDevpService.class);
BasDevp station = basDevpService.selectById(stationId);
if (station == null) {
return null;
}
return parseStorageArea(station.getArea());
}
/**
* 生成入库找库位时的堆垛机优先顺序。
*
*
处理规则:
* 1. 先根据入库站点查询所属库区。
* 2. 先提取该库区内的堆垛机,并按可用空库位过滤不可用堆垛机。
* 3. 若当前库区没有满足条件的空库位,再补充其他库区的堆垛机。
* 4. 当 {@code locType1 = 1} 时,先返回低库位堆垛机,再把同批堆垛机的高库位追加到后面。
* 5. 对不存在、故障、不可入以及无空库位的堆垛机直接剔除。
* 6. 当物料为 {@code emptyPallet} 时,按空板入库优先规则重新排序。
*
*
返回结果中的每一项格式为:
* {@code {crnNo: 堆垛机号, locType1: 库位高低类型}}
*
* @param stationId 入库站点
* @param locType1 目标库位高低类型,1=低库位,2=高库位
* @param matnr 物料编码,传入 {@code emptyPallet} 时使用空板排序规则
* @return 按优先级排好序的堆垛机列表
*/
public static List