This commit is contained in:
yanps
2023-12-07 13:41:09 +08:00
parent c6699730f6
commit 0e5e839396
43 changed files with 308 additions and 75 deletions

View File

@@ -6,6 +6,9 @@ import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
/**
* @author 20220102CG\noblelift
*/
public class AgvUtil {
/**
* 获得之后num个天的时间

View File

@@ -13,6 +13,9 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author 20220102CG\noblelift
*/
@RestController
@RequiredArgsConstructor
@Api(tags = "AGV任务")
@@ -23,14 +26,13 @@ public class MagicAgvController {
/**
* 设备请求离开
*
* @PreAuthorize("@el.check('routePlan:list')")
* @param device
* @return
*/
@PostMapping("/agvack/{device}")
@Log("AGV请求离开")
@ApiOperation("AGV请求离开")
//@PreAuthorize("@el.check('routePlan:list')")
public ResponseEntity<Object> requestAck(@PathVariable String device) {
return new ResponseEntity<>(magicAgvService.requestAck(device), HttpStatus.OK);
}

View File

@@ -1,4 +1,7 @@
package org.nl.acs.agv.rest;
/**
* @author 20220102CG\noblelift
*/
public class NDCAgvController {
}

View File

@@ -1,4 +1,7 @@
package org.nl.acs.agv.rest;
/**
* @author 20220102CG\noblelift
*/
public class XianGongAgvController {
}

View File

@@ -1,4 +1,7 @@
package org.nl.acs.agv.rest;
/**
* @author 20220102CG\noblelift
*/
public class ZheDaAgvController {
}

View File

@@ -7,7 +7,7 @@ import java.util.Map;
/**
* 所有agv公用接口
* author
* @author 20220102CG\noblelift
*/
public interface AgvService {
/**

View File

@@ -46,7 +46,7 @@ public interface MagicAgvService {
/**
*
* 根据code下发agv任务
* @param code
* @return
* @throws Exception

View File

@@ -12,7 +12,7 @@ import java.util.Map;
*/
public interface NDCAgvService {
/**
*
* 全部agv
* @return
*/
Map<String, AgvDto> findAllAgvFromCache();
@@ -34,7 +34,7 @@ public interface NDCAgvService {
public void sendAgvInstToNDC(String agv_system_type, Instruction inst) throws Exception;
/**
*
* 一号agv指令
* @param phase
* @param index
* @param result
@@ -47,7 +47,7 @@ public interface NDCAgvService {
public byte[] sendAgvOneModeInst(int phase, int index, int result, int startPoint, int nextPoint, int startHigh, int nextHigh);
/**
*
* 下发二号agv指令
* @param phase
* @param index
* @param result
@@ -56,7 +56,7 @@ public interface NDCAgvService {
public byte[] sendAgvTwoModeInst(int phase, int index, int result);
/**
*
* 下发一号agv指令
* @param phase
* @param index
* @param result

View File

@@ -14,7 +14,7 @@ import java.util.Map;
*/
public interface XianGongAgvService {
/**
*
* 查询所有AGV
* @return
*/
Map<String, AgvDto> findAllAgvFromCache();
@@ -53,7 +53,7 @@ public interface XianGongAgvService {
public HttpResponse queryXZAgvDeviceStatus();
/**
*
* 查询AGV任务状态
* @param instCode
* @return
*/
@@ -78,7 +78,7 @@ public interface XianGongAgvService {
public HttpResponse sendOrderSequencesToXZ(Instruction inst) throws Exception;
/**
*
* 添加
* @param inst
* @return
* @throws Exception
@@ -95,7 +95,7 @@ public interface XianGongAgvService {
/**
*
* 创建
* @param inst
* @param type
* @return

View File

@@ -6,6 +6,7 @@ import org.nl.acs.instruction.domain.Instruction;
/**
* 浙大AGV服务
* @author 20220102CG\noblelift
*/
public interface ZheDaAgvService {
@@ -28,7 +29,7 @@ public interface ZheDaAgvService {
public HttpResponse queryAgvInstStatus(String floor);
/**
*
* AGV任务处理
* @param jobno
* @param type
* @param address

View File

@@ -24,6 +24,9 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author 20220102CG\noblelift
*/
@Slf4j
@Service
@RequiredArgsConstructor

View File

@@ -38,6 +38,9 @@ import java.util.Map;
import static org.nl.acs.device_driver.conveyor.double_station_stacker.enums.CommandEnum.PICKUP_COMPLETE;
/**
* @author 20220102CG\noblelift
*/
@Slf4j
@Service
@RequiredArgsConstructor
@@ -173,9 +176,8 @@ public class MagicAgvServiceImpl implements MagicAgvService {
}
//指定agv车号 暂时不用
//指定agv车号 暂时不用 设置任务最终时间
//orderjo.put("intendedVehicle", "");
//设置任务最终时间
orderjo.put("deadline", AgvUtil.getNextDay(1));
orderjo.put("destinations", ja);

View File

@@ -25,6 +25,9 @@ import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
/**
* @author 20220102CG\noblelift
*/
@Slf4j
@Service
@RequiredArgsConstructor
@@ -64,7 +67,7 @@ public class NDCAgvServiceImpl implements NDCAgvService {
};
log.info("下发删除AGV指令--{}", Bytes2HexString(b));
// NDCSocketConnectionAutoRun.write(b);
// NDCSocketConnectionAutoRun.write(b);
System.out.println("下发删除agv指令数据:" + Bytes2HexString(b));
}

View File

@@ -30,6 +30,9 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author 20220102CG\noblelift
*/
@Slf4j
@Service
@RequiredArgsConstructor

View File

@@ -27,6 +27,9 @@ import org.nl.system.service.param.ISysParamService;
import org.nl.config.SpringContextHolder;
import org.springframework.stereotype.Service;
/**
* @author 20220102CG\noblelift
*/
@Slf4j
@Service
@RequiredArgsConstructor
@@ -120,13 +123,12 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
}
/**
*
* ZDAGV
* @param type
* @return
*/
@LokiLog(type = LokiLogType.AGV)
@Override
//ZDAGV
public HttpResponse queryAgvInstStatus(String type) {
if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) {
String agvurl = "";
@@ -154,7 +156,7 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
}
/**
* 处理AGV指令
* 处理AGV指令 ZDAGV
*
* @param jobno
* @param type
@@ -165,7 +167,6 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
*/
@LokiLog(type = LokiLogType.AGV)
@Override
//ZDAGV
public synchronized String process(String jobno, String type, String address, String action, String processingVehicle) {
log.info("查询到AGV请求参数,jobno:{},address:{}", jobno + ",address:" + address + ",type:" + type + ",action:" + action);
//释放AGV资源继续后续动作
@@ -197,9 +198,11 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
//豪凯自动线对接位
if (addressdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) addressdevice.getDeviceDriver();
if ((hongXiangConveyorDeviceDriver.getAction() == CommonFinalParam.ACTION_ONE || hongXiangConveyorDeviceDriver.getAction() == CommonFinalParam.ACTION_THREE) && hongXiangConveyorDeviceDriver.getMove() == 1) {
inst.setExecute_status(CommonFinalParam.ONE);
is_feedback = true;
if ((hongXiangConveyorDeviceDriver.getAction() == CommonFinalParam.ACTION_ONE || hongXiangConveyorDeviceDriver.getAction() == CommonFinalParam.ACTION_THREE)) {
if(hongXiangConveyorDeviceDriver.getMove() == 1){
inst.setExecute_status(CommonFinalParam.ONE);
is_feedback = true;
}
}
}
}
@@ -291,9 +294,11 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
if (ENTRY_REQUIRED.equals(type)) {
if (addressdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) addressdevice.getDeviceDriver();
if ((hongXiangConveyorDeviceDriver.getAction() == CommonFinalParam.ACTION_TWO || hongXiangConveyorDeviceDriver.getAction() == CommonFinalParam.ACTION_THREE) && hongXiangConveyorDeviceDriver.getMove() == 0) {
inst.setExecute_status("3");
is_feedback = true;
if ((hongXiangConveyorDeviceDriver.getAction() == CommonFinalParam.ACTION_TWO || hongXiangConveyorDeviceDriver.getAction() == CommonFinalParam.ACTION_THREE)) {
if(hongXiangConveyorDeviceDriver.getMove() == 0){
inst.setExecute_status("3");
is_feedback = true;
}
}
}
}
@@ -363,7 +368,7 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
/**
* 返回一个点位操作子任务
* 返回一个点位操作子任务 ZDAGV
*
* @param locationName 点位
* @param operation 点位操作
@@ -373,7 +378,6 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
* demo:destination("cz14", "JackUnload", "3", "")
* @return
*/
//ZDAGV
@LokiLog(type = LokiLogType.AGV)
public static JSONObject destination(String locationName, String operation, String propertiesType, String pro) {
//新增业务订单

View File

@@ -44,7 +44,7 @@ public interface LabelingTemplateService extends CommonService<LabelingTemplate>
LabelingTemplate getById(String id);
/**
*
* 根据id查询
* @param id
* @return
*/
@@ -59,21 +59,21 @@ public interface LabelingTemplateService extends CommonService<LabelingTemplate>
int insert(LabelingTemplateDto resources);
/**
*
* 根据id修改
* @param resources
* @return
*/
int updateById(LabelingTemplateDto resources);
/**
*
* 根据id删除
* @param id
* @return
*/
int removeById(String id);
/**
*
* 根据多个id删除
* @param ids
* @return
*/

View File

@@ -4,6 +4,9 @@ import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* @author LENOVO
*/
public abstract class BlockedRunable implements Runnable {
private String threadName;
private Date startTime;
@@ -16,10 +19,19 @@ public abstract class BlockedRunable implements Runnable {
this.index = index;
}
/**
* 获取code
* @return
*/
public abstract String getCode();
/**
* subRun
* @throws Exception
*/
public abstract void subRun() throws Exception;
@Override
public void run() {
try {
this.setStartTime(new Date());
@@ -60,6 +72,7 @@ public abstract class BlockedRunable implements Runnable {
this.index = index;
}
@Override
public int hashCode() {
int prime = 1;
int result = 1;
@@ -67,6 +80,7 @@ public abstract class BlockedRunable implements Runnable {
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;

View File

@@ -8,6 +8,9 @@ import org.nl.acs.device_driver.LinewayDeviceDriver;
import java.util.List;
import java.util.Map;
/**
* @author 20220102CG\noblelift
*/
public interface DeviceAppService {
/**
* 查找所有设备
@@ -32,6 +35,11 @@ public interface DeviceAppService {
*/
Device findDeviceByAddress(String address);
/**
* 设备总数
*
* @return
*/
int deviceSize();
/**
@@ -41,6 +49,10 @@ public interface DeviceAppService {
*/
Map<String, List<List<OpcItemDto>>> findAllFormatProtocolFromDriver();
/**
* key:opcServer编码,List 每个opcServe下面挂了多少Plc
* @return
*/
Map<String, List<List<OpcItemDto>>> findAllFormatProtocolFromDriverByPlc();
@@ -61,6 +73,12 @@ public interface DeviceAppService {
*/
Map<String, String> findDeviceOptions(DeviceType deviceType);
/**
* 根据设备类型查找设备
*
* @param deviceType
* @return
*/
List findDeviceByType(DeviceType deviceType);
/**
@@ -71,8 +89,16 @@ public interface DeviceAppService {
*/
List<Device> findDevice(DeviceType deviceType);
/**
* 重新加载设备驱动
*/
void reload();
/**
* 找线网设备
*
* @return
*/
List<LinewayDeviceDriver> findLaneway();
/**
@@ -83,8 +109,18 @@ public interface DeviceAppService {
*/
String findDeviceTypeByCode(String deviceCode);
/**
* 移除设备
*
* @param deviceCode
*/
void removeDevice(String deviceCode);
/**
* 添加设备
*
* @param deviceCode
*/
void addDevice(String deviceCode);
}

View File

@@ -17,11 +17,20 @@ import org.springframework.stereotype.Service;
import java.util.*;
/**
* @author 20220102CG\noblelift
*/
@Slf4j
@Service
public class DeviceAppServiceImpl implements DeviceAppService, ApplicationAutoInitial {
private List<Device> devices = new ArrayList(); // 所有设备链表
private List<String> code_indexs = new ArrayList(); // 设备对应的下表
/**
* 所有设备链表
*/
private List<Device> devices = new ArrayList();
/**
* 设备对应的下表
*/
private List<String> code_indexs = new ArrayList();
@Autowired
private DeviceManageService deviceManageService;
@Autowired
@@ -48,6 +57,7 @@ public class DeviceAppServiceImpl implements DeviceAppService, ApplicationAutoIn
return device;
}
@Override
public Device findDeviceByAddress(String address) {
Iterator var2 = this.findAllDevice().iterator();
@@ -304,6 +314,7 @@ public class DeviceAppServiceImpl implements DeviceAppService, ApplicationAutoIn
return null;
}
@Override
public List<LinewayDeviceDriver> findLaneway() {
return this.findDeviceDriver(LinewayDeviceDriver.class);
}
@@ -314,6 +325,7 @@ public class DeviceAppServiceImpl implements DeviceAppService, ApplicationAutoIn
this.reload();
}
@Override
public synchronized void reload() {
List<DeviceManageDto> deviceManageDtos = deviceManageService.queryAllWithExtra();
this.devices = new ArrayList();

View File

@@ -15,6 +15,9 @@ import org.springframework.stereotype.Service;
import java.util.*;
/**
* @author 20220102CG\noblelift
*/
@Service
@Slf4j
public class DeviceDriverDefinationAppServiceImpl implements DeviceDriverDefinationAppService, InitializingBean, ApplicationContextAware {

View File

@@ -10,6 +10,9 @@ import org.springframework.stereotype.Component;
import java.util.*;
import java.util.concurrent.*;
/**
* @author 20220102CG\noblelift
*/
@Component
@Slf4j
public class DeviceExecuteAutoRun extends AbstractAutoRunnable {
@@ -83,7 +86,6 @@ public class DeviceExecuteAutoRun extends AbstractAutoRunnable {
}
}
// Thread.sleep(10000L);
log.info("设备执行线程开始...");
while (true) {

View File

@@ -2,6 +2,9 @@ package org.nl.acs.opc;
import lombok.Data;
/**
* @author 20220102CG\noblelift
*/
@Data
public class DeviceExtraManageDto {
private String device_id;
@@ -17,7 +20,6 @@ public class DeviceExtraManageDto {
public Object parseName() {
//return DictionaryUtl.parseValue(this.getCollection_type(), this.getValue_type(), this.getName());
return extra_value;
}
}

View File

@@ -6,6 +6,9 @@ import lombok.Data;
import java.util.*;
/**
* @author 20220102CG\noblelift
*/
@Data
public class DeviceManageDto {
private static final long serialVersionUID = 1L;
@@ -53,16 +56,24 @@ public class DeviceManageDto {
private Boolean is_configed;
private Boolean is_exist;
private Boolean is_entrance;
/* 粉桶号 */
/**
* 粉桶号
*/
private String barrels_code;
/* 配合批号 */
/**
* 配合批号
*/
private String cooperate_code;
/* 粉种名称 */
/**
* 粉种名称
*/
private String powder_name;
/* 粉桶状态 */
/**
* 粉桶状态
*/
private String barrels_status;
private List<DeviceExtraManageDto> extra = new LinkedList();

View File

@@ -2,8 +2,20 @@ package org.nl.acs.opc;
import java.util.List;
/**
* @author 20220102CG\noblelift
*/
public interface DeviceManageService {
/**
* 查询所有设备
* @return
*/
List<DeviceManageDto> queryAllWithExtra();
/**
* 根据设备编号查询设备
* @param device_code
* @return
*/
List<DeviceManageDto> queryAllWithExtra(String device_code);
}

View File

@@ -21,7 +21,9 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
* @author 20220102CG\noblelift
*/
@Service
public class DeviceManageServiceImpl implements DeviceManageService {
@@ -42,24 +44,19 @@ public class DeviceManageServiceImpl implements DeviceManageService {
@Override
public List<DeviceManageDto> queryAllWithExtra() {
// JSONArray arr = WQLObject.getWQLObject("acs_device").query().getResultJSONArray(0);
// 获取所有的设备
List<Device> deviceList = new LambdaQueryChainWrapper<>(deviceMapper).list();
JSONArray arr = JSONArray.parseArray(JSON.toJSONString(deviceList));
// 获取列表扩展
// JSONArray extArr = WQLObject.getWQLObject("acs_device_extra").query().getResultJSONArray(0);
List<DeviceExtra> deviceExtraList = new LambdaQueryChainWrapper<>(deviceExtraMapper).list();
JSONArray extArr = JSONArray.parseArray(JSON.toJSONString(deviceExtraList));
// 设备+扩展DTO
List<DeviceExtraManageDto> extras = extArr.toJavaList(DeviceExtraManageDto.class);
// WQLObject runpointTab = WQLObject.getWQLObject("acs_device_runpoint");
// WQLObject opcTab = WQLObject.getWQLObject("acs_opc");
//OPC_PLC表【acs_opc_plc】
// WQLObject plcTab = WQLObject.getWQLObject("acs_opc_plc");
List<DeviceManageDto> devices = new ArrayList<>();
for (int i = 0; i < arr.size(); i++) {
JSONObject json = arr.getJSONObject(i);
@@ -68,7 +65,6 @@ public class DeviceManageServiceImpl implements DeviceManageService {
String opc_plc_id = json.getString("opc_plc_id");
if (StrUtil.isNotEmpty(opc_plc_id) && StrUtil.isNotEmpty(opc_server_id)) {
//OPC表【acs_opc】
// String opc_code = opcTab.query("is_delete= '0' AND is_active= '1' AND opc_id = '" + opc_server_id + "'").uniqueResult(0).getString("opc_code");
String opc_code = new LambdaQueryChainWrapper<>(opcMapper).apply("is_delete= '0' AND is_active= '1' AND opc_id = '" + opc_server_id + "'")
.one().getOpc_code();
/*Opc opc = opcMapper.selectOne(Wrappers.lambdaQuery(Opc.class).eq(Opc::getIs_delete, "0").eq(Opc::getIs_active, CommonFinalParam.ONE).eq(Opc::getOpc_id, opc_server_id));
@@ -77,12 +73,10 @@ public class DeviceManageServiceImpl implements DeviceManageService {
opc_code = opc.getOpc_code();
}*/
device.setOpc_server_code(opc_code);
// if(ObjectUtil.isEmpty(plcTab.query("is_delete= '0' AND is_active= '1' AND plc_id = '" + opc_plc_id + "'").uniqueResult(0)))
if (ObjectUtil.isEmpty(new LambdaQueryChainWrapper<>(opcPlcMapper).apply("is_delete= '0' AND is_active= '1' AND plc_id = '" + opc_plc_id + "'").one())) {
System.out.println(device.getDevice_code());
continue;
}
// String plc_code = plcTab.query("is_delete= '0' AND is_active= '1' AND plc_id = '" + opc_plc_id + "'").uniqueResult(0).getString("plc_code");
String plc_code = new LambdaQueryChainWrapper<>(opcPlcMapper).apply("is_delete= '0' AND is_active= '1' AND plc_id = '" + opc_plc_id + "'").one().getPlc_code();
device.setOpc_plc_code(plc_code);
}
@@ -99,10 +93,6 @@ public class DeviceManageServiceImpl implements DeviceManageService {
if (extra.getDevice_id().equals(device.getDevice_id())) {
device.getExtra().add(extra);
if (StrUtil.equals(extra.getExtra_code(), "station_manager") && StrUtil.equals(extra.getExtra_value().toString(), "true")) {
// String has_goods = runpointTab.query("is_delete= '0' AND is_active= '1' AND device_id = '" + extra.getDevice_id() + "'").uniqueResult(0).getString("hasgoods");
// String material_type = runpointTab.query("is_delete= '0' AND is_active= '1' AND device_id = '" + extra.getDevice_id() + "'").uniqueResult(0).getString("material_type");
// String batch = runpointTab.query("is_delete= '0' AND is_active= '1' AND device_id = '" + extra.getDevice_id() + "'").uniqueResult(0).getString("batch");
// String islock = runpointTab.query("is_delete= '0' AND is_active= '1' AND device_id = '" + extra.getDevice_id() + "'").uniqueResult(0).getString("islock");
String has_goods = new LambdaQueryChainWrapper<>(deviceRunpointMapper).apply("is_delete= '0' AND is_active= '1' AND device_id = '" + extra.getDevice_id() + "'").one().getHasgoods();
String material_type = new LambdaQueryChainWrapper<>(deviceRunpointMapper).apply("is_delete= '0' AND is_active= '1' AND device_id = '" + extra.getDevice_id() + "'").one().getMaterial_type();
String batch = new LambdaQueryChainWrapper<>(deviceRunpointMapper).apply("is_delete= '0' AND is_active= '1' AND device_id = '" + extra.getDevice_id() + "'").one().getBatch();
@@ -121,21 +111,15 @@ public class DeviceManageServiceImpl implements DeviceManageService {
@Override
public List<DeviceManageDto> queryAllWithExtra(String device_code) {
// JSONArray arr = WQLObject.getWQLObject("acs_device").query("device_code = '" + device_code + " '").getResultJSONArray(0);
List<Device> deviceList = new LambdaQueryChainWrapper<>(deviceMapper).eq(Device::getDevice_code, device_code).list();
JSONArray arr = JSONArray.parseArray(JSON.toJSONString(deviceList));
// JSONArray extArr = WQLObject.getWQLObject("acs_device_extra").query("device_code = '" + device_code + " '").getResultJSONArray(0);
List<DeviceExtra> deviceExtraList = new LambdaQueryChainWrapper<>(deviceExtraMapper).eq(DeviceExtra::getDevice_code, device_code).list();
JSONArray extArr = JSONArray.parseArray(JSON.toJSONString(deviceExtraList));
List<DeviceExtraManageDto> extras = extArr.toJavaList(DeviceExtraManageDto.class);
// WQLObject runpointTab = WQLObject.getWQLObject("acs_device_runpoint");
// WQLObject opcTab = WQLObject.getWQLObject("acs_opc");
//OPC_PLC表【acs_opc_plc】
// WQLObject plcTab = WQLObject.getWQLObject("acs_opc_plc");
List<DeviceManageDto> devices = new ArrayList<>();
for (int i = 0; i < arr.size(); i++) {
JSONObject json = arr.getJSONObject(i);
@@ -143,8 +127,6 @@ public class DeviceManageServiceImpl implements DeviceManageService {
String opc_server_id = json.getString("opc_server_id");
String opc_plc_id = json.getString("opc_plc_id");
if (StrUtil.isNotEmpty(opc_plc_id) && StrUtil.isNotEmpty(opc_server_id)) {
//OPC表【acs_opc】
// JSONObject rb = opcTab.query("is_delete= '0' AND is_active= '1' AND opc_id = '" + opc_server_id + "'").uniqueResult(0);
Opc opc = new LambdaQueryChainWrapper<>(opcMapper).apply("is_delete= '0' AND is_active= '1' AND opc_id = '" + opc_server_id + "'").one();
if (ObjectUtil.isEmpty(opc)) {
System.out.println(device.getDevice_code());
@@ -152,12 +134,10 @@ public class DeviceManageServiceImpl implements DeviceManageService {
}
String opc_code = opc.getOpc_code();
device.setOpc_server_code(opc_code);
// if(ObjectUtil.isEmpty(plcTab.query("is_delete= '0' AND is_active= '1' AND plc_id = '" + opc_plc_id + "'").uniqueResult(0)))
if (ObjectUtil.isEmpty(new LambdaQueryChainWrapper<>(opcPlcMapper).apply("is_delete= '0' AND is_active= '1' AND plc_id = '" + opc_plc_id + "'").one())) {
System.out.println(device.getDevice_code());
continue;
}
// String plc_code = plcTab.query("is_delete= '0' AND is_active= '1' AND plc_id = '" + opc_plc_id + "'").uniqueResult(0).getString("plc_code");
String plc_code = new LambdaQueryChainWrapper<>(opcPlcMapper).apply("is_delete= '0' AND is_active= '1' AND plc_id = '" + opc_plc_id + "'").one().getPlc_code();
device.setOpc_plc_code(plc_code);
}
@@ -174,10 +154,6 @@ public class DeviceManageServiceImpl implements DeviceManageService {
if (extra.getDevice_id().equals(device.getDevice_id())) {
device.getExtra().add(extra);
if (StrUtil.equals(extra.getExtra_code(), "station_manager") && StrUtil.equals(extra.getExtra_value().toString(), "true")) {
// String has_goods = runpointTab.query("is_delete= '0' AND is_active= '1' AND device_id = '" + extra.getDevice_id() + "'").uniqueResult(0).getString("hasgoods");
// String material_type = runpointTab.query("is_delete= '0' AND is_active= '1' AND device_id = '" + extra.getDevice_id() + "'").uniqueResult(0).getString("material_type");
// String batch = runpointTab.query("is_delete= '0' AND is_active= '1' AND device_id = '" + extra.getDevice_id() + "'").uniqueResult(0).getString("batch");
// String islock = runpointTab.query("is_delete= '0' AND is_active= '1' AND device_id = '" + extra.getDevice_id() + "'").uniqueResult(0).getString("islock");
String has_goods = new LambdaQueryChainWrapper<>(deviceRunpointMapper).apply("is_delete= '0' AND is_active= '1' AND device_id = '" + extra.getDevice_id() + "'").one().getHasgoods();
String material_type = new LambdaQueryChainWrapper<>(deviceRunpointMapper).apply("is_delete= '0' AND is_active= '1' AND device_id = '" + extra.getDevice_id() + "'").one().getMaterial_type();
String batch = new LambdaQueryChainWrapper<>(deviceRunpointMapper).apply("is_delete= '0' AND is_active= '1' AND device_id = '" + extra.getDevice_id() + "'").one().getBatch();

View File

@@ -17,7 +17,9 @@ import org.springframework.stereotype.Service;
import java.util.*;
/**
* @author 20220102CG\noblelift
*/
@Slf4j
@Service
public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerConnectionStateListener {
@@ -359,6 +361,7 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC
}
@Override
public void connectionStateChanged(boolean connected) {
if (!connected) {
this.server = null;
@@ -381,6 +384,7 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC
}
@Override
public void changed(Item item, ItemState itemState) {
String itemId = item.getId();

View File

@@ -16,6 +16,7 @@ import java.util.concurrent.Executors;
/**
* OPC设备同步启动
* @author 20220102CG\noblelift
*/
@Component
public class DeviceOpcSynchronizeAutoRun extends AbstractAutoRunnable {

View File

@@ -12,6 +12,9 @@ import java.io.IOException;
import java.util.List;
import java.util.Map;
/**
* @author 20220102CG\noblelift
*/
public class JsonUtl {
private static ObjectMapper objectMapper = null;
private static ObjectMapper objectMapperLog = null;

View File

@@ -4,6 +4,9 @@ package org.nl.acs.opc;
import java.util.Arrays;
import java.util.Objects;
/**
* @author 20220102CG\noblelift
*/
public class ObjectUtl {
private ObjectUtl() {
}

View File

@@ -1,5 +1,8 @@
package org.nl.acs.opc;
/**
* @author 20220102CG\noblelift
*/
public class OpcConfig {
public static Boolean auto_start_opc = Boolean.valueOf(true);
public static String udw_opc_value_key = "opc_value";
@@ -11,6 +14,8 @@ public class OpcConfig {
public static String resource_code = "opc_sync";
public static String resource_name = "opc同步";
//OPC 数据同步是否采用回调机制实现。之前是线程定期全部读,效率低。
/**
* OPC 数据同步是否采用回调机制实现。之前是线程定期全部读,效率低。
*/
public static Boolean opc_item_read_using_callback = false;
}

View File

@@ -3,6 +3,9 @@ package org.nl.acs.opc;
import java.util.ArrayList;
import java.util.List;
/**
* @author 20220102CG\noblelift
*/
public class OpcItemDto {
private String device_code;
private String device_name;

View File

@@ -4,6 +4,14 @@ import org.nl.acs.opc.service.dto.OpcServerManageDto;
import java.util.Map;
/**
* @author 20220102CG\noblelift
*/
public interface OpcServerManageService {
/**
* 查询所有opc服务器
*
* @return
*/
Map<String, OpcServerManageDto> queryAllServerMap();
}

View File

@@ -11,15 +11,42 @@ import org.openscada.opc.lib.da.Group;
*/
public interface OpcServerService {
/**
* 重新加载
*/
void reload();
/**
* 获取服务器
* @param var1
* @return
*/
Group getServer(String var1);
/**
* 获取服务器
* @param var1
* @return
*/
Group getServerByNewConn(String var1);
/**
* 写入整数
* @param var1
* @param var2
*/
void writeInteger(String var1, ItemValue... var2);
/**
* 写入整数
* @param var1
* @param var2
*/
void writeIntegerByNewConn(String var1, ItemValue... var2);
/**
* 清除服务器
* @param var1
*/
void clearServer(String var1);
}

View File

@@ -46,6 +46,7 @@ public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoIn
*
* @throws Exception
*/
@Override
public void autoInitial() throws Exception {
this.reload(); // 加载opc服务
if (OpcConfig.auto_start_opc) {
@@ -68,11 +69,13 @@ public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoIn
}
}
@Override
public synchronized void reload() {
this.opcServerManageDtos = this.opcServerManageService.queryAllServerMap();
this.opcServerManageDtos = Collections.synchronizedMap(this.opcServerManageDtos);
}
@Override
public synchronized Group getServer(String code) {
synchronized (this.buildLock(code)) {
Group group = null;
@@ -188,6 +191,7 @@ public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoIn
}
}
@Override
public synchronized void clearServer(String code) {
try {
Server server = (Server) this.servers.get(code);
@@ -204,6 +208,7 @@ public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoIn
this.groups.remove(code);
}
@Override
public void writeInteger(String code, ItemValue... values) {
try {
Group group = this.getServer(code);

View File

@@ -3,6 +3,9 @@ package org.nl.acs.opc;
import cn.hutool.core.util.StrUtil;
import org.openscada.opc.lib.da.Server;
/**
* @author 20220102CG\noblelift
*/
public class OpcServerUtl {
public static synchronized Server getServerWithOutException(String host, String clsid, String user, String password,

View File

@@ -1,5 +1,8 @@
package org.nl.acs.opc;
/**
* @author 20220102CG\noblelift
*/
public class OpcStartTag {
public static boolean is_run = false;
}

View File

@@ -17,6 +17,9 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.Executors;
/**
* @author 20220102CG\noblelift
*/
@Slf4j
public class OpcUtl {
private static int timeout = 1 * 60 * 1000;

View File

@@ -1,5 +1,8 @@
package org.nl.acs.opc;
/**
* @author 20220102CG\noblelift
*/
public class QualityTypeValue {
public static short OPC_QUALITY_GOOD = 192;
public static short OPC_QUALITY_LOCAL_OVERRIDE = 216;

View File

@@ -1,16 +1,25 @@
package org.nl.acs.opc;
/**
* @author 20220102CG\noblelift
*/
public class WcsConfig {
public static Integer opc_group_sync_max_item = 700;
//设备是否需要校验在线
/**
* 设备是否需要校验在线
*/
public static Boolean fake_online;
//物料默认类型描述
/**
* 物料默认类型描述
*/
public static String task_container_type_default_desc;
//重复的指令下发超时 ms
/**
* 重复的指令下发超时 ms
*/
public static Integer opc_write_repeat_check = 1000;
}

View File

@@ -16,6 +16,9 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* @author 20220102CG\noblelift
*/
@Service
public class opcServerManageServiceImpl implements OpcServerManageService {

View File

@@ -41,19 +41,48 @@ public interface OpcService extends CommonService<Opc> {
*/
List<OpcDto> queryAll(OpcQueryParam query);
/**
* 根据ID查询
*
* @param id ID
* @return Opc
*/
Opc getById(String id);
/**
* 根据ID查询
*
* @param id ID
* @return OpcDto
*/
OpcDto findById(String id);
/**
* 插入一条新数据。
* @param resources
* @return
*/
int insert(OpcDto resources);
/**
* 编辑一条数据
* @param resources
* @return
*/
int updateById(OpcDto resources);
/**
* 删除数据
* @param id
* @return
*/
int removeById(String id);
/**
* 根据多个id删除
* @param ids
* @return
*/
int removeByIds(Set<String> ids);
/**
@@ -136,11 +165,30 @@ public interface OpcService extends CommonService<Opc> {
*/
OpcDto queryServerPlc(String opc_id);
/**
* 查询
*
* @param whereJson 条件
* @return Map<String, String>
*/
HashMap<String, String> getmeteal(Map whereJson);
/**
* 创建PLC
*
* @param map map
*/
void createPLC(Map map);
/**
* 删除plc
* @param map
*/
void delPLC(Map map);
/**
* 编辑plc
* @param json
*/
void editPLC(JSONObject json);
}

View File

@@ -1,5 +1,8 @@
package org.nl.acs.opc.service.dto;
/**
* @author 20220102CG\noblelift
*/
public class OpcServerManageDto {
private static final long serialVersionUID = 1L;

View File

@@ -48,10 +48,11 @@ import java.util.*;
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class OpcServiceImpl extends CommonServiceImpl<OpcMapper, Opc> implements OpcService {
// private final RedisUtils redisUtils;
private final OpcMapper opcMapper;
private final OpcPlcMapper opcPlcMapper;
private static final String BLURRY = "blurry";
@Override
public PageInfo<OpcDto> queryAll(OpcQueryParam query, Pageable pageable) {
IPage<Opc> queryPage = PageUtil.toMybatisPage(pageable);
@@ -130,7 +131,7 @@ public class OpcServiceImpl extends CommonServiceImpl<OpcMapper, Opc> implements
IPage<Opc> queryPage = PageUtil.toMybatisPage(page);
LambdaQueryWrapper<Opc> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(Opc::getIs_delete, "0").eq(Opc::getIs_active, CommonFinalParam.ONE);
if (whereJson.get("blurry") != null) {
if (whereJson.get(BLURRY) != null) {
wrapper.like(Opc::getOpc_code, whereJson.get("blurry")).or().like(Opc::getOpc_name, whereJson.get("blurry")).or().like(Opc::getOpc_host, whereJson.get("blurry"));
}
IPage<Opc> opcPage = opcMapper.selectPage(queryPage, wrapper);
@@ -179,7 +180,7 @@ public class OpcServiceImpl extends CommonServiceImpl<OpcMapper, Opc> implements
@Override
public List<OpcDto> queryAll(Map whereJson) {
LambdaQueryWrapper<Opc> wrapper = new LambdaQueryWrapper<>();
if (whereJson.get("blurry") != null) {
if (whereJson.get(BLURRY) != null) {
wrapper.like(Opc::getOpc_code, whereJson.get("blurry")).or().like(Opc::getOpc_name, whereJson.get("blurry")).or().like(Opc::getOpc_host, whereJson.get("blurry"));
}
return ConvertUtil.convertList(opcMapper.selectList(wrapper), OpcDto.class);