opt:任务看板代码优化
This commit is contained in:
@@ -40,4 +40,7 @@ public interface DeviceExtraMapper extends CommonMapper<DeviceExtra> {
|
||||
|
||||
@Select(wrapperDeviceProtocolSql)
|
||||
List<DeviceExtra> selectDeviceProtocolList(@Param("ew") Wrapper<DeviceExtra> queryWrapper);
|
||||
|
||||
@Select("select * from lzhl_two_acs.acs_device_extra where device_id=#{device_id} and extra_code=#{extra_code} order by create_time desc")
|
||||
DeviceExtra findByDeviceId(@Param("device_id") String device_id,@Param("extra_code") String extra_code);
|
||||
}
|
||||
|
||||
@@ -405,6 +405,7 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
map.put("to_container_type", "1");
|
||||
map.put("to_container_no", "1");
|
||||
this.writing(map);
|
||||
led_message = getLedMessage(inst);
|
||||
requireSucess = true;
|
||||
led_message = getLedMessage(inst);
|
||||
return true;
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package org.nl.acs.taskscreen.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@@ -15,11 +17,16 @@ import org.nl.acs.auto.initial.ApplicationAutoInitial;
|
||||
import org.nl.acs.common.base.PageInfo;
|
||||
import org.nl.acs.common.base.impl.CommonServiceImpl;
|
||||
import org.nl.acs.device.domain.Device;
|
||||
import org.nl.acs.device.domain.DeviceExtra;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device.service.dto.DeviceDto;
|
||||
import org.nl.acs.device.service.dto.DeviceExtraDto;
|
||||
import org.nl.acs.device.service.dto.DeviceQueryParam;
|
||||
import org.nl.acs.device.service.mapper.DeviceExtraMapper;
|
||||
import org.nl.acs.device.service.mapper.DeviceMapper;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.belt_conveyor.BeltConveyorDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.led_screen.LedScreenDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.siemens_conveyor.SiemensConveyorDeviceDriver;
|
||||
import org.nl.acs.instruction.domain.Instruction;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
@@ -27,6 +34,8 @@ import org.nl.acs.opc.DeviceAppServiceImpl;
|
||||
import org.nl.acs.storage_cell.service.dto.StorageCellDto;
|
||||
import org.nl.acs.taskscreen.mapper.TaskScreenMapper;
|
||||
import org.nl.acs.taskscreen.service.TaskScreenService;
|
||||
import org.nl.acs.utils.ConvertUtil;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@@ -38,19 +47,27 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author tuqiang
|
||||
* @date 2023-05-09
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
@Slf4j
|
||||
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
|
||||
public class TaskScreenServiceImpl extends CommonServiceImpl<TaskScreenMapper,Device> implements TaskScreenService, ApplicationAutoInitial {
|
||||
public class TaskScreenServiceImpl extends CommonServiceImpl<TaskScreenMapper, Device> implements TaskScreenService, ApplicationAutoInitial {
|
||||
|
||||
|
||||
private final DeviceMapper deviceMapper;
|
||||
private final DeviceAppService deviceAppservice;
|
||||
private final DeviceExtraMapper deviceExtraMapper;
|
||||
private final DeviceService deviceService;
|
||||
|
||||
|
||||
@Override
|
||||
public void autoInitial() throws Exception {
|
||||
@@ -67,7 +84,7 @@ public class TaskScreenServiceImpl extends CommonServiceImpl<TaskScreenMapper,De
|
||||
for (int i = 0; i < arr.size(); i++) {
|
||||
JSONObject obj = arr.getJSONObject(i);
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("device_code",obj.getString("device_code"));
|
||||
json.put("device_code", obj.getString("device_code"));
|
||||
result.add(json);
|
||||
}
|
||||
return result;
|
||||
@@ -78,22 +95,44 @@ public class TaskScreenServiceImpl extends CommonServiceImpl<TaskScreenMapper,De
|
||||
if (!ObjectUtil.isNotEmpty(device_code)) {
|
||||
return null;
|
||||
}
|
||||
//根据设备号找到当前设备
|
||||
LambdaQueryChainWrapper<Device> wrapper = new LambdaQueryChainWrapper<Device>(deviceMapper)
|
||||
.eq(Device::getDevice_code, device_code);
|
||||
Device device1 = deviceMapper.selectOne(wrapper);
|
||||
//获取关联设备驱动信息
|
||||
String link_device_code = String.valueOf(device1.getExtraValue().get("link_device_code"));
|
||||
Device link_device = deviceAppservice.findDeviceByCode(link_device_code);
|
||||
BeltConveyorDeviceDriver beltConveyorDeviceDriver;
|
||||
DeviceDto deviceDto = deviceService.findByCode(device_code);
|
||||
String device_id = deviceDto.getDevice_id();
|
||||
DeviceExtra deviceExtra = deviceExtraMapper.findByDeviceId(device_id, "link_device_code");
|
||||
String extra_value = deviceExtra.getExtra_value();
|
||||
List<String> extraDeviceCodes = getExtraDeviceCodes(extra_value);
|
||||
if (CollUtil.isEmpty(extraDeviceCodes) || extraDeviceCodes.size() < 0){
|
||||
throw new BadRequestException("没有查询到数据");
|
||||
}
|
||||
String deviceCode = extraDeviceCodes.get(0);
|
||||
DeviceDto link_device = deviceService.findByCode(deviceCode);
|
||||
String device_code1 = link_device.getDevice_code();
|
||||
Device device = deviceAppservice.findDeviceByCode(device_code1);
|
||||
JSONObject json = new JSONObject();
|
||||
if (link_device.getDeviceDriver() instanceof BeltConveyorDeviceDriver) {
|
||||
beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) link_device.getDeviceDriver();
|
||||
if(ObjectUtil.isNotEmpty(beltConveyorDeviceDriver.getLed_message())){
|
||||
if (device.getDeviceDriver() instanceof BeltConveyorDeviceDriver) {
|
||||
BeltConveyorDeviceDriver beltConveyorDeviceDriver;
|
||||
beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) device.getDeviceDriver();
|
||||
if (ObjectUtil.isNotEmpty(beltConveyorDeviceDriver.getLed_message())) {
|
||||
Instruction inst = beltConveyorDeviceDriver.getInst();
|
||||
json = beltConveyorDeviceDriver.getLedMessage(inst);
|
||||
}
|
||||
}
|
||||
return json;
|
||||
}
|
||||
|
||||
public List<String> getExtraDeviceCodes(String extraValue) {
|
||||
|
||||
if (StrUtil.isEmpty(extraValue)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
String devicesString = extraValue.substring(1, extraValue.length() - 1);
|
||||
List<String> devicesList = new ArrayList<>();
|
||||
String[] devices = devicesString.split(",");
|
||||
for (int i = 0; i < devices.length; i++) {
|
||||
String s = devices[i].replace("\"", "").replace("\"", "");
|
||||
devicesList.add(s);
|
||||
}
|
||||
return devicesList;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user