This commit is contained in:
USER-20220102CG\noblelift
2022-08-18 08:52:16 +08:00
parent 512cd3acd3
commit 5a7d010c93
3 changed files with 0 additions and 299 deletions

View File

@@ -1,104 +0,0 @@
package org.nl.acs.test.rest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.test.service.TestService;
import org.nl.annotation.Log;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
import java.util.Map;
/**
* @author ldjun
* @date 2021-03-18
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "任务管理")
@RequestMapping("/api/test")
@Slf4j
public class TestController {
private final TestService testService;
@Log("test1")
@ApiOperation("test1")
@PostMapping("/test1")
//@PreAuthorize("@el.check('task:add')")
public ResponseEntity<Object> test1() throws IOException {
testService.test1();
return new ResponseEntity<>(HttpStatus.CREATED);
}
@Log("test2")
@ApiOperation("test2")
@PostMapping("/test2")
//@PreAuthorize("@el.check('task:add')")
public ResponseEntity<Object> test2() throws IOException {
testService.test2();
return new ResponseEntity<>(HttpStatus.CREATED);
}
@Log("test3")
@ApiOperation("test3")
@PostMapping("/test3")
//@PreAuthorize("@el.check('task:add')")
public ResponseEntity<Object> test3() throws IOException {
testService.test3();
return new ResponseEntity<>(HttpStatus.CREATED);
}
@Log("test4")
@ApiOperation("test4")
@PostMapping("/test4")
//@PreAuthorize("@el.check('task:add')")
public ResponseEntity<Object> test4(@RequestBody Map map) throws IOException {
testService.test4(map);
return new ResponseEntity<>(HttpStatus.CREATED);
}
@Log("test5")
@ApiOperation("test5")
@PostMapping("/test5")
//@PreAuthorize("@el.check('task:add')")
public ResponseEntity<Object> test5() throws IOException {
testService.test5();
return new ResponseEntity<>(HttpStatus.CREATED);
}
@Log("test6")
@ApiOperation("test6")
@PostMapping("/test6")
//@PreAuthorize("@el.check('task:add')")
public ResponseEntity<Object> test6(@RequestBody Map map) throws IOException {
testService.test6(map);
return new ResponseEntity<>(HttpStatus.CREATED);
}
@Log("test7")
@ApiOperation("test7")
@PostMapping("/test7")
//@PreAuthorize("@el.check('task:add')")
public ResponseEntity<Object> test7() throws IOException {
testService.test7();
return new ResponseEntity<>(HttpStatus.CREATED);
}
@Log("print")
@ApiOperation("print")
@PostMapping("/print")
//@PreAuthorize("@el.check('task:add')")
public ResponseEntity<Object> print() throws IOException {
return new ResponseEntity<>(testService.print(), HttpStatus.OK);
}
}

View File

@@ -1,72 +0,0 @@
package org.nl.acs.test.service;
import com.alibaba.fastjson.JSONObject;
import java.io.IOException;
import java.util.Map;
/**
* @author ldjun
* @description 服务接口
* @date 2021-03-18
**/
public interface TestService {
/**
* 初始化
*
* @throws IOException
*/
void test1() throws IOException;
/**
* 触发打印
*
* @throws IOException
*/
void test2() throws IOException;
/**
* 加载模板
*
* @throws IOException
*/
void test3() throws IOException;
/**
* 发送bufferdata缓存数据
*
* @throws IOException
*/
void test4(Map map) throws IOException;
/**
* 清空缓存
*
* @throws IOException
*/
void test5() throws IOException;
/**
* 发送settext指令
*
* @throws IOException
*/
void test6(Map map) throws IOException;
/**
* 事务发送
*
* @throws IOException
*/
void test7() throws IOException;
/**
* 发送打印
*
* @throws IOException
*/
JSONObject print() throws IOException;
}

View File

@@ -1,123 +0,0 @@
package org.nl.acs.test.service.impl;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.test.service.TestService;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.Map;
/**
* @author ldjun
* @description 服务实现
* @date 2021-03-18
**/
@Service
@RequiredArgsConstructor
@Slf4j
public class TestServiceImpl implements TestService {
@Override
public void test1() throws IOException {
try {
//返回编译完成信号
LetteringSocketConnectionAutoRun.write("SETMSG 26 1" + "\r\n");
//返回打印开始信号
LetteringSocketConnectionAutoRun.write("SETMSG 2 1" + "\r\n");
//返回打印完成信号
LetteringSocketConnectionAutoRun.write("SETMSG 3 1" + "\r\n");
//返回每次打印的内容
LetteringSocketConnectionAutoRun.write("SETMSG 24 1" + "\r\n");
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void test2() throws IOException {
try {
LetteringSocketConnectionAutoRun.write("BUFFERCLEAR" + "\r\n");
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void test3() throws IOException {
// LOADPROJECT "ZY.lbm"
//此处为模板名称 D310激光机,加载CS.lbm模版
String str = "CS.lbm";
try {
LetteringSocketConnectionAutoRun.write("LOADPROJECT" + " \"" + str + "\"" + "\r\n");
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void test4(Map map) throws IOException {
String name = map.get("name").toString();
String name2 = map.get("name2").toString();
String name3 = map.get("name3").toString();
String name4 = map.get("name4").toString();
String yh = "\"";
try {
//先清空缓存
LetteringSocketConnectionAutoRun.write("BUFFERCLEAR" + "\r\n");
// test5();
// LetteringSocketConnectionAutoRun.write("BUFFERDATA -1 "+ yh + name + yh +" " + yh + name2 + yh +" "
// +yh +name3 +yh + " " + yh + name4 + yh + "\r\n");
//两行
// LetteringSocketConnectionAutoRun.write("BUFFERDATA -1 "+ yh + name + yh +" " + yh + name2 + yh +" "
// + "\r\n");
LetteringSocketConnectionAutoRun.write("BUFFERDATA -1 " + yh + name + yh + " " + "\r\n");
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void test5() throws IOException {
try {
LetteringSocketConnectionAutoRun.write("BUFFERCLEAR" + "\r\n");
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void test6(Map map) throws IOException {
String yh = "\"";
String inst = map.get("inst").toString();
String inst2 = map.get("inst2").toString();
String strInst = "SETTEXT " + "S1" + " " + yh + inst + yh + "\r\n"; //2个变量
String strInst2 = "SETTEXT " + "S2" + " " + yh + inst2 + yh + "\r\n"; //2个变量
LetteringSocketConnectionAutoRun.write(strInst);
LetteringSocketConnectionAutoRun.write(strInst2);
}
@Override
public void test7() throws IOException {
}
@Override
public JSONObject print() throws IOException {
JSONObject jo = new JSONObject();
jo.put("cpbh", "A1111111111");
jo.put("cpmc", "产品名称:A1111111111");
return jo;
}
}