刘先源
2 weeks ago
10 changed files with 184 additions and 50 deletions
@ -0,0 +1,21 @@ |
|||
package org.nl.acs.agv.server; |
|||
|
|||
import com.alibaba.fastjson.JSONObject; |
|||
import org.nl.acs.ext.UnifiedResponse; |
|||
import org.nl.acs.instruction.service.dto.Instruction; |
|||
|
|||
/** |
|||
* @Author: lyd |
|||
* @Description: |
|||
* @Date: 2022-08-15 |
|||
*/ |
|||
public interface ConveyorService { |
|||
/** |
|||
* 请求输送线取放货 |
|||
* |
|||
* @param json |
|||
* @return |
|||
*/ |
|||
JSONObject applyPutAndGet(JSONObject json); |
|||
|
|||
} |
@ -0,0 +1,48 @@ |
|||
package org.nl.acs.agv.server.impl; |
|||
|
|||
import cn.hutool.core.util.StrUtil; |
|||
import cn.hutool.http.HttpRequest; |
|||
import com.alibaba.fastjson.JSON; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.nl.acs.agv.server.ConveyorService; |
|||
import org.nl.acs.config.AcsConfig; |
|||
import org.nl.modules.common.exception.BadRequestException; |
|||
import org.nl.modules.system.service.ParamService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Slf4j |
|||
@Service |
|||
@RequiredArgsConstructor |
|||
public class ConveyorServiceImpl implements ConveyorService { |
|||
|
|||
@Autowired |
|||
private ParamService paramService; |
|||
|
|||
@Override |
|||
public JSONObject applyPutAndGet(JSONObject json) { |
|||
log.info("applyPutAndGet - 请求参数 {}"+ json.toString()); |
|||
|
|||
if (!StrUtil.equals(paramService.findByCode(AcsConfig.CONVEYOR).getValue(), "1")) { |
|||
throw new BadRequestException("未连接输送线系统!"); |
|||
} |
|||
String url = paramService.findByCode(AcsConfig.CONVEYOR_URL).getValue(); |
|||
try { |
|||
/* String body = HttpRequest |
|||
.post(url) |
|||
.setConnectionTimeout(10000) |
|||
.body(JSON.toJSONString(json)) |
|||
.execute() |
|||
.body(); |
|||
log.info("applyPutAndGet - 返回参数 {}", body); |
|||
return JSON.parseObject(body);*/ |
|||
JSONObject result = new JSONObject(); |
|||
result.put("action", "1"); |
|||
return JSON.parseObject(result.toString()); |
|||
} catch (Exception e) { |
|||
throw new BadRequestException(e.getMessage()); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,33 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<included> |
|||
<springProperty scope="context" name="logPath" source="logging.file.path" defaultValue="logs"/> |
|||
<property name="LOG_HOME" value="${logPath}"/> |
|||
<!-- 按照每天生成日志文件 --> |
|||
<appender name="ConveyorServiceImpl" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
|||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> |
|||
<!--日志文件输出的文件名--> |
|||
<FileNamePattern>${LOG_HOME}/ACS请求输送线/%d{yyyy-MM-dd}.%i.log</FileNamePattern> |
|||
<!--日志文件保留天数--> |
|||
<maxHistory>15</maxHistory> |
|||
<!--单个日志最大容量 至少10MB才能看得出来--> |
|||
<maxFileSize>200MB</maxFileSize> |
|||
<!--所有日志最多占多大容量--> |
|||
<totalSizeCap>2GB</totalSizeCap> |
|||
</rollingPolicy> |
|||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> |
|||
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符--> |
|||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> |
|||
<charset>${log.charset}</charset> |
|||
</encoder> |
|||
|
|||
</appender> |
|||
|
|||
<appender name="asyncFileAppender" class="ch.qos.logback.classic.AsyncAppender"> |
|||
<appender-ref ref="ConveyorServiceImpl"/> |
|||
<!-- 设置队列大小,根据您的需求调整 --> |
|||
<queueSize>512</queueSize> |
|||
</appender> |
|||
<logger name="org.nl.acs.agv.server.impl.ConveyorServiceImpl" level="info" additivity="true"> |
|||
<appender-ref ref="asyncFileAppender"/> |
|||
</logger> |
|||
</included> |
Loading…
Reference in new issue