opt:优化现场问题;
This commit is contained in:
@@ -1650,40 +1650,47 @@ public class DeviceServiceImpl extends CommonServiceImpl<DeviceMapper, Device> i
|
||||
if (file.isEmpty()) {
|
||||
throw new BadRequestException(LangProcess.msg("error_nullPoint"));
|
||||
}
|
||||
Long currentUserId = Long.valueOf(SecurityUtils.getCurrentUserId());
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
// 1.获取上传文件输入流
|
||||
InputStream inputStream = null;
|
||||
try {
|
||||
inputStream = file.getInputStream();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// WQLObject wo = WQLObject.getWQLObject("acs_device");
|
||||
|
||||
// 调用用 hutool 方法读取数据 默认调用第一个sheet
|
||||
ExcelReader excelReader = ExcelUtil.getReader(inputStream);
|
||||
// 从第二行开始获取数据 excelReader.read的结果是一个2纬的list,外层是行,内层是行对应的所有列
|
||||
List<List<Object>> read = excelReader.read(1, excelReader.getRowCount());
|
||||
// 循环获取的数据
|
||||
for (int i = 0; i < read.size(); i++) {
|
||||
List list = read.get(i);
|
||||
JSONObject param = new JSONObject();
|
||||
String device_code = list.get(0).toString();
|
||||
String device_name = list.get(1).toString();
|
||||
String device_type = list.get(2).toString();
|
||||
String is_config = list.get(3).toString();
|
||||
String is_route = list.get(4).toString();
|
||||
String region = list.get(5).toString();
|
||||
String driver_code = list.get(3).toString();
|
||||
String is_config = list.get(5).toString();
|
||||
String is_route = list.get(6).toString();
|
||||
String region = list.get(7).toString();
|
||||
String address = list.get(4).toString();
|
||||
if (StrUtil.isEmpty(device_code)) {
|
||||
throw new BadRequestException(LangProcess.msg("error_checkNull", "device_code"));
|
||||
}
|
||||
//判断数据库记录是否存在,不存在则新增,存在则配置acs_device_extra和acs_storage_cell
|
||||
Device deviceRunpoint = new LambdaQueryChainWrapper<>(deviceMapper)
|
||||
.eq(Device::getDevice_code, device_code)
|
||||
.one();
|
||||
if (ObjectUtil.isNotEmpty(deviceRunpoint)) {
|
||||
addConfig(deviceRunpoint);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (StrUtil.isEmpty(device_name)) {
|
||||
device_name = device_code;
|
||||
}
|
||||
if (StrUtil.isEmpty(device_type)) {
|
||||
device_type = "conveyor";
|
||||
device_type = "station";
|
||||
}
|
||||
if (StrUtil.isEmpty(driver_code)) {
|
||||
driver_code = "standard_ordinary_site";
|
||||
}
|
||||
if (StrUtil.isEmpty(is_config)) {
|
||||
is_config = "FALSE";
|
||||
@@ -1700,6 +1707,7 @@ public class DeviceServiceImpl extends CommonServiceImpl<DeviceMapper, Device> i
|
||||
param.put("device_code", device_code);
|
||||
param.put("device_name", device_name);
|
||||
param.put("device_type", device_type);
|
||||
param.put("driver_code", driver_code);
|
||||
param.put("is_config", is_config);
|
||||
param.put("is_route", is_route);
|
||||
param.put("create_by", nickName);
|
||||
@@ -1707,13 +1715,196 @@ public class DeviceServiceImpl extends CommonServiceImpl<DeviceMapper, Device> i
|
||||
param.put("update_by", nickName);
|
||||
param.put("update_time", now);
|
||||
param.put("region", region);
|
||||
|
||||
// wo.insert(param);
|
||||
param.put("address", address);
|
||||
Device entity = ConvertUtil.convert(param, Device.class);
|
||||
deviceMapper.insert(entity);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void addConfig(Device device) {
|
||||
String device_id = device.getDevice_id();
|
||||
String device_code = device.getDevice_code();
|
||||
String opc_server_id = device.getOpc_plc_id();
|
||||
String opc_plc_id = device.getOpc_plc_id();
|
||||
String address = device.getAddress();
|
||||
String device_type = device.getDevice_type();
|
||||
String driver_code = device.getDriver_code();
|
||||
if (StrUtil.isEmpty(device_id)) {
|
||||
throw new BadRequestException(LangProcess.msg("error_checkNull", "device_id"));
|
||||
}
|
||||
DeviceDto dto = this.findById(device_id);
|
||||
DeviceRunpointDto devrundto = new DeviceRunpointDto();
|
||||
log.info("插入设备扩展表字段信息");
|
||||
//先删除设备扩展表【acs_device_extra】
|
||||
deviceExtraService.deleteAllByDeviceIds(new String[]{device_id});
|
||||
JSONObject form = new JSONObject();
|
||||
form.put("device_id", device_id);
|
||||
form.put("device_code", device_code);
|
||||
form.put("address", address);
|
||||
deviceExtraService.createByDeviceConfig(form, "01");
|
||||
//判断是否存在并开启站点管理
|
||||
// if (form.containsKey("station_manager")) {
|
||||
// if ("true".equals(form.get("station_manager").toString())) {
|
||||
// //判断数据库记录是否存在 不存在则新增 存在则修改
|
||||
// DeviceRunpoint deviceRunpoint = new LambdaQueryChainWrapper<>(deviceRunpointMapper)
|
||||
// .eq(DeviceRunpoint::getDevice_id, device_id)
|
||||
// .one();
|
||||
// if (ObjectUtil.isEmpty(deviceRunpoint)) {
|
||||
// devrundto.setDevice_code(dto.getDevice_code());
|
||||
// devrundto.setDevice_id(dto.getDevice_id());
|
||||
// devrundto.setCreate_by("auto");
|
||||
// devrundto.setCreate_time(DateUtil.now());
|
||||
//
|
||||
// DeviceRunpoint entity = ConvertUtil.convert(devrundto, DeviceRunpoint.class);
|
||||
// deviceRunpointMapper.insert(entity);
|
||||
//
|
||||
// } else {
|
||||
// deviceRunpoint.setContainer(null);
|
||||
// deviceRunpoint.setTaskno("0");
|
||||
// deviceRunpoint.setHasgoods("0");
|
||||
// deviceRunpoint.setRemark(null);
|
||||
// deviceRunpointMapper.updateById(deviceRunpoint);
|
||||
// }
|
||||
// } else {
|
||||
// LambdaQueryWrapper<DeviceRunpoint> wrapper = new LambdaQueryWrapper<>();
|
||||
// wrapper.eq(DeviceRunpoint::getDevice_id, device_id);
|
||||
// deviceRunpointMapper.delete(wrapper);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//有db
|
||||
// JSONArray data1 = jsonObject.getJSONArray("data1");
|
||||
// if (data1 != null) {
|
||||
// //处理读的DB字段
|
||||
// //设备扩展表【acs_device_extra】
|
||||
// LambdaQueryWrapper<DeviceExtra> wrapper = new LambdaQueryWrapper<>();
|
||||
// wrapper.eq(DeviceExtra::getDevice_id, device_id);
|
||||
// wrapper.eq(DeviceExtra::getFiled_type, "02");
|
||||
// deviceExtraMapper.delete(wrapper);
|
||||
// for (int i = 0; i < data1.size(); i++) {
|
||||
// JSONObject param = new JSONObject();
|
||||
// JSONObject json = data1.getJSONObject(i);
|
||||
// param.put("extra_id", IdUtil.simpleUUID());
|
||||
// //heartbeat
|
||||
// param.put("extra_code", json.getString("code"));
|
||||
// param.put("extra_name", json.getString("db"));
|
||||
// param.put("remark", json.getString("name"));
|
||||
// param.put("order_seq", i + 1);
|
||||
// //DB读
|
||||
// param.put("filed_type", "02");
|
||||
// param.put("device_id", device_id);
|
||||
// param.put("device_code", device_code);
|
||||
// param.put("create_by", SecurityUtils.getCurrentUsername());
|
||||
// param.put("create_time", DateUtil.now());
|
||||
// DeviceExtra entity = ConvertUtil.convert(param, DeviceExtra.class);
|
||||
// deviceExtraMapper.insert(entity);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// //处理写
|
||||
// JSONArray data2 = jsonObject.getJSONArray("data2");
|
||||
// if (data2 != null) {
|
||||
// LambdaQueryWrapper<DeviceExtra> wrapper = new LambdaQueryWrapper<>();
|
||||
// wrapper.eq(DeviceExtra::getDevice_id, device_id);
|
||||
// wrapper.eq(DeviceExtra::getFiled_type, "03");
|
||||
// deviceExtraMapper.delete(wrapper);
|
||||
// for (int i = 0; i < data2.size(); i++) {
|
||||
// JSONObject param = new JSONObject();
|
||||
// JSONObject json = data2.getJSONObject(i);
|
||||
// param.put("extra_id", IdUtil.simpleUUID());
|
||||
// //heartbeat
|
||||
// param.put("extra_code", json.getString("code"));
|
||||
// param.put("extra_name", json.getString("db"));
|
||||
// param.put("remark", json.getString("name"));
|
||||
// param.put("order_seq", i + 1);
|
||||
// //DB读
|
||||
// param.put("filed_type", "03");
|
||||
// param.put("device_id", device_id);
|
||||
// param.put("device_code", device_code);
|
||||
// param.put("create_by", SecurityUtils.getCurrentUsername());
|
||||
// param.put("create_time", DateUtil.now());
|
||||
// DeviceExtra entity = ConvertUtil.convert(param, DeviceExtra.class);
|
||||
// deviceExtraMapper.insert(entity);
|
||||
// }
|
||||
// }
|
||||
if (StrUtil.equals(device_type, "storage")) {
|
||||
int x = form.getInteger("x");
|
||||
int maxY = form.getInteger("maxY");
|
||||
int minY = form.getInteger("minY");
|
||||
int maxZ = form.getInteger("maxZ");
|
||||
int minZ = form.getInteger("minZ");
|
||||
for (int i = minY; i <= maxY; i++) {
|
||||
for (int j = minZ; j <= maxZ; j++) {
|
||||
StorageCell storageCell = new LambdaQueryChainWrapper<>(storageCellMapper)
|
||||
.eq(StorageCell::getStorage_code, device_code + "-" + formatNum(i) + "-" + formatNum(j))
|
||||
.one();
|
||||
if (ObjectUtil.isEmpty(storageCell)) {
|
||||
StorageCellDto celldto = new StorageCellDto();
|
||||
celldto.setStorage_id(IdUtil.simpleUUID());
|
||||
celldto.setStorage_code(device_code + "-" + formatNum(i) + "-" + formatNum(j));
|
||||
celldto.setParent_storage_code(device_code + "-" + formatNum(i) + "-" + formatNum(j));
|
||||
celldto.setX(formatNum(x));
|
||||
celldto.setY(formatNum(i));
|
||||
celldto.setZ(formatNum(j));
|
||||
celldto.setCreate_by("init");
|
||||
celldto.setCreate_time(SecurityUtils.getCurrentUsername());
|
||||
StorageCell entity = ConvertUtil.convert(celldto, StorageCell.class);
|
||||
storageCellMapper.insert(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//空盘堆叠驱动 需要按照数量生成
|
||||
if (StrUtil.equals(driver_code, "standard_emptypallet_site") && form.containsKey("max_emptypalletnum")) {
|
||||
int num = form.getInteger("max_emptypalletnum");
|
||||
for (int i = 1; i < num + 1; i++) {
|
||||
StorageCell storageCell = new LambdaQueryChainWrapper<>(storageCellMapper)
|
||||
.eq(StorageCell::getStorage_code, device_code + "." + i)
|
||||
.one();
|
||||
if (ObjectUtil.isEmpty(storageCell)) {
|
||||
StorageCellDto celldto = new StorageCellDto();
|
||||
celldto.setStorage_id(IdUtil.simpleUUID());
|
||||
celldto.setStorage_code(device_code + "." + i);
|
||||
celldto.setParent_storage_code(device_code + "." + i);
|
||||
celldto.setX("0");
|
||||
celldto.setY("0");
|
||||
celldto.setZ("0");
|
||||
celldto.setAddress(Integer.parseInt(CodeUtil.getNewCode("NDCADDRESS_NO")));
|
||||
celldto.setCreate_by("init");
|
||||
celldto.setCreate_time(SecurityUtils.getCurrentUsername());
|
||||
StorageCell entity = ConvertUtil.convert(celldto, StorageCell.class);
|
||||
storageCellMapper.insert(entity);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//普通站点
|
||||
StorageCell storageCell = new LambdaQueryChainWrapper<>(storageCellMapper)
|
||||
.eq(StorageCell::getStorage_code, device_code)
|
||||
.one();
|
||||
if (ObjectUtil.isEmpty(storageCell)) {
|
||||
StorageCellDto celldto = new StorageCellDto();
|
||||
celldto.setStorage_id(IdUtil.simpleUUID());
|
||||
celldto.setStorage_code(device_code);
|
||||
celldto.setParent_storage_code(device_code);
|
||||
celldto.setX("0");
|
||||
celldto.setY("0");
|
||||
celldto.setZ("0");
|
||||
celldto.setAddress(org.apache.commons.lang3.StringUtils.isBlank(address)?Integer.parseInt(CodeUtil.getNewCode("NDCADDRESS_NO")):Integer.parseInt(address));
|
||||
celldto.setCreate_by("init");
|
||||
celldto.setCreate_time(SecurityUtils.getCurrentUsername());
|
||||
StorageCell entity = ConvertUtil.convert(celldto, StorageCell.class);
|
||||
storageCellMapper.insert(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
updateDevice(device_code);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Map<String, Object> getValue1(JSONArray wss, int j, Integer dbInterval, int i) {
|
||||
int size = wss.size();
|
||||
Map<String, Object> map = new ListOrderedMap<>();
|
||||
|
||||
@@ -194,7 +194,7 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
|
||||
.eq(Task::getTask_status, task_status)
|
||||
.eq(Task::getIs_delete, "0")
|
||||
.orderByDesc(Task::getPriority)
|
||||
.orderByAsc(Task::getCreate_time)
|
||||
.orderByAsc(Task::getTask_code)
|
||||
.list();
|
||||
return ConvertUtil.convertList(taskList, TaskDto.class);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user