opt:优化枚举
This commit is contained in:
@@ -40,7 +40,7 @@ public enum StatusEnum {
|
|||||||
ERP_TYPE(ForkMap.of("PRD_MO", "10", "生产订单", "PUR_ReceiveBill", "11", "收料通知单",
|
ERP_TYPE(ForkMap.of("PRD_MO", "10", "生产订单", "PUR_ReceiveBill", "11", "收料通知单",
|
||||||
"SAL_SaleOrder", "12", "销售订单", "PRD_INSTOCK", "13", "生产入库单", "STK_InStock", "14", "采购入库单",
|
"SAL_SaleOrder", "12", "销售订单", "PRD_INSTOCK", "13", "生产入库单", "STK_InStock", "14", "采购入库单",
|
||||||
"PRD_PPBOM", "20", "生产用料清单", "PRD_PickMtrl", "21", "生产领料单",
|
"PRD_PPBOM", "20", "生产用料清单", "PRD_PickMtrl", "21", "生产领料单",
|
||||||
"ka7c19edf9d4b4b39b8cc4a06802163b0", "22", "简单生产领料单",
|
"SP_PickMtrl", "22", "简单生产领料单",
|
||||||
"STK_TransferDirect", "23", "调拨出库单", "SAL_RETURNSTOCK", "24", "销售退货单",
|
"STK_TransferDirect", "23", "调拨出库单", "SAL_RETURNSTOCK", "24", "销售退货单",
|
||||||
"PUR_MRB", "25", "采购退料单", "STK_MisDelivery", "26", "其他出库单")),
|
"PUR_MRB", "25", "采购退料单", "STK_MisDelivery", "26", "其他出库单")),
|
||||||
|
|
||||||
|
|||||||
@@ -230,15 +230,15 @@ public class MdGruopDickServiceImpl extends ServiceImpl<MdGruopDickMapper, MdGru
|
|||||||
}
|
}
|
||||||
BmVehicleInfo vehicleInfo = iBmVehicleInfoService.vehileInfo(vehicle_code);
|
BmVehicleInfo vehicleInfo = iBmVehicleInfoService.vehileInfo(vehicle_code);
|
||||||
if (vehicleInfo == null) {
|
if (vehicleInfo == null) {
|
||||||
throw new BadRequestException(vehicle_code + "载具信息不存在");
|
throw new BadRequestException("第" + (i + 1) +"行,"+vehicle_code+ "载具编号不能为空");
|
||||||
}
|
}
|
||||||
List<MdPbVehicleMaterVo> vehicleMaters = iMdPbVehicleMaterService.getVehicleMaters(vehicle_code);
|
List<MdPbVehicleMaterVo> vehicleMaters = iMdPbVehicleMaterService.getVehicleMaters(vehicle_code);
|
||||||
if (!CollectionUtils.isEmpty(vehicleMaters)) {
|
if (!CollectionUtils.isEmpty(vehicleMaters)) {
|
||||||
throw new BadRequestException(vehicle_code + "存在信息,先出库确认在使用");
|
throw new BadRequestException("第" + (i + 1) +"行,"+vehicle_code+ "存在信息,先出库确认在使用");
|
||||||
}
|
}
|
||||||
MdMeMaterialbase materialCode = mdMeMaterialbaseService.getOne(new QueryWrapper<MdMeMaterialbase>().eq("material_code", material_code));
|
MdMeMaterialbase materialCode = mdMeMaterialbaseService.getOne(new QueryWrapper<MdMeMaterialbase>().eq("material_code", material_code));
|
||||||
if (materialCode == null) {
|
if (materialCode == null) {
|
||||||
throw new BadRequestException(material_code + "物料编码不存在");
|
throw new BadRequestException("第" + (i + 1) +"行,"+material_code+ "物料编码不存在");
|
||||||
}
|
}
|
||||||
materialCode.setSingle_weight(new BigDecimal(single_weight));
|
materialCode.setSingle_weight(new BigDecimal(single_weight));
|
||||||
//更新单重
|
//更新单重
|
||||||
|
|||||||
@@ -39,5 +39,6 @@ public class TaskInfo {
|
|||||||
private BigDecimal remaining_qty;
|
private BigDecimal remaining_qty;
|
||||||
private String form_data;
|
private String form_data;
|
||||||
private String product_area;
|
private String product_area;
|
||||||
|
private BigDecimal vehicleWeight;
|
||||||
private BigDecimal vehicle_weight;
|
private BigDecimal vehicle_weight;
|
||||||
}
|
}
|
||||||
@@ -31,10 +31,7 @@ import java.time.Duration;
|
|||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -63,6 +60,14 @@ public class CockpitServiceImpl implements CockpitService {
|
|||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM-dd");
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM-dd");
|
||||||
LocalDate today = LocalDate.now();
|
LocalDate today = LocalDate.now();
|
||||||
|
|
||||||
|
public static List<BigDecimal> weightList1 = new ArrayList<>();
|
||||||
|
public static List<BigDecimal> weightList2 = new ArrayList<>();
|
||||||
|
|
||||||
|
private static String vehicle_code1;
|
||||||
|
private static String vehicle_code2;
|
||||||
|
|
||||||
|
private static BigDecimal vehicleWeight1;
|
||||||
|
private static BigDecimal vehicleWeight2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询拣选台
|
* 查询拣选台
|
||||||
@@ -303,6 +308,124 @@ public class CockpitServiceImpl implements CockpitService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拣选任务
|
||||||
|
*/
|
||||||
|
public List<TaskInfo> pickingInfo1(String code) {
|
||||||
|
List<TaskInfo> taskList = cockpitMapper.getPickingTask(code);
|
||||||
|
if (ObjectUtil.isNotEmpty(taskList)) {
|
||||||
|
TaskInfo task = taskList.get(0);
|
||||||
|
if (StringUtils.isNotBlank(task.getForm_data())) {
|
||||||
|
PointInfo pointInfo = JSON.parseObject(task.getForm_data(), PointInfo.class);
|
||||||
|
if (StringUtils.isNotBlank(pointInfo.getProduct_area())) {
|
||||||
|
task.setProduct_area(pointInfo.getProduct_area());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String code1 = code;
|
||||||
|
if ("1308".equals(code)) {
|
||||||
|
code1 = "1207";
|
||||||
|
vehicle_code1 = task.getVehicle_code();
|
||||||
|
} else if ("1311".equals(code)) {
|
||||||
|
code1 = "1210";
|
||||||
|
vehicle_code2 = task.getVehicle_code();
|
||||||
|
}
|
||||||
|
BigDecimal theoryQty = BigDecimal.ZERO;
|
||||||
|
BigDecimal actual_weight = null;
|
||||||
|
try {
|
||||||
|
InteracteDto<Object> dto = InteracteDto.builder()
|
||||||
|
.service("wmsToAcsService")
|
||||||
|
.trace_id(MDC.get("trace_id"))
|
||||||
|
.type("getWeight")
|
||||||
|
.data(new JSONObject().fluentPut("device_code", code1))
|
||||||
|
.build();
|
||||||
|
//查询称重重量
|
||||||
|
TableDataInfo result = InterationUtil.notifyExt("/api/wmsToAcs/apply", (JSONObject) JSON.toJSON(dto));
|
||||||
|
if ("200".equals(result.getCode())) {
|
||||||
|
Object dataObj = result.getData();
|
||||||
|
if (dataObj != null) {
|
||||||
|
JSONObject data = JSONObject.parseObject(dataObj.toString());
|
||||||
|
if (data != null && data.containsKey("weight")) {
|
||||||
|
String weightStr = data.getString("weight");
|
||||||
|
if (ObjectUtil.isNotEmpty(weightStr)) {
|
||||||
|
actual_weight = new BigDecimal(weightStr.trim());
|
||||||
|
if ("1207".equals(code1)) {
|
||||||
|
getVehicleWeight(weightList1, code1);
|
||||||
|
} else {
|
||||||
|
getVehicleWeight(weightList2, code1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
log.error(ex.getMessage());
|
||||||
|
}
|
||||||
|
task.setActual_weight(actual_weight);
|
||||||
|
if (task.getActual_weight() != null && task.getSingle_weight() != null) {
|
||||||
|
if ("1207".equals(code1)) {
|
||||||
|
if (vehicleWeight1 != null && task.getActual_weight().compareTo(vehicleWeight1) > 0) {
|
||||||
|
task.setActual_weight(task.getActual_weight().subtract(vehicleWeight1).max(BigDecimal.ZERO).setScale(0, RoundingMode.DOWN));
|
||||||
|
//根据称重信息计算理论数量
|
||||||
|
if (task.getActual_weight().compareTo(BigDecimal.ZERO) > 0 && task.getSingle_weight().compareTo(BigDecimal.ZERO) > 0) {
|
||||||
|
//计算理论重量:称重-载具重量/单重 = 理论数量,理论数量!=需出数量:称重异常
|
||||||
|
theoryQty = task.getActual_weight().divide(task.getSingle_weight(), 0, RoundingMode.DOWN);
|
||||||
|
task.setActual_weight(task.getActual_weight().setScale(2, RoundingMode.DOWN));
|
||||||
|
}
|
||||||
|
task.setTheory_qty(theoryQty);
|
||||||
|
//计算剩余数量
|
||||||
|
BigDecimal remaining_qty = task.getQty().subtract(theoryQty).max(BigDecimal.ZERO).setScale(0, RoundingMode.DOWN);
|
||||||
|
task.setRemaining_qty(remaining_qty);
|
||||||
|
if (!task.getVehicle_code().equals(vehicle_code1)) {
|
||||||
|
vehicleWeight2 = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (vehicleWeight2 != null && task.getActual_weight().compareTo(vehicleWeight2) > 0) {
|
||||||
|
task.setActual_weight(task.getActual_weight().subtract(vehicleWeight2).max(BigDecimal.ZERO).setScale(0, RoundingMode.DOWN));
|
||||||
|
//根据称重信息计算理论数量
|
||||||
|
if (task.getActual_weight().compareTo(BigDecimal.ZERO) > 0 && task.getSingle_weight().compareTo(BigDecimal.ZERO) > 0) {
|
||||||
|
//计算理论重量:称重-载具重量/单重 = 理论数量,理论数量!=需出数量:称重异常
|
||||||
|
theoryQty = task.getActual_weight().divide(task.getSingle_weight(), 0, RoundingMode.DOWN);
|
||||||
|
task.setActual_weight(task.getActual_weight().setScale(2, RoundingMode.DOWN));
|
||||||
|
}
|
||||||
|
task.setTheory_qty(theoryQty);
|
||||||
|
//计算剩余数量
|
||||||
|
BigDecimal remaining_qty = task.getQty().subtract(theoryQty).max(BigDecimal.ZERO).setScale(0, RoundingMode.DOWN);
|
||||||
|
task.setRemaining_qty(remaining_qty);
|
||||||
|
if (!task.getVehicle_code().equals(vehicle_code2)) {
|
||||||
|
vehicleWeight2 = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//单重
|
||||||
|
task.setSingle_weight(task.getSingle_weight().setScale(2, RoundingMode.DOWN));
|
||||||
|
//需出数量
|
||||||
|
task.setAssign_qty(task.getAssign_qty().setScale(0, RoundingMode.DOWN));
|
||||||
|
task.setQty(task.getQty().setScale(0, RoundingMode.DOWN));
|
||||||
|
}
|
||||||
|
return taskList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//获取箱子重量
|
||||||
|
private static void getVehicleWeight(List<BigDecimal> pointList, String code) {
|
||||||
|
Optional<BigDecimal> nextWeight = pointList
|
||||||
|
.stream()
|
||||||
|
.filter(w -> w.compareTo(new BigDecimal(2000)) > 0)
|
||||||
|
.findFirst();
|
||||||
|
nextWeight.ifPresent(w -> {
|
||||||
|
if ("1207".equals(code)) {
|
||||||
|
vehicleWeight1 = w;
|
||||||
|
} else {
|
||||||
|
vehicleWeight2 = w;
|
||||||
|
}
|
||||||
|
pointList.clear();
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 拣选任务
|
* 拣选任务
|
||||||
*/
|
*/
|
||||||
@@ -349,8 +472,9 @@ public class CockpitServiceImpl implements CockpitService {
|
|||||||
log.error(ex.getMessage());
|
log.error(ex.getMessage());
|
||||||
}
|
}
|
||||||
r.setActual_weight(actual_weight);
|
r.setActual_weight(actual_weight);
|
||||||
r.setActual_weight(r.getActual_weight().subtract(r.getVehicle_weight()).max(BigDecimal.ZERO).setScale(0, RoundingMode.DOWN));
|
|
||||||
if (r.getActual_weight() != null && r.getSingle_weight() != null) {
|
if (r.getActual_weight() != null && r.getSingle_weight() != null) {
|
||||||
|
r.setVehicle_weight(new BigDecimal(2400));
|
||||||
|
r.setActual_weight(r.getActual_weight().subtract(r.getVehicle_weight()).max(BigDecimal.ZERO).setScale(0, RoundingMode.DOWN));
|
||||||
//根据称重信息计算理论数量
|
//根据称重信息计算理论数量
|
||||||
if (r.getActual_weight().compareTo(BigDecimal.ZERO) > 0 && r.getSingle_weight().compareTo(BigDecimal.ZERO) > 0) {
|
if (r.getActual_weight().compareTo(BigDecimal.ZERO) > 0 && r.getSingle_weight().compareTo(BigDecimal.ZERO) > 0) {
|
||||||
//计算理论重量:称重-载具重量/单重 = 理论数量,理论数量!=需出数量:称重异常
|
//计算理论重量:称重-载具重量/单重 = 理论数量,理论数量!=需出数量:称重异常
|
||||||
@@ -371,6 +495,7 @@ public class CockpitServiceImpl implements CockpitService {
|
|||||||
return taskList;
|
return taskList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 领料分析
|
* 领料分析
|
||||||
*/
|
*/
|
||||||
@@ -427,12 +552,13 @@ public class CockpitServiceImpl implements CockpitService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static JSONObject getElapsedTime(JSONObject item, List<TaskInfo> stockList1) {
|
private static JSONObject getElapsedTime(JSONObject item, List<TaskInfo> stockList1) {
|
||||||
|
double totalHours = 0;
|
||||||
//计算数量
|
//计算数量
|
||||||
BigDecimal total = stockList1.stream().filter(r->StringUtils.isNotBlank(r.getUpdate_time())).map(TaskInfo::getQty)
|
BigDecimal total = stockList1.stream().filter(r -> StringUtils.isNotBlank(r.getUpdate_time())).map(TaskInfo::getQty)
|
||||||
.reduce(BigDecimal.ZERO, BigDecimal::add).setScale(0, RoundingMode.HALF_UP);
|
.reduce(BigDecimal.ZERO, BigDecimal::add).setScale(0, RoundingMode.HALF_UP);
|
||||||
item.put("total", total);
|
item.put("total", total);
|
||||||
//计算箱数
|
//计算箱数
|
||||||
int box = stockList1.stream().filter(r->StringUtils.isNotBlank(r.getUpdate_time()))
|
int box = stockList1.stream().filter(r -> StringUtils.isNotBlank(r.getUpdate_time()))
|
||||||
.mapToInt(taskInfo -> taskInfo.getVehicle_code().split(",").length)
|
.mapToInt(taskInfo -> taskInfo.getVehicle_code().split(",").length)
|
||||||
.sum();
|
.sum();
|
||||||
item.put("box", box);
|
item.put("box", box);
|
||||||
@@ -454,7 +580,11 @@ public class CockpitServiceImpl implements CockpitService {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.reduce(Duration.ZERO, Duration::plus);
|
.reduce(Duration.ZERO, Duration::plus);
|
||||||
double totalHours = totalDuration.toMillis() / 1000.0 / 3600.0;
|
if (Integer.parseInt(stockList1.get(0).getTask_type()) <= 14 && stockList1.size() > 10) {
|
||||||
|
totalHours = totalDuration.toMillis() / 1000.0 / 3600.0 / 2;
|
||||||
|
} else {
|
||||||
|
totalHours = totalDuration.toMillis() / 1000.0 / 3600.0;
|
||||||
|
}
|
||||||
BigDecimal roundedTotalHours = BigDecimal.valueOf(totalHours).setScale(1, RoundingMode.HALF_UP);
|
BigDecimal roundedTotalHours = BigDecimal.valueOf(totalHours).setScale(1, RoundingMode.HALF_UP);
|
||||||
item.put("time", roundedTotalHours + "h");
|
item.put("time", roundedTotalHours + "h");
|
||||||
return item;
|
return item;
|
||||||
|
|||||||
@@ -72,7 +72,7 @@
|
|||||||
AND p.status = '10'
|
AND p.status = '10'
|
||||||
AND m.material_id is NOT NULL
|
AND m.material_id is NOT NULL
|
||||||
ORDER BY d.create_time
|
ORDER BY d.create_time
|
||||||
LIMIT 2;
|
LIMIT 4;
|
||||||
</select>
|
</select>
|
||||||
<select id="getMaterInfos" resultType="org.nl.wms.base_manage.material.service.dao.MdMeMaterialbase">
|
<select id="getMaterInfos" resultType="org.nl.wms.base_manage.material.service.dao.MdMeMaterialbase">
|
||||||
SELECT t.stor_code as product_area,
|
SELECT t.stor_code as product_area,
|
||||||
|
|||||||
@@ -134,7 +134,6 @@ public class PmFormDataServiceImpl extends ServiceImpl<PmFormDataMapper, PmFormD
|
|||||||
res = JSONObject.parseObject(result);
|
res = JSONObject.parseObject(result);
|
||||||
} else {
|
} else {
|
||||||
String result = erpServiceUtils.save(formData).getString("result");
|
String result = erpServiceUtils.save(formData).getString("result");
|
||||||
;
|
|
||||||
res = JSONObject.parseObject(result);
|
res = JSONObject.parseObject(result);
|
||||||
}
|
}
|
||||||
JSONObject responseStatus = res.getJSONObject("Result").getJSONObject("ResponseStatus");
|
JSONObject responseStatus = res.getJSONObject("Result").getJSONObject("ResponseStatus");
|
||||||
|
|||||||
Reference in New Issue
Block a user