2023-02-14 09:08:21 +08:00
|
|
|
package com.cnbm.packing.controller;
|
|
|
|
|
2023-02-25 14:19:33 +08:00
|
|
|
import com.cnbm.dispatch.enums.kuka.step1.Step1Mes2PlcVar;
|
|
|
|
import com.cnbm.dispatch.enums.kuka.step1.Step1Plc2MesVar;
|
|
|
|
import com.cnbm.dispatch.enums.kuka.step2.Step2Mes2PlcVar;
|
|
|
|
import com.cnbm.dispatch.enums.kuka.step2.Step2Plc2MesVar;
|
|
|
|
import com.cnbm.dispatch.enums.kuka.step3.Step3Mes2PlcVar;
|
|
|
|
import com.cnbm.dispatch.enums.kuka.step3.Step3Plc2MesVar;
|
2023-02-24 14:21:25 +08:00
|
|
|
import com.cnbm.packing.service.DynamicDataSourceService;
|
2023-02-25 14:19:33 +08:00
|
|
|
import com.cnbm.s7.entity.R;
|
|
|
|
import com.cnbm.s7.s7connector.enmuc.S7Client;
|
2023-02-14 09:08:21 +08:00
|
|
|
import io.swagger.annotations.Api;
|
2023-02-24 14:21:25 +08:00
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
2023-02-25 14:19:33 +08:00
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
2023-02-24 14:21:25 +08:00
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
2023-02-14 09:08:21 +08:00
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import com.cnbm.common.utils.Result;
|
2023-02-24 14:21:25 +08:00
|
|
|
import springfox.documentation.annotations.ApiIgnore;
|
|
|
|
|
2023-02-25 14:19:33 +08:00
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
|
import java.text.ParseException;
|
2023-02-24 14:21:25 +08:00
|
|
|
import java.util.Map;
|
|
|
|
|
2023-02-25 14:19:33 +08:00
|
|
|
|
2023-02-14 09:08:21 +08:00
|
|
|
/**
|
|
|
|
* @Author weihongyang
|
|
|
|
* @Date 2022/6/24 8:57 AM
|
|
|
|
* @Version 1.0
|
|
|
|
*/
|
|
|
|
@RestController
|
2023-02-24 14:21:25 +08:00
|
|
|
@RequestMapping("/test")
|
|
|
|
@Api(tags="测试接口")
|
2023-02-14 09:08:21 +08:00
|
|
|
public class TestController {
|
|
|
|
|
2023-02-25 14:19:33 +08:00
|
|
|
private static final Logger logger = LoggerFactory.getLogger(TestController.class);
|
2023-02-24 14:21:25 +08:00
|
|
|
@Autowired
|
|
|
|
DynamicDataSourceService service;
|
2023-02-25 14:19:33 +08:00
|
|
|
private Object read(S7Client s7Client,Step1Plc2MesVar var) throws UnsupportedEncodingException, ParseException {
|
|
|
|
try {
|
|
|
|
return s7Client.read(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getLength(), var.getStrSize(), var.getType());
|
|
|
|
}catch (Exception e){
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private Object read(S7Client s7Client,Step1Mes2PlcVar var) throws UnsupportedEncodingException, ParseException {
|
|
|
|
try {
|
|
|
|
return s7Client.read(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getLength(), var.getStrSize(), var.getType());
|
|
|
|
}catch (Exception e){
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private Object read(S7Client s7Client,Step2Plc2MesVar var) throws UnsupportedEncodingException, ParseException {
|
|
|
|
try {
|
|
|
|
return s7Client.read(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getLength(), var.getStrSize(), var.getType());
|
|
|
|
}catch (Exception e){
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private Object read(S7Client s7Client,Step2Mes2PlcVar var) throws UnsupportedEncodingException, ParseException {
|
|
|
|
try {
|
|
|
|
return s7Client.read(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getLength(), var.getStrSize(), var.getType());
|
|
|
|
}catch (Exception e){
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private Object read(S7Client s7Client,Step3Plc2MesVar var) throws UnsupportedEncodingException, ParseException {
|
|
|
|
try {
|
|
|
|
return s7Client.read(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getLength(), var.getStrSize(), var.getType());
|
|
|
|
}catch (Exception e){
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private Object read(S7Client s7Client,Step3Mes2PlcVar var) throws UnsupportedEncodingException, ParseException {
|
|
|
|
try {
|
|
|
|
return s7Client.read(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getLength(), var.getStrSize(), var.getType());
|
|
|
|
}catch (Exception e){
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@PostMapping("/testReadAll")
|
|
|
|
public R testReadAll() throws UnsupportedEncodingException, ParseException {
|
|
|
|
for(Step1Plc2MesVar actual:Step1Plc2MesVar.values()){
|
|
|
|
logger.info(read(S7Client.S7_KUKA,actual).toString());
|
|
|
|
System.out.println(actual.getName().toString()+" : "+read(S7Client.S7_KUKA,actual).toString());
|
|
|
|
}
|
|
|
|
for(Step1Mes2PlcVar actual:Step1Mes2PlcVar.values()){
|
|
|
|
logger.info(read(S7Client.S7_KUKA,actual).toString());
|
|
|
|
System.out.println(actual.getName().toString()+" : "+read(S7Client.S7_KUKA,actual).toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
for(Step2Plc2MesVar actual:Step2Plc2MesVar.values()){
|
|
|
|
logger.info(read(S7Client.S7_KUKA,actual).toString());
|
|
|
|
System.out.println(actual.getName().toString()+" : "+read(S7Client.S7_KUKA,actual).toString());
|
|
|
|
}
|
|
|
|
for(Step2Mes2PlcVar actual:Step2Mes2PlcVar.values()){
|
|
|
|
logger.info(read(S7Client.S7_KUKA,actual).toString());
|
|
|
|
System.out.println(actual.getName().toString()+" : "+read(S7Client.S7_KUKA,actual).toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
for(Step3Plc2MesVar actual:Step3Plc2MesVar.values()){
|
|
|
|
logger.info(read(S7Client.S7_KUKA,actual).toString());
|
|
|
|
System.out.println(actual.getName().toString()+" : "+read(S7Client.S7_KUKA,actual).toString());
|
|
|
|
}
|
|
|
|
for(Step3Mes2PlcVar actual:Step3Mes2PlcVar.values()){
|
|
|
|
logger.info(read(S7Client.S7_KUKA,actual).toString());
|
|
|
|
System.out.println(actual.getName().toString()+" : "+read(S7Client.S7_KUKA,actual).toString());
|
|
|
|
}
|
|
|
|
return R.ok();
|
|
|
|
}
|
|
|
|
@PostMapping("/testlogger")
|
|
|
|
public R testlogger() {
|
|
|
|
logger.info("test logger");
|
|
|
|
System.out.println("test logger");
|
|
|
|
return R.ok();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-02-24 14:21:25 +08:00
|
|
|
@PostMapping("getPMPPBySubId")
|
|
|
|
@ApiImplicitParams({
|
|
|
|
@ApiImplicitParam(name = "subId", value = "基板ID", paramType = "query", required = true, dataTypeClass=Integer.class) ,
|
|
|
|
})
|
|
|
|
public Result<Float> getPMPPBySubId(@ApiIgnore @RequestParam Map<String, Object> params){
|
|
|
|
Object subId = params.get("subId");
|
|
|
|
return new Result<Float>().ok(service.getPMPPBySubId(subId.toString()));
|
|
|
|
}
|
|
|
|
@PostMapping("getOrderNameBySubId")
|
|
|
|
@ApiImplicitParams({
|
|
|
|
@ApiImplicitParam(name = "subId", value = "基板ID", paramType = "query", required = true, dataTypeClass=Integer.class) ,
|
|
|
|
})
|
|
|
|
public Result<String> getOrderNameBySubId(@ApiIgnore @RequestParam Map<String, Object> params){
|
|
|
|
Object subId = params.get("subId");
|
|
|
|
//service.getExtendArgFromCamline()
|
|
|
|
return new Result<String>().ok(service.getOrderNameBySubId(subId.toString()));
|
2023-02-14 09:08:21 +08:00
|
|
|
}
|
|
|
|
|
2023-02-24 14:21:25 +08:00
|
|
|
@PostMapping("getExtendArgFromCamline")
|
|
|
|
@ApiImplicitParams({
|
|
|
|
@ApiImplicitParam(name = "subId", value = "基板ID", paramType = "query", required = true, dataTypeClass=Integer.class) ,
|
|
|
|
})
|
|
|
|
public Result<String> getExtendArgFromCamline(@ApiIgnore @RequestParam Map<String, Object> params){
|
|
|
|
Object subId = params.get("subId");
|
|
|
|
return new Result<String>().ok(service.getExtendArgFromCamline(subId.toString()).toString());
|
2023-02-14 09:08:21 +08:00
|
|
|
}
|
2023-02-24 14:21:25 +08:00
|
|
|
|
2023-02-14 09:08:21 +08:00
|
|
|
}
|