add 代码提交
This commit is contained in:
@@ -20,6 +20,7 @@ import org.nl.acs.opc.DeviceAppServiceImpl;
|
||||
import org.nl.common.utils.CodeUtil;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.nl.system.service.param.ISysParamService;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -31,6 +32,7 @@ import java.util.Map;
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Lazy
|
||||
public class NDCAgvServiceImpl implements NDCAgvService {
|
||||
|
||||
private final DeviceAppService deviceAppService;
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.nl.config.language.LangProcess;
|
||||
import org.nl.system.service.param.ISysParamService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@@ -42,6 +43,7 @@ import java.util.Map;
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Lazy
|
||||
public class XianGongAgvServiceImpl implements XianGongAgvService {
|
||||
private final DeviceAppService deviceAppService;
|
||||
private final ISysParamService paramService;
|
||||
|
||||
@@ -2,7 +2,11 @@ package org.nl.acs.device_driver.conveyor.carton_labeling_machine;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
@@ -24,13 +28,21 @@ import org.nl.acs.monitor.DeviceStageMonitor;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.route.service.RouteLineService;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.common.mnt.websocket.SendPrintSocket;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.nl.system.service.lucene.LuceneExecuteLogService;
|
||||
import org.nl.system.service.param.ISysParamService;
|
||||
import org.nl.system.service.tickets.TicketsService;
|
||||
import org.nl.system.service.tickets.dto.Tickets;
|
||||
import org.nl.system.service.tickets.dto.mapper.TicketsMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Method;
|
||||
import java.math.BigInteger;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@@ -63,6 +75,10 @@ public class CartonLabelingMachineDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
|
||||
TicketsService ticketService = SpringContextHolder.getBean("ticketsServiceImpl");
|
||||
|
||||
// @Autowired
|
||||
// private TicketsMapper ticketsMapper;
|
||||
TicketsMapper ticketsMapper=SpringContextHolder.getBean("ticketsMapper");
|
||||
|
||||
String device_code;
|
||||
int mode = 0;
|
||||
int error = 0;
|
||||
@@ -129,7 +145,7 @@ public class CartonLabelingMachineDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
public void execute() throws JsonProcessingException {
|
||||
message = null;
|
||||
try {
|
||||
device_code = this.getDeviceCode();
|
||||
@@ -137,15 +153,13 @@ public class CartonLabelingMachineDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
status = this.itemProtocol.getStatus();
|
||||
error = this.itemProtocol.getError();
|
||||
move = this.itemProtocol.getMove();
|
||||
|
||||
weight=this.itemProtocol.getWeight();
|
||||
if(mode != last_mode){
|
||||
requireSucess = false;
|
||||
}
|
||||
|
||||
} catch (Exception var17) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mode == 0) {
|
||||
this.setIsonline(false);
|
||||
this.setIserror(true);
|
||||
@@ -163,32 +177,106 @@ public class CartonLabelingMachineDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
Instruction instruction = null;
|
||||
List toInstructions;
|
||||
|
||||
if (mode == 8 && status == 1 && move == 1 && !requireSucess) {
|
||||
if (mode == 8 && move == 1 && !requireSucess) {
|
||||
//TODO:将贴标信息下发,并反馈200
|
||||
// deliverTheTemplate();
|
||||
String template_address = paramService.findByCode("template_address").getValue();
|
||||
if(StrUtil.isNotEmpty(template_address)){
|
||||
FileWriter fw = null;
|
||||
try{
|
||||
File file = new File(template_address);
|
||||
if (!file.exists()) {
|
||||
file.createNewFile();
|
||||
JSONObject template= ticketsMapper.template();
|
||||
String jsonString = template.toString();
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
// 解析外部 JSON 字符串,获取 "template" 字段的值
|
||||
JsonNode rootNode = objectMapper.readTree(jsonString);
|
||||
String templateJson = rootNode.get("template").asText();
|
||||
// 解析嵌套的 "template" 字符串为 JSON 对象
|
||||
JsonNode templateNode = objectMapper.readTree(templateJson);
|
||||
// 输出 panels 数据
|
||||
JSONObject jsonObject = JSONObject.parseObject(templateNode.toString());
|
||||
// 获取 panels 数组
|
||||
JSONArray panels = jsonObject.getJSONArray("panels");
|
||||
JSONObject panel = panels.getJSONObject(0);
|
||||
// 获取 printElements 数组
|
||||
JSONArray printElements = panel.getJSONArray("printElements");
|
||||
for (int i = 0; i < printElements.size(); i++) {
|
||||
JSONObject printElement = printElements.getJSONObject(i);
|
||||
JSONObject options = printElement.getJSONObject("options");
|
||||
if(options.containsKey("testData")){
|
||||
if(options.get("testData").equals("date")){
|
||||
LocalDate currentDate = LocalDate.now();
|
||||
options.put("title","日期: "+currentDate);
|
||||
printElement.put("options",options);
|
||||
}
|
||||
fw = new FileWriter(template_address);
|
||||
OutputStreamWriter write = new OutputStreamWriter(new FileOutputStream(file), "utf-8");
|
||||
BufferedWriter bw = new BufferedWriter(write);
|
||||
bw.write("");
|
||||
bw.close();
|
||||
}catch(Exception e){
|
||||
|
||||
}finally {
|
||||
try {
|
||||
fw.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
if(options.get("testData").equals("weight")){
|
||||
options.put("title","重量: "+weight+"kg");
|
||||
printElement.put("options",options);
|
||||
}
|
||||
if(options.get("testData").equals("time")){
|
||||
LocalTime currentTime = LocalTime.now();
|
||||
options.put("title","时间: "+ currentTime.getHour() + ":" + currentTime.getMinute() + ":" + currentTime.getSecond());
|
||||
printElement.put("options",options);
|
||||
}
|
||||
}else{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
jsonObject.put("type", 2);
|
||||
requireSucess=true;
|
||||
log.info("纸箱打印数据: " + jsonObject.toString());
|
||||
SendPrintSocket.sendPrint(jsonObject.toString());
|
||||
Map map = new HashMap();
|
||||
map.put("to_command", 200);
|
||||
this.writing(map);
|
||||
} else {
|
||||
message = "无请求";
|
||||
}
|
||||
if (mode == 7 && move == 1 && !requireSucess) {
|
||||
//TODO:将贴标信息下发,并反馈200
|
||||
JSONObject template= ticketsMapper.template1();
|
||||
Tickets tickets=ticketsMapper.ticket();
|
||||
String bottle_number=tickets.getBottle_number();
|
||||
String fbottle_number=tickets.getFbottle_number();
|
||||
Integer fbottle_number1=Integer.parseInt(fbottle_number);
|
||||
String psletters = bottle_number.substring(0,18);
|
||||
String psdigits = bottle_number.substring(18,23);
|
||||
Integer psdigits1=Integer.parseInt(psdigits)-fbottle_number1;
|
||||
String jsonString = template.toString();
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
// 解析外部 JSON 字符串,获取 "template" 字段的值
|
||||
JsonNode rootNode = objectMapper.readTree(jsonString);
|
||||
String templateJson = rootNode.get("template").asText();
|
||||
// 解析嵌套的 "template" 字符串为 JSON 对象
|
||||
JsonNode templateNode = objectMapper.readTree(templateJson);
|
||||
// 输出 panels 数据
|
||||
JSONObject jsonObject = JSONObject.parseObject(templateNode.toString());
|
||||
// 获取 panels 数组
|
||||
JSONArray panels = jsonObject.getJSONArray("panels");
|
||||
JSONObject panel = panels.getJSONObject(0);
|
||||
// 获取 printElements 数组
|
||||
JSONArray printElements = panel.getJSONArray("printElements");
|
||||
for (int i = 0; i < printElements.size(); i++) {
|
||||
JSONObject printElement = printElements.getJSONObject(i);
|
||||
JSONObject options = printElement.getJSONObject("options");
|
||||
if(options.containsKey("testData")){
|
||||
if(options.get("title").equals("二维码")){
|
||||
String number1=psletters+psdigits1;
|
||||
options.put("testData",number1);
|
||||
printElement.put("options",options);
|
||||
}
|
||||
else if(options.get("testData").equals("瓶号")){
|
||||
String number1=psletters+psdigits1;
|
||||
options.put("title",number1);
|
||||
printElement.put("options",options);
|
||||
}
|
||||
}else{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
jsonObject.put("type", 1);
|
||||
requireSucess=true;
|
||||
fbottle_number1=fbottle_number1+1;
|
||||
String fbottle_number2=String.valueOf(fbottle_number1);
|
||||
// 输出 panels 数据
|
||||
SendPrintSocket.sendPrint(jsonObject.toString());
|
||||
log.info("瓶盖打印数据: " + jsonObject.toString());
|
||||
tickets.setFbottle_number(fbottle_number2);
|
||||
ticketsMapper.updateById(tickets);
|
||||
Map map = new HashMap();
|
||||
map.put("to_command", 200);
|
||||
map.put("to_message","");
|
||||
|
||||
@@ -47,6 +47,10 @@ public class ItemProtocol {
|
||||
* 贴标信息
|
||||
*/
|
||||
public static String item_to_message = "to_message";
|
||||
/**
|
||||
* 重量
|
||||
*/
|
||||
public static String item_weight = "weight";
|
||||
|
||||
|
||||
Boolean isonline;
|
||||
@@ -89,6 +93,9 @@ public class ItemProtocol {
|
||||
return this.getOpcStringValue(item_to_message);
|
||||
}
|
||||
|
||||
public float getWeight(){
|
||||
return this.getOpcFloatValue(item_weight);
|
||||
}
|
||||
/**
|
||||
* 是否有货
|
||||
* @param move
|
||||
@@ -137,6 +144,7 @@ public class ItemProtocol {
|
||||
list.add(new ItemDto(item_status, "设备状态", "DB81.B3"));
|
||||
list.add(new ItemDto(item_error, "故障", "DB81.B5"));
|
||||
list.add(new ItemDto(item_move, "光电", "DB81.B2"));
|
||||
list.add(new ItemDto(item_weight, "重量", "DB81.B2"));
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@@ -80,6 +80,10 @@ public class ItemProtocol {
|
||||
* 生产重量(单位:g)
|
||||
*/
|
||||
private static String item_to_weight = "to_weight";
|
||||
/**
|
||||
* 是否打印瓶身
|
||||
*/
|
||||
private static String item_is_printbottle = "is_printbottle";
|
||||
|
||||
private PrimaryDeviceConveyorDeviceDriver driver;
|
||||
|
||||
@@ -148,6 +152,10 @@ public class ItemProtocol {
|
||||
return this.getOpcIntegerValue(item_to_ice);
|
||||
}
|
||||
|
||||
public int getIs_printbottle() {
|
||||
return this.getOpcIntegerValue(item_is_printbottle);
|
||||
}
|
||||
|
||||
public Float getTo_weight() {
|
||||
return this.getOpcFloatValue(item_to_weight);
|
||||
}
|
||||
@@ -211,6 +219,7 @@ public class ItemProtocol {
|
||||
list.add(new ItemDto(item_to_labeling1, "人工贴标1(后贴标位)", "DB601.D8"));
|
||||
list.add(new ItemDto(item_to_ice, "加冰", "DB601.D8"));
|
||||
list.add(new ItemDto(item_to_weight, "生产重量", "DB601.D8"));
|
||||
list.add(new ItemDto(item_is_printbottle, "是否打印瓶身", "DB601.D8"));
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,8 @@ import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.acs.task.service.dto.TaskDto;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.nl.config.thread.ThreadPoolExecutorUtil;
|
||||
import org.nl.system.service.lucene.LuceneExecuteLogService;
|
||||
import org.nl.system.service.lucene.dto.LuceneLogDto;
|
||||
import org.nl.system.service.tickets.dto.Tickets;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
|
||||
@@ -406,6 +408,44 @@ public class PrimaryDeviceConveyorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* 多个信号一起下发电气
|
||||
*
|
||||
* @param map
|
||||
*/
|
||||
|
||||
public void writing(Map<String, Object> map) {
|
||||
LuceneExecuteLogService lucene = SpringContextHolder.getBean(LuceneExecuteLogService.class);
|
||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
|
||||
Map<String, Object> itemMap = new LinkedHashMap<>();
|
||||
map.forEach((key, value) -> {
|
||||
if (ObjectUtil.isNotEmpty(value)) {
|
||||
itemMap.put(getToParam() + key, value);
|
||||
}
|
||||
});
|
||||
if (ObjectUtil.isNotEmpty(itemMap)) {
|
||||
try {
|
||||
this.checkcontrol(itemMap);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
try{
|
||||
this.checkcontrol(itemMap);
|
||||
} catch (Exception e1){
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
|
||||
lucene.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号:" + itemMap));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 抽取统一下发电气信号前缀
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getToParam() {
|
||||
return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + ".";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public class MesToAcsServiceImpl implements MesToAcsService {
|
||||
public Object issuedTickets(JSONObject json) {
|
||||
if(ObjectUtil.isNotEmpty(json)){
|
||||
Tickets tickets = BeanUtil.copyProperties(json, Tickets.class);
|
||||
if(StrUtil.isEmpty(tickets.getTicket_code()) || StrUtil.isEmpty(tickets.getProduction_orders()) || StrUtil.isEmpty(tickets.getDevice_code())){
|
||||
if(StrUtil.isEmpty(tickets.getTicket_code()) || StrUtil.isEmpty(tickets.getActual_batch()) || StrUtil.isEmpty(tickets.getDevice_code())){
|
||||
throw new BadRequestException("工单信息不能为空");
|
||||
}
|
||||
Device deviceByCode = deviceAppService.findDeviceByCode(tickets.getDevice_code());
|
||||
|
||||
@@ -23,11 +23,13 @@ import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.system.service.param.ISysParamService;
|
||||
import org.slf4j.MDC;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
@Lazy
|
||||
public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
@Autowired
|
||||
ISysParamService paramService;
|
||||
|
||||
@@ -61,6 +61,7 @@ import org.nl.config.SpringContextHolder;
|
||||
import org.nl.config.language.LangProcess;
|
||||
import org.nl.system.service.param.ISysParamService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
@@ -80,6 +81,7 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
@Lazy
|
||||
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
|
||||
public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> implements TaskService, ApplicationAutoInitial {
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.taskscreen.mapper.TaskScreenMapper;
|
||||
import org.nl.acs.taskscreen.service.TaskScreenService;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -36,6 +37,7 @@ import java.util.List;
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
@Slf4j
|
||||
@Lazy
|
||||
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
|
||||
public class TaskScreenServiceImpl extends CommonServiceImpl<TaskScreenMapper, Device> implements TaskScreenService, ApplicationAutoInitial {
|
||||
|
||||
|
||||
@@ -17,33 +17,9 @@ import java.util.Map;
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum WorkOrderStatusEnum {
|
||||
//分切工单状态
|
||||
CUT_PRODUCT_STATUS(MapOf.of("开始", "01", "配送中", "02", "配送完成", "03", "入站中", "04", "入站完成", "05", "出站中", "06", "结束", "09")),
|
||||
|
||||
//生箔工序工单状态
|
||||
PRODUCT_STATUS(MapOf.of("开始", "01", "空轴搬出", "02", "确认下卷", "03", "下卷完成",
|
||||
"04", "结束", "09")),
|
||||
|
||||
//完成方式
|
||||
FINISH_TYPE(MapOf.of("自动", "01", "手动", "02"));
|
||||
|
||||
|
||||
private Map<String, String> code;
|
||||
|
||||
public String code(String desc) {
|
||||
String code = this.getCode().get(desc);
|
||||
if (StringUtils.isNotEmpty(code)) {
|
||||
return code;
|
||||
}
|
||||
throw new BadRequestException(this.name() + "对应类型" + desc + "未定义");
|
||||
}
|
||||
|
||||
public String check(String code) {
|
||||
for (Map.Entry<String, String> entry : this.getCode().entrySet()) {
|
||||
if (entry.getValue().equals("code")) {
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
throw new BadRequestException(this.name() + "对应类型" + code + "未定义");
|
||||
}
|
||||
UNPRODUCED("0", "未生产"),
|
||||
PRODUCING("1", "生产中"),
|
||||
COMPLETE("2", "完成");
|
||||
private final String code;
|
||||
private final String name;
|
||||
}
|
||||
@@ -90,6 +90,7 @@ public class SendPrintSocket {
|
||||
try {
|
||||
//如果有多个客户端连接一个服务端,只要给一个客户端下发打印即可
|
||||
for (SendPrintSocket printSocket : webSocketSet) {
|
||||
log.info("下发数据给打印机");
|
||||
if (printSocket.session.isOpen()){
|
||||
printSocket.session.getBasicRemote().sendText(print);
|
||||
break;
|
||||
@@ -101,7 +102,4 @@ public class SendPrintSocket {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
SendPrintSocket.sendPrint("xxx");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,76 +1,127 @@
|
||||
package org.nl.common.utils;
|
||||
|
||||
import com.fazecast.jSerialComm.SerialPort;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
@Service
|
||||
@ConditionalOnProperty(prefix = "comPort",name = "need")
|
||||
public class ComPortUtil {
|
||||
|
||||
private static SerialPort serialPort;
|
||||
|
||||
@Value("${comPort.name}")
|
||||
private String cname;
|
||||
@Value("${comPort.newBaudRate}")
|
||||
private static int newBaudRate;
|
||||
@Value("${comPort.newDataBits}")
|
||||
private static int newDataBits;
|
||||
@Value("${comPort.newStopBits}")
|
||||
private static int newStopBits;
|
||||
@Value("${comPort.newParity}")
|
||||
private static int newParity;
|
||||
|
||||
public ComPortUtil() {
|
||||
SerialPort[] commPorts = SerialPort.getCommPorts();
|
||||
if (commPorts ==null || commPorts.length < 1 || StringUtils.isEmpty(cname)){
|
||||
throw new RuntimeException("项目启动失败:无法识别com口信息");
|
||||
}
|
||||
for (SerialPort commPort : commPorts) {
|
||||
if (commPort.getSystemPortName().equals(cname)){
|
||||
serialPort = commPort;
|
||||
}
|
||||
throw new RuntimeException("项目启动失败:没有找到对应com口");
|
||||
}
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
||||
System.out.println("---项目停机执行关闭逻辑---");
|
||||
this.doDestroy();
|
||||
}));
|
||||
}
|
||||
private static void readComMsg(Function function){
|
||||
if (serialPort!=null){
|
||||
try {
|
||||
serialPort.openPort();// 打开串口
|
||||
serialPort.setComPortParameters(newBaudRate, newDataBits, newStopBits, newParity);// 设置串口参数
|
||||
serialPort.setComPortTimeouts(SerialPort.TIMEOUT_READ_SEMI_BLOCKING, 0, 0);
|
||||
byte[] buffer = new byte[1024];
|
||||
while (serialPort.isOpen()){
|
||||
Thread.sleep(500);
|
||||
int bytesRead = serialPort.readBytes(buffer, buffer.length);
|
||||
if (bytesRead > 0) {
|
||||
String msg = new String(buffer, 0, bytesRead);
|
||||
System.out.println("--获取COM口信息--"+msg);
|
||||
if (function != null){
|
||||
function.apply(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (serialPort!=null && serialPort.isOpen()) {
|
||||
serialPort.closePort();// 关闭串口
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void doDestroy(){
|
||||
if (serialPort!=null && serialPort.isOpen()) {
|
||||
serialPort.closePort();// 关闭串口
|
||||
}
|
||||
}
|
||||
}
|
||||
//package org.nl.common.utils;
|
||||
//
|
||||
//import cn.hutool.core.bean.BeanUtil;
|
||||
//import cn.hutool.core.date.DateUtil;
|
||||
//import cn.hutool.core.util.IdUtil;
|
||||
//import com.fazecast.jSerialComm.SerialPort;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.apache.commons.lang3.StringUtils;
|
||||
//import org.nl.system.service.tickets.dto.Tickets;
|
||||
//import org.nl.system.service.tickets.dto.mapper.TicketsMapper;
|
||||
//import org.nl.system.service.weight.dao.Weight;
|
||||
//import org.nl.system.service.weight.dao.mapper.WeightMapper;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.beans.factory.annotation.Value;
|
||||
//import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
//import org.springframework.stereotype.Service;
|
||||
//
|
||||
//import javax.annotation.PostConstruct;
|
||||
//import java.util.function.Function;
|
||||
//
|
||||
//@Service
|
||||
//@Slf4j
|
||||
//@ConditionalOnProperty(prefix = "comPort",name = "need")
|
||||
//public class ComPortUtil {
|
||||
//
|
||||
// private static SerialPort serialPort;
|
||||
//
|
||||
// @Value("${comPort.cname}")
|
||||
// public String cname;
|
||||
// @Value("${comPort.newBaudRate}")
|
||||
// public int newBaudRate;
|
||||
// @Value("${comPort.newDataBits}")
|
||||
// public int newDataBits;
|
||||
// @Value("${comPort.newStopBits}")
|
||||
// public int newStopBits;
|
||||
// @Value("${comPort.newParity}")
|
||||
// public int newParity;
|
||||
// @Autowired
|
||||
// WeightMapper weightMapper;
|
||||
// @Autowired
|
||||
// TicketsMapper ticketsMapper;
|
||||
//
|
||||
// @PostConstruct
|
||||
// public void beanafter() {
|
||||
// log.info("进入串口连接");
|
||||
// SerialPort[] commPorts = SerialPort.getCommPorts();
|
||||
// if (commPorts ==null || commPorts.length < 1 || StringUtils.isEmpty(cname)){
|
||||
// throw new RuntimeException("项目启动失败:无法识别com口信息");
|
||||
// }
|
||||
// for (SerialPort commPort : commPorts) {
|
||||
// System.out.println("串口名称:"+commPort.getSystemPortName());
|
||||
// if (commPort.getSystemPortName().equals(cname)){
|
||||
// serialPort = commPort;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//// if (serialPort ==null){
|
||||
//// throw new RuntimeException("项目启动失败:没有找到对应com口");
|
||||
//// }
|
||||
// Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
||||
// System.out.println("---项目停机执行关闭逻辑---");
|
||||
// this.doDestroy();
|
||||
// }));
|
||||
// readComMsg(null);
|
||||
// }
|
||||
// private void readComMsg(Function function){
|
||||
// if (serialPort!=null){
|
||||
// Thread run = new Thread(()->{
|
||||
// try {
|
||||
// serialPort.openPort();// 打开串口
|
||||
// serialPort.setComPortParameters(newBaudRate, newDataBits, newStopBits, newParity);// 设置串口参数
|
||||
// serialPort.setComPortTimeouts(SerialPort.TIMEOUT_READ_SEMI_BLOCKING, 0, 0);
|
||||
// byte[] buffer = new byte[1024];
|
||||
// System.out.println("---------"+Thread.currentThread().getName());
|
||||
// while (serialPort.isOpen()){
|
||||
// Thread.sleep(500);
|
||||
// int bytesRead = serialPort.readBytes(buffer, buffer.length);
|
||||
// if (bytesRead > 0) {
|
||||
// String msg = new String(buffer, 0, bytesRead);
|
||||
// boolean containsDigit = false;
|
||||
// for (int i = 0; i < msg.length(); i++) {
|
||||
// if (Character.isDigit(msg.charAt(i))) {
|
||||
// containsDigit = true;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// if (containsDigit) {
|
||||
// Weight weight1 = new Weight();
|
||||
// weight1.setWeight_id(IdUtil.getSnowflake(1, 1).nextIdStr());
|
||||
// float weight=Float.parseFloat(msg.replaceAll("[^0-9]", ""));
|
||||
// float realweight=weight/100;
|
||||
// weight1.setReal_weight(String.valueOf(realweight));
|
||||
// String now = DateUtil.now();
|
||||
// weight1.setCreate_time(now);
|
||||
// Tickets tickets=new Tickets();
|
||||
// tickets=ticketsMapper.ticket();
|
||||
// String ticket_code=tickets.getTicket_code();
|
||||
// weight1.setTicket_code(ticket_code);
|
||||
// weightMapper.insert(weight1);
|
||||
// System.out.println("--获取COM口信息--" + msg);
|
||||
// }
|
||||
// if (function != null){
|
||||
// function.apply(msg);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// } finally {
|
||||
// try {
|
||||
// if (serialPort.isOpen()) {
|
||||
// serialPort.closePort(); // 确保关闭串口
|
||||
// }
|
||||
// } catch (Exception ex) {
|
||||
// ex.printStackTrace(); // 处理关闭串口时的异常
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// run.start();
|
||||
// }
|
||||
// }
|
||||
// private void doDestroy(){
|
||||
// if (serialPort!=null && serialPort.isOpen()) {
|
||||
// serialPort.closePort();// 关闭串口
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.nl.common.base.TableDataInfo;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
@@ -28,21 +29,24 @@ public class TemplateController {
|
||||
|
||||
@PostMapping
|
||||
@Log("添加模板")
|
||||
public ResponseEntity<Object> add(@RequestBody Map map) {
|
||||
boolean template_isNot = CollUtil.isNotEmpty(map);
|
||||
if(!template_isNot || StrUtil.isEmpty((String) map.get("template_name"))){
|
||||
throw new RuntimeException("模板名称不能为空");
|
||||
}
|
||||
public ResponseEntity<Object> add(@RequestParam Map<String,String> map) throws JsonProcessingException {
|
||||
templateService.addTemplate(map);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/getTemplateList")
|
||||
@Log("前端打印模板名称下拉选列表")
|
||||
@Log("前端瓶盖打印模板名称下拉选列表")
|
||||
public ResponseEntity<Object> getTemplateList() {
|
||||
return new ResponseEntity<>(templateService.getTemplateList(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/getTemplateList1")
|
||||
@Log("前端纸箱打印模板名称下拉选列表")
|
||||
public ResponseEntity<Object> getTemplateList1() {
|
||||
return new ResponseEntity<>(templateService.getTemplateList1(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/getTicketList")
|
||||
@Log("前端模板需要关联的工单下拉选列表")
|
||||
public ResponseEntity<Object> getTicketList() {
|
||||
|
||||
@@ -13,6 +13,8 @@ import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -44,6 +46,19 @@ public class TicketsController {
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/submits")
|
||||
@Log("工单下发")
|
||||
public ResponseEntity<Object> submits(@RequestBody Tickets entity){
|
||||
ticketsService.submits(entity);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@PostMapping("/finishorder")
|
||||
@Log("工单完成")
|
||||
public ResponseEntity<Object> finishorder(@RequestBody Tickets entity){
|
||||
ticketsService.finishorder(entity);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
@PutMapping
|
||||
@Log("修改工单")
|
||||
public ResponseEntity<Object> update(@RequestBody TicketsDto ticketsDto) {
|
||||
@@ -51,7 +66,7 @@ public class TicketsController {
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("selectOne")
|
||||
@GetMapping("/selectOne")
|
||||
@Log("查询单个工单")
|
||||
public ResponseEntity<Object> getById(@RequestParam String id) {
|
||||
return new ResponseEntity<>(ticketsService.getById(id), HttpStatus.OK);
|
||||
@@ -64,4 +79,10 @@ public class TicketsController {
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("导出每日工单信息")
|
||||
@GetMapping(value = "/download")
|
||||
public void download(HttpServletResponse response, @RequestParam Map whereJson) throws IOException {
|
||||
ticketsService.download(ticketsService.queryAll(whereJson), response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.nl.system.service.template;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.system.service.template.dto.Template;
|
||||
|
||||
@@ -11,7 +12,7 @@ import java.util.Map;
|
||||
public interface TemplateService extends IService<Template> {
|
||||
|
||||
|
||||
void addTemplate(Map map);
|
||||
void addTemplate(Map<String,String> map) throws JsonProcessingException;
|
||||
|
||||
|
||||
Template selectById(String id);
|
||||
@@ -23,6 +24,13 @@ public interface TemplateService extends IService<Template> {
|
||||
*/
|
||||
JSONArray getTemplateList();
|
||||
|
||||
/**
|
||||
* 前端纸箱打印模板名称下拉选列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
JSONArray getTemplateList1();
|
||||
|
||||
/**
|
||||
*前端模板需要关联的工单下拉选列表
|
||||
*
|
||||
|
||||
@@ -34,6 +34,10 @@ public class Template {
|
||||
* 创建人
|
||||
*/
|
||||
private String create_by;
|
||||
/**
|
||||
* 模板类型
|
||||
*/
|
||||
private String template_type;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
|
||||
@@ -15,8 +15,12 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.nl.acs.device.domain.Device;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.mnt.websocket.SendPrintSocket;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.system.service.template.TemplateService;
|
||||
import org.nl.system.service.template.dto.Template;
|
||||
@@ -40,15 +44,24 @@ public class TemplateServiceImpl extends ServiceImpl<TemplateMapper, Template> i
|
||||
private TicketsMapper ticketsMapper;
|
||||
|
||||
@Override
|
||||
public void addTemplate(Map map) {
|
||||
String template_name =(String) map.get("template_name");
|
||||
Map panels=new HashMap();
|
||||
panels.put("panels",map.get("panels"));
|
||||
public void addTemplate(Map<String,String> map) throws JsonProcessingException {
|
||||
String value=null;
|
||||
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||
value=entry.getKey();
|
||||
}
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
JsonNode rootNode = objectMapper.readTree(value);
|
||||
String template_name =rootNode.path("template_name").asText();
|
||||
String templateStatus = rootNode.path("template_status").asText();
|
||||
JsonNode panelsNode = rootNode.path("panels");
|
||||
String panels="{\"panels\":"+ panelsNode+"}";
|
||||
// String replace = panels1.replace("=", ":").substring(1, panels1.length() - 1);
|
||||
Template template = new Template();
|
||||
template.setTemplate_id(RandomUtil.randomNumbers(16));
|
||||
template.setTemplate_name(template_name);
|
||||
template.setTemplate(JSON.toJSONString(panels));
|
||||
template.setTemplate_status(templateStatus);
|
||||
// template.setTemplate(JSON.toJSONString(panels));
|
||||
template.setTemplate(panels);
|
||||
template.setCreate_by(SecurityUtils.getCurrentUsername());
|
||||
template.setCreate_time(DateUtil.now());
|
||||
template.setUpdate_by(SecurityUtils.getCurrentUsername());
|
||||
@@ -92,7 +105,26 @@ public class TemplateServiceImpl extends ServiceImpl<TemplateMapper, Template> i
|
||||
//设备基础信息表【acs_device】
|
||||
// JSONArray arr = WQLObject.getWQLObject("acs_device").query("is_delete= '0' AND is_active= '1' AND device_type = 'conveyor'").getResultJSONArray(0);
|
||||
List<Template> getTemplateList = new LambdaQueryChainWrapper<>(templateMapper)
|
||||
.apply("is_delete= '1'")
|
||||
.apply("is_delete= '1'AND template_status= '1'")
|
||||
.list();
|
||||
JSONArray arr = JSONArray.parseArray(JSON.toJSONString(getTemplateList));
|
||||
JSONArray result = new JSONArray();
|
||||
for (int i = 0; i < arr.size(); i++) {
|
||||
JSONObject obj = arr.getJSONObject(i);
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("template_id", obj.getString("template_id"));
|
||||
json.put("template_name", obj.getString("template_name"));
|
||||
result.add(json);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONArray getTemplateList1() {
|
||||
//设备基础信息表【acs_device】
|
||||
// JSONArray arr = WQLObject.getWQLObject("acs_device").query("is_delete= '0' AND is_active= '1' AND device_type = 'conveyor'").getResultJSONArray(0);
|
||||
List<Template> getTemplateList = new LambdaQueryChainWrapper<>(templateMapper)
|
||||
.apply("is_delete= '1'AND template_status= '2'")
|
||||
.list();
|
||||
JSONArray arr = JSONArray.parseArray(JSON.toJSONString(getTemplateList));
|
||||
JSONArray result = new JSONArray();
|
||||
|
||||
@@ -2,10 +2,14 @@ package org.nl.system.service.tickets;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.nl.acs.address.service.dto.AddressDto;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.system.service.tickets.dto.Tickets;
|
||||
import org.nl.system.service.tickets.dto.TicketsDto;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -33,6 +37,17 @@ public interface TicketsService extends IService<Tickets> {
|
||||
*/
|
||||
void addTicket(Map param);
|
||||
|
||||
/**
|
||||
* 工单下发
|
||||
* @param entity
|
||||
*/
|
||||
void submits(Tickets entity);
|
||||
|
||||
/**
|
||||
* 工单完成
|
||||
* @param entity
|
||||
*/
|
||||
void finishorder(Tickets entity);
|
||||
/**
|
||||
* 修改工单
|
||||
* @param ticketsDto
|
||||
@@ -45,4 +60,21 @@ public interface TicketsService extends IService<Tickets> {
|
||||
* @return
|
||||
*/
|
||||
Tickets selectByTicketCode(String linkTickets);
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
*
|
||||
* @param dtos 待导出的数据
|
||||
* @param response /
|
||||
* @throws IOException /
|
||||
*/
|
||||
void download(List<TicketsDto> dtos, HttpServletResponse response) throws IOException;
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
*
|
||||
* @param whereJson 条件参数
|
||||
* @return List<AddressDto>
|
||||
*/
|
||||
List<TicketsDto> queryAll(Map whereJson);
|
||||
}
|
||||
|
||||
@@ -34,9 +34,9 @@ public class Tickets {
|
||||
*/
|
||||
private String device_code;
|
||||
/**
|
||||
* 生产订单
|
||||
* 生产批次
|
||||
*/
|
||||
private String production_orders;
|
||||
private String actual_batch;
|
||||
/**
|
||||
* 生产物料
|
||||
*/
|
||||
@@ -77,6 +77,14 @@ public class Tickets {
|
||||
* 所属客户
|
||||
*/
|
||||
private String customer;
|
||||
/**
|
||||
* 瓶身关联标签模板
|
||||
*/
|
||||
private String bottle_board;
|
||||
/**
|
||||
* 纸箱关联标签模板
|
||||
*/
|
||||
private String carton_board;
|
||||
/**
|
||||
* 是否装冰
|
||||
*/
|
||||
@@ -89,6 +97,14 @@ public class Tickets {
|
||||
* 瓶身号
|
||||
*/
|
||||
private String bottle_number;
|
||||
/**
|
||||
* 当前瓶身完成数量
|
||||
*/
|
||||
private String fbottle_number;
|
||||
/**
|
||||
* 当前纸箱完成数量
|
||||
*/
|
||||
private String fcarton_number;
|
||||
/**
|
||||
* 纸箱号
|
||||
*/
|
||||
@@ -124,5 +140,16 @@ public class Tickets {
|
||||
* 贴标信息
|
||||
*/
|
||||
private String labeling_message;
|
||||
|
||||
/**
|
||||
* 大型号
|
||||
*/
|
||||
private String large_model;
|
||||
/**
|
||||
* 小型号
|
||||
*/
|
||||
private String small_model;
|
||||
/**
|
||||
* 批次号
|
||||
*/
|
||||
private String batch_number;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ public class TicketsDto {
|
||||
|
||||
private String device_code;
|
||||
|
||||
private String production_orders;
|
||||
private String actual_batch;
|
||||
|
||||
private String production_materials;
|
||||
|
||||
@@ -35,4 +35,19 @@ public class TicketsDto {
|
||||
|
||||
private String weight_ok;
|
||||
|
||||
private String batch_number;
|
||||
|
||||
private String carton_number;
|
||||
|
||||
private String large_model;
|
||||
|
||||
private String small_model;
|
||||
|
||||
private String bottle_board;
|
||||
|
||||
private String carton_board;
|
||||
|
||||
private String fbatch_number;
|
||||
|
||||
private String fcarton_number;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.nl.system.service.tickets.dto.mapper;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.nl.system.service.tickets.dto.Tickets;
|
||||
|
||||
@@ -7,4 +8,8 @@ import org.nl.system.service.tickets.dto.Tickets;
|
||||
* @author LENOVO
|
||||
*/
|
||||
public interface TicketsMapper extends BaseMapper<Tickets> {
|
||||
JSONObject template();
|
||||
JSONObject template1();
|
||||
//获取当前正在生产工单的信息
|
||||
Tickets ticket();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.nl.system.service.tickets.dto.mapper.TicketsMapper">
|
||||
<select id="template" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT te.template
|
||||
FROM `acs_tickets` ti
|
||||
LEFT JOIN acs_template te ON ti.carton_board = te.template_name
|
||||
WHERE ti.ticket_status = '1'
|
||||
AND te.is_delete= '1'
|
||||
LIMIT 1;
|
||||
</select>
|
||||
<select id="template1" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT te.template
|
||||
FROM `acs_tickets` ti
|
||||
LEFT JOIN acs_template te ON ti.bottle_board = te.template_name
|
||||
WHERE ti.ticket_status = '1'
|
||||
AND te.is_delete= '1'
|
||||
LIMIT 1;
|
||||
</select>
|
||||
<select id="ticket" resultType="org.nl.system.service.tickets.dto.Tickets">
|
||||
SELECT *
|
||||
FROM `acs_tickets` ti
|
||||
WHERE ticket_status = '1'
|
||||
AND is_delete= '1'
|
||||
</select>
|
||||
<select id="bottle_number" resultType="org.nl.system.service.tickets.dto.Tickets">
|
||||
SELECT *
|
||||
FROM `acs_tickets` ti
|
||||
WHERE ticket_status = '1'
|
||||
AND te.is_delete= '1'
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -3,19 +3,27 @@ package org.nl.system.service.tickets.impl;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.address.domain.Address;
|
||||
import org.nl.acs.address.service.dto.AddressDto;
|
||||
import org.nl.acs.device.domain.Device;
|
||||
import org.nl.acs.device_driver.conveyor.primary_device.PrimaryDeviceConveyorDeviceDriver;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.utils.ConvertUtil;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.common.utils.CodeUtil;
|
||||
import org.nl.common.utils.FileUtil;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.system.service.param.ISysParamService;
|
||||
import org.nl.system.service.param.dao.Param;
|
||||
@@ -27,6 +35,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
@@ -37,6 +47,7 @@ import java.util.*;
|
||||
* @author LENOVO
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class TicketsServiceImpl extends ServiceImpl<TicketsMapper, Tickets> implements TicketsService {
|
||||
|
||||
|
||||
@@ -54,7 +65,7 @@ public class TicketsServiceImpl extends ServiceImpl<TicketsMapper, Tickets> impl
|
||||
QueryWrapper<Tickets> wrapper = new QueryWrapper<>();
|
||||
if(ObjectUtil.isNotEmpty(param)){
|
||||
wrapper.like(ObjectUtil.isNotEmpty(param.get("ticket_code")),"ticket_code",param.get("ticket_code"))
|
||||
.eq("is_delete","1").le("ticket_status",1);
|
||||
.eq("is_delete","1");
|
||||
wrapper.gt(ObjectUtil.isNotEmpty(param.get("start_time")),"start_time",param.get("start_time"))
|
||||
.le(ObjectUtil.isNotEmpty(param.get("end_time")),"end_time",param.get("end_time"));
|
||||
wrapper.orderByAsc("create_time");
|
||||
@@ -74,58 +85,87 @@ public class TicketsServiceImpl extends ServiceImpl<TicketsMapper, Tickets> impl
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void addTicket(Map param) {
|
||||
public void addTicket(Map param) {
|
||||
if(ObjectUtil.isNotEmpty(param)){
|
||||
String ticket_id = (String)param.get("ticket_code");
|
||||
if(ObjectUtil.isNotEmpty(ticket_id)) {
|
||||
Tickets ticket = getById(ticket_id);
|
||||
if(ObjectUtil.isNotEmpty(ticket)){
|
||||
throw new BadRequestException("工单号已存在");
|
||||
}
|
||||
}else {
|
||||
throw new BadRequestException("工单号不能为空");
|
||||
}
|
||||
String device_code = (String)param.get("device_code");
|
||||
String production_orders = (String)param.get("production_orders");
|
||||
String production_materials = (String)param.get("production_materials");
|
||||
String labeling_message=(String)param.get("labeling_message");
|
||||
String bottle_number=(String)param.get("bottle_number");
|
||||
String carton_number=(String)param.get("carton_number");
|
||||
String carton_form=(String)param.get("carton_form");
|
||||
String carton_qty=(String)param.get("carton_qty");
|
||||
String ticket_status=(String)param.get("ticket_status");
|
||||
String planned_quantity = (String)param.get("planned_quantity");
|
||||
String customer = (String)param.get("customer");
|
||||
// if(StrUtil.isBlank(ticket_id) || StrUtil.isBlank(device_code) || StrUtil.isBlank(production_orders) || StrUtil.isNotEmpty((String)param.get("weight_ok")) ||
|
||||
// StrUtil.isBlank(production_materials) || StrUtil.isBlank(planned_quantity) || StrUtil.isBlank(planned_quantity) || StrUtil.isBlank(customer)){
|
||||
// throw new BadRequestException("参数不能为空");
|
||||
// }
|
||||
String batch_number=(String)param.get("batch_number");
|
||||
String large_model=(String)param.get("large_model");
|
||||
String small_model=(String)param.get("small_model");
|
||||
String bottle_board=(String)param.get("bottle_board");
|
||||
String carton_board=(String)param.get("carton_board");
|
||||
Tickets tickets = BeanUtil.copyProperties(param, Tickets.class);
|
||||
DateTime parse = DateUtil.parse(tickets.getStart_time());
|
||||
DateTime startTime = parse.setTimeZone(TimeZone.getTimeZone(ZoneId.of("Asia/Shanghai")));
|
||||
DateTime end_time = DateUtil.parse(tickets.getEnd_time());
|
||||
DateTime endTime = end_time.setTimeZone(TimeZone.getTimeZone(ZoneId.of("Asia/Shanghai")));
|
||||
tickets.setTicket_id(RandomUtil.randomNumbers(16));
|
||||
tickets.setStart_time(startTime.toString());
|
||||
tickets.setEnd_time(endTime.toString());
|
||||
// DateTime parse = DateUtil.parse(tickets.getStart_time());
|
||||
// DateTime startTime = parse.setTimeZone(TimeZone.getTimeZone(ZoneId.of("Asia/Shanghai")));
|
||||
// DateTime end_time = DateUtil.parse(tickets.getEnd_time());
|
||||
// DateTime endTime = end_time.setTimeZone(TimeZone.getTimeZone(ZoneId.of("Asia/Shanghai")));
|
||||
tickets.setTicket_id(RandomUtil.randomNumbers(8));
|
||||
tickets.setTicket_status("0");
|
||||
tickets.setDevice_code("ZPLC");
|
||||
tickets.setTicket_code(String.valueOf(IdUtil.getSnowflake(1, 1).nextId()));
|
||||
// tickets.setActual_start_time(startTime.toString());
|
||||
// tickets.setActual_end_time(endTime.toString());
|
||||
tickets.setCreate_by(SecurityUtils.getCurrentUsername());
|
||||
tickets.setCreate_time(DateUtil.now());
|
||||
tickets.setFbottle_number("0");
|
||||
tickets.setFcarton_number("0");
|
||||
ticketsMapper.insert(tickets);
|
||||
// String device_code1 = paramService.findByCode("device_code").getValue();
|
||||
// if(StrUtil.isNotBlank(device_code1)){
|
||||
// Device device = deviceAppService.findDeviceByCode(device_code1);
|
||||
// if(StrUtil.isNotBlank(device_code)){
|
||||
// Device device = deviceAppService.findDeviceByCode(device_code);
|
||||
// if(ObjectUtil.isEmpty(device))throw new BadRequestException("请在系统参数中添加设备");
|
||||
// if(device.getDeviceDriver() instanceof PrimaryDeviceConveyorDeviceDriver){
|
||||
// PrimaryDeviceConveyorDeviceDriver primary = (PrimaryDeviceConveyorDeviceDriver) device.getDeviceDriver();
|
||||
// if(primary.getMode() == 2 && primary.getStatus() == 1 && primary.getError() == 0){
|
||||
// primary.setSignal(tickets);
|
||||
// }
|
||||
// Map<String, Object> map = new LinkedHashMap<>();
|
||||
// map.put("to_order_No", ticket_id);
|
||||
// map.put("to_command",100);
|
||||
// primary.writing(map);
|
||||
// log.info("工单下发成功工单号{}",ticket_id);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void submits(Tickets entity) {
|
||||
Tickets tickets=ticketsMapper.selectById(entity.getTicket_id());
|
||||
if(entity.getTicket_status().equals("1")){
|
||||
throw new BadRequestException("当前工单已经下发");
|
||||
}
|
||||
Device device = deviceAppService.findDeviceByCode("ZPLC");
|
||||
if(device.getDeviceDriver() instanceof PrimaryDeviceConveyorDeviceDriver) {
|
||||
PrimaryDeviceConveyorDeviceDriver primary = (PrimaryDeviceConveyorDeviceDriver) device.getDeviceDriver();
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("to_order_No", entity.getTicket_id());
|
||||
map.put("to_ice",entity.getIs_ice());
|
||||
if(StrUtil.isBlank(entity.getBottle_number())){
|
||||
map.put("is_printbottle",0);
|
||||
}else{
|
||||
map.put("is_printbottle",1);
|
||||
}
|
||||
map.put("to_command",100);
|
||||
primary.writing(map);
|
||||
log.info("工单下发成功工单号{}",tickets.getTicket_code());
|
||||
}
|
||||
tickets.setTicket_status("1");
|
||||
tickets.setActual_start_time(DateUtil.now());
|
||||
ticketsMapper.updateById(tickets);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishorder(Tickets entity) {
|
||||
if(!entity.getTicket_status().equals("1")){
|
||||
throw new BadRequestException("当前工单状态不是已开工");
|
||||
}
|
||||
Tickets tickets=ticketsMapper.selectById(entity.getTicket_id());
|
||||
tickets.setTicket_status("2");
|
||||
tickets.setActual_end_time(DateUtil.now());
|
||||
ticketsMapper.updateById(tickets);
|
||||
}
|
||||
@Override
|
||||
public void update(TicketsDto ticketsDto) {
|
||||
Tickets tickets = BeanUtil.copyProperties(ticketsDto, Tickets.class);
|
||||
@@ -139,4 +179,37 @@ public class TicketsServiceImpl extends ServiceImpl<TicketsMapper, Tickets> impl
|
||||
public Tickets selectByTicketCode(String linkTickets) {
|
||||
return getOne(Wrappers.lambdaQuery(Tickets.class).eq(StrUtil.isNotBlank(linkTickets), Tickets::getTicket_code, linkTickets));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(List<TicketsDto> all, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (TicketsDto Tickets : all) {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("客户", Tickets.getCustomer());
|
||||
map.put("实发型号", Tickets.getProduction_materials());
|
||||
map.put("实发批次", Tickets.getActual_batch());
|
||||
map.put("客户", Tickets.getCustomer());
|
||||
map.put("客户", Tickets.getCustomer());
|
||||
map.put("客户", Tickets.getCustomer());
|
||||
map.put("客户", Tickets.getCustomer());
|
||||
map.put("客户", Tickets.getCustomer());
|
||||
map.put("客户", Tickets.getCustomer());
|
||||
map.put("客户", Tickets.getCustomer());
|
||||
map.put("客户", Tickets.getCustomer());
|
||||
map.put("客户", Tickets.getCustomer());
|
||||
map.put("客户", Tickets.getCustomer());
|
||||
list.add(map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TicketsDto> queryAll(Map whereJson) {
|
||||
|
||||
List<Tickets> ticketsList = new LambdaQueryChainWrapper<>(ticketsMapper)
|
||||
.list();
|
||||
return ConvertUtil.convertList(ticketsList,TicketsDto.class);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -23,9 +23,9 @@ public class TicketsVo {
|
||||
*/
|
||||
private String device_code;
|
||||
/**
|
||||
* 生产订单
|
||||
* 生产批次
|
||||
*/
|
||||
private String production_orders;
|
||||
private String actual_batch;
|
||||
/**
|
||||
* 生产物料
|
||||
*/
|
||||
@@ -72,5 +72,17 @@ public class TicketsVo {
|
||||
private String create_by;
|
||||
|
||||
private String create_time;
|
||||
/**
|
||||
* 批次号
|
||||
*/
|
||||
private String batch_number;
|
||||
/**
|
||||
* 大型号
|
||||
*/
|
||||
private String large_model;
|
||||
/**
|
||||
* 小型号
|
||||
*/
|
||||
private String small_model;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
package org.nl.system.service.weight;
|
||||
|
||||
public interface WeightService {
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package org.nl.system.service.weight.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @author zjj
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("acs_weight")
|
||||
public class Weight {
|
||||
/**
|
||||
* 重量id
|
||||
*/
|
||||
@TableId(type = IdType.NONE)
|
||||
private String weight_id;
|
||||
/**
|
||||
* 实时重量
|
||||
*/
|
||||
private String real_weight;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private String create_time;
|
||||
/**
|
||||
* 工单号
|
||||
*/
|
||||
private String ticket_code;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package org.nl.system.service.weight.dao;
|
||||
|
||||
import lombok.*;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class WeightDto {
|
||||
private String weight_id;
|
||||
private String real_weight;
|
||||
private String create_time;
|
||||
private String ticket_code;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package org.nl.system.service.weight.dao.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.nl.system.service.weight.dao.Weight;
|
||||
|
||||
public interface WeightMapper extends BaseMapper<Weight> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.nl.system.service.weight.dao.mapper.WeightMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -18,6 +18,7 @@ https://juejin.cn/post/6844903775631572999
|
||||
<!--<include resource="log/XrToMes.xml"/>
|
||||
<include resource="log/MesToErp.xml"/>-->
|
||||
<include resource="log/XgAgvDeviceDriver.xml"/>
|
||||
<include resource="log/ComPortUtil.xml"/>
|
||||
|
||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<!--withJansi 参数改为true-->
|
||||
@@ -157,44 +158,35 @@ https://juejin.cn/post/6844903775631572999
|
||||
|
||||
<!--生产环境:打印控制台和输出到文件-->
|
||||
<springProfile name="prod">
|
||||
<root level="INFO">
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
<root level="info">
|
||||
<appender-ref ref="asyncLuceneAppender"/>
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
</root>
|
||||
<logger name="org.springframework" level="ERROR" additivity="false">
|
||||
<logger name="jdbc" level="ERROR" additivity="true">
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
</logger>
|
||||
<logger name="org.apache" level="ERROR" additivity="false">
|
||||
<logger name="org.springframework" level="ERROR" additivity="true">
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
</logger>
|
||||
<logger name="org.hibernate" level="ERROR" additivity="false">
|
||||
<logger name="org.hibernate" level="ERROR" additivity="true">
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
</logger>
|
||||
<logger name="io.netty" level="ERROR" additivity="false">
|
||||
<logger name="org.quartz" level="ERROR" additivity="true">
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
</logger>
|
||||
<logger name="jdbc" level="ERROR" additivity="false">
|
||||
<logger name="com.google" level="ERROR" additivity="true">
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
</logger>
|
||||
<logger name="io.lettuce" level="ERROR" additivity="false">
|
||||
<logger name="org.redisson" level="ERROR" additivity="true">
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
</logger>
|
||||
<logger name="com.fasterxml" level="ERROR" additivity="false">
|
||||
<logger name="org.nl.modules.wql" level="ERROR" additivity="true">
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
</logger>
|
||||
<logger name="org.quartz" level="ERROR" additivity="false">
|
||||
<logger name="org.springframework.data" level="ERROR" additivity="true">
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
</logger>
|
||||
<logger name="com.google" level="ERROR" additivity="false">
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
</logger>
|
||||
<logger name="springfox" level="ERROR" additivity="false">
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
</logger>
|
||||
<logger name="log4jdbc" level="ERROR" additivity="false">
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
</logger>
|
||||
<logger name="nl.basjes" level="ERROR" additivity="false">
|
||||
<logger name="org.jinterop" level="ERROR" additivity="true">
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
</logger>
|
||||
</springProfile>
|
||||
|
||||
Reference in New Issue
Block a user