opt:西门子优化
This commit is contained in:
@@ -16,4 +16,9 @@ public class CallEmpVo {
|
||||
* 设备工序
|
||||
*/
|
||||
private String region_code;
|
||||
|
||||
/**
|
||||
* 目标点位是有货点位,是否强制修改成无货。
|
||||
*/
|
||||
private Boolean check_flag;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.nl.wms.ext.fab.service.impl;
|
||||
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@@ -9,8 +10,12 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import nl.basjes.shaded.org.springframework.util.Assert;
|
||||
import org.checkerframework.checker.units.qual.A;
|
||||
import org.nl.common.enums.GoodsEnum;
|
||||
import org.nl.common.enums.VehicleTypeEnum;
|
||||
import org.nl.common.enums.region.RegionEnum;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.system.service.dict.ISysDictService;
|
||||
import org.nl.system.service.dict.dao.Dict;
|
||||
import org.nl.system.service.param.dao.Param;
|
||||
import org.nl.wms.database.vehicle.service.IMdBaseVehicleService;
|
||||
import org.nl.wms.database.vehicle.service.dao.MdBaseVehicle;
|
||||
@@ -33,11 +38,14 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class FabServiceImpl {
|
||||
@@ -61,6 +69,10 @@ public class FabServiceImpl {
|
||||
private PcOperationSNTTask pcOperationSNTTask;
|
||||
@Autowired
|
||||
private PcOperationCNTask pcOperationCNTask;
|
||||
|
||||
@Autowired
|
||||
private ISysDictService dictService;
|
||||
|
||||
@Autowired
|
||||
private ISchBaseVehiclematerialgroupService iSchBaseVehiclematerialgroupService;
|
||||
|
||||
@@ -230,8 +242,20 @@ public class FabServiceImpl {
|
||||
if (ObjectUtil.isEmpty(schBasePoint1)) {
|
||||
throw new BadRequestException("点位不存在");
|
||||
}
|
||||
if (StrUtil.isNotEmpty(schBasePoint1.getVehicle_code())) {
|
||||
throw new BadRequestException("该点位不是空站点,请确认再呼叫");
|
||||
if (Boolean.TRUE.equals(callEmpVo.getCheck_flag())){
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
iSchBasePointService.update(Wrappers.lambdaUpdate(SchBasePoint.class)
|
||||
.eq(SchBasePoint::getPoint_code, form.getString("device_code"))
|
||||
.set(SchBasePoint::getVehicle_code, null)
|
||||
.set(SchBasePoint::getPoint_status, GoodsEnum.OUT_OF_STOCK.getValue())
|
||||
.set(SchBasePoint::getUpdate_id, currentUserId)
|
||||
.set(SchBasePoint::getUpdate_name, nickName)
|
||||
.set(SchBasePoint::getUpdate_time, now)
|
||||
);
|
||||
} else if (StrUtil.isNotEmpty(schBasePoint1.getVehicle_code())) {
|
||||
throw new BadRequestException("该点位不是空站点,请确认是否设置成空站点并继续呼叫?");
|
||||
}
|
||||
param.put("device_code", callEmpVo.getDevice_code());
|
||||
param.put("config_code", "TOSTOREHOUSETask");
|
||||
@@ -257,6 +281,20 @@ public class FabServiceImpl {
|
||||
} else {
|
||||
param.put("config_code", "PcOperationSMTTask");
|
||||
}
|
||||
List<Dict> dictList = dictService.getDictByName("fork_type_point");
|
||||
if(!CollectionUtils.isEmpty(dictList)) {
|
||||
List<String> valueList = dictList.stream()
|
||||
.map(Dict::getValue) // 提取每个Dict的value属性
|
||||
.filter(Objects::nonNull) // 过滤掉 null
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (!CollectionUtils.isEmpty(valueList)
|
||||
&& valueList.contains( sendMaterVo.getDevice_code())
|
||||
&& VehicleTypeEnum.FRAME_R02.getVehicleCode().equals(vehicle.getVehicle_type())) {
|
||||
param.put("car_type", "small");
|
||||
}
|
||||
}
|
||||
|
||||
param.put("vehicle_code", sendMaterVo.getVehicle_code());
|
||||
param.put("vehicle_type", vehicle.getVehicle_type());
|
||||
iSchBasePointService.update(Wrappers.lambdaUpdate(SchBasePoint.class)
|
||||
@@ -275,6 +313,28 @@ public class FabServiceImpl {
|
||||
param.put("vehicle_code", schBasePoint.getVehicle_code());
|
||||
param.put("vehicle_type", schBasePoint.getVehicle_type());
|
||||
param.put("ext_data", sendVehicleVo);
|
||||
|
||||
SchBasePoint schBasePointSnt = iSchBasePointService.selectByPointCode(form.getString("device_code"));
|
||||
if (ObjectUtil.isEmpty(schBasePointSnt)) {
|
||||
throw new BadRequestException("点位不存在");
|
||||
}
|
||||
if(StringUtils.isEmpty(schBasePointSnt.getVehicle_code())){
|
||||
throw new BadRequestException("点位不存在载具");
|
||||
}
|
||||
MdBaseVehicle vehicle2 = iMdBaseVehicleService.getOne(new QueryWrapper<MdBaseVehicle>().eq("vehicle_code", schBasePointSnt.getVehicle_code()));
|
||||
List<Dict> dictList2 = dictService.getDictByName("fork_type_point");
|
||||
if(!CollectionUtils.isEmpty(dictList2)) {
|
||||
List<String> valueList = dictList2.stream()
|
||||
.map(Dict::getValue) // 提取每个Dict的value属性
|
||||
.filter(Objects::nonNull) // 过滤掉 null
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (!CollectionUtils.isEmpty(valueList)
|
||||
&& valueList.contains(sendVehicleVo.getDevice_code())
|
||||
&& VehicleTypeEnum.FRAME_R02.getVehicleCode().equals(vehicle2.getVehicle_type())) {
|
||||
param.put("car_type", "small");
|
||||
}
|
||||
}
|
||||
pcOperationSNTTask.apply(param);
|
||||
iSchBasePointService.update(Wrappers.lambdaUpdate(SchBasePoint.class)
|
||||
.eq(SchBasePoint::getPoint_code, sendVehicleVo.getDevice_code())
|
||||
|
||||
@@ -68,7 +68,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@@ -115,6 +115,9 @@ public class HandheldServiceImpl implements HandheldService {
|
||||
private SchBasePointMapper schBasePointMapper;
|
||||
static final Map<String, String> STATUS = MapOf.of("释放", "0", "锁定", "1");
|
||||
|
||||
// 线程池,用于异步执行任务
|
||||
private final ExecutorService executorService = Executors.newSingleThreadExecutor();
|
||||
|
||||
|
||||
@Override
|
||||
public void emptyCageStorageTask(JSONObject param) {
|
||||
@@ -239,16 +242,36 @@ public class HandheldServiceImpl implements HandheldService {
|
||||
Map<String, List<VehicleDto>> point2VehicleMap = vehicleList.stream()
|
||||
.collect(Collectors.groupingBy(VehicleDto::getPoint_code));
|
||||
|
||||
for (SchBasePoint schBasePoint : sortedPointList) {
|
||||
String pointCode = schBasePoint.getPoint_code();
|
||||
List<VehicleDto> matchVehicleDtos = point2VehicleMap.get(pointCode);
|
||||
if (CollectionUtil.isNotEmpty(matchVehicleDtos)) {
|
||||
for (VehicleDto vehicleDto : matchVehicleDtos) {
|
||||
// 生成任务(可添加日志记录,便于生产环境排查问题)
|
||||
artificialBendingNew(vehicleDto.getVehicle_code(), vehicleDto.getPoint_code());
|
||||
// 异步执行任务生成,每个任务间隔12秒
|
||||
executorService.submit(() -> {
|
||||
try {
|
||||
for (SchBasePoint schBasePoint : sortedPointList) {
|
||||
String pointCode = schBasePoint.getPoint_code();
|
||||
List<VehicleDto> matchVehicleDtos = point2VehicleMap.get(pointCode);
|
||||
if (CollectionUtil.isNotEmpty(matchVehicleDtos)) {
|
||||
for (VehicleDto vehicleDto : matchVehicleDtos) {
|
||||
try {
|
||||
// 生成任务(可添加日志记录,便于生产环境排查问题)
|
||||
log.info("异步生成任务:载具号={}, 点位={}", vehicleDto.getVehicle_code(), vehicleDto.getPoint_code());
|
||||
artificialBendingNew(vehicleDto.getVehicle_code(), vehicleDto.getPoint_code());
|
||||
// 每个任务间隔12秒
|
||||
Thread.sleep(12000);
|
||||
} catch (InterruptedException e) {
|
||||
log.error("任务生成线程被中断:{}", e.getMessage());
|
||||
Thread.currentThread().interrupt();
|
||||
break;
|
||||
} catch (Exception e) {
|
||||
log.error("生成任务失败:载具号={}, 点位={}, 错误信息:{}", vehicleDto.getVehicle_code(), vehicleDto.getPoint_code(), e.getMessage(), e);
|
||||
// 继续执行下一个任务
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("异步执行任务生成失败:{}", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -295,6 +318,19 @@ public class HandheldServiceImpl implements HandheldService {
|
||||
jo.put("region_code", RegionEnum.NBGD.getRegion_code());
|
||||
param.put("region_code", RegionEnum.NBGD.getRegion_code());
|
||||
jo.put("car_type","start");
|
||||
List<Dict> dictList = dictService.getDictByName("fork_type_point");
|
||||
if(!CollectionUtils.isEmpty(dictList)) {
|
||||
List<String> valueList = dictList.stream()
|
||||
.map(Dict::getValue) // 提取每个Dict的value属性
|
||||
.filter(Objects::nonNull) // 过滤掉 null
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (!CollectionUtils.isEmpty(valueList)
|
||||
&& valueList.contains(device_code)
|
||||
&& VehicleTypeEnum.FRAME_R02.getVehicleCode().equals( mdBaseVehicle.getVehicle_type())) {
|
||||
jo.put("car_type", "small");
|
||||
}
|
||||
}
|
||||
jo.put("ext_data", param);
|
||||
connectorTask.apply(jo);
|
||||
}
|
||||
@@ -326,6 +362,22 @@ public class HandheldServiceImpl implements HandheldService {
|
||||
jo.put("create_mode", GeneralDefinition.AUTO_CREATION);
|
||||
jo.put("vehicle_code", vehicle_code);
|
||||
jo.put("car_type","end");
|
||||
|
||||
MdBaseVehicle mdBaseVehicle = iMdBaseVehicleService.selectByVehicleCode(vehicle_code);
|
||||
if (ObjectUtil.isEmpty(mdBaseVehicle)) throw new BadRequestException("载具不存在!");
|
||||
List<Dict> dictList = dictService.getDictByName("fork_type_point");
|
||||
if(!CollectionUtils.isEmpty(dictList)) {
|
||||
List<String> valueList = dictList.stream()
|
||||
.map(Dict::getValue) // 提取每个Dict的value属性
|
||||
.filter(Objects::nonNull) // 过滤掉 null
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (!CollectionUtils.isEmpty(valueList)
|
||||
&& valueList.contains(point_code)
|
||||
&& VehicleTypeEnum.FRAME_R02.getVehicleCode().equals(mdBaseVehicle.getVehicle_type())) {
|
||||
jo.put("car_type", "small");
|
||||
}
|
||||
}
|
||||
connectorTask.apply(jo);
|
||||
}
|
||||
|
||||
@@ -354,6 +406,20 @@ public class HandheldServiceImpl implements HandheldService {
|
||||
jo.put("vehicle_code", vehicle);
|
||||
jo.put("car_type","start");
|
||||
|
||||
List<Dict> dictList = dictService.getDictByName("fork_type_point");
|
||||
if(!CollectionUtils.isEmpty(dictList)) {
|
||||
List<String> valueList = dictList.stream()
|
||||
.map(Dict::getValue) // 提取每个Dict的value属性
|
||||
.filter(Objects::nonNull) // 过滤掉 null
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (!CollectionUtils.isEmpty(valueList)
|
||||
&& valueList.contains(device_code)
|
||||
&& VehicleTypeEnum.FRAME_R02.getVehicleCode().equals(mdBaseVehicle.getVehicle_type())) {
|
||||
jo.put("car_type", "small");
|
||||
}
|
||||
}
|
||||
|
||||
jo.put("ext_data", param);
|
||||
connectorTask.apply(jo);
|
||||
}
|
||||
@@ -748,7 +814,19 @@ public class HandheldServiceImpl implements HandheldService {
|
||||
jo.put("create_mode", GeneralDefinition.AUTO_CREATION);
|
||||
jo.put("vehicle_code", vehicle_code);
|
||||
jo.put("vehicle_type", mdBaseVehicle.getVehicle_type());
|
||||
jo.put("car_type","start");
|
||||
jo.put("car_type","end");
|
||||
List<Dict> dictList = dictService.getDictByName("fork_type_point");
|
||||
if(!CollectionUtils.isEmpty(dictList)) {
|
||||
List<String> valueList = dictList.stream()
|
||||
.map(Dict::getValue) // 提取每个Dict的value属性
|
||||
.filter(Objects::nonNull) // 过滤掉 null
|
||||
.collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(valueList)
|
||||
&& valueList.contains(device_code)
|
||||
&& VehicleTypeEnum.FRAME_R02.getVehicleCode().equals(mdBaseVehicle.getVehicle_type())) {
|
||||
jo.put("car_type", "small");
|
||||
}
|
||||
}
|
||||
jo.put("ext_data", param);
|
||||
connectorTask.apply(jo);
|
||||
}
|
||||
|
||||
@@ -60,4 +60,12 @@ public class AgvUsageController {
|
||||
Map<String, Object> result = agvUsageService.getAgvUsageRateToday();
|
||||
return new ResponseEntity<>(result, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/monthly")
|
||||
@Log("获取月度AGV使用率统计")
|
||||
@ApiOperation("获取月度AGV使用率统计")
|
||||
public ResponseEntity<Object> getMonthlyStatistics() {
|
||||
List<Map<String, Object>> result = agvUsageService.getMonthlyAgvUsageStatistics();
|
||||
return new ResponseEntity<>(result, HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,4 +15,6 @@ public interface IAgvUsageService {
|
||||
Map<String, Object> getAgvRealtimeStatus();
|
||||
|
||||
Map<String, Object> getAgvUsageRateToday();
|
||||
|
||||
List<Map<String, Object>> getMonthlyAgvUsageStatistics();
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ public class AgvUsageServiceImpl implements IAgvUsageService {
|
||||
String endDate = sdf.format(query.getEndDate());
|
||||
|
||||
StringBuilder urlBuilder = new StringBuilder(acsUrl)
|
||||
.append("/api/agv_usage/statistics/detail?startDate=")
|
||||
.append("api/agv_usage/statistics/detail?startDate=")
|
||||
.append(startDate)
|
||||
.append("&endDate=")
|
||||
.append(endDate);
|
||||
@@ -177,4 +177,32 @@ public class AgvUsageServiceImpl implements IAgvUsageService {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> getMonthlyAgvUsageStatistics() {
|
||||
if (!isConnectAcs()) {
|
||||
log.warn("未连接ACS系统");
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
String acsUrl = getAcsUrl();
|
||||
if (StrUtil.isEmpty(acsUrl)) {
|
||||
log.warn("ACS地址未配置");
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
String url = acsUrl + "api/agv_usage/monthly";
|
||||
|
||||
try {
|
||||
String result = HttpRequest.get(url)
|
||||
.setConnectionTimeout(5000)
|
||||
.execute()
|
||||
.body();
|
||||
// 使用TypeReference指定泛型类型,保证类型匹配
|
||||
return JSON.parseObject(result, new TypeReference<List<Map<String, Object>>>() {});
|
||||
} catch (Exception e) {
|
||||
log.error("调用ACS获取月度AGV使用率统计失败: {}", e.getMessage());
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,7 +238,6 @@ public class SchBasePointServiceImpl extends ServiceImpl<SchBasePointMapper, Sch
|
||||
pointMapper.update(entity, Wrappers.lambdaUpdate(SchBasePoint.class)
|
||||
.eq(SchBasePoint::getPoint_code, entity.getPoint_code())
|
||||
.set(SchBasePoint::getVehicle_code, vehicle_code));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -73,7 +73,7 @@ public class CombineSourceStoreInTask extends AbstractTask {
|
||||
GoodsEnum.OUT_OF_STOCK.getValue(), vehicle_type, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (ObjectUtil.isEmpty(schBasePoint)) {
|
||||
task.setRemark("未找到所需点位!");
|
||||
taskService.updateById(task);
|
||||
@@ -203,13 +203,7 @@ public class CombineSourceStoreInTask extends AbstractTask {
|
||||
String point_code2 = taskObj.getPoint_code2();
|
||||
SchBasePoint schBasePoint2 = pointService.selectByPointCode(point_code2);
|
||||
if (ObjectUtil.isNotEmpty(schBasePoint2)) {
|
||||
String vehicle_type = taskObj.getVehicle_type();
|
||||
if (vehicle_type.equals(VehicleTypeEnum.FRAME_R01.getVehicleCode()) || vehicle_type.equals(VehicleTypeEnum.FRAME_R02.getVehicleCode())) {
|
||||
schBasePoint2.setVehicles(taskObj.getVehicle_code());
|
||||
schBasePoint2.setVehicle_qty(taskObj.getVehicle_qty());
|
||||
} else {
|
||||
schBasePoint2.setVehicle_code(taskObj.getVehicle_code());
|
||||
}
|
||||
schBasePoint2.setVehicle_code(taskObj.getVehicle_code());
|
||||
schBasePoint2.setPoint_status(GoodsEnum.EMPTY_PALLETS.getValue());
|
||||
schBasePoint2.setIs_lock(false);
|
||||
PointUtils.setUpdateByAcs(schBasePoint2);
|
||||
|
||||
@@ -67,11 +67,11 @@ public class EmptyCageNewTask extends AbstractTask {
|
||||
switch (vehicle_type) {
|
||||
case "R01":
|
||||
schBasePoint = schBasePointService.selectStackPoint(RegionEnum.S.getRegion_code(),
|
||||
GoodsEnum.OUT_OF_STOCK.getValue(), VehicleTypeEnum.FRAME_R01.getVehicleCode(), IS_VEHICLE.get("vehicles"), POINT_TYPE.get("空托盘"));
|
||||
GoodsEnum.OUT_OF_STOCK.getValue(), VehicleTypeEnum.FRAME_R01.getVehicleCode(), IS_VEHICLE.get("vehicle_code"), POINT_TYPE.get("空托盘"));
|
||||
break;
|
||||
case "R02":
|
||||
schBasePoint = schBasePointService.selectStackPoint(RegionEnum.S.getRegion_code(),
|
||||
GoodsEnum.OUT_OF_STOCK.getValue(), VehicleTypeEnum.FRAME_R02.getVehicleCode(), IS_VEHICLE.get("vehicles"), POINT_TYPE.get("空托盘"));
|
||||
GoodsEnum.OUT_OF_STOCK.getValue(), VehicleTypeEnum.FRAME_R02.getVehicleCode(), IS_VEHICLE.get("vehicle_code"), POINT_TYPE.get("空托盘"));
|
||||
break;
|
||||
case "S04":
|
||||
schBasePoint = schBasePointService.selectStackPoint(RegionEnum.LAG.getRegion_code(),
|
||||
@@ -219,13 +219,7 @@ public class EmptyCageNewTask extends AbstractTask {
|
||||
String point_code2 = taskObj.getPoint_code2();
|
||||
SchBasePoint schBasePoint2 = pointService.selectByPointCode(point_code2);
|
||||
if (ObjectUtil.isNotEmpty(schBasePoint2)) {
|
||||
String vehicle_type = taskObj.getVehicle_type();
|
||||
if (vehicle_type.equals(VehicleTypeEnum.FRAME_R01.getVehicleCode()) || vehicle_type.equals(VehicleTypeEnum.FRAME_R02.getVehicleCode())) {
|
||||
schBasePoint2.setVehicles(taskObj.getVehicle_code());
|
||||
schBasePoint2.setVehicle_qty(taskObj.getVehicle_qty());
|
||||
} else {
|
||||
schBasePoint2.setVehicle_code(taskObj.getVehicle_code());
|
||||
}
|
||||
schBasePoint2.setVehicle_code(taskObj.getVehicle_code());
|
||||
schBasePoint2.setPoint_status(GoodsEnum.EMPTY_PALLETS.getValue());
|
||||
schBasePoint2.setIs_lock(false);
|
||||
PointUtils.setUpdateByAcs(schBasePoint2);
|
||||
|
||||
Reference in New Issue
Block a user