提交代码

dev-discount
胡锐 2 years ago
parent 2203fe2287
commit a0cf36e60b
  1. 9
      hai-bweb/src/main/java/com/bweb/controller/HighOrderController.java
  2. 2
      hai-cweb/src/main/java/com/cweb/controller/HighTestController.java
  3. 4
      hai-schedule/src/main/java/com/hai/schedule/HighGasSchedule.java
  4. 18
      hai-service/src/main/java/com/hai/config/MqttProviderConfig.java
  5. 13
      hai-service/src/main/java/com/hai/config/ZkcPrinterTemplate.java
  6. 4
      hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java

@ -75,7 +75,8 @@ public class HighOrderController {
@RequestMapping(value = "/print", method = RequestMethod.GET) @RequestMapping(value = "/print", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "打印") @ApiOperation(value = "打印")
public ResponseData print(@RequestParam(name = "orderId", required = true) Long orderId) { public ResponseData print(@RequestParam(name = "orderId", required = true) Long orderId,
@RequestParam(name = "printType", required = true) Integer printType) {
try { try {
HighOrder order = highOrderService.getOrderById(orderId); HighOrder order = highOrderService.getOrderById(orderId);
@ -83,11 +84,15 @@ public class HighOrderController {
log.error("HighCouponController -> getCouponList() error!","权限不足"); log.error("HighCouponController -> getCouponList() error!","权限不足");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPETENCE_INSUFFICIENT, ""); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPETENCE_INSUFFICIENT, "");
} }
order.setPrintStatus(true); order.setPrintStatus(true);
order.setPrintNum(order.getPrintNum() + 1); order.setPrintNum(order.getPrintNum() + 1);
highOrderService.updateOrderDetail(order); highOrderService.updateOrderDetail(order);
// 1. 热敏打印机 2. 云打印机
if (printType == 2) {
highOrderService.printGasOrder(order.getHighChildOrderList().get(0).getGoodsId(), order.getOrderNo());
}
return ResponseMsgUtil.success("操作成功"); return ResponseMsgUtil.success("操作成功");
} catch (Exception e) { } catch (Exception e) {

File diff suppressed because one or more lines are too long

@ -151,11 +151,11 @@ public class HighGasSchedule {
} }
} }
@Scheduled(cron = "0 30 7 * * ?") //每日7点1分执行一次 /* @Scheduled(cron = "0 30 7 * * ?") //每日7点1分执行一次
public void refreshPriceOfficial() throws Exception { public void refreshPriceOfficial() throws Exception {
gasOilPriceOfficialService.refreshPriceOfficial(); gasOilPriceOfficialService.refreshPriceOfficial();
gasOilPriceOfficialService.refreshGasPriceOfficial(null, null); gasOilPriceOfficialService.refreshGasPriceOfficial(null, null);
} }*/
} }

@ -11,16 +11,18 @@ import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import java.util.Random;
@Configuration @Configuration
@Slf4j @Slf4j
public class MqttProviderConfig { public class MqttProviderConfig {
@Value("${spring.mqtt.username}") // @Value("${spring.mqtt.username}")
private String username; private String username;
@Value("${spring.mqtt.password}") // @Value("${spring.mqtt.password}")
private String password; private String password;
@Value("${spring.mqtt.url}") // @Value("${spring.mqtt.url}")
private String hostUrl; private String hostUrl;
/* @Value("${spring.mqtt.client.id}") /* @Value("${spring.mqtt.client.id}")
@ -58,7 +60,7 @@ public class MqttProviderConfig {
MqttConnectOptions options = new MqttConnectOptions(); MqttConnectOptions options = new MqttConnectOptions();
//是否清空session,设置false表示服务器会保留客户端的连接记录(订阅主题,qos),客户端重连之后能获取到服务器在客户端断开连接期间推送的消息 //是否清空session,设置false表示服务器会保留客户端的连接记录(订阅主题,qos),客户端重连之后能获取到服务器在客户端断开连接期间推送的消息
//设置为true表示每次连接服务器都是以新的身份 //设置为true表示每次连接服务器都是以新的身份
options.setCleanSession(true); options.setCleanSession(false);
//设置连接用户名 //设置连接用户名
options.setUserName(username); options.setUserName(username);
//设置连接密码 //设置连接密码
@ -67,6 +69,8 @@ public class MqttProviderConfig {
options.setConnectionTimeout(100); options.setConnectionTimeout(100);
//设置心跳时间 单位为秒,表示服务器每隔 1.5*20秒的时间向客户端发送心跳判断客户端是否在线 //设置心跳时间 单位为秒,表示服务器每隔 1.5*20秒的时间向客户端发送心跳判断客户端是否在线
options.setKeepAliveInterval(20); options.setKeepAliveInterval(20);
options.setAutomaticReconnect(false);
// 设置遗嘱消息的话题,若客户端和服务器之间的连接意外断开,服务器将发布客户端的遗嘱信息 // 设置遗嘱消息的话题,若客户端和服务器之间的连接意外断开,服务器将发布客户端的遗嘱信息
// options.setWill("willTopic",(clientId + "与服务器断开连接").getBytes(),0,false); // options.setWill("willTopic",(clientId + "与服务器断开连接").getBytes(),0,false);
//设置回调 //设置回调
@ -88,7 +92,7 @@ public class MqttProviderConfig {
MqttMessage mqttMessage = new MqttMessage(); MqttMessage mqttMessage = new MqttMessage();
mqttMessage.setQos(qos); mqttMessage.setQos(qos);
mqttMessage.setRetained(retained); mqttMessage.setRetained(retained);
mqttMessage.setPayload(message.getBytes("UTF-8")); mqttMessage.setPayload(message.getBytes());
// 主题的目的地,用于发布/订阅信息 // 主题的目的地,用于发布/订阅信息
MqttTopic mqttTopic = client.getTopic(topic); MqttTopic mqttTopic = client.getTopic(topic);
//提供一种机制来跟踪消息的传递进度 //提供一种机制来跟踪消息的传递进度
@ -106,10 +110,6 @@ public class MqttProviderConfig {
} }
} }
public static void main(String[] args) {
System.out.println(sendPrinterRrCodeBytest("1213131", 1));
}
public static byte[] sendPrinterRrCodeBytest(String printText, int pageCount) { public static byte[] sendPrinterRrCodeBytest(String printText, int pageCount) {
try { try {
byte[] by = printText.getBytes(); byte[] by = printText.getBytes();

@ -1,9 +1,12 @@
package com.hai.config; package com.hai.config;
import com.hai.common.utils.DateUtil;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.util.Date;
/** /**
* 商鹏打印机模板 * ZKC云打印机模板
* @author hurui * @author hurui
*/ */
public class ZkcPrinterTemplate { public class ZkcPrinterTemplate {
@ -37,7 +40,7 @@ public class ZkcPrinterTemplate {
stream.write(gasName.getBytes("UTF-8")); stream.write(gasName.getBytes("UTF-8"));
stream.write(0x0A); stream.write(0x0A);
stream.write("(收银员)".getBytes("UTF-8")); stream.write("(收银员存根)".getBytes("UTF-8"));
stream.write(0x0A); stream.write(0x0A);
// 左对齐 // 左对齐
@ -70,9 +73,6 @@ public class ZkcPrinterTemplate {
stream.write("实际加油升数以加油机为准!".getBytes("UTF-8")); stream.write("实际加油升数以加油机为准!".getBytes("UTF-8"));
stream.write(0x0A); stream.write(0x0A);
stream.write("--------------------------------".getBytes("UTF-8"));
stream.write(0x0A);
stream.write(0x1B); stream.write(0x1B);
stream.write(0x0E); stream.write(0x0E);
@ -161,9 +161,6 @@ public class ZkcPrinterTemplate {
stream.write("实际加油升数以加油机为准!".getBytes("UTF-8")); stream.write("实际加油升数以加油机为准!".getBytes("UTF-8"));
stream.write(0x0A); stream.write(0x0A);
stream.write("--------------------------------".getBytes("UTF-8"));
stream.write(0x0A);
stream.write(0x1B); stream.write(0x1B);
stream.write(0x0E); stream.write(0x0E);

@ -1717,7 +1717,7 @@ public class HighOrderServiceImpl implements HighOrderService {
String oilCashierStubTempText = ZkcPrinterTemplate.oilCashierStubTemp( String oilCashierStubTempText = ZkcPrinterTemplate.oilCashierStubTemp(
childOrder.getGoodsName(), childOrder.getGoodsName(),
order.getOrderNo(), order.getOrderNo(),
DateUtil.date2String(new Date(), "yyyy-MM-dd HH:mm:ss"), DateUtil.date2String(order.getPayTime(), "yyyy-MM-dd HH:mm:ss"),
"嗨森逛", "嗨森逛",
childOrder.getGasGunNo(), childOrder.getGasGunNo(),
childOrder.getGasOilNo(), childOrder.getGasOilNo(),
@ -1730,7 +1730,7 @@ public class HighOrderServiceImpl implements HighOrderService {
String oilClientStubTempText = ZkcPrinterTemplate.oilClientStubTemp( String oilClientStubTempText = ZkcPrinterTemplate.oilClientStubTemp(
childOrder.getGoodsName(), childOrder.getGoodsName(),
order.getOrderNo(), order.getOrderNo(),
DateUtil.date2String(new Date(), "yyyy-MM-dd HH:mm:ss"), DateUtil.date2String(order.getPayTime(), "yyyy-MM-dd HH:mm:ss"),
"嗨森逛", "嗨森逛",
childOrder.getGasGunNo(), childOrder.getGasGunNo(),
childOrder.getGasOilNo(), childOrder.getGasOilNo(),

Loading…
Cancel
Save